✨ feat: niyam's sessions run veda's released sarathi and kavach

Merged
AT
19d ago
+133-4

Slice: #299

Auto-merge is off on purpose. On the desktop $CLAUDE_PROJECT_DIR is the main checkout, so every session on the new main runs the main checkout's .claude/hooks/sarathi.sh:

  • Before Alok pulls main there, that file is missing, so new sessions get no niyam session-start: no agent identity, and GitHub stays locked.
  • After the pull, sarathi.sh refuses every Bash call until the pin is installed.

So this merges only after Alok says he is ready to git pull and pnpm install in /Users/alok/code/athya/niyam right after it. Auto-merge goes on then.

What changes

  • @veda-hq/sarathi 0.6.10, which carries kavach 0.6.10, pinned exactly. These are the latest releases.
  • .claude/hooks/sarathi.sh is veda's file, copied verbatim. It loads sarathi only from $CLAUDE_PROJECT_DIR/node_modules at the pin, never from source.
  • .claude/settings.json has one sarathi entry per event: SessionStart (600 s) and PreToolUse on Bash (70 s). niyam's env lock and permissions stay there.
  • .claude/sarathi.json holds niyam's session-start (600 s) and guard (Bash, failClosed) handlers, the way niyam onboard writes them since #318. kavach's command guard runs beside them on Bash. Run on these files, onboard 0.6.20's claudeSettings() changes nothing.
  • pnpm check runs pnpm hooks:check, which is sarathi check --settings .claude/settings.json.

kavach's worktree guard stays off

I checked kavach 0.6.10's worktree_guard.py on sample calls:

  • niyam review-thread PRRT_… --reply "…" is let through, as a worktree.reviewedCLIs entry.
  • A Write to the session scratchpad is refused: BLOCKED: mutation target /private/tmp/claude-501/…/scratchpad/x.md is outside this session's Claude worktree …; that is a system temp folder.
  • A Write to the side-session notes folder is refused: BLOCKED: mutation target …/side-session-notes/…/x.md is outside this session's Claude worktree.

So there is no worktree guard and no .claude/kavach.json yet, as #299 records.

Checks

  • pnpm check passes on main 7eb6a31.
  • niyam doctor (from dist/) prints "All good".
  • I ran these through sarathi hook PreToolUse: a gh issue comment --body-file - heredoc, gh pr create, git push -u origin, niyam review-thread --reply and pnpm check all pass, and git push --no-verify is refused.

Guards: package.json (its scripts), named in #299's Guards:. Alok re-approved #295 at 12:12:41Z.

🤖 Generated with Claude Code


Summary by cubic

Wires niyam's Claude sessions to run veda's released @veda-hq/sarathi 0.6.10 (with kavach 0.6.10), replacing the inline hooks in .claude/settings.json. Pins @veda-hq/sarathi 0.6.10 exactly; .claude/hooks/sarathi.sh (copied verbatim from veda) loads sarathi only from $CLAUDE_PROJECT_DIR's node_modules at the pin; niyam's session-start and guard handlers move to .claude/sarathi.json (as niyam onboard writes them), beside kavach's command guard; pnpm check now runs sarathi check --settings .claude/settings.json. kavach's worktree guard stays off as #299 records: 0.6.10 admits niyam review-thread --reply but refuses writes to the session scratchpad and side-session notes.

Rollout

  • Auto-merge is off on purpose: on the desktop $CLAUDE_PROJECT_DIR is the main checkout, so a merge before Alok pulls leaves sessions without a niyam session-start, and after he pulls, sarathi.sh refuses every Bash call until the pin is installed.
  • Merge only after Alok is ready to git pull and pnpm install right after in /Users/alok/code/athya/niyam.
  • pnpm check passes on main, niyam doctor prints "All good", and PreToolUse runs of gh issue comment, gh pr create, git push -u origin, niyam review-thread --reply, and pnpm check pass; git push --no-verify is refused.