First version copilot:

- basic llm call that can perform CRUD actions over dummy workflow json files
This commit is contained in:
tusharmagar 2025-10-30 16:09:19 +08:00 committed by Ramnique Singh
parent 055dda35b9
commit 4310b1d45d
11 changed files with 327 additions and 4 deletions

View file

@ -0,0 +1,24 @@
import fs from "fs";
import path from "path";
import { z } from "zod";
import { McpServerConfig } from "../../entities/mcp.js";
import { ensureBaseDirs, getStoragePaths } from "../services/storage.js";
export function mcpConfigPath(): string {
const base = getStoragePaths();
ensureBaseDirs(base);
return path.join(base.workDir, "mcp", "servers.json");
}
export function readMcpConfig(): z.infer<typeof McpServerConfig> {
const p = mcpConfigPath();
if (!fs.existsSync(p)) return { mcpServers: [] };
const raw = fs.readFileSync(p, "utf8");
return McpServerConfig.parse(JSON.parse(raw));
}
export function writeMcpConfig(value: z.infer<typeof McpServerConfig>): void {
const p = mcpConfigPath();
const parsed = McpServerConfig.parse(value);
fs.writeFileSync(p, JSON.stringify(parsed, null, 2) + "\n", "utf8");
}