1
0

probe-trace.mjs 895 B

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