ClaudeMods
☰
JA
● 0 人がオンライン ・閲覧 0 回
スポンサー作品を投稿
GitHub リポジトリ · 投稿者 josippapez

repo-docs

1 つのリポジトリ向けに、ローカルのセマンティックドキュメント検索、インストール済みパッケージ検索、JS/TS ファイルの影響範囲ツールを提供します。dev-core と orchestrate が共有します。

josippapez@josippapez

josippapez/ai-setup/tree/main/claude/plugins/repo-docs

翻訳済み

この mod について

1 つのリポジトリを対象に、ローカルのセマンティックドキュメント検索、インストール済みパッケージ検索、JS/TS ファイルの影響範囲確認を行うツールです。dev-core から切り出され、dev-core と orchestrate が同じ MCP サーバーとツール名前空間を共有できるようにしています。それぞれが同じコピーを同梱する必要はありません。

これらのツールを使うプラグインは、自分の README/skill で repo-docs を依存関係として宣言し、mcp__plugin_repo-docs_repo-docs__ が呼び出せない場合はユーザーにインストールを案内する必要があります。* claude/install.sh は dev-core と orchestrate と一緒に自動インストールします。

構成

  • .mcp.json — repo-docs サーバー(runtime):find_docs、list_docs、read_doc、find_libs、get_file_dependents、get_blast_radius。Markdown の規約、インストール済みパッケージ、あるファイルを直接または推移的に import する JS/TS ファイルを扱い、tsconfig の paths エイリアスとワークスペースパッケージ名も解決します。
  • hooks/ — 依存関係のセットアップ、インデックスのライフサイクル。
  • commands/ — /reindex と /repo-docs-ignore。

依存関係の自動インストール

手動で npm install を実行する必要はありません。SessionStart hook(hooks/hooks.json)は最初のセッションでプラグインの永続データディレクトリ(${CLAUDE_PLUGIN_DATA}/node_modules)に npm install を実行し、package.json が変わるたびに再実行します。MCP サーバーは NODE_PATH で依存関係を解決します。最初のセッションでは @huggingface/transformers のインストール中に少し時間がかかることがあります(bge-small モデルは約 128 MB)。以降は依存関係がプラグイン更新後も保持されるため、セッションはすぐに始まります。Embedding/reranker モデルはデフォルトで共有ディレクトリ ~/.claude/repo-docs-models にキャッシュされ、REPO_DOCS_MODELS_DIR 環境変数で変更できます。

接続時にドキュメントインデックスをウォームアップ

MCP は接続時にリポジトリの Markdown をバックグラウンドで事前埋め込みします(fire-and-forget、mtime キャッシュによる増分処理)。そのため最初の find_docs でインデックス作成のコストは発生しません。find_docs はチャンク化したハイブリッド検索(BM25 キーワード + 高密度な bge-small 埋め込み)を行い、ファイルごとに最適なチャンク、セクションアンカー、スニペットを返します。各チャンクは単独で 1 回、さらにドキュメントパスと見出しの階層を先頭に付けて 1 回埋め込みます。2 つのランキングを統合し、クロスエンコーダー(bge-reranker-base)が上位 10 件を判定します。判定には呼び出しごとに約半秒かかります。rerank: false を渡すか、すべての呼び出しで RERANK_ENABLED=0 を設定すると省略できます。モデルのロード中、または最初のインデックス構築前は、find_docs がキーワードスコアラーで回答し、そのことをヘッダーに示します。デフォルトでは read_doc は生ファイルを返すため、find_docs の行番号と一致します。compact: true では圧縮された読み取り結果を返します。変更ファイルの再構築はいつでも /reindex または node runtime/tools/build-semantic-index.cjs <repo-root> で強制できます(完全な再構築では先に .claude/repo-docs/ を削除します)。

Markdown ファイルに触れたターンの終了時、hooks/reindex.ts のモッドが hooks/reindex-on-edit.cjs を実行し、ローカルソケット(.claude/repo-docs/inject.sock)経由で実行中のサーバーに変更ドキュメントの再埋め込みを依頼します。再接続しなくても、セッション途中の編集を検索できます。

0.3.0 で削除されたもの

get_file_dependents と get_blast_radius は CodeGraph に置き換えられた後に削除され、0.5.0 で復活しました。TypeScript モノレポの影響測定タスクでは、CodeGraph が影響を受ける 16 ファイルのうち 9 ファイルを列挙し、get_blast_radius は 16 ファイルすべてを列挙しました。移動、リネーム、削除、API 変更の前にファイル一覧を得るために使います。CodeGraph 自体は 0.6.0 でプラグインから削除されました。積極的なドキュメントポインター注入(UserPromptSubmit と PostToolBatch hooks)と一度きりの Grep/Glob リマインダーは、39 セッションで 1,879 回注入しても read_doc の追跡利用が 0 回だったため削除されました。

終了時の回収

SessionEnd hook(hooks/reap-mcp-on-exit.cjs)は終了時にこのセッション自身の standalone-mcp.cjs プロセスを停止します。Claude Code はプラグイン MCP サーバーを常に回収するとは限らず、そうしないと蓄積するためです。

テスト

