Skip to content

Commit dfe2c29

Browse files
author
SqlRush
committed
Classify PowerShell job aliases
1 parent 5928089 commit dfe2c29

4 files changed

Lines changed: 16 additions & 1 deletion

File tree

docs/cc-100-roadmap.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ M5 补充:PowerShell command canonicalization 现在补齐 mutating service al
187187

188188
M5 补充:PowerShell destructive classifier 现在明确覆盖 `Stop-Computer``Suspend-Computer` 和 native `shutdown(.exe)`,这类关机/休眠路径不再落入未知普通命令分类。
189189

190+
M5 补充:PowerShell command canonicalization 现在补齐 mutating job aliases:`sajb`/`spjb`/`rjb` 会分别归入 `Start/Stop/Remove-Job` destructive 分类,避免后台 job 创建、停止和删除 alias 被当成未知普通命令。
191+
190192
M5 补充:WebFetch HTML-to-text rendering 现在会跳过 `hidden``aria-hidden="true"`、CSS `display:none`/`visibility:hidden` 的不可见元素子树,隐藏文本和图片说明不会进入 rendered body 或 prompt-focused excerpt。
191193

192194
M5 补充:WebFetch HTML-to-text rendering 现在会为无可见文本但带 `aria-label`/`title` 的链接保留可访问名称和 resolved href,icon-only 链接可进入 rendered body 与 prompt-focused excerpt。

docs/claude-code-go-rewrite-plan.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ test/parity/ # golden tests against TS/official behavior
255255
- 本轮补充:PowerShell command canonicalization 现在补齐 mutating ItemProperty aliases:`sp`/`np`/`clp`/`cpp`/`mp`/`rp`/`rnp` 会分别归入 `Set/New/Clear/Copy/Move/Remove/Rename-ItemProperty` destructive 分类,避免属性变更 alias 被当成未知普通命令。
256256
- 本轮补充:PowerShell command canonicalization 现在补齐 mutating service aliases:`sasv`/`spsv`/`rsv`/`ssv` 会分别归入 `Start/Stop/Restart/Set-Service` destructive 分类,避免服务状态或配置变更 alias 被当成未知普通命令。
257257
- 本轮补充:PowerShell destructive classifier 现在明确覆盖 `Stop-Computer``Suspend-Computer` 和 native `shutdown(.exe)`,这类关机/休眠路径不再落入未知普通命令分类。
258+
- 本轮补充:PowerShell command canonicalization 现在补齐 mutating job aliases:`sajb`/`spjb`/`rjb` 会分别归入 `Start/Stop/Remove-Job` destructive 分类,避免后台 job 创建、停止和删除 alias 被当成未知普通命令。
258259
- 本轮补充:`BashOutput` 现在设置 100k 最大结果大小,和前台 `Bash` 一起覆盖大输出 tool-result preview 截断、完整输出落盘及 `full_output_path` 元数据。
259260
- 本轮补充:Bash/PowerShell 后台命令现在会通过 tool progress 通道发 started/finished 事件,记录后台 ID、shell/status、exit/timed_out/cancelled、duration、时间戳和 stdout/stderr byte count,且 completed、timed_out、cancelled 终态测试确保 progress 不携带 command 文本。
260261
- 本轮补充:WebSearch domain filters 现在在 schema 层声明 array `items:string`,通用 tool schema validator 同步支持 `items` 校验;`allowed_domains`/`blocked_domains` 会拒绝空字符串、URL/port、非法 wildcard 和非域名 label。

internal/tools/powershell/tools.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2146,7 +2146,7 @@ func destructiveWords(words []string) bool {
21462146
switch command {
21472147
case "git":
21482148
return bashtools.IsDestructiveCommand(powerShellGitCommand(words))
2149-
case "remove-item", "set-content", "add-content", "clear-content", "clear-item", "clear-itemproperty", "out-file", "new-item", "move-item", "move-itemproperty", "copy-item", "copy-itemproperty", "rename-item", "rename-itemproperty", "set-item", "set-itemproperty", "stop-process", "start-service", "stop-service", "restart-service", "set-service", "restart-computer", "stop-computer", "suspend-computer", "shutdown", "invoke-expression", "iex", "start-process", "start-transcript", "stop-transcript":
2149+
case "remove-item", "set-content", "add-content", "clear-content", "clear-item", "clear-itemproperty", "out-file", "new-item", "move-item", "move-itemproperty", "copy-item", "copy-itemproperty", "rename-item", "rename-itemproperty", "set-item", "set-itemproperty", "start-job", "stop-job", "remove-job", "stop-process", "start-service", "stop-service", "restart-service", "set-service", "restart-computer", "stop-computer", "suspend-computer", "shutdown", "invoke-expression", "iex", "start-process", "start-transcript", "stop-transcript":
21502150
return true
21512151
default:
21522152
return strings.HasPrefix(command, "remove-") || strings.HasPrefix(command, "set-") || strings.HasPrefix(command, "new-") || strings.HasPrefix(command, "export-")
@@ -2279,6 +2279,12 @@ func powerShellAliasTarget(name string) string {
22792279
return "restart-service"
22802280
case "ssv":
22812281
return "set-service"
2282+
case "sajb":
2283+
return "start-job"
2284+
case "spjb":
2285+
return "stop-job"
2286+
case "rjb":
2287+
return "remove-job"
22822288
case "gal":
22832289
return "get-alias"
22842290
case "gdr":

internal/tools/powershell/tools_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,12 @@ func TestPowerShellCommandClassification(t *testing.T) {
571571
"Stop-Process -Id 1",
572572
"kill -Id 1",
573573
"spps -Id 1",
574+
"Start-Job -ScriptBlock { Get-Process }",
575+
"sajb -ScriptBlock { Get-Process }",
576+
"Stop-Job -Id 1",
577+
"spjb -Id 1",
578+
"Remove-Job -Id 1",
579+
"rjb -Id 1",
574580
"Start-Service -Name spooler",
575581
"sasv -Name spooler",
576582
"Stop-Service -Name spooler",

0 commit comments

Comments
 (0)