proagents 1.6.12 → 1.6.15

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 (40) hide show
  1. package/.proagents/.cursorrules +16 -2
  2. package/.proagents/.learning/global/common-patterns.template.json +60 -0
  3. package/.proagents/.learning/global/user-preferences.template.json +78 -0
  4. package/.proagents/.windsurfrules +16 -2
  5. package/.proagents/AGENTS.md +55 -0
  6. package/.proagents/AI_INSTRUCTIONS.md +1252 -53
  7. package/.proagents/ANTIGRAVITY.md +16 -2
  8. package/.proagents/BOLT.md +16 -2
  9. package/.proagents/CHATGPT.md +16 -2
  10. package/.proagents/CLAUDE.md +16 -2
  11. package/.proagents/GEMINI.md +16 -2
  12. package/.proagents/GROQ.md +16 -2
  13. package/.proagents/KIRO.md +16 -2
  14. package/.proagents/LOVABLE.md +16 -2
  15. package/.proagents/PROAGENTS.md +52 -26
  16. package/.proagents/REPLIT.md +16 -2
  17. package/.proagents/active-features/_index.template.json +75 -0
  18. package/.proagents/changelog/_recent.template.md +51 -0
  19. package/.proagents/docs/command-details.md +985 -82
  20. package/.proagents/worklog/_context.md +31 -1
  21. package/.proagents/worklog/_context.template.md +82 -0
  22. package/.proagents/worklog/ai-stats.json +19 -0
  23. package/.proagents/worklog/ai-stats.template.json +54 -0
  24. package/README.md +85 -1
  25. package/bin/proagents.js +132 -1
  26. package/lib/commands/ai.js +103 -11
  27. package/lib/commands/changelog.js +389 -0
  28. package/lib/commands/completion.js +413 -0
  29. package/lib/commands/config.js +248 -0
  30. package/lib/commands/doctor.js +222 -25
  31. package/lib/commands/help.js +22 -2
  32. package/lib/commands/init.js +171 -2
  33. package/lib/commands/open.js +188 -0
  34. package/lib/commands/release.js +1007 -0
  35. package/lib/commands/restore.js +150 -0
  36. package/lib/commands/stats.js +320 -0
  37. package/lib/commands/uninstall.js +98 -4
  38. package/lib/commands/upgrade.js +102 -10
  39. package/lib/commands/version.js +140 -0
  40. package/package.json +1 -1
