gm-oc 1.0.1 → 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 +60 -61
- package/package.json +1 -2
package/bin/gm-oc.js
CHANGED
|
@@ -2,81 +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
|
-
if (
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
let config = {};
|
|
23
|
-
if (fs.existsSync(opencodeConfigPath)) {
|
|
24
|
-
config = JSON.parse(fs.readFileSync(opencodeConfigPath, 'utf8'));
|
|
25
|
-
}
|
|
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);
|
|
41
|
+
}
|
|
26
42
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
enabled: true,
|
|
30
|
-
entry: 'gm-skill',
|
|
31
|
-
orchestrator: 'plugkit'
|
|
32
|
-
};
|
|
43
|
+
// Compaction
|
|
44
|
+
config.compaction = { ...COMPACTION, ...(config.compaction || {}) };
|
|
33
45
|
|
|
34
|
-
|
|
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 };
|
|
39
51
|
}
|
|
40
52
|
|
|
41
|
-
|
|
42
|
-
console.log('
|
|
43
|
-
console.log(
|
|
44
|
-
console.log(
|
|
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`);
|
|
57
|
+
|
|
58
|
+
installSkill();
|
|
59
|
+
|
|
60
|
+
console.log('🎉 gm-oc setup complete!\n');
|
|
45
61
|
}
|
|
46
62
|
|
|
47
63
|
async function verify() {
|
|
48
64
|
console.log('🔍 Verifying gm-oc installation...\n');
|
|
49
|
-
|
|
50
|
-
if (fs.existsSync(
|
|
51
|
-
const
|
|
52
|
-
if (
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
+
}
|
|
56
75
|
}
|
|
57
|
-
} else {
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
async function main() {
|
|
63
|
-
const cmd = process.argv[2] || 'setup';
|
|
64
|
-
|
|
65
|
-
switch (cmd) {
|
|
66
|
-
case 'setup':
|
|
67
|
-
case 'install':
|
|
68
|
-
await setup();
|
|
69
|
-
break;
|
|
70
|
-
case 'verify':
|
|
71
|
-
await verify();
|
|
72
|
-
break;
|
|
73
|
-
default:
|
|
74
|
-
console.log('Usage: gm-oc <setup|verify>');
|
|
75
|
-
process.exit(1);
|
|
76
|
-
}
|
|
76
|
+
} else { console.log('⚠️ OpenCode config not found'); ok = false; }
|
|
77
|
+
console.log(ok ? '\n🎉 All checks passed!' : '\n⚠️ Some checks failed.');
|
|
77
78
|
}
|
|
78
79
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
process.exit(1);
|
|
82
|
-
});
|
|
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"],
|