@caddis/cli 0.4.88 → 0.4.90
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.
- package/README.md +46 -0
- package/bundles/antigravity-plugin/agents/preflight.md +4 -0
- package/bundles/antigravity-plugin/plugin.json +1 -1
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_exit.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_file_lock.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_frontmatter.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_redact.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_roadmap.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_rows.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_status.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_tidy.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_todo.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_workstreams.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/__pycache__/caddis_worktree_safety.cpython-311.pyc +0 -0
- package/bundles/antigravity-plugin/scripts/caddis_fleet.py +37 -10
- package/bundles/antigravity-plugin/scripts/caddis_guide.json +16 -11
- package/bundles/antigravity-plugin/scripts/caddis_handoff.py +370 -0
- package/bundles/antigravity-plugin/scripts/caddis_heartbeat.py +339 -0
- package/bundles/antigravity-plugin/scripts/caddis_hub_collect.py +37 -8
- package/bundles/antigravity-plugin/scripts/caddis_roadmap_run.py +130 -63
- package/bundles/antigravity-plugin/scripts/caddis_routing.py +36 -0
- package/bundles/antigravity-plugin/scripts/caddis_todo.py +55 -10
- package/bundles/antigravity-plugin/scripts/caddis_workstreams.py +35 -12
- package/bundles/antigravity-plugin/scripts/schemas/hub-collect.schema.json +42 -0
- package/bundles/antigravity-plugin/scripts/schemas/hub-plans.schema.json +23 -0
- package/bundles/antigravity-plugin/session_end_agy.py +26 -1
- package/bundles/antigravity-plugin/skills/code-review/SKILL.md +2 -0
- package/bundles/antigravity-plugin/skills/coordinate/SKILL.md +5 -3
- package/bundles/antigravity-plugin/skills/cross-review/SKILL.md +1 -0
- package/bundles/antigravity-plugin/skills/feature-plan/SKILL.md +47 -19
- package/bundles/antigravity-plugin/skills/fleet-open/SKILL.md +1 -1
- package/bundles/antigravity-plugin/skills/handoff/SKILL.md +82 -7
- package/bundles/antigravity-plugin/skills/implement/SKILL.md +86 -6
- package/bundles/antigravity-plugin/skills/park/SKILL.md +1 -0
- package/bundles/antigravity-plugin/skills/preflight/SKILL.md +1 -0
- package/bundles/antigravity-plugin/skills/roadmap/assets/plan-resume-prompt.md +8 -1
- package/bundles/antigravity-plugin/warm_start_agy.py +29 -1
- package/bundles/antigravity-plugin-extras/plugin.json +1 -1
- package/bundles/antigravity-plugin-extras/skills/cross-review/SKILL.md +1 -0
- package/bundles/codex/.codex/skills/coding/code-review/SKILL.md +2 -0
- package/bundles/codex/.codex/skills/workflow/preflight/SKILL.md +1 -0
- package/bundles/codex/.codex/skills/workflow/roadmap/assets/plan-resume-prompt.md +8 -1
- package/bundles/manifest.json +3 -3
- package/dist/allowed-urls.txt +3 -2
- package/dist/cli.js +554 -275
- package/dist/export/assets/export-B7BBDg5I.js +150 -0
- package/dist/export/assets/export-HxTgj3z2.css +1 -0
- package/dist/export/assets/mark-anim-DZa95SHo.webp +0 -0
- package/dist/export/assets/mark-still-CcPgBc_-.png +0 -0
- package/dist/export/fonts/ibm-plex-mono-400.6d569bb7.woff2 +0 -0
- package/dist/export/fonts/ibm-plex-mono-700.9f478677.woff2 +0 -0
- package/dist/export/fonts/ibm-plex-sans-400.17fc1ce7.woff2 +0 -0
- package/dist/export/fonts/ibm-plex-sans-500.dcc69acf.woff2 +0 -0
- package/dist/export/fonts/ibm-plex-sans-600.d4dad061.woff2 +0 -0
- package/dist/export/fonts/ibm-plex-sans-700.40d9a530.woff2 +0 -0
- package/dist/export/index.html +2 -2
- package/dist/export/licenses/{OFL-MapleMono.txt → OFL-IBMPlexMono.txt} +4 -4
- package/dist/{ui/licenses/OFL-MapleMono.txt → export/licenses/OFL-IBMPlexSans.txt} +4 -4
- package/dist/ui/assets/{Activity-C9TCizJV.js → Activity-DZKPMOeV.js} +1 -1
- package/dist/ui/assets/Guide-5ZFfL6sl.js +9 -0
- package/dist/ui/assets/Guide-Dnsb-TRd.css +1 -0
- package/dist/ui/assets/RoadmapTab-DPsiSmIF.js +31 -0
- package/dist/ui/assets/index-DGlNAmeA.css +1 -0
- package/dist/ui/assets/index-xl156OCN.js +231 -0
- package/dist/ui/assets/mark-anim-DZa95SHo.webp +0 -0
- package/dist/ui/assets/mark-still-CcPgBc_-.png +0 -0
- package/dist/ui/fonts/ibm-plex-mono-400.6d569bb7.woff2 +0 -0
- package/dist/ui/fonts/ibm-plex-mono-700.9f478677.woff2 +0 -0
- package/dist/ui/fonts/ibm-plex-sans-400.17fc1ce7.woff2 +0 -0
- package/dist/ui/fonts/ibm-plex-sans-500.dcc69acf.woff2 +0 -0
- package/dist/ui/fonts/ibm-plex-sans-600.d4dad061.woff2 +0 -0
- package/dist/ui/fonts/ibm-plex-sans-700.40d9a530.woff2 +0 -0
- package/dist/ui/index.html +2 -2
- package/dist/{export/licenses/OFL-Atkinson.txt → ui/licenses/OFL-IBMPlexMono.txt} +3 -3
- package/dist/ui/licenses/{OFL-Atkinson.txt → OFL-IBMPlexSans.txt} +3 -3
- package/package.json +4 -1
- package/dist/export/assets/export-CEtCs5rg.css +0 -1
- package/dist/export/assets/export-v-kcNvPW.js +0 -150
- package/dist/export/assets/mark-small-B1q4Vk3J.svg +0 -8
- package/dist/export/fonts/atkinson-400.849ae6f0.woff2 +0 -0
- package/dist/export/fonts/atkinson-500.21d6ef26.woff2 +0 -0
- package/dist/export/fonts/atkinson-600.ce9f3210.woff2 +0 -0
- package/dist/export/fonts/atkinson-700.3a9cc18a.woff2 +0 -0
- package/dist/export/fonts/maple-mono-400.071799fd.woff2 +0 -0
- package/dist/export/fonts/maple-mono-700.1e17b237.woff2 +0 -0
- package/dist/ui/assets/Guide-6aEYW9oW.js +0 -9
- package/dist/ui/assets/Guide-zcVFGUxR.css +0 -1
- package/dist/ui/assets/RoadmapTab-hUK2kzCW.js +0 -31
- package/dist/ui/assets/index-DE7v-v_o.css +0 -1
- package/dist/ui/assets/index-d44hkSAE.js +0 -221
- package/dist/ui/assets/mark-small-B1q4Vk3J.svg +0 -8
- package/dist/ui/fonts/atkinson-400.849ae6f0.woff2 +0 -0
- package/dist/ui/fonts/atkinson-500.21d6ef26.woff2 +0 -0
- package/dist/ui/fonts/atkinson-600.ce9f3210.woff2 +0 -0
- package/dist/ui/fonts/atkinson-700.3a9cc18a.woff2 +0 -0
- package/dist/ui/fonts/maple-mono-400.071799fd.woff2 +0 -0
- package/dist/ui/fonts/maple-mono-700.1e17b237.woff2 +0 -0
package/README.md
CHANGED
|
@@ -132,6 +132,52 @@ caddis update --extras # add extras to an existing install
|
|
|
132
132
|
The first run. Detects, shows exactly what it is about to run, asks, then installs. `--yes` skips
|
|
133
133
|
the prompt for CI.
|
|
134
134
|
|
|
135
|
+
### `caddis hub`
|
|
136
|
+
|
|
137
|
+
A local web page (127.0.0.1 only) with your repos, PRs, plans and live sessions. `caddis hub start`
|
|
138
|
+
starts it in the background; `caddis hub stop` stops it.
|
|
139
|
+
|
|
140
|
+
**Logins that last.** Run `caddis hub open` to get a one-time login code and open the hub. Your session lasts 7 days without use and 30 days at most, and it survives a hub restart.
|
|
141
|
+
|
|
142
|
+
**Timeline first, Board second.** Roadmaps and plans open on the Timeline view by default, with the Board view as the second option. Click any phase tile on the Timeline to open the phase panel and read its Tracker status, PR links and plan section text.
|
|
143
|
+
|
|
144
|
+
**Guide Poster and Details.** The Guide page has a `Poster` tab (with `Workflow` and `Mind map` views, plus a `Print` button for a two-page A3 landscape wall poster) and a `Details` tab. Every item on the poster links to its entry in Details.
|
|
145
|
+
|
|
146
|
+
**Sessions from more than one agent.** Claude Code sessions come from `claude agents --json`. agy
|
|
147
|
+
(Antigravity) sessions come from the caddis agy hooks: each agy turn writes a status file, and the
|
|
148
|
+
hub lists that session with an `agy` chip. A turn that starts sets `working`. A turn that ends sets
|
|
149
|
+
`waiting` (waiting for you, after 45 s). A session that has not written for 10 minutes shows as
|
|
150
|
+
`idle`, unless it waits and its agy process still runs. The hub drops a session when its process
|
|
151
|
+
stops or when it has not written for 24 hours. Headless runs (`CADDIS_HEADLESS`) write nothing.
|
|
152
|
+
|
|
153
|
+
Any other agent can show its sessions the same way. Write one JSON file per session to
|
|
154
|
+
`~/.caddis/sessions/<session-id>.json` (`CADDIS_HOME` replaces the home folder). Write a temp file
|
|
155
|
+
in that folder, then rename it over the target:
|
|
156
|
+
|
|
157
|
+
```json
|
|
158
|
+
{
|
|
159
|
+
"session_id": "c0ffee-1234",
|
|
160
|
+
"harness": "my-agent",
|
|
161
|
+
"caddis_version": "1.3.200",
|
|
162
|
+
"pid": 4242,
|
|
163
|
+
"started": 1793000000.0,
|
|
164
|
+
"last_seen": 1793000300.0,
|
|
165
|
+
"status": "waiting",
|
|
166
|
+
"status_since": 1793000300.0,
|
|
167
|
+
"cwd": "/work/shop",
|
|
168
|
+
"repo_path": "/work/shop",
|
|
169
|
+
"waiting_for": "input needed"
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
- Times are Unix seconds. `status` is `working` or `waiting`; the hub ignores a file without one.
|
|
174
|
+
- `pid` is the agent's own process, or `null` when it is not known. With a pid, the hub drops the
|
|
175
|
+
session when that process stops. Without one, only the times count.
|
|
176
|
+
- `harness` names the agent. The hub skips `claude`, because Claude Code sessions come from
|
|
177
|
+
`claude agents`.
|
|
178
|
+
- `cwd` puts the session under its repo. `waiting_for` is a short reason; it is shown when waiting.
|
|
179
|
+
- The first six keys are the session heartbeat that `caddis doctor` already reads. Do not remove them.
|
|
180
|
+
|
|
135
181
|
### Removing caddis
|
|
136
182
|
|
|
137
183
|
**There is no `caddis remove`.** This CLI installs and updates; it never uninstalls. Removal goes
|
|
@@ -23,6 +23,10 @@ For the plan (or the named phase) check each claim against the codebase:
|
|
|
23
23
|
its own? Flag any phase that leaves a judgment call open, names a file/symbol vaguely, omits exact
|
|
24
24
|
data bindings, or has a non-literal exit gate. (Supports the planner→coder handoff.)
|
|
25
25
|
|
|
26
|
+
**One size check, always reported as `severity: warning` (category `conventions`), never a blocker:** a phase
|
|
27
|
+
over 12 files or over 6 cards or tasks, an agy card over 6 files (unless the phase says
|
|
28
|
+
`**Programme phase:** yes`), and a `**Model:**` line that names no effort (`<model>, effort <low|medium|high>`).
|
|
29
|
+
|
|
26
30
|
## Method
|
|
27
31
|
- Read the plan. For each claim, run the cheapest check that confirms or refutes it (Glob/Grep/Read).
|
|
28
32
|
- Don't trust the plan's prose — verify against files. A claim you can't verify is a finding, not a pass.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/bundles/antigravity-plugin/scripts/__pycache__/caddis_worktree_safety.cpython-311.pyc
CHANGED
|
Binary file
|
|
@@ -24,6 +24,13 @@ except ModuleNotFoundError as exc:
|
|
|
24
24
|
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
25
25
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "claude-harness" / "scripts"))
|
|
26
26
|
import caddis_exit
|
|
27
|
+
try:
|
|
28
|
+
import caddis_routing # SESSION_DEFAULTS: the model and effort each start line names
|
|
29
|
+
except ModuleNotFoundError as exc:
|
|
30
|
+
if exc.name != "caddis_routing":
|
|
31
|
+
raise
|
|
32
|
+
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "claude-harness" / "scripts"))
|
|
33
|
+
import caddis_routing
|
|
27
34
|
|
|
28
35
|
ACK_FIELDS = ("name", "role", "machine", "folder", "relay", "tasks", "mode", "owns-watchers", "worktrees")
|
|
29
36
|
NO_ACK = "no ack"
|
|
@@ -198,8 +205,21 @@ def start_line(ack: Ack, stamp: datetime) -> str:
|
|
|
198
205
|
claude named for the role at the sheet's hour, with `/caddis:fleet-open <role>` as the first prompt.
|
|
199
206
|
|
|
200
207
|
No permission or Remote Control flags: every start reads `defaultMode` and `remoteControlAtStartup` from the
|
|
201
|
-
owner's settings (owner, 16 Oct). caddis starts no process; the owner does (`claude --bg` decided against).
|
|
202
|
-
|
|
208
|
+
owner's settings (owner, 16 Oct). caddis starts no process; the owner does (`claude --bg` decided against).
|
|
209
|
+
`--model` and `--effort` come from `caddis_routing.session_start` (the role's SESSION_DEFAULTS row)."""
|
|
210
|
+
return (f'cd "{ack.folder}"; claude {_model_flags(ack.role)} --name {new_name(ack.role, stamp)} '
|
|
211
|
+
f'"/caddis:fleet-open {ack.role}"')
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
def _model_flags(role: str) -> str:
|
|
215
|
+
model, effort = caddis_routing.session_start(role)
|
|
216
|
+
return f"--model {model} --effort {effort}"
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
def model_line(role: str) -> str:
|
|
220
|
+
"""The first line of every resume block: the model and effort the next session starts on."""
|
|
221
|
+
model, effort = caddis_routing.session_start(role)
|
|
222
|
+
return f"Model for next session: {model}, effort {effort}\n"
|
|
203
223
|
|
|
204
224
|
|
|
205
225
|
def render_sheet(acks: list[Ack], coordinator: str, stamp: datetime) -> str:
|
|
@@ -465,28 +485,33 @@ def announce_text(script: Path, name: str, folder: str) -> str:
|
|
|
465
485
|
|
|
466
486
|
|
|
467
487
|
def render_resume(session: str, session_id: str, workstream: str, prompt: str, role: str, stamp: datetime,
|
|
468
|
-
fleet_mode: bool = False, announce_script: Path | None = None, folder: str = ""
|
|
488
|
+
fleet_mode: bool = False, announce_script: Path | None = None, folder: str = "",
|
|
489
|
+
root: Path | None = None) -> str:
|
|
469
490
|
"""The last output of `/caddis:handoff`. In a fleet close the restart sheet holds the only start line.
|
|
470
491
|
|
|
471
492
|
With `announce_script`, the start line (not the fenced block, which stays the relay's text) ends with the
|
|
472
|
-
whoami + announce sentence: the start line is what the new session receives with its name.
|
|
493
|
+
whoami + announce sentence: the start line is what the new session receives with its name.
|
|
494
|
+
With `root`, the block names the repo and the start line first changes to it, because the relay's paths are
|
|
495
|
+
repo-relative. `;`, as in the restart sheet: Windows PowerShell 5.1 has no `&&`."""
|
|
473
496
|
shown = prompt # the fenced block stays the relay text
|
|
497
|
+
repo = f"Repo: {root.as_posix()}\n" if root is not None else ""
|
|
498
|
+
cd = f'cd "{root.as_posix()}"; ' if root is not None else ""
|
|
474
499
|
if fleet_mode:
|
|
475
500
|
start = "Start line: from the restart sheet"
|
|
476
501
|
else:
|
|
477
502
|
name = new_name(role, stamp)
|
|
478
503
|
if announce_script is not None:
|
|
479
504
|
prompt = f"{prompt}\n{announce_text(announce_script, name, folder)}"
|
|
480
|
-
start = f"Start line:\
|
|
481
|
-
return (f"=== RESUME ===\nSession: {session} ({session_id})\nWorkstream: {workstream}\n"
|
|
482
|
-
f"{_fenced(shown)}\n{start}\n")
|
|
505
|
+
start = f"Start line:\n{cd}claude {_model_flags(role)} --name {name} {shell_arg(prompt)}"
|
|
506
|
+
return (f"{model_line(role)}=== RESUME ===\nSession: {session} ({session_id})\nWorkstream: {workstream}\n"
|
|
507
|
+
f"{repo}{_fenced(shown)}\n{start}\n")
|
|
483
508
|
|
|
484
509
|
|
|
485
510
|
def render_coordinator_resume(session: str, session_id: str, workstream: str) -> str:
|
|
486
511
|
"""The resume block for the repo's coordinator: three lines to type, no prompt and no start line.
|
|
487
512
|
|
|
488
513
|
`/caddis:coordinate start` reads the coordinator's relay and tasks itself, so a pasted prompt would only race it."""
|
|
489
|
-
return (f"=== RESUME ===\nSession: {session} ({session_id})\nWorkstream: {workstream}\n"
|
|
514
|
+
return (f"{model_line('coordinator')}=== RESUME ===\nSession: {session} ({session_id})\nWorkstream: {workstream}\n"
|
|
490
515
|
"This session is the repo's coordinator. To resume, type these three lines in this window, one at a time:\n"
|
|
491
516
|
"/clear\n/rename coordinator\n/caddis:coordinate start\n"
|
|
492
517
|
f"Do not paste a resume prompt; /caddis:coordinate start reads .caddis/relay/{workstream}.md "
|
|
@@ -555,7 +580,7 @@ def _resume_block_cli(args: argparse.Namespace) -> int:
|
|
|
555
580
|
sys.stderr.write(f"resume-block failed: bad role {role!r}\n")
|
|
556
581
|
return caddis_exit.BLOCKED
|
|
557
582
|
print(render_resume(session, args.session_id, args.name, prompt, role, datetime.now(), args.fleet,
|
|
558
|
-
Path(__file__).resolve(), root.name), end="")
|
|
583
|
+
Path(__file__).resolve(), root.name, root), end="")
|
|
559
584
|
return caddis_exit.CLEAN
|
|
560
585
|
|
|
561
586
|
|
|
@@ -592,7 +617,9 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
592
617
|
p.add_argument("--name", required=True, help="the relay's workstream name")
|
|
593
618
|
p.add_argument("--session-id", required=True)
|
|
594
619
|
p.add_argument("--root", default=".", type=Path)
|
|
595
|
-
p.add_argument("--role", help="role for the new session's name
|
|
620
|
+
p.add_argument("--role", help="role for the new session's name and its SESSION_DEFAULTS model and effort, e.g. "
|
|
621
|
+
"plan-writer for plan or design work (default: the session name's role, else the relay name; "
|
|
622
|
+
"a role with no Claude row starts as the orchestrator)")
|
|
596
623
|
p.add_argument("--fleet", action="store_true", help="fleet close: print no start line (the restart sheet has it)")
|
|
597
624
|
p.add_argument("--coordinator", action="store_true",
|
|
598
625
|
help="this session holds the repo's coordinator lock: print the three restart lines, no prompt")
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema": 1,
|
|
3
|
-
"version": "1.3.
|
|
4
|
-
"generated": "2026-10-
|
|
3
|
+
"version": "1.3.173",
|
|
4
|
+
"generated": "2026-10-29 01:50 UTC",
|
|
5
5
|
"commands": [
|
|
6
6
|
{
|
|
7
7
|
"name": "add-rules",
|
|
@@ -149,7 +149,8 @@
|
|
|
149
149
|
],
|
|
150
150
|
"scripts": [
|
|
151
151
|
"caddis_coordinate.py",
|
|
152
|
-
"caddis_lanes.py"
|
|
152
|
+
"caddis_lanes.py",
|
|
153
|
+
"caddis_routing.py"
|
|
153
154
|
],
|
|
154
155
|
"noArgs": false,
|
|
155
156
|
"stage": "ship",
|
|
@@ -511,6 +512,10 @@
|
|
|
511
512
|
"",
|
|
512
513
|
"Checklist"
|
|
513
514
|
],
|
|
515
|
+
[
|
|
516
|
+
"",
|
|
517
|
+
"Checkpoint (mid-phase, between cards)"
|
|
518
|
+
],
|
|
514
519
|
[
|
|
515
520
|
"1",
|
|
516
521
|
"capture learnings FIRST (knowledge-transfer)"
|
|
@@ -534,10 +539,6 @@
|
|
|
534
539
|
[
|
|
535
540
|
"",
|
|
536
541
|
"Done (this session / across sessions)"
|
|
537
|
-
],
|
|
538
|
-
[
|
|
539
|
-
"",
|
|
540
|
-
"Next step (exact)"
|
|
541
542
|
]
|
|
542
543
|
],
|
|
543
544
|
"scripts": [
|
|
@@ -548,8 +549,10 @@
|
|
|
548
549
|
"caddis_docs_pr.py",
|
|
549
550
|
"caddis_fleet.py",
|
|
550
551
|
"caddis_gate.py",
|
|
552
|
+
"caddis_handoff.py",
|
|
551
553
|
"caddis_inventory.py",
|
|
552
554
|
"caddis_relay_git.py",
|
|
555
|
+
"caddis_routing.py",
|
|
553
556
|
"caddis_tidy.py",
|
|
554
557
|
"caddis_workstreams.py",
|
|
555
558
|
"check_doc_coverage.py",
|
|
@@ -584,6 +587,10 @@
|
|
|
584
587
|
"",
|
|
585
588
|
"Keep the session small and quiet"
|
|
586
589
|
],
|
|
590
|
+
[
|
|
591
|
+
"",
|
|
592
|
+
"Waves"
|
|
593
|
+
],
|
|
587
594
|
[
|
|
588
595
|
"",
|
|
589
596
|
"Three rules: one attempt, one review"
|
|
@@ -607,15 +614,13 @@
|
|
|
607
614
|
[
|
|
608
615
|
"",
|
|
609
616
|
"Task progress *(only for `Execution: per-task` phases)*"
|
|
610
|
-
],
|
|
611
|
-
[
|
|
612
|
-
"",
|
|
613
|
-
"Not done / follow-ups"
|
|
614
617
|
]
|
|
615
618
|
],
|
|
616
619
|
"scripts": [
|
|
620
|
+
"caddis_created.py",
|
|
617
621
|
"caddis_gate.py",
|
|
618
622
|
"caddis_lanes.py",
|
|
623
|
+
"caddis_routing.py",
|
|
619
624
|
"caddis_spend.py",
|
|
620
625
|
"caddis_status.py",
|
|
621
626
|
"caddis_tidy.py",
|
|
@@ -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())
|