stigmergy 1.1.0 → 1.1.2
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/package.json +1 -1
- package/src/cli/router.js +34 -9
- package/src/core/installer.js +1 -0
package/package.json
CHANGED
package/src/cli/router.js
CHANGED
|
@@ -33,6 +33,7 @@ async function main() {
|
|
|
33
33
|
// Create instances
|
|
34
34
|
const memory = new MemoryManager();
|
|
35
35
|
const installer = new StigmergyInstaller();
|
|
36
|
+
const router = new SmartRouter();
|
|
36
37
|
|
|
37
38
|
// Handle help command early
|
|
38
39
|
if (
|
|
@@ -263,11 +264,40 @@ async function main() {
|
|
|
263
264
|
console.log(`[ROUTE] Analyzing prompt: ${prompt}`);
|
|
264
265
|
|
|
265
266
|
// Route to appropriate AI CLI tool
|
|
266
|
-
const route = await router.
|
|
267
|
+
const route = await router.smartRoute(prompt);
|
|
267
268
|
console.log(`[ROUTE] Selected tool: ${route.tool}`);
|
|
268
269
|
|
|
269
270
|
// Prepare tool arguments
|
|
270
|
-
|
|
271
|
+
let toolArgs = [];
|
|
272
|
+
|
|
273
|
+
try {
|
|
274
|
+
// Get CLI pattern for this tool
|
|
275
|
+
const cliPattern = await router.analyzer.getCLIPattern(route.tool);
|
|
276
|
+
|
|
277
|
+
// Use the unified CLI parameter handler
|
|
278
|
+
const CLIParameterHandler = require('../core/cli_parameter_handler');
|
|
279
|
+
toolArgs = CLIParameterHandler.generateArguments(
|
|
280
|
+
route.tool,
|
|
281
|
+
route.prompt,
|
|
282
|
+
cliPattern,
|
|
283
|
+
);
|
|
284
|
+
} catch (patternError) {
|
|
285
|
+
// Fallback to original logic if pattern analysis fails
|
|
286
|
+
if (route.tool === 'claude') {
|
|
287
|
+
// Claude CLI expects the prompt with -p flag for non-interactive mode
|
|
288
|
+
toolArgs = ['-p', `"${route.prompt}"`];
|
|
289
|
+
} else if (route.tool === 'qodercli' || route.tool === 'iflow') {
|
|
290
|
+
// Qoder CLI and iFlow expect the prompt with -p flag
|
|
291
|
+
toolArgs = ['-p', `"${route.prompt}"`];
|
|
292
|
+
} else if (route.tool === 'codex') {
|
|
293
|
+
// Codex CLI needs 'exec' subcommand for non-interactive mode
|
|
294
|
+
toolArgs = ['exec', '-p', `"${route.prompt}"`];
|
|
295
|
+
} else {
|
|
296
|
+
// For other tools, pass the prompt with -p flag
|
|
297
|
+
toolArgs = ['-p', `"${route.prompt}"`];
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
271
301
|
const toolPath = route.tool;
|
|
272
302
|
|
|
273
303
|
console.log(`[EXEC] Running: ${toolPath} ${toolArgs.join(' ')}`);
|
|
@@ -317,14 +347,9 @@ async function main() {
|
|
|
317
347
|
process.exit(1);
|
|
318
348
|
}
|
|
319
349
|
} catch (error) {
|
|
320
|
-
const cliError = await errorHandler.handleCLIError(
|
|
321
|
-
route.tool,
|
|
322
|
-
error,
|
|
323
|
-
prompt,
|
|
324
|
-
);
|
|
325
350
|
console.log(
|
|
326
|
-
`[ERROR] Failed to
|
|
327
|
-
|
|
351
|
+
`[ERROR] Failed to route prompt:`,
|
|
352
|
+
error.message,
|
|
328
353
|
);
|
|
329
354
|
process.exit(1);
|
|
330
355
|
}
|