mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-08-29 03:44:06 +08:00
Merge pull request #9977 from Kilo-Org/mark/inline-tool-registry-overrides
refactor(cli): inline override predicates in tool registry
This commit is contained in:
@@ -71,21 +71,6 @@ export namespace KiloToolRegistry {
|
||||
})
|
||||
}
|
||||
|
||||
/** Override question-tool client gating (adds "vscode" to allowed clients) */
|
||||
export function question(): boolean {
|
||||
return ["app", "cli", "desktop", "vscode"].includes(Flag.KILO_CLIENT) || Flag.KILO_ENABLE_QUESTION_TOOL
|
||||
}
|
||||
|
||||
/** Plan tool is always registered in Kilo (gated by agent permission instead) */
|
||||
export function plan(): boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
/** Suggest tool is only registered for cli and vscode clients */
|
||||
export function suggest(tool: Tool.Def): Tool.Def[] {
|
||||
return ["cli", "vscode"].includes(Flag.KILO_CLIENT) ? [tool] : []
|
||||
}
|
||||
|
||||
/** Kilo-specific tools to append to the builtin list */
|
||||
export function extra(
|
||||
tools: { codebase: Tool.Def; semantic?: Tool.Def; recall: Tool.Def; manager: Tool.Def },
|
||||
@@ -99,9 +84,4 @@ export namespace KiloToolRegistry {
|
||||
...(Flag.KILO_CLIENT === "vscode" && cfg.experimental?.agent_manager_tool === true ? [tools.manager] : []),
|
||||
]
|
||||
}
|
||||
|
||||
/** Check for E2E LLM URL (uses KILO_E2E_LLM_URL env var) */
|
||||
export function e2e(): boolean {
|
||||
return !!process.env["KILO_E2E_LLM_URL"]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,10 @@ import { Plugin } from "../plugin"
|
||||
import { Provider } from "@/provider/provider"
|
||||
import { ProviderID, type ModelID } from "../provider/schema"
|
||||
import { WebSearchTool } from "./websearch"
|
||||
import { KiloToolRegistry } from "../kilocode/tool/registry" // kilocode_change
|
||||
import { makeRuntime } from "@/effect/run-service" // kilocode_change
|
||||
// kilocode_change start
|
||||
import { KiloToolRegistry } from "../kilocode/tool/registry"
|
||||
import { makeRuntime } from "@/effect/run-service"
|
||||
// kilocode_change end
|
||||
import { Flag } from "@opencode-ai/core/flag/flag"
|
||||
import * as Log from "@opencode-ai/core/util/log"
|
||||
import { LspTool } from "./lsp"
|
||||
@@ -117,8 +119,10 @@ export const layer: Layer.Layer<
|
||||
const patchtool = yield* ApplyPatchTool
|
||||
const skilltool = yield* SkillTool
|
||||
const agent = yield* Agent.Service
|
||||
const suggesttool = yield* SuggestTool // kilocode_change
|
||||
const kiloToolInfos = yield* KiloToolRegistry.infos() // kilocode_change
|
||||
// kilocode_change start
|
||||
const suggesttool = yield* SuggestTool
|
||||
const kiloToolInfos = yield* KiloToolRegistry.infos()
|
||||
// kilocode_change end
|
||||
|
||||
const state = yield* InstanceState.make<State>(
|
||||
Effect.fn("ToolRegistry.state")(function* (ctx) {
|
||||
@@ -194,10 +198,10 @@ export const layer: Layer.Layer<
|
||||
}
|
||||
}
|
||||
|
||||
const cfg = yield* config.get()
|
||||
const questionEnabled = KiloToolRegistry.question() // kilocode_change
|
||||
const cfg = yield* config.get() // kilocode_change: capture for KiloToolRegistry.extra
|
||||
const questionEnabled =
|
||||
["app", "cli", "desktop", "vscode"].includes(Flag.KILO_CLIENT) || Flag.KILO_ENABLE_QUESTION_TOOL // kilocode_change: add vscode client + KILO_* flag
|
||||
|
||||
// kilocode_change start
|
||||
const tool = yield* Effect.all({
|
||||
invalid: Tool.init(invalid),
|
||||
bash: Tool.init(bash),
|
||||
@@ -217,11 +221,9 @@ export const layer: Layer.Layer<
|
||||
plan: Tool.init(plan),
|
||||
suggest: Tool.init(suggesttool), // kilocode_change
|
||||
})
|
||||
// kilocode_change end
|
||||
|
||||
const kilo = yield* KiloToolRegistry.build(kiloToolInfos, { agent: agents, truncate }) // kilocode_change
|
||||
|
||||
// kilocode_change start
|
||||
return {
|
||||
custom,
|
||||
builtin: [
|
||||
@@ -239,15 +241,16 @@ export const layer: Layer.Layer<
|
||||
tool.search,
|
||||
tool.skill,
|
||||
tool.patch,
|
||||
...(KiloToolRegistry.plan() ? [tool.plan] : []), // kilocode_change
|
||||
...KiloToolRegistry.suggest(tool.suggest), // kilocode_change
|
||||
...KiloToolRegistry.extra(kilo, cfg), // kilocode_change
|
||||
// kilocode_change start
|
||||
tool.plan,
|
||||
...(["cli", "vscode"].includes(Flag.KILO_CLIENT) ? [tool.suggest] : []),
|
||||
...KiloToolRegistry.extra(kilo, cfg),
|
||||
// kilocode_change end
|
||||
...(Flag.KILO_EXPERIMENTAL_LSP_TOOL ? [tool.lsp] : []),
|
||||
],
|
||||
task: tool.task,
|
||||
read: tool.read,
|
||||
}
|
||||
// kilocode_change end
|
||||
}),
|
||||
)
|
||||
|
||||
@@ -301,8 +304,10 @@ export const layer: Layer.Layer<
|
||||
}
|
||||
|
||||
const usePatch =
|
||||
KiloToolRegistry.e2e() || // kilocode_change
|
||||
// kilocode_change start
|
||||
!!process.env["KILO_E2E_LLM_URL"] ||
|
||||
(input.modelID.includes("gpt-") && !input.modelID.includes("oss") && !input.modelID.includes("gpt-4"))
|
||||
// kilocode_change end
|
||||
if (tool.id === ApplyPatchTool.id) return usePatch
|
||||
if (tool.id === EditTool.id) return !usePatch // kilocode_change
|
||||
|
||||
|
||||
Reference in New Issue
Block a user