@christang/keel 5.84.0 → 5.86.0
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.
- package/README.md +49 -5
- package/README.zh-CN.md +34 -0
- package/assets/bootstrap/AGENTS.md +2 -2
- package/assets/openspec/schemas/keel-spec-driven/schema.yaml +3 -3
- package/assets/openspec/schemas/keel-spec-driven/templates/tasks.md +3 -3
- package/bin/keel.js +60 -7
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/plugins/keel/.claude-plugin/plugin.json +1 -1
- package/plugins/keel/.codex-plugin/plugin.json +2 -1
- package/plugins/keel/agents/keel-single-task-goal-claude.md +1 -1
- package/plugins/keel/agents/keel-single-task-goal-codex.md +1 -1
- package/plugins/keel/hooks/codex.json +44 -0
- package/plugins/keel/scripts/codex-mail-hook.js +75 -0
- package/plugins/keel/scripts/mail-hook.js +11 -9
- package/plugins/keel/skills/keel-run-single-task-goal/SKILL.md +2 -2
- package/plugins/keel/skills/keel-run-single-task-goal/guidance.md +1 -1
- package/scripts/fake_slack.py +277 -0
- package/scripts/validate_codex_receiving.py +296 -0
- package/scripts/validate_plugin.py +1922 -227
- package/src/core/capabilities.js +2 -2
- package/src/core/chat/archive.js +234 -0
- package/src/core/chat/bridge.js +808 -0
- package/src/core/chat/cli.js +465 -0
- package/src/core/chat/config.js +64 -0
- package/src/core/chat/guards.js +96 -0
- package/src/core/chat/lifecycle.js +214 -0
- package/src/core/chat/migrate.js +142 -0
- package/src/core/chat/notice.js +216 -0
- package/src/core/chat/redact.js +37 -0
- package/src/core/chat/slack.js +104 -0
- package/src/core/chat/store.js +776 -0
- package/src/core/chat/view.js +169 -0
- package/src/core/config.js +36 -10
- package/src/core/mail.js +123 -433
- package/src/core/projection.js +43 -24
- package/src/core/task-contract.js +3 -3
package/README.md
CHANGED
|
@@ -76,6 +76,15 @@ keel --version
|
|
|
76
76
|
codex plugin add keel@<marketplace> # Codex
|
|
77
77
|
```
|
|
78
78
|
|
|
79
|
+
For Codex, start a fresh session after updating the plugin and review its current
|
|
80
|
+
hook definitions with `/hooks` in the CLI. Installation does not grant hook trust.
|
|
81
|
+
Bind a mailbox role with `keel mail role --set codex-maint`; trusted hooks announce
|
|
82
|
+
unread mail at session start and the next user input without marking it read.
|
|
83
|
+
If receiving hooks are unavailable, use `keel mail list` and `keel mail read`
|
|
84
|
+
explicitly. Codex idle wake-up and native write-guard enforcement remain unverified.
|
|
85
|
+
See the [Codex acceptance record](docs/codex-validation.md) for versions, runtime
|
|
86
|
+
evidence, limitations and the clean-consumer Full-mode check.
|
|
87
|
+
|
|
79
88
|
A global `keel` comes first on PATH, ahead of the plugin's copy, so on Claude Code the agent runs
|
|
80
89
|
it instead. Keep it at the plugin's version or remove it (`npm rm -g @christang/keel`); the
|
|
81
90
|
session-start line names it whenever the two disagree.
|
|
@@ -123,6 +132,20 @@ keel context # what to do now, recomputed from OpenSpec + Git
|
|
|
123
132
|
keel --doctor # check everything is wired up
|
|
124
133
|
```
|
|
125
134
|
|
|
135
|
+
To refresh OpenSpec's generated templates, run `keel openspec update`. After a
|
|
136
|
+
successful update, Keel restores its overlays for every target installed in the
|
|
137
|
+
repository. `keel --doctor` also reports overlay health for the other installed
|
|
138
|
+
targets, so healthy Claude coverage cannot hide missing Codex overlays.
|
|
139
|
+
|
|
140
|
+
Subagent use is the model's execution choice, subject to the host's policy.
|
|
141
|
+
`keel project --event subagent-start --change <change> --task <id>` produces a
|
|
142
|
+
read-only helper brief without extra activation. Add `--subagent-mode implementation`
|
|
143
|
+
for a delegate inside the task's Touch boundary; it requires an implementation
|
|
144
|
+
task and a matching active guard, while `delegation.tier` is optional metadata.
|
|
145
|
+
The current agent reviews returns, re-runs verification, and owns completion.
|
|
146
|
+
This CLI projects a brief; it does not spawn an agent or prove hook enforcement.
|
|
147
|
+
Native goal activation still requires explicit authorization.
|
|
148
|
+
|
|
126
149
|
Do the spec work through OpenSpec's commands (`/opsx:propose`, `/opsx:apply`, `/opsx:sync`,
|
|
127
150
|
`/opsx:archive`). Keel's gates run at the task boundaries. The whole loop:
|
|
128
151
|
|
|
@@ -150,7 +173,7 @@ because a permission granted in conversation does not survive a context reset. D
|
|
|
150
173
|
`keel/config.yaml` instead:
|
|
151
174
|
|
|
152
175
|
```yaml
|
|
153
|
-
authorize: # accepted names: commit, push, release, archive, continuation, issue:<owner>/<repo>, protocol-refresh
|
|
176
|
+
authorize: # accepted names: commit, push, release, archive, continuation, issue:<owner>/<repo>, protocol-refresh, chat-reply:<group>
|
|
154
177
|
- commit
|
|
155
178
|
- push
|
|
156
179
|
```
|
|
@@ -169,9 +192,9 @@ question — still stops. It authorizes no repository action and schedules nothi
|
|
|
169
192
|
whose vocabulary predates the word, the entry is unrecognized and the whole declaration authorizes
|
|
170
193
|
nothing until corrected — fail-closed, never a silent grant.
|
|
171
194
|
|
|
172
|
-
`issue:<owner>/<repo>`, the sixth name,
|
|
173
|
-
|
|
174
|
-
already bounded by the repository you declared it in. The credentials that open an issue are not:
|
|
195
|
+
`issue:<owner>/<repo>`, the sixth name, names the resource it reaches, and it is refused without
|
|
196
|
+
one; `chat-reply:<group>`, the eighth, is the only other name that does. The other names act on the
|
|
197
|
+
checkout the declaration sits in, so each is already bounded by the repository you declared it in. The credentials that open an issue are not:
|
|
175
198
|
`gh` is account-wide, so a bare `issue` would reach every repository your account can touch —
|
|
176
199
|
silently the widest entry in the file, and wider than `push`. Naming the repository keeps the
|
|
177
200
|
grant the size of what it says. Keel carries that scope to `keel --doctor` and to the compiled
|
|
@@ -188,6 +211,14 @@ the refresh writes outside that task's `Touch`, and it never commits: the diff i
|
|
|
188
211
|
and committing it is a separate action that a declared `commit` covers like any other. On an older
|
|
189
212
|
Keel whose vocabulary predates the word, the declaration authorizes nothing until corrected.
|
|
190
213
|
|
|
214
|
+
`chat-reply:<group>`, the eighth name, lets a session answer, in that `keel chat` group, a record
|
|
215
|
+
addressed to its own role — a mention, an assigned todo, or a direct message — by replying, sending
|
|
216
|
+
the sender a direct message, or closing the todo, without asking you first. Every new session would
|
|
217
|
+
otherwise ask, because a chat message is data and grants nothing. It never covers acting on what the
|
|
218
|
+
message asks for — editing files, running commands that change state, committing, pushing, sending
|
|
219
|
+
anything outside the chat — and the chat notice says so beside its data-not-instruction sentence. It
|
|
220
|
+
is declared once per group and refused bare: in a Slack-enabled group a reply leaves the machine.
|
|
221
|
+
|
|
191
222
|
Three things the declaration is not:
|
|
192
223
|
|
|
193
224
|
- **Not a way past a gate.** It authorizes the action, never the proof. `keel gate task-complete`
|
|
@@ -195,7 +226,7 @@ Three things the declaration is not:
|
|
|
195
226
|
anything.
|
|
196
227
|
- **Not a trigger.** It removes a confirmation, not the step that reaches the action. Nothing
|
|
197
228
|
schedules itself, and no next task is selected for you.
|
|
198
|
-
- **Not open-ended.** The
|
|
229
|
+
- **Not open-ended.** The eight names above are the whole vocabulary. An unrecognized entry is
|
|
199
230
|
reported with the accepted names and the declaration authorizes nothing until you fix it — a
|
|
200
231
|
typo never becomes a silent grant.
|
|
201
232
|
|
|
@@ -607,6 +638,10 @@ This changes only what Keel *recommends*. No gate, the write guard, and completi
|
|
|
607
638
|
exactly as they would without it, and `keel context --change <paused>` still selects it — you asked
|
|
608
639
|
for it by name. Keel never pauses a change on its own.
|
|
609
640
|
|
|
641
|
+
## Group chat between sessions
|
|
642
|
+
|
|
643
|
+
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. Each member has its own unread state, and history is kept. 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. A host that cannot wake on its own should rely 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: see [the Slack setup guide](docs/chat-slack-setup.md). The 5.83 `keel mail` commands keep working on direct groups.
|
|
644
|
+
|
|
610
645
|
## Commands
|
|
611
646
|
|
|
612
647
|
```bash
|
|
@@ -628,6 +663,15 @@ keel guard clear --json
|
|
|
628
663
|
keel lenses list
|
|
629
664
|
keel lenses add <name> [--force]
|
|
630
665
|
|
|
666
|
+
# Group chat between sessions (see docs/chat-slack-setup.md for Slack)
|
|
667
|
+
keel chat role --set <role> [--alias <a>]
|
|
668
|
+
keel chat group create <g> [--member <r>]... | add | remove | archive | list
|
|
669
|
+
keel chat <g> [<text>] [--since 2h] [--follow] # read, or post
|
|
670
|
+
keel chat dm <role> <text> | todo <g> --assignee <r> <text> | todos [--mine]
|
|
671
|
+
keel chat unread | read | notice | search <text>
|
|
672
|
+
keel chat bridge add | install | status | pause <2h> | stop | start | uninstall
|
|
673
|
+
keel chat archive sync | pull
|
|
674
|
+
|
|
631
675
|
# Unattended triage — may this issue start work without asking?
|
|
632
676
|
# Keel never fetches the issue; pass what gh returned. At least one of the two.
|
|
633
677
|
keel triage [--labels <l1,l2>] [--issue <n>] [--json]
|
package/README.zh-CN.md
CHANGED
|
@@ -111,6 +111,17 @@ keel context # 现在该做什么,从 OpenSpec + Git 重算
|
|
|
111
111
|
keel --doctor # 检查各部分是否就位
|
|
112
112
|
```
|
|
113
113
|
|
|
114
|
+
更新 OpenSpec 生成的模板正文时,运行 `keel openspec update`。更新成功后,Keel 会为仓库
|
|
115
|
+
中所有已安装的 target 恢复 overlay。`keel --doctor` 也会逐项报告其他已安装 target 的
|
|
116
|
+
overlay 状态,避免 Claude 检查正常时漏掉 Codex 的缺失。
|
|
117
|
+
|
|
118
|
+
是否使用 subagent 由模型选择,仍须遵守宿主政策。运行
|
|
119
|
+
`keel project --event subagent-start --change <change> --task <id>` 可生成只读 helper
|
|
120
|
+
brief,无须额外激活许可。加 `--subagent-mode implementation` 可生成实现委派 brief,
|
|
121
|
+
要求当前任务为 implementation,且有效 guard 匹配任务、指纹和 Touch;`delegation.tier`
|
|
122
|
+
只是可选能力元数据。主 agent 审查返回结果、独立重跑验证并负责完成判定。CLI 只生成
|
|
123
|
+
brief,不启动 agent,也不证明 hook 实际执行;native goal 仍须明确授权激活。
|
|
124
|
+
|
|
114
125
|
spec 相关的活走 OpenSpec 的命令(`/opsx:propose`、`/opsx:apply`、`/opsx:sync`、`/opsx:archive`),
|
|
115
126
|
Keel 的门禁在任务边界处运行。整个回路:
|
|
116
127
|
|
|
@@ -170,6 +181,20 @@ keel --uninstall # 当 core.hooksPath 由 Keel 设置时回退
|
|
|
170
181
|
|
|
171
182
|
`--with-git-hooks` 是显式 opt-in:普通 `keel --install` 绝不碰 git config,且这个覆盖仅限本仓、可逆。
|
|
172
183
|
|
|
184
|
+
## 会话之间的群聊
|
|
185
|
+
|
|
186
|
+
在同一个仓库里干活的各个会话——Claude Code、Codex、无人值守的执行器,还有你——用 `keel chat` 组成一个工作群:
|
|
187
|
+
- 群成员可以增删维护;
|
|
188
|
+
- 消息可以 @ 某个角色,也可以 @all;
|
|
189
|
+
- 可以挂轻量待办,并关联 issue;
|
|
190
|
+
- 每个成员有各自的未读状态,历史全部保留。
|
|
191
|
+
|
|
192
|
+
只有被 @、分到待办或收到私聊时才会唤醒 Claude 会话,其余消息等下一次对话时再提示。消息只是另一个 agent 发来的数据,不代表授权。
|
|
193
|
+
|
|
194
|
+
不能自己被唤醒的宿主(如 Codex)应依靠下一次对话时的提醒,不要让模型定期检查群聊。确实需要定时检查时,先用 `keel chat notice --check` 把关,每次运行都开新线程;让会话加入群聊时,也要明确告诉它不要设置定时或循环检查(#194)。
|
|
195
|
+
|
|
196
|
+
每台电脑配一个 Slack App、跑一个桥接程序,同一批群就能实时连到其他电脑上的会话和你的手机。聊天记录同时存在孤儿分支 `keel-chat` 上,不受 Slack 保留期限制。配置方法见 [Slack 配置说明](docs/chat-slack-setup.zh-CN.md)。5.83 的 `keel mail` 命令继续可用,消息存在私聊群里。
|
|
197
|
+
|
|
173
198
|
## 命令参考
|
|
174
199
|
|
|
175
200
|
```bash
|
|
@@ -190,6 +215,15 @@ keel guard clear --json
|
|
|
190
215
|
keel project tasks --target claude [--change <c>] [--json]
|
|
191
216
|
keel project --target codex --event compaction --json
|
|
192
217
|
|
|
218
|
+
# 会话之间的群聊(接 Slack 见 docs/chat-slack-setup.zh-CN.md)
|
|
219
|
+
keel chat role --set <角色> [--alias <简写>]
|
|
220
|
+
keel chat group create <群> [--member <角色>]... | add | remove | archive | list
|
|
221
|
+
keel chat <群> [<消息>] [--since 2h] [--follow] # 查看,或发言
|
|
222
|
+
keel chat dm <角色> <消息> | todo <群> --assignee <角色> <内容> | todos [--mine]
|
|
223
|
+
keel chat unread | read | notice | search <文本>
|
|
224
|
+
keel chat bridge add | install | status | pause <2h> | stop | start | uninstall
|
|
225
|
+
keel chat archive sync | pull
|
|
226
|
+
|
|
193
227
|
# 安装 / 维护
|
|
194
228
|
keel --init | --install | --check | --doctor | --uninstall [--target <t>] [--dry-run]
|
|
195
229
|
keel --update [--dry-run]
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
<!-- keel:start version=5.
|
|
1
|
+
<!-- keel:start version=5.86.0 -->
|
|
2
2
|
## Keel Bootstrap
|
|
3
3
|
|
|
4
4
|
- Start every session with `keel context`; OpenSpec artifacts and Git are the only durable authority — never native memory, goals, or transcripts.
|
|
5
5
|
- Obey the selected task capsule: `keel gate task-start` before implementing, `--record` its fingerprint to Evidence `Contract`, which `task-complete` requires, before checking complete. Touch bounds product writes; the change's own dir is exempt. On Claude a passing `task-start` guards it by default (`--no-guard` opts out).
|
|
6
|
-
- One
|
|
6
|
+
- One agent owns decisions; model-chosen helpers return read-only report/evidence, delegates need task Touch and a matching active guard. No commit, sync, or archive without explicit authorization.
|
|
7
7
|
- 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.
|
|
8
8
|
- Native plugin projections (SessionStart context) are disposable views, never authority; without the plugin or hook, run the commands manually.
|
|
9
9
|
- 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.
|
|
@@ -124,8 +124,8 @@ artifacts:
|
|
|
124
124
|
|
|
125
125
|
Execution recommendation and Rationale are advisory notes for the current
|
|
126
126
|
Keel agent. Keel-managed work executes in the current agent conversation;
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
retain task decisions in the current agent; bounded helpers and guarded
|
|
128
|
+
implementation delegates are model choices, subject to host policy.
|
|
129
129
|
Autonomy boundary defaults to hard-stop for every action the repository
|
|
130
130
|
has not standing-authorized in `keel/config.yaml`; a declared action is
|
|
131
131
|
inherited only by a task that authored no boundary of its own, and the
|
|
@@ -193,7 +193,7 @@ apply:
|
|
|
193
193
|
5. If a selected task lacks an execution contract, source expectations, or accepted hidden-knowledge assumptions raised by risk-triggered deep alignment or a domain lens, update OpenSpec first instead of dispatching implementation.
|
|
194
194
|
6. Rough future slices may remain non-executable drafts, but they cannot be selected for implementation or marked complete.
|
|
195
195
|
7. The current Keel agent remains task owner and executor. Treat any Execution recommendation as an advisory implementation note, not as a completion gate.
|
|
196
|
-
8.
|
|
196
|
+
8. Keep task decisions in the current agent; model-chosen helpers are read-only and implementation delegates require task write authority and a matching active guard. Host policy remains authoritative. Keep task selection, implementation, verification, and failure recovery in the current agent conversation.
|
|
197
197
|
9. Use the current checkout and selected task contract. Verification failure or context pressure preserves the checkout; continue from evidence, record a blocker, or explicitly roll back to last-green only when authorized.
|
|
198
198
|
10. When `Coupling: required`, verify design.md contains a Coupled Iteration Contract and that the task defines a complete candidate, completion gate, and evidence. If not, update OpenSpec instead of execution.
|
|
199
199
|
11. The current agent may read any repository file needed for the selected task, but repository-wide read authority is read-only and does not expand write authority.
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
defaults: Owner is the current Keel agent, Mode is implementation, Read
|
|
4
4
|
is the change proposal/design/specs/tasks plus discovered repository
|
|
5
5
|
context, Acceptance derives from Covers, Coupling defaults to none,
|
|
6
|
-
helpers stay read-only/evidence-only
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
helpers stay read-only/evidence-only; model-chosen implementation delegates
|
|
7
|
+
need task write authority and a matching active guard. `Delegation: <tier>`
|
|
8
|
+
optionally overrides capability metadata from `keel/config.yaml`. Autonomy defaults to hard-stop, and
|
|
9
9
|
commit, push, sync, archive, and cross-task continuation stay unauthorized,
|
|
10
10
|
EXCEPT where `keel/config.yaml` standing-authorizes an action: a task that
|
|
11
11
|
authors no `Autonomy boundary:` inherits that declaration, and the capsule
|
package/bin/keel.js
CHANGED
|
@@ -96,12 +96,13 @@ const HELP = `keel ${PACKAGE_JSON.version}
|
|
|
96
96
|
Usage:
|
|
97
97
|
keel context [repo] [--change name] [--task id] [--json] [--clear-handoff]
|
|
98
98
|
keel capabilities [repo] [--target claude|codex|opencode] [--json]
|
|
99
|
-
keel project [repo] --target claude|codex|opencode --event startup|resume|compaction|goal|task-view|worktree|subagent-start|subagent-stop [--authorize goal|task-view|subagent] [--expected-owner owner] [--native-complete] [--change name] [--task id] [--json]
|
|
99
|
+
keel project [repo] --target claude|codex|opencode --event startup|resume|compaction|goal|task-view|worktree|subagent-start|subagent-stop [--authorize goal|task-view|subagent] [--subagent-mode helper|implementation] [--expected-owner owner] [--native-complete] [--change name] [--task id] [--json]
|
|
100
100
|
keel project tasks [repo] --target claude [--change name] [--json]
|
|
101
101
|
keel gate task-start|task-complete [repo] [--change name] [--task id] [--base git-ref] [--no-guard] [--record] [--keep-evidence M1,M3] [--json]
|
|
102
102
|
keel gate change-close [repo] [--change name] --action sync|archive [--base git-ref] [--json]
|
|
103
103
|
keel guard start|status|clear [repo] [--change name] [--task id] [--force] [--json]
|
|
104
104
|
keel lenses list|add [name] [repo] [--force]
|
|
105
|
+
keel chat role|group|post|dm|unread|read|show|<group> ... [--repo path] (group chat between sessions; see keel chat help)
|
|
105
106
|
keel mail role|send|list|read|hook [repo] ... (cross-host mailbox; see keel mail help)
|
|
106
107
|
keel triage [repo] [--labels <l1,l2>] [--issue <n>] [--json]
|
|
107
108
|
keel openspec [args...]
|
|
@@ -201,6 +202,7 @@ function parseArgs(argv) {
|
|
|
201
202
|
openspecArgs: [],
|
|
202
203
|
force: false,
|
|
203
204
|
projectionEvent: null,
|
|
205
|
+
subagentMode: null,
|
|
204
206
|
authorizations: [],
|
|
205
207
|
expectedOwner: null,
|
|
206
208
|
nativeComplete: false,
|
|
@@ -341,7 +343,7 @@ function parseArgs(argv) {
|
|
|
341
343
|
parsed[key] = argv[index];
|
|
342
344
|
continue;
|
|
343
345
|
}
|
|
344
|
-
if (arg === "--event" || arg === "--authorize" || arg === "--expected-owner") {
|
|
346
|
+
if (arg === "--event" || arg === "--authorize" || arg === "--expected-owner" || arg === "--subagent-mode") {
|
|
345
347
|
index += 1;
|
|
346
348
|
if (index >= argv.length) {
|
|
347
349
|
fail(`${arg} requires a value`);
|
|
@@ -351,7 +353,8 @@ function parseArgs(argv) {
|
|
|
351
353
|
parsed.authorizations.push(argv[index]);
|
|
352
354
|
}
|
|
353
355
|
} else {
|
|
354
|
-
const key = arg === "--event" ? "projectionEvent"
|
|
356
|
+
const key = arg === "--event" ? "projectionEvent"
|
|
357
|
+
: arg === "--subagent-mode" ? "subagentMode" : "expectedOwner";
|
|
355
358
|
if (parsed[key] !== null) fail(`${arg} was provided more than once`);
|
|
356
359
|
parsed[key] = argv[index];
|
|
357
360
|
}
|
|
@@ -539,6 +542,13 @@ function parseArgs(argv) {
|
|
|
539
542
|
if (parsed.action !== "context" && parsed.clearHandoff) {
|
|
540
543
|
fail("--clear-handoff applies only to keel context");
|
|
541
544
|
}
|
|
545
|
+
if (parsed.subagentMode !== null && (
|
|
546
|
+
parsed.action !== "project" || parsed.projectSubcommand !== null
|
|
547
|
+
|| !["subagent-start", "subagent-stop"].includes(parsed.projectionEvent)
|
|
548
|
+
|| !["helper", "implementation"].includes(parsed.subagentMode)
|
|
549
|
+
)) {
|
|
550
|
+
fail("--subagent-mode helper|implementation applies only to subagent lifecycle projection");
|
|
551
|
+
}
|
|
542
552
|
if (
|
|
543
553
|
parsed.action === "capabilities"
|
|
544
554
|
&& (
|
|
@@ -1467,7 +1477,7 @@ function keelOpenSpecOverlay(action) {
|
|
|
1467
1477
|
"- Run the Slice Start Gate: selected current slices must name source expectations and include Read, Touch, Acceptance, Commands, and Stop/Autonomy boundaries before implementation.",
|
|
1468
1478
|
"- Rough future slices may remain drafts, but cannot be selected for implementation or marked complete.",
|
|
1469
1479
|
"- Obey the selected task contract: Read is required starting context, Touch is the write boundary, Commands prove Acceptance, and the Autonomy boundary controls fallback decisions.",
|
|
1470
|
-
"- A target-native helper returns report/evidence only, and a
|
|
1480
|
+
"- A target-native helper returns report/evidence only, and a model-chosen guarded delegate may write inside `Touch`; both cannot mark tasks complete, update OpenSpec state, commit, sync, archive, or change Acceptance.",
|
|
1471
1481
|
"- The current agent reviews all subagent output, command evidence, and diffs before marking any task complete.",
|
|
1472
1482
|
"- When implementation exposes a material expectation, acceptance boundary, or user-owned decision absent from durable authority, stop before implementing that choice, rerun `keel-align-expectations`, and reauthor the affected proposal/design/spec/task authority first.",
|
|
1473
1483
|
"- A discovered repository fact that does not change accepted behavior or scope may be recorded and execution continues inside the existing task boundary without a product interview.",
|
|
@@ -1499,11 +1509,11 @@ function keelOpenSpecOverlay(action) {
|
|
|
1499
1509
|
"### Target-native subagent gate",
|
|
1500
1510
|
"",
|
|
1501
1511
|
"- The current agent remains responsible for Keel ownership, task/archive decisions, scope control, and final reporting.",
|
|
1502
|
-
"- Use a target-native subagent when the current agent decides it is useful for a bounded helper step, or as a delegate implementing the selected task
|
|
1512
|
+
"- Use a target-native subagent when the current agent decides it is useful for a bounded helper step, or as a delegate implementing the selected task using existing task write authority when a guard manifest is active and matches the task, fingerprint and Touch; optional `delegation:` tiers are metadata.",
|
|
1503
1513
|
"- Target-native subagents acting as helpers return report/evidence only. A delegate may write, and only inside `Touch`; its reported command results are a claim, and the current agent re-runs each `M<n>` check itself before recording Evidence.",
|
|
1504
1514
|
"- Delegation is refused with no active guard manifest, because an absent manifest passes every write through silently and looks identical to a checked one.",
|
|
1505
1515
|
"- Neither may mark tasks complete, update OpenSpec state, commit, sync, archive, or change Acceptance; the current agent reviews all output before acting.",
|
|
1506
|
-
"- The subagent brief must name the selected change/task, required read context, allowed write boundary or read-only diagnostic scope, expected commands/evidence, and prohibited actions. Compile it with `keel project --event subagent-start
|
|
1516
|
+
"- The subagent brief must name the selected change/task, required read context, allowed write boundary or read-only diagnostic scope, expected commands/evidence, and prohibited actions. Compile it with `keel project --event subagent-start` for a read-only helper or add `--subagent-mode implementation` for a guarded delegate; no extra user activation is required. Host policy remains authoritative; Keel adds no separate carrier because the host already has one.",
|
|
1507
1517
|
"- Prohibited actions include scope expansion, Acceptance changes, completion marking, sync/archive decisions, commits, handoff changes, and cross-runtime delegation unless the selected task or user explicitly authorizes them.",
|
|
1508
1518
|
...actionBody,
|
|
1509
1519
|
OPENSPEC_SURFACE_OVERLAY_END,
|
|
@@ -1647,6 +1657,36 @@ function overlayRemediation(target) {
|
|
|
1647
1657
|
return `run keel --init --target ${target} or keel --install --target ${target}`;
|
|
1648
1658
|
}
|
|
1649
1659
|
|
|
1660
|
+
// Only repository-owned surfaces enroll a target. Global Codex prompts can
|
|
1661
|
+
// belong to a different project and must not cause this one to be rewritten.
|
|
1662
|
+
function installedOpenSpecTargets(repo) {
|
|
1663
|
+
return ["claude", "codex", "opencode"].filter((target) => {
|
|
1664
|
+
const roots = target === "codex"
|
|
1665
|
+
? [".agents/skills", ".codex/skills"]
|
|
1666
|
+
: [openspecSkillRootForTarget(target, repo)];
|
|
1667
|
+
return roots.some((root) => OPENSPEC_SKILLS.some((skill) =>
|
|
1668
|
+
fs.existsSync(path.join(repo, root, skill, "SKILL.md"))
|
|
1669
|
+
)) || (target !== "codex" && commandSurfaceForTarget(target, repo).paths
|
|
1670
|
+
.some((file) => fs.existsSync(file)));
|
|
1671
|
+
});
|
|
1672
|
+
}
|
|
1673
|
+
|
|
1674
|
+
function printAdditionalOverlayHealth(repo, selectedTarget) {
|
|
1675
|
+
for (const target of installedOpenSpecTargets(repo)) {
|
|
1676
|
+
if (target === selectedTarget) continue;
|
|
1677
|
+
const counts = countOpenSpecOverlays(
|
|
1678
|
+
openspecOverlaySurfacesForTarget(target, repo).map((surface) => surface.path)
|
|
1679
|
+
);
|
|
1680
|
+
const name = { claude: "Claude", codex: "Codex", opencode: "OpenCode" }[target];
|
|
1681
|
+
printDoctorLine(
|
|
1682
|
+
`${name} Keel ${overlayActionLabel()} overlay`,
|
|
1683
|
+
surfaceStatus(counts),
|
|
1684
|
+
`${formatCount(counts, "skills and commands")}`
|
|
1685
|
+
+ (surfaceStatus(counts) === "ok" ? "" : `; ${overlayRemediation(target)}`)
|
|
1686
|
+
);
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1689
|
+
|
|
1650
1690
|
function printTargetSurface(repo, target) {
|
|
1651
1691
|
process.stdout.write("\nTarget surface:\n");
|
|
1652
1692
|
|
|
@@ -1923,6 +1963,7 @@ function runDoctor(options) {
|
|
|
1923
1963
|
}
|
|
1924
1964
|
|
|
1925
1965
|
printTargetSurface(repo, options.target);
|
|
1966
|
+
printAdditionalOverlayHealth(repo, options.target);
|
|
1926
1967
|
printLensSurface(repo, options.target);
|
|
1927
1968
|
const authorizationOk = printStandingAuthorizationSurface(repo);
|
|
1928
1969
|
printPrecedentSurface(repo);
|
|
@@ -2319,7 +2360,15 @@ function runAction(options) {
|
|
|
2319
2360
|
);
|
|
2320
2361
|
return 1;
|
|
2321
2362
|
}
|
|
2322
|
-
|
|
2363
|
+
const status = runCommand(openspec, options.openspecArgs, { stdio: "inherit" });
|
|
2364
|
+
if (status !== 0 || options.openspecArgs[0] !== "update") return status;
|
|
2365
|
+
const repo = process.cwd();
|
|
2366
|
+
for (const target of installedOpenSpecTargets(repo)) {
|
|
2367
|
+
process.stdout.write(`keel: restoring ${target} OpenSpec overlays after update\n`);
|
|
2368
|
+
const result = refreshOpenSpecSurfaceOverlay(repo, target);
|
|
2369
|
+
if (result.status !== 0) return result.status;
|
|
2370
|
+
}
|
|
2371
|
+
return status;
|
|
2323
2372
|
}
|
|
2324
2373
|
|
|
2325
2374
|
if (options.action === "context") {
|
|
@@ -2596,6 +2645,10 @@ function main() {
|
|
|
2596
2645
|
if (process.argv[2] === "mail") {
|
|
2597
2646
|
return require("../src/core/mail").runMail(process.argv.slice(3));
|
|
2598
2647
|
}
|
|
2648
|
+
// `keel chat` likewise: the group chat between sessions (#187).
|
|
2649
|
+
if (process.argv[2] === "chat") {
|
|
2650
|
+
return require("../src/core/chat/cli").runChat(process.argv.slice(3));
|
|
2651
|
+
}
|
|
2599
2652
|
const options = parseArgs(process.argv.slice(2));
|
|
2600
2653
|
if (options.help || (!options.action && !options.version)) {
|
|
2601
2654
|
printHelp();
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@christang/keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.86.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@christang/keel",
|
|
9
|
-
"version": "5.
|
|
9
|
+
"version": "5.86.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@fission-ai/openspec": "^1.4.1"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.86.0",
|
|
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.
|
|
3
|
+
"version": "5.86.0",
|
|
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",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"discipline"
|
|
16
16
|
],
|
|
17
17
|
"skills": "./skills/",
|
|
18
|
+
"hooks": "./hooks/codex.json",
|
|
18
19
|
"agents": "./agents/",
|
|
19
20
|
"interface": {
|
|
20
21
|
"displayName": "Keel",
|
|
@@ -12,6 +12,6 @@ Thin Claude adapter for the `keel-run-single-task-goal` skill. It activates one
|
|
|
12
12
|
- Activation: compile the view with `keel project goal --target claude --change C --task T --json`; the goal condition stays within the 4,000-character budget, and Keel refuses activation rather than omit Acceptance, fingerprint, or stop authority.
|
|
13
13
|
- Evidence: Claude's evaluator is transcript-only, so surface every command result and gate outcome before any success claim; only `keel gate task-complete` plus the current agent's durable checkbox complete the task.
|
|
14
14
|
- Helpers: Claude subagents used as helpers are bounded read-only evidence producers via `keel project helper`; they carry no write, delegation, acceptance, or completion authority, and their returns are accepted only after repository byte identity.
|
|
15
|
-
- Delegates:
|
|
15
|
+
- Delegates: the model may choose implementation inside task `Touch` with a matching active guard; optional `delegation:` tiers are metadata, not extra permission. The current agent keeps sole write authority, re-runs each `M<n>` check itself before recording Evidence, and owns Review, gates, the checkbox, and completion. Host policy remains authoritative.
|
|
16
16
|
- Stop: terminate after one task on completion, drift, blocker, or premature native success; continuing requires a new explicit authorization and start fingerprint.
|
|
17
17
|
- Fallback: with disabled hooks, managed policy, or missing trust, report and run the identical manual Keel loop.
|
|
@@ -10,7 +10,7 @@ role: single-task-goal-activation
|
|
|
10
10
|
Thin Codex adapter for the `keel-run-single-task-goal` skill. It activates one bounded goal for exactly one authorized OpenSpec task and never introduces a scheduler, global stop hook, agent team, or cross-task authority.
|
|
11
11
|
|
|
12
12
|
- Activation: compile the view with `keel project goal --target codex --change C --task T --json`, then follow the single-task goal lifecycle. Where no callable goal surface exists, surface the exact command and treat the capability as advisory.
|
|
13
|
-
- Ownership: the current agent stays the sole holder of write authority and owns Review, gates, the checkbox, and completion; a native evaluator success never completes the task. A
|
|
13
|
+
- Ownership: the current agent stays the sole holder of write authority and owns Review, gates, the checkbox, and completion; a native evaluator success never completes the task. A model-chosen delegate writes only inside task `Touch` with a matching active guard, and the current agent re-runs each `M<n>` check before recording Evidence. Optional tiers are metadata; host policy remains authoritative.
|
|
14
14
|
- Helpers: Codex subagents are used only as bounded read-only evidence producers via `keel project helper`; they carry no write, delegation, acceptance, or completion authority, and their returns are accepted only after repository byte identity.
|
|
15
15
|
- Stop: terminate after one task on completion, drift, blocker, or premature native success; continuing requires a new explicit authorization and start fingerprint.
|
|
16
16
|
- Fallback: without a callable Codex surface, run the identical manual Keel loop.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"description": "Codex lifecycle hooks. Review their current definitions in /hooks before use; mailbox notices never consume messages or grant authority.",
|
|
3
|
+
"hooks": {
|
|
4
|
+
"SessionStart": [
|
|
5
|
+
{
|
|
6
|
+
"hooks": [
|
|
7
|
+
{
|
|
8
|
+
"type": "command",
|
|
9
|
+
"command": "node \"${PLUGIN_ROOT}/scripts/session-start.js\"",
|
|
10
|
+
"timeout": 15
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"type": "command",
|
|
14
|
+
"command": "node \"${PLUGIN_ROOT}/scripts/codex-mail-hook.js\" session-start",
|
|
15
|
+
"timeout": 10
|
|
16
|
+
}
|
|
17
|
+
]
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
"PreToolUse": [
|
|
21
|
+
{
|
|
22
|
+
"matcher": "Edit|Write|NotebookEdit",
|
|
23
|
+
"hooks": [
|
|
24
|
+
{
|
|
25
|
+
"type": "command",
|
|
26
|
+
"command": "node \"${PLUGIN_ROOT}/scripts/pretooluse-guard.js\"",
|
|
27
|
+
"timeout": 10
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"UserPromptSubmit": [
|
|
33
|
+
{
|
|
34
|
+
"hooks": [
|
|
35
|
+
{
|
|
36
|
+
"type": "command",
|
|
37
|
+
"command": "node \"${PLUGIN_ROOT}/scripts/codex-mail-hook.js\" user-prompt-submit",
|
|
38
|
+
"timeout": 10
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
// Codex's receiving adapter (#183). Use the existing compatibility notice
|
|
5
|
+
// provider, then emit only Codex's documented additionalContext contract.
|
|
6
|
+
// Neither read nor Claude's watchPaths/exit-2 wake signal belongs here.
|
|
7
|
+
const fs = require("fs");
|
|
8
|
+
const path = require("path");
|
|
9
|
+
const { spawnSync } = require("child_process");
|
|
10
|
+
|
|
11
|
+
const EVENTS = {
|
|
12
|
+
"session-start": "SessionStart",
|
|
13
|
+
"user-prompt-submit": "UserPromptSubmit",
|
|
14
|
+
};
|
|
15
|
+
const configuredTimeout = Number(process.env.KEEL_HOOK_TIMEOUT_MS);
|
|
16
|
+
const timeout = Number.isFinite(configuredTimeout) && configuredTimeout > 0
|
|
17
|
+
? Math.min(configuredTimeout, 8000) : 8000;
|
|
18
|
+
|
|
19
|
+
function keelCommand() {
|
|
20
|
+
const explicit = (process.env.KEEL_CLI || "").trim();
|
|
21
|
+
if (explicit) return explicit;
|
|
22
|
+
const root = path.resolve(__dirname, "../../..");
|
|
23
|
+
try {
|
|
24
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(root, "package.json"), "utf8"));
|
|
25
|
+
const cli = path.join(root, "bin/keel.js");
|
|
26
|
+
if (pkg.name === "@christang/keel" && fs.existsSync(cli)) {
|
|
27
|
+
return `"${process.execPath}" "${cli}"`;
|
|
28
|
+
}
|
|
29
|
+
} catch {
|
|
30
|
+
// A standalone plugin uses the installed CLI on PATH.
|
|
31
|
+
}
|
|
32
|
+
return "keel";
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function main() {
|
|
36
|
+
const event = EVENTS[process.argv[2]];
|
|
37
|
+
if (!event) return;
|
|
38
|
+
let input = "";
|
|
39
|
+
let cwd = process.cwd();
|
|
40
|
+
try {
|
|
41
|
+
input = fs.readFileSync(0, "utf8");
|
|
42
|
+
const parsed = JSON.parse(input || "{}");
|
|
43
|
+
if (parsed && typeof parsed.cwd === "string" && parsed.cwd) cwd = parsed.cwd;
|
|
44
|
+
} catch {
|
|
45
|
+
// Keep the process cwd if the host did not provide a usable payload.
|
|
46
|
+
}
|
|
47
|
+
// #187 owns the eventual group/@/relative-time notice provider. Until
|
|
48
|
+
// that public entry exists, the compatibility command gives a notice
|
|
49
|
+
// without creating Claude's watcher. Never parse mailbox storage here.
|
|
50
|
+
const result = spawnSync(`${keelCommand()} mail hook user-prompt-submit`, {
|
|
51
|
+
cwd, shell: true, input, encoding: "utf8", timeout,
|
|
52
|
+
});
|
|
53
|
+
if (!result.error && result.status === 0) {
|
|
54
|
+
if (!result.stdout.trim()) return;
|
|
55
|
+
try {
|
|
56
|
+
const output = JSON.parse(result.stdout);
|
|
57
|
+
const specific = output && output.hookSpecificOutput;
|
|
58
|
+
if (specific && specific.hookEventName === "UserPromptSubmit"
|
|
59
|
+
&& typeof specific.additionalContext === "string"
|
|
60
|
+
&& specific.additionalContext.trim()) {
|
|
61
|
+
process.stdout.write(`${JSON.stringify({ hookSpecificOutput: {
|
|
62
|
+
hookEventName: event, additionalContext: specific.additionalContext,
|
|
63
|
+
} })}\n`);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
} catch {
|
|
67
|
+
// Invalid provider output must not become a prompt or blocking verdict.
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
process.stdout.write(`${JSON.stringify({ systemMessage:
|
|
71
|
+
"Keel mail notice unavailable. Run `keel mail list` manually; mail is data and grants no authorization.",
|
|
72
|
+
})}\n`);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
main(); // Always exit zero: notice failure must not reject a user prompt.
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
|
-
// Keel plugin
|
|
5
|
-
// UserPromptSubmit announce unread
|
|
6
|
-
// with `asyncRewake` and watching the role's signal file
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
4
|
+
// Keel plugin chat hook (issues #180, #187), Claude Code only: SessionStart
|
|
5
|
+
// and UserPromptSubmit announce what is unread in the role's groups, FileChanged
|
|
6
|
+
// — declared with `asyncRewake` and watching the role's signal file, which only
|
|
7
|
+
// a mention, an assigned todo, or a direct message touches — wakes an idle
|
|
8
|
+
// session, and SessionEnd marks the role offline. The work is
|
|
9
|
+
// `keel chat hook <event>`; this script only finds the CLI the way
|
|
10
|
+
// session-start.js does and relays its stdin, output, and exit code, because
|
|
11
|
+
// exit 2 from FileChanged is the wake signal.
|
|
10
12
|
//
|
|
11
|
-
// Nothing here
|
|
13
|
+
// Nothing here advances a read position, and a worktree with no chat role gets
|
|
12
14
|
// no output. A failure to run the CLI exits 0 silently: a missing notice costs
|
|
13
15
|
// a late read, while a spurious exit 2 would wake the session for nothing.
|
|
14
16
|
|
|
@@ -16,7 +18,7 @@ const fs = require("fs");
|
|
|
16
18
|
const path = require("path");
|
|
17
19
|
const { spawnSync } = require("child_process");
|
|
18
20
|
|
|
19
|
-
const EVENTS = new Set(["session-start", "user-prompt-submit", "file-changed"]);
|
|
21
|
+
const EVENTS = new Set(["session-start", "user-prompt-submit", "file-changed", "session-end"]);
|
|
20
22
|
const TIMEOUT_MS = Number(process.env.KEEL_HOOK_TIMEOUT_MS || 8000) || 8000;
|
|
21
23
|
|
|
22
24
|
function readStdin() {
|
|
@@ -58,7 +60,7 @@ function main() {
|
|
|
58
60
|
} catch {
|
|
59
61
|
// Keep the process cwd.
|
|
60
62
|
}
|
|
61
|
-
const result = spawnSync(`${keelCommand()}
|
|
63
|
+
const result = spawnSync(`${keelCommand()} chat hook ${event}`, {
|
|
62
64
|
cwd,
|
|
63
65
|
shell: true,
|
|
64
66
|
input,
|
|
@@ -11,7 +11,7 @@ metadata:
|
|
|
11
11
|
|
|
12
12
|
## Purpose
|
|
13
13
|
|
|
14
|
-
Activate a native goal
|
|
14
|
+
Activate a native goal runtime to execute exactly one authorized OpenSpec task end to end, while OpenSpec, Git, the task-capsule fingerprint, and deterministic Keel gates stay the only durable authority. The current agent remains the sole holder of write authority and owns Review, gate invocation, the task checkbox, and completion. A model-chosen implementation delegate with a matching active guard may write inside the `Touch` boundary that authority already defined and acquires none of those decisions; the current agent re-runs each `M<n>` check itself before recording Evidence, because a delegate's reported result is a claim and the byte-identity check that validates a read-only helper cannot apply to a writer. A native evaluator declaring success never marks or reports the task complete.
|
|
15
15
|
|
|
16
16
|
## Guidance
|
|
17
17
|
|
|
@@ -34,7 +34,7 @@ Activate only on an explicit, unambiguous request to automatically execute or re
|
|
|
34
34
|
- Proposal, design, or spec authoring before tasks are final.
|
|
35
35
|
- Ambiguous selection, multiple tasks, or a whole task group or change backlog.
|
|
36
36
|
- An unrelated native `/goal` use that is not a Keel OpenSpec task.
|
|
37
|
-
-
|
|
37
|
+
- Ordinary helper use, which does not activate a native goal. Model-chosen implementation delegates still require task write authority and a matching active guard.
|
|
38
38
|
- OpenCode, which stays manual compatibility only with no v4 native activation.
|
|
39
39
|
|
|
40
40
|
If any of these hold, stop and use the normal manual Keel loop.
|