gitnexushub 0.2.5 → 0.2.7
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/editors/claude-code.d.ts +1 -1
- package/dist/editors/claude-code.js +17 -63
- package/dist/index.js +9 -10
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Claude Code Editor Setup
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Writes MCP config directly to ~/.claude.json (top-level mcpServers key).
|
|
5
5
|
* Skills are installed to ~/.claude/skills/.
|
|
6
6
|
*/
|
|
7
7
|
import type { EditorConfig } from './types.js';
|
|
@@ -1,45 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Claude Code Editor Setup
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Writes MCP config directly to ~/.claude.json (top-level mcpServers key).
|
|
5
5
|
* Skills are installed to ~/.claude/skills/.
|
|
6
6
|
*/
|
|
7
7
|
import os from 'os';
|
|
8
8
|
import path from 'path';
|
|
9
9
|
import fs from 'fs/promises';
|
|
10
|
-
import { execSync } from 'child_process';
|
|
11
10
|
import { readJsonFile, writeJsonFile } from '../utils.js';
|
|
12
11
|
import { HUB_SKILLS } from '../content.js';
|
|
13
|
-
const GITNEXUS_SKILL_NAMES = HUB_SKILLS;
|
|
14
|
-
function isClaudeOnPath() {
|
|
15
|
-
try {
|
|
16
|
-
execSync('claude --version', { stdio: 'pipe' });
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
catch {
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
12
|
async function configure(hubUrl, token) {
|
|
24
13
|
const mcpUrl = `${hubUrl}/mcp`;
|
|
25
|
-
const headerValue = `Authorization: Bearer ${token}`;
|
|
26
|
-
// Try `claude mcp add` first
|
|
27
|
-
if (isClaudeOnPath()) {
|
|
28
|
-
try {
|
|
29
|
-
const cmd = `claude mcp add gitnexus --transport http --header "${headerValue}" -s user "${mcpUrl}"`;
|
|
30
|
-
if (process.platform === 'win32') {
|
|
31
|
-
execSync(`cmd /c ${cmd}`, { stdio: 'pipe' });
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
execSync(cmd, { stdio: 'pipe' });
|
|
35
|
-
}
|
|
36
|
-
return { success: true, message: 'MCP configured via `claude mcp add`' };
|
|
37
|
-
}
|
|
38
|
-
catch {
|
|
39
|
-
// Fall through to file-based config
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
// Fallback: write ~/.claude.json
|
|
43
14
|
try {
|
|
44
15
|
const claudeJsonPath = path.join(os.homedir(), '.claude.json');
|
|
45
16
|
const existing = (await readJsonFile(claudeJsonPath)) || {};
|
|
@@ -47,7 +18,7 @@ async function configure(hubUrl, token) {
|
|
|
47
18
|
existing.mcpServers = {};
|
|
48
19
|
}
|
|
49
20
|
existing.mcpServers.gitnexus = {
|
|
50
|
-
type: '
|
|
21
|
+
type: 'http',
|
|
51
22
|
url: mcpUrl,
|
|
52
23
|
headers: { Authorization: `Bearer ${token}` },
|
|
53
24
|
};
|
|
@@ -58,6 +29,20 @@ async function configure(hubUrl, token) {
|
|
|
58
29
|
return { success: false, message: `Failed: ${err.message}` };
|
|
59
30
|
}
|
|
60
31
|
}
|
|
32
|
+
async function unconfigure() {
|
|
33
|
+
try {
|
|
34
|
+
const claudeJsonPath = path.join(os.homedir(), '.claude.json');
|
|
35
|
+
const existing = await readJsonFile(claudeJsonPath);
|
|
36
|
+
if (existing?.mcpServers?.gitnexus) {
|
|
37
|
+
delete existing.mcpServers.gitnexus;
|
|
38
|
+
await writeJsonFile(claudeJsonPath, existing);
|
|
39
|
+
}
|
|
40
|
+
return { success: true, message: 'MCP removed from ~/.claude.json' };
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
return { success: false, message: `Failed: ${err.message}` };
|
|
44
|
+
}
|
|
45
|
+
}
|
|
61
46
|
async function installSkills(skills) {
|
|
62
47
|
const skillsDir = path.join(os.homedir(), '.claude', 'skills');
|
|
63
48
|
let installed = 0;
|
|
@@ -74,41 +59,10 @@ async function installSkills(skills) {
|
|
|
74
59
|
}
|
|
75
60
|
return installed;
|
|
76
61
|
}
|
|
77
|
-
async function unconfigure() {
|
|
78
|
-
// Try `claude mcp remove` first
|
|
79
|
-
if (isClaudeOnPath()) {
|
|
80
|
-
try {
|
|
81
|
-
const cmd = 'claude mcp remove gitnexus';
|
|
82
|
-
if (process.platform === 'win32') {
|
|
83
|
-
execSync(`cmd /c ${cmd}`, { stdio: 'pipe' });
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
execSync(cmd, { stdio: 'pipe' });
|
|
87
|
-
}
|
|
88
|
-
return { success: true, message: 'MCP removed via `claude mcp remove`' };
|
|
89
|
-
}
|
|
90
|
-
catch {
|
|
91
|
-
// Fall through to file-based removal
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
// Fallback: remove from ~/.claude.json
|
|
95
|
-
try {
|
|
96
|
-
const claudeJsonPath = path.join(os.homedir(), '.claude.json');
|
|
97
|
-
const existing = await readJsonFile(claudeJsonPath);
|
|
98
|
-
if (existing?.mcpServers?.gitnexus) {
|
|
99
|
-
delete existing.mcpServers.gitnexus;
|
|
100
|
-
await writeJsonFile(claudeJsonPath, existing);
|
|
101
|
-
}
|
|
102
|
-
return { success: true, message: 'MCP removed from ~/.claude.json' };
|
|
103
|
-
}
|
|
104
|
-
catch (err) {
|
|
105
|
-
return { success: false, message: `Failed: ${err.message}` };
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
62
|
async function removeSkills() {
|
|
109
63
|
const skillsDir = path.join(os.homedir(), '.claude', 'skills');
|
|
110
64
|
let removed = 0;
|
|
111
|
-
for (const name of
|
|
65
|
+
for (const name of HUB_SKILLS) {
|
|
112
66
|
try {
|
|
113
67
|
await fs.rm(path.join(skillsDir, name), { recursive: true, force: true });
|
|
114
68
|
removed++;
|
package/dist/index.js
CHANGED
|
@@ -88,12 +88,7 @@ program
|
|
|
88
88
|
.name('gnx')
|
|
89
89
|
.description('Connect your editor to GitNexus Hub')
|
|
90
90
|
.version(PKG_VERSION);
|
|
91
|
-
// ───
|
|
92
|
-
const connectOpts = (cmd) => cmd
|
|
93
|
-
.argument('[token]', 'gnx_ API token (optional if already saved)')
|
|
94
|
-
.option('--editor <name>', 'Editor to configure: claude-code | cursor | windsurf | opencode')
|
|
95
|
-
.option('--hub <url>', 'Hub URL', DEFAULT_HUB_URL)
|
|
96
|
-
.option('--skip-project', 'Only configure MCP, skip project files');
|
|
91
|
+
// ─── connect command (also the default) ──────────────────────────
|
|
97
92
|
const connectAction = async (tokenArg, opts) => {
|
|
98
93
|
try {
|
|
99
94
|
printBanner();
|
|
@@ -106,10 +101,14 @@ const connectAction = async (tokenArg, opts) => {
|
|
|
106
101
|
process.exit(1);
|
|
107
102
|
}
|
|
108
103
|
};
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
104
|
+
program
|
|
105
|
+
.command('connect', { isDefault: true })
|
|
106
|
+
.description('Register Hub MCP, install skills, and write project files')
|
|
107
|
+
.argument('[token]', 'gnx_ API token (optional if already saved)')
|
|
108
|
+
.option('--editor <name>', 'Editor to configure: claude-code | cursor | windsurf | opencode')
|
|
109
|
+
.option('--hub <url>', 'Hub URL', DEFAULT_HUB_URL)
|
|
110
|
+
.option('--skip-project', 'Only configure MCP, skip project files')
|
|
111
|
+
.action(connectAction);
|
|
113
112
|
// ─── disconnect command ───────────────────────────────────────────
|
|
114
113
|
program
|
|
115
114
|
.command('disconnect')
|
package/package.json
CHANGED