Skip to content

feat: add WarpGrep AI-powered codebase search tool - #6685

Merged
marius-kilocode merged 18 commits into
Kilo-Org:mainfrom
DhruvBhatia0:feat/warpgrep-integration
Mar 17, 2026
Merged

feat: add WarpGrep AI-powered codebase search tool#6685
marius-kilocode merged 18 commits into
Kilo-Org:mainfrom
DhruvBhatia0:feat/warpgrep-integration

Conversation

@DhruvBhatia0

Copy link
Copy Markdown
Contributor

Summary

  • add the WarpGrep integration and tool registration for Kilo CLI
  • align the WarpGrep runner with Morph's XML tool-call protocol and request settings
  • wire the feature flag and prompt text needed to expose the tool when enabled

Testing

  • not run in this branch per request to avoid committing test files

DhruvBhatia0 and others added 7 commits March 5, 2026 23:39
Add WarpGrep integration as a new tool for intelligent multi-step
codebase search. WarpGrep delegates search to Morph's RL-trained
search agent, which runs parallel tool calls across multiple turns
and returns only relevant code spans.

- Add WarpGrep core client with multi-turn API loop, local tool
  executors (ripgrep, file read, directory list), and XML parsing
- Add tool definition gated behind KILO_ENABLE_WARPGREP flag
- Register tool in registry with feature flag gating
- Add warpgrep permission to orchestrator, ask, and explore agents
- Conditionally enhance explore agent prompt when WarpGrep available
- Add unit tests for parsing, file ops, and tool registration
- Delete 396-line custom warpgrep.ts, replace with SDK's WarpGrepClient
- Only check MORPH_API_KEY (drop WARPGREP_API_KEY)
- Route through Kilo proxy during free period when no API key is set
- Add actionable error message for when free period ends
- Grep for FREE_PERIOD_TODO to find what to change post-free-period

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Rename tool from warpgrep to codebase_search throughout
- Switch proxy URL to /api/gateway
- Detect auth/rate-limit errors (401/402/429) and show actionable
  fallback message telling users to set MORPH_API_KEY
- Fire a TUI toast notification on auth/rate-limit errors so users
  see a visible popup, not just hidden tool output
