@riddledc/riddle-proof 0.5.46 → 0.5.48

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 CHANGED
@@ -63,9 +63,10 @@ Codex/CLI-style testing:
63
63
 
64
64
  ```sh
65
65
  riddle-proof-loop run --request-json request.json --checkpoint-mode yield
66
+ riddle-proof-loop run --request-json request.json --agent local
66
67
  riddle-proof-loop status --state-path /tmp/riddle-proof-run.json
67
68
  riddle-proof-loop respond --state-path /tmp/riddle-proof-run.json --response-json response.json
68
- riddle-proof-loop doctor codex_exec
69
+ riddle-proof-loop doctor local
69
70
  ```
70
71
 
71
72
  In yield mode, the harness returns portable checkpoint packets for recon,
@@ -73,6 +74,10 @@ authoring, implementation, proof assessment, and evidence recovery. A host can
73
74
  answer those packets with `riddle-proof.checkpoint_response.v1` JSON without
74
75
  needing OpenClaw-specific proof semantics.
75
76
 
77
+ `--agent local` is the generic CLI executor slot. The current implementation
78
+ uses the local Codex CLI adapter underneath, but the loop contract and CLI
79
+ surface are intentionally not Codex-specific.
80
+
76
81
  ## Runner Harness
77
82
 
78
83
  `runRiddleProof` is the reusable idea-to-PR workflow driver. It does not ship
@@ -10,7 +10,7 @@ import {
10
10
  createRunStatusSnapshot,
11
11
  normalizeRunParams,
12
12
  setRunStatus
13
- } from "./chunk-JTNMEH57.js";
13
+ } from "./chunk-JOXTKWX6.js";
14
14
  import {
15
15
  createRiddleProofRunCard
16
16
  } from "./chunk-PLSGW2GI.js";
@@ -281,6 +281,20 @@ function checkpointContinueStage(result) {
281
281
  const resume = recordValue(result.checkpointContract?.resume);
282
282
  return nonEmptyString(resume?.continue_with_stage);
283
283
  }
