stigmergy 1.2.12 → 1.3.1-beta

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 (84) hide show
  1. package/README.md +39 -3
  2. package/STIGMERGY.md +3 -0
  3. package/config/builtin-skills.json +43 -0
  4. package/config/enhanced-cli-config.json +438 -0
  5. package/docs/CLI_TOOLS_AGENT_SKILL_ANALYSIS.md +463 -0
  6. package/docs/DESIGN_CLI_HELP_ANALYZER_REFACTOR.md +726 -0
  7. package/docs/ENHANCED_CLI_AGENT_SKILL_CONFIG.md +285 -0
  8. package/docs/IMPLEMENTATION_CHECKLIST_CLI_HELP_ANALYZER_REFACTOR.md +1268 -0
  9. package/docs/INSTALLER_ARCHITECTURE.md +257 -0
  10. package/docs/LESSONS_LEARNED.md +252 -0
  11. package/docs/SPECS_CLI_HELP_ANALYZER_REFACTOR.md +287 -0
  12. package/docs/SUDO_PROBLEM_AND_SOLUTION.md +529 -0
  13. package/docs/correct-skillsio-implementation.md +368 -0
  14. package/docs/development_guidelines.md +276 -0
  15. package/docs/independent-resume-implementation.md +198 -0
  16. package/docs/resumesession-final-implementation.md +195 -0
  17. package/docs/resumesession-usage.md +87 -0
  18. package/package.json +19 -9
  19. package/scripts/analyze-router.js +168 -0
  20. package/scripts/run-comprehensive-tests.js +230 -0
  21. package/scripts/run-quick-tests.js +90 -0
  22. package/scripts/test-runner.js +344 -0
  23. package/skills/resumesession/INDEPENDENT_SKILL.md +171 -0
  24. package/skills/resumesession/SKILL.md +127 -0
  25. package/skills/resumesession/__init__.py +33 -0
  26. package/skills/resumesession/implementations/simple-resume.js +13 -0
  27. package/src/adapters/claude/install_claude_integration.js +9 -1
  28. package/src/adapters/codebuddy/install_codebuddy_integration.js +3 -1
  29. package/src/adapters/codex/install_codex_integration.js +15 -5
  30. package/src/adapters/gemini/install_gemini_integration.js +3 -1
  31. package/src/adapters/qwen/install_qwen_integration.js +3 -1
  32. package/src/cli/commands/autoinstall.js +65 -0
  33. package/src/cli/commands/errors.js +190 -0
  34. package/src/cli/commands/independent-resume.js +395 -0
  35. package/src/cli/commands/install.js +179 -0
  36. package/src/cli/commands/permissions.js +108 -0
  37. package/src/cli/commands/project.js +485 -0
  38. package/src/cli/commands/scan.js +97 -0
  39. package/src/cli/commands/simple-resume.js +377 -0
  40. package/src/cli/commands/skills.js +158 -0
  41. package/src/cli/commands/status.js +113 -0
  42. package/src/cli/commands/stigmergy-resume.js +775 -0
  43. package/src/cli/commands/system.js +301 -0
  44. package/src/cli/commands/universal-resume.js +394 -0
  45. package/src/cli/router-beta.js +471 -0
  46. package/src/cli/utils/environment.js +75 -0
  47. package/src/cli/utils/formatters.js +47 -0
  48. package/src/cli/utils/skills_cache.js +92 -0
  49. package/src/core/cache_cleaner.js +1 -0
  50. package/src/core/cli_adapters.js +345 -0
  51. package/src/core/cli_help_analyzer.js +582 -26
  52. package/src/core/cli_path_detector.js +702 -709
  53. package/src/core/cli_tools.js +515 -160
  54. package/src/core/coordination/nodejs/CLIIntegrationManager.js +18 -0
  55. package/src/core/coordination/nodejs/HookDeploymentManager.js +242 -412
  56. package/src/core/coordination/nodejs/HookDeploymentManager.refactored.js +323 -0
  57. package/src/core/coordination/nodejs/generators/CLIAdapterGenerator.js +363 -0
  58. package/src/core/coordination/nodejs/generators/ResumeSessionGenerator.js +932 -0
  59. package/src/core/coordination/nodejs/generators/SkillsIntegrationGenerator.js +1395 -0
  60. package/src/core/coordination/nodejs/generators/index.js +12 -0
  61. package/src/core/enhanced_cli_installer.js +1208 -608
  62. package/src/core/enhanced_cli_parameter_handler.js +402 -0
  63. package/src/core/execution_mode_detector.js +222 -0
  64. package/src/core/installer.js +151 -106
  65. package/src/core/local_skill_scanner.js +732 -0
  66. package/src/core/multilingual/language-pattern-manager.js +1 -1
  67. package/src/core/skills/BuiltinSkillsDeployer.js +188 -0
  68. package/src/core/skills/StigmergySkillManager.js +123 -16
  69. package/src/core/skills/embedded-openskills/SkillParser.js +7 -3
  70. package/src/core/smart_router.js +291 -2
  71. package/src/index.js +10 -4
  72. package/src/utils.js +66 -7
  73. package/test/cli-integration.test.js +304 -0
  74. package/test/direct_smart_router_test.js +88 -0
  75. package/test/enhanced-cli-agent-skill-test.js +485 -0
  76. package/test/simple_test.js +82 -0
  77. package/test/smart_router_test_runner.js +123 -0
  78. package/test/smart_routing_edge_cases.test.js +284 -0
  79. package/test/smart_routing_simple_verification.js +139 -0
  80. package/test/smart_routing_verification.test.js +346 -0
  81. package/test/specific-cli-agent-skill-analysis.js +385 -0
  82. package/test/unit/smart_router.test.js +295 -0
  83. package/test/very_simple_test.js +54 -0
  84. package/src/cli/router.js +0 -1737
