MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / buildProject

Function buildProject

__tests__/explore-allocation-e2e.test.ts:60–70  ·  view source on GitHub ↗

Build + index a throwaway project from a `{ relPath: source }` map.

(prefix: string, files: Record<string, string>)

Source from the content-addressed store, hash-verified

58
59/** Build + index a throwaway project from a `{ relPath: source }` map. */
60async function buildProject(prefix: string, files: Record<string, string>): Promise<Project> {
61 const dir = fs.mkdtempSync(path.join(os.tmpdir(), prefix));
62 for (const [rel, body] of Object.entries(files)) {
63 const abs = path.join(dir, rel);
64 fs.mkdirSync(path.dirname(abs), { recursive: true });
65 fs.writeFileSync(abs, body.trimStart());
66 }
67 const cg = CodeGraph.initSync(dir);
68 await cg.indexAll();
69 return { dir, cg, handler: new ToolHandler(cg) };
70}
71
72function destroyProject(project?: Project): void {
73 if (!project) return;

Callers 1

Calls 3

initSyncMethod · 0.80
joinMethod · 0.45
indexAllMethod · 0.45

Tested by

no test coverage detected