@christang/keel 5.200.0 → 5.202.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.
Files changed (46) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/README.md +6 -10
  3. package/README.zh-CN.md +6 -10
  4. package/assets/bootstrap/AGENTS.md +1 -1
  5. package/assets/openspec/schemas/keel-spec-driven/schema.yaml +2 -2
  6. package/bin/keel.js +14 -15
  7. package/npm-shrinkwrap.json +2 -2
  8. package/package.json +1 -1
  9. package/plugins/keel/.claude-plugin/plugin.json +1 -1
  10. package/plugins/keel/.codex-plugin/plugin.json +1 -1
  11. package/plugins/keel/commands/chat.md +17 -0
  12. package/plugins/keel/commands/context.md +18 -0
  13. package/plugins/keel/commands/done.md +25 -0
  14. package/plugins/keel/commands/start.md +23 -0
  15. package/plugins/keel/skills/{keel-align-expectations → align-expectations}/SKILL.md +4 -3
  16. package/plugins/keel/skills/{keel-debug-failure → debug-failure}/SKILL.md +3 -2
  17. package/plugins/keel/skills/{keel-handoff → handoff}/SKILL.md +3 -2
  18. package/plugins/keel/skills/{keel-review-checklist → review-checklist}/SKILL.md +3 -2
  19. package/plugins/keel/skills/{keel-review-checklist → review-checklist}/conditional-checks.md +1 -1
  20. package/plugins/keel/skills/{keel-tdd-or-test-first → tdd-or-test-first}/SKILL.md +3 -2
  21. package/plugins/keel/skills/{keel-tdd-or-test-first → tdd-or-test-first}/guidance.md +1 -1
  22. package/scripts/install_to_repo.py +1 -1
  23. package/scripts/validation/baseline.py +5 -7
  24. package/scripts/validation/chat.py +78 -1
  25. package/scripts/validation/common.py +31 -10
  26. package/scripts/validation/contract.py +22 -21
  27. package/scripts/validation/docs.py +17 -16
  28. package/scripts/validation/export.py +37 -430
  29. package/scripts/validation/guard.py +13 -12
  30. package/scripts/validation/hosts.py +110 -9
  31. package/scripts/validation/install.py +14 -13
  32. package/scripts/validation/registry.py +3 -4
  33. package/scripts/validation/selfcheck.py +4 -4
  34. package/src/core/chat/cli.js +2 -1
  35. package/src/core/chat/notice.js +50 -9
  36. package/src/core/gates.js +1 -1
  37. package/src/core/patrol.js +2 -0
  38. package/src/core/shift.js +5 -2
  39. package/src/core/tick.js +5 -4
  40. package/plugins/keel/skills/keel-md-docx/SKILL.md +0 -51
  41. package/plugins/keel/skills/keel-md-docx/scripts/fonts-macos.conf +0 -10
  42. package/plugins/keel/skills/keel-md-docx/scripts/md2word.py +0 -359
  43. package/plugins/keel/skills/keel-md-docx/scripts/package.json +0 -8
  44. package/plugins/keel/skills/keel-md-docx/scripts/requirements.txt +0 -3
  45. package/plugins/keel/skills/keel-md-docx/scripts/runtime.mjs +0 -31
  46. package/src/core/docx.js +0 -211
@@ -22,6 +22,7 @@ from concurrent.futures import ThreadPoolExecutor, as_completed
22
22
  from pathlib import Path
23
23
 