@@ -46,7 +46,9 @@ class ClaudeInstaller {
46
46
  timeout: 30,
47
47
  collaboration_mode: 'active',
48
48
  claude_skills_integration: true,
49
- claude_hooks_enabled: true
49
+ claude_hooks_enabled: true,
50
+ resumesession_enabled: true,
51
+ resumesession_integration: true
50
52
  };
51
53
 
52
54
  // Merge configs
@@ -85,6 +87,12 @@ class ClaudeInstaller {
85
87
  enabled: true,
86
88
  auto_register: true,
87
89
  cross_cli_aware: true
90
+ },
91
+ resumesession: {
92
+ enabled: true,
93
+ command: '/stigmergy-resume',
94
+ description: 'Resume or query session history across CLIs',
95
+ version: '1.0.4'
88
96
  }
89
97
  };
90
98
 
@@ -68,7 +68,9 @@ class CodeBuddyIntegrationInstaller {
68
68
  supported_clis: ['claude', 'gemini', 'qwen', 'iflow', 'qoder', 'copilot'],
69
69
  auto_route: true,
70
70
  timeout: 30,
71
- collaboration_mode: 'active'
71
+ collaboration_mode: 'active',
72
+ resumesession_enabled: true,
73
+ resumesession_integration: true
72
74
  }
73
75
  }
74
76
  };
@@ -60,7 +60,9 @@ class CodexIntegrationInstaller {
60
60
  module: 'src.core.enhanced_init_processor',
61
61
  enabled: true,
62
62
  cross_cli_enabled: true,
63
- supported_clis: ['claude', 'gemini', 'qwen', 'iflow', 'qoder', 'codebuddy', 'copilot']
63
+ supported_clis: ['claude', 'gemini', 'qwen', 'iflow', 'qoder', 'codebuddy', 'copilot'],
64
+ resumesession_enabled: true,
65
+ resumesession_integration: true
64
66
  },
