Skip to content
This repository was archived by the owner on Apr 8, 2026. It is now read-only.

Commit 79bde61

Browse files
sync: refactor(effect): move read tool onto defineEffect (anomalyco#21016)
Upstream: c796b9a
1 parent 9931a6a commit 79bde61

1 file changed

Lines changed: 5 additions & 95 deletions

File tree

packages/xcsh/src/tool/registry.ts

Lines changed: 5 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -135,53 +135,6 @@ export namespace ToolRegistry {
135135
}),
136136
)
137137

138-
<<<<<<< ours
139-
const invalid = yield* build(InvalidTool)
140-
const ask = yield* build(QuestionTool)
141-
const bash = yield* build(BashTool)
142-
const read = yield* build(ReadTool)
143-
const glob = yield* build(GlobTool)
144-
const grep = yield* build(GrepTool)
145-
const edit = yield* build(EditTool)
146-
const write = yield* build(WriteTool)
147-
const task = yield* build(TaskTool)
148-
const fetch = yield* build(WebFetchTool)
149-
const todo = yield* build(TodoWriteTool)
150-
const search = yield* build(WebSearchTool)
151-
const code = yield* build(CodeSearchTool)
152-
const skill = yield* build(SkillTool)
153-
const patch = yield* build(ApplyPatchTool)
154-
const lsp = yield* build(LspTool)
155-
const batch = yield* build(BatchTool)
156-
const plan = yield* build(PlanExitTool)
157-
158-
const all = Effect.fn("ToolRegistry.all")(function* (custom: Tool.Info[]) {
159-
const cfg = yield* config.get()
160-
const question = ["app", "cli", "desktop"].includes(Flag.XCSH_CLIENT) || Flag.XCSH_ENABLE_QUESTION_TOOL
161-
162-
return [
163-
invalid,
164-
...(question ? [ask] : []),
165-
bash,
166-
read,
167-
glob,
168-
grep,
169-
edit,
170-
write,
171-
task,
172-
fetch,
173-
todo,
174-
search,
175-
code,
176-
skill,
177-
patch,
178-
...(Flag.XCSH_EXPERIMENTAL_LSP_TOOL ? [lsp] : []),
179-
...(cfg.experimental?.batch_tool === true ? [batch] : []),
180-
...(Flag.XCSH_EXPERIMENTAL_PLAN_MODE && Flag.XCSH_CLIENT === "cli" ? [plan] : []),
181-
...custom,
182-
]
183-
})
184-
=======
185138
const invalid = yield* build(InvalidTool)
186139
const ask = yield* build(QuestionTool)
187140
const bash = yield* build(BashTool)
@@ -200,53 +153,11 @@ export namespace ToolRegistry {
200153
const lsp = yield* build(LspTool)
201154
const batch = yield* build(BatchTool)
202155
const plan = yield* build(PlanExitTool)
203-
>>>>>>> theirs
204156

205157
const all = Effect.fn("ToolRegistry.all")(function* (custom: Tool.Info[]) {
206158
const cfg = yield* config.get()
207-
const question = ["app", "cli", "desktop"].includes(Flag.OPENCODE_CLIENT) || Flag.OPENCODE_ENABLE_QUESTION_TOOL
159+
const question = ["app", "cli", "desktop"].includes(Flag.XCSH_CLIENT) || Flag.XCSH_ENABLE_QUESTION_TOOL
208160

209-
<<<<<<< ours
210-
const tools = Effect.fn("ToolRegistry.tools")(function* (
211-
model: { providerID: ProviderID; modelID: ModelID },
212-
agent?: Agent.Info,
213-
) {
214-
const s = yield* InstanceState.get(state)
215-
const allTools = yield* all(s.custom)
216-
const filtered = allTools.filter((tool) => {
217-
if (tool.id === "codesearch" || tool.id === "websearch") {
218-
return model.providerID === ProviderID.opencode || Flag.XCSH_ENABLE_EXA
219-
}
220-
221-
const usePatch =
222-
!!Env.get("XCSH_E2E_LLM_URL") ||
223-
(model.modelID.includes("gpt-") && !model.modelID.includes("oss") && !model.modelID.includes("gpt-4"))
224-
if (tool.id === "apply_patch") return usePatch
225-
if (tool.id === "edit" || tool.id === "write") return !usePatch
226-
227-
return true
228-
})
229-
return yield* Effect.forEach(
230-
filtered,
231-
Effect.fnUntraced(function* (tool: Tool.Info) {
232-
using _ = log.time(tool.id)
233-
const next = yield* Effect.promise(() => tool.init({ agent }))
234-
const output = {
235-
description: next.description,
236-
parameters: next.parameters,
237-
}
238-
yield* plugin.trigger("tool.definition", { toolID: tool.id }, output)
239-
return {
240-
id: tool.id,
241-
description: output.description,
242-
parameters: output.parameters,
243-
execute: next.execute,
244-
formatValidationError: next.formatValidationError,
245-
}
246-
}),
247-
{ concurrency: "unbounded" },
248-
)
249-
=======
250161
return [
251162
invalid,
252163
...(question ? [ask] : []),
@@ -263,9 +174,9 @@ export namespace ToolRegistry {
263174
code,
264175
skill,
265176
patch,
266-
...(Flag.OPENCODE_EXPERIMENTAL_LSP_TOOL ? [lsp] : []),
177+
...(Flag.XCSH_EXPERIMENTAL_LSP_TOOL ? [lsp] : []),
267178
...(cfg.experimental?.batch_tool === true ? [batch] : []),
268-
...(Flag.OPENCODE_EXPERIMENTAL_PLAN_MODE && Flag.OPENCODE_CLIENT === "cli" ? [plan] : []),
179+
...(Flag.XCSH_EXPERIMENTAL_PLAN_MODE && Flag.XCSH_CLIENT === "cli" ? [plan] : []),
269180
...custom,
270181
]
271182
})
@@ -284,17 +195,16 @@ export namespace ToolRegistry {
284195
const allTools = yield* all(s.custom)
285196
const filtered = allTools.filter((tool) => {
286197
if (tool.id === "codesearch" || tool.id === "websearch") {
287-
return model.providerID === ProviderID.opencode || Flag.OPENCODE_ENABLE_EXA
198+
return model.providerID === ProviderID.opencode || Flag.XCSH_ENABLE_EXA
288199
}
289200

290201
const usePatch =
291-
!!Env.get("OPENCODE_E2E_LLM_URL") ||
202+
!!Env.get("XCSH_E2E_LLM_URL") ||
292203
(model.modelID.includes("gpt-") && !model.modelID.includes("oss") && !model.modelID.includes("gpt-4"))
293204
if (tool.id === "apply_patch") return usePatch
294205
if (tool.id === "edit" || tool.id === "write") return !usePatch
295206

296207
return true
297-
>>>>>>> theirs
298208
})
299209
return yield* Effect.forEach(
300210
filtered,

0 commit comments

Comments
 (0)