gm-oc 2.0.25 → 2.0.27

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/.mcp.json ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "$schema": "https://schemas.modelcontextprotocol.io/0.1.0/mcp.json"
3
+ }
package/cli.js CHANGED
@@ -2,18 +2,35 @@
2
2
  const fs = require('fs');
3
3
  const path = require('path');
4
4
  const os = require('os');
5
+ const { execSync } = require('child_process');
5
6
 
6
7
  const homeDir = process.env.HOME || process.env.USERPROFILE || os.homedir();
7
- const ocConfigDir = path.join(homeDir, '.config', 'opencode');
8
+ const destDir = process.platform === 'win32'
9
+ ? path.join(homeDir, 'AppData', 'Roaming', 'opencode')
10
+ : path.join(homeDir, '.config', 'opencode');
11
+
8
12
  const srcDir = __dirname;
9
- const pluginMarker = path.join(ocConfigDir, 'plugins', 'gm-oc.mjs');
10
- const isUpgrade = fs.existsSync(pluginMarker);
13
+ const isUpgrade = fs.existsSync(path.join(destDir, 'agents', 'gm.md'));
11
14
 
12
15
  console.log(isUpgrade ? 'Upgrading gm-oc...' : 'Installing gm-oc...');
13
16
 
14
17
  try {
15
- fs.mkdirSync(path.join(ocConfigDir, 'plugins'), { recursive: true });
16
- fs.mkdirSync(path.join(ocConfigDir, 'agents'), { recursive: true });
18
+ fs.mkdirSync(destDir, { recursive: true });
19
+
20
+ const filesToCopy = [
21
+ ['agents', 'agents'],
22
+ ['hooks', 'hooks'],
23
+ ['skills', 'skills'],
24
+ ['index.js', 'index.js'],
25
+ ['gm.js', 'gm.js'],
26
+ ['opencode.json', 'opencode.json'],
27
+ ['.mcp.json', '.mcp.json'],
28
+ ['README.md', 'README.md'],
29
+ ['LICENSE', 'LICENSE'],
30
+ ['CONTRIBUTING.md', 'CONTRIBUTING.md'],
31
+ ['.gitignore', '.gitignore'],
32
+ ['.editorconfig', '.editorconfig']
33
+ ];
17
34
 
18
35
  function copyRecursive(src, dst) {
19
36
  if (!fs.existsSync(src)) return;
@@ -25,38 +42,14 @@ try {
25
42
  }
26
43
  }
27
44
 
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 into opencode config dir
32
- copyRecursive(path.join(srcDir, 'agents'), path.join(ocConfigDir, 'agents'));
33
-
34
- // Write/update opencode.json — set default_agent
35
- const ocJsonPath = path.join(ocConfigDir, 'opencode.json');
36
- let ocConfig = {};
37
- try { ocConfig = JSON.parse(fs.readFileSync(ocJsonPath, 'utf-8')); } catch (e) {}
38
- // Remove stale MCP config (no longer used)
39
- delete ocConfig.mcp;
40
- ocConfig.default_agent = 'gm';
41
- fs.writeFileSync(ocJsonPath, JSON.stringify(ocConfig, null, 2) + '\n');
42
-
43
- // Clean old AppData install location (no longer used by opencode)
44
- const oldDir = process.platform === 'win32'
45
- ? path.join(homeDir, 'AppData', 'Roaming', 'opencode', 'plugin') : null;
46
- if (oldDir && fs.existsSync(oldDir)) {
47
- try { fs.rmSync(oldDir, { recursive: true, force: true }); } catch (e) {}
48
- }
49
-
50
- // Install skills globally via the skills package (supports all agents)
51
- const { execSync: execSync2 } = require('child_process');
52
- try {
53
- execSync2('bunx skills add AnEntrypoint/plugforge --full-depth --all --global --yes', { stdio: 'inherit' });
54
- } catch (e) {
55
- console.warn('Warning: skills install failed (non-fatal):', e.message);
56
- }
45
+ filesToCopy.forEach(([src, dst]) => copyRecursive(path.join(srcDir, src), path.join(destDir, dst)));
57
46
 
58
- console.log(`✓ gm-oc ${isUpgrade ? 'upgraded' : 'installed'} to ${ocConfigDir}`);
47
+ const destPath = process.platform === 'win32'
48
+ ? destDir.replace(/\\/g, '/')
49
+ : destDir;
50
+ console.log(`✓ gm-oc ${isUpgrade ? 'upgraded' : 'installed'} to ${destPath}`);
59
51
  console.log('Restart OpenCode to activate.');
52
+ console.log('Run "opencode agent list" to verify your agent is available.');
60
53
  } catch (e) {
61
54
  console.error('Installation failed:', e.message);
62
55
  process.exit(1);
package/gm.js CHANGED
@@ -1 +1,37 @@
1
- module.exports = require('./gm-oc.mjs');
1
+ const fs = require('fs');
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 };
package/index.js CHANGED
@@ -1 +1 @@
1
- module.exports = { GmPlugin: require('./gm-oc.mjs').GmPlugin };
1
+ module.exports = { GmPlugin: require('./gm.js').GmPlugin };
package/install.js CHANGED
@@ -52,6 +52,23 @@ function safeCopyDirectory(src, dst) {
52
52
  }
