dsh-gitnexus-plus 0.1.1 → 0.1.3

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 (64) hide show
  1. package/README-CN.md +174 -0
  2. package/README.md +184 -447
  3. package/lib/bin/search-helper.d.ts +22 -0
  4. package/lib/bin/search-helper.d.ts.map +1 -0
  5. package/lib/bin/search-helper.js +57 -0
  6. package/lib/bin/search-helper.js.map +1 -0
  7. package/lib/client.js +978 -122
  8. package/lib/gitnexus/analyze.d.ts +27 -2
  9. package/lib/gitnexus/analyze.d.ts.map +1 -1
  10. package/lib/gitnexus/analyze.js +71 -6
  11. package/lib/gitnexus/analyze.js.map +1 -1
  12. package/lib/gitnexus/commands.d.ts +41 -8
  13. package/lib/gitnexus/commands.d.ts.map +1 -1
  14. package/lib/gitnexus/commands.js +62 -9
  15. package/lib/gitnexus/commands.js.map +1 -1
  16. package/lib/gitnexus/coverage.d.ts +16 -0
  17. package/lib/gitnexus/coverage.d.ts.map +1 -1
  18. package/lib/gitnexus/coverage.js +61 -2
  19. package/lib/gitnexus/coverage.js.map +1 -1
  20. package/lib/gitnexus/git-activity.d.ts +85 -0
  21. package/lib/gitnexus/git-activity.d.ts.map +1 -1
  22. package/lib/gitnexus/git-activity.js +286 -1
  23. package/lib/gitnexus/git-activity.js.map +1 -1
  24. package/lib/gitnexus/index-meta.d.ts +15 -5
  25. package/lib/gitnexus/index-meta.d.ts.map +1 -1
  26. package/lib/gitnexus/index-meta.js +25 -5
  27. package/lib/gitnexus/index-meta.js.map +1 -1
  28. package/lib/gitnexus/languages.d.ts +7 -0
  29. package/lib/gitnexus/languages.d.ts.map +1 -1
  30. package/lib/gitnexus/languages.js +82 -2
  31. package/lib/gitnexus/languages.js.map +1 -1
  32. package/lib/gitnexus/root.d.ts +6 -0
  33. package/lib/gitnexus/root.d.ts.map +1 -1
  34. package/lib/gitnexus/root.js +6 -0
  35. package/lib/gitnexus/root.js.map +1 -1
  36. package/lib/gitnexus/scan.d.ts +3 -0
  37. package/lib/gitnexus/scan.d.ts.map +1 -1
  38. package/lib/gitnexus/scan.js +6 -3
  39. package/lib/gitnexus/scan.js.map +1 -1
  40. package/lib/gitnexus/search.d.ts +167 -0
  41. package/lib/gitnexus/search.d.ts.map +1 -0
  42. package/lib/gitnexus/search.js +517 -0
  43. package/lib/gitnexus/search.js.map +1 -0
  44. package/lib/index.d.ts +32 -13
  45. package/lib/index.d.ts.map +1 -1
  46. package/lib/index.js +68 -21
  47. package/lib/index.js.map +1 -1
  48. package/lib/routes/analyze.d.ts +8 -2
  49. package/lib/routes/analyze.d.ts.map +1 -1
  50. package/lib/routes/analyze.js +5 -1
  51. package/lib/routes/analyze.js.map +1 -1
  52. package/lib/routes/coverage.d.ts +15 -6
  53. package/lib/routes/coverage.d.ts.map +1 -1
  54. package/lib/routes/coverage.js +77 -12
  55. package/lib/routes/coverage.js.map +1 -1
  56. package/lib/routes/file-history.d.ts +21 -0
  57. package/lib/routes/file-history.d.ts.map +1 -0
  58. package/lib/routes/file-history.js +69 -0
  59. package/lib/routes/file-history.js.map +1 -0
  60. package/lib/routes/search.d.ts +27 -0
  61. package/lib/routes/search.d.ts.map +1 -0
  62. package/lib/routes/search.js +77 -0
  63. package/lib/routes/search.js.map +1 -0
  64. package/package.json +3 -2
package/README.md CHANGED
@@ -1,484 +1,221 @@
1
1
  # dsh-gitnexus-plus
2
2
 
