agentic-qe 3.7.21 → 3.7.22

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 (52) hide show
  1. package/.claude/helpers/brain-checkpoint.cjs +4 -1
  2. package/.claude/helpers/statusline-v3.cjs +3 -1
  3. package/.claude/skills/skills-manifest.json +1 -1
  4. package/CHANGELOG.md +14 -0
  5. package/README.md +0 -12
  6. package/assets/helpers/statusline-v3.cjs +3 -1
  7. package/dist/cli/brain-commands.js +6 -10
  8. package/dist/cli/bundle.js +2049 -3380
  9. package/dist/cli/commands/hooks.js +29 -6
  10. package/dist/cli/commands/init.js +1 -73
  11. package/dist/cli/commands/learning.js +164 -12
  12. package/dist/cli/handlers/init-handler.d.ts +0 -1
  13. package/dist/cli/handlers/init-handler.js +0 -6
  14. package/dist/cli/index.js +0 -2
  15. package/dist/context/sources/defect-source.js +2 -2
  16. package/dist/context/sources/memory-source.js +2 -2
  17. package/dist/context/sources/requirements-source.js +2 -2
  18. package/dist/init/index.d.ts +0 -2
  19. package/dist/init/index.js +0 -1
  20. package/dist/init/init-wizard-steps.d.ts +10 -0
  21. package/dist/init/init-wizard-steps.js +87 -1
  22. package/dist/init/init-wizard.d.ts +1 -9
  23. package/dist/init/init-wizard.js +3 -69
  24. package/dist/init/orchestrator.js +0 -1
  25. package/dist/init/phases/01-detection.js +0 -27
  26. package/dist/init/phases/07-hooks.js +6 -4
  27. package/dist/init/phases/phase-interface.d.ts +0 -1
  28. package/dist/init/settings-merge.js +1 -1
  29. package/dist/kernel/unified-memory.js +5 -6
  30. package/dist/learning/experience-capture-middleware.js +20 -0
  31. package/dist/learning/index.d.ts +0 -2
  32. package/dist/learning/index.js +0 -4
  33. package/dist/learning/metrics-tracker.js +15 -13
  34. package/dist/learning/pattern-lifecycle.d.ts +1 -1
  35. package/dist/learning/pattern-lifecycle.js +18 -20
  36. package/dist/learning/qe-unified-memory.js +1 -28
  37. package/dist/mcp/bundle.js +180 -175
  38. package/package.json +1 -1
  39. package/dist/cli/commands/migrate.d.ts +0 -9
  40. package/dist/cli/commands/migrate.js +0 -566
  41. package/dist/init/init-wizard-migration.d.ts +0 -52
  42. package/dist/init/init-wizard-migration.js +0 -345
  43. package/dist/init/migration/config-migrator.d.ts +0 -31
  44. package/dist/init/migration/config-migrator.js +0 -149
  45. package/dist/init/migration/data-migrator.d.ts +0 -72
  46. package/dist/init/migration/data-migrator.js +0 -232
  47. package/dist/init/migration/detector.d.ts +0 -44
  48. package/dist/init/migration/detector.js +0 -105
  49. package/dist/init/migration/index.d.ts +0 -8
  50. package/dist/init/migration/index.js +0 -8
  51. package/dist/learning/v2-to-v3-migration.d.ts +0 -86
  52. package/dist/learning/v2-to-v3-migration.js +0 -529
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentic-qe",
3
- "version": "3.7.21",
3
+ "version": "3.7.22",
4
4
  "description": "Agentic Quality Engineering V3 - Domain-Driven Design Architecture with 13 Bounded Contexts, O(log n) coverage analysis, ReasoningBank learning, 60 specialized QE agents, mathematical Coherence verification, deep Claude Flow integration",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,9 +0,0 @@
