@christang/keel 5.168.0 → 5.169.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.168.0",
3
+ "version": "5.169.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.168.0 -->
1
+ <!-- keel:start version=5.169.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.168.0",
3
+ "version": "5.169.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@christang/keel",
9
- "version": "5.168.0",
9
+ "version": "5.169.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.168.0",
5
+ "version": "5.169.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.168.0",
3
+ "version": "5.169.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.168.0",
3
+ "version": "5.169.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.168.0"
55
- PROTOCOL_VERSION = "5.168.0"
54
+ PACKAGE_VERSION = "5.169.0"
55
+ PROTOCOL_VERSION = "5.169.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
@@ -8454,8 +8454,9 @@ def validate_shift_cli_keeps_old_sessions_scenario() -> int:
8454
8454
  After a delivered hand-over, the newest `shift: keep_old_sessions:`
8455
8455
  (default 3) stopped background sessions in the role's bound worktrees stay
8456
8456
  listed; each older one is removed with `claude rm` once Keel's store holds
8457
- a copy of its transcript. One whose transcript is nowhere stays, and so do
8458
- another role's sessions and the new one.
8457
+ a copy of its transcript. Only a session with a transcript, the host's or
8458
+ Keel's copy, counts (#401): one whose transcript is nowhere takes no slot and
8459
+ stays, and so do another role's sessions and the new one.
8459
8460
  """
8460
8461
  label = "shift-cli-keeps-old-sessions:"
8461
8462
  OLD = "5b14fbae-b6aa-40b6-a72a-b3f89d2c6eea"
@@ -8529,22 +8530,28 @@ def validate_shift_cli_keeps_old_sessions_scenario() -> int:
8529
8530
  def removed() -> list[dict]:
8530
8531
  return [json.loads(line) for line in calls.read_text().splitlines() if json.loads(line)["argv"][:1] == ["rm"]]
8531
8532
 
8532
- olds = [old_row(1, bound["verify"]), old_row(2, bound["verify"]), old_row(3, bound["verify"], with_transcript=False),
8533
- old_row(4, bound["verify"]), old_row(5, bound["rtl"])]
8533
+ # #401: a session never given a prompt has no transcript and is not a shift, so it takes no kept slot even
8534
+ # when it is newer than the others; one whose host transcript is gone but Keel holds a copy still counts.
8535
+ copy_only = old_row(1, bound["verify"], with_transcript=False)
8536
+ kept_dir.mkdir(parents=True, exist_ok=True)
8537
+ (kept_dir / f"{copy_only['sessionId']}.jsonl.gz").write_bytes(gzip.compress(b'{"type": "user"}\n'))
8538
+ olds = [copy_only, old_row(2, bound["verify"]), old_row(3, bound["verify"]), old_row(4, bound["verify"]),
8539
+ old_row(6, bound["verify"], with_transcript=False), old_row(5, bound["rtl"])]
8534
8540
  setup("2", olds)
8535
8541
  gone = removed()
8536
8542
  if not gone:
8537
8543
  report(f"{label} the hand-over removed no old session: {calls.read_text()!r}")
8538
8544
  return 1
8539
8545
  ids = sorted(r["argv"][1] for r in gone)
8540
- if ids != ["01010101", "02020202"]:
8541
- report(f"{label} with keep_old_sessions 2 the removed sessions are {ids!r}, not the two oldest with a transcript.")
8546
+ if ids != ["01010101", "02020202", "03030303"]:
8547
+ report(f"{label} with keep_old_sessions 2 the removed sessions are {ids!r}, "
8548
+ "not the oldest beyond the two newest with a transcript.")
8542
8549
  return 1
8543
8550
  if not all(r["kept"] for r in gone):
8544
8551
  report(f"{label} a session was removed before Keel's store held its transcript: {gone!r}")
8545
8552
  return 1
8546
8553
  left = {row["id"] for row in json.loads(agents.read_text())}
8547
- for keep_id, why in (("03030303", "the session with no transcript"), ("05050505", "rtl's session"),
8554
+ for keep_id, why in (("06060606", "the session with no transcript"), ("05050505", "rtl's session"),
8548
8555
  ("newsess1", "the new session"), (OLD[:8], "the shift just handed over"), ("04040404", "the second newest old session")):
8549
8556
  if keep_id not in left:
8550
8557
  report(f"{label} {why} ({keep_id}) was removed: {sorted(left)!r}")
package/src/core/shift.js CHANGED
@@ -563,21 +563,26 @@ function keptCopyOf(where, role, transcript) {
563
563
 
564
564
  // After a delivered hand-over, the newest `keep` stopped background sessions in
565
565
  // the role's bound worktrees stay listed; each older one is removed with
566
- // `claude rm` once Keel's store holds its transcript, and one whose transcript
567
- // is nowhere stays (#397 D2). `claude rm` leaves the host's transcript (F4).
566
+ // `claude rm` once Keel's store holds its transcript (#397 D2). `claude rm`
567
+ // leaves the host's transcript (F4). Only a session with a transcript, the
568
+ // host's or Keel's copy, is a shift: one never given a prompt has neither, so
569
+ // it takes no slot and stays (#401).
568
570
  function removeOldSessions(claude, where, entry, keep) {
569
571
  const bound = new Set(Object.entries(store.readJsonFile(path.join(where.root, "roles.json")))
570
572
  .filter(([, name]) => name === entry.role).map(([worktree]) => realpath(worktree)));
571
573
  const listed = listAgents(claude);
572
574
  if (!listed) return [];
575
+ const { keptFile } = require("./chat/notice");
573
576
  const old = listed
574
577
  .filter((row) => row && row.kind === "background" && !row.status && row.cwd && bound.has(realpath(row.cwd))
575
578
  && row.sessionId && row.id !== entry.new_session)
576
- .sort((a, b) => (Number(b.startedAt) || 0) - (Number(a.startedAt) || 0));
579
+ .map((row) => ({ row, transcript: hostTranscript(row.cwd, row.sessionId),
580
+ kept: keptFile(where, entry.role, `${row.sessionId}.jsonl`) }))
581
+ .filter(({ transcript, kept }) => transcript || fs.existsSync(kept))
582
+ .sort((a, b) => (Number(b.row.startedAt) || 0) - (Number(a.row.startedAt) || 0));
577
583
  const removed = [];
578
- for (const row of old.slice(keep)) {
579
- const transcript = hostTranscript(row.cwd, row.sessionId);
580
- if (!transcript || !keptCopyOf(where, entry.role, transcript)) continue;
584
+ for (const { row, transcript } of old.slice(keep)) {
585
+ if (transcript && !keptCopyOf(where, entry.role, transcript)) continue;
581
586
  const gone = spawnSync(claude, ["rm", row.id || row.sessionId.slice(0, 8)], { encoding: "utf8" });
582
587
  if (!gone.error && gone.status === 0) removed.push(row.id || row.sessionId.slice(0, 8));
583
588
  }