codebase-index 1.6.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (288) hide show
  1. codebase_index-1.6.0/.claude/skills/codebase-index/.skill_version +1 -0
  2. codebase_index-1.6.0/.claude/skills/codebase-index/SKILL.md +198 -0
  3. codebase_index-1.6.0/.claude/skills/codebase-index/examples/hooks/settings.json +16 -0
  4. codebase_index-1.6.0/.claude/skills/codebase-index/scripts/cbx +25 -0
  5. codebase_index-1.6.0/.claude/skills/codebase-index/scripts/cbx.ps1 +25 -0
  6. codebase_index-1.6.0/.claude-plugin/marketplace.json +11 -0
  7. codebase_index-1.6.0/.claude-plugin/plugin.json +25 -0
  8. codebase_index-1.6.0/.codex/skills/codebase-index/.skill_version +1 -0
  9. codebase_index-1.6.0/.codex/skills/codebase-index/SKILL.md +198 -0
  10. codebase_index-1.6.0/.codex/skills/codebase-index/examples/hooks/settings.json +16 -0
  11. codebase_index-1.6.0/.codex/skills/codebase-index/scripts/cbx +25 -0
  12. codebase_index-1.6.0/.codex/skills/codebase-index/scripts/cbx.ps1 +25 -0
  13. codebase_index-1.6.0/.editorconfig +28 -0
  14. codebase_index-1.6.0/.gitattributes +7 -0
  15. codebase_index-1.6.0/.github/FUNDING.yml +8 -0
  16. codebase_index-1.6.0/.github/ISSUE_TEMPLATE/bug_report.yml +74 -0
  17. codebase_index-1.6.0/.github/ISSUE_TEMPLATE/feature_request.yml +56 -0
  18. codebase_index-1.6.0/.github/ISSUE_TEMPLATE/skill_listing_request.yml +42 -0
  19. codebase_index-1.6.0/.github/PULL_REQUEST_TEMPLATE.md +38 -0
  20. codebase_index-1.6.0/.github/workflows/ci.yml +44 -0
  21. codebase_index-1.6.0/.github/workflows/release.yml +62 -0
  22. codebase_index-1.6.0/.gitignore +39 -0
  23. codebase_index-1.6.0/.opencode/agents/codebase-index.md +148 -0
  24. codebase_index-1.6.0/.opencode/commands/codebase-index.md +12 -0
  25. codebase_index-1.6.0/.opencode/skills/codebase-index/.skill_version +1 -0
  26. codebase_index-1.6.0/.opencode/skills/codebase-index/SKILL.md +198 -0
  27. codebase_index-1.6.0/.opencode/skills/codebase-index/examples/hooks/settings.json +16 -0
  28. codebase_index-1.6.0/.opencode/skills/codebase-index/scripts/cbx +25 -0
  29. codebase_index-1.6.0/.opencode/skills/codebase-index/scripts/cbx.ps1 +25 -0
  30. codebase_index-1.6.0/AGENTS.md +57 -0
  31. codebase_index-1.6.0/CHANGELOG.md +388 -0
  32. codebase_index-1.6.0/CODE_OF_CONDUCT.md +132 -0
  33. codebase_index-1.6.0/CONTRIBUTING.md +162 -0
  34. codebase_index-1.6.0/LICENSE +21 -0
  35. codebase_index-1.6.0/PKG-INFO +748 -0
  36. codebase_index-1.6.0/README.md +698 -0
  37. codebase_index-1.6.0/ROADMAP.md +112 -0
  38. codebase_index-1.6.0/SECURITY.md +51 -0
  39. codebase_index-1.6.0/adapters/claude.ps1 +68 -0
  40. codebase_index-1.6.0/adapters/claude.sh +92 -0
  41. codebase_index-1.6.0/adapters/codex.ps1 +85 -0
  42. codebase_index-1.6.0/adapters/codex.sh +109 -0
  43. codebase_index-1.6.0/adapters/opencode.ps1 +105 -0
  44. codebase_index-1.6.0/adapters/opencode.sh +121 -0
  45. codebase_index-1.6.0/assets/demo.png +0 -0
  46. codebase_index-1.6.0/assets/social-preview.png +0 -0
  47. codebase_index-1.6.0/bin/cbx +30 -0
  48. codebase_index-1.6.0/bin/cbx.ps1 +27 -0
  49. codebase_index-1.6.0/bin/codebase-index +4 -0
  50. codebase_index-1.6.0/bin/codebase-index.ps1 +8 -0
  51. codebase_index-1.6.0/docs/ARCHITECTURE.md +230 -0
  52. codebase_index-1.6.0/docs/BENCHMARKS.md +115 -0
  53. codebase_index-1.6.0/docs/COMPARISON.md +185 -0
  54. codebase_index-1.6.0/docs/DATABASE_SCHEMA.md +185 -0
  55. codebase_index-1.6.0/docs/FAQ.md +179 -0
  56. codebase_index-1.6.0/docs/INSTALLATION.md +289 -0
  57. codebase_index-1.6.0/docs/LANGUAGES.md +93 -0
  58. codebase_index-1.6.0/docs/MCP.md +173 -0
  59. codebase_index-1.6.0/docs/PRODUCT_UPGRADE_PLAN.md +171 -0
  60. codebase_index-1.6.0/docs/QUICKSTART.md +129 -0
  61. codebase_index-1.6.0/docs/RELEASE_CHECKLIST.md +120 -0
  62. codebase_index-1.6.0/docs/RETRIEVAL.md +164 -0
  63. codebase_index-1.6.0/docs/RETRIEVAL_PIPELINE.md +147 -0
  64. codebase_index-1.6.0/docs/ROADMAP.md +111 -0
  65. codebase_index-1.6.0/docs/SCHEMA.md +170 -0
  66. codebase_index-1.6.0/docs/SECURITY.md +110 -0
  67. codebase_index-1.6.0/docs/SECURITY_MODEL.md +111 -0
  68. codebase_index-1.6.0/docs/SEO.md +196 -0
  69. codebase_index-1.6.0/docs/SKILL_DESIGN.md +126 -0
  70. codebase_index-1.6.0/docs/installer.md +240 -0
  71. codebase_index-1.6.0/docs/superpowers/plans/2026-05-29-benchmark-index-improvements.md +873 -0
  72. codebase_index-1.6.0/docs/superpowers/plans/2026-05-29-generalize-skill-research-discipline.md +293 -0
  73. codebase_index-1.6.0/docs/superpowers/plans/2026-05-29-m1-storage-discovery.md +1542 -0
  74. codebase_index-1.6.0/docs/superpowers/plans/2026-05-29-m2-fts-lexical.md +1186 -0
  75. codebase_index-1.6.0/docs/superpowers/plans/2026-05-29-m3-treesitter-symbols.md +1486 -0
  76. codebase_index-1.6.0/docs/superpowers/plans/2026-05-29-m4-hybrid-search.md +1585 -0
  77. codebase_index-1.6.0/docs/superpowers/plans/2026-05-29-m5-graph-impact.md +1294 -0
  78. codebase_index-1.6.0/docs/superpowers/plans/2026-05-29-m6-embeddings-vector.md +1568 -0
  79. codebase_index-1.6.0/docs/superpowers/plans/2026-05-29-m7-5-plugin-one-command-install.md +890 -0
  80. codebase_index-1.6.0/docs/superpowers/plans/2026-05-29-m7-skill-packaging.md +948 -0
  81. codebase_index-1.6.0/docs/superpowers/plans/2026-05-29-m8-hooks-watch.md +1315 -0
  82. codebase_index-1.6.0/docs/superpowers/plans/2026-05-29-m9-release.md +938 -0
  83. codebase_index-1.6.0/docs/superpowers/plans/2026-05-29-multilang-symbols-make-skill-win.md +198 -0
  84. codebase_index-1.6.0/docs/superpowers/plans/2026-06-24-snippet-skeletonization.md +1140 -0
  85. codebase_index-1.6.0/docs/superpowers/specs/2026-05-29-plugin-one-command-install-design.md +130 -0
  86. codebase_index-1.6.0/docs/superpowers/specs/2026-06-14-typed-framework-edges-design.md +136 -0
  87. codebase_index-1.6.0/docs/superpowers/specs/2026-06-24-snippet-skeletonization-design.md +260 -0
  88. codebase_index-1.6.0/examples/config.example.json +23 -0
  89. codebase_index-1.6.0/examples/demo-project/README.md +55 -0
  90. codebase_index-1.6.0/examples/hooks/settings.json +18 -0
  91. codebase_index-1.6.0/examples/queries.md +29 -0
  92. codebase_index-1.6.0/examples/sample-queries.md +67 -0
  93. codebase_index-1.6.0/examples/sample-retrieval-output.md +140 -0
  94. codebase_index-1.6.0/hooks/hooks.json +14 -0
  95. codebase_index-1.6.0/install.ps1 +186 -0
  96. codebase_index-1.6.0/install.sh +260 -0
  97. codebase_index-1.6.0/lib/common.ps1 +312 -0
  98. codebase_index-1.6.0/lib/common.sh +450 -0
  99. codebase_index-1.6.0/pyproject.toml +103 -0
  100. codebase_index-1.6.0/requirements.lock +3 -0
  101. codebase_index-1.6.0/scripts/bootstrap.ps1 +50 -0
  102. codebase_index-1.6.0/scripts/bootstrap.sh +57 -0
  103. codebase_index-1.6.0/scripts/gen_assets.py +291 -0
  104. codebase_index-1.6.0/scripts/release_smoke.py +79 -0
  105. codebase_index-1.6.0/scripts/sync_skill_copies.py +175 -0
  106. codebase_index-1.6.0/skill/SKILL.md +198 -0
  107. codebase_index-1.6.0/skill/examples/basic-usage.md +87 -0
  108. codebase_index-1.6.0/skill/examples/claude-md-example.md +54 -0
  109. codebase_index-1.6.0/skill/examples/hooks-example.json +19 -0
  110. codebase_index-1.6.0/skill/scripts/bootstrap.py +183 -0
  111. codebase_index-1.6.0/skill/scripts/cbx +25 -0
  112. codebase_index-1.6.0/skill/scripts/cbx.ps1 +25 -0
  113. codebase_index-1.6.0/skill/scripts/doctor.py +118 -0
  114. codebase_index-1.6.0/skill/scripts/install.py +73 -0
  115. codebase_index-1.6.0/skill/scripts/smoke_test.py +123 -0
  116. codebase_index-1.6.0/skills/codebase-index/SKILL.md +198 -0
  117. codebase_index-1.6.0/src/codebase_index/__init__.py +7 -0
  118. codebase_index-1.6.0/src/codebase_index/__main__.py +3 -0
  119. codebase_index-1.6.0/src/codebase_index/cli.py +916 -0
  120. codebase_index-1.6.0/src/codebase_index/config.py +110 -0
  121. codebase_index-1.6.0/src/codebase_index/discovery/__init__.py +10 -0
  122. codebase_index-1.6.0/src/codebase_index/discovery/classify.py +151 -0
  123. codebase_index-1.6.0/src/codebase_index/discovery/ignore.py +58 -0
  124. codebase_index-1.6.0/src/codebase_index/discovery/walker.py +75 -0
  125. codebase_index-1.6.0/src/codebase_index/doctor.py +138 -0
  126. codebase_index-1.6.0/src/codebase_index/embeddings/__init__.py +2 -0
  127. codebase_index-1.6.0/src/codebase_index/embeddings/backend.py +67 -0
  128. codebase_index-1.6.0/src/codebase_index/embeddings/external.py +56 -0
  129. codebase_index-1.6.0/src/codebase_index/embeddings/local.py +41 -0
  130. codebase_index-1.6.0/src/codebase_index/embeddings/noop.py +15 -0
  131. codebase_index-1.6.0/src/codebase_index/graph/__init__.py +8 -0
  132. codebase_index-1.6.0/src/codebase_index/graph/analysis.py +468 -0
  133. codebase_index-1.6.0/src/codebase_index/graph/builder.py +160 -0
  134. codebase_index-1.6.0/src/codebase_index/graph/expand.py +136 -0
  135. codebase_index-1.6.0/src/codebase_index/graph/export.py +381 -0
  136. codebase_index-1.6.0/src/codebase_index/graph/navigate.py +201 -0
  137. codebase_index-1.6.0/src/codebase_index/indexer/__init__.py +8 -0
  138. codebase_index-1.6.0/src/codebase_index/indexer/doc_chunks.py +202 -0
  139. codebase_index-1.6.0/src/codebase_index/indexer/freshness.py +109 -0
  140. codebase_index-1.6.0/src/codebase_index/indexer/pipeline.py +423 -0
  141. codebase_index-1.6.0/src/codebase_index/mcp/__init__.py +2 -0
  142. codebase_index-1.6.0/src/codebase_index/mcp/server.py +354 -0
  143. codebase_index-1.6.0/src/codebase_index/models.py +145 -0
  144. codebase_index-1.6.0/src/codebase_index/output/__init__.py +6 -0
  145. codebase_index-1.6.0/src/codebase_index/output/json.py +13 -0
  146. codebase_index-1.6.0/src/codebase_index/output/markdown.py +316 -0
  147. codebase_index-1.6.0/src/codebase_index/output/redact.py +31 -0
  148. codebase_index-1.6.0/src/codebase_index/parsers/__init__.py +9 -0
  149. codebase_index-1.6.0/src/codebase_index/parsers/base.py +47 -0
  150. codebase_index-1.6.0/src/codebase_index/parsers/languages.py +290 -0
  151. codebase_index-1.6.0/src/codebase_index/parsers/line_chunker.py +39 -0
  152. codebase_index-1.6.0/src/codebase_index/parsers/symbol_chunks.py +62 -0
  153. codebase_index-1.6.0/src/codebase_index/parsers/treesitter.py +439 -0
  154. codebase_index-1.6.0/src/codebase_index/retrieval/__init__.py +9 -0
  155. codebase_index-1.6.0/src/codebase_index/retrieval/budget.py +82 -0
  156. codebase_index-1.6.0/src/codebase_index/retrieval/fusion.py +62 -0
  157. codebase_index-1.6.0/src/codebase_index/retrieval/intent.py +56 -0
  158. codebase_index-1.6.0/src/codebase_index/retrieval/pipeline.py +207 -0
  159. codebase_index-1.6.0/src/codebase_index/retrieval/rerank.py +69 -0
  160. codebase_index-1.6.0/src/codebase_index/retrieval/searchers.py +291 -0
  161. codebase_index-1.6.0/src/codebase_index/retrieval/skeleton.py +251 -0
  162. codebase_index-1.6.0/src/codebase_index/retrieval/types.py +79 -0
  163. codebase_index-1.6.0/src/codebase_index/scaffold.py +399 -0
  164. codebase_index-1.6.0/src/codebase_index/service.py +158 -0
  165. codebase_index-1.6.0/src/codebase_index/skill_template/SKILL.md +198 -0
  166. codebase_index-1.6.0/src/codebase_index/skill_template/examples/hooks/settings.json +16 -0
  167. codebase_index-1.6.0/src/codebase_index/skill_template/scripts/cbx +25 -0
  168. codebase_index-1.6.0/src/codebase_index/skill_template/scripts/cbx.ps1 +25 -0
  169. codebase_index-1.6.0/src/codebase_index/skill_update.py +150 -0
  170. codebase_index-1.6.0/src/codebase_index/storage/__init__.py +8 -0
  171. codebase_index-1.6.0/src/codebase_index/storage/db.py +116 -0
  172. codebase_index-1.6.0/src/codebase_index/storage/repo.py +701 -0
  173. codebase_index-1.6.0/src/codebase_index/storage/schema.sql +125 -0
  174. codebase_index-1.6.0/src/codebase_index/watch/__init__.py +5 -0
  175. codebase_index-1.6.0/src/codebase_index/watch/watcher.py +93 -0
  176. codebase_index-1.6.0/tests/__init__.py +0 -0
  177. codebase_index-1.6.0/tests/benchmark_honest.py +477 -0
  178. codebase_index-1.6.0/tests/benchmark_honest_RESULTS.md +84 -0
  179. codebase_index-1.6.0/tests/benchmark_honest_newtowny.txt +124 -0
  180. codebase_index-1.6.0/tests/benchmark_public.py +521 -0
  181. codebase_index-1.6.0/tests/benchmark_public_RESULTS.md +92 -0
  182. codebase_index-1.6.0/tests/benchmark_real_repo.py +833 -0
  183. codebase_index-1.6.0/tests/conftest.py +197 -0
  184. codebase_index-1.6.0/tests/fixtures/README.md +22 -0
  185. codebase_index-1.6.0/tests/fixtures/expected_answers.yml +31 -0
  186. codebase_index-1.6.0/tests/fixtures/multilang/sample.go +15 -0
  187. codebase_index-1.6.0/tests/fixtures/multilang/sample.java +18 -0
  188. codebase_index-1.6.0/tests/fixtures/multilang/sample.rs +15 -0
  189. codebase_index-1.6.0/tests/fixtures/sample_repo/.env +2 -0
  190. codebase_index-1.6.0/tests/fixtures/sample_repo/.gitignore +1 -0
  191. codebase_index-1.6.0/tests/fixtures/sample_repo/huge.json +1 -0
  192. codebase_index-1.6.0/tests/fixtures/sample_repo/logo.png +0 -0
  193. codebase_index-1.6.0/tests/fixtures/sample_repo/node_modules/leftpad/index.js +1 -0
  194. codebase_index-1.6.0/tests/fixtures/sample_repo/secrets.pem +3 -0
  195. codebase_index-1.6.0/tests/fixtures/sample_repo/src/api/service.py +11 -0
  196. codebase_index-1.6.0/tests/fixtures/sample_repo/src/auth/token.py +11 -0
  197. codebase_index-1.6.0/tests/fixtures/sample_repo/src/models/user.py +6 -0
  198. codebase_index-1.6.0/tests/fixtures/sample_repo/src/schema.generated.ts +1 -0
  199. codebase_index-1.6.0/tests/fixtures/sample_repo/web/app.ts +3 -0
  200. codebase_index-1.6.0/tests/golden/architecture.json +151 -0
  201. codebase_index-1.6.0/tests/golden/describe_refresh.json +44 -0
  202. codebase_index-1.6.0/tests/golden/explain_auth.json +21 -0
  203. codebase_index-1.6.0/tests/golden/impact_user_model.json +40 -0
  204. codebase_index-1.6.0/tests/golden/mcp_architecture.json +153 -0
  205. codebase_index-1.6.0/tests/golden/mcp_describe_symbol.json +46 -0
  206. codebase_index-1.6.0/tests/golden/mcp_explain_code.json +23 -0
  207. codebase_index-1.6.0/tests/golden/mcp_find_refs.json +37 -0
  208. codebase_index-1.6.0/tests/golden/mcp_find_symbol.json +23 -0
  209. codebase_index-1.6.0/tests/golden/mcp_healthcheck.json +14 -0
  210. codebase_index-1.6.0/tests/golden/mcp_impact_of.json +42 -0
  211. codebase_index-1.6.0/tests/golden/mcp_index_stats.json +23 -0
  212. codebase_index-1.6.0/tests/golden/mcp_path_between.json +51 -0
  213. codebase_index-1.6.0/tests/golden/mcp_search_code.json +53 -0
  214. codebase_index-1.6.0/tests/golden/path_renew_to_token.json +49 -0
  215. codebase_index-1.6.0/tests/golden/refs_refresh_access_token.json +35 -0
  216. codebase_index-1.6.0/tests/golden/search_token.json +51 -0
  217. codebase_index-1.6.0/tests/golden/stats.json +21 -0
  218. codebase_index-1.6.0/tests/golden/symbol_user.json +21 -0
  219. codebase_index-1.6.0/tests/golden_utils.py +77 -0
  220. codebase_index-1.6.0/tests/installer/smoke.ps1 +63 -0
  221. codebase_index-1.6.0/tests/installer/smoke.sh +67 -0
  222. codebase_index-1.6.0/tests/test_analysis.py +229 -0
  223. codebase_index-1.6.0/tests/test_benchmark_comparison.py +338 -0
  224. codebase_index-1.6.0/tests/test_bootstrap.py +207 -0
  225. codebase_index-1.6.0/tests/test_budget.py +66 -0
  226. codebase_index-1.6.0/tests/test_chunker.py +35 -0
  227. codebase_index-1.6.0/tests/test_classify.py +93 -0
  228. codebase_index-1.6.0/tests/test_clean_cli.py +87 -0
  229. codebase_index-1.6.0/tests/test_cli.py +54 -0
  230. codebase_index-1.6.0/tests/test_cli_golden.py +79 -0
  231. codebase_index-1.6.0/tests/test_config.py +92 -0
  232. codebase_index-1.6.0/tests/test_discovery.py +51 -0
  233. codebase_index-1.6.0/tests/test_doc_chunks.py +52 -0
  234. codebase_index-1.6.0/tests/test_doctor.py +78 -0
  235. codebase_index-1.6.0/tests/test_embeddings_backend.py +65 -0
  236. codebase_index-1.6.0/tests/test_embeddings_external.py +24 -0
  237. codebase_index-1.6.0/tests/test_embeddings_local.py +31 -0
  238. codebase_index-1.6.0/tests/test_freshness.py +69 -0
  239. codebase_index-1.6.0/tests/test_fusion.py +66 -0
  240. codebase_index-1.6.0/tests/test_graph.py +188 -0
  241. codebase_index-1.6.0/tests/test_graph_coverage.py +66 -0
  242. codebase_index-1.6.0/tests/test_graph_export_cli.py +80 -0
  243. codebase_index-1.6.0/tests/test_hooks_merge.py +50 -0
  244. codebase_index-1.6.0/tests/test_hybrid_ranking.py +51 -0
  245. codebase_index-1.6.0/tests/test_ignore.py +18 -0
  246. codebase_index-1.6.0/tests/test_impact_cli.py +44 -0
  247. codebase_index-1.6.0/tests/test_index_cli.py +36 -0
  248. codebase_index-1.6.0/tests/test_init_cli.py +100 -0
  249. codebase_index-1.6.0/tests/test_intent.py +60 -0
  250. codebase_index-1.6.0/tests/test_languages.py +47 -0
  251. codebase_index-1.6.0/tests/test_mcp_golden.py +100 -0
  252. codebase_index-1.6.0/tests/test_mcp_server.py +208 -0
  253. codebase_index-1.6.0/tests/test_multilang_symbols.py +104 -0
  254. codebase_index-1.6.0/tests/test_navigate.py +102 -0
  255. codebase_index-1.6.0/tests/test_output.py +168 -0
  256. codebase_index-1.6.0/tests/test_packaging.py +30 -0
  257. codebase_index-1.6.0/tests/test_parse_guardrails.py +99 -0
  258. codebase_index-1.6.0/tests/test_perf_smoke.py +37 -0
  259. codebase_index-1.6.0/tests/test_pipeline.py +179 -0
  260. codebase_index-1.6.0/tests/test_pipeline_search.py +110 -0
  261. codebase_index-1.6.0/tests/test_pipeline_vectors.py +134 -0
  262. codebase_index-1.6.0/tests/test_plugin_manifest.py +66 -0
  263. codebase_index-1.6.0/tests/test_plugin_skill_parity.py +11 -0
  264. codebase_index-1.6.0/tests/test_plugin_wrappers.py +66 -0
  265. codebase_index-1.6.0/tests/test_public_benchmark.py +32 -0
  266. codebase_index-1.6.0/tests/test_quality_benchmark.py +122 -0
  267. codebase_index-1.6.0/tests/test_redact.py +28 -0
  268. codebase_index-1.6.0/tests/test_repo_search.py +23 -0
  269. codebase_index-1.6.0/tests/test_rerank.py +78 -0
  270. codebase_index-1.6.0/tests/test_retrieval_types.py +18 -0
  271. codebase_index-1.6.0/tests/test_scaffold.py +51 -0
  272. codebase_index-1.6.0/tests/test_search_cli.py +234 -0
  273. codebase_index-1.6.0/tests/test_searchers.py +41 -0
  274. codebase_index-1.6.0/tests/test_seeded_index.py +12 -0
  275. codebase_index-1.6.0/tests/test_service.py +39 -0
  276. codebase_index-1.6.0/tests/test_skeleton.py +169 -0
  277. codebase_index-1.6.0/tests/test_skill_update.py +138 -0
  278. codebase_index-1.6.0/tests/test_storage.py +580 -0
  279. codebase_index-1.6.0/tests/test_symbol_cli.py +53 -0
  280. codebase_index-1.6.0/tests/test_symbol_ranking.py +91 -0
  281. codebase_index-1.6.0/tests/test_symbol_refs.py +42 -0
  282. codebase_index-1.6.0/tests/test_sync_skill_copies.py +89 -0
  283. codebase_index-1.6.0/tests/test_treesitter.py +111 -0
  284. codebase_index-1.6.0/tests/test_update.py +124 -0
  285. codebase_index-1.6.0/tests/test_update_cli.py +66 -0
  286. codebase_index-1.6.0/tests/test_vector_search.py +115 -0
  287. codebase_index-1.6.0/tests/test_vectors_storage.py +57 -0
  288. codebase_index-1.6.0/tests/test_watcher.py +102 -0
