gitnexus 1.1.1 → 1.1.2
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 +196 -196
- package/dist/cli/ai-context.js +89 -89
- package/dist/cli/setup.js +1 -1
- package/dist/core/ingestion/pipeline.js +4 -1
- package/dist/core/ingestion/process-processor.js +27 -3
- package/dist/core/search/bm25-index.js +5 -5
- package/dist/mcp/local/local-backend.d.ts +6 -0
- package/dist/mcp/local/local-backend.js +135 -79
- package/dist/mcp/resources.js +55 -38
- package/dist/mcp/tools.js +82 -82
- package/package.json +80 -80
- package/skills/debugging.md +106 -106
- package/skills/exploring.md +126 -126
- package/skills/impact-analysis.md +117 -117
- package/skills/refactoring.md +120 -120
package/skills/refactoring.md
CHANGED
|
@@ -1,120 +1,120 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: gitnexus-refactoring
|
|
3
|
-
description: Plan safe refactors using blast radius and dependency mapping
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Refactoring with GitNexus
|
|
7
|
-
|
|
8
|
-
## Quick Start
|
|
9
|
-
```
|
|
10
|
-
0. READ gitnexus://repos → Discover indexed repos
|
|
11
|
-
1. If "Index is stale" → gitnexus_analyze({repo: "my-app"})
|
|
12
|
-
2. gitnexus_impact({target, direction: "upstream", repo: "my-app"}) → Map all dependents
|
|
13
|
-
3. READ gitnexus://repo/my-app/schema → Understand graph structure
|
|
14
|
-
4. gitnexus_cypher({query: "...", repo: "my-app"}) → Find all references
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
## When to Use
|
|
18
|
-
- "Rename this function safely"
|
|
19
|
-
- "Extract this into a module"
|
|
20
|
-
- "Split this service"
|
|
21
|
-
- "Refactor without breaking things"
|
|
22
|
-
|
|
23
|
-
## Checklists
|
|
24
|
-
|
|
25
|
-
### Rename Symbol
|
|
26
|
-
```
|
|
27
|
-
Rename Refactoring:
|
|
28
|
-
- [ ] gitnexus_impact({target: oldName, direction: "upstream", repo: "my-app"}) — find all callers
|
|
29
|
-
- [ ] gitnexus_search({query: oldName, repo: "my-app"}) — find string literals
|
|
30
|
-
- [ ] Check for reflection/dynamic references
|
|
31
|
-
- [ ] Update in order: interface → implementation → usages
|
|
32
|
-
- [ ] Run tests for affected processes
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
### Extract Module
|
|
36
|
-
```
|
|
37
|
-
Extract Module:
|
|
38
|
-
- [ ] gitnexus_explore({name: target, type: "symbol", repo: "my-app"}) — map dependencies
|
|
39
|
-
- [ ] gitnexus_impact({target, direction: "upstream", repo: "my-app"}) — find callers
|
|
40
|
-
- [ ] READ gitnexus://repo/my-app/cluster/{name} — check cohesion
|
|
41
|
-
- [ ] Define new module interface
|
|
42
|
-
- [ ] Update imports across affected files
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
### Split Function
|
|
46
|
-
```
|
|
47
|
-
Split Function:
|
|
48
|
-
- [ ] gitnexus_explore({name: target, type: "symbol", repo: "my-app"}) — understand callees
|
|
49
|
-
- [ ] Group related logic
|
|
50
|
-
- [ ] gitnexus_impact — verify callers won't break
|
|
51
|
-
- [ ] Create new functions
|
|
52
|
-
- [ ] Update callers
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
## Resource Reference
|
|
56
|
-
|
|
57
|
-
### gitnexus://repo/{name}/schema
|
|
58
|
-
Graph structure for Cypher queries:
|
|
59
|
-
```yaml
|
|
60
|
-
nodes: [Function, Class, Method, Community, Process]
|
|
61
|
-
relationships: [CALLS, IMPORTS, EXTENDS, MEMBER_OF]
|
|
62
|
-
|
|
63
|
-
example_queries:
|
|
64
|
-
find_callers: |
|
|
65
|
-
MATCH (caller)-[:CodeRelation {type: 'CALLS'}]->(f:Function {name: "X"})
|
|
66
|
-
RETURN caller.name
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
### gitnexus://repo/{name}/cluster/{clusterName}
|
|
70
|
-
Check if extraction preserves cohesion:
|
|
71
|
-
```yaml
|
|
72
|
-
name: Payment
|
|
73
|
-
cohesion: 92%
|
|
74
|
-
members: [processPayment, validateCard, PaymentService]
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
## Tool Reference
|
|
78
|
-
|
|
79
|
-
### Finding all references
|
|
80
|
-
```cypher
|
|
81
|
-
MATCH (caller)-[:CodeRelation {type: 'CALLS'}]->(f:Function {name: "validateUser"})
|
|
82
|
-
RETURN caller.name, caller.filePath
|
|
83
|
-
ORDER BY caller.filePath
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
### Finding imports of a module
|
|
87
|
-
```cypher
|
|
88
|
-
MATCH (importer)-[:CodeRelation {type: 'IMPORTS'}]->(f:File {name: "utils.ts"})
|
|
89
|
-
RETURN importer.name, importer.filePath
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
## Example: Safely Rename `validateUser` to `authenticateUser`
|
|
93
|
-
|
|
94
|
-
```
|
|
95
|
-
1. gitnexus_impact({target: "validateUser", direction: "upstream", repo: "my-app"})
|
|
96
|
-
→ loginHandler, apiMiddleware, testUtils
|
|
97
|
-
|
|
98
|
-
2. gitnexus_search({query: "validateUser", repo: "my-app"})
|
|
99
|
-
→ Found in: config.json (dynamic reference!)
|
|
100
|
-
|
|
101
|
-
3. READ gitnexus://repo/my-app/processes
|
|
102
|
-
→ LoginFlow, TokenRefresh, APIGateway
|
|
103
|
-
|
|
104
|
-
4. Plan update order:
|
|
105
|
-
1. Update declaration in auth.ts
|
|
106
|
-
2. Update config.json string reference
|
|
107
|
-
3. Update loginHandler
|
|
108
|
-
4. Update apiMiddleware
|
|
109
|
-
5. Run tests for LoginFlow, TokenRefresh
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
## Refactoring Safety Rules
|
|
113
|
-
|
|
114
|
-
| Risk Factor | Mitigation |
|
|
115
|
-
|-------------|------------|
|
|
116
|
-
| Many callers (>5) | Update in small batches |
|
|
117
|
-
| Cross-cluster | Coordinate with other teams |
|
|
118
|
-
| String references | Search for dynamic usage |
|
|
119
|
-
| Reflection | Check for dynamic invocation |
|
|
120
|
-
| External exports | May break downstream repos |
|
|
1
|
+
---
|
|
2
|
+
name: gitnexus-refactoring
|
|
3
|
+
description: Plan safe refactors using blast radius and dependency mapping
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Refactoring with GitNexus
|
|
7
|
+
|
|
8
|
+
## Quick Start
|
|
9
|
+
```
|
|
10
|
+
0. READ gitnexus://repos → Discover indexed repos
|
|
11
|
+
1. If "Index is stale" → gitnexus_analyze({repo: "my-app"})
|
|
12
|
+
2. gitnexus_impact({target, direction: "upstream", repo: "my-app"}) → Map all dependents
|
|
13
|
+
3. READ gitnexus://repo/my-app/schema → Understand graph structure
|
|
14
|
+
4. gitnexus_cypher({query: "...", repo: "my-app"}) → Find all references
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## When to Use
|
|
18
|
+
- "Rename this function safely"
|
|
19
|
+
- "Extract this into a module"
|
|
20
|
+
- "Split this service"
|
|
21
|
+
- "Refactor without breaking things"
|
|
22
|
+
|
|
23
|
+
## Checklists
|
|
24
|
+
|
|
25
|
+
### Rename Symbol
|
|
26
|
+
```
|
|
27
|
+
Rename Refactoring:
|
|
28
|
+
- [ ] gitnexus_impact({target: oldName, direction: "upstream", repo: "my-app"}) — find all callers
|
|
29
|
+
- [ ] gitnexus_search({query: oldName, repo: "my-app"}) — find string literals
|
|
30
|
+
- [ ] Check for reflection/dynamic references
|
|
31
|
+
- [ ] Update in order: interface → implementation → usages
|
|
32
|
+
- [ ] Run tests for affected processes
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Extract Module
|
|
36
|
+
```
|
|
37
|
+
Extract Module:
|
|
38
|
+
- [ ] gitnexus_explore({name: target, type: "symbol", repo: "my-app"}) — map dependencies
|
|
39
|
+
- [ ] gitnexus_impact({target, direction: "upstream", repo: "my-app"}) — find callers
|
|
40
|
+
- [ ] READ gitnexus://repo/my-app/cluster/{name} — check cohesion
|
|
41
|
+
- [ ] Define new module interface
|
|
42
|
+
- [ ] Update imports across affected files
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Split Function
|
|
46
|
+
```
|
|
47
|
+
Split Function:
|
|
48
|
+
- [ ] gitnexus_explore({name: target, type: "symbol", repo: "my-app"}) — understand callees
|
|
49
|
+
- [ ] Group related logic
|
|
50
|
+
- [ ] gitnexus_impact — verify callers won't break
|
|
51
|
+
- [ ] Create new functions
|
|
52
|
+
- [ ] Update callers
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Resource Reference
|
|
56
|
+
|
|
57
|
+
### gitnexus://repo/{name}/schema
|
|
58
|
+
Graph structure for Cypher queries:
|
|
59
|
+
```yaml
|
|
60
|
+
nodes: [Function, Class, Method, Community, Process]
|
|
61
|
+
relationships: [CALLS, IMPORTS, EXTENDS, MEMBER_OF]
|
|
62
|
+
|
|
63
|
+
example_queries:
|
|
64
|
+
find_callers: |
|
|
65
|
+
MATCH (caller)-[:CodeRelation {type: 'CALLS'}]->(f:Function {name: "X"})
|
|
66
|
+
RETURN caller.name
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### gitnexus://repo/{name}/cluster/{clusterName}
|
|
70
|
+
Check if extraction preserves cohesion:
|
|
71
|
+
```yaml
|
|
72
|
+
name: Payment
|
|
73
|
+
cohesion: 92%
|
|
74
|
+
members: [processPayment, validateCard, PaymentService]
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Tool Reference
|
|
78
|
+
|
|
79
|
+
### Finding all references
|
|
80
|
+
```cypher
|
|
81
|
+
MATCH (caller)-[:CodeRelation {type: 'CALLS'}]->(f:Function {name: "validateUser"})
|
|
82
|
+
RETURN caller.name, caller.filePath
|
|
83
|
+
ORDER BY caller.filePath
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Finding imports of a module
|
|
87
|
+
```cypher
|
|
88
|
+
MATCH (importer)-[:CodeRelation {type: 'IMPORTS'}]->(f:File {name: "utils.ts"})
|
|
89
|
+
RETURN importer.name, importer.filePath
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Example: Safely Rename `validateUser` to `authenticateUser`
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
1. gitnexus_impact({target: "validateUser", direction: "upstream", repo: "my-app"})
|
|
96
|
+
→ loginHandler, apiMiddleware, testUtils
|
|
97
|
+
|
|
98
|
+
2. gitnexus_search({query: "validateUser", repo: "my-app"})
|
|
99
|
+
→ Found in: config.json (dynamic reference!)
|
|
100
|
+
|
|
101
|
+
3. READ gitnexus://repo/my-app/processes
|
|
102
|
+
→ LoginFlow, TokenRefresh, APIGateway
|
|
103
|
+
|
|
104
|
+
4. Plan update order:
|
|
105
|
+
1. Update declaration in auth.ts
|
|
106
|
+
2. Update config.json string reference
|
|
107
|
+
3. Update loginHandler
|
|
108
|
+
4. Update apiMiddleware
|
|
109
|
+
5. Run tests for LoginFlow, TokenRefresh
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Refactoring Safety Rules
|
|
113
|
+
|
|
114
|
+
| Risk Factor | Mitigation |
|
|
115
|
+
|-------------|------------|
|
|
116
|
+
| Many callers (>5) | Update in small batches |
|
|
117
|
+
| Cross-cluster | Coordinate with other teams |
|
|
118
|
+
| String references | Search for dynamic usage |
|
|
119
|
+
| Reflection | Check for dynamic invocation |
|
|
120
|
+
| External exports | May break downstream repos |
|