gm-kilo 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.
- package/gm.mjs +28 -1
- package/package.json +1 -1
package/gm.mjs
CHANGED
|
@@ -15,6 +15,28 @@ export default async ({ directory }) => {
|
|
|
15
15
|
encoding: 'utf-8', cwd: directory, timeout: 180000
|
|
16
16
|
}, (err, stdout) => resolve(err ? '' : (stdout || '').trim()));
|
|
17
17
|
});
|
|
18
|
+
const runCodeSearch = (query) => new Promise((resolve) => {
|
|
19
|
+
const q = query.replace(/"/g, '\\"').substring(0, 200);
|
|
20
|
+
exec('bun x codebasesearch@latest "' + q + '"', {
|
|
21
|
+
encoding: 'utf-8', cwd: directory, timeout: 300000
|
|
22
|
+
}, (err, stdout) => {
|
|
23
|
+
if (err) return resolve('');
|
|
24
|
+
const lines = (stdout || '').split('\n');
|
|
25
|
+
const start = lines.findIndex(l => l.includes('Searching for:'));
|
|
26
|
+
resolve(start >= 0 ? lines.slice(start).join('\n').trim() : (stdout || '').trim());
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
const getLastUserMessage = (msgs) => {
|
|
30
|
+
for (let i = msgs.length - 1; i >= 0; i--) {
|
|
31
|
+
const m = msgs[i];
|
|
32
|
+
if (m.role === 'user') {
|
|
33
|
+
const parts = Array.isArray(m.content) ? m.content : [m.content];
|
|
34
|
+
const text = parts.map(p => typeof p === 'string' ? p : (p?.text || '')).join(' ').trim();
|
|
35
|
+
if (text) return text;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return '';
|
|
39
|
+
};
|
|
18
40
|
const prdFile = join(directory, '.prd');
|
|
19
41
|
return {
|
|
20
42
|
'experimental.chat.system.transform': async (input, output) => {
|
|
@@ -26,8 +48,13 @@ export default async ({ directory }) => {
|
|
|
26
48
|
const lastMsg = msgs.length > 0 ? msgs[msgs.length - 1] : null;
|
|
27
49
|
const hasNewUserPrompt = !lastMsg || lastMsg.role === 'user';
|
|
28
50
|
if (hasNewUserPrompt) {
|
|
29
|
-
const
|
|
51
|
+
const userQuery = getLastUserMessage(msgs);
|
|
52
|
+
const [thorns, search] = await Promise.all([
|
|
53
|
+
runThorns(),
|
|
54
|
+
userQuery ? runCodeSearch(userQuery) : Promise.resolve('')
|
|
55
|
+
]);
|
|
30
56
|
if (thorns) content += '\n\n=== Repository Analysis (mcp-thorns) ===\n' + thorns;
|
|
57
|
+
if (search) content += '\n\n=== Semantic Code Search Results ===\n' + search;
|
|
31
58
|
}
|
|
32
59
|
if (content) output.system.push(content);
|
|
33
60
|
}
|