@christang/keel 5.189.0 → 5.190.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.189.0",
3
+ "version": "5.190.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.189.0 -->
1
+ <!-- keel:start version=5.190.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.189.0",
3
+ "version": "5.190.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@christang/keel",
9
- "version": "5.189.0",
9
+ "version": "5.190.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.189.0",
5
+ "version": "5.190.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.189.0",
3
+ "version": "5.190.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.189.0",
3
+ "version": "5.190.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",
@@ -351,6 +351,43 @@ def validate_chat_hook_follows_session_worktree_scenario() -> int:
351
351
  if "sess-v" in chat_session_list(rtl, "rtl"):
352
352
  report(f"{label} rtl's session list took the resumed session: {chat_session_list(rtl, 'rtl')!r}")
353
353
  return 1
354
+
355
+ # #441, measured on Claude Code 2.1.304 (2026-10-21): on resume the host
356
+ # reports the launch directory for `transcript_path` too, naming a file that
357
+ # does not exist; the session keeps writing its transcript in the project
358
+ # directory of the worktree it runs in.
359
+ with tempfile.TemporaryDirectory(prefix="keel-chat-441-") as raw:
360
+ base = Path(raw)
361
+ rtl, verify, env = chat_scratch_group(base)
362
+ config = base / "claude-config"
363
+ env = {**env, "CLAUDE_CONFIG_DIR": str(config)}
364
+ chat_session_start(rtl, env, "sess-r", os.getpid())
365
+ real = config / "projects" / host_project_name(verify) / "sess-w.jsonl"
366
+ write_text(real, json.dumps({"type": "user", "message": {"role": "user", "content": "carry on"}}) + "\n")
367
+ reported = config / "projects" / host_project_name(rtl) / "sess-w.jsonl"
368
+ started = chat_session_start(rtl, env, "sess-w", os.getpid(), source="resume", transcript=reported)
369
+ try:
370
+ watched = json.loads(started.stdout)["hookSpecificOutput"]["watchPaths"]
371
+ except (ValueError, KeyError, TypeError):
372
+ report(f"{label} the measured resume payload printed no watch paths: {started.stdout!r} {started.stderr!r}")
373
+ return 1
374
+ if not any(path.endswith("/signal/verify") for path in watched):
375
+ report(f"{label} a resumed -w session whose reported transcript does not exist watches {watched!r}, not verify's signal.")
376
+ return 1
377
+ if any(path.endswith("/signal/rtl") for path in watched):
378
+ report(f"{label} a resumed -w session whose reported transcript does not exist also watches rtl's signal: {watched!r}")
379
+ return 1
380
+ if chat_session_record(rtl, "sess-w").get("role") != "verify":
381
+ report(f"{label} the measured resume was recorded as {chat_session_record(rtl, 'sess-w').get('role')!r}, not verify.")
382
+ return 1
383
+ if chat_presence(rtl, "rtl").get("cli_session") != "sess-r":
384
+ report(f"{label} rtl's presence took the measured resume: {chat_presence(rtl, 'rtl')!r}")
385
+ return 1
386
+ segments_file = mailbox_common_dir(rtl) / "keel-chat" / "shift" / "segments" / "verify.json"
387
+ segments = json.loads(segments_file.read_text(encoding="utf-8")).get("segments", []) if segments_file.is_file() else []
388
+ if not segments or os.path.realpath(segments[-1].get("transcript") or "") != os.path.realpath(real):
389
+ report(f"{label} the resumed session's segment names {segments!r}, not the transcript that exists ({real}).")
390
+ return 1
354
391
  if label.rstrip(":") not in {name for name, _ in registry.SCENARIOS}:
355
392
  report(f"{label} the scenario registry does not include it.")
356
393
  return 1
@@ -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.189.0"
38
+ PACKAGE_VERSION = "5.190.0"
39
39
 
40
40
 
41
- PROTOCOL_VERSION = "5.189.0"
41
+ PROTOCOL_VERSION = "5.190.0"
42
42
 
43
43
 
44
44
  LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
@@ -546,9 +546,29 @@ function hostProjectName(directory) {
546
546
  // 2026-10-21, Claude Code 2.1.304), while its transcript stays in the host
547
547
  // project directory of the worktree it runs in. When that names another
548
548
  // worktree of this repository, the session is that worktree's.
549
+ // A resumed `claude --bg -w` session reports the launch directory for
550
+ // `transcript_path` as well as `cwd`, naming a file that does not exist; its
551
+ // transcript stays in the project directory of the worktree it runs in
552
+ // (measured on Claude Code 2.1.304, #441). The file that exists is the truth.
553
+ function existingTranscript(payload) {
554
+ const reported = typeof payload.transcript_path === "string" ? payload.transcript_path : "";
555
+ if (path.isAbsolute(reported) && fs.existsSync(reported)) return reported;
556
+ const id = typeof payload.session_id === "string" ? payload.session_id : "";
557
+ if (!/^[A-Za-z0-9._-]{1,128}$/.test(id)) return reported;
558
+ const projects = path.join(process.env.CLAUDE_CONFIG_DIR || path.join(require("os").homedir(), ".claude"), "projects");
559
+ let dirs = [];
560
+ try {
561
+ dirs = fs.readdirSync(projects);
562
+ } catch {
563
+ return reported;
564
+ }
565
+ const found = dirs.map((dir) => path.join(projects, dir, `${id}.jsonl`)).find((file) => fs.existsSync(file));
566
+ return found || reported;
567
+ }
568
+
549
569
  function hookLocation(payload) {
550
570
  const where = store.locate(payload.cwd || process.cwd());
551
- const transcript = typeof payload.transcript_path === "string" ? payload.transcript_path : "";
571
+ const transcript = existingTranscript(payload);
552
572
  if (!where || !path.isAbsolute(transcript)) return where;
553
573
  const project = path.basename(path.dirname(transcript));
554
574
  const named = (dir) => [dir, realpathOf(dir)].some((candidate) => hostProjectName(candidate) === project);
@@ -666,7 +686,7 @@ function hook(event, input, { mail = false } = {}) {
666
686
  if (event === "session-start") rememberSession(where, role, file);
667
687
  const started = event === "session-start" ? { source: typeof payload.source === "string" ? payload.source : null } : null;
668
688
  touchPresence(where, role, "online", mail ? null : "claude-code", started);
669
- if (event === "session-start" || event === "user-prompt-submit") recordSegment(where, role, payload.transcript_path);
689
+ if (event === "session-start" || event === "user-prompt-submit") recordSegment(where, role, existingTranscript(payload));
670
690
  const chatText = noticeText(where, role);
671
691
  const text = chatText && mail ? `${chatText}\n${MAIL_POINTER}` : chatText;
672
692
  if (event === "session-start") {