gitnexushub 0.2.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/dist/api.d.ts +64 -0
- package/dist/api.js +55 -0
- package/dist/config.d.ts +14 -0
- package/dist/config.js +31 -0
- package/dist/content.d.ts +20 -0
- package/dist/content.js +137 -0
- package/dist/context.d.ts +11 -0
- package/dist/context.js +50 -0
- package/dist/editors/claude-code.d.ts +8 -0
- package/dist/editors/claude-code.js +129 -0
- package/dist/editors/cursor.d.ts +8 -0
- package/dist/editors/cursor.js +83 -0
- package/dist/editors/detect.d.ts +7 -0
- package/dist/editors/detect.js +42 -0
- package/dist/editors/opencode.d.ts +8 -0
- package/dist/editors/opencode.js +83 -0
- package/dist/editors/types.d.ts +19 -0
- package/dist/editors/types.js +4 -0
- package/dist/editors/windsurf.d.ts +8 -0
- package/dist/editors/windsurf.js +83 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +397 -0
- package/dist/project.d.ts +21 -0
- package/dist/project.js +48 -0
- package/dist/utils.d.ts +23 -0
- package/dist/utils.js +90 -0
- package/package.json +53 -0
- package/skills/gitnexus-debugging.md +89 -0
- package/skills/gitnexus-exploring.md +78 -0
- package/skills/gitnexus-guide.md +64 -0
- package/skills/gitnexus-impact-analysis.md +97 -0
- package/skills/gitnexus-pr-review.md +163 -0
- package/skills/gitnexus-refactoring.md +121 -0
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File Utilities
|
|
3
|
+
*
|
|
4
|
+
* Shared helpers for JSON I/O, directory checks, and marker-based section upsert.
|
|
5
|
+
*/
|
|
6
|
+
export declare function readJsonFile(filePath: string): Promise<any | null>;
|
|
7
|
+
export declare function writeJsonFile(filePath: string, data: any): Promise<void>;
|
|
8
|
+
export declare function dirExists(dirPath: string): Promise<boolean>;
|
|
9
|
+
export declare function fileExists(filePath: string): Promise<boolean>;
|
|
10
|
+
export declare const GITNEXUS_START_MARKER = "<!-- gitnexus:start -->";
|
|
11
|
+
export declare const GITNEXUS_END_MARKER = "<!-- gitnexus:end -->";
|
|
12
|
+
/**
|
|
13
|
+
* Create or update a GitNexus-marked section in a file.
|
|
14
|
+
* - File doesn't exist → create with content
|
|
15
|
+
* - File exists without markers → append
|
|
16
|
+
* - File exists with markers → replace section
|
|
17
|
+
*/
|
|
18
|
+
export declare function upsertMarkedSection(filePath: string, content: string): Promise<'created' | 'updated' | 'appended'>;
|
|
19
|
+
/**
|
|
20
|
+
* Remove the GitNexus-marked section from a file.
|
|
21
|
+
* Deletes the file entirely if it only contained the marked section.
|
|
22
|
+
*/
|
|
23
|
+
export declare function removeMarkedSection(filePath: string): Promise<boolean>;
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File Utilities
|
|
3
|
+
*
|
|
4
|
+
* Shared helpers for JSON I/O, directory checks, and marker-based section upsert.
|
|
5
|
+
*/
|
|
6
|
+
import fs from 'fs/promises';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
export async function readJsonFile(filePath) {
|
|
9
|
+
try {
|
|
10
|
+
const raw = await fs.readFile(filePath, 'utf-8');
|
|
11
|
+
return JSON.parse(raw);
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export async function writeJsonFile(filePath, data) {
|
|
18
|
+
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
19
|
+
await fs.writeFile(filePath, JSON.stringify(data, null, 2) + '\n', 'utf-8');
|
|
20
|
+
}
|
|
21
|
+
export async function dirExists(dirPath) {
|
|
22
|
+
try {
|
|
23
|
+
const stat = await fs.stat(dirPath);
|
|
24
|
+
return stat.isDirectory();
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export async function fileExists(filePath) {
|
|
31
|
+
try {
|
|
32
|
+
await fs.access(filePath);
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export const GITNEXUS_START_MARKER = '<!-- gitnexus:start -->';
|
|
40
|
+
export const GITNEXUS_END_MARKER = '<!-- gitnexus:end -->';
|
|
41
|
+
/**
|
|
42
|
+
* Create or update a GitNexus-marked section in a file.
|
|
43
|
+
* - File doesn't exist → create with content
|
|
44
|
+
* - File exists without markers → append
|
|
45
|
+
* - File exists with markers → replace section
|
|
46
|
+
*/
|
|
47
|
+
export async function upsertMarkedSection(filePath, content) {
|
|
48
|
+
const exists = await fileExists(filePath);
|
|
49
|
+
if (!exists) {
|
|
50
|
+
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
51
|
+
await fs.writeFile(filePath, content, 'utf-8');
|
|
52
|
+
return 'created';
|
|
53
|
+
}
|
|
54
|
+
const existingContent = await fs.readFile(filePath, 'utf-8');
|
|
55
|
+
const startIdx = existingContent.indexOf(GITNEXUS_START_MARKER);
|
|
56
|
+
const endIdx = existingContent.indexOf(GITNEXUS_END_MARKER);
|
|
57
|
+
if (startIdx !== -1 && endIdx !== -1 && endIdx > startIdx) {
|
|
58
|
+
const before = existingContent.substring(0, startIdx);
|
|
59
|
+
const after = existingContent.substring(endIdx + GITNEXUS_END_MARKER.length);
|
|
60
|
+
const newContent = before + content + after;
|
|
61
|
+
await fs.writeFile(filePath, newContent.trim() + '\n', 'utf-8');
|
|
62
|
+
return 'updated';
|
|
63
|
+
}
|
|
64
|
+
const newContent = existingContent.trim() + '\n\n' + content + '\n';
|
|
65
|
+
await fs.writeFile(filePath, newContent, 'utf-8');
|
|
66
|
+
return 'appended';
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Remove the GitNexus-marked section from a file.
|
|
70
|
+
* Deletes the file entirely if it only contained the marked section.
|
|
71
|
+
*/
|
|
72
|
+
export async function removeMarkedSection(filePath) {
|
|
73
|
+
if (!(await fileExists(filePath)))
|
|
74
|
+
return false;
|
|
75
|
+
const content = await fs.readFile(filePath, 'utf-8');
|
|
76
|
+
const startIdx = content.indexOf(GITNEXUS_START_MARKER);
|
|
77
|
+
const endIdx = content.indexOf(GITNEXUS_END_MARKER);
|
|
78
|
+
if (startIdx === -1 || endIdx === -1 || endIdx <= startIdx)
|
|
79
|
+
return false;
|
|
80
|
+
const before = content.substring(0, startIdx);
|
|
81
|
+
const after = content.substring(endIdx + GITNEXUS_END_MARKER.length);
|
|
82
|
+
const remaining = (before + after).trim();
|
|
83
|
+
if (remaining.length === 0) {
|
|
84
|
+
await fs.unlink(filePath);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
await fs.writeFile(filePath, remaining + '\n', 'utf-8');
|
|
88
|
+
}
|
|
89
|
+
return true;
|
|
90
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "gitnexushub",
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "Connect your editor to GitNexus Hub — one command MCP setup + project context",
|
|
5
|
+
"author": "Abhigyan Patwari",
|
|
6
|
+
"license": "PolyForm-Noncommercial-1.0.0",
|
|
7
|
+
"homepage": "https://app.akonlabs.com",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/Akon-Labs/gitnexus-enterprise.git",
|
|
11
|
+
"directory": "gitnexus-connect"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/Akon-Labs/gitnexus-enterprise/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"gitnexus",
|
|
18
|
+
"mcp",
|
|
19
|
+
"model-context-protocol",
|
|
20
|
+
"claude",
|
|
21
|
+
"cursor",
|
|
22
|
+
"windsurf",
|
|
23
|
+
"code-intelligence",
|
|
24
|
+
"ai-agent"
|
|
25
|
+
],
|
|
26
|
+
"type": "module",
|
|
27
|
+
"bin": {
|
|
28
|
+
"gnx": "dist/index.js",
|
|
29
|
+
"gitnexus-connect": "dist/index.js"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsc",
|
|
33
|
+
"dev": "tsx src/index.ts",
|
|
34
|
+
"prepare": "npm run build"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"commander": "^12.0.0",
|
|
38
|
+
"picocolors": "^1.1.1"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@types/node": "^20.19.37",
|
|
42
|
+
"tsx": "^4.0.0",
|
|
43
|
+
"typescript": "^5.4.5"
|
|
44
|
+
},
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=18.0.0"
|
|
47
|
+
},
|
|
48
|
+
"files": [
|
|
49
|
+
"dist",
|
|
50
|
+
"skills"
|
|
51
|
+
],
|
|
52
|
+
"publishConfig": {}
|
|
53
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: gitnexus-debugging
|
|
3
|
+
description: "Use when the user is debugging a bug, tracing an error, or asking why something fails. Examples: \"Why is X failing?\", \"Where does this error come from?\", \"Trace this bug\""
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Debugging with GitNexus
|
|
7
|
+
|
|
8
|
+
## When to Use
|
|
9
|
+
|
|
10
|
+
- "Why is this function failing?"
|
|
11
|
+
- "Trace where this error comes from"
|
|
12
|
+
- "Who calls this method?"
|
|
13
|
+
- "This endpoint returns 500"
|
|
14
|
+
- Investigating bugs, errors, or unexpected behavior
|
|
15
|
+
|
|
16
|
+
## Workflow
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
1. gitnexus_query({query: "<error or symptom>"}) → Find related execution flows
|
|
20
|
+
2. gitnexus_context({name: "<suspect>"}) → See callers/callees/processes
|
|
21
|
+
3. READ gitnexus://repo/{name}/process/{name} → Trace execution flow
|
|
22
|
+
4. gitnexus_cypher({query: "MATCH path..."}) → Custom traces if needed
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
> If "Index is stale" → run `npx gitnexus analyze` in terminal.
|
|
26
|
+
|
|
27
|
+
## Checklist
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
- [ ] Understand the symptom (error message, unexpected behavior)
|
|
31
|
+
- [ ] gitnexus_query for error text or related code
|
|
32
|
+
- [ ] Identify the suspect function from returned processes
|
|
33
|
+
- [ ] gitnexus_context to see callers and callees
|
|
34
|
+
- [ ] Trace execution flow via process resource if applicable
|
|
35
|
+
- [ ] gitnexus_cypher for custom call chain traces if needed
|
|
36
|
+
- [ ] Read source files to confirm root cause
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Debugging Patterns
|
|
40
|
+
|
|
41
|
+
| Symptom | GitNexus Approach |
|
|
42
|
+
| -------------------- | ---------------------------------------------------------- |
|
|
43
|
+
| Error message | `gitnexus_query` for error text → `context` on throw sites |
|
|
44
|
+
| Wrong return value | `context` on the function → trace callees for data flow |
|
|
45
|
+
| Intermittent failure | `context` → look for external calls, async deps |
|
|
46
|
+
| Performance issue | `context` → find symbols with many callers (hot paths) |
|
|
47
|
+
| Recent regression | `detect_changes` to see what your changes affect |
|
|
48
|
+
|
|
49
|
+
## Tools
|
|
50
|
+
|
|
51
|
+
**gitnexus_query** — find code related to error:
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
gitnexus_query({query: "payment validation error"})
|
|
55
|
+
→ Processes: CheckoutFlow, ErrorHandling
|
|
56
|
+
→ Symbols: validatePayment, handlePaymentError, PaymentException
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**gitnexus_context** — full context for a suspect:
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
gitnexus_context({name: "validatePayment"})
|
|
63
|
+
→ Incoming calls: processCheckout, webhookHandler
|
|
64
|
+
→ Outgoing calls: verifyCard, fetchRates (external API!)
|
|
65
|
+
→ Processes: CheckoutFlow (step 3/7)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**gitnexus_cypher** — custom call chain traces:
|
|
69
|
+
|
|
70
|
+
```cypher
|
|
71
|
+
MATCH path = (a)-[:CodeRelation {type: 'CALLS'}*1..2]->(b:Function {name: "validatePayment"})
|
|
72
|
+
RETURN [n IN nodes(path) | n.name] AS chain
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Example: "Payment endpoint returns 500 intermittently"
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
1. gitnexus_query({query: "payment error handling"})
|
|
79
|
+
→ Processes: CheckoutFlow, ErrorHandling
|
|
80
|
+
→ Symbols: validatePayment, handlePaymentError
|
|
81
|
+
|
|
82
|
+
2. gitnexus_context({name: "validatePayment"})
|
|
83
|
+
→ Outgoing calls: verifyCard, fetchRates (external API!)
|
|
84
|
+
|
|
85
|
+
3. READ gitnexus://repo/my-app/process/CheckoutFlow
|
|
86
|
+
→ Step 3: validatePayment → calls fetchRates (external)
|
|
87
|
+
|
|
88
|
+
4. Root cause: fetchRates calls external API without proper timeout
|
|
89
|
+
```
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: gitnexus-exploring
|
|
3
|
+
description: "Use when the user asks how code works, wants to understand architecture, trace execution flows, or explore unfamiliar parts of the codebase. Examples: \"How does X work?\", \"What calls this function?\", \"Show me the auth flow\""
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Exploring Codebases with GitNexus
|
|
7
|
+
|
|
8
|
+
## When to Use
|
|
9
|
+
|
|
10
|
+
- "How does authentication work?"
|
|
11
|
+
- "What's the project structure?"
|
|
12
|
+
- "Show me the main components"
|
|
13
|
+
- "Where is the database logic?"
|
|
14
|
+
- Understanding code you haven't seen before
|
|
15
|
+
|
|
16
|
+
## Workflow
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
1. READ gitnexus://repos → Discover indexed repos
|
|
20
|
+
2. READ gitnexus://repo/{name}/context → Codebase overview, check staleness
|
|
21
|
+
3. gitnexus_query({query: "<what you want to understand>"}) → Find related execution flows
|
|
22
|
+
4. gitnexus_context({name: "<symbol>"}) → Deep dive on specific symbol
|
|
23
|
+
5. READ gitnexus://repo/{name}/process/{name} → Trace full execution flow
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
> If step 2 says "Index is stale" → run `npx gitnexus analyze` in terminal.
|
|
27
|
+
|
|
28
|
+
## Checklist
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
- [ ] READ gitnexus://repo/{name}/context
|
|
32
|
+
- [ ] gitnexus_query for the concept you want to understand
|
|
33
|
+
- [ ] Review returned processes (execution flows)
|
|
34
|
+
- [ ] gitnexus_context on key symbols for callers/callees
|
|
35
|
+
- [ ] READ process resource for full execution traces
|
|
36
|
+
- [ ] Read source files for implementation details
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Resources
|
|
40
|
+
|
|
41
|
+
| Resource | What you get |
|
|
42
|
+
| --------------------------------------- | ------------------------------------------------------- |
|
|
43
|
+
| `gitnexus://repo/{name}/context` | Stats, staleness warning (~150 tokens) |
|
|
44
|
+
| `gitnexus://repo/{name}/clusters` | All functional areas with cohesion scores (~300 tokens) |
|
|
45
|
+
| `gitnexus://repo/{name}/cluster/{name}` | Area members with file paths (~500 tokens) |
|
|
46
|
+
| `gitnexus://repo/{name}/process/{name}` | Step-by-step execution trace (~200 tokens) |
|
|
47
|
+
|
|
48
|
+
## Tools
|
|
49
|
+
|
|
50
|
+
**gitnexus_query** — find execution flows related to a concept:
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
gitnexus_query({query: "payment processing"})
|
|
54
|
+
→ Processes: CheckoutFlow, RefundFlow, WebhookHandler
|
|
55
|
+
→ Symbols grouped by flow with file locations
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**gitnexus_context** — 360-degree view of a symbol:
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
gitnexus_context({name: "validateUser"})
|
|
62
|
+
→ Incoming calls: loginHandler, apiMiddleware
|
|
63
|
+
→ Outgoing calls: checkToken, getUserById
|
|
64
|
+
→ Processes: LoginFlow (step 2/5), TokenRefresh (step 1/3)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Example: "How does payment processing work?"
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
1. READ gitnexus://repo/my-app/context → 918 symbols, 45 processes
|
|
71
|
+
2. gitnexus_query({query: "payment processing"})
|
|
72
|
+
→ CheckoutFlow: processPayment → validateCard → chargeStripe
|
|
73
|
+
→ RefundFlow: initiateRefund → calculateRefund → processRefund
|
|
74
|
+
3. gitnexus_context({name: "processPayment"})
|
|
75
|
+
→ Incoming: checkoutHandler, webhookHandler
|
|
76
|
+
→ Outgoing: validateCard, chargeStripe, saveTransaction
|
|
77
|
+
4. Read src/payments/processor.ts for implementation details
|
|
78
|
+
```
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: gitnexus-guide
|
|
3
|
+
description: "Use when the user asks about GitNexus itself — available tools, how to query the knowledge graph, MCP resources, graph schema, or workflow reference. Examples: \"What GitNexus tools are available?\", \"How do I use GitNexus?\""
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# GitNexus Guide
|
|
7
|
+
|
|
8
|
+
Quick reference for all GitNexus MCP tools, resources, and the knowledge graph schema.
|
|
9
|
+
|
|
10
|
+
## Always Start Here
|
|
11
|
+
|
|
12
|
+
For any task involving code understanding, debugging, impact analysis, or refactoring:
|
|
13
|
+
|
|
14
|
+
1. **Read `gitnexus://repo/{name}/context`** — codebase overview + check index freshness
|
|
15
|
+
2. **Match your task to a skill below** and **read that skill file**
|
|
16
|
+
3. **Follow the skill's workflow and checklist**
|
|
17
|
+
|
|
18
|
+
> If step 1 warns the index is stale, run `npx gitnexus analyze` in the terminal first.
|
|
19
|
+
|
|
20
|
+
## Skills
|
|
21
|
+
|
|
22
|
+
| Task | Skill to read |
|
|
23
|
+
| -------------------------------------------- | ------------------- |
|
|
24
|
+
| Understand architecture / "How does X work?" | `gitnexus-exploring` |
|
|
25
|
+
| Blast radius / "What breaks if I change X?" | `gitnexus-impact-analysis` |
|
|
26
|
+
| Trace bugs / "Why is X failing?" | `gitnexus-debugging` |
|
|
27
|
+
| Rename / extract / split / refactor | `gitnexus-refactoring` |
|
|
28
|
+
| Tools, resources, schema reference | `gitnexus-guide` (this file) |
|
|
29
|
+
| Index, status, clean, wiki CLI commands | `gitnexus-cli` |
|
|
30
|
+
|
|
31
|
+
## Tools Reference
|
|
32
|
+
|
|
33
|
+
| Tool | What it gives you |
|
|
34
|
+
| ---------------- | ------------------------------------------------------------------------ |
|
|
35
|
+
| `query` | Process-grouped code intelligence — execution flows related to a concept |
|
|
36
|
+
| `context` | 360-degree symbol view — categorized refs, processes it participates in |
|
|
37
|
+
| `impact` | Symbol blast radius — what breaks at depth 1/2/3 with confidence |
|
|
38
|
+
| `detect_changes` | Git-diff impact — what do your current changes affect |
|
|
39
|
+
| `rename` | Multi-file coordinated rename with confidence-tagged edits |
|
|
40
|
+
| `cypher` | Raw graph queries (read `gitnexus://repo/{name}/schema` first) |
|
|
41
|
+
| `list_repos` | Discover indexed repos |
|
|
42
|
+
|
|
43
|
+
## Resources Reference
|
|
44
|
+
|
|
45
|
+
Lightweight reads (~100-500 tokens) for navigation:
|
|
46
|
+
|
|
47
|
+
| Resource | Content |
|
|
48
|
+
| ---------------------------------------------- | ----------------------------------------- |
|
|
49
|
+
| `gitnexus://repo/{name}/context` | Stats, staleness check |
|
|
50
|
+
| `gitnexus://repo/{name}/clusters` | All functional areas with cohesion scores |
|
|
51
|
+
| `gitnexus://repo/{name}/cluster/{clusterName}` | Area members |
|
|
52
|
+
| `gitnexus://repo/{name}/processes` | All execution flows |
|
|
53
|
+
| `gitnexus://repo/{name}/process/{processName}` | Step-by-step trace |
|
|
54
|
+
| `gitnexus://repo/{name}/schema` | Graph schema for Cypher |
|
|
55
|
+
|
|
56
|
+
## Graph Schema
|
|
57
|
+
|
|
58
|
+
**Nodes:** File, Function, Class, Interface, Method, Community, Process
|
|
59
|
+
**Edges (via CodeRelation.type):** CALLS, IMPORTS, EXTENDS, IMPLEMENTS, DEFINES, MEMBER_OF, STEP_IN_PROCESS
|
|
60
|
+
|
|
61
|
+
```cypher
|
|
62
|
+
MATCH (caller)-[:CodeRelation {type: 'CALLS'}]->(f:Function {name: "myFunc"})
|
|
63
|
+
RETURN caller.name, caller.filePath
|
|
64
|
+
```
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: gitnexus-impact-analysis
|
|
3
|
+
description: "Use when the user wants to know what will break if they change something, or needs safety analysis before editing code. Examples: \"Is it safe to change X?\", \"What depends on this?\", \"What will break?\""
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Impact Analysis with GitNexus
|
|
7
|
+
|
|
8
|
+
## When to Use
|
|
9
|
+
|
|
10
|
+
- "Is it safe to change this function?"
|
|
11
|
+
- "What will break if I modify X?"
|
|
12
|
+
- "Show me the blast radius"
|
|
13
|
+
- "Who uses this code?"
|
|
14
|
+
- Before making non-trivial code changes
|
|
15
|
+
- Before committing — to understand what your changes affect
|
|
16
|
+
|
|
17
|
+
## Workflow
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
1. gitnexus_impact({target: "X", direction: "upstream"}) → What depends on this
|
|
21
|
+
2. READ gitnexus://repo/{name}/processes → Check affected execution flows
|
|
22
|
+
3. gitnexus_detect_changes() → Map current git changes to affected flows
|
|
23
|
+
4. Assess risk and report to user
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
> If "Index is stale" → run `npx gitnexus analyze` in terminal.
|
|
27
|
+
|
|
28
|
+
## Checklist
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
- [ ] gitnexus_impact({target, direction: "upstream"}) to find dependents
|
|
32
|
+
- [ ] Review d=1 items first (these WILL BREAK)
|
|
33
|
+
- [ ] Check high-confidence (>0.8) dependencies
|
|
34
|
+
- [ ] READ processes to check affected execution flows
|
|
35
|
+
- [ ] gitnexus_detect_changes() for pre-commit check
|
|
36
|
+
- [ ] Assess risk level and report to user
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Understanding Output
|
|
40
|
+
|
|
41
|
+
| Depth | Risk Level | Meaning |
|
|
42
|
+
| ----- | ---------------- | ------------------------ |
|
|
43
|
+
| d=1 | **WILL BREAK** | Direct callers/importers |
|
|
44
|
+
| d=2 | LIKELY AFFECTED | Indirect dependencies |
|
|
45
|
+
| d=3 | MAY NEED TESTING | Transitive effects |
|
|
46
|
+
|
|
47
|
+
## Risk Assessment
|
|
48
|
+
|
|
49
|
+
| Affected | Risk |
|
|
50
|
+
| ------------------------------ | -------- |
|
|
51
|
+
| <5 symbols, few processes | LOW |
|
|
52
|
+
| 5-15 symbols, 2-5 processes | MEDIUM |
|
|
53
|
+
| >15 symbols or many processes | HIGH |
|
|
54
|
+
| Critical path (auth, payments) | CRITICAL |
|
|
55
|
+
|
|
56
|
+
## Tools
|
|
57
|
+
|
|
58
|
+
**gitnexus_impact** — the primary tool for symbol blast radius:
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
gitnexus_impact({
|
|
62
|
+
target: "validateUser",
|
|
63
|
+
direction: "upstream",
|
|
64
|
+
minConfidence: 0.8,
|
|
65
|
+
maxDepth: 3
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
→ d=1 (WILL BREAK):
|
|
69
|
+
- loginHandler (src/auth/login.ts:42) [CALLS, 100%]
|
|
70
|
+
- apiMiddleware (src/api/middleware.ts:15) [CALLS, 100%]
|
|
71
|
+
|
|
72
|
+
→ d=2 (LIKELY AFFECTED):
|
|
73
|
+
- authRouter (src/routes/auth.ts:22) [CALLS, 95%]
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**gitnexus_detect_changes** — git-diff based impact analysis:
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
gitnexus_detect_changes({scope: "staged"})
|
|
80
|
+
|
|
81
|
+
→ Changed: 5 symbols in 3 files
|
|
82
|
+
→ Affected: LoginFlow, TokenRefresh, APIMiddlewarePipeline
|
|
83
|
+
→ Risk: MEDIUM
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Example: "What breaks if I change validateUser?"
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
1. gitnexus_impact({target: "validateUser", direction: "upstream"})
|
|
90
|
+
→ d=1: loginHandler, apiMiddleware (WILL BREAK)
|
|
91
|
+
→ d=2: authRouter, sessionManager (LIKELY AFFECTED)
|
|
92
|
+
|
|
93
|
+
2. READ gitnexus://repo/my-app/processes
|
|
94
|
+
→ LoginFlow and TokenRefresh touch validateUser
|
|
95
|
+
|
|
96
|
+
3. Risk: 2 direct callers, 2 processes = MEDIUM
|
|
97
|
+
```
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: gitnexus-pr-review
|
|
3
|
+
description: "Use when the user wants to review a pull request, understand what a PR changes, assess risk of merging, or check for missing test coverage. Examples: \"Review this PR\", \"What does PR #42 change?\", \"Is this PR safe to merge?\""
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# PR Review with GitNexus
|
|
7
|
+
|
|
8
|
+
## When to Use
|
|
9
|
+
|
|
10
|
+
- "Review this PR"
|
|
11
|
+
- "What does PR #42 change?"
|
|
12
|
+
- "Is this safe to merge?"
|
|
13
|
+
- "What's the blast radius of this PR?"
|
|
14
|
+
- "Are there missing tests for this PR?"
|
|
15
|
+
- Reviewing someone else's code changes before merge
|
|
16
|
+
|
|
17
|
+
## Workflow
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
1. gh pr diff <number> → Get the raw diff
|
|
21
|
+
2. gitnexus_detect_changes({scope: "compare", base_ref: "main"}) → Map diff to affected flows
|
|
22
|
+
3. For each changed symbol:
|
|
23
|
+
gitnexus_impact({target: "<symbol>", direction: "upstream"}) → Blast radius per change
|
|
24
|
+
4. gitnexus_context({name: "<key symbol>"}) → Understand callers/callees
|
|
25
|
+
5. READ gitnexus://repo/{name}/processes → Check affected execution flows
|
|
26
|
+
6. Summarize findings with risk assessment
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
> If "Index is stale" → run `npx gitnexus analyze` in terminal before reviewing.
|
|
30
|
+
|
|
31
|
+
## Checklist
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
- [ ] Fetch PR diff (gh pr diff or git diff base...head)
|
|
35
|
+
- [ ] gitnexus_detect_changes to map changes to affected execution flows
|
|
36
|
+
- [ ] gitnexus_impact on each non-trivial changed symbol
|
|
37
|
+
- [ ] Review d=1 items (WILL BREAK) — are callers updated?
|
|
38
|
+
- [ ] gitnexus_context on key changed symbols to understand full picture
|
|
39
|
+
- [ ] Check if affected processes have test coverage
|
|
40
|
+
- [ ] Assess overall risk level
|
|
41
|
+
- [ ] Write review summary with findings
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Review Dimensions
|
|
45
|
+
|
|
46
|
+
| Dimension | How GitNexus Helps |
|
|
47
|
+
| --- | --- |
|
|
48
|
+
| **Correctness** | `context` shows callers — are they all compatible with the change? |
|
|
49
|
+
| **Blast radius** | `impact` shows d=1/d=2/d=3 dependents — anything missed? |
|
|
50
|
+
| **Completeness** | `detect_changes` shows all affected flows — are they all handled? |
|
|
51
|
+
| **Test coverage** | `impact({includeTests: true})` shows which tests touch changed code |
|
|
52
|
+
| **Breaking changes** | d=1 upstream items that aren't updated in the PR = potential breakage |
|
|
53
|
+
|
|
54
|
+
## Risk Assessment
|
|
55
|
+
|
|
56
|
+
| Signal | Risk |
|
|
57
|
+
| --- | --- |
|
|
58
|
+
| Changes touch <3 symbols, 0-1 processes | LOW |
|
|
59
|
+
| Changes touch 3-10 symbols, 2-5 processes | MEDIUM |
|
|
60
|
+
| Changes touch >10 symbols or many processes | HIGH |
|
|
61
|
+
| Changes touch auth, payments, or data integrity code | CRITICAL |
|
|
62
|
+
| d=1 callers exist outside the PR diff | Potential breakage — flag it |
|
|
63
|
+
|
|
64
|
+
## Tools
|
|
65
|
+
|
|
66
|
+
**gitnexus_detect_changes** — map PR diff to affected execution flows:
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
gitnexus_detect_changes({scope: "compare", base_ref: "main"})
|
|
70
|
+
|
|
71
|
+
→ Changed: 8 symbols in 4 files
|
|
72
|
+
→ Affected processes: CheckoutFlow, RefundFlow, WebhookHandler
|
|
73
|
+
→ Risk: MEDIUM
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**gitnexus_impact** — blast radius per changed symbol:
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
gitnexus_impact({target: "validatePayment", direction: "upstream"})
|
|
80
|
+
|
|
81
|
+
→ d=1 (WILL BREAK):
|
|
82
|
+
- processCheckout (src/checkout.ts:42) [CALLS, 100%]
|
|
83
|
+
- webhookHandler (src/webhooks.ts:15) [CALLS, 100%]
|
|
84
|
+
|
|
85
|
+
→ d=2 (LIKELY AFFECTED):
|
|
86
|
+
- checkoutRouter (src/routes/checkout.ts:22) [CALLS, 95%]
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**gitnexus_impact with tests** — check test coverage:
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
gitnexus_impact({target: "validatePayment", direction: "upstream", includeTests: true})
|
|
93
|
+
|
|
94
|
+
→ Tests that cover this symbol:
|
|
95
|
+
- validatePayment.test.ts [direct]
|
|
96
|
+
- checkout.integration.test.ts [via processCheckout]
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**gitnexus_context** — understand a changed symbol's role:
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
gitnexus_context({name: "validatePayment"})
|
|
103
|
+
|
|
104
|
+
→ Incoming calls: processCheckout, webhookHandler
|
|
105
|
+
→ Outgoing calls: verifyCard, fetchRates
|
|
106
|
+
→ Processes: CheckoutFlow (step 3/7), RefundFlow (step 1/5)
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Example: "Review PR #42"
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
1. gh pr diff 42 > /tmp/pr42.diff
|
|
113
|
+
→ 4 files changed: payments.ts, checkout.ts, types.ts, utils.ts
|
|
114
|
+
|
|
115
|
+
2. gitnexus_detect_changes({scope: "compare", base_ref: "main"})
|
|
116
|
+
→ Changed symbols: validatePayment, PaymentInput, formatAmount
|
|
117
|
+
→ Affected processes: CheckoutFlow, RefundFlow
|
|
118
|
+
→ Risk: MEDIUM
|
|
119
|
+
|
|
120
|
+
3. gitnexus_impact({target: "validatePayment", direction: "upstream"})
|
|
121
|
+
→ d=1: processCheckout, webhookHandler (WILL BREAK)
|
|
122
|
+
→ webhookHandler is NOT in the PR diff — potential breakage!
|
|
123
|
+
|
|
124
|
+
4. gitnexus_impact({target: "PaymentInput", direction: "upstream"})
|
|
125
|
+
→ d=1: validatePayment (in PR), createPayment (NOT in PR)
|
|
126
|
+
→ createPayment uses the old PaymentInput shape — breaking change!
|
|
127
|
+
|
|
128
|
+
5. gitnexus_context({name: "formatAmount"})
|
|
129
|
+
→ Called by 12 functions — but change is backwards-compatible (added optional param)
|
|
130
|
+
|
|
131
|
+
6. Review summary:
|
|
132
|
+
- MEDIUM risk — 3 changed symbols affect 2 execution flows
|
|
133
|
+
- BUG: webhookHandler calls validatePayment but isn't updated for new signature
|
|
134
|
+
- BUG: createPayment depends on PaymentInput type which changed
|
|
135
|
+
- OK: formatAmount change is backwards-compatible
|
|
136
|
+
- Tests: checkout.test.ts covers processCheckout path, but no webhook test
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Review Output Format
|
|
140
|
+
|
|
141
|
+
Structure your review as:
|
|
142
|
+
|
|
143
|
+
```markdown
|
|
144
|
+
## PR Review: <title>
|
|
145
|
+
|
|
146
|
+
**Risk: LOW / MEDIUM / HIGH / CRITICAL**
|
|
147
|
+
|
|
148
|
+
### Changes Summary
|
|
149
|
+
- <N> symbols changed across <M> files
|
|
150
|
+
- <P> execution flows affected
|
|
151
|
+
|
|
152
|
+
### Findings
|
|
153
|
+
1. **[severity]** Description of finding
|
|
154
|
+
- Evidence from GitNexus tools
|
|
155
|
+
- Affected callers/flows
|
|
156
|
+
|
|
157
|
+
### Missing Coverage
|
|
158
|
+
- Callers not updated in PR: ...
|
|
159
|
+
- Untested flows: ...
|
|
160
|
+
|
|
161
|
+
### Recommendation
|
|
162
|
+
APPROVE / REQUEST CHANGES / NEEDS DISCUSSION
|
|
163
|
+
```
|