local-codebase-indexer 0.5.0__tar.gz → 0.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 (77) hide show
  1. local_codebase_indexer-0.6.0/.claude-plugin/marketplace.json +14 -0
  2. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/AGENTS.md +20 -3
  3. local_codebase_indexer-0.6.0/CHANGELOG.md +29 -0
  4. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/CLAUDE.md +9 -0
  5. local_codebase_indexer-0.6.0/MANIFEST.in +9 -0
  6. {local_codebase_indexer-0.5.0/local_codebase_indexer.egg-info → local_codebase_indexer-0.6.0}/PKG-INFO +34 -4
  7. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/README.md +32 -2
  8. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/README.zh-CN.md +24 -2
  9. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/README.zh-TW.md +28 -2
  10. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/TODO.md +2 -1
  11. local_codebase_indexer-0.6.0/bin/indexer +11 -0
  12. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/local_codebase_indexer/__init__.py +1 -1
  13. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/local_codebase_indexer/cli.py +46 -10
  14. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/local_codebase_indexer/core.py +2 -0
  15. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/local_codebase_indexer/dataflow.py +8 -8
  16. local_codebase_indexer-0.6.0/local_codebase_indexer/impact.py +178 -0
  17. local_codebase_indexer-0.6.0/local_codebase_indexer/mcp_server.py +196 -0
  18. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/local_codebase_indexer/query.py +159 -94
  19. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/local_codebase_indexer/scanner.py +88 -10
  20. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/local_codebase_indexer/synonyms.py +18 -4
  21. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0/local_codebase_indexer.egg-info}/PKG-INFO +34 -4
  22. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/local_codebase_indexer.egg-info/SOURCES.txt +8 -1
  23. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/local_codebase_indexer.egg-info/requires.txt +1 -1
  24. local_codebase_indexer-0.6.0/plugins/local-codebase-indexer/.claude-plugin/plugin.json +8 -0
  25. local_codebase_indexer-0.6.0/plugins/local-codebase-indexer/.mcp.json +8 -0
  26. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/pyproject.toml +1 -1
  27. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/requirements.txt +1 -1
  28. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/server.json +2 -2
  29. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/tests/test_indexer.py +1 -1
  30. local_codebase_indexer-0.6.0/tests/test_reliability.py +265 -0
  31. local_codebase_indexer-0.5.0/MANIFEST.in +0 -5
  32. local_codebase_indexer-0.5.0/local_codebase_indexer/mcp_server.py +0 -152
  33. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/benchmarks/README.md +0 -0
  34. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/benchmarks/baseline.json +0 -0
  35. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/benchmarks/corpus/Auth/LoginService.cs +0 -0
  36. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/benchmarks/corpus/Controllers/LotController.cs +0 -0
  37. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/benchmarks/corpus/Controllers/ScrapController.cs +0 -0
  38. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/benchmarks/corpus/Data/MesDbContext.cs +0 -0
  39. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/benchmarks/corpus/Legacy/frmChangeLine.frm +0 -0
  40. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/benchmarks/corpus/Models/DrillBreakEvent.cs +0 -0
  41. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/benchmarks/corpus/Models/Lot.cs +0 -0
  42. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/benchmarks/corpus/Models/ScrapRecord.cs +0 -0
  43. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/benchmarks/corpus/Printing/LabelPrinter.cs +0 -0
  44. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/benchmarks/corpus/Repositories/LotRepository.cs +0 -0
  45. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/benchmarks/corpus/Repositories/ScrapRepository.cs +0 -0
  46. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/benchmarks/corpus/Services/IScrapService.cs +0 -0
  47. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/benchmarks/corpus/Services/InspectionService.cs +0 -0
  48. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/benchmarks/corpus/Services/LotService.cs +0 -0
  49. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/benchmarks/corpus/Services/ScrapService.cs +0 -0
  50. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/benchmarks/corpus/Sql/MES_Lot.sql +0 -0
  51. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/benchmarks/corpus/Sql/usp_Inspection_Report.sql +0 -0
  52. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/benchmarks/corpus/Sql/usp_Lot_UpdateStatus.sql +0 -0
  53. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/benchmarks/corpus/Sql/usp_Scrap_Insert.sql +0 -0
  54. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/benchmarks/corpus/Utils/DateRangeHelper.cs +0 -0
  55. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/benchmarks/corpus/Utils/PartNumberDecoder.cs +0 -0
  56. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/benchmarks/corpus/Web/scrapForm.ts +0 -0
  57. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/benchmarks/corpus/Web.config +0 -0
  58. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/benchmarks/corpus/tools/export_report.py +0 -0
  59. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/benchmarks/queries_stdlib.json +0 -0
  60. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/benchmarks/queries_synthetic.json +0 -0
  61. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/benchmarks/run_benchmark.py +0 -0
  62. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/index.md +0 -0
  63. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/llms.txt +0 -0
  64. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/local_codebase_indexer/__main__.py +0 -0
  65. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/local_codebase_indexer/callgraph.py +0 -0
  66. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/local_codebase_indexer/cscalls.py +0 -0
  67. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/local_codebase_indexer/csdata.py +0 -0
  68. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/local_codebase_indexer/db.py +0 -0
  69. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/local_codebase_indexer/embedder.py +0 -0
  70. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/local_codebase_indexer/langparse.py +0 -0
  71. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/local_codebase_indexer/sqlaccess.py +0 -0
  72. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/local_codebase_indexer.egg-info/dependency_links.txt +0 -0
  73. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/local_codebase_indexer.egg-info/entry_points.txt +0 -0
  74. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/local_codebase_indexer.egg-info/top_level.txt +0 -0
  75. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/setup.cfg +0 -0
  76. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/tests/test_dataaccess.py +0 -0
  77. {local_codebase_indexer-0.5.0 → local_codebase_indexer-0.6.0}/tests/test_onnx_plumbing.py +0 -0
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "local-codebase-indexer",
3
+ "description": "Local code index for AI coding assistants: search, call relations and SQL table/procedure access",
4
+ "owner": {
5
+ "name": "sfy257000"
6
+ },
7
+ "plugins": [
8
+ {
9
+ "name": "local-codebase-indexer",
10
+ "source": "./plugins/local-codebase-indexer",
11
+ "description": "MCP server that indexes your project locally (SQLite, no cloud) for code search, callers and SQL data access"
12
+ }
13
+ ]
14
+ }
@@ -24,7 +24,16 @@ local-codebase-indexer --root <project> context <file> --lines 120 --padding 15
24
24
  local-codebase-indexer --root <project> status # is the index fresh?
