gm-codex 2.0.200 → 2.0.202
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/hooks/session-start-hook.js +43 -22
- package/package.json +1 -1
- package/plugin.json +1 -1
|
@@ -2,7 +2,44 @@
|
|
|
2
2
|
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const path = require('path');
|
|
5
|
-
const
|
|
5
|
+
const os = require('os');
|
|
6
|
+
const { spawnSync } = require('child_process');
|
|
7
|
+
|
|
8
|
+
const IS_WIN = process.platform === 'win32';
|
|
9
|
+
const TOOLS_DIR = path.join(os.homedir(), '.claude', 'gm-tools');
|
|
10
|
+
|
|
11
|
+
function localBin(name) {
|
|
12
|
+
const ext = IS_WIN ? '.exe' : '';
|
|
13
|
+
return path.join(TOOLS_DIR, 'node_modules', '.bin', name + ext);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function runLocal(name, args, opts = {}) {
|
|
17
|
+
const bin = localBin(name);
|
|
18
|
+
if (fs.existsSync(bin)) {
|
|
19
|
+
return spawnSync(bin, args, { encoding: 'utf8', windowsHide: true, timeout: 30000, ...opts });
|
|
20
|
+
}
|
|
21
|
+
return spawnSync('bun', ['x', name, ...args], { encoding: 'utf8', windowsHide: true, timeout: 30000, ...opts });
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const MANAGED_PKGS = ['gm-exec', 'codebasesearch', 'mcp-thorns', 'agent-browser'];
|
|
25
|
+
const PKG_JSON = path.join(TOOLS_DIR, 'package.json');
|
|
26
|
+
|
|
27
|
+
function ensureTools() {
|
|
28
|
+
try { fs.mkdirSync(TOOLS_DIR, { recursive: true }); } catch {}
|
|
29
|
+
if (!fs.existsSync(PKG_JSON)) {
|
|
30
|
+
try { fs.writeFileSync(PKG_JSON, JSON.stringify({ name: 'gm-tools', version: '1.0.0', private: true })); } catch {}
|
|
31
|
+
}
|
|
32
|
+
const missing = MANAGED_PKGS.filter(p => !fs.existsSync(localBin(p)));
|
|
33
|
+
if (missing.length > 0) {
|
|
34
|
+
try {
|
|
35
|
+
spawnSync('bun', ['add', ...missing.map(p => p + '@latest')], {
|
|
36
|
+
cwd: TOOLS_DIR, encoding: 'utf8', timeout: 180000, windowsHide: true
|
|
37
|
+
});
|
|
38
|
+
} catch {}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
ensureTools();
|
|
6
43
|
|
|
7
44
|
const projectDir = process.env.CLAUDE_PROJECT_DIR || process.env.GEMINI_PROJECT_DIR || process.env.OC_PROJECT_DIR || process.env.KILO_PROJECT_DIR;
|
|
8
45
|
|
|
@@ -33,28 +70,12 @@ try {
|
|
|
33
70
|
|
|
34
71
|
if (projectDir && fs.existsSync(projectDir)) {
|
|
35
72
|
try {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
stdio: ['pipe', 'pipe', 'pipe'],
|
|
41
|
-
cwd: projectDir,
|
|
42
|
-
timeout: 15000,
|
|
43
|
-
killSignal: 'SIGTERM'
|
|
44
|
-
});
|
|
45
|
-
} catch (bunErr) {
|
|
46
|
-
thornOutput = bunErr.killed
|
|
47
|
-
? '=== mcp-thorns ===\nSkipped (timeout)'
|
|
48
|
-
: `=== mcp-thorns ===\nSkipped (error: ${bunErr.message.split('\n')[0]})`;
|
|
49
|
-
}
|
|
50
|
-
outputs.push(`=== 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${thornOutput}`);
|
|
51
|
-
} catch (e) {
|
|
52
|
-
if (e.killed && e.signal === 'SIGTERM') {
|
|
53
|
-
outputs.push(`=== mcp-thorns ===\nSkipped (3min timeout)`);
|
|
54
|
-
} else {
|
|
55
|
-
outputs.push(`=== mcp-thorns ===\nSkipped (error: ${e.message.split('\n')[0]})`);
|
|
73
|
+
const r = runLocal('mcp-thorns', [projectDir], { timeout: 15000 });
|
|
74
|
+
const thornOutput = ((r.stdout || '') + (r.stderr || '')).trim();
|
|
75
|
+
if (thornOutput) {
|
|
76
|
+
outputs.push(`=== 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${thornOutput}`);
|
|
56
77
|
}
|
|
57
|
-
}
|
|
78
|
+
} catch (e) {}
|
|
58
79
|
}
|
|
59
80
|
const additionalContext = outputs.join('\n\n');
|
|
60
81
|
|
package/package.json
CHANGED