24
24
  from validation.common import (
25
+ portable_projection_bytes,
25
26
  HANDOFF_STUB,
26
27
  OPENSPEC_CONFIG_PATH,
27
28
  OPENSPEC_SURFACE_OVERLAY_START,
@@ -793,15 +794,115 @@ def validate_runtime_versions_are_checked_scenario() -> int:
793
794
 
794
795
 
795
796
  PLUGIN_SKILLS = (
796
- "keel-align-expectations",
797
- "keel-debug-failure",
798
- "keel-handoff",
799
- "keel-md-docx",
800
- "keel-review-checklist",
801
- "keel-tdd-or-test-first",
797
+ "align-expectations",
798
+ "debug-failure",
799
+ "handoff",
800
+ "review-checklist",
801
+ "tdd-or-test-first",
802
802
  )
803
803
 
804
804
 
805
+ SLASH_SKILLS = ("align-expectations", "debug-failure", "handoff", "review-checklist", "tdd-or-test-first")
806
+ MODEL_ONLY_SKILLS = ("debug-failure", "review-checklist", "tdd-or-test-first")
807
+
808
+
809
+ def skill_frontmatter(path: Path) -> dict[str, str]:
810
+ text = path.read_text(encoding="utf-8")
811
+ match = re.match(r"---\n(.*?)\n---\n", text, re.S)
812
+ fields: dict[str, str] = {}
813
+ for line in (match.group(1).splitlines() if match else []):
814
+ key, _, value = line.partition(":")
815
+ if key and not key.startswith(" "):
816
+ fields[key.strip()] = value.strip().strip('"')
817
+ return fields
818
+
819
+
820
+ def validate_slash_menu_ships_scenario() -> int:
821
+ """Issue #464 (owner, 2026-10-25): the slash menu offers what a person runs.
822
+
823
+ Every skill read as `/keel:keel-<name>`, and the three the protocol has the
824
+ model run at fixed points sat in the menu beside the two a person may want.
825
+ The skills drop the repeated prefix; the model-only ones declare
826
+ `user-invocable: false`; the others declare an `argument-hint`; and no
827
+ shipped file still names a skill the old way.
828
+ """
829
+ label = "slash-menu-ships:"
830
+ skills_root = ROOT / PLUGIN_ROOT / "skills"
831
+ found = sorted(entry.name for entry in skills_root.iterdir() if entry.is_dir())
832
+ if found != sorted(SLASH_SKILLS):
833
+ report(f"{label} the plugin's skills are {found!r}, not {sorted(SLASH_SKILLS)!r}.")
834
+ return 1
835
+ for name in SLASH_SKILLS:
836
+ fields = skill_frontmatter(skills_root / name / "SKILL.md")
837
+ if fields.get("name") != name:
838
+ report(f"{label} {name}/SKILL.md names itself {fields.get('name')!r}.")
839
+ return 1
840
+ hidden = fields.get("user-invocable") == "false"
841
+ if name in MODEL_ONLY_SKILLS and not hidden:
842
+ report(f"{label} {name} is the model's, yet does not declare `user-invocable: false`.")
843
+ return 1
844
+ if name not in MODEL_ONLY_SKILLS and hidden:
845
+ report(f"{label} {name} is a person's, yet declares `user-invocable: false`.")
846
+ return 1
847
+ if name not in MODEL_ONLY_SKILLS and not fields.get("argument-hint"):
848
+ report(f"{label} {name} stays in the menu without an `argument-hint`.")
849
+ return 1
850
+ # The old names, built here so this file does not name them itself. An
851
+ # archived evidence file keeps its name (`…-v1.md`), as does the
852
+ # `keel-handoff/v1` format.
853
+ prefix = "keel" + "-"
854
+ old = re.compile(re.escape(prefix) + r"(?:" + "|".join(re.escape(n) for n in SLASH_SKILLS if n != "handoff") + r")\b(?!-v\d)|"
855
+ + re.escape(prefix) + r"handoff(?!/v1)(?!-)")
856
+ tracked = subprocess.run(["git", "ls-files", "-z"], cwd=ROOT, text=True, capture_output=True, check=True).stdout.split("\0")
857
+ stale = []
858
+ for relative in tracked:
859
+ if not relative or relative == "keel/CHANGELOG.md" or relative.startswith(("openspec/specs/", "openspec/changes/", "keel/archive/")):
860
+ continue
861
+ path = ROOT / relative
862
+ if not path.is_file():
863
+ continue
864
+ try:
865
+ if old.search(path.read_text(encoding="utf-8")):
866
+ stale.append(relative)
867
+ except UnicodeDecodeError:
868
+ continue
869
+ if stale:
870
+ report(f"{label} these files still name a skill the old way: {stale!r}")
871
+ return 1
872
+ # The four everyday flows a person runs, each naming the keel command it orders.
873
+ commands_root = ROOT / PLUGIN_ROOT / "commands"
874
+ commands = sorted(path.stem for path in commands_root.glob("*.md"))
875
+ expected = {"context": "keel context", "start": "keel gate task-start", "done": "keel gate task-complete", "chat": "keel chat unread"}
876
+ if commands != sorted([*expected, "shift"]):
877
+ report(f"{label} the plugin's commands are {commands!r}, not {sorted([*expected, 'shift'])!r}.")
878
+ return 1
879
+ for name, command in expected.items():
880
+ if command not in (commands_root / f"{name}.md").read_text(encoding="utf-8"):
881
+ report(f"{label} commands/{name}.md does not name `{command}`.")
882
+ return 1
883
+ invocable = [*sorted([*expected, "shift"]), *(name for name in SLASH_SKILLS if name not in MODEL_ONLY_SKILLS)]
884
+ for doc in ("docs/commands.md", "docs/commands.zh-CN.md"):
885
+ path = ROOT / doc
886
+ if not path.is_file():
887
+ report(f"{label} {doc} does not exist.")
888
+ return 1
889
+ missing = [name for name in invocable if f"/keel:{name}" not in path.read_text(encoding="utf-8")]
890
+ if missing:
891
+ report(f"{label} {doc} does not list {', '.join(f'/keel:{name}' for name in missing)}.")
892
+ return 1
893
+ claude = shutil.which("claude")
894
+ if claude:
895
+ validated = subprocess.run([claude, "plugin", "validate", str(ROOT / PLUGIN_ROOT)], text=True, capture_output=True, timeout=120)
896
+ if validated.returncode != 0:
897
+ report(f"{label} `claude plugin validate` failed: {(validated.stdout + validated.stderr).strip()[-400:]}")
898
+ return 1
899
+ if "slash-menu-ships" not in {name for name, _ in registry.SCENARIOS}:
900
+ report(f"{label} scenario is not registered.")
901
+ return 1
902
+ report("slash-menu-ships scenario passed.")
903
+ return 0
904
+
905
+
805
906
  def strict_semver(version: str) -> bool:
806
907
  return bool(re.fullmatch(r"\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?", version or ""))
807
908
 
@@ -885,7 +986,7 @@ def validate_native_plugin_manifests_scenario() -> int:
885
986
  report(f"native-plugin-manifests plugin copy of {skill_name} has {extra}, which the source does not")
886
987
  return 1
887
988
  for name in canonical_files:
888
- if (plugin_dir / name).read_bytes() != (canonical_dir / name).read_bytes():
989
+ if portable_projection_bytes(plugin_dir / name) != (canonical_dir / name).read_bytes():
889
990
  report(f"native-plugin-manifests plugin copy diverges from canonical source: {skill_name}/{name}")
890
991
  return 1
891
992
  lenses_root = ROOT / "assets/lenses"
@@ -4353,8 +4454,8 @@ def validate_native_plugin_marketplaces_scenario() -> int:
4353
4454
  missing = [
4354
4455
  needle
4355
4456
  for needle in (
4356
- "keel-align-expectations",
4357
- "keel-review-checklist",
4457
+ "align-expectations",
4458
+ "review-checklist",
4358
4459
  "SessionStart",
4359
4460
  "PreToolUse",
4360
4461
  )
@@ -22,6 +22,7 @@ from concurrent.futures import ThreadPoolExecutor, as_completed
22
22
  from pathlib import Path
23
23
 
24
24
  from validation.common import (
25
+ portable_projection_bytes,
25
26
  BOOTSTRAP_BLOCK_BYTE_BUDGET,
26
27
  LEGACY_PROFILE_SKILLS,
27
28
  MANAGED_END,
@@ -302,7 +303,7 @@ def validate_target_surface_scenario() -> int:
302
303
 
303
304
  def validate_domain_lenses_scenario() -> int:
304
305
  plugin_skills_root = ROOT / PLUGIN_ROOT / "skills"
305
- if not (plugin_skills_root / "keel-align-expectations/SKILL.md").is_file():
306
+ if not (plugin_skills_root / "align-expectations/SKILL.md").is_file():
306
307
  report("domain-lenses scenario plugin misses the alignment skill")
307
308
  return 1
308
309
  lenses_root = ROOT / "assets/lenses"
@@ -459,7 +460,7 @@ def assert_openspec_overlay(path: Path, action: str) -> str | None:
459
460
  required.extend(
460
461
  [
461
462
  "keel gate change-close --action archive",
462
- "keel-review-checklist",
463
+ "review-checklist",
463
464
  "critical expectation",
464
465
  "behavior evidence",
465
466
  "durable follow-up owner",
@@ -745,7 +746,7 @@ def validate_sync_surface_overlay_scenario() -> int:
745
746
  """The surface that performs a gated action never named its gate.
746
747
 
747
748
  AGENTS.md gates sync and archive identically — `keel gate change-close
748
- --action sync|archive` plus `keel-review-checklist`. Archive's command
749
+ --action sync|archive` plus `review-checklist`. Archive's command
749
750
  surface carries a Keel overlay saying so; sync's carried none, because
750
751
  `OPENSPEC_OVERLAY_ACTIONS` listed only propose, apply, and archive. An
751
752
  agent invoking `/opsx:sync` read generic upstream instructions and was told
@@ -800,7 +801,7 @@ def validate_sync_surface_overlay_scenario() -> int:
800
801
  # M2 — and it says the things that change behavior.
801
802
  for needle, why in (
802
803
  ("keel gate change-close --action sync", "the gate"),
803
- ("keel-review-checklist", "the semantic review"),
804
+ ("review-checklist", "the semantic review"),
804
805
  ("keel openspec", "how to invoke OpenSpec off PATH"),
805
806
  ("--skip-specs", "that a following archive must skip specs"),
806
807
  ):
@@ -1435,10 +1436,10 @@ def validate_uninstall_scenario() -> int:
1435
1436
  if not (repo / "keel/templates/TASK.lite.md").is_file():
1436
1437
  report("uninstall scenario deleted user-edited Lite TASK template.")
1437
1438
  return 1
1438
- if (repo / ".claude/skills/keel-handoff/SKILL.md").exists():
1439
+ if (repo / ".claude/skills/handoff/SKILL.md").exists():
1439
1440
  report("uninstall scenario did not remove packaged Claude skill.")
1440
1441
  return 1
1441
- if (repo / ".claude/skills/keel-review-checklist/SKILL.md").exists():
1442
+ if (repo / ".claude/skills/review-checklist/SKILL.md").exists():
1442
1443
  report("uninstall scenario did not remove packaged Claude review skill.")
1443
1444
  return 1
1444
1445
  if not (repo / OPENSPEC_CONFIG_PATH).is_file():
@@ -2938,10 +2939,10 @@ def validate_thin_native_install_scenario() -> int:
2938
2939
  tmp = Path(raw_tmp)
2939
2940
 
2940
2941
  forbidden_copies = (
2941
- ".claude/skills/keel-review-checklist",
2942
- ".claude/skills/keel-align-expectations",
2942
+ ".claude/skills/review-checklist",
2943
+ ".claude/skills/align-expectations",
2943
2944
  ".claude/hooks/keel-gate",
2944
- ".agents/skills/keel-review-checklist",
2945
+ ".agents/skills/review-checklist",
2945
2946
  "keel/adapters",
2946
2947
  )
2947
2948
 
@@ -3163,9 +3164,9 @@ def validate_thin_native_install_scenario() -> int:
3163
3164
 
3164
3165
  def validate_domain_execution_references_scenario() -> int:
3165
3166
  consuming_skills = (
3166
- "keel-tdd-or-test-first",
3167
- "keel-debug-failure",
3168
- "keel-review-checklist",
3167
+ "tdd-or-test-first",
3168
+ "debug-failure",
3169
+ "review-checklist",
3169
3170
  )
3170
3171
  templates = ("web.md", "hardware.md", "hardware-dsl.md")
3171
3172
  roots = (ROOT / "src/skills", ROOT / PLUGIN_ROOT / "skills")
@@ -3219,7 +3220,7 @@ def validate_domain_execution_references_scenario() -> int:
3219
3220
 
3220
3221
  for skill in consuming_skills:
3221
3222
  src_text = (roots[0] / skill / "SKILL.md").read_bytes()
3222
- shipped_text = (roots[1] / skill / "SKILL.md").read_bytes()
3223
+ shipped_text = portable_projection_bytes(roots[1] / skill / "SKILL.md")
3223
3224
  if src_text != shipped_text:
3224
3225
  report(
3225
3226
  f"domain-execution-references: shipped {skill} copy diverges "
@@ -388,6 +388,7 @@ SCENARIOS: tuple = (
388
388
  ),
389
389
  ("authoring-alignment-overlay", contract.validate_authoring_alignment_overlay_scenario),
390
390
  ("native-plugin-manifests", hosts.validate_native_plugin_manifests_scenario),
391
+ ("slash-menu-ships", hosts.validate_slash_menu_ships_scenario),
391
392
  ("native-plugin-session-start", hosts.validate_native_plugin_session_start_scenario),
392
393
  ("runtime-version-drift", hosts.validate_runtime_version_drift_scenario),
393
394
  ("session-start-source-repo-protocol", hosts.validate_session_start_source_repo_protocol_scenario),
@@ -459,6 +460,7 @@ SCENARIOS: tuple = (
459
460
  ("chat-visitor-not-recorded", chat.validate_chat_visitor_not_recorded_scenario),
460
461
  ("chat-role-set-records-session", chat.validate_chat_role_set_records_session_scenario),
461
462
  ("chat-wake-skips-removed-session", chat.validate_chat_wake_skips_removed_session_scenario),
463
+ ("chat-wake-moved-worktree", chat.validate_chat_wake_moved_worktree_scenario),
462
464
  ("chat-ack", chat.validate_chat_ack_scenario),
463
465
  ("coordinator-patrol", shift.validate_coordinator_patrol_scenario),
464
466
  ("patrol-since-last", shift.validate_patrol_since_last_scenario),
@@ -659,8 +661,5 @@ SCENARIOS: tuple = (
659
661
  "a-count-is-derived-from-what-it-counts",
660
662
  docs.validate_a_count_is_derived_from_what_it_counts_scenario,
661
663
  ),
662
- ("docx-skill-ships", export.validate_docx_skill_ships_scenario),
663
- ("docx-setup-asks-first", export.validate_docx_setup_asks_first_scenario),
664
- ("docx-convert-refuses-first", export.validate_docx_convert_refuses_first_scenario),
665
- ("docx-converts-markdown-with-svg", export.validate_docx_converts_markdown_with_svg_scenario),
664
+ ("docx-retired", export.validate_docx_retired_scenario),
666
665
  )
@@ -470,7 +470,7 @@ def validate_resident_topic_matching_scenario() -> int:
470
470
 
471
471
  # The one-message-many-failures shape, counted rather than forbidden.
472
472
  #
473
- # Issue #43 records it caught by `keel-review-checklist` in three consecutive
473
+ # Issue #43 records it caught by `review-checklist` in three consecutive
474
474
  # changes, every time in this file: `if <the run did not work> or <the output
475
475
  # lacks a specific thing>:` followed by one `report(...)` describing only the
476
476
  # second operand. When the first fires the sentence is false, and it sends the
@@ -479,7 +479,7 @@ def validate_resident_topic_matching_scenario() -> int:
479
479
  # This number bounds a SHAPE. It is not a count of defects: many of the sites
480
480
  # it counts carry a message that genuinely covers every operand, and deciding
481
481
  # whether a particular sentence misleads needs a model, so that judgment stays
482
- # in `keel-review-checklist`. What the number does is make a *new* one visible
482
+ # in `review-checklist`. What the number does is make a *new* one visible
483
483
  # when it is written, which is earlier than a review that only runs at a
484
484
  # completion gate.
485
485
  #
@@ -630,7 +630,7 @@ def probe():
630
630
  def validate_assertion_shape_count_scenario() -> int:
631
631
  """Issue #43: one condition guarding two failures, caught three times.
632
632
 
633
- `keel-review-checklist` catches it, but only at a completion gate and only
633
+ `review-checklist` catches it, but only at a completion gate and only
634
634
  because a human wrote a checklist entry pointing the model at it. This
635
635
  counts the shape so a new one is visible when it is written.
636
636
  """
@@ -1170,7 +1170,7 @@ def validate_authored_scenario_names_scenario() -> int:
1170
1170
  "--scenario gate-diagnostics` passes\n"
1171
1171
  " - M2 (regression): `core-gates` and `target-surface-doctor` stay "
1172
1172
  "green\n"
1173
- " - M3 (regression): `task-start`, `keel-review-checklist`, "
1173
+ " - M3 (regression): `task-start`, `review-checklist`, "
1174
1174
  "`contract-drift`, `subagent-stop`, and `keel-task-capsule` are "
1175
1175
  "unchanged\n"
1176
1176
  " - M4: `cli` and "
@@ -706,8 +706,9 @@ function runWake(cwd, options) {
706
706
  out(`${role}'s CLI session ${presence.cli_session} is running; a record addressed to it wakes it, so nothing was resumed.`);
707
707
  return 0;
708
708
  }
709
- const resumed = notice.resumeCli(entry);
709
+ const resumed = notice.resumeCli(entry, where);
710
710
  if (resumed.removed) throw new ChatError(`${role}'s recorded CLI ${resumed.output}.`);
711
+ if (resumed.moved) throw new ChatError(`${role}'s recorded CLI ${resumed.output}`);
711
712
  out(`${resumed.ok ? "Resumed" : "Could not resume"} ${role}'s CLI session ${entry.session} in ${entry.worktree}.${resumed.output ? `\n${resumed.output}` : ""}`);
712
713
  return resumed.ok ? 0 : 1;
713
714
  }
@@ -211,9 +211,25 @@ function wakeStep(session, text) {
211
211
  // The prompt an ended CLI session resumes with: a pointer, never the work.
212
212
  const CLI_WAKE_PROMPT = "You have unread keel chat records; run keel context, then keel chat unread.";
213
213
 
214
+ // The command that continues a session whose directory is gone in the role's
215
+ // worktree (#465 D1). Keel prints it and never runs it (D3): a fork is a new
216
+ // session with a new id, not a resume of the recorded one.
217
+ function forkCommand(where, entry) {
218
+ const bound = where
219
+ ? Object.entries(store.readJsonFile(path.join(where.root, "roles.json")))
220
+ .filter(([worktree, name]) => name === entry.role && fs.existsSync(worktree)).map(([worktree]) => worktree)
221
+ : [];
222
+ const target = bound.length === 1 ? bound[0] : "<the role's worktree>";
223
+ const mode = bound.length === 1 ? require("../config").readShiftDeclaration(target).permissionMode : "auto";
224
+ const name = `${entry.role} · ${store.isoLocal(new Date()).slice(5, 16).replace("T", " ")}`;
225
+ const command = `cd ${target} && claude --bg --fork-session --resume ${entry.session} -n ${JSON.stringify(name)} --permission-mode ${mode} ${JSON.stringify(CLI_WAKE_PROMPT)}`;
226
+ return bound.length > 1 ? `${command}\n(the role is bound to ${bound.join(", ")}: use the one it works in)` : command;
227
+ }
228
+
214
229
  // Resumes a role's recorded CLI session (#348 D3). Only `--bg --resume <id>`
215
- // and the prompt: any other flag starts a copy with a new session id.
216
- function resumeCli(entry) {
230
+ // and the prompt: any other flag starts a copy with a new session id. A
231
+ // session whose directory no longer exists resumes nothing (#465).
232
+ function resumeCli(entry, where = null) {
217
233
  const claude = process.env.KEEL_CLAUDE || "claude";
218
234
  // A session `claude rm` removed is gone for good (#415 D4): when the host's
219
235
  // list can be read and lacks it, nothing is resumed. An unreadable list
@@ -221,19 +237,33 @@ function resumeCli(entry) {
221
237
  const listed = require("child_process").spawnSync(claude, ["agents", "--json", "--all"], {
222
238
  encoding: "utf8", timeout: 30 * 1000,
223
239
  });
240
+ let row = null;
224
241
  try {
225
242
  const rows = JSON.parse(listed.stdout);
226
- if (!listed.error && listed.status === 0 && Array.isArray(rows)
227
- && !rows.some((row) => row && row.sessionId === entry.session)) {
228
- return {
229
- ok: false,
230
- removed: true,
231
- output: `session ${entry.session} was removed: \`claude agents\` no longer lists it, so a new session must be started for the role in ${entry.worktree || "its worktree"}`,
232
- };
243
+ if (!listed.error && listed.status === 0 && Array.isArray(rows)) {
244
+ row = rows.find((found) => found && found.sessionId === entry.session) || null;
245
+ if (!row) {
246
+ return {
247
+ ok: false,
248
+ removed: true,
249
+ output: `session ${entry.session} was removed: \`claude agents\` no longer lists it, so a new session must be started for the role in ${entry.worktree || "its worktree"}`,
250
+ };
251
+ }
233
252
  }
234
253
  } catch {
235
254
  // Not a list: fall through and resume.
236
255
  }
256
+ // The host resumes a session only in the directory it registered, so one
257
+ // whose directory was renamed or removed cannot start (#465 F3).
258
+ const ran = (row && row.cwd) || entry.worktree;
259
+ if (ran && !fs.existsSync(ran)) {
260
+ return {
261
+ ok: false,
262
+ moved: true,
263
+ output: `session ${entry.session} ran in ${ran}, which no longer exists, and Claude Code resumes a session only in the directory it ran in. `
264
+ + `To continue its conversation as a new session in the role's worktree, run:\n${forkCommand(where, entry)}`,
265
+ };
266
+ }
237
267
  const result = require("child_process").spawnSync(claude, ["--bg", "--resume", entry.session, CLI_WAKE_PROMPT], {
238
268
  cwd: entry.worktree || undefined, encoding: "utf8",
239
269
  });
@@ -244,6 +274,16 @@ function resumeCli(entry) {
244
274
  return { ok: !result.error && result.status === 0, output: result.error ? result.error.message : output };
245
275
  }
246
276
 
277
+ // Covered roles whose ended CLI session ran in a worktree that no longer
278
+ // exists (#465 D4). Presence only: the patrol asks the host nothing.
279
+ function movedSessionRisks(where, covers = () => true) {
280
+ const roles = [...new Set(Object.values(store.readJsonFile(path.join(where.root, "roles.json"))).filter(Boolean))].sort();
281
+ return roles.filter(covers).map((role) => asleep(where, role))
282
+ .filter((entry) => entry && entry.cli && entry.worktree && !fs.existsSync(entry.worktree))
283
+ .map((entry) => `${entry.role}'s CLI session ${entry.session} ran in ${entry.worktree}, which no longer exists, so it cannot be resumed; `
284
+ + `\`keel chat wake now ${entry.role}\` prints the command that continues it in the role's worktree`);
285
+ }
286
+
247
287
  // --- parked roles (#316) ------------------------------------------------------------
248
288
 
249
289
  function parkFile(where, role) {
@@ -729,6 +769,7 @@ module.exports = {
729
769
  unpark,
730
770
  wakeStep,
731
771
  resumeCli,
772
+ movedSessionRisks,
732
773
  twinWarning,
733
774
  check,
734
775
  bridgeLine,
package/src/core/gates.js CHANGED
@@ -1023,7 +1023,7 @@ function transientOwnerMessage(candidate) {
1023
1023
  // A finding has three dispositions and the gate recognized two. One found and
1024
1024
  // fixed inside the task recording it has no owner to name and nothing to
1025
1025
  // discard, so the only text that passed was `Discard reason:` — filing a repair
1026
- // as a dismissal. This capability and `keel-review-checklist` both already
1026
+ // as a dismissal. This capability and `review-checklist` both already
1027
1027
  // scoped the ownership requirement to an *unresolved* finding; only the
1028
1028
  // implementation applied it to all of them. `## Invalidates` has carried the
1029
1029
  // same third slot since it shipped, where `Updated by:` names tasks of this
@@ -559,6 +559,8 @@ function runPatrol(argv) {
559
559
  if (quota) result.risks.push(quota);
560
560
  // A CLI hand-off that failed or hangs (#357 D4), of the roles this patrol covers.
561
561
  result.risks.push(...require("./shift").handOffRisks(where, Date.now(), (name) => name === role || options.coverage.covers(name)));
562
+ // An ended CLI session whose worktree is gone cannot be woken (#465 D4).
563
+ result.risks.push(...require("./chat/notice").movedSessionRisks(where, (name) => name === role || options.coverage.covers(name)));
562
564
  // Near the limit nudges stop, since each wakes a large session (D3).
563
565
  const quiet = options.quota !== null && options.quota >= options.quotaQuietAt;
564
566
  if (options.nudge && quiet) result.paused = `nudges paused: quota at ${options.quota}%`;
package/src/core/shift.js CHANGED
@@ -1605,9 +1605,12 @@ function runShift(argv) {
1605
1605
  case "status": {
1606
1606
  const rows = status(where);
1607
1607
  const queue = handOffs(where);
1608
+ // Roles whose ended CLI session ran in a worktree that is gone (#465 D4).
1609
+ const unresumable = require("./chat/notice").movedSessionRisks(where);
1608
1610
  const text = [rows.length ? rows.map(describe).join("\n") : "No shift change recorded.",
1609
- ...(queue.length ? ["", "Hand-offs (CLI, run by `keel tick`):", ...queue.map(describeHandOff)] : [])].join("\n");
1610
- out({ roles: rows, handOffs: queue }, text);
1611
+ ...(queue.length ? ["", "Hand-offs (CLI, run by `keel tick`):", ...queue.map(describeHandOff)] : []),
1612
+ ...(unresumable.length ? ["", "Sessions that cannot be resumed:", ...unresumable.map((line) => `- ${line}`)] : [])].join("\n");
1613
+ out({ roles: rows, handOffs: queue, unresumable }, text);
1611
1614
  return 0;
1612
1615
  }
1613
1616
  default:
package/src/core/tick.js CHANGED
@@ -96,13 +96,14 @@ function wakeEnded(where, state) {
96
96
  const waiting = store.unread(where, role).filter((record) => store.wakes(record, role)).map((record) => record.id).sort();
97
97
  const newest = waiting[waiting.length - 1];
98
98
  if (!newest || (state.woken[role] && state.woken[role] >= newest)) continue;
99
- const resumed = notice.resumeCli(entry);
100
- // Marked woken only once it worked, the session is gone, or three tries
101
- // failed for this record (#408 D3); a newer record starts the count again.
99
+ const resumed = notice.resumeCli(entry, where);
100
+ // Marked woken only once it worked, the session or its directory is gone
101
+ // (#465 D2), or three tries failed for this record (#408 D3); a newer
102
+ // record starts the count again.
102
103
  const before = (state.wake_attempts || {})[role];
103
104
  const count = before && before.record === newest ? before.count + 1 : 1;
104
105
  state.wake_attempts = { ...(state.wake_attempts || {}), [role]: { record: newest, count } };
105
- if (resumed.ok || resumed.removed || count >= 3) state.woken[role] = newest;
106
+ if (resumed.ok || resumed.removed || resumed.moved || count >= 3) state.woken[role] = newest;
106
107
  woken.push({ role, session: entry.session, record: newest, ok: resumed.ok, output: resumed.output });
107
108
  }
108
109
  return woken;
@@ -1,51 +0,0 @@
1
- ---
2
- name: keel-md-docx
3
- description: Export a local Markdown file that contains SVG diagrams to one Word (.docx) document, keeping the SVG as vector images with PNG fallbacks. Use when the user asks to export, convert, or deliver Markdown with SVG as Word or .docx. Do not use for other document formats, for Markdown without a Word request, or for editing an existing Word file.
4
- ---
5
-
6
- # keel-md-docx
7
-
8
- ## Purpose
9
-
10
- Turn one local Markdown file into one `.docx`: headings, paragraphs, inline formatting, lists, quotes, code blocks, and tables stay editable; every SVG becomes a vector image with an embedded PNG fallback, scaled to fit the page; every image ends up inside the document. The converter is `scripts/md2word.py` with the helper `scripts/runtime.mjs`, run by `keel docx convert` in an environment Keel manages. Nothing here runs unless the user asks for this export.
11
-
12
- ## Steps
13
-
14
- 1. **Check the environment.** Run `keel docx setup`. Without `--yes` it installs nothing: it prints each package, its licence and size, and where the environment would go (`~/.keel/docx/`, or `$KEEL_HOME/docx/`). If it reports the environment ready, go to step 3.
15
- 2. **Ask before installing.** Show the user that list in plain terms and ask whether to install. Only after they agree, run `keel docx setup --yes`. It installs into the Keel-managed environment, never into system Python or Node, and downloads no fonts or runtimes. If the user declines, stop and say the export needs it.
16
- 3. **State the output path.** Tell the user where the document will be written: by default the input's name with `.docx`, or the path they gave. If a file is already there, ask whether to replace it; `keel docx convert` refuses an existing output unless `--replace` is given.
17
- 4. **Convert.** Run `keel docx convert <input.md> [-o <output.docx>] [--template <template.docx>] [--replace]`. A template contributes its styles, headers, and page settings; its body is discarded.
18
- 5. **Report the result.** Relay the output path and image count on success, and every `Warning:` line. On failure relay the `Conversion failed:` reason; the previous output, if any, is untouched.
19
-
20
- ## What converts
21
-
22
- - A standalone `<svg>…</svg>` block, a fenced code block labelled `svg`, and image references to local `.svg` files, resolved relative to the Markdown file. SVG inside ordinary code stays code.
23
- - Local raster images (PNG, JPEG) and `data:` URIs.
24
- - Headings, paragraphs, bold, italic, strikethrough, links, lists, quotes, code blocks, and tables.
25
-
26
- ## Limits
27
-
28
- - An SVG stays an image; it is not split into editable Word shapes.
29
- - `foreignObject`, scripts, external fonts, external images, and external stylesheets inside an SVG fail the conversion with the reason; use SVG `text` and `path`, and embed bitmaps as `data:` URIs.
30
- - A remote image fails the conversion: save it locally first. Nothing is downloaded during conversion.
31
- - Mermaid, math, footnotes, a table of contents, internal bookmark links, and HTML/CSS page layout are not converted. Lists use explicit numbers and bullets, not Word numbering. A tall diagram is scaled down rather than split across pages; a wide table may need a template or a landscape page.
32
- - Inline HTML styling is dropped with a warning; an unsupported Markdown block stops the conversion.
33
- - The default page is A4 with 2 cm margins, Arial with Heiti SC for Chinese. On macOS Keel points the SVG renderer at the system font folders for this process only; on other systems install the fonts the document needs or supply a template.
34
-
35
- ## Dependencies
36
-
37
- Installed only by `keel docx setup --yes`, into `~/.keel/docx/` (`python/` is a virtual environment, `node/` holds the npm packages). Sizes are from the registries on 2026-10-21 for macOS arm64, not measured from an install.
38
-
39
- | Package | Version | Licence | Size |
40
- | --- | --- | --- | --- |
41
- | python-docx | `>=1.1,<2` (1.2.0) | MIT | 0.25 MB wheel |
42
- | lxml | `>=5,<7` (6.0.2) | BSD-3-Clause | 8.6 MB wheel |
43
- | Pillow | `>=10,<13` (12.0.0) | MIT-CMU | 4.65 MB wheel |
44
- | marked | 17.0.5 | MIT | 0.44 MB |
45
- | sharp | 0.35.5 | Apache-2.0 | 0.96 MB, plus its platform binary (0.29 MB, Apache-2.0) and libvips 1.3.4 (18.2 MB, LGPL-3.0-or-later) |
46
-
47
- The version lists are `scripts/requirements.txt` and `scripts/package.json`. Python 3.10 or newer and the Node that runs `keel` are used.
48
-
49
- ## Verification status
50
-
51
- As of the release that added this skill (#405), the setup plan, the consent flow, the refusals, and the hand-off to the converter are tested with stand-in installers. The real conversion, every failure case against real SVG, and the page-by-page rendering of a Chinese mixed-text example are **unverified** in Keel: the converter was verified as the #405 prototype on macOS arm64 only (Python 3.12, marked 17.0.5, sharp 0.35.5), outside Keel. Linux, Windows, Codex, and Microsoft Word itself are unverified.
@@ -1,10 +0,0 @@
1
- <?xml version="1.0"?>
2
- <!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
3
- <fontconfig>
4
- <!-- Only used by this process; makes macOS CJK fonts visible to libvips/LO. -->
5
- <dir>/System/Library/Fonts</dir>
6
- <dir>/System/Library/Fonts/Supplemental</dir>
7
- <dir>/Library/Fonts</dir>
8
- <cachedir prefix="xdg">fontconfig</cachedir>
9
- <alias><family>sans-serif</family><prefer><family>Arial</family><family>Heiti SC</family></prefer></alias>
10
- </fontconfig>