@christang/keel 5.200.0 → 5.201.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/assets/bootstrap/AGENTS.md +1 -1
- 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/validation/chat.py +77 -0
- package/scripts/validation/common.py +2 -2
- package/scripts/validation/registry.py +1 -0
- package/src/core/chat/cli.js +2 -1
- package/src/core/chat/notice.js +50 -9
- package/src/core/patrol.js +2 -0
- package/src/core/shift.js +5 -2
- package/src/core/tick.js +5 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.201.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/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@christang/keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.201.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.201.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.201.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.201.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",
|
|
@@ -510,6 +510,83 @@ def validate_chat_wake_skips_removed_session_scenario() -> int:
|
|
|
510
510
|
return 0
|
|
511
511
|
|
|
512
512
|
|
|
513
|
+
def validate_chat_wake_moved_worktree_scenario() -> int:
|
|
514
|
+
"""Issue #465: a session whose directory is gone is explained, not resumed.
|
|
515
|
+
|
|
516
|
+
After the workspace rename on 2026-10-25, presence and `claude agents` both
|
|
517
|
+
recorded each role's session under the old path. `claude --bg --resume`
|
|
518
|
+
printed `Workspace not trusted … could not be resolved on disk` and started
|
|
519
|
+
nothing. `wake now` now names the vanished directory and prints the fork
|
|
520
|
+
command to copy; the tick does not retry it; patrol and shift status list it.
|
|
521
|
+
"""
|
|
522
|
+
label = "chat-wake-moved-worktree:"
|
|
523
|
+
with tempfile.TemporaryDirectory(prefix="keel-wake-465-") as raw:
|
|
524
|
+
base = Path(raw)
|
|
525
|
+
rtl, verify, env, _ = shift_scratch(base)
|
|
526
|
+
gone = str(base / "renamed-away" / "verify")
|
|
527
|
+
calls = base / "claude-calls.jsonl"
|
|
528
|
+
fake = base / "fake-claude"
|
|
529
|
+
write_text(fake, "#!/usr/bin/env python3\nimport json, sys\n"
|
|
530
|
+
f"open({str(calls)!r}, 'a').write(json.dumps(sys.argv[1:]) + '\\n')\n"
|
|
531
|
+
"if sys.argv[1:3] == ['agents', '--json']:\n"
|
|
532
|
+
f" print(json.dumps([{{'kind': 'background', 'sessionId': 'sess-verify-1', 'id': 'sess-ver', 'cwd': {gone!r}}}]))\n"
|
|
533
|
+
"else:\n print('backgrounded · fake')\n")
|
|
534
|
+
fake.chmod(0o755)
|
|
535
|
+
env = {**env, "KEEL_CLAUDE": str(fake)}
|
|
536
|
+
dead = subprocess.Popen(["true"])
|
|
537
|
+
dead.wait()
|
|
538
|
+
chat_session_start(verify, env, "sess-verify-1", dead.pid)
|
|
539
|
+
presence_file = mailbox_common_dir(rtl) / "keel-chat" / "presence" / "verify.json"
|
|
540
|
+
presence = json.loads(presence_file.read_text(encoding="utf-8"))
|
|
541
|
+
presence["cli_worktree"] = gone
|
|
542
|
+
presence_file.write_text(json.dumps(presence), encoding="utf-8")
|
|
543
|
+
|
|
544
|
+
def resumes() -> list[list[str]]:
|
|
545
|
+
made = [json.loads(line) for line in calls.read_text().splitlines()] if calls.exists() else []
|
|
546
|
+
return [call for call in made if call[:1] == ["--bg"]]
|
|
547
|
+
|
|
548
|
+
woke = run_keel(rtl, "chat", "wake", "now", "verify", env=env)
|
|
549
|
+
said = woke.stdout + woke.stderr
|
|
550
|
+
if resumes():
|
|
551
|
+
report(f"{label} wake now resumed a session whose directory is gone: {resumes()!r}")
|
|
552
|
+
return 1
|
|
553
|
+
if woke.returncode == 0:
|
|
554
|
+
report(f"{label} wake now exits 0 for a session it could not resume: {said!r}")
|
|
555
|
+
return 1
|
|
556
|
+
if gone not in said:
|
|
557
|
+
report(f"{label} wake now does not name the directory that no longer exists: {said!r}")
|
|
558
|
+
return 1
|
|
559
|
+
if not any(f"cd {where} && claude --bg --fork-session --resume sess-verify-1" in said for where in (verify, os.path.realpath(verify))):
|
|
560
|
+
report(f"{label} wake now does not print the fork command for verify's worktree: {said!r}")
|
|
561
|
+
return 1
|
|
562
|
+
|
|
563
|
+
run_keel(rtl, "chat", "dm", "verify", "rerun R012", env=env)
|
|
564
|
+
run_keel(verify, "tick", "--repo", str(rtl), env=env)
|
|
565
|
+
if resumes():
|
|
566
|
+
report(f"{label} keel tick resumed a session whose directory is gone: {resumes()!r}")
|
|
567
|
+
return 1
|
|
568
|
+
risks = [line for line in run_keel(rtl, "patrol", env=env).stdout.splitlines() if "verify" in line and "no longer exists" in line]
|
|
569
|
+
if not risks:
|
|
570
|
+
report(f"{label} the patrol reports no risk for verify's session whose directory is gone.")
|
|
571
|
+
return 1
|
|
572
|
+
if "keel chat wake now verify" not in risks[0]:
|
|
573
|
+
report(f"{label} the patrol's risk does not name `keel chat wake now verify`: {risks[0]!r}")
|
|
574
|
+
return 1
|
|
575
|
+
status = run_keel(rtl, "shift", "status", env=env).stdout
|
|
576
|
+
listed = status.split("Sessions that cannot be resumed:", 1)
|
|
577
|
+
if len(listed) != 2:
|
|
578
|
+
report(f"{label} keel shift status has no `Sessions that cannot be resumed:` section: {status!r}")
|
|
579
|
+
return 1
|
|
580
|
+
if "verify" not in listed[1]:
|
|
581
|
+
report(f"{label} keel shift status does not list verify under `Sessions that cannot be resumed:`: {status!r}")
|
|
582
|
+
return 1
|
|
583
|
+
if label.rstrip(":") not in {name for name, _ in registry.SCENARIOS}:
|
|
584
|
+
report(f"{label} the scenario registry does not include it.")
|
|
585
|
+
return 1
|
|
586
|
+
report(f"{label.rstrip(':')} scenario passed.")
|
|
587
|
+
return 0
|
|
588
|
+
|
|
589
|
+
|
|
513
590
|
def validate_chat_wake_now_cli_scenario() -> int:
|
|
514
591
|
"""Issue #348 on the CLI (owner's CLI waker, 2026-10-19): one step wakes a role.
|
|
515
592
|
|
|
@@ -35,10 +35,10 @@ os.environ["KEEL_UPDATE_CLAUDE"] = str(Path(tempfile.gettempdir()) / "keel-suite
|
|
|
35
35
|
os.environ["KEEL_UPDATE_CODEX"] = str(Path(tempfile.gettempdir()) / "keel-suite-has-no-codex")
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
PACKAGE_VERSION = "5.
|
|
38
|
+
PACKAGE_VERSION = "5.201.0"
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
PROTOCOL_VERSION = "5.
|
|
41
|
+
PROTOCOL_VERSION = "5.201.0"
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
|
|
@@ -459,6 +459,7 @@ SCENARIOS: tuple = (
|
|
|
459
459
|
("chat-visitor-not-recorded", chat.validate_chat_visitor_not_recorded_scenario),
|
|
460
460
|
("chat-role-set-records-session", chat.validate_chat_role_set_records_session_scenario),
|
|
461
461
|
("chat-wake-skips-removed-session", chat.validate_chat_wake_skips_removed_session_scenario),
|
|
462
|
+
("chat-wake-moved-worktree", chat.validate_chat_wake_moved_worktree_scenario),
|
|
462
463
|
("chat-ack", chat.validate_chat_ack_scenario),
|
|
463
464
|
("coordinator-patrol", shift.validate_coordinator_patrol_scenario),
|
|
464
465
|
("patrol-since-last", shift.validate_patrol_since_last_scenario),
|
package/src/core/chat/cli.js
CHANGED
|
@@ -706,8 +706,9 @@ function runWake(cwd, options) {
|
|
|
706
706
|
out(`${role}'s CLI session ${presence.cli_session} is running; a record addressed to it wakes it, so nothing was resumed.`);
|
|
707
707
|
return 0;
|
|
708
708
|
}
|
|
709
|
-
const resumed = notice.resumeCli(entry);
|
|
709
|
+
const resumed = notice.resumeCli(entry, where);
|
|
710
710
|
if (resumed.removed) throw new ChatError(`${role}'s recorded CLI ${resumed.output}.`);
|
|
711
|
+
if (resumed.moved) throw new ChatError(`${role}'s recorded CLI ${resumed.output}`);
|
|
711
712
|
out(`${resumed.ok ? "Resumed" : "Could not resume"} ${role}'s CLI session ${entry.session} in ${entry.worktree}.${resumed.output ? `\n${resumed.output}` : ""}`);
|
|
712
713
|
return resumed.ok ? 0 : 1;
|
|
713
714
|
}
|
package/src/core/chat/notice.js
CHANGED
|
@@ -211,9 +211,25 @@ function wakeStep(session, text) {
|
|
|
211
211
|
// The prompt an ended CLI session resumes with: a pointer, never the work.
|
|
212
212
|
const CLI_WAKE_PROMPT = "You have unread keel chat records; run keel context, then keel chat unread.";
|
|
213
213
|
|
|
214
|
+
// The command that continues a session whose directory is gone in the role's
|
|
215
|
+
// worktree (#465 D1). Keel prints it and never runs it (D3): a fork is a new
|
|
216
|
+
// session with a new id, not a resume of the recorded one.
|
|
217
|
+
function forkCommand(where, entry) {
|
|
218
|
+
const bound = where
|
|
219
|
+
? Object.entries(store.readJsonFile(path.join(where.root, "roles.json")))
|
|
220
|
+
.filter(([worktree, name]) => name === entry.role && fs.existsSync(worktree)).map(([worktree]) => worktree)
|
|
221
|
+
: [];
|
|
222
|
+
const target = bound.length === 1 ? bound[0] : "<the role's worktree>";
|
|
223
|
+
const mode = bound.length === 1 ? require("../config").readShiftDeclaration(target).permissionMode : "auto";
|
|
224
|
+
const name = `${entry.role} · ${store.isoLocal(new Date()).slice(5, 16).replace("T", " ")}`;
|
|
225
|
+
const command = `cd ${target} && claude --bg --fork-session --resume ${entry.session} -n ${JSON.stringify(name)} --permission-mode ${mode} ${JSON.stringify(CLI_WAKE_PROMPT)}`;
|
|
226
|
+
return bound.length > 1 ? `${command}\n(the role is bound to ${bound.join(", ")}: use the one it works in)` : command;
|
|
227
|
+
}
|
|
228
|
+
|
|
214
229
|
// Resumes a role's recorded CLI session (#348 D3). Only `--bg --resume <id>`
|
|
215
|
-
// and the prompt: any other flag starts a copy with a new session id.
|
|
216
|
-
|
|
230
|
+
// and the prompt: any other flag starts a copy with a new session id. A
|
|
231
|
+
// session whose directory no longer exists resumes nothing (#465).
|
|
232
|
+
function resumeCli(entry, where = null) {
|
|
217
233
|
const claude = process.env.KEEL_CLAUDE || "claude";
|
|
218
234
|
// A session `claude rm` removed is gone for good (#415 D4): when the host's
|
|
219
235
|
// list can be read and lacks it, nothing is resumed. An unreadable list
|
|
@@ -221,19 +237,33 @@ function resumeCli(entry) {
|
|
|
221
237
|
const listed = require("child_process").spawnSync(claude, ["agents", "--json", "--all"], {
|
|
222
238
|
encoding: "utf8", timeout: 30 * 1000,
|
|
223
239
|
});
|
|
240
|
+
let row = null;
|
|
224
241
|
try {
|
|
225
242
|
const rows = JSON.parse(listed.stdout);
|
|
226
|
-
if (!listed.error && listed.status === 0 && Array.isArray(rows)
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
243
|
+
if (!listed.error && listed.status === 0 && Array.isArray(rows)) {
|
|
244
|
+
row = rows.find((found) => found && found.sessionId === entry.session) || null;
|
|
245
|
+
if (!row) {
|
|
246
|
+
return {
|
|
247
|
+
ok: false,
|
|
248
|
+
removed: true,
|
|
249
|
+
output: `session ${entry.session} was removed: \`claude agents\` no longer lists it, so a new session must be started for the role in ${entry.worktree || "its worktree"}`,
|
|
250
|
+
};
|
|
251
|
+
}
|
|
233
252
|
}
|
|
234
253
|
} catch {
|
|
235
254
|
// Not a list: fall through and resume.
|
|
236
255
|
}
|
|
256
|
+
// The host resumes a session only in the directory it registered, so one
|
|
257
|
+
// whose directory was renamed or removed cannot start (#465 F3).
|
|
258
|
+
const ran = (row && row.cwd) || entry.worktree;
|
|
259
|
+
if (ran && !fs.existsSync(ran)) {
|
|
260
|
+
return {
|
|
261
|
+
ok: false,
|
|
262
|
+
moved: true,
|
|
263
|
+
output: `session ${entry.session} ran in ${ran}, which no longer exists, and Claude Code resumes a session only in the directory it ran in. `
|
|
264
|
+
+ `To continue its conversation as a new session in the role's worktree, run:\n${forkCommand(where, entry)}`,
|
|
265
|
+
};
|
|
266
|
+
}
|
|
237
267
|
const result = require("child_process").spawnSync(claude, ["--bg", "--resume", entry.session, CLI_WAKE_PROMPT], {
|
|
238
268
|
cwd: entry.worktree || undefined, encoding: "utf8",
|
|
239
269
|
});
|
|
@@ -244,6 +274,16 @@ function resumeCli(entry) {
|
|
|
244
274
|
return { ok: !result.error && result.status === 0, output: result.error ? result.error.message : output };
|
|
245
275
|
}
|
|
246
276
|
|
|
277
|
+
// Covered roles whose ended CLI session ran in a worktree that no longer
|
|
278
|
+
// exists (#465 D4). Presence only: the patrol asks the host nothing.
|
|
279
|
+
function movedSessionRisks(where, covers = () => true) {
|
|
280
|
+
const roles = [...new Set(Object.values(store.readJsonFile(path.join(where.root, "roles.json"))).filter(Boolean))].sort();
|
|
281
|
+
return roles.filter(covers).map((role) => asleep(where, role))
|
|
282
|
+
.filter((entry) => entry && entry.cli && entry.worktree && !fs.existsSync(entry.worktree))
|
|
283
|
+
.map((entry) => `${entry.role}'s CLI session ${entry.session} ran in ${entry.worktree}, which no longer exists, so it cannot be resumed; `
|
|
284
|
+
+ `\`keel chat wake now ${entry.role}\` prints the command that continues it in the role's worktree`);
|
|
285
|
+
}
|
|
286
|
+
|
|
247
287
|
// --- parked roles (#316) ------------------------------------------------------------
|
|
248
288
|
|
|
249
289
|
function parkFile(where, role) {
|
|
@@ -729,6 +769,7 @@ module.exports = {
|
|
|
729
769
|
unpark,
|
|
730
770
|
wakeStep,
|
|
731
771
|
resumeCli,
|
|
772
|
+
movedSessionRisks,
|
|
732
773
|
twinWarning,
|
|
733
774
|
check,
|
|
734
775
|
bridgeLine,
|
package/src/core/patrol.js
CHANGED
|
@@ -559,6 +559,8 @@ function runPatrol(argv) {
|
|
|
559
559
|
if (quota) result.risks.push(quota);
|
|
560
560
|
// A CLI hand-off that failed or hangs (#357 D4), of the roles this patrol covers.
|
|
561
561
|
result.risks.push(...require("./shift").handOffRisks(where, Date.now(), (name) => name === role || options.coverage.covers(name)));
|
|
562
|
+
// An ended CLI session whose worktree is gone cannot be woken (#465 D4).
|
|
563
|
+
result.risks.push(...require("./chat/notice").movedSessionRisks(where, (name) => name === role || options.coverage.covers(name)));
|
|
562
564
|
// Near the limit nudges stop, since each wakes a large session (D3).
|
|
563
565
|
const quiet = options.quota !== null && options.quota >= options.quotaQuietAt;
|
|
564
566
|
if (options.nudge && quiet) result.paused = `nudges paused: quota at ${options.quota}%`;
|
package/src/core/shift.js
CHANGED
|
@@ -1605,9 +1605,12 @@ function runShift(argv) {
|
|
|
1605
1605
|
case "status": {
|
|
1606
1606
|
const rows = status(where);
|
|
1607
1607
|
const queue = handOffs(where);
|
|
1608
|
+
// Roles whose ended CLI session ran in a worktree that is gone (#465 D4).
|
|
1609
|
+
const unresumable = require("./chat/notice").movedSessionRisks(where);
|
|
1608
1610
|
const text = [rows.length ? rows.map(describe).join("\n") : "No shift change recorded.",
|
|
1609
|
-
...(queue.length ? ["", "Hand-offs (CLI, run by `keel tick`):", ...queue.map(describeHandOff)] : [])
|
|
1610
|
-
|
|
1611
|
+
...(queue.length ? ["", "Hand-offs (CLI, run by `keel tick`):", ...queue.map(describeHandOff)] : []),
|
|
1612
|
+
...(unresumable.length ? ["", "Sessions that cannot be resumed:", ...unresumable.map((line) => `- ${line}`)] : [])].join("\n");
|
|
1613
|
+
out({ roles: rows, handOffs: queue, unresumable }, text);
|
|
1611
1614
|
return 0;
|
|
1612
1615
|
}
|
|
1613
1616
|
default:
|
package/src/core/tick.js
CHANGED
|
@@ -96,13 +96,14 @@ function wakeEnded(where, state) {
|
|
|
96
96
|
const waiting = store.unread(where, role).filter((record) => store.wakes(record, role)).map((record) => record.id).sort();
|
|
97
97
|
const newest = waiting[waiting.length - 1];
|
|
98
98
|
if (!newest || (state.woken[role] && state.woken[role] >= newest)) continue;
|
|
99
|
-
const resumed = notice.resumeCli(entry);
|
|
100
|
-
// Marked woken only once it worked, the session
|
|
101
|
-
// failed for this record (#408 D3); a newer
|
|
99
|
+
const resumed = notice.resumeCli(entry, where);
|
|
100
|
+
// Marked woken only once it worked, the session or its directory is gone
|
|
101
|
+
// (#465 D2), or three tries failed for this record (#408 D3); a newer
|
|
102
|
+
// record starts the count again.
|
|
102
103
|
const before = (state.wake_attempts || {})[role];
|
|
103
104
|
const count = before && before.record === newest ? before.count + 1 : 1;
|
|
104
105
|
state.wake_attempts = { ...(state.wake_attempts || {}), [role]: { record: newest, count } };
|
|
105
|
-
if (resumed.ok || resumed.removed || count >= 3) state.woken[role] = newest;
|
|
106
|
+
if (resumed.ok || resumed.removed || resumed.moved || count >= 3) state.woken[role] = newest;
|
|
106
107
|
woken.push({ role, session: entry.session, record: newest, ok: resumed.ok, output: resumed.output });
|
|
107
108
|
}
|
|
108
109
|
return woken;
|