gm-oc 2.0.40 → 2.0.41
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 +8 -0
- package/gm.mjs +13 -13
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -44,6 +44,14 @@ try {
|
|
|
44
44
|
|
|
45
45
|
filesToCopy.forEach(([src, dst]) => copyRecursive(path.join(srcDir, src), path.join(destDir, dst)));
|
|
46
46
|
|
|
47
|
+
// Also write to plugins/gm-oc.mjs - the actual file OpenCode loads
|
|
48
|
+
const pluginsDir = path.join(destDir, 'plugins');
|
|
49
|
+
fs.mkdirSync(pluginsDir, { recursive: true });
|
|
50
|
+
const gmMjsSrc = path.join(srcDir, 'gm.mjs');
|
|
51
|
+
if (fs.existsSync(gmMjsSrc)) {
|
|
52
|
+
fs.copyFileSync(gmMjsSrc, path.join(pluginsDir, 'gm-oc.mjs'));
|
|
53
|
+
}
|
|
54
|
+
|
|
47
55
|
const destPath = process.platform === 'win32'
|
|
48
56
|
? destDir.replace(/\\/g, '/')
|
|
49
57
|
: destDir;
|
package/gm.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { readFileSync, existsSync } from 'fs';
|
|
2
|
+
import { join, dirname } from 'path';
|
|
3
3
|
import { exec } from 'child_process';
|
|
4
4
|
import { fileURLToPath } from 'url';
|
|
5
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
|
|
8
|
+
export async function GmPlugin({ directory }) {
|
|
9
|
+
const agentsDir = join(__dirname, '..', 'agents');
|
|
10
|
+
|
|
10
11
|
const loadAgentRules = () => {
|
|
11
|
-
|
|
12
|
-
try { return fs.readFileSync(agentMd, 'utf-8'); } catch (e) { return ''; }
|
|
12
|
+
try { return readFileSync(join(agentsDir, 'gm.md'), 'utf-8'); } catch (e) { return ''; }
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
const runThorns = () => new Promise((resolve) => {
|
|
@@ -42,16 +42,16 @@ export default async ({ project, client, $, directory, worktree }) => {
|
|
|
42
42
|
return '';
|
|
43
43
|
};
|
|
44
44
|
|
|
45
|
-
const prdFile =
|
|
45
|
+
const prdFile = join(directory, '.prd');
|
|
46
46
|
|
|
47
47
|
return {
|
|
48
48
|
'experimental.chat.system.transform': async (input, output) => {
|
|
49
49
|
const rules = loadAgentRules();
|
|
50
|
-
const prd =
|
|
50
|
+
const prd = existsSync(prdFile) ? readFileSync(prdFile, 'utf-8').trim() : '';
|
|
51
51
|
let content = rules || '';
|
|
52
52
|
if (prd) content += '\n\nPENDING WORK (.prd):\n' + prd;
|
|
53
|
-
// On every user prompt: run thorns fresh
|
|
54
|
-
// Skip if last message is from assistant (
|
|
53
|
+
// On every user prompt: run thorns + codebasesearch fresh in parallel
|
|
54
|
+
// Skip if last message is from assistant (tool result inject, no new user input)
|
|
55
55
|
const msgs = input?.messages || [];
|
|
56
56
|
const lastMsg = msgs.length > 0 ? msgs[msgs.length - 1] : null;
|
|
57
57
|
const hasNewUserPrompt = !lastMsg || lastMsg.role === 'user';
|
|
@@ -67,4 +67,4 @@ export default async ({ project, client, $, directory, worktree }) => {
|
|
|
67
67
|
if (content) output.system.push(content);
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
|
-
}
|
|
70
|
+
}
|