diff --git a/gitnexus/src/core/group/service.ts b/gitnexus/src/core/group/service.ts index c18587ce2..f1356dcec 100644 --- a/gitnexus/src/core/group/service.ts +++ b/gitnexus/src/core/group/service.ts @@ -14,7 +14,10 @@ import { repoInSubgroup, } from './group-path-utils.js'; import { getDefaultGitnexusDir, getGroupDir, listGroups, readContractRegistry } from './storage.js'; -import { syncGroup } from './sync.js'; +// `./sync.js` is imported LAZILY in `groupSync` — see the comment at its call +// site. It statically pulls the six contract extractors and, through them, the +// native tree-sitter binding; a static import here puts all of that on MCP +// server startup, which never syncs. import { logger } from '../logger.js'; import type { ContractRegistry, @@ -338,6 +341,12 @@ export class GroupService { return { error: `Group "${name}" not found. Run group_list to see configured groups.` }; throw err; } + // Lazy: `sync.js` reaches the six contract extractors and the native + // tree-sitter binding. `groupSync` is the ONLY consumer — the other seven + // group tools never need it — so deferring it here keeps that closure off + // MCP server startup entirely and off every non-sync group call. The CLI + // already does exactly this at `cli/group.ts`'s sync command. + const { syncGroup } = await import('./sync.js'); const result = await syncGroup(config, { groupDir, exactOnly: Boolean(params.exactOnly),