gm-kilo 2.0.25 → 2.0.27

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/.mcp.json ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "$schema": "https://schemas.modelcontextprotocol.io/0.1.0/mcp.json"
3
+ }
package/cli.js CHANGED
@@ -2,18 +2,35 @@
2
2
  const fs = require('fs');
3
3
  const path = require('path');
4
4
  const os = require('os');
5
+ const { execSync } = require('child_process');
5
6
 
6
7
  const homeDir = process.env.HOME || process.env.USERPROFILE || os.homedir();
7
- const kiloConfigDir = path.join(homeDir, '.config', 'kilo');
8
+ const destDir = process.platform === 'win32'
9
+ ? path.join(homeDir, 'AppData', 'Roaming', 'kilo')
10
+ : path.join(homeDir, '.config', 'kilo');
11
+
8
12
  const srcDir = __dirname;
9
- const pluginMarker = path.join(kiloConfigDir, 'plugins', 'gm-kilo.mjs');
10
- const isUpgrade = fs.existsSync(pluginMarker);
13
+ const isUpgrade = fs.existsSync(path.join(destDir, 'agents', 'gm.md'));
11
14
 
12
15
  console.log(isUpgrade ? 'Upgrading gm-kilo...' : 'Installing gm-kilo...');
13
16
 
14
17
  try {
15
- fs.mkdirSync(path.join(kiloConfigDir, 'plugins'), { recursive: true });
16
- fs.mkdirSync(path.join(kiloConfigDir, 'agents'), { recursive: true });
18
+ fs.mkdirSync(destDir, { recursive: true });
19
+
20
+ const filesToCopy = [
21
+ ['agents', 'agents'],
22
+ ['hooks', 'hooks'],
23
+ ['skills', 'skills'],
24
+ ['index.js', 'index.js'],
25
+ ['gm.js', 'gm.js'],
26
+ ['kilocode.json', 'kilocode.json'],
27
+ ['.mcp.json', '.mcp.json'],
28
+ ['README.md', 'README.md'],
29
+ ['LICENSE', 'LICENSE'],
30
+ ['CONTRIBUTING.md', 'CONTRIBUTING.md'],
31
+ ['.gitignore', '.gitignore'],
32
+ ['.editorconfig', '.editorconfig']
33
+ ];
17
34
 
18
35
  function copyRecursive(src, dst) {
19
36
  if (!fs.existsSync(src)) return;
@@ -25,49 +42,14 @@ try {
25
42
  }
26
43
  }
27
44
 
28
- // Install ESM plugin for kilo auto-loading from plugins directory
29
- fs.copyFileSync(path.join(srcDir, 'gm-kilo.mjs'), path.join(kiloConfigDir, 'plugins', 'gm-kilo.mjs'));
30
-
31
- // Copy agents into kilo config dir
32
- copyRecursive(path.join(srcDir, 'agents'), path.join(kiloConfigDir, 'agents'));
33
-
34
- // Write/fix kilocode.json — set default_agent, fix $schema
35
- const kiloJsonPath = path.join(kiloConfigDir, 'kilocode.json');
36
- let kiloConfig = {};
37
- try {
38
- const raw = fs.readFileSync(kiloJsonPath, 'utf-8');
39
- kiloConfig = JSON.parse(raw);
40
- // Fix corrupted $schema key (written as "" in older versions)
41
- if (kiloConfig['']) { delete kiloConfig['']; }
42
- } catch (e) {}
43
- // Remove stale MCP config (no longer used)
44
- delete kiloConfig.mcp;
45
- kiloConfig['$schema'] = 'https://kilo.ai/config.json';
46
- kiloConfig.default_agent = 'gm';
47
- // Remove stale local-path plugin reference
48
- if (Array.isArray(kiloConfig.plugin)) {
49
- kiloConfig.plugin = kiloConfig.plugin.filter(p => !path.isAbsolute(p) && !p.startsWith('C:') && !p.startsWith('/'));
50
- if (kiloConfig.plugin.length === 0) delete kiloConfig.plugin;
51
- }
52
- fs.writeFileSync(kiloJsonPath, JSON.stringify(kiloConfig, null, 2) + '\n');
53
-
54
- // Clean old AppData install location (no longer used by kilo)
55
- const oldDir = process.platform === 'win32'
56
- ? path.join(homeDir, 'AppData', 'Roaming', 'kilo', 'plugin') : null;
57
- if (oldDir && fs.existsSync(oldDir)) {
58
- try { fs.rmSync(oldDir, { recursive: true, force: true }); } catch (e) {}
59
- }
60
-
61
- // Install skills globally via the skills package (supports all agents)
62
- const { execSync: execSync2 } = require('child_process');
63
- try {
64
- execSync2('bunx skills add AnEntrypoint/plugforge --full-depth --all --global --yes', { stdio: 'inherit' });
65
- } catch (e) {
66
- console.warn('Warning: skills install failed (non-fatal):', e.message);
67
- }
45
+ filesToCopy.forEach(([src, dst]) => copyRecursive(path.join(srcDir, src), path.join(destDir, dst)));
68
46
 
69
- console.log(`✓ gm-kilo ${isUpgrade ? 'upgraded' : 'installed'} to ${kiloConfigDir}`);
47
+ const destPath = process.platform === 'win32'
48
+ ? destDir.replace(/\\/g, '/')
49
+ : destDir;
50
+ console.log(`✓ gm-kilo ${isUpgrade ? 'upgraded' : 'installed'} to ${destPath}`);
70
51
  console.log('Restart Kilo CLI to activate.');
52
+ console.log('Run "kilo agents list" to verify your agent is available.');
71
53
  } catch (e) {
72
54
  console.error('Installation failed:', e.message);
73
55
  process.exit(1);
package/gm.js CHANGED
@@ -1 +1,85 @@
1
- module.exports = require('./gm-kilo.mjs');
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ const GmPlugin = async ({ project, client, $, directory, worktree }) => {
5
+ const pluginDir = __dirname;
6
+ let agentRules = '';
7
+
8
+ const loadAgentRules = () => {
9
+ if (agentRules) return agentRules;
10
+ const agentMd = path.join(pluginDir, 'agents', 'gm.md');
11
+ try { agentRules = fs.readFileSync(agentMd, 'utf-8'); } catch (e) {}
12
+ return agentRules;
13
+ };
14
+
15
+ const runThornsAnalysis = async () => {
16
+ try {
17
+ thornsOutput = '=== mcp-thorns ===\n' + analyze(directory);
18
+ } catch (e) {
19
+ thornsOutput = '=== mcp-thorns ===\nSkipped (' + e.message + ')';
20
+ }
21
+ };
22
+
23
+ const runSessionIdle = async () => {
24
+ if (!client || !client.tui) return;
25
+ const blockReasons = [];
26
+ try {
27
+ const status = await $`git status --porcelain`.timeout(2000).nothrow();
28
+ if (status.exitCode === 0 && status.stdout.trim().length > 0)
29
+ blockReasons.push('Git: Uncommitted changes exist');
30
+ } catch (e) {}
31
+ try {
32
+ const ahead = await $`git rev-list --count @{u}..HEAD`.timeout(2000).nothrow();
33
+ if (ahead.exitCode === 0 && parseInt(ahead.stdout.trim()) > 0)
34
+ blockReasons.push('Git: ' + ahead.stdout.trim() + ' commit(s) not pushed');
35
+ } catch (e) {}
36
+ try {
37
+ const behind = await $`git rev-list --count HEAD..@{u}`.timeout(2000).nothrow();
38
+ if (behind.exitCode === 0 && parseInt(behind.stdout.trim()) > 0)
39
+ blockReasons.push('Git: ' + behind.stdout.trim() + ' upstream change(s) not pulled');
40
+ } catch (e) {}
41
+ const prdFile = path.join(directory, '.prd');
42
+ if (fs.existsSync(prdFile)) {
43
+ const prd = fs.readFileSync(prdFile, 'utf-8').trim();
44
+ if (prd.length > 0) blockReasons.push('Work items remain in .prd:\n' + prd);
45
+ }
46
+ if (blockReasons.length > 0) throw new Error(blockReasons.join(' | '));
47
+ const filesToRun = [];
48
+ const evalJs = path.join(directory, 'eval.js');
49
+ if (fs.existsSync(evalJs)) filesToRun.push('eval.js');
50
+ const evalsDir = path.join(directory, 'evals');
51
+ if (fs.existsSync(evalsDir) && fs.statSync(evalsDir).isDirectory()) {
52
+ filesToRun.push(...fs.readdirSync(evalsDir)
53
+ .filter(f => f.endsWith('.js') && !path.join(evalsDir, f).includes('/lib/'))
54
+ .sort().map(f => path.join('evals', f)));
55
+ }
56
+ for (const file of filesToRun) {
57
+ try { await $`node ${file}`.timeout(60000); } catch (e) {
58
+ throw new Error('eval error: ' + e.message + '\n' + (e.stdout || '') + '\n' + (e.stderr || ''));
59
+ }
60
+ }
61
+ };
62
+
63
+ const prdFile = path.join(directory, '.prd');
64
+
65
+ return {
66
+ onLoad: async () => {
67
+ console.log('✓ gm plugin loaded');
68
+ },
69
+
70
+ getSystemPrompt: async () => {
71
+ const rules = loadAgentRules();
72
+ const prd = fs.existsSync(prdFile) ? fs.readFileSync(prdFile, 'utf-8').trim() : '';
73
+ let prompt = rules || '';
74
+ if (prd) prompt += '\n\nPENDING WORK (.prd):\n' + prd;
75
+ return prompt;
76
+ },
77
+
78
+ onSessionEnd: async () => {
79
+ const prd = fs.existsSync(prdFile) ? fs.readFileSync(prdFile, 'utf-8').trim() : '';
80
+ if (prd) throw new Error('Work items remain in .prd - commit changes before exiting');
81
+ }
82
+ };
83
+ };
84
+
85
+ module.exports = { GmPlugin };
package/index.js CHANGED
@@ -1 +1 @@
1
- module.exports = { GmPlugin: require('./gm-kilo.mjs').GmPlugin };
1
+ module.exports = { GmPlugin: require('./gm.js').GmPlugin };
package/install.js CHANGED
@@ -52,6 +52,23 @@ function safeCopyDirectory(src, dst) {
52
52
  }
53
53
  }
