✨ feat(sarathi): sarathi where answers module-graph questions from the project's depcruise, 0.8.9
Slice: #566
sarathi where is a port of athya_mono's scripts/where.ts (W-69, athya-hq/athya_mono#3631). Once it ships, athya_mono deletes its own copy and calls sarathi where.
What it keeps
- The modes:
<regex>(focus,--depth N, default 1),--reaches/-r, and--affected [rev](defaultmain). - The flags:
--scope DIR(repeatable, defaultapps packages),--max N(default 60) and--help. - The output: one
a → bedge per line, deduplicated and sorted, then… N more of M (raise with --max)when it truncates. EXCLUDED, unchanged.- The exit codes: 0 is an answer, 2 a usage error, and every other failure is non-zero. athya_mono's android e2e gate reads non-zero as "the graph failed, run everything".
What changes for a package
- depcruise:
whereruns the project's ownnode_modules/.bin/depcruise, found fromgit rev-parse --show-toplevel, so sarathi gains no dependency. Without it,whererefuses and names the binary. - Config: the dependency-cruiser config comes from
--config, or fromwhere.configin.claude/sarathi.json. With neither,whererefuses rather than fall back to the project's default config. athya_mono's gate config deliberately resolves@athya/sharedtodist, and a fallback to it would look right while losing edges. - Failures: no checkout, no binary, no config, a killed child, or a failed cruise that printed nothing all exit 1, with the reason on stderr. stdout carries only the answer.
sarathi check: it validates the newwherekey, andconfig.tsaccepts it at the top level.
Upgrade order: releases before this one refuse a top-level where key, and on PreToolUse that refuses every tool call. A project adds the key only once every checkout runs the new release, and uses --config until then. The README section says so.
Tests: where.test.ts covers argument parsing, the depcruise arguments, EXCLUDED, the edge formatting and truncation, the spawn-failure handling, and whereMain in real git checkouts against a stub depcruise. athya_mono keeps one wiring test that runs against its real repository.
Version: sarathi goes to 0.8.9 and shares v0.8.9 with W-50's pariksha PR, as the 0114 coordinator decided. Whichever PR merges second pushes the tag.
🤖 Generated with Claude Code
Summary by cubic
Adds sarathi where, a port of athya_mono's scripts/where.ts, that answers module-graph questions from the project's own dependency-cruiser, so a session need not open files to find what a module sits next to or what depends on it.
- Supports
<regex>focus with--depth N,--reaches/-r, and--affected [rev](defaultmain), plus--scope DIR(repeatable, defaultapps packages; a folder starting with-is refused, since depcruise would read it as an option),--max N(default 60), and--help. - Prints one
a → bedge per line, deduplicated and sorted, then… N more of M (raise with --max)when truncated. - Runs the project's
node_modules/.bin/depcruisefromgit rev-parse --show-toplevel, so sarathi gains no dependency; it refuses when the binary is missing. - Config comes from
--configorwhere.configin.claude/sarathi.json; without either it refuses rather than fall back to the project's default config, which would look right while dropping every edge into a package's source. - Exit 0 is an answer, exit 2 a usage error, exit 1 a failure with the reason on stderr, so callers reading non-zero as "the graph failed" keep working;
sarathi checkvalidates the newwherekey. - Version bumps to 0.8.9; projects add the
wherekey only once every checkout runs 0.8.9 or later, since older releases refuse unknown top-level keys.