review.test-mapfile
Test mapfile macros with security validation to identify and prevent unauthorized tags in Re:VIEW manuscripts.
Instructions
Test #@mapfile macro with security validation (developer tool)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cwd | Yes | ||
| file | Yes |
Implementation Reference
- src/index.ts:581-629 (handler)Primary MCP tool handler for 'review.test-mapfile'. Validates mapfile path and size using security config, then calls the core testMapfileCommand.case "review.test-mapfile": { const securityConfig = await loadSecurityConfig(args.cwd as string); const pathValidation = validateMapfilePath(args.file as string, securityConfig); if (!pathValidation.valid) { return { content: [ { type: "text", text: JSON.stringify({ success: false, error: `Security validation failed: ${pathValidation.reason}` }) } ] }; } const sizeValidation = await validateMapfileSize( args.file as string, args.cwd as string, securityConfig ); if (!sizeValidation.valid) { return { content: [ { type: "text", text: JSON.stringify({ success: false, error: `File size validation failed: ${sizeValidation.reason}` }) } ] }; } const result = await hybridCommands.testMapfile({ file: args.file as string, cwd: args.cwd as string }); return { content: [ { type: "text", text: JSON.stringify(result) } ] }; }
- src/commands/hybrid-pipeline.ts:132-173 (handler)Core logic for testing #@mapfile macro: writes a test .re file embedding the mapfile, preprocesses it with Re:VIEW, reads the output, and reports success with processed content.export async function testMapfileCommand(options: TestMapfileOptions) { const { file, cwd } = options; const testFile = path.join(cwd, "test-mapfile.re"); const testContent = `//list[test]{ #@mapfile(${file}) #@end //} `; try { await fs.writeFile(testFile, testContent, "utf-8"); const result = await preprocessCommand({ pattern: "test-mapfile.re", output: ".out", stats: true, cwd }); await fs.unlink(testFile).catch(() => {}); if (result.success) { const outputFile = path.join(cwd, ".out", "test-mapfile.re"); const processedContent = await fs.readFile(outputFile, "utf-8").catch(() => ""); return { success: true, processedContent, stats: result.stats }; } return result; } catch (error: any) { await fs.unlink(testFile).catch(() => {}); return { success: false, error: error.message }; } }
- src/index.ts:353-364 (schema)MCP tool schema: defines name, description, and input schema (cwd and file) advertised via ListTools.{ name: "review.test-mapfile", description: "Test #@mapfile macro with security validation (developer tool)", inputSchema: { type: "object", properties: { cwd: { type: "string" }, file: { type: "string" } }, required: ["cwd", "file"] } },
- TypeScript interface for testMapfileCommand input options, matching the tool's inputSchema.export interface TestMapfileOptions { file: string; cwd: string; }
- src/commands/hybrid-pipeline.ts:208-213 (registration)Exports hybridCommands object registering testMapfileCommand for import and use in src/index.ts.export const hybridCommands = { preprocess: preprocessCommand, buildPdfHybrid: buildPdfHybridCommand, checkRubyExtensions: checkRubyExtensionsCommand, testMapfile: testMapfileCommand };