gitnexus 1.3.11 → 1.4.1
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 +194 -194
- package/dist/cli/ai-context.js +87 -105
- package/dist/cli/analyze.js +0 -8
- package/dist/cli/index.js +25 -15
- package/dist/cli/setup.js +19 -17
- package/dist/core/augmentation/engine.js +20 -20
- package/dist/core/embeddings/embedding-pipeline.js +26 -26
- package/dist/core/ingestion/ast-cache.js +2 -3
- package/dist/core/ingestion/call-processor.js +5 -7
- package/dist/core/ingestion/cluster-enricher.js +16 -16
- package/dist/core/ingestion/pipeline.js +2 -23
- package/dist/core/ingestion/tree-sitter-queries.js +484 -484
- package/dist/core/ingestion/utils.js +5 -1
- package/dist/core/ingestion/workers/worker-pool.js +0 -8
- package/dist/core/kuzu/kuzu-adapter.js +19 -11
- package/dist/core/kuzu/schema.js +287 -287
- package/dist/core/search/bm25-index.js +6 -7
- package/dist/core/search/hybrid-search.js +3 -3
- package/dist/core/wiki/diagrams.d.ts +27 -0
- package/dist/core/wiki/diagrams.js +163 -0
- package/dist/core/wiki/generator.d.ts +50 -2
- package/dist/core/wiki/generator.js +548 -49
- package/dist/core/wiki/graph-queries.d.ts +42 -0
- package/dist/core/wiki/graph-queries.js +276 -97
- package/dist/core/wiki/html-viewer.js +192 -192
- package/dist/core/wiki/llm-client.js +73 -11
- package/dist/core/wiki/prompts.d.ts +52 -8
- package/dist/core/wiki/prompts.js +200 -86
- package/dist/mcp/core/kuzu-adapter.d.ts +3 -1
- package/dist/mcp/core/kuzu-adapter.js +44 -13
- package/dist/mcp/local/local-backend.js +128 -128
- package/dist/mcp/resources.js +42 -42
- package/dist/mcp/server.js +19 -18
- package/dist/mcp/tools.js +103 -93
- package/hooks/claude/gitnexus-hook.cjs +155 -238
- package/hooks/claude/pre-tool-use.sh +79 -79
- package/hooks/claude/session-start.sh +42 -42
- package/package.json +96 -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/cli/lazy-action.d.ts +0 -6
- package/dist/cli/lazy-action.js +0 -18
- package/dist/mcp/compatible-stdio-transport.d.ts +0 -25
- package/dist/mcp/compatible-stdio-transport.js +0 -200
package/README.md
CHANGED
|
@@ -1,194 +1,194 @@
|
|
|
1
|
-
# GitNexus
|
|
2
|
-
|
|
3
|
-
**Graph-powered code intelligence for AI agents.** Index any codebase into a knowledge graph, then query it via MCP or CLI.
|
|
4
|
-
|
|
5
|
-
Works with **Cursor**, **Claude Code**, **Windsurf**, **Cline**, **OpenCode**, and any MCP-compatible tool.
|
|
6
|
-
|
|
7
|
-
[](https://www.npmjs.com/package/gitnexus)
|
|
8
|
-
[](https://polyformproject.org/licenses/noncommercial/1.0.0/)
|
|
9
|
-
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
## Why?
|
|
13
|
-
|
|
14
|
-
AI coding tools don't understand your codebase structure. They edit a function without knowing 47 other functions depend on it. GitNexus fixes this by **precomputing every dependency, call chain, and relationship** into a queryable graph.
|
|
15
|
-
|
|
16
|
-
**Three commands to give your AI agent full codebase awareness.**
|
|
17
|
-
|
|
18
|
-
## Quick Start
|
|
19
|
-
|
|
20
|
-
```bash
|
|
21
|
-
# Index your repo (run from repo root)
|
|
22
|
-
npx gitnexus analyze
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
That's it. This indexes the codebase, installs agent skills, registers Claude Code hooks, and creates `AGENTS.md` / `CLAUDE.md` context files — all in one command.
|
|
26
|
-
|
|
27
|
-
To configure MCP for your editor, run `npx gitnexus setup` once — or set it up manually below.
|
|
28
|
-
|
|
29
|
-
`gitnexus setup` auto-detects your editors and writes the correct global MCP config. You only need to run it once.
|
|
30
|
-
|
|
31
|
-
### Editor Support
|
|
32
|
-
|
|
33
|
-
| Editor | MCP | Skills | Hooks (auto-augment) | Support |
|
|
34
|
-
|--------|-----|--------|---------------------|---------|
|
|
35
|
-
| **Claude Code** | Yes | Yes | Yes (PreToolUse) | **Full** |
|
|
36
|
-
| **Cursor** | Yes | Yes | — | MCP + Skills |
|
|
37
|
-
| **Windsurf** | Yes | — | — | MCP |
|
|
38
|
-
| **OpenCode** | Yes | Yes | — | MCP + Skills |
|
|
39
|
-
|
|
40
|
-
> **Claude Code** gets the deepest integration: MCP tools + agent skills + PreToolUse hooks that automatically enrich grep/glob/bash calls with knowledge graph context.
|
|
41
|
-
|
|
42
|
-
### Community Integrations
|
|
43
|
-
|
|
44
|
-
| Agent | Install | Source |
|
|
45
|
-
|-------|---------|--------|
|
|
46
|
-
| [pi](https://pi.dev) | `pi install npm:pi-gitnexus` | [pi-gitnexus](https://github.com/tintinweb/pi-gitnexus) |
|
|
47
|
-
|
|
48
|
-
## MCP Setup (manual)
|
|
49
|
-
|
|
50
|
-
If you prefer to configure manually instead of using `gitnexus setup`:
|
|
51
|
-
|
|
52
|
-
### Claude Code (full support — MCP + skills + hooks)
|
|
53
|
-
|
|
54
|
-
```bash
|
|
55
|
-
claude mcp add gitnexus -- npx -y gitnexus@latest mcp
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
### Cursor / Windsurf
|
|
59
|
-
|
|
60
|
-
Add to `~/.cursor/mcp.json` (global — works for all projects):
|
|
61
|
-
|
|
62
|
-
```json
|
|
63
|
-
{
|
|
64
|
-
"mcpServers": {
|
|
65
|
-
"gitnexus": {
|
|
66
|
-
"command": "npx",
|
|
67
|
-
"args": ["-y", "gitnexus@latest", "mcp"]
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
### OpenCode
|
|
74
|
-
|
|
75
|
-
Add to `~/.config/opencode/config.json`:
|
|
76
|
-
|
|
77
|
-
```json
|
|
78
|
-
{
|
|
79
|
-
"mcp": {
|
|
80
|
-
"gitnexus": {
|
|
81
|
-
"command": "npx",
|
|
82
|
-
"args": ["-y", "gitnexus@latest", "mcp"]
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
## How It Works
|
|
89
|
-
|
|
90
|
-
GitNexus builds a complete knowledge graph of your codebase through a multi-phase indexing pipeline:
|
|
91
|
-
|
|
92
|
-
1. **Structure** — Walks the file tree and maps folder/file relationships
|
|
93
|
-
2. **Parsing** — Extracts functions, classes, methods, and interfaces using Tree-sitter ASTs
|
|
94
|
-
3. **Resolution** — Resolves imports and function calls across files with language-aware logic
|
|
95
|
-
4. **Clustering** — Groups related symbols into functional communities
|
|
96
|
-
5. **Processes** — Traces execution flows from entry points through call chains
|
|
97
|
-
6. **Search** — Builds hybrid search indexes for fast retrieval
|
|
98
|
-
|
|
99
|
-
The result is a **KuzuDB graph database** stored locally in `.gitnexus/` with full-text search and semantic embeddings.
|
|
100
|
-
|
|
101
|
-
## MCP Tools
|
|
102
|
-
|
|
103
|
-
Your AI agent gets these tools automatically:
|
|
104
|
-
|
|
105
|
-
| Tool | What It Does | `repo` Param |
|
|
106
|
-
|------|-------------|--------------|
|
|
107
|
-
| `list_repos` | Discover all indexed repositories | — |
|
|
108
|
-
| `query` | Process-grouped hybrid search (BM25 + semantic + RRF) | Optional |
|
|
109
|
-
| `context` | 360-degree symbol view — categorized refs, process participation | Optional |
|
|
110
|
-
| `impact` | Blast radius analysis with depth grouping and confidence | Optional |
|
|
111
|
-
| `detect_changes` | Git-diff impact — maps changed lines to affected processes | Optional |
|
|
112
|
-
| `rename` | Multi-file coordinated rename with graph + text search | Optional |
|
|
113
|
-
| `cypher` | Raw Cypher graph queries | Optional |
|
|
114
|
-
|
|
115
|
-
> With one indexed repo, the `repo` param is optional. With multiple, specify which: `query({query: "auth", repo: "my-app"})`.
|
|
116
|
-
|
|
117
|
-
## MCP Resources
|
|
118
|
-
|
|
119
|
-
| Resource | Purpose |
|
|
120
|
-
|----------|---------|
|
|
121
|
-
| `gitnexus://repos` | List all indexed repositories (read first) |
|
|
122
|
-
| `gitnexus://repo/{name}/context` | Codebase stats, staleness check, and available tools |
|
|
123
|
-
| `gitnexus://repo/{name}/clusters` | All functional clusters with cohesion scores |
|
|
124
|
-
| `gitnexus://repo/{name}/cluster/{name}` | Cluster members and details |
|
|
125
|
-
| `gitnexus://repo/{name}/processes` | All execution flows |
|
|
126
|
-
| `gitnexus://repo/{name}/process/{name}` | Full process trace with steps |
|
|
127
|
-
| `gitnexus://repo/{name}/schema` | Graph schema for Cypher queries |
|
|
128
|
-
|
|
129
|
-
## MCP Prompts
|
|
130
|
-
|
|
131
|
-
| Prompt | What It Does |
|
|
132
|
-
|--------|-------------|
|
|
133
|
-
| `detect_impact` | Pre-commit change analysis — scope, affected processes, risk level |
|
|
134
|
-
| `generate_map` | Architecture documentation from the knowledge graph with mermaid diagrams |
|
|
135
|
-
|
|
136
|
-
## CLI Commands
|
|
137
|
-
|
|
138
|
-
```bash
|
|
139
|
-
gitnexus setup # Configure MCP for your editors (one-time)
|
|
140
|
-
gitnexus analyze [path] # Index a repository (or update stale index)
|
|
141
|
-
gitnexus analyze --force # Force full re-index
|
|
142
|
-
gitnexus analyze --skip-embeddings # Skip embedding generation (faster)
|
|
143
|
-
gitnexus mcp # Start MCP server (stdio) — serves all indexed repos
|
|
144
|
-
gitnexus serve # Start local HTTP server (multi-repo) for web UI
|
|
145
|
-
gitnexus list # List all indexed repositories
|
|
146
|
-
gitnexus status # Show index status for current repo
|
|
147
|
-
gitnexus clean # Delete index for current repo
|
|
148
|
-
gitnexus clean --all --force # Delete all indexes
|
|
149
|
-
gitnexus wiki [path] # Generate LLM-powered docs from knowledge graph
|
|
150
|
-
gitnexus wiki --model <model> # Wiki with custom LLM model (default: gpt-4o-mini)
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
## Multi-Repo Support
|
|
154
|
-
|
|
155
|
-
GitNexus supports indexing multiple repositories. Each `gitnexus analyze` registers the repo in a global registry (`~/.gitnexus/registry.json`). The MCP server serves all indexed repos automatically.
|
|
156
|
-
|
|
157
|
-
## Supported Languages
|
|
158
|
-
|
|
159
|
-
TypeScript, JavaScript, Python, Java, C, C++, C#, Go, Rust, PHP, Swift
|
|
160
|
-
|
|
161
|
-
## Agent Skills
|
|
162
|
-
|
|
163
|
-
GitNexus ships with skill files that teach AI agents how to use the tools effectively:
|
|
164
|
-
|
|
165
|
-
- **Exploring** — Navigate unfamiliar code using the knowledge graph
|
|
166
|
-
- **Debugging** — Trace bugs through call chains
|
|
167
|
-
- **Impact Analysis** — Analyze blast radius before changes
|
|
168
|
-
- **Refactoring** — Plan safe refactors using dependency mapping
|
|
169
|
-
|
|
170
|
-
Installed automatically by both `gitnexus analyze` (per-repo) and `gitnexus setup` (global).
|
|
171
|
-
|
|
172
|
-
## Requirements
|
|
173
|
-
|
|
174
|
-
- Node.js >= 18
|
|
175
|
-
- Git repository (uses git for commit tracking)
|
|
176
|
-
|
|
177
|
-
## Privacy
|
|
178
|
-
|
|
179
|
-
- All processing happens locally on your machine
|
|
180
|
-
- No code is sent to any server
|
|
181
|
-
- Index stored in `.gitnexus/` inside your repo (gitignored)
|
|
182
|
-
- Global registry at `~/.gitnexus/` stores only paths and metadata
|
|
183
|
-
|
|
184
|
-
## Web UI
|
|
185
|
-
|
|
186
|
-
GitNexus also has a browser-based UI at [gitnexus.vercel.app](https://gitnexus.vercel.app) — 100% client-side, your code never leaves the browser.
|
|
187
|
-
|
|
188
|
-
**Local Backend Mode:** Run `gitnexus serve` and open the web UI locally — it auto-detects the server and shows all your indexed repos, with full AI chat support. No need to re-upload or re-index. The agent's tools (Cypher queries, search, code navigation) route through the backend HTTP API automatically.
|
|
189
|
-
|
|
190
|
-
## License
|
|
191
|
-
|
|
192
|
-
[PolyForm Noncommercial 1.0.0](https://polyformproject.org/licenses/noncommercial/1.0.0/)
|
|
193
|
-
|
|
194
|
-
Free for non-commercial use. Contact for commercial licensing.
|
|
1
|
+
# GitNexus
|
|
2
|
+
|
|
3
|
+
**Graph-powered code intelligence for AI agents.** Index any codebase into a knowledge graph, then query it via MCP or CLI.
|
|
4
|
+
|
|
5
|
+
Works with **Cursor**, **Claude Code**, **Windsurf**, **Cline**, **OpenCode**, and any MCP-compatible tool.
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/gitnexus)
|
|
8
|
+
[](https://polyformproject.org/licenses/noncommercial/1.0.0/)
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Why?
|
|
13
|
+
|
|
14
|
+
AI coding tools don't understand your codebase structure. They edit a function without knowing 47 other functions depend on it. GitNexus fixes this by **precomputing every dependency, call chain, and relationship** into a queryable graph.
|
|
15
|
+
|
|
16
|
+
**Three commands to give your AI agent full codebase awareness.**
|
|
17
|
+
|
|
18
|
+
## Quick Start
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# Index your repo (run from repo root)
|
|
22
|
+
npx gitnexus analyze
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
That's it. This indexes the codebase, installs agent skills, registers Claude Code hooks, and creates `AGENTS.md` / `CLAUDE.md` context files — all in one command.
|
|
26
|
+
|
|
27
|
+
To configure MCP for your editor, run `npx gitnexus setup` once — or set it up manually below.
|
|
28
|
+
|
|
29
|
+
`gitnexus setup` auto-detects your editors and writes the correct global MCP config. You only need to run it once.
|
|
30
|
+
|
|
31
|
+
### Editor Support
|
|
32
|
+
|
|
33
|
+
| Editor | MCP | Skills | Hooks (auto-augment) | Support |
|
|
34
|
+
|--------|-----|--------|---------------------|---------|
|
|
35
|
+
| **Claude Code** | Yes | Yes | Yes (PreToolUse) | **Full** |
|
|
36
|
+
| **Cursor** | Yes | Yes | — | MCP + Skills |
|
|
37
|
+
| **Windsurf** | Yes | — | — | MCP |
|
|
38
|
+
| **OpenCode** | Yes | Yes | — | MCP + Skills |
|
|
39
|
+
|
|
40
|
+
> **Claude Code** gets the deepest integration: MCP tools + agent skills + PreToolUse hooks that automatically enrich grep/glob/bash calls with knowledge graph context.
|
|
41
|
+
|
|
42
|
+
### Community Integrations
|
|
43
|
+
|
|
44
|
+
| Agent | Install | Source |
|
|
45
|
+
|-------|---------|--------|
|
|
46
|
+
| [pi](https://pi.dev) | `pi install npm:pi-gitnexus` | [pi-gitnexus](https://github.com/tintinweb/pi-gitnexus) |
|
|
47
|
+
|
|
48
|
+
## MCP Setup (manual)
|
|
49
|
+
|
|
50
|
+
If you prefer to configure manually instead of using `gitnexus setup`:
|
|
51
|
+
|
|
52
|
+
### Claude Code (full support — MCP + skills + hooks)
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
claude mcp add gitnexus -- npx -y gitnexus@latest mcp
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Cursor / Windsurf
|
|
59
|
+
|
|
60
|
+
Add to `~/.cursor/mcp.json` (global — works for all projects):
|
|
61
|
+
|
|
62
|
+
```json
|
|
63
|
+
{
|
|
64
|
+
"mcpServers": {
|
|
65
|
+
"gitnexus": {
|
|
66
|
+
"command": "npx",
|
|
67
|
+
"args": ["-y", "gitnexus@latest", "mcp"]
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### OpenCode
|
|
74
|
+
|
|
75
|
+
Add to `~/.config/opencode/config.json`:
|
|
76
|
+
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"mcp": {
|
|
80
|
+
"gitnexus": {
|
|
81
|
+
"command": "npx",
|
|
82
|
+
"args": ["-y", "gitnexus@latest", "mcp"]
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## How It Works
|
|
89
|
+
|
|
90
|
+
GitNexus builds a complete knowledge graph of your codebase through a multi-phase indexing pipeline:
|
|
91
|
+
|
|
92
|
+
1. **Structure** — Walks the file tree and maps folder/file relationships
|
|
93
|
+
2. **Parsing** — Extracts functions, classes, methods, and interfaces using Tree-sitter ASTs
|
|
94
|
+
3. **Resolution** — Resolves imports and function calls across files with language-aware logic
|
|
95
|
+
4. **Clustering** — Groups related symbols into functional communities
|
|
96
|
+
5. **Processes** — Traces execution flows from entry points through call chains
|
|
97
|
+
6. **Search** — Builds hybrid search indexes for fast retrieval
|
|
98
|
+
|
|
99
|
+
The result is a **KuzuDB graph database** stored locally in `.gitnexus/` with full-text search and semantic embeddings.
|
|
100
|
+
|
|
101
|
+
## MCP Tools
|
|
102
|
+
|
|
103
|
+
Your AI agent gets these tools automatically:
|
|
104
|
+
|
|
105
|
+
| Tool | What It Does | `repo` Param |
|
|
106
|
+
|------|-------------|--------------|
|
|
107
|
+
| `list_repos` | Discover all indexed repositories | — |
|
|
108
|
+
| `query` | Process-grouped hybrid search (BM25 + semantic + RRF) | Optional |
|
|
109
|
+
| `context` | 360-degree symbol view — categorized refs, process participation | Optional |
|
|
110
|
+
| `impact` | Blast radius analysis with depth grouping and confidence | Optional |
|
|
111
|
+
| `detect_changes` | Git-diff impact — maps changed lines to affected processes | Optional |
|
|
112
|
+
| `rename` | Multi-file coordinated rename with graph + text search | Optional |
|
|
113
|
+
| `cypher` | Raw Cypher graph queries | Optional |
|
|
114
|
+
|
|
115
|
+
> With one indexed repo, the `repo` param is optional. With multiple, specify which: `query({query: "auth", repo: "my-app"})`.
|
|
116
|
+
|
|
117
|
+
## MCP Resources
|
|
118
|
+
|
|
119
|
+
| Resource | Purpose |
|
|
120
|
+
|----------|---------|
|
|
121
|
+
| `gitnexus://repos` | List all indexed repositories (read first) |
|
|
122
|
+
| `gitnexus://repo/{name}/context` | Codebase stats, staleness check, and available tools |
|
|
123
|
+
| `gitnexus://repo/{name}/clusters` | All functional clusters with cohesion scores |
|
|
124
|
+
| `gitnexus://repo/{name}/cluster/{name}` | Cluster members and details |
|
|
125
|
+
| `gitnexus://repo/{name}/processes` | All execution flows |
|
|
126
|
+
| `gitnexus://repo/{name}/process/{name}` | Full process trace with steps |
|
|
127
|
+
| `gitnexus://repo/{name}/schema` | Graph schema for Cypher queries |
|
|
128
|
+
|
|
129
|
+
## MCP Prompts
|
|
130
|
+
|
|
131
|
+
| Prompt | What It Does |
|
|
132
|
+
|--------|-------------|
|
|
133
|
+
| `detect_impact` | Pre-commit change analysis — scope, affected processes, risk level |
|
|
134
|
+
| `generate_map` | Architecture documentation from the knowledge graph with mermaid diagrams |
|
|
135
|
+
|
|
136
|
+
## CLI Commands
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
gitnexus setup # Configure MCP for your editors (one-time)
|
|
140
|
+
gitnexus analyze [path] # Index a repository (or update stale index)
|
|
141
|
+
gitnexus analyze --force # Force full re-index
|
|
142
|
+
gitnexus analyze --skip-embeddings # Skip embedding generation (faster)
|
|
143
|
+
gitnexus mcp # Start MCP server (stdio) — serves all indexed repos
|
|
144
|
+
gitnexus serve # Start local HTTP server (multi-repo) for web UI
|
|
145
|
+
gitnexus list # List all indexed repositories
|
|
146
|
+
gitnexus status # Show index status for current repo
|
|
147
|
+
gitnexus clean # Delete index for current repo
|
|
148
|
+
gitnexus clean --all --force # Delete all indexes
|
|
149
|
+
gitnexus wiki [path] # Generate LLM-powered docs from knowledge graph
|
|
150
|
+
gitnexus wiki --model <model> # Wiki with custom LLM model (default: gpt-4o-mini)
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Multi-Repo Support
|
|
154
|
+
|
|
155
|
+
GitNexus supports indexing multiple repositories. Each `gitnexus analyze` registers the repo in a global registry (`~/.gitnexus/registry.json`). The MCP server serves all indexed repos automatically.
|
|
156
|
+
|
|
157
|
+
## Supported Languages
|
|
158
|
+
|
|
159
|
+
TypeScript, JavaScript, Python, Java, C, C++, C#, Go, Rust, PHP, Swift
|
|
160
|
+
|
|
161
|
+
## Agent Skills
|
|
162
|
+
|
|
163
|
+
GitNexus ships with skill files that teach AI agents how to use the tools effectively:
|
|
164
|
+
|
|
165
|
+
- **Exploring** — Navigate unfamiliar code using the knowledge graph
|
|
166
|
+
- **Debugging** — Trace bugs through call chains
|
|
167
|
+
- **Impact Analysis** — Analyze blast radius before changes
|
|
168
|
+
- **Refactoring** — Plan safe refactors using dependency mapping
|
|
169
|
+
|
|
170
|
+
Installed automatically by both `gitnexus analyze` (per-repo) and `gitnexus setup` (global).
|
|
171
|
+
|
|
172
|
+
## Requirements
|
|
173
|
+
|
|
174
|
+
- Node.js >= 18
|
|
175
|
+
- Git repository (uses git for commit tracking)
|
|
176
|
+
|
|
177
|
+
## Privacy
|
|
178
|
+
|
|
179
|
+
- All processing happens locally on your machine
|
|
180
|
+
- No code is sent to any server
|
|
181
|
+
- Index stored in `.gitnexus/` inside your repo (gitignored)
|
|
182
|
+
- Global registry at `~/.gitnexus/` stores only paths and metadata
|
|
183
|
+
|
|
184
|
+
## Web UI
|
|
185
|
+
|
|
186
|
+
GitNexus also has a browser-based UI at [gitnexus.vercel.app](https://gitnexus.vercel.app) — 100% client-side, your code never leaves the browser.
|
|
187
|
+
|
|
188
|
+
**Local Backend Mode:** Run `gitnexus serve` and open the web UI locally — it auto-detects the server and shows all your indexed repos, with full AI chat support. No need to re-upload or re-index. The agent's tools (Cypher queries, search, code navigation) route through the backend HTTP API automatically.
|
|
189
|
+
|
|
190
|
+
## License
|
|
191
|
+
|
|
192
|
+
[PolyForm Noncommercial 1.0.0](https://polyformproject.org/licenses/noncommercial/1.0.0/)
|
|
193
|
+
|
|
194
|
+
Free for non-commercial use. Contact for commercial licensing.
|
package/dist/cli/ai-context.js
CHANGED
|
@@ -25,101 +25,83 @@ const GITNEXUS_END_MARKER = '<!-- gitnexus:end -->';
|
|
|
25
25
|
* - Self-review checklist — forces model to verify its own work
|
|
26
26
|
*/
|
|
27
27
|
function generateGitNexusContent(projectName, stats) {
|
|
28
|
-
return `${GITNEXUS_START_MARKER}
|
|
29
|
-
# GitNexus — Code Intelligence
|
|
30
|
-
|
|
31
|
-
This project is indexed by GitNexus as **${projectName}** (${stats.nodes || 0} symbols, ${stats.edges || 0} relationships, ${stats.processes || 0} execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely.
|
|
32
|
-
|
|
33
|
-
> If any GitNexus tool warns the index is stale, run \`npx gitnexus analyze\` in terminal first.
|
|
34
|
-
|
|
35
|
-
## Always Do
|
|
36
|
-
|
|
37
|
-
- **MUST run impact analysis before editing any symbol.** Before modifying a function, class, or method, run \`gitnexus_impact({target: "symbolName", direction: "upstream"})\` and report the blast radius (direct callers, affected processes, risk level) to the user.
|
|
38
|
-
- **MUST run \`gitnexus_detect_changes()\` before committing** to verify your changes only affect expected symbols and execution flows.
|
|
39
|
-
- **MUST warn the user** if impact analysis returns HIGH or CRITICAL risk before proceeding with edits.
|
|
40
|
-
- When exploring unfamiliar code, use \`gitnexus_query({query: "concept"})\` to find execution flows instead of grepping. It returns process-grouped results ranked by relevance.
|
|
41
|
-
- When you need full context on a specific symbol — callers, callees, which execution flows it participates in — use \`gitnexus_context({name: "symbolName"})\`.
|
|
42
|
-
|
|
43
|
-
## When Debugging
|
|
44
|
-
|
|
45
|
-
1. \`gitnexus_query({query: "<error or symptom>"})\` — find execution flows related to the issue
|
|
46
|
-
2. \`gitnexus_context({name: "<suspect function>"})\` — see all callers, callees, and process participation
|
|
47
|
-
3. \`READ gitnexus://repo/${projectName}/process/{processName}\` — trace the full execution flow step by step
|
|
48
|
-
4. For regressions: \`gitnexus_detect_changes({scope: "compare", base_ref: "main"})\` — see what your branch changed
|
|
49
|
-
|
|
50
|
-
## When Refactoring
|
|
51
|
-
|
|
52
|
-
- **Renaming**: MUST use \`gitnexus_rename({symbol_name: "old", new_name: "new", dry_run: true})\` first. Review the preview — graph edits are safe, text_search edits need manual review. Then run with \`dry_run: false\`.
|
|
53
|
-
- **Extracting/Splitting**: MUST run \`gitnexus_context({name: "target"})\` to see all incoming/outgoing refs, then \`gitnexus_impact({target: "target", direction: "upstream"})\` to find all external callers before moving code.
|
|
54
|
-
- After any refactor: run \`gitnexus_detect_changes({scope: "all"})\` to verify only expected files changed.
|
|
55
|
-
|
|
56
|
-
## Never Do
|
|
57
|
-
|
|
58
|
-
- NEVER edit a function, class, or method without first running \`gitnexus_impact\` on it.
|
|
59
|
-
- NEVER ignore HIGH or CRITICAL risk warnings from impact analysis.
|
|
60
|
-
- NEVER rename symbols with find-and-replace — use \`gitnexus_rename\` which understands the call graph.
|
|
61
|
-
- NEVER commit changes without running \`gitnexus_detect_changes()\` to check affected scope.
|
|
62
|
-
|
|
63
|
-
## Tools Quick Reference
|
|
64
|
-
|
|
65
|
-
| Tool | When to use | Command |
|
|
66
|
-
|------|-------------|---------|
|
|
67
|
-
| \`query\` | Find code by concept | \`gitnexus_query({query: "auth validation"})\` |
|
|
68
|
-
| \`context\` | 360-degree view of one symbol | \`gitnexus_context({name: "validateUser"})\` |
|
|
69
|
-
| \`impact\` | Blast radius before editing | \`gitnexus_impact({target: "X", direction: "upstream"})\` |
|
|
70
|
-
| \`detect_changes\` | Pre-commit scope check | \`gitnexus_detect_changes({scope: "staged"})\` |
|
|
71
|
-
| \`rename\` | Safe multi-file rename | \`gitnexus_rename({symbol_name: "old", new_name: "new", dry_run: true})\` |
|
|
72
|
-
| \`cypher\` | Custom graph queries | \`gitnexus_cypher({query: "MATCH ..."})\` |
|
|
73
|
-
|
|
74
|
-
## Impact Risk Levels
|
|
75
|
-
|
|
76
|
-
| Depth | Meaning | Action |
|
|
77
|
-
|-------|---------|--------|
|
|
78
|
-
| d=1 | WILL BREAK — direct callers/importers | MUST update these |
|
|
79
|
-
| d=2 | LIKELY AFFECTED — indirect deps | Should test |
|
|
80
|
-
| d=3 | MAY NEED TESTING — transitive | Test if critical path |
|
|
81
|
-
|
|
82
|
-
## Resources
|
|
83
|
-
|
|
84
|
-
| Resource | Use for |
|
|
85
|
-
|----------|---------|
|
|
86
|
-
| \`gitnexus://repo/${projectName}/context\` | Codebase overview, check index freshness |
|
|
87
|
-
| \`gitnexus://repo/${projectName}/clusters\` | All functional areas |
|
|
88
|
-
| \`gitnexus://repo/${projectName}/processes\` | All execution flows |
|
|
89
|
-
| \`gitnexus://repo/${projectName}/process/{name}\` | Step-by-step execution trace |
|
|
90
|
-
|
|
91
|
-
## Self-Check Before Finishing
|
|
92
|
-
|
|
93
|
-
Before completing any code modification task, verify:
|
|
94
|
-
1. \`gitnexus_impact\` was run for all modified symbols
|
|
95
|
-
2. No HIGH/CRITICAL risk warnings were ignored
|
|
96
|
-
3. \`gitnexus_detect_changes()\` confirms changes match expected scope
|
|
97
|
-
4. All d=1 (WILL BREAK) dependents were updated
|
|
98
|
-
|
|
99
|
-
##
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
\`\`\`
|
|
106
|
-
|
|
107
|
-
If the index previously included embeddings, preserve them by adding \`--embeddings\`:
|
|
108
|
-
|
|
109
|
-
\`\`\`bash
|
|
110
|
-
npx gitnexus analyze --embeddings
|
|
111
|
-
\`\`\`
|
|
112
|
-
|
|
113
|
-
To check whether embeddings exist, inspect \`.gitnexus/meta.json\` — the \`stats.embeddings\` field shows the count (0 means no embeddings). **Running analyze without \`--embeddings\` will delete any previously generated embeddings.**
|
|
114
|
-
|
|
115
|
-
> Claude Code users: A PostToolUse hook handles this automatically after \`git commit\` and \`git merge\`.
|
|
116
|
-
|
|
117
|
-
## CLI
|
|
118
|
-
|
|
119
|
-
- Re-index: \`npx gitnexus analyze\`
|
|
120
|
-
- Check freshness: \`npx gitnexus status\`
|
|
121
|
-
- Generate docs: \`npx gitnexus wiki\`
|
|
122
|
-
|
|
28
|
+
return `${GITNEXUS_START_MARKER}
|
|
29
|
+
# GitNexus — Code Intelligence
|
|
30
|
+
|
|
31
|
+
This project is indexed by GitNexus as **${projectName}** (${stats.nodes || 0} symbols, ${stats.edges || 0} relationships, ${stats.processes || 0} execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely.
|
|
32
|
+
|
|
33
|
+
> If any GitNexus tool warns the index is stale, run \`npx gitnexus analyze\` in terminal first.
|
|
34
|
+
|
|
35
|
+
## Always Do
|
|
36
|
+
|
|
37
|
+
- **MUST run impact analysis before editing any symbol.** Before modifying a function, class, or method, run \`gitnexus_impact({target: "symbolName", direction: "upstream"})\` and report the blast radius (direct callers, affected processes, risk level) to the user.
|
|
38
|
+
- **MUST run \`gitnexus_detect_changes()\` before committing** to verify your changes only affect expected symbols and execution flows.
|
|
39
|
+
- **MUST warn the user** if impact analysis returns HIGH or CRITICAL risk before proceeding with edits.
|
|
40
|
+
- When exploring unfamiliar code, use \`gitnexus_query({query: "concept"})\` to find execution flows instead of grepping. It returns process-grouped results ranked by relevance.
|
|
41
|
+
- When you need full context on a specific symbol — callers, callees, which execution flows it participates in — use \`gitnexus_context({name: "symbolName"})\`.
|
|
42
|
+
|
|
43
|
+
## When Debugging
|
|
44
|
+
|
|
45
|
+
1. \`gitnexus_query({query: "<error or symptom>"})\` — find execution flows related to the issue
|
|
46
|
+
2. \`gitnexus_context({name: "<suspect function>"})\` — see all callers, callees, and process participation
|
|
47
|
+
3. \`READ gitnexus://repo/${projectName}/process/{processName}\` — trace the full execution flow step by step
|
|
48
|
+
4. For regressions: \`gitnexus_detect_changes({scope: "compare", base_ref: "main"})\` — see what your branch changed
|
|
49
|
+
|
|
50
|
+
## When Refactoring
|
|
51
|
+
|
|
52
|
+
- **Renaming**: MUST use \`gitnexus_rename({symbol_name: "old", new_name: "new", dry_run: true})\` first. Review the preview — graph edits are safe, text_search edits need manual review. Then run with \`dry_run: false\`.
|
|
53
|
+
- **Extracting/Splitting**: MUST run \`gitnexus_context({name: "target"})\` to see all incoming/outgoing refs, then \`gitnexus_impact({target: "target", direction: "upstream"})\` to find all external callers before moving code.
|
|
54
|
+
- After any refactor: run \`gitnexus_detect_changes({scope: "all"})\` to verify only expected files changed.
|
|
55
|
+
|
|
56
|
+
## Never Do
|
|
57
|
+
|
|
58
|
+
- NEVER edit a function, class, or method without first running \`gitnexus_impact\` on it.
|
|
59
|
+
- NEVER ignore HIGH or CRITICAL risk warnings from impact analysis.
|
|
60
|
+
- NEVER rename symbols with find-and-replace — use \`gitnexus_rename\` which understands the call graph.
|
|
61
|
+
- NEVER commit changes without running \`gitnexus_detect_changes()\` to check affected scope.
|
|
62
|
+
|
|
63
|
+
## Tools Quick Reference
|
|
64
|
+
|
|
65
|
+
| Tool | When to use | Command |
|
|
66
|
+
|------|-------------|---------|
|
|
67
|
+
| \`query\` | Find code by concept | \`gitnexus_query({query: "auth validation"})\` |
|
|
68
|
+
| \`context\` | 360-degree view of one symbol | \`gitnexus_context({name: "validateUser"})\` |
|
|
69
|
+
| \`impact\` | Blast radius before editing | \`gitnexus_impact({target: "X", direction: "upstream"})\` |
|
|
70
|
+
| \`detect_changes\` | Pre-commit scope check | \`gitnexus_detect_changes({scope: "staged"})\` |
|
|
71
|
+
| \`rename\` | Safe multi-file rename | \`gitnexus_rename({symbol_name: "old", new_name: "new", dry_run: true})\` |
|
|
72
|
+
| \`cypher\` | Custom graph queries | \`gitnexus_cypher({query: "MATCH ..."})\` |
|
|
73
|
+
|
|
74
|
+
## Impact Risk Levels
|
|
75
|
+
|
|
76
|
+
| Depth | Meaning | Action |
|
|
77
|
+
|-------|---------|--------|
|
|
78
|
+
| d=1 | WILL BREAK — direct callers/importers | MUST update these |
|
|
79
|
+
| d=2 | LIKELY AFFECTED — indirect deps | Should test |
|
|
80
|
+
| d=3 | MAY NEED TESTING — transitive | Test if critical path |
|
|
81
|
+
|
|
82
|
+
## Resources
|
|
83
|
+
|
|
84
|
+
| Resource | Use for |
|
|
85
|
+
|----------|---------|
|
|
86
|
+
| \`gitnexus://repo/${projectName}/context\` | Codebase overview, check index freshness |
|
|
87
|
+
| \`gitnexus://repo/${projectName}/clusters\` | All functional areas |
|
|
88
|
+
| \`gitnexus://repo/${projectName}/processes\` | All execution flows |
|
|
89
|
+
| \`gitnexus://repo/${projectName}/process/{name}\` | Step-by-step execution trace |
|
|
90
|
+
|
|
91
|
+
## Self-Check Before Finishing
|
|
92
|
+
|
|
93
|
+
Before completing any code modification task, verify:
|
|
94
|
+
1. \`gitnexus_impact\` was run for all modified symbols
|
|
95
|
+
2. No HIGH/CRITICAL risk warnings were ignored
|
|
96
|
+
3. \`gitnexus_detect_changes()\` confirms changes match expected scope
|
|
97
|
+
4. All d=1 (WILL BREAK) dependents were updated
|
|
98
|
+
|
|
99
|
+
## CLI
|
|
100
|
+
|
|
101
|
+
- Re-index: \`npx gitnexus analyze\`
|
|
102
|
+
- Check freshness: \`npx gitnexus status\`
|
|
103
|
+
- Generate docs: \`npx gitnexus wiki\`
|
|
104
|
+
|
|
123
105
|
${GITNEXUS_END_MARKER}`;
|
|
124
106
|
}
|
|
125
107
|
/**
|
|
@@ -211,16 +193,16 @@ async function installSkills(repoPath) {
|
|
|
211
193
|
}
|
|
212
194
|
catch {
|
|
213
195
|
// Fallback: generate minimal skill content
|
|
214
|
-
skillContent = `---
|
|
215
|
-
name: ${skill.name}
|
|
216
|
-
description: ${skill.description}
|
|
217
|
-
---
|
|
218
|
-
|
|
219
|
-
# ${skill.name.charAt(0).toUpperCase() + skill.name.slice(1)}
|
|
220
|
-
|
|
221
|
-
${skill.description}
|
|
222
|
-
|
|
223
|
-
Use GitNexus tools to accomplish this task.
|
|
196
|
+
skillContent = `---
|
|
197
|
+
name: ${skill.name}
|
|
198
|
+
description: ${skill.description}
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
# ${skill.name.charAt(0).toUpperCase() + skill.name.slice(1)}
|
|
202
|
+
|
|
203
|
+
${skill.description}
|
|
204
|
+
|
|
205
|
+
Use GitNexus tools to accomplish this task.
|
|
224
206
|
`;
|
|
225
207
|
}
|
|
226
208
|
await fs.writeFile(skillPath, skillContent, 'utf-8');
|
package/dist/cli/analyze.js
CHANGED
|
@@ -242,13 +242,6 @@ export const analyzeCommand = async (inputPath, options) => {
|
|
|
242
242
|
}
|
|
243
243
|
// ── Phase 5: Finalize (98–100%) ───────────────────────────────────
|
|
244
244
|
updateBar(98, 'Saving metadata...');
|
|
245
|
-
// Count embeddings in the index (cached + newly generated)
|
|
246
|
-
let embeddingCount = 0;
|
|
247
|
-
try {
|
|
248
|
-
const embResult = await executeQuery(`MATCH (e:CodeEmbedding) RETURN count(e) AS cnt`);
|
|
249
|
-
embeddingCount = embResult?.[0]?.cnt ?? 0;
|
|
250
|
-
}
|
|
251
|
-
catch { /* table may not exist if embeddings never ran */ }
|
|
252
245
|
const meta = {
|
|
253
246
|
repoPath,
|
|
254
247
|
lastCommit: currentCommit,
|
|
@@ -259,7 +252,6 @@ export const analyzeCommand = async (inputPath, options) => {
|
|
|
259
252
|
edges: stats.edges,
|
|
260
253
|
communities: pipelineResult.communityResult?.stats.totalCommunities,
|
|
261
254
|
processes: pipelineResult.processResult?.stats.totalProcesses,
|
|
262
|
-
embeddings: embeddingCount,
|
|
263
255
|
},
|
|
264
256
|
};
|
|
265
257
|
await saveMeta(storagePath, meta);
|