For agentic workers: REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (
- [ ]) syntax for tracking.
Goal: Make ZCode Bash read-only permission classification conservative and keep it independent from cwd persistence.
Architecture: Keep using unbash for AST parsing, then apply a conservative safety layer over parsed simple commands, redirects, assignments, and argv. Bash read-only classification may grant plan-mode permission and concurrency safety, but it must not decide whether a successful Bash call persists cwd.
Tech Stack: TypeScript, Vitest, unbash, @zcode/core permission service, Bash tool handler.
Glob/Grep tools to work around this bug.不要自动提交 still applies.command, builtin, and noglob.cat, head, tail, wc, stat, strings, file, grep, egrep, fgrep, rg, find, ls, tree, du, diff, pwd, whoami, and trivial commands such as echo, printf, true, and false.find is safe only when write/execution options such as -delete, -exec, -execdir, -ok, -okdir, -fprint, -fprint0, -fls, -fprintf, and -files0-from are absent.cd/pushd/popd combined with git requires permission checks rather than automatic read-only allow./dev/null output is safe, but regular output redirects, /dev/tcp, /dev/udp, and Windows/UNC read redirects are unsafe.apps/zcode-cli/packages/core/src/tool/handlers/bash-command-parser.ts so each BashCommandInvocation exposes normalized redirects and assignment names, not just boolean flags.find/git guards.apps/zcode-cli/packages/core/src/tool/handlers/bash-readonly-policy.ts as the small public entrypoint.bash-readonly-policy-types.ts: shared policy types.bash-readonly-policy-flags.ts: safe flag/value tables.bash-readonly-policy-callbacks.ts: per-command dangerous-argument callbacks.bash-readonly-policy-commands.ts: command policy maps and allowlists.bash-readonly-policy-argv.ts: argv, redirect, env, wrapper, and git evaluation.apps/zcode-cli/packages/core/src/tool/handlers/bash-semantics.ts so isRuntimeReadOnlyBashCommand() checks all parsed simple commands using the readonly policy.isBashReadOnlyCommand() and concurrency safety share the same safety contract.apps/zcode-cli/packages/core/src/tool/handlers/bash.ts so successful foreground main-thread Bash always calls decideBashCwdPolicy(...), including commands that were classified as read-only.runtimeScope.apps/zcode-cli/packages/core/tests/bash-permission.test.ts for safe read/search/list commands, safe redirects, wrapper stripping, denied dynamic/assignment/write cases, denied cd && git, and denied write redirects.apps/zcode-cli/packages/core/tests/bash-handler.test.ts proving read-only classification does not suppress main-thread cwd persistence.pnpm --filter @zcode/core typecheck.pnpm lint; note unrelated failures if present.pnpm --filter @zcode/core exec vitest run tests/bash-permission.test.ts tests/bash-handler.test.ts passed.pnpm --filter @zcode/core typecheck passed.oxfmt --check on touched Bash files and this plan passed.pnpm lint passed with existing warnings only.pnpm typecheck still fails in packages/desktop/test/e2e/reporting/e2e-ui-coverage.ts because the existing Istanbul packages lack local declarations and several callback parameters are implicit any.