@christang/keel 5.231.6 → 5.231.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keel",
3
- "version": "5.231.6",
3
+ "version": "5.231.8",
4
4
  "description": "Keel OpenSpec execution discipline: stateless continuity, task capsules, deterministic gates, and expectation alignment for Codex and Claude Code.",
5
5
  "author": {
6
6
  "name": "TanglmChris",
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  **English** | [中文](README.zh-CN.md)
4
4
 
5
- > OpenSpec execution discipline for AI coding agents — Claude Code, Codex, OpenCode, and DSH.
5
+ > Execution and coordination for AI coding agents — Claude Code, Codex, OpenCode, and DSH.
6
6
 
7
7
  ![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)
8
8
  ![Node](https://img.shields.io/badge/node-%3E%3D20.19.0-brightgreen.svg)
@@ -10,15 +10,46 @@
10
10
 
11
11
  ## What Keel is for
12
12
 
13
- [OpenSpec](https://github.com/fission-ai/openspec) gives a project a spec-driven
14
- workflow: proposal, design, specs, tasks, and an archive of what changed. Claude Code
15
- (or Codex) gives you the agent that does the work. Keel sits between them and keeps the
16
- agent on track while it works through an OpenSpec change.
13
+ Keel helps a team assign work, track it by role, and verify what happened. It uses
14
+ native harness capabilities for execution and provides shared commands for task
15
+ coordination and evidence.
17
16
 
18
- Left alone, an agent tends to drift: it edits files the task never mentioned, loses the
19
- thread after a context reset, or checks work off without proof. Keel adds a thin, checkable
20
- layer that prevents that, and it does so by building on tools you already have instead of
21
- replacing them.
17
+ ### Assign a task and check delivery
18
+
19
+ Use `keel chat todo <group> --assignee <role> <text>` to assign work. With the
20
+ returned ID, run `keel chat show <todo-id> --json`. The `task` reports the
21
+ original ID, open/closed chat state and any closure record. The sibling
22
+ `delivery.state` reports `acknowledged` for a locally recorded native receipt,
23
+ `unknown` for an ambiguous submission or `unobserved` when no local evidence
24
+ is available. An acknowledgement confirms delivery to the execution host.
25
+ Work, completion and acceptance each require their own evidence.
26
+ See the [team runbook](docs/cli-team.md).
27
+
28
+ ### When a host receives work
29
+
30
+ With trusted hooks and a bound role, Claude and Codex show mailbox hints at
31
+ `SessionStart` and `UserPromptSubmit`. Claude's `FileChanged` hook can wake
32
+ an addressed idle session. For an idle managed Codex role, a configured
33
+ scheduler runs `keel tick`, or an operator runs `keel codex drain`, against its
34
+ recorded app-server. The separate `keel chat wake add` watcher is an opt-in
35
+ alternative on supported hosts. Use one delivery mechanism per role.
36
+ See the [host contract](docs/host-contract.md#mailbox-notices-and-idle-delivery).
37
+
38
+ ### Product direction
39
+
40
+ [#535](https://github.com/TanglmChris/keel/issues/535) defines the goal of
41
+ switching harnesses and models at tick boundaries and recovering automatically
42
+ from usage exhaustion within configured permissions and budgets. It also calls
43
+ for lightweight ordinary work, stronger checks for higher risk, and OpenSpec
44
+ as one selectable workflow. The task query above has shipped.
45
+ Automatic cross-harness continuation and risk-based workflow selection remain
46
+ in implementation under [#544](https://github.com/TanglmChris/keel/issues/544).
47
+ Active tasks follow their existing contracts.
48
+
49
+ ### OpenSpec execution today
50
+
51
+ [OpenSpec](https://github.com/fission-ai/openspec) provides the proposal, design,
52
+ specs, tasks and archive for Keel's current Full workflow.
22
53
 
23
54
  What Keel adds:
24
55
 
@@ -915,7 +946,7 @@ remote's sha is not in this clone) or `not-on-remote`. A lookup that fails is
915
946
 
916
947
  ## Group chat between sessions
917
948
 
918
- Sessions working the same repository — a Claude Code session, a Codex session, an unattended runner, and you — share a work group with `keel chat`. Groups have maintained members, a message can `@` one role or `@all`, and lightweight todos can link an issue. A record can supersede its author's earlier one (`--supersedes <id>`), and the earlier one then leaves everyone's unread; unread lists newest first. A record posted with `--ack` asks the roles it addresses to acknowledge it, by `keel chat ack <id>` or a reply, and `keel chat show <id>` and `keel chat acks` list who has acknowledged, who only read it, and who has not read it. `keel chat post` and `keel chat dm` take `--no-wake` for a record that is only information: it is delivered, listed by `keel chat unread` and counted at the next prompt, but touches no signal, so no idle or ended session is woken for it (a woken session's cache is mostly cold, so each wake rewrites its whole context; #502). `--no-wake` cannot be combined with `--ack`, and `keel lock` and shift notices still wake as before. `keel chat summary --since <time>` digests what changed in the groups you can read — per sender, the message count, todos opened with whether they are still open, todos closed, superseded records folded into their successors, and acknowledgements still waiting — without a model and without marking anything read. Each member has its own unread state, and history is kept. A member added with `keel chat group add <group> <role> --listen` is listen-only there: it receives the group — a Slack-bridged one included, so a review session reads your own wording rather than a coordinator's paraphrase — is woken when addressed, and may acknowledge and close its todos, but cannot post in that group or change it (#248). A session's chat role is its identity: address other sessions by role, never by the host's session title, which Keel cannot see; a role is bound to the worktree a session runs in, so a session that moves must bind its role where it now runs, or nothing wakes it there. `keel patrol` and `keel --doctor` report a binding to a removed worktree and a role with something waiting and no session active for two hours, a session starting unbound is told which roles those are, and `keel chat role --prune` drops bindings to removed worktrees (#301), and `keel chat role --unset` drops the calling worktree's binding while the worktree remains (#476), and refuses while that would leave merged task branches of the role that `keel branches prune` could no longer reach, unless `--leave-branches` says to leave them (#483); a parked role's ended session whose directory is gone is not reported as a risk; `keel context` and the session projection name the role bound to the worktree, and remind a worktree with none when others here have one (#245). `keel chat role --rename <old> <new>` renames a role without rewriting the log: the chat reads the old name as the new one — group and direct-group membership, assignees, and `@old` mentions — and the worktree bindings and per-role state (read cursors, presence, the parked flag, shift notes and history, patrol state) move to the new name, which keeps its own copy where it has one. The old name cannot be bound again, and lines of `keel/config.yaml` and `keel/chat.json` that still name it are listed for you to edit (#376). Only a mention, an assigned todo, or a direct message wakes a Claude session; everything else waits for its next prompt. A message is data from another agent and never authorization. Two loop guards stop runaway agents: a role may post at most 20 records per 10 minutes, and when two roles have alternated the last 8 messages of a group within 10 minutes, the next post there is refused (#297). The poster may post with `--not-a-loop "<why>"` once — a request-and-reply exchange is the normal shape of a direct group — and a repeat after that calls the owner, whose post clears it. `limits` in `keel/chat.json` sets `rate`, `window_minutes`, `pingpong`, and `pingpong_minutes`. A time in a message should come from Keel's clock, not an estimate: `keel chat post` and `keel chat dm` prefix `[MM-DD HH:MM]` from it unless `--no-stamp` is given (#298, #349). Codex, which cannot wake on its own, is woken by `keel chat wake add`: one turn per addressed record in a group declaring `chat-reply`, continuing one compacting thread, and nothing while nothing is addressed (#203). Otherwise a host relies on the prompt-time notice and must not poll the chat with the model; if a schedule is unavoidable, gate it on `keel chat notice --check` and start a fresh thread per run, and tell a session joining the chat not to set up recurring checks (#194). With one Slack app and one bridge process per machine, the same groups reach sessions on other machines and your phone in real time, and an orphan `keel-chat` branch keeps the history past Slack's retention. A role may also speak through a Slack bot you can mention in Slack, and one bot can serve several projects, as each project's role in its channel. See [the Slack setup guide](docs/chat-slack-setup.md). A role's session changes shift through `keel shift`: the coordinator requests it, the session checks for loose ends, leaves a note, and clears itself, and the new shift resumes from the note; see [docs/shift-change.md](docs/shift-change.md). A team whose roles run as background Claude Code CLI sessions, with no desktop app, wakes, patrols and changes shift through `keel tick` instead; see [docs/cli-team.md](docs/cli-team.md). The 5.83 `keel mail` commands keep working on direct groups.
949
+ Sessions working the same repository — a Claude Code session, a Codex session, an unattended runner, and you — share a work group with `keel chat`. Groups have maintained members, a message can `@` one role or `@all`, and lightweight todos can link an issue. A record can supersede its author's earlier one (`--supersedes <id>`), and the earlier one then leaves everyone's unread; unread lists newest first. A record posted with `--ack` asks the roles it addresses to acknowledge it, by `keel chat ack <id>` or a reply, and `keel chat show <id>` and `keel chat acks` list who has acknowledged, who only read it, and who has not read it. `keel chat post` and `keel chat dm` take `--no-wake` for a record that is only information: it is delivered, listed by `keel chat unread` and counted at the next prompt, but touches no signal, so no idle or ended session is woken for it (a woken session's cache is mostly cold, so each wake rewrites its whole context; #502). `--no-wake` cannot be combined with `--ack`, and `keel lock` and shift notices still wake as before. `keel chat summary --since <time>` digests what changed in the groups you can read — per sender, the message count, todos opened with whether they are still open, todos closed, superseded records folded into their successors, and acknowledgements still waiting — without a model and without marking anything read. Each member has its own unread state, and history is kept. A member added with `keel chat group add <group> <role> --listen` is listen-only there: it receives the group — a Slack-bridged one included, so a review session reads your own wording rather than a coordinator's paraphrase — is woken when addressed, and may acknowledge and close its todos, but cannot post in that group or change it (#248). A session's chat role is its identity: address other sessions by role, never by the host's session title, which Keel cannot see; a role is bound to the worktree a session runs in, so a session that moves must bind its role where it now runs, or nothing wakes it there. `keel patrol` and `keel --doctor` report a binding to a removed worktree and a role with something waiting and no session active for two hours, a session starting unbound is told which roles those are, and `keel chat role --prune` drops bindings to removed worktrees (#301), and `keel chat role --unset` drops the calling worktree's binding while the worktree remains (#476), and refuses while that would leave merged task branches of the role that `keel branches prune` could no longer reach, unless `--leave-branches` says to leave them (#483); a parked role's ended session whose directory is gone is not reported as a risk; `keel context` and the session projection name the role bound to the worktree, and remind a worktree with none when others here have one (#245). `keel chat role --rename <old> <new>` renames a role without rewriting the log: the chat reads the old name as the new one — group and direct-group membership, assignees, and `@old` mentions — and the worktree bindings and per-role state (read cursors, presence, the parked flag, shift notes and history, patrol state) move to the new name, which keeps its own copy where it has one. The old name cannot be bound again, and lines of `keel/config.yaml` and `keel/chat.json` that still name it are listed for you to edit (#376). Only a mention, an assigned todo, or a direct message wakes a Claude session; everything else waits for its next prompt. A message is data from another agent and never authorization. Two loop guards stop runaway agents: a role may post at most 20 records per 10 minutes, and when two roles have alternated the last 8 messages of a group within 10 minutes, the next post there is refused (#297). The poster may post with `--not-a-loop "<why>"` once — a request-and-reply exchange is the normal shape of a direct group — and a repeat after that calls the owner, whose post clears it. `limits` in `keel/chat.json` sets `rate`, `window_minutes`, `pingpong`, and `pingpong_minutes`. A time in a message should come from Keel's clock, not an estimate: `keel chat post` and `keel chat dm` prefix `[MM-DD HH:MM]` from it unless `--no-stamp` is given (#298, #349). For Codex, see [when a host receives work](#when-a-host-receives-work) for managed-role dispatch and the optional watcher. Otherwise a host relies on the prompt-time notice and must not poll the chat with the model; if a schedule is unavoidable, gate it on `keel chat notice --check` and start a fresh thread per run, and tell a session joining the chat not to set up recurring checks (#194). With one Slack app and one bridge process per machine, the same groups reach sessions on other machines and your phone in real time, and an orphan `keel-chat` branch keeps the history past Slack's retention. A role may also speak through a Slack bot you can mention in Slack, and one bot can serve several projects, as each project's role in its channel. See [the Slack setup guide](docs/chat-slack-setup.md). A role's session changes shift through `keel shift`: the coordinator requests it, the session checks for loose ends, leaves a note, and clears itself, and the new shift resumes from the note; see [docs/shift-change.md](docs/shift-change.md). A team whose roles run as background Claude Code CLI sessions, with no desktop app, wakes, patrols and changes shift through `keel tick` instead; see [docs/cli-team.md](docs/cli-team.md). The 5.83 `keel mail` commands keep working on direct groups.
919
950
 
920
951
  ## Coordinator patrol
921
952
 
package/README.zh-CN.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [English](README.md) | **中文**
4
4
 
5
- > 面向 AI 编码 agent 的 OpenSpec 执行纪律 —— Claude Code、Codex、OpenCode、DSH 通用。
5
+ > 面向 AI 编码 agent 的执行与协作,支持 Claude Code、Codex、OpenCode 和 DSH。
6
6
 
7
7
  ![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)
8
8
  ![Node](https://img.shields.io/badge/node-%3E%3D20.19.0-brightgreen.svg)
@@ -10,13 +10,37 @@
10
10
 
11
11
  ## Keel 是做什么的
12
12
 
13
- [OpenSpec](https://github.com/fission-ai/openspec) 给项目一套 spec 驱动的工作流:proposal、
14
- design、specs、tasks,以及记录改动的 archive。Claude Code(或 Codex)提供干活的 agent。
15
- Keel 夹在两者中间,在 agent 走完一个 OpenSpec change 的过程中盯住它别跑偏。
13
+ Keel 让团队按角色派工、查询进度和核验结果。执行由各宿主的原生能力承担,Keel 提供共享的任务协调和证据查询命令。
16
14
 
17
- 放任不管时,agent 容易漂移:改了任务没提到的文件、上下文重置后丢了线索、或者没有证据就把活
18
- 勾成完成。Keel 加的是一层轻量、可校验的约束来防止这些,而且它建立在你已有的工具之上,而不是
19
- 替换它们。
15
+ ### 派工与查询投递
16
+
17
+ 用 `keel chat todo <group> --assignee <role> <text>` 派工,再用返回的 ID 执行
18
+ `keel chat show <todo-id> --json`。`task` 返回原任务 ID、群聊中的开启或关闭状态,以及关闭记录。
19
+ 同级字段 `delivery.state` 返回 `acknowledged`(本机已记录原生投递确认)、
20
+ `unknown`(提交结果不明)或 `unobserved`(本机没有可用证据)。
21
+ 确认回执能证明执行端收到了投递。实际执行、完成和验收各自需要相应证据。
22
+ 参见[团队运行手册](docs/cli-team.zh-CN.md)。
23
+
24
+ ### 宿主什么时候接收任务
25
+
26
+ 角色已绑定且 Hook 已通过信任审核时,Claude 和 Codex 都在 `SessionStart` 和
27
+ `UserPromptSubmit` 提示未读消息。Claude 的 `FileChanged` 可唤醒被点名的空闲会话。
28
+ 对于空闲的托管 Codex 角色,由配置的调度器调用 `keel tick`,或由操作者调用
29
+ `keel codex drain`,向已登记的 app-server 投递。在支持的宿主上,另可显式配置
30
+ `keel chat wake add` watcher。同一角色只启用一套投递机制。
31
+ 参见[宿主契约](docs/host-contract.md#mailbox-notices-and-idle-delivery)。
32
+
33
+ ### 产品方向
34
+
35
+ [#535](https://github.com/TanglmChris/keel/issues/535) 定下的目标是在 tick 边界切换宿主和模型,
36
+ 并在已配置的权限和预算内从 usage 耗尽等异常自动续接。普通任务默认轻量,高风险任务加强检查,
37
+ OpenSpec 成为可选工作流之一。上面的任务查询已经发布。
38
+ 跨宿主自动接续和按风险选择流程仍由 [#544](https://github.com/TanglmChris/keel/issues/544) 实施。
39
+ 在途任务继续遵守原有契约。
40
+
41
+ ### 当前的 OpenSpec 执行流程
42
+
43
+ [OpenSpec](https://github.com/fission-ai/openspec) 为 Keel 当前的 Full 流程提供 proposal、design、specs、tasks 和 archive。
20
44
 
21
45
  Keel 加的东西:
22
46
 
@@ -98,7 +122,7 @@ codex plugin add keel@keel-marketplace # Codex
98
122
  会话在下一次 hook 调用时就用上更新后的插件,而改动了 hook 定义的版本需要再审阅一次。
99
123
  用 `keel mail role --set codex-maint` 绑定一个邮箱角色;受信任的 hook 会在会话启动和下一次用户输入时
100
124
  提示未读邮件,但不会把它标为已读。如果收件 hook 不可用,就显式使用 `keel mail list` 和 `keel mail read`。
101
- Codex 闲着时不会自己醒来;在它的 worktree 里运行 `keel chat wake add`,有找它的消息到达时就会启动一轮(#203)。
125
+ 托管角色的空闲投递和另一套可选的 watcher 见[宿主什么时候接收任务](#宿主什么时候接收任务)。
102
126
  原生的写入守卫执行仍未经验证。
103
127
  版本、运行时证据、局限以及干净消费方上的 Full 模式检查,见 [Codex 验收记录](docs/codex-validation.md)。
104
128
 
@@ -763,7 +787,7 @@ JSON 输出包含 `defaultBranch` 和 `worktrees`;每个 worktree 的 `issues`
763
787
  `remote-ahead` 不计入。
764
788
  ## 会话之间的群聊
765
789
 
766
- 在同一个仓库里干活的各个会话——Claude Code 会话、Codex 会话、无人值守的执行器,还有你——用 `keel chat` 共享一个工作群。群有维护中的成员名单,一条消息可以 `@` 某个角色或 `@all`,轻量待办可以关联 issue。一条记录可以取代同一作者之前的记录(`--supersedes <id>`),被取代的那条随即从所有人的未读里消失;未读按新到旧排列。用 `--ack` 发出的记录会请它所指向的角色确认,方式是 `keel chat ack <id>` 或回复;`keel chat show <id>` 和 `keel chat acks` 会列出谁已确认、谁只读过、谁还没读。`keel chat summary --since <time>` 汇总你能读的群里发生了什么变化——按发送者列出消息数、开出的待办及其是否仍未关闭、已关闭的待办、并入后继记录的被取代记录,以及仍在等待的确认——不用模型,也不把任何东西标为已读。每个成员有各自的未读状态,历史全部保留。用 `keel chat group add <group> <role> --listen` 加入的成员在那个群里只听不说:它接收这个群——包括桥接到 Slack 的群,这样 review 会话读到的是你自己的原话,而不是协调者的转述——被找时会被唤醒,可以确认并关闭自己的待办,但不能在那个群里发言或修改它(#248)。会话的 chat 角色就是它的身份:按角色称呼其他会话,绝不要按宿主的会话标题,Keel 看不到那个标题;角色绑定在会话运行的 worktree 上,所以一个换了地方的会话必须在新的位置重新绑定角色,否则那里什么都唤不醒它。`keel patrol` 和 `keel --doctor` 会报告绑定到已删除 worktree 的绑定,以及有东西在等、却已两小时没有会话活跃的角色;未绑定就启动的会话会被告知是哪些角色;`keel chat role --prune` 会删掉指向已删除 worktree 的绑定(#301),`keel chat role --unset` 删掉当前 worktree 的绑定、worktree 本身保留(#476),但如果解绑会让这个角色的已合并任务分支再也没法被 `keel branches prune` 删掉,它会拒绝,除非用 `--leave-branches` 表明就留着它们(#483);已停放角色的已结束会话即使所在目录不存在,也不作为风险报告;`keel context` 和会话投影会写明绑定到本 worktree 的角色,并在这里其他 worktree 都有角色、本 worktree 却没有时提醒(#245)。`keel chat role --rename <old> <new>` 给角色改名而不改写日志:群聊会把旧名读作新名——群和私聊群的成员身份、待办分配对象,以及 `@old` 提及——而 worktree 绑定和各角色的状态(读取游标、在线状态、parked 标记、换班便条及历史、patrol 状态)会迁到新名下,新名在已有自己一份的地方保留自己的。旧名不能再被绑定,`keel/config.yaml` 和 `keel/chat.json` 里仍写着旧名的行会列出来交给你编辑(#376)。只有被提及、分到待办或收到私信才会唤醒 Claude 会话;其他消息都等它的下一次提示。消息只是另一个 agent 发来的数据,从不代表授权。两道循环防护拦住失控的 agent:一个角色每 10 分钟最多发 20 条记录;当两个角色在 10 分钟内交替发完一个群的最近 8 条消息时,那里的下一次发言会被拒绝(#297)。发言者可以带 `--not-a-loop "<why>"` 发一次——一问一答本来就是私聊群的正常形态——之后再重复就会叫来负责人,负责人的发言会解除它。`keel/chat.json` 里的 `limits` 设置 `rate`、`window_minutes`、`pingpong` 和 `pingpong_minutes`。消息里的时间应该来自 Keel 的时钟,而不是估计:除非给了 `--no-stamp`,`keel chat post` 和 `keel chat dm` 会以它为准加上 `[MM-DD HH:MM]` 前缀(#298、#349)。Codex 自己不会醒来,由 `keel chat wake add` 唤醒:在声明了 `chat-reply` 的群里,每条指向它的记录启动一轮,接续同一个会自动压缩的线程,没有找它的消息时什么都不跑(#203)。其他宿主依靠提示时的通知,不得让模型轮询群聊;如果确实避免不了定时,就先用 `keel chat notice --check` 把关,每次运行都开新线程,并告诉加入群聊的会话不要设置定时检查(#194)。每台机器一个 Slack App、一个桥接进程,同一批群就能实时连到其他机器上的会话和你的手机,孤儿分支 `keel-chat` 会把历史保留到超出 Slack 保留期之后。角色也可以通过一个你能在 Slack 里提及的 Slack bot 发言,一个 bot 可以服务多个项目,在每个项目的频道里充当那个项目的角色。见 [Slack 配置指南](docs/chat-slack-setup.zh-CN.md)。角色的会话通过 `keel shift` 换班:协调者发起,会话自查收尾、留下便条、清空自己,新的一班从便条接手;见 [docs/shift-change.zh-CN.md](docs/shift-change.zh-CN.md)。如果团队的角色以后台 Claude Code CLI 会话运行、没有桌面应用,就改用 `keel tick` 来唤醒、巡查和换班;见 [docs/cli-team.zh-CN.md](docs/cli-team.zh-CN.md)。5.83 的 `keel mail` 命令在私聊群上继续可用。
790
+ 在同一个仓库里干活的各个会话——Claude Code 会话、Codex 会话、无人值守的执行器,还有你——用 `keel chat` 共享一个工作群。群有维护中的成员名单,一条消息可以 `@` 某个角色或 `@all`,轻量待办可以关联 issue。一条记录可以取代同一作者之前的记录(`--supersedes <id>`),被取代的那条随即从所有人的未读里消失;未读按新到旧排列。用 `--ack` 发出的记录会请它所指向的角色确认,方式是 `keel chat ack <id>` 或回复;`keel chat show <id>` 和 `keel chat acks` 会列出谁已确认、谁只读过、谁还没读。`keel chat summary --since <time>` 汇总你能读的群里发生了什么变化——按发送者列出消息数、开出的待办及其是否仍未关闭、已关闭的待办、并入后继记录的被取代记录,以及仍在等待的确认——不用模型,也不把任何东西标为已读。每个成员有各自的未读状态,历史全部保留。用 `keel chat group add <group> <role> --listen` 加入的成员在那个群里只听不说:它接收这个群——包括桥接到 Slack 的群,这样 review 会话读到的是你自己的原话,而不是协调者的转述——被找时会被唤醒,可以确认并关闭自己的待办,但不能在那个群里发言或修改它(#248)。会话的 chat 角色就是它的身份:按角色称呼其他会话,绝不要按宿主的会话标题,Keel 看不到那个标题;角色绑定在会话运行的 worktree 上,所以一个换了地方的会话必须在新的位置重新绑定角色,否则那里什么都唤不醒它。`keel patrol` 和 `keel --doctor` 会报告绑定到已删除 worktree 的绑定,以及有东西在等、却已两小时没有会话活跃的角色;未绑定就启动的会话会被告知是哪些角色;`keel chat role --prune` 会删掉指向已删除 worktree 的绑定(#301),`keel chat role --unset` 删掉当前 worktree 的绑定、worktree 本身保留(#476),但如果解绑会让这个角色的已合并任务分支再也没法被 `keel branches prune` 删掉,它会拒绝,除非用 `--leave-branches` 表明就留着它们(#483);已停放角色的已结束会话即使所在目录不存在,也不作为风险报告;`keel context` 和会话投影会写明绑定到本 worktree 的角色,并在这里其他 worktree 都有角色、本 worktree 却没有时提醒(#245)。`keel chat role --rename <old> <new>` 给角色改名而不改写日志:群聊会把旧名读作新名——群和私聊群的成员身份、待办分配对象,以及 `@old` 提及——而 worktree 绑定和各角色的状态(读取游标、在线状态、parked 标记、换班便条及历史、patrol 状态)会迁到新名下,新名在已有自己一份的地方保留自己的。旧名不能再被绑定,`keel/config.yaml` 和 `keel/chat.json` 里仍写着旧名的行会列出来交给你编辑(#376)。只有被提及、分到待办或收到私信才会唤醒 Claude 会话;其他消息都等它的下一次提示。消息只是另一个 agent 发来的数据,从不代表授权。两道循环防护拦住失控的 agent:一个角色每 10 分钟最多发 20 条记录;当两个角色在 10 分钟内交替发完一个群的最近 8 条消息时,那里的下一次发言会被拒绝(#297)。发言者可以带 `--not-a-loop "<why>"` 发一次——一问一答本来就是私聊群的正常形态——之后再重复就会叫来负责人,负责人的发言会解除它。`keel/chat.json` 里的 `limits` 设置 `rate`、`window_minutes`、`pingpong` 和 `pingpong_minutes`。消息里的时间应该来自 Keel 的时钟,而不是估计:除非给了 `--no-stamp`,`keel chat post` 和 `keel chat dm` 会以它为准加上 `[MM-DD HH:MM]` 前缀(#298、#349)。Codex 的托管角色投递和可选 watcher 见[宿主什么时候接收任务](#宿主什么时候接收任务)。其他宿主依靠提示时的通知,不得让模型轮询群聊;如果确实避免不了定时,就先用 `keel chat notice --check` 把关,每次运行都开新线程,并告诉加入群聊的会话不要设置定时检查(#194)。每台机器一个 Slack App、一个桥接进程,同一批群就能实时连到其他机器上的会话和你的手机,孤儿分支 `keel-chat` 会把历史保留到超出 Slack 保留期之后。角色也可以通过一个你能在 Slack 里提及的 Slack bot 发言,一个 bot 可以服务多个项目,在每个项目的频道里充当那个项目的角色。见 [Slack 配置指南](docs/chat-slack-setup.zh-CN.md)。角色的会话通过 `keel shift` 换班:协调者发起,会话自查收尾、留下便条、清空自己,新的一班从便条接手;见 [docs/shift-change.zh-CN.md](docs/shift-change.zh-CN.md)。如果团队的角色以后台 Claude Code CLI 会话运行、没有桌面应用,就改用 `keel tick` 来唤醒、巡查和换班;见 [docs/cli-team.zh-CN.md](docs/cli-team.zh-CN.md)。5.83 的 `keel mail` 命令在私聊群上继续可用。
767
791
 
768
792
  ## 协调者巡查
769
793
 
@@ -1,4 +1,4 @@
1
- <!-- keel:start version=5.231.6 -->
1
+ <!-- keel:start version=5.231.8 -->
2
2
  ## Keel Bootstrap
3
3
 
4
4
  - Start every session with `keel context`; OpenSpec artifacts and Git are the durable authority, and memory or transcripts may only inform.
@@ -8,4 +8,5 @@
8
8
  - Route Full (the OpenSpec flow) for new features, interface or protocol changes, cross-module work, or over ~3 files / 100 lines; Lite for local fixes with no interface change. No gate checks routing; a project corrects the size bar with `full_mode_paths:` in `keel/config.yaml`, which `keel context` reports.
9
9
  - SessionStart projections are disposable views, never authority; without the plugin, run the commands by hand.
10
10
  - Keel skills and hooks come from the `keel` native plugin (`codex plugin add` / `claude plugin install`); `keel --init` owns only the OpenSpec schema, overlays, and this bootstrap.
11
+ - Claude/Codex startup and prompt hints are separate from host-specific idle delivery.
11
12
  <!-- keel:end -->
package/bin/keel.js CHANGED
@@ -109,6 +109,7 @@ Usage:
109
109
  keel sync status [--repo <path>] [--verify] [--remote <name>] [--json] (what exists only on this machine; fetches nothing, --verify asks the remote its sha)
110
110
  keel patrol [--issues <file>] [--idle <dur>] [--since-last [--notify]] [--nudge] [--json] [--repo <path>] (the coordinator's patrol; keel patrol task prints its schedule)
111
111
  keel codex status|start|deliver|handover|drain|recover [--repo <path>] [--role <role>] [--socket <path>] [--json] (managed Codex roles; explicit host identity)
112
+ keel codex status [--repo <path>] --role <role> --record <id> [--json] (read the durable delivery receipt locally)
112
113
  keel codex inspect-registration --repo <path> --role <role> --thread <id> --socket <path> --authority <reference>
113
114
  keel codex register --plan <json-file> [--json]
114
115
  keel codex inspect-migration --repo <path> --role <role> --to-socket <path> --authority <reference>
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@christang/keel",
3
- "version": "5.231.6",
3
+ "version": "5.231.8",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@christang/keel",
9
- "version": "5.231.6",
9
+ "version": "5.231.8",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@fission-ai/openspec": "1.14.0"
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@christang/keel",
3
3
  "displayName": "Keel",
4
4
  "description": "Keel OpenSpec execution discipline CLI for Claude Code, Codex, and OpenCode.",
5
- "version": "5.231.6",
5
+ "version": "5.231.8",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keel",
3
- "version": "5.231.6",
3
+ "version": "5.231.8",
4
4
  "description": "Keel OpenSpec execution discipline: stateless continuity, task capsules, deterministic gates, and expectation alignment for Codex and Claude Code.",
5
5
  "author": {
6
6
  "name": "TanglmChris",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keel",
3
- "version": "5.231.6",
3
+ "version": "5.231.8",
4
4
  "description": "Keel OpenSpec execution discipline: stateless continuity, task capsules, deterministic gates, and expectation alignment for Codex and Claude Code.",
5
5
  "author": {
6
6
  "name": "TanglmChris",
@@ -8,7 +8,7 @@ const path=require('node:path');
8
8
  const fs=require('node:fs');
9
9
  const {spawn}=require('node:child_process');
10
10
  const cli=path.resolve(__dirname,'../bin/keel.js');
11
- function run(args,action="status"){return new Promise(resolve=>{const p=spawn(process.execPath,action==='tick'?[cli,'tick',...args]:[cli,'codex',action,...args]);let out='',err='';p.stdout.on('data',b=>out+=b);p.stderr.on('data',b=>err+=b);p.on('close',code=>resolve({code,out,err}));});}
11
+ function run(args,action="status"){return new Promise(resolve=>{const p=spawn(process.execPath,['chat','tick'].includes(action)?[cli,action,...args]:[cli,'codex',action,...args]);let out='',err='';p.stdout.on('data',b=>out+=b);p.stderr.on('data',b=>err+=b);p.on('close',code=>resolve({code,out,err}));});}
12
12
  test('managed CLI lifecycle, mailbox scheduling and frame boundaries',async()=>{
13
13
  const dir=fs.mkdtempSync(path.join(os.tmpdir(),'keel-host-'));const sock=path.join(dir,'host.sock');const requests=[];const requestDetails=[];const peers=[];const blank=new Set(),lost=new Set();let active=true,serial=0,uncertain=false,invalidHost=false,injectNotice=false,unloaded=false,resumeActive=false,resumeFails=false,resumeMismatch=false,readMismatch=false,resumeDelay=false,initNameFails=false;
14
14
  const server=http.createServer();server.on('upgrade',(req,s)=>{peers.push(s);s.on('end',()=>{for(const id of blank)lost.add(id);});s.write('HTTP/1.1 101 Switching Protocols\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: '+crypto.createHash('sha1').update(req.headers['sec-websocket-key']+'258EAFA5-E914-47DA-95CA-C5AB0DC85B11').digest('base64')+'\r\n\r\n');let initialized=false;let buf=Buffer.alloc(0);s.on('data',chunk=>{buf=Buffer.concat([buf,chunk]);while(buf.length>=6){let n=buf[1]&127,off=2;if(n===126){if(buf.length<8)return;n=buf.readUInt16BE(2);off=4;}else if(n===127){if(buf.length<14)return;n=Number(buf.readBigUInt64BE(2));off=10;}if(buf.length<off+4+n)return;const mask=buf.subarray(off,off+4);const data=Buffer.from(buf.subarray(off+4,off+4+n));buf=buf.subarray(off+4+n);for(let i=0;i<data.length;i++)data[i]^=mask[i%4];const x=JSON.parse(data);requests.push(x.method);requestDetails.push(x);if(x.method==='initialized'){initialized=true;continue;}if(!x.id)continue;if(x.method!=='initialize'&&!initialized){s.destroy();return;}if(x.method==='thread/read'&&lost.has(x.params.threadId)){const b=Buffer.from(JSON.stringify({id:x.id,error:{message:'thread not loaded: '+x.params.threadId}}));s.write(Buffer.concat([Buffer.from([129,b.length]),b]));continue;}if(x.method==='thread/name/set'&&!initNameFails)blank.delete(x.params.threadId);if(x.method==='thread/name/set'&&initNameFails){const b=Buffer.from(JSON.stringify({id:x.id,error:{message:'fixture name persistence failure'}}));s.write(Buffer.concat([Buffer.from([129,b.length]),b]));continue;}if(x.method==='thread/resume'){if(resumeFails){const b=Buffer.from(JSON.stringify({id:x.id,error:{message:'fixture resume failure'}}));s.write(Buffer.concat([Buffer.from([129,b.length]),b]));continue;}unloaded=false;if(resumeActive)active=true;}const result=x.method==='initialize'?(invalidHost?{}:{userAgent:'test-host'}):x.method==='turn/start'?{turn:uncertain?{}:{id:'turn-fixture'}}:{thread:{id:x.method==='thread/start'?`fixture-thread-${++serial}`:(x.params.threadId||'fixture-thread'),status:{type:unloaded?'notLoaded':active?'active':'idle'},cwd:(x.method==='thread/read'&&readMismatch)||(x.method==='thread/resume'&&resumeMismatch)?'/wrong-worktree':dir}};if(x.method==='thread/start')blank.add(result.thread.id);const b=Buffer.from(JSON.stringify({id:x.id,result}));const h=b.length<126?Buffer.from([129,b.length]):Buffer.from([129,126,b.length>>8,b.length&255]);const split=Math.floor(b.length/2);const frame=(op,body)=>Buffer.concat([body.length<126?Buffer.from([op,body.length]):Buffer.from([op,126,body.length>>8,body.length&255]),body]);if(injectNotice){const notice=Buffer.from(JSON.stringify({id:x.id,method:'server/notice',params:{}}));s.write(frame(129,notice));}const reply=()=>{if(!s.destroyed)s.write(Buffer.concat([frame(1,b.subarray(0,split)),frame(128,b.subarray(split))]));};if(resumeDelay&&x.method==='thread/resume')setTimeout(reply,5500).unref();else reply();}});});
@@ -28,6 +28,22 @@ test('managed CLI lifecycle, mailbox scheduling and frame boundaries',async()=>{
28
28
  const duplicate=await run(message,'deliver');assert.equal(duplicate.code,0,duplicate.err);assert.equal(requests.filter(x=>x==='turn/start').length,1);
29
29
  active=true;const waiting=await run(['--repo',dir,'--role','test-role','--note','finish fixture','--json'],'handover');assert.equal(waiting.code,0,waiting.err);assert.equal(JSON.parse(waiting.out).state,'waiting');assert.equal(serial,1);
30
30
  active=false;const handed=await run(['--repo',dir,'--role','test-role','--note','finish fixture','--json'],'handover');assert.equal(handed.code,0,handed.err);assert.equal(serial,2);assert.ok(requestDetails.some(x=>x.method==='thread/name/set'&&x.params.threadId==='fixture-thread-2'&&x.params.name==='test-role'),'successor must be persisted before handover succeeds');
31
+ const receiptFile=path.join(dir,'.git/keel-chat/codex-roles/test-role.json');
32
+ const receiptArgs=['--repo',dir,'--role','test-role','--json'];
33
+ const inspectReceipt=async record=>{
34
+ const before=fs.readFileSync(receiptFile);
35
+ const nativeRequests=requests.length;
36
+ const query=await run([...receiptArgs,'--record',record]);
37
+ assert.equal(query.code,0,query.err);
38
+ const parsed=JSON.parse(query.out);
39
+ return {parsed,before,nativeRequests};
40
+ };
41
+ const original=await inspectReceipt('fixture-record');
42
+ assert.deepEqual(original.parsed,{
43
+ role:'test-role',record:'fixture-record',state:'delivered',thread:'fixture-thread-1',turn:JSON.parse(sent.out).turn,
44
+ },'delivery receipt must preserve its original thread');
45
+ assert.equal(requests.length,original.nativeRequests);
46
+ assert.deepEqual(fs.readFileSync(receiptFile),original.before);
31
47
  const store=require('../src/core/chat/store');const where=store.requireLocation(dir);
32
48
  store.createGroup(where,'owner','team',['test-role']);
33
49
  store.writeRecord(where,{group:'team',kind:'message',from:'owner',mentions:['test-role'],text:'addressed fixture'});
@@ -36,11 +52,50 @@ test('managed CLI lifecycle, mailbox scheduling and frame boundaries',async()=>{
36
52
  const drained=await run(['--repo',dir,'--json'],'drain');assert.equal(drained.code,0,drained.err);assert.equal(requests.filter(x=>x==='turn/start').length,beforeDrain+1);
37
53
  const drainedAgain=await run(['--repo',dir,'--json'],'drain');assert.equal(drainedAgain.code,0,drainedAgain.err);assert.equal(requests.filter(x=>x==='turn/start').length,beforeDrain+1);
38
54
  const beforeTick=requests.filter(x=>x==='turn/start').length;
39
- store.writeRecord(where,{group:'team',kind:'message',from:'owner',mentions:['test-role'],text:'tick addressed fixture'});
55
+ const portableTodo=store.writeRecord(where,{group:'team',kind:'todo',from:'owner',assignee:'test-role',text:'tick addressed fixture'});
56
+ const readPortable=async ({id})=>{
57
+ const registryBefore=fs.readFileSync(receiptFile);
58
+ const nativeRequests=requests.length;
59
+ const read=await run(['--repo',dir,'show',id,'--json'],'chat');
60
+ assert.equal(read.code,0,read.err);
61
+ assert.equal(requests.length,nativeRequests,'query must not contact app-server');
62
+ assert.deepEqual(fs.readFileSync(receiptFile),registryBefore,'query must preserve the registry');
63
+ const view=JSON.parse(read.out);
64
+ assert.deepEqual(view.task,{id,state:'open',closureRecordId:null});
65
+ return view.delivery;
66
+ };
67
+ assert.deepEqual(await readPortable(portableTodo),{state:'unobserved'},'portable query needs an unobserved delivery state');
40
68
  const ticked=await run(['--repo',dir,'--json'],'tick');assert.equal(ticked.code,0,ticked.err);assert.ok(JSON.parse(ticked.out).codex.some(x=>x.state==='delivered'));assert.equal(requests.filter(x=>x==='turn/start').length,beforeTick+1);
41
- uncertain=true;const failedMessage=['--repo',dir,'--role','test-role','--record','uncertain-record','--text','read pending','--json'];const failed=await run(failedMessage,'deliver');assert.notEqual(failed.code,0);const retried=await run(failedMessage,'deliver');assert.notEqual(retried.code,0);assert.match(retried.err,/unknown/);assert.equal(requests.filter(x=>x==='turn/start').length,4);
69
+ assert.deepEqual(await readPortable(portableTodo),{state:'acknowledged'});
70
+ const noReceipt=store.writeRecord(where,{group:'team',kind:'todo',from:'test-role',assignee:'owner',text:'no native receipt'});
71
+ assert.deepEqual(await readPortable(noReceipt),{state:'unobserved'});
72
+ const uncertainTodo=store.writeRecord(where,{group:'team',kind:'todo',from:'owner',assignee:'test-role',text:'ambiguous native receipt'});
73
+ uncertain=true;const failedMessage=['--repo',dir,'--role','test-role','--record',uncertainTodo.id,'--text','read pending','--json'];const failed=await run(failedMessage,'deliver');assert.notEqual(failed.code,0);const retried=await run(failedMessage,'deliver');assert.notEqual(retried.code,0);assert.match(retried.err,/unknown/);assert.equal(requests.filter(x=>x==='turn/start').length,4);
42
74
  const lock=path.join(dir,'.git/keel-chat/codex-roles/test-role.json.lock');fs.writeFileSync(lock,'owned by another process');const locked=await run(message,'deliver');assert.notEqual(locked.code,0);assert.equal(fs.readFileSync(lock,'utf8'),'owned by another process');fs.unlinkSync(lock);
43
75
  const registry=JSON.parse(fs.readFileSync(path.join(dir,'.git/keel-chat/codex-roles/test-role.json')));assert.equal(registry.history.length,1);assert.equal(registry.history[0].note,'finish fixture');
76
+ const pending=await inspectReceipt(uncertainTodo.id);
77
+ assert.deepEqual(pending.parsed,{role:'test-role',record:uncertainTodo.id,state:'unknown',thread:'fixture-thread-2',turn:null});
78
+ assert.equal(requests.length,pending.nativeRequests);
79
+ assert.deepEqual(fs.readFileSync(receiptFile),pending.before);
80
+ assert.deepEqual(await readPortable(uncertainTodo),{state:'unknown'});
81
+ fs.writeFileSync(receiptFile,'{');
82
+ try {
83
+ assert.deepEqual(await readPortable(portableTodo),{state:'unknown'});
84
+ } finally {
85
+ fs.writeFileSync(receiptFile,pending.before);
86
+ }
87
+ const absent=await inspectReceipt('unrecorded-fixture');
88
+ assert.deepEqual(absent.parsed,{role:'test-role',record:'unrecorded-fixture',state:'unrecorded',thread:null,turn:null});
89
+ assert.equal(requests.length,absent.nativeRequests);
90
+ const legacyRecord='legacy-receipt';
91
+ const legacyKey=require('node:crypto').createHash('sha256').update(legacyRecord).digest('hex');
92
+ registry.deliveries[legacyKey]={record:legacyRecord,state:'delivered',turn:'old-native-turn'};
93
+ fs.writeFileSync(receiptFile,JSON.stringify(registry));
94
+ const legacy=await inspectReceipt(legacyRecord);
95
+ assert.deepEqual(legacy.parsed,{role:'test-role',record:legacyRecord,state:'delivered',thread:null,turn:'old-native-turn'});
96
+ assert.equal(requests.length,legacy.nativeRequests);
97
+ assert.deepEqual(fs.readFileSync(receiptFile),legacy.before);
98
+
44
99
 
45
100
  uncertain=false;const large=await run(['--repo',dir,'--role','test-role','--record','large-record','--text','x'.repeat(70000),'--json'],'deliver');assert.equal(large.code,0,large.err);
46
101
  const raceBefore=requests.filter(x=>x==='turn/start').length;const raceArgs=['--repo',dir,'--role','test-role','--record','concurrent-record','--text','concurrent fixture','--json'];const raced=await Promise.all([run(raceArgs,'deliver'),run(raceArgs,'deliver')]);assert.ok(raced.some(x=>x.code===0));assert.equal(requests.filter(x=>x==='turn/start').length,raceBefore+1);
@@ -53,7 +108,7 @@ test('managed CLI lifecycle, mailbox scheduling and frame boundaries',async()=>{
53
108
  const recovered=await run(recoveryArgs('recovery-record'),'deliver');assert.equal(recovered.code,0,recovered.err);assert.equal(JSON.parse(recovered.out).state,'delivered');assert.equal(resumes(),rb+1);assert.equal(turns(),tb+1);assert.equal(serial,2);
54
109
  const resumeRequest=requestDetails.find(x=>x.method==='thread/resume');assert.deepEqual(resumeRequest.params,{threadId:'fixture-thread-2',serviceName:'keel'});
55
110
  unloaded=true;rb=resumes();tb=turns();const recoveredDuplicate=await run(recoveryArgs('recovery-record'),'deliver');assert.equal(recoveredDuplicate.code,0,recoveredDuplicate.err);assert.equal(resumes(),rb);assert.equal(turns(),tb);
56
- const unknown=await run(recoveryArgs('uncertain-record'),'deliver');assert.notEqual(unknown.code,0);assert.match(unknown.err,/unknown/);assert.equal(resumes(),rb);
111
+ const unknown=await run(recoveryArgs(uncertainTodo.id),'deliver');assert.notEqual(unknown.code,0);assert.match(unknown.err,/unknown/);assert.equal(resumes(),rb);
57
112
  resumeActive=true;const busyRecovery=await run(recoveryArgs('busy-recovery'),'deliver');assert.equal(busyRecovery.code,0,busyRecovery.err);assert.equal(JSON.parse(busyRecovery.out).state,'waiting');assert.equal(turns(),tb);resumeActive=false;active=false;
58
113
  unloaded=true;resumeFails=true;const failedRecovery=await run(recoveryArgs('failed-recovery'),'deliver');assert.notEqual(failedRecovery.code,0);assert.match(failedRecovery.err,/fixture resume failure/);assert.equal(turns(),tb);resumeFails=false;
59
114
  unloaded=true;resumeMismatch=true;const mismatchRecovery=await run(recoveryArgs('mismatch-recovery'),'deliver');assert.notEqual(mismatchRecovery.code,0);assert.match(mismatchRecovery.err,/identity/);assert.equal(turns(),tb);resumeMismatch=false;
@@ -35,10 +35,10 @@ os.environ["KEEL_UPDATE_CLAUDE"] = str(Path(tempfile.gettempdir()) / "keel-suite
35
35
  os.environ["KEEL_UPDATE_CODEX"] = str(Path(tempfile.gettempdir()) / "keel-suite-has-no-codex")
36
36
 
37
37
 
38
- PACKAGE_VERSION = "5.231.6"
38
+ PACKAGE_VERSION = "5.231.8"
39
39
 
40
40
 
41
- PROTOCOL_VERSION = "5.231.6"
41
+ PROTOCOL_VERSION = "5.231.8"
42
42
 
43
43
 
44
44
  LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
@@ -5487,8 +5487,22 @@ def validate_external_agent_catalog_scenario() -> int:
5487
5487
  write_gate_fixture(repo, standing_authorization_task())
5488
5488
  write_authorize_config(repo, "external_agents:\n allow:\n - codex\n")
5489
5489
 
5490
- def listing() -> dict | None:
5491
- result = run_keel(repo, "agents", "--json", env=env)
5490
+ # Stand in only for the platform and filesystem location of the macOS bundle.
5491
+ bundle_path = "/Applications/DeepSeek Harness.app/Contents/Resources/runtime/cli/bin/dsh"
5492
+ probe = base / "dsh-fixture-platform.cjs"
5493
+ probe.write_text(
5494
+ 'Object.defineProperty(process, "platform", {value: process.env.FIXTURE_PLATFORM});\n'
5495
+ 'const fs = require("node:fs");\n'
5496
+ 'for (const method of ["accessSync", "statSync"]) {\n'
5497
+ ' const original = fs[method];\n'
5498
+ f' fs[method] = (file, ...args) => original(file === {json.dumps(bundle_path)}\n'
5499
+ ' ? process.env.FIXTURE_BUNDLE : file, ...args);\n'
5500
+ '}\n', encoding="utf-8")
5501
+ platform_env = {**env, "NODE_OPTIONS": f'--require="{probe}"',
5502
+ "FIXTURE_PLATFORM": "linux", "FIXTURE_BUNDLE": str(base / "missing-bundle")}
5503
+
5504
+ def listing(override_env: dict | None = None) -> dict | None:
5505
+ result = run_keel(repo, "agents", "--json", env=override_env or platform_env)
5492
5506
  try:
5493
5507
  return json.loads(result.stdout)
5494
5508
  except json.JSONDecodeError:
@@ -5508,12 +5522,27 @@ def validate_external_agent_catalog_scenario() -> int:
5508
5522
  if agents["codex"].get("resolved") != stub:
5509
5523
  report(f"{label} codex resolved to {agents['codex'].get('resolved')!r}, not the stub on PATH.")
5510
5524
  return 1
5511
- dsh_path = agents["dsh"].get("executable")
5512
- expected = dsh_path if dsh_path and Path(dsh_path).exists() else None
5513
- if agents["dsh"].get("resolved") != expected:
5514
- report(f"{label} dsh resolution {agents['dsh'].get('resolved')!r} disagrees with "
5515
- f"whether {dsh_path!r} exists.")
5516
- return 1
5525
+ standalone = base / "bin" / "dsh"
5526
+ if agents["dsh"].get("resolved") != str(standalone):
5527
+ report(f"{label} DSH did not resolve from fixture PATH: {agents['dsh']}")
5528
+ return 1
5529
+ mac_env = {**platform_env, "FIXTURE_PLATFORM": "darwin"}
5530
+ bundle_env = {**mac_env, "FIXTURE_BUNDLE": stub}
5531
+ for fixture_env, expected in ((mac_env, str(standalone)), (bundle_env, bundle_path)):
5532
+ mac = listing(fixture_env)
5533
+ observed = next(row for row in mac["agents"] if row["name"] == "dsh")
5534
+ assert observed["resolved"] == expected, observed
5535
+ # Prevent the machine's real PATH from satisfying the missing case.
5536
+ for tool in ("node", "git"):
5537
+ binary = shutil.which(tool)
5538
+ assert binary is not None, tool
5539
+ (base / "bin" / tool).symlink_to(binary)
5540
+ standalone.chmod(0o644)
5541
+ try:
5542
+ missing = listing({**platform_env, "PATH": str(base / "bin")})
5543
+ assert next(row for row in missing["agents"] if row["name"] == "dsh")["resolved"] is None
5544
+ finally:
5545
+ standalone.chmod(0o755)
5517
5546
  if agents["codex"].get("allowed") is not True or agents["dsh"].get("allowed") is not False:
5518
5547
  report(f"{label} allowance is not read from external_agents: allow: "
5519
5548
  f"codex={agents['codex'].get('allowed')!r} dsh={agents['dsh'].get('allowed')!r}")
@@ -5562,20 +5591,24 @@ def validate_external_agent_catalog_scenario() -> int:
5562
5591
  return 1
5563
5592
 
5564
5593
  # A machine entry declaring one field overrides that field only.
5565
- custom = base / "bin" / "dsh"
5594
+ custom = base / "custom-dsh"
5595
+ custom.symlink_to(standalone)
5566
5596
  (base / "home" / "agents.json").write_text(
5567
5597
  json.dumps({"agents": {"dsh": {"executable": str(custom)}}}), encoding="utf-8")
5568
- payload = listing()
5598
+ payload = listing(bundle_env)
5569
5599
  if payload is None:
5570
5600
  return 1
5571
5601
  dsh = {item.get("name"): item for item in payload.get("agents") or []}.get("dsh") or {}
5572
- if dsh.get("source") != "machine" or dsh.get("executable") != str(custom):
5602
+ if dsh.get("source") != "machine" or dsh.get("resolved") != str(custom):
5573
5603
  report(f"{label} the machine entry did not override dsh: {dsh}")
5574
5604
  return 1
5575
5605
  if dsh.get("command") != agents["dsh"].get("command"):
5576
5606
  report(f"{label} a machine entry declaring only an executable replaced the bundled template.")
5577
5607
  return 1
5578
5608
 
5609
+ custom.unlink()
5610
+ unresolved = listing(bundle_env)
5611
+ assert next(row for row in unresolved["agents"] if row["name"] == "dsh")["resolved"] is None
5579
5612
  # A malformed machine file is named and none of it is used.
5580
5613
  (base / "home" / "agents.json").write_text("{not json", encoding="utf-8")
5581
5614
  payload = listing()
@@ -5785,6 +5818,11 @@ def validate_external_agent_brief_scenario() -> int:
5785
5818
  report(f"{label} a helper worktree under .claude/worktrees/ was refused from a sibling worktree: "
5786
5819
  f"{out.strip()[:600]}")
5787
5820
  return 1
5821
+ if sys.platform == "linux":
5822
+ catalog = run_keel(repo, "agents", "--json", env=env)
5823
+ dsh = next(row for row in json.loads(catalog.stdout)["agents"] if row["name"] == "dsh")
5824
+ assert dsh["resolved"] == str(base / "bin" / "dsh"), "DSH did not resolve from fixture PATH"
5825
+ assert dsh["resolved"] in (payload.get("run") or ""), "brief and catalog disagree"
5788
5826
  # Issue #259: a dsh brief keeps temporary files in tmp/ beside the brief.
5789
5827
  tmp = prompt.parent / "tmp"
5790
5828
  if not tmp.is_dir():
@@ -24,6 +24,7 @@ const FIELDS = ["executable", "command", "sandbox", "ownSandbox", "sendsTo", "pi
24
24
  const MODES = ["helper", "implementation"];
25
25
 
26
26
  const RTL_TOOLCHAIN = "rtl_ppa_prj docs/toolchain.md (main 632ad85)";
27
+ const DSH_MAC_BUNDLE = "/Applications/DeepSeek Harness.app/Contents/Resources/runtime/cli/bin/dsh";
27
28
 
28
29
  const BUNDLED = {
29
30
  codex: {
@@ -70,7 +71,7 @@ const BUNDLED = {
70
71
  ],
71
72
  },
72
73
  dsh: {
73
- executable: "/Applications/DeepSeek Harness.app/Contents/Resources/runtime/cli/bin/dsh",
74
+ executable: "dsh",
74
75
  command: "cd {dir} && TMPDIR={tmp} PYTHONPYCACHEPREFIX={tmp}/pycache {executable} --profile headless - < {prompt} > {out}",
75
76
  sandbox: { helper: null, implementation: null },
76
77
  ownSandbox: "the headless profile applies its own workspace-write file policy: outside the directory it starts in, writes are refused (including /dev/stdout and ~/Library/Caches) while /tmp stays writable; inside it, it writes freely, so it still needs a separate worktree (dsh 0.2.0-rc.2, #259)",
@@ -79,7 +80,7 @@ const BUNDLED = {
79
80
  {
80
81
  date: "2026-10-05",
81
82
  source: "ls -l ~/.local/bin/dsh and dsh --version, 0.2.0-rc.2 (rtl_ppa_prj #191)",
82
- text: "The CLI lives inside the app bundle. A `~/.local/bin/dsh` on PATH, where one exists, is a symlink to that same file, so the catalog keeps the bundle path, which works with or without it.",
83
+ text: "In this macOS installation, the CLI lives inside the app bundle and `~/.local/bin/dsh` is a symlink to that file. Keel prefers the executable bundle on macOS and otherwise looks for `dsh` on PATH.",
83
84
  },
84
85
  {
85
86
  date: "2026-10-05",
@@ -177,7 +178,10 @@ function loadCatalog() {
177
178
  const problems = [];
178
179
  const entries = {};
179
180
  for (const [name, entry] of Object.entries(BUNDLED)) {
180
- entries[name] = { name, source: "bundled", ...clone(entry) };
181
+ const executable = name === "dsh" && process.platform === "darwin" && isExecutable(DSH_MAC_BUNDLE)
182
+ ? DSH_MAC_BUNDLE
183
+ : entry.executable;
184
+ entries[name] = { name, source: "bundled", ...clone(entry), executable };
181
185
  }
182
186
  for (const [name, declared] of Object.entries(readMachineEntries(problems))) {
183
187
  if (!declared || typeof declared !== "object" || Array.isArray(declared)) {
@@ -8,6 +8,7 @@
8
8
  const fs = require("fs");
9
9
  const path = require("path");
10
10
  const { spawnSync } = require("child_process");
11
+ const { listWorktrees } = require("./worktrees");
11
12
 
12
13
  const REMOTE = "origin";
13
14
 
@@ -80,9 +81,8 @@ function refs(cwd, prefix) {
80
81
  }
81
82
 
82
83
  function checkedOut(cwd) {
83
- const listed = git(cwd, ["worktree", "list", "--porcelain"]);
84
- return new Set(listed.out.split("\n").filter((line) => line.startsWith("branch refs/heads/"))
85
- .map((line) => line.slice("branch refs/heads/".length)));
84
+ const checkedOutBranches = listWorktrees(cwd, { optional: true }).map((row) => row.branch).filter(Boolean);
85
+ return new Set(checkedOutBranches);
86
86
  }
87
87
 
88
88
  // Branches a worktree bound to the role has checked out, from its own HEAD
@@ -498,6 +498,8 @@ function dispatch(where, options) {
498
498
  if (record.kind === "todo") {
499
499
  const closure = store.todoClosure(where, record);
500
500
  result.task = { id: record.id, state: closure ? "closed" : "open", closureRecordId: closure ? closure.id : null };
501
+ const { recordedDeliveryState } = require("../codex-host");
502
+ result.delivery = { state: recordedDeliveryState(where, record.assignee, record.id) };
501
503
  }
502
504
  out(JSON.stringify(result));
503
505
  } else out([`${record.group} ${formatLine(record)}`, `read by: ${readers.join(", ") || "nobody yet"}`, ...(acks ? ackLines(acks) : [])].join("\n"));
@@ -118,6 +118,35 @@ function connect(socketPath, timeout = 5000) {
118
118
  });
119
119
  }
120
120
 
121
+ function deliveryKey(record) {
122
+ return crypto.createHash("sha256").update(record).digest("hex");
123
+ }
124
+
125
+ function deliveryReceipt(role, record) {
126
+ const claim = role.deliveries?.[deliveryKey(record)];
127
+ if (claim && claim.record !== record) throw Error("managed delivery claim identity mismatch");
128
+ const turn = claim?.state === "delivered" && typeof claim.turn === "string" && claim.turn ? claim.turn : null;
129
+ const thread = typeof claim?.thread === "string" && claim.thread ? claim.thread : null;
130
+ const state = !claim ? "unrecorded" : turn ? "delivered" : "unknown";
131
+ return { role: role.role, record, state, thread, turn };
132
+ }
133
+
134
+ function recordedDeliveryState(where, assignee, record) {
135
+ const fs = require("node:fs");
136
+ const store = require("./chat/store");
137
+ try {
138
+ store.checkName(assignee, "Assignee");
139
+ const file = path.join(where.root, "codex-roles", `${assignee}.json`);
140
+ const role = JSON.parse(fs.readFileSync(file, "utf8"));
141
+ if (role?.role !== assignee || role.state !== "managed") return "unknown";
142
+ const receipt = deliveryReceipt(role, record);
143
+ if (receipt.state === "delivered") return "acknowledged";
144
+ return receipt.state === "unrecorded" ? "unobserved" : "unknown";
145
+ } catch (error) {
146
+ return error.code === "ENOENT" ? "unobserved" : "unknown";
147
+ }
148
+ }
149
+
121
150
  async function run(args) {
122
151
  const onboarding = require("./codex-onboarding");
123
152
  if (onboarding.actions.includes(args[0])) return onboarding.run(args, {connect});
@@ -172,6 +201,13 @@ async function run(args) {
172
201
  options.thread = recorded.thread;
173
202
  }
174
203
  }
204
+ if (action === "status" && options.record) {
205
+ if (!recorded || recorded.role !== options.role) throw Error("delivery receipt needs an owned --role");
206
+ const receipt = deliveryReceipt(recorded, options.record);
207
+ process.stdout.write((options.json ? JSON.stringify(receipt)
208
+ : `Codex delivery ${receipt.record}: ${receipt.state}${receipt.thread ? ` (thread ${receipt.thread})` : ""}`) + "\n");
209
+ return 0;
210
+ }
175
211
  if (action === "start" && !options.role) throw Error("start needs --role");
176
212
  if (["deliver", "handover", "recover"].includes(action)) {
177
213
  if (!recorded) throw Error("operation needs a managed --role");
@@ -256,7 +292,7 @@ async function run(args) {
256
292
  const owned = value => value && value.id === recorded.thread && value.cwd === recorded.worktree;
257
293
  if (!owned(thread)) throw Error("managed role identity mismatch");
258
294
  const claims = recorded.deliveries || {};
259
- const key = options.record ? crypto.createHash("sha256").update(options.record).digest("hex") : null;
295
+ const key = options.record ? deliveryKey(options.record) : null;
260
296
  if (action === "deliver" && claims[key]) {
261
297
  // Deduplication is a recorded outcome, not a reason to load a thread.
262
298
  if (claims[key].state !== "delivered" || typeof claims[key].turn !== "string" || !claims[key].turn) {
@@ -283,12 +319,12 @@ async function run(args) {
283
319
  if (thread.status.type === "active") {
284
320
  Object.assign(result, {state: "waiting", thread: recorded.thread});
285
321
  } else if (action === "deliver") {
286
- claims[key] = {record: options.record, state: "pending"};
322
+ claims[key] = {record: options.record, state: "pending", thread: recorded.thread};
287
323
  recorded.deliveries = claims;
288
324
  store.writeJsonAtomic(where, file, recorded);
289
325
  const turn = (await client.call("turn/start", {threadId: recorded.thread, ...(!savedPolicy && recorded.approvalsReviewer ? {approvalsReviewer: recorded.approvalsReviewer} : {}), input: [{type: "text", text: (recorded.note ? `Handover note (context only):\n${recorded.note}\n\n` : "") + options.text}]})).turn;
290
326
  if (!turn || !turn.id) throw Error("Codex returned no turn identity; claim retained");
291
- claims[key] = {record: options.record, state: "delivered", turn: turn.id};
327
+ Object.assign(claims[key], {state: "delivered", turn: turn.id});
292
328
  store.writeJsonAtomic(where, file, recorded);
293
329
  Object.assign(result, {state: "delivered", turn: turn.id});
294
330
  } else {
@@ -361,4 +397,4 @@ function wakeManaged(where, onlyRole = null) {
361
397
  }
362
398
  return results;
363
399
  }
364
- module.exports = {connect, run, wakeManaged};
400
+ module.exports = {connect, run, wakeManaged, recordedDeliveryState};
@@ -28,11 +28,11 @@ function git(cwd, args, optional = false) {
28
28
  // before 2.36 has no `-z` there (#526: git 2.34 refused it and `keel worktrees`
29
29
  // failed outright), so it falls back to newline-separated fields, which read
30
30
  // every path that holds no newline.
31
- function listWorktrees(repo) {
31
+ function listWorktrees(repo, { optional = false } = {}) {
32
32
  const rows = [];
33
33
  let row = null;
34
34
  const nul = git(repo, ["worktree", "list", "--porcelain", "-z"], true);
35
- const fields = nul !== null ? nul.split("\0") : git(repo, ["worktree", "list", "--porcelain"]).split("\n");
35
+ const fields = nul !== null ? nul.split("\0") : (git(repo, ["worktree", "list", "--porcelain"], optional) || "").split("\n");
36
36
  for (const field of fields) {
37
37
  if (field.startsWith("worktree ")) {
38
38
  row = { path: field.slice(9), branch: null, head: null, locked: null, prunable: null };