src / index.ts
import { PluginContext } from "@lmstudio/sdk";
import { spawn } from "child_process";
import fs from "fs";
import path from "path";
import { toolsProvider } from "./toolsProvider";
import { configSchematics } from "./config";
export async function main(context: PluginContext) {
const pluginRoot = path.resolve(__dirname, "..");
const setupScript = path.join(pluginRoot, "scripts", "setup.js");
const venvDir = path.join(pluginRoot, "venv");
const mcpDir = path.join(pluginRoot, "sec-edgar-mcp");
if (!fs.existsSync(venvDir) || !fs.existsSync(mcpDir)) {
try {
console.log("Setting up sec-edgar-mcp environment asynchronously...");
await new Promise<void>((resolve, reject) => {
const child = spawn("node", [setupScript], { stdio: "inherit" });
child.on("close", (code) => {
if (code === 0) resolve();
else reject(new Error(`Setup failed with code ${code}`));
});
});
console.log("Setup complete.");
} catch (e) {
console.error("Setup failed:", e);
}
}
context.withToolsProvider(toolsProvider);
context.withConfigSchematics(configSchematics);
}src / index.ts
import { PluginContext } from "@lmstudio/sdk";
import { spawn } from "child_process";
import fs from "fs";
import path from "path";
import { toolsProvider } from "./toolsProvider";
import { configSchematics } from "./config";
export async function main(context: PluginContext) {
const pluginRoot = path.resolve(__dirname, "..");
const setupScript = path.join(pluginRoot, "scripts", "setup.js");
const venvDir = path.join(pluginRoot, "venv");
const mcpDir = path.join(pluginRoot, "sec-edgar-mcp");
if (!fs.existsSync(venvDir) || !fs.existsSync(mcpDir)) {
try {
console.log("Setting up sec-edgar-mcp environment asynchronously...");
await new Promise<void>((resolve, reject) => {
const child = spawn("node", [setupScript], { stdio: "inherit" });
child.on("close", (code) => {
if (code === 0) resolve();
else reject(new Error(`Setup failed with code ${code}`));
});
});
console.log("Setup complete.");
} catch (e) {
console.error("Setup failed:", e);
}
}
context.withToolsProvider(toolsProvider);
context.withConfigSchematics(configSchematics);
}