stigmergy 1.0.97 → 1.0.99

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/src/main.js CHANGED
@@ -6,75 +6,75 @@
6
6
  * Version: 1.0.76
7
7
  */
8
8
 
9
- const { spawn, spawnSync } = require("child_process");
10
- const path = require("path");
11
- const fs = require("fs/promises");
12
- const os = require("os");
9
+ const { spawn, spawnSync } = require('child_process');
10
+ const path = require('path');
11
+ const fs = require('fs/promises');
12
+ const os = require('os');
13
13
 
14
14
  // Import error handler
15
- const { errorHandler } = require("./core/error_handler");
15
+ const { errorHandler } = require('./core/error_handler');
16
16
 
17
17
  // Set up global error handlers using our error handler module
18
- const { setupGlobalErrorHandlers } = require("./core/error_handler");
18
+ const { setupGlobalErrorHandlers } = require('./core/error_handler');
19
19
  setupGlobalErrorHandlers();
20
20
 
21
21
  // AI CLI Tools Configuration
22
22
  const CLI_TOOLS = {
23
23
  claude: {
24
- name: "Claude CLI",
25
- version: "claude --version",
26
- install: "npm install -g @anthropic-ai/claude-cli",
27
- hooksDir: path.join(os.homedir(), ".claude", "hooks"),
28
- config: path.join(os.homedir(), ".claude", "config.json"),
24
+ name: 'Claude CLI',
25
+ version: 'claude --version',
26
+ install: 'npm install -g @anthropic-ai/claude-cli',
27
+ hooksDir: path.join(os.homedir(), '.claude', 'hooks'),
28
+ config: path.join(os.homedir(), '.claude', 'config.json'),
29
29
  },
30
30
  gemini: {
31
- name: "Gemini CLI",
32
- version: "gemini --version",
33
- install: "npm install -g @google/generative-ai-cli",
34
- hooksDir: path.join(os.homedir(), ".gemini", "extensions"),
35
- config: path.join(os.homedir(), ".gemini", "config.json"),
31
+ name: 'Gemini CLI',
32
+ version: 'gemini --version',
33
+ install: 'npm install -g @google/generative-ai-cli',
34
+ hooksDir: path.join(os.homedir(), '.gemini', 'extensions'),
35
+ config: path.join(os.homedir(), '.gemini', 'config.json'),
36
36
  },
37
37
  qwen: {
38
- name: "Qwen CLI",
39
- version: "qwen --version",
40
- install: "npm install -g @alibaba/qwen-cli",
41
- hooksDir: path.join(os.homedir(), ".qwen", "hooks"),
42
- config: path.join(os.homedir(), ".qwen", "config.json"),
38
+ name: 'Qwen CLI',
39
+ version: 'qwen --version',
40
+ install: 'npm install -g @alibaba/qwen-cli',
41
+ hooksDir: path.join(os.homedir(), '.qwen', 'hooks'),
42
+ config: path.join(os.homedir(), '.qwen', 'config.json'),
43
43
  },
44
44
  iflow: {
45
- name: "iFlow CLI",
46
- version: "iflow --version",
47
- install: "npm install -g iflow-cli",
48
- hooksDir: path.join(os.homedir(), ".iflow", "hooks"),
49
- config: path.join(os.homedir(), ".iflow", "config.json"),
45
+ name: 'iFlow CLI',
46
+ version: 'iflow --version',
47
+ install: 'npm install -g iflow-cli',
48
+ hooksDir: path.join(os.homedir(), '.iflow', 'hooks'),
49
+ config: path.join(os.homedir(), '.iflow', 'config.json'),
50
50
  },
51
51
  qoder: {
52
- name: "Qoder CLI",
53
- version: "qodercli --version",
54
- install: "npm install -g @qoder-ai/qodercli",
55
- hooksDir: path.join(os.homedir(), ".qoder", "hooks"),
56
- config: path.join(os.homedir(), ".qoder", "config.json"),
52
+ name: 'Qoder CLI',
53
+ version: 'qodercli --version',
54
+ install: 'npm install -g @qoder-ai/qodercli',
55
+ hooksDir: path.join(os.homedir(), '.qoder', 'hooks'),
56
+ config: path.join(os.homedir(), '.qoder', 'config.json'),
57
57
  },
58
58
  codebuddy: {
59
- name: "CodeBuddy CLI",
60
- version: "codebuddy --version",
61
- install: "npm install -g codebuddy-cli",
62
- hooksDir: path.join(os.homedir(), ".codebuddy", "hooks"),
63
- config: path.join(os.homedir(), ".codebuddy", "config.json"),
59
+ name: 'CodeBuddy CLI',
60
+ version: 'codebuddy --version',
61
+ install: 'npm install -g codebuddy-cli',
62
+ hooksDir: path.join(os.homedir(), '.codebuddy', 'hooks'),
63
+ config: path.join(os.homedir(), '.codebuddy', 'config.json'),
64
64
  },
65
65
  copilot: {
66
- name: "GitHub Copilot CLI",
67
- version: "copilot --version",
68
- install: "npm install -g @github/copilot-cli",
69
- hooksDir: path.join(os.homedir(), ".copilot", "mcp"),
70
- config: path.join(os.homedir(), ".copilot", "config.json"),
66
+ name: 'GitHub Copilot CLI',
67
+ version: 'copilot --version',
68
+ install: 'npm install -g @github/copilot-cli',
69
+ hooksDir: path.join(os.homedir(), '.copilot', 'mcp'),
70
+ config: path.join(os.homedir(), '.copilot', 'config.json'),
71
71
  },
72
72
  codex: {
73
- name: "OpenAI Codex CLI",
74
- version: "codex --version",
75
- install: "npm install -g openai-codex-cli",
76
- hooksDir: path.join(os.homedir(), ".config", "codex", "slash_commands"),
77
- config: path.join(os.homedir(), ".codex", "config.json"),
73
+ name: 'OpenAI Codex CLI',
74
+ version: 'codex --version',
75
+ install: 'npm install -g openai-codex-cli',
76
+ hooksDir: path.join(os.homedir(), '.config', 'codex', 'slash_commands'),
77
+ config: path.join(os.homedir(), '.codex', 'config.json'),
78
78
  },
79
79
  };
