dsh-code-index 0.9.1 → 0.10.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/CHANGELOG.md CHANGED
@@ -2,6 +2,25 @@
2
2
 
3
3
  All notable changes to dsh-code-index are documented here.
4
4
 
5
+ ## 0.10.0 — ArkTS & Reliable Code Context (stable candidate, unreleased)
6
+
7
+ - Add dedicated `.ets` parsing using pinned harmony-contrib/tree-sitter-arkts
8
+ 0.3.0 / ABI-14 WASM bundled with MIT notices; no native grammar installation.
9
+ - Extract component structs, methods, fields, decorators and TS-style business
10
+ declarations with stable qualified IDs and decorator-inclusive source ranges.
11
+ Integrate mixed ETS/TS imports, tools, Git changes and Context Packs.
12
+ - Avoid UI built-in/attribute false relationships: UI calls need local or explicit
13
+ bindings; decorators/leading-dot modifiers are metadata. Keep default imports
14
+ import-scoped and ambiguous ETS/TS stems unresolved. No state/rerender graph.
15
+ - Record lightweight parsed/partial/failed diagnostics and bounded issue locations;
16
+ omit unreliable ArkTS declarations, report index gaps, and rebuild schema-2 caches.
17
+ - Add 15 ArkTS regression tests and pinned official sources (seven Browser files,
18
+ all 15 `@Local` documentation snippets). Node 22.23.3 and 24.19.0 each pass
19
+ 235 tests, typecheck, server/client builds and real package-consumer smoke.
20
+ See `RELEASE_EVIDENCE_v0.10.0.md` for actual methods and Desktop results.
21
+ - v0.9.1 remains the published stable version. No v0.10 tag, npm publication,
22
+ GitHub Release or main push has been performed.
23
+
5
24
  ## 0.9.1 — Gitignore directory whitelist fix (2026-10-10)
6
25
 
7
26
  - 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).
package/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  English | [中文](README.zh.md)
7
7
 
8
- **v0.9.0 — Edit-ready Context Packs**
8
+ **v0.10.0 stable candidate — ArkTS & Reliable Code Context**
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
 
@@ -14,7 +14,11 @@ Give your [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) ag
14
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
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
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).
17
+ v0.9.1 is published on npm and fixes Gitignore directory whitelist rules that silently omitted source trees. The packaged candidate passed real Agent verification in DSH Desktop `0.2.0-rc.2`. See [release evidence](RELEASE_EVIDENCE_v0.9.1.md).
18
+
19
+ This branch prepares the unpublished `0.10.0` stable candidate; npm `latest` remains v0.9.1.
20
+ ArkTS `.ets` files now use a pinned, bundled MIT grammar rather than the TS
21
+ parser. See [ArkTS PoC](ARKTS_POC_v0.10.0.md) and [v0.10 evidence](RELEASE_EVIDENCE_v0.10.0.md).
18
22
 
19
23
  ## On this page
20
24
 
@@ -33,7 +37,7 @@ v0.9.0 is published on npm and passed real Agent verification in DSH Desktop `0.
33
37
  Requires Node 22/24 and a matching DSH `0.2.0-rc.2` host group. Install the published version into a Web profile:
34
38
 
35
39
  ```sh
36
- npx @deepseek-ai/dsh@0.2.0-rc.2 plugin --profile web add dsh-code-index@0.9.0
40
+ npx @deepseek-ai/dsh@0.2.0-rc.2 plugin --profile web add dsh-code-index@0.9.1
37
41
  npx @deepseek-ai/dsh@0.2.0-rc.2 web
