@caddis/cli 0.4.112 → 0.4.114

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 (29) hide show
  1. package/bundles/antigravity-plugin/plugin.json +1 -1
  2. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_exit.cpython-311.pyc +0 -0
  3. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_file_lock.cpython-311.pyc +0 -0
  4. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_frontmatter.cpython-311.pyc +0 -0
  5. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_redact.cpython-311.pyc +0 -0
  6. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_roadmap.cpython-311.pyc +0 -0
  7. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_rows.cpython-311.pyc +0 -0
  8. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_status.cpython-311.pyc +0 -0
  9. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_tidy.cpython-311.pyc +0 -0
  10. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_todo.cpython-311.pyc +0 -0
  11. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_workstreams.cpython-311.pyc +0 -0
  12. package/bundles/antigravity-plugin/scripts/__pycache__/caddis_worktree_safety.cpython-311.pyc +0 -0
  13. package/bundles/antigravity-plugin/scripts/caddis_coordinate.py +107 -1
  14. package/bundles/antigravity-plugin/scripts/caddis_guide.json +2 -2
  15. package/bundles/antigravity-plugin/scripts/oss_review.py +10 -5
  16. package/bundles/antigravity-plugin/skills/coordinate/SKILL.md +6 -2
  17. package/bundles/manifest.json +2 -2
  18. package/dist/cli.js +207 -113
  19. package/dist/ui/assets/{Activity-B816JVqx.js → Activity-CITEjSUJ.js} +1 -1
  20. package/dist/ui/assets/Benchmarks-B2_1oerW.css +1 -0
  21. package/dist/ui/assets/Benchmarks-ChQoYa0P.js +1 -0
  22. package/dist/ui/assets/{Guide-CnL1DiTr.js → Guide-9Ob-m7gx.js} +1 -1
  23. package/dist/ui/assets/{Palette-BKM_A64G.js → Palette-CinCoveU.js} +1 -1
  24. package/dist/ui/assets/{RoadmapTab-DhC4-kqv.js → RoadmapTab-BeD4-8IU.js} +2 -2
  25. package/dist/ui/assets/{external-link-DagTFCsV.js → external-link-D_rks7KV.js} +1 -1
  26. package/dist/ui/assets/index-CFKn_GzG.js +231 -0
  27. package/dist/ui/index.html +1 -1
  28. package/package.json +1 -1
  29. package/dist/ui/assets/index-Bj5qA-fq.js +0 -226
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "caddis",
3
- "version": "1.3.196",
3
+ "version": "1.3.198",
4
4
  "description": "caddis — agent-agnostic dev harness as an Antigravity (agy) plugin: TDD skills + commands, single-sourced with the Claude Code plugin."
5
5
  }
@@ -986,6 +986,7 @@ def ask_remove(rid: str, ask_id: str) -> bool:
986
986
  # --- command line (C1.5) ------------------------------------------------------------------------------------------
987
987
 
988
988
  EXIT_OK, EXIT_ERROR, EXIT_USAGE, EXIT_LOCK_REFUSED = 0, 1, 2, 3
989
+ EXIT_UNKNOWN = 4 # `stake` could not tell: the caller warns every live peer (fail closed)
989
990
 
990
991
 
991
992
  def _gh_head_of(rid: str) -> Callable[[int], str | None]:
@@ -1650,6 +1651,105 @@ def _claude_agents() -> list[dict]:
1650
1651
  return value
1651
1652
 
1652
1653
 
