gitnexus 1.4.1 → 1.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/README.md +215 -194
  2. package/dist/cli/ai-context.d.ts +2 -1
  3. package/dist/cli/ai-context.js +117 -90
  4. package/dist/cli/analyze.d.ts +2 -0
  5. package/dist/cli/analyze.js +57 -30
  6. package/dist/cli/augment.js +1 -1
  7. package/dist/cli/eval-server.d.ts +1 -1
  8. package/dist/cli/eval-server.js +14 -6
  9. package/dist/cli/index.js +18 -25
  10. package/dist/cli/lazy-action.d.ts +6 -0
  11. package/dist/cli/lazy-action.js +18 -0
  12. package/dist/cli/mcp.js +1 -1
  13. package/dist/cli/setup.js +42 -32
  14. package/dist/cli/skill-gen.d.ts +26 -0
  15. package/dist/cli/skill-gen.js +549 -0
  16. package/dist/cli/status.js +13 -4
  17. package/dist/cli/tool.d.ts +3 -2
  18. package/dist/cli/tool.js +48 -13
  19. package/dist/cli/wiki.js +2 -2
  20. package/dist/config/ignore-service.d.ts +25 -0
  21. package/dist/config/ignore-service.js +76 -0
  22. package/dist/config/supported-languages.d.ts +1 -0
  23. package/dist/config/supported-languages.js +1 -1
  24. package/dist/core/augmentation/engine.js +99 -72
  25. package/dist/core/embeddings/embedder.d.ts +1 -1
  26. package/dist/core/embeddings/embedder.js +1 -1
  27. package/dist/core/embeddings/embedding-pipeline.d.ts +3 -3
  28. package/dist/core/embeddings/embedding-pipeline.js +74 -47
  29. package/dist/core/embeddings/types.d.ts +1 -1
  30. package/dist/core/graph/types.d.ts +5 -2
  31. package/dist/core/ingestion/ast-cache.js +3 -2
  32. package/dist/core/ingestion/call-processor.d.ts +5 -7
  33. package/dist/core/ingestion/call-processor.js +430 -283
  34. package/dist/core/ingestion/call-routing.d.ts +53 -0
  35. package/dist/core/ingestion/call-routing.js +108 -0
  36. package/dist/core/ingestion/cluster-enricher.js +16 -16
  37. package/dist/core/ingestion/constants.d.ts +16 -0
  38. package/dist/core/ingestion/constants.js +16 -0
  39. package/dist/core/ingestion/entry-point-scoring.d.ts +2 -1
  40. package/dist/core/ingestion/entry-point-scoring.js +94 -24
  41. package/dist/core/ingestion/export-detection.d.ts +18 -0
  42. package/dist/core/ingestion/export-detection.js +231 -0
  43. package/dist/core/ingestion/filesystem-walker.js +4 -3
  44. package/dist/core/ingestion/framework-detection.d.ts +5 -1
  45. package/dist/core/ingestion/framework-detection.js +48 -8
  46. package/dist/core/ingestion/heritage-processor.d.ts +13 -5
  47. package/dist/core/ingestion/heritage-processor.js +109 -55
  48. package/dist/core/ingestion/import-processor.d.ts +16 -20
  49. package/dist/core/ingestion/import-processor.js +202 -696
  50. package/dist/core/ingestion/language-config.d.ts +46 -0
  51. package/dist/core/ingestion/language-config.js +167 -0
  52. package/dist/core/ingestion/mro-processor.d.ts +45 -0
  53. package/dist/core/ingestion/mro-processor.js +369 -0
  54. package/dist/core/ingestion/named-binding-extraction.d.ts +61 -0
  55. package/dist/core/ingestion/named-binding-extraction.js +363 -0
  56. package/dist/core/ingestion/parsing-processor.d.ts +3 -11
  57. package/dist/core/ingestion/parsing-processor.js +85 -181
  58. package/dist/core/ingestion/pipeline.d.ts +5 -1
  59. package/dist/core/ingestion/pipeline.js +192 -116
  60. package/dist/core/ingestion/process-processor.js +2 -1
  61. package/dist/core/ingestion/resolution-context.d.ts +53 -0
  62. package/dist/core/ingestion/resolution-context.js +132 -0
  63. package/dist/core/ingestion/resolvers/csharp.d.ts +22 -0
  64. package/dist/core/ingestion/resolvers/csharp.js +109 -0
  65. package/dist/core/ingestion/resolvers/go.d.ts +19 -0
  66. package/dist/core/ingestion/resolvers/go.js +42 -0
  67. package/dist/core/ingestion/resolvers/index.d.ts +18 -0
  68. package/dist/core/ingestion/resolvers/index.js +13 -0
  69. package/dist/core/ingestion/resolvers/jvm.d.ts +23 -0
  70. package/dist/core/ingestion/resolvers/jvm.js +87 -0
  71. package/dist/core/ingestion/resolvers/php.d.ts +15 -0
  72. package/dist/core/ingestion/resolvers/php.js +35 -0
  73. package/dist/core/ingestion/resolvers/python.d.ts +19 -0
  74. package/dist/core/ingestion/resolvers/python.js +52 -0
  75. package/dist/core/ingestion/resolvers/ruby.d.ts +12 -0
  76. package/dist/core/ingestion/resolvers/ruby.js +15 -0
  77. package/dist/core/ingestion/resolvers/rust.d.ts +15 -0
  78. package/dist/core/ingestion/resolvers/rust.js +73 -0
  79. package/dist/core/ingestion/resolvers/standard.d.ts +28 -0
  80. package/dist/core/ingestion/resolvers/standard.js +123 -0
  81. package/dist/core/ingestion/resolvers/utils.d.ts +33 -0
  82. package/dist/core/ingestion/resolvers/utils.js +122 -0
  83. package/dist/core/ingestion/symbol-table.d.ts +21 -1
  84. package/dist/core/ingestion/symbol-table.js +40 -12
  85. package/dist/core/ingestion/tree-sitter-queries.d.ts +12 -11
  86. package/dist/core/ingestion/tree-sitter-queries.js +642 -485
  87. package/dist/core/ingestion/type-env.d.ts +49 -0
  88. package/dist/core/ingestion/type-env.js +611 -0
  89. package/dist/core/ingestion/type-extractors/c-cpp.d.ts +2 -0
  90. package/dist/core/ingestion/type-extractors/c-cpp.js +385 -0
  91. package/dist/core/ingestion/type-extractors/csharp.d.ts +2 -0
  92. package/dist/core/ingestion/type-extractors/csharp.js +383 -0
  93. package/dist/core/ingestion/type-extractors/go.d.ts +2 -0
  94. package/dist/core/ingestion/type-extractors/go.js +467 -0
  95. package/dist/core/ingestion/type-extractors/index.d.ts +22 -0
  96. package/dist/core/ingestion/type-extractors/index.js +31 -0
  97. package/dist/core/ingestion/type-extractors/jvm.d.ts +3 -0
  98. package/dist/core/ingestion/type-extractors/jvm.js +681 -0
  99. package/dist/core/ingestion/type-extractors/php.d.ts +2 -0
  100. package/dist/core/ingestion/type-extractors/php.js +549 -0
  101. package/dist/core/ingestion/type-extractors/python.d.ts +2 -0
  102. package/dist/core/ingestion/type-extractors/python.js +406 -0
  103. package/dist/core/ingestion/type-extractors/ruby.d.ts +2 -0
  104. package/dist/core/ingestion/type-extractors/ruby.js +389 -0
  105. package/dist/core/ingestion/type-extractors/rust.d.ts +2 -0
  106. package/dist/core/ingestion/type-extractors/rust.js +449 -0
  107. package/dist/core/ingestion/type-extractors/shared.d.ts +133 -0
  108. package/dist/core/ingestion/type-extractors/shared.js +703 -0
  109. package/dist/core/ingestion/type-extractors/swift.d.ts +2 -0
  110. package/dist/core/ingestion/type-extractors/swift.js +137 -0
  111. package/dist/core/ingestion/type-extractors/types.d.ts +127 -0
  112. package/dist/core/ingestion/type-extractors/types.js +1 -0
  113. package/dist/core/ingestion/type-extractors/typescript.d.ts +2 -0
  114. package/dist/core/ingestion/type-extractors/typescript.js +494 -0
  115. package/dist/core/ingestion/utils.d.ts +98 -0
  116. package/dist/core/ingestion/utils.js +1064 -9
  117. package/dist/core/ingestion/workers/parse-worker.d.ts +38 -4
  118. package/dist/core/ingestion/workers/parse-worker.js +251 -359
  119. package/dist/core/ingestion/workers/worker-pool.js +8 -0
  120. package/dist/core/{kuzu → lbug}/csv-generator.d.ts +1 -1
  121. package/dist/core/{kuzu → lbug}/csv-generator.js +20 -4
  122. package/dist/core/{kuzu/kuzu-adapter.d.ts → lbug/lbug-adapter.d.ts} +19 -19
  123. package/dist/core/{kuzu/kuzu-adapter.js → lbug/lbug-adapter.js} +82 -82
  124. package/dist/core/{kuzu → lbug}/schema.d.ts +4 -4
  125. package/dist/core/{kuzu → lbug}/schema.js +304 -289
  126. package/dist/core/search/bm25-index.d.ts +4 -4
  127. package/dist/core/search/bm25-index.js +17 -16
  128. package/dist/core/search/hybrid-search.d.ts +2 -2
  129. package/dist/core/search/hybrid-search.js +9 -9
  130. package/dist/core/tree-sitter/parser-loader.js +9 -2
  131. package/dist/core/wiki/generator.d.ts +4 -52
  132. package/dist/core/wiki/generator.js +53 -552
  133. package/dist/core/wiki/graph-queries.d.ts +4 -46
  134. package/dist/core/wiki/graph-queries.js +103 -282
  135. package/dist/core/wiki/html-viewer.js +192 -192
  136. package/dist/core/wiki/llm-client.js +11 -73
  137. package/dist/core/wiki/prompts.d.ts +8 -52
  138. package/dist/core/wiki/prompts.js +86 -200
  139. package/dist/mcp/compatible-stdio-transport.d.ts +25 -0
  140. package/dist/mcp/compatible-stdio-transport.js +200 -0
  141. package/dist/mcp/core/{kuzu-adapter.d.ts → lbug-adapter.d.ts} +7 -9
  142. package/dist/mcp/core/{kuzu-adapter.js → lbug-adapter.js} +77 -79
  143. package/dist/mcp/local/local-backend.d.ts +7 -6
  144. package/dist/mcp/local/local-backend.js +176 -147
  145. package/dist/mcp/resources.js +42 -42
  146. package/dist/mcp/server.js +18 -19
  147. package/dist/mcp/tools.js +103 -104
  148. package/dist/server/api.js +12 -12
  149. package/dist/server/mcp-http.d.ts +1 -1
  150. package/dist/server/mcp-http.js +1 -1
  151. package/dist/storage/repo-manager.d.ts +20 -2
  152. package/dist/storage/repo-manager.js +55 -1
  153. package/dist/types/pipeline.d.ts +1 -1
  154. package/hooks/claude/gitnexus-hook.cjs +238 -155
  155. package/hooks/claude/pre-tool-use.sh +79 -79
  156. package/hooks/claude/session-start.sh +42 -42
  157. package/package.json +99 -96
  158. package/scripts/patch-tree-sitter-swift.cjs +74 -74
  159. package/skills/gitnexus-cli.md +82 -82
  160. package/skills/gitnexus-debugging.md +89 -89
  161. package/skills/gitnexus-exploring.md +78 -78
  162. package/skills/gitnexus-guide.md +64 -64
  163. package/skills/gitnexus-impact-analysis.md +97 -97
  164. package/skills/gitnexus-pr-review.md +163 -163
  165. package/skills/gitnexus-refactoring.md +121 -121
  166. package/vendor/leiden/index.cjs +355 -355
  167. package/vendor/leiden/utils.cjs +392 -392
  168. package/dist/core/wiki/diagrams.d.ts +0 -27
  169. package/dist/core/wiki/diagrams.js +0 -163
