@christang/keel 5.193.0 → 5.194.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.193.0",
3
+ "version": "5.194.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.193.0 -->
1
+ <!-- keel:start version=5.194.0 -->
2
2
  ## Keel Bootstrap
3
3
 
4
4
  - Start every session with `keel context`; OpenSpec artifacts and Git are the durable authority, and memory or transcripts may only inform.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@christang/keel",
3
- "version": "5.193.0",
3
+ "version": "5.194.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@christang/keel",
9
- "version": "5.193.0",
9
+ "version": "5.194.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.193.0",
5
+ "version": "5.194.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.193.0",
3
+ "version": "5.194.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.193.0",
3
+ "version": "5.194.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",
@@ -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.193.0"
38
+ PACKAGE_VERSION = "5.194.0"
39
39
 
40
40
 
41
- PROTOCOL_VERSION = "5.193.0"
41
+ PROTOCOL_VERSION = "5.194.0"
42
42
 
43
43
 
44
44
  LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
@@ -425,6 +425,7 @@ SCENARIOS: tuple = (
425
425
  ("shift-history", shift.validate_shift_history_scenario),
426
426
  ("shift-history-show", shift.validate_shift_history_show_scenario),
427
427
  ("shift-resume-checks-commits", shift.validate_shift_resume_checks_commits_scenario),
428
+ ("shift-resume-skips-session-ids", shift.validate_shift_resume_skips_session_ids_scenario),
428
429
  ("shift-keeps-transcripts", shift.validate_shift_keeps_transcripts_scenario),
429
430
  ("shift-keeps-found-transcripts", shift.validate_shift_keeps_found_transcripts_scenario),
430
431
  ("role-drift", shift.validate_role_drift_scenario),
@@ -1526,6 +1526,60 @@ def validate_worktree_overview_scenario() -> int:
1526
1526
  return 0
1527
1527
 
1528
1528
 
1529
+ def validate_shift_resume_skips_session_ids_scenario() -> int:
1530
+ """Issue #445: a shift note's session ids are not read as commits.
1531
+
1532
+ The `CLI session:` header Keel writes, and a recorded session id quoted
1533
+ in prose, are not listed; a landed commit and an unknown hex token still
1534
+ are. An empty session slot leaves no blank line in the header.
1535
+ """
1536
+ label = "shift-resume-skips-session-ids:"
1537
+ with tempfile.TemporaryDirectory(prefix="keel-shift-445-") as raw:
1538
+ base = Path(raw)
1539
+ rtl, verify, env, _ = shift_scratch(base)
1540
+ own = "b5a55cf2-5e84-4193-902b-22012e35eb8e"
1541
+ other = "a166c34f-93e5-441e-b277-fe1e0bda647d"
1542
+ chat_session_start(rtl, env, other, os.getpid())
1543
+
1544
+ def git(*args: str) -> str:
1545
+ return subprocess.run(["git", *args], cwd=rtl, text=True, capture_output=True, check=True).stdout.strip()
1546
+
1547
+ git("commit", "-q", "--allow-empty", "-m", "landed")
1548
+ git("push", "-q", "origin", "HEAD")
1549
+ landed = git("rev-parse", "HEAD")
1550
+ default = git("rev-parse", "--abbrev-ref", "HEAD")
1551
+ note = f"{landed[:8]} landed. deadbee1 was the old base. Session {other[:8]} ran the probe."
1552
+ cli = {**env, "CLAUDE_CODE_ENTRYPOINT": "cli", "CLAUDE_CODE_SESSION_ID": own, "CLAUDE_PID": str(os.getpid())}
1553
+ readied = run_keel(verify, "shift", "ready", note, env=cli)
1554
+ if readied.returncode != 0:
1555
+ report(f"{label} ready failed: {readied.stdout} {readied.stderr}")
1556
+ return 1
1557
+ resumed = run_keel(verify, "shift", "resume", env=env)
1558
+ listed = [line for line in resumed.stdout.splitlines() if line.startswith("- ")]
1559
+
1560
+ def line_for(token: str) -> str:
1561
+ return next((line for line in listed if line.startswith(f"- {token}")), "")
1562
+
1563
+ if f"already in origin/{default}" not in line_for(landed[:8]):
1564
+ report(f"{label} the landed commit is not marked already in origin/{default}: {listed!r}")
1565
+ return 1
1566
+ if "not found" not in line_for("deadbee1"):
1567
+ report(f"{label} an unknown hex token is no longer reported not found: {listed!r}")
1568
+ return 1
1569
+ for name, session in (("the header's CLI session", own), ("a recorded session", other)):
1570
+ if line_for(session[:8]):
1571
+ report(f"{label} {name} id {session[:8]} is listed as a commit: {line_for(session[:8])!r}")
1572
+ return 1
1573
+ if f"CLI session: {own}." not in resumed.stdout:
1574
+ report(f"{label} the note header lost its CLI session line: {resumed.stdout!r}")
1575
+ return 1
1576
+ if "\n\n\n" in resumed.stdout.split(note)[0]:
1577
+ report(f"{label} the note header holds blank lines for empty slots: {resumed.stdout.split(note)[0]!r}")
1578
+ return 1
1579
+ report("shift-resume-skips-session-ids scenario passed.")
1580
+ return 0
1581
+
1582
+
1529
1583
  def validate_shift_resume_checks_commits_scenario() -> int:
1530
1584
  """Issue #347: a shift note's commit ids go stale before the next shift reads it.
1531
1585
 
package/src/core/shift.js CHANGED
@@ -451,6 +451,7 @@ function ready(where, options) {
451
451
  const desktop = desktopSession();
452
452
  const pid = desktop ? desktopProcess() : null;
453
453
  const cli = desktop ? null : cliSession();
454
+ // An empty slot is dropped rather than left as a blank line (#445 D3).
454
455
  const head = [
455
456
  `# Shift note: ${role || path.basename(where.worktree)}`,
456
457
  "",
@@ -463,8 +464,7 @@ function ready(where, options) {
463
464
  options.wake ? "Self-initiated: this shift armed `keel shift ready --wake`." : "",
464
465
  !role ? `Started by hand: ${options.forceReason}.` : "",
465
466
  options.forceReason && result.items.length ? `\nLeft as is (${options.forceReason}):\n${result.items.map((item) => `- ${item.kind}: ${item.detail}`).join("\n")}` : "",
466
- "",
467
- ].join("\n");
467
+ ].filter((line, index) => index < 2 || line !== "").concat("").join("\n");
468
468
  const note = ownNotePath(where, role);
469
469
  writeFileAtomic(note, `${head}\n${text}\n`);
470
470
  // Requests are chat records; without a role there is none to close (D2).
@@ -964,7 +964,8 @@ function resumeRole(where, named) {
964
964
  // `ready` and `resume` (#347). Each is marked against the remote-tracking refs
965
965
  // as they are: Keel fetches nothing, and says when they were last fetched.
966
966
  const NOTE_PAIR = /([A-Za-z0-9][\w./-]*)\s*@\s*([0-9a-f]{7,40})\b/g;
967
- const NOTE_SHA = /(?<![\w@/-])([0-9a-f]{7,40})\b/g;
967
+ // The first segment of a UUID — a session id — is not a commit (#445 D1).
968
+ const NOTE_SHA = /(?<![\w@/-])([0-9a-f]{7,40})\b(?!-[0-9a-f]{4}-)/g;
968
969
  const looksLikeSha = (token) => /[a-f]/.test(token) && /\d/.test(token);
969
970
 
970
971
  function remoteDefault(cwd) {
@@ -976,7 +977,23 @@ function remoteDefault(cwd) {
976
977
  return null;
977
978
  }
978
979
 
979
- function noteCommits(cwd, text) {
980
+ // Session ids Keel records or keeps a transcript of (#445 D2).
981
+ function knownSessionIds(where) {
982
+ const ids = new Set();
983
+ const names = (dir) => {
984
+ try {
985
+ return fs.readdirSync(dir);
986
+ } catch {
987
+ return [];
988
+ }
989
+ };
990
+ for (const file of names(path.join(where.root, "sessions"))) ids.add(file.split(".")[0]);
991
+ const kept = path.join(where.root, "shift", "transcripts");
992
+ for (const role of names(kept)) for (const file of names(path.join(kept, role))) ids.add(file.split(".")[0]);
993
+ return [...ids].filter((id) => /^[0-9a-f]{8}-/.test(id));
994
+ }
995
+
996
+ function noteCommits(cwd, text, sessions = []) {
980
997
  const seen = new Set();
981
998
  const named = [];
982
999
  // After `@` the pair already says it is a commit, so an all-digit sha counts
@@ -988,7 +1005,9 @@ function noteCommits(cwd, text) {
988
1005
  for (const match of String(text).matchAll(NOTE_SHA)) {
989
1006
  if (seen.has(match.index)) continue;
990
1007
  // A bare token needs a letter and a digit, or, when it is all digits, to
991
- // resolve to a commit, so a date does not count.
1008
+ // resolve to a commit, so a date does not count; one that begins a session
1009
+ // id Keel records is that session (#445 D2).
1010
+ if (sessions.some((id) => id.startsWith(match[1]))) continue;
992
1011
  const allDigits = /^\d+$/.test(match[1]);
993
1012
  if (allDigits ? !git(cwd, ["rev-parse", "--verify", "--quiet", `${match[1]}^{commit}`]).ok : !looksLikeSha(match[1])) continue;
994
1013
  named.push({ index: match.index, branch: null, sha: match[1], token: match[1] });
@@ -1033,7 +1052,7 @@ function resume(where, named = null) {
1033
1052
  const history = path.join(shiftDir(where), "history", `${role || path.basename(note, ".md")}-${stamp}.md`);
1034
1053
  fs.mkdirSync(path.dirname(history), { recursive: true });
1035
1054
  fs.renameSync(note, history);
1036
- if (!role) return { role: null, note: history, text, told: null, commits: noteCommits(where.worktree, text), fetched: lastFetch(where.worktree) };
1055
+ if (!role) return { role: null, note: history, text, told: null, commits: noteCommits(where.worktree, text, knownSessionIds(where)), fetched: lastFetch(where.worktree) };
1037
1056
  // The cold-start message has done its work once the note is read.
1038
1057
  for (const record of store.unread(where, role)) {
1039
1058
  if (isShift(record)) store.advanceCursor(where, role, record.group, record.id);
@@ -1047,7 +1066,7 @@ function resume(where, named = null) {
1047
1066
  ? store.post(where, { group, text, refs: [REF] })
1048
1067
  : store.writeRecord(where, { group, kind: "message", from: role, refs: [REF], text })).id;
1049
1068
  }
1050
- return { role, note: history, text, told, waiting: role ? unstarted(where, role) : [], commits: noteCommits(where.worktree, text), fetched: lastFetch(where.worktree) };
1069
+ return { role, note: history, text, told, waiting: role ? unstarted(where, role) : [], commits: noteCommits(where.worktree, text, knownSessionIds(where)), fetched: lastFetch(where.worktree) };
1051
1070
  }
1052
1071
 
1053
1072
  function status(where) {