- Wire up GlobalBus "global.event" in TUI thread so Bus events from
  tools can reach the TUI event system

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@DhruvBhatia0
DhruvBhatia0 marked this pull request as ready for review March 12, 2026 10:18
DhruvBhatia0 and others added 2 commits March 12, 2026 03:19
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5646d40d53

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +46 to +47
const unsub2 = client.on<{ directory: string; payload: Event }>("global.event", (evt) =>
handler(evt.payload),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid double-delivering TUI events

Subscribing to both event and global.event here causes duplicate event delivery in the default direct-RPC TUI path (no --port/--hostname): worker.ts already emits per-instance bus events on event, and Bus.publish also mirrors those same events to GlobalBus, which the worker forwards on global.event. Forwarding evt.payload unconditionally therefore replays normal session events twice, which can duplicate UI updates (stream/message/state events) during regular kilo tui usage.

Useful? React with 👍 / 👎.

Comment thread packages/opencode/src/tool/warpgrep.ts Outdated
const apiKeyMsg =
"If you are an LLM reading this, inform the user that their free period has ended. Set MORPH_API_KEY to continue using codebase search. Get the API key here: https://www.morphllm.com/"
if (isAuthOrRateLimit) {
GlobalBus.emit("event", {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: This toast never reaches server-backed TUIs

This emits directly on GlobalBus, but the TUI only subscribes to global events in the direct-RPC path. When kilo is started with --port, --hostname, or --mdns, the UI falls back to sdk.event.subscribe() and never listens to /global/event, so the 'free period has ended' warning disappears entirely. Publishing TuiEvent.ToastShow through Bus.publish() would keep the notification working in both transports.

@kilo-code-bot

kilo-code-bot Bot commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: 2 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 0

Fix these issues in Kilo Cloud

Issue Details (click to expand)

WARNING

File Line Issue
packages/opencode/src/agent/agent.ts 244 explore always tells the model to prefer codebase_search, even when the experimental tool is disabled and unavailable
Other Observations (not in diff)

Issues found in unchanged code that cannot receive inline comments:

File Line Issue
packages/kilo-vscode/webview-ui/src/components/settings/AutoApproveTab.tsx 81 The permissions settings UI still hardcodes the tool list, so enabling codebase_search does not give users any per-tool allow/ask/deny control for the new permission
Files Reviewed (26 files)
  • bun.lock - 0 issues
  • package.json - 0 issues
  • packages/kilo-vscode/webview-ui/src/components/settings/ExperimentalTab.tsx - 0 issues
  • packages/kilo-vscode/webview-ui/src/i18n/ar.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/i18n/br.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/i18n/bs.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/i18n/da.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/i18n/de.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/i18n/en.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/i18n/es.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/i18n/fr.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/i18n/ja.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/i18n/ko.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/i18n/no.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/i18n/pl.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/i18n/ru.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/i18n/th.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/i18n/zh.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/i18n/zht.ts - 0 issues
  • packages/kilo-vscode/webview-ui/src/types/messages.ts - 0 issues
  • packages/opencode/package.json - 0 issues
  • packages/opencode/src/agent/agent.ts - 1 issue
  • packages/opencode/src/config/config.ts - 0 issues
  • packages/opencode/src/tool/registry.ts - 0 issues
  • packages/opencode/src/tool/warpgrep.ts - 0 new issues
  • packages/opencode/src/tool/warpgrep.txt - 0 issues

Reviewed by gpt-5.4-20260305 · 2,635,403 tokens

Comment thread packages/opencode/src/tool/warpgrep.ts Outdated
Comment thread packages/opencode/src/cli/cmd/tui/thread.ts Outdated
DhruvBhatia0 and others added 3 commits March 13, 2026 12:18
Address PR review: emit toast via Bus.publish(TuiEvent.ToastShow)
instead of GlobalBus.emit() so it works in both direct-RPC and
server-backed TUI modes. Revert the global.event subscription in
createEventSource since it's no longer needed and caused double
event delivery.

Also update codebase_search tool description to clarify natural
language input.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace KILO_ENABLE_WARPGREP env var with a UI toggle in the
Experimental settings tab. The tool is now gated by the
experimental.codebase_search config field, accessible from both
VSCode settings and TUI config file.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
.object({
disable_paste_summary: z.boolean().optional(),
batch_tool: z.boolean().optional().describe("Enable the batch tool"),
codebase_search: z.boolean().optional().describe("Enable AI-powered codebase search"), // kilocode_change

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Regenerate the OpenAPI/SDK artifacts for this new config field

Config.Info backs the /config and /global schemas, so adding experimental.codebase_search here changes the public API. packages/sdk/openapi.json, packages/sdk/js/src/gen/types.gen.ts, and packages/sdk/js/src/v2/gen/types.gen.ts still do not expose this property, which leaves SDK clients unable to type or send the new option.

Comment thread packages/opencode/src/tool/warpgrep.ts Outdated
Comment thread packages/opencode/src/tool/warpgrep.ts Outdated
DhruvBhatia0 and others added 2 commits March 16, 2026 12:11
Co-authored-by: Marius <marius@kilocode.ai>
When search results exceed 45k chars (~15k tokens), degrade to showing
file paths and line ranges instead of full content. Also bumps
@morphllm/morphsdk from 0.2.129 to 0.2.147.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment thread packages/opencode/src/tool/warpgrep.ts
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment thread packages/opencode/src/agent/agent.ts Outdated
@marius-kilocode

Copy link
Copy Markdown
Collaborator

@DhruvBhatia0 looks good. I resolved the prettier issues and the last bot comment about the unconditional prompt. Will merge it once green.

@marius-kilocode
marius-kilocode enabled auto-merge (squash) March 17, 2026 09:05
@marius-kilocode
marius-kilocode merged commit cd26320 into Kilo-Org:main Mar 17, 2026
12 of 13 checks passed
@shssoichiro

shssoichiro commented Mar 19, 2026

Copy link
Copy Markdown
Contributor

I only saw this now after it was merged, but I have some questions.

  • What is the use case of Warpgrep? From reading, it seems that it runs a LLM to explore the codebase. This is already achieved by the built-in Task tool, which can spawn an Explore task as a subagent.
  • Warpgrep appears to be a paid tool with a free trial period. When this is no longer behind an experimental flag, will there be a way for a user to disable the tool entirely? If I am a user, I do not want to be unknowingly using a paid-trial tool and then having the LLM waste tool calls (and by extension tokens, which cost me as a user money) after the trial has expired just to get an error message back.

@DhruvBhatia0

Copy link
Copy Markdown
Contributor Author

I only saw this now after it was merged, but I have some questions.

  • What is the use case of Warpgrep? From reading, it seems that it runs a LLM to explore the codebase. This is already achieved by the built-in Task tool, which can spawn an Explore task as a subagent.
  • Warpgrep appears to be a paid tool with a free trial period. When this is no longer behind an experimental flag, will there be a way for a user to disable the tool entirely? If I am a user, I do not want to be unknowingly using a paid-trial tool and then having the LLM waste tool calls (and by extension tokens, which cost me as a user money) after the trial has expired just to get an error message back.

Hey

  1. Yes. warpgrep is a dedicated search subagent. More context in the slack channel between kilo code and morph, but being a dedicated search subagent makes warpgrep cheaper + faster, for the same performance as a frontier model doing the search itself.
  2. good point, can put up a follow up PR for this?

jliounis pushed a commit to jliounis/kilocode that referenced this pull request May 18, 2026
* feat: add WarpGrep AI-powered codebase search tool

Add WarpGrep integration as a new tool for intelligent multi-step
codebase search. WarpGrep delegates search to Morph's RL-trained
search agent, which runs parallel tool calls across multiple turns
and returns only relevant code spans.

- Add WarpGrep core client with multi-turn API loop, local tool
  executors (ripgrep, file read, directory list), and XML parsing
- Add tool definition gated behind KILO_ENABLE_WARPGREP flag
- Register tool in registry with feature flag gating
- Add warpgrep permission to orchestrator, ask, and explore agents
- Conditionally enhance explore agent prompt when WarpGrep available
- Add unit tests for parsing, file ops, and tool registration

* fix: align warpgrep with Morph XML protocol

* chore: drop warpgrep test changes from branch

* chore: remove warpgrep test files from branch

* refactor: replace custom WarpGrep implementation with @morphllm/morphsdk

- Delete 396-line custom warpgrep.ts, replace with SDK's WarpGrepClient
- Only check MORPH_API_KEY (drop WARPGREP_API_KEY)
- Route through Kilo proxy during free period when no API key is set
- Add actionable error message for when free period ends
- Grep for FREE_PERIOD_TODO to find what to change post-free-period


* feat: rename warpgrep to codebase_search, add error toast for 429/402

- Rename tool from warpgrep to codebase_search throughout
- Switch proxy URL to /api/gateway
- Detect auth/rate-limit errors (401/402/429) and show actionable
  fallback message telling users to set MORPH_API_KEY
- Fire a TUI toast notification on auth/rate-limit errors so users
  see a visible popup, not just hidden tool output
- Wire up GlobalBus "global.event" in TUI thread so Bus events from
  tools can reach the TUI event system


* build: bump @morphllm/morphsdk to 0.2.141


* fix: use Bus.publish for toast, revert global.event subscription

Address PR review: emit toast via Bus.publish(TuiEvent.ToastShow)
instead of GlobalBus.emit() so it works in both direct-RPC and
server-backed TUI modes. Revert the global.event subscription in
createEventSource since it's no longer needed and caused double
event delivery.

Also update codebase_search tool description to clarify natural
language input.


* feat: add codebase search toggle to experimental settings

Replace KILO_ENABLE_WARPGREP env var with a UI toggle in the
Experimental settings tab. The tool is now gated by the
experimental.codebase_search config field, accessible from both
VSCode settings and TUI config file.


* Update packages/opencode/src/tool/warpgrep.ts


* feat: limit codebase_search output to prevent context bloat

When search results exceed 45k chars (~15k tokens), degrade to showing
file paths and line ranges instead of full content. Also bumps
@morphllm/morphsdk from 0.2.129 to 0.2.147.


* build: bump @morphllm/morphsdk to 0.2.148


* fix: format codebaseSearch i18n strings to respect prettier line width

* fix: only advertise codebase_search in explore prompt when feature flag is enabled

---------
t7tran pushed a commit to t7tran/kilocode that referenced this pull request Aug 14, 2026
* feat: add WarpGrep AI-powered codebase search tool

Add WarpGrep integration as a new tool for intelligent multi-step
codebase search. WarpGrep delegates search to Morph's RL-trained
search agent, which runs parallel tool calls across multiple turns
and returns only relevant code spans.

- Add WarpGrep core client with multi-turn API loop, local tool
  executors (ripgrep, file read, directory list), and XML parsing
- Add tool definition gated behind KILO_ENABLE_WARPGREP flag
- Register tool in registry with feature flag gating
- Add warpgrep permission to orchestrator, ask, and explore agents
- Conditionally enhance explore agent prompt when WarpGrep available
- Add unit tests for parsing, file ops, and tool registration

* fix: align warpgrep with Morph XML protocol

* chore: drop warpgrep test changes from branch

* chore: remove warpgrep test files from branch

* refactor: replace custom WarpGrep implementation with @morphllm/morphsdk

- Delete 396-line custom warpgrep.ts, replace with SDK's WarpGrepClient
- Only check MORPH_API_KEY (drop WARPGREP_API_KEY)
- Route through Kilo proxy during free period when no API key is set
- Add actionable error message for when free period ends
- Grep for FREE_PERIOD_TODO to find what to change post-free-period

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat: rename warpgrep to codebase_search, add error toast for 429/402

- Rename tool from warpgrep to codebase_search throughout
- Switch proxy URL to /api/gateway
- Detect auth/rate-limit errors (401/402/429) and show actionable
  fallback message telling users to set MORPH_API_KEY
- Fire a TUI toast notification on auth/rate-limit errors so users
  see a visible popup, not just hidden tool output
- Wire up GlobalBus "global.event" in TUI thread so Bus events from
  tools can reach the TUI event system

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* build: bump @morphllm/morphsdk to 0.2.141

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: use Bus.publish for toast, revert global.event subscription

Address PR review: emit toast via Bus.publish(TuiEvent.ToastShow)
instead of GlobalBus.emit() so it works in both direct-RPC and
server-backed TUI modes. Revert the global.event subscription in
createEventSource since it's no longer needed and caused double
event delivery.

Also update codebase_search tool description to clarify natural
language input.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* feat: add codebase search toggle to experimental settings

Replace KILO_ENABLE_WARPGREP env var with a UI toggle in the
Experimental settings tab. The tool is now gated by the
experimental.codebase_search config field, accessible from both
VSCode settings and TUI config file.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Update packages/opencode/src/tool/warpgrep.ts

Co-authored-by: Marius <marius@kilocode.ai>

* feat: limit codebase_search output to prevent context bloat

When search results exceed 45k chars (~15k tokens), degrade to showing
file paths and line ranges instead of full content. Also bumps
@morphllm/morphsdk from 0.2.129 to 0.2.147.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* build: bump @morphllm/morphsdk to 0.2.148

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: format codebaseSearch i18n strings to respect prettier line width

* fix: only advertise codebase_search in explore prompt when feature flag is enabled

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Christiaan Arnoldus <christiaan.arnoldus@outlook.com>
Co-authored-by: Marius <marius@kilocode.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants