gitnexushub 0.4.5 → 0.6.0
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 +90 -1
- package/dist/api.js +34 -0
- package/dist/index.js +27 -0
- package/dist/install-ci-command.d.ts +176 -0
- package/dist/install-ci-command.js +680 -0
- package/dist/wiki/claude.d.ts +11 -5
- package/dist/wiki/claude.js +8 -3
- package/dist/wiki/compose-overview.d.ts +29 -0
- package/dist/wiki/compose-overview.js +48 -0
- package/dist/wiki/concurrency.d.ts +20 -0
- package/dist/wiki/concurrency.js +91 -0
- package/dist/wiki/helpers.d.ts +102 -0
- package/dist/wiki/helpers.js +308 -0
- package/dist/wiki/incremental.d.ts +72 -0
- package/dist/wiki/incremental.js +214 -0
- package/dist/wiki/index.js +37 -0
- package/dist/wiki/session.d.ts +10 -0
- package/dist/wiki/session.js +89 -9
- package/dist/wiki/upload-command.d.ts +12 -0
- package/dist/wiki/upload-command.js +384 -53
- package/hooks/gitnexus-enterprise-hook.cjs +134 -0
- package/package.json +1 -1
- package/skills/gitnexus-debugging.md +89 -89
- package/skills/gitnexus-exploring.md +78 -78
- package/skills/gitnexus-impact-analysis.md +99 -99
- package/skills/gitnexus-pr-review.md +161 -161
|
@@ -368,7 +368,51 @@ function writeMetaCache(repoId, meta) {
|
|
|
368
368
|
}
|
|
369
369
|
}
|
|
370
370
|
|
|
371
|
+
/**
|
|
372
|
+
* Edit-closure capture. After Edit/Write/MultiEdit succeeds in the agent,
|
|
373
|
+
* fire a fire-and-forget POST telling the hub which file was edited. The
|
|
374
|
+
* hub correlates against recent MCP result_symbols to record whether
|
|
375
|
+
* GitNexus drove this edit (the strongest possible quality signal).
|
|
376
|
+
*
|
|
377
|
+
* Best-effort: never blocks the editor, never re-tries, swallows errors.
|
|
378
|
+
*/
|
|
379
|
+
async function handleEditObservation(input, config, entry) {
|
|
380
|
+
const tool = input.tool_name;
|
|
381
|
+
if (tool !== 'Edit' && tool !== 'Write' && tool !== 'MultiEdit') return;
|
|
382
|
+
|
|
383
|
+
// Only fire when the edit succeeded. Some editors omit exit info; treat
|
|
384
|
+
// missing as success so we don't drop legitimate edits.
|
|
385
|
+
const out = input.tool_output;
|
|
386
|
+
if (out && out.exit_code !== undefined && out.exit_code !== 0) return;
|
|
387
|
+
if (out && out.error) return;
|
|
388
|
+
|
|
389
|
+
const filePath = (input.tool_input && input.tool_input.file_path) || '';
|
|
390
|
+
if (!filePath || typeof filePath !== 'string') return;
|
|
391
|
+
|
|
392
|
+
// Best-effort line extraction. Edit tool input often carries a `line`
|
|
393
|
+
// hint; MultiEdit usually doesn't.
|
|
394
|
+
const line = Number.isInteger(input.tool_input && input.tool_input.line)
|
|
395
|
+
? Number(input.tool_input.line)
|
|
396
|
+
: null;
|
|
397
|
+
|
|
398
|
+
await httpPostJson(`${config.hubUrl}/api/activity/edit-observed`, authHeaders(config), {
|
|
399
|
+
sessionId: input.session_id || null,
|
|
400
|
+
repoId: entry.hubRepoId,
|
|
401
|
+
filePath,
|
|
402
|
+
line,
|
|
403
|
+
tool,
|
|
404
|
+
agentName: 'claude-code',
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
|
|
371
408
|
async function handlePostToolUse(input, config, entry) {
|
|
409
|
+
// Fan out: edit observations are independent of the git-staleness check.
|
|
410
|
+
// Both run on PostToolUse; we don't want one to block the other.
|
|
411
|
+
if (input.tool_name === 'Edit' || input.tool_name === 'Write' || input.tool_name === 'MultiEdit') {
|
|
412
|
+
await handleEditObservation(input, config, entry);
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
|
|
372
416
|
if (input.tool_name !== 'Bash') return;
|
|
373
417
|
const cmd = (input.tool_input && input.tool_input.command) || '';
|
|
374
418
|
if (!/\bgit\s+(commit|merge|rebase|cherry-pick|pull)(\s|$)/.test(cmd)) return;
|
|
@@ -411,6 +455,89 @@ async function handlePostToolUse(input, config, entry) {
|
|
|
411
455
|
);
|
|
412
456
|
}
|
|
413
457
|
|
|
458
|
+
// ─── Soft-nudge upgrade flow ──────────────────────────────────────────────
|
|
459
|
+
//
|
|
460
|
+
// Hook version is read from the bundled package.json. Once per local day
|
|
461
|
+
// we hit /api/activity/hook-version and compare. If the published latest
|
|
462
|
+
// is ahead of ours, we print a single stderr line — never blocks editing.
|
|
463
|
+
// State is held in ~/.gitnexus/hook-version-check.json so we don't spam
|
|
464
|
+
// the hub on every PreToolUse.
|
|
465
|
+
|
|
466
|
+
const VERSION_CHECK_FILE = path.join(os.homedir(), '.gitnexus', 'hook-version-check.json');
|
|
467
|
+
const VERSION_CHECK_TTL_MS = 24 * 60 * 60 * 1000; // once per day
|
|
468
|
+
|
|
469
|
+
function readPackageVersion() {
|
|
470
|
+
try {
|
|
471
|
+
const pkgPath = path.join(__dirname, '..', 'package.json');
|
|
472
|
+
return JSON.parse(fs.readFileSync(pkgPath, 'utf-8')).version || null;
|
|
473
|
+
} catch {
|
|
474
|
+
return null;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
function readVersionCheckState() {
|
|
479
|
+
try {
|
|
480
|
+
const stat = fs.statSync(VERSION_CHECK_FILE);
|
|
481
|
+
if (Date.now() - stat.mtimeMs > VERSION_CHECK_TTL_MS) return null;
|
|
482
|
+
return JSON.parse(fs.readFileSync(VERSION_CHECK_FILE, 'utf-8'));
|
|
483
|
+
} catch {
|
|
484
|
+
return null;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
function writeVersionCheckState(state) {
|
|
489
|
+
try {
|
|
490
|
+
fs.mkdirSync(path.dirname(VERSION_CHECK_FILE), { recursive: true });
|
|
491
|
+
fs.writeFileSync(VERSION_CHECK_FILE, JSON.stringify(state));
|
|
492
|
+
} catch {
|
|
493
|
+
/* ignore — best effort */
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* Compare two semver strings (major.minor.patch only — pre-releases ignored).
|
|
499
|
+
* Returns -1 if a < b, 0 if equal, 1 if a > b. Defensive against malformed.
|
|
500
|
+
*/
|
|
501
|
+
function compareSemver(a, b) {
|
|
502
|
+
const pa = String(a || '0.0.0')
|
|
503
|
+
.split('.')
|
|
504
|
+
.map((n) => parseInt(n, 10) || 0);
|
|
505
|
+
const pb = String(b || '0.0.0')
|
|
506
|
+
.split('.')
|
|
507
|
+
.map((n) => parseInt(n, 10) || 0);
|
|
508
|
+
for (let i = 0; i < 3; i++) {
|
|
509
|
+
const x = pa[i] || 0;
|
|
510
|
+
const y = pb[i] || 0;
|
|
511
|
+
if (x < y) return -1;
|
|
512
|
+
if (x > y) return 1;
|
|
513
|
+
}
|
|
514
|
+
return 0;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
async function maybeNudgeUpgrade(config) {
|
|
518
|
+
const local = readPackageVersion();
|
|
519
|
+
if (!local) return;
|
|
520
|
+
|
|
521
|
+
const cached = readVersionCheckState();
|
|
522
|
+
if (cached && compareSemver(local, cached.latestVersion) >= 0) return;
|
|
523
|
+
|
|
524
|
+
const res = await httpGetJson(`${config.hubUrl}/api/activity/hook-version`, authHeaders(config));
|
|
525
|
+
if (!res || res.status !== 200 || !res.body) return;
|
|
526
|
+
|
|
527
|
+
const latest = res.body.latestVersion;
|
|
528
|
+
if (!latest) return;
|
|
529
|
+
|
|
530
|
+
writeVersionCheckState({ latestVersion: latest, checkedAt: Date.now() });
|
|
531
|
+
|
|
532
|
+
if (compareSemver(local, latest) < 0) {
|
|
533
|
+
const note = res.body.notes ? ` — ${res.body.notes}` : '';
|
|
534
|
+
process.stderr.write(
|
|
535
|
+
`[gitnexus] connect hook ${local} → update available (${latest})${note}. ` +
|
|
536
|
+
`Run: npm update -g gitnexushub\n`,
|
|
537
|
+
);
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
|
|
414
541
|
async function main() {
|
|
415
542
|
if (process.env.GITNEXUS_NO_AUGMENT === '1') return;
|
|
416
543
|
|
|
@@ -421,6 +548,13 @@ async function main() {
|
|
|
421
548
|
const config = readConfig();
|
|
422
549
|
if (!config || !config.hubToken || !config.hubUrl) return;
|
|
423
550
|
|
|
551
|
+
// Once-per-day soft-nudge if we're behind. Best-effort, won't block.
|
|
552
|
+
// Skipped entirely on PostToolUse so the editor's response path stays
|
|
553
|
+
// hot — PreToolUse fires more often, so the check still happens daily.
|
|
554
|
+
if (event === 'PreToolUse') {
|
|
555
|
+
maybeNudgeUpgrade(config).catch(() => {});
|
|
556
|
+
}
|
|
557
|
+
|
|
424
558
|
const entries = readRegistry();
|
|
425
559
|
const cwd = input.cwd || process.cwd();
|
|
426
560
|
const entry = resolveCwdToRepo(cwd, entries);
|
package/package.json
CHANGED
|
@@ -1,89 +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" → trigger re-indexing from the Hub dashboard.
|
|
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 | `impact` on changed functions → check what callers broke |
|
|
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
|
-
```
|
|
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" → trigger re-indexing from the Hub dashboard.
|
|
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 | `impact` on changed functions → check what callers broke |
|
|
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
|
+
```
|
|
@@ -1,78 +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" → trigger re-indexing from the Hub dashboard.
|
|
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
|
-
```
|
|
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" → trigger re-indexing from the Hub dashboard.
|
|
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
|
+
```
|