✨ feat(sarathi): a PreToolUse handler holds direct claude.ai publishes to the action box

Merged
AT
1d ago
+650-47

Slice: #669

The first of two pull requests (#669, "How"). veda's hooks run only the sarathi release the root package.json pins, so this one ships the handler and the check in sarathi 0.8.17. The pin bump and veda's .claude/sarathi.json and .claude/settings.json wiring follow the v0.8.17 tag, as a fix under a State of #669.

  • hooks/action-box.sh (source src/hooks/action-box.ts): a PreToolUse handler for ^mcp__.+__(publish_version|publish_files|edit_version)$, matched by suffix, not by server id. Using requireActionBox from src/page/page.ts, it refuses (exit 2):

    • a publish_version whose content lacks a whole action box;
    • a publish_files whose index.html (read from its path) lacks one, or cannot be read. A republish with no index.html passes.
    • an edit_version on the page (no path, or index.html) whose edits take out a data-action-box, data-action-link or data-if-silent.

    Any fault refuses too.

  • sarathi check takes several settings entries that run sarathi for one event. A handler's regular expression is covered only by an entry with the identical matcher, or one with none. A plain name two entries both cover is a problem, since sarathi would run twice. Every entry is held to the longest handler timeout. handlerMatchers replaces settingsMatcher. A single entry is judged as before, except that a regex handler no longer forces the settings entry to drop its matcher.

  • README ("The hooks", the handler table, SubagentStop, "Pages"), and two smoke lines: the wrapper on its own, and through sarathi hook PreToolUse with a regex-matched fixture config.

  • sarathi 0.8.17: v0.8.16 was tagged while this was built, so this takes the next legal version. VERSION follows.

deniedMcpServers, asked for with this work, is left out: #669's "Not here" gives the evidence that it did not drop the desktop's connectors, and that it could not be tested from a worktree.

Guards: per #669, packages/sarathi/README.md and packages/sarathi/package.json's smoke script.

🤖 Generated with Claude Code


Summary by cubic

The first of two PRs for #669 ("How"): ships a PreToolUse handler that holds a session's direct claude.ai publishes to the action box, in sarathi 0.8.17, along with the sarathi check rules its settings must meet. veda's pin bump and .claude wiring follow the v0.8.17 tag.

New Features

  • action-box.sh refuses publish_version, publish_files, and edit_version calls, matched by tool suffix, when the page lacks a whole action box, and refuses on any fault.
  • publish_files reads each served index.html from its path; a republish without one passes. edit_version on the page refuses only an edit that takes out a data-action-box, data-action-link, or data-if-silent marker.
  • sarathi check now accepts several settings entries per event, counts a regex handler as covered only by an entry with the identical matcher or one matching every tool, and holds every entry to the longest handler timeout.