gm-oc 1.0.0
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 +95 -0
- package/package.json +20 -0
package/bin/gm-oc.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
import { execSync } from 'child_process';
|
|
7
|
+
|
|
8
|
+
const homeDir = process.env.HOME || process.env.USERPROFILE;
|
|
9
|
+
const opencodeConfigPath = path.join(homeDir, '.opencode', 'config.json');
|
|
10
|
+
|
|
11
|
+
async function setup() {
|
|
12
|
+
console.log('🚀 Setting up gm-oc (OpenCode)...\n');
|
|
13
|
+
|
|
14
|
+
// Step 1: Ensure plugkit is running
|
|
15
|
+
console.log('1️⃣ Bootstrapping plugkit...');
|
|
16
|
+
try {
|
|
17
|
+
const plugkitCmd = process.platform === 'win32'
|
|
18
|
+
? `bun x gm-plugkit@latest spool > /dev/null 2>&1 &`
|
|
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');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Step 2: Create OpenCode config if needed
|
|
28
|
+
console.log('2️⃣ Configuring OpenCode...');
|
|
29
|
+
try {
|
|
30
|
+
const configDir = path.dirname(opencodeConfigPath);
|
|
31
|
+
if (!fs.existsSync(configDir)) {
|
|
32
|
+
fs.mkdirSync(configDir, { recursive: true });
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
let config = {};
|
|
36
|
+
if (fs.existsSync(opencodeConfigPath)) {
|
|
37
|
+
config = JSON.parse(fs.readFileSync(opencodeConfigPath, 'utf8'));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
config.routing = config.routing || {};
|
|
41
|
+
config.routing['gm-skill'] = {
|
|
42
|
+
enabled: true,
|
|
43
|
+
entry: 'gm-skill',
|
|
44
|
+
orchestrator: 'plugkit'
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
fs.writeFileSync(opencodeConfigPath, JSON.stringify(config, null, 2));
|
|
48
|
+
console.log('✅ OpenCode configured\n');
|
|
49
|
+
} catch (e) {
|
|
50
|
+
console.error('❌ Failed to configure OpenCode:', e.message);
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
|
|
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');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function verify() {
|
|
61
|
+
console.log('🔍 Verifying gm-oc installation...\n');
|
|
62
|
+
|
|
63
|
+
if (fs.existsSync(opencodeConfigPath)) {
|
|
64
|
+
const config = JSON.parse(fs.readFileSync(opencodeConfigPath, 'utf8'));
|
|
65
|
+
if (config.routing?.['gm-skill']?.enabled) {
|
|
66
|
+
console.log('✅ GM routing configured for OpenCode\n');
|
|
67
|
+
} else {
|
|
68
|
+
console.log('⚠️ GM routing not enabled\n');
|
|
69
|
+
}
|
|
70
|
+
} else {
|
|
71
|
+
console.log('⚠️ OpenCode config not found\n');
|
|
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
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
main().catch(e => {
|
|
93
|
+
console.error('Error:', e);
|
|
94
|
+
process.exit(1);
|
|
95
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "gm-oc",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "OpenCode integration for GM orchestration engine",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"gm-oc": "./bin/gm-oc.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"setup": "node bin/gm-oc.js setup",
|
|
11
|
+
"install": "node bin/gm-oc.js install",
|
|
12
|
+
"verify": "node bin/gm-oc.js verify"
|
|
13
|
+
},
|
|
14
|
+
"keywords": ["gm", "opencode", "agent", "orchestration"],
|
|
15
|
+
"author": "admin@coas.co.za",
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=18.0.0"
|
|
19
|
+
}
|
|
20
|
+
}
|