Graphs that teach > graphs that impress. Turn any code into an interactive knowledge graph you can explore, search, and ask questions about. Works with Claude Code, Codex, Cursor, Copilot, Gemini CLI, and more.
TypeScript antigravity-skillsbusiness-knowledgeclaude-codeclaude-skillscodebase-analysiscodexcodex-skillsdeveloper-tools-ai-agentgemini-cli-skillskarpathy-llm-wikiknowledge-baseknowledge-graphmemoryopencode-skillspi-agentunderstandcodevibe-coding
fix(graph): accept data-file coverage nodes
Lum11048640eb43eb24
diff --git a/tests/skill/understand/test_prepare_incremental.test.mjs b/tests/skill/understand/test_prepare_incremental.test.mjsindex d1e14566..4b63d3be 100644--- a/tests/skill/understand/test_prepare_incremental.test.mjs+++ b/tests/skill/understand/test_prepare_incremental.test.mjs@@ -729,6 +729,49 @@ describe('finalize-incremental.mjs', { timeout: 30_000 }, () => {expect(readFileSync(metaPath, 'utf-8')).toBe(metaBefore);});+ it.each([+ ['table', 'db/schema.sql', 'users'],+ ['endpoint', 'api/openapi.yaml', 'GET-users'],+ ])('accepts a valid %s node as analyzed-file coverage', (nodeType, changedPath, name) => {+ const initialContent = nodeType === 'table'+ ? 'CREATE TABLE users (id INT);\n'+ : 'openapi: 3.0.0\npaths: {}\n';+ const changedContent = nodeType === 'table'+ ? 'CREATE TABLE users (id INT, name TEXT);\n'+ : 'openapi: 3.0.0\npaths:\n /users: {}\n';+ const { root, baseCommit } = setupRepository({+ 'src/a.ts': 'export const a = 1;\n',+ 'src/b.ts': 'export const b = 2;\n',+ 'src/c.ts': 'export const c = 3;\n',+ [changedPath]: initialContent,+ });+ writeProjectFile(root, changedPath, changedContent);+ const headCommit = commit(root, `change ${nodeType} file`);+ prepare(root, baseCommit);++ const intermediate = join(root, '.ua', 'intermediate');+ const retained = JSON.parse(readFileSync(join(intermediate, 'batch-existing.json'), 'utf-8'));+ const analyzedNode = {+ id: `${nodeType}:${changedPath}:${name}`,+ type: nodeType,+ name,+ filePath: changedPath,+ summary: `${nodeType} definition`,+ tags: [nodeType],+ complexity: 'simple',+ };+ writeFileSync(+ join(intermediate, 'assembled-graph.json'),+ JSON.stringify({ nodes: [...retained.nodes, analyzedNode], edges: retained.edges }),+ 'utf-8',+ );+ run(process.execPath, [finalizeScript, root], root);++ const graph = JSON.parse(readFileSync(join(root, '.ua', 'knowledge-graph.json'), 'utf-8'));+ expect(graph.project.gitCommitHash).toBe(headCommit);+ expect(graph.nodes).toContainEqual(expect.objectContaining({ id: analyzedNode.id }));+ });+it('adds a newly introduced language to graph project metadata', () => {const { root, baseCommit } = setupRepository({'src/a.ts': 'export const a = 1;\n',diff --git a/understand-anything-plugin/skills/understand/finalize-incremental.mjs b/understand-anything-plugin/skills/understand/finalize-incremental.mjsindex 9902b789..1ef96489 100644--- a/understand-anything-plugin/skills/understand/finalize-incremental.mjs+++ b/understand-anything-plugin/skills/understand/finalize-incremental.mjs@@ -104,6 +104,18 @@ function buildPathIndex(nodes) {return index;}+function hasAnalyzedFileCoverage(nodes, filePath) {+ return nodes.some(node => {+ const path = normalizeRelativePath(node.filePath);+ if (path !== filePath || typeof node.id !== 'string') return false;+ if (WHOLE_FILE_TYPES.has(node.type)) return node.id === `${node.type}:${filePath}`;+ if (node.type === 'table' || node.type === 'endpoint') {+ return node.id.startsWith(`${node.type}:${filePath}:`);+ }+ return false;+ });+}+function resolveNodeRef(value, nodeIds, pathIndex) {if (typeof value === 'object' && value) value = value.id;if (typeof value !== 'string' || !value) return null;@@ -420,7 +432,9 @@ function main() {);const nodeIds = new Set(assembled.nodes.map(node => node.id));const pathIndex = buildPathIndex(assembled.nodes);- const missingAnalyzedPaths = plan.filesToReanalyze.filter(path => !pathIndex.has(path));+ const missingAnalyzedPaths = plan.filesToReanalyze.filter(+ path => !hasAnalyzedFileCoverage(assembled.nodes, path),+ );if (missingAnalyzedPaths.length > 0) {throw new Error(`Assembled graph is missing whole-file nodes for analyzed paths: ` +@@ -483,4 +497,10 @@ if (isCliEntry()) {}}-export { assignLayers, commonParentDepth, normalizeTour, refreshGraphImports };+export {+ assignLayers,+ commonParentDepth,+ hasAnalyzedFileCoverage,+ normalizeTour,+ refreshGraphImports,+};