@ihyeon/flow-qa 0.9.6 → 0.9.7

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/dist/src/cli.js CHANGED
@@ -11,8 +11,8 @@ 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
- import { renderMarkdown } from "./report.js";
15
- import { targetFingerprint, targetLabel } from "./targets.js";
14
+ import { renderSavedMarkdown } from "./report.js";
15
+ import { registrationTarget, sameReportTarget, targetLabel } from "./targets.js";
16
16
  import { createAgentHandoff, reviewAgentHandoff } from "./agent-handoff.js";
17
17
  const help = {
18
18
  en: `Flow QA — turn user flows into repeatable tests and evidence-backed QA reports
@@ -195,9 +195,10 @@ export async function main(args) {
195
195
  if (platform === 'web' && (values['bundle-id'] !== undefined || values.device !== undefined) || platform !== 'web' && values.url !== undefined) {
196
196
  throw new Error(localized(locale, 'Use --url for web, or --bundle-id and --device for a mobile app.', '웹은 --url, 모바일 앱은 --bundle-id와 --device를 사용하세요.'));
197
197
  }
198
- config.targets[name] = targetSchema.parse(platform === 'web'
198
+ const target = targetSchema.parse(platform === 'web'
199
199
  ? { url: required(values.url, '--url', locale) }
200
200
  : { kind: 'mobile', platform, bundleId: required(values['bundle-id'], '--bundle-id', locale), device: required(values.device, '--device', locale) });
201
+ config.targets[name] = registrationTarget(target, config.targets[name]);
201
202
  await writeConfig(workspace, config);
202
203
  console.log(localized(locale, `Target ${name} saved: ${targetLabel(config.targets[name])}. No app has been launched.`, `대상 ${name} 저장: ${targetLabel(config.targets[name])}. 앱은 실행하지 않았습니다.`));
203
204
  return;
@@ -317,12 +318,10 @@ export async function main(args) {
317
318
  if (command === 'report') {
318
319
  const runDirectory = resolve(workspace, required(arg, localized(locale, 'Run directory', '실행 폴더'), locale));
319
320
  let content = await readFile(resolve(runDirectory, 'qa-report.md'), 'utf8');
320
- if (locale === 'ko') {
321
- try {
322
- content = renderMarkdown(JSON.parse(await readFile(resolve(runDirectory, 'qa-report.json'), 'utf8')), locale);
323
- }
324
- catch { /* Preserve the saved report if an older or malformed JSON report cannot be rendered. */ }
321
+ try {
322
+ content = renderSavedMarkdown(JSON.parse(await readFile(resolve(runDirectory, 'qa-report.json'), 'utf8')), content, locale);
325
323
  }
324
+ catch { /* Preserve the saved Markdown when normalized JSON is absent or malformed. */ }
326
325
  console.log(content.replace(/\u001b/g, ''));
327
326
  return;
328
327
  }
@@ -342,7 +341,7 @@ export async function main(args) {
342
341
  };
343
342
  const before = await load(arg), after = await load(second);
344
343
  const sameSelection = JSON.stringify(before.cases.map((item) => item.id).sort()) === JSON.stringify(after.cases.map((item) => item.id).sort());
345
- const comparable = before.suiteId === after.suiteId && before.suiteHash === after.suiteHash && targetFingerprint(before.target) === targetFingerprint(after.target) && sameSelection;
344
+ const comparable = before.suiteId === after.suiteId && before.suiteHash === after.suiteHash && sameReportTarget(before.target, after.target) && sameSelection;
346
345
  console.log(comparable ? localized(locale, 'Comparing the same suite, target and case selection (check external data state separately)', '동일 명세·대상·케이스 범위 비교 (외부 데이터 상태는 별도 확인)') : localized(locale, 'Suite, target or case selection differs; no direct regression verdict is made.', '명세·대상 또는 케이스 범위가 달라 직접적인 회귀 판정은 하지 않습니다.'));
347
346
  if (before.selection || after.selection)
348
347
  console.log(localized(locale, 'This comparison includes selected cases only; omitted cases were not evaluated.', '이 비교에는 선택 실행이 포함되어 있습니다. 미선택 케이스는 검증되지 않았습니다.'));
@@ -1,9 +1,74 @@
1
1
  import { realpathSync } from 'node:fs';
2
2
  import path from 'node:path';
3
+ import { z } from 'zod';
3
4
  import { expectedChecks } from "./compiler.js";
4
5
  import { isReportSelectionValid } from "./case-selection.js";
5
6
  import { localized, localizeProductMessage } from "./i18n.js";
7
+ import { idSchema } from "./schema.js";
6
8
  import { targetLabel } from "./targets.js";
9
+ const RUN_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
10
+ const archiveEnvelopeSchema = z.object({
11
+ schemaVersion: z.literal('flow-qa/report-1'), runId: z.string().regex(RUN_ID), suiteId: idSchema,
12
+ suiteHash: z.string(), target: z.union([
13
+ z.object({ name: z.string(), url: z.string() }),
14
+ z.object({ name: z.string(), kind: z.literal('mobile'), platform: z.enum(['ios', 'android']), bundleId: z.string(), device: z.string() }),
15
+ ]),
16
+ startedAt: z.string(), finishedAt: z.string(), status: z.enum(['passed', 'failed', 'blocked', 'error', 'interrupted']),
17
+ cases: z.array(z.object({ id: z.string(), title: z.string(), status: z.enum(['passed', 'failed', 'flaky', 'blocked', 'skipped', 'error']),
18
+ expected: z.array(z.string()), attempts: z.array(z.unknown()), reason: z.string().optional() }).passthrough()),
19
+ errors: z.array(z.string()), usage: z.object({ modelTokens: z.number(), modelCachedTokens: z.number().optional(), estimatedCostUsd: z.number().optional() }).optional(),
20
+ selection: z.unknown().optional(),
21
+ }).passthrough();
22
+ /** The original UI metadata contract accepts older reports with incomplete attempt details. */
23
+ export function parseArchivedReportEnvelope(raw) {
24
+ const parsed = archiveEnvelopeSchema.safeParse(raw);
25
+ return parsed.success && isReportSelectionValid(parsed.data.cases, parsed.data.selection) ? parsed.data : undefined;
26
+ }
27
+ const savedErrorSchema = z.object({ code: z.string(), message: z.string(), category: z.enum(['test', 'configuration', 'infrastructure', 'internal', 'interrupted']).optional() });
28
+ const savedAttemptSchema = z.object({
29
+ index: z.number().int().nonnegative(), status: z.enum(['passed', 'failed', 'timed-out', 'interrupted', 'skipped']),
30
+ startedAt: z.string(), durationMs: z.number().finite().nonnegative(),
31
+ error: savedErrorSchema.optional(), secondaryErrors: z.array(savedErrorSchema),
32
+ steps: z.array(z.object({ api: z.string(), label: z.string(), status: z.string() })),
33
+ artifacts: z.array(z.object({ kind: z.string(), redaction: z.enum(['complete', 'not-required', 'incomplete']), path: z.string().optional() })),
34
+ });
35
+ const savedReportSchema = z.object({
36
+ ...archiveEnvelopeSchema.shape,
37
+ suiteHash: z.string().regex(/^[a-f0-9]{64}$/),
38
+ cases: z.array(z.object({
39
+ id: idSchema, title: z.string(), status: z.enum(['passed', 'failed', 'flaky', 'blocked', 'skipped', 'error']),
40
+ expected: z.array(z.string()), reason: z.string().optional(),
41
+ attempts: z.array(savedAttemptSchema),
42
+ })),
43
+ usage: z.object({ modelTokens: z.number().finite().nonnegative(), modelCachedTokens: z.number().finite().nonnegative().optional(), estimatedCostUsd: z.number().finite().nonnegative().optional() }).optional(),
44
+ });
45
+ /** Shared archive gate for the CLI and local UI. Inspect the original object so extra selection keys cannot be stripped. */
46
+ export function isSavedReport(raw) {
47
+ if (!savedReportSchema.safeParse(raw).success)
48
+ return false;
49
+ const report = raw;
50
+ if (!isReportSelectionValid(report.cases, report.selection))
51
+ return false;
52
+ for (const item of report.cases) {
53
+ if (item.status === 'passed' && (item.attempts.length !== 1 || item.attempts[0]?.index !== 0 || item.attempts[0]?.status !== 'passed'))
54
+ return false;
55
+ if (item.status === 'flaky' && (item.attempts.length < 2 || item.attempts.at(-1)?.status !== 'passed'
56
+ || item.attempts.some((attempt, index) => attempt.index !== index || (index < item.attempts.length - 1 && !['failed', 'timed-out'].includes(attempt.status)))))
57
+ return false;
58
+ }
59
+ return report.status !== 'passed' || (report.errors.length === 0 && report.cases.length > 0 && report.cases.every((item) => item.status === 'passed'));
60
+ }
61
+ /** Prefer the normalized result for either language; keep older saved Markdown when it cannot be rendered. */
62
+ export function renderSavedMarkdown(raw, savedMarkdown, locale) {
63
+ if (!isSavedReport(raw))
64
+ return savedMarkdown;
65
+ try {
66
+ return renderMarkdown(raw, locale);
67
+ }
68
+ catch {
69
+ return savedMarkdown;
70
+ }
71
+ }
7
72
  function scopedCases(context) {
8
73
  if (!context.selection)
9
74
  return context.suite.cases;
@@ -1,6 +1,6 @@
1
1
  import { localized } from "./i18n.js";
2
2
  import { isReportSelectionValid } from "./case-selection.js";
3
- import { targetFingerprint, targetLabel } from "./targets.js";
3
+ import { sameReportTarget, targetLabel } from "./targets.js";
4
4
  export const comparisonCategories = ['newly-failed', 'now-passed', 'changed', 'unchanged', 'added', 'missing'];
5
5
  export class ComparisonError extends Error {
6
6
  status;
@@ -51,7 +51,7 @@ export function compareReports(baseline, current) {
51
51
  throw new ComparisonError(400, 'A comparison needs two different runs.');
52
52
  if (baseline.suiteId !== current.suiteId)
53
53
  throw new ComparisonError(409, 'Both reports must belong to the same suite.');
54
- if (targetFingerprint(baseline.target) !== targetFingerprint(current.target)) {
54
+ if (!sameReportTarget(baseline.target, current.target)) {
55
55
  throw new ComparisonError(409, 'Both reports must use the same target.');
56
56
  }
57
57
  if (!baseline.suiteHash.trim() || !current.suiteHash.trim()) {
@@ -13,6 +13,29 @@ export function targetFingerprint(target) {
13
13
  : { kind: 'web', url: target.url };
14
14
  return createHash('sha256').update(JSON.stringify(identity)).digest('hex');
15
15
  }
16
+ // Keep the original authority spelling so only the optional root slash compares equal.
17
+ function rootAuthority(url) {
18
+ return /^(https?:\/\/[^/?#@\\\s]+)\/?$/i.exec(url)?.[1];
19
+ }
20
+ export function sameReportTarget(left, right) {
21
+ if (targetFingerprint(left) === targetFingerprint(right))
22
+ return true;
23
+ if (left.kind === 'mobile' || right.kind === 'mobile' || typeof left.url !== 'string' || typeof right.url !== 'string')
24
+ return false;
25
+ const authority = rootAuthority(left.url);
26
+ return authority !== undefined && authority === rootAuthority(right.url);
27
+ }
28
+ export function registrationTarget(target, previous) {
29
+ if (target.kind === 'mobile')
30
+ return target;
31
+ const authority = rootAuthority(target.url);
32
+ if (!authority)
33
+ return target;
34
+ if (previous && previous.kind !== 'mobile' && rootAuthority(previous.url) === authority) {
35
+ return { ...target, url: previous.url };
36
+ }
37
+ return { ...target, url: authority };
38
+ }
16
39
  export function reportTarget(name, target) {
17
40
  return target.kind === 'mobile'
18
41
  ? { name, kind: 'mobile', platform: target.platform, bundleId: target.bundleId, device: target.device }
@@ -13,10 +13,10 @@ import { runSuite } from "../engine.js";
13
13
  import { localeFromAcceptLanguage, localizeProductMessage } from "../i18n.js";
14
14
  import { EvidenceError, readEvidence } from "./evidence.js";
15
15
  import { buildPlanningPrompt, planFlow, PlannerError } from "../planner.js";
16
- import { renderMarkdown } from "../report.js";
16
+ import { parseArchivedReportEnvelope, renderSavedMarkdown } from "../report.js";
17
17
  import { compareReports, ComparisonError, renderComparisonMarkdown } from "../run-comparison.js";
18
18
  import { configSchema, idSchema, modelSchema, suiteSchema, targetSchema } from "../schema.js";
19
- import { targetFingerprint } from "../targets.js";
19
+ import { registrationTarget, targetFingerprint } from "../targets.js";
20
20
  import { CONFIG_FILE, sha256 } from "../workspace.js";
21
21
  const MAX_BODY = 256 * 1024;
22
22
  const MAX_FLOW = 128 * 1024;
@@ -36,18 +36,6 @@ const runCursorSchema = z.object({
36
36
  filterHash: z.string().regex(/^[0-9a-f]{64}$/),
37
37
  }).strict();
38
38
  const FILE_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]{0,159}$/;
39
- const reportEnvelope = z.object({
40
- schemaVersion: z.literal('flow-qa/report-1'), runId: z.string().regex(RUN_ID), suiteId: idSchema,
41
- suiteHash: z.string(), target: z.union([
42
- z.object({ name: z.string(), url: z.string() }),
43
- z.object({ name: z.string(), kind: z.literal('mobile'), platform: z.enum(['ios', 'android']), bundleId: z.string(), device: z.string() }),
44
- ]),
45
- startedAt: z.string(), finishedAt: z.string(), status: z.enum(['passed', 'failed', 'blocked', 'error', 'interrupted']),
46
- cases: z.array(z.object({ id: z.string(), title: z.string(), status: z.enum(['passed', 'failed', 'flaky', 'blocked', 'skipped', 'error']),
47
- expected: z.array(z.string()), attempts: z.array(z.unknown()), reason: z.string().optional() }).passthrough()),
48
- errors: z.array(z.string()), usage: z.object({ modelTokens: z.number(), modelCachedTokens: z.number().optional(), estimatedCostUsd: z.number().optional() }).optional(),
49
- selection: z.unknown().optional(),
50
- }).passthrough().refine((report) => isReportSelectionValid(report.cases, report.selection));
51
39
  const PUBLIC_DIR = path.join(path.dirname(fileURLToPath(import.meta.url)), 'public');
52
40
  const STATIC_FILES = {
53
41
  '/': { file: path.join(PUBLIC_DIR, 'index.html'), type: 'text/html; charset=utf-8' },
@@ -396,17 +384,12 @@ export async function startUIServer(options) {
396
384
  }
397
385
  async function report(runId, includeMarkdown, locale = 'en') {
398
386
  const dir = await runDirectory(runId);
399
- const parsed = reportEnvelope.safeParse(jsonObject(await readRegular(dir, 'qa-report.json', MAX_REPORT)));
400
- if (!parsed.success || parsed.data.runId !== runId)
387
+ const raw = parseArchivedReportEnvelope(jsonObject(await readRegular(dir, 'qa-report.json', MAX_REPORT)));
388
+ if (!raw || raw.runId !== runId)
401
389
  notFound();
402
- const raw = parsed.data;
403
390
  let markdown = includeMarkdown ? await readRegular(dir, 'qa-report.md', MAX_REPORT) : undefined;
404
- if (markdown !== undefined && locale === 'ko') {
405
- try {
406
- markdown = renderMarkdown(raw, locale);
407
- }
408
- catch { /* Preserve the saved report when an older or malformed JSON report cannot be rendered. */ }
409
- }
391
+ if (markdown !== undefined)
392
+ markdown = renderSavedMarkdown(raw, markdown, locale);
410
393
  return { report: raw, ...(markdown === undefined ? {} : { markdown }) };
411
394
  }
412
395
  async function runCandidates() {
@@ -821,7 +804,7 @@ export async function startUIServer(options) {
821
804
  ]), body);
822
805
  const target = parse(targetSchema, input);
823
806
  const settings = await config();
824
- settings.targets[name] = target;
807
+ settings.targets[name] = registrationTarget(target, settings.targets[name]);
825
808
  await updateConfig(settings);
826
809
  });
827
810
  sendJSON(response, 200, { ok: true });
package/docs/releases.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Releases and verification
2
2
 
3
+ ## 0.9.7 — reopen archived reports and compare repeated web runs
4
+
5
+ The CLI and local UI render archived normalized reports in both English and Korean. A passing run saved by an older release now reads consistently in either language. The original Markdown snapshot stays available on disk.
6
+
7
+ Web target registration and run comparisons recognize a bare origin and the same origin with a single final slash. Re-registering an existing target preserves its original URL spelling. Mobile targets and URL paths retain their existing identity. The packaged skill also shows how to use the full accessible name of a link in a browser case.
8
+
3
9
  ## 0.9.6 — show diagnosis guidance only for nonpassing runs
4
10
 
5
11
  Passing Markdown reports no longer include the generic **Possible causes** section or its Korean failure wording. Failed, blocked, interrupted, and error reports retain the existing guidance; report JSON and other Markdown sections are unchanged. A focused regression checks passing and failed reports in English and Korean. Re-rendering the saved healthy and assertion-failure reports confirmed that only the healthy report loses the footer; the failed report remains byte-for-byte identical.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ihyeon/flow-qa",
3
- "version": "0.9.6",
3
+ "version": "0.9.7",
4
4
  "license": "MIT",
5
5
  "author": "Hyeonse Im",
6
6
  "repository": {
@@ -16,6 +16,8 @@ Give the generated `planning/my-flow.prompt.md` to that AI, save its JSON reply
16
16
  flow-qa validate cases/my-flow.json --workspace my-qa
17
17
  ```
18
18
 
19
+ For a named role locator, copy the control's full accessible name from the target browser. For example, a link announced as `← All notes` needs that arrow in its name. If a locator finds no node, check the browser’s accessibility tree before treating it as an application failure.
20
+
19
21
  Validation confirms the schema, not that product expectations are correct. Cases with `questions` are blocked. `preconditions` describe setup but do not create accounts, inventory, login state, or other data. A changed source flow invalidates a suite with recorded source provenance; redesign cases rather than bypassing the check. Planning can also use a configured planner model, which sends the flow to the configured endpoint.
20
22
 
21
23
  ## Choose and execute a target
@@ -32,6 +34,10 @@ Web execution needs the package's Chromium (`flow-qa browser install`). The run
32
34
 
33
35
  To run only named cases, repeat `--case TC-001 --case TC-003` on `run`. Omitted cases were not evaluated. Each case must establish its own starting state; selecting a case does not run earlier cases as prerequisites. The run writes `qa-report.json` and `qa-report.md` under a new `.flowqa/runs/<run-id>/`. Use `flow-qa report <run-directory> --workspace my-qa` to read a saved report. Compare only with attention to suite, target, selection, and external data state.
34
36
 
37
+ When reopening an older run, the CLI and local UI render a supported normalized report using the requested language. The original on-disk Markdown file is the snapshot generated at execution time. The CLI can still display that snapshot if normalized JSON is missing or unreadable.
38
+
39
+ Flow QA treats an HTTP(S) origin with or without its final slash as the same root when comparing reports. Paths such as `/preview` and `/preview/` stay distinct. When re-registering an existing target, use the same target name so its stored URL spelling and downstream fingerprint stay stable. Previously linked fingerprint-only results in Error-to-Test retain their original scope.
40
+
35
41
  ## External browser agent path (web only)
36
42
 
37
43
  For a reviewed web suite and an external agent with its own browser tools: