gm-kilo 2.0.39 → 2.0.42

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 +17 -34
  2. package/package.json +1 -1
package/gm.mjs CHANGED
@@ -1,49 +1,32 @@
1
- import fs from 'fs';
2
- import path from 'path';
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
- export default async ({ project, client, $, directory, worktree }) => {
8
- const pluginDir = __dirname;
9
- let agentRules = '';
10
- let thornsPromise = null;
11
- let thornsOutput = '';
6
+ const __dirname = dirname(fileURLToPath(import.meta.url));
12
7
 
8
+ export default async ({ directory }) => {
9
+ const agentsDir = join(__dirname, 'agents');
13
10
  const loadAgentRules = () => {
14
- if (agentRules) return agentRules;
15
- const agentMd = path.join(pluginDir, 'agents', 'gm.md');
16
- try { agentRules = fs.readFileSync(agentMd, 'utf-8'); } catch (e) {}
17
- return agentRules;
11
+ try { return readFileSync(join(agentsDir, 'gm.md'), 'utf-8'); } catch (e) { return ''; }
18
12
  };
19
-
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);
29
- });
30
- });
31
- return thornsPromise;
32
- };
33
-
34
- const prdFile = path.join(directory, '.prd');
35
-
13
+ const runThorns = () => new Promise((resolve) => {
14
+ exec('bun x mcp-thorns@latest', {
15
+ encoding: 'utf-8', cwd: directory, timeout: 180000
16
+ }, (err, stdout) => resolve(err ? '' : (stdout || '').trim()));
17
+ });
18
+ const prdFile = join(directory, '.prd');
36
19
  return {
37
20
  'experimental.chat.system.transform': async (input, output) => {
38
21
  const rules = loadAgentRules();
39
- const prd = fs.existsSync(prdFile) ? fs.readFileSync(prdFile, 'utf-8').trim() : '';
22
+ const prd = existsSync(prdFile) ? readFileSync(prdFile, 'utf-8').trim() : '';
40
23
  let content = rules || '';
41
24
  if (prd) content += '\n\nPENDING WORK (.prd):\n' + prd;
42
- // Inject thorns only on the first API call of a conversation (no assistant messages yet)
43
25
  const msgs = input?.messages || [];
44
- const isFirstCall = !msgs.some(m => m.role === 'assistant');
45
- if (isFirstCall) {
46
- const thorns = await startThorns();
26
+ const lastMsg = msgs.length > 0 ? msgs[msgs.length - 1] : null;
27
+ const hasNewUserPrompt = !lastMsg || lastMsg.role === 'user';
28
+ if (hasNewUserPrompt) {
29
+ const thorns = await runThorns();
47
30
  if (thorns) content += '\n\n=== Repository Analysis (mcp-thorns) ===\n' + thorns;
48
31
  }
49
32
  if (content) output.system.push(content);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-kilo",
3
- "version": "2.0.39",
3
+ "version": "2.0.42",
4
4
  "description": "State machine agent with hooks, skills, and automated git enforcement",
5
5
  "author": "AnEntrypoint",
6
6
  "license": "MIT",