stigmergy 1.0.85 → 1.0.87

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 +2 -2
  2. package/src/main_english.js +194 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stigmergy",
3
- "version": "1.0.85",
3
+ "version": "1.0.87",
4
4
  "type": "commonjs",
5
5
  "description": "Stigmergy CLI - Multi-Agents Cross-AI CLI Tools Collaboration System",
6
6
  "main": "src/main_english.js",
@@ -22,7 +22,7 @@
22
22
  "dev": "node --watch src/index.js",
23
23
  "lint": "eslint src/",
24
24
  "format": "prettier --write src/",
25
- "postinstall": "node src/main_english.js setup"
25
+ "postinstall": "node src/main_english.js auto-install"
26
26
  },
27
27
  "keywords": [
28
28
  "ai",
@@ -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.85
6
+ * Version: 1.0.87
7
7
  */
8
8
 
9
9
  const { spawn, spawnSync } = require('child_process');
@@ -530,6 +530,162 @@ 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 baseName = templateFile.replace('.j2', '');
612
+ const dstFileName = `${baseName}.md`;
613
+ const dstPath = path.join(projectDir, dstFileName);
614
+
615
+ // Read template and substitute variables
616
+ const templateContent = await fs.readFile(path.join(assetsTemplatesDir, templateFile), 'utf8');
617
+ const processedContent = this.substituteTemplateVariables(templateContent);
618
+
619
+ await fs.writeFile(dstPath, processedContent);
620
+ console.log(`[OK] Deployed project doc: ${dstFileName}`);
621
+ deployedCount++;
622
+ }
623
+ }
624
+
625
+ console.log(`[RESULT] ${deployedCount} project documentation files deployed`);
626
+ return true;
627
+ } catch (error) {
628
+ console.log(`[ERROR] Failed to deploy project documentation: ${error.message}`);
629
+ return false;
630
+ }
631
+ }
632
+
633
+ substituteTemplateVariables(content) {
634
+ const now = new Date();
635
+ const projectName = path.basename(process.cwd());
636
+
637
+ const variables = {
638
+ '{{PROJECT_NAME}}': projectName,
639
+ '{{PROJECT_TYPE}}': 'Node.js Project',
640
+ '{{TECH_STACK}}': 'Node.js, JavaScript, TypeScript',
641
+ '{{CREATED_DATE}}': now.toISOString(),
642
+ '{{LAST_UPDATED}}': now.toISOString(),
643
+ '{{GENERATION_TIME}}': now.toLocaleString(),
644
+ '{{CODE_STYLE}}': 'ESLint + Prettier',
645
+ '{{TEST_FRAMEWORK}}': 'Jest',
646
+ '{{BUILD_TOOL}}': 'npm',
647
+ '{{DEPLOY_METHOD}}': 'npm publish',
648
+ '{{PRIMARY_LANGUAGE}}': 'English',
649
+ '{{TARGET_LANGUAGES}}': 'Chinese, Japanese, Spanish',
650
+ '{{DOC_STYLE}}': 'Markdown',
651
+ '{{OUTPUT_FORMAT}}': 'Markdown',
652
+ '{{RECENT_CHANGES}}': 'No recent changes recorded',
653
+ '{{KNOWN_ISSUES}}': 'No known issues',
654
+ '{{TODO_ITEMS}}': 'No todo items',
655
+ '{{TEAM_PREFERENCES}}': 'Standard development practices',
656
+ '{{TRANSLATION_PREFERENCES}}': 'Technical accuracy first',
657
+ '{{DOC_STANDARDS}}': 'Markdown with code examples',
658
+ '{{ANALYSIS_TEMPLATES}}': 'Standard analysis templates',
659
+ '{{COMMON_LANGUAGES}}': 'English, Chinese, Japanese',
660
+ '{{CHINESE_TERMINOLOGY}}': 'Standard Chinese technical terms',
661
+ '{{LOCALIZATION_STANDARDS}}': 'Chinese localization standards',
662
+ '{{USER_HABITS}}': 'Chinese user preferences',
663
+ '{{COMPLIANCE_REQUIREMENTS}}': 'Local regulations compliance',
664
+ '{{CHINESE_DOC_STYLE}}': '简体中文技术文档',
665
+ '{{ENCODING_STANDARD}}': 'UTF-8',
666
+ '{{TECHNICAL_DOMAIN}}': 'Software Development',
667
+ '{{WORKFLOW_ENGINE}}': 'iFlow CLI',
668
+ '{{EXECUTION_ENVIRONMENT}}': 'Node.js',
669
+ '{{DATA_SOURCES}}': 'Local files, APIs',
670
+ '{{OUTPUT_TARGETS}}': 'Files, databases, APIs',
671
+ '{{AGENT_COMMUNICATION_PROTOCOL}}': 'JSON-based messaging',
672
+ '{{COLLABORATION_MODE}}': 'Sequential and Parallel',
673
+ '{{DECISION_MECHANISM}}': 'Consensus-based',
674
+ '{{CONFLICT_RESOLUTION}}': 'Expert arbitration',
675
+ '{{AGENT_PROFILES}}': 'Default agent configurations',
676
+ '{{COLLABORATION_HISTORY}}': 'No history yet',
677
+ '{{DECISION_RECORDS}}': 'No decisions recorded yet',
678
+ '{{PERFORMANCE_METRICS}}': 'To be collected'
679
+ };
680
+
681
+ let processedContent = content;
682
+ for (const [placeholder, value] of Object.entries(variables)) {
683
+ processedContent = processedContent.replace(new RegExp(placeholder.replace(/[{}]/g, '\\$&'), 'g'), value);
684
+ }
685
+
686
+ return processedContent;
687
+ }
688
+
533
689
  async deployHooks(available) {
534
690
  console.log('\n[DEPLOY] Deploying cross-CLI integration hooks...');
535
691
 
@@ -543,6 +699,13 @@ class StigmergyInstaller {
543
699
  const configDir = path.dirname(toolInfo.config);
544
700
  await fs.mkdir(configDir, { recursive: true });
545
701
 
702
+ // Copy adapter files from local assets
703
+ const assetsAdaptersDir = path.join(os.homedir(), '.stigmergy', 'assets', 'adapters', toolName);
704
+ if (await this.fileExists(assetsAdaptersDir)) {
705
+ await this.copyDirectory(assetsAdaptersDir, toolInfo.hooksDir);
706
+ console.log(`[OK] Copied adapter files for ${toolInfo.name}`);
707
+ }
708
+
546
709
  console.log(`[OK] Created directories for ${toolInfo.name}`);
547
710
  console.log(`[INFO] Hooks directory: ${toolInfo.hooksDir}`);
548
711
  console.log(`[INFO] Config directory: ${configDir}`);
@@ -554,6 +717,7 @@ class StigmergyInstaller {
554
717
  console.log('\n[OK] Hook deployment completed');
555
718
  return true;
556
719
  }
720
+ }
557
721
 
558
722
  async initializeConfig() {
559
723
  console.log('\n[CONFIG] Initializing Stigmergy configuration...');
@@ -563,7 +727,7 @@ class StigmergyInstaller {
563
727
 
564
728
  const configFile = path.join(this.configDir, 'config.json');
565
729
  const config = {
566
- version: '1.0.85',
730
+ version: '1.0.87',
567
731
  initialized: true,
568
732
  createdAt: new Date().toISOString(),
569
733
  lastUpdated: new Date().toISOString(),
@@ -617,7 +781,7 @@ async function main() {
617
781
 
618
782
  if (args.length === 0 || args.includes('--help') || args.includes('-h')) {
619
783
  console.log('Stigmergy CLI - Multi-Agents Cross-AI CLI Tools Collaboration System');
620
- console.log('Version: 1.0.85');
784
+ console.log('Version: 1.0.87');
621
785
  console.log('');
622
786
  console.log('[SYSTEM] Automated Installation and Deployment System');
623
787
  console.log('');
@@ -629,7 +793,7 @@ async function main() {
629
793
  console.log(' status Check CLI tools status');
630
794
  console.log(' scan Scan for available AI CLI tools');
631
795
  console.log(' install Auto-install missing CLI tools');
632
- console.log(' deploy Deploy hooks to installed tools');
796
+ console.log(' deploy Deploy hooks and integration to installed tools');
633
797
  console.log(' setup Complete setup and configuration');
634
798
  console.log(' call <tool> Execute prompt with specified or auto-routed AI CLI');
635
799
  console.log('');
@@ -648,7 +812,7 @@ async function main() {
648
812
  switch (command) {
649
813
  case 'version':
650
814
  case '--version':
651
- console.log('Stigmergy CLI v1.0.85');
815
+ console.log('Stigmergy CLI v1.0.87');
652
816
  break;
653
817
 
654
818
  case 'status':
@@ -685,9 +849,14 @@ async function main() {
685
849
  case 'setup':
686
850
  console.log('[SETUP] Starting complete Stigmergy setup...\n');
687
851
 
852
+ // Step 1: Download required assets
853
+ await installer.downloadRequiredAssets();
854
+
855
+ // Step 2: Scan for CLI tools
688
856
  const { available: setupAvailable, missing: setupMissing } = await installer.scanCLI();
689
857
  const setupOptions = await installer.showInstallOptions(setupMissing);
690
858
 
859
+ // Step 3: Install missing CLI tools if user chooses
691
860
  if (setupOptions.length > 0) {
692
861
  const selectedTools = await installer.getUserSelection(setupOptions, setupMissing);
693
862
  if (selectedTools.length > 0) {
@@ -698,8 +867,16 @@ async function main() {
698
867
  console.log('\n[INFO] All required tools are already installed!');
699
868
  }
700
869
 
870
+ // Step 4: Deploy hooks to available CLI tools
701
871
  await installer.deployHooks(setupAvailable);
872
+
873
+ // Step 5: Deploy project documentation
874
+ await installer.deployProjectDocumentation();
875
+
876
+ // Step 6: Initialize configuration
702
877
  await installer.initializeConfig();
878
+
879
+ // Step 7: Show usage instructions
703
880
  installer.showUsageInstructions();
704
881
  break;
705
882
 
@@ -722,9 +899,13 @@ async function main() {
722
899
  console.log('[AUTO-INSTALL] Stigmergy CLI automated setup');
723
900
  console.log('='.repeat(60));
724
901
 
902
+ // Step 1: Download required assets
903
+ await installer.downloadRequiredAssets();
904
+
905
+ // Step 2: Scan for CLI tools
725
906
  const { available: autoAvailable, missing: autoMissing } = await installer.scanCLI();
726
907
 
727
- // Show summary to user after installation
908
+ // Step 3: Show summary to user after installation
728
909
  if (Object.keys(autoMissing).length > 0) {
729
910
  console.log('\n[INFO] Found ' + Object.keys(autoMissing).length + ' missing AI CLI tools:');
730
911
  for (const [toolName, toolInfo] of Object.entries(autoMissing)) {
@@ -736,10 +917,16 @@ async function main() {
736
917
  console.log('\n[INFO] All AI CLI tools are already installed! No additional tools required.');
737
918
  }
738
919
 
920
+ // Step 4: Deploy hooks to available CLI tools
739
921
  await installer.deployHooks(autoAvailable);
922
+
923
+ // Step 5: Deploy project documentation
924
+ await installer.deployProjectDocumentation();
925
+
926
+ // Step 6: Initialize configuration
740
927
  await installer.initializeConfig();
741
928
 
742
- // Show final message to guide users
929
+ // Step 7: Show final message to guide users
743
930
  console.log('\n[SUCCESS] Stigmergy CLI installed successfully!');
744
931
  console.log('[USAGE] Run "stigmergy setup" to complete full configuration and install missing AI CLI tools.');
745
932
  console.log('[USAGE] Run "stigmergy install" to install only missing AI CLI tools.');