@christang/keel 5.167.0 → 5.168.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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keel",
3
- "version": "5.167.0",
3
+ "version": "5.168.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,4 +1,4 @@
1
- <!-- keel:start version=5.167.0 -->
1
+ <!-- keel:start version=5.168.0 -->
2
2
  ## Keel Bootstrap
3
3
 
4
4
  - Start every session with `keel context`; OpenSpec artifacts and Git are the only durable authority — never native memory, goals, or transcripts.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@christang/keel",
3
- "version": "5.167.0",
3
+ "version": "5.168.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@christang/keel",
9
- "version": "5.167.0",
9
+ "version": "5.168.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@fission-ai/openspec": "^1.4.1"
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@christang/keel",
3
3
  "displayName": "Keel",
4
4
  "description": "Keel OpenSpec execution discipline CLI for Claude Code, Codex, and OpenCode.",
5
- "version": "5.167.0",
5
+ "version": "5.168.0",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keel",
3
- "version": "5.167.0",
3
+ "version": "5.168.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.167.0",
3
+ "version": "5.168.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",
@@ -51,8 +51,8 @@ REQUIRED_SCRIPTS = [
51
51
  "scripts/validate_plugin.py",
52
52
  ]
53
53
 
54
- PACKAGE_VERSION = "5.167.0"
55
- PROTOCOL_VERSION = "5.167.0"
54
+ PACKAGE_VERSION = "5.168.0"
55
+ PROTOCOL_VERSION = "5.168.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
@@ -8370,29 +8370,24 @@ def validate_shift_cli_self_shift_scenario() -> int:
8370
8370
  return 1
8371
8371
 
8372
8372
  # Finished: idle, though its state still labels its last message `working` (#393, keel-maint's
8373
- # ended turn). The waiter retires it and starts the next, with no tick.
8374
- write_text(stoplag, "late")
8373
+ # ended turn). The waiter stops it and starts the next, named for its start, with no tick (#399).
8375
8374
  agents_row("idle", "working")
8376
8375
  if not wait_for(lambda: len(starts()) >= 1):
8377
8376
  report(f"{label} the waiter did not hand over without a tick: {acted()!r}")
8378
8377
  return 1
8379
- listed = json.loads(agents.read_text())
8380
- if any(row["sessionId"] != OLD for row in listed):
8381
- report(f"{label} the rename resumed a session that was still running, starting a copy: {listed!r}")
8378
+ order = acted()
8379
+ if any(argv[:2] == ["--bg", "--resume"] for argv in order):
8380
+ report(f"{label} the hand-over woke the old session to rename it: {order!r}")
8382
8381
  return 1
8383
- if not re.match(r"^verify · shifted ", listed[0]["name"]):
8384
- report(f"{label} the old session did not take the shifted name: {listed!r}")
8382
+ if order[:1] != [["stop", OLD[:8]]] or len(order) != 2:
8383
+ report(f"{label} the old session was not retired as one stop before the new start: {order!r}")
8385
8384
  return 1
8386
- stoplag.unlink()
8387
- order = acted()
8388
- shifted = re.compile(r"^/rename verify · shifted \d{4}-\d{2}-\d{2} \d{2}:\d{2}$")
8389
- if (order[0] != ["stop", OLD[:8]] or order[1][:3] != ["--bg", "--resume", OLD] or len(order[1]) != 4
8390
- or not shifted.match(order[1][3]) or order[2] != ["stop", OLD[:8]] or order[3][:5] != ["--bg", "-n", "verify", "--permission-mode", "auto"]
8391
- or len(order) != 4):
8392
- report(f"{label} the old session was not retired as stop, rename-by-resume, stop, then the new start: {order!r}")
8385
+ named = re.compile(r"^verify · \d{2}-\d{2} \d{2}:\d{2}$")
8386
+ if order[1][:2] != ["--bg", "-n"] or not named.match(order[1][2]) or order[1][3:5] != ["--permission-mode", "auto"]:
8387
+ report(f"{label} the new session is not started as `verify · <MM-DD HH:MM>`: {order[1]!r}")
8393
8388
  return 1