1654
+ # --- stake test (design 7.3a) --------------------------------------------------------------------------------------
1655
+
1656
+ _SESSION_ENV_VARS = ("CADDIS_SESSION_ID", "CLAUDE_SESSION_ID", "CLAUDE_CODE_SESSION_ID") # as caddis_adhoc
1657
+ _WIN_ABS = re.compile(r"^(?:[A-Za-z]:[\\/]|[\\/]{2})") # E:\ or E:/ or a UNC path
1658
+
1659
+
1660
+ def _path_key(path: str) -> str | None:
1661
+ """Return a comparable key for an absolute path, else None (unknown).
1662
+
1663
+ Separators become `/`, `.` and `..` collapse, and case folds on every platform: a false match only adds a
1664
+ warning, a missed match drops one (fail closed). A path real on this machine is resolved first (junctions)."""
1665
+ text = path.strip()
1666
+ if not text or not (os.path.isabs(text) or _WIN_ABS.match(text)):
1667
+ return None
1668
+ if os.path.isabs(text):
1669
+ text = os.path.realpath(text)
1670
+ text = text.replace("\\", "/")
1671
+ unc = text.startswith("//")
1672
+ text = re.sub(r"/{2,}", "/", text)
1673
+ parts: list[str] = []
1674
+ for part in text.split("/"):
1675
+ if part == "..":
1676
+ if len(parts) > 1:
1677
+ parts.pop()
1678
+ elif part not in (".", "") or not parts:
1679
+ parts.append(part)
1680
+ return ("/" if unc else "") + "/".join(parts).casefold()
1681
+
1682
+
1683
+ def _inside(key: str, root: str) -> bool:
1684
+ return key == root or key.startswith(root.rstrip("/") + "/")
1685
+
1686
+
1687
+ def stake_report(agents: list[dict], roots: list[str]) -> list[tuple[str, str, str]]:
1688
+ """Return `(verdict, name, detail)` per agent: `STAKE` with a reason, or `NO-STAKE` with its cwd.
1689
+
1690
+ `roots` are the checkout and its worktrees. The caller's own session (sessionId equal to a session env
1691
+ variable) is left out. A cwd that is missing, empty or not absolute is a stake."""
1692
+ own = {os.environ[v] for v in _SESSION_ENV_VARS if os.environ.get(v)}
1693
+ root_keys = [(root, key) for root in roots if (key := _path_key(root)) is not None]
1694
+ report = []
1695
+ for agent in agents:
1696
+ if own and agent.get("sessionId") in own:
1697
+ continue
1698
+ name = str(agent.get("name") or agent.get("sessionId") or "<unnamed>")
1699
+ cwd = agent.get("cwd")
1700
+ key = _path_key(cwd) if isinstance(cwd, str) else None
1701
+ if key is None:
1702
+ report.append(("STAKE", name, f"cwd unknown ({cwd!r})"))
1703
+ continue
1704
+ hit = next((root for root, root_key in root_keys if _inside(key, root_key)), None)
1705
+ if hit is not None:
1706
+ report.append(("STAKE", name, f"cwd {cwd} is in {hit}"))
1707
+ else:
1708
+ report.append(("NO-STAKE", name, cwd))
1709
+ return report
1710
+
1711
+
1712
+ def _repo_roots(repo: Path) -> list[str]:
1713
+ """Return the checkout and every worktree of the repo at `repo`. Raise OSError when git cannot tell."""
1714
+ try:
1715
+ result = _run(["git", "-C", str(repo), "worktree", "list", "--porcelain"])
1716
+ except subprocess.TimeoutExpired as exc:
1717
+ raise OSError(f"git worktree list timed out after {_TIMEOUT} s") from exc
1718
+ if result.returncode != 0:
1719
+ detail = " ".join((result.stderr or result.stdout or "").split()) or f"exit {result.returncode}"
1720
+ raise OSError(f"git worktree list failed in {repo}: {detail}")
1721
+ roots = [line[len("worktree "):].strip() for line in result.stdout.splitlines() if line.startswith("worktree ")]
1722
+ if not roots:
1723
+ raise OSError(f"git worktree list printed no worktree for {repo}")
1724
+ return [str(repo.resolve())] + roots
1725
+
1726
+
1727
+ def _stake(args: argparse.Namespace) -> int:
1728
+ """Print `STAKE`/`NO-STAKE` per peer and a summary; `STAKE-UNKNOWN: <reason>` and exit 4 when it cannot tell."""
1729
+ try:
1730
+ if args.agents_json:
1731
+ try:
1732
+ agents = json.loads(Path(args.agents_json).read_text(encoding="utf-8"))
1733
+ except ValueError as exc:
1734
+ raise ValueError("the agents file is not JSON") from exc
1735
+ else:
1736
+ agents = _claude_agents()
1737
+ if not isinstance(agents, list) or not all(isinstance(a, dict) for a in agents):
1738
+ raise ValueError("the agents list is not a JSON list of objects")
1739
+ report = stake_report(agents, _repo_roots(Path(args.repo)))
1740
+ except (OSError, ValueError, subprocess.SubprocessError) as exc:
1741
+ reason = " ".join(str(exc).split()) or type(exc).__name__
1742
+ _emit(args, {"result": "unknown", "reason": reason}, f"STAKE-UNKNOWN: {reason}")
1743
+ return EXIT_UNKNOWN
1744
+ stakes = sum(1 for verdict, _, _ in report if verdict == "STAKE")
1745
+ skipped = len(agents) - len(report)
1746
+ summary = f"SUMMARY: {stakes} stake, {len(report) - stakes} no stake, {skipped} self skipped"
1747
+ lines = [f"{verdict} {name} {detail}" for verdict, name, detail in report] + [summary]
1748
+ _emit(args, {"result": "ok", "peers": [{"verdict": v, "name": n, "detail": d} for v, n, d in report],
1749
+ "self_skipped": skipped}, "\n".join(lines))
1750
+ return EXIT_OK
1751
+
1752
+
1653
1753
  def _waits_on(text: str) -> list[dict]:
