@christang/keel 5.219.0 → 5.220.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.219.0",
3
+ "version": "5.220.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.219.0 -->
1
+ <!-- keel:start version=5.220.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.219.0",
3
+ "version": "5.220.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@christang/keel",
9
- "version": "5.219.0",
9
+ "version": "5.220.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.219.0",
5
+ "version": "5.220.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.219.0",
3
+ "version": "5.220.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.219.0",
3
+ "version": "5.220.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.219.0"
38
+ PACKAGE_VERSION = "5.220.0"
39
39
 
40
40
 
41
- PROTOCOL_VERSION = "5.219.0"
41
+ PROTOCOL_VERSION = "5.220.0"
42
42
 
43
43
 
44
44
  LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
@@ -495,6 +495,8 @@ SCENARIOS: tuple = (
495
495
  ("session-start-says-silent-tick", shift.validate_session_start_says_silent_tick_scenario),
496
496
  ("launchd-stable-node", shift.validate_launchd_stable_node_scenario),
497
497
  ("tick-task-names-main-checkout", shift.validate_tick_task_names_main_checkout_scenario),
498
+ ("tick-task-without-patrol", shift.validate_tick_task_without_patrol_scenario),
499
+ ("tick-task-refuses-unreadable-patrol", shift.validate_tick_task_refuses_unreadable_patrol_scenario),
498
500
  ("tick-skips-missing-bound-worktree", shift.validate_tick_skips_missing_bound_worktree_scenario),
499
501
  ("launchd-doctor-names-job-directories", shift.validate_launchd_doctor_names_job_directories_scenario),
500
502
  ("shift-slash-command", shift.validate_shift_slash_command_scenario),
@@ -880,6 +880,75 @@ def validate_tick_task_names_main_checkout_scenario() -> int:
880
880
  return 0
881
881
 
882
882
 
883
+ def validate_tick_task_without_patrol_scenario() -> int:
884
+ """Issue #509: a repository that declares no patrol still gets a tick job.
885
+
886
+ `keel tick task` failed for want of a `patrol:`, though the tick's resume
887
+ of ended sessions and its hand-over need none; Keel's own repository
888
+ declared a patrol only to get a job.
889
+ """
890
+ label = "tick-task-without-patrol:"
891
+ with tempfile.TemporaryDirectory(prefix="keel-tick-509-") as raw:
892
+ base = Path(raw)
893
+ rtl, _verify, env, _ = shift_scratch(base)
894
+ main = os.path.realpath(rtl)
895
+ wa = chat_worktree(rtl, rtl / ".claude" / "worktrees" / "wa")
896
+
897
+ def named(text: str, pattern: str) -> str:
898
+ return (re.search(pattern, text, re.S) or [None, ""])[1]
899
+
900
+ for where, cwd in (("the main checkout", rtl), ("a linked worktree", wa)):
901
+ printed = run_keel(cwd, "tick", "task", env=env)
902
+ if printed.returncode != 0:
903
+ report(f"{label} keel tick task failed in {where} with no patrol declared: {printed.stderr!r}")
904
+ return 1
905
+ repo = named(printed.stdout, r"<string>--repo</string>\s*<string>(.*?)</string>")
906
+ directory = named(printed.stdout, r"<key>WorkingDirectory</key>\s*<string>(.*?)</string>")
907
+ if repo != main or directory != main:
908
+ report(f"{label} the job printed in {where} does not name the main checkout {main!r}: --repo {repo!r}, WorkingDirectory {directory!r}")
909
+ return 1
910
+ if os.path.realpath(wa) in printed.stdout:
911
+ report(f"{label} the job printed in {where} names the worktree {os.path.realpath(wa)!r}: {printed.stdout!r}")
912
+ return 1
913
+ for needle in ("declares no `patrol:`", "resumes ended sessions", "carries hand-overs out", "Keel creates nothing"):
914
+ if needle not in printed.stdout:
915
+ report(f"{label} the text printed in {where} does not say {needle!r}: {printed.stdout!r}")
916
+ return 1
917
+ ran = run_keel(rtl, "tick", "--repo", main, env=env)
918
+ if ran.returncode != 0:
919
+ report(f"{label} the printed command `keel tick --repo {main}` exits {ran.returncode}: {ran.stderr!r}")
920
+ return 1
921
+ if label.rstrip(":") not in {name for name, _ in registry.SCENARIOS}:
922
+ report(f"{label} the scenario registry does not include it.")
923
+ return 1
924
+ report(f"{label.rstrip(':')} scenario passed.")
925
+ return 0
926
+
927
+
928
+ def validate_tick_task_refuses_unreadable_patrol_scenario() -> int:
929
+ """Issue #509 D4: a `patrol:` Keel cannot read is shown, not treated as none."""
930
+ label = "tick-task-refuses-unreadable-patrol:"
931
+ with tempfile.TemporaryDirectory(prefix="keel-tick-509b-") as raw:
932
+ base = Path(raw)
933
+ rtl, _verify, env, _ = shift_scratch(base)
934
+ write_authorize_config(rtl, "patrol:\n role: rtl\n")
935
+ refused = run_keel(rtl, "tick", "task", env=env)
936
+ if refused.returncode == 0:
937
+ report(f"{label} keel tick task printed a job for a patrol it cannot read: {refused.stdout!r}")
938
+ return 1
939
+ if "<plist" in refused.stdout:
940
+ report(f"{label} a plist was printed for a patrol it cannot read: {refused.stdout!r}")
941
+ return 1
942
+ if not refused.stderr.strip():
943
+ report(f"{label} the refusal says nothing on stderr: {refused.stdout!r}")
944
+ return 1
945
+ if label.rstrip(":") not in {name for name, _ in registry.SCENARIOS}:
946
+ report(f"{label} the scenario registry does not include it.")
947
+ return 1
948
+ report(f"{label.rstrip(':')} scenario passed.")
949
+ return 0
950
+
951
+
883
952
  def validate_tick_skips_missing_bound_worktree_scenario() -> int:
884
953
  """Issue #503: a bound worktree that was removed does not stop the patrol.
885
954
 
package/src/core/tick.js CHANGED
@@ -59,10 +59,11 @@ function patrolWorktrees(where) {
59
59
  // bound worktree again. It stands in only when it exists and its
60
60
  // keel/config.yaml declares a `patrol:`, since that is the file `keel tick
61
61
  // --repo` reads; otherwise `dir` is null and `why` says which.
62
- function stableRepo(where) {
62
+ function stableRepo(where, patrolless = false) {
63
63
  if (path.basename(where.common) !== ".git") return { dir: null, why: "the repository has no main checkout" };
64
64
  const dir = path.dirname(where.common);
65
- if (!require("./config").readPatrolDeclarations(dir).declarations.length) return { dir: null, why: `the main checkout ${dir} declares no \`patrol:\`` };
65
+ // With no patrol anywhere nothing is read from it, so it stands in as it is (#509 D2).
66
+ if (!patrolless && !require("./config").readPatrolDeclarations(dir).declarations.length) return { dir: null, why: `the main checkout ${dir} declares no \`patrol:\`` };
66
67
  return { dir, why: null };
67
68
  }
68
69
 
@@ -306,14 +307,19 @@ function xml(text) {
306
307
  }
307
308
 
308
309
  function task(where) {
309
- const found = patrolWorktree(where);
310
- if (!found.worktree) throw new TickError(found.why);
310
+ // A repository that declares no patrol still gets a job: the tick's resume of
311
+ // ended sessions and its hand-over need none (#509 D1). A declaration Keel
312
+ // cannot read carries a message and is refused as before (D4).
313
+ const declared = require("./config").readPatrolDeclarations(where.worktree);
314
+ const patrolless = !declared.declarations.length && !declared.messages.length;
315
+ const found = patrolless ? { worktree: null, why: null } : patrolWorktree(where);
316
+ if (!patrolless && !found.worktree) throw new TickError(found.why);
311
317
  const label = `dev.keel.tick.${where.project.replace(/[^A-Za-z0-9.-]/g, "-")}`;
312
318
  const logs = path.join(where.root, "tick");
313
319
  // The job names the main checkout when it can stand in (#503 D1), so that
314
320
  // binding the role elsewhere or pruning a worktree changes nothing it names.
315
- const stable = stableRepo(where);
316
- const repo = stable.dir || found.worktree;
321
+ const stable = stableRepo(where, patrolless);
322
+ const repo = stable.dir || found.worktree || where.worktree;
317
323
  const args = [stableNode(), KEEL, "tick", "--repo", repo];
318
324
  const plist = [
319
325
  '<?xml version="1.0" encoding="UTF-8"?>',
@@ -331,7 +337,7 @@ function task(where) {
331
337
  "</plist>",
332
338
  ].join("\n");
333
339
  const target = path.join(os.homedir(), "Library", "LaunchAgents", `${label}.plist`);
334
- return { label, interval: INTERVAL_SECONDS, repo, stable: Boolean(stable.dir), why: stable.why, worktree: found.worktree, plist, target,
340
+ return { label, interval: INTERVAL_SECONDS, repo, stable: Boolean(stable.dir), why: stable.why, patrolless, worktree: found.worktree, plist, target,
335
341
  install: [`mkdir -p ${path.dirname(target)} && cat > ${target} <<'PLIST'\n${plist}\nPLIST`, `launchctl bootstrap gui/${process.getuid ? process.getuid() : "<uid>"} ${target}`] };
336
342
  }
337
343
 
@@ -339,9 +345,11 @@ function renderTask(job) {
339
345
  // The main checkout is named when it can stand in, and the tick finds each
340
346
  // role's bound worktree on every run; otherwise the worktree is named, and
341
347
  // the job stops working if that worktree moves (#503).
342
- const where = job.stable
343
- ? `in the main checkout ${job.repo}, and the tick runs each declared patrol in the worktree its role is bound to when due, so binding a role elsewhere needs no new job`
344
- : `in the worktree ${job.repo}, because ${job.why}; the job stops working if that worktree is moved or pruned, so declare the \`patrol:\` in the main checkout and print it again`;
348
+ const where = job.patrolless
349
+ ? `in ${job.stable ? "the main checkout" : "the worktree"} ${job.repo}; keel/config.yaml declares no \`patrol:\`, so each run resumes ended sessions and carries hand-overs out and runs no patrol${job.stable ? "" : `, and the job stops working if that worktree is moved or pruned (${job.why})`}`
350
+ : job.stable
351
+ ? `in the main checkout ${job.repo}, and the tick runs each declared patrol in the worktree its role is bound to when due, so binding a role elsewhere needs no new job`
352
+ : `in the worktree ${job.repo}, because ${job.why}; the job stops working if that worktree is moved or pruned, so declare the \`patrol:\` in the main checkout and print it again`;
345
353
  return [
346
354
  `launchd job for \`keel tick\` (label ${job.label}): it calls \`keel tick\` every ${job.interval} s ${where}. Keel creates nothing: install it with the two commands below.`,
347
355
  "",