stigmergy 1.0.86 → 1.0.88

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/main_english.js +192 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stigmergy",
3
- "version": "1.0.86",
3
+ "version": "1.0.88",
4
4
  "type": "commonjs",
5
5
  "description": "Stigmergy CLI - Multi-Agents Cross-AI CLI Tools Collaboration System",
6
6
  "main": "src/main_english.js",
@@ -3,7 +3,7 @@
3
3
  /**
4
4
  * Stigmergy CLI - Multi-Agents Cross-AI CLI Tools Collaboration System
5
5
  * International Version - Pure English & ANSI Only
6
- * Version: 1.0.86
6
+ * Version: 1.0.88
7
7
  */
8
8
 
9
9
  const { spawn, spawnSync } = require('child_process');
@@ -530,6 +530,161 @@ class StigmergyInstaller {
530
530
  return true;
531
531
  }
532
532
 
533
+ async downloadRequiredAssets() {
534
+ console.log('\n[DOWNLOAD] Downloading required assets and plugins...');
535
+
536
+ try {
537
+ // Create local assets directory
538
+ const assetsDir = path.join(os.homedir(), '.stigmergy', 'assets');
539
+ await fs.mkdir(assetsDir, { recursive: true });
540
+
541
+ // Copy template files from package
542
+ const packageTemplatesDir = path.join(__dirname, '..', 'templates', 'project-docs');
543
+ const localTemplatesDir = path.join(assetsDir, 'templates');
544
+
545
+ if (await this.fileExists(packageTemplatesDir)) {
546
+ await fs.mkdir(localTemplatesDir, { recursive: true });
547
+
548
+ // Copy all template files
549
+ const templateFiles = await fs.readdir(packageTemplatesDir);
550
+ for (const file of templateFiles) {
551
+ const srcPath = path.join(packageTemplatesDir, file);
552
+ const dstPath = path.join(localTemplatesDir, file);
553
+ await fs.copyFile(srcPath, dstPath);
554
+ console.log(`[OK] Copied template: ${file}`);
555
+ }
556
+ }
557
+
558
+ // Download/copy CLI adapters
559
+ const adaptersDir = path.join(__dirname, '..', 'src', 'adapters');
560
+ const localAdaptersDir = path.join(assetsDir, 'adapters');
561
+
562
+ if (await this.fileExists(adaptersDir)) {
563
+ await fs.mkdir(localAdaptersDir, { recursive: true });
564
+
565
+ // Copy adapter files recursively
566
+ await this.copyDirectory(adaptersDir, localAdaptersDir);
567
+ console.log(`[OK] Copied CLI adapters to ${localAdaptersDir}`);
568
+ }
569
+
570
+ console.log('[OK] Required assets downloaded successfully');
571
+ return true;
572
+ } catch (error) {
573
+ console.log(`[ERROR] Failed to download assets: ${error.message}`);
574
+ return false;
575
+ }
576
+ }
577
+
578
+ async copyDirectory(src, dst) {
579
+ await fs.mkdir(dst, { recursive: true });
580
+ const entries = await fs.readdir(src, { withFileTypes: true });
581
+
582
+ for (const entry of entries) {
583
+ const srcPath = path.join(src, entry.name);
584
+ const dstPath = path.join(dst, entry.name);
585
+
586
+ if (entry.isDirectory()) {
587
+ await this.copyDirectory(srcPath, dstPath);
588
+ } else {
589
+ await fs.copyFile(srcPath, dstPath);
590
+ }
591
+ }
592
+ }
593
+
594
+ async deployProjectDocumentation() {
595
+ console.log('\n[DEPLOY] Deploying project documentation...');
596
+
597
+ try {
598
+ const projectDir = process.cwd();
599
+ const assetsTemplatesDir = path.join(os.homedir(), '.stigmergy', 'assets', 'templates');
600
+
601
+ if (!(await this.fileExists(assetsTemplatesDir))) {
602
+ console.log('[SKIP] No template files found');
603
+ return true;
604
+ }
605
+
606
+ const templateFiles = await fs.readdir(assetsTemplatesDir);
607
+ let deployedCount = 0;
608
+
609
+ for (const templateFile of templateFiles) {
610
+ if (templateFile.endsWith('.j2')) {
611
+ const dstFileName = templateFile.replace('.j2', '');
612
+ const dstPath = path.join(projectDir, dstFileName);
613
+
614
+ // Read template and substitute variables
615
+ const templateContent = await fs.readFile(path.join(assetsTemplatesDir, templateFile), 'utf8');
616
+ const processedContent = this.substituteTemplateVariables(templateContent);
617
+
618
+ await fs.writeFile(dstPath, processedContent);
619
+ console.log(`[OK] Deployed project doc: ${dstFileName}`);
620
+ deployedCount++;
621
+ }
622
+ }
623
+
624
+ console.log(`[RESULT] ${deployedCount} project documentation files deployed`);
625
+ return true;
626
+ } catch (error) {
627
+ console.log(`[ERROR] Failed to deploy project documentation: ${error.message}`);
628
+ return false;
629
+ }
630
+ }
631
+
632
+ substituteTemplateVariables(content) {
633
+ const now = new Date();
634
+ const projectName = path.basename(process.cwd());
635
+
636
+ const variables = {
637
+ '{{PROJECT_NAME}}': projectName,
638
+ '{{PROJECT_TYPE}}': 'Node.js Project',
639
+ '{{TECH_STACK}}': 'Node.js, JavaScript, TypeScript',
640
+ '{{CREATED_DATE}}': now.toISOString(),
641
+ '{{LAST_UPDATED}}': now.toISOString(),
642
+ '{{GENERATION_TIME}}': now.toLocaleString(),
643
+ '{{CODE_STYLE}}': 'ESLint + Prettier',
644
+ '{{TEST_FRAMEWORK}}': 'Jest',
645
+ '{{BUILD_TOOL}}': 'npm',
646
+ '{{DEPLOY_METHOD}}': 'npm publish',
647
+ '{{PRIMARY_LANGUAGE}}': 'English',
648
+ '{{TARGET_LANGUAGES}}': 'Chinese, Japanese, Spanish',
649
+ '{{DOC_STYLE}}': 'Markdown',
650
+ '{{OUTPUT_FORMAT}}': 'Markdown',
651
+ '{{RECENT_CHANGES}}': 'No recent changes recorded',
652
+ '{{KNOWN_ISSUES}}': 'No known issues',
653
+ '{{TODO_ITEMS}}': 'No todo items',
654
+ '{{TEAM_PREFERENCES}}': 'Standard development practices',
655
+ '{{TRANSLATION_PREFERENCES}}': 'Technical accuracy first',
656
+ '{{DOC_STANDARDS}}': 'Markdown with code examples',
657
+ '{{ANALYSIS_TEMPLATES}}': 'Standard analysis templates',
658
+ '{{COMMON_LANGUAGES}}': 'English, Chinese, Japanese',
659
+ '{{CHINESE_TERMINOLOGY}}': 'Standard Chinese technical terms',
660
+ '{{LOCALIZATION_STANDARDS}}': 'Chinese localization standards',
661
+ '{{USER_HABITS}}': 'Chinese user preferences',
662
+ '{{COMPLIANCE_REQUIREMENTS}}': 'Local regulations compliance',
663
+ '{{CHINESE_DOC_STYLE}}': '简体中文技术文档',
664
+ '{{ENCODING_STANDARD}}': 'UTF-8',
665
+ '{{TECHNICAL_DOMAIN}}': 'Software Development',
666
+ '{{WORKFLOW_ENGINE}}': 'iFlow CLI',
667
+ '{{EXECUTION_ENVIRONMENT}}': 'Node.js',
668
+ '{{DATA_SOURCES}}': 'Local files, APIs',
669
+ '{{OUTPUT_TARGETS}}': 'Files, databases, APIs',
670
+ '{{AGENT_COMMUNICATION_PROTOCOL}}': 'JSON-based messaging',
671
+ '{{COLLABORATION_MODE}}': 'Sequential and Parallel',
672
+ '{{DECISION_MECHANISM}}': 'Consensus-based',
673
+ '{{CONFLICT_RESOLUTION}}': 'Expert arbitration',
674
+ '{{AGENT_PROFILES}}': 'Default agent configurations',
675
+ '{{COLLABORATION_HISTORY}}': 'No history yet',
676
+ '{{DECISION_RECORDS}}': 'No decisions recorded yet',
677
+ '{{PERFORMANCE_METRICS}}': 'To be collected'
678
+ };
679
+
680
+ let processedContent = content;
681
+ for (const [placeholder, value] of Object.entries(variables)) {
682
+ processedContent = processedContent.replace(new RegExp(placeholder.replace(/[{}]/g, '\\$&'), 'g'), value);
683
+ }
684
+
685
+ return processedContent;
686
+ }
687
+
533
688
  async deployHooks(available) {
534
689
  console.log('\n[DEPLOY] Deploying cross-CLI integration hooks...');
535
690
 
@@ -543,6 +698,13 @@ class StigmergyInstaller {
543
698
  const configDir = path.dirname(toolInfo.config);
544
699
  await fs.mkdir(configDir, { recursive: true });
545
700
 
701
+ // Copy adapter files from local assets
702
+ const assetsAdaptersDir = path.join(os.homedir(), '.stigmergy', 'assets', 'adapters', toolName);
703
+ if (await this.fileExists(assetsAdaptersDir)) {
704
+ await this.copyDirectory(assetsAdaptersDir, toolInfo.hooksDir);
705
+ console.log(`[OK] Copied adapter files for ${toolInfo.name}`);
706
+ }
707
+
546
708
  console.log(`[OK] Created directories for ${toolInfo.name}`);
547
709
  console.log(`[INFO] Hooks directory: ${toolInfo.hooksDir}`);
548
710
  console.log(`[INFO] Config directory: ${configDir}`);
@@ -563,7 +725,7 @@ class StigmergyInstaller {
563
725
 
564
726
  const configFile = path.join(this.configDir, 'config.json');
565
727
  const config = {
566
- version: '1.0.86',
728
+ version: '1.0.88',
567
729
  initialized: true,
568
730
  createdAt: new Date().toISOString(),
569
731
  lastUpdated: new Date().toISOString(),
@@ -617,7 +779,7 @@ async function main() {
617
779
 
618
780
  if (args.length === 0 || args.includes('--help') || args.includes('-h')) {
619
781
  console.log('Stigmergy CLI - Multi-Agents Cross-AI CLI Tools Collaboration System');
620
- console.log('Version: 1.0.86');
782
+ console.log('Version: 1.0.88');
621
783
  console.log('');
622
784
  console.log('[SYSTEM] Automated Installation and Deployment System');
623
785
  console.log('');
@@ -629,7 +791,7 @@ async function main() {
629
791
  console.log(' status Check CLI tools status');
630
792
  console.log(' scan Scan for available AI CLI tools');
631
793
  console.log(' install Auto-install missing CLI tools');
632
- console.log(' deploy Deploy hooks to installed tools');
794
+ console.log(' deploy Deploy hooks and integration to installed tools');
633
795
  console.log(' setup Complete setup and configuration');
634
796
  console.log(' call <tool> Execute prompt with specified or auto-routed AI CLI');
635
797
  console.log('');
@@ -648,7 +810,7 @@ async function main() {
648
810
  switch (command) {
649
811
  case 'version':
650
812
  case '--version':
651
- console.log('Stigmergy CLI v1.0.86');
813
+ console.log('Stigmergy CLI v1.0.88');
652
814
  break;
653
815
 
654
816
  case 'status':
@@ -685,9 +847,14 @@ async function main() {
685
847
  case 'setup':
686
848
  console.log('[SETUP] Starting complete Stigmergy setup...\n');
687
849
 
850
+ // Step 1: Download required assets
851
+ await installer.downloadRequiredAssets();
852
+
853
+ // Step 2: Scan for CLI tools
688
854
  const { available: setupAvailable, missing: setupMissing } = await installer.scanCLI();
689
855
  const setupOptions = await installer.showInstallOptions(setupMissing);
690
856
 
857
+ // Step 3: Install missing CLI tools if user chooses
691
858
  if (setupOptions.length > 0) {
692
859
  const selectedTools = await installer.getUserSelection(setupOptions, setupMissing);
693
860
  if (selectedTools.length > 0) {
@@ -698,8 +865,16 @@ async function main() {
698
865
  console.log('\n[INFO] All required tools are already installed!');
699
866
  }
700
867
 
868
+ // Step 4: Deploy hooks to available CLI tools
701
869
  await installer.deployHooks(setupAvailable);
870
+
871
+ // Step 5: Deploy project documentation
872
+ await installer.deployProjectDocumentation();
873
+
874
+ // Step 6: Initialize configuration
702
875
  await installer.initializeConfig();
876
+
877
+ // Step 7: Show usage instructions
703
878
  installer.showUsageInstructions();
704
879
  break;
705
880
 
@@ -722,9 +897,13 @@ async function main() {
722
897
  console.log('[AUTO-INSTALL] Stigmergy CLI automated setup');
723
898
  console.log('='.repeat(60));
724
899
 
900
+ // Step 1: Download required assets
901
+ await installer.downloadRequiredAssets();
902
+
903
+ // Step 2: Scan for CLI tools
725
904
  const { available: autoAvailable, missing: autoMissing } = await installer.scanCLI();
726
905
 
727
- // Show summary to user after installation
906
+ // Step 3: Show summary to user after installation
728
907
  if (Object.keys(autoMissing).length > 0) {
729
908
  console.log('\n[INFO] Found ' + Object.keys(autoMissing).length + ' missing AI CLI tools:');
730
909
  for (const [toolName, toolInfo] of Object.entries(autoMissing)) {
@@ -736,10 +915,16 @@ async function main() {
736
915
  console.log('\n[INFO] All AI CLI tools are already installed! No additional tools required.');
737
916
  }
738
917
 
918
+ // Step 4: Deploy hooks to available CLI tools
739
919
  await installer.deployHooks(autoAvailable);
920
+
921
+ // Step 5: Deploy project documentation
922
+ await installer.deployProjectDocumentation();
923
+
924
+ // Step 6: Initialize configuration
740
925
  await installer.initializeConfig();
741
926
 
742
- // Show final message to guide users
927
+ // Step 7: Show final message to guide users
743
928
  console.log('\n[SUCCESS] Stigmergy CLI installed successfully!');
744
929
  console.log('[USAGE] Run "stigmergy setup" to complete full configuration and install missing AI CLI tools.');
745
930
  console.log('[USAGE] Run "stigmergy install" to install only missing AI CLI tools.');