1654
1754
  try:
1655
1755
  value = json.loads(text)
@@ -1691,6 +1791,10 @@ def _parser() -> argparse.ArgumentParser:
1691
1791
  p.add_argument("--pr", type=int, required=True, help="the PR whose diff to check (`gh pr diff`)")
1692
1792
  p.add_argument("--gh-repo", help="owner/name for `gh pr diff -R` (default: the current folder's repo)")
1693
1793
 
1794
+ p = command("stake", repo=False)
1795
+ p.add_argument("--repo", required=True, help="a path to the checkout or one of its worktrees (not a repo id)")
1796
+ p.add_argument("--agents-json", help="read the agents list from this file, not `claude agents --json` (tests)")
1797
+
1694
1798
  p = command("session", repo=False)
1695
1799
  which = p.add_mutually_exclusive_group(required=True)
1696
1800
  which.add_argument("--session-id", help="the Claude Code sessionId to find")
@@ -1778,6 +1882,8 @@ def _dispatch(args: argparse.Namespace) -> int:
1778
1882
  rid = repo_id_for(Path(args.path))
1779
1883
  _emit(args, {"repo": rid}, rid)
1780
1884
  return EXIT_OK
1885
+ if args.command == "stake":
1886
+ return _stake(args)
1781
1887
  if args.command == "session":
1782
1888
  found = session_lookup(_claude_agents(), session_id=args.session_id, name=args.name)
1783
1889
  _emit(args, found, f"pid {found['pid']} ({found['name']})")
@@ -1891,7 +1997,7 @@ def _dispatch(args: argparse.Namespace) -> int:
1891
1997
 
1892
1998
  def main(argv: list[str] | None = None) -> int:
1893
1999
  """Run one subcommand. Exit 0 on success, 1 on an error (one line on stderr), 2 on a usage error, 3 when the
1894
- lock is refused."""
2000
+ lock is refused, 4 when `stake` cannot tell (`STAKE-UNKNOWN`)."""
1895
2001
  try:
1896
2002
  parser = _parser()
1897
2003
  args = parser.parse_args(argv)
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schema": 1,
3
- "version": "1.3.195",
4
- "generated": "2026-11-13 03:53 UTC",
3
+ "version": "1.3.197",
4
+ "generated": "2026-11-13 19:04 UTC",
5
5
  "commands": [
6
6
  {
7
7
  "name": "add-rules",
@@ -775,15 +775,17 @@ def _kill_tree(proc) -> None:
775
775
  proc.kill()
776
776
 
777
777
 
778
- def _run_capped(argv: list[str], timeout: float, stdin_text: str | None = None) -> tuple[int, str, str]:
779
- """Run `argv`; (exit, stdout, stderr). stdin carries `stdin_text`, then closes (closed at once when None).
778
+ def _run_capped(argv: list[str], timeout: float, stdin_text: str | None = None,
779
+ cwd: str | None = None) -> tuple[int, str, str]:
780
+ """Run `argv` in `cwd` (None: this process's cwd); (exit, stdout, stderr). stdin carries `stdin_text`, then
781
+ closes (closed at once when None).
780
782
  On timeout kill the whole tree and raise TimeoutError: a killed caddis_spend must not leave agy running on."""
781
783
  group = ({"creationflags": subprocess.CREATE_NEW_PROCESS_GROUP} if os.name == "nt"
782
784
  else {"start_new_session": True})
783
785
  env = {**os.environ, "CADDIS_HEADLESS": "1"}
