@christang/keel 5.90.2 → 5.92.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 CHANGED
@@ -646,6 +646,44 @@ This changes only what Keel *recommends*. No gate, the write guard, and completi
646
646
  exactly as they would without it, and `keel context --change <paused>` still selects it — you asked
647
647
  for it by name. Keel never pauses a change on its own.
648
648
 
649
+ ## External model CLIs
650
+
651
+ A session can hand work to an external model CLI — codex, DeepSeek Harness's `dsh`, or one you
652
+ register — as a delegate. Whether to call one is the model's choice; Keel's part is the interface,
653
+ the gates, and the pitfalls others already hit. A host's own subagents are not involved: the model
654
+ knows those better.
655
+
656
+ ```bash
657
+ keel agents # the catalog: where each executable resolves, and whether this project allows it
658
+ keel agents codex # its template, sandboxes, where it sends data, dated pitfalls
659
+ keel agents brief codex --mode helper --dir . --out /tmp/brief.md --change <c> --task <t>
660
+ ```
661
+
662
+ `keel agents brief` compiles the same brief `keel project --event subagent-start` publishes, writes
663
+ it to a file, and prints the command to run. **Keel launches nothing**; the session runs it, and
664
+ re-runs every check before anything counts as evidence. It refuses:
665
+
666
+ - an agent the project has not allowed — with no declaration, none is;
667
+ - a Read or Touch path the project said must not leave;
668
+ - a write-capable run in the session's own checkout. The host's write guard never sees an external
669
+ process, so implementation (and a helper whose CLI has no read-only sandbox, like `dsh`) needs a
670
+ separate `git worktree add`.
671
+
672
+ ```yaml
673
+ external_agents:
674
+ allow:
675
+ - codex
676
+ egress_deny:
677
+ - secrets/**: vendor keys under NDA
678
+ ```
679
+
680
+ The catalog records facts only — template, sandboxes, destination, and pitfalls each with a date and
681
+ a source — and never what an agent is good at, because a judgement sitting in the session steers it
682
+ and goes stale with the next model. Which work suits an external agent is yours to write. Tool paths
683
+ are machine facts: `~/.keel/agents.json` adds an agent or overrides a field, such as
684
+ `{"agents": {"dsh": {"executable": "/path/to/dsh"}}}`. Keel cannot see what an agent reads beyond
685
+ the brief, so `egress_deny` guards what is handed over, not what it can open.
686
+
649
687
  ## Group chat between sessions
650
688
 
651
689
  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. 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: see [the Slack setup guide](docs/chat-slack-setup.md). The 5.83 `keel mail` commands keep working on direct groups.
@@ -684,6 +722,10 @@ keel chat archive sync | pull
684
722
  # Keel never fetches the issue; pass what gh returned. At least one of the two.
685
723
  keel triage [--labels <l1,l2>] [--issue <n>] [--json]
686
724
 
725
+ # External model CLIs — catalog, and the brief Keel compiles (it launches nothing)
726
+ keel agents [name] [--json]
727
+ keel agents brief <name> --mode helper|implementation --dir <path> --out <file>
728
+
687
729
  # Install / maintenance
688
730
  keel --init | --install | --check | --doctor | --uninstall [--target <t>] [--dry-run]
689
731
  keel --update [--dry-run]
package/README.zh-CN.md CHANGED
@@ -185,6 +185,40 @@ keel --uninstall # 当 core.hooksPath 由 Keel 设置时回退
185
185
 
186
186
  `--with-git-hooks` 是显式 opt-in:普通 `keel --install` 绝不碰 git config,且这个覆盖仅限本仓、可逆。
187
187
 
188
+ ## 外部模型 CLI
189
+
190
+ 会话可以把活交给外部模型 CLI 当委派对象,比如 codex、DeepSeek Harness 的 `dsh`,或你自己注册的。
191
+ 调不调由模型自己判断;Keel 只提供调用接口、门控,以及大家踩过的坑。宿主自带的 subagent 不归 Keel 管,
192
+ 模型自己更懂。
193
+
194
+ ```bash
195
+ keel agents # 事实目录:可执行文件在哪、本项目是否允许
196
+ keel agents codex # 命令模板、沙箱、数据发往哪里、带日期的坑
197
+ keel agents brief codex --mode helper --dir . --out /tmp/brief.md --change <c> --task <t>
198
+ ```
199
+
200
+ `keel agents brief` 编译的就是 `keel project --event subagent-start` 给出的那份任务说明,写成文件,
201
+ 再打印要跑的命令。**Keel 不启动任何进程**:命令由会话自己跑,对方交回的结果要由会话复跑每个检查后才算证据。
202
+ 以下情况会被拒绝:
203
+
204
+ - 项目没允许的 agent(没写声明就一个都不允许);
205
+ - 任务要读或要改的路径命中了禁止外发的清单;
206
+ - 在会话自己的 checkout 里做会写入的调用。宿主的写入守卫看不到外部进程,所以实现类任务,以及没有只读
207
+ 沙箱的 CLI(如 `dsh`)即使只做评审,都要用 `git worktree add` 建的独立 worktree。
208
+
209
+ ```yaml
210
+ external_agents:
211
+ allow:
212
+ - codex
213
+ egress_deny:
214
+ - secrets/**: 受 NDA 约束的厂商密钥
215
+ ```
216
+
217
+ 事实目录只记事实:命令模板、沙箱、数据去向,以及每条都带日期和出处的坑;不写「擅长什么」,因为这种评价
218
+ 常驻在会话里会左右主 agent 的判断,换个模型版本就过时。哪些活适合交出去由你自己写。工具路径属于本机事实:
219
+ `~/.keel/agents.json` 可以新增 agent 或覆盖某个字段,比如 `{"agents": {"dsh": {"executable": "/path/to/dsh"}}}`。
220
+ Keel 看不到对方在任务说明之外还读了什么,所以 `egress_deny` 防的是主动交出去的内容,管不住对方自己能打开的文件。
221
+
188
222
  ## 会话之间的群聊
