Skip to content

Commit 13f7161

Browse files
committed
Delete ripgrepPlugin's own char-cap helper now that the wiring caps unconditionally
bounded() and its six call sites reapplied truncateToolResultContent by hand because ripgrepPlugin answers grep/search_files without calling next(), so the old in-chain result-truncation plugin never saw its output. Now that resultTruncationPlugin (and the secret scrub) wrap the whole chain unconditionally, this duplicate application is dead weight — six call sites are six places to forget a future change to the cap. Deleted rather than left alongside the new wiring.
1 parent 4b28396 commit 13f7161

1 file changed

Lines changed: 6 additions & 16 deletions

File tree

src/plugins/ripgrep-plugin.ts

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
import { statSync } from "node:fs";
22
import { dirname, basename } from "node:path";
33
import type { ToolPlugin } from "@intx/tools-posix";
4-
import type { ToolResult } from "@intx/types/runtime";
54

65
import {
76
runBoundedGrep,
87
runBoundedSearchFiles,
98
type BoundedGrepArgs,
109
} from "./bounded-grep-fallback.js";
1110
import { createRgCollector } from "./rg-output.js";
12-
import { truncateToolResultContent } from "./result-truncation-plugin.js";
1311
import { MAX_OUTPUT_BYTES, runRg, type RgLimits, type SpawnRg } from "./rg-run.js";
1412

1513
// A grep over a large tree with the pure-TypeScript walker enumerates the whole
@@ -33,14 +31,6 @@ function capLines(text: string, max: number): string {
3331
return `${lines.slice(0, max).join("\n")}\n... (showing first ${max} of ${lines.length}+ matches; narrow path/glob)`;
3432
}
3533

36-
// ripgrepPlugin answers grep and search_files without calling next, so the
37-
// result-truncation middleware sitting later in the chain never sees these
38-
// results. The shared primitive is applied here instead, keeping one wording
39-
// for size truncation on a path that would otherwise return uncapped.
40-
function bounded(callId: string, content: string): ToolResult {
41-
return { callId, content: truncateToolResultContent(content) };
42-
}
43-
4434
// Mirrors read_file's truncate-and-offer behavior: a cap or timeout still
4535
// surfaces whatever matches were collected before it fired, instead of
4636
// discarding them behind a bare error. `notice` is only set for conditions
@@ -114,7 +104,7 @@ export function ripgrepPlugin(cwd: string, limits: RgLimits = {}, spawnChild?: S
114104
};
115105
if (glob !== undefined) boundedArgs.glob = glob;
116106
const content = await runBoundedGrep(boundedArgs, signal, rgCwd);
117-
return bounded(call.id, boundedContent(content, maxResults, maxBytes));
107+
return { callId: call.id, content: boundedContent(content, maxResults, maxBytes) };
118108
} catch (err) {
119109
return {
120110
callId: call.id,
@@ -130,9 +120,9 @@ export function ripgrepPlugin(cwd: string, limits: RgLimits = {}, spawnChild?: S
130120
return { callId: call.id, content: result.message, isError: true };
131121
}
132122
if (result.kind === "partial") {
133-
return bounded(call.id, partialContent(result.stdout, maxResults, result.notice));
123+
return { callId: call.id, content: partialContent(result.stdout, maxResults, result.notice) };
134124
}
135-
return bounded(call.id, capLines(result.stdout, maxResults));
125+
return { callId: call.id, content: capLines(result.stdout, maxResults) };
136126
}
137127

138128
if (call.name === "search_files") {
@@ -150,7 +140,7 @@ export function ripgrepPlugin(cwd: string, limits: RgLimits = {}, spawnChild?: S
150140
signal,
151141
rgCwd,
152142
);
153-
return bounded(call.id, boundedContent(content, maxResults, maxBytes));
143+
return { callId: call.id, content: boundedContent(content, maxResults, maxBytes) };
154144
} catch (err) {
155145
return {
156146
callId: call.id,
@@ -166,9 +156,9 @@ export function ripgrepPlugin(cwd: string, limits: RgLimits = {}, spawnChild?: S
166156
return { callId: call.id, content: result.message, isError: true };
167157
}
168158
if (result.kind === "partial") {
169-
return bounded(call.id, partialContent(result.stdout, maxResults, result.notice));
159+
return { callId: call.id, content: partialContent(result.stdout, maxResults, result.notice) };
170160
}
171-
return bounded(call.id, capLines(result.stdout, maxResults));
161+
return { callId: call.id, content: capLines(result.stdout, maxResults) };
172162
}
173163

174164
return next(call, signal);

0 commit comments

Comments
 (0)