gitnexushub 0.2.10 → 0.2.12

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.
@@ -1,161 +1,161 @@
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> or git diff main...HEAD → Get changed files
21
- 2. git diff main...HEAD --name-only → Get file list
22
- 3. gitnexus_detect_changes({changed_files: ["file1", "file2", ...]}) → Map to affected flows
23
- 4. For each changed symbol:
24
- gitnexus_impact({target: "<symbol>", direction: "upstream"}) → Blast radius per change
25
- 5. gitnexus_context({name: "<key symbol>"}) → Understand callers/callees
26
- 6. Summarize findings with risk assessment
27
- ```
28
-
29
- ## Checklist
30
-
31
- ```
32
- - [ ] Get PR diff and file list (gh pr diff / git diff --name-only)
33
- - [ ] gitnexus_detect_changes({changed_files: [...]}) to map changes to affected flows
34
- - [ ] gitnexus_impact on each non-trivial changed symbol
35
- - [ ] Review d=1 items (WILL BREAK) — are callers updated?
36
- - [ ] gitnexus_context on key changed symbols to understand full picture
37
- - [ ] Check if affected processes have test coverage
38
- - [ ] Assess overall risk level
39
- - [ ] Write review summary with findings
40
- ```
41
-
42
- ## Review Dimensions
43
-
44
- | Dimension | How GitNexus Helps |
45
- | --- | --- |
46
- | **Correctness** | `context` shows callers — are they all compatible with the change? |
47
- | **Blast radius** | `impact` shows d=1/d=2/d=3 dependents — anything missed? |
48
- | **Completeness** | `detect_changes` shows all affected flows — are they all handled? |
49
- | **Test coverage** | `impact({includeTests: true})` shows which tests touch changed code |
50
- | **Breaking changes** | d=1 upstream items that aren't updated in the PR = potential breakage |
51
-
52
- ## Risk Assessment
53
-
54
- | Signal | Risk |
55
- | --- | --- |
56
- | Changes touch <3 symbols, 0-1 processes | LOW |
57
- | Changes touch 3-10 symbols, 2-5 processes | MEDIUM |
58
- | Changes touch >10 symbols or many processes | HIGH |
59
- | Changes touch auth, payments, or data integrity code | CRITICAL |
60
- | d=1 callers exist outside the PR diff | Potential breakage — flag it |
61
-
62
- ## Tools
63
-
64
- **gitnexus_detect_changes** — map PR diff to affected execution flows:
65
-
66
- ```
67
- gitnexus_detect_changes({changed_files: ["src/payments.ts", "src/checkout.ts", "src/types.ts"]})
68
-
69
- → Changed: 8 symbols in 3 files
70
- → Affected processes: CheckoutFlow, RefundFlow, WebhookHandler
71
- → Risk: MEDIUM
72
- ```
73
-
74
- **gitnexus_impact** — blast radius per changed symbol:
75
-
76
- ```
77
- gitnexus_impact({target: "validatePayment", direction: "upstream"})
78
-
79
- → d=1 (WILL BREAK):
80
- - processCheckout (src/checkout.ts:42) [CALLS, 100%]
81
- - webhookHandler (src/webhooks.ts:15) [CALLS, 100%]
82
-
83
- → d=2 (LIKELY AFFECTED):
84
- - checkoutRouter (src/routes/checkout.ts:22) [CALLS, 95%]
85
- ```
86
-
87
- **gitnexus_impact with tests** — check test coverage:
88
-
89
- ```
90
- gitnexus_impact({target: "validatePayment", direction: "upstream", includeTests: true})
91
-
92
- → Tests that cover this symbol:
93
- - validatePayment.test.ts [direct]
94
- - checkout.integration.test.ts [via processCheckout]
95
- ```
96
-
97
- **gitnexus_context** — understand a changed symbol's role:
98
-
99
- ```
100
- gitnexus_context({name: "validatePayment"})
101
-
102
- → Incoming calls: processCheckout, webhookHandler
103
- → Outgoing calls: verifyCard, fetchRates
104
- → Processes: CheckoutFlow (step 3/7), RefundFlow (step 1/5)
105
- ```
106
-
107
- ## Example: "Review PR #42"
108
-
109
- ```
110
- 1. git diff main...HEAD --name-only
111
- → payments.ts, checkout.ts, types.ts, utils.ts
112
-
113
- 2. gitnexus_detect_changes({changed_files: ["src/payments.ts", "src/checkout.ts", "src/types.ts", "src/utils.ts"]})
114
- → Changed symbols: validatePayment, PaymentInput, formatAmount
115
- → Affected processes: CheckoutFlow, RefundFlow
116
- → Risk: MEDIUM
117
-
118
- 3. gitnexus_impact({target: "validatePayment", direction: "upstream"})
119
- → d=1: processCheckout, webhookHandler (WILL BREAK)
120
- → webhookHandler is NOT in the PR diff — potential breakage!
121
-
122
- 4. gitnexus_impact({target: "PaymentInput", direction: "upstream"})
123
- → d=1: validatePayment (in PR), createPayment (NOT in PR)
124
- → createPayment uses the old PaymentInput shape — breaking change!
125
-
126
- 5. gitnexus_context({name: "formatAmount"})
127
- → Called by 12 functions — but change is backwards-compatible (added optional param)
128
-
129
- 6. Review summary:
130
- - MEDIUM risk — 3 changed symbols affect 2 execution flows
131
- - BUG: webhookHandler calls validatePayment but isn't updated for new signature
132
- - BUG: createPayment depends on PaymentInput type which changed
133
- - OK: formatAmount change is backwards-compatible
134
- - Tests: checkout.test.ts covers processCheckout path, but no webhook test
135
- ```
136
-
137
- ## Review Output Format
138
-
139
- Structure your review as:
140
-
141
- ```markdown
142
- ## PR Review: <title>
143
-
144
- **Risk: LOW / MEDIUM / HIGH / CRITICAL**
145
-
146
- ### Changes Summary
147
- - <N> symbols changed across <M> files
148
- - <P> execution flows affected
149
-
150
- ### Findings
151
- 1. **[severity]** Description of finding
152
- - Evidence from GitNexus tools
153
- - Affected callers/flows
154
-
155
- ### Missing Coverage
156
- - Callers not updated in PR: ...
157
- - Untested flows: ...
158
-
159
- ### Recommendation
160
- APPROVE / REQUEST CHANGES / NEEDS DISCUSSION
161
- ```
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> or git diff main...HEAD → Get changed files
21
+ 2. git diff main...HEAD --name-only → Get file list
22
+ 3. gitnexus_detect_changes({changed_files: ["file1", "file2", ...]}) → Map to affected flows
23
+ 4. For each changed symbol:
24
+ gitnexus_impact({target: "<symbol>", direction: "upstream"}) → Blast radius per change
25
+ 5. gitnexus_context({name: "<key symbol>"}) → Understand callers/callees
26
+ 6. Summarize findings with risk assessment
27
+ ```
28
+
29
+ ## Checklist
30
+
31
+ ```
32
+ - [ ] Get PR diff and file list (gh pr diff / git diff --name-only)
33
+ - [ ] gitnexus_detect_changes({changed_files: [...]}) to map changes to affected flows
34
+ - [ ] gitnexus_impact on each non-trivial changed symbol
35
+ - [ ] Review d=1 items (WILL BREAK) — are callers updated?
36
+ - [ ] gitnexus_context on key changed symbols to understand full picture
37
+ - [ ] Check if affected processes have test coverage
38
+ - [ ] Assess overall risk level
39
+ - [ ] Write review summary with findings
40
+ ```
41
+
42
+ ## Review Dimensions
43
+
44
+ | Dimension | How GitNexus Helps |
45
+ | --- | --- |
46
+ | **Correctness** | `context` shows callers — are they all compatible with the change? |
47
+ | **Blast radius** | `impact` shows d=1/d=2/d=3 dependents — anything missed? |
48
+ | **Completeness** | `detect_changes` shows all affected flows — are they all handled? |
49
+ | **Test coverage** | `impact({includeTests: true})` shows which tests touch changed code |
50
+ | **Breaking changes** | d=1 upstream items that aren't updated in the PR = potential breakage |
51
+
52
+ ## Risk Assessment
53
+
54
+ | Signal | Risk |
55
+ | --- | --- |
56
+ | Changes touch <3 symbols, 0-1 processes | LOW |
57
+ | Changes touch 3-10 symbols, 2-5 processes | MEDIUM |
58
+ | Changes touch >10 symbols or many processes | HIGH |
59
+ | Changes touch auth, payments, or data integrity code | CRITICAL |
60
+ | d=1 callers exist outside the PR diff | Potential breakage — flag it |
61
+
62
+ ## Tools
63
+
64
+ **gitnexus_detect_changes** — map PR diff to affected execution flows:
65
+
66
+ ```
67
+ gitnexus_detect_changes({changed_files: ["src/payments.ts", "src/checkout.ts", "src/types.ts"]})
68
+
69
+ → Changed: 8 symbols in 3 files
70
+ → Affected processes: CheckoutFlow, RefundFlow, WebhookHandler
71
+ → Risk: MEDIUM
72
+ ```
73
+
74
+ **gitnexus_impact** — blast radius per changed symbol:
75
+
76
+ ```
77
+ gitnexus_impact({target: "validatePayment", direction: "upstream"})
78
+
79
+ → d=1 (WILL BREAK):
80
+ - processCheckout (src/checkout.ts:42) [CALLS, 100%]
81
+ - webhookHandler (src/webhooks.ts:15) [CALLS, 100%]
82
+
83
+ → d=2 (LIKELY AFFECTED):
84
+ - checkoutRouter (src/routes/checkout.ts:22) [CALLS, 95%]
85
+ ```
86
+
87
+ **gitnexus_impact with tests** — check test coverage:
88
+
89
+ ```
90
+ gitnexus_impact({target: "validatePayment", direction: "upstream", includeTests: true})
91
+
92
+ → Tests that cover this symbol:
93
+ - validatePayment.test.ts [direct]
94
+ - checkout.integration.test.ts [via processCheckout]
95
+ ```
96
+
97
+ **gitnexus_context** — understand a changed symbol's role:
98
+
99
+ ```
100
+ gitnexus_context({name: "validatePayment"})
101
+
102
+ → Incoming calls: processCheckout, webhookHandler
103
+ → Outgoing calls: verifyCard, fetchRates
104
+ → Processes: CheckoutFlow (step 3/7), RefundFlow (step 1/5)
105
+ ```
106
+
107
+ ## Example: "Review PR #42"
108
+
109
+ ```
110
+ 1. git diff main...HEAD --name-only
111
+ → payments.ts, checkout.ts, types.ts, utils.ts
112
+
113
+ 2. gitnexus_detect_changes({changed_files: ["src/payments.ts", "src/checkout.ts", "src/types.ts", "src/utils.ts"]})
114
+ → Changed symbols: validatePayment, PaymentInput, formatAmount
115
+ → Affected processes: CheckoutFlow, RefundFlow
116
+ → Risk: MEDIUM
117
+
118
+ 3. gitnexus_impact({target: "validatePayment", direction: "upstream"})
119
+ → d=1: processCheckout, webhookHandler (WILL BREAK)
120
+ → webhookHandler is NOT in the PR diff — potential breakage!
121
+
122
+ 4. gitnexus_impact({target: "PaymentInput", direction: "upstream"})
123
+ → d=1: validatePayment (in PR), createPayment (NOT in PR)
124
+ → createPayment uses the old PaymentInput shape — breaking change!
125
+
126
+ 5. gitnexus_context({name: "formatAmount"})
127
+ → Called by 12 functions — but change is backwards-compatible (added optional param)
128
+
129
+ 6. Review summary:
130
+ - MEDIUM risk — 3 changed symbols affect 2 execution flows
131
+ - BUG: webhookHandler calls validatePayment but isn't updated for new signature
132
+ - BUG: createPayment depends on PaymentInput type which changed
133
+ - OK: formatAmount change is backwards-compatible
134
+ - Tests: checkout.test.ts covers processCheckout path, but no webhook test
135
+ ```
136
+
137
+ ## Review Output Format
138
+
139
+ Structure your review as:
140
+
141
+ ```markdown
142
+ ## PR Review: <title>
143
+
144
+ **Risk: LOW / MEDIUM / HIGH / CRITICAL**
145
+
146
+ ### Changes Summary
147
+ - <N> symbols changed across <M> files
148
+ - <P> execution flows affected
149
+
150
+ ### Findings
151
+ 1. **[severity]** Description of finding
152
+ - Evidence from GitNexus tools
153
+ - Affected callers/flows
154
+
155
+ ### Missing Coverage
156
+ - Callers not updated in PR: ...
157
+ - Untested flows: ...
158
+
159
+ ### Recommendation
160
+ APPROVE / REQUEST CHANGES / NEEDS DISCUSSION
161
+ ```
@@ -0,0 +1,121 @@
1
+ ---
2
+ name: gitnexus-refactoring
3
+ description: "Use when the user wants to rename, extract, split, move, or restructure code safely. Examples: \"Rename this function\", \"Extract this into a module\", \"Refactor this class\", \"Move this to a separate file\""
4
+ ---
5
+
6
+ # Refactoring with GitNexus
7
+
8
+ ## When to Use
9
+
10
+ - "Rename this function safely"
11
+ - "Extract this into a module"
12
+ - "Split this service"
13
+ - "Move this to a new file"
14
+ - Any task involving renaming, extracting, splitting, or restructuring code
15
+
16
+ ## Workflow
17
+
18
+ ```
19
+ 1. gitnexus_impact({target: "X", direction: "upstream"}) → Map all dependents
20
+ 2. gitnexus_query({query: "X"}) → Find execution flows involving X
21
+ 3. gitnexus_context({name: "X"}) → See all incoming/outgoing refs
22
+ 4. Plan update order: interfaces → implementations → callers → tests
23
+ ```
24
+
25
+ > If "Index is stale" → run `npx gitnexus analyze` in terminal.
26
+
27
+ ## Checklists
28
+
29
+ ### Rename Symbol
30
+
31
+ ```
32
+ - [ ] gitnexus_rename({symbol_name: "oldName", new_name: "newName", dry_run: true}) — preview all edits
33
+ - [ ] Review graph edits (high confidence) and ast_search edits (review carefully)
34
+ - [ ] If satisfied: gitnexus_rename({..., dry_run: false}) — apply edits
35
+ - [ ] gitnexus_detect_changes() — verify only expected files changed
36
+ - [ ] Run tests for affected processes
37
+ ```
38
+
39
+ ### Extract Module
40
+
41
+ ```
42
+ - [ ] gitnexus_context({name: target}) — see all incoming/outgoing refs
43
+ - [ ] gitnexus_impact({target, direction: "upstream"}) — find all external callers
44
+ - [ ] Define new module interface
45
+ - [ ] Extract code, update imports
46
+ - [ ] gitnexus_detect_changes() — verify affected scope
47
+ - [ ] Run tests for affected processes
48
+ ```
49
+
50
+ ### Split Function/Service
51
+
52
+ ```
53
+ - [ ] gitnexus_context({name: target}) — understand all callees
54
+ - [ ] Group callees by responsibility
55
+ - [ ] gitnexus_impact({target, direction: "upstream"}) — map callers to update
56
+ - [ ] Create new functions/services
57
+ - [ ] Update callers
58
+ - [ ] gitnexus_detect_changes() — verify affected scope
59
+ - [ ] Run tests for affected processes
60
+ ```
61
+
62
+ ## Tools
63
+
64
+ **gitnexus_rename** — automated multi-file rename:
65
+
66
+ ```
67
+ gitnexus_rename({symbol_name: "validateUser", new_name: "authenticateUser", dry_run: true})
68
+ → 12 edits across 8 files
69
+ → 10 graph edits (high confidence), 2 ast_search edits (review)
70
+ → Changes: [{file_path, edits: [{line, old_text, new_text, confidence}]}]
71
+ ```
72
+
73
+ **gitnexus_impact** — map all dependents first:
74
+
75
+ ```
76
+ gitnexus_impact({target: "validateUser", direction: "upstream"})
77
+ → d=1: loginHandler, apiMiddleware, testUtils
78
+ → Affected Processes: LoginFlow, TokenRefresh
79
+ ```
80
+
81
+ **gitnexus_detect_changes** — verify your changes after refactoring:
82
+
83
+ ```
84
+ gitnexus_detect_changes({scope: "all"})
85
+ → Changed: 8 files, 12 symbols
86
+ → Affected processes: LoginFlow, TokenRefresh
87
+ → Risk: MEDIUM
88
+ ```
89
+
90
+ **gitnexus_cypher** — custom reference queries:
91
+
92
+ ```cypher
93
+ MATCH (caller)-[:CodeRelation {type: 'CALLS'}]->(f:Function {name: "validateUser"})
94
+ RETURN caller.name, caller.filePath ORDER BY caller.filePath
95
+ ```
96
+
97
+ ## Risk Rules
98
+
99
+ | Risk Factor | Mitigation |
100
+ | ------------------- | ----------------------------------------- |
101
+ | Many callers (>5) | Use gitnexus_rename for automated updates |
102
+ | Cross-area refs | Use detect_changes after to verify scope |
103
+ | String/dynamic refs | gitnexus_query to find them |
104
+ | External/public API | Version and deprecate properly |
105
+
106
+ ## Example: Rename `validateUser` to `authenticateUser`
107
+
108
+ ```
109
+ 1. gitnexus_rename({symbol_name: "validateUser", new_name: "authenticateUser", dry_run: true})
110
+ → 12 edits: 10 graph (safe), 2 ast_search (review)
111
+ → Files: validator.ts, login.ts, middleware.ts, config.json...
112
+
113
+ 2. Review ast_search edits (config.json: dynamic reference!)
114
+
115
+ 3. gitnexus_rename({symbol_name: "validateUser", new_name: "authenticateUser", dry_run: false})
116
+ → Applied 12 edits across 8 files
117
+
118
+ 4. gitnexus_detect_changes({scope: "all"})
119
+ → Affected: LoginFlow, TokenRefresh
120
+ → Risk: MEDIUM — run tests for these flows
121
+ ```