package/dist/cli/index.js CHANGED
@@ -2,18 +2,8 @@
2
2
  // Heap re-spawn removed — only analyze.ts needs the 8GB heap (via its own ensureHeap()).
3
3
  // Removing it from here improves MCP server startup time significantly.
4
4
  import { Command } from 'commander';
5
- import { analyzeCommand } from './analyze.js';
6
- import { serveCommand } from './serve.js';
7
- import { listCommand } from './list.js';
8
- import { statusCommand } from './status.js';
9
- import { mcpCommand } from './mcp.js';
10
- import { cleanCommand } from './clean.js';
11
- import { setupCommand } from './setup.js';
12
- import { augmentCommand } from './augment.js';
13
- import { wikiCommand } from './wiki.js';
14
- import { queryCommand, contextCommand, impactCommand, cypherCommand } from './tool.js';
15
- import { evalServerCommand } from './eval-server.js';
16
5
  import { createRequire } from 'node:module';
6
+ import { createLazyAction } from './lazy-action.js';
17
7
  const _require = createRequire(import.meta.url);
18
8
  const pkg = _require('../../package.json');
19
9
  const program = new Command();
@@ -24,37 +14,40 @@ program
24
14
  program
25
15
  .command('setup')
26
16
  .description('One-time setup: configure MCP for Cursor, Claude Code, OpenCode')