189
223
 
190
224
  在同一个仓库里干活的各个会话——Claude Code、Codex、无人值守的执行器,还有你——用 `keel chat` 组成一个工作群:
@@ -228,6 +262,10 @@ keel chat unread | read | notice | search <文本>
228
262
  keel chat bridge add | install | status | pause <2h> | stop | start | uninstall
229
263
  keel chat archive sync | pull
230
264
 
265
+ # 外部模型 CLI —— 事实目录,以及 Keel 编译的任务说明(Keel 不启动进程)
266
+ keel agents [name] [--json]
267
+ keel agents brief <name> --mode helper|implementation --dir <path> --out <file>
268
+
231
269
  # 安装 / 维护
232
270
  keel --init | --install | --check | --doctor | --uninstall [--target <t>] [--dry-run]
233
271
  keel --update [--dry-run]
@@ -1,4 +1,4 @@
1
- <!-- keel:start version=5.90.2 -->
1
+ <!-- keel:start version=5.92.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.
package/bin/keel.js CHANGED
@@ -105,6 +105,7 @@ Usage:
105
105
  keel chat role|group|post|dm|unread|read|show|<group> ... [--repo path] (group chat between sessions; see keel chat help)
106
106
  keel mail role|send|list|read|hook [repo] ... (cross-host mailbox; see keel mail help)
107
107
  keel triage [repo] [--labels <l1,l2>] [--issue <n>] [--json]
108
+ keel agents [name] [--repo path] [--json] (external model CLIs, read on demand; Keel launches none)
108
109
  keel openspec [args...]
109
110
  keel --init [repo] [--target claude|codex|opencode] [--dry-run] [--force-template-update]
110
111
  keel --install [repo] [--target claude|codex|opencode] [--dry-run] [--force-template-update] [--with-git-hooks]
