dsh-code-index 0.8.0 → 0.9.1
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/CHANGELOG.md +20 -0
- package/README.md +83 -65
- package/README.zh.md +85 -47
- package/dist/index.d.ts +634 -0
- package/dist/index.js +516 -198
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/scripts/context-pack-demo.mjs +49 -0
- package/scripts/process-desktop-demo.py +88 -0
- package/scripts/release-smoke.mjs +34 -1
- package/scripts/render-agent-demo.py +87 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to dsh-code-index are documented here.
|
|
4
4
|
|
|
5
|
+
## 0.9.1 — Gitignore directory whitelist fix (2026-10-10)
|
|
6
|
+
|
|
7
|
+
- Fix Gitignore directory whitelist rules (`!dir/`) silently excluding source trees: directory probes now retain their trailing slash in both the scanner and watcher. Thanks to @bbskye5008 for the detailed report and reproduction in [Issue #2](https://github.com/lemonxiny55/dsh-code-index/issues/2).
|
|
8
|
+
- Apply nested `.gitignore` precedence consistently, while preserving Git's rule that files inside an ignored parent directory cannot be re-included. Add regressions for source/context retrieval, affected tests, and external add/change/delete freshness.
|
|
9
|
+
- Verified on Node 22/24 and with a real DSH Desktop Agent using the packaged candidate. See `RELEASE_EVIDENCE_v0.9.1.md` for methods, results and publication status.
|
|
10
|
+
|
|
11
|
+
## 0.9.0 — Edit-ready Context Packs (2026-10-05)
|
|
12
|
+
|
|
13
|
+
- `code_context` now includes bounded, whole-line source excerpts for primary declarations, strong callers/callees, imports, likely tests and changes. Overlapping current/base ranges are deduplicated independently. Large declarations degrade to changed-line windows, then signature-only metadata.
|
|
14
|
+
- One final ContextPack DTO selects candidates before presentation; both text and serialized pack respect the normalized hard character budget. Default canonical output stays a string; explicit `outputFormat: pack` enables structured output.
|
|
15
|
+
- Inclusion reasons remain separate from exact/import-scoped/name-only relationship provenance. Missing or stale evidence is reported rather than fabricated.
|
|
16
|
+
- Git symbol classification now distinguishes added/modified/deleted against a frozen commit baseline, including the betaCaller addition regression. Ambiguous identity is unclassified; reliable file renames are retained, and symbol renames are not inferred.
|
|
17
|
+
- Deterministic camel/snake, filename/path/signature terms, bounded graph neighborhoods, and clean-tree test seeds improve task selection. No BM25 or architecture rewrite.
|
|
18
|
+
- Added executable context-quality contracts for task recall, source evidence, noise exclusion, budget, isolation, worktrees, freshness, overlap and classification.
|
|
19
|
+
- Development target moves to matching DSH/dsh-tools `0.2.0-rc.2`. Full/compact surfaces, v0.8 configuration, Node 22/24, local-first behavior, and text calls remain supported. Public declaration files are now included in the package.
|
|
20
|
+
- Synced English/Chinese product docs and added a reproducible 30-second recording of real local tool calls. Web Context Card is deferred; Card replay/navigation remain unverified. No Card screenshot or benchmark claim is made.
|
|
21
|
+
- Final DSH Desktop `0.2.0-rc.2` real Agent verification passed: default text and explicit pack calls, bounded source/reasons/provenance, related tests, change classification and external freshness. The npm package was published manually on 2026-10-05.
|
|
22
|
+
|
|
23
|
+
See `RELEASE_EVIDENCE_v0.9.0.md` for verified checks and release boundaries.
|
|
24
|
+
|
|
5
25
|
## 0.8.0 — 2026-09-23
|
|
6
26
|
|
|
7
27
|
### Added
|
package/README.md
CHANGED
|
@@ -5,11 +5,68 @@
|
|
|
5
5
|
|
|
6
6
|
English | [中文](README.zh.md)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
**v0.9.0 — Edit-ready Context Packs**
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
Give your [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) agent the bounded source context it needs to start a code task. One `code_context` call selects primary declarations, strong callers/callees, imports, current changes, and likely tests, with exact source ranges and reasons for inclusion. When evidence is missing, the pack says so.
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
- **Source within budget:** complete declarations, then whole-line windows, then explicit signature-only fallback. Overlapping source lines are deduplicated; current and baseline excerpts stay separate.
|
|
13
|
+
- **One selected pack:** text and opt-in structured output consume the same final ContextPack. Both stay within the default 5000-character cap.
|
|
14
|
+
- **Evidence you can inspect:** inclusion reasons are separate from `exact` / `import-scoped` / `name-only` relationship provenance. No probability or confidence estimate is invented.
|
|
15
|
+
- **Local and current:** isolated repo/worktree indexes, external add/change/delete freshness, no external indexing API key. Existing full/compact surfaces and v0.8 configuration remain supported.
|
|
16
|
+
|
|
17
|
+
v0.9.0 is published on npm and passed real Agent verification in DSH Desktop `0.2.0-rc.2`. See [release evidence](RELEASE_EVIDENCE_v0.9.0.md).
|
|
18
|
+
|
|
19
|
+
## On this page
|
|
20
|
+
|
|
21
|
+
- [🚀 Quick start](#quick-start)
|
|
22
|
+
- [🧭 Project isolation and live updates](#project-isolation-and-live-updates)
|
|
23
|
+
- [👀 See it in action](#see-it-in-action)
|
|
24
|
+
- [🧰 Tools](#tools)
|
|
25
|
+
- [Configuration](#configuration)
|
|
26
|
+
- [Supported languages](#supported-languages)
|
|
27
|
+
- [How it works](#how-it-works)
|
|
28
|
+
- [Known limitations](#known-limitations)
|
|
29
|
+
- [Feedback](#feedback)
|
|
30
|
+
|
|
31
|
+
## Quick start
|
|
32
|
+
|
|
33
|
+
Requires Node 22/24 and a matching DSH `0.2.0-rc.2` host group. Install the published version into a Web profile:
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
npx @deepseek-ai/dsh@0.2.0-rc.2 plugin --profile web add dsh-code-index@0.9.0
|
|
37
|
+
npx @deepseek-ai/dsh@0.2.0-rc.2 web
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
For local development, run `pnpm install` and `pnpm build` at the repository root, then use `plugin --profile web add .`. See [Install](#install) for profile options.
|
|
41
|
+
|
|
42
|
+
## Project isolation and live updates
|
|
43
|
+
|
|
44
|
+
```text
|
|
45
|
+
Open repo A → search finds A's symbols
|
|
46
|
+
Switch to repo B → search finds B's symbols, not A's
|
|
47
|
+
Edit files outside DSH → the next query sees the change
|
|
48
|
+
Switch back to A → A's context is still isolated
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Each Git worktree gets its own index and change state. The plugin watches projects accessed by the session and checks file metadata on tool calls, so additions, edits, and deletions become visible without a manual rebuild.
|
|
52
|
+
|
|
53
|
+
## See it in action
|
|
54
|
+
|
|
55
|
+
**42 seconds in DSH Desktop: why did loading `' input '` produce `'INPUT'`?**
|
|
56
|
+
|
|
57
|
+

|
|
58
|
+
|
|
59
|
+
One real `code_context` call returned `loadConfig` at `src/config.ts:1–3`, its callers, Git additions/modifications/deletions, and a likely test, with inclusion reasons and relationship provenance: **2347/5000 characters**. The Agent used that context to identify `.toUpperCase()` as the cause.
|
|
60
|
+
|
|
61
|
+
This is **actual desktop footage recorded on 2026-10-08**, using the installed v0.9.0 plugin and a tiny demonstration repository. Only DSH is shown; waiting was cut and audio removed. No files were edited or tests run. The clip is not a latency measurement or a claim that a fix/tests succeeded. [MP4](assets/desktop-agent-v090.mp4) · [Recording notes and provenance](assets/desktop-agent-v090.md) · [Actual tool-card evidence](assets/desktop-agent-v090.evidence.json).
|
|
62
|
+
|
|
63
|
+
The earlier [bilingual terminal replay](assets/agent-context-demo.md) remains available as a separate, clearly labeled replay of audited 2026-10-05 Agent records. It also shows external-edit freshness and a 500-character signature-only fallback.
|
|
64
|
+
|
|
65
|
+
Try asking: **“Use code_context to locate a config-loading bug, show the relevant source and callers, and identify likely tests.”** Tell us what helped or what context was missing in the [DSH discussion](https://github.com/deepseek-ai/deepseek-harness/discussions/5623).
|
|
66
|
+
|
|
67
|
+
The earlier [30-second local tool demo](assets/context-pack-demo.html) remains available and can be reproduced with `pnpm build`, then `node scripts/context-pack-demo.mjs`. Web Context Card remains deferred; Card replay and file navigation have not been verified.
|
|
68
|
+
|
|
69
|
+
## Tools
|
|
13
70
|
|
|
14
71
|
| Tool | Purpose |
|
|
15
72
|
|---|---|
|
|
@@ -19,37 +76,28 @@ Fits a niche the ecosystem took a while to fill: alongside git/voice/browser/mem
|
|
|
19
76
|
| `code_map` | Bounded ranked repo map (top files by symbol density + import-graph PageRank, key symbols + lines) |
|
|
20
77
|
| `code_refs` | Trace a symbol through the call graph: callers (who calls it) and callees (what it calls), resolved to file:line |
|
|
21
78
|
| `code_change_context` | Start from the working-tree or an explicit diff and return changed symbols, callers, import dependents, bounded impact paths, and likely tests |
|
|
22
|
-
| `code_context` |
|
|
79
|
+
| `code_context` | Edit-ready ContextPack: bounded source, reasons, relationships, changes/tests, gaps, and a hard budget; text by default |
|
|
23
80
|
| `code_health` | Opt-in (`codeHealth: true`): circular dependencies (import cycles) and orphan modules |
|
|
24
81
|
|
|
25
82
|
Plus an optional **auto-injected system prompt section** (`code-index:repo-map`, order 60): a compact ranked map selected from the active DSH session workspace. Set `autoInject: false` to disable and rely on the `code_map` tool only.
|
|
26
83
|
|
|
27
|
-
## Project-aware live context
|
|
28
|
-
|
|
29
|
-
```text
|
|
30
|
-
Open repo A → code_context uses A
|
|
31
|
-
Switch to repo B → code_context automatically uses B
|
|
32
|
-
Edit repo B from VS Code → the next code_context sees the new state
|
|
33
|
-
Switch back to repo A → A's symbols and Git changes remain isolated
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
Each Git worktree gets its own index and change state. The plugin keeps contexts for up to four recently used projects and watches only projects a session has accessed. Filesystem events are coalesced; tool calls also scan current file metadata and reparse changed files before returning context.
|
|
37
|
-
|
|
38
84
|
## Install
|
|
39
85
|
|
|
40
86
|
Requires `dsh` (any install path — npx, npm, or source) and Node ≥ 22.
|
|
41
87
|
|
|
42
|
-
The development compatibility target is `@deepseek-ai/dsh@0.
|
|
88
|
+
The development compatibility target is `@deepseek-ai/dsh@0.2.0-rc.2` / `@deepseek-ai/dsh-tools@0.2.0-rc.2` (Node 22 and 24 CI matrix). The DSH plugin surface is still a preview API, so upstream changes may require compatibility updates.
|
|
89
|
+
|
|
90
|
+
v0.9 requires the matching `0.2.0-rc.2` tool runtime; the peer pin prevents fresh npm installs from selecting the older registry `latest` tag. Upgrade the host group together. The text/config/tool-surface compatibility above does not promise support for older DSH APIs.
|
|
43
91
|
|
|
44
92
|
```sh
|
|
45
93
|
# from npm (prebuilt)
|
|
46
|
-
npx @deepseek-ai/dsh plugin --profile web add dsh-code-index
|
|
94
|
+
npx @deepseek-ai/dsh@0.2.0-rc.2 plugin --profile web add dsh-code-index@0.9.0
|
|
47
95
|
|
|
48
96
|
# or from a directory containing this checkout
|
|
49
|
-
npx @deepseek-ai/dsh plugin --profile web add ./dsh-code-index
|
|
97
|
+
npx @deepseek-ai/dsh@0.2.0-rc.2 plugin --profile web add ./dsh-code-index
|
|
50
98
|
```
|
|
51
99
|
|
|
52
|
-
Restart the Web UI (`npx @deepseek-ai/dsh web`) — startup logs confirm each tool:
|
|
100
|
+
Restart the Web UI (`npx @deepseek-ai/dsh@0.2.0-rc.2 web`) — startup logs confirm each tool:
|
|
53
101
|
|
|
54
102
|
```
|
|
55
103
|
[dsh-code-index] plugin loaded
|
|
@@ -72,61 +120,29 @@ In a workspace session, ask the agent:
|
|
|
72
120
|
|
|
73
121
|
No API key is needed to *index*; the model must of course be configured to call the tools.
|
|
74
122
|
|
|
75
|
-
##
|
|
76
|
-
|
|
77
|
-
User prompt:
|
|
78
|
-
|
|
79
|
-
> Which repo are we in? Run `code_map` first, then find where `extractSymbols` is defined.
|
|
80
|
-
|
|
81
|
-
The agent calls the tools in turn:
|
|
82
|
-
|
|
83
|
-
```
|
|
84
|
-
code_map
|
|
85
|
-
# repo map
|
|
86
|
-
## src/extract.ts (14)
|
|
87
|
-
function extractSymbols(code, id) :121
|
|
88
|
-
function languageForFile(filePath) :37
|
|
89
|
-
...
|
|
90
|
-
|
|
91
|
-
code_search { query: "extractSymbols" }
|
|
92
|
-
export function extractSymbols(code, id) — src/extract.ts:121
|
|
93
|
-
```
|
|
123
|
+
## More capabilities
|
|
94
124
|
|
|
95
125
|
The index builds lazily on first use; later calls are served from the on-disk cache with mtime-incremental refresh.
|
|
96
126
|
|
|
97
127
|
### Call graph
|
|
98
128
|
|
|
99
|
-
`code_refs` traces
|
|
129
|
+
`code_refs` traces definitions, callers, and callees. The following is an earlier real example of that existing tool, not a v0.9 Context Card:
|
|
100
130
|
|
|
101
|
-

|
|
102
132
|
|
|
103
133
|
### Change-aware context
|
|
104
134
|
|
|
105
135
|
`code_change_context` defaults to the current Git working tree against `HEAD`. It also accepts an inline unified diff, repo-relative `files`, or stable `symbols` IDs. Results are bounded and each inferred relationship carries a provenance label: `exact`, `import-scoped`, or `name-only`. Deletions and renames use the baseline ref when available; untracked non-ignored files are included in working-tree mode.
|
|
106
136
|
|
|
107
|
-
###
|
|
137
|
+
### Edit-ready Context Packs
|
|
108
138
|
|
|
109
|
-
`code_context`
|
|
139
|
+
`code_context` routes change, symbol, architecture, test, exploration, and ambiguous tasks. Deterministic camel/snake terms plus file/path/signature terms rank candidates; exact named symbols are retained before selection. Strong primary seeds find likely tests even on a clean tree. Graph neighborhoods are bounded. BM25 is not used.
|
|
110
140
|
|
|
111
|
-
|
|
112
|
-
code_context { task: "Fix duplicate configuration loading during startup" }
|
|
113
|
-
|
|
114
|
-
Task context — change
|
|
115
|
-
Primary symbols:
|
|
116
|
-
- [exact] function loadConfig() — src/config.ts:42
|
|
117
|
-
Relevant files:
|
|
118
|
-
- src/config.ts (current change)
|
|
119
|
-
- src/bootstrap.ts (entry path)
|
|
120
|
-
Relationships:
|
|
121
|
-
- bootstrap → loadConfig at src/bootstrap.ts:18 [exact; explicit-import-binding]
|
|
122
|
-
Current changes:
|
|
123
|
-
- modified function loadConfig() src/config.ts:42 [exact]
|
|
124
|
-
Likely affected tests:
|
|
125
|
-
- tests/config.spec.ts
|
|
126
|
-
Budget: 3720 / 5000 chars
|
|
127
|
-
```
|
|
141
|
+
`budgetChars` defaults to 5000 and is normalized to 300–20000; `maxFiles` defaults to 12 and `maxSymbols` to 10. Budget units are JavaScript string characters, not tokens or UTF-8 bytes. Both rendered text and serialized final pack must fit. Code is never cut mid-line to fill the cap. Very small budgets can leave only signatures or gaps; a repository identity that cannot fit produces an explicit error. Task display is summarized to 120 characters without affecting routing.
|
|
128
142
|
|
|
129
|
-
The
|
|
143
|
+
The default canonical return remains a **string**. Request `outputFormat: "pack"` explicitly for the exported `ContextPack` DTO. Its `items` are already selected, with source `file/startLine/endLine/side/ref/mode/code`, `reason`, and separate relationship `resolution/provenance` where relevant. `budget.usedChars` accounts for text; `budget.packChars` accounts for serialized JSON. Render with `renderContextPack`; no hidden candidate list is exposed through the result.
|
|
144
|
+
|
|
145
|
+
Git changes with a readable, frozen baseline commit classify declarations as added/modified/deleted. Reliable file renames remain supported. Unknown or ambiguous structural identity is `unclassified`; symbol renames are not guessed. Explicit `files`/`symbols` in `code_change_context` remain selection modes, not a proof of a Git modification.
|
|
130
146
|
|
|
131
147
|
## Configuration
|
|
132
148
|
|
|
@@ -166,7 +182,7 @@ TypeScript, JavaScript, Python, Go, Rust, Java, C++ and C (`.ts .tsx .mts .cts .
|
|
|
166
182
|
- **Repo map** (`src/repomap.ts`): personalized PageRank over the import graph (teleport = per-file density share, so hub files that are themselves imported by other hubs rise above flat in-degree counting), seeded by the density-aware file score (class/interface/function weighted, test paths damped), top-N files, per-file symbol cap, hard char truncation.
|
|
167
183
|
- **Call graph** (`src/refgraph.ts`): call sites extracted per file (per language, with their enclosing function) are resolved by name into callers and callees — `code_refs` exposes this directly, and `code_search` uses call fan-in as a ranking tie-break.
|
|
168
184
|
- **Change context** (`src/change-context.ts`): maps Git hunks to stable symbols, then follows bounded provenance-labeled callers, import dependents, entry paths, impact, and likely affected tests without returning the whole repository.
|
|
169
|
-
- **
|
|
185
|
+
- **ContextPack** (`src/context.ts`, `src/context-pack.ts`, `src/source-excerpts.ts`): ranks task candidates, reads ephemeral source evidence, selects a final DTO under text/JSON budgets, then renders only selected items.
|
|
170
186
|
- **Health** (`src/health.ts`): Tarjan SCC over the import graph yields circular dependencies; orphan-module detection lists symbol-bearing files with no inbound or outbound imports (entry points and tests excluded).
|
|
171
187
|
- **Workspace resolution**: each tool resolves the session cwd (`agent.session.header.cwd`) and walks up to the nearest `.git` (bounded — a directory without a repo marker is never indexed).
|
|
172
188
|
- **Project contexts** (`src/repo-context.ts`): canonical real paths identify separate worktrees; up to four contexts are retained. Each tool call scans current metadata and reparses only changed files, while the watcher refreshes dirty files after a bounded debounce.
|
|
@@ -177,10 +193,9 @@ TypeScript, JavaScript, Python, Go, Rust, Java, C++ and C (`.ts .tsx .mts .cts .
|
|
|
177
193
|
- **web-tree-sitter pinned to `^0.25` (ESM)** — the 0.25 line uses ESM named exports (`Language`/`Query`); this pairing with `tree-sitter-wasms` static builds is verified working under Node ≥ 22/24.
|
|
178
194
|
- Auto-injected maps use DSH's system-prompt assembly context for the active session. Agentless assembly falls back to the DSH process working directory. A newly accessed project may have an empty map on its first prompt while indexing completes; following assemblies receive its map.
|
|
179
195
|
- The watcher starts only for projects accessed by a tool and is disposed with the plugin. With `externalWatch: false`, per-call metadata scans still detect ordinary mtime changes.
|
|
180
|
-
- The preview DSH API is typechecked and exercised through package-level lifecycle fakes; a real DSH Web install/enable/disable run is a separate release gate.
|
|
181
196
|
- Large monorepos still require a directory metadata scan on each tool call. File parsing is incremental, but scan latency depends on repository size and storage speed.
|
|
182
|
-
-
|
|
183
|
-
-
|
|
197
|
+
- Function-local variables are excluded. Module declarations and class members are indexed; a parser/graph is not a type checker.
|
|
198
|
+
- Source reads reject files changed after the index snapshot, paths resolving outside the root, and current files over 1 MB. Signature-only fallbacks and gaps identify missing evidence; likely tests are leads, not proof of coverage.
|
|
184
199
|
|
|
185
200
|
## Development
|
|
186
201
|
|
|
@@ -205,8 +220,11 @@ It re-points every dead link at its real `.pnpm` store entry as a junction; safe
|
|
|
205
220
|
|
|
206
221
|
## Feedback
|
|
207
222
|
|
|
208
|
-
|
|
223
|
+
Used dsh-code-index? Tell me what helped, what broke, or what context it missed. Reply in the [official DSH plugin discussion](https://github.com/deepseek-ai/deepseek-harness/discussions/5623), or use the [feedback issue form](https://github.com/lemonxiny55/dsh-code-index/issues/new?template=feedback.yml) if issue submissions are enabled for the repository.
|
|
224
|
+
|
|
225
|
+
To make a report actionable, include the approximate repository size and languages, the task you tried, the context you expected, and what the agent actually received. Mention whether project switching, a worktree, or an external file edit was involved. Please do not include private source code, credentials, or API keys.
|
|
209
226
|
|
|
210
227
|
## License
|
|
211
228
|
|
|
212
229
|
MIT. Not affiliated with DeepSeek; built on the public `dsh` plugin surface.
|
|
230
|
+
|
package/README.zh.md
CHANGED
|
@@ -2,11 +2,68 @@
|
|
|
2
2
|
|
|
3
3
|
[English](README.md) | 中文
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**v0.9.0 — Edit-ready Context Packs**
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
让 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) Agent 用一次 `code_context` 调用拿到开始处理任务所需的有界源码上下文:主要声明、强相关 caller/callee、imports、当前变化和相关测试。每个关键 item 都有入选理由,源码有准确行号;证据不足时明确说明缺口。
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
- **预算内直接给源码:**完整声明 → 整行窗口 → 明确的 signature-only 降级。重叠源码行去重,current/base 分开。
|
|
10
|
+
- **唯一最终 pack:**文本与显式 structured output 都基于预算选择后的 ContextPack;默认硬上限 5000 字符。
|
|
11
|
+
- **可检查的证据:**入选 reason 与关系的 `exact` / `import-scoped` / `name-only` provenance 分开,不编造概率或 confidence。
|
|
12
|
+
- **本地、隔离、实时:**repo/worktree 独立,外部增改删自动刷新,不需要外部索引 API key;保留 full/compact surface 和 v0.8 配置。
|
|
13
|
+
|
|
14
|
+
v0.9.0 已发布到 npm,并通过 DSH Desktop `0.2.0-rc.2` 真实 Agent 验证。验证边界见[release evidence](RELEASE_EVIDENCE_v0.9.0.md)。
|
|
15
|
+
|
|
16
|
+
## 本页导航
|
|
17
|
+
|
|
18
|
+
- [🚀 快速开始](#快速开始)
|
|
19
|
+
- [🧭 项目隔离与实时更新](#项目隔离与实时更新)
|
|
20
|
+
- [👀 实际效果](#实际效果)
|
|
21
|
+
- [🧰 工具一览](#工具一览)
|
|
22
|
+
- [配置](#配置)
|
|
23
|
+
- [支持的语言](#支持的语言)
|
|
24
|
+
- [工作原理](#工作原理)
|
|
25
|
+
- [已知限制](#已知限制)
|
|
26
|
+
- [反馈](#反馈)
|
|
27
|
+
|
|
28
|
+
## 快速开始
|
|
29
|
+
|
|
30
|
+
需要 Node 22/24 与匹配的 DSH `0.2.0-rc.2` 宿主版本组。将已发布版本安装到 Web profile:
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
npx @deepseek-ai/dsh@0.2.0-rc.2 plugin --profile web add dsh-code-index@0.9.0
|
|
34
|
+
npx @deepseek-ai/dsh@0.2.0-rc.2 web
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
本地开发时,在仓库根目录运行 `pnpm install`、`pnpm build`,然后使用 `plugin --profile web add .`。其他 profile 选项见[安装说明](#安装)。
|
|
38
|
+
|
|
39
|
+
## 项目隔离与实时更新
|
|
40
|
+
|
|
41
|
+
```text
|
|
42
|
+
打开仓库 A → 搜索到 A 的符号
|
|
43
|
+
切换到仓库 B → 搜索到 B 的符号,不会混入 A
|
|
44
|
+
从 DSH 外部修改文件 → 下一次查询看到变化
|
|
45
|
+
切回 A → A 的上下文仍然独立
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
每个 Git worktree 都有独立索引和变更状态。插件会监听会话访问过的项目,并在工具调用时检查文件元数据,因此新增、修改和删除都会自动反映到后续查询,无需手动重建。
|
|
49
|
+
|
|
50
|
+
## 实际效果
|
|
51
|
+
|
|
52
|
+
**42 秒真实 DSH 桌面演示:加载 `' input '` 为什么变成了 `'INPUT'`?**
|
|
53
|
+
|
|
54
|
+

|
|
55
|
+
|
|
56
|
+
一次真实 `code_context` 调用返回 `src/config.ts:1–3` 的 `loadConfig`、调用方、Git 增改删和相关测试线索,附入选理由与关系来源,共 **2347/5000 字符**。Agent 据此定位到改变大小写的 `.toUpperCase()`。
|
|
57
|
+
|
|
58
|
+
这是 **2026-10-08 新录制的真实桌面画面**,使用已安装的 v0.9.0 与一个小演示仓库。只展示 DSH,剪去等待并移除音轨;没有修改文件或运行测试,不代表实际耗时,也不宣称修复或测试成功。[MP4 视频](assets/desktop-agent-v090.mp4) · [录制与来源说明](assets/desktop-agent-v090.md) · [实际工具卡片证据](assets/desktop-agent-v090.evidence.json)。
|
|
59
|
+
|
|
60
|
+
先前的[中英终端回放](assets/agent-context-demo.md)继续保留,单独标明来自 2026-10-05 的真实 Agent 记录,补充展示外部编辑刷新及 500 字符下的签名降级。
|
|
61
|
+
|
|
62
|
+
可以先试一句:**“用 code_context 定位一个配置加载 Bug,给出相关源码、调用者和可能受影响的测试。”** 欢迎在 [DSH Discussion](https://github.com/deepseek-ai/deepseek-harness/discussions/5623) 分享哪些上下文有帮助、哪些被漏掉。
|
|
63
|
+
|
|
64
|
+
早期的 [30 秒本地工具演示](assets/context-pack-demo.html) 仍然保留,可用 `pnpm build` 后运行 `node scripts/context-pack-demo.mjs` 复现。Web Context Card 继续延期,Card replay 和文件跳转尚未验证。
|
|
65
|
+
|
|
66
|
+
## 工具一览
|
|
10
67
|
|
|
11
68
|
| 工具 | 用途 |
|
|
12
69
|
|---|---|
|
|
@@ -16,37 +73,28 @@
|
|
|
16
73
|
| `code_map` | 限量排名仓库地图(按符号密度 + import 图 PageRank 取核心文件 + 关键符号与行号) |
|
|
17
74
|
| `code_refs` | 沿调用图追踪符号:callers(谁调用了它)与 callees(它调用了谁),解析到 file:line |
|
|
18
75
|
| `code_change_context` | 从工作区或显式 diff 出发,返回变更符号、调用者、import 依赖、有限影响路径和可能受影响的测试 |
|
|
19
|
-
| `code_context` |
|
|
76
|
+
| `code_context` | Edit-ready ContextPack:有界源码、理由、关系、变化/测试、缺口和硬预算,默认文本返回 |
|
|
20
77
|
| `code_health` | 可选开启(`codeHealth: true`):环依赖(import 环)与孤儿模块 |
|
|
21
78
|
|
|
22
79
|
外加一个可选的**自动注入系统提示词段**(`code-index:repo-map`,序 60):自动选择当前 DSH 会话工作区的精简排名地图。将 `autoInject: false` 可关闭,只依赖 `code_map` 工具。
|
|
23
80
|
|
|
24
|
-
## 项目感知实时上下文
|
|
25
|
-
|
|
26
|
-
```text
|
|
27
|
-
打开仓库 A → code_context 使用 A
|
|
28
|
-
切换到仓库 B → code_context 自动改用 B
|
|
29
|
-
从 VS Code 修改仓库 B → 下一次 code_context 看到最新状态
|
|
30
|
-
切回仓库 A → A 的符号与 Git 变更仍然独立
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
每个 Git worktree 都有独立索引和变更状态。插件最多保留最近使用的四个项目上下文,只监听会话访问过的项目。文件事件会合并处理;工具调用也会扫描当前文件元数据,并在返回上下文前重解析已变更文件。
|
|
34
|
-
|
|
35
81
|
## 安装
|
|
36
82
|
|
|
37
83
|
需要 `dsh`(任意安装方式——npx、npm 或源码)与 Node ≥ 22。
|
|
38
84
|
|
|
39
|
-
当前开发兼容目标为 `@deepseek-ai/dsh@0.
|
|
85
|
+
当前开发兼容目标为 `@deepseek-ai/dsh@0.2.0-rc.2` / `@deepseek-ai/dsh-tools@0.2.0-rc.2`(CI 覆盖 Node 22 和 24)。DSH 插件接口仍属于预览 API,上游变化可能需要更新兼容适配。
|
|
86
|
+
|
|
87
|
+
v0.9 要求匹配的 `0.2.0-rc.2` tools runtime;精确 peer pin 防止 npm 新安装选到 registry 中旧的 `latest` 标签。宿主版本组需一起升级;文本、配置、工具 surface 的兼容承诺不等于支持旧 DSH API。
|
|
40
88
|
|
|
41
89
|
```sh
|
|
42
90
|
# 从 npm(预编译)
|
|
43
|
-
npx @deepseek-ai/dsh plugin --profile web add dsh-code-index
|
|
91
|
+
npx @deepseek-ai/dsh@0.2.0-rc.2 plugin --profile web add dsh-code-index@0.9.0
|
|
44
92
|
|
|
45
93
|
# 或从包含本仓库检查副本的目录
|
|
46
|
-
npx @deepseek-ai/dsh plugin --profile web add ./dsh-code-index
|
|
94
|
+
npx @deepseek-ai/dsh@0.2.0-rc.2 plugin --profile web add ./dsh-code-index
|
|
47
95
|
```
|
|
48
96
|
|
|
49
|
-
重启 Web UI(`npx @deepseek-ai/dsh web`)——启动日志会确认每个工具:
|
|
97
|
+
重启 Web UI(`npx @deepseek-ai/dsh@0.2.0-rc.2 web`)——启动日志会确认每个工具:
|
|
50
98
|
|
|
51
99
|
```
|
|
52
100
|
[dsh-code-index] plugin loaded
|
|
@@ -69,41 +117,29 @@ npx @deepseek-ai/dsh plugin --profile web add ./dsh-code-index
|
|
|
69
117
|
|
|
70
118
|
*索引*本身不需要 API key;模型当然要配置好才能调用这些工具。
|
|
71
119
|
|
|
72
|
-
##
|
|
73
|
-
|
|
74
|
-
用户提示:
|
|
75
|
-
|
|
76
|
-
> 我们现在在哪个仓库?先跑 `code_map`,然后找出 `extractSymbols` 定义在哪。
|
|
77
|
-
|
|
78
|
-
agent 依次调用工具:
|
|
79
|
-
|
|
80
|
-
```
|
|
81
|
-
code_map
|
|
82
|
-
# repo map
|
|
83
|
-
## src/extract.ts (14)
|
|
84
|
-
function extractSymbols(code, id) :121
|
|
85
|
-
function languageForFile(filePath) :37
|
|
86
|
-
...
|
|
87
|
-
|
|
88
|
-
code_search { query: "extractSymbols" }
|
|
89
|
-
export function extractSymbols(code, id) — src/extract.ts:121
|
|
90
|
-
```
|
|
120
|
+
## 更多能力
|
|
91
121
|
|
|
92
122
|
索引在首次使用时惰性构建;后续调用由磁盘缓存提供,并按 mtime 增量刷新。
|
|
93
123
|
|
|
94
124
|
### 调用图
|
|
95
125
|
|
|
96
|
-
`code_refs`
|
|
126
|
+
`code_refs` 追踪定义、调用者和被调用者。以下是既有工具的较早真实示例,不是 v0.9 Context Card:
|
|
97
127
|
|
|
98
|
-

|
|
99
129
|
|
|
100
130
|
### 变更感知上下文
|
|
101
131
|
|
|
102
132
|
`code_change_context` 默认分析相对于 `HEAD` 的当前 Git 工作区,也支持内联 unified diff、仓库相对 `files` 或稳定的 `symbols` ID。结果有数量和字符预算,每条推导关系都会标注 `exact`、`import-scoped` 或 `name-only` 来源。删除和重命名在可用时读取 baseline;工作区模式也会包含未被忽略的未跟踪源码文件。
|
|
103
133
|
|
|
104
|
-
###
|
|
134
|
+
### Edit-ready Context Packs
|
|
105
135
|
|
|
106
|
-
`code_context`
|
|
136
|
+
`code_context` 识别修改、符号、架构、测试、探索和模糊任务。用 camel/snake 分词及文件名、路径、签名 terms 做确定性候选排序,保留 exact symbol;从强 primary seed 找 clean-tree likely tests,图邻域有界。不使用 BM25。
|
|
137
|
+
|
|
138
|
+
`budgetChars` 默认 5000,规范化到 300–20000;`maxFiles` 默认 12,`maxSymbols` 默认 10。预算按 JavaScript 字符串字符计,不是 token 或 UTF-8 字节。文本和最终 pack 的 JSON 都必须满足上限,不切断代码行。小预算可能只剩签名或缺口;仓库身份本身无法放入预算时返回明确错误。展示任务摘要最多 120 字符,不影响路由。
|
|
139
|
+
|
|
140
|
+
默认 canonical return 保持 **string**。显式传 `outputFormat: "pack"` 才返回导出的 `ContextPack` DTO。`items` 已经过预算选择,源码字段为 `file/startLine/endLine/side/ref/mode/code`,同时有 `reason` 及适用的独立关系 `resolution/provenance`。`budget.usedChars` 对应文本,`budget.packChars` 对应 JSON;用 `renderContextPack` 渲染,不暴露隐藏候选列表。
|
|
141
|
+
|
|
142
|
+
Git 变化使用固定的 baseline commit 判定 added/modified/deleted,保留可靠文件 rename。结构身份不明确或 baseline 缺失时为 `unclassified`,不猜 symbol rename。`code_change_context` 的显式 `files`/`symbols` 仍是选择模式,不构成 Git modified 的证据。
|
|
107
143
|
|
|
108
144
|
## 配置
|
|
109
145
|
|
|
@@ -143,7 +179,7 @@ TypeScript、JavaScript、Python、Go、Rust、Java、C++、C(`.ts .tsx .mts .ct
|
|
|
143
179
|
- **仓库地图**(`src/repomap.ts`):import 图上的个性化 PageRank(传送向量 = 各文件密度份额,被其他枢纽文件引用的枢纽会比平铺入度统计排得更靠前),以密度感知的文件打分为底(class/interface/function 加权,测试路径衰减),取 Top-N 文件,每文件符号上限,硬截断。
|
|
144
180
|
- **调用图**(`src/refgraph.ts`):逐文件提取调用点(按语言,并记录其所属函数),按名称解析成 callers 与 callees——`code_refs` 直接暴露,`code_search` 也把调用热度作为排名平局裁决。
|
|
145
181
|
- **变更上下文**(`src/change-context.ts`):把 Git hunk 映射到稳定符号,再在有限深度内追踪带来源标签的调用者、import 依赖、入口路径、影响范围和可能受影响的测试,避免返回整个仓库。
|
|
146
|
-
-
|
|
182
|
+
- **ContextPack**(`src/context.ts`、`src/context-pack.ts`、`src/source-excerpts.ts`):候选排序、临时读取源码证据、按文本/JSON 预算选择唯一 DTO,再渲染入选项。
|
|
147
183
|
- **健康检查**(`src/health.ts`):对 import 图跑 Tarjan SCC 得到环依赖;孤儿模块检测列出既不被 import、也不 import 任何文件的含符号文件(排除入口与测试)。
|
|
148
184
|
- **工作区解析**:每个工具解析会话 cwd(`agent.session.header.cwd`)并向上查找最近的 `.git`(有界——没有仓库标记的目录绝不会被索引)。
|
|
149
185
|
- **项目上下文**(`src/repo-context.ts`):用真实规范路径区分各 worktree,最多保留四个上下文。每次工具调用扫描文件元数据并只重解析变化文件;watcher 会在有限 debounce 后刷新脏文件。
|
|
@@ -155,9 +191,8 @@ TypeScript、JavaScript、Python、Go、Rust、Java、C++、C(`.ts .tsx .mts .ct
|
|
|
155
191
|
- 自动注入地图使用 DSH system prompt assembly 提供的当前会话上下文。没有 Agent 的 prompt assembly 会回退到 DSH 进程工作目录。新访问的项目第一次注入可能暂时为空,待索引完成后后续 assembly 会使用项目地图。
|
|
156
192
|
- Watcher 只为工具实际访问的项目启动,并随插件卸载清理。设置 `externalWatch: false` 后,每次工具调用仍会扫描元数据以发现常规 mtime 变化。
|
|
157
193
|
- 大型 monorepo 每次工具调用仍需要扫描目录元数据。文件解析是增量的,但扫描耗时取决于仓库规模和磁盘速度。
|
|
158
|
-
-
|
|
159
|
-
-
|
|
160
|
-
- 开发者预览版 harness:上游 harness/插件 API 大概率有破坏性变更。
|
|
194
|
+
- 不索引函数局部变量;索引模块声明和类成员,parser/graph 不等同于 type checker。
|
|
195
|
+
- current 源码读取会拒绝索引快照后发生变化、真实路径越出 root 或超过 1 MB 的文件;signature-only 和 gaps 标明缺失证据。Likely tests 是线索,不保证覆盖。
|
|
161
196
|
|
|
162
197
|
## 开发
|
|
163
198
|
|
|
@@ -182,8 +217,11 @@ node.exe scripts\fix-wsl-links.mjs C:\Users\you\.dsh\profiles\web # dsh profil
|
|
|
182
217
|
|
|
183
218
|
## 反馈
|
|
184
219
|
|
|
185
|
-
|
|
220
|
+
用过 dsh-code-index?欢迎告诉我哪些地方有帮助、哪里出错,或缺少了什么上下文。可以回复[DSH 官方插件介绍讨论](https://github.com/deepseek-ai/deepseek-harness/discussions/5623);如果仓库允许创建 Issue,也可以使用[反馈 Issue 表单](https://github.com/lemonxiny55/dsh-code-index/issues/new?template=feedback.yml)。
|
|
221
|
+
|
|
222
|
+
为了方便复现,请尽量说明仓库的大致规模和语言、执行的任务、预期上下文与 Agent 实际收到的内容,以及是否涉及项目切换、worktree 或外部文件修改。请勿粘贴私有源码、凭据或 API key。
|
|
186
223
|
|
|
187
224
|
## 许可证
|
|
188
225
|
|
|
189
226
|
MIT。与 DeepSeek 无关;基于公开的 `dsh` 插件接口构建。
|
|
227
|
+
|