784
786
  stdin = subprocess.DEVNULL if stdin_text is None else subprocess.PIPE
785
787
  proc = subprocess.Popen(argv, stdin=stdin, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
786
- text=True, encoding="utf-8", errors="replace", env=env, **group)
788
+ text=True, encoding="utf-8", errors="replace", env=env, cwd=cwd, **group)
787
789
  try:
788
790
  stdout, stderr = proc.communicate(input=stdin_text, timeout=timeout)
789
791
  except subprocess.TimeoutExpired:
@@ -824,15 +826,18 @@ def agy_stdin(prompt: str) -> str:
824
826
  return json.dumps({"event": "user", "message": {"content": prompt}}) + "\n"
825
827
 
826
828
 
827
- def call_agy(launcher: list[str], prompt: str, timeout: float = AGY_TIMEOUT_S, model: str = AGY_MODEL) -> str:
829
+ def call_agy(launcher: list[str], prompt: str, timeout: float = AGY_TIMEOUT_S, model: str = AGY_MODEL,
830
+ cwd: str | None = None) -> str:
828
831
  """One review by agy Carbon (`model`) through `caddis_spend.py run` -> the reply text.
829
832
 
833
+ `cwd` roots the agy run there (None: this process's cwd).
834
+
830
835
  The prompt goes on stdin (agy_stdin), never on the command line.
831
836
  ProviderSkipped: caddis_spend refused (exit 75) or agy is missing.
832
837
  ProviderFailure: a non-zero exit, a status other than SUCCESS (ERROR, RESOURCE_EXHAUSTED), no result
833
838
  event, or an empty reply."""
834
839
  argv = [*launcher, "--model", model, "--mode", "plan", *AGY_STREAM_FLAGS, "--print="]
835
- code, stdout, stderr = _run_capped(argv, timeout, stdin_text=agy_stdin(prompt))
840
+ code, stdout, stderr = _run_capped(argv, timeout, stdin_text=agy_stdin(prompt), cwd=cwd)
836
841
  if code in SPEND_REFUSED:
837
842
  raise ProviderSkipped(f"caddis_spend refused the agy call (exit {code}): "
838
843
  f"{stderr.strip()[-300:]}")
@@ -231,8 +231,12 @@ and 7.3. While the queue is frozen (section 5 step 1), do steps 3.1 to 3.3 only.
231
231
  9. Send `merge-warning <PR> <watched sha> in 2 min. Reply ack <PR> <sha> or hold.` to every live peer
232
232
  that has a stake in this repo (design 7.3), and `queue set --repo <R> --pr <n> --state merging`. Send
233
233
  `re-warn <PR> <sha>` after any coordinator restart and after any new head on a warned PR. Old acks do not count.
234
- Stake test, run for each live peer at the warning (design 7.3a). A peer has a stake when ANY of these
235
- holds: its cwd is inside the checkout or one of its worktrees (for example under
234
+ Stake test, run at the warning (design 7.3a): run
235
+ `python "${CLAUDE_PLUGIN_ROOT}/scripts/caddis_coordinate.py" stake --repo <checkout>`. Warn every `STAKE`
236
+ peer and every peer the script does not list; warn no `NO-STAKE` peer unless the queue, the ledger or a
237
+ `ready`/`phase` message ties it to this repo. `STAKE-UNKNOWN` (exit 4): warn every live peer. The script
238
+ only decides by cwd; it never removes a stake that the queue, the ledger or a message gives. A peer has a
239
+ stake when ANY of these holds: its cwd is inside the checkout or one of its worktrees (for example under
236
240
  `.worktrees/<repo>/`); the queue or the ledger lists a PR, branch or plan phase of that peer in this
237
241
  repo; or it has sent `ready` or `phase` for this repo. Anything else is no stake. When the cwd is
238
242
  unknown or you are unsure, the peer has a stake. A peer with no stake gets no warning and is not in
@@ -1,7 +1,7 @@
1
1
  {
2
- "poolVersion": "1.3.196",
2
+ "poolVersion": "1.3.198",
3
3
  "bundles": {
4
- "antigravity-plugin": "1.3.196",
4
+ "antigravity-plugin": "1.3.198",
5
5
  "antigravity-plugin-extras": "1.3.54",
6
6
  "codex": "unknown"
7
7
  }