@tangle-network/browser-agent-driver 0.30.0 → 0.31.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/dist/cli-ack-patch.d.ts +39 -0
- package/dist/cli-ack-patch.d.ts.map +1 -0
- package/dist/cli-ack-patch.js +47 -0
- package/dist/cli-ack-patch.js.map +1 -0
- package/dist/cli-design-audit.d.ts +12 -0
- package/dist/cli-design-audit.d.ts.map +1 -1
- package/dist/cli-design-audit.js +88 -0
- package/dist/cli-design-audit.js.map +1 -1
- package/dist/cli-jobs.d.ts +13 -0
- package/dist/cli-jobs.d.ts.map +1 -0
- package/dist/cli-jobs.js +262 -0
- package/dist/cli-jobs.js.map +1 -0
- package/dist/cli-patterns.d.ts +26 -0
- package/dist/cli-patterns.d.ts.map +1 -0
- package/dist/cli-patterns.js +49 -0
- package/dist/cli-patterns.js.map +1 -0
- package/dist/cli-reports.d.ts +12 -0
- package/dist/cli-reports.d.ts.map +1 -0
- package/dist/cli-reports.js +97 -0
- package/dist/cli-reports.js.map +1 -0
- package/dist/cli.js +29 -1
- package/dist/cli.js.map +1 -1
- package/dist/design/audit/attribution/aggregate.d.ts +16 -0
- package/dist/design/audit/attribution/aggregate.d.ts.map +1 -0
- package/dist/design/audit/attribution/aggregate.js +81 -0
- package/dist/design/audit/attribution/aggregate.js.map +1 -0
- package/dist/design/audit/attribution/store.d.ts +36 -0
- package/dist/design/audit/attribution/store.d.ts.map +1 -0
- package/dist/design/audit/attribution/store.js +108 -0
- package/dist/design/audit/attribution/store.js.map +1 -0
- package/dist/design/audit/attribution/types.d.ts +13 -0
- package/dist/design/audit/attribution/types.d.ts.map +1 -0
- package/dist/design/audit/attribution/types.js +10 -0
- package/dist/design/audit/attribution/types.js.map +1 -0
- package/dist/design/audit/classify-ensemble.d.ts +46 -0
- package/dist/design/audit/classify-ensemble.d.ts.map +1 -0
- package/dist/design/audit/classify-ensemble.js +207 -0
- package/dist/design/audit/classify-ensemble.js.map +1 -0
- package/dist/design/audit/ethics/check.d.ts +59 -0
- package/dist/design/audit/ethics/check.d.ts.map +1 -0
- package/dist/design/audit/ethics/check.js +137 -0
- package/dist/design/audit/ethics/check.js.map +1 -0
- package/dist/design/audit/ethics/loader.d.ts +21 -0
- package/dist/design/audit/ethics/loader.d.ts.map +1 -0
- package/dist/design/audit/ethics/loader.js +207 -0
- package/dist/design/audit/ethics/loader.js.map +1 -0
- package/dist/design/audit/ethics/rules/finance.yaml +37 -0
- package/dist/design/audit/ethics/rules/kids.yaml +37 -0
- package/dist/design/audit/ethics/rules/legal.yaml +35 -0
- package/dist/design/audit/ethics/rules/medical.yaml +36 -0
- package/dist/design/audit/evaluate.d.ts.map +1 -1
- package/dist/design/audit/evaluate.js +4 -1
- package/dist/design/audit/evaluate.js.map +1 -1
- package/dist/design/audit/first-principles-mode.d.ts +42 -0
- package/dist/design/audit/first-principles-mode.d.ts.map +1 -0
- package/dist/design/audit/first-principles-mode.js +77 -0
- package/dist/design/audit/first-principles-mode.js.map +1 -0
- package/dist/design/audit/modality/android.d.ts +14 -0
- package/dist/design/audit/modality/android.d.ts.map +1 -0
- package/dist/design/audit/modality/android.js +18 -0
- package/dist/design/audit/modality/android.js.map +1 -0
- package/dist/design/audit/modality/html.d.ts +22 -0
- package/dist/design/audit/modality/html.d.ts.map +1 -0
- package/dist/design/audit/modality/html.js +51 -0
- package/dist/design/audit/modality/html.js.map +1 -0
- package/dist/design/audit/modality/index.d.ts +8 -0
- package/dist/design/audit/modality/index.d.ts.map +1 -0
- package/dist/design/audit/modality/index.js +15 -0
- package/dist/design/audit/modality/index.js.map +1 -0
- package/dist/design/audit/modality/ios.d.ts +16 -0
- package/dist/design/audit/modality/ios.d.ts.map +1 -0
- package/dist/design/audit/modality/ios.js +19 -0
- package/dist/design/audit/modality/ios.js.map +1 -0
- package/dist/design/audit/modality/types.d.ts +9 -0
- package/dist/design/audit/modality/types.d.ts.map +1 -0
- package/dist/design/audit/modality/types.js +9 -0
- package/dist/design/audit/modality/types.js.map +1 -0
- package/dist/design/audit/patches/index.d.ts +8 -0
- package/dist/design/audit/patches/index.d.ts.map +1 -0
- package/dist/design/audit/patches/index.js +5 -0
- package/dist/design/audit/patches/index.js.map +1 -0
- package/dist/design/audit/patches/parse.d.ts +29 -0
- package/dist/design/audit/patches/parse.d.ts.map +1 -0
- package/dist/design/audit/patches/parse.js +153 -0
- package/dist/design/audit/patches/parse.js.map +1 -0
- package/dist/design/audit/patches/render.d.ts +20 -0
- package/dist/design/audit/patches/render.d.ts.map +1 -0
- package/dist/design/audit/patches/render.js +55 -0
- package/dist/design/audit/patches/render.js.map +1 -0
- package/dist/design/audit/patches/severity-enforcement.d.ts +23 -0
- package/dist/design/audit/patches/severity-enforcement.d.ts.map +1 -0
- package/dist/design/audit/patches/severity-enforcement.js +42 -0
- package/dist/design/audit/patches/severity-enforcement.js.map +1 -0
- package/dist/design/audit/patches/validate.d.ts +34 -0
- package/dist/design/audit/patches/validate.d.ts.map +1 -0
- package/dist/design/audit/patches/validate.js +53 -0
- package/dist/design/audit/patches/validate.js.map +1 -0
- package/dist/design/audit/patterns/match.d.ts +24 -0
- package/dist/design/audit/patterns/match.d.ts.map +1 -0
- package/dist/design/audit/patterns/match.js +48 -0
- package/dist/design/audit/patterns/match.js.map +1 -0
- package/dist/design/audit/patterns/mine.d.ts +31 -0
- package/dist/design/audit/patterns/mine.d.ts.map +1 -0
- package/dist/design/audit/patterns/mine.js +35 -0
- package/dist/design/audit/patterns/mine.js.map +1 -0
- package/dist/design/audit/patterns/store.d.ts +14 -0
- package/dist/design/audit/patterns/store.d.ts.map +1 -0
- package/dist/design/audit/patterns/store.js +53 -0
- package/dist/design/audit/patterns/store.js.map +1 -0
- package/dist/design/audit/patterns/types.d.ts +53 -0
- package/dist/design/audit/patterns/types.d.ts.map +1 -0
- package/dist/design/audit/patterns/types.js +13 -0
- package/dist/design/audit/patterns/types.js.map +1 -0
- package/dist/design/audit/pipeline.d.ts +12 -0
- package/dist/design/audit/pipeline.d.ts.map +1 -1
- package/dist/design/audit/pipeline.js +65 -3
- package/dist/design/audit/pipeline.js.map +1 -1
- package/dist/design/audit/rubric/anchor-loader.d.ts +44 -0
- package/dist/design/audit/rubric/anchor-loader.d.ts.map +1 -0
- package/dist/design/audit/rubric/anchor-loader.js +210 -0
- package/dist/design/audit/rubric/anchor-loader.js.map +1 -0
- package/dist/design/audit/rubric/anchors/blog.yaml +33 -0
- package/dist/design/audit/rubric/anchors/dashboard.yaml +35 -0
- package/dist/design/audit/rubric/anchors/docs.yaml +35 -0
- package/dist/design/audit/rubric/anchors/ecommerce.yaml +33 -0
- package/dist/design/audit/rubric/anchors/marketing.yaml +34 -0
- package/dist/design/audit/rubric/anchors/saas-app.yaml +38 -0
- package/dist/design/audit/rubric/anchors/social.yaml +33 -0
- package/dist/design/audit/rubric/anchors/tool.yaml +33 -0
- package/dist/design/audit/rubric/anchors/utility.yaml +33 -0
- package/dist/design/audit/rubric/fragments/audience-clinician.md +42 -0
- package/dist/design/audit/rubric/fragments/audience-developer.md +40 -0
- package/dist/design/audit/rubric/fragments/audience-kids.md +35 -0
- package/dist/design/audit/rubric/fragments/audience-vulnerability-minor-facing.md +37 -0
- package/dist/design/audit/rubric/fragments/first-principles.md +65 -0
- package/dist/design/audit/rubric/fragments/modality-mobile.md +39 -0
- package/dist/design/audit/rubric/fragments/modality-tablet.md +35 -0
- package/dist/design/audit/rubric/fragments/regulatory-coppa.md +32 -0
- package/dist/design/audit/rubric/fragments/regulatory-gdpr.md +33 -0
- package/dist/design/audit/rubric/fragments/regulatory-hipaa.md +36 -0
- package/dist/design/audit/rubric/loader.d.ts +26 -6
- package/dist/design/audit/rubric/loader.d.ts.map +1 -1
- package/dist/design/audit/rubric/loader.js +45 -26
- package/dist/design/audit/rubric/loader.js.map +1 -1
- package/dist/design/audit/rubric/rollup-weights.d.ts +25 -0
- package/dist/design/audit/rubric/rollup-weights.d.ts.map +1 -0
- package/dist/design/audit/rubric/rollup-weights.js +51 -0
- package/dist/design/audit/rubric/rollup-weights.js.map +1 -0
- package/dist/design/audit/types.d.ts +28 -0
- package/dist/design/audit/types.d.ts.map +1 -1
- package/dist/design/audit/v2/build-result.d.ts +47 -0
- package/dist/design/audit/v2/build-result.d.ts.map +1 -0
- package/dist/design/audit/v2/build-result.js +163 -0
- package/dist/design/audit/v2/build-result.js.map +1 -0
- package/dist/design/audit/v2/score.d.ts +49 -0
- package/dist/design/audit/v2/score.d.ts.map +1 -0
- package/dist/design/audit/v2/score.js +211 -0
- package/dist/design/audit/v2/score.js.map +1 -0
- package/dist/design/audit/v2/types.d.ts +431 -0
- package/dist/design/audit/v2/types.d.ts.map +1 -0
- package/dist/design/audit/v2/types.js +26 -0
- package/dist/design/audit/v2/types.js.map +1 -0
- package/dist/discover/index.d.ts +16 -0
- package/dist/discover/index.d.ts.map +1 -0
- package/dist/discover/index.js +25 -0
- package/dist/discover/index.js.map +1 -0
- package/dist/discover/wayback.d.ts +49 -0
- package/dist/discover/wayback.d.ts.map +1 -0
- package/dist/discover/wayback.js +123 -0
- package/dist/discover/wayback.js.map +1 -0
- package/dist/jobs/anti-bot.d.ts +19 -0
- package/dist/jobs/anti-bot.d.ts.map +1 -0
- package/dist/jobs/anti-bot.js +64 -0
- package/dist/jobs/anti-bot.js.map +1 -0
- package/dist/jobs/cost-estimate.d.ts +12 -0
- package/dist/jobs/cost-estimate.d.ts.map +1 -0
- package/dist/jobs/cost-estimate.js +21 -0
- package/dist/jobs/cost-estimate.js.map +1 -0
- package/dist/jobs/cost-history.d.ts +19 -0
- package/dist/jobs/cost-history.d.ts.map +1 -0
- package/dist/jobs/cost-history.js +42 -0
- package/dist/jobs/cost-history.js.map +1 -0
- package/dist/jobs/index.d.ts +31 -0
- package/dist/jobs/index.d.ts.map +1 -0
- package/dist/jobs/index.js +37 -0
- package/dist/jobs/index.js.map +1 -0
- package/dist/jobs/orchestrator.d.ts +42 -0
- package/dist/jobs/orchestrator.d.ts.map +1 -0
- package/dist/jobs/orchestrator.js +282 -0
- package/dist/jobs/orchestrator.js.map +1 -0
- package/dist/jobs/queue.d.ts +45 -0
- package/dist/jobs/queue.d.ts.map +1 -0
- package/dist/jobs/queue.js +114 -0
- package/dist/jobs/queue.js.map +1 -0
- package/dist/jobs/retry.d.ts +36 -0
- package/dist/jobs/retry.d.ts.map +1 -0
- package/dist/jobs/retry.js +77 -0
- package/dist/jobs/retry.js.map +1 -0
- package/dist/jobs/store.d.ts +31 -0
- package/dist/jobs/store.d.ts.map +1 -0
- package/dist/jobs/store.js +92 -0
- package/dist/jobs/store.js.map +1 -0
- package/dist/jobs/types.d.ts +106 -0
- package/dist/jobs/types.d.ts.map +1 -0
- package/dist/jobs/types.js +13 -0
- package/dist/jobs/types.js.map +1 -0
- package/dist/reports/aggregate.d.ts +38 -0
- package/dist/reports/aggregate.d.ts.map +1 -0
- package/dist/reports/aggregate.js +145 -0
- package/dist/reports/aggregate.js.map +1 -0
- package/dist/reports/index.d.ts +21 -0
- package/dist/reports/index.d.ts.map +1 -0
- package/dist/reports/index.js +15 -0
- package/dist/reports/index.js.map +1 -0
- package/dist/reports/narrate.d.ts +19 -0
- package/dist/reports/narrate.d.ts.map +1 -0
- package/dist/reports/narrate.js +40 -0
- package/dist/reports/narrate.js.map +1 -0
- package/dist/reports/templates.d.ts +43 -0
- package/dist/reports/templates.d.ts.map +1 -0
- package/dist/reports/templates.js +200 -0
- package/dist/reports/templates.js.map +1 -0
- package/dist/reports/tokens.d.ts +77 -0
- package/dist/reports/tokens.d.ts.map +1 -0
- package/dist/reports/tokens.js +88 -0
- package/dist/reports/tokens.js.map +1 -0
- package/dist/reports/tools.d.ts +76 -0
- package/dist/reports/tools.d.ts.map +1 -0
- package/dist/reports/tools.js +205 -0
- package/dist/reports/tools.js.map +1 -0
- package/dist/reports/types.d.ts +51 -0
- package/dist/reports/types.d.ts.map +1 -0
- package/dist/reports/types.js +9 -0
- package/dist/reports/types.js.map +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Layer 4 — `bad design-audit ack-patch` subcommand handler.
|
|
3
|
+
*
|
|
4
|
+
* Invoked by coding agents after applying a patch:
|
|
5
|
+
* bad design-audit ack-patch <patchId> --pre-run-id <runId> [--applied-by <who>]
|
|
6
|
+
*
|
|
7
|
+
* When a re-audit is run with `--post-patch <patchId>`, the pipeline looks up
|
|
8
|
+
* the pending application and writes the observed outcome. This file handles
|
|
9
|
+
* the ack-patch side; the --post-patch flow lives in pipeline.ts.
|
|
10
|
+
*/
|
|
11
|
+
export interface AckPatchOptions {
|
|
12
|
+
patchId: string;
|
|
13
|
+
preRunId: string;
|
|
14
|
+
appliedBy?: string;
|
|
15
|
+
predictedDim?: string;
|
|
16
|
+
predictedDelta?: number;
|
|
17
|
+
patchBefore?: string;
|
|
18
|
+
patchAfter?: string;
|
|
19
|
+
patchScope?: string;
|
|
20
|
+
dir?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Record that a patch was applied. Returns the applicationId for correlation.
|
|
24
|
+
* The predicted delta is optional — when not provided, defaults to 'untested'.
|
|
25
|
+
*/
|
|
26
|
+
export declare function ackPatch(opts: AckPatchOptions): Promise<string>;
|
|
27
|
+
export interface PostPatchOptions {
|
|
28
|
+
patchId: string;
|
|
29
|
+
postRunId: string;
|
|
30
|
+
observedDim: string;
|
|
31
|
+
observedDelta: number;
|
|
32
|
+
dir?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Record the observed outcome after a re-audit. Looks up the pending
|
|
36
|
+
* application for `patchId` and appends an outcome event.
|
|
37
|
+
*/
|
|
38
|
+
export declare function recordPatchOutcome(opts: PostPatchOptions): Promise<void>;
|
|
39
|
+
//# sourceMappingURL=cli-ack-patch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-ack-patch.d.ts","sourceRoot":"","sources":["../src/cli-ack-patch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAYH,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED;;;GAGG;AACH,wBAAsB,QAAQ,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,CAsBrE;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,aAAa,EAAE,MAAM,CAAA;IACrB,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAe9E"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Layer 4 — `bad design-audit ack-patch` subcommand handler.
|
|
3
|
+
*
|
|
4
|
+
* Invoked by coding agents after applying a patch:
|
|
5
|
+
* bad design-audit ack-patch <patchId> --pre-run-id <runId> [--applied-by <who>]
|
|
6
|
+
*
|
|
7
|
+
* When a re-audit is run with `--post-patch <patchId>`, the pipeline looks up
|
|
8
|
+
* the pending application and writes the observed outcome. This file handles
|
|
9
|
+
* the ack-patch side; the --post-patch flow lives in pipeline.ts.
|
|
10
|
+
*/
|
|
11
|
+
import * as crypto from 'node:crypto';
|
|
12
|
+
import { appendPatchApplication, patchHash, findPendingApplication, updateApplicationOutcome, } from './design/audit/attribution/store.js';
|
|
13
|
+
/**
|
|
14
|
+
* Record that a patch was applied. Returns the applicationId for correlation.
|
|
15
|
+
* The predicted delta is optional — when not provided, defaults to 'untested'.
|
|
16
|
+
*/
|
|
17
|
+
export async function ackPatch(opts) {
|
|
18
|
+
const applicationId = crypto.randomUUID();
|
|
19
|
+
const hash = patchHash({ before: opts.patchBefore ?? '', after: opts.patchAfter ?? '' }, opts.patchScope ?? 'component');
|
|
20
|
+
const app = {
|
|
21
|
+
applicationId,
|
|
22
|
+
patchId: opts.patchId,
|
|
23
|
+
patchHash: hash,
|
|
24
|
+
appliedAt: new Date().toISOString(),
|
|
25
|
+
appliedBy: opts.appliedBy ?? 'agent:unknown',
|
|
26
|
+
preAuditRunId: opts.preRunId,
|
|
27
|
+
predicted: {
|
|
28
|
+
dim: (opts.predictedDim ?? 'product_intent'),
|
|
29
|
+
delta: opts.predictedDelta ?? 0,
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
await appendPatchApplication(app, opts.dir);
|
|
33
|
+
return applicationId;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Record the observed outcome after a re-audit. Looks up the pending
|
|
37
|
+
* application for `patchId` and appends an outcome event.
|
|
38
|
+
*/
|
|
39
|
+
export async function recordPatchOutcome(opts) {
|
|
40
|
+
const pending = await findPendingApplication(opts.patchId, opts.dir);
|
|
41
|
+
if (!pending) {
|
|
42
|
+
throw new Error(`No pending PatchApplication found for patchId ${opts.patchId}. ` +
|
|
43
|
+
'Run `bad design-audit ack-patch` after applying the patch, before re-auditing.');
|
|
44
|
+
}
|
|
45
|
+
await updateApplicationOutcome(pending.applicationId, opts.postRunId, { dim: opts.observedDim, delta: opts.observedDelta }, opts.dir);
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=cli-ack-patch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-ack-patch.js","sourceRoot":"","sources":["../src/cli-ack-patch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,O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BAAwB,CAC5B,OAAO,CAAC,aAAa,EACrB,IAAI,CAAC,SAAS,EACd,EAAE,GAAG,EAAE,IAAI,CAAC,WAAwB,EAAE,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,EACjE,IAAI,CAAC,GAAG,CACT,CAAA;AACH,CAAC"}
|
|
@@ -32,6 +32,18 @@ export interface DesignAuditOptions {
|
|
|
32
32
|
rubricsDir?: string;
|
|
33
33
|
/** Subjective LLM audit passes: standard, deep, max, number, or comma-list */
|
|
34
34
|
auditPasses?: string;
|
|
35
|
+
/** Bypass the ethics floor entirely. Audited + warned. Test-only. */
|
|
36
|
+
skipEthics?: boolean;
|
|
37
|
+
/** Override directory for ethics rule yaml files. */
|
|
38
|
+
ethicsRulesDir?: string;
|
|
39
|
+
/** Comma-separated audience tags: developer, clinician, kids, ... */
|
|
40
|
+
audience?: string;
|
|
41
|
+
/** Comma-separated regulatory contexts: hipaa, gdpr, coppa, ... */
|
|
42
|
+
regulatoryContext?: string;
|
|
43
|
+
/** Comma-separated audience-vulnerability tags: patient-facing, minor-facing, ... */
|
|
44
|
+
audienceVulnerability?: string;
|
|
45
|
+
/** Single modality: mobile, tablet, desktop, tv, kiosk */
|
|
46
|
+
modality?: string;
|
|
35
47
|
}
|
|
36
48
|
export declare function runDesignAudit(opts: DesignAuditOptions): Promise<void>;
|
|
37
49
|
export interface ExtractDesignTokensOptions {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-design-audit.d.ts","sourceRoot":"","sources":["../src/cli-design-audit.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,OAAO,KAAK,EAA4B,YAAY,EAA8L,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"cli-design-audit.d.ts","sourceRoot":"","sources":["../src/cli-design-audit.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,OAAO,KAAK,EAA4B,YAAY,EAA8L,MAAM,YAAY,CAAA;AA0RpQ,MAAM,WAAW,kBAAk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AM,WAAW,0BAA0B;IACzC,GAAG,EAAE,MAAM,CAAA;IACX,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IAClE,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;CACjK;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,YAAY,CAAA;IACpB,SAAS,EAAE,MAAM,CAAA;IACjB,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CACxC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,0BAA0B,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAsRrG"}
|
package/dist/cli-design-audit.js
CHANGED
|
@@ -15,6 +15,62 @@ import { resolveProviderApiKey, resolveProviderModelName } from './provider-defa
|
|
|
15
15
|
import { loadLocalEnvFiles } from './env-loader.js';
|
|
16
16
|
import { cliError } from './cli-ui.js';
|
|
17
17
|
import { auditOnePage } from './design/audit/pipeline.js';
|
|
18
|
+
/** Split "a, b , c" → ['a','b','c']. Returns undefined for empty input so the
|
|
19
|
+
* v2 predicate predicates can distinguish "operator did not say" from "[]". */
|
|
20
|
+
function parseTagList(input) {
|
|
21
|
+
if (!input)
|
|
22
|
+
return undefined;
|
|
23
|
+
const tags = input.split(',').map(s => s.trim()).filter(Boolean);
|
|
24
|
+
return tags.length > 0 ? tags : undefined;
|
|
25
|
+
}
|
|
26
|
+
/** Pretty-print the ethics-violation report for a set of pages. Prints
|
|
27
|
+
* nothing when no page tripped a rule. Each rule is shown with severity,
|
|
28
|
+
* remediation, and citation so the operator can act without re-running. */
|
|
29
|
+
function printEthicsViolations(pages) {
|
|
30
|
+
const offenders = pages.filter(p => (p.ethicsViolations?.length ?? 0) > 0);
|
|
31
|
+
if (offenders.length === 0)
|
|
32
|
+
return;
|
|
33
|
+
console.log('');
|
|
34
|
+
console.log(` ${chalk.bgRed.white.bold(' ETHICS VIOLATIONS ')}`);
|
|
35
|
+
for (const page of offenders) {
|
|
36
|
+
console.log(` ${chalk.dim('Page:')} ${page.url}`);
|
|
37
|
+
for (const v of page.ethicsViolations ?? []) {
|
|
38
|
+
const sevColor = v.severity === 'critical-floor' ? chalk.red : chalk.yellow;
|
|
39
|
+
console.log(` ${sevColor('•')} ${chalk.bold(v.ruleId)} ${chalk.dim('—')} ${sevColor(v.severity)} ${chalk.dim(`(rollup capped at ${v.rollupCap})`)}`);
|
|
40
|
+
console.log(` ${chalk.dim('fix:')} ${v.remediation}`);
|
|
41
|
+
if (v.citation)
|
|
42
|
+
console.log(` ${chalk.dim('cite:')} ${v.citation}`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/** Lowest rollup cap across all violated pages, or undefined if none fired. */
|
|
47
|
+
function lowestRollupCap(pages) {
|
|
48
|
+
const caps = pages.flatMap(p => p.ethicsViolations ?? []).map(v => v.rollupCap);
|
|
49
|
+
return caps.length === 0 ? undefined : Math.min(...caps);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Layer 1 — print the per-dimension breakdown for one page when an
|
|
53
|
+
* `auditResultV2` is attached. Five dim lines + one rollup line; each shows
|
|
54
|
+
* score, range, and confidence so an agent can reason about uncertainty.
|
|
55
|
+
*/
|
|
56
|
+
function printV2Breakdown(page) {
|
|
57
|
+
const v2 = page.auditResultV2;
|
|
58
|
+
if (!v2 || !v2.scores || !v2.rollup)
|
|
59
|
+
return;
|
|
60
|
+
const dimOrder = ['product_intent', 'visual_craft', 'trust_clarity', 'workflow', 'content_ia'];
|
|
61
|
+
for (const dim of dimOrder) {
|
|
62
|
+
const s = v2.scores[dim];
|
|
63
|
+
if (!s)
|
|
64
|
+
continue;
|
|
65
|
+
const sevColor = s.score >= 8 ? chalk.green : s.score >= 5 ? chalk.yellow : chalk.red;
|
|
66
|
+
const confColor = s.confidence === 'high' ? chalk.green : s.confidence === 'medium' ? chalk.yellow : chalk.dim;
|
|
67
|
+
console.log(` ${chalk.dim(dim.padEnd(15))} ${sevColor(`${s.score}/10`)} ${chalk.dim(`[${s.range[0]}-${s.range[1]}]`)} ${confColor(s.confidence)}`);
|
|
68
|
+
}
|
|
69
|
+
const r = v2.rollup;
|
|
70
|
+
const rColor = r.score >= 8 ? chalk.green : r.score >= 5 ? chalk.yellow : chalk.red;
|
|
71
|
+
const confColor = r.confidence === 'high' ? chalk.green : r.confidence === 'medium' ? chalk.yellow : chalk.dim;
|
|
72
|
+
console.log(` ${chalk.dim('rollup'.padEnd(15))} ${rColor(`${r.score.toFixed(1)}/10`)} ${chalk.dim(`[${r.range[0].toFixed(1)}-${r.range[1].toFixed(1)}]`)} ${confColor(r.confidence)} ${chalk.dim(r.rule)}`);
|
|
73
|
+
}
|
|
18
74
|
import { resolveAuditPasses } from './design/audit/evaluate.js';
|
|
19
75
|
import { detectSystemicFindings, topByRoi } from './design/audit/roi.js';
|
|
20
76
|
import { getTelemetry, setInvocation } from './telemetry/index.js';
|
|
@@ -198,6 +254,18 @@ export async function runDesignAudit(opts) {
|
|
|
198
254
|
const modelName = resolveProviderModelName(provider, opts.model);
|
|
199
255
|
const apiKey = opts.apiKey ?? resolveProviderApiKey(provider);
|
|
200
256
|
const auditPasses = resolveAuditPasses(opts.auditPasses);
|
|
257
|
+
// Layer 7 — ethics gate options. Threaded into every auditOnePage call site.
|
|
258
|
+
if (opts.skipEthics) {
|
|
259
|
+
console.warn(` ${chalk.yellow('⚠')} ${chalk.bold('--skip-ethics')} ${chalk.dim('— ethics floor disabled (test-only)')}`);
|
|
260
|
+
}
|
|
261
|
+
const ethicsCommonOpts = {
|
|
262
|
+
skipEthics: opts.skipEthics,
|
|
263
|
+
ethicsRulesDir: opts.ethicsRulesDir,
|
|
264
|
+
audience: parseTagList(opts.audience),
|
|
265
|
+
regulatoryContext: parseTagList(opts.regulatoryContext),
|
|
266
|
+
audienceVulnerability: parseTagList(opts.audienceVulnerability),
|
|
267
|
+
modality: parseTagList(opts.modality),
|
|
268
|
+
};
|
|
201
269
|
// Telemetry: every design-audit invocation gets a stable runId. Children
|
|
202
270
|
// (per-page, evolve rounds) link back via parentRunId so a fleet rollup can
|
|
203
271
|
// reconstruct the tree.
|
|
@@ -266,6 +334,7 @@ export async function runDesignAudit(opts) {
|
|
|
266
334
|
runId,
|
|
267
335
|
provider,
|
|
268
336
|
model: modelName,
|
|
337
|
+
...ethicsCommonOpts,
|
|
269
338
|
});
|
|
270
339
|
const result = gen2;
|
|
271
340
|
results.push(result);
|
|
@@ -276,6 +345,7 @@ export async function runDesignAudit(opts) {
|
|
|
276
345
|
? chalk.dim(` (${result.classification.type}/${result.classification.domain})`)
|
|
277
346
|
: '';
|
|
278
347
|
console.log(` ${icon} ${scoreColor(`${result.score}/10`)} ${chalk.dim('—')} ${findingCount} finding${findingCount !== 1 ? 's' : ''}${classLabel}`);
|
|
348
|
+
printV2Breakdown(result);
|
|
279
349
|
}
|
|
280
350
|
// Cross-page systemic detection + top-fixes ranking.
|
|
281
351
|
// Findings appearing on 2+ pages collapse into a single systemic finding.
|
|
@@ -297,16 +367,29 @@ export async function runDesignAudit(opts) {
|
|
|
297
367
|
const minor = allFindings.filter(f => f.severity === 'minor').length;
|
|
298
368
|
if (opts.json) {
|
|
299
369
|
const jsonPath = path.join(outputDir, 'report.json');
|
|
370
|
+
// Layer 1 — emit BOTH schemaVersion 1 (legacy) and schemaVersion 2 (new)
|
|
371
|
+
// shapes for one release. Consumers can migrate to v2 incrementally.
|
|
372
|
+
const v2Pages = results
|
|
373
|
+
.map(r => r.auditResultV2)
|
|
374
|
+
.filter((r) => r !== undefined);
|
|
300
375
|
fs.writeFileSync(jsonPath, JSON.stringify({
|
|
376
|
+
schemaVersion: 1,
|
|
301
377
|
timestamp: new Date().toISOString(),
|
|
302
378
|
profile,
|
|
303
379
|
url: opts.url,
|
|
304
380
|
pages: results,
|
|
305
381
|
topFixes,
|
|
306
382
|
summary: { avgScore, totalFindings: allFindings.length, critical, major, minor },
|
|
383
|
+
v2: {
|
|
384
|
+
schemaVersion: 2,
|
|
385
|
+
pages: v2Pages,
|
|
386
|
+
},
|
|
307
387
|
}, null, 2));
|
|
308
388
|
console.log(` ${chalk.dim('JSON →')} ${jsonPath}`);
|
|
309
389
|
}
|
|
390
|
+
// ── Layer 7 — surface ethics violations BEFORE the score summary so the
|
|
391
|
+
// operator sees the floor reason, not just the capped number. ──
|
|
392
|
+
printEthicsViolations(results);
|
|
310
393
|
// Summary
|
|
311
394
|
console.log('');
|
|
312
395
|
console.log(` ${chalk.dim('─'.repeat(52))}`);
|
|
@@ -319,6 +402,10 @@ export async function runDesignAudit(opts) {
|
|
|
319
402
|
if (minor > 0)
|
|
320
403
|
findingParts.push(chalk.dim(`${minor} minor`));
|
|
321
404
|
console.log(` Avg: ${avgColor(`${avgScore.toFixed(1)}/10`)} ${chalk.dim('·')} ${allFindings.length} findings ${findingParts.length ? chalk.dim('(') + findingParts.join(chalk.dim(' · ')) + chalk.dim(')') : ''}`);
|
|
405
|
+
const lowestCap = lowestRollupCap(results);
|
|
406
|
+
if (lowestCap !== undefined) {
|
|
407
|
+
console.log(` ${chalk.red('⚠ Rollup capped at')} ${chalk.bold(`${lowestCap}/10`)} ${chalk.dim('— resolve ethics violations to lift the cap')}`);
|
|
408
|
+
}
|
|
322
409
|
console.log(` ${chalk.dim('Report →')} ${reportPath}`);
|
|
323
410
|
if (screenshotDir)
|
|
324
411
|
console.log(` ${chalk.dim('Screenshots →')} ${screenshotDir}`);
|
|
@@ -342,6 +429,7 @@ export async function runDesignAudit(opts) {
|
|
|
342
429
|
provider,
|
|
343
430
|
model: modelName,
|
|
344
431
|
parentRunId: runId,
|
|
432
|
+
...ethicsCommonOpts,
|
|
345
433
|
});
|
|
346
434
|
repResults.push(gen2);
|
|
347
435
|
}
|