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.
Files changed (3) hide show
  1. package/agents/gm.md +3 -6
  2. package/gm.mjs +44 -42
  3. package/package.json +1 -1
package/agents/gm.md CHANGED
@@ -1,10 +1,7 @@
1
1
  ---
2
- name: gm
3
- description: Agent (not skill) - immutable programming state machine. Always invoke for all work coordination.
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 runThornsAnalysis = async () => {
20
+ const runThorns = () => {
21
+ if (thornsReady) return thornsOutput;
22
+ thornsReady = true;
18
23
  try {
19
- thornsOutput = '=== mcp-thorns ===\n' + analyze(directory);
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 runSessionIdle = async () => {
26
- if (!client || !client.tui) return;
27
- const blockReasons = [];
35
+ const runCodeSearch = (query) => {
36
+ if (!query || !directory) return '';
28
37
  try {
29
- const status = await $`git status --porcelain`.timeout(2000).nothrow();
30
- if (status.exitCode === 0 && status.stdout.trim().length > 0)
31
- blockReasons.push('Git: Uncommitted changes exist');
32
- } catch (e) {}
33
- try {
34
- const ahead = await $`git rev-list --count @{u}..HEAD`.timeout(2000).nothrow();
35
- if (ahead.exitCode === 0 && parseInt(ahead.stdout.trim()) > 0)
36
- blockReasons.push('Git: ' + ahead.stdout.trim() + ' commit(s) not pushed');
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 behind = await $`git rev-list --count HEAD..@{u}`.timeout(2000).nothrow();
40
- if (behind.exitCode === 0 && parseInt(behind.stdout.trim()) > 0)
41
- blockReasons.push('Git: ' + behind.stdout.trim() + ' upstream change(s) not pulled');
42
- } catch (e) {}
43
- const prdFile = path.join(directory, '.prd');
44
- if (fs.existsSync(prdFile)) {
45
- const prd = fs.readFileSync(prdFile, 'utf-8').trim();
46
- if (prd.length > 0) blockReasons.push('Work items remain in .prd:\n' + prd);
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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-kilo",
3
- "version": "2.0.31",
3
+ "version": "2.0.34",
4
4
  "description": "State machine agent with hooks, skills, and automated git enforcement",
5
5
  "author": "AnEntrypoint",
6
6
  "license": "MIT",