gm-gc 2.0.480 → 2.0.482

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm",
3
- "version": "2.0.480",
3
+ "version": "2.0.482",
4
4
  "description": "State machine agent with hooks, skills, and automated git enforcement",
5
5
  "author": "AnEntrypoint",
6
6
  "homepage": "https://github.com/AnEntrypoint/gm",
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  const fs = require('fs');
3
3
  const path = require('path');
4
- const writeTools = ['write_file'];
4
+ const writeTools = ['write_file', 'edit_file'];
5
5
  const forbiddenTools = ['find', 'Find', 'Glob', 'Grep', 'glob', 'search_file_content'];
6
6
  const run = () => {
7
7
  try {
@@ -22,8 +22,11 @@ const run = () => {
22
22
  return { deny: true, reason: 'Cannot create documentation files. Only AGENTS.md, CLAUDE.md and readme.md are maintained.' };
23
23
  }
24
24
  if (/\.(test|spec)\.(js|ts|jsx|tsx|mjs|cjs)$/.test(base) ||
25
+ /^(jest|vitest|mocha|ava|jasmine|tap)\.(config|setup)/.test(base) ||
26
+ /\.(snap|stub|mock|fixture)\.(js|ts|json)$/.test(base) ||
25
27
  file_path.includes('/__tests__/') || file_path.includes('/test/') ||
26
- file_path.includes('/tests/') || file_path.includes('/__mocks__/')) {
28
+ file_path.includes('/tests/') || file_path.includes('/fixtures/') ||
29
+ file_path.includes('/test-data/') || file_path.includes('/__mocks__/')) {
27
30
  return { deny: true, reason: 'Test files forbidden on disk. Use real services for all testing.' };
28
31
  }
29
32
  }
@@ -34,6 +37,26 @@ const run = () => {
34
37
  if (!isExec && !isGit) {
35
38
  return { deny: true, reason: 'run_shell_command requires exec:<lang> format with a NEWLINE between the lang and code. Example: exec:bash\nnpm --version\n(newline after exec:bash, not a space). Allowed: exec:nodejs, exec:bash, exec:python, exec:typescript, git, gh.' };
36
39
  }
40
+ if (isExec) {
41
+ const newline = command.indexOf('\n');
42
+ if (newline === -1) return { allow: true };
43
+ const rawLang = command.substring(5, newline);
44
+ const code = command.substring(newline + 1);
45
+ const { spawnSync } = require('child_process');
46
+ const pluginRoot = path.join(__dirname, '..');
47
+ const plugkitJs = path.join(pluginRoot, 'bin', 'plugkit.js');
48
+ let result;
49
+ if (rawLang === 'browser') {
50
+ result = spawnSync('node', [plugkitJs, 'exec', 'browser'], { input: code, encoding: 'utf-8', timeout: 300000 });
51
+ } else if (rawLang === 'codesearch') {
52
+ const projectDir = process.env.GEMINI_PROJECT_DIR || process.cwd();
53
+ result = spawnSync('node', [plugkitJs, 'search', '--path', projectDir, code], { encoding: 'utf-8', timeout: 60000 });
54
+ } else {
55
+ result = spawnSync('node', [plugkitJs, 'exec', rawLang], { input: code, encoding: 'utf-8', timeout: 120000 });
56
+ }
57
+ const output = (result.stdout || '') + (result.stderr || '');
58
+ return { deny: true, reason: 'exec:' + rawLang + ' output:\n\n' + output };
59
+ }
37
60
  }
38
61
  return { allow: true };
39
62
  } catch (e) {
@@ -1,42 +1,40 @@
1
1
  #!/usr/bin/env node
2
2
  const fs = require('fs');
3
3
  const path = require('path');
4
- const { execSync } = require('child_process');
4
+ const { spawnSync } = require('child_process');
5
5
  const pluginRoot = process.env.GEMINI_PROJECT_DIR ? path.join(__dirname, '..') : (process.env.CLAUDE_PLUGIN_ROOT || path.join(__dirname, '..'));
6
+ const plugkitBin = path.join(pluginRoot, 'bin', 'plugkit.js');
6
7
  const projectDir = process.env.GEMINI_PROJECT_DIR || process.cwd();
7
8
  const readStdinPrompt = () => {
8
9
  try { return JSON.parse(fs.readFileSync(0, 'utf-8')).prompt || ''; } catch (e) { return ''; }
9
10
  };
10
- const readGmAgent = () => {
11
- try { return fs.readFileSync(path.join(pluginRoot, 'agents/gm.md'), 'utf-8'); } catch (e) { return ''; }
12
- };
13
- const runMcpThorns = () => {
11
+ const runCodeinsight = () => {
14
12
  if (!projectDir || !fs.existsSync(projectDir)) return '';
15
13
  try {
16
- const out = execSync('plugkit codeinsight ' + JSON.stringify(projectDir), { encoding: 'utf-8', stdio: 'pipe', cwd: projectDir, timeout: 55000 });
17
- if (!out || out.startsWith('Error')) return '';
18
- return '=== This is your initial insight of the repository, look at every possible aspect of this for initial opinionation and to offset the need for code exploration ===\n' + out;
14
+ const r = spawnSync('node', [plugkitBin, 'codeinsight', projectDir], { encoding: 'utf-8', stdio: 'pipe', cwd: projectDir, timeout: 10000 });
15
+ const out = (r.stdout || '').trim();
16
+ if (!out || out.startsWith('Error') || r.status !== 0) return '';
17
+ return out;
19
18
  } catch (e) { return ''; }
20
19
  };
21
- const runCodeSearch = (query) => {
20
+ const runSearch = (query) => {
22
21
  if (!query || !projectDir) return '';
23
22
  try {
24
- const q = query.replace(/"/g, '\\"').substring(0, 200);
25
- let out;
26
- try { out = execSync(`bun x codebasesearch "${q}"`, { encoding: 'utf-8', stdio: 'pipe', cwd: projectDir, timeout: 55000 }); }
27
- catch (e) { out = execSync(`npx -y codebasesearch "${q}"`, { encoding: 'utf-8', stdio: 'pipe', cwd: projectDir, timeout: 55000 }); }
28
- const lines = out.split('\n');
29
- const start = lines.findIndex(l => l.includes('Searching for:'));
30
- return start >= 0 ? lines.slice(start).join('\n').trim() : out.trim();
23
+ const r = spawnSync('node', [plugkitBin, 'search', '--path', projectDir, query.substring(0, 200)], { encoding: 'utf-8', stdio: 'pipe', cwd: projectDir, timeout: 5000 });
24
+ const out = (r.stdout || '').trim();
25
+ if (!out || r.status !== 0) return '';
26
+ return out;
31
27
  } catch (e) { return ''; }
32
28
  };
33
29
  try {
34
30
  const prompt = readStdinPrompt();
35
- const parts = [];
36
- const gm = readGmAgent();
37
- if (gm) parts.push(gm);
38
- parts.push('use gm agent | ref: TOOL_INVARIANTS | codesearch for exploration | exec: for execution');
39
- console.log(JSON.stringify({ systemMessage: parts.join('\n\n') }, null, 2));
31
+ const insight = runCodeinsight();
32
+ const search = runSearch(prompt);
33
+ const sections = ['Invoke the gm skill to begin. DO NOT use EnterPlanMode.'];
34
+ if (insight) sections.push('=== codeinsight ===\n' + insight);
35
+ if (search) sections.push('=== search ===\n' + search);
36
+ const injection = '<system-reminder>\n' + sections.join('\n\n') + '\n</system-reminder>';
37
+ console.log(JSON.stringify({ decision: 'deny', reason: injection }, null, 2));
40
38
  } catch (e) {
41
- console.log(JSON.stringify({ systemMessage: 'use gm agent' }, null, 2));
39
+ console.log(JSON.stringify({ decision: 'deny', reason: '<system-reminder>\nInvoke the gm skill to begin. DO NOT use EnterPlanMode.\n</system-reminder>' }, null, 2));
42
40
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-gc",
3
- "version": "2.0.480",
3
+ "version": "2.0.482",
4
4
  "description": "State machine agent with hooks, skills, and automated git enforcement",
5
5
  "author": "AnEntrypoint",
6
6
  "license": "MIT",