3
- A DeepSeek Harness plugin for **GitNexus index visibility** — starting with the part
4
- GitNexus itself cannot tell you: **what the index left out**.
3
+ **English** · [简体中文](README-CN.md)
4
+
5
+ **Current release: [0.1.3](https://github.com/Moowningstar/gitnexus-plus/releases/tag/v0.1.3)** ·
6
+ [npm](https://www.npmjs.com/package/dsh-gitnexus-plus) ·
7
+ [Issues](https://github.com/Moowningstar/gitnexus-plus/issues)
8
+
9
+ [What it does](#what-it-does) · [Install](#install) · [Troubleshooting](#troubleshooting) ·
10
+ [Upstream GitNexus docs](#upstream-gitnexus-documentation)
11
+
12
+ A DeepSeek Harness plugin: see what a GitNexus index **covers and what it leaves out**,
13
+ refresh it from the sidebar, and search its symbols by keyword.
14
+
15
+ It does not fork GitNexus, rewrite its parser, or bundle/redistribute it. `gitnexus` is a
16
+ **peer**; you provide it.
17
+
18
+ ## What it does
19
+
20
+ - **Index coverage** — lists the oversized files `gitnexus analyze` skipped, with size,
21
+ language share, and generated/minified signals.
22
+ - **Index freshness** — indexed commit vs `HEAD`, classified `current` / `behind` /
23
+ `diverged` / `unknown`, plus the uncommitted-change count.
24
+ - **Graph composition** — nodes, edges, communities, processes, embeddings, edges per node.
25
+ - **Git activity × index** — recent commits, authors, branches and most-changed files,
26
+ each file marked **indexed**, **excluded by design**, or **missing from the index**.
27
+ Includes an activity × index cross-tab, a baseline review against the indexed commit
28
+ (or the activity-window start when the index recorded none), a 7/14/30-day commit
29
+ timeline, and a per-file timeline when a file row is clicked.
30
+ - **Language distribution** — bytes split into languages GitNexus can parse, formats it
31
+ only recognizes, and everything else. Without GitNexus, a built-in extension map keeps
32
+ the breakdown useful and marks it `builtin`, never "parsed".
33
+ - **Keyword search** — matches graph node `name` / `filePath`, returns kind, path and line;
34
+ clicking a hit opens the file at that line, and a separate Copy button copies
35
+ `path:line`.
36
+ - **Source fallback** — when the graph helper cannot start (no usable shell sandbox,
37
+ DLL/ABI, busy index), a bounded line search over the indexed files returns
38
+ `mode: "text"` instead of pretending to be the graph.
39
+ - **No-index visibility** — a git project without an index shows a scan overview,
40
+ language split and the initialize command instead of an empty panel.
41
+ - **Maintenance** — initialize, incremental refresh and full rebuild (`--force`) run
42
+ through DSH's shell executor, with no self-escalation.
43
+
44
+ ## Install
45
+
46
+ Requirements:
47
+
48
+ - DSH `>=0.2.0-rc.2 <0.3.0`
49
+ - Node `>=22`
50
+ - GitNexus `>=1.6.0 <2.0.0` (peer; not installed by this plugin)
5
51
 
6
- ## The problem it solves
7
-
8
- `gitnexus analyze` silently drops files. Its entire surface for saying so is one
9
- line on stderr, printed once:
10
-
11
- ```
12
- Skipped 3 large files (>512KB, likely generated/vendored)
13
- - dist/app.min.js
14
- ...and 2 more (set GITNEXUS_VERBOSE=1 to list them all)
15
- ```
16
-
17
- That line is not returned, not persisted, not queryable, and gone when the terminal
18
- scrolls. Meanwhile the files it names can be the difference between an index that
19
- represents your codebase and one that does not — measured on this machine,
20
- `material-ui` skips 4.4 MB (12.4 % of scanned bytes), and those files contribute
21
- **zero** symbols to the graph.
22
-
23
- This plugin turns that line into data, a tool, and a route.
24
-
25
- ## What this project is, and what it is not
26
-
27
- [GitNexus](https://github.com/abhigyanpatwari/GitNexus) is a code-intelligence engine by
28
- **Abhigyan Patwari**. It parses a repository into symbols, relationships and execution
29
- flows and writes them to a local graph database. It is a genuinely good piece of work,
30
- and this project would have nothing to show without it.
31
-
32
- What GitNexus does not give an everyday user is **visibility** and **automation**:
33
-
34
- - **Visibility** — how much of the repository does the index actually cover? Which files
35
- were skipped for being too large? Has the index fallen behind `HEAD`, and by how much?
36
- The CLI does not answer those unasked, and the answer is invisible exactly when it
37
- matters.
38
- - **Automation** — once an index is stale, somebody has to remember to refresh it.
39
-
40
- **This project is a layer that adds those two things and nothing else.** It reads the
41
- index GitNexus wrote, reports what the index left out, and can start an incremental
42
- refresh through GitNexus's own CLI.
43
-
44
- It does **not**:
45
-
46
- - fork GitNexus, patch it, or reimplement its parser or graph database;
47
- - redistribute GitNexus source. Nothing from that project is inside this package's
48
- tarball. `gitnexus` is declared as a **peer**, not a dependency, so installing this
49
- plugin installs nothing from it — the operator supplies GitNexus, by whatever means,
50
- and the two stay separate;
51
- - claim authorship of, or any contribution to, GitNexus. All rights in GitNexus belong
52
- to its author;
53
- - replace GitNexus. With no GitNexus index there is nothing here to display.
54
-
55
- ## Licence — read this before a commercial use
56
-
57
- This project is **MIT** (see [LICENSE](LICENSE)).
58
-
59
- **It depends on GitNexus, which is `PolyForm-Noncommercial-1.0.0`.** That licence grants
60
- noncommercial use and restricts commercial use. GitNexus is **not** a dependency of this
61
- package — it is a peer, so installing this plugin does not install it, and the plugin
62
- never bundles or redistributes it. Installing this plugin's package therefore installs
63
- nothing under that licence. But every GitNexus-backed feature — reading an index,
64
- refreshing one, installing one on request — puts your use of *GitNexus* under
65
- *GitNexus's* licence:
66
-
67
- - **your use of this plugin's GitNexus-backed features is subject to GitNexus's
68
- licence**, not to this project's MIT grant;
69
- - **commercial use requires a separate grant from GitNexus's author.** If your use is
70
- commercial, read
71
- <https://github.com/abhigyanpatwari/GitNexus/blob/main/LICENSE> or contact the author
72
- before relying on any of it.
73
-
74
- This project cannot and does not change that: it only calls the interfaces GitNexus
75
- provides. The read-only half — reading `.gitnexus/gitnexus.json` and reporting on it —
76
- is this project's own code and carries no GitNexus code, but it also has nothing to
77
- report on unless GitNexus produced that file.
78
-
79
- A one-line summary: **the MIT licence here covers my code; GitNexus's licence covers
80
- GitNexus, and installing this plugin installs GitNexus.**
81
-
82
- ## What it reports
83
-
84
- - **Skipped large files** — path, size, share of its language, and two independent
85
- signals for *why* it is not source: a single-line (minified) heuristic, and a
86
- build-output path heuristic. Binary assets are detected separately and never
87
- called minified.
88
- - **Index freshness** — the indexed commit against HEAD, classified `current` /
89
- `behind` / `diverged` / `unknown` the same way `gitnexus status` does, plus the
90
- uncommitted-change count.
91
- - **Graph composition** — nodes, edges, communities, processes, embeddings, and
92
- edges-per-node, all read from the manifest.
93
- - **Query surfaces** — which of graph / keyword search / semantic search are
94
- actually available, with the reason when one is not. An index with no FTS cannot
95
- answer keyword queries, and hiding that is how a reader concludes otherwise.
96
- - **Git activity, crossed with the index** — recent commits, authors (bots marked),
97
- branches, most-changed files and most-recent files, each carrying a three-way
98
- verdict: *indexed*, *excluded by design*, or **missing from the index**. That last
99
- one is the point: of the files people are actively editing, which does the graph
100
- not see?
101
- - **Language distribution by bytes**, split three ways: languages GitNexus can
102
- *parse* into the graph, formats it merely *recognizes*, and everything else.
103
- - **Resolver confidence** — untyped receiver sites, which make `impact` and
104
- `context` a lower bound rather than an exact answer.
105
-
106
- ## Why the git three-way split matters
107
-
108
- A two-way "indexed / not indexed" count is misleading. Measured on a real
109
- repository, 1 635 files had been touched in 90 days: 491 indexed, 1 143 absent, and
110
- reporting that as "70 % missing" is wrong — 1 143 of them are lockfiles, dotfiles
111
- and binary assets that no scan would select either. Exactly **one** was a genuine
112
- gap (`src/stores/windowModeStore.ts`). The panel reports the three numbers
113
- separately, and only the third raises a warning.
114
-
115
-
116
- ## Design commitments
117
-
118
- **Reuse, don't reimplement.** "Which files did GitNexus skip?" has exactly one
119
- correct answer: the set `walkRepositoryPaths` produced. This plugin deep-imports
120
- GitNexus's own `createIgnoreFilter`, `glob` call and `getLanguageFromFilename`
121
- rather than approximating them, and `test/run.mjs` cross-checks its scan against
122
- `walkRepositoryPaths` on real repositories. If upstream reshapes those modules the
123
- plugin degrades to a documented fallback scan (`ScanReport.primitives === 'fallback'`)
124
- instead of reporting a wrong number.
125
-
126
- **Absent is reported as absent.** The size cap an index was built under is read from
127
- that index. Legacy indexes (`meta.json`, no `indexCoverage`) are reported with the
128
- cap *unknown* and a note — never defaulted to today's value, which would misattribute
129
- covered files as skipped.
130
-
131
- **Read-only.** Nothing here triggers `analyze`, writes to `.gitnexus/`, or takes the
132
- index lock. A status check must never start a 30-second rebuild.
133
-
134
- ## Getting GitNexus — the prerequisite, and the two ways to satisfy it
135
-
136
- This plugin reads an index. **Only GitNexus produces one.** So the plugin checks
137
- whether GitNexus is present, and when it is not, the panel says so above everything else
138
- rather than letting you wonder why the numbers are missing.
139
-
140
- Two ways out, in the order the panel offers them:
141
-
142
- **① Install it yourself.** The panel shows a copyable `npm install -g gitnexus`, and
143
- that is the recommendation. You know your network, your registry and your toolchain; a
144
- command you can run is more useful than a download this plugin performs on your behalf,
145
- and it works behind whatever mirror or feed your machine actually reaches.
146
-
147
- **② Let the plugin install it.** Second in the list and behind a confirmation, because
148
- it is a much larger decision. It runs, through the host's shell executor:
149
-
150
- ```
151
- npm install --prefix <DSH_HOME>/gitnexus-plus/gitnexus gitnexus@^1.6.12
52
+ ```sh
53
+ dsh plugin add dsh-gitnexus-plus
152
54
  ```
153
55
 
154
- and the confirmation states what that means before anything starts:
56
+ Restart DSH after adding it. The panel is a right-sidebar tab: open the sidebar's **+**
57
+ → guide page → **GitNexus 索引**.
155
58
 
156
- - **about 500 MB to 1 GB** downloaded, from whatever registry your `.npmrc` already
157
- names — this plugin hardcodes none, because a hardcoded one breaks exactly the users
158
- whose network is why they need this path;
159
- - **several minutes**, longer on a slow link or when the native modules have to compile;
160
- - **this machine's build toolchain is used** — `@ladybugdb/core`, `tree-sitter` and
161
- `tree-sitter-*` compile on install. That is why this is `npm` and not `pnpm`: pnpm 10+
162
- refuses dependency build scripts by default, and the failure it produces is one you
163
- cannot act on. GitNexus's own message names the grants it needs:
164
- `--allow-build=@ladybugdb/core --allow-build=gitnexus --allow-build=tree-sitter`;
165
- - it installs into a **plugin-owned directory**, never your global prefix, so it needs no
166
- elevation and cannot collide with a GitNexus you already have.
59
+ The `desktop` profile is managed by Electron; the CLI cannot change it. Use the Web
60
+ sidebar's Plugins page there. From a local checkout:
167
61
 
168
- Everything runs through `ctx.shell`, so a sandboxed deployment confines it exactly as it
169
- confines your own commands. **A refusal is reported as a refusal and never retried
170
- wider** — the plugin never asks for more scope than the session already granted.
62
+ ```sh
63
+ dsh plugin --profile web add <absolute path to this package>
64
+ ```
171
65
 
172
- If your GitNexus lives somewhere unusual, name it directly and none of this applies:
66
+ GitNexus can be installed by you or by the panel. For a custom location:
173
67
 
174
68
  ```sh
175
69
  GITNEXUS_CLI=/path/to/gitnexus/dist/cli/index.js
176
70
  ```
177
71
 
178
- That path is checked first, and it is the answer for an offline or air-gapped machine:
179
- put a copy anywhere, point at it, done.
72
+ ### Getting GitNexus
180
73
 
181
- ## Usage
74
+ Installing it yourself is recommended:
182
75
 
183
76
  ```sh
184
- # CLI, no install
185
- npm run build # tsc (host) + tsc (client) + wrap
186
- node lib/bin/gitnexus-coverage.js <repo-path>
187
- node lib/bin/gitnexus-coverage.js -r material-ui # by registry alias
188
- node lib/bin/gitnexus-coverage.js --all --json # every indexed repository
189
- node lib/bin/gitnexus-coverage.js <repo> --fail-on-large # exit 2 — CI gate
190
-
191
- # type check
192
- npm run check
193
-
194
- # tests
195
- npm test
77
+ npm install -g gitnexus
196
78
  ```
197
79
 
198
- In DSH the plugin exposes:
199
-
200
- - **tool** `gitnexus_coverage` — `{ repo, includeLanguages? }`
201
- - **route** `GET /api/gitnexus/coverage?repo=<project>` — one report, plus the
202
- maintenance commands for that project
203
- - **panel** — a right-sidebar tab type `gitnexus`, opened from the sidebar's **+** →
204
- guide page ("GitNexus 索引")
205
-
206
- The coverage route is read-only and accepts only directories that are already GitNexus
207
- indexes, so it cannot be turned into a filesystem probe; it is additionally
208
- restricted to loopback peers because a third-party DSH route is unauthenticated by
209
- default on a bare `dsh web` profile.
210
-
211
- There is now a **second** route, `/api/gitnexus/analyze`, and it is the only one that
212
- can change anything. It answers `POST` to start an incremental refresh, `GET` to report
213
- where that got to, and `DELETE` to stop it. It is a separate module from the coverage
214
- route so the read-only half keeps a method policy that cannot mutate — the shared guard
215
- takes the accepted methods from the route rather than hard-coding one set for both. The
216
- mutating verbs additionally pass the write guard, which refuses cross-origin requests;
217
- loopback alone is not enough, because any page the operator visits can reach
218
- `127.0.0.1`. See **Maintenance** below for what it will and will not do.
219
-
220
- ## TypeScript, and why the build looks the way it does
221
-
222
- The source is TypeScript under `strict`, including `noImplicitAny`. That is not
223
- decoration: an implicit `any` is a **silent** failure — it does not report an error,
224
- it just makes the checker stop working exactly where it was needed. Migrating this
225
- codebase from JS+JSDoc to real types surfaced six places where the documentation and
226
- the code disagreed, none of which produced a runtime error until the affected branch
227
- was reached:
228
-
229
- | Where | JSDoc claimed | Actually |
230
- | --- | --- | --- |
231
- | `LargeFile.generatedHint` | `string \| null` | `boolean` — consumed as `if (x)` |
232
- | `LargeFile.minified` | non-null | nullable, when the probe budget runs out |
233
- | `analyzer.primitives` | `number` | a **string**, compared against `'gitnexus'` |
234
- | `MinifiedVerdict` | a type name | **the type did not exist** |
235
- | `activityView()` result | — | missing `truncated`, which callers read |
236
- | `analyzeCoverage` options | 3 fields | 5 — two were undocumented |
237
-
238
- ### Two compile targets, no bundler
80
+ The panel can also install it through DSH's shell:
239
81
 
82
+ ```sh
83
+ npm install --prefix <DSH_HOME>/gitnexus-plus/gitnexus gitnexus@^1.6.12
240
84
  ```
241
- src/index.ts ───────────┐
242
- src/gitnexus/*.ts ──────┤ tsc (NodeNext) → lib/**/*.js + *.d.ts ESM
243
- src/routes/*.ts ────────┤
244
- src/bin/*.ts ───────────┘
245
-
246
- src/client/index.ts ────→ tsc (CommonJS) → build/client/index.js
247
- ↓ text wrap (scripts/build-client.mjs)
248
- lib/client.js
249
- ```
250
-
251
- The browser half needs no bundler because it **is** one module: its only imports are
252
- platform baseline modules (`react`, the UI primitives) supplied by the loader's own
253
- `require` at runtime, and it has no relative imports at all. `tsc --module commonjs`
254
- therefore emits exactly one self-contained file, and the wrap is a text operation. A
255
- bundler would add a dependency and a resolution graph to solve a problem this package
256
- does not have.
257
-
258
- `esModuleInterop` is **off** for the client target on purpose: it makes
259
- `import * as React from 'react'` compile to a bare `const React = require("react")`,
260
- which is precisely what the loader factory provides. With interop on, tsc injects an
261
- `__importStar` helper that would ride along in every page load.
262
85
 
263
- ### `scripts/*.mjs` stays JavaScript (deliberate)
86
+ That downloads roughly 500 MB–1 GB and needs a C++ toolchain; no registry is hardcoded.
87
+ Treat the first install as unverified and fall back to the manual command if it fails.
264
88
 
265
- `scripts/link-runtime.mjs` runs from `postinstall`, and `scripts/build-client.mjs` is
266
- the build driver itself. A bootstrap script **must not depend on the build it
267
- bootstraps** — if those needed compiling, a fresh clone's `npm install` would fail
268
- because `lib/` does not exist yet. `src/**` and `bin/**` are TypeScript; `scripts/`
269
- is plain ESM, and that line is intentional rather than unfinished.
89
+ ## Usage
270
90
 
271
- ### Runtime packages ship no type declarations
91
+ The panel reports the project the current workspace points at; it has no global
92
+ repository list. Its bound is a project root (a `.gitnexus` index or a `.git` marker), so
93
+ it cannot become a filesystem probe.
272
94
 
273
- `@deepseek-ai/schemastery`, `@deepseek-ai/dsh-tools`, `@deepseek-ai/cordis` and
274
- `@deepseek-ai/dsh-client-ui-primitives` each declare `"types": "lib/types/index.d.ts"`
275
- in their manifest and ship no such file. Every plugin author has to write these
276
- declarations; `types/` holds the four, with the surface limited to what this plugin
277
- actually uses. The primitive **props** were read off real call sites in shipped
278
- plugins rather than guessed, because a wrong prop name fails silently at runtime —
279
- the control renders with a default and nothing reports anything.
95
+ Inside DSH:
280
96
 
281
- ## Client half
97
+ - tool `gitnexus_coverage`: `{ repo, includeLanguages? }`
98
+ - route `GET /api/gitnexus/coverage?repo=<project>`
99
+ - route `GET /api/gitnexus/search?repo=<project>&q=<keyword>&limit=20`
100
+ - route `GET /api/gitnexus/file-history?repo=<project>&path=<file>&days=7` — one file's
101
+ bounded commit timeline
102
+ - route `POST/GET/DELETE /api/gitnexus/analyze` (the only entry that changes an index)
103
+ - right-sidebar tab `gitnexus`
282
104
 
283
- `src/client/index.ts` is one CommonJS module using nothing but baseline modules
284
- (`react`), so `scripts/build-client.mjs` wraps it into the loader's factory
285
- artifact with no bundler at all — a text wrap cannot drift from its source the way
286
- a bundle can.
105
+ CLI:
287
106
 
288
- The panel splits fetching (`CoveragePanel`) from presentation (`CoverageView`).
289
- That is not stylistic: a component that fetches cannot be rendered against a
290
- fixture, and the states worth asserting on — a report with skipped files, one
291
- without, an error, missing language data — are exactly the ones a fixture supplies.
292
- `test/client.mjs` renders each of them through a minimal single-pass hooks shim.
107
+ ```sh
108
+ npm run build
109
+ node lib/bin/gitnexus-coverage.js <repo-path>
110
+ node lib/bin/gitnexus-coverage.js -r material-ui # by registry alias
111
+ node lib/bin/gitnexus-coverage.js --all --json # every indexed repository
112
+ node lib/bin/gitnexus-coverage.js <repo> --fail-on-large # CI gate, exit 2
113
+ npm run check
114
+ npm test
115
+ ```
293
116
 
294
- Styling is theme-agnostic by construction: host elements only, `color` inherited,
295
- every border derived from `currentColor`. `@deepseek-ai/dsh-client-ui-primitives` is
296
- a baseline module but ships no JS in the installed runtime, so its exports cannot
297
- be verified from outside — guessing at component props would fail at mount time in
298
- a browser, where no test in this repository can see it.
117
+ Search has two modes:
299
118
 
300
- ## Verified end to end
119
+ - **graph** — the normal path. The host does not load native `lbug`; it starts
120
+ `lib/bin/search-helper.js` under system Node and searches node names and file paths. It
121
+ does not search bodies, so it works on an index built with `--skip-fts`.
122
+ - **text** — the fallback when the graph query cannot start. It reads the files listed in
123
+ the index manifest, matches lines, searches code before docs, and caps files/bytes/
124
+ matches. The panel labels it 源码关键词(回退).
301
125
 
302
- Installed into the `web` profile and booted; the route answered with real data:
126
+ Clicking a hit calls
127
+ `ctx.sidebarRight.openResourceIn(sessionId, address, { params: { line } })` to open the
128
+ platform file viewer at that line; without that service it falls back to copying the path.
303
129
 
304
- ```
305
- GET /api/gitnexus/coverage?repo=D:\Project\material-ui HTTP 200
306
- manifest meta.json · scanned 28927 · selected 28924 · large 3 · 11 languages
307
- 2.3 MB packages/mui-icons-material/lib/index.js generated
308
- 1.4 MB CHANGELOG.old.md
309
- 739.9 KB packages/mui-icons-material/lib/index.mjs generated
310
- GET /api/gitnexus/coverage?repo=C:\Windows HTTP 404 (refused)
311
- ```
130
+ ## Troubleshooting
312
131
 
313
- ## Scope: the project you are in, not a global list
314
-
315
- The panel reports **the project the session's workspace points at**. It does not
316
- list indexed repositories and has no picker.
317
-
318
- That is a deliberate reversal. The first design read `~/.gitnexus/registry.json`
319
- and offered a dropdown, which made a global file a hard dependency — so a fresh
320
- clone, a second working tree, or an index built with `GITNEXUS_HOME` redirected
321
- could not be shown at all, which is exactly when a coverage panel is most useful.
322
- The workspace comes from the slot's session-scoped props (`useWorkspaces` matched
323
- by `sessionId`); the host route accepts any directory **that is already a GitNexus
324
- index**, which is the bound that keeps it from being a filesystem probe.
325
-
326
- ## Maintenance: the refresh runs here, the escape hatches do not
327
-
328
- Two situations the read-only half cannot resolve on its own:
329
-
330
- - **初始化索引 / 增量刷新** — the index is missing or behind HEAD. This one the plugin
331
- runs for you.
332
- - **强制全量重构** — the incremental refresh has hung. GitNexus's update path is not
333
- reliably terminating, and when it wedges a full rebuild is the only way out. Handed
334
- over as text.
335
-
336
- **增量刷新 runs through the host's shell executor.** An earlier revision handed over
337
- every command as text, justified by "a plugin that spawns processes bypasses the
338
- permission system". That reasoning was wrong, and the correction is worth stating
339
- precisely:
340
-
341
- DSH's approval service governs **sandbox escalation** — widening the scope a session was
342
- granted. Its audit pair must be turn-enclosed, which is why `ApprovalService.request()`
343
- throws outside an open turn; a panel route has no turn, so it cannot ask. It also has
344
- nothing to ask about here: this command writes `.gitnexus/` **inside the workspace**,
345
- already within the granted scope.
346
-
347
- Confinement is not something a caller opts into. It is what `ctx.shell` *is* in a given
348
- deployment — `dsh-pwsh-local` exposes the argv seam that `dsh-pwsh-sandbox` wraps
349
- through `ctx.sandbox.confine`. So routing through the executor gives this plugin exactly
350
- the isolation your own shell commands get.
351
-
352
- What the plugin commits to, and what is tested:
353
-
354
- - **It never sets `sandboxPolicy`.** Requesting one would be this plugin choosing its
355
- own confinement — escalation, asked for through a door that cannot ask. A denial comes
356
- back as `denied` and **is never retried wider**.
357
- - **One run per repository.** Two concurrent `analyze` processes contend for the same
358
- store, and the second reports a failure that says nothing about the repository.
359
- - **`--index-only` always.** Without it `analyze` rewrites `AGENTS.md`, `CLAUDE.md` and
360
- the agent skill files in your tree — a far larger change than "refresh the index".
361
- - **A confirmation before it starts**, stating the exact command, what it touches and
362
- how long it takes.
363
- - **Cancellable**, with a ten-minute ceiling by default (`analyzeTimeoutMs`).
364
-
365
- The full rebuild still has no button, because the host route does not implement
366
- `--force`. A button that quietly ran something other than its label would be worse than
367
- no button.
368
-
369
- The commands handed over are not a bare `gitnexus analyze`, because that does not work
370
- in every deployment:
132
+ Start with the state the panel reports: `GitNexus absent`, `no index`, `index stale`,
133
+ `FTS unavailable`. The rows below cover this plugin's boundary; the linked upstream
134
+ GitNexus path owns the rest.
371
135
 
136
+ | Symptom | What to do here | Upstream GitNexus path |
137
+ | --- | --- | --- |
138
+ | The panel says GitNexus is absent | Install it yourself, or use the panel's install. For a non-standard location set `GITNEXUS_CLI=/path/to/gitnexus/dist/cli/index.js`. | [`gitnexus/README.md` — Requirements](https://github.com/abhigyanpatwari/GitNexus/blob/main/gitnexus/README.md#requirements), [Quick Start](https://github.com/abhigyanpatwari/GitNexus/blob/main/gitnexus/README.md#quick-start) |
139
+ | The project has no index | Use **初始化索引** in the panel, or run `gitnexus analyze --index-only <repo>`. | [`README.md` — CLI Reference](https://github.com/abhigyanpatwari/GitNexus/blob/main/README.md#cli-reference), [`RUNBOOK.md` — Index out of date](https://github.com/abhigyanpatwari/GitNexus/blob/main/RUNBOOK.md#index-out-of-date--stale-tools) |
140
+ | Refresh fails, `spawn EPERM`, or the index stays `incremental-in-progress` | The panel's command already sets `GITNEXUS_MEMORY=off`, `NODE_OPTIONS=--max-old-space-size=8192`, `GITNEXUS_HOME=<repo>/.gitnexus/plugin-home` and `--index-only`. If the sandbox still refuses, run the copied command in your own shell; the plugin will not escalate. | [`RUNBOOK.md` — LadybugDB / lock errors](https://github.com/abhigyanpatwari/GitNexus/blob/main/RUNBOOK.md#ladybugdb--lock-errors), [Memory / analyze crashes](https://github.com/abhigyanpatwari/GitNexus/blob/main/RUNBOOK.md#memory--analyze-crashes) |
141
+ | Refresh fails with `EPERM … mkdir '<repo>\.gitnexus\parsedfile-store'` | GitNexus 1.6.12 creates this cache directory from the parse worker. The plugin pre-creates the cache directories before spawning; restart DSH after upgrading. If it still fails, the sandbox token cannot write `.gitnexus`; run the copied command in a normal terminal. | [`RUNBOOK.md` — LadybugDB / lock errors](https://github.com/abhigyanpatwari/GitNexus/blob/main/RUNBOOK.md#ladybugdb--lock-errors), [`RUNBOOK.md` — Clean slate](https://github.com/abhigyanpatwari/GitNexus/blob/main/RUNBOOK.md#clean-slate-corrupt-or-huge-gitnexus) |
142
+ | Incremental analyze hangs, or the database reports `Maximum database size … has been reached` | Use **全量重建** (`--force`), or the clean-slate steps. | [`RUNBOOK.md` — Clean slate](https://github.com/abhigyanpatwari/GitNexus/blob/main/RUNBOOK.md#clean-slate-corrupt-or-huge-gitnexus), [`gitnexus/README.md` — Troubleshooting](https://github.com/abhigyanpatwari/GitNexus/blob/main/gitnexus/README.md#troubleshooting) |
143
+ | Search fails with `A dynamic link library (DLL) initialization routine failed` / `lbugjs.node` | Graph search runs in `lib/bin/search-helper.js`, never in the Electron host. Restart DSH after upgrading and keep `node` on the shell PATH. If the helper cannot start at all, search falls back to source text. | [`gitnexus/README.md` — Troubleshooting](https://github.com/abhigyanpatwari/GitNexus/blob/main/gitnexus/README.md#troubleshooting) |
144
+ | Windows search returns very few hits, or the panel warns FTS is unavailable | The index was built with `--skip-fts`, or the FTS extension cannot load. Keyword search still matches names and paths; the source fallback matches lines. Repairing FTS is an upstream action. | [`gitnexus/README.md` — Windows: full-text search unavailable](https://github.com/abhigyanpatwari/GitNexus/blob/main/gitnexus/README.md#windows-full-text-search-unavailable), [Analyze warns about unavailable FTS](https://github.com/abhigyanpatwari/GitNexus/blob/main/gitnexus/README.md#analyze-warns-about-unavailable-fts-or-vector-extensions) |
145
+ | Clicking a search hit does not open a file | The click uses `ctx.sidebarRight.openResourceIn`; a profile without that service falls back to copying `path:line`. Restart DSH; if it persists, use the Copy button. | This panel/DSH boundary; no upstream GitNexus path. |
146
+ | The file timeline fails with 404/401 | The client hot-reloaded before the host did, so `/api/gitnexus/file-history` is not mounted yet. Restart DSH (not just refresh the page). | This plugin's host route; no upstream GitNexus path. |
147
+ | Analyze runs out of memory | Keep the panel's `NODE_OPTIONS` / `GITNEXUS_MEMORY` settings, or raise the heap manually; the index may need a full rebuild. | [`gitnexus/README.md` — Analysis runs out of memory](https://github.com/abhigyanpatwari/GitNexus/blob/main/gitnexus/README.md#analysis-runs-out-of-memory), [`RUNBOOK.md` — Memory / analyze crashes](https://github.com/abhigyanpatwari/GitNexus/blob/main/RUNBOOK.md#memory--analyze-crashes) |
148
+ | A large file is missing from the graph | This is what the panel reports: size/share, generated/minified heuristics, binary detection. Raising the cap is an upstream analyze option; this plugin only reports the skip. | [`gitnexus/README.md` — Large files are being skipped](https://github.com/abhigyanpatwari/GitNexus/blob/main/gitnexus/README.md#large-files-are-being-skipped) |
149
+ | Native install fails (`@ladybugdb/core`, `tree-sitter-*`) | The plugin runs `npm install --prefix …`; it needs a C++ toolchain and a reachable registry. Run the manual command from **Getting GitNexus** to see the compiler error. | [`gitnexus/README.md` — Installation fails with native module errors](https://github.com/abhigyanpatwari/GitNexus/blob/main/gitnexus/README.md#installation-fails-with-native-module-errors) |
150
+ | The panel does not appear at all | Check that `dsh plugin add` succeeded and DSH was restarted; open it from the sidebar's **+** guide page. For the `desktop` profile, use the Web Plugins page. | This plugin's install path; no upstream GitNexus path. |
151
+
152
+ ## Upstream GitNexus documentation
153
+
154
+ This README describes the plugin, not GitNexus. GitNexus behavior follows its source docs.
155
+ Repository: [`abhigyanpatwari/GitNexus`](https://github.com/abhigyanpatwari/GitNexus)
156
+ (branch `main`).
157
+
158
+ | Topic | Path |
159
+ | --- | --- |
160
+ | Install, CLI, environment variables, MCP | [`README.md`](https://github.com/abhigyanpatwari/GitNexus/blob/main/README.md) |
161
+ | CLI package, requirements, full Troubleshooting | [`gitnexus/README.md`](https://github.com/abhigyanpatwari/GitNexus/blob/main/gitnexus/README.md) |
162
+ | Index stale, clean slate, locks, memory | [`RUNBOOK.md`](https://github.com/abhigyanpatwari/GitNexus/blob/main/RUNBOOK.md) |
163
+ | Architecture and data flow | [`ARCHITECTURE.md`](https://github.com/abhigyanpatwari/GitNexus/blob/main/ARCHITECTURE.md) |
164
+ | Tests and guardrails | [`TESTING.md`](https://github.com/abhigyanpatwari/GitNexus/blob/main/TESTING.md), [`GUARDRAILS.md`](https://github.com/abhigyanpatwari/GitNexus/blob/main/GUARDRAILS.md) |
165
+ | CLI command reference | [`gitnexus/skills/gitnexus-cli.md`](https://github.com/abhigyanpatwari/GitNexus/blob/main/gitnexus/skills/gitnexus-cli.md) |
166
+ | Language-specific notes | [`docs/languages/`](https://github.com/abhigyanpatwari/GitNexus/tree/main/docs/languages) |
167
+
168
+ Local `.docs/` notes are gitignored; the links above are the published source of truth.
169
+
170
+ ## Maintenance commands
171
+
172
+ The panel shows and runs more than a bare `gitnexus analyze`:
173
+
174
+ ```powershell
175
+ $env:GITNEXUS_MEMORY='off'; $env:NODE_OPTIONS='--max-old-space-size=8192'; `
176
+ $env:GITNEXUS_HOME='<repo>/.gitnexus/plugin-home'; `
177
+ gitnexus analyze --index-only '<repo>'
372
178
  ```
373
- $env:GITNEXUS_MEMORY='off'; $env:NODE_OPTIONS='--max-old-space-size=8192'; \
374
- gitnexus analyze --index-only '<project>'
375
179
 
376
- $env:GITNEXUS_MEMORY='off'; $env:NODE_OPTIONS='--max-old-space-size=8192'; \
377
- gitnexus analyze --index-only --force '<project>'
378
- ```
180
+ Add `--force` for a full rebuild.
379
181
 
380
- - `GITNEXUS_MEMORY=off` — the CLI otherwise re-spawns itself with a larger heap over
381
- piped stdio, which a confined sandbox denies (`spawn EPERM`).
182
+ - `GITNEXUS_MEMORY=off` — stops the CLI from re-spawning itself over piped stdio, which a
183
+ confined sandbox denies (`spawn EPERM`).
382
184
  - `NODE_OPTIONS=--max-old-space-size=8192` — supplies the heap that respawn wanted.
383
- - `--index-only` — the default `analyze` also rewrites `AGENTS.md`, `CLAUDE.md` and
384
- agent skill files inside your repository. A maintenance action must not edit the
385
- working tree.
386
-
387
- `--skip-fts` is **no longer** part of either command. Measured on a 39-file repository,
388
- disabling a search index the store already has forces a full graph-store rebuild —
389
- 179.22 s against 8.57 s, a 21× penalty on the transition an operator is most likely to
390
- hit, and the opposite of incremental. Letting FTS fail on its own costs nothing: it
391
- prints a warning and indexes anyway.
392
-
393
- The panel prints these rationales next to the commands, so they do not look
394
- arbitrary. `src/gitnexus/commands.js` is pure and asserted verbatim by tests.
395
-
396
-
397
- The CLI cannot manage the `desktop` profile — Electron owns it. Use the Web
398
- sidebar's Plugins page there. `web` is CLI-managed:
399
-
400
- ```sh
401
- dsh plugin --profile web add <absolute path to this package>
402
- dsh --profile web --dump-config | grep gitnexus-plus # layer composes
403
- dsh --profile web # restart (bundle set changed)
404
- ```
405
-
406
- `dsh plugin add` also adds the package to `dsh.profile.bundles` automatically,
407
- because this package declares `dsh.bundle`.
408
-
409
- ## Known limits
410
-
411
- - **A machine without GitNexus is not detected yet.** The plugin declares no runtime
412
- dependencies and never imports `gitnexus`; it reads an index another tool produced
413
- and, when it can, deep-imports the upstream scan primitives at runtime. That design
414
- keeps it a pure observer, but it makes "the operator has no GitNexus" a reachable
415
- state. `src/gitnexus/toolchain.ts` implements a three-state probe (`ready` /
416
- `library-only` / `absent`, separating "the library tree exists" from "a CLI is on
417
- PATH", because they gate different promises), and the refresh runner now consults it
418
- **before spawning anything**: with no CLI it reports `unavailable` and tells the
419
- operator to install one, rather than starting a process that cannot work. The engine
420
- also degrades correctly on its own — `scan.ts` falls back to its own walker and
421
- reports `primitives: 'fallback'`, and the built-in size caps apply.
422
- - **A report that reused GitNexus's scan rules and one that fell back to an
423
- approximation are still not distinguished inside the report itself.** The toolchain
424
- verdict now travels with it, so the panel knows whether GitNexus is present and says so
425
- — but the per-file numbers do not carry a provenance marker, so a fallback walk is not
426
- labelled as one where the numbers are shown. The built-in walker deliberately does
427
- **not** implement upstream's ignore rules faithfully, and its uncovered-file count can
428
- therefore carry false positives.
429
- - **Installing GitNexus from the panel has never been run against a real network.** The
430
- command shape is verified (`npm install --prefix … --no-audit --no-fund`, no hardcoded
431
- registry), the runner's state machine is covered by fourteen assertions, and the
432
- failure paths name the two likely causes — unreachable registry, missing C++ toolchain.
433
- What is **not** verified is the download and compile itself: it is several hundred
434
- megabytes and was never executed from inside a confined DSH process. Treat the first
435
- authorised install on any machine as untested, and fall back to the manual command if
436
- it fails — which is why that command is offered first.
437
- - **`--omit=optional` saves about 486 MB of that install, and is not used by default.**
438
- Measured: a full GitNexus tree is 998.9 MB, and omitting the optional dependencies
439
- gives 513.2 MB by dropping `onnxruntime-node` (287 MB), `onnxruntime-web` (139 MB) and
440
- `@huggingface/transformers`. Those serve vector search and embeddings, which this
441
- plugin never enables and reports as `unavailable`. The default does not pass the flag
442
- because the plugin cannot verify that analysis still succeeds without them on every
443
- platform, and a refresh that fails in an unexplained way is worse than one that is
444
- large. A deployment that wants the smaller tree can set `gitnexusInstallDir` aside and
445
- install by hand with `--omit=optional`.
446
- - **The refresh runs outside the conversation, and that has a real consequence.** A
447
- command started from the panel goes through `ctx.shell` and is confined exactly as
448
- your own shell commands are, but it is **not** a tool call: it writes no
449
- `approval/asked` + `approval/decided` pair into the session log, and it does not
450
- appear in the transcript. That pair could not be written even if it were wanted —
451
- `ApprovalService.request()` requires an open turn and throws without one, which is
452
- also why there is nothing to approve: the command does not escalate. The audit record
453
- is the run state the panel holds, which is per-process and is not persisted. If you
454
- want a refresh on the conversation's record, run the handed-over command in the
455
- session instead; that path is unchanged.
456
- - **Walk cost scales with file count.** ~29 000 files takes ~1.4 s warm, ~13 s on a
457
- cold filesystem cache. The host half caches reports for 15 s; a panel that polls
458
- faster than that gains nothing.
459
- - **The minified heuristic reads a 64 KB head and extrapolates.** It flags
460
- single-line bundles reliably and correctly *declines* generated-but-multi-line
461
- output (verified: a 2.3 MB, 75 263-line file averages 31 chars/line). The
462
- generated-path heuristic covers that gap, as a hint rather than a verdict.
463
- - **Binary assets are detected and reported separately, and that is not cosmetic.**
464
- A first revision tested only "no newlines ⇒ one enormous line", so a real 380 MB
465
- `.glb` was reported as *"single-line ≈ 399 230 584 chars — probably minified
466
- rather than source"*. The number was absurd; the conclusion was worse, because it
467
- implied that 97 % of one repository's skipped bytes were compressed **source**
468
- when 414 of 417 MB were 3D models that could never hold a symbol. Detection is
469
- git's own rule (a NUL byte in the head means binary), plus a control-byte ratio;
470
- binary short-circuits both the minified and generated claims, and the headline
471
- warning now separates binary from text so the figure worth acting on is visible.
472
- Verified end to end on the repository that exposed it: the actionable remainder
473
- went from an implied 416.9 MB to **2.6 MB**.
474
- - **`git ls-tree` is not used.** An earlier design compared the index against
475
- git-tracked files; real data killed it — 8 of the "missing" tracked files in a
476
- 37-file repo were dotfiles excluded by the walker's `dot: false`, and 2 indexed
477
- files were untracked. The walker's own rules are the only honest denominator.
478
- - **Panel effects and re-render are untested.** `react-dom` is not installed on
479
- this machine, so rendering uses a single-pass shim: `useState` yields its initial
480
- value and `useEffect` never runs. The pure view is covered; the fetch lifecycle
481
- is not.
482
- - **No incremental update yet.** This ships the read-only monitoring half of the
483
- plan. Driving `analyze` is a separate concern with its own safety story — if
484
- nothing else, a status check must never start a 30-second rebuild.
185
+ - `GITNEXUS_HOME` — redirects the global registry write into the project, so a failed
186
+ write to `~/.gitnexus` cannot leave the index stuck at `incremental-in-progress`.
187
+ - `--index-only` — otherwise `analyze` rewrites `AGENTS.md`, `CLAUDE.md` and skill files
188
+ inside the repository.
189
+
190
+ `--skip-fts` is **adaptive per index**: no flag when the manifest says FTS is available,
191
+ and the flag when it is not. `skipFts: true` can force the flag; there is no config that
192
+ forces FTS on, because enabling it is a repair (`gitnexus analyze --repair-fts`), not an
193
+ incremental refresh.
194
+
195
+ ## License (read before commercial use)
196
+
197
+ This plugin is **MIT** (see [LICENSE](LICENSE)).
198
+
199
+ **GitNexus is `PolyForm-Noncommercial-1.0.0`**: noncommercial use is granted, commercial
200
+ use is restricted. `gitnexus` is a **peer**; this package does not install, bundle or
201
+ redistribute it. But using this plugin's GitNexus-backed features (reading an index,
202
+ refreshing it, installing it) puts **your use of GitNexus** under GitNexus's license;
203
+ commercial use needs a separate grant from GitNexus's author:
204
+
205
+ <https://github.com/abhigyanpatwari/GitNexus/blob/main/LICENSE>
206
+
207
+ In one line: **MIT covers this plugin's code; GitNexus's license covers GitNexus, and using
208
+ the related features puts that use under it.**
209
+
210
+ ## Boundaries
211
+
212
+ - Coverage and search are read-only; maintenance is a separately confirmed write and
213
+ never starts by itself.
214
+ - The plugin reports facts about a GitNexus index; it does not rewrite the parser or
215
+ reimplement the graph database.
216
+ - Graph search matches names/paths, not bodies; the text fallback matches lines and is
217
+ capped.
218
+ - The source fallback only covers files in the index manifest; refresh the index for new
219
+ files.
220
+ - Deeper design/build notes are kept out of the public README; this file stays at the
221
+ "what it does" and "how to fix it" level.