Goal: 实现 shell init snapshot 策略:首次 Bash toolcall 用 login shell 生成真实 .sh snapshot,后续 source snapshot 后跳过 -l。
Scope: 只影响 Bash tool runtime。provider-visible content、tool exposure、tool description、Explore/Main/Plan system prompt 不因本计划变化。
shellPath -c -l <snapshot creation script>。SHELL=shellPath、GIT_EDITOR=true。unlink(snapshotPath)。["-c", command],不可访问则 fallback 到 ["-c", "-l", command]。shell-snapshots/ 顶层超过默认 30 天 cutoff 的 .sh 文件。shell-snapshots/snapshot-${shell}-${timestamp}-${random}.sh。undefined,后续继续 login shell fallback。NodeExecutionAdapter.close() 中 cleanup。.sh。.sh,执行顺序是:source shell init snapshot -> source ZCode startup script -> user command -> cwd capture trailer。shell-init-snapshot.ts
getOrCreate() 只返回 ready snapshot 或 undefined。windowsPathToGitBashPath()。index.ts
-l。bash-startup-script.ts
docs/runtime-tools/bash-effective-shell-snapshot.md。pnpm --dir apps/zcode-cli --filter @zcode/adapters exec vitest run \
tests/shell-init-snapshot.test.ts \
tests/shell-init-snapshot-cleanup.test.ts \
tests/bash-startup-script.test.ts \
tests/exec.test.ts
pnpm --dir apps/zcode-cli --filter @zcode/adapters typecheck
git diff --check
Full workspace gates remain:
pnpm lint
pnpm typecheck
rg/find/grep alias 注入;该能力依赖 bundled search assets,另行设计。