Skip to content

Commit 0cdafa2

Browse files
author
SqlRush
committed
Support PowerShell Get-Content First alias
1 parent ee8b313 commit 0cdafa2

4 files changed

Lines changed: 8 additions & 2 deletions

File tree

docs/cc-100-roadmap.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,8 @@ M5 补充:PowerShell native read-only classifier 现在覆盖 Windows `sort.ex
221221

222222
M5 补充:PowerShell native read-only classifier 现在覆盖显式 `more.com <path>` 的安全相对路径读取子集,并拒绝裸 `more`、空输入、pass-through 和越界路径。
223223

224+
M5 补充:PowerShell read-only classifier 现在把 `Get-Content -First` 作为 `-TotalCount`/`-Head` 的安全读取 alias 处理,保留缺值和越界路径拒绝。
225+
224226
M5 补充:Bash 前台输出和 `BashOutput` 现在都走统一 tool-result budget 截断/落盘路径;`BashOutput` 增加 100k 最大结果限制,大后台输出会保存完整内容并返回 `full_output_path` 元数据。
225227

226228
M5 补充:Bash/PowerShell 后台任务现在会发 `*_background_started``*_background_finished` tool progress 事件,包含后台 ID、shell/status、exit/timed_out/cancelled、duration、时间戳和输出字节数,不携带 command 文本;completed、timed_out、cancelled 终态均已覆盖测试。

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ test/parity/ # golden tests against TS/official behavior
222222
- 本轮补充:PowerShell command canonicalization 现在补齐 `Compare-Object` 的常见 `compare`/`diff` alias,同时继续保留 `diff.exe` 这类原生命令后缀,避免外部命令误套 cmdlet 分类。
223223
- 本轮补充:PowerShell native read-only classifier 现在覆盖 Windows `sort.exe <path>`/`sort.exe /R <path>` 的安全相对路径读取子集,并拒绝空输入、`/O` 输出文件、pass-through 和越界路径。
224224
- 本轮补充:PowerShell native read-only classifier 现在覆盖显式 `more.com <path>` 的安全相对路径读取子集,并拒绝裸 `more`、空输入、pass-through 和越界路径。
225+
- 本轮补充:PowerShell read-only classifier 现在把 `Get-Content -First` 作为 `-TotalCount`/`-Head` 的安全读取 alias 处理,保留缺值和越界路径拒绝。
225226
- 本轮补充:`BashOutput` 现在设置 100k 最大结果大小,和前台 `Bash` 一起覆盖大输出 tool-result preview 截断、完整输出落盘及 `full_output_path` 元数据。
226227
- 本轮补充:Bash/PowerShell 后台命令现在会通过 tool progress 通道发 started/finished 事件,记录后台 ID、shell/status、exit/timed_out/cancelled、duration、时间戳和 stdout/stderr byte count,且 completed、timed_out、cancelled 终态测试确保 progress 不携带 command 文本。
227228
- 本轮补充: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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,10 +1217,10 @@ var powerShellReadOnlyCmdlets = map[string]powerShellReadOnlyConfig{
12171217
validatePositionalsAsPaths: true,
12181218
},
12191219
"get-content": {
1220-
allowedFlags: stringSet("path", "literalpath", "totalcount", "head", "tail", "raw", "encoding", "delimiter", "readcount"),
1220+
allowedFlags: stringSet("path", "literalpath", "totalcount", "head", "first", "tail", "raw", "encoding", "delimiter", "readcount"),
12211221
unsafeFlags: stringSet("wait"),
12221222
pathFlags: stringSet("path", "literalpath"),
1223-
valueFlags: stringSet("totalcount", "head", "tail", "encoding", "delimiter", "readcount"),
1223+
valueFlags: stringSet("totalcount", "head", "first", "tail", "encoding", "delimiter", "readcount"),
12241224
validatePositionalsAsPaths: true,
12251225
},
12261226
"get-item": {

internal/tools/powershell/tools_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ func TestPowerShellCommandClassification(t *testing.T) {
110110
"Get-Content -Encoding UTF8 README.md",
111111
"Get-Content -ReadCount 0 README.md",
112112
"Get-Content -Tail 10 README.md",
113+
"Get-Content -First 5 README.md",
113114
`Get-Content .\README.md`,
114115
"type README.md",
115116
"gi README.md",
@@ -277,6 +278,8 @@ func TestPowerShellCommandClassification(t *testing.T) {
277278
"Get-Content -Credential admin README.md",
278279
"Get-Content -Raw:unexpected README.md",
279280
"Get-Content -Encoding",
281+
"Get-Content -First",
282+
"Get-Content -First 5 /etc/passwd",
280283
"Get-ChildItem -Credential admin ./internal",
281284
"Select-String -Pattern TODO -Path /etc/passwd",
282285
"Get-Process -ComputerName server",

0 commit comments

Comments
 (0)