8394
- if "keel shift resume" not in order[3][-1] or "--resume" in order[3]:
8395
- report(f"{label} the new session does not start fresh with a keel shift resume prompt: {order[3]!r}")
8389
+ if "keel shift resume" not in order[1][-1] or "--resume" in order[1]:
8390
+ report(f"{label} the new session does not start fresh with a keel shift resume prompt: {order[1]!r}")
8396
8391
  return 1
8397
8392
  if os.path.realpath(starts()[0]["cwd"]) != os.path.realpath(verify):
8398
8393
  report(f"{label} the new session started in {starts()[0]['cwd']}, not verify's worktree.")
@@ -8402,12 +8397,12 @@ def validate_shift_cli_self_shift_scenario() -> int:
8402
8397
  report(f"{label} a claude the hand-over ran inherited the old session's {leaked[0]['claude_env']!r}.")
8403
8398
  return 1
8404
8399
  text = status_text()
8405
- for needle in ("delivered", "newsess1", f"claude attach {OLD[:8]}", "shifted"):
8400
+ for needle in ("delivered", "newsess1", f"claude attach {OLD[:8]}", order[1][2]):
8406
8401
  if needle not in text:
8407
8402
  report(f"{label} shift status does not show {needle!r} for the delivered hand-off: {text!r}")
8408
8403
  return 1
8409
8404
  tick()
8410
- if len(starts()) != 1 or len(acted()) != 4:
8405
+ if len(starts()) != 1 or len(acted()) != 2:
8411
8406
  report(f"{label} a tick after the hand-over acted again: {acted()!r}")
8412
8407
  return 1
8413
8408
 
@@ -8431,45 +8426,6 @@ def validate_shift_cli_self_shift_scenario() -> int:
8431
8426
  report(f"{label} a second tick started another session.")
8432
8427
  return 1
8433
8428
 
8434
- # A rename that never shows is recorded, and the new session still starts.
8435
- calls.write_text("")
8436
- agents_row("idle", "done")
8437
- write_text(norename, "x")
8438
- run_keel(verify, "shift", "ready", "--wake", "next: rerun R015", env={**cli_env, "KEEL_SHIFT_HANDOVER_TIMEOUT_MS": "1"})
8439
- ticked = tick()
8440
- text = status_text()
8441
- if len(starts()) != 1:
8442
- report(f"{label} a rename that did not show stopped the new session from starting: {acted()!r} {ticked.stderr!r}")
8443
- return 1
8444
- if "delivered" not in text:
8445
- report(f"{label} a rename that did not show kept the hand-off from being delivered: {text!r}")
8446
- return 1
8447
- if "rename not shown" not in text:
8448
- report(f"{label} shift status does not say the rename did not show: {text!r}")
8449
- return 1
8450
- norename.unlink()
8451
-
8452
- # A session that never shows as stopped is not resumed for its rename (#395), and the new session still starts.
8453
- calls.write_text("")
8454
- agents_row("idle", "done")
8455
- write_text(stoplag, "never")
8456
- run_keel(verify, "shift", "ready", "--wake", "next: rerun R016", env={**cli_env, "KEEL_SHIFT_HANDOVER_TIMEOUT_MS": "1"})
8457
- ticked = run_keel(verify, "tick", "--repo", str(rtl), env={**tick_only, "KEEL_SHIFT_STOP_WAIT_MS": "1000"})
8458
- text = status_text()
8459
- if any(argv[:2] == ["--bg", "--resume"] for argv in acted()):
8460
- report(f"{label} a session that never stopped was resumed for its rename: {acted()!r}")
8461
- return 1
8462
- if len(starts()) != 1:
8463
- report(f"{label} a session that never stopped kept the new session from starting: {acted()!r} {ticked.stderr!r}")
8464
- return 1
8465
- if "delivered" not in text:
8466
- report(f"{label} a session that never stopped kept the hand-off from being delivered: {text!r}")
8467
- return 1
8468
- if "rename not shown" not in text:
8469
- report(f"{label} shift status does not say a session that never stopped was not renamed: {text!r}")
8470
- return 1
8471
- stoplag.unlink()
8472
-
8473
8429
  # A start that fails stays visible and is a patrol risk.
