gm-oc 2.0.41 → 2.0.42
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/gm.mjs +2 -32
- package/package.json +1 -1
package/gm.mjs
CHANGED
|
@@ -18,30 +18,6 @@ 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: 55000
|
|
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
|
-
|
|
45
21
|
const prdFile = join(directory, '.prd');
|
|
46
22
|
|
|
47
23
|
return {
|
|
@@ -50,19 +26,13 @@ export async function GmPlugin({ directory }) {
|
|
|
50
26
|
const prd = existsSync(prdFile) ? readFileSync(prdFile, 'utf-8').trim() : '';
|
|
51
27
|
let content = rules || '';
|
|
52
28
|
if (prd) content += '\n\nPENDING WORK (.prd):\n' + prd;
|
|
53
|
-
//
|
|
54
|
-
// Skip if last message is from assistant (tool result inject, no new user input)
|
|
29
|
+
// Run thorns fresh on every user prompt (skip during tool-result-only calls)
|
|
55
30
|
const msgs = input?.messages || [];
|
|
56
31
|
const lastMsg = msgs.length > 0 ? msgs[msgs.length - 1] : null;
|
|
57
32
|
const hasNewUserPrompt = !lastMsg || lastMsg.role === 'user';
|
|
58
33
|
if (hasNewUserPrompt) {
|
|
59
|
-
const
|
|
60
|
-
const [thorns, search] = await Promise.all([
|
|
61
|
-
runThorns(),
|
|
62
|
-
userQuery ? runCodeSearch(userQuery) : Promise.resolve('')
|
|
63
|
-
]);
|
|
34
|
+
const thorns = await runThorns();
|
|
64
35
|
if (thorns) content += '\n\n=== Repository Analysis (mcp-thorns) ===\n' + thorns;
|
|
65
|
-
if (search) content += '\n\n=== Semantic code search results ===\n' + search;
|
|
66
36
|
}
|
|
67
37
|
if (content) output.system.push(content);
|
|
68
38
|
}
|