gm-kilo 2.0.336 → 2.0.337
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-kilo.mjs +24 -0
- package/package.json +1 -1
package/gm-kilo.mjs
CHANGED
|
@@ -19,10 +19,26 @@ function detectLang(src) {
|
|
|
19
19
|
|
|
20
20
|
function stripFooter(s) { return s ? s.replace(/\n\[Running tools\][\s\S]*$/, '').trimEnd() : ''; }
|
|
21
21
|
|
|
22
|
+
function tryLangPlugin(lang, code, cwd) {
|
|
23
|
+
const langPluginDir = join(__dirname, '..', 'lang');
|
|
24
|
+
const langPluginFile = join(langPluginDir, lang+'.js');
|
|
25
|
+
if (!existsSync(langPluginFile)) return null;
|
|
26
|
+
try {
|
|
27
|
+
const plugin = require(langPluginFile);
|
|
28
|
+
if (plugin && plugin.exec && plugin.exec.run) {
|
|
29
|
+
const result = plugin.exec.run(code, cwd || process.cwd());
|
|
30
|
+
return String(result === undefined ? '' : result);
|
|
31
|
+
}
|
|
32
|
+
} catch(e) {}
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
|
|
22
36
|
function runExec(rawLang, code, cwd) {
|
|
23
37
|
const lang = LANG_ALIASES[rawLang] || (rawLang || detectLang(code));
|
|
24
38
|
const opts = { encoding: 'utf-8', timeout: 30000, ...(cwd && { cwd }) };
|
|
25
39
|
const out = (r) => { const o = (r.stdout||'').trimEnd(), e = stripFooter(r.stderr||'').trimEnd(); return o && e ? o+'\n[stderr]\n'+e : o||e||'(no output)'; };
|
|
40
|
+
const pluginResult = tryLangPlugin(lang, code, cwd);
|
|
41
|
+
if (pluginResult !== null) return pluginResult;
|
|
26
42
|
if (lang === 'python') return out(spawnSync('python3',['-c',code],opts));
|
|
27
43
|
const ext = lang === 'typescript' ? 'ts' : lang === 'bash' ? 'sh' : 'mjs';
|
|
28
44
|
const tmp = join(tmpdir(),'gm-plugin-'+Date.now()+'.'+ext);
|
|
@@ -94,6 +110,14 @@ export async function GmPlugin({ directory }) {
|
|
|
94
110
|
output.args = { ...output.args, command: safePrintf('Use the code-search skill for codebase exploration instead of '+input.tool+'. Describe what you need in plain language.') };
|
|
95
111
|
return;
|
|
96
112
|
}
|
|
113
|
+
if (input.tool === 'EnterPlanMode') {
|
|
114
|
+
output.args = { ...output.args, command: safePrintf('Plan mode is disabled. Use the gm skill (PLAN→EXECUTE→EMIT→VERIFY→COMPLETE state machine) instead.') };
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if (input.tool === 'Task' && input.args?.subagent_type === 'Explore') {
|
|
118
|
+
output.args = { ...output.args, command: safePrintf('The Explore agent is blocked. Use exec:codesearch in the Bash tool instead.\n\nexec:codesearch\n<natural language description of what to find>') };
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
97
121
|
if (input.tool === 'write' || input.tool === 'Write') {
|
|
98
122
|
const fp = (output.args && output.args.file_path) || '';
|
|
99
123
|
const base = basename(fp).toLowerCase();
|