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
@@ -2,6 +2,7 @@
2
2
  // line of that step only, nothing else of the sheet. Idempotent: a box already ticked stays.
3
3
  // Pure, never throws: what cannot be ticked comes back as a problem.
4
4
  import { parseBatchSheet } from "../../../shared/domain/dev/plan-format.ts";
5
+ import { notTheTddLine, sheetHasNoStep, stepHasNoTddLine, tddLineHasNoBox } from "./messages.ts";
5
6
 
6
7
  export type TddBox = "RED" | "GREEN" | "COST";
7
8
 
@@ -9,14 +10,14 @@ export type Ticked = { ok: true; text: string } | { ok: false; problem: string }
9
10
 
10
11
  export function tickBox(sheet: string, step: number, box: TddBox): Ticked {
11
12
  const found = parseBatchSheet(sheet).steps.find((s) => s.number === step);
12
- if (found === undefined) return { ok: false, problem: `the sheet has no step ${step}` };
13
- if (found.tdd === null) return { ok: false, problem: `step ${step} has no TDD line` };
13
+ if (found === undefined) return { ok: false, problem: sheetHasNoStep(step) };
14
+ if (found.tdd === null) return { ok: false, problem: stepHasNoTddLine(step) };
14
15
  const lines = sheet.split("\n");
15
16
  const at = found.tdd.line - 1;
16
17
  const line = lines[at] ?? "";
17
- if (!line.startsWith("TDD:")) return { ok: false, problem: `line ${found.tdd.line} is not step ${step}'s TDD line` };
18
+ if (!line.startsWith("TDD:")) return { ok: false, problem: notTheTddLine(found.tdd.line, step) };
18
19
  const box_ = new RegExp(`${box} \\[[ xX]\\]`);
19
- if (!box_.test(line)) return { ok: false, problem: `step ${step}'s TDD line has no ${box} box` };
20
+ if (!box_.test(line)) return { ok: false, problem: tddLineHasNoBox(step, box) };
20
21
  lines[at] = line.replace(new RegExp(`${box} \\[[ xX]\\]`), `${box} [x]`);
21
22
  return { ok: true, text: lines.join("\n") };
22
23
  }
@@ -2,6 +2,11 @@
2
2
  // paths the act changed (two snapshots of the tree), and the narrow test run code made after it.
3
3
  // RED holds when only test files changed and the tests fail; GREEN when no test file changed and
4
4
  // the tests pass. The implementer's Cost line is read here too. Pure.
5
+ import { NONE_WHERE } from "./markers.ts";
6
+ import {
7
+ GREEN_BY_ITSELF, NEW_TESTS_PASS_AT_ONCE, NO_COST_LINE, TEST_AUTHOR_CHANGED_NOTHING, TESTS_TIMED_OUT, noFailureAdded, onlyStubsChanged,
8
+ portCallInLoop, productionChangedBeforeRed, testFileChangedAtGreen, testsDidNotRun, testsStillFail,
9
+ } from "./messages.ts";
5
10
 
6
11
  /** A tree snapshot: path → hash of its content; null when the content was not read. */
7
12
  export type Snapshot = ReadonlyMap<string, string | null>;
@@ -47,21 +52,21 @@ export { under } from "../../../shared/domain/dev/test-paths.ts";
47
52
  export type IsTest = (path: string) => boolean;
48
53
 
49
54
  function runProblem(run: ObservedRun): string | null {
50
- if (!run.ran) return `the step's tests did not run: ${run.reason}`;
51
- if (run.timedOut) return "the step's tests timed out";
55
+ if (!run.ran) return testsDidNotRun(run.reason);
56
+ if (run.timedOut) return TESTS_TIMED_OUT;
52
57
  return null;
53
58
  }
54
59
 
55
60
  /** Why RED does not hold; null when it does. `stubs` are the production files the step marks `to create`, which
56
61
  * the test author may write as signature stubs. */
57
62
  export function redProblem(changed: readonly string[], isTest: IsTest, run: ObservedRun, stubs: readonly string[] = []): string | null {
58
- if (changed.length === 0) return "the test author changed no file";
63
+ if (changed.length === 0) return TEST_AUTHOR_CHANGED_NOTHING;
59
64
  const outside = changed.filter((p) => !isTest(p) && !stubs.includes(p));
60
- if (outside.length > 0) return `a production path changed before a red test: ${outside.join(", ")}`;
61
- if (!changed.some(isTest)) return `the test author changed no test file, only stubs: ${changed.join(", ")}`;
65
+ if (outside.length > 0) return productionChangedBeforeRed(outside);
66
+ if (!changed.some(isTest)) return onlyStubsChanged(changed);
62
67
  const problem = runProblem(run);
63
68
  if (problem !== null) return problem;
64
- if (run.ran && run.exit === 0) return "the new tests pass at once: a test green before its code is never kept";
69
+ if (run.ran && run.exit === 0) return NEW_TESTS_PASS_AT_ONCE;
65
70
  return null;
66
71
  }
67
72
 
@@ -89,19 +94,19 @@ export function addedFailure(beforeTail: string | number | null, afterTail: stri
89
94
  const after = failureCount(afterTail);
90
95
  if (before === null || after === null) return "unknown";
91
96
  if (after > before) return "ok";
92
- return { problem: `the new tests add no failure (failures ${before} → ${after}): a test green before its code is never kept` };
97
+ return { problem: noFailureAdded(before, after) };
93
98
  }
