Tools - Move all description to a named export toolMetadata

This commit is contained in:
2026-04-09 10:05:09 +05:30
parent bc28df017f
commit 741bfee670
7 changed files with 85 additions and 68 deletions
@@ -4,22 +4,15 @@
*/
import { tool } from "@opencode-ai/plugin";
import { createEvaluateInEngine262Tool } from "../../src/agent-tools";
import {
createEvaluateInEngine262Tool,
toolMetadata,
} from "../../src/agent-tools/evaluateInEngine262";
export default tool({
description:
"Executes JavaScript code in the engine262 JavaScript engine and captures which ECMAScript specification sections are hit during execution. " +
"Returns JSON with importantSections and otherSections arrays. " +
"Use this to understand how specific JavaScript operations map to the ECMAScript spec. " +
"ask262Debug is available globally in the execution context (no import needed). " +
"Use ask262Debug.startImportant() and ask262Debug.stopImportant() to mark important sections. " +
"Example: ask262Debug.startImportant(); let x = 1 + 2; ask262Debug.stopImportant();",
description: toolMetadata.description,
args: {
code: tool.schema
.string()
.describe(
"JavaScript code to execute in engine262 (e.g., '[1,2,3].map(x => x * 2)')",
),
code: tool.schema.string().describe(toolMetadata.args.code),
},
async execute(args) {
const { code } = args;
+7 -15
View File
@@ -5,27 +5,19 @@
import { tool } from "@opencode-ai/plugin";
import * as lancedbSdk from "@lancedb/lancedb";
import { createGetSectionContentTool } from "../../src/agent-tools";
import {
createGetSectionContentTool,
toolMetadata,
} from "../../src/agent-tools/getSectionContent";
export default tool({
description:
"Retrieves all text chunks from a specific ECMAScript specification section by section ID. " +
"Supports recursive fetching - if recursive=true and the section has children, it will fetch all descendants. " +
"Use this to get complete spec text when you know the section ID (e.g., 'sec-if-statement').",
description: toolMetadata.description,
args: {
sectionId: tool.schema
.string()
.describe(
"The section ID (e.g., 'sec-if-statement', 'sec-array-prototype-map') to fetch content for",
),
sectionId: tool.schema.string().describe(toolMetadata.args.sectionId),
recursive: tool.schema
.boolean()
.default(true)
.describe(
"If true, recursively fetches content from all child sections and descendants. " +
"If false, only returns content from the specified section itself. " +
"Use false when you only need the specific section's content without subsections.",
),
.describe(toolMetadata.args.recursive),
},
async execute(args, context) {
const { sectionId, recursive } = args;
+6 -10
View File
@@ -6,19 +6,15 @@
import { tool } from "@opencode-ai/plugin";
import * as lancedbSdk from "@lancedb/lancedb";
import { OllamaEmbeddings } from "@langchain/ollama";
import { createSearchSpecSectionsTool } from "../../src/agent-tools";
import {
createSearchSpecSectionsTool,
toolMetadata,
} from "../../src/agent-tools/searchSpecSections";
export default tool({
description:
"Vector search the ECMAScript specification for sections relevant to a query. " +
"Returns JSON array with sectionId, sectionTitle, score, partIndex, totalParts, and content. " +
"Use this when you need to find spec sections related to a JavaScript topic or question.",
description: toolMetadata.description,
args: {
query: tool.schema
.string()
.describe(
"The search query to find relevant specification sections (e.g., 'how does array map work')",
),
query: tool.schema.string().describe(toolMetadata.args.query),
},
async execute(args, context) {
const { query } = args;