@d0nj/dsh-native-tools 0.0.0-stage → 0.1.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 +109 -2
- package/cordis.patch.yml +33 -0
- package/dist/format.d.ts +36 -0
- package/dist/format.js +66 -0
- package/dist/grammars.d.ts +33 -0
- package/dist/grammars.js +124 -0
- package/dist/index.d.ts +105 -0
- package/dist/index.js +156 -0
- package/dist/native.d.ts +165 -0
- package/dist/native.js +60 -0
- package/dist/tools/ast.d.ts +51 -0
- package/dist/tools/ast.js +283 -0
- package/dist/tools/edit.d.ts +36 -0
- package/dist/tools/edit.js +127 -0
- package/dist/tools/glob.d.ts +15 -0
- package/dist/tools/glob.js +69 -0
- package/dist/tools/grep.d.ts +20 -0
- package/dist/tools/grep.js +105 -0
- package/dist/tools/read.d.ts +88 -0
- package/dist/tools/read.js +247 -0
- package/dist/tools/write.d.ts +25 -0
- package/dist/tools/write.js +86 -0
- package/grammars.json +357 -0
- package/icon.svg +5 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/native/dsh-natives.win32-x64.aab58ceaef11.node +0 -0
- package/package.json +76 -4
package/dist/index.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import '@deepseek-ai/dsh-agent';
|
|
2
|
+
import '@deepseek-ai/dsh-fs';
|
|
3
|
+
import '@deepseek-ai/dsh-tools';
|
|
4
|
+
import '@deepseek-ai/dsh-working-directory';
|
|
5
|
+
import z from '@deepseek-ai/schemastery';
|
|
6
|
+
import { loadNative } from './native.js';
|
|
7
|
+
import { defaultGrammarDir, ensureGrammar, grammarIdForPath, GRAMMAR_BASE_URL } from './grammars.js';
|
|
8
|
+
import { createAstEditTool, createAstGrepTool } from './tools/ast.js';
|
|
9
|
+
import { createEditTool } from './tools/edit.js';
|
|
10
|
+
import { createGlobTool, GLOB_MAX_RESULTS } from './tools/glob.js';
|
|
11
|
+
import { createGrepTool, GREP_MAX_LINE_BYTES, GREP_MAX_MATCHES } from './tools/grep.js';
|
|
12
|
+
import { createReadTool, READ_LIMIT, READ_MAX_BYTES, READ_MAX_LINE_LENGTH } from './tools/read.js';
|
|
13
|
+
import { createWriteTool } from './tools/write.js';
|
|
14
|
+
export const name = 'native-tools';
|
|
15
|
+
export const inject = ['tools', 'workingDirectory', 'fs'];
|
|
16
|
+
export const Config = z.object({
|
|
17
|
+
grep: z.boolean().default(true).description('Register the Rust-backed grep tool.'),
|
|
18
|
+
glob: z.boolean().default(true).description('Register the Rust-backed glob tool.'),
|
|
19
|
+
read: z.boolean().default(true).description('Register the Rust-backed read tool.'),
|
|
20
|
+
edit: z.boolean().default(true).description('Register the Rust-backed edit tool.'),
|
|
21
|
+
write: z.boolean().default(false).description('Register the Rust-backed write tool, replacing the shipped one.'),
|
|
22
|
+
astGrep: z.boolean().default(true).description('Register the deferred ast_grep structural search tool.'),
|
|
23
|
+
astEdit: z.boolean().default(true).description('Register the deferred ast_edit structural rewrite tool.'),
|
|
24
|
+
grepMaxMatches: z.number().default(GREP_MAX_MATCHES).description('Matches kept in the model-visible result.'),
|
|
25
|
+
grepMaxLineBytes: z.number().default(GREP_MAX_LINE_BYTES).description('Per-line preview cap in UTF-8 bytes.'),
|
|
26
|
+
globMaxResults: z.number().default(GLOB_MAX_RESULTS).description('Paths kept in the model-visible result.'),
|
|
27
|
+
readLimit: z.number().default(READ_LIMIT).description('Maximum lines one read call may request.'),
|
|
28
|
+
readMaxLineLength: z.number().default(READ_MAX_LINE_LENGTH).description('Per-line character cap in a read result.'),
|
|
29
|
+
readMaxBytes: z.number().default(READ_MAX_BYTES).description('Byte budget for the lines a read call returns.'),
|
|
30
|
+
readSummaryMinLines: z.number().default(200).description('Files at least this long can be read with summarize: true. Set 0 to disable summarization.'),
|
|
31
|
+
readSummaryMinBodyLines: z.number().default(6).description('Function bodies at least this many lines long are elided by a summary.'),
|
|
32
|
+
grammarDir: z.string().description('Directory holding on-demand WebAssembly grammars; defaults to ~/.dsh/grammars.'),
|
|
33
|
+
grammarBaseUrl: z.string().description('Base URL the pinned grammar assets are downloaded from.'),
|
|
34
|
+
grammarAutoDownload: z.boolean().default(true).description('Fetch a pinned WebAssembly grammar the first time a read needs one.'),
|
|
35
|
+
timeoutMs: z.number().default(30_000).description('Cooperative budget per tool call, enforced through the abort signal.'),
|
|
36
|
+
});
|
|
37
|
+
const POSITIVE_INTS = [
|
|
38
|
+
'grepMaxMatches',
|
|
39
|
+
'grepMaxLineBytes',
|
|
40
|
+
'globMaxResults',
|
|
41
|
+
'readLimit',
|
|
42
|
+
'readMaxLineLength',
|
|
43
|
+
'readMaxBytes',
|
|
44
|
+
'readSummaryMinBodyLines',
|
|
45
|
+
'timeoutMs',
|
|
46
|
+
];
|
|
47
|
+
export function resolveConfig(config) {
|
|
48
|
+
const resolved = {
|
|
49
|
+
grep: config.grep ?? true,
|
|
50
|
+
glob: config.glob ?? true,
|
|
51
|
+
read: config.read ?? true,
|
|
52
|
+
edit: config.edit ?? true,
|
|
53
|
+
write: config.write ?? false,
|
|
54
|
+
astGrep: config.astGrep ?? true,
|
|
55
|
+
astEdit: config.astEdit ?? true,
|
|
56
|
+
grepMaxMatches: config.grepMaxMatches ?? GREP_MAX_MATCHES,
|
|
57
|
+
grepMaxLineBytes: config.grepMaxLineBytes ?? GREP_MAX_LINE_BYTES,
|
|
58
|
+
globMaxResults: config.globMaxResults ?? GLOB_MAX_RESULTS,
|
|
59
|
+
readLimit: config.readLimit ?? READ_LIMIT,
|
|
60
|
+
readMaxLineLength: config.readMaxLineLength ?? READ_MAX_LINE_LENGTH,
|
|
61
|
+
readMaxBytes: config.readMaxBytes ?? READ_MAX_BYTES,
|
|
62
|
+
readSummaryMinLines: config.readSummaryMinLines ?? 200,
|
|
63
|
+
readSummaryMinBodyLines: config.readSummaryMinBodyLines ?? 6,
|
|
64
|
+
grammarDir: config.grammarDir,
|
|
65
|
+
grammarBaseUrl: config.grammarBaseUrl ?? GRAMMAR_BASE_URL,
|
|
66
|
+
grammarAutoDownload: config.grammarAutoDownload ?? true,
|
|
67
|
+
timeoutMs: config.timeoutMs ?? 30_000,
|
|
68
|
+
};
|
|
69
|
+
for (const key of POSITIVE_INTS) {
|
|
70
|
+
const value = resolved[key];
|
|
71
|
+
if (!Number.isInteger(value) || value < 1)
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
return resolved;
|
|
75
|
+
}
|
|
76
|
+
export function apply(ctx, config) {
|
|
77
|
+
const logger = ctx.logger(name);
|
|
78
|
+
const resolved = resolveConfig(config);
|
|
79
|
+
if (resolved === undefined) {
|
|
80
|
+
logger.error('ignoring row: every numeric setting must be a positive integer');
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
const native = loadNative();
|
|
85
|
+
logger.info('native addon %s ready', native.version());
|
|
86
|
+
native.setGrammarDir(resolved.grammarDir ?? defaultGrammarDir());
|
|
87
|
+
logger.info('grammar directory %s', native.grammarDirPath());
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
logger.error('native addon unavailable; the Rust tools stay unregistered: %o', error);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const sandboxPolicy = ctx.get('sandboxPolicy');
|
|
94
|
+
const policyFor = (exec) => {
|
|
95
|
+
const agent = exec.agent;
|
|
96
|
+
if (sandboxPolicy === undefined)
|
|
97
|
+
return undefined;
|
|
98
|
+
return sandboxPolicy.resolve(agent === undefined ? {} : { session: agent.session });
|
|
99
|
+
};
|
|
100
|
+
ctx.on('agent/created', (event) => {
|
|
101
|
+
const agent = event.agent;
|
|
102
|
+
const workdir = async (signal) => await ctx.workingDirectory.ensure(agent, signal);
|
|
103
|
+
const tools = [];
|
|
104
|
+
if (resolved.grep) {
|
|
105
|
+
tools.push(createGrepTool({
|
|
106
|
+
workdir,
|
|
107
|
+
maxMatches: resolved.grepMaxMatches,
|
|
108
|
+
maxLineBytes: resolved.grepMaxLineBytes,
|
|
109
|
+
timeoutMs: resolved.timeoutMs,
|
|
110
|
+
}));
|
|
111
|
+
}
|
|
112
|
+
if (resolved.glob) {
|
|
113
|
+
tools.push(createGlobTool({ workdir, maxResults: resolved.globMaxResults, timeoutMs: resolved.timeoutMs }));
|
|
114
|
+
}
|
|
115
|
+
if (resolved.read) {
|
|
116
|
+
tools.push(createReadTool({
|
|
117
|
+
ctx,
|
|
118
|
+
fs: ctx.fs,
|
|
119
|
+
workdir,
|
|
120
|
+
caps: {
|
|
121
|
+
limit: resolved.readLimit,
|
|
122
|
+
maxLineLength: resolved.readMaxLineLength,
|
|
123
|
+
maxBytes: resolved.readMaxBytes,
|
|
124
|
+
},
|
|
125
|
+
...(resolved.readSummaryMinLines > 0
|
|
126
|
+
? { summary: { minLines: resolved.readSummaryMinLines, minBodyLines: resolved.readSummaryMinBodyLines } }
|
|
127
|
+
: {}),
|
|
128
|
+
...(resolved.grammarAutoDownload
|
|
129
|
+
? {
|
|
130
|
+
grammar: {
|
|
131
|
+
idForPath: grammarIdForPath,
|
|
132
|
+
ensure: async (id, signal) => await ensureGrammar(id, { signal, baseUrl: resolved.grammarBaseUrl }),
|
|
133
|
+
},
|
|
134
|
+
}
|
|
135
|
+
: {}),
|
|
136
|
+
timeoutMs: resolved.timeoutMs,
|
|
137
|
+
}));
|
|
138
|
+
}
|
|
139
|
+
if (resolved.edit) {
|
|
140
|
+
tools.push(createEditTool({ ctx, fs: ctx.fs, workdir, policy: policyFor, timeoutMs: resolved.timeoutMs }));
|
|
141
|
+
}
|
|
142
|
+
if (resolved.write) {
|
|
143
|
+
tools.push(createWriteTool({ ctx, fs: ctx.fs, workdir, policy: policyFor, timeoutMs: resolved.timeoutMs }));
|
|
144
|
+
}
|
|
145
|
+
if (resolved.astGrep) {
|
|
146
|
+
tools.push(createAstGrepTool({ ctx, fs: ctx.fs, workdir, policy: policyFor, timeoutMs: resolved.timeoutMs }));
|
|
147
|
+
}
|
|
148
|
+
if (resolved.astEdit) {
|
|
149
|
+
tools.push(createAstEditTool({ ctx, fs: ctx.fs, workdir, policy: policyFor, timeoutMs: resolved.timeoutMs }));
|
|
150
|
+
}
|
|
151
|
+
for (const tool of tools)
|
|
152
|
+
agent.ctx.tools.register(tool);
|
|
153
|
+
return undefined;
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=index.js.map
|
package/dist/native.d.ts
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
export interface GrepRequest {
|
|
2
|
+
pattern: string;
|
|
3
|
+
cwd: string;
|
|
4
|
+
path?: string;
|
|
5
|
+
include?: string;
|
|
6
|
+
maxMatches: number;
|
|
7
|
+
maxLineBytes: number;
|
|
8
|
+
cancel?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface GrepHit {
|
|
11
|
+
path: string;
|
|
12
|
+
lineNumber: number;
|
|
13
|
+
line: string;
|
|
14
|
+
}
|
|
15
|
+
export interface GrepResponse {
|
|
16
|
+
hits: GrepHit[];
|
|
17
|
+
total: number;
|
|
18
|
+
}
|
|
19
|
+
export interface GlobRequest {
|
|
20
|
+
pattern: string;
|
|
21
|
+
cwd: string;
|
|
22
|
+
path?: string;
|
|
23
|
+
maxResults: number;
|
|
24
|
+
cancel?: number;
|
|
25
|
+
}
|
|
26
|
+
export interface GlobResponse {
|
|
27
|
+
paths: string[];
|
|
28
|
+
total: number;
|
|
29
|
+
root: string;
|
|
30
|
+
}
|
|
31
|
+
export interface ReadRequest {
|
|
32
|
+
content: string;
|
|
33
|
+
offset: number;
|
|
34
|
+
limit: number;
|
|
35
|
+
maxLineLength: number;
|
|
36
|
+
maxBytes: number;
|
|
37
|
+
cancel?: number;
|
|
38
|
+
}
|
|
39
|
+
export interface ReadLine {
|
|
40
|
+
number: number;
|
|
41
|
+
text: string;
|
|
42
|
+
}
|
|
43
|
+
export interface ReadResponse {
|
|
44
|
+
lines: ReadLine[];
|
|
45
|
+
totalLines: number;
|
|
46
|
+
}
|
|
47
|
+
export interface EditRequest {
|
|
48
|
+
text: string;
|
|
49
|
+
oldString: string;
|
|
50
|
+
newString: string;
|
|
51
|
+
replaceAll: boolean;
|
|
52
|
+
cancel?: number;
|
|
53
|
+
}
|
|
54
|
+
export interface EditResponse {
|
|
55
|
+
outcome: 'ok' | 'notFound' | 'ambiguous';
|
|
56
|
+
content: string;
|
|
57
|
+
replacements: number;
|
|
58
|
+
}
|
|
59
|
+
export interface AstGrepRequest {
|
|
60
|
+
pattern: string;
|
|
61
|
+
cwd: string;
|
|
62
|
+
path?: string;
|
|
63
|
+
lang?: string;
|
|
64
|
+
include?: string;
|
|
65
|
+
limit: number;
|
|
66
|
+
skip: number;
|
|
67
|
+
maxFiles: number;
|
|
68
|
+
cancel?: number;
|
|
69
|
+
}
|
|
70
|
+
export interface AstMetaVariable {
|
|
71
|
+
name: string;
|
|
72
|
+
text: string;
|
|
73
|
+
}
|
|
74
|
+
export interface AstMatch {
|
|
75
|
+
path: string;
|
|
76
|
+
text: string;
|
|
77
|
+
startLine: number;
|
|
78
|
+
startColumn: number;
|
|
79
|
+
endLine: number;
|
|
80
|
+
endColumn: number;
|
|
81
|
+
spanLines: number;
|
|
82
|
+
byteStart: number;
|
|
83
|
+
byteEnd: number;
|
|
84
|
+
meta: AstMetaVariable[];
|
|
85
|
+
}
|
|
86
|
+
export interface AstWarning {
|
|
87
|
+
path: string;
|
|
88
|
+
message: string;
|
|
89
|
+
}
|
|
90
|
+
export interface AstGrepResponse {
|
|
91
|
+
matches: AstMatch[];
|
|
92
|
+
total: number;
|
|
93
|
+
filesSearched: number;
|
|
94
|
+
filesWithMatches: number;
|
|
95
|
+
limitReached: boolean;
|
|
96
|
+
truncatedFiles: boolean;
|
|
97
|
+
warnings: AstWarning[];
|
|
98
|
+
unsupported: string[];
|
|
99
|
+
}
|
|
100
|
+
export interface AstRewriteRequest {
|
|
101
|
+
text: string;
|
|
102
|
+
pattern: string;
|
|
103
|
+
rewrite: string;
|
|
104
|
+
lang?: string;
|
|
105
|
+
path?: string;
|
|
106
|
+
maxReplacements: number;
|
|
107
|
+
cancel?: number;
|
|
108
|
+
}
|
|
109
|
+
export interface AstRewriteResponse {
|
|
110
|
+
content: string;
|
|
111
|
+
replacements: number;
|
|
112
|
+
}
|
|
113
|
+
export interface SummaryRequest {
|
|
114
|
+
text: string;
|
|
115
|
+
lang?: string;
|
|
116
|
+
path?: string;
|
|
117
|
+
minBodyLines: number;
|
|
118
|
+
unfoldUntilLines: number;
|
|
119
|
+
cancel?: number;
|
|
120
|
+
}
|
|
121
|
+
export interface SummarySegment {
|
|
122
|
+
startLine: number;
|
|
123
|
+
endLine: number;
|
|
124
|
+
kind: string;
|
|
125
|
+
label: string;
|
|
126
|
+
}
|
|
127
|
+
export interface SummaryResponse {
|
|
128
|
+
segments: SummarySegment[];
|
|
129
|
+
totalLines: number;
|
|
130
|
+
elidedLines: number;
|
|
131
|
+
language: string;
|
|
132
|
+
}
|
|
133
|
+
export interface GrammarStatus {
|
|
134
|
+
id: string;
|
|
135
|
+
installed: boolean;
|
|
136
|
+
}
|
|
137
|
+
export interface NativeSurface {
|
|
138
|
+
version(): string;
|
|
139
|
+
beginCall(): number;
|
|
140
|
+
cancelCall(id: number): void;
|
|
141
|
+
endCall(id: number): void;
|
|
142
|
+
grep(request: GrepRequest): Promise<GrepResponse>;
|
|
143
|
+
glob(request: GlobRequest): Promise<GlobResponse>;
|
|
144
|
+
readWindow(request: ReadRequest): Promise<ReadResponse>;
|
|
145
|
+
editContent(request: EditRequest): Promise<EditResponse>;
|
|
146
|
+
astGrep(request: AstGrepRequest): Promise<AstGrepResponse>;
|
|
147
|
+
astRewrite(request: AstRewriteRequest): Promise<AstRewriteResponse>;
|
|
148
|
+
summarizeCode(request: SummaryRequest): Promise<SummaryResponse>;
|
|
149
|
+
astLanguages(): string[];
|
|
150
|
+
setGrammarDir(path: string): void;
|
|
151
|
+
grammarDirPath(): string | null;
|
|
152
|
+
grammarStatus(ids: string[]): GrammarStatus[];
|
|
153
|
+
decompressZstd(data: Buffer): Buffer;
|
|
154
|
+
diffHunks(before: string, after: string, context: number): DiffHunk[];
|
|
155
|
+
diffChanged(before: string, after: string): boolean;
|
|
156
|
+
}
|
|
157
|
+
export interface DiffHunk {
|
|
158
|
+
oldText: string | null;
|
|
159
|
+
newText: string;
|
|
160
|
+
}
|
|
161
|
+
export declare function candidatePaths(platform?: NodeJS.Platform, arch?: NodeJS.Architecture): string[];
|
|
162
|
+
export declare function loadNative(): NativeSurface;
|
|
163
|
+
export declare function nativeVersion(): string | undefined;
|
|
164
|
+
export declare function cancellable<T>(signal: AbortSignal | undefined, run: (cancel: number) => Promise<T>): Promise<T>;
|
|
165
|
+
//# sourceMappingURL=native.d.ts.map
|
package/dist/native.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import { existsSync, readdirSync, statSync } from 'node:fs';
|
|
3
|
+
import { dirname, join } from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
const require = createRequire(import.meta.url);
|
|
6
|
+
function nativeRoot() {
|
|
7
|
+
return join(dirname(fileURLToPath(import.meta.url)), '..', 'native');
|
|
8
|
+
}
|
|
9
|
+
export function candidatePaths(platform = process.platform, arch = process.arch) {
|
|
10
|
+
const dir = nativeRoot();
|
|
11
|
+
const prefix = `dsh-natives.${platform}-${arch}`;
|
|
12
|
+
let names = [];
|
|
13
|
+
try {
|
|
14
|
+
names = readdirSync(dir).filter((name) => name.startsWith(prefix) && name.endsWith('.node'));
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return [join(dir, `${prefix}.node`)];
|
|
18
|
+
}
|
|
19
|
+
const ranked = names
|
|
20
|
+
.map((name) => join(dir, name))
|
|
21
|
+
.map((path) => ({ path, mtime: statSync(path).mtimeMs }))
|
|
22
|
+
.sort((left, right) => right.mtime - left.mtime)
|
|
23
|
+
.map((entry) => entry.path);
|
|
24
|
+
const plain = join(dir, `${prefix}.node`);
|
|
25
|
+
return ranked.length === 0 ? [plain] : ranked;
|
|
26
|
+
}
|
|
27
|
+
let cached;
|
|
28
|
+
export function loadNative() {
|
|
29
|
+
if (cached !== undefined)
|
|
30
|
+
return cached;
|
|
31
|
+
const candidates = candidatePaths();
|
|
32
|
+
const found = candidates.find((candidate) => existsSync(candidate));
|
|
33
|
+
if (found === undefined) {
|
|
34
|
+
throw new Error(`dsh-native-tools: no native addon for ${process.platform}-${process.arch}; looked in ${candidates.join(', ')}. Build it with "pnpm --filter @d0nj/dsh-native-tools build:native".`);
|
|
35
|
+
}
|
|
36
|
+
cached = require(found);
|
|
37
|
+
return cached;
|
|
38
|
+
}
|
|
39
|
+
export function nativeVersion() {
|
|
40
|
+
try {
|
|
41
|
+
return loadNative().version();
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export async function cancellable(signal, run) {
|
|
48
|
+
const native = loadNative();
|
|
49
|
+
const token = native.beginCall();
|
|
50
|
+
const abort = () => native.cancelCall(token);
|
|
51
|
+
signal?.addEventListener('abort', abort, { once: true });
|
|
52
|
+
try {
|
|
53
|
+
return await run(token);
|
|
54
|
+
}
|
|
55
|
+
finally {
|
|
56
|
+
signal?.removeEventListener('abort', abort);
|
|
57
|
+
native.endCall(token);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=native.js.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
import type { SandboxExecutionPolicy } from '@deepseek-ai/dsh-sandbox';
|
|
3
|
+
import type { FileSystem } from '@deepseek-ai/dsh-fs';
|
|
4
|
+
import { type ToolDefinition } from '@deepseek-ai/dsh-tools';
|
|
5
|
+
import { type JsonMeta, type MatchFile } from '../format.js';
|
|
6
|
+
import { type AstMatch } from '../native.js';
|
|
7
|
+
export declare const AST_MATCH_LIMIT = 50;
|
|
8
|
+
export declare const AST_MAX_FILES = 200;
|
|
9
|
+
export declare const AST_MAX_REPLACEMENTS = 1000;
|
|
10
|
+
export declare const AST_META_MAX_BYTES = 65536;
|
|
11
|
+
export interface AstDeps {
|
|
12
|
+
readonly ctx: Context;
|
|
13
|
+
readonly fs: FileSystem;
|
|
14
|
+
readonly workdir: (signal: AbortSignal) => Promise<string>;
|
|
15
|
+
readonly policy?: ((exec: {
|
|
16
|
+
readonly agent?: unknown;
|
|
17
|
+
}) => SandboxExecutionPolicy | undefined) | undefined;
|
|
18
|
+
readonly timeoutMs: number;
|
|
19
|
+
}
|
|
20
|
+
export interface AstGrepValue {
|
|
21
|
+
matches: Array<{
|
|
22
|
+
path: string;
|
|
23
|
+
lineNumber: number;
|
|
24
|
+
line: string;
|
|
25
|
+
meta: string[];
|
|
26
|
+
}>;
|
|
27
|
+
total: number;
|
|
28
|
+
filesSearched: number;
|
|
29
|
+
unsupported: string[];
|
|
30
|
+
warnings: string[];
|
|
31
|
+
}
|
|
32
|
+
export interface AstEditValue {
|
|
33
|
+
preview: string;
|
|
34
|
+
applied: boolean;
|
|
35
|
+
files: Array<{
|
|
36
|
+
path: string;
|
|
37
|
+
replacements: number;
|
|
38
|
+
}>;
|
|
39
|
+
total: number;
|
|
40
|
+
}
|
|
41
|
+
export declare function astMatchesToLines(matches: readonly AstMatch[]): MatchFile[];
|
|
42
|
+
export declare function renderAstMatches(value: AstGrepValue): string;
|
|
43
|
+
export declare function previewToken(entries: ReadonlyArray<{
|
|
44
|
+
path: string;
|
|
45
|
+
before: string;
|
|
46
|
+
}>): string;
|
|
47
|
+
export declare function renderAstEdit(value: AstEditValue): string;
|
|
48
|
+
export declare function astEditMeta(value: AstEditValue): JsonMeta;
|
|
49
|
+
export declare function createAstGrepTool(deps: AstDeps): ToolDefinition;
|
|
50
|
+
export declare function createAstEditTool(deps: AstDeps): ToolDefinition;
|
|
51
|
+
//# sourceMappingURL=ast.d.ts.map
|