literally-aeo 0.1.1 → 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-ZBDUE3A5.js → chunk-2GU6CNQI.js} +12 -7
  32. package/dist/lib/chunks/{chunk-CKUTDJAB.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-XL4JIQ5X.js → chunk-4PD65FRJ.js} +7 -3
  35. package/dist/lib/chunks/{chunk-GMKF2FU4.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-XNRSHATN.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-SWS3K62X.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-E3OEE5XN.js → chunk-CUYVHXHI.js} +2 -2
  51. package/dist/lib/chunks/{chunk-2GY42RIJ.js → chunk-D3GE3OCB.js} +1 -1
  52. package/dist/lib/chunks/chunk-DVFFYY5G.js +74 -0
  53. package/dist/lib/chunks/{chunk-ZXGATMMH.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-FNDJUELJ.js → chunk-FOCJ7HPC.js} +7 -7
  59. package/dist/lib/chunks/{chunk-FPAN3VRW.js → chunk-FUAUPNRO.js} +26 -18
  60. package/dist/lib/chunks/{chunk-OQVIRYT5.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-47IZBMP2.js → chunk-GESHTTSA.js} +2 -2
  64. package/dist/lib/chunks/chunk-GNMFJ2OK.js +321 -0
  65. package/dist/lib/chunks/{chunk-NVBMIPXR.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-POUSX3T4.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-HFOYASRQ.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-3DG7GHFA.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-KHU5DRBE.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-LPND3VNQ.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-MD4AVTK2.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-I3TMFPK4.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-3KQFLOC7.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
@@ -0,0 +1,180 @@
1
+ # Operating literally-aeo for a user
2
+
3
+ You are an AI agent running an AEO audit on the user's own machine, for a
4
+ user who is usually not a developer. This guide is the protocol. Phrase
5
+ things your own way; never skip a checkpoint, never reorder the paid steps,
6
+ and never spend money the user has not approved as an amount.
7
+
8
+ The engine enforces the cap, not you: every paid run needs `--max-usd`, and
9
+ a run stops (exit 2) before it would cross it. Your job is to get the user's
10
+ informed yes for an amount, then pass exactly that amount.
11
+
12
+ ## Rules that hold throughout
13
+
14
+ - **Keys never pass through the chat.** Never ask for a key, password or
15
+ token in the conversation, never print one, never `cat` the `.env` file.
16
+ The user pastes keys into `.env` in their own editor. `literally-aeo
17
+ doctor` reports settings by name and source only; that is all you need.
18
+ - **Consent per system change.** Installing Node or another tool, or
19
+ changing shell configuration, needs the user's yes for that change.
20
+ - **One folder per brand.** Keep everything for a brand under
21
+ `~/literally-aeo/<brand>/` (the `.env`, the brief, `draft/`, `run/`),
22
+ never in Documents or the user's working folders.
23
+ - **Never delete a run directory to start fresh.** Running the same command
24
+ again resumes and reuses every answer already paid for. Deleting it pays
25
+ for them again.
26
+ - **Exit codes:** 0 done; 1 failed (invalid input or an error: read the
27
+ message); 2 stopped and resumable (a missing setting, a failed canary,
28
+ another writer, or the cap); 3 done with disclosed limits.
29
+ - **Machine-readable output:** add `--json` to any command and read stdout.
30
+ Progress goes to stderr.
31
+ - **Disclose untrusted reads.** Tell the user once, plainly: the analysis
32
+ stages run Codex in a sandbox that restricts writes and network access,
33
+ not reads, and the answers and pages it reads are untrusted text. The
34
+ stage prompts treat them as material, never as instructions. On a machine
35
+ holding confidential files, a container is the safer place to run.
36
+
37
+ ## Checkpoint 1: install and check
38
+
39
+ 1. Check `node --version` (24 or newer). If Node is missing or older, say
40
+ what you would install and how, and do it only on a yes.
41
+ 2. `npm install -g literally-aeo`. Codex ships with the package; there is
42
+ nothing else to install for the analysis stages.
43
+ 3. `mkdir -p ~/literally-aeo/<brand> && cd ~/literally-aeo/<brand>`, then
44
+ `literally-aeo init`. It writes an example `audit.json` (a fictional
45
+ company: a placeholder for `doctor`, replaced in checkpoint 5) and
46
+ `.env.example`, never over an existing file.
47
+ 4. `literally-aeo doctor --json`. Read `checks`: what is missing, the Codex
48
+ binary the engine will run, and which coding-agent CLIs (`claude`,
49
+ `codex`, `cursor-agent`) are installed. `doctor` cannot tell whether a
50
+ CLI is logged in: a run checks that with a canary before any paid work,
51
+ so never tell the user a login works until a run has passed it.
52
+
53
+ ## Checkpoint 2: accounts and keys
54
+
55
+ Explain each account in one sentence, what it pays for, and the cheapest
56
+ way to start:
57
+
58
+ - **Vercel AI Gateway** (`AI_GATEWAY_API_KEY`): pays for the assistant
59
+ answers the audit measures and every model call that judges them.
60
+ - **DataForSEO** (`DATAFORSEO_LOGIN`, `DATAFORSEO_PASSWORD`): pays for
61
+ Google AI Overviews, the searches that check the product claims answers
62
+ make, and the research behind the proposed config.
63
+
64
+ Copy `.env.example` to `.env` (`cp .env.example .env`) and ask the user to
65
+ open `.env` in their editor and paste the values. Then run
66
+ `literally-aeo doctor --env-file .env --json` again until every setting the
67
+ run needs reports present.
68
+
69
+ Coding-agent surfaces (Claude Code, Codex, Cursor) are measured with the
70
+ CLI's own login on this machine. They matter most when the buyers are
71
+ developers. If the user cannot or will not set one up, remove it from
72
+ `surfaces` in `audit.json` in checkpoint 5 and tell them it is now out of
73
+ scope for this audit.
74
+
75
+ ## Checkpoint 3: the brief
76
+
77
+ Ask, in plain words:
78
+
79
+ - the company name and website;
80
+ - what they want AI assistants to recommend them for;
81
+ - competitors they know (optional);
82
+ - pages that matter most, such as pricing or a product page (optional);
83
+ - anything else worth knowing (optional).
84
+
85
+ Write their answers to `brief.json`:
86
+
87
+ ```json
88
+ {
89
+ "companyName": "Acme Files",
90
+ "website": "https://acme.example",
91
+ "desiredRecommendation": "Secure file sharing for regulated teams",
92
+ "competitors": "Rival Drive (rival.example)",
93
+ "moneyPages": "https://acme.example/pricing",
94
+ "notes": ""
95
+ }
96
+ ```
97
+
98
+ ## Checkpoint 4: approve the research cost
99
+
100
+ Run `literally-aeo author --brief brief.json --estimate --json` and show the
101
+ estimate. It spends nothing. Only on a yes, run
102
+
103
+ ```sh
104
+ literally-aeo author --brief brief.json --output draft --env-file .env --max-usd <approved amount>
105
+ ```
106
+
107
+ It researches the company and proposes `draft/audit.json`, with
108
+ `draft/author-record.json` beside it. Keep both files together.
109
+
110
+ ## Checkpoint 5: approve the questions
111
+
112
+ Read `draft/audit.json` and present it as a short list, never as JSON: the
113
+ sections, the buyer questions in each, the competitors, and the surfaces
114
+ (the assistants that will be asked). Apply the user's edits to
115
+ `draft/audit.json` yourself. The optional `model` field names the model
116
+ that judges and writes the report; leave it out to use the recommended
117
+ one, which `literally-aeo doctor` lists with every supported model. Run
118
+ `literally-aeo doctor --config draft/audit.json --env-file .env --json`
119
+ after editing.
120
+
121
+ ## Checkpoint 6: approve the audit cost
122
+
123
+ Run `literally-aeo plan --config draft/audit.json --output run --json`.
124
+ Show the estimate's low to high range, what drives it (answers per surface,
125
+ the model), and the categories (`estimate.categories`). Recommend
126
+ `recommendedCapUsd`, the high end, as the cap. Say it is an estimate, not a
127
+ quote. The user's approved amount is the cap.
128
+
129
+ ## Checkpoint 7: run and watch
130
+
131
+ Start the run in the background:
132
+
133
+ ```sh
134
+ literally-aeo run --config draft/audit.json --env-file .env --output run --max-usd <approved amount>
135
+ ```
136
+
137
+ It takes from minutes to hours. Follow it with
138
+ `literally-aeo status run --json`: `phase`, `answers` (captured of planned),
139
+ `spend` (charged against `capUsd`, by category), `lastError`. Poll every few
140
+ minutes, not continuously. Tell the user what changed, briefly.
141
+
142
+ When the process exits:
143
+
144
+ - **0**: done. Go to checkpoint 8.
145
+ - **3**: done with disclosed limits (unjudged answers, a narrative marked
146
+ as needing improvement). Explain the limits in plain words, then go to
147
+ checkpoint 8.
148
+ - **2**: stopped and resumable. Read `literally-aeo status run --json` and
149
+ the stderr message and explain why. If `stoppedAtBudget` is true, the cap
150
+ was reached: show what was spent (`spend`) and what is left to do, and
151
+ ask whether to raise it, to what total. Only on a new yes, run the same
152
+ command with `--max-usd <new total cap>`; the raise is recorded, and the
153
+ answers already paid for are reused. Otherwise fix the cause (a setting,
154
+ a login) and run the same command again; it resumes.
155
+ - **1**: read the error, fix the input if you can, and explain it if you
156
+ cannot. Never delete `run/`.
157
+
158
+ To judge the same answers again with another model, use
159
+ `literally-aeo rejudge run --output run-<model> --model <id> --env-file .env`:
160
+ nothing is asked again, and only the judging is paid for. Without
161
+ `--max-usd` it prints its estimate and spends nothing; show that, get an
162
+ amount approved, and run it again with `--max-usd <approved amount>`. A run
163
+ never changes its own model: editing `model` in `audit.json` over an
164
+ existing run directory is refused.
165
+
166
+ ## Checkpoint 8: explain the result
167
+
168
+ Open the report with `literally-aeo view run` (a one-time link on this
169
+ machine only). Summarize: where the brand is mentioned and cited, on which
170
+ assistants, who is recommended instead, and what the report recommends.
171
+ Quote the report; do not add claims it does not make.
172
+
173
+ ## Checkpoint 9: keep and share
174
+
175
+ Offer `literally-aeo export run`: a `.aeo.zip` bundle with the captured
176
+ answers, every judgment, the metrics, the report and the journal of every
177
+ operation, which anyone can check offline with `literally-aeo verify`.
178
+ Credentials found in it block the export. Tell the user the bundle shows
179
+ the questions and the answers, so they should share it only where those can
180
+ be read.
@@ -10,7 +10,6 @@ import type { GroundingBundle } from '../grounding/schema';
10
10
  import { validateGroundingBundle } from '../grounding/validation';
