@riddledc/riddle-proof-packs 0.4.4 → 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 +10 -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.d.cts +2 -17
- package/dist/index.d.ts +2 -17
- package/dist/index.js +7 -129
- 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/README.md
CHANGED
|
@@ -110,6 +110,16 @@ The `neon-step-sequencer` directory contains the first app-specific ratchet lab
|
|
|
110
110
|
|
|
111
111
|
Human-review packets are proof artifacts for subjective follow-up. They are deliberately not taste scores. A packet should say what objective receipts passed, what was preserved, which candidate is ready for listening review, and which caveats remain.
|
|
112
112
|
|
|
113
|
+
From the CLI:
|
|
114
|
+
|
|
115
|
+
```sh
|
|
116
|
+
riddle-proof-review-packet \
|
|
117
|
+
--proof artifacts/riddle-proof/proof.json \
|
|
118
|
+
--output artifacts/riddle-proof
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
This writes `human-review-packet.json` and `human-review-packet.md` next to the proof run. Use `--stdout` when an agent should read the Markdown handoff immediately.
|
|
122
|
+
|
|
113
123
|
```ts
|
|
114
124
|
import {
|
|
115
125
|
createHumanReviewPacketArtifacts,
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// src/humanReviewPacket.ts
|
|
2
|
+
var isRecord = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
3
|
+
var asRecord = (value) => isRecord(value) ? value : null;
|
|
4
|
+
var asArray = (value) => Array.isArray(value) ? value : [];
|
|
5
|
+
var getPath = (value, path) => {
|
|
6
|
+
let cursor = value;
|
|
7
|
+
for (const part of path.split(".")) {
|
|
8
|
+
if (!isRecord(cursor)) return void 0;
|
|
9
|
+
cursor = cursor[part];
|
|
10
|
+
}
|
|
11
|
+
return cursor;
|
|
12
|
+
};
|
|
13
|
+
var formatValue = (value) => {
|
|
14
|
+
if (value === null || value === void 0 || value === "") return "not captured";
|
|
15
|
+
if (typeof value === "number") return Number.isInteger(value) ? String(value) : String(Number(value.toFixed(4)));
|
|
16
|
+
if (typeof value === "boolean") return value ? "true" : "false";
|
|
17
|
+
return String(value);
|
|
18
|
+
};
|
|
19
|
+
var formatCodeValue = (value) => `\`${formatValue(value)}\``;
|
|
20
|
+
var formatAction = (action) => {
|
|
21
|
+
const record = asRecord(action);
|
|
22
|
+
if (!record) return "not captured";
|
|
23
|
+
const type = record.type ?? "set_mixer_level";
|
|
24
|
+
const track = record.track ?? "track";
|
|
25
|
+
const from = formatValue(record.from);
|
|
26
|
+
const to = formatValue(record.to);
|
|
27
|
+
const delta = record.delta === null || record.delta === void 0 ? "" : ` (${formatValue(record.delta)})`;
|
|
28
|
+
return `${type} ${track}: ${from} -> ${to}${delta}`;
|
|
29
|
+
};
|
|
30
|
+
var addOptionalList = (lines, heading, values) => {
|
|
31
|
+
const entries = asArray(values).filter((entry) => entry !== null && entry !== void 0 && entry !== "");
|
|
32
|
+
if (!entries.length) return;
|
|
33
|
+
lines.push("", `## ${heading}`, "");
|
|
34
|
+
for (const entry of entries) lines.push(`- ${formatValue(entry)}`);
|
|
35
|
+
};
|
|
36
|
+
function findHumanReviewPacket(value) {
|
|
37
|
+
if (!value || typeof value !== "object") return null;
|
|
38
|
+
if (isRecord(value) && value.kind === "human_review_packet") return value;
|
|
39
|
+
if (Array.isArray(value)) {
|
|
40
|
+
for (const entry of value) {
|
|
41
|
+
const packet = findHumanReviewPacket(entry);
|
|
42
|
+
if (packet) return packet;
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
for (const entry of Object.values(value)) {
|
|
47
|
+
const packet = findHumanReviewPacket(entry);
|
|
48
|
+
if (packet) return packet;
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
function requireHumanReviewPacket(value) {
|
|
53
|
+
const packet = findHumanReviewPacket(value);
|
|
54
|
+
if (!packet) throw new Error("No human_review_packet found");
|
|
55
|
+
return packet;
|
|
56
|
+
}
|
|
57
|
+
function formatHumanReviewPacketMarkdown(packet, options = {}) {
|
|
58
|
+
if (packet.kind !== "human_review_packet") {
|
|
59
|
+
throw new Error("Expected a human_review_packet");
|
|
60
|
+
}
|
|
61
|
+
const recommendation = asRecord(packet.recommendation) ?? {};
|
|
62
|
+
const candidate = asRecord(recommendation.candidate) ?? {};
|
|
63
|
+
const guardrails = asRecord(packet.guardrails) ?? {};
|
|
64
|
+
const ranking = asRecord(packet.ranking) ?? {};
|
|
65
|
+
const request = asRecord(packet.request) ?? {};
|
|
66
|
+
const supportedCandidates = asArray(packet.supportedCandidates);
|
|
67
|
+
const rejectedCandidates = asArray(packet.rejectedCandidates);
|
|
68
|
+
const selectedSong = getPath(packet, "target.selectedSong.selectedSong") ?? getPath(packet, "target.routeState.selectedSong");
|
|
69
|
+
const lines = [
|
|
70
|
+
`# ${options.title ?? "Human Review Packet"}`,
|
|
71
|
+
"",
|
|
72
|
+
`- status: ${formatCodeValue(packet.status)}`,
|
|
73
|
+
`- domain: ${formatCodeValue(packet.domain)}`,
|
|
74
|
+
`- evidence_role_pattern: ${formatCodeValue(packet.evidenceRolePattern)}`,
|
|
75
|
+
`- requested_intent: ${formatValue(packet.requestedIntent)}`,
|
|
76
|
+
`- selected_song: ${formatValue(selectedSong)}`,
|
|
77
|
+
"",
|
|
78
|
+
"## Recommendation",
|
|
79
|
+
"",
|
|
80
|
+
`- action: ${formatCodeValue(recommendation.action)}`,
|
|
81
|
+
`- candidate: ${formatCodeValue(candidate.label)}`,
|
|
82
|
+
`- candidate_action: ${formatCodeValue(formatAction(candidate.action))}`,
|
|
83
|
+
`- reason: ${formatValue(recommendation.reason)}`,
|
|
84
|
+
"",
|
|
85
|
+
"## Objective Receipts",
|
|
86
|
+
"",
|
|
87
|
+
`- supported_candidates: ${formatCodeValue(guardrails.supportedClaimCandidateCount ?? supportedCandidates.length)}`,
|
|
88
|
+
`- rejected_candidates: ${formatCodeValue(guardrails.rejectedCandidateCount ?? rejectedCandidates.length)}`,
|
|
89
|
+
`- state_restored_after_loop: ${formatCodeValue(guardrails.stateRestoredAfterLoop)}`,
|
|
90
|
+
`- candidate_actions_are_transient: ${formatCodeValue(request.candidateActionsAreTransient)}`,
|
|
91
|
+
`- no_permanent_edit_unless_apply_best: ${formatCodeValue(guardrails.noPermanentEditUnlessApplyBest)}`,
|
|
92
|
+
"",
|
|
93
|
+
"## Ranking",
|
|
94
|
+
"",
|
|
95
|
+
`- metric: ${formatCodeValue(ranking.metric)}`,
|
|
96
|
+
`- role: ${formatCodeValue(ranking.role)}`,
|
|
97
|
+
`- lower_is_better: ${formatCodeValue(ranking.lowerIsBetter)}`,
|
|
98
|
+
`- baseline: ${formatCodeValue(ranking.baselineCandidateRankingMetric)}`,
|
|
99
|
+
`- best: ${formatCodeValue(ranking.bestCandidateRankingMetric)}`,
|
|
100
|
+
`- delta: ${formatCodeValue(ranking.rankingMetricDelta)}`,
|
|
101
|
+
"",
|
|
102
|
+
"## Boundary",
|
|
103
|
+
"",
|
|
104
|
+
formatValue(packet.proofBoundary)
|
|
105
|
+
];
|
|
106
|
+
addOptionalList(lines, "Listening Prompts", packet.listenerPrompts);
|
|
107
|
+
addOptionalList(lines, "Caveats", packet.caveats);
|
|
108
|
+
if (rejectedCandidates.length) {
|
|
109
|
+
lines.push("", "## Rejected Candidates", "");
|
|
110
|
+
for (const entry of rejectedCandidates) {
|
|
111
|
+
const rejected = asRecord(entry) ?? {};
|
|
112
|
+
const failedReceipts = asArray(rejected.failedReceipts).map(formatValue).join(", ") || "not captured";
|
|
113
|
+
lines.push(`- ${formatCodeValue(rejected.label)}: ${failedReceipts}`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return `${lines.join("\n")}
|
|
117
|
+
`;
|
|
118
|
+
}
|
|
119
|
+
function createHumanReviewPacketArtifacts(proofOrPacket, options = {}) {
|
|
120
|
+
const packet = requireHumanReviewPacket(proofOrPacket);
|
|
121
|
+
const markdown = formatHumanReviewPacketMarkdown(packet, options);
|
|
122
|
+
return {
|
|
123
|
+
packet,
|
|
124
|
+
json: `${JSON.stringify(packet, null, 2)}
|
|
125
|
+
`,
|
|
126
|
+
markdown
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export {
|
|
131
|
+
findHumanReviewPacket,
|
|
132
|
+
requireHumanReviewPacket,
|
|
133
|
+
formatHumanReviewPacketMarkdown,
|
|
134
|
+
createHumanReviewPacketArtifacts
|
|
135
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
type HumanReviewPacket = Record<string, unknown> & {
|
|
2
|
+
kind: "human_review_packet";
|
|
3
|
+
};
|
|
4
|
+
interface HumanReviewPacketMarkdownOptions {
|
|
5
|
+
title?: string;
|
|
6
|
+
}
|
|
7
|
+
interface HumanReviewPacketArtifacts {
|
|
8
|
+
packet: HumanReviewPacket;
|
|
9
|
+
json: string;
|
|
10
|
+
markdown: string;
|
|
11
|
+
}
|
|
12
|
+
declare function findHumanReviewPacket(value: unknown): HumanReviewPacket | null;
|
|
13
|
+
declare function requireHumanReviewPacket(value: unknown): HumanReviewPacket;
|
|
14
|
+
declare function formatHumanReviewPacketMarkdown(packet: HumanReviewPacket, options?: HumanReviewPacketMarkdownOptions): string;
|
|
15
|
+
declare function createHumanReviewPacketArtifacts(proofOrPacket: unknown, options?: HumanReviewPacketMarkdownOptions): HumanReviewPacketArtifacts;
|
|
16
|
+
|
|
17
|
+
export { type HumanReviewPacket as H, type HumanReviewPacketArtifacts as a, type HumanReviewPacketMarkdownOptions as b, createHumanReviewPacketArtifacts as c, formatHumanReviewPacketMarkdown as d, findHumanReviewPacket as f, requireHumanReviewPacket as r };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
type HumanReviewPacket = Record<string, unknown> & {
|
|
2
|
+
kind: "human_review_packet";
|
|
3
|
+
};
|
|
4
|
+
interface HumanReviewPacketMarkdownOptions {
|
|
5
|
+
title?: string;
|
|
6
|
+
}
|
|
7
|
+
interface HumanReviewPacketArtifacts {
|
|
8
|
+
packet: HumanReviewPacket;
|
|
9
|
+
json: string;
|
|
10
|
+
markdown: string;
|
|
11
|
+
}
|
|
12
|
+
declare function findHumanReviewPacket(value: unknown): HumanReviewPacket | null;
|
|
13
|
+
declare function requireHumanReviewPacket(value: unknown): HumanReviewPacket;
|
|
14
|
+
declare function formatHumanReviewPacketMarkdown(packet: HumanReviewPacket, options?: HumanReviewPacketMarkdownOptions): string;
|
|
15
|
+
declare function createHumanReviewPacketArtifacts(proofOrPacket: unknown, options?: HumanReviewPacketMarkdownOptions): HumanReviewPacketArtifacts;
|
|
16
|
+
|
|
17
|
+
export { type HumanReviewPacket as H, type HumanReviewPacketArtifacts as a, type HumanReviewPacketMarkdownOptions as b, createHumanReviewPacketArtifacts as c, formatHumanReviewPacketMarkdown as d, findHumanReviewPacket as f, requireHumanReviewPacket as r };
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as _riddledc_riddle_proof from '@riddledc/riddle-proof';
|
|
2
2
|
import { RiddleProofProfile } from '@riddledc/riddle-proof';
|
|
3
|
+
export { H as HumanReviewPacket, a as HumanReviewPacketArtifacts, b as HumanReviewPacketMarkdownOptions, c as createHumanReviewPacketArtifacts, f as findHumanReviewPacket, d as formatHumanReviewPacketMarkdown, r as requireHumanReviewPacket } from './humanReviewPacket-APSxuvat.cjs';
|
|
3
4
|
|
|
4
5
|
interface RiddleProofPackProfileManifest {
|
|
5
6
|
/** Profile slug and canonical manifest key. */
|
|
@@ -59,20 +60,4 @@ interface RiddleProofPackProfileOverrides {
|
|
|
59
60
|
*/
|
|
60
61
|
declare function instantiateRiddleProofProfile(profileName: string, options?: RiddleProofPackProfileOverrides): RiddleProofProfile;
|
|
61
62
|
|
|
62
|
-
type
|
|
63
|
-
kind: "human_review_packet";
|
|
64
|
-
};
|
|
65
|
-
interface HumanReviewPacketMarkdownOptions {
|
|
66
|
-
title?: string;
|
|
67
|
-
}
|
|
68
|
-
interface HumanReviewPacketArtifacts {
|
|
69
|
-
packet: HumanReviewPacket;
|
|
70
|
-
json: string;
|
|
71
|
-
markdown: string;
|
|
72
|
-
}
|
|
73
|
-
declare function findHumanReviewPacket(value: unknown): HumanReviewPacket | null;
|
|
74
|
-
declare function requireHumanReviewPacket(value: unknown): HumanReviewPacket;
|
|
75
|
-
declare function formatHumanReviewPacketMarkdown(packet: HumanReviewPacket, options?: HumanReviewPacketMarkdownOptions): string;
|
|
76
|
-
declare function createHumanReviewPacketArtifacts(proofOrPacket: unknown, options?: HumanReviewPacketMarkdownOptions): HumanReviewPacketArtifacts;
|
|
77
|
-
|
|
78
|
-
export { type HumanReviewPacket, type HumanReviewPacketArtifacts, type HumanReviewPacketMarkdownOptions, RIDDLE_PROOF_PACK_MANIFEST, RIDDLE_PROOF_PACK_PROFILES, type RiddleProofPackProfileManifest, createHumanReviewPacketArtifacts, findHumanReviewPacket, formatHumanReviewPacketMarkdown, getPackEnabledRiddleProofPackProfiles, getRiddleProofPackProfile, getRiddleProofPackProfileByPackId, getRiddleProofPackProfileManifest, getRiddleProofProfilesByPackId, instantiateRiddleProofProfile, listRiddleProofPackProfiles, listRiddleProofPacks, requireHumanReviewPacket };
|
|
63
|
+
export { RIDDLE_PROOF_PACK_MANIFEST, RIDDLE_PROOF_PACK_PROFILES, type RiddleProofPackProfileManifest, getPackEnabledRiddleProofPackProfiles, getRiddleProofPackProfile, getRiddleProofPackProfileByPackId, getRiddleProofPackProfileManifest, getRiddleProofProfilesByPackId, instantiateRiddleProofProfile, listRiddleProofPackProfiles, listRiddleProofPacks };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as _riddledc_riddle_proof from '@riddledc/riddle-proof';
|
|
2
2
|
import { RiddleProofProfile } from '@riddledc/riddle-proof';
|
|
3
|
+
export { H as HumanReviewPacket, a as HumanReviewPacketArtifacts, b as HumanReviewPacketMarkdownOptions, c as createHumanReviewPacketArtifacts, f as findHumanReviewPacket, d as formatHumanReviewPacketMarkdown, r as requireHumanReviewPacket } from './humanReviewPacket-APSxuvat.js';
|
|
3
4
|
|
|
4
5
|
interface RiddleProofPackProfileManifest {
|
|
5
6
|
/** Profile slug and canonical manifest key. */
|
|
@@ -59,20 +60,4 @@ interface RiddleProofPackProfileOverrides {
|
|
|
59
60
|
*/
|
|
60
61
|
declare function instantiateRiddleProofProfile(profileName: string, options?: RiddleProofPackProfileOverrides): RiddleProofProfile;
|
|
61
62
|
|
|
62
|
-
type
|
|
63
|
-
kind: "human_review_packet";
|
|
64
|
-
};
|
|
65
|
-
interface HumanReviewPacketMarkdownOptions {
|
|
66
|
-
title?: string;
|
|
67
|
-
}
|
|
68
|
-
interface HumanReviewPacketArtifacts {
|
|
69
|
-
packet: HumanReviewPacket;
|
|
70
|
-
json: string;
|
|
71
|
-
markdown: string;
|
|
72
|
-
}
|
|
73
|
-
declare function findHumanReviewPacket(value: unknown): HumanReviewPacket | null;
|
|
74
|
-
declare function requireHumanReviewPacket(value: unknown): HumanReviewPacket;
|
|
75
|
-
declare function formatHumanReviewPacketMarkdown(packet: HumanReviewPacket, options?: HumanReviewPacketMarkdownOptions): string;
|
|
76
|
-
declare function createHumanReviewPacketArtifacts(proofOrPacket: unknown, options?: HumanReviewPacketMarkdownOptions): HumanReviewPacketArtifacts;
|
|
77
|
-
|
|
78
|
-
export { type HumanReviewPacket, type HumanReviewPacketArtifacts, type HumanReviewPacketMarkdownOptions, RIDDLE_PROOF_PACK_MANIFEST, RIDDLE_PROOF_PACK_PROFILES, type RiddleProofPackProfileManifest, createHumanReviewPacketArtifacts, findHumanReviewPacket, formatHumanReviewPacketMarkdown, getPackEnabledRiddleProofPackProfiles, getRiddleProofPackProfile, getRiddleProofPackProfileByPackId, getRiddleProofPackProfileManifest, getRiddleProofProfilesByPackId, instantiateRiddleProofProfile, listRiddleProofPackProfiles, listRiddleProofPacks, requireHumanReviewPacket };
|
|
63
|
+
export { RIDDLE_PROOF_PACK_MANIFEST, RIDDLE_PROOF_PACK_PROFILES, type RiddleProofPackProfileManifest, getPackEnabledRiddleProofPackProfiles, getRiddleProofPackProfile, getRiddleProofPackProfileByPackId, getRiddleProofPackProfileManifest, getRiddleProofProfilesByPackId, instantiateRiddleProofProfile, listRiddleProofPackProfiles, listRiddleProofPacks };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createHumanReviewPacketArtifacts,
|
|
3
|
+
findHumanReviewPacket,
|
|
4
|
+
formatHumanReviewPacketMarkdown,
|
|
5
|
+
requireHumanReviewPacket
|
|
6
|
+
} from "./chunk-XQ2N4EYF.js";
|
|
7
|
+
|
|
1
8
|
// src/pack-data.ts
|
|
2
9
|
import { normalizeRiddleProofProfile } from "@riddledc/riddle-proof";
|
|
3
10
|
|
|
@@ -2310,135 +2317,6 @@ function instantiateRiddleProofProfile(profileName, options = {}) {
|
|
|
2310
2317
|
}
|
|
2311
2318
|
);
|
|
2312
2319
|
}
|
|
2313
|
-
|
|
2314
|
-
// src/humanReviewPacket.ts
|
|
2315
|
-
var isRecord2 = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
2316
|
-
var asRecord = (value) => isRecord2(value) ? value : null;
|
|
2317
|
-
var asArray = (value) => Array.isArray(value) ? value : [];
|
|
2318
|
-
var getPath = (value, path) => {
|
|
2319
|
-
let cursor = value;
|
|
2320
|
-
for (const part of path.split(".")) {
|
|
2321
|
-
if (!isRecord2(cursor)) return void 0;
|
|
2322
|
-
cursor = cursor[part];
|
|
2323
|
-
}
|
|
2324
|
-
return cursor;
|
|
2325
|
-
};
|
|
2326
|
-
var formatValue = (value) => {
|
|
2327
|
-
if (value === null || value === void 0 || value === "") return "not captured";
|
|
2328
|
-
if (typeof value === "number") return Number.isInteger(value) ? String(value) : String(Number(value.toFixed(4)));
|
|
2329
|
-
if (typeof value === "boolean") return value ? "true" : "false";
|
|
2330
|
-
return String(value);
|
|
2331
|
-
};
|
|
2332
|
-
var formatCodeValue = (value) => `\`${formatValue(value)}\``;
|
|
2333
|
-
var formatAction = (action) => {
|
|
2334
|
-
const record = asRecord(action);
|
|
2335
|
-
if (!record) return "not captured";
|
|
2336
|
-
const type = record.type ?? "set_mixer_level";
|
|
2337
|
-
const track = record.track ?? "track";
|
|
2338
|
-
const from = formatValue(record.from);
|
|
2339
|
-
const to = formatValue(record.to);
|
|
2340
|
-
const delta = record.delta === null || record.delta === void 0 ? "" : ` (${formatValue(record.delta)})`;
|
|
2341
|
-
return `${type} ${track}: ${from} -> ${to}${delta}`;
|
|
2342
|
-
};
|
|
2343
|
-
var addOptionalList = (lines, heading, values) => {
|
|
2344
|
-
const entries = asArray(values).filter((entry) => entry !== null && entry !== void 0 && entry !== "");
|
|
2345
|
-
if (!entries.length) return;
|
|
2346
|
-
lines.push("", `## ${heading}`, "");
|
|
2347
|
-
for (const entry of entries) lines.push(`- ${formatValue(entry)}`);
|
|
2348
|
-
};
|
|
2349
|
-
function findHumanReviewPacket(value) {
|
|
2350
|
-
if (!value || typeof value !== "object") return null;
|
|
2351
|
-
if (isRecord2(value) && value.kind === "human_review_packet") return value;
|
|
2352
|
-
if (Array.isArray(value)) {
|
|
2353
|
-
for (const entry of value) {
|
|
2354
|
-
const packet = findHumanReviewPacket(entry);
|
|
2355
|
-
if (packet) return packet;
|
|
2356
|
-
}
|
|
2357
|
-
return null;
|
|
2358
|
-
}
|
|
2359
|
-
for (const entry of Object.values(value)) {
|
|
2360
|
-
const packet = findHumanReviewPacket(entry);
|
|
2361
|
-
if (packet) return packet;
|
|
2362
|
-
}
|
|
2363
|
-
return null;
|
|
2364
|
-
}
|
|
2365
|
-
function requireHumanReviewPacket(value) {
|
|
2366
|
-
const packet = findHumanReviewPacket(value);
|
|
2367
|
-
if (!packet) throw new Error("No human_review_packet found");
|
|
2368
|
-
return packet;
|
|
2369
|
-
}
|
|
2370
|
-
function formatHumanReviewPacketMarkdown(packet, options = {}) {
|
|
2371
|
-
if (packet.kind !== "human_review_packet") {
|
|
2372
|
-
throw new Error("Expected a human_review_packet");
|
|
2373
|
-
}
|
|
2374
|
-
const recommendation = asRecord(packet.recommendation) ?? {};
|
|
2375
|
-
const candidate = asRecord(recommendation.candidate) ?? {};
|
|
2376
|
-
const guardrails = asRecord(packet.guardrails) ?? {};
|
|
2377
|
-
const ranking = asRecord(packet.ranking) ?? {};
|
|
2378
|
-
const request = asRecord(packet.request) ?? {};
|
|
2379
|
-
const supportedCandidates = asArray(packet.supportedCandidates);
|
|
2380
|
-
const rejectedCandidates = asArray(packet.rejectedCandidates);
|
|
2381
|
-
const selectedSong = getPath(packet, "target.selectedSong.selectedSong") ?? getPath(packet, "target.routeState.selectedSong");
|
|
2382
|
-
const lines = [
|
|
2383
|
-
`# ${options.title ?? "Human Review Packet"}`,
|
|
2384
|
-
"",
|
|
2385
|
-
`- status: ${formatCodeValue(packet.status)}`,
|
|
2386
|
-
`- domain: ${formatCodeValue(packet.domain)}`,
|
|
2387
|
-
`- evidence_role_pattern: ${formatCodeValue(packet.evidenceRolePattern)}`,
|
|
2388
|
-
`- requested_intent: ${formatValue(packet.requestedIntent)}`,
|
|
2389
|
-
`- selected_song: ${formatValue(selectedSong)}`,
|
|
2390
|
-
"",
|
|
2391
|
-
"## Recommendation",
|
|
2392
|
-
"",
|
|
2393
|
-
`- action: ${formatCodeValue(recommendation.action)}`,
|
|
2394
|
-
`- candidate: ${formatCodeValue(candidate.label)}`,
|
|
2395
|
-
`- candidate_action: ${formatCodeValue(formatAction(candidate.action))}`,
|
|
2396
|
-
`- reason: ${formatValue(recommendation.reason)}`,
|
|
2397
|
-
"",
|
|
2398
|
-
"## Objective Receipts",
|
|
2399
|
-
"",
|
|
2400
|
-
`- supported_candidates: ${formatCodeValue(guardrails.supportedClaimCandidateCount ?? supportedCandidates.length)}`,
|
|
2401
|
-
`- rejected_candidates: ${formatCodeValue(guardrails.rejectedCandidateCount ?? rejectedCandidates.length)}`,
|
|
2402
|
-
`- state_restored_after_loop: ${formatCodeValue(guardrails.stateRestoredAfterLoop)}`,
|
|
2403
|
-
`- candidate_actions_are_transient: ${formatCodeValue(request.candidateActionsAreTransient)}`,
|
|
2404
|
-
`- no_permanent_edit_unless_apply_best: ${formatCodeValue(guardrails.noPermanentEditUnlessApplyBest)}`,
|
|
2405
|
-
"",
|
|
2406
|
-
"## Ranking",
|
|
2407
|
-
"",
|
|
2408
|
-
`- metric: ${formatCodeValue(ranking.metric)}`,
|
|
2409
|
-
`- role: ${formatCodeValue(ranking.role)}`,
|
|
2410
|
-
`- lower_is_better: ${formatCodeValue(ranking.lowerIsBetter)}`,
|
|
2411
|
-
`- baseline: ${formatCodeValue(ranking.baselineCandidateRankingMetric)}`,
|
|
2412
|
-
`- best: ${formatCodeValue(ranking.bestCandidateRankingMetric)}`,
|
|
2413
|
-
`- delta: ${formatCodeValue(ranking.rankingMetricDelta)}`,
|
|
2414
|
-
"",
|
|
2415
|
-
"## Boundary",
|
|
2416
|
-
"",
|
|
2417
|
-
formatValue(packet.proofBoundary)
|
|
2418
|
-
];
|
|
2419
|
-
addOptionalList(lines, "Listening Prompts", packet.listenerPrompts);
|
|
2420
|
-
addOptionalList(lines, "Caveats", packet.caveats);
|
|
2421
|
-
if (rejectedCandidates.length) {
|
|
2422
|
-
lines.push("", "## Rejected Candidates", "");
|
|
2423
|
-
for (const entry of rejectedCandidates) {
|
|
2424
|
-
const rejected = asRecord(entry) ?? {};
|
|
2425
|
-
const failedReceipts = asArray(rejected.failedReceipts).map(formatValue).join(", ") || "not captured";
|
|
2426
|
-
lines.push(`- ${formatCodeValue(rejected.label)}: ${failedReceipts}`);
|
|
2427
|
-
}
|
|
2428
|
-
}
|
|
2429
|
-
return `${lines.join("\n")}
|
|
2430
|
-
`;
|
|
2431
|
-
}
|
|
2432
|
-
function createHumanReviewPacketArtifacts(proofOrPacket, options = {}) {
|
|
2433
|
-
const packet = requireHumanReviewPacket(proofOrPacket);
|
|
2434
|
-
const markdown = formatHumanReviewPacketMarkdown(packet, options);
|
|
2435
|
-
return {
|
|
2436
|
-
packet,
|
|
2437
|
-
json: `${JSON.stringify(packet, null, 2)}
|
|
2438
|
-
`,
|
|
2439
|
-
markdown
|
|
2440
|
-
};
|
|
2441
|
-
}
|
|
2442
2320
|
export {
|
|
2443
2321
|
RIDDLE_PROOF_PACK_MANIFEST,
|
|
2444
2322
|
RIDDLE_PROOF_PACK_PROFILES,
|
|
@@ -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"
|