@christang/keel 5.164.0 → 5.166.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/validate_plugin.py +62 -14
- package/src/core/shift.js +21 -7
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.166.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.166.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.166.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.166.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.166.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",
|
|
@@ -49,8 +49,8 @@ REQUIRED_SCRIPTS = [
|
|
|
49
49
|
"scripts/validate_plugin.py",
|
|
50
50
|
]
|
|
51
51
|
|
|
52
|
-
PACKAGE_VERSION = "5.
|
|
53
|
-
PROTOCOL_VERSION = "5.
|
|
52
|
+
PACKAGE_VERSION = "5.166.0"
|
|
53
|
+
PROTOCOL_VERSION = "5.166.0"
|
|
54
54
|
LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
|
|
55
55
|
OPENSPEC_SCHEMA_NAME = "keel-spec-driven"
|
|
56
56
|
# Mirrors KEEL_PACKAGE_NAME in scripts/install_to_repo.py, one of the two
|
|
@@ -8241,8 +8241,8 @@ def validate_shift_cli_self_shift_scenario() -> int:
|
|
|
8241
8241
|
retires it (stop, rename by resuming it with `/rename`, stop) and starts a
|
|
8242
8242
|
new session in the role's worktree that runs `keel shift resume`. `keel
|
|
8243
8243
|
tick` carries out a queued hand-off too, and the two start one session. A
|
|
8244
|
-
session that is busy, or blocked on a question
|
|
8245
|
-
|
|
8244
|
+
session that is busy, or waiting for input (blocked on a question), is left
|
|
8245
|
+
alone; its job state is not read (#393). `keel shift status` shows the queue, and a
|
|
8246
8246
|
failed start is a patrol risk.
|
|
8247
8247
|
"""
|
|
8248
8248
|
label = "shift-cli-self-shift:"
|
|
@@ -8251,20 +8251,35 @@ def validate_shift_cli_self_shift_scenario() -> int:
|
|
|
8251
8251
|
base = Path(raw)
|
|
8252
8252
|
rtl, verify, env, _ = shift_scratch(base)
|
|
8253
8253
|
calls, agents, fail, norename = base / "claude-calls.jsonl", base / "agents.json", base / "fail-start", base / "no-rename"
|
|
8254
|
+
stoplag = base / "stop-lag"
|
|
8254
8255
|
fake = base / "fake-claude"
|
|
8255
8256
|
# The fake answers with the shapes measured on Claude Code 2.1.303: a live row has `status` and `state`; a stopped one has `state: stopped` and no `status`.
|
|
8257
|
+
# `stop` returns before the process exits (#395): with `stop-lag` holding n, the row stops n listings later, never with `never`;
|
|
8258
|
+
# and a resume of a session still running starts a copy that takes the name, as measured.
|
|
8256
8259
|
write_text(fake, "#!/usr/bin/env python3\nimport json, os, sys\n"
|
|
8257
|
-
f"agents, fail, norename = {str(agents)!r}, {str(fail)!r}, {str(norename)!r}\n"
|
|
8260
|
+
f"agents, fail, norename, stoplag = {str(agents)!r}, {str(fail)!r}, {str(norename)!r}, {str(stoplag)!r}\n"
|
|
8258
8261
|
f"open({str(calls)!r}, 'a').write(json.dumps({{'argv': sys.argv[1:], 'cwd': os.getcwd(), 'claude_env': sorted(k for k in os.environ if k.startswith('CLAUDE'))}}) + '\\n')\n"
|
|
8259
8262
|
"argv = sys.argv[1:]\n"
|
|
8260
|
-
"if argv[:2] == ['agents', '--json']:\n print(open(agents).read()); sys.exit(0)\n"
|
|
8261
8263
|
"rows = json.loads(open(agents).read())\n"
|
|
8264
|
+
"if argv[:2] == ['agents', '--json']:\n"
|
|
8265
|
+
" for row in rows:\n if '_stop_in' in row:\n row['_stop_in'] -= 1\n"
|
|
8266
|
+
" if row['_stop_in'] <= 0:\n row.pop('_stop_in'); row.pop('status', None); row['state'] = 'stopped'\n"
|
|
8267
|
+
" open(agents, 'w').write(json.dumps(rows)); print(json.dumps(rows)); sys.exit(0)\n"
|
|
8262
8268
|
"if argv[:1] == ['stop']:\n"
|
|
8263
|
-
"
|
|
8269
|
+
" lag = open(stoplag).read().strip() if os.path.exists(stoplag) else '0'\n"
|
|
8270
|
+
" for row in rows:\n if row['id'] == argv[1] and 'status' in row:\n"
|
|
8271
|
+
" if lag == '0':\n row.pop('status', None); row['state'] = 'stopped'\n"
|
|
8272
|
+
" else:\n row['_stop_in'] = 10 ** 9 if lag == 'never' else int(lag)\n"
|
|
8264
8273
|
" open(agents, 'w').write(json.dumps(rows)); print('stopped ' + argv[1]); sys.exit(0)\n"
|
|
8265
8274
|
"if argv[:2] == ['--bg', '--resume']:\n"
|
|
8266
|
-
"
|
|
8267
|
-
"
|
|
8275
|
+
" name = argv[3].split(None, 1)[1]\n"
|
|
8276
|
+
" running = [row for row in rows if row['sessionId'] == argv[2] and 'status' in row]\n"
|
|
8277
|
+
" if running:\n"
|
|
8278
|
+
" rows.append({**running[0], 'sessionId': 'c0c0c0c0-0000-0000-0000-000000000000', 'id': 'c0c0c0c0', 'name': name, 'status': 'idle'})\n"
|
|
8279
|
+
" rows[-1].pop('_stop_in', None)\n"
|
|
8280
|
+
" print('note: session ' + argv[2][:8] + ' is already running in the background, so this started a copy as c0c0c0c0.')\n"
|
|
8281
|
+
" for row in rows:\n if row['sessionId'] == argv[2] and not running and not os.path.exists(norename):\n row['name'] = name\n"
|
|
8282
|
+
" open(agents, 'w').write(json.dumps(rows)); print('backgrounded · ' + (rows[-1]['id'] if running else argv[2][:8])); sys.exit(0)\n"
|
|
8268
8283
|
"if argv[:1] == ['--bg'] and os.path.exists(fail):\n print('Workspace not trusted.', file=sys.stderr); sys.exit(1)\n"
|
|
8269
8284
|
"if argv[:1] == ['--bg']:\n print('backgrounded · newsess1 · verify'); sys.exit(0)\n"
|
|
8270
8285
|
"print('stopped')\n")
|
|
@@ -8280,6 +8295,8 @@ def validate_shift_cli_self_shift_scenario() -> int:
|
|
|
8280
8295
|
row = {"kind": "background", "name": name, "sessionId": OLD, "id": OLD[:8], "pid": os.getpid(), "state": state, "cwd": str(verify)}
|
|
8281
8296
|
if status:
|
|
8282
8297
|
row["status"] = status
|
|
8298
|
+
if status == "waiting":
|
|
8299
|
+
row["waitingFor"] = "input needed"
|
|
8283
8300
|
agents.write_text(json.dumps([row]))
|
|
8284
8301
|
|
|
8285
8302
|
def rows() -> list[dict]:
|
|
@@ -8321,7 +8338,7 @@ def validate_shift_cli_self_shift_scenario() -> int:
|
|
|
8321
8338
|
report(f"{label} the note does not record the CLI session.")
|
|
8322
8339
|
return 1
|
|
8323
8340
|
|
|
8324
|
-
# A busy session, and one blocked on a question, are left alone.
|
|
8341
|
+
# A busy session, and one blocked on a question (measured: status waiting, state blocked), are left alone.
|
|
8325
8342
|
time.sleep(1.0)
|
|
8326
8343
|
if acted():
|
|
8327
8344
|
report(f"{label} the hand-over acted while the old session was busy: {acted()!r}")
|
|
@@ -8329,17 +8346,27 @@ def validate_shift_cli_self_shift_scenario() -> int:
|
|
|
8329
8346
|
if "pending" not in status_text():
|
|
8330
8347
|
report(f"{label} shift status does not show the pending hand-off: {status_text()!r}")
|
|
8331
8348
|
return 1
|
|
8332
|
-
agents_row("
|
|
8349
|
+
agents_row("waiting", "blocked")
|
|
8333
8350
|
time.sleep(1.0)
|
|
8334
8351
|
if acted():
|
|
8335
|
-
report(f"{label} the hand-over cut off a session blocked on a question (
|
|
8352
|
+
report(f"{label} the hand-over cut off a session blocked on a question (status waiting): {acted()!r}")
|
|
8336
8353
|
return 1
|
|
8337
8354
|
|
|
8338
|
-
# Finished:
|
|
8339
|
-
|
|
8355
|
+
# Finished: idle, though its state still labels its last message `working` (#393, keel-maint's
|
|
8356
|
+
# ended turn). The waiter retires it and starts the next, with no tick.
|
|
8357
|
+
agents_row("idle", "working")
|
|
8358
|
+
write_text(stoplag, "2")
|
|
8340
8359
|
if not wait_for(lambda: len(starts()) >= 1):
|
|
8341
8360
|
report(f"{label} the waiter did not hand over without a tick: {acted()!r}")
|
|
8342
8361
|
return 1
|
|
8362
|
+
listed = json.loads(agents.read_text())
|
|
8363
|
+
if any(row["sessionId"] != OLD for row in listed):
|
|
8364
|
+
report(f"{label} the rename resumed a session that was still running, starting a copy: {listed!r}")
|
|
8365
|
+
return 1
|
|
8366
|
+
if not re.match(r"^verify · shifted ", listed[0]["name"]):
|
|
8367
|
+
report(f"{label} the old session did not take the shifted name: {listed!r}")
|
|
8368
|
+
return 1
|
|
8369
|
+
stoplag.unlink()
|
|
8343
8370
|
order = acted()
|
|
8344
8371
|
shifted = re.compile(r"^/rename verify · shifted \d{4}-\d{2}-\d{2} \d{2}:\d{2}$")
|
|
8345
8372
|
if (order[0] != ["stop", OLD[:8]] or order[1][:3] != ["--bg", "--resume", OLD] or len(order[1]) != 4
|
|
@@ -8405,6 +8432,27 @@ def validate_shift_cli_self_shift_scenario() -> int:
|
|
|
8405
8432
|
return 1
|
|
8406
8433
|
norename.unlink()
|
|
8407
8434
|
|
|
8435
|
+
# A session that never shows as stopped is not resumed for its rename (#395), and the new session still starts.
|
|
8436
|
+
calls.write_text("")
|
|
8437
|
+
agents_row("idle", "done")
|
|
8438
|
+
write_text(stoplag, "never")
|
|
8439
|
+
run_keel(verify, "shift", "ready", "--wake", "next: rerun R016", env={**cli_env, "KEEL_SHIFT_HANDOVER_TIMEOUT_MS": "1"})
|
|
8440
|
+
ticked = run_keel(verify, "tick", "--repo", str(rtl), env={**tick_only, "KEEL_SHIFT_STOP_WAIT_MS": "1000"})
|
|
8441
|
+
text = status_text()
|
|
8442
|
+
if any(argv[:2] == ["--bg", "--resume"] for argv in acted()):
|
|
8443
|
+
report(f"{label} a session that never stopped was resumed for its rename: {acted()!r}")
|
|
8444
|
+
return 1
|
|
8445
|
+
if len(starts()) != 1:
|
|
8446
|
+
report(f"{label} a session that never stopped kept the new session from starting: {acted()!r} {ticked.stderr!r}")
|
|
8447
|
+
return 1
|
|
8448
|
+
if "delivered" not in text:
|
|
8449
|
+
report(f"{label} a session that never stopped kept the hand-off from being delivered: {text!r}")
|
|
8450
|
+
return 1
|
|
8451
|
+
if "rename not shown" not in text:
|
|
8452
|
+
report(f"{label} shift status does not say a session that never stopped was not renamed: {text!r}")
|
|
8453
|
+
return 1
|
|
8454
|
+
stoplag.unlink()
|
|
8455
|
+
|
|
8408
8456
|
# A start that fails stays visible and is a patrol risk.
|
|
8409
8457
|
calls.write_text("")
|
|
8410
8458
|
agents_row("idle", "done")
|
package/src/core/shift.js
CHANGED
|
@@ -503,13 +503,13 @@ function handOffs(where) {
|
|
|
503
503
|
|
|
504
504
|
const SHIFT_START_TEXT = (role) => `${role}: your new shift starts now. Run keel context, then keel shift resume.`;
|
|
505
505
|
|
|
506
|
-
// The old session has finished when it is gone,
|
|
507
|
-
//
|
|
508
|
-
//
|
|
506
|
+
// The old session has finished when it is gone, stopped (no status), or idle.
|
|
507
|
+
// `busy` and `waiting` (blocked on a question to the owner, measured) wait, and
|
|
508
|
+
// so does anything unknown. The job `state` labels the last message, not the
|
|
509
|
+
// turn: an ended turn that described pending work stayed `working` (#393).
|
|
509
510
|
function finished(row) {
|
|
510
|
-
if (!row) return true;
|
|
511
|
-
|
|
512
|
-
return !row.state || ["done", "idle", "stopped"].includes(row.state);
|
|
511
|
+
if (!row || !row.status) return true;
|
|
512
|
+
return row.status === "idle";
|
|
513
513
|
}
|
|
514
514
|
|
|
515
515
|
function listAgents(claude) {
|
|
@@ -525,14 +525,28 @@ function listAgents(claude) {
|
|
|
525
525
|
// Stop the old session, give it a name that says it shifted, stop it again. The
|
|
526
526
|
// rename is a resume with `/rename` and no other flag, which keeps the session id
|
|
527
527
|
// and shows in `claude agents` (measured 2026-10-19); it is best effort (#388 D4).
|
|
528
|
+
// `claude stop` returns before the process exits, and a resume of a session still
|
|
529
|
+
// running starts a copy of it (#395), so the resume waits for the stop to show.
|
|
528
530
|
function retire(claude, entry, row) {
|
|
529
531
|
const id = row.id || entry.session.slice(0, 8);
|
|
532
|
+
const pause = new Int32Array(new SharedArrayBuffer(4));
|
|
530
533
|
if (row.state !== "stopped") spawnSync(claude, ["stop", id], { encoding: "utf8" });
|
|
534
|
+
const stopBy = Date.now() + envMs("KEEL_SHIFT_STOP_WAIT_MS", 30000);
|
|
535
|
+
for (;;) {
|
|
536
|
+
// A listing that failed says nothing about the session: keep waiting.
|
|
537
|
+
const listed = listAgents(claude);
|
|
538
|
+
const now = listed && listed.find((item) => item && item.sessionId === entry.session);
|
|
539
|
+
if (listed && (!now || !now.status)) break;
|
|
540
|
+
if (Date.now() >= stopBy) {
|
|
541
|
+
spawnSync(claude, ["stop", id], { encoding: "utf8" });
|
|
542
|
+
return null;
|
|
543
|
+
}
|
|
544
|
+
Atomics.wait(pause, 0, 0, 500);
|
|
545
|
+
}
|
|
531
546
|
const stamp = store.isoLocal(new Date()).slice(0, 16).replace("T", " ");
|
|
532
547
|
const name = `${entry.role} · shifted ${stamp}`;
|
|
533
548
|
spawnSync(claude, ["--bg", "--resume", entry.session, `/rename ${name}`], { encoding: "utf8", cwd: row.cwd || entry.worktree });
|
|
534
549
|
const deadline = Date.now() + envMs("KEEL_SHIFT_RENAME_WAIT_MS", 30000);
|
|
535
|
-
const pause = new Int32Array(new SharedArrayBuffer(4));
|
|
536
550
|
let shown = false;
|
|
537
551
|
for (;;) {
|
|
538
552
|
const now = (listAgents(claude) || []).find((item) => item && item.sessionId === entry.session);
|