gm-kilo 2.0.31 → 2.0.34
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/agents/gm.md +3 -6
- package/gm.mjs +44 -42
- package/package.json +1 -1
package/agents/gm.md
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
agent: true
|
|
5
|
-
enforce: critical
|
|
2
|
+
description: GM agent - Immutable programming state machine for autonomous task execution
|
|
3
|
+
mode: primary
|
|
6
4
|
---
|
|
7
|
-
|
|
8
5
|
# GM AGENT - Immutable Programming State Machine
|
|
9
6
|
|
|
10
7
|
> **CRITICAL**: `gm` is an **AGENT**, not a skill. It is the subagent invoked for all work coordination and execution in this system.
|
|
@@ -374,4 +371,4 @@ Before reporting completion or sending final response, execute in `dev` skill or
|
|
|
374
371
|
|
|
375
372
|
**CANNOT PROCEED PAST THIS POINT WITHOUT ALL CHECKS PASSING:**
|
|
376
373
|
|
|
377
|
-
If any check fails → fix the issue → re-execute → re-verify. Do not skip. Do not guess. Only witnessed execution counts as verification. Only completion of ALL checks = work is done.
|
|
374
|
+
If any check fails → fix the issue → re-execute → re-verify. Do not skip. Do not guess. Only witnessed execution counts as verification. Only completion of ALL checks = work is done.
|
package/gm.mjs
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
+
import { execSync } from 'child_process';
|
|
3
4
|
import { fileURLToPath } from 'url';
|
|
4
5
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
5
6
|
|
|
6
7
|
export default async ({ project, client, $, directory, worktree }) => {
|
|
7
8
|
const pluginDir = __dirname;
|
|
8
9
|
let agentRules = '';
|
|
10
|
+
let thornsOutput = '';
|
|
11
|
+
let thornsReady = false;
|
|
9
12
|
|
|
10
13
|
const loadAgentRules = () => {
|
|
11
14
|
if (agentRules) return agentRules;
|
|
@@ -14,66 +17,65 @@ export default async ({ project, client, $, directory, worktree }) => {
|
|
|
14
17
|
return agentRules;
|
|
15
18
|
};
|
|
16
19
|
|
|
17
|
-
const
|
|
20
|
+
const runThorns = () => {
|
|
21
|
+
if (thornsReady) return thornsOutput;
|
|
22
|
+
thornsReady = true;
|
|
18
23
|
try {
|
|
19
|
-
|
|
24
|
+
const out = execSync('bun x mcp-thorns@latest', {
|
|
25
|
+
encoding: 'utf-8', cwd: directory, timeout: 180000,
|
|
26
|
+
stdio: ['pipe', 'pipe', 'pipe']
|
|
27
|
+
});
|
|
28
|
+
thornsOutput = out.trim();
|
|
20
29
|
} catch (e) {
|
|
21
|
-
thornsOutput = '=== mcp-thorns ===\nSkipped (' + e.message + ')';
|
|
30
|
+
thornsOutput = '=== mcp-thorns ===\nSkipped (' + e.message.split('\n')[0] + ')';
|
|
22
31
|
}
|
|
32
|
+
return thornsOutput;
|
|
23
33
|
};
|
|
24
34
|
|
|
25
|
-
const
|
|
26
|
-
if (!
|
|
27
|
-
const blockReasons = [];
|
|
35
|
+
const runCodeSearch = (query) => {
|
|
36
|
+
if (!query || !directory) return '';
|
|
28
37
|
try {
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
} catch (e) {}
|
|
38
|
+
const q = query.replace(/"/g, '\\"').substring(0, 200);
|
|
39
|
+
const out = execSync('bun x codebasesearch@latest "' + q + '"', {
|
|
40
|
+
encoding: 'utf-8', cwd: directory, timeout: 55000,
|
|
41
|
+
stdio: ['pipe', 'pipe', 'pipe']
|
|
42
|
+
});
|
|
43
|
+
const lines = out.split('\n');
|
|
44
|
+
const start = lines.findIndex(l => l.includes('Searching for:'));
|
|
45
|
+
return start >= 0 ? lines.slice(start).join('\n').trim() : out.trim();
|
|
46
|
+
} catch (e) { return ''; }
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const getLastUserMessage = (input) => {
|
|
38
50
|
try {
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
if (blockReasons.length > 0) throw new Error(blockReasons.join(' | '));
|
|
49
|
-
const filesToRun = [];
|
|
50
|
-
const evalJs = path.join(directory, 'eval.js');
|
|
51
|
-
if (fs.existsSync(evalJs)) filesToRun.push('eval.js');
|
|
52
|
-
const evalsDir = path.join(directory, 'evals');
|
|
53
|
-
if (fs.existsSync(evalsDir) && fs.statSync(evalsDir).isDirectory()) {
|
|
54
|
-
filesToRun.push(...fs.readdirSync(evalsDir)
|
|
55
|
-
.filter(f => f.endsWith('.js') && !path.join(evalsDir, f).includes('/lib/'))
|
|
56
|
-
.sort().map(f => path.join('evals', f)));
|
|
57
|
-
}
|
|
58
|
-
for (const file of filesToRun) {
|
|
59
|
-
try { await $`node ${file}`.timeout(60000); } catch (e) {
|
|
60
|
-
throw new Error('eval error: ' + e.message + '\n' + (e.stdout || '') + '\n' + (e.stderr || ''));
|
|
51
|
+
const msgs = input?.messages || [];
|
|
52
|
+
for (let i = msgs.length - 1; i >= 0; i--) {
|
|
53
|
+
const m = msgs[i];
|
|
54
|
+
if (m.role === 'user') {
|
|
55
|
+
const parts = Array.isArray(m.content) ? m.content : [m.content];
|
|
56
|
+
const text = parts.map(p => typeof p === 'string' ? p : (p?.text || '')).join(' ').trim();
|
|
57
|
+
if (text) return text;
|
|
58
|
+
}
|
|
61
59
|
}
|
|
62
|
-
}
|
|
60
|
+
} catch (e) {}
|
|
61
|
+
return '';
|
|
63
62
|
};
|
|
64
63
|
|
|
65
64
|
const prdFile = path.join(directory, '.prd');
|
|
66
65
|
|
|
67
66
|
return {
|
|
68
|
-
onLoad: async () => {
|
|
69
|
-
console.log('✓ gm plugin loaded');
|
|
70
|
-
},
|
|
71
|
-
|
|
72
67
|
'experimental.chat.system.transform': async (input, output) => {
|
|
73
68
|
const rules = loadAgentRules();
|
|
74
69
|
const prd = fs.existsSync(prdFile) ? fs.readFileSync(prdFile, 'utf-8').trim() : '';
|
|
75
70
|
let content = rules || '';
|
|
76
71
|
if (prd) content += '\n\nPENDING WORK (.prd):\n' + prd;
|
|
72
|
+
const thorns = runThorns();
|
|
73
|
+
if (thorns) content += '\n\n=== Repository Analysis (mcp-thorns) ===\n' + thorns;
|
|
74
|
+
const lastMsg = getLastUserMessage(input);
|
|
75
|
+
if (lastMsg) {
|
|
76
|
+
const searchResults = runCodeSearch(lastMsg);
|
|
77
|
+
if (searchResults) content += '\n\n=== Semantic code search results ===\n' + searchResults;
|
|
78
|
+
}
|
|
77
79
|
if (content) output.system.push(content);
|
|
78
80
|
}
|
|
79
81
|
};
|