|
| 1 | +// blueprint_scene tool: a laid-out nodes/edges graph of how a repo is built — |
| 2 | +// ready for a <DependencyGraph>-style component. |
| 3 | +// |
| 4 | +// Pipeline (extension modules, verbatim): fetchRepoData + fetchSource -> |
| 5 | +// atoms prompt/parse -> lineage prompt/parse -> buildBlueprintScene. Two model |
| 6 | +// calls (atoms, then lineage); the optional "feynman" plain-English layer is |
| 7 | +// skipped since the scene only needs atoms + lineage. `facts` is null here — |
| 8 | +// the extension's local "runner" (measured metrics) isn't part of a headless MCP. |
| 9 | + |
| 10 | +import { fetchRepoData } from '../fetcher.js'; |
| 11 | +import { fetchSource, buildAtomsPrompt, parseAtoms, buildLineagePrompt, parseLineage } from '../deepdive.js'; |
| 12 | +import { buildBlueprintScene } from '../blueprint-adapter.js'; |
| 13 | +import { parseRepoInput } from './repo-input.js'; |
| 14 | +import { callAnthropic } from './anthropic.js'; |
| 15 | + |
| 16 | +export const BLUEPRINT_TOOL = { |
| 17 | + name: 'blueprint_scene', |
| 18 | + description: |
| 19 | + 'Map how a GitHub repo is built and return a laid-out graph: nodes (its key parts) and ' + |
| 20 | + 'edges (how they relate), with positions. Use this to visualize a repository as a ' + |
| 21 | + 'dependency / architecture diagram. Heavier than scan_repo (reads source, two model calls).', |
| 22 | + inputSchema: { |
| 23 | + type: 'object', |
| 24 | + properties: { repo: { type: 'string', description: 'A repo as owner/name or a GitHub URL' } }, |
| 25 | + required: ['repo'], |
| 26 | + additionalProperties: false, |
| 27 | + }, |
| 28 | + outputSchema: { |
| 29 | + type: 'object', |
| 30 | + properties: { |
| 31 | + id: { type: 'string' }, |
| 32 | + scope: { type: 'string' }, |
| 33 | + repoId: { type: 'string' }, |
| 34 | + title: { type: 'string' }, |
| 35 | + nodes: { |
| 36 | + type: 'array', |
| 37 | + items: { |
| 38 | + type: 'object', |
| 39 | + properties: { |
| 40 | + id: { type: 'string' }, |
| 41 | + label: { type: 'string' }, |
| 42 | + kind: { type: 'string' }, |
| 43 | + x: { type: 'number' }, |
| 44 | + y: { type: 'number' }, |
| 45 | + }, |
| 46 | + }, |
| 47 | + }, |
| 48 | + edges: { |
| 49 | + type: 'array', |
| 50 | + items: { |
| 51 | + type: 'object', |
| 52 | + properties: { |
| 53 | + source: { type: 'string' }, |
| 54 | + target: { type: 'string' }, |
| 55 | + label: { type: 'string' }, |
| 56 | + }, |
| 57 | + }, |
| 58 | + }, |
| 59 | + camera: { type: 'object' }, |
| 60 | + }, |
| 61 | + required: ['nodes', 'edges'], |
| 62 | + }, |
| 63 | +}; |
| 64 | + |
| 65 | +export async function runBlueprintScene(args) { |
| 66 | + const { platform, repoId } = parseRepoInput(args?.repo); |
| 67 | + const repoData = await fetchRepoData(platform, repoId); |
| 68 | + const source = await fetchSource(platform, repoId); |
| 69 | + const { atoms } = parseAtoms(await callAnthropic(buildAtomsPrompt(repoData, source, null))); |
| 70 | + const lineage = parseLineage(await callAnthropic(buildLineagePrompt(atoms))); |
| 71 | + return buildBlueprintScene({ deepDive: { atoms, lineage }, repoId, title: repoId }); |
| 72 | +} |
0 commit comments