refactory_verify_exports
Compare a post-decomposition module against a golden export snapshot to detect missing, added, or type-changed exports.
Instructions
Compare post-decomposition module against golden export snapshot. Reports missing, added, or type-changed exports.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| goldenFile | Yes | Path to .golden-exports.json from characterize | |
| newFile | Yes | Path to the new re-export module |
Implementation Reference
- src/server.js:142-152 (registration)Tool 'refactory_verify_exports' registered in the TOOLS array with name, description, and inputSchema (goldenFile + newFile required).
name: "refactory_verify_exports", description: "Compare post-decomposition module against golden export snapshot. Reports missing, added, or type-changed exports.", inputSchema: { type: "object", properties: { goldenFile: { type: "string", description: "Path to .golden-exports.json from characterize" }, newFile: { type: "string", description: "Path to the new re-export module" }, }, required: ["goldenFile", "newFile"], }, }, - src/tools/characterize.js:67-93 (handler)The verifyExports function is the handler for refactory_verify_exports. It loads golden exports JSON and the new module, then compares exports reporting missing, added, and type-changed exports.
function verifyExports({ goldenFile, newFile }) { const absGolden = path.resolve(goldenFile); const absNew = path.resolve(newFile); if (!fs.existsSync(absGolden)) { throw new Error(`Golden file not found: ${absGolden}`); } if (!fs.existsSync(absNew)) { throw new Error(`New module not found: ${absNew}`); } const golden = JSON.parse(fs.readFileSync(absGolden, "utf8")); const mod = freshRequire(absNew); const current = captureExports(mod); const goldenNames = Object.keys(golden.exports); const currentNames = Object.keys(current); const missing = goldenNames.filter((n) => !(n in current)); const added = currentNames.filter((n) => !(n in golden.exports)); const typeChanged = goldenNames.filter( (n) => n in current && current[n] !== golden.exports[n] ); const matches = missing.length === 0 && added.length === 0 && typeChanged.length === 0; return { matches, missing, added, typeChanged }; } - src/server.js:210-210 (handler)Dispatch case in server.js: when tool name is 'refactory_verify_exports', calls verifyExports(args) synchronously.
case "refactory_verify_exports": result = verifyExports(args); break; - src/server.js:144-152 (schema)Input schema for refactory_verify_exports: requires goldenFile (string) and newFile (string).
inputSchema: { type: "object", properties: { goldenFile: { type: "string", description: "Path to .golden-exports.json from characterize" }, newFile: { type: "string", description: "Path to the new re-export module" }, }, required: ["goldenFile", "newFile"], }, }, - src/tools/characterize.js:100-123 (helper)CaptureExports helper maps every export key to its typeof string. Also freshRequire helper to load module without cache for re-checking.
function captureExports(mod) { const result = {}; if (mod == null) return result; // If the module is a plain function (module.exports = fn), record as "default" if (typeof mod === "function") { result["default"] = "function"; // Also capture any properties attached to the function for (const key of Object.keys(mod)) { result[key] = typeof mod[key]; } return result; } if (typeof mod !== "object") { result["default"] = typeof mod; return result; } for (const key of Object.keys(mod)) { result[key] = typeof mod[key]; } return result; }