Skip to content

Commit 8deeb13

Browse files
committed
fix(skills): add help handler to standalone browser/desktop/system
Mirrors the outlook fix so every skill script behaves consistently. Without this, `.\skills\browser\browser.ps1 help` (etc.) fell through to the `default` switch case and threw "Unknown action: help" instead of returning a proper help payload. Each script now: - Short-circuits `help`, `""`, and `list-actions` before touching CDP, Win32 APIs, or any other side-effect setup. - Returns the parsed SKILL.md content plus the list of supported actions. - Records $script:SkillDir once at parse time so the help branch can locate SKILL.md from inside the Invoke-*Action function. - Lists `help` in the "Unknown action" error message for discoverability.
1 parent d6d0fbb commit 8deeb13

3 files changed

Lines changed: 39 additions & 3 deletions

File tree

skills/browser/browser.ps1

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ param(
1515

1616
# ─── Standalone bootstrap ───
1717
$_standalone = (-not $Args_ -or $Args_.Count -eq 0) -and -not (Get-Variable -Name SkillsRoot -Scope Script -ErrorAction SilentlyContinue)
18+
$script:SkillDir = Split-Path -Parent $MyInvocation.MyCommand.Path
1819
if ($_standalone) {
1920
. (Join-Path (Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path))) "lib\bootstrap.ps1")
2021
if ($Rest) { $Args_ = Parse-CliArgs -Arguments $Rest } else { $Args_ = @{} }
@@ -77,6 +78,17 @@ function Send-CDP {
7778

7879
# ─── Main logic ───
7980
function Invoke-BrowserAction {
81+
# Help / list-actions do NOT need a CDP connection.
82+
if ($Action -eq "help" -or $Action -eq "" -or $Action -eq "list-actions") {
83+
$skillMd = Join-Path $script:SkillDir "SKILL.md"
84+
$help = if (Test-Path $skillMd) { [string](Get-Content $skillMd -Raw) } else { "" }
85+
return @{
86+
skill = "browser"
87+
help = $help
88+
actions = @("tabs", "navigate", "screenshot", "content", "html", "evaluate", "click", "type", "new-tab", "close-tab", "scroll", "fill", "wait", "help", "list-actions")
89+
}
90+
}
91+
8092
switch ($Action) {
8193
"tabs" {
8294
$targets = Get-Targets
@@ -183,7 +195,7 @@ function Invoke-BrowserAction {
183195
return @{ waited = $seconds }
184196
}
185197
default {
186-
throw "Unknown action: $Action. Use: tabs, navigate, screenshot, content, html, evaluate, click, type, new-tab, close-tab, scroll, fill, wait"
198+
throw "Unknown action: $Action. Use: tabs, navigate, screenshot, content, html, evaluate, click, type, new-tab, close-tab, scroll, fill, wait, help"
187199
}
188200
}
189201
}

skills/desktop/desktop.ps1

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ param(
1515

1616
# ─── Standalone bootstrap ───
1717
$_standalone = (-not $Args_ -or $Args_.Count -eq 0) -and -not (Get-Variable -Name SkillsRoot -Scope Script -ErrorAction SilentlyContinue)
18+
$script:SkillDir = Split-Path -Parent $MyInvocation.MyCommand.Path
1819
if ($_standalone) {
1920
. (Join-Path (Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path))) "lib\bootstrap.ps1")
2021
if ($Rest) { $Args_ = Parse-CliArgs -Arguments $Rest } else { $Args_ = @{} }
@@ -74,6 +75,17 @@ function Find-Window {
7475

7576
# ─── Main logic ───
7677
function Invoke-DesktopAction {
78+
# Help / list-actions do NOT need any Win32 or graphics setup.
79+
if ($Action -eq "help" -or $Action -eq "" -or $Action -eq "list-actions") {
80+
$skillMd = Join-Path $script:SkillDir "SKILL.md"
81+
$help = if (Test-Path $skillMd) { [string](Get-Content $skillMd -Raw) } else { "" }
82+
return @{
83+
skill = "desktop"
84+
help = $help
85+
actions = @("screenshot", "windows", "focus", "minimize", "maximize", "keys", "launch", "help", "list-actions")
86+
}
87+
}
88+
7789
switch ($Action) {
7890
"screenshot" {
7991
$outFile = $Args_.'out-file'
@@ -172,7 +184,7 @@ function Invoke-DesktopAction {
172184
return @{ launched = $Args_.app }
173185
}
174186
default {
175-
throw "Unknown action: $Action. Use: screenshot, windows, focus, minimize, maximize, keys, launch"
187+
throw "Unknown action: $Action. Use: screenshot, windows, focus, minimize, maximize, keys, launch, help"
176188
}
177189
}
178190
}

skills/system/system.ps1

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ param(
1515

1616
# ─── Standalone bootstrap ───
1717
$_standalone = (-not $Args_ -or $Args_.Count -eq 0) -and -not (Get-Variable -Name SkillsRoot -Scope Script -ErrorAction SilentlyContinue)
18+
$script:SkillDir = Split-Path -Parent $MyInvocation.MyCommand.Path
1819
if ($_standalone) {
1920
. (Join-Path (Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path))) "lib\bootstrap.ps1")
2021
if ($Rest) { $Args_ = Parse-CliArgs -Arguments $Rest } else { $Args_ = @{} }
@@ -25,6 +26,17 @@ $defaultTimeout = if ($Config.default_timeout) { [int]$Config.default_timeout }
2526

2627
# ─── Main logic ───
2728
function Invoke-SystemAction {
29+
# Help / list-actions do NOT need any system probing.
30+
if ($Action -eq "help" -or $Action -eq "" -or $Action -eq "list-actions") {
31+
$skillMd = Join-Path $script:SkillDir "SKILL.md"
32+
$help = if (Test-Path $skillMd) { [string](Get-Content $skillMd -Raw) } else { "" }
33+
return @{
34+
skill = "system"
35+
help = $help
36+
actions = @("exec", "info", "processes", "env", "help", "list-actions")
37+
}
38+
}
39+
2840
switch ($Action) {
2941
"exec" {
3042
$command = $Args_.command
@@ -79,7 +91,7 @@ function Invoke-SystemAction {
7991
return @{ name = $name; value = $val }
8092
}
8193
default {
82-
throw "Unknown action: $Action. Use: exec, info, processes, env"
94+
throw "Unknown action: $Action. Use: exec, info, processes, env, help"
8395
}
8496
}
8597
}

0 commit comments

Comments
 (0)