27
- .action(setupCommand);
17
+ .action(createLazyAction(() => import('./setup.js'), 'setupCommand'));
28
18
  program
29
19
  .command('analyze [path]')
30
20
  .description('Index a repository (full analysis)')
31
21
  .option('-f, --force', 'Force full re-index even if up to date')
32
22
  .option('--embeddings', 'Enable embedding generation for semantic search (off by default)')
33
- .action(analyzeCommand);
23
+ .option('--skills', 'Generate repo-specific skill files from detected communities')
24
+ .option('-v, --verbose', 'Enable verbose ingestion warnings (default: false)')
25
+ .addHelpText('after', '\nEnvironment variables:\n GITNEXUS_NO_GITIGNORE=1 Skip .gitignore parsing (still reads .gitnexusignore)')
26
+ .action(createLazyAction(() => import('./analyze.js'), 'analyzeCommand'));
34
27
  program
35
28
  .command('serve')
36
29
  .description('Start local HTTP server for web UI connection')
37
30
  .option('-p, --port <port>', 'Port number', '4747')
38
31
  .option('--host <host>', 'Bind address (default: 127.0.0.1, use 0.0.0.0 for remote access)')
39
- .action(serveCommand);
32
+ .action(createLazyAction(() => import('./serve.js'), 'serveCommand'));
40
33
  program