25
25
  ```
26
26
 
27
- Put `--json` before the subcommand for JSON output. The index lives in `<project>/.ai_context/` (git-ignored automatically).
27
+ Put `--json` before or after the subcommand for JSON output. The index lives in `<project>/.ai_context/` (git-ignored automatically).
28
+
29
+ ## Install as a Claude Code plugin
30
+
31
+ ```text
32
+ /plugin marketplace add sfy257000/local-codebase-indexer
33
+ /plugin install local-codebase-indexer@local-codebase-indexer
34
+ ```
35
+
36
+ Needs `uv` (`pip install uv`). Then restart Claude Code.
28
37
 
29
38
  ## Register as an MCP server (Claude Code)
30
39
 
@@ -32,7 +41,7 @@ Put `--json` before the subcommand for JSON output. The index lives in `<project
32
41
  claude mcp add local-indexer -- local-codebase-indexer --root <project> serve
33
42
  ```
34
43
 
35
- Tools: `codebase_semantic_search`, `codebase_get_symbol_relations`, `codebase_get_optimized_context`, `codebase_get_data_access`, `codebase_impact_analysis`, `codebase_index_status`.
44
+ Tools: `codebase_semantic_search`, `codebase_get_symbol_relations`, `codebase_get_optimized_context`, `codebase_get_data_access`, `codebase_impact_analysis`, `codebase_index_status`, `codebase_index_doctor`.
36
45
 
37
46
  ## Reading the results
38
47
 
@@ -42,8 +51,16 @@ Tools: `codebase_semantic_search`, `codebase_get_symbol_relations`, `codebase_ge
42
51
  ## Working on this repo itself
43
52
 
44
53
  ```bash
45
- pip install -e ".[dev,onnx]" && python -m pytest -q
54
+ pip install -e ".[dev,onnx]" onnx && python -m pytest -q
46
55
  python benchmarks/run_benchmark.py --compare benchmarks/baseline.json
47
56
  ```
48
57
 
49
58
  The package is `local_codebase_indexer/`. See `README.md` for design notes and known limits, `TODO.md` for planned work.
59
+
60
+ ## Diagnostics and bounded results (0.6.0)
61
+
62
+ - `local-codebase-indexer --root <project> doctor --path <file>` explains exclusions.
63
+ - `search <query> --file '*Repository*.cs' --language csharp --limit 5 --offset 5` filters before ranking. Follow `pagination.next_offset` in JSON.
64
+ - `data-access <table> --confidence confirmed --limit 20 --offset 20` pages each section independently. JSON has section totals and next offsets; `--full` really lists every entry.
65
+ - `impact` includes historical accesses and callers for removed code. `snapshot=before` line numbers refer to the base revision. Historical indexes are cached in `.ai_context/impact/`; deleting that cache is safe.
66
+ - A missing root is an error; an empty or failed indexing run returns exit status 3. `--json` and `--root` work before or after the subcommand.
@@ -0,0 +1,29 @@
1
+ # Changelog
2
+
3
+ ## 0.6.0
4
+
5
+ ### Fixed
6
+
7
+ - Impact analysis reports all methods in a changed hunk and retains removed methods/files, historical SQL accesses and callers. Current and historical line numbers are labeled separately.
8
+ - Malformed JSON-RPC messages and invalid tool arguments return errors without terminating the MCP session.
9
+ - Nested `.gitignore` negations correctly override parent file patterns.
10
+ - Missing project roots fail before creating directories; empty or partially failed indexing returns exit status 3 with diagnostics.
11
+ - Search strictly honors its result limit, including queries routed to SQL data access.
12
+ - Generated packaging metadata is no longer tracked; source distributions exclude generated benchmark indexes.
13
+ - CI explicitly installs and imports `onnx`, `onnxruntime` and `tokenizers`, so ONNX plumbing tests cannot silently skip for missing dependencies.
14
+
15
+ ### Added
16
+
17
+ - `doctor --path <file>` and the `codebase_index_doctor` MCP tool explain indexing exclusions and report index health.
18
+ - Search file/language filters, offset pagination, similar-name suggestions and actionable no-result hints.
19
+ - Data-access confidence filtering, per-section pagination, totals and next offsets. `--full` / `detail=true` no longer silently truncates at 40 displayed or 200 queried entries.
20
+ - General English/Chinese paraphrases for common operations and password terminology. Keyword expansion is separated from vector expansion to preserve existing rankings.
21
+ - Cached historical impact indexes under `.ai_context/impact/`, reusable per base revision and package/index version.
22
+ - `--json` and `--root` also work after the subcommand.
23
+
24
+ ### Validation and limits
25
+
26
+ - Full tests include ONNX plumbing and regression coverage for deleted code, multi-method hunks, Chinese paths, cached historical indexes, invalid MCP messages, ignore negations, filters and pagination beyond 200 entries.
27
+ - Python 3.12 comparison against 0.5.0, with unchanged benchmark queries and baseline: synthetic Recall@5 0.893 → 0.917; noisy synthetic 0.857 → 0.881; synonym Recall@5 0.30 → 0.50 in both synthetic suites. Standard-library retrieval metrics are unchanged. These small author-written suites do not establish general semantic understanding.
28
+ - First-time historical impact analysis indexes the Git archive and may take time on large projects. External `extra_roots` cannot be reconstructed historically. Existing call-graph and dynamic-SQL limitations remain.
29
+ - Pagination assumes the index remains unchanged between requests.
@@ -26,6 +26,15 @@ local-codebase-indexer --root <project> status # is the inde
26
26
 
27
27
  Put `--json` before the subcommand for JSON output. The index lives in `<project>/.ai_context/` (git-ignored automatically).
28
28
 
29
+ ## Install as a Claude Code plugin
30
+
31
+ ```text
32
+ /plugin marketplace add sfy257000/local-codebase-indexer
33
+ /plugin install local-codebase-indexer@local-codebase-indexer
34
+ ```
35
+
36
+ Needs `uv` (`pip install uv`). Then restart Claude Code.
37
+
29
38
  ## Register as an MCP server (Claude Code)
30
39
 
