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
@@ -6,6 +6,7 @@
6
6
  import type { Shell } from "../ports.ts";
7
7
  import { readIdentity, runGit } from "../git/commit-files.ts";
8
8
  import { GIT_CURRENT_BRANCH_COMMAND, GIT_STATUS_COMMAND, changedPaths } from "../../domain/git/close.ts";
9
+ import { BRANCH_NONE, PLAN_NONE, SHEETS_OK, changesOutsideWorkFolder, identityMissing, identityOk, noSheetFor } from "./messages.ts";
9
10
 
10
11
  export interface PreflightInput {
11
12
  /** The plan as the user reads it, `workbench/demo/DEMO-PLAN.md`; null when the code has none. */
@@ -34,12 +35,12 @@ export async function preflight(deps: { shell: Pick<Shell, "run"> }, input: Pref
34
35
  let ok = true;
35
36
  const fail = (line: string): void => { ok = false; lines.push(`preflight ✗ ${line}`); };
36
37
 
37
- if (input.planShown === null) fail("plan: none in the code's folder: /dev-plan first");
38
+ if (input.planShown === null) fail(PLAN_NONE);
38
39
  else if (input.problems.length > 0) fail(`plan: ${input.problems.length} format problem(s): ${listed(input.problems)}`);
39
40
  else lines.push(`preflight ✓ plan: ${input.planShown} (${input.batches} batch(es))`);
40
41
 
41
- if (input.missingSheets.length > 0) fail(`sheets: no sheet for ${input.missingSheets.join(", ")}`);
42
- else lines.push("preflight ✓ sheets: one for every batch not done");
42
+ if (input.missingSheets.length > 0) fail(noSheetFor(input.missingSheets.join(", ")));
43
+ else lines.push(SHEETS_OK);
43
44
 
44
45
  if (!input.order.ok) fail(`order: ${input.order.problem}`);
45
46
  else lines.push(`preflight ✓ order: ${input.order.order.join(" → ") || "(no batch)"}`);
@@ -48,14 +49,13 @@ export async function preflight(deps: { shell: Pick<Shell, "run"> }, input: Pref
48
49
  // A Bubblewrap shell runs with HOME=/tmp and a cleared environment: only the repository's own
49
50
  // configuration reaches git there, so the hint names it.
50
51
  if (!identity.ok) {
51
- fail(`git identity: ${identity.detail} (each batch's close commits): git config user.name and user.email in the repository ` +
52
- "(a confined shell reads no --global file)");
52
+ fail(identityMissing(identity.detail));
53
53
  }
54
- else lines.push(`preflight ✓ git identity: ${identity.ident.name} <${identity.ident.email}>`);
54
+ else lines.push(identityOk(identity.ident.name, identity.ident.email));
55
55
 
56
56
  const branch = await runGit(deps.shell, GIT_CURRENT_BRANCH_COMMAND);
57
57
  const name = branch.exitCode === 0 ? branch.stdout.trim() : "";
58
- if (name === "") fail("branch: none checked out (a detached HEAD?): check out the work branch");
58
+ if (name === "") fail(BRANCH_NONE);
59
59
  else lines.push(`preflight ✓ branch: ${name}`);
60
60
 
61
61
  const status = await runGit(deps.shell, GIT_STATUS_COMMAND);
@@ -64,7 +64,7 @@ export async function preflight(deps: { shell: Pick<Shell, "run"> }, input: Pref
64
64
  const own = (p: string): boolean => p === work || p.startsWith(`${work}/`) || p.startsWith(".orkeon/");
65
65
  const others = changedPaths(status.stdout).filter((p) => !own(p));
66
66
  if (others.length > 0) {
67
- lines.push(`preflight ⚠ tree: ${others.length} change(s) outside the work folder (${listed(others)}): a close commits only its batch's files`);
67
+ lines.push(changesOutsideWorkFolder(others.length, listed(others)));
68
68
  }
69
69
  }
70
70
  return { ok, lines };
@@ -0,0 +1,34 @@
1
+ // The text the dev services hand to the model: the refusals of a tool call (the guard, the hooks, the budget, a
2
+ // restore), the notes on the access cost an auditor reads, and the inventory of a draft brief.
3
+
4
+ // tool-call-policy.ts, tool-callbacks.ts
5
+ export const MEMORY_GUARD = "refused by the shared memory's guard";
6
+ export const MEMORY_CONTEXT =
7
+ "The shared memory's candidates and entries are written by memory_push and /memory-admit only: do without this call.";
8
+ export const hookMountCheckDeny = (step: string, text: string): string =>
9
+ `${step}: ${text}\nThe call did not run: a hook's command line may name no path its ` +
10
+ "program may not write; ask the user to change the hook.";
11
+ export const hookRefusedDeny = (step: string, text: string): string =>
12
+ `${step}: refused by ${text}\nThe call did not run: change it, or ask the user to fix the hook.`;
13
+ export const callbackFailed = (step: string, reason: string): string => `${step}: the callback failed: ${reason}`;
14
+ export const memoryGuardFailed = (reason: string): string => `the shared memory's guard failed: ${reason}`;
15
+ export const mountCheckRefusedHook = (label: string, denial: string): string =>
16
+ `the runtime's mount check refused the command line of ${label}, which did not run: ${denial}`;
17
+
18
+ // spend.ts, wrapped-tools.ts
19
+ export const budgetSpent = (limit: number): string =>
20
+ `budget: this batch has spent its ${limit} tool calls; end the act and say what is left`;
21
+ export const lookupsSpent = (limit: number): string =>
22
+ `review: your ${limit} look-ups are spent; open nothing more and write your findings now, from what you read: ` +
23
+ "CLEAR, or each question with its severity, evidence and target";
24
+ export const noRoleRestores = (command: string): string => `'${command}' restores: no role restores, the step did it once`;
25
+
26
+ // measure-access-cost.ts
27
+ export const toolFailedJudgeFromDiff = (tool: string, reason: string): string =>
28
+ `${tool} failed (${reason}); judge the Cost axis from the diff`;
29
+ export const reindexErrorJudgeFromDiff = (error: string): string => `incremental_reindex: ${error}; judge the Cost axis from the diff`;
30
+ export const accessCostErrorJudgeFromDiff = (error: string): string => `access_cost: ${error}; judge the Cost axis from the diff`;
31
+ export const NO_READABLE_REPORT = "access_cost returned no readable report; judge the Cost axis from the diff";
32
+
33
+ // brief-inventory.ts
34
+ export const INDEX_FOUND_NOTHING = "(the index found nothing for this request)";
@@ -1,16 +1,20 @@
1
1
  // One round of questions on a written spec or change brief: the questions asked one at a time (settleQuestions),
2
2
  // the file's open-questions and decisions sections rewritten and written after each answer, then - when anything
3
- // was decided - one fold: the caller's model call rewrites the body with the decisions, and the folded file is
4
- // written. A fold that fails leaves the decisions recorded in their section and says so in a warning: an answer a
3
+ // was decided and the caller gave a fold - one fold: the caller's model call rewrites the body with the decisions,
4
+ // and the folded file is written (foldDecisions). A caller that gives none folds itself, once, when its rounds are
5
+ // over. A fold that fails leaves the decisions recorded in their section and says so in a warning: an answer a
5
6
  // person gave is never lost.
6
7
  import type { HumanInput } from "../ports.ts";
7
8
  import { withQuestionSections } from "../../domain/dev/questions.ts";
8
9
  import type { Decision, Question } from "../../domain/dev/questions.ts";
9
10
  import { settleQuestions } from "./settle-questions.ts";
11
+ import { REWRITE_REFUSED, decisionsNotFolded } from "./messages.ts";
10
12
 
11
13
  export interface RoundState { text: string; open: Question[]; decisions: Decision[] }
12
14
  export type Folded = { ok: true; text: string; open: Question[] } | { ok: false; problems: string[] };
13
15
 
16
+ export type Fold = (state: RoundState, fresh: readonly Decision[]) => Promise<Folded>;
17
+
14
18
  export interface RoundDeps {
15
19
  human: HumanInput;
16
20
  today: string;
@@ -19,8 +23,9 @@ export interface RoundDeps {
19
23
  /** The headings the two sections are written under ("## 12. Open questions", "## 13. Decisions"). */
20
24
  headings: { questions: string; decisions: string };
21
25
  write: (text: string) => Promise<void>;
22
- /** Rewrites the body with the decisions of the round; `open` are the questions still open. */
23
- fold: (state: RoundState, fresh: readonly Decision[]) => Promise<Folded>;
26
+ /** Rewrites the body with the decisions of the round; `open` are the questions still open. Absent: the round
27
+ * records the answers and rewrites nothing. */
28
+ fold?: Fold;
24
29
  }
25
30
 
26
31
  export interface RoundOutcome { state: RoundState; made: Decision[]; blocked: boolean; warnings: string[] }
@@ -36,17 +41,20 @@ export async function questionRound(
36
41
  await deps.write(text);
37
42
  },
38
43
  }, which);
39
- let next: RoundState = { text, open: settled.open, decisions: settled.decisions };
40
- const warnings: string[] = [];
41
- if (settled.made.length > 0) {
42
- const folded = await deps.fold(next, settled.made);
43
- if (folded.ok) {
44
- next = { ...next, text: folded.text, open: folded.open };
45
- await deps.write(folded.text);
46
- } else {
47
- warnings.push(`the body does not say the decisions yet (${folded.problems[0] ?? "the rewrite was refused"}); ` +
48
- "they are recorded under Decisions");
49
- }
50
- }
51
- return { state: next, made: settled.made, blocked: settled.blocked, warnings };
44
+ const next: RoundState = { text, open: settled.open, decisions: settled.decisions };
45
+ if (deps.fold === undefined) return { state: next, made: settled.made, blocked: settled.blocked, warnings: [] };
46
+ const folded = await foldDecisions(next, settled.made, deps.fold, deps.write);
47
+ return { state: folded.state, made: settled.made, blocked: settled.blocked, warnings: folded.warnings };
48
+ }
49
+
50
+ /** One fold of `made` into the body of `state`, the folded file written: nothing to do when nothing was decided, a
51
+ * warning and the state as it was when the rewrite is refused. */
52
+ export async function foldDecisions(
53
+ state: RoundState, made: readonly Decision[], fold: Fold, write: (text: string) => Promise<void>,
54
+ ): Promise<{ state: RoundState; warnings: string[] }> {
55
+ if (made.length === 0) return { state, warnings: [] };
56
+ const folded = await fold(state, made);
57
+ if (!folded.ok) return { state, warnings: [decisionsNotFolded(folded.problems[0] ?? REWRITE_REFUSED)] };
58
+ await write(folded.text);
59
+ return { state: { ...state, text: folded.text, open: folded.open }, warnings: [] };
52
60
  }
@@ -11,6 +11,7 @@ import {
11
11
  DEFAULT_WORK_FOLDER, isSamePath, mainWorktreeOf, normalizeWorkDir,
12
12
  } from "../../domain/dev/work-folder.ts";
13
13
  import { WORKSPACE } from "../../domain/vfs.ts";
14
+ import { absentFromCheckout, linkedWorktreeNote, notARelativeFolderFallback } from "./messages.ts";
14
15
 
15
16
  export const GIT_WORKTREE_LIST = "git worktree list --porcelain";
16
17
  export const GIT_TOPLEVEL = "git rev-parse --show-toplevel";
@@ -88,7 +89,7 @@ export async function resolveWorkFolder(
88
89
  const check = normalizeWorkDir(request.value);
89
90
  if (!check.ok) {
90
91
  return fallback("invalid",
91
- `${request.source} '${request.value}' is not a relative folder of the checkout (${check.reason}): ${DEFAULT_WORK_FOLDER}/ applies`);
92
+ notARelativeFolderFallback(request.source, request.value, check.reason, DEFAULT_WORK_FOLDER));
92
93
  }
93
94
  const value = check.folder;
94
95
  if (value === "") return fallback("default", null);
@@ -101,7 +102,7 @@ export async function resolveWorkFolder(
101
102
  return { folder: value, vfsPath, outcome: "applied", request, exists: true, note: null };
102
103
  }
103
104
 
104
- const absentNote = `${request.source} '${value}' is absent from the checkout: ${DEFAULT_WORK_FOLDER}/ applies`;
105
+ const absentNote = absentFromCheckout(request.source, value, DEFAULT_WORK_FOLDER);
105
106
  const porcelain = await gitStdout(deps.shell, GIT_WORKTREE_LIST);
106
107
  const toplevel = await gitStdout(deps.shell, GIT_TOPLEVEL);
107
108
  const main = porcelain === null ? null : mainWorktreeOf(porcelain);
@@ -118,7 +119,7 @@ export async function resolveWorkFolder(
118
119
  outcome: "main-worktree",
119
120
  request,
120
121
  exists: true,
121
- note: `this checkout is a linked worktree: the work folder is the main worktree's ${folder}`,
122
+ note: linkedWorktreeNote(folder),
122
123
  };
123
124
  }
