@caddis/cli 0.4.87 → 0.4.89

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 (81) hide show
  1. package/README.md +46 -0
  2. package/bundles/antigravity-plugin/agents/preflight.md +4 -0
  3. package/bundles/antigravity-plugin/plugin.json +1 -1
  4. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_exit.cpython-311.pyc +0 -0
  5. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_file_lock.cpython-311.pyc +0 -0
  6. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_frontmatter.cpython-311.pyc +0 -0
  7. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_redact.cpython-311.pyc +0 -0
  8. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_roadmap.cpython-311.pyc +0 -0
  9. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_rows.cpython-311.pyc +0 -0
  10. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_status.cpython-311.pyc +0 -0
  11. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_tidy.cpython-311.pyc +0 -0
  12. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_todo.cpython-311.pyc +0 -0
  13. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_workstreams.cpython-311.pyc +0 -0
  14. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_worktree_safety.cpython-311.pyc +0 -0
  15. package/bundles/antigravity-plugin/scripts/caddis_fleet.py +28 -6
  16. package/bundles/antigravity-plugin/scripts/caddis_guide.json +2418 -0
  17. package/bundles/antigravity-plugin/scripts/caddis_handoff.py +370 -0
  18. package/bundles/antigravity-plugin/scripts/caddis_heartbeat.py +339 -0
  19. package/bundles/antigravity-plugin/scripts/caddis_hub_collect.py +60 -9
  20. package/bundles/antigravity-plugin/scripts/caddis_routing.py +36 -0
  21. package/bundles/antigravity-plugin/scripts/caddis_todo.py +101 -12
  22. package/bundles/antigravity-plugin/scripts/schemas/hub-collect.schema.json +46 -0
  23. package/bundles/antigravity-plugin/scripts/schemas/hub-plans.schema.json +27 -0
  24. package/bundles/antigravity-plugin/session_end_agy.py +26 -1
  25. package/bundles/antigravity-plugin/skills/coordinate/SKILL.md +5 -3
  26. package/bundles/antigravity-plugin/skills/feature-plan/SKILL.md +47 -19
  27. package/bundles/antigravity-plugin/skills/fleet-open/SKILL.md +1 -1
  28. package/bundles/antigravity-plugin/skills/handoff/SKILL.md +77 -6
  29. package/bundles/antigravity-plugin/skills/implement/SKILL.md +67 -5
  30. package/bundles/antigravity-plugin/warm_start_agy.py +29 -1
  31. package/bundles/manifest.json +2 -2
  32. package/dist/allowed-urls.txt +3 -2
  33. package/dist/cli.js +545 -274
  34. package/dist/export/assets/export-B7BBDg5I.js +150 -0
  35. package/dist/export/assets/export-HxTgj3z2.css +1 -0
  36. package/dist/export/assets/mark-anim-DZa95SHo.webp +0 -0
  37. package/dist/export/assets/mark-still-CcPgBc_-.png +0 -0
  38. package/dist/export/fonts/ibm-plex-mono-400.6d569bb7.woff2 +0 -0
  39. package/dist/export/fonts/ibm-plex-mono-700.9f478677.woff2 +0 -0
  40. package/dist/export/fonts/ibm-plex-sans-400.17fc1ce7.woff2 +0 -0
  41. package/dist/export/fonts/ibm-plex-sans-500.dcc69acf.woff2 +0 -0
  42. package/dist/export/fonts/ibm-plex-sans-600.d4dad061.woff2 +0 -0
  43. package/dist/export/fonts/ibm-plex-sans-700.40d9a530.woff2 +0 -0
  44. package/dist/export/index.html +2 -2
  45. package/dist/export/licenses/{OFL-MapleMono.txt → OFL-IBMPlexMono.txt} +4 -4
  46. package/dist/{ui/licenses/OFL-MapleMono.txt → export/licenses/OFL-IBMPlexSans.txt} +4 -4
  47. package/dist/ui/assets/{Activity-BgqFFOv1.js → Activity-DZKPMOeV.js} +1 -1
  48. package/dist/ui/assets/Guide-5ZFfL6sl.js +9 -0
  49. package/dist/ui/assets/Guide-Dnsb-TRd.css +1 -0
  50. package/dist/ui/assets/RoadmapTab-DPsiSmIF.js +31 -0
  51. package/dist/ui/assets/index-DGlNAmeA.css +1 -0
  52. package/dist/ui/assets/index-xl156OCN.js +231 -0
  53. package/dist/ui/assets/mark-anim-DZa95SHo.webp +0 -0
  54. package/dist/ui/assets/mark-still-CcPgBc_-.png +0 -0
  55. package/dist/ui/fonts/ibm-plex-mono-400.6d569bb7.woff2 +0 -0
  56. package/dist/ui/fonts/ibm-plex-mono-700.9f478677.woff2 +0 -0
  57. package/dist/ui/fonts/ibm-plex-sans-400.17fc1ce7.woff2 +0 -0
  58. package/dist/ui/fonts/ibm-plex-sans-500.dcc69acf.woff2 +0 -0
  59. package/dist/ui/fonts/ibm-plex-sans-600.d4dad061.woff2 +0 -0
  60. package/dist/ui/fonts/ibm-plex-sans-700.40d9a530.woff2 +0 -0
  61. package/dist/ui/index.html +2 -2
  62. package/dist/{export/licenses/OFL-Atkinson.txt → ui/licenses/OFL-IBMPlexMono.txt} +3 -3
  63. package/dist/ui/licenses/{OFL-Atkinson.txt → OFL-IBMPlexSans.txt} +3 -3
  64. package/package.json +4 -1
  65. package/dist/export/assets/export-Dro73_I7.js +0 -150
  66. package/dist/export/assets/export-N0paGhbL.css +0 -1
  67. package/dist/export/assets/mark-small-CwCIyjyC.svg +0 -8
  68. package/dist/export/fonts/atkinson-400.849ae6f0.woff2 +0 -0
  69. package/dist/export/fonts/atkinson-700.3a9cc18a.woff2 +0 -0
  70. package/dist/export/fonts/maple-mono-400.071799fd.woff2 +0 -0
  71. package/dist/export/fonts/maple-mono-700.1e17b237.woff2 +0 -0
  72. package/dist/ui/assets/Guide-Df0Kg8wI.js +0 -9
  73. package/dist/ui/assets/Guide-zcVFGUxR.css +0 -1
  74. package/dist/ui/assets/RoadmapTab-CV7WCGBL.js +0 -31
  75. package/dist/ui/assets/index-DEge93wH.css +0 -1
  76. package/dist/ui/assets/index-DQbpiY2a.js +0 -221
  77. package/dist/ui/assets/mark-small-CwCIyjyC.svg +0 -8
  78. package/dist/ui/fonts/atkinson-400.849ae6f0.woff2 +0 -0
  79. package/dist/ui/fonts/atkinson-700.3a9cc18a.woff2 +0 -0
  80. package/dist/ui/fonts/maple-mono-400.071799fd.woff2 +0 -0
  81. package/dist/ui/fonts/maple-mono-700.1e17b237.woff2 +0 -0
