aios-core 4.1.0 → 4.2.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.
Files changed (145) hide show
  1. package/.aios-core/.session/current-session.json +14 -0
  2. package/.aios-core/core/registry/registry-schema.json +166 -166
  3. package/.aios-core/core/registry/service-registry.json +6585 -6585
  4. package/.aios-core/data/entity-registry.yaml +208 -8
  5. package/.aios-core/data/registry-update-log.jsonl +165 -0
  6. package/.aios-core/development/scripts/approval-workflow.js +642 -642
  7. package/.aios-core/development/scripts/backup-manager.js +606 -606
  8. package/.aios-core/development/scripts/branch-manager.js +389 -389
  9. package/.aios-core/development/scripts/code-quality-improver.js +1311 -1311
  10. package/.aios-core/development/scripts/commit-message-generator.js +849 -849
  11. package/.aios-core/development/scripts/conflict-resolver.js +674 -674
  12. package/.aios-core/development/scripts/dependency-analyzer.js +637 -637
  13. package/.aios-core/development/scripts/diff-generator.js +351 -351
  14. package/.aios-core/development/scripts/elicitation-engine.js +384 -384
  15. package/.aios-core/development/scripts/elicitation-session-manager.js +299 -299
  16. package/.aios-core/development/scripts/git-wrapper.js +461 -461
  17. package/.aios-core/development/scripts/manifest-preview.js +244 -244
  18. package/.aios-core/development/scripts/metrics-tracker.js +775 -775
  19. package/.aios-core/development/scripts/modification-validator.js +554 -554
  20. package/.aios-core/development/scripts/pattern-learner.js +1224 -1224
  21. package/.aios-core/development/scripts/performance-analyzer.js +757 -757
  22. package/.aios-core/development/scripts/refactoring-suggester.js +1138 -1138
  23. package/.aios-core/development/scripts/rollback-handler.js +530 -530
  24. package/.aios-core/development/scripts/security-checker.js +358 -358
  25. package/.aios-core/development/scripts/template-engine.js +239 -239
  26. package/.aios-core/development/scripts/template-validator.js +278 -278
  27. package/.aios-core/development/scripts/test-generator.js +843 -843
  28. package/.aios-core/development/scripts/transaction-manager.js +589 -589
  29. package/.aios-core/development/scripts/usage-tracker.js +673 -673
  30. package/.aios-core/development/scripts/validate-filenames.js +226 -226
  31. package/.aios-core/development/scripts/version-tracker.js +526 -526
  32. package/.aios-core/development/scripts/yaml-validator.js +396 -396
  33. package/.aios-core/development/tasks/validate-next-story.md +99 -2
  34. package/.aios-core/development/templates/service-template/README.md.hbs +158 -158
  35. package/.aios-core/development/templates/service-template/__tests__/index.test.ts.hbs +237 -237
  36. package/.aios-core/development/templates/service-template/client.ts.hbs +403 -403
  37. package/.aios-core/development/templates/service-template/errors.ts.hbs +182 -182
  38. package/.aios-core/development/templates/service-template/index.ts.hbs +120 -120
  39. package/.aios-core/development/templates/service-template/package.json.hbs +87 -87
  40. package/.aios-core/development/templates/service-template/types.ts.hbs +145 -145
  41. package/.aios-core/development/templates/squad-template/LICENSE +21 -21
  42. package/.aios-core/docs/SHARD-TRANSLATION-GUIDE.md +335 -0
  43. package/.aios-core/docs/component-creation-guide.md +458 -0
  44. package/.aios-core/docs/session-update-pattern.md +307 -0
  45. package/.aios-core/docs/standards/AIOS-FRAMEWORK-MASTER.md +1963 -0
  46. package/.aios-core/docs/standards/AIOS-LIVRO-DE-OURO-V2.1-SUMMARY.md +1190 -0
  47. package/.aios-core/docs/standards/AIOS-LIVRO-DE-OURO-V2.1.md +439 -0
  48. package/.aios-core/docs/standards/AIOS-LIVRO-DE-OURO.md +5398 -0
  49. package/.aios-core/docs/standards/V3-ARCHITECTURAL-DECISIONS.md +523 -0
  50. package/.aios-core/docs/template-syntax.md +267 -0
  51. package/.aios-core/docs/troubleshooting-guide.md +625 -0
  52. package/.aios-core/infrastructure/templates/aios-sync.yaml.template +193 -193
  53. package/.aios-core/infrastructure/templates/coderabbit.yaml.template +279 -279
  54. package/.aios-core/infrastructure/templates/github-workflows/ci.yml.template +169 -169
  55. package/.aios-core/infrastructure/templates/github-workflows/pr-automation.yml.template +330 -330
  56. package/.aios-core/infrastructure/templates/github-workflows/release.yml.template +196 -196
  57. package/.aios-core/infrastructure/templates/gitignore/gitignore-aios-base.tmpl +63 -63
  58. package/.aios-core/infrastructure/templates/gitignore/gitignore-brownfield-merge.tmpl +18 -18
  59. package/.aios-core/infrastructure/templates/gitignore/gitignore-node.tmpl +85 -85
  60. package/.aios-core/infrastructure/templates/gitignore/gitignore-python.tmpl +145 -145
  61. package/.aios-core/infrastructure/tests/utilities-audit-results.json +501 -0
  62. package/.aios-core/install-manifest.yaml +101 -101
  63. package/.aios-core/local-config.yaml.template +70 -70
  64. package/.aios-core/manifests/agents.csv +29 -0
  65. package/.aios-core/manifests/schema/manifest-schema.json +190 -190
  66. package/.aios-core/manifests/tasks.csv +198 -0
  67. package/.aios-core/manifests/workers.csv +204 -0
  68. package/.aios-core/monitor/hooks/lib/__init__.py +1 -1
  69. package/.aios-core/monitor/hooks/lib/enrich.py +58 -58
  70. package/.aios-core/monitor/hooks/lib/send_event.py +47 -47
  71. package/.aios-core/monitor/hooks/notification.py +29 -29
  72. package/.aios-core/monitor/hooks/post_tool_use.py +45 -45
  73. package/.aios-core/monitor/hooks/pre_compact.py +29 -29
  74. package/.aios-core/monitor/hooks/pre_tool_use.py +40 -40
  75. package/.aios-core/monitor/hooks/stop.py +29 -29
  76. package/.aios-core/monitor/hooks/subagent_stop.py +29 -29
  77. package/.aios-core/monitor/hooks/user_prompt_submit.py +38 -38
  78. package/.aios-core/product/templates/adr.hbs +125 -125
  79. package/.aios-core/product/templates/component-react-tmpl.tsx +98 -98
  80. package/.aios-core/product/templates/dbdr.hbs +241 -241
  81. package/.aios-core/product/templates/engine/schemas/adr.schema.json +102 -102
  82. package/.aios-core/product/templates/engine/schemas/dbdr.schema.json +205 -205
  83. package/.aios-core/product/templates/engine/schemas/epic.schema.json +175 -175
  84. package/.aios-core/product/templates/engine/schemas/pmdr.schema.json +175 -175
  85. package/.aios-core/product/templates/engine/schemas/prd-v2.schema.json +300 -300
  86. package/.aios-core/product/templates/engine/schemas/prd.schema.json +152 -152
  87. package/.aios-core/product/templates/engine/schemas/story.schema.json +222 -222
  88. package/.aios-core/product/templates/engine/schemas/task.schema.json +154 -154
  89. package/.aios-core/product/templates/epic.hbs +212 -212
  90. package/.aios-core/product/templates/eslintrc-security.json +32 -32
  91. package/.aios-core/product/templates/github-actions-cd.yml +212 -212
  92. package/.aios-core/product/templates/github-actions-ci.yml +172 -172
  93. package/.aios-core/product/templates/pmdr.hbs +186 -186
  94. package/.aios-core/product/templates/prd-v2.0.hbs +216 -216
  95. package/.aios-core/product/templates/prd.hbs +201 -201
  96. package/.aios-core/product/templates/shock-report-tmpl.html +502 -502
  97. package/.aios-core/product/templates/story.hbs +263 -263
  98. package/.aios-core/product/templates/task.hbs +170 -170
  99. package/.aios-core/product/templates/tmpl-comment-on-examples.sql +158 -158
  100. package/.aios-core/product/templates/tmpl-migration-script.sql +91 -91
  101. package/.aios-core/product/templates/tmpl-rls-granular-policies.sql +104 -104
  102. package/.aios-core/product/templates/tmpl-rls-kiss-policy.sql +10 -10
  103. package/.aios-core/product/templates/tmpl-rls-roles.sql +135 -135
  104. package/.aios-core/product/templates/tmpl-rls-simple.sql +77 -77
  105. package/.aios-core/product/templates/tmpl-rls-tenant.sql +152 -152
  106. package/.aios-core/product/templates/tmpl-rollback-script.sql +77 -77
  107. package/.aios-core/product/templates/tmpl-seed-data.sql +140 -140
  108. package/.aios-core/product/templates/tmpl-smoke-test.sql +16 -16
  109. package/.aios-core/product/templates/tmpl-staging-copy-merge.sql +139 -139
  110. package/.aios-core/product/templates/tmpl-stored-proc.sql +140 -140
  111. package/.aios-core/product/templates/tmpl-trigger.sql +152 -152
  112. package/.aios-core/product/templates/tmpl-view-materialized.sql +133 -133
  113. package/.aios-core/product/templates/tmpl-view.sql +177 -177
  114. package/.aios-core/product/templates/token-exports-css-tmpl.css +240 -240
  115. package/.aios-core/quality/schemas/quality-metrics.schema.json +233 -233
  116. package/.aios-core/scripts/migrate-framework-docs.sh +300 -300
  117. package/.aios-core/scripts/pm.sh +0 -0
  118. package/.claude/hooks/enforce-architecture-first.py +196 -196
  119. package/.claude/hooks/mind-clone-governance.py +192 -192
  120. package/.claude/hooks/read-protection.py +151 -151
  121. package/.claude/hooks/slug-validation.py +176 -176
  122. package/.claude/hooks/sql-governance.py +182 -182
  123. package/.claude/hooks/write-path-validation.py +194 -194
  124. package/.claude/rules/agent-authority.md +105 -0
  125. package/.claude/rules/coderabbit-integration.md +93 -0
  126. package/.claude/rules/ids-principles.md +112 -0
  127. package/.claude/rules/story-lifecycle.md +139 -0
  128. package/.claude/rules/workflow-execution.md +150 -0
  129. package/LICENSE +48 -48
  130. package/bin/aios-minimal.js +0 -0
  131. package/bin/aios.js +0 -0
  132. package/package.json +1 -1
  133. package/packages/aios-install/bin/aios-install.js +0 -0
  134. package/packages/aios-install/bin/edmcp.js +0 -0
  135. package/packages/aios-pro-cli/bin/aios-pro.js +0 -0
  136. package/packages/installer/src/wizard/pro-setup.js +433 -49
  137. package/scripts/check-markdown-links.py +352 -352
  138. package/scripts/code-intel-health-check.js +343 -0
  139. package/scripts/dashboard-parallel-dev.sh +0 -0
  140. package/scripts/dashboard-parallel-phase3.sh +0 -0
  141. package/scripts/dashboard-parallel-phase4.sh +0 -0
  142. package/scripts/glue/README.md +355 -0
  143. package/scripts/glue/compose-agent-prompt.cjs +362 -0
  144. package/scripts/install-monitor-hooks.sh +0 -0
  145. package/.aios-core/lib/build.json +0 -1
