@flowspec-qa/runner 0.2.4 → 0.4.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 (49) hide show
  1. package/dist/commands/capture.d.ts +22 -0
  2. package/dist/commands/capture.d.ts.map +1 -0
  3. package/dist/commands/capture.js +110 -0
  4. package/dist/commands/capture.js.map +1 -0
  5. package/dist/commands/discover.d.ts.map +1 -1
  6. package/dist/commands/discover.js +403 -37
  7. package/dist/commands/discover.js.map +1 -1
  8. package/dist/commands/generate.d.ts +3 -0
  9. package/dist/commands/generate.d.ts.map +1 -0
  10. package/dist/commands/generate.js +63 -0
  11. package/dist/commands/generate.js.map +1 -0
  12. package/dist/commands/ingest.d.ts.map +1 -1
  13. package/dist/commands/ingest.js +9 -1
  14. package/dist/commands/ingest.js.map +1 -1
  15. package/dist/commands/mcp-server.d.ts.map +1 -1
  16. package/dist/commands/mcp-server.js +2 -1
  17. package/dist/commands/mcp-server.js.map +1 -1
  18. package/dist/commands/projects.d.ts.map +1 -1
  19. package/dist/commands/projects.js +34 -0
  20. package/dist/commands/projects.js.map +1 -1
  21. package/dist/commands/record.d.ts +13 -0
  22. package/dist/commands/record.d.ts.map +1 -0
  23. package/dist/commands/record.js +90 -0
  24. package/dist/commands/record.js.map +1 -0
  25. package/dist/commands/report.d.ts +3 -0
  26. package/dist/commands/report.d.ts.map +1 -0
  27. package/dist/commands/report.js +40 -0
  28. package/dist/commands/report.js.map +1 -0
  29. package/dist/commands/run.d.ts.map +1 -1
  30. package/dist/commands/run.js +110 -32
  31. package/dist/commands/run.js.map +1 -1
  32. package/dist/index.js +11 -1
  33. package/dist/index.js.map +1 -1
  34. package/package.json +9 -5
  35. package/.maestro.env +0 -20
  36. package/src/commands/auth.ts +0 -65
  37. package/src/commands/devices.ts +0 -76
  38. package/src/commands/discover.ts +0 -84
  39. package/src/commands/doctor.ts +0 -134
  40. package/src/commands/heal.ts +0 -53
  41. package/src/commands/ingest.ts +0 -56
  42. package/src/commands/mcp-server.ts +0 -140
  43. package/src/commands/projects.ts +0 -31
  44. package/src/commands/results.ts +0 -34
  45. package/src/commands/run.ts +0 -225
  46. package/src/commands/suites.ts +0 -41
  47. package/src/index.ts +0 -34
  48. package/test_simple.yaml +0 -3
  49. package/tsconfig.json +0 -8