1
- /**
2
- * Agentic QE v3 - Migrate Command
3
- *
4
- * V2-to-V3 migration tools with agent compatibility (ADR-048).
5
- */
6
- import { Command } from 'commander';
7
- import type { CLIContext } from '../handlers/interfaces.js';
8
- export declare function createMigrateCommand(context: CLIContext, cleanupAndExit: (code: number) => Promise<never>, ensureInitialized: () => Promise<boolean>): Command;
9
- //# sourceMappingURL=migrate.d.ts.map
@@ -1,566 +0,0 @@
1
- /**
2
- * Agentic QE v3 - Migrate Command
3
- *
4
- * V2-to-V3 migration tools with agent compatibility (ADR-048).
5
- */
6
- import { Command } from 'commander';
7
- import chalk from 'chalk';
8
- import { parseJsonFile } from '../helpers/safe-json.js';
9
- import { v2AgentMapping, resolveAgentName, isDeprecatedAgent, v3Agents, } from '../../migration/agent-compat.js';
10
- export function createMigrateCommand(context, cleanupAndExit, ensureInitialized) {
11
- const migrateCmd = new Command('migrate')
12
- .description('V2-to-V3 migration tools with agent compatibility (ADR-048)');
13
- // migrate run
14
- migrateCmd
15
- .command('run')
16
- .description('Run full migration from v2 to v3')
17
- .option('--dry-run', 'Preview migration without making changes')
18
- .option('--backup', 'Create backup before migration (recommended)', true)
19
- .option('--skip-memory', 'Skip memory database migration')
20
- .option('--skip-patterns', 'Skip pattern migration')
21
- .option('--skip-config', 'Skip configuration migration')
22
- .option('--skip-agents', 'Skip agent name migration')
23
- .option('--target <component>', 'Migrate specific component (agents, skills, config, memory)')
24
- .option('--force', 'Force migration even if v3 already exists')
25
- .action(async (options) => {
26
- const fs = await import('fs');
27
- const path = await import('path');
28
- console.log(chalk.blue('\n V2 to V3 Migration (ADR-048)\n'));
29
- const cwd = process.cwd();
30
- const v2Dir = path.join(cwd, '.agentic-qe');
31
- const v3Dir = path.join(cwd, '.aqe');
32
- const claudeAgentDir = path.join(cwd, '.claude', 'agents');
33
- // Step 1: Detect v2 installation
34
- console.log(chalk.white('1. Detecting v2 installation...'));
35
- const hasV2Dir = fs.existsSync(v2Dir);
36
- const hasClaudeAgents = fs.existsSync(claudeAgentDir);
37
- if (!hasV2Dir && !hasClaudeAgents) {
38
- console.log(chalk.yellow(' ! No v2 installation found'));
39
- console.log(chalk.gray(' This might be a fresh project. Use `aqe init` instead.'));
40
- await cleanupAndExit(0);
41
- }
42
- const v2Files = {
43
- memoryDb: path.join(v2Dir, 'memory.db'),
44
- config: path.join(v2Dir, 'config.json'),
45
- patterns: path.join(v2Dir, 'patterns'),
46
- };
47
- const hasMemory = hasV2Dir && fs.existsSync(v2Files.memoryDb);
48
- const hasConfig = hasV2Dir && fs.existsSync(v2Files.config);
49
- const hasPatterns = hasV2Dir && fs.existsSync(v2Files.patterns);
50
- // Detect v2 agents needing migration
51
- const agentsToMigrate = [];
52
- if (hasClaudeAgents) {
53
- const files = fs.readdirSync(claudeAgentDir);
54
- for (const file of files) {
55
- if (file.endsWith('.md') && file.startsWith('qe-')) {
56
- const agentName = file.replace('.md', '');
57
- if (isDeprecatedAgent(agentName)) {
58
- agentsToMigrate.push(agentName);
59
- }
60
- }
61
- }
62
- }
63
- console.log(chalk.green(' * Found v2 installation:'));
64
- console.log(chalk.gray(` Memory DB: ${hasMemory ? '*' : 'x'}`));
65
- console.log(chalk.gray(` Config: ${hasConfig ? '*' : 'x'}`));
66
- console.log(chalk.gray(` Patterns: ${hasPatterns ? '*' : 'x'}`));
67
- console.log(chalk.gray(` Agents to migrate: ${agentsToMigrate.length}\n`));
68
- // Step 2: Check v3 existence
69
- console.log(chalk.white('2. Checking v3 status...'));
70
- if (fs.existsSync(v3Dir) && !options.force) {
71
- console.log(chalk.yellow(' ! v3 directory already exists at .aqe/'));
72
- console.log(chalk.gray(' Use --force to overwrite existing v3 installation.'));
73
- await cleanupAndExit(1);
74
- }
75
- console.log(chalk.green(' * Ready for migration\n'));
76
- // Dry run mode
77
- if (options.dryRun) {
78
- console.log(chalk.blue(' Dry Run - Migration Plan:\n'));
79
- if (!options.skipMemory && hasMemory) {
80
- const stats = fs.statSync(v2Files.memoryDb);
81
- console.log(chalk.gray(` - Migrate memory.db (${(stats.size / 1024).toFixed(1)} KB)`));
82
- }
83
- if (!options.skipConfig && hasConfig) {
84
- console.log(chalk.gray(' - Convert config.json to v3 format'));
85
- }
86
- if (!options.skipPatterns && hasPatterns) {
87
- const patternFiles = fs.readdirSync(v2Files.patterns);
88
- console.log(chalk.gray(` - Migrate ${patternFiles.length} pattern files`));
89
- }
90
- if (!options.skipAgents && agentsToMigrate.length > 0) {
91
- console.log(chalk.gray(` - Migrate ${agentsToMigrate.length} agent names:`));
92
- for (const agent of agentsToMigrate) {
93
- console.log(chalk.gray(` ${agent} -> ${resolveAgentName(agent)}`));
94
- }
95
- }
96
- console.log(chalk.yellow('\n! This is a dry run. No changes were made.'));
97
- console.log(chalk.gray('Run without --dry-run to execute migration.\n'));
98
- await cleanupAndExit(0);
99
- }
100
- // Step 3: Create backup
101
- if (options.backup) {
102
- console.log(chalk.white('3. Creating backup...'));
103
- const backupDir = path.join(cwd, '.aqe-backup', `backup-${Date.now()}`);
104
- try {
105
- fs.mkdirSync(backupDir, { recursive: true });
106
- const copyDir = (src, dest) => {
107
- if (!fs.existsSync(src))
108
- return;
109
- if (fs.statSync(src).isDirectory()) {
110
- fs.mkdirSync(dest, { recursive: true });
111
- for (const file of fs.readdirSync(src)) {
112
- copyDir(path.join(src, file), path.join(dest, file));
113
- }
114
- }
115
- else {
116
- fs.copyFileSync(src, dest);
117
- }
118
- };
119
- if (hasV2Dir)
120
- copyDir(v2Dir, path.join(backupDir, '.agentic-qe'));
121
- if (hasClaudeAgents)
122
- copyDir(claudeAgentDir, path.join(backupDir, '.claude', 'agents'));
123
- console.log(chalk.green(` * Backup created at .aqe-backup/\n`));
124
- }
125
- catch (err) {
126
- console.log(chalk.red(` x Backup failed: ${err}`));
127
- await cleanupAndExit(1);
128
- }
129
- }
130
- else {
131
- console.log(chalk.yellow('3. Backup skipped (--no-backup)\n'));
132
- }
133
- // Step 4: Create v3 directory structure
134
- if (!options.target || options.target === 'config' || options.target === 'memory') {
135
- console.log(chalk.white('4. Creating v3 directory structure...'));
136
- try {
137
- fs.mkdirSync(v3Dir, { recursive: true });
138
- fs.mkdirSync(path.join(v3Dir, 'agentdb'), { recursive: true });
139
- fs.mkdirSync(path.join(v3Dir, 'reasoning-bank'), { recursive: true });
140
- fs.mkdirSync(path.join(v3Dir, 'cache'), { recursive: true });
141
- fs.mkdirSync(path.join(v3Dir, 'logs'), { recursive: true });
142
- console.log(chalk.green(' * Directory structure created\n'));
143
- }
144
- catch (err) {
145
- console.log(chalk.red(` x Failed: ${err}\n`));
146
- await cleanupAndExit(1);
147
- }
148
- }
149
- // Step 5: Migrate memory database
150
- if ((!options.target || options.target === 'memory') && !options.skipMemory && hasMemory) {
151
- console.log(chalk.white('5. Migrating memory database...'));
152
- try {
153
- const destDb = path.join(v3Dir, 'agentdb', 'memory.db');
154
- fs.copyFileSync(v2Files.memoryDb, destDb);
155
- const indexFile = path.join(v3Dir, 'agentdb', 'index.json');
156
- fs.writeFileSync(indexFile, JSON.stringify({
157
- version: '3.0.0',
158
- migratedFrom: 'v2',
159
- migratedAt: new Date().toISOString(),
160
- hnswEnabled: true,
161
- vectorDimensions: 384,
162
- }, null, 2));
163
- const stats = fs.statSync(v2Files.memoryDb);
164
- console.log(chalk.green(` * Memory database migrated (${(stats.size / 1024).toFixed(1)} KB)\n`));
165
- }
166
- catch (err) {
167
- console.log(chalk.red(` x Migration failed: ${err}\n`));
168
- }
169
- }
170
- else if (options.target && options.target !== 'memory') {
171
- console.log(chalk.gray('5. Memory migration skipped (--target)\n'));
172
- }
173
- else if (options.skipMemory) {
174
- console.log(chalk.yellow('5. Memory migration skipped\n'));
175
- }
176
- else {
177
- console.log(chalk.gray('5. No memory database to migrate\n'));
178
- }
179
- // Step 6: Migrate configuration
180
- if ((!options.target || options.target === 'config') && !options.skipConfig && hasConfig) {
181
- console.log(chalk.white('6. Migrating configuration...'));
182
- try {
183
- const v2ConfigRaw = fs.readFileSync(v2Files.config, 'utf-8');
184
- const v2Config = parseJsonFile(v2ConfigRaw, v2Files.config);
185
- const v3Config = {
186
- version: '3.0.0',
187
- migratedFrom: v2Config.version || '2.x',
188
- migratedAt: new Date().toISOString(),
189
- kernel: { eventBus: 'in-memory', coordinator: 'queen' },
190
- domains: {
191
- 'test-generation': { enabled: true },
192
- 'test-execution': { enabled: true },
193
- 'coverage-analysis': { enabled: true, algorithm: 'hnsw', dimensions: 384 },
194
- 'quality-assessment': { enabled: true },
195
- 'defect-intelligence': { enabled: true },
196
- 'requirements-validation': { enabled: true },
197
- 'code-intelligence': { enabled: true },
198
- 'security-compliance': { enabled: true },
199
- 'contract-testing': { enabled: true },
200
- 'visual-accessibility': { enabled: false },
201
- 'chaos-resilience': { enabled: true },
202
- 'learning-optimization': { enabled: true },
203
- },
204
- memory: {
205
- backend: 'hybrid',
206
- path: '.aqe/agentdb/',
207
- hnsw: { M: 16, efConstruction: 200 },
208
- },
209
- learning: {
210
- reasoningBank: true,
211
- sona: true,
212
- patternRetention: v2Config.learning?.patternRetention || 180,
213
- },
214
- v2Migration: {
215
- originalConfig: v2Config,
216
- migrationDate: new Date().toISOString(),
217
- },
218
- };
219
- const destConfig = path.join(v3Dir, 'config.json');
220
- fs.writeFileSync(destConfig, JSON.stringify(v3Config, null, 2));
221
- console.log(chalk.green(' * Configuration migrated\n'));
222
- }
223
- catch (err) {
224
- console.log(chalk.red(` x Config migration failed: ${err}\n`));
225
- }
226
- }
227
- else if (options.target && options.target !== 'config') {
228
- console.log(chalk.gray('6. Config migration skipped (--target)\n'));
229
- }
230
- else if (options.skipConfig) {
231
- console.log(chalk.yellow('6. Configuration migration skipped\n'));
232
- }
233
- else {
234
- console.log(chalk.gray('6. No configuration to migrate\n'));
235
- }
236
- // Step 7: Migrate patterns
237
- if ((!options.target || options.target === 'memory') && !options.skipPatterns && hasPatterns) {
238
- console.log(chalk.white('7. Migrating patterns to ReasoningBank...'));
239
- try {
240
- const patternFiles = fs.readdirSync(v2Files.patterns);
241
- let migratedCount = 0;
242
- for (const file of patternFiles) {
243
- const srcPath = path.join(v2Files.patterns, file);
244
- const destPath = path.join(v3Dir, 'reasoning-bank', file);
245
- if (fs.statSync(srcPath).isFile()) {
246
- fs.copyFileSync(srcPath, destPath);
247
- migratedCount++;
248
- }
249
- }
250
- const indexPath = path.join(v3Dir, 'reasoning-bank', 'index.json');
251
- fs.writeFileSync(indexPath, JSON.stringify({
252
- version: '3.0.0',
253
- migratedFrom: 'v2',
254
- migratedAt: new Date().toISOString(),
255
- patternCount: migratedCount,
256
- hnswIndexed: false,
257
- }, null, 2));
258
- console.log(chalk.green(` * ${migratedCount} patterns migrated\n`));
259
- }
260
- catch (err) {
261
- console.log(chalk.red(` x Pattern migration failed: ${err}\n`));
262
- }
263
- }
264
- else if (options.skipPatterns) {
265
- console.log(chalk.yellow('7. Pattern migration skipped\n'));
266
- }
267
- else {
268
- console.log(chalk.gray('7. No patterns to migrate\n'));
269
- }
270
- // Step 8: Migrate agent names (ADR-048)
271
- if ((!options.target || options.target === 'agents') && !options.skipAgents && agentsToMigrate.length > 0) {
272
- console.log(chalk.white('8. Migrating agent names (ADR-048)...'));
273
- let migratedAgents = 0;
274
- const deprecatedDir = path.join(claudeAgentDir, 'deprecated');
275
- if (!fs.existsSync(deprecatedDir)) {
276
- fs.mkdirSync(deprecatedDir, { recursive: true });
277
- }
278
- for (const v2Name of agentsToMigrate) {
279
- const v3Name = resolveAgentName(v2Name);
280
- const v2FilePath = path.join(claudeAgentDir, `${v2Name}.md`);
281
- const v3FilePath = path.join(claudeAgentDir, `${v3Name}.md`);
282
- const deprecatedPath = path.join(deprecatedDir, `${v2Name}.md.v2`);
283
- try {
284
- const content = fs.readFileSync(v2FilePath, 'utf-8');
285
- const frontmatterMatch = content.match(/^---\n([\s\S]*?)\n---/);
286
- if (!frontmatterMatch) {
287
- console.log(chalk.yellow(` ! ${v2Name}: No frontmatter found, skipping`));
288
- continue;
289
- }
290
- const frontmatter = frontmatterMatch[1];
291
- const bodyStart = content.indexOf('---', 4) + 4;
292
- let body = content.slice(bodyStart);
293
- let newFrontmatter = frontmatter.replace(/^name:\s*.+$/m, `name: ${v3Name}`);
294
- if (!newFrontmatter.includes('v2_compat:')) {
295
- newFrontmatter += `\nv2_compat:\n name: ${v2Name}\n deprecated_in: "3.0.0"\n removed_in: "4.0.0"`;
296
- }
297
- const toTitleCase = (s) => s.replace('qe-', '').split('-').map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(' ');
298
- const v2DisplayName = toTitleCase(v2Name);
299
- const v3DisplayName = toTitleCase(v3Name);
300
- body = body.replace(new RegExp(v2DisplayName, 'g'), v3DisplayName);
301
- body = body.replace(new RegExp(v2Name, 'g'), v3Name);
302
- const newContent = `---\n${newFrontmatter}\n---${body}`;
303
- fs.writeFileSync(v3FilePath, newContent, 'utf-8');
304
- fs.renameSync(v2FilePath, deprecatedPath);
305
- console.log(chalk.gray(` ${v2Name} -> ${v3Name}`));
306
- migratedAgents++;
307
- }
308
- catch (err) {
309
- console.log(chalk.red(` x ${v2Name}: ${err}`));
310
- }
311
- }
312
- if (migratedAgents > 0) {
313
- console.log(chalk.green(` * ${migratedAgents} agents migrated`));
314
- console.log(chalk.gray(` Old files archived to: ${deprecatedDir}\n`));
315
- }
316
- else {
317
- console.log(chalk.yellow(' ! No agents were migrated\n'));
318
- }
319
- }
320
- else if (options.skipAgents) {
321
- console.log(chalk.yellow('8. Agent migration skipped\n'));
322
- }
323
- else {
324
- console.log(chalk.gray('8. No agents need migration\n'));
325
- }
326
- // Step 9: Validation
327
- console.log(chalk.white('9. Validating migration...'));
328
- const validationResults = {
329
- v3DirExists: fs.existsSync(v3Dir),
330
- configExists: fs.existsSync(path.join(v3Dir, 'config.json')),
331
- agentdbExists: fs.existsSync(path.join(v3Dir, 'agentdb')),
332
- reasoningBankExists: fs.existsSync(path.join(v3Dir, 'reasoning-bank')),
333
- };
334
- const allValid = Object.values(validationResults).every(v => v);
335
- if (allValid) {
336
- console.log(chalk.green(' * Migration validated successfully\n'));
337
- }
338
- else {
339
- console.log(chalk.yellow(' ! Some validations failed:'));
340
- for (const [key, value] of Object.entries(validationResults)) {
341
- console.log(chalk.gray(` ${key}: ${value ? '*' : 'x'}`));
342
- }
343
- }
344
- // Summary
345
- console.log(chalk.blue('='.repeat(47)));
346
- console.log(chalk.green.bold(' Migration Complete!\n'));
347
- console.log(chalk.white('Next steps:'));
348
- console.log(chalk.gray(' 1. Run `aqe migrate verify` to validate'));
349
- console.log(chalk.gray(' 2. Run `aqe migrate status` to check'));
350
- console.log(chalk.gray(' 3. Use `aqe migrate rollback` if needed\n'));
351
- await cleanupAndExit(0);
352
- });
353
- // migrate status
354
- migrateCmd
355
- .command('status')
356
- .description('Check migration status of current project')
357
- .option('--json', 'Output as JSON')
358
- .action(async (options) => {
359
- const fs = await import('fs');
360
- const path = await import('path');
361
- const cwd = process.cwd();
362
- const v2Dir = path.join(cwd, '.agentic-qe');
363
- const v3Dir = path.join(cwd, '.aqe');
364
- const claudeAgentDir = path.join(cwd, '.claude', 'agents');
365
- const isV2Project = fs.existsSync(v2Dir);
366
- const isV3Project = fs.existsSync(v3Dir);
367
- const agentsToMigrate = [];
368
- const agentsMigrated = [];
369
- if (fs.existsSync(claudeAgentDir)) {
370
- const files = fs.readdirSync(claudeAgentDir);
371
- for (const file of files) {
372
- if (file.endsWith('.md') && file.startsWith('qe-')) {
373
- const agentName = file.replace('.md', '');
374
- if (isDeprecatedAgent(agentName)) {
375
- agentsToMigrate.push(agentName);
376
- }
377
- else if (v3Agents.includes(agentName)) {
378
- agentsMigrated.push(agentName);
379
- }
380
- }
381
- }
382
- }
383
- const needsMigration = isV2Project && !isV3Project || agentsToMigrate.length > 0;
384
- const status = {
385
- version: '3.0.0',
386
- isV2Project,
387
- isV3Project,
388
- needsMigration,
389
- agentsToMigrate,
390
- agentsMigrated,
391
- components: [
392
- { name: 'Data Directory', status: isV3Project ? 'migrated' : (isV2Project ? 'pending' : 'not-required') },
393
- { name: 'Agent Names', status: agentsToMigrate.length === 0 ? 'migrated' : 'pending' },
394
- ],
395
- };
396
- if (options.json) {
397
- console.log(JSON.stringify(status, null, 2));
398
- return;
399
- }
400
- console.log(chalk.bold('\n Migration Status\n'));
401
- console.log(`Version: ${chalk.cyan(status.version)}`);
402
- console.log(`V2 Project: ${status.isV2Project ? chalk.yellow('Yes') : chalk.dim('No')}`);
403
- console.log(`V3 Project: ${status.isV3Project ? chalk.green('Yes') : chalk.dim('No')}`);
404
- console.log(`Needs Migration: ${status.needsMigration ? chalk.yellow('Yes') : chalk.green('No')}`);
405
- console.log(chalk.bold('\n Components\n'));
406
- for (const comp of status.components) {
407
- const color = comp.status === 'migrated' ? chalk.green : comp.status === 'pending' ? chalk.yellow : chalk.dim;
408
- console.log(` ${comp.name}: ${color(comp.status)}`);
409
- }
410
- if (agentsToMigrate.length > 0) {
411
- console.log(chalk.bold('\n Agents Needing Migration\n'));
412
- for (const agent of agentsToMigrate) {
413
- console.log(` ${chalk.yellow(agent)} -> ${chalk.green(resolveAgentName(agent))}`);
414
- }
415
- }
416
- console.log();
417
- await cleanupAndExit(0);
418
- });
419
- // migrate verify
420
- migrateCmd
421
- .command('verify')
422
- .description('Verify migration integrity')
423
- .option('--fix', 'Attempt to fix issues automatically')
424
- .action(async (options) => {
425
- const fs = await import('fs');
426
- const path = await import('path');
427
- console.log(chalk.bold('\n Verifying Migration...\n'));
428
- const cwd = process.cwd();
429
- const v3Dir = path.join(cwd, '.aqe');
430
- const claudeAgentDir = path.join(cwd, '.claude', 'agents');
431
- const deprecatedInUse = [];
432
- if (fs.existsSync(claudeAgentDir)) {
433
- const files = fs.readdirSync(claudeAgentDir);
434
- for (const file of files) {
435
- if (file.endsWith('.md') && file.startsWith('qe-')) {
436
- const agentName = file.replace('.md', '');
437
- if (isDeprecatedAgent(agentName)) {
438
- deprecatedInUse.push(agentName);
439
- }
440
- }
441
- }
442
- }
443
- const checks = [
444
- {
445
- name: 'V3 Directory',
446
- passed: fs.existsSync(v3Dir),
447
- message: fs.existsSync(v3Dir) ? 'Exists' : 'Missing .aqe/',
448
- },
449
- {
450
- name: 'Agent Compatibility',
451
- passed: deprecatedInUse.length === 0,
452
- message: deprecatedInUse.length === 0 ? 'All agents use v3 names' : `${deprecatedInUse.length} deprecated agents`,
453
- },
454
- {
455
- name: 'Config Format',
456
- passed: fs.existsSync(path.join(v3Dir, 'config.json')),
457
- message: 'Valid v3 config',
458
- },
459
- ];
460
- let allPassed = true;
461
- for (const check of checks) {
462
- const icon = check.passed ? chalk.green('*') : chalk.red('x');
463
- const color = check.passed ? chalk.green : chalk.red;
464
- console.log(` ${icon} ${check.name}: ${color(check.message)}`);
465
- if (!check.passed)
466
- allPassed = false;
467
- }
468
- console.log();
469
- if (allPassed) {
470
- console.log(chalk.green(' All verification checks passed!\n'));
471
- }
472
- else {
473
- console.log(chalk.yellow(' Some checks failed.'));
474
- if (options.fix) {
475
- console.log(chalk.dim(' Attempting automatic fixes...\n'));
476
- // ... fix logic would go here
477
- }
478
- else {
479
- console.log(chalk.dim(' Run with --fix to attempt fixes.\n'));
480
- }
481
- }
482
- await cleanupAndExit(0);
483
- });
484
- // migrate rollback
485
- migrateCmd
486
- .command('rollback')
487
- .description('Rollback to previous version from backup')
488
- .option('--backup-id <id>', 'Specific backup to restore')
489
- .option('--force', 'Skip confirmation')
490
- .action(async (options) => {
491
- const fs = await import('fs');
492
- const path = await import('path');
493
- const cwd = process.cwd();
494
- const backupRoot = path.join(cwd, '.aqe-backup');
495
- if (!fs.existsSync(backupRoot)) {
496
- console.log(chalk.yellow('\n! No backups found.\n'));
497
- return;
498
- }
499
- const backups = fs.readdirSync(backupRoot)
500
- .filter(f => f.startsWith('backup-'))
501
- .sort()
502
- .reverse();
503
- if (backups.length === 0) {
504
- console.log(chalk.yellow('\n! No backups found.\n'));
505
- return;
506
- }
507
- console.log(chalk.bold('\n Available Backups\n'));
508
- for (const backup of backups.slice(0, 5)) {
509
- const timestamp = backup.replace('backup-', '');
510
- const date = new Date(parseInt(timestamp));
511
- console.log(` ${chalk.cyan(backup)} - ${date.toLocaleString()}`);
512
- }
513
- const targetBackup = options.backupId || backups[0];
514
- const backupPath = path.join(backupRoot, targetBackup);
515
- if (!fs.existsSync(backupPath)) {
516
- console.log(chalk.red(`\n Backup not found: ${targetBackup}\n`));
517
- await cleanupAndExit(1);
518
- }
519
- if (!options.force) {
520
- console.log(chalk.yellow(`\n! This will restore from: ${targetBackup}`));
521
- console.log(chalk.dim(' Run with --force to confirm.\n'));
522
- return;
523
- }
524
- console.log(chalk.bold(`\n Rolling back to ${targetBackup}...\n`));
525
- const v2Backup = path.join(backupPath, '.agentic-qe');
526
- const agentsBackup = path.join(backupPath, '.claude', 'agents');
527
- if (fs.existsSync(v2Backup)) {
528
- const v2Dir = path.join(cwd, '.agentic-qe');
529
- fs.cpSync(v2Backup, v2Dir, { recursive: true });
530
- console.log(chalk.dim(' Restored .agentic-qe/'));
531
- }
532
- if (fs.existsSync(agentsBackup)) {
533
- const agentsDir = path.join(cwd, '.claude', 'agents');
534
- fs.cpSync(agentsBackup, agentsDir, { recursive: true });
535
- console.log(chalk.dim(' Restored .claude/agents/'));
536
- }
537
- const v3Dir = path.join(cwd, '.aqe');
538
- if (fs.existsSync(v3Dir)) {
539
- fs.rmSync(v3Dir, { recursive: true, force: true });
540
- console.log(chalk.dim(' Removed .aqe/'));
541
- }
542
- console.log(chalk.green('\n Rollback complete!\n'));
543
- await cleanupAndExit(0);
544
- });
545
- // migrate mapping
546
- migrateCmd
547
- .command('mapping')
548
- .description('Show v2 to v3 agent name mappings (ADR-048)')
549
- .option('--json', 'Output as JSON')
550
- .action(async (options) => {
551
- if (options.json) {
552
- console.log(JSON.stringify(v2AgentMapping, null, 2));
553
- return;
554
- }
555
- console.log(chalk.bold('\n Agent Name Mappings (V2 -> V3)\n'));
556
- const entries = Object.entries(v2AgentMapping);
557
- for (const [v2Name, v3Name] of entries) {
558
- console.log(` ${chalk.yellow(v2Name)} -> ${chalk.green(v3Name)}`);
559
- }
560
- console.log(chalk.dim(`\n Total: ${entries.length} mappings\n`));
561
- console.log(chalk.gray(' See ADR-048 for full migration strategy.\n'));
562
- await cleanupAndExit(0);
563
- });
564
- return migrateCmd;
565
- }
566
- //# sourceMappingURL=migrate.js.map
@@ -1,52 +0,0 @@
1
- /**
2
- * Init Wizard - V2 Migration Logic
3
- *
4
- * Contains V2 installation detection, migration, and config conversion.
5
- * Extracted from init-wizard.ts.
6
- */
7
- /**
8
- * V2 Installation Detection Result
9
- */
10
- export interface V2DetectionResult {
11
- detected: boolean;
12
- memoryDbPath?: string;
13
- configPath?: string;
14
- agentsPath?: string;
15
- hasMemoryDb: boolean;
16
- hasConfig: boolean;
17
- hasAgents: boolean;
18
- version?: string;
19
- }
20
- /**
21
- * Read AQE version directly from memory.db without full initialization.
22
- * Returns undefined if no version is stored (v2 installations).
23
- */
24
- export declare function readVersionFromDb(dbPath: string): string | undefined;
25
- /**
26
- * Write AQE version to memory.db in _system namespace.
27
- * This marks the installation as v3.
28
- */
29
- export declare function writeVersionToDb(projectRoot: string, version: string): Promise<boolean>;
30
- /**
31
- * Detect existing v2 AQE installation.
32
- *
33
- * Detection logic:
34
- * 1. If memory.db exists, try to read aqe_version from kv_store._system
35
- * 2. If version exists and starts with '3.', it's v3 - not detected
36
- * 3. If no version or version < 3.0.0, and v2 markers exist, it's v2
37
- */
38
- export declare function detectV2Installation(projectRoot: string): Promise<V2DetectionResult>;
39
- /**
40
- * Run v2 to v3 migration during init (when --auto-migrate is used).
41
- */
42
- export declare function runV2Migration(projectRoot: string, v2Detection: V2DetectionResult): Promise<void>;
43
- /**
44
- * Remove v2 QE agents from .claude/agents/ root folder.
45
- * V2 QE agents are replaced by current agents in .claude/agents/v3/.
46
- */
47
- export declare function removeV2QEAgents(projectRoot: string): Promise<void>;
48
- /**
49
- * Migrate v2 config files to v3 format.
50
- */
51
- export declare function migrateV2Config(projectRoot: string, v2Detection: V2DetectionResult): Promise<void>;
52
- //# sourceMappingURL=init-wizard-migration.d.ts.map