literally-aeo 0.1.0 → 0.2.0

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.
Files changed (262) hide show
  1. package/README.md +42 -6
  2. package/dist/author-tools.js +33 -64
  3. package/dist/cli.mjs +2723 -1616
  4. package/dist/lib/agents/author-schema.js +4 -5
  5. package/dist/lib/agents/author-validation.js +5 -6
  6. package/dist/lib/agents/copy-validation.js +4 -5
  7. package/dist/lib/agents/verifier.js +8 -8
  8. package/dist/lib/analysis/domain-classifier.js +8 -8
  9. package/dist/lib/analysis/domain-labels.js +3 -4
  10. package/dist/lib/analysis/progress.js +3 -4
  11. package/dist/lib/analysis/sentiment.js +8 -8
  12. package/dist/lib/author/examples.js +5 -6
  13. package/dist/lib/bundle/contracts.js +5 -6
  14. package/dist/lib/bundle/export.js +22 -19
  15. package/dist/lib/bundle/isolation.js +17 -0
  16. package/dist/lib/bundle/journal.js +6 -7
  17. package/dist/lib/bundle/project-journal.js +11 -10
  18. package/dist/lib/bundle/project.js +19 -16
  19. package/dist/lib/bundle/read.js +23 -20
  20. package/dist/lib/bundle/recorder.js +9 -8
  21. package/dist/lib/bundle/redact.js +6 -7
  22. package/dist/lib/bundle/trace-coverage.js +6 -7
  23. package/dist/lib/bundle/verify-integrity.js +8 -9
  24. package/dist/lib/bundle/verify-measurement.js +10 -11
  25. package/dist/lib/bundle/verify-report.js +11 -12
  26. package/dist/lib/bundle/verify.js +17 -18
  27. package/dist/lib/bundle/writer-lock.js +3 -1
  28. package/dist/lib/capture-manifest.js +3 -4
  29. package/dist/lib/checks/run-checks.js +10 -9
  30. package/dist/lib/chunks/chunk-2B5QF6UQ.js +159 -0
  31. package/dist/lib/chunks/{chunk-4US3OBKJ.js → chunk-2GU6CNQI.js} +12 -7
  32. package/dist/lib/chunks/{chunk-AWOJWMPN.js → chunk-2ROXN2EC.js} +42 -7
  33. package/dist/lib/chunks/{chunk-XHWRSGX3.js → chunk-3JO5TXBA.js} +1 -1
  34. package/dist/lib/chunks/{chunk-5GZVDGTX.js → chunk-4PD65FRJ.js} +7 -3
  35. package/dist/lib/chunks/{chunk-P4K6BP3L.js → chunk-5JPYM4MD.js} +1 -1
  36. package/dist/lib/chunks/{chunk-5VNYUCLL.js → chunk-622NMXN6.js} +6 -9
  37. package/dist/lib/chunks/{chunk-4ZY6P5SO.js → chunk-663HABKP.js} +5 -5
  38. package/dist/lib/chunks/{chunk-RMFT4KKK.js → chunk-6G25V4CF.js} +1 -1
  39. package/dist/lib/chunks/{chunk-GVC4LH2N.js → chunk-6GHHNPFJ.js} +1 -1
  40. package/dist/lib/chunks/{chunk-KMRQSIZW.js → chunk-6GOBBNDU.js} +16 -1
  41. package/dist/lib/chunks/{chunk-SBAZBOPI.js → chunk-6P7EZJI7.js} +4 -2
  42. package/dist/lib/chunks/chunk-7XO3SQAX.js +117 -0
  43. package/dist/lib/chunks/{chunk-M2OD74GP.js → chunk-7Z27HQWL.js} +3 -3
  44. package/dist/lib/chunks/{chunk-IPNK7FYT.js → chunk-AYY4MYTW.js} +1 -1
  45. package/dist/lib/chunks/{chunk-WDSCJEDG.js → chunk-BE4ENGUY.js} +10 -10
  46. package/dist/lib/chunks/{chunk-FKLNEB2P.js → chunk-BGOIPHJZ.js} +39 -11
  47. package/dist/lib/chunks/{chunk-7GXRDAUY.js → chunk-BLKLPUYR.js} +2 -2
  48. package/dist/lib/chunks/chunk-BSRKN6FU.js +93 -0
  49. package/dist/lib/chunks/{chunk-PCYNBDZ7.js → chunk-CO5T6WU5.js} +14 -9
  50. package/dist/lib/chunks/{chunk-BEQLSAVX.js → chunk-CUYVHXHI.js} +2 -2
  51. package/dist/lib/chunks/{chunk-RBOO4NDG.js → chunk-D3GE3OCB.js} +1 -1
  52. package/dist/lib/chunks/chunk-DVFFYY5G.js +74 -0
  53. package/dist/lib/chunks/{chunk-5H3SNUQT.js → chunk-EBUQPCKB.js} +1 -1
  54. package/dist/lib/chunks/{chunk-4E4NDGOZ.js → chunk-EE26FNSY.js} +1 -1
  55. package/dist/lib/chunks/{chunk-AUB5THIS.js → chunk-EJ655TVU.js} +1 -1
  56. package/dist/lib/chunks/{chunk-S2AM76LT.js → chunk-F4W5YHDZ.js} +2 -2
  57. package/dist/lib/chunks/chunk-FAUFE7MI.js +31 -0
  58. package/dist/lib/chunks/{chunk-2KJZ326K.js → chunk-FOCJ7HPC.js} +7 -7
  59. package/dist/lib/chunks/{chunk-OL746E4T.js → chunk-FUAUPNRO.js} +26 -18
  60. package/dist/lib/chunks/{chunk-J6IJGYP5.js → chunk-G62E525I.js} +2 -2
  61. package/dist/lib/chunks/{chunk-2NJEWPCV.js → chunk-GDKGZQ3T.js} +2 -2
  62. package/dist/lib/chunks/{chunk-HSZ3DM74.js → chunk-GEFKDW7X.js} +15 -2
  63. package/dist/lib/chunks/{chunk-CS24IL3K.js → chunk-GESHTTSA.js} +2 -2
  64. package/dist/lib/chunks/chunk-GNMFJ2OK.js +321 -0
  65. package/dist/lib/chunks/{chunk-H3G3VTT7.js → chunk-HFRAHG5C.js} +44 -26
  66. package/dist/lib/chunks/{chunk-MHAKYFDF.js → chunk-HQG63ZKO.js} +11 -11
  67. package/dist/lib/chunks/{chunk-OORO55OM.js → chunk-HTOD4W4E.js} +21 -6
  68. package/dist/lib/chunks/{chunk-Q2PWES4B.js → chunk-I3XGRGXE.js} +1 -1
  69. package/dist/lib/chunks/{chunk-WUELMJ22.js → chunk-IE7NAL6B.js} +1 -1
  70. package/dist/lib/chunks/{chunk-KRFHQQS7.js → chunk-JXMDOAKA.js} +17 -17
  71. package/dist/lib/chunks/{chunk-S7KJZIUR.js → chunk-KJMU5KH4.js} +2 -2
  72. package/dist/lib/chunks/{chunk-2ROSV4HD.js → chunk-L7MEIRJB.js} +1 -1
  73. package/dist/lib/chunks/{chunk-CPT2GKKW.js → chunk-LOBXOZ2R.js} +1 -1
  74. package/dist/lib/chunks/{chunk-IAR6XGEW.js → chunk-ML4W6KC6.js} +1 -1
  75. package/dist/lib/chunks/{chunk-WKH6BJAZ.js → chunk-MNWO7EHC.js} +4 -4
  76. package/dist/lib/chunks/{chunk-D2LPQO6Y.js → chunk-MRL5RUP7.js} +1 -1
  77. package/dist/lib/chunks/{chunk-IEVAFDW7.js → chunk-NCXSNHXX.js} +3 -3
  78. package/dist/lib/chunks/{chunk-AKKFERA4.js → chunk-NGHAP2P5.js} +4 -4
  79. package/dist/lib/chunks/{chunk-ZLOOC46D.js → chunk-OKL7GN2F.js} +3 -3
  80. package/dist/lib/chunks/{chunk-YOZNLFSB.js → chunk-OQU5IXAJ.js} +5 -5
  81. package/dist/lib/chunks/{chunk-I7VNIW6Q.js → chunk-OU73OUX4.js} +16 -10
  82. package/dist/lib/chunks/{chunk-56VOFZ7T.js → chunk-QHUDJVPJ.js} +90 -24
  83. package/dist/lib/chunks/{chunk-WTQWU522.js → chunk-QSJ4IKUF.js} +9 -9
  84. package/dist/lib/chunks/{chunk-FBFZBLTY.js → chunk-R6XDZWUL.js} +7 -8
  85. package/dist/lib/chunks/{chunk-CJ5YD3CU.js → chunk-RJ5R6YYA.js} +5 -5
  86. package/dist/lib/chunks/{chunk-5EX5DKMA.js → chunk-RR46EDDR.js} +33 -25
  87. package/dist/lib/chunks/chunk-RYCRL3YA.js +106 -0
  88. package/dist/lib/chunks/{chunk-Z4LMDKBU.js → chunk-SHUMCKCS.js} +2 -2
  89. package/dist/lib/chunks/{chunk-3EBWDHPK.js → chunk-TJQ5OPLQ.js} +10 -12
  90. package/dist/lib/chunks/chunk-U64NCRRR.js +97 -0
  91. package/dist/lib/chunks/chunk-U772TN32.js +67 -0
  92. package/dist/lib/chunks/{chunk-YR67JG2V.js → chunk-UEMZYHYJ.js} +8 -3
  93. package/dist/lib/chunks/{chunk-J46W3EMQ.js → chunk-UZJSTJFP.js} +5 -5
  94. package/dist/lib/chunks/{chunk-XJVXASDD.js → chunk-V7OAPKNF.js} +3 -3
  95. package/dist/lib/chunks/{chunk-WE2WPNG2.js → chunk-VKM6MMA4.js} +66 -7
  96. package/dist/lib/chunks/{chunk-YWJPJI3W.js → chunk-VL253W5C.js} +3 -1
  97. package/dist/lib/chunks/{chunk-XU6WQ5UL.js → chunk-VPZQGND4.js} +3 -3
  98. package/dist/lib/chunks/{chunk-X2Y2ZNG3.js → chunk-W2VGLWTS.js} +3 -3
  99. package/dist/lib/chunks/{chunk-6AUEDSTU.js → chunk-W5DC23OP.js} +1 -1
  100. package/dist/lib/chunks/chunk-W5X7WJYL.js +91 -0
  101. package/dist/lib/chunks/{chunk-QFVRCSJ2.js → chunk-WDOA5JEH.js} +2 -0
  102. package/dist/lib/chunks/{chunk-6KO7HGCQ.js → chunk-WVACVWBL.js} +2 -2
  103. package/dist/lib/chunks/{chunk-MIF5IYNR.js → chunk-XDG6NPJB.js} +26 -29
  104. package/dist/lib/chunks/{chunk-X6E44EGV.js → chunk-XR44YSHT.js} +2 -2
  105. package/dist/lib/chunks/chunk-Y2CZ6FZY.js +61 -0
  106. package/dist/lib/chunks/{chunk-5KKLUM7M.js → chunk-YAAUWCJ4.js} +1 -1
  107. package/dist/lib/chunks/{chunk-N2ZZ6JRF.js → chunk-YRBIC5QH.js} +1 -1
  108. package/dist/lib/chunks/chunk-ZIGNJAPC.js +11 -0
  109. package/dist/lib/cli/bundle-commands.js +71 -65
  110. package/dist/lib/cli/guide-command.js +25 -0
  111. package/dist/lib/cli/io.js +1 -1
  112. package/dist/lib/cli/run-commands.js +270 -104
  113. package/dist/lib/cli/status-command.js +234 -0
  114. package/dist/lib/codex-workflow/aggregate.js +8 -9
  115. package/dist/lib/codex-workflow/author-tools.js +6 -7
  116. package/dist/lib/codex-workflow/author.js +17 -17
  117. package/dist/lib/codex-workflow/capture.js +10 -9
  118. package/dist/lib/codex-workflow/checkpoint.js +6 -7
  119. package/dist/lib/codex-workflow/checks.js +6 -7
  120. package/dist/lib/codex-workflow/codex-binary.js +13 -0
  121. package/dist/lib/codex-workflow/codex-home.js +6 -3
  122. package/dist/lib/codex-workflow/copy-editor.js +14 -14
  123. package/dist/lib/codex-workflow/copy-recovery.js +3 -4
  124. package/dist/lib/codex-workflow/copy.js +11 -11
  125. package/dist/lib/codex-workflow/finish.js +17 -18
  126. package/dist/lib/codex-workflow/host-models.js +7 -7
  127. package/dist/lib/codex-workflow/loop.js +42 -38
  128. package/dist/lib/codex-workflow/quality.js +3 -4
  129. package/dist/lib/codex-workflow/run-inputs.js +5 -6
  130. package/dist/lib/codex-workflow/run-source.js +14 -13
  131. package/dist/lib/codex-workflow/schemas.js +5 -6
  132. package/dist/lib/codex-workflow/session.js +7 -8
  133. package/dist/lib/codex-workflow/stage.js +26 -23
  134. package/dist/lib/codex-workflow/workdir.js +6 -7
  135. package/dist/lib/engine/audit-file.js +7 -6
  136. package/dist/lib/engine/author.js +37 -31
  137. package/dist/lib/engine/budget.js +7 -1
  138. package/dist/lib/engine/cost-estimate.js +41 -0
  139. package/dist/lib/engine/local-run.js +48 -42
  140. package/dist/lib/engine/preflight.js +10 -6
  141. package/dist/lib/engine/rejudge.js +56 -50
  142. package/dist/lib/engine/resources.js +1 -1
  143. package/dist/lib/engine/run-configuration.js +2 -1
  144. package/dist/lib/engine/run-status.js +151 -0
  145. package/dist/lib/engine/templates.js +8 -7
  146. package/dist/lib/grounding/controller.js +7 -7
  147. package/dist/lib/grounding/extract.js +6 -6
  148. package/dist/lib/grounding/grounding-runtime.js +18 -17
  149. package/dist/lib/grounding/model.js +5 -5
  150. package/dist/lib/grounding/recorded-tools.js +10 -9
  151. package/dist/lib/harness/report/artifacts.js +4 -5
  152. package/dist/lib/lib/checkpoint.js +3 -4
  153. package/dist/lib/models/batching.js +5 -5
  154. package/dist/lib/models/cost-coefficients.js +20 -0
  155. package/dist/lib/models/local-profile.js +10 -0
  156. package/dist/lib/models/pricing.js +6 -0
  157. package/dist/lib/models/profiles.js +7 -14
  158. package/dist/lib/models/structured-images.js +1 -1
  159. package/dist/lib/models/structured.js +4 -4
  160. package/dist/lib/models/supported-models.js +20 -0
  161. package/dist/lib/pipeline.js +9 -8
  162. package/dist/lib/probes/agent-cli-parsers.js +1 -1
  163. package/dist/lib/probes/agent-clis.js +6 -5
  164. package/dist/lib/probes/charged-trace.js +10 -0
  165. package/dist/lib/probes/probes.js +6 -6
  166. package/dist/lib/runner.js +10 -10
  167. package/dist/lib/schema.js +3 -4
  168. package/dist/lib/section-result.js +3 -4
  169. package/dist/lib/stores/artifacts.js +3 -4
  170. package/dist/lib/stores/files.js +9 -9
  171. package/dist/lib/stores/local-versions.js +4 -5
  172. package/dist/lib/stores/memory.js +6 -7
  173. package/dist/lib/stores/publication.js +5 -6
  174. package/dist/lib/viewer/server.js +18 -19
  175. package/dist/lib/workflow/schema.js +2 -3
  176. package/dist/types/agents/copy-validation.d.ts +4 -4
  177. package/dist/types/agents/verifier.d.ts +6 -6
  178. package/dist/types/bundle/contracts.d.ts +1 -1
  179. package/dist/types/bundle/isolation.d.ts +37 -0
  180. package/dist/types/bundle/project-journal.d.ts +2 -0
  181. package/dist/types/bundle/recorder.d.ts +4 -0
  182. package/dist/types/bundle/writer-lock.d.ts +9 -0
  183. package/dist/types/cli/guide-command.d.ts +4 -0
  184. package/dist/types/cli/status-command.d.ts +2 -0
  185. package/dist/types/codex-workflow/codex-binary.d.ts +26 -0
  186. package/dist/types/codex-workflow/codex-home.d.ts +24 -20
  187. package/dist/types/codex-workflow/copy-editor.d.ts +1 -1
  188. package/dist/types/codex-workflow/copy.d.ts +3 -4
  189. package/dist/types/codex-workflow/finish.d.ts +5 -3
  190. package/dist/types/codex-workflow/host-models.d.ts +7 -3
  191. package/dist/types/codex-workflow/loop.d.ts +10 -1
  192. package/dist/types/codex-workflow/run-inputs.d.ts +28 -113
  193. package/dist/types/codex-workflow/stage.d.ts +16 -5
  194. package/dist/types/engine/audit-file.d.ts +3 -2
  195. package/dist/types/engine/author.d.ts +7 -1
  196. package/dist/types/engine/budget.d.ts +46 -15
  197. package/dist/types/engine/cost-estimate.d.ts +40 -0
  198. package/dist/types/engine/local-run.d.ts +6 -0
  199. package/dist/types/engine/preflight.d.ts +5 -0
  200. package/dist/types/engine/resources.d.ts +2 -0
  201. package/dist/types/engine/run-configuration.d.ts +4 -3
  202. package/dist/types/engine/run-status.d.ts +75 -0
  203. package/dist/types/engine/templates.d.ts +1 -2
  204. package/dist/types/models/cost-coefficients.d.ts +106 -0
  205. package/dist/types/models/local-profile.d.ts +12 -0
  206. package/dist/types/models/pricing.d.ts +8 -0
  207. package/dist/types/models/profiles.d.ts +55 -160
  208. package/dist/types/models/served-model.d.ts +2 -3
  209. package/dist/types/models/structured.d.ts +3 -3
  210. package/dist/types/models/supported-models.d.ts +48 -0
  211. package/dist/types/probes/charged-trace.d.ts +8 -0
  212. package/dist/types/probes/probe-trace.d.ts +2 -0
  213. package/dist/types/schema.d.ts +28 -113
  214. package/dist/types/workflow/schema.d.ts +79 -152
  215. package/package.json +2 -1
  216. package/resources/guide/OPERATOR.md +180 -0
  217. package/src/agents/copy-validation.ts +8 -12
  218. package/src/agents/verifier.ts +10 -14
  219. package/src/bundle/contracts.ts +3 -3
  220. package/src/bundle/isolation.ts +157 -0
  221. package/src/bundle/project-journal.ts +4 -0
  222. package/src/bundle/project.ts +20 -7
  223. package/src/bundle/recorder.ts +5 -0
  224. package/src/bundle/writer-lock.ts +27 -0
  225. package/src/cli/guide-command.ts +28 -0
  226. package/src/cli/io.ts +2 -0
  227. package/src/cli/literally-aeo.ts +39 -19
  228. package/src/cli/run-commands.ts +236 -18
  229. package/src/cli/status-command.ts +113 -0
  230. package/src/codex-workflow/codex-binary.ts +105 -0
  231. package/src/codex-workflow/codex-home.ts +50 -40
  232. package/src/codex-workflow/copy.ts +7 -10
  233. package/src/codex-workflow/finish.ts +13 -8
  234. package/src/codex-workflow/host-models.ts +33 -24
  235. package/src/codex-workflow/loop.ts +36 -9
  236. package/src/codex-workflow/stage.ts +126 -17
  237. package/src/engine/audit-file.ts +10 -8
  238. package/src/engine/author.ts +47 -2
  239. package/src/engine/budget.ts +138 -43
  240. package/src/engine/cost-estimate.ts +178 -0
  241. package/src/engine/guide/OPERATOR.md +180 -0
  242. package/src/engine/local-run.ts +38 -8
  243. package/src/engine/preflight.ts +90 -7
  244. package/src/engine/resources.ts +9 -4
  245. package/src/engine/run-configuration.ts +19 -1
  246. package/src/engine/run-status.ts +452 -0
  247. package/src/engine/templates.ts +5 -2
  248. package/src/models/cost-coefficients.ts +140 -0
  249. package/src/models/local-profile.ts +150 -0
  250. package/src/models/pricing.ts +31 -0
  251. package/src/models/profiles.ts +58 -419
  252. package/src/models/served-model.ts +2 -3
  253. package/src/models/structured-images.ts +5 -4
  254. package/src/models/structured.ts +20 -7
  255. package/src/models/supported-models.ts +112 -0
  256. package/src/probes/agent-clis.ts +24 -2
  257. package/src/probes/charged-trace.ts +87 -0
  258. package/src/probes/probe-trace.ts +2 -0
  259. package/src/probes/probes.ts +48 -2
  260. package/dist/lib/chunks/chunk-CFFPOTP4.js +0 -356
  261. package/dist/lib/chunks/chunk-LIZX4N3H.js +0 -110
  262. package/dist/lib/chunks/chunk-OYKV5NDM.js +0 -28
