@christang/keel 5.181.0 → 5.183.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/.claude-plugin/plugin.json +1 -1
- package/README.md +7 -6
- package/README.zh-CN.md +6 -6
- package/assets/bootstrap/AGENTS.md +1 -1
- package/assets/openspec/schemas/keel-spec-driven/schema.yaml +3 -3
- package/bin/keel.js +71 -15
- 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/plugins/keel/skills/keel-align-expectations/SKILL.md +1 -1
- package/plugins/keel/skills/keel-debug-failure/SKILL.md +1 -1
- package/plugins/keel/skills/keel-review-checklist/SKILL.md +1 -1
- package/scripts/validate_plugin.py +454 -38
- package/src/core/chat/notice.js +3 -0
- package/src/core/shift.js +76 -13
- package/src/core/tick.js +9 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.183.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",
|
package/README.md
CHANGED
|
@@ -39,7 +39,7 @@ Keel leans on native capabilities rather than reinventing them. The spec workflo
|
|
|
39
39
|
OpenSpec. The execution skills, the SessionStart continuity hook, and the write-guard hook
|
|
40
40
|
ship as an ordinary Claude Code / Codex plugin. Besides running OpenSpec's own init,
|
|
41
41
|
`keel --init` writes a small host surface into your repo: an `AGENTS.md` bootstrap block, the
|
|
42
|
-
OpenSpec schema, the
|
|
42
|
+
OpenSpec schema, the overlay on OpenSpec's workflow skills, and on Claude the plugin's auto-update entry in
|
|
43
43
|
`.claude/settings.json`.
|
|
44
44
|
|
|
45
45
|
## Requirements
|
|
@@ -180,13 +180,14 @@ A subagent is the model's choice and is treated as the main agent is: the gates,
|
|
|
180
180
|
no brief, activation, or second agent's rerun before one acts, and does not nudge the
|
|
181
181
|
model toward or away from using one (#414).
|
|
182
182
|
|
|
183
|
-
Do the spec work through OpenSpec's
|
|
184
|
-
|
|
183
|
+
Do the spec work through OpenSpec's workflow skills (`openspec-propose`, `openspec-apply-change`,
|
|
184
|
+
`openspec-sync-specs`, `openspec-archive-change`); Keel generates them as skills only, with no OpenSpec
|
|
185
|
+
slash commands (#406). Keel's gates run at the task boundaries. The whole loop:
|
|
185
186
|
|
|
186
187
|
```
|
|
187
|
-
keel --init → keel context →
|
|
188
|
+
keel --init → keel context → openspec-apply-change (tasks in order)
|
|
188
189
|
→ task-start (+ write guard) → implement & verify
|
|
189
|
-
→ task-complete →
|
|
190
|
+
→ task-complete → openspec-sync-specs · openspec-archive-change
|
|
190
191
|
```
|
|
191
192
|
|
|
192
193
|
On the Claude target, the session-start hook also shows that state to **you**, not only to the
|
|
@@ -521,7 +522,7 @@ command at the right moment. Three things make that happen.
|
|
|
521
522
|
session with `keel context`, route the work Full or Lite, pass the gates at task boundaries,
|
|
522
523
|
and stay inside the task's declared write scope. That is how the agent knows *when* to run
|
|
523
524
|
what.
|
|
524
|
-
- **The skills.** The `keel-*` execution skills and the
|
|
525
|
+
- **The skills.** The `keel-*` execution skills and the overlays on OpenSpec's workflow skills walk the
|
|
525
526
|
agent through align → apply → review → complete, invoking the gates at each step. A new or
|
|
526
527
|
materially expanded skill is researched from an authoritative source with its provenance and
|
|
527
528
|
license recorded, its description is tested with realistic should-trigger and should-not-trigger
|
package/README.zh-CN.md
CHANGED
|
@@ -31,7 +31,7 @@ Keel 加的东西:
|
|
|
31
31
|
Keel 尽量借力原生能力,而不是重造。spec 工作流就是原生 OpenSpec;执行技能、SessionStart 连续性
|
|
32
32
|
hook 和写入守卫 hook 都以一个普通的 Claude Code / Codex 插件分发。除了运行 OpenSpec 自己的 init,
|
|
33
33
|
`keel --init` 还往你的 repo 里写一小块宿主面:`AGENTS.md` bootstrap 块、OpenSpec schema、
|
|
34
|
-
|
|
34
|
+
OpenSpec 工作流 skill 上的 overlay,以及在 Claude 上写入 `.claude/settings.json` 的插件自动更新条目。
|
|
35
35
|
|
|
36
36
|
## 环境要求
|
|
37
37
|
|
|
@@ -154,13 +154,13 @@ overlay 状态,所以 Claude 一侧正常不会掩盖 Codex overlay 的缺失
|
|
|
154
154
|
和证据规则适用于执行该步骤的任何一方。Keel 在 subagent 动手前不要求 brief、额外激活或另一个
|
|
155
155
|
agent 复跑,也不引导模型去用或不用它(#414)。
|
|
156
156
|
|
|
157
|
-
spec 相关的活走 OpenSpec
|
|
158
|
-
Keel 的门禁在任务边界处运行。整个回路:
|
|
157
|
+
spec 相关的活走 OpenSpec 的工作流 skill(`openspec-propose`、`openspec-apply-change`、`openspec-sync-specs`、
|
|
158
|
+
`openspec-archive-change`);Keel 只生成 skill,不生成 OpenSpec 斜杠命令(#406)。Keel 的门禁在任务边界处运行。整个回路:
|
|
159
159
|
|
|
160
160
|
```
|
|
161
|
-
keel --init → keel context →
|
|
161
|
+
keel --init → keel context → openspec-apply-change(按顺序做 task)
|
|
162
162
|
→ task-start(+ 写入守卫) → 实现并验证
|
|
163
|
-
→ task-complete →
|
|
163
|
+
→ task-complete → openspec-sync-specs · openspec-archive-change
|
|
164
164
|
```
|
|
165
165
|
|
|
166
166
|
在 Claude target 上,session-start hook 还会把这个状态展示给**你**,而不只是给 agent——在你输入任何内容
|
|
@@ -422,7 +422,7 @@ executor_tier: high
|
|
|
422
422
|
- **协议**:`keel --init` 会往你 repo 的 `AGENTS.md` 写一段 bootstrap 块(在 Claude 上由
|
|
423
423
|
`CLAUDE.md` 引入)。它写明 agent 要遵守的规则:每次会话先跑 `keel context`、把工作路由到 Full 或 Lite、
|
|
424
424
|
在任务边界处过门禁、只在任务声明的写入范围内改文件。这就是 agent 知道**何时**运行什么的来源。
|
|
425
|
-
- **技能**:`keel-*` 执行技能和
|
|
425
|
+
- **技能**:`keel-*` 执行技能和 OpenSpec 工作流 skill 上的 overlay 带着 agent 走「对齐 → apply → review →
|
|
426
426
|
完成」,每一步调用门禁。新增或实质扩展的技能,要从 authoritative source 研究并记录出处与许可证,
|
|
427
427
|
用真实的 should-trigger 与 should-not-trigger 用例检验其 description,并至少通过一个 real task。
|
|
428
428
|
`src/skills/<name>/SKILL.md` 是唯一可移植权威,target metadata 只是附加,发现与激活由 target-native 运行时负责。
|
|
@@ -137,7 +137,7 @@ artifacts:
|
|
|
137
137
|
final assertions, immediate task-stop conditions, and
|
|
138
138
|
evidence. The task must agree with design.md's Coupled Iteration Contract.
|
|
139
139
|
|
|
140
|
-
|
|
140
|
+
`openspec-apply-change` works through the unchecked tasks of this file in order. Any
|
|
141
141
|
repository file may be read needed for the selected task; Read lists required
|
|
142
142
|
starting context, not a read allowlist. The Slice Start Gate requires each
|
|
143
143
|
selected current slice or contiguous slice group to name source
|
|
@@ -183,7 +183,7 @@ apply:
|
|
|
183
183
|
- tasks
|
|
184
184
|
tracks: tasks.md
|
|
185
185
|
instruction: |
|
|
186
|
-
Use
|
|
186
|
+
Use the `openspec-apply-change` skill as the implementation entry for Keel-managed work.
|
|
187
187
|
|
|
188
188
|
Apply workflow:
|
|
189
189
|
1. Read the current change's proposal.md, specs, design.md when present, and tasks.md.
|
|
@@ -200,5 +200,5 @@ apply:
|
|
|
200
200
|
12. Modify only files listed under Touch. If modifying any other file is required, stop and report an Out-of-scope Need with file or area, why needed, consequence if unchanged, minimal proposed change, and evidence.
|
|
201
201
|
13. Do not commit or push unless the selected task, a human instruction, or a standing authorization in `keel/config.yaml` allows it.
|
|
202
202
|
14. After each iteration, compare Changed Files and command evidence with the selected task contract before checking tasks complete.
|
|
203
|
-
15. Run `keel-review-checklist` only at completion gates: after a complete task group, before
|
|
203
|
+
15. Run `keel-review-checklist` only at completion gates: after a complete task group, before `openspec-sync-specs` or `openspec-archive-change` for `openspec/changes/<change>/tasks.md`, before meaningful handoff, or when implementation reports risks, follow-ups, or out-of-scope need. No hook gates completion; running the gates is the agent's own step.
|
|
204
204
|
16. Before archive or handoff, unresolved follow-ups must be owned by current OpenSpec tasks, a new OpenSpec change, archive evidence, or an explicit discard reason.
|
package/bin/keel.js
CHANGED
|
@@ -66,7 +66,7 @@ const OPENSPEC_SKILLS = [
|
|
|
66
66
|
// `sync` is here because `AGENTS.md` gates it exactly as it gates archive —
|
|
67
67
|
// `keel gate change-close --action sync|archive` plus `keel-review-checklist`.
|
|
68
68
|
// Archive's surface said so and sync's said nothing, so an agent invoking
|
|
69
|
-
//
|
|
69
|
+
// the sync workflow read generic upstream instructions with no mention of the gate
|
|
70
70
|
// that decides whether the sync may complete. `explore` is deliberately absent:
|
|
71
71
|
// it reads and reports, reaches no gate, and changes no state, so an overlay
|
|
72
72
|
// there would read as governance where there is none.
|
|
@@ -666,6 +666,7 @@ function runCommand(command, args, options = {}) {
|
|
|
666
666
|
|
|
667
667
|
const result = spawnSync(command, args, {
|
|
668
668
|
cwd: options.cwd || process.cwd(),
|
|
669
|
+
env: options.env || process.env,
|
|
669
670
|
stdio: options.stdio || "inherit",
|
|
670
671
|
encoding: options.encoding || "utf8",
|
|
671
672
|
shell: process.platform === "win32",
|
|
@@ -1532,6 +1533,46 @@ function openspecToolsForTarget(target) {
|
|
|
1532
1533
|
return target;
|
|
1533
1534
|
}
|
|
1534
1535
|
|
|
1536
|
+
// Where OpenSpec reads its one global configuration (OpenSpec 1.14
|
|
1537
|
+
// `getGlobalConfigDir`): XDG_CONFIG_HOME on every platform when set, else
|
|
1538
|
+
// %APPDATA% on Windows and ~/.config elsewhere.
|
|
1539
|
+
function openspecGlobalConfigFile() {
|
|
1540
|
+
const base = process.env.XDG_CONFIG_HOME
|
|
1541
|
+
|| (process.platform === "win32"
|
|
1542
|
+
? process.env.APPDATA || path.join(os.homedir(), "AppData", "Roaming")
|
|
1543
|
+
: path.join(os.homedir(), ".config"));
|
|
1544
|
+
return path.join(base, "openspec", "config.json");
|
|
1545
|
+
}
|
|
1546
|
+
|
|
1547
|
+
// OpenSpec reads `delivery` only from that global file, and its default,
|
|
1548
|
+
// `both`, put every workflow on Claude twice: a skill and an `/opsx:` command
|
|
1549
|
+
// (#406). The OpenSpec runs that generate surfaces get the user's own
|
|
1550
|
+
// configuration with `delivery` replaced by `skills`, through a temporary
|
|
1551
|
+
// XDG_CONFIG_HOME; the user's file is read and never written. Every other
|
|
1552
|
+
// field, the workflow selection among them, still applies.
|
|
1553
|
+
function withSkillsDelivery(run) {
|
|
1554
|
+
let config = {};
|
|
1555
|
+
try {
|
|
1556
|
+
const parsed = JSON.parse(fs.readFileSync(openspecGlobalConfigFile(), "utf8"));
|
|
1557
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) config = parsed;
|
|
1558
|
+
} catch {
|
|
1559
|
+
// Absent or unreadable reads as OpenSpec's defaults, as OpenSpec does.
|
|
1560
|
+
}
|
|
1561
|
+
const home = fs.mkdtempSync(path.join(os.tmpdir(), "keel-openspec-config-"));
|
|
1562
|
+
try {
|
|
1563
|
+
fs.mkdirSync(path.join(home, "openspec"));
|
|
1564
|
+
fs.writeFileSync(
|
|
1565
|
+
path.join(home, "openspec", "config.json"),
|
|
1566
|
+
`${JSON.stringify({ ...config, delivery: "skills" }, null, 2)}\n`
|
|
1567
|
+
);
|
|
1568
|
+
return run({ ...process.env, XDG_CONFIG_HOME: home });
|
|
1569
|
+
} finally {
|
|
1570
|
+
fs.rmSync(home, { recursive: true, force: true });
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
const OPENSPEC_GENERATING_COMMANDS = new Set(["init", "update"]);
|
|
1575
|
+
|
|
1535
1576
|
function runOpenSpec(args, repo, options) {
|
|
1536
1577
|
const command = options.dryRun ? "openspec" : findOpenSpecCommand();
|
|
1537
1578
|
if (!command) {
|
|
@@ -1540,10 +1581,8 @@ function runOpenSpec(args, repo, options) {
|
|
|
1540
1581
|
);
|
|
1541
1582
|
return 1;
|
|
1542
1583
|
}
|
|
1543
|
-
return runCommand(command, args, {
|
|
1544
|
-
|
|
1545
|
-
dryRun: options.dryRun,
|
|
1546
|
-
});
|
|
1584
|
+
if (options.dryRun) return runCommand(command, args, { cwd: repo, dryRun: true });
|
|
1585
|
+
return withSkillsDelivery((env) => runCommand(command, args, { cwd: repo, env }));
|
|
1547
1586
|
}
|
|
1548
1587
|
|
|
1549
1588
|
function runProjectInit(options) {
|
|
@@ -1746,7 +1785,8 @@ function commandSurfaceForTarget(target, repo) {
|
|
|
1746
1785
|
paths: OPENSPEC_COMMAND_IDS.map((id) =>
|
|
1747
1786
|
path.join(repo, location, `${id}.md`)
|
|
1748
1787
|
),
|
|
1749
|
-
remediation: "run keel --init --target claude
|
|
1788
|
+
remediation: "run keel --init --target claude to remove them",
|
|
1789
|
+
retired: true,
|
|
1750
1790
|
};
|
|
1751
1791
|
}
|
|
1752
1792
|
if (target === "codex" && codexOpenSpecLayout(repo) === "agents") {
|
|
@@ -1776,7 +1816,8 @@ function commandSurfaceForTarget(target, repo) {
|
|
|
1776
1816
|
paths: OPENSPEC_COMMAND_IDS.map((id) =>
|
|
1777
1817
|
path.join(repo, location, `opsx-${id}.md`)
|
|
1778
1818
|
),
|
|
1779
|
-
remediation: "run keel --init --target opencode
|
|
1819
|
+
remediation: "run keel --init --target opencode to remove them",
|
|
1820
|
+
retired: true,
|
|
1780
1821
|
};
|
|
1781
1822
|
}
|
|
1782
1823
|
|
|
@@ -1804,16 +1845,19 @@ function openspecOverlaySurfacesForTarget(target, repo) {
|
|
|
1804
1845
|
archive: "openspec-archive-change",
|
|
1805
1846
|
sync: "openspec-sync-specs",
|
|
1806
1847
|
}[action];
|
|
1848
|
+
// Claude and OpenCode command files are no longer generated (#406); one a
|
|
1849
|
+
// repository still holds from a `both` delivery keeps its overlay until
|
|
1850
|
+
// the next `keel --init` removes it.
|
|
1851
|
+
const command = commandPathForAction(target, repo, action);
|
|
1852
|
+
const keepsCommand = command !== null
|
|
1853
|
+
&& (target === "codex" || fs.existsSync(command));
|
|
1807
1854
|
return [
|
|
1808
1855
|
{
|
|
1809
1856
|
action,
|
|
1810
1857
|
path: path.join(repo, skillRoot, skillName, "SKILL.md"),
|
|
1811
1858
|
},
|
|
1812
|
-
{
|
|
1813
|
-
|
|
1814
|
-
path: commandPathForAction(target, repo, action),
|
|
1815
|
-
},
|
|
1816
|
-
].filter((surface) => surface.path !== null);
|
|
1859
|
+
...(keepsCommand ? [{ action, path: command }] : []),
|
|
1860
|
+
];
|
|
1817
1861
|
});
|
|
1818
1862
|
}
|
|
1819
1863
|
|
|
@@ -1902,7 +1946,7 @@ function keelOpenSpecOverlay(action) {
|
|
|
1902
1946
|
: [
|
|
1903
1947
|
"- Archive completion is gated by `keel gate change-close --action archive` plus `keel-review-checklist`; verify task evidence, follow-up ownership, and completion gates before proceeding.",
|
|
1904
1948
|
"- Before final sync/archive, each related critical expectation must have behavior evidence, a durable follow-up owner, or an explicit discard reason.",
|
|
1905
|
-
"- When
|
|
1949
|
+
"- When the `openspec-sync-specs` skill has already promoted the change's spec delta, run the archive with `--skip-specs` so the promoted delta is not re-applied; archive is not idempotent over an already-synced delta.",
|
|
1906
1950
|
"- After archiving, run `keel guard clear` to drop the change's guard manifest; the read-only gate never clears it for you.",
|
|
1907
1951
|
"- A repository that standing-authorizes `archive` in `keel/config.yaml` does not need the per-occurrence archive confirmation; a repository that declares nothing still needs it.",
|
|
1908
1952
|
"- The completion gate and follow-up ownership checks still run unchanged under a standing authorization; it removes the confirmation, not the proof.",
|
|
@@ -2237,7 +2281,17 @@ function printTargetSurface(repo, target) {
|
|
|
2237
2281
|
);
|
|
2238
2282
|
|
|
2239
2283
|
const commands = commandSurfaceForTarget(target, repo);
|
|
2240
|
-
if (commands.
|
|
2284
|
+
if (commands.retired) {
|
|
2285
|
+
const leftover = commands.paths.filter((file) => fs.existsSync(file));
|
|
2286
|
+
printDoctorLine(
|
|
2287
|
+
"OpenSpec commands",
|
|
2288
|
+
leftover.length === 0 ? "ok" : "duplicate",
|
|
2289
|
+
leftover.length === 0
|
|
2290
|
+
? "none; Keel generates OpenSpec's workflows as skills only (#406)"
|
|
2291
|
+
: `${leftover.length} command file${leftover.length === 1 ? "" : "s"} under ${commands.location} `
|
|
2292
|
+
+ `duplicate the skills; ${commands.remediation}`
|
|
2293
|
+
);
|
|
2294
|
+
} else if (commands.skillsOnly) {
|
|
2241
2295
|
printDoctorLine(
|
|
2242
2296
|
"OpenSpec commands",
|
|
2243
2297
|
"ok",
|
|
@@ -2876,7 +2930,9 @@ function runAction(options) {
|
|
|
2876
2930
|
return 1;
|
|
2877
2931
|
}
|
|
2878
2932
|
const archiving = options.openspecArgs[0] === "archive" ? archiveTracking(process.cwd(), options.openspecArgs) : null;
|
|
2879
|
-
const status =
|
|
2933
|
+
const status = OPENSPEC_GENERATING_COMMANDS.has(options.openspecArgs[0])
|
|
2934
|
+
? withSkillsDelivery((env) => runCommand(openspec, options.openspecArgs, { stdio: "inherit", env }))
|
|
2935
|
+
: runCommand(openspec, options.openspecArgs, { stdio: "inherit" });
|
|
2880
2936
|
if (status === 0 && archiving) keepArchivedTracked(process.cwd(), archiving);
|
|
2881
2937
|
if (status !== 0 || options.openspecArgs[0] !== "update") return status;
|
|
2882
2938
|
const repo = process.cwd();
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@christang/keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.183.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.183.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.183.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.183.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",
|
|
@@ -7,7 +7,7 @@ description: Align explicit requirements, implicit expectations, non-goals, obse
|
|
|
7
7
|
|
|
8
8
|
## Purpose
|
|
9
9
|
|
|
10
|
-
Turn user intent and repository facts into durable OpenSpec authority before specs and executable tasks harden. Alignment is risk-scaled: clear, complete, low-risk requests pass through a compact quick path; material ambiguity switches to a focused deep path. This skill owns materiality routing, acceptance authority, and write-back ownership; which surface a host offers for asking is the host's, and it does not replace
|
|
10
|
+
Turn user intent and repository facts into durable OpenSpec authority before specs and executable tasks harden. Alignment is risk-scaled: clear, complete, low-risk requests pass through a compact quick path; material ambiguity switches to a focused deep path. This skill owns materiality routing, acceptance authority, and write-back ownership; which surface a host offers for asking is the host's, and it does not replace `openspec-apply-change`, review, or OpenSpec artifact mechanics.
|
|
11
11
|
|
|
12
12
|
## Routing
|
|
13
13
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: keel-debug-failure
|
|
3
|
-
description: Debug Keel agent command or validation failures under Keel's selected OpenSpec task contract. Use when
|
|
3
|
+
description: Debug Keel agent command or validation failures under Keel's selected OpenSpec task contract. Use when `openspec-apply-change` or a selected task reports failed commands, failing tests, validation errors, stop decisions, or needs an evidence-bound failure report.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# keel-debug-failure
|
|
@@ -7,7 +7,7 @@ description: Run the current agent's thin semantic consistency review after shar
|
|
|
7
7
|
|
|
8
8
|
## Purpose
|
|
9
9
|
|
|
10
|
-
Use this thin Keel consistency gate only at completion gates: after a complete
|
|
10
|
+
Use this thin Keel consistency gate only at completion gates: after a complete `openspec-apply-change` task group, before `openspec-sync-specs` or `openspec-archive-change`, before meaningful handoff, or when delivery reports risks, findings, follow-ups, or out-of-scope need.
|
|
11
11
|
|
|
12
12
|
Shared Core commands (`keel gate task-start`, `task-complete`, and `change-close`) validate deterministic structure. They do not judge product intent, behavioral test sufficiency, design quality, or risk completeness. Those judgments remain with the current agent.
|
|
13
13
|
|
|
@@ -51,8 +51,8 @@ REQUIRED_SCRIPTS = [
|
|
|
51
51
|
"scripts/validate_plugin.py",
|
|
52
52
|
]
|
|
53
53
|
|
|
54
|
-
PACKAGE_VERSION = "5.
|
|
55
|
-
PROTOCOL_VERSION = "5.
|
|
54
|
+
PACKAGE_VERSION = "5.183.0"
|
|
55
|
+
PROTOCOL_VERSION = "5.183.0"
|
|
56
56
|
LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
|
|
57
57
|
OPENSPEC_SCHEMA_NAME = "keel-spec-driven"
|
|
58
58
|
# Mirrors KEEL_PACKAGE_NAME in scripts/install_to_repo.py, one of the two
|
|
@@ -171,9 +171,9 @@ SKILL_DOC_REQUIREMENTS = [
|
|
|
171
171
|
"path": "src/skills/keel-review-checklist/SKILL.md",
|
|
172
172
|
"required": [
|
|
173
173
|
"completion gates",
|
|
174
|
-
"
|
|
175
|
-
"
|
|
176
|
-
"
|
|
174
|
+
"openspec-apply-change",
|
|
175
|
+
"openspec-sync-specs",
|
|
176
|
+
"openspec-archive-change",
|
|
177
177
|
"## Context to read",
|
|
178
178
|
"keel gate task-start",
|
|
179
179
|
"task-complete",
|
|
@@ -753,7 +753,7 @@ def validate_openspec_schema(errors: list[str]) -> None:
|
|
|
753
753
|
f"name: {OPENSPEC_SCHEMA_NAME}",
|
|
754
754
|
"description: Keel OpenSpec workflow",
|
|
755
755
|
"apply:",
|
|
756
|
-
"
|
|
756
|
+
"openspec-apply-change",
|
|
757
757
|
"keel-review-checklist",
|
|
758
758
|
"Mode",
|
|
759
759
|
"Covers",
|
|
@@ -1227,7 +1227,7 @@ def validate_target_surface_scenario() -> int:
|
|
|
1227
1227
|
claude_doctor.returncode != 0
|
|
1228
1228
|
or "Target surface:" not in claude_doctor.stdout
|
|
1229
1229
|
or "OpenSpec commands: ok" not in claude_doctor.stdout
|
|
1230
|
-
or "
|
|
1230
|
+
or "skills only" not in claude_doctor.stdout
|
|
1231
1231
|
or "OpenSpec action skills: ok" not in claude_doctor.stdout
|
|
1232
1232
|
or ".claude/skills" not in posix_paths(claude_doctor.stdout)
|
|
1233
1233
|
or "bootstrap: ok" not in claude_doctor.stdout
|
|
@@ -1294,7 +1294,7 @@ def validate_target_surface_scenario() -> int:
|
|
|
1294
1294
|
if (
|
|
1295
1295
|
opencode_doctor.returncode != 0
|
|
1296
1296
|
or "OpenSpec commands: ok" not in opencode_doctor.stdout
|
|
1297
|
-
or "
|
|
1297
|
+
or "skills only" not in opencode_doctor.stdout
|
|
1298
1298
|
or "OpenSpec action skills: ok" not in opencode_doctor.stdout
|
|
1299
1299
|
or ".opencode/skills" not in posix_paths(opencode_doctor.stdout)
|
|
1300
1300
|
or "bootstrap: ok" not in opencode_doctor.stdout
|
|
@@ -8420,6 +8420,191 @@ def validate_shift_start_desktop_scenario() -> int:
|
|
|
8420
8420
|
return 0
|
|
8421
8421
|
|
|
8422
8422
|
|
|
8423
|
+
# A claude for the hand-over's host contract (#408): `agents --json` from a rows
|
|
8424
|
+
# file, `stop` that drops the row's status and pid at once and ends the process
|
|
8425
|
+
# a second later (`late`) or never (`never`), as measured on 2.1.304 (row 0.32 s,
|
|
8426
|
+
# return 0.98 s, exit 3.2 s), `rm` that logs whether that process was still
|
|
8427
|
+
# running, and a new session for `--bg`.
|
|
8428
|
+
HANDOVER_CONTRACT_FAKE = """#!/usr/bin/env python3
|
|
8429
|
+
import json, os, subprocess, sys
|
|
8430
|
+
agents, calls, mode = os.environ['FAKE_AGENTS'], os.environ['FAKE_CALLS'], os.environ.get('FAKE_STOP_MODE', 'late')
|
|
8431
|
+
argv = sys.argv[1:]
|
|
8432
|
+
def running(pid):
|
|
8433
|
+
try:
|
|
8434
|
+
os.kill(pid, 0)
|
|
8435
|
+
except OSError:
|
|
8436
|
+
return False
|
|
8437
|
+
return True
|
|
8438
|
+
rows = json.loads(open(agents).read())
|
|
8439
|
+
record = {'argv': argv}
|
|
8440
|
+
if argv[:1] == ['rm']:
|
|
8441
|
+
gone = [row for row in rows if row['id'] == argv[1]]
|
|
8442
|
+
record['alive'] = bool(gone) and bool(gone[0].get('_pid')) and running(gone[0]['_pid'])
|
|
8443
|
+
rows = [row for row in rows if row['id'] != argv[1]]
|
|
8444
|
+
open(calls, 'a').write(json.dumps(record) + '\\n')
|
|
8445
|
+
if argv[:2] == ['agents', '--json']:
|
|
8446
|
+
print(json.dumps([{k: v for k, v in row.items() if not k.startswith('_')} for row in rows])); sys.exit(0)
|
|
8447
|
+
if argv[:1] == ['stop']:
|
|
8448
|
+
for row in rows:
|
|
8449
|
+
if row['id'] == argv[1] and 'status' in row:
|
|
8450
|
+
pid = row.pop('pid', None); row.pop('status', None); row['state'] = 'stopped'; row['_pid'] = pid
|
|
8451
|
+
if pid and mode == 'late':
|
|
8452
|
+
subprocess.Popen(['sh', '-c', f'sleep 1; kill {pid}'], start_new_session=True,
|
|
8453
|
+
stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
|
8454
|
+
open(agents, 'w').write(json.dumps(rows)); print('stopped ' + argv[1]); sys.exit(0)
|
|
8455
|
+
if argv[:1] == ['--bg']:
|
|
8456
|
+
rows.append({'kind': 'background', 'name': 'verify', 'sessionId': 'newsess1-0000-0000-0000-000000000000', 'id': 'newsess1',
|
|
8457
|
+
'status': 'busy', 'state': 'working', 'pid': os.getpid(), 'cwd': os.getcwd(), 'startedAt': 1792600000000})
|
|
8458
|
+
open(agents, 'w').write(json.dumps(rows)); print('backgrounded · newsess1 · verify'); sys.exit(0)
|
|
8459
|
+
open(agents, 'w').write(json.dumps(rows)); print('ok')
|
|
8460
|
+
"""
|
|
8461
|
+
|
|
8462
|
+
|
|
8463
|
+
def detached_sleeper() -> int:
|
|
8464
|
+
"""A process that is not this one's child, so a kill reaps it instead of leaving a zombie."""
|
|
8465
|
+
return int(subprocess.run(["sh", "-c", "sleep 600 >/dev/null 2>&1 & echo $!"], text=True,
|
|
8466
|
+
capture_output=True, check=True).stdout.strip())
|
|
8467
|
+
|
|
8468
|
+
|
|
8469
|
+
def validate_shift_cli_removes_after_exit_scenario() -> int:
|
|
8470
|
+
"""Issue #408: a hand-over never removes a session whose process still runs.
|
|
8471
|
+
|
|
8472
|
+
Measured on Claude Code 2.1.304 (2026-10-21): after `claude stop` the row
|
|
8473
|
+
loses `status` and `pid` at 0.32 s, the command returns at 0.98 s, and the
|
|
8474
|
+
process exits about 3.2 s in. Since #418 the session just handed over is
|
|
8475
|
+
removed by default, so the removal waits for the process the note recorded.
|
|
8476
|
+
"""
|
|
8477
|
+
label = "shift-cli-removes-after-exit:"
|
|
8478
|
+
OLD = "5b14fbae-b6aa-40b6-a72a-b3f89d2c6eea"
|
|
8479
|
+
for mode in ("late", "never"):
|
|
8480
|
+
with tempfile.TemporaryDirectory(prefix="keel-shift-408a-") as raw:
|
|
8481
|
+
base = Path(raw)
|
|
8482
|
+
rtl, verify, env, _ = shift_scratch(base)
|
|
8483
|
+
agents, calls, fake, config = base / "agents.json", base / "calls.jsonl", base / "fake-claude", base / "claude"
|
|
8484
|
+
write_text(fake, HANDOVER_CONTRACT_FAKE)
|
|
8485
|
+
fake.chmod(0o755)
|
|
8486
|
+
write_text(config / "projects" / host_project_name(verify) / f"{OLD}.jsonl",
|
|
8487
|
+
json.dumps({"type": "user", "message": {"role": "user", "content": "carry on"}}) + "\n")
|
|
8488
|
+
process = detached_sleeper()
|
|
8489
|
+
try:
|
|
8490
|
+
agents.write_text(json.dumps([{"kind": "background", "name": "verify", "sessionId": OLD, "id": OLD[:8],
|
|
8491
|
+
"status": "idle", "state": "done", "pid": process, "cwd": str(verify),
|
|
8492
|
+
"startedAt": 1792500000000}]))
|
|
8493
|
+
calls.write_text("")
|
|
8494
|
+
env = {**env, "KEEL_CLAUDE": str(fake), "CLAUDE_CONFIG_DIR": str(config), "FAKE_AGENTS": str(agents),
|
|
8495
|
+
"FAKE_CALLS": str(calls), "FAKE_STOP_MODE": mode, "KEEL_SHIFT_HANDOVER_TIMEOUT_MS": "1",
|
|
8496
|
+
"KEEL_SHIFT_EXIT_WAIT_MS": "5000" if mode == "late" else "1500"}
|
|
8497
|
+
cli_env = {**env, "CLAUDE_CODE_ENTRYPOINT": "cli", "CLAUDE_CODE_SESSION_ID": OLD, "CLAUDE_PID": str(process)}
|
|
8498
|
+
readied = run_keel(verify, "shift", "ready", "--wake", "next: rerun R030", env=cli_env)
|
|
8499
|
+
if readied.returncode != 0:
|
|
8500
|
+
report(f"{label} ready --wake failed: {readied.stderr!r}")
|
|
8501
|
+
return 1
|
|
8502
|
+
run_keel(verify, "tick", "--repo", str(rtl), env=env)
|
|
8503
|
+
removals = [json.loads(line) for line in calls.read_text().splitlines() if json.loads(line)["argv"][:1] == ["rm"]]
|
|
8504
|
+
status = run_keel(rtl, "shift", "status", env=env).stdout
|
|
8505
|
+
if mode == "late":
|
|
8506
|
+
if [r["argv"][1] for r in removals] != [OLD[:8]]:
|
|
8507
|
+
report(f"{label} the hand-over did not remove the session just handed over once its process exited: {removals!r}")
|
|
8508
|
+
return 1
|
|
8509
|
+
if removals[0]["alive"]:
|
|
8510
|
+
report(f"{label} `claude rm` of the session just handed over ran while its process was still running.")
|
|
8511
|
+
return 1
|
|
8512
|
+
else:
|
|
8513
|
+
if removals:
|
|
8514
|
+
report(f"{label} a session whose process never exited was removed: {removals!r}")
|
|
8515
|
+
return 1
|
|
8516
|
+
if f"claude attach {OLD[:8]}" not in status:
|
|
8517
|
+
report(f"{label} shift status does not say the old session is kept for `claude attach`: {status!r}")
|
|
8518
|
+
return 1
|
|
8519
|
+
finally:
|
|
8520
|
+
with contextlib.suppress(OSError):
|
|
8521
|
+
os.kill(process, signal.SIGKILL)
|
|
8522
|
+
if label.rstrip(":") not in {name for name, _ in SCENARIOS}:
|
|
8523
|
+
report(f"{label} the scenario registry does not include it.")
|
|
8524
|
+
return 1
|
|
8525
|
+
report(f"{label.rstrip(':')} scenario passed.")
|
|
8526
|
+
return 0
|
|
8527
|
+
|
|
8528
|
+
|
|
8529
|
+
def validate_shift_cli_names_host_failure_scenario() -> int:
|
|
8530
|
+
"""Issue #408: a hand-off the host cannot be asked about says why it waits."""
|
|
8531
|
+
label = "shift-cli-names-host-failure:"
|
|
8532
|
+
OLD = "5b14fbae-b6aa-40b6-a72a-b3f89d2c6eea"
|
|
8533
|
+
for case, needle in (("missing", "claude was not found"), ("garbled", "agents --json")):
|
|
8534
|
+
with tempfile.TemporaryDirectory(prefix="keel-shift-408b-") as raw:
|
|
8535
|
+
base = Path(raw)
|
|
8536
|
+
rtl, verify, env, _ = shift_scratch(base)
|
|
8537
|
+
claude = base / "no-claude"
|
|
8538
|
+
if case == "garbled":
|
|
8539
|
+
write_text(claude, "#!/bin/sh\necho 'not a list'\n")
|
|
8540
|
+
claude.chmod(0o755)
|
|
8541
|
+
env = {**env, "KEEL_CLAUDE": str(claude), "KEEL_SHIFT_HANDOVER_TIMEOUT_MS": "1"}
|
|
8542
|
+
cli_env = {**env, "CLAUDE_CODE_ENTRYPOINT": "cli", "CLAUDE_CODE_SESSION_ID": OLD, "CLAUDE_PID": str(os.getpid())}
|
|
8543
|
+
readied = run_keel(verify, "shift", "ready", "--wake", "next: rerun R031", env=cli_env)
|
|
8544
|
+
if readied.returncode != 0:
|
|
8545
|
+
report(f"{label} ready --wake failed ({case}): {readied.stderr!r}")
|
|
8546
|
+
return 1
|
|
8547
|
+
run_keel(verify, "tick", "--repo", str(rtl), env=env)
|
|
8548
|
+
status = run_keel(rtl, "shift", "status", env=env).stdout
|
|
8549
|
+
if "pending" not in status:
|
|
8550
|
+
report(f"{label} the hand-off is no longer pending ({case}): {status!r}")
|
|
8551
|
+
return 1
|
|
8552
|
+
if needle not in status:
|
|
8553
|
+
report(f"{label} shift status does not name why the hand-off waits ({case}, expected {needle!r}): {status!r}")
|
|
8554
|
+
return 1
|
|
8555
|
+
if label.rstrip(":") not in {name for name, _ in SCENARIOS}:
|
|
8556
|
+
report(f"{label} the scenario registry does not include it.")
|
|
8557
|
+
return 1
|
|
8558
|
+
report(f"{label.rstrip(':')} scenario passed.")
|
|
8559
|
+
return 0
|
|
8560
|
+
|
|
8561
|
+
|
|
8562
|
+
def validate_tick_retries_failed_wake_scenario() -> int:
|
|
8563
|
+
"""Issue #408: a tick retries a failed wake a bounded number of times.
|
|
8564
|
+
|
|
8565
|
+
A tick marked the role woken whether or not the resume worked, so one
|
|
8566
|
+
failure was never retried; a removed session is not tried again either.
|
|
8567
|
+
"""
|
|
8568
|
+
label = "tick-retries-failed-wake:"
|
|
8569
|
+
for case in ("failing", "removed"):
|
|
8570
|
+
with tempfile.TemporaryDirectory(prefix="keel-tick-408c-") as raw:
|
|
8571
|
+
base = Path(raw)
|
|
8572
|
+
rtl, verify, env, _ = shift_scratch(base)
|
|
8573
|
+
calls = base / "calls.jsonl"
|
|
8574
|
+
fake = base / "fake-claude"
|
|
8575
|
+
listed = "['sess-verify-1']" if case == "failing" else "['other-0000']"
|
|
8576
|
+
write_text(fake, "#!/usr/bin/env python3\nimport json, sys\n"
|
|
8577
|
+
f"open({str(calls)!r}, 'a').write(json.dumps(sys.argv[1:]) + '\\n')\n"
|
|
8578
|
+
"if sys.argv[1:3] == ['agents', '--json']:\n"
|
|
8579
|
+
f" print(json.dumps([{{'kind': 'background', 'sessionId': s, 'id': s[:8]}} for s in {listed}])); sys.exit(0)\n"
|
|
8580
|
+
"if sys.argv[1:2] == ['--bg']:\n print('Workspace not trusted.', file=sys.stderr); sys.exit(1)\n")
|
|
8581
|
+
fake.chmod(0o755)
|
|
8582
|
+
env = {**env, "KEEL_CLAUDE": str(fake)}
|
|
8583
|
+
dead = subprocess.Popen(["true"])
|
|
8584
|
+
dead.wait()
|
|
8585
|
+
chat_session_start(verify, env, "sess-verify-1", dead.pid)
|
|
8586
|
+
run_keel(rtl, "chat", "dm", "verify", "rerun R032", env=env)
|
|
8587
|
+
for _ in range(4):
|
|
8588
|
+
run_keel(verify, "tick", "--repo", str(rtl), env=env)
|
|
8589
|
+
made = [json.loads(line) for line in calls.read_text().splitlines()] if calls.exists() else []
|
|
8590
|
+
resumes = [call for call in made if call[:2] == ["--bg", "--resume"]]
|
|
8591
|
+
lookups = [call for call in made if call[:2] == ["agents", "--json"]]
|
|
8592
|
+
if case == "failing" and len(resumes) != 3:
|
|
8593
|
+
report(f"{label} four ticks tried a failing resume {len(resumes)} times, not 3.")
|
|
8594
|
+
return 1
|
|
8595
|
+
if case == "removed" and resumes:
|
|
8596
|
+
report(f"{label} a removed session was resumed: {resumes!r}")
|
|
8597
|
+
return 1
|
|
8598
|
+
if case == "removed" and len(lookups) != 1:
|
|
8599
|
+
report(f"{label} four ticks looked up a removed session {len(lookups)} times, not once.")
|
|
8600
|
+
return 1
|
|
8601
|
+
if label.rstrip(":") not in {name for name, _ in SCENARIOS}:
|
|
8602
|
+
report(f"{label} the scenario registry does not include it.")
|
|
8603
|
+
return 1
|
|
8604
|
+
report(f"{label.rstrip(':')} scenario passed.")
|
|
8605
|
+
return 0
|
|
8606
|
+
|
|
8607
|
+
|
|
8423
8608
|
def validate_shift_cli_self_shift_scenario() -> int:
|
|
8424
8609
|
"""Issues #357 and #388 on the CLI (owner, 2026-10-19): hand over, promptly, and retire.
|
|
8425
8610
|
|
|
@@ -8472,8 +8657,7 @@ def validate_shift_cli_self_shift_scenario() -> int:
|
|
|
8472
8657
|
"if argv[:1] == ['--bg']:\n print('backgrounded · newsess1 · verify'); sys.exit(0)\n"
|
|
8473
8658
|
"print('stopped')\n")
|
|
8474
8659
|
fake.chmod(0o755)
|
|
8475
|
-
env = {**env, "KEEL_CLAUDE": str(fake), "KEEL_SHIFT_HANDOVER_POLL_MS": "200", "KEEL_SHIFT_HANDOVER_TIMEOUT_MS": "20000"
|
|
8476
|
-
"KEEL_SHIFT_RENAME_WAIT_MS": "1500"}
|
|
8660
|
+
env = {**env, "KEEL_CLAUDE": str(fake), "KEEL_SHIFT_HANDOVER_POLL_MS": "200", "KEEL_SHIFT_HANDOVER_TIMEOUT_MS": "20000"}
|
|
8477
8661
|
# With the waiter given no time, a hand-over is the tick's alone.
|
|
8478
8662
|
tick_only = {**env, "KEEL_SHIFT_HANDOVER_TIMEOUT_MS": "1"}
|
|
8479
8663
|
cli_env = {**env, "CLAUDE_CODE_ENTRYPOINT": "cli", "CLAUDE_CODE_SESSION_ID": OLD, "CLAUDE_PID": str(os.getpid())}
|
|
@@ -8674,9 +8858,12 @@ def validate_shift_cli_keeps_old_sessions_scenario() -> int:
|
|
|
8674
8858
|
" open(agents, 'w').write(json.dumps(rows)); print('backgrounded · newsess1 · verify'); sys.exit(0)\n"
|
|
8675
8859
|
"open(agents, 'w').write(json.dumps(rows)); print('ok'); sys.exit(0)\n")
|
|
8676
8860
|
fake.chmod(0o755)
|
|
8677
|
-
env = {**env, "KEEL_CLAUDE": str(fake), "CLAUDE_CONFIG_DIR": str(config_dir), "KEEL_SHIFT_HANDOVER_TIMEOUT_MS": "1"
|
|
8678
|
-
|
|
8679
|
-
|
|
8861
|
+
env = {**env, "KEEL_CLAUDE": str(fake), "CLAUDE_CONFIG_DIR": str(config_dir), "KEEL_SHIFT_HANDOVER_TIMEOUT_MS": "1"}
|
|
8862
|
+
# The process the note records has exited by the time the hand-over removes the session,
|
|
8863
|
+
# as on the host; #408 makes the removal wait for it.
|
|
8864
|
+
exited = subprocess.Popen(["true"])
|
|
8865
|
+
exited.wait()
|
|
8866
|
+
cli_env = {**env, "CLAUDE_CODE_ENTRYPOINT": "cli", "CLAUDE_CODE_SESSION_ID": OLD, "CLAUDE_PID": str(exited.pid)}
|
|
8680
8867
|
roles = json.loads((mailbox_common_dir(rtl) / "keel-chat" / "roles.json").read_text(encoding="utf-8"))
|
|
8681
8868
|
bound = {role: path for path, role in roles.items()}
|
|
8682
8869
|
|
|
@@ -10951,16 +11138,21 @@ def openspec_overlay_files(
|
|
|
10951
11138
|
target: str,
|
|
10952
11139
|
codex_home: Path | None = None,
|
|
10953
11140
|
) -> dict[str, list[Path]]:
|
|
11141
|
+
# Keel generates skills only (#406); a command file counts only while a
|
|
11142
|
+
# repository still holds one from an earlier `both` delivery.
|
|
11143
|
+
def held(*paths: Path) -> list[Path]:
|
|
11144
|
+
return [paths[0], *[p for p in paths[1:] if p.exists()]]
|
|
11145
|
+
|
|
10954
11146
|
if target == "claude":
|
|
10955
11147
|
return {
|
|
10956
|
-
"apply":
|
|
11148
|
+
"apply": held(
|
|
10957
11149
|
repo / ".claude/skills/openspec-apply-change/SKILL.md",
|
|
10958
11150
|
repo / ".claude/commands/opsx/apply.md",
|
|
10959
|
-
|
|
10960
|
-
"archive":
|
|
11151
|
+
),
|
|
11152
|
+
"archive": held(
|
|
10961
11153
|
repo / ".claude/skills/openspec-archive-change/SKILL.md",
|
|
10962
11154
|
repo / ".claude/commands/opsx/archive.md",
|
|
10963
|
-
|
|
11155
|
+
),
|
|
10964
11156
|
}
|
|
10965
11157
|
if target == "codex":
|
|
10966
11158
|
assert codex_home is not None
|
|
@@ -10971,14 +11163,14 @@ def openspec_overlay_files(
|
|
|
10971
11163
|
"archive": [repo / ".agents/skills/openspec-archive-change/SKILL.md"],
|
|
10972
11164
|
}
|
|
10973
11165
|
return {
|
|
10974
|
-
"apply":
|
|
11166
|
+
"apply": held(
|
|
10975
11167
|
repo / ".opencode/skills/openspec-apply-change/SKILL.md",
|
|
10976
11168
|
repo / ".opencode/commands/opsx-apply.md",
|
|
10977
|
-
|
|
10978
|
-
"archive":
|
|
11169
|
+
),
|
|
11170
|
+
"archive": held(
|
|
10979
11171
|
repo / ".opencode/skills/openspec-archive-change/SKILL.md",
|
|
10980
11172
|
repo / ".opencode/commands/opsx-archive.md",
|
|
10981
|
-
|
|
11173
|
+
),
|
|
10982
11174
|
}
|
|
10983
11175
|
|
|
10984
11176
|
|
|
@@ -11081,15 +11273,20 @@ def expected_overlay_surfaces(
|
|
|
11081
11273
|
for action, skill in OVERLAY_ACTION_SKILLS.items():
|
|
11082
11274
|
if action == "propose" and target == "opencode":
|
|
11083
11275
|
continue
|
|
11276
|
+
# Keel generates skills only (#406); a command file counts only while a
|
|
11277
|
+
# repository still holds one from an earlier `both` delivery.
|
|
11084
11278
|
if target == "claude":
|
|
11085
11279
|
surfaces.append(repo / f".claude/skills/{skill}/SKILL.md")
|
|
11086
|
-
|
|
11280
|
+
command = repo / f".claude/commands/opsx/{action}.md"
|
|
11087
11281
|
elif target == "codex":
|
|
11088
11282
|
assert codex_home is not None
|
|
11089
11283
|
surfaces.append(repo / f".agents/skills/{skill}/SKILL.md")
|
|
11284
|
+
command = None
|
|
11090
11285
|
else:
|
|
11091
11286
|
surfaces.append(repo / f".opencode/skills/{skill}/SKILL.md")
|
|
11092
|
-
|
|
11287
|
+
command = repo / f".opencode/commands/opsx-{action}.md"
|
|
11288
|
+
if command is not None and command.exists():
|
|
11289
|
+
surfaces.append(command)
|
|
11093
11290
|
return surfaces
|
|
11094
11291
|
|
|
11095
11292
|
|
|
@@ -11325,8 +11522,8 @@ def validate_sync_surface_overlay_scenario() -> int:
|
|
|
11325
11522
|
tmp = Path(raw)
|
|
11326
11523
|
|
|
11327
11524
|
surfaces = {
|
|
11525
|
+
# Skills only since #406: Keel generates no `.claude/commands/opsx/`.
|
|
11328
11526
|
"claude": [
|
|
11329
|
-
".claude/commands/opsx/sync.md",
|
|
11330
11527
|
".claude/skills/openspec-sync-specs/SKILL.md",
|
|
11331
11528
|
],
|
|
11332
11529
|
"codex": [
|
|
@@ -11377,8 +11574,8 @@ def validate_sync_surface_overlay_scenario() -> int:
|
|
|
11377
11574
|
|
|
11378
11575
|
# M4 — explore stays uncovered, deliberately.
|
|
11379
11576
|
explore = repo / (
|
|
11380
|
-
".claude/
|
|
11381
|
-
else
|
|
11577
|
+
".claude/skills/openspec-explore/SKILL.md" if target == "claude"
|
|
11578
|
+
else ".agents/skills/openspec-explore/SKILL.md"
|
|
11382
11579
|
)
|
|
11383
11580
|
if explore.is_file() and marker in explore.read_text(encoding="utf-8"):
|
|
11384
11581
|
report(
|
|
@@ -11531,6 +11728,224 @@ def validate_update_restores_overlays_scenario() -> int:
|
|
|
11531
11728
|
return 0
|
|
11532
11729
|
|
|
11533
11730
|
|
|
11731
|
+
def validate_openspec_skills_only_scenario() -> int:
|
|
11732
|
+
"""Issue #406: one copy of each OpenSpec workflow, whatever the global delivery.
|
|
11733
|
+
|
|
11734
|
+
OpenSpec reads `delivery` only from the user's global configuration, which
|
|
11735
|
+
defaults to `both` and put every workflow on Claude twice — a skill and an
|
|
11736
|
+
`/opsx:` command. Keel runs OpenSpec with that configuration's `delivery`
|
|
11737
|
+
replaced by `skills`, and never writes the file itself.
|
|
11738
|
+
"""
|
|
11739
|
+
label = "openspec-skills-only:"
|
|
11740
|
+
with tempfile.TemporaryDirectory(prefix="keel-406-") as raw_tmp:
|
|
11741
|
+
tmp = Path(raw_tmp)
|
|
11742
|
+
config = tmp / "xdg/openspec/config.json"
|
|
11743
|
+
write_text(config, json.dumps({
|
|
11744
|
+
"featureFlags": {}, "profile": "custom", "delivery": "both",
|
|
11745
|
+
"workflows": ["propose", "explore", "apply", "sync", "archive"],
|
|
11746
|
+
}, indent=2) + "\n")
|
|
11747
|
+
before = config.read_bytes()
|
|
11748
|
+
env = dict(os.environ)
|
|
11749
|
+
env["XDG_CONFIG_HOME"] = str(tmp / "xdg")
|
|
11750
|
+
stray = ".claude/commands/opsx/apply.md"
|
|
11751
|
+
upstream = "---\nname: OPSX: Apply\n---\n\nImplement tasks.\n"
|
|
11752
|
+
|
|
11753
|
+
def keel(repo: Path, *args: str):
|
|
11754
|
+
result = run_keel(repo, *args, env=env)
|
|
11755
|
+
if result.returncode != 0:
|
|
11756
|
+
report(f"{label} `keel {' '.join(args)}` failed: {(result.stderr or result.stdout).strip()}")
|
|
11757
|
+
return result
|
|
11758
|
+
|
|
11759
|
+
claude = tmp / "claude"
|
|
11760
|
+
claude.mkdir()
|
|
11761
|
+
if keel(claude, "--init", "--target", "claude").returncode != 0:
|
|
11762
|
+
return 1
|
|
11763
|
+
commands = sorted(p.name for p in (claude / ".claude/commands/opsx").glob("*")) \
|
|
11764
|
+
if (claude / ".claude/commands/opsx").is_dir() else []
|
|
11765
|
+
if commands:
|
|
11766
|
+
report(f"{label} with a global `delivery: both`, keel --init left command files: {commands!r}")
|
|
11767
|
+
return 1
|
|
11768
|
+
skills = [claude / f".claude/skills/{skill}/SKILL.md" for skill in ("openspec-propose", "openspec-explore", "openspec-apply-change",
|
|
11769
|
+
"openspec-sync-specs", "openspec-archive-change")]
|
|
11770
|
+
absent = [str(p.relative_to(claude)) for p in skills if not p.is_file()]
|
|
11771
|
+
if absent:
|
|
11772
|
+
report(f"{label} keel --init did not generate the workflow skills: {absent!r}")
|
|
11773
|
+
return 1
|
|
11774
|
+
# OpenSpec's own text only: the Keel overlay's wording is
|
|
11775
|
+
# guidance-names-openspec-skills's to check.
|
|
11776
|
+
naming = [str(p.relative_to(claude)) for p in skills
|
|
11777
|
+
if "/opsx:" in strip_openspec_surface_overlay(p.read_text(encoding="utf-8"))]
|
|
11778
|
+
if naming:
|
|
11779
|
+
report(f"{label} OpenSpec's generated skill text still names `/opsx:` commands: {naming!r}")
|
|
11780
|
+
return 1
|
|
11781
|
+
unmarked = [str(p.relative_to(claude)) for p in expected_overlay_surfaces(claude, "claude")
|
|
11782
|
+
if OPENSPEC_SURFACE_OVERLAY_START not in p.read_text(encoding="utf-8")]
|
|
11783
|
+
if unmarked:
|
|
11784
|
+
report(f"{label} managed skills lack the Keel overlay: {unmarked!r}")
|
|
11785
|
+
return 1
|
|
11786
|
+
if config.read_bytes() != before:
|
|
11787
|
+
report(f"{label} keel --init rewrote the global OpenSpec configuration: {config.read_text()!r}")
|
|
11788
|
+
return 1
|
|
11789
|
+
|
|
11790
|
+
doctor = keel(claude, "--doctor", "--target", "claude")
|
|
11791
|
+
commands_line = next((l for l in doctor.stdout.splitlines() if l.startswith("OpenSpec commands:")), "")
|
|
11792
|
+
overlay_line = next((l for l in doctor.stdout.splitlines() if l.startswith("Keel apply/archive/sync overlay:")), "")
|
|
11793
|
+
if not commands_line.startswith("OpenSpec commands: ok"):
|
|
11794
|
+
report(f"{label} doctor does not read a skills-only repository's commands as ok: {commands_line!r}")
|
|
11795
|
+
return 1
|
|
11796
|
+
if "skills only" not in commands_line:
|
|
11797
|
+
report(f"{label} doctor's commands line does not say the workflows are skills only: {commands_line!r}")
|
|
11798
|
+
return 1
|
|
11799
|
+
if not overlay_line.startswith("Keel apply/archive/sync overlay: ok"):
|
|
11800
|
+
report(f"{label} doctor does not read the skills-only overlay as ok: {overlay_line!r}")
|
|
11801
|
+
return 1
|
|
11802
|
+
if "4/4" not in overlay_line:
|
|
11803
|
+
report(f"{label} doctor's overlay line does not count 4/4 surfaces: {overlay_line!r}")
|
|
11804
|
+
return 1
|
|
11805
|
+
|
|
11806
|
+
write_text(claude / stray, upstream)
|
|
11807
|
+
if keel(claude, "--install", "--target", "claude").returncode != 0:
|
|
11808
|
+
return 1
|
|
11809
|
+
if OPENSPEC_SURFACE_OVERLAY_START not in (claude / stray).read_text(encoding="utf-8"):
|
|
11810
|
+
report(f"{label} keel --install did not overlay a command file the repository still holds.")
|
|
11811
|
+
return 1
|
|
11812
|
+
doctor = keel(claude, "--doctor", "--target", "claude")
|
|
11813
|
+
commands_line = next((l for l in doctor.stdout.splitlines() if l.startswith("OpenSpec commands:")), "")
|
|
11814
|
+
if not commands_line.startswith("OpenSpec commands: duplicate"):
|
|
11815
|
+
report(f"{label} doctor does not read a leftover command file as duplicate: {commands_line!r}")
|
|
11816
|
+
return 1
|
|
11817
|
+
for needle in ("1 ", ".claude/commands/opsx", "keel --init --target claude"):
|
|
11818
|
+
if needle not in posix_paths(commands_line):
|
|
11819
|
+
report(f"{label} the duplicate line does not name {needle!r}: {commands_line!r}")
|
|
11820
|
+
return 1
|
|
11821
|
+
if keel(claude, "--init", "--target", "claude").returncode != 0:
|
|
11822
|
+
return 1
|
|
11823
|
+
if (claude / stray).exists():
|
|
11824
|
+
report(f"{label} keel --init did not remove a command file a `both` delivery left.")
|
|
11825
|
+
return 1
|
|
11826
|
+
|
|
11827
|
+
passthrough = tmp / "passthrough"
|
|
11828
|
+
passthrough.mkdir()
|
|
11829
|
+
if keel(passthrough, "--init", "--target", "claude").returncode != 0:
|
|
11830
|
+
return 1
|
|
11831
|
+
write_text(passthrough / stray, upstream)
|
|
11832
|
+
if keel(passthrough, "openspec", "update", "--force").returncode != 0:
|
|
11833
|
+
return 1
|
|
11834
|
+
if (passthrough / stray).exists():
|
|
11835
|
+
report(f"{label} keel openspec update did not remove a command file a `both` delivery left.")
|
|
11836
|
+
return 1
|
|
11837
|
+
|
|
11838
|
+
opencode = tmp / "opencode"
|
|
11839
|
+
opencode.mkdir()
|
|
11840
|
+
if keel(opencode, "--init", "--target", "opencode").returncode != 0:
|
|
11841
|
+
return 1
|
|
11842
|
+
left = sorted(p.name for p in (opencode / ".opencode/commands").glob("opsx-*.md")) \
|
|
11843
|
+
if (opencode / ".opencode/commands").is_dir() else []
|
|
11844
|
+
if left:
|
|
11845
|
+
report(f"{label} keel --init --target opencode left command files: {left!r}")
|
|
11846
|
+
return 1
|
|
11847
|
+
# Any OpenSpec command — doctor runs some — records OpenSpec's own
|
|
11848
|
+
# telemetry notice in the file it reads; everything else must stand.
|
|
11849
|
+
settled = {k: v for k, v in json.loads(config.read_text()).items() if k != "telemetry"}
|
|
11850
|
+
if settled != json.loads(before):
|
|
11851
|
+
report(f"{label} a later run changed the global OpenSpec configuration: {config.read_text()!r}")
|
|
11852
|
+
return 1
|
|
11853
|
+
# Last: OpenSpec itself may record its telemetry notice in the file it reads.
|
|
11854
|
+
listed = keel(passthrough, "openspec", "config", "list")
|
|
11855
|
+
if "delivery: both" not in listed.stdout:
|
|
11856
|
+
report(f"{label} keel openspec config list no longer reports the user's own delivery: {listed.stdout!r}")
|
|
11857
|
+
return 1
|
|
11858
|
+
|
|
11859
|
+
if "openspec-skills-only" not in {name for name, _ in SCENARIOS}:
|
|
11860
|
+
report(f"{label} scenario is not registered.")
|
|
11861
|
+
return 1
|
|
11862
|
+
report("openspec-skills-only scenario passed.")
|
|
11863
|
+
return 0
|
|
11864
|
+
|
|
11865
|
+
|
|
11866
|
+
def validate_guidance_names_openspec_skills_scenario() -> int:
|
|
11867
|
+
"""Issue #406: guidance names no `/opsx:` command, since Keel generates none.
|
|
11868
|
+
|
|
11869
|
+
With the workflows delivered as skills only, a sentence telling the reader
|
|
11870
|
+
to run `/opsx:sync` points at a command that does not exist.
|
|
11871
|
+
"""
|
|
11872
|
+
label = "guidance-names-openspec-skills:"
|
|
11873
|
+
shipped = [ROOT / "README.md", ROOT / "README.zh-CN.md",
|
|
11874
|
+
ROOT / "assets/openspec/schemas/keel-spec-driven/schema.yaml",
|
|
11875
|
+
*sorted((ROOT / "src/skills").rglob("SKILL.md")),
|
|
11876
|
+
*sorted((ROOT / "plugins/keel/skills").rglob("SKILL.md"))]
|
|
11877
|
+
naming = [str(p.relative_to(ROOT)) for p in shipped if "/opsx:" in p.read_text(encoding="utf-8")]
|
|
11878
|
+
if naming:
|
|
11879
|
+
report(f"{label} shipped guidance still names `/opsx:` commands: {naming!r}")
|
|
11880
|
+
return 1
|
|
11881
|
+
block = extract_managed_block((ROOT / "AGENTS.md").read_text(encoding="utf-8")) or ""
|
|
11882
|
+
if not block:
|
|
11883
|
+
report(f"{label} AGENTS.md has no managed protocol block to read.")
|
|
11884
|
+
return 1
|
|
11885
|
+
for needle in ("/opsx:", "commands/opsx"):
|
|
11886
|
+
if needle in block:
|
|
11887
|
+
report(f"{label} the AGENTS.md protocol block still names {needle!r}.")
|
|
11888
|
+
return 1
|
|
11889
|
+
|
|
11890
|
+
with tempfile.TemporaryDirectory(prefix="keel-406-guidance-") as raw_tmp:
|
|
11891
|
+
repo = Path(raw_tmp)
|
|
11892
|
+
init = run_keel(repo, "--init", "--target", "claude")
|
|
11893
|
+
if init.returncode != 0:
|
|
11894
|
+
report(f"{label} keel --init --target claude failed: {(init.stderr or init.stdout).strip()}")
|
|
11895
|
+
return 1
|
|
11896
|
+
archive = (repo / ".claude/skills/openspec-archive-change/SKILL.md").read_text(encoding="utf-8")
|
|
11897
|
+
overlay = archive[archive.find(OPENSPEC_SURFACE_OVERLAY_START):archive.find(OPENSPEC_SURFACE_OVERLAY_END)]
|
|
11898
|
+
if not overlay:
|
|
11899
|
+
report(f"{label} the archive skill carries no Keel overlay to read.")
|
|
11900
|
+
return 1
|
|
11901
|
+
if "/opsx:" in overlay:
|
|
11902
|
+
report(f"{label} the archive overlay still names an `/opsx:` command.")
|
|
11903
|
+
return 1
|
|
11904
|
+
if "openspec-sync-specs" not in overlay:
|
|
11905
|
+
report(f"{label} the archive overlay does not name `openspec-sync-specs`.")
|
|
11906
|
+
return 1
|
|
11907
|
+
|
|
11908
|
+
if "guidance-names-openspec-skills" not in {name for name, _ in SCENARIOS}:
|
|
11909
|
+
report(f"{label} scenario is not registered.")
|
|
11910
|
+
return 1
|
|
11911
|
+
report("guidance-names-openspec-skills scenario passed.")
|
|
11912
|
+
return 0
|
|
11913
|
+
|
|
11914
|
+
|
|
11915
|
+
def validate_own_surface_is_skills_only_scenario() -> int:
|
|
11916
|
+
"""Issue #406: this repository carries the surface Keel now generates.
|
|
11917
|
+
|
|
11918
|
+
Keel's own checkout held `.claude/commands/opsx/*` beside the skills, from
|
|
11919
|
+
OpenSpec 1.6 under `delivery: both`.
|
|
11920
|
+
"""
|
|
11921
|
+
label = "own-surface-is-skills-only:"
|
|
11922
|
+
commands = ROOT / ".claude/commands/opsx"
|
|
11923
|
+
held = sorted(p.name for p in commands.glob("*")) if commands.is_dir() else []
|
|
11924
|
+
if held:
|
|
11925
|
+
report(f"{label} this repository still holds OpenSpec command files: {held!r}")
|
|
11926
|
+
return 1
|
|
11927
|
+
naming = [str(p.relative_to(ROOT)) for p in sorted((ROOT / ".claude/skills").glob("openspec-*/SKILL.md"))
|
|
11928
|
+
if "/opsx:" in p.read_text(encoding="utf-8")]
|
|
11929
|
+
if naming:
|
|
11930
|
+
report(f"{label} this repository's Claude skills still name `/opsx:` commands: {naming!r}")
|
|
11931
|
+
return 1
|
|
11932
|
+
doctor = run_keel(ROOT, "--doctor", "--target", "claude")
|
|
11933
|
+
lines = doctor.stdout.splitlines()
|
|
11934
|
+
commands_line = next((l for l in lines if l.startswith("OpenSpec commands:")), "")
|
|
11935
|
+
overlay_line = next((l for l in lines if l.startswith("Keel apply/archive/sync overlay:")), "")
|
|
11936
|
+
if not commands_line.startswith("OpenSpec commands: ok"):
|
|
11937
|
+
report(f"{label} doctor here does not read the commands line ok: {commands_line!r}")
|
|
11938
|
+
return 1
|
|
11939
|
+
if not overlay_line.startswith("Keel apply/archive/sync overlay: ok"):
|
|
11940
|
+
report(f"{label} doctor here does not read the overlay line ok: {overlay_line!r}")
|
|
11941
|
+
return 1
|
|
11942
|
+
if "own-surface-is-skills-only" not in {name for name, _ in SCENARIOS}:
|
|
11943
|
+
report(f"{label} scenario is not registered.")
|
|
11944
|
+
return 1
|
|
11945
|
+
report("own-surface-is-skills-only scenario passed.")
|
|
11946
|
+
return 0
|
|
11947
|
+
|
|
11948
|
+
|
|
11534
11949
|
def validate_openspec_surface_overlay_scenario() -> int:
|
|
11535
11950
|
with tempfile.TemporaryDirectory(prefix="keel-overlay-") as raw_tmp:
|
|
11536
11951
|
tmp = Path(raw_tmp)
|
|
@@ -11699,11 +12114,12 @@ def validate_openspec_surface_overlay_scenario() -> int:
|
|
|
11699
12114
|
report(f"openspec-surface-overlay scenario OpenCode overlay failed: {error}")
|
|
11700
12115
|
return 1
|
|
11701
12116
|
|
|
11702
|
-
|
|
12117
|
+
# The skill, since Keel generates no command file (#406).
|
|
12118
|
+
opencode_apply_skill = opencode_repo / ".opencode/skills/openspec-apply-change/SKILL.md"
|
|
11703
12119
|
write_text(
|
|
11704
|
-
|
|
12120
|
+
opencode_apply_skill,
|
|
11705
12121
|
strip_openspec_surface_overlay(
|
|
11706
|
-
|
|
12122
|
+
opencode_apply_skill.read_text(encoding="utf-8")
|
|
11707
12123
|
),
|
|
11708
12124
|
)
|
|
11709
12125
|
opencode_missing_doctor = run_keel(
|
|
@@ -27373,9 +27789,9 @@ def validate_authoring_alignment_overlay_scenario() -> int:
|
|
|
27373
27789
|
report("authoring-alignment-overlay Claude init failed:")
|
|
27374
27790
|
report((claude_init.stderr or claude_init.stdout).strip())
|
|
27375
27791
|
return 1
|
|
27792
|
+
# Skills only since #406: Keel generates no `.claude/commands/opsx/`.
|
|
27376
27793
|
claude_surfaces = (
|
|
27377
27794
|
claude_repo / ".claude/skills/openspec-propose/SKILL.md",
|
|
27378
|
-
claude_repo / ".claude/commands/opsx/propose.md",
|
|
27379
27795
|
)
|
|
27380
27796
|
for surface in claude_surfaces:
|
|
27381
27797
|
content = surface.read_text(encoding="utf-8")
|
|
@@ -29661,8 +30077,6 @@ def validate_delegation_overlay_scenario() -> int:
|
|
|
29661
30077
|
"""
|
|
29662
30078
|
|
|
29663
30079
|
generated = [
|
|
29664
|
-
ROOT / ".claude/commands/opsx/apply.md",
|
|
29665
|
-
ROOT / ".claude/commands/opsx/archive.md",
|
|
29666
30080
|
ROOT / ".claude/skills/openspec-apply-change/SKILL.md",
|
|
29667
30081
|
ROOT / ".claude/skills/openspec-archive-change/SKILL.md",
|
|
29668
30082
|
ROOT / ".codex/skills/openspec-apply-change/SKILL.md",
|
|
@@ -39730,8 +40144,6 @@ def validate_native_capabilities_unrestricted_scenario() -> int:
|
|
|
39730
40144
|
ROOT / "assets/openspec/schemas/keel-spec-driven/schema.yaml",
|
|
39731
40145
|
ROOT / "openspec/schemas/keel-spec-driven/schema.yaml",
|
|
39732
40146
|
]
|
|
39733
|
-
for action in ("apply", "archive", "sync", "propose"):
|
|
39734
|
-
surfaces.append(ROOT / f".claude/commands/opsx/{action}.md")
|
|
39735
40147
|
for name in ("apply-change", "archive-change", "sync-specs", "propose"):
|
|
39736
40148
|
surfaces.append(ROOT / f".claude/skills/openspec-{name}/SKILL.md")
|
|
39737
40149
|
surfaces.append(ROOT / f".codex/skills/openspec-{name}/SKILL.md")
|
|
@@ -39749,7 +40161,7 @@ def validate_native_capabilities_unrestricted_scenario() -> int:
|
|
|
39749
40161
|
for first_read in (
|
|
39750
40162
|
ROOT / "AGENTS.md",
|
|
39751
40163
|
ROOT / "assets/bootstrap/AGENTS.md",
|
|
39752
|
-
ROOT / ".claude/
|
|
40164
|
+
ROOT / ".claude/skills/openspec-apply-change/SKILL.md",
|
|
39753
40165
|
ROOT / ".codex/skills/openspec-apply-change/SKILL.md",
|
|
39754
40166
|
):
|
|
39755
40167
|
text = first_read.read_text(encoding="utf-8")
|
|
@@ -39813,8 +40225,6 @@ def validate_surfaces_agree_with_code_scenario() -> int:
|
|
|
39813
40225
|
return 1
|
|
39814
40226
|
|
|
39815
40227
|
overlays = []
|
|
39816
|
-
for action in ("apply", "archive", "sync"):
|
|
39817
|
-
overlays.append(ROOT / f".claude/commands/opsx/{action}.md")
|
|
39818
40228
|
for name in ("apply-change", "archive-change", "sync-specs"):
|
|
39819
40229
|
overlays.append(ROOT / f".claude/skills/openspec-{name}/SKILL.md")
|
|
39820
40230
|
overlays.append(ROOT / f".codex/skills/openspec-{name}/SKILL.md")
|
|
@@ -41901,6 +42311,9 @@ SCENARIOS: tuple = (
|
|
|
41901
42311
|
("version-alignment", validate_version_alignment_scenario),
|
|
41902
42312
|
("sync-surface-overlay", validate_sync_surface_overlay_scenario),
|
|
41903
42313
|
("openspec-surface-overlay", validate_openspec_surface_overlay_scenario),
|
|
42314
|
+
("openspec-skills-only", validate_openspec_skills_only_scenario),
|
|
42315
|
+
("guidance-names-openspec-skills", validate_guidance_names_openspec_skills_scenario),
|
|
42316
|
+
("own-surface-is-skills-only", validate_own_surface_is_skills_only_scenario),
|
|
41904
42317
|
("update-restores-overlays", validate_update_restores_overlays_scenario),
|
|
41905
42318
|
("uninstall", validate_uninstall_scenario),
|
|
41906
42319
|
(
|
|
@@ -42136,6 +42549,9 @@ SCENARIOS: tuple = (
|
|
|
42136
42549
|
("shift-self-wake", validate_shift_self_wake_scenario),
|
|
42137
42550
|
("shift-cli-self-shift", validate_shift_cli_self_shift_scenario),
|
|
42138
42551
|
("shift-cli-keeps-old-sessions", validate_shift_cli_keeps_old_sessions_scenario),
|
|
42552
|
+
("shift-cli-removes-after-exit", validate_shift_cli_removes_after_exit_scenario),
|
|
42553
|
+
("shift-cli-names-host-failure", validate_shift_cli_names_host_failure_scenario),
|
|
42554
|
+
("tick-retries-failed-wake", validate_tick_retries_failed_wake_scenario),
|
|
42139
42555
|
("owner-language", validate_owner_language_scenario),
|
|
42140
42556
|
("owner-language-after-tools", validate_owner_language_after_tools_scenario),
|
|
42141
42557
|
("shift-history", validate_shift_history_scenario),
|
|
@@ -42444,7 +42860,7 @@ def validate_archive_overlay_hygiene(errors: list[str]) -> None:
|
|
|
42444
42860
|
if "--skip-specs" not in cli:
|
|
42445
42861
|
errors.append(
|
|
42446
42862
|
"the archive overlay must direct archive to pass --skip-specs "
|
|
42447
|
-
"after
|
|
42863
|
+
"after the openspec-sync-specs skill has promoted the delta."
|
|
42448
42864
|
)
|
|
42449
42865
|
if "drop the change's guard manifest" not in cli:
|
|
42450
42866
|
errors.append(
|
package/src/core/chat/notice.js
CHANGED
|
@@ -238,6 +238,9 @@ function resumeCli(entry) {
|
|
|
238
238
|
cwd: entry.worktree || undefined, encoding: "utf8",
|
|
239
239
|
});
|
|
240
240
|
const output = `${result.stdout || ""}${result.stderr || ""}`.trim();
|
|
241
|
+
if (result.error && result.error.code === "ENOENT") {
|
|
242
|
+
return { ok: false, output: "claude was not found; put it on PATH or name it with KEEL_CLAUDE" };
|
|
243
|
+
}
|
|
241
244
|
return { ok: !result.error && result.status === 0, output: result.error ? result.error.message : output };
|
|
242
245
|
}
|
|
243
246
|
|
package/src/core/shift.js
CHANGED
|
@@ -513,14 +513,55 @@ function finished(row) {
|
|
|
513
513
|
return row.status === "idle";
|
|
514
514
|
}
|
|
515
515
|
|
|
516
|
-
|
|
517
|
-
|
|
516
|
+
// Every host call in the hand-over is bounded (#408 D2): a hung `claude` must
|
|
517
|
+
// not hold the waiter or the tick.
|
|
518
|
+
function hostTimeout() {
|
|
519
|
+
return envMs("KEEL_SHIFT_HOST_TIMEOUT_MS", 60 * 1000);
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
// Why a host call did not answer, in words the owner can act on.
|
|
523
|
+
function hostTrouble(result, what) {
|
|
524
|
+
if (result.error && result.error.code === "ENOENT") return "claude was not found; put it on PATH or name it with KEEL_CLAUDE";
|
|
525
|
+
if (result.error && result.error.code === "ETIMEDOUT") return `\`${what}\` timed out after ${hostTimeout() / 1000} s`;
|
|
526
|
+
if (result.error) return `\`${what}\` failed: ${result.error.message}`;
|
|
527
|
+
return `\`${what}\` printed no session list (exit ${result.status})`;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
function queryAgents(claude) {
|
|
531
|
+
const listed = spawnSync(claude, ["agents", "--json", "--all"], { encoding: "utf8", timeout: hostTimeout() });
|
|
518
532
|
try {
|
|
519
533
|
const parsed = JSON.parse(listed.stdout);
|
|
520
|
-
|
|
534
|
+
if (!listed.error && listed.status === 0 && Array.isArray(parsed)) return { rows: parsed, why: null };
|
|
521
535
|
} catch {
|
|
522
|
-
|
|
536
|
+
// not a list
|
|
523
537
|
}
|
|
538
|
+
return { rows: null, why: hostTrouble(listed, "claude agents --json --all") };
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
function listAgents(claude) {
|
|
542
|
+
return queryAgents(claude).rows;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
function processRunning(pid) {
|
|
546
|
+
if (!Number.isInteger(pid) || pid <= 1) return false;
|
|
547
|
+
try {
|
|
548
|
+
process.kill(pid, 0);
|
|
549
|
+
return true;
|
|
550
|
+
} catch (error) {
|
|
551
|
+
return error.code === "EPERM";
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
// `claude stop` returns before the process exits (#395; on 2.1.304 the row
|
|
556
|
+
// loses its status at 0.32 s, stop returns at 0.98 s, the process exits at
|
|
557
|
+
// about 3.2 s), so a removal waits for the process the note recorded.
|
|
558
|
+
function waitForExit(pid, limitMs) {
|
|
559
|
+
const deadline = Date.now() + limitMs;
|
|
560
|
+
while (processRunning(pid)) {
|
|
561
|
+
if (Date.now() >= deadline) return false;
|
|
562
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 100);
|
|
563
|
+
}
|
|
564
|
+
return true;
|
|
524
565
|
}
|
|
525
566
|
|
|
526
567
|
// Stop the old session; `claude stop` keeps its conversation. It is not resumed:
|
|
@@ -528,7 +569,7 @@ function listAgents(claude) {
|
|
|
528
569
|
// its claude.ai title back over a rename (#399 F1, F2). The new session carries
|
|
529
570
|
// a name of its own instead.
|
|
530
571
|
function retire(claude, entry, row) {
|
|
531
|
-
if (row.state !== "stopped") spawnSync(claude, ["stop", row.id || entry.session.slice(0, 8)], { encoding: "utf8" });
|
|
572
|
+
if (row.state !== "stopped") spawnSync(claude, ["stop", row.id || entry.session.slice(0, 8)], { encoding: "utf8", timeout: hostTimeout() });
|
|
532
573
|
}
|
|
533
574
|
|
|
534
575
|
// The new session's name: the role and its local start time (#399 D1), which
|
|
@@ -582,8 +623,14 @@ function removeOldSessions(claude, where, entry, keep) {
|
|
|
582
623
|
.sort((a, b) => (Number(b.row.startedAt) || 0) - (Number(a.row.startedAt) || 0));
|
|
583
624
|
const removed = [];
|
|
584
625
|
for (const { row, transcript } of old.slice(keep)) {
|
|
626
|
+
// Never a session whose process still runs (#408 D1): the one just handed
|
|
627
|
+
// over gets a bounded wait for the process its note recorded; any other
|
|
628
|
+
// still running is left for the next hand-over.
|
|
629
|
+
const handedOver = row.sessionId === entry.session;
|
|
630
|
+
const pid = Number(handedOver ? entry.pid : row.pid);
|
|
631
|
+
if (handedOver ? !waitForExit(pid, envMs("KEEL_SHIFT_EXIT_WAIT_MS", 15 * 1000)) : processRunning(pid)) continue;
|
|
585
632
|
if (transcript && !keptCopyOf(where, entry.role, transcript)) continue;
|
|
586
|
-
const gone = spawnSync(claude, ["rm", row.id || row.sessionId.slice(0, 8)], { encoding: "utf8" });
|
|
633
|
+
const gone = spawnSync(claude, ["rm", row.id || row.sessionId.slice(0, 8)], { encoding: "utf8", timeout: hostTimeout() });
|
|
587
634
|
if (!gone.error && gone.status === 0) removed.push(row.id || row.sessionId.slice(0, 8));
|
|
588
635
|
}
|
|
589
636
|
return removed;
|
|
@@ -624,15 +671,29 @@ function handOver(where, only = null) {
|
|
|
624
671
|
const claude = process.env.KEEL_CLAUDE || "claude";
|
|
625
672
|
const pending = handOffs(where).filter((entry) => entry.state === "pending" && (!only || entry.role === only));
|
|
626
673
|
if (!pending.length) return [];
|
|
627
|
-
const
|
|
628
|
-
|
|
629
|
-
|
|
674
|
+
const queried = queryAgents(claude);
|
|
675
|
+
const sessions = queried.rows;
|
|
676
|
+
// A listing that failed says nothing about the old session: wait for the next
|
|
677
|
+
// step, and say why on the entry, which status and the patrol show (#408 D2).
|
|
678
|
+
if (!sessions) {
|
|
679
|
+
for (const queuedEntry of pending) {
|
|
680
|
+
const entry = store.readJsonFile(queueFile(where, queuedEntry.role));
|
|
681
|
+
if (entry && entry.state === "pending" && entry.waiting_on !== queried.why) {
|
|
682
|
+
store.writeJsonAtomic(where, queueFile(where, entry.role), { ...entry, waiting_on: queried.why });
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
return [];
|
|
686
|
+
}
|
|
630
687
|
const done = [];
|
|
631
688
|
for (const queued of pending) {
|
|
632
689
|
const ran = withHandOverLock(where, queued.role, () => {
|
|
633
690
|
const entry = store.readJsonFile(queueFile(where, queued.role));
|
|
634
691
|
if (!entry || entry.state !== "pending") return null;
|
|
635
692
|
const row = sessions.find((item) => item && item.sessionId === entry.session);
|
|
693
|
+
if (entry.waiting_on) {
|
|
694
|
+
delete entry.waiting_on;
|
|
695
|
+
store.writeJsonAtomic(where, queueFile(where, entry.role), entry);
|
|
696
|
+
}
|
|
636
697
|
if (!finished(row)) return null;
|
|
637
698
|
// `stop`, `attach` and `logs` take the 8-character job id, not the full
|
|
638
699
|
// session id (`No job matching`, measured 2026-10-19).
|
|
@@ -641,7 +702,7 @@ function handOver(where, only = null) {
|
|
|
641
702
|
const mode = declared.permissionMode;
|
|
642
703
|
const name = sessionName(entry.role);
|
|
643
704
|
const started = spawnSync(claude, ["--bg", "-n", name, "--permission-mode", mode, SHIFT_START_TEXT(entry.role)], {
|
|
644
|
-
cwd: entry.worktree, encoding: "utf8",
|
|
705
|
+
cwd: entry.worktree, encoding: "utf8", timeout: hostTimeout(),
|
|
645
706
|
});
|
|
646
707
|
const output = `${started.stdout || ""}`;
|
|
647
708
|
if (!started.error && started.status === 0) {
|
|
@@ -650,7 +711,7 @@ function handOver(where, only = null) {
|
|
|
650
711
|
entry.removed = removeOldSessions(claude, where, entry, declared.keepOldSessions);
|
|
651
712
|
if (declared.message) entry.notice = declared.message;
|
|
652
713
|
} else {
|
|
653
|
-
const reason = started.error ? started
|
|
714
|
+
const reason = started.error ? hostTrouble(started, "claude --bg") : String(started.stderr || output).trim().split(/\r?\n/).pop();
|
|
654
715
|
Object.assign(entry, { state: "failed", failed_at: store.isoLocal(new Date()), error: reason || `exited ${started.status}` });
|
|
655
716
|
}
|
|
656
717
|
store.writeJsonAtomic(where, queueFile(where, entry.role), entry);
|
|
@@ -689,7 +750,8 @@ function waitForHandOver(where, role) {
|
|
|
689
750
|
function describeHandOff(entry) {
|
|
690
751
|
const tail = entry.state === "delivered"
|
|
691
752
|
? `delivered ${entry.delivered_at} as session ${entry.new_session || "(id not printed)"}${entry.new_name ? ` "${entry.new_name}"` : ""}`
|
|
692
|
-
: entry.state === "failed" ? `failed ${entry.failed_at}: ${entry.error}`
|
|
753
|
+
: entry.state === "failed" ? `failed ${entry.failed_at}: ${entry.error}`
|
|
754
|
+
: entry.waiting_on ? `pending: cannot ask the host — ${entry.waiting_on}` : "pending: waits for the session to go idle";
|
|
693
755
|
// An entry from before #399 recorded whether the old session's rename showed.
|
|
694
756
|
const renamed = entry.state === "delivered" && "renamed" in entry ? (entry.renamed ? `; old session renamed "${entry.renamed}"` : "; rename not shown") : "";
|
|
695
757
|
const removed = (entry.removed || []).length ? `; older sessions removed from \`claude agents\` (transcripts kept by Keel): ${entry.removed.join(", ")}` : "";
|
|
@@ -705,7 +767,8 @@ function describeHandOff(entry) {
|
|
|
705
767
|
function handOffRisks(where, now = Date.now()) {
|
|
706
768
|
return handOffs(where).filter((entry) => entry.state === "failed"
|
|
707
769
|
|| (entry.state === "pending" && now - Date.parse(entry.requested_at) > 15 * 60 * 1000))
|
|
708
|
-
.map((entry) => `${entry.role}'s CLI hand-off ${entry.state}${entry.error ? `: ${entry.error}` : ` since ${entry.requested_at}`}
|
|
770
|
+
.map((entry) => `${entry.role}'s CLI hand-off ${entry.state}${entry.error ? `: ${entry.error}` : ` since ${entry.requested_at}`}`
|
|
771
|
+
+ `${entry.waiting_on ? ` (${entry.waiting_on})` : ""}; see \`keel shift status\``);
|
|
709
772
|
}
|
|
710
773
|
|
|
711
774
|
// --- the one-shot wake (#293) -------------------------------------------------------
|
package/src/core/tick.js
CHANGED
|
@@ -57,7 +57,12 @@ function wakeEnded(where, state) {
|
|
|
57
57
|
const newest = waiting[waiting.length - 1];
|
|
58
58
|
if (!newest || (state.woken[role] && state.woken[role] >= newest)) continue;
|
|
59
59
|
const resumed = notice.resumeCli(entry);
|
|
60
|
-
|
|
60
|
+
// Marked woken only once it worked, the session is gone, or three tries
|
|
61
|
+
// failed for this record (#408 D3); a newer record starts the count again.
|
|
62
|
+
const before = (state.wake_attempts || {})[role];
|
|
63
|
+
const count = before && before.record === newest ? before.count + 1 : 1;
|
|
64
|
+
state.wake_attempts = { ...(state.wake_attempts || {}), [role]: { record: newest, count } };
|
|
65
|
+
if (resumed.ok || resumed.removed || count >= 3) state.woken[role] = newest;
|
|
61
66
|
woken.push({ role, session: entry.session, record: newest, ok: resumed.ok, output: resumed.output });
|
|
62
67
|
}
|
|
63
68
|
return woken;
|
|
@@ -68,7 +73,9 @@ function tick(where, now = new Date()) {
|
|
|
68
73
|
const wakeState = readState(where);
|
|
69
74
|
result.woken = wakeEnded(where, wakeState);
|
|
70
75
|
result.handedOver = require("./shift").handOver(where);
|
|
71
|
-
if (result.woken.length)
|
|
76
|
+
if (result.woken.length) {
|
|
77
|
+
store.writeJsonAtomic(where, stateFile(where), { ...readState(where), woken: wakeState.woken, wake_attempts: wakeState.wake_attempts });
|
|
78
|
+
}
|
|
72
79
|
const found = patrolWorktree(where);
|
|
73
80
|
if (!found.worktree) {
|
|
74
81
|
result.patrol = { ran: false, why: found.why };
|