11
11
  import {
12
12
  internalModelRoleDigest,
13
- resolveInternalModelProfile,
14
13
  type InternalModelRoleConfig,
15
14
  } from '../models/profiles';
16
15
  import { ModelBudgetError } from '../models/accounting';
@@ -260,7 +259,7 @@ export const validateAgentCopy = async (args: {
260
259
  runId: string;
261
260
  configVersion?: number;
262
261
  grounding?: GroundingBundle;
263
- verifierProfile?: InternalModelRoleConfig;
262
+ verifierProfile: InternalModelRoleConfig;
264
263
  verifier: RecommendationVerifier;
265
264
  previous?: AeoReportCopy | null;
266
265
  brandLogo?: AeoReportCopy['brandLogo'];
@@ -343,8 +342,7 @@ export const validateAgentCopy = async (args: {
343
342
  };
344
343
  }
345
344
 
346
- const profile =
347
- args.verifierProfile ?? resolveInternalModelProfile().roles.premiseVerifier;
345
+ const profile = args.verifierProfile;
348
346
  let catalog;
349
347
 
350
348
  try {
@@ -776,7 +774,7 @@ export type CopyFactsUnchangedOptions = {
776
774
  config: AeoAuditConfig;
777
775
  runId: string;
778
776
  grounding?: GroundingBundle;
779
- verifierProfile?: InternalModelRoleConfig;
777
+ verifierProfile: InternalModelRoleConfig;
780
778
  };
781
779
 
782
780
  export const copyFactsUnchanged = (
@@ -786,7 +784,7 @@ export const copyFactsUnchanged = (
786
784
  config,
787
785
  runId,
788
786
  grounding,
789
- verifierProfile = resolveInternalModelProfile().roles.premiseVerifier,
787
+ verifierProfile,
790
788
  }: CopyFactsUnchangedOptions,
791
789
  ): boolean => {
792
790
  const facts = new Map(
@@ -869,7 +867,7 @@ export const validateHumanCopy = async (args: {
869
867
  configVersion: number;
870
868
  grounding: GroundingBundle;
871
869
  verifier: RecommendationVerifier;
872
- verifierProfile?: InternalModelRoleConfig;
870
+ verifierProfile: InternalModelRoleConfig;
873
871
  secrets?: readonly string[];
874
872
  signal?: AbortSignal;
875
873
  }): Promise<
@@ -921,8 +919,7 @@ export const validateHumanCopy = async (args: {
921
919
  );
922
920
  }
923
921
 
924
- const profile =
925
- args.verifierProfile ?? resolveInternalModelProfile().roles.premiseVerifier;
922
+ const profile = args.verifierProfile;
926
923
  let facts: ReportFact[];
927
924
 
928
925
  try {
@@ -1101,7 +1098,7 @@ export const assertCopyValidation = (args: {
1101
1098
  snapshot: AeoSnapshot;
1102
1099
  runId: string;
1103
1100
  grounding: unknown;
1104
- verifierProfile?: InternalModelRoleConfig;
1101
+ verifierProfile: InternalModelRoleConfig;
1105
1102
  }): CopyValidationReceipt => {
1106
1103
  const grounding = validateGroundingBundle(args.grounding, {
1107
1104
  reportKey: args.config.reportKey,
@@ -1112,8 +1109,7 @@ export const assertCopyValidation = (args: {
1112
1109
  const provenance = isStoredProvenance(args.provenance)
1113
1110
  ? args.provenance
1114
1111
  : null;
1115
- const profile =
1116
- args.verifierProfile ?? resolveInternalModelProfile().roles.premiseVerifier;
1112
+ const profile = args.verifierProfile;
1117
1113
  const verifierPromptVersions: Record<number, number> = {
1118
1114
  3: 1,
1119
1115
  4: 2,
@@ -1,10 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import type { ModelCallAccounting } from '../models/accounting';
3
3
  import type { GroundingSource } from '../grounding/schema';
4
- import {
5
- resolveInternalModelProfile,
6
- type InternalModelRoleConfig,
7
- } from '../models/profiles';
4
+ import type { InternalModelRoleConfig } from '../models/profiles';
8
5
  import {
9
6
  generateStructured,
10
7
  structuredCallReservation,
@@ -25,9 +22,9 @@ const verdictSchema = z
25
22
  path: z.string(),
26
23
  /** The verdict itself. The premise findings and the flag must
27
24
  * agree, and only the flag lets `errors` reject a block: a
28
- * passing review may still carry stray text there. Measured
29
- * 2026-09-12: GLM wrote "None found." and "none" into `errors`
30
- * for blocks it had approved, and each cost a copy generation. */
25
+ * passing review may still carry stray text there: a measured
26
+ * model wrote "None found." and "none" into `errors` for blocks
27
+ * it had approved, and each cost a copy generation. */
31
28
  passed: z.boolean(),
32
29
  allPremisesCovered: z.boolean(),
33
30
  actionAppropriate: z.boolean(),
@@ -315,7 +312,7 @@ export const checkPremiseVerdicts = (
315
312
  // A declared premise judged on a related fact rather than the one
316
313
  // the writer cited is not refused: the verdict is what matters, the
317
314
  // receipt keeps the verifier's own basis, and refusing it cost three
318
- // of seven verifications on 2026-09-12 (DeepSeek) for nothing.
315
+ // of seven verifications in a measured run for nothing.
319
316
  }
320
317
 
321
318
  // The premise findings are the evidence; the block flag follows them. A
@@ -344,12 +341,11 @@ export const checkPremiseVerdicts = (
344
341
 
345
342
  export const createRecommendationVerifier = (args: {
346
343
  accounting: ModelCallAccounting;
347
- profile?: InternalModelRoleConfig;
344
+ profile: InternalModelRoleConfig;
348
345
  transport?: StructuredTransport;
349
346
  memory?: VerifierMemory;
350
347
  }): RecommendationVerifier => {
351
- const profile =
352
- args.profile ?? resolveInternalModelProfile().roles.premiseVerifier;
348
+ const { profile } = args;
353
349
 
354
350
  return async (requested, signal) => {
355
351
  const history = (await args.memory?.read()) ?? {};
@@ -530,9 +526,9 @@ export const createRecommendationVerifier = (args: {
530
526
  * the caller can classify it.
531
527
  *
532
528
  * Fitting the input limit is not enough on its own for a reasoning model.
533
- * Measured 2026-09-11: packing every block that fit into one call left GLM
534
- * thinking past 40,960 output tokens without returning a verdict, having been
535
- * billed for all of it. What bounds the call is how many judgements it
529
+ * Measured: packing every block that fit into one call left a reasoning
530
+ * model thinking past 40,960 output tokens without returning a verdict,
531
+ * having been billed for all of it. What bounds the call is how many judgements it
536
532
  * contains, not how many bytes.
537
533
  */
538
534
  export const verifierChunks = (
@@ -11,9 +11,9 @@ import { canonicalDigest } from './json';
11
11
  // ============================================================================
12
12
 
13
13
  export const toolId = 'literally-aeo';
14
- // The engine has no package of its own yet (spec §13, Phase 2); bundles
15
- // name this development version until it does.
16
- export const toolVersion = '0.1.1';
14
+ // The package version, recorded in every journal and bundle; the build and
15
+ // version.spec.ts refuse a mismatch with package.json.
16
+ export const toolVersion = '0.2.0';
17
17
  export const bundleSchemaVersion = 1;
18
18
  export const traceSchemaVersion = 1;
19
19
  export const canonicalization = 'literally-aeo-canonical-json-v1';
@@ -0,0 +1,157 @@
1
+ import { z } from 'zod';
2
+ import { readEnv } from '../lib/env';
3
+ import { isAgentSurface } from '../surfaces';
4
+ import type { BundleEvent } from './contracts';
5
+
6
+ // ============================================================================
7
+ // The isolation a run actually had (specs/aeo-open-source-cli-spec.md §4.1,
8
+ // specs/aeo-claude-operator-spec.md §4.4). Each writer records its boundary
9
+ // when it opens the journal; the sandbox of every Codex stage session and
10
+ // every coding-agent probe are already operations in the journal. runtime.json
11
+ // reports what those events show and discloses what a native run lacks; a
12
+ // writer that recorded nothing is unknown, never assumed isolated.
13
+ // ============================================================================
14
+
15
+ export const IsolationBoundary = {
16
+ NATIVE: 'native',
17
+ CONTAINER: 'container',
18
+ } as const;
19
+
20
+ export type IsolationBoundary =
21
+ (typeof IsolationBoundary)[keyof typeof IsolationBoundary];
22
+
23
+ export const writerIsolationSchema = z.looseObject({
24
+ boundary: z.enum([IsolationBoundary.NATIVE, IsolationBoundary.CONTAINER]),
25
+ /** The sandbox the Codex probe surface runs in, should it run. */
26
+ codexProbeSandbox: z.string(),
27
+ });
28
+
29
+ export type WriterIsolation = z.infer<typeof writerIsolationSchema>;
30
+
31
+ /**
32
+ * observedIsolation is this process's boundary: the hosted container runs
33
+ * every agent CLI through an isolated worker under its own UID
34
+ * (AEO_ISOLATED_ADAPTER); anything else runs on the operator's machine as
35
+ * the operator.
36
+ */
37
+ export const observedIsolation = (): WriterIsolation => {
38
+ const isolation: WriterIsolation = {
39
+ boundary:
40
+ readEnv('AEO_ISOLATED_ADAPTER') === '1'
41
+ ? IsolationBoundary.CONTAINER
42
+ : IsolationBoundary.NATIVE,
43
+ codexProbeSandbox:
44
+ readEnv('AEO_CODEX_SANDBOX') === 'danger-full-access'
45
+ ? 'danger-full-access'
46
+ : 'read-only',
47
+ };
48
+
49
+ return isolation;
50
+ };
51
+
52
+ export type RunIsolation = {
53
+ /** One per writer, in journal order; unknown for a writer from before
54
+ * isolation was recorded. */
55
+ writers: (IsolationBoundary | 'unknown')[];
56
+ /** The Codex stage sessions' sandbox modes, as each session recorded. */
57
+ stageSandboxes: string[];
58
+ /** The agent CLIs probed by a native writer: they ran as the operator's
59
+ * own account, with its account-level settings. */
60
+ agentCliAccounts: string[];
61
+ };
62
+
63
+ const runtimeIsolationOf = (
64
+ event: BundleEvent,
65
+ ): IsolationBoundary | 'unknown' => {
66
+ const runtime = z
67
+ .looseObject({ isolation: writerIsolationSchema })
68
+ .safeParse(event.payload.runtime);
69
+
70
+ return runtime.success ? runtime.data.isolation.boundary : 'unknown';
71
+ };
72
+
73
+ const stringOf = (value: unknown): string | undefined => {
74
+ return typeof value === 'string' ? value : undefined;
75
+ };
76
+
77
+ const sandboxOf = (event: BundleEvent): string | undefined => {
78
+ const details = z
79
+ .looseObject({ sandbox: z.string() })
80
+ .safeParse(event.payload.details);
81
+
82
+ return details.success ? details.data.sandbox : undefined;
83
+ };
84
+
85
+ /** summarizeIsolation reads a run's isolation from its journal events. */
86
+ export const summarizeIsolation = (
87
+ events: readonly BundleEvent[],
88
+ ): RunIsolation => {
89
+ const writers: RunIsolation['writers'] = [];
90
+ const stageSandboxes = new Set<string>();
91
+ const agentCliAccounts = new Set<string>();
92
+
93
+ for (const event of events) {
94
+ if (event.type === 'run_started' || event.type === 'run_resumed') {
95
+ writers.push(runtimeIsolationOf(event));
96
+ continue;
97
+ }
98
+
99
+ if (event.type !== 'operation_started') {
100
+ continue;
101
+ }
102
+
103
+ const kind = stringOf(event.payload.kind);
104
+ const role = stringOf(event.payload.role);
105
+ const sandbox = sandboxOf(event);
106
+
107
+ if (kind === 'codex_session' && sandbox !== undefined) {
108
+ stageSandboxes.add(sandbox);
109
+ }
110
+
111
+ // A probe belongs to the writer that opened the journal before it.
112
+ const writer = writers.at(-1);
113
+
114
+ if (
115
+ (kind === 'probe' || kind === 'canary') &&
116
+ role !== undefined &&
117
+ isAgentSurface(role) &&
118
+ writer !== IsolationBoundary.CONTAINER
119
+ ) {
120
+ agentCliAccounts.add(role);
121
+ }
122
+ }
123
+
124
+ const isolation: RunIsolation = {
125
+ writers,
126
+ stageSandboxes: [...stageSandboxes].sort(),
127
+ agentCliAccounts: [...agentCliAccounts].sort(),
128
+ };
129
+
130
+ return isolation;
131
+ };
132
+
133
+ /** isolationLimitations states what the recorded isolation does not
134
+ * cover, in plain sentences for runtime.json. */
135
+ export const isolationLimitations = (isolation: RunIsolation): string[] => {
136
+ const limitations: string[] = [];
137
+
138
+ if (isolation.writers.includes('unknown')) {
139
+ limitations.push(
140
+ 'A writer of this run predates isolation recording; its boundary is unknown.',
141
+ );
142
+ }
143
+
144
+ if (isolation.writers.includes(IsolationBoundary.NATIVE)) {
145
+ limitations.push(
146
+ "Part or all of this run executed natively, without a container boundary. Codex sandboxes restrict writes and network access, not reads: a Codex session could read any file the operator's account can, while it processed untrusted answers and pages.",
147
+ );
148
+ }
149
+
150
+ if (isolation.agentCliAccounts.length > 0) {
151
+ limitations.push(
152
+ `The coding-agent CLIs ${isolation.agentCliAccounts.join(', ')} ran as the operator's own account. Account-level settings outside the tool's control (user rules, approved MCP servers) applied and are not recorded.`,
153
+ );
154
+ }
155
+
156
+ return limitations;
157
+ };
@@ -8,6 +8,7 @@ import {
8
8
  RunOrigin,
9
9
  type BundleManifest,
10
10
  } from './contracts';
11
+ import { summarizeIsolation, type RunIsolation } from './isolation';
11
12
  import { readJournal } from './journal';
12
13
  import { sha256Hex } from './json';
13
14
  import { runJournalDir } from './recorder';
@@ -61,6 +62,7 @@ export type JournalProjection = {
61
62
  origin: RunOrigin;
62
63
  trace: BundleManifest['trace'];
63
64
  writers: z.infer<typeof runtimeSchema>[];
65
+ isolation: RunIsolation;
64
66
  };
65
67
 
66
68
  /**
@@ -100,6 +102,7 @@ export const projectJournal = async (
100
102
  origin: RunOrigin.LEGACY_IMPORT,
101
103
  trace: { coverage: 'none', limitations: legacyTraceLimitations },
102
104
  writers: [],
105
+ isolation: summarizeIsolation([]),
103
106
  };
104
107
  }
105
108
 
@@ -173,6 +176,7 @@ export const projectJournal = async (
173
176
  origin: origin.success ? origin.data : RunOrigin.LEGACY_IMPORT,
174
177
  trace,
175
178
  writers,
179
+ isolation: summarizeIsolation(events),
176
180
  };
177
181
 
178
182
  return projection;
@@ -2,7 +2,7 @@ import { readdir, readFile } from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
  import { credentialDetected } from '../agents/credentials';
4
4
  import { capturePlan } from '../capture-manifest';
5
- import { codexModel } from '../codex-workflow/codex-home';
5
+ import { codexGateway } from '../codex-workflow/codex-home';
6
6
  import { stagePrompts } from '../codex-workflow/prompts';
7
7
  import { readRunInputs, type RunInputs } from '../codex-workflow/run-inputs';
8
8
  import { stageVersions } from '../codex-workflow/schemas';
@@ -19,6 +19,7 @@ import {
19
19
  predecessorPrefix,
20
20
  type PlanDocument,
21
21
  } from './contracts';
22
+ import { isolationLimitations } from './isolation';
22
23
  import { canonicalDigest, encodeBundleJson } from './json';
23
24
  import { bundlePathError } from './paths';
24
25
  import { predecessorDir, readDerivedFrom, type DerivedFrom } from './lineage';
@@ -111,6 +112,21 @@ const runPolicyOf = (request: RunInputs['request']) => {
111
112
  return runPolicy;
112
113
  };
113
114
 
115
+ /** The Codex stages' model as the run pinned it; null for a run whose
116
+ * profile predates the stage model in the profile (its sessions record the
117
+ * model they asked for in the journal). */
118
+ const stageModelOf = (inputs: RunInputs) => {
119
+ const stages = inputs.request.modelProfile?.stages;
120
+
121
+ return stages
122
+ ? {
123
+ model: stages.model,
124
+ provider: codexGateway.providerName,
125
+ reasoningEffort: stages.reasoningEffort,
126
+ }
127
+ : null;
128
+ };
129
+
114
130
  const methodOf = async (dir: string, inputs: RunInputs, snapshot: unknown) => {
115
131
  const meta =
116
132
  isRecord(snapshot) && isRecord(snapshot.meta) ? snapshot.meta : {};
@@ -142,11 +158,7 @@ const methodOf = async (dir: string, inputs: RunInputs, snapshot: unknown) => {
142
158
  // a session's own packet is in the journal.
143
159
  stagePrompts,
144
160
  stageVersions,
145
- codexModel: {
146
- model: codexModel.model,
147
- provider: codexModel.providerName,
148
- reasoningEffort: codexModel.reasoningEffort,
149
- },
161
+ codexModel: stageModelOf(inputs),
150
162
  };
151
163
 
152
164
  return method;
@@ -303,9 +315,10 @@ export const projectWorkdir = async (
303
315
  version: 1,
304
316
  writers: journal.writers,
305
317
  agentCliVersions: capture.agentCliVersions,
318
+ isolation: journal.isolation,
306
319
  limitations:
307
320
  journal.writers.length > 0
308
- ? []
321
+ ? isolationLimitations(journal.isolation)
309
322
  : [
310
323
  'The work directory predates runtime recording; the writers of this run are unknown.',
311
324
  ],
@@ -18,6 +18,7 @@ import {
18
18
  type RunOrigin,
19
19
  } from './contracts';
20
20
  import { openJournal, putObject, readJournal, type Journal } from './journal';
21
+ import { observedIsolation, type WriterIsolation } from './isolation';
21
22
 
22
23
  // ============================================================================
23
24
  // The execution recorder (specs/aeo-open-source-cli-spec.md §7): the host
@@ -169,6 +170,9 @@ export type OpenRecorderOptions = {
169
170
  * run_resumed (spec §7.2): the export claims coverage only for kinds
170
171
  * every writer observed. Defaults to the workflow's own. */
171
172
  observes?: readonly OperationKind[];
173
+ /** The boundary this writer runs inside; observed from the process when
174
+ * the writer does not state it. */
175
+ isolation?: WriterIsolation;
172
176
  };
173
177
 
174
178
  const frozenMeasurement = (text: string): string | undefined => {
@@ -220,6 +224,7 @@ export const openRecorder = async (
220
224
  node: process.version,
221
225
  platform: process.platform,
222
226
  arch: process.arch,
227
+ isolation: options.isolation ?? observedIsolation(),
223
228
  };
224
229
 
225
230
  const observes = [...(options.observes ?? workflowOperationKinds)];
@@ -131,3 +131,30 @@ export const acquireWriterLock = async (
131
131
 
132
132
  return { takenOver, release };
133
133
  };
134
+
135
+ /** live: the process runs on this host; abandoned: it is gone from this
136
+ * host; unknown: it belongs to another host, which this one cannot ask. */
137
+ export type WriterLockState = 'live' | 'abandoned' | 'unknown';
138
+
139
+ /** readWriterLock reports who holds a run directory without taking it:
140
+ * undefined when no writer does. */
141
+ export const readWriterLock = async (
142
+ dir: string,
143
+ ): Promise<{ owner: WriterLockOwner; state: WriterLockState } | undefined> => {
144
+ const owner = await readOwner(path.join(dir, writerLockFile)).catch(
145
+ // A lock torn mid-write reads as an unknown owner, never as no writer.
146
+ () => ({ host: '', pid: -1, purpose: 'unknown', acquiredAt: '' }),
147
+ );
148
+
149
+ if (owner === undefined) {
150
+ return undefined;
151
+ }
152
+
153
+ let state: WriterLockState = 'unknown';
154
+
155
+ if (owner.host === hostname()) {
156
+ state = owner.pid > 0 && isProcessAlive(owner.pid) ? 'live' : 'abandoned';
157
+ }
158
+
159
+ return { owner, state };
160
+ };
@@ -0,0 +1,28 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import { engineResources } from '../engine/resources';
3
+ import { writeOut, type Flags } from './io';
4
+
5
+ // ============================================================================
6
+ // literally-aeo guide (specs/aeo-claude-operator-spec.md §4.5): the operator
7
+ // guide for an AI agent running an audit for a user, printed from the
8
+ // installed package so it always matches the commands of this version.
9
+ // ============================================================================
10
+
11
+ /** readOperatorGuide returns the guide this engine ships. */
12
+ export const readOperatorGuide = async (): Promise<string> => {
13
+ const { guide } = await engineResources();
14
+
15
+ return readFile(guide, 'utf8');
16
+ };
17
+
18
+ export const runGuide = async (flags: Flags) => {
19
+ const guide = await readOperatorGuide();
20
+
21
+ writeOut(
22
+ flags.switches.has('--json')
23
+ ? JSON.stringify({ resultVersion: 1, command: 'guide', guide })
24
+ : guide.trimEnd(),
25
+ );
26
+
27
+ return 0;
28
+ };