Skip to content

Commit 698a3f5

Browse files
committed
feat(core): make code-search an optional feature
devo-code-search pulls in a heavy dependency stack (tokenizers, model2vec, hf-hub/hf-xet, hnsw_rs, and 24 tree-sitter grammars) that adds ~48 MB to a release binary. Embedders that don't need semantic search (e.g. a lightweight remote diagnostic agent) currently cannot opt out. This makes code-search a default-on feature so existing builds are unchanged, while `--no-default-features` (or `default-features = false`) yields a slim build that omits the entire code-search stack. Verified: minimal binary 54.6 MB -> 6.6 MB stripped; cargo tree shows the tree-sitter/hf-hub/xet/tokenizers/model2vec/hnsw stack fully removed.
1 parent 1db8358 commit 698a3f5

3 files changed

Lines changed: 21 additions & 1 deletion

File tree

crates/core/Cargo.toml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,17 @@ license.workspace = true
55
name = "devo-core"
66
version.workspace = true
77

8+
[features]
9+
default = ["code-search"]
10+
# Semantic code search tool (`code_search`). Optional because it pulls in heavy
11+
# dependencies (tokenizers, model2vec, hf-hub/hf-xet, hnsw_rs and the full
12+
# tree-sitter grammar set). Disable with `--no-default-features` for a slim
13+
# build that omits the entire code-search stack.
14+
code-search = ["dep:devo-code-search"]
15+
816
[dependencies]
917
devo-config = { workspace = true }
10-
devo-code-search = { workspace = true }
18+
devo-code-search = { workspace = true, optional = true }
1119
devo-network-proxy = { workspace = true }
1220
devo-protocol = { workspace = true }
1321
devo-provider = { workspace = true }

crates/core/src/tools/handlers/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
mod agent;
22
mod apply_patch;
33
mod bash;
4+
#[cfg(feature = "code-search")]
45
mod code_search;
56
mod exec_command;
67
mod file_write;
@@ -23,6 +24,7 @@ mod websearch;
2324
pub use agent::register_agent_tools;
2425
pub use apply_patch::ApplyPatchHandler;
2526
pub use bash::BashHandler;
27+
#[cfg(feature = "code-search")]
2628
pub use code_search::CodeSearchHandler;
2729
pub use exec_command::{ExecCommandHandler, WriteStdinHandler};
2830
pub use file_write::WriteHandler;
@@ -130,7 +132,14 @@ fn build_registry_from_builder(
130132
for (kind, name) in handlers {
131133
let handler: Arc<dyn ToolHandler> = match kind {
132134
ToolHandlerKind::Bash => Arc::new(BashHandler::new()),
135+
#[cfg(feature = "code-search")]
133136
ToolHandlerKind::CodeSearch => Arc::new(CodeSearchHandler::new()),
137+
// When the `code-search` feature is disabled the planner never emits
138+
// this handler kind (see registry_plan), so the arm is unreachable.
139+
#[cfg(not(feature = "code-search"))]
140+
ToolHandlerKind::CodeSearch => {
141+
unreachable!("code_search handler requested but `code-search` feature is disabled")
142+
}
134143
ToolHandlerKind::ShellCommand => Arc::new(ShellCommandHandler::new()),
135144
ToolHandlerKind::Read => Arc::new(ReadHandler::new()),
136145
ToolHandlerKind::Write => Arc::new(WriteHandler::new()),

crates/core/src/tools/registry_plan.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ fn grep_schema() -> JsonSchema {
258258
)
259259
}
260260

261+
#[cfg(feature = "code-search")]
261262
fn code_search_schema() -> JsonSchema {
262263
let enum_string = |description: &str, values: &[&str]| {
263264
let mut schema = JsonSchema::string(Some(description));
@@ -333,6 +334,7 @@ fn code_search_schema() -> JsonSchema {
333334
)
334335
}
335336

337+
#[cfg(feature = "code-search")]
336338
pub(crate) fn code_search_tool_spec() -> ToolSpec {
337339
ToolSpec {
338340
name: "code_search".to_string(),
@@ -737,6 +739,7 @@ pub fn build_tool_registry_plan(config: &ToolPlanConfig) -> ToolRegistryPlan {
737739
ToolHandlerKind::Grep,
738740
);
739741

742+
#[cfg(feature = "code-search")]
740743
if config.code_search {
741744
plan.push(code_search_tool_spec(), ToolHandlerKind::CodeSearch);
742745
}

0 commit comments

Comments
 (0)