stigmergy 1.2.8 → 1.2.11

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 (48) hide show
  1. package/README.md +40 -6
  2. package/STIGMERGY.md +10 -0
  3. package/package.json +19 -5
  4. package/scripts/preuninstall.js +10 -0
  5. package/src/adapters/claude/install_claude_integration.js +21 -21
  6. package/src/adapters/codebuddy/install_codebuddy_integration.js +54 -51
  7. package/src/adapters/codex/install_codex_integration.js +27 -28
  8. package/src/adapters/gemini/install_gemini_integration.js +60 -60
  9. package/src/adapters/iflow/install_iflow_integration.js +72 -72
  10. package/src/adapters/qoder/install_qoder_integration.js +64 -64
  11. package/src/adapters/qwen/install_qwen_integration.js +7 -7
  12. package/src/cli/router.js +581 -175
  13. package/src/commands/skill-bridge.js +39 -0
  14. package/src/commands/skill-handler.js +150 -0
  15. package/src/commands/skill.js +127 -0
  16. package/src/core/cli_path_detector.js +710 -0
  17. package/src/core/cli_tools.js +72 -1
  18. package/src/core/coordination/nodejs/AdapterManager.js +29 -1
  19. package/src/core/directory_permission_manager.js +568 -0
  20. package/src/core/enhanced_cli_installer.js +609 -0
  21. package/src/core/installer.js +232 -88
  22. package/src/core/multilingual/language-pattern-manager.js +78 -50
  23. package/src/core/persistent_shell_configurator.js +468 -0
  24. package/src/core/skills/StigmergySkillManager.js +357 -0
  25. package/src/core/skills/__tests__/SkillInstaller.test.js +275 -0
  26. package/src/core/skills/__tests__/SkillParser.test.js +202 -0
  27. package/src/core/skills/__tests__/SkillReader.test.js +189 -0
  28. package/src/core/skills/cli-command-test.js +201 -0
  29. package/src/core/skills/comprehensive-e2e-test.js +473 -0
  30. package/src/core/skills/e2e-test.js +267 -0
  31. package/src/core/skills/embedded-openskills/SkillInstaller.js +438 -0
  32. package/src/core/skills/embedded-openskills/SkillParser.js +123 -0
  33. package/src/core/skills/embedded-openskills/SkillReader.js +143 -0
  34. package/src/core/skills/integration-test.js +248 -0
  35. package/src/core/skills/package.json +6 -0
  36. package/src/core/skills/regression-test.js +285 -0
  37. package/src/core/skills/run-all-tests.js +129 -0
  38. package/src/core/skills/sync-test.js +210 -0
  39. package/src/core/skills/test-runner.js +242 -0
  40. package/src/utils/helpers.js +3 -20
  41. package/src/auth.js +0 -173
  42. package/src/auth_command.js +0 -208
  43. package/src/calculator.js +0 -313
  44. package/src/core/enhanced_installer.js +0 -479
  45. package/src/core/enhanced_uninstaller.js +0 -638
  46. package/src/data_encryption.js +0 -143
  47. package/src/data_structures.js +0 -440
  48. package/src/deploy.js +0 -55
