@deepseek-ai/dsh-file-reference-local 0.2.0-rc.2 → 0.2.1-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.i18n.yaml CHANGED
@@ -15,8 +15,8 @@
15
15
  en: d152484eb41ac6b4
16
16
  zh: 09388d293f9be9cb
17
17
  /deepseek-ai-dsh-file-reference-local/use-this-package:
18
- en: bb3ce050657f834a
19
- zh: 2e1afa3efb7a5702
18
+ en: 1fd922f09d15163f
19
+ zh: e1d68a27a676256d
20
20
  /deepseek-ai-dsh-file-reference-local/use-this-package/enabling-the-provider:
21
21
  en: 62b9ce096fa4a94e
22
22
  zh: 53081797c34d64eb
@@ -33,8 +33,8 @@
33
33
  en: f0023b9c833747b5
34
34
  zh: 42aef0c0fce9ce8c
35
35
  /deepseek-ai-dsh-file-reference-local/understand-the-implementation/source-map:
36
- en: a04bc6a11619cae7
37
- zh: 4fb1a0d04398260b
36
+ en: 50b4cb9acee6e4a7
37
+ zh: a1455ea70c837ebc
38
38
  /deepseek-ai-dsh-file-reference-local/understand-the-implementation/main-flow:
39
39
  en: bb338cacc1ef8c01
40
40
  zh: d7ad96a5646f5444
package/README.md CHANGED
@@ -25,7 +25,9 @@ Agents and host UIs can complete `@file` mentions with ranked paths from each ag
25
25
  <a id="use-this-package"></a>
26
26
  ## Use this package
27
27
 
28
- Mount this provider when `@file` completion should discover the Harness host's own filesystem — the namespace the shipped `read` tool operates on. Each agent's workspace is indexed from its session working directory, falling back to the host process directory when the session has none.
28
+ Changing the Session's working directory discards the previous directory's search index; the next completion searches the new directory.
29
+
30
+ Mount this provider when `@file` completion should discover the Harness host's own filesystem — the namespace the shipped `read` tool operates on. Each agent's workspace is indexed from its Session's current working directory.
29
31
 
30
32
  ### Enabling the provider
31
33
 
@@ -71,7 +73,6 @@ The provider maintains one reusable `WorkspaceFileSearch` per agent, rooted at t
71
73
  |---|---|
72
74
  | [`src/index.ts`](src/index.ts) | `LocalFileReferenceService`: config validation, per-agent searches, prompt install |
73
75
  | [`src/search.ts`](src/search.ts) | `WorkspaceFileSearch`: traversal, ranking, exclusion, staleness and background rebuild |
74
- | — | No runtime invariant companion is published; per-agent indexes are private advisory caches whose invalidation and disposal are observed directly through service tests. |
75
76
 
76
77
  ### Main flow
77
78
 
package/README.zh.md CHANGED
@@ -25,7 +25,9 @@ agent(智能体)及宿主 UI 可以用各 agent 本地工作区中经过排
25
25
  <a id="use-this-package"></a>
26
26
  ## 使用本包
27
27
 
28
- 当 `@file` 补全应发现 Harness 宿主自身的文件系统——即随附 `read` 工具所操作的命名空间——时,挂载此提供方。每个 agent 的工作区从该会话的工作目录开始建立索引;会话没有工作目录时回退到宿主进程目录。
28
+ 切换 Session 工作目录后,旧目录的搜索索引会被丢弃;下一次补全会搜索新目录。
29
+
30
+ 当 `@file` 补全应发现 Harness 宿主自身的文件系统——即随附 `read` 工具所操作的命名空间——时,挂载此提供方。每个 agent 的工作区从其 Session 当前工作目录开始建立索引。
29
31
 
30
32
  ### 启用提供方
31
33
 
@@ -71,7 +73,6 @@ agent(智能体)及宿主 UI 可以用各 agent 本地工作区中经过排
71
73
  |---|---|
72
74
  | [`src/index.ts`](src/index.ts) | `LocalFileReferenceService`:配置校验、按 agent 搜索、提示词安装 |
73
75
  | [`src/search.ts`](src/search.ts) | `WorkspaceFileSearch`:遍历、排序、排除、陈旧标记与后台重建 |
74
- | — | 不发布运行时不变式伴生入口;按 agent 的 index 是私有 advisory cache,其失效与 dispose 行为通过服务测试直接观察。 |
75
76
 
