gitnexushub 0.2.4 → 0.2.6

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,7 +1,7 @@
1
1
  /**
2
2
  * Claude Code Editor Setup
3
3
  *
4
- * Runs `claude mcp add` CLI command, or falls back to writing ~/.claude.json.
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
- * Runs `claude mcp add` CLI command, or falls back to writing ~/.claude.json.
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: 'streamable-http',
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 GITNEXUS_SKILL_NAMES) {
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
@@ -7,8 +7,11 @@
7
7
  * disconnect Remove all GitNexus config, skills, and project files
8
8
  * index Trigger indexing for a GitHub repo on the Hub
9
9
  */
10
+ import { createRequire } from 'module';
10
11
  import { Command } from 'commander';
11
12
  import pc from 'picocolors';
13
+ const require = createRequire(import.meta.url);
14
+ const PKG_VERSION = require('../package.json').version;
12
15
  import { loadConfig, saveConfig, clearConfig } from './config.js';
13
16
  import { HubAPI } from './api.js';
14
17
  import { isGitRepo, getGitRemoteUrl, parseGitRemote, matchRepo } from './project.js';
@@ -84,7 +87,7 @@ const program = new Command();
84
87
  program
85
88
  .name('gnx')
86
89
  .description('Connect your editor to GitNexus Hub')
87
- .version('0.2.0');
90
+ .version(PKG_VERSION);
88
91
  // ─── Default command: connect ─────────────────────────────────────
89
92
  const connectOpts = (cmd) => cmd
90
93
  .argument('[token]', 'gnx_ API token (optional if already saved)')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitnexushub",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "Connect your editor to GitNexus Hub — one command MCP setup + project context",
5
5
  "author": "Abhigyan Patwari",
6
6
  "license": "PolyForm-Noncommercial-1.0.0",