Rewrite file
rewrite_fileApply heuristic migrations to rewrite code for upgrading HeroUI v2 and NextUI projects to v3 beta, returning transformed source with diagnostics.
Instructions
Apply heuristic migrations to code and return the rewritten source plus diagnostics.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"code": "<code>"
},
"name": "rewrite_file"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes |
Implementation Reference
- src/core/migration.ts:364-375 (handler)The `rewriteFile` function executes the logic for rewriting file content based on migration rules.
export function rewriteFile(code: string): RewriteFileResult { const { migratedCode, warnings, astEdits } = transformCode(code); // convert warning strings into generic edits const warningEdits = warnings.map((w) => ({ type: "warning", description: w, confidence: 0.5 })); return { rewrittenCode: migratedCode, edits: [...astEdits, ...warningEdits], warnings, manualReviewRequired: warnings.length > 0, confidence: 0.5, }; }