@aayambansal/squint 0.5.1 → 0.5.2
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/{App-KTNAMHY6.js → App-QTB6FIJM.js} +5 -5
- package/dist/{cdp-D2F4P7UQ.js → cdp-FKFCV2B5.js} +1 -1
- package/dist/{chunk-VJ2QKHYK.js → chunk-3GHZOVAA.js} +1 -1
- package/dist/{chunk-4XSHHGA6.js → chunk-DRMVCSUG.js} +38 -1
- package/dist/{chunk-ERF2SPUW.js → chunk-HSQ7XLD2.js} +8 -7
- package/dist/{chunk-2NYNTVMX.js → chunk-LBQDTQ5A.js} +2 -2
- package/dist/{chunk-AMA3F2Y2.js → chunk-NCEEMDD6.js} +1 -1
- package/dist/{chunk-G5NS2IFQ.js → chunk-W5ZGF5JQ.js} +21 -5
- package/dist/{chunk-3YCG234A.js → chunk-YRANCWY6.js} +1 -1
- package/dist/cli.js +20 -15
- package/dist/{commands-WC7V6EAE.js → commands-RVCKIMNV.js} +1 -1
- package/dist/flows-OAQYGH77.js +13 -0
- package/dist/{preview-JN5PTWLX.js → preview-XWPCSQFT.js} +2 -2
- package/dist/receipts-Z55AHONO.js +60 -0
- package/dist/{remote-UOV4ZXWU.js → remote-QNRB5APU.js} +4 -4
- package/dist/{server-2WPGU3KQ.js → server-AROYCMDF.js} +4 -4
- package/package.json +1 -1
- package/dist/flows-MXJL45HW.js +0 -11
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
App
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-LBQDTQ5A.js";
|
|
5
|
+
import "./chunk-3GHZOVAA.js";
|
|
6
|
+
import "./chunk-W5ZGF5JQ.js";
|
|
7
7
|
import "./chunk-UBADCBPT.js";
|
|
8
8
|
import "./chunk-IEQGTVWN.js";
|
|
9
9
|
import "./chunk-AUJJGMZG.js";
|
|
@@ -14,9 +14,9 @@ import "./chunk-6NPUVPQD.js";
|
|
|
14
14
|
import "./chunk-K5QJMSJH.js";
|
|
15
15
|
import "./chunk-WAJXATCO.js";
|
|
16
16
|
import "./chunk-62JNF5M2.js";
|
|
17
|
-
import "./chunk-
|
|
17
|
+
import "./chunk-HSQ7XLD2.js";
|
|
18
18
|
import "./chunk-7CAGWFAQ.js";
|
|
19
|
-
import "./chunk-
|
|
19
|
+
import "./chunk-YRANCWY6.js";
|
|
20
20
|
import "./chunk-PYC53J7D.js";
|
|
21
21
|
import "./chunk-GV2HAALP.js";
|
|
22
22
|
export {
|
|
@@ -15,7 +15,7 @@ var COMMANDS = [
|
|
|
15
15
|
{ name: "review", args: "[focus]", group: "verify", description: "screenshots + the engine critiques its own rendered work" },
|
|
16
16
|
{ name: "polish", args: "[1-5]", group: "verify", description: "unattended rounds of review \u2192 fix (default 2)" },
|
|
17
17
|
{ name: "score", group: "verify", description: "deterministic quality snapshot (problems, a11y, tells, runtime, LCP)" },
|
|
18
|
-
{ name: "flows", args: "[name]", group: "verify", description: "replay declared
|
|
18
|
+
{ name: "flows", args: "[name]", group: "verify", description: "replay declared journeys; /flows suggest drafts them from live routes" },
|
|
19
19
|
{ name: "variants", args: "<2-4> <ask>", group: "explore", description: "parallel design explorations; apply/list/clean" },
|
|
20
20
|
{ name: "sandbox", args: "[on|diff|apply|discard]", group: "explore", description: "asks accumulate in a shadow worktree until you apply" },
|
|
21
21
|
{ name: "undo", group: "explore", description: "revert the last ask (files only)" },
|
|
@@ -140,9 +140,46 @@ function stepExpression(step) {
|
|
|
140
140
|
return null;
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
|
+
async function suggestFlows(cwd, baseUrl, chromePath) {
|
|
144
|
+
const fs2 = await import("fs");
|
|
145
|
+
const path2 = await import("path");
|
|
146
|
+
const { cdpCapture } = await import("./cdp-FKFCV2B5.js");
|
|
147
|
+
const { loadRoutes } = await import("./preview-XWPCSQFT.js");
|
|
148
|
+
const dir = path2.join(cwd, ".squint", "flows");
|
|
149
|
+
fs2.mkdirSync(dir, { recursive: true });
|
|
150
|
+
const created = [];
|
|
151
|
+
const skipped = [];
|
|
152
|
+
for (const route of loadRoutes(cwd)) {
|
|
153
|
+
const slug = route === "/" ? "home" : route.replace(/^\//, "").replace(/[^a-z0-9]+/gi, "-").toLowerCase();
|
|
154
|
+
const file = path2.join(dir, `${slug}.flow`);
|
|
155
|
+
if (fs2.existsSync(file)) {
|
|
156
|
+
skipped.push(slug);
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
const url = new URL(route, baseUrl).toString();
|
|
160
|
+
const shotDir = fs2.mkdtempSync(path2.join((await import("os")).tmpdir(), "squint-suggest-"));
|
|
161
|
+
let heading = null;
|
|
162
|
+
try {
|
|
163
|
+
const capture = await cdpCapture(chromePath, url, shotDir, [], 1200, true);
|
|
164
|
+
const match = capture.narration.map((n) => /^heading \d: "(.+)"$/.exec(n)).find(Boolean);
|
|
165
|
+
heading = match?.[1] ?? null;
|
|
166
|
+
} catch {
|
|
167
|
+
} finally {
|
|
168
|
+
fs2.rmSync(shotDir, { recursive: true, force: true });
|
|
169
|
+
}
|
|
170
|
+
const lines = [`goto ${route}`];
|
|
171
|
+
if (heading) lines.push(`expect ${heading}`);
|
|
172
|
+
lines.push(`shot ${slug}`);
|
|
173
|
+
fs2.writeFileSync(file, `${lines.join("\n")}
|
|
174
|
+
`);
|
|
175
|
+
created.push(slug);
|
|
176
|
+
}
|
|
177
|
+
return { created, skipped };
|
|
178
|
+
}
|
|
143
179
|
|
|
144
180
|
export {
|
|
145
181
|
parseFlow,
|
|
146
182
|
loadFlows,
|
|
147
|
-
stepExpression
|
|
183
|
+
stepExpression,
|
|
184
|
+
suggestFlows
|
|
148
185
|
};
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
cdpCapture,
|
|
7
7
|
hasWebSocket
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-YRANCWY6.js";
|
|
9
9
|
import {
|
|
10
10
|
findChrome,
|
|
11
11
|
screenshot
|
|
@@ -21,7 +21,7 @@ import fs from "fs";
|
|
|
21
21
|
import path from "path";
|
|
22
22
|
var MAX_CHECKS = 20;
|
|
23
23
|
var MAX_BYTES = 1e4;
|
|
24
|
-
function loadChecks(cwd) {
|
|
24
|
+
function loadChecks(cwd, context = "audit") {
|
|
25
25
|
const dir = path.join(cwd, ".squint", "checks");
|
|
26
26
|
let entries;
|
|
27
27
|
try {
|
|
@@ -34,11 +34,12 @@ function loadChecks(cwd) {
|
|
|
34
34
|
try {
|
|
35
35
|
const source = fs.readFileSync(path.join(dir, entry), "utf8");
|
|
36
36
|
if (source.trim().length === 0 || Buffer.byteLength(source) > MAX_BYTES) continue;
|
|
37
|
-
|
|
37
|
+
const pragma = /^\s*\/\/\s*squint-trigger:\s*(turn|audit)/.exec(source);
|
|
38
|
+
checks.push({ name: entry.replace(/\.js$/, ""), source, trigger: pragma?.[1] === "audit" ? "audit" : "turn" });
|
|
38
39
|
} catch {
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
|
-
return checks;
|
|
42
|
+
return context === "audit" ? checks : checks.filter((c) => c.trigger === "turn");
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
// src/preview/preview.ts
|
|
@@ -153,7 +154,7 @@ async function probeRuntime(url, cwd) {
|
|
|
153
154
|
cwd ? [{ name: "pulse", width: 1280, height: 800 }] : [],
|
|
154
155
|
1500,
|
|
155
156
|
false,
|
|
156
|
-
cwd ? loadChecks(cwd) : []
|
|
157
|
+
cwd ? loadChecks(cwd, "turn") : []
|
|
157
158
|
);
|
|
158
159
|
return { report, pulsePath: shots[0]?.path, perf, checkFailures };
|
|
159
160
|
} catch {
|
|
@@ -163,13 +164,13 @@ async function probeRuntime(url, cwd) {
|
|
|
163
164
|
async function comparePulse(previous, current) {
|
|
164
165
|
const chrome = findChrome();
|
|
165
166
|
if (!chrome || !hasWebSocket()) return null;
|
|
166
|
-
const { pixelDiffPct } = await import("./cdp-
|
|
167
|
+
const { pixelDiffPct } = await import("./cdp-FKFCV2B5.js");
|
|
167
168
|
return pixelDiffPct(chrome, previous, current);
|
|
168
169
|
}
|
|
169
170
|
async function comparePulseAttributed(previous, current, url) {
|
|
170
171
|
const chrome = findChrome();
|
|
171
172
|
if (!chrome || !hasWebSocket()) return null;
|
|
172
|
-
const { pixelDiffAttributed } = await import("./cdp-
|
|
173
|
+
const { pixelDiffAttributed } = await import("./cdp-FKFCV2B5.js");
|
|
173
174
|
return pixelDiffAttributed(chrome, previous, current, url);
|
|
174
175
|
}
|
|
175
176
|
function buildRuntimeFixPrompt(report) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
completeCommand
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-3GHZOVAA.js";
|
|
5
5
|
import {
|
|
6
6
|
Session
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-W5ZGF5JQ.js";
|
|
8
8
|
|
|
9
9
|
// src/tui/App.tsx
|
|
10
10
|
import { Box as Box3, Static, Text as Text3, useApp, useInput } from "ink";
|
|
@@ -51,7 +51,7 @@ import {
|
|
|
51
51
|
comparePulseAttributed,
|
|
52
52
|
probeRuntime,
|
|
53
53
|
runtimeSummary
|
|
54
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-HSQ7XLD2.js";
|
|
55
55
|
import {
|
|
56
56
|
clearState,
|
|
57
57
|
loadState,
|
|
@@ -1122,8 +1122,24 @@ every ask now carries it; auto-fix presses to ${MAX_GOAL_FIX_ATTEMPTS} attempts
|
|
|
1122
1122
|
this.push("error", "dev server not running \u2014 /dev first");
|
|
1123
1123
|
break;
|
|
1124
1124
|
}
|
|
1125
|
+
if (arg.trim() === "suggest") {
|
|
1126
|
+
void (async () => {
|
|
1127
|
+
const chrome = findChrome();
|
|
1128
|
+
if (!chrome) {
|
|
1129
|
+
this.push("error", "no Chrome/Chromium found");
|
|
1130
|
+
return;
|
|
1131
|
+
}
|
|
1132
|
+
const { suggestFlows } = await import("./flows-OAQYGH77.js");
|
|
1133
|
+
this.push("status", "drafting flows from the live routes\u2026");
|
|
1134
|
+
const { created, skipped } = await suggestFlows(this.opts.cwd, this.state.devUrl, chrome);
|
|
1135
|
+
if (created.length > 0) this.push("status", `drafted ${created.length} flow(s): ${created.join(", ")} \u2014 edit .squint/flows/*.flow or ask the engine to deepen them`);
|
|
1136
|
+
if (skipped.length > 0) this.push("status", `kept existing: ${skipped.join(", ")}`);
|
|
1137
|
+
if (created.length === 0 && skipped.length === 0) this.push("status", "no routes to draft from \u2014 add .squint/routes");
|
|
1138
|
+
})();
|
|
1139
|
+
break;
|
|
1140
|
+
}
|
|
1125
1141
|
void (async () => {
|
|
1126
|
-
const { loadFlows } = await import("./flows-
|
|
1142
|
+
const { loadFlows } = await import("./flows-OAQYGH77.js");
|
|
1127
1143
|
const flows = loadFlows(this.opts.cwd);
|
|
1128
1144
|
if (flows.length === 0) {
|
|
1129
1145
|
this.push("status", "no flows \u2014 add .squint/flows/<name>.flow (goto/click/fill/press/expect/shot lines), or ask the engine to write one");
|
|
@@ -1134,8 +1150,8 @@ every ask now carries it; auto-fix presses to ${MAX_GOAL_FIX_ATTEMPTS} attempts
|
|
|
1134
1150
|
this.push("error", "no Chrome/Chromium found for flows");
|
|
1135
1151
|
return;
|
|
1136
1152
|
}
|
|
1137
|
-
const { runFlow } = await import("./cdp-
|
|
1138
|
-
const { previewDir } = await import("./preview-
|
|
1153
|
+
const { runFlow } = await import("./cdp-FKFCV2B5.js");
|
|
1154
|
+
const { previewDir } = await import("./preview-XWPCSQFT.js");
|
|
1139
1155
|
this.push("status", `replaying ${flows.length} flow(s)\u2026`);
|
|
1140
1156
|
this.notify({ running: true, runStartedAt: Date.now() });
|
|
1141
1157
|
const failures = [];
|
|
@@ -1459,7 +1475,7 @@ ${sandboxFiles(this.opts.cwd).join("\n")}`);
|
|
|
1459
1475
|
this.notify({ items: [], totals: { costUsd: 0, turns: 0 } });
|
|
1460
1476
|
break;
|
|
1461
1477
|
case "help": {
|
|
1462
|
-
void import("./commands-
|
|
1478
|
+
void import("./commands-RVCKIMNV.js").then(({ commandHelp }) => this.push("status", commandHelp()));
|
|
1463
1479
|
break;
|
|
1464
1480
|
}
|
|
1465
1481
|
case "quit":
|
|
@@ -179,7 +179,7 @@ var describe = (value) => {
|
|
|
179
179
|
return String(value);
|
|
180
180
|
};
|
|
181
181
|
async function runFlow(chromePath, baseUrl, flow, outDir) {
|
|
182
|
-
const { stepExpression } = await import("./flows-
|
|
182
|
+
const { stepExpression } = await import("./flows-OAQYGH77.js");
|
|
183
183
|
const { child, wsUrl, profileDir } = await launchChrome(chromePath);
|
|
184
184
|
const shots = [];
|
|
185
185
|
let connection = null;
|
package/dist/cli.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
App
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-LBQDTQ5A.js";
|
|
5
|
+
import "./chunk-3GHZOVAA.js";
|
|
6
6
|
import {
|
|
7
7
|
connectDaemon,
|
|
8
8
|
socketPath,
|
|
9
9
|
startDaemon
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import "./chunk-
|
|
10
|
+
} from "./chunk-NCEEMDD6.js";
|
|
11
|
+
import "./chunk-W5ZGF5JQ.js";
|
|
12
12
|
import "./chunk-UBADCBPT.js";
|
|
13
13
|
import "./chunk-IEQGTVWN.js";
|
|
14
14
|
import "./chunk-AUJJGMZG.js";
|
|
@@ -23,9 +23,9 @@ import {
|
|
|
23
23
|
composePrompt
|
|
24
24
|
} from "./chunk-WAJXATCO.js";
|
|
25
25
|
import "./chunk-62JNF5M2.js";
|
|
26
|
-
import "./chunk-
|
|
26
|
+
import "./chunk-HSQ7XLD2.js";
|
|
27
27
|
import "./chunk-7CAGWFAQ.js";
|
|
28
|
-
import "./chunk-
|
|
28
|
+
import "./chunk-YRANCWY6.js";
|
|
29
29
|
import "./chunk-PYC53J7D.js";
|
|
30
30
|
import {
|
|
31
31
|
detectEngines,
|
|
@@ -187,18 +187,18 @@ function registerDaemon(program2) {
|
|
|
187
187
|
process.on("SIGTERM", stop);
|
|
188
188
|
});
|
|
189
189
|
program2.command("mcp").description("serve the gates as MCP tools over stdio (check, shot, flows, context)").action(async () => {
|
|
190
|
-
const { runMcpServer } = await import("./server-
|
|
190
|
+
const { runMcpServer } = await import("./server-AROYCMDF.js");
|
|
191
191
|
runMcpServer(process.cwd());
|
|
192
192
|
});
|
|
193
193
|
program2.command("attach").description("attach this terminal to a running squint daemon (full TUI; --plain for line mode)").option("--plain", "line-mode attach instead of the full TUI").action(async (opts) => {
|
|
194
194
|
const cwd = process.cwd();
|
|
195
195
|
if (!opts.plain) {
|
|
196
196
|
try {
|
|
197
|
-
const { RemoteSession } = await import("./remote-
|
|
197
|
+
const { RemoteSession } = await import("./remote-QNRB5APU.js");
|
|
198
198
|
const remote = await RemoteSession.connect(cwd);
|
|
199
199
|
const config = loadConfig(defaultPaths(cwd));
|
|
200
200
|
const { render: render2 } = await import("ink");
|
|
201
|
-
const { App: App2 } = await import("./App-
|
|
201
|
+
const { App: App2 } = await import("./App-QTB6FIJM.js");
|
|
202
202
|
const React = await import("react");
|
|
203
203
|
render2(
|
|
204
204
|
React.createElement(App2, {
|
|
@@ -315,7 +315,7 @@ function registerEnv(program2) {
|
|
|
315
315
|
}
|
|
316
316
|
}
|
|
317
317
|
const { findChrome } = await import("./chrome-EEXJCG6W.js");
|
|
318
|
-
const { hasWebSocket } = await import("./cdp-
|
|
318
|
+
const { hasWebSocket } = await import("./cdp-FKFCV2B5.js");
|
|
319
319
|
const chrome = findChrome();
|
|
320
320
|
console.log(
|
|
321
321
|
chrome ? `${pc3.green("\u2713")} Chrome ${pc3.dim(chrome)}` : `${pc3.yellow("\u25CB")} Chrome ${pc3.dim("\u2014 screenshots and runtime probing disabled")}`
|
|
@@ -551,7 +551,7 @@ function registerQuality(program2) {
|
|
|
551
551
|
report.gates = gateResults.map((r) => ({ id: r.gate.id, ok: r.ok, durationMs: r.durationMs, outputTail: r.ok ? void 0 : r.outputTail }));
|
|
552
552
|
if (gateResults.some((r) => !r.ok)) failed = true;
|
|
553
553
|
if (opts.url) {
|
|
554
|
-
const { captureViewports, runtimeSummary, previewDir } = await import("./preview-
|
|
554
|
+
const { captureViewports, runtimeSummary, previewDir } = await import("./preview-XWPCSQFT.js");
|
|
555
555
|
const capture = await captureViewports(cwd, opts.url);
|
|
556
556
|
if (!capture) {
|
|
557
557
|
console.log(pc5.red("\u2717 audit: capture failed (Chrome missing or URL unreachable)"));
|
|
@@ -583,14 +583,14 @@ function registerQuality(program2) {
|
|
|
583
583
|
console.log(`${pc5.green("\u2713")} audit ${pc5.dim(`(${advisories.a11y.length} a11y, ${advisories.slop.length} slop, ${advisories.jank.length} jank advisories)`)}`);
|
|
584
584
|
}
|
|
585
585
|
}
|
|
586
|
-
const { loadFlows } = await import("./flows-
|
|
586
|
+
const { loadFlows } = await import("./flows-OAQYGH77.js");
|
|
587
587
|
const flows = loadFlows(cwd);
|
|
588
588
|
if (flows.length > 0) {
|
|
589
589
|
const { findChrome } = await import("./chrome-EEXJCG6W.js");
|
|
590
590
|
const chrome = findChrome();
|
|
591
591
|
const flowReport = [];
|
|
592
592
|
if (chrome) {
|
|
593
|
-
const { runFlow } = await import("./cdp-
|
|
593
|
+
const { runFlow } = await import("./cdp-FKFCV2B5.js");
|
|
594
594
|
for (const flow of flows) {
|
|
595
595
|
const result = await runFlow(chrome, opts.url, flow, previewDir(cwd));
|
|
596
596
|
flowReport.push({ name: flow.name, ok: result.ok, detail: result.ok ? void 0 : `step ${result.failedStep}: ${result.detail}` });
|
|
@@ -603,6 +603,11 @@ function registerQuality(program2) {
|
|
|
603
603
|
}
|
|
604
604
|
report.ok = !failed;
|
|
605
605
|
report.finishedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
606
|
+
try {
|
|
607
|
+
const { writeReceipt } = await import("./receipts-Z55AHONO.js");
|
|
608
|
+
console.log(pc5.dim(`receipt \u2192 ${writeReceipt(cwd, report)}`));
|
|
609
|
+
} catch {
|
|
610
|
+
}
|
|
606
611
|
if (opts.json) {
|
|
607
612
|
const fs2 = await import("fs");
|
|
608
613
|
fs2.writeFileSync(opts.json, JSON.stringify(report, null, 2));
|
|
@@ -611,7 +616,7 @@ function registerQuality(program2) {
|
|
|
611
616
|
if (failed) process.exitCode = 1;
|
|
612
617
|
});
|
|
613
618
|
program2.command("shot").description("Screenshot a running app at mobile/tablet/desktop viewports (+ .squint/routes)").argument("<url>", "URL of the running app (e.g. http://localhost:5173)").action(async (url) => {
|
|
614
|
-
const { captureViewports } = await import("./preview-
|
|
619
|
+
const { captureViewports } = await import("./preview-XWPCSQFT.js");
|
|
615
620
|
const result = await captureViewports(process.cwd(), url);
|
|
616
621
|
if (!result) {
|
|
617
622
|
console.error(pc5.red("\u2717 no Chrome/Chromium found"));
|
|
@@ -798,7 +803,7 @@ function registerTui(program2) {
|
|
|
798
803
|
}
|
|
799
804
|
|
|
800
805
|
// src/cli.tsx
|
|
801
|
-
var VERSION = true ? "0.5.
|
|
806
|
+
var VERSION = true ? "0.5.2" : "0.0.0-dev";
|
|
802
807
|
var program = new Command();
|
|
803
808
|
program.name("squint").description("Lovable for your terminal \u2014 a frontend harness on top of Claude Code, Codex, and friends.").version(VERSION);
|
|
804
809
|
registerRun(program);
|
|
@@ -11,9 +11,9 @@ import {
|
|
|
11
11
|
probeRuntime,
|
|
12
12
|
routeShotName,
|
|
13
13
|
runtimeSummary
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-HSQ7XLD2.js";
|
|
15
15
|
import "./chunk-7CAGWFAQ.js";
|
|
16
|
-
import "./chunk-
|
|
16
|
+
import "./chunk-YRANCWY6.js";
|
|
17
17
|
import "./chunk-PYC53J7D.js";
|
|
18
18
|
import "./chunk-GV2HAALP.js";
|
|
19
19
|
export {
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/quality/receipts.ts
|
|
4
|
+
import { execFileSync } from "child_process";
|
|
5
|
+
import crypto from "crypto";
|
|
6
|
+
import fs from "fs";
|
|
7
|
+
import path from "path";
|
|
8
|
+
function sha256(data) {
|
|
9
|
+
return crypto.createHash("sha256").update(data).digest("hex");
|
|
10
|
+
}
|
|
11
|
+
function canonical(value) {
|
|
12
|
+
if (Array.isArray(value)) return `[${value.map(canonical).join(",")}]`;
|
|
13
|
+
if (value && typeof value === "object") {
|
|
14
|
+
const entries = Object.entries(value).filter(([, v]) => v !== void 0).sort(([a], [b]) => a < b ? -1 : 1);
|
|
15
|
+
return `{${entries.map(([k, v]) => `${JSON.stringify(k)}:${canonical(v)}`).join(",")}}`;
|
|
16
|
+
}
|
|
17
|
+
return JSON.stringify(value);
|
|
18
|
+
}
|
|
19
|
+
function buildReceipt(cwd, report) {
|
|
20
|
+
let gitHead = null;
|
|
21
|
+
try {
|
|
22
|
+
gitHead = execFileSync("git", ["rev-parse", "HEAD"], { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }).trim();
|
|
23
|
+
} catch {
|
|
24
|
+
}
|
|
25
|
+
const screenshots = {};
|
|
26
|
+
const shots = report.audit?.shots ?? [];
|
|
27
|
+
for (const shot of shots) {
|
|
28
|
+
try {
|
|
29
|
+
screenshots[path.basename(shot)] = sha256(fs.readFileSync(shot));
|
|
30
|
+
} catch {
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
const unsigned = {
|
|
34
|
+
version: true ? "0.5.2" : "0.0.0-dev",
|
|
35
|
+
node: process.version,
|
|
36
|
+
gitHead,
|
|
37
|
+
report,
|
|
38
|
+
screenshots
|
|
39
|
+
};
|
|
40
|
+
return { ...unsigned, digest: sha256(canonical(unsigned)) };
|
|
41
|
+
}
|
|
42
|
+
function verifyReceipt(receipt) {
|
|
43
|
+
const { digest, ...unsigned } = receipt;
|
|
44
|
+
return sha256(canonical(unsigned)) === digest;
|
|
45
|
+
}
|
|
46
|
+
function writeReceipt(cwd, report) {
|
|
47
|
+
const receipt = buildReceipt(cwd, report);
|
|
48
|
+
const dir = path.join(cwd, ".squint", "receipts");
|
|
49
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
50
|
+
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
51
|
+
const file = path.join(dir, `${stamp}${receipt.report.ok ? "" : "-failed"}.json`);
|
|
52
|
+
fs.writeFileSync(file, JSON.stringify(receipt, null, 2));
|
|
53
|
+
return file;
|
|
54
|
+
}
|
|
55
|
+
export {
|
|
56
|
+
buildReceipt,
|
|
57
|
+
canonical,
|
|
58
|
+
verifyReceipt,
|
|
59
|
+
writeReceipt
|
|
60
|
+
};
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import {
|
|
3
3
|
connectDaemon,
|
|
4
4
|
socketPath
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-NCEEMDD6.js";
|
|
6
|
+
import "./chunk-W5ZGF5JQ.js";
|
|
7
7
|
import "./chunk-UBADCBPT.js";
|
|
8
8
|
import "./chunk-IEQGTVWN.js";
|
|
9
9
|
import "./chunk-AUJJGMZG.js";
|
|
@@ -14,9 +14,9 @@ import "./chunk-6NPUVPQD.js";
|
|
|
14
14
|
import "./chunk-K5QJMSJH.js";
|
|
15
15
|
import "./chunk-WAJXATCO.js";
|
|
16
16
|
import "./chunk-62JNF5M2.js";
|
|
17
|
-
import "./chunk-
|
|
17
|
+
import "./chunk-HSQ7XLD2.js";
|
|
18
18
|
import "./chunk-7CAGWFAQ.js";
|
|
19
|
-
import "./chunk-
|
|
19
|
+
import "./chunk-YRANCWY6.js";
|
|
20
20
|
import "./chunk-PYC53J7D.js";
|
|
21
21
|
import "./chunk-GV2HAALP.js";
|
|
22
22
|
|
|
@@ -12,14 +12,14 @@ import {
|
|
|
12
12
|
} from "./chunk-62JNF5M2.js";
|
|
13
13
|
import {
|
|
14
14
|
loadFlows
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-DRMVCSUG.js";
|
|
16
16
|
import {
|
|
17
17
|
captureViewports,
|
|
18
18
|
previewDir,
|
|
19
19
|
runtimeSummary
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-HSQ7XLD2.js";
|
|
21
21
|
import "./chunk-7CAGWFAQ.js";
|
|
22
|
-
import "./chunk-
|
|
22
|
+
import "./chunk-YRANCWY6.js";
|
|
23
23
|
import {
|
|
24
24
|
findChrome
|
|
25
25
|
} from "./chunk-PYC53J7D.js";
|
|
@@ -75,7 +75,7 @@ ${list.join("\n")}`);
|
|
|
75
75
|
if (flows.length === 0) return "no flows declared \u2014 add .squint/flows/<name>.flow";
|
|
76
76
|
const chrome = findChrome();
|
|
77
77
|
if (!chrome) return "no Chrome/Chromium found";
|
|
78
|
-
const { runFlow } = await import("./cdp-
|
|
78
|
+
const { runFlow } = await import("./cdp-FKFCV2B5.js");
|
|
79
79
|
const lines = [];
|
|
80
80
|
for (const flow of flows) {
|
|
81
81
|
const result = await runFlow(chrome, url, flow, previewDir(cwd));
|
package/package.json
CHANGED