package/src/cli/io.ts CHANGED
@@ -18,6 +18,8 @@ const valueOptions = new Set([
18
18
  '--port',
19
19
  '--brief',
20
20
  '--redact',
21
+ '--max-usd',
22
+ '--model',
21
23
  ]);
22
24
 
23
25
  export const parseFlags = (argv: readonly string[]): Flags => {
@@ -1,6 +1,7 @@
1
1
  import { Console } from 'node:console';
2
2
  import { toolVersion } from '../bundle/contracts';
3
3
  import { runExport, runVerify, runView } from './bundle-commands';
4
+ import { runGuide } from './guide-command';
4
5
  import { parseFlags, writeErr, writeOut } from './io';
5
6
  import {
6
7
  runDoctor,
@@ -10,6 +11,7 @@ import {
10
11
  runRejudge,
11
12
  runRun,
12
13
  } from './run-commands';
14
+ import { runStatus } from './status-command';
13
15
 
14
16
  // ============================================================================
15
17
  // literally-aeo (specs/aeo-open-source-cli-spec.md §4.3). No command loads
@@ -23,40 +25,52 @@ Usage:
23
25
  literally-aeo init [--config audit.json]
24
26
  literally-aeo doctor [--config audit.json] [--env-file .env] [--output audit-run]
25
27
  literally-aeo plan [--config audit.json] [--output audit-run]
26
- literally-aeo run [--config audit.json] [--env-file .env] [--output audit-run] [--budget-file limits.json]
27
- literally-aeo author --brief brief.json [--output audit-draft] [--env-file .env]
28
- literally-aeo rejudge <run-dir> --output <new-run-dir> [--config audit.json] [--env-file .env]
28
+ literally-aeo run [--config audit.json] [--env-file .env] [--output audit-run] [--max-usd N] [--budget-file limits.json]
29
+ literally-aeo author --brief brief.json [--estimate] [--max-usd N] [--model <id>] [--output audit-draft] [--env-file .env]
30
+ literally-aeo rejudge <run-dir> --output <new-run-dir> [--model <id>] [--max-usd N] [--config audit.json] [--env-file .env]
29
31
  literally-aeo view <archive|bundle-dir|run-dir> [--working] [--port N]
30
32
  literally-aeo export <run-dir> [--output <file.aeo.zip>] [--env-file <file>] [--accept-findings] [--redact redactions.json]
31
33
  literally-aeo verify <archive|bundle-dir|run-dir>
34
+ literally-aeo status <run-dir>
35
+ literally-aeo guide
32
36
 
33
37
  Every command takes --json (a versioned result on stdout) and --quiet.
34
38
 
35
39
  init writes an example audit.json and .env.example, never over a file.
36
- doctor checks the CLIs, settings and run directory a run needs, offline;
37
- settings are named, never shown. plan prints what a run would measure and
38
- whether the run directory is new, resumable or completed, offline. run
39
- measures: it captures every planned answer (reusing what the run directory
40
- already holds), judges, reviews and writes the report; running it again
41
- resumes; --budget-file raises the run's limits, recorded. author researches a brief
42
- (JSON: companyName, website, desiredRecommendation, and optionally
43
- competitors, moneyPages, notes) and proposes an audit.json beside the
44
- record of the session; a run of that file bundles the record and the diff
45
- from proposal to final. rejudge judges a
46
- finished run's captures again in a new run directory, carrying the original
47
- revision as its predecessor; nothing is probed again. view serves the
40
+ doctor checks the model, the CLIs, settings and run directory a run needs,
41
+ offline; settings are named, never shown, and an unsupported model is
42
+ refused with the supported list. plan prints what a run would measure, its
43
+ estimated cost as a range, and whether the run directory is new, resumable
44
+ or completed, offline. run measures: it captures every planned answer
45
+ (reusing what the run directory already holds), judges, reviews and writes
46
+ the report; running it again resumes. A new run starts only under an
47
+ approved cap, --max-usd or runPolicy.budget.maxUsd, which covers every
48
+ paid call (probes, Codex stages, host model calls, searches); without one
49
+ it prints the estimate and spends nothing. A run freezes its cap and its
50
+ model; --max-usd or --budget-file raises the cap of a run, recorded.
51
+ author researches a brief (JSON: companyName, website,
52
+ desiredRecommendation, and optionally competitors, moneyPages, notes) and
53
+ proposes an audit.json beside the record of the session; --estimate prints
54
+ what that costs and spends nothing, and the session needs --max-usd. A run
55
+ of that file bundles the record and the diff from proposal to final.
56
+ rejudge judges a finished run's captures again in a new run directory,
57
+ carrying the original revision as its predecessor; nothing is probed
58
+ again, and --model judges with another model. view serves the
48
59
  report and its evidence on this machine only (127.0.0.1, a one-time link);
49
60
  a run directory without a finalized revision shows its working state,
50
61
  labelled as such. export packs a run directory into a portable archive;
51
- verify checks one offline.
62
+ verify checks one offline. status reports a run directory's phase,
63
+ answers and spend against its cap, read-only, beside a live run too. guide
64
+ prints the protocol an AI agent follows to run an audit for a user.
52
65
 
53
66
  Settings come from the process environment first, then the env file
54
67
  (default ./.env); no other file is read.
55
68
 
56
69
  Exit codes: 0 done; 1 invalid input, a failed check or an error; 2 stopped
57
- before or during work and resumable (missing setting, failed canary, a live
58
- writer holding the run), or an unsupported bundle; 3 done with disclosed
59
- limitations; 128 plus the signal number when interrupted.`;
70
+ before or during work and resumable (no approved cap, the cap reached,
71
+ missing setting, failed canary, a live writer holding the run), or an
72
+ unsupported bundle; 3 done with disclosed limitations; 128 plus the signal
73
+ number when interrupted.`;
60
74
 
61
75
  const main = async (argv: readonly string[]) => {
62
76
  const flags = parseFlags(argv);
@@ -101,6 +115,12 @@ const main = async (argv: readonly string[]) => {
101
115
  case 'view':
102
116
  return runView(commandFlags, usageText);
103
117
 
118
+ case 'status':
119
+ return runStatus(commandFlags, usageText);
120
+
121
+ case 'guide':
122
+ return runGuide(commandFlags);
123
+
104
124
  default:
105
125
  throw new Error(usageText);
106
126
  }
@@ -5,7 +5,20 @@ import { workflowSecrets } from '../codex-workflow/codex-home';
5
5
  import { prepareWorkdir, runWorkflow } from '../codex-workflow/loop';
6
6
  import { readAuditFile, type AuditFile } from '../engine/audit-file';
7
7
  import { readSettings, type Settings } from '../engine/env-file';
8
- import { readBudgetAmendment, type BudgetAmendment } from '../engine/budget';
8
+ import {
9
+ BudgetCapMissingError,
10
+ readBudgetAmendment,
11
+ readFrozenBudget,
12
+ RunModelChangedError,
13
+ type BudgetAmendment,
14
+ } from '../engine/budget';
15
+ import {
16
+ describeCostRange,
17
+ estimateAuthorCost,
18
+ estimateRunCost,
19
+ type AuthorCostEstimate,
20
+ type RunCostEstimate,
21
+ } from '../engine/cost-estimate';
9
22
  import {
10
23
  openLocalRun,
11
24
  planLocalRun,
@@ -34,6 +47,11 @@ import { engineResources } from '../engine/resources';
34
47
  import { exampleAuditFile, exampleEnvFile } from '../engine/templates';
35
48
  import { getEnvironment, writeEnv } from '../lib/env';
36
49
  import { ModelBudgetError } from '../models/accounting';
50
+ import {
51
+ findSupportedModel,
52
+ recommendedModelId,
53
+ resolveSupportedModel,
54
+ } from '../models/supported-models';
37
55
  import { hasErrorCode } from '../stores/fs-errors';
38
56
  import { formatLine, writeErr, writeOut, type Flags } from './io';
39
57
 
@@ -51,6 +69,57 @@ const runDirOf = (flags: Flags) => {
51
69
  return path.resolve(flags.options.get('--output') ?? 'audit-run');
52
70
  };
53
71
 
72
+ /** The amount the operator approved with --max-usd, if any. */
73
+ const maxUsdOf = (flags: Flags): number | undefined => {
74
+ const value = flags.options.get('--max-usd');
75
+
76
+ if (value === undefined) {
77
+ return undefined;
78
+ }
79
+
80
+ const usd = Number(value.replace(/^\$/, ''));
81
+
82
+ if (!Number.isFinite(usd) || usd <= 0) {
83
+ throw new Error(
84
+ `Please give --max-usd a positive amount in dollars, such as 40; got ${value}.`,
85
+ );
86
+ }
87
+
88
+ return usd;
89
+ };
90
+
91
+ /** The cost lines a person reads, for plan and for a refused run. */
92
+ const estimateLines = (estimate: RunCostEstimate | AuthorCostEstimate) => {
93
+ const categories: [string, { low: number; high: number } | undefined][] = [
94
+ [
95
+ 'probes',
96
+ 'probes' in estimate.categories ? estimate.categories.probes : undefined,
97
+ ],
98
+ ['Codex stages', estimate.categories.stages],
99
+ [
100
+ 'host model calls',
101
+ 'hostCalls' in estimate.categories
102
+ ? estimate.categories.hostCalls
103
+ : undefined,
104
+ ],
105
+ ['search', estimate.categories.search],
106
+ ];
107
+
108
+ return [
109
+ formatLine(
110
+ 'Estimated cost',
111
+ `${describeCostRange(estimate)} (an estimate, not a quote; ${estimate.model})`,
112
+ ),
113
+ ...categories.flatMap(([label, range]) =>
114
+ range ? [formatLine(` ${label}`, describeCostRange(range))] : [],
115
+ ),
116
+ formatLine(
117
+ 'Recommended cap',
118
+ `$${estimate.recommendedCapUsd} (the high end)`,
119
+ ),
120
+ ];
121
+ };
122
+
54
123
  /** init writes the two templates beside each other, never over an
55
124
  * existing file. */
56
125
  export const runInit = async (flags: Flags) => {
@@ -91,12 +160,19 @@ export const runInit = async (flags: Flags) => {
91
160
 
92
161
  export const runDoctor = async (flags: Flags) => {
93
162
  const file = await readAuditFile(configPathOf(flags));
94
- const { plan, request } = planLocalRun(file);
163
+ // An unsupported model is doctor's finding, not its crash: the rest of
164
+ // the checks still run, against the plan the recommended model would make.
165
+ const isSupported =
166
+ findSupportedModel(file.model ?? recommendedModelId) !== undefined;
167
+ const { plan, request } = planLocalRun(
168
+ isSupported ? file : { ...file, model: undefined },
169
+ );
95
170
  const settings = await readSettings(flags.options.get('--env-file'));
96
171
  const checks = await runPreflight({
97
172
  surfaces: plan.surfaces,
98
173
  settings,
99
174
  dir: runDirOf(flags),
175
+ model: file.model,
100
176
  groundingSearch: usesGroundingSearch(request),
101
177
  });
102
178
  const ok = checks.every((check) => check.ok);
@@ -128,8 +204,15 @@ export const runPlan = async (flags: Flags) => {
128
204
  const dir = runDirOf(flags);
129
205
  const state = await runDirectoryState(dir);
130
206
  const bySurface = Object.fromEntries(plan.probesBySurface);
207
+ const model = resolveSupportedModel(file.model);
208
+ const estimate = estimateRunCost({
209
+ plan,
210
+ model,
211
+ grounding: request.grounding,
212
+ });
131
213
  const summary = {
132
214
  brand: config.brand.name,
215
+ model: model.id,
133
216
  sections: config.sections.map((section) => ({
134
217
  key: section.key,
135
218
  questions: section.prompts.length,
@@ -140,11 +223,10 @@ export const runPlan = async (flags: Flags) => {
140
223
  maxPlannedUnits: request.maxPlannedUnits,
141
224
  grounding: request.grounding,
142
225
  budget: file.runPolicy.budget,
143
- // What the budget can actually stop (spec §6): the host's model calls.
144
- budgetEnforcedFor: [
145
- 'host model calls (perception, labels, grounding, copy verifier)',
146
- ],
147
- budgetRecordedOnly: ['probe answers', 'Codex stage sessions'],
226
+ // The cap covers every paid call: probes, Codex stage sessions, host
227
+ // model calls and searches.
228
+ estimate,
229
+ recommendedCapUsd: estimate.recommendedCapUsd,
148
230
  runDirectory: { path: dir, state },
149
231
  digests,
150
232
  };
@@ -158,6 +240,7 @@ export const runPlan = async (flags: Flags) => {
158
240
  writeOut(
159
241
  [
160
242
  formatLine('Brand', summary.brand),
243
+ formatLine('Model', summary.model),
161
244
  ...summary.sections.map((section) =>
162
245
  formatLine(`Section ${section.key}`, `${section.questions} questions`),
163
246
  ),
@@ -175,14 +258,12 @@ export const runPlan = async (flags: Flags) => {
175
258
  ? 'full (claims researched and adjudicated)'
176
259
  : 'extraction_only (claims inventoried, not researched)',
177
260
  ),
261
+ ...estimateLines(estimate),
178
262
  formatLine(
179
- 'Budget',
180
- `${'$'}${summary.budget.maxUsd}, ${summary.budget.maxTokens} tokens, ${summary.budget.maxHours} h`,
181
- ),
182
- formatLine(' enforced for', summary.budgetEnforcedFor.join('; ')),
183
- formatLine(
184
- ' recorded, not capped',
185
- summary.budgetRecordedOnly.join('; '),
263
+ 'Cap',
264
+ summary.budget.maxUsd === undefined
265
+ ? 'none in audit.json; approve one with run --max-usd <amount>'
266
+ : `${'$'}${summary.budget.maxUsd} (audit.json), covering every paid call`,
186
267
  ),
187
268
  formatLine('Run directory', `${dir} (${state})`),
188
269
  formatLine('Measurement digest', digests.measurement),
@@ -204,10 +285,27 @@ export const runRun = async (flags: Flags) => {
204
285
  const amendment = budgetFile
205
286
  ? await readBudgetAmendment(path.resolve(budgetFile))
206
287
  : undefined;
288
+ const maxUsd = maxUsdOf(flags);
289
+ const refused = await refuseWithoutCap({
290
+ file,
291
+ dir,
292
+ maxUsd,
293
+ estimate: estimateRunCost({
294
+ plan,
295
+ model: resolveSupportedModel(file.model),
296
+ grounding: request.grounding,
297
+ }),
298
+ });
299
+
300
+ if (refused !== undefined) {
301
+ return refused;
302
+ }
303
+
207
304
  const checks = await runPreflight({
208
305
  surfaces: plan.surfaces,
209
306
  settings,
210
307
  dir,
308
+ model: file.model,
211
309
  groundingSearch: usesGroundingSearch(request),
212
310
  });
213
311
  const failing = checks.filter((check) => !check.ok);
@@ -228,10 +326,46 @@ export const runRun = async (flags: Flags) => {
228
326
  configFile: configPathOf(flags),
229
327
  dir,
230
328
  settings,
329
+ maxUsd,
231
330
  amendment,
232
331
  });
233
332
  };
234
333
 
334
+ /** A run starts only under an amount the operator approved: a new run
335
+ * directory without --max-usd or runPolicy.budget.maxUsd is refused with
336
+ * the estimate, before any paid work (exit 2, nothing spent). A resume
337
+ * keeps the cap it froze. */
338
+ const refuseWithoutCap = async ({
339
+ file,
340
+ dir,
341
+ maxUsd,
342
+ estimate,
343
+ }: {
344
+ file: AuditFile;
345
+ dir: string;
346
+ maxUsd: number | undefined;
347
+ estimate: RunCostEstimate;
348
+ }): Promise<number | undefined> => {
349
+ if (maxUsd !== undefined || file.runPolicy.budget.maxUsd !== undefined) {
350
+ return undefined;
351
+ }
352
+
353
+ if (await readFrozenBudget(dir)) {
354
+ return undefined;
355
+ }
356
+
357
+ writeErr(
358
+ [
359
+ 'Not started: a run needs an approved spending cap. Nothing was spent.',
360
+ ...estimateLines(estimate),
361
+ '',
362
+ `Approve an amount and run again with it, for example: --max-usd ${estimate.recommendedCapUsd}`,
363
+ ].join('\n'),
364
+ );
365
+
366
+ return 2;
367
+ };
368
+
235
369
  /** author researches a brief and proposes an audit.json (spec §4.1). */
236
370
  export const runAuthor = async (flags: Flags, usage: string) => {
237
371
  const briefFile = flags.options.get('--brief');
@@ -241,6 +375,36 @@ export const runAuthor = async (flags: Flags, usage: string) => {
241
375
  }
242
376
 
243
377
  const brief = await readBrief(path.resolve(briefFile));
378
+ const model = resolveSupportedModel(flags.options.get('--model'));
379
+ const estimate = estimateAuthorCost(model);
380
+ const maxUsd = maxUsdOf(flags);
381
+
382
+ // --estimate is free: it reads the brief and prints what researching it
383
+ // would cost, and spends nothing.
384
+ if (flags.switches.has('--estimate') || maxUsd === undefined) {
385
+ if (flags.switches.has('--json')) {
386
+ writeOut(
387
+ JSON.stringify({
388
+ resultVersion: 1,
389
+ command: 'author',
390
+ started: false,
391
+ estimate,
392
+ recommendedCapUsd: estimate.recommendedCapUsd,
393
+ }),
394
+ );
395
+ } else {
396
+ writeOut(
397
+ [
398
+ ...estimateLines(estimate),
399
+ '',
400
+ `Nothing was spent. To research the brief, approve an amount: --max-usd ${estimate.recommendedCapUsd}`,
401
+ ].join('\n'),
402
+ );
403
+ }
404
+
405
+ return flags.switches.has('--estimate') ? 0 : 2;
406
+ }
407
+
244
408
  const dir = path.resolve(flags.options.get('--output') ?? 'audit-draft');
245
409
  const settings = await readSettings(flags.options.get('--env-file'));
246
410
  // The author researches through the pinned search provider, so its key
@@ -275,6 +439,8 @@ export const runAuthor = async (flags: Flags, usage: string) => {
275
439
  const result = await runLocalAuthor({
276
440
  brief,
277
441
  dir,
442
+ model,
443
+ maxUsd,
278
444
  secrets: settings.values(credentialSettingNames),
279
445
  });
280
446
 
@@ -302,6 +468,14 @@ export const runAuthor = async (flags: Flags, usage: string) => {
302
468
  return 2;
303
469
  }
304
470
 
471
+ if (err instanceof ModelBudgetError) {
472
+ writeErr(
473
+ `Stopped at the approved cap of $${maxUsd}: ${err.message}. Nothing more was spent; run the same command with a higher --max-usd to continue.`,
474
+ );
475
+
476
+ return 2;
477
+ }
478
+
305
479
  throw err;
306
480
  }
307
481
  };
@@ -344,9 +518,33 @@ export const runRejudge = async (flags: Flags, usage: string) => {
344
518
  configOption === undefined
345
519
  ? await readRecordedAuthorEvidence(sourceDir)
346
520
  : undefined;
347
- const file = await readAuditFile(configFile);
521
+ // --model judges the same captures with another model: the method
522
+ // changes, the measurement does not, and the lineage records both.
523
+ const modelOption = flags.options.get('--model');
524
+ const configured = await readAuditFile(configFile);
525
+ const file =
526
+ modelOption === undefined
527
+ ? configured
528
+ : { ...configured, model: resolveSupportedModel(modelOption).id };
348
529
  const settings = await readSettings(flags.options.get('--env-file'));
349
530
  const { plan, request } = planLocalRun(file);
531
+ const maxUsd = maxUsdOf(flags);
532
+ const refused = await refuseWithoutCap({
533
+ file,
534
+ dir,
535
+ maxUsd,
536
+ // Nothing is probed again: only the judging and writing are paid.
537
+ estimate: estimateRunCost({
538
+ plan: { units: plan.units, probesBySurface: new Map() },
539
+ model: resolveSupportedModel(file.model),
540
+ grounding: request.grounding,
541
+ }),
542
+ });
543
+
544
+ if (refused !== undefined) {
545
+ return refused;
546
+ }
547
+
350
548
  const lineage = await prepareRejudgment({
351
549
  source: sourceDir,
352
550
  target: dir,
@@ -358,6 +556,7 @@ export const runRejudge = async (flags: Flags, usage: string) => {
358
556
  surfaces: plan.surfaces,
359
557
  settings,
360
558
  dir,
559
+ model: file.model,
361
560
  groundingSearch: usesGroundingSearch(request),
362
561
  });
363
562
  const failing = checks.filter((check) => !check.ok);
@@ -382,6 +581,8 @@ export const runRejudge = async (flags: Flags, usage: string) => {
382
581
  configFile,
383
582
  dir,
384
583
  settings,
584
+ maxUsd,
585
+ ...(modelOption !== undefined && { modelOverride: file.model }),
385
586
  evidence,
386
587
  derivedFromRunId: lineage.runId,
387
588
  });
@@ -393,6 +594,10 @@ type ExecuteRunOptions = {
393
594
  configFile: string;
394
595
  dir: string;
395
596
  settings: Settings;
597
+ /** The cap approved on the command line. */
598
+ maxUsd?: number;
599
+ /** The model a rejudgment names outside the configuration file. */
600
+ modelOverride?: string;
396
601
  amendment?: BudgetAmendment;
397
602
  /** Author evidence already recorded; read beside configFile otherwise. */
398
603
  evidence?: RecordedAuthorEvidence;
@@ -407,6 +612,8 @@ const executeRun = async ({
407
612
  configFile,
408
613
  dir,
409
614
  settings,
615
+ maxUsd,
616
+ modelOverride,
410
617
  amendment,
411
618
  evidence,
412
619
  derivedFromRunId,
@@ -417,6 +624,7 @@ const executeRun = async ({
417
624
  dir,
418
625
  configFile,
419
626
  evidence: evidence ?? (await readAuthorEvidence(configFile, file)),
627
+ ...(modelOverride !== undefined && { model: modelOverride }),
420
628
  });
421
629
 
422
630
  // The copy stage reads its rules and publisher context from the engine,
@@ -440,6 +648,7 @@ const executeRun = async ({
440
648
  try {
441
649
  const local = await openLocalRun(file, dir, {
442
650
  signal: controller.signal,
651
+ ...(maxUsd !== undefined && { maxUsd }),
443
652
  amendment,
444
653
  derivedFromRunId,
445
654
  });
@@ -456,6 +665,7 @@ const executeRun = async ({
456
665
  signal: controller.signal,
457
666
  origin: 'local',
458
667
  held: local.held,
668
+ ledger: local.ledger,
459
669
  }).catch(async (err: unknown) => {
460
670
  await local.held.writer.release();
461
671
  await local.source.close();
@@ -511,17 +721,25 @@ const executeRun = async ({
511
721
 
512
722
  if (
513
723
  err instanceof PreflightFailedError ||
514
- err instanceof WriterLockHeldError
724
+ err instanceof WriterLockHeldError ||
725
+ err instanceof BudgetCapMissingError
515
726
  ) {
516
727
  writeErr(err.message);
517
728
 
518
729
  return 2;
519
730
  }
520
731
 
521
- // Spending stops at the limit; the ledger survives for the resume.
732
+ if (err instanceof RunModelChangedError) {
733
+ writeErr(err.message);
734
+
735
+ return 1;
736
+ }
737
+
738
+ // Spending stops at the cap; the ledger and every banked answer survive
739
+ // for the resume, which never pays for them again.
522
740
  if (err instanceof ModelBudgetError) {
523
741
  writeErr(
524
- `Stopped at the run's budget: ${err.message}. Raise it with --budget-file <limits.json> and run the same command to resume.`,
742
+ `Stopped at the run's cap: ${err.message}. Nothing past the cap was dispatched. To continue, approve a higher amount and run the same command with --max-usd <amount> (or --budget-file <limits.json>); literally-aeo status ${dir} shows the spend so far.`,
525
743
  );
526
744
 
527
745
  return 2;
@@ -0,0 +1,113 @@
1
+ import path from 'node:path';
2
+ import { readRunStatus, type RunStatus } from '../engine/run-status';
3
+ import { formatLine, writeErr, writeOut, type Flags } from './io';
4
+
5
+ // ============================================================================
6
+ // literally-aeo status <run-dir> (specs/aeo-claude-operator-spec.md §4.5):
7
+ // where a run is, what it has captured and what it has spent against its
8
+ // cap. Read-only and offline; safe to poll beside a running writer.
9
+ // ============================================================================
10
+
11
+ const usd = (value: number | undefined) => {
12
+ return value === undefined ? 'unknown' : `$${value.toFixed(2)}`;
13
+ };
14
+
15
+ const toJson = (status: RunStatus) => {
16
+ // JSON carries null where a value is unknown, never a guess.
17
+ const result = {
18
+ resultVersion: 1,
19
+ command: 'status',
20
+ runDirectory: { path: status.dir, state: status.state },
21
+ writer: status.writer ?? null,
22
+ phase: status.phase ?? null,
23
+ lastActivity: status.lastActivity
24
+ ? {
25
+ ...status.lastActivity,
26
+ stage: status.lastActivity.stage ?? null,
27
+ role: status.lastActivity.role ?? null,
28
+ }
29
+ : null,
30
+ completedStages: status.completedStages,
31
+ answers: { ...status.answers, planned: status.answers.planned ?? null },
32
+ spend: {
33
+ ...status.spend,
34
+ capUsd: status.spend.capUsd ?? null,
35
+ deadlineAt: status.spend.deadlineAt ?? null,
36
+ remainingUsd: status.spend.remainingUsd ?? null,
37
+ },
38
+ lastError: status.lastError ?? null,
39
+ stoppedAtBudget: status.stoppedAtBudget,
40
+ };
41
+
42
+ return result;
43
+ };
44
+
45
+ const toText = (status: RunStatus) => {
46
+ const { answers, spend, writer, lastError } = status;
47
+ const lines = [
48
+ formatLine('Run directory', `${status.dir} (${status.state})`),
49
+ formatLine(
50
+ 'Writer',
51
+ writer
52
+ ? `${writer.purpose}, process ${writer.pid} on ${writer.host} since ${writer.since} (${writer.state})`
53
+ : 'none',
54
+ ),
55
+ formatLine('Phase', status.phase ?? 'not started'),
56
+ formatLine(
57
+ 'Stage outputs',
58
+ status.completedStages.length > 0
59
+ ? status.completedStages.join(', ')
60
+ : 'none yet',
61
+ ),
62
+ formatLine(
63
+ 'Answers',
64
+ `${answers.captured} captured of ${answers.planned ?? 'unknown'} planned${answers.failed > 0 ? `, ${answers.failed} failed` : ''}`,
65
+ ),
66
+ formatLine(
67
+ 'Spend',
68
+ `${usd(spend.chargedUsd)} of ${usd(spend.capUsd)} (${usd(spend.openUsd)} reserved, not settled)`,
69
+ ),
70
+ ...Object.entries(spend.byCategory).map(([category, spent]) =>
71
+ formatLine(` ${category}`, `${usd(spent.usd)} in ${spent.calls} calls`),
72
+ ),
73
+ formatLine(
74
+ 'Last error',
75
+ lastError
76
+ ? `${lastError.type} at ${lastError.at}: ${lastError.reason}`
77
+ : 'none',
78
+ ),
79
+ ...(status.stoppedAtBudget
80
+ ? [
81
+ '',
82
+ "Stopped at the run's cap. To continue, approve a higher amount and run the same command with --max-usd <new total> (or --budget-file <limits.json>); it resumes.",
83
+ ]
84
+ : []),
85
+ ];
86
+
87
+ return lines.join('\n');
88
+ };
89
+
90
+ export const runStatus = async (flags: Flags, usage: string) => {
91
+ const target = flags.positional[0];
92
+
93
+ if (target === undefined) {
94
+ throw new Error(usage);
95
+ }
96
+
97
+ const dir = path.resolve(target);
98
+ const status = await readRunStatus(dir);
99
+
100
+ if (!status) {
101
+ writeErr(`${dir} holds no run.`);
102
+
103
+ return 1;
104
+ }
105
+
106
+ writeOut(
107
+ flags.switches.has('--json')
108
+ ? JSON.stringify(toJson(status))
109
+ : toText(status),
110
+ );
111
+
112
+ return 0;
113
+ };