fix grep exact file path searches (#22356)

This commit is contained in:
Kit Langton
2026-04-13 19:26:50 -04:00
committed by GitHub
parent 59c0fc28ee
commit a06f40297b
6 changed files with 139 additions and 4 deletions

View File

@@ -90,4 +90,25 @@ describe("tool.grep", () => {
}),
),
)
it.live("supports exact file paths", () =>
provideTmpdirInstance((dir) =>
Effect.gen(function* () {
const file = path.join(dir, "test.txt")
yield* Effect.promise(() => Bun.write(file, "line1\nline2\nline3"))
const info = yield* GrepTool
const grep = yield* info.init()
const result = yield* grep.execute(
{
pattern: "line2",
path: file,
},
ctx,
)
expect(result.metadata.matches).toBe(1)
expect(result.output).toContain(file)
expect(result.output).toContain("Line 2: line2")
}),
),
)
})