@d0nj/dsh-native-tools 0.0.0-stage → 1.0.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/README.md CHANGED
@@ -1,3 +1,110 @@
1
- # Temporary Holding Version
1
+ # @d0nj/dsh-native-tools
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Rust replacements for the DeepSeek Harness `grep`, `glob`, `read` and `edit` tools. The search, line-windowing and literal-replacement engines are a N-API addon linked into the Host process; the model-facing contract, result envelopes, presentation cards and filesystem intents stay exactly as the shipped tools define them.
4
+
5
+ ## Why
6
+
7
+ The shipped `grep` and `glob` spawn a packaged ripgrep for every call and parse its `--json` stream back in JavaScript. `read` re-slices multi-megabyte strings on the JS thread and `edit` re-implements literal matching per provider. This bundle moves those bodies into Rust, in-process, on the libuv thread pool:
8
+
9
+ | Call | Shipped | This bundle |
10
+ |---|---|---|
11
+ | `grep` (this repo, warm, 222 matches) | 43.8 ms spawn + NDJSON parse | 33.3 ms, no process |
12
+ | `glob` (this repo, warm, 203 paths) | 43.2 ms spawn + sort | 16.8 ms, no process |
13
+ | `read` (2000 lines) | JS scan | Rust scan, same envelope |
14
+ | `edit` | provider-side `indexOf` | Rust match/count/CRLF, provider-side CAS write |
15
+
16
+ The win is the removed fork/exec and the removed JSON round trip, not a faster regex engine: both run the same `grep-searcher`.
17
+
18
+ ## How it mounts
19
+
20
+ The shipped `tool-fs` and `tool-fs-search` rows live inside every agent preset, and a patch cannot reach a preset's inner rows by id. So this row registers **nothing** on its own scope. It listens for `agent/created` and registers each definition into that agent's own scope, where a nearer definition shadows the preset's by name — the same mechanism `@d0nj/dsh-agent-rules` uses for its system-prompt section. A profile-level or preset-level duplicate would instead throw `tool "grep" is already registered`.
21
+
22
+ Consequences worth knowing:
23
+
24
+ - `write`, `apply_patch` and `read_image` keep the shipped implementation. `write` therefore still runs the observation and `fs/write-intent` policy that pairs with the `read` observations this bundle emits.
25
+ - On the Desktop build this profile change was picked up by the running Host without a restart; if a build does not, restart the app — the Host composes the profile at boot.
26
+
27
+ ## AST tools
28
+
29
+ Two deferred tools ride the same addon (`deferLoading`, so they cost no prompt space until called):
30
+
31
+ | Tool | What it does |
32
+ |---|---|
33
+ | `ast_grep` | Structural search with ast-grep pattern syntax (`$A` one node, `$$$ARGS` many, `$_` anonymous), language inferred from extension or set with `lang`, capped at 50 matches, captures reported as `A=alpha` |
34
+ | `ast_edit` | Structural rewrite: `pat` + `out`, defaults to a dry run that writes nothing and returns a preview token; `dry_run: false` with that token re-derives the tree and refuses if anything changed, then writes through `ctx.fs.writeText` with the `fs/edit-intent` |
35
+
36
+ Compiled-in grammars: TypeScript, TSX, JavaScript, JSON, Rust, Python, Bash, Markdown, YAML, Go — 6.85 MB of the addon, which is why the language set is a deliberate list rather than "all of tree-sitter".
37
+
38
+ Three grammar facts baked into the crate, all measured rather than assumed: Python, Rust and Go need `µ` as the pattern expando because `$` is not an identifier character there; Markdown parses only through its block grammar and only with a trailing newline, so the addon pads and strips it; a JSON member pattern (`"$K": $V`) parses as multiple roots unless it is wrapped in a whole document.
39
+
40
+ ## Summaries and WebAssembly grammars
41
+
42
+ `read` takes `summarize: true`: files at or above `readSummaryMinLines` have each long function body replaced by a `… +N lines (kind)` marker, so the signature and the last line of the body survive while the middle — which is what usually fits in a read anyway — stops costing tokens. The parse happens in Rust (`summarize_code`), 20 ms for a normal file.
43
+
44
+ Languages outside the ten linked grammars are parsed through **WebAssembly grammars**: the addon compiles with `wasm-grammars` (turning on `tree-sitter`'s wasm feature and wasmtime), and loads a `<id>.wasm` module from the grammar directory through a `WasmStore`. `@d0nj/dsh-native-tools` ships `grammars.json`, a hash-pinned manifest; on the first read of a `.lua`, `.rb`, `.sql` or similar file it downloads `<name>.wasm.zst` from the configured base URL, decompresses it in the addon, checks the SHA-256 and the byte size against the pin, and only then writes it. A mismatch is refused, never installed.
45
+
46
+ Two honest limits:
47
+
48
+ - `ast_grep` and `ast_edit` cover the **linked** grammars only. `ast-grep-core` builds its own parser inside `StrDoc`, so it cannot reach a wasm language; supporting them would mean vendoring that crate, which is what oh-my-pi does.
49
+ - The wasm-enabled addon is 19.7 MB against 9.6 MB without it. `DSH_NATIVE_WASM=1` turns the feature on at build time and CI sets it; a local build without the variable stays small and simply reports wasm translations as unavailable.
50
+
51
+ ## Diff engine
52
+
53
+ Every applied change is diffed in Rust (`similar`, three-line context, one hunk per separated edit) and handed to the presentation card as `{path, oldText, newText}`. That replaced a hand-rolled prefix/suffix scan in this package that collapsed scattered edits into one wide block, so `edit` now reports each hunk the way the shipped tool does.
54
+
55
+ `write` is built on the same engine and is **opt-in** (`write: false`). It mirrors the shipped contract — `{path, operation, before, after}`, a `Created file`/`Updated file` envelope, and a diff card from the same hunks — and writes through `ctx.fs.writeText` with the `fs/write-intent` waterfall. One gap keeps it off by default: the shipped tool also forwards a sandbox execution policy as a fifth argument and advertises `sandbox_permissions`/`justification` parameters; this one does neither, so a profile that relies on `ctx.fs` sandbox enforcement should leave it disabled.
56
+
57
+ ## Config
58
+
59
+ | Key | Default | Meaning |
60
+ |---|---|---|
61
+ | `grep` / `glob` / `read` / `edit` | `true` | Register that tool at all |
62
+ | `write` | `false` | Register the Rust-backed write tool |
63
+ | `astGrep` / `astEdit` | `true` | Register the deferred AST tools |
64
+ | `grepMaxMatches` | `250` | Matches kept in the model-visible result |
65
+ | `grepMaxLineBytes` | `2000` | Per-line preview cap, UTF-8 bytes |
66
+ | `globMaxResults` | `100` | Paths kept in the model-visible result |
67
+ | `readLimit` | `2000` | Maximum lines one `read` may request |
68
+ | `readMaxLineLength` | `2000` | Per-line character cap |
69
+ | `readMaxBytes` | `51200` | Byte budget for returned lines |
70
+ | `readSummaryMinLines` | `200` | Shortest file `summarize: true` will parse; `0` disables it |
71
+ | `readSummaryMinBodyLines` | `6` | Shortest function body a summary elides |
72
+ | `grammarDir` | `~/.dsh/grammars` | Where wasm grammars are cached |
73
+ | `grammarBaseUrl` | stencil-hq `v1` release | Where pinned grammar assets come from |
74
+ | `grammarAutoDownload` | `true` | Fetch a pinned grammar on first need |
75
+ | `timeoutMs` | `30000` | Cooperative budget, enforced through the abort signal |
76
+
77
+ ## Behaviour parity
78
+
79
+ Reproduced: grep's `include` whitelist and its three rejection messages, gitignore/hidden rules (ripgrep's own, including the "`.gitignore` only inside a repository" rule), VCS directory exclusions in `glob`, mtime ordering, `No matches found` / `No files found`, the `Found {kept} of {seen} matches` header, `Line {n}: {text}` grouping, `(Showing {a} of {b} paths. …)`, ` (line truncated)` and `(line is not valid UTF-8)`, read's `<path>/<type>/<content>` envelope and all three footers, edit's strictly literal matching with `FS_EDIT_NOT_FOUND` / `FS_AMBIGUOUS_EDIT`, CRLF preservation, and each tool's call/result card.
80
+
81
+ Deliberately not reproduced, in order of consequence:
82
+
83
+ - **Spill store.** Shipped saves an over-cap result to `ctx.spillStore` and prints a locator. Over-cap results here print the "could not be saved" recovery line instead, because the addon only carries the retained slice across the boundary.
84
+ - **Sandbox escalation fields.** No `sandbox_permissions` / `justification` parameters and no `[sandbox: …]` denial marker; provider errors surface with their own message and code.
85
+ - **Streaming reads.** Files are always read whole through `ctx.fs.readText`; the shipped 10 MiB `streamText` route is absent.
86
+ - **Read `lang` hint** and the multi-hunk diff metadata (`diff` is not a runtime dependency here, so one hunk is produced per edit).
87
+
88
+ Read-only tools bypass nothing: `read` still resolves through `ctx.fs`, and `grep`/`glob` were already unconfined (they spawn ripgrep directly). `edit` still writes through `ctx.fs.writeText` with the intent from `fs/edit-intent`, so the session's mode, CAS version guard and observation watermark all stay in force.
89
+
90
+ ## Build
91
+
92
+ ```bash
93
+ pnpm --filter @d0nj/dsh-native-tools build:native # cargo → native/<platform>-<arch>.<hash>.node
94
+ pnpm --filter @d0nj/dsh-native-tools build # tsc → dist/
95
+ pnpm --filter @d0nj/dsh-native-tools test # cargo + node --test over the real addon
96
+ ```
97
+
98
+ The crate lives at `crates/dsh-natives` and is built for N-API v9 (Host runs Electron 44 / Node 24 / napi 10). Only the host platform is built, so a publish needs one prebuild per target (`win32-x64`, `darwin-x64`, `darwin-arm64`, `linux-x64`, `linux-arm64`) plus a Rust toolchain in CI.
99
+
100
+ Addon files carry a content hash in their name because Windows keeps a loaded `.node` mapped and refuses an overwrite: a rebuild while the Harness is running writes a new file, and the loader picks the newest match by mtime. Old files are pruned on the next build once they are unlocked. A missing addon is not fatal: the row logs one error and registers nothing, leaving the shipped tools in place.
101
+
102
+ ## CI
103
+
104
+ `.github/workflows/ci.yml` installs a Rust toolchain when the runner has none, caches `~/.cargo` with `target`, runs `turbo run build:native build typecheck test check`, and then packs this package and fails if the tarball has no hashed `.node` — the loader falls back silently, so that check is what keeps a broken artifact from shipping.
105
+
106
+ `.github/workflows/publish.yml` builds the addon on `ubuntu-latest`, `macos-latest` and `windows-latest`, uploads the three artifacts, and the release job downloads them into `native/` before packing, so one tarball carries every prebuilt platform and the loader picks the match at install time. `darwin-x64` and `linux-arm64` are not in that matrix yet.
107
+
108
+ ## Deps
109
+
110
+ Peers (mirrored in `devDependencies`): `@deepseek-ai/cordis ~4.1.0`, `dsh-agent` / `dsh-fs` / `dsh-tools` / `dsh-working-directory` `^0.2.2-rc.5`, `@deepseek-ai/schemastery ~3.19.0`. The TypeScript half has no runtime dependency of its own; the addon is the only binary artifact.
@@ -0,0 +1,33 @@
1
+ # Registers Rust-backed replacements for the shipped file and search tools.
2
+ #
3
+ # The row is inserted, never overridden. It registers nothing on its own scope:
4
+ # the shipped tool rows are mounted *inside* every agent preset, so a
5
+ # registration at profile scope would collide, and a patch cannot reach a
6
+ # preset's inner rows by id. Each tool is instead registered through
7
+ # `agent/created` into that agent's own scope, which shadows the preset
8
+ # definition by name — the same mechanism `@d0nj/dsh-agent-rules` uses for its
9
+ # system-prompt section.
10
+ #
11
+ # `write`, `apply_patch` and `read_image` keep the shipped implementation, so
12
+ # this row lists only the four tools it owns.
13
+ - insert:
14
+ - id: native-tools
15
+ name: '@d0nj/dsh-native-tools'
16
+ config:
17
+ grep: true
18
+ glob: true
19
+ read: true
20
+ edit: true
21
+ write: false
22
+ astGrep: true
23
+ astEdit: true
24
+ grepMaxMatches: 250
25
+ grepMaxLineBytes: 2000
26
+ globMaxResults: 100
27
+ readLimit: 2000
28
+ readMaxLineLength: 2000
29
+ readMaxBytes: 51200
30
+ readSummaryMinLines: 200
31
+ readSummaryMinBodyLines: 6
32
+ grammarAutoDownload: true
33
+ timeoutMs: 30000
@@ -0,0 +1,36 @@
1
+ export interface GrepMatch {
2
+ path: string;
3
+ lineNumber: number;
4
+ line: string;
5
+ }
6
+ export type MatchFile = {
7
+ path: string;
8
+ matches: Array<{
9
+ lineNumber: number;
10
+ line: string;
11
+ }>;
12
+ };
13
+ export declare const SPILL_FALLBACK = "The complete result could not be saved; narrow pattern, path, or include to see more.";
14
+ export declare const GLOB_SPILL_FALLBACK = "The complete result could not be saved; narrow pattern or path to see more.";
15
+ export declare function groupMatches(matches: readonly GrepMatch[]): MatchFile[];
16
+ export declare function grepHeader(kept: number, seen: number): string;
17
+ export declare function grepBody(files: readonly MatchFile[]): string;
18
+ export declare function formatGrep(matches: readonly GrepMatch[], seen: number, recovery: string): string;
19
+ export declare function formatGlob(paths: readonly string[], total: number, recovery: string): string;
20
+ export declare function capMeta<T extends JsonMeta>(meta: T, maxBytes: number): T;
21
+ export type PathsMeta = {
22
+ shape: 'paths';
23
+ paths: string[];
24
+ truncated: boolean;
25
+ total: number;
26
+ };
27
+ export type MatchesMeta = {
28
+ shape: 'matches';
29
+ files: MatchFile[];
30
+ truncated: boolean;
31
+ total: number;
32
+ };
33
+ export type JsonMeta = PathsMeta | MatchesMeta;
34
+ export declare function pathsMeta(paths: readonly string[], total: number): PathsMeta;
35
+ export declare function matchesMeta(matches: readonly GrepMatch[], seen: number): MatchesMeta;
36
+ //# sourceMappingURL=format.d.ts.map
package/dist/format.js ADDED
@@ -0,0 +1,66 @@
1
+ export const SPILL_FALLBACK = 'The complete result could not be saved; narrow pattern, path, or include to see more.';
2
+ export const GLOB_SPILL_FALLBACK = 'The complete result could not be saved; narrow pattern or path to see more.';
3
+ export function groupMatches(matches) {
4
+ const files = new Map();
5
+ for (const match of matches) {
6
+ const existing = files.get(match.path);
7
+ if (existing === undefined) {
8
+ files.set(match.path, { path: match.path, matches: [{ lineNumber: match.lineNumber, line: match.line }] });
9
+ continue;
10
+ }
11
+ existing.matches.push({ lineNumber: match.lineNumber, line: match.line });
12
+ }
13
+ return [...files.values()];
14
+ }
15
+ export function grepHeader(kept, seen) {
16
+ if (kept < seen)
17
+ return `Found ${kept} of ${seen} matches`;
18
+ return `Found ${seen} ${seen === 1 ? 'match' : 'matches'}`;
19
+ }
20
+ export function grepBody(files) {
21
+ return files
22
+ .map((file) => `${file.path}\n${file.matches.map((match) => `Line ${match.lineNumber}: ${match.line}`).join('\n')}`)
23
+ .join('\n\n');
24
+ }
25
+ export function formatGrep(matches, seen, recovery) {
26
+ if (seen === 0)
27
+ return 'No matches found';
28
+ const files = groupMatches(matches);
29
+ const header = grepHeader(matches.length, seen);
30
+ const body = grepBody(files);
31
+ if (matches.length < seen)
32
+ return `${header}\n\n${body}\n\n(${recovery})`;
33
+ return `${header}\n\n${body}`;
34
+ }
35
+ export function formatGlob(paths, total, recovery) {
36
+ if (total === 0)
37
+ return 'No files found';
38
+ if (paths.length >= total)
39
+ return paths.join('\n');
40
+ return `${paths.join('\n')}\n\n(Showing ${paths.length} of ${total} paths. ${recovery})`;
41
+ }
42
+ export function capMeta(meta, maxBytes) {
43
+ if (JSON.stringify(meta).length <= maxBytes)
44
+ return meta;
45
+ if (meta.shape === 'paths') {
46
+ const paths = meta.paths;
47
+ let kept = paths.length;
48
+ while (kept > 1 && Buffer.byteLength(JSON.stringify({ ...meta, paths: paths.slice(0, kept), truncated: true })) > maxBytes) {
49
+ kept -= 1;
50
+ }
51
+ return { ...meta, paths: paths.slice(0, kept), truncated: true };
52
+ }
53
+ const files = meta.files;
54
+ let kept = files.length;
55
+ while (kept > 1 && Buffer.byteLength(JSON.stringify({ ...meta, files: files.slice(0, kept), truncated: true })) > maxBytes) {
56
+ kept -= 1;
57
+ }
58
+ return { ...meta, files: files.slice(0, kept), truncated: true };
59
+ }
60
+ export function pathsMeta(paths, total) {
61
+ return { shape: 'paths', paths: [...paths], truncated: paths.length < total, total };
62
+ }
63
+ export function matchesMeta(matches, seen) {
64
+ return { shape: 'matches', files: groupMatches(matches), truncated: matches.length < seen, total: seen };
65
+ }
66
+ //# sourceMappingURL=format.js.map
@@ -0,0 +1,33 @@
1
+ export declare const GRAMMAR_RELEASE = "v1";
2
+ export declare const GRAMMAR_BASE_URL = "https://github.com/stencil-hq/wasm-grammars/releases/download/v1";
3
+ export declare const WASM_EXTENSIONS: Record<string, string>;
4
+ export interface GrammarEntry {
5
+ language: string;
6
+ crate: string;
7
+ version: string;
8
+ symbol: string;
9
+ file: string;
10
+ sha256: string;
11
+ size: number;
12
+ }
13
+ interface GrammarManifest {
14
+ release: string;
15
+ tree_sitter: string;
16
+ grammars: GrammarEntry[];
17
+ }
18
+ export declare function loadManifest(): GrammarManifest;
19
+ export declare function grammarEntry(id: string): GrammarEntry | undefined;
20
+ export declare function grammarIdForPath(path: string): string | undefined;
21
+ export declare function defaultGrammarDir(): string;
22
+ export declare function isInstalled(id: string): boolean;
23
+ export interface EnsureGrammarResult {
24
+ installed: boolean;
25
+ reason?: string;
26
+ }
27
+ export declare function ensureGrammar(id: string, options: {
28
+ readonly baseUrl?: string | undefined;
29
+ readonly signal?: AbortSignal | undefined;
30
+ readonly fetchImpl?: typeof fetch | undefined;
31
+ }): Promise<EnsureGrammarResult>;
32
+ export {};
33
+ //# sourceMappingURL=grammars.d.ts.map
@@ -0,0 +1,124 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
3
+ import { homedir } from 'node:os';
4
+ import { basename, extname, join } from 'node:path';
5
+ import { fileURLToPath } from 'node:url';
6
+ import { loadNative } from './native.js';
7
+ export const GRAMMAR_RELEASE = 'v1';
8
+ export const GRAMMAR_BASE_URL = `https://github.com/stencil-hq/wasm-grammars/releases/download/${GRAMMAR_RELEASE}`;
9
+ export const WASM_EXTENSIONS = {
10
+ astro: 'astro',
11
+ rb: 'ruby',
12
+ erb: 'ruby',
13
+ lua: 'lua',
14
+ php: 'php',
15
+ swift: 'swift',
16
+ kt: 'kotlin',
17
+ kts: 'kotlin',
18
+ scala: 'scala',
19
+ sc: 'scala',
20
+ hs: 'haskell',
21
+ ex: 'elixir',
22
+ exs: 'elixir',
23
+ erl: 'erlang',
24
+ hrl: 'erlang',
25
+ clj: 'clojure',
26
+ cljs: 'clojure',
27
+ sql: 'sql',
28
+ r: 'r',
29
+ jl: 'julia',
30
+ nix: 'nix',
31
+ zig: 'zig',
32
+ vue: 'vue',
33
+ svelte: 'svelte',
34
+ xml: 'xml',
35
+ svg: 'xml',
36
+ proto: 'protobuf',
37
+ tf: 'hcl',
38
+ hcl: 'hcl',
39
+ ini: 'ini',
40
+ mk: 'make',
41
+ cmake: 'cmake',
42
+ tla: 'tlaplus',
43
+ v: 'verilog',
44
+ sv: 'verilog',
45
+ svh: 'verilog',
46
+ fs: 'fortran',
47
+ f90: 'fortran',
48
+ cs: 'csharp',
49
+ dart: 'dart',
50
+ graphql: 'graphql',
51
+ gql: 'graphql',
52
+ ml: 'ocaml',
53
+ mli: 'ocaml',
54
+ odin: 'odin',
55
+ sol: 'solidity',
56
+ star: 'starlark',
57
+ bzl: 'starlark',
58
+ just: 'just',
59
+ };
60
+ let manifestCache;
61
+ export function loadManifest() {
62
+ if (manifestCache !== undefined)
63
+ return manifestCache;
64
+ const path = join(fileURLToPath(new URL('.', import.meta.url)), '..', 'grammars.json');
65
+ manifestCache = JSON.parse(readFileSync(path, 'utf8'));
66
+ return manifestCache;
67
+ }
68
+ export function grammarEntry(id) {
69
+ return loadManifest().grammars.find((entry) => entry.language === id);
70
+ }
71
+ export function grammarIdForPath(path) {
72
+ const extension = extname(path).replace('.', '').toLowerCase();
73
+ if (extension === '' || extension === basename(path))
74
+ return undefined;
75
+ return WASM_EXTENSIONS[extension];
76
+ }
77
+ export function defaultGrammarDir() {
78
+ const explicit = process.env.DSH_GRAMMAR_DIR?.trim();
79
+ return explicit !== undefined && explicit.length > 0 ? explicit : join(homedir(), '.dsh', 'grammars');
80
+ }
81
+ export function isInstalled(id) {
82
+ const [status] = loadNative().grammarStatus([id]);
83
+ return status?.installed === true;
84
+ }
85
+ export async function ensureGrammar(id, options) {
86
+ if (isInstalled(id))
87
+ return { installed: true };
88
+ const entry = grammarEntry(id);
89
+ if (entry === undefined)
90
+ return { installed: false, reason: `no WebAssembly grammar is published for "${id}"` };
91
+ const base = options.baseUrl ?? GRAMMAR_BASE_URL;
92
+ const fetchImpl = options.fetchImpl ?? fetch;
93
+ const url = `${base.replace(/\/$/, '')}/${entry.file}.zst`;
94
+ const response = await fetchImpl(url, { signal: options.signal ?? null, redirect: 'follow' });
95
+ if (!response.ok)
96
+ return { installed: false, reason: `downloading ${entry.file} returned ${response.status}` };
97
+ const compressed = new Uint8Array(await response.arrayBuffer());
98
+ const wasm = (() => {
99
+ try {
100
+ return loadNative().decompressZstd(Buffer.from(compressed));
101
+ }
102
+ catch {
103
+ return undefined;
104
+ }
105
+ })();
106
+ if (wasm === undefined) {
107
+ return { installed: false, reason: `${entry.file} is not a zstd frame this build can decode` };
108
+ }
109
+ const digest = createHash('sha256').update(wasm).digest('hex');
110
+ if (digest !== entry.sha256) {
111
+ return { installed: false, reason: `${entry.file} hashed to ${digest}, not the pinned ${entry.sha256}` };
112
+ }
113
+ if (wasm.length !== entry.size) {
114
+ return { installed: false, reason: `${entry.file} decoded to ${wasm.length} bytes, not the pinned ${entry.size}` };
115
+ }
116
+ const dir = loadNative().grammarDirPath() ?? defaultGrammarDir();
117
+ mkdirSync(dir, { recursive: true });
118
+ const target = join(dir, `${id}.wasm`);
119
+ const staging = `${target}.${process.pid}.tmp`;
120
+ writeFileSync(staging, wasm);
121
+ renameSync(staging, target);
122
+ return { installed: existsSync(target) && isInstalled(id) };
123
+ }
124
+ //# sourceMappingURL=grammars.js.map
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Rust-backed replacements for the shipped file and search tools.
3
+ *
4
+ * The tools are registered through each agent's own context, not this row's
5
+ * context: the shipped tool rows are mounted inside every preset, and a nearer
6
+ * scope shadows a definition by name. Registering at the row's own scope would
7
+ * throw `tool "grep" is already registered` instead.
8
+ *
9
+ * @module @d0nj/dsh-native-tools
10
+ */
11
+ import type { Context } from '@deepseek-ai/cordis';
12
+ import '@deepseek-ai/dsh-agent';
13
+ import '@deepseek-ai/dsh-fs';
14
+ import '@deepseek-ai/dsh-tools';
15
+ import '@deepseek-ai/dsh-working-directory';
16
+ import z from '@deepseek-ai/schemastery';
17
+ export declare const name = "native-tools";
18
+ export declare const inject: string[];
19
+ export declare const Config: z<Schemastery.ObjectS<NoInfer<{
20
+ grep: z<boolean, boolean, "defined">;
21
+ glob: z<boolean, boolean, "defined">;
22
+ read: z<boolean, boolean, "defined">;
23
+ edit: z<boolean, boolean, "defined">;
24
+ write: z<boolean, boolean, "defined">;
25
+ astGrep: z<boolean, boolean, "defined">;
26
+ astEdit: z<boolean, boolean, "defined">;
27
+ grepMaxMatches: z<number, number, "defined">;
28
+ grepMaxLineBytes: z<number, number, "defined">;
29
+ globMaxResults: z<number, number, "defined">;
30
+ readLimit: z<number, number, "defined">;
31
+ readMaxLineLength: z<number, number, "defined">;
32
+ readMaxBytes: z<number, number, "defined">;
33
+ readSummaryMinLines: z<number, number, "defined">;
34
+ readSummaryMinBodyLines: z<number, number, "defined">;
35
+ grammarDir: z<string, string, "plain">;
36
+ grammarBaseUrl: z<string, string, "plain">;
37
+ grammarAutoDownload: z<boolean, boolean, "defined">;
38
+ timeoutMs: z<number, number, "defined">;
39
+ }>>, Schemastery.ObjectT<NoInfer<{
40
+ grep: z<boolean, boolean, "defined">;
41
+ glob: z<boolean, boolean, "defined">;
42
+ read: z<boolean, boolean, "defined">;
43
+ edit: z<boolean, boolean, "defined">;
44
+ write: z<boolean, boolean, "defined">;
45
+ astGrep: z<boolean, boolean, "defined">;
46
+ astEdit: z<boolean, boolean, "defined">;
47
+ grepMaxMatches: z<number, number, "defined">;
48
+ grepMaxLineBytes: z<number, number, "defined">;
49
+ globMaxResults: z<number, number, "defined">;
50
+ readLimit: z<number, number, "defined">;
51
+ readMaxLineLength: z<number, number, "defined">;
52
+ readMaxBytes: z<number, number, "defined">;
53
+ readSummaryMinLines: z<number, number, "defined">;
54
+ readSummaryMinBodyLines: z<number, number, "defined">;
55
+ grammarDir: z<string, string, "plain">;
56
+ grammarBaseUrl: z<string, string, "plain">;
57
+ grammarAutoDownload: z<boolean, boolean, "defined">;
58
+ timeoutMs: z<number, number, "defined">;
59
+ }>>, "plain">;
60
+ export interface PluginConfig {
61
+ grep?: boolean | undefined;
62
+ glob?: boolean | undefined;
63
+ read?: boolean | undefined;
64
+ edit?: boolean | undefined;
65
+ write?: boolean | undefined;
66
+ astGrep?: boolean | undefined;
67
+ astEdit?: boolean | undefined;
68
+ grepMaxMatches?: number | undefined;
69
+ grepMaxLineBytes?: number | undefined;
70
+ globMaxResults?: number | undefined;
71
+ readLimit?: number | undefined;
72
+ readMaxLineLength?: number | undefined;
73
+ readMaxBytes?: number | undefined;
74
+ readSummaryMinLines?: number | undefined;
75
+ readSummaryMinBodyLines?: number | undefined;
76
+ grammarDir?: string | undefined;
77
+ grammarBaseUrl?: string | undefined;
78
+ grammarAutoDownload?: boolean | undefined;
79
+ timeoutMs?: number | undefined;
80
+ }
81
+ interface ResolvedConfig {
82
+ grep: boolean;
83
+ glob: boolean;
84
+ read: boolean;
85
+ edit: boolean;
86
+ write: boolean;
87
+ astGrep: boolean;
88
+ astEdit: boolean;
89
+ grepMaxMatches: number;
90
+ grepMaxLineBytes: number;
91
+ globMaxResults: number;
92
+ readLimit: number;
93
+ readMaxLineLength: number;
94
+ readMaxBytes: number;
95
+ readSummaryMinLines: number;
96
+ readSummaryMinBodyLines: number;
97
+ grammarDir: string | undefined;
98
+ grammarBaseUrl: string;
99
+ grammarAutoDownload: boolean;
100
+ timeoutMs: number;
101
+ }
102
+ export declare function resolveConfig(config: PluginConfig): ResolvedConfig | undefined;
103
+ export declare function apply(ctx: Context, config: PluginConfig): void;
104
+ export {};
105
+ //# sourceMappingURL=index.d.ts.map