gm-kilo 2.0.35 → 2.0.37

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 (2) hide show
  1. package/gm.mjs +15 -49
  2. package/package.json +1 -1
package/gm.mjs CHANGED
@@ -1,14 +1,14 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
- import { execSync } from 'child_process';
3
+ import { exec } from 'child_process';
4
4
  import { fileURLToPath } from 'url';
5
5
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
6
6
 
7
7
  export default async ({ project, client, $, directory, worktree }) => {
8
8
  const pluginDir = __dirname;
9
9
  let agentRules = '';
10
+ let thornsPromise = null;
10
11
  let thornsOutput = '';
11
- let thornsReady = false;
12
12
 
13
13
  const loadAgentRules = () => {
14
14
  if (agentRules) return agentRules;
@@ -17,48 +17,18 @@ export default async ({ project, client, $, directory, worktree }) => {
17
17
  return agentRules;
18
18
  };
19
19
 
20
- const runThorns = () => {
21
- if (thornsReady) return thornsOutput;
22
- thornsReady = true;
23
- try {
24
- const out = execSync('bun x mcp-thorns@latest', {
25
- encoding: 'utf-8', cwd: directory, timeout: 180000,
26
- stdio: ['pipe', 'pipe', 'pipe']
20
+ // Start thorns in background immediately on plugin load
21
+ const startThorns = () => {
22
+ if (thornsPromise) return thornsPromise;
23
+ thornsPromise = new Promise((resolve) => {
24
+ exec('bun x mcp-thorns@latest', {
25
+ encoding: 'utf-8', cwd: directory, timeout: 180000
26
+ }, (err, stdout) => {
27
+ thornsOutput = err ? '' : (stdout || '').trim();
28
+ resolve(thornsOutput);
27
29
  });
28
- thornsOutput = out.trim();
29
- } catch (e) {
30
- thornsOutput = '=== mcp-thorns ===\nSkipped (' + e.message.split('\n')[0] + ')';
31
- }
32
- return thornsOutput;
33
- };
34
-
35
- const runCodeSearch = (query) => {
36
- if (!query || !directory) return '';
37
- try {
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) => {
50
- try {
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
- }
59
- }
60
- } catch (e) {}
61
- return '';
30
+ });
31
+ return thornsPromise;
62
32
  };
63
33
 
64
34
  const prdFile = path.join(directory, '.prd');
@@ -69,13 +39,9 @@ export default async ({ project, client, $, directory, worktree }) => {
69
39
  const prd = fs.existsSync(prdFile) ? fs.readFileSync(prdFile, 'utf-8').trim() : '';
70
40
  let content = rules || '';
71
41
  if (prd) content += '\n\nPENDING WORK (.prd):\n' + prd;
72
- const thorns = runThorns();
42
+ // Await thorns fully on first call (starts and waits), cached on subsequent calls
43
+ const thorns = await startThorns();
73
44
  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
- }
79
45
  if (content) output.system.push(content);
80
46
  }
81
47
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-kilo",
3
- "version": "2.0.35",
3
+ "version": "2.0.37",
4
4
  "description": "State machine agent with hooks, skills, and automated git enforcement",
5
5
  "author": "AnEntrypoint",
6
6
  "license": "MIT",