Skip to content

Commit 740ee0b

Browse files
authored
add maxResults to ripgrep tool (#280)
1 parent 515d15a commit 740ee0b

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/discord-bot/src/AiResponse.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ const Tools = Toolkit.make(
3737
glob: Schema.optionalKey(Schema.String).annotate({
3838
description:
3939
"An optional glob pattern to filter which files to search (e.g. '**/*.ts')"
40+
}),
41+
maxResults: Schema.Finite.annotate({
42+
description: "The maximum number of matches to return"
4043
})
4144
}),
4245
failure: EffectRepoError,
@@ -62,8 +65,11 @@ const ToolsLayer = Tools.toLayer(Effect.gen(function*() {
6265
const content = yield* repo.readFileRange({ path, startLine, endLine })
6366
return content
6467
}),
65-
ripgrep: Effect.fn(function*({ glob, pattern }) {
66-
const matches = yield* Stream.runCollect(repo.search({ pattern, glob }))
68+
ripgrep: Effect.fn(function*({ glob, maxResults, pattern }) {
69+
const matches = yield* repo.search({ pattern, glob }).pipe(
70+
Stream.take(maxResults),
71+
Stream.runCollect
72+
)
6773
return matches
6874
}),
6975
glob: Effect.fn(function*({ pattern }) {

0 commit comments

Comments
 (0)