gm-oc 2.0.21 → 2.0.23
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/cli.js +27 -37
- package/gm-oc.mjs +25 -0
- package/gm.js +1 -37
- package/index.js +1 -1
- package/package.json +2 -1
package/cli.js
CHANGED
|
@@ -2,41 +2,18 @@
|
|
|
2
2
|
const fs = require('fs');
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const os = require('os');
|
|
5
|
-
const { execSync } = require('child_process');
|
|
6
5
|
|
|
7
6
|
const homeDir = process.env.HOME || process.env.USERPROFILE || os.homedir();
|
|
8
|
-
const
|
|
9
|
-
? path.join(homeDir, 'AppData', 'Roaming', 'opencode', 'plugin')
|
|
10
|
-
: path.join(homeDir, '.config', 'opencode', 'plugin');
|
|
11
|
-
|
|
7
|
+
const ocConfigDir = path.join(homeDir, '.config', 'opencode');
|
|
12
8
|
const srcDir = __dirname;
|
|
13
|
-
const
|
|
9
|
+
const pluginMarker = path.join(ocConfigDir, 'plugins', 'gm-oc.mjs');
|
|
10
|
+
const isUpgrade = fs.existsSync(pluginMarker);
|
|
14
11
|
|
|
15
12
|
console.log(isUpgrade ? 'Upgrading gm-oc...' : 'Installing gm-oc...');
|
|
16
13
|
|
|
17
14
|
try {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const p = path.join(destDir, dir);
|
|
21
|
-
if (fs.existsSync(p)) fs.rmSync(p, { recursive: true, force: true });
|
|
22
|
-
}
|
|
23
|
-
fs.mkdirSync(destDir, { recursive: true });
|
|
24
|
-
|
|
25
|
-
const filesToCopy = [
|
|
26
|
-
['agents', 'agents'],
|
|
27
|
-
['hooks', 'hooks'],
|
|
28
|
-
['skills', 'skills'],
|
|
29
|
-
['index.js', 'index.js'],
|
|
30
|
-
['gm.js', 'gm.js'],
|
|
31
|
-
['opencode.json', 'opencode.json'],
|
|
32
|
-
['package.json', 'package.json'],
|
|
33
|
-
['.mcp.json', '.mcp.json'],
|
|
34
|
-
['README.md', 'README.md'],
|
|
35
|
-
['LICENSE', 'LICENSE'],
|
|
36
|
-
['CONTRIBUTING.md', 'CONTRIBUTING.md'],
|
|
37
|
-
['.gitignore', '.gitignore'],
|
|
38
|
-
['.editorconfig', '.editorconfig']
|
|
39
|
-
];
|
|
15
|
+
fs.mkdirSync(path.join(ocConfigDir, 'plugins'), { recursive: true });
|
|
16
|
+
fs.mkdirSync(path.join(ocConfigDir, 'agents'), { recursive: true });
|
|
40
17
|
|
|
41
18
|
function copyRecursive(src, dst) {
|
|
42
19
|
if (!fs.existsSync(src)) return;
|
|
@@ -48,19 +25,32 @@ try {
|
|
|
48
25
|
}
|
|
49
26
|
}
|
|
50
27
|
|
|
51
|
-
|
|
28
|
+
// Install ESM plugin for opencode auto-loading from plugins directory
|
|
29
|
+
fs.copyFileSync(path.join(srcDir, 'gm-oc.mjs'), path.join(ocConfigDir, 'plugins', 'gm-oc.mjs'));
|
|
30
|
+
|
|
31
|
+
// Copy agents and skills into opencode config dir
|
|
32
|
+
copyRecursive(path.join(srcDir, 'agents'), path.join(ocConfigDir, 'agents'));
|
|
33
|
+
copyRecursive(path.join(srcDir, 'skills'), path.join(ocConfigDir, 'skills'));
|
|
52
34
|
|
|
35
|
+
// Write/update opencode.json — merge MCP from package, set default_agent
|
|
36
|
+
const ocJsonPath = path.join(ocConfigDir, 'opencode.json');
|
|
37
|
+
let ocConfig = {};
|
|
38
|
+
try { ocConfig = JSON.parse(fs.readFileSync(ocJsonPath, 'utf-8')); } catch (e) {}
|
|
53
39
|
try {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
} catch (e) {
|
|
57
|
-
|
|
40
|
+
const pkgConfig = JSON.parse(fs.readFileSync(path.join(srcDir, 'opencode.json'), 'utf-8'));
|
|
41
|
+
if (pkgConfig.mcp) ocConfig.mcp = Object.assign({}, pkgConfig.mcp, ocConfig.mcp);
|
|
42
|
+
} catch (e) {}
|
|
43
|
+
ocConfig.default_agent = 'gm';
|
|
44
|
+
fs.writeFileSync(ocJsonPath, JSON.stringify(ocConfig, null, 2) + '\n');
|
|
45
|
+
|
|
46
|
+
// Clean old AppData install location (no longer used by opencode)
|
|
47
|
+
const oldDir = process.platform === 'win32'
|
|
48
|
+
? path.join(homeDir, 'AppData', 'Roaming', 'opencode', 'plugin') : null;
|
|
49
|
+
if (oldDir && fs.existsSync(oldDir)) {
|
|
50
|
+
try { fs.rmSync(oldDir, { recursive: true, force: true }); } catch (e) {}
|
|
58
51
|
}
|
|
59
52
|
|
|
60
|
-
|
|
61
|
-
? destDir.replace(/\\/g, '/')
|
|
62
|
-
: destDir;
|
|
63
|
-
console.log(`✓ gm-oc ${isUpgrade ? 'upgraded' : 'installed'} to ${destPath}`);
|
|
53
|
+
console.log(`✓ gm-oc ${isUpgrade ? 'upgraded' : 'installed'} to ${ocConfigDir}`);
|
|
64
54
|
console.log('Restart OpenCode to activate.');
|
|
65
55
|
} catch (e) {
|
|
66
56
|
console.error('Installation failed:', e.message);
|
package/gm-oc.mjs
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { readFileSync, existsSync } from 'fs';
|
|
2
|
+
import { join, dirname } from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
|
|
5
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
6
|
+
|
|
7
|
+
export async function GmPlugin({ directory }) {
|
|
8
|
+
const agentMd = join(__dirname, '..', 'agents', 'gm.md');
|
|
9
|
+
const prdFile = join(directory, '.prd');
|
|
10
|
+
|
|
11
|
+
return {
|
|
12
|
+
'experimental.chat.system.transform': async (input, output) => {
|
|
13
|
+
try {
|
|
14
|
+
const rules = readFileSync(agentMd, 'utf-8');
|
|
15
|
+
if (rules) output.system.unshift(rules);
|
|
16
|
+
} catch (e) {}
|
|
17
|
+
try {
|
|
18
|
+
if (existsSync(prdFile)) {
|
|
19
|
+
const prd = readFileSync(prdFile, 'utf-8').trim();
|
|
20
|
+
if (prd) output.system.push('\nPENDING WORK (.prd):\n' + prd);
|
|
21
|
+
}
|
|
22
|
+
} catch (e) {}
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
package/gm.js
CHANGED
|
@@ -1,37 +1 @@
|
|
|
1
|
-
|
|
2
|
-
const path = require('path');
|
|
3
|
-
|
|
4
|
-
const GmPlugin = async ({ project, client, $, directory, worktree }) => {
|
|
5
|
-
const pluginDir = __dirname;
|
|
6
|
-
let agentRules = '';
|
|
7
|
-
|
|
8
|
-
const loadAgentRules = () => {
|
|
9
|
-
if (agentRules) return agentRules;
|
|
10
|
-
const agentMd = path.join(pluginDir, 'agents', 'gm.md');
|
|
11
|
-
try { agentRules = fs.readFileSync(agentMd, 'utf-8'); } catch (e) {}
|
|
12
|
-
return agentRules;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const prdFile = path.join(directory, '.prd');
|
|
16
|
-
|
|
17
|
-
return {
|
|
18
|
-
onLoad: async () => {
|
|
19
|
-
console.log('✓ gm plugin loaded');
|
|
20
|
-
},
|
|
21
|
-
|
|
22
|
-
getSystemPrompt: async () => {
|
|
23
|
-
const rules = loadAgentRules();
|
|
24
|
-
const prd = fs.existsSync(prdFile) ? fs.readFileSync(prdFile, 'utf-8').trim() : '';
|
|
25
|
-
let prompt = rules || '';
|
|
26
|
-
if (prd) prompt += '\n\nPENDING WORK (.prd):\n' + prd;
|
|
27
|
-
return prompt;
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
onSessionEnd: async () => {
|
|
31
|
-
const prd = fs.existsSync(prdFile) ? fs.readFileSync(prdFile, 'utf-8').trim() : '';
|
|
32
|
-
if (prd) throw new Error('Work items remain in .prd - commit changes before exiting');
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
module.exports = { GmPlugin };
|
|
1
|
+
module.exports = require('./gm-oc.mjs');
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports = { GmPlugin: require('./gm.
|
|
1
|
+
module.exports = { GmPlugin: require('./gm-oc.mjs').GmPlugin };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gm-oc",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.23",
|
|
4
4
|
"description": "Advanced Claude Code plugin with WFGY integration, MCP tools, and automated hooks",
|
|
5
5
|
"author": "AnEntrypoint",
|
|
6
6
|
"license": "MIT",
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"skills/",
|
|
43
43
|
"scripts/",
|
|
44
44
|
"gm.js",
|
|
45
|
+
"gm-oc.mjs",
|
|
45
46
|
"index.js",
|
|
46
47
|
"opencode.json",
|
|
47
48
|
".github/",
|