GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(hook): add tool.definition hook for plugins to modify tool descr… · un33k/opencode@1608565

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages
    • opencode/src/tool
      • registry.ts
    • plugin/src
      • index.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/opencode/src/tool/registry.ts‎

Copy file name to clipboardExpand all lines: packages/opencode/src/tool/registry.ts
+9-1Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,17 @@ export namespace ToolRegistry {
149149
})
150150
.map(async (t) => {
151151
using _ = log.time(t.id)
152+
const tool = await t.init({ agent })
153+
const output = {
154+
description: tool.description,
155+
parameters: tool.parameters,
156+
}
157+
await Plugin.trigger("tool.definition", { toolID: t.id }, output)
152158
return {
153159
id: t.id,
154-
...(await t.init({ agent })),
160+
...tool,
161+
description: output.description,
162+
parameters: output.parameters,
155163
}
156164
}),
157165
)
Collapse file

‎packages/plugin/src/index.ts‎

Copy file name to clipboardExpand all lines: packages/plugin/src/index.ts
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,4 +224,8 @@ export interface Hooks {
224224
input: { sessionID: string; messageID: string; partID: string },
225225
output: { text: string },
226226
) => Promise<void>
227+
/**
228+
* Modify tool definitions (description and parameters) sent to LLM
229+
*/
230+
"tool.definition"?: (input: { toolID: string }, output: { description: string; parameters: any }) => Promise<void>
227231
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.