Skip to content

fix(docs): resolve missing tool outputs for spread-inherited V2 tools#4020

Merged
waleedlatif1 merged 3 commits intostagingfrom
waleedlatif1/fix-extend-docs-outputs
Apr 7, 2026
Merged

fix(docs): resolve missing tool outputs for spread-inherited V2 tools#4020
waleedlatif1 merged 3 commits intostagingfrom
waleedlatif1/fix-extend-docs-outputs

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

Summary

  • Fix generate-docs.ts to resolve outputs for V2 tools that inherit via spread syntax (e.g., ...extendParserTool)
  • Extract findMatchingClose helper replacing ~26 inline brace-matching loops (-98 net lines)
  • Extract extractOutputsFromToolContent helper consolidating duplicated output extraction patterns
  • Regenerate docs for extend, pulse, reducto, textract, vision, stt, mistral_parse — all now show proper outputs

Type of Change

  • Bug fix

Testing

Ran generate-docs.ts and verified all 186 docs generate successfully with correct outputs. Diffed before/after refactor to confirm behavior preservation.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Apr 7, 2026 7:35pm

Request Review

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 7, 2026

PR Summary

Low Risk
Low risk: changes are limited to the docs generation script and regenerated MDX output tables; no runtime/product code paths are affected beyond documentation builds.

Overview
Fixes the docs generator so tool output schemas are correctly detected even when a V2 tool inherits its config via spread (e.g., ...baseTool).

Refactors scripts/generate-docs.ts by centralizing delimiter matching into findMatchingClose and consolidating output parsing into extractOutputsFromToolContent, then regenerates several tool docs (extend, pulse, reducto, textract, vision, stt, mistral_parse) to include the previously-missing Output tables.

Reviewed by Cursor Bugbot for commit 785d9fe. Configure here.

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 7, 2026

Greptile Summary

This PR fixes a bug in scripts/generate-docs.ts where V2 tools inheriting properties via TypeScript spread syntax (e.g., ...extendParserTool) had empty outputs in generated docs. The root cause: extractToolInfo narrowed toolContent to start AFTER the spread line (past the id: field), so the spread was invisible to the output extractor.

The fix adds a fallback path — when no outputs are found, the script reconstructs the full enclosing export block (using a global regex to find the last export const ... = { before id:), detects *Tool/*Base spread inheritance, and fetches outputs from the base tool definition directly.

Additional refactoring:

  • findMatchingClose helper extracted, replacing ~26 inline brace-counting loops throughout the file (-98 net lines)
  • extractOutputsFromToolContent helper extracted, consolidating two duplicated output-extraction patterns (const-reference and inline-object)
  • 7 MDX tool docs regenerated (extend, vision, stt, mistral_parse, reducto, textract, pulse) with correct output tables

One minor inconsistency: two inline brace-matching loops in parseConstFieldContent (~line 1403) and parseFieldContent (~line 1990) were not refactored to use findMatchingClose, leaving them out of step with the rest of the file."

Confidence Score: 5/5

Safe to merge — the fix is correct, well-scoped to a docs generation script with no app runtime impact, and the regenerated MDX files show the previously-missing outputs.

All findings are P2 style/consistency issues. The core V2 spread-inheritance fix is sound: the global-regex approach correctly identifies the last enclosing export declaration before the id: field, findMatchingClose is properly used with absolute file offsets, and baseToolRegex applies a word-boundary lookahead to avoid false matches. The two remaining inline brace-matching loops are a minor consistency issue but do not affect correctness.

scripts/generate-docs.ts — two inline brace-matching loops in parseConstFieldContent and parseFieldContent were not refactored to use findMatchingClose

Important Files Changed

Filename Overview
scripts/generate-docs.ts Core fix correctly reconstructs the full V2 tool block before the id: field to detect spread inheritance; findMatchingClose and extractOutputsFromToolContent helpers well-extracted; 2 inline brace-matching loops remain unrefactored
apps/docs/content/docs/en/tools/extend.mdx Regenerated with previously-missing outputs (id, status, chunks, blocks, pageCount, creditsUsed) now correctly resolved via spread inheritance fix
apps/docs/content/docs/en/tools/vision.mdx Regenerated with correct tool outputs from spread-inherited base tool definition
apps/docs/content/docs/en/tools/mistral_parse.mdx Regenerated with correct outputs after spread inheritance fix
apps/docs/content/docs/en/tools/reducto.mdx Regenerated with correct outputs after spread inheritance fix
apps/docs/content/docs/en/tools/stt.mdx Regenerated with correct outputs after spread inheritance fix
apps/docs/content/docs/en/tools/textract.mdx Regenerated with correct outputs after spread inheritance fix
apps/docs/content/docs/en/tools/pulse.mdx Regenerated with correct outputs after spread inheritance fix

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[getToolInfo
calls extractToolInfo] --> B[Narrow toolContent
find export block around id:]
    B --> C[extractOutputsFromToolContent
on narrowed toolContent]
    C --> D{Outputs
found?}
    D -- Yes --> G[Return outputs]
    D -- No --> E[Reconstruct fullToolBlock
find last 'export const = {'
in beforeId via global regex]
    E --> F[Search for spread:
...\w+Tool|Base\w*]
    F --> H{Spread
found?}
    H -- No --> I[Return empty]
    H -- Yes --> J[Locate base tool
export const baseVarName = {]
    J --> K[extractOutputsFromToolContent
on base tool block]
    K --> G
Loading

Reviews (2): Last reviewed commit: "fix(docs): remove unnecessary case-insen..." | Re-trigger Greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

@waleedlatif1 waleedlatif1 merged commit 762fbbd into staging Apr 7, 2026
12 checks passed
@waleedlatif1 waleedlatif1 deleted the waleedlatif1/fix-extend-docs-outputs branch April 7, 2026 19:41
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 785d9fe. Configure here.

const endIdx = findMatchingClose(fileContent, baseStart)
if (endIdx !== -1) {
const baseToolContent = fileContent.substring(baseStart, endIdx)
outputs = extractOutputsFromToolContent(baseToolContent, toolPrefix)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spread inheritance overrides explicitly empty outputs

Low Severity

The spread inheritance fallback checks Object.keys(outputs).length === 0 to decide whether to look up a base tool's outputs. This can't distinguish between "no outputs key found" and "tool explicitly declared outputs: {}". If a V2 tool intentionally overrides outputs to be empty (e.g., ...baseTool, outputs: {}), the code would incorrectly inherit the base tool's outputs, generating wrong documentation for that tool.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 785d9fe. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant