gitnexus 1.2.5 → 1.2.7
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 +186 -187
- package/dist/cli/ai-context.js +71 -71
- package/dist/cli/eval-server.js +1 -1
- package/dist/cli/mcp.js +1 -1
- package/dist/core/embeddings/embedder.js +6 -0
- package/dist/core/ingestion/filesystem-walker.js +17 -3
- package/dist/core/ingestion/parsing-processor.js +4 -1
- package/dist/core/ingestion/tree-sitter-queries.js +282 -282
- package/dist/core/ingestion/workers/parse-worker.js +13 -4
- package/dist/core/ingestion/workers/worker-pool.js +43 -9
- package/dist/core/kuzu/schema.js +256 -256
- package/dist/core/search/bm25-index.js +5 -5
- package/dist/core/wiki/html-viewer.js +192 -192
- package/dist/mcp/core/kuzu-adapter.d.ts +17 -9
- package/dist/mcp/core/kuzu-adapter.js +99 -25
- package/dist/mcp/local/local-backend.d.ts +18 -3
- package/dist/mcp/local/local-backend.js +169 -125
- package/dist/mcp/resources.js +46 -46
- package/dist/mcp/server.js +16 -16
- package/dist/mcp/tools.js +77 -77
- package/package.json +82 -82
- package/skills/debugging.md +85 -85
- package/skills/exploring.md +75 -75
- package/skills/impact-analysis.md +94 -94
- package/skills/refactoring.md +113 -113
package/skills/debugging.md
CHANGED
|
@@ -1,85 +1,85 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: gitnexus-debugging
|
|
3
|
-
description: Trace bugs through call chains using knowledge graph
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Debugging with GitNexus
|
|
7
|
-
|
|
8
|
-
## When to Use
|
|
9
|
-
- "Why is this function failing?"
|
|
10
|
-
- "Trace where this error comes from"
|
|
11
|
-
- "Who calls this method?"
|
|
12
|
-
- "This endpoint returns 500"
|
|
13
|
-
- Investigating bugs, errors, or unexpected behavior
|
|
14
|
-
|
|
15
|
-
## Workflow
|
|
16
|
-
|
|
17
|
-
```
|
|
18
|
-
1. gitnexus_query({query: "<error or symptom>"}) → Find related execution flows
|
|
19
|
-
2. gitnexus_context({name: "<suspect>"}) → See callers/callees/processes
|
|
20
|
-
3. READ gitnexus://repo/{name}/process/{name} → Trace execution flow
|
|
21
|
-
4. gitnexus_cypher({query: "MATCH path..."}) → Custom traces if needed
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
> If "Index is stale" → run `npx gitnexus analyze` in terminal.
|
|
25
|
-
|
|
26
|
-
## Checklist
|
|
27
|
-
|
|
28
|
-
```
|
|
29
|
-
- [ ] Understand the symptom (error message, unexpected behavior)
|
|
30
|
-
- [ ] gitnexus_query for error text or related code
|
|
31
|
-
- [ ] Identify the suspect function from returned processes
|
|
32
|
-
- [ ] gitnexus_context to see callers and callees
|
|
33
|
-
- [ ] Trace execution flow via process resource if applicable
|
|
34
|
-
- [ ] gitnexus_cypher for custom call chain traces if needed
|
|
35
|
-
- [ ] Read source files to confirm root cause
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
## Debugging Patterns
|
|
39
|
-
|
|
40
|
-
| Symptom | GitNexus Approach |
|
|
41
|
-
|---------|-------------------|
|
|
42
|
-
| Error message | `gitnexus_query` for error text → `context` on throw sites |
|
|
43
|
-
| Wrong return value | `context` on the function → trace callees for data flow |
|
|
44
|
-
| Intermittent failure | `context` → look for external calls, async deps |
|
|
45
|
-
| Performance issue | `context` → find symbols with many callers (hot paths) |
|
|
46
|
-
| Recent regression | `detect_changes` to see what your changes affect |
|
|
47
|
-
|
|
48
|
-
## Tools
|
|
49
|
-
|
|
50
|
-
**gitnexus_query** — find code related to error:
|
|
51
|
-
```
|
|
52
|
-
gitnexus_query({query: "payment validation error"})
|
|
53
|
-
→ Processes: CheckoutFlow, ErrorHandling
|
|
54
|
-
→ Symbols: validatePayment, handlePaymentError, PaymentException
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
**gitnexus_context** — full context for a suspect:
|
|
58
|
-
```
|
|
59
|
-
gitnexus_context({name: "validatePayment"})
|
|
60
|
-
→ Incoming calls: processCheckout, webhookHandler
|
|
61
|
-
→ Outgoing calls: verifyCard, fetchRates (external API!)
|
|
62
|
-
→ Processes: CheckoutFlow (step 3/7)
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
**gitnexus_cypher** — custom call chain traces:
|
|
66
|
-
```cypher
|
|
67
|
-
MATCH path = (a)-[:CodeRelation {type: 'CALLS'}*1..2]->(b:Function {name: "validatePayment"})
|
|
68
|
-
RETURN [n IN nodes(path) | n.name] AS chain
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
## Example: "Payment endpoint returns 500 intermittently"
|
|
72
|
-
|
|
73
|
-
```
|
|
74
|
-
1. gitnexus_query({query: "payment error handling"})
|
|
75
|
-
→ Processes: CheckoutFlow, ErrorHandling
|
|
76
|
-
→ Symbols: validatePayment, handlePaymentError
|
|
77
|
-
|
|
78
|
-
2. gitnexus_context({name: "validatePayment"})
|
|
79
|
-
→ Outgoing calls: verifyCard, fetchRates (external API!)
|
|
80
|
-
|
|
81
|
-
3. READ gitnexus://repo/my-app/process/CheckoutFlow
|
|
82
|
-
→ Step 3: validatePayment → calls fetchRates (external)
|
|
83
|
-
|
|
84
|
-
4. Root cause: fetchRates calls external API without proper timeout
|
|
85
|
-
```
|
|
1
|
+
---
|
|
2
|
+
name: gitnexus-debugging
|
|
3
|
+
description: Trace bugs through call chains using knowledge graph
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Debugging with GitNexus
|
|
7
|
+
|
|
8
|
+
## When to Use
|
|
9
|
+
- "Why is this function failing?"
|
|
10
|
+
- "Trace where this error comes from"
|
|
11
|
+
- "Who calls this method?"
|
|
12
|
+
- "This endpoint returns 500"
|
|
13
|
+
- Investigating bugs, errors, or unexpected behavior
|
|
14
|
+
|
|
15
|
+
## Workflow
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
1. gitnexus_query({query: "<error or symptom>"}) → Find related execution flows
|
|
19
|
+
2. gitnexus_context({name: "<suspect>"}) → See callers/callees/processes
|
|
20
|
+
3. READ gitnexus://repo/{name}/process/{name} → Trace execution flow
|
|
21
|
+
4. gitnexus_cypher({query: "MATCH path..."}) → Custom traces if needed
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
> If "Index is stale" → run `npx gitnexus analyze` in terminal.
|
|
25
|
+
|
|
26
|
+
## Checklist
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
- [ ] Understand the symptom (error message, unexpected behavior)
|
|
30
|
+
- [ ] gitnexus_query for error text or related code
|
|
31
|
+
- [ ] Identify the suspect function from returned processes
|
|
32
|
+
- [ ] gitnexus_context to see callers and callees
|
|
33
|
+
- [ ] Trace execution flow via process resource if applicable
|
|
34
|
+
- [ ] gitnexus_cypher for custom call chain traces if needed
|
|
35
|
+
- [ ] Read source files to confirm root cause
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Debugging Patterns
|
|
39
|
+
|
|
40
|
+
| Symptom | GitNexus Approach |
|
|
41
|
+
|---------|-------------------|
|
|
42
|
+
| Error message | `gitnexus_query` for error text → `context` on throw sites |
|
|
43
|
+
| Wrong return value | `context` on the function → trace callees for data flow |
|
|
44
|
+
| Intermittent failure | `context` → look for external calls, async deps |
|
|
45
|
+
| Performance issue | `context` → find symbols with many callers (hot paths) |
|
|
46
|
+
| Recent regression | `detect_changes` to see what your changes affect |
|
|
47
|
+
|
|
48
|
+
## Tools
|
|
49
|
+
|
|
50
|
+
**gitnexus_query** — find code related to error:
|
|
51
|
+
```
|
|
52
|
+
gitnexus_query({query: "payment validation error"})
|
|
53
|
+
→ Processes: CheckoutFlow, ErrorHandling
|
|
54
|
+
→ Symbols: validatePayment, handlePaymentError, PaymentException
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**gitnexus_context** — full context for a suspect:
|
|
58
|
+
```
|
|
59
|
+
gitnexus_context({name: "validatePayment"})
|
|
60
|
+
→ Incoming calls: processCheckout, webhookHandler
|
|
61
|
+
→ Outgoing calls: verifyCard, fetchRates (external API!)
|
|
62
|
+
→ Processes: CheckoutFlow (step 3/7)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
**gitnexus_cypher** — custom call chain traces:
|
|
66
|
+
```cypher
|
|
67
|
+
MATCH path = (a)-[:CodeRelation {type: 'CALLS'}*1..2]->(b:Function {name: "validatePayment"})
|
|
68
|
+
RETURN [n IN nodes(path) | n.name] AS chain
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Example: "Payment endpoint returns 500 intermittently"
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
1. gitnexus_query({query: "payment error handling"})
|
|
75
|
+
→ Processes: CheckoutFlow, ErrorHandling
|
|
76
|
+
→ Symbols: validatePayment, handlePaymentError
|
|
77
|
+
|
|
78
|
+
2. gitnexus_context({name: "validatePayment"})
|
|
79
|
+
→ Outgoing calls: verifyCard, fetchRates (external API!)
|
|
80
|
+
|
|
81
|
+
3. READ gitnexus://repo/my-app/process/CheckoutFlow
|
|
82
|
+
→ Step 3: validatePayment → calls fetchRates (external)
|
|
83
|
+
|
|
84
|
+
4. Root cause: fetchRates calls external API without proper timeout
|
|
85
|
+
```
|
package/skills/exploring.md
CHANGED
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: gitnexus-exploring
|
|
3
|
-
description: Navigate unfamiliar code using GitNexus knowledge graph
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Exploring Codebases with GitNexus
|
|
7
|
-
|
|
8
|
-
## When to Use
|
|
9
|
-
- "How does authentication work?"
|
|
10
|
-
- "What's the project structure?"
|
|
11
|
-
- "Show me the main components"
|
|
12
|
-
- "Where is the database logic?"
|
|
13
|
-
- Understanding code you haven't seen before
|
|
14
|
-
|
|
15
|
-
## Workflow
|
|
16
|
-
|
|
17
|
-
```
|
|
18
|
-
1. READ gitnexus://repos → Discover indexed repos
|
|
19
|
-
2. READ gitnexus://repo/{name}/context → Codebase overview, check staleness
|
|
20
|
-
3. gitnexus_query({query: "<what you want to understand>"}) → Find related execution flows
|
|
21
|
-
4. gitnexus_context({name: "<symbol>"}) → Deep dive on specific symbol
|
|
22
|
-
5. READ gitnexus://repo/{name}/process/{name} → Trace full execution flow
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
> If step 2 says "Index is stale" → run `npx gitnexus analyze` in terminal.
|
|
26
|
-
|
|
27
|
-
## Checklist
|
|
28
|
-
|
|
29
|
-
```
|
|
30
|
-
- [ ] READ gitnexus://repo/{name}/context
|
|
31
|
-
- [ ] gitnexus_query for the concept you want to understand
|
|
32
|
-
- [ ] Review returned processes (execution flows)
|
|
33
|
-
- [ ] gitnexus_context on key symbols for callers/callees
|
|
34
|
-
- [ ] READ process resource for full execution traces
|
|
35
|
-
- [ ] Read source files for implementation details
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
## Resources
|
|
39
|
-
|
|
40
|
-
| Resource | What you get |
|
|
41
|
-
|----------|-------------|
|
|
42
|
-
| `gitnexus://repo/{name}/context` | Stats, staleness warning (~150 tokens) |
|
|
43
|
-
| `gitnexus://repo/{name}/clusters` | All functional areas with cohesion scores (~300 tokens) |
|
|
44
|
-
| `gitnexus://repo/{name}/cluster/{name}` | Area members with file paths (~500 tokens) |
|
|
45
|
-
| `gitnexus://repo/{name}/process/{name}` | Step-by-step execution trace (~200 tokens) |
|
|
46
|
-
|
|
47
|
-
## Tools
|
|
48
|
-
|
|
49
|
-
**gitnexus_query** — find execution flows related to a concept:
|
|
50
|
-
```
|
|
51
|
-
gitnexus_query({query: "payment processing"})
|
|
52
|
-
→ Processes: CheckoutFlow, RefundFlow, WebhookHandler
|
|
53
|
-
→ Symbols grouped by flow with file locations
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
**gitnexus_context** — 360-degree view of a symbol:
|
|
57
|
-
```
|
|
58
|
-
gitnexus_context({name: "validateUser"})
|
|
59
|
-
→ Incoming calls: loginHandler, apiMiddleware
|
|
60
|
-
→ Outgoing calls: checkToken, getUserById
|
|
61
|
-
→ Processes: LoginFlow (step 2/5), TokenRefresh (step 1/3)
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
## Example: "How does payment processing work?"
|
|
65
|
-
|
|
66
|
-
```
|
|
67
|
-
1. READ gitnexus://repo/my-app/context → 918 symbols, 45 processes
|
|
68
|
-
2. gitnexus_query({query: "payment processing"})
|
|
69
|
-
→ CheckoutFlow: processPayment → validateCard → chargeStripe
|
|
70
|
-
→ RefundFlow: initiateRefund → calculateRefund → processRefund
|
|
71
|
-
3. gitnexus_context({name: "processPayment"})
|
|
72
|
-
→ Incoming: checkoutHandler, webhookHandler
|
|
73
|
-
→ Outgoing: validateCard, chargeStripe, saveTransaction
|
|
74
|
-
4. Read src/payments/processor.ts for implementation details
|
|
75
|
-
```
|
|
1
|
+
---
|
|
2
|
+
name: gitnexus-exploring
|
|
3
|
+
description: Navigate unfamiliar code using GitNexus knowledge graph
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Exploring Codebases with GitNexus
|
|
7
|
+
|
|
8
|
+
## When to Use
|
|
9
|
+
- "How does authentication work?"
|
|
10
|
+
- "What's the project structure?"
|
|
11
|
+
- "Show me the main components"
|
|
12
|
+
- "Where is the database logic?"
|
|
13
|
+
- Understanding code you haven't seen before
|
|
14
|
+
|
|
15
|
+
## Workflow
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
1. READ gitnexus://repos → Discover indexed repos
|
|
19
|
+
2. READ gitnexus://repo/{name}/context → Codebase overview, check staleness
|
|
20
|
+
3. gitnexus_query({query: "<what you want to understand>"}) → Find related execution flows
|
|
21
|
+
4. gitnexus_context({name: "<symbol>"}) → Deep dive on specific symbol
|
|
22
|
+
5. READ gitnexus://repo/{name}/process/{name} → Trace full execution flow
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
> If step 2 says "Index is stale" → run `npx gitnexus analyze` in terminal.
|
|
26
|
+
|
|
27
|
+
## Checklist
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
- [ ] READ gitnexus://repo/{name}/context
|
|
31
|
+
- [ ] gitnexus_query for the concept you want to understand
|
|
32
|
+
- [ ] Review returned processes (execution flows)
|
|
33
|
+
- [ ] gitnexus_context on key symbols for callers/callees
|
|
34
|
+
- [ ] READ process resource for full execution traces
|
|
35
|
+
- [ ] Read source files for implementation details
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Resources
|
|
39
|
+
|
|
40
|
+
| Resource | What you get |
|
|
41
|
+
|----------|-------------|
|
|
42
|
+
| `gitnexus://repo/{name}/context` | Stats, staleness warning (~150 tokens) |
|
|
43
|
+
| `gitnexus://repo/{name}/clusters` | All functional areas with cohesion scores (~300 tokens) |
|
|
44
|
+
| `gitnexus://repo/{name}/cluster/{name}` | Area members with file paths (~500 tokens) |
|
|
45
|
+
| `gitnexus://repo/{name}/process/{name}` | Step-by-step execution trace (~200 tokens) |
|
|
46
|
+
|
|
47
|
+
## Tools
|
|
48
|
+
|
|
49
|
+
**gitnexus_query** — find execution flows related to a concept:
|
|
50
|
+
```
|
|
51
|
+
gitnexus_query({query: "payment processing"})
|
|
52
|
+
→ Processes: CheckoutFlow, RefundFlow, WebhookHandler
|
|
53
|
+
→ Symbols grouped by flow with file locations
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**gitnexus_context** — 360-degree view of a symbol:
|
|
57
|
+
```
|
|
58
|
+
gitnexus_context({name: "validateUser"})
|
|
59
|
+
→ Incoming calls: loginHandler, apiMiddleware
|
|
60
|
+
→ Outgoing calls: checkToken, getUserById
|
|
61
|
+
→ Processes: LoginFlow (step 2/5), TokenRefresh (step 1/3)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Example: "How does payment processing work?"
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
1. READ gitnexus://repo/my-app/context → 918 symbols, 45 processes
|
|
68
|
+
2. gitnexus_query({query: "payment processing"})
|
|
69
|
+
→ CheckoutFlow: processPayment → validateCard → chargeStripe
|
|
70
|
+
→ RefundFlow: initiateRefund → calculateRefund → processRefund
|
|
71
|
+
3. gitnexus_context({name: "processPayment"})
|
|
72
|
+
→ Incoming: checkoutHandler, webhookHandler
|
|
73
|
+
→ Outgoing: validateCard, chargeStripe, saveTransaction
|
|
74
|
+
4. Read src/payments/processor.ts for implementation details
|
|
75
|
+
```
|
|
@@ -1,94 +1,94 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: gitnexus-impact-analysis
|
|
3
|
-
description: Analyze blast radius before making code changes
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Impact Analysis with GitNexus
|
|
7
|
-
|
|
8
|
-
## When to Use
|
|
9
|
-
- "Is it safe to change this function?"
|
|
10
|
-
- "What will break if I modify X?"
|
|
11
|
-
- "Show me the blast radius"
|
|
12
|
-
- "Who uses this code?"
|
|
13
|
-
- Before making non-trivial code changes
|
|
14
|
-
- Before committing — to understand what your changes affect
|
|
15
|
-
|
|
16
|
-
## Workflow
|
|
17
|
-
|
|
18
|
-
```
|
|
19
|
-
1. gitnexus_impact({target: "X", direction: "upstream"}) → What depends on this
|
|
20
|
-
2. READ gitnexus://repo/{name}/processes → Check affected execution flows
|
|
21
|
-
3. gitnexus_detect_changes() → Map current git changes to affected flows
|
|
22
|
-
4. Assess risk and report to user
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
> If "Index is stale" → run `npx gitnexus analyze` in terminal.
|
|
26
|
-
|
|
27
|
-
## Checklist
|
|
28
|
-
|
|
29
|
-
```
|
|
30
|
-
- [ ] gitnexus_impact({target, direction: "upstream"}) to find dependents
|
|
31
|
-
- [ ] Review d=1 items first (these WILL BREAK)
|
|
32
|
-
- [ ] Check high-confidence (>0.8) dependencies
|
|
33
|
-
- [ ] READ processes to check affected execution flows
|
|
34
|
-
- [ ] gitnexus_detect_changes() for pre-commit check
|
|
35
|
-
- [ ] Assess risk level and report to user
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
## Understanding Output
|
|
39
|
-
|
|
40
|
-
| Depth | Risk Level | Meaning |
|
|
41
|
-
|-------|-----------|---------|
|
|
42
|
-
| d=1 | **WILL BREAK** | Direct callers/importers |
|
|
43
|
-
| d=2 | LIKELY AFFECTED | Indirect dependencies |
|
|
44
|
-
| d=3 | MAY NEED TESTING | Transitive effects |
|
|
45
|
-
|
|
46
|
-
## Risk Assessment
|
|
47
|
-
|
|
48
|
-
| Affected | Risk |
|
|
49
|
-
|----------|------|
|
|
50
|
-
| <5 symbols, few processes | LOW |
|
|
51
|
-
| 5-15 symbols, 2-5 processes | MEDIUM |
|
|
52
|
-
| >15 symbols or many processes | HIGH |
|
|
53
|
-
| Critical path (auth, payments) | CRITICAL |
|
|
54
|
-
|
|
55
|
-
## Tools
|
|
56
|
-
|
|
57
|
-
**gitnexus_impact** — the primary tool for symbol blast radius:
|
|
58
|
-
```
|
|
59
|
-
gitnexus_impact({
|
|
60
|
-
target: "validateUser",
|
|
61
|
-
direction: "upstream",
|
|
62
|
-
minConfidence: 0.8,
|
|
63
|
-
maxDepth: 3
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
→ d=1 (WILL BREAK):
|
|
67
|
-
- loginHandler (src/auth/login.ts:42) [CALLS, 100%]
|
|
68
|
-
- apiMiddleware (src/api/middleware.ts:15) [CALLS, 100%]
|
|
69
|
-
|
|
70
|
-
→ d=2 (LIKELY AFFECTED):
|
|
71
|
-
- authRouter (src/routes/auth.ts:22) [CALLS, 95%]
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
**gitnexus_detect_changes** — git-diff based impact analysis:
|
|
75
|
-
```
|
|
76
|
-
gitnexus_detect_changes({scope: "staged"})
|
|
77
|
-
|
|
78
|
-
→ Changed: 5 symbols in 3 files
|
|
79
|
-
→ Affected: LoginFlow, TokenRefresh, APIMiddlewarePipeline
|
|
80
|
-
→ Risk: MEDIUM
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
## Example: "What breaks if I change validateUser?"
|
|
84
|
-
|
|
85
|
-
```
|
|
86
|
-
1. gitnexus_impact({target: "validateUser", direction: "upstream"})
|
|
87
|
-
→ d=1: loginHandler, apiMiddleware (WILL BREAK)
|
|
88
|
-
→ d=2: authRouter, sessionManager (LIKELY AFFECTED)
|
|
89
|
-
|
|
90
|
-
2. READ gitnexus://repo/my-app/processes
|
|
91
|
-
→ LoginFlow and TokenRefresh touch validateUser
|
|
92
|
-
|
|
93
|
-
3. Risk: 2 direct callers, 2 processes = MEDIUM
|
|
94
|
-
```
|
|
1
|
+
---
|
|
2
|
+
name: gitnexus-impact-analysis
|
|
3
|
+
description: Analyze blast radius before making code changes
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Impact Analysis with GitNexus
|
|
7
|
+
|
|
8
|
+
## When to Use
|
|
9
|
+
- "Is it safe to change this function?"
|
|
10
|
+
- "What will break if I modify X?"
|
|
11
|
+
- "Show me the blast radius"
|
|
12
|
+
- "Who uses this code?"
|
|
13
|
+
- Before making non-trivial code changes
|
|
14
|
+
- Before committing — to understand what your changes affect
|
|
15
|
+
|
|
16
|
+
## Workflow
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
1. gitnexus_impact({target: "X", direction: "upstream"}) → What depends on this
|
|
20
|
+
2. READ gitnexus://repo/{name}/processes → Check affected execution flows
|
|
21
|
+
3. gitnexus_detect_changes() → Map current git changes to affected flows
|
|
22
|
+
4. Assess risk and report to user
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
> If "Index is stale" → run `npx gitnexus analyze` in terminal.
|
|
26
|
+
|
|
27
|
+
## Checklist
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
- [ ] gitnexus_impact({target, direction: "upstream"}) to find dependents
|
|
31
|
+
- [ ] Review d=1 items first (these WILL BREAK)
|
|
32
|
+
- [ ] Check high-confidence (>0.8) dependencies
|
|
33
|
+
- [ ] READ processes to check affected execution flows
|
|
34
|
+
- [ ] gitnexus_detect_changes() for pre-commit check
|
|
35
|
+
- [ ] Assess risk level and report to user
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Understanding Output
|
|
39
|
+
|
|
40
|
+
| Depth | Risk Level | Meaning |
|
|
41
|
+
|-------|-----------|---------|
|
|
42
|
+
| d=1 | **WILL BREAK** | Direct callers/importers |
|
|
43
|
+
| d=2 | LIKELY AFFECTED | Indirect dependencies |
|
|
44
|
+
| d=3 | MAY NEED TESTING | Transitive effects |
|
|
45
|
+
|
|
46
|
+
## Risk Assessment
|
|
47
|
+
|
|
48
|
+
| Affected | Risk |
|
|
49
|
+
|----------|------|
|
|
50
|
+
| <5 symbols, few processes | LOW |
|
|
51
|
+
| 5-15 symbols, 2-5 processes | MEDIUM |
|
|
52
|
+
| >15 symbols or many processes | HIGH |
|
|
53
|
+
| Critical path (auth, payments) | CRITICAL |
|
|
54
|
+
|
|
55
|
+
## Tools
|
|
56
|
+
|
|
57
|
+
**gitnexus_impact** — the primary tool for symbol blast radius:
|
|
58
|
+
```
|
|
59
|
+
gitnexus_impact({
|
|
60
|
+
target: "validateUser",
|
|
61
|
+
direction: "upstream",
|
|
62
|
+
minConfidence: 0.8,
|
|
63
|
+
maxDepth: 3
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
→ d=1 (WILL BREAK):
|
|
67
|
+
- loginHandler (src/auth/login.ts:42) [CALLS, 100%]
|
|
68
|
+
- apiMiddleware (src/api/middleware.ts:15) [CALLS, 100%]
|
|
69
|
+
|
|
70
|
+
→ d=2 (LIKELY AFFECTED):
|
|
71
|
+
- authRouter (src/routes/auth.ts:22) [CALLS, 95%]
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**gitnexus_detect_changes** — git-diff based impact analysis:
|
|
75
|
+
```
|
|
76
|
+
gitnexus_detect_changes({scope: "staged"})
|
|
77
|
+
|
|
78
|
+
→ Changed: 5 symbols in 3 files
|
|
79
|
+
→ Affected: LoginFlow, TokenRefresh, APIMiddlewarePipeline
|
|
80
|
+
→ Risk: MEDIUM
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Example: "What breaks if I change validateUser?"
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
1. gitnexus_impact({target: "validateUser", direction: "upstream"})
|
|
87
|
+
→ d=1: loginHandler, apiMiddleware (WILL BREAK)
|
|
88
|
+
→ d=2: authRouter, sessionManager (LIKELY AFFECTED)
|
|
89
|
+
|
|
90
|
+
2. READ gitnexus://repo/my-app/processes
|
|
91
|
+
→ LoginFlow and TokenRefresh touch validateUser
|
|
92
|
+
|
|
93
|
+
3. Risk: 2 direct callers, 2 processes = MEDIUM
|
|
94
|
+
```
|