dsh-plugin-codegraph 0.4.1 → 0.5.0
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.
- package/README.md +75 -3
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -74,13 +74,84 @@ A plugin can wrap `@colbymchenry/codegraph`'s own CLI instead of reimplementing
|
|
|
74
74
|
|
|
75
75
|
- **No second thing to install.** Shelling out to a CLI means the host needs that binary on `PATH`, at a version the plugin was actually tested against — an extra install step, and an extra way for the two to drift out of sync. `npm install` is the whole story here; the indexer and store run in-process.
|
|
76
76
|
- **Fewer tools, not more.** Every tool's schema rides along in the system prompt on every turn, whether or not it gets called that turn. Ten single-purpose tools (one per CLI subcommand) cost more of that budget, every turn, than the two this plugin exposes — `codegraph`'s `operation` field is a dispatch, not a compromise.
|
|
77
|
-
- **
|
|
77
|
+
- **The parse cache is incremental; the edges are not.** "Sync only the changed files" sounds obviously faster, but the rule this graph resolves calls by — one unique name wins workspace-wide — is global: adding a symbol in file A that collides with one already indexed from file B should invalidate edges that point at B, even though B never changed. A parser that reparses only the touched files *and patches in their own new edges* has no way to notice that. So this plugin splits the two: each file's extraction is cached and reused (**991 ms → 45 ms** on a 337-file workspace), while edges are rebuilt over the whole graph on every run. Reparsing everything was the wrong thing to save; re-resolving everything is cheap.
|
|
78
78
|
|
|
79
79
|
## Language coverage
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
Eighteen languages, all bundled — no per-language setup, and grammars load lazily, so a Go-only workspace never pays for the Python one.
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
| Language | Extensions | Language | Extensions |
|
|
84
|
+
|---|---|---|---|
|
|
85
|
+
| TypeScript | `.ts` `.mts` `.cts` | C | `.c` `.h` |
|
|
86
|
+
| TSX | `.tsx` | C++ | `.cpp` `.cc` `.cxx` `.hpp` `.hh` `.hxx` |
|
|
87
|
+
| JavaScript | `.js` `.mjs` `.cjs` | C# | `.cs` |
|
|
88
|
+
| JSX | `.jsx` | PHP | `.php` |
|
|
89
|
+
| Python | `.py` `.pyi` | Rust | `.rs` |
|
|
90
|
+
| Go | `.go` | Ruby | `.rb` |
|
|
91
|
+
| Java | `.java` | Zig | `.zig` |
|
|
92
|
+
| Kotlin | `.kt` `.kts` | Swift | `.swift` |
|
|
93
|
+
| Dart | `.dart` | Scala | `.scala` `.sc` |
|
|
94
|
+
|
|
95
|
+
The **store is format-bound, not language-bound**: a graph the `codegraph` CLI built over languages this indexer does not parse stays fully queryable. For anything outside the table above, index with the CLI and query through this plugin.
|
|
96
|
+
|
|
97
|
+
## Auto-indexing
|
|
98
|
+
|
|
99
|
+
Three things keep the graph current without you asking:
|
|
100
|
+
|
|
101
|
+
- **A new session starts with an index.** Open a session in a workspace that has never been indexed and the plugin starts a background build for it — the first structural question already has a graph. A workspace that already has one is left to the watcher.
|
|
102
|
+
- **Watching is on by default.** Every in-scope directory is watched through the host's filesystem seam, and a debounced change triggers a rebuild. An empty change set schedules nothing, so the plugin's own `.codegraph` writes never loop.
|
|
103
|
+
- **Re-indexing parses only what changed.** Each run persists its per-file extraction; the next one confirms each file by mtime+size (or a SHA-256, under `cacheVerify: 'hash'`) and reuses it. Measured on a 337-file workspace: **991 ms for the first run, 45 ms for every run after** — and a watch rebuild after one edit costs about the same as reusing everything else.
|
|
104
|
+
|
|
105
|
+
Two more things keep it *correct* rather than just current: committed build output (a checked-in `dist/` tree) is skipped by shape so its mangled names never pollute resolution, and a large workspace's first index moves to a background job instead of holding a tool call open.
|
|
106
|
+
|
|
107
|
+
## What this plugin adds
|
|
108
|
+
|
|
109
|
+
Five things you do not get from a CLI an agent shells out to:
|
|
110
|
+
|
|
111
|
+
1. **No second runtime.** `dsh plugin add dsh-plugin-codegraph` is the whole install — no binary on `PATH`, no MCP server to wire, no version to keep in sync with the plugin.
|
|
112
|
+
2. **An index that starts itself.** Opening a session in an unindexed workspace builds one in the background, and every change after that is picked up by a watcher.
|
|
113
|
+
3. **A model that knows the state of what it is querying.** Every request's prompt carries how large the index is, when it was built, and how many generated files were skipped — for free, instead of a `status` round-trip.
|
|
114
|
+
4. **Entry points for a human.** `/codegraph status|index|files`, and a settings panel with a rebuild button. Neither spends a model turn.
|
|
115
|
+
5. **Re-indexes that are cheap.** A parse cache makes a repeat run 991 ms → 45 ms on a 337-file workspace, so "just re-index before you answer" stops being an expensive habit.
|
|
116
|
+
|
|
117
|
+
## Compared with the `codegraph` CLI
|
|
118
|
+
|
|
119
|
+
The CLI is the origin of the on-disk format this plugin reads and writes, and it covers more languages than this indexer parses. They are aimed at different things:
|
|
120
|
+
|
|
121
|
+
| | This plugin | [`@colbymchenry/codegraph`](https://github.com/colbymchenry/codegraph) |
|
|
122
|
+
|---|---|---|
|
|
123
|
+
| **Shape** | A DSH plugin: two tools, a `/codegraph` command, a settings panel, and a prompt section | An MCP server plus a CLI you install and wire into each agent |
|
|
124
|
+
| **Install** | `dsh plugin add dsh-plugin-codegraph` — no second runtime, no MCP config | Install the CLI, run its setup to wire the MCP server per agent, then `codegraph init` per project |
|
|
125
|
+
| **First index** | Automatic: opening a session in an unindexed workspace starts one | Explicit `codegraph init` per project |
|
|
126
|
+
| **Index state** | One line in the prompt on every request (size, age, skipped artifacts) plus a settings panel | Ask its MCP tool |
|
|
127
|
+
| **Re-index cost** | Parse cache — 991 ms → 45 ms on a 337-file workspace | Not measured here |
|
|
128
|
+
| **Background indexing** | Past ~1000 files the run becomes a `ctx.jobs` job | Not measured here |
|
|
129
|
+
| **Committed bundles** | Skipped by shape (`.min.`, or an average line > 500 chars) | Not measured here |
|
|
130
|
+
| **Languages** | 18 bundled grammars | 40+, including ArkTS, Vue, Svelte, Solidity, Terraform |
|
|
131
|
+
| **On-disk format** | Schema v4 — the CLI's own path and format | Schema v4 (origin) |
|
|
132
|
+
|
|
133
|
+
What this plugin adds is not a better graph — it is the same graph, delivered where DSH can act on it: no second process, no MCP plumbing, a state line the model reads for free, a human command, and a UI.
|
|
134
|
+
|
|
135
|
+
## The Rust engine
|
|
136
|
+
|
|
137
|
+
Parsing was the one place this plugin was visibly slow, and the reason was structural: `parse` plus `extractFile` ran on the host's main thread through `web-tree-sitter`, one file at a time. A native addon now does that work instead — `tree-sitter` compiled into Rust, one worker per core through rayon — and it is on for **TypeScript, TSX, JavaScript and JSX** already.
|
|
138
|
+
|
|
139
|
+
| | JS + WASM | Rust addon |
|
|
140
|
+
|---|---|---|
|
|
141
|
+
| parse + extract (336 files, same input) | 727 ms | **110 ms** |
|
|
142
|
+
| whole walk, 337-file workspace (median of 4) | 807–886 ms | **277–336 ms** (2.6–2.9×) |
|
|
143
|
+
|
|
144
|
+
The whole-walk number is lower than the engine number because the walk is not only extraction: reading files, hashing, caching decisions and the final write are unchanged, and three files in that workspace would need the JS engine anyway (below). On a workspace with no such files the gap widens.
|
|
145
|
+
|
|
146
|
+
Three details worth knowing:
|
|
147
|
+
|
|
148
|
+
- **It is optional, and it degrades quietly.** The addon ships as `.node` platform artifacts; if it is missing, unbuilt, or throws, every file falls back to the JS extractor. `engine: 'js'` forces that path, `'auto'` (default) uses the addon where it can.
|
|
149
|
+
- **The rule table is not duplicated.** The addon receives `LANGUAGE_TABLE` as JSON and builds its matchers from it, so the two engines cannot drift on what a rule says — only on how well they implement it, which is what the parity tests measure.
|
|
150
|
+
- **Files whose parse tree has errors are left to the JS engine.** The two grammars (WASM 0.20 vs crate 0.23/0.25) recover from malformed input differently — on a real workspace that showed up as one phantom definition and a line off by one — so the addon refuses those files and `walk` extracts them the old way. Correct over fast.
|
|
151
|
+
|
|
152
|
+
`packages/tree-sitter/tests/rust-parity.spec.ts` asserts the two engines produce **byte-identical** extractions on every fixture, and on a real workspace when `CODEGRAPH_PARITY_WORKSPACE` is set.
|
|
153
|
+
|
|
154
|
+
**Coverage and next.** Four languages today. Python, Go, Java, C/C++, Rust, C# and the rest still go through the JS extractor, which keeps working unchanged; each new language needs its own Rust-side special cases plus a parity run before it ships. Multi-platform binaries (Linux, Windows, both architectures) are not published yet — building the addon is documented in [`crates/indexer-rust/README.md`](crates/indexer-rust/README.md).
|
|
84
155
|
|
|
85
156
|
## Call resolution never guesses
|
|
86
157
|
|
|
@@ -126,6 +197,7 @@ The bundle mounts all four plugins in one layer. Retune any of them from the pro
|
|
|
126
197
|
exclude: ['node_modules', 'dist', 'vendor']
|
|
127
198
|
respectGitignore: true
|
|
128
199
|
skipMinified: true # the default; set false to index committed bundles anyway
|
|
200
|
+
engine: auto # auto | js | rust — prefer the native addon where it applies
|
|
129
201
|
watch: true # the default; shown for clarity — set false to keep indexing purely explicit
|
|
130
202
|
|
|
131
203
|
- id: codegraph-tool
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-plugin-codegraph",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Structural code intelligence for DeepSeek Harness — gives the agent codegraph and codegraph_index tools to find where a symbol is declared, what calls it, what a change reaches, and how one symbol reaches another, from a tree-sitter index it builds itself",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh",
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"dsh-plugin-codegraph-
|
|
46
|
-
"dsh-plugin-codegraph-
|
|
47
|
-
"dsh-plugin-codegraph-
|
|
48
|
-
"dsh-plugin-codegraph-sqlite": "^0.
|
|
49
|
-
"dsh-plugin-codegraph-
|
|
45
|
+
"dsh-plugin-codegraph-panel": "^0.5.0",
|
|
46
|
+
"dsh-plugin-codegraph-service": "^0.5.0",
|
|
47
|
+
"dsh-plugin-codegraph-tool": "^0.5.0",
|
|
48
|
+
"dsh-plugin-codegraph-sqlite": "^0.5.0",
|
|
49
|
+
"dsh-plugin-codegraph-tree-sitter": "^0.5.0"
|
|
50
50
|
}
|
|
51
51
|
}
|