Repository navigation
feat(worktree): 完善话题工作区生命周期 - #956
Merged
deepcoldy merged 85 commits intoSep 12, 2026
Merged
Conversation
wzono
force-pushed
the
feat/topic-worktree-lifecycle
branch
from
August 20, 2026 10:06
d67c241 to
441c32b
Compare
wzono
force-pushed
the
feat/topic-worktree-lifecycle
branch
from
August 24, 2026 04:01
441c32b to
a410421
Compare
added 4 commits
August 25, 2026 19:48
…-lifecycle # Conflicts: # test/command-handler.test.ts
…-lifecycle Co-authored-by: TRAE CLI <[email protected]>
…-lifecycle Co-authored-by: TRAE CLI <[email protected]> # Conflicts: # test/pm2-existing-client.test.ts
Co-Authored-By: Claude Code <[email protected]>
Co-Authored-By: Claude Code <[email protected]>
Co-Authored-By: Claude Code <[email protected]>
Co-Authored-By: Claude Code <[email protected]>
…-lifecycle Co-authored-by: TRAE CLI <[email protected]>
Co-Authored-By: Claude Code <[email protected]>
Co-Authored-By: Claude Code <[email protected]>
Co-Authored-By: Claude Code <[email protected]>
Co-Authored-By: Claude Code <[email protected]>
Co-Authored-By: Claude Code <[email protected]>
Co-Authored-By: Claude Code <[email protected]>
…-lifecycle Co-authored-by: TRAE CLI <[email protected]>
deepcoldy
added a commit
that referenced
this pull request
Sep 12, 2026
外部作者 Ding-Ye(土豆有点)的 #1366。将飞书文档原生评论从「整篇文档共用一个 CLI 会话」改为「按 commentId 线程隔离」,解决同文档多条独立评论被并入同一 turn、 部分评论长期无正式回复的问题。 冲突解决(src/core/worker-pool.ts):保留 master 上 #1333 的 cliInstanceBinding adopt 守卫,同时采用本 PR 的 forkAdoptWorker 'accepted'|'rejected' 返回契约,二者并存,纯机械合并。 test/daemon-rename-route.test.ts 的 mock 工厂并集保留 #956 runAutoWorktreeCommit 与本 PR persistStreamCardState 两个键。 合并树已逐字节核对:14 个 PR 文件与基于当前 master 的本地验证树一致, 其余文件与 master 尖端一致;通过 tsc、相关单测与 bun run build。 Co-Authored-By: Claude Code <[email protected]>
|
🚀 Released in v3.22.0 |
LucasIcarus
added a commit
that referenced
this pull request
Sep 14, 2026
主干 #956 新增的 findActiveSessionsByWorkingDirStrict 按旧协议把 legacy JSON 当作可读 store(解析行、坏行 fail closed)。本 PR 收口后跨进程读取面只认 .db、JSON 一律不解析,于是「另一个 bot 的 sessions-<appId>.json 仍在、.db 未建」在原实现里会被静默当成空 store——升级窗口内未重启的 bot 若在该 worktree 上仍有活动会话,删除 worktree 的安全清单会漏掉它。 改为:清单前先按 listUnmigratedAppIds 找出待迁移的 store;有待迁移时再按 仍存在于本机(bots.json / 在线 descriptor / 本进程 appId)的 bot 过滤,任一 命中即抛 SessionStoreUnmigratedError。「哪些 bot 仍然存在」在这里必须是结 论性的:knownBotAppIds 新增 strict 模式,bots.json 读不到 / 不是 JSON / 没有 bot 列表、或 descriptor 目录列不出时直接抛错(listOnlineDaemons 同步加 strict),不把「无法判定」折成「废弃数据」。已移出 bots.json 的残留 JSON 与本 PR 的既有裁定一致,视为废弃不阻塞。command-handler 的重试任务与 /close 的兄弟会话清单两处调用已有 try/catch,抛错会转成「无法完整读取同 worktree 会话清单,已取消删除」;删除锁内的最终清单沿用主干既有的 handler 级 catch(只记日志),两次清单之间状态未变时不会走到那里。 rebase 时删除了主干那条「legacy JSON 坏行 fail closed」用例(JSON 已不 再被读取),以「已知 bot 未迁移 fail closed / 未知 bot 残留忽略 / bots.json 不可读 fail closed / 无待迁移时不读 bots.json」四条用例替代。 Co-Authored-By: Claude Fable 5.1 <[email protected]>
LucasIcarus
added a commit
that referenced
this pull request
Sep 14, 2026
§3.3 原文只写了常规跨进程读「不把 unmigrated 的 bot 计入结果并提示」。 主干 #956 新增的 worktree 回收是破坏性路径,按同一规则跳过会漏掉未重启 bot 在该目录上的活动会话,故裁定为 fail closed,且「哪些 bot 仍然存在」 的判定在此处必须是结论性的(bots.json / descriptor 目录读不到即抛错)。 §3.8 补记:编译版二进制里 dashboard 进程读到的 current 是自身烘焙版本而 非磁盘版本,「运行中 daemon vs 磁盘」在 dashboard 侧按无法判定处理。 Co-Authored-By: Claude Fable 5.1 <[email protected]>
LucasIcarus
added a commit
that referenced
this pull request
Sep 14, 2026
rebase 到含 #1333 / #1348 / #956 的主干后,restore-zombie-close 的 「legacy-bound Codex session」三例与 daemon-rename-route 的「serializes pool creation」一例仍用无参 init() 重置会话库,本 PR 已把 init(appId) 改为必填, CI shard 1/3 因此红。按各文件既有的 appId 补参(app_test / APP),验收 grep `sessionStore.init(\s*)` 在 test 下仍为 0。 Co-Authored-By: Claude Fable 5.1 <[email protected]>
LucasIcarus
added a commit
that referenced
this pull request
Sep 16, 2026
主干 #956 新增的 findActiveSessionsByWorkingDirStrict 按旧协议把 legacy JSON 当作可读 store(解析行、坏行 fail closed)。本 PR 收口后跨进程读取面只认 .db、JSON 一律不解析,于是「另一个 bot 的 sessions-<appId>.json 仍在、.db 未建」在原实现里会被静默当成空 store——升级窗口内未重启的 bot 若在该 worktree 上仍有活动会话,删除 worktree 的安全清单会漏掉它。 改为:清单前先按 listUnmigratedAppIds 找出待迁移的 store;有待迁移时再按 仍存在于本机(bots.json / 在线 descriptor / 本进程 appId)的 bot 过滤,任一 命中即抛 SessionStoreUnmigratedError。「哪些 bot 仍然存在」在这里必须是结 论性的:knownBotAppIds 新增 strict 模式,bots.json 读不到 / 不是 JSON / 没有 bot 列表、或 descriptor 目录列不出时直接抛错(listOnlineDaemons 同步加 strict),不把「无法判定」折成「废弃数据」。已移出 bots.json 的残留 JSON 与本 PR 的既有裁定一致,视为废弃不阻塞。command-handler 的重试任务与 /close 的兄弟会话清单两处调用已有 try/catch,抛错会转成「无法完整读取同 worktree 会话清单,已取消删除」;删除锁内的最终清单沿用主干既有的 handler 级 catch(只记日志),两次清单之间状态未变时不会走到那里。 rebase 时删除了主干那条「legacy JSON 坏行 fail closed」用例(JSON 已不 再被读取),以「已知 bot 未迁移 fail closed / 未知 bot 残留忽略 / bots.json 不可读 fail closed / 无待迁移时不读 bots.json」四条用例替代。 Co-Authored-By: Claude Fable 5.1 <[email protected]>
LucasIcarus
added a commit
that referenced
this pull request
Sep 16, 2026
§3.3 原文只写了常规跨进程读「不把 unmigrated 的 bot 计入结果并提示」。 主干 #956 新增的 worktree 回收是破坏性路径,按同一规则跳过会漏掉未重启 bot 在该目录上的活动会话,故裁定为 fail closed,且「哪些 bot 仍然存在」 的判定在此处必须是结论性的(bots.json / descriptor 目录读不到即抛错)。 §3.8 补记:编译版二进制里 dashboard 进程读到的 current 是自身烘焙版本而 非磁盘版本,「运行中 daemon vs 磁盘」在 dashboard 侧按无法判定处理。 Co-Authored-By: Claude Fable 5.1 <[email protected]>
LucasIcarus
added a commit
that referenced
this pull request
Sep 16, 2026
rebase 到含 #1333 / #1348 / #956 的主干后,restore-zombie-close 的 「legacy-bound Codex session」三例与 daemon-rename-route 的「serializes pool creation」一例仍用无参 init() 重置会话库,本 PR 已把 init(appId) 改为必填, CI shard 1/3 因此红。按各文件既有的 appId 补参(app_test / APP),验收 grep `sessionStore.init(\s*)` 在 test 下仍为 0。 Co-Authored-By: Claude Fable 5.1 <[email protected]>
This was referenced Sep 16, 2026
LucasIcarus
added a commit
that referenced
this pull request
Sep 29, 2026
主干 #956 新增的 findActiveSessionsByWorkingDirStrict 按旧协议把 legacy JSON 当作可读 store(解析行、坏行 fail closed)。本 PR 收口后跨进程读取面只认 .db、JSON 一律不解析,于是「另一个 bot 的 sessions-<appId>.json 仍在、.db 未建」在原实现里会被静默当成空 store——升级窗口内未重启的 bot 若在该 worktree 上仍有活动会话,删除 worktree 的安全清单会漏掉它。 改为:清单前先按 listUnmigratedAppIds 找出待迁移的 store;有待迁移时再按 仍存在于本机(bots.json / 在线 descriptor / 本进程 appId)的 bot 过滤,任一 命中即抛 SessionStoreUnmigratedError。「哪些 bot 仍然存在」在这里必须是结 论性的:knownBotAppIds 新增 strict 模式,bots.json 读不到 / 不是 JSON / 没有 bot 列表、或 descriptor 目录列不出时直接抛错(listOnlineDaemons 同步加 strict),不把「无法判定」折成「废弃数据」。已移出 bots.json 的残留 JSON 与本 PR 的既有裁定一致,视为废弃不阻塞。command-handler 的重试任务与 /close 的兄弟会话清单两处调用已有 try/catch,抛错会转成「无法完整读取同 worktree 会话清单,已取消删除」;删除锁内的最终清单沿用主干既有的 handler 级 catch(只记日志),两次清单之间状态未变时不会走到那里。 rebase 时删除了主干那条「legacy JSON 坏行 fail closed」用例(JSON 已不 再被读取),以「已知 bot 未迁移 fail closed / 未知 bot 残留忽略 / bots.json 不可读 fail closed / 无待迁移时不读 bots.json」四条用例替代。 Co-Authored-By: Claude Fable 5.1 <[email protected]>
LucasIcarus
added a commit
that referenced
this pull request
Sep 29, 2026
§3.3 原文只写了常规跨进程读「不把 unmigrated 的 bot 计入结果并提示」。 主干 #956 新增的 worktree 回收是破坏性路径,按同一规则跳过会漏掉未重启 bot 在该目录上的活动会话,故裁定为 fail closed,且「哪些 bot 仍然存在」 的判定在此处必须是结论性的(bots.json / descriptor 目录读不到即抛错)。 §3.8 补记:编译版二进制里 dashboard 进程读到的 current 是自身烘焙版本而 非磁盘版本,「运行中 daemon vs 磁盘」在 dashboard 侧按无法判定处理。 Co-Authored-By: Claude Fable 5.1 <[email protected]>
LucasIcarus
added a commit
that referenced
this pull request
Sep 29, 2026
rebase 到含 #1333 / #1348 / #956 的主干后,restore-zombie-close 的 「legacy-bound Codex session」三例与 daemon-rename-route 的「serializes pool creation」一例仍用无参 init() 重置会话库,本 PR 已把 init(appId) 改为必填, CI shard 1/3 因此红。按各文件既有的 appId 补参(app_test / APP),验收 grep `sessionStore.init(\s*)` 在 test 下仍为 0。 Co-Authored-By: Claude Fable 5.1 <[email protected]>
LucasIcarus
added a commit
that referenced
this pull request
Sep 29, 2026
rebase 到含 #1333 / #1348 / #956 的主干后,restore-zombie-close 的 「legacy-bound Codex session」三例与 daemon-rename-route 的「serializes pool creation」一例仍用无参 init() 重置会话库,本 PR 已把 init(appId) 改为必填, CI shard 1/3 因此红。按各文件既有的 appId 补参(app_test / APP),验收 grep `sessionStore.init(\s*)` 在 test 下仍为 0。 Co-Authored-By: Claude Fable 5.1 <[email protected]>
LucasIcarus
added a commit
that referenced
this pull request
Sep 29, 2026
rebase 到含 #1333 / #1348 / #956 的主干后,restore-zombie-close 的 「legacy-bound Codex session」三例与 daemon-rename-route 的「serializes pool creation」一例仍用无参 init() 重置会话库,本 PR 已把 init(appId) 改为必填, CI shard 1/3 因此红。按各文件既有的 appId 补参(app_test / APP),验收 grep `sessionStore.init(\s*)` 在 test 下仍为 0。 Co-Authored-By: Claude Fable 5.1 <[email protected]>
LucasIcarus
added a commit
that referenced
this pull request
Sep 29, 2026
rebase 到含 #1333 / #1348 / #956 的主干后,restore-zombie-close 的 「legacy-bound Codex session」三例与 daemon-rename-route 的「serializes pool creation」一例仍用无参 init() 重置会话库,本 PR 已把 init(appId) 改为必填, CI shard 1/3 因此红。按各文件既有的 appId 补参(app_test / APP),验收 grep `sessionStore.init(\s*)` 在 test 下仍为 0。 Co-Authored-By: Claude Fable 5.1 <[email protected]>
LucasIcarus
added a commit
that referenced
this pull request
Sep 30, 2026
主干 #956 把 `/th` `/tw` `/t here|worktree` 做成 daemon 入口里的两条正则预判(先改写成 `/t …` 再交给 parseTopicHeader),command-handler 里还留了一份同构的 parseForceTopicInvocation 只给测试 用;rebase 之后头部 `/repo wt` 与它相遇时只能沿用主干的静默优先级(生命周期目录优先、`/repo` 被丢掉)。本次按命令路由器的原则(解析只有一处、fail closed)收口: - topic-header:`/th` `/tw` 成为分隔符别名,`/t` `/topic` 紧跟的裸 `here|worktree` 一词被吃成 `header.lifecycle`;变体算「已写头部」(未知 /xxx fail closed)与「声明了规格」(thread 里回 「只在新话题第一条生效」,不再当普通输入送进 CLI) - topic-spec:`lifecycle` 透传;与 `/repo`(含 `/repo wt`、裸 `/repo`)同写 → `lifecycle_conflicts_repo`,与其它错误一并收齐;新增 zh/en 文案 - daemon:删掉两条正则与改写,`forceTopicMode = forceTopic.lifecycle ?? 'default'`;头部 wt 不再 需要「forceTopicMode === 'default' 时才生效」的让位 - command-handler:删掉 parseForceTopicInvocation / ForceTopicMode(无生产调用方) - schema:`/th` `/tw` 进 FORCE_TOPIC_COMMANDS(触发 API 里同为保留命令);docs-site 补一行说明 有意的行为变化(记入设计文档 §9/§16):`标题 /tw 干活` 现在是带标题的生命周期头部(主干里 正则锚在行首,不识别);chat 模式群里 `/tw` 与 `/t` 一样强制开新话题;`/tw /repo x` 由静默丢掉 `/repo` 改为拒绝。 验证:`bun run build`;topic-header / topic-spec / command-handler / slash-commands-doc-sync / topic-directive-header / daemon-rename-route / command-schema / command-trigger* / event-dispatcher / command-router-oracle-diff 全绿;daemon-rename-route 里 `/tw` 的 targetSubdir 用例在本机 master 基线上同样失败(macOS /var 与 /private/var 的 realpath 差异),非本次引入。 Claude-Session: https://claude.ai/code/session_01Vu96pufjDoyTRmKFqCzWGQ
deepcoldy
pushed a commit
that referenced
this pull request
Oct 13, 2026
stdout 接管道时 write() 是异步的,紧跟显式 process.exit() 会丢弃未排空的尾部(实测父进程恒定只收到约 146 KiB,与 payload 大小无关)。 - 新增 src/cli/stdout-flush.ts 的 writeAndFlush:以 write 完成回调为边界 - botmux ask --json:写完结果再 ack;写失败不 ack、exit 1,daemon 仍可回收回执 - botmux hook:directive 内嵌用户文字作答(无长度上限)时等写完再 exit 0 - sandbox relay:send 与 dispatch 两处统一 mirrorRelayResponseAndExit,stdout/stderr 均写完再镜像宿主退出码 - pm2 只读 jlist 同类修复已在 master 落地(#956),保留大注册表(>200KB)真实子进程回归钉住;另新增 2MiB 管道背压回归与 ask 50 万字符 comment 端到端回归 验证:tsc 与 bun run build 通过;相关 10 个测试文件 159 通过 / 3 跳过(node vitest 与 bun test 双运行时);反向变异(撤掉修复)下三个回归测试均变红。 Co-Authored-By: Claude Code <[email protected]>
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.
改动内容
新增的话题 / 工作区命令
/th [任务]/t here [任务]。/tw [任务]/t worktree [任务]。/repo here/close wt//close worktree/cleanup-wt <ID>补充说明:
/t [任务]与/topic [任务]原本已经存在;本 PR 为它们增加here/worktree两种模式及/th//tw快捷别名。/repo wt ...原本已经存在,不属于本 PR 新增命令。/here或/worktree命令;here/worktree是/t、/repo、/close的参数或模式。话题 worktree 生命周期
/tw的待处理配置会持久化,daemon 重启后仍保留 force、路径、分支、复用策略和仓库相对子目录。/close wt使用跨 Bot 的严格活跃会话清单;无法证明安全时 fail closed。union_id授权;不把 app-scopedopen_id当作跨应用身份。/cleanup-wt <ID>重新校验后继续执行。可靠性补充
jlist在输出较大时等待 stdout flush 后再退出,避免 JSON 被截断。为什么要改
影响范围
验证
bun run build:通过。git diff --check origin/master...HEAD:通过。bun-test当前有一项编译 sandbox shim 临时目录探测失败,需后续重跑/确认。