31
40
  ```bash
@@ -0,0 +1,9 @@
1
+ include server.json CHANGELOG.md README*.md TODO.md AGENTS.md CLAUDE.md llms.txt index.md requirements.txt
2
+ graft tests
3
+ graft plugins
4
+ graft .claude-plugin
5
+ graft benchmarks
6
+ prune benchmarks/__pycache__
7
+ global-exclude __pycache__ *.pyc
8
+ prune benchmarks/corpus/.ai_context
9
+ include bin/indexer
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: local-codebase-indexer
3
- Version: 0.5.0
3
+ Version: 0.6.0
4
4
  Summary: Local codebase indexer and context provider for AI coding assistants: MCP server and CLI with SQL data-access and C# call relations. No cloud, no server.
5
5
  Author: sfy257000
6
6
  Project-URL: Homepage, https://github.com/sfy257000/local-codebase-indexer
@@ -26,7 +26,7 @@ Requires-Dist: tree-sitter-python
26
26
  Requires-Dist: tree-sitter-javascript
27
27
  Requires-Dist: tree-sitter-typescript
28
28
  Requires-Dist: numpy
29
- Requires-Dist: pathspec
29
+ Requires-Dist: pathspec>=0.12.1
30
30
  Provides-Extra: onnx
31
31
  Requires-Dist: onnxruntime; extra == "onnx"
32
32
  Requires-Dist: tokenizers; extra == "onnx"
@@ -54,6 +54,15 @@ From a clone: `pip install -e .` (the `bin/indexer` launcher still works in a ch
54
54
 
55
55
  If you are an AI coding assistant asked to set this up: run `pip install local-codebase-indexer`, then `claude mcp add local-indexer -- local-codebase-indexer --root <project> serve` (Claude Code) or use the CLI commands below. Full instructions are in [`AGENTS.md`](AGENTS.md).
56
56
 
57
+ ### As a Claude Code plugin
58
+
59
+ ```text
60
+ /plugin marketplace add sfy257000/local-codebase-indexer
61
+ /plugin install local-codebase-indexer@local-codebase-indexer
62
+ ```
63
+
64
+ This registers the MCP server for the project you open (it runs `uvx local-codebase-indexer --root <project> serve`, so [uv](https://docs.astral.sh/uv/) must be installed: `pip install uv`). Restart Claude Code afterwards.
65
+
57
66
  ## Usage (CLI)
58
67
 
59
68
  ```bash
@@ -68,7 +77,7 @@ local-codebase-indexer status # is the ind
68
77
  ```
69
78
 
70
79
  - Without `--root` the current directory is used; `INDEXER_ROOT` also works.
71
- - Put `--json` before the subcommand to get JSON output.
80
+ - Put `--json` before or after the subcommand to get JSON output.
72
81
  - `search`, `relations` and `context` run an incremental refresh first (mtime check, then md5 only when mtime changed).
73
82
  - The tool names from the spec also work as subcommands: `codebase_semantic_search`, `codebase_get_symbol_relations`, `codebase_get_optimized_context` (options `--query`, `--symbol_name --relation_direction`, `--file_path --focus_lines --padding_lines`).
74
83
 
@@ -79,7 +88,28 @@ claude mcp add local-indexer -- local-codebase-indexer --root /path/to/project s
79
88
  # without installing: claude mcp add local-indexer -- uvx local-codebase-indexer --root /path/to/project serve
80
89
  ```
81
90
 
82
- `serve` speaks JSON-RPC (MCP) over stdio and exposes six tools: `codebase_semantic_search`, `codebase_get_symbol_relations`, `codebase_get_optimized_context`, `codebase_get_data_access`, `codebase_impact_analysis`, `codebase_index_status`. A long-lived server re-checks the index before a query when the last check is older than 15 s (a no-op check takes about a second on a few thousand files). `codebase_get_data_access` returns a summary (5 entries per section, every program) unless `detail` is set; `codebase_semantic_search` lists dependency-graph neighbours only with `related`.
91
+ `serve` speaks JSON-RPC (MCP) over stdio and exposes seven tools: `codebase_semantic_search`, `codebase_get_symbol_relations`, `codebase_get_optimized_context`, `codebase_get_data_access`, `codebase_impact_analysis`, `codebase_index_status`, `codebase_index_doctor`. A long-lived server re-checks the index before a query when the last check is older than 15 s (a no-op check takes about a second on a few thousand files). `codebase_get_data_access` returns a summary (5 entries per section, every program) unless `detail` is set; `codebase_semantic_search` lists dependency-graph neighbours only with `related`.
92
+
93
+ ## Diagnose missing code and control output
94
+
95
+ ```bash
96
+ local-codebase-indexer --root <project> doctor
97
+ local-codebase-indexer --root <project> doctor --path src/Service.cs
98
+ local-codebase-indexer --root <project> search "retrieve invoice" --file '*.py' --language python --limit 5
99
+ local-codebase-indexer --root <project> search "retrieve invoice" --file '*.py' --language python --limit 5 --offset 5
100
+ local-codebase-indexer --root <project> data-access MES_Lot --confidence confirmed --limit 20 --offset 0
101
+ local-codebase-indexer --root <project> data-access MES_Lot --full
102
+ ```
103
+
104
+ `doctor` reports supported text files, ignore rules, excluded directories, unsupported extensions, files over 5 MB, binary files and index health. `--path` explains a specific file, including a parent directory that prevents indexing. Directory counts are counts of excluded directories, not all the files hidden inside them. Nested `.gitignore` negations override parent file patterns; an excluded parent directory must first be re-included, just as with Git. Built-in excluded directories such as `node_modules` remain excluded.
105
+
106
+ Search filters apply **before** ranking. `--file` is a case-sensitive glob over the complete project-relative path (`*` also matches `/`); languages are `csharp`, `python`, `javascript`, `typescript`, `tsx`, and `text`. The JSON `pagination` object has `has_more` and `next_offset`; keep the same query and filters for subsequent pages. Pages assume the index remains unchanged. No-result responses suggest similar symbols where available and explain useful next steps. General verb paraphrases expand keyword/symbol matching without diluting vector queries; project-specific jargon still belongs in `.ai_context/synonyms.json`.
107
+
108
+ Data-access `--confidence` selects an exact level (`confirmed`, `probable`, or `uncertain`). `--limit` and `--offset` apply independently to each section, including programs and procedure accesses. JSON includes `pagination.sections` with totals and next offsets. MCP accepts the same `limit`, `offset`, and `confidence` fields; search uses `file_pattern` and `language`. `--full` / MCP `detail=true` lists all entries when no explicit page size is supplied. The old 40-entry display and 200-entry query caps have been removed.
109
+
110
+ `impact` includes both current symbols and affected symbols/accesses/callers from the base revision, so deleting a method or file remains visible. `snapshot: before` means its line numbers refer to the base revision, not the current file. The first request for a base revision builds a temporary historical index, which can take time on a large repository; a complete baseline is cached under `.ai_context/impact/` for reuse. Remove this directory to reclaim space. Historical analysis covers files in the Git archive; external `extra_roots` are not reconstructed. Static call-graph confidence and known language limitations still apply.
111
+
112
+ A nonexistent `--root` is rejected without creating it. `index` returns exit status 3 for an empty or partially failed run; use `doctor` and `status` to diagnose it. Invalid MCP inputs return an error while keeping the server available for the next request.
83
113
 
