gitnexushub 0.2.11 → 0.3.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 CHANGED
@@ -53,7 +53,10 @@ export interface RepoDetail {
53
53
  export declare class HubAPI {
54
54
  private hubUrl;
55
55
  private token;
56
+ private fingerprint;
57
+ private deviceName;
56
58
  constructor(hubUrl: string, token: string);
59
+ private get authHeaders();
57
60
  private request;
58
61
  private post;
59
62
  getMe(): Promise<UserProfile>;
package/dist/api.js CHANGED
@@ -3,17 +3,29 @@
3
3
  *
4
4
  * Fetch-based, zero-dependency API client for GitNexus Hub.
5
5
  */
6
+ import { computeFingerprint, getDeviceName } from './fingerprint.js';
6
7
  export class HubAPI {
7
8
  hubUrl;
8
9
  token;
10
+ fingerprint;
11
+ deviceName;
9
12
  constructor(hubUrl, token) {
10
13
  this.hubUrl = hubUrl;
11
14
  this.token = token;
15
+ this.fingerprint = computeFingerprint();
16
+ this.deviceName = getDeviceName();
17
+ }
18
+ get authHeaders() {
19
+ return {
20
+ Authorization: `Bearer ${this.token}`,
21
+ 'X-Device-Fingerprint': this.fingerprint,
22
+ 'X-Device-Name': this.deviceName,
23
+ };
12
24
  }
13
25
  async request(path) {
14
26
  const url = `${this.hubUrl}${path}`;
15
27
  const res = await fetch(url, {
16
- headers: { Authorization: `Bearer ${this.token}` },
28
+ headers: this.authHeaders,
17
29
  });
18
30
  if (!res.ok) {
19
31
  const body = await res.json().catch(() => ({ error: res.statusText }));
@@ -26,7 +38,7 @@ export class HubAPI {
26
38
  const res = await fetch(url, {
27
39
  method: 'POST',
28
40
  headers: {
29
- Authorization: `Bearer ${this.token}`,
41
+ ...this.authHeaders,
30
42
  'Content-Type': 'application/json',
31
43
  },
32
44
  body: JSON.stringify(body),
package/dist/config.js CHANGED
@@ -20,7 +20,23 @@ export async function saveConfig(updates) {
20
20
  export async function clearConfig() {
21
21
  try {
22
22
  const fs = await import('fs/promises');
23
- await fs.rm(CONFIG_DIR, { recursive: true, force: true });
23
+ // Only remove connect-specific keys, not the entire ~/.gitnexus/ dir
24
+ // (other tools like `gitnexus wiki` store their own config here)
25
+ const existing = await loadConfig();
26
+ if (!existing.hubToken && !existing.hubUrl)
27
+ return; // nothing to clear
28
+ const config = await readJsonFile(CONFIG_PATH);
29
+ if (config) {
30
+ delete config.hubToken;
31
+ delete config.hubUrl;
32
+ // If nothing left, remove the file; otherwise rewrite
33
+ if (Object.keys(config).length === 0) {
34
+ await fs.rm(CONFIG_PATH, { force: true });
35
+ }
36
+ else {
37
+ await writeJsonFile(CONFIG_PATH, config);
38
+ }
39
+ }
24
40
  }
25
41
  catch {
26
42
  // Already gone
package/dist/content.js CHANGED
@@ -16,6 +16,8 @@ export const HUB_SKILLS = [
16
16
  'gitnexus-exploring',
17
17
  'gitnexus-debugging',
18
18
  'gitnexus-impact-analysis',
19
+ 'gitnexus-refactoring',
20
+ 'gitnexus-guide',
19
21
  'gitnexus-pr-review',
20
22
  ];
21
23
  /**
@@ -23,68 +25,68 @@ export const HUB_SKILLS = [
23
25
  * No detect_changes or rename references (not available via Hub MCP).
24
26
  */
25
27
  function generateHubContent(projectName, stats) {
26
- return `${GITNEXUS_START_MARKER}
27
- # GitNexus — Code Intelligence
28
-
29
- This project is indexed by GitNexus as **${projectName}** (${stats.nodes || 0} symbols, ${stats.edges || 0} relationships, ${stats.processes || 0} execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely.
30
-
31
- > Re-indexing is managed from the GitNexus Hub dashboard.
32
-
33
- ## Always Do
34
-
35
- - **MUST run impact analysis before editing any symbol.** Before modifying a function, class, or method, run \`gitnexus_impact({target: "symbolName", direction: "upstream"})\` and report the blast radius (direct callers, affected processes, risk level) to the user.
36
- - **MUST warn the user** if impact analysis returns HIGH or CRITICAL risk before proceeding with edits.
37
- - When exploring unfamiliar code, use \`gitnexus_query({query: "concept"})\` to find execution flows instead of grepping. It returns process-grouped results ranked by relevance.
38
- - When you need full context on a specific symbol — callers, callees, which execution flows it participates in — use \`gitnexus_context({name: "symbolName"})\`.
39
-
40
- ## When Debugging
41
-
42
- 1. \`gitnexus_query({query: "<error or symptom>"})\` — find execution flows related to the issue
43
- 2. \`gitnexus_context({name: "<suspect function>"})\` — see all callers, callees, and process participation
44
- 3. \`READ gitnexus://repo/${projectName}/process/{processName}\` — trace the full execution flow step by step
45
-
46
- ## When Refactoring
47
-
48
- - **Extracting/Splitting**: MUST run \`gitnexus_context({name: "target"})\` to see all incoming/outgoing refs, then \`gitnexus_impact({target: "target", direction: "upstream"})\` to find all external callers before moving code.
49
-
50
- ## Never Do
51
-
52
- - NEVER edit a function, class, or method without first running \`gitnexus_impact\` on it.
53
- - NEVER ignore HIGH or CRITICAL risk warnings from impact analysis.
54
-
55
- ## Tools Quick Reference
56
-
57
- | Tool | When to use | Command |
58
- |------|-------------|---------|
59
- | \`query\` | Find code by concept | \`gitnexus_query({query: "auth validation"})\` |
60
- | \`context\` | 360-degree view of one symbol | \`gitnexus_context({name: "validateUser"})\` |
61
- | \`impact\` | Blast radius before editing | \`gitnexus_impact({target: "X", direction: "upstream"})\` |
62
- | \`cypher\` | Custom graph queries | \`gitnexus_cypher({query: "MATCH ..."})\` |
63
-
64
- ## Impact Risk Levels
65
-
66
- | Depth | Meaning | Action |
67
- |-------|---------|--------|
68
- | d=1 | WILL BREAK — direct callers/importers | MUST update these |
69
- | d=2 | LIKELY AFFECTED — indirect deps | Should test |
70
- | d=3 | MAY NEED TESTING — transitive | Test if critical path |
71
-
72
- ## Resources
73
-
74
- | Resource | Use for |
75
- |----------|---------|
76
- | \`gitnexus://repo/${projectName}/context\` | Codebase overview, check index freshness |
77
- | \`gitnexus://repo/${projectName}/clusters\` | All functional areas |
78
- | \`gitnexus://repo/${projectName}/processes\` | All execution flows |
79
- | \`gitnexus://repo/${projectName}/process/{name}\` | Step-by-step execution trace |
80
-
81
- ## Self-Check Before Finishing
82
-
83
- Before completing any code modification task, verify:
84
- 1. \`gitnexus_impact\` was run for all modified symbols
85
- 2. No HIGH/CRITICAL risk warnings were ignored
86
- 3. All d=1 (WILL BREAK) dependents were updated
87
-
28
+ return `${GITNEXUS_START_MARKER}
29
+ # GitNexus — Code Intelligence
30
+
31
+ This project is indexed by GitNexus as **${projectName}** (${stats.nodes || 0} symbols, ${stats.edges || 0} relationships, ${stats.processes || 0} execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely.
32
+
33
+ > Re-indexing is managed from the GitNexus Hub dashboard.
34
+
35
+ ## Always Do
36
+
37
+ - **MUST run impact analysis before editing any symbol.** Before modifying a function, class, or method, run \`gitnexus_impact({target: "symbolName", direction: "upstream"})\` and report the blast radius (direct callers, affected processes, risk level) to the user.
38
+ - **MUST warn the user** if impact analysis returns HIGH or CRITICAL risk before proceeding with edits.
39
+ - When exploring unfamiliar code, use \`gitnexus_query({query: "concept"})\` to find execution flows instead of grepping. It returns process-grouped results ranked by relevance.
40
+ - When you need full context on a specific symbol — callers, callees, which execution flows it participates in — use \`gitnexus_context({name: "symbolName"})\`.
41
+
42
+ ## When Debugging
43
+
44
+ 1. \`gitnexus_query({query: "<error or symptom>"})\` — find execution flows related to the issue
45
+ 2. \`gitnexus_context({name: "<suspect function>"})\` — see all callers, callees, and process participation
46
+ 3. \`READ gitnexus://repo/${projectName}/process/{processName}\` — trace the full execution flow step by step
47
+
48
+ ## When Refactoring
49
+
50
+ - **Extracting/Splitting**: MUST run \`gitnexus_context({name: "target"})\` to see all incoming/outgoing refs, then \`gitnexus_impact({target: "target", direction: "upstream"})\` to find all external callers before moving code.
51
+
52
+ ## Never Do
53
+
54
+ - NEVER edit a function, class, or method without first running \`gitnexus_impact\` on it.
55
+ - NEVER ignore HIGH or CRITICAL risk warnings from impact analysis.
56
+
57
+ ## Tools Quick Reference
58
+
59
+ | Tool | When to use | Command |
60
+ |------|-------------|---------|
61
+ | \`query\` | Find code by concept | \`gitnexus_query({query: "auth validation"})\` |
62
+ | \`context\` | 360-degree view of one symbol | \`gitnexus_context({name: "validateUser"})\` |
63
+ | \`impact\` | Blast radius before editing | \`gitnexus_impact({target: "X", direction: "upstream"})\` |
64
+ | \`cypher\` | Custom graph queries | \`gitnexus_cypher({query: "MATCH ..."})\` |
65
+
66
+ ## Impact Risk Levels
67
+
68
+ | Depth | Meaning | Action |
69
+ |-------|---------|--------|
70
+ | d=1 | WILL BREAK — direct callers/importers | MUST update these |
71
+ | d=2 | LIKELY AFFECTED — indirect deps | Should test |
72
+ | d=3 | MAY NEED TESTING — transitive | Test if critical path |
73
+
74
+ ## Resources
75
+
76
+ | Resource | Use for |
77
+ |----------|---------|
78
+ | \`gitnexus://repo/${projectName}/context\` | Codebase overview, check index freshness |
79
+ | \`gitnexus://repo/${projectName}/clusters\` | All functional areas |
80
+ | \`gitnexus://repo/${projectName}/processes\` | All execution flows |
81
+ | \`gitnexus://repo/${projectName}/process/{name}\` | Step-by-step execution trace |
82
+
83
+ ## Self-Check Before Finishing
84
+
85
+ Before completing any code modification task, verify:
86
+ 1. \`gitnexus_impact\` was run for all modified symbols
87
+ 2. No HIGH/CRITICAL risk warnings were ignored
88
+ 3. All d=1 (WILL BREAK) dependents were updated
89
+
88
90
  ${GITNEXUS_END_MARKER}`;
89
91
  }
90
92
  /**
@@ -9,6 +9,7 @@ import path from 'path';
9
9
  import fs from 'fs/promises';
10
10
  import { readJsonFile, writeJsonFile } from '../utils.js';
11
11
  import { HUB_SKILLS } from '../content.js';
12
+ import { computeFingerprint, getDeviceName } from '../fingerprint.js';
12
13
  async function configure(hubUrl, token) {
13
14
  const mcpUrl = `${hubUrl}/mcp`;
14
15
  try {
@@ -21,7 +22,11 @@ async function configure(hubUrl, token) {
21
22
  existing.mcpServers.gitnexus = {
22
23
  type: 'http',
23
24
  url: mcpUrl,
24
- headers: { Authorization: `Bearer ${token}` },
25
+ headers: {
26
+ Authorization: `Bearer ${token}`,
27
+ 'X-Device-Fingerprint': computeFingerprint(),
28
+ 'X-Device-Name': getDeviceName(),
29
+ },
25
30
  };
26
31
  await writeJsonFile(claudeJsonPath, existing);
27
32
  return { success: true, message: 'MCP configured in ~/.claude.json', overrodeCli };
@@ -9,11 +9,16 @@ import path from 'path';
9
9
  import fs from 'fs/promises';
10
10
  import { readJsonFile, writeJsonFile } from '../utils.js';
11
11
  import { HUB_SKILLS } from '../content.js';
12
+ import { computeFingerprint, getDeviceName } from '../fingerprint.js';
12
13
  function getMcpConfig(hubUrl, token) {
13
14
  return {
14
15
  type: 'streamable-http',
15
16
  url: `${hubUrl}/mcp`,
16
- headers: { Authorization: `Bearer ${token}` },
17
+ headers: {
18
+ Authorization: `Bearer ${token}`,
19
+ 'X-Device-Fingerprint': computeFingerprint(),
20
+ 'X-Device-Name': getDeviceName(),
21
+ },
17
22
  };
18
23
  }
19
24
  async function configure(hubUrl, token) {
@@ -70,7 +75,9 @@ async function removeSkills() {
70
75
  await fs.rm(path.join(skillsDir, name), { recursive: true, force: true });
71
76
  removed++;
72
77
  }
73
- catch { /* already gone */ }
78
+ catch {
79
+ /* already gone */
80
+ }
74
81
  }
75
82
  return removed;
76
83
  }
@@ -9,11 +9,16 @@ import path from 'path';
9
9
  import fs from 'fs/promises';
10
10
  import { readJsonFile, writeJsonFile } from '../utils.js';
11
11
  import { HUB_SKILLS } from '../content.js';
12
+ import { computeFingerprint, getDeviceName } from '../fingerprint.js';
12
13
  function getMcpConfig(hubUrl, token) {
13
14
  return {
14
15
  type: 'remote',
15
16
  url: `${hubUrl}/mcp`,
16
- headers: { Authorization: `Bearer ${token}` },
17
+ headers: {
18
+ Authorization: `Bearer ${token}`,
19
+ 'X-Device-Fingerprint': computeFingerprint(),
20
+ 'X-Device-Name': getDeviceName(),
21
+ },
17
22
  };
18
23
  }
19
24
  async function configure(hubUrl, token) {
@@ -26,7 +31,11 @@ async function configure(hubUrl, token) {
26
31
  const overrodeCli = !!(existing.mcp.gitnexus && 'command' in existing.mcp.gitnexus);
27
32
  existing.mcp.gitnexus = getMcpConfig(hubUrl, token);
28
33
  await writeJsonFile(configPath, existing);
29
- return { success: true, message: 'MCP configured in ~/.config/opencode/opencode.json', overrodeCli };
34
+ return {
35
+ success: true,
36
+ message: 'MCP configured in ~/.config/opencode/opencode.json',
37
+ overrodeCli,
38
+ };
30
39
  }
31
40
  catch (err) {
32
41
  return { success: false, message: `Failed: ${err.message}` };
@@ -70,7 +79,9 @@ async function removeSkills() {
70
79
  await fs.rm(path.join(skillsDir, name), { recursive: true, force: true });
71
80
  removed++;
72
81
  }
73
- catch { /* already gone */ }
82
+ catch {
83
+ /* already gone */
84
+ }
74
85
  }
75
86
  return removed;
76
87
  }
@@ -9,10 +9,15 @@ import path from 'path';
9
9
  import fs from 'fs/promises';
10
10
  import { readJsonFile, writeJsonFile } from '../utils.js';
11
11
  import { HUB_SKILLS } from '../content.js';
12
+ import { computeFingerprint, getDeviceName } from '../fingerprint.js';
12
13
  function getMcpConfig(hubUrl, token) {
13
14
  return {
14
15
  serverUrl: `${hubUrl}/mcp`,
15
- headers: { Authorization: `Bearer ${token}` },
16
+ headers: {
17
+ Authorization: `Bearer ${token}`,
18
+ 'X-Device-Fingerprint': computeFingerprint(),
19
+ 'X-Device-Name': getDeviceName(),
20
+ },
16
21
  };
17
22
  }
18
23
  async function configure(hubUrl, token) {
@@ -25,7 +30,11 @@ async function configure(hubUrl, token) {
25
30
  const overrodeCli = !!(existing.mcpServers.gitnexus && 'command' in existing.mcpServers.gitnexus);
26
31
  existing.mcpServers.gitnexus = getMcpConfig(hubUrl, token);
27
32
  await writeJsonFile(mcpPath, existing);
28
- return { success: true, message: 'MCP configured in ~/.codeium/windsurf/mcp_config.json', overrodeCli };
33
+ return {
34
+ success: true,
35
+ message: 'MCP configured in ~/.codeium/windsurf/mcp_config.json',
36
+ overrodeCli,
37
+ };
29
38
  }
30
39
  catch (err) {
31
40
  return { success: false, message: `Failed: ${err.message}` };
@@ -69,7 +78,9 @@ async function removeSkills() {
69
78
  await fs.rm(path.join(skillsDir, name), { recursive: true, force: true });
70
79
  removed++;
71
80
  }
72
- catch { /* already gone */ }
81
+ catch {
82
+ /* already gone */
83
+ }
73
84
  }
74
85
  return removed;
75
86
  }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Device Fingerprint
3
+ *
4
+ * Computes a stable fingerprint for the current device.
5
+ * Used to bind device tokens to specific machines.
6
+ * Same algorithm as gitnexus/src/cli/auth.ts:computeFingerprint().
7
+ */
8
+ /** SHA-256 hash of hostname:username:platform:arch, truncated to 16 hex chars. */
9
+ export declare function computeFingerprint(): string;
10
+ /** Human-readable device name: USER@HOSTNAME */
11
+ export declare function getDeviceName(): string;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Device Fingerprint
3
+ *
4
+ * Computes a stable fingerprint for the current device.
5
+ * Used to bind device tokens to specific machines.
6
+ * Same algorithm as gitnexus/src/cli/auth.ts:computeFingerprint().
7
+ */
8
+ import os from 'os';
9
+ import crypto from 'crypto';
10
+ /** SHA-256 hash of hostname:username:platform:arch, truncated to 16 hex chars. */
11
+ export function computeFingerprint() {
12
+ const identity = `${os.hostname()}:${os.userInfo().username}:${os.platform()}:${os.arch()}`;
13
+ return crypto.createHash('sha256').update(identity).digest('hex').slice(0, 16);
14
+ }
15
+ /** Human-readable device name: USER@HOSTNAME */
16
+ export function getDeviceName() {
17
+ return `${os.userInfo().username}@${os.hostname()}`;
18
+ }
package/dist/index.js CHANGED
@@ -22,7 +22,7 @@ import { cursorEditor } from './editors/cursor.js';
22
22
  import { windsurfEditor } from './editors/windsurf.js';
23
23
  import { opencodeEditor } from './editors/opencode.js';
24
24
  import { claudeCodeEditor } from './editors/claude-code.js';
25
- const DEFAULT_HUB_URL = 'https://gitnexus-enterprise-production.up.railway.app';
25
+ const DEFAULT_HUB_URL = process.env.GITNEXUS_HUB_URL || 'https://gitnexus-enterprise-production.up.railway.app';
26
26
  const EDITORS = {
27
27
  'claude-code': claudeCodeEditor,
28
28
  cursor: cursorEditor,
package/package.json CHANGED
@@ -1,53 +1,55 @@
1
- {
2
- "name": "gitnexushub",
3
- "version": "0.2.11",
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
- }
1
+ {
2
+ "name": "gitnexushub",
3
+ "version": "0.3.0",
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
+ "test": "vitest run",
35
+ "prepare": "npm run build"
36
+ },
37
+ "dependencies": {
38
+ "commander": "^12.0.0",
39
+ "picocolors": "^1.1.1"
40
+ },
41
+ "devDependencies": {
42
+ "@types/node": "^20.19.37",
43
+ "tsx": "^4.0.0",
44
+ "typescript": "^5.4.5",
45
+ "vitest": "^4.1.4"
46
+ },
47
+ "engines": {
48
+ "node": ">=18.0.0"
49
+ },
50
+ "files": [
51
+ "dist",
52
+ "skills"
53
+ ],
54
+ "publishConfig": {}
55
+ }
@@ -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,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
+ ```