@caddis/cli 0.4.85 → 0.4.87
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/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_hub_collect.py +36 -1
- package/bundles/antigravity-plugin/scripts/caddis_prod_check.py +59 -11
- package/bundles/antigravity-plugin/scripts/caddis_roadmap.py +5 -13
- package/bundles/antigravity-plugin/scripts/caddis_status.py +45 -0
- package/bundles/antigravity-plugin/scripts/caddis_todo.py +111 -23
- package/bundles/antigravity-plugin/scripts/schemas/hub-collect.schema.json +16 -1
- package/bundles/antigravity-plugin/scripts/schemas/hub-plans.schema.json +16 -1
- package/bundles/antigravity-plugin/skills/feature-plan/SKILL.md +4 -0
- package/bundles/antigravity-plugin/skills/implement/SKILL.md +2 -1
- package/bundles/manifest.json +2 -2
- package/dist/cli.js +1 -1
- package/dist/export/assets/{export-DErZHj4B.js → export-Dro73_I7.js} +29 -29
- package/dist/export/assets/{export-C0_skoDL.css → export-N0paGhbL.css} +1 -1
- package/dist/export/index.html +2 -2
- package/dist/ui/assets/{Activity-CaqQ_HdD.js → Activity-BgqFFOv1.js} +1 -1
- package/dist/ui/assets/{Guide-9PV1m0e9.js → Guide-Df0Kg8wI.js} +1 -1
- package/dist/ui/assets/RoadmapTab-CV7WCGBL.js +31 -0
- package/dist/ui/assets/{index-Cv4RVfyi.css → index-DEge93wH.css} +1 -1
- package/dist/ui/assets/{index-Dotj3WfG.js → index-DQbpiY2a.js} +39 -39
- package/dist/ui/index.html +2 -2
- package/package.json +1 -1
- package/dist/ui/assets/RoadmapTab-CDm42wB2.js +0 -31
|
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
|
|
@@ -52,8 +52,43 @@ def _roadmaps_json(root: Path) -> dict:
|
|
|
52
52
|
module.FETCH = saved
|
|
53
53
|
|
|
54
54
|
|
|
55
|
+
def _local_origin_branches(common: Path) -> list[str]:
|
|
56
|
+
"""Which of origin/main and origin/master exist, from the loose ref files and packed-refs (no subprocess)."""
|
|
57
|
+
try:
|
|
58
|
+
packed = (common / "packed-refs").read_text(encoding="utf-8")
|
|
59
|
+
except (OSError, UnicodeDecodeError):
|
|
60
|
+
packed = ""
|
|
61
|
+
packed_refs = {line.split(" ", 1)[1].strip() for line in packed.splitlines() if " refs/" in line}
|
|
62
|
+
return [name for name in ("main", "master")
|
|
63
|
+
if (common / "refs" / "remotes" / "origin" / name).is_file() or f"refs/remotes/origin/{name}" in packed_refs]
|
|
64
|
+
|
|
65
|
+
|
|
55
66
|
def _plans_json(root: Path) -> dict:
|
|
56
|
-
|
|
67
|
+
"""Plans from the origin ref the repo already has (R15: local git only), so a pushed Tracker edit shows with no
|
|
68
|
+
pull. A folder that is not a git checkout, or has no origin default branch, reads the working tree."""
|
|
69
|
+
branch = None
|
|
70
|
+
common = git_common_dir(Path(root))
|
|
71
|
+
if common is None:
|
|
72
|
+
return _sibling("caddis_todo").plans_json(root)
|
|
73
|
+
try: # origin/HEAD is a one-line file; reading it saves a git process per repo
|
|
74
|
+
head = (common / "refs" / "remotes" / "origin" / "HEAD").read_text(encoding="utf-8").strip()
|
|
75
|
+
except (OSError, UnicodeDecodeError):
|
|
76
|
+
head = ""
|
|
77
|
+
if head.startswith("ref: refs/remotes/origin/"):
|
|
78
|
+
branch = head[len("ref: refs/remotes/origin/"):]
|
|
79
|
+
elif len(found := _local_origin_branches(common)) == 1:
|
|
80
|
+
branch = found[0] # the same rule as caddis_roadmap.default_branch with FETCH off, read from the files
|
|
81
|
+
else:
|
|
82
|
+
roadmap = _sibling("caddis_roadmap")
|
|
83
|
+
saved = roadmap.FETCH
|
|
84
|
+
roadmap.FETCH = False
|
|
85
|
+
try:
|
|
86
|
+
branch = roadmap.default_branch(Path(root))
|
|
87
|
+
except roadmap.RoadmapError:
|
|
88
|
+
branch = None
|
|
89
|
+
finally:
|
|
90
|
+
roadmap.FETCH = saved
|
|
91
|
+
return _sibling("caddis_todo").plans_json(root, branch=branch)
|
|
57
92
|
|
|
58
93
|
|
|
59
94
|
def _relays_json(root: Path) -> dict:
|
|
@@ -5,6 +5,10 @@ succeeded (with --docs-only: the deploy job was skipped); (3) the version endpoi
|
|
|
5
5
|
it; (4) the health endpoint JSON has every value `true`, not only HTTP 200; (5) optional: named background jobs were
|
|
6
6
|
attempted after the deploy with zero failures. A repo with no profile gets items 1 and 2 only.
|
|
7
7
|
|
|
8
|
+
Push run (item 1): `[ci] workflow = "<name>"` names the workflow to check. Without it, when several workflows ran on
|
|
9
|
+
the merge SHA (a CI workflow and a Pages one), the run whose jobs hold the deploy job or a required job is used. A job
|
|
10
|
+
of a reusable workflow, listed as `<caller job> / <job>`, counts as `<job>`.
|
|
11
|
+
|
|
8
12
|
Prints one PASS or FAIL line per item and a RESULT line. Exit 0 only when every item passes; 1 when one fails; 3 when
|
|
9
13
|
the profile cannot be read; 4 when the SHA is ambiguous or not found. Read-only: it never writes to GitHub or prod.
|
|
10
14
|
|
|
@@ -69,6 +73,7 @@ def real_runner(cwd: Path) -> Runner:
|
|
|
69
73
|
class Profile:
|
|
70
74
|
found: bool = False
|
|
71
75
|
branch: str = "main"
|
|
76
|
+
workflow: str | None = None # the push workflow to check, when the repo has more than one (e.g. a Pages one)
|
|
72
77
|
required_jobs: list[str] = field(default_factory=list)
|
|
73
78
|
deploy_job: str = "deploy_prod"
|
|
74
79
|
push_run_wait_minutes: float = 10
|
|
@@ -82,7 +87,7 @@ class Profile:
|
|
|
82
87
|
|
|
83
88
|
|
|
84
89
|
_KEY_TYPES: dict[str, type | tuple[type, ...]] = {
|
|
85
|
-
"branch": str, "required_jobs": list, "deploy_job": str, "push_run_wait_minutes": (int, float),
|
|
90
|
+
"branch": str, "workflow": str, "required_jobs": list, "deploy_job": str, "push_run_wait_minutes": (int, float),
|
|
86
91
|
"run_wait_minutes": (int, float), "version_url": str, "version_field": str, "health_url": str, "auth": str,
|
|
87
92
|
"timeout_seconds": int,
|
|
88
93
|
}
|
|
@@ -111,6 +116,9 @@ def load_profile(repo: Path, path: Path | None = None) -> Profile:
|
|
|
111
116
|
if key == "required_jobs" and not all(isinstance(job, str) for job in value):
|
|
112
117
|
raise ValueError(f"{path}: required_jobs must be a list of job names")
|
|
113
118
|
setattr(profile, key, value)
|
|
119
|
+
if profile.workflow is not None and (not profile.workflow.strip()
|
|
120
|
+
or profile.workflow.lower().endswith((".yml", ".yaml"))):
|
|
121
|
+
raise ValueError(f"{path}: workflow must be the workflow's name (its `name:` line), not a file name")
|
|
114
122
|
if profile.auth not in ("none", "ntlm"):
|
|
115
123
|
raise ValueError(f"{path}: auth must be 'none' or 'ntlm'")
|
|
116
124
|
if background is not None:
|
|
@@ -167,16 +175,42 @@ def resolve_sha(ctx: Context, sha: str) -> tuple[int, str]:
|
|
|
167
175
|
|
|
168
176
|
|
|
169
177
|
def push_runs(ctx: Context, limit: int = 20) -> list[dict]:
|
|
170
|
-
|
|
171
|
-
|
|
178
|
+
args = ["run", "list", "--branch", ctx.profile.branch, "--event", "push", "--limit", str(limit),
|
|
179
|
+
"--json", "databaseId,headSha,status,conclusion,workflowName"]
|
|
180
|
+
if ctx.profile.workflow:
|
|
181
|
+
args[2:2] = ["--workflow", ctx.profile.workflow]
|
|
182
|
+
runs = ctx.gh_json(*args)
|
|
183
|
+
if ctx.profile.workflow: # also filter here: the list must never hold another workflow's run
|
|
184
|
+
runs = [r for r in runs if r.get("workflowName") == ctx.profile.workflow] # type: ignore[union-attr]
|
|
185
|
+
return runs # type: ignore[return-value]
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
def _pick_run(ctx: Context, candidates: list[dict]) -> tuple[dict | None, str]:
|
|
189
|
+
"""(run, state): state is "sure", "wait" (no run lists the jobs yet: they are queued) or "guess" (nothing can
|
|
190
|
+
tell the runs apart). Several workflows can run on one push (serve-sight: `CI and Deploy` and `roadmap-pages`).
|
|
191
|
+
With no `workflow` in the profile, take the run whose jobs hold the deploy job or a required job."""
|
|
192
|
+
if len(candidates) <= 1:
|
|
193
|
+
return (candidates[0] if candidates else None), ("sure" if candidates else "wait")
|
|
194
|
+
wanted = [j for j in (ctx.profile.deploy_job, *ctx.profile.required_jobs) if j]
|
|
195
|
+
if not wanted: # no deploy job and no required jobs: waiting cannot help
|
|
196
|
+
return candidates[0], "guess"
|
|
197
|
+
for run in candidates:
|
|
198
|
+
view = ctx.gh_json("run", "view", str(run["databaseId"]), "--json", "jobs")
|
|
199
|
+
jobs = _jobs(view if isinstance(view, dict) else {})
|
|
200
|
+
if any(_job(jobs, name) is not None for name in wanted):
|
|
201
|
+
return run, "sure"
|
|
202
|
+
return candidates[0], "wait"
|
|
172
203
|
|
|
173
204
|
|
|
174
205
|
def find_push_run(ctx: Context, sha: str) -> dict | None:
|
|
175
206
|
"""Wait up to the profile's minutes for a push run of `sha` to appear."""
|
|
176
207
|
deadline = ctx.clock.now() + ctx.profile.push_run_wait_minutes * 60
|
|
177
208
|
while True:
|
|
178
|
-
run =
|
|
179
|
-
if
|
|
209
|
+
run, state = _pick_run(ctx, [r for r in push_runs(ctx) if r.get("headSha") == sha])
|
|
210
|
+
if state != "wait" or ctx.dry_run or ctx.clock.now() >= deadline:
|
|
211
|
+
if run and state != "sure":
|
|
212
|
+
ctx.out(f"INFO 1 {sha[:12]} has several push runs and none lists {ctx.profile.deploy_job or 'the jobs'}"
|
|
213
|
+
f"; using run {run['databaseId']}. Set `workflow` in .caddis/prod-check.toml")
|
|
180
214
|
return run
|
|
181
215
|
ctx.clock.sleep(15)
|
|
182
216
|
|
|
@@ -197,9 +231,23 @@ def _jobs(view: dict) -> dict[str, str]:
|
|
|
197
231
|
return {j.get("name", ""): (j.get("conclusion") or j.get("status") or "") for j in view.get("jobs", [])}
|
|
198
232
|
|
|
199
233
|
|
|
234
|
+
def _same_job(actual: str, name: str) -> bool:
|
|
235
|
+
"""A job of a reusable workflow is listed as "<caller job> / <job>" (serve-sight: `ci / deploy_prod`)."""
|
|
236
|
+
return actual == name or actual.endswith(" / " + name)
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
def _job(jobs: dict[str, str], name: str) -> str | None:
|
|
240
|
+
"""The state of job `name`, or None when the run has no such job. When several reusable workflows each have a
|
|
241
|
+
job of that name, a state that is not success wins, so one success never hides a failure."""
|
|
242
|
+
states = [state for actual, state in jobs.items() if _same_job(actual, name)]
|
|
243
|
+
if not states:
|
|
244
|
+
return None
|
|
245
|
+
return next((s for s in states if s != "success"), "success")
|
|
246
|
+
|
|
247
|
+
|
|
200
248
|
def _deploy_done(view: dict, deploy_job: str) -> datetime | None:
|
|
201
249
|
for job in view.get("jobs", []):
|
|
202
|
-
if job.get("name")
|
|
250
|
+
if _same_job(job.get("name", ""), deploy_job) and job.get("completedAt"):
|
|
203
251
|
return _utc(job["completedAt"])
|
|
204
252
|
return None
|
|
205
253
|
|
|
@@ -232,13 +280,13 @@ def check_ci(ctx: Context, sha: str, docs_only: bool) -> tuple[list[str], dict |
|
|
|
232
280
|
ctx.out("jobs: " + ", ".join(f"{name}={state}" for name, state in jobs.items()))
|
|
233
281
|
deploy = ctx.profile.deploy_job
|
|
234
282
|
if docs_only:
|
|
235
|
-
if jobs
|
|
283
|
+
if _job(jobs, deploy) == "skipped" and conclusion == "success":
|
|
236
284
|
ctx.out(f"PASS 2 docs-only: {deploy} skipped, run conclusion success")
|
|
237
285
|
return [], view
|
|
238
286
|
if conclusion != "success":
|
|
239
287
|
ctx.out(f"FAIL 2 docs-only merge, but the run concluded {conclusion}")
|
|
240
288
|
return ["2 jobs"], view
|
|
241
|
-
ctx.out(f"FAIL 2 docs-only merge, but {deploy} = {jobs
|
|
289
|
+
ctx.out(f"FAIL 2 docs-only merge, but {deploy} = {_job(jobs, deploy) or 'absent'}; run the full prod check")
|
|
242
290
|
return ["2 jobs"], view
|
|
243
291
|
if not ctx.profile.found:
|
|
244
292
|
if conclusion == "success":
|
|
@@ -246,11 +294,11 @@ def check_ci(ctx: Context, sha: str, docs_only: bool) -> tuple[list[str], dict |
|
|
|
246
294
|
return [], view
|
|
247
295
|
ctx.out(f"FAIL 2 run conclusion {conclusion}")
|
|
248
296
|
return ["2 jobs"], view
|
|
249
|
-
bad = {name: jobs
|
|
250
|
-
if deploy and jobs
|
|
297
|
+
bad = {name: _job(jobs, name) or "absent" for name in ctx.profile.required_jobs if _job(jobs, name) != "success"}
|
|
298
|
+
if deploy and _job(jobs, deploy) != "success":
|
|
251
299
|
# A code merge that did not deploy fails, also when the job is not listed as required.
|
|
252
300
|
# A repo with no deploy job sets `deploy_job = ""` in its profile.
|
|
253
|
-
bad[deploy] = jobs
|
|
301
|
+
bad[deploy] = _job(jobs, deploy) or "absent"
|
|
254
302
|
if bad:
|
|
255
303
|
skipped = " (skipped without --docs-only)" if bad.get(deploy) == "skipped" else ""
|
|
256
304
|
ctx.out("FAIL 2 " + ", ".join(f"{n}={c}" for n, c in bad.items()) + skipped)
|
|
@@ -88,15 +88,17 @@ try:
|
|
|
88
88
|
import caddis_exit
|
|
89
89
|
import caddis_redact
|
|
90
90
|
import caddis_rows
|
|
91
|
+
import caddis_status
|
|
91
92
|
import caddis_worktree_safety
|
|
92
93
|
except ModuleNotFoundError as exc:
|
|
93
|
-
if exc.name not in {"caddis_exit", "caddis_redact", "caddis_rows", "caddis_worktree_safety"}:
|
|
94
|
+
if exc.name not in {"caddis_exit", "caddis_redact", "caddis_rows", "caddis_status", "caddis_worktree_safety"}:
|
|
94
95
|
raise
|
|
95
96
|
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
96
97
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "claude-harness" / "scripts"))
|
|
97
98
|
import caddis_exit
|
|
98
99
|
import caddis_redact
|
|
99
100
|
import caddis_rows
|
|
101
|
+
import caddis_status
|
|
100
102
|
import caddis_worktree_safety
|
|
101
103
|
|
|
102
104
|
# No child process opens a console window on Windows (this runs under hooks and status lines that
|
|
@@ -690,8 +692,7 @@ def parse_tracker(text: str) -> dict[int, str]:
|
|
|
690
692
|
|
|
691
693
|
|
|
692
694
|
def _is_done_status(cell: str) -> bool:
|
|
693
|
-
|
|
694
|
-
return value.lower().startswith("done") or value.startswith("✅")
|
|
695
|
+
return caddis_status.is_done(cell)
|
|
695
696
|
|
|
696
697
|
|
|
697
698
|
class PhaseIndex:
|
|
@@ -2246,16 +2247,7 @@ def phase_facts(plan_text: str | None) -> dict[int, dict]:
|
|
|
2246
2247
|
|
|
2247
2248
|
def tile_state(tracker_cell: str, state: str) -> str:
|
|
2248
2249
|
"""todo | in-progress | done | moved | blocked, from the Tracker cell (origin), falling back to status()."""
|
|
2249
|
-
|
|
2250
|
-
if cell.startswith("moved") or "moved" in cell.split(" - ", 1)[0]:
|
|
2251
|
-
return "moved"
|
|
2252
|
-
if cell.startswith(("done", "✅", "merged")):
|
|
2253
|
-
return "done"
|
|
2254
|
-
if cell.startswith(("blocked", "halt", "waiting")):
|
|
2255
|
-
return "blocked"
|
|
2256
|
-
if cell.startswith(("in progress", "in-progress", "active", "building", "built", "⏳")):
|
|
2257
|
-
return "in-progress"
|
|
2258
|
-
return "done" if state == "done" else "todo"
|
|
2250
|
+
return caddis_status.status_state(tracker_cell, "done" if state == "done" else "todo")
|
|
2259
2251
|
|
|
2260
2252
|
|
|
2261
2253
|
def build(root: Path, slug: str, roadmap_mod=None) -> dict:
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"""One vocabulary for a plan Tracker's Status cell, for every caller (todo, tidy, roadmap, runner, hub).
|
|
2
|
+
|
|
3
|
+
Owner decisions: "pending" anywhere is never done (2026-09-27); the check marks below count as done (2026-10-26).
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import re
|
|
9
|
+
|
|
10
|
+
DONE_WORDS = ("done", "merged")
|
|
11
|
+
DONE_MARKS = ("✅", "☑", "✔", "✓")
|
|
12
|
+
OPEN_MARKS = ("☐",)
|
|
13
|
+
BLOCKED_WORDS = ("blocked", "halt", "waiting")
|
|
14
|
+
IN_PROGRESS_WORDS = ("in progress", "in-progress", "active", "building", "built", "⏳")
|
|
15
|
+
STATES = ("todo", "in-progress", "blocked", "done", "moved")
|
|
16
|
+
|
|
17
|
+
_DONE_WORD = re.compile(r"^(?:%s)\b" % "|".join(DONE_WORDS))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _clean(cell: str) -> str:
|
|
21
|
+
text = (cell or "").strip().strip("*").strip()
|
|
22
|
+
while text.startswith(OPEN_MARKS):
|
|
23
|
+
text = text[1:].lstrip()
|
|
24
|
+
return text.lower()
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def status_state(cell: str, fallback: str = "todo") -> str:
|
|
28
|
+
"""todo | in-progress | blocked | done | moved. `fallback` when the cell names no state (empty, a bare open box,
|
|
29
|
+
"not started")."""
|
|
30
|
+
text = _clean(cell)
|
|
31
|
+
if "pending" in text:
|
|
32
|
+
return "in-progress"
|
|
33
|
+
if text.startswith("moved") or "moved" in text.split(" - ", 1)[0]:
|
|
34
|
+
return "moved"
|
|
35
|
+
if _DONE_WORD.match(text) or text.startswith(DONE_MARKS):
|
|
36
|
+
return "done"
|
|
37
|
+
if text.startswith(BLOCKED_WORDS):
|
|
38
|
+
return "blocked"
|
|
39
|
+
if text.startswith(IN_PROGRESS_WORDS):
|
|
40
|
+
return "in-progress"
|
|
41
|
+
return fallback
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def is_done(cell: str) -> bool:
|
|
45
|
+
return status_state(cell) == "done"
|
|
@@ -19,15 +19,18 @@ from pathlib import Path
|
|
|
19
19
|
try:
|
|
20
20
|
import caddis_exit
|
|
21
21
|
from caddis_frontmatter import parse, split_document
|
|
22
|
+
from caddis_status import is_done, status_state
|
|
22
23
|
from caddis_workstreams import _artifact, _name
|
|
23
24
|
except ModuleNotFoundError as exc:
|
|
24
|
-
if exc.name not in {"caddis_exit", "caddis_file_lock", "caddis_frontmatter", "
|
|
25
|
+
if exc.name not in {"caddis_exit", "caddis_file_lock", "caddis_frontmatter", "caddis_status",
|
|
26
|
+
"caddis_workstreams"}:
|
|
25
27
|
raise
|
|
26
28
|
# caddis_tidy imports caddis_file_lock after this module: these two folders stay on the path.
|
|
27
29
|
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
28
30
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "claude-harness" / "scripts"))
|
|
29
31
|
import caddis_exit
|
|
30
32
|
from caddis_frontmatter import parse, split_document
|
|
33
|
+
from caddis_status import is_done, status_state
|
|
31
34
|
from caddis_workstreams import _artifact, _name
|
|
32
35
|
|
|
33
36
|
|
|
@@ -56,13 +59,8 @@ def _resolves_path(root: Path, value: str) -> Path:
|
|
|
56
59
|
|
|
57
60
|
|
|
58
61
|
def _is_done(status: str) -> bool:
|
|
59
|
-
"""A Tracker status cell that means done
|
|
60
|
-
|
|
61
|
-
lowered = status.strip().lower()
|
|
62
|
-
first = lowered.split(" ", 1)[0] if lowered else ""
|
|
63
|
-
if "pending" in lowered:
|
|
64
|
-
return False
|
|
65
|
-
return first in {"done", "✅"} or first.startswith("✅")
|
|
62
|
+
"""A Tracker status cell that means done. The vocabulary lives in caddis_status; tidy and tests call this name."""
|
|
63
|
+
return is_done(status)
|
|
66
64
|
|
|
67
65
|
|
|
68
66
|
def _active_plan(root: Path, workstream: str | None) -> Path | None:
|
|
@@ -159,7 +157,8 @@ def tracker_table(text: str) -> tuple[list[str], list[str]] | None:
|
|
|
159
157
|
One reader, so caddis_tidy and any later caller never disagree about the same table.
|
|
160
158
|
"""
|
|
161
159
|
# A real heading line only: plan prose may mention "## Tracker" inline before the section.
|
|
162
|
-
|
|
160
|
+
# "## Tracker" or a numbered "## 12. Tracker" (hand-written plans number their sections).
|
|
161
|
+
heading = re.search(r"^##\s+(?:\d+[.)]?\s+)?Tracker\b.*$", text, re.M)
|
|
163
162
|
if heading is None:
|
|
164
163
|
return None
|
|
165
164
|
section = text[heading.end():].split("\n## ", 1)[0]
|
|
@@ -184,6 +183,10 @@ def _plan_files(root: Path) -> list[Path]:
|
|
|
184
183
|
|
|
185
184
|
|
|
186
185
|
def _plan_entry(root: Path, path: Path) -> dict:
|
|
186
|
+
return _plan_entry_text(path.relative_to(Path(root)).as_posix(), path.read_text(encoding="utf-8"))
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def _plan_entry_text(rel: str, text: str) -> dict:
|
|
187
190
|
# caddis_tidy imports this module at load time, so this module imports it only here.
|
|
188
191
|
try:
|
|
189
192
|
import caddis_tidy
|
|
@@ -192,7 +195,6 @@ def _plan_entry(root: Path, path: Path) -> dict:
|
|
|
192
195
|
raise
|
|
193
196
|
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
|
194
197
|
import caddis_tidy
|
|
195
|
-
text = path.read_text(encoding="utf-8")
|
|
196
198
|
meta, body = split_document(text)
|
|
197
199
|
if text.lstrip("").startswith("---") and not meta:
|
|
198
200
|
raise ValueError("frontmatter is not closed or has no keys")
|
|
@@ -208,26 +210,112 @@ def _plan_entry(root: Path, path: Path) -> dict:
|
|
|
208
210
|
continue
|
|
209
211
|
cells = caddis_tidy._row_cells(line)
|
|
210
212
|
if cells:
|
|
211
|
-
|
|
212
|
-
|
|
213
|
+
cell = cells[status_at] if len(cells) > status_at else ""
|
|
214
|
+
tracker.append({"phase": cells[0], "status": cell, "state": status_state(cell)})
|
|
215
|
+
return {"path": rel, "title": title,
|
|
213
216
|
"status": meta.get("status"), "feature": meta.get("feature"),
|
|
214
217
|
"tracker": tracker, "open_rows": sum(1 for row in tracker if not _is_done(row["status"]))}
|
|
215
218
|
|
|
216
219
|
|
|
217
|
-
|
|
218
|
-
"""
|
|
220
|
+
class _Batch:
|
|
221
|
+
"""One `git cat-file --batch` process, asked object by object (local git only, no network)."""
|
|
222
|
+
|
|
223
|
+
def __init__(self, root: Path):
|
|
224
|
+
self.proc = subprocess.Popen(["git", "-C", str(root), "cat-file", "--batch"], stdin=subprocess.PIPE,
|
|
225
|
+
stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, creationflags=_NO_WINDOW)
|
|
226
|
+
|
|
227
|
+
def get(self, name: str) -> tuple[str, str, bytes] | None:
|
|
228
|
+
"""(oid, type, content) of `name`, or None when git says it is missing."""
|
|
229
|
+
assert self.proc.stdin is not None and self.proc.stdout is not None
|
|
230
|
+
self.proc.stdin.write(name.encode("utf-8") + b"\n")
|
|
231
|
+
self.proc.stdin.flush()
|
|
232
|
+
header = self.proc.stdout.readline().split()
|
|
233
|
+
if len(header) != 3:
|
|
234
|
+
return None # "<name> missing" (or ambiguous)
|
|
235
|
+
size = int(header[2])
|
|
236
|
+
content = self.proc.stdout.read(size + 1)[:size] # the content, then one newline
|
|
237
|
+
return header[0].decode("ascii"), header[1].decode("ascii"), content
|
|
238
|
+
|
|
239
|
+
def close(self) -> None:
|
|
240
|
+
if self.proc.stdin:
|
|
241
|
+
self.proc.stdin.close()
|
|
242
|
+
try:
|
|
243
|
+
self.proc.wait(timeout=10)
|
|
244
|
+
except subprocess.TimeoutExpired:
|
|
245
|
+
self.proc.kill()
|
|
246
|
+
self.proc.wait()
|
|
247
|
+
if self.proc.stdout:
|
|
248
|
+
self.proc.stdout.close()
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
def _tree_blobs(tree: bytes, oid_len: int) -> list[tuple[str, str]]:
|
|
252
|
+
"""[(name, blob oid)] from a raw tree object: `<mode> <name>\\0<oid bytes>` repeated. Files only."""
|
|
253
|
+
out: list[tuple[str, str]] = []
|
|
254
|
+
at = 0
|
|
255
|
+
while at < len(tree):
|
|
256
|
+
space = tree.index(b" ", at)
|
|
257
|
+
nul = tree.index(b"\0", space)
|
|
258
|
+
mode, name = tree[at:space], tree[space + 1:nul].decode("utf-8", errors="replace")
|
|
259
|
+
oid = tree[nul + 1:nul + 1 + oid_len].hex()
|
|
260
|
+
at = nul + 1 + oid_len
|
|
261
|
+
if mode in (b"100644", b"100755"):
|
|
262
|
+
out.append((name, oid))
|
|
263
|
+
return out
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
def _origin_plan_texts(root: Path, branch: str) -> list[tuple[str, str]] | None:
|
|
267
|
+
"""[(path, text)] of the plan files on origin/<branch>: `.caddis/plans/*.md`, else `.github/plans/*.md`, never
|
|
268
|
+
`done/`. One git process for the whole read. None when git cannot read the ref."""
|
|
269
|
+
try:
|
|
270
|
+
batch = _Batch(root)
|
|
271
|
+
except OSError:
|
|
272
|
+
return None
|
|
273
|
+
try:
|
|
274
|
+
if batch.get(f"refs/remotes/origin/{branch}") is None:
|
|
275
|
+
return None
|
|
276
|
+
for folder in (".caddis/plans", ".github/plans"):
|
|
277
|
+
tree = batch.get(f"refs/remotes/origin/{branch}:{folder}")
|
|
278
|
+
if tree is None or tree[1] != "tree":
|
|
279
|
+
continue
|
|
280
|
+
names = sorted((name, oid) for name, oid in _tree_blobs(tree[2], len(tree[0]) // 2) if name.endswith(".md"))
|
|
281
|
+
if not names:
|
|
282
|
+
continue
|
|
283
|
+
texts: list[tuple[str, str]] = []
|
|
284
|
+
for name, oid in names:
|
|
285
|
+
blob = batch.get(oid)
|
|
286
|
+
if blob is None:
|
|
287
|
+
return None
|
|
288
|
+
texts.append((f"{folder}/{name}", blob[2].decode("utf-8", errors="replace").replace("\r\n", "\n")))
|
|
289
|
+
return texts
|
|
290
|
+
return []
|
|
291
|
+
except (OSError, ValueError):
|
|
292
|
+
return None
|
|
293
|
+
finally:
|
|
294
|
+
batch.close()
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
def _entry_or_error(rel: str, read) -> dict:
|
|
298
|
+
try:
|
|
299
|
+
return read()
|
|
300
|
+
except Exception as exc: # one bad file must not hide the others
|
|
301
|
+
return {"path": rel, "error": (str(exc).splitlines() or [type(exc).__name__])[0]}
|
|
302
|
+
|
|
219
303
|
|
|
220
|
-
|
|
304
|
+
def plans_json(root: Path, branch: str | None = None) -> dict:
|
|
305
|
+
"""Every current plan as data: `{"schema": 1, "source": ..., "plans": [...]}`. Never prints, never exits.
|
|
306
|
+
|
|
307
|
+
With `branch`, read the plans from the local `origin/<branch>` ref (the hub: a pushed Tracker edit shows with
|
|
308
|
+
no pull); when git cannot read that ref, read the working tree. `source` names which one was read. A file that
|
|
309
|
+
does not parse gives `{"path", "error"}`; the other plans still come back.
|
|
221
310
|
"""
|
|
222
311
|
root = Path(root)
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
return {"schema": 1, "plans": plans}
|
|
312
|
+
texts = _origin_plan_texts(root, branch) if branch else None
|
|
313
|
+
if texts is not None:
|
|
314
|
+
plans = [_entry_or_error(rel, lambda rel=rel, text=text: _plan_entry_text(rel, text)) for rel, text in texts]
|
|
315
|
+
return {"schema": 1, "source": f"origin/{branch}", "plans": plans}
|
|
316
|
+
plans = [_entry_or_error(path.relative_to(root).as_posix(), lambda path=path: _plan_entry(root, path))
|
|
317
|
+
for path in _plan_files(root)]
|
|
318
|
+
return {"schema": 1, "source": "working-tree", "plans": plans}
|
|
231
319
|
|
|
232
320
|
|
|
233
321
|
def main(argv: list[str] | None = None) -> int:
|
|
@@ -331,12 +331,16 @@
|
|
|
331
331
|
"type": "object",
|
|
332
332
|
"required": [
|
|
333
333
|
"schema",
|
|
334
|
+
"source",
|
|
334
335
|
"plans"
|
|
335
336
|
],
|
|
336
337
|
"properties": {
|
|
337
338
|
"schema": {
|
|
338
339
|
"type": "integer"
|
|
339
340
|
},
|
|
341
|
+
"source": {
|
|
342
|
+
"type": "string"
|
|
343
|
+
},
|
|
340
344
|
"plans": {
|
|
341
345
|
"type": "array",
|
|
342
346
|
"items": {
|
|
@@ -379,7 +383,8 @@
|
|
|
379
383
|
"type": "object",
|
|
380
384
|
"required": [
|
|
381
385
|
"phase",
|
|
382
|
-
"status"
|
|
386
|
+
"status",
|
|
387
|
+
"state"
|
|
383
388
|
],
|
|
384
389
|
"properties": {
|
|
385
390
|
"phase": {
|
|
@@ -387,6 +392,16 @@
|
|
|
387
392
|
},
|
|
388
393
|
"status": {
|
|
389
394
|
"type": "string"
|
|
395
|
+
},
|
|
396
|
+
"state": {
|
|
397
|
+
"type": "string",
|
|
398
|
+
"enum": [
|
|
399
|
+
"todo",
|
|
400
|
+
"in-progress",
|
|
401
|
+
"blocked",
|
|
402
|
+
"done",
|
|
403
|
+
"moved"
|
|
404
|
+
]
|
|
390
405
|
}
|
|
391
406
|
}
|
|
392
407
|
}
|
|
@@ -4,12 +4,16 @@
|
|
|
4
4
|
"type": "object",
|
|
5
5
|
"required": [
|
|
6
6
|
"schema",
|
|
7
|
+
"source",
|
|
7
8
|
"plans"
|
|
8
9
|
],
|
|
9
10
|
"properties": {
|
|
10
11
|
"schema": {
|
|
11
12
|
"type": "integer"
|
|
12
13
|
},
|
|
14
|
+
"source": {
|
|
15
|
+
"type": "string"
|
|
16
|
+
},
|
|
13
17
|
"plans": {
|
|
14
18
|
"type": "array",
|
|
15
19
|
"items": {
|
|
@@ -52,7 +56,8 @@
|
|
|
52
56
|
"type": "object",
|
|
53
57
|
"required": [
|
|
54
58
|
"phase",
|
|
55
|
-
"status"
|
|
59
|
+
"status",
|
|
60
|
+
"state"
|
|
56
61
|
],
|
|
57
62
|
"properties": {
|
|
58
63
|
"phase": {
|
|
@@ -60,6 +65,16 @@
|
|
|
60
65
|
},
|
|
61
66
|
"status": {
|
|
62
67
|
"type": "string"
|
|
68
|
+
},
|
|
69
|
+
"state": {
|
|
70
|
+
"type": "string",
|
|
71
|
+
"enum": [
|
|
72
|
+
"todo",
|
|
73
|
+
"in-progress",
|
|
74
|
+
"blocked",
|
|
75
|
+
"done",
|
|
76
|
+
"moved"
|
|
77
|
+
]
|
|
63
78
|
}
|
|
64
79
|
}
|
|
65
80
|
}
|
|
@@ -395,6 +395,10 @@ Three rules: one attempt, one review.
|
|
|
395
395
|
| 1 | M1 | mid | claude | not started | — | — | |
|
|
396
396
|
```
|
|
397
397
|
|
|
398
|
+
Status words (one vocabulary, `scripts/caddis_status.py`): done is `done`, `merged`, `✅`, `☑`, `✔` or `✓`;
|
|
399
|
+
`in progress`, `blocked` and `moved` name the other states; anything else (`not started`, `☐`) is to do. A cell
|
|
400
|
+
that says `pending` is never done.
|
|
401
|
+
|
|
398
402
|
## Plan quality gate — local-coder ready (MANDATORY)
|
|
399
403
|
The plan must be executable by a **low-capability local coder model** (the planner→coder handoff: a
|
|
400
404
|
strong model plans, a cheaper/local model implements). The plan carries the intelligence; the coder
|
|
@@ -241,7 +241,8 @@ row, visible to any later reader without anyone having to catch it live.
|
|
|
241
241
|
open `caddis-run codex -m gpt-6-astra` and ask it to follow this same subsection.
|
|
242
242
|
|
|
243
243
|
**2. Determine where to resume.** The `## Tracker` table is the resume signal. Start at the first phase whose
|
|
244
|
-
status is not `done
|
|
244
|
+
status is not done (`done`, `merged`, `✅`, `☑`, `✔`, `✓`; never a cell that says `pending`;
|
|
245
|
+
one vocabulary in `scripts/caddis_status.py`). If every phase is already done, verify the tests are green and go straight to the
|
|
245
246
|
report — do not redo completed work.
|
|
246
247
|
|
|
247
248
|
**3. Implement each remaining phase, TDD-first.** For each phase, in order:
|
package/bundles/manifest.json
CHANGED
package/dist/cli.js
CHANGED
|
@@ -8921,7 +8921,7 @@ function plan(raw) {
|
|
|
8921
8921
|
path: str4(p2.path),
|
|
8922
8922
|
title: str4(p2.title),
|
|
8923
8923
|
status: str4(p2.status),
|
|
8924
|
-
tracker: arr2(p2.tracker).map((t) => ({ phase: str4(rec3(t).phase), status: str4(rec3(t).status) })),
|
|
8924
|
+
tracker: arr2(p2.tracker).map((t) => ({ phase: str4(rec3(t).phase), status: str4(rec3(t).status), state: str4(rec3(t).state) })),
|
|
8925
8925
|
open_rows: int(p2.open_rows)
|
|
8926
8926
|
};
|
|
8927
8927
|
}
|