@ihyeon/flow-qa 0.10.14 → 0.12.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.
package/README.ko.md CHANGED
@@ -72,6 +72,8 @@ flow-qa plan flows/my-flow.md --workspace my-qa
72
72
 
73
73
  CLI에서는 `flow-qa run cases/task-flow.json --target demo --case TC-001 --case TC-003`처럼 ID를 반복합니다. `--case`를 생략하면 전체를 실행합니다. 부분 실행의 통과는 선택한 케이스에만 해당하며, 보고서와 비교 화면에도 선택 범위를 표시합니다. 자세한 동작은 [UI 가이드](docs/ui.md#run-selected-cases)를 참고하세요.
74
74
 
75
+ 재실행 목록은 보고서에 저장된 종료 시각과 시작 시각 순으로 표시합니다. `flow-qa rerun <실행 폴더> --dry-run`으로 등록된 대상과 실패 케이스 ID를 미리 볼 수 있습니다. 미리보기에서는 대상 요청과 새 보고서 생성이 발생하지 않습니다.
76
+
75
77
  `0.5.0`부터 상세 보고서에서 **실패·오류 케이스 준비**를 누르면 실행 당시와 같은 저장된 케이스를 불러와 `실패`와 `실행 오류`만 선택합니다. 준비 후 케이스와 대상을 다시 검토하고 직접 실행하세요. 케이스·원본 파일이 없거나 바뀌었으면 준비를 중단하며, 실행 대상이 없거나 바뀌었으면 다시 선택해야 합니다. 자세한 동작은 [실패 케이스 준비](docs/ui.md#prepare-failed-cases)를 참고하세요.
76
78
 
77
79
  준비한 케이스 정의·대상·선택 케이스 그대로 실행하면 새 보고서에 원본 실행 ID가 남습니다. 상세 보고서에서 원본을 열거나 두 결과를 바로 비교할 수 있습니다. 이 조건을 변경해 실행하면 독립 실행으로 저장합니다. 원본 보고서가 삭제돼도 새 보고서는 읽을 수 있으며 원본이 없다는 상태를 표시합니다.
@@ -80,6 +82,8 @@ CLI에서는 `flow-qa run cases/task-flow.json --target demo --case TC-001 --cas
80
82
 
81
83
  CLI에서는 `flow-qa reruns .flowqa/runs/<원본-실행-ID> --workspace my-qa --lang ko`로 원본에서 직접 시작한 재실행의 상태와 저장 폴더를 찾습니다. 목록에 나온 폴더는 같은 `--workspace`의 `flow-qa report`에 넘기거나 원본 폴더와 함께 `flow-qa compare`에 넘길 수 있습니다. 불완전한 기록은 목록에서 제외합니다.
82
84
 
85
+ `flow-qa rerun .flowqa/runs/<원본-실행-ID> --workspace my-qa --lang ko`를 실행하면 원본에서 실패·실행 오류가 난 케이스만 원래 등록한 대상에 다시 실행합니다. 새 보고서에 원본 실행 ID가 남으므로 `reruns`와 `compare`에서 결과 변화를 볼 수 있습니다. 실패·오류 케이스가 없으면 새 실행을 만들지 않고 안내와 함께 정상 종료합니다. 저장된 케이스·원본 플로우·대상이 바뀌었다면 실행 전에 중단합니다. 각 케이스에는 독립적인 시작 상태가 필요합니다.
86
+
83
87
  `0.8.0`부터 **상세 보고서**에서 케이스·오류 내용을 검색하고 상태별로 좁히거나 **실패·오류만** 볼 수 있습니다. **시도 2회 이상만 보기**(0.8.7)를 켜면 여러 번 시도한 케이스만 표시합니다. 표시 건수와 보고서 전체 케이스 수를 구분하며, Markdown·JSON 다운로드와 실패·오류 재실행 준비는 보고서 전체 범위를 유지합니다. 필터에 맞는 ID만 화면 순서대로 저장하려면 **표시된 케이스 ID 다운로드**(0.8.6)를 선택하세요. 자세한 동작은 [보고서 케이스 탐색](docs/ui.md#explore-cases-in-a-report)을 참고하세요.
84
88
 
85
89
  ## 실행 결과 비교
package/README.md CHANGED
@@ -80,6 +80,10 @@ From an original report, **Find reruns of this run** shows directly linked runs
80
80
 
81
81
  In the CLI, `flow-qa reruns .flowqa/runs/<original-run-id> --workspace my-qa` lists direct reruns with their status and saved directory. Pass a listed directory to `flow-qa report` or compare it with the original using `flow-qa compare` and the same `--workspace`. The command checks the saved reports and skips incomplete entries.
82
82
 
83
+ Direct reruns are ordered by their saved finish and start times. Add `--dry-run` to `flow-qa rerun <run-directory>` to print the registered target and failing case IDs before execution. Previewing makes no target requests and creates no new report.
84
+
85
+ Run `flow-qa rerun .flowqa/runs/<original-run-id> --workspace my-qa` to execute only its failed and errored cases against the original registered target. The new report records the original run ID, so `reruns` and `compare` can show what changed. A report with no failed or errored cases prints a message and exits successfully without creating another run. If the saved cases, source flow, or target changed, the command stops before starting a run. Each case must establish its own starting state.
86
+
83
87
  From `0.8.0`, **Detailed report** supports case/error-text search, status filters, and **Failed/error only**. Use **At least 2 attempts** (0.8.7) to see only cases with multiple recorded attempts. Counts distinguish displayed matches from all recorded cases. Markdown/JSON downloads and failed/error preparation retain the full report scope. To save just the filtered IDs in the displayed order, choose **Download visible case IDs** (0.8.6). See [report case exploration](docs/ui.md#explore-cases-in-a-report).
84
88
 
85
89
  ## Compare recorded runs
package/dist/src/cli.js CHANGED
@@ -5,13 +5,14 @@ import { resolve, dirname, basename, join } from 'node:path';
5
5
  import { fileURLToPath } from 'node:url';
6
6
  import { parseArgs } from 'node:util';
7
7
  import { localeFromEnv, localized, localizeProductMessage } from "./i18n.js";
8
- import { configSchema, idSchema, modelSchema, targetSchema } from "./schema.js";
8
+ import { configSchema, idSchema, modelSchema, suiteSchema, targetSchema } from "./schema.js";
9
9
  import { initWorkspace, readConfig, readSuite, sha256, verifySuiteSource, withConfigLock, writeConfig, writeJSON } from "./workspace.js";
10
10
  import { buildPlanningPrompt, planFlow } from "./planner.js";
11
11
  import { compileSuite } from "./compiler.js";
12
12
  import { CaseSelectionError, isReportSelectionValid, selectCases } from "./case-selection.js";
13
13
  import { runSuite } from "./engine.js";
14
14
  import { MAX_SAVED_REPORT_BYTES, RUN_ID, parseArchivedReportEnvelope, renderSavedMarkdown } from "./report.js";
15
+ import { prepareRerunSelection } from "./rerun.js";
15
16
  import { registrationTarget, sameReportTarget, targetLabel } from "./targets.js";
16
17
  import { compareCaseSteps } from "./step-comparison.js";
17
18
  import { createAgentHandoff, reviewAgentHandoff } from "./agent-handoff.js";
@@ -38,6 +39,7 @@ Usage: flow-qa <command> [arguments] [options]
38
39
  agent-review <handoff-dir> <result.json>
39
40
  Check agent-supplied findings and evidence references
40
41
  report <run-directory> View a saved QA report
42
+ rerun <run-directory> [--dry-run] Rerun failed/error cases from a saved report
41
43
  reruns <run-directory> List runs prepared from a saved report
42
44
  compare <run-a> <run-b> Compare case results and authored steps
43
45
  ui [--demo] [--port 4310] Start the local QA UI
@@ -70,6 +72,7 @@ Local example: flow-qa ui --demo
70
72
  agent-review <handoff-dir> <result.json>
71
73
  에이전트 관찰 결과와 증거 파일 참조 검사
72
74
  report <run-directory> 저장된 QA 리포트 보기
75
+ rerun <run-directory> [--dry-run] 저장된 실행의 실패·오류 케이스 재실행
73
76
  reruns <run-directory> 저장된 리포트에서 시작한 재실행 찾기
74
77
  compare <run-a> <run-b> 케이스 결과와 원본 단계 비교
75
78
  ui [--demo] [--port 4310] 로컬 QA 화면 실행
@@ -137,6 +140,82 @@ async function chromiumInstalled() {
137
140
  return false;
138
141
  }
139
142
  }
143
+ const SAFE_CASE_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]{0,159}$/;
144
+ async function safeWorkspaceDirectory(workspace, parts, message = 'Invalid workspace path.') {
145
+ let directory = workspace;
146
+ for (const part of parts) {
147
+ directory = join(directory, part);
148
+ const info = await lstat(directory);
149
+ if (!info.isDirectory() || info.isSymbolicLink() || await realpath(directory) !== directory) {
150
+ throw new Error(message);
151
+ }
152
+ }
153
+ return directory;
154
+ }
155
+ async function readSafeFile(directory, name, limit) {
156
+ const path = join(directory, name);
157
+ const info = await lstat(path);
158
+ if (!info.isFile() || info.isSymbolicLink() || info.size > limit || await realpath(path) !== path) {
159
+ throw new Error('Invalid saved file path or size.');
160
+ }
161
+ const handle = await open(path, constants.O_RDONLY | constants.O_NOFOLLOW);
162
+ try {
163
+ const opened = await handle.stat();
164
+ if (!opened.isFile() || opened.size > limit)
165
+ throw new Error('Invalid saved file path or size.');
166
+ return await handle.readFile('utf8');
167
+ }
168
+ finally {
169
+ await handle.close();
170
+ }
171
+ }
172
+ function savedFlowName(suite, roots) {
173
+ if (!suite.source)
174
+ return undefined;
175
+ const file = suite.source.file;
176
+ const relative = /^(?:\.\/)?flows\/([^/\\]+)$/.exec(file);
177
+ const name = relative?.[1] ?? (roots.includes(dirname(file)) ? basename(file) : undefined);
178
+ if (!name || !SAFE_CASE_NAME.test(name) || name.includes('..') || !name.endsWith('.md')) {
179
+ throw new Error('Invalid source flow path.');
180
+ }
181
+ return name;
182
+ }
183
+ async function savedRunPath(workspace, input, locale) {
184
+ const canonicalWorkspace = await realpath(workspace);
185
+ const root = await safeWorkspaceDirectory(canonicalWorkspace, ['.flowqa', 'runs'], localized(locale, 'Invalid workspace run path.', '작업 공간의 실행 경로가 유효하지 않습니다.'));
186
+ const selectedDir = resolve(workspace, required(input, localized(locale, 'Run directory', '실행 폴더'), locale));
187
+ const id = basename(selectedDir);
188
+ const info = await lstat(selectedDir);
189
+ if (!RUN_ID.test(id) || !info.isDirectory() || info.isSymbolicLink() || await realpath(selectedDir) !== join(root, id)) {
190
+ throw new Error(localized(locale, 'Choose a saved run in this workspace.', '이 작업 공간에 저장된 실행을 선택하세요.'));
191
+ }
192
+ return { canonicalWorkspace, root, id };
193
+ }
194
+ async function readArchivedRun(root, id) {
195
+ const directory = join(root, id);
196
+ const info = await lstat(directory);
197
+ if (!info.isDirectory() || info.isSymbolicLink() || await realpath(directory) !== directory)
198
+ return undefined;
199
+ const report = parseArchivedReportEnvelope(JSON.parse(await readSafeFile(directory, 'qa-report.json', MAX_SAVED_REPORT_BYTES)));
200
+ return report?.runId === id ? report : undefined;
201
+ }
202
+ async function executeRun(options, locale, rerun = false) {
203
+ const controller = new AbortController();
204
+ const interrupt = () => controller.abort();
205
+ process.once('SIGINT', interrupt);
206
+ process.once('SIGTERM', interrupt);
207
+ try {
208
+ const { report, runDir } = await runSuite({ ...options, signal: controller.signal });
209
+ if (report.selection)
210
+ console.log(localized(locale, `${rerun ? 'Selected rerun' : 'Selected run'}: ${report.selection.caseIds.length}/${report.selection.totalCases} cases; the full suite was not evaluated.`, `${rerun ? '선택 재실행' : '선택 실행'}: ${report.selection.totalCases}개 중 ${report.selection.caseIds.length}개. 전체 케이스를 검증한 결과가 아닙니다.`));
211
+ console.log(localized(locale, `Run result: ${report.status}\nQA report: ${resolve(runDir, 'qa-report.md')}\nRaw result: ${resolve(runDir, 'qa-report.json')}`, `실행 결과: ${report.status}\nQA 리포트: ${resolve(runDir, 'qa-report.md')}\n원본 결과: ${resolve(runDir, 'qa-report.json')}`));
212
+ process.exitCode = report.status === 'passed' ? 0 : report.status === 'interrupted' ? 130 : 1;
213
+ }
214
+ finally {
215
+ process.off('SIGINT', interrupt);
216
+ process.off('SIGTERM', interrupt);
217
+ }
218
+ }
140
219
  export async function main(args) {
141
220
  let locale = localeFromEnv();
142
221
  try {
@@ -146,7 +225,7 @@ export async function main(args) {
146
225
  case: { type: 'string', multiple: true },
147
226
  platform: { type: 'string' }, 'bundle-id': { type: 'string' }, device: { type: 'string' },
148
227
  'prompt-only': { type: 'boolean' }, help: { type: 'boolean', short: 'h' },
149
- demo: { type: 'boolean' }, port: { type: 'string' }, 'with-deps': { type: 'boolean' }, lang: { type: 'string' },
228
+ 'dry-run': { type: 'boolean' }, demo: { type: 'boolean' }, port: { type: 'string' }, 'with-deps': { type: 'boolean' }, lang: { type: 'string' },
150
229
  } });
151
230
  if (values.lang !== undefined) {
152
231
  if (values.lang !== 'en' && values.lang !== 'ko')
@@ -163,7 +242,7 @@ export async function main(args) {
163
242
  (values['bundle-id'] !== undefined || values.device !== undefined) && command !== 'connect') {
164
243
  throw new Error(localized(locale, 'Platform and device options are only supported by connect and plan. See --help.', '플랫폼·기기 옵션은 connect와 plan에서만 사용할 수 있습니다. --help를 참고하세요.'));
165
244
  }
166
- if (values.case !== undefined && command !== 'run' && command !== 'agent-handoff' || values.demo && command !== 'ui' || values.port && command !== 'ui' ||
245
+ if (values['dry-run'] && command !== 'rerun' || values.case !== undefined && command !== 'run' && command !== 'agent-handoff' || values.demo && command !== 'ui' || values.port && command !== 'ui' ||
167
246
  values['with-deps'] && (command !== 'browser' || arg !== 'install'))
168
247
  throw new Error(localized(locale, 'This option is not supported for the command. See --help.', '이 명령에서 사용할 수 없는 옵션입니다. --help를 참고하세요.'));
169
248
  if (command === 'ui') {
@@ -319,22 +398,8 @@ export async function main(args) {
319
398
  throw new Error(localizeProductMessage('Select one or more unique cases from this suite.', locale));
320
399
  throw error;
321
400
  }
322
- const controller = new AbortController();
323
- const interrupt = () => controller.abort();
324
- process.once('SIGINT', interrupt);
325
- process.once('SIGTERM', interrupt);
326
- try {
327
- const { report, runDir } = await runSuite({ workspace, suite, config, targetName: required(targetName, '--target', locale), signal: controller.signal,
328
- ...(caseIds ? { caseIds } : {}) });
329
- if (report.selection)
330
- console.log(localized(locale, `Selected run: ${report.selection.caseIds.length}/${report.selection.totalCases} cases; the full suite was not evaluated.`, `선택 실행: ${report.selection.totalCases}개 중 ${report.selection.caseIds.length}개. 전체 케이스를 검증한 결과가 아닙니다.`));
331
- console.log(localized(locale, `Run result: ${report.status}\nQA report: ${resolve(runDir, 'qa-report.md')}\nRaw result: ${resolve(runDir, 'qa-report.json')}`, `실행 결과: ${report.status}\nQA 리포트: ${resolve(runDir, 'qa-report.md')}\n원본 결과: ${resolve(runDir, 'qa-report.json')}`));
332
- process.exitCode = report.status === 'passed' ? 0 : report.status === 'interrupted' ? 130 : 1;
333
- }
334
- finally {
335
- process.off('SIGINT', interrupt);
336
- process.off('SIGTERM', interrupt);
337
- }
401
+ await executeRun({ workspace, suite, config, targetName: required(targetName, '--target', locale),
402
+ ...(caseIds ? { caseIds } : {}) }, locale);
338
403
  return;
339
404
  }
340
405
  if (command === 'report') {
@@ -347,52 +412,73 @@ export async function main(args) {
347
412
  console.log(content.replace(/\u001b/g, ''));
348
413
  return;
349
414
  }
350
- if (command === 'reruns') {
351
- if (second)
352
- throw new Error(localized(locale, 'reruns accepts one run directory.', 'reruns에는 실행 폴더 하나만 지정하세요.'));
353
- const canonicalWorkspace = await realpath(workspace);
354
- let root = canonicalWorkspace;
355
- for (const part of ['.flowqa', 'runs']) {
356
- root = join(root, part);
357
- const info = await lstat(root);
358
- if (!info.isDirectory() || info.isSymbolicLink() || await realpath(root) !== root) {
359
- throw new Error(localized(locale, 'Invalid workspace run path.', '작업 공간의 실행 경로가 유효하지 않습니다.'));
360
- }
415
+ if (command === 'rerun') {
416
+ if (positionals.length !== 2 || values.target !== undefined || values.out !== undefined ||
417
+ values.url !== undefined || values.model !== undefined || values['key-env'] !== undefined || values['prompt-only']) {
418
+ throw new Error(localized(locale, 'rerun accepts one run directory and the saved target.', 'rerun에는 실행 폴더 하나와 저장된 대상만 사용할 수 있습니다.'));
419
+ }
420
+ const { canonicalWorkspace, root: runsRoot, id: originalId } = await savedRunPath(workspace, arg, locale);
421
+ let previous;
422
+ try {
423
+ previous = await readArchivedRun(runsRoot, originalId);
361
424
  }
362
- const selectedDir = resolve(workspace, required(arg, localized(locale, 'Run directory', '실행 폴더'), locale));
363
- const originalId = basename(selectedDir);
364
- const selectedInfo = await lstat(selectedDir);
365
- if (!RUN_ID.test(originalId) || selectedInfo.isSymbolicLink() ||
366
- await realpath(selectedDir) !== join(root, originalId)) {
367
- throw new Error(localized(locale, 'Choose a saved run in this workspace.', '이 작업 공간에 저장된 실행을 선택하세요.'));
425
+ catch { /* Invalid or unsafe saved run. */ }
426
+ if (!previous || previous.runId !== originalId) {
427
+ throw new Error(localized(locale, 'This is not a valid saved run.', '유효한 저장 실행이 아닙니다.'));
368
428
  }
369
- const readReport = async (id) => {
370
- const dir = join(root, id);
371
- const dirInfo = await lstat(dir);
372
- if (!dirInfo.isDirectory() || dirInfo.isSymbolicLink() || await realpath(dir) !== dir)
373
- return undefined;
374
- const file = join(dir, 'qa-report.json');
375
- const fileInfo = await lstat(file);
376
- if (!fileInfo.isFile() || fileInfo.isSymbolicLink() || fileInfo.size > MAX_SAVED_REPORT_BYTES ||
377
- await realpath(file) !== file)
378
- return undefined;
379
- const handle = await open(file, constants.O_RDONLY | constants.O_NOFOLLOW);
380
- let contents;
429
+ const casesRoot = await safeWorkspaceDirectory(canonicalWorkspace, ['cases']);
430
+ const matches = [];
431
+ const flowRoots = [join(canonicalWorkspace, 'flows'), join(workspace, 'flows')];
432
+ for (const file of await readdir(casesRoot)) {
433
+ if (!SAFE_CASE_NAME.test(file) || file.includes('..') || !file.endsWith('.json'))
434
+ continue;
381
435
  try {
382
- const opened = await handle.stat();
383
- if (!opened.isFile() || opened.size > MAX_SAVED_REPORT_BYTES)
384
- return undefined;
385
- contents = await handle.readFile('utf8');
436
+ const suite = suiteSchema.parse(JSON.parse(await readSafeFile(casesRoot, file, 1024 * 1024)));
437
+ savedFlowName(suite, flowRoots);
438
+ if (suite.id === previous.suiteId)
439
+ matches.push({ file, suite });
386
440
  }
387
- finally {
388
- await handle.close();
441
+ catch { /* Invalid or unsafe case files are absent from the saved library. */ }
442
+ }
443
+ if (matches.length !== 1) {
444
+ throw new Error(localized(locale, matches.length ? 'Multiple saved case files match this report.' : 'No saved case file matches this report.', matches.length ? '이 보고서와 일치하는 케이스 파일이 여러 개입니다.' : '이 보고서와 일치하는 케이스 파일이 없습니다.'));
445
+ }
446
+ const suite = matches[0].suite;
447
+ const flowName = savedFlowName(suite, flowRoots);
448
+ if (flowName) {
449
+ const flowRoot = await safeWorkspaceDirectory(canonicalWorkspace, ['flows']);
450
+ const flow = await readSafeFile(flowRoot, flowName, 128 * 1024);
451
+ if (sha256(flow) !== suite.source.sha256) {
452
+ throw new Error(localized(locale, 'The source flow changed. Save the cases again.', '원본 플로우가 변경됐습니다. 케이스를 다시 저장하세요.'));
389
453
  }
390
- const report = parseArchivedReportEnvelope(JSON.parse(contents));
391
- return report?.runId === id ? report : undefined;
392
- };
454
+ }
455
+ const config = configSchema.parse(JSON.parse(await readSafeFile(canonicalWorkspace, 'flowqa.config.json', 256 * 1024)));
456
+ const prepared = prepareRerunSelection(previous, suite, config);
457
+ if (!prepared.targetMatches && (prepared.caseIds.length || values['dry-run'])) {
458
+ throw new Error(localized(locale, 'The selected target changed. Review it again.', '실행 대상 설정이 변경됐습니다. 다시 확인하세요.'));
459
+ }
460
+ if (values['dry-run']) {
461
+ console.log(localized(locale, `Target: ${prepared.targetName}`, `실행 대상: ${prepared.targetName}`));
462
+ }
463
+ if (prepared.caseIds.length === 0) {
464
+ console.log(localizeProductMessage('No failed or errored cases are available to rerun.', locale));
465
+ return;
466
+ }
467
+ if (values['dry-run']) {
468
+ console.log(localized(locale, `Cases: ${prepared.caseIds.join(', ')}`, `케이스: ${prepared.caseIds.join(', ')}`));
469
+ return;
470
+ }
471
+ await executeRun({ workspace: canonicalWorkspace, suite, config, targetName: prepared.targetName,
472
+ caseIds: prepared.caseIds, parentRunId: originalId }, locale, true);
473
+ return;
474
+ }
475
+ if (command === 'reruns') {
476
+ if (second)
477
+ throw new Error(localized(locale, 'reruns accepts one run directory.', 'reruns에는 실행 폴더 하나만 지정하세요.'));
478
+ const { root, id: originalId } = await savedRunPath(workspace, arg, locale);
393
479
  let original;
394
480
  try {
395
- original = await readReport(originalId);
481
+ original = await readArchivedRun(root, originalId);
396
482
  }
397
483
  catch { /* Invalid saved run. */ }
398
484
  if (!original)
@@ -402,14 +488,17 @@ export async function main(args) {
402
488
  if (!RUN_ID.test(id) || id === originalId)
403
489
  continue;
404
490
  try {
405
- const report = await readReport(id);
491
+ const report = await readArchivedRun(root, id);
406
492
  if (report?.parentRunId !== originalId)
407
493
  continue;
408
- matches.push({ id, status: report.status, mtime: (await lstat(join(root, id))).mtimeMs });
494
+ const startTime = Date.parse(report.startedAt);
495
+ const finishTime = Date.parse(report.finishedAt);
496
+ const started = Number.isFinite(startTime) ? startTime : -Infinity;
497
+ matches.push({ id, status: report.status, started, finished: Number.isFinite(finishTime) ? finishTime : started });
409
498
  }
410
499
  catch { /* Incomplete or unsafe saved run. */ }
411
500
  }
412
- matches.sort((a, b) => b.mtime - a.mtime || a.id.localeCompare(b.id));
501
+ matches.sort((a, b) => b.finished - a.finished || b.started - a.started || a.id.localeCompare(b.id));
413
502
  if (!matches.length) {
414
503
  console.log(localized(locale, 'No runs were prepared from this report.', '이 리포트에서 시작한 재실행이 없습니다.'));
415
504
  return;
@@ -16,7 +16,7 @@ const archiveEnvelopeSchema = z.object({
16
16
  z.object({ name: z.string(), url: z.string() }),
17
17
  z.object({ name: z.string(), kind: z.literal('mobile'), platform: z.enum(['ios', 'android']), bundleId: z.string(), device: z.string() }),
18
18
  ]),
19
- startedAt: z.string(), finishedAt: z.string(), status: z.enum(['passed', 'failed', 'blocked', 'error', 'interrupted']),
19
+ startedAt: z.string().default(''), finishedAt: z.string().default(''), status: z.enum(['passed', 'failed', 'blocked', 'error', 'interrupted']),
20
20
  cases: z.array(z.object({ id: z.string(), title: z.string(), status: z.enum(['passed', 'failed', 'flaky', 'blocked', 'skipped', 'error']),
21
21
  expected: z.array(z.string()), definedSteps: z.array(z.object({ type: z.string() })).optional(),
22
22
  attempts: z.array(z.unknown()), reason: z.string().optional() }).passthrough()),
@@ -39,6 +39,7 @@ const savedAttemptSchema = z.object({
39
39
  });
40
40
  const savedReportSchema = z.object({
41
41
  ...archiveEnvelopeSchema.shape,
42
+ startedAt: z.string(), finishedAt: z.string(),
42
43
  suiteHash: z.string().regex(/^[a-f0-9]{64}$/),
43
44
  cases: z.array(z.object({
44
45
  id: idSchema, title: z.string(), status: z.enum(['passed', 'failed', 'flaky', 'blocked', 'skipped', 'error']),
@@ -0,0 +1,28 @@
1
+ import { isReportSelectionValid } from "./case-selection.js";
2
+ import { targetFingerprint } from "./targets.js";
3
+ import { sha256 } from "./workspace.js";
4
+ /** Keep CLI and UI reruns tied to the same saved suite, cases, and target. */
5
+ export function prepareRerunSelection(previous, suite, settings) {
6
+ if (sha256(`${JSON.stringify(suite, null, 2)}\n`) !== previous.suiteHash) {
7
+ throw new Error('The saved case file changed since this run. Review it before rerunning.');
8
+ }
9
+ const available = new Set(suite.cases.map((item) => item.id));
10
+ if (previous.cases.some((item) => !item.id.trim() || !available.has(item.id)) ||
11
+ new Set(previous.cases.map((item) => item.id)).size !== previous.cases.length ||
12
+ (!previous.selection && previous.cases.length !== suite.cases.length)) {
13
+ throw new Error('The report cases do not match the saved case file.');
14
+ }
15
+ if (previous.selection && (previous.selection.totalCases !== suite.cases.length ||
16
+ !isReportSelectionValid(previous.cases, previous.selection))) {
17
+ throw new Error('The report selection does not match the saved case file.');
18
+ }
19
+ const failing = new Set(previous.cases.filter((item) => item.status === 'failed' || item.status === 'error').map((item) => item.id));
20
+ const caseIds = suite.cases.filter((item) => failing.has(item.id)).map((item) => item.id);
21
+ const targetName = previous.target.name;
22
+ const expectedFingerprint = targetFingerprint(previous.target);
23
+ const currentTarget = Object.hasOwn(settings.targets, targetName) ? settings.targets[targetName] : undefined;
24
+ return { caseIds, targetName, targetFingerprint: expectedFingerprint,
25
+ targetMatches: Boolean(currentTarget &&
26
+ (suite.platform ?? 'web') === (currentTarget.kind === 'mobile' ? 'mobile' : 'web') &&
27
+ targetFingerprint(currentTarget) === expectedFingerprint) };
28
+ }
@@ -15,12 +15,13 @@ import { fileURLToPath, pathToFileURL } from 'node:url';
15
15
  import { z } from 'zod';
16
16
  import { chromium } from 'playwright';
17
17
  import { compileSuite } from "../compiler.js";
18
- import { CaseSelectionError, isReportSelectionValid, selectCases } from "../case-selection.js";
18
+ import { CaseSelectionError, selectCases } from "../case-selection.js";
19
19
  import { runSuite } from "../engine.js";
20
20
  import { localeFromAcceptLanguage, localizeProductMessage } from "../i18n.js";
21
21
  import { EvidenceError, readEvidence } from "./evidence.js";
22
22
  import { buildPlanningPrompt, planFlow, PlannerError } from "../planner.js";
23
23
  import { MAX_SAVED_REPORT_BYTES, RUN_ID, parseArchivedReportEnvelope, renderSavedMarkdown } from "../report.js";
24
+ import { prepareRerunSelection } from "../rerun.js";
24
25
  import { compareReports, ComparisonError, renderComparisonMarkdown } from "../run-comparison.js";
25
26
  import { configSchema, idSchema, modelSchema, suiteSchema, targetSchema } from "../schema.js";
26
27
  import { registrationTarget, targetFingerprint } from "../targets.js";
@@ -444,33 +445,17 @@ export async function startUIServer(options) {
444
445
  }
445
446
  throw error;
446
447
  }
447
- const { suite } = selected;
448
- if (sha256(`${JSON.stringify(suite, null, 2)}\n`) !== previous.suiteHash) {
449
- throw new HTTPError(409, 'The saved case file changed since this run. Review it before rerunning.');
450
- }
451
- const available = new Set(suite.cases.map((item) => item.id));
452
- if (previous.cases.some((item) => !item.id.trim() || !available.has(item.id)) ||
453
- new Set(previous.cases.map((item) => item.id)).size !== previous.cases.length ||
454
- (!previous.selection && previous.cases.length !== suite.cases.length)) {
455
- throw new HTTPError(409, 'The report cases do not match the saved case file.');
448
+ const settings = await config();
449
+ try {
450
+ const prepared = prepareRerunSelection(previous, selected.suite, settings);
451
+ if (prepared.caseIds.length === 0)
452
+ throw new Error('No failed or errored cases are available to rerun.');
453
+ return { originRunId: runId, file, ...selected,
454
+ ...prepared };
456
455
  }
457
- if (previous.selection && (previous.selection.totalCases !== suite.cases.length ||
458
- !isReportSelectionValid(previous.cases, previous.selection))) {
459
- throw new HTTPError(409, 'The report selection does not match the saved case file.');
456
+ catch (error) {
457
+ throw new HTTPError(409, error.message);
460
458
  }
461
- const failing = new Set(previous.cases.filter((item) => item.status === 'failed' || item.status === 'error').map((item) => item.id));
462
- const caseIds = suite.cases.filter((item) => failing.has(item.id)).map((item) => item.id);
463
- if (caseIds.length === 0)
464
- throw new HTTPError(409, 'No failed or errored cases are available to rerun.');
465
- const settings = await config();
466
- const targetName = previous.target.name;
467
- const expectedFingerprint = targetFingerprint(previous.target);
468
- const currentTarget = Object.hasOwn(settings.targets, targetName) ? settings.targets[targetName] : undefined;
469
- return { originRunId: runId, file, ...selected, caseIds, targetName,
470
- targetFingerprint: expectedFingerprint,
471
- targetMatches: Boolean(currentTarget &&
472
- (suite.platform ?? 'web') === (currentTarget.kind === 'mobile' ? 'mobile' : 'web') &&
473
- targetFingerprint(currentTarget) === expectedFingerprint) };
474
459
  }
475
460
  async function runCandidates() {
476
461
  const root = await directory(['.flowqa', 'runs']);
package/docs/releases.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Releases and verification
2
2
 
3
+ ## 0.12.0 — preview failed cases and order reruns by execution time
4
+
5
+ `flow-qa rerun <saved-run> --dry-run` verifies the saved suite and target, then prints the target name and the failed or errored case IDs. The preview makes no target requests and writes no reports. `reruns` orders children by recorded finish time, start time and run ID. Undated legacy reports remain in the list.
6
+
7
+ ## 0.11.0 — rerun failed cases from the CLI
8
+
9
+ `flow-qa rerun <saved-run> --workspace <workspace>` runs the failed or errored cases from an original report against its unchanged registered target. It shares the local UI's checks for the saved suite, selected cases, and target identity. The new report retains `parentRunId`, and `reruns` lists it. A report without failed or errored cases exits successfully with an informational message and creates no run. Changed definitions, source flows, targets, and unsafe saved paths stop before execution.
10
+
3
11
  ## 0.10.8 — Concurrent configuration updates
4
12
 
5
13
  CLI `connect` and `model` commands and the local UI's target and model settings now lock the same canonical configuration file before reading and saving it. Concurrent commands that update different targets or model roles retain every successful change. The lock is stored in the private `.flowqa` directory beside the actual configuration file, including when a CLI workspace uses a symlink to that file. A terminated writer releases its SQLite lock automatically, so another command can retry. Each save still replaces the complete JSON file after it is written.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ihyeon/flow-qa",
3
- "version": "0.10.14",
3
+ "version": "0.12.0",
4
4
  "license": "MIT",
5
5
  "author": "Hyeonse Im",
6
6
  "repository": {