8474
8430
  calls.write_text("")
8475
8431
  agents_row("idle", "done")
package/src/core/shift.js CHANGED
@@ -523,43 +523,18 @@ function listAgents(claude) {
523
523
  }
524
524
  }
525
525
 
526
- // Stop the old session, give it a name that says it shifted, stop it again. The
527
- // rename is a resume with `/rename` and no other flag, which keeps the session id
528
- // and shows in `claude agents` (measured 2026-10-19); it is best effort (#388 D4).
529
- // `claude stop` returns before the process exits, and a resume of a session still
530
- // running starts a copy of it (#395). The row loses its status before the process
531
- // exits too (0.83 s against 2.68 s, measured), so the resume waits for the process
532
- // the row showed before the stop (#397 D1); a row with no pid was already stopped.
526
+ // Stop the old session; `claude stop` keeps its conversation. It is not resumed:
527
+ // renaming it took a resume, and a session running with Remote Control writes
528
+ // its claude.ai title back over a rename (#399 F1, F2). The new session carries
529
+ // a name of its own instead.
533
530
  function retire(claude, entry, row) {
534
- const id = row.id || entry.session.slice(0, 8);
535
- const pause = new Int32Array(new SharedArrayBuffer(4));
536
- const pid = Number.isInteger(row.pid) && row.pid > 1 ? row.pid : null;
537
- if (row.state !== "stopped") spawnSync(claude, ["stop", id], { encoding: "utf8" });
538
- const stopBy = Date.now() + envMs("KEEL_SHIFT_STOP_WAIT_MS", 30000);
539
- for (;;) {
540
- // A listing that failed says nothing about the session: keep waiting.
541
- const listed = pid ? null : listAgents(claude);
542
- const now = listed && listed.find((item) => item && item.sessionId === entry.session);
543
- if (pid ? !alive(pid) : listed && (!now || !now.status)) break;
544
- if (Date.now() >= stopBy) {
545
- spawnSync(claude, ["stop", id], { encoding: "utf8" });
546
- return null;
547
- }
548
- Atomics.wait(pause, 0, 0, 500);
549
- }
550
- const stamp = store.isoLocal(new Date()).slice(0, 16).replace("T", " ");
551
- const name = `${entry.role} · shifted ${stamp}`;
552
- spawnSync(claude, ["--bg", "--resume", entry.session, `/rename ${name}`], { encoding: "utf8", cwd: row.cwd || entry.worktree });
553
- const deadline = Date.now() + envMs("KEEL_SHIFT_RENAME_WAIT_MS", 30000);
554
- let shown = false;
555
- for (;;) {
556
- const now = (listAgents(claude) || []).find((item) => item && item.sessionId === entry.session);
557
- shown = Boolean(now && now.name === name);
558
- if (shown || Date.now() >= deadline) break;
559
- Atomics.wait(pause, 0, 0, 500);
560
- }
561
- spawnSync(claude, ["stop", id], { encoding: "utf8" });
562
- return shown ? name : null;
531
+ if (row.state !== "stopped") spawnSync(claude, ["stop", row.id || entry.session.slice(0, 8)], { encoding: "utf8" });
532
+ }
533
+
534
+ // The new session's name: the role and its local start time (#399 D1), which
535
+ // reaches claude.ai at creation, so each shift has a name of its own.
536
+ function sessionName(role, now = new Date()) {
537
+ return `${role} · ${store.isoLocal(now).slice(5, 16).replace("T", " ")}`;
563
538
  }
564
539
 
565
540
  // The host's transcript of a session in `cwd`, under either spelling of the path.