54
54
 
55
+ function safeCopyFile(src, dst) {
56
+ try {
57
+ if (!fs.existsSync(src)) {
58
+ return false;
59
+ }
60
+ const content = fs.readFileSync(src, 'utf-8');
61
+ const dstDir = path.dirname(dst);
62
+ if (!fs.existsSync(dstDir)) {
63
+ fs.mkdirSync(dstDir, { recursive: true });
64
+ }
65
+ fs.writeFileSync(dst, content, 'utf-8');
66
+ return true;
67
+ } catch (err) {
68
+ return false;
69
+ }
70
+ }
71
+
55
72
  function install() {
56
73
  if (!isInsideNodeModules()) {
57
74
  return;
@@ -62,11 +79,13 @@ function install() {
62
79
  return;
63
80
  }
64
81
 
65
- const kiloDir = path.join(projectRoot, '.config', 'kilo', 'plugin');
82
+ const kiloDir = path.join(projectRoot, '.config', 'kilo');
66
83
  const sourceDir = __dirname;
67
84
 
68
85
  safeCopyDirectory(path.join(sourceDir, 'agents'), path.join(kiloDir, 'agents'));
69
86
  safeCopyDirectory(path.join(sourceDir, 'hooks'), path.join(kiloDir, 'hooks'));
87
+ safeCopyFile(path.join(sourceDir, 'kilocode.json'), path.join(kiloDir, 'kilocode.json'));
88
+ safeCopyFile(path.join(sourceDir, '.mcp.json'), path.join(kiloDir, '.mcp.json'));
70
89
  }
71
90
 
72
91
  install();
package/kilocode.json CHANGED
@@ -1,4 +1,7 @@
1
1
  {
2
2
  "$schema": "https://kilo.ai/config.json",
3
- "default_agent": "gm"
3
+ "default_agent": "gm",
4
+ "plugin": [
5
+ "gm-kilo"
6
+ ]
4
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-kilo",
3
- "version": "2.0.25",
3
+ "version": "2.0.27",
4
4
  "description": "State machine agent with hooks, skills, and automated git enforcement",
5
5
  "author": "AnEntrypoint",
6
6
  "license": "MIT",
@@ -12,6 +12,7 @@
12
12
  "keywords": [
13
13
  "kilo",
14
14
  "kilo-cli",
15
+ "mcp",
15
16
  "automation",
16
17
  "gm"
17
18
  ],
@@ -29,19 +30,22 @@
29
30
  "publishConfig": {
30
31
  "access": "public"
31
32
  },
32
- "dependencies": {},
33
+ "dependencies": {
34
+ "mcp-thorns": "^4.1.0"
35
+ },
33
36
  "scripts": {
34
37
  "postinstall": "node scripts/postinstall.js"
35
38
  },
36
39
  "files": [
37
40
  "agents/",
38
41
  "hooks/",
42
+ "skills/",
39
43
  "scripts/",
40
44
  "gm.js",
41
- "gm-kilo.mjs",
42
45
  "index.js",
43
46
  "kilocode.json",
44
47
  ".github/",
48
+ ".mcp.json",
45
49
  "README.md",
46
50
  "cli.js",
47
51
  "install.js",