Skip to main content
Glama

Rewrite file

rewrite_file

Apply 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.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYes

Implementation Reference

  • 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,
      };
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but omits critical safety information: whether the operation is destructive, if it requires specific file permissions, or what 'heuristic' implies regarding reliability. While it mentions returning 'rewritten source plus diagnostics,' it doesn't explain error conditions or side effects.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence with minimal waste. Front-loaded with the action (apply migrations) followed by return value. 'Heuristic migrations' is slightly opaque but the structure is efficient.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given zero annotation coverage, 0% schema descriptions, no output schema, and a mutation-oriented operation (rewrite), the description is insufficient. It lacks input constraints, error handling details, and behavioral guarantees needed for a code transformation tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0% (no descriptions in schema), yet the description fails to compensate by defining the 'code' parameter. It doesn't specify expected format, language constraints, or whether this accepts file paths, raw strings, or specific syntax.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses specific verbs (apply, return) and identifies the resource (code/source). However, 'heuristic migrations' remains somewhat jargon-heavy and doesn't clearly differentiate from sibling tools like analyze_file or compare_component which might also process code.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance provided on when to use this tool versus siblings like analyze_file or compare_component. No mention of prerequisites or conditions where rewriting is preferable to other code analysis tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/sctg-development/heroui-migration-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server