feat: Plan Mode 批准方案时支持"清除上下文并实施计划" - #331
Open
cmp0xff wants to merge 9 commits into
Open
Conversation
Plan Mode 批准方案后,若直接在同一会话中实现,规划阶段的探索记录 (文件读取、工具输出、来回问答、被否定的思路)会全部留在上下文里, 导致执行阶段 token 消耗高、噪声大。 新增 SessionManager.startPlanImplementationSession,以源会话为基准派生一个 干净的新会话:仅携带系统提示、运行上下文、AGENTS.md 指令与 <proposed_plan> 全文;磁盘产物与文件历史通过 GitFileHistory.forkSession 指向源会话 checkpoint 保持 /undo 可追溯,原规划会话保留在 sessions-index.json 供 /resume 回看。 Co-authored-by: Claude Code <noreply@anthropic.com>
批准弹窗原仅 3 个选项,选择 "implement this plan" 会在同一会话继续, 规划阶段的上下文噪声无法消除。新增第 4 项 "clear context and implement this plan":调用 startPlanImplementationSession 派生干净的新会话后发送 同一实现指令,并将源会话标题追加"(规划)"后缀以便在会话列表区分。 数字键选择与底部提示由 1-3 扩展为 1-4。 Co-authored-by: Claude Code <noreply@anthropic.com>
Plan Mode 批准弹窗新增 "clear context and implement this plan" 选项后, 同步更新 docs/plan-mode*.md 的选项表(数字键提示 1-3 → 1-4),并在三份 README 的斜杠命令表中补上此前缺失的 /plan 行。 Co-authored-by: Claude Code <noreply@anthropic.com>
为 clear-context 实施方案注入来源说明,并补齐派生会话校验。 原方案消息仅是一段裸的 <proposed_plan>,实现模型缺少方案来源与角色的 说明;startPlanImplementationSession 也未校验源会话是否处于 Plan Mode、 方案文本是否为空。本次以中英文指令包装方案,新增 planMode 与非空校验, 以 isPlan 标记替代 isSummary,并提取 registerSessionEntry 复用 forkSession 的注册/排序/截断逻辑。 Co-authored-by: deepseek-v4-pro <noreply@deepseek.com>
清除上下文派生失败时不再提前关闭方案弹窗,供用户重新选择。 源会话标题后缀由中文改为英文 " (planned)",与英文选择界面保持一致; 派生成功后才清除 pendingPlanImplementation,失败时在 catch 中恢复。 Co-authored-by: deepseek-v4-pro <noreply@deepseek.com>
明确选项 4 派生会话携带系统提示、运行上下文、AGENTS.md 指令与方案, 并说明规划阶段加载的 skills 不会带入实现会话。 Co-authored-by: deepseek-v4-pro <noreply@deepseek.com>
cmp0xff
force-pushed
the
feat/plan-clear-context-implement
branch
from
September 1, 2026 21:43
e7877f3 to
6f9f13c
Compare
cmp0xff
force-pushed
the
feat/plan-clear-context-implement
branch
from
September 2, 2026 08:40
a35141b to
fb60435
Compare
旧实现直接信任调用方传入的方案,并将其作为系统消息注入;源会话记录的 skill 信息也可能过期。这会改变方案原本的用户指令层级,并使干净会话中的 skill 重新发现不可靠。 现在只允许从已完成的 Plan Mode 会话派生,要求方案与最近一条完整的 <proposed_plan> 完全一致,并记录其确切消息来源。派生会话通过共享逻辑重建当前可信前缀,按名称或路径重新解析精简 skill 目录,再把交接指令与方案作为首条用户消息正常提交;创建失败时清理未使用的会话与文件历史。 未采用“通用实现指令加隐藏系统方案”,因为它会绕过正常的 skill 匹配并提升方案权限。 验证:git diff --check、npm run check 和 npm test 均通过。 Co-authored-by: Codex <noreply@openai.com>
可恢复的规划会话在后台继续运行时,其消息、状态、重试、权限和进程输出可能污染当前实现会话。选项 4 还可能被重复触发,固定长度标题则会把来源徽章拆到下一行。 现在为所有相关事件保留来源会话 ID,严格筛选活动会话更新,并统一会话视图切换与失败恢复。派生操作在首次选择后进入单次执行状态,标题、来源徽章和状态也在各自布局区域渲染。 未停止源会话的后台进程,因为源会话必须保持可恢复,并持久化后台任务的最终结果。 验证:git diff --check、npm run check 和 npm test 均通过。 Co-authored-by: Codex <noreply@openai.com>
原说明包含过多消息构造、skill 筛选和 checkpoint 回退细节,不利于用户快速理解选项 4。 中英文文档现在只保留用户可观察的行为:方案以用户消息交接,当前配置、AGENTS.md 和可用 skills 会重新加载,规划历史不会复制,工作区保持不变,源会话可恢复,并尽力继承文件历史。 未继续展开内部验证和消息顺序,因为这些细节由实现与测试保证,不影响用户选择。 验证:已对照实际流程核对中英文版本;git diff --check、npm run check 和 npm test 均通过。 Co-authored-by: Codex <noreply@openai.com>
cmp0xff
force-pushed
the
feat/plan-clear-context-implement
branch
from
September 2, 2026 09:14
fb60435 to
70c98e8
Compare
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
结果
<proposed_plan>。planned/implementation标记,并在 80 列终端中保证长标题不会挤坏徽章、状态或时间行。Closes #325
验证
git diff --checknpm run checknpm test(CLI 326/326;core 357 通过、1 个 Windows 专用用例在 macOS 跳过;VS Code 57/57)dist/或package-lock.json变更Co-authored-by: Codex noreply@openai.com
Accountability Index