gm-oc 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.
- package/bin/gm-oc.js +58 -72
- package/package.json +1 -2
package/bin/gm-oc.js
CHANGED
|
@@ -2,94 +2,80 @@
|
|
|
2
2
|
|
|
3
3
|
import fs from 'fs';
|
|
4
4
|
import path from 'path';
|
|
5
|
-
import {
|
|
6
|
-
import { execSync } from 'child_process';
|
|
5
|
+
import { spawnSync } from 'child_process';
|
|
7
6
|
|
|
8
7
|
const homeDir = process.env.HOME || process.env.USERPROFILE;
|
|
9
|
-
const
|
|
8
|
+
const configPath = path.join(homeDir, '.config', 'opencode', 'opencode.json');
|
|
9
|
+
|
|
10
|
+
// Equivocal-to-Claude settings ported into OpenCode's schema.
|
|
11
|
+
// permission.{bash,read,edit} glob rules ↔ Claude permissions.allow
|
|
12
|
+
// compaction.auto + reserved ↔ CLAUDE_AUTOCOMPACT_PCT_OVERRIDE (no direct % knob)
|
|
13
|
+
// thinking/effortLevel: provider-specific only — set at model level, not here.
|
|
14
|
+
const PERMISSION_RULES = {
|
|
15
|
+
bash: { '*plugkit*': 'allow', '*gm-plugkit*': 'allow', '*gm-tools*': 'allow' },
|
|
16
|
+
read: { '.gm/**': 'allow' },
|
|
17
|
+
edit: { '.gm/**': 'allow' }
|
|
18
|
+
};
|
|
19
|
+
const COMPACTION = { auto: true, prune: true, reserved: 10000 };
|
|
20
|
+
|
|
21
|
+
function installSkill() {
|
|
22
|
+
console.log('Installing gm-skill via skills CLI (--agent opencode)...');
|
|
23
|
+
const r = spawnSync('bun', ['x', 'skills', 'add', 'AnEntrypoint/gm-skill', '-y', '-g', '--agent', 'opencode'],
|
|
24
|
+
{ stdio: 'inherit', shell: process.platform === 'win32' });
|
|
25
|
+
if (r.status === 0) { console.log('✅ Skill installed\n'); return; }
|
|
26
|
+
console.log('bun not available or failed; trying npx fallback...');
|
|
27
|
+
const r2 = spawnSync('npx', ['-y', 'skills', 'add', 'AnEntrypoint/gm-skill', '-y', '-g', '--agent', 'opencode'],
|
|
28
|
+
{ stdio: 'inherit', shell: process.platform === 'win32' });
|
|
29
|
+
if (r2.status === 0) { console.log('✅ Skill installed\n'); return; }
|
|
30
|
+
console.error('⚠️ Skill install failed; install manually: bun x skills add AnEntrypoint/gm-skill -y -g --agent opencode\n');
|
|
31
|
+
}
|
|
10
32
|
|
|
11
33
|
async function setup() {
|
|
12
34
|
console.log('🚀 Setting up gm-oc (OpenCode)...\n');
|
|
13
35
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
: `bun x gm-plugkit@latest spool > /dev/null 2>&1 &`;
|
|
20
|
-
execSync(plugkitCmd, { stdio: 'inherit' });
|
|
21
|
-
await new Promise(r => setTimeout(r, 2000));
|
|
22
|
-
console.log('✅ plugkit started\n');
|
|
23
|
-
} catch (e) {
|
|
24
|
-
console.log('⚠️ plugkit may already be running\n');
|
|
36
|
+
fs.mkdirSync(path.dirname(configPath), { recursive: true });
|
|
37
|
+
let config = {};
|
|
38
|
+
if (fs.existsSync(configPath)) {
|
|
39
|
+
const raw = fs.readFileSync(configPath, 'utf8').trim();
|
|
40
|
+
if (raw) config = JSON.parse(raw);
|
|
25
41
|
}
|
|
26
42
|
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
try {
|
|
30
|
-
const configDir = path.dirname(opencodeConfigPath);
|
|
31
|
-
if (!fs.existsSync(configDir)) {
|
|
32
|
-
fs.mkdirSync(configDir, { recursive: true });
|
|
33
|
-
}
|
|
43
|
+
// Compaction
|
|
44
|
+
config.compaction = { ...COMPACTION, ...(config.compaction || {}) };
|
|
34
45
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
46
|
+
// Permissions
|
|
47
|
+
config.permission = config.permission || {};
|
|
48
|
+
for (const [tool, rules] of Object.entries(PERMISSION_RULES)) {
|
|
49
|
+
const existing = (typeof config.permission[tool] === 'object' && config.permission[tool]) ? config.permission[tool] : {};
|
|
50
|
+
config.permission[tool] = { ...existing, ...rules };
|
|
51
|
+
}
|
|
39
52
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
orchestrator: 'plugkit'
|
|
45
|
-
};
|
|
53
|
+
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
54
|
+
console.log('✅ Configured ~/.config/opencode/opencode.json');
|
|
55
|
+
console.log(` compaction.auto = true, reserved = ${COMPACTION.reserved}`);
|
|
56
|
+
console.log(` permission.bash, .read, .edit allow plugkit/.gm/**\n`);
|
|
46
57
|
|
|
47
|
-
|
|
48
|
-
console.log('✅ OpenCode configured\n');
|
|
49
|
-
} catch (e) {
|
|
50
|
-
console.error('❌ Failed to configure OpenCode:', e.message);
|
|
51
|
-
process.exit(1);
|
|
52
|
-
}
|
|
58
|
+
installSkill();
|
|
53
59
|
|
|
54
|
-
console.log('🎉 gm-oc setup complete
|
|
55
|
-
console.log('\nNext steps:');
|
|
56
|
-
console.log(' 1. Start OpenCode');
|
|
57
|
-
console.log(' 2. GM orchestration will initialize automatically\n');
|
|
60
|
+
console.log('🎉 gm-oc setup complete!\n');
|
|
58
61
|
}
|
|
59
62
|
|
|
60
63
|
async function verify() {
|
|
61
64
|
console.log('🔍 Verifying gm-oc installation...\n');
|
|
62
|
-
|
|
63
|
-
if (fs.existsSync(
|
|
64
|
-
const
|
|
65
|
-
if (
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
let ok = true;
|
|
66
|
+
if (fs.existsSync(configPath)) {
|
|
67
|
+
const c = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
68
|
+
if (c.compaction?.auto === true) console.log('✅ compaction.auto = true');
|
|
69
|
+
else { console.log('❌ compaction not configured'); ok = false; }
|
|
70
|
+
for (const [tool, rules] of Object.entries(PERMISSION_RULES)) {
|
|
71
|
+
for (const [pat, val] of Object.entries(rules)) {
|
|
72
|
+
if (c.permission?.[tool]?.[pat] === val) console.log(`✅ permission.${tool}["${pat}"] = ${val}`);
|
|
73
|
+
else { console.log(`❌ permission.${tool}["${pat}"] missing`); ok = false; }
|
|
74
|
+
}
|
|
69
75
|
}
|
|
70
|
-
} else {
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
async function main() {
|
|
76
|
-
const cmd = process.argv[2] || 'setup';
|
|
77
|
-
|
|
78
|
-
switch (cmd) {
|
|
79
|
-
case 'setup':
|
|
80
|
-
case 'install':
|
|
81
|
-
await setup();
|
|
82
|
-
break;
|
|
83
|
-
case 'verify':
|
|
84
|
-
await verify();
|
|
85
|
-
break;
|
|
86
|
-
default:
|
|
87
|
-
console.log('Usage: gm-oc <setup|verify>');
|
|
88
|
-
process.exit(1);
|
|
89
|
-
}
|
|
76
|
+
} else { console.log('⚠️ OpenCode config not found'); ok = false; }
|
|
77
|
+
console.log(ok ? '\n🎉 All checks passed!' : '\n⚠️ Some checks failed.');
|
|
90
78
|
}
|
|
91
79
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
process.exit(1);
|
|
95
|
-
});
|
|
80
|
+
const cmd = process.argv[2] || 'setup';
|
|
81
|
+
({ setup, install: setup, verify })[cmd]?.() ?? (console.log('Usage: gm-oc <setup|verify>'), process.exit(1));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gm-oc",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "OpenCode 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-oc.js setup",
|
|
11
|
-
"install": "node bin/gm-oc.js install",
|
|
12
11
|
"verify": "node bin/gm-oc.js verify"
|
|
13
12
|
},
|
|
14
13
|
"keywords": ["gm", "opencode", "agent", "orchestration"],
|