124
125
 
@@ -4,8 +4,10 @@
4
4
  // before the next question is asked. When nobody answers (an unattended run, an empty text) the asking stops at
5
5
  // once: nothing is decided on anyone's behalf, the questions stay in the file and the step reads BLOCKED.
6
6
  import type { HumanInput } from "../ports.ts";
7
- import { LEAVE_OPEN, askingOrder, decide, questionPrompt } from "../../domain/dev/questions.ts";
7
+ import { askingOrder, decide, questionPrompt } from "../../domain/dev/questions.ts";
8
+ import { LEAVE_OPEN } from "../../domain/dev/markers.ts";
8
9
  import type { Decision, Question } from "../../domain/dev/questions.ts";
10
+ import { EMPTY_ANSWER_LEAVES_OPEN } from "./messages.ts";
9
11
 
10
12
  export interface SettleDeps {
11
13
  human: HumanInput;
@@ -40,7 +42,7 @@ export async function settleQuestions(
40
42
  if (!r.answered) return { open: left, decisions: all, made, blocked: true };
41
43
  answer = r.value === LEAVE_OPEN ? null : r.value;
42
44
  } else {
43
- const r = await deps.human.text(`${prompt}\n(an empty answer leaves the questions in the file)`);
45
+ const r = await deps.human.text(`${prompt}${EMPTY_ANSWER_LEAVES_OPEN}`);
44
46
  if (!r.answered) return { open: left, decisions: all, made, blocked: true };
45
47
  answer = r.value;
46
48
  }
@@ -1,14 +1,17 @@
1
1
  // The read-only review of a written spec or change brief, once per run: the reviewer's sub-agent questions the
2
2
  // file, and its rows join the open questions (a row asking what an open question or a decision already holds is
3
3
  // not added), the file written again. The rows' ids are returned so the caller asks the Blocking ones.
4
- import type { Llm } from "../ports.ts";
4
+ import type { Llm, Logger } from "../ports.ts";
5
5
  import { runSubAgent } from "../agents/run-sub-agent.ts";
6
+ import type { ActRoute } from "../agents/route-agent.ts";
6
7
  import { REVIEWER_CHARTER } from "../../domain/dev/reviewer-charter.ts";
7
- import { REVIEW_ANSWER_SCHEMA, checkReviewAnswer } from "../../domain/dev/review-answer.ts";
8
+ import { REVIEW_ANSWER_SCHEMA, reviewChecks } from "../../domain/dev/review-answer.ts";
8
9
  import type { ReviewAnswer } from "../../domain/dev/review-answer.ts";
9
- import { buildReviewAnswerPrompt, buildReviewBrief, reviewSystem } from "../../domain/dev/review-prompt.ts";
10
+ import { reviewSystem } from "../../domain/dev/prompts.ts";
11
+ import { buildReviewAnswerPrompt, buildReviewBrief } from "../../domain/dev/review-brief.ts";
10
12
  import { numberQuestions, reviewDrafts, withQuestionSections } from "../../domain/dev/questions.ts";
11
13
  import type { RoundState } from "./question-round.ts";
14
+ import { addedAsOpenQuestions, reviewCounts, reviewNotRun } from "./messages.ts";
12
15
 
13
16
  export interface SourceReviewRequest {
14
17
  mode: "spec" | "change";
@@ -28,6 +31,7 @@ export type SourceReviewOutcome =
28
31
 
29
32
  export async function reviewSource(
30
33
  llm: Pick<Llm, "act" | "extract">, state: RoundState, request: SourceReviewRequest, write: (text: string) => Promise<void>,
34
+ route?: ActRoute, log?: Pick<Logger, "info">,
31
35
  ): Promise<SourceReviewOutcome> {
32
36
  const targets = [request.whole, ...request.ids];
33
37
  const outcome = await runSubAgent(llm, {
@@ -39,8 +43,8 @@ export async function reviewSource(
39
43
  }),
40
44
  schema: REVIEW_ANSWER_SCHEMA,
41
45
  answerPrompt: (reply, problems) => buildReviewAnswerPrompt(reply, problems, targets),
42
- check: (v) => checkReviewAnswer(v, { targets }),
43
- });
46
+ ...reviewChecks(targets),
47
+ }, route, log);
44
48
  if (!outcome.ok) return { ran: false, reason: `${outcome.reason}: ${outcome.problems[0] ?? "no detail"}` };
