Skip to content

Commit f6d2a58

Browse files
committed
fix(tools): keep regex quantifiers in bounded grep
Brace rejection stays on globs and search_files. Drop the test-only bounded-read re-export from the read-file guard.
1 parent 496415b commit f6d2a58

4 files changed

Lines changed: 34 additions & 10 deletions

File tree

‎src/plugins/bounded-grep-fallback.test.ts‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,35 @@ describe("runBoundedGrep", () => {
9797
).rejects.toThrow();
9898
});
9999
});
100+
101+
test("accepts regex quantifier braces and still rejects glob braces", async () => {
102+
await withTempDir(async (dir) => {
103+
await writeFile(join(dir, "q.txt"), "foo\nfooo\n");
104+
const out = await runBoundedGrep(
105+
{ pattern: "foo{1,3}", path: "." },
106+
new AbortController().signal,
107+
dir,
108+
);
109+
expect(out).toContain("q.txt");
110+
expect(out).not.toContain("brace expansion");
111+
112+
await expect(
113+
runBoundedGrep(
114+
{ pattern: "foo", path: ".", glob: "*.{ts,txt}" },
115+
new AbortController().signal,
116+
dir,
117+
),
118+
).rejects.toThrow(/brace expansion is not supported/);
119+
120+
await expect(
121+
runBoundedSearchFiles(
122+
{ pattern: "*.{ts,txt}", path: "." },
123+
new AbortController().signal,
124+
dir,
125+
),
126+
).rejects.toThrow(/brace expansion is not supported/);
127+
});
128+
});
100129
});
101130

102131
describe("runBoundedSearchFiles", () => {

‎src/plugins/bounded-grep-fallback.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ export async function runBoundedGrep(
227227
): Promise<string> {
228228
signal.throwIfAborted();
229229

230-
const regex = compileUserRegex(rejectBraceExpansion(args.pattern));
230+
const regex = compileUserRegex(args.pattern);
231231

232232
const maxDirectoryEntries =
233233
limits.maxDirectoryEntries ?? BOUNDED_GREP_MAX_DIRECTORY_ENTRIES;

‎src/plugins/read-file-guard-plugin.test.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ import type {
1111
ToolResult,
1212
} from "@intx/types/runtime";
1313
import {
14-
READ_FILE_DEFAULT_MAX_LINES,
1514
READ_FILE_MAX_BYTES,
1615
READ_FILE_MAX_LINE_LENGTH,
1716
READ_FILE_MAX_SCAN_BYTES,
18-
READ_FILE_MAX_TOOL_OUTPUT_BYTES,
1917
readBytesBounded,
18+
} from "../io/bounded-read.js";
19+
import {
20+
READ_FILE_DEFAULT_MAX_LINES,
21+
READ_FILE_MAX_TOOL_OUTPUT_BYTES,
2022
readFileBounded,
2123
readFileGuardPlugin,
2224
} from "./read-file-guard-plugin.js";

‎src/plugins/read-file-guard-plugin.ts‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,6 @@ import {
2525
readStreamBounded,
2626
} from "../io/bounded-read.js";
2727

28-
export {
29-
READ_FILE_MAX_BYTES,
30-
READ_FILE_MAX_LINE_LENGTH,
31-
READ_FILE_MAX_SCAN_BYTES,
32-
readBytesBounded,
33-
} from "../io/bounded-read.js";
34-
3528
export const READ_FILE_DEFAULT_MAX_LINES = 2000;
3629
/** Refuse tool-output blobs larger than this before bounded paging. */
3730
export const READ_FILE_MAX_TOOL_OUTPUT_BYTES = READ_FILE_MAX_SCAN_BYTES;

0 commit comments

Comments
 (0)