@riddledc/riddle-proof-packs 0.4.3 → 0.4.5
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 +45 -0
- package/bin/riddle-proof-review-packet +4 -0
- package/dist/chunk-XQ2N4EYF.js +135 -0
- package/dist/humanReviewPacket-APSxuvat.d.cts +17 -0
- package/dist/humanReviewPacket-APSxuvat.d.ts +17 -0
- package/dist/index.cjs +139 -2
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +12 -1
- package/dist/reviewPacketCli.cjs +319 -0
- package/dist/reviewPacketCli.d.cts +28 -0
- package/dist/reviewPacketCli.d.ts +28 -0
- package/dist/reviewPacketCli.js +155 -0
- package/package.json +6 -2
- package/packs/neon-step-sequencer/examples/README.md +1 -1
- package/packs/neon-step-sequencer/examples/run-006-ratchet-loop-human-review-packet/human-review-packet.json +795 -0
- package/packs/neon-step-sequencer/examples/run-006-ratchet-loop-human-review-packet/human-review-packet.md +49 -0
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/reviewPacketCli.ts
|
|
31
|
+
var reviewPacketCli_exports = {};
|
|
32
|
+
__export(reviewPacketCli_exports, {
|
|
33
|
+
main: () => main,
|
|
34
|
+
parseReviewPacketCliArgs: () => parseReviewPacketCliArgs,
|
|
35
|
+
writeReviewPacketFiles: () => writeReviewPacketFiles
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(reviewPacketCli_exports);
|
|
38
|
+
var import_node_fs = require("fs");
|
|
39
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
40
|
+
|
|
41
|
+
// src/humanReviewPacket.ts
|
|
42
|
+
var isRecord = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
43
|
+
var asRecord = (value) => isRecord(value) ? value : null;
|
|
44
|
+
var asArray = (value) => Array.isArray(value) ? value : [];
|
|
45
|
+
var getPath = (value, path2) => {
|
|
46
|
+
let cursor = value;
|
|
47
|
+
for (const part of path2.split(".")) {
|
|
48
|
+
if (!isRecord(cursor)) return void 0;
|
|
49
|
+
cursor = cursor[part];
|
|
50
|
+
}
|
|
51
|
+
return cursor;
|
|
52
|
+
};
|
|
53
|
+
var formatValue = (value) => {
|
|
54
|
+
if (value === null || value === void 0 || value === "") return "not captured";
|
|
55
|
+
if (typeof value === "number") return Number.isInteger(value) ? String(value) : String(Number(value.toFixed(4)));
|
|
56
|
+
if (typeof value === "boolean") return value ? "true" : "false";
|
|
57
|
+
return String(value);
|
|
58
|
+
};
|
|
59
|
+
var formatCodeValue = (value) => `\`${formatValue(value)}\``;
|
|
60
|
+
var formatAction = (action) => {
|
|
61
|
+
const record = asRecord(action);
|
|
62
|
+
if (!record) return "not captured";
|
|
63
|
+
const type = record.type ?? "set_mixer_level";
|
|
64
|
+
const track = record.track ?? "track";
|
|
65
|
+
const from = formatValue(record.from);
|
|
66
|
+
const to = formatValue(record.to);
|
|
67
|
+
const delta = record.delta === null || record.delta === void 0 ? "" : ` (${formatValue(record.delta)})`;
|
|
68
|
+
return `${type} ${track}: ${from} -> ${to}${delta}`;
|
|
69
|
+
};
|
|
70
|
+
var addOptionalList = (lines, heading, values) => {
|
|
71
|
+
const entries = asArray(values).filter((entry) => entry !== null && entry !== void 0 && entry !== "");
|
|
72
|
+
if (!entries.length) return;
|
|
73
|
+
lines.push("", `## ${heading}`, "");
|
|
74
|
+
for (const entry of entries) lines.push(`- ${formatValue(entry)}`);
|
|
75
|
+
};
|
|
76
|
+
function findHumanReviewPacket(value) {
|
|
77
|
+
if (!value || typeof value !== "object") return null;
|
|
78
|
+
if (isRecord(value) && value.kind === "human_review_packet") return value;
|
|
79
|
+
if (Array.isArray(value)) {
|
|
80
|
+
for (const entry of value) {
|
|
81
|
+
const packet = findHumanReviewPacket(entry);
|
|
82
|
+
if (packet) return packet;
|
|
83
|
+
}
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
for (const entry of Object.values(value)) {
|
|
87
|
+
const packet = findHumanReviewPacket(entry);
|
|
88
|
+
if (packet) return packet;
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
function requireHumanReviewPacket(value) {
|
|
93
|
+
const packet = findHumanReviewPacket(value);
|
|
94
|
+
if (!packet) throw new Error("No human_review_packet found");
|
|
95
|
+
return packet;
|
|
96
|
+
}
|
|
97
|
+
function formatHumanReviewPacketMarkdown(packet, options = {}) {
|
|
98
|
+
if (packet.kind !== "human_review_packet") {
|
|
99
|
+
throw new Error("Expected a human_review_packet");
|
|
100
|
+
}
|
|
101
|
+
const recommendation = asRecord(packet.recommendation) ?? {};
|
|
102
|
+
const candidate = asRecord(recommendation.candidate) ?? {};
|
|
103
|
+
const guardrails = asRecord(packet.guardrails) ?? {};
|
|
104
|
+
const ranking = asRecord(packet.ranking) ?? {};
|
|
105
|
+
const request = asRecord(packet.request) ?? {};
|
|
106
|
+
const supportedCandidates = asArray(packet.supportedCandidates);
|
|
107
|
+
const rejectedCandidates = asArray(packet.rejectedCandidates);
|
|
108
|
+
const selectedSong = getPath(packet, "target.selectedSong.selectedSong") ?? getPath(packet, "target.routeState.selectedSong");
|
|
109
|
+
const lines = [
|
|
110
|
+
`# ${options.title ?? "Human Review Packet"}`,
|
|
111
|
+
"",
|
|
112
|
+
`- status: ${formatCodeValue(packet.status)}`,
|
|
113
|
+
`- domain: ${formatCodeValue(packet.domain)}`,
|
|
114
|
+
`- evidence_role_pattern: ${formatCodeValue(packet.evidenceRolePattern)}`,
|
|
115
|
+
`- requested_intent: ${formatValue(packet.requestedIntent)}`,
|
|
116
|
+
`- selected_song: ${formatValue(selectedSong)}`,
|
|
117
|
+
"",
|
|
118
|
+
"## Recommendation",
|
|
119
|
+
"",
|
|
120
|
+
`- action: ${formatCodeValue(recommendation.action)}`,
|
|
121
|
+
`- candidate: ${formatCodeValue(candidate.label)}`,
|
|
122
|
+
`- candidate_action: ${formatCodeValue(formatAction(candidate.action))}`,
|
|
123
|
+
`- reason: ${formatValue(recommendation.reason)}`,
|
|
124
|
+
"",
|
|
125
|
+
"## Objective Receipts",
|
|
126
|
+
"",
|
|
127
|
+
`- supported_candidates: ${formatCodeValue(guardrails.supportedClaimCandidateCount ?? supportedCandidates.length)}`,
|
|
128
|
+
`- rejected_candidates: ${formatCodeValue(guardrails.rejectedCandidateCount ?? rejectedCandidates.length)}`,
|
|
129
|
+
`- state_restored_after_loop: ${formatCodeValue(guardrails.stateRestoredAfterLoop)}`,
|
|
130
|
+
`- candidate_actions_are_transient: ${formatCodeValue(request.candidateActionsAreTransient)}`,
|
|
131
|
+
`- no_permanent_edit_unless_apply_best: ${formatCodeValue(guardrails.noPermanentEditUnlessApplyBest)}`,
|
|
132
|
+
"",
|
|
133
|
+
"## Ranking",
|
|
134
|
+
"",
|
|
135
|
+
`- metric: ${formatCodeValue(ranking.metric)}`,
|
|
136
|
+
`- role: ${formatCodeValue(ranking.role)}`,
|
|
137
|
+
`- lower_is_better: ${formatCodeValue(ranking.lowerIsBetter)}`,
|
|
138
|
+
`- baseline: ${formatCodeValue(ranking.baselineCandidateRankingMetric)}`,
|
|
139
|
+
`- best: ${formatCodeValue(ranking.bestCandidateRankingMetric)}`,
|
|
140
|
+
`- delta: ${formatCodeValue(ranking.rankingMetricDelta)}`,
|
|
141
|
+
"",
|
|
142
|
+
"## Boundary",
|
|
143
|
+
"",
|
|
144
|
+
formatValue(packet.proofBoundary)
|
|
145
|
+
];
|
|
146
|
+
addOptionalList(lines, "Listening Prompts", packet.listenerPrompts);
|
|
147
|
+
addOptionalList(lines, "Caveats", packet.caveats);
|
|
148
|
+
if (rejectedCandidates.length) {
|
|
149
|
+
lines.push("", "## Rejected Candidates", "");
|
|
150
|
+
for (const entry of rejectedCandidates) {
|
|
151
|
+
const rejected = asRecord(entry) ?? {};
|
|
152
|
+
const failedReceipts = asArray(rejected.failedReceipts).map(formatValue).join(", ") || "not captured";
|
|
153
|
+
lines.push(`- ${formatCodeValue(rejected.label)}: ${failedReceipts}`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return `${lines.join("\n")}
|
|
157
|
+
`;
|
|
158
|
+
}
|
|
159
|
+
function createHumanReviewPacketArtifacts(proofOrPacket, options = {}) {
|
|
160
|
+
const packet = requireHumanReviewPacket(proofOrPacket);
|
|
161
|
+
const markdown = formatHumanReviewPacketMarkdown(packet, options);
|
|
162
|
+
return {
|
|
163
|
+
packet,
|
|
164
|
+
json: `${JSON.stringify(packet, null, 2)}
|
|
165
|
+
`,
|
|
166
|
+
markdown
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// src/reviewPacketCli.ts
|
|
171
|
+
var DEFAULT_JSON_NAME = "human-review-packet.json";
|
|
172
|
+
var DEFAULT_MARKDOWN_NAME = "human-review-packet.md";
|
|
173
|
+
var USAGE = `riddle-proof-review-packet --proof <path|-> [options]
|
|
174
|
+
|
|
175
|
+
Extract a human_review_packet from a Riddle Proof artifact and write a compact
|
|
176
|
+
JSON/Markdown handoff for listening or follow-up review.
|
|
177
|
+
|
|
178
|
+
Options:
|
|
179
|
+
--proof <path|-> Riddle Proof proof.json/profile-result.json, or '-' for stdin.
|
|
180
|
+
--output <dir> Output directory. Defaults to the proof file directory.
|
|
181
|
+
--json <path> JSON output path. Defaults to <output>/human-review-packet.json.
|
|
182
|
+
--markdown <path> Markdown output path. Defaults to <output>/human-review-packet.md.
|
|
183
|
+
--title <title> Markdown title. Defaults to "Human Review Packet".
|
|
184
|
+
--stdout Also print the Markdown handoff to stdout.
|
|
185
|
+
--help Show this help.
|
|
186
|
+
`;
|
|
187
|
+
var readValue = (argv, index, name) => {
|
|
188
|
+
const value = argv[index + 1];
|
|
189
|
+
if (!value || value.startsWith("--")) throw new Error(`${name} requires a value.`);
|
|
190
|
+
return value;
|
|
191
|
+
};
|
|
192
|
+
function parseReviewPacketCliArgs(argv) {
|
|
193
|
+
const parsed = {
|
|
194
|
+
help: false,
|
|
195
|
+
proofPath: null,
|
|
196
|
+
outputDir: null,
|
|
197
|
+
jsonPath: null,
|
|
198
|
+
markdownPath: null,
|
|
199
|
+
title: null,
|
|
200
|
+
stdout: false
|
|
201
|
+
};
|
|
202
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
203
|
+
const arg = argv[index];
|
|
204
|
+
if (arg === "--help" || arg === "-h") {
|
|
205
|
+
parsed.help = true;
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
if (arg === "--proof") {
|
|
209
|
+
parsed.proofPath = readValue(argv, index, arg);
|
|
210
|
+
index += 1;
|
|
211
|
+
continue;
|
|
212
|
+
}
|
|
213
|
+
if (arg === "--output" || arg === "--output-dir") {
|
|
214
|
+
parsed.outputDir = readValue(argv, index, arg);
|
|
215
|
+
index += 1;
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
if (arg === "--json") {
|
|
219
|
+
parsed.jsonPath = readValue(argv, index, arg);
|
|
220
|
+
index += 1;
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
if (arg === "--markdown" || arg === "--md") {
|
|
224
|
+
parsed.markdownPath = readValue(argv, index, arg);
|
|
225
|
+
index += 1;
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
if (arg === "--title") {
|
|
229
|
+
parsed.title = readValue(argv, index, arg);
|
|
230
|
+
index += 1;
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
if (arg === "--stdout") {
|
|
234
|
+
parsed.stdout = true;
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
if (!arg.startsWith("--") && !parsed.proofPath) {
|
|
238
|
+
parsed.proofPath = arg;
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
throw new Error(`Unknown argument ${arg}.`);
|
|
242
|
+
}
|
|
243
|
+
return parsed;
|
|
244
|
+
}
|
|
245
|
+
var readProofArtifact = (proofPath) => {
|
|
246
|
+
if (proofPath === "-") return JSON.parse((0, import_node_fs.readFileSync)(0, "utf8"));
|
|
247
|
+
const absoluteProofPath = import_node_path.default.resolve(proofPath);
|
|
248
|
+
if (!(0, import_node_fs.existsSync)(absoluteProofPath)) {
|
|
249
|
+
throw new Error(`Proof artifact not found: ${absoluteProofPath}`);
|
|
250
|
+
}
|
|
251
|
+
return JSON.parse((0, import_node_fs.readFileSync)(absoluteProofPath, "utf8"));
|
|
252
|
+
};
|
|
253
|
+
var outputDirFor = (proofPath, outputDir) => {
|
|
254
|
+
if (outputDir) return import_node_path.default.resolve(outputDir);
|
|
255
|
+
if (proofPath === "-") return process.cwd();
|
|
256
|
+
return import_node_path.default.dirname(import_node_path.default.resolve(proofPath));
|
|
257
|
+
};
|
|
258
|
+
function writeReviewPacketFiles({
|
|
259
|
+
proofPath,
|
|
260
|
+
outputDir,
|
|
261
|
+
jsonPath,
|
|
262
|
+
markdownPath,
|
|
263
|
+
title
|
|
264
|
+
}) {
|
|
265
|
+
const proof = readProofArtifact(proofPath);
|
|
266
|
+
const artifacts = createHumanReviewPacketArtifacts(proof, {
|
|
267
|
+
title: title ?? void 0
|
|
268
|
+
});
|
|
269
|
+
const resolvedOutputDir = outputDirFor(proofPath, outputDir);
|
|
270
|
+
const resolvedJsonPath = import_node_path.default.resolve(jsonPath ?? import_node_path.default.join(resolvedOutputDir, DEFAULT_JSON_NAME));
|
|
271
|
+
const resolvedMarkdownPath = import_node_path.default.resolve(markdownPath ?? import_node_path.default.join(resolvedOutputDir, DEFAULT_MARKDOWN_NAME));
|
|
272
|
+
(0, import_node_fs.mkdirSync)(import_node_path.default.dirname(resolvedJsonPath), { recursive: true });
|
|
273
|
+
(0, import_node_fs.mkdirSync)(import_node_path.default.dirname(resolvedMarkdownPath), { recursive: true });
|
|
274
|
+
(0, import_node_fs.writeFileSync)(resolvedJsonPath, artifacts.json);
|
|
275
|
+
(0, import_node_fs.writeFileSync)(resolvedMarkdownPath, artifacts.markdown);
|
|
276
|
+
return {
|
|
277
|
+
...artifacts,
|
|
278
|
+
jsonPath: resolvedJsonPath,
|
|
279
|
+
markdownPath: resolvedMarkdownPath
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
async function main(argv = process.argv.slice(2)) {
|
|
283
|
+
const args = parseReviewPacketCliArgs(argv);
|
|
284
|
+
if (args.help) {
|
|
285
|
+
(0, import_node_fs.writeFileSync)(1, USAGE);
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
if (!args.proofPath) throw new Error("--proof is required.");
|
|
289
|
+
const result = writeReviewPacketFiles({
|
|
290
|
+
proofPath: args.proofPath,
|
|
291
|
+
outputDir: args.outputDir,
|
|
292
|
+
jsonPath: args.jsonPath,
|
|
293
|
+
markdownPath: args.markdownPath,
|
|
294
|
+
title: args.title
|
|
295
|
+
});
|
|
296
|
+
if (args.stdout) {
|
|
297
|
+
(0, import_node_fs.writeFileSync)(1, result.markdown);
|
|
298
|
+
} else {
|
|
299
|
+
(0, import_node_fs.writeFileSync)(1, `${JSON.stringify({
|
|
300
|
+
ok: true,
|
|
301
|
+
json: result.jsonPath,
|
|
302
|
+
markdown: result.markdownPath,
|
|
303
|
+
status: result.packet.status ?? null,
|
|
304
|
+
recommendation: result.packet.recommendation && typeof result.packet.recommendation === "object" ? result.packet.recommendation.candidate?.label ?? null : null
|
|
305
|
+
}, null, 2)}
|
|
306
|
+
`);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
main().catch((error) => {
|
|
310
|
+
(0, import_node_fs.writeFileSync)(2, `${error instanceof Error ? error.message : String(error)}
|
|
311
|
+
`);
|
|
312
|
+
process.exitCode = 1;
|
|
313
|
+
});
|
|
314
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
315
|
+
0 && (module.exports = {
|
|
316
|
+
main,
|
|
317
|
+
parseReviewPacketCliArgs,
|
|
318
|
+
writeReviewPacketFiles
|
|
319
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { H as HumanReviewPacket } from './humanReviewPacket-APSxuvat.cjs';
|
|
2
|
+
|
|
3
|
+
interface ParsedArgs {
|
|
4
|
+
help: boolean;
|
|
5
|
+
proofPath: string | null;
|
|
6
|
+
outputDir: string | null;
|
|
7
|
+
jsonPath: string | null;
|
|
8
|
+
markdownPath: string | null;
|
|
9
|
+
title: string | null;
|
|
10
|
+
stdout: boolean;
|
|
11
|
+
}
|
|
12
|
+
declare function parseReviewPacketCliArgs(argv: string[]): ParsedArgs;
|
|
13
|
+
declare function writeReviewPacketFiles({ proofPath, outputDir, jsonPath, markdownPath, title, }: {
|
|
14
|
+
proofPath: string;
|
|
15
|
+
outputDir: string | null;
|
|
16
|
+
jsonPath: string | null;
|
|
17
|
+
markdownPath: string | null;
|
|
18
|
+
title: string | null;
|
|
19
|
+
}): {
|
|
20
|
+
jsonPath: string;
|
|
21
|
+
markdownPath: string;
|
|
22
|
+
packet: HumanReviewPacket;
|
|
23
|
+
json: string;
|
|
24
|
+
markdown: string;
|
|
25
|
+
};
|
|
26
|
+
declare function main(argv?: string[]): Promise<void>;
|
|
27
|
+
|
|
28
|
+
export { main, parseReviewPacketCliArgs, writeReviewPacketFiles };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { H as HumanReviewPacket } from './humanReviewPacket-APSxuvat.js';
|
|
2
|
+
|
|
3
|
+
interface ParsedArgs {
|
|
4
|
+
help: boolean;
|
|
5
|
+
proofPath: string | null;
|
|
6
|
+
outputDir: string | null;
|
|
7
|
+
jsonPath: string | null;
|
|
8
|
+
markdownPath: string | null;
|
|
9
|
+
title: string | null;
|
|
10
|
+
stdout: boolean;
|
|
11
|
+
}
|
|
12
|
+
declare function parseReviewPacketCliArgs(argv: string[]): ParsedArgs;
|
|
13
|
+
declare function writeReviewPacketFiles({ proofPath, outputDir, jsonPath, markdownPath, title, }: {
|
|
14
|
+
proofPath: string;
|
|
15
|
+
outputDir: string | null;
|
|
16
|
+
jsonPath: string | null;
|
|
17
|
+
markdownPath: string | null;
|
|
18
|
+
title: string | null;
|
|
19
|
+
}): {
|
|
20
|
+
jsonPath: string;
|
|
21
|
+
markdownPath: string;
|
|
22
|
+
packet: HumanReviewPacket;
|
|
23
|
+
json: string;
|
|
24
|
+
markdown: string;
|
|
25
|
+
};
|
|
26
|
+
declare function main(argv?: string[]): Promise<void>;
|
|
27
|
+
|
|
28
|
+
export { main, parseReviewPacketCliArgs, writeReviewPacketFiles };
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createHumanReviewPacketArtifacts
|
|
3
|
+
} from "./chunk-XQ2N4EYF.js";
|
|
4
|
+
|
|
5
|
+
// src/reviewPacketCli.ts
|
|
6
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
7
|
+
import path from "path";
|
|
8
|
+
var DEFAULT_JSON_NAME = "human-review-packet.json";
|
|
9
|
+
var DEFAULT_MARKDOWN_NAME = "human-review-packet.md";
|
|
10
|
+
var USAGE = `riddle-proof-review-packet --proof <path|-> [options]
|
|
11
|
+
|
|
12
|
+
Extract a human_review_packet from a Riddle Proof artifact and write a compact
|
|
13
|
+
JSON/Markdown handoff for listening or follow-up review.
|
|
14
|
+
|
|
15
|
+
Options:
|
|
16
|
+
--proof <path|-> Riddle Proof proof.json/profile-result.json, or '-' for stdin.
|
|
17
|
+
--output <dir> Output directory. Defaults to the proof file directory.
|
|
18
|
+
--json <path> JSON output path. Defaults to <output>/human-review-packet.json.
|
|
19
|
+
--markdown <path> Markdown output path. Defaults to <output>/human-review-packet.md.
|
|
20
|
+
--title <title> Markdown title. Defaults to "Human Review Packet".
|
|
21
|
+
--stdout Also print the Markdown handoff to stdout.
|
|
22
|
+
--help Show this help.
|
|
23
|
+
`;
|
|
24
|
+
var readValue = (argv, index, name) => {
|
|
25
|
+
const value = argv[index + 1];
|
|
26
|
+
if (!value || value.startsWith("--")) throw new Error(`${name} requires a value.`);
|
|
27
|
+
return value;
|
|
28
|
+
};
|
|
29
|
+
function parseReviewPacketCliArgs(argv) {
|
|
30
|
+
const parsed = {
|
|
31
|
+
help: false,
|
|
32
|
+
proofPath: null,
|
|
33
|
+
outputDir: null,
|
|
34
|
+
jsonPath: null,
|
|
35
|
+
markdownPath: null,
|
|
36
|
+
title: null,
|
|
37
|
+
stdout: false
|
|
38
|
+
};
|
|
39
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
40
|
+
const arg = argv[index];
|
|
41
|
+
if (arg === "--help" || arg === "-h") {
|
|
42
|
+
parsed.help = true;
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (arg === "--proof") {
|
|
46
|
+
parsed.proofPath = readValue(argv, index, arg);
|
|
47
|
+
index += 1;
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (arg === "--output" || arg === "--output-dir") {
|
|
51
|
+
parsed.outputDir = readValue(argv, index, arg);
|
|
52
|
+
index += 1;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (arg === "--json") {
|
|
56
|
+
parsed.jsonPath = readValue(argv, index, arg);
|
|
57
|
+
index += 1;
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
if (arg === "--markdown" || arg === "--md") {
|
|
61
|
+
parsed.markdownPath = readValue(argv, index, arg);
|
|
62
|
+
index += 1;
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
if (arg === "--title") {
|
|
66
|
+
parsed.title = readValue(argv, index, arg);
|
|
67
|
+
index += 1;
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
if (arg === "--stdout") {
|
|
71
|
+
parsed.stdout = true;
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (!arg.startsWith("--") && !parsed.proofPath) {
|
|
75
|
+
parsed.proofPath = arg;
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
throw new Error(`Unknown argument ${arg}.`);
|
|
79
|
+
}
|
|
80
|
+
return parsed;
|
|
81
|
+
}
|
|
82
|
+
var readProofArtifact = (proofPath) => {
|
|
83
|
+
if (proofPath === "-") return JSON.parse(readFileSync(0, "utf8"));
|
|
84
|
+
const absoluteProofPath = path.resolve(proofPath);
|
|
85
|
+
if (!existsSync(absoluteProofPath)) {
|
|
86
|
+
throw new Error(`Proof artifact not found: ${absoluteProofPath}`);
|
|
87
|
+
}
|
|
88
|
+
return JSON.parse(readFileSync(absoluteProofPath, "utf8"));
|
|
89
|
+
};
|
|
90
|
+
var outputDirFor = (proofPath, outputDir) => {
|
|
91
|
+
if (outputDir) return path.resolve(outputDir);
|
|
92
|
+
if (proofPath === "-") return process.cwd();
|
|
93
|
+
return path.dirname(path.resolve(proofPath));
|
|
94
|
+
};
|
|
95
|
+
function writeReviewPacketFiles({
|
|
96
|
+
proofPath,
|
|
97
|
+
outputDir,
|
|
98
|
+
jsonPath,
|
|
99
|
+
markdownPath,
|
|
100
|
+
title
|
|
101
|
+
}) {
|
|
102
|
+
const proof = readProofArtifact(proofPath);
|
|
103
|
+
const artifacts = createHumanReviewPacketArtifacts(proof, {
|
|
104
|
+
title: title ?? void 0
|
|
105
|
+
});
|
|
106
|
+
const resolvedOutputDir = outputDirFor(proofPath, outputDir);
|
|
107
|
+
const resolvedJsonPath = path.resolve(jsonPath ?? path.join(resolvedOutputDir, DEFAULT_JSON_NAME));
|
|
108
|
+
const resolvedMarkdownPath = path.resolve(markdownPath ?? path.join(resolvedOutputDir, DEFAULT_MARKDOWN_NAME));
|
|
109
|
+
mkdirSync(path.dirname(resolvedJsonPath), { recursive: true });
|
|
110
|
+
mkdirSync(path.dirname(resolvedMarkdownPath), { recursive: true });
|
|
111
|
+
writeFileSync(resolvedJsonPath, artifacts.json);
|
|
112
|
+
writeFileSync(resolvedMarkdownPath, artifacts.markdown);
|
|
113
|
+
return {
|
|
114
|
+
...artifacts,
|
|
115
|
+
jsonPath: resolvedJsonPath,
|
|
116
|
+
markdownPath: resolvedMarkdownPath
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
async function main(argv = process.argv.slice(2)) {
|
|
120
|
+
const args = parseReviewPacketCliArgs(argv);
|
|
121
|
+
if (args.help) {
|
|
122
|
+
writeFileSync(1, USAGE);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if (!args.proofPath) throw new Error("--proof is required.");
|
|
126
|
+
const result = writeReviewPacketFiles({
|
|
127
|
+
proofPath: args.proofPath,
|
|
128
|
+
outputDir: args.outputDir,
|
|
129
|
+
jsonPath: args.jsonPath,
|
|
130
|
+
markdownPath: args.markdownPath,
|
|
131
|
+
title: args.title
|
|
132
|
+
});
|
|
133
|
+
if (args.stdout) {
|
|
134
|
+
writeFileSync(1, result.markdown);
|
|
135
|
+
} else {
|
|
136
|
+
writeFileSync(1, `${JSON.stringify({
|
|
137
|
+
ok: true,
|
|
138
|
+
json: result.jsonPath,
|
|
139
|
+
markdown: result.markdownPath,
|
|
140
|
+
status: result.packet.status ?? null,
|
|
141
|
+
recommendation: result.packet.recommendation && typeof result.packet.recommendation === "object" ? result.packet.recommendation.candidate?.label ?? null : null
|
|
142
|
+
}, null, 2)}
|
|
143
|
+
`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
main().catch((error) => {
|
|
147
|
+
writeFileSync(2, `${error instanceof Error ? error.message : String(error)}
|
|
148
|
+
`);
|
|
149
|
+
process.exitCode = 1;
|
|
150
|
+
});
|
|
151
|
+
export {
|
|
152
|
+
main,
|
|
153
|
+
parseReviewPacketCliArgs,
|
|
154
|
+
writeReviewPacketFiles
|
|
155
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riddledc/riddle-proof-packs",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.5",
|
|
4
4
|
"description": "Reusable proof pack profiles and metadata helpers for the Riddle proof framework.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "RiddleDC",
|
|
@@ -23,9 +23,13 @@
|
|
|
23
23
|
"files": [
|
|
24
24
|
"dist",
|
|
25
25
|
"packs",
|
|
26
|
+
"bin",
|
|
26
27
|
"LICENSE",
|
|
27
28
|
"README.md"
|
|
28
29
|
],
|
|
30
|
+
"bin": {
|
|
31
|
+
"riddle-proof-review-packet": "./bin/riddle-proof-review-packet"
|
|
32
|
+
},
|
|
29
33
|
"sideEffects": false,
|
|
30
34
|
"engines": {
|
|
31
35
|
"node": ">=18"
|
|
@@ -39,7 +43,7 @@
|
|
|
39
43
|
"typescript": "^5.4.5"
|
|
40
44
|
},
|
|
41
45
|
"scripts": {
|
|
42
|
-
"build": "tsup src/index.ts --format cjs,esm --dts --out-dir dist --clean",
|
|
46
|
+
"build": "tsup src/index.ts src/reviewPacketCli.ts --format cjs,esm --dts --out-dir dist --clean",
|
|
43
47
|
"clean": "rm -rf dist",
|
|
44
48
|
"lint": "echo 'lint: (not configured)'",
|
|
45
49
|
"test": "npm run build && node test.js"
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
These examples are local Playwright runner outputs captured against LilArcade Neon Step Sequencer on May 24, 2026. They are included to show how this pack records atomic proof claims with explicit evidence-role patterns.
|
|
4
4
|
|
|
5
|
-
The raw `profile-result.json` files are real runner outputs. They intentionally keep enough evidence to audit the verdict, but the summaries are the preferred place to start.
|
|
5
|
+
The raw `profile-result.json` files are real runner outputs. They intentionally keep enough evidence to audit the verdict, but the summaries are the preferred place to start. Run 006 also includes standalone `human-review-packet.json` and `human-review-packet.md` files generated from the proof artifact.
|
|
6
6
|
|
|
7
7
|
## Runs
|
|
8
8
|
|