gm-cc 1.0.0 → 1.0.2

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.
Files changed (2) hide show
  1. package/bin/gm-cc.js +47 -103
  2. package/package.json +1 -2
package/bin/gm-cc.js CHANGED
@@ -2,125 +2,69 @@
2
2
 
3
3
  import fs from 'fs';
4
4
  import path from 'path';
5
- import { fileURLToPath } from 'url';
6
- import { execSync } from 'child_process';
5
+ import { spawnSync } from 'child_process';
7
6
 
8
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
9
7
  const homeDir = process.env.HOME || process.env.USERPROFILE;
10
8
  const claudeSettingsPath = path.join(homeDir, '.claude', 'settings.json');
11
9
 
10
+ const GM_PERMISSIONS = [
11
+ 'Read(.gm)',
12
+ 'Write(.gm)',
13
+ 'Edit(.gm)',
14
+ 'Bash(*gm-plugkit*)',
15
+ 'Bash(*gm-tools*)',
16
+ 'Bash(*plugkit*)'
17
+ ];
18
+
19
+ function installSkill() {
20
+ console.log('Installing gm-skill via skills CLI (--agent claude-code)...');
21
+ const args = ['x', 'skills', 'add', 'AnEntrypoint/gm-skill', '-y', '-g', '--agent', 'claude-code'];
22
+ const r = spawnSync('bun', args, { stdio: 'inherit', shell: process.platform === 'win32' });
23
+ if (r.status === 0) { console.log('✅ Skill installed\n'); return; }
24
+ console.log('bun not available or failed; trying npx fallback...');
25
+ const r2 = spawnSync('npx', ['-y', 'skills', 'add', 'AnEntrypoint/gm-skill', '-y', '-g', '--agent', 'claude-code'],
26
+ { stdio: 'inherit', shell: process.platform === 'win32' });
27
+ if (r2.status === 0) { console.log('✅ Skill installed\n'); return; }
28
+ console.error('⚠️ Skill install failed; install manually: bun x skills add AnEntrypoint/gm-skill -y -g --agent claude-code\n');
29
+ }
30
+
12
31
  async function setup() {
13
32
  console.log('🚀 Setting up gm-cc (Claude Code)...\n');
14
33
 
15
- // Step 1: Ensure plugkit is running
16
- console.log('1️⃣ Bootstrapping plugkit...');
17
- try {
18
- const plugkitCmd = process.platform === 'win32'
19
- ? `bun x gm-plugkit@latest spool > /dev/null 2>&1 &`
20
- : `bun x gm-plugkit@latest spool > /dev/null 2>&1 &`;
21
- execSync(plugkitCmd, { stdio: 'inherit' });
22
- await new Promise(r => setTimeout(r, 2000));
23
- console.log('✅ plugkit started\n');
24
- } catch (e) {
25
- console.log('⚠️ plugkit may already be running\n');
34
+ console.log('Configuring permissions in Claude Code...');
35
+ let settings = {};
36
+ if (fs.existsSync(claudeSettingsPath)) {
37
+ settings = JSON.parse(fs.readFileSync(claudeSettingsPath, 'utf8'));
26
38
  }
27
-
28
- // Step 2: Add gm-skill to Claude Code
29
- console.log('2️⃣ Installing gm-skill for Claude Code...');
30
- try {
31
- execSync('bun x gm-skill add AnEntrypoint/gm-skill -y -g', { stdio: 'inherit' });
32
- console.log('✅ gm-skill installed\n');
33
- } catch (e) {
34
- console.error('❌ Failed to install gm-skill:', e.message);
35
- process.exit(1);
39
+ settings.permissions = settings.permissions || {};
40
+ settings.permissions.allow = settings.permissions.allow || [];
41
+ for (const perm of GM_PERMISSIONS) {
42
+ if (!settings.permissions.allow.includes(perm)) settings.permissions.allow.push(perm);
36
43
  }
44
+ fs.mkdirSync(path.dirname(claudeSettingsPath), { recursive: true });
45
+ fs.writeFileSync(claudeSettingsPath, JSON.stringify(settings, null, 2));
46
+ console.log('✅ Permissions configured in ~/.claude/settings.json\n');
37
47
 
38
- // Step 3: Add permissions to Claude Code settings
39
- console.log('3️⃣ Configuring permissions in Claude Code...');
40
- try {
41
- let settings = {};
42
- if (fs.existsSync(claudeSettingsPath)) {
43
- const content = fs.readFileSync(claudeSettingsPath, 'utf8');
44
- settings = JSON.parse(content);
45
- }
46
-
47
- if (!settings.permissions) {
48
- settings.permissions = { allow: [] };
49
- }
50
- if (!settings.permissions.allow) {
51
- settings.permissions.allow = [];
52
- }
53
-
54
- const gmPermissions = [
55
- 'Read(.gm)',
56
- 'Write(.gm)',
57
- 'Edit(.gm)',
58
- 'Bash(*gm-plugkit*)',
59
- 'Bash(*gm-tools*)',
60
- 'Bash(*plugkit*)'
61
- ];
62
-
63
- gmPermissions.forEach(perm => {
64
- if (!settings.permissions.allow.includes(perm)) {
65
- settings.permissions.allow.push(perm);
66
- }
67
- });
68
-
69
- fs.writeFileSync(claudeSettingsPath, JSON.stringify(settings, null, 2));
70
- console.log('✅ Permissions configured\n');
71
- } catch (e) {
72
- console.error('❌ Failed to configure permissions:', e.message);
73
- process.exit(1);
74
- }
48
+ installSkill();
75
49
 
76
- console.log('🎉 gm-cc setup complete!');
77
- console.log('\nNext steps:');
78
- console.log(' 1. Reload Claude Code: /hooks');
79
- console.log(' 2. Start using gm-skill in Claude Code\n');
50
+ console.log('🎉 gm-cc setup complete!\n');
80
51
  }
81
52
 
82
53
  async function verify() {
83
54
  console.log('🔍 Verifying gm-cc installation...\n');
84
- let allGood = true;
85
-
86
- console.log('Checking Claude Code settings...');
55
+ let ok = true;
87
56
  if (fs.existsSync(claudeSettingsPath)) {
88
57
  const settings = JSON.parse(fs.readFileSync(claudeSettingsPath, 'utf8'));
89
- if (settings.permissions?.allow?.includes('Read(.gm)')) {
90
- console.log('✅ GM permissions configured\n');
91
- } else {
92
- console.log('❌ GM permissions not found\n');
93
- allGood = false;
94
- }
95
- } else {
96
- console.log('⚠️ Claude Code settings not found\n');
97
- }
98
-
99
- if (allGood) {
100
- console.log('🎉 All checks passed!\n');
101
- } else {
102
- console.log('⚠️ Some checks failed. Run setup again.\n');
103
- }
104
- }
105
-
106
- async function main() {
107
- const cmd = process.argv[2] || 'setup';
108
-
109
- switch (cmd) {
110
- case 'setup':
111
- case 'install':
112
- await setup();
113
- break;
114
- case 'verify':
115
- await verify();
116
- break;
117
- default:
118
- console.log('Usage: gm-cc <setup|verify>');
119
- process.exit(1);
120
- }
58
+ const have = new Set(settings.permissions?.allow || []);
59
+ const missing = GM_PERMISSIONS.filter(p => !have.has(p));
60
+ if (missing.length === 0) console.log('✅ All GM permissions present');
61
+ else { console.log('❌ Missing permissions:', missing.join(', ')); ok = false; }
62
+ } else { console.log('⚠️ Claude settings not found'); ok = false; }
63
+ const skillPath = path.join(homeDir, '.claude', 'skills', 'gm-skill', 'SKILL.md');
64
+ if (fs.existsSync(skillPath)) console.log('✅ Skill installed at', skillPath);
65
+ else { console.log(' Skill not found at', skillPath); ok = false; }
66
+ console.log(ok ? '\n🎉 All checks passed!' : '\n⚠️ Some checks failed.');
121
67
  }
122
68
 
123
- main().catch(e => {
124
- console.error('Error:', e);
125
- process.exit(1);
126
- });
69
+ const cmd = process.argv[2] || 'setup';
70
+ ({ setup, install: setup, verify })[cmd]?.() ?? (console.log('Usage: gm-cc <setup|verify>'), process.exit(1));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-cc",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Claude Code integration for GM orchestration engine",
5
5
  "type": "module",
6
6
  "bin": {
@@ -8,7 +8,6 @@
8
8
  },
9
9
  "scripts": {
10
10
  "setup": "node bin/gm-cc.js setup",
11
- "install": "node bin/gm-cc.js install",
12
11
  "verify": "node bin/gm-cc.js verify"
13
12
  },
14
13
  "keywords": ["gm", "claude-code", "agent", "orchestration"],