@@ -1,638 +0,0 @@
1
- /**
2
- * Enhanced Stigmergy Uninstaller
3
- *
4
- * Comprehensive uninstallation with complete cleanup of all Stigmergy-related files,
5
- * configurations, caches, and integrations across all supported CLI tools.
6
- */
7
-
8
- const fs = require('fs');
9
- const path = require('path');
10
- const os = require('os');
11
- const { spawnSync } = require('child_process');
12
-
13
- class EnhancedUninstaller {
14
- constructor(options = {}) {
15
- this.options = {
16
- dryRun: options.dryRun || false,
17
- force: options.force || false,
18
- verbose: options.verbose || false,
19
- preserveUserConfigs: options.preserveUserConfigs || false,
20
- ...options,
21
- };
22
-
23
- this.homeDir = os.homedir();
24
- this.stigmergyDir = path.join(this.homeDir, '.stigmergy');
25
- this.stigmergyTestDir = path.join(this.homeDir, '.stigmergy-test');
26
-
27
- this.supportedCLIs = [
28
- 'claude',
29
- 'gemini',
30
- 'qwen',
31
- 'iflow',
32
- 'qodercli',
33
- 'codebuddy',
34
- 'codex',
35
- 'copilot',
36
- 'qwencode',
37
- ];
38
-
39
- this.results = {
40
- filesRemoved: 0,
41
- directoriesRemoved: 0,
42
- errors: [],
43
- skipped: [],
44
- };
45
- }
46
-
47
- /**
48
- * Perform complete uninstallation
49
- */
50
- async completeUninstall() {
51
- console.log('šŸ—‘ļæ½? Starting Enhanced Stigmergy Uninstall...\n');
52
-
53
- if (this.options.dryRun) {
54
- console.log('šŸ” DRY RUN MODE - No files will be deleted\n');
55
- }
56
-
57
- try {
58
- // 1. Clean Stigmergy main directory
59
- await this.cleanStigmergyDirectory();
60
-
61
- // 2. Clean test directory
62
- await this.cleanTestDirectory();
63
-
64
- // 3. Clean CLI configurations
65
- await this.cleanCLIConfigurations();
66
-
67
- // 4. Clean NPX cache
68
- await this.cleanNPXCache();
69
-
70
- // 5. Clean temporary files
71
- await this.cleanTemporaryFiles();
72
-
73
- // 6. Uninstall global packages (if requested)
74
- if (this.options.uninstallGlobal) {
75
- await this.uninstallGlobalPackages();
76
- }
77
-
78
- // 7. Print summary
79
- this.printSummary();
80
-
81
- return this.results;
82
- } catch (error) {
83
- console.error('ļæ½?Uninstall failed:', error.message);
84
- this.results.errors.push(error.message);
85
- return this.results;
86
- }
87
- }
88
-
89
- /**
90
- * Create uninstall plan without executing
91
- */
92
- async createUninstallPlan() {
93
- console.log('šŸ“‹ Creating Uninstall Plan...\n');
94
-
95
- const plan = {
96
- directories: [],
97
- files: [],
98
- globalPackages: [],
99
- cliConfigurations: [],
100
- estimatedSize: 0,
101
- };
102
-
103
- // Scan Stigmergy directory
104
- if (fs.existsSync(this.stigmergyDir)) {
105
- await this.scanDirectory(this.stigmergyDir, plan);
106
- }
107
-
108
- // Scan test directory
109
- if (fs.existsSync(this.stigmergyTestDir)) {
110
- await this.scanDirectory(this.stigmergyTestDir, plan);
111
- }
112
-
113
- // Scan CLI configurations
114
- for (const cli of this.supportedCLIs) {
115
- const cliConfig = path.join(this.homeDir, `.${cli}`);
116
- if (fs.existsSync(cliConfig)) {
117
- const stigmergyFiles = await this.findStigmergyFiles(cliConfig);
118
- plan.cliConfigurations.push({
119
- cli,
120
- files: stigmergyFiles,
121
- });
122
- }
123
- }
124
-
125
- // Calculate estimated size
126
- plan.estimatedSize = await this.calculateDirectorySize([
127
- this.stigmergyDir,
128
- this.stigmergyTestDir,
129
- ...plan.cliConfigurations.flatMap((c) => c.files),
130
- ]);
131
-
132
- return plan;
133
- }
134
-
135
- /**
136
- * Clean Stigmergy main directory
137
- */
138
- async cleanStigmergyDirectory() {
139
- console.log('šŸ“ Cleaning Stigmergy directory...');
140
-
141
- if (!fs.existsSync(this.stigmergyDir)) {
142
- console.log(' ā„¹ļø Stigmergy directory not found');
143
- return;
144
- }
145
-
146
- const files = await this.getAllFiles(this.stigmergyDir);
147
-
148
- if (this.options.dryRun) {
149
- console.log(` šŸ” Would remove ${files.length} files and directories`);
150
- this.logFiles(files, ' ');
151
- return;
152
- }
153
-
154
- try {
155
- await this.removeDirectory(this.stigmergyDir);
156
- console.log(` ļæ½?Removed ${files.length} files and directories`);
157
- this.results.filesRemoved += files.length;
158
- this.results.directoriesRemoved++;
159
- } catch (error) {
160
- console.error(
161
- ` ļæ½?Failed to remove Stigmergy directory: ${error.message}`,
162
- );
163
- this.results.errors.push(`Stigmergy directory: ${error.message}`);
164
- }
165
- }
166
-
167
- /**
168
- * Clean test directory
169
- */
170
- async cleanTestDirectory() {
171
- console.log('🧪 Cleaning test directory...');
172
-
173
- if (!fs.existsSync(this.stigmergyTestDir)) {
174
- console.log(' ā„¹ļø Test directory not found');
175
- return;
176
- }
177
-
178
- if (this.options.dryRun) {
179
- console.log(' šŸ” Would remove test directory');
180
- return;
181
- }
182
-
183
- try {
184
- await this.removeDirectory(this.stigmergyTestDir);
185
- console.log(' ļæ½?Removed test directory');
186
- this.results.directoriesRemoved++;
187
- } catch (error) {
188
- console.error(` ļæ½?Failed to remove test directory: ${error.message}`);
189
- this.results.errors.push(`Test directory: ${error.message}`);
190
- }
191
- }
192
-
193
- /**
194
- * Clean CLI configurations
195
- */
196
- async cleanCLIConfigurations() {
197
- console.log('āš™ļø Cleaning CLI configurations...');
198
-
199
- let totalCleaned = 0;
200
-
201
- for (const cli of this.supportedCLIs) {
202
- const cliConfig = path.join(this.homeDir, `.${cli}`);
203
-
204
- if (!fs.existsSync(cliConfig)) {
205
- continue;
206
- }
207
-
208
- const stigmergyFiles = await this.findStigmergyFiles(cliConfig);
209
-
210
- if (stigmergyFiles.length === 0) {
211
- continue;
212
- }
213
-
214
- console.log(` šŸ“‚ ${cli}: ${stigmergyFiles.length} Stigmergy files`);
215
-
216
- if (this.options.dryRun) {
217
- this.logFiles(stigmergyFiles, ' šŸ” ');
218
- continue;
219
- }
220
-
221
- try {
222
- for (const file of stigmergyFiles) {
223
- await this.removeFile(file);
224
- totalCleaned++;
225
- }
226
- console.log(` ļæ½?Cleaned ${stigmergyFiles.length} files`);
227
- } catch (error) {
228
- console.error(` ļæ½?Failed to clean ${cli}: ${error.message}`);
229
- this.results.errors.push(`${cli} config: ${error.message}`);
230
- }
231
- }
232
-
233
- if (!this.options.dryRun && totalCleaned > 0) {
234
- console.log(` ļæ½?Cleaned ${totalCleaned} CLI configuration files`);
235
- this.results.filesRemoved += totalCleaned;
236
- }
237
- }
238
-
239
- /**
240
- * Clean NPX cache
241
- */
242
- async cleanNPXCache() {
243
- console.log('šŸ“¦ Cleaning NPX cache...');
244
-
245
- const npxCacheDirs = await this.findNPXCacheDirectories();
246
-
247
- if (npxCacheDirs.length === 0) {
248
- console.log(' ā„¹ļø No Stigmergy entries in NPX cache');
249
- return;
250
- }
251
-
252
- console.log(
253
- ` šŸ“¦ Found ${npxCacheDirs.length} Stigmergy entries in NPX cache`,
254
- );
255
-
256
- if (this.options.dryRun) {
257
- this.logFiles(npxCacheDirs, ' šŸ” ');
258
- return;
259
- }
260
-
261
- let removed = 0;
262
- for (const cacheDir of npxCacheDirs) {
263
- try {
264
- await this.removeDirectory(cacheDir);
265
- removed++;
266
- } catch (error) {
267
- console.error(` ļæ½?Failed to remove ${cacheDir}: ${error.message}`);
268
- this.results.errors.push(`NPX cache: ${error.message}`);
269
- }
270
- }
271
-
272
- if (removed > 0) {
273
- console.log(` ļæ½?Removed ${removed} NPX cache entries`);
274
- this.results.directoriesRemoved += removed;
275
- }
276
- }
277
-
278
- /**
279
- * Clean temporary files
280
- */
281
- async cleanTemporaryFiles() {
282
- console.log('šŸ—‘ļæ½? Cleaning temporary files...');
283
-
284
- const tempDirs = [
285
- path.join(os.tmpdir()),
286
- path.join(this.homeDir, 'AppData', 'Local', 'Temp'),
287
- ];
288
-
289
- let totalRemoved = 0;
290
-
291
- for (const tempDir of tempDirs) {
292
- if (!fs.existsSync(tempDir)) {
293
- continue;
294
- }
295
-
296
- try {
297
- const tempFiles = await this.findStigmergyTempFiles(tempDir);
298
-
299
- if (this.options.dryRun) {
300
- console.log(` šŸ” ${tempDir}: ${tempFiles.length} temporary files`);
301
- continue;
302
- }
303
-
304
- for (const file of tempFiles) {
305
- await this.removeFile(file);
306
- totalRemoved++;
307
- }
308
-
309
- if (tempFiles.length > 0) {
310
- console.log(
311
- ` ļæ½?${path.basename(tempDir)}: removed ${tempFiles.length} files`,
312
- );
313
- }
314
- } catch (error) {
315
- console.error(` ļæ½?Failed to clean ${tempDir}: ${error.message}`);
316
- this.results.errors.push(`Temp files: ${error.message}`);
317
- }
318
- }
319
-
320
- if (!this.options.dryRun && totalRemoved > 0) {
321
- console.log(` ļæ½?Removed ${totalRemoved} temporary files`);
322
- this.results.filesRemoved += totalRemoved;
323
- }
324
- }
325
-
326
- /**
327
- * Uninstall global packages
328
- */
329
- async uninstallGlobalPackages() {
330
- console.log('🌐 Uninstalling global packages...');
331
-
332
- const globalPackages = ['stigmergy-cli', 'stigmergy'];
333
-
334
- for (const pkg of globalPackages) {
335
- try {
336
- const result = spawnSync('npm', ['list', '-g', pkg], {
337
- encoding: 'utf8',
338
- shell: true,
339
- });
340
-
341
- if (result.status === 0 && result.stdout.includes(pkg)) {
342
- console.log(` šŸ“¦ Found global package: ${pkg}`);
343
-
344
- if (this.options.dryRun) {
345
- console.log(` šŸ” Would uninstall: ${pkg}`);
346
- continue;
347
- }
348
-
349
- const uninstallResult = spawnSync('npm', ['uninstall', '-g', pkg], {
350
- encoding: 'utf8',
351
- shell: true,
352
- stdio: 'inherit',
353
- });
354
-
355
- if (uninstallResult.status === 0) {
356
- console.log(` ļæ½?Uninstalled: ${pkg}`);
357
- } else {
358
- console.log(` āš ļø Failed to uninstall: ${pkg}`);
359
- }
360
- }
361
- } catch (error) {
362
- console.error(` ļæ½?Error checking ${pkg}: ${error.message}`);
363
- }
364
- }
365
- }
366
-
367
- /**
368
- * Helper methods
369
- */
370
- async removeDirectory(dirPath) {
371
- try {
372
- if (!fs.existsSync(dirPath)) {
373
- return false;
374
- }
375
-
376
- if (this.options.verbose) {
377
- console.log(` Removing directory: ${dirPath}`);
378
- }
379
-
380
- fs.rmSync(dirPath, { recursive: true, force: true, maxRetries: 3 });
381
- return true;
382
- } catch (error) {
383
- if (!this.options.force) {
384
- throw error;
385
- }
386
- this.results.skipped.push(`Directory: ${dirPath} (${error.message})`);
387
- return false;
388
- }
389
- }
390
-
391
- async removeFile(filePath) {
392
- try {
393
- if (!fs.existsSync(filePath)) {
394
- return false;
395
- }
396
-
397
- if (this.options.verbose) {
398
- console.log(` Removing file: ${filePath}`);
399
- }
400
-
401
- fs.unlinkSync(filePath);
402
- return true;
403
- } catch (error) {
404
- if (!this.options.force) {
405
- throw error;
406
- }
407
- this.results.skipped.push(`File: ${filePath} (${error.message})`);
408
- return false;
409
- }
410
- }
411
-
412
- async getAllFiles(dirPath) {
413
- const files = [];
414
-
415
- try {
416
- const items = fs.readdirSync(dirPath);
417
-
418
- for (const item of items) {
419
- const fullPath = path.join(dirPath, item);
420
- const stat = fs.statSync(fullPath);
421
-
422
- if (stat.isDirectory()) {
423
- files.push(...(await this.getAllFiles(fullPath)));
424
- files.push(fullPath);
425
- } else {
426
- files.push(fullPath);
427
- }
428
- }
429
-
430
- files.push(dirPath);
431
- } catch (error) {
432
- console.warn(`Warning: Could not read ${dirPath}: ${error.message}`);
433
- }
434
-
435
- return files;
436
- }
437
-
438
- async findStigmergyFiles(dirPath) {
439
- const stigmergyFiles = [];
440
-
441
- try {
442
- const files = fs.readdirSync(dirPath, { withFileTypes: true });
443
-
444
- for (const file of files) {
445
- const fullPath = path.join(dirPath, file.name);
446
-
447
- if (file.isDirectory()) {
448
- stigmergyFiles.push(...(await this.findStigmergyFiles(fullPath)));
449
- } else if (this.isStigmergyFile(file.name)) {
450
- stigmergyFiles.push(fullPath);
451
- }
452
- }
453
- } catch (error) {
454
- // Skip directories we can't read
455
- }
456
-
457
- return stigmergyFiles;
458
- }
459
-
460
- isStigmergyFile(fileName) {
461
- const stigmergyPatterns = [
462
- 'stigmergy',
463
- 'cross-cli',
464
- 'hook',
465
- 'integration',
466
- '.stigmergy',
467
- ];
468
-
469
- const lowerFileName = fileName.toLowerCase();
470
- return stigmergyPatterns.some((pattern) =>
471
- lowerFileName.includes(pattern.toLowerCase()),
472
- );
473
- }
474
-
475
- async findNPXCacheDirectories() {
476
- const cacheDirs = [];
477
- const npxCacheBase = path.join(
478
- this.homeDir,
479
- 'AppData',
480
- 'Local',
481
- 'npm-cache',
482
- '_npx',
483
- );
484
-
485
- if (!fs.existsSync(npxCacheBase)) {
486
- // Try alternative locations
487
- const alternatives = [
488
- path.join(this.homeDir, '.npm', '_npx'),
489
- path.join(os.tmpdir(), 'npm-cache', '_npx'),
490
- ];
491
-
492
- for (const alt of alternatives) {
493
- if (fs.existsSync(alt)) {
494
- npxCacheBase = alt;
495
- break;
496
- }
497
- }
498
- }
499
-
500
- if (fs.existsSync(npxCacheBase)) {
501
- try {
502
- const entries = fs.readdirSync(npxCacheBase);
503
-
504
- for (const entry of entries) {
505
- const entryPath = path.join(npxCacheBase, entry);
506
- const stigmergyPath = path.join(
507
- entryPath,
508
- 'node_modules',
509
- 'stigmergy',
510
- );
511
-
512
- if (fs.existsSync(stigmergyPath)) {
513
- cacheDirs.push(entryPath);
514
- }
515
- }
516
- } catch (error) {
517
- console.warn(`Warning: Could not scan NPX cache: ${error.message}`);
518
- }
519
- }
520
-
521
- return cacheDirs;
522
- }
523
-
524
- async findStigmergyTempFiles(tempDir) {
525
- const tempFiles = [];
526
-
527
- try {
528
- const files = fs.readdirSync(tempDir, { withFileTypes: true });
529
-
530
- for (const file of files) {
531
- if (
532
- this.isStigmergyFile(file.name) ||
533
- file.name.startsWith('stigmergy-') ||
534
- file.name.includes('stigmergy')
535
- ) {
536
- const fullPath = path.join(tempDir, file.name);
537
-
538
- if (file.isDirectory()) {
539
- tempFiles.push(fullPath);
540
- } else {
541
- tempFiles.push(fullPath);
542
- }
543
- }
544
- }
545
- } catch (error) {
546
- // Skip temp directories we can't read
547
- }
548
-
549
- return tempFiles;
550
- }
551
-
552
- async scanDirectory(dirPath, plan) {
553
- try {
554
- const stat = fs.statSync(dirPath);
555
-
556
- if (stat.isDirectory()) {
557
- const files = fs.readdirSync(dirPath, { withFileTypes: true });
558
-
559
- for (const file of files) {
560
- const fullPath = path.join(dirPath, file.name);
561
-
562
- if (file.isDirectory()) {
563
- plan.directories.push(fullPath);
564
- await this.scanDirectory(fullPath, plan);
565
- } else {
566
- plan.files.push(fullPath);
567
- }
568
- }
569
- } else {
570
- plan.files.push(dirPath);
571
- }
572
- } catch (error) {
573
- console.warn(`Warning: Could not scan ${dirPath}: ${error.message}`);
574
- }
575
- }
576
-
577
- async calculateDirectorySize(paths) {
578
- let totalSize = 0;
579
-
580
- for (const filePath of paths) {
581
- try {
582
- if (fs.existsSync(filePath)) {
583
- const stat = fs.statSync(filePath);
584
- totalSize += stat.size;
585
- }
586
- } catch (error) {
587
- // Skip files we can't stat
588
- }
589
- }
590
-
591
- return totalSize;
592
- }
593
-
594
- formatBytes(bytes) {
595
- const sizes = ['Bytes', 'KB', 'MB', 'GB'];
596
- if (bytes === 0) return '0 Bytes';
597
- const i = Math.floor(Math.log(bytes) / Math.log(1024));
598
- return Math.round((bytes / Math.pow(1024, i)) * 100) / 100 + ' ' + sizes[i];
599
- }
600
-
601
- logFiles(files, prefix = '') {
602
- files.forEach((file) => {
603
- console.log(`${prefix}${path.basename(file)}`);
604
- });
605
- }
606
-
607
- printSummary() {
608
- console.log('\nšŸ“Š UNINSTALL SUMMARY:');
609
- console.log('='.repeat(50));
610
-
611
- if (this.options.dryRun) {
612
- console.log('šŸ” DRY RUN MODE - No files were actually deleted');
613
- } else {
614
- console.log(`šŸ“ Directories removed: ${this.results.directoriesRemoved}`);
615
- console.log(`šŸ“„ Files removed: ${this.results.filesRemoved}`);
616
- }
617
-
618
- if (this.results.skipped.length > 0) {
619
- console.log(`ā­ļø Items skipped: ${this.results.skipped.length}`);
620
- if (this.options.verbose) {
621
- this.results.skipped.forEach((item) => {
622
- console.log(` ${item}`);
623
- });
624
- }
625
- }
626
-
627
- if (this.results.errors.length > 0) {
628
- console.log(`ļæ½?Errors: ${this.results.errors.length}`);
629
- this.results.errors.forEach((error) => {
630
- console.log(` ${error}`);
631
- });
632
- }
633
-
634
- console.log('\nļæ½?Enhanced uninstall completed!');
635
- }
636
- }
637
-
638
- module.exports = EnhancedUninstaller;