node --test claude/plugins/repo-docs/hooks/*.test.cjs claude/plugins/repo-docs/runtime/lib/*.test.cjs claude/plugins/repo-docs/runtime/tools/*.test.cjs

Mod

hooks/status.ts は .claude/repo-docs/index-build.lock が存在する間、ビルド率とともに「repo-docs: indexing docs…」を表示し、完了時に toast を表示します。

  • hooks/transcript.tsx は /repo-docs:reindex Bash 呼び出しを「Reindex repo docs」として描画し、結果を再埋め込み済み、変更なし、スキップしたドキュメント数の 1 行表示にします。
  • hooks/reindex.ts は古い PostToolUse 再インデックス hook を置き換えます。ターン終了時に Edit、Write、またはファイル名を指定する Bash コマンドで Markdown ファイルに触れていれば、実行中のサーバーへ変更ドキュメントの再埋め込みを 1 回依頼します。

インストール

まず作者の README で marketplace とプラグイン名を確認してください。コマンドはリポジトリの構成によって変わる場合があります。

claude plugin marketplace add josippapez/ai-setup
claude plugin install repo-docs
原文 / README

repo-docs

Local semantic doc search, installed-package lookup and JS/TS file-impact tools for one repository. Split out of dev-core so dev-core and orchestrate share one MCP server and one tool namespace instead of each bundling an identical copy.

Any plugin that uses its tools must declare repo-docs as a dependency in its own README/skill and tell the user to install it if mcp__plugin_repo-docs_repo-docs__* is not callable. claude/install.sh installs it automatically alongside dev-core and orchestrate.

Layout

  • .mcp.json — the repo-docs server (runtime/): find_docs, list_docs, read_doc, find_libs, get_file_dependents, get_blast_radius. Markdown conventions, installed packages, and which JS/TS files import a file (directly or transitively, resolving tsconfig paths aliases and workspace package names).
  • hooks/ — dependency setup, index lifecycle.
  • commands/ — /reindex and /repo-docs-ignore.

Dependencies auto-install

No manual npm install. A SessionStart hook (hooks/hooks.json) runs npm install into the plugin's persistent data dir (${CLAUDE_PLUGIN_DATA}/node_modules) on first session and again whenever package.json changes; the MCP server resolves them via NODE_PATH. The first session may take a moment while @huggingface/transformers installs (the bge-small model is ~128 MB); later sessions are instant (deps persist across plugin updates). Embedding/reranker models are cached in a shared dir — ~/.claude/repo-docs-models by default, override with the REPO_DOCS_MODELS_DIR env var.

Docs index warms on connect

The MCP pre-embeds the repo's Markdown in the background when it connects (fire-and-forget, incremental via an mtime cache), so the first find_docs doesn't pay the indexing cost. find_docs runs a chunked hybrid search (BM25 keyword + dense bge-small embeddings) and returns, per file, the best-matching chunk with its section anchor and a snippet. Each chunk is embedded twice, on its own and with its doc path and heading breadcrumb in front; the two rankings are fused, and a cross-encoder (bge-reranker-base) votes on the top 10. The vote adds about half a second per call; pass rerank: false, or set RERANK_ENABLED=0 for every call, to skip it. While the model is still loading or before the first index build, find_docs answers with a keyword scorer and says so in its header. read_doc returns the raw file by default, so find_docs line numbers line up; compact: true returns a minified read. Force a rebuild of changed files any time with /reindex or node runtime/tools/build-semantic-index.cjs <repo-root> (delete .claude/repo-docs/ first for a full rebuild).

At the end of a turn that touched a Markdown file, the mod in hooks/reindex.ts runs hooks/reindex-on-edit.cjs, which asks the running server, over a local socket (.claude/repo-docs/inject.sock), to re-embed changed docs, so mid-session doc edits are searchable without a reconnect.

Removed in 0.3.0

get_file_dependents and get_blast_radius came back in 0.5.0 after CodeGraph replaced them: on a measured impact task in a TypeScript monorepo, CodeGraph listed 9 of 16 affected files and get_blast_radius listed all 16. Use them for the file list before a move, rename, delete or API change. CodeGraph itself was dropped from the plugin in 0.6.0. The proactive doc-pointer injection (UserPromptSubmit and PostToolBatch hooks) and the one-shot Grep/Glob reminder were removed after measuring 1,879 injections across 39 sessions with zero read_doc follow-ups.

Reap on exit

A SessionEnd hook (hooks/reap-mcp-on-exit.cjs) kills this session's own standalone-mcp.cjs process on exit — Claude Code doesn't always reap plugin MCP servers, so they'd otherwise accumulate across sessions.

Tests

node --test claude/plugins/repo-docs/hooks/*.test.cjs claude/plugins/repo-docs/runtime/lib/*.test.cjs claude/plugins/repo-docs/runtime/tools/*.test.cjs

Mod

hooks/status.ts shows "repo-docs: indexing docs…" with the build percentage while .claude/repo-docs/index-build.lock exists, and a toast when the build finishes.

  • hooks/transcript.tsx draws the /repo-docs:reindex Bash call as "Reindex repo docs" and its result as a one-line count of re-embedded, unchanged and skipped docs.
  • hooks/reindex.ts replaces the old PostToolUse reindex hook: when a turn ends, if it touched a markdown file through Edit, Write or a Bash command naming one, it asks the running server to re-embed changed docs once.

関連作品