1
0

probe-context.mjs 950 B

123456789101112131415161718192021
  1. #!/usr/bin/env node
  2. // Probe codegraph_context (with call-paths) against an index using the built dist.
  3. // Usage: node probe-context.mjs <repo-with-.codegraph> <task words...>
  4. import { pathToFileURL } from 'node:url';
  5. import { resolve } from 'node:path';
  6. const [, , repo, ...taskParts] = process.argv;
  7. const task = taskParts.join(' ');
  8. if (!repo || !task) { console.error('usage: probe-context.mjs <repo> <task...>'); process.exit(1); }
  9. const load = async (rel) => import(pathToFileURL(resolve(rel)).href);
  10. const idx = await load('dist/index.js');
  11. const tools = await load('dist/mcp/tools.js');
  12. const CodeGraph = idx.default?.default ?? idx.default ?? idx.CodeGraph;
  13. const ToolHandler = tools.ToolHandler ?? tools.default?.ToolHandler;
  14. const cg = CodeGraph.openSync(repo);
  15. const h = new ToolHandler(cg);
  16. const res = await h.execute('codegraph_context', { task });
  17. console.log(res.content?.[0]?.text ?? '(no text)');
  18. try { cg.close?.(); } catch {}