@@ -0,0 +1,413 @@
1
+ import chalk from 'chalk';
2
+
3
+ /**
4
+ * Generate bash completion script
5
+ */
6
+ function generateBashCompletion() {
7
+ return `# ProAgents bash completion
8
+ # Add this to ~/.bashrc or ~/.bash_completion
9
+
10
+ _proagents_completions() {
11
+ local cur prev opts commands subcommands
12
+ COMPREPLY=()
13
+ cur="\${COMP_WORDS[COMP_CWORD]}"
14
+ prev="\${COMP_WORDS[COMP_CWORD-1]}"
15
+
16
+ # Main commands
17
+ commands="init feature fix status docs ai config uninstall commands doctor upgrade migrate version release stats restore changelog completion"
18
+
19
+ # Subcommands for specific commands
20
+ case "\${COMP_WORDS[1]}" in
21
+ feature)
22
+ subcommands="start status list complete"
23
+ COMPREPLY=( \$(compgen -W "\${subcommands}" -- \${cur}) )
24
+ return 0
25
+ ;;
26
+ ai)
27
+ subcommands="add list remove"
28
+ COMPREPLY=( \$(compgen -W "\${subcommands}" -- \${cur}) )
29
+ return 0
30
+ ;;
31
+ config)
32
+ subcommands="list show edit set get setup customize export import"
33
+ COMPREPLY=( \$(compgen -W "\${subcommands}" -- \${cur}) )
34
+ return 0
35
+ ;;
36
+ changelog)
37
+ subcommands="view add list export feature module git"
38
+ COMPREPLY=( \$(compgen -W "\${subcommands}" -- \${cur}) )
39
+ return 0
40
+ ;;
41
+ release)
42
+ if [[ \${cur} == -* ]]; then
43
+ opts="-t --type -v --version -o --output -a --append -i --include -e --exclude -m --module -p --path --since --until --bump --prerelease --urgency --interactive --changelog --tag --tag-message --json"
44
+ COMPREPLY=( \$(compgen -W "\${opts}" -- \${cur}) )
45
+ return 0
46
+ fi
47
+ ;;
48
+ completion)
49
+ subcommands="bash zsh fish"
50
+ COMPREPLY=( \$(compgen -W "\${subcommands}" -- \${cur}) )
51
+ return 0
52
+ ;;
53
+ esac
54
+
55
+ # Options for specific commands
56
+ case "\${prev}" in
57
+ -t|--type)
58
+ COMPREPLY=( \$(compgen -W "detailed short client developer hotfix prerelease" -- \${cur}) )
59
+ return 0
60
+ ;;
61
+ --prerelease)
62
+ COMPREPLY=( \$(compgen -W "alpha beta rc" -- \${cur}) )
63
+ return 0
64
+ ;;
65
+ --urgency)
66
+ COMPREPLY=( \$(compgen -W "low medium high critical" -- \${cur}) )
67
+ return 0
68
+ ;;
69
+ -i|--include|-e|--exclude)
70
+ COMPREPLY=( \$(compgen -W "features fixes improvements security breaking docs deps perf" -- \${cur}) )
71
+ return 0
72
+ ;;
73
+ esac
74
+
75
+ # Complete file paths for specific arguments
76
+ case "\${prev}" in
77
+ restore|import)
78
+ COMPREPLY=( \$(compgen -f -- \${cur}) )
79
+ return 0
80
+ ;;
81
+ -o|--output)
82
+ COMPREPLY=( \$(compgen -f -- \${cur}) )
83
+ return 0
84
+ ;;
85
+ esac
86
+
87
+ # Default to main commands
88
+ if [[ \${COMP_CWORD} -eq 1 ]]; then
89
+ COMPREPLY=( \$(compgen -W "\${commands}" -- \${cur}) )
90
+ fi
91
+ }
92
+
93
+ complete -F _proagents_completions proagents
94
+ complete -F _proagents_completions pa
95
+ `;
96
+ }
97
+
98
+ /**
99
+ * Generate zsh completion script
100
+ */
101
+ function generateZshCompletion() {
102
+ return `#compdef proagents pa
103
+
104
+ # ProAgents zsh completion
105
+ # Add this to ~/.zshrc or save to ~/.zsh/completions/_proagents
106
+
107
+ _proagents() {
108
+ local -a commands subcommands options
109
+
110
+ commands=(
111
+ 'init:Initialize ProAgents in the current project'
112
+ 'feature:Feature development commands'
113
+ 'fix:Quick bug fix mode'
114
+ 'status:Show ProAgents status in current project'
115
+ 'docs:Open ProAgents documentation'
116
+ 'ai:Manage AI platform instruction files'
117
+ 'config:Manage ProAgents configuration'
118
+ 'uninstall:Remove ProAgents from current project'
119
+ 'commands:Show all available commands with examples'
120
+ 'doctor:Check health of ProAgents installation'
121
+ 'upgrade:Upgrade .proagents folder to latest version'
122
+ 'migrate:Migrate from proagents/ to .proagents/ folder structure'
123
+ 'version:Show detailed version information'
124
+ 'release:Generate release notes with type selection'
125
+ 'stats:Show project and AI usage statistics'
126
+ 'restore:Restore ProAgents data from backup'
127
+ 'changelog:Manage project changelogs'
128
+ 'completion:Generate shell completion scripts'
129
+ )
130
+
131
+ _arguments -C \\
132
+ '1: :->command' \\
133
+ '*: :->args'
134
+
135
+ case \$state in
136
+ command)
137
+ _describe 'command' commands
138
+ ;;
139
+ args)
140
+ case \$words[2] in
141
+ feature)
142
+ subcommands=(
143
+ 'start:Start a new feature'
144
+ 'status:Check current feature status'
145
+ 'list:List all features'
146
+ 'complete:Mark current feature as complete'
147
+ )
148
+ _describe 'subcommand' subcommands
149
+ ;;
150
+ ai)
151
+ subcommands=(
152
+ 'add:Add more AI platforms'
153
+ 'list:List installed AI platforms'
154
+ 'remove:Remove AI platforms from config'
155
+ )
156
+ _describe 'subcommand' subcommands
157
+ ;;
158
+ config)
159
+ subcommands=(
160
+ 'list:Show all configurable options'
161
+ 'show:Show current config values'
162
+ 'edit:Info on how to edit config'
163
+ 'set:Set a config value'
164
+ 'get:Get a config value'
165
+ 'setup:Interactive configuration wizard'
166
+ 'customize:Copy templates to create custom configurations'
167
+ 'export:Export configuration for sharing or backup'
168
+ 'import:Import configuration from export file'
169
+ )
170
+ _describe 'subcommand' subcommands
171
+ ;;
172
+ changelog)
173
+ subcommands=(
174
+ 'view:View recent changelog entries'
175
+ 'add:Add a new changelog entry'
176
+ 'list:List available changelogs'
177
+ 'export:Export changelog to CHANGELOG.md'
178
+ 'feature:View changelog for a specific feature'
179
+ 'module:View changelog for a specific module'
180
+ 'git:View git commit history as changelog'
181
+ )
182
+ _describe 'subcommand' subcommands
183
+ ;;
184
+ completion)
185
+ subcommands=(
186
+ 'bash:Generate bash completion script'
187
+ 'zsh:Generate zsh completion script'
188
+ 'fish:Generate fish completion script'
189
+ )
190
+ _describe 'subcommand' subcommands
191
+ ;;
192
+ release)
193
+ options=(
194
+ '-t[Release type]:type:(detailed short client developer hotfix prerelease)'
195
+ '--type[Release type]:type:(detailed short client developer hotfix prerelease)'
196
+ '-v[Version number]:version:'
197
+ '--version[Version number]:version:'
198
+ '-o[Output to file]:file:_files'
199
+ '--output[Output to file]:file:_files'
200
+ '-a[Append to existing release notes]'
201
+ '--append[Append to existing release notes]'
202
+ '-i[Include only categories]:categories:'
203
+ '--include[Include only categories]:categories:'
204
+ '-e[Exclude categories]:categories:'
205
+ '--exclude[Exclude categories]:categories:'
206
+ '-m[Filter by module name]:module:'
207
+ '--module[Filter by module name]:module:'
208
+ '-p[Filter by file path]:path:_files'
209
+ '--path[Filter by file path]:path:_files'
210
+ '--since[Start from tag/commit/date]:ref:'
211
+ '--until[End at tag/commit/date]:ref:'
212
+ '--bump[Suggest version bump based on changes]'
213
+ '--prerelease[Mark as pre-release]:stage:(alpha beta rc)'
214
+ '--urgency[Hotfix urgency level]:level:(low medium high critical)'
215
+ '--interactive[Interactive mode with filter selection]'
216
+ '--changelog[Update CHANGELOG.md with release notes]'
217
+ '--tag[Create git tag for this release]'
218
+ '--tag-message[Custom message for git tag]:message:'
219
+ '--json[Output in JSON format]'
220
+ )
221
+ _arguments \$options
222
+ ;;
223
+ restore)
224
+ _arguments \\
225
+ '-f[Skip confirmation prompt]' \\
226
+ '--force[Skip confirmation prompt]' \\
227
+ '-q[Minimal output]' \\
228
+ '--quiet[Minimal output]' \\
229
+ '--json[Output in JSON format]' \\
230
+ '1:backup file:_files -g "*.json"'
231
+ ;;
232
+ esac
233
+ ;;
234
+ esac
235
+ }
236
+
237
+ _proagents "\$@"
238
+ `;
239
+ }
240
+
241
+ /**
242
+ * Generate fish completion script
243
+ */
244
+ function generateFishCompletion() {
245
+ return `# ProAgents fish completion
246
+ # Save to ~/.config/fish/completions/proagents.fish
247
+
248
+ # Disable file completion by default
249
+ complete -c proagents -f
250
+
251
+ # Main commands
252
+ complete -c proagents -n "__fish_use_subcommand" -a init -d "Initialize ProAgents in the current project"
253
+ complete -c proagents -n "__fish_use_subcommand" -a feature -d "Feature development commands"
254
+ complete -c proagents -n "__fish_use_subcommand" -a fix -d "Quick bug fix mode"
255
+ complete -c proagents -n "__fish_use_subcommand" -a status -d "Show ProAgents status in current project"
256
+ complete -c proagents -n "__fish_use_subcommand" -a docs -d "Open ProAgents documentation"
257
+ complete -c proagents -n "__fish_use_subcommand" -a ai -d "Manage AI platform instruction files"
258
+ complete -c proagents -n "__fish_use_subcommand" -a config -d "Manage ProAgents configuration"
259
+ complete -c proagents -n "__fish_use_subcommand" -a uninstall -d "Remove ProAgents from current project"
260
+ complete -c proagents -n "__fish_use_subcommand" -a commands -d "Show all available commands with examples"
261
+ complete -c proagents -n "__fish_use_subcommand" -a doctor -d "Check health of ProAgents installation"
262
+ complete -c proagents -n "__fish_use_subcommand" -a upgrade -d "Upgrade .proagents folder to latest version"
263
+ complete -c proagents -n "__fish_use_subcommand" -a migrate -d "Migrate from proagents/ to .proagents/"
264
+ complete -c proagents -n "__fish_use_subcommand" -a version -d "Show detailed version information"
265
+ complete -c proagents -n "__fish_use_subcommand" -a release -d "Generate release notes with type selection"
266
+ complete -c proagents -n "__fish_use_subcommand" -a stats -d "Show project and AI usage statistics"
267
+ complete -c proagents -n "__fish_use_subcommand" -a restore -d "Restore ProAgents data from backup"
268
+ complete -c proagents -n "__fish_use_subcommand" -a changelog -d "Manage project changelogs"
269
+ complete -c proagents -n "__fish_use_subcommand" -a completion -d "Generate shell completion scripts"
270
+
271
+ # Feature subcommands
272
+ complete -c proagents -n "__fish_seen_subcommand_from feature" -a start -d "Start a new feature"
273
+ complete -c proagents -n "__fish_seen_subcommand_from feature" -a status -d "Check current feature status"
274
+ complete -c proagents -n "__fish_seen_subcommand_from feature" -a list -d "List all features"
275
+ complete -c proagents -n "__fish_seen_subcommand_from feature" -a complete -d "Mark current feature as complete"
276
+
277
+ # AI subcommands
278
+ complete -c proagents -n "__fish_seen_subcommand_from ai" -a add -d "Add more AI platforms"
279
+ complete -c proagents -n "__fish_seen_subcommand_from ai" -a list -d "List installed AI platforms"
280
+ complete -c proagents -n "__fish_seen_subcommand_from ai" -a remove -d "Remove AI platforms from config"
281
+
282
+ # Config subcommands
283
+ complete -c proagents -n "__fish_seen_subcommand_from config" -a list -d "Show all configurable options"
284
+ complete -c proagents -n "__fish_seen_subcommand_from config" -a show -d "Show current config values"
285
+ complete -c proagents -n "__fish_seen_subcommand_from config" -a edit -d "Info on how to edit config"
286
+ complete -c proagents -n "__fish_seen_subcommand_from config" -a set -d "Set a config value"
287
+ complete -c proagents -n "__fish_seen_subcommand_from config" -a get -d "Get a config value"
288
+ complete -c proagents -n "__fish_seen_subcommand_from config" -a setup -d "Interactive configuration wizard"
289
+ complete -c proagents -n "__fish_seen_subcommand_from config" -a customize -d "Copy templates to create custom configurations"
290
+ complete -c proagents -n "__fish_seen_subcommand_from config" -a export -d "Export configuration for sharing or backup"
291
+ complete -c proagents -n "__fish_seen_subcommand_from config" -a import -d "Import configuration from export file"
292
+
293
+ # Changelog subcommands
294
+ complete -c proagents -n "__fish_seen_subcommand_from changelog" -a view -d "View recent changelog entries"
295
+ complete -c proagents -n "__fish_seen_subcommand_from changelog" -a add -d "Add a new changelog entry"
296
+ complete -c proagents -n "__fish_seen_subcommand_from changelog" -a list -d "List available changelogs"
297
+ complete -c proagents -n "__fish_seen_subcommand_from changelog" -a export -d "Export changelog to CHANGELOG.md"
298
+ complete -c proagents -n "__fish_seen_subcommand_from changelog" -a feature -d "View changelog for a specific feature"
299
+ complete -c proagents -n "__fish_seen_subcommand_from changelog" -a module -d "View changelog for a specific module"
300
+ complete -c proagents -n "__fish_seen_subcommand_from changelog" -a git -d "View git commit history as changelog"
301
+
302
+ # Completion subcommands
303
+ complete -c proagents -n "__fish_seen_subcommand_from completion" -a bash -d "Generate bash completion script"
304
+ complete -c proagents -n "__fish_seen_subcommand_from completion" -a zsh -d "Generate zsh completion script"
305
+ complete -c proagents -n "__fish_seen_subcommand_from completion" -a fish -d "Generate fish completion script"
306
+
307
+ # Release options
308
+ complete -c proagents -n "__fish_seen_subcommand_from release" -s t -l type -d "Release type" -xa "detailed short client developer hotfix prerelease"
309
+ complete -c proagents -n "__fish_seen_subcommand_from release" -s v -l version -d "Version number"
310
+ complete -c proagents -n "__fish_seen_subcommand_from release" -s o -l output -d "Output to file" -r
311
+ complete -c proagents -n "__fish_seen_subcommand_from release" -s a -l append -d "Append to existing release notes"
312
+ complete -c proagents -n "__fish_seen_subcommand_from release" -s i -l include -d "Include only categories"
313
+ complete -c proagents -n "__fish_seen_subcommand_from release" -s e -l exclude -d "Exclude categories"
314
+ complete -c proagents -n "__fish_seen_subcommand_from release" -s m -l module -d "Filter by module name"
315
+ complete -c proagents -n "__fish_seen_subcommand_from release" -s p -l path -d "Filter by file path" -r
316
+ complete -c proagents -n "__fish_seen_subcommand_from release" -l since -d "Start from tag/commit/date"
317
+ complete -c proagents -n "__fish_seen_subcommand_from release" -l until -d "End at tag/commit/date"
318
+ complete -c proagents -n "__fish_seen_subcommand_from release" -l bump -d "Suggest version bump based on changes"
319
+ complete -c proagents -n "__fish_seen_subcommand_from release" -l prerelease -d "Mark as pre-release" -xa "alpha beta rc"
320
+ complete -c proagents -n "__fish_seen_subcommand_from release" -l urgency -d "Hotfix urgency level" -xa "low medium high critical"
321
+ complete -c proagents -n "__fish_seen_subcommand_from release" -l interactive -d "Interactive mode with filter selection"
322
+ complete -c proagents -n "__fish_seen_subcommand_from release" -l changelog -d "Update CHANGELOG.md with release notes"
323
+ complete -c proagents -n "__fish_seen_subcommand_from release" -l tag -d "Create git tag for this release"
324
+ complete -c proagents -n "__fish_seen_subcommand_from release" -l tag-message -d "Custom message for git tag"
325
+ complete -c proagents -n "__fish_seen_subcommand_from release" -l json -d "Output in JSON format"
326
+
327
+ # Stats options
328
+ complete -c proagents -n "__fish_seen_subcommand_from stats" -l json -d "Output in JSON format"
329
+
330
+ # Restore options
331
+ complete -c proagents -n "__fish_seen_subcommand_from restore" -s f -l force -d "Skip confirmation prompt"
332
+ complete -c proagents -n "__fish_seen_subcommand_from restore" -s q -l quiet -d "Minimal output"
333
+ complete -c proagents -n "__fish_seen_subcommand_from restore" -l json -d "Output in JSON format"
334
+
335
+ # Alias for pa
336
+ complete -c pa -w proagents
337
+ `;
338
+ }
339
+
340
+ /**
341
+ * Completion command - generate shell completions
342
+ */
343
+ export async function completionCommand(shell, options = {}) {
344
+ // If no shell specified, try to detect
345
+ if (!shell) {
346
+ const shellEnv = process.env.SHELL || '';
347
+ if (shellEnv.includes('zsh')) {
348
+ shell = 'zsh';
349
+ } else if (shellEnv.includes('fish')) {
350
+ shell = 'fish';
351
+ } else {
352
+ shell = 'bash';
353
+ }
354
+
355
+ if (!options.quiet) {
356
+ console.error(chalk.gray(`Detected shell: ${shell}\n`));
357
+ }
358
+ }
359
+
360
+ let script;
361
+ let installInstructions;
362
+
363
+ switch (shell.toLowerCase()) {
364
+ case 'bash':
365
+ script = generateBashCompletion();
366
+ installInstructions = `
367
+ ${chalk.cyan('To install:')}
368
+ ${chalk.white('# Add to ~/.bashrc:')}
369
+ ${chalk.green('proagents completion bash >> ~/.bashrc')}
370
+ ${chalk.white('# Or save to a file:')}
371
+ ${chalk.green('proagents completion bash > /etc/bash_completion.d/proagents')}
372
+ ${chalk.white('# Then reload:')}
373
+ ${chalk.green('source ~/.bashrc')}
374
+ `;
375
+ break;
376
+
377
+ case 'zsh':
378
+ script = generateZshCompletion();
379
+ installInstructions = `
380
+ ${chalk.cyan('To install:')}
381
+ ${chalk.white('# Save to completions directory:')}
382
+ ${chalk.green('proagents completion zsh > ~/.zsh/completions/_proagents')}
383
+ ${chalk.white('# Or add to ~/.zshrc:')}
384
+ ${chalk.green('proagents completion zsh >> ~/.zshrc')}
385
+ ${chalk.white('# Then reload:')}
386
+ ${chalk.green('source ~/.zshrc')}
387
+ `;
388
+ break;
389
+
390
+ case 'fish':
391
+ script = generateFishCompletion();
392
+ installInstructions = `
393
+ ${chalk.cyan('To install:')}
394
+ ${chalk.white('# Save to completions directory:')}
395
+ ${chalk.green('proagents completion fish > ~/.config/fish/completions/proagents.fish')}
396
+ ${chalk.white('# Completions are loaded automatically')}
397
+ `;
398
+ break;
399
+
400
+ default:
401
+ console.error(chalk.red(`Unknown shell: ${shell}`));
402
+ console.error(chalk.gray('Supported shells: bash, zsh, fish'));
403
+ return;
404
+ }
405
+
406
+ // Output script
407
+ console.log(script);
408
+
409
+ // Show install instructions to stderr (so they don't pollute piped output)
410
+ if (!options.quiet) {
411
+ console.error(installInstructions);
412
+ }
413
+ }
@@ -621,3 +621,251 @@ export async function configCustomizeCommand() {
621
621
 
622
622
  console.log(chalk.gray('\nEdit the created files to customize your settings.\n'));
623
623
  }