38
42
  ```
39
43
 
@@ -85,7 +89,7 @@ Plus an optional **auto-injected system prompt section** (`code-index:repo-map`,
85
89
 
86
90
  Requires `dsh` (any install path — npx, npm, or source) and Node ≥ 22.
87
91
 
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.
92
+ The verified compatibility target is `@deepseek-ai/dsh@0.2.0-rc.2` / `@deepseek-ai/dsh-tools@0.2.0-rc.2` (Node 22 and 24 verification matrix). The DSH plugin surface is still a preview API, so upstream changes may require compatibility updates.
89
93
 
90
94
  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.
91
95
 
@@ -173,7 +177,38 @@ Options are passed as the plugin row's `config` in the profile patch (or default
173
177
 
174
178
  ## Supported languages
175
179
 
176
- TypeScript, JavaScript, Python, Go, Rust, Java, C++ and C (`.ts .tsx .mts .cts .js .jsx .mjs .cjs .py .pyi .go .rs .java .cpp .cc .cxx .c++ .hpp .hxx .hh .h .ipp .tpp .inl .c`) via tree-sitter WASM — pure parsing, no native build. The symbol provider seam (`src/extract.ts` + grammars) is where other languages/embeddings plug in later. C/C++ symbol extraction resolves names through the declarator chain (templates, qualified `ns::name` definitions, in-class methods), and `#include "…"` specifiers feed the repo-map reference graph.
180
+ ArkTS, TypeScript, JavaScript, Python, Go, Rust, Java, C++ and C (`.ets .ts .tsx .mts .cts .js .jsx .mjs .cjs .py .pyi .go .rs .java .cpp .cc .cxx .c++ .hpp .hxx .hh .h .ipp .tpp .inl .c`) via tree-sitter WASM — pure parsing, no native build. The symbol provider seam (`src/extract.ts` + grammars) is where other languages/embeddings plug in later. C/C++ symbol extraction resolves names through the declarator chain (templates, qualified `ns::name` definitions, in-class methods), and `#include "…"` specifiers feed the repo-map reference graph.
181
+
182
+ ### ArkTS scope and limits
183
+
184
+ - Components declared with `struct` appear as `kind: class`, signature `struct Name`.
185
+ Methods, fields, global functions, classes/interfaces/types/enums and module
186
+ variables have stable qualified IDs, owners and source line ranges. Decorators
187
+ (`@Component`, `@ComponentV2`, `@State`, `@Local`, `@Builder`, etc.) are retained
188
+ as metadata and included in the definition's source range.
189
+ - `build()` and nested declarative UI blocks parse as ArkTS. Local components and
190
+ explicit ETS/TS imports feed symbols, search, map, references, change context
191
+ and Context Packs. `@Extend` metadata and UI attribute chains are excluded from
192
+ call relationships. Bare capitalized calls in UI bodies have no global-name or
193
+ imported-module fallback; unbound SDK components cannot acquire unrelated
194
+ same-named project targets. Ordinary callback/business calls retain existing
195
+ provenance. `code_refs` uses binding-aware candidates for ArkTS call sites.
196
+ - Relative mixed ETS/TS imports work when the target is statically unique.
197
+ Extensionless stems with both ETS and another source file stay unresolved.
198
+ Default imports remain `import-scoped`; no HAR/oh-package/module alias, SDK
199
+ typing, re-export chain, state-update or UI rerender semantics are inferred.
200
+ Unbound/global custom UI components may therefore have no relationship edge.
201
+ Syntax acceptance does not prove valid ArkTS or HarmonyOS runtime behavior.
202
+ - Each indexed file records `parsed`, `partial`, or `failed` syntax/read status,
203
+ ERROR/MISSING counts and at most three issue locations. Unreliable ArkTS
204
+ declarations are omitted rather than assigned misleading IDs. `code_index`
205
+ reports a bounded incomplete-index summary, and Context Packs/change context
206
+ carry gaps within their existing budgets. `parsed` means syntax extraction
207
+ completed, not that the index contains every semantic reference. Cache schema
208
+ 3 rebuilds older caches automatically; source bodies remain unpersisted.
209
+ - Grammar: [harmony-contrib 0.3.0](https://github.com/harmony-contrib/tree-sitter-arkts),
210
+ ABI 14, unchanged npm WASM bundled with its MIT notices. Consumer installation
211
+ requires no native ArkTS addon. [Asset provenance](grammars/README.md).
177
212
 
178
213
  ## How it works
179
214
 
package/README.zh.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [English](README.md) | 中文
4
4
 
5
- **v0.9.0 — Edit-ready Context Packs**
5
+ **v0.10.0 稳定候选 — ArkTS & Reliable Code Context**
6
6
 
7
7
  让 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) Agent 用一次 `code_context` 调用拿到开始处理任务所需的有界源码上下文:主要声明、强相关 caller/callee、imports、当前变化和相关测试。每个关键 item 都有入选理由,源码有准确行号;证据不足时明确说明缺口。
8
8
 
@@ -11,7 +11,11 @@
11
11
  - **可检查的证据:**入选 reason 与关系的 `exact` / `import-scoped` / `name-only` provenance 分开,不编造概率或 confidence。
12
12
  - **本地、隔离、实时:**repo/worktree 独立,外部增改删自动刷新,不需要外部索引 API key;保留 full/compact surface 和 v0.8 配置。
13
13
 