@@ -0,0 +1,198 @@
1
+ ---
2
+ name: codebase-index
3
+ description: Use this skill before answering questions about a repository's architecture, implementation locations, symbols, references, dependencies, refactoring impact, data flow, bugs, or where something is implemented. It searches a local hybrid codebase index so Claude reads only the most relevant files instead of scanning the entire project.
4
+ allowed-tools: Bash(python -m codebase_index *), Bash(python3 -m codebase_index *), Bash(codebase-index *), Bash(cbx *), Read, Grep, Glob
5
+ ---
6
+
7
+ # Codebase Index
8
+
9
+ Use this skill first for codebase questions.
10
+
11
+ Never scan the entire repository before searching the index.
12
+
13
+ ## When to use
14
+
15
+ Invoke this skill **before reading any files** when the user asks about this project's code:
16
+
17
+ - "where is X implemented" / "find X" / "locate the X function"
18
+ - "how does X work" / "explain the X flow"
19
+ - "what breaks if I change X" / "what depends on X" (impact analysis)
20
+ - "who calls X" / "references to X"
21
+ - "trace the data flow of X"
22
+ - "why is this error happening" (error/stack trace)
23
+ - "explain the architecture" / "give me an overview"
24
+ - Any question about symbols, files, dependencies, or refactoring scope
25
+
26
+ Do **not** use it for: editing files, running the application, or non-code questions.
27
+
28
+ ## How to call the CLI
29
+
30
+ Use the `codebase-index` CLI directly, or the bundled `cbx` wrapper:
31
+
32
+ ```bash
33
+ codebase-index search "$QUERY" --json
34
+ ```
35
+
36
+ Pick the subcommand by intent:
37
+
38
+ | User intent | Command |
39
+ |---|---|
40
+ | "how does X work" / "explain X" / "walk me through" | `codebase-index explain "$QUERY" --json` |
41
+ | overview / architecture / "map the codebase" | `codebase-index architecture --json` |
42
+ | general / unsure | `codebase-index search "$QUERY" --json` |
43
+ | keyword / "where is" | `codebase-index search "$QUERY" --json` |
44
+ | a specific symbol name | `codebase-index symbol "<name>" --json` |
45
+ | "who calls / references" | `codebase-index refs "<name>" --json` |
46
+ | "what breaks if I change" | `codebase-index impact "<file-or-symbol>" --json` |
47
+ | "how is X connected to Y" / dependency path | `codebase-index path "<A>" "<B>" --json` |
48
+ | "what is X" / describe a symbol's role | `codebase-index describe "<name>" --json` |
49
+ | visual graph / "open graph" (for the human, not for you to read) | `codebase-index graph "<file-or-symbol>" --open` |
50
+
51
+ `architecture` returns the codebase map computed at index time — detected modules
52
+ (communities), god nodes (most-connected symbols), surprising cross-module links,
53
+ and suggested questions. Reach for it on "give me an overview" / "where do I
54
+ start" questions instead of a broad `explain`.
55
+
56
+ `path "A" "B"` returns the shortest dependency/call chain between two symbols or
57
+ files; `describe "X"` returns a node card (definition, callers, callees,
58
+ in/out degree, module, god-node rank). Both annotate edges with a `confidence`
59
+ (`extracted` exact, `inferred` heuristic, `ambiguous` unresolved) — treat a path
60
+ or callee list that leans on `inferred`/`ambiguous` edges as less certain.
61
+
62
+ The `graph` command renders an HTML dependency graph for a person to look at —
63
+ it is not a retrieval packet. Use it only when the user explicitly wants a visual
64
+ graph; for "what depends on X" answer from `impact`/`refs` instead. In a headless
65
+ session prefer `--output <path>` over `--open`. `--format graphml|dot|neo4j`
66
+ exports the graph for external tools (Gephi/yEd, Graphviz, Neo4j) instead of HTML.
67
+
68
+ `explain` has a higher default token budget (2200) and HOW_IT_WORKS intent weights — use it whenever the question is about understanding behavior or flow.
69
+
70
+ For `search`, pick a `--mode` when the intent is clear:
71
+ - `--mode symbol` — pure symbol lookups (faster, no FTS noise)
72
+ - `--mode fts` — text/keyword queries where symbol names don't matter
73
+ - `--mode hybrid` — default; best for mixed queries
74
+ - `--mode vector` — semantic / near-synonym queries ("where do we rate-limit
75
+ requests" without the exact words). Requires opt-in embeddings; falls back with
76
+ a clear message when they are not enabled. `hybrid` already blends vectors in
77
+ when embeddings are on, so reach for `vector` only for pure-semantic recall.
78
+
79
+ Natural-language kind words such as `method`, `function`, `class`, `interface`,
80
+ `enum`, and `type` constrain the symbol retriever inside `search`.
81
+
82
+ Use `--json` for programmatic parsing; omit for human-readable output.
83
+ Search/read commands auto-build the index when it is missing; still check
84
+ freshness and run `update`/`index` when responses report stale data.
85
+
86
+ ## Step-by-step workflow
87
+
88
+ 1. **Query the index** using the appropriate subcommand for `$QUERY`.
89
+ 2. **Check index freshness** in the response:
90
+ - `index.exists: false` → run `codebase-index index` first, then re-query.
91
+ - `index.stale: true`, `files_changed_since_build < 20` → run `codebase-index update`, then re-query.
92
+ - `index.stale: true`, `files_changed_since_build ≥ 20` → run `codebase-index index` (full rebuild).
93
+ - Otherwise proceed with results.
94
+ 3. **Read ONLY the `recommended_reads`** — use the Read tool with `offset`/`limit` to read the exact line ranges returned. Do not open whole files.
95
+ 4. **Answer** with file:line citations (e.g., `src/auth/token.py:88-134`).
96
+ 5. **Fallback** only if confidence is low or results are empty (see below).
97
+
98
+ ## Token-budgeted output interpretation
99
+
100
+ The index returns a **ranked retrieval packet** with:
101
+
102
+ - `rank` — result position (start with 1-3)
103
+ - `path` — file path
104
+ - `line_start` / `line_end` — exact line range to read
105
+ - `symbols` — symbols found in this range
106
+ - `score` — relevance score
107
+ - `reason` — why this result ranked (e.g., "exact symbol match, 4 callers")
108
+ - `snippet` — compact code excerpt (may already answer the question); `null` means budget was spent — read via `recommended_reads` instead
109
+ - `skeletonized` — when `true`, the `snippet` is a **focus skeleton**: import/signature/class lines and the line(s) matching your query are kept, while function bodies collapse to a marker like `... 24 lines elided (read 88-134)`. Read that line range (or the result's `line_start`/`line_end`) when you need a full body.
110
+ - `elided_lines` — how many source lines the skeleton folded away (`0` when not skeletonized).
111
+
112
+ Top-level fields:
113
+
114
+ - `recommended_reads` — the precise `{path, line_start, line_end}` list to open next. This is your read plan.
115
+ - `confidence` — `high` (answer directly), `medium` (read + optionally confirm with one Grep), `low` (use fallback).
116
+ - `fallback_suggestions` — ripgrep patterns and paths to try if the index is weak.
117
+ - `intent` / `mode` — how the query was classified and which retrievers ran;
118
+ useful to sanity-check a weak result (e.g. a "how does X work" question that
119
+ resolved to a bare symbol lookup may need `explain` instead).
120
+ - `pagination` — present only when more results exist than fit the page. It
121
+ reports `has_more` and `next_offset`. To page, re-run `search` with
122
+ `--offset <next_offset>` (e.g. `search "query" --limit 10 --offset 10`). Prefer
123
+ refining with a more specific subcommand or raising `--token-budget` first —
124
+ page only when the top results genuinely miss the answer.
125
+ - `coverage` (on `refs`/`impact` only) — graph-completeness signal. Dependency
126
+ edges (imports/inheritance) are extracted only for fully supported languages.
127
+ When `coverage.partial` is `true` (the symbol/file is in a Tier-B language such
128
+ as Lua), an **empty or short `refs`/`impact` result is inconclusive** — it may
129
+ just be unanalyzed, not absent. Confirm with a Grep before concluding "nothing
130
+ references this". `coverage.languages` lists the affected languages.
131
+
132
+ ## Token efficiency rules
133
+
134
+ - Trust the index. Read the **fewest** files needed — start with rank 1-3 only.
135
+ - Read **line ranges**, not whole files. Use `line_start`/`line_end` with Read's `offset`/`limit`.
136
+ - The `snippet` may already answer the question — re-read only if you need more context.
137
+ - Prefer `search`/`symbol`/`refs`/`impact`/`explain` over manual Grep/Glob — those are expensive fallbacks, not step 1.
138
+ - Don't re-run the query with trivially reworded text; refine with a different subcommand instead.
139
+ - For broad questions (`confidence: low`, architecture, data-flow), raise the budget: `--token-budget 3000`.
140
+ - Test files are demoted in ranking by default. Include "test" in the query to surface them.
141
+ - Snippets are skeletonized by default to fit more results in the budget. The matched line is always preserved; pass `--raw` (CLI) or `raw: true` (MCP) on the rare occasion you need full bodies inline instead of reading the cited line range.
142
+
143
+ ## Fallback behavior
144
+
145
+ Fall back to built-in search **only** when: results are empty, `confidence` is `low`, or the user asks for something the index clearly doesn't cover.
146
+
147
+ 0. If confidence is consistently low across queries, run diagnostics first:
148
+ ```bash
149
+ codebase-index stats --json # per-language file/symbol counts + graph tier
150
+ codebase-index doctor # surface config or security issues
151
+ ```
152
+ Low symbol counts for a language may mean the index needs a full rebuild: `codebase-index index`.
153
+ In `stats`, each language carries `graph: full|partial` (and `doctor` reports a
154
+ `graph_coverage` finding): `partial` (Tier-B) means `refs`/`impact` lack
155
+ import/inheritance edges for that language — treat empty results there as
156
+ inconclusive.
157
+
158
+ 1. Use `fallback_suggestions.ripgrep` patterns from the response via Grep.
159
+ 2. If still nothing, Glob for likely paths, then Grep within them.
160
+ 3. As a last resort, broaden the search — but tell the user the index was weak here (it may need a rebuild: `codebase-index index`).
161
+
162
+ Never start with a full-repo scan when the index exists and is fresh.
163
+
164
+ ## Examples
165
+
166
+ ```bash
167
+ # "how does the auth flow work?"
168
+ codebase-index explain "auth flow" --json
169
+
170
+ # "explain the overall architecture" / "where do I start" — modules, god nodes
171
+ codebase-index architecture --json
172
+
173
+ # "where is auth token refresh implemented?"
174
+ codebase-index search "auth token refresh" --json
175
+
176
+ # "what breaks if I change the User model?"
177
+ codebase-index impact "User" --json
178
+
179
+ # "who calls send_email?"
180
+ codebase-index refs "send_email" --json
181
+
182
+ # "find the AuthService class"
183
+ codebase-index symbol "AuthService" --json
184
+
185
+ # precise symbol search (faster, no FTS noise)
186
+ codebase-index search "AuthService" --mode symbol --json
187
+
188
+ # "how is the API layer connected to the database?"
189
+ codebase-index path "ApiController" "Database" --json
190
+
191
+ # "what is the Database class and how is it used?"
192
+ codebase-index describe "Database" --json
193
+
194
+ # generate and open an HTML graph around a file or symbol
195
+ codebase-index graph "User" --direction both --depth 2 --open
196
+ ```
197
+
198
+ Then Read only the returned line ranges and answer with citations.
@@ -0,0 +1,16 @@
1
+ {
2
+ "hooks": {
3
+ "PostToolUse": [
4
+ {
5
+ "matcher": "Edit|Write|MultiEdit",
6
+ "hooks": [
7
+ {
8
+ "type": "command",
9
+ "command": "codebase-index update --quiet >/dev/null 2>&1 &",
10
+ "timeout": 5
11
+ }
12
+ ]
13
+ }
14
+ ]
15
+ }
16
+ }
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env bash
2
+ # Thin, safe wrapper around the installed `codebase-index` CLI.
3
+ # - Resolves the binary (prefers one on PATH; falls back to `python -m codebase_index`).
4
+ # - Whitelists subcommands so the skill can never invoke destructive ones (clean/init/watch).
5
+ set -euo pipefail
6
+
7
+ ALLOWED="search explain symbol refs impact graph stats doctor update index"
8
+
9
+ sub="${1:-}"
10
+ case " $ALLOWED " in
11
+ *" ${sub} "*) : ;;
12
+ *)
13
+ echo "cbx: refusing subcommand '${sub}'. Allowed: ${ALLOWED}" >&2
14
+ exit 2
15
+ ;;
16
+ esac
17
+
18
+ if python -c "import codebase_index" >/dev/null 2>&1; then
19
+ exec python -m codebase_index "$@"
20
+ elif command -v codebase-index >/dev/null 2>&1; then
21
+ exec codebase-index "$@"
22
+ else
23
+ echo "cbx: codebase_index is not importable and codebase-index is not on PATH" >&2
24
+ exit 127
25
+ fi
@@ -0,0 +1,25 @@
1
+ # Windows PowerShell wrapper around the installed `codebase-index` CLI.
2
+ # Mirrors scripts/cbx: whitelists safe subcommands, falls back to `python -m codebase_index`.
3
+ param(
4
+ [Parameter(Mandatory = $true, Position = 0)]
5
+ [string]$Subcommand,
6
+ [Parameter(ValueFromRemainingArguments = $true)]
7
+ [string[]]$Rest
8
+ )
9
+
10
+ $ErrorActionPreference = "Stop"
11
+ $allowed = @("search", "explain", "symbol", "refs", "impact", "graph", "stats", "doctor", "update", "index")
12
+
13
+ if ($allowed -notcontains $Subcommand) {
14
+ Write-Error "cbx: refusing subcommand '$Subcommand'. Allowed: $($allowed -join ', ')"
15
+ exit 2
16
+ }
17
+
18
+ & python -c "import codebase_index" 2>$null
19
+ if ($LASTEXITCODE -eq 0) {
20
+ & python -m codebase_index $Subcommand @Rest
21
+ exit $LASTEXITCODE
22
+ }
23
+ $bin = Get-Command codebase-index -ErrorAction SilentlyContinue
24
+ if ($bin) { & $bin.Source $Subcommand @Rest }
25
+ exit $LASTEXITCODE
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "codebase-index",
3
+ "owner": { "name": "codebase-index contributors" },
4
+ "plugins": [
5
+ {
6
+ "name": "codebase-index",
7
+ "source": "./",
8
+ "description": "Local-first hybrid codebase index skill with auto-provisioned CLI."
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/claude-code-plugin-manifest.json",
3
+ "name": "codebase-index",
4
+ "displayName": "Codebase Index",
5
+ "description": "Local-first hybrid codebase index. Auto-provisions its Python CLI on first session start; the skill searches the index so Claude reads only the most relevant files.",
6
+ "version": "1.6.0",
7
+ "author": {
8
+ "name": "codebase-index contributors"
9
+ },
10
+ "repository": "https://github.com/denfry/codebase-index",
11
+ "license": "MIT",
12
+ "keywords": [
13
+ "claude-code",
14
+ "code-search",
15
+ "semantic-code-search",
16
+ "codebase-index",
17
+ "mcp",
18
+ "ai-agents",
19
+ "local-first",
20
+ "tree-sitter",
21
+ "rag",
22
+ "sqlite",
23
+ "fts5"
24
+ ]
25
+ }
@@ -0,0 +1,198 @@
1
+ ---
2
+ name: codebase-index
3
+ description: Use this skill before answering questions about a repository's architecture, implementation locations, symbols, references, dependencies, refactoring impact, data flow, bugs, or where something is implemented. It searches a local hybrid codebase index so Claude reads only the most relevant files instead of scanning the entire project.
4
+ allowed-tools: Bash(python -m codebase_index *), Bash(python3 -m codebase_index *), Bash(codebase-index *), Bash(cbx *), Read, Grep, Glob
5
+ ---
6
+
7
+ # Codebase Index
8
+
9
+ Use this skill first for codebase questions.
10
+
11
+ Never scan the entire repository before searching the index.
12
+
13
+ ## When to use
14
+
15
+ Invoke this skill **before reading any files** when the user asks about this project's code:
16
+
17
+ - "where is X implemented" / "find X" / "locate the X function"
18
+ - "how does X work" / "explain the X flow"
19
+ - "what breaks if I change X" / "what depends on X" (impact analysis)
20
+ - "who calls X" / "references to X"
21
+ - "trace the data flow of X"
22
+ - "why is this error happening" (error/stack trace)
23
+ - "explain the architecture" / "give me an overview"
24
+ - Any question about symbols, files, dependencies, or refactoring scope
25
+
26
+ Do **not** use it for: editing files, running the application, or non-code questions.
27
+
28
+ ## How to call the CLI
29
+
30
+ Use the `codebase-index` CLI directly, or the bundled `cbx` wrapper:
31
+
32
+ ```bash
33
+ codebase-index search "$QUERY" --json
34
+ ```
35
+
36
+ Pick the subcommand by intent:
37
+
38
+ | User intent | Command |
39
+ |---|---|
40
+ | "how does X work" / "explain X" / "walk me through" | `codebase-index explain "$QUERY" --json` |
41
+ | overview / architecture / "map the codebase" | `codebase-index architecture --json` |
42
+ | general / unsure | `codebase-index search "$QUERY" --json` |
43
+ | keyword / "where is" | `codebase-index search "$QUERY" --json` |
44
+ | a specific symbol name | `codebase-index symbol "<name>" --json` |
45
+ | "who calls / references" | `codebase-index refs "<name>" --json` |
46
+ | "what breaks if I change" | `codebase-index impact "<file-or-symbol>" --json` |
47
+ | "how is X connected to Y" / dependency path | `codebase-index path "<A>" "<B>" --json` |
48
+ | "what is X" / describe a symbol's role | `codebase-index describe "<name>" --json` |
49
+ | visual graph / "open graph" (for the human, not for you to read) | `codebase-index graph "<file-or-symbol>" --open` |
50
+
51
+ `architecture` returns the codebase map computed at index time — detected modules
52
+ (communities), god nodes (most-connected symbols), surprising cross-module links,
53
+ and suggested questions. Reach for it on "give me an overview" / "where do I
54
+ start" questions instead of a broad `explain`.
55
+
56
+ `path "A" "B"` returns the shortest dependency/call chain between two symbols or
57
+ files; `describe "X"` returns a node card (definition, callers, callees,
58
+ in/out degree, module, god-node rank). Both annotate edges with a `confidence`
59
+ (`extracted` exact, `inferred` heuristic, `ambiguous` unresolved) — treat a path
60
+ or callee list that leans on `inferred`/`ambiguous` edges as less certain.
61
+
62
+ The `graph` command renders an HTML dependency graph for a person to look at —
63
+ it is not a retrieval packet. Use it only when the user explicitly wants a visual
64
+ graph; for "what depends on X" answer from `impact`/`refs` instead. In a headless
65
+ session prefer `--output <path>` over `--open`. `--format graphml|dot|neo4j`
66
+ exports the graph for external tools (Gephi/yEd, Graphviz, Neo4j) instead of HTML.
67
+
68
+ `explain` has a higher default token budget (2200) and HOW_IT_WORKS intent weights — use it whenever the question is about understanding behavior or flow.
69
+
70
+ For `search`, pick a `--mode` when the intent is clear:
71
+ - `--mode symbol` — pure symbol lookups (faster, no FTS noise)
72
+ - `--mode fts` — text/keyword queries where symbol names don't matter
73
+ - `--mode hybrid` — default; best for mixed queries
74
+ - `--mode vector` — semantic / near-synonym queries ("where do we rate-limit
75
+ requests" without the exact words). Requires opt-in embeddings; falls back with
76
+ a clear message when they are not enabled. `hybrid` already blends vectors in
77
+ when embeddings are on, so reach for `vector` only for pure-semantic recall.
78
+
79
+ Natural-language kind words such as `method`, `function`, `class`, `interface`,
80
+ `enum`, and `type` constrain the symbol retriever inside `search`.
81
+
82
+ Use `--json` for programmatic parsing; omit for human-readable output.
83
+ Search/read commands auto-build the index when it is missing; still check
84
+ freshness and run `update`/`index` when responses report stale data.
85
+
86
+ ## Step-by-step workflow
87
+
88
+ 1. **Query the index** using the appropriate subcommand for `$QUERY`.
89
+ 2. **Check index freshness** in the response:
90
+ - `index.exists: false` → run `codebase-index index` first, then re-query.
91
+ - `index.stale: true`, `files_changed_since_build < 20` → run `codebase-index update`, then re-query.
92
+ - `index.stale: true`, `files_changed_since_build ≥ 20` → run `codebase-index index` (full rebuild).
93
+ - Otherwise proceed with results.
94
+ 3. **Read ONLY the `recommended_reads`** — use the Read tool with `offset`/`limit` to read the exact line ranges returned. Do not open whole files.
95
+ 4. **Answer** with file:line citations (e.g., `src/auth/token.py:88-134`).
96
+ 5. **Fallback** only if confidence is low or results are empty (see below).
97
+
98
+ ## Token-budgeted output interpretation
99
+
100
+ The index returns a **ranked retrieval packet** with:
101
+
102
+ - `rank` — result position (start with 1-3)
103
+ - `path` — file path
104
+ - `line_start` / `line_end` — exact line range to read
105
+ - `symbols` — symbols found in this range
106
+ - `score` — relevance score
107
+ - `reason` — why this result ranked (e.g., "exact symbol match, 4 callers")
108
+ - `snippet` — compact code excerpt (may already answer the question); `null` means budget was spent — read via `recommended_reads` instead
109
+ - `skeletonized` — when `true`, the `snippet` is a **focus skeleton**: import/signature/class lines and the line(s) matching your query are kept, while function bodies collapse to a marker like `... 24 lines elided (read 88-134)`. Read that line range (or the result's `line_start`/`line_end`) when you need a full body.
110
+ - `elided_lines` — how many source lines the skeleton folded away (`0` when not skeletonized).
111
+
112
+ Top-level fields:
113
+
114
+ - `recommended_reads` — the precise `{path, line_start, line_end}` list to open next. This is your read plan.
115
+ - `confidence` — `high` (answer directly), `medium` (read + optionally confirm with one Grep), `low` (use fallback).
116
+ - `fallback_suggestions` — ripgrep patterns and paths to try if the index is weak.
117
+ - `intent` / `mode` — how the query was classified and which retrievers ran;
118
+ useful to sanity-check a weak result (e.g. a "how does X work" question that
119
+ resolved to a bare symbol lookup may need `explain` instead).
120
+ - `pagination` — present only when more results exist than fit the page. It
121
+ reports `has_more` and `next_offset`. To page, re-run `search` with
122
+ `--offset <next_offset>` (e.g. `search "query" --limit 10 --offset 10`). Prefer
123
+ refining with a more specific subcommand or raising `--token-budget` first —
124
+ page only when the top results genuinely miss the answer.
125
+ - `coverage` (on `refs`/`impact` only) — graph-completeness signal. Dependency
126
+ edges (imports/inheritance) are extracted only for fully supported languages.
127
+ When `coverage.partial` is `true` (the symbol/file is in a Tier-B language such
128
+ as Lua), an **empty or short `refs`/`impact` result is inconclusive** — it may
129
+ just be unanalyzed, not absent. Confirm with a Grep before concluding "nothing
130
+ references this". `coverage.languages` lists the affected languages.
131
+
132
+ ## Token efficiency rules
133
+
134
+ - Trust the index. Read the **fewest** files needed — start with rank 1-3 only.
135
+ - Read **line ranges**, not whole files. Use `line_start`/`line_end` with Read's `offset`/`limit`.
136
+ - The `snippet` may already answer the question — re-read only if you need more context.
137
+ - Prefer `search`/`symbol`/`refs`/`impact`/`explain` over manual Grep/Glob — those are expensive fallbacks, not step 1.
138
+ - Don't re-run the query with trivially reworded text; refine with a different subcommand instead.
139
+ - For broad questions (`confidence: low`, architecture, data-flow), raise the budget: `--token-budget 3000`.
140
+ - Test files are demoted in ranking by default. Include "test" in the query to surface them.
141
+ - Snippets are skeletonized by default to fit more results in the budget. The matched line is always preserved; pass `--raw` (CLI) or `raw: true` (MCP) on the rare occasion you need full bodies inline instead of reading the cited line range.
142
+
143
+ ## Fallback behavior
144
+
145
+ Fall back to built-in search **only** when: results are empty, `confidence` is `low`, or the user asks for something the index clearly doesn't cover.
146
+
147
+ 0. If confidence is consistently low across queries, run diagnostics first:
148
+ ```bash
149
+ codebase-index stats --json # per-language file/symbol counts + graph tier
150
+ codebase-index doctor # surface config or security issues
151
+ ```
152
+ Low symbol counts for a language may mean the index needs a full rebuild: `codebase-index index`.
153
+ In `stats`, each language carries `graph: full|partial` (and `doctor` reports a
154
+ `graph_coverage` finding): `partial` (Tier-B) means `refs`/`impact` lack
155
+ import/inheritance edges for that language — treat empty results there as
156
+ inconclusive.
157
+
158
+ 1. Use `fallback_suggestions.ripgrep` patterns from the response via Grep.
159
+ 2. If still nothing, Glob for likely paths, then Grep within them.
160
+ 3. As a last resort, broaden the search — but tell the user the index was weak here (it may need a rebuild: `codebase-index index`).
161
+
162
+ Never start with a full-repo scan when the index exists and is fresh.
163
+
164
+ ## Examples
165
+
166
+ ```bash
167
+ # "how does the auth flow work?"
168
+ codebase-index explain "auth flow" --json
169
+
170
+ # "explain the overall architecture" / "where do I start" — modules, god nodes
171
+ codebase-index architecture --json
172
+
173
+ # "where is auth token refresh implemented?"
174
+ codebase-index search "auth token refresh" --json
175
+
176
+ # "what breaks if I change the User model?"
177
+ codebase-index impact "User" --json
178
+
179
+ # "who calls send_email?"
180
+ codebase-index refs "send_email" --json
181
+
182
+ # "find the AuthService class"
183
+ codebase-index symbol "AuthService" --json
184
+
185
+ # precise symbol search (faster, no FTS noise)
186
+ codebase-index search "AuthService" --mode symbol --json
187
+
188
+ # "how is the API layer connected to the database?"
189
+ codebase-index path "ApiController" "Database" --json
190
+
191
+ # "what is the Database class and how is it used?"
192
+ codebase-index describe "Database" --json
193
+
194
+ # generate and open an HTML graph around a file or symbol
195
+ codebase-index graph "User" --direction both --depth 2 --open
196
+ ```
197
+
198
+ Then Read only the returned line ranges and answer with citations.
@@ -0,0 +1,16 @@
1
+ {
2
+ "hooks": {
3
+ "PostToolUse": [
4
+ {
5
+ "matcher": "Edit|Write|MultiEdit",
6
+ "hooks": [
7
+ {
8
+ "type": "command",
9
+ "command": "codebase-index update --quiet >/dev/null 2>&1 &",
10
+ "timeout": 5
11
+ }
12
+ ]
13
+ }
14
+ ]
15
+ }
16
+ }
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env bash
2
+ # Thin, safe wrapper around the installed `codebase-index` CLI.
3
+ # - Resolves the binary (prefers one on PATH; falls back to `python -m codebase_index`).
4
+ # - Whitelists subcommands so the skill can never invoke destructive ones (clean/init/watch).
5
+ set -euo pipefail
6
+
7
+ ALLOWED="search explain symbol refs impact graph stats doctor update index"
8
+
9
+ sub="${1:-}"
10
+ case " $ALLOWED " in
11
+ *" ${sub} "*) : ;;
12
+ *)
13
+ echo "cbx: refusing subcommand '${sub}'. Allowed: ${ALLOWED}" >&2
14
+ exit 2
15
+ ;;
16
+ esac
17
+
18
+ if python -c "import codebase_index" >/dev/null 2>&1; then
19
+ exec python -m codebase_index "$@"
20
+ elif command -v codebase-index >/dev/null 2>&1; then
21
+ exec codebase-index "$@"
22
+ else
23
+ echo "cbx: codebase_index is not importable and codebase-index is not on PATH" >&2
24
+ exit 127
25
+ fi
@@ -0,0 +1,25 @@
1
+ # Windows PowerShell wrapper around the installed `codebase-index` CLI.
2
+ # Mirrors scripts/cbx: whitelists safe subcommands, falls back to `python -m codebase_index`.
3
+ param(
4
+ [Parameter(Mandatory = $true, Position = 0)]
5
+ [string]$Subcommand,
6
+ [Parameter(ValueFromRemainingArguments = $true)]
7
+ [string[]]$Rest
8
+ )
9
+
10
+ $ErrorActionPreference = "Stop"
11
+ $allowed = @("search", "explain", "symbol", "refs", "impact", "graph", "stats", "doctor", "update", "index")
12
+
13
+ if ($allowed -notcontains $Subcommand) {
14
+ Write-Error "cbx: refusing subcommand '$Subcommand'. Allowed: $($allowed -join ', ')"
15
+ exit 2
16
+ }
17
+
18
+ & python -c "import codebase_index" 2>$null
19
+ if ($LASTEXITCODE -eq 0) {
20
+ & python -m codebase_index $Subcommand @Rest
21
+ exit $LASTEXITCODE
22
+ }
23
+ $bin = Get-Command codebase-index -ErrorAction SilentlyContinue
24
+ if ($bin) { & $bin.Source $Subcommand @Rest }
25
+ exit $LASTEXITCODE
@@ -0,0 +1,28 @@
1
+ root = true
2
+
3
+ [*]
4
+ indent_style = space
5
+ indent_size = 4
6
+ end_of_line = lf
7
+ charset = utf-8
8
+ trim_trailing_whitespace = true
9
+ insert_final_newline = true
10
+
11
+ [*.md]
12
+ indent_size = 2
13
+ trim_trailing_whitespace = false
14
+
15
+ [*.{yml,yaml}]
16
+ indent_size = 2
17
+
18
+ [*.{json,jsonc}]
19
+ indent_size = 2
20
+
21
+ [*.py]
22
+ indent_size = 4
23
+
24
+ [*.{sh,ps1}]
25
+ indent_size = 2
26
+
27
+ [Makefile]
28
+ indent_style = tab
@@ -0,0 +1,7 @@
1
+ # Скрипты-инсталляторы должны иметь LF, иначе ломаются на macOS/Linux
2
+ # (shebang "#!/usr/bin/env sh\r" недопустим). PowerShell-файлы — тоже LF для единообразия.
3
+ *.sh text eol=lf
4
+ *.ps1 text eol=lf
5
+ *.py text eol=lf
6
+ # cbx — POSIX-скрипт без расширения; CRLF в worktree ломает shebang при копировании
7
+ cbx text eol=lf
@@ -0,0 +1,8 @@
1
+ github:
2
+ patreon: # placeholder
3
+ ko_fi: # placeholder
4
+ tidelift: # placeholder
5
+ community_bridge: # placeholder
6
+ liberapay: # placeholder
7
+ issuehunt: # placeholder
8
+ custom: # placeholder