@@ -2848,6 +2849,10 @@ function main() {
2848
2849
  if (process.argv[2] === "chat") {
2849
2850
  return require("../src/core/chat/cli").runChat(process.argv.slice(3));
2850
2851
  }
2852
+ // `keel agents` likewise: the external model CLI catalog (#219).
2853
+ if (process.argv[2] === "agents") {
2854
+ return require("../src/core/agents").runAgents(process.argv.slice(3));
2855
+ }
2851
2856
  const options = parseArgs(process.argv.slice(2));
2852
2857
  if (options.help || (!options.action && !options.version)) {
2853
2858
  printHelp();
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@christang/keel",
3
- "version": "5.90.2",
3
+ "version": "5.92.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@christang/keel",
9
- "version": "5.90.2",
9
+ "version": "5.92.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@fission-ai/openspec": "^1.4.1"
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.90.2",
5
+ "version": "5.92.0",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keel",
3
- "version": "5.90.2",
3
+ "version": "5.92.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.90.2",
3
+ "version": "5.92.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",
@@ -102,13 +102,16 @@ TASKS_LEGACY_HEADING_PATTERNS = (
102
102
  "remove legacy ## Current Completion; derive progress from checklist [x]/[ ] state",
103
103
  ),
104
104
  )
105
+ TASKS_DIRTY_STATE_PATTERN = re.compile(
106
+ r"(?i)\b(?:dirty|uncommitted|not\s+committed|pending\s+commit)\b"
107
+ )
105
108
  TASKS_COMMIT_STATUS_PATTERNS = (
106
109
  (
107
110
  re.compile(r"(?i)\bcommit[-\s]?hash\b"),
108
111
  "remove commit hash wording from tasks.md; git log is the source of truth",
109
112
  ),
110
113
  (
111
- re.compile(r"(?i)\b(?:dirty|uncommitted|not\s+committed|pending\s+commit)\b"),
114
+ TASKS_DIRTY_STATE_PATTERN,
112
115
  "remove dirty/uncommitted state from tasks.md; keep durable work state in OpenSpec and use HANDOFF only as an explicit pointer override",
113
116
  ),
114
117
  (
@@ -171,6 +174,29 @@ TASKS_CONTEXTUAL_HASH_RE = re.compile(
171
174
  rf"(?i){_HASH_CONTEXT_WORD}.*{_HASH_SHAPED_TOKEN}|"
172
175
  rf"{_HASH_SHAPED_TOKEN}.*{_HASH_CONTEXT_WORD}"
173
176
  )
177
+ # Inside a task field the two rules above read a claim, not a line (#213). A
178
+ # field cites its provenance — the base a Scope check compared against, which
179
+ # keel-review-checklist asks it to name, the commit a result ran on, the inputs
180
+ # a hash identifies — and a context word elsewhere on that line does not make
181
+ # the token a record. So a field refuses a token only where a state claim binds
182
+ # it: a context word naming it directly, or the token followed by the act.
183
+ TASKS_FIELD_BOUND_HASH_RE = re.compile(
184
+ r"(?i)\b(?:commits?|committed|committing|master|main|HEAD|hash(?:es)?)\b"
185
+ r"[\s:=@(\uff08-]*(?:(?:is|was|now)\s+)?(?:(?:at|as|to|into|onto|in|on)\s+)?"
186
+ rf"{_HASH_SHAPED_TOKEN}"
187
+ rf"|{_HASH_SHAPED_TOKEN}\s*(?:(?:is|was)\s+)?\b(?:committed|merged|pushed)\b"
188
+ rf"|(?:提交|合入|哈希)\S{{0,4}}?\s*{_HASH_SHAPED_TOKEN}"
189
+ )
190
+ # Likewise `dirty` names the design under test as often as this worktree — a
191
+ # cache buffer's dirty groups — and a negation says the opposite of what the
192
+ # bare word matched. Inside a field the word is refused only as a claim about
193
+ # the work: predicative after a copula, or the value of a Status/State label.
194
+ TASKS_FIELD_DIRTY_STATE_RE = re.compile(
195
+ r"(?i)\b(?:is|are|was|were|remains?|remained|stays?|stayed|left)\s+"
196
+ r"(?:(?:still|now|yet)\s+)?(?:dirty|uncommitted)\b"
197
+ r"|\b(?:status|state)\s*[:\uff1a=]\s*(?:dirty|uncommitted)\b"
198
+ r"|\bnot\s+(?:yet\s+)?committed\b|\bpending\s+commit\b"
199
+ )
174
200
 
175
201
 
176
202
  @dataclass(frozen=True)
@@ -735,6 +761,25 @@ def covers_field_lines(content: str) -> set[int]:
735
761
  return lines
736
762
 
737
763
 
764
+ def task_field_lines(content: str) -> set[int]:
765
+ """1-based line numbers inside any task field.
766
+
767
+ A field starts at a two-space `- Name:` label, the compiler's bound, and
768
+ runs until a non-blank line indented less than two spaces — the next task
769
+ title, a heading, or a notes section, which keep the line-wide rules.
770
+ """
771
+ inside = False
772
+ lines: set[int] = set()
773
+ for number, line in enumerate(content.splitlines(), start=1):
774
+ if TASKS_FIELD_LABEL_RE.match(line):
775
+ inside = True
776
+ elif line.strip() and not line.startswith(" "):
777
+ inside = False
778
+ if inside:
779
+ lines.add(number)
780
+ return lines
781
+
782
+
738
783
  # What an author quotes is content they cite, not a claim they make. Evidence
739
784
  # prose quotes the command that ran, the output it printed, the branch base it
740
785
  # ran against, and the name of the requirement under change — and every one of
@@ -787,6 +832,7 @@ def check_tasks_semantics(repo: Path) -> list[str]:
787
832
  errors.append(f"{relative}:{line}: {message}")
788
833
 
789
834
  cited = covers_field_lines(content)
835
+ fields = task_field_lines(content)
790
836
  fenced = False
791
837
  for line_number, line in enumerate(content.splitlines(), start=1):
792
838
  # A fenced block is one long quoted span, and its own delimiter
@@ -799,7 +845,10 @@ def check_tasks_semantics(repo: Path) -> list[str]:
799
845
  if fenced or is_tasks_rule_line(line) or line_number in cited:
800
846
  continue
801
847
  line = without_quoted_spans(line)
848
+ in_field = line_number in fields
802
849
  for pattern, message in TASKS_COMMIT_STATUS_PATTERNS:
850
+ if in_field and pattern is TASKS_DIRTY_STATE_PATTERN:
851
+ pattern = TASKS_FIELD_DIRTY_STATE_RE
803
852
  if pattern.search(line):
804
853
  errors.append(f"{relative}:{line_number}: {message}")
805
854
  if TASKS_SUBMISSION_STATE_RE.search(line) and TASKS_GIT_CONTEXT_RE.search(
@@ -808,7 +857,8 @@ def check_tasks_semantics(repo: Path) -> list[str]:
808
857
  errors.append(
809
858
  f"{relative}:{line_number}: {TASKS_SUBMISSION_MESSAGE}"
810
859
  )
811
- if TASKS_CONTEXTUAL_HASH_RE.search(line):
860
+ hash_rule = TASKS_FIELD_BOUND_HASH_RE if in_field else TASKS_CONTEXTUAL_HASH_RE
861
+ if hash_rule.search(line):
812
862
  errors.append(
813
863
  f"{relative}:{line_number}: remove contextual commit hash from tasks.md; git log is the source of truth"
814
864
  )