Repository navigation
fix(cli): safely restore grep signal controls #12882
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
marius-kilocode
merged 3 commits into
main
from
reintroduce-optimization-with-agent-safety-tests
Aug 6, 2026
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@kilocode/cli": patch | ||
| --- | ||
|
|
||
| Add bounded, context-aware grep controls without leaving agents waiting on completed searches. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| import type { Match } from "@opencode-ai/schema/filesystem" | ||
|
|
||
| export interface Options { | ||
| readonly context?: number | ||
| readonly literal?: boolean | ||
| readonly ignoreCase?: boolean | ||
| } | ||
|
|
||
| export type GrepMatch = Match & { | ||
| readonly context: boolean | ||
| readonly textTruncated: boolean | ||
| } | ||
|
|
||
| export const flags = (input: Options) => [ | ||
| ...(input.literal ? ["--fixed-strings"] : []), | ||
| ...(input.ignoreCase ? ["--ignore-case"] : []), | ||
| ...(input.context ? [`--context=${input.context}`] : []), | ||
| ] | ||
|
|
||
| export const stop = (limit: number) => { | ||
| let matches = 0 | ||
| return (row: { readonly context: boolean }) => !row.context && ++matches > limit | ||
| } | ||
|
|
||
| export const select = < | ||
| A extends { | ||
| readonly context: boolean | ||
| readonly path: { readonly text: string } | ||
| readonly line_number: number | ||
| }, | ||
| >( | ||
| input: { readonly limit: number; readonly context?: number }, | ||
| items: readonly A[], | ||
| ) => { | ||
| let count = 0 | ||
| const overflow = items.findIndex((row) => !row.context && ++count > input.limit) | ||
| const selected = items.slice(0, overflow === -1 ? items.length : overflow) | ||
| const matches = selected.filter((row) => !row.context) | ||
| return selected.filter( | ||
| (row) => | ||
| !row.context || | ||
| matches.some( | ||
| (match) => | ||
| match.path.text === row.path.text && Math.abs(match.line_number - row.line_number) <= (input.context ?? 0), | ||
| ), | ||
| ) | ||
| } | ||
|
|
||
| export const decorate = (match: Match, context: boolean, textTruncated: boolean): GrepMatch => | ||
| Object.assign(match, { context, textTruncated }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import type { ChildProcess } from "effect/unstable/process" | ||
|
|
||
| const commands = new WeakSet<object>() | ||
|
|
||
| export function attach(command: ChildProcess.StandardCommand) { | ||
| commands.add(command) | ||
| return command | ||
| } | ||
|
|
||
| export function take(command: ChildProcess.StandardCommand) { | ||
| const found = commands.has(command) | ||
| commands.delete(command) | ||
| return found | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.