gm-oc 2.0.145 → 2.0.146

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,14 +1,18 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ if (process.env.AGENTGUI_SUBPROCESS === '1') {
4
+ console.log(JSON.stringify({ additionalContext: '' }));
5
+ process.exit(0);
6
+ }
7
+
3
8
  const fs = require('fs');
4
9
  const path = require('path');
5
- const { execSync } = require('child_process');
6
10
 
7
11
  const pluginRoot = process.env.CLAUDE_PLUGIN_ROOT || process.env.GEMINI_PROJECT_DIR || process.env.OC_PLUGIN_ROOT || process.env.KILO_PLUGIN_ROOT || path.join(__dirname, '..');
8
12
  const projectDir = process.env.CLAUDE_PROJECT_DIR || process.env.GEMINI_PROJECT_DIR || process.env.OC_PROJECT_DIR || process.env.KILO_PROJECT_DIR;
9
13
 
10
- const COMPACT_CONTEXT = 'use gm agent | ref: TOOL_INVARIANTS | codesearch for exploration | Bash for execution';
11
- const PLAN_MODE_BLOCK = 'DO NOT use EnterPlanMode or any plan mode tool. Use GM agent planning (PLAN→EXECUTE→EMIT→VERIFY→COMPLETE state machine) instead. Plan mode is blocked.';
14
+ const COMPACT_CONTEXT = 'use gm agent | ref: TOOL_INVARIANTS | codesearch for exploration | bun x gm-exec for execution';
15
+ const PLAN_MODE_BLOCK = 'DO NOT use EnterPlanMode. Use GM agent planning (PLAN→EXECUTE→EMIT→VERIFY→COMPLETE state machine) instead. Plan mode is blocked.';
12
16
 
13
17
  const ensureGitignore = () => {
14
18
  if (!projectDir) return;
@@ -25,104 +29,7 @@ const ensureGitignore = () => {
25
29
  : content + '\n' + entry + '\n';
26
30
  fs.writeFileSync(gitignorePath, newContent);
27
31
  }
28
- } catch (e) {
29
- // Silently fail - not critical
30
- }
31
- };
32
-
33
- const getBaseContext = (resetMsg = '') => {
34
- let ctx = 'use gm agent';
35
- if (resetMsg) ctx += ' - ' + resetMsg;
36
- return ctx;
37
- };
38
-
39
- const readStdinPrompt = () => {
40
- try {
41
- const raw = fs.readFileSync(0, 'utf-8');
42
- const data = JSON.parse(raw);
43
- return data.prompt || '';
44
- } catch (e) {
45
- return '';
46
- }
47
- };
48
-
49
- const readGmAgent = () => {
50
- if (!pluginRoot) return '';
51
- try {
52
- return fs.readFileSync(path.join(pluginRoot, 'agents/gm.md'), 'utf-8');
53
- } catch (e) {
54
- return '';
55
- }
56
- };
57
-
58
- const runMcpThorns = () => {
59
- if (!projectDir || !fs.existsSync(projectDir)) return '';
60
- try {
61
- let thornOutput;
62
- try {
63
- thornOutput = execSync('bun x mcp-thorns', {
64
- encoding: 'utf-8',
65
- stdio: ['pipe', 'pipe', 'pipe'],
66
- cwd: projectDir,
67
- timeout: 180000,
68
- killSignal: 'SIGTERM'
69
- });
70
- } catch (bunErr) {
71
- if (bunErr.killed && bunErr.signal === 'SIGTERM') {
72
- thornOutput = '=== mcp-thorns ===\nSkipped (3min timeout)';
73
- } else {
74
- try {
75
- thornOutput = execSync('npx -y mcp-thorns', {
76
- encoding: 'utf-8',
77
- stdio: ['pipe', 'pipe', 'pipe'],
78
- cwd: projectDir,
79
- timeout: 180000,
80
- killSignal: 'SIGTERM'
81
- });
82
- } catch (npxErr) {
83
- if (npxErr.killed && npxErr.signal === 'SIGTERM') {
84
- thornOutput = '=== mcp-thorns ===\nSkipped (3min timeout)';
85
- } else {
86
- thornOutput = `=== mcp-thorns ===\nSkipped (error: ${bunErr.message.split('\n')[0]})`;
87
- }
88
- }
89
- }
90
- }
91
- return `=== Repository analysis ===\n${thornOutput}`;
92
- } catch (e) {
93
- return `=== mcp-thorns ===\nSkipped (error: ${e.message.split('\n')[0]})`;
94
- }
95
- };
96
-
97
- const runCodeSearch = (query, cwd) => {
98
- if (!query || !cwd || !fs.existsSync(cwd)) return '';
99
- try {
100
- const escaped = query.replace(/"/g, '\\"').substring(0, 200);
101
- let out;
102
- try {
103
- out = execSync(`bun x codebasesearch "${escaped}"`, {
104
- encoding: 'utf-8',
105
- stdio: ['pipe', 'pipe', 'pipe'],
106
- cwd,
107
- timeout: 55000,
108
- killSignal: 'SIGTERM'
109
- });
110
- } catch (bunErr) {
111
- if (bunErr.killed) return '';
112
- out = execSync(`npx -y codebasesearch "${escaped}"`, {
113
- encoding: 'utf-8',
114
- stdio: ['pipe', 'pipe', 'pipe'],
115
- cwd,
116
- timeout: 55000,
117
- killSignal: 'SIGTERM'
118
- });
119
- }
120
- const lines = out.split('\n');
121
- const resultStart = lines.findIndex(l => l.includes('Searching for:'));
122
- return resultStart >= 0 ? lines.slice(resultStart).join('\n').trim() : out.trim();
123
- } catch (e) {
124
- return '';
125
- }
32
+ } catch (e) {}
126
33
  };
127
34
 
128
35
  const emit = (additionalContext) => {
@@ -141,31 +48,8 @@ const emit = (additionalContext) => {
141
48
 
142
49
  try {
143
50
  ensureGitignore();
144
-
145
- const prompt = readStdinPrompt();
146
- const parts = [];
147
-
148
- // Always: include gm.md and mcp-thorns
149
- const gmContent = readGmAgent();
150
- if (gmContent) {
151
- parts.push(gmContent);
152
- }
153
-
154
- const thornOutput = runMcpThorns();
155
- parts.push(thornOutput);
156
-
157
- // Always: base context and codebasesearch
158
- parts.push(getBaseContext() + ' | ' + COMPACT_CONTEXT + ' | ' + PLAN_MODE_BLOCK);
159
-
160
- if (prompt && projectDir) {
161
- const searchResults = runCodeSearch(prompt, projectDir);
162
- if (searchResults) {
163
- parts.push(`=== Semantic code search results ===\n${searchResults}`);
164
- }
165
- }
166
-
167
- emit(parts.join('\n\n'));
51
+ emit('use gm agent | ' + COMPACT_CONTEXT + ' | ' + PLAN_MODE_BLOCK);
168
52
  } catch (error) {
169
- emit(getBaseContext('hook error: ' + error.message) + ' | ' + COMPACT_CONTEXT);
53
+ emit('use gm agent | hook error: ' + error.message);
170
54
  process.exit(0);
171
55
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-oc",
3
- "version": "2.0.145",
3
+ "version": "2.0.146",
4
4
  "description": "State machine agent with hooks, skills, and automated git enforcement",
5
5
  "author": "AnEntrypoint",
6
6
  "license": "MIT",