From f9134f1882f1a1022a9160ede6d084e7776449e2 Mon Sep 17 00:00:00 2001 From: sahalterion Date: Fri, 17 Apr 2026 19:52:53 -0700 Subject: [PATCH] fix(group): address senior review feedback - Add CROSS_REPO_IMPORT to RelationshipType so api.ts cast typechecks. - Wire actual recursion into findConnections so groupGraph depth > 1 traverses transitive cross-links instead of silently stopping at 1. - Drop shadowing dynamic imports in groupStatus; use the module-level fsp/path already in scope. - Switch import-scanner to fs.promises.readFile so file reads no longer block the event loop inside the async scanner. - Extend group_discover MCP schema with repoPaths so the explicit-path mode is reachable via MCP (was CLI-only). Co-Authored-By: Claude Opus 4.7 (1M context) --- gitnexus-shared/src/graph/types.ts | 3 ++- .../src/core/group/extractors/import-scanner.ts | 2 +- gitnexus/src/core/group/service.ts | 4 ++++ gitnexus/src/mcp/tools.ts | 13 +++++++++---- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/gitnexus-shared/src/graph/types.ts b/gitnexus-shared/src/graph/types.ts index d3dc81625..2c85fd030 100644 --- a/gitnexus-shared/src/graph/types.ts +++ b/gitnexus-shared/src/graph/types.ts @@ -115,7 +115,8 @@ export type RelationshipType = | 'HANDLES_TOOL' | 'ENTRY_POINT_OF' | 'WRAPS' - | 'QUERIES'; + | 'QUERIES' + | 'CROSS_REPO_IMPORT'; export interface GraphNode { id: string; diff --git a/gitnexus/src/core/group/extractors/import-scanner.ts b/gitnexus/src/core/group/extractors/import-scanner.ts index c6c460712..2bac8de42 100644 --- a/gitnexus/src/core/group/extractors/import-scanner.ts +++ b/gitnexus/src/core/group/extractors/import-scanner.ts @@ -159,7 +159,7 @@ export async function scanRepoForImports( let content: string; try { - content = fs.readFileSync(abs, 'utf-8'); + content = await fs.promises.readFile(abs, 'utf-8'); } catch { continue; } diff --git a/gitnexus/src/core/group/service.ts b/gitnexus/src/core/group/service.ts index 55b379d5f..c371ff41c 100644 --- a/gitnexus/src/core/group/service.ts +++ b/gitnexus/src/core/group/service.ts @@ -638,6 +638,10 @@ export class GroupService { remoteRepo: remoteRepoGroupPath, remoteContext, }); + + // Recurse into the remote repo so depth > 1 actually traverses further. + // `visited` (closed over above) prevents cycles. + await findConnections(remoteRegistryName, currentDepth + 1); } }; diff --git a/gitnexus/src/mcp/tools.ts b/gitnexus/src/mcp/tools.ts index 917ee3fbf..255948c0b 100644 --- a/gitnexus/src/mcp/tools.ts +++ b/gitnexus/src/mcp/tools.ts @@ -576,18 +576,23 @@ WHEN TO USE: After group_sync, to explore how a symbol in one repo connects to s }, { name: 'group_discover', - description: `Auto-discover indexed repos in a directory and create a group with code-level dependency detection. + description: `Auto-discover indexed repos in a directory (or from an explicit list) and create a group with code-level dependency detection. -WHEN TO USE: When a user wants to see a combined knowledge graph from a parent directory containing multiple indexed repos. Scans for .gitnexus/ in subdirectories, reads package manifests, builds package mappings, creates a group, and optionally runs sync.`, +WHEN TO USE: When a user wants to see a combined knowledge graph from multiple indexed repos. Reads package manifests, builds package mappings, creates a group, and optionally runs sync. Provide either \`directory\` (parent-dir scan) or \`repoPaths\` (explicit list).`, inputSchema: { type: 'object', properties: { - directory: { type: 'string', description: 'Parent directory containing repos' }, + directory: { type: 'string', description: 'Parent directory containing repos (alternative to repoPaths)' }, + repoPaths: { + type: 'array', + items: { type: 'string' }, + description: 'Explicit list of repo paths (alternative to directory scan)', + }, name: { type: 'string', description: 'Group name (default: workspace)' }, force: { type: 'boolean', description: 'Overwrite existing group' }, skipSync: { type: 'boolean', description: 'Skip running sync after creation' }, }, - required: ['directory'], + required: [], }, }, ];