41
34
  .command('mcp')
42
35
  .description('Start MCP server (stdio) — serves all indexed repos')
43
- .action(mcpCommand);
36
+ .action(createLazyAction(() => import('./mcp.js'), 'mcpCommand'));
44
37
  program
45
38
  .command('list')
46
39
  .description('List all indexed repositories')
47
- .action(listCommand);
40
+ .action(createLazyAction(() => import('./list.js'), 'listCommand'));
48
41
  program
49
42
  .command('status')
50
43
  .description('Show index status for current repo')
51
- .action(statusCommand);
44
+ .action(createLazyAction(() => import('./status.js'), 'statusCommand'));
52
45
  program
53
46
  .command('clean')
54
47
  .description('Delete GitNexus index for current repo')
55
48
  .option('-f, --force', 'Skip confirmation prompt')
56
49
  .option('--all', 'Clean all indexed repos')
57
- .action(cleanCommand);
50
+ .action(createLazyAction(() => import('./clean.js'), 'cleanCommand'));
58
51
  program
59
52
  .command('wiki [path]')
60
53
  .description('Generate repository wiki from knowledge graph')
@@ -64,11 +57,11 @@ program
64
57
  .option('--api-key <key>', 'LLM API key (saved to ~/.gitnexus/config.json)')
65
58
  .option('--concurrency <n>', 'Parallel LLM calls (default: 3)', '3')
66
59
  .option('--gist', 'Publish wiki as a public GitHub Gist after generation')
67
- .action(wikiCommand);
60
+ .action(createLazyAction(() => import('./wiki.js'), 'wikiCommand'));
68
61
  program
69
62
  .command('augment <pattern>')
70
63
  .description('Augment a search pattern with knowledge graph context (used by hooks)')