14
- v0.9.0 已发布到 npm,并通过 DSH Desktop `0.2.0-rc.2` 真实 Agent 验证。验证边界见[release evidence](RELEASE_EVIDENCE_v0.9.0.md)。
14
+ v0.9.1 已发布到 npm,修复了 Gitignore 目录白名单规则静默遗漏源码的问题。打包候选产物已通过 DSH Desktop `0.2.0-rc.2` 真实 Agent 验证。验证边界见[release evidence](RELEASE_EVIDENCE_v0.9.1.md)。
15
+
16
+ 本分支准备尚未发布的 `0.10.0` 稳定候选,npm `latest` 仍是已发布的 v0.9.1。
17
+ `.ets` 现在使用锁定版本、随包附带 MIT 许可证的 ArkTS grammar,独立于 TS parser。
18
+ 见 [ArkTS PoC](ARKTS_POC_v0.10.0.md) 和 [v0.10 验证证据](RELEASE_EVIDENCE_v0.10.0.md)。
15
19
 
16
20
  ## 本页导航
17
21
 
@@ -30,7 +34,7 @@ v0.9.0 已发布到 npm,并通过 DSH Desktop `0.2.0-rc.2` 真实 Agent 验证
30
34
  需要 Node 22/24 与匹配的 DSH `0.2.0-rc.2` 宿主版本组。将已发布版本安装到 Web profile:
31
35
 
32
36
  ```sh
33
- 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 plugin --profile web add dsh-code-index@0.9.1
34
38
  npx @deepseek-ai/dsh@0.2.0-rc.2 web
35
39
  ```
36
40
 
@@ -170,7 +174,30 @@ Git 变化使用固定的 baseline commit 判定 added/modified/deleted,保留
170
174
 
171
175
  ## 支持的语言
172
176
 
