@christang/keel 5.91.0 → 5.92.1
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 +43 -0
- package/README.zh-CN.md +38 -0
- package/assets/bootstrap/AGENTS.md +1 -1
- package/bin/keel.js +5 -0
- 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 +1 -1
- package/scripts/validate_plugin.py +452 -2
- package/src/core/agents.js +606 -0
- package/src/core/config.js +78 -0
package/README.md
CHANGED
|
@@ -646,6 +646,45 @@ 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, which writes the agent's exit status to a `.exit` file
|
|
664
|
+
beside its result. **Keel launches nothing**; the session runs it, and re-runs every check before
|
|
665
|
+
anything counts as evidence. It refuses:
|
|
666
|
+
|
|
667
|
+
- an agent the project has not allowed — with no declaration, none is;
|
|
668
|
+
- a Read or Touch path the project said must not leave;
|
|
669
|
+
- a write-capable run in the session's own checkout. The host's write guard never sees an external
|
|
670
|
+
process, so implementation (and a helper whose CLI has no read-only sandbox, like `dsh`) needs a
|
|
671
|
+
separate `git worktree add`.
|
|
672
|
+
|
|
673
|
+
```yaml
|
|
674
|
+
external_agents:
|
|
675
|
+
allow:
|
|
676
|
+
- codex
|
|
677
|
+
egress_deny:
|
|
678
|
+
- secrets/**: vendor keys under NDA
|
|
679
|
+
```
|
|
680
|
+
|
|
681
|
+
The catalog records facts only — template, sandboxes, destination, and pitfalls each with a date and
|
|
682
|
+
a source — and never what an agent is good at, because a judgement sitting in the session steers it
|
|
683
|
+
and goes stale with the next model. Which work suits an external agent is yours to write. Tool paths
|
|
684
|
+
are machine facts: `~/.keel/agents.json` adds an agent or overrides a field, such as
|
|
685
|
+
`{"agents": {"dsh": {"executable": "/path/to/dsh"}}}`. Keel cannot see what an agent reads beyond
|
|
686
|
+
the brief, so `egress_deny` guards what is handed over, not what it can open.
|
|
687
|
+
|
|
649
688
|
## Group chat between sessions
|
|
650
689
|
|
|
651
690
|
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 +723,10 @@ keel chat archive sync | pull
|
|
|
684
723
|
# Keel never fetches the issue; pass what gh returned. At least one of the two.
|
|
685
724
|
keel triage [--labels <l1,l2>] [--issue <n>] [--json]
|
|
686
725
|
|
|
726
|
+
# External model CLIs — catalog, and the brief Keel compiles (it launches nothing)
|
|
727
|
+
keel agents [name] [--json]
|
|
728
|
+
keel agents brief <name> --mode helper|implementation --dir <path> --out <file>
|
|
729
|
+
|
|
687
730
|
# Install / maintenance
|
|
688
731
|
keel --init | --install | --check | --doctor | --uninstall [--target <t>] [--dry-run]
|
|
689
732
|
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
|
+
再打印要跑的命令;这条命令会把 agent 的退出码写进结果旁边的 `.exit` 文件。**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]
|
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();
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@christang/keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.92.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@christang/keel",
|
|
9
|
-
"version": "5.
|
|
9
|
+
"version": "5.92.1",
|
|
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.92.1",
|
|
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.92.1",
|
|
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",
|
|
@@ -47,8 +47,8 @@ REQUIRED_SCRIPTS = [
|
|
|
47
47
|
"scripts/validate_plugin.py",
|
|
48
48
|
]
|
|
49
49
|
|
|
50
|
-
PACKAGE_VERSION = "5.
|
|
51
|
-
PROTOCOL_VERSION = "5.
|
|
50
|
+
PACKAGE_VERSION = "5.92.1"
|
|
51
|
+
PROTOCOL_VERSION = "5.92.1"
|
|
52
52
|
LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
|
|
53
53
|
OPENSPEC_SCHEMA_NAME = "keel-spec-driven"
|
|
54
54
|
# Mirrors KEEL_PACKAGE_NAME in scripts/install_to_repo.py, one of the two
|
|
@@ -35250,6 +35250,452 @@ def validate_codex_receiving_scenario() -> int:
|
|
|
35250
35250
|
return result.returncode
|
|
35251
35251
|
|
|
35252
35252
|
|
|
35253
|
+
EXTERNAL_AGENT_FACT_FIELDS = {
|
|
35254
|
+
"name", "source", "executable", "resolved", "allowed",
|
|
35255
|
+
"command", "sandbox", "sendsTo", "pitfalls",
|
|
35256
|
+
}
|
|
35257
|
+
|
|
35258
|
+
|
|
35259
|
+
def _external_agents_env(base: Path) -> tuple[dict[str, str], Path]:
|
|
35260
|
+
"""An environment whose Keel home and PATH belong to the fixture.
|
|
35261
|
+
|
|
35262
|
+
The stub `codex` stands in for the real one so resolution is checked against
|
|
35263
|
+
a path the scenario controls; it records any invocation, because a catalog
|
|
35264
|
+
or a brief that launched the agent would be the one thing Keel promised not
|
|
35265
|
+
to do.
|
|
35266
|
+
"""
|
|
35267
|
+
home = base / "home"
|
|
35268
|
+
home.mkdir()
|
|
35269
|
+
stub_bin = base / "bin"
|
|
35270
|
+
stub_bin.mkdir()
|
|
35271
|
+
calls = base / "calls.log"
|
|
35272
|
+
for name in ("codex", "dsh"):
|
|
35273
|
+
stub = stub_bin / name
|
|
35274
|
+
stub.write_text(f"#!/bin/sh\necho {name} \"$@\" >> '{calls}'\n", encoding="utf-8")
|
|
35275
|
+
stub.chmod(0o755)
|
|
35276
|
+
env = dict(os.environ)
|
|
35277
|
+
env["KEEL_HOME"] = str(home)
|
|
35278
|
+
env["PATH"] = f"{stub_bin}{os.pathsep}{env.get('PATH', '')}"
|
|
35279
|
+
return env, calls
|
|
35280
|
+
|
|
35281
|
+
|
|
35282
|
+
def validate_external_agent_catalog_scenario() -> int:
|
|
35283
|
+
"""The catalog records facts, merges the machine file, and stays on demand.
|
|
35284
|
+
|
|
35285
|
+
#219: an external model CLI writes outside the host's write guard and sends
|
|
35286
|
+
the repository to another provider. What Keel offers about one is facts a
|
|
35287
|
+
reader can check — template, sandboxes, destination, dated pitfalls — and
|
|
35288
|
+
never a judgement of what it is good at, because a judgement resident in the
|
|
35289
|
+
session steers the agent that reads it (owner, 2026-10-04).
|
|
35290
|
+
"""
|
|
35291
|
+
label = "external-agent-catalog:"
|
|
35292
|
+
with tempfile.TemporaryDirectory(prefix="keel-agents-") as raw:
|
|
35293
|
+
base = Path(raw)
|
|
35294
|
+
env, calls = _external_agents_env(base)
|
|
35295
|
+
repo = base / "repo"
|
|
35296
|
+
repo.mkdir()
|
|
35297
|
+
write_gate_fixture(repo, standing_authorization_task())
|
|
35298
|
+
write_authorize_config(repo, "external_agents:\n allow:\n - codex\n")
|
|
35299
|
+
|
|
35300
|
+
def listing() -> dict | None:
|
|
35301
|
+
result = run_keel(repo, "agents", "--json", env=env)
|
|
35302
|
+
try:
|
|
35303
|
+
return json.loads(result.stdout)
|
|
35304
|
+
except json.JSONDecodeError:
|
|
35305
|
+
report(f"{label} `keel agents --json` printed no JSON: "
|
|
35306
|
+
f"{(result.stdout + result.stderr).strip()[:400]}")
|
|
35307
|
+
return None
|
|
35308
|
+
|
|
35309
|
+
payload = listing()
|
|
35310
|
+
if payload is None:
|
|
35311
|
+
return 1
|
|
35312
|
+
agents = {item.get("name"): item for item in payload.get("agents") or []}
|
|
35313
|
+
for name in ("codex", "dsh"):
|
|
35314
|
+
if agents.get(name, {}).get("source") != "bundled":
|
|
35315
|
+
report(f"{label} {name} is not listed as a bundled entry: {agents.get(name)}")
|
|
35316
|
+
return 1
|
|
35317
|
+
stub = str(base / "bin" / "codex")
|
|
35318
|
+
if agents["codex"].get("resolved") != stub:
|
|
35319
|
+
report(f"{label} codex resolved to {agents['codex'].get('resolved')!r}, not the stub on PATH.")
|
|
35320
|
+
return 1
|
|
35321
|
+
dsh_path = agents["dsh"].get("executable")
|
|
35322
|
+
expected = dsh_path if dsh_path and Path(dsh_path).exists() else None
|
|
35323
|
+
if agents["dsh"].get("resolved") != expected:
|
|
35324
|
+
report(f"{label} dsh resolution {agents['dsh'].get('resolved')!r} disagrees with "
|
|
35325
|
+
f"whether {dsh_path!r} exists.")
|
|
35326
|
+
return 1
|
|
35327
|
+
if agents["codex"].get("allowed") is not True or agents["dsh"].get("allowed") is not False:
|
|
35328
|
+
report(f"{label} allowance is not read from external_agents: allow: "
|
|
35329
|
+
f"codex={agents['codex'].get('allowed')!r} dsh={agents['dsh'].get('allowed')!r}")
|
|
35330
|
+
return 1
|
|
35331
|
+
for name, item in agents.items():
|
|
35332
|
+
extra = set(item) - EXTERNAL_AGENT_FACT_FIELDS
|
|
35333
|
+
if extra:
|
|
35334
|
+
report(f"{label} {name} carries fields outside the fact fields: {sorted(extra)}. "
|
|
35335
|
+
"The catalog records facts, not a judgement of what an agent suits.")
|
|
35336
|
+
return 1
|
|
35337
|
+
pitfalls = item.get("pitfalls") or []
|
|
35338
|
+
if not pitfalls:
|
|
35339
|
+
report(f"{label} {name} records no pitfall.")
|
|
35340
|
+
return 1
|
|
35341
|
+
for pitfall in pitfalls:
|
|
35342
|
+
if not re.fullmatch(r"\d{4}-\d{2}-\d{2}", str(pitfall.get("date", ""))) \
|
|
35343
|
+
or not str(pitfall.get("source", "")).strip():
|
|
35344
|
+
report(f"{label} {name} has a pitfall without a date and a source: {pitfall}")
|
|
35345
|
+
return 1
|
|
35346
|
+
|
|
35347
|
+
shown = run_keel(repo, "agents", "codex", env=env)
|
|
35348
|
+
text = shown.stdout
|
|
35349
|
+
codex = agents["codex"]
|
|
35350
|
+
for needle in (codex.get("command"), "read-only", "workspace-write", codex.get("sendsTo"),
|
|
35351
|
+
*[p["text"] for p in codex["pitfalls"]],
|
|
35352
|
+
*[p["date"] for p in codex["pitfalls"]]):
|
|
35353
|
+
if not needle:
|
|
35354
|
+
report(f"{label} the codex entry has an empty command, destination, or pitfall.")
|
|
35355
|
+
return 1
|
|
35356
|
+
if needle not in text:
|
|
35357
|
+
report(f"{label} `keel agents codex` does not print {needle!r}.")
|
|
35358
|
+
return 1
|
|
35359
|
+
|
|
35360
|
+
# A machine entry declaring one field overrides that field only.
|
|
35361
|
+
custom = base / "bin" / "dsh"
|
|
35362
|
+
(base / "home" / "agents.json").write_text(
|
|
35363
|
+
json.dumps({"agents": {"dsh": {"executable": str(custom)}}}), encoding="utf-8")
|
|
35364
|
+
payload = listing()
|
|
35365
|
+
if payload is None:
|
|
35366
|
+
return 1
|
|
35367
|
+
dsh = {item.get("name"): item for item in payload.get("agents") or []}.get("dsh") or {}
|
|
35368
|
+
if dsh.get("source") != "machine" or dsh.get("executable") != str(custom):
|
|
35369
|
+
report(f"{label} the machine entry did not override dsh: {dsh}")
|
|
35370
|
+
return 1
|
|
35371
|
+
if dsh.get("command") != agents["dsh"].get("command"):
|
|
35372
|
+
report(f"{label} a machine entry declaring only an executable replaced the bundled template.")
|
|
35373
|
+
return 1
|
|
35374
|
+
|
|
35375
|
+
# A malformed machine file is named and none of it is used.
|
|
35376
|
+
(base / "home" / "agents.json").write_text("{not json", encoding="utf-8")
|
|
35377
|
+
payload = listing()
|
|
35378
|
+
if payload is None:
|
|
35379
|
+
return 1
|
|
35380
|
+
problems = " ".join(payload.get("problems") or [])
|
|
35381
|
+
if "agents.json" not in problems:
|
|
35382
|
+
report(f"{label} a malformed agents.json was not reported: {payload.get('problems')}")
|
|
35383
|
+
return 1
|
|
35384
|
+
sources = {item.get("source") for item in payload.get("agents") or []}
|
|
35385
|
+
if sources != {"bundled"}:
|
|
35386
|
+
report(f"{label} a malformed agents.json still contributed entries: {sources}")
|
|
35387
|
+
return 1
|
|
35388
|
+
|
|
35389
|
+
# Session start carries no catalog.
|
|
35390
|
+
context = run_keel(repo, "context", env=env)
|
|
35391
|
+
for needle in ("dsh", "DeepSeek", "/dev/null", "workspace-write"):
|
|
35392
|
+
if needle in context.stdout:
|
|
35393
|
+
report(f"{label} `keel context` carries catalog text {needle!r}.")
|
|
35394
|
+
return 1
|
|
35395
|
+
if calls.exists():
|
|
35396
|
+
report(f"{label} an agent was launched: {calls.read_text(encoding='utf-8').strip()}")
|
|
35397
|
+
return 1
|
|
35398
|
+
|
|
35399
|
+
report("external-agent-catalog scenario passed.")
|
|
35400
|
+
return 0
|
|
35401
|
+
|
|
35402
|
+
|
|
35403
|
+
def external_agent_brief_task() -> str:
|
|
35404
|
+
return (
|
|
35405
|
+
"- [ ] 1.1 Speed up the parser\n"
|
|
35406
|
+
" - Covers:\n"
|
|
35407
|
+
" - E1: public behavior\n"
|
|
35408
|
+
" - Read:\n"
|
|
35409
|
+
" - docs/spec.md\n"
|
|
35410
|
+
" - secrets/vendor.key\n"
|
|
35411
|
+
" - Touch:\n"
|
|
35412
|
+
" - src/feature.js\n"
|
|
35413
|
+
" - Verify:\n"
|
|
35414
|
+
" - Strategy: evidence-first\n"
|
|
35415
|
+
" - Reason: this is a gate fixture; it exercises contract structure and has no executable behavior that can fail first\n"
|
|
35416
|
+
" - M1: node test.js proves the parser is faster\n"
|
|
35417
|
+
" - Evidence:\n"
|
|
35418
|
+
" - Contract: pending\n"
|
|
35419
|
+
" - M1: pending\n"
|
|
35420
|
+
" - Review:\n"
|
|
35421
|
+
" - Status: pending\n"
|
|
35422
|
+
" - Acceptance check: pending\n"
|
|
35423
|
+
" - Scope check: pending\n"
|
|
35424
|
+
" - Findings: pending\n"
|
|
35425
|
+
" - Blocker: none\n"
|
|
35426
|
+
)
|
|
35427
|
+
|
|
35428
|
+
|
|
35429
|
+
def validate_external_agent_brief_scenario() -> int:
|
|
35430
|
+
"""The brief is the delegation brief, checked for egress and write boundary.
|
|
35431
|
+
|
|
35432
|
+
#219: Keel compiles what the external agent is handed and prints the command;
|
|
35433
|
+
the session runs it. The brief refuses what the project has not allowed, a
|
|
35434
|
+
path the project said must not leave, and any write into the session's own
|
|
35435
|
+
checkout, because the host's write guard never sees an external process.
|
|
35436
|
+
"""
|
|
35437
|
+
label = "external-agent-brief:"
|
|
35438
|
+
with tempfile.TemporaryDirectory(prefix="keel-agent-brief-") as raw:
|
|
35439
|
+
base = Path(raw)
|
|
35440
|
+
env, calls = _external_agents_env(base)
|
|
35441
|
+
repo = base / "repo"
|
|
35442
|
+
repo.mkdir()
|
|
35443
|
+
write_gate_fixture(repo, external_agent_brief_task())
|
|
35444
|
+
write_text(repo / "docs/spec.md", "spec\n")
|
|
35445
|
+
write_text(repo / "secrets/vendor.key", "key\n")
|
|
35446
|
+
write_text(repo / "src/feature.js", "// feature\n")
|
|
35447
|
+
for command in (["init", "-q"], ["add", "-A"],
|
|
35448
|
+
["-c", "user.email=k@example.com", "-c", "user.name=k",
|
|
35449
|
+
"commit", "-q", "-m", "fixture"]):
|
|
35450
|
+
subprocess.run(["git", *command], cwd=repo, check=True, capture_output=True)
|
|
35451
|
+
prompt = base / "brief.md"
|
|
35452
|
+
|
|
35453
|
+
def brief(name: str, mode: str, directory: Path) -> tuple[dict, str]:
|
|
35454
|
+
if prompt.exists():
|
|
35455
|
+
prompt.unlink()
|
|
35456
|
+
result = run_keel(repo, "agents", "brief", name, "--mode", mode,
|
|
35457
|
+
"--dir", str(directory), "--out", str(prompt),
|
|
35458
|
+
"--change", "demo", "--task", "1.1", "--json", env=env)
|
|
35459
|
+
try:
|
|
35460
|
+
return json.loads(result.stdout), result.stdout + result.stderr
|
|
35461
|
+
except json.JSONDecodeError:
|
|
35462
|
+
return {}, result.stdout + result.stderr
|
|
35463
|
+
|
|
35464
|
+
def refused(payload: dict, output: str, *needles: str, what: str) -> bool:
|
|
35465
|
+
reasons = " ".join(payload.get("reasons") or [])
|
|
35466
|
+
if payload.get("status") != "blocked":
|
|
35467
|
+
report(f"{label} {what} was not refused: {output.strip()[:400]}")
|
|
35468
|
+
return False
|
|
35469
|
+
for needle in needles:
|
|
35470
|
+
if needle not in reasons:
|
|
35471
|
+
report(f"{label} {what} was refused without naming {needle!r}: {reasons}")
|
|
35472
|
+
return False
|
|
35473
|
+
if prompt.exists():
|
|
35474
|
+
report(f"{label} {what} was refused but still wrote a prompt file.")
|
|
35475
|
+
return False
|
|
35476
|
+
return True
|
|
35477
|
+
|
|
35478
|
+
# Absent declaration allows nothing, and says how to declare.
|
|
35479
|
+
payload, out = brief("codex", "helper", repo)
|
|
35480
|
+
if not refused(payload, out, "external_agents:", "allow:", what="an undeclared project"):
|
|
35481
|
+
return 1
|
|
35482
|
+
# An agent outside allow.
|
|
35483
|
+
write_authorize_config(repo, "external_agents:\n allow:\n - codex\n")
|
|
35484
|
+
payload, out = brief("dsh", "helper", repo)
|
|
35485
|
+
if not refused(payload, out, "dsh", "codex", what="an agent outside allow"):
|
|
35486
|
+
return 1
|
|
35487
|
+
# A deny entry without a reason refuses every brief.
|
|
35488
|
+
write_authorize_config(repo, "external_agents:\n allow:\n - codex\n"
|
|
35489
|
+
" egress_deny:\n - secrets/**\n")
|
|
35490
|
+
payload, out = brief("codex", "helper", repo)
|
|
35491
|
+
if not refused(payload, out, "secrets/**", what="a deny entry without a reason"):
|
|
35492
|
+
return 1
|
|
35493
|
+
# A denied Read path refuses, naming path, pattern and reason.
|
|
35494
|
+
write_authorize_config(repo, "external_agents:\n allow: [codex, dsh]\n"
|
|
35495
|
+
" egress_deny:\n - secrets/**: vendor NDA keys\n")
|
|
35496
|
+
payload, out = brief("codex", "helper", repo)
|
|
35497
|
+
if not refused(payload, out, "secrets/vendor.key", "secrets/**", "vendor NDA keys",
|
|
35498
|
+
what="a denied Read path"):
|
|
35499
|
+
return 1
|
|
35500
|
+
# A clean helper brief.
|
|
35501
|
+
write_authorize_config(repo, "external_agents:\n allow: [codex, dsh]\n"
|
|
35502
|
+
" egress_deny:\n - private/**: customer data\n")
|
|
35503
|
+
payload, out = brief("codex", "helper", repo)
|
|
35504
|
+
if payload.get("status") != "ready":
|
|
35505
|
+
report(f"{label} a clean helper brief was refused: {out.strip()[:600]}")
|
|
35506
|
+
return 1
|
|
35507
|
+
if not prompt.exists():
|
|
35508
|
+
report(f"{label} a clean helper brief reported ready but wrote no prompt file.")
|
|
35509
|
+
return 1
|
|
35510
|
+
text = prompt.read_text(encoding="utf-8")
|
|
35511
|
+
for needle in ("Speed up the parser", "docs/spec.md", "secrets/vendor.key",
|
|
35512
|
+
"M1: node test.js", "commit", "push", "OpenSpec"):
|
|
35513
|
+
if needle not in text:
|
|
35514
|
+
report(f"{label} the prompt file does not carry {needle!r}.")
|
|
35515
|
+
return 1
|
|
35516
|
+
command = payload.get("run") or ""
|
|
35517
|
+
for needle in ("read-only", str(repo), str(prompt)):
|
|
35518
|
+
if needle not in command:
|
|
35519
|
+
report(f"{label} the printed command does not name {needle!r}: {command}")
|
|
35520
|
+
return 1
|
|
35521
|
+
if "cannot observe" not in " ".join(payload.get("warnings") or []):
|
|
35522
|
+
report(f"{label} the brief does not say Keel cannot observe what the agent reads.")
|
|
35523
|
+
return 1
|
|
35524
|
+
# A helper with no sandbox over the session's own checkout.
|
|
35525
|
+
payload, out = brief("dsh", "helper", repo)
|
|
35526
|
+
if not refused(payload, out, "sandbox", "worktree", what="a dsh helper over the checkout"):
|
|
35527
|
+
return 1
|
|
35528
|
+
# Implementation with no guard: the projection's own reason.
|
|
35529
|
+
projected = run_keel(repo, "project", "--target", "claude", "--event", "subagent-start",
|
|
35530
|
+
"--subagent-mode", "implementation", "--change", "demo",
|
|
35531
|
+
"--task", "1.1", "--json", env=env)
|
|
35532
|
+
expected = " ".join(json.loads(projected.stdout).get("reasons") or [])
|
|
35533
|
+
payload, out = brief("codex", "implementation", repo)
|
|
35534
|
+
if not expected:
|
|
35535
|
+
report(f"{label} the projection gave no reason to compare against: {projected.stdout[:400]}")
|
|
35536
|
+
return 1
|
|
35537
|
+
if not refused(payload, out, expected, what="an unguarded implementation"):
|
|
35538
|
+
return 1
|
|
35539
|
+
started = run_keel(repo, "gate", "task-start", "--change", "demo", "--task", "1.1",
|
|
35540
|
+
"--record", "--json", env=env)
|
|
35541
|
+
if json.loads(started.stdout).get("status") != "pass":
|
|
35542
|
+
report(f"{label} the fixture task did not start: {started.stdout[:400]}")
|
|
35543
|
+
return 1
|
|
35544
|
+
payload, out = brief("codex", "implementation", repo)
|
|
35545
|
+
if not refused(payload, out, "worktree", what="an implementation over the checkout"):
|
|
35546
|
+
return 1
|
|
35547
|
+
worktree = base / "agent-wt"
|
|
35548
|
+
subprocess.run(["git", "worktree", "add", "-q", "--detach", str(worktree)],
|
|
35549
|
+
cwd=repo, check=True, capture_output=True)
|
|
35550
|
+
payload, out = brief("codex", "implementation", worktree)
|
|
35551
|
+
if payload.get("status") != "ready":
|
|
35552
|
+
report(f"{label} an implementation brief over a separate worktree was refused: "
|
|
35553
|
+
f"{out.strip()[:600]}")
|
|
35554
|
+
return 1
|
|
35555
|
+
if not prompt.exists():
|
|
35556
|
+
report(f"{label} an implementation brief reported ready but wrote no prompt file.")
|
|
35557
|
+
return 1
|
|
35558
|
+
command = payload.get("run") or ""
|
|
35559
|
+
for needle in ("workspace-write", str(worktree)):
|
|
35560
|
+
if needle not in command:
|
|
35561
|
+
report(f"{label} the implementation command does not name {needle!r}: {command}")
|
|
35562
|
+
return 1
|
|
35563
|
+
if calls.exists():
|
|
35564
|
+
report(f"{label} an agent was launched: {calls.read_text(encoding='utf-8').strip()}")
|
|
35565
|
+
return 1
|
|
35566
|
+
|
|
35567
|
+
report("external-agent-brief scenario passed.")
|
|
35568
|
+
return 0
|
|
35569
|
+
|
|
35570
|
+
|
|
35571
|
+
def validate_external_agents_are_documented_scenario() -> int:
|
|
35572
|
+
"""The command reaches the protocol, the READMEs, and the privacy policy.
|
|
35573
|
+
|
|
35574
|
+
#219: an agent that never reads the README must still learn that external
|
|
35575
|
+
model CLIs are delegates with a compiled brief, so the bootstrap block and
|
|
35576
|
+
this repository's protocol name it. The privacy policy lists what leaves the
|
|
35577
|
+
machine, and handing a repository to codex or dsh is now one of those ways.
|
|
35578
|
+
"""
|
|
35579
|
+
label = "external-agents-are-documented:"
|
|
35580
|
+
|
|
35581
|
+
def flat(path: Path) -> str:
|
|
35582
|
+
return re.sub(r"\s+", " ", path.read_text(encoding="utf-8"))
|
|
35583
|
+
|
|
35584
|
+
protocol = flat(ROOT / "AGENTS.md")
|
|
35585
|
+
if "keel agents brief" not in protocol:
|
|
35586
|
+
report(f"{label} AGENTS.md does not name `keel agents brief`.")
|
|
35587
|
+
return 1
|
|
35588
|
+
if "launches nothing" not in protocol:
|
|
35589
|
+
report(f"{label} AGENTS.md does not say Keel launches nothing.")
|
|
35590
|
+
return 1
|
|
35591
|
+
# The installed bootstrap spends its byte budget only on rules every session
|
|
35592
|
+
# uses; `external_agents:` is inert until declared, as delegation is, so it
|
|
35593
|
+
# reaches an agent where it is declared instead (D9).
|
|
35594
|
+
if "keel agents" in flat(ROOT / "assets/bootstrap/AGENTS.md"):
|
|
35595
|
+
report(f"{label} the bootstrap block names `keel agents`, spending its budget on a "
|
|
35596
|
+
"declaration that is inert until a project makes it.")
|
|
35597
|
+
return 1
|
|
35598
|
+
for path in (ROOT / "README.md", ROOT / "README.zh-CN.md"):
|
|
35599
|
+
text = path.read_text(encoding="utf-8")
|
|
35600
|
+
blocks = re.findall(r"```bash\n(.*?)```", text, re.S)
|
|
35601
|
+
if not any("keel agents" in block for block in blocks):
|
|
35602
|
+
report(f"{label} {path.name} lists no `keel agents` in a command block.")
|
|
35603
|
+
return 1
|
|
35604
|
+
yaml_blocks = re.findall(r"```yaml\n(.*?)```", text, re.S)
|
|
35605
|
+
example = next((block for block in yaml_blocks if "external_agents:" in block), "")
|
|
35606
|
+
if not example:
|
|
35607
|
+
report(f"{label} {path.name} shows no `external_agents:` example.")
|
|
35608
|
+
return 1
|
|
35609
|
+
for key in ("allow:", "egress_deny:"):
|
|
35610
|
+
if key not in example:
|
|
35611
|
+
report(f"{label} {path.name}'s external_agents example has no {key}.")
|
|
35612
|
+
return 1
|
|
35613
|
+
privacy = (ROOT / "PRIVACY.md").read_text(encoding="utf-8")
|
|
35614
|
+
leaves = privacy.split("## What leaves your machine", 1)[-1].split("\n## ", 1)[0]
|
|
35615
|
+
if "External model CLIs" not in leaves:
|
|
35616
|
+
report(f"{label} PRIVACY.md does not list external model CLIs under what leaves the machine.")
|
|
35617
|
+
return 1
|
|
35618
|
+
|
|
35619
|
+
report("external-agents-are-documented scenario passed.")
|
|
35620
|
+
return 0
|
|
35621
|
+
|
|
35622
|
+
|
|
35623
|
+
def validate_external_agent_exit_status_scenario() -> int:
|
|
35624
|
+
"""The printed command records the agent's exit status (#221).
|
|
35625
|
+
|
|
35626
|
+
Of nine codex runs read in rtl_ppa_prj, one recorded its exit status; a run
|
|
35627
|
+
that finished with `exit=0` read as a failure because it left no result
|
|
35628
|
+
file. The status is the one signal that is not the agent's own report.
|
|
35629
|
+
"""
|
|
35630
|
+
label = "external-agent-exit-status:"
|
|
35631
|
+
with tempfile.TemporaryDirectory(prefix="keel-agent-exit-") as raw:
|
|
35632
|
+
base = Path(raw).resolve()
|
|
35633
|
+
env, _calls = _external_agents_env(base)
|
|
35634
|
+
for name in ("codex", "dsh"):
|
|
35635
|
+
stub = base / "bin" / name
|
|
35636
|
+
stub.write_text("#!/bin/sh\ncat > /dev/null\nexit 3\n", encoding="utf-8")
|
|
35637
|
+
stub.chmod(0o755)
|
|
35638
|
+
(base / "home" / "agents.json").write_text(
|
|
35639
|
+
json.dumps({"agents": {"dsh": {"executable": str(base / "bin" / "dsh")}}}),
|
|
35640
|
+
encoding="utf-8")
|
|
35641
|
+
repo = base / "repo"
|
|
35642
|
+
repo.mkdir()
|
|
35643
|
+
write_gate_fixture(repo, external_agent_brief_task())
|
|
35644
|
+
write_text(repo / "src/feature.js", "// feature\n")
|
|
35645
|
+
write_authorize_config(repo, "external_agents:\n allow: [codex, dsh]\n")
|
|
35646
|
+
for command in (["init", "-q"], ["add", "-A"],
|
|
35647
|
+
["-c", "user.email=k@example.com", "-c", "user.name=k",
|
|
35648
|
+
"commit", "-q", "-m", "fixture"]):
|
|
35649
|
+
subprocess.run(["git", *command], cwd=repo, check=True, capture_output=True)
|
|
35650
|
+
worktree = base / "agent-wt"
|
|
35651
|
+
subprocess.run(["git", "worktree", "add", "-q", "--detach", str(worktree)],
|
|
35652
|
+
cwd=repo, check=True, capture_output=True)
|
|
35653
|
+
|
|
35654
|
+
for name, directory in (("codex", repo), ("dsh", worktree)):
|
|
35655
|
+
prompt = base / f"{name}-brief.md"
|
|
35656
|
+
result = run_keel(repo, "agents", "brief", name, "--mode", "helper",
|
|
35657
|
+
"--dir", str(directory), "--out", str(prompt),
|
|
35658
|
+
"--change", "demo", "--task", "1.1", "--json", env=env)
|
|
35659
|
+
try:
|
|
35660
|
+
payload = json.loads(result.stdout)
|
|
35661
|
+
except json.JSONDecodeError:
|
|
35662
|
+
report(f"{label} {name} brief printed no JSON: {(result.stdout + result.stderr)[:400]}")
|
|
35663
|
+
return 1
|
|
35664
|
+
if payload.get("status") != "ready":
|
|
35665
|
+
report(f"{label} {name} brief was refused: {payload.get('reasons')}")
|
|
35666
|
+
return 1
|
|
35667
|
+
exit_file = payload.get("exit")
|
|
35668
|
+
if not exit_file:
|
|
35669
|
+
report(f"{label} the {name} brief names no exit file.")
|
|
35670
|
+
return 1
|
|
35671
|
+
text = run_keel(repo, "agents", "brief", name, "--mode", "helper",
|
|
35672
|
+
"--dir", str(directory), "--out", str(prompt),
|
|
35673
|
+
"--change", "demo", "--task", "1.1", env=env).stdout
|
|
35674
|
+
if exit_file not in text:
|
|
35675
|
+
report(f"{label} the {name} text output does not name the exit file {exit_file}.")
|
|
35676
|
+
return 1
|
|
35677
|
+
ran = subprocess.run(["sh", "-c", f"{payload['run']}\npwd"], cwd=base, env=env,
|
|
35678
|
+
capture_output=True, text=True)
|
|
35679
|
+
if not Path(exit_file).exists():
|
|
35680
|
+
report(f"{label} running the {name} command wrote no exit file: {ran.stderr[:300]}")
|
|
35681
|
+
return 1
|
|
35682
|
+
status = Path(exit_file).read_text(encoding="utf-8").strip()
|
|
35683
|
+
if status != "3":
|
|
35684
|
+
report(f"{label} the {name} exit file holds {status!r}, not the stub's 3.")
|
|
35685
|
+
return 1
|
|
35686
|
+
if ran.stdout.strip().splitlines()[-1:] != [str(base)]:
|
|
35687
|
+
report(f"{label} running the {name} command moved the shell to {ran.stdout.strip()!r}.")
|
|
35688
|
+
return 1
|
|
35689
|
+
|
|
35690
|
+
shown = run_keel(repo, "agents", "codex", env=env).stdout
|
|
35691
|
+
if not re.search(r"parallel[^\n]*quota", shown, re.I):
|
|
35692
|
+
report(f"{label} `keel agents codex` has no pitfall about parallel runs sharing one quota.")
|
|
35693
|
+
return 1
|
|
35694
|
+
|
|
35695
|
+
report("external-agent-exit-status scenario passed.")
|
|
35696
|
+
return 0
|
|
35697
|
+
|
|
35698
|
+
|
|
35253
35699
|
SCENARIOS: tuple = (
|
|
35254
35700
|
("stateless-continuity", validate_stateless_continuity_scenario),
|
|
35255
35701
|
("core-gates", validate_core_gates_scenario),
|
|
@@ -35694,6 +36140,10 @@ SCENARIOS: tuple = (
|
|
|
35694
36140
|
"a-task-field-cites-its-provenance",
|
|
35695
36141
|
validate_a_task_field_cites_its_provenance_scenario,
|
|
35696
36142
|
),
|
|
36143
|
+
("external-agent-catalog", validate_external_agent_catalog_scenario),
|
|
36144
|
+
("external-agent-brief", validate_external_agent_brief_scenario),
|
|
36145
|
+
("external-agents-are-documented", validate_external_agents_are_documented_scenario),
|
|
36146
|
+
("external-agent-exit-status", validate_external_agent_exit_status_scenario),
|
|
35697
36147
|
("validation-runner", validate_validation_runner_scenario),
|
|
35698
36148
|
("section-boundary", validate_section_boundary_scenario),
|
|
35699
36149
|
("review-entry-extent", validate_review_entry_extent_scenario),
|