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
@@ -1,42 +1,42 @@
1
- #!/bin/bash
2
- # GitNexus SessionStart hook for Claude Code
3
- # Fires on session startup. Stdout is injected into Claude's context.
4
- # Checks if the current directory has a GitNexus index.
5
-
6
- dir="$PWD"
7
- found=false
8
- for i in 1 2 3 4 5; do
9
- if [ -d "$dir/.gitnexus" ]; then
10
- found=true
11
- break
12
- fi
13
- parent="$(dirname "$dir")"
14
- [ "$parent" = "$dir" ] && break
15
- dir="$parent"
16
- done
17
-
18
- if [ "$found" = false ]; then
19
- exit 0
20
- fi
21
-
22
- # Inject GitNexus context — this stdout goes directly into Claude's context
23
- cat << 'EOF'
24
- ## GitNexus Code Intelligence
25
-
26
- This codebase is indexed by GitNexus, providing a knowledge graph with execution flows, relationships, and semantic search.
27
-
28
- **Available MCP Tools:**
29
- - `query` — Process-grouped code intelligence (execution flows related to a concept)
30
- - `context` — 360-degree symbol view (categorized refs, process participation)
31
- - `impact` — Blast radius analysis (what breaks if you change a symbol)
32
- - `detect_changes` — Git-diff impact analysis (what do your changes affect)
33
- - `rename` — Multi-file coordinated rename with confidence tags
34
- - `cypher` — Raw graph queries
35
- - `list_repos` — Discover indexed repos
36
-
37
- **Quick Start:** READ `gitnexus://repo/{name}/context` for codebase overview, then use `query` to find execution flows.
38
-
39
- **Resources:** `gitnexus://repo/{name}/context` (overview), `/processes` (execution flows), `/schema` (for Cypher)
40
- EOF
41
-
42
- exit 0
1
+ #!/bin/bash
2
+ # GitNexus SessionStart hook for Claude Code
3
+ # Fires on session startup. Stdout is injected into Claude's context.
4
+ # Checks if the current directory has a GitNexus index.
5
+
6
+ dir="$PWD"
7
+ found=false
8
+ for i in 1 2 3 4 5; do
9
+ if [ -d "$dir/.gitnexus" ]; then
10
+ found=true
11
+ break
12
+ fi
13
+ parent="$(dirname "$dir")"
14
+ [ "$parent" = "$dir" ] && break
15
+ dir="$parent"
16
+ done
17
+
18
+ if [ "$found" = false ]; then
19
+ exit 0
20
+ fi
21
+
22
+ # Inject GitNexus context — this stdout goes directly into Claude's context
23
+ cat << 'EOF'
24
+ ## GitNexus Code Intelligence
25
+
26
+ This codebase is indexed by GitNexus, providing a knowledge graph with execution flows, relationships, and semantic search.
27
+
28
+ **Available MCP Tools:**
29
+ - `query` — Process-grouped code intelligence (execution flows related to a concept)
30
+ - `context` — 360-degree symbol view (categorized refs, process participation)
31
+ - `impact` — Blast radius analysis (what breaks if you change a symbol)
32
+ - `detect_changes` — Git-diff impact analysis (what do your changes affect)
33
+ - `rename` — Multi-file coordinated rename with confidence tags
34
+ - `cypher` — Raw graph queries
35
+ - `list_repos` — Discover indexed repos
36
+
37
+ **Quick Start:** READ `gitnexus://repo/{name}/context` for codebase overview, then use `query` to find execution flows.
38
+
39
+ **Resources:** `gitnexus://repo/{name}/context` (overview), `/processes` (execution flows), `/schema` (for Cypher)
40
+ EOF
41
+
42
+ exit 0
package/package.json CHANGED
@@ -1,96 +1,99 @@
1
- {
2
- "name": "gitnexus",
3
- "version": "1.4.1",
4
- "description": "Graph-powered code intelligence for AI agents. Index any codebase, query via MCP or CLI.",
5
- "author": "Abhigyan Patwari",
6
- "license": "PolyForm-Noncommercial-1.0.0",
7
- "homepage": "https://github.com/abhigyanpatwari/GitNexus#readme",
8
- "repository": {
9
- "type": "git",
10
- "url": "git+https://github.com/abhigyanpatwari/GitNexus.git",
11
- "directory": "gitnexus"
12
- },
13
- "bugs": {
14
- "url": "https://github.com/abhigyanpatwari/GitNexus/issues"
15
- },
16
- "keywords": [
17
- "mcp",
18
- "model-context-protocol",
19
- "code-intelligence",
20
- "knowledge-graph",
21
- "cursor",
22
- "claude",
23
- "ai-agent",
24
- "gitnexus",
25
- "static-analysis",
26
- "codebase-indexing"
27
- ],
28
- "type": "module",
29
- "bin": {
30
- "gitnexus": "dist/cli/index.js"
31
- },
32
- "files": [
33
- "dist",
34
- "hooks",
35
- "scripts",
36
- "skills",
37
- "vendor"
38
- ],
39
- "scripts": {
40
- "build": "tsc",
41
- "dev": "tsx watch src/cli/index.ts",
42
- "test": "vitest run test/unit",
43
- "test:integration": "vitest run test/integration",
44
- "test:all": "vitest run",
45
- "test:watch": "vitest",
46
- "test:coverage": "vitest run --coverage",
47
- "prepare": "npm run build",
48
- "postinstall": "node scripts/patch-tree-sitter-swift.cjs"
49
- },
50
- "dependencies": {
51
- "@huggingface/transformers": "^3.0.0",
52
- "@modelcontextprotocol/sdk": "^1.0.0",
53
- "cli-progress": "^3.12.0",
54
- "commander": "^12.0.0",
55
- "cors": "^2.8.5",
56
- "express": "^4.19.2",
57
- "glob": "^11.0.0",
58
- "graphology": "^0.25.4",
59
- "graphology-indices": "^0.17.0",
60
- "graphology-utils": "^2.3.0",
61
- "kuzu": "^0.11.3",
62
- "lru-cache": "^11.0.0",
63
- "mnemonist": "^0.39.0",
64
- "pandemonium": "^2.4.0",
65
- "tree-sitter": "^0.21.0",
66
- "tree-sitter-c": "^0.21.0",
67
- "tree-sitter-c-sharp": "^0.21.0",
68
- "tree-sitter-cpp": "^0.22.0",
69
- "tree-sitter-go": "^0.21.0",
70
- "tree-sitter-java": "^0.21.0",
71
- "tree-sitter-javascript": "^0.21.0",
72
- "tree-sitter-kotlin": "^0.3.8",
73
- "tree-sitter-php": "^0.23.12",
74
- "tree-sitter-python": "^0.21.0",
75
- "tree-sitter-rust": "^0.21.0",
76
- "tree-sitter-typescript": "^0.21.0",
77
- "uuid": "^13.0.0"
78
- },
79
- "optionalDependencies": {
80
- "tree-sitter-swift": "^0.6.0"
81
- },
82
- "devDependencies": {
83
- "@types/cli-progress": "^3.11.6",
84
- "@types/cors": "^2.8.17",
85
- "@types/express": "^4.17.21",
86
- "@types/node": "^20.0.0",
87
- "@types/uuid": "^10.0.0",
88
- "@vitest/coverage-v8": "^4.0.18",
89
- "tsx": "^4.0.0",
90
- "typescript": "^5.4.5",
91
- "vitest": "^4.0.18"
92
- },
93
- "engines": {
94
- "node": ">=18.0.0"
95
- }
96
- }
1
+ {
2
+ "name": "gitnexus",
3
+ "version": "1.4.6",
4
+ "description": "Graph-powered code intelligence for AI agents. Index any codebase, query via MCP or CLI.",
5
+ "author": "Abhigyan Patwari",
6
+ "license": "PolyForm-Noncommercial-1.0.0",
7
+ "homepage": "https://github.com/abhigyanpatwari/GitNexus#readme",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/abhigyanpatwari/GitNexus.git",
11
+ "directory": "gitnexus"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/abhigyanpatwari/GitNexus/issues"
15
+ },
16
+ "keywords": [
17
+ "mcp",
18
+ "model-context-protocol",
19
+ "code-intelligence",
20
+ "knowledge-graph",
21
+ "cursor",
22
+ "claude",
23
+ "ai-agent",
24
+ "gitnexus",
25
+ "static-analysis",
26
+ "codebase-indexing"
27
+ ],
28
+ "type": "module",
29
+ "bin": {
30
+ "gitnexus": "dist/cli/index.js"
31
+ },
32
+ "files": [
33
+ "dist",
34
+ "hooks",
35
+ "scripts",
36
+ "skills",
37
+ "vendor"
38
+ ],
39
+ "scripts": {
40
+ "build": "tsc",
41
+ "dev": "tsx watch src/cli/index.ts",
42
+ "test": "vitest run test/unit",
43
+ "test:integration": "vitest run test/integration",
44
+ "test:all": "vitest run",
45
+ "test:watch": "vitest",
46
+ "test:coverage": "vitest run --coverage",
47
+ "prepare": "npm run build",
48
+ "postinstall": "node scripts/patch-tree-sitter-swift.cjs",
49
+ "prepack": "npm run build && chmod +x dist/cli/index.js"
50
+ },
51
+ "dependencies": {
52
+ "@huggingface/transformers": "^3.0.0",
53
+ "@modelcontextprotocol/sdk": "^1.0.0",
54
+ "cli-progress": "^3.12.0",
55
+ "commander": "^12.0.0",
56
+ "cors": "^2.8.5",
57
+ "express": "^4.19.2",
58
+ "glob": "^11.0.0",
59
+ "graphology": "^0.25.4",
60
+ "graphology-indices": "^0.17.0",
61
+ "graphology-utils": "^2.3.0",
62
+ "@ladybugdb/core": "^0.15.1",
63
+ "ignore": "^7.0.5",
64
+ "lru-cache": "^11.0.0",
65
+ "mnemonist": "^0.39.0",
66
+ "pandemonium": "^2.4.0",
67
+ "tree-sitter": "^0.21.0",
68
+ "tree-sitter-c": "^0.21.0",
69
+ "tree-sitter-c-sharp": "^0.21.0",
70
+ "tree-sitter-cpp": "^0.22.0",
71
+ "tree-sitter-go": "^0.21.0",
72
+ "tree-sitter-java": "^0.21.0",
73
+ "tree-sitter-javascript": "^0.21.0",
74
+ "tree-sitter-php": "^0.23.12",
75
+ "tree-sitter-python": "^0.21.0",
76
+ "tree-sitter-ruby": "^0.23.1",
77
+ "tree-sitter-rust": "^0.21.0",
78
+ "tree-sitter-typescript": "^0.21.0",
79
+ "uuid": "^13.0.0"
80
+ },
81
+ "optionalDependencies": {
82
+ "tree-sitter-kotlin": "^0.3.8",
83
+ "tree-sitter-swift": "^0.6.0"
84
+ },
85
+ "devDependencies": {
86
+ "@types/cli-progress": "^3.11.6",
87
+ "@types/cors": "^2.8.17",
88
+ "@types/express": "^4.17.21",
89
+ "@types/node": "^20.0.0",
90
+ "@types/uuid": "^10.0.0",
91
+ "@vitest/coverage-v8": "^4.0.18",
92
+ "tsx": "^4.0.0",
93
+ "typescript": "^5.4.5",
94
+ "vitest": "^4.0.18"
95
+ },
96
+ "engines": {
97
+ "node": ">=18.0.0"
98
+ }
99
+ }
@@ -1,74 +1,74 @@
1
- #!/usr/bin/env node
2
- /**
3
- * WORKAROUND: tree-sitter-swift@0.6.0 binding.gyp build failure
4
- *
5
- * Background:
6
- * tree-sitter-swift@0.6.0's binding.gyp contains an "actions" array that
7
- * invokes `tree-sitter generate` to regenerate parser.c from grammar.js.
8
- * This is intended for grammar developers, but the published npm package
9
- * already ships pre-generated parser files (parser.c, scanner.c), so the
10
- * actions are unnecessary for consumers. Since consumers don't have
11
- * tree-sitter-cli installed, the actions always fail during `npm install`.
12
- *
13
- * Why we can't just upgrade:
14
- * tree-sitter-swift@0.7.1 fixes this (removes postinstall, ships prebuilds),
15
- * but it requires tree-sitter@^0.22.1. The upstream project pins tree-sitter
16
- * to ^0.21.0 and all other grammar packages depend on that version.
17
- * Upgrading tree-sitter would be a separate breaking change.
18
- *
19
- * How this workaround works:
20
- * 1. tree-sitter-swift's own postinstall fails (npm warns but continues)
21
- * 2. This script runs as gitnexus's postinstall
22
- * 3. It removes the "actions" array from binding.gyp
23
- * 4. It rebuilds the native binding with the cleaned binding.gyp
24
- *
25
- * TODO: Remove this script when tree-sitter is upgraded to ^0.22.x,
26
- * which allows using tree-sitter-swift@0.7.1+ directly.
27
- */
28
- const fs = require('fs');
29
- const path = require('path');
30
- const { execSync } = require('child_process');
31
-
32
- const swiftDir = path.join(__dirname, '..', 'node_modules', 'tree-sitter-swift');
33
- const bindingPath = path.join(swiftDir, 'binding.gyp');
34
-
35
- try {
36
- if (!fs.existsSync(bindingPath)) {
37
- process.exit(0);
38
- }
39
-
40
- const content = fs.readFileSync(bindingPath, 'utf8');
41
- let needsRebuild = false;
42
-
43
- if (content.includes('"actions"')) {
44
- // Strip Python-style comments (#) before JSON parsing
45
- const cleaned = content.replace(/#[^\n]*/g, '');
46
- const gyp = JSON.parse(cleaned);
47
-
48
- if (gyp.targets && gyp.targets[0] && gyp.targets[0].actions) {
49
- delete gyp.targets[0].actions;
50
- fs.writeFileSync(bindingPath, JSON.stringify(gyp, null, 2) + '\n');
51
- console.log('[tree-sitter-swift] Patched binding.gyp (removed actions array)');
52
- needsRebuild = true;
53
- }
54
- }
55
-
56
- // Check if native binding exists
57
- const bindingNode = path.join(swiftDir, 'build', 'Release', 'tree_sitter_swift_binding.node');
58
- if (!fs.existsSync(bindingNode)) {
59
- needsRebuild = true;
60
- }
61
-
62
- if (needsRebuild) {
63
- console.log('[tree-sitter-swift] Rebuilding native binding...');
64
- execSync('npx node-gyp rebuild', {
65
- cwd: swiftDir,
66
- stdio: 'pipe',
67
- timeout: 120000,
68
- });
69
- console.log('[tree-sitter-swift] Native binding built successfully');
70
- }
71
- } catch (err) {
72
- console.warn('[tree-sitter-swift] Could not build native binding:', err.message);
73
- console.warn('[tree-sitter-swift] You may need to manually run: cd node_modules/tree-sitter-swift && npx node-gyp rebuild');
74
- }
1
+ #!/usr/bin/env node
2
+ /**
3
+ * WORKAROUND: tree-sitter-swift@0.6.0 binding.gyp build failure
4
+ *
5
+ * Background:
6
+ * tree-sitter-swift@0.6.0's binding.gyp contains an "actions" array that
7
+ * invokes `tree-sitter generate` to regenerate parser.c from grammar.js.
8
+ * This is intended for grammar developers, but the published npm package
9
+ * already ships pre-generated parser files (parser.c, scanner.c), so the
10
+ * actions are unnecessary for consumers. Since consumers don't have
11
+ * tree-sitter-cli installed, the actions always fail during `npm install`.
12
+ *
13
+ * Why we can't just upgrade:
14
+ * tree-sitter-swift@0.7.1 fixes this (removes postinstall, ships prebuilds),
15
+ * but it requires tree-sitter@^0.22.1. The upstream project pins tree-sitter
16
+ * to ^0.21.0 and all other grammar packages depend on that version.
17
+ * Upgrading tree-sitter would be a separate breaking change.
18
+ *
19
+ * How this workaround works:
20
+ * 1. tree-sitter-swift's own postinstall fails (npm warns but continues)
21
+ * 2. This script runs as gitnexus's postinstall
22
+ * 3. It removes the "actions" array from binding.gyp
23
+ * 4. It rebuilds the native binding with the cleaned binding.gyp
24
+ *
25
+ * TODO: Remove this script when tree-sitter is upgraded to ^0.22.x,
26
+ * which allows using tree-sitter-swift@0.7.1+ directly.
27
+ */
28
+ const fs = require('fs');
29
+ const path = require('path');
30
+ const { execSync } = require('child_process');
31
+
32
+ const swiftDir = path.join(__dirname, '..', 'node_modules', 'tree-sitter-swift');
33
+ const bindingPath = path.join(swiftDir, 'binding.gyp');
34
+
35
+ try {
36
+ if (!fs.existsSync(bindingPath)) {
37
+ process.exit(0);
38
+ }
39
+
40
+ const content = fs.readFileSync(bindingPath, 'utf8');
41
+ let needsRebuild = false;
42
+
43
+ if (content.includes('"actions"')) {
44
+ // Strip Python-style comments (#) before JSON parsing
45
+ const cleaned = content.replace(/#[^\n]*/g, '');
46
+ const gyp = JSON.parse(cleaned);
47
+
48
+ if (gyp.targets && gyp.targets[0] && gyp.targets[0].actions) {
49
+ delete gyp.targets[0].actions;
50
+ fs.writeFileSync(bindingPath, JSON.stringify(gyp, null, 2) + '\n');
51
+ console.log('[tree-sitter-swift] Patched binding.gyp (removed actions array)');
52
+ needsRebuild = true;
53
+ }
54
+ }
55
+
56
+ // Check if native binding exists
57
+ const bindingNode = path.join(swiftDir, 'build', 'Release', 'tree_sitter_swift_binding.node');
58
+ if (!fs.existsSync(bindingNode)) {
59
+ needsRebuild = true;
60
+ }
61
+
62
+ if (needsRebuild) {
63
+ console.log('[tree-sitter-swift] Rebuilding native binding...');
64
+ execSync('npx node-gyp rebuild', {
65
+ cwd: swiftDir,
66
+ stdio: 'pipe',
67
+ timeout: 120000,
68
+ });
69
+ console.log('[tree-sitter-swift] Native binding built successfully');
70
+ }
71
+ } catch (err) {
72
+ console.warn('[tree-sitter-swift] Could not build native binding:', err.message);
73
+ console.warn('[tree-sitter-swift] You may need to manually run: cd node_modules/tree-sitter-swift && npx node-gyp rebuild');
74
+ }
@@ -1,82 +1,82 @@
1
- ---
2
- name: gitnexus-cli
3
- description: "Use when the user needs to run GitNexus CLI commands like analyze/index a repo, check status, clean the index, generate a wiki, or list indexed repos. Examples: \"Index this repo\", \"Reanalyze the codebase\", \"Generate a wiki\""
4
- ---
5
-
6
- # GitNexus CLI Commands
7
-
8
- All commands work via `npx` — no global install required.
9
-
10
- ## Commands
11
-
12
- ### analyze — Build or refresh the index
13
-
14
- ```bash
15
- npx gitnexus analyze
16
- ```
17
-
18
- Run from the project root. This parses all source files, builds the knowledge graph, writes it to `.gitnexus/`, and generates CLAUDE.md / AGENTS.md context files.
19
-
20
- | Flag | Effect |
21
- | -------------- | ---------------------------------------------------------------- |
22
- | `--force` | Force full re-index even if up to date |
23
- | `--embeddings` | Enable embedding generation for semantic search (off by default) |
24
-
25
- **When to run:** First time in a project, after major code changes, or when `gitnexus://repo/{name}/context` reports the index is stale.
26
-
27
- ### status — Check index freshness
28
-
29
- ```bash
30
- npx gitnexus status
31
- ```
32
-
33
- Shows whether the current repo has a GitNexus index, when it was last updated, and symbol/relationship counts. Use this to check if re-indexing is needed.
34
-
35
- ### clean — Delete the index
36
-
37
- ```bash
38
- npx gitnexus clean
39
- ```
40
-
41
- Deletes the `.gitnexus/` directory and unregisters the repo from the global registry. Use before re-indexing if the index is corrupt or after removing GitNexus from a project.
42
-
43
- | Flag | Effect |
44
- | --------- | ------------------------------------------------- |
45
- | `--force` | Skip confirmation prompt |
46
- | `--all` | Clean all indexed repos, not just the current one |
47
-
48
- ### wiki — Generate documentation from the graph
49
-
50
- ```bash
51
- npx gitnexus wiki
52
- ```
53
-
54
- Generates repository documentation from the knowledge graph using an LLM. Requires an API key (saved to `~/.gitnexus/config.json` on first use).
55
-
56
- | Flag | Effect |
57
- | ------------------- | ----------------------------------------- |
58
- | `--force` | Force full regeneration |
59
- | `--model <model>` | LLM model (default: minimax/minimax-m2.5) |
60
- | `--base-url <url>` | LLM API base URL |
61
- | `--api-key <key>` | LLM API key |
62
- | `--concurrency <n>` | Parallel LLM calls (default: 3) |
63
- | `--gist` | Publish wiki as a public GitHub Gist |
64
-
65
- ### list — Show all indexed repos
66
-
67
- ```bash
68
- npx gitnexus list
69
- ```
70
-
71
- Lists all repositories registered in `~/.gitnexus/registry.json`. The MCP `list_repos` tool provides the same information.
72
-
73
- ## After Indexing
74
-
75
- 1. **Read `gitnexus://repo/{name}/context`** to verify the index loaded
76
- 2. Use the other GitNexus skills (`exploring`, `debugging`, `impact-analysis`, `refactoring`) for your task
77
-
78
- ## Troubleshooting
79
-
80
- - **"Not inside a git repository"**: Run from a directory inside a git repo
81
- - **Index is stale after re-analyzing**: Restart Claude Code to reload the MCP server
82
- - **Embeddings slow**: Omit `--embeddings` (it's off by default) or set `OPENAI_API_KEY` for faster API-based embedding
1
+ ---
2
+ name: gitnexus-cli
3
+ description: "Use when the user needs to run GitNexus CLI commands like analyze/index a repo, check status, clean the index, generate a wiki, or list indexed repos. Examples: \"Index this repo\", \"Reanalyze the codebase\", \"Generate a wiki\""
4
+ ---
5
+
6
+ # GitNexus CLI Commands
7
+
8
+ All commands work via `npx` — no global install required.
9
+
10
+ ## Commands
11
+
12
+ ### analyze — Build or refresh the index
13
+
14
+ ```bash
15
+ npx gitnexus analyze
16
+ ```
17
+
18
+ Run from the project root. This parses all source files, builds the knowledge graph, writes it to `.gitnexus/`, and generates CLAUDE.md / AGENTS.md context files.
19
+
20
+ | Flag | Effect |
21
+ | -------------- | ---------------------------------------------------------------- |
22
+ | `--force` | Force full re-index even if up to date |
23
+ | `--embeddings` | Enable embedding generation for semantic search (off by default) |
24
+
25
+ **When to run:** First time in a project, after major code changes, or when `gitnexus://repo/{name}/context` reports the index is stale. In Claude Code, a PostToolUse hook runs `analyze` automatically after `git commit` and `git merge`, preserving embeddings if previously generated.
26
+
27
+ ### status — Check index freshness
28
+
29
+ ```bash
30
+ npx gitnexus status
31
+ ```
32
+
33
+ Shows whether the current repo has a GitNexus index, when it was last updated, and symbol/relationship counts. Use this to check if re-indexing is needed.
34
+
35
+ ### clean — Delete the index
36
+
37
+ ```bash
38
+ npx gitnexus clean
39
+ ```
40
+
41
+ Deletes the `.gitnexus/` directory and unregisters the repo from the global registry. Use before re-indexing if the index is corrupt or after removing GitNexus from a project.
42
+
43
+ | Flag | Effect |
44
+ | --------- | ------------------------------------------------- |
45
+ | `--force` | Skip confirmation prompt |
46
+ | `--all` | Clean all indexed repos, not just the current one |
47
+
48
+ ### wiki — Generate documentation from the graph
49
+
50
+ ```bash
51
+ npx gitnexus wiki
52
+ ```
53
+
54
+ Generates repository documentation from the knowledge graph using an LLM. Requires an API key (saved to `~/.gitnexus/config.json` on first use).
55
+
56
+ | Flag | Effect |
57
+ | ------------------- | ----------------------------------------- |
58
+ | `--force` | Force full regeneration |
59
+ | `--model <model>` | LLM model (default: minimax/minimax-m2.5) |
60
+ | `--base-url <url>` | LLM API base URL |
61
+ | `--api-key <key>` | LLM API key |
62
+ | `--concurrency <n>` | Parallel LLM calls (default: 3) |
63
+ | `--gist` | Publish wiki as a public GitHub Gist |
64
+
65
+ ### list — Show all indexed repos
66
+
67
+ ```bash
68
+ npx gitnexus list
69
+ ```
70
+
71
+ Lists all repositories registered in `~/.gitnexus/registry.json`. The MCP `list_repos` tool provides the same information.
72
+
73
+ ## After Indexing
74
+
75
+ 1. **Read `gitnexus://repo/{name}/context`** to verify the index loaded
76
+ 2. Use the other GitNexus skills (`exploring`, `debugging`, `impact-analysis`, `refactoring`) for your task
77
+
78
+ ## Troubleshooting
79
+
80
+ - **"Not inside a git repository"**: Run from a directory inside a git repo
81
+ - **Index is stale after re-analyzing**: Restart Claude Code to reload the MCP server
82
+ - **Embeddings slow**: Omit `--embeddings` (it's off by default) or set `OPENAI_API_KEY` for faster API-based embedding