stigmergy 1.2.13 โ†’ 1.3.2-beta.1

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 (50) hide show
  1. package/README.md +39 -3
  2. package/STIGMERGY.md +3 -0
  3. package/config/enhanced-cli-config.json +438 -0
  4. package/docs/CLI_TOOLS_AGENT_SKILL_ANALYSIS.md +463 -0
  5. package/docs/ENHANCED_CLI_AGENT_SKILL_CONFIG.md +285 -0
  6. package/docs/INSTALLER_ARCHITECTURE.md +257 -0
  7. package/docs/SUDO_PROBLEM_AND_SOLUTION.md +529 -0
  8. package/package.json +16 -5
  9. package/scripts/analyze-router.js +168 -0
  10. package/scripts/run-comprehensive-tests.js +230 -0
  11. package/scripts/run-quick-tests.js +90 -0
  12. package/scripts/test-runner.js +344 -0
  13. package/src/cli/commands/autoinstall.js +158 -0
  14. package/src/cli/commands/errors.js +190 -0
  15. package/src/cli/commands/install.js +142 -0
  16. package/src/cli/commands/permissions.js +108 -0
  17. package/src/cli/commands/project.js +449 -0
  18. package/src/cli/commands/resume.js +136 -0
  19. package/src/cli/commands/scan.js +97 -0
  20. package/src/cli/commands/skills.js +158 -0
  21. package/src/cli/commands/status.js +106 -0
  22. package/src/cli/commands/system.js +301 -0
  23. package/src/cli/router-beta.js +477 -0
  24. package/src/cli/utils/environment.js +75 -0
  25. package/src/cli/utils/formatters.js +47 -0
  26. package/src/cli/utils/skills_cache.js +92 -0
  27. package/src/core/cache_cleaner.js +1 -0
  28. package/src/core/cli_adapters.js +345 -0
  29. package/src/core/cli_help_analyzer.js +473 -1
  30. package/src/core/cli_path_detector.js +2 -1
  31. package/src/core/cli_tools.js +107 -0
  32. package/src/core/coordination/nodejs/HookDeploymentManager.js +204 -416
  33. package/src/core/coordination/nodejs/HookDeploymentManager.refactored.js +323 -0
  34. package/src/core/coordination/nodejs/generators/CLIAdapterGenerator.js +363 -0
  35. package/src/core/coordination/nodejs/generators/ResumeSessionGenerator.js +703 -0
  36. package/src/core/coordination/nodejs/generators/SkillsIntegrationGenerator.js +1210 -0
  37. package/src/core/coordination/nodejs/generators/index.js +12 -0
  38. package/src/core/enhanced_cli_installer.js +375 -31
  39. package/src/core/enhanced_cli_parameter_handler.js +395 -0
  40. package/src/core/execution_mode_detector.js +222 -0
  41. package/src/core/installer.js +83 -67
  42. package/src/core/local_skill_scanner.js +732 -0
  43. package/src/core/multilingual/language-pattern-manager.js +1 -1
  44. package/src/core/skills/StigmergySkillManager.js +26 -8
  45. package/src/core/smart_router.js +279 -2
  46. package/src/index.js +10 -4
  47. package/test/cli-integration.test.js +304 -0
  48. package/test/enhanced-cli-agent-skill-test.js +485 -0
  49. package/test/specific-cli-agent-skill-analysis.js +385 -0
  50. package/src/cli/router.js +0 -1783