@@ -1,527 +1,527 @@
1
- const fs = require('fs').promises;
2
- const path = require('path');
3
- const semver = require('semver');
4
- const chalk = require('chalk');
5
-
6
- /**
7
- * Framework version tracking utility for AIOS-FULLSTACK
8
- * Manages framework versions, migration history, and compatibility tracking
9
- */
10
- class VersionTracker {
11
- constructor(options = {}) {
12
- this.rootPath = options.rootPath || process.cwd();
13
- this.versionFile = path.join(this.rootPath, '.aios', 'version-info.json');
14
- this.migrationDir = path.join(this.rootPath, '.aios', 'migrations');
15
- this.currentVersion = null;
16
- this.versionInfo = null;
17
- }
18
-
19
- /**
20
- * Initialize version tracking system
21
- */
22
- async initialize() {
23
- try {
24
- // Ensure directories exist
25
- await fs.mkdir(path.dirname(this.versionFile), { recursive: true });
26
- await fs.mkdir(this.migrationDir, { recursive: true });
27
-
28
- // Check if version info exists
29
- try {
30
- await fs.access(this.versionFile);
31
- this.versionInfo = await this.loadVersionInfo();
32
- } catch (_error) {
33
- // Create initial version info
34
- this.versionInfo = this.createInitialVersionInfo();
35
- await this.saveVersionInfo();
36
- console.log(chalk.green('✅ Version tracking initialized'));
37
- }
38
-
39
- this.currentVersion = this.versionInfo.current_version;
40
- return this.versionInfo;
41
-
42
- } catch (_error) {
43
- console.error(chalk.red(`Version tracking initialization failed: ${error.message}`));
44
- throw error;
45
- }
46
- }
47
-
48
- /**
49
- * Get current framework version
50
- */
51
- async getCurrentVersion() {
52
- if (!this.versionInfo) {
53
- await this.initialize();
54
- }
55
- return this.currentVersion;
56
- }
57
-
58
- /**
59
- * Record a new framework version
60
- */
61
- async recordVersion(versionData) {
62
- try {
63
- const {
64
- version,
65
- description,
66
- changes = [],
67
- migration_required = false,
68
- breaking_changes = [],
69
- compatibility_notes = '',
70
- release_notes = ''
71
- } = versionData;
72
-
73
- // Validate version format
74
- if (!semver.valid(version)) {
75
- throw new Error(`Invalid version format: ${version}`);
76
- }
77
-
78
- // Check if version already exists
79
- if (this.versionInfo.versions.some(v => v.version === version)) {
80
- throw new Error(`Version ${version} already exists`);
81
- }
82
-
83
- // Validate version increment
84
- if (this.currentVersion && !semver.gt(version, this.currentVersion)) {
85
- throw new Error(`New version ${version} must be greater than current ${this.currentVersion}`);
86
- }
87
-
88
- const versionEntry = {
89
- version,
90
- description,
91
- timestamp: new Date().toISOString(),
92
- changes,
93
- migration_required,
94
- breaking_changes,
95
- compatibility_notes,
96
- release_notes,
97
- previous_version: this.currentVersion,
98
- status: 'active',
99
- components_modified: await this.detectModifiedComponents(),
100
- api_changes: await this.detectApiChanges(),
101
- deprecations: [],
102
- migration_path: migration_required ? `${this.currentVersion}-to-${version}` : null
103
- };
104
-
105
- // Add to version history
106
- this.versionInfo.versions.unshift(versionEntry);
107
- this.versionInfo.current_version = version;
108
- this.versionInfo.previous_version = this.currentVersion;
109
- this.versionInfo.last_updated = new Date().toISOString();
110
- this.versionInfo.total_versions++;
111
-
112
- // Update current version
113
- this.currentVersion = version;
114
-
115
- // Save updated info
116
- await this.saveVersionInfo();
117
-
118
- console.log(chalk.green(`✅ Recorded new framework version: ${version}`));
119
-
120
- if (migration_required) {
121
- console.log(chalk.yellow(`⚠️ Migration required from ${this.versionInfo.previous_version} to ${version}`));
122
- }
123
-
124
- return versionEntry;
125
-
126
- } catch (_error) {
127
- console.error(chalk.red(`Failed to record version: ${error.message}`));
128
- throw error;
129
- }
130
- }
131
-
132
- /**
133
- * Get version history with optional filtering
134
- */
135
- async getVersionHistory(options = {}) {
136
- const {
137
- limit = 10,
138
- include_migrations = true,
139
- include_breaking = false,
140
- since_version = null,
141
- status_filter = null
142
- } = options;
143
-
144
- if (!this.versionInfo) {
145
- await this.initialize();
146
- }
147
-
148
- let versions = [...this.versionInfo.versions];
149
-
150
- // Apply filters
151
- if (since_version) {
152
- const sinceIndex = versions.findIndex(v => v.version === since_version);
153
- if (sinceIndex !== -1) {
154
- versions = versions.slice(0, sinceIndex);
155
- }
156
- }
157
-
158
- if (status_filter) {
159
- versions = versions.filter(v => v.status === status_filter);
160
- }
161
-
162
- if (include_breaking) {
163
- versions = versions.filter(v => v.breaking_changes?.length > 0);
164
- }
165
-
166
- if (!include_migrations) {
167
- versions = versions.filter(v => !v.migration_required);
168
- }
169
-
170
- // Apply limit
171
- versions = versions.slice(0, limit);
172
-
173
- return {
174
- current_version: this.currentVersion,
175
- total_versions: this.versionInfo.total_versions,
176
- filtered_count: versions.length,
177
- versions: versions.map(v => ({
178
- version: v.version,
179
- description: v.description,
180
- timestamp: v.timestamp,
181
- migration_required: v.migration_required,
182
- breaking_changes: v.breaking_changes?.length || 0,
183
- status: v.status,
184
- components_modified: v.components_modified?.length || 0
185
- }))
186
- };
187
- }
188
-
189
- /**
190
- * Check compatibility between versions
191
- */
192
- async checkCompatibility(fromVersion, toVersion) {
193
- const compatibility = {
194
- compatible: false,
195
- migration_required: false,
196
- breaking_changes: [],
197
- warnings: [],
198
- migration_path: null,
199
- estimated_effort: 'unknown',
200
- risk_level: 'low'
201
- };
202
-
203
- try {
204
- // Validate versions
205
- if (!semver.valid(fromVersion) || !semver.valid(toVersion)) {
206
- throw new Error('Invalid version format provided');
207
- }
208
-
209
- const fromVersionInfo = this.versionInfo.versions.find(v => v.version === fromVersion);
210
- const toVersionInfo = this.versionInfo.versions.find(v => v.version === toVersion);
211
-
212
- if (!fromVersionInfo) {
213
- compatibility.warnings.push(`Source version ${fromVersion} not found in history`);
214
- }
215
-
216
- if (!toVersionInfo) {
217
- compatibility.warnings.push(`Target version ${toVersion} not found in history`);
218
- }
219
-
220
- // Check semantic version compatibility
221
- const versionDiff = semver.diff(fromVersion, toVersion);
222
-
223
- switch (versionDiff) {
224
- case 'patch':
225
- compatibility.compatible = true;
226
- compatibility.risk_level = 'low';
227
- compatibility.estimated_effort = 'minimal';
228
- break;
229
-
230
- case 'minor':
231
- compatibility.compatible = true;
232
- compatibility.migration_required = toVersionInfo?.migration_required || false;
233
- compatibility.risk_level = 'low';
234
- compatibility.estimated_effort = 'low';
235
- break;
236
-
237
- case 'major':
238
- compatibility.migration_required = true;
239
- compatibility.risk_level = 'high';
240
- compatibility.estimated_effort = 'high';
241
- compatibility.compatible = false;
242
- break;
243
-
244
- case 'premajor':
245
- case 'preminor':
246
- case 'prepatch':
247
- compatibility.migration_required = true;
248
- compatibility.risk_level = 'medium';
249
- compatibility.estimated_effort = 'medium';
250
- compatibility.compatible = false;
251
- break;
252
- }
253
-
254
- // Collect breaking changes in the path
255
- const versionsInPath = this.getVersionsInPath(fromVersion, toVersion);
256
-
257
- for (const version of versionsInPath) {
258
- if (version.breaking_changes?.length > 0) {
259
- compatibility.breaking_changes.push(...version.breaking_changes);
260
- compatibility.migration_required = true;
261
- }
262
- }
263
-
264
- // Set migration path if needed
265
- if (compatibility.migration_required) {
266
- compatibility.migration_path = `${fromVersion}-to-${toVersion}`;
267
- }
268
-
269
- return compatibility;
270
-
271
- } catch (_error) {
272
- compatibility.warnings.push(`Compatibility check failed: ${error.message}`);
273
- return compatibility;
274
- }
275
- }
276
-
277
- /**
278
- * Mark a version as deprecated
279
- */
280
- async deprecateVersion(version, deprecationInfo = {}) {
281
- try {
282
- const versionEntry = this.versionInfo.versions.find(v => v.version === version);
283
-
284
- if (!versionEntry) {
285
- throw new Error(`Version ${version} not found`);
286
- }
287
-
288
- if (versionEntry.status === 'deprecated') {
289
- throw new Error(`Version ${version} is already deprecated`);
290
- }
291
-
292
- const deprecation = {
293
- deprecated_at: new Date().toISOString(),
294
- reason: deprecationInfo.reason || 'Version deprecated',
295
- migration_target: deprecationInfo.migration_target || this.currentVersion,
296
- removal_timeline: deprecationInfo.removal_timeline || 'TBD',
297
- deprecation_notice: deprecationInfo.notice || `Version ${version} is deprecated. Please upgrade to ${this.currentVersion}.`
298
- };
299
-
300
- versionEntry.status = 'deprecated';
301
- versionEntry.deprecation_info = deprecation;
302
-
303
- await this.saveVersionInfo();
304
-
305
- console.log(chalk.yellow(`⚠️ Version ${version} marked as deprecated`));
306
- return deprecation;
307
-
308
- } catch (_error) {
309
- console.error(chalk.red(`Failed to deprecate version: ${error.message}`));
310
- throw error;
311
- }
312
- }
313
-
314
- /**
315
- * Get migration path between versions
316
- */
317
- async getMigrationPath(fromVersion, toVersion) {
318
- const path = {
319
- from_version: fromVersion,
320
- to_version: toVersion,
321
- steps: [],
322
- total_migrations: 0,
323
- estimated_duration: 0,
324
- risk_assessment: 'low',
325
- requirements: [],
326
- rollback_available: true
327
- };
328
-
329
- try {
330
- const versionsInPath = this.getVersionsInPath(fromVersion, toVersion);
331
-
332
- for (const version of versionsInPath) {
333
- if (version.migration_required) {
334
- const step = {
335
- from: version.previous_version,
336
- to: version.version,
337
- migration_id: version.migration_path,
338
- breaking_changes: version.breaking_changes || [],
339
- estimated_time: this.estimateMigrationTime(version),
340
- risk_level: this.assessMigrationRisk(version),
341
- prerequisites: version.migration_prerequisites || [],
342
- rollback_supported: true
343
- };
344
-
345
- path.steps.push(step);
346
- path.total_migrations++;
347
- path.estimated_duration += step.estimated_time;
348
-
349
- if (step.risk_level === 'high') {
350
- path.risk_assessment = 'high';
351
- } else if (step.risk_level === 'medium' && path.risk_assessment === 'low') {
352
- path.risk_assessment = 'medium';
353
- }
354
- }
355
- }
356
-
357
- // Collect unique requirements
358
- path.requirements = [...new Set(
359
- path.steps.flatMap(step => step.prerequisites)
360
- )];
361
-
362
- return path;
363
-
364
- } catch (_error) {
365
- console.error(chalk.red(`Failed to get migration path: ${error.message}`));
366
- throw error;
367
- }
368
- }
369
-
370
- /**
371
- * Generate version report
372
- */
373
- async generateVersionReport() {
374
- if (!this.versionInfo) {
375
- await this.initialize();
376
- }
377
-
378
- const report = {
379
- timestamp: new Date().toISOString(),
380
- current_version: this.currentVersion,
381
- total_versions: this.versionInfo.total_versions,
382
- version_distribution: {
383
- active: 0,
384
- deprecated: 0,
385
- archived: 0
386
- },
387
- migration_summary: {
388
- total_migrations: 0,
389
- pending_migrations: 0,
390
- failed_migrations: 0
391
- },
392
- breaking_changes_summary: {
393
- total_breaking_versions: 0,
394
- recent_breaking_changes: []
395
- },
396
- compatibility_matrix: {},
397
- recommendations: []
398
- };
399
-
400
- // Analyze version distribution
401
- this.versionInfo.versions.forEach(version => {
402
- report.version_distribution[version.status]++;
403
-
404
- if (version.migration_required) {
405
- report.migration_summary.total_migrations++;
406
- }
407
-
408
- if (version.breaking_changes?.length > 0) {
409
- report.breaking_changes_summary.total_breaking_versions++;
410
-
411
- if (semver.gte(version.version, semver.major(this.currentVersion) + '.0.0')) {
412
- report.breaking_changes_summary.recent_breaking_changes.push({
413
- version: version.version,
414
- changes: version.breaking_changes.slice(0, 3)
415
- });
416
- }
417
- }
418
- });
419
-
420
- // Generate recommendations
421
- if (report.version_distribution.deprecated > 5) {
422
- report.recommendations.push({
423
- type: 'cleanup',
424
- priority: 'medium',
425
- message: `${report.version_distribution.deprecated} deprecated versions should be archived`
426
- });
427
- }
428
-
429
- if (report.breaking_changes_summary.total_breaking_versions > 10) {
430
- report.recommendations.push({
431
- type: 'stability',
432
- priority: 'high',
433
- message: 'High number of breaking changes detected. Consider stability improvements.'
434
- });
435
- }
436
-
437
- return report;
438
- }
439
-
440
- // Private helper methods
441
- createInitialVersionInfo() {
442
- return {
443
- schema_version: '1.0.0',
444
- current_version: '1.0.0',
445
- previous_version: null,
446
- created_at: new Date().toISOString(),
447
- last_updated: new Date().toISOString(),
448
- total_versions: 1,
449
- versions: [{
450
- version: '1.0.0',
451
- description: 'Initial framework version',
452
- timestamp: new Date().toISOString(),
453
- changes: ['Initial framework setup'],
454
- migration_required: false,
455
- breaking_changes: [],
456
- compatibility_notes: 'Initial version',
457
- release_notes: 'AIOS-FULLSTACK framework v1.0.0',
458
- previous_version: null,
459
- status: 'active',
460
- components_modified: [],
461
- api_changes: [],
462
- deprecations: [],
463
- migration_path: null
464
- }],
465
- migration_history: [],
466
- compatibility_matrix: {}
467
- };
468
- }
469
-
470
- async loadVersionInfo() {
471
- try {
472
- const content = await fs.readFile(this.versionFile, 'utf-8');
473
- return JSON.parse(content);
474
- } catch (_error) {
475
- throw new Error(`Failed to load version info: ${error.message}`);
476
- }
477
- }
478
-
479
- async saveVersionInfo() {
480
- try {
481
- const content = JSON.stringify(this.versionInfo, null, 2);
482
- await fs.writeFile(this.versionFile, content);
483
- } catch (_error) {
484
- throw new Error(`Failed to save version info: ${error.message}`);
485
- }
486
- }
487
-
488
- async detectModifiedComponents() {
489
- // This would analyze git changes or compare with previous state
490
- // For now, return empty array
491
- return [];
492
- }
493
-
494
- async detectApiChanges() {
495
- // This would analyze API changes between versions
496
- // For now, return empty array
497
- return [];
498
- }
499
-
500
- getVersionsInPath(fromVersion, toVersion) {
501
- const versions = this.versionInfo.versions.filter(v => {
502
- return semver.gt(v.version, fromVersion) && semver.lte(v.version, toVersion);
503
- });
504
-
505
- return versions.sort((a, b) => semver.compare(a.version, b.version));
506
- }
507
-
508
- estimateMigrationTime(version) {
509
- // Simple heuristic based on breaking changes and components modified
510
- const baseTime = 30; // minutes
511
- const breakingChangeMultiplier = version.breaking_changes?.length || 0;
512
- const componentMultiplier = version.components_modified?.length || 0;
513
-
514
- return baseTime + (breakingChangeMultiplier * 15) + (componentMultiplier * 5);
515
- }
516
-
517
- assessMigrationRisk(version) {
518
- const breakingChanges = version.breaking_changes?.length || 0;
519
- const componentsModified = version.components_modified?.length || 0;
520
-
521
- if (breakingChanges > 5 || componentsModified > 20) return 'high';
522
- if (breakingChanges > 2 || componentsModified > 10) return 'medium';
523
- return 'low';
524
- }
525
- }
526
-
1
+ const fs = require('fs').promises;
2
+ const path = require('path');
3
+ const semver = require('semver');
4
+ const chalk = require('chalk');
5
+
6
+ /**
7
+ * Framework version tracking utility for AIOS-FULLSTACK
8
+ * Manages framework versions, migration history, and compatibility tracking
9
+ */
10
+ class VersionTracker {
11
+ constructor(options = {}) {
12
+ this.rootPath = options.rootPath || process.cwd();
13
+ this.versionFile = path.join(this.rootPath, '.aios', 'version-info.json');
14
+ this.migrationDir = path.join(this.rootPath, '.aios', 'migrations');
15
+ this.currentVersion = null;
16
+ this.versionInfo = null;
17
+ }
18
+
19
+ /**
20
+ * Initialize version tracking system
21
+ */
22
+ async initialize() {
23
+ try {
24
+ // Ensure directories exist
25
+ await fs.mkdir(path.dirname(this.versionFile), { recursive: true });
26
+ await fs.mkdir(this.migrationDir, { recursive: true });
27
+
28
+ // Check if version info exists
29
+ try {
30
+ await fs.access(this.versionFile);
31
+ this.versionInfo = await this.loadVersionInfo();
32
+ } catch (_error) {
33
+ // Create initial version info
34
+ this.versionInfo = this.createInitialVersionInfo();
35
+ await this.saveVersionInfo();
36
+ console.log(chalk.green('✅ Version tracking initialized'));
37
+ }
38
+
39
+ this.currentVersion = this.versionInfo.current_version;
40
+ return this.versionInfo;
41
+
42
+ } catch (_error) {
43
+ console.error(chalk.red(`Version tracking initialization failed: ${error.message}`));
44
+ throw error;
45
+ }
46
+ }
47
+
48
+ /**
49
+ * Get current framework version
50
+ */
51
+ async getCurrentVersion() {
52
+ if (!this.versionInfo) {
53
+ await this.initialize();
54
+ }
55
+ return this.currentVersion;
56
+ }
57
+
58
+ /**
59
+ * Record a new framework version
60
+ */
61
+ async recordVersion(versionData) {
62
+ try {
63
+ const {
64
+ version,
65
+ description,
66
+ changes = [],
67
+ migration_required = false,
68
+ breaking_changes = [],
69
+ compatibility_notes = '',
70
+ release_notes = ''
71
+ } = versionData;
72
+
73
+ // Validate version format
74
+ if (!semver.valid(version)) {
75
+ throw new Error(`Invalid version format: ${version}`);
76
+ }
77
+
78
+ // Check if version already exists
79
+ if (this.versionInfo.versions.some(v => v.version === version)) {
80
+ throw new Error(`Version ${version} already exists`);
81
+ }
82
+
83
+ // Validate version increment
84
+ if (this.currentVersion && !semver.gt(version, this.currentVersion)) {
85
+ throw new Error(`New version ${version} must be greater than current ${this.currentVersion}`);
86
+ }
87
+
88
+ const versionEntry = {
89
+ version,
90
+ description,
91
+ timestamp: new Date().toISOString(),
92
+ changes,
93
+ migration_required,
94
+ breaking_changes,
95
+ compatibility_notes,
96
+ release_notes,
97
+ previous_version: this.currentVersion,
98
+ status: 'active',
99
+ components_modified: await this.detectModifiedComponents(),
100
+ api_changes: await this.detectApiChanges(),
101
+ deprecations: [],
102
+ migration_path: migration_required ? `${this.currentVersion}-to-${version}` : null
103
+ };
104
+
105
+ // Add to version history
106
+ this.versionInfo.versions.unshift(versionEntry);
107
+ this.versionInfo.current_version = version;
108
+ this.versionInfo.previous_version = this.currentVersion;
109
+ this.versionInfo.last_updated = new Date().toISOString();
110
+ this.versionInfo.total_versions++;
111
+
112
+ // Update current version
113
+ this.currentVersion = version;
114
+
115
+ // Save updated info
116
+ await this.saveVersionInfo();
117
+
118
+ console.log(chalk.green(`✅ Recorded new framework version: ${version}`));
119
+
120
+ if (migration_required) {
121
+ console.log(chalk.yellow(`⚠️ Migration required from ${this.versionInfo.previous_version} to ${version}`));
122
+ }
123
+
124
+ return versionEntry;
125
+
126
+ } catch (_error) {
127
+ console.error(chalk.red(`Failed to record version: ${error.message}`));
128
+ throw error;
129
+ }
130
+ }
131
+
132
+ /**
133
+ * Get version history with optional filtering
134
+ */
135
+ async getVersionHistory(options = {}) {
136
+ const {
137
+ limit = 10,
138
+ include_migrations = true,
139
+ include_breaking = false,
140
+ since_version = null,
141
+ status_filter = null
142
+ } = options;
143
+
144
+ if (!this.versionInfo) {
145
+ await this.initialize();
146
+ }
147
+
148
+ let versions = [...this.versionInfo.versions];
149
+
150
+ // Apply filters
151
+ if (since_version) {
152
+ const sinceIndex = versions.findIndex(v => v.version === since_version);
153
+ if (sinceIndex !== -1) {
154
+ versions = versions.slice(0, sinceIndex);
155
+ }
156
+ }
157
+
158
+ if (status_filter) {
159
+ versions = versions.filter(v => v.status === status_filter);
160
+ }
161
+
162
+ if (include_breaking) {
163
+ versions = versions.filter(v => v.breaking_changes?.length > 0);
164
+ }
165
+
166
+ if (!include_migrations) {
167
+ versions = versions.filter(v => !v.migration_required);
168
+ }
169
+
170
+ // Apply limit
171
+ versions = versions.slice(0, limit);
172
+
173
+ return {
174
+ current_version: this.currentVersion,
175
+ total_versions: this.versionInfo.total_versions,
176
+ filtered_count: versions.length,
177
+ versions: versions.map(v => ({
178
+ version: v.version,
179
+ description: v.description,
180
+ timestamp: v.timestamp,
181
+ migration_required: v.migration_required,
182
+ breaking_changes: v.breaking_changes?.length || 0,
183
+ status: v.status,
184
+ components_modified: v.components_modified?.length || 0
185
+ }))
186
+ };
187
+ }
188
+
189
+ /**
190
+ * Check compatibility between versions
191
+ */
192
+ async checkCompatibility(fromVersion, toVersion) {
193
+ const compatibility = {
194
+ compatible: false,
195
+ migration_required: false,
196
+ breaking_changes: [],
197
+ warnings: [],
198
+ migration_path: null,
199
+ estimated_effort: 'unknown',
200
+ risk_level: 'low'
201
+ };
202
+
203
+ try {
204
+ // Validate versions
205
+ if (!semver.valid(fromVersion) || !semver.valid(toVersion)) {
206
+ throw new Error('Invalid version format provided');
207
+ }
208
+
209
+ const fromVersionInfo = this.versionInfo.versions.find(v => v.version === fromVersion);
210
+ const toVersionInfo = this.versionInfo.versions.find(v => v.version === toVersion);
211
+
212
+ if (!fromVersionInfo) {
213
+ compatibility.warnings.push(`Source version ${fromVersion} not found in history`);
214
+ }
215
+
216
+ if (!toVersionInfo) {
217
+ compatibility.warnings.push(`Target version ${toVersion} not found in history`);
218
+ }
219
+
220
+ // Check semantic version compatibility
221
+ const versionDiff = semver.diff(fromVersion, toVersion);
222
+
223
+ switch (versionDiff) {
224
+ case 'patch':
225
+ compatibility.compatible = true;
226
+ compatibility.risk_level = 'low';
227
+ compatibility.estimated_effort = 'minimal';
228
+ break;
229
+
230
+ case 'minor':
231
+ compatibility.compatible = true;
232
+ compatibility.migration_required = toVersionInfo?.migration_required || false;
233
+ compatibility.risk_level = 'low';
234
+ compatibility.estimated_effort = 'low';
235
+ break;
236
+
237
+ case 'major':
238
+ compatibility.migration_required = true;
239
+ compatibility.risk_level = 'high';
240
+ compatibility.estimated_effort = 'high';
241
+ compatibility.compatible = false;
242
+ break;
243
+
244
+ case 'premajor':
245
+ case 'preminor':
246
+ case 'prepatch':
247
+ compatibility.migration_required = true;
248
+ compatibility.risk_level = 'medium';
249
+ compatibility.estimated_effort = 'medium';
250
+ compatibility.compatible = false;
251
+ break;
252
+ }
253
+
254
+ // Collect breaking changes in the path
255
+ const versionsInPath = this.getVersionsInPath(fromVersion, toVersion);
256
+
257
+ for (const version of versionsInPath) {
258
+ if (version.breaking_changes?.length > 0) {
259
+ compatibility.breaking_changes.push(...version.breaking_changes);
260
+ compatibility.migration_required = true;
261
+ }
262
+ }
263
+
264
+ // Set migration path if needed
265
+ if (compatibility.migration_required) {
266
+ compatibility.migration_path = `${fromVersion}-to-${toVersion}`;
267
+ }
268
+
269
+ return compatibility;
270
+
271
+ } catch (_error) {
272
+ compatibility.warnings.push(`Compatibility check failed: ${error.message}`);
273
+ return compatibility;
274
+ }
275
+ }
276
+
277
+ /**
278
+ * Mark a version as deprecated
279
+ */
280
+ async deprecateVersion(version, deprecationInfo = {}) {
281
+ try {
282
+ const versionEntry = this.versionInfo.versions.find(v => v.version === version);
283
+
284
+ if (!versionEntry) {
285
+ throw new Error(`Version ${version} not found`);
286
+ }
287
+
288
+ if (versionEntry.status === 'deprecated') {
289
+ throw new Error(`Version ${version} is already deprecated`);
290
+ }
291
+
292
+ const deprecation = {
293
+ deprecated_at: new Date().toISOString(),
294
+ reason: deprecationInfo.reason || 'Version deprecated',
295
+ migration_target: deprecationInfo.migration_target || this.currentVersion,
296
+ removal_timeline: deprecationInfo.removal_timeline || 'TBD',
297
+ deprecation_notice: deprecationInfo.notice || `Version ${version} is deprecated. Please upgrade to ${this.currentVersion}.`
298
+ };
299
+
300
+ versionEntry.status = 'deprecated';
301
+ versionEntry.deprecation_info = deprecation;
302
+
303
+ await this.saveVersionInfo();
304
+
305
+ console.log(chalk.yellow(`⚠️ Version ${version} marked as deprecated`));
306
+ return deprecation;
307
+
308
+ } catch (_error) {
309
+ console.error(chalk.red(`Failed to deprecate version: ${error.message}`));
310
+ throw error;
311
+ }
312
+ }
313
+
314
+ /**
315
+ * Get migration path between versions
316
+ */
317
+ async getMigrationPath(fromVersion, toVersion) {
318
+ const path = {
319
+ from_version: fromVersion,
320
+ to_version: toVersion,
321
+ steps: [],
322
+ total_migrations: 0,
323
+ estimated_duration: 0,
324
+ risk_assessment: 'low',
325
+ requirements: [],
326
+ rollback_available: true
327
+ };
328
+
329
+ try {
330
+ const versionsInPath = this.getVersionsInPath(fromVersion, toVersion);
331
+
332
+ for (const version of versionsInPath) {
333
+ if (version.migration_required) {
334
+ const step = {
335
+ from: version.previous_version,
336
+ to: version.version,
337
+ migration_id: version.migration_path,
338
+ breaking_changes: version.breaking_changes || [],
339
+ estimated_time: this.estimateMigrationTime(version),
340
+ risk_level: this.assessMigrationRisk(version),
341
+ prerequisites: version.migration_prerequisites || [],
342
+ rollback_supported: true
343
+ };
344
+
345
+ path.steps.push(step);
346
+ path.total_migrations++;
347
+ path.estimated_duration += step.estimated_time;
348
+
349
+ if (step.risk_level === 'high') {
350
+ path.risk_assessment = 'high';
351
+ } else if (step.risk_level === 'medium' && path.risk_assessment === 'low') {
352
+ path.risk_assessment = 'medium';
353
+ }
354
+ }
355
+ }
356
+
357
+ // Collect unique requirements
358
+ path.requirements = [...new Set(
359
+ path.steps.flatMap(step => step.prerequisites)
360
+ )];
361
+
362
+ return path;
363
+
364
+ } catch (_error) {
365
+ console.error(chalk.red(`Failed to get migration path: ${error.message}`));
366
+ throw error;
367
+ }
368
+ }
369
+
370
+ /**
371
+ * Generate version report
372
+ */
373
+ async generateVersionReport() {
374
+ if (!this.versionInfo) {
375
+ await this.initialize();
376
+ }
377
+
378
+ const report = {
379
+ timestamp: new Date().toISOString(),
380
+ current_version: this.currentVersion,
381
+ total_versions: this.versionInfo.total_versions,
382
+ version_distribution: {
383
+ active: 0,
384
+ deprecated: 0,
385
+ archived: 0
386
+ },
387
+ migration_summary: {
388
+ total_migrations: 0,
389
+ pending_migrations: 0,
390
+ failed_migrations: 0
391
+ },
392
+ breaking_changes_summary: {
393
+ total_breaking_versions: 0,
394
+ recent_breaking_changes: []
395
+ },
396
+ compatibility_matrix: {},
397
+ recommendations: []
398
+ };
399
+
400
+ // Analyze version distribution
401
+ this.versionInfo.versions.forEach(version => {
402
+ report.version_distribution[version.status]++;
403
+
404
+ if (version.migration_required) {
405
+ report.migration_summary.total_migrations++;
406
+ }
407
+
408
+ if (version.breaking_changes?.length > 0) {
409
+ report.breaking_changes_summary.total_breaking_versions++;
410
+
411
+ if (semver.gte(version.version, semver.major(this.currentVersion) + '.0.0')) {
412
+ report.breaking_changes_summary.recent_breaking_changes.push({
413
+ version: version.version,
414
+ changes: version.breaking_changes.slice(0, 3)
415
+ });
416
+ }
417
+ }
418
+ });
419
+
420
+ // Generate recommendations
421
+ if (report.version_distribution.deprecated > 5) {
422
+ report.recommendations.push({
423
+ type: 'cleanup',
424
+ priority: 'medium',
425
+ message: `${report.version_distribution.deprecated} deprecated versions should be archived`
426
+ });
427
+ }
428
+
429
+ if (report.breaking_changes_summary.total_breaking_versions > 10) {
430
+ report.recommendations.push({
431
+ type: 'stability',
432
+ priority: 'high',
433
+ message: 'High number of breaking changes detected. Consider stability improvements.'
434
+ });
435
+ }
436
+
437
+ return report;
438
+ }
439
+
440
+ // Private helper methods
441
+ createInitialVersionInfo() {
442
+ return {
443
+ schema_version: '1.0.0',
444
+ current_version: '1.0.0',
445
+ previous_version: null,
446
+ created_at: new Date().toISOString(),
447
+ last_updated: new Date().toISOString(),
448
+ total_versions: 1,
449
+ versions: [{
450
+ version: '1.0.0',
451
+ description: 'Initial framework version',
452
+ timestamp: new Date().toISOString(),
453
+ changes: ['Initial framework setup'],
454
+ migration_required: false,
455
+ breaking_changes: [],
456
+ compatibility_notes: 'Initial version',
457
+ release_notes: 'AIOS-FULLSTACK framework v1.0.0',
458
+ previous_version: null,
459
+ status: 'active',
460
+ components_modified: [],
461
+ api_changes: [],
462
+ deprecations: [],
463
+ migration_path: null
464
+ }],
465
+ migration_history: [],
466
+ compatibility_matrix: {}
467
+ };
468
+ }
469
+
470
+ async loadVersionInfo() {
471
+ try {
472
+ const content = await fs.readFile(this.versionFile, 'utf-8');
473
+ return JSON.parse(content);
474
+ } catch (_error) {
475
+ throw new Error(`Failed to load version info: ${error.message}`);
476
+ }
477
+ }
478
+
479
+ async saveVersionInfo() {
480
+ try {
481
+ const content = JSON.stringify(this.versionInfo, null, 2);
482
+ await fs.writeFile(this.versionFile, content);
483
+ } catch (_error) {
484
+ throw new Error(`Failed to save version info: ${error.message}`);
485
+ }
486
+ }
487
+
488
+ async detectModifiedComponents() {
489
+ // This would analyze git changes or compare with previous state
490
+ // For now, return empty array
491
+ return [];
492
+ }
493
+
494
+ async detectApiChanges() {
495
+ // This would analyze API changes between versions
496
+ // For now, return empty array
497
+ return [];
498
+ }
499
+
500
+ getVersionsInPath(fromVersion, toVersion) {
501
+ const versions = this.versionInfo.versions.filter(v => {
502
+ return semver.gt(v.version, fromVersion) && semver.lte(v.version, toVersion);
503
+ });
504
+
505
+ return versions.sort((a, b) => semver.compare(a.version, b.version));
506
+ }
507
+
508
+ estimateMigrationTime(version) {
509
+ // Simple heuristic based on breaking changes and components modified
510
+ const baseTime = 30; // minutes
511
+ const breakingChangeMultiplier = version.breaking_changes?.length || 0;
512
+ const componentMultiplier = version.components_modified?.length || 0;
513
+
514
+ return baseTime + (breakingChangeMultiplier * 15) + (componentMultiplier * 5);
515
+ }
516
+
517
+ assessMigrationRisk(version) {
518
+ const breakingChanges = version.breaking_changes?.length || 0;
519
+ const componentsModified = version.components_modified?.length || 0;
520
+
521
+ if (breakingChanges > 5 || componentsModified > 20) return 'high';
522
+ if (breakingChanges > 2 || componentsModified > 10) return 'medium';
523
+ return 'low';
524
+ }
525
+ }
526
+
527
527
  module.exports = VersionTracker;