✨ feat(sarathi): worktree cleanup, services prune, worktree pick and the hooks-path hook

Merged
AT
8d ago
+9459-17

Slice: #371

Moves Athya's pnpm cleanup, the hourly Docker prune launchd agent, pnpm wt and the hooks-path healer into sarathi, so athya_mono can delete scripts/cleanup.ts, scripts/docker-prune-service.ts, scripts/wt.sh and scripts/heal-hooks-path.sh (athya_mono W-62.1, slice athya-hq/athya_mono#3745).

What sarathi gains:

  • sarathi worktree pick [--shell]: lists worktrees on stderr, prints only the chosen path; --shell prints the wt function that does the cd.
  • hooks/worktree-hooks-path.sh: at SessionStart, clears a worktree-scoped core.hooksPath in the session's checkout, so the shared value applies again.
  • sarathi services prune install|run|run-now|status|uninstall: the hourly Docker sweep as a launchd agent.
  • sarathi worktree cleanup [--dry-run], with its worktree.cleanup settings in .claude/sarathi.json.

Tests against the Athya originals: cleanup 157 → 168, faults 3 → 3, prune 60 → 64 (one added for Cubic's review, below), plus new pick and hooks-path cases.

Where sarathi now differs from the Athya scripts, from Cubic's first review (44c88ba, README in 09997c9):

  • the hooks-path handler does nothing unless extensions.worktreeConfig is on (in a single checkout git config --worktree falls back to .git/config, and it would have unset the project's own core.hooksPath);
  • worktree.cleanup paths refuse .git in any case;
  • cleanup lists ignored files by :(literal) pathspecs;
  • an unreadable folder in the git-ai step's keep list is an error, not an empty list;
  • the archive refuses a symbolic link in any folder above a destination;
  • pick reads git worktree list --porcelain -z and leaves out worktrees whose folders are gone; Ctrl-D at its prompt is an invalid selection, exit 1;
  • the prune keeps an image whose build or tag time does not read as a time, and runs its git greps one at a time.

The fourth commit, beyond the three-patch series, splits cleanup.test.ts verbatim at describe boundaries. At 3595 lines GitHub showed no diff for it, so niyam's Guard could not count its tests. The 168 cleanup tests now span cleanup.test.ts, cleanup.run.test.ts and cleanup.steps.test.ts, with the shared fake machine in cleanup.fixture.test.ts. Node reports 1031 tests rather than 1030 because it counts the test-less fixture file as one, as it does expect.test.ts.

No version bump here: the sarathi release follows the merge, in the slot the release coordinator gives (the next free v* tag, shared with #370).

Checks run locally on this head: pnpm --dir packages/sarathi run check (coverage 95/95/90, smoke included), pnpm lint, pnpm guards.

🤖 Generated with Claude Code