UNPKG

zignet

Version:

MCP server for Zig — AI-powered code analysis, validation, and documentation with fine-tuned LLM

77 lines (75 loc) 2.03 kB
import { n as DEFAULT_ZIG_VERSION } from "./config-BtEBjBiA.js"; import { n as zigFormat } from "./executor-CUKaN4qu.js"; //#region src/tools/compile.ts /** * Format Zig code using official Zig formatter */ async function compileZig(input) { const { code, zig_version = DEFAULT_ZIG_VERSION } = input; if (!code || code.trim().length === 0) return { success: false, errors: [{ message: "Input code cannot be empty", severity: "error" }], summary: "❌ Empty input", zig_version }; try { const result = await Promise.resolve(zigFormat(code, zig_version)); if (result.success) return { success: true, output: result.output, errors: [], summary: `✅ Formatted successfully (Zig ${zig_version})`, zig_version }; else return { success: false, errors: result.diagnostics.map((d) => ({ message: d.message, line: d.line, column: d.column, severity: "error" })), summary: `❌ Format failed (Zig ${zig_version})`, zig_version }; } catch (error) { return { success: false, errors: [{ message: `Failed to run Zig formatter: ${error instanceof Error ? error.message : String(error)}`, severity: "error" }], summary: `❌ Format failed: Could not execute Zig ${zig_version}`, zig_version }; } } /** * Format compile result for MCP response */ function formatCompileResult(result) { const lines = []; lines.push(result.summary); lines.push(""); if (result.success && result.output) { lines.push("**Formatted Zig Code:**"); lines.push("```zig"); lines.push(result.output); lines.push("```"); return lines.join("\n"); } if (result.errors.length > 0) { lines.push("**Errors:**"); result.errors.forEach((error, index) => { const location = error.line && error.column ? ` (${error.line}:${error.column})` : ""; lines.push(`${index + 1}. ${error.message}${location}`); }); } return lines.join("\n"); } //#endregion export { formatCompileResult as n, compileZig as t }; //# sourceMappingURL=compile-DaJPSQYR.js.map