✨ feat: kavach's worktree guard guards niyam sessions

Merged
AT
19d ago
+90-12

Slice: #389

Auto-merge is off on purpose. sarathi reads .claude/sarathi.json and the pin from $CLAUDE_PROJECT_DIR, which is the main checkout on the desktop. When Alok pulls main there, the worktree guard comes on for every desktop session, the ones already running included. Until pnpm install brings in sarathi 0.6.11, sarathi.sh refuses every Bash, Edit and Write. So this merges only when Alok is ready to git pull and pnpm install in /Users/alok/code/athya/niyam right after it.

What changes

  • @veda-hq/sarathi 0.6.10 → 0.6.11, which carries kavach 0.6.11. kavach now lets a session write its own scratchpad and the side-session notes folders the app granted it (veda-hq/veda#68, veda-hq/veda#111).
  • .claude/sarathi.json puts the worktree guard first, on Bash|Edit|Write|MultiEdit|NotebookEdit, and names .claude/kavach.json.
  • The PreToolUse matcher in .claude/settings.json widens to those five tools, as sarathi check --settings requires.
  • New .claude/kavach.json: veda's readOnlyCommands and ownCheckout, plus one reviewedCLIs entry, niyam review-thread with --body-file as its path option. niyam 0.6.19 and main were audited: it reads only the file it is given, and writes nothing locally.
  • Run on these files, onboard's claudeSettings() changes nothing.

Checked through sarathi hook PreToolUse

  • Let through:
    • writes to this session's scratchpad, its two granted notes folders, and the worktree;
    • pnpm check, install, build and lint;
    • git commit -F .tmp/…, git push, git fetch and git rebase;
    • gh pr create --body-file .tmp/…, gh issue comment and gh issue edit with --body-file .tmp/…;
    • niyam review-thread … --reply "…", --body-file and --resolve;
    • niyam propose and niyam --version.
  • Refused:
    • another session's scratchpad or notes folder, a .. escape, /tmp, and the main checkout;
    • any write from a session in the main checkout itself;
    • heredocs, node dist/cli.js … and node --test <file>;
    • the other niyam subcommands (listed in #389's Cost).

pnpm check passes.

🤖 Generated with Claude Code


Summary by cubic

Upgrades @veda-hq/sarathi to 0.6.11 so kavach's worktree guard covers niyam sessions. The guard now runs on Bash, Edit, Write, MultiEdit, and NotebookEdit instead of Bash alone, and new .claude/kavach.json lets a session write its own scratchpad and the notes folders the app granted it. Adds a reviewedCLIs entry so niyam review-thread passes with --reply.

Merge timing
Auto-merge is off on purpose: the guard activates in the main checkout the moment this merges, and every tool call in desktop sessions is refused until pnpm install pulls in sarathi 0.6.11. Merge only when ready to git pull and pnpm install immediately after.

Guard behavior

  • Passes: writes to the session's own scratchpad, granted notes folders, and worktree; pnpm check, install, build, lint; git commit -F .tmp/…, push, fetch, rebase; gh pr create and gh issue commands with --body-file .tmp/…; niyam review-thread with --reply, --body-file, or --resolve; niyam propose and --version.
  • Refuses: another session's scratchpad or notes folders, .. escapes, /tmp, the main checkout, any write from the main checkout itself, heredocs, node dist/cli.js …, node --test <file>, and other niyam subcommands.

pnpm check passes.