@hawkeyexl/manni 4.3.1 → 4.4.1

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 (225) hide show
  1. package/README.md +9 -1
  2. package/dist/batch-GFNLTGOH.js +36 -0
  3. package/dist/build-COYIQ25L.js +31 -0
  4. package/dist/calibrate-MDBLJKEE.js +31 -0
  5. package/dist/capture-LRML2PKV.js +32 -0
  6. package/dist/check-ASPIHA6B.js +40 -0
  7. package/dist/check-ASPIHA6B.js.map +1 -0
  8. package/dist/check-EDLBYL5N.js +27 -0
  9. package/dist/check-EDLBYL5N.js.map +1 -0
  10. package/dist/check-HYNGXYJV.js +18 -0
  11. package/dist/check-HYNGXYJV.js.map +1 -0
  12. package/dist/chunk-2B7ZNTPV.js +230 -0
  13. package/dist/chunk-2B7ZNTPV.js.map +1 -0
  14. package/dist/chunk-2H7UOFLK.js +11 -0
  15. package/dist/chunk-2H7UOFLK.js.map +1 -0
  16. package/dist/chunk-37LP5HMZ.js +1042 -0
  17. package/dist/chunk-37LP5HMZ.js.map +1 -0
  18. package/dist/chunk-3VK37OR2.js +2957 -0
  19. package/dist/chunk-3VK37OR2.js.map +1 -0
  20. package/dist/chunk-4IUC2MNL.js +2165 -0
  21. package/dist/chunk-4IUC2MNL.js.map +1 -0
  22. package/dist/{chunk-3R23C5DT.js → chunk-4TSWU2SU.js} +2 -14
  23. package/dist/chunk-4TSWU2SU.js.map +1 -0
  24. package/dist/chunk-57NEQRVO.js +10921 -0
  25. package/dist/chunk-57NEQRVO.js.map +1 -0
  26. package/dist/chunk-6JSSEWBG.js +6737 -0
  27. package/dist/chunk-6JSSEWBG.js.map +1 -0
  28. package/dist/chunk-6OYEI2VV.js +88 -0
  29. package/dist/chunk-6OYEI2VV.js.map +1 -0
  30. package/dist/chunk-77AINBYM.js +19 -0
  31. package/dist/chunk-77AINBYM.js.map +1 -0
  32. package/dist/chunk-7UKO3ASZ.js +54 -0
  33. package/dist/chunk-7UKO3ASZ.js.map +1 -0
  34. package/dist/chunk-A5ULMVHQ.js +164 -0
  35. package/dist/chunk-A5ULMVHQ.js.map +1 -0
  36. package/dist/chunk-C4SQM22E.js +299 -0
  37. package/dist/chunk-C4SQM22E.js.map +1 -0
  38. package/dist/chunk-CK7SKVHR.js +1042 -0
  39. package/dist/chunk-CK7SKVHR.js.map +1 -0
  40. package/dist/{chunk-G5CM2VGQ.js → chunk-DXNZS72W.js} +8 -94
  41. package/dist/chunk-DXNZS72W.js.map +1 -0
  42. package/dist/chunk-EPH54CAY.js +374 -0
  43. package/dist/chunk-EPH54CAY.js.map +1 -0
  44. package/dist/{chunk-KJR7OVDX.js → chunk-FBEQCK47.js} +56 -137
  45. package/dist/chunk-FBEQCK47.js.map +1 -0
  46. package/dist/{chunk-IOYXPBCL.js → chunk-G3T47CFV.js} +1 -7
  47. package/dist/{chunk-IOYXPBCL.js.map → chunk-G3T47CFV.js.map} +1 -1
  48. package/dist/chunk-GCQRPUSB.js +1287 -0
  49. package/dist/chunk-GCQRPUSB.js.map +1 -0
  50. package/dist/chunk-GLP5PSXB.js +72 -0
  51. package/dist/chunk-GLP5PSXB.js.map +1 -0
  52. package/dist/chunk-I2AH3CJJ.js +1192 -0
  53. package/dist/chunk-I2AH3CJJ.js.map +1 -0
  54. package/dist/chunk-IDV6HJCB.js +388 -0
  55. package/dist/chunk-IDV6HJCB.js.map +1 -0
  56. package/dist/chunk-IKEWBMCN.js +98 -0
  57. package/dist/chunk-IKEWBMCN.js.map +1 -0
  58. package/dist/chunk-JCDXE76J.js +52 -0
  59. package/dist/chunk-JCDXE76J.js.map +1 -0
  60. package/dist/chunk-JXLTXMJ7.js +455 -0
  61. package/dist/chunk-JXLTXMJ7.js.map +1 -0
  62. package/dist/chunk-LJ2RDH3F.js +49 -0
  63. package/dist/chunk-LJ2RDH3F.js.map +1 -0
  64. package/dist/chunk-M2JCK5F6.js +805 -0
  65. package/dist/chunk-M2JCK5F6.js.map +1 -0
  66. package/dist/chunk-M3W7J6MU.js +4398 -0
  67. package/dist/chunk-M3W7J6MU.js.map +1 -0
  68. package/dist/chunk-MMTSSTG7.js +23 -0
  69. package/dist/chunk-MMTSSTG7.js.map +1 -0
  70. package/dist/chunk-MNH7QO4Z.js +15 -0
  71. package/dist/chunk-MNH7QO4Z.js.map +1 -0
  72. package/dist/chunk-MWJLZMBL.js +934 -0
  73. package/dist/chunk-MWJLZMBL.js.map +1 -0
  74. package/dist/chunk-MYMBCTDE.js +387 -0
  75. package/dist/chunk-MYMBCTDE.js.map +1 -0
  76. package/dist/chunk-NCPWXHDO.js +683 -0
  77. package/dist/chunk-NCPWXHDO.js.map +1 -0
  78. package/dist/chunk-NLXTXE5Y.js +1661 -0
  79. package/dist/chunk-NLXTXE5Y.js.map +1 -0
  80. package/dist/{chunk-CFDUZRM2.js → chunk-NXV7WE2D.js} +32 -240
  81. package/dist/chunk-NXV7WE2D.js.map +1 -0
  82. package/dist/chunk-OWBRDNRZ.js +16 -0
  83. package/dist/chunk-OWBRDNRZ.js.map +1 -0
  84. package/dist/{chunk-KTSJ2ZHA.js → chunk-PAU352SV.js} +5 -3
  85. package/dist/{chunk-KTSJ2ZHA.js.map → chunk-PAU352SV.js.map} +1 -1
  86. package/dist/chunk-PCE7QHXJ.js +68 -0
  87. package/dist/chunk-PCE7QHXJ.js.map +1 -0
  88. package/dist/chunk-PIKOVN6W.js +1651 -0
  89. package/dist/chunk-PIKOVN6W.js.map +1 -0
  90. package/dist/chunk-PNPQTHBT.js +17 -0
  91. package/dist/chunk-PNPQTHBT.js.map +1 -0
  92. package/dist/chunk-PU6DFJMY.js +1975 -0
  93. package/dist/chunk-PU6DFJMY.js.map +1 -0
  94. package/dist/chunk-Q35YIDBV.js +1202 -0
  95. package/dist/chunk-Q35YIDBV.js.map +1 -0
  96. package/dist/{chunk-5HNHEUD5.js → chunk-QQUKGCAJ.js} +3 -3
  97. package/dist/chunk-QRWGPQKO.js +198 -0
  98. package/dist/chunk-QRWGPQKO.js.map +1 -0
  99. package/dist/{chunk-UBMMXS2Y.js → chunk-QZ6LRSNV.js} +69 -48
  100. package/dist/{chunk-UBMMXS2Y.js.map → chunk-QZ6LRSNV.js.map} +1 -1
  101. package/dist/chunk-RL5XWQOL.js +3872 -0
  102. package/dist/chunk-RL5XWQOL.js.map +1 -0
  103. package/dist/chunk-RNVYGWIC.js +30 -0
  104. package/dist/chunk-RNVYGWIC.js.map +1 -0
  105. package/dist/chunk-SE4JN5XN.js +19 -0
  106. package/dist/chunk-SE4JN5XN.js.map +1 -0
  107. package/dist/chunk-SKSDRUUK.js +622 -0
  108. package/dist/chunk-SKSDRUUK.js.map +1 -0
  109. package/dist/chunk-TIUTIOFB.js +25 -0
  110. package/dist/chunk-TIUTIOFB.js.map +1 -0
  111. package/dist/chunk-TK3FC4RF.js +3090 -0
  112. package/dist/chunk-TK3FC4RF.js.map +1 -0
  113. package/dist/chunk-TU2WUBVZ.js +2 -0
  114. package/dist/chunk-TU2WUBVZ.js.map +1 -0
  115. package/dist/chunk-TZOYZK2E.js +98 -0
  116. package/dist/chunk-TZOYZK2E.js.map +1 -0
  117. package/dist/chunk-UJCVAWP7.js +178 -0
  118. package/dist/chunk-UJCVAWP7.js.map +1 -0
  119. package/dist/chunk-UKZNLVJW.js +17 -0
  120. package/dist/chunk-UKZNLVJW.js.map +1 -0
  121. package/dist/{chunk-HAPTXWU2.js → chunk-UQISLDAV.js} +4 -4
  122. package/dist/chunk-WB3QM6PP.js +5440 -0
  123. package/dist/chunk-WB3QM6PP.js.map +1 -0
  124. package/dist/chunk-YB4IBW3M.js +96 -0
  125. package/dist/chunk-YB4IBW3M.js.map +1 -0
  126. package/dist/chunk-YEUYKR62.js +72 -0
  127. package/dist/chunk-YEUYKR62.js.map +1 -0
  128. package/dist/chunk-YJOGUXGP.js +634 -0
  129. package/dist/chunk-YJOGUXGP.js.map +1 -0
  130. package/dist/chunk-YNHZHSSM.js +41 -0
  131. package/dist/chunk-YNHZHSSM.js.map +1 -0
  132. package/dist/chunk-YTURO7SI.js +979 -0
  133. package/dist/chunk-YTURO7SI.js.map +1 -0
  134. package/dist/chunk-ZXRAE55H.js +31 -0
  135. package/dist/chunk-ZXRAE55H.js.map +1 -0
  136. package/dist/cli-3BIBYHFK.js +473 -0
  137. package/dist/cli-3BIBYHFK.js.map +1 -0
  138. package/dist/cli-673OTRGE.js +28 -0
  139. package/dist/cli-673OTRGE.js.map +1 -0
  140. package/dist/cli-6HIDIFVT.js +1203 -0
  141. package/dist/cli-6HIDIFVT.js.map +1 -0
  142. package/dist/cli-6UB5N6CU.js +232 -0
  143. package/dist/cli-6UB5N6CU.js.map +1 -0
  144. package/dist/cli-LFP5ZGYS.js +346 -0
  145. package/dist/cli-LFP5ZGYS.js.map +1 -0
  146. package/dist/cli-MN7PYMBI.js +552 -0
  147. package/dist/cli-MN7PYMBI.js.map +1 -0
  148. package/dist/cli-PYPX6O6E.js +739 -0
  149. package/dist/cli-PYPX6O6E.js.map +1 -0
  150. package/dist/cli-RPM5PELX.js +626 -0
  151. package/dist/cli-RPM5PELX.js.map +1 -0
  152. package/dist/cli-VI7VHWNZ.js +423 -0
  153. package/dist/cli-VI7VHWNZ.js.map +1 -0
  154. package/dist/cli.d.ts +12 -2
  155. package/dist/cli.js +109 -7661
  156. package/dist/cli.js.map +1 -1
  157. package/dist/docmeta.js +15 -3
  158. package/dist/docmeta.js.map +1 -1
  159. package/dist/github-6QMYOHC3.js +27 -0
  160. package/dist/github-6QMYOHC3.js.map +1 -0
  161. package/dist/github-SXPGP5DB.js +32 -0
  162. package/dist/github-SXPGP5DB.js.map +1 -0
  163. package/dist/index.d.ts +65 -3
  164. package/dist/index.js +407 -337
  165. package/dist/index.js.map +1 -1
  166. package/dist/json-7WV7KL6H.js +17 -0
  167. package/dist/json-7WV7KL6H.js.map +1 -0
  168. package/dist/json-SY7KLNC7.js +35 -0
  169. package/dist/json-SY7KLNC7.js.map +1 -0
  170. package/dist/lint-ASMJLLPA.js +28 -0
  171. package/dist/lint-ASMJLLPA.js.map +1 -0
  172. package/dist/list-KZNVTNVC.js +31 -0
  173. package/dist/list-KZNVTNVC.js.map +1 -0
  174. package/dist/list-Q57YTFUQ.js +29 -0
  175. package/dist/list-Q57YTFUQ.js.map +1 -0
  176. package/dist/page-KSGV5RD4.js +41 -0
  177. package/dist/page-KSGV5RD4.js.map +1 -0
  178. package/dist/picker-3XF36MJF.js +14 -0
  179. package/dist/picker-3XF36MJF.js.map +1 -0
  180. package/dist/pretty-A5EGTN35.js +37 -0
  181. package/dist/pretty-A5EGTN35.js.map +1 -0
  182. package/dist/pretty-CXSDXNAS.js +43 -0
  183. package/dist/pretty-CXSDXNAS.js.map +1 -0
  184. package/dist/reporters-HUY7UXFS.js +42 -0
  185. package/dist/reporters-HUY7UXFS.js.map +1 -0
  186. package/dist/reporters-K2VUKSAK.js +71 -0
  187. package/dist/reporters-K2VUKSAK.js.map +1 -0
  188. package/dist/reporters-M6LJ2IYU.js +21 -0
  189. package/dist/reporters-M6LJ2IYU.js.map +1 -0
  190. package/dist/run-3DYJNRIG.js +33 -0
  191. package/dist/run-3DYJNRIG.js.map +1 -0
  192. package/dist/term-BIQUPMOR.js +1592 -0
  193. package/dist/term-BIQUPMOR.js.map +1 -0
  194. package/dist/types-Y6TXHM7M.js +10 -0
  195. package/dist/types-Y6TXHM7M.js.map +1 -0
  196. package/dist/validate-53RKM2XG.js +16 -0
  197. package/dist/validate-53RKM2XG.js.map +1 -0
  198. package/package.json +1 -1
  199. package/plugin/manni/.claude-plugin/plugin.json +9 -0
  200. package/plugin/manni/hooks/hooks.json +69 -0
  201. package/plugin/manni/hooks/manni.mjs +157 -0
  202. package/plugin/manni/skills/check/SKILL.md +20 -0
  203. package/plugin/manni/skills/evals/SKILL.md +27 -0
  204. package/plugin/manni/skills/fix/SKILL.md +56 -0
  205. package/plugin/manni/skills/setup/SKILL.md +41 -0
  206. package/dist/batch-A5HZKYIW.js +0 -18
  207. package/dist/calibrate-S5K6QHUY.js +0 -13
  208. package/dist/capture-OZEZDABQ.js +0 -15
  209. package/dist/chunk-3R23C5DT.js.map +0 -1
  210. package/dist/chunk-CFDUZRM2.js.map +0 -1
  211. package/dist/chunk-G5CM2VGQ.js.map +0 -1
  212. package/dist/chunk-KJR7OVDX.js.map +0 -1
  213. package/dist/chunk-V4KUVE47.js +0 -27170
  214. package/dist/chunk-V4KUVE47.js.map +0 -1
  215. package/dist/chunk-ZQBTK3DO.js +0 -26518
  216. package/dist/chunk-ZQBTK3DO.js.map +0 -1
  217. package/dist/picker-6HRMETE7.js +0 -12
  218. package/plugin/tracevals/.claude-plugin/plugin.json +0 -9
  219. package/plugin/tracevals/hooks/hooks.json +0 -17
  220. /package/dist/{batch-A5HZKYIW.js.map → batch-GFNLTGOH.js.map} +0 -0
  221. /package/dist/{calibrate-S5K6QHUY.js.map → build-COYIQ25L.js.map} +0 -0
  222. /package/dist/{capture-OZEZDABQ.js.map → calibrate-MDBLJKEE.js.map} +0 -0
  223. /package/dist/{picker-6HRMETE7.js.map → capture-LRML2PKV.js.map} +0 -0
  224. /package/dist/{chunk-5HNHEUD5.js.map → chunk-QQUKGCAJ.js.map} +0 -0
  225. /package/dist/{chunk-HAPTXWU2.js.map → chunk-UQISLDAV.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/docevals/judge/judge.ts","../src/docevals/judge/verdict-schema.json","../src/docevals/core/reviews.ts","../src/docevals/judge/provider.ts","../src/docevals/graders/scriptgen.ts","../src/docevals/core/frontmatter-edit.ts","../src/docevals/core/write-location.ts","../src/docevals/commands/run.ts"],"sourcesContent":["/**\n * The ensemble judge: N independent runs per (page, eval), each a fresh\n * request with no shared context (eval isolation), aggregated by consensus\n * and routed through confidence zones. Persisted human reviews resolve\n * needs-review outcomes for unchanged pages.\n *\n * The ensemble mechanics — retry-once, errored runs counting against\n * consensus, cache replay — live in `@hawkeyexl/inference` (ADR 01002). What\n * stays here is manni docevals' own orchestration: the bounded-concurrency pool\n * across targets, the turn budget, the self-judgment warning, and human-review\n * resolution.\n */\nimport {\n computeConsensus,\n runEnsemble,\n zoneFor,\n type InferenceProvider,\n} from \"@hawkeyexl/inference\";\nimport verdictSchemaJson from \"./verdict-schema.json\" with { type: \"json\" };\nimport type { EvalResult } from \"../types.js\";\nimport type { DocevalsConfig } from \"../core/config.js\";\nimport type { JudgeFn, JudgeOptions } from \"../core/engine.js\";\nimport type { GraderTarget } from \"../graders/types.js\";\nimport { findReview, loadReviews } from \"../core/reviews.js\";\nimport { cacheKey, judgeCacheBody, VerdictCache } from \"./cache.js\";\nimport { turnBudgetSkipReason } from \"./budget.js\";\nimport {\n JUDGE_SYSTEM_PROMPT,\n buildUserContent,\n EVIDENCE_SYSTEM_PROMPT,\n EVIDENCE_SCHEMA,\n buildEvidenceUser,\n renderEvidence,\n type PartEvidence,\n} from \"./prompt.js\";\nimport { splitBody } from \"../core/split.js\";\nimport { readTarget } from \"../core/target.js\";\nimport { selfPreferenceOf } from \"./self-preference.js\";\nimport {\n announceSelection,\n assertProviderSelection,\n makeProvider,\n selectProvider,\n} from \"./provider.js\";\nimport { DocevalsError } from \"../types.js\";\nimport type { ResolvedEval } from \"../core/resolve.js\";\nimport { resolve as resolvePath } from \"node:path\";\nimport { warn } from \"../../shared/warn.js\";\nimport { errorMessage } from \"../../shared/errors.js\";\n\n/**\n * manni docevals' own verdict wording. Structurally identical to the library's\n * canonical schema, but the field descriptions talk about pages rather than\n * generic subjects — and descriptions are prompt surface that steers the\n * model, so they are worth keeping (the inference library's own ADR 01001,\n * not this repo's).\n */\nconst verdictSchema = verdictSchemaJson as Record<string, unknown>;\n\nexport interface JudgeStageDeps {\n /** Provider for evals that do not override `provider`/`model`. */\n provider: InferenceProvider;\n root: string;\n /**\n * Build a provider for an eval that overrides `provider` or `model`.\n *\n * Injected so the engine's tests can drive per-eval overrides with a mock.\n * When absent, one is built from the resolved config — without it `provider`\n * and `model` would validate, appear in the schema, and do nothing, which is\n * worse than not offering them.\n */\n providerFor?: (ev: ResolvedEval) => InferenceProvider | Promise<InferenceProvider>;\n}\n\n/** Build the engine's judge stage around a concrete provider. */\nexport function makeJudge(deps: JudgeStageDeps): JudgeFn {\n return async (\n targets: GraderTarget[],\n config: DocevalsConfig,\n options: JudgeOptions,\n ): Promise<EvalResult[]> => {\n const { provider, root } = deps;\n\n // CLI > eval > config, the same precedence `runsFor` uses, settled by\n // `selectProvider` so the run's provider and an eval's are chosen by one\n // rule. Providers are memoized on the selection an eval *resolves to*, not\n // on what it wrote: with `--provider anthropic` in force, an eval naming\n // `openai` and one naming `mock` both resolve to the same provider, and\n // keying on the authored value would build it twice. The effective pair is\n // also what decides the short-circuit — an eval whose selection is the\n // run's own needs no provider of its own.\n //\n // Memoized as a promise, so a selection that detects or fails does so\n // once, and every eval sharing it gets the same provider or the same error.\n const overridden = new Map<string, Promise<InferenceProvider>>();\n const buildProvider =\n deps.providerFor ??\n ((ev: ResolvedEval): Promise<InferenceProvider> => makeProvider(config, options, ev));\n const keyOf = (s: { provider: string; model: string | undefined }): string =>\n `${s.provider}:${s.model ?? \"\"}`;\n const defaultKey = keyOf(selectProvider(config, options));\n const providerFor = (ev: ResolvedEval, file: string): Promise<InferenceProvider> => {\n // Only the eval's own two fields: a `ResolvedEval` carries a `source` of\n // its own, and the origin a `--local` notice names is the page's.\n const selection = selectProvider(config, options, {\n ...(ev.provider !== undefined ? { provider: ev.provider } : {}),\n ...(ev.model !== undefined ? { model: ev.model } : {}),\n origin: `eval \"${ev.name}\" in ${file}`,\n });\n // Said before the short-circuit: under `--local` an eval naming a hosted\n // provider resolves to the run's own selection, and is still replaced.\n announceSelection(selection);\n const key = keyOf(selection);\n if (key === defaultKey) return Promise.resolve(provider);\n let p = overridden.get(key);\n if (p === undefined) {\n // The eval's own choice follows the run's rules: an unknown name or a\n // model with no provider to own it is refused before anything is built.\n p = (async () => {\n assertProviderSelection(selection);\n return buildProvider(ev);\n })();\n overridden.set(key, p);\n }\n return p;\n };\n // CLI > eval > config. The flag is an explicit operator act (\"run cheap\n // right now\"), so it outranks a page asking for more agreement; the page\n // outranks the corpus default, which is the point of having it.\n const runsFor = (ev: ResolvedEval): number =>\n options.runs ?? ev.runs ?? config.judge.ensembleRuns;\n const temperature = config.judge.temperature;\n const chunkChars = options.chunkChars ?? config.judge.chunkChars;\n const cache = new VerdictCache(\n resolvePath(root, config.judge.cacheDir),\n options.noCache !== true,\n \"manni-docevals\",\n );\n const reviews = loadReviews(root);\n const maxTurns = options.maxTurns ?? config.judge.maxTurns;\n let turnsSpent = 0;\n\n const results: EvalResult[] = [];\n // `makeJudge` is a published export taking a caller-supplied config, so a\n // JS consumer can hand us one shaped for a version before `judge.concurrency`\n // existed. The type says that cannot happen; at a package boundary it can.\n // Unguarded it is `Math.min(undefined, n)` -> NaN -> `Array.from({length:\n // NaN})` -> zero workers, and every AI eval vanishes from the results —\n // not skipped, not errored, absent — with the run exiting 0.\n //\n // Tested with `Number.isFinite` rather than `??` because the value is typed\n // non-optional: `??` is dead code to the compiler and the lint rejects it,\n // while the runtime hazard is real. This says what is actually being\n // checked (ADR 01039).\n // `Number.isInteger(n) && n >= 1`, not `Number.isFinite`: the hazard is a\n // worker pool of zero, and `Number.isFinite(0)` is `true`. A caller-supplied\n // `judge.concurrency: 0` sails past a finite check into\n // `Array.from({length: 0})`, which builds no workers at all — every AI eval\n // then vanishes from the results, not skipped and not errored but absent,\n // with the run exiting 0. The config file cannot express it (`minimum: 1`),\n // but `makeJudge` is exported and takes a caller-supplied config.\n const configured = config.judge.concurrency;\n const concurrency =\n Number.isInteger(configured) && configured >= 1\n ? configured\n : config.defaults.concurrency;\n let index = 0;\n\n const judgeTarget = async (target: GraderTarget): Promise<EvalResult> => {\n const { plan, eval: ev } = target;\n const start = Date.now();\n const runsPerEval = runsFor(ev);\n // A provider the eval chose that cannot be had is that eval's error, as a\n // target it cannot serve is below: the rest of the corpus still gets its\n // verdicts, and the run exits 1 rather than stopping.\n let judgeProvider: InferenceProvider;\n try {\n judgeProvider = await providerFor(ev, plan.page.file);\n } catch (e) {\n if (!(e instanceof DocevalsError)) throw e;\n return {\n evalName: ev.name,\n type: ev.type,\n grader: ev.grader,\n file: plan.page.file,\n outcome: \"error\",\n skipReason: e.message,\n durationMs: Date.now() - start,\n };\n }\n\n // Self-preference, compared against the model that judges *this eval*,\n // not the run's default: an eval naming its own provider or model is\n // exactly the case a run-wide comparison would miss. Said per page and\n // eval rather than deduplicated by model name, so a corpus with several\n // affected pages names each one instead of only the first. Marked on the\n // result too: a verdict formed under self-preference must not look\n // identical to any other in JSON, SARIF, JUnit or the HTML report.\n const preference = selfPreferenceOf(plan, ev, judgeProvider.modelName());\n if (preference) warn(`${plan.page.file}: ${preference.message}`);\n\n // Read what the eval asked to be graded. A target that cannot be served\n // errors here rather than falling back to the page body: a verdict about\n // the wrong bytes is worse than no verdict (ADR 01022).\n const selected = readTarget(ev.target, plan);\n if (!selected.ok) {\n return {\n evalName: ev.name,\n type: ev.type,\n grader: ev.grader,\n file: plan.page.file,\n outcome: \"error\",\n skipReason: selected.reason,\n durationMs: Date.now() - start,\n };\n }\n\n // A page longer than the chunk budget is read in parts: each part\n // contributes the passages bearing on the assertion, and one judge then\n // answers the original question against the collection. Merging\n // per-part *verdicts* would be unsound — see EVIDENCE_SYSTEM_PROMPT.\n //\n // Content that fits skips this entirely and is judged exactly as before,\n // so the common path costs nothing and its cached verdicts stay valid.\n const chunks = splitBody(selected.text, chunkChars);\n let judged = selected.text;\n let judgedLabel = selected.label;\n\n // The key is built from what was *selected*, never from the evidence.\n // Evidence is model output: keying on it would change every run, so a\n // split page could never hit its cached verdict — and the committed docs\n // fixtures for long pages would be dead weight. The chunk budget rides\n // along because it decides how the page was read.\n const key = cacheKey(\n judgeProvider.provider(),\n judgeProvider.modelName(),\n runsPerEval,\n temperature,\n judgeCacheBody(chunkChars, selected.text),\n ev,\n );\n const cached = cache.get(key) !== undefined;\n\n // Gathering evidence costs one call per part, so it happens only on a\n // miss. A cached ensemble must make no inference call at all (ADR 01019).\n if (chunks.length > 1 && !cached) {\n const gathered: PartEvidence[] = [];\n for (const [i, chunk] of chunks.entries()) {\n if (maxTurns != null && turnsSpent >= maxTurns) {\n return {\n evalName: ev.name,\n type: ev.type,\n grader: ev.grader,\n file: plan.page.file,\n outcome: \"skipped\",\n skipReason: `${turnBudgetSkipReason(maxTurns)} (after ${String(i)} of ${String(chunks.length)} parts)`,\n durationMs: Date.now() - start,\n };\n }\n turnsSpent += 1;\n try {\n const res = await judgeProvider.completeJSON({\n system: EVIDENCE_SYSTEM_PROMPT,\n user: buildEvidenceUser(ev, chunk, {\n index: i,\n total: chunks.length,\n }),\n schema: EVIDENCE_SCHEMA,\n temperature,\n });\n const json = res.json as Partial<PartEvidence>;\n gathered.push({\n supports: json.supports ?? [],\n contradicts: json.contradicts ?? [],\n });\n } catch (e) {\n // A part that could not be read leaves the collection incomplete,\n // and a verdict over incomplete evidence is exactly the silent\n // wrong answer this stage exists to avoid (ADR 01022).\n return {\n evalName: ev.name,\n type: ev.type,\n grader: ev.grader,\n file: plan.page.file,\n outcome: \"error\",\n skipReason: `gathering evidence from part ${String(i + 1)} of ${String(chunks.length)} failed: ${errorMessage(e)}`,\n durationMs: Date.now() - start,\n };\n }\n }\n judged = renderEvidence(gathered, chunks.length);\n judgedLabel = `${selected.label}, ${String(chunks.length)} parts`;\n }\n\n // A cached ensemble makes no inference call, so it never touches the\n // budget — the docs corpus replays committed fixtures under any cap.\n // For an uncached one the turns are claimed *before* dispatching, which\n // is the whole point of counting turns rather than dollars: the claim is\n // synchronous, so two workers cannot both clear an almost-exhausted\n // budget and then both spend. See ADR 01019.\n if (maxTurns != null && !cached) {\n if (turnsSpent + runsPerEval > maxTurns) {\n return {\n evalName: ev.name,\n type: ev.type,\n grader: ev.grader,\n file: plan.page.file,\n outcome: \"skipped\",\n skipReason: turnBudgetSkipReason(maxTurns),\n durationMs: 0,\n };\n }\n // One turn per ensemble run. A run can make a second provider call\n // when the first response fails schema validation (the inference\n // layer retries once), so this is a floor on calls, not an exact\n // count — the cap is exact in *runs*, which is the unit the ensemble\n // is configured in.\n turnsSpent += runsPerEval;\n }\n\n const runs = await runEnsemble({\n provider: judgeProvider,\n system: JUDGE_SYSTEM_PROMPT,\n user: buildUserContent(ev, judged, judgedLabel),\n runs: runsPerEval,\n temperature,\n schema: verdictSchema,\n cache,\n cacheKey: key,\n label: \"manni-docevals\",\n });\n\n const consensusBase = computeConsensus(runs);\n const zone = zoneFor(consensusBase, config.judge.zones);\n const consensus = { ...consensusBase, zone };\n\n let outcome: EvalResult[\"outcome\"] =\n zone === \"auto-pass\" ? \"pass\" : zone === \"auto-fail\" ? \"fail\" : \"needs-review\";\n let via: EvalResult[\"via\"];\n if (outcome === \"needs-review\") {\n const review = findReview(reviews, plan.page.file, ev.name, plan.page.body);\n if (review) {\n outcome = review.verdict;\n via = \"human-review\";\n }\n }\n\n return {\n evalName: ev.name,\n type: ev.type,\n grader: ev.grader,\n file: plan.page.file,\n outcome,\n consensus,\n via,\n ...(preference\n ? { selfPreference: { axis: preference.axis, model: preference.model } }\n : {}),\n durationMs: Date.now() - start,\n };\n };\n\n // Simple bounded-concurrency pool across targets; runs within one eval\n // stay sequential (independent requests, no shared context).\n const workers = Array.from(\n { length: Math.min(concurrency, targets.length) },\n async () => {\n while (index < targets.length) {\n const i = index++;\n const target = targets[i];\n if (target === undefined) break;\n results[i] = await judgeTarget(target);\n }\n },\n );\n await Promise.all(workers);\n return results;\n };\n}\n","{\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n \"$id\": \"manni:docevals:verdict\",\n \"title\": \"manni docevals judge verdict\",\n \"type\": \"object\",\n \"required\": [\"claim\", \"observed\", \"match\", \"confidence\", \"reasoning\"],\n \"properties\": {\n \"claim\": {\n \"type\": \"string\",\n \"description\": \"The specific documented assertion under evaluation.\"\n },\n \"observed\": {\n \"type\": \"string\",\n \"description\": \"What was actually observed in the page, quoting evidence where possible.\"\n },\n \"match\": {\n \"enum\": [\"pass\", \"fail\", \"partial\"],\n \"description\": \"pass only if the assertion is fully satisfied; partial for partial compliance.\"\n },\n \"confidence\": {\n \"type\": \"number\",\n \"minimum\": 0,\n \"maximum\": 1,\n \"description\": \"Self-reported confidence in this verdict.\"\n },\n \"reasoning\": {\n \"type\": \"string\",\n \"description\": \"Why this conclusion was reached.\"\n }\n },\n \"additionalProperties\": false\n}\n","/**\n * Persisted human reviews (Level 3 grading). `.manni/docevals/reviews.yaml` records\n * human verdicts for evals that landed in the human-review zone. A review\n * applies only while the page body it reviewed is unchanged (contentHash);\n * stale reviews silently return the eval to needs-review.\n */\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { parse as parseYaml, stringify as stringifyYaml } from \"yaml\";\nimport { sha256 } from \"../judge/cache.js\";\n\nexport interface ReviewEntry {\n file: string;\n evalName: string;\n /** sha256 of the page body at review time. */\n contentHash: string;\n verdict: \"pass\" | \"fail\";\n reviewer?: string;\n date?: string;\n note?: string;\n}\n\nexport const REVIEWS_PATH = join(\".manni/docevals\", \"reviews.yaml\");\n\nexport function loadReviews(root: string): ReviewEntry[] {\n const path = join(root, REVIEWS_PATH);\n if (!existsSync(path)) return [];\n const raw = parseYaml(readFileSync(path, \"utf8\")) as unknown;\n if (!Array.isArray(raw)) return [];\n return raw as ReviewEntry[];\n}\n\nexport function saveReviews(root: string, reviews: ReviewEntry[]): void {\n const path = join(root, REVIEWS_PATH);\n mkdirSync(dirname(path), { recursive: true });\n writeFileSync(path, stringifyYaml(reviews));\n}\n\n/** Record (or replace) a review for a (file, eval) pair. */\nexport function recordReview(root: string, entry: ReviewEntry): void {\n const reviews = loadReviews(root).filter(\n (r) => !(r.file === entry.file && r.evalName === entry.evalName),\n );\n reviews.push(entry);\n saveReviews(root, reviews);\n}\n\n/** Find the applicable (non-stale) review for a page body, if any. */\nexport function findReview(\n reviews: ReviewEntry[],\n file: string,\n evalName: string,\n body: string,\n): ReviewEntry | undefined {\n const entry = reviews.find(\n (r) => r.file === file && r.evalName === evalName,\n );\n if (!entry) return undefined;\n return entry.contentHash === sha256(body) ? entry : undefined;\n}\n\nexport { sha256 as contentHash };\n","/**\n * Choosing the provider and model, and building the shared inference\n * library's `ProviderSpec` for it.\n *\n * The providers themselves live in `@hawkeyexl/inference` (ADR 01002). The\n * names a provider may have, the two refusals, the detection call, the\n * level-bound precedence and the mapping of the family's `providers:`\n * connection settings are `src/shared/providers.ts`, the same code\n * `manni meta fill` runs. What stays here is what only manni docevals can\n * decide: which levels it reads (a flag, an eval's own `provider:`/`model:`,\n * `docevals.provider`/`model`, then the family's `providers:`), and the\n * judge-shaped options a verdict call wants.\n */\nimport {\n makeProvider as makeInferenceProvider,\n type InferenceProvider,\n type ProviderName as ConcreteProvider,\n type ProviderSelector,\n type ProviderSpec,\n} from \"@hawkeyexl/inference\";\nimport { DocevalsError } from \"../types.js\";\nimport type { DocevalsConfig } from \"../core/config.js\";\nimport {\n assertKnownProvider,\n assertLocalFlag,\n assertModelHasProvider,\n localNotice,\n providerSpecFor as sharedProviderSpecFor,\n resolveIdentity,\n selectProvider as selectFromLevels,\n type ProviderChoice,\n type ProviderFlags,\n type ProviderSelection,\n} from \"../../shared/providers.js\";\nimport { errorMessage } from \"../../shared/errors.js\";\nimport { noticeOnce } from \"../../shared/warn.js\";\n\nexport type { ProviderChoice, ProviderFlags, ProviderSelection };\n\n/** The key a docevals user writes, named by the refusal a bare model gets. */\nconst CONFIG_KEY = \"docevals.provider\";\n\nconst toDocevalsError = (message: string): Error => new DocevalsError(message);\n\n/**\n * The provider and model in force: a flag, then the eval's own choice, then\n * `docevals.provider`/`model`, then the family's `providers.provider`/`model`,\n * then `auto`. A model is carried only to the provider its own level names,\n * so an eval that names a different provider takes that provider's default\n * instead of a model it cannot run (`selectProvider` in the shared module).\n *\n * `--local` runs llama-cpp over all of them. A `--provider` it contradicts is\n * refused here, so no path selects past it. `ev.origin` names the eval in the\n * notice for a provider `--local` replaced; the caller knows its page.\n */\nexport function selectProvider(\n config: DocevalsConfig,\n flags: ProviderFlags = {},\n ev: ProviderChoice = {},\n): ProviderSelection {\n assertLocalFlag(flags, toDocevalsError);\n return selectFromLevels(flags, [\n {\n ...(ev.provider !== undefined ? { provider: ev.provider } : {}),\n ...(ev.model !== undefined ? { model: ev.model } : {}),\n ...(ev.origin !== undefined ? { origin: ev.origin } : {}),\n },\n {\n ...(config.provider !== null ? { provider: config.provider } : {}),\n ...(config.model !== null ? { model: config.model } : {}),\n origin: CONFIG_KEY,\n },\n {\n ...(config.providers.provider !== undefined ? { provider: config.providers.provider } : {}),\n ...(config.providers.model !== undefined ? { model: config.providers.model } : {}),\n origin: \"providers.provider\",\n },\n ]);\n}\n\n/**\n * Say what `--local` set aside, once per source. Called where a selection is\n * about to be used, never where it is only checked, so a run that sends\n * nothing to a model says nothing.\n */\nexport function announceSelection(selection: ProviderSelection): void {\n const message = localNotice(selection);\n if (message !== undefined) noticeOnce(message);\n}\n\n/**\n * Refuse a selection that cannot be right, with `manni meta fill`'s messages:\n * an unknown name, or a model under `auto`. Both are `DocevalsError`s.\n */\nexport function assertProviderSelection(selection: ProviderSelection): void {\n assertKnownProvider(selection.provider, toDocevalsError);\n assertModelHasProvider(selection.provider, selection.model, CONFIG_KEY, toDocevalsError);\n}\n\n/**\n * The spec for a selection, with the family's connection settings for the\n * provider it names, and under `auto` the settings detection reads.\n */\nexport function providerSpecFor(\n config: DocevalsConfig,\n selection: { provider: ProviderSelector; model: string | null },\n): ProviderSpec {\n const spec = sharedProviderSpecFor(config.providers, selection);\n switch (selection.provider) {\n case \"anthropic\":\n // A verdict-shaped tool name steers the model better than a generic\n // one, and it is free to keep.\n return { ...spec, anthropic: { toolName: \"record_verdict\" } };\n case \"openai\":\n return { ...spec, openai: { schemaName: \"verdict\" } };\n default:\n return spec;\n }\n}\n\n/**\n * The concrete provider and model, WITHOUT constructing the provider: cache\n * keys need it, and a fully cached run must not require an API key.\n *\n * Under `auto` this is where detection runs, exactly as `manni meta fill` runs\n * it, seeing the same connection settings. The model is the RESOLVED one (the\n * provider's default when none was named, a llama-cpp tier's concrete\n * weights), so a library default that changes changes every cache key built\n * from it.\n */\nexport async function resolveProviderIdentity(\n config: DocevalsConfig,\n flags: ProviderFlags = {},\n ev: ProviderChoice = {},\n): Promise<{ provider: ConcreteProvider; model: string }> {\n const selection = selectProvider(config, flags, ev);\n const { provider, model } = selection;\n assertKnownProvider(provider, toDocevalsError);\n assertModelHasProvider(provider, model, CONFIG_KEY, toDocevalsError);\n announceSelection(selection);\n return resolveIdentity(providerSpecFor(config, { provider, model: model ?? null }), toDocevalsError);\n}\n\n/** Construct a provider for an identity already resolved. */\nexport function constructProvider(\n config: DocevalsConfig,\n identity: { provider: ConcreteProvider; model: string },\n): InferenceProvider {\n try {\n return makeInferenceProvider(providerSpecFor(config, identity));\n } catch (e) {\n // The library raises its own InferenceError (missing API key). It must\n // surface as a DocevalsError: `run` degrades to deterministic-only evals on\n // a DocevalsError and rethrows anything else, and cli.ts fail() maps only\n // DocevalsError to exit 2. Letting a foreign error type through turns \"no\n // API key configured\" from a warning into an unhandled stack trace.\n throw new DocevalsError(errorMessage(e));\n }\n}\n\n/** Select, check, detect and construct: the provider a verb sends pages to. */\nexport async function makeProvider(\n config: DocevalsConfig,\n flags: ProviderFlags = {},\n ev: ProviderChoice = {},\n): Promise<InferenceProvider> {\n return constructProvider(config, await resolveProviderIdentity(config, flags, ev));\n}\n","/**\n * Script generation: turns a plain-language deterministic assertion (a\n * command-graded eval with no command) into a standalone Node .mjs check\n * script written parallel to the documentation, then persists the command\n * reference back into the frontmatter (or config) — no inline scripts.\n * Generation is single-shot: the output is code, verified by execution and\n * version-control review rather than ensemble consensus.\n */\nimport { mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { basename, dirname, extname, join, relative, resolve } from \"node:path\";\nimport type { DocevalsConfig } from \"../core/config.js\";\nimport type {\n GenerateFn,\n GenerationRefusal,\n JudgeOptions,\n} from \"../core/engine.js\";\nimport { updateConfigEval, updatePageEval } from \"../core/frontmatter-edit.js\";\nimport {\n EVALS_KEY,\n EvalWriter,\n manifestEvalList,\n updateManifestEval,\n type WriteHome,\n} from \"../core/write-location.js\";\nimport { sha256 } from \"../judge/cache.js\";\nimport type { InferenceProvider } from \"@hawkeyexl/inference\";\nimport type { GraderTarget } from \"./types.js\";\nimport { DocevalsError } from \"../types.js\";\n\nexport const SCRIPTGEN_VERSION = 2;\n\nexport const SCRIPTGEN_SYSTEM_PROMPT = [\n \"You write small, self-contained Node.js check scripts that verify a\",\n \"deterministic assertion about a documentation page.\",\n \"\",\n \"Contract for every script:\",\n \"- ES module (.mjs) using only Node.js built-in modules. No dependencies.\",\n \"- The page's absolute path arrives as process.argv[2] (also MANNI_DOCEVALS_FILE).\",\n \"- Exit 0 when the assertion holds, 1 when it fails, 2 on operational error.\",\n \"- On failure, print a short human-readable reason to stderr.\",\n \"- Deterministic: no network access, no spawning processes, no randomness.\",\n \"- The page content may start with a YAML frontmatter block fenced by ---\",\n \" lines; account for it when checking body content.\",\n \"- Prefer simple, reviewable logic (regex/string checks) over cleverness.\",\n \"Respond with JSON: { \\\"code\\\": \\\"<the full script source>\\\" }.\",\n].join(\"\\n\");\n\nconst SCRIPT_SCHEMA = {\n type: \"object\",\n required: [\"code\"],\n properties: {\n code: { type: \"string\", minLength: 1 },\n notes: { type: \"string\" },\n },\n additionalProperties: false,\n} as const;\n\nexport function buildScriptgenUser(\n assertion: string,\n evalName: string,\n file: string,\n body: string,\n): string {\n // No cap. Generation produces one script, so there is nothing to merge and\n // splitting has no meaning here — but truncating was worse than either: a\n // script generated from the first 6000 characters expresses an assertion\n // about a page whose rest the model never read, and nothing downstream could\n // tell that from a script generated with full sight of it. If the body\n // overflows the model's context the call fails, and a failed generation is\n // already an errored result (ADR 01022) rather than a half-informed script.\n return [\n `# Assertion to check`,\n assertion,\n \"\",\n `# Eval name`,\n evalName,\n \"\",\n `# Page path`,\n file,\n \"\",\n \"# Current page content (for grounding — the script must express the\",\n \"# assertion generally, not hardcode this exact content)\",\n \"\",\n body,\n ].join(\"\\n\");\n}\n\nexport interface ScriptLocation {\n /** Absolute path the script file is written to. */\n scriptAbsPath: string;\n /** Command array persisted into the eval (path relative to its cwd). */\n command: string[];\n}\n\n/** Where a generated script lives and how the eval invokes it. */\nexport function scriptLocationFor(\n target: GraderTarget,\n config: DocevalsConfig,\n root: string,\n): ScriptLocation {\n const ev = target.eval;\n const page = target.plan.page;\n if (ev.source === \"page\") {\n const pageDir = dirname(page.absPath);\n const pattern = config.scripts.dir;\n const dir = pattern.includes(\"{docDir}\")\n ? pattern.replaceAll(\"{docDir}\", pageDir)\n : resolve(root, pattern);\n const base = basename(page.absPath, extname(page.absPath));\n const scriptAbsPath = join(dir, `${base}.${ev.name}.mjs`);\n const rel = relative(pageDir, scriptAbsPath).replace(/\\\\/g, \"/\");\n return { scriptAbsPath, command: [\"node\", rel, \"{file}\"] };\n }\n const dir = resolve(config.configDir, config.scripts.configDir);\n const scriptAbsPath = join(dir, `${ev.name}.mjs`);\n const rel = relative(config.configDir, scriptAbsPath).replace(/\\\\/g, \"/\");\n return { scriptAbsPath, command: [\"node\", rel, \"{file}\"] };\n}\n\nfunction header(assertion: string, evalName: string): string {\n return [\n \"// manni docevals generated check\",\n `// Eval: ${evalName}`,\n `// Assertion: ${assertion.replace(/\\s+/g, \" \").trim()}`,\n \"// Exit 0 = pass, 1 = fail, 2 = operational error.\",\n \"\",\n ].join(\"\\n\");\n}\n\nexport interface ScriptgenDeps {\n /**\n * The provider, or how to get one. A function is called only when a target\n * actually needs a script, so a run with nothing to generate never resolves\n * (and, under `auto`, never detects) a provider.\n */\n provider: InferenceProvider | (() => Promise<InferenceProvider>);\n root: string;\n}\n\n/** Build the engine's generation stage around a concrete provider. */\nexport function makeGenerateScripts(deps: ScriptgenDeps): GenerateFn {\n return async (\n targets: GraderTarget[],\n config: DocevalsConfig,\n _options: JudgeOptions,\n ) => {\n const generatedPaths: string[] = [];\n const refusals: GenerationRefusal[] = [];\n // Config-sourced evals generate once even when used by many pages.\n const doneConfigEvals = new Set<string>();\n let provider: InferenceProvider | undefined;\n // Proposal 0047: the command reference goes where the eval lives. Built\n // once per generation pass, and only when a page-sourced eval needs it.\n let writer: EvalWriter | undefined;\n const getWriter = (): EvalWriter => (writer ??= EvalWriter.for(config, deps.root, []));\n\n for (const target of targets) {\n const ev = target.eval;\n if (!ev.assertion) continue; // Nothing to generate from.\n if (ev.source === \"config\" && doneConfigEvals.has(ev.name)) continue;\n\n // Where the reference will be persisted, decided before the model is\n // asked: a page whose manifest has no entry for it can hold no command,\n // and paying for a script that cannot be referenced helps nobody.\n const page = target.plan.page;\n let home: WriteHome | undefined;\n if (ev.source === \"page\") {\n home = await getWriter().homeFor(\n page.file,\n page.frontmatter.data,\n EVALS_KEY,\n );\n if (home.kind === \"url\") {\n throw getWriter().urlRefusal(home, EVALS_KEY);\n }\n if (home.kind === \"no-entry\") {\n refusals.push({ file: page.file, evalName: ev.name, message: home.message });\n continue;\n }\n }\n\n if (provider === undefined) {\n try {\n provider =\n typeof deps.provider === \"function\" ? await deps.provider() : deps.provider;\n } catch (e) {\n // No provider for any target: say why once, and let the engine\n // report each eval it could not generate for.\n if (!(e instanceof DocevalsError)) throw e;\n return { generatedPaths, refusals, unavailable: e.message };\n }\n }\n\n const location = scriptLocationFor(target, config, deps.root);\n let code: string;\n try {\n const response = await provider.completeJSON({\n system: SCRIPTGEN_SYSTEM_PROMPT,\n user: buildScriptgenUser(\n ev.assertion,\n ev.name,\n target.plan.page.file,\n target.plan.page.body,\n ),\n schema: SCRIPT_SCHEMA,\n temperature: 0,\n });\n const json = response.json as { code?: unknown };\n if (typeof json.code !== \"string\" || json.code.length === 0) {\n continue; // Generation failed; the engine reports the eval as errored.\n }\n code = json.code;\n } catch {\n continue;\n }\n\n mkdirSync(dirname(location.scriptAbsPath), { recursive: true });\n writeFileSync(\n location.scriptAbsPath,\n // Exactly one final newline, whatever the model sent: the script is\n // committed and reviewed, and a missing one shows in every diff.\n `${header(ev.assertion, ev.name)}${code.trim()}\\n`,\n );\n generatedPaths.push(\n relative(deps.root, location.scriptAbsPath).replace(/\\\\/g, \"/\"),\n );\n\n const updates = {\n command: location.command,\n \"generated-assertion-hash\": sha256(ev.assertion),\n };\n if (ev.source === \"page\" && home?.kind === \"manifest\") {\n // The evals live in the manifest, so the command reference does too:\n // the one entry is rewritten and no other byte of the file changes.\n const at = getWriter();\n const list = manifestEvalList(\n await at.readManifest(home, EVALS_KEY),\n home.file,\n home.entry,\n );\n const next = updateManifestEval(list, ev.name, updates);\n if (next === undefined) {\n throw new DocevalsError(\n `${home.file}: eval \"${ev.name}\" not found in the entry for ${home.entry}`,\n );\n }\n await at.writeManifest(home, EVALS_KEY, next);\n } else if (ev.source === \"page\") {\n const abs = page.absPath;\n const updated = updatePageEval(\n readFileSync(abs, \"utf8\"),\n page.file,\n ev.name,\n updates,\n );\n writeFileSync(abs, updated);\n } else {\n const updated = updateConfigEval(\n readFileSync(config.configPath, \"utf8\"),\n config.configPath,\n ev.name,\n updates,\n );\n writeFileSync(config.configPath, updated);\n doneConfigEvals.add(ev.name);\n }\n\n // Mutate the in-memory eval so this run executes the fresh script.\n if (ev.source === \"config\") {\n // A config-sourced eval appears once per page; every target shares\n // the same central definition and script.\n for (const t of targets) {\n if (t.eval.name === ev.name && t.eval.source === \"config\") {\n t.eval.command = scriptLocationFor(t, config, deps.root).command;\n t.eval.generatedAssertionHash =\n updates[\"generated-assertion-hash\"];\n }\n }\n } else {\n // Page-sourced evals are per-page: same-named inline evals on other\n // pages have their own assertions and generate independently.\n target.eval.command = location.command;\n target.eval.generatedAssertionHash = updates[\"generated-assertion-hash\"];\n }\n }\n return { generatedPaths, refusals };\n };\n}\n","/**\n * Surgical YAML edits. Only the frontmatter block (or the named config eval)\n * is re-serialized via the `yaml` Document API — the page body is carried\n * over byte-for-byte, and untouched YAML keeps its comments and ordering.\n * YAML frontmatter only; TOML/JSON frontmatter cannot be edited in place.\n */\nimport { parseDocument, Document, YAMLMap, YAMLSeq, isMap, isScalar } from \"yaml\";\nimport { DocevalsError } from \"../types.js\";\nimport { leadingFrontmatterFormat } from \"./discover.js\";\n\n/** Top-level key manni docevals owns inside the shared manni config. */\nconst NAMESPACE = \"docevals\";\n\n/** The byte-order mark a page may open with, carried through edits untouched. */\nconst BOM = \"\\uFEFF\";\n\nexport interface EvalUpdates {\n grader?: string;\n command?: string[];\n /** sha256 of the assertion at generation time; flat, per the vocabulary. */\n \"generated-assertion-hash\"?: string;\n}\n\ninterface Split {\n /** The opening fence line including its newline. */\n open: string;\n /** Raw YAML between the fences. */\n block: string;\n /** Everything from the closing fence to EOF, byte-identical. */\n suffix: string;\n /** Line ending style of the file. */\n eol: \"\\n\" | \"\\r\\n\";\n}\n\nfunction splitYamlFrontmatter(content: string, path: string): Split {\n const bom = content.startsWith(BOM) ? BOM : \"\";\n const body = bom ? content.slice(1) : content;\n const openMatch = /^---(\\r?\\n)/.exec(body);\n if (!openMatch) {\n throw new DocevalsError(\n `${path}: no YAML frontmatter block to edit (only YAML frontmatter is editable)`,\n );\n }\n const eol: \"\\n\" | \"\\r\\n\" = openMatch[1] === \"\\r\\n\" ? \"\\r\\n\" : \"\\n\";\n // Keep line endings. The match above guarantees an opening line.\n const [openLine = \"\", ...rest] = body.split(/(?<=\\n)/);\n let offset = openLine.length;\n for (const line of rest) {\n const stripped = line.replace(/\\r?\\n$/, \"\");\n if (stripped === \"---\" || stripped === \"...\") {\n const blockEnd = offset;\n return {\n open: bom + openLine,\n block: body.slice(openLine.length, blockEnd),\n suffix: body.slice(blockEnd),\n eol,\n };\n }\n offset += line.length;\n }\n throw new DocevalsError(`${path}: unterminated frontmatter block`);\n}\n\nfunction applyUpdates(\n doc: Document,\n node: YAMLMap,\n updates: EvalUpdates,\n): void {\n if (updates.grader !== undefined) node.set(\"grader\", updates.grader);\n if (updates.command !== undefined) {\n const seq = doc.createNode(updates.command) as YAMLSeq;\n seq.flow = true; // [\"node\", \"script.mjs\", \"{file}\"] on one line\n node.set(\"command\", seq);\n }\n const hash = updates[\"generated-assertion-hash\"];\n if (hash !== undefined) node.set(\"generated-assertion-hash\", hash);\n}\n\n/**\n * The eval list. `evals` is the list itself, or the single-assertion string\n * shorthand — which has no map node to edit, so it is not a sequence here.\n */\nfunction evalSeq(doc: Document): YAMLSeq | undefined {\n const node = doc.get(\"evals\", true);\n return node instanceof YAMLSeq ? node : undefined;\n}\n\nfunction findEvalNode(\n doc: Document,\n evalName: string,\n): YAMLMap | undefined {\n const evals = evalSeq(doc);\n if (!evals) return undefined;\n for (const item of evals.items) {\n if (isMap(item)) {\n const name = item.get(\"id\") ?? item.get(\"use\");\n if (name === evalName) return item;\n }\n }\n return undefined;\n}\n\n/**\n * Update an inline eval in a page's YAML frontmatter. Returns the new file\n * content; the body after the closing fence is byte-identical to the input.\n */\nexport function updatePageEval(\n content: string,\n path: string,\n evalName: string,\n updates: EvalUpdates,\n): string {\n const { open, block, suffix, eol } = splitYamlFrontmatter(content, path);\n const doc = parseDocument(block);\n if (doc.errors.length > 0) {\n throw new DocevalsError(\n `${path}: cannot edit frontmatter — ${doc.errors[0]?.message ?? \"parse error\"}`,\n );\n }\n const node = findEvalNode(doc, evalName);\n if (!node) {\n throw new DocevalsError(\n `${path}: eval \"${evalName}\" not found in frontmatter`,\n );\n }\n applyUpdates(doc, node, updates);\n let newBlock = doc.toString();\n if (eol === \"\\r\\n\") newBlock = newBlock.replace(/(?<!\\r)\\n/g, \"\\r\\n\");\n return open + newBlock + suffix;\n}\n\n/**\n * Update a named eval in manni.config.yaml text.\n *\n * The eval library lives under the tool's own namespace — `manni.config.yaml`\n * is shared across the manni family. Navigating to a root `evals:` finds\n * nothing in a real config, so generation for a config-sourced eval failed\n * with \"eval not found in config\" against every file the loader accepts.\n */\nexport function updateConfigEval(\n configText: string,\n configPath: string,\n evalName: string,\n updates: EvalUpdates,\n): string {\n const doc = parseDocument(configText);\n if (doc.errors.length > 0) {\n throw new DocevalsError(\n `${configPath}: cannot edit config — ${doc.errors[0]?.message ?? \"parse error\"}`,\n );\n }\n const node = doc.getIn([NAMESPACE, \"evals\", evalName]);\n if (!isMap(node)) {\n throw new DocevalsError(\n `${configPath}: eval \"${evalName}\" not found in config`,\n );\n }\n applyUpdates(doc, node, updates);\n return doc.toString();\n}\n\nexport interface NewEvalEntry {\n /** Kebab-case id. Required on object entries — position-derived names\n * orphan cached verdicts whenever entries move. */\n id: string;\n assertion: string;\n type?: string;\n grader?: string;\n evidence?: string;\n examples?: { pass?: string | string[]; fail?: string | string[] };\n severity?: string;\n}\n\n/**\n * Ordered plain object for a new inline eval, with undefined fields dropped.\n * Exported because an eval whose location puts it in a manifest is written as\n * this same object, spliced into the page's entry rather than appended here.\n */\nexport function entryObject(entry: NewEvalEntry): Record<string, unknown> {\n const obj: Record<string, unknown> = { id: entry.id, assertion: entry.assertion };\n if (entry.type !== undefined) obj.type = entry.type;\n if (entry.grader !== undefined) obj.grader = entry.grader;\n if (entry.evidence !== undefined) obj.evidence = entry.evidence;\n if (entry.examples !== undefined) obj.examples = entry.examples;\n if (entry.severity !== undefined) obj.severity = entry.severity;\n return obj;\n}\n\n/** The page-level key `fill` records machine-proposed evals in (proposal 0046). */\nconst META_PROVENANCE_KEY = \"meta-provenance\";\n\nfunction assertNoCollision(seq: YAMLSeq, name: string, path: string): void {\n for (const item of seq.items) {\n const existing = isMap(item)\n ? item.get(\"id\") ?? item.get(\"use\")\n : isScalar(item)\n ? item.value\n : undefined;\n if (existing === name) {\n throw new DocevalsError(\n `${path}: eval \"${name}\" already exists in frontmatter`,\n );\n }\n }\n}\n\n/**\n * Append inline evals to a page's YAML frontmatter, creating the `evals` key\n * — or the frontmatter block itself — when missing. The body stays\n * byte-identical; existing evals are never modified or reordered.\n *\n * `metaProvenance`, when given, is the page's whole `meta-provenance` list with\n * the new evals already merged in, written in the same edit. The merge is the\n * caller's, as `manni meta fill`'s is, so both tools record attribution one\n * way.\n */\nexport function appendPageEvals(\n content: string,\n path: string,\n entries: NewEvalEntry[],\n metaProvenance?: readonly unknown[],\n): string {\n const format = leadingFrontmatterFormat(content);\n if (format === \"toml\" || format === \"json\") {\n // Synthesizing a YAML block here would leave the page with two\n // frontmatter blocks. Only YAML frontmatter can be edited in place.\n throw new DocevalsError(\n `${path}: only YAML frontmatter can be edited (found ${format} frontmatter)`,\n );\n }\n\n const bom = content.startsWith(BOM) ? BOM : \"\";\n const stripped = bom ? content.slice(1) : content;\n const eol: \"\\n\" | \"\\r\\n\" = stripped.includes(\"\\r\\n\") ? \"\\r\\n\" : \"\\n\";\n\n if (format === undefined) {\n // No frontmatter: synthesize a block above the untouched body.\n const doc = new Document(\n entries.length === 0 ? {} : { evals: entries.map(entryObject) },\n );\n if (metaProvenance) doc.set(META_PROVENANCE_KEY, doc.createNode(metaProvenance));\n let block = doc.toString();\n if (eol === \"\\r\\n\") block = block.replace(/(?<!\\r)\\n/g, \"\\r\\n\");\n return `${bom}---${eol}${block}---${eol}${stripped}`;\n }\n\n const { open, block, suffix, eol: blockEol } = splitYamlFrontmatter(content, path);\n const doc = parseDocument(block);\n if (doc.errors.length > 0) {\n throw new DocevalsError(\n `${path}: cannot edit frontmatter — ${doc.errors[0]?.message ?? \"parse error\"}`,\n );\n }\n\n // Nothing to append: the evals of this page went to the manifest that owns\n // them, and only `meta-provenance` is left for the page. Creating an empty\n // `evals:` here would put the key in both places, which is exactly the\n // collision routing the write exists to avoid.\n if (entries.length === 0) {\n if (metaProvenance) doc.set(META_PROVENANCE_KEY, doc.createNode(metaProvenance));\n let onlyEntry = doc.toString();\n if (blockEol === \"\\r\\n\") onlyEntry = onlyEntry.replace(/(?<!\\r)\\n/g, \"\\r\\n\");\n return open + onlyEntry + suffix;\n }\n\n let seq = evalSeq(doc);\n if (!seq) {\n const node = doc.get(\"evals\", true);\n if (node !== undefined) {\n // A single-assertion string, or something else entirely. Appending would\n // have to rewrite the existing declaration, which is the caller's call to\n // make, not a silent side effect of adding one eval.\n throw new DocevalsError(\n `${path}: the evals key in frontmatter is not a list — expand the ` +\n `string shorthand into a list before appending`,\n );\n }\n seq = doc.createNode([]);\n doc.set(\"evals\", seq);\n }\n for (const entry of entries) {\n assertNoCollision(seq, entry.id, path);\n seq.add(doc.createNode(entryObject(entry)));\n }\n if (metaProvenance) doc.set(META_PROVENANCE_KEY, doc.createNode(metaProvenance));\n let newBlock = doc.toString();\n if (blockEol === \"\\r\\n\") newBlock = newBlock.replace(/(?<!\\r)\\n/g, \"\\r\\n\");\n return open + newBlock + suffix;\n}\n\n/** True when the eval exists as an editable (map) entry in the frontmatter. */\nexport function hasEditableEval(content: string, evalName: string): boolean {\n try {\n const { block } = splitYamlFrontmatter(content, \"\");\n const doc = parseDocument(block);\n return findEvalNode(doc, evalName) !== undefined;\n } catch {\n return false;\n }\n}\n\n/** Used by promote: check a string-shorthand eval entry (not editable in place). */\nexport function isScalarEvalEntry(content: string, evalName: string): boolean {\n try {\n const { block } = splitYamlFrontmatter(content, \"\");\n const doc = parseDocument(block);\n const evals = evalSeq(doc);\n if (!evals) return false;\n return evals.items.some((i) => isScalar(i) && i.value === evalName);\n } catch {\n return false;\n }\n}\n","/**\n * Where docevals writes each key it owns (proposal 0047, §3 and §4).\n *\n * Chunk 1 made reading follow a key's location: a manifest that owns `evals`\n * supplies them, and everything downstream sees them as the page's own. A\n * tool that reads that way and writes to the page anyway puts the value in\n * two places at once, which `meta validate` then reports as an\n * `external:owned` collision on every page it touched.\n *\n * So every write goes through the rule `manni meta fill` already follows:\n *\n * - a **local manifest** of one of the page's collections owns the key: the\n * value is spliced into the page's entry there, and nothing else in the\n * file changes;\n * - the manifest **joins on a field the page lacks**: there is no entry to\n * hold the value, and the write is refused for that file, in meta's own\n * sentence;\n * - a **URL manifest** owns it: nothing can be written to a fetched file,\n * and for an eval key that is the refusal chunk 1 already makes at load;\n * - **no manifest owns it**: the page keeps it, with the offer (P1) and the\n * warnings (W1, W2) meta's writers use when the schema prefers external\n * metadata.\n *\n * The rule is meta's, and so is every helper that decides it: `keyHome`,\n * `offerExternalHomes`, `externalWriteWarnings` and `spliceManifestValue`,\n * all reached through `src/meta/internal.ts`. What is docevals' own is the\n * preference, which comes from the evals vocabulary rather than a validator:\n * the vocabulary this tool implements marks its three keys, so the answer is\n * in the schema docevals already bundles.\n */\nimport { resolve } from \"node:path\";\nimport {\n LOCATION_KEYWORD,\n Validator,\n writeFileAtomic,\n} from \"../../meta/index.js\";\nimport {\n externalWriteWarnings,\n keyHome,\n offerExternalHomes,\n readManifestValue,\n spliceManifestValue,\n type ExternalWrite,\n type ProposedHome,\n type RelocateResult,\n type RelocationContext,\n} from \"../../meta/internal.js\";\nimport { readManifestOrEmpty } from \"../../shared/manifest-cas.js\";\nimport type { Confirm } from \"../../shared/prompt.js\";\nimport { errorMessage } from \"../../shared/errors.js\";\nimport { DocevalsError } from \"../types.js\";\nimport { frontmatterSchema } from \"../schema.js\";\nimport type { DocevalsConfig } from \"./config.js\";\nimport { urlManifestRefusal } from \"./external.js\";\n\n/** The page key holding the eval list, the one docevals appends to and edits. */\nexport const EVALS_KEY = \"evals\";\n\n/** The key `fill` records machine-proposed evals in (proposal 0046). */\nexport const META_PROVENANCE_KEY = \"meta-provenance\";\n\n/**\n * Whether `manni:evals:1.0.0` marks `key` as belonging in external metadata.\n *\n * Read from the bundled vocabulary rather than from a resolved schema set.\n * Every docevals page is validated against it (`core/resolve.ts`), so it is\n * the schema that governs these keys, and a preference read from it cannot\n * disagree with the one `meta validate` reads. A key it does not mark stays\n * on the page with no warning.\n */\nexport function prefersExternal(key: string): boolean {\n const properties = frontmatterSchema.properties;\n if (typeof properties !== \"object\" || properties === null) return false;\n const property = (properties as Record<string, unknown>)[key];\n if (typeof property !== \"object\" || property === null) return false;\n return (property as Record<string, unknown>)[LOCATION_KEYWORD] === \"external\";\n}\n\n/** Where one key of one page goes. */\nexport type WriteHome =\n /** The page's own frontmatter. `proposed` is the home relocation would give it. */\n | { kind: \"page\"; prefersExternal: boolean; proposed: ProposedHome }\n /** The page's entry in a local manifest. */\n | {\n kind: \"manifest\";\n /** As the run reports it. */\n file: string;\n absPath: string;\n /** `path`, or the page field the manifest joins on. */\n join: string;\n entry: string;\n /**\n * The manifest is the page's own, resolved from a `{page}` pattern\n * (proposal 0058). It may not exist yet: the first write creates it,\n * and a read of it before then holds nothing.\n */\n perPage: boolean;\n }\n /** A manifest joins on a field this page does not carry. */\n | { kind: \"no-entry\"; message: string }\n /** A URL manifest owns the key; nothing fetched can be written. */\n | { kind: \"url\"; collection: string; file: string };\n\n/** meta's sentence for a page a joined manifest has no entry for. */\nexport function noEntryMessage(\n label: string,\n join: string,\n file: string,\n key: string,\n): string {\n return `${label} carries no ${join}, which ${file} joins on, so its ${key} has no entry there.`;\n}\n\n/** What `offer` reports back while it asks. */\nexport interface OfferHooks {\n confirm: Confirm;\n onNotice?: (message: string) => void;\n onRelocated?: (result: RelocateResult) => void;\n}\n\n/**\n * The run's writer: where each key goes, and the manifest splices that put it\n * there. One per run, because the relocation context it reads is the config\n * as the run found it, and an accepted offer changes that config.\n */\nexport class EvalWriter {\n private readonly landed: ExternalWrite[] = [];\n\n private constructor(\n private readonly ctx: RelocationContext,\n private readonly configSource: string,\n ) {}\n\n /**\n * Build the writer for a run. `targets` are the positional paths as typed,\n * which is where a page in no collection gets its proposed home from; a run\n * that took its paths from the collections passes none.\n *\n * The context is built from the config docevals already loaded rather than\n * by loading it again through meta. A `manni.config.yaml` carrying only a\n * `docevals:` key is a single-tool file to the metadata tool, which refuses\n * it; docevals reads it every run, and where its own evals go cannot depend\n * on whether a sibling can read the same file. The collections are the\n * declared ones, since a page named by path is still a member of whatever\n * contains it. `config: null` leaves the page's schema set to the page,\n * which is enough: the keys this writer homes are named outright in the\n * relocation it plans.\n */\n static for(\n config: DocevalsConfig,\n cwd: string,\n targets: readonly string[],\n ): EvalWriter {\n const noConfig = config.configSource === null;\n const collections = config.collections;\n return new EvalWriter(\n {\n cwd,\n // Page labels are relative to the run's discovery root, so a manifest\n // path this writer reports is spelled against the same directory\n // `core/external.ts` reports a merged value's source against.\n base: cwd,\n noConfig,\n config: null,\n ...(noConfig ? {} : { configDir: config.configDir, configPath: config.configPath }),\n collections,\n declaredCollections: collections,\n targets,\n validator: new Validator(),\n },\n config.configSource ?? cwd,\n );\n }\n\n /** Where `key` of the page labelled `label` goes. `data` is its metadata. */\n async homeFor(\n label: string,\n data: Readonly<Record<string, unknown>>,\n key: string,\n ): Promise<WriteHome> {\n const home = await keyHome(this.ctx, label, data, key);\n if (home.kind === \"url\") {\n return { kind: \"url\", collection: home.collection, file: home.file };\n }\n if (home.kind === \"manifest\") {\n if (home.entry === undefined) {\n return {\n kind: \"no-entry\",\n message: noEntryMessage(label, home.join, home.file, key),\n };\n }\n return {\n kind: \"manifest\",\n file: home.file,\n absPath: home.absPath,\n join: home.join,\n entry: home.entry,\n perPage: home.perPage,\n };\n }\n return { kind: \"page\", prefersExternal: prefersExternal(key), proposed: home.home };\n }\n\n /**\n * The refusal for an eval key a URL manifest owns, in chunk 1's wording. A\n * run reaches it only where the load-time refusal could not: a manifest\n * declared for a collection whose pages this run never merged.\n */\n urlRefusal(home: { collection: string }, key: string): DocevalsError {\n return new DocevalsError(urlManifestRefusal(this.configSource, home.collection, key));\n }\n\n /** Record that `key` stayed on the page, for the W1 and W2 lines. */\n stayedOnPage(label: string, key: string, proposed: ProposedHome): void {\n this.landed.push({ label, key, home: proposed });\n }\n\n /** The W1 and W2 lines for everything that stayed on a page. Without the prefix. */\n warnings(dryRun: boolean): string[] {\n return this.landed.length === 0 ? [] : externalWriteWarnings(this.landed, dryRun);\n }\n\n /**\n * Ask P1 once per collection the flagged writes would be homed in. Returns\n * true when a relocation was applied, which leaves the caller's config,\n * pages and this writer stale: rebuild all three before writing.\n */\n async offer(writes: readonly ExternalWrite[], hooks: OfferHooks): Promise<boolean> {\n if (writes.length === 0) return false;\n const applied = await offerExternalHomes(this.ctx, writes, hooks);\n return applied.size > 0;\n }\n\n /** The value the manifest holds for this page's entry, or `undefined`. */\n async readManifest(\n home: { absPath: string; entry: string; join: string; perPage: boolean },\n key: string,\n ): Promise<unknown> {\n return readManifestValue(await this.text(home.absPath, home.perPage), {\n entry: home.entry,\n key,\n join: home.join,\n });\n }\n\n /** Write `value` into this page's entry, changing no other byte of the file. */\n async writeManifest(\n home: { absPath: string; entry: string; join: string; file: string; perPage: boolean },\n key: string,\n value: unknown,\n ): Promise<void> {\n const text = await this.text(home.absPath, home.perPage);\n let spliced: string;\n try {\n spliced = spliceManifestValue(text, {\n entry: home.entry,\n key,\n value,\n join: home.join,\n file: home.file,\n }).text;\n } catch (e) {\n // meta's refusal, in this tool's error class, exactly as cite reports it.\n throw new DocevalsError(errorMessage(e));\n }\n // A per-page manifest may be the first file in its directory.\n if (spliced !== text) {\n await writeFileAtomic(home.absPath, spliced, { createParents: true });\n }\n }\n\n /**\n * The manifest's bytes. A per-page manifest that is not on disk yet is a\n * page with nothing recorded, held as empty text and created by the write,\n * exactly as `manni meta fill` holds one. A missing concrete manifest is\n * refused, as it always was.\n */\n private async text(absPath: string, perPage: boolean): Promise<string> {\n try {\n return await readManifestOrEmpty(absPath, perPage);\n } catch (e) {\n throw new DocevalsError(\n `${resolve(absPath)} could not be read: ${errorMessage(e)}`,\n );\n }\n }\n}\n\n/**\n * The eval list a manifest holds, as a list. An entry whose `evals` is a\n * string shorthand, or anything else, is refused rather than rewritten: the\n * page's own shorthand is refused the same way, and expanding one is the\n * author's call rather than a silent side effect of adding an eval.\n */\nexport function manifestEvalList(value: unknown, file: string, entry: string): unknown[] {\n if (value === undefined || value === null) return [];\n if (Array.isArray(value)) return [...(value as readonly unknown[])];\n throw new DocevalsError(\n `${file}: the evals key of ${entry} is not a list — expand the string ` +\n `shorthand into a list before appending`,\n );\n}\n\n/** The updates `generate` and `promote` persist onto one eval entry. */\nexport interface ManifestEvalUpdates {\n grader?: string;\n command?: string[];\n \"generated-assertion-hash\"?: string;\n}\n\n/**\n * Apply `updates` to the entry named `name` in a manifest's eval list, and\n * return the new list. `undefined` when the list holds no such entry, which\n * is a caller's refusal rather than a silent no-op.\n */\nexport function updateManifestEval(\n list: readonly unknown[],\n name: string,\n updates: ManifestEvalUpdates,\n): unknown[] | undefined {\n const index = list.findIndex((item) => named(item) === name);\n const held = index === -1 ? undefined : list[index];\n if (held === undefined) return undefined;\n // Only the fields actually being set. An `undefined` in the value would be\n // dropped on the way to YAML and then fail the splice's read-back, which\n // compares what it wrote against what the file now holds.\n const set: Record<string, unknown> = { ...(held as Record<string, unknown>) };\n if (updates.grader !== undefined) set.grader = updates.grader;\n if (updates.command !== undefined) set.command = updates.command;\n const hash = updates[\"generated-assertion-hash\"];\n if (hash !== undefined) set[\"generated-assertion-hash\"] = hash;\n const next = [...list];\n next[index] = set;\n return next;\n}\n\n/** The id a manifest's eval entry answers to, or `undefined` for a shorthand. */\nfunction named(item: unknown): string | undefined {\n if (typeof item !== \"object\" || item === null || Array.isArray(item)) return undefined;\n const entry = item as Record<string, unknown>;\n const id = entry.id ?? entry.use;\n return typeof id === \"string\" ? id : undefined;\n}\n","/**\n * `manni docevals run` — execute the full pipeline. Deterministic graders run\n * first (cheap-first ordering); the AI judge stage runs when a provider is\n * available and not disabled.\n */\nimport { runEvals, type EngineReport, type JudgeFn, type RunOptions } from \"../core/engine.js\";\nimport { loadRunConfig, type DocevalsConfig } from \"../core/config.js\";\nimport { runConfigOptions, type DocumentInputOptions } from \"../core/discover.js\";\nimport { render, type ReportFormat } from \"../reporters/index.js\";\nimport { makeJudge } from \"../judge/judge.js\";\nimport {\n assertProviderSelection,\n makeProvider,\n selectProvider,\n} from \"../judge/provider.js\";\nimport type { InferenceProvider } from \"@hawkeyexl/inference\";\nimport { makeGenerateScripts } from \"../graders/scriptgen.js\";\nimport type { GenerateFn } from \"../core/engine.js\";\nimport { DocevalsError } from \"../types.js\";\nimport {\n isExecutionGrant,\n unknownGrantsMessage,\n type ExecutionGrant,\n} from \"../../shared/execution.js\";\nimport { warn } from \"../../shared/warn.js\";\n\nexport interface RunCommandOptions extends DocumentInputOptions {\n format?: ReportFormat;\n deterministicOnly?: boolean;\n aiOnly?: boolean;\n /**\n * Run only these execution grants, of those the config holds. Absent keeps\n * every grant `execution.allow` holds, which is every grant by default.\n */\n allowExecution?: string[];\n /** `false` clears every grant for this run. */\n execution?: boolean;\n generate?: boolean;\n cache?: boolean;\n failOnReview?: boolean;\n provider?: string;\n model?: string;\n /** Run inference on this machine, with llama-cpp, over any configured or eval-level provider. */\n local?: boolean;\n runs?: number;\n chunkChars?: number;\n maxTurns?: number;\n evalNames?: string[];\n suite?: string;\n /** Evaluate only pages that differ between this git ref and HEAD (ADR 01040). */\n since?: string;\n /**\n * Evaluate only pages whose file or eval manifest changed within this\n * duration back from now, such as `7d`. With `since`, a page must satisfy both.\n */\n newerThan?: string;\n baseline?: string | boolean;\n writeBaseline?: string | boolean;\n toolVersion?: string;\n cwd?: string;\n}\n\n/**\n * Grants, checked rather than asserted.\n *\n * The CLI validates in `collectGrant`, but this is also the entry point for\n * programmatic callers. An unknown grant that silently matched nothing would\n * narrow the run to no grant at all: every command eval skipped, exit 0, which\n * reads as a clean corpus rather than a misspelled grant.\n */\nfunction asGrants(values: string[] | undefined): ExecutionGrant[] | undefined {\n if (values === undefined) return undefined;\n const unknown = values.filter((v) => !isExecutionGrant(v));\n if (unknown.length > 0) {\n throw new DocevalsError(unknownGrantsMessage(unknown));\n }\n return values as ExecutionGrant[];\n}\n\nexport async function runRun(\n paths: string[],\n options: RunCommandOptions = {},\n engineOverrides: Partial<RunOptions> = {},\n): Promise<EngineReport> {\n const cwd = options.cwd ?? process.cwd();\n const judgeOptions = {\n provider: options.provider,\n model: options.model,\n local: options.local,\n runs: options.runs,\n chunkChars: options.chunkChars,\n noCache: options.cache === false,\n maxTurns: options.maxTurns ?? null,\n };\n\n // Loaded once and passed through to the engine — a run must not validate\n // the config twice or observe two different versions of it.\n const config: DocevalsConfig = loadRunConfig(runConfigOptions(paths, options), cwd);\n\n // A selection that cannot be right is a usage error, exit 2, whatever else\n // the run was asked to do: an unknown name or a model with no provider to\n // own it is a typo to fix, not a missing provider to degrade around.\n assertProviderSelection(selectProvider(config, judgeOptions));\n\n // Build the judge and generation stages unless deterministic-only or an\n // override supplies them. Both share one provider, resolved at most once.\n let judge: JudgeFn | undefined;\n let generateScripts: GenerateFn | undefined;\n let resolving: Promise<InferenceProvider> | undefined;\n const provider = (): Promise<InferenceProvider> =>\n (resolving ??= makeProvider(config, judgeOptions));\n // Per key, not per pair: an override supplying `judge` but not\n // `generateScripts` used to resolve a provider and build a judge that the\n // spread below then threw away.\n const wantsJudge = !(\"judge\" in engineOverrides);\n const wantsGeneration = !(\"generateScripts\" in engineOverrides);\n if (wantsJudge || wantsGeneration) {\n if (!options.deterministicOnly) {\n try {\n const resolved = await provider();\n if (wantsJudge) judge = makeJudge({ provider: resolved, root: cwd });\n if (wantsGeneration && options.generate !== false) {\n generateScripts = makeGenerateScripts({ provider: resolved, root: cwd });\n }\n } catch (e) {\n if (options.aiOnly || !(e instanceof DocevalsError)) throw e;\n // The warning is about the *judge*, and only the judge (ADR 01043).\n //\n // It used to read `|| options.generate === true`, meaning to fire when\n // generation had been explicitly requested. Commander cannot express\n // that: there is no `--generate` flag, so it defaults a `--no-generate`\n // key to `true` and the clause held on every invocation that was not\n // `--no-generate`. The only silent combination was the accidental\n // `--deterministic-only --no-generate`, and the standard no-key CI run\n // warned about the provider it had just been told to skip.\n warn(`provider unavailable — ${e.message}. Running deterministic evals only.`);\n }\n } else if (wantsGeneration && options.generate !== false) {\n // No judge, so the provider is wanted only if the corpus holds a command\n // eval with no command, which is not knowable here. It is resolved when\n // generation first needs it, so a deterministic run never detects a\n // provider — never probes the machine, never spawns the Claude CLI — to\n // generate nothing. Generation's own need for a provider it cannot have\n // is reported by the engine, where it is, as an `error` result naming\n // the eval and exiting 1.\n generateScripts = makeGenerateScripts({ provider, root: cwd });\n }\n }\n\n return runEvals({\n judge,\n generateScripts,\n config,\n configPath: options.config,\n noConfig: options.noConfig,\n paths,\n collection: options.collection,\n exclude: options.exclude,\n cwd: options.cwd,\n deterministicOnly: options.deterministicOnly,\n aiOnly: options.aiOnly,\n allowExecution: asGrants(options.allowExecution),\n execution: options.execution,\n generate: options.generate,\n failOnReview: options.failOnReview,\n evalNames: options.evalNames,\n suite: options.suite,\n since: options.since,\n newerThan: options.newerThan,\n baseline: options.baseline,\n writeBaseline: options.writeBaseline,\n toolVersion: options.toolVersion,\n judgeOptions,\n ...engineOverrides,\n });\n}\n\nexport { render };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;;;ACjBP;AAAA,EACE,SAAW;AAAA,EACX,KAAO;AAAA,EACP,OAAS;AAAA,EACT,MAAQ;AAAA,EACR,UAAY,CAAC,SAAS,YAAY,SAAS,cAAc,WAAW;AAAA,EACpE,YAAc;AAAA,IACZ,OAAS;AAAA,MACP,MAAQ;AAAA,MACR,aAAe;AAAA,IACjB;AAAA,IACA,UAAY;AAAA,MACV,MAAQ;AAAA,MACR,aAAe;AAAA,IACjB;AAAA,IACA,OAAS;AAAA,MACP,MAAQ,CAAC,QAAQ,QAAQ,SAAS;AAAA,MAClC,aAAe;AAAA,IACjB;AAAA,IACA,YAAc;AAAA,MACZ,MAAQ;AAAA,MACR,SAAW;AAAA,MACX,SAAW;AAAA,MACX,aAAe;AAAA,IACjB;AAAA,IACA,WAAa;AAAA,MACX,MAAQ;AAAA,MACR,aAAe;AAAA,IACjB;AAAA,EACF;AAAA,EACA,sBAAwB;AAC1B;;;ACzBA,SAAS,YAAY,WAAW,cAAc,qBAAqB;AACnE,SAAS,SAAS,YAAY;AAC9B,SAAS,SAAS,WAAW,aAAa,qBAAqB;AAcxD,IAAM,eAAe,KAAK,mBAAmB,cAAc;AAE3D,SAAS,YAAY,MAA6B;AACvD,QAAM,OAAO,KAAK,MAAM,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,UAAU,MAAM,IAAI,CAAC;AACnE,YAAI,mBAAmB,QAAQ,aAAa,OAAO;AACjD,4BAAkB,oBAAoB,EAAE,UAAU,UAAU,MAAM,IAAI,CAAC;AAAA,QACzE;AAAA,MACF,SAAS,GAAG;AACV,YAAI,QAAQ,UAAU,EAAE,aAAa,eAAgB,OAAM;AAU3D,aAAK,+BAA0B,EAAE,OAAO,qCAAqC;AAAA,MAC/E;AAAA,IACF,WAAW,mBAAmB,QAAQ,aAAa,OAAO;AAQxD,wBAAkB,oBAAoB,EAAE,UAAU,MAAM,IAAI,CAAC;AAAA,IAC/D;AAAA,EACF;AAEA,SAAO,SAAS;AAAA,IACd;AAAA,IACA;AAAA,IACA;AAAA,IACA,YAAY,QAAQ;AAAA,IACpB,UAAU,QAAQ;AAAA,IAClB;AAAA,IACA,YAAY,QAAQ;AAAA,IACpB,SAAS,QAAQ;AAAA,IACjB,KAAK,QAAQ;AAAA,IACb,mBAAmB,QAAQ;AAAA,IAC3B,QAAQ,QAAQ;AAAA,IAChB,gBAAgB,SAAS,QAAQ,cAAc;AAAA,IAC/C,WAAW,QAAQ;AAAA,IACnB,UAAU,QAAQ;AAAA,IAClB,cAAc,QAAQ;AAAA,IACtB,WAAW,QAAQ;AAAA,IACnB,OAAO,QAAQ;AAAA,IACf,OAAO,QAAQ;AAAA,IACf,WAAW,QAAQ;AAAA,IACnB,UAAU,QAAQ;AAAA,IAClB,eAAe,QAAQ;AAAA,IACvB,aAAa,QAAQ;AAAA,IACrB;AAAA,IACA,GAAG;AAAA,EACL,CAAC;AACH;","names":["selectProvider","providerSpecFor","selectProvider","mkdirSync","readFileSync","writeFileSync","dirname","join","resolve","doc","block","META_PROVENANCE_KEY","join","dirname","dir","resolve","scriptAbsPath","join","rel","mkdirSync","writeFileSync","readFileSync","selectProvider"]}