stigmergy 1.2.13 → 1.3.2-beta.0
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/README.md +39 -3
- package/STIGMERGY.md +3 -0
- package/config/enhanced-cli-config.json +438 -0
- package/docs/CLI_TOOLS_AGENT_SKILL_ANALYSIS.md +463 -0
- package/docs/ENHANCED_CLI_AGENT_SKILL_CONFIG.md +285 -0
- package/docs/INSTALLER_ARCHITECTURE.md +257 -0
- package/docs/SUDO_PROBLEM_AND_SOLUTION.md +529 -0
- package/package.json +14 -5
- package/scripts/analyze-router.js +168 -0
- package/scripts/test-runner.js +344 -0
- package/src/cli/commands/autoinstall.js +158 -0
- package/src/cli/commands/errors.js +190 -0
- package/src/cli/commands/install.js +142 -0
- package/src/cli/commands/permissions.js +108 -0
- package/src/cli/commands/project.js +449 -0
- package/src/cli/commands/resume.js +136 -0
- package/src/cli/commands/scan.js +97 -0
- package/src/cli/commands/skills.js +158 -0
- package/src/cli/commands/status.js +106 -0
- package/src/cli/commands/system.js +301 -0
- package/src/cli/router-beta.js +477 -0
- package/src/cli/utils/environment.js +75 -0
- package/src/cli/utils/formatters.js +47 -0
- package/src/cli/utils/skills_cache.js +92 -0
- package/src/core/cache_cleaner.js +1 -0
- package/src/core/cli_adapters.js +345 -0
- package/src/core/cli_help_analyzer.js +473 -1
- package/src/core/cli_path_detector.js +2 -1
- package/src/core/cli_tools.js +107 -0
- package/src/core/coordination/nodejs/HookDeploymentManager.js +185 -422
- package/src/core/coordination/nodejs/HookDeploymentManager.refactored.js +323 -0
- package/src/core/coordination/nodejs/generators/CLIAdapterGenerator.js +363 -0
- package/src/core/coordination/nodejs/generators/ResumeSessionGenerator.js +701 -0
- package/src/core/coordination/nodejs/generators/SkillsIntegrationGenerator.js +1210 -0
- package/src/core/coordination/nodejs/generators/index.js +12 -0
- package/src/core/enhanced_cli_installer.js +220 -30
- package/src/core/enhanced_cli_parameter_handler.js +395 -0
- package/src/core/execution_mode_detector.js +222 -0
- package/src/core/installer.js +51 -70
- package/src/core/local_skill_scanner.js +732 -0
- package/src/core/multilingual/language-pattern-manager.js +1 -1
- package/src/core/skills/StigmergySkillManager.js +26 -8
- package/src/core/smart_router.js +279 -2
- package/src/index.js +10 -4
- package/test/cli-integration.test.js +304 -0
- package/test/enhanced-cli-agent-skill-test.js +485 -0
- package/test/specific-cli-agent-skill-analysis.js +385 -0
- package/src/cli/router.js +0 -1783
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Specific CLI Agent and Skill Analysis
|
|
5
|
+
* Analyzes gemini, copilot, codex, and kode CLI tools
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const path = require('path');
|
|
9
|
+
const os = require('os');
|
|
10
|
+
const { spawnSync } = require('child_process');
|
|
11
|
+
|
|
12
|
+
// Import enhanced components
|
|
13
|
+
const CLIHelpAnalyzer = require('../src/core/cli_help_analyzer');
|
|
14
|
+
const SmartRouter = require('../src/core/smart_router');
|
|
15
|
+
const { CLI_TOOLS } = require('../src/core/cli_tools');
|
|
16
|
+
|
|
17
|
+
class SpecificCLIAnalyzer {
|
|
18
|
+
constructor() {
|
|
19
|
+
this.analyzer = new CLIHelpAnalyzer();
|
|
20
|
+
this.router = new SmartRouter();
|
|
21
|
+
this.targetCLIs = ['gemini', 'copilot', 'codex', 'kode'];
|
|
22
|
+
this.testResults = {};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Main analysis function
|
|
27
|
+
*/
|
|
28
|
+
async analyze() {
|
|
29
|
+
console.log('🔍 Analyzing Specific CLI Tools for Agent and Skill Support');
|
|
30
|
+
console.log('=' .repeat(70));
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
// Initialize components
|
|
34
|
+
await this.analyzer.initialize();
|
|
35
|
+
await this.router.initialize();
|
|
36
|
+
|
|
37
|
+
// Analyze each target CLI
|
|
38
|
+
for (const cliName of this.targetCLIs) {
|
|
39
|
+
await this.analyzeCLI(cliName);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Show comprehensive results
|
|
43
|
+
this.showAnalysisResults();
|
|
44
|
+
|
|
45
|
+
} catch (error) {
|
|
46
|
+
console.error('❌ Analysis failed:', error.message);
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Analyze individual CLI tool
|
|
53
|
+
*/
|
|
54
|
+
async analyzeCLI(cliName) {
|
|
55
|
+
console.log(`\n🔧 Analyzing ${cliName.toUpperCase()} CLI...`);
|
|
56
|
+
console.log('-'.repeat(50));
|
|
57
|
+
|
|
58
|
+
this.testResults[cliName] = {
|
|
59
|
+
installed: false,
|
|
60
|
+
helpAvailable: false,
|
|
61
|
+
agentSupport: false,
|
|
62
|
+
skillSupport: false,
|
|
63
|
+
commandFormat: null,
|
|
64
|
+
examples: [],
|
|
65
|
+
limitations: [],
|
|
66
|
+
testInputs: []
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
// 1. Check if CLI is installed
|
|
70
|
+
await this.checkCLIInstallation(cliName);
|
|
71
|
+
|
|
72
|
+
// 2. Get help information
|
|
73
|
+
await this.getCLIHelp(cliName);
|
|
74
|
+
|
|
75
|
+
// 3. Test agent/skill detection
|
|
76
|
+
await this.testAgentSkillDetection(cliName);
|
|
77
|
+
|
|
78
|
+
// 4. Test command generation
|
|
79
|
+
await this.testCommandGeneration(cliName);
|
|
80
|
+
|
|
81
|
+
// 5. Test smart routing
|
|
82
|
+
await this.testSmartRouting(cliName);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Check if CLI tool is installed
|
|
87
|
+
*/
|
|
88
|
+
async checkCLIInstallation(cliName) {
|
|
89
|
+
try {
|
|
90
|
+
const result = spawnSync(cliName, ['--version'], {
|
|
91
|
+
encoding: 'utf8',
|
|
92
|
+
timeout: 5000,
|
|
93
|
+
stdio: ['pipe', 'pipe', 'pipe']
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
if (result.status === 0) {
|
|
97
|
+
this.testResults[cliName].installed = true;
|
|
98
|
+
console.log(`✅ ${cliName} is installed`);
|
|
99
|
+
if (result.stdout) {
|
|
100
|
+
console.log(` Version: ${result.stdout.trim()}`);
|
|
101
|
+
}
|
|
102
|
+
} else {
|
|
103
|
+
console.log(`❌ ${cliName} is not installed or not responding`);
|
|
104
|
+
}
|
|
105
|
+
} catch (error) {
|
|
106
|
+
console.log(`❌ ${cliName} not found: ${error.message}`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Get CLI help information
|
|
112
|
+
*/
|
|
113
|
+
async getCLIHelp(cliName) {
|
|
114
|
+
const helpMethods = [
|
|
115
|
+
['--help'],
|
|
116
|
+
['-h'],
|
|
117
|
+
['help'],
|
|
118
|
+
['--usage'],
|
|
119
|
+
[''],
|
|
120
|
+
['version'],
|
|
121
|
+
['--version']
|
|
122
|
+
];
|
|
123
|
+
|
|
124
|
+
let helpText = '';
|
|
125
|
+
let helpMethod = '';
|
|
126
|
+
|
|
127
|
+
for (const method of helpMethods) {
|
|
128
|
+
try {
|
|
129
|
+
const result = spawnSync(cliName, method, {
|
|
130
|
+
encoding: 'utf8',
|
|
131
|
+
timeout: 8000,
|
|
132
|
+
stdio: ['pipe', 'pipe', 'pipe']
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
if (result.status === 0 && result.stdout) {
|
|
136
|
+
helpText = result.stdout;
|
|
137
|
+
helpMethod = `${cliName} ${method.join(' ')}`;
|
|
138
|
+
break;
|
|
139
|
+
} else if (result.stderr && result.stderr.includes('help')) {
|
|
140
|
+
helpText = result.stderr;
|
|
141
|
+
helpMethod = `${cliName} ${method.join(' ')} (stderr)`;
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
} catch (error) {
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (helpText) {
|
|
150
|
+
this.testResults[cliName].helpAvailable = true;
|
|
151
|
+
console.log(`📚 Help available via: ${helpMethod}`);
|
|
152
|
+
|
|
153
|
+
// Analyze help text for agent/skill patterns
|
|
154
|
+
this.analyzeHelpText(cliName, helpText);
|
|
155
|
+
} else {
|
|
156
|
+
console.log(`❌ No help information available`);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Analyze help text for agent/skill patterns
|
|
162
|
+
*/
|
|
163
|
+
analyzeHelpText(cliName, helpText) {
|
|
164
|
+
const lowerHelp = helpText.toLowerCase();
|
|
165
|
+
|
|
166
|
+
// Check for agent-related keywords
|
|
167
|
+
const agentKeywords = ['agent', '智能体', 'expert', 'specialist', 'assistant'];
|
|
168
|
+
const hasAgentKeywords = agentKeywords.some(keyword => lowerHelp.includes(keyword));
|
|
169
|
+
|
|
170
|
+
// Check for skill-related keywords
|
|
171
|
+
const skillKeywords = ['skill', '技能', 'capability', 'tool', 'plugin', 'extension'];
|
|
172
|
+
const hasSkillKeywords = skillKeywords.some(keyword => lowerHelp.includes(keyword));
|
|
173
|
+
|
|
174
|
+
// Check for prompt-related parameters
|
|
175
|
+
const promptParams = ['-p', '--prompt', '--input', '--query', 'positional'];
|
|
176
|
+
const hasPromptParams = promptParams.some(param => lowerHelp.includes(param));
|
|
177
|
+
|
|
178
|
+
// Check for non-interactive modes
|
|
179
|
+
const nonInteractiveModes = ['non-interactive', 'batch', 'script', 'stdin'];
|
|
180
|
+
const hasNonInteractive = nonInteractiveModes.some(mode => lowerHelp.includes(mode));
|
|
181
|
+
|
|
182
|
+
this.testResults[cliName].agentSupport = hasAgentKeywords;
|
|
183
|
+
this.testResults[cliName].skillSupport = hasSkillKeywords;
|
|
184
|
+
this.testResults[cliName].hasPromptParams = hasPromptParams;
|
|
185
|
+
this.testResults[cliName].hasNonInteractive = hasNonInteractive;
|
|
186
|
+
|
|
187
|
+
console.log(`🤖 Agent keywords: ${hasAgentKeywords ? '✅' : '❌'}`);
|
|
188
|
+
console.log(`🔧 Skill keywords: ${hasSkillKeywords ? '✅' : '❌'}`);
|
|
189
|
+
console.log(`📝 Prompt params: ${hasPromptParams ? '✅' : '❌'}`);
|
|
190
|
+
console.log(`🔄 Non-interactive: ${hasNonInteractive ? '✅' : '❌'}`);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Test agent/skill detection capabilities
|
|
195
|
+
*/
|
|
196
|
+
async testAgentSkillDetection(cliName) {
|
|
197
|
+
const testInputs = [
|
|
198
|
+
'请使用异化分析技能分析程序员异化现象',
|
|
199
|
+
'使用数字马克思智能体进行阶级分析',
|
|
200
|
+
'请专家助手分析技术影响',
|
|
201
|
+
'使用分析技能进行深度研究'
|
|
202
|
+
];
|
|
203
|
+
|
|
204
|
+
console.log('\n🧪 Testing agent/skill detection:');
|
|
205
|
+
|
|
206
|
+
for (const input of testInputs) {
|
|
207
|
+
try {
|
|
208
|
+
const detections = this.analyzer.detectAgentSkillMentions(input, cliName);
|
|
209
|
+
this.testResults[cliName].testInputs.push({
|
|
210
|
+
input,
|
|
211
|
+
detections
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
console.log(` Input: "${input}"`);
|
|
215
|
+
console.log(` Agent: ${detections.hasAgent ? '✅' : '❌'} | Skill: ${detections.hasSkill ? '✅' : '❌'} | Confidence: ${detections.confidence}`);
|
|
216
|
+
} catch (error) {
|
|
217
|
+
console.log(` ❌ Detection failed: ${error.message}`);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Test command generation
|
|
224
|
+
*/
|
|
225
|
+
async testCommandGeneration(cliName) {
|
|
226
|
+
const testPrompt = '请使用异化分析技能分析程序员异化现象';
|
|
227
|
+
|
|
228
|
+
console.log('\n⚙️ Testing command generation:');
|
|
229
|
+
console.log(` Test prompt: "${testPrompt}"`);
|
|
230
|
+
|
|
231
|
+
try {
|
|
232
|
+
const optimizedCall = this.analyzer.generateOptimizedCall(cliName, testPrompt);
|
|
233
|
+
if (optimizedCall) {
|
|
234
|
+
this.testResults[cliName].commandFormat = optimizedCall.fullCommand;
|
|
235
|
+
console.log(` Generated: ${optimizedCall.fullCommand}`);
|
|
236
|
+
} else {
|
|
237
|
+
console.log(` ❌ Command generation failed`);
|
|
238
|
+
}
|
|
239
|
+
} catch (error) {
|
|
240
|
+
console.log(` ❌ Command generation error: ${error.message}`);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Test smart routing
|
|
246
|
+
*/
|
|
247
|
+
async testSmartRouting(cliName) {
|
|
248
|
+
const testInputs = [
|
|
249
|
+
`请使用分析技能分析程序员异化现象`,
|
|
250
|
+
`使用数字马克思智能体进行阶级分析`
|
|
251
|
+
];
|
|
252
|
+
|
|
253
|
+
console.log('\n🧭 Testing smart routing:');
|
|
254
|
+
|
|
255
|
+
for (const input of testInputs) {
|
|
256
|
+
try {
|
|
257
|
+
const route = await this.router.smartRouteEnhanced(input);
|
|
258
|
+
if (route.tool === cliName) {
|
|
259
|
+
console.log(` ✅ Routed to ${cliName} (confidence: ${route.confidence})`);
|
|
260
|
+
} else {
|
|
261
|
+
console.log(` ⚠️ Routed to ${route.tool} instead of ${cliName}`);
|
|
262
|
+
}
|
|
263
|
+
} catch (error) {
|
|
264
|
+
console.log(` ❌ Routing failed: ${error.message}`);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Show comprehensive analysis results
|
|
271
|
+
*/
|
|
272
|
+
showAnalysisResults() {
|
|
273
|
+
console.log('\n' + '=' .repeat(70));
|
|
274
|
+
console.log('📊 COMPREHENSIVE CLI ANALYSIS RESULTS');
|
|
275
|
+
console.log('=' .repeat(70));
|
|
276
|
+
|
|
277
|
+
for (const [cliName, results] of Object.entries(this.testResults)) {
|
|
278
|
+
console.log(`\n🔧 ${cliName.toUpperCase()} CLI ANALYSIS`);
|
|
279
|
+
console.log('-'.repeat(50));
|
|
280
|
+
|
|
281
|
+
// Installation status
|
|
282
|
+
console.log(`📦 Installation: ${results.installed ? '✅ Installed' : '❌ Not Installed'}`);
|
|
283
|
+
|
|
284
|
+
// Help availability
|
|
285
|
+
console.log(`📚 Help Available: ${results.helpAvailable ? '✅ Yes' : '❌ No'}`);
|
|
286
|
+
|
|
287
|
+
// Agent/Skill support
|
|
288
|
+
console.log(`🤖 Agent Support: ${results.agentSupport ? '✅ Yes' : '❌ No'}`);
|
|
289
|
+
console.log(`🔧 Skill Support: ${results.skillSupport ? '✅ Yes' : '❌ No'}`);
|
|
290
|
+
|
|
291
|
+
// Command format
|
|
292
|
+
if (results.commandFormat) {
|
|
293
|
+
console.log(`⚙️ Command Format: ${results.commandFormat}`);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// Test inputs summary
|
|
297
|
+
if (results.testInputs.length > 0) {
|
|
298
|
+
console.log(`🧪 Detection Tests: ${results.testInputs.length} completed`);
|
|
299
|
+
const avgConfidence = results.testInputs.reduce((sum, test) => sum + test.detections.confidence, 0) / results.testInputs.length;
|
|
300
|
+
console.log(` Average Confidence: ${avgConfidence.toFixed(2)}`);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// Overall assessment
|
|
304
|
+
const supportScore = (results.agentSupport ? 1 : 0) + (results.skillSupport ? 1 : 0);
|
|
305
|
+
let assessment = '';
|
|
306
|
+
|
|
307
|
+
if (supportScore === 2) {
|
|
308
|
+
assessment = '✅ Full Support';
|
|
309
|
+
} else if (supportScore === 1) {
|
|
310
|
+
assessment = '⚠️ Partial Support';
|
|
311
|
+
} else {
|
|
312
|
+
assessment = '❌ No Support';
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
console.log(`🎯 Overall Assessment: ${assessment}`);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// Summary comparison
|
|
319
|
+
console.log('\n' + '=' .repeat(70));
|
|
320
|
+
console.log('📋 SUMMARY COMPARISON');
|
|
321
|
+
console.log('=' .repeat(70));
|
|
322
|
+
|
|
323
|
+
const comparisonTable = [
|
|
324
|
+
['CLI Tool', 'Installed', 'Agent Support', 'Skill Support', 'Overall'],
|
|
325
|
+
['-'.repeat(10), '-'.repeat(10), '-'.repeat(12), '-'.repeat(12), '-'.repeat(8)]
|
|
326
|
+
];
|
|
327
|
+
|
|
328
|
+
for (const [cliName, results] of Object.entries(this.testResults)) {
|
|
329
|
+
const installed = results.installed ? '✅' : '❌';
|
|
330
|
+
const agent = results.agentSupport ? '✅' : '❌';
|
|
331
|
+
const skill = results.skillSupport ? '✅' : '❌';
|
|
332
|
+
|
|
333
|
+
const supportScore = (results.agentSupport ? 1 : 0) + (results.skillSupport ? 1 : 0);
|
|
334
|
+
const overall = supportScore === 2 ? 'Excellent' : supportScore === 1 ? 'Good' : 'Poor';
|
|
335
|
+
|
|
336
|
+
comparisonTable.push([cliName, installed, agent, skill, overall]);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// Print table
|
|
340
|
+
for (const row of comparisonTable) {
|
|
341
|
+
console.log(row.join(' | '));
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// Recommendations
|
|
345
|
+
console.log('\n💡 RECOMMENDATIONS');
|
|
346
|
+
console.log('-'.repeat(30));
|
|
347
|
+
|
|
348
|
+
for (const [cliName, results] of Object.entries(this.testResults)) {
|
|
349
|
+
if (!results.installed) {
|
|
350
|
+
console.log(`📦 ${cliName}: Consider installing for broader CLI tool coverage`);
|
|
351
|
+
} else if (!results.agentSupport || !results.skillSupport) {
|
|
352
|
+
console.log(`🔧 ${cliName}: Limited agent/skill support - may need manual prompt engineering`);
|
|
353
|
+
} else {
|
|
354
|
+
console.log(`✨ ${cliName}: Full support available - ready for enhanced CLI calls`);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
// Main execution
|
|
361
|
+
async function main() {
|
|
362
|
+
const analyzer = new SpecificCLIAnalyzer();
|
|
363
|
+
await analyzer.analyze();
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
// Handle errors
|
|
367
|
+
process.on('unhandledRejection', (reason, promise) => {
|
|
368
|
+
console.error('[FATAL] Unhandled Rejection at:', promise, 'reason:', reason);
|
|
369
|
+
process.exit(1);
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
process.on('uncaughtException', (error) => {
|
|
373
|
+
console.error('[FATAL] Uncaught Exception:', error);
|
|
374
|
+
process.exit(1);
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
// Run analysis if this file is executed directly
|
|
378
|
+
if (require.main === module) {
|
|
379
|
+
main().catch((error) => {
|
|
380
|
+
console.error('[FATAL] Analysis execution failed:', error);
|
|
381
|
+
process.exit(1);
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
module.exports = SpecificCLIAnalyzer;
|