45
49
  const review = outcome.value;
46
50
  if (review.rows.length === 0) return { ran: true, review, state, added: [] };
@@ -54,10 +58,10 @@ export async function reviewSource(
54
58
  }
55
59
 
56
60
  export function reviewLine(outcome: SourceReviewOutcome): string {
57
- if (!outcome.ran) return `review: not run (${outcome.reason})`;
61
+ if (!outcome.ran) return reviewNotRun(outcome.reason);
58
62
  const rows = outcome.review.rows;
59
63
  if (rows.length === 0) return `review: ${outcome.review.verdict}`;
60
64
  const blocking = rows.filter((r) => r.severity === "Blocking").length;
61
- const kept = outcome.added.length === rows.length ? "" : `, ${outcome.added.length} added as open questions`;
62
- return `review: ${outcome.review.verdict} — ${blocking} Blocking, ${rows.length - blocking} Major${kept}`;
65
+ const kept = outcome.added.length === rows.length ? "" : addedAsOpenQuestions(outcome.added.length);
66
+ return reviewCounts(outcome.review.verdict, blocking, rows.length - blocking, kept);
63
67
  }
@@ -10,6 +10,8 @@ import type { Decision, Question } from "../../domain/dev/questions.ts";
10
10
  import { parsePlanSource } from "../../domain/dev/spec-format.ts";
