@ihyeon/flow-qa 0.9.2 → 0.9.3

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.
@@ -176,9 +176,38 @@ function validateAgentResult(request, result) {
176
176
  function safeLine(value) {
177
177
  return value.replace(/[\u0000-\u001f\u007f-\u009f|]/g, ' ').slice(0, 2000);
178
178
  }
179
- function markdownLiteral(value) {
180
- const escaped = safeLine(value).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/`/g, '&#96;');
181
- return `\`${escaped}\``;
179
+ function markdownLiteral(value, limit = 2000) {
180
+ const visible = value.slice(0, limit).replace(/[\u0000-\u001f\u007f-\u009f\u2028\u2029\\]/g, (character) => {
181
+ if (character === '\\')
182
+ return '\\\\';
183
+ if (character === '\n')
184
+ return '\\n';
185
+ if (character === '\r')
186
+ return '\\r';
187
+ if (character === '\t')
188
+ return '\\t';
189
+ return `\\u${character.codePointAt(0).toString(16).padStart(4, '0')}`;
190
+ });
191
+ const longestRun = Math.max(0, ...(visible.match(/`+/g) ?? []).map((run) => run.length));
192
+ const fence = '`'.repeat(longestRun + 1);
193
+ const content = visible.startsWith('`') || visible.endsWith('`') ? ` ${visible} ` : visible;
194
+ return `${fence}${content}${fence}`;
195
+ }
196
+ function expectedLocator(locator) {
197
+ if (locator.by === 'role')
198
+ return `role ${markdownLiteral(locator.value)}${locator.name ? ` named ${markdownLiteral(locator.name, 8192)}` : ''}`;
199
+ return `${locator.by} ${markdownLiteral(locator.value, 8192)}`;
200
+ }
201
+ function expectedAssertion(step) {
202
+ if (step.type === 'assertVisible')
203
+ return `${step.visible ? 'visible' : 'hidden'} at ${expectedLocator(step.locator)}`;
204
+ if (step.type === 'assertText')
205
+ return `text ${step.match === 'equals' ? 'equal to' : 'containing'} ${markdownLiteral(step.expected, 8192)} at ${expectedLocator(step.locator)}`;
206
+ if (step.type === 'assertUrl')
207
+ return `URL ${markdownLiteral(step.expected, 8192)}`;
208
+ if (step.type === 'assertAgent')
209
+ return `condition ${markdownLiteral(step.instruction, 8192)}`;
210
+ throw new Error('Agent result refers to a non-assertion step.');
182
211
  }
183
212
  export async function reviewAgentHandoff(directoryPath, resultPath) {
184
213
  const directoryInfo = await lstat(directoryPath);
@@ -222,12 +251,21 @@ export async function reviewAgentHandoff(directoryPath, resultPath) {
222
251
  'These findings were supplied by an external agent. File references and structure were checked; execution and authenticity were not verified by Flow QA.', '',
223
252
  `Suite: ${safeLine(request.suite.id)} · target: ${safeLine(request.target.name)} · ${result.cases.length} selected case(s)`,
224
253
  `Observed passed: ${counts['observed-passed']} · observed failed: ${counts['observed-failed']} · blocked: ${counts.blocked} · unverified: ${counts.unverified}`, '',
225
- ...result.cases.flatMap((item) => [
226
- `## ${safeLine(item.id)} — ${safeLine(item.status)}`,
227
- ...(item.status === 'blocked' ? [`Reason: ${markdownLiteral(item.reason)}`] : []),
228
- ...item.observations.map((observation) => `- Assertion step ${observation.stepIndex}: ${observation.outcome}; ${markdownLiteral(observation.detail)} [${observation.evidence}]`),
229
- '',
230
- ]),
254
+ ...result.cases.flatMap((item, index) => {
255
+ const testCase = request.suite.cases[index];
256
+ return [
257
+ `## ${safeLine(item.id)} — ${safeLine(item.status)}`,
258
+ `Case: ${markdownLiteral(testCase.title, 8192)}`,
259
+ ...(item.status === 'blocked' ? [`Reason: ${markdownLiteral(item.reason)}`] : []),
260
+ ...item.observations.flatMap((observation) => [
261
+ `- Assertion step ${observation.stepIndex}: ${observation.outcome}`,
262
+ ` - Expected: ${expectedAssertion(testCase.steps[observation.stepIndex])}`,
263
+ ` - Observed: ${markdownLiteral(observation.detail)}`,
264
+ ` - Evidence: ${markdownLiteral(observation.evidence)}`,
265
+ ]),
266
+ '',
267
+ ];
268
+ }),
231
269
  ];
232
270
  return `${lines.join('\n')}\n`;
233
271
  }
@@ -2,6 +2,12 @@
2
2
 
3
3
  [한국어](#한국어) · [English](#english)
4
4
 
5
+ ## 2026-11-18 follow-up finding · 후속 조사
6
+
7
+ The previous independent browser-agent trial produced both failed and passing observations from the same reviewed case. `agent-review` checked the result structure and evidence references, but its summary printed only the agent's observation. A reviewer had to open `request.json` and find the matching step to see what had been expected. The summary should pair each reported assertion with the reviewed expectation and locator, while keeping the agent's observation and evidence reference distinct. The result JSON and its validation rules remain the source record.
8
+
9
+ 지난 독립 브라우저 에이전트 검증에서는 동일한 검토 케이스로 실패와 통과를 관찰했습니다. 기존 `agent-review` 요약에는 에이전트의 관찰 내용만 있어 검토자가 `request.json`에서 기대값과 locator를 따로 찾아야 했습니다. 각 assertion의 기대 조건·관찰·증거를 함께 표시하도록 개선하되 결과 JSON과 검증 규칙은 그대로 사용합니다.
10
+
5
11
  ## English
6
12
 
7
13
  Use an existing, reviewed **web** case suite with a coding agent that has its own browser tools, including Playwright if available. This path creates a portable, readable folder. The agent does not need Flow QA or its `e2e` dependencies installed; the reviewer's Flow QA CLI prepares and checks the folder. The handoff itself does not call a model, open a browser, or run a test.
@@ -45,6 +51,8 @@ flow-qa agent-review my-qa/.flowqa/handoffs/<directory> my-qa/.flowqa/handoffs/<
45
51
 
46
52
  The review requires the same request hash and case IDs in the same order. `observed-passed` requires matching observations for every assertion in step order; `observed-failed` requires a first mismatch after any earlier matching assertions and no later observations. A case with open questions cannot be marked observed. Evidence must be a real, nonempty regular file inside `evidence/`, with an approved extension and at most 10 MB; links and traversal are rejected. The result must be at most 1 MB. These checks make the response reviewable; they do **not** prove that the external agent visited the target or that the screenshot is authentic. The output is labeled **external agent observations** and is never added to Flow QA's engine-backed `qa-report.json` history.
47
53
 
54
+ The review summary shows each reported assertion's expected condition and locator from the reviewed case beside the agent's observed detail and evidence path. A failed case therefore identifies the first mismatched expectation without a manual lookup in `request.json`. The summary prints case content and observations, so inspect it before sharing.
55
+
48
56
  Only the registered target identity is exported. Model connections and their key environment variables are omitted. A target URL with credentials, a query, a fragment, or a token-like path is refused rather than silently redacted. Case content is not masked because that would change the reviewed suite: inspect the URL, case text, and evidence before sharing the folder. The handoff accepts at most 1 MB of case/request JSON, supports web targets only, and does not prepare logins, accounts, or test data.
49
57
 
50
58
  ## 한국어
@@ -63,3 +71,5 @@ flow-qa agent-review my-qa/.flowqa/handoffs/<폴더> my-qa/.flowqa/handoffs/<폴
63
71
  ```
64
72
 
65
73
  검토 명령은 요청 해시·케이스 범위·관찰 상태·증거 파일의 존재와 경로를 확인합니다. 에이전트가 실제로 페이지를 방문했는지, 증거가 진짜인지까지 증명하지 않습니다. 이 결과는 에이전트의 관찰 기록으로만 표시하며 기존 `qa-report.json` 실행 기록에 합치지 않습니다. 모델 설정과 키 환경 변수는 묶음에 넣지 않습니다. 쿼리·인증정보·토큰처럼 보이는 경로가 있는 대상 URL은 거부하고, 케이스 본문은 몰래 마스킹하지 않습니다. 외부 공유 전에 케이스·대상·증거의 민감한 내용을 직접 확인하세요.
74
+
75
+ 검토 요약은 각 assertion의 검토된 기대 조건·locator와 에이전트의 관찰 내용·증거 파일 경로를 함께 보여줍니다. 실패한 케이스는 첫 불일치 기대값을 `request.json`에서 따로 찾지 않아도 확인할 수 있습니다. 요약에도 케이스 본문과 관찰 내용이 들어가므로 공유 전에 내용을 확인하세요.
package/docs/releases.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Releases and verification
2
2
 
3
+ ## 0.9.3 — show reviewed expectations in external observations
4
+
5
+ The `agent-review` summary now pairs each reported assertion with the case's reviewed expectation and locator, the external agent's observed detail, and its evidence path. The case title appears above its observations. This makes a failed observation identifiable from the summary without finding the matching step in `request.json`. Untrusted text is rendered as Markdown code spans with enough backticks to preserve literal values, including pipes, angle brackets, and backticks; line breaks and control characters are displayed as escapes. The handoff and result JSON contracts and their validation rules are unchanged.
6
+
7
+ The 2026-11-18 follow-up finding and sharing guidance are recorded in the [handoff guide](agent-handoff.md). On Node.js 24.22.1, `npm run check` passed 124 tests, type checking and UI checks; `npm run check:package` passed for an 83-file tarball; and `npm run smoke:package` installed that tarball and passed its browser and synthetic agent-result checks. The compiled CLI also reviewed the existing independent agent's recorded failed and passing handoffs from 2026-11-17, showing the reviewed expectation beside each observation. These checks used local fixtures and existing evidence. Registry publication and remote CI are verified after the main push.
8
+
3
9
  ## 0.9.2 — copied-skill installation and agent result contract
4
10
 
5
11
  An independent agent used a generated handoff to observe a real browser failure, then returned an observed-failed case with an explanatory `reason`. The exported JSON Schema allowed that field while `agent-review` already rejected it. Generated schemas and prompts now describe the existing per-status rules: observed outcomes put the explanation in assertion observations and omit the blocking reason; blocked and unverified outcomes retain their distinct reason/observation limits. The result schema version and runtime interpretation are unchanged.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ihyeon/flow-qa",
3
- "version": "0.9.2",
3
+ "version": "0.9.3",
4
4
  "license": "MIT",
5
5
  "author": "Hyeonse Im",
6
6
  "repository": {
@@ -48,3 +48,5 @@ flow-qa agent-review <handoff-directory> <handoff-directory>/agent-result.json
48
48
  ```
49
49
 
50
50
  This review checks request binding, case scope and order, observation structure, and evidence file references. It does not verify visits or evidence authenticity and does not create an engine QA report. Handoff omits model connection settings but does not mask case content; check material before sharing. See `AGENT_PROMPT.md` and `agent-result.schema.json` inside each generated bundle for that bundle's exact contract.
51
+
52
+ For each observed assertion, the review summary pairs the reviewed expectation and locator with the agent's observation and evidence path. Inspect both sides of a mismatch before changing the application or its case.