stigmergy 1.3.11 ā 1.3.14
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
CHANGED
|
@@ -336,26 +336,41 @@ async function executeSmartRoutedCommand(route, options = {}) {
|
|
|
336
336
|
|
|
337
337
|
// Use enhanced parameter handling for one-time mode only
|
|
338
338
|
if (mode === 'one-time') {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
339
|
+
try {
|
|
340
|
+
const EnhancedCLIParameterHandler = require('../../core/enhanced_cli_parameter_handler');
|
|
341
|
+
const paramHandler = new EnhancedCLIParameterHandler();
|
|
342
|
+
|
|
343
|
+
// Generate optimized arguments with agent/skill support
|
|
344
|
+
// Add timeout protection for parameter generation
|
|
345
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
346
|
+
setTimeout(() => reject(new Error('Parameter generation timeout')), 30000); // 30 second timeout for parameter generation
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
const paramPromise = paramHandler.generateArgumentsWithRetry(
|
|
350
|
+
route.tool,
|
|
351
|
+
route.prompt,
|
|
352
|
+
{
|
|
353
|
+
maxRetries,
|
|
354
|
+
enableAgentSkillOptimization: true
|
|
355
|
+
}
|
|
356
|
+
);
|
|
357
|
+
|
|
358
|
+
const paramResult = await Promise.race([paramPromise, timeoutPromise]);
|
|
359
|
+
|
|
360
|
+
toolArgs = paramResult.arguments;
|
|
361
|
+
|
|
362
|
+
// Re-add OAuth authentication (paramResult might overwrite)
|
|
363
|
+
toolArgs = addOAuthAuthArgs(route.tool, toolArgs);
|
|
364
|
+
|
|
365
|
+
if (verbose) {
|
|
366
|
+
console.log(chalk.gray(`[DEBUG] Generated args: ${toolArgs.join(' ')}`));
|
|
367
|
+
}
|
|
368
|
+
} catch (paramError) {
|
|
369
|
+
console.log(chalk.yellow(`[WARN] Parameter generation failed: ${paramError.message}, using basic arguments`));
|
|
370
|
+
// Fallback to basic arguments if enhanced parameter generation fails
|
|
371
|
+
if (verbose) {
|
|
372
|
+
console.log(chalk.gray(`[DEBUG] Falling back to basic args: ${toolArgs.join(' ')}`));
|
|
349
373
|
}
|
|
350
|
-
);
|
|
351
|
-
|
|
352
|
-
toolArgs = paramResult.arguments;
|
|
353
|
-
|
|
354
|
-
// Re-add OAuth authentication (paramResult might overwrite)
|
|
355
|
-
toolArgs = addOAuthAuthArgs(route.tool, toolArgs);
|
|
356
|
-
|
|
357
|
-
if (verbose) {
|
|
358
|
-
console.log(chalk.gray(`[DEBUG] Generated args: ${toolArgs.join(' ')}`));
|
|
359
374
|
}
|
|
360
375
|
} else {
|
|
361
376
|
if (verbose) {
|
|
@@ -379,15 +394,23 @@ async function executeSmartRoutedCommand(route, options = {}) {
|
|
|
379
394
|
console.log(chalk.gray(`[DEBUG] Mode: ${mode}`));
|
|
380
395
|
}
|
|
381
396
|
|
|
397
|
+
console.log(chalk.gray(`[EXEC] ${route.tool}: ${route.prompt}`)); // Add this to match direct command format
|
|
398
|
+
|
|
382
399
|
// Execute the command
|
|
383
400
|
// For interactive mode, we need stdio: 'inherit' to allow user interaction
|
|
401
|
+
// For one-time mode, we should use 'inherit' to ensure CLI tools can properly execute
|
|
402
|
+
const stdioOption = mode === 'interactive' ? 'inherit' : 'inherit'; // Use 'inherit' for both modes to ensure proper CLI execution
|
|
403
|
+
|
|
404
|
+
console.log(chalk.gray(`[DEBUG] About to execute command with args: ${toolArgs.join(' ')}`)); // Debug log
|
|
405
|
+
console.log(chalk.gray(`[DEBUG] Using stdio option: ${stdioOption}`)); // Debug log
|
|
384
406
|
const result = await executeCommand(toolPath, toolArgs, {
|
|
385
|
-
stdio:
|
|
407
|
+
stdio: stdioOption,
|
|
386
408
|
shell: true,
|
|
387
409
|
cwd,
|
|
388
410
|
env,
|
|
389
411
|
timeout: 300000 // 5 minutes
|
|
390
412
|
});
|
|
413
|
+
console.log(chalk.gray(`[DEBUG] Command execution completed`)); // Debug log
|
|
391
414
|
|
|
392
415
|
return { success: true, tool: route.tool, result, mode };
|
|
393
416
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Resume Session Commands
|
|
3
|
-
* Modular implementation for resume
|
|
3
|
+
* Modular implementation for resume command
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
const chalk = require('chalk');
|
|
@@ -47,7 +47,7 @@ async function handleResumeCommand(args = [], options = {}) {
|
|
|
47
47
|
console.log(chalk.yellow('[INFO] ResumeSession is an optional component for session recovery'));
|
|
48
48
|
|
|
49
49
|
console.log(chalk.blue('\nš¦ To install ResumeSession:'));
|
|
50
|
-
console.log(' npm install -g
|
|
50
|
+
console.log(' npm install -g resumesession');
|
|
51
51
|
console.log('');
|
|
52
52
|
console.log(chalk.blue('š§ ResumeSession provides:'));
|
|
53
53
|
console.log(' ⢠Cross-CLI session history');
|
|
@@ -100,18 +100,16 @@ function printResumeHelp() {
|
|
|
100
100
|
console.log(chalk.cyan(`
|
|
101
101
|
š Stigmergy Resume Session System
|
|
102
102
|
|
|
103
|
-
š ResumeSession forwards to the
|
|
103
|
+
š ResumeSession forwards to the resumesession CLI tool for session management.
|
|
104
104
|
|
|
105
105
|
š ļø Available Commands:
|
|
106
106
|
stigmergy resume [args] Forward to resumesession CLI
|
|
107
|
-
stigmergy resumesession [args] Same as resume (full name)
|
|
108
|
-
stigmergy sg-resume [args] Same as resume (short alias)
|
|
109
107
|
|
|
110
108
|
š¦ Requirements:
|
|
111
|
-
|
|
109
|
+
resumesession CLI tool must be installed separately.
|
|
112
110
|
|
|
113
111
|
š¾ Installation:
|
|
114
|
-
npm install -g
|
|
112
|
+
npm install -g resumesession
|
|
115
113
|
|
|
116
114
|
š Common Usage:
|
|
117
115
|
stigmergy resume list # Show available sessions
|
package/src/cli/router-beta.js
CHANGED
|
@@ -319,7 +319,7 @@ async function main() {
|
|
|
319
319
|
await handleAutoInstallCommand(options);
|
|
320
320
|
});
|
|
321
321
|
|
|
322
|
-
// Resume session
|
|
322
|
+
// Resume session command
|
|
323
323
|
program
|
|
324
324
|
.command('resume')
|
|
325
325
|
.description('Resume session (forwards to @stigmergy/resume CLI tool)')
|
|
@@ -329,26 +329,8 @@ async function main() {
|
|
|
329
329
|
await handleResumeCommand(args, options);
|
|
330
330
|
});
|
|
331
331
|
|
|
332
|
-
program
|
|
333
|
-
.command('resumesession')
|
|
334
|
-
.description('Resume session management (forwards to @stigmergy/resume)')
|
|
335
|
-
.argument('[args...]', 'Arguments to pass to resumesession')
|
|
336
|
-
.option('-v, --verbose', 'Verbose output')
|
|
337
|
-
.action(async (args, options) => {
|
|
338
|
-
await handleResumeCommand(args, options);
|
|
339
|
-
});
|
|
340
|
-
|
|
341
|
-
program
|
|
342
|
-
.command('sg-resume')
|
|
343
|
-
.description('Resume session management (short alias)')
|
|
344
|
-
.argument('[args...]', 'Arguments to pass to resumesession')
|
|
345
|
-
.option('-v, --verbose', 'Verbose output')
|
|
346
|
-
.action(async (args, options) => {
|
|
347
|
-
await handleResumeCommand(args, options);
|
|
348
|
-
});
|
|
349
|
-
|
|
350
332
|
// Route commands to CLI tools
|
|
351
|
-
for (const tool of ['claude', 'gemini', 'qwen', 'codebuddy', 'codex', 'iflow', 'qodercli', 'copilot', 'kode'
|
|
333
|
+
for (const tool of ['claude', 'gemini', 'qwen', 'codebuddy', 'codex', 'iflow', 'qodercli', 'copilot', 'kode']) {
|
|
352
334
|
program
|
|
353
335
|
.command(tool)
|
|
354
336
|
.description(`Use ${tool} CLI tool`)
|
|
@@ -534,8 +534,8 @@ function buildQuery(input) {
|
|
|
534
534
|
search: null
|
|
535
535
|
};
|
|
536
536
|
|
|
537
|
-
const cleanInput = input.replace(new RegExp('^\\\\\\\\/?' + '${commandName}' + '
|
|
538
|
-
const parts = cleanInput.split(
|
|
537
|
+
const cleanInput = input.replace(new RegExp('^\\\\\\\\/?' + '${commandName}' + '\\\\\\s*', 'i'), '').trim();
|
|
538
|
+
const parts = cleanInput.split(/\\\\s+/).filter(p => p.length > 0);
|
|
539
539
|
|
|
540
540
|
for (let i = 0; i < parts.length; i++) {
|
|
541
541
|
const part = parts[i].toLowerCase();
|
|
@@ -624,8 +624,8 @@ class GeminiHistoryHandler {
|
|
|
624
624
|
search: null
|
|
625
625
|
};
|
|
626
626
|
|
|
627
|
-
const cleanInput = input.replace(new RegExp('^\\\\\\\\/?' + this.commandName + '
|
|
628
|
-
const parts = cleanInput.split(
|
|
627
|
+
const cleanInput = input.replace(new RegExp('^\\\\\\\\/?' + this.commandName + '\\\\\\s*', 'i'), '').trim();
|
|
628
|
+
const parts = cleanInput.split(/\\\\s+/).filter(p => p.length > 0);
|
|
629
629
|
|
|
630
630
|
for (let i = 0; i < parts.length; i++) {
|
|
631
631
|
const part = parts[i].toLowerCase();
|
package/src/utils.js
CHANGED
|
@@ -631,10 +631,12 @@ async function executeCommand(command, args = [], options = {}) {
|
|
|
631
631
|
const opts = {
|
|
632
632
|
stdio: 'inherit',
|
|
633
633
|
shell: true,
|
|
634
|
-
timeout: 300000, // 5 minute timeout
|
|
635
634
|
...options,
|
|
636
635
|
};
|
|
637
636
|
|
|
637
|
+
// Extract timeout from options to handle separately
|
|
638
|
+
const timeoutValue = options.timeout || 300000; // Default to 5 minutes if not specified
|
|
639
|
+
|
|
638
640
|
return new Promise((resolve, reject) => {
|
|
639
641
|
// Don't log the command if it contains sensitive information
|
|
640
642
|
if (process.env.DEBUG === 'true') {
|
|
@@ -704,6 +706,9 @@ async function executeCommand(command, args = [], options = {}) {
|
|
|
704
706
|
// Flag to ensure timeout is cleared only once
|
|
705
707
|
let timeoutCleared = false;
|
|
706
708
|
|
|
709
|
+
// Flag to prevent duplicate promise resolution
|
|
710
|
+
let promiseResolved = false;
|
|
711
|
+
|
|
707
712
|
// Function to clear timeout safely
|
|
708
713
|
const clearTimeoutSafely = () => {
|
|
709
714
|
if (timeoutId && !timeoutCleared) {
|
|
@@ -712,12 +717,28 @@ async function executeCommand(command, args = [], options = {}) {
|
|
|
712
717
|
}
|
|
713
718
|
};
|
|
714
719
|
|
|
720
|
+
// Function to resolve safely (prevent duplicate resolution)
|
|
721
|
+
const safeResolve = (result) => {
|
|
722
|
+
if (!promiseResolved) {
|
|
723
|
+
promiseResolved = true;
|
|
724
|
+
resolve(result);
|
|
725
|
+
}
|
|
726
|
+
};
|
|
727
|
+
|
|
728
|
+
// Function to reject safely (prevent duplicate rejection)
|
|
729
|
+
const safeReject = (error) => {
|
|
730
|
+
if (!promiseResolved) {
|
|
731
|
+
promiseResolved = true;
|
|
732
|
+
reject(error);
|
|
733
|
+
}
|
|
734
|
+
};
|
|
735
|
+
|
|
715
736
|
child.on('exit', (code, signal) => {
|
|
716
737
|
// Clear timeout when process exits
|
|
717
738
|
clearTimeoutSafely();
|
|
718
739
|
|
|
719
740
|
// Resolve with collected stdout/stderr
|
|
720
|
-
|
|
741
|
+
safeResolve({
|
|
721
742
|
code,
|
|
722
743
|
signal,
|
|
723
744
|
stdout,
|
|
@@ -732,8 +753,8 @@ async function executeCommand(command, args = [], options = {}) {
|
|
|
732
753
|
|
|
733
754
|
// Only resolve if not already resolved via 'exit' event
|
|
734
755
|
// This prevents duplicate resolution
|
|
735
|
-
if (!
|
|
736
|
-
|
|
756
|
+
if (!promiseResolved) {
|
|
757
|
+
safeResolve({
|
|
737
758
|
code,
|
|
738
759
|
signal,
|
|
739
760
|
stdout,
|
|
@@ -766,16 +787,16 @@ async function executeCommand(command, args = [], options = {}) {
|
|
|
766
787
|
});
|
|
767
788
|
|
|
768
789
|
// Handle timeout
|
|
769
|
-
if (
|
|
790
|
+
if (timeoutValue) {
|
|
770
791
|
timeoutId = setTimeout(() => {
|
|
771
792
|
child.kill();
|
|
772
793
|
reject({
|
|
773
794
|
error: new Error('Command timeout'),
|
|
774
|
-
message: `Command timed out after ${
|
|
795
|
+
message: `Command timed out after ${timeoutValue}ms`,
|
|
775
796
|
stdout,
|
|
776
797
|
stderr,
|
|
777
798
|
});
|
|
778
|
-
},
|
|
799
|
+
}, timeoutValue);
|
|
779
800
|
}
|
|
780
801
|
} catch (error) {
|
|
781
802
|
reject({
|