orkeon-code 1.0.0-rc.1 → 1.0.0-rc.2

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 (440) hide show
  1. package/.orkeon-runtime +10 -0
  2. package/.orkeon-version +1 -1
  3. package/NOTICE.md +1 -1
  4. package/README.fr.md +16 -22
  5. package/README.md +16 -22
  6. package/config/appsettings.jev.example.json +4 -1
  7. package/config/appsettings.kev.example.json +4 -1
  8. package/config/appsettings.liquid.example.json +4 -1
  9. package/config/appsettings.ollama-whisper.example.json +1 -0
  10. package/config/appsettings.whisper.example.json +1 -0
  11. package/mcp/whisper/README.md +2 -1
  12. package/orkeon-code +206 -11
  13. package/orkeon-code.ps1 +109 -7
  14. package/package.json +2 -1
  15. package/src/commands/.orkeon/orkeon-cli.d.ts +1 -4
  16. package/src/commands/_lib/args.ts +5 -4
  17. package/src/commands/_lib/dev/dev-batches.ts +34 -36
  18. package/src/commands/_lib/dev/dev-implement.ts +11 -14
  19. package/src/commands/_lib/dev/dev-source.ts +7 -11
  20. package/src/commands/_lib/dev/dev.ts +34 -37
  21. package/src/commands/_lib/dev/markers.ts +7 -0
  22. package/src/commands/_lib/dev/messages.ts +112 -0
  23. package/src/commands/_lib/dev-step.ts +16 -13
  24. package/src/commands/_lib/dispatch.ts +62 -39
  25. package/src/commands/_lib/git/branch.ts +9 -10
  26. package/src/commands/_lib/git/commit.ts +9 -13
  27. package/src/commands/_lib/git/diff.ts +22 -12
  28. package/src/commands/_lib/git/messages.ts +54 -0
  29. package/src/commands/_lib/git/review.ts +9 -10
  30. package/src/commands/_lib/memory/memory-admit.ts +19 -21
  31. package/src/commands/_lib/memory/memory.ts +3 -2
  32. package/src/commands/_lib/memory/messages.ts +32 -0
  33. package/src/commands/_lib/messages.ts +48 -0
  34. package/src/commands/_lib/project/messages.ts +8 -0
  35. package/src/commands/_lib/session/export.ts +3 -2
  36. package/src/commands/_lib/session/messages.ts +87 -0
  37. package/src/commands/_lib/session/prompts.ts +4 -0
  38. package/src/commands/_lib/session/resume.ts +15 -24
  39. package/src/commands/_lib/session/tasks.ts +20 -23
  40. package/src/commands/_lib/settings/advisor.ts +11 -16
  41. package/src/commands/_lib/settings/agents.ts +18 -28
  42. package/src/commands/_lib/settings/choices.ts +8 -0
  43. package/src/commands/_lib/settings/config.ts +43 -43
  44. package/src/commands/_lib/settings/effort.ts +147 -0
  45. package/src/commands/_lib/settings/hooks.ts +12 -20
  46. package/src/commands/_lib/settings/messages.ts +408 -0
  47. package/src/commands/_lib/settings/mode.ts +33 -24
  48. package/src/commands/_lib/settings/model.ts +71 -36
  49. package/src/commands/_lib/settings/output-style.ts +39 -0
  50. package/src/commands/_lib/settings/permissions.ts +71 -93
  51. package/src/commands/_lib/settings/route.ts +63 -0
  52. package/src/commands/_lib/settings/skills.ts +53 -11
  53. package/src/commands/_lib/settings/theme.ts +42 -0
  54. package/src/commands/_lib/speech/messages.ts +58 -0
  55. package/src/commands/_lib/speech/prompts.ts +4 -0
  56. package/src/commands/_lib/speech/say.ts +9 -10
  57. package/src/commands/_lib/speech/transcribe.ts +14 -23
  58. package/src/commands/_lib/speech/voice.ts +14 -18
  59. package/src/commands/_lib/status/doctor.ts +47 -28
  60. package/src/commands/_lib/status/messages.ts +100 -0
  61. package/src/commands/_lib/status/meta.ts +3 -24
  62. package/src/commands/_lib/status/status.ts +10 -11
  63. package/src/commands/_lib/status/usage-tools.ts +2 -3
  64. package/src/commands/_lib/status/usage.ts +7 -18
  65. package/src/commands/_lib/view.ts +6 -1
  66. package/src/commands/dev/dev-batches.cmd.ts +4 -3
  67. package/src/commands/dev/dev-learn.cmd.ts +3 -3
  68. package/src/commands/dev/dev-plan.cmd.ts +6 -7
  69. package/src/commands/dev/dev-spec.cmd.ts +6 -7
  70. package/src/commands/git/commit.cmd.ts +3 -3
  71. package/src/commands/git/review.cmd.ts +3 -3
  72. package/src/commands/memory/memory.cmd.ts +2 -2
  73. package/src/commands/project/analyze.cmd.ts +3 -3
  74. package/src/commands/project/debug-tool-call.cmd.ts +4 -9
  75. package/src/commands/project/init-verifiers.cmd.ts +3 -3
  76. package/src/commands/project/init.cmd.ts +3 -3
  77. package/src/commands/project/verify.cmd.ts +2 -2
  78. package/src/commands/session/assistant.cmd.ts +2 -2
  79. package/src/commands/session/compact.cmd.ts +1 -1
  80. package/src/commands/session/copy.cmd.ts +8 -7
  81. package/src/commands/session/rename.cmd.ts +3 -2
  82. package/src/commands/session/rewind.cmd.ts +3 -4
  83. package/src/commands/session/summary.cmd.ts +3 -3
  84. package/src/commands/session/tasks.cmd.ts +4 -2
  85. package/src/commands/settings/config.cmd.ts +4 -2
  86. package/src/commands/settings/effort.cmd.ts +10 -31
  87. package/src/commands/settings/fast.cmd.ts +2 -1
  88. package/src/commands/settings/mode.cmd.ts +3 -3
  89. package/src/commands/settings/model.cmd.ts +3 -2
  90. package/src/commands/settings/output-style.cmd.ts +9 -38
  91. package/src/commands/settings/permissions.cmd.ts +2 -2
  92. package/src/commands/settings/proactive.cmd.ts +2 -1
  93. package/src/commands/settings/route.cmd.ts +16 -0
  94. package/src/commands/settings/skills.cmd.ts +3 -3
  95. package/src/commands/settings/theme.cmd.ts +14 -0
  96. package/src/commands/speech/say.cmd.ts +2 -2
  97. package/src/commands/speech/transcribe.cmd.ts +2 -2
  98. package/src/commands/status/release-notes.cmd.ts +1 -1
  99. package/src/crews/.orkeon/orkeon.d.ts +538 -93
  100. package/src/crews/_probe-shared-memory/domain/messages.ts +54 -0
  101. package/src/crews/_probe-shared-memory/domain/probe-verdict.ts +17 -12
  102. package/src/crews/_probe-shared-memory/domain/prompts.ts +5 -0
  103. package/src/crews/_probe-shared-memory/probe.ork.ts +5 -3
  104. package/src/crews/advisor/application/messages.ts +4 -0
  105. package/src/crews/advisor/application/prompts.ts +4 -0
  106. package/src/crews/advisor/application/run-advisor.ts +2 -1
  107. package/src/crews/advisor/crew.ork.ts +5 -4
  108. package/src/crews/advisor/domain/advice.ts +7 -23
  109. package/src/crews/advisor/domain/messages.ts +8 -0
  110. package/src/crews/advisor/domain/prompts.ts +26 -0
  111. package/src/crews/agent-run/application/messages.ts +18 -0
  112. package/src/crews/agent-run/application/run-agent-run.ts +5 -4
  113. package/src/crews/agent-run/crew.ork.ts +3 -3
  114. package/src/crews/analyze/application/messages.ts +27 -0
  115. package/src/crews/analyze/application/prompts.ts +4 -0
  116. package/src/crews/analyze/application/run-analyze.ts +16 -14
  117. package/src/crews/analyze/crew.ork.ts +5 -4
  118. package/src/crews/analyze/domain/harvest.ts +33 -65
  119. package/src/crews/analyze/domain/prompts.ts +86 -0
  120. package/src/crews/code-review/application/lens-material.ts +24 -0
  121. package/src/crews/code-review/application/messages.ts +17 -0
  122. package/src/crews/code-review/application/prompts.ts +10 -17
  123. package/src/crews/code-review/application/review.ts +4 -1
  124. package/src/crews/code-review/application/run-code-review.ts +13 -15
  125. package/src/crews/code-review/crew.ork.ts +5 -4
  126. package/src/crews/code-review/domain/lenses.ts +6 -45
  127. package/src/crews/code-review/domain/messages.ts +25 -0
  128. package/src/crews/code-review/domain/prompts.ts +58 -0
  129. package/src/crews/code-review/domain/report.ts +5 -6
  130. package/src/crews/code-review/domain/scope.ts +6 -12
  131. package/src/crews/dev-batches/application/messages.ts +127 -0
  132. package/src/crews/dev-batches/application/plan-close.ts +12 -12
  133. package/src/crews/dev-batches/application/prompts.ts +10 -0
  134. package/src/crews/dev-batches/application/run-dev-batches.ts +57 -50
  135. package/src/crews/dev-batches/application/run-wave.ts +24 -22
  136. package/src/crews/dev-batches/application/seed-harvest.ts +8 -7
  137. package/src/crews/dev-batches/crew.ork.ts +12 -9
  138. package/src/crews/dev-batches/domain/batches-log.ts +1 -3
  139. package/src/crews/dev-batches/domain/markers.ts +5 -0
  140. package/src/crews/dev-batches/domain/messages.ts +6 -0
  141. package/src/crews/dev-batches/domain/wave-order.ts +3 -2
  142. package/src/crews/dev-change/application/change-material.ts +44 -0
  143. package/src/crews/dev-change/application/evidence.ts +25 -22
  144. package/src/crews/dev-change/application/messages.ts +81 -0
  145. package/src/crews/dev-change/application/{change-prompt.ts → prompts.ts} +40 -43
  146. package/src/crews/dev-change/application/run-dev-change.ts +43 -34
  147. package/src/crews/dev-change/crew.ork.ts +11 -9
  148. package/src/crews/dev-change/domain/change-answer.ts +24 -20
  149. package/src/crews/dev-change/domain/change-render.ts +13 -15
  150. package/src/crews/dev-change/domain/markers.ts +28 -0
  151. package/src/crews/dev-change/domain/messages.ts +16 -0
  152. package/src/crews/dev-implement/application/close.ts +21 -18
  153. package/src/crews/dev-implement/application/locate-sheet.ts +7 -5
  154. package/src/crews/dev-implement/application/messages.ts +161 -0
  155. package/src/crews/dev-implement/application/observe.ts +4 -2
  156. package/src/crews/dev-implement/application/prompts.ts +9 -0
  157. package/src/crews/dev-implement/application/report-writes.ts +14 -9
  158. package/src/crews/dev-implement/application/run-dev-implement.ts +84 -73
  159. package/src/crews/dev-implement/application/suite-job.ts +15 -11
  160. package/src/crews/dev-implement/crew.ork.ts +2 -1
  161. package/src/crews/dev-implement/domain/contracts.ts +59 -60
  162. package/src/crews/dev-implement/domain/correction.ts +16 -15
  163. package/src/crews/dev-implement/domain/cycles.ts +2 -1
  164. package/src/crews/dev-implement/domain/markers.ts +23 -0
  165. package/src/crews/dev-implement/domain/messages.ts +58 -0
  166. package/src/crews/dev-implement/domain/prompts.ts +93 -0
  167. package/src/crews/dev-implement/domain/roles.ts +3 -7
  168. package/src/crews/dev-implement/domain/sheet-edits.ts +6 -5
  169. package/src/crews/dev-implement/domain/sheet-ticks.ts +5 -4
  170. package/src/crews/dev-implement/domain/step-checks.ts +17 -16
  171. package/src/crews/dev-implement/domain/step-section.ts +6 -4
  172. package/src/crews/dev-learn/application/learn-prompt-fit.ts +63 -0
  173. package/src/crews/dev-learn/application/messages.ts +51 -0
  174. package/src/crews/dev-learn/application/{learn-prompt.ts → prompts.ts} +24 -65
  175. package/src/crews/dev-learn/application/run-dev-learn.ts +37 -32
  176. package/src/crews/dev-learn/crew.ork.ts +4 -3
  177. package/src/crews/dev-learn/domain/learn-answer.ts +25 -27
  178. package/src/crews/dev-learn/domain/messages.ts +65 -0
  179. package/src/crews/dev-learn/domain/owner-lines.ts +12 -9
  180. package/src/crews/dev-learn/domain/proposals-render.ts +8 -9
  181. package/src/crews/dev-plan/application/anchor-paths.ts +57 -20
  182. package/src/crews/dev-plan/application/inventory.ts +17 -13
  183. package/src/crews/dev-plan/application/messages.ts +88 -0
  184. package/src/crews/dev-plan/application/plan-prompt-fit.ts +44 -0
  185. package/src/crews/dev-plan/application/{plan-prompt.ts → prompts.ts} +37 -55
  186. package/src/crews/dev-plan/application/run-dev-plan.ts +103 -75
  187. package/src/crews/dev-plan/crew.ork.ts +11 -8
  188. package/src/crews/dev-plan/domain/inventory-model.ts +3 -3
  189. package/src/crews/dev-plan/domain/markers.ts +18 -0
  190. package/src/crews/dev-plan/domain/messages.ts +118 -0
  191. package/src/crews/dev-plan/domain/plan-answer.ts +118 -103
  192. package/src/crews/dev-plan/domain/plan-render.ts +30 -31
  193. package/src/crews/dev-plan/domain/prompts.ts +44 -0
  194. package/src/crews/dev-spec/application/messages.ts +30 -0
  195. package/src/crews/dev-spec/application/{spec-prompt.ts → prompts.ts} +42 -47
  196. package/src/crews/dev-spec/application/run-dev-spec.ts +67 -36
  197. package/src/crews/dev-spec/application/spec-material.ts +42 -0
  198. package/src/crews/dev-spec/crew.ork.ts +11 -9
  199. package/src/crews/dev-spec/domain/markers.ts +30 -0
  200. package/src/crews/dev-spec/domain/messages.ts +39 -0
  201. package/src/crews/dev-spec/domain/spec-answer.ts +46 -47
  202. package/src/crews/dev-spec/domain/spec-render.ts +18 -18
  203. package/src/crews/dev-verify/application/audit-brief.ts +187 -0
  204. package/src/crews/dev-verify/application/audit.ts +38 -30
  205. package/src/crews/dev-verify/application/capture.ts +34 -26
  206. package/src/crews/dev-verify/application/messages.ts +119 -0
  207. package/src/crews/dev-verify/application/prompts.ts +209 -0
  208. package/src/crews/dev-verify/application/run-dev-verify.ts +60 -46
  209. package/src/crews/dev-verify/application/run-gate.ts +11 -9
  210. package/src/crews/dev-verify/crew.ork.ts +6 -6
  211. package/src/crews/dev-verify/domain/audit-answer.ts +16 -12
  212. package/src/crews/dev-verify/domain/capture-sections.ts +5 -4
  213. package/src/crews/dev-verify/domain/commands.ts +3 -3
  214. package/src/crews/dev-verify/domain/gate.ts +21 -16
  215. package/src/crews/dev-verify/domain/markers.ts +16 -0
  216. package/src/crews/dev-verify/domain/mechanical-table.ts +37 -44
  217. package/src/crews/dev-verify/domain/messages.ts +92 -0
  218. package/src/crews/dev-verify/domain/verdict.ts +4 -4
  219. package/src/crews/git-commit/application/draft.ts +16 -37
  220. package/src/crews/git-commit/application/messages.ts +15 -0
  221. package/src/crews/git-commit/application/prompts.ts +47 -0
  222. package/src/crews/git-commit/application/run-git-commit.ts +13 -12
  223. package/src/crews/git-commit/crew.ork.ts +5 -4
  224. package/src/crews/git-commit/domain/commit.ts +15 -35
  225. package/src/crews/git-commit/domain/markers.ts +4 -0
  226. package/src/crews/git-commit/domain/messages.ts +48 -0
  227. package/src/crews/init-verifiers/application/authoring.ts +2 -1
  228. package/src/crews/init-verifiers/application/messages.ts +13 -0
  229. package/src/crews/init-verifiers/application/prompts.ts +5 -1
  230. package/src/crews/init-verifiers/application/run-init-verifiers.ts +3 -2
  231. package/src/crews/init-verifiers/crew.ork.ts +5 -4
  232. package/src/crews/main-loop/application/auto-compact.ts +2 -1
  233. package/src/crews/main-loop/application/messages.ts +81 -0
  234. package/src/crews/main-loop/application/prompts.ts +12 -0
  235. package/src/crews/main-loop/application/run-main-loop.ts +63 -30
  236. package/src/crews/main-loop/application/{turn-prompt.ts → turn-context.ts} +7 -8
  237. package/src/crews/main-loop/crew.ork.ts +12 -7
  238. package/src/crews/main-loop/domain/prompt-assembly.ts +45 -228
  239. package/src/crews/main-loop/domain/prompts.ts +336 -0
  240. package/src/crews/main-loop/domain/turn-chains.ts +10 -9
  241. package/src/crews/project-init/application/detect.ts +5 -4
  242. package/src/crews/project-init/application/messages.ts +15 -0
  243. package/src/crews/project-init/application/prompts.ts +11 -7
  244. package/src/crews/project-init/crew.ork.ts +5 -4
  245. package/src/crews/project-init/domain/existing-files.ts +6 -4
  246. package/src/crews/project-init/domain/messages.ts +13 -0
  247. package/src/crews/project-init/domain/package-map.ts +3 -3
  248. package/src/crews/project-init/domain/prompts.ts +10 -0
  249. package/src/crews/session-compact/application/prompts.ts +5 -0
  250. package/src/crews/session-compact/crew.ork.ts +5 -4
  251. package/src/crews/shared-memory-admit/application/prompts.ts +5 -0
  252. package/src/crews/shared-memory-admit/crew.ork.ts +3 -2
  253. package/src/crews/speech/application/messages.ts +3 -0
  254. package/src/crews/speech/application/prompts.ts +3 -0
  255. package/src/crews/speech/application/run-speech.ts +2 -1
  256. package/src/crews/speech/crew.ork.ts +2 -1
  257. package/src/shared/application/agents/child-agent.ts +11 -7
  258. package/src/shared/application/agents/messages.ts +35 -0
  259. package/src/shared/application/agents/route-agent.ts +115 -0
  260. package/src/shared/application/agents/run-sub-agent.ts +31 -8
  261. package/src/shared/application/compaction/compact-session.ts +19 -14
  262. package/src/shared/application/compaction/messages.ts +20 -0
  263. package/src/shared/application/compaction/prune-context.ts +94 -0
  264. package/src/shared/application/compaction/pruned-llm.ts +35 -0
  265. package/src/shared/application/dev/brief-inventory.ts +6 -4
  266. package/src/shared/application/dev/close-batch.ts +9 -7
  267. package/src/shared/application/dev/find-repo-pack.ts +4 -3
  268. package/src/shared/application/dev/learn-decision.ts +20 -18
  269. package/src/shared/application/dev/load-dev-context.ts +7 -8
  270. package/src/shared/application/dev/measure-access-cost.ts +5 -4
  271. package/src/shared/application/dev/messages.ts +132 -0
  272. package/src/shared/application/dev/phase-timer.ts +54 -0
  273. package/src/shared/application/dev/plan-source.ts +12 -8
  274. package/src/shared/application/dev/preflight.ts +8 -8
  275. package/src/shared/application/dev/prompts.ts +34 -0
  276. package/src/shared/application/dev/question-round.ts +25 -17
  277. package/src/shared/application/dev/resolve-work-folder.ts +4 -3
  278. package/src/shared/application/dev/settle-questions.ts +4 -2
  279. package/src/shared/application/dev/source-review.ts +12 -8
  280. package/src/shared/application/dev/source-step.ts +12 -10
  281. package/src/shared/application/dev/spend.ts +17 -4
  282. package/src/shared/application/dev/step-precedents.ts +2 -1
  283. package/src/shared/application/dev/tool-call-policy.ts +9 -11
  284. package/src/shared/application/dev/tool-callbacks.ts +52 -5
  285. package/src/shared/application/dev/tool-trace-recorder.ts +2 -1
  286. package/src/shared/application/dev/verdict-sources.ts +5 -3
  287. package/src/shared/application/dev/wrapped-tools.ts +4 -2
  288. package/src/shared/application/extra-tools.ts +2 -1
  289. package/src/shared/application/git/batch-worktree.ts +22 -17
  290. package/src/shared/application/git/commit-files.ts +24 -19
  291. package/src/shared/application/git/merge-batch.ts +11 -7
  292. package/src/shared/application/git/messages.ts +75 -0
  293. package/src/shared/application/git/open-pull-request.ts +4 -3
  294. package/src/shared/application/host-context.ts +59 -0
  295. package/src/shared/application/host-layout-store.ts +45 -0
  296. package/src/shared/application/llm-profile.ts +4 -3
  297. package/src/shared/application/messages.ts +14 -0
  298. package/src/shared/application/permission-rules.ts +10 -0
  299. package/src/shared/application/ports/decision.ts +14 -0
  300. package/src/shared/application/ports/human.ts +25 -0
  301. package/src/shared/application/ports/llm.ts +32 -3
  302. package/src/shared/application/ports/memory.ts +1 -1
  303. package/src/shared/application/ports/theme.ts +11 -0
  304. package/src/shared/application/ports.ts +4 -2
  305. package/src/shared/application/session-io.ts +2 -1
  306. package/src/shared/application/shared-memory/admit-entries.ts +16 -14
  307. package/src/shared/application/shared-memory/harvest-after-gaps.ts +5 -8
  308. package/src/shared/application/shared-memory/harvest-mistakes.ts +3 -2
  309. package/src/shared/application/shared-memory/import-agent-memory.ts +9 -7
  310. package/src/shared/application/shared-memory/memory-files.ts +2 -1
  311. package/src/shared/application/shared-memory/memory-settings.ts +2 -1
  312. package/src/shared/application/shared-memory/messages.ts +63 -0
  313. package/src/shared/application/shared-memory/push-candidate.ts +14 -11
  314. package/src/shared/application/shared-memory/recall-precedents.ts +2 -1
  315. package/src/shared/application/skills/messages.ts +4 -0
  316. package/src/shared/application/skills/suggest-skills.ts +102 -0
  317. package/src/shared/application/workflow/messages.ts +8 -0
  318. package/src/shared/application/workflow/workflow-state.ts +7 -6
  319. package/src/shared/domain/agent-policy/behavior-flags.ts +4 -10
  320. package/src/shared/domain/agent-policy/extra-tools.ts +2 -4
  321. package/src/shared/domain/agent-policy/messages.ts +66 -0
  322. package/src/shared/domain/agent-policy/path-rules.ts +299 -0
  323. package/src/shared/domain/agent-policy/permission.ts +20 -18
  324. package/src/shared/domain/agent-policy/prompts.ts +17 -0
  325. package/src/shared/domain/agent-policy/reasoning.ts +59 -0
  326. package/src/shared/domain/agent-policy/rule-sets.ts +18 -14
  327. package/src/shared/domain/agent-policy/tool-access.ts +17 -3
  328. package/src/shared/domain/agent-registry.ts +6 -5
  329. package/src/shared/domain/agents/chain.ts +2 -2
  330. package/src/shared/domain/agents/charter.ts +8 -5
  331. package/src/shared/domain/agents/exclusive.ts +2 -1
  332. package/src/shared/domain/agents/instances.ts +18 -15
  333. package/src/shared/domain/agents/messages.ts +39 -0
  334. package/src/shared/domain/agents/model-route.ts +199 -0
  335. package/src/shared/domain/agents/prompts.ts +20 -0
  336. package/src/shared/domain/code-intel-contract.ts +5 -4
  337. package/src/shared/domain/code-intel-routing.ts +8 -61
  338. package/src/shared/domain/compact-outcome.ts +5 -3
  339. package/src/shared/domain/compaction-thresholds.ts +2 -1
  340. package/src/shared/domain/compaction.ts +22 -113
  341. package/src/shared/domain/config-schema.ts +94 -81
  342. package/src/shared/domain/context-prune.ts +176 -0
  343. package/src/shared/domain/decision/questions.ts +102 -0
  344. package/src/shared/domain/dev/access-cost.ts +19 -15
  345. package/src/shared/domain/dev/batches-concurrency.ts +5 -6
  346. package/src/shared/domain/dev/build-commands.ts +5 -4
  347. package/src/shared/domain/dev/call-guard.ts +29 -28
  348. package/src/shared/domain/dev/carried-text.ts +3 -5
  349. package/src/shared/domain/dev/learn-proposals.ts +5 -4
  350. package/src/shared/domain/dev/learn-state.ts +3 -2
  351. package/src/shared/domain/dev/markers.ts +107 -0
  352. package/src/shared/domain/dev/messages.ts +259 -0
  353. package/src/shared/domain/dev/phase-timing.ts +50 -0
  354. package/src/shared/domain/dev/plan-checks.ts +24 -23
  355. package/src/shared/domain/dev/plan-format.ts +14 -24
  356. package/src/shared/domain/dev/project-files.ts +1 -15
  357. package/src/shared/domain/dev/prompts/brief-blocks.ts +20 -0
  358. package/src/shared/domain/dev/{review-prompt.ts → prompts.ts} +91 -61
  359. package/src/shared/domain/dev/questions.ts +33 -15
  360. package/src/shared/domain/dev/repo-pack.ts +12 -9
  361. package/src/shared/domain/dev/review-answer.ts +40 -17
  362. package/src/shared/domain/dev/review-brief.ts +54 -0
  363. package/src/shared/domain/dev/reviewer-charter.ts +4 -0
  364. package/src/shared/domain/dev/sheet-facts.ts +2 -4
  365. package/src/shared/domain/dev/spec-format.ts +13 -14
  366. package/src/shared/domain/dev/step-budget.ts +4 -2
  367. package/src/shared/domain/dev/step-rules.ts +3 -4
  368. package/src/shared/domain/dev/test-commands.ts +14 -10
  369. package/src/shared/domain/dev/tool-guards.ts +4 -3
  370. package/src/shared/domain/dev/trait-pattern.ts +14 -10
  371. package/src/shared/domain/dev/verdict-format.ts +14 -21
  372. package/src/shared/domain/dev/whitespace.ts +3 -2
  373. package/src/shared/domain/dev/work-folder.ts +4 -3
  374. package/src/shared/domain/dev/yaml-subset.ts +8 -26
  375. package/src/shared/domain/error-text.ts +13 -0
  376. package/src/shared/domain/git/close.ts +5 -4
  377. package/src/shared/domain/git/messages.ts +20 -0
  378. package/src/shared/domain/git/pull-request.ts +5 -5
  379. package/src/shared/domain/host-layout.ts +147 -0
  380. package/src/shared/domain/host-paths.ts +399 -0
  381. package/src/shared/domain/llm-failure.ts +35 -7
  382. package/src/shared/domain/llm-profile.ts +22 -3
  383. package/src/shared/domain/marked-message.ts +1 -5
  384. package/src/shared/domain/markers.ts +30 -0
  385. package/src/shared/domain/messages.ts +291 -0
  386. package/src/shared/domain/model-catalog.ts +2 -9
  387. package/src/shared/domain/permission-modes.ts +4 -8
  388. package/src/shared/domain/prelude.ts +2 -2
  389. package/src/shared/domain/project-manifests.ts +3 -2
  390. package/src/shared/domain/prompts.ts +233 -0
  391. package/src/shared/domain/search-routing.ts +3 -11
  392. package/src/shared/domain/secret-patterns.ts +3 -2
  393. package/src/shared/domain/session-keys.ts +7 -0
  394. package/src/shared/domain/session-start.ts +3 -2
  395. package/src/shared/domain/shared-memory/agent-memory-import.ts +4 -2
  396. package/src/shared/domain/shared-memory/candidates.ts +3 -4
  397. package/src/shared/domain/shared-memory/entry.ts +26 -20
  398. package/src/shared/domain/shared-memory/front-matter.ts +17 -13
  399. package/src/shared/domain/shared-memory/gate.ts +4 -3
  400. package/src/shared/domain/shared-memory/harvest.ts +9 -6
  401. package/src/shared/domain/shared-memory/layout.ts +11 -8
  402. package/src/shared/domain/shared-memory/markers.ts +9 -0
  403. package/src/shared/domain/shared-memory/messages.ts +66 -0
  404. package/src/shared/domain/shared-memory/precedents-block.ts +4 -15
  405. package/src/shared/domain/shared-memory/prompts.ts +28 -0
  406. package/src/shared/domain/shared-memory/refused.ts +3 -3
  407. package/src/shared/domain/skills/prompts.ts +4 -0
  408. package/src/shared/domain/skills/shortlist.ts +149 -0
  409. package/src/shared/domain/snip-turns.ts +2 -14
  410. package/src/shared/domain/speech.ts +2 -1
  411. package/src/shared/domain/tool-trace.ts +5 -7
  412. package/src/shared/domain/verifiers.ts +7 -11
  413. package/src/shared/domain/vfs.ts +8 -1
  414. package/src/shared/domain/workflow/prompts.ts +15 -0
  415. package/src/shared/domain/workflow/state-file.ts +14 -12
  416. package/src/shared/infrastructure/globals.ts +7 -2
  417. package/src/shared/infrastructure/orkeon/child-agents.ts +11 -16
  418. package/src/shared/infrastructure/orkeon/chooser.ts +32 -0
  419. package/src/shared/infrastructure/orkeon/decision-model.ts +31 -0
  420. package/src/shared/infrastructure/orkeon/dev-deps.ts +21 -14
  421. package/src/shared/infrastructure/orkeon/files.ts +24 -6
  422. package/src/shared/infrastructure/orkeon/github-pull-requests.ts +3 -2
  423. package/src/shared/infrastructure/orkeon/host-context.ts +36 -0
  424. package/src/shared/infrastructure/orkeon/human-input.ts +1 -5
  425. package/src/shared/infrastructure/orkeon/llm-profile.ts +36 -16
  426. package/src/shared/infrastructure/orkeon/llm.ts +85 -30
  427. package/src/shared/infrastructure/orkeon/markers.ts +6 -0
  428. package/src/shared/infrastructure/orkeon/memory-store.ts +1 -1
  429. package/src/shared/infrastructure/orkeon/memory-tools.ts +18 -20
  430. package/src/shared/infrastructure/orkeon/messages.ts +15 -0
  431. package/src/shared/infrastructure/orkeon/prompts.ts +47 -0
  432. package/src/shared/infrastructure/orkeon/reasoning.ts +40 -0
  433. package/src/shared/infrastructure/orkeon/script-tools.ts +14 -19
  434. package/src/shared/infrastructure/orkeon/session-store.ts +7 -51
  435. package/src/shared/infrastructure/orkeon/shell-jobs.ts +13 -7
  436. package/src/shared/infrastructure/orkeon/shell.ts +13 -5
  437. package/src/shared/infrastructure/orkeon/tool-catalogue.ts +3 -2
  438. package/src/shared/infrastructure/orkeon/wiring.ts +68 -12
  439. package/src/crews/dev-verify/application/auditor-prompt.ts +0 -323
  440. package/src/shared/domain/session-summary.ts +0 -13
