josippapez/ai-setup/tree/main/claude/plugins/repo-docs
repo-docs
하나의 저장소를 위한 로컬 의미 기반 문서 검색, 설치된 패키지 조회, JS/TS 파일 영향 범위 도구입니다. dev-core와 orchestrate가 공유합니다.
이 mod 소개
하나의 저장소를 위한 로컬 의미 기반 문서 검색, 설치된 패키지 조회, 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 임베딩)을 수행하고 파일마다 가장 잘 맞는 청크, 섹션 앵커, 스니펫을 반환합니다. 각 청크를 자체적으로 한 번, 문서 경로와 제목 breadcrumb를 앞에 붙여 한 번 더 임베딩합니다. 두 순위를 합친 뒤 cross-encoder(bge-reranker-base)가 상위 10개를 평가합니다. 평가에는 호출마다 약 0.5초가 추가됩니다. 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”로 그리고, 결과를 다시 임베딩한 문서, 변경되지 않은 문서, 건너뛴 문서 수의 한 줄 요약으로 표시합니다.
- hooks/reindex.ts는 기존 PostToolUse 재인덱싱 hook을 대체합니다. 턴이 끝날 때 Edit, Write 또는 파일명을 지정한 Bash 명령으로 Markdown 파일을 건드렸다면 실행 중인 서버에 변경 문서를 한 번 다시 임베딩하도록 요청합니다.
설치
먼저 작성자의 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— therepo-docsserver (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 tsconfigpathsaliases and workspace package names).hooks/— dependency setup, index lifecycle.commands/—/reindexand/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.tsxdraws the/repo-docs:reindexBash call as "Reindex repo docs" and its result as a one-line count of re-embedded, unchanged and skipped docs.hooks/reindex.tsreplaces the oldPostToolUsereindex 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.
