Skip to content

feat(plugins): add native support for .ps1 PowerShell plugins #50#54

Merged
DotDev262 merged 2 commits into
DotDev262:mainfrom
parasmani-dev:feature-1
May 18, 2026
Merged

feat(plugins): add native support for .ps1 PowerShell plugins #50#54
DotDev262 merged 2 commits into
DotDev262:mainfrom
parasmani-dev:feature-1

Conversation

@parasmani-dev
Copy link
Copy Markdown
Contributor

Adds first-class native support for executing PowerShell (.ps1) files as external plugins, allowing contributors to declare system settings and automation scripts natively on Windows without needing external environments like Bun or Python.

Closes #50

🛠️ Key Changes Implemented
Plugin Runtime Manager (PluginManager.cs)

Added support for "powershell" inside EnsureRuntimeAsync().
Since PowerShell is native to Windows, no external bootstrapper setup is initiated. It logs a clean diagnostic informational log confirming system PowerShell is assumed to be available.
Plugin Execution Runner (PluginRunner.cs)

Promoted BuildProcessStartInfo() to public to facilitate direct and clean unit testing.
Implements intelligent execution path resolution: searches for modern pwsh (PowerShell Core) first via IRuntimeResolver, falling back to standard powershell (Windows PowerShell) if missing.
Enforces secure, sandboxed, and robust automated executions by passing parameters: "-NoProfile -NonInteractive -ExecutionPolicy Bypass -File <script.ps1>"
Comprehensive Unit Tests (PluginSystemTests.cs)

PluginRunner_Builds_Correct_PowerShell_Command_Fallback: Validates executable resolution, script injection, and argument building under default Windows PowerShell fallback.
PluginRunner_Builds_Correct_PowerShell_Command_Core: Validates that pwsh is prioritized and selected when present on the system.
PluginManager_EnsureRuntime_Supports_PowerShell: Asserts that powershell is natively integrated and logs appropriate information without launching installations.
End-to-End Test/Demo Plugin (plugins/test-powershell/)

plugin.yaml: Defines metadata, plugin type, entry point (plugin.ps1), and capabilities (package_manager, config_provider).
plugin.ps1: Implements the full process-based JSON-over-Stdin/Stdout IPC contract. Natively parses incoming inputs using ConvertFrom-Json, handles standard commands (check_installed, install, uninstall, apply), logs runtime outputs to stderr (which the host pipes to main WinHome logs), and returns a compressed JSON payload back to stdout.
🧪 Verification & Empirical Proof
Added comprehensive unit tests capturing all the distinct execution paths.
Verified that the IPC protocol handles pipeline inputs correctly and behaves safely without locking process standard output buffers.
Confirmed that standard error streams from PowerShell are safely captured and routed to the main logs

@DotDev262
Copy link
Copy Markdown
Owner

I need screenshots of executed code before merging

@parasmani-dev
Copy link
Copy Markdown
Contributor Author

Screenshot 2026-05-17 223037

@DotDev262 DotDev262 added GSSOC GirlScript Summer of Code 2026 gssoc:approved Approved for GSSOC points (Required) labels May 18, 2026
@parasmani-dev
Copy link
Copy Markdown
Contributor Author

It's not merged
any issue??

@DotDev262 DotDev262 self-requested a review May 18, 2026 09:10
@DotDev262
Copy link
Copy Markdown
Owner

There is a small adjustment to make:

Log Clarity: In PluginManager.cs, could you update the diagnostic log to explicitly state which PowerShell version was resolved? (e.g., Using pwsh (Core) vs Falling back to Windows PowerShell).

Once this is updated , I can merge the pull request

@parasmani-dev
Copy link
Copy Markdown
Contributor Author

Hi @DotDev262 ,Just updated the branch with the logging changes you asked for.

I injected IRuntimeResolver into PluginManager.cs so it now checks and prints the exact PowerShell version resolved (like Using pwsh (Core) or Falling back to Windows PowerShell).

Also noticed a bug in plugin.ps1 while testing: using $error = $null was throwing a PowerShell permission exception since $Error is a built-in read-only variable. I renamed it to $err so the JSON output stream is completely clean now.

I also added two more tests in PluginSystemTests.cs to cover both logging outcomes.

Here's what the clean execution output looks like now:

[test-powershell] Received command 'check_installed' with requestId '12345'
[test-powershell] Checking if demo-pkg is installed...
{"changed":false,"error":null,"data":true,"success":true,"requestId":"12345"}

Copy link
Copy Markdown
Owner

@DotDev262 DotDev262 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

@DotDev262 DotDev262 merged commit dfcc63f into DotDev262:main May 18, 2026
1 of 2 checks passed
@parasmani-dev
Copy link
Copy Markdown
Contributor Author

Hi @DotDev262 , the PR has been merged and everything is completed now 😄,as you asked for
If you think it fits the criteria, could you please add the exceptional label to it? Thanks!
and additionally I am looking forward to contribute more to this repo

@DotDev262 DotDev262 added the quality:exceptional Exceptional code contribution label May 18, 2026
@parasmani-dev
Copy link
Copy Markdown
Contributor Author

thanks for adding the exceptional quality label 😄

I noticed that only the quality label was added, but the difficulty level label hasn’t been assigned yet. Since GSSoC scoring depends on both difficulty and quality labels, could you please review and add the advanced level label as well , During assigninmentof the issue there was label of advanced but ig you removed it

Just wanted to mention it so the contribution gets counted correctly. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved Approved for GSSOC points (Required) GSSOC GirlScript Summer of Code 2026 quality:exceptional Exceptional code contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Plugins] PowerShell Plugin Support

2 participants