94
99
 
95
100
  /** Why GREEN does not hold; null when it does. `before` is code's run just before the act: tests that failed then
96
101
  * and pass now with no file changed turned green by themselves (flaky), which is never kept. */
97
102
  export function greenProblem(changed: readonly string[], isTest: IsTest, run: ObservedRun, before?: ObservedRun): string | null {
98
103
  const tests = changed.filter(isTest);
99
- if (tests.length > 0) return `a test file changed while turning it green: ${tests.join(", ")}`;
104
+ if (tests.length > 0) return testFileChangedAtGreen(tests);
100
105
  const problem = runProblem(run);
101
106
  if (problem !== null) return problem;
102
- if (run.ran && run.exit !== 0) return `the step's tests still fail (exit ${run.exit})`;
107
+ if (run.ran && run.exit !== 0) return testsStillFail(run.exit);
103
108
  if (changed.length === 0 && before?.ran === true && before.exit !== 0) {
104
- return "the implementer changed no file, yet the tests that failed before now pass: a test that turns green by itself is flaky";
109
+ return GREEN_BY_ITSELF;
105
110
  }
106
111
  return null;
107
112
  }
@@ -109,10 +114,6 @@ export function greenProblem(changed: readonly string[], isTest: IsTest, run: Ob
109
114
  export type CostRead = { ok: true; line: string } | { ok: false; problem: string; line?: string };
110
115
 
111
116
  const BLOCKING_ACCESS = /\b(loops?|lambdas?|memory filters?)\b/i;
112
- const PLACE = "(?:a |any |one )?(?:loops?|lambdas?|memory filters?)";
113
- /** The one "where" that clears a line naming a loop, a lambda or a memory filter: none of them holds a port call. */
114
- const NONE_WHERE = new RegExp(
115
- `^(?:none|nothing|no port call(?: (?:in|inside|within) ${PLACE}(?:,? (?:or |nor )?${PLACE})*)?)\\.?$`, "i");
116
117
  /** A none the model explains (`none — no port, no loop over a port call`): cleared unless the reason takes it back. */
117
118
  const NONE_EXPLAINED = /^(?:none|nothing)\s*(?:[—–:(]|-\s|,\s)/i;
118
119
  const TAKEN_BACK = /\b(?:but|except|however|apart from|save for)\b/i;
@@ -123,14 +124,14 @@ const clearsWhere = (where: string): boolean => NONE_WHERE.test(where) || (NONE_
123
124
  * loop`). */
124
125
  export function readCost(answer: string): CostRead {
125
126
  const match = /^\s*\**Cost\**\s*:\s*(.+)$/im.exec(answer);
126
- if (match === null) return { ok: false, problem: "the implementer stated no Cost line" };
127
+ if (match === null) return { ok: false, problem: NO_COST_LINE };
127
128
  const body = match[1].trim();
128
129
  const line = `Cost: ${body}`;
129
130
  const cut = body.indexOf(";");
130
131
  const counts = cut < 0 ? body : body.slice(0, cut);
131
132
  const where = cut < 0 ? "" : body.slice(cut + 1).trim();
132
133
  if (BLOCKING_ACCESS.test(counts) || (BLOCKING_ACCESS.test(where) && !clearsWhere(where))) {
133
- return { ok: false, problem: `a port call in a loop, a lambda or a memory filter: back to /dev-plan (${line})`, line };
134
+ return { ok: false, problem: portCallInLoop(line), line };
134
135
  }
135
136
  return { ok: true, line };
136
137
  }
@@ -4,6 +4,8 @@
4
4
  // plan-format's unfenced lines, as the sheet is written by /dev-plan. Pure, never throws.
5
5
  import { parseBatchSheet, unfencedLines } from "../../../shared/domain/dev/plan-format.ts";
6
6
  import type { TddTicks } from "../../../shared/domain/dev/plan-format.ts";
7
+ import { TEST_POLICY_SECTION } from "../../../shared/domain/dev/markers.ts";
8
+ import { anchorsRowNamesMissingStep, stepNamesNoTestFile, tddLineWithoutTest } from "./messages.ts";
7
9
 
8
10
  export interface StepTest { name: string; level: string; project: string; ids: string[] }
9
11
  /** One path of an Anchors cell: `to create`, `existing`, or the member it names; its line when given. */
@@ -75,7 +77,7 @@ export function parseImplementSheet(text: string): ImplementSheet {
75
77
  codeElements: section(lines, "Code elements").filter((l) => l.trim() !== ""),
76
78
  appliedRules: designRow(section(lines, "Design"), "Applied rules"),
77
79
  accessCost: designRow(section(lines, "Design"), "Access cost"),
78
- testPolicy: section(lines, "Test policy and scopes").filter((l) => l.trim() !== "").join("\n"),
80
+ testPolicy: section(lines, TEST_POLICY_SECTION).filter((l) => l.trim() !== "").join("\n"),
79
81
  problems: base.problems.map((p) => `line ${p.line}: ${p.message}`),
80
82
  };
81
83
  const ticks = new Map(base.steps.map((s) => [s.number, s.tdd]));
@@ -109,13 +111,13 @@ export function parseImplementSheet(text: string): ImplementSheet {
109
111
  const number = /^(\d+)\b/.exec(cells[0] ?? "");
110
112
  if (number === null || cells.length < 4) continue;
111
113
  const step = sheet.steps.find((s) => s.number === Number(number[1]));
112
- if (step === undefined) { sheet.problems.push(`an Anchors row names step ${number[1]}, which the sheet lacks`); continue; }
114
+ if (step === undefined) { sheet.problems.push(anchorsRowNamesMissingStep(number[1])); continue; }
113
115
  step.anchor = { testFiles: anchorRefs(cells[1]), doubles: cells[2] === "—" ? "" : cells[2], production: anchorRefs(cells[3]) };
114
116
  }
115
117
  for (const s of sheet.steps) {
116
- if (s.tdd !== null && s.tests.length === 0) sheet.problems.push(`step ${s.number} has a TDD line and no test`);
118
+ if (s.tdd !== null && s.tests.length === 0) sheet.problems.push(tddLineWithoutTest(s.number));
117
119
  if (s.tdd !== null && (s.anchor === null || s.anchor.testFiles.length === 0)) {
118
- sheet.problems.push(`step ${s.number} names no test file in ## Anchors`);
120
+ sheet.problems.push(stepNamesNoTestFile(s.number));
119
121
  }
120
122
  }
121
123
  return sheet;
@@ -0,0 +1,63 @@
1
+ // The learner's prompt for one axis fitted under its budget: the text of ./prompts.ts,
2
+ // the last rows cut until the head fits, then the owner lines of a re-ask cut from the
3
+ // end. One text, for one extract call. Pure.
4
+ import type { LearnRow } from "../../../shared/domain/shared-memory/verdict-rows.ts";
5
+ import { shortCell } from "../../../shared/domain/shared-memory/verdict-rows.ts";
6
+ import type { OwnerLinesBlock } from "../domain/owner-lines.ts";
7
+ import { ROWS_TABLE_HEAD, learnHead, ownerLinesPart } from "./prompts.ts";
8
+
9
+ export interface LearnPromptInput {
10
+ axis: string;
11
+ rows: readonly LearnRow[]; // the shown rows (≤ 40), oldest first
12
+ refused: readonly string[]; // "<topic> — <motif>" (Orkeon Code) and "<text>" (harness), each once
13
+ owners: readonly string[]; // repository guidance files that exist (§ 2.3), relative paths
14
+ }
15
+
16
+ /** One budget with the sub-agent briefs: MAX_BRIEF_CHARS of the charter. */
17
+ export const MAX_LEARN_PROMPT_CHARS = 24_000;
18
+ /** The room a re-ask keeps for its owner lines: 3 blocks of 8 lines cut at 160 characters under the longest harness
19
+ * destination (86 characters) need about 6 700. Its last rows are cut first to leave it. */
20
+ export const OWNER_LINES_RESERVE = 7_000;
21
+
22
+ const cell = (text: string, n: number): string => shortCell(text, n).replace(/\|/g, "/").replace(/\r\n|\r|\n/g, " ");
23
+
24
+ export function renderRowsTable(rows: readonly LearnRow[]): string {
25
+ return [
26
+ ...ROWS_TABLE_HEAD,
27
+ ...rows.map((r) =>
28
+ `| ${[cell(r.id, 20), cell(r.batch, 80), r.severity, cell(r.gap, 200), cell(r.evidence, 80), cell(r.fix, 120)].join(" | ")} |`),
29
+ ].join("\n");
30
+ }
31
+
32
+ /** The owner lines kept within the budget: the last line of the last block goes first. */
33
+ function fittedBlocks(blocks: readonly OwnerLinesBlock[], room: number): OwnerLinesBlock[] {
34
+ const kept = blocks.map((b) => ({ ...b, lines: [...b.lines] }));
35
+ const size = (): number => ownerLinesPart(kept).join("\n").length;
36
+ while (size() > room) {
37
+ const last = [...kept].reverse().find((b) => b.lines.length > 0);
38
+ if (!last) break;
39
+ last.lines.pop();
40
+ }
41
+ return kept;
42
+ }
43
+
44
+ function headOf(input: LearnPromptInput, problems: readonly string[]): string {
45
+ return learnHead({ axis: input.axis, table: renderRowsTable(input.rows), refused: input.refused, owners: input.owners }, problems);
46
+ }
47
+
48
+ /** ownerLines: on the re-ask, the owner lines code found for the problems. The last rows are cut until the head,
49
+ * problems included, fits MAX_LEARN_PROMPT_CHARS, less OWNER_LINES_RESERVE when owner lines are shown; the owner
50
+ * lines are then cut to stay within MAX_LEARN_PROMPT_CHARS. */
51
+ export function buildLearnPrompt(
52
+ input: LearnPromptInput, problems: readonly string[], ownerLines: readonly OwnerLinesBlock[] = [],
53
+ ): string {
54
+ const rows = [...input.rows];
55
+ let head = headOf(input, problems);
56
+ const room = MAX_LEARN_PROMPT_CHARS - (ownerLines.some((b) => b.lines.length > 0) ? OWNER_LINES_RESERVE : 0);
57
+ while (rows.length > 0 && head.length > room) {
58
+ rows.pop();
59
+ head = headOf({ ...input, rows }, problems);
60
+ }
61
+ const owned = ownerLinesPart(fittedBlocks(ownerLines, MAX_LEARN_PROMPT_CHARS - head.length - 1));
62
+ return owned.length === 0 ? head : [head, ...owned].join("\n");
63
+ }
@@ -0,0 +1,51 @@
1
+ // The messages of /dev-learn: its refusals, the lines of its listing and of its end message, the reasons of a motif
2
+ // code drops, the question of its decisions, and the words of its crew (ADR 0026).
3
+
4
+ // ── The crew ────────────────────────────────────────────────────────────
5
+
6
+ export const LEARNER_GOAL = "Turn the gaps that audits keep finding into a few preventive lines, each with its owner file.";
7
+
8
+ // ── Refusals ────────────────────────────────────────────────────────────
9
+
10
+ export const BAD_INPUT_AXIS = "dev-learn: bad input axis";
11
+ export const BAD_INPUT_LIST = "dev-learn: bad input list";
12
+ export const LEARN_NOT_IN_WORK_TREE = "dev-learn: not inside a git work tree";
13
+ export const notAtTop = (top: string, workspace: string): string =>
14
+ `dev-learn: the git work tree is ${top}, not ${workspace}: run Orkeon Code at the top of the repository`;
15
+
16
+ // ── The head line and the listing ───────────────────────────────────────
17
+
18
+ export const learnHead = (
19
+ label: string, gaps: number, batches: number, files: number, orkeon: number, harness: number, refused: number,
20
+ ): string =>
21
+ `dev-learn — work folder ${label} — ${gaps} untreated gaps across ` +
22
+ `${batches} batches in ${files} verdict files (treated: ` +
23
+ `${orkeon} by Orkeon Code, ${harness} by the harness; ` +
24
+ `refused motifs: ${refused})`;
25
+ export const nothingUntreatedOnAxis = (axis: string): string => `dev-learn: nothing untreated on axis ${axis}`;
26
+ export const NOTHING_UNTREATED = "dev-learn: nothing untreated";
27
+ export const AXIS_TABLE_HEADER = "axis gaps batches blocking";
28
+
29
+ // ── The model call and the filters ──────────────────────────────────────
30
+
31
+ export const REFUSED_IN_HARNESS = "refused in the harness's state";
32
+ export const REMOVED_LINE_KEPT = "its removed line is kept (harness refusal)";
33
+
34
+ // ── The end message ─────────────────────────────────────────────────────
35
+
36
+ export const axisUnchanged = (axis: string, since: string | undefined): string =>
37
+ `axis ${axis} — unchanged since ${since ?? "an earlier run"}: no call`;
38
+ export const motifsProposed = (head: string, count: number, ids: string, dropped: number): string =>
39
+ `${head}${count} motifs proposed (${ids}), ${dropped} dropped`;
40
+ export const noMotifKept = (head: string, dropped: number): string => `${head}no motif kept, ${dropped} dropped`;
41
+ export const decideQuestion = (axis: string, shown: string): string =>
42
+ `dev-learn — axis ${axis}: select the motifs to accept; the others are refused. ` +
43
+ `Decide later, or nothing selected, decides nothing (read ${shown} first)`;
44
+ export const underThreeBatches = (axis: string, batches: number): string =>
45
+ `axis ${axis} — ${batches} batches, under the 3 a motif needs: nothing to propose`;
46
+ export const noAxisEligible = (named: string): string =>
47
+ `dev-learn: no axis has untreated gaps in 3 batches or more (${named}): nothing written`;
48
+ export const noProposalOnAxis = (axis: string, problem: string): string => `dev-learn: axis ${axis}: no proposal (${problem})`;
49
+ export const proposalsWritten = (shown: string): string => `dev-learn: proposals written to ${shown}/`;
50
+ export const REFUSE_EACH = " or /dev-learn --refuse <id> for each one you reject — read the lines first in PROPOSALS.md";
51
+ export const NOTHING_TO_DECIDE_UNTIL_NEW_GAPS = "→ nothing to decide: the axes return once new gaps arrive";
@@ -1,10 +1,7 @@
1
- // The learner's prompt for one axis (ADR 0003): the instructions first, then the
2
- // material - the axis, its untreated rows as a table, the refused motifs, the
3
- // repository's guidance files and the harness destinations - and, on the re-ask, the
4
- // problems of the previous answer with the owner lines code found for them. One text,
5
- // for one extract call.
6
- import type { LearnRow } from "../../../shared/domain/shared-memory/verdict-rows.ts";
7
- import { shortCell } from "../../../shared/domain/shared-memory/verdict-rows.ts";
1
+ // The learner's prompt for one axis (ADR 0003): the instructions, the material - the
2
+ // axis, its untreated rows as a table, the refused motifs, the repository's guidance
3
+ // files and the harness destinations - the problems of a refused answer and the owner
4
+ // lines code found for them. Text only: ./learn-prompt-fit.ts fits it under its budget.
8
5
  import { MAX_LINES_PER_MOTIF, MAX_TOPIC_CHARS } from "../domain/learn-answer.ts";
9
6
  import type { OwnerLinesBlock } from "../domain/owner-lines.ts";
10
7
 
@@ -47,19 +44,14 @@ export const LEARN_INSTRUCTIONS: string = [
47
44
  "files listed or from a file the rows' evidence names.",
48
45
  ].join("\n");
49
46
 
50
- export interface LearnPromptInput {
47
+ /** The material of one axis as the prompt shows it, its rows already rendered as a table. */
48
+ export interface LearnMaterial {
51
49
  axis: string;
52
- rows: readonly LearnRow[]; // the shown rows (≤ 40), oldest first
53
- refused: readonly string[]; // "<topic> — <motif>" (Orkeon Code) and "<text>" (harness), each once
54
- owners: readonly string[]; // repository guidance files that exist (§ 2.3), relative paths
50
+ table: string;
51
+ refused: readonly string[];
52
+ owners: readonly string[];
55
53
  }
56
54
 
57
- /** One budget with the sub-agent briefs: MAX_BRIEF_CHARS of the charter. */
58
- export const MAX_LEARN_PROMPT_CHARS = 24_000;
59
- /** The room a re-ask keeps for its owner lines: 3 blocks of 8 lines cut at 160 characters under the longest harness
60
- * destination (86 characters) need about 6 700. Its last rows are cut first to leave it. */
61
- export const OWNER_LINES_RESERVE = 7_000;
62
-
63
55
  /** Where a harness owner may live, in the orkeon-workshop repository. */
64
56
  const HARNESS_DESTINATIONS: readonly string[] = [
65
57
  ".devcontainer/harness/packs/dev/claude/skills/dev-plan/references/plan-template.md",
@@ -69,43 +61,28 @@ const HARNESS_DESTINATIONS: readonly string[] = [
69
61
  ".devcontainer/harness/packs/repo-<name>/claude/rules/<file>",
70
62
  ];
71
63
 
72
- const cell = (text: string, n: number): string => shortCell(text, n).replace(/\|/g, "/").replace(/\r\n|\r|\n/g, " ");
73
-
74
- export function renderRowsTable(rows: readonly LearnRow[]): string {
75
- return [
76
- "| id | batch | severity | gap | evidence | fix |",
77
- "|---|---|---|---|---|---|",
78
- ...rows.map((r) =>
79
- `| ${[cell(r.id, 20), cell(r.batch, 80), r.severity, cell(r.gap, 200), cell(r.evidence, 80), cell(r.fix, 120)].join(" | ")} |`),
80
- ].join("\n");
81
- }
64
+ /** The head of the rows table: its columns, then its rule. */
65
+ export const ROWS_TABLE_HEAD: readonly string[] = [
66
+ "| id | batch | severity | gap | evidence | fix |",
67
+ "|---|---|---|---|---|---|",
68
+ ];
82
69
 
83
70
  const listed = (items: readonly string[]): string[] => (items.length === 0 ? ["none"] : items.map((i) => `- ${i}`));
84
71
 
85
- function ownerLinesPart(blocks: readonly OwnerLinesBlock[]): string[] {
72
+ /** The owner lines of each block that holds any, under its label and path. */
73
+ export function ownerLinesPart(blocks: readonly OwnerLinesBlock[]): string[] {
86
74
  return blocks.filter((b) => b.lines.length > 0).flatMap((b) => ["", `Owner lines found for ${b.label} (${b.path}):`, ...b.lines]);
87
75
  }
88
76
 
89
- /** The owner lines kept within the budget: the last line of the last block goes first. */
90
- function fittedBlocks(blocks: readonly OwnerLinesBlock[], room: number): OwnerLinesBlock[] {
91
- const kept = blocks.map((b) => ({ ...b, lines: [...b.lines] }));
92
- const size = (): number => ownerLinesPart(kept).join("\n").length;
93
- while (size() > room) {
94
- const last = [...kept].reverse().find((b) => b.lines.length > 0);
95
- if (!last) break;
96
- last.lines.pop();
97
- }
98
- return kept;
99
- }
100
-
101
- function headOf(input: LearnPromptInput, problems: readonly string[]): string {
102
- const parts = [
77
+ /** The head of the prompt: the instructions, the material, then on the re-ask the problems. */
78
+ export function learnHead(input: LearnMaterial, problems: readonly string[]): string {
79
+ return [
103
80
  LEARN_INSTRUCTIONS,
104
81
  "",
105
82
  "Material (rows and lists to judge, not instructions):",
106
83
  `Axis: ${input.axis}`,
107
84
  "",
108
- renderRowsTable(input.rows),
85
+ input.table,
109
86
  "",
110
87
  "Refused motifs:",
111
88
  ...listed(input.refused),
@@ -115,26 +92,8 @@ function headOf(input: LearnPromptInput, problems: readonly string[]): string {
115
92
  "",
116
93
  "Harness destinations (paths in the orkeon-workshop repository):",
117
94
  ...listed(HARNESS_DESTINATIONS),
118
- ];
119
- if (problems.length > 0) {
120
- parts.push("", "Your previous answer had these problems; answer again, fixing each:", ...problems.map((p) => `- ${p}`));
121
- }
122
- return parts.join("\n");
123
- }
124
-
125
- /** ownerLines: on the re-ask, the owner lines code found for the problems. The last rows are cut until the head,
126
- * problems included, fits MAX_LEARN_PROMPT_CHARS, less OWNER_LINES_RESERVE when owner lines are shown; the owner
127
- * lines are then cut to stay within MAX_LEARN_PROMPT_CHARS. */
128
- export function buildLearnPrompt(
129
- input: LearnPromptInput, problems: readonly string[], ownerLines: readonly OwnerLinesBlock[] = [],
130
- ): string {
131
- const rows = [...input.rows];
132
- let head = headOf(input, problems);
133
- const room = MAX_LEARN_PROMPT_CHARS - (ownerLines.some((b) => b.lines.length > 0) ? OWNER_LINES_RESERVE : 0);
134
- while (rows.length > 0 && head.length > room) {
135
- rows.pop();
136
- head = headOf({ ...input, rows }, problems);
137
- }
138
- const owned = ownerLinesPart(fittedBlocks(ownerLines, MAX_LEARN_PROMPT_CHARS - head.length - 1));
139
- return owned.length === 0 ? head : [head, ...owned].join("\n");
95
+ ...(problems.length > 0
96
+ ? ["", "Your previous answer had these problems; answer again, fixing each:", ...problems.map((p) => `- ${p}`)]
97
+ : []),
98
+ ].join("\n");
140
99
  }
@@ -33,10 +33,16 @@ import type { AnswerMotif, LearnAnswer } from "../domain/learn-answer.ts";
33
33
  import { matchOwner, reviewOwner } from "../domain/owner-lines.ts";
34
34
  import type { OwnerLinesBlock, OwnerReview } from "../domain/owner-lines.ts";
35
35
  import { renderProposals } from "../domain/proposals-render.ts";
36
- import { MAX_LEARN_PROMPT_CHARS, buildLearnPrompt } from "./learn-prompt.ts";
37
- import type { LearnPromptInput } from "./learn-prompt.ts";
36
+ import { MAX_LEARN_PROMPT_CHARS, buildLearnPrompt } from "./learn-prompt-fit.ts";
37
+ import type { LearnPromptInput } from "./learn-prompt-fit.ts";
38
38
  import { readBacklog } from "./learn-backlog.ts";
39
39
  import type { Backlog } from "./learn-backlog.ts";
40
+ import { AXIS_TABLE_HEADER, BAD_INPUT_AXIS, BAD_INPUT_LIST, NOTHING_TO_DECIDE_UNTIL_NEW_GAPS, NOTHING_UNTREATED, LEARN_NOT_IN_WORK_TREE, REFUSED_IN_HARNESS, REFUSE_EACH, REMOVED_LINE_KEPT, axisUnchanged, decideQuestion, learnHead, motifsProposed, noAxisEligible, noMotifKept, noProposalOnAxis, notAtTop, nothingUntreatedOnAxis, proposalsWritten, underThreeBatches } from "./messages.ts";
41
+ import { answerDidNotParse } from "../../../shared/application/agents/messages.ts";
42
+ import { errorText } from "../../../shared/domain/error-text.ts";
43
+ import {
44
+ learnBlockedNotWritten as blockedCannotWrite, learnNoWorkFolder as noWorkFolder, learnOutsideMounts as workFolderOutsideMounts,
45
+ } from "../../../shared/application/dev/messages.ts";
40
46
  import { WORKSPACE, workspaceRelative } from "../../../shared/domain/vfs.ts";
41
47
 
42
48
  export interface DevLearnInputs { axis?: unknown; list?: unknown }
@@ -88,11 +94,11 @@ function checkInputs(input: DevLearnInputs): Checked | string {
88
94
  let checkedAxis: string | null = null;
89
95
  if (axis !== undefined && axis !== null) {
90
96
  if (typeof axis !== "string" || axis.length < 1 || axis.length > 40 || /[|\r\n]/.test(axis)) {
91
- return "dev-learn: bad input axis";
97
+ return BAD_INPUT_AXIS;
92
98
  }
93
99
  checkedAxis = axis;
94
100
  }
95
- if (list !== undefined && typeof list !== "boolean") return "dev-learn: bad input list";
101
+ if (list !== undefined && typeof list !== "boolean") return BAD_INPUT_LIST;
96
102
  return { axis: checkedAxis, list: list === true };
97
103
  }
98
104
 
@@ -100,15 +106,15 @@ async function toplevelRefusal(shell: Pick<Shell, "run">): Promise<string | null
100
106
  let top: string;
101
107
  try {
102
108
  const r = await shell.run(GIT_TOPLEVEL);
103
- if (r.exitCode !== 0) return "dev-learn: not inside a git work tree";
109
+ if (r.exitCode !== 0) return LEARN_NOT_IN_WORK_TREE;
104
110
  top = r.stdout.trim();
105
111
  } catch {
106
- return "dev-learn: not inside a git work tree";
112
+ return LEARN_NOT_IN_WORK_TREE;
107
113
  }
108
- if (top === "") return "dev-learn: not inside a git work tree";
114
+ if (top === "") return LEARN_NOT_IN_WORK_TREE;
109
115
  return top === WORKSPACE
110
116
  ? null
111
- : `dev-learn: the git work tree is ${top}, not ${WORKSPACE}: run Orkeon Code at the top of the repository`;
117
+ : notAtTop(top, WORKSPACE);
112
118
  }
113
119
 
114
120
  function warningLines(warnings: readonly string[]): string[] {
@@ -126,10 +132,10 @@ function batchesOf(rows: readonly LearnRow[]): string[] {
126
132
  }
127
133
 
128
134
  function headLine(work: WorkFolder, packShown: string | null, backlog: Backlog): string {
129
- return `dev-learn — work folder ${workFolderLabel(work, packShown)} — ${backlog.untreated.length} untreated gaps across ` +
130
- `${batchesOf(backlog.untreated).length} batches in ${backlog.files} verdict files (treated: ` +
131
- `${backlog.orkeon.treated.length} by Orkeon Code, ${backlog.harness.treated.length} by the harness; ` +
132
- `refused motifs: ${refusedCount(backlog)})`;
135
+ return learnHead(
136
+ workFolderLabel(work, packShown), backlog.untreated.length, batchesOf(backlog.untreated).length, backlog.files,
137
+ backlog.orkeon.treated.length, backlog.harness.treated.length, refusedCount(backlog),
138
+ );
133
139
  }
134
140
 
135
141
  // ---- --list ----
@@ -142,11 +148,11 @@ function axisTableLine(a: AxisBacklog): string {
142
148
  function listLines(backlog: Backlog, axes: readonly AxisBacklog[], axis: string | null): string[] {
143
149
  if (axis !== null) {
144
150
  const rows = axes.flatMap((a) => a.rows);
145
- return rows.length === 0 ? [`dev-learn: nothing untreated on axis ${axis}`] : axisListing(rows);
151
+ return rows.length === 0 ? [nothingUntreatedOnAxis(axis)] : axisListing(rows);
146
152
  }
147
153
  const out = axes.length === 0
148
- ? ["dev-learn: nothing untreated"]
149
- : ["", "axis gaps batches blocking", ...axes.map(axisTableLine)];
154
+ ? [NOTHING_UNTREATED]
155
+ : ["", AXIS_TABLE_HEADER, ...axes.map(axisTableLine)];
150
156
  const refused = [
151
157
  ...backlog.refused.map((m) => `- ${m.topic} — ${m.motif}`),
152
158
  ...backlog.harness.refused.map((t) => `- ${t} (harness)`),
@@ -259,7 +265,7 @@ async function ask(
259
265
  value = await llm.extract(buildLearnPrompt(input, problems, blocks), LEARN_ANSWER_SCHEMA);
260
266
  } catch (error) {
261
267
  if (first !== null) return { ok: true, answer: first };
262
- problems = [`the answer did not parse: ${reasonOf(error)}`];
268
+ problems = [answerDidNotParse(errorText(error))];
263
269
  continue;
264
270
  }
265
271
  const checked = checkLearnAnswer(value, shownIds, blocks.some((b) => b.lines.length > 0));
@@ -309,12 +315,12 @@ function filterMotifs(
309
315
  continue;
310
316
  }
311
317
  if (harnessTexts.some((t) => foldText(t.trim()) === foldText(motif.title) || topicOf(t) === motif.topic)) {
312
- dropped.push({ title: motif.title, filter: "novelty", reason: "refused in the harness's state" });
318
+ dropped.push({ title: motif.title, filter: "novelty", reason: REFUSED_IN_HARNESS });
313
319
  continue;
314
320
  }
315
321
  const linesRemoved = motif.linesRemoved.filter((l) => !keptLines.includes(foldText(l.trim())));
316
322
  if (motif.status !== "new" && linesRemoved.length === 0) {
317
- dropped.push({ title: motif.title, filter: "novelty", reason: "its removed line is kept (harness refusal)" });
323
+ dropped.push({ title: motif.title, filter: "novelty", reason: REMOVED_LINE_KEPT });
318
324
  continue;
319
325
  }
320
326
  kept.push({ motif: { ...motif, linesRemoved }, batches, k: i + 1 });
@@ -376,12 +382,12 @@ function settleIds(axes: AxisProposal[]): void {
376
382
  }
377
383
 
378
384
  function axisOutcomeLine(a: AxisProposal): string {
379
- if (a.outcome === "unchanged") return `axis ${a.axis} — unchanged since ${a.reason ?? "an earlier run"}: no call`;
385
+ if (a.outcome === "unchanged") return axisUnchanged(a.axis, a.reason);
380
386
  const head = `axis ${a.axis} — ${a.batches} batches: `;
381
387
  if (a.outcome === "proposed") {
382
- return `${head}${a.motifs.length} motifs proposed (${a.motifs.map((m) => m.id).join(", ")}), ${a.dropped.length} dropped`;
388
+ return motifsProposed(head, a.motifs.length, a.motifs.map((m) => m.id).join(", "), a.dropped.length);
383
389
  }
384
- if (a.outcome === "no-motif") return `${head}no motif kept, ${a.dropped.length} dropped`;
390
+ if (a.outcome === "no-motif") return noMotifKept(head, a.dropped.length);
385
391
  return `${head}no proposal (${a.reason ?? "no answer"})`;
386
392
  }
387
393
 
@@ -404,8 +410,7 @@ async function askDecisions(
404
410
  if (axis.motifs.length === 0) continue;
405
411
  const byOption = new Map(axis.motifs.map((m) => [motifOption(m), m.id]));
406
412
  const answer = await human.multi(
407
- `dev-learn — axis ${axis.axis}: select the motifs to accept; the others are refused. ` +
408
- `Decide later, or nothing selected, decides nothing (read ${shown} first)`,
413
+ decideQuestion(axis.axis, shown),
409
414
  [...byOption.keys()],
410
415
  );
411
416
  if (!answer.answered) continue;
@@ -429,11 +434,11 @@ export async function runDevLearn(input: DevLearnInputs, deps: DevLearnDeps): Pr
429
434
  const work = ctx.work;
430
435
  if (work.vfsPath === null) {
431
436
  return [...warningLines(ctx.warnings),
432
- `dev-learn: the work folder ${work.folder} is in the main worktree, outside the mounts: run /dev-learn from the main checkout`,
437
+ workFolderOutsideMounts(work.folder),
433
438
  ].join("\n");
434
439
  }
435
440
  if (!work.exists) {
436
- return [...warningLines(ctx.warnings), `dev-learn: no work folder ${work.folder}/: nothing to learn from`].join("\n");
441
+ return [...warningLines(ctx.warnings), noWorkFolder(work.folder)].join("\n");
437
442
  }
438
443
 
439
444
  // refused.md under memory.dir, as /memory-admit and memory_push read it; a value set aside is said.
@@ -450,11 +455,11 @@ export async function runDevLearn(input: DevLearnInputs, deps: DevLearnDeps): Pr
450
455
  const eligible = axes.filter((a) => a.batches.length >= MIN_MOTIF_BATCHES);
451
456
  if (args.axis !== null && eligible.length === 0) {
452
457
  const b = axes[0]?.batches.length ?? 0;
453
- return done(`axis ${axes[0]?.axis ?? wanted} — ${b} batches, under the 3 a motif needs: nothing to propose`);
458
+ return done(underThreeBatches(`${axes[0]?.axis ?? wanted}`, b));
454
459
  }
455
460
  if (eligible.length === 0) {
456
461
  const named = axes.slice(0, MAX_AXES_NAMED).map((a) => `${a.axis} ${a.batches.length}`).join(", ");
457
- return done(`dev-learn: no axis has untreated gaps in 3 batches or more (${named === "" ? "none" : named}): nothing written`);
462
+ return done(noAxisEligible(named === "" ? "none" : named));
458
463
  }
459
464
 
460
465
  const handled = eligible.slice(0, MAX_AXES_PER_RUN);
@@ -487,7 +492,7 @@ export async function runDevLearn(input: DevLearnInputs, deps: DevLearnDeps): Pr
487
492
  if (!asked.ok) {
488
493
  proposal.outcome = "no-proposal";
489
494
  proposal.reason = asked.problem;
490
- deps.log.warn(`dev-learn: axis ${entry.axis}: no proposal (${asked.problem})`);
495
+ deps.log.warn(noProposalOnAxis(entry.axis, asked.problem));
491
496
  continue;
492
497
  }
493
498
  const { kept, dropped } = filterMotifs(asked.answer, rowsById, backlog);
@@ -528,9 +533,9 @@ export async function runDevLearn(input: DevLearnInputs, deps: DevLearnDeps): Pr
528
533
  } catch (error) {
529
534
  if (!(error instanceof WriteFailure)) throw error;
530
535
  const shown = workspaceRelative(error.path);
531
- return done(`dev-learn: BLOCKED — ${shown} cannot be written (${error.message})`);
536
+ return done(blockedCannotWrite(shown, error.message));
532
537
  }
533
- deps.log.info(`dev-learn: proposals written to ${work.folder}/${folder}/`);
538
+ deps.log.info(proposalsWritten(`${work.folder}/${folder}`));
534
539
 
535
540
  const lines = proposals.map(axisOutcomeLine);
536
541
  if (left.length > 0) lines.push(`next run: ${left.map((a) => a.axis).join(", ")}`);
@@ -544,10 +549,10 @@ export async function runDevLearn(input: DevLearnInputs, deps: DevLearnDeps): Pr
544
549
  if (ids.length > 0) {
545
550
  lines.push(
546
551
  `→ /dev-learn --accept ${ids.join(",")}`,
547
- " or /dev-learn --refuse <id> for each one you reject — read the lines first in PROPOSALS.md",
552
+ REFUSE_EACH,
548
553
  );
549
554
  } else if (decided.ids.size === 0) {
550
- lines.push("→ nothing to decide: the axes return once new gaps arrive");
555
+ lines.push(NOTHING_TO_DECIDE_UNTIL_NEW_GAPS);
551
556
  }
552
557
  return done(...lines);
553
558
  }
@@ -28,8 +28,9 @@ import {
28
28
  orkeonHumanInput,
29
29
  orkeonShell,
30
30
  } from "../../shared/infrastructure/orkeon/wiring.ts";
31
- import { createLlm } from "../../shared/infrastructure/orkeon/llm.ts";
31
+ import { agentLlm } from "../../shared/infrastructure/orkeon/llm.ts";
32
32
  import { runDevLearn } from "./application/run-dev-learn.ts";
33
+ import { LEARNER_GOAL } from "./application/messages.ts";
33
34
 
34
35
  const ports = { shell: orkeonShell(), files: orkeonFiles(), config: orkeonConfigStore(), human: orkeonHumanInput() };
35
36
 
@@ -38,9 +39,9 @@ const learner = orkeonAgent()
38
39
  .role("Recurring-gap analyst")
39
40
  // NO tools on purpose: one extract per axis, and every row it judges is in the prompt.
40
41
  .tools([])
41
- .goal("Turn the gaps that audits keep finding into a few preventive lines, each with its owner file.")
42
+ .goal(LEARNER_GOAL)
42
43
  .body(async (_input: any, ctx: any) =>
43
- await runDevLearn(inputs(), { ...ports, llm: createLlm(ctx.llm), log: ctx.log, clock: orkeonClock() }))
44
+ await runDevLearn(inputs(), { ...ports, llm: agentLlm(ctx), log: ctx.log, clock: orkeonClock() }))
44
45
  .build();
45
46
 
46
47
  publishCrew(