dsh-plugin-codegraph 0.4.1 → 0.4.2

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 (2) hide show
  1. package/README.md +61 -3
  2. package/package.json +6 -6
package/README.md CHANGED
@@ -74,13 +74,71 @@ 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
- - **No incremental reparse, on purpose.** "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. `codegraph_index` always rebuilds the whole graph instead — cheaper to reparse everything than to get that invalidation wrong — leaving incremental reparse as a future optimization only once it's an actual, measured bottleneck, not a default.
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
- The bundled indexer parses **TypeScript, TSX, JavaScript, JSX, Python, Go, Java, C, C++, C#, PHP, Rust, Ruby, Zig, Kotlin, Swift, Dart, and Scala**. Grammars load lazily — one per language, on first sight of a matching file — so a Go-only workspace never loads a Python grammar.
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
- The **store is format-bound, not language-bound**: a graph built by the `codegraph` CLI over languages this indexer does not parse is still fully queryable. If you need broader indexing coverage today, index with the CLI and query through this plugin.
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
+ ## Roadmap: a Rust core
136
+
137
+ The indexer is the one place this plugin is visibly slow on a first run, and the reason is structural: parsing runs on the host's main thread through `web-tree-sitter`, one file at a time. On a 337-file workspace a cold walk is 920 ms, and parsing plus extraction is essentially all of it — measured serially, 425 ms of `parse` and 491 ms of `extractFile`.
138
+
139
+ The plan is to move extraction into a Rust core — `tree-sitter`'s native crate behind a `napi-rs` addon, with a worker pool parsing files in parallel — keeping every behaviour above (same cache keys, same resolution rules, same schema v4 output) so nothing user-visible changes except the clock. A sibling indexer here went from 17.6 s single-threaded in JS to 4.1 s on 8 threads in Rust (4.3×) on a different, heavier workload; that is the right order of magnitude for this one, not a promise.
140
+
141
+ **Not in the current release.** Until it lands, the parse cache is what makes repeats cheap, and the first run is what it is.
84
142
 
85
143
  ## Call resolution never guesses
86
144
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-codegraph",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
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-tool": "^0.4.1",
46
- "dsh-plugin-codegraph-panel": "^0.4.1",
47
- "dsh-plugin-codegraph-tree-sitter": "^0.4.1",
48
- "dsh-plugin-codegraph-sqlite": "^0.4.1",
49
- "dsh-plugin-codegraph-service": "^0.4.1"
45
+ "dsh-plugin-codegraph-panel": "^0.4.2",
46
+ "dsh-plugin-codegraph-service": "^0.4.2",
47
+ "dsh-plugin-codegraph-sqlite": "^0.4.2",
48
+ "dsh-plugin-codegraph-tree-sitter": "^0.4.2",
49
+ "dsh-plugin-codegraph-tool": "^0.4.2"
50
50
  }
51
51
  }