84
114
  ## Three-layer index
85
115
 
@@ -19,6 +19,15 @@ From a clone: `pip install -e .` (the `bin/indexer` launcher still works in a ch
19
19
 
20
20
  If you are an AI coding assistant asked to set this up: run `pip install local-codebase-indexer`, then `claude mcp add local-indexer -- local-codebase-indexer --root <project> serve` (Claude Code) or use the CLI commands below. Full instructions are in [`AGENTS.md`](AGENTS.md).
21
21
 
22
+ ### As a Claude Code plugin
23
+
24
+ ```text
25
+ /plugin marketplace add sfy257000/local-codebase-indexer
26
+ /plugin install local-codebase-indexer@local-codebase-indexer
27
+ ```
28
+
29
+ This registers the MCP server for the project you open (it runs `uvx local-codebase-indexer --root <project> serve`, so [uv](https://docs.astral.sh/uv/) must be installed: `pip install uv`). Restart Claude Code afterwards.
30
+
22
31
  ## Usage (CLI)
23
32
 
24
33
  ```bash
@@ -33,7 +42,7 @@ local-codebase-indexer status # is the ind
33
42
  ```
34
43
 
35
44
  - Without `--root` the current directory is used; `INDEXER_ROOT` also works.
36
- - Put `--json` before the subcommand to get JSON output.
45
+ - Put `--json` before or after the subcommand to get JSON output.
37
46
  - `search`, `relations` and `context` run an incremental refresh first (mtime check, then md5 only when mtime changed).
38
47
  - The tool names from the spec also work as subcommands: `codebase_semantic_search`, `codebase_get_symbol_relations`, `codebase_get_optimized_context` (options `--query`, `--symbol_name --relation_direction`, `--file_path --focus_lines --padding_lines`).
39
48
 
@@ -44,7 +53,28 @@ claude mcp add local-indexer -- local-codebase-indexer --root /path/to/project s
44
53
  # without installing: claude mcp add local-indexer -- uvx local-codebase-indexer --root /path/to/project serve
45
54
  ```
46
55
 
47
- `serve` speaks JSON-RPC (MCP) over stdio and exposes six tools: `codebase_semantic_search`, `codebase_get_symbol_relations`, `codebase_get_optimized_context`, `codebase_get_data_access`, `codebase_impact_analysis`, `codebase_index_status`. A long-lived server re-checks the index before a query when the last check is older than 15 s (a no-op check takes about a second on a few thousand files). `codebase_get_data_access` returns a summary (5 entries per section, every program) unless `detail` is set; `codebase_semantic_search` lists dependency-graph neighbours only with `related`.
56
+ `serve` speaks JSON-RPC (MCP) over stdio and exposes seven tools: `codebase_semantic_search`, `codebase_get_symbol_relations`, `codebase_get_optimized_context`, `codebase_get_data_access`, `codebase_impact_analysis`, `codebase_index_status`, `codebase_index_doctor`. A long-lived server re-checks the index before a query when the last check is older than 15 s (a no-op check takes about a second on a few thousand files). `codebase_get_data_access` returns a summary (5 entries per section, every program) unless `detail` is set; `codebase_semantic_search` lists dependency-graph neighbours only with `related`.
57
+
58
+ ## Diagnose missing code and control output
59
+
60
+ ```bash
61
+ local-codebase-indexer --root <project> doctor
62
+ local-codebase-indexer --root <project> doctor --path src/Service.cs
63
+ local-codebase-indexer --root <project> search "retrieve invoice" --file '*.py' --language python --limit 5
64
+ local-codebase-indexer --root <project> search "retrieve invoice" --file '*.py' --language python --limit 5 --offset 5
65
+ local-codebase-indexer --root <project> data-access MES_Lot --confidence confirmed --limit 20 --offset 0
66
+ local-codebase-indexer --root <project> data-access MES_Lot --full
67
+ ```
68
+
69
+ `doctor` reports supported text files, ignore rules, excluded directories, unsupported extensions, files over 5 MB, binary files and index health. `--path` explains a specific file, including a parent directory that prevents indexing. Directory counts are counts of excluded directories, not all the files hidden inside them. Nested `.gitignore` negations override parent file patterns; an excluded parent directory must first be re-included, just as with Git. Built-in excluded directories such as `node_modules` remain excluded.
70
+
71
+ Search filters apply **before** ranking. `--file` is a case-sensitive glob over the complete project-relative path (`*` also matches `/`); languages are `csharp`, `python`, `javascript`, `typescript`, `tsx`, and `text`. The JSON `pagination` object has `has_more` and `next_offset`; keep the same query and filters for subsequent pages. Pages assume the index remains unchanged. No-result responses suggest similar symbols where available and explain useful next steps. General verb paraphrases expand keyword/symbol matching without diluting vector queries; project-specific jargon still belongs in `.ai_context/synonyms.json`.
72
+
73
+ Data-access `--confidence` selects an exact level (`confirmed`, `probable`, or `uncertain`). `--limit` and `--offset` apply independently to each section, including programs and procedure accesses. JSON includes `pagination.sections` with totals and next offsets. MCP accepts the same `limit`, `offset`, and `confidence` fields; search uses `file_pattern` and `language`. `--full` / MCP `detail=true` lists all entries when no explicit page size is supplied. The old 40-entry display and 200-entry query caps have been removed.
74
+
75
+ `impact` includes both current symbols and affected symbols/accesses/callers from the base revision, so deleting a method or file remains visible. `snapshot: before` means its line numbers refer to the base revision, not the current file. The first request for a base revision builds a temporary historical index, which can take time on a large repository; a complete baseline is cached under `.ai_context/impact/` for reuse. Remove this directory to reclaim space. Historical analysis covers files in the Git archive; external `extra_roots` are not reconstructed. Static call-graph confidence and known language limitations still apply.
76
+
77
+ A nonexistent `--root` is rejected without creating it. `index` returns exit status 3 for an empty or partially failed run; use `doctor` and `status` to diagnose it. Invalid MCP inputs return an error while keeping the server available for the next request.
48
78
 
49
79
  ## Three-layer index
50
80
 
@@ -15,6 +15,15 @@ pipx install local-codebase-indexer
15
15
 
16
16
  从源码:`pip install -e .`(在 clone 下 `bin/indexer` 仍可使用)。
17
17
 
18
+ ### 作为 Claude Code plugin 安装
19
+
20
+ ```text
21
+ /plugin marketplace add sfy257000/local-codebase-indexer
22
+ /plugin install local-codebase-indexer@local-codebase-indexer
23
+ ```
24
+
25
+ 会为你打开的项目注册 MCP 服务器(实际运行 `uvx local-codebase-indexer --root <项目> serve`,所以要先装 [uv](https://docs.astral.sh/uv/):`pip install uv`)。安装后重启 Claude Code。
26
+
18
27
  ## 使用(CLI)
19
28
 
20
29
  ```bash
@@ -29,7 +38,7 @@ local-codebase-indexer status # 索引是
29
38
  ```
30
39
 
31
40
  - 不指定 `--root` 时使用当前目录,也可用环境变量 `INDEXER_ROOT`。
32
- - 加 `--json`(放在子命令前)输出 JSON。
41
+ - 加 `--json`(可放在子命令前后)输出 JSON。
33
42
  - `search`、`relations`、`context` 执行前会自动做一次增量更新(先比较 mtime,mtime 变了才计算 md5)。
34
43
  - 规格中的工具名称也可以直接作为子命令:`codebase_semantic_search`、`codebase_get_symbol_relations`、`codebase_get_optimized_context`(参数 `--query`、`--symbol_name --relation_direction`、`--file_path --focus_lines --padding_lines`)。
35
44
 
@@ -40,7 +49,20 @@ claude mcp add local-indexer -- local-codebase-indexer --root /path/to/project s
40
49
  # 不安装直接运行:claude mcp add local-indexer -- uvx local-codebase-indexer --root /path/to/project serve
41
50
  ```
42
51
 
43
- `serve` 通过 stdio 提供 JSON-RPC(MCP),暴露六个工具:`codebase_semantic_search`、`codebase_get_symbol_relations`、`codebase_get_optimized_context`、`codebase_get_data_access`、`codebase_impact_analysis`、`codebase_index_status`。常驻的 server 在距离上次检查超过 15 秒时,查询前会重新检查索引(几千个文件无变动约 1 秒)。`codebase_get_data_access` 默认返回摘要(每区 5 条、程序全列),加 `detail` 才列全部;`codebase_semantic_search` 加 `related` 才附依赖文件。
52
+ `serve` 通过 stdio 提供 JSON-RPC(MCP),暴露七个工具:`codebase_semantic_search`、`codebase_get_symbol_relations`、`codebase_get_optimized_context`、`codebase_get_data_access`、`codebase_impact_analysis`、`codebase_index_status`、`codebase_index_doctor`。常驻的 server 在距离上次检查超过 15 秒时,查询前会重新检查索引(几千个文件无变动约 1 秒)。`codebase_get_data_access` 默认返回摘要(每区 5 条、程序全列),加 `detail` 才列全部;`codebase_semantic_search` 加 `related` 才附依赖文件。
53
+
54
+ ## 诊断、筛选与分页(0.6.0)
55
+
56
+ ```bash
57
+ local-codebase-indexer --root <项目> doctor --path src/Service.cs
58
+ local-codebase-indexer --root <项目> search "读取发票" --file '*.py' --language python --limit 5 --offset 0
59
+ local-codebase-indexer --root <项目> data-access MES_Lot --confidence confirmed --limit 20 --offset 20
60
+ local-codebase-indexer --root <项目> data-access MES_Lot --full
61
+ ```
62
+
63
+ `doctor` 解释忽略规则、不支持的扩展名、过大和二进制文件以及索引状态。搜索先筛选再排名;文件 glob 区分大小写,`*` 可以跨 `/`。JSON 提供 `pagination.next_offset`。数据访问支持精确信心等级筛选和每个区段独立分页;`--full`/MCP `detail=true` 不再受旧有 40/200 条上限限制。MCP 搜索使用 `file_pattern`、`language`、`limit`、`offset`,数据访问使用 `confidence`、`limit`、`offset`,新增诊断工具 `codebase_index_doctor`。
64
+
65
+ `impact` 保留删除代码及历史调用、数据表影响;`snapshot=before` 的行号属于基准版本。历史索引首次建立后缓存在 `.ai_context/impact/`,可安全删除以释放空间;不会重建外部 `extra_roots`,静态分析限制仍适用。不存在的根目录会报错,空索引或部分失败返回退出码 3;MCP 参数错误不会结束服务。新增常见中英文同义词,项目术语仍可配置在 `.ai_context/synonyms.json`。
44
66
 
45
67
  ## 三层索引
46
68
 
@@ -15,6 +15,15 @@ pipx install local-codebase-indexer
15
15
 
16
16
  從原始碼:`pip install -e .`(在 clone 下 `bin/indexer` 仍可使用)。
17
17
 
18
+ ### 當作 Claude Code plugin 安裝
19
+
20
+ ```text
21
+ /plugin marketplace add sfy257000/local-codebase-indexer
22
+ /plugin install local-codebase-indexer@local-codebase-indexer
23
+ ```
24
+
25
+ 會替你開啟的專案註冊 MCP 伺服器(實際執行 `uvx local-codebase-indexer --root <專案> serve`,所以要先裝 [uv](https://docs.astral.sh/uv/):`pip install uv`)。安裝後重開 Claude Code。
26
+
18
27
  ## 使用(CLI)
19
28
 
20
29
  ```bash
@@ -29,7 +38,7 @@ local-codebase-indexer status # 索引是
29
38
  ```
30
39
 
31
40
  - 不給 `--root` 時使用目前目錄,也可用環境變數 `INDEXER_ROOT`。
32
- - 加 `--json`(放在子命令前)輸出 JSON。
41
+ - 加 `--json`(可放在子命令前後)輸出 JSON。
33
42
  - `search`、`relations`、`context` 執行前會自動做一次增量更新(先比 mtime,mtime 變了才算 md5)。
34
43
  - 規格中的工具名稱也可直接當子命令:`codebase_semantic_search`、`codebase_get_symbol_relations`、`codebase_get_optimized_context`(參數 `--query`、`--symbol_name --relation_direction`、`--file_path --focus_lines --padding_lines`)。
35
44
 
@@ -40,7 +49,24 @@ claude mcp add local-indexer -- local-codebase-indexer --root /path/to/project s
40
49
  # 不安裝直接跑:claude mcp add local-indexer -- uvx local-codebase-indexer --root /path/to/project serve
41
50
  ```
42
51
 
43
- `serve` 以 stdio 提供 JSON-RPC(MCP),暴露六個工具:`codebase_semantic_search`、`codebase_get_symbol_relations`、`codebase_get_optimized_context`、`codebase_get_data_access`、`codebase_impact_analysis`、`codebase_index_status`。長駐的 server 在距離上次檢查超過 15 秒時,查詢前會重新檢查索引(幾千個檔案無變動約 1 秒)。`codebase_get_data_access` 預設回摘要(每區 5 筆、程式全列),加 `detail` 才列全部;`codebase_semantic_search` 加 `related` 才附相依檔案。
52
+ `serve` 以 stdio 提供 JSON-RPC(MCP),暴露七個工具:`codebase_semantic_search`、`codebase_get_symbol_relations`、`codebase_get_optimized_context`、`codebase_get_data_access`、`codebase_impact_analysis`、`codebase_index_status`、`codebase_index_doctor`。長駐的 server 在距離上次檢查超過 15 秒時,查詢前會重新檢查索引(幾千個檔案無變動約 1 秒)。`codebase_get_data_access` 預設回摘要(每區 5 筆、程式全列),加 `detail` 才列全部;`codebase_semantic_search` 加 `related` 才附相依檔案。
53
+
54
+ ## 診斷、篩選與分頁(0.6.0)
55
+
56
+ ```bash
57
+ local-codebase-indexer --root <專案> doctor --path src/Service.cs
58
+ local-codebase-indexer --root <專案> search "讀取發票" --file '*.py' --language python --limit 5 --offset 0
59
+ local-codebase-indexer --root <專案> data-access MES_Lot --confidence confirmed --limit 20 --offset 20
60
+ local-codebase-indexer --root <專案> data-access MES_Lot --full
61
+ ```
62
+
63
+ - `doctor` 顯示索引範圍、忽略項目、不支援的副檔名、過大/二進位檔案與索引狀態;`--path` 可查單一檔案的排除原因。排除目錄的數量不代表其中的檔案數量。
64
+ - 搜尋先套用檔案與語言篩選再排序。`--file` 是完整相對路徑的 glob,區分大小寫,`*` 可跨 `/`。JSON 的 `pagination.next_offset` 提供下一頁;翻頁時保留相同查詢與篩選,並避免在中途修改索引。
65
+ - `data-access` 的 `--confidence` 精確選取 `confirmed`/`probable`/`uncertain`;分頁對每個區段各自套用,JSON 提供各區總數與下一個 offset。`--full`/MCP `detail=true` 不再受舊有 40/200 筆上限限制。
66
+ - MCP 搜尋參數為 `file_pattern`、`language`、`limit`、`offset`;資料存取工具支援 `confidence`、`limit`、`offset`。新增 `codebase_index_doctor` 診斷工具。
67
+ - `impact` 同時分析修改前後的程式,包含刪除項目及舊有呼叫/資料表影響;`snapshot=before` 的行號屬於基準版本。首次會建立歷史索引,之後重用 `.ai_context/impact/` 快取;此目錄可安全刪除以釋放空間。歷史分析不重建 Git 之外的 `extra_roots`,既有靜態分析限制仍適用。
68
+ - 不存在的根目錄會報錯,不會自動建立;空索引或有失敗項目的 `index` 回傳結束碼 3。MCP 收到錯誤參數後仍可繼續處理下一個請求。
69
+ - 擴充一般中英文動詞與密碼用語;專案術語仍建議放入 `.ai_context/synonyms.json`。這是詞彙搜尋改善,並不保證能理解所有自然語句。
44
70
 
45
71
  ## 三層索引
46
72
 
@@ -17,12 +17,13 @@ Priorities come from the benchmark (`benchmarks/run_benchmark.py`, baseline in `
17
17
  | ANN index | Exact search is not the bottleneck. Measured (Python stdlib copies, linear growth): 17k chunks cold CLI search 0.35 s / warm 0.13 s / index 10 s; 52k chunks 0.75 s / 0.36 s / 28 s; 104k chunks 1.09 s / 0.73 s / 54 s, 372 MB RSS, 729 MB database. At 104k chunks the cosine product plus top-k takes about 12 ms; loading the vectors out of SQLite (fetch 0.31 s, join 0.12 s) is about half of a warm query | Exact cosine itself becomes slow, which is far beyond 1M chunks |
18
18
  | Vector matrix cache | Cheap and measurable: it removes about half of a warm query at 104k chunks (about 0.8 s -> 0.3 s). Not needed below ~50k chunks | A real project passes ~50k chunks. Keep the matrix in the MCP server process, and/or store it as a memory-mapped `.npy` next to the database so the CLI benefits too (invalidate on any index change) |
19
19
  | `codebase_trace_execution` | Needs reliable call / data-flow relations; today's usage edges are name matches | Call graph gaps (item 3) are narrowed; today edges carry a confidence level |
20
- | `codebase_impact_analysis` | Same dependency; must separate confirmed from guessed edges | Call graph gaps (item 3) are narrowed; today edges carry a confidence level |
21
20
  | `codebase_architecture_overview` | Low value for the intended use cases | A concrete need appears |
22
21
  | `codebase_find_references` (upgrade) | `relations` already returns name-matched references | Done in part: `relations` already separates confirmed / probable / candidate callers |
23
22
 
24
23
  ## Done
25
24
 
25
+ - 0.6.0: complete before/after impact analysis with cached historical indexes; resilient MCP input validation; nested ignore negations; root validation; doctor diagnostics; bounded and filtered search; confidence-filtered data-access pagination with no hidden full-output caps; general paraphrases; mandatory ONNX dependencies in CI. See CHANGELOG.md for validation and limitations.
26
+
26
27
  - 0.5.0: a long-lived MCP server re-checks the index (was: once per process); full build 155 s -> 36 s on 2.3k files (C# usings no longer scanned as Python modules, per-file savepoints with batched commits); Chinese comment <-> identifier dictionary mined per project (iWAP paraphrase MRR 0.57 -> 0.64); data-access summary by default (`detail` / `--full`), related files only on request; EF confidence from the context variable's type; NO KNOWN CALLER roots; `impact` tool for a git diff; status shows the running version and warns when the code changed after start
27
28
 
28
29
  - Data access: `StringBuilder` SQL, EF LINQ on `DbSet<T>` members (resolved after indexing against declared DbSets), `programs` roll-up from accessors to controller actions; `relations Type.Method`; call graph resolves `Lazy<T>.Value` and `foreach (var x in ...)` element types; programs roll-up walks from an implementation to its interface method's callers and lists Razor pages (`Url.Action`, AngularJS `ControllerPath + 'Action'`); a typed identifier's scope includes files named after it and ranks names matching the rest of the query first ("WD0096 存檔" -> SetRecord); EF `SaveChanges` on tracked entities listed as possible writes; `.ai_context/extra_roots`; `.ai_context/ignore`, minified files skipped; C# namespace imports only link files whose types are used; piped CLI output is UTF-8
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env python3
2
+ """Launcher: bin/indexer <tool_name> --params"""
3
+ import os
4
+ import sys
5
+
6
+ sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
7
+
8
+ from local_codebase_indexer.cli import main # noqa: E402
9
+
10
+ if __name__ == "__main__":
11
+ sys.exit(main())
@@ -1,3 +1,3 @@
1
1
  """Universal Local Codebase Indexer & Context Provider (see index.md)."""
2
2
 
3
- __version__ = "0.5.0"
3
+ __version__ = "0.6.0"
@@ -19,6 +19,20 @@ def _emit(data, text: str, as_json: bool) -> None:
19
19
  print(json.dumps(data, ensure_ascii=False, indent=2) if as_json else text)
20
20
 
21
21
 
22
+ def _positive(value: str) -> int:
23
+ n = int(value)
24
+ if n < 1:
25
+ raise argparse.ArgumentTypeError("must be positive")
26
+ return n
27
+
28
+
29
+ def _nonnegative(value: str) -> int:
30
+ n = int(value)
31
+ if n < 0:
32
+ raise argparse.ArgumentTypeError("must be nonnegative")
33
+ return n
34
+
35
+
22
36
  def build_parser() -> argparse.ArgumentParser:
23
37
  p = argparse.ArgumentParser(prog="local-codebase-indexer", description="Local codebase indexer & context provider")
24
38
  p.add_argument("--root", default=os.environ.get("INDEXER_ROOT", os.getcwd()), help="project root (default: cwd)")
@@ -32,7 +46,10 @@ def build_parser() -> argparse.ArgumentParser:
32
46
  s = sub.add_parser("search", aliases=["codebase_semantic_search"], help="hybrid semantic search")
33
47
  s.add_argument("query", nargs="?")
34
48
  s.add_argument("--query", dest="query_opt")
35
- s.add_argument("--limit", type=int, default=5)
49
+ s.add_argument("--limit", type=_positive, default=5)
50
+ s.add_argument("--offset", type=_nonnegative, default=0)
51
+ s.add_argument("--file", dest="file_pattern", help="file glob, e.g. '*Repository*.cs'")
52
+ s.add_argument("--language", help="csharp, python, javascript, typescript, tsx or text")
36
53
  s.add_argument("--related", action="store_true", help="also list dependency-graph neighbours of the top hits")
37
54
 
38
55
  s = sub.add_parser("relations", aliases=["codebase_get_symbol_relations"], help="symbol dependency graph")
@@ -52,16 +69,24 @@ def build_parser() -> argparse.ArgumentParser:
52
69
  help="who reads / writes / executes a table or stored procedure, and what a procedure touches")
53
70
  s.add_argument("object", nargs="?")
54
71
  s.add_argument("--object_name", dest="object_opt")
55
- s.add_argument("--full", action="store_true", help="up to 40 entries per section instead of a 5-entry summary")
72
+ s.add_argument("--full", action="store_true", help="list every entry instead of a 5-entry summary")
73
+ s.add_argument("--limit", type=_positive, help="page size per section")
74
+ s.add_argument("--offset", type=_nonnegative, default=0)
75
+ s.add_argument("--confidence", choices=["confirmed", "probable", "uncertain"])
56
76
 
57
77
  s = sub.add_parser("impact", aliases=["codebase_impact_analysis"],
58
78
  help="symbols, tables, programs and pages touched by a git diff")
59
79
  s.add_argument("base", nargs="?", help="git revision or range (default: uncommitted work against HEAD)")
60
80
  s.add_argument("--full", action="store_true", help="list every changed symbol")
61
81
 
82
+ s = sub.add_parser("doctor", help="diagnose index coverage and excluded files")
83
+ s.add_argument("--path", help="explain why a specific file is excluded")
62
84
  sub.add_parser("stats", help="show index statistics")
63
85
  sub.add_parser("status", aliases=["codebase_index_status"], help="index health: freshness, failures, consistency")
64
86
  sub.add_parser("serve", help="run as MCP server over stdio (JSON-RPC)")
87
+ for parser in set(sub.choices.values()):
88
+ parser.add_argument("--root", default=argparse.SUPPRESS, help="project root")
89
+ parser.add_argument("--json", action="store_true", default=argparse.SUPPRESS, help="print JSON")
65
90
  return p
66
91
 
67
92
 
@@ -86,14 +111,14 @@ def main(argv: list[str] | None = None) -> int:
86
111
  _fix_stdio(serving=args.cmd == "serve")
87
112
  root = os.path.abspath(args.root)
88
113
 
89
- if args.cmd == "serve":
90
- from .mcp_server import serve
91
- return serve(root)
92
-
93
114
  from .query import (render_context, render_data_access, render_impact, render_relations, render_search,
94
- render_status)
115
+ render_status, render_doctor)
95
116
 
117
+ t = None
96
118
  try:
119
+ if args.cmd == "serve":
120
+ from .mcp_server import serve
121
+ return serve(root)
97
122
  t = _tools(root)
98
123
  if args.cmd == "index":
99
124
  st = t.refresh(force=args.force).as_dict()
@@ -101,13 +126,18 @@ def main(argv: list[str] | None = None) -> int:
101
126
  f'-{st["deleted"]} (skipped {st["skipped"]}, failed {st["failed"]}); {st["symbols"]} symbols, {st["chunks"]} chunks')
102
127
  if st["warnings"]:
103
128
  text += "\nwarnings:\n " + "\n ".join(st["warnings"][:20])
129
+ if not st['scanned']:
130
+ text += "\nNo indexable files. Run doctor to check the root, ignore rules and supported extensions."
131
+ st['hints'] = ["Run doctor to check the root, ignore rules and supported extensions."]
104
132
  _emit(st, text, args.json)
133
+ if st['failed'] or not st['scanned']:
134
+ return 3
105
135
  elif args.cmd in ("search", "codebase_semantic_search"):
106
136
  q = args.query_opt or args.query
107
137
  if not q:
108
138
  print("error: a query is required", file=sys.stderr)
109
139
  return 2
110
- res = t.semantic_search(q, args.limit, args.related)
140
+ res = t.semantic_search(q, args.limit, args.related, args.file_pattern, args.language, args.offset)
111
141
  _emit(res, render_search(res), args.json)
112
142
  elif args.cmd in ("relations", "codebase_get_symbol_relations"):
113
143
  sym = args.symbol_opt or args.symbol
@@ -128,7 +158,7 @@ def main(argv: list[str] | None = None) -> int:
128
158
  if not name:
129
159
  print("error: an object name is required", file=sys.stderr)
130
160
  return 2
131
- res = t.data_access(name)
161
+ res = t.data_access(name, args.limit, args.offset, args.confidence)
132
162
  _emit(res, render_data_access(res, args.full), args.json)
133
163
  elif args.cmd in ("impact", "codebase_impact_analysis"):
134
164
  res = t.impact(args.base)
@@ -137,12 +167,18 @@ def main(argv: list[str] | None = None) -> int:
137
167
  res = t.index_status()
138
168
  _emit(res, render_status(res), args.json)
139
169
  return 0 if res["state"] in ("fresh", "stale") else 3
170
+ elif args.cmd == "doctor":
171
+ res = t.doctor(args.path)
172
+ _emit(res, render_doctor(res), args.json)
140
173
  elif args.cmd == "stats":
141
174
  st = t.stats()
142
175
  _emit(st, "\n".join(f"{k}: {v}" for k, v in st.items()), args.json)
143
- except (ValueError, FileNotFoundError) as exc:
176
+ except (ValueError, OSError) as exc:
144
177
  print(f"error: {exc}", file=sys.stderr)
145
178
  return 1
179
+ finally:
180
+ if t is not None:
181
+ t.indexer.close()
146
182
  return 0
147
183
 
148
184
 
@@ -123,6 +123,8 @@ class IndexStats:
123
123
  class Indexer:
124
124
  def __init__(self, root: str, db_path: str | None = None, embedder=None):
125
125
  self.root = os.path.abspath(root)
126
+ if not os.path.isdir(self.root):
127
+ raise ValueError(f"project root is not an existing directory: {self.root}")
126
128
  self.db_path = db_path or dbmod.default_db_path(self.root)
127
129
  self.conn = dbmod.connect(self.db_path)
128
130
  self.embedder = embedder or get_embedder()
@@ -16,7 +16,6 @@ from collections import deque
16
16
 
17
17
  MAX_DEPTH = 4
18
18
  ENTRY_DEPTH = 8
19
- LIST_CAP = 200
20
19
  _METHOD_KINDS = ("method", "constructor", "function")
21
20
  SQL_OBJECT_KINDS = ("table", "procedure", "view", "function")
22
21
  _CONF = {"confirmed": 0, "probable": 1, "uncertain": 2}
@@ -168,8 +167,8 @@ def _touches(conn: sqlite3.Connection, lk: _Lookup, definitions: list[dict], max
168
167
  for d in _definitions(conn, r["target_key"]):
169
168
  if d["type"] in ("procedure", "function", "view"):
170
169
  queue.append((d["id"], chain + [r["target_name"]], depth + 1))
171
- return {"reads": _sort(reads)[:LIST_CAP], "writes": _sort(writes)[:LIST_CAP],
172
- "executes": _sort(execs)[:LIST_CAP], "dynamic_sql": _sort(dynamic)[:LIST_CAP]}
170
+ return {"reads": _sort(reads), "writes": _sort(writes),
171
+ "executes": _sort(execs), "dynamic_sql": _sort(dynamic)}
173
172
 
174
173
 
175
174
  def _program(sym: sqlite3.Row) -> str | None:
@@ -225,8 +224,9 @@ def _programs(conn: sqlite3.Connection, lk: _Lookup, entries: list[dict]) -> tup
225
224
  queue.append((parent, access, depth + 1, pconf))
226
225
  if not parents and sym["symbol_type"] in _METHOD_KINDS:
227
226
  root = roots.setdefault(sid, {"symbol": sym["qualified_name"] or sym["symbol_name"],
228
- "file_path": sym["file_path"], "line": sym["start_line"], "access": set()})
227
+ "file_path": sym["file_path"], "line": sym["start_line"], "access": set(), "confidence": conf})
229
228
  root["access"].add(access)
229
+ root['confidence'] = min(root['confidence'], conf, key=_CONF.__getitem__)
230
230
  out = []
231
231
  for p in sorted(progs.values(), key=lambda p: p["program"]):
232
232
  ids = sorted(p.pop("ids"))
@@ -269,11 +269,11 @@ def data_access(conn: sqlite3.Connection, object_name: str, max_depth: int = MAX
269
269
 
270
270
  result = {
271
271
  "object": object_name, "key": key, "found": True, "kind": kind, "definitions": defs,
272
- "readers": pick("read")[:LIST_CAP],
273
- "writers": pick("write")[:LIST_CAP],
274
- "executed_by": pick("exec")[:LIST_CAP],
272
+ "readers": pick("read"),
273
+ "writers": pick("write"),
274
+ "executed_by": pick("exec"),
275
275
  "mapped_by": _sort([e for e in confirmed if e["access"] == "map"]),
276
- "possible": _sort(possible)[:LIST_CAP],
276
+ "possible": _sort(possible),
277
277
  "programs": [],
278
278
  "no_known_caller": [],
279
279
  "notes": [],