76
77
  ### 主要流程
77
78
 
package/lib/index.js CHANGED
@@ -318,7 +318,7 @@ function errorReason(reason, fallback) {
318
318
  */
319
319
  /** Local-filesystem owner of the file-reference discovery service. */
320
320
  var LocalFileReferenceService = class extends FileReferenceService {
321
- static inject = ["agents"];
321
+ static inject = ["agents", "workingDirectory"];
322
322
  static Config = z.object({
323
323
  maxResults: z.number().step(1).min(1).default(20),
324
324
  maxEntries: z.number().step(1).min(1).default(DEFAULT_FILE_SEARCH_MAX_ENTRIES),
@@ -366,30 +366,35 @@ var LocalFileReferenceService = class extends FileReferenceService {
366
366
  await installPrompt(agent);
367
367
  });
368
368
  ctx.on("agent/disposed", ({ agent }) => {
369
- this.searches.get(agent)?.dispose();
369
+ this.searches.get(agent)?.search.dispose();
370
370
  this.searches.delete(agent);
371
371
  disposePrompt(agent);
372
372
  });
373
373
  ctx.on("session/event", (session, event) => {
374
374
  if (event.type !== "tool/result") return;
375
375
  const agent = ctx.agents.get(session.id);
376
- if (agent !== void 0) this.searches.get(agent)?.invalidate();
376
+ if (agent !== void 0) this.searches.get(agent)?.search.invalidate();
377
377
  });
378
378
  ctx.effect(() => async () => {
379
- for (const search of this.searches.values()) search.dispose();
379
+ for (const { search } of this.searches.values()) search.dispose();
380
380
  this.searches.clear();
381
381
  const promptFibers = [...this.promptFibers.values()];
382
382
  this.promptFibers.clear();
383
383
  await Promise.all([...promptFibers.map((fiber) => fiber.dispose()), ...this.promptDisposals]);
384
384
  }, "file-reference-local: search cache");
385
385
  }
386
- list(agent, query, signal) {
387
- let search = this.searches.get(agent);
388
- if (search === void 0) {
389
- search = new WorkspaceFileSearch(agent.session.header.cwd ?? process.cwd(), this.config);
390
- this.searches.set(agent, search);
386
+ async list(agent, query, signal) {
387
+ const cwd = await this.ctx.workingDirectory.ensure(agent, signal);
388
+ let cached = this.searches.get(agent);
389
+ if (cached?.cwd !== cwd) {
390
+ cached?.search.dispose();
391
+ cached = {
392
+ cwd,
393
+ search: new WorkspaceFileSearch(cwd, this.config)
394
+ };
395
+ this.searches.set(agent, cached);
391
396
  }
392
- return search.list(query, signal);
397
+ return cached.search.list(query, signal);
393
398
  }
394
399
  };
395
400
  function validateConfig(config) {
@@ -11,7 +11,7 @@ export { FILE_REFERENCE_PROMPT } from '@deepseek-ai/dsh-file-reference';
11
11
  export { activeAtToken, formatFileMention } from '@deepseek-ai/dsh-file-reference/grammar';
12
12
  /** Local-filesystem owner of the file-reference discovery service. */
13
13
  export class LocalFileReferenceService extends FileReferenceService {
14
- static inject = ['agents'];
14
+ static inject = ['agents', 'workingDirectory'];
15
15
  static Config = z.object({
16
16
  maxResults: z.number().step(1).min(1).default(DEFAULT_FILE_SEARCH_MAX_RESULTS),
17
17
  maxEntries: z.number().step(1).min(1).default(DEFAULT_FILE_SEARCH_MAX_ENTRIES),
@@ -60,7 +60,7 @@ export class LocalFileReferenceService extends FileReferenceService {
60
60
  installPrompt(agent);
61
61
  ctx.on('agent/created', async ({ agent }) => { await installPrompt(agent); });
62
62
  ctx.on('agent/disposed', ({ agent }) => {
63
- this.searches.get(agent)?.dispose();
63
+ this.searches.get(agent)?.search.dispose();
64
64
  this.searches.delete(agent);
65
65
  disposePrompt(agent);
66
66
  });
@@ -69,10 +69,10 @@ export class LocalFileReferenceService extends FileReferenceService {
69
69
  return;
70
70
  const agent = ctx.agents.get(session.id);
71
71
  if (agent !== undefined)
72
- this.searches.get(agent)?.invalidate();
72
+ this.searches.get(agent)?.search.invalidate();
73
73
  });
74
74
  ctx.effect(() => async () => {
75
- for (const search of this.searches.values())
75
+ for (const { search } of this.searches.values())
76
76
  search.dispose();
77
77
  this.searches.clear();
78
78
  const promptFibers = [...this.promptFibers.values()];
@@ -83,13 +83,15 @@ export class LocalFileReferenceService extends FileReferenceService {
83
83
  ]);
84
84
  }, 'file-reference-local: search cache');
85
85
  }
86
- list(agent, query, signal) {
87
- let search = this.searches.get(agent);
88
- if (search === undefined) {
89
- search = new WorkspaceFileSearch(agent.session.header.cwd ?? process.cwd(), this.config);
90
- this.searches.set(agent, search);
86
+ async list(agent, query, signal) {
87
+ const cwd = await this.ctx.workingDirectory.ensure(agent, signal);
88
+ let cached = this.searches.get(agent);
89
+ if (cached?.cwd !== cwd) {
90
+ cached?.search.dispose();
91
+ cached = { cwd, search: new WorkspaceFileSearch(cwd, this.config) };
92
+ this.searches.set(agent, cached);
91
93
  }
92
- return search.list(query, signal);
94
+ return cached.search.list(query, signal);
93
95
  }
94
96
  }
95
97
  function validateConfig(config) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deepseek-ai/dsh-file-reference-local",
3
3
  "description": "Local-filesystem ctx.fileReferences provider with bounded fuzzy indexes",
4
- "version": "0.2.0-rc.2",
4
+ "version": "0.2.1-alpha.2",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -32,20 +32,24 @@
32
32
  ],
33
33
  "license": "MIT",
34
34
  "dependencies": {
35
- "@deepseek-ai/schemastery": "~3.18.4"
35
+ "@deepseek-ai/schemastery": "~3.18.5-alpha.1"
36
36
  },
37
37
  "peerDependencies": {
38
- "@deepseek-ai/dsh-file-reference": "0.2.0-rc.2",
39
- "@deepseek-ai/dsh-system-prompt": "0.2.0-rc.2",
40
- "@deepseek-ai/dsh-tools": "0.2.0-rc.2",
41
- "@deepseek-ai/cordis": "~4.0.4",
42
- "@deepseek-ai/dsh-agent": "0.2.0-rc.2"
38
+ "@deepseek-ai/dsh-agent": "0.2.1-alpha.2",
39
+ "@deepseek-ai/dsh-file-reference": "0.2.1-alpha.2",
40
+ "@deepseek-ai/dsh-system-prompt": "0.2.1-alpha.2",
41
+ "@deepseek-ai/dsh-tools": "0.2.1-alpha.2",
42
+ "@deepseek-ai/cordis": "~4.0.5-alpha.1",
43
+ "@deepseek-ai/dsh-working-directory": "0.2.1-alpha.2"
43
44
  },
44
45
  "devDependencies": {
45
- "@deepseek-ai/dsh-agent": "0.2.0-rc.2",
46
- "@deepseek-ai/dsh-file-reference": "0.2.0-rc.2",
47
- "@deepseek-ai/dsh-system-prompt": "0.2.0-rc.2",
48
- "@deepseek-ai/dsh-tools": "0.2.0-rc.2",
49
- "@deepseek-ai/cordis": "~4.0.4"
46
+ "@deepseek-ai/dsh-agent": "0.2.1-alpha.2",
47
+ "@deepseek-ai/dsh-file-reference": "0.2.1-alpha.2",
48
+ "@deepseek-ai/dsh-system-prompt": "0.2.1-alpha.2",
49
+ "@deepseek-ai/dsh-tools": "0.2.1-alpha.2",
50
+ "@deepseek-ai/cordis": "~4.0.5-alpha.1",
51
+ "@deepseek-ai/dsh-working-directory": "0.2.1-alpha.2",
52
+ "@deepseek-ai/dsh-fs-local": "0.2.1-alpha.2",
53
+ "@deepseek-ai/dsh-session-projection": "0.2.1-alpha.2"
50
54
  }
51
55
  }