71
- .action(augmentCommand);
64
+ .action(createLazyAction(() => import('./augment.js'), 'augmentCommand'));
72
65
  // ─── Direct Tool Commands (no MCP overhead) ────────────────────────
73
66
  // These invoke LocalBackend directly for use in eval, scripts, and CI.
74
67
  program
@@ -79,7 +72,7 @@ program
79
72
  .option('-g, --goal <text>', 'What you want to find')
80
73
  .option('-l, --limit <n>', 'Max processes to return (default: 5)')
81
74
  .option('--content', 'Include full symbol source code')
82
- .action(queryCommand);
75
+ .action(createLazyAction(() => import('./tool.js'), 'queryCommand'));
83
76
  program
84
77
  .command('context [name]')
85
78
  .description('360-degree view of a code symbol: callers, callees, processes')
@@ -87,7 +80,7 @@ program
87
80
  .option('-u, --uid <uid>', 'Direct symbol UID (zero-ambiguity lookup)')
88
81
  .option('-f, --file <path>', 'File path to disambiguate common names')
89
82
  .option('--content', 'Include full symbol source code')
90
- .action(contextCommand);
83
+ .action(createLazyAction(() => import('./tool.js'), 'contextCommand'));
91
84
  program
92
85
  .command('impact <target>')
93
86
  .description('Blast radius analysis: what breaks if you change a symbol')
@@ -95,17 +88,17 @@ program
95
88
  .option('-r, --repo <name>', 'Target repository')
96
89
  .option('--depth <n>', 'Max relationship depth (default: 3)')
97
90
  .option('--include-tests', 'Include test files in results')
98
- .action(impactCommand);
91
+ .action(createLazyAction(() => import('./tool.js'), 'impactCommand'));
99
92
  program
100
93
  .command('cypher <query>')
101
94
  .description('Execute raw Cypher query against the knowledge graph')
102
95
  .option('-r, --repo <name>', 'Target repository')
103
- .action(cypherCommand);
96
+ .action(createLazyAction(() => import('./tool.js'), 'cypherCommand'));
104
97
  // ─── Eval Server (persistent daemon for SWE-bench) ─────────────────
105
98
  program
106
99
  .command('eval-server')
107
100
  .description('Start lightweight HTTP server for fast tool calls during evaluation')
108
101
  .option('-p, --port <port>', 'Port number', '4848')
109
102
  .option('--idle-timeout <seconds>', 'Auto-shutdown after N seconds idle (0 = disabled)', '0')
110
- .action(evalServerCommand);
103
+ .action(createLazyAction(() => import('./eval-server.js'), 'evalServerCommand'));
111
104
  program.parse(process.argv);
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Creates a lazy-loaded CLI action that defers module import until invocation.
3
+ * The generic constraints ensure the export name is a valid key of the module
4
+ * at compile time — catching typos when used with concrete module imports.
5
+ */
6
+ export declare function createLazyAction<TModule extends Record<string, unknown>, TKey extends string & keyof TModule>(loader: () => Promise<TModule>, exportName: TKey): (...args: unknown[]) => Promise<void>;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Creates a lazy-loaded CLI action that defers module import until invocation.
3
+ * The generic constraints ensure the export name is a valid key of the module
4
+ * at compile time — catching typos when used with concrete module imports.
5
+ */
6
+ function isCallable(value) {
7
+ return typeof value === 'function';
8
+ }
9
+ export function createLazyAction(loader, exportName) {
10
+ return async (...args) => {
11
+ const module = await loader();
12
+ const action = module[exportName];
13
+ if (!isCallable(action)) {
14
+ throw new Error(`Lazy action export not found: ${exportName}`);
15
+ }
16
+ await action(...args);
17
+ };
18
+ }
package/dist/cli/mcp.js CHANGED
@@ -9,7 +9,7 @@ import { startMCPServer } from '../mcp/server.js';
9
9
  import { LocalBackend } from '../mcp/local/local-backend.js';