284
+ function checkpointRecommendedStage(result) {
285
+ const resumeStage = checkpointContinueStage(result);
286
+ if (resumeStage) return resumeStage;
287
+ return nonEmptyString(result.checkpointContract?.recommended_advance_stage) || nonEmptyString(result.decisionRequest?.continue_with_stage) || nonEmptyString(result.decisionRequest?.recommended_advance_stage) || nonEmptyString(recordValue(result.decisionRequest)?.continueWithStage) || nonEmptyString(recordValue(result.decisionRequest)?.recommendedAdvanceStage);
288
+ }
289
+ function stageCheckpointContinuation(result) {
290
+ const stage = checkpointRecommendedStage(result);
291
+ if (!stage) return null;
292
+ return {
293
+ action: "run",
294
+ state_path: String(result.state_path || ""),
295
+ advance_stage: stage
296
+ };
297
+ }
284
298
  function recommendedContinuation(result) {
285
299
  const continueStage = checkpointContinueStage(result);
286
300
  if (!continueStage) return null;
@@ -323,6 +337,18 @@ function defaultStageForProofCheckpointDecision(decision) {
323
337
  if (decision === "needs_richer_proof") return "author";
324
338
  return null;
325
339
  }
340
+ function checkpointContractFromPacket(packet) {
341
+ return recordValue(packet.evidence_excerpt?.checkpoint_contract) || recordValue(recordValue(packet.state_excerpt?.stage_decision_request)?.checkpoint_contract) || null;
342
+ }
343
+ function stageFromCheckpointResponse(response, packet) {
344
+ if (response.decision === "needs_recon") return "recon";
345
+ if (response.decision === "needs_implementation") return "implement";
346
+ const payload = recordValue(response.payload) || {};
347
+ const contract = checkpointContractFromPacket(packet);
348
+ const resume = recordValue(contract?.resume);
349
+ const stage = response.continue_with_stage || nonEmptyString(payload.continue_with_stage) || nonEmptyString(payload.recommended_stage) || nonEmptyString(resume?.continue_with_stage) || (response.decision === "retry_stage" ? packet.stage : "");
350
+ return stage ? stage : null;
351
+ }
326
352
  function proofAssessmentPayloadFromCheckpointResponse(response) {
327
353
  if (![
328
354
  "ready_to_ship",
@@ -425,6 +451,13 @@ function visualDeltaEvidenceRecoveryAssessment(state, payload, blocker) {
425
451
  blockers: [...blockers, blocker]
426
452
  };
427
453
  }
454
+ function isRecoverableStageCheckpoint(checkpoint) {
455
+ return [
456
+ "ship_gate_blocked",
457
+ "verify_required",
458
+ "verify_supervisor_judgment_required"
459
+ ].includes(checkpoint);
460
+ }
428
461
  function contextFor(request, state, result) {
429
462
  return {
430
463
  request,
@@ -771,6 +804,18 @@ function checkpointResponseContinuation(state, value) {
771
804
  };
772
805
  }
773
806
  }
807
+ if (response.decision === "continue_stage" || response.decision === "retry_stage" || response.decision === "needs_implementation") {
808
+ const stage = stageFromCheckpointResponse(response, packet);
809
+ if (stage) {
810
+ appendCheckpointResponse(state, response);
811
+ return {
812
+ next: {
813
+ ...base,
814
+ advance_stage: stage
815
+ }
816
+ };
817
+ }
818
+ }
774
819
  appendCheckpointResponse(state, response, { clear_packet: false });
775
820
  return {
776
821
  blocker: {
@@ -893,18 +938,23 @@ async function handleImplementation(request, state, result, agent) {
893
938
  adapter_details: implementation.details || null
894
939
  })
895
940
  });
896
- return {
897
- blocker: {
898
- code: "implementation_diff_missing",
941
+ recordEvent(state, {
942
+ kind: "agent.implementation.retry_requested",
943
+ checkpoint: result.checkpoint || null,
944
+ stage: "implement",
945
+ summary: "Implementation adapter left no detectable diff; retrying the implement checkpoint inside the bounded loop.",
946
+ details: compactRecord({
947
+ worktree_path: workdir || null,
899
948
  checkpoint: result.checkpoint || null,
900
- message: "The implementation adapter returned, but the after worktree has no detectable git diff. The harness will not advance to verify.",
901
- details: compactRecord({
902
- worktree_path: workdir || null,
903
- changed_files: implementation.changedFiles || [],
904
- tests_run: implementation.testsRun || [],
905
- implementation_notes: implementation.implementationNotes || null,
906
- adapter_details: implementation.details || null
907
- })
949
+ next_stage: "implement"
950
+ })
951
+ });
952
+ return {
953
+ next: {
954
+ action: "run",
955
+ state_path: String(result.state_path || ""),
956
+ advance_stage: "implement",
957
+ implementation_notes: implementation.implementationNotes || implementation.summary || "Implementation adapter returned without a detectable git diff; retry the implement checkpoint."
908
958
  }
909
959
  };
910
960
  }
@@ -940,16 +990,32 @@ async function routeCheckpoint(request, state, result, agent, input) {
940
990
  terminal: terminalResult(state, "completed", result, result.summary || "Riddle Proof engine completed.")
941
991
  };
942
992
  }
993
+ if (isRecoverableStageCheckpoint(checkpoint) && !input.dry_run && !request.dry_run) {
994
+ if (input.checkpoint_mode === "yield") {
995
+ return { terminal: checkpointAwaitingResult(state, result, input.checkpoint_visibility) };
996
+ }
997
+ const next = stageCheckpointContinuation(result);
998
+ if (next) {
999
+ recordEvent(state, {
1000
+ kind: "checkpoint.recovery_continuation",
1001
+ checkpoint,
1002
+ stage: stageFromCheckpoint(result),
1003
+ summary: `Routing recoverable checkpoint ${checkpoint} back to ${next.advance_stage}.`,
1004
+ details: {
1005
+ next,
1006
+ checkpointContract: result.checkpointContract || null
1007
+ }
1008
+ });
1009
+ return { next };
1010
+ }
1011
+ }
943
1012
  const failureBlocker = engineFailureBlocker(result, checkpoint);
944
1013
  if (failureBlocker) {
945
1014
  return { blocker: failureBlocker };
946
1015
  }
947
1016
  if ([
948
1017
  "recon_human_escalation",
949
- "verify_human_escalation",
950
- "ship_gate_blocked",
951
- "verify_required",
952
- "verify_supervisor_judgment_required"
1018
+ "verify_human_escalation"
953
1019
  ].includes(checkpoint) && result.ok === false) {
954
1020
  return {
955
1021
  blocker: {
File without changes
@@ -213,7 +213,7 @@ function createRunStatusSnapshot(state, at = timestamp()) {
213
213
  checkpoint_summary: state.checkpoint_summary,
214
214
  state_paths: state.state_paths,
215
215
  proof_contract: state.proof_contract,
216
- run_card: createRiddleProofRunCard(state, { at }),
216
+ run_card: state.run_card || createRiddleProofRunCard(state, { at }),
217
217
  latest_event: latestEvent
218
218
  });
219
219
  }
@@ -3,7 +3,7 @@ import {
3
3
  appendStageHeartbeat,
4
4
  createRunState,
5
5
  setRunStatus
6
- } from "./chunk-JTNMEH57.js";
6
+ } from "./chunk-JOXTKWX6.js";
7
7
  import {
8
8
  createRunResult
9
9
  } from "./chunk-DUFDZJOF.js";
package/dist/cli.cjs CHANGED
@@ -1747,9 +1747,27 @@ async function executeWorkflow(params, pluginConfig, resolvedConfig) {
1747
1747
  }
1748
1748
  return "inspect the ship gate details, repair the missing invariant, then resume the run";
1749
1749
  };
1750
+ const shipGateRecoveryStage = (shipGate) => {
1751
+ const reasons = shipGate.reasons || [];
1752
+ if (reasons.some((reason) => reason.includes("before_cdn") || reason.includes("prod_cdn") || reason.includes("prod_url"))) {
1753
+ return "recon";
1754
+ }
1755
+ if (reasons.some((reason) => reason.includes("implementation"))) {
1756
+ return "implement";
1757
+ }
1758
+ if (reasons.some((reason) => reason.includes("after_cdn") || reason.includes("verify_status") || reason.includes("visual_delta"))) {
1759
+ return "verify";
1760
+ }
1761
+ if (reasons.some((reason) => reason.includes("proof_assessment"))) {
1762
+ return "verify";
1763
+ }
1764
+ return "verify";
1765
+ };
1750
1766
  const shipGateBlocked = (state, executed, details = {}) => {
1751
1767
  const shipGate = validateShipGate(state);
1752
1768
  const nextAction = primaryShipGateNextAction(shipGate);
1769
+ const recoveryStage = shipGateRecoveryStage(shipGate);
1770
+ const advanceOptions = Array.from(/* @__PURE__ */ new Set([recoveryStage, "verify", "author", "implement", "recon", "ship"]));
1753
1771
  return checkpoint(
1754
1772
  "verify",
1755
1773
  "ship_gate_blocked",
@@ -1757,12 +1775,13 @@ async function executeWorkflow(params, pluginConfig, resolvedConfig) {
1757
1775
  {
1758
1776
  ok: false,
1759
1777
  nextActions: ["inspect_ship_gate", "advance_run_to_verify", "supply_proof_assessment_json", "return_to_recon_if_baseline_is_missing"],
1760
- advanceOptions: ["verify", "author", "implement", "recon"],
1761
- recommendedAdvanceStage: "verify",
1762
- continueWithStage: "verify",
1778
+ advanceOptions,
1779
+ recommendedAdvanceStage: recoveryStage,
1780
+ continueWithStage: recoveryStage,
1763
1781
  blocking: true,
1764
- details: { ...details, shipGate, next_action: nextAction, executed },
1782
+ details: { ...details, shipGate, next_action: nextAction, recovery_stage: recoveryStage, executed },
1765
1783
  nextAction,
1784
+ recoveryStage,
1766
1785
  shipGate,
1767
1786
  verifyStatus: state?.verify_status || null,
1768
1787
  mergeRecommendation: state?.merge_recommendation || null,
@@ -3931,7 +3950,7 @@ function createRunStatusSnapshot(state, at = timestamp2()) {
3931
3950
  checkpoint_summary: state.checkpoint_summary,
3932
3951
  state_paths: state.state_paths,
3933
3952
  proof_contract: state.proof_contract,
3934
- run_card: createRiddleProofRunCard(state, { at }),
3953
+ run_card: state.run_card || createRiddleProofRunCard(state, { at }),
3935
3954
  latest_event: latestEvent
3936
3955
  });
3937
3956
  }
@@ -4180,6 +4199,20 @@ function checkpointContinueStage2(result) {
4180
4199
  const resume = recordValue(result.checkpointContract?.resume);
4181
4200
  return nonEmptyString(resume?.continue_with_stage);
4182
4201
  }
4202
+ function checkpointRecommendedStage(result) {
4203
+ const resumeStage = checkpointContinueStage2(result);
4204
+ if (resumeStage) return resumeStage;
4205
+ return nonEmptyString(result.checkpointContract?.recommended_advance_stage) || nonEmptyString(result.decisionRequest?.continue_with_stage) || nonEmptyString(result.decisionRequest?.recommended_advance_stage) || nonEmptyString(recordValue(result.decisionRequest)?.continueWithStage) || nonEmptyString(recordValue(result.decisionRequest)?.recommendedAdvanceStage);
4206
+ }
4207
+ function stageCheckpointContinuation(result) {
4208
+ const stage = checkpointRecommendedStage(result);
4209
+ if (!stage) return null;
4210
+ return {
4211
+ action: "run",
4212
+ state_path: String(result.state_path || ""),
4213
+ advance_stage: stage
4214
+ };
4215
+ }
4183
4216
  function recommendedContinuation(result) {
4184
4217
  const continueStage = checkpointContinueStage2(result);
4185
4218
  if (!continueStage) return null;
@@ -4222,6 +4255,18 @@ function defaultStageForProofCheckpointDecision(decision) {
4222
4255
  if (decision === "needs_richer_proof") return "author";
4223
4256
  return null;
4224
4257
  }
4258
+ function checkpointContractFromPacket(packet) {
4259
+ return recordValue(packet.evidence_excerpt?.checkpoint_contract) || recordValue(recordValue(packet.state_excerpt?.stage_decision_request)?.checkpoint_contract) || null;
4260
+ }
4261
+ function stageFromCheckpointResponse(response, packet) {
4262
+ if (response.decision === "needs_recon") return "recon";
4263
+ if (response.decision === "needs_implementation") return "implement";
4264
+ const payload = recordValue(response.payload) || {};
4265
+ const contract = checkpointContractFromPacket(packet);
4266
+ const resume = recordValue(contract?.resume);
4267
+ const stage = response.continue_with_stage || nonEmptyString(payload.continue_with_stage) || nonEmptyString(payload.recommended_stage) || nonEmptyString(resume?.continue_with_stage) || (response.decision === "retry_stage" ? packet.stage : "");
4268
+ return stage ? stage : null;
4269
+ }
4225
4270
  function proofAssessmentPayloadFromCheckpointResponse(response) {
4226
4271
  if (![
4227
4272
  "ready_to_ship",
@@ -4324,6 +4369,13 @@ function visualDeltaEvidenceRecoveryAssessment(state, payload, blocker) {
4324
4369
  blockers: [...blockers, blocker]
4325
4370
  };
4326
4371
  }
4372
+ function isRecoverableStageCheckpoint(checkpoint) {
4373
+ return [
4374
+ "ship_gate_blocked",
4375
+ "verify_required",
4376
+ "verify_supervisor_judgment_required"
4377
+ ].includes(checkpoint);
4378
+ }
4327
4379
  function contextFor(request, state, result) {
4328
4380
  return {
4329
4381
  request,
@@ -4670,6 +4722,18 @@ function checkpointResponseContinuation(state, value) {
4670
4722
  };
4671
4723
  }
4672
4724
  }
4725
+ if (response.decision === "continue_stage" || response.decision === "retry_stage" || response.decision === "needs_implementation") {
4726
+ const stage = stageFromCheckpointResponse(response, packet);
4727
+ if (stage) {
4728
+ appendCheckpointResponse(state, response);
4729
+ return {
4730
+ next: {
4731
+ ...base,
4732
+ advance_stage: stage
4733
+ }
4734
+ };
4735
+ }
4736
+ }
4673
4737
  appendCheckpointResponse(state, response, { clear_packet: false });
4674
4738
  return {
4675
4739
  blocker: {
@@ -4792,18 +4856,23 @@ async function handleImplementation(request, state, result, agent) {
4792
4856
  adapter_details: implementation.details || null
4793
4857
  })
4794
4858
  });
4795
- return {
4796
- blocker: {
4797
- code: "implementation_diff_missing",
4859
+ recordEvent(state, {
4860
+ kind: "agent.implementation.retry_requested",
4861
+ checkpoint: result.checkpoint || null,
4862
+ stage: "implement",
4863
+ summary: "Implementation adapter left no detectable diff; retrying the implement checkpoint inside the bounded loop.",
4864
+ details: compactRecord({
4865
+ worktree_path: workdir || null,
4798
4866
  checkpoint: result.checkpoint || null,
4799
- message: "The implementation adapter returned, but the after worktree has no detectable git diff. The harness will not advance to verify.",
4800
- details: compactRecord({
4801
- worktree_path: workdir || null,
4802
- changed_files: implementation.changedFiles || [],
4803
- tests_run: implementation.testsRun || [],
4804
- implementation_notes: implementation.implementationNotes || null,
4805
- adapter_details: implementation.details || null
4806
- })
4867
+ next_stage: "implement"
4868
+ })
4869
+ });
4870
+ return {
4871
+ next: {
4872
+ action: "run",
4873
+ state_path: String(result.state_path || ""),
4874
+ advance_stage: "implement",
4875
+ implementation_notes: implementation.implementationNotes || implementation.summary || "Implementation adapter returned without a detectable git diff; retry the implement checkpoint."
4807
4876
  }
4808
4877
  };
4809
4878
  }
@@ -4839,16 +4908,32 @@ async function routeCheckpoint(request, state, result, agent, input) {
4839
4908
  terminal: terminalResult(state, "completed", result, result.summary || "Riddle Proof engine completed.")
4840
4909
  };
4841
4910
  }
4911
+ if (isRecoverableStageCheckpoint(checkpoint) && !input.dry_run && !request.dry_run) {
4912
+ if (input.checkpoint_mode === "yield") {
4913
+ return { terminal: checkpointAwaitingResult(state, result, input.checkpoint_visibility) };
4914
+ }
4915
+ const next = stageCheckpointContinuation(result);
4916
+ if (next) {
4917
+ recordEvent(state, {
4918
+ kind: "checkpoint.recovery_continuation",
4919
+ checkpoint,
4920
+ stage: stageFromCheckpoint2(result),
4921
+ summary: `Routing recoverable checkpoint ${checkpoint} back to ${next.advance_stage}.`,
4922
+ details: {
4923
+ next,
4924
+ checkpointContract: result.checkpointContract || null
4925
+ }
4926
+ });
4927
+ return { next };
4928
+ }
4929
+ }
4842
4930
  const failureBlocker = engineFailureBlocker(result, checkpoint);
4843
4931
  if (failureBlocker) {
4844
4932
  return { blocker: failureBlocker };
4845
4933
  }
4846
4934
  if ([
4847
4935
  "recon_human_escalation",
4848
- "verify_human_escalation",
4849
- "ship_gate_blocked",
4850
- "verify_required",
4851
- "verify_supervisor_judgment_required"
4936
+ "verify_human_escalation"
4852
4937
  ].includes(checkpoint) && result.ok === false) {
4853
4938
  return {
4854
4939
  blocker: {
@@ -5988,12 +6073,13 @@ async function runCodexExecAgentDoctor(config = {}, runner = createCodexExecJson
5988
6073
  function usage() {
5989
6074
  return [
5990
6075
  "Usage:",
5991
- " riddle-proof-loop run --request-json <file|json|-> [--agent disabled|codex_exec] [--checkpoint-mode yield|auto]",
6076
+ " riddle-proof-loop run --request-json <file|json|-> [--agent disabled|local] [--checkpoint-mode yield|auto]",
5992
6077
  " riddle-proof-loop respond --state-path <path> --response-json <file|json|->",
5993
6078
  " riddle-proof-loop status --state-path <path>",
5994
- " riddle-proof-loop doctor codex_exec [--codex-command <path>]",
6079
+ " riddle-proof-loop doctor local [--codex-command <path>]",
5995
6080
  "",
5996
- "The default CLI run mode is checkpoint-mode=yield unless --agent codex_exec is used."
6081
+ "The default CLI run mode is checkpoint-mode=yield unless --agent local is used.",
6082
+ "Compatibility aliases: --agent codex_exec and doctor codex_exec."
5997
6083
  ].join("\n");
5998
6084
  }
5999
6085
  function parseArgs(argv) {
@@ -6050,11 +6136,14 @@ function codexConfig(options) {
6050
6136
  codexFullAuto: codexFullAuto === "false" ? false : void 0
6051
6137
  };
6052
6138
  }
6139
+ function isLocalAgentMode(value) {
6140
+ return value === "local" || value === "local_exec" || value === "codex_exec";
6141
+ }
6053
6142
  function agentFor(options) {
6054
6143
  const agentMode = optionString(options, "agent") || "disabled";
6055
- if (agentMode === "codex_exec") return createCodexExecAgentAdapter(codexConfig(options));
6144
+ if (isLocalAgentMode(agentMode)) return createCodexExecAgentAdapter(codexConfig(options));
6056
6145
  if (agentMode === "disabled") return createDisabledRiddleProofAgentAdapter();
6057
- throw new Error(`Unsupported --agent ${agentMode}. Use disabled or codex_exec.`);
6146
+ throw new Error(`Unsupported --agent ${agentMode}. Use disabled or local.`);
6058
6147
  }
6059
6148
  function requestForRun(options) {
6060
6149
  const statePath = optionString(options, "statePath");
@@ -6067,7 +6156,7 @@ function requestForRun(options) {
6067
6156
  function checkpointModeFor(options) {
6068
6157
  const explicit = optionString(options, "checkpointMode");
6069
6158
  if (explicit) return explicit;
6070
- return optionString(options, "agent") === "codex_exec" ? "auto" : "yield";
6159
+ return isLocalAgentMode(optionString(options, "agent")) ? "auto" : "yield";
6071
6160
  }
6072
6161
  async function main() {
6073
6162
  const { positional, options } = parseArgs(process.argv.slice(2));
@@ -6079,7 +6168,7 @@ async function main() {
6079
6168
  }
6080
6169
  if (command === "doctor") {
6081
6170
  const subject = positional[1];
6082
- if (subject !== "codex_exec") throw new Error("Only `doctor codex_exec` is supported.");
6171
+ if (!isLocalAgentMode(subject)) throw new Error("Only `doctor local` is supported.");
6083
6172
  const result = await runCodexExecAgentDoctor(codexConfig(options));
6084
6173
  process.stdout.write(`${JSON.stringify(result, null, 2)}
6085
6174
  `);
@@ -6109,6 +6198,7 @@ async function main() {
6109
6198
  agent: agentFor(options),
6110
6199
  config: {
6111
6200
  stateDir: optionString(options, "stateDir"),
6201
+ riddleEngineModuleUrl: optionString(options, "riddleEngineModuleUrl"),
6112
6202
  riddleProofDir: optionString(options, "riddleProofDir"),
6113
6203
  defaultReviewer: optionString(options, "defaultReviewer"),
6114
6204
  defaultShipMode: optionString(options, "defaultShipMode")
package/dist/cli.js CHANGED
@@ -1,15 +1,16 @@
1
1
  #!/usr/bin/env node
2
- import {
3
- createCodexExecAgentAdapter,
4
- runCodexExecAgentDoctor
5
- } from "./chunk-NOBFZDZG.js";
6
2
  import {
7
3
  createDisabledRiddleProofAgentAdapter,
8
4
  readRiddleProofRunStatus,
9
5
  runRiddleProofEngineHarness
10
- } from "./chunk-X3AQ2WUM.js";
6
+ } from "./chunk-2RS4PBYK.js";
11
7
  import "./chunk-4ASMX4R6.js";
12
- import "./chunk-JTNMEH57.js";
8
+ import "./chunk-JFQXAJH2.js";
9
+ import {
10
+ createCodexExecAgentAdapter,
11
+ runCodexExecAgentDoctor
12
+ } from "./chunk-NOBFZDZG.js";
13
+ import "./chunk-JOXTKWX6.js";
13
14
  import "./chunk-PLSGW2GI.js";
14
15
  import "./chunk-R6SCWJCI.js";
15
16
  import "./chunk-DUFDZJOF.js";
@@ -19,12 +20,13 @@ import { existsSync, readFileSync } from "fs";
19
20
  function usage() {
20
21
  return [
21
22
  "Usage:",
22
- " riddle-proof-loop run --request-json <file|json|-> [--agent disabled|codex_exec] [--checkpoint-mode yield|auto]",
23
+ " riddle-proof-loop run --request-json <file|json|-> [--agent disabled|local] [--checkpoint-mode yield|auto]",
23
24
  " riddle-proof-loop respond --state-path <path> --response-json <file|json|->",
24
25
  " riddle-proof-loop status --state-path <path>",
25
- " riddle-proof-loop doctor codex_exec [--codex-command <path>]",
26
+ " riddle-proof-loop doctor local [--codex-command <path>]",
26
27
  "",
27
- "The default CLI run mode is checkpoint-mode=yield unless --agent codex_exec is used."
28
+ "The default CLI run mode is checkpoint-mode=yield unless --agent local is used.",
29
+ "Compatibility aliases: --agent codex_exec and doctor codex_exec."
28
30
  ].join("\n");
29
31
  }
30
32
  function parseArgs(argv) {
@@ -81,11 +83,14 @@ function codexConfig(options) {
81
83
  codexFullAuto: codexFullAuto === "false" ? false : void 0
82
84
  };
83
85
  }
86
+ function isLocalAgentMode(value) {
87
+ return value === "local" || value === "local_exec" || value === "codex_exec";
88
+ }
84
89
  function agentFor(options) {
85
90
  const agentMode = optionString(options, "agent") || "disabled";
86
- if (agentMode === "codex_exec") return createCodexExecAgentAdapter(codexConfig(options));
91
+ if (isLocalAgentMode(agentMode)) return createCodexExecAgentAdapter(codexConfig(options));
87
92
  if (agentMode === "disabled") return createDisabledRiddleProofAgentAdapter();
88
- throw new Error(`Unsupported --agent ${agentMode}. Use disabled or codex_exec.`);
93
+ throw new Error(`Unsupported --agent ${agentMode}. Use disabled or local.`);
89
94
  }
90
95
  function requestForRun(options) {
91
96
  const statePath = optionString(options, "statePath");
@@ -98,7 +103,7 @@ function requestForRun(options) {
98
103
  function checkpointModeFor(options) {
99
104
  const explicit = optionString(options, "checkpointMode");
100
105
  if (explicit) return explicit;
101
- return optionString(options, "agent") === "codex_exec" ? "auto" : "yield";
106
+ return isLocalAgentMode(optionString(options, "agent")) ? "auto" : "yield";
102
107
  }
103
108
  async function main() {
104
109
  const { positional, options } = parseArgs(process.argv.slice(2));
@@ -110,7 +115,7 @@ async function main() {
110
115
  }
111
116
  if (command === "doctor") {
112
117
  const subject = positional[1];
113
- if (subject !== "codex_exec") throw new Error("Only `doctor codex_exec` is supported.");
118
+ if (!isLocalAgentMode(subject)) throw new Error("Only `doctor local` is supported.");
114
119
  const result = await runCodexExecAgentDoctor(codexConfig(options));
115
120
  process.stdout.write(`${JSON.stringify(result, null, 2)}
116
121
  `);
@@ -140,6 +145,7 @@ async function main() {
140
145
  agent: agentFor(options),
141
146
  config: {
142
147
  stateDir: optionString(options, "stateDir"),
148
+ riddleEngineModuleUrl: optionString(options, "riddleEngineModuleUrl"),
143
149
  riddleProofDir: optionString(options, "riddleProofDir"),
144
150
  defaultReviewer: optionString(options, "defaultReviewer"),
145
151
  defaultShipMode: optionString(options, "defaultShipMode")