@@ -0,0 +1,22 @@
1
+ /**
2
+ * `flowspecqa capture` — Phase 13 (Manual Capture).
3
+ *
4
+ * Single-shot capture of the current device screen. Used to fill specific
5
+ * evidence gaps that the autonomous Discovery couldn't reach (e.g. a
6
+ * comprobante after PIN/2FA, an error state from a server-side condition).
7
+ *
8
+ * Usage:
9
+ * flowspecqa capture --entity X --label "Comprobante transferencia exitosa"
10
+ *
11
+ * Flow:
12
+ * 1. Auto-pick or accept --device serial.
13
+ * 2. Wake screen + read current hierarchy + take screenshot.
14
+ * 3. Build a single EvidenceRecord with capture_mode='manual'.
15
+ * 4. Upload to backend as a standalone manual capture.
16
+ * 5. Print the next step (validate in UI to promote to baseline).
17
+ *
18
+ * Spec: DISCOVERY_SPEC.md § 13.
19
+ */
20
+ import { Command } from 'commander';
21
+ export declare function captureCommand(): Command;
22
+ //# sourceMappingURL=capture.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capture.d.ts","sourceRoot":"","sources":["../../src/commands/capture.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKpC,wBAAgB,cAAc,IAAI,OAAO,CA2FxC"}
@@ -0,0 +1,110 @@
1
+ /**
2
+ * `flowspecqa capture` — Phase 13 (Manual Capture).
3
+ *
4
+ * Single-shot capture of the current device screen. Used to fill specific
5
+ * evidence gaps that the autonomous Discovery couldn't reach (e.g. a
6
+ * comprobante after PIN/2FA, an error state from a server-side condition).
7
+ *
8
+ * Usage:
9
+ * flowspecqa capture --entity X --label "Comprobante transferencia exitosa"
10
+ *
11
+ * Flow:
12
+ * 1. Auto-pick or accept --device serial.
13
+ * 2. Wake screen + read current hierarchy + take screenshot.
14
+ * 3. Build a single EvidenceRecord with capture_mode='manual'.
15
+ * 4. Upload to backend as a standalone manual capture.
16
+ * 5. Print the next step (validate in UI to promote to baseline).
17
+ *
18
+ * Spec: DISCOVERY_SPEC.md § 13.
19
+ */
20
+ import { Command } from 'commander';
21
+ import chalk from 'chalk';
22
+ import ora from 'ora';
23
+ import { discoveryEngine } from '@flowspec-qa/runner-core';
24
+ export function captureCommand() {
25
+ return new Command('capture')
26
+ .description('Captura manual de una pantalla — útil para llenar gaps que el Discovery autónomo no alcanzó (ej: comprobantes post-2FA)')
27
+ .requiredOption('--entity <id>', 'Entity ID donde guardar la captura')
28
+ .requiredOption('--label <label>', 'Nombre humano del flujo o pantalla (ej: "Comprobante transferencia exitosa")')
29
+ .option('--project <id>', 'Project ID (UUID o nombre like TRUSTBANK)')
30
+ .option('--device <serial>', 'Serial del dispositivo. Auto-detectado si hay uno solo.')
31
+ .option('--app-id <id>', 'App package ID (opcional, mejora trazabilidad)')
32
+ .action(async (options) => {
33
+ // ── Auto-pick device if not specified ─────────────────────────
34
+ let deviceId = options.device;
35
+ if (!deviceId) {
36
+ const { detectAllDevices } = await import('@flowspec-qa/runner-core');
37
+ const ready = detectAllDevices('android').filter((d) => d.status === 'ready');
38
+ if (ready.length === 0) {
39
+ console.error(chalk.red('\n❌ Sin dispositivos Android listos. Conecta uno y habilita USB Debugging.\n'));
40
+ console.log(chalk.dim(' Ejecuta: flowspecqa devices para verificar.'));
41
+ process.exit(1);
42
+ }
43
+ if (ready.length === 1) {
44
+ deviceId = ready[0].id;
45
+ console.log(chalk.dim(`📱 Dispositivo auto-seleccionado: ${chalk.bold(ready[0].name)} (${deviceId})`));
46
+ }
47
+ else {
48
+ console.error(chalk.yellow('\n⚠️ Múltiples dispositivos conectados. Especifica uno con --device <serial>:\n'));
49
+ ready.forEach((d, i) => {
50
+ console.log(` ${i + 1}. ${chalk.bold(d.name.padEnd(28))} ${chalk.dim(d.id)}`);
51
+ });
52
+ process.exit(1);
53
+ }
54
+ }
55
+ // Resolve Project ID
56
+ let projectId = options.project;
57
+ const { FlowSpecQAApi } = await import('@flowspec-qa/runner-core');
58
+ try {
59
+ const projects = await FlowSpecQAApi.listProjects();
60
+ if (projectId) {
61
+ const match = projects.find((p) => p.name === projectId || p.id === projectId);
62
+ if (match)
63
+ projectId = match.id;
64
+ }
65
+ else {
66
+ const trustBank = projects.find((p) => p.name === 'TRUSTBANK');
67
+ projectId = trustBank ? trustBank.id : projects[0]?.id;
68
+ }
69
+ }
70
+ catch (e) { }
71
+ console.log(chalk.cyan(`\n📸 Captura manual — ${chalk.bold(options.label)}`));
72
+ console.log(chalk.gray(` Entidad: ${options.entity}`));
73
+ console.log(chalk.gray(` Dispositivo: ${deviceId}\n`));
74
+ console.log(chalk.dim(' Asegúrate de que la app esté en la pantalla que quieres capturar.\n'));
75
+ const spinner = ora('Capturando estado del dispositivo...').start();
76
+ try {
77
+ const result = await discoveryEngine.captureSingleManualScreen({
78
+ entityId: options.entity,
79
+ projectId,
80
+ label: options.label,
81
+ appId: options.appId,
82
+ deviceId,
83
+ runnerVersion: '0.3.0',
84
+ onProgress: (step, detail) => {
85
+ spinner.text = detail || step;
86
+ },
87
+ });
88
+ spinner.succeed(chalk.green(`Captura registrada: ${chalk.bold(result.record_id.slice(0, 8))} · ` +
89
+ `calidad ${chalk.cyan(result.evidence_quality)} · ` +
90
+ `${result.elements_count} elementos · ` +
91
+ `${result.has_screenshot ? '📷 con screenshot' : '⚠️ sin screenshot'}`));
92
+ console.log('');
93
+ console.log(chalk.bold(' Próximos pasos'));
94
+ console.log(chalk.gray(' ──────────────────────────────────────────'));
95
+ console.log(` ${chalk.cyan('Validar ')} Abre la UI → Entidad ${options.entity} → tab "Baseline"`);
96
+ console.log(` ${chalk.cyan('Promover ')} Click "Validar evidencia" para que pase a baseline canónico`);
97
+ console.log(` ${chalk.cyan('Reusar ')} Próximo \`flowspecqa discover --mode incremental\` saltará esta pantalla`);
98
+ console.log('');
99
+ if (result.evidence_quality !== 'complete') {
100
+ console.log(chalk.yellow(` ⚠️ Calidad ${result.evidence_quality} — `
101
+ + 'considera capturar de nuevo si el screenshot quedó parcial.\n'));
102
+ }
103
+ }
104
+ catch (err) {
105
+ spinner.fail(chalk.red(`Captura fallida: ${err?.message || err}`));
106
+ process.exit(1);
107
+ }
108
+ });
109
+ }
110
+ //# sourceMappingURL=capture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capture.js","sourceRoot":"","sources":["../../src/commands/capture.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,MAAM,UAAU,cAAc;IAC5B,OAAO,IAAI,OAAO,CAAC,SAAS,CAAC;SAC1B,WAAW,CAAC,yHAAyH,CAAC;SACtI,cAAc,CAAC,eAAe,EAAE,oCAAoC,CAAC;SACrE,cAAc,CAAC,iBAAiB,EAAE,8EAA8E,CAAC;SACjH,MAAM,CAAC,gBAAgB,EAAE,2CAA2C,CAAC;SACrE,MAAM,CAAC,mBAAmB,EAAE,yDAAyD,CAAC;SACtF,MAAM,CAAC,eAAe,EAAE,gDAAgD,CAAC;SACzE,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;QACxB,iEAAiE;QACjE,IAAI,QAAQ,GAAuB,OAAO,CAAC,MAAM,CAAC;QAClD,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,EAAE,gBAAgB,EAAE,GAAG,MAAM,MAAM,CAAC,0BAA0B,CAAC,CAAC;YACtE,MAAM,KAAK,GAAG,gBAAgB,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,CAAM,EAAE,EAAE,CA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;YAEhB,IAAI,MAAM,CAAC,gBAAgB,KAAK,UAAU,EAAE,CAAC;gBAC3C,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CACtB,iBAAiB,MAAM,CAAC,gBAAgB,KAAK;sBAC3C,+DAA+D,CAClE,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,oBAAoB,GAAG,EAAE,OAAO,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC;YACnE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"discover.d.ts","sourceRoot":"","sources":["../../src/commands/discover.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,wBAAgB,eAAe,IAAI,OAAO,CA+EzC"}
1
+ {"version":3,"file":"discover.d.ts","sourceRoot":"","sources":["../../src/commands/discover.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC,wBAAgB,eAAe,IAAI,OAAO,CA6ezC"}
@@ -1,73 +1,439 @@
1
1
  import { Command } from 'commander';
2
2
  import chalk from 'chalk';
3
- import ora from 'ora';
3
+ import inquirer from 'inquirer';
4
+ import path from 'path';
5
+ import { classifyCorpus } from '@flowspec-qa/runner-core';
4
6
  export function discoverCommand() {
5
7
  return new Command('discover')
6
- .description('Discover application flows and generate test plans (Discovery QA)')
7
- .argument('<url>', 'URL or app package ID to discover (web: http://..., mobile: com.example.app)')
8
- .option('--mobile', 'Discover a mobile application on a physical device via Maestro', false)
9
- .option('--project <id>', 'Optional Project ID for SaaS sync')
10
- .option('--entity <id>', 'Optional Entity ID for explicit association')
11
- .option('--username <email>', 'Username/email for app login (or FLOWSPECQA_APP_USERNAME env var)')
12
- .option('--password <password>', 'Password for app login (or FLOWSPECQA_APP_PASSWORD env var)')
13
- .option('--device <serial>', 'Android device serial to target (from `flowspecqa devices`). Auto-selected when only one Android is connected.')
8
+ .description('Descubre flujos de la aplicación y genera plan de pruebas con evidencias visuales')
9
+ .argument('<url>', 'URL o package ID de la app (web: http://..., mobile: com.example.app)')
10
+ .option('--mobile', 'Descubrir app móvil en dispositivo físico via Maestro', false)
11
+ .option('--project <id>', 'Project ID para sync con SaaS')
12
+ .option('--entity <id>', 'Entity ID para asociación explícita')
13
+ .option('--username <email>', 'Email/usuario para login en la app (o env FLOWSPECQA_APP_USERNAME)')
14
+ .option('--password <password>', 'Contraseña (o env FLOWSPECQA_APP_PASSWORD)')
15
+ .option('--device <serial>', 'Serial del dispositivo Android (de `flowspecqa devices`). Auto-seleccionado si hay uno solo.')
16
+ .option('--no-interactive', 'Desactiva el loop interactivo — ejecuta Discovery de una sola pasada')
17
+ .option('--mode <mode>', 'Modo de Discovery: full (default), incremental, recapture, resume', 'full')
14
18
  .action(async (url, options) => {
15
- // ── Auto device selection for mobile ─────────────────────────────
19
+ // ── Auto-selección de dispositivo ────────────────────────────────
16
20
  let deviceId = options.device;
17
21
  if (options.mobile && !deviceId) {
18
22
  const { detectAllDevices } = await import('@flowspec-qa/runner-core');
19
23
  const ready = detectAllDevices('android').filter((d) => d.status === 'ready');
20
24
  if (ready.length === 0) {
21
- console.error(chalk.red('\n❌ No Android devices ready. Connect a device and enable USB Debugging.\n'));
22
- console.log(chalk.dim(' Run: flowspecqa devices to check connected devices.'));
25
+ console.error(chalk.red('\n❌ Sin dispositivos Android listos. Conecta uno y habilita USB Debugging.\n'));
26
+ console.log(chalk.dim(' Ejecuta: flowspecqa devices para verificar dispositivos.'));
23
27
  process.exit(1);
24
28
  }
25
29
  if (ready.length === 1) {
26
30
  deviceId = ready[0].id;
27
- console.log(chalk.dim(`\n📱 Auto-selected device: ${chalk.bold(ready[0].name)} (${deviceId})`));
31
+ console.log(chalk.dim(`\n📱 Dispositivo auto-seleccionado: ${chalk.bold(ready[0].name)} (${deviceId})`));
28
32
  }
29
33
  else {
30
- // Multiple devices — list and require explicit --device
31
- console.error(chalk.yellow('\n⚠️ Multiple Android devices connected. Specify one with --device <serial>:\n'));
34
+ console.error(chalk.yellow('\n⚠️ Múltiples dispositivos Android conectados. Especifica uno con --device <serial>:\n'));
32
35
  ready.forEach((d, i) => {
33
36
  console.log(` ${i + 1}. ${chalk.bold(d.name.padEnd(28))} ${chalk.dim(d.id)} Android ${d.osVersion ?? '?'}`);
34
37
  });
35
- console.log(`\n ${chalk.cyan('Example:')} flowspecqa discover ${url} --mobile --device ${ready[0].id}\n`);
38
+ console.log(`\n ${chalk.cyan('Ejemplo:')} flowspecqa discover ${url} --mobile --device ${ready[0].id}\n`);
36
39
  process.exit(1);
37
40
  }
38
41
  }
39
- const spinner = ora(`Exploring ${url}...`).start();
42
+ // ── Progress callback — muestra log en tiempo real ───────────────
43
+ const stepLabels = {
44
+ start: '🚀 Iniciando Discovery...',
45
+ reset: '🔄 Reseteando estado de la app...',
46
+ screen: '📸 Capturando pantalla',
47
+ error_state: '⚠️ Explorando estado de error',
48
+ login: '🔐 Autenticando para pantallas privadas...',
49
+ navigate: '🌐 Navegando',
50
+ dom: '🔍 Extrayendo elementos del DOM...',
51
+ screenshot: '📸 Capturando screenshots...',
52
+ vision: '🧠 Analizando con Vision AI...',
53
+ sync: '📡 Sincronizando con SaaS...',
54
+ };
55
+ const onProgress = (step, detail) => {
56
+ const label = stepLabels[step] || ` ${step}`;
57
+ const detailStr = detail ? chalk.gray(` — ${detail}`) : '';
58
+ process.stdout.write(`\r${chalk.cyan(' →')} ${label}${detailStr}${' '.repeat(10)}\n`);
59
+ };
60
+ // ── Validate --mode flag (Phase 8 atomization + Phase 11 incremental) ──
61
+ const mode = String(options.mode || 'full').toLowerCase();
62
+ const VALID_MODES = ['full', 'incremental', 'recapture', 'resume'];
63
+ if (!VALID_MODES.includes(mode)) {
64
+ console.error(chalk.red(`\n❌ --mode inválido: "${mode}". Valores aceptados: ${VALID_MODES.join(', ')}`));
65
+ process.exit(1);
66
+ }
67
+ // Sprint 6 implements incremental. Recapture and resume still pending.
68
+ if (mode === 'recapture') {
69
+ console.log(chalk.yellow(`⚠️ --mode recapture todavía es parcial — usa la misma lógica que incremental por ahora.\n` +
70
+ ` Sprint 6+ entregará el filtro estricto a pantallas marcadas needs_recapture.\n`));
71
+ }
72
+ if (mode === 'resume') {
73
+ if (!options.mobile) {
74
+ console.error(chalk.red(`\n❌ --mode resume solo está disponible para mobile (--mobile).\n`));
75
+ process.exit(1);
76
+ }
77
+ console.log(chalk.cyan(`🤝 Modo resume activado.\n` +
78
+ ` Asegúrate de tener la app abierta en el dispositivo y haber pasado\n` +
79
+ ` manualmente cualquier paso bloqueante (PIN/2FA/OTP/SSO/biometría).\n` +
80
+ ` Discovery NO va a reiniciar la app — captura desde el estado actual.\n`));
81
+ }
82
+ if (mode === 'incremental' && !options.entity) {
83
+ console.error(chalk.red(`\n❌ --mode incremental requiere --entity para consultar el baseline.\n`));
84
+ process.exit(1);
85
+ }
86
+ console.log(chalk.blue(`\n🔍 FlowSpec QA Discovery — ${chalk.bold(url)}`));
87
+ console.log(chalk.gray(` Framework: ${options.mobile ? 'Maestro (mobile)' : 'Playwright (web)'}`));
88
+ console.log(chalk.gray(` Modo: ${mode}\n`));
40
89
  try {
41
90
  const { discoveryEngine } = await import('@flowspec-qa/runner-core');
42
- spinner.text = 'Phase 1: Analyzing application structure...';
43
- await new Promise(r => setTimeout(r, 800));
44
- spinner.text = 'Phase 2: Extracting interactive elements (buttons, inputs)...';
45
- await new Promise(r => setTimeout(r, 1200));
46
- spinner.text = 'Phase 3: Building autonomous discovery plan...';
47
- await discoveryEngine.run({
91
+ // ── Interactive loop callback (mobile only, unless --no-interactive or non-TTY) ──
92
+ // Commander's --no-X flags default options.interactive to true.
93
+ // We also skip the loop in non-TTY contexts (CI, background processes).
94
+ const interactiveEnabled = options.mobile &&
95
+ options.interactive !== false &&
96
+ process.stdout.isTTY === true;
97
+ // Track the corpus across the run + interactive loop so exploreElement
98
+ // can register EvidenceRecords into the same corpus.
99
+ let discoveryCorpus;
100
+ // ── Step 0: Ensure project_id is available ──────────────────
101
+ let projectId = options.project;
102
+ const { FlowSpecQAApi } = await import('@flowspec-qa/runner-core');
103
+ const projects = await FlowSpecQAApi.listProjects();
104
+ if (projectId) {
105
+ // If user provided a name (e.g. TRUSTBANK), resolve to UUID
106
+ const match = projects.find(p => p.name === projectId || p.id === projectId);
107
+ if (match)
108
+ projectId = match.id;
109
+ }
110
+ else {
111
+ if (projects.length === 0) {
112
+ console.error(chalk.red('\n❌ No tienes proyectos en FlowSpecQA.\n'));
113
+ process.exit(1);
114
+ }
115
+ if (projects.length === 1) {
116
+ projectId = projects[0].id;
117
+ console.log(chalk.dim(`\n📁 Auto-asociando al único proyecto: ${chalk.bold(projects[0].name)}`));
118
+ }
119
+ else {
120
+ const trustBank = projects.find((p) => p.name === 'TRUSTBANK');
121
+ if (trustBank && interactiveEnabled) {
122
+ const { useTrustBank } = await inquirer.prompt([{
123
+ type: 'confirm',
124
+ name: 'useTrustBank',
125
+ message: `He encontrado el proyecto ${chalk.bold('TRUSTBANK')}. ¿Quieres usarlo?`,
126
+ default: true
127
+ }]);
128
+ if (useTrustBank)
129
+ projectId = trustBank.id;
130
+ }
131
+ if (!projectId && interactiveEnabled) {
132
+ const { selectedProject } = await inquirer.prompt([{
133
+ type: 'list',
134
+ name: 'selectedProject',
135
+ message: 'Por favor, selecciona un proyecto:',
136
+ choices: projects.map(p => ({ name: p.name, value: p.id }))
137
+ }]);
138
+ projectId = selectedProject;
139
+ }
140
+ else if (!projectId) {
141
+ projectId = trustBank ? trustBank.id : projects[0].id;
142
+ }
143
+ }
144
+ }
145
+ // ── Hybrid Discovery Decision Point ──────────────────────────
146
+ if (interactiveEnabled && mode === 'resume') {
147
+ console.log('\n' + chalk.cyan('─'.repeat(60)));
148
+ console.log(chalk.bold('🤖 Discovery Híbrido Activado'));
149
+ console.log(chalk.gray(' He detectado el dispositivo. ¿Cómo quieres explorar Consorcio?'));
150
+ console.log(chalk.cyan('─'.repeat(60)));
151
+ const { hybridChoice } = await inquirer.prompt([{
152
+ type: 'list',
153
+ name: 'hybridChoice',
154
+ message: 'Selecciona una estrategia:',
155
+ choices: [
156
+ { name: '🤖 Modo Automático (IA explora sola)', value: 'auto' },
157
+ { name: '🤝 Modo Asistido (Tú eliges los pasos, la IA los ejecuta)', value: 'assisted' },
158
+ { name: '🎬 Modo Manual (Tú grabas el flujo - Estilo JMeter)', value: 'manual' },
159
+ ],
160
+ }]);
161
+ if (hybridChoice === 'manual') {
162
+ console.log(chalk.yellow('\n🎬 Iniciando Modo Recorder guiado...'));
163
+ const { runRecordSession } = await import('./record.js');
164
+ await runRecordSession({
165
+ entity: options.entity || 'Consorcio-Discovery',
166
+ projectId: projectId,
167
+ deviceId: deviceId,
168
+ appId: url
169
+ });
170
+ return;
171
+ }
172
+ if (hybridChoice === 'assisted') {
173
+ console.log(chalk.cyan('\n🤝 Iniciando Discovery Asistido (Paso a Paso)...'));
174
+ // Set a flag to tell the loop to be more guided/step-by-step
175
+ options.assisted = true;
176
+ }
177
+ }
178
+ // ── onFormDetected — prompt tester for field values ─────────────────
179
+ const onFormDetected = interactiveEnabled
180
+ ? async (form) => {
181
+ console.log('\n' + chalk.cyan('─'.repeat(60)));
182
+ console.log(chalk.bold('📋 Discovery encontró un formulario\n'));
183
+ console.log(` ${chalk.bold('Pantalla:')} ${form.screenName}`);
184
+ console.log(` ${chalk.bold('Campos detectados:')}`);
185
+ form.fields.forEach((f) => {
186
+ console.log(` ${chalk.cyan('•')} ${chalk.bold(f.id)}${f.label ? ` — ${f.label}` : ''}`);
187
+ });
188
+ console.log(chalk.cyan('─'.repeat(60)));
189
+ const { explore } = await inquirer.prompt([{
190
+ type: 'confirm',
191
+ name: 'explore',
192
+ message: '¿Deseas explorar este flujo?',
193
+ default: true,
194
+ }]);
195
+ if (!explore)
196
+ return null;
197
+ console.log(chalk.bold('\n Ingresa los datos de prueba:'));
198
+ const answers = await inquirer.prompt(form.fields.map((f) => ({
199
+ type: 'input',
200
+ name: f.id,
201
+ message: ` › ${f.label || f.id}:`,
202
+ default: '',
203
+ })));
204
+ const testerLabel = (await inquirer.prompt([{
205
+ type: 'input',
206
+ name: 'label',
207
+ message: ' ¿Cómo quieres llamar a este flujo?',
208
+ default: `${form.screenName} — flujo principal`,
209
+ }])).label;
210
+ console.log(chalk.green(`\n ✅ Datos capturados para "${testerLabel}"`));
211
+ return answers;
212
+ }
213
+ : undefined;
214
+ // ── onRetryFailed — app no cargó tras reintentos automáticos ────────
215
+ const onRetryFailed = interactiveEnabled
216
+ ? async (message) => {
217
+ console.log('\n' + chalk.red('─'.repeat(60)));
218
+ console.log(chalk.bold.red('🚨 La app no pudo ser confirmada en primer plano\n'));
219
+ console.log(chalk.yellow(` ${message}`));
220
+ console.log(chalk.red('─'.repeat(60)));
221
+ const { proceed } = await inquirer.prompt([{
222
+ type: 'confirm',
223
+ name: 'proceed',
224
+ message: '¿Continuar de todas formas? (la evidencia capturada puede ser incorrecta)',
225
+ default: false,
226
+ }]);
227
+ if (!proceed) {
228
+ console.log(chalk.red('\n❌ Discovery abortado por el usuario.'));
229
+ process.exit(1);
230
+ }
231
+ return true;
232
+ }
233
+ : undefined;
234
+ const onInteractiveLoop = interactiveEnabled
235
+ ? async (evidence) => {
236
+ const unexplored = discoveryEngine.detectUnexplored(evidence);
237
+ const currentScreen = evidence.screens[evidence.screens.length - 1]?.name;
238
+ // In assisted mode, we prioritize elements from the current screen
239
+ const displayList = options.assisted
240
+ ? unexplored.filter((u) => u.sourceScreen === currentScreen)
241
+ : unexplored;
242
+ // If current screen is fully explored in assisted mode, show ALL unexplored or finish
243
+ const effectiveList = (options.assisted && displayList.length === 0) ? unexplored : displayList;
244
+ if (effectiveList.length === 0) {
245
+ console.log(chalk.green('\n✅ Discovery completado — no quedan elementos sin explorar.'));
246
+ return false;
247
+ }
248
+ // ── Summary banner ──────────────────────────────────────
249
+ const mainScreens = evidence.screens.filter((s) => !s.isErrorState).length;
250
+ const errorStates = evidence.screens.filter((s) => s.isErrorState).length;
251
+ const confScore = Math.min(95, 50 + evidence.verifiedTexts.length * 8 + errorStates * 4);
252
+ console.log('\n' + chalk.cyan('─'.repeat(60)));
253
+ console.log(chalk.bold('📊 Resumen Discovery:') +
254
+ ` ${chalk.green(mainScreens + ' pantallas')}` +
255
+ ` ${chalk.yellow(evidence.metrics.elementsFound + ' elementos')}` +
256
+ ` ${chalk.red(errorStates + ' error states')}` +
257
+ ` ${chalk.blue('Confianza: ~' + confScore + '%')}`);
258
+ console.log(chalk.cyan('─'.repeat(60)));
259
+ if (options.assisted) {
260
+ console.log(chalk.bold.cyan(`\n📍 Pantalla actual: ${chalk.white(currentScreen)}`));
261
+ console.log(chalk.dim(` Elige qué acción quieres que la IA ejecute ahora:\n`));
262
+ }
263
+ else {
264
+ console.log(chalk.bold.yellow('\n🔍 Elementos sin explorar:\n'));
265
+ }
266
+ effectiveList.forEach((u, i) => {
267
+ const text = u.elementText ? chalk.white(`"${u.elementText.substring(0, 25)}"`) : '';
268
+ console.log(` ${chalk.dim(String(i + 1).padStart(2, ' '))}. ` +
269
+ `${chalk.cyan(u.elementId.padEnd(26))} ${text.padEnd(30)} ` +
270
+ (options.assisted ? '' : chalk.gray(`en: ${u.sourceScreen}`)));
271
+ });
272
+ // ── Inquirer checkbox ───────────────────────────────────
273
+ const { selected } = await inquirer.prompt([{
274
+ type: options.assisted ? 'list' : 'checkbox', // List for step-by-step, checkbox for batch
275
+ name: 'selected',
276
+ message: options.assisted ? 'Selecciona el siguiente paso:' : '¿Qué quieres explorar?',
277
+ pageSize: Math.min(15, effectiveList.length + 3),
278
+ instructions: false,
279
+ choices: [
280
+ ...effectiveList.map((u) => {
281
+ const label = chalk.cyan(u.elementId.padEnd(26)) +
282
+ (u.elementText ? chalk.white(`"${u.elementText.substring(0, 22)}"`) : chalk.dim('(sin texto)')) +
283
+ (options.assisted ? '' : chalk.gray(` ← ${u.sourceScreen}`));
284
+ return { name: label, value: u };
285
+ }),
286
+ new inquirer.Separator(' ────────────────────────────────────────'),
287
+ {
288
+ name: chalk.green('✅ Finalizar — generar suite con lo explorado'),
289
+ value: '__DONE__',
290
+ },
291
+ ],
292
+ }]);
293
+ // User chose "Done" or nothing
294
+ if (!selected || (Array.isArray(selected) && selected.length === 0) || selected === '__DONE__' || (Array.isArray(selected) && selected.includes('__DONE__'))) {
295
+ console.log(chalk.green('\n✅ Generando suite con evidencias actuales...'));
296
+ return false;
297
+ }
298
+ // Normalize to array
299
+ const toExplore = Array.isArray(selected) ? selected : [selected];
300
+ // ── Explore each selected element ───────────────────────
301
+ if (!options.assisted) {
302
+ console.log(chalk.blue(`\n🔭 Explorando ${toExplore.length} elemento(s)...\n`));
303
+ }
304
+ for (const element of toExplore) {
305
+ const label = element.elementText
306
+ ? `${element.elementId} ("${element.elementText.substring(0, 20)}")`
307
+ : element.elementId;
308
+ console.log(chalk.bold(`\n → ${label} ${chalk.gray('en ' + element.sourceScreen)}`));
309
+ const newScreens = await discoveryEngine.exploreElement(element, {
310
+ url,
311
+ framework: 'maestro',
312
+ projectId,
313
+ entityId: options.entity,
314
+ username: options.username || process.env.FLOWSPECQA_APP_USERNAME,
315
+ password: options.password || process.env.FLOWSPECQA_APP_PASSWORD,
316
+ deviceId,
317
+ onProgress,
318
+ onFormDetected,
319
+ onRetryFailed,
320
+ }, evidence, discoveryCorpus);
321
+ if (newScreens.length > 0) {
322
+ console.log(chalk.green(` ✅ +${newScreens.length} pantalla(s) nueva(s): ` +
323
+ newScreens.map((s) => chalk.bold(s.name)).join(', ')));
324
+ }
325
+ }
326
+ return true; // continue loop — show updated unexplored list
327
+ }
328
+ : undefined;
329
+ const runResult = await discoveryEngine.run({
48
330
  url,
49
331
  framework: options.mobile ? 'maestro' : 'playwright',
50
- projectId: options.project,
332
+ projectId: projectId,
51
333
  entityId: options.entity,
52
334
  username: options.username || process.env.FLOWSPECQA_APP_USERNAME,
53
335
  password: options.password || process.env.FLOWSPECQA_APP_PASSWORD,
54
336
  deviceId,
337
+ // Phase 11 — pass the validated mode to the engine.
338
+ // The engine consults the entity's baseline when mode='incremental'
339
+ // and skips screens whose fingerprint matches a verified baseline.
340
+ mode: mode,
341
+ onProgress,
342
+ onInteractiveLoop,
343
+ onFormDetected,
344
+ onRetryFailed,
55
345
  });
56
- spinner.succeed(`Discovery complete! Intelligence gathered from ${chalk.bold(url)}.`);
57
- console.log(`\n${chalk.cyan('╔══════════════════════════════════════════════════════════════════════╗')}`);
58
- console.log(`${chalk.cyan('║')} ${chalk.bold('NEXT STEPS: CHOOSE YOUR ROUTE')} ${chalk.cyan('║')}`);
59
- console.log(`${chalk.cyan('╠══════════════════════════════════════════════════════════════════════╣')}`);
60
- console.log(`${chalk.cyan('║')} ${chalk.bold('Route A: SaaS Portal (Cloud Context)')} ${chalk.cyan('║')}`);
61
- console.log(`${chalk.cyan('║')} - The AI already has this plan synced in the project database. ${chalk.cyan('║')}`);
62
- console.log(`${chalk.cyan('║')} - Go to your FlowSpecQA dashboard and click "Generate Automation". ${chalk.cyan('║')}`);
63
- console.log(`${chalk.cyan('║')} ${chalk.cyan('║')}`);
64
- console.log(`${chalk.cyan('║')} ${chalk.bold('Route B: CLI (Local Generation)')} ${chalk.cyan('║')}`);
65
- console.log(`${chalk.cyan('║')} - Use the local discovery plan to generate code immediately: ${chalk.cyan('║')}`);
66
- console.log(`${chalk.cyan('║')} ${chalk.green(`flowspecqa generate --from ./specs/discovery_plan.md`)} ${chalk.cyan('║')}`);
67
- console.log(`${chalk.cyan('╚══════════════════════════════════════════════════════════════════════╝')}\n`);
346
+ // Store corpus reference so the interactive loop can extend it
347
+ discoveryCorpus = runResult.corpus;
348
+ // Compute absolute output path for display
349
+ const outputDir = path.resolve(options.output || 'specs');
350
+ console.log(chalk.green('\n✅ Discovery completado — generando artefactos desde evidencia disponible.\n'));
351
+ // ── Clasificación de evidencia (Spec § 5.3) ────────────────────
352
+ if (discoveryCorpus) {
353
+ const cls = classifyCorpus(discoveryCorpus);
354
+ const W = (n, color) => chalk[color](String(n).padStart(3, ' '));
355
+ console.log(chalk.bold(' Evidencia clasificada:'));
356
+ console.log(` ${W(cls.strict_count, 'green')} ${chalk.green('STRICT')} casos respaldados por evidencia suficiente`);
357
+ console.log(` ${W(cls.partial_count, 'yellow')} ${chalk.yellow('PARTIAL')} flujos incompletos que requieren revisión`);
358
+ console.log(` ${W(cls.reco_count, 'cyan')} ${chalk.cyan('RECO')} recomendaciones derivadas del corpus descubierto`);
359
+ console.log(` ${W(cls.gaps_count, 'red')} ${chalk.red('GAPS')} cobertura pendiente por explorar`);
360
+ // Show 1-2 PARTIAL items with recommendation
361
+ if (cls.details.partial.length > 0) {
362
+ console.log(chalk.dim('\n PARTIAL destacados:'));
363
+ cls.details.partial.slice(0, 2).forEach(p => {
364
+ const desc = p.description.length > 100 ? p.description.slice(0, 97) + '...' : p.description;
365
+ console.log(chalk.dim(` ⚠ ${p.evidenceId}: ${desc}`));
366
+ });
367
+ }
368
+ // Show top GAPS by priority (alta first)
369
+ if (cls.details.gaps.length > 0) {
370
+ const sortedGaps = [...cls.details.gaps].sort((a, b) => {
371
+ const order = { alta: 0, media: 1, baja: 2 };
372
+ return order[a.priority] - order[b.priority];
373
+ });
374
+ console.log(chalk.dim('\n GAPS destacados:'));
375
+ sortedGaps.slice(0, 3).forEach(g => {
376
+ const prio = g.priority === 'alta' ? chalk.red('●') : g.priority === 'media' ? chalk.yellow('●') : chalk.gray('●');
377
+ const action = g.action.length > 78 ? g.action.slice(0, 75) + '...' : g.action;
378
+ console.log(chalk.dim(` ${prio} ${action}`));
379
+ });
380
+ }
381
+ // Show top RECO by priority
382
+ if (cls.details.reco.length > 0) {
383
+ const sortedRecos = [...cls.details.reco].sort((a, b) => {
384
+ const order = { alta: 0, media: 1, baja: 2 };
385
+ return order[a.priority] - order[b.priority];
386
+ });
387
+ console.log(chalk.dim('\n RECO destacados:'));
388
+ sortedRecos.slice(0, 3).forEach(r => {
389
+ const prio = r.priority === 'alta' ? chalk.red('●') : r.priority === 'media' ? chalk.yellow('●') : chalk.gray('●');
390
+ const title = r.title.length > 78 ? r.title.slice(0, 75) + '...' : r.title;
391
+ console.log(chalk.dim(` ${prio} [${r.category}] ${title}`));
392
+ });
393
+ }
394
+ console.log('');
395
+ }
396
+ const reportFile = runResult.reportPath
397
+ ? path.resolve(runResult.reportPath)
398
+ : path.join(outputDir, 'discovery_report.html');
399
+ const stripAnsi = (str) => {
400
+ // eslint-disable-next-line no-control-regex
401
+ return str.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{1,4})*)?[0-9A-ORZcf-nqry=><]/g, '');
402
+ };
403
+ // Renders a single box line, padding to fill the border width
404
+ const formatBoxLine = (content, totalWidth = 84) => {
405
+ const contentWidth = totalWidth - 6; // ║ (1) + 2 spaces + 2 spaces + ║ (1)
406
+ const visible = stripAnsi(content);
407
+ const padding = Math.max(0, contentWidth - visible.length);
408
+ return `${chalk.cyan('║')} ${content}${' '.repeat(padding)} ${chalk.cyan('║')}`;
409
+ };
410
+ // Renders a plain string that may be longer than contentWidth, wrapping across multiple lines
411
+ const formatBoxPath = (filePath, totalWidth = 84) => {
412
+ const contentWidth = totalWidth - 6;
413
+ const lines = [];
414
+ let remaining = filePath;
415
+ while (remaining.length > 0) {
416
+ lines.push(remaining.slice(0, contentWidth));
417
+ remaining = remaining.slice(contentWidth);
418
+ }
419
+ return lines.map(l => {
420
+ const padding = Math.max(0, contentWidth - l.length);
421
+ return `${chalk.cyan('║')} ${chalk.green(l)}${' '.repeat(padding)} ${chalk.cyan('║')}`;
422
+ }).join('\n');
423
+ };
424
+ console.log(`${chalk.cyan('╔══════════════════════════════════════════════════════════════════════════════════╗')}`);
425
+ console.log(formatBoxLine(chalk.bold('PRÓXIMOS PASOS')));
426
+ console.log(`${chalk.cyan('╠══════════════════════════════════════════════════════════════════════════════════╣')}`);
427
+ console.log(formatBoxLine(chalk.bold('📋 Reporte de evidencias (HTML):')));
428
+ console.log(formatBoxPath(reportFile));
429
+ console.log(formatBoxLine(''));
430
+ console.log(formatBoxLine(chalk.bold('Portal SaaS:')));
431
+ console.log(formatBoxLine('El plan ya está sincronizado. Ve a FlowSpecQA y genera tests.'));
432
+ console.log(`${chalk.cyan('╚══════════════════════════════════════════════════════════════════════════════════╝')}\n`);
68
433
  }
69
434
  catch (err) {
70
- spinner.fail(chalk.red(`Discovery failed: ${err.message}`));
435
+ console.error(chalk.red(`\n❌ Discovery fallido: ${err.message}`));
436
+ process.exit(1);
71
437
  }
72
438
  });
73
439
  }