Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions packages/opencode/src/tool/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,13 @@ export namespace ToolRegistry {
if (matches.length) await Config.waitForDependencies()
for (const match of matches) {
const namespace = path.basename(match, path.extname(match))
const mod = await import(match)
for (const [id, def] of Object.entries<ToolDefinition>(mod)) {
custom.push(fromPlugin(id === "default" ? namespace : `${namespace}_${id}`, def))
try {
const mod = await import(match)
for (const [id, def] of Object.entries<ToolDefinition>(mod)) {
custom.push(fromPlugin(id === "default" ? namespace : `${namespace}_${id}`, def))
}
} catch (e) {
log.warn("failed to load custom tool", { path: match, error: e })
}
}

Expand Down
3 changes: 2 additions & 1 deletion packages/opencode/test/tool/registry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ describe("tool.registry", () => {
await Instance.provide({
directory: tmp.path,
fn: async () => {
// should not throw even when the tool has unresolvable dependencies
const ids = await ToolRegistry.ids()
expect(ids).toContain("cowsay")
expect(ids).not.toContain("cowsay")
},
})
})
Expand Down
Loading