review.lint
Validate Re:VIEW manuscript files by compiling to LaTeX and analyzing warnings to identify common errors before publishing.
Instructions
Run a fast sanity check by compiling each .re to latex and parsing stderr warnings.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cwd | Yes |
Implementation Reference
- src/index.ts:521-541 (handler)The handler for 'review.lint' tool. Compiles each .re file listed in catalog.yml using 'review-compile --target=latex', catches errors, parses stderr with parseStderr to collect diagnostics, and returns them as JSON.case "review.lint": { const files = await pickFilesFromCatalog(args.cwd as string); const diagnostics: any[] = []; for (const f of files) { try { await withBundle(args.cwd as string, ["review-compile", "--target=latex", "--footnotetext", f]); } catch (e: any) { const stderr = e?.stderr || e?.message || ""; diagnostics.push(...parseStderr(stderr, f)); continue; } } return { content: [ { type: "text", text: JSON.stringify({ diagnostics }) } ] }; }
- src/index.ts:303-311 (schema)Tool definition including name, description, and input schema (requires 'cwd' string) for listing in ListTools response.{ name: "review.lint", description: "Run a fast sanity check by compiling each .re to latex and parsing stderr warnings.", inputSchema: { type: "object", properties: { cwd: { type: "string" } }, required: ["cwd"] } },
- src/index.ts:404-422 (helper)Helper function to parse stderr from review-compile, extracting diagnostics for invalid block starts and duplicate IDs.function parseStderr(stderr: string, fallbackFile?: string) { const diags: any[] = []; const lines = stderr.split(/\r?\n/); const reInvalid = /^([^\s:]+):(\d+):\s+`\/\/'\s+seen.*?:\s+"(.+)"$/; // 09_xx.re:42: `//' seen ... const reDupId = /warning:\s+duplicate ID:/i; for (let raw of lines) { const line = raw.replace(/^\p{So}|^\s*⚠\s*WARN\s*/u, "").trim(); const m = line.match(reInvalid); if (m) { diags.push({ file: m[1], line: Number(m[2]), severity: "warning", message: `Invalid block start '//': ${m[3]}` }); continue; } if (reDupId.test(line)) { diags.push({ file: fallbackFile ?? null, line: null, severity: "warning", message: "Duplicate/empty ID detected" }); } } return diags; }