@@ -0,0 +1,136 @@
1
+ /**
2
+ * Resume Session Commands
3
+ * Modular implementation for resume/resumesession/sg-resume commands
4
+ */
5
+
6
+ const chalk = require('chalk');
7
+ const { spawnSync } = require('child_process');
8
+ const { getCLIPath } = require('../../core/cli_tools');
9
+
10
+ /**
11
+ * Handle resume session command - Forward to @stigmergy/resume CLI tool
12
+ * @param {Array} args - Arguments to pass to resumesession
13
+ * @param {Object} options - Command options
14
+ */
15
+ async function handleResumeCommand(args = [], options = {}) {
16
+ try {
17
+ console.log(chalk.blue('[RESUME] Checking for ResumeSession CLI tool...'));
18
+
19
+ // Check if resumesession command is available
20
+ const resumesessionPath = await getCLIPath('resumesession');
21
+
22
+ if (resumesessionPath) {
23
+ console.log(chalk.green(`[RESUME] Found ResumeSession at: ${resumesessionPath}`));
24
+
25
+ // Forward all arguments to the resumesession CLI tool
26
+ const resumeArgs = args; // Pass all arguments through
27
+ console.log(chalk.blue(`[RESUME] Forwarding to resumesession: ${resumeArgs.join(' ') || '(no args)'}`));
28
+
29
+ // Execute resumesession with the provided arguments
30
+ const result = spawnSync(resumesessionPath, resumeArgs, {
31
+ stdio: 'inherit',
32
+ shell: true,
33
+ cwd: process.cwd(),
34
+ env: { ...process.env, FORCE_COLOR: '1' } // Ensure colors are preserved
35
+ });
36
+
37
+ if (result.status !== 0) {
38
+ console.log(chalk.yellow(`[WARN] ResumeSession exited with code ${result.status}`));
39
+ return { success: false, exitCode: result.status, forwarded: true };
40
+ }
41
+
42
+ return { success: true, exitCode: result.status, forwarded: true };
43
+
44
+ } else {
45
+ // ResumeSession CLI tool not found
46
+ console.log(chalk.red('[ERROR] ResumeSession CLI tool not found'));
47
+ console.log(chalk.yellow('[INFO] ResumeSession is an optional component for session recovery'));
48
+
49
+ console.log(chalk.blue('\n๐Ÿ“ฆ To install ResumeSession:'));
50
+ console.log(' npm install -g @stigmergy/resume');
51
+ console.log('');
52
+ console.log(chalk.blue('๐Ÿ”ง ResumeSession provides:'));
53
+ console.log(' โ€ข Cross-CLI session history');
54
+ console.log(' โ€ข Memory sharing between CLI tools');
55
+ console.log(' โ€ข Session recovery and continuation');
56
+ console.log(' โ€ข Centralized configuration management');
57
+ console.log('');
58
+ console.log(chalk.blue('๐Ÿ“‹ Usage examples:'));
59
+ console.log(' stigmergy resume list # Show session history');
60
+ console.log(' stigmergy resume continue <session-id> # Continue a session');
61
+ console.log(' stigmergy resume export # Export session data');
62
+ console.log(' stigmergy resume --help # Show all options');
63
+
64
+ return { success: false, error: 'ResumeSession CLI tool not found', forwarded: false };
65
+ }
66
+
67
+ } catch (error) {
68
+ console.error(chalk.red('[ERROR] Resume command failed:'), error.message);
69
+
70
+ if (options.verbose) {
71
+ console.error(chalk.red('Stack trace:'), error.stack);
72
+ }
73
+
74
+ return { success: false, error: error.message, forwarded: false };
75
+ }
76
+ }
77
+
78
+ /**
79
+ * Handle resumesession command alias
80
+ * @param {Array} args - Arguments
81
+ * @param {Object} options - Options
82
+ */
83
+ async function handleResumeSessionCommand(args = [], options = {}) {
84
+ return await handleResumeCommand(args, options);
85
+ }
86
+
87
+ /**
88
+ * Handle sg-resume command alias
89
+ * @param {Array} args - Arguments
90
+ * @param {Object} options - Options
91
+ */
92
+ async function handleSgResumeCommand(args = [], options = {}) {
93
+ return await handleResumeCommand(args, options);
94
+ }
95
+
96
+ /**
97
+ * Print resume help information
98
+ */
99
+ function printResumeHelp() {
100
+ console.log(chalk.cyan(`
101
+ ๐Ÿ”„ Stigmergy Resume Session System
102
+
103
+ ๐Ÿ“‹ ResumeSession forwards to the @stigmergy/resume CLI tool for session management.
104
+
105
+ ๐Ÿ› ๏ธ Available Commands:
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
+
110
+ ๐Ÿ“ฆ Requirements:
111
+ @stigmergy/resume CLI tool must be installed separately.
112
+
113
+ ๐Ÿ’พ Installation:
114
+ npm install -g @stigmergy/resume
115
+
116
+ ๐Ÿ” Common Usage:
117
+ stigmergy resume list # Show available sessions
118
+ stigmergy resume continue <id> # Continue a specific session
119
+ stigmergy resume export # Export session data
120
+ stigmergy resume clean # Clean old sessions
121
+
122
+ ๐Ÿ“š More Information:
123
+ ResumeSession provides cross-CLI memory sharing and session recovery
124
+ capabilities, allowing you to maintain context across different AI CLI tools.
125
+
126
+ If ResumeSession is not installed, you can still use all other Stigmergy
127
+ CLI features normally.
128
+ `));
129
+ }
130
+
131
+ module.exports = {
132
+ handleResumeCommand,
133
+ handleResumeSessionCommand,
134
+ handleSgResumeCommand,
135
+ printResumeHelp
136
+ };
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Scan Command Module
3
+ * Handles CLI tool scanning and discovery commands
4
+ */
5
+
6
+ const { CLI_TOOLS } = require('../../core/cli_tools');
7
+ const chalk = require('chalk');
8
+ const { ensureSkillsCache } = require('../utils/skills_cache');
9
+
10
+ /**
11
+ * Handle scan command
12
+ * @param {Object} options - Command options
13
+ * @param {boolean} options.deep - Deep scan for CLI tools
14
+ * @param {boolean} options.json - Output in JSON format
15
+ * @param {boolean} options.verbose - Verbose output
16
+ */
17
+ async function handleScanCommand(options = {}) {
18
+ try {
19
+ // Initialize or update skills/agents cache
20
+ await ensureSkillsCache({ verbose: options.verbose });
21
+
22
+ console.log(chalk.blue('๐Ÿ” Scanning for CLI tools...'));
23
+
24
+ const scanOptions = {
25
+ deep: options.deep || false,
26
+ verbose: options.verbose || false
27
+ };
28
+
29
+ // Scan for available CLI tools
30
+ const results = await CLI_TOOLS.scanForTools(scanOptions);
31
+
32
+ if (results.found && results.found.length > 0) {
33
+ console.log(chalk.green(`\nโœ… Found ${results.found.length} CLI tools:`));
34
+
35
+ for (const tool of results.found) {
36
+ console.log(chalk.cyan(` ๐Ÿ“ฆ ${tool.name}`));
37
+ console.log(chalk.gray(` Version: ${tool.version || 'unknown'}`));
38
+ console.log(chalk.gray(` Path: ${tool.path}`));
39
+
40
+ if (options.verbose) {
41
+ console.log(chalk.gray(` Type: ${tool.type}`));
42
+ console.log(chalk.gray(` Status: ${tool.status}`));
43
+ if (tool.description) {
44
+ console.log(chalk.gray(` Description: ${tool.description}`));
45
+ }
46
+ }
47
+ }
48
+ } else {
49
+ console.log(chalk.yellow('\nโš ๏ธ No CLI tools found'));
50
+ }
51
+
52
+ // Show missing tools
53
+ if (results.missing && results.missing.length > 0) {
54
+ console.log(chalk.yellow(`\nโŒ Missing ${results.missing.length} tools:`));
55
+ results.missing.forEach(tool => {
56
+ console.log(chalk.red(` โŒ ${tool}`));
57
+ });
58
+
59
+ console.log(chalk.cyan('\n๐Ÿ’ก To install missing tools:'));
60
+ console.log(chalk.cyan(' stigmergy install'));
61
+ }
62
+
63
+ // Summary
64
+ console.log('');
65
+ console.log(chalk.blue('๐Ÿ“Š Scan Summary:'));
66
+ console.log(` Total tools checked: ${results.total || 0}`);
67
+ console.log(` Found: ${results.found?.length || 0}`);
68
+ console.log(` Missing: ${results.missing?.length || 0}`);
69
+
70
+ if (options.json) {
71
+ console.log('');
72
+ console.log(chalk.blue('๐Ÿ“„ JSON Output:'));
73
+ console.log(JSON.stringify(results, null, 2));
74
+ }
75
+
76
+ // Recommendations
77
+ if (results.found && results.found.length > 0) {
78
+ console.log(chalk.cyan('\n๐Ÿ’ก You can now use these tools:'));
79
+ const toolExamples = results.found.slice(0, 3);
80
+ toolExamples.forEach(tool => {
81
+ console.log(chalk.cyan(` stigmergy ${tool.name} "your prompt here"`));
82
+ });
83
+
84
+ if (results.found.length > 3) {
85
+ console.log(chalk.cyan(` ... and ${results.found.length - 3} more tools`));
86
+ }
87
+ }
88
+
89
+ } catch (error) {
90
+ console.log(chalk.red(`โŒ Scan failed: ${error.message}`));
91
+ process.exit(1);
92
+ }
93
+ }
94
+
95
+ module.exports = {
96
+ handleScanCommand
97
+ };
@@ -0,0 +1,158 @@
1
+ /**
2
+ * Skills Management Commands
3
+ * Modular implementation for all skill-related commands
4
+ */
5
+
6
+ const chalk = require('chalk');
7
+ const { handleSkillCommand } = require('../../commands/skill-handler');
8
+
9
+ /**
10
+ * Handle main skill command with all subcommands
11
+ * @param {string} subcommand - Skill subcommand (install/list/read/remove/validate/sync)
12
+ * @param {Array} args - Additional arguments
13
+ * @param {Object} options - Command options
14
+ */
15
+ async function handleSkillMainCommand(subcommand, args = [], options = {}) {
16
+ try {
17
+ // Handle skill command aliases from router-beta.js
18
+ let action;
19
+ let skillArgs;
20
+
21
+ switch (subcommand) {
22
+ case 'skill-i':
23
+ action = 'install';
24
+ skillArgs = args;
25
+ break;
26
+ case 'skill-l':
27
+ action = 'list';
28
+ skillArgs = args;
29
+ break;
30
+ case 'skill-v':
31
+ // skill-v can be validate or read, based on parameters
32
+ action = args[0] && (args[0].endsWith('.md') || args[0].includes('/') || args[0].includes('\\'))
33
+ ? 'validate'
34
+ : 'read';
35
+ skillArgs = args;
36
+ break;
37
+ case 'skill-r':
38
+ action = 'read';
39
+ skillArgs = args;
40
+ break;
41
+ case 'skill-d':
42
+ case 'skill-m':
43
+ action = 'remove';
44
+ skillArgs = args;
45
+ break;
46
+ default:
47
+ action = subcommand || 'help';
48
+ skillArgs = args;
49
+ break;
50
+ }
51
+
52
+ const exitCode = await handleSkillCommand(action, skillArgs, {
53
+ verbose: options.verbose || false,
54
+ force: options.force || false,
55
+ autoSync: !options.noAutoSync
56
+ });
57
+
58
+ return { success: exitCode === 0, exitCode };
59
+ } catch (error) {
60
+ console.error(chalk.red(`[ERROR] Skill command failed: ${error.message}`));
61
+ return { success: false, error: error.message };
62
+ }
63
+ }
64
+
65
+ /**
66
+ * Handle skill install command (skill-i alias)
67
+ * @param {Array} args - Arguments
68
+ * @param {Object} options - Options
69
+ */
70
+ async function handleSkillInstallCommand(args = [], options = {}) {
71
+ return await handleSkillMainCommand('install', args, options);
72
+ }
73
+
74
+ /**
75
+ * Handle skill list command (skill-l alias)
76
+ * @param {Array} args - Arguments
77
+ * @param {Object} options - Options
78
+ */
79
+ async function handleSkillListCommand(args = [], options = {}) {
80
+ return await handleSkillMainCommand('list', args, options);
81
+ }
82
+
83
+ /**
84
+ * Handle skill read command (skill-r alias)
85
+ * @param {Array} args - Arguments
86
+ * @param {Object} options - Options
87
+ */
88
+ async function handleSkillReadCommand(args = [], options = {}) {
89
+ return await handleSkillMainCommand('read', args, options);
90
+ }
91
+
92
+ /**
93
+ * Handle skill validate/read command (skill-v alias)
94
+ * @param {Array} args - Arguments
95
+ * @param {Object} options - Options
96
+ */
97
+ async function handleSkillValidateCommand(args = [], options = {}) {
98
+ return await handleSkillMainCommand('validate', args, options);
99
+ }
100
+
101
+ /**
102
+ * Handle skill remove command (skill-d, skill-m aliases)
103
+ * @param {Array} args - Arguments
104
+ * @param {Object} options - Options
105
+ */
106
+ async function handleSkillRemoveCommand(args = [], options = {}) {
107
+ return await handleSkillMainCommand('remove', args, options);
108
+ }
109
+
110
+ /**
111
+ * Print skills help information
112
+ */
113
+ function printSkillsHelp() {
114
+ console.log(chalk.cyan(`
115
+ ๐ŸŽฏ Stigmergy Skills Management System
116
+
117
+ ๐Ÿ“‹ Available Commands:
118
+ stigmergy skill install <source> Install a skill from source
119
+ stigmergy skill list List all installed skills
120
+ stigmergy skill read <skill-name> Read skill content and description
121
+ stigmergy skill validate <path> Validate skill file or directory
122
+ stigmergy skill remove <skill-name> Remove installed skill
123
+ stigmergy skill sync Sync skills with remote repositories
124
+
125
+ ๐Ÿ”— Aliases (Shortcuts):
126
+ skill-i โ†’ skill install
127
+ skill-l โ†’ skill list
128
+ skill-r โ†’ skill read
129
+ skill-v โ†’ skill validate/read (auto-detect)
130
+ skill-d โ†’ skill remove
131
+ skill-m โ†’ skill remove (็งป้™ค)
132
+
133
+ ๐Ÿ’ก Examples:
134
+ stigmergy skill install anthropics/skills
135
+ stigmergy skill-i anthropics/skills # Using alias
136
+ stigmergy skill list
137
+ stigmergy skill-l # Using alias
138
+ stigmergy skill read canvas-design
139
+ stigmergy skill-v ./my-skill.md # Validate file
140
+ stigmergy skill-r docx # Using alias
141
+ stigmergy skill remove old-skill
142
+ stigmergy skill-d old-skill # Using alias
143
+
144
+ ๐Ÿ“š More Information:
145
+ Skills extend CLI tool capabilities with specialized workflows and tools.
146
+ Each skill contains instructions for specific tasks and integrations.
147
+ `));
148
+ }
149
+
150
+ module.exports = {
151
+ handleSkillMainCommand,
152
+ handleSkillInstallCommand,
153
+ handleSkillListCommand,
154
+ handleSkillReadCommand,
155
+ handleSkillValidateCommand,
156
+ handleSkillRemoveCommand,
157
+ printSkillsHelp
158
+ };
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Status Command Module
3
+ * Handles CLI tool status checking commands
4
+ */
5
+
6
+ const { CLI_TOOLS } = require('../../core/cli_tools');
7
+ const chalk = require('chalk');
8
+ const { formatToolStatus } = require('../utils/formatters');
9
+
10
+ /**
11
+ * Handle status command
12
+ * @param {Object} options - Command options
13
+ * @param {string} options.cli - Specific CLI to check
14
+ * @param {boolean} options.json - Output in JSON format
15
+ * @param {boolean} options.verbose - Verbose output
16
+ */
17
+ async function handleStatusCommand(options = {}) {
18
+ try {
19
+ const supportedTools = ['claude', 'gemini', 'qwen', 'codebuddy', 'codex', 'iflow', 'qodercli', 'copilot'];
20
+
21
+ if (options.cli) {
22
+ // Check specific CLI
23
+ if (!supportedTools.includes(options.cli)) {
24
+ console.log(chalk.red(`โŒ Unknown CLI tool: ${options.cli}`));
25
+ console.log(chalk.yellow(`Supported tools: ${supportedTools.join(', ')}`));
26
+ process.exit(1);
27
+ }
28
+
29
+ try {
30
+ const status = await CLI_TOOLS.checkInstallation(options.cli);
31
+
32
+ if (options.json) {
33
+ console.log(JSON.stringify(status, null, 2));
34
+ } else {
35
+ console.log(chalk.cyan(`๐Ÿ“Š ${options.cli} Status:`));
36
+ console.log(formatToolStatus({ ...status, tool: options.cli }));
37
+
38
+ if (options.verbose && status.installed) {
39
+ if (status.version) {
40
+ console.log(chalk.gray(` ๐Ÿ“ฆ Version: ${status.version}`));
41
+ }
42
+ if (status.path) {
43
+ console.log(chalk.gray(` ๐Ÿ“ Path: ${status.path}`));
44
+ }
45
+ if (status.lastChecked) {
46
+ console.log(chalk.gray(` ๐Ÿ• Last checked: ${status.lastChecked}`));
47
+ }
48
+ }
49
+ }
50
+ } catch (error) {
51
+ console.log(chalk.red(`โŒ Error checking ${options.cli}: ${error.message}`));
52
+ process.exit(1);
53
+ }
54
+ } else {
55
+ // Check all CLIs
56
+ console.log(chalk.cyan('๐Ÿ“Š CLI Tools Status:'));
57
+
58
+ let installedCount = 0;
59
+ const results = [];
60
+
61
+ for (const tool of supportedTools) {
62
+ try {
63
+ const status = await CLI_TOOLS.checkInstallation(tool);
64
+ results.push({ tool, ...status });
65
+
66
+ if (status.installed) {
67
+ installedCount++;
68
+ console.log(chalk.green(` โœ… ${tool}`));
69
+ } else {
70
+ console.log(chalk.red(` โŒ ${tool}`));
71
+ }
72
+ } catch (error) {
73
+ results.push({ tool, installed: false, error: error.message });
74
+ console.log(chalk.yellow(` โš ๏ธ ${tool}: Error checking status`));
75
+ }
76
+ }
77
+
78
+ // Summary
79
+ console.log('');
80
+ console.log(chalk.blue(`๐Ÿ“ˆ Summary: ${installedCount}/${supportedTools.length} tools installed`));
81
+
82
+ if (installedCount < supportedTools.length) {
83
+ console.log(chalk.yellow('\n๐Ÿ’ก To install missing tools, run:'));
84
+ console.log(chalk.cyan(' stigmergy install'));
85
+
86
+ const missing = results.filter(r => !r.installed);
87
+ if (missing.length > 0 && missing.length < supportedTools.length) {
88
+ console.log(chalk.cyan(` stigmergy install --cli ${missing.map(r => r.tool).join(',')}`));
89
+ }
90
+ }
91
+
92
+ if (options.json) {
93
+ console.log('');
94
+ console.log(chalk.blue('๐Ÿ“„ Detailed JSON output:'));
95
+ console.log(JSON.stringify(results, null, 2));
96
+ }
97
+ }
98
+ } catch (error) {
99
+ console.log(chalk.red(`โŒ Status check failed: ${error.message}`));
100
+ process.exit(1);
101
+ }
102
+ }
103
+
104
+ module.exports = {
105
+ handleStatusCommand
106
+ };