From 101bc58795a4036fcb7406911957629df254cea2 Mon Sep 17 00:00:00 2001 From: Lex Christopherson Date: Tue, 20 Jan 2026 09:59:01 -0600 Subject: [PATCH] feat(04-02): integrate graph summary into regeneration flow - regenerateEntitySummary() now async, prefers graph when available - Falls back to entity-file-based summary if no graph.db - Stdin handler properly awaits async regeneration - SessionStart hook injects graph-backed summary into context Co-Authored-By: Claude Opus 4.5 --- hooks/gsd-intel-index.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/hooks/gsd-intel-index.js b/hooks/gsd-intel-index.js index bc167d633..7a2466a11 100755 --- a/hooks/gsd-intel-index.js +++ b/hooks/gsd-intel-index.js @@ -718,12 +718,23 @@ async function syncEntityToGraph(entityPath) { /** * Regenerate summary.md from all entity files * Creates a semantic overview of the codebase + * Prefers graph-backed summary when graph.db exists */ -function regenerateEntitySummary() { +async function regenerateEntitySummary() { const intelDir = path.join(process.cwd(), '.planning', 'intel'); const entitiesDir = path.join(intelDir, 'entities'); const summaryPath = path.join(intelDir, 'summary.md'); + const dbPath = path.join(intelDir, 'graph.db'); + // Try graph-backed summary first (preferred when graph.db exists) + if (fs.existsSync(dbPath)) { + const graphSummary = await generateGraphSummary(); + if (graphSummary) { + return; // Graph summary written successfully + } + } + + // Fallback: entity-file-based summary // Check directories exist if (!fs.existsSync(entitiesDir)) { return; @@ -932,8 +943,8 @@ process.stdin.on('end', () => { // Handle entity file writes - sync to graph, regenerate summary if (isEntityFile(filePath)) { - syncEntityToGraph(filePath).then(() => { - regenerateEntitySummary(); + syncEntityToGraph(filePath).then(async () => { + await regenerateEntitySummary(); process.exit(0); }).catch(() => { // Silent failure