@qlzt/dsh-tool-fs-search 0.0.0-stage → 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/LICENSE +21 -0
- package/README.i18n.yaml +115 -0
- package/README.md +222 -2
- package/README.zh.md +223 -0
- package/lib/index.js +1272 -0
- package/lib/types/direct-call.d.ts +16 -0
- package/lib/types/glob.d.ts +146 -0
- package/lib/types/grep.d.ts +141 -0
- package/lib/types/index.d.ts +74 -0
- package/lib/types/presentation.d.ts +125 -0
- package/lib/types/search-core.d.ts +208 -0
- package/package.json +60 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 DeepSeek
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.i18n.yaml
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# Bilingual-pair consistency record for README.md (docs/i18n/README.md): per heading
|
|
2
|
+
# section, a hash of its English and Chinese blocks outside code blocks and generated regions.
|
|
3
|
+
# After editing either side, bring the other along and re-record with:
|
|
4
|
+
# pnpm run verify-translation-pairing --write packages/fs/tool-fs-search/README.md
|
|
5
|
+
/:
|
|
6
|
+
en: 117a1d8e2f2d3651
|
|
7
|
+
zh: 8a27e703652d670c
|
|
8
|
+
/deepseek-ai-dsh-tool-fs-search:
|
|
9
|
+
en: 6fd594ab2eacb521
|
|
10
|
+
zh: bcbce1550c71bbae
|
|
11
|
+
/deepseek-ai-dsh-tool-fs-search/summary:
|
|
12
|
+
en: a2d8407299a71efe
|
|
13
|
+
zh: d43338a4c7954a39
|
|
14
|
+
/deepseek-ai-dsh-tool-fs-search/table-of-contents:
|
|
15
|
+
en: d152484eb41ac6b4
|
|
16
|
+
zh: 09388d293f9be9cb
|
|
17
|
+
/deepseek-ai-dsh-tool-fs-search/use-this-package:
|
|
18
|
+
en: 494119ddc7157140
|
|
19
|
+
zh: 2fb6e69531ccb2b8
|
|
20
|
+
/deepseek-ai-dsh-tool-fs-search/use-this-package/minimal-composition:
|
|
21
|
+
en: a5a01d14e0bec814
|
|
22
|
+
zh: 409298cfafd91b05
|
|
23
|
+
/deepseek-ai-dsh-tool-fs-search/use-this-package/the-tools:
|
|
24
|
+
en: 9edb7655f8ed8bc6
|
|
25
|
+
zh: 21eadd65c1f2f07c
|
|
26
|
+
/deepseek-ai-dsh-tool-fs-search/use-this-package/configuration:
|
|
27
|
+
en: 3e84e19a22aeb6c8
|
|
28
|
+
zh: 8ac44b21eb697f2f
|
|
29
|
+
/deepseek-ai-dsh-tool-fs-search/use-this-package/deployment-requirement:
|
|
30
|
+
en: 4aa9b74deef586bc
|
|
31
|
+
zh: f855f815829d4e1e
|
|
32
|
+
/deepseek-ai-dsh-tool-fs-search/use-this-package/failures-and-recovery:
|
|
33
|
+
en: d7a59e296308b2bd
|
|
34
|
+
zh: 66243fcd932fe49a
|
|
35
|
+
/deepseek-ai-dsh-tool-fs-search/understand-the-implementation:
|
|
36
|
+
en: 7546db09c46181e0
|
|
37
|
+
zh: 3aae6dc6a773511c
|
|
38
|
+
/deepseek-ai-dsh-tool-fs-search/understand-the-implementation/design-concept:
|
|
39
|
+
en: 03bde21e022e845a
|
|
40
|
+
zh: 9c9e8b9a9713dda5
|
|
41
|
+
/deepseek-ai-dsh-tool-fs-search/understand-the-implementation/source-map:
|
|
42
|
+
en: 5a30f023dd86c345
|
|
43
|
+
zh: 558b6e80c62648ba
|
|
44
|
+
/deepseek-ai-dsh-tool-fs-search/understand-the-implementation/how-a-search-runs:
|
|
45
|
+
en: 8443370c1f347d0c
|
|
46
|
+
zh: 5f5c6fa8cdb97cba
|
|
47
|
+
/deepseek-ai-dsh-tool-fs-search/understand-the-implementation/two-budgets-two-artifacts:
|
|
48
|
+
en: b7e8c2191f8227dc
|
|
49
|
+
zh: a064e2e03761bfd5
|
|
50
|
+
/deepseek-ai-dsh-tool-fs-search/further-exploration:
|
|
51
|
+
en: 602fbbee4ebd695c
|
|
52
|
+
zh: 448634faeef2f321
|
|
53
|
+
/deepseek-ai-dsh-tool-fs-search/model-experience:
|
|
54
|
+
en: 215e7ba838619b7b
|
|
55
|
+
zh: a311da3843709f90
|
|
56
|
+
/deepseek-ai-dsh-tool-fs-search/model-experience/system-prompt:
|
|
57
|
+
en: cf78b9dd5596495f
|
|
58
|
+
zh: bd44560f8c2435e8
|
|
59
|
+
/deepseek-ai-dsh-tool-fs-search/model-experience/system-prompt/what-the-model-sees:
|
|
60
|
+
en: 0700638250399773
|
|
61
|
+
zh: a42336403025e9bd
|
|
62
|
+
/deepseek-ai-dsh-tool-fs-search/model-experience/system-prompt/what-the-model-sees/glob-guidance:
|
|
63
|
+
en: c8f798f1bf500fe7
|
|
64
|
+
zh: 9f56b60ec8ae1779
|
|
65
|
+
/deepseek-ai-dsh-tool-fs-search/model-experience/system-prompt/what-the-model-sees/grep-guidance:
|
|
66
|
+
en: 7ed8e5efe4deb2de
|
|
67
|
+
zh: eb8419d4579aeab2
|
|
68
|
+
/deepseek-ai-dsh-tool-fs-search/model-experience/system-prompt/token-effect:
|
|
69
|
+
en: c10c8a3e9e470e62
|
|
70
|
+
zh: c2a2404bfa4fd60a
|
|
71
|
+
/deepseek-ai-dsh-tool-fs-search/model-experience/system-prompt/kv-cache-effect:
|
|
72
|
+
en: db2f355d8209a537
|
|
73
|
+
zh: bd91d8e33a7042f6
|
|
74
|
+
/deepseek-ai-dsh-tool-fs-search/model-experience/tool-schemas:
|
|
75
|
+
en: 3039bc5e7a796b21
|
|
76
|
+
zh: 6b7a9eaf69c9ea53
|
|
77
|
+
/deepseek-ai-dsh-tool-fs-search/model-experience/tool-schemas/what-the-model-sees:
|
|
78
|
+
en: ab07aaec26eaa89a
|
|
79
|
+
zh: 693c46c42ebc3030
|
|
80
|
+
/deepseek-ai-dsh-tool-fs-search/model-experience/tool-schemas/token-effect:
|
|
81
|
+
en: 023a80f81229887f
|
|
82
|
+
zh: 5410d27cde4fb656
|
|
83
|
+
/deepseek-ai-dsh-tool-fs-search/model-experience/tool-schemas/kv-cache-effect:
|
|
84
|
+
en: 4555717d7b481f52
|
|
85
|
+
zh: 88d5f239ac01f197
|
|
86
|
+
/deepseek-ai-dsh-tool-fs-search/model-experience/results-and-spill-notices:
|
|
87
|
+
en: e9d1330ebd642a0d
|
|
88
|
+
zh: f9bc6dffb0afd878
|
|
89
|
+
/deepseek-ai-dsh-tool-fs-search/model-experience/results-and-spill-notices/what-the-model-sees:
|
|
90
|
+
en: 3a357b506d327e18
|
|
91
|
+
zh: b2d97abd9af096d4
|
|
92
|
+
/deepseek-ai-dsh-tool-fs-search/model-experience/results-and-spill-notices/token-effect:
|
|
93
|
+
en: 033a5b99fec018a1
|
|
94
|
+
zh: 79fc41e856cd9925
|
|
95
|
+
/deepseek-ai-dsh-tool-fs-search/model-experience/results-and-spill-notices/kv-cache-effect:
|
|
96
|
+
en: f5d5f97a153f7c70
|
|
97
|
+
zh: 14660e568cd51bdc
|
|
98
|
+
/deepseek-ai-dsh-tool-fs-search/model-experience/tool-errors:
|
|
99
|
+
en: 2d4f2c8605eccab3
|
|
100
|
+
zh: 67f1f0218f73c6bf
|
|
101
|
+
/deepseek-ai-dsh-tool-fs-search/model-experience/tool-errors/what-the-model-sees:
|
|
102
|
+
en: 375c4554a70d93a4
|
|
103
|
+
zh: 372a088c6ecf68ab
|
|
104
|
+
/deepseek-ai-dsh-tool-fs-search/model-experience/tool-errors/token-effect:
|
|
105
|
+
en: 681cadd5be7b8ac1
|
|
106
|
+
zh: 1f0102977ea02785
|
|
107
|
+
/deepseek-ai-dsh-tool-fs-search/model-experience/tool-errors/kv-cache-effect:
|
|
108
|
+
en: f5d5f97a153f7c70
|
|
109
|
+
zh: 14660e568cd51bdc
|
|
110
|
+
/deepseek-ai-dsh-tool-fs-search/known-limitations-and-deferred-work:
|
|
111
|
+
en: 4fca846226cb8ef2
|
|
112
|
+
zh: fb797ec586cec7f4
|
|
113
|
+
/deepseek-ai-dsh-tool-fs-search/known-limitations-and-deferred-work/dev-note:
|
|
114
|
+
en: e67f633dc6fe7773
|
|
115
|
+
zh: 3bb0c20c93f16f98
|
package/README.md
CHANGED
|
@@ -1,3 +1,223 @@
|
|
|
1
|
-
|
|
1
|
+
---
|
|
2
|
+
description: "The model-facing glob and grep discovery tools for users and maintainers composing or debugging workspace search for agents."
|
|
3
|
+
kind: "package-reference"
|
|
4
|
+
---
|
|
2
5
|
|
|
3
|
-
|
|
6
|
+
# @deepseek-ai/dsh-tool-fs-search
|
|
7
|
+
|
|
8
|
+
English | [中文](README.zh.md)
|
|
9
|
+
|
|
10
|
+
## Summary
|
|
11
|
+
|
|
12
|
+
Use `dsh-tool-fs-search` to give models `glob` file discovery and `grep` content search over a local workspace. Searches need no host `rg` installation or filesystem provider, return workdir-relative results, and include hidden and ignored files while excluding VCS metadata. Configurable caps bound inline output; with an optional spill store, capped results remain fully recoverable. Choose the sibling `dsh-tool-fs` package for reading, writing, or editing files.
|
|
13
|
+
|
|
14
|
+
## Table of Contents
|
|
15
|
+
|
|
16
|
+
- [Use this package](#use-this-package)
|
|
17
|
+
- [Understand the implementation](#understand-the-implementation)
|
|
18
|
+
- [Further Exploration](#further-exploration)
|
|
19
|
+
- [Model Experience](#model-experience)
|
|
20
|
+
- [Known Limitations and Deferred Work](#known-limitations-and-deferred-work)
|
|
21
|
+
- [Dev Note](#dev-note)
|
|
22
|
+
|
|
23
|
+
-----
|
|
24
|
+
|
|
25
|
+
<a id="use-this-package"></a>
|
|
26
|
+
## Use this package
|
|
27
|
+
|
|
28
|
+
Searches use the Session's current working directory, including changes made with `working_directory`.
|
|
29
|
+
|
|
30
|
+
Mount the tools after a `ctx.subprocess` backend; no host `rg` install is needed, and no filesystem provider is required. The model then gets modification-time-ordered file discovery and line-oriented content search, each bounded and timeout-guarded.
|
|
31
|
+
|
|
32
|
+
### Minimal composition
|
|
33
|
+
|
|
34
|
+
A subprocess backend, then the tools; the spill backend is optional and makes capped results fully recoverable.
|
|
35
|
+
|
|
36
|
+
```yaml
|
|
37
|
+
- name: '@deepseek-ai/dsh-subprocess-local'
|
|
38
|
+
- name: '@deepseek-ai/dsh-tool-fs-search'
|
|
39
|
+
config:
|
|
40
|
+
sampleOverCapGlobResults: false
|
|
41
|
+
- name: '@deepseek-ai/dsh-spill-local'
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
`sampleOverCapGlobResults` is required and has no fallback: deployments choose the over-cap ordering contract explicitly. When formatted spill succeeds, both modes preserve the complete sorted list in the spill artifact.
|
|
45
|
+
|
|
46
|
+
### The tools
|
|
47
|
+
|
|
48
|
+
| Tool | Arguments | Behavior |
|
|
49
|
+
|---|---|---|
|
|
50
|
+
| `glob` | `pattern`, `path?` | Finds files whose paths match a glob pattern, including hidden and ignored files but excluding VCS metadata; a pattern with no `/` matches basenames at any depth, so `*` matches the whole tree; complete results stay modification-time ordered |
|
|
51
|
+
| `grep` | `pattern`, `path?`, `include?` | Searches file contents with a ripgrep regex and returns matches grouped by file as `Line N: <preview>`; `include` is one positive glob filter, with comma-separated lists and negated values rejected up front |
|
|
52
|
+
|
|
53
|
+
Routine budgets stay out of the model-facing schema: a model that needs surrounding context reads the matched file with `read`, and one that needs later results follows the returned spill locator's retrieval hint.
|
|
54
|
+
|
|
55
|
+
### Configuration
|
|
56
|
+
|
|
57
|
+
`sampleOverCapGlobResults` is required; the remaining keys are optional search caps with the defaults below.
|
|
58
|
+
|
|
59
|
+
| Key | Default | Meaning |
|
|
60
|
+
|---|---|---|
|
|
61
|
+
| `sampleOverCapGlobResults` | none (required) | `true` samples an over-cap `glob` page across top-level entries; `false` keeps the modification-time-ordered head |
|
|
62
|
+
| `globMaxResults` | `100` | Max paths one `glob` call shows inline |
|
|
63
|
+
| `grepMaxMatches` | `250` | Max flat matches one `grep` call retains inline; later matches go to the formatted spill artifact |
|
|
64
|
+
| `grepMaxLineBytes` | `2000` | Byte cap per matched-line preview, preserving UTF-8 boundaries |
|
|
65
|
+
| `rawOutputMaxBytes` | `20000000` | Max complete raw `rg` stdout a search will parse; larger raw output fails with `SEARCH_RAW_OUTPUT_OVERFLOW` |
|
|
66
|
+
| `timeoutMs` | `30000` | Cooperative tool-call budget on both tools, enforced through `exec.signal` |
|
|
67
|
+
| `graceMs` | `3000` | Terminate-escalation grace the subprocess seam grants past `timeoutMs` |
|
|
68
|
+
| `stderrMaxBytes` | `65536` | Diagnostic-tail budget for `rg` stderr |
|
|
69
|
+
| `searchMetaMaxBytes` | `65536` | Max bytes of one search's serialized `presentationMeta`; trailing groups/paths drop past it |
|
|
70
|
+
|
|
71
|
+
The generated [configuration catalog](../../../docs/config-catalog.md#deepseek-aidsh-tool-fs-search) is the exhaustive source for every accepted field and its JSDoc.
|
|
72
|
+
|
|
73
|
+
### Deployment requirement
|
|
74
|
+
|
|
75
|
+
Node deployments receive the `@vscode/ripgrep` platform package on supported macOS, Linux, and Windows targets; Python SDK wheels copy the target-native binary beside the single-file runtime as a `-rg` sidecar. No carrier requires a host `rg`. Returned paths are displayed relative to the resolved workdir (the calling session's cwd when present) and are follow-up-readable with `read` only when that workdir and the filesystem root are the same workspace.
|
|
76
|
+
|
|
77
|
+
### Failures and recovery
|
|
78
|
+
|
|
79
|
+
Search failures carry the package-owned codes `SEARCH_INVALID_PATTERN` (ripgrep rejected the regex or glob), `SEARCH_FAILED` (a failed launch, inaccessible target, signal kill, or malformed `--json` output), `SEARCH_RAW_OUTPUT_OVERFLOW` (raw output over the cap), and `SEARCH_ABORTED` (cooperative timeout or caller cancellation). Exit 0 is success with results and exit 1 is a successful empty search; model argument mistakes stay ordinary tool argument errors.
|
|
80
|
+
|
|
81
|
+
-----
|
|
82
|
+
|
|
83
|
+
<a id="understand-the-implementation"></a>
|
|
84
|
+
## Understand the implementation
|
|
85
|
+
|
|
86
|
+
<details>
|
|
87
|
+
<summary>Implementation internals — click to expand</summary>
|
|
88
|
+
|
|
89
|
+
This section explains the design decisions behind the search tools and points at the code that realizes them; the observable behavior is fully covered in [Use this package](#use-this-package).
|
|
90
|
+
|
|
91
|
+
### Design concept
|
|
92
|
+
|
|
93
|
+
Local workspace discovery is naturally a process-backed `rg` workflow, and putting search on `ctx.fs` would force every filesystem backend to grow a search API. The subprocess seam owns spawn execution, process-tree termination, environment scrubbing, and bounded output capture; this package owns schemas, argument validation, argv construction, parsing, retention, formatted-result spill, and timeout declaration. The tools never expose a background job — the call returns only after `rg` exits, is terminated by the cooperative timeout, is aborted, or fails.
|
|
94
|
+
|
|
95
|
+
### Source map
|
|
96
|
+
|
|
97
|
+
| File | Role |
|
|
98
|
+
|---|---|
|
|
99
|
+
| [`src/index.ts`](src/index.ts) | Plugin entry: `Config`, tool composition, cap validation |
|
|
100
|
+
| [`src/glob.ts`](src/glob.ts) | `glob` schema, argv, parsing, inline sampling, formatting |
|
|
101
|
+
| [`src/grep.ts`](src/grep.ts) | `grep` schema, argv, `--json` parsing, preview retention, formatting |
|
|
102
|
+
| [`src/search-core.ts`](src/search-core.ts) | Shared spawn helper, `SEARCH_*` errors, spill handoff, workdir-relative display |
|
|
103
|
+
| [`src/presentation.ts`](src/presentation.ts) | Search-card metadata projection |
|
|
104
|
+
| [`src/direct-call.ts`](src/direct-call.ts) | Direct-call result acceptance for spill post-processing |
|
|
105
|
+
|
|
106
|
+
### How a search runs
|
|
107
|
+
|
|
108
|
+
Each call resolves the packaged binary (`@vscode/ripgrep`, or the executable's `-rg` sidecar in a pkg single-file runtime), prepends `--no-config` so a host `RIPGREP_CONFIG_PATH` cannot inject a `--pre` preprocessor into the unconfined spawn, and passes every model-controlled value as a plain argv element — no shell layer exists, so no quoting applies. Collect-mode budgets bound complete stdout and a stderr tail; a lossy stdout read fails as `SEARCH_RAW_OUTPUT_OVERFLOW` rather than parsing a silently-partial stream. The tools never read a raw spill path.
|
|
109
|
+
|
|
110
|
+
### Two budgets, two artifacts
|
|
111
|
+
|
|
112
|
+
Raw stdout and stderr are internal transport details; the tools always collect the complete result in memory, and only the inline page is capped. When a call yields more logical results than the inline cap, a best-effort spill saves the complete formatted preview to the spill store and the page carries its locator, while dispatches whose full value never enters model context skip the spill. Missing or failed spill keeps the inline page and reports that the complete result could not be saved — never an error. The collection and spill handoff live in `src/search-core.ts` and `src/presentation.ts`.
|
|
113
|
+
|
|
114
|
+
</details>
|
|
115
|
+
|
|
116
|
+
-----
|
|
117
|
+
|
|
118
|
+
<a id="further-exploration"></a>
|
|
119
|
+
## Further Exploration
|
|
120
|
+
|
|
121
|
+
Read these pages when the package-level contract is not enough. They move from the tools to the subprocess seam, the spill store, and the filesystem family.
|
|
122
|
+
|
|
123
|
+
- [Filesystem subsystem](../../../docs/subsystems/filesystem.md) — exhaustive provider contract, policy events, and error taxonomy.
|
|
124
|
+
- [tool-fs](../tool-fs/README.md) — the sibling `read`/`write`/`edit` tools for follow-up reads.
|
|
125
|
+
- [Subprocess capability](../../../docs/subsystems/subprocess.md) — the spawn seam these tools execute through.
|
|
126
|
+
- [Spill store](../../spill/spill/README.md) — the optional backend that makes capped results fully recoverable.
|
|
127
|
+
- [Timeout utility](../../util/timeout/README.md) — the `MAX_TIMER_DELAY_MS` bound on the terminate grace.
|
|
128
|
+
- [Generated tool catalog](../../../docs/tool-catalog.md#deepseek-aidsh-tool-fs-search) — the exhaustive schemas this package registers.
|
|
129
|
+
|
|
130
|
+
-----
|
|
131
|
+
|
|
132
|
+
<a id="model-experience"></a>
|
|
133
|
+
## Model Experience
|
|
134
|
+
|
|
135
|
+
### System prompt
|
|
136
|
+
|
|
137
|
+
#### What the model sees
|
|
138
|
+
|
|
139
|
+
At assembly time, each section checks `ctx.tools.get(name, scope)` and renders only while its tool is visible. The grep paragraph includes its read follow-up sentence only while read is visible. The original text and section order stay unchanged for the same supported tool set, including PTC capabilities behind `run_code`. This scope-dependent text selection applies to system-prompt sections. Tool schema descriptions remain registration-time text and do not name other tools.
|
|
140
|
+
|
|
141
|
+
##### Glob guidance
|
|
142
|
+
|
|
143
|
+
```markdown
|
|
144
|
+
Use the glob tool — not shell find — to discover files by path pattern.
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
##### Grep guidance
|
|
148
|
+
|
|
149
|
+
```markdown
|
|
150
|
+
Use the grep tool — not shell grep or rg — to search file contents. Use read on a matched file when you need surrounding context.
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
#### Token effect
|
|
154
|
+
|
|
155
|
+
Guidance cost follows the visible tools; the required sampling choice selects one glob variant.
|
|
156
|
+
|
|
157
|
+
#### KV Cache effect
|
|
158
|
+
|
|
159
|
+
Prefix-stable while the visible tool set, plugin scope, sampling choice, and guidance text are unchanged. Restrictions, activation, disposal, or changing the choice may invalidate reuse from the first changed section.
|
|
160
|
+
|
|
161
|
+
### Tool schemas
|
|
162
|
+
|
|
163
|
+
#### What the model sees
|
|
164
|
+
|
|
165
|
+
The glob description states the configured over-cap ordering. The generated [`glob` and `grep` schemas](../../../docs/tool-catalog.md#deepseek-aidsh-tool-fs-search) use `sampleOverCapGlobResults: true`; the tools are registered unconditionally.
|
|
166
|
+
|
|
167
|
+
#### Token effect
|
|
168
|
+
|
|
169
|
+
Fixed schema cost on every request where the tools are visible.
|
|
170
|
+
|
|
171
|
+
#### KV Cache effect
|
|
172
|
+
|
|
173
|
+
Prefix-stable while tool visibility and definitions are unchanged. Registration lifecycle or scoped restrictions may invalidate reuse from the first changed schema token.
|
|
174
|
+
|
|
175
|
+
### Results and spill notices
|
|
176
|
+
|
|
177
|
+
#### What the model sees
|
|
178
|
+
|
|
179
|
+
`glob` returns one path per line; `grep` groups `Line <line>: <preview>` matches beneath each path. Empty searches return `No files found` or `No matches found`. A capped result ends with its omission count plus the spill locator and backend retrieval hint, or says the complete result could not be saved. With `sampleOverCapGlobResults: true`, an over-cap `glob` page takes paths round-robin across entries immediately beneath the actual search root, and the footer states the sampled basis and how many top-level entries it reached; with `false`, the page is the modification-time-ordered head and keeps the plain capped-result footer. The spill artifact always holds the complete list in modification-time order.
|
|
180
|
+
|
|
181
|
+
#### Token effect
|
|
182
|
+
|
|
183
|
+
Inline paths and matches are bounded by `globMaxResults`, `grepMaxMatches`, and `grepMaxLineBytes`; the call and retained result remain in history until compaction.
|
|
184
|
+
|
|
185
|
+
#### KV Cache effect
|
|
186
|
+
|
|
187
|
+
Append-only; newly visible content follows the reusable request prefix and does not invalidate existing KV-cache entries.
|
|
188
|
+
|
|
189
|
+
### Tool errors
|
|
190
|
+
|
|
191
|
+
#### What the model sees
|
|
192
|
+
|
|
193
|
+
Failures are normalized as `Error: <message>` with structured `SEARCH_INVALID_PATTERN`, `SEARCH_FAILED`, `SEARCH_RAW_OUTPUT_OVERFLOW`, or `SEARCH_ABORTED` metadata for callers.
|
|
194
|
+
|
|
195
|
+
#### Token effect
|
|
196
|
+
|
|
197
|
+
Only a failing call adds these retained tokens.
|
|
198
|
+
|
|
199
|
+
#### KV Cache effect
|
|
200
|
+
|
|
201
|
+
Append-only; newly visible content follows the reusable request prefix and does not invalidate existing KV-cache entries.
|
|
202
|
+
|
|
203
|
+
## Known Limitations and Deferred Work
|
|
204
|
+
|
|
205
|
+
<a id="known-limitations-and-deferred-work"></a>
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
These limits define when the search tools are a poor fit or need special operational care. They are current package constraints, not a general search comparison or a task backlog.
|
|
209
|
+
|
|
210
|
+
- **Search and file access have no shared-workspace proof** — returned paths are follow-up-readable only when the workdir and filesystem root denote the same workspace; the package performs no runtime cross-service validation.
|
|
211
|
+
- **The packaged binary is fixed at dependency version** — Node deployments use the version selected by `@vscode/ripgrep`; Python single-file runtimes copy that target-native version into the required `-rg` sidecar. An unsupported platform or a corrupted installation fails with `SEARCH_FAILED`, while the Python runtime package rejects a missing sidecar before launch. Remote or virtual filesystems need a co-located workspace or another search consumer.
|
|
212
|
+
- **The schemas expose one bounded page** — offset pagination, case-mode switches, alternate output modes, and provider-backed discovery remain outside this package; capped complete output requires a spill backend.
|
|
213
|
+
- **Sampling, when enabled, groups by first path segment beneath the search root only** — an over-cap `glob` page balances across those top-level entries, so a result concentrated deeper is still shown unevenly below that level; recursive balancing is deferred.
|
|
214
|
+
|
|
215
|
+
<a id="dev-note"></a>
|
|
216
|
+
### Dev Note
|
|
217
|
+
|
|
218
|
+
<details>
|
|
219
|
+
<summary>Working context for maintainers — click to expand</summary>
|
|
220
|
+
|
|
221
|
+
None.
|
|
222
|
+
|
|
223
|
+
</details>
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "面向模型的 glob 与 grep 发现工具:供组合或排查 agent(智能体)工作区搜索的用户与维护者使用。"
|
|
3
|
+
kind: "package-reference"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# @deepseek-ai/dsh-tool-fs-search
|
|
7
|
+
|
|
8
|
+
[English](README.md) | 中文
|
|
9
|
+
|
|
10
|
+
## 概述
|
|
11
|
+
|
|
12
|
+
使用 `dsh-tool-fs-search` 为模型提供本地工作区中的 `glob` 文件发现与 `grep` 内容搜索。搜索无需在宿主上安装 `rg`,也无需文件系统提供方;结果相对于工作目录,并包含隐藏与忽略文件但排除 VCS 元数据。可配置上限约束内联输出;挂载可选 spill 存储后,达到上限的结果仍可完整恢复。若需读取、写入或编辑文件,请选择同级 `dsh-tool-fs` 包。
|
|
13
|
+
|
|
14
|
+
## 目录
|
|
15
|
+
|
|
16
|
+
- [使用本包](#use-this-package)
|
|
17
|
+
- [理解实现](#understand-the-implementation)
|
|
18
|
+
- [进一步探索](#further-exploration)
|
|
19
|
+
- [模型体验](#model-experience)
|
|
20
|
+
- [已知限制与延期工作](#known-limitations-and-deferred-work)
|
|
21
|
+
- [开发备注](#dev-note)
|
|
22
|
+
|
|
23
|
+
-----
|
|
24
|
+
|
|
25
|
+
<a id="use-this-package"></a>
|
|
26
|
+
## 使用本包
|
|
27
|
+
|
|
28
|
+
搜索使用 Session 的当前工作目录,包括通过 `working_directory` 切换后的目录。
|
|
29
|
+
|
|
30
|
+
在 `ctx.subprocess` 后端之后挂载工具;无需宿主 `rg` 安装,也无需文件系统提供方。模型随后获得按修改时间排序的文件发现与按行组织的内容搜索,两者都有界并受超时防护。
|
|
31
|
+
|
|
32
|
+
### 最小组合
|
|
33
|
+
|
|
34
|
+
一个子进程后端,然后是工具;spill 后端为可选,使达到上限的结果可完整恢复。
|
|
35
|
+
|
|
36
|
+
```yaml
|
|
37
|
+
- name: '@deepseek-ai/dsh-subprocess-local'
|
|
38
|
+
- name: '@deepseek-ai/dsh-tool-fs-search'
|
|
39
|
+
config:
|
|
40
|
+
sampleOverCapGlobResults: false
|
|
41
|
+
- name: '@deepseek-ai/dsh-spill-local'
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
`sampleOverCapGlobResults` 是必填项且没有回退值:部署必须显式选择超过上限时的排序约定。格式化 spill 成功时,两种模式都会在 spill 产物中保留完整排序列表。
|
|
45
|
+
|
|
46
|
+
### 工具
|
|
47
|
+
|
|
48
|
+
| 工具 | 参数 | 行为 |
|
|
49
|
+
|---|---|---|
|
|
50
|
+
| `glob` | `pattern`、`path?` | 查找路径匹配 glob 模式的文件,包含隐藏与忽略文件但排除 VCS 元数据;不含 `/` 的模式匹配任意深度的基名,因此 `*` 匹配整棵树;完整结果保持按修改时间排序 |
|
|
51
|
+
| `grep` | `pattern`、`path?`、`include?` | 用 ripgrep 正则搜索文件内容,并按文件分组返回 `Line N: <preview>` 匹配;`include` 是一个正向 glob 过滤器,逗号分隔列表与否定值会被前置拒绝 |
|
|
52
|
+
|
|
53
|
+
常规预算不进入面向模型的 schema:需要周边上下文的模型用 `read` 读取匹配文件,需要后续结果的模型遵循返回的 spill locator 检索提示。
|
|
54
|
+
|
|
55
|
+
### 配置
|
|
56
|
+
|
|
57
|
+
`sampleOverCapGlobResults` 为必填;其余键是可选的搜索上限,默认值如下。
|
|
58
|
+
|
|
59
|
+
| 键 | 默认值 | 含义 |
|
|
60
|
+
|---|---|---|
|
|
61
|
+
| `sampleOverCapGlobResults` | 无(必填) | `true` 在顶层条目之间对超过上限的 `glob` 页面采样;`false` 保留按修改时间排序的前部 |
|
|
62
|
+
| `globMaxResults` | `100` | 一次 `glob` 调用内联展示的最大路径数 |
|
|
63
|
+
| `grepMaxMatches` | `250` | 一次 `grep` 调用内联保留的最大平铺匹配数;后续匹配写入格式化 spill 产物 |
|
|
64
|
+
| `grepMaxLineBytes` | `2000` | 每条匹配行预览的字节上限,保留 UTF-8 边界 |
|
|
65
|
+
| `rawOutputMaxBytes` | `20000000` | 搜索将解析的完整原始 `rg` stdout 上限;更大的原始输出以 `SEARCH_RAW_OUTPUT_OVERFLOW` 失败 |
|
|
66
|
+
| `timeoutMs` | `30000` | 附加到两个工具的协作式工具调用预算,通过 `exec.signal` 强制执行 |
|
|
67
|
+
| `graceMs` | `3000` | subprocess seam 在 `timeoutMs` 之外授予的终止升级宽限期 |
|
|
68
|
+
| `stderrMaxBytes` | `65536` | `rg` stderr 的诊断尾部预算 |
|
|
69
|
+
| `searchMetaMaxBytes` | `65536` | 一次搜索序列化 `presentationMeta` 的字节上限;超出部分丢弃尾部的组/路径 |
|
|
70
|
+
|
|
71
|
+
生成的[配置目录](../../../docs/config-catalog.zh.md#deepseek-aidsh-tool-fs-search)是每个受支持字段及其 JSDoc 的穷尽式真源。
|
|
72
|
+
|
|
73
|
+
### 部署要求
|
|
74
|
+
|
|
75
|
+
Node 部署在受支持的 macOS、Linux 与 Windows 目标上获得 `@vscode/ripgrep` 平台包;Python SDK 的 wheel 包把目标原生二进制复制到单文件运行时旁,作为 `-rg` 伴随文件。两种载体均不要求宿主安装 `rg`。返回路径相对于解析后的工作目录显示(有会话 cwd 时使用会话 cwd),只有该工作目录与文件系统根目录是同一工作区时,才能用 `read` 继续读取。
|
|
76
|
+
|
|
77
|
+
### 失败与恢复
|
|
78
|
+
|
|
79
|
+
搜索失败携带本包定义的错误码:`SEARCH_INVALID_PATTERN`(ripgrep 拒绝正则或 glob)、`SEARCH_FAILED`(启动失败、目标不可访问、信号终止或 `--json` 输出格式错误)、`SEARCH_RAW_OUTPUT_OVERFLOW`(原始输出超过上限)与 `SEARCH_ABORTED`(协作式超时或调用方取消)。退出 0 表示成功且有结果,退出 1 表示成功的空搜索;模型参数错误仍是普通工具参数错误。
|
|
80
|
+
|
|
81
|
+
-----
|
|
82
|
+
|
|
83
|
+
<a id="understand-the-implementation"></a>
|
|
84
|
+
## 理解实现
|
|
85
|
+
|
|
86
|
+
<details>
|
|
87
|
+
<summary>实现细节——点击展开</summary>
|
|
88
|
+
|
|
89
|
+
本节解释搜索工具背后的设计决策,并指出实现它们的代码位置;可观察行为已在[使用本包](#use-this-package)中完整说明。
|
|
90
|
+
|
|
91
|
+
### 设计理念
|
|
92
|
+
|
|
93
|
+
本地工作区发现天然是由进程支持的 `rg` 工作流;如果把搜索放到 `ctx.fs` 上,就会迫使每个文件系统后端扩展搜索 API。subprocess seam 负责 spawn 执行、进程树终止、环境清理与有界输出捕获;本包负责 schema、参数校验、argv 构造、解析、保留、格式化结果 spill 与超时声明。工具绝不暴露后台任务——只有在 `rg` 退出、被协作式超时终止、被中止或失败后,调用才会返回。
|
|
94
|
+
|
|
95
|
+
### 源码地图
|
|
96
|
+
|
|
97
|
+
| 文件 | 职责 |
|
|
98
|
+
|---|---|
|
|
99
|
+
| [`src/index.ts`](src/index.ts) | 插件入口:`Config`、工具组合、上限校验 |
|
|
100
|
+
| [`src/glob.ts`](src/glob.ts) | `glob` schema、argv、解析、内联采样、格式化 |
|
|
101
|
+
| [`src/grep.ts`](src/grep.ts) | `grep` schema、argv、`--json` 解析、预览保留、格式化 |
|
|
102
|
+
| [`src/search-core.ts`](src/search-core.ts) | 共享 spawn 助手、`SEARCH_*` 错误、spill 交接、工作目录相对展示 |
|
|
103
|
+
| [`src/presentation.ts`](src/presentation.ts) | 搜索卡片元数据投影 |
|
|
104
|
+
| [`src/direct-call.ts`](src/direct-call.ts) | spill 后处理的直接调用结果接受 |
|
|
105
|
+
|
|
106
|
+
### 搜索如何运行
|
|
107
|
+
|
|
108
|
+
每次调用解析打包二进制(`@vscode/ripgrep`,或 pkg 单文件运行时中可执行程序的 `-rg` 伴随文件),前置 `--no-config`,使宿主的 `RIPGREP_CONFIG_PATH` 无法向不受约束的 spawn 注入 `--pre` 预处理器,并把每个模型控制的值作为普通 argv 元素传入——不存在 shell 层,因此不涉及 shell 引号处理。collect 模式预算限制完整 stdout 与 stderr 尾部;lossy stdout 读取以 `SEARCH_RAW_OUTPUT_OVERFLOW` 失败,而不是解析静默不完整的流。工具从不读取原始 spill 路径。
|
|
109
|
+
|
|
110
|
+
### 两类预算、两类产物
|
|
111
|
+
|
|
112
|
+
原始 stdout 与 stderr 是内部传输细节;工具始终把完整结果收集到内存中,只有内联页面设有上限。当调用产生超过内联上限的逻辑结果时,尽力而为的 spill 会把完整格式化预览保存到 spill 存储,页面携带其 locator;完整值不会进入模型上下文的分派则跳过 spill。spill 缺失或失败时保留内联页面,并报告完整结果无法保存——绝不会成为错误。收集与 spill 交接位于 `src/search-core.ts` 与 `src/presentation.ts`。
|
|
113
|
+
|
|
114
|
+
</details>
|
|
115
|
+
|
|
116
|
+
-----
|
|
117
|
+
|
|
118
|
+
<a id="further-exploration"></a>
|
|
119
|
+
## 进一步探索
|
|
120
|
+
|
|
121
|
+
当包级约定不够用时阅读以下页面。它们从工具逐步进入 subprocess seam、spill 存储与文件系统家族。
|
|
122
|
+
|
|
123
|
+
- [文件系统子系统](../../../docs/subsystems/filesystem.zh.md)——穷尽式提供方约定、策略事件与错误分类体系。
|
|
124
|
+
- [tool-fs](../tool-fs/README.zh.md)——用于后续读取的同级 `read`/`write`/`edit` 工具。
|
|
125
|
+
- [子进程能力](../../../docs/subsystems/subprocess.zh.md)——这些工具执行所经由的 spawn seam。
|
|
126
|
+
- [Spill 存储](../../spill/spill/README.zh.md)——使达到上限结果可完整恢复的可选后端。
|
|
127
|
+
- [超时工具](../../util/timeout/README.zh.md)——终止宽限期的 `MAX_TIMER_DELAY_MS` 上限。
|
|
128
|
+
- [生成工具目录](../../../docs/tool-catalog.zh.md#deepseek-aidsh-tool-fs-search)——本包注册的穷尽式 schema。
|
|
129
|
+
|
|
130
|
+
-----
|
|
131
|
+
|
|
132
|
+
<a id="model-experience"></a>
|
|
133
|
+
## 模型体验
|
|
134
|
+
|
|
135
|
+
### 系统提示词
|
|
136
|
+
|
|
137
|
+
#### 模型看到的内容
|
|
138
|
+
|
|
139
|
+
组装时,每个段落通过 `ctx.tools.get(name, scope)` 检查对应工具,仅在其可见时输出。grep 段落仅在 read 可见时包含后续使用 read 的句子。同一受支持工具集合下,原文和段落顺序保持不变,包括通过 `run_code` 暴露的 PTC 能力。 这种按 scope 选择文本的机制适用于系统提示词段落。工具 schema 描述仍是注册时的文本,不提及其他工具。
|
|
140
|
+
|
|
141
|
+
##### Glob 指导
|
|
142
|
+
|
|
143
|
+
```markdown
|
|
144
|
+
Use the glob tool — not shell find — to discover files by path pattern.
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
##### Grep 指导
|
|
148
|
+
|
|
149
|
+
```markdown
|
|
150
|
+
Use the grep tool — not shell grep or rg — to search file contents. Use read on a matched file when you need surrounding context.
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
#### Token 影响
|
|
154
|
+
|
|
155
|
+
指导成本取决于可见工具;必填的采样选择决定采用哪一个 glob 变体。
|
|
156
|
+
|
|
157
|
+
#### KV Cache 影响
|
|
158
|
+
|
|
159
|
+
可见工具集合、插件作用域、采样选择与指导文本不变时前缀稳定。限制、激活、dispose(资源释放)或改变选择可能从首个变化的段落开始使复用失效。
|
|
160
|
+
|
|
161
|
+
### 工具 schema
|
|
162
|
+
|
|
163
|
+
#### 模型看到的内容
|
|
164
|
+
|
|
165
|
+
glob 描述声明了配置的超过上限排序方式。生成的 [`glob` 和 `grep` schema](../../../docs/tool-catalog.zh.md#deepseek-aidsh-tool-fs-search) 使用 `sampleOverCapGlobResults: true`;工具无条件注册。
|
|
166
|
+
|
|
167
|
+
#### Token 影响
|
|
168
|
+
|
|
169
|
+
工具可见时每个请求有固定的 schema 成本。
|
|
170
|
+
|
|
171
|
+
#### KV Cache 影响
|
|
172
|
+
|
|
173
|
+
工具可见性与定义不变时前缀稳定。注册生命周期或作用域限制可能从第一个改变的 schema token 起使复用失效。
|
|
174
|
+
|
|
175
|
+
### 结果与 spill 提示
|
|
176
|
+
|
|
177
|
+
#### 模型看到的内容
|
|
178
|
+
|
|
179
|
+
`glob` 每行返回一个路径;`grep` 在每个路径下分组展示 `Line <line>: <preview>` 匹配。空搜索返回 `No files found` 或 `No matches found`。达到上限的结果以省略计数结尾,并附 spill locator 与后端检索提示,或说明完整结果无法保存。启用 `sampleOverCapGlobResults: true` 时,超过上限的 `glob` 页面按实际搜索根正下方的条目轮转取路径,页脚说明采样依据及其覆盖的顶层条目数;`false` 时页面是按修改时间排序的前部,并保留普通的上限结果页脚。spill 产物始终持有按修改时间排序的完整列表。
|
|
180
|
+
|
|
181
|
+
#### Token 影响
|
|
182
|
+
|
|
183
|
+
内联路径与匹配受 `globMaxResults`、`grepMaxMatches` 与 `grepMaxLineBytes` 约束;调用及其保留结果在压缩(compaction)前留在历史中。
|
|
184
|
+
|
|
185
|
+
#### KV Cache 影响
|
|
186
|
+
|
|
187
|
+
仅追加;新可见内容跟在可复用请求前缀之后,不会使既有 KV Cache 条目失效。
|
|
188
|
+
|
|
189
|
+
### 工具错误
|
|
190
|
+
|
|
191
|
+
#### 模型看到的内容
|
|
192
|
+
|
|
193
|
+
失败被规范化为 `Error: <message>`,并携带结构化 `SEARCH_INVALID_PATTERN`、`SEARCH_FAILED`、`SEARCH_RAW_OUTPUT_OVERFLOW` 或 `SEARCH_ABORTED` 元数据供调用方使用。
|
|
194
|
+
|
|
195
|
+
#### Token 影响
|
|
196
|
+
|
|
197
|
+
只有失败的调用会增加这些保留 token。
|
|
198
|
+
|
|
199
|
+
#### KV Cache 影响
|
|
200
|
+
|
|
201
|
+
仅追加;新可见内容跟在可复用请求前缀之后,不会使既有 KV Cache 条目失效。
|
|
202
|
+
|
|
203
|
+
## 已知限制与延期工作
|
|
204
|
+
|
|
205
|
+
<a id="known-limitations-and-deferred-work"></a>
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
这些限制说明搜索工具何时不合适,或何时需要特别的运维注意。它们是当前包约束,不是通用搜索对比或任务积压。
|
|
209
|
+
|
|
210
|
+
- **搜索与文件访问没有共享工作区证明**——只有当工作目录与文件系统根目录指向同一工作区时,返回路径才可继续读取;本包不执行运行时跨服务校验。
|
|
211
|
+
- **打包二进制固定在依赖版本上**——Node 部署使用 `@vscode/ripgrep` 选择的版本;Python 单文件运行时将对应目标的原生版本复制为必需的 `-rg` 伴随文件。不支持的平台或损坏的安装会以 `SEARCH_FAILED` 使调用失败,Python 运行时包则会在启动前拒绝缺少伴随文件的安装。远程或虚拟文件系统需要共置的工作区或另一个搜索消费方。
|
|
212
|
+
- **schema 只暴露一个有界页面**——偏移分页、大小写开关、替代输出模式与提供方支撑的发现仍不在本包范围内;达到上限的完整输出需要 spill 后端。
|
|
213
|
+
- **启用采样时仅按搜索根正下方的第一段路径分组**——超过上限的 `glob` 页面在这些顶层条目之间平衡,因此集中在更深处的结果在该层级之下仍会呈现不均;递归平衡被延期。
|
|
214
|
+
|
|
215
|
+
<a id="dev-note"></a>
|
|
216
|
+
### 开发备注
|
|
217
|
+
|
|
218
|
+
<details>
|
|
219
|
+
<summary>维护者的工作上下文——点击展开</summary>
|
|
220
|
+
|
|
221
|
+
无。
|
|
222
|
+
|
|
223
|
+
</details>
|