10
10
  export const mcpCommand = async () => {
11
11
  // Prevent unhandled errors from crashing the MCP server process.
12
- // KuzuDB lock conflicts and transient errors should degrade gracefully.
12
+ // LadybugDB lock conflicts and transient errors should degrade gracefully.
13
13
  process.on('uncaughtException', (err) => {
14
14
  console.error(`GitNexus MCP: uncaught exception — ${err.message}`);
15
15
  // Process is in an undefined state after uncaughtException — exit after flushing
package/dist/cli/setup.js CHANGED
@@ -9,6 +9,7 @@ import fs from 'fs/promises';
9
9
  import path from 'path';
10
10
  import os from 'os';
11
11
  import { fileURLToPath } from 'url';
12
+ import { glob } from 'glob';
12
13
  import { getGlobalDir } from '../storage/repo-manager.js';
13
14
  const __filename = fileURLToPath(import.meta.url);
14
15
  const __dirname = path.dirname(__filename);
@@ -147,36 +148,34 @@ async function installClaudeCodeHooks(result) {
147
148
  // even when it's no longer inside the npm package tree
148
149
  const resolvedCli = path.join(__dirname, '..', 'cli', 'index.js');
149
150
  const normalizedCli = path.resolve(resolvedCli).replace(/\\/g, '/');
150
- content = content.replace("let cliPath = path.resolve(__dirname, '..', '..', 'dist', 'cli', 'index.js');", `let cliPath = '${normalizedCli}';`);
151
+ const jsonCli = JSON.stringify(normalizedCli);
152
+ content = content.replace("let cliPath = path.resolve(__dirname, '..', '..', 'dist', 'cli', 'index.js');", `let cliPath = ${jsonCli};`);
151
153
  await fs.writeFile(dest, content, 'utf-8');
152
154
  }
153
155
  catch {
154
156
  // Script not found in source — skip
155
157
  }
156
- const hookCmd = `node "${path.join(destHooksDir, 'gitnexus-hook.cjs').replace(/\\/g, '/')}"`;
158
+ const hookPath = path.join(destHooksDir, 'gitnexus-hook.cjs').replace(/\\/g, '/');
159
+ const hookCmd = `node "${hookPath.replace(/"/g, '\\"')}"`;
157
160
  // Merge hook config into ~/.claude/settings.json
158
161
  const existing = await readJsonFile(settingsPath) || {};
159
162
  if (!existing.hooks)
160
163
  existing.hooks = {};
161
- // NOTE: SessionStart hooks are broken on Windows (Claude Code bug #23576).
162
- // Session context is delivered via CLAUDE.md / skills instead.
163
- // Add PreToolUse hook if not already present
164
- if (!existing.hooks.PreToolUse)
165
- existing.hooks.PreToolUse = [];
166
- const hasPreToolHook = existing.hooks.PreToolUse.some((h) => h.hooks?.some((hh) => hh.command?.includes('gitnexus')));
167
- if (!hasPreToolHook) {
168
- existing.hooks.PreToolUse.push({
169
- matcher: 'Grep|Glob|Bash',
170
- hooks: [{
171
- type: 'command',
172
- command: hookCmd,
173
- timeout: 8000,
174
- statusMessage: 'Enriching with GitNexus graph context...',
175
- }],
176
- });
164
+ function ensureHookEntry(eventName, matcher, timeout, statusMessage) {
165
+ if (!existing.hooks[eventName])
166
+ existing.hooks[eventName] = [];
167
+ const hasHook = existing.hooks[eventName].some((h) => h.hooks?.some(hh => hh.command?.includes('gitnexus-hook')));
168
+ if (!hasHook) {
169
+ existing.hooks[eventName].push({
170
+ matcher,
171
+ hooks: [{ type: 'command', command: hookCmd, timeout, statusMessage }],
172
+ });
173
+ }
177
174
  }
175
+ ensureHookEntry('PreToolUse', 'Grep|Glob|Bash', 10, 'Enriching with GitNexus graph context...');
176
+ ensureHookEntry('PostToolUse', 'Bash', 10, 'Checking GitNexus index freshness...');
178
177
  await writeJsonFile(settingsPath, existing);
179
- result.configured.push('Claude Code hooks (PreToolUse)');
178
+ result.configured.push('Claude Code hooks (PreToolUse, PostToolUse)');
180
179
  }
181
180
  catch (err) {
182
181
  result.errors.push(`Claude Code hooks: ${err.message}`);
@@ -203,7 +202,6 @@ async function setupOpenCode(result) {
203
202
  }
204
203
  }
205
204
  // ─── Skill Installation ───────────────────────────────────────────
206
- const SKILL_NAMES = ['gitnexus-exploring', 'gitnexus-debugging', 'gitnexus-impact-analysis', 'gitnexus-refactoring', 'gitnexus-guide', 'gitnexus-cli'];
207
205
  /**
208
206
  * Install GitNexus skills to a target directory.
209
207
  * Each skill is installed as {targetDir}/gitnexus-{skillName}/SKILL.md
@@ -216,24 +214,36 @@ const SKILL_NAMES = ['gitnexus-exploring', 'gitnexus-debugging', 'gitnexus-impac
216
214
  async function installSkillsTo(targetDir) {
217
215
  const installed = [];
218
216
  const skillsRoot = path.join(__dirname, '..', '..', 'skills');
219
- for (const skillName of SKILL_NAMES) {
217
+ let flatFiles = [];
218
+ let dirSkillFiles = [];
219
+ try {
220
+ [flatFiles, dirSkillFiles] = await Promise.all([
221
+ glob('*.md', { cwd: skillsRoot }),
222
+ glob('*/SKILL.md', { cwd: skillsRoot }),
223
+ ]);
224
+ }
225
+ catch {
226
+ return [];
227
+ }
228
+ const skillSources = new Map();
229
+ for (const relPath of dirSkillFiles) {
230
+ skillSources.set(path.dirname(relPath), { isDirectory: true });
231
+ }
232
+ for (const relPath of flatFiles) {
233
+ const skillName = path.basename(relPath, '.md');
234
+ if (!skillSources.has(skillName)) {
235
+ skillSources.set(skillName, { isDirectory: false });
236
+ }
237
+ }
238
+ for (const [skillName, source] of skillSources) {
220
239
  const skillDir = path.join(targetDir, skillName);
221
240
  try {
222
- // Try directory-based skill first (skills/{name}/SKILL.md)
223
- const dirSource = path.join(skillsRoot, skillName);
224
- const dirSkillFile = path.join(dirSource, 'SKILL.md');
225
- let isDirectory = false;
226
- try {
227
- const stat = await fs.stat(dirSource);
228
- isDirectory = stat.isDirectory();
229
- }
230
- catch { /* not a directory */ }
231
- if (isDirectory) {
241
+ if (source.isDirectory) {
242
+ const dirSource = path.join(skillsRoot, skillName);
232
243
  await copyDirRecursive(dirSource, skillDir);
233
244
  installed.push(skillName);
234
245
  }
235
246
  else {
236
- // Fall back to flat file (skills/{name}.md)
237
247
  const flatSource = path.join(skillsRoot, `${skillName}.md`);
238
248
  const content = await fs.readFile(flatSource, 'utf-8');
239
249
  await fs.mkdir(skillDir, { recursive: true });
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Skill File Generator
3
+ *
4
+ * Generates repo-specific SKILL.md files from detected Leiden communities.
5
+ * Each significant community becomes a skill that describes a functional area
6
+ * of the codebase, including key files, entry points, execution flows, and
7
+ * cross-community connections.
8
+ */
9
+ import { PipelineResult } from '../types/pipeline.js';
10
+ export interface GeneratedSkillInfo {
11
+ name: string;
12
+ label: string;
13
+ symbolCount: number;
14
+ fileCount: number;
15
+ }
16
+ /**
17
+ * @brief Generate repo-specific skill files from detected communities
18
+ * @param {string} repoPath - Absolute path to the repository root
19
+ * @param {string} projectName - Human-readable project name
20
+ * @param {PipelineResult} pipelineResult - In-memory pipeline data with communities, processes, graph
21
+ * @returns {Promise<{ skills: GeneratedSkillInfo[], outputPath: string }>} Generated skill metadata
22
+ */
23
+ export declare const generateSkillFiles: (repoPath: string, projectName: string, pipelineResult: PipelineResult) => Promise<{
24
+ skills: GeneratedSkillInfo[];
25
+ outputPath: string;
26
+ }>;