53
53
  }
54
54
 
55
+ function safeCopyFile(src, dst) {
56
+ try {
57
+ if (!fs.existsSync(src)) {
58
+ return false;
59
+ }
60
+ const content = fs.readFileSync(src, 'utf-8');
61
+ const dstDir = path.dirname(dst);
62
+ if (!fs.existsSync(dstDir)) {
63
+ fs.mkdirSync(dstDir, { recursive: true });
64
+ }
65
+ fs.writeFileSync(dst, content, 'utf-8');
66
+ return true;
67
+ } catch (err) {
68
+ return false;
69
+ }
70
+ }
71
+
55
72
  function install() {
56
73
  if (!isInsideNodeModules()) {
57
74
  return;
@@ -62,11 +79,13 @@ function install() {
62
79
  return;
63
80
  }
64
81
 
65
- const ocDir = path.join(projectRoot, '.config', 'opencode', 'plugin');
82
+ const ocDir = path.join(projectRoot, '.config', 'opencode');
66
83
  const sourceDir = __dirname;
67
84
 
68
85
  safeCopyDirectory(path.join(sourceDir, 'agents'), path.join(ocDir, 'agents'));
69
86
  safeCopyDirectory(path.join(sourceDir, 'hooks'), path.join(ocDir, 'hooks'));
87
+ safeCopyFile(path.join(sourceDir, 'opencode.json'), path.join(ocDir, 'opencode.json'));
88
+ safeCopyFile(path.join(sourceDir, '.mcp.json'), path.join(ocDir, '.mcp.json'));
70
89
  }
71
90
 
72
91
  install();
package/opencode.json CHANGED
@@ -1,4 +1,7 @@
1
1
  {
2
2
  "$schema": "https://opencode.ai/config.json",
3
- "default_agent": "gm"
3
+ "default_agent": "gm",
4
+ "plugin": [
5
+ "gm-oc"
6
+ ]
4
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-oc",
3
- "version": "2.0.25",
3
+ "version": "2.0.27",
4
4
  "description": "State machine agent with hooks, skills, and automated git enforcement",
5
5
  "author": "AnEntrypoint",
6
6
  "license": "MIT",
@@ -12,6 +12,7 @@
12
12
  "keywords": [
13
13
  "opencode",
14
14
  "opencode-plugin",
15
+ "mcp",
15
16
  "automation",
16
17
  "gm"
17
18
  ],
@@ -29,19 +30,22 @@
29
30
  "publishConfig": {
30
31
  "access": "public"
31
32
  },
32
- "dependencies": {},
33
+ "dependencies": {
34
+ "mcp-thorns": "^4.1.0"
35
+ },
33
36
  "scripts": {
34
37
  "postinstall": "node scripts/postinstall.js"
35
38
  },
36
39
  "files": [
37
40
  "agents/",
38
41
  "hooks/",
42
+ "skills/",
39
43
  "scripts/",
40
44
  "gm.js",
41
- "gm-oc.mjs",
42
45
  "index.js",
43
46
  "opencode.json",
44
47
  ".github/",
48
+ ".mcp.json",
45
49
  "README.md",
46
50
  "cli.js",
47
51
  "install.js",