feat(plugins): add native support for .ps1 PowerShell plugins #50#54
Conversation
|
I need screenshots of executed code before merging |
|
It's not merged |
|
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 |
… variable collision in plugin.ps1
|
Hi @DotDev262 ,Just updated the branch with the logging changes you asked for. I injected Also noticed a bug in I also added two more tests in Here's what the clean execution output looks like now: |
|
Hi @DotDev262 , the PR has been merged and everything is completed now 😄,as you asked for |
|
thanks for adding the 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! |

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