local-codebase-indexer 0.3.2__tar.gz → 0.5.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.
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/AGENTS.md +3 -2
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/CLAUDE.md +3 -2
- {local_codebase_indexer-0.3.2/local_codebase_indexer.egg-info → local_codebase_indexer-0.5.0}/PKG-INFO +15 -8
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/README.md +14 -7
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/README.zh-CN.md +14 -7
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/README.zh-TW.md +14 -7
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/TODO.md +8 -4
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/local_codebase_indexer/__init__.py +1 -1
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/local_codebase_indexer/cli.py +18 -7
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/local_codebase_indexer/core.py +233 -8
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/local_codebase_indexer/cscalls.py +79 -3
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/local_codebase_indexer/csdata.py +126 -5
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/local_codebase_indexer/dataflow.py +80 -5
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/local_codebase_indexer/db.py +10 -2
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/local_codebase_indexer/langparse.py +24 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/local_codebase_indexer/mcp_server.py +23 -7
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/local_codebase_indexer/query.py +203 -27
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/local_codebase_indexer/scanner.py +40 -3
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/local_codebase_indexer/sqlaccess.py +1 -1
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0/local_codebase_indexer.egg-info}/PKG-INFO +15 -8
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/server.json +2 -2
- local_codebase_indexer-0.5.0/tests/test_dataaccess.py +419 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/tests/test_indexer.py +86 -3
- local_codebase_indexer-0.3.2/tests/test_dataaccess.py +0 -144
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/MANIFEST.in +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/benchmarks/README.md +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/benchmarks/baseline.json +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/benchmarks/corpus/Auth/LoginService.cs +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/benchmarks/corpus/Controllers/LotController.cs +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/benchmarks/corpus/Controllers/ScrapController.cs +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/benchmarks/corpus/Data/MesDbContext.cs +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/benchmarks/corpus/Legacy/frmChangeLine.frm +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/benchmarks/corpus/Models/DrillBreakEvent.cs +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/benchmarks/corpus/Models/Lot.cs +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/benchmarks/corpus/Models/ScrapRecord.cs +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/benchmarks/corpus/Printing/LabelPrinter.cs +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/benchmarks/corpus/Repositories/LotRepository.cs +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/benchmarks/corpus/Repositories/ScrapRepository.cs +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/benchmarks/corpus/Services/IScrapService.cs +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/benchmarks/corpus/Services/InspectionService.cs +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/benchmarks/corpus/Services/LotService.cs +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/benchmarks/corpus/Services/ScrapService.cs +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/benchmarks/corpus/Sql/MES_Lot.sql +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/benchmarks/corpus/Sql/usp_Inspection_Report.sql +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/benchmarks/corpus/Sql/usp_Lot_UpdateStatus.sql +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/benchmarks/corpus/Sql/usp_Scrap_Insert.sql +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/benchmarks/corpus/Utils/DateRangeHelper.cs +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/benchmarks/corpus/Utils/PartNumberDecoder.cs +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/benchmarks/corpus/Web/scrapForm.ts +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/benchmarks/corpus/Web.config +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/benchmarks/corpus/tools/export_report.py +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/benchmarks/queries_stdlib.json +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/benchmarks/queries_synthetic.json +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/benchmarks/run_benchmark.py +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/index.md +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/llms.txt +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/local_codebase_indexer/__main__.py +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/local_codebase_indexer/callgraph.py +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/local_codebase_indexer/embedder.py +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/local_codebase_indexer/synonyms.py +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/local_codebase_indexer.egg-info/SOURCES.txt +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/local_codebase_indexer.egg-info/dependency_links.txt +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/local_codebase_indexer.egg-info/entry_points.txt +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/local_codebase_indexer.egg-info/requires.txt +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/local_codebase_indexer.egg-info/top_level.txt +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/pyproject.toml +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/requirements.txt +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/setup.cfg +0 -0
- {local_codebase_indexer-0.3.2 → local_codebase_indexer-0.5.0}/tests/test_onnx_plumbing.py +0 -0
|
@@ -18,7 +18,8 @@ Check: `local-codebase-indexer --help`. No API keys or network access are needed
|
|
|
18
18
|
local-codebase-indexer --root <project> index # build / refresh the index
|
|
19
19
|
local-codebase-indexer --root <project> search "natural language or identifier" --limit 5
|
|
20
20
|
local-codebase-indexer --root <project> relations <SymbolName> --direction both
|
|
21
|
-
local-codebase-indexer --root <project> data-access <TableOrProcedure> # who reads / writes / executes it
|
|
21
|
+
local-codebase-indexer --root <project> data-access <TableOrProcedure> # who reads / writes / executes it, which programs and pages reach it
|
|
22
|
+
local-codebase-indexer --root <project> impact [base] # what a diff touches: symbols, tables, programs, pages
|
|
22
23
|
local-codebase-indexer --root <project> context <file> --lines 120 --padding 15
|
|
23
24
|
local-codebase-indexer --root <project> status # is the index fresh?
|
|
24
25
|
```
|
|
@@ -31,7 +32,7 @@ Put `--json` before the subcommand for JSON output. The index lives in `<project
|
|
|
31
32
|
claude mcp add local-indexer -- local-codebase-indexer --root <project> serve
|
|
32
33
|
```
|
|
33
34
|
|
|
34
|
-
Tools: `codebase_semantic_search`, `codebase_get_symbol_relations`, `codebase_get_optimized_context`, `codebase_get_data_access`, `codebase_index_status`.
|
|
35
|
+
Tools: `codebase_semantic_search`, `codebase_get_symbol_relations`, `codebase_get_optimized_context`, `codebase_get_data_access`, `codebase_impact_analysis`, `codebase_index_status`.
|
|
35
36
|
|
|
36
37
|
## Reading the results
|
|
37
38
|
|
|
@@ -18,7 +18,8 @@ Check: `local-codebase-indexer --help`. No API keys or network access are needed
|
|
|
18
18
|
local-codebase-indexer --root <project> index # build / refresh the index
|
|
19
19
|
local-codebase-indexer --root <project> search "natural language or identifier" --limit 5
|
|
20
20
|
local-codebase-indexer --root <project> relations <SymbolName> --direction both
|
|
21
|
-
local-codebase-indexer --root <project> data-access <TableOrProcedure> # who reads / writes / executes it
|
|
21
|
+
local-codebase-indexer --root <project> data-access <TableOrProcedure> # who reads / writes / executes it, which programs and pages reach it
|
|
22
|
+
local-codebase-indexer --root <project> impact [base] # what a diff touches: symbols, tables, programs, pages
|
|
22
23
|
local-codebase-indexer --root <project> context <file> --lines 120 --padding 15
|
|
23
24
|
local-codebase-indexer --root <project> status # is the index fresh?
|
|
24
25
|
```
|
|
@@ -31,7 +32,7 @@ Put `--json` before the subcommand for JSON output. The index lives in `<project
|
|
|
31
32
|
claude mcp add local-indexer -- local-codebase-indexer --root <project> serve
|
|
32
33
|
```
|
|
33
34
|
|
|
34
|
-
Tools: `codebase_semantic_search`, `codebase_get_symbol_relations`, `codebase_get_optimized_context`, `codebase_get_data_access`, `codebase_index_status`.
|
|
35
|
+
Tools: `codebase_semantic_search`, `codebase_get_symbol_relations`, `codebase_get_optimized_context`, `codebase_get_data_access`, `codebase_impact_analysis`, `codebase_index_status`.
|
|
35
36
|
|
|
36
37
|
## Reading the results
|
|
37
38
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: local-codebase-indexer
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.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
|
|
@@ -61,7 +61,8 @@ local-codebase-indexer --root <project> index # build / in
|
|
|
61
61
|
local-codebase-indexer search "database mapping for LotNo" --limit 5
|
|
62
62
|
local-codebase-indexer relations IExistOpenHandleService --direction both # upstream | downstream | both
|
|
63
63
|
local-codebase-indexer context Services/LotService.cs --lines 120 --padding 15 # alias: slice
|
|
64
|
-
local-codebase-indexer data-access MES_Lot # who reads / writes / executes a table or procedure; what a procedure touches
|
|
64
|
+
local-codebase-indexer data-access MES_Lot # who reads / writes / executes a table or procedure; what a procedure touches (--full: every entry)
|
|
65
|
+
local-codebase-indexer impact main...HEAD # symbols, tables, programs and pages a change touches (no argument: uncommitted work)
|
|
65
66
|
local-codebase-indexer stats
|
|
66
67
|
local-codebase-indexer status # is the index fresh? failed files, git commit, consistency checks
|
|
67
68
|
```
|
|
@@ -78,7 +79,7 @@ claude mcp add local-indexer -- local-codebase-indexer --root /path/to/project s
|
|
|
78
79
|
# without installing: claude mcp add local-indexer -- uvx local-codebase-indexer --root /path/to/project serve
|
|
79
80
|
```
|
|
80
81
|
|
|
81
|
-
`serve` speaks JSON-RPC (MCP) over stdio and exposes
|
|
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`.
|
|
82
83
|
|
|
83
84
|
## Three-layer index
|
|
84
85
|
|
|
@@ -88,18 +89,20 @@ claude mcp add local-indexer -- local-codebase-indexer --root /path/to/project s
|
|
|
88
89
|
| Topology | `using` / `import` resolved to file dependencies, inheritance (base lists) and type usage (`invocation`), stored in the `dependencies` table |
|
|
89
90
|
| Semantic | 384-dim chunk embeddings in `vss_chunks`; queries fuse FTS5 keyword, symbol-name and vector rankings with Reciprocal Rank Fusion, then expand to the dependency neighbours of the top 3 files |
|
|
90
91
|
|
|
91
|
-
Encodings: UTF-8 first, then Big5, then cp1252. Files over 5MB are skipped. Root and nested `.gitignore` files are respected, and `.git`, `bin`, `obj`, `node_modules` and similar directories are always skipped.
|
|
92
|
+
Encodings: UTF-8 first, then Big5, then cp1252. Files over 5MB are skipped. Root and nested `.gitignore` files are respected, and `.git`, `bin`, `obj`, `node_modules` and similar directories are always skipped. `*.min.js` / `*.min.css` are skipped too. Third-party or generated code that is committed to the repo can be excluded with `.ai_context/ignore` (gitignore syntax), e.g. `Scripts/*`, `!Scripts/Custom/`, `Web References/` (keep generated EF database-first models: their DbContext declares the DbSets).
|
|
92
93
|
|
|
93
94
|
## Differences from the spec
|
|
94
95
|
|
|
95
96
|
- **Vector storage**: `sqlite-vss` needs a native extension and is no longer maintained, so `vss_chunks` stores float32 BLOBs and cosine similarity is computed with numpy. No extension to install.
|
|
96
|
-
- **Embedding model**: the default is a built-in hashing embedder (identifier sub-words, bigrams, CJK character bigrams). It is fast and reproducible but **does not understand synonyms**. For real transformer embeddings, export `all-MiniLM-L6-v2` or `bge-small-en-v1.5` to ONNX, install `onnxruntime` and `tokenizers`, and set `INDEXER_ONNX_MODEL=<folder with model.onnx and tokenizer.json>` (
|
|
97
|
-
- **Call relations** for C# are resolved with limited type inference (using / namespaces, field and constructor-injected types, locals, interface to implementation), and every edge carries a confidence: `confirmed` (the receiver type is known), `probable` (reached through an interface or a single candidate) or `candidate` (name match only). There is no Roslyn: no overload resolution by argument type, no delegates / lambdas / extension methods, and call chains are followed one level. Inheritance edges come from the AST and are reliable.
|
|
97
|
+
- **Embedding model**: the default is a built-in hashing embedder (identifier sub-words, bigrams, CJK character bigrams). It is fast and reproducible but **does not understand synonyms**. For real transformer embeddings, export `all-MiniLM-L6-v2` or `bge-small-en-v1.5` to ONNX, install `onnxruntime` and `tokenizers`, and set `INDEXER_ONNX_MODEL=<folder with model.onnx and tokenizer.json>` (mean pooling suits MiniLM, bge models recommend CLS pooling). Switching embedders triggers a full re-index. Measured (0.4.0): `all-MiniLM-L6-v2` raises benchmark MRR by 0.08-0.13, but on a real 30k-chunk C# / Chinese-comment codebase it scored lower than hashing on paraphrased queries (MRR 0.29 vs 0.48; multilingual MiniLM-L12: 0.41) while a full index took 35-43 minutes instead of 2. Hashing stays the default; for domain jargon, `.ai_context/synonyms.json` helps more than a general model.
|
|
98
|
+
- **Call relations** for C# are resolved with limited type inference (using / namespaces, field and constructor-injected types, `Lazy<T>.Value`, locals, `foreach (var x in items.Where(..))` element types, interface to implementation), and every edge carries a confidence: `confirmed` (the receiver type is known), `probable` (reached through an interface or a single candidate) or `candidate` (name match only). There is no Roslyn: no overload resolution by argument type, no delegates / lambdas / extension methods, and call chains are followed one level. Inheritance edges come from the AST and are reliable.
|
|
98
99
|
- Extra schema additions: `symbols.qualified_name`, `chunk_metadata.symbol_id`, and the `raw_refs`, `chunks_fts` and `meta` tables.
|
|
99
100
|
|
|
100
101
|
## Data access (SQL)
|
|
101
102
|
|
|
102
|
-
`data-access <table-or-procedure>` answers "what writes / reads / executes X". It is built from T-SQL (INSERT / UPDATE / DELETE / MERGE / TRUNCATE / SELECT INTO / FROM / JOIN / EXEC, with alias resolution; CTEs, temp tables and system objects excluded), from C# SQL strings (literals, `+`, interpolation, `string.Format`, consts, locals) passed to Dapper, `SqlCommand` or EF `FromSql`, from stored-procedure names used with `CommandType.StoredProcedure`, and from EF `ToTable` / `[Table]` mappings. A procedure's callers are indirect writers of the tables it writes (followed up to 4 hops). Each entry has a confidence; **dynamic SQL (`EXEC(@sql)`, `sp_executesql`, SQL built from unknown values) cannot be resolved and is listed separately as `uncertain`**, never mixed into the confirmed lists. Known gaps: `FROM a JOIN b ON ..., c` loses `c`, and a stored-procedure name passed to a non-database method is not seen.
|
|
103
|
+
`data-access <table-or-procedure>` answers "what writes / reads / executes X". It is built from T-SQL (INSERT / UPDATE / DELETE / MERGE / TRUNCATE / SELECT INTO / FROM / JOIN / EXEC, with alias resolution; CTEs, temp tables and system objects excluded), from C# SQL strings (literals, `+`, interpolation, `string.Format`, consts, locals, `StringBuilder.Append` / `AppendLine` / `AppendFormat`) passed to Dapper, `SqlCommand` or EF `FromSql`, from stored-procedure names used with `CommandType.StoredProcedure`, from EF LINQ on `DbSet<T>` members (`ctx.Orders.Where(..)` / `.Add(..)` / `.Remove(..)`, `from o in ctx.Orders`; `probable`, since only the member name is matched) and from EF `ToTable` / `[Table]` mappings. A procedure's callers are indirect writers of the tables it writes (followed up to 4 hops). `programs` (USED BY PROGRAMS) follows confirmed / probable C# calls upward from those accessors to `*Controller` methods (up to 8 hops) (including from an implementation to the callers of the interface method it implements, for `foreach (var step in steps) step.Run()` pipelines) and groups them per controller file, with the Razor pages (`.cshtml`) whose `Url.Action("Action"[, "Controller"])` or AngularJS `ControllerPath + 'Action'` (controller from `$scope.Controller = 'X'`) targets those actions, so a table maps to the screens that touch it. A method that reads a DbSet and calls `SaveChanges` without an explicit `Add` / `Remove` may update tracked entities; it is listed as a possible (`uncertain`) writer. Each entry has a confidence; **dynamic SQL (`EXEC(@sql)`, `sp_executesql`, SQL built from unknown values) cannot be resolved and is listed separately as `uncertain`**, never mixed into the confirmed lists. EF accesses are `confirmed` when the context variable (`using (var db = new X())`, a field or property, or `this`) is typed as a class that declares or inherits the DbSet, `probable` otherwise. Methods on the way up that have no confirmed / probable caller at all are listed under NO KNOWN CALLER: entry points such as API endpoints, jobs or `Main`, or calls the graph could not resolve. Known gaps: `FROM a JOIN b ON ..., c` loses `c`, and a stored-procedure name passed to a non-database method is not seen.
|
|
104
|
+
|
|
105
|
+
Stored procedures that live only in the database can be exported to a folder outside the repo and listed in `.ai_context/extra_roots` (one folder per line, absolute or relative to the root); their files are indexed under their absolute paths.
|
|
103
106
|
|
|
104
107
|
Natural-language search routes questions such as "who modifies MES_ScrapRecord" or "哪些程式會寫入 MES_Lot" to this index first.
|
|
105
108
|
|
|
@@ -107,9 +110,13 @@ Natural-language search routes questions such as "who modifies MES_ScrapRecord"
|
|
|
107
110
|
|
|
108
111
|
Queries are expanded with a small synonym dictionary (`SP` / `預存程序` / `stored procedure` / `usp`, table, lot, scrap, ...; `local_codebase_indexer/synonyms.py`). Add or disable groups per project in `.ai_context/synonyms.json`: `{"groups": [["wpnlot", "在製批"]], "disable": ["sp"]}`. This helps abbreviations and Chinese/English terms, not free paraphrase.
|
|
109
112
|
|
|
113
|
+
The index also mines its own dictionary: Chinese bigrams in the comments right above a symbol are paired with the sub-words of its name (`/// 收帳` above `ReceiveLotAsync` gives 收帳 = receive). A pair is kept when at least 5 symbols support it, it covers at least 15% of the symbols commented with the bigram (smoothed) and the word is at least 15x likelier there than overall. On a 30k-chunk C# codebase this yields about 350 pairs (收帳 -> receive, 拆批 -> divide, 油墨 -> ink, 底片 -> film) and raised MRR on paraphrased queries from 0.57 to 0.64.
|
|
114
|
+
|
|
110
115
|
## Index health
|
|
111
116
|
|
|
112
|
-
`status` (also the MCP tool `codebase_index_status`) reports whether the index can be trusted without refreshing it: `fresh`, `stale` (files changed or git HEAD moved since the last update), `degraded` (failed files or an inconsistent database) or `not_indexed`. A file that fails to parse is removed from the index, listed with its error, and retried on every update, so search never returns stale lines for it. `index --force` rebuilds everything.
|
|
117
|
+
`status` (also the MCP tool `codebase_index_status`) reports whether the index can be trusted without refreshing it: `fresh`, `stale` (files changed or git HEAD moved since the last update), `degraded` (failed files or an inconsistent database) or `not_indexed`. A file that fails to parse is removed from the index, listed with its error, and retried on every update, so search never returns stale lines for it. `index --force` rebuilds everything. Status also shows the running version and warns when the package's code changed on disk after the process started (restart the MCP server, i.e. open a new Claude Code session, to run it).
|
|
118
|
+
|
|
119
|
+
Speed (2.3k files, 30k chunks, hashing embedder): full build about 36 s into an empty database, a branch switch that rewrites 400 files about 10 s, a no-op check about 1 s. Each file is written inside a savepoint (atomic), and commits are batched every 500 files.
|
|
113
120
|
|
|
114
121
|
## Benchmark
|
|
115
122
|
|
|
@@ -26,7 +26,8 @@ local-codebase-indexer --root <project> index # build / in
|
|
|
26
26
|
local-codebase-indexer search "database mapping for LotNo" --limit 5
|
|
27
27
|
local-codebase-indexer relations IExistOpenHandleService --direction both # upstream | downstream | both
|
|
28
28
|
local-codebase-indexer context Services/LotService.cs --lines 120 --padding 15 # alias: slice
|
|
29
|
-
local-codebase-indexer data-access MES_Lot # who reads / writes / executes a table or procedure; what a procedure touches
|
|
29
|
+
local-codebase-indexer data-access MES_Lot # who reads / writes / executes a table or procedure; what a procedure touches (--full: every entry)
|
|
30
|
+
local-codebase-indexer impact main...HEAD # symbols, tables, programs and pages a change touches (no argument: uncommitted work)
|
|
30
31
|
local-codebase-indexer stats
|
|
31
32
|
local-codebase-indexer status # is the index fresh? failed files, git commit, consistency checks
|
|
32
33
|
```
|
|
@@ -43,7 +44,7 @@ claude mcp add local-indexer -- local-codebase-indexer --root /path/to/project s
|
|
|
43
44
|
# without installing: claude mcp add local-indexer -- uvx local-codebase-indexer --root /path/to/project serve
|
|
44
45
|
```
|
|
45
46
|
|
|
46
|
-
`serve` speaks JSON-RPC (MCP) over stdio and exposes
|
|
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`.
|
|
47
48
|
|
|
48
49
|
## Three-layer index
|
|
49
50
|
|
|
@@ -53,18 +54,20 @@ claude mcp add local-indexer -- local-codebase-indexer --root /path/to/project s
|
|
|
53
54
|
| Topology | `using` / `import` resolved to file dependencies, inheritance (base lists) and type usage (`invocation`), stored in the `dependencies` table |
|
|
54
55
|
| Semantic | 384-dim chunk embeddings in `vss_chunks`; queries fuse FTS5 keyword, symbol-name and vector rankings with Reciprocal Rank Fusion, then expand to the dependency neighbours of the top 3 files |
|
|
55
56
|
|
|
56
|
-
Encodings: UTF-8 first, then Big5, then cp1252. Files over 5MB are skipped. Root and nested `.gitignore` files are respected, and `.git`, `bin`, `obj`, `node_modules` and similar directories are always skipped.
|
|
57
|
+
Encodings: UTF-8 first, then Big5, then cp1252. Files over 5MB are skipped. Root and nested `.gitignore` files are respected, and `.git`, `bin`, `obj`, `node_modules` and similar directories are always skipped. `*.min.js` / `*.min.css` are skipped too. Third-party or generated code that is committed to the repo can be excluded with `.ai_context/ignore` (gitignore syntax), e.g. `Scripts/*`, `!Scripts/Custom/`, `Web References/` (keep generated EF database-first models: their DbContext declares the DbSets).
|
|
57
58
|
|
|
58
59
|
## Differences from the spec
|
|
59
60
|
|
|
60
61
|
- **Vector storage**: `sqlite-vss` needs a native extension and is no longer maintained, so `vss_chunks` stores float32 BLOBs and cosine similarity is computed with numpy. No extension to install.
|
|
61
|
-
- **Embedding model**: the default is a built-in hashing embedder (identifier sub-words, bigrams, CJK character bigrams). It is fast and reproducible but **does not understand synonyms**. For real transformer embeddings, export `all-MiniLM-L6-v2` or `bge-small-en-v1.5` to ONNX, install `onnxruntime` and `tokenizers`, and set `INDEXER_ONNX_MODEL=<folder with model.onnx and tokenizer.json>` (
|
|
62
|
-
- **Call relations** for C# are resolved with limited type inference (using / namespaces, field and constructor-injected types, locals, interface to implementation), and every edge carries a confidence: `confirmed` (the receiver type is known), `probable` (reached through an interface or a single candidate) or `candidate` (name match only). There is no Roslyn: no overload resolution by argument type, no delegates / lambdas / extension methods, and call chains are followed one level. Inheritance edges come from the AST and are reliable.
|
|
62
|
+
- **Embedding model**: the default is a built-in hashing embedder (identifier sub-words, bigrams, CJK character bigrams). It is fast and reproducible but **does not understand synonyms**. For real transformer embeddings, export `all-MiniLM-L6-v2` or `bge-small-en-v1.5` to ONNX, install `onnxruntime` and `tokenizers`, and set `INDEXER_ONNX_MODEL=<folder with model.onnx and tokenizer.json>` (mean pooling suits MiniLM, bge models recommend CLS pooling). Switching embedders triggers a full re-index. Measured (0.4.0): `all-MiniLM-L6-v2` raises benchmark MRR by 0.08-0.13, but on a real 30k-chunk C# / Chinese-comment codebase it scored lower than hashing on paraphrased queries (MRR 0.29 vs 0.48; multilingual MiniLM-L12: 0.41) while a full index took 35-43 minutes instead of 2. Hashing stays the default; for domain jargon, `.ai_context/synonyms.json` helps more than a general model.
|
|
63
|
+
- **Call relations** for C# are resolved with limited type inference (using / namespaces, field and constructor-injected types, `Lazy<T>.Value`, locals, `foreach (var x in items.Where(..))` element types, interface to implementation), and every edge carries a confidence: `confirmed` (the receiver type is known), `probable` (reached through an interface or a single candidate) or `candidate` (name match only). There is no Roslyn: no overload resolution by argument type, no delegates / lambdas / extension methods, and call chains are followed one level. Inheritance edges come from the AST and are reliable.
|
|
63
64
|
- Extra schema additions: `symbols.qualified_name`, `chunk_metadata.symbol_id`, and the `raw_refs`, `chunks_fts` and `meta` tables.
|
|
64
65
|
|
|
65
66
|
## Data access (SQL)
|
|
66
67
|
|
|
67
|
-
`data-access <table-or-procedure>` answers "what writes / reads / executes X". It is built from T-SQL (INSERT / UPDATE / DELETE / MERGE / TRUNCATE / SELECT INTO / FROM / JOIN / EXEC, with alias resolution; CTEs, temp tables and system objects excluded), from C# SQL strings (literals, `+`, interpolation, `string.Format`, consts, locals) passed to Dapper, `SqlCommand` or EF `FromSql`, from stored-procedure names used with `CommandType.StoredProcedure`, and from EF `ToTable` / `[Table]` mappings. A procedure's callers are indirect writers of the tables it writes (followed up to 4 hops). Each entry has a confidence; **dynamic SQL (`EXEC(@sql)`, `sp_executesql`, SQL built from unknown values) cannot be resolved and is listed separately as `uncertain`**, never mixed into the confirmed lists. Known gaps: `FROM a JOIN b ON ..., c` loses `c`, and a stored-procedure name passed to a non-database method is not seen.
|
|
68
|
+
`data-access <table-or-procedure>` answers "what writes / reads / executes X". It is built from T-SQL (INSERT / UPDATE / DELETE / MERGE / TRUNCATE / SELECT INTO / FROM / JOIN / EXEC, with alias resolution; CTEs, temp tables and system objects excluded), from C# SQL strings (literals, `+`, interpolation, `string.Format`, consts, locals, `StringBuilder.Append` / `AppendLine` / `AppendFormat`) passed to Dapper, `SqlCommand` or EF `FromSql`, from stored-procedure names used with `CommandType.StoredProcedure`, from EF LINQ on `DbSet<T>` members (`ctx.Orders.Where(..)` / `.Add(..)` / `.Remove(..)`, `from o in ctx.Orders`; `probable`, since only the member name is matched) and from EF `ToTable` / `[Table]` mappings. A procedure's callers are indirect writers of the tables it writes (followed up to 4 hops). `programs` (USED BY PROGRAMS) follows confirmed / probable C# calls upward from those accessors to `*Controller` methods (up to 8 hops) (including from an implementation to the callers of the interface method it implements, for `foreach (var step in steps) step.Run()` pipelines) and groups them per controller file, with the Razor pages (`.cshtml`) whose `Url.Action("Action"[, "Controller"])` or AngularJS `ControllerPath + 'Action'` (controller from `$scope.Controller = 'X'`) targets those actions, so a table maps to the screens that touch it. A method that reads a DbSet and calls `SaveChanges` without an explicit `Add` / `Remove` may update tracked entities; it is listed as a possible (`uncertain`) writer. Each entry has a confidence; **dynamic SQL (`EXEC(@sql)`, `sp_executesql`, SQL built from unknown values) cannot be resolved and is listed separately as `uncertain`**, never mixed into the confirmed lists. EF accesses are `confirmed` when the context variable (`using (var db = new X())`, a field or property, or `this`) is typed as a class that declares or inherits the DbSet, `probable` otherwise. Methods on the way up that have no confirmed / probable caller at all are listed under NO KNOWN CALLER: entry points such as API endpoints, jobs or `Main`, or calls the graph could not resolve. Known gaps: `FROM a JOIN b ON ..., c` loses `c`, and a stored-procedure name passed to a non-database method is not seen.
|
|
69
|
+
|
|
70
|
+
Stored procedures that live only in the database can be exported to a folder outside the repo and listed in `.ai_context/extra_roots` (one folder per line, absolute or relative to the root); their files are indexed under their absolute paths.
|
|
68
71
|
|
|
69
72
|
Natural-language search routes questions such as "who modifies MES_ScrapRecord" or "哪些程式會寫入 MES_Lot" to this index first.
|
|
70
73
|
|
|
@@ -72,9 +75,13 @@ Natural-language search routes questions such as "who modifies MES_ScrapRecord"
|
|
|
72
75
|
|
|
73
76
|
Queries are expanded with a small synonym dictionary (`SP` / `預存程序` / `stored procedure` / `usp`, table, lot, scrap, ...; `local_codebase_indexer/synonyms.py`). Add or disable groups per project in `.ai_context/synonyms.json`: `{"groups": [["wpnlot", "在製批"]], "disable": ["sp"]}`. This helps abbreviations and Chinese/English terms, not free paraphrase.
|
|
74
77
|
|
|
78
|
+
The index also mines its own dictionary: Chinese bigrams in the comments right above a symbol are paired with the sub-words of its name (`/// 收帳` above `ReceiveLotAsync` gives 收帳 = receive). A pair is kept when at least 5 symbols support it, it covers at least 15% of the symbols commented with the bigram (smoothed) and the word is at least 15x likelier there than overall. On a 30k-chunk C# codebase this yields about 350 pairs (收帳 -> receive, 拆批 -> divide, 油墨 -> ink, 底片 -> film) and raised MRR on paraphrased queries from 0.57 to 0.64.
|
|
79
|
+
|
|
75
80
|
## Index health
|
|
76
81
|
|
|
77
|
-
`status` (also the MCP tool `codebase_index_status`) reports whether the index can be trusted without refreshing it: `fresh`, `stale` (files changed or git HEAD moved since the last update), `degraded` (failed files or an inconsistent database) or `not_indexed`. A file that fails to parse is removed from the index, listed with its error, and retried on every update, so search never returns stale lines for it. `index --force` rebuilds everything.
|
|
82
|
+
`status` (also the MCP tool `codebase_index_status`) reports whether the index can be trusted without refreshing it: `fresh`, `stale` (files changed or git HEAD moved since the last update), `degraded` (failed files or an inconsistent database) or `not_indexed`. A file that fails to parse is removed from the index, listed with its error, and retried on every update, so search never returns stale lines for it. `index --force` rebuilds everything. Status also shows the running version and warns when the package's code changed on disk after the process started (restart the MCP server, i.e. open a new Claude Code session, to run it).
|
|
83
|
+
|
|
84
|
+
Speed (2.3k files, 30k chunks, hashing embedder): full build about 36 s into an empty database, a branch switch that rewrites 400 files about 10 s, a no-op check about 1 s. Each file is written inside a savepoint (atomic), and commits are batched every 500 files.
|
|
78
85
|
|
|
79
86
|
## Benchmark
|
|
80
87
|
|
|
@@ -22,7 +22,8 @@ local-codebase-indexer --root <项目路径> index # 建立
|
|
|
22
22
|
local-codebase-indexer search "database mapping for LotNo" --limit 5
|
|
23
23
|
local-codebase-indexer relations IExistOpenHandleService --direction both # upstream | downstream | both
|
|
24
24
|
local-codebase-indexer context Services/LotService.cs --lines 120 --padding 15 # 别名:slice
|
|
25
|
-
local-codebase-indexer data-access MES_Lot # 谁读 / 写 /
|
|
25
|
+
local-codebase-indexer data-access MES_Lot # 谁读 / 写 / 执行某数据表或存储过程;存储过程碰了哪些数据(--full 列出全部)
|
|
26
|
+
local-codebase-indexer impact main...HEAD # 一次变更动到的符号、数据表、程序与页面(不给参数=未提交的变更)
|
|
26
27
|
local-codebase-indexer stats
|
|
27
28
|
local-codebase-indexer status # 索引是否新鲜、失败文件、git commit、一致性检查
|
|
28
29
|
```
|
|
@@ -39,7 +40,7 @@ claude mcp add local-indexer -- local-codebase-indexer --root /path/to/project s
|
|
|
39
40
|
# 不安装直接运行:claude mcp add local-indexer -- uvx local-codebase-indexer --root /path/to/project serve
|
|
40
41
|
```
|
|
41
42
|
|
|
42
|
-
`serve` 通过 stdio 提供 JSON-RPC(MCP
|
|
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` 才附依赖文件。
|
|
43
44
|
|
|
44
45
|
## 三层索引
|
|
45
46
|
|
|
@@ -49,18 +50,20 @@ claude mcp add local-indexer -- local-codebase-indexer --root /path/to/project s
|
|
|
49
50
|
| Topology | `using` / `import` 解析为文件依赖;继承(base list);类型使用(`invocation`)。存放在 `dependencies` 表 |
|
|
50
51
|
| Semantic | 代码块嵌入 384 维,存入 `vss_chunks`;查询时用 FTS5 关键字、符号名称、向量三路做 Reciprocal Rank Fusion,再展开前 3 名文件的依赖邻居 |
|
|
51
52
|
|
|
52
|
-
编码:先尝试 UTF-8,再尝试 Big5、cp1252。单个文件超过 5MB 不索引;遵守根目录与子目录的 `.gitignore`;固定跳过 `.git`、`bin`、`obj`、`node_modules`
|
|
53
|
+
编码:先尝试 UTF-8,再尝试 Big5、cp1252。单个文件超过 5MB 不索引;遵守根目录与子目录的 `.gitignore`;固定跳过 `.git`、`bin`、`obj`、`node_modules` 等。`*.min.js` / `*.min.css` 也跳过。已提交进仓库的第三方或生成的代码可用 `.ai_context/ignore`(gitignore 语法)排除,例如 `Scripts/*`、`!Scripts/Custom/`、`Web References/`(EF database-first 生成的 model 不要排除,DbSet 声明在它的 DbContext 里)。
|
|
53
54
|
|
|
54
55
|
## 与规格的差异
|
|
55
56
|
|
|
56
57
|
- **向量存储**:规格中的 `sqlite-vss` 需要原生扩展且已停止维护,这里 `vss_chunks` 改为存 float32 BLOB,用 numpy 暴力计算 cosine,不需要额外安装扩展。
|
|
57
|
-
- **嵌入模型**:默认是内置的 hashing 嵌入(标识符拆词、双词组、中文双字),快速、可复现,但**不理解同义词**。要使用真正的 transformer,把 `all-MiniLM-L6-v2` 或 `bge-small-en-v1.5` 导出为 ONNX,安装 `onnxruntime`、`tokenizers`,并设置 `INDEXER_ONNX_MODEL=<包含 model.onnx 与 tokenizer.json
|
|
58
|
-
- **C# 调用关系**以有限度的类型推断解析(using / namespace
|
|
58
|
+
- **嵌入模型**:默认是内置的 hashing 嵌入(标识符拆词、双词组、中文双字),快速、可复现,但**不理解同义词**。要使用真正的 transformer,把 `all-MiniLM-L6-v2` 或 `bge-small-en-v1.5` 导出为 ONNX,安装 `onnxruntime`、`tokenizers`,并设置 `INDEXER_ONNX_MODEL=<包含 model.onnx 与 tokenizer.json 的文件夹>`(目前使用平均池化,适合 MiniLM,bge 系列建议使用 CLS 池化)。切换嵌入后会自动重建索引。实测(0.4.0):`all-MiniLM-L6-v2` 让 benchmark MRR 提高 0.08–0.13,但在真实的 3 万 chunk C# / 中文注释项目上,换个说法的查询反而比 hashing 差(MRR 0.29 对 0.48;多语 MiniLM-L12 为 0.41),完整建索引从 2 分钟变成 35–43 分钟。因此默认维持 hashing;领域术语用 `.ai_context/synonyms.json` 比通用模型有效。
|
|
59
|
+
- **C# 调用关系**以有限度的类型推断解析(using / namespace、字段与构造函数注入的类型、`Lazy<T>.Value`、局部变量、`foreach (var x in items.Where(..))` 的元素类型、接口对应实现),每条关系都标置信等级:`confirmed`(接收者类型已知)、`probable`(经由接口或唯一候选)、`candidate`(仅名称相符)。没有 Roslyn,所以不做按参数类型的重载解析、不处理委托 / lambda / 扩展方法,调用链只追一层。继承关系来自 AST,可靠。
|
|
59
60
|
- 额外增加了 `symbols.qualified_name`、`chunk_metadata.symbol_id`、`raw_refs`、`chunks_fts` 与 `meta` 表。
|
|
60
61
|
|
|
61
62
|
## 数据访问(SQL)
|
|
62
63
|
|
|
63
|
-
`data-access <数据表或存储过程>` 回答“谁写入 / 读取 / 执行 X”。数据来源:T-SQL(INSERT / UPDATE / DELETE / MERGE / TRUNCATE / SELECT INTO / FROM / JOIN / EXEC,含别名解析,排除 CTE、临时表、系统对象)、C# 的 SQL 字符串(字面值、`+`、字符串插值、`string.Format
|
|
64
|
+
`data-access <数据表或存储过程>` 回答“谁写入 / 读取 / 执行 X”。数据来源:T-SQL(INSERT / UPDATE / DELETE / MERGE / TRUNCATE / SELECT INTO / FROM / JOIN / EXEC,含别名解析,排除 CTE、临时表、系统对象)、C# 的 SQL 字符串(字面值、`+`、字符串插值、`string.Format`、常量、局部变量、`StringBuilder.Append` / `AppendLine` / `AppendFormat`)经 Dapper、`SqlCommand` 或 EF `FromSql` 发出、配合 `CommandType.StoredProcedure` 的存储过程名称、对 `DbSet<T>` 成员的 EF LINQ(`ctx.Orders.Where(..)` / `.Add(..)` / `.Remove(..)`、`from o in ctx.Orders`;只比对成员名称,所以是 `probable`),以及 EF 的 `ToTable` / `[Table]` 映射。调用某存储过程的代码视为该过程所写数据表的间接写入者(最多追 4 层)。`programs`(USED BY PROGRAMS)沿 confirmed / probable 的 C# 调用往上追到 `*Controller` 方法(最多 8 层),(实现方法也会接到它所实现接口方法的调用者,涵盖 `foreach (var step in steps) step.Run()` 这种管线),按 controller 文件分组,并列出 `Url.Action("Action"[, "Controller"])` 或 AngularJS `ControllerPath + 'Action'`(controller 取自 `$scope.Controller = 'X'`)指向这些 action 的 Razor 页面(`.cshtml`),查一张表就知道哪些画面会动到它。方法读了某 DbSet 又调用 `SaveChanges`、但没有明确 `Add` / `Remove` 时,可能是在更新跟踪中的实体,列为可能(`uncertain`)写入者。每条都有置信等级;**动态 SQL(`EXEC(@sql)`、`sp_executesql`、由未知值组成的 SQL)无法解析,会单独列为 `uncertain`**,不会混进确定的清单。EF 访问在 context 变量(`using (var db = new X())`、字段或属性、`this`)的类型是声明或继承该 DbSet 的类时为 `confirmed`,否则 `probable`。往上追时没有任何 confirmed / probable 调用者的方法列在 NO KNOWN CALLER:可能是 API、计划任务、`Main` 等入口,或是调用图解不出的调用。已知缺口:`FROM a JOIN b ON ..., c` 会漏掉 `c`;把存储过程名称传给非数据库方法时看不到。
|
|
65
|
+
|
|
66
|
+
只存在数据库里的存储过程,可导出到仓库外的文件夹,再写进 `.ai_context/extra_roots`(一行一个文件夹,绝对路径或相对于项目根目录);这些文件以绝对路径索引。
|
|
64
67
|
|
|
65
68
|
自然语言搜索遇到“谁修改 MES_ScrapRecord”“哪些程序会写入 MES_Lot”这类问题,会先走这个索引。
|
|
66
69
|
|
|
@@ -68,9 +71,13 @@ claude mcp add local-indexer -- local-codebase-indexer --root /path/to/project s
|
|
|
68
71
|
|
|
69
72
|
查询会用小型同义词字典扩展(`SP` / `预存程序` / `stored procedure` / `usp`、数据表、批号、报废等;见 `local_codebase_indexer/synonyms.py`)。可在 `.ai_context/synonyms.json` 为项目新增或停用分组:`{"groups": [["wpnlot", "在制批"]], "disable": ["sp"]}`。这对缩写与中英对照有帮助,对自由改写的同义说法没用。
|
|
70
73
|
|
|
74
|
+
索引也会自动挖项目自己的词典:符号正上方注释里的中文双字词,配对符号名称的英文子词(`ReceiveLotAsync` 上面写 `/// 收帳` → 收帳 = receive)。至少 5 个符号支持、在带有该词注释的符号中占 15% 以上(有平滑)、且该英文词在那里出现的概率是整体的 15 倍以上才保留。在 3 万 chunk 的 C# 项目上约得到 350 组(收帳→receive、拆批→divide、油墨→ink、底片→film),换个说法的查询 MRR 由 0.57 提升到 0.64。
|
|
75
|
+
|
|
71
76
|
## 索引健康状态
|
|
72
77
|
|
|
73
|
-
`status`(也是 MCP 工具 `codebase_index_status`)不更新索引,只报告索引是否可信:`fresh`(新鲜)、`stale`(文件有变更或 git HEAD 已移动)、`degraded`(有解析失败的文件或数据库不一致)、`not_indexed`(尚未建立)。解析失败的文件会从索引移除、连同错误原因列出,并在每次更新时重试,所以搜索不会返回它的过期内容。`index --force` 可全部重建。
|
|
78
|
+
`status`(也是 MCP 工具 `codebase_index_status`)不更新索引,只报告索引是否可信:`fresh`(新鲜)、`stale`(文件有变更或 git HEAD 已移动)、`degraded`(有解析失败的文件或数据库不一致)、`not_indexed`(尚未建立)。解析失败的文件会从索引移除、连同错误原因列出,并在每次更新时重试,所以搜索不会返回它的过期内容。`index --force` 可全部重建。status 也会显示运行中的版本;包的代码在进程启动后有改动时会提示重启 MCP server(也就是开新的 Claude Code session)。
|
|
79
|
+
|
|
80
|
+
速度(2.3k 文件、3 万 chunk、hashing 嵌入):空数据库全量约 36 秒,切分支改写 400 个文件约 10 秒,无变动检查约 1 秒。每个文件在 savepoint 内写入(不可分割),每 500 个文件 commit 一次。
|
|
74
81
|
|
|
75
82
|
## 基准测试
|
|
76
83
|
|
|
@@ -22,7 +22,8 @@ local-codebase-indexer --root <專案路徑> index # 建立
|
|
|
22
22
|
local-codebase-indexer search "database mapping for LotNo" --limit 5
|
|
23
23
|
local-codebase-indexer relations IExistOpenHandleService --direction both # upstream | downstream | both
|
|
24
24
|
local-codebase-indexer context Services/LotService.cs --lines 120 --padding 15 # 別名:slice
|
|
25
|
-
local-codebase-indexer data-access MES_Lot # 誰讀 / 寫 /
|
|
25
|
+
local-codebase-indexer data-access MES_Lot # 誰讀 / 寫 / 執行某資料表或預存程序;預存程序碰了哪些資料(--full 列出全部)
|
|
26
|
+
local-codebase-indexer impact main...HEAD # 一次變更動到的符號、資料表、程式與頁面(不給參數=未提交的變更)
|
|
26
27
|
local-codebase-indexer stats
|
|
27
28
|
local-codebase-indexer status # 索引是否新鮮、失敗檔案、git commit、一致性檢查
|
|
28
29
|
```
|
|
@@ -39,7 +40,7 @@ claude mcp add local-indexer -- local-codebase-indexer --root /path/to/project s
|
|
|
39
40
|
# 不安裝直接跑:claude mcp add local-indexer -- uvx local-codebase-indexer --root /path/to/project serve
|
|
40
41
|
```
|
|
41
42
|
|
|
42
|
-
`serve` 以 stdio 提供 JSON-RPC(MCP
|
|
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` 才附相依檔案。
|
|
43
44
|
|
|
44
45
|
## 三層索引
|
|
45
46
|
|
|
@@ -49,18 +50,20 @@ claude mcp add local-indexer -- local-codebase-indexer --root /path/to/project s
|
|
|
49
50
|
| Topology | `using` / `import` 解析成檔案相依;繼承(base list);型別使用(`invocation`)。存在 `dependencies` 表 |
|
|
50
51
|
| Semantic | 區塊嵌入 384 維,存 `vss_chunks`;查詢時以 FTS5 關鍵字、符號名稱、向量三路做 Reciprocal Rank Fusion,再展開前 3 名檔案的相依鄰居 |
|
|
51
52
|
|
|
52
|
-
編碼:先試 UTF-8,再試 Big5、cp1252。單檔超過 5MB 不索引;遵守根目錄與子目錄的 `.gitignore`;固定略過 `.git`、`bin`、`obj`、`node_modules`
|
|
53
|
+
編碼:先試 UTF-8,再試 Big5、cp1252。單檔超過 5MB 不索引;遵守根目錄與子目錄的 `.gitignore`;固定略過 `.git`、`bin`、`obj`、`node_modules` 等。`*.min.js` / `*.min.css` 也略過。已 commit 進 repo 的第三方或產生的程式可用 `.ai_context/ignore`(gitignore 語法)排除,例如 `Scripts/*`、`!Scripts/Custom/`、`Web References/`(EF database-first 產生的 model 不要排除,DbSet 宣告在它的 DbContext 裡)。
|
|
53
54
|
|
|
54
55
|
## 與規格的差異
|
|
55
56
|
|
|
56
57
|
- **向量儲存**:規格的 `sqlite-vss` 需要原生擴充且已停止維護,這裡 `vss_chunks` 改存 float32 BLOB,用 numpy 暴力計算 cosine,不需要額外安裝擴充。
|
|
57
|
-
- **嵌入模型**:預設是內建的 hashing 嵌入(識別字拆詞、雙詞組、中文雙字),快速、可重現,但**不理解同義詞**。要用真正的 transformer,匯出 `all-MiniLM-L6-v2` 或 `bge-small-en-v1.5` 為 ONNX,裝 `onnxruntime`、`tokenizers`,並設 `INDEXER_ONNX_MODEL=<含 model.onnx 與 tokenizer.json
|
|
58
|
-
- **C# 呼叫關係**以有限度的型別推斷解析(using / namespace
|
|
58
|
+
- **嵌入模型**:預設是內建的 hashing 嵌入(識別字拆詞、雙詞組、中文雙字),快速、可重現,但**不理解同義詞**。要用真正的 transformer,匯出 `all-MiniLM-L6-v2` 或 `bge-small-en-v1.5` 為 ONNX,裝 `onnxruntime`、`tokenizers`,並設 `INDEXER_ONNX_MODEL=<含 model.onnx 與 tokenizer.json 的資料夾>`(目前用平均池化,適合 MiniLM,bge 系列建議用 CLS 池化)。切換嵌入後會自動重建索引。實測(0.4.0):`all-MiniLM-L6-v2` 讓 benchmark MRR 提高 0.08–0.13,但在真實的 3 萬 chunk C# / 中文註解專案上,換句話說的查詢反而比 hashing 差(MRR 0.29 對 0.48;多語 MiniLM-L12 為 0.41),完整建索引從 2 分鐘變成 35–43 分鐘。因此預設維持 hashing;領域行話用 `.ai_context/synonyms.json` 比通用模型有效。
|
|
59
|
+
- **C# 呼叫關係**以有限度的型別推斷解析(using / namespace、欄位與建構式注入的型別、`Lazy<T>.Value`、區域變數、`foreach (var x in items.Where(..))` 的元素型別、介面對應實作),每條關係都標信心等級:`confirmed`(接收者型別已知)、`probable`(經由介面或唯一候選)、`candidate`(僅名稱相符)。沒有 Roslyn,所以不做依引數型別的多載解析、不處理委派 / lambda / 擴充方法,呼叫鏈只追一層。繼承關係來自 AST,可靠。
|
|
59
60
|
- 額外加了 `symbols.qualified_name`、`chunk_metadata.symbol_id`、`raw_refs`、`chunks_fts` 與 `meta` 表。
|
|
60
61
|
|
|
61
62
|
## 資料存取(SQL)
|
|
62
63
|
|
|
63
|
-
`data-access <資料表或預存程序>` 回答「誰寫入 / 讀取 / 執行 X」。資料來源:T-SQL(INSERT / UPDATE / DELETE / MERGE / TRUNCATE / SELECT INTO / FROM / JOIN / EXEC,含別名解析,排除 CTE、暫存表、系統物件)、C# 的 SQL 字串(字面值、`+`、字串內插、`string.Format
|
|
64
|
+
`data-access <資料表或預存程序>` 回答「誰寫入 / 讀取 / 執行 X」。資料來源:T-SQL(INSERT / UPDATE / DELETE / MERGE / TRUNCATE / SELECT INTO / FROM / JOIN / EXEC,含別名解析,排除 CTE、暫存表、系統物件)、C# 的 SQL 字串(字面值、`+`、字串內插、`string.Format`、常數、區域變數、`StringBuilder.Append` / `AppendLine` / `AppendFormat`)經 Dapper、`SqlCommand` 或 EF `FromSql` 送出、搭配 `CommandType.StoredProcedure` 的 SP 名稱、對 `DbSet<T>` 成員的 EF LINQ(`ctx.Orders.Where(..)` / `.Add(..)` / `.Remove(..)`、`from o in ctx.Orders`;只比對成員名稱,所以是 `probable`),以及 EF 的 `ToTable` / `[Table]` 對應。呼叫某 SP 的程式視為該 SP 所寫資料表的間接寫入者(最多追 4 層)。`programs`(USED BY PROGRAMS)沿 confirmed / probable 的 C# 呼叫往上追到 `*Controller` 方法(最多 8 層),(實作方法也會接到它所實作介面方法的呼叫者,涵蓋 `foreach (var step in steps) step.Run()` 這種管線),依 controller 檔案分組,並列出 `Url.Action("Action"[, "Controller"])` 或 AngularJS `ControllerPath + 'Action'`(controller 取自 `$scope.Controller = 'X'`)指向這些 action 的 Razor 頁面(`.cshtml`),查一張表就知道哪些畫面會動到它。方法讀了某 DbSet 又呼叫 `SaveChanges`、但沒有明確 `Add` / `Remove` 時,可能是在更新追蹤中的實體,列為可能(`uncertain`)寫入者。每筆都有信心等級;**動態 SQL(`EXEC(@sql)`、`sp_executesql`、由未知值組成的 SQL)無法解析,會獨立列為 `uncertain`**,不會混進確定的清單。EF 存取在 context 變數(`using (var db = new X())`、欄位或屬性、`this`)的型別是宣告或繼承該 DbSet 的類別時為 `confirmed`,否則 `probable`。往上追時沒有任何 confirmed / probable 呼叫者的方法列在 NO KNOWN CALLER:可能是 API、排程、`Main` 等入口,或是呼叫圖解不出的呼叫。已知缺口:`FROM a JOIN b ON ..., c` 會漏掉 `c`;把 SP 名稱傳給非資料庫方法時看不到。
|
|
65
|
+
|
|
66
|
+
只存在資料庫裡的預存程序,可匯出到 repo 外的資料夾,再寫進 `.ai_context/extra_roots`(一行一個資料夾,絕對路徑或相對於專案根目錄);這些檔案以絕對路徑索引。
|
|
64
67
|
|
|
65
68
|
自然語言搜尋遇到「誰修改 MES_ScrapRecord」「哪些程式會寫入 MES_Lot」這類問題,會先走這個索引。
|
|
66
69
|
|
|
@@ -68,9 +71,13 @@ claude mcp add local-indexer -- local-codebase-indexer --root /path/to/project s
|
|
|
68
71
|
|
|
69
72
|
查詢會用小型同義詞字典擴展(`SP` / `預存程序` / `stored procedure` / `usp`、資料表、批號、報廢等;見 `local_codebase_indexer/synonyms.py`)。可在 `.ai_context/synonyms.json` 為專案新增或停用群組:`{"groups": [["wpnlot", "在製批"]], "disable": ["sp"]}`。這對縮寫與中英對照有幫助,對自由改寫的同義說法沒用。
|
|
70
73
|
|
|
74
|
+
索引也會自動挖專案自己的字典:符號正上方註解裡的中文雙字詞,配對符號名稱的英文子詞(`ReceiveLotAsync` 上面寫 `/// 收帳` → 收帳 = receive)。至少 5 個符號支持、在帶有該詞註解的符號中占 15% 以上(有平滑)、且該英文詞在那裡出現的機率是整體的 15 倍以上才保留。在 3 萬 chunk 的 C# 專案上約得到 350 組(收帳→receive、拆批→divide、油墨→ink、底片→film),換句話說的查詢 MRR 由 0.57 提升到 0.64。
|
|
75
|
+
|
|
71
76
|
## 索引健康狀態
|
|
72
77
|
|
|
73
|
-
`status`(也是 MCP 工具 `codebase_index_status`)不更新索引,只回報索引是否可信:`fresh`(新鮮)、`stale`(檔案有變更或 git HEAD 已移動)、`degraded`(有解析失敗的檔案或資料庫不一致)、`not_indexed`(尚未建立)。解析失敗的檔案會從索引移除、連同錯誤原因列出,並在每次更新時重試,所以搜尋不會回傳它的過期內容。`index --force` 可全部重建。
|
|
78
|
+
`status`(也是 MCP 工具 `codebase_index_status`)不更新索引,只回報索引是否可信:`fresh`(新鮮)、`stale`(檔案有變更或 git HEAD 已移動)、`degraded`(有解析失敗的檔案或資料庫不一致)、`not_indexed`(尚未建立)。解析失敗的檔案會從索引移除、連同錯誤原因列出,並在每次更新時重試,所以搜尋不會回傳它的過期內容。`index --force` 可全部重建。status 也會顯示執行中的版本;套件程式碼在程序啟動後有改動時會提示重開 MCP server(也就是開新的 Claude Code session)。
|
|
79
|
+
|
|
80
|
+
速度(2.3k 檔、3 萬 chunk、hashing 嵌入):空資料庫全量約 36 秒,切分支改寫 400 個檔約 10 秒,無變動檢查約 1 秒。每個檔案在 savepoint 內寫入(不可分割),每 500 個檔案 commit 一次。
|
|
74
81
|
|
|
75
82
|
## 基準測試
|
|
76
83
|
|
|
@@ -5,15 +5,15 @@ Priorities come from the benchmark (`benchmarks/run_benchmark.py`, baseline in `
|
|
|
5
5
|
## Next
|
|
6
6
|
|
|
7
7
|
0. **Publish to the MCP registry** (not done yet). PyPI 0.3.0 is out and carries the `mcp-name` marker; `server.json` is ready. Run `mcp-publisher login github` then `mcp-publisher publish` from the repo folder, then verify with `curl "https://registry.modelcontextprotocol.io/v0.1/servers?search=local-codebase-indexer"`. Repeat after each release (bump both versions in `server.json`).
|
|
8
|
-
1. **
|
|
9
|
-
|
|
10
|
-
2. **Resolve `FROM a JOIN b ON ..., c`** (a comma list after a JOIN loses `c`), non-sink SQL proc-name literals (`Run("usp_X")`), and EF query tracing (only the table mapping is recorded now).
|
|
11
|
-
3. **C# call graph gaps**: overload resolution by argument type, delegates / lambdas / extension methods, call chains longer than one level. Without Roslyn these stay approximate; edges carry `confirmed` / `probable` / `candidate`.
|
|
8
|
+
1. **Resolve `FROM a JOIN b ON ..., c`** (a comma list after a JOIN loses `c`), non-sink SQL proc-name literals (`Run("usp_X")`), EF `this.ToTable(..)` inside `EntityTypeConfiguration<T>` (entity not taken from the base class yet), and EF updates through tracked entities when the entity was loaded in another method than the one calling `SaveChanges` (only same-method read + `SaveChanges` is listed, as uncertain).
|
|
9
|
+
2. **C# call graph gaps**: overload resolution by argument type, delegates / lambdas / extension methods, call chains longer than one level. Without Roslyn these stay approximate; edges carry `confirmed` / `probable` / `candidate`.
|
|
12
10
|
|
|
13
11
|
## Deferred (not worth doing yet)
|
|
14
12
|
|
|
15
13
|
| Item | Why deferred | Revisit when |
|
|
16
14
|
|---|---|---|
|
|
15
|
+
| Real embedding model as default | Measured 0.4.0 on a real 30k-chunk C# codebase with Chinese comments, 12 paraphrased queries (6 zh, 6 en): hashing MRR 0.48 / hit@5 6, `all-MiniLM-L6-v2` 0.29 / 6, `paraphrase-multilingual-MiniLM-L12-v2` (int8) 0.41 / 6; full index 128 s vs 35 / 43 min. Benchmark: MiniLM +0.08-0.13 MRR, multilingual -0.01..+0.03. Domain jargon ("split a lot into two") was missed by all three | A model trained on code + Chinese, or embedding becomes incremental enough that branch switches stay under a minute |
|
|
16
|
+
| Content-hash cache of parse results across branch switches | Measured: a switch that rewrites 400 files re-indexes in about 10 s; parsing is about 40% of that, so a cache would save a few seconds at the cost of a large table | Branch switches routinely rewrite thousands of files |
|
|
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 |
|
|
@@ -23,6 +23,10 @@ Priorities come from the benchmark (`benchmarks/run_benchmark.py`, baseline in `
|
|
|
23
23
|
|
|
24
24
|
## Done
|
|
25
25
|
|
|
26
|
+
- 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
|
+
- 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
|
|
29
|
+
|
|
26
30
|
- SQL / data-access relations: `data_access` table and tool (`data-access` CLI, `codebase_get_data_access` MCP); T-SQL read / write / exec, C# SQL strings and Dapper / SqlCommand / EF sinks, EF table mappings, indirect writers through procedures, dynamic SQL reported as `uncertain`; search routes "who writes / reads / calls X" to it. Benchmark `sql_dataflow` Recall@5 0.72 -> 1.00, new `data_access` queries 0.67 -> 1.00
|
|
27
31
|
- C# symbol-level calls: using / field / constructor-injection / local type inference, interface dispatch, confidence levels. `relations Save` no longer shares one reference list across four unrelated methods
|
|
28
32
|
- Domain-term query expansion (`local_codebase_indexer/synonyms.py`, extendable with `.ai_context/synonyms.json`); `abbreviation` Recall@5 0.67 -> 1.00, `cross_lingual` 0.50 -> 1.00 (small, author-written sets: optimistic). ONNX pooling / query-prefix options
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"""Command line interface: ``
|
|
1
|
+
"""Command line interface: ``local-codebase-indexer <tool_name> --params`` (index.md section 4)."""
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
@@ -33,6 +33,7 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
33
33
|
s.add_argument("query", nargs="?")
|
|
34
34
|
s.add_argument("--query", dest="query_opt")
|
|
35
35
|
s.add_argument("--limit", type=int, default=5)
|
|
36
|
+
s.add_argument("--related", action="store_true", help="also list dependency-graph neighbours of the top hits")
|
|
36
37
|
|
|
37
38
|
s = sub.add_parser("relations", aliases=["codebase_get_symbol_relations"], help="symbol dependency graph")
|
|
38
39
|
s.add_argument("symbol", nargs="?")
|
|
@@ -51,6 +52,12 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
51
52
|
help="who reads / writes / executes a table or stored procedure, and what a procedure touches")
|
|
52
53
|
s.add_argument("object", nargs="?")
|
|
53
54
|
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")
|
|
56
|
+
|
|
57
|
+
s = sub.add_parser("impact", aliases=["codebase_impact_analysis"],
|
|
58
|
+
help="symbols, tables, programs and pages touched by a git diff")
|
|
59
|
+
s.add_argument("base", nargs="?", help="git revision or range (default: uncommitted work against HEAD)")
|
|
60
|
+
s.add_argument("--full", action="store_true", help="list every changed symbol")
|
|
54
61
|
|
|
55
62
|
sub.add_parser("stats", help="show index statistics")
|
|
56
63
|
sub.add_parser("status", aliases=["codebase_index_status"], help="index health: freshness, failures, consistency")
|
|
@@ -59,14 +66,14 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
59
66
|
|
|
60
67
|
|
|
61
68
|
def _fix_stdio(serving: bool) -> None:
|
|
62
|
-
"""MCP
|
|
63
|
-
keep its encoding but never crash on a character it cannot show."""
|
|
69
|
+
"""MCP and piped output (an AI assistant calling the CLI) are UTF-8; the Windows locale codec (cp950, cp1252)
|
|
70
|
+
would garble Chinese. On a console, keep its encoding but never crash on a character it cannot show."""
|
|
64
71
|
for name in ("stdin", "stdout", "stderr"):
|
|
65
72
|
stream = getattr(sys, name, None)
|
|
66
73
|
if stream is None or not hasattr(stream, "reconfigure"):
|
|
67
74
|
continue
|
|
68
75
|
try:
|
|
69
|
-
if serving:
|
|
76
|
+
if serving or (name != "stdin" and not stream.isatty()):
|
|
70
77
|
stream.reconfigure(encoding="utf-8", errors="replace")
|
|
71
78
|
elif name != "stdin":
|
|
72
79
|
stream.reconfigure(errors="replace")
|
|
@@ -83,7 +90,8 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
83
90
|
from .mcp_server import serve
|
|
84
91
|
return serve(root)
|
|
85
92
|
|
|
86
|
-
from .query import render_context, render_data_access, render_relations, render_search,
|
|
93
|
+
from .query import (render_context, render_data_access, render_impact, render_relations, render_search,
|
|
94
|
+
render_status)
|
|
87
95
|
|
|
88
96
|
try:
|
|
89
97
|
t = _tools(root)
|
|
@@ -99,7 +107,7 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
99
107
|
if not q:
|
|
100
108
|
print("error: a query is required", file=sys.stderr)
|
|
101
109
|
return 2
|
|
102
|
-
res = t.semantic_search(q, args.limit)
|
|
110
|
+
res = t.semantic_search(q, args.limit, args.related)
|
|
103
111
|
_emit(res, render_search(res), args.json)
|
|
104
112
|
elif args.cmd in ("relations", "codebase_get_symbol_relations"):
|
|
105
113
|
sym = args.symbol_opt or args.symbol
|
|
@@ -121,7 +129,10 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
121
129
|
print("error: an object name is required", file=sys.stderr)
|
|
122
130
|
return 2
|
|
123
131
|
res = t.data_access(name)
|
|
124
|
-
_emit(res, render_data_access(res), args.json)
|
|
132
|
+
_emit(res, render_data_access(res, args.full), args.json)
|
|
133
|
+
elif args.cmd in ("impact", "codebase_impact_analysis"):
|
|
134
|
+
res = t.impact(args.base)
|
|
135
|
+
_emit(res, render_impact(res, args.full), args.json)
|
|
125
136
|
elif args.cmd in ("status", "codebase_index_status"):
|
|
126
137
|
res = t.index_status()
|
|
127
138
|
_emit(res, render_status(res), args.json)
|