173
- TypeScript、JavaScript、Python、Go、Rust、Java、C++、C(`.ts .tsx .mts .cts .js .jsx .mjs .cjs .py .pyi .go .rs .java .cpp .cc .cxx .c++ .hpp .hxx .hh .h .ipp .tpp .inl .c`),通过 tree-sitter WASM 解析——纯解析,无需原生编译。符号提供方的接缝(`src/extract.ts` + 语法文件)预留了后续接入其他语言/嵌入检索的位置。C/C++ 符号提取通过 declarator 链解析名字(模板、`ns::name` 限定定义、类内方法),`#include "…"` 会接入 repo map 的引用图。
177
+ ArkTS、TypeScript、JavaScript、Python、Go、Rust、Java、C++、C(`.ets .ts .tsx .mts .cts .js .jsx .mjs .cjs .py .pyi .go .rs .java .cpp .cc .cxx .c++ .hpp .hxx .hh .h .ipp .tpp .inl .c`),通过 tree-sitter WASM 解析——纯解析,无需原生编译。符号提供方的接缝(`src/extract.ts` + 语法文件)预留了后续接入其他语言/嵌入检索的位置。C/C++ 符号提取通过 declarator 链解析名字(模板、`ns::name` 限定定义、类内方法),`#include "…"` 会接入 repo map 的引用图。
178
+
179
+ ### ArkTS 功能与限制
180
+
181
+ - `struct` 组件使用现有 `kind: class`,签名为 `struct Name`。方法、字段、全局函数、
182
+ class/interface/type/enum 和模块变量保留稳定的限定 ID、所属作用域和源码行号。
183
+ `@Component`、`@ComponentV2`、`@State`、`@Local`、`@Builder` 等装饰器保留为元数据,
184
+ 装饰器所在行纳入定义源码范围。
185
+ - 能解析 `build()` 和嵌套声明式 UI;本地组件、显式 ETS/TS import 接入符号、搜索、地图、
186
+ 引用、变更上下文和 Context Pack。`@Extend` 元数据及 UI 属性链不会被当作业务调用关系。
187
+ UI 块内大写裸调用不使用全仓库同名或仅导入模块的回退,避免给无绑定的 SDK 组件关联
188
+ 无关项目符号。普通 callback/业务调用沿用已有 provenance;ArkTS 的 `code_refs` 使用
189
+ 按绑定解析的候选关系。
190
+ - 唯一可确定目标的相对 ETS/TS import 可解析;同一无扩展名路径同时存在 ETS 和其他源码
191
+ 时不猜测。默认 import 保留 `import-scoped`,不推断 HAR/oh-package/模块别名、SDK 类型、
192
+ re-export 链、状态更新或 UI 重渲染语义。无显式绑定的全局自定义 UI 组件可能没有关系边。
193
+ 语法解析通过不等于 ArkTS 编译通过或鸿蒙运行时行为已验证。
194
+ - 每个索引文件记录 `parsed` / `partial` / `failed`、ERROR/MISSING 数量和最多三处位置。
195
+ 不可靠的 ArkTS 声明会被省略,避免错误的范围或所属作用域。`code_index` 提供有限的
196
+ 索引不完整摘要,Context Pack 和变更上下文在原有预算内保留缺口。`parsed` 只表示语法
197
+ 提取完成,不承诺完整语义引用。缓存 schema 3 自动重建旧缓存,仍不持久化源码正文。
198
+ - grammar 使用 [harmony-contrib 0.3.0](https://github.com/harmony-contrib/tree-sitter-arkts),
199
+ ABI 14,未经修改的 npm WASM 与 MIT 声明随包发布,消费端无需原生 ArkTS addon。
200
+ 见 [WASM 来源](grammars/README.md)。
174
201
 
175
202
  ## 工作原理
176
203
 
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import Schema from '@deepseek-ai/schemastery';
3
3
 
4
4
  /** Shared data model for dsh-code-index. */
5
5
  /** On-disk cache layout version. Bump when persisted graph/symbol shapes change. */
6
- declare const REPO_INDEX_SCHEMA_VERSION: 2;
6
+ declare const REPO_INDEX_SCHEMA_VERSION: 3;
7
7
  type SymbolKind = 'function' | 'method' | 'class' | 'interface' | 'type' | 'enum' | 'variable' | 'field' | 'import' | 'module';
8
8
  /** Stable, file-qualified symbol identity: `sym:v1:<file>#<scope>/<segment>`. */
9
9
  type SymbolId = string;
@@ -16,6 +16,8 @@ interface SymbolScopePart {
16
16
  ordinal: number;
17
17
  }
18
18
  interface SymbolInfo {
19
+ /** ArkTS decorators as written; their source lines belong to the definition. */
20
+ decorators?: string[];
19
21
  /** Stable qualified id; unique within a RepoIndex. */
20
22
  id: SymbolId;
21
23
  /** Symbol name (identifier / type id / member name). */
@@ -53,6 +55,8 @@ interface ImportInfo {
53
55
  }
54
56
  /** One call site: callee name, line, and enclosing function ('' = module level). */
55
57
  interface CallInfo {
58
+ /** ArkUI syntax requires an explicit/local binding; no global name guessing. */
59
+ context?: 'arkui';
56
60
  /** Callee name as written (identifier, member/property, or qualified tail). */
57
61
  name: string;
58
62
  /** 1-based line of the call expression. */
@@ -65,6 +69,8 @@ interface CallInfo {
65
69
  qualifier: string | null;
66
70
  }
67
71
  interface IndexedFile {
72
+ /** Syntax/read completeness, not a typecheck or HarmonyOS runtime verdict. */
73
+ diagnostic?: ParseDiagnostic;
68
74
  /** Repo-relative path (forward-slash). */
69
75
  path: string;
70
76
  lang: string;
@@ -79,6 +85,16 @@ interface IndexedFile {
79
85
  * Optional because caches written before call-graph support lack it. */
80
86
  calls?: CallInfo[];
81
87
  }
88
+ interface ParseDiagnostic {
89
+ status: 'parsed' | 'partial' | 'failed';
90
+ errorCount: number;
91
+ missingCount: number;
92
+ issues: Array<{
93
+ kind: 'ERROR' | 'MISSING';
94
+ line: number;
95
+ }>;
96
+ reason?: 'source-unavailable' | 'parser-failed';
97
+ }
82
98
  interface RepoIndex {
83
99
  /** Persisted layout version; see {@link REPO_INDEX_SCHEMA_VERSION}. */
84
100
  schemaVersion: typeof REPO_INDEX_SCHEMA_VERSION;
@@ -122,14 +138,14 @@ declare function findRepoRoot(startDir: string, maxLevels?: number): Promise<str
122
138
  * Parses a source text with a per-language grammar (web-tree-sitter WASM,
123
139
  * static grammars from tree-sitter-wasms) and returns flat SymbolInfo rows.
124
140
  *
125
- * NOTE on the dependency pin: web-tree-sitter must stay at ^0.20.x — newer
126
- * releases expect dylinked grammar wasm, while tree-sitter-wasms ships
127
- * static builds. Verified working pair: web-tree-sitter@0.20.8 + tree-sitter-wasms@0.1.13.
141
+ * web-tree-sitter 0.25 loads the existing tree-sitter-wasms grammars and the
142
+ * pinned ArkTS ABI-14 asset. See grammars/README.md for provenance.
128
143
  */
129
144
 
130
- type LanguageId = 'typescript' | 'javascript' | 'python' | 'go' | 'rust' | 'java' | 'cpp' | 'c';
145
+ type LanguageId = 'arkts' | 'typescript' | 'javascript' | 'python' | 'go' | 'rust' | 'java' | 'cpp' | 'c';
131
146
  declare function languageForFile(filePath: string): LanguageId | null;
132
147
  interface ExtractedFile {
148
+ diagnostic: ParseDiagnostic;
133
149
  symbols: SymbolInfo[];
134
150
  /** Derived compatibility view of {@link importDetails} specifiers. */
135
151
  imports: string[];
@@ -171,6 +187,9 @@ declare function defaultCachePath(root: string, cacheDir?: string): string;
171
187
  declare function loadIndex(cachePath: string): Promise<RepoIndex | null>;
172
188
  declare function saveIndex(cachePath: string, index: RepoIndex): Promise<void>;
173
189
 
190
+ /** One summary and at most three file locations. No source or exception dump. */
191
+ declare function indexIntegrityWarnings(index: RepoIndex): string[];
192
+
174
193
  /** Pure search / filter logic over a RepoIndex — unit-testable, no IO. */
175
194
 
176
195
  interface SymbolFilter {
@@ -631,4 +650,4 @@ declare const name = "dsh-code-index";
631
650
  declare const inject: readonly ["tools", "systemPrompt"];
632
651
  declare function apply(ctx: MinimalContext, pluginConfig?: PluginConfig): void;
633
652
 
634
- export { type AffectedTest, CACHE_DIR_NAME, type ChangeContextInput, type ChangeContextOptions, type ChangeContextResult, type ChangeKind, type ChangedSymbol, type CodeChangeContextArgs, Config, type ContextFile, type ContextOptions, type ContextPack, type ContextPackItem, type ContextRelationship, type ContextRoute, type ContextSymbol, type ContextTaskKind, DEFAULT_EXCLUDED_DIRS, type DiffHunk, type FileChange, type ImpactHop, type ImpactRow, type ImportDependent, type IndexOptions, type IndexedFile, type RepoIndex, SUPPORTED_EXTS, type SymbolInfo, type SymbolKind, type SymbolPath, type TaskContextResult, type UnmappedChange, apply, buildChangeContext, buildIndex, buildIndexWithCache, buildModuleGraph, buildSymbolTable, buildTaskContext, callerCounts, changeContextInputFromArgs, defaultCachePath, extractAll, extractSymbols, findCycles, findOrphanModules, findRepoRoot, inject, languageForFile, loadIndex, name, parseFileToSymbols, parseUnifiedDiff, rankRepoMap, readGitFileAtRef, readWorkingTreeDiff, renderChangeContext, renderContextPack, renderHit, renderRepoMap, renderTaskContext, routeTask, saveIndex, scanRepo, scoreFile, searchSymbols, symbolCount, symbolRefs, tools };
653
+ export { type AffectedTest, CACHE_DIR_NAME, type ChangeContextInput, type ChangeContextOptions, type ChangeContextResult, type ChangeKind, type ChangedSymbol, type CodeChangeContextArgs, Config, type ContextFile, type ContextOptions, type ContextPack, type ContextPackItem, type ContextRelationship, type ContextRoute, type ContextSymbol, type ContextTaskKind, DEFAULT_EXCLUDED_DIRS, type DiffHunk, type FileChange, type ImpactHop, type ImpactRow, type ImportDependent, type IndexOptions, type IndexedFile, type ParseDiagnostic, type RepoIndex, SUPPORTED_EXTS, type SymbolInfo, type SymbolKind, type SymbolPath, type TaskContextResult, type UnmappedChange, apply, buildChangeContext, buildIndex, buildIndexWithCache, buildModuleGraph, buildSymbolTable, buildTaskContext, callerCounts, changeContextInputFromArgs, defaultCachePath, extractAll, extractSymbols, findCycles, findOrphanModules, findRepoRoot, indexIntegrityWarnings, inject, languageForFile, loadIndex, name, parseFileToSymbols, parseUnifiedDiff, rankRepoMap, readGitFileAtRef, readWorkingTreeDiff, renderChangeContext, renderContextPack, renderHit, renderRepoMap, renderTaskContext, routeTask, saveIndex, scanRepo, scoreFile, searchSymbols, symbolCount, symbolRefs, tools };