gm-oc 2.0.32 → 2.0.35

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 +54 -0
  2. package/package.json +1 -1
package/gm.mjs CHANGED
@@ -1,11 +1,14 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
+ import { execSync } from 'child_process';
3
4
  import { fileURLToPath } from 'url';
4
5
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
5
6
 
6
7
  export default async ({ project, client, $, directory, worktree }) => {
7
8
  const pluginDir = __dirname;
8
9
  let agentRules = '';
10
+ let thornsOutput = '';
11
+ let thornsReady = false;
9
12
 
10
13
  const loadAgentRules = () => {
11
14
  if (agentRules) return agentRules;
@@ -14,6 +17,50 @@ export default async ({ project, client, $, directory, worktree }) => {
14
17
  return agentRules;
15
18
  };
16
19
 
20
+ const runThorns = () => {
21
+ if (thornsReady) return thornsOutput;
22
+ thornsReady = true;
23
+ try {
24
+ const out = execSync('bun x mcp-thorns@latest', {
25
+ encoding: 'utf-8', cwd: directory, timeout: 180000,
26
+ stdio: ['pipe', 'pipe', 'pipe']
27
+ });
28
+ thornsOutput = out.trim();
29
+ } catch (e) {
30
+ thornsOutput = '=== mcp-thorns ===\nSkipped (' + e.message.split('\n')[0] + ')';
31
+ }
32
+ return thornsOutput;
33
+ };
34
+
35
+ const runCodeSearch = (query) => {
36
+ if (!query || !directory) return '';
37
+ try {
38
+ const q = query.replace(/"/g, '\\"').substring(0, 200);
39
+ const out = execSync('bun x codebasesearch@latest "' + q + '"', {
40
+ encoding: 'utf-8', cwd: directory, timeout: 55000,
41
+ stdio: ['pipe', 'pipe', 'pipe']
42
+ });
43
+ const lines = out.split('\n');
44
+ const start = lines.findIndex(l => l.includes('Searching for:'));
45
+ return start >= 0 ? lines.slice(start).join('\n').trim() : out.trim();
46
+ } catch (e) { return ''; }
47
+ };
48
+
49
+ const getLastUserMessage = (input) => {
50
+ try {
51
+ const msgs = input?.messages || [];
52
+ for (let i = msgs.length - 1; i >= 0; i--) {
53
+ const m = msgs[i];
54
+ if (m.role === 'user') {
55
+ const parts = Array.isArray(m.content) ? m.content : [m.content];
56
+ const text = parts.map(p => typeof p === 'string' ? p : (p?.text || '')).join(' ').trim();
57
+ if (text) return text;
58
+ }
59
+ }
60
+ } catch (e) {}
61
+ return '';
62
+ };
63
+
17
64
  const prdFile = path.join(directory, '.prd');
18
65
 
19
66
  return {
@@ -22,6 +69,13 @@ export default async ({ project, client, $, directory, worktree }) => {
22
69
  const prd = fs.existsSync(prdFile) ? fs.readFileSync(prdFile, 'utf-8').trim() : '';
23
70
  let content = rules || '';
24
71
  if (prd) content += '\n\nPENDING WORK (.prd):\n' + prd;
72
+ const thorns = runThorns();
73
+ if (thorns) content += '\n\n=== Repository Analysis (mcp-thorns) ===\n' + thorns;
74
+ const lastMsg = getLastUserMessage(input);
75
+ if (lastMsg) {
76
+ const searchResults = runCodeSearch(lastMsg);
77
+ if (searchResults) content += '\n\n=== Semantic code search results ===\n' + searchResults;
78
+ }
25
79
  if (content) output.system.push(content);
26
80
  }
27
81
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-oc",
3
- "version": "2.0.32",
3
+ "version": "2.0.35",
4
4
  "description": "State machine agent with hooks, skills, and automated git enforcement",
5
5
  "author": "AnEntrypoint",
6
6
  "license": "MIT",