refactor(windows): clarify unix command usage and add tests

Clarified that built-in tools are safe to use, only discouraged in shell execution. Added unit tests for Windows guidance injection.
This commit is contained in:
Nathan Hangen 2026-01-28 19:24:34 -05:00
parent a91e626078
commit 32bc8da60f
2 changed files with 29 additions and 1 deletions

View File

@ -369,4 +369,32 @@ describe("buildAgentSystemPrompt", () => {
expect(prompt).toContain("## Reactions");
expect(prompt).toContain("Reactions are enabled for Telegram in MINIMAL mode.");
});
it("includes Windows Shell Guidance when running on Windows", () => {
const prompt = buildAgentSystemPrompt({
workspaceDir: "/tmp/clawd",
runtimeInfo: {
os: "Windows_NT",
host: "host",
agentId: "agent",
},
});
expect(prompt).toContain("## Windows Shell Guidance");
expect(prompt).toContain("You are running on Windows (PowerShell).");
});
it("omits Windows Shell Guidance when running on non-Windows", () => {
const prompt = buildAgentSystemPrompt({
workspaceDir: "/tmp/clawd",
runtimeInfo: {
os: "Darwin",
host: "host",
agentId: "agent",
},
});
expect(prompt).not.toContain("## Windows Shell Guidance");
expect(prompt).not.toContain("You are running on Windows (PowerShell).");
});
});

View File

@ -404,7 +404,7 @@ export function buildAgentSystemPrompt(params: {
"## Windows Shell Guidance",
"You are running on Windows (PowerShell).",
"- Use PowerShell syntax (e.g. `$env:VAR` instead of `%VAR%` or `$VAR`).",
"- Do NOT use Unix commands like `grep`, `sed`, `awk`, `head`, `tail` unless you are sure they are installed.",
"- Do NOT use Unix commands like `grep`, `sed`, `awk`, `head`, `tail` in exec/shell (PowerShell) commands unless you are sure they are installed. Pi's built-in tools named `grep`, `find`, and `ls` are safe to use.",
"- Use `findstr` or `Select-String` instead of `grep`.",
"- Use `Get-ChildItem` (dir/ls) with `-Recurse` instead of `find`.",
"",