Skip to main content
Glama
t09tanaka

TypeScript Rename Helper

by t09tanaka

planFileMove

Plan file moves or renames while automatically updating all TypeScript import paths. Returns an edit plan and move suggestions without making any changes to the filesystem, enabling safe preview of refactoring operations.

Instructions

Plan file move/rename with import path updates. Returns edit plans and file move suggestions without modifying the filesystem.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectRootNoOptional base directory for resolving relative paths and limiting tsconfig discovery
workspaceRootNoOptional monorepo root used to search multiple tsconfig.json files
tsconfigPathNoOptional explicit tsconfig.json path for the primary project
oldPathYesAbsolute path or path relative to projectRoot/workspaceRoot of the file to move
newPathYesAbsolute path or path relative to projectRoot/workspaceRoot of the destination

Implementation Reference

  • Core handler that resolves paths, collects TypeScript services, runs getEditsForFileRename across projects, and returns edit plans with file move suggestions.
    export function planFileMove(params: PlanFileMoveParams): PlanFileMoveResult {
      const baseDir = path.resolve(
        params.workspaceRoot ?? params.projectRoot ?? process.cwd()
      );
    
      // 1. oldPath / newPath を絶対パスに正規化
      const oldAbs = resolveInputPath(params.oldPath, baseDir);
      const newAbs = resolveInputPath(params.newPath, baseDir);
      const candidateContexts = collectWorkspaceTsServices([oldAbs, newAbs], {
        projectRoot: params.projectRoot,
        workspaceRoot: params.workspaceRoot,
        tsconfigPath: params.tsconfigPath,
        primaryFilePath: oldAbs,
      });
      const editBucket = createEditBucket();
    
      // 2. 各 TS プロジェクトで getEditsForFileRename を実行し、結果をマージ
      for (const context of candidateContexts) {
        const fileTextChanges = context.service.getEditsForFileRename(
          oldAbs,
          newAbs,
          {},
          {}
        );
        addFileTextChanges(editBucket, context.tsModule, fileTextChanges);
      }
    
      const edits = toFileTextEdits(editBucket);
    
      // 3. fsMoves として 1 件追加
      const fsMoves = [
        {
          from: oldAbs,
          to: newAbs,
        },
      ];
    
      // 7. 結果を返す
      return {
        edits,
        fsMoves,
      };
    }
  • Input parameter type for planFileMove: workspace/project roots, optional tsconfig path, oldPath and newPath for the file move.
    export type PlanFileMoveParams = {
      projectRoot?: string; // 旧互換: 相対パスの解決基準 / ワークスペース境界
      workspaceRoot?: string; // monorepo 全体を探索するためのルート
      tsconfigPath?: string; // 移動元ファイルの所属 tsconfig を明示したい場合
      oldPath: string; // 元ファイルパス
      newPath: string; // 移動先ファイルパス
    };
  • Output result type: list of text edits to update imports, and fsMoves for actual file system moves.
    export type PlanFileMoveResult = {
      edits: FileTextEdits[];
      fsMoves: FsMove[]; // 通常は 1 件だけ
    };
  • src/index.ts:79-111 (registration)
    Tool registration in the TOOLS array with name 'planFileMove' and its input schema definition.
    {
      name: "planFileMove",
      description:
        "Plan file move/rename with import path updates. Returns edit plans and file move suggestions without modifying the filesystem.",
      inputSchema: {
        type: "object",
        properties: {
          projectRoot: {
            type: "string",
            description:
              "Optional base directory for resolving relative paths and limiting tsconfig discovery",
          },
          workspaceRoot: {
            type: "string",
            description:
              "Optional monorepo root used to search multiple tsconfig.json files",
          },
          tsconfigPath: {
            type: "string",
            description:
              "Optional explicit tsconfig.json path for the primary project",
          },
          oldPath: {
            type: "string",
            description: "Absolute path or path relative to projectRoot/workspaceRoot of the file to move",
          },
          newPath: {
            type: "string",
            description: "Absolute path or path relative to projectRoot/workspaceRoot of the destination",
          },
        },
        required: ["oldPath", "newPath"],
      },
  • src/index.ts:192-203 (registration)
    Call handler in the switch statement: dispatches to planFileMove when the tool name matches.
    case "planFileMove": {
      const params = args as unknown as PlanFileMoveParams;
      const result = planFileMove(params);
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(result, null, 2),
          },
        ],
      };
    }
Behavior3/5

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

Without annotations, the description bears full responsibility. It discloses non-destructive behavior ('without modifying the filesystem') and output type ('edit plans and file move suggestions'), but omits details like idempotency, error handling on missing paths, or whether it checks for destination conflicts. Adequate but not comprehensive.

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

Conciseness5/5

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

The description is a single concise sentence conveying the core function and behavior. No extraneous words; every part earns its place. Front-loaded with action and key features.

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?

With no output schema, the description should explain return format or structure more fully. 'Returns edit plans and file move suggestions' is vague; an agent needs to know what fields or structure to expect. Parameter details are complete via schema, but output details are insufficient for a planning tool.

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

Parameters3/5

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

Input schema covers all parameters with descriptions, so baseline 3 applies. The description adds no extra context beyond the schema, such as required file existence or path resolution details. It neither harms nor significantly improves understanding.

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

Purpose5/5

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

The description clearly states the tool's purpose: planning file move/rename with import path updates, and explicitly distinguishes it from execution by noting it returns plans without modifying the filesystem. Sibling tools planDirectoryMove and planRenameSymbol indicate this is for individual files, providing clear differentiation.

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

Usage Guidelines3/5

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

The description implies usage for planning a move/rename without committing changes, but lacks explicit guidance on when to use versus siblings, prerequisites (e.g., file existence), or when not to use. The context of 'planning' is clear but not elaborated with conditions.

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/t09tanaka/ts-rename-helper-mcp'

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