11
11
  import type { SourceKind } from "../../domain/dev/spec-format.ts";
12
12
  import { WORKSPACE } from "../../domain/vfs.ts";
13
+ import { DECISIONS_DO_NOT_READ_BACK, NO_WORK_TREE, idsReadBack, invalidCode, invalidInput, openQuestionsReadBack, outsideCheckout, runFromCheckout, titleDoesNotReadCode, workFolderOutsideCheckoutMounts } from "./messages.ts";
14
+ import { prefixedCannotBeRead as stepCannotRead } from "../messages.ts";
13
15
 
14
16
  export const MAX_CODE_CHARS = 64;
15
17
  export const MAX_REQUEST_CHARS = 20_000;
@@ -54,14 +56,14 @@ export function problemLines(problems: readonly string[]): string[] {
54
56
 
55
57
  /** The code of the inputs, or the refusal. */
56
58
  export function inputCode(step: string, value: unknown): string | { refused: string } {
57
- if (typeof value !== "string" || value.length > MAX_CODE_CHARS || !isCode(value)) return { refused: `${step}: invalid crew input: code` };
59
+ if (typeof value !== "string" || value.length > MAX_CODE_CHARS || !isCode(value)) return { refused: invalidCode(step) };
58
60
  return value;
59
61
  }
60
62
 
61
63
  /** A free text input: "" when absent, the refusal when it is not a string or too long. */
62
64
  export function inputText(step: string, name: string, value: unknown): string | { refused: string } {
63
65
  if (value === undefined || value === null) return "";
64
- if (typeof value !== "string" || value.length > MAX_REQUEST_CHARS) return { refused: `${step}: invalid crew input: ${name}` };
66
+ if (typeof value !== "string" || value.length > MAX_REQUEST_CHARS) return { refused: invalidInput(step, name) };
65
67
  return value.trim();
66
68
  }
67
69
 
@@ -74,7 +76,7 @@ export async function toplevelRefusal(step: string, shell: Pick<Shell, "run">):
74
76
  top = "";
75
77
  }
76
78
  if (top === WORKSPACE) return null;
77
- return `${step}: run from the checkout at ${WORKSPACE} (git reports ${top === "" ? "no work tree" : top})`;
79
+ return runFromCheckout(step, WORKSPACE, top === "" ? NO_WORK_TREE : top);
78
80
  }
79
81
 
