dsh-hashline-edit 0.5.1 → 0.5.4

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.md CHANGED
@@ -16,6 +16,7 @@ The semantic core is the [pi-better-edit](https://github.com/Rianico/pi-better-e
16
16
  | DeepSeek Harness | plugin-capable build; developed and tested against **DSH 0.2.2-rc.3**; host packages are declared as peer dependencies with range `>=0.2.2-rc.1 <0.2.3-0` |
17
17
  | codegraph CLI | ≥ 1.6.4 — optional; needed only for the eight `codegraph_*` graph tools ([Codegraph tools](#codegraph-tools)) |
18
18
  | Rust / TypeScript toolchain | optional; needed only for the `diagnostics` tool — `cargo` on `PATH`, and TypeScript from the project's `node_modules/typescript` or a `tsc` on `PATH` |
19
+ | ripgrep (`rg`) | optional; needed only for the `rg` tool — the first `rg` on `PATH`, or pin one with `rgPath` ([rg](#rg)); without it the call returns install guidance instead of searching |
19
20
 
20
21
  ### Anchor width (3 or 4)
21
22
 
@@ -91,7 +92,7 @@ Served anchors are leased per session and per file. A stale, unknown, retired or
91
92
 
92
93
  ### Live switches and profiles
93
94
 
94
- `read`, `applyPatch`, `edit`, `codegraph` and `diagnostics` are five live per-agent switches. The host reloads the bundle row and remounts every live agent, so flipping one takes effect without a rebuild. `read` shadows the built-in read and enables the shell/grep views; `applyPatch` registers the `apply_patch` tool; `edit` registers the anchored range `edit` tool; `codegraph` registers the optional codegraph graph tools ([Codegraph tools](#codegraph-tools)); `diagnostics` registers the anchored `diagnostics` tool ([diagnostics](#diagnostics)).
95
+ `read`, `applyPatch`, `edit`, `rg`, `codegraph`, `diagnostics` and `writeAutoRead` are seven live per-agent switches. The host reloads the bundle row and remounts every live agent, so flipping one takes effect without a rebuild. `read` shadows the built-in read and enables the shell/grep views; `applyPatch` registers the `apply_patch` tool; `edit` registers the anchored range `edit` tool; `rg` registers an `rg` tool that runs the system `rg` and hides the host's built-in `grep` (and its brief) ([rg](#rg)); `codegraph` registers the optional codegraph graph tools ([Codegraph tools](#codegraph-tools)); `diagnostics` registers the anchored `diagnostics` tool ([diagnostics](#diagnostics)); `writeAutoRead` appends the written file's anchored page to the built-in `write` result so the next `edit` needs no `read` — off by default, so a write returns the native one-line success.
95
96
 
96
97
  | Switch | Default | Effect |
97
98
  | --- | --- | --- |
@@ -100,6 +101,8 @@ Served anchors are leased per session and per file. A stale, unknown, retired or
100
101
  | `edit` | `false` | Register the anchored range `edit` tool. |
101
102
  | `codegraph` | `false` (`cordis.patch.yml` ships `true`) | Register the eight `codegraph_*` graph tools and the `tool:codegraph` prompt section. |
102
103
  | `diagnostics` | `false` (`cordis.patch.yml` ships `true`) | Register the `diagnostics` tool and the `tool:diagnostics` prompt section. |
104
+ | `rg` | `true` | Register the `rg` tool over the system `rg` and hide the host's built-in `grep` tool and its brief; the read switch's grep view serves its matches through the tool's own value — each match gains its `hash` anchor and the rendered page is `HASH│content`, on a direct call and inside `run_code` alike. |
105
+ | `writeAutoRead` | `false` | Append the written file's anchored page to the built-in `write` result. Off: the write returns the native one-line success and injects nothing. The served hash-echo refusal guard runs either way. |
103
106
 
104
107
  The two mutation switches form three supported profiles. With both mutation switches off, neither write tool is registered and the native-hide layer is not installed; the native editors and the host's built-in `write` stay visible. Each snippet below is the `config` block of the `dsh-hashline-edit` row:
105
108
 
@@ -114,11 +117,12 @@ config: { read: true, applyPatch: true, edit: true }
114
117
  config: { read: true, applyPatch: false, edit: true }
115
118
  ```
116
119
 
117
- `codegraph` and `diagnostics` are the two optional surfaces: neither changes which write tools register, both default to `false` in the schema while `cordis.patch.yml` ships them `true`, and both need something outside the package — an index for `codegraph` ([Codegraph tools](#codegraph-tools)), a project toolchain for `diagnostics` ([diagnostics](#diagnostics)). `codegraphPath` is a config key, not a switch: `""` (the default) uses the first runnable `codegraph` on `PATH`, and any other value pins an executable outside `PATH`.
120
+ `codegraph` and `diagnostics` are the two optional surfaces: neither changes which write tools register, both default to `false` in the schema while `cordis.patch.yml` ships them `true`, and both need something outside the package — an index for `codegraph` ([Codegraph tools](#codegraph-tools)), a project toolchain for `diagnostics` ([diagnostics](#diagnostics)). `rg` needs only ripgrep on the machine and defaults to `true`; `codegraphPath` and `rgPath` are config keys, not switches: `""` (the default) uses the first runnable executable on `PATH`, and any other value pins one outside `PATH`.
118
121
 
119
122
  | Config key | Default | Effect |
120
123
  | --- | --- | --- |
121
124
  | `codegraphPath` | `""` | Config key (not a switch): pin an executable outside `PATH`; empty uses the first runnable `codegraph` on `PATH`. |
125
+ | `rgPath` | `""` | Config key (not a switch): pin an `rg` outside `PATH`; empty uses the first runnable `rg` on `PATH`. |
122
126
 
123
127
  ### `read`
124
128
 
@@ -203,6 +207,29 @@ Each item names one inclusive bare anchor, `anchor_from`, and exactly one payloa
203
207
  - **`indent: "auto"`** (default `as-is`) re-bases the payload's indentation: the common leading-whitespace prefix of `text` is stripped and the leading whitespace of the `anchor_from` line is applied instead, with blank lines untouched. It is refused together with `text_ref` or a deletion (`text: ""`), and the applied change is reported in the call's notes channel ([ADR-0030](docs/adr/0030-edit-auto-indent.md)).
204
208
  - **`expand: "item"`** replaces the whole innermost enclosing syntax item — leading doc comment and attributes through the matching closing brace — instead of only the named rows. It names only `anchor_from` (an `anchor_to` is refused) and must be the only item in the call; an unsupported file or grammar refuses with `[E_EXPAND_UNAVAILABLE]` and writes nothing. Normal undo, diff and served rows still apply ([ADR-0031](docs/adr/0031-edit-expand-to-item.md)).
205
209
 
210
+ ### `rg`
211
+
212
+ File-content search executed by the system `rg`, replacing the host's built-in `grep` (which spawns the ripgrep binary vendored in `@vscode/ripgrep` with one fixed argv). It is registered as `rg` — not `grep` — so no call can be confused with the built-in tool or with a shell command of the same name; while the switch is on, the native `grep` and its `tool:grep` brief are hidden through the native-hide lane, and this tool ships its own brief, `prompts/rg-guidelines.md`, in the native `TOOL_GREP` prompt slot ([ADR-0033](docs/adr/0033-system-rg-grep-tool.md)).
213
+
214
+ | Parameter | Type | Effect |
215
+ | --- | --- | --- |
216
+ | `pattern` | required `string` | ripgrep regular expression, or literal text with `fixedStrings`. |
217
+ | `path` | `string` | File or directory to search; defaults to the session working directory. |
218
+ | `include` | `string` | One positive glob filter (e.g. `*.ts`, `*.{js,jsx}`); no lists, no negation. |
219
+ | `ignoreCase` | `boolean` | `-i`; absent keeps ripgrep's smart case. |
220
+ | `fixedStrings` | `boolean` | `-F`: literal text, not a regex. |
221
+ | `wordMatch` | `boolean` | `-w`: whole words only. |
222
+ | `hidden` | `boolean` | `--hidden`: also search hidden files and directories. |
223
+ | `noIgnore` | `boolean` | `--no-ignore`: ignore `.gitignore`/`.ignore` rules. |
224
+
225
+ ```text
226
+ rg({ pattern: "run_code", include: "*.ts", ignoreCase: true })
227
+ ```
228
+
229
+ - **System `rg`, no shell.** One process, a plain argv vector (`rg --json --regexp=… --glob=… -- <path>`), both streams captured, a 30 s budget and an 8 MB capture ceiling. The user's own ripgrep runs, so `RIPGREP_CONFIG_PATH`, the installed version and the ignore rules are the ones they configured; `rgPath` pins an executable outside `PATH`.
230
+ - **Anchored rows through the read switch.** The canonical value keeps the native grep's `{ matches: [{ path, lineNumber, line }] }` shape, so the unchanged grep view re-reads every matched line from disk, serves it as `HASH│content` and leases it; the served anchors are then written onto that value — each match gains its `hash` — and the tool's renderer turns them into the shared search page. That value channel is also the only one a nested `run_code` caller receives, so the anchors work there too. Over 250 matches or over the inline token budget the view passes the result through and the rendered text reports `Found N of M matches` instead.
231
+ - **Expected failures are text results, not tool errors.** No `rg` on `PATH`, a pattern ripgrep rejects, an unreadable target, the deadline and a capture overflow all return a normal successful result carrying guidance; only an empty `pattern` or a malformed `include` is a hard argument error.
232
+
206
233
  ### codegraph tools
207
234
 
208
235
  Eight read-only tools over a repository indexed by the external `codegraph` CLI, one process per call. Three return source, five return locations only:
@@ -240,9 +267,7 @@ Runs the project's own toolchain and serves what it reports as anchors — one c
240
267
  - **Expected failures are text results, not tool errors.** A missing toolchain, a missing `tsconfig.json`/`jsconfig.json` for `tsc`, the 120 s budget, a non-zero exit and output that does not parse (the raw tail is shown) all return a normal successful result carrying that guidance. Only a `tool` outside the enum is a hard argument error.
241
268
  - **No shell.** `cargo` comes from `PATH`; `tsc` prefers `node_modules/typescript/bin/tsc`, walking up from `cwd`, then a `tsc` on `PATH`. The tool is registered only while `diagnostics: true`, and its brief is `prompts/diagnostics-guidelines.md`.
242
269
 
243
- ## Shell view
244
-
245
- The plugin installs a `tools/post-execute` listener for the host's `pwsh`, `bash` and built-in `grep` tools. When the command is a whitelisted read-only file view, the captured stdout is replaced with the aligned file's `HASH│content` rows, and those rows are served (leased) exactly like a read — a following `apply_patch` or `edit` can use them with no re-read. A built-in grep result whose matches are proven against disk is served the same way (see the table below).
270
+ The plugin installs a `tools/post-execute` listener for the host's `pwsh`, `bash` and `grep` tools. When the command is a whitelisted read-only file view, the captured stdout is replaced with the aligned file's `HASH│content` rows, and those rows are served (leased) exactly like a read — a following `apply_patch` or `edit` can use them with no re-read. A `grep`-shaped result whose matches are proven against disk is served the same way (see the table below). The `rg` tool is the `grep`-shaped result that reaches this listener unless the `grep` switch is off: its value declares the anchor on every match, so the served anchors are projected there rather than onto its content, which is what makes a nested `run_code` call served as well.
246
271
 
247
272
  | Command shape | Served as |
248
273
  | --- | --- |
@@ -250,11 +275,16 @@ The plugin installs a `tools/post-execute` listener for the host's `pwsh`, `bash
250
275
  | `Get-Content <file> \| Select-Object -First\|-Last\|-Skip <N>` | the bounded slice |
251
276
  | `Get-Content <file> \| Select-Object -Skip N -First M` (either order) | disk lines N+1 through N+M |
252
277
  | `Select-String <pattern> <file>` | the matched lines, with their line numbers |
253
- | `rg <pattern> <file>` (explicit single file, no switches) | the matched lines, with their line numbers |
254
- | built-in `grep` (`@deepseek-ai/dsh-tool-fs-search`) | the matched lines grouped per file, each row `HASH│content` |
278
+ | `rg <pattern> <file>` (explicit single file; matching-only switches such as `-i`, `-F`, `-w`, `-S`, `-n`) | the matched lines, with their line numbers |
279
+ | `grep -n <pattern> <file>` | the matched lines, with their line numbers |
280
+ | `grep <pattern> <file>` | the matched lines, aligned by content (refused when a duplicate makes the position ambiguous) |
281
+ | `head [-n N|-N] <file>`, `tail [-n N|-N] <file>` | the bounded head or tail slice |
282
+ | `rg` (this plugin's system-`rg` tool) | each match's anchor on the canonical value, rendered as the grouped `HASH│content` page |
255
283
 
256
284
  The grep view applies the host's spill policy: at most 250 matches and at most 12,500 inline tokens (the host estimate `ceil(chars / 4) + 4`). A result over either cap, a failed call, a forged or stale match line, or non-ascending coordinates passes through byte-for-byte with no lease.
257
285
 
286
+ A nested (`run_code`) dispatch never receives model-facing content, so it is served only through the value — this plugin's `rg`, whose matches carry `hash`. Two host-owned values cannot gain an anchor field (`additionalProperties: false`): the native `grep` tool's matches and the built-in `write` tool's auto-read reach a nested caller unanchored, while both stay anchored on their model-facing result. Inside `run_code`, use `rg` (the default replacement) when anchors are needed, and `read` after a built-in `write`.
287
+
258
288
  Alignment is strict: stdout lines are mapped to 1-based disk line numbers with a monotonic, unique match (search output's own line numbers are used as hints). Every served view is prefixed with the shared `[Bash view: <file> (lines a-b of N total)]` page header, so the positions the raw output used to name are not lost. Anything the view cannot prove — an unknown pipeline, a statement separator (`;`), a variable path (`$f`), a wildcard, formatted output, a truncated capture, a failed command — passes through byte-for-byte. The hook never guesses and never serves the wrong occurrence of a duplicated line.
259
289
  ## Encoding: UTF-8 only
260
290
 
@@ -355,4 +385,4 @@ The hashline engine is [**pi-better-edit**](https://github.com/Rianico/pi-better
355
385
 
356
386
  ## License
357
387
 
358
- [MIT](LICENSE)
388
+ [MIT](LICENSE)
package/cordis.patch.yml CHANGED
@@ -7,7 +7,11 @@
7
7
  # `apply_patch`); `apply_patch` hides only the native `apply_patch`; the built-in
8
8
  # `write` stays visible;
9
9
  # both may be on at once. Each toggles live: the host reloads this row and the
10
- # plugin re-mounts every live agent. Defaults: read on, apply_patch on, edit off.
10
+ # plugin re-mounts every live agent. Defaults: read on, apply_patch on, edit off, rg on.
11
+ # `rg` registers an `rg` tool over the system `rg` and disables the built-in `grep` (and its
12
+ # brief); the tool's matches keep the built-in value shape, so the read switch's grep view still
13
+ # serves them as `HASH│content` rows — written onto each match's `hash`, so a nested `run_code` call is
14
+ # served too. `rgPath` pins an `rg` executable outside PATH.
11
15
  - insert:
12
16
  # `codegraph` adds the eight graph tools (explore/node/context/search/callers/callees/
13
17
  # impact/implementations); the three source tools serve `HASH│content` rows. It needs the
@@ -25,3 +29,12 @@
25
29
  # as `HASH│content` rows. It needs that toolchain on the machine, and reports a
26
30
  # missing one (or a missing tsconfig) as call text.
27
31
  diagnostics: true
32
+ # `rg` replaces the built-in grep with a tool over the system `rg`, exposing ripgrep's
33
+ # matching switches and hiding the built-in grep and its brief; the read switch's grep
34
+ # view serves its matches as anchors, on each match's `hash` for a nested `run_code` call too.
35
+ rg: true
36
+ rgPath: ""
37
+ # `writeAutoRead` appends the written file's anchored page to the built-in `write` result
38
+ # so the next `edit` needs no `read`; off by default (the write returns the native one-line
39
+ # success) because the whole-file page is context the call did not ask for.
40
+ writeAutoRead: false