80
80
 
@@ -82,18 +82,18 @@ class SmartRouter {
82
82
  constructor() {
83
83
  this.tools = CLI_TOOLS;
84
84
  this.routeKeywords = [
85
- "use",
86
- "help",
87
- "please",
88
- "write",
89
- "generate",
90
- "explain",
91
- "analyze",
92
- "translate",
93
- "code",
94
- "article",
85
+ 'use',
86
+ 'help',
87
+ 'please',
88
+ 'write',
89
+ 'generate',
90
+ 'explain',
91
+ 'analyze',
92
+ 'translate',
93
+ 'code',
94
+ 'article',
95
95
  ];
96
- this.defaultTool = "claude";
96
+ this.defaultTool = 'claude';
97
97
  }
98
98
 
99
99
  shouldRoute(userInput) {
@@ -106,13 +106,13 @@ class SmartRouter {
106
106
  const input = userInput.trim();
107
107
 
108
108
  // Detect tool-specific keywords
109
- for (const [toolName, toolInfo] of Object.entries(this.tools)) {
109
+ for (const [toolName, _] of Object.entries(this.tools)) {
110
110
  for (const keyword of this.extractKeywords(toolName)) {
111
111
  if (input.toLowerCase().includes(keyword.toLowerCase())) {
112
112
  // Extract clean parameters
113
113
  const cleanInput = input
114
- .replace(new RegExp(`.*${keyword}\\s*`, "gi"), "")
115
- .replace(/^(用|帮我|请|麻烦|给我|帮我写|帮我生成)\s*/i, "")
114
+ .replace(new RegExp(`.*${keyword}\\s*`, 'gi'), '')
115
+ .replace(/^(用|帮我|请|麻烦|给我|帮我写|帮我生成)\s*/i, '')
116
116
  .trim();
117
117
  return { tool: toolName, prompt: cleanInput };
118
118
  }
@@ -121,21 +121,21 @@ class SmartRouter {
121
121
 
122
122
  // Default routing
123
123
  const cleanInput = input
124
- .replace(/^(用|帮我|请|麻烦|给我|帮我写|帮我生成)\s*/i, "")
124
+ .replace(/^(用|帮我|请|麻烦|给我|帮我写|帮我生成)\s*/i, '')
125
125
  .trim();
126
126
  return { tool: this.defaultTool, prompt: cleanInput };
127
127
  }
128
128
 
129
129
  extractKeywords(toolName) {
130
130
  const keywordMap = {
131
- claude: ["claude", "anthropic"],
132
- gemini: ["gemini", "google", "谷歌"],
133
- qwen: ["qwen", "通义", "阿里"],
134
- iflow: ["iflow", "心流", "intelligent"],
135
- qoder: ["qoder", "qodercli"],
136
- codebuddy: ["codebuddy", "buddy"],
137
- copilot: ["copilot", "github"],
138
- codex: ["codex", "openai"],
131
+ claude: ['claude', 'anthropic'],
132
+ gemini: ['gemini', 'google', '谷歌'],
133
+ qwen: ['qwen', '通义', '阿里'],
134
+ iflow: ['iflow', '心流', 'intelligent'],
135
+ qoder: ['qoder', 'qodercli'],
136
+ codebuddy: ['codebuddy', 'buddy'],
137
+ copilot: ['copilot', 'github'],
138
+ codex: ['codex', 'openai'],
139
139
  };
140
140
  return keywordMap[toolName] || [toolName];
141
141
  }
@@ -152,7 +152,7 @@ class SmartRouter {
152
152
 
153
153
  try {
154
154
  const result = spawnSync(toolName, [prompt], {
155
- encoding: "utf8",
155
+ encoding: 'utf8',
156
156
  timeout: 30000,
157
157
  });
158
158
 
@@ -169,11 +169,11 @@ class SmartRouter {
169
169
  checkCLI(toolName) {
170
170
  try {
171
171
  const tool = this.tools[toolName];
172
- const command = tool.version.split(" ")[0];
173
- const args = tool.version.split(" ").slice(1);
172
+ const command = tool.version.split(' ')[0];
173
+ const args = tool.version.split(' ').slice(1);
174
174
 
175
175
  const result = spawnSync(command, args, {
176
- stdio: "ignore",
176
+ stdio: 'ignore',
177
177
  timeout: 10000,
178
178
  env: { ...process.env },
179
179
  });
@@ -188,8 +188,8 @@ class SmartRouter {
188
188
  if (!tool) return null;
189
189
 
190
190
  try {
191
- const result = spawnSync(toolName, ["--help"], {
192
- encoding: "utf8",
191
+ const result = spawnSync(toolName, ['--help'], {
192
+ encoding: 'utf8',
193
193
  timeout: 15000,
194
194
  });
195
195
 
@@ -228,7 +228,7 @@ class SmartRouter {
228
228
  );
229
229
  if (exampleMatches) {
230
230
  capabilities.examples = exampleMatches.map((match) =>
231
- match.replace(/^(example|Usage|用法)[::]\s*/i, "").trim(),
231
+ match.replace(/^(example|Usage|用法)[::]\s*/i, '').trim(),
232
232
  );
233
233
  }
234
234
 
@@ -239,7 +239,7 @@ class SmartRouter {
239
239
  class StigmergyInstaller {
240
240
  constructor() {
241
241
  this.homeDir = os.homedir();
242
- this.stigmergyDir = path.join(this.homeDir, ".stigmergy");
242
+ this.stigmergyDir = path.join(this.homeDir, '.stigmergy');
243
243
  this.projectDir = process.cwd();
244
244
  }
245
245
 
@@ -255,11 +255,11 @@ class StigmergyInstaller {
255
255
  checkCLI(toolName) {
256
256
  try {
257
257
  const tool = CLI_TOOLS[toolName];
258
- const command = tool.version.split(" ")[0];
259
- const args = tool.version.split(" ").slice(1);
258
+ const command = tool.version.split(' ')[0];
259
+ const args = tool.version.split(' ').slice(1);
260
260
 
261
261
  const result = spawnSync(command, args, {
262
- stdio: "ignore",
262
+ stdio: 'ignore',
263
263
  timeout: 10000,
264
264
  env: { ...process.env },
265
265
  });
@@ -277,8 +277,8 @@ class StigmergyInstaller {
277
277
  details: [],
278
278
  };
279
279
 
280
- console.log("[SCAN] Scanning for AI CLI tools on your system...");
281
- console.log("=".repeat(60));
280
+ console.log('[SCAN] Scanning for AI CLI tools on your system...');
281
+ console.log('='.repeat(60));
282
282
 
283
283
  for (const [key, tool] of Object.entries(CLI_TOOLS)) {
284
284
  const isAvailable = this.checkCLI(key);
@@ -289,7 +289,7 @@ class StigmergyInstaller {
289
289
  results.details.push({
290
290
  key,
291
291
  name: tool.name,
292
- status: "Available",
292
+ status: 'Available',
293
293
  install: tool.install,
294
294
  hooksDir: tool.hooksDir,
295
295
  });
@@ -299,54 +299,54 @@ class StigmergyInstaller {
299
299
  results.details.push({
300
300
  key,
301
301
  name: tool.name,
302
- status: "Not Available",
302
+ status: 'Not Available',
303
303
  install: tool.install,
304
304
  hooksDir: tool.hooksDir,
305
305
  });
306
306
  }
307
307
  }
308
308
 
309
- console.log("=".repeat(60));
309
+ console.log('='.repeat(60));
310
310
  console.log(
311
311
  `[SUMMARY] ${results.available.length}/${results.total} tools available`,
312
312
  );
313
- console.log("");
313
+ console.log('');
314
314
 
315
315
  return results;
316
316
  }
317
317
 
318
318
  async promptForInstallation(scanResults) {
319
319
  if (scanResults.unavailable.length === 0) {
320
- console.log("[SUCCESS] All AI CLI tools are already installed!");
320
+ console.log('[SUCCESS] All AI CLI tools are already installed!');
321
321
  return [];
322
322
  }
323
323
 
324
324
  console.log(
325
- "[INSTALL] The following AI CLI tools can be automatically installed:",
325
+ '[INSTALL] The following AI CLI tools can be automatically installed:',
326
326
  );
327
- console.log("");
327
+ console.log('');
328
328
 
329
329
  scanResults.unavailable.forEach((toolKey, index) => {
330
330
  const tool = CLI_TOOLS[toolKey];
331
331
  console.log(` ${index + 1}. ${tool.name}`);
332
332
  console.log(` Install: ${tool.install}`);
333
- console.log("");
333
+ console.log('');
334
334
  });
335
335
 
336
- console.log("[OPTIONS] Installation Options:");
337
- console.log(" - Enter numbers separated by spaces (e.g: 1 3 5)");
336
+ console.log('[OPTIONS] Installation Options:');
337
+ console.log(' - Enter numbers separated by spaces (e.g: 1 3 5)');
338
338
  console.log(' - Enter "all" to install all missing tools');
339
339
  console.log(' - Enter "skip" to skip CLI installation');
340
340
 
341
341
  return new Promise((resolve) => {
342
- process.stdout.write("\n[SELECT] Select tools to install: ");
342
+ process.stdout.write('\n[SELECT] Select tools to install: ');
343
343
 
344
- process.stdin.once("data", (data) => {
344
+ process.stdin.once('data', (data) => {
345
345
  const input = data.toString().trim();
346
346
 
347
- if (input === "" || input.toLowerCase() === "skip") {
347
+ if (input === '' || input.toLowerCase() === 'skip') {
348
348
  resolve([]);
349
- } else if (input.toLowerCase() === "all") {
349
+ } else if (input.toLowerCase() === 'all') {
350
350
  resolve(scanResults.unavailable);
351
351
  } else {
352
352
  const numbers = input.split(/\s+/).map((n) => parseInt(n) - 1);
@@ -361,12 +361,12 @@ class StigmergyInstaller {
361
361
 
362
362
  async installTools(toolKeys) {
363
363
  if (toolKeys.length === 0) {
364
- console.log("[SKIP] Skipping CLI tool installation.");
364
+ console.log('[SKIP] Skipping CLI tool installation.');
365
365
  return;
366
366
  }
367
367
 
368
368
  console.log(`\n[INSTALL] Installing ${toolKeys.length} AI CLI tools...`);
369
- console.log("=".repeat(60));
369
+ console.log('='.repeat(60));
370
370
 
371
371
  for (const toolKey of toolKeys) {
372
372
  const tool = CLI_TOOLS[toolKey];
@@ -374,16 +374,16 @@ class StigmergyInstaller {
374
374
 
375
375
  try {
376
376
  const packageInstall = spawn(
377
- "npm",
378
- ["install", "-g"].concat(tool.install.split(" ").slice(3)),
377
+ 'npm',
378
+ ['install', '-g'].concat(tool.install.split(' ').slice(3)),
379
379
  {
380
- stdio: "inherit",
380
+ stdio: 'inherit',
381
381
  shell: true,
382
382
  },
383
383
  );
384
384
 
385
385
  await new Promise((resolve, reject) => {
386
- packageInstall.on("close", (code) => {
386
+ packageInstall.on('close', (code) => {
387
387
  if (code === 0) {
388
388
  console.log(`[OK] ${tool.name} installed successfully!`);
389
389
  resolve();
@@ -398,12 +398,12 @@ class StigmergyInstaller {
398
398
  }
399
399
  }
400
400
 
401
- console.log("\n[VERIFY] CLI Installation completed! Verifying...");
401
+ console.log('\n[VERIFY] CLI Installation completed! Verifying...');
402
402
  await this.verifyInstallation(toolKeys);
403
403
  }
404
404
 
405
405
  async verifyInstallation(toolKeys) {
406
- console.log("=".repeat(60));
406
+ console.log('='.repeat(60));
407
407
  let successCount = 0;
408
408
 
409
409
  for (const toolKey of toolKeys) {
@@ -423,20 +423,20 @@ class StigmergyInstaller {
423
423
  );
424
424
 
425
425
  if (successCount === toolKeys.length) {
426
- console.log("[SUCCESS] All selected CLI tools are now ready to use!");
426
+ console.log('[SUCCESS] All selected CLI tools are now ready to use!');
427
427
  }
428
428
  }
429
429
 
430
430
  async deployHooks(availableTools) {
431
431
  if (availableTools.length === 0) {
432
- console.log("[SKIP] No CLI tools available for hook deployment.");
432
+ console.log('[SKIP] No CLI tools available for hook deployment.');
433
433
  return;
434
434
  }
435
435
 
436
436
  console.log(
437
437
  `\n[DEPLOY] Deploying Stigmergy hooks to ${availableTools.length} CLI tools...`,
438
438
  );
439
- console.log("=".repeat(60));
439
+ console.log('='.repeat(60));
440
440
 
441
441
  const hookTemplate = `#!/usr/bin/env node
442
442
 
@@ -519,13 +519,13 @@ const hook = new StigmergyHook();
519
519
 
520
520
  await this.ensureDirectory(hooksDir);
521
521
 
522
- const hookFile = path.join(hooksDir, "stigmergy-hook.cjs");
522
+ const hookFile = path.join(hooksDir, 'stigmergy-hook.cjs');
523
523
  try {
524
- await fs.writeFile(hookFile, hookTemplate, "utf8");
524
+ await fs.writeFile(hookFile, hookTemplate, 'utf8');
525
525
 
526
- if (process.platform !== "win32") {
527
- const { spawn } = require("child_process");
528
- spawn("chmod", ["+x", hookFile], { stdio: "ignore" });
526
+ if (process.platform !== 'win32') {
527
+ const { spawn } = require('child_process');
528
+ spawn('chmod', ['+x', hookFile], { stdio: 'ignore' });
529
529
  }
530
530
 
531
531
  console.log(`[OK] ${tool.name}: Hook deployed to ${hooksDir}`);
@@ -538,17 +538,17 @@ const hook = new StigmergyHook();
538
538
  }
539
539
 
540
540
  console.log(
541
- "\n[RESULT] Hook Deployment Result: " +
541
+ '\n[RESULT] Hook Deployment Result: ' +
542
542
  deployedCount +
543
- "/" +
543
+ '/' +
544
544
  availableTools.length +
545
- " hooks deployed",
545
+ ' hooks deployed',
546
546
  );
547
547
  }
548
548
 
549
549
  async removeHooks() {
550
- console.log("\n[REMOVE] Removing Stigmergy hooks from CLI tools...");
551
- console.log("=".repeat(60));
550
+ console.log('\n[REMOVE] Removing Stigmergy hooks from CLI tools...');
551
+ console.log('='.repeat(60));
552
552
 
553
553
  let removedCount = 0;
554
554
  let errorCount = 0;
@@ -559,7 +559,7 @@ const hook = new StigmergyHook();
559
559
 
560
560
  try {
561
561
  // Remove the stigmergy hook file
562
- const hookFile = path.join(toolInfo.hooksDir, "stigmergy-hook.cjs");
562
+ const hookFile = path.join(toolInfo.hooksDir, 'stigmergy-hook.cjs');
563
563
 
564
564
  // Check if the hook file exists
565
565
  try {
@@ -601,29 +601,29 @@ const hook = new StigmergyHook();
601
601
  }
602
602
 
603
603
  console.log(
604
- "\n[RESULT] Hook Removal Result: " +
604
+ '\n[RESULT] Hook Removal Result: ' +
605
605
  removedCount +
606
- " hooks removed, " +
606
+ ' hooks removed, ' +
607
607
  errorCount +
608
- " errors",
608
+ ' errors',
609
609
  );
610
- console.log("[SUCCESS] Stigmergy hooks removal completed!");
610
+ console.log('[SUCCESS] Stigmergy hooks removal completed!');
611
611
 
612
612
  // Also remove global configuration
613
613
  try {
614
- const configPath = path.join(this.stigmergyDir, "config.json");
614
+ const configPath = path.join(this.stigmergyDir, 'config.json');
615
615
  await fs.unlink(configPath);
616
- console.log("[OK] Removed global configuration file");
616
+ console.log('[OK] Removed global configuration file');
617
617
  } catch (error) {
618
618
  console.log(
619
- "[INFO] Global configuration file not found or already removed",
619
+ '[INFO] Global configuration file not found or already removed',
620
620
  );
621
621
  }
622
622
 
623
- console.log("\n[NEXT] To completely uninstall Stigmergy:");
624
- console.log(" 1. Run: npm uninstall -g stigmergy");
623
+ console.log('\n[NEXT] To completely uninstall Stigmergy:');
624
+ console.log(' 1. Run: npm uninstall -g stigmergy');
625
625
  console.log(
626
- " 2. Manually check and clean up any remaining files if needed",
626
+ ' 2. Manually check and clean up any remaining files if needed',
627
627
  );
628
628
  }
629
629
 
@@ -631,7 +631,7 @@ const hook = new StigmergyHook();
631
631
  await this.ensureDirectory(this.stigmergyDir);
632
632
 
633
633
  const globalConfig = {
634
- version: "1.0.77",
634
+ version: '1.0.77',
635
635
  installed: new Date().toISOString(),
636
636
  projectPath: this.projectDir,
637
637
  availableTools: availableTools,
@@ -639,36 +639,36 @@ const hook = new StigmergyHook();
639
639
  collaboration: {
640
640
  enabled: true,
641
641
  protocols: [
642
- "Use {cli} to {task}",
643
- "Call {cli} to {task}",
644
- "Ask {cli} for {task}",
645
- "Get {cli} to {task}",
646
- "Have {cli} {task}",
642
+ 'Use {cli} to {task}',
643
+ 'Call {cli} to {task}',
644
+ 'Ask {cli} for {task}',
645
+ 'Get {cli} to {task}',
646
+ 'Have {cli} {task}',
647
647
  ],
648
648
  examples: [
649
- "Use claude to help debug this code",
650
- "Call gemini to analyze the file",
651
- "Ask qwen to translate this text",
649
+ 'Use claude to help debug this code',
650
+ 'Call gemini to analyze the file',
651
+ 'Ask qwen to translate this text',
652
652
  ],
653
653
  },
654
654
  };
655
655
 
656
- const configPath = path.join(this.stigmergyDir, "config.json");
656
+ const configPath = path.join(this.stigmergyDir, 'config.json');
657
657
  try {
658
658
  await fs.writeFile(configPath, JSON.stringify(globalConfig, null, 2));
659
- console.log("[CONFIG] Global configuration saved to:", configPath);
659
+ console.log('[CONFIG] Global configuration saved to:', configPath);
660
660
  } catch (error) {
661
- console.log("[WARN] Warning: Could not save global configuration");
661
+ console.log('[WARN] Warning: Could not save global configuration');
662
662
  }
663
663
 
664
- const projectDocs = path.join(this.projectDir, "STIGMERGY.md");
664
+ const projectDocs = path.join(this.projectDir, 'STIGMERGY.md');
665
665
  const docsTemplate = `# Stigmergy Multi-AI CLI Collaboration
666
666
 
667
667
  This project is configured for Stigmergy-based multi-AI CLI collaboration.
668
668
 
669
669
  ## Available AI CLI Tools
670
670
 
671
- ${availableTools.map((tool) => `- **${CLI_TOOLS[tool].name}**: \`stigmergy call ${tool}\``).join("\n")}
671
+ ${availableTools.map((tool) => `- **${CLI_TOOLS[tool].name}**: \`stigmergy call ${tool}\``).join('\n')}
672
672
 
673
673
  ## Usage Examples
674
674
 
@@ -707,42 +707,42 @@ For more information: https://github.com/ptreezh/stigmergy-CLI-Multi-Agents
707
707
  `;
708
708
 
709
709
  try {
710
- await fs.writeFile(projectDocs, docsTemplate, "utf8");
711
- console.log("[DOCS] Project documentation created: STIGMERGY.md");
710
+ await fs.writeFile(projectDocs, docsTemplate, 'utf8');
711
+ console.log('[DOCS] Project documentation created: STIGMERGY.md');
712
712
  } catch (error) {
713
- console.log("[WARN] Warning: Could not create project documentation");
713
+ console.log('[WARN] Warning: Could not create project documentation');
714
714
  }
715
715
  }
716
716
 
717
717
  async showUsageInstructions() {
718
- console.log("\n" + "=".repeat(60));
719
- console.log("[SUCCESS] Stigmergy Installation and Deployment Complete!");
720
- console.log("=".repeat(60));
721
- console.log("");
722
- console.log("[NEXT] Next Steps:");
723
- console.log("");
724
- console.log("1. Verify Installation:");
725
- console.log(" stigmergy status");
726
- console.log("");
727
- console.log("2. Check Available Tools:");
728
- console.log(" stigmergy scan");
729
- console.log("");
730
- console.log("3. Start Using AI CLI Collaboration:");
718
+ console.log('\n' + '='.repeat(60));
719
+ console.log('[SUCCESS] Stigmergy Installation and Deployment Complete!');
720
+ console.log('='.repeat(60));
721
+ console.log('');
722
+ console.log('[NEXT] Next Steps:');
723
+ console.log('');
724
+ console.log('1. Verify Installation:');
725
+ console.log(' stigmergy status');
726
+ console.log('');
727
+ console.log('2. Check Available Tools:');
728
+ console.log(' stigmergy scan');
729
+ console.log('');
730
+ console.log('3. Start Using AI CLI Collaboration:');
731
731
  console.log(' stigmergy call claude "help me debug this code"');
732
732
  console.log(' stigmergy call gemini "generate documentation"');
733
733
  console.log(' stigmergy call qwen "translate to English"');
734
- console.log("");
735
- console.log("4. Initialize New Projects:");
736
- console.log(" stigmergy init --primary claude");
737
- console.log("");
738
- console.log("[INFO] Documentation:");
739
- console.log(" - Global Config: ~/.stigmergy/config.json");
740
- console.log(" - Project Docs: ./STIGMERGY.md");
734
+ console.log('');
735
+ console.log('4. Initialize New Projects:');
736
+ console.log(' stigmergy init --primary claude');
737
+ console.log('');
738
+ console.log('[INFO] Documentation:');
739
+ console.log(' - Global Config: ~/.stigmergy/config.json');
740
+ console.log(' - Project Docs: ./STIGMERGY.md');
741
741
  console.log(
742
- " - GitHub: https://github.com/ptreezh/stigmergy-CLI-Multi-Agents",
742
+ ' - GitHub: https://github.com/ptreezh/stigmergy-CLI-Multi-Agents',
743
743
  );
744
- console.log("");
745
- console.log("[END] Happy collaborating with multiple AI CLI tools!");
744
+ console.log('');
745
+ console.log('[END] Happy collaborating with multiple AI CLI tools!');
746
746
  }
747
747
  }
748
748
 
@@ -751,62 +751,62 @@ async function main() {
751
751
  const args = process.argv.slice(2);
752
752
  const installer = new StigmergyInstaller();
753
753
 
754
- if (args.length === 0 || args.includes("--help") || args.includes("-h")) {
754
+ if (args.length === 0 || args.includes('--help') || args.includes('-h')) {
755
755
  console.log(
756
- "Stigmergy CLI - Multi-Agents Cross-AI CLI Tools Collaboration System",
756
+ 'Stigmergy CLI - Multi-Agents Cross-AI CLI Tools Collaboration System',
757
757
  );
758
- console.log("Version: 1.0.78");
759
- console.log("");
760
- console.log("[SYSTEM] Automated Installation and Deployment System");
761
- console.log("");
762
- console.log("Usage: stigmergy [command] [options]");
763
- console.log("");
764
- console.log("Commands:");
765
- console.log(" help, --help Show this help message");
766
- console.log(" version, --version Show version information");
767
- console.log(" status Check CLI tools status");
768
- console.log(" scan Scan for available AI CLI tools");
769
- console.log(" install Auto-install missing CLI tools");
770
- console.log(" deploy Deploy hooks to installed tools");
758
+ console.log('Version: 1.0.78');
759
+ console.log('');
760
+ console.log('[SYSTEM] Automated Installation and Deployment System');
761
+ console.log('');
762
+ console.log('Usage: stigmergy [command] [options]');
763
+ console.log('');
764
+ console.log('Commands:');
765
+ console.log(' help, --help Show this help message');
766
+ console.log(' version, --version Show version information');
767
+ console.log(' status Check CLI tools status');
768
+ console.log(' scan Scan for available AI CLI tools');
769
+ console.log(' install Auto-install missing CLI tools');
770
+ console.log(' deploy Deploy hooks to installed tools');
771
771
  console.log(
772
- " remove Remove all Stigmergy hooks from installed tools",
772
+ ' remove Remove all Stigmergy hooks from installed tools',
773
773
  );
774
- console.log(" setup Complete setup and configuration");
774
+ console.log(' setup Complete setup and configuration');
775
775
  console.log(
776
- " call <tool> Execute prompt with specified or auto-routed AI CLI",
776
+ ' call <tool> Execute prompt with specified or auto-routed AI CLI',
777
777
  );
778
- console.log("");
779
- console.log("[WORKFLOW] Automated Workflow:");
780
- console.log(" 1. npm install -g stigmergy # Install Stigmergy");
778
+ console.log('');
779
+ console.log('[WORKFLOW] Automated Workflow:');
780
+ console.log(' 1. npm install -g stigmergy # Install Stigmergy');
781
781
  console.log(
782
- " 2. stigmergy install # Auto-scan & install CLI tools",
782
+ ' 2. stigmergy install # Auto-scan & install CLI tools',
783
783
  );
784
- console.log(" 3. stigmergy setup # Deploy hooks & config");
785
- console.log(" 4. stigmergy call <ai> <prompt> # Start collaborating");
786
- console.log("");
784
+ console.log(' 3. stigmergy setup # Deploy hooks & config');
785
+ console.log(' 4. stigmergy call <ai> <prompt> # Start collaborating');
786
+ console.log('');
787
787
  console.log(
788
- "For more information, visit: https://github.com/ptreezh/stigmergy-CLI-Multi-Agents",
788
+ 'For more information, visit: https://github.com/ptreezh/stigmergy-CLI-Multi-Agents',
789
789
  );
790
790
  return;
791
791
  }
792
792
 
793
- if (args.includes("--version") || args.includes("version")) {
794
- console.log("1.0.77");
793
+ if (args.includes('--version') || args.includes('version')) {
794
+ console.log('1.0.77');
795
795
  return;
796
796
  }
797
797
 
798
798
  // Auto-install mode for postinstall script
799
- if (args.includes("auto-install")) {
799
+ if (args.includes('auto-install')) {
800
800
  console.log(
801
- "[AUTO-INSTALL] Stigmergy CLI - Automated Installation and Deployment",
801
+ '[AUTO-INSTALL] Stigmergy CLI - Automated Installation and Deployment',
802
802
  );
803
- console.log("Multi-AI CLI Tools Collaboration System v1.0.77");
804
- console.log("=".repeat(60));
803
+ console.log('Multi-AI CLI Tools Collaboration System v1.0.77');
804
+ console.log('='.repeat(60));
805
805
 
806
- const originalPrompt = installer.promptForInstallation;
806
+ const _ = installer.promptForInstallation;
807
807
  installer.promptForInstallation = async () => {
808
808
  console.log(
809
- "[AUTO-INSTALL] Skipping interactive CLI installation in postinstall mode",
809
+ '[AUTO-INSTALL] Skipping interactive CLI installation in postinstall mode',
810
810
  );
811
811
  console.log(
812
812
  '[AUTO-INSTALL] You can run "stigmergy" manually to install CLI tools interactively',
@@ -814,16 +814,16 @@ async function main() {
814
814
  return [];
815
815
  };
816
816
 
817
- console.log("\n[STEP 1] Scanning for AI CLI tools...");
817
+ console.log('\n[STEP 1] Scanning for AI CLI tools...');
818
818
  const scanResults = await installer.scanAvailableTools();
819
819
 
820
- console.log("\n[STEP 2] Deploying Stigmergy hooks...");
820
+ console.log('\n[STEP 2] Deploying Stigmergy hooks...');
821
821
  await installer.deployHooks(scanResults.available);
822
822
 
823
- console.log("\n[STEP 3] Setting up configuration...");
823
+ console.log('\n[STEP 3] Setting up configuration...');
824
824
  await installer.setupGlobalConfiguration(scanResults.available);
825
825
 
826
- console.log("\n[AUTO-INSTALL] Stigmergy automated setup completed!");
826
+ console.log('\n[AUTO-INSTALL] Stigmergy automated setup completed!');
827
827
  console.log(
828
828
  '[AUTO-INSTALL] Run "stigmergy" to start interactive CLI tool installation',
829
829
  );
@@ -832,76 +832,76 @@ async function main() {
832
832
 
833
833
  // Define valid commands
834
834
  const validCommands = [
835
- "help",
836
- "--help",
837
- "-h",
838
- "version",
839
- "--version",
840
- "status",
841
- "scan",
842
- "install",
843
- "deploy",
844
- "remove",
845
- "setup",
846
- "auto-install",
847
- "call",
835
+ 'help',
836
+ '--help',
837
+ '-h',
838
+ 'version',
839
+ '--version',
840
+ 'status',
841
+ 'scan',
842
+ 'install',
843
+ 'deploy',
844
+ 'remove',
845
+ 'setup',
846
+ 'auto-install',
847
+ 'call',
848
848
  ];
849
849
 
850
850
  // Handle remove command
851
- if (args[0] === "remove") {
851
+ if (args[0] === 'remove') {
852
852
  console.log(
853
- "[REMOVE] Removing Stigmergy hooks from all installed CLI tools...",
853
+ '[REMOVE] Removing Stigmergy hooks from all installed CLI tools...',
854
854
  );
855
855
  await installer.removeHooks();
856
856
  return;
857
857
  }
858
858
 
859
859
  // Handle call command
860
- if (args[0] === "call") {
860
+ if (args[0] === 'call') {
861
861
  return await handleCallCommand(args.slice(1));
862
862
  }
863
863
 
864
864
  // Check for invalid commands
865
865
  const hasValidCommand = args.some((arg) => validCommands.includes(arg));
866
866
  if (!hasValidCommand && args.length > 0) {
867
- console.log("[ERROR] Invalid command:", args[0]);
868
- console.log("");
869
- console.log("Usage: stigmergy [command] [options]");
870
- console.log("");
871
- console.log("Available commands:");
872
- console.log(" help, --help Show this help message");
873
- console.log(" version, --version Show version information");
874
- console.log(" status Check CLI tools status");
875
- console.log(" scan Scan for available AI CLI tools");
876
- console.log(" install Auto-install missing CLI tools");
877
- console.log(" deploy Deploy hooks to installed tools");
878
- console.log(" setup Complete setup and configuration");
867
+ console.log('[ERROR] Invalid command:', args[0]);
868
+ console.log('');
869
+ console.log('Usage: stigmergy [command] [options]');
870
+ console.log('');
871
+ console.log('Available commands:');
872
+ console.log(' help, --help Show this help message');
873
+ console.log(' version, --version Show version information');
874
+ console.log(' status Check CLI tools status');
875
+ console.log(' scan Scan for available AI CLI tools');
876
+ console.log(' install Auto-install missing CLI tools');
877
+ console.log(' deploy Deploy hooks to installed tools');
878
+ console.log(' setup Complete setup and configuration');
879
879
  console.log(
880
- " call <tool> Execute prompt with specified or auto-routed AI CLI",
880
+ ' call <tool> Execute prompt with specified or auto-routed AI CLI',
881
881
  );
882
882
  console.log(
883
- " call <tool> Execute prompt with specified or auto-routed AI CLI",
883
+ ' call <tool> Execute prompt with specified or auto-routed AI CLI',
884
884
  );
885
- console.log("");
885
+ console.log('');
886
886
  console.log('Run "stigmergy --help" for more information.');
887
887
  process.exit(1);
888
888
  }
889
889
 
890
890
  // Start automated installation and deployment
891
- console.log("[START] Stigmergy CLI - Automated Installation and Deployment");
892
- console.log("Multi-AI CLI Tools Collaboration System v1.0.77");
893
- console.log("=".repeat(60));
891
+ console.log('[START] Stigmergy CLI - Automated Installation and Deployment');
892
+ console.log('Multi-AI CLI Tools Collaboration System v1.0.77');
893
+ console.log('='.repeat(60));
894
894
 
895
- console.log("\n[STEP 1] Scanning for AI CLI tools...");
895
+ console.log('\n[STEP 1] Scanning for AI CLI tools...');
896
896
  const scanResults = await installer.scanAvailableTools();
897
897
 
898
898
  if (scanResults.unavailable.length > 0) {
899
- console.log("\n[STEP 2] CLI Tool Installation");
899
+ console.log('\n[STEP 2] CLI Tool Installation');
900
900
  const selectedTools = await installer.promptForInstallation(scanResults);
901
901
  await installer.installTools(selectedTools);
902
902
 
903
903
  if (selectedTools.length > 0) {
904
- console.log("\n[RESCAN] Re-scanning after installation...");
904
+ console.log('\n[RESCAN] Re-scanning after installation...');
905
905
  scanResults.available = scanResults.available.concat(
906
906
  selectedTools.filter((tool) => installer.checkCLI(tool)),
907
907
  );
@@ -910,13 +910,13 @@ async function main() {
910
910
  );
911
911
  }
912
912
  } else {
913
- console.log("\n[STEP 2] All CLI tools already available!");
913
+ console.log('\n[STEP 2] All CLI tools already available!');
914
914
  }
915
915
 
916
- console.log("\n[STEP 3] Deploying Stigmergy hooks...");
916
+ console.log('\n[STEP 3] Deploying Stigmergy hooks...');
917
917
  await installer.deployHooks(scanResults.available);
918
918
 
919
- console.log("\n[STEP 4] Setting up configuration...");
919
+ console.log('\n[STEP 4] Setting up configuration...');
920
920
  await installer.setupGlobalConfiguration(scanResults.available);
921
921
 
922
922
  await installer.showUsageInstructions();
@@ -925,9 +925,9 @@ async function main() {
925
925
  // Memory Management System
926
926
  class MemoryManager {
927
927
  constructor(stigmergyDir) {
928
- this.memoryDir = path.join(stigmergyDir, "memory");
929
- this.globalMemoryFile = path.join(this.memoryDir, "global.json");
930
- this.projectMemoryFile = path.join(process.cwd(), ".stigmergy-memory.json");
928
+ this.memoryDir = path.join(stigmergyDir, 'memory');
929
+ this.globalMemoryFile = path.join(this.memoryDir, 'global.json');
930
+ this.projectMemoryFile = path.join(process.cwd(), '.stigmergy-memory.json');
931
931
  }
932
932
 
933
933
  async ensureDirectory() {
@@ -952,7 +952,7 @@ class MemoryManager {
952
952
  async loadGlobalMemory() {
953
953
  try {
954
954
  await this.ensureDirectory();
955
- const data = await fs.readFile(this.globalMemoryFile, "utf8");
955
+ const data = await fs.readFile(this.globalMemoryFile, 'utf8');
956
956
  return JSON.parse(data);
957
957
  } catch (error) {
958
958
  return {};
@@ -977,7 +977,7 @@ class MemoryManager {
977
977
 
978
978
  async loadProjectMemory() {
979
979
  try {
980
- const data = await fs.readFile(this.projectMemoryFile, "utf8");
980
+ const data = await fs.readFile(this.projectMemoryFile, 'utf8');
981
981
  return JSON.parse(data);
982
982
  } catch (error) {
983
983
  return {
@@ -1010,16 +1010,16 @@ class MemoryManager {
1010
1010
  async function handleCallCommand(args) {
1011
1011
  const router = new SmartRouter();
1012
1012
  const memoryManager = new MemoryManager(
1013
- path.join(os.homedir(), ".stigmergy"),
1013
+ path.join(os.homedir(), '.stigmergy'),
1014
1014
  );
1015
1015
 
1016
1016
  if (args.length === 0) {
1017
- console.log("[ERROR] Call command requires a tool name and/or prompt");
1018
- console.log("");
1019
- console.log("Usage: stigmergy call <tool> <prompt>");
1020
- console.log(" stigmergy call <prompt> (auto-route to best tool)");
1021
- console.log("");
1022
- console.log("Available tools:", Object.keys(CLI_TOOLS).join(", "));
1017
+ console.log('[ERROR] Call command requires a tool name and/or prompt');
1018
+ console.log('');
1019
+ console.log('Usage: stigmergy call <tool> <prompt>');
1020
+ console.log(' stigmergy call <prompt> (auto-route to best tool)');
1021
+ console.log('');
1022
+ console.log('Available tools:', Object.keys(CLI_TOOLS).join(', '));
1023
1023
  return;
1024
1024
  }
1025
1025
 
@@ -1028,29 +1028,29 @@ async function handleCallCommand(args) {
1028
1028
  // Check if first argument is a valid tool
1029
1029
  if (CLI_TOOLS[args[0]]) {
1030
1030
  toolName = args[0];
1031
- prompt = args.slice(1).join(" ");
1031
+ prompt = args.slice(1).join(' ');
1032
1032
  } else {
1033
1033
  // Auto-route based on keywords
1034
- const routeResult = router.smartRoute(args.join(" "));
1034
+ const routeResult = router.smartRoute(args.join(' '));
1035
1035
  toolName = routeResult.tool;
1036
- prompt = routeResult.prompt || args.join(" ");
1036
+ prompt = routeResult.prompt || args.join(' ');
1037
1037
  }
1038
1038
 
1039
1039
  if (!prompt) {
1040
- console.log("[ERROR] Prompt is required");
1040
+ console.log('[ERROR] Prompt is required');
1041
1041
  return;
1042
1042
  }
1043
1043
 
1044
1044
  console.log(`[CALL] Routing to: ${CLI_TOOLS[toolName].name}`);
1045
1045
  console.log(`[PROMPT] ${prompt}`);
1046
- console.log("=".repeat(60));
1046
+ console.log('='.repeat(60));
1047
1047
 
1048
1048
  const result = await router.executeTool(toolName, prompt);
1049
1049
 
1050
1050
  if (result.success) {
1051
- console.log("[SUCCESS] Execution completed");
1051
+ console.log('[SUCCESS] Execution completed');
1052
1052
  if (result.output) {
1053
- console.log("[OUTPUT]");
1053
+ console.log('[OUTPUT]');
1054
1054
  console.log(result.output);
1055
1055
  }
1056
1056
 
@@ -1058,36 +1058,36 @@ async function handleCallCommand(args) {
1058
1058
  await memoryManager.addInteraction(
1059
1059
  toolName,
1060
1060
  prompt,
1061
- result.output || "Success",
1061
+ result.output || 'Success',
1062
1062
  );
1063
- console.log(`[MEMORY] Interaction saved to project memory`);
1063
+ console.log('[MEMORY] Interaction saved to project memory');
1064
1064
  } else {
1065
- console.log("[ERROR] Execution failed");
1065
+ console.log('[ERROR] Execution failed');
1066
1066
  if (result.error) {
1067
- console.log("[ERROR]", result.error);
1067
+ console.log('[ERROR]', result.error);
1068
1068
  }
1069
1069
 
1070
1070
  // Save failed interaction to memory
1071
1071
  await memoryManager.addInteraction(
1072
1072
  toolName,
1073
1073
  prompt,
1074
- result.error || "Failed",
1074
+ result.error || 'Failed',
1075
1075
  );
1076
1076
  }
1077
1077
 
1078
- console.log("");
1079
- console.log("[INFO] For help with CLI usage: stigmergy help");
1078
+ console.log('');
1079
+ console.log('[INFO] For help with CLI usage: stigmergy help');
1080
1080
  }
1081
1081
 
1082
1082
  // Setup stdin for interactive prompts
1083
1083
  if (require.main === module) {
1084
1084
  if (process.stdin.isTTY) {
1085
1085
  process.stdin.resume();
1086
- process.stdin.setEncoding("utf8");
1086
+ process.stdin.setEncoding('utf8');
1087
1087
  }
1088
1088
 
1089
1089
  main().catch((error) => {
1090
- console.error("[ERROR] Error:", error.message);
1090
+ console.error('[ERROR] Error:', error.message);
1091
1091
  process.exit(1);
1092
1092
  });
1093
1093
  }
@@ -1098,4 +1098,4 @@ module.exports = {
1098
1098
  CLI_TOOLS,
1099
1099
  SmartRouter,
1100
1100
  MemoryManager,
1101
- };
1101
+ };