80
82
  export interface CodeFolder {
@@ -89,7 +91,7 @@ export interface CodeFolder {
89
91
  /** The code's folder under the work folder and the names it holds ([] when it does not exist yet). */
90
92
  export async function codeFolder(step: string, files: Pick<Files, "list">, work: WorkFolder, code: string): Promise<CodeFolder | { refused: string }> {
91
93
  if (work.vfsPath === null) {
92
- return { refused: `${step}: the work folder ${work.folder} is outside the checkout's mounts: run from the main worktree` };
94
+ return { refused: workFolderOutsideCheckoutMounts(step, work.folder) };
93
95
  }
94
96
  const vfs = `${work.vfsPath}/${code}`;
95
97
  const shown = `${work.folder}/${code}`;
@@ -110,14 +112,14 @@ export async function readRequest(step: string, files: Pick<Files, "read">, requ
110
112
  if (!PATH_TOKEN.test(request)) return { text: request, from: "" };
111
113
  const relative = request.startsWith(`${WORKSPACE}/`) ? request.slice(WORKSPACE.length + 1) : request.replace(/^\.\//, "");
112
114
  if (relative.startsWith("/") || relative.split("/").includes("..")) {
113
- return { refused: `${step}: ${request} is outside the checkout: give a path under ${WORKSPACE}` };
115
+ return { refused: outsideCheckout(step, request, WORKSPACE) };
114
116
  }
115
117
  try {
116
118
  const text = await files.read(`${WORKSPACE}/${relative}`, MAX_REQUEST_CHARS);
117
119
  if (text.trim() === "") return { refused: `${step}: ${relative} is empty` };
118
120
  return { text, from: relative };
119
121
  } catch (e) {
120
- return { refused: `${step}: ${relative} cannot be read (${firstLine(e)})` };
122
+ return { refused: stepCannotRead(step, relative, firstLine(e)) };
121
123
  }
122
124
  }
123
125
 
@@ -130,15 +132,15 @@ export function sourceSelfCheck(
130
132
  ): string[] {
131
133
  const parsed = parsePlanSource(text, kind);
132
134
  const problems = parsed.problems.map((p) => `line ${p.line}: ${p.message}`);
133
- if (parsed.code !== expect.code) problems.push(`the title does not read the code ${expect.code}`);
135
+ if (parsed.code !== expect.code) problems.push(titleDoesNotReadCode(expect.code));
134
136
  const read = parsed.ids.map((i) => i.id).join(",");
135
137
  if (read !== expect.ids.join(",")) {
136
- problems.push(`the ids read back are ${read || "none"}, not ${expect.ids.join(",")}`);
138
+ problems.push(idsReadBack(read || "none", expect.ids.join(",")));
137
139
  }
138
140
  if (parsed.openQuestions.length !== expect.open.length) {
139
- problems.push(`${parsed.openQuestions.length} open questions read back, ${expect.open.length} written`);
141
+ problems.push(openQuestionsReadBack(parsed.openQuestions.length, expect.open.length));
140
142
  }
141
- if (parseDecisions(text).length !== expect.decisions.length) problems.push("the decisions do not read back");
143
+ if (parseDecisions(text).length !== expect.decisions.length) problems.push(DECISIONS_DO_NOT_READ_BACK);
142
144
  return problems;
143
145
  }
144
146
 
@@ -1,9 +1,12 @@
1
1
  // A batch's budget of tool calls: the runtime gives a delegated agent no budget (L8P-D12), so a parallel
2
2
  // /dev-batches' batch agent counts its own calls and its callbacks refuse every call past the bound.
3
3
  import type { ToolCallbacks } from "./tool-callbacks.ts";
4
+ import { REVIEWER_LOOKUPS } from "../../domain/dev/reviewer-charter.ts";
5
+ import { budgetSpent, lookupsSpent } from "./prompts.ts";
4
6
 
5
7
  /** A batch's tool calls: counted, and refused once `limit` is reached. A call to a tool the act does not offer is
6
- * refused by the runtime before `onToolCall` (Orkeon #193): it costs nothing here, the act's `maxIterations` bounds it. */
8
+ * refused by the runtime before `onToolCall` (Orkeon #193): it costs nothing here, the act's `maxIterations` bounds it.
9
+ * A call the host's gate refuses is counted: the gate judges after `onToolCall` (Orkeon #303). */
7
10
  export interface Spend {
8
11
  readonly limit: number;
9
12
  calls(): number;
@@ -24,8 +27,11 @@ export function createSpend(limit: number): Spend {
24
27
  };
25
28
  }
26
29
 
27
- /** `callbacks` denying every call past the spend's limit; `callbacks` themselves without a spend. */
28
- export function spendGuard<C extends Pick<ToolCallbacks, "forAct">>(callbacks: C, spend: Spend | undefined): C {
30
+ /** `callbacks` denying every call past the spend's limit with what `spent` says of it (a batch's budget when not
31
+ * given); `callbacks` themselves without a spend. */
32
+ export function spendGuard<C extends Pick<ToolCallbacks, "forAct">>(
33
+ callbacks: C, spend: Spend | undefined, spent: (limit: number) => string = budgetSpent,
34
+ ): C {
29
35
  if (spend === undefined) return callbacks;
30
36
  return {
31
37
  ...callbacks,
@@ -35,8 +41,15 @@ export function spendGuard<C extends Pick<ToolCallbacks, "forAct">>(callbacks: C
35
41
  ...inner,
36
42
  onToolCall: async (call) => (spend.take()
37
43
  ? inner.onToolCall(call)
38
- : { deny: `budget: this batch has spent its ${spend.limit} tool calls; end the act and say what is left` }),
44
+ : { deny: spent(spend.limit) }),
39
45
  };
40
46
  },
41
47
  };
42
48
  }
49
+
50
+ /** The callbacks of one act of the reviewer of a plan, a spec or a brief: `callbacks` under a fresh spend of
51
+ * REVIEWER_LOOKUPS calls, a call past it refused with the order to write the findings. One spend per act: call it
52
+ * once for each. */
53
+ export function reviewerCallbacks<C extends Pick<ToolCallbacks, "forAct">>(callbacks: C): C {
54
+ return spendGuard(callbacks, createSpend(REVIEWER_LOOKUPS), lookupsSpent);
55
+ }
@@ -11,6 +11,7 @@ import { buildPrecedentsBlock } from "../../domain/shared-memory/precedents-bloc
11
11
  import { recallEntries } from "../shared-memory/recall-precedents.ts";
12
12
  import { readMemorySettings } from "../shared-memory/memory-settings.ts";
13
13
  import type { MemorySettings } from "../shared-memory/memory-settings.ts";
14
+ import { namedRecallFailed } from "./messages.ts";
14
15
 
15
16
  /** T1 spec or change start, T2 plan start, T3 before a batch's red tests, T4 before the audit, T5 a correction. */
16
17
  export type RecallTrigger = "T1" | "T2" | "T3" | "T4" | "T5";
@@ -76,7 +77,7 @@ export function stepPrecedents(deps: StepPrecedentsDeps, options: { on: boolean
76
77
  return block === "" ? NOTHING_RECALLED : { block, ids: recall.precedents.map((p) => p.entry.id) };
77
78
  } catch (error) {
78
79
  settings = null; // a failed read is tried again at the next trigger, not kept for the run
79
- deps.log.warn(`shared memory: recall ${trigger} failed, no precedents (${firstLine(error)})`);
80
+ deps.log.warn(namedRecallFailed(trigger, firstLine(error)));
80
81
  return NOTHING_RECALLED;
81
82
  }
82
83
  };
@@ -1,4 +1,4 @@
1
- // What a dev crew's onToolCall decides for one call the host's gate allowed, over probes the callbacks build
1
+ // What a dev crew's onToolCall decides for one call, before the host's gate judges it, over probes the callbacks build
2
2
  // (tool-callbacks.ts): the path resolved under the checkout first, then the shared memory's guard, then the crew's
3
3
  // guard (shared/domain/dev/call-guard.ts) told whether a file_write under a rewrite rule names a new file, then the
4
4
  // pre-tool hooks, stopped at the first that fails. It holds the order and the refusals' texts; what the probes read
@@ -9,6 +9,8 @@ import { resolvePathInput } from "../../domain/dev/path-args.ts";
9
9
  import { REWRITE_TOOL } from "../../domain/agent-policy/rule-sets.ts";
10
10
  import { sameToolName } from "../../domain/agent-policy/permission.ts";
11
11
  import { memoryWriteRefusal } from "../../domain/shared-memory/layout.ts";
12
+ import { MEMORY_CONTEXT, MEMORY_GUARD, callbackFailed, hookMountCheckDeny, hookRefusedDeny } from "./prompts.ts";
13
+ import { mountCheckRefusedPreHook, preHookRefused, relativePathResolved } from "./messages.ts";
12
14
 
13
15
  /** The runtime's verdict and result callbacks, as ActOptions types them (the subset the callbacks return): allow,
14
16
  * deny, or allow with the call's input rewritten (a relative path resolved). */
@@ -31,9 +33,6 @@ export interface CallProbes {
31
33
  /** The verdict, and the lines the callbacks log for it (at info). */
32
34
  export interface CallJudgement { verdict: ToolCallVerdict; notes: string[] }
33
35
 
34
- const MEMORY_GUARD = "refused by the shared memory's guard";
35
- const MEMORY_CONTEXT = "The shared memory's candidates and entries are written by memory_push and /memory-admit only: do without this call.";
36
-
37
36
  /** The refusal of a write into the shared memory, `why` its reason (memoryWriteRefusal), without a step's name. */
38
37
  export function memoryDenyText(why: string): string {
39
38
  return `${MEMORY_GUARD}: ${why}\n${MEMORY_CONTEXT}`;
@@ -42,9 +41,8 @@ export function memoryDenyText(why: string): string {
42
41
  /** The refusal of a call a pre-tool hook stopped, led by the step's name. */
43
42
  function hookDenyText(step: string, failure: HookFailure): string {
44
43
  return failure.by === "mount-check"
45
- ? `${step}: ${failure.text}\nThe call did not run: a hook's command line may name no path its ` +
46
- "program may not write; ask the user to change the hook."
47
- : `${step}: refused by ${failure.text}\nThe call did not run: change it, or ask the user to fix the hook.`;
44
+ ? hookMountCheckDeny(step, failure.text)
45
+ : hookRefusedDeny(step, failure.text);
48
46
  }
49
47
 
50
48
  export async function judgeToolCall(
@@ -58,7 +56,7 @@ export async function judgeToolCall(
58
56
  // (the runtime would resolve it too, after the guard: too late for the rules and the hooks).
59
57
  const resolved = resolvePathInput(call.name, call.input);
60
58
  const input = resolved ?? call.input;
61
- if (resolved !== null) notes.push(`${guard.step}: ${call.name}: a relative path resolved under the checkout`);
59
+ if (resolved !== null) notes.push(relativePathResolved(guard.step, call.name));
62
60
  const dir = await probes.memoryDir();
63
61
  const memory = dir === null ? null : memoryWriteRefusal(dir, call.name, input);
64
62
  if (memory !== null) {
@@ -78,12 +76,12 @@ export async function judgeToolCall(
78
76
  const failed = await probes.runHook(hook, call.name, input);
79
77
  if (failed === undefined) continue;
80
78
  notes.push(failed.by === "mount-check"
81
- ? `${guard.step}: the runtime's mount check refused pre-tool hook #${hook.n} for ${call.name}`
82
- : `${guard.step}: pre-tool hook #${hook.n} refused ${call.name}`);
79
+ ? mountCheckRefusedPreHook(guard.step, hook.n, call.name)
80
+ : preHookRefused(guard.step, hook.n, call.name));
83
81
  return judged({ deny: hookDenyText(guard.step, failed) });
84
82
  }
85
83
  return judged(resolved === null ? "allow" : { input: resolved });
86
84
  } catch (e) {
87
- return judged({ deny: `${guard.step}: the callback failed: ${String((e as Error)?.message ?? e)}` });
85
+ return judged({ deny: callbackFailed(guard.step, String((e as Error)?.message ?? e)) });
88
86
  }
89
87
  }
@@ -1,5 +1,5 @@
1
1
  // The dev crews' onToolCall and onToolResult (RT-04), built from a crew's inputs and handed to every act through
2
- // createLlm(ctx.llm, callbacks). The host's gate runs first and the callback sees only the calls it allowed: the
2
+ // agentLlm(ctx, callbacks). The callback runs before the host's gate, which judges the input it returns (Orkeon #303): the
3
3
  // callback hands the call to the decision (tool-call-policy.ts) over probes built here: the memory folder read
4
4
  // once, the path a file_write under a rewrite rule names read once (a file the runtime says is not found is a new
5
5
  // one, which file_write may create), and the hooks run in the shell; it logs the decision's notes. After the call,
@@ -13,12 +13,19 @@ import { OPERATIONS_TOOL } from "../../domain/agent-policy/rule-sets.ts";
13
13
  import { sameToolName } from "../../domain/agent-policy/permission.ts";
14
14
  import { memoryWriteRefusal } from "../../domain/shared-memory/layout.ts";
15
15
  import { mapStrings, textFromRoot } from "../../domain/dev/path-rebase.ts";
16
+ import { callToVirtual, textToVirtual } from "../../domain/host-paths.ts";
17
+ import { pathListRefusal } from "../../domain/agent-policy/path-rules.ts";
18
+ import { isIdentityContext } from "../host-context.ts";
19
+ import type { HostContext } from "../host-context.ts";
16
20
  import type { CallGuard, CallGuardSpec, ToolHook } from "../../domain/dev/call-guard.ts";
17
21
  import { WORKSPACE } from "../../domain/vfs.ts";
18
22
  import { judgeToolCall, memoryDenyText } from "./tool-call-policy.ts";
19
23
  import type { CallProbes, HookFailure, ToolCallVerdict } from "./tool-call-policy.ts";
20
24
 
21
25
  export type { HookFailure, ToolCallVerdict } from "./tool-call-policy.ts";
26
+ import { memoryGuardFailed, mountCheckRefusedHook } from "./prompts.ts";
27
+ import { couldNotRun as hookCouldNotRun } from "../messages.ts";
28
+ import { postHooksFailed } from "./messages.ts";
22
29
 
23
30
  /** A hook is stopped after this many seconds, and refuses (pre) or is reported (post). */
24
31
  export const HOOK_TIMEOUT_SECONDS = 60;
@@ -62,7 +69,7 @@ export function memoryGuardCallbacks(memoryDir: () => Promise<string>): Pick<Too
62
69
  const why = memoryWriteRefusal(await dir(), call.name, call.input);
63
70
  return why === null ? "allow" : { deny: memoryDenyText(why) };
64
71
  } catch (e) {
65
- return { deny: `the shared memory's guard failed: ${String((e as Error)?.message ?? e)}` };
72
+ return { deny: memoryGuardFailed(String((e as Error)?.message ?? e)) };
66
73
  }
67
74
  },
68
75
  async onToolResult() { return undefined; },
@@ -119,7 +126,7 @@ async function runHook(deps: ToolCallbackDeps, hook: ToolHook, tool: string, inp
119
126
  const command = hookCommand(hook, tool, input);
120
127
  const label = `${hook.event} hook #${hook.n} (${command})`;
121
128
  const refused = (denial: string): HookFailure =>
122
- ({ by: "mount-check", text: `the runtime's mount check refused the command line of ${label}, which did not run: ${denial}` });
129
+ ({ by: "mount-check", text: mountCheckRefusedHook(label, denial) });
123
130
  try {
124
131
  const r = await deps.shell.run(command, { timeoutSeconds: HOOK_TIMEOUT_SECONDS });
125
132
  // A refused command line comes back not completed: read as a timeout, it would hide the refusal.
@@ -133,7 +140,7 @@ async function runHook(deps: ToolCallbackDeps, hook: ToolHook, tool: string, inp
133
140
  const message = String((e as Error)?.message ?? e);
134
141
  const denial = mountDenial(message);
135
142
  if (denial !== null) return refused(denial);
136
- return { by: "hook", text: `${label} could not run: ${message.split("\n")[0]}` };
143
+ return { by: "hook", text: hookCouldNotRun(label, message.split("\n")[0]) };
137
144
  }
138
145
  }
139
146
 
@@ -173,7 +180,7 @@ export function createToolCallbacks(guard: CallGuard, deps: ToolCallbackDeps): T
173
180
  if (failed !== undefined) notes.push(`[${failed.text}]`);
174
181
  }
175
182
  if (notes.length === 0) return undefined;
176
- deps.log?.warn(`${guard.step}: ${notes.length} post-tool hook(s) failed after ${call.name}`);
183
+ deps.log?.warn(postHooksFailed(guard.step, notes.length, call.name));
177
184
  return { context: [shownText(result), ...notes].join("\n") };
178
185
  },
179
186
  };
@@ -213,3 +220,43 @@ export function rootedCallbacks<C extends Pick<ToolCallbacks, "forAct">>(callbac
213
220
  },
214
221
  };
215
222
  }
223
+
224
+ /**
225
+ * The outermost layer of every act's callbacks (createLlm wraps each act in it): the host's spellings and the
226
+ * user's path lists. Before the call, its path fields and its command are brought back to the canonical virtual
227
+ * spelling (host-paths.ts callToVirtual), the lists judge that spelling (path-rules.ts pathListRefusal), then
228
+ * `inner` sees the canonical call: an inner refusal stands; an inner `{ input }` is kept, canonicalised once more;
229
+ * an inner allow becomes `{ input }` when the spelling changed, so the runtime gates and runs the canonical call.
230
+ * After the call, every string of the result is read with its physical spellings canonicalised (textToVirtual)
231
+ * before `inner` sees it; an inner `{ context }` is canonicalised too; a result the spellings changed replaces
232
+ * what the model reads. The identity context (a posix host without mounts, no list) leaves `inner` as it is.
233
+ */
234
+ export function hostCallbacks(inner: ActCallbacks | undefined, host: HostContext): ActCallbacks | undefined {
235
+ if (isIdentityContext(host)) return inner;
236
+ const { layout, lists } = host;
237
+ const canonicalInput = (name: string, input: unknown): unknown => callToVirtual(name, input, layout) ?? input;
238
+ return {
239
+ async onToolCall(call): Promise<ToolCallVerdict> {
240
+ const input = canonicalInput(call.name, call.input);
241
+ const why = pathListRefusal(lists, layout, call.name, input);
242
+ if (why !== null) return { deny: why };
243
+ const changed = input !== call.input;
244
+ if (inner === undefined) return changed ? { input } : "allow";
245
+ const verdict = await inner.onToolCall({ name: call.name, input });
246
+ if (typeof verdict === "object" && "deny" in verdict) return verdict;
247
+ if (typeof verdict === "object" && "input" in verdict) return { input: canonicalInput(call.name, verdict.input) };
248
+ return changed ? { input } : verdict;
249
+ },
250
+ async onToolResult(call, result) {
251
+ const mapped = mapStrings(result, (text) => textToVirtual(text, layout));
252
+ const shown = shownText(mapped);
253
+ const changed = shown !== shownText(result);
254
+ if (inner === undefined) return changed ? { context: shown } : undefined;
255
+ const answer = await inner.onToolResult({ name: call.name, input: canonicalInput(call.name, call.input) }, mapped);
256
+ if (answer !== undefined && answer !== null && typeof answer === "object" && typeof answer.context === "string") {
257
+ return { context: textToVirtual(answer.context, layout) };
258
+ }
259
+ return changed ? { context: shown } : undefined;
260
+ },
261
+ };
262
+ }
@@ -22,7 +22,8 @@ export function createToolTrace(): ToolTrace {
22
22
  }
23
23
 
24
24
  /** The callbacks given, each result recorded first, and each call they deny, which gets no result: their verdicts
25
- * and their context stand unchanged. A call the host's gate refuses reaches neither callback, and is not recorded. */
25
+ * and their context stand unchanged. A call the host's gate refuses after `onToolCall` (Orkeon #303) comes back as a `DENIED:` result through the
26
+ * host's invocation pipeline, recorded like any other; one the callback denies gets no result. */
26
27
  export function tracedCallbacks(inner: Pick<ToolCallbacks, "forAct">, trace: Pick<ToolTrace, "record">): Pick<ToolCallbacks, "forAct"> {
27
28
  return {
28
29
  forAct(mode, gateEnabled) {
@@ -6,6 +6,8 @@ import type { Files } from "../ports.ts";
6
6
  import type { WorkFolder } from "./resolve-work-folder.ts";
7
7
  import { LEARN_FILE } from "../../domain/shared-memory/verdict-rows.ts";
8
8
  import type { VerdictSource } from "../../domain/shared-memory/verdict-rows.ts";
9
+ import { folderListsTooMany, workListsTooMany } from "./messages.ts";
10
+ import { cannotBeRead } from "../messages.ts";
9
11
 
10
12
  export const WORK_LIST_CAP = 1000;
11
13
  export const FOLDER_LIST_CAP = 500;
@@ -31,18 +33,18 @@ export async function readVerdictSources(
31
33
  for (const code of entries.map(bare).filter((e) => e !== "" && !e.startsWith("."))) {
32
34
  const names = (await listOrEmpty(files, `${work.vfsPath}/${code}`, FOLDER_LIST_CAP)).map(bare);
33
35
  if (names.length >= FOLDER_LIST_CAP) {
34
- warnings.push(`${work.folder}/${code}/ lists ${FOLDER_LIST_CAP} entries or more: later files are not read`);
36
+ warnings.push(folderListsTooMany(`${work.folder}/${code}`, FOLDER_LIST_CAP));
35
37
  }
36
38
  for (const name of names.filter((n) => LEARN_FILE.test(n))) {
37
39
  try {
38
40
  sources.push({ code, name, text: await files.read(`${work.vfsPath}/${code}/${name}`) });
39
41
  } catch (error) {
40
- warnings.push(`${work.folder}/${code}/${name} cannot be read (${firstLine(error)})`);
42
+ warnings.push(cannotBeRead(`${work.folder}/${code}/${name}`, firstLine(error)));
41
43
  }
42
44
  }
43
45
  }
44
46
  if (entries.length >= WORK_LIST_CAP) {
45
- warnings.push(`${work.folder}/ lists ${WORK_LIST_CAP} entries or more: later folders are not read`);
47
+ warnings.push(workListsTooMany(work.folder, WORK_LIST_CAP));
46
48
  }
47
49
  return { sources, warnings };
48
50
  }