65
67
  scan: {
66
68
  command: 'scan',
@@ -68,7 +70,9 @@ class CodexIntegrationInstaller {
68
70
  module: 'src.core.ai_environment_scanner',
69
71
  enabled: true,
70
72
  cross_cli_enabled: true,
71
- supported_clis: ['claude', 'gemini', 'qwen', 'iflow', 'qoder', 'codebuddy', 'copilot']
73
+ supported_clis: ['claude', 'gemini', 'qwen', 'iflow', 'qoder', 'codebuddy', 'copilot'],
74
+ resumesession_enabled: true,
75
+ resumesession_integration: true
72
76
  },
73
77
  status: {
74
78
  command: 'status',
@@ -76,7 +80,9 @@ class CodexIntegrationInstaller {
76
80
  module: 'src.core.cli_hook_integration',
77
81
  enabled: true,
78
82
  cross_cli_enabled: true,
79
- supported_clis: ['claude', 'gemini', 'qwen', 'iflow', 'qoder', 'codebuddy', 'copilot']
83
+ supported_clis: ['claude', 'gemini', 'qwen', 'iflow', 'qoder', 'codebuddy', 'copilot'],
84
+ resumesession_enabled: true,
85
+ resumesession_integration: true
80
86
  },
81
87
  deploy: {
82
88
  command: 'deploy',
@@ -84,7 +90,9 @@ class CodexIntegrationInstaller {
84
90
  module: 'src.core.cli_hook_integration',
85
91
  enabled: true,
86
92
  cross_cli_enabled: true,
87
- supported_clis: ['claude', 'gemini', 'qwen', 'iflow', 'qoder', 'codebuddy', 'copilot']
93
+ supported_clis: ['claude', 'gemini', 'qwen', 'iflow', 'qoder', 'codebuddy', 'copilot'],
94
+ resumesession_enabled: true,
95
+ resumesession_integration: true
88
96
  },
89
97
  call: {
90
98
  command: 'call',
@@ -92,7 +100,9 @@ class CodexIntegrationInstaller {
92
100
  module: 'src.core.cli_hook_integration',
93
101
  enabled: true,
94
102
  cross_cli_enabled: true,
95
- supported_clis: ['claude', 'gemini', 'qwen', 'iflow', 'qoder', 'codebuddy', 'copilot']
103
+ supported_clis: ['claude', 'gemini', 'qwen', 'iflow', 'qoder', 'codebuddy', 'copilot'],
104
+ resumesession_enabled: true,
105
+ resumesession_integration: true
96
106
  }
97
107
  };
98
108
 
@@ -63,7 +63,9 @@ class GeminiIntegrationInstaller {
63
63
  auto_detect: true,
64
64
  timeout: 30,
65
65
  error_handling: 'continue',
66
- collaboration_mode: 'active'
66
+ collaboration_mode: 'active',
67
+ resumesession_enabled: true,
68
+ resumesession_integration: true
67
69
  }
68
70
  },
69
71
  cross_cli_response_processor: {
@@ -45,7 +45,9 @@ class QwenInstaller {
45
45
  auto_detect: true,
46
46
  timeout: 30,
47
47
  collaboration_mode: 'active',
48
- qwen_oauth_integration: true
48
+ qwen_oauth_integration: true,
49
+ resumesession_enabled: true,
50
+ resumesession_integration: true
49
51
  };
50
52
 
51
53
  // Merge configs
@@ -0,0 +1,65 @@
1
+ import chalk from 'chalk';
2
+ import { handleInstallCommand } from './install.js';
3
+ import { handleDeployCommand } from './project.js';
4
+ import BuiltinSkillsDeployer from '../../core/skills/BuiltinSkillsDeployer.js';
5
+
6
+ export async function handleAutoInstallCommand(options) {
7
+ console.log(chalk.blue('šŸš€ Stigmergy Auto-Installation'));
8
+ console.log(chalk.gray('=====================================\n'));
9
+
10
+ // Step 1: Install CLI tools
11
+ console.log(chalk.blue('šŸ“¦ Step 1/3: Installing CLI tools...'));
12
+
13
+ try {
14
+ await handleInstallCommand({
15
+ verbose: options.verbose || process.env.DEBUG === 'true',
16
+ force: options.force || false
17
+ });
18
+ } catch (error) {
19
+ console.error(chalk.red('āœ— CLI tools installation failed:'), error.message);
20
+ // Continue with next step even if CLI tools installation fails
21
+ }
22
+
23
+ // Step 2: Deploy hooks and ResumeSession
24
+ console.log(chalk.blue('\nšŸš€ Step 2/3: Deploying hooks and ResumeSession integration...'));
25
+
26
+ try {
27
+ const deployResult = await handleDeployCommand({
28
+ verbose: options.verbose || process.env.DEBUG === 'true',
29
+ force: options.force || false
30
+ });
31
+
32
+ if (deployResult.success) {
33
+ console.log(chalk.green('āœ“ Hooks deployed successfully'));
34
+ } else {
35
+ console.warn(chalk.yellow('⚠ Hooks deployment completed with warnings'));
36
+ }
37
+ } catch (error) {
38
+ console.error(chalk.red('āœ— Hooks deployment failed:'), error.message);
39
+ // Continue with next step even if hooks deployment fails
40
+ }
41
+
42
+ // Step 3: Deploy built-in skills
43
+ console.log(chalk.blue('\nšŸš€ Step 3/3: Deploying built-in skills...'));
44
+
45
+ try {
46
+ const skillsDeployer = new BuiltinSkillsDeployer();
47
+ const skillsResult = await skillsDeployer.deployAll();
48
+
49
+ if (skillsResult.success) {
50
+ console.log(chalk.green('āœ“ Built-in skills deployed successfully'));
51
+ } else {
52
+ console.warn(chalk.yellow('⚠ Built-in skills deployment completed with warnings'));
53
+ }
54
+ } catch (error) {
55
+ console.error(chalk.red('āœ— Built-in skills deployment failed:'), error.message);
56
+ // Continue even if skills deployment fails
57
+ }
58
+
59
+ console.log(chalk.green('\nšŸŽ‰ Auto-installation completed successfully!'));
60
+ console.log(chalk.cyan('\nNext steps:'));
61
+ console.log(' • Run: stigmergy --help');
62
+ console.log(' • Try: stigmergy claude "Hello World"');
63
+ console.log(' • Check: stigmergy status');
64
+ console.log(' • Resume sessions: stigmergy resume --limit 10');
65
+ }
@@ -0,0 +1,190 @@
1
+ /**
2
+ * Error Reporting Commands
3
+ * Modular implementation for error reporting and system troubleshooting
4
+ */
5
+
6
+ const chalk = require('chalk');
7
+ const { errorHandler } = require('../../core/error_handler');
8
+ const fs = require('fs').promises;
9
+ const path = require('path');
10
+ const os = require('os');
11
+
12
+ /**
13
+ * Handle errors command - Generate comprehensive error report
14
+ * @param {Object} options - Command options
15
+ */
16
+ async function handleErrorsCommand(options = {}) {
17
+ try {
18
+ console.log(chalk.cyan('[ERRORS] Generating Stigmergy CLI error report...\n'));
19
+
20
+ const report = {
21
+ timestamp: new Date().toISOString(),
22
+ system: {},
23
+ environment: {},
24
+ errors: [],
25
+ diagnostics: {}
26
+ };
27
+
28
+ // System information
29
+ console.log(chalk.blue('šŸ–„ļø System Information:'));
30
+ report.system = {
31
+ platform: os.platform(),
32
+ arch: os.arch(),
33
+ nodeVersion: process.version,
34
+ memory: Math.round(os.totalmem() / 1024 / 1024) + ' MB',
35
+ freeMemory: Math.round(os.freemem() / 1024 / 1024) + ' MB'
36
+ };
37
+
38
+ Object.entries(report.system).forEach(([key, value]) => {
39
+ console.log(` ${key}: ${chalk.green(value)}`);
40
+ });
41
+
42
+ // Environment information
43
+ console.log(chalk.blue('\nšŸŒ Environment Information:'));
44
+ report.environment = {
45
+ pwd: process.cwd(),
46
+ home: os.homedir(),
47
+ shell: process.env.SHELL || process.env.COMSPEC || 'unknown',
48
+ path: process.env.PATH ? process.env.PATH.split(path.delimiter).slice(0, 3).join(path.delimiter) + '...' : 'unknown',
49
+ nodeEnv: process.env.NODE_ENV || 'undefined',
50
+ debugMode: process.env.DEBUG === 'true'
51
+ };
52
+
53
+ Object.entries(report.environment).forEach(([key, value]) => {
54
+ console.log(` ${key}: ${chalk.green(value)}`);
55
+ });
56
+
57
+ // Error handler report (if available)
58
+ console.log(chalk.blue('\nšŸ“‹ Error Handler Report:'));
59
+ try {
60
+ if (errorHandler && typeof errorHandler.printErrorReport === 'function') {
61
+ await errorHandler.printErrorReport();
62
+ console.log(chalk.green(' āœ… Error handler report generated'));
63
+ } else {
64
+ console.log(chalk.yellow(' āš ļø Error handler not available'));
65
+ }
66
+ } catch (error) {
67
+ console.log(chalk.red(` āŒ Error handler failed: ${error.message}`));
68
+ report.errors.push({
69
+ type: 'error_handler',
70
+ message: error.message,
71
+ timestamp: new Date().toISOString()
72
+ });
73
+ }
74
+
75
+ // Check for common issues
76
+ console.log(chalk.blue('\nšŸ” Common Issues Check:'));
77
+
78
+ const checks = [
79
+ {
80
+ name: 'Current directory writable',
81
+ check: async () => {
82
+ try {
83
+ await fs.access(process.cwd(), fs.constants.W_OK);
84
+ return true;
85
+ } catch {
86
+ return false;
87
+ }
88
+ }
89
+ },
90
+ {
91
+ name: 'Home directory accessible',
92
+ check: async () => {
93
+ try {
94
+ await fs.access(os.homedir(), fs.constants.R_OK);
95
+ return true;
96
+ } catch {
97
+ return false;
98
+ }
99
+ }
100
+ },
101
+ {
102
+ name: 'Node modules accessible',
103
+ check: async () => {
104
+ try {
105
+ await fs.access(path.join(process.cwd(), 'node_modules'), fs.constants.R_OK);
106
+ return true;
107
+ } catch {
108
+ return false;
109
+ }
110
+ }
111
+ },
112
+ {
113
+ name: 'Package.json exists',
114
+ check: async () => {
115
+ try {
116
+ await fs.access(path.join(process.cwd(), 'package.json'), fs.constants.R_OK);
117
+ return true;
118
+ } catch {
119
+ return false;
120
+ }
121
+ }
122
+ }
123
+ ];
124
+
125
+ for (const check of checks) {
126
+ try {
127
+ const passed = await check.check();
128
+ const icon = passed ? chalk.green('āœ…') : chalk.red('āŒ');
129
+ console.log(` ${icon} ${check.name}`);
130
+
131
+ if (!passed) {
132
+ report.errors.push({
133
+ type: 'common_issue',
134
+ message: `${check.name} failed`,
135
+ timestamp: new Date().toISOString()
136
+ });
137
+ }
138
+ } catch (error) {
139
+ console.log(` ${chalk.yellow('āš ļø')} ${check.name} - Check failed`);
140
+ }
141
+ }
142
+
143
+ // Log files check
144
+ console.log(chalk.blue('\nšŸ“„ Log Files:'));
145
+ const logLocations = [
146
+ path.join(os.homedir(), '.stigmergy', 'logs'),
147
+ path.join(process.cwd(), 'logs'),
148
+ path.join(os.tmpdir(), 'stigmergy-logs')
149
+ ];
150
+
151
+ for (const logLocation of logLocations) {
152
+ try {
153
+ const stats = await fs.stat(logLocation);
154
+ console.log(` ${chalk.green('āœ…')} ${logLocation} (${stats.size} bytes)`);
155
+ } catch {
156
+ console.log(` ${chalk.gray('⚪')} ${logLocation} (not found)`);
157
+ }
158
+ }
159
+
160
+ // Summary
161
+ console.log(chalk.blue('\nšŸ“Š Error Report Summary:'));
162
+ const errorCount = report.errors.length;
163
+ const warningCount = report.environment.debugMode ? 1 : 0;
164
+
165
+ console.log(` Errors: ${chalk.red(errorCount)}`);
166
+ console.log(` Warnings: ${chalk.yellow(warningCount)}`);
167
+
168
+ if (errorCount === 0) {
169
+ console.log(chalk.green('\nāœ… No critical errors detected!'));
170
+ } else {
171
+ console.log(chalk.red(`\nāŒ ${errorCount} issue(s) found - see details above`));
172
+ }
173
+
174
+ // Save report to file if requested
175
+ if (options.save) {
176
+ const reportPath = path.join(process.cwd(), `stigmergy-error-report-${Date.now()}.json`);
177
+ await fs.writeFile(reportPath, JSON.stringify(report, null, 2));
178
+ console.log(chalk.blue(`\nšŸ’¾ Report saved to: ${reportPath}`));
179
+ }
180
+
181
+ return { success: true, report };
182
+ } catch (error) {
183
+ console.error(chalk.red('[ERROR] Failed to generate error report:'), error.message);
184
+ return { success: false, error: error.message };
185
+ }
186
+ }
187
+
188
+ module.exports = {
189
+ handleErrorsCommand
190
+ };