@riddledc/riddle-proof 0.8.36 → 0.8.38
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 +21 -0
- package/dist/advanced/index.d.cts +1 -1
- package/dist/advanced/index.d.ts +1 -1
- package/dist/advanced/proof-run-engine.d.cts +1 -1
- package/dist/advanced/proof-run-engine.d.ts +1 -1
- package/dist/chunk-6KYXX4OE.js +209 -0
- package/dist/{chunk-TWTEUS7R.js → chunk-DI2XNGEZ.js} +126 -1
- package/dist/{chunk-E25K5PDM.js → chunk-U44KBAPH.js} +168 -7
- package/dist/cli/index.js +3 -2
- package/dist/cli.cjs +488 -3
- package/dist/cli.js +3 -2
- package/dist/index.cjs +336 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +26 -18
- package/dist/pr-comment.cjs +235 -0
- package/dist/pr-comment.d.cts +41 -0
- package/dist/pr-comment.d.ts +41 -0
- package/dist/pr-comment.js +11 -0
- package/dist/{proof-run-engine-DYUu2mqY.d.cts → proof-run-engine-4dM37pEx.d.cts} +3 -3
- package/dist/{proof-run-engine-BmNYuOJ7.d.ts → proof-run-engine-BqaeqAze.d.ts} +3 -3
- package/dist/proof-run-engine.d.cts +1 -1
- package/dist/proof-run-engine.d.ts +1 -1
- package/dist/riddle-client.cjs +126 -1
- package/dist/riddle-client.d.cts +21 -1
- package/dist/riddle-client.d.ts +21 -1
- package/dist/riddle-client.js +1 -1
- package/dist/runtime/index.cjs +126 -1
- package/dist/runtime/index.d.cts +1 -1
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.js +1 -1
- package/dist/runtime/riddle-client.cjs +126 -1
- package/dist/runtime/riddle-client.d.cts +1 -1
- package/dist/runtime/riddle-client.d.ts +1 -1
- package/dist/runtime/riddle-client.js +1 -1
- package/package.json +7 -2
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createRiddleApiClient,
|
|
3
|
+
isTerminalRiddleJobStatus,
|
|
4
|
+
parseRiddleViewport
|
|
5
|
+
} from "./chunk-DI2XNGEZ.js";
|
|
6
|
+
import {
|
|
7
|
+
RIDDLE_PROOF_PR_COMMENT_MARKER,
|
|
8
|
+
buildRiddleProofPrCommentMarkdown,
|
|
9
|
+
summarizeRiddleProofPrComment
|
|
10
|
+
} from "./chunk-6KYXX4OE.js";
|
|
1
11
|
import {
|
|
2
12
|
RIDDLE_PROOF_PROFILE_EVIDENCE_VERSION,
|
|
3
13
|
assessRiddleProofProfileEvidence,
|
|
@@ -13,11 +23,6 @@ import {
|
|
|
13
23
|
resolveRiddleProofProfileTargetUrl,
|
|
14
24
|
resolveRiddleProofProfileTimeoutSec
|
|
15
25
|
} from "./chunk-Z2LCVROU.js";
|
|
16
|
-
import {
|
|
17
|
-
createRiddleApiClient,
|
|
18
|
-
isTerminalRiddleJobStatus,
|
|
19
|
-
parseRiddleViewport
|
|
20
|
-
} from "./chunk-TWTEUS7R.js";
|
|
21
26
|
import {
|
|
22
27
|
createDisabledRiddleProofAgentAdapter,
|
|
23
28
|
readRiddleProofRunStatus,
|
|
@@ -56,11 +61,14 @@ var KNOWN_CLI_OPTIONS = /* @__PURE__ */ new Set([
|
|
|
56
61
|
"codexSandbox",
|
|
57
62
|
"codexTimeoutMs",
|
|
58
63
|
"command",
|
|
64
|
+
"commentMode",
|
|
59
65
|
"continueWithStage",
|
|
60
66
|
"createdAt",
|
|
61
67
|
"decision",
|
|
62
68
|
"defaultReviewer",
|
|
63
69
|
"defaultShipMode",
|
|
70
|
+
"bodyFile",
|
|
71
|
+
"dryRun",
|
|
64
72
|
"exclude",
|
|
65
73
|
"format",
|
|
66
74
|
"framework",
|
|
@@ -88,20 +96,25 @@ var KNOWN_CLI_OPTIONS = /* @__PURE__ */ new Set([
|
|
|
88
96
|
"pack",
|
|
89
97
|
"packFile",
|
|
90
98
|
"profile",
|
|
99
|
+
"proofDir",
|
|
100
|
+
"pr",
|
|
91
101
|
"progressEveryMs",
|
|
92
102
|
"quiet",
|
|
93
103
|
"readinessPath",
|
|
94
104
|
"readinessTimeout",
|
|
95
105
|
"reasonsJson",
|
|
106
|
+
"repo",
|
|
96
107
|
"requestJson",
|
|
97
108
|
"requiredJson",
|
|
98
109
|
"responseJson",
|
|
99
110
|
"resultFormat",
|
|
111
|
+
"resultJson",
|
|
100
112
|
"resultsDir",
|
|
101
113
|
"riddleEngineModuleUrl",
|
|
102
114
|
"riddleProofDir",
|
|
103
115
|
"route",
|
|
104
116
|
"runDir",
|
|
117
|
+
"runResponse",
|
|
105
118
|
"runner",
|
|
106
119
|
"scriptFile",
|
|
107
120
|
"sourceKind",
|
|
@@ -138,9 +151,10 @@ function usage() {
|
|
|
138
151
|
" riddle-proof-loop run-profile aggregate --profile <file|json|-> --url <base-url> [--base-url <base-url>] --input-dir <dir>|--inputs <path[,path...]> [--output <dir>|--output-dir <dir>] [--result-format json|compact-json|summary|none; default json]",
|
|
139
152
|
" riddle-proof-loop run-profile recover --profile <file|json|-> --url <base-url> [--base-url <base-url>] --job <job-id> [--viewport-name <name[,name...]>] [--output <dir>|--output-dir <dir>] [--result-format json|compact-json|summary|none; default json]",
|
|
140
153
|
" riddle-proof-loop regression-pack run [--pack oc-flow-regression|--pack-file <file>] [--local-core true|false; default true] [--hosted-riddle true|false; default false] [--format json|markdown|compact-json; default json] [--output <dir>|--output-dir <dir>]",
|
|
154
|
+
" riddle-proof-loop pr-comment --proof-dir <dir>|--run-response <file> [--result-json <file>] --pr <number|url> [--repo owner/name] [--dry-run] [--body-file <file>] [--comment-mode update|append]",
|
|
141
155
|
" riddle-proof-loop profile-body-assertions --artifact <file|url|-> --candidates-json <file|json|-> [--required-json <file|json|->] [--format json|body-contains]",
|
|
142
156
|
" riddle-proof-loop profile-http-status-preflight --profile <file|json|-> --url <base-url> [--format json|summary]",
|
|
143
|
-
" riddle-proof-loop riddle-preview-deploy <build-dir> <label> [--framework spa|static]",
|
|
157
|
+
" riddle-proof-loop riddle-preview-deploy <build-dir> <label> [--framework spa|static] [--quiet]",
|
|
144
158
|
" riddle-proof-loop riddle-server-preview <directory> --script-file <file> [--path /route] [--wait-for-selector selector]",
|
|
145
159
|
" riddle-proof-loop riddle-run-script --url <url> --script-file <file> [--viewport 1280x720] [--strict true|false]",
|
|
146
160
|
" riddle-proof-loop riddle-poll <job-id> [--wait] [--attempts n] [--quiet]",
|
|
@@ -909,6 +923,18 @@ function formatPollDuration(ms) {
|
|
|
909
923
|
const remainder = seconds % 60;
|
|
910
924
|
return minutes > 0 ? `${minutes}m${String(remainder).padStart(2, "0")}s` : `${seconds}s`;
|
|
911
925
|
}
|
|
926
|
+
function formatByteCount(bytes) {
|
|
927
|
+
if (typeof bytes !== "number" || !Number.isFinite(bytes)) return "n/a";
|
|
928
|
+
if (bytes < 1024) return `${bytes}B`;
|
|
929
|
+
const units = ["KB", "MB", "GB", "TB"];
|
|
930
|
+
let value = bytes / 1024;
|
|
931
|
+
let unitIndex = 0;
|
|
932
|
+
while (value >= 1024 && unitIndex < units.length - 1) {
|
|
933
|
+
value /= 1024;
|
|
934
|
+
unitIndex += 1;
|
|
935
|
+
}
|
|
936
|
+
return `${value >= 10 ? value.toFixed(0) : value.toFixed(1)}${units[unitIndex]}`;
|
|
937
|
+
}
|
|
912
938
|
function riddlePollProgressLine(snapshot) {
|
|
913
939
|
const submittedAt = snapshot.submitted_at || "not-submitted";
|
|
914
940
|
const queuePart = snapshot.running_without_submission ? ` waiting_for_submit=${formatPollDuration(snapshot.pre_submission_elapsed_ms)}${snapshot.queue_elapsed_ms !== null ? ` queued_for=${formatPollDuration(snapshot.queue_elapsed_ms)}` : ""}` : snapshot.queue_elapsed_ms !== null ? ` queue=${formatPollDuration(snapshot.queue_elapsed_ms)}` : "";
|
|
@@ -922,6 +948,93 @@ function riddlePollProgressLine(snapshot) {
|
|
|
922
948
|
`submitted_at=${submittedAt}${queuePart}${terminalPart}`
|
|
923
949
|
].join(" ");
|
|
924
950
|
}
|
|
951
|
+
function riddlePreviewProgressLine(snapshot) {
|
|
952
|
+
const idPart = snapshot.id ? ` id=${snapshot.id}` : "";
|
|
953
|
+
const statusPart = snapshot.status ? ` status=${snapshot.status}` : "";
|
|
954
|
+
const attemptPart = snapshot.attempt && snapshot.attempts ? ` attempt=${snapshot.attempt}/${snapshot.attempts}` : "";
|
|
955
|
+
const previewPart = snapshot.preview_url ? ` url=${snapshot.preview_url}` : "";
|
|
956
|
+
const filePart = typeof snapshot.file_count === "number" ? ` files=${snapshot.file_count}` : "";
|
|
957
|
+
const totalPart = typeof snapshot.total_bytes === "number" ? ` bytes=${formatByteCount(snapshot.total_bytes)}` : "";
|
|
958
|
+
const archivePart = typeof snapshot.tarball_bytes === "number" ? ` archive=${formatByteCount(snapshot.tarball_bytes)}` : "";
|
|
959
|
+
const recoveryPart = snapshot.publish_error ? ` publish_error=${JSON.stringify(snapshot.publish_error)}` : "";
|
|
960
|
+
const messagePart = snapshot.message ? ` ${snapshot.message}` : "";
|
|
961
|
+
return `[riddle-preview] ${snapshot.stage}${idPart}${statusPart}${attemptPart} elapsed=${formatPollDuration(snapshot.elapsed_ms)} label=${snapshot.label} framework=${snapshot.framework}${filePart}${totalPart}${archivePart}${previewPart}${recoveryPart}${messagePart}`;
|
|
962
|
+
}
|
|
963
|
+
function readJsonFileIfExists(filePath) {
|
|
964
|
+
if (!filePath || !existsSync(filePath)) return void 0;
|
|
965
|
+
return readJsonValue(filePath, filePath);
|
|
966
|
+
}
|
|
967
|
+
function defaultProofDirJsonPath(proofDir, filename) {
|
|
968
|
+
return proofDir ? path.join(proofDir, filename) : void 0;
|
|
969
|
+
}
|
|
970
|
+
function prNumberFromValue(value) {
|
|
971
|
+
const text = value?.trim();
|
|
972
|
+
if (!text) return "";
|
|
973
|
+
const match = text.match(/\/pull\/(\d+)(?:\/|$)/) || text.match(/^#?(\d+)$/);
|
|
974
|
+
return match ? match[1] : text;
|
|
975
|
+
}
|
|
976
|
+
function ghJson(args, input) {
|
|
977
|
+
const result = spawnSync("gh", args, {
|
|
978
|
+
input: typeof input === "undefined" ? void 0 : `${JSON.stringify(input)}
|
|
979
|
+
`,
|
|
980
|
+
encoding: "utf-8",
|
|
981
|
+
timeout: 9e4
|
|
982
|
+
});
|
|
983
|
+
if (result.error) throw result.error;
|
|
984
|
+
if (result.status !== 0) {
|
|
985
|
+
const detail = (result.stderr || result.stdout || "").trim();
|
|
986
|
+
throw new Error(`gh ${args.join(" ")} failed${detail ? `: ${detail}` : ""}`);
|
|
987
|
+
}
|
|
988
|
+
const stdout = (result.stdout || "").trim();
|
|
989
|
+
return stdout ? JSON.parse(stdout) : {};
|
|
990
|
+
}
|
|
991
|
+
function resolveGhRepoName(repoOption) {
|
|
992
|
+
if (repoOption?.trim()) return repoOption.trim();
|
|
993
|
+
const result = spawnSync("gh", ["repo", "view", "--json", "nameWithOwner", "--jq", ".nameWithOwner"], {
|
|
994
|
+
encoding: "utf-8",
|
|
995
|
+
timeout: 3e4
|
|
996
|
+
});
|
|
997
|
+
if (result.error) throw result.error;
|
|
998
|
+
if (result.status !== 0 || !result.stdout.trim()) {
|
|
999
|
+
const detail = (result.stderr || result.stdout || "").trim();
|
|
1000
|
+
throw new Error(`Could not resolve GitHub repository. Pass --repo owner/name.${detail ? ` gh said: ${detail}` : ""}`);
|
|
1001
|
+
}
|
|
1002
|
+
return result.stdout.trim();
|
|
1003
|
+
}
|
|
1004
|
+
function findManagedPrComment(repo, prNumber) {
|
|
1005
|
+
const comments = ghJson(["api", `repos/${repo}/issues/${prNumber}/comments`, "--paginate"]);
|
|
1006
|
+
return comments.find((comment) => typeof comment.body === "string" && comment.body.includes(RIDDLE_PROOF_PR_COMMENT_MARKER));
|
|
1007
|
+
}
|
|
1008
|
+
function upsertPrComment(input) {
|
|
1009
|
+
const payload = { body: input.body };
|
|
1010
|
+
if (input.mode !== "append") {
|
|
1011
|
+
const existing = findManagedPrComment(input.repo, input.prNumber);
|
|
1012
|
+
if (existing?.id) {
|
|
1013
|
+
return {
|
|
1014
|
+
action: "updated",
|
|
1015
|
+
comment: ghJson([
|
|
1016
|
+
"api",
|
|
1017
|
+
`repos/${input.repo}/issues/comments/${existing.id}`,
|
|
1018
|
+
"-X",
|
|
1019
|
+
"PATCH",
|
|
1020
|
+
"--input",
|
|
1021
|
+
"-"
|
|
1022
|
+
], payload)
|
|
1023
|
+
};
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
return {
|
|
1027
|
+
action: "created",
|
|
1028
|
+
comment: ghJson([
|
|
1029
|
+
"api",
|
|
1030
|
+
`repos/${input.repo}/issues/${input.prNumber}/comments`,
|
|
1031
|
+
"-X",
|
|
1032
|
+
"POST",
|
|
1033
|
+
"--input",
|
|
1034
|
+
"-"
|
|
1035
|
+
], payload)
|
|
1036
|
+
};
|
|
1037
|
+
}
|
|
925
1038
|
function readJsonValue(value, label) {
|
|
926
1039
|
if (!value) throw new Error(`${label} is required.`);
|
|
927
1040
|
const raw = value === "-" ? readStdin() : existsSync(value) ? readFileSync(value, "utf-8") : value;
|
|
@@ -4554,6 +4667,47 @@ async function main() {
|
|
|
4554
4667
|
process.exitCode = result.ok ? 0 : 1;
|
|
4555
4668
|
return;
|
|
4556
4669
|
}
|
|
4670
|
+
if (command === "pr-comment") {
|
|
4671
|
+
const proofDir = optionString(options, "proofDir") || optionString(options, "outputDir") || positional[1];
|
|
4672
|
+
const runResponsePath = optionString(options, "runResponse") || defaultProofDirJsonPath(proofDir, "riddle-run-response.json");
|
|
4673
|
+
const resultJsonPath = optionString(options, "resultJson") || defaultProofDirJsonPath(proofDir, "result.json");
|
|
4674
|
+
const runResponse = readJsonFileIfExists(runResponsePath);
|
|
4675
|
+
const result = readJsonFileIfExists(resultJsonPath);
|
|
4676
|
+
if (!runResponse && !result) {
|
|
4677
|
+
throw new Error("pr-comment requires --proof-dir with riddle-run-response.json/result.json or explicit --run-response/--result-json.");
|
|
4678
|
+
}
|
|
4679
|
+
const body = buildRiddleProofPrCommentMarkdown({
|
|
4680
|
+
title: optionString(options, "title"),
|
|
4681
|
+
goal: optionString(options, "summary"),
|
|
4682
|
+
successCriteria: optionString(options, "successCriteria"),
|
|
4683
|
+
runResponse,
|
|
4684
|
+
result
|
|
4685
|
+
});
|
|
4686
|
+
const bodyFile = optionString(options, "bodyFile");
|
|
4687
|
+
if (bodyFile) writeFileSync(bodyFile, body);
|
|
4688
|
+
if (optionBoolean(options, "dryRun")) {
|
|
4689
|
+
process.stdout.write(body);
|
|
4690
|
+
return;
|
|
4691
|
+
}
|
|
4692
|
+
const prNumber = prNumberFromValue(optionString(options, "pr"));
|
|
4693
|
+
if (!prNumber) throw new Error("pr-comment requires --pr <number|url> unless --dry-run is used.");
|
|
4694
|
+
const commentMode = optionString(options, "commentMode") || "update";
|
|
4695
|
+
if (!["update", "append"].includes(commentMode)) throw new Error("--comment-mode must be update or append.");
|
|
4696
|
+
const repo = resolveGhRepoName(optionString(options, "repo"));
|
|
4697
|
+
const resultPayload = upsertPrComment({ repo, prNumber, body, mode: commentMode });
|
|
4698
|
+
const comment = resultPayload.comment;
|
|
4699
|
+
process.stdout.write(`${JSON.stringify({
|
|
4700
|
+
ok: true,
|
|
4701
|
+
action: resultPayload.action,
|
|
4702
|
+
repo,
|
|
4703
|
+
pr: prNumber,
|
|
4704
|
+
comment_url: cliString(comment.html_url) || null,
|
|
4705
|
+
summary: summarizeRiddleProofPrComment({ runResponse, result }),
|
|
4706
|
+
body_file: bodyFile || null
|
|
4707
|
+
}, null, 2)}
|
|
4708
|
+
`);
|
|
4709
|
+
return;
|
|
4710
|
+
}
|
|
4557
4711
|
if (command === "profile-http-status-preflight") {
|
|
4558
4712
|
const profile = normalizeProfileForCli(options);
|
|
4559
4713
|
const result = await preflightRiddleProofProfileHttpStatusChecks(profile);
|
|
@@ -4597,7 +4751,14 @@ async function main() {
|
|
|
4597
4751
|
if (command === "riddle-preview-deploy") {
|
|
4598
4752
|
const buildDir = positional[1];
|
|
4599
4753
|
const label = positional[2];
|
|
4600
|
-
const
|
|
4754
|
+
const clientConfig = riddleClientConfig(options);
|
|
4755
|
+
if (options.quiet !== true) {
|
|
4756
|
+
clientConfig.onPreviewProgress = (snapshot) => {
|
|
4757
|
+
process.stderr.write(`${riddlePreviewProgressLine(snapshot)}
|
|
4758
|
+
`);
|
|
4759
|
+
};
|
|
4760
|
+
}
|
|
4761
|
+
const result = await createRiddleApiClient(clientConfig).deployPreview(buildDir, label, previewFrameworkOption(options));
|
|
4601
4762
|
for (const warning of result.warnings ?? []) {
|
|
4602
4763
|
process.stderr.write(`Warning: ${warning}
|
|
4603
4764
|
`);
|
package/dist/cli/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import "../chunk-
|
|
1
|
+
import "../chunk-U44KBAPH.js";
|
|
2
|
+
import "../chunk-DI2XNGEZ.js";
|
|
3
|
+
import "../chunk-6KYXX4OE.js";
|
|
2
4
|
import "../chunk-Z2LCVROU.js";
|
|
3
|
-
import "../chunk-TWTEUS7R.js";
|
|
4
5
|
import "../chunk-ZREWMTFA.js";
|
|
5
6
|
import "../chunk-ZQWVXQKJ.js";
|
|
6
7
|
import "../chunk-RDPG554T.js";
|