ccqa 1.51.1 → 1.52.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.md +11 -4
- package/dist/bin/ccqa.mjs +22489 -13425
- package/dist/evidence-constants-BufWx8Bt.cjs +59 -0
- package/dist/hub-client/index.cjs +434 -0
- package/dist/hub-client/index.d.cts +1376 -0
- package/dist/hub-client/index.d.mts +28 -4
- package/dist/package.json +49 -9
- package/dist/runtime/judge.cjs +1307 -0
- package/dist/runtime/judge.d.cts +68 -0
- package/dist/runtime/judge.d.mts +24 -2
- package/dist/runtime/judge.mjs +1229 -3
- package/dist/runtime/step-evidence.cjs +106 -0
- package/dist/runtime/step-evidence.d.cts +53 -0
- package/dist/runtime/step-evidence.mjs +1 -1
- package/dist/runtime/test-helpers.cjs +461 -0
- package/dist/runtime/test-helpers.d.cts +39 -0
- package/dist/runtime/test-helpers.mjs +134 -3
- package/package.json +49 -9
- package/dist/diagnose-CZms9Cer.mjs +0 -2432
- package/dist/spawn-ab-CR_Sr7wh.mjs +0 -199
- /package/dist/{evidence-constants-Cm_S_5od.mjs → evidence-constants-C425F7ZG.mjs} +0 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
//#region src/runtime/judge.d.ts
|
|
2
|
+
/** One decided claim. */
|
|
3
|
+
interface Verdict {
|
|
4
|
+
ok: boolean;
|
|
5
|
+
/** Why, in one sentence. Carried into the failure message so a red test says what was wrong. */
|
|
6
|
+
reason: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The slice of Playwright's `Page` this needs. Structural because ccqa does
|
|
10
|
+
* not depend on Playwright, which also lets a caller pass anything else that
|
|
11
|
+
* can hand over text.
|
|
12
|
+
*/
|
|
13
|
+
interface TextSource {
|
|
14
|
+
innerText(selector: string): Promise<string>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The one method this needs from Playwright's `TestInfo` — structural, so
|
|
18
|
+
* ccqa keeps no Playwright dependency.
|
|
19
|
+
*/
|
|
20
|
+
interface TestInfoLike {
|
|
21
|
+
attach(name: string, options: {
|
|
22
|
+
body: string;
|
|
23
|
+
contentType: string;
|
|
24
|
+
}): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
interface JudgeOptions {
|
|
27
|
+
/** CSS selector whose text is read as the evidence. Default "body". */
|
|
28
|
+
from?: string;
|
|
29
|
+
/** Playwright's per-test handle; when given, the verdict is attached to the test's report. */
|
|
30
|
+
testInfo?: TestInfoLike;
|
|
31
|
+
/** Model for this judgement. Falls back to CCQA_JUDGE_MODEL, then CCQA_MODEL. */
|
|
32
|
+
model?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Fails the test unless a model agrees the claim holds for the text read from
|
|
36
|
+
* `from` (a selector; omitted, the page's body). The reason the model gave
|
|
37
|
+
* rides in the failure, so a red test says what was wrong.
|
|
38
|
+
*
|
|
39
|
+
* A selector matching several elements judges the first, as Playwright's
|
|
40
|
+
* page-level `innerText` does — narrow it if that is not what you mean.
|
|
41
|
+
*
|
|
42
|
+
* A string third argument is shorthand for `{ from: <string> }` — the form
|
|
43
|
+
* generated tests already carry. Pass `testInfo` (Playwright's per-test
|
|
44
|
+
* handle) to attach the verdict to the test's report, pass or fail.
|
|
45
|
+
*/
|
|
46
|
+
declare function judgeByLlm(page: TextSource, claim: string, options?: string | JudgeOptions): Promise<void>;
|
|
47
|
+
interface ClaimInput {
|
|
48
|
+
/** The claim to decide, as written in the spec's `judgeByLlm`. */
|
|
49
|
+
claim: string;
|
|
50
|
+
/** The text it is decided against. */
|
|
51
|
+
text: string;
|
|
52
|
+
model?: string;
|
|
53
|
+
cwd?: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Decides a claim about text a run cannot predict — a generated answer, a
|
|
57
|
+
* summary. A model that will not answer, or answers something this cannot
|
|
58
|
+
* read, is an unmade decision rather than a passing one: it throws, so a
|
|
59
|
+
* claim never goes silently unjudged.
|
|
60
|
+
*/
|
|
61
|
+
declare function decideClaim(input: ClaimInput): Promise<Verdict>;
|
|
62
|
+
/**
|
|
63
|
+
* The model is asked for bare JSON but sometimes wraps it in prose or a fence.
|
|
64
|
+
* An answer with no readable verdict is a failure to decide, not a false one.
|
|
65
|
+
*/
|
|
66
|
+
declare function parseVerdict(answer: string): Verdict;
|
|
67
|
+
//#endregion
|
|
68
|
+
export { ClaimInput, JudgeOptions, TestInfoLike, TextSource, Verdict, decideClaim, judgeByLlm, parseVerdict };
|
package/dist/runtime/judge.d.mts
CHANGED
|
@@ -13,6 +13,24 @@ interface Verdict {
|
|
|
13
13
|
interface TextSource {
|
|
14
14
|
innerText(selector: string): Promise<string>;
|
|
15
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* The one method this needs from Playwright's `TestInfo` — structural, so
|
|
18
|
+
* ccqa keeps no Playwright dependency.
|
|
19
|
+
*/
|
|
20
|
+
interface TestInfoLike {
|
|
21
|
+
attach(name: string, options: {
|
|
22
|
+
body: string;
|
|
23
|
+
contentType: string;
|
|
24
|
+
}): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
interface JudgeOptions {
|
|
27
|
+
/** CSS selector whose text is read as the evidence. Default "body". */
|
|
28
|
+
from?: string;
|
|
29
|
+
/** Playwright's per-test handle; when given, the verdict is attached to the test's report. */
|
|
30
|
+
testInfo?: TestInfoLike;
|
|
31
|
+
/** Model for this judgement. Falls back to CCQA_JUDGE_MODEL, then CCQA_MODEL. */
|
|
32
|
+
model?: string;
|
|
33
|
+
}
|
|
16
34
|
/**
|
|
17
35
|
* Fails the test unless a model agrees the claim holds for the text read from
|
|
18
36
|
* `from` (a selector; omitted, the page's body). The reason the model gave
|
|
@@ -20,8 +38,12 @@ interface TextSource {
|
|
|
20
38
|
*
|
|
21
39
|
* A selector matching several elements judges the first, as Playwright's
|
|
22
40
|
* page-level `innerText` does — narrow it if that is not what you mean.
|
|
41
|
+
*
|
|
42
|
+
* A string third argument is shorthand for `{ from: <string> }` — the form
|
|
43
|
+
* generated tests already carry. Pass `testInfo` (Playwright's per-test
|
|
44
|
+
* handle) to attach the verdict to the test's report, pass or fail.
|
|
23
45
|
*/
|
|
24
|
-
declare function judgeByLlm(page: TextSource, claim: string,
|
|
46
|
+
declare function judgeByLlm(page: TextSource, claim: string, options?: string | JudgeOptions): Promise<void>;
|
|
25
47
|
interface ClaimInput {
|
|
26
48
|
/** The claim to decide, as written in the spec's `judgeByLlm`. */
|
|
27
49
|
claim: string;
|
|
@@ -43,4 +65,4 @@ declare function decideClaim(input: ClaimInput): Promise<Verdict>;
|
|
|
43
65
|
*/
|
|
44
66
|
declare function parseVerdict(answer: string): Verdict;
|
|
45
67
|
//#endregion
|
|
46
|
-
export { ClaimInput, TextSource, Verdict, decideClaim, judgeByLlm, parseVerdict };
|
|
68
|
+
export { ClaimInput, JudgeOptions, TestInfoLike, TextSource, Verdict, decideClaim, judgeByLlm, parseVerdict };
|