Repository navigation
refactor(worktree): remove worktree-setup.sh support and align print-mode trust - #5528
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
| Name | Type |
|---|---|
| @moonshot-ai/agent-core-v2 | Minor |
| @moonshot-ai/acp-server | Patch |
| @moonshot-ai/kap-server | Patch |
| @moonshot-ai/klient | Patch |
| @moonshot-ai/migration-legacy | Patch |
| @moonshot-ai/kimi-code-product | Patch |
| @moonshot-ai/remote-control | Patch |
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a3c6eb3891
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Requirement or Bug
实验性 Git worktree 功能中的
.kimi-code/worktree-setup.sh初始化脚本能力设计尚未收敛,本 PR 在正式发布前先移除该能力,只保留.worktreeinclude忽略文件复制及其他 worktree 管理功能。同时移除 print 模式-w单独的未受信任项目阻断检查,使其与普通kimi -p的信任模型保持一致。Bug Reproduction Steps
N/A
Root Cause
N/A
Code Changes
核心思路
新建 worktree 的流程现在在完成
.worktreeinclude文件复制后直接结束并进入新工作树,不再发现、提示或执行.kimi-code/worktree-setup.sh。由于 print 模式不再自动执行仓库内的 shell 脚本,kimi -p -w移除单独的未受信任项目阻断检查,沿用普通kimi -p的项目级 MCP 跳过警告与引擎门控。去掉脚本执行阶段后,print 模式
preparePrintWorktree不再存在「工作树已创建但脚本失败未就绪」的中间态,TUI 也不再需要脚本确认弹窗、流式输出截尾与失败删树分支,引擎层进程执行逻辑也随之收简。关键决策
kimi -p -w的项目信任检查kimi -p对齐-w保留硬阻断runWorktreeSetupScript与相关类型阅读指南
packages/agent-core-v2/src/app/worktree/worktree.ts与worktreeService.ts:移除CreatedWorktree.setupScript、runSetupScript、脚本路径解析,以及仅由其使用的runWithLease包装与RunOptions字段。apps/kimi-code/src/cli/v2/run-v2-print.ts:移除isProjectTrusted与脚本执行段,将preparePrintWorktree返回值收紧为Promise<CreatedWorktree | undefined>。apps/kimi-code/src/tui/controllers/worktree-creation.ts:移除脚本询问/重试/失败删树逻辑、OutputTail,并收紧WorktreeCreationHost依赖。packages/node-sdk/src/*透传导出清理、apps/kimi-code/src/tui/components/{dialogs/worktree-choices,messages/worktree-progress}.ts弹窗与进度行分支清理、测试更新、.changeset/worktree-core.md措辞同步,以及docs/{zh,en}/guides/worktrees.md文档更新。Behavior Changes and Affected Users
.kimi-code/worktree-setup.shKIMI_CODE_WORKTREE_SOURCE_DIR与KIMI_CODE_WORKTREE_DIR.worktreeinclude照常复制忽略文件worktree开关、且在仓库配置了.kimi-code/worktree-setup.sh的 TUI 与 print 模式用户kimi -p -wkimi -p一致kimi -p -w在未受信任项目下自动中止的脚本或外部自动化流程kimi -p信任模型保持一致)@moonshot-ai/kimi-code-sdk与@moonshot-ai/agent-core-v2worktree 接口RunSetupScriptInput、RunSetupScriptOptions、runWorktreeSetupScript/runSetupScript与CreatedWorktree.setupScript.changeset/worktree-core.md受影响模块与验证
packages/agent-core-v2、packages/node-sdk、apps/kimi-code、docs/{zh,en}/guides/worktrees.md、.changeset/worktree-core.md。agent-core-v2、node-sdk、apps/kimi-code三包类型检查全部通过。.kimi-code/worktree-setup.sh时不执行且保留.worktreeinclude、未受信任项目下kimi -p -w放行并输出 MCP 跳过警告、createWorktree失败退出码 1,以及 TUI 创建与进度渲染。kimi -p ... -w(未受信任仓库含.worktreeinclude、可执行.kimi-code/worktree-setup.sh与.kimi-code/mcp.json)与 PTY 交互式kimi -w,均正确复制.env、跳过脚本且无弹窗。pnpm lint与pnpm run check:duplication全部通过。worktreeService.test.ts回归用例未跳过 Windows,将随 CI 校验)。验证命令与结果
pnpm exec tsc -p packages/agent-core-v2/tsconfig.json --noEmit(退出码 0)pnpm exec tsc -p packages/node-sdk/tsconfig.json --noEmit(退出码 0)pnpm exec tsc -p apps/kimi-code/tsconfig.json --noEmit(退出码 0)pnpm exec vitest run --reporter=agent运行 9 个 worktree/CLI/TUI 测试文件(596 项通过;补齐createWorktree失败用例后复跑apps/kimi-code/test/cli/v2-run-print.test.ts51/51 通过)pnpm lint(退出码 0,0 warnings / 0 errors)pnpm run check:duplication FETCH_HEAD(退出码 0,无新增重复)Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.