@@ -0,0 +1,370 @@
1
+ """The checkpoint tier of /caddis:handoff: a cheap mid-phase handoff in two calls.
2
+
3
+ PREPARE (`checkpoint --session-id <id> [--name <ws>] [--plan <path> --phase <id>]`) reads the relay hash
4
+ BEFORE the model composes the new relay, and prints the exact FINISH command. FINISH (`--relay-file` given)
5
+ writes the relay with `put --require-status --expected-hash`, so a peer's change made in between is never
6
+ overwritten, runs the cheap checklist rows, and prints the resume block as its last output.
7
+
8
+ Refusals (exit 1): a headless session (`CADDIS_HEADLESS`), the coordinator's relay, a coordinator check that
9
+ cannot run or cannot be read (the safe side is to refuse), FINISH without `--idle`, a failed relay write, and a
10
+ relay over the 4,000-character budget. After the relay is written, a late error (no resume block, an exception)
11
+ exits 1 with the last line `ERROR after relay write: ...`; FINISH still prints the resume block when it can. In a shared checkout the checkpoint changes
12
+ no tracked file (the Tracker row is skipped; card state goes in the local relay). Siblings run as subprocesses
13
+ with `sys.executable`, found in this script's dir, then `<dir>/../claude-harness/scripts` (source tree).
14
+ A missing sibling degrades open (`skipped: <script> not installed`), except the relay write, the coordinator
15
+ check and the resume block.
16
+ """
17
+
18
+ from __future__ import annotations
19
+
20
+ import argparse
21
+ import json
22
+ import os
23
+ from pathlib import Path
24
+ import re
25
+ import subprocess
26
+ import sys
27
+ import tempfile
28
+
29
+ BUDGET = 4000
30
+ HEADLESS_VALUES = {"1", "true", "yes", "on"}
31
+ ROWS = ("knowledge-transfer", "plan-tracker", "relay", "tasks-file", "kb-index", "violations-report",
32
+ "usage-record", "tidy-apply", "state-prune", "prune-list", "handover-check", "own-cleanup")
33
+ CHECKPOINT_TIER_ROWS = ("kb-index", "violations-report", "tidy-apply", "state-prune", "prune-list", "own-cleanup")
34
+ SHARED_SKIP = "skipped: shared checkout (card state is in the relay)"
35
+ _HERE = Path(__file__).resolve().parent
36
+
37
+
38
+ def _sibling(name: str) -> Path | None:
39
+ for folder in (_HERE, _HERE.parent / "claude-harness" / "scripts"):
40
+ path = folder / name
41
+ if path.is_file():
42
+ return path
43
+ return None
44
+
45
+
46
+ def _run(script: str, *args: str) -> subprocess.CompletedProcess | None:
47
+ """Run a sibling script; None when it is not installed. Never `python -I` (siblings import siblings)."""
48
+ path = _sibling(script)
49
+ if path is None:
50
+ return None
51
+ return subprocess.run([sys.executable, str(path), *args], capture_output=True, text=True,
52
+ encoding="utf-8", errors="replace")
53
+
54
+
55
+ def _output(res: subprocess.CompletedProcess) -> str:
56
+ return ((res.stdout or "") + (res.stderr or "")).strip()
57
+
58
+
59
+ def _headless() -> bool:
60
+ return os.environ.get("CADDIS_HEADLESS", "").strip().lower() in HEADLESS_VALUES
61
+
62
+
63
+ def _git(*args: str) -> str | None:
64
+ try:
65
+ res = subprocess.run(["git", *args], capture_output=True, text=True, encoding="utf-8", errors="replace")
66
+ except OSError:
67
+ return None
68
+ return res.stdout.strip() if res.returncode == 0 else None
69
+
70
+
71
+ def _resolve_name(args: argparse.Namespace) -> str | None:
72
+ if args.name:
73
+ return args.name
74
+ extra = ["--plan", Path(args.plan).stem] if args.plan else []
75
+ branch = _git("rev-parse", "--abbrev-ref", "HEAD")
76
+ if not extra and branch and branch != "HEAD":
77
+ # On the default branch there is no workstream name: without --default-branch the resolver names it `branch.main`.
78
+ head = _git("symbolic-ref", "--short", "refs/remotes/origin/HEAD") or ""
79
+ extra = ["--branch", branch, "--default-branch", head.split("/", 1)[-1] if head else "main"]
80
+ res = _run("caddis_workstreams.py", "resolve", *extra)
81
+ if res is None or res.returncode != 0:
82
+ return None
83
+ return res.stdout.strip() or None
84
+
85
+
86
+ _NO_COORDINATOR = "no coordinator config"
87
+
88
+
89
+ def _coordinator_relay() -> tuple[bool, str | None]:
90
+ """(known, relay). known is False when the check cannot run or its answer cannot be read."""
91
+ res = _run("caddis_coordinate.py", "config", "show", "--path", ".", "--json")
92
+ if res is None:
93
+ return False, "caddis_coordinate.py not installed"
94
+ if res.returncode != 0:
95
+ out = _output(res)
96
+ if _NO_COORDINATOR in out:
97
+ return True, None
98
+ return False, out[:200] or f"exit {res.returncode}"
99
+ try:
100
+ data = json.loads(res.stdout)
101
+ except ValueError:
102
+ return False, "config show did not print JSON"
103
+ if not isinstance(data, dict):
104
+ return False, "config show did not print a JSON object"
105
+ relay = data.get("relay")
106
+ return True, relay if isinstance(relay, str) else None
107
+
108
+
109
+ def _own_files(session_id: str) -> list[str]:
110
+ """The `## Files changed this session` list of the session state file (handoff Step 0, point 1)."""
111
+ path = Path(".caddis") / "session-state" / f"{session_id}.md"
112
+ try:
113
+ lines = path.read_text(encoding="utf-8").splitlines()
114
+ except (OSError, ValueError):
115
+ return []
116
+ out, inside = [], False
117
+ for line in lines:
118
+ if line.startswith("## "):
119
+ inside = line.strip() == "## Files changed this session"
120
+ elif inside and line.strip().startswith("- "):
121
+ out.append(line.strip())
122
+ return out
123
+
124
+
125
+ def _shared(session_id: str) -> str:
126
+ """`no`, `yes <reason>`, or `unknown (<why>)`. FINISH treats anything but `no` as shared."""
127
+ fd, tmp = tempfile.mkstemp(prefix="caddis-own-files-", suffix=".txt")
128
+ try:
129
+ with os.fdopen(fd, "w", encoding="utf-8") as handle:
130
+ handle.write("\n".join(_own_files(session_id)) + "\n")
131
+ res = _run("caddis_checkout_guard.py", "shared", "--root", ".", "--own-files", tmp)
132
+ finally:
133
+ try:
134
+ os.unlink(tmp)
135
+ except OSError:
136
+ pass
137
+ if res is None:
138
+ return "unknown (caddis_checkout_guard.py not installed)"
139
+ for line in res.stdout.splitlines():
140
+ if line.startswith("SHARED: "):
141
+ return line[len("SHARED: "):].strip()
142
+ return "unknown (" + (_output(res)[:200] or "no answer") + ")"
143
+
144
+
145
+ def _tasks_file(session_id: str, name: str) -> tuple[str, str]:
146
+ """Run `session_state.py tasks-file`; return (row status, tasks line text)."""
147
+ res = _run("session_state.py", "tasks-file", "--session-id", session_id, "--relay", name)
148
+ if res is None:
149
+ status = "skipped: session_state.py not installed"
150
+ elif res.returncode != 0:
151
+ status = "failed: " + (_output(res)[:200] or f"exit {res.returncode}")
152
+ else:
153
+ status = "done"
154
+ rel = f".caddis/relay/{name}.tasks.md"
155
+ if Path(rel).is_file():
156
+ return status, f"{rel} (put this line in the resume prompt: Load every row of {rel} with TaskCreate.)"
157
+ return status, "none"
158
+
159
+
160
+ def _refusals(name: str) -> int | None:
161
+ if _headless():
162
+ print("CHECKPOINT: refused headless: return BLOCKED with your state")
163
+ return 1
164
+ known, relay = _coordinator_relay()
165
+ if not known:
166
+ print(f"CHECKPOINT: cannot tell if {name} is the coordinator relay ({relay}): run /caddis:handoff")
167
+ return 1
168
+ if name == relay:
169
+ print("CHECKPOINT: coordinator: run /caddis:handoff")
170
+ return 1
171
+ return None
172
+
173
+
174
+ def prepare(args: argparse.Namespace) -> int:
175
+ if _headless():
176
+ print("CHECKPOINT: refused headless: return BLOCKED with your state")
177
+ return 1
178
+ name = _resolve_name(args)
179
+ if not name:
180
+ print("CHECKPOINT: no workstream name: pass --name <ws>")
181
+ return 1
182
+ refused = _refusals(name)
183
+ if refused is not None:
184
+ return refused
185
+ hashed = _run("caddis_workstreams.py", "hash", name, "--root", ".")
186
+ if hashed is None or hashed.returncode != 0:
187
+ why = "caddis_workstreams.py not installed" if hashed is None else _output(hashed)[:200]
188
+ print(f"CHECKPOINT: cannot read the relay hash: {why}")
189
+ return 1
190
+ digest = hashed.stdout.strip() or "none"
191
+ shared = _shared(args.session_id)
192
+ _status, tasks = _tasks_file(args.session_id, name)
193
+ plan = f" --plan {args.plan} --phase {args.phase}" if args.plan and args.phase else ""
194
+ print(f"workstream: {name}")
195
+ print(f"relay: .caddis/relay/{name}.md")
196
+ print(f"hash: {digest}")
197
+ print(f"shared: {shared}")
198
+ print(f"tasks: {tasks}")
199
+ print(f"budget: {BUDGET}")
200
+ print("format: the relay file needs frontmatter (type: relay, workstream, branch, plan, session_id, generated.at), a `## Resume prompt` section with one fenced block, and a last line `STATUS: CONTINUE` (or OWNER-GATE, BLOCKED, FAILED)")
201
+ print(f'next: python "{Path(__file__).resolve()}" checkpoint --session-id {args.session_id} --name {name} '
202
+ f"--relay-file <tmp> --expected-hash {digest} --kt <done|skipped:reason> --idle{plan}")
203
+ return 0
204
+
205
+
206
+ def _tracker_row(plan: str | None, phase: str | None, shared: str) -> str:
207
+ if shared != "no":
208
+ return SHARED_SKIP
209
+ if not plan or not phase:
210
+ return "skipped: no --plan and --phase"
211
+ try:
212
+ lines = Path(plan).read_text(encoding="utf-8").splitlines()
213
+ except (OSError, ValueError) as exc:
214
+ return f"failed: cannot read {plan}: {exc}"
215
+ pattern = re.compile(rf"^(phase\s+)?{re.escape(phase)}(\s|$)", re.IGNORECASE)
216
+ inside = False
217
+ for line in lines:
218
+ if line.startswith("## "):
219
+ inside = line.strip().lower().startswith("## tracker")
220
+ elif inside and line.lstrip().startswith("|"):
221
+ cells = [c.strip() for c in line.strip().strip("|").split("|")]
222
+ if cells and pattern.match(cells[0]):
223
+ if "in progress" in line.lower():
224
+ return "done"
225
+ return f"failed: the Tracker row for phase {phase} does not say in progress"
226
+ return f"failed: no Tracker row for phase {phase} in {plan}"
227
+
228
+
229
+ def _kt_row(kt: str | None) -> str:
230
+ if kt == "done":
231
+ return "done"
232
+ if kt and kt.startswith("skipped:"):
233
+ return kt if kt.startswith("skipped: ") else "skipped: " + kt[len("skipped:"):].strip()
234
+ return "failed: --kt must be done or skipped:<reason>"
235
+
236
+
237
+ def _checklist(rows: dict[str, str]) -> None:
238
+ print("=== CHECKPOINT CHECKLIST ===")
239
+ for i, name in enumerate(ROWS, start=1):
240
+ print(f"{i:>2} {name:<18} {rows.get(name, 'skipped: not run')}")
241
+
242
+
243
+ def finish(args: argparse.Namespace) -> int:
244
+ if _headless():
245
+ print("CHECKPOINT: refused headless: return BLOCKED with your state")
246
+ return 1
247
+ if not args.idle:
248
+ print("CHECKPOINT: wait until no agent or background command runs")
249
+ return 1
250
+ if not args.name or not args.expected_hash:
251
+ print("CHECKPOINT: finish needs --name and --expected-hash (run prepare first)")
252
+ return 1
253
+ refused = _refusals(args.name)
254
+ if refused is not None:
255
+ return refused
256
+ name, rows = args.name, {}
257
+ try:
258
+ rows["knowledge-transfer"] = _kt_row(args.kt)
259
+ rows["plan-tracker"] = _tracker_row(args.plan, args.phase, _shared(args.session_id))
260
+
261
+ # `put` accepts `none` (lower case) or a lower-case SHA-256 hex digest.
262
+ expected = args.expected_hash.strip().lower()
263
+ put = _run("caddis_workstreams.py", "put", name, args.relay_file, "--require-status",
264
+ "--expected-hash", expected, "--session-id", args.session_id, "--root", ".")
265
+ except Exception as exc: # no traceback: the next step must be a clear line, and nothing was written
266
+ print(f"CHECKPOINT: error before the relay write: {type(exc).__name__}: {exc}; the relay was not written")
267
+ return 1
268
+ if put is None or put.returncode != 0:
269
+ print(_output(put) if put is not None else "caddis_workstreams.py not installed")
270
+ print("CHECKPOINT: row 3 relay failed: the relay was not written; nothing after it ran")
271
+ return 1
272
+ print(f"relay written: .caddis/relay/{name}.md")
273
+ state = {"resume": False}
274
+ try:
275
+ return _after_put(args, name, rows, state)
276
+ except Exception as exc: # the relay is written: never exit 0 without the resume text
277
+ if not state["resume"]:
278
+ try:
279
+ _resume_block(name, args.session_id, state)
280
+ except Exception:
281
+ pass
282
+ _late_error(f"{type(exc).__name__}: {exc}")
283
+ return 1
284
+
285
+
286
+ def _late_error(reason: str) -> None:
287
+ print(f"ERROR after relay write: {reason}; the relay IS written, resume with the printed relay path")
288
+
289
+
290
+ def _resume_block(name: str, session_id: str, state: dict) -> str | None:
291
+ """Print the resume block; return None when printed, else the reason it could not be built."""
292
+ block = _run("caddis_fleet.py", "resume-block", "--name", name, "--session-id", session_id, "--root", ".")
293
+ if block is None:
294
+ return "caddis_fleet.py not installed, no resume block"
295
+ sys.stdout.write(block.stdout)
296
+ if block.returncode != 0:
297
+ sys.stdout.write(block.stderr)
298
+ return "resume-block failed: " + ((block.stderr or "").strip()[:200] or f"exit {block.returncode}")
299
+ state["resume"] = "=== RESUME ===" in block.stdout
300
+ return None
301
+
302
+
303
+ def _after_put(args: argparse.Namespace, name: str, rows: dict[str, str], state: dict) -> int:
304
+ rows["relay"] = "done"
305
+ index = _run("caddis_workstreams.py", "render-index", "--session-id", args.session_id, "--root", ".")
306
+ if index is not None and index.returncode != 0:
307
+ rows["relay"] = "done (render-index failed: " + _output(index)[:160] + ")"
308
+
309
+ rows["tasks-file"], _tasks = _tasks_file(args.session_id, name)
310
+
311
+ gate = _run("caddis_gate.py", "handover-check", "--doc", f".caddis/relay/{name}.md", "--repo-root", ".",
312
+ "--max-chars", str(BUDGET))
313
+ if gate is None:
314
+ rows["handover-check"] = "skipped: caddis_gate.py not installed"
315
+ elif gate.returncode != 0:
316
+ rows["handover-check"] = "failed: " + (_output(gate)[:200] or f"exit {gate.returncode}")
317
+ print(_output(gate))
318
+ _checklist(rows)
319
+ print(f"CHECKPOINT: handover-check failed: fix .caddis/relay/{name}.md (budget {BUDGET}), then run "
320
+ "the hash and the finish again")
321
+ return 1
322
+ else:
323
+ rows["handover-check"] = "done"
324
+
325
+ usage = _run("session_state.py", "usage", "--session-id", args.session_id)
326
+ if usage is None:
327
+ rows["usage-record"] = "skipped: session_state.py not installed"
328
+ elif usage.returncode != 0:
329
+ rows["usage-record"] = "failed: " + (_output(usage)[:200] or f"exit {usage.returncode}")
330
+ else:
331
+ rows["usage-record"] = "done"
332
+ for row in CHECKPOINT_TIER_ROWS:
333
+ rows[row] = "skipped: checkpoint tier"
334
+
335
+ if args.plan and _git("status", "--porcelain", "--", args.plan):
336
+ print("plan file modified, not committed")
337
+ _checklist(rows)
338
+ failed = _resume_block(name, args.session_id, state)
339
+ if failed is not None:
340
+ _late_error(failed)
341
+ return 1
342
+ return 0
343
+
344
+
345
+ def main(argv: list[str] | None = None) -> int:
346
+ try:
347
+ sys.stdout.reconfigure(encoding="utf-8")
348
+ except (AttributeError, ValueError):
349
+ pass
350
+ parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
351
+ sub = parser.add_subparsers(dest="cmd", required=True)
352
+ p = sub.add_parser("checkpoint", help="prepare (no --relay-file) or finish (--relay-file) a checkpoint")
353
+ p.add_argument("--session-id", required=True)
354
+ p.add_argument("--name", help="workstream name (default: caddis_workstreams.py resolve)")
355
+ p.add_argument("--plan")
356
+ p.add_argument("--phase")
357
+ p.add_argument("--relay-file", help="FINISH: the new relay text, written by the Write tool")
358
+ p.add_argument("--expected-hash", help="FINISH: the hash PREPARE printed")
359
+ p.add_argument("--kt", help="FINISH: done | skipped:<reason>")
360
+ p.add_argument("--idle", action="store_true", help="FINISH: no agent or background command runs")
361
+ args = parser.parse_args(argv)
362
+ try:
363
+ return finish(args) if args.relay_file else prepare(args)
364
+ except Exception as exc: # documented: internal errors exit 0, with no RESUME block
365
+ print(f"CHECKPOINT: internal error: {exc}")
366
+ return 0
367
+
368
+
369
+ if __name__ == "__main__":
370
+ sys.exit(main())