@@ -5,19 +5,12 @@
5
5
  // goes in the brief only, never in the system message.
6
6
 
7
7
  import { BOUNDED_READ_RULE, KNOWN_TOOLS_RULE, NODE_READ_RULE } from "./reading-rule.ts";
8
- import { NEXT_BATCH_REVIEWER_CHARTER, REVIEWER_TOOLS } from "./reviewer-charter.ts";
8
+ import { NEXT_BATCH_REVIEWER_CHARTER, REVIEWER_LOOKUPS, REVIEWER_TOOLS } from "./reviewer-charter.ts";
9
9
  import { describeCodeIntelRouting } from "../code-intel-routing.ts";
10
- import { carry } from "./carried-text.ts";
11
- import type { CarriedText } from "./carried-text.ts";
12
- import { PROJECT_LIST_RULE, projectFileLines } from "./project-files.ts";
10
+ import { PROJECT_LIST_RULE } from "./prompts/brief-blocks.ts";
13
11
 
14
12
  export type ReviewMode = "plan" | "spec" | "change" | "next-batch";
15
13
 
16
- export const MAX_REVIEW_REPLY_CHARS = 12_000;
17
-
18
- /** The most carried text a review brief holds, in characters (MAX_BRIEF_CHARS less the brief's own lines). */
19
- export const CARRIED_REVIEW_CHARS = 18_000;
20
-
21
14
  const COMMON = [
22
15
  "You review a piece of development work before anyone builds it.",
23
16
  "Your task is to hunt for gaps the author did not close; you do not praise, summarise or repeat the document.",
@@ -26,7 +19,8 @@ const COMMON = [
26
19
  "",
27
20
  "How a finding is asked:",
28
21
  "- Phrase it so that it is settled by a yes, a no, or a choice among the options it names.",
29
- "- Write it as one sentence that closes with a question mark.",
22
+ "- Write it as one sentence of at most 300 characters that closes with a question mark; what does not fit goes",
23
+ " in its evidence.",
30
24
  "- Cite where it comes from: a path:line you opened, or a section of the files (§ n, or a heading);",
31
25
  " a finding without a citation is dropped, so a suspicion you cannot point at stays out of the list.",
32
26
  "- Before asking, look for the answer in the rest of the material (the other files the brief names, the code):",
@@ -64,6 +58,8 @@ const SPEC_FOCUS = [
64
58
  " use case;",
65
59
  "- whether the lifecycle is covered (create, read, change, withdraw, as relevant), whether an error or an edge that",
66
60
  " matters has no behaviour, and whether something the code already does is asked again or named differently.",
61
+ "What the spec's Decisions section records is settled and wins over the body, which is rewritten with it only",
62
+ "after your review: a question a decision answers, or a body line a decision replaces, is no row.",
67
63
  ];
68
64
 
69
65
  const CHANGE_FOCUS = [
@@ -123,6 +119,14 @@ const closing = (tools: readonly string[], listed: boolean): string[] => [
123
119
  "batch by its id: F1, F2…).",
124
120
  ];
125
121
 
122
+ /** The look-up budget of a plan, a spec or a brief's review: said so that the reviewer spends it on what weighs. */
123
+ const LOOKUP_BUDGET_RULE = [
124
+ "",
125
+ `You have ${REVIEWER_LOOKUPS} look-ups (tool calls) in all: spend them on what the heaviest questions need, several in one`,
126
+ "turn when they do not depend on one another. Past them every call is refused: write your findings then, from what",
127
+ "you read.",
128
+ ];
129
+
126
130
  /** The closing of a spec or a brief: the same reading rule, its own material and targets. */
127
131
  function sourceClosing(document: string, targets: string): string[] {
128
132
  return [
@@ -146,76 +150,102 @@ function sourceClosing(document: string, targets: string): string[] {
146
150
 
147
151
  /** The behaviour common to every mode, then the mode's focus: the act's system message. No material. */
148
152
  export function reviewSystem(mode: ReviewMode): string {
149
- if (mode === "spec") return [...COMMON, ...SPEC_FOCUS, ...sourceClosing("spec", "the spec as a whole, or one UC- or BR- id")].join("\n");
153
+ if (mode === "spec") return [...COMMON, ...SPEC_FOCUS, ...LOOKUP_BUDGET_RULE, ...sourceClosing("spec", "the spec as a whole, or one UC- or BR- id")].join("\n");
150
154
  if (mode === "change") {
151
- return [...COMMON, ...CHANGE_FOCUS, ...sourceClosing("brief", "the brief as a whole, or one CH- id")].join("\n");
155
+ return [...COMMON, ...CHANGE_FOCUS, ...LOOKUP_BUDGET_RULE, ...sourceClosing("brief", "the brief as a whole, or one CH- id")].join("\n");
152
156
  }
153
157
  if (mode === "next-batch") return [...COMMON, ...NEXT_BATCH_FOCUS, ...closing(NEXT_BATCH_REVIEWER_CHARTER.tools, true)].join("\n");
154
- return [...COMMON, ...PLAN_FOCUS, ...closing(REVIEWER_TOOLS, false)].join("\n");
158
+ return [...COMMON, ...PLAN_FOCUS, ...LOOKUP_BUDGET_RULE, ...closing(REVIEWER_TOOLS, false)].join("\n");
155
159
  }
156
160
 
157
- export interface ReviewBriefInput {
161
+ /** A review brief with every choice made: what it says is in the brief, the inventory trimmed, the project list. */
162
+ export interface ReviewBriefView {
158
163
  mode: ReviewMode;
159
- /** The folder under review, relative ("workbench/prune"). */
164
+ /** The folder under review, ending with a slash. */
160
165
  folder: string;
161
- /** The files to review, relative, in reading order. */
162
166
  files: readonly string[];
163
- /** The spec or brief the work was planned from, relative; for a spec or a brief, its origin ("" when none). */
167
+ /** Whether the text of every file to review is carried in the brief. */
168
+ filesInBrief: boolean;
164
169
  source: string;
165
- /** The inventory text: the plan's I<n> refs, the path:line rows of a spec or a brief. */
170
+ /** Whether the text of the source (the plan of a next batch) is carried in the brief. */
171
+ sourceInBrief: boolean;
172
+ /** The inventory, trimmed at its end. */
166
173
  inventory: string;
167
- /** What a row may target. */
174
+ /** The carried texts, each under its title. */
175
+ blocks: readonly string[];
176
+ /** The lines of the project's files, none when there is no list. */
177
+ project: readonly string[];
168
178
  targets: readonly string[];
169
- /** Texts carried in the brief, each under its title (next-batch: the batch's sheet, then what each closed batch
170
- * changed), so the reviewer opens no file for them; the whole room of CARRIED_REVIEW_CHARS for them. */
171
- carried?: readonly CarriedText[];
172
- /** The project's files (tracked and untracked, the work folder left out), listed so that the reviewer guesses no
173
- * name; absent or empty: no list. */
174
- projectFiles?: readonly string[];
175
179
  }
176
180
 
177
- export function buildReviewBrief(input: ReviewBriefInput): string {
178
- const folder = input.folder.endsWith("/") ? input.folder : `${input.folder}/`;
179
- const { blocks, whole } = carry(input.carried ?? [], CARRIED_REVIEW_CHARS);
180
- const inBrief = (file: string): boolean => whole.has(file);
181
- const lines = [
182
- `mode: ${input.mode} ${folder}`,
183
- input.files.length > 0 && input.files.every(inBrief)
181
+ const NO_ENTRY = "(no entry)";
182
+
183
+ /** The lines of a review brief that depend on its mode: the source and the inventory, the carried texts. */
184
+ function reviewBriefModeLines(view: ReviewBriefView): string[] {
185
+ if (view.mode === "plan") {
186
+ return [`Source it was planned from: ${view.source}`, "Inventory the plan's anchors were chosen from (I<n> refs):", view.inventory || NO_ENTRY];
187
+ }
188
+ if (view.mode === "next-batch") {
189
+ return [
190
+ `The plan: ${view.source}${view.sourceInBrief ? " (in this brief)" : ""}`,
191
+ "The batches closed before it, with their commits and files:",
192
+ view.inventory || NO_ENTRY,
193
+ ...(view.blocks.length > 0
194
+ ? ["", "In this brief, so that you open no file for them (the sheet, what each closed batch changed, then the plan):", "", ...view.blocks]
195
+ : []),
196
+ ];
197
+ }
198
+ return [
199
+ ...(view.source !== "" ? [`Origin of the request: ${view.source}`] : []),
200
+ "What the code index found for the request (path:line):",
201
+ view.inventory || NO_ENTRY,
202
+ ];
203
+ }
204
+
205
+ /** The brief that names the files to review, the source, the inventory and the targets. */
206
+ export function reviewBrief(view: ReviewBriefView): string {
207
+ return [
208
+ `mode: ${view.mode} ${view.folder}`,
209
+ view.filesInBrief
184
210
  ? "Files to review, in this order (their text is in this brief: open none of them):"
185
211
  : "Files to review, in this order (read each by section, a heading at a time):",
186
- ...input.files.map((file) => `- ${file}`),
187
- ];
188
- if (input.mode === "plan") {
189
- lines.push(`Source it was planned from: ${input.source}`);
190
- lines.push("Inventory the plan's anchors were chosen from (I<n> refs):", input.inventory.trimEnd() || "(no entry)");
191
- } else if (input.mode === "next-batch") {
192
- lines.push(`The plan: ${input.source}${inBrief(input.source) ? " (in this brief)" : ""}`);
193
- lines.push("The batches closed before it, with their commits and files:", input.inventory.trimEnd() || "(no entry)");
194
- if (blocks.length > 0) lines.push("", "In this brief, so that you open no file for them (the sheet, what each closed batch changed, then the plan):", "", ...blocks);
195
- } else {
196
- if (input.source !== "") lines.push(`Origin of the request: ${input.source}`);
197
- lines.push("What the code index found for the request (path:line):", input.inventory.trimEnd() || "(no entry)");
198
- }
199
- const project = projectFileLines(input.projectFiles ?? []);
200
- if (project.length > 0) lines.push("", ...project);
201
- lines.push(`A row targets one of: ${input.targets.join(", ")}.`);
202
- return lines.join("\n");
212
+ ...view.files.map((file) => `- ${file}`),
213
+ ...reviewBriefModeLines(view),
214
+ ...(view.project.length > 0 ? ["", ...view.project] : []),
215
+ `A row targets one of: ${view.targets.join(", ")}.`,
216
+ ].join("\n");
203
217
  }
204
218
 
205
- export function buildReviewAnswerPrompt(reply: string, problems: readonly string[], targets: readonly string[]): string {
206
- const text = reply.length > MAX_REVIEW_REPLY_CHARS
207
- ? `[earlier text cut]\n${reply.slice(-MAX_REVIEW_REPLY_CHARS)}`
208
- : reply;
209
- const lines = [
219
+ /** A reply cut to its end, said so. */
220
+ export const earlierTextCut = (tail: string): string => `[earlier text cut]\n${tail}`;
221
+
222
+ /** The prompt that turns the plain-text review into the answer's schema. */
223
+ export function reviewAnswerPrompt(text: string, problems: readonly string[], targets: readonly string[]): string {
224
+ return [
210
225
  "Turn the review below into the JSON answer. Take the rows from the review as written; invent no row it does not",
211
226
  "hold. The verdict follows the rows: GAPS when the review asks one question or more, CLEAR when it asks none,",
212
227
  "whatever word the review opens with. A row's severity is Blocking or Major; its question is one closed question",
213
- "ending with ?; its evidence is a path:line, a § n or a section heading; its target is the id alone, one of",
228
+ "of at most 300 characters ending with ? (shorten a longer one to what it asks); its evidence is a path:line, a § n or a section heading; its target is the id alone, one of",
214
229
  `${targets.join(", ")} (never the id with a qualifier, such as "F2 (step 1)").`,
215
- ];
216
- if (problems.length > 0) {
217
- lines.push("", "The previous answer was refused; fix each of these:", ...problems.map((p) => `- ${p}`));
218
- }
219
- lines.push("", "The review:", "", text);
220
- return lines.join("\n");
230
+ ...(problems.length > 0 ? ["", "The previous answer was refused; fix each of these:", ...problems.map((p) => `- ${p}`)] : []),
231
+ "",
232
+ "The review:",
233
+ "",
234
+ text,
235
+ ].join("\n");
221
236
  }
237
+
238
+ // ── The call guard of a dev step: what the model is told to do instead ──
239
+
240
+ export const USE_READ_TOOLS_AND_EDITORS = "Use the read tools and the file editors only.";
241
+ export const USE_READ_TOOLS = "Use the read tools only.";
242
+ export const refusedDuringStep = (title: string, command: string): string =>
243
+ `${title} are refused during /${command}: do without this call.`;
244
+ export const CHANGE_EXISTING_SOURCE_BY_NODE =
245
+ "This source file exists: change it by node (node_read for its sha256, then node_replace, node_insert or " +
246
+ "node_ensure) or with edit_file, never by writing it whole; file_write only creates a file.";
247
+ export const opensNoSourceOrTest = (role: string): string =>
248
+ `The ${role} opens no source or test file by its path: work from the batch sheet and the plan.`;
249
+ export const writesOutsideRootsOnly = (role: string, implementer: boolean): string =>
250
+ `The ${role} writes outside these roots only: ${implementer ? "leave the tests as they are" : "write the tests, no source file"}.`;
251
+ export const USE_VALIDATE_PARSE = "Use validate \"parse\" (the default); the build is run_build's, with the pack's command.";
@@ -3,6 +3,12 @@
3
3
  // template's columns (`| # | Severity | Question | Impact | Options |`), so spec-format.ts and the harness read
4
4
  // its severity as before; a decision row (`| # | Question | Answer | Date |`) records what was settled, in a section
5
5
  // of its own. Pure, no IO.
6
+ import {
7
+ DECISIONS_HEADER, DECISIONS_HEADING, LEAVE_OPEN, OPEN_QUESTIONS_HEADER, OPEN_QUESTIONS_HEADING, RECOMMENDED_MARK,
8
+ } from "./markers.ts";
9
+ import {
10
+ impactOneLine, notAnOptionToList, optionCount, optionOneLine, questionOneLine, severityMustBe, twoOptionsSame,
11
+ } from "./messages.ts";
6
12
 
7
13
  export type QuestionSeverity = "Blocking" | "Major";
8
14
  export const QUESTION_SEVERITIES: readonly QuestionSeverity[] = ["Blocking", "Major"];
@@ -12,11 +18,6 @@ export interface Question { id: string; severity: QuestionSeverity; question: st
12
18
  /** One settled question: the question as it was asked, the answer the person gave, the day. */
13
19
  export interface Decision { id: string; question: string; answer: string; date: string }
14
20
 
15
- export const OPEN_QUESTIONS_HEADER = ["| # | Severity | Question | Impact | Options |", "|---|---|---|---|---|"];
16
- export const DECISIONS_HEADER = ["| # | Question | Answer | Date |", "|---|---|---|---|"];
17
- /** The option a person picks to keep a question open; never written as an option of the file. */
18
- export const LEAVE_OPEN = "Leave it open";
19
- export const RECOMMENDED_MARK = " (recommended)";
20
21
  export const MAX_QUESTIONS = 12;
21
22
  export const MAX_OPTIONS = 4;
22
23
  const MAX_QUESTION_CHARS = 300;
@@ -102,9 +103,6 @@ function highest(ids: Iterable<string>): number {
102
103
  return max;
103
104
  }
104
105
 
105
- export const OPEN_QUESTIONS_HEADING = /^## .*Open questions/;
106
- export const DECISIONS_HEADING = /^## (\d+\. )?Decisions\s*$/;
107
-
108
106
  /** The open questions of a file, as written by questionRow or by hand: a row without a Q<n> id gets the next free
109
107
  * one, a severity other than Blocking reads Major, a row without a question is skipped. */
110
108
  export function parseOpenQuestions(text: string, taken: Iterable<string> = []): Question[] {
@@ -144,27 +142,47 @@ export const QUESTION_SCHEMA: object = {
144
142
  required: ["severity", "question", "impact", "options"],
145
143
  };
146
144
 
145
+ /**
146
+ * The options of a question as a model gave them, made to fit a row without a second call: each on one line, its
147
+ * ';' and '|' (the separators of the row) turned into commas, the empty ones, the repeats and LEAVE_OPEN (code adds
148
+ * it) dropped, MAX_OPTIONS kept. A question left with one option, or with one longer than a row holds, has none: it
149
+ * is asked as free text.
150
+ */
151
+ export function tidyOptions(options: readonly string[]): string[] {
152
+ const seen = new Set<string>();
153
+ const kept: string[] = [];
154
+ for (const raw of options) {
155
+ const option = raw.replace(/\s*[;|]\s*/g, ", ").replace(/\s+/g, " ").trim();
156
+ const key = option.toLowerCase();
157
+ if (option === "" || key === LEAVE_OPEN.toLowerCase() || seen.has(key)) continue;
158
+ seen.add(key);
159
+ kept.push(option);
160
+ }
161
+ if (kept.length < 2 || kept.some((o) => o.length > MAX_OPTION_CHARS)) return [];
162
+ return kept.slice(0, MAX_OPTIONS);
163
+ }
164
+
147
165
  /** What is wrong with question `k` of an answer: [] when it is one closed question fitting a row. */
148
166
  export function draftQuestionProblems(q: DraftQuestion, k: number): string[] {
149
167
  const problems: string[] = [];
150
- if (!QUESTION_SEVERITIES.includes(q.severity as QuestionSeverity)) problems.push(`question ${k}: severity must be Blocking or Major`);
168
+ if (!QUESTION_SEVERITIES.includes(q.severity as QuestionSeverity)) problems.push(severityMustBe(k));
151
169
  const text = q.question.trim();
152
170
  if (text === "" || breaksCell(text) || text.length > MAX_QUESTION_CHARS || !text.endsWith("?")) {
153
- problems.push(`question ${k}: one line of at most ${MAX_QUESTION_CHARS} characters ending with ?, no '|'`);
171
+ problems.push(questionOneLine(k, MAX_QUESTION_CHARS));
154
172
  }
155
- if (breaksCell(q.impact) || q.impact.length > MAX_CELL_CHARS) problems.push(`question ${k}: the impact is one line, no '|'`);
173
+ if (breaksCell(q.impact) || q.impact.length > MAX_CELL_CHARS) problems.push(impactOneLine(k));
156
174
  if (q.options.length === 1 || q.options.length > MAX_OPTIONS) {
157
- problems.push(`question ${k}: no option, or 2 to ${MAX_OPTIONS} options with the recommended one first`);
175
+ problems.push(optionCount(k, MAX_OPTIONS));
158
176
  }
159
177
  const seen = new Set<string>();
160
178
  for (const o of q.options) {
161
179
  const t = o.trim();
162
180
  if (t === "" || breaksCell(t) || t.includes(";") || t.length > MAX_OPTION_CHARS) {
163
- problems.push(`question ${k}: an option is one line of at most ${MAX_OPTION_CHARS} characters, no ';' nor '|'`);
181
+ problems.push(optionOneLine(k, MAX_OPTION_CHARS));
164
182
  break;
165
183
  }
166
- if (t.toLowerCase() === LEAVE_OPEN.toLowerCase()) { problems.push(`question ${k}: '${LEAVE_OPEN}' is not an option to list`); break; }
167
- if (seen.has(t.toLowerCase())) { problems.push(`question ${k}: two options read the same`); break; }
184
+ if (t.toLowerCase() === LEAVE_OPEN.toLowerCase()) { problems.push(notAnOptionToList(k, LEAVE_OPEN)); break; }
185
+ if (seen.has(t.toLowerCase())) { problems.push(twoOptionsSame(k)); break; }
168
186
  seen.add(t.toLowerCase());
169
187
  }
170
188
  return problems;
@@ -6,6 +6,10 @@
6
6
  import { parseYamlSubset } from "./yaml-subset.ts";
7
7
  import type { YamlError, YamlMap, YamlValue } from "./yaml-subset.ts";
8
8
  import { ruleTraitProblem, traitPatternProblem } from "./trait-pattern.ts";
9
+ import {
10
+ expectedMapping, expectedString, LIST_FOUND_MAPPING, listHolding, noRepositoryPack, PACK_NOT_A_MAPPING, packHasNo,
11
+ testsAlsoSourceRoot,
12
+ } from "./messages.ts";
9
13
 
10
14
  export interface RepoPackLayout {
11
15
  domain?: string; application?: string; infrastructure?: string; tests?: string; work?: string;
@@ -83,7 +87,7 @@ class Reader {
83
87
  if (!isMap(v)) {
84
88
  if (!this.reported.has(section)) {
85
89
  this.reported.add(section);
86
- this.issues.push({ key: section, message: `expected a mapping, found a ${kindOf(v)}` });
90
+ this.issues.push({ key: section, message: expectedMapping(kindOf(v)) });
87
91
  }
88
92
  return false;
89
93
  }
@@ -96,7 +100,7 @@ class Reader {
96
100
  const v = lookup(this.document, key);
97
101
  if (v === undefined || v === null) return undefined;
98
102
  if (Array.isArray(v) || isMap(v)) {
99
- this.issues.push({ key, message: `expected a string, found a ${kindOf(v)}` });
103
+ this.issues.push({ key, message: expectedString(kindOf(v)) });
100
104
  return undefined;
101
105
  }
102
106
  return String(v);
@@ -107,13 +111,13 @@ class Reader {
107
111
  const v = lookup(this.document, key);
108
112
  if (v === undefined || v === null) return [];
109
113
  if (isMap(v)) {
110
- this.issues.push({ key, message: "expected a list of strings, found a mapping" });
114
+ this.issues.push({ key, message: LIST_FOUND_MAPPING });
111
115
  return [];
112
116
  }
113
117
  if (!Array.isArray(v)) return [String(v)];
114
118
  const bad = v.find((item) => item === null || typeof item === "object");
115
119
  if (bad !== undefined) {
116
- this.issues.push({ key, message: `expected a list of strings, found a list holding a ${kindOf(bad)}` });
120
+ this.issues.push({ key, message: listHolding(kindOf(bad)) });
117
121
  return [];
118
122
  }
119
123
  return v.map((item) => String(item));
@@ -149,8 +153,7 @@ function checkTestsRoot(r: Reader, layout: RepoPackLayout): void {
149
153
  if (key === undefined) return;
150
154
  r.issues.push({
151
155
  key: "layout.tests",
152
- message: `'${tests}' is also layout.${key}: the test author and the implementer would both be refused that folder; ` +
153
- `drop layout.tests and name the test files with layout.test_files ("${tests}/*.test.ts")`,
156
+ message: testsAlsoSourceRoot(tests, key),
154
157
  });
155
158
  }
156
159
 
@@ -158,7 +161,7 @@ export function parseRepoPack(text: string): RepoPackParse {
158
161
  const parsed = parseYamlSubset(text);
159
162
  if (!parsed.ok) return parsed;
160
163
  const document = parsed.value;
161
- if (!isMap(document)) return { ok: false, error: { line: 1, message: "the pack is not a mapping" } };
164
+ if (!isMap(document)) return { ok: false, error: { line: 1, message: PACK_NOT_A_MAPPING } };
162
165
  const r = new Reader(document);
163
166
  const pack: RepoPack = {
164
167
  layout: {
@@ -232,6 +235,6 @@ export function packValue(pack: RepoPack, key: string): string | readonly string
232
235
 
233
236
  export function missingPackKeyLine(key: string, packShown: string | null): string {
234
237
  return packShown === null
235
- ? `no repository pack: add ${key} to .orkeon/repo.yaml`
236
- : `the repository pack ${packShown} has no ${key}: add it there`;
238
+ ? noRepositoryPack(key)
239
+ : packHasNo(packShown, key);
237
240
  }
@@ -2,16 +2,26 @@
2
2
  // check that turns the extraction into a ReviewAnswer or the list of what is wrong
3
3
  // with it. Pure, no IO. Only two severities exist: wording is never reported, so a
4
4
  // review has no Minor row. Each row targets what the caller says it may (in plan
5
- // mode the global plan or one of its batches) and cites where it comes from.
5
+ // mode the global plan or one of its batches) and cites where it comes from. Once re-asked, a row whose evidence
6
+ // still cites nothing is kept, marked NO_CITATION, rather than one row dropping the whole review (reviewChecks).
6
7
 
7
8
  import type { Checked } from "../agents/charter.ts";
9
+ import {
10
+ ANSWER_NOT_AN_OBJECT, atMostRows, NO_CITATION, QUESTION_EMPTY, QUESTION_NO_MARK, questionLongerThan, ROWS_MUST_BE_A_LIST,
11
+ rowEvidenceCitesNothing, rowEvidenceEmpty, rowOneClosedQuestion, rowRepeats, rowSeverityMustBe, rowTargetNotOneOf,
12
+ rowTwoTargets, VERDICT_CLEAR_OR_GAPS,
13
+ } from "./messages.ts";
8
14
 
9
15
  export type ReviewSeverity = "Blocking" | "Major";
10
16
  export interface ReviewRow { severity: ReviewSeverity; question: string; evidence: string; target: string }
11
17
  export interface ReviewAnswer { verdict: "CLEAR" | "GAPS"; rows: ReviewRow[] }
12
18
  /** What a row may target. Plan mode: ["plan", "F1", …, "Fn"]. A target is one of them, alone or followed by a
13
19
  * qualifier (`F2 (step 1)` is F2); one that names two of them is refused. */
14
- export interface ReviewCheckContext { targets: readonly string[] }
20
+ export interface ReviewCheckContext {
21
+ targets: readonly string[];
22
+ /** Keep a row whose evidence cites nothing, marked NO_CITATION, instead of refusing it (the last try). */
23
+ uncitedKept?: boolean;
24
+ }
15
25
 
16
26
  export const MAX_REVIEW_ROWS = 12;
17
27
  const MAX_QUESTION_CHARS = 300;
@@ -87,9 +97,9 @@ export function targetId(target: string, targets: readonly string[]): { id: stri
87
97
 
88
98
  /** Why a question is not one closed question fitting a table cell, or undefined when it is. */
89
99
  function questionFault(question: string): string | undefined {
90
- if (question === "") return "it is empty";
91
- if (question.length > MAX_QUESTION_CHARS) return `it is longer than ${MAX_QUESTION_CHARS} characters`;
92
- if (!question.endsWith("?")) return "it does not end with ?";
100
+ if (question === "") return QUESTION_EMPTY;
101
+ if (question.length > MAX_QUESTION_CHARS) return questionLongerThan(MAX_QUESTION_CHARS);
102
+ if (!question.endsWith("?")) return QUESTION_NO_MARK;
93
103
  return undefined;
94
104
  }
95
105
 
@@ -101,36 +111,39 @@ function checkRow(value: unknown, k: number, ctx: ReviewCheckContext, problems:
101
111
  const item = isPlainObject(value) ? value : {};
102
112
  const before = problems.length;
103
113
  const severity = text(item.severity);
104
- if (!SEVERITIES.includes(severity as ReviewSeverity)) problems.push(`row ${k}: severity must be Blocking or Major`);
114
+ if (!SEVERITIES.includes(severity as ReviewSeverity)) problems.push(rowSeverityMustBe(k));
105
115
  const question = cell(text(item.question));
106
116
  const fault = questionFault(question);
107
- if (fault !== undefined) problems.push(`row ${k}: the question must be one closed question ending with ? (${fault})`);
108
- const evidence = cell(text(item.evidence));
109
- if (evidence === "") problems.push(`row ${k}: evidence is empty`);
110
- else if (!citesSource(evidence)) problems.push(`row ${k}: evidence cites no path:line, § section or heading`);
117
+ if (fault !== undefined) problems.push(rowOneClosedQuestion(k, fault));
118
+ let evidence = cell(text(item.evidence));
119
+ if (evidence === "") problems.push(rowEvidenceEmpty(k));
120
+ else if (!citesSource(evidence)) {
121
+ if (ctx.uncitedKept === true) evidence = `${evidence} ${NO_CITATION}`;
122
+ else problems.push(rowEvidenceCitesNothing(k));
123
+ }
111
124
  const named = text(item.target);
112
125
  const target = targetId(named, ctx.targets);
113
- if (target === null) problems.push(`row ${k}: target '${named}' is not one of ${targetList(ctx.targets)}`);
114
- else if ("two" in target) problems.push(`row ${k}: target '${named}' names two targets`);
126
+ if (target === null) problems.push(rowTargetNotOneOf(k, named, targetList(ctx.targets)));
127
+ else if ("two" in target) problems.push(rowTwoTargets(k, named));
115
128
  if (problems.length > before || target === null || "two" in target) return undefined;
116
129
  return { severity: severity as ReviewSeverity, question, evidence, target: target.id };
117
130
  }
118
131
 
119
132
  export function checkReviewAnswer(value: unknown, ctx: ReviewCheckContext): Checked<ReviewAnswer> {
120
- if (!isPlainObject(value)) return { ok: false, problems: ["the answer is not an object"] };
133
+ if (!isPlainObject(value)) return { ok: false, problems: [ANSWER_NOT_AN_OBJECT] };
121
134
  const problems: string[] = [];
122
135
  const said = text(value.verdict);
123
- if (said !== "CLEAR" && said !== "GAPS") problems.push("verdict must be CLEAR or GAPS");
136
+ if (said !== "CLEAR" && said !== "GAPS") problems.push(VERDICT_CLEAR_OR_GAPS);
124
137
 
125
138
  const rows: ReviewRow[] = [];
126
139
  // The rows are the substance: the verdict follows them. A review that opens with "CLEAR" and then asks two
127
140
  // questions is GAPS, whatever word the extraction copied.
128
141
  let verdict: ReviewAnswer["verdict"] = said === "GAPS" ? "GAPS" : "CLEAR";
129
142
  if (!Array.isArray(value.rows)) {
130
- problems.push("rows must be a list");
143
+ problems.push(ROWS_MUST_BE_A_LIST);
131
144
  } else {
132
145
  verdict = value.rows.length > 0 ? "GAPS" : "CLEAR";
133
- if (value.rows.length > MAX_REVIEW_ROWS) problems.push(`at most ${MAX_REVIEW_ROWS} rows, not ${value.rows.length}`);
146
+ if (value.rows.length > MAX_REVIEW_ROWS) problems.push(atMostRows(MAX_REVIEW_ROWS, value.rows.length));
134
147
  const seen = new Map<string, number>();
135
148
  value.rows.forEach((item, i) => {
136
149
  const k = i + 1;
@@ -138,7 +151,7 @@ export function checkReviewAnswer(value: unknown, ctx: ReviewCheckContext): Chec
138
151
  const question = isPlainObject(item) ? text(item.question) : "";
139
152
  if (question !== "") {
140
153
  const first = seen.get(fold(question));
141
- if (first !== undefined) problems.push(`row ${k}: repeats row ${first}`);
154
+ if (first !== undefined) problems.push(rowRepeats(k, first));
142
155
  else seen.set(fold(question), k);
143
156
  }
144
157
  if (checked) rows.push(checked);
@@ -148,3 +161,13 @@ export function checkReviewAnswer(value: unknown, ctx: ReviewCheckContext): Chec
148
161
  if (problems.length > 0) return { ok: false, problems };
149
162
  return { ok: true, value: { verdict, rows } };
150
163
  }
164
+
165
+ /** The checks of a review over `targets`: the first try refuses an uncited row, the last one keeps it marked. */
166
+ export function reviewChecks(targets: readonly string[]): {
167
+ check: (value: unknown) => Checked<ReviewAnswer>; lastCheck: (value: unknown) => Checked<ReviewAnswer>;
168
+ } {
169
+ return {
170
+ check: (value) => checkReviewAnswer(value, { targets }),
171
+ lastCheck: (value) => checkReviewAnswer(value, { targets, uncitedKept: true }),
172
+ };
173
+ }
@@ -0,0 +1,54 @@
1
+ // The reviewer's brief and answer prompt, assembled: the carried texts fitted to their room, what the brief says
2
+ // is in it, the project list, the reply cut to its end. The wording is in ./prompts.ts.
3
+
4
+ import { carry } from "./carried-text.ts";
5
+ import type { CarriedText } from "./carried-text.ts";
6
+ import { projectFileLines } from "./project-files.ts";
7
+ import { earlierTextCut, reviewAnswerPrompt, reviewBrief } from "./prompts.ts";
8
+ import type { ReviewMode } from "./prompts.ts";
9
+
10
+ export const MAX_REVIEW_REPLY_CHARS = 12_000;
11
+
12
+ /** The most carried text a review brief holds, in characters (MAX_BRIEF_CHARS less the brief's own lines). */
13
+ export const CARRIED_REVIEW_CHARS = 18_000;
14
+
15
+ export interface ReviewBriefInput {
16
+ mode: ReviewMode;
17
+ /** The folder under review, relative ("workbench/prune"). */
18
+ folder: string;
19
+ /** The files to review, relative, in reading order. */
20
+ files: readonly string[];
21
+ /** The spec or brief the work was planned from, relative; for a spec or a brief, its origin ("" when none). */
22
+ source: string;
23
+ /** The inventory text: the plan's I<n> refs, the path:line rows of a spec or a brief. */
24
+ inventory: string;
25
+ /** What a row may target. */
26
+ targets: readonly string[];
27
+ /** Texts carried in the brief, each under its title (next-batch: the batch's sheet, then what each closed batch
28
+ * changed), so the reviewer opens no file for them; the whole room of CARRIED_REVIEW_CHARS for them. */
29
+ carried?: readonly CarriedText[];
30
+ /** The project's files (tracked and untracked, the work folder left out), listed so that the reviewer guesses no
31
+ * name; absent or empty: no list. */
32
+ projectFiles?: readonly string[];
33
+ }
34
+
35
+ export function buildReviewBrief(input: ReviewBriefInput): string {
36
+ const { blocks, whole } = carry(input.carried ?? [], CARRIED_REVIEW_CHARS);
37
+ return reviewBrief({
38
+ mode: input.mode,
39
+ folder: input.folder.endsWith("/") ? input.folder : `${input.folder}/`,
40
+ files: input.files,
41
+ filesInBrief: input.files.length > 0 && input.files.every((file) => whole.has(file)),
42
+ source: input.source,
43
+ sourceInBrief: whole.has(input.source),
44
+ inventory: input.inventory.trimEnd(),
45
+ blocks,
46
+ project: projectFileLines(input.projectFiles ?? []),
47
+ targets: input.targets,
48
+ });
49
+ }
50
+
51
+ export function buildReviewAnswerPrompt(reply: string, problems: readonly string[], targets: readonly string[]): string {
52
+ const text = reply.length > MAX_REVIEW_REPLY_CHARS ? earlierTextCut(reply.slice(-MAX_REVIEW_REPLY_CHARS)) : reply;
53
+ return reviewAnswerPrompt(text, problems, targets);
54
+ }
@@ -21,6 +21,10 @@ export const REVIEWER_CHARTER: Charter = {
21
21
  maxIterations: 20,
22
22
  };
23
23
 
24
+ /** The look-ups (tool calls) a review of a plan, a spec or a brief may make: past them every call is refused and the
25
+ * reviewer writes its findings, so that a review always concludes inside its charter's turns. */
26
+ export const REVIEWER_LOOKUPS = 16;
27
+
24
28
  /** The review of the next batch of /dev-batches: its brief carries the batch's sheet and what the closed batches
25
29
  * changed, so five read tools and eight turns are enough (a plan's review keeps the ten and its twenty); glob is one
26
30
  * of them, since its brief lists the project's files and a cut list sends the reader to it. */
@@ -2,6 +2,7 @@
2
2
  // `## TDD sequence`, the test methods of its step tables, its `Applied rules` row and its
3
3
  // `TDD:` lines. Line-based, as the harness's greps read the file. Pure.
4
4
  import { SHEET_ID_SOURCE } from "./trait-pattern.ts";
5
+ import { APPLIED_ROW, OPEN_BOX, TICKED_TDD_LINE } from "./markers.ts";
5
6
 
6
7
  export interface SheetFacts {
7
8
  ids: string[]; // ids of `## TDD sequence`, sorted, unique (AC:166)
@@ -12,9 +13,6 @@ export interface SheetFacts {
12
13
  closed: boolean; // check 1 (AC:119)
13
14
  }
14
15
 
15
- const TICKED = "TDD: RED [x] GREEN [x] COST [x]";
16
- const OPEN_BOX = /(RED|GREEN|COST) \[ \]/;
17
- const APPLIED_ROW = /^\| *Applied rules *\|/;
18
16
  const SEPARATOR_ROW = /^\|[-: |]+$/;
19
17
  const IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/;
20
18
 
@@ -71,7 +69,7 @@ export function sheetFacts(sheet: string): SheetFacts {
71
69
  const ids = unique(section.flatMap((l) => l.match(new RegExp(SHEET_ID_SOURCE, "g")) ?? [])).sort();
72
70
  const appliedRulesRow = lines.find((l) => APPLIED_ROW.test(l)) ?? null;
73
71
  const afterLabel = appliedRulesRow === null ? "" : appliedRulesRow.slice(appliedRulesRow.indexOf("Applied rules") + "Applied rules".length);
74
- const tickedLines = lines.filter((l) => l.includes(TICKED)).length;
72
+ const tickedLines = lines.filter((l) => l.includes(TICKED_TDD_LINE)).length;
75
73
  return {
76
74
  ids,
77
75
  methods: stepMethods(section),