gm-oc 2.0.42 → 2.0.43

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 +30 -2
  2. package/package.json +1 -1
package/gm.mjs CHANGED
@@ -18,6 +18,30 @@ export async function GmPlugin({ directory }) {
18
18
  }, (err, stdout) => resolve(err ? '' : (stdout || '').trim()));
19
19
  });
20
20
 
21
+ const runCodeSearch = (query) => new Promise((resolve) => {
22
+ const q = query.replace(/"/g, '\\"').substring(0, 200);
23
+ exec('bun x codebasesearch@latest "' + q + '"', {
24
+ encoding: 'utf-8', cwd: directory, timeout: 300000
25
+ }, (err, stdout) => {
26
+ if (err) return resolve('');
27
+ const lines = (stdout || '').split('\n');
28
+ const start = lines.findIndex(l => l.includes('Searching for:'));
29
+ resolve(start >= 0 ? lines.slice(start).join('\n').trim() : (stdout || '').trim());
30
+ });
31
+ });
32
+
33
+ const getLastUserMessage = (msgs) => {
34
+ for (let i = msgs.length - 1; i >= 0; i--) {
35
+ const m = msgs[i];
36
+ if (m.role === 'user') {
37
+ const parts = Array.isArray(m.content) ? m.content : [m.content];
38
+ const text = parts.map(p => typeof p === 'string' ? p : (p?.text || '')).join(' ').trim();
39
+ if (text) return text;
40
+ }
41
+ }
42
+ return '';
43
+ };
44
+
21
45
  const prdFile = join(directory, '.prd');
22
46
 
23
47
  return {
@@ -26,13 +50,17 @@ export async function GmPlugin({ directory }) {
26
50
  const prd = existsSync(prdFile) ? readFileSync(prdFile, 'utf-8').trim() : '';
27
51
  let content = rules || '';
28
52
  if (prd) content += '\n\nPENDING WORK (.prd):\n' + prd;
29
- // Run thorns fresh on every user prompt (skip during tool-result-only calls)
30
53
  const msgs = input?.messages || [];
31
54
  const lastMsg = msgs.length > 0 ? msgs[msgs.length - 1] : null;
32
55
  const hasNewUserPrompt = !lastMsg || lastMsg.role === 'user';
33
56
  if (hasNewUserPrompt) {
34
- const thorns = await runThorns();
57
+ const userQuery = getLastUserMessage(msgs);
58
+ const [thorns, search] = await Promise.all([
59
+ runThorns(),
60
+ userQuery ? runCodeSearch(userQuery) : Promise.resolve('')
61
+ ]);
35
62
  if (thorns) content += '\n\n=== Repository Analysis (mcp-thorns) ===\n' + thorns;
63
+ if (search) content += '\n\n=== Semantic Code Search Results ===\n' + search;
36
64
  }
37
65
  if (content) output.system.push(content);
38
66
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-oc",
3
- "version": "2.0.42",
3
+ "version": "2.0.43",
4
4
  "description": "State machine agent with hooks, skills, and automated git enforcement",
5
5
  "author": "AnEntrypoint",
6
6
  "license": "MIT",