624
+
625
+ /**
626
+ * Command: proagents config export
627
+ * Export configuration for sharing/backup
628
+ */
629
+ export function configExportCommand(options = {}) {
630
+ const targetDir = process.cwd();
631
+ const configPath = join(targetDir, 'proagents.config.yaml');
632
+ const proagentsDir = join(targetDir, '.proagents');
633
+
634
+ if (!existsSync(configPath)) {
635
+ if (!options.json) {
636
+ console.log(chalk.yellow('\nConfig file not found. Run "proagents init" first.\n'));
637
+ }
638
+ return;
639
+ }
640
+
641
+ try {
642
+ const exportData = {
643
+ exportedAt: new Date().toISOString(),
644
+ version: '1.0',
645
+ type: 'proagents-config-export'
646
+ };
647
+
648
+ // Export main config
649
+ const mainConfig = readFileSync(configPath, 'utf-8');
650
+ exportData.mainConfig = yaml.load(mainConfig);
651
+
652
+ // Export custom standards (if any)
653
+ const standardsDir = join(proagentsDir, 'config', 'standards');
654
+ if (existsSync(standardsDir)) {
655
+ exportData.standards = {};
656
+ const standardFiles = readdirSync(standardsDir).filter(f => !f.includes('.template.'));
657
+ for (const file of standardFiles) {
658
+ try {
659
+ exportData.standards[file] = readFileSync(join(standardsDir, file), 'utf-8');
660
+ } catch {
661
+ // Skip unreadable files
662
+ }
663
+ }
664
+ }
665
+
666
+ // Export custom rules (if any)
667
+ const rulesDir = join(proagentsDir, 'config', 'rules');
668
+ if (existsSync(rulesDir)) {
669
+ exportData.rules = {};
670
+ const ruleFiles = readdirSync(rulesDir).filter(f => !f.includes('.template.'));
671
+ for (const file of ruleFiles) {
672
+ try {
673
+ exportData.rules[file] = readFileSync(join(rulesDir, file), 'utf-8');
674
+ } catch {
675
+ // Skip unreadable files
676
+ }
677
+ }
678
+ }
679
+
680
+ // Export custom integrations (if any)
681
+ const integrationsDir = join(proagentsDir, 'config', 'integrations');
682
+ if (existsSync(integrationsDir)) {
683
+ exportData.integrations = {};
684
+ const integrationFiles = readdirSync(integrationsDir).filter(f => !f.includes('.template.'));
685
+ for (const file of integrationFiles) {
686
+ try {
687
+ exportData.integrations[file] = readFileSync(join(integrationsDir, file), 'utf-8');
688
+ } catch {
689
+ // Skip unreadable files
690
+ }
691
+ }
692
+ }
693
+
694
+ // Output
695
+ if (options.output) {
696
+ const outputPath = options.output === true ? 'proagents-config-export.json' : options.output;
697
+ writeFileSync(outputPath, JSON.stringify(exportData, null, 2));
698
+ console.log(chalk.green(`\n✓ Configuration exported to: ${outputPath}\n`));
699
+ } else {
700
+ // Output to stdout for piping
701
+ console.log(JSON.stringify(exportData, null, 2));
702
+ }
703
+
704
+ } catch (error) {
705
+ if (!options.json) {
706
+ console.log(chalk.red('\nError exporting config: ' + error.message + '\n'));
707
+ }
708
+ }
709
+ }
710
+
711
+ /**
712
+ * Command: proagents config import <file>
713
+ * Import configuration from export file
714
+ */
715
+ export async function configImportCommand(importFile, options = {}) {
716
+ const targetDir = process.cwd();
717
+ const proagentsDir = join(targetDir, '.proagents');
718
+ const configPath = join(targetDir, 'proagents.config.yaml');
719
+
720
+ if (!options.quiet) {
721
+ console.log(chalk.bold('\nProAgents Config Import'));
722
+ console.log(chalk.gray('=======================\n'));
723
+ }
724
+
725
+ // Check if import file exists
726
+ if (!importFile) {
727
+ console.log(chalk.red('Error: Please provide an import file path.'));
728
+ console.log(chalk.gray('\nUsage: proagents config import <config-export.json>'));
729
+ console.log(chalk.gray('Example: proagents config import proagents-config-export.json\n'));
730
+ return;
731
+ }
732
+
733
+ const importPath = importFile.startsWith('/') ? importFile : join(targetDir, importFile);
734
+
735
+ if (!existsSync(importPath)) {
736
+ console.log(chalk.red(`Error: Import file not found: ${importPath}\n`));
737
+ return;
738
+ }
739
+
740
+ // Read and parse import file
741
+ let importData;
742
+ try {
743
+ const content = readFileSync(importPath, 'utf-8');
744
+ importData = JSON.parse(content);
745
+ } catch (error) {
746
+ console.log(chalk.red(`Error: Could not parse import file: ${error.message}\n`));
747
+ return;
748
+ }
749
+
750
+ // Validate import file
751
+ if (importData.type !== 'proagents-config-export') {
752
+ console.log(chalk.red('Error: Invalid import file format.\n'));
753
+ return;
754
+ }
755
+
756
+ if (!options.quiet) {
757
+ console.log(chalk.cyan('Import Information:'));
758
+ console.log(` Exported: ${chalk.white(importData.exportedAt)}`);
759
+ console.log(` Version: ${chalk.white(importData.version)}`);
760
+ console.log('');
761
+ }
762
+
763
+ // Confirm import unless --force
764
+ if (!options.force) {
765
+ const rl = createInterface({
766
+ input: process.stdin,
767
+ output: process.stdout
768
+ });
769
+
770
+ const answer = await new Promise(resolve => {
771
+ rl.question(chalk.yellow('Import this configuration? This will overwrite existing config. (y/N) '), resolve);
772
+ });
773
+ rl.close();
774
+
775
+ if (answer.toLowerCase() !== 'y') {
776
+ console.log(chalk.gray('\nImport cancelled.\n'));
777
+ return;
778
+ }
779
+ console.log('');
780
+ }
781
+
782
+ let importedCount = 0;
783
+ let errorCount = 0;
784
+
785
+ // Import main config
786
+ if (importData.mainConfig) {
787
+ try {
788
+ const header = `# ProAgents Configuration\n# Imported from: ${importFile}\n# Import date: ${new Date().toISOString().split('T')[0]}\n\n`;
789
+ const yamlContent = yaml.dump(importData.mainConfig, { indent: 2, lineWidth: 120 });
790
+ writeFileSync(configPath, header + yamlContent);
791
+ importedCount++;
792
+ if (!options.quiet) {
793
+ console.log(chalk.green(' ✓ proagents.config.yaml'));
794
+ }
795
+ } catch (error) {
796
+ errorCount++;
797
+ console.log(chalk.red(` ✗ proagents.config.yaml: ${error.message}`));
798
+ }
799
+ }
800
+
801
+ // Import standards
802
+ if (importData.standards) {
803
+ const standardsDir = join(proagentsDir, 'config', 'standards');
804
+ for (const [file, content] of Object.entries(importData.standards)) {
805
+ try {
806
+ writeFileSync(join(standardsDir, file), content);
807
+ importedCount++;
808
+ if (!options.quiet) {
809
+ console.log(chalk.green(` ✓ config/standards/${file}`));
810
+ }
811
+ } catch (error) {
812
+ errorCount++;
813
+ console.log(chalk.red(` ✗ config/standards/${file}: ${error.message}`));
814
+ }
815
+ }
816
+ }
817
+
818
+ // Import rules
819
+ if (importData.rules) {
820
+ const rulesDir = join(proagentsDir, 'config', 'rules');
821
+ for (const [file, content] of Object.entries(importData.rules)) {
822
+ try {
823
+ writeFileSync(join(rulesDir, file), content);
824
+ importedCount++;
825
+ if (!options.quiet) {
826
+ console.log(chalk.green(` ✓ config/rules/${file}`));
827
+ }
828
+ } catch (error) {
829
+ errorCount++;
830
+ console.log(chalk.red(` ✗ config/rules/${file}: ${error.message}`));
831
+ }
832
+ }
833
+ }
834
+
835
+ // Import integrations
836
+ if (importData.integrations) {
837
+ const integrationsDir = join(proagentsDir, 'config', 'integrations');
838
+ for (const [file, content] of Object.entries(importData.integrations)) {
839
+ try {
840
+ writeFileSync(join(integrationsDir, file), content);
841
+ importedCount++;
842
+ if (!options.quiet) {
843
+ console.log(chalk.green(` ✓ config/integrations/${file}`));
844
+ }
845
+ } catch (error) {
846
+ errorCount++;
847
+ console.log(chalk.red(` ✗ config/integrations/${file}: ${error.message}`));
848
+ }
849
+ }
850
+ }
851
+
852
+ // Summary
853
+ if (!options.quiet) {
854
+ console.log(chalk.bold('\nImport Complete'));
855
+ console.log(chalk.gray('─'.repeat(40)));
856
+ console.log(chalk.green(` ✓ Imported: ${importedCount} files`));
857
+ if (errorCount > 0) {
858
+ console.log(chalk.red(` ✗ Errors: ${errorCount} files`));
859
+ }
860
+ console.log('');
861
+ }
862
+
863
+ if (options.json) {
864
+ console.log(JSON.stringify({
865
+ success: true,
866
+ imported: importedCount,
867
+ errors: errorCount,
868
+ sourceDate: importData.exportedAt
869
+ }, null, 2));
870
+ }
871
+ }