@@ -656,16 +631,17 @@ function handOver(where, only = null) {
656
631
  if (!finished(row)) return null;
657
632
  // `stop`, `attach` and `logs` take the 8-character job id, not the full
658
633
  // session id (`No job matching`, measured 2026-10-19).
659
- if (row) entry.renamed = retire(claude, entry, row);
634
+ if (row) retire(claude, entry, row);
660
635
  const declared = readShiftDeclaration(entry.worktree);
661
636
  const mode = declared.permissionMode;
662
- const started = spawnSync(claude, ["--bg", "-n", entry.role, "--permission-mode", mode, SHIFT_START_TEXT(entry.role)], {
637
+ const name = sessionName(entry.role);
638
+ const started = spawnSync(claude, ["--bg", "-n", name, "--permission-mode", mode, SHIFT_START_TEXT(entry.role)], {
663
639
  cwd: entry.worktree, encoding: "utf8",
664
640
  });
665
641
  const output = `${started.stdout || ""}`;
666
642
  if (!started.error && started.status === 0) {
667
643
  const id = (output.match(/backgrounded\s*·\s*(\S+)/) || [])[1] || null;
668
- Object.assign(entry, { state: "delivered", delivered_at: store.isoLocal(new Date()), new_session: id });
644
+ Object.assign(entry, { state: "delivered", delivered_at: store.isoLocal(new Date()), new_session: id, new_name: name });
669
645
  entry.removed = removeOldSessions(claude, where, entry, declared.keepOldSessions);
670
646
  if (declared.message) entry.notice = declared.message;
671
647
  } else {
@@ -707,9 +683,10 @@ function waitForHandOver(where, role) {
707
683
 
708
684
  function describeHandOff(entry) {
709
685
  const tail = entry.state === "delivered"
710
- ? `delivered ${entry.delivered_at} as session ${entry.new_session || "(id not printed)"}`
686
+ ? `delivered ${entry.delivered_at} as session ${entry.new_session || "(id not printed)"}${entry.new_name ? ` "${entry.new_name}"` : ""}`
711
687
  : entry.state === "failed" ? `failed ${entry.failed_at}: ${entry.error}` : "pending: waits for the session to go idle";
712
- const renamed = entry.state === "delivered" ? (entry.renamed ? `; old session renamed "${entry.renamed}"` : "; rename not shown") : "";
688
+ // An entry from before #399 recorded whether the old session's rename showed.
689
+ const renamed = entry.state === "delivered" && "renamed" in entry ? (entry.renamed ? `; old session renamed "${entry.renamed}"` : "; rename not shown") : "";
713
690
  const removed = (entry.removed || []).length ? `; older sessions removed from \`claude agents\` (transcripts kept by Keel): ${entry.removed.join(", ")}` : "";
714
691
  const notice = entry.notice ? `; ${entry.notice}` : "";
715
692
  const own = entry.session.slice(0, 8);
@@ -1223,8 +1200,8 @@ const CLEAR_HINT = [
1223
1200
  function clearHint(result) {
1224
1201
  if (result.queued) {
1225
1202
  return "This is a Claude Code CLI session, which cannot clear itself (#357). End your turn now: once this session has finished, "
1226
- + `a waiter stops it and renames it — its conversation is kept, \`claude attach ${result.cli.session.slice(0, 8)}\` reopens it — and starts a new session `
1227
- + `in ${result.worktree} that runs \`keel shift resume\`; \`keel tick\` does the same if the waiter is gone. \`keel shift status\` shows the hand-off.`;
1203
+ + `a waiter stops it — its conversation is kept, \`claude attach ${result.cli.session.slice(0, 8)}\` reopens it — and starts a new session `
1204
+ + `named for its start, \`${result.role} · <MM-DD HH:MM>\`, in ${result.worktree} that runs \`keel shift resume\`; \`keel tick\` does the same if the waiter is gone. \`keel shift status\` shows the hand-off.`;
1228
1205
  }
1229
1206
  let last;
1230
1207
  if (!result.role) last = `Without a chat role nothing wakes the new session; ${result.startedBy} — tell it to run \`keel shift resume\`.`;