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.
- package/README.md +215 -194
- package/dist/cli/ai-context.d.ts +2 -1
- package/dist/cli/ai-context.js +117 -90
- package/dist/cli/analyze.d.ts +2 -0
- package/dist/cli/analyze.js +57 -30
- package/dist/cli/augment.js +1 -1
- package/dist/cli/eval-server.d.ts +1 -1
- package/dist/cli/eval-server.js +14 -6
- package/dist/cli/index.js +18 -25
- package/dist/cli/lazy-action.d.ts +6 -0
- package/dist/cli/lazy-action.js +18 -0
- package/dist/cli/mcp.js +1 -1
- package/dist/cli/setup.js +42 -32
- package/dist/cli/skill-gen.d.ts +26 -0
- package/dist/cli/skill-gen.js +549 -0
- package/dist/cli/status.js +13 -4
- package/dist/cli/tool.d.ts +3 -2
- package/dist/cli/tool.js +48 -13
- package/dist/cli/wiki.js +2 -2
- package/dist/config/ignore-service.d.ts +25 -0
- package/dist/config/ignore-service.js +76 -0
- package/dist/config/supported-languages.d.ts +1 -0
- package/dist/config/supported-languages.js +1 -1
- package/dist/core/augmentation/engine.js +99 -72
- package/dist/core/embeddings/embedder.d.ts +1 -1
- package/dist/core/embeddings/embedder.js +1 -1
- package/dist/core/embeddings/embedding-pipeline.d.ts +3 -3
- package/dist/core/embeddings/embedding-pipeline.js +74 -47
- package/dist/core/embeddings/types.d.ts +1 -1
- package/dist/core/graph/types.d.ts +5 -2
- package/dist/core/ingestion/ast-cache.js +3 -2
- package/dist/core/ingestion/call-processor.d.ts +5 -7
- package/dist/core/ingestion/call-processor.js +430 -283
- package/dist/core/ingestion/call-routing.d.ts +53 -0
- package/dist/core/ingestion/call-routing.js +108 -0
- package/dist/core/ingestion/cluster-enricher.js +16 -16
- package/dist/core/ingestion/constants.d.ts +16 -0
- package/dist/core/ingestion/constants.js +16 -0
- package/dist/core/ingestion/entry-point-scoring.d.ts +2 -1
- package/dist/core/ingestion/entry-point-scoring.js +94 -24
- package/dist/core/ingestion/export-detection.d.ts +18 -0
- package/dist/core/ingestion/export-detection.js +231 -0
- package/dist/core/ingestion/filesystem-walker.js +4 -3
- package/dist/core/ingestion/framework-detection.d.ts +5 -1
- package/dist/core/ingestion/framework-detection.js +48 -8
- package/dist/core/ingestion/heritage-processor.d.ts +13 -5
- package/dist/core/ingestion/heritage-processor.js +109 -55
- package/dist/core/ingestion/import-processor.d.ts +16 -20
- package/dist/core/ingestion/import-processor.js +202 -696
- package/dist/core/ingestion/language-config.d.ts +46 -0
- package/dist/core/ingestion/language-config.js +167 -0
- package/dist/core/ingestion/mro-processor.d.ts +45 -0
- package/dist/core/ingestion/mro-processor.js +369 -0
- package/dist/core/ingestion/named-binding-extraction.d.ts +61 -0
- package/dist/core/ingestion/named-binding-extraction.js +363 -0
- package/dist/core/ingestion/parsing-processor.d.ts +3 -11
- package/dist/core/ingestion/parsing-processor.js +85 -181
- package/dist/core/ingestion/pipeline.d.ts +5 -1
- package/dist/core/ingestion/pipeline.js +192 -116
- package/dist/core/ingestion/process-processor.js +2 -1
- package/dist/core/ingestion/resolution-context.d.ts +53 -0
- package/dist/core/ingestion/resolution-context.js +132 -0
- package/dist/core/ingestion/resolvers/csharp.d.ts +22 -0
- package/dist/core/ingestion/resolvers/csharp.js +109 -0
- package/dist/core/ingestion/resolvers/go.d.ts +19 -0
- package/dist/core/ingestion/resolvers/go.js +42 -0
- package/dist/core/ingestion/resolvers/index.d.ts +18 -0
- package/dist/core/ingestion/resolvers/index.js +13 -0
- package/dist/core/ingestion/resolvers/jvm.d.ts +23 -0
- package/dist/core/ingestion/resolvers/jvm.js +87 -0
- package/dist/core/ingestion/resolvers/php.d.ts +15 -0
- package/dist/core/ingestion/resolvers/php.js +35 -0
- package/dist/core/ingestion/resolvers/python.d.ts +19 -0
- package/dist/core/ingestion/resolvers/python.js +52 -0
- package/dist/core/ingestion/resolvers/ruby.d.ts +12 -0
- package/dist/core/ingestion/resolvers/ruby.js +15 -0
- package/dist/core/ingestion/resolvers/rust.d.ts +15 -0
- package/dist/core/ingestion/resolvers/rust.js +73 -0
- package/dist/core/ingestion/resolvers/standard.d.ts +28 -0
- package/dist/core/ingestion/resolvers/standard.js +123 -0
- package/dist/core/ingestion/resolvers/utils.d.ts +33 -0
- package/dist/core/ingestion/resolvers/utils.js +122 -0
- package/dist/core/ingestion/symbol-table.d.ts +21 -1
- package/dist/core/ingestion/symbol-table.js +40 -12
- package/dist/core/ingestion/tree-sitter-queries.d.ts +12 -11
- package/dist/core/ingestion/tree-sitter-queries.js +642 -485
- package/dist/core/ingestion/type-env.d.ts +49 -0
- package/dist/core/ingestion/type-env.js +611 -0
- package/dist/core/ingestion/type-extractors/c-cpp.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/c-cpp.js +385 -0
- package/dist/core/ingestion/type-extractors/csharp.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/csharp.js +383 -0
- package/dist/core/ingestion/type-extractors/go.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/go.js +467 -0
- package/dist/core/ingestion/type-extractors/index.d.ts +22 -0
- package/dist/core/ingestion/type-extractors/index.js +31 -0
- package/dist/core/ingestion/type-extractors/jvm.d.ts +3 -0
- package/dist/core/ingestion/type-extractors/jvm.js +681 -0
- package/dist/core/ingestion/type-extractors/php.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/php.js +549 -0
- package/dist/core/ingestion/type-extractors/python.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/python.js +406 -0
- package/dist/core/ingestion/type-extractors/ruby.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/ruby.js +389 -0
- package/dist/core/ingestion/type-extractors/rust.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/rust.js +449 -0
- package/dist/core/ingestion/type-extractors/shared.d.ts +133 -0
- package/dist/core/ingestion/type-extractors/shared.js +703 -0
- package/dist/core/ingestion/type-extractors/swift.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/swift.js +137 -0
- package/dist/core/ingestion/type-extractors/types.d.ts +127 -0
- package/dist/core/ingestion/type-extractors/types.js +1 -0
- package/dist/core/ingestion/type-extractors/typescript.d.ts +2 -0
- package/dist/core/ingestion/type-extractors/typescript.js +494 -0
- package/dist/core/ingestion/utils.d.ts +98 -0
- package/dist/core/ingestion/utils.js +1064 -9
- package/dist/core/ingestion/workers/parse-worker.d.ts +38 -4
- package/dist/core/ingestion/workers/parse-worker.js +251 -359
- package/dist/core/ingestion/workers/worker-pool.js +8 -0
- package/dist/core/{kuzu → lbug}/csv-generator.d.ts +1 -1
- package/dist/core/{kuzu → lbug}/csv-generator.js +20 -4
- package/dist/core/{kuzu/kuzu-adapter.d.ts → lbug/lbug-adapter.d.ts} +19 -19
- package/dist/core/{kuzu/kuzu-adapter.js → lbug/lbug-adapter.js} +82 -82
- package/dist/core/{kuzu → lbug}/schema.d.ts +4 -4
- package/dist/core/{kuzu → lbug}/schema.js +304 -289
- package/dist/core/search/bm25-index.d.ts +4 -4
- package/dist/core/search/bm25-index.js +17 -16
- package/dist/core/search/hybrid-search.d.ts +2 -2
- package/dist/core/search/hybrid-search.js +9 -9
- package/dist/core/tree-sitter/parser-loader.js +9 -2
- package/dist/core/wiki/generator.d.ts +4 -52
- package/dist/core/wiki/generator.js +53 -552
- package/dist/core/wiki/graph-queries.d.ts +4 -46
- package/dist/core/wiki/graph-queries.js +103 -282
- package/dist/core/wiki/html-viewer.js +192 -192
- package/dist/core/wiki/llm-client.js +11 -73
- package/dist/core/wiki/prompts.d.ts +8 -52
- package/dist/core/wiki/prompts.js +86 -200
- package/dist/mcp/compatible-stdio-transport.d.ts +25 -0
- package/dist/mcp/compatible-stdio-transport.js +200 -0
- package/dist/mcp/core/{kuzu-adapter.d.ts → lbug-adapter.d.ts} +7 -9
- package/dist/mcp/core/{kuzu-adapter.js → lbug-adapter.js} +77 -79
- package/dist/mcp/local/local-backend.d.ts +7 -6
- package/dist/mcp/local/local-backend.js +176 -147
- package/dist/mcp/resources.js +42 -42
- package/dist/mcp/server.js +18 -19
- package/dist/mcp/tools.js +103 -104
- package/dist/server/api.js +12 -12
- package/dist/server/mcp-http.d.ts +1 -1
- package/dist/server/mcp-http.js +1 -1
- package/dist/storage/repo-manager.d.ts +20 -2
- package/dist/storage/repo-manager.js +55 -1
- package/dist/types/pipeline.d.ts +1 -1
- package/hooks/claude/gitnexus-hook.cjs +238 -155
- package/hooks/claude/pre-tool-use.sh +79 -79
- package/hooks/claude/session-start.sh +42 -42
- package/package.json +99 -96
- package/scripts/patch-tree-sitter-swift.cjs +74 -74
- package/skills/gitnexus-cli.md +82 -82
- package/skills/gitnexus-debugging.md +89 -89
- package/skills/gitnexus-exploring.md +78 -78
- package/skills/gitnexus-guide.md +64 -64
- package/skills/gitnexus-impact-analysis.md +97 -97
- package/skills/gitnexus-pr-review.md +163 -163
- package/skills/gitnexus-refactoring.md +121 -121
- package/vendor/leiden/index.cjs +355 -355
- package/vendor/leiden/utils.cjs +392 -392
- package/dist/core/wiki/diagrams.d.ts +0 -27
- 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
|
-
.
|
|
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
|
-
//
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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
|
-
|
|
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
|
-
|
|
223
|
-
|
|
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
|
+
}>;
|