feat(tool): add recursive flag to section content retrieval

- Introduce `recursive` boolean argument (default true) to the getSectionContent tool schema.
- Update descriptions to clarify that recursive fetching occurs only when `recursive=true`.
- Pass the `recursive` parameter from the CLI wrapper to the core tool function.
- Modify the content fetching logic to traverse child sections only when `recursive` is enabled.
This commit is contained in:
2026-04-09 09:51:43 +05:30
parent 1b338ffed7
commit 26509680ea
2 changed files with 23 additions and 6 deletions
+11 -3
View File
@@ -10,7 +10,7 @@ import { createGetSectionContentTool } from "../../src/agent-tools";
export default tool({
description:
"Retrieves all text chunks from a specific ECMAScript specification section by section ID. " +
"Supports recursive fetching - if a section has children, it will fetch all descendants. " +
"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').",
args: {
sectionId: tool.schema
@@ -18,9 +18,17 @@ export default tool({
.describe(
"The section ID (e.g., 'sec-if-statement', 'sec-array-prototype-map') to fetch content for",
),
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.",
),
},
async execute(args, context) {
const { sectionId } = args;
const { sectionId, recursive } = args;
const { worktree } = context;
// Connect to LanceDB
@@ -30,7 +38,7 @@ export default tool({
// Create and execute tool
const contentTool = createGetSectionContentTool(table);
const result = await contentTool.func({ sectionId });
const result = await contentTool.func({ sectionId, recursive });
return result;
},