stigmergy 1.2.11 → 1.2.12

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/cli/router.js +50 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stigmergy",
3
- "version": "1.2.11",
3
+ "version": "1.2.12",
4
4
  "description": "Stigmergy CLI - Multi-Agents Cross-AI CLI Tools Collaboration System",
5
5
  "main": "src/index.js",
6
6
  "bin": {
package/src/cli/router.js CHANGED
@@ -45,6 +45,30 @@ function formatBytes(bytes) {
45
45
  return Math.round(bytes / Math.pow(1024, i) * 100) / 100 + ' ' + sizes[i];
46
46
  }
47
47
 
48
+ // Helper function to get appropriate working directory for CLI tools
49
+ function getWorkingDirectoryForTool(toolName) {
50
+ switch (toolName) {
51
+ case 'qwen':
52
+ // For Qwen CLI, use user home directory to avoid module resolution issues
53
+ return os.homedir();
54
+ case 'claude':
55
+ // For Claude CLI, use user home directory
56
+ return os.homedir();
57
+ case 'gemini':
58
+ // For Gemini CLI, use user home directory
59
+ return os.homedir();
60
+ case 'iflow':
61
+ // For iFlow CLI, use user home directory
62
+ return os.homedir();
63
+ case 'qodercli':
64
+ // For Qoder CLI, use user home directory
65
+ return os.homedir();
66
+ default:
67
+ // For other tools, use current directory
68
+ return process.cwd();
69
+ }
70
+ }
71
+
48
72
  async function main() {
49
73
  const args = process.argv.slice(2);
50
74
 
@@ -757,9 +781,18 @@ async function main() {
757
781
  console.log(`[DEBUG] Windows unified command: ${execCommand}`);
758
782
  }
759
783
 
784
+ // Set environment for tools that need specific working directories
785
+ const env = { ...process.env };
786
+ if (route.tool === 'qwen') {
787
+ // For Qwen CLI, clear NODE_PATH to avoid import conflicts
788
+ delete env.NODE_PATH;
789
+ }
790
+
760
791
  const result = await executeCommand(execCommand, execArgs, {
761
792
  stdio: 'inherit',
762
793
  shell: true,
794
+ cwd: getWorkingDirectoryForTool(route.tool),
795
+ env,
763
796
  });
764
797
 
765
798
  if (!result.success) {
@@ -809,9 +842,17 @@ async function main() {
809
842
  // For other execution errors, try to execute the command directly
810
843
  // which handles cases where the tool executed successfully but returned an error object
811
844
  console.log(`[EXEC] Running: ${toolPath} ${toolArgs.join(' ')}`);
845
+ // Set environment for tools that need specific working directories
846
+ const env = { ...process.env };
847
+ if (route.tool === 'qwen') {
848
+ delete env.NODE_PATH;
849
+ }
850
+
812
851
  const result = await executeCommand(toolPath, toolArgs, {
813
852
  stdio: 'inherit',
814
853
  shell: true,
854
+ cwd: getWorkingDirectoryForTool(route.tool),
855
+ env,
815
856
  });
816
857
 
817
858
  if (!result.success) {
@@ -1651,9 +1692,18 @@ async function main() {
1651
1692
  // For other execution errors, try to execute the command directly
1652
1693
  // which handles cases where the tool executed successfully but returned an error object
1653
1694
  console.log(`[EXEC] Running: ${toolPath} ${toolArgs.join(' ')}`);
1695
+
1696
+ // Set environment for tools that need specific working directories
1697
+ const env = { ...process.env };
1698
+ if (route.tool === 'qwen') {
1699
+ delete env.NODE_PATH;
1700
+ }
1701
+
1654
1702
  const result = await executeCommand(toolPath, toolArgs, {
1655
1703
  stdio: 'inherit',
1656
1704
  shell: true,
1705
+ cwd: getWorkingDirectoryForTool(route.tool),
1706
+ env,
1657
1707
  });
1658
1708
 
1659
1709
  if (!result.success) {