opencode-toolbox 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +28 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -37948,7 +37948,7 @@ Returns tools with schemas. Use toolbox_execute() to run them.`;
37948
37948
  var EXECUTE_DESC = `Execute a tool discovered via toolbox_search_bm25 or toolbox_search_regex.
37949
37949
 
37950
37950
  Pass arguments as JSON string matching the tool's schema.`;
37951
- var SYSTEM_PROMPT = `# Extended Toolbox
37951
+ var SYSTEM_PROMPT_BASE = `# Extended Toolbox
37952
37952
 
37953
37953
  You have access to an extended toolbox with additional capabilities (web search, time utilities, code search, etc.).
37954
37954
 
@@ -37960,6 +37960,27 @@ You have access to an extended toolbox with additional capabilities (web search,
37960
37960
  ## Workflow
37961
37961
  1. Search: toolbox_search_bm25({ text: "what you need" }) or toolbox_search_regex({ pattern: "prefix_.*" })
37962
37962
  2. Execute: toolbox_execute({ name: "tool_name", arguments: '{"key": "value"}' })`;
37963
+ function generateSystemPrompt(mcpManager) {
37964
+ const servers = mcpManager.getAllServers();
37965
+ if (servers.length === 0) {
37966
+ return SYSTEM_PROMPT_BASE;
37967
+ }
37968
+ const serverLines = [];
37969
+ for (const server of servers) {
37970
+ if (server.status === "connected" && server.tools.length > 0) {
37971
+ const toolNames = server.tools.map((t) => t.id.name).join(", ");
37972
+ serverLines.push(`- ${server.name}: ${toolNames}`);
37973
+ }
37974
+ }
37975
+ if (serverLines.length === 0) {
37976
+ return SYSTEM_PROMPT_BASE;
37977
+ }
37978
+ return `${SYSTEM_PROMPT_BASE}
37979
+
37980
+ ## Registered MCP Servers
37981
+ ${serverLines.join(`
37982
+ `)}`;
37983
+ }
37963
37984
  var ToolboxPlugin = async (ctx) => {
37964
37985
  const configPath = process.env.OPENCODE_TOOLBOX_CONFIG || DEFAULT_CONFIG_PATH;
37965
37986
  const configResult = await loadConfig(configPath);
@@ -38083,7 +38104,12 @@ var ToolboxPlugin = async (ctx) => {
38083
38104
  })
38084
38105
  },
38085
38106
  "experimental.chat.system.transform": async (_input, output) => {
38086
- output.system.push(SYSTEM_PROMPT);
38107
+ try {
38108
+ await ensureInitialized();
38109
+ output.system.push(generateSystemPrompt(mcpManager));
38110
+ } catch {
38111
+ output.system.push(SYSTEM_PROMPT_BASE);
38112
+ }
38087
38113
  }
38088
38114
  };
38089
38115
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-toolbox",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Tool Search Tool Plugin for OpenCode - search and execute tools from MCP servers on-demand",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",