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.
- package/.orkeon-runtime +10 -0
- package/.orkeon-version +1 -1
- package/NOTICE.md +1 -1
- package/README.fr.md +16 -22
- package/README.md +16 -22
- package/config/appsettings.jev.example.json +4 -1
- package/config/appsettings.kev.example.json +4 -1
- package/config/appsettings.liquid.example.json +4 -1
- package/config/appsettings.ollama-whisper.example.json +1 -0
- package/config/appsettings.whisper.example.json +1 -0
- package/mcp/whisper/README.md +2 -1
- package/orkeon-code +206 -11
- package/orkeon-code.ps1 +109 -7
- package/package.json +2 -1
- package/src/commands/.orkeon/orkeon-cli.d.ts +1 -4
- package/src/commands/_lib/args.ts +5 -4
- package/src/commands/_lib/dev/dev-batches.ts +34 -36
- package/src/commands/_lib/dev/dev-implement.ts +11 -14
- package/src/commands/_lib/dev/dev-source.ts +7 -11
- package/src/commands/_lib/dev/dev.ts +34 -37
- package/src/commands/_lib/dev/markers.ts +7 -0
- package/src/commands/_lib/dev/messages.ts +112 -0
- package/src/commands/_lib/dev-step.ts +16 -13
- package/src/commands/_lib/dispatch.ts +62 -39
- package/src/commands/_lib/git/branch.ts +9 -10
- package/src/commands/_lib/git/commit.ts +9 -13
- package/src/commands/_lib/git/diff.ts +22 -12
- package/src/commands/_lib/git/messages.ts +54 -0
- package/src/commands/_lib/git/review.ts +9 -10
- package/src/commands/_lib/memory/memory-admit.ts +19 -21
- package/src/commands/_lib/memory/memory.ts +3 -2
- package/src/commands/_lib/memory/messages.ts +32 -0
- package/src/commands/_lib/messages.ts +48 -0
- package/src/commands/_lib/project/messages.ts +8 -0
- package/src/commands/_lib/session/export.ts +3 -2
- package/src/commands/_lib/session/messages.ts +87 -0
- package/src/commands/_lib/session/prompts.ts +4 -0
- package/src/commands/_lib/session/resume.ts +15 -24
- package/src/commands/_lib/session/tasks.ts +20 -23
- package/src/commands/_lib/settings/advisor.ts +11 -16
- package/src/commands/_lib/settings/agents.ts +18 -28
- package/src/commands/_lib/settings/choices.ts +8 -0
- package/src/commands/_lib/settings/config.ts +43 -43
- package/src/commands/_lib/settings/effort.ts +147 -0
- package/src/commands/_lib/settings/hooks.ts +12 -20
- package/src/commands/_lib/settings/messages.ts +408 -0
- package/src/commands/_lib/settings/mode.ts +33 -24
- package/src/commands/_lib/settings/model.ts +71 -36
- package/src/commands/_lib/settings/output-style.ts +39 -0
- package/src/commands/_lib/settings/permissions.ts +71 -93
- package/src/commands/_lib/settings/route.ts +63 -0
- package/src/commands/_lib/settings/skills.ts +53 -11
- package/src/commands/_lib/settings/theme.ts +42 -0
- package/src/commands/_lib/speech/messages.ts +58 -0
- package/src/commands/_lib/speech/prompts.ts +4 -0
- package/src/commands/_lib/speech/say.ts +9 -10
- package/src/commands/_lib/speech/transcribe.ts +14 -23
- package/src/commands/_lib/speech/voice.ts +14 -18
- package/src/commands/_lib/status/doctor.ts +47 -28
- package/src/commands/_lib/status/messages.ts +100 -0
- package/src/commands/_lib/status/meta.ts +3 -24
- package/src/commands/_lib/status/status.ts +10 -11
- package/src/commands/_lib/status/usage-tools.ts +2 -3
- package/src/commands/_lib/status/usage.ts +7 -18
- package/src/commands/_lib/view.ts +6 -1
- package/src/commands/dev/dev-batches.cmd.ts +4 -3
- package/src/commands/dev/dev-learn.cmd.ts +3 -3
- package/src/commands/dev/dev-plan.cmd.ts +6 -7
- package/src/commands/dev/dev-spec.cmd.ts +6 -7
- package/src/commands/git/commit.cmd.ts +3 -3
- package/src/commands/git/review.cmd.ts +3 -3
- package/src/commands/memory/memory.cmd.ts +2 -2
- package/src/commands/project/analyze.cmd.ts +3 -3
- package/src/commands/project/debug-tool-call.cmd.ts +4 -9
- package/src/commands/project/init-verifiers.cmd.ts +3 -3
- package/src/commands/project/init.cmd.ts +3 -3
- package/src/commands/project/verify.cmd.ts +2 -2
- package/src/commands/session/assistant.cmd.ts +2 -2
- package/src/commands/session/compact.cmd.ts +1 -1
- package/src/commands/session/copy.cmd.ts +8 -7
- package/src/commands/session/rename.cmd.ts +3 -2
- package/src/commands/session/rewind.cmd.ts +3 -4
- package/src/commands/session/summary.cmd.ts +3 -3
- package/src/commands/session/tasks.cmd.ts +4 -2
- package/src/commands/settings/config.cmd.ts +4 -2
- package/src/commands/settings/effort.cmd.ts +10 -31
- package/src/commands/settings/fast.cmd.ts +2 -1
- package/src/commands/settings/mode.cmd.ts +3 -3
- package/src/commands/settings/model.cmd.ts +3 -2
- package/src/commands/settings/output-style.cmd.ts +9 -38
- package/src/commands/settings/permissions.cmd.ts +2 -2
- package/src/commands/settings/proactive.cmd.ts +2 -1
- package/src/commands/settings/route.cmd.ts +16 -0
- package/src/commands/settings/skills.cmd.ts +3 -3
- package/src/commands/settings/theme.cmd.ts +14 -0
- package/src/commands/speech/say.cmd.ts +2 -2
- package/src/commands/speech/transcribe.cmd.ts +2 -2
- package/src/commands/status/release-notes.cmd.ts +1 -1
- package/src/crews/.orkeon/orkeon.d.ts +538 -93
- package/src/crews/_probe-shared-memory/domain/messages.ts +54 -0
- package/src/crews/_probe-shared-memory/domain/probe-verdict.ts +17 -12
- package/src/crews/_probe-shared-memory/domain/prompts.ts +5 -0
- package/src/crews/_probe-shared-memory/probe.ork.ts +5 -3
- package/src/crews/advisor/application/messages.ts +4 -0
- package/src/crews/advisor/application/prompts.ts +4 -0
- package/src/crews/advisor/application/run-advisor.ts +2 -1
- package/src/crews/advisor/crew.ork.ts +5 -4
- package/src/crews/advisor/domain/advice.ts +7 -23
- package/src/crews/advisor/domain/messages.ts +8 -0
- package/src/crews/advisor/domain/prompts.ts +26 -0
- package/src/crews/agent-run/application/messages.ts +18 -0
- package/src/crews/agent-run/application/run-agent-run.ts +5 -4
- package/src/crews/agent-run/crew.ork.ts +3 -3
- package/src/crews/analyze/application/messages.ts +27 -0
- package/src/crews/analyze/application/prompts.ts +4 -0
- package/src/crews/analyze/application/run-analyze.ts +16 -14
- package/src/crews/analyze/crew.ork.ts +5 -4
- package/src/crews/analyze/domain/harvest.ts +33 -65
- package/src/crews/analyze/domain/prompts.ts +86 -0
- package/src/crews/code-review/application/lens-material.ts +24 -0
- package/src/crews/code-review/application/messages.ts +17 -0
- package/src/crews/code-review/application/prompts.ts +10 -17
- package/src/crews/code-review/application/review.ts +4 -1
- package/src/crews/code-review/application/run-code-review.ts +13 -15
- package/src/crews/code-review/crew.ork.ts +5 -4
- package/src/crews/code-review/domain/lenses.ts +6 -45
- package/src/crews/code-review/domain/messages.ts +25 -0
- package/src/crews/code-review/domain/prompts.ts +58 -0
- package/src/crews/code-review/domain/report.ts +5 -6
- package/src/crews/code-review/domain/scope.ts +6 -12
- package/src/crews/dev-batches/application/messages.ts +127 -0
- package/src/crews/dev-batches/application/plan-close.ts +12 -12
- package/src/crews/dev-batches/application/prompts.ts +10 -0
- package/src/crews/dev-batches/application/run-dev-batches.ts +57 -50
- package/src/crews/dev-batches/application/run-wave.ts +24 -22
- package/src/crews/dev-batches/application/seed-harvest.ts +8 -7
- package/src/crews/dev-batches/crew.ork.ts +12 -9
- package/src/crews/dev-batches/domain/batches-log.ts +1 -3
- package/src/crews/dev-batches/domain/markers.ts +5 -0
- package/src/crews/dev-batches/domain/messages.ts +6 -0
- package/src/crews/dev-batches/domain/wave-order.ts +3 -2
- package/src/crews/dev-change/application/change-material.ts +44 -0
- package/src/crews/dev-change/application/evidence.ts +25 -22
- package/src/crews/dev-change/application/messages.ts +81 -0
- package/src/crews/dev-change/application/{change-prompt.ts → prompts.ts} +40 -43
- package/src/crews/dev-change/application/run-dev-change.ts +43 -34
- package/src/crews/dev-change/crew.ork.ts +11 -9
- package/src/crews/dev-change/domain/change-answer.ts +24 -20
- package/src/crews/dev-change/domain/change-render.ts +13 -15
- package/src/crews/dev-change/domain/markers.ts +28 -0
- package/src/crews/dev-change/domain/messages.ts +16 -0
- package/src/crews/dev-implement/application/close.ts +21 -18
- package/src/crews/dev-implement/application/locate-sheet.ts +7 -5
- package/src/crews/dev-implement/application/messages.ts +161 -0
- package/src/crews/dev-implement/application/observe.ts +4 -2
- package/src/crews/dev-implement/application/prompts.ts +9 -0
- package/src/crews/dev-implement/application/report-writes.ts +14 -9
- package/src/crews/dev-implement/application/run-dev-implement.ts +84 -73
- package/src/crews/dev-implement/application/suite-job.ts +15 -11
- package/src/crews/dev-implement/crew.ork.ts +2 -1
- package/src/crews/dev-implement/domain/contracts.ts +59 -60
- package/src/crews/dev-implement/domain/correction.ts +16 -15
- package/src/crews/dev-implement/domain/cycles.ts +2 -1
- package/src/crews/dev-implement/domain/markers.ts +23 -0
- package/src/crews/dev-implement/domain/messages.ts +58 -0
- package/src/crews/dev-implement/domain/prompts.ts +93 -0
- package/src/crews/dev-implement/domain/roles.ts +3 -7
- package/src/crews/dev-implement/domain/sheet-edits.ts +6 -5
- package/src/crews/dev-implement/domain/sheet-ticks.ts +5 -4
- package/src/crews/dev-implement/domain/step-checks.ts +17 -16
- package/src/crews/dev-implement/domain/step-section.ts +6 -4
- package/src/crews/dev-learn/application/learn-prompt-fit.ts +63 -0
- package/src/crews/dev-learn/application/messages.ts +51 -0
- package/src/crews/dev-learn/application/{learn-prompt.ts → prompts.ts} +24 -65
- package/src/crews/dev-learn/application/run-dev-learn.ts +37 -32
- package/src/crews/dev-learn/crew.ork.ts +4 -3
- package/src/crews/dev-learn/domain/learn-answer.ts +25 -27
- package/src/crews/dev-learn/domain/messages.ts +65 -0
- package/src/crews/dev-learn/domain/owner-lines.ts +12 -9
- package/src/crews/dev-learn/domain/proposals-render.ts +8 -9
- package/src/crews/dev-plan/application/anchor-paths.ts +57 -20
- package/src/crews/dev-plan/application/inventory.ts +17 -13
- package/src/crews/dev-plan/application/messages.ts +88 -0
- package/src/crews/dev-plan/application/plan-prompt-fit.ts +44 -0
- package/src/crews/dev-plan/application/{plan-prompt.ts → prompts.ts} +37 -55
- package/src/crews/dev-plan/application/run-dev-plan.ts +103 -75
- package/src/crews/dev-plan/crew.ork.ts +11 -8
- package/src/crews/dev-plan/domain/inventory-model.ts +3 -3
- package/src/crews/dev-plan/domain/markers.ts +18 -0
- package/src/crews/dev-plan/domain/messages.ts +118 -0
- package/src/crews/dev-plan/domain/plan-answer.ts +118 -103
- package/src/crews/dev-plan/domain/plan-render.ts +30 -31
- package/src/crews/dev-plan/domain/prompts.ts +44 -0
- package/src/crews/dev-spec/application/messages.ts +30 -0
- package/src/crews/dev-spec/application/{spec-prompt.ts → prompts.ts} +42 -47
- package/src/crews/dev-spec/application/run-dev-spec.ts +67 -36
- package/src/crews/dev-spec/application/spec-material.ts +42 -0
- package/src/crews/dev-spec/crew.ork.ts +11 -9
- package/src/crews/dev-spec/domain/markers.ts +30 -0
- package/src/crews/dev-spec/domain/messages.ts +39 -0
- package/src/crews/dev-spec/domain/spec-answer.ts +46 -47
- package/src/crews/dev-spec/domain/spec-render.ts +18 -18
- package/src/crews/dev-verify/application/audit-brief.ts +187 -0
- package/src/crews/dev-verify/application/audit.ts +38 -30
- package/src/crews/dev-verify/application/capture.ts +34 -26
- package/src/crews/dev-verify/application/messages.ts +119 -0
- package/src/crews/dev-verify/application/prompts.ts +209 -0
- package/src/crews/dev-verify/application/run-dev-verify.ts +60 -46
- package/src/crews/dev-verify/application/run-gate.ts +11 -9
- package/src/crews/dev-verify/crew.ork.ts +6 -6
- package/src/crews/dev-verify/domain/audit-answer.ts +16 -12
- package/src/crews/dev-verify/domain/capture-sections.ts +5 -4
- package/src/crews/dev-verify/domain/commands.ts +3 -3
- package/src/crews/dev-verify/domain/gate.ts +21 -16
- package/src/crews/dev-verify/domain/markers.ts +16 -0
- package/src/crews/dev-verify/domain/mechanical-table.ts +37 -44
- package/src/crews/dev-verify/domain/messages.ts +92 -0
- package/src/crews/dev-verify/domain/verdict.ts +4 -4
- package/src/crews/git-commit/application/draft.ts +16 -37
- package/src/crews/git-commit/application/messages.ts +15 -0
- package/src/crews/git-commit/application/prompts.ts +47 -0
- package/src/crews/git-commit/application/run-git-commit.ts +13 -12
- package/src/crews/git-commit/crew.ork.ts +5 -4
- package/src/crews/git-commit/domain/commit.ts +15 -35
- package/src/crews/git-commit/domain/markers.ts +4 -0
- package/src/crews/git-commit/domain/messages.ts +48 -0
- package/src/crews/init-verifiers/application/authoring.ts +2 -1
- package/src/crews/init-verifiers/application/messages.ts +13 -0
- package/src/crews/init-verifiers/application/prompts.ts +5 -1
- package/src/crews/init-verifiers/application/run-init-verifiers.ts +3 -2
- package/src/crews/init-verifiers/crew.ork.ts +5 -4
- package/src/crews/main-loop/application/auto-compact.ts +2 -1
- package/src/crews/main-loop/application/messages.ts +81 -0
- package/src/crews/main-loop/application/prompts.ts +12 -0
- package/src/crews/main-loop/application/run-main-loop.ts +63 -30
- package/src/crews/main-loop/application/{turn-prompt.ts → turn-context.ts} +7 -8
- package/src/crews/main-loop/crew.ork.ts +12 -7
- package/src/crews/main-loop/domain/prompt-assembly.ts +45 -228
- package/src/crews/main-loop/domain/prompts.ts +336 -0
- package/src/crews/main-loop/domain/turn-chains.ts +10 -9
- package/src/crews/project-init/application/detect.ts +5 -4
- package/src/crews/project-init/application/messages.ts +15 -0
- package/src/crews/project-init/application/prompts.ts +11 -7
- package/src/crews/project-init/crew.ork.ts +5 -4
- package/src/crews/project-init/domain/existing-files.ts +6 -4
- package/src/crews/project-init/domain/messages.ts +13 -0
- package/src/crews/project-init/domain/package-map.ts +3 -3
- package/src/crews/project-init/domain/prompts.ts +10 -0
- package/src/crews/session-compact/application/prompts.ts +5 -0
- package/src/crews/session-compact/crew.ork.ts +5 -4
- package/src/crews/shared-memory-admit/application/prompts.ts +5 -0
- package/src/crews/shared-memory-admit/crew.ork.ts +3 -2
- package/src/crews/speech/application/messages.ts +3 -0
- package/src/crews/speech/application/prompts.ts +3 -0
- package/src/crews/speech/application/run-speech.ts +2 -1
- package/src/crews/speech/crew.ork.ts +2 -1
- package/src/shared/application/agents/child-agent.ts +11 -7
- package/src/shared/application/agents/messages.ts +35 -0
- package/src/shared/application/agents/route-agent.ts +115 -0
- package/src/shared/application/agents/run-sub-agent.ts +31 -8
- package/src/shared/application/compaction/compact-session.ts +19 -14
- package/src/shared/application/compaction/messages.ts +20 -0
- package/src/shared/application/compaction/prune-context.ts +94 -0
- package/src/shared/application/compaction/pruned-llm.ts +35 -0
- package/src/shared/application/dev/brief-inventory.ts +6 -4
- package/src/shared/application/dev/close-batch.ts +9 -7
- package/src/shared/application/dev/find-repo-pack.ts +4 -3
- package/src/shared/application/dev/learn-decision.ts +20 -18
- package/src/shared/application/dev/load-dev-context.ts +7 -8
- package/src/shared/application/dev/measure-access-cost.ts +5 -4
- package/src/shared/application/dev/messages.ts +132 -0
- package/src/shared/application/dev/phase-timer.ts +54 -0
- package/src/shared/application/dev/plan-source.ts +12 -8
- package/src/shared/application/dev/preflight.ts +8 -8
- package/src/shared/application/dev/prompts.ts +34 -0
- package/src/shared/application/dev/question-round.ts +25 -17
- package/src/shared/application/dev/resolve-work-folder.ts +4 -3
- package/src/shared/application/dev/settle-questions.ts +4 -2
- package/src/shared/application/dev/source-review.ts +12 -8
- package/src/shared/application/dev/source-step.ts +12 -10
- package/src/shared/application/dev/spend.ts +17 -4
- package/src/shared/application/dev/step-precedents.ts +2 -1
- package/src/shared/application/dev/tool-call-policy.ts +9 -11
- package/src/shared/application/dev/tool-callbacks.ts +52 -5
- package/src/shared/application/dev/tool-trace-recorder.ts +2 -1
- package/src/shared/application/dev/verdict-sources.ts +5 -3
- package/src/shared/application/dev/wrapped-tools.ts +4 -2
- package/src/shared/application/extra-tools.ts +2 -1
- package/src/shared/application/git/batch-worktree.ts +22 -17
- package/src/shared/application/git/commit-files.ts +24 -19
- package/src/shared/application/git/merge-batch.ts +11 -7
- package/src/shared/application/git/messages.ts +75 -0
- package/src/shared/application/git/open-pull-request.ts +4 -3
- package/src/shared/application/host-context.ts +59 -0
- package/src/shared/application/host-layout-store.ts +45 -0
- package/src/shared/application/llm-profile.ts +4 -3
- package/src/shared/application/messages.ts +14 -0
- package/src/shared/application/permission-rules.ts +10 -0
- package/src/shared/application/ports/decision.ts +14 -0
- package/src/shared/application/ports/human.ts +25 -0
- package/src/shared/application/ports/llm.ts +32 -3
- package/src/shared/application/ports/memory.ts +1 -1
- package/src/shared/application/ports/theme.ts +11 -0
- package/src/shared/application/ports.ts +4 -2
- package/src/shared/application/session-io.ts +2 -1
- package/src/shared/application/shared-memory/admit-entries.ts +16 -14
- package/src/shared/application/shared-memory/harvest-after-gaps.ts +5 -8
- package/src/shared/application/shared-memory/harvest-mistakes.ts +3 -2
- package/src/shared/application/shared-memory/import-agent-memory.ts +9 -7
- package/src/shared/application/shared-memory/memory-files.ts +2 -1
- package/src/shared/application/shared-memory/memory-settings.ts +2 -1
- package/src/shared/application/shared-memory/messages.ts +63 -0
- package/src/shared/application/shared-memory/push-candidate.ts +14 -11
- package/src/shared/application/shared-memory/recall-precedents.ts +2 -1
- package/src/shared/application/skills/messages.ts +4 -0
- package/src/shared/application/skills/suggest-skills.ts +102 -0
- package/src/shared/application/workflow/messages.ts +8 -0
- package/src/shared/application/workflow/workflow-state.ts +7 -6
- package/src/shared/domain/agent-policy/behavior-flags.ts +4 -10
- package/src/shared/domain/agent-policy/extra-tools.ts +2 -4
- package/src/shared/domain/agent-policy/messages.ts +66 -0
- package/src/shared/domain/agent-policy/path-rules.ts +299 -0
- package/src/shared/domain/agent-policy/permission.ts +20 -18
- package/src/shared/domain/agent-policy/prompts.ts +17 -0
- package/src/shared/domain/agent-policy/reasoning.ts +59 -0
- package/src/shared/domain/agent-policy/rule-sets.ts +18 -14
- package/src/shared/domain/agent-policy/tool-access.ts +17 -3
- package/src/shared/domain/agent-registry.ts +6 -5
- package/src/shared/domain/agents/chain.ts +2 -2
- package/src/shared/domain/agents/charter.ts +8 -5
- package/src/shared/domain/agents/exclusive.ts +2 -1
- package/src/shared/domain/agents/instances.ts +18 -15
- package/src/shared/domain/agents/messages.ts +39 -0
- package/src/shared/domain/agents/model-route.ts +199 -0
- package/src/shared/domain/agents/prompts.ts +20 -0
- package/src/shared/domain/code-intel-contract.ts +5 -4
- package/src/shared/domain/code-intel-routing.ts +8 -61
- package/src/shared/domain/compact-outcome.ts +5 -3
- package/src/shared/domain/compaction-thresholds.ts +2 -1
- package/src/shared/domain/compaction.ts +22 -113
- package/src/shared/domain/config-schema.ts +94 -81
- package/src/shared/domain/context-prune.ts +176 -0
- package/src/shared/domain/decision/questions.ts +102 -0
- package/src/shared/domain/dev/access-cost.ts +19 -15
- package/src/shared/domain/dev/batches-concurrency.ts +5 -6
- package/src/shared/domain/dev/build-commands.ts +5 -4
- package/src/shared/domain/dev/call-guard.ts +29 -28
- package/src/shared/domain/dev/carried-text.ts +3 -5
- package/src/shared/domain/dev/learn-proposals.ts +5 -4
- package/src/shared/domain/dev/learn-state.ts +3 -2
- package/src/shared/domain/dev/markers.ts +107 -0
- package/src/shared/domain/dev/messages.ts +259 -0
- package/src/shared/domain/dev/phase-timing.ts +50 -0
- package/src/shared/domain/dev/plan-checks.ts +24 -23
- package/src/shared/domain/dev/plan-format.ts +14 -24
- package/src/shared/domain/dev/project-files.ts +1 -15
- package/src/shared/domain/dev/prompts/brief-blocks.ts +20 -0
- package/src/shared/domain/dev/{review-prompt.ts → prompts.ts} +91 -61
- package/src/shared/domain/dev/questions.ts +33 -15
- package/src/shared/domain/dev/repo-pack.ts +12 -9
- package/src/shared/domain/dev/review-answer.ts +40 -17
- package/src/shared/domain/dev/review-brief.ts +54 -0
- package/src/shared/domain/dev/reviewer-charter.ts +4 -0
- package/src/shared/domain/dev/sheet-facts.ts +2 -4
- package/src/shared/domain/dev/spec-format.ts +13 -14
- package/src/shared/domain/dev/step-budget.ts +4 -2
- package/src/shared/domain/dev/step-rules.ts +3 -4
- package/src/shared/domain/dev/test-commands.ts +14 -10
- package/src/shared/domain/dev/tool-guards.ts +4 -3
- package/src/shared/domain/dev/trait-pattern.ts +14 -10
- package/src/shared/domain/dev/verdict-format.ts +14 -21
- package/src/shared/domain/dev/whitespace.ts +3 -2
- package/src/shared/domain/dev/work-folder.ts +4 -3
- package/src/shared/domain/dev/yaml-subset.ts +8 -26
- package/src/shared/domain/error-text.ts +13 -0
- package/src/shared/domain/git/close.ts +5 -4
- package/src/shared/domain/git/messages.ts +20 -0
- package/src/shared/domain/git/pull-request.ts +5 -5
- package/src/shared/domain/host-layout.ts +147 -0
- package/src/shared/domain/host-paths.ts +399 -0
- package/src/shared/domain/llm-failure.ts +35 -7
- package/src/shared/domain/llm-profile.ts +22 -3
- package/src/shared/domain/marked-message.ts +1 -5
- package/src/shared/domain/markers.ts +30 -0
- package/src/shared/domain/messages.ts +291 -0
- package/src/shared/domain/model-catalog.ts +2 -9
- package/src/shared/domain/permission-modes.ts +4 -8
- package/src/shared/domain/prelude.ts +2 -2
- package/src/shared/domain/project-manifests.ts +3 -2
- package/src/shared/domain/prompts.ts +233 -0
- package/src/shared/domain/search-routing.ts +3 -11
- package/src/shared/domain/secret-patterns.ts +3 -2
- package/src/shared/domain/session-keys.ts +7 -0
- package/src/shared/domain/session-start.ts +3 -2
- package/src/shared/domain/shared-memory/agent-memory-import.ts +4 -2
- package/src/shared/domain/shared-memory/candidates.ts +3 -4
- package/src/shared/domain/shared-memory/entry.ts +26 -20
- package/src/shared/domain/shared-memory/front-matter.ts +17 -13
- package/src/shared/domain/shared-memory/gate.ts +4 -3
- package/src/shared/domain/shared-memory/harvest.ts +9 -6
- package/src/shared/domain/shared-memory/layout.ts +11 -8
- package/src/shared/domain/shared-memory/markers.ts +9 -0
- package/src/shared/domain/shared-memory/messages.ts +66 -0
- package/src/shared/domain/shared-memory/precedents-block.ts +4 -15
- package/src/shared/domain/shared-memory/prompts.ts +28 -0
- package/src/shared/domain/shared-memory/refused.ts +3 -3
- package/src/shared/domain/skills/prompts.ts +4 -0
- package/src/shared/domain/skills/shortlist.ts +149 -0
- package/src/shared/domain/snip-turns.ts +2 -14
- package/src/shared/domain/speech.ts +2 -1
- package/src/shared/domain/tool-trace.ts +5 -7
- package/src/shared/domain/verifiers.ts +7 -11
- package/src/shared/domain/vfs.ts +8 -1
- package/src/shared/domain/workflow/prompts.ts +15 -0
- package/src/shared/domain/workflow/state-file.ts +14 -12
- package/src/shared/infrastructure/globals.ts +7 -2
- package/src/shared/infrastructure/orkeon/child-agents.ts +11 -16
- package/src/shared/infrastructure/orkeon/chooser.ts +32 -0
- package/src/shared/infrastructure/orkeon/decision-model.ts +31 -0
- package/src/shared/infrastructure/orkeon/dev-deps.ts +21 -14
- package/src/shared/infrastructure/orkeon/files.ts +24 -6
- package/src/shared/infrastructure/orkeon/github-pull-requests.ts +3 -2
- package/src/shared/infrastructure/orkeon/host-context.ts +36 -0
- package/src/shared/infrastructure/orkeon/human-input.ts +1 -5
- package/src/shared/infrastructure/orkeon/llm-profile.ts +36 -16
- package/src/shared/infrastructure/orkeon/llm.ts +85 -30
- package/src/shared/infrastructure/orkeon/markers.ts +6 -0
- package/src/shared/infrastructure/orkeon/memory-store.ts +1 -1
- package/src/shared/infrastructure/orkeon/memory-tools.ts +18 -20
- package/src/shared/infrastructure/orkeon/messages.ts +15 -0
- package/src/shared/infrastructure/orkeon/prompts.ts +47 -0
- package/src/shared/infrastructure/orkeon/reasoning.ts +40 -0
- package/src/shared/infrastructure/orkeon/script-tools.ts +14 -19
- package/src/shared/infrastructure/orkeon/session-store.ts +7 -51
- package/src/shared/infrastructure/orkeon/shell-jobs.ts +13 -7
- package/src/shared/infrastructure/orkeon/shell.ts +13 -5
- package/src/shared/infrastructure/orkeon/tool-catalogue.ts +3 -2
- package/src/shared/infrastructure/orkeon/wiring.ts +68 -12
- package/src/crews/dev-verify/application/auditor-prompt.ts +0 -323
- package/src/shared/domain/session-summary.ts +0 -13
|
@@ -8,6 +8,18 @@ import type { RepoPackCommands, RepoPackLayout } from "../../../shared/domain/de
|
|
|
8
8
|
import { PLACEHOLDER, plainWords, valueProblem } from "../../../shared/domain/dev/test-commands.ts";
|
|
9
9
|
import { BOUNDED_READ_RULE, NODE_EDIT_RULE, NODE_READ_RULE } from "../../../shared/domain/dev/reading-rule.ts";
|
|
10
10
|
import type { AnchorRef, ImplementSheet, ImplementStep } from "./step-section.ts";
|
|
11
|
+
import { CORRECTION_LABEL as CORRECTION, STALE_HEADING } from "./markers.ts";
|
|
12
|
+
import { PACK_HAS_NO_CLASS_OR_PROJECT_TEST, PACK_HAS_NO_TEST_PROJECT, stepNamesNoTestFile } from "./messages.ts";
|
|
13
|
+
import { SHELL_OPERATOR_OUTSIDE_QUOTES } from "../../../shared/domain/dev/messages.ts";
|
|
14
|
+
import {
|
|
15
|
+
ANY_LEVEL_RULE, ASSUMPTION_RULE, CODE_ELEMENTS_LINE, FILES_HEADING, GREEN_ANSWER, IN_THIS_BRIEF_HEADING, INTEGRATION_LEVEL_RULE,
|
|
16
|
+
LEAST_CODE_RULE, NO_ID, NONE_LISTED, NONE_NAMED, ONE_TEST_PER_ROW_RULE, PRODUCTION_HEADING, READ_ONLY_NEVER_WRITE, RED_ANSWER,
|
|
17
|
+
RED_TESTS_HEADING, RULES_HEADING, SIGNATURE_STUB_AT_MOST, STUB_EXISTING, STUB_IMPORT_RULE, STUB_OF_EARLIER_RED, STUBBED_AT_RED,
|
|
18
|
+
TEST_FILE_EXISTING, TEST_FILE_IN_BRIEF, TEST_FILE_TO_CREATE, TESTS_TO_WRITE_HEADING, THE_TEST_FILES, UNIT_LEVEL_RULE,
|
|
19
|
+
WRITE_FAILING_TESTS_FOR_FINDING, appliedRulesLine, briefTitle, correctionOfFinding, doublesLine, greenRunRule, inThisBrief,
|
|
20
|
+
lastRedRun, memberRefLine, neverWriteTestRule, oneStep, productionLine, redRunRule, sheetLine, stepLabel, stepsOfOneBehaviour,
|
|
21
|
+
stubsRule, testFileLine, testFilesOnlyRule, testRow,
|
|
22
|
+
} from "./prompts.ts";
|
|
11
23
|
|
|
12
24
|
export type TestCommand = { ok: true; command: string } | { ok: false; reason: string };
|
|
13
25
|
|
|
@@ -30,25 +42,25 @@ function fill(template: string, values: { project: string; klass: string }): Tes
|
|
|
30
42
|
if (problem !== null) return { ok: false, reason: `${hole}: ${problem}` };
|
|
31
43
|
}
|
|
32
44
|
const command = template.replace(PLACEHOLDER, (hole) => (/project/i.test(hole) ? values.project : values.klass));
|
|
33
|
-
return plainWords(command) ? { ok: true, command } : { ok: false, reason:
|
|
45
|
+
return plainWords(command) ? { ok: true, command } : { ok: false, reason: SHELL_OPERATOR_OUTSIDE_QUOTES };
|
|
34
46
|
}
|
|
35
47
|
|
|
36
48
|
/** The narrow command that runs the step's tests: `test_class`, else `test_project`; never the whole suite. */
|
|
37
49
|
export function testCommandFor(commands: RepoPackCommands, step: ImplementStep): TestCommand {
|
|
38
50
|
const file = testFileOf(step);
|
|
39
|
-
if (file === null) return { ok: false, reason:
|
|
51
|
+
if (file === null) return { ok: false, reason: stepNamesNoTestFile(step.number) };
|
|
40
52
|
const values = { project: step.tests[0]?.project ?? "", klass: classOf(file) };
|
|
41
53
|
const byClass = commands.testClass?.trim();
|
|
42
54
|
if (byClass) return fill(byClass, values);
|
|
43
55
|
const byProject = commands.testProject?.trim();
|
|
44
56
|
if (byProject) return fill(byProject, values);
|
|
45
|
-
return { ok: false, reason:
|
|
57
|
+
return { ok: false, reason: PACK_HAS_NO_CLASS_OR_PROJECT_TEST };
|
|
46
58
|
}
|
|
47
59
|
|
|
48
60
|
/** `test_project` for one Project cell: the affected tests of a later run. */
|
|
49
61
|
export function projectCommandFor(commands: RepoPackCommands, project: string): TestCommand {
|
|
50
62
|
const byProject = commands.testProject?.trim();
|
|
51
|
-
if (!byProject) return { ok: false, reason:
|
|
63
|
+
if (!byProject) return { ok: false, reason: PACK_HAS_NO_TEST_PROJECT };
|
|
52
64
|
return fill(byProject, { project, klass: project });
|
|
53
65
|
}
|
|
54
66
|
|
|
@@ -82,8 +94,8 @@ export function existingStubsOf(step: ImplementStep): string[] {
|
|
|
82
94
|
/** What a stub path is to the test author: a file to create, an existing one, or an earlier RED's stub. */
|
|
83
95
|
function stubKind(step: ImplementStep, path: string): string {
|
|
84
96
|
if (stubsOf(step).includes(path)) return "to create";
|
|
85
|
-
if (existingStubsOf(step).includes(path)) return
|
|
86
|
-
return
|
|
97
|
+
if (existingStubsOf(step).includes(path)) return STUB_EXISTING;
|
|
98
|
+
return STUB_OF_EARLIER_RED;
|
|
87
99
|
}
|
|
88
100
|
|
|
89
101
|
/** Where the tests live, as the pack says: its test folder, and its test file patterns. */
|
|
@@ -92,59 +104,50 @@ function testsWhere(layout: RepoPackLayout): string {
|
|
|
92
104
|
...(layout.tests?.trim() ? [`under \`${layout.tests.trim()}\``] : []),
|
|
93
105
|
...(layout.testFiles ?? []).filter((p) => p.trim() !== "").map((p) => `\`${p.trim()}\``),
|
|
94
106
|
];
|
|
95
|
-
return parts.length === 0 ?
|
|
107
|
+
return parts.length === 0 ? THE_TEST_FILES : parts.join(" or ");
|
|
96
108
|
}
|
|
97
109
|
|
|
98
|
-
const CORRECTION = /^Correction (C\d+) — (.*)$/;
|
|
99
|
-
const ASSUMPTION_RULE = "A question that changes no scope, id or design decision is settled by you: say it as a line " +
|
|
100
|
-
"`Assumption: <what you assumed>`, only for a behaviour the plan leaves open (an error, a rounding, an edge), once. " +
|
|
101
|
-
"A test value, a stub's wording or a file's state is your choice or a fact, never an assumption. Never one the " +
|
|
102
|
-
"sheet's `## Assumptions` already holds, in any wording: the sheet is in your brief, and an assumption is recorded " +
|
|
103
|
-
"once per batch.";
|
|
104
|
-
|
|
105
110
|
/** One anchor as a brief line; `shown` overrides the state it says (a file the sheet says to create, stubbed since). */
|
|
106
111
|
function refLine(ref: AnchorRef, shown: string = ref.state): string {
|
|
107
112
|
const at = ref.line === undefined ? ref.path : `${ref.path}:${ref.line}`;
|
|
108
|
-
if (ref.state === "member") return
|
|
113
|
+
if (ref.state === "member") return memberRefLine(at, ref.member);
|
|
109
114
|
return `\`${at}\` — ${shown}`;
|
|
110
115
|
}
|
|
111
116
|
|
|
112
117
|
/** How the test author works on its test file: creates it whole when it is to create, else adds to it by node; one
|
|
113
118
|
* carried in the brief is not read again. */
|
|
114
119
|
function testFileRule(state: string, inBrief: boolean): string {
|
|
115
|
-
if (inBrief) return
|
|
116
|
-
return state === "to create"
|
|
117
|
-
? "create it with file_write; once it exists, add to it by node"
|
|
118
|
-
: "read it by node (node_outline, then node_read), add the tests with node_insert inside its suite, never rewrite it whole";
|
|
120
|
+
if (inBrief) return TEST_FILE_IN_BRIEF;
|
|
121
|
+
return state === "to create" ? TEST_FILE_TO_CREATE : TEST_FILE_EXISTING;
|
|
119
122
|
}
|
|
120
123
|
|
|
121
124
|
function ids(step: ImplementStep): string {
|
|
122
|
-
return [...new Set(step.tests.flatMap((t) => t.ids))].join(", ") ||
|
|
125
|
+
return [...new Set(step.tests.flatMap((t) => t.ids))].join(", ") || NONE_NAMED;
|
|
123
126
|
}
|
|
124
127
|
|
|
125
128
|
function levelRule(step: ImplementStep): string {
|
|
126
129
|
const levels = new Set(step.tests.map((t) => t.level.toLowerCase()));
|
|
127
130
|
const lines: string[] = [];
|
|
128
|
-
if (levels.has("unit")) lines.push(
|
|
129
|
-
if (levels.has("integration")) lines.push(
|
|
130
|
-
return lines.length === 0 ?
|
|
131
|
+
if (levels.has("unit")) lines.push(UNIT_LEVEL_RULE);
|
|
132
|
+
if (levels.has("integration")) lines.push(INTEGRATION_LEVEL_RULE);
|
|
133
|
+
return lines.length === 0 ? ANY_LEVEL_RULE : lines.join("\n");
|
|
131
134
|
}
|
|
132
135
|
|
|
133
136
|
function header(input: ContractInput, role: string, steps: readonly ImplementStep[] = [input.step]): string[] {
|
|
134
137
|
const { sheet } = input;
|
|
135
138
|
const what = steps.length === 1
|
|
136
|
-
?
|
|
137
|
-
:
|
|
138
|
-
const allIds = [...new Set(steps.flatMap((s) => s.tests.flatMap((t) => t.ids)))].join(", ") ||
|
|
139
|
+
? oneStep(steps[0].number, steps[0].title)
|
|
140
|
+
: stepsOfOneBehaviour(steps.map((s) => s.number).join(", "), steps.map((s) => s.title).join("; "));
|
|
141
|
+
const allIds = [...new Set(steps.flatMap((s) => s.tests.flatMap((t) => t.ids)))].join(", ") || NONE_NAMED;
|
|
139
142
|
return [
|
|
140
|
-
|
|
143
|
+
briefTitle(role, input.code, sheet.batch ?? "?", what),
|
|
141
144
|
"",
|
|
142
|
-
|
|
145
|
+
sheetLine(input.sheetPath, steps.length === 1 ? ids(steps[0]) : allIds),
|
|
143
146
|
];
|
|
144
147
|
}
|
|
145
148
|
|
|
146
149
|
function testsTable(step: ImplementStep): string[] {
|
|
147
|
-
return step.tests.map((t, i) =>
|
|
150
|
+
return step.tests.map((t, i) => testRow(i + 1, t.name, t.level, t.project, t.ids.join(", ") || NO_ID));
|
|
148
151
|
}
|
|
149
152
|
|
|
150
153
|
/** The test author's brief: write the step's tests, all red, test files only. */
|
|
@@ -154,7 +157,7 @@ export const CARRIED_CONTRACT_CHARS = 12_000;
|
|
|
154
157
|
/** The carried texts as a section of the brief (or nothing), and the files it holds whole. */
|
|
155
158
|
function carriedSection(input: ContractInput): { lines: string[]; whole: ReadonlySet<string> } {
|
|
156
159
|
const { blocks, whole } = carry(input.carried ?? [], CARRIED_CONTRACT_CHARS);
|
|
157
|
-
return { lines: blocks.length === 0 ? [] : ["",
|
|
160
|
+
return { lines: blocks.length === 0 ? [] : ["", IN_THIS_BRIEF_HEADING, ...blocks], whole };
|
|
158
161
|
}
|
|
159
162
|
|
|
160
163
|
export function redContract(input: ContractInput): string {
|
|
@@ -171,34 +174,33 @@ export function redContract(input: ContractInput): string {
|
|
|
171
174
|
return [
|
|
172
175
|
...header(input, "RED"),
|
|
173
176
|
"",
|
|
174
|
-
|
|
177
|
+
TESTS_TO_WRITE_HEADING,
|
|
175
178
|
...(correction === null
|
|
176
179
|
? testsTable(step)
|
|
177
|
-
: [
|
|
178
|
-
"Write the test (or tests) that fail on this finding today; the names are yours, in the style of the file."]),
|
|
180
|
+
: [correctionOfFinding(correction[1], correction[2]), WRITE_FAILING_TESTS_FOR_FINDING]),
|
|
179
181
|
...(step.note.length > 0 ? ["", ...step.note] : []),
|
|
180
182
|
"",
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
...(step.anchor?.production ?? []).map((r) =>
|
|
183
|
+
FILES_HEADING,
|
|
184
|
+
testFileLine(refLine(shownRef), testFileRule(testRef.state, testInBrief)),
|
|
185
|
+
doublesLine(doubles === "" ? NONE_NAMED : doubles),
|
|
186
|
+
...(step.anchor?.production ?? []).map((r) => productionLine(stubs.includes(r.path) ? SIGNATURE_STUB_AT_MOST : READ_ONLY_NEVER_WRITE, refLine(r))),
|
|
185
187
|
...carried.lines,
|
|
186
188
|
"",
|
|
187
|
-
|
|
188
|
-
|
|
189
|
+
RULES_HEADING,
|
|
190
|
+
testFilesOnlyRule(testsWhere(layout)),
|
|
189
191
|
...(stubs.length === 0 ? [] : [
|
|
190
|
-
|
|
191
|
-
|
|
192
|
+
stubsRule(stubs.map((p) => `\`${p}\` (${stubKind(step, p)})`).join(", ")),
|
|
193
|
+
STUB_IMPORT_RULE,
|
|
192
194
|
]),
|
|
193
|
-
|
|
195
|
+
ONE_TEST_PER_ROW_RULE,
|
|
194
196
|
levelRule(step),
|
|
195
|
-
|
|
197
|
+
redRunRule(input.testCommand),
|
|
196
198
|
`- ${NODE_READ_RULE}`,
|
|
197
199
|
`- ${BOUNDED_READ_RULE}`,
|
|
198
200
|
`- ${NODE_EDIT_RULE}`,
|
|
199
201
|
`- ${ASSUMPTION_RULE}`,
|
|
200
202
|
"",
|
|
201
|
-
|
|
203
|
+
RED_ANSWER,
|
|
202
204
|
].join("\n");
|
|
203
205
|
}
|
|
204
206
|
|
|
@@ -206,48 +208,45 @@ export function redContract(input: ContractInput): string {
|
|
|
206
208
|
export function greenContract(input: ContractInput, red: { tail: string; log: string | null }): string {
|
|
207
209
|
const { sheet, layout } = input;
|
|
208
210
|
const steps = input.cycle !== undefined && input.cycle.length > 0 ? input.cycle : [input.step];
|
|
209
|
-
const elements = sheet.codeElements.length === 0 ? [
|
|
211
|
+
const elements = sheet.codeElements.length === 0 ? [NONE_LISTED] : sheet.codeElements;
|
|
210
212
|
const testFiles = [...new Set(steps.map((s) => testFileOf(s) ?? "(none)"))];
|
|
211
213
|
const production = steps.flatMap((s) => s.anchor?.production ?? []);
|
|
212
214
|
const carried = carriedSection(input);
|
|
213
215
|
// A production file to create exists once RED stubbed it: the brief carries it and says so.
|
|
214
216
|
const shown = (r: AnchorRef): string => carried.whole.has(r.path)
|
|
215
|
-
?
|
|
217
|
+
? inThisBrief(refLine(r, r.state === "to create" ? STUBBED_AT_RED : r.state))
|
|
216
218
|
: refLine(r);
|
|
217
219
|
const seen = new Set<string>();
|
|
218
220
|
return [
|
|
219
221
|
...header(input, "GREEN", steps),
|
|
220
222
|
"",
|
|
221
|
-
|
|
222
|
-
...steps.flatMap((s) => [...(steps.length > 1 ? [
|
|
223
|
-
|
|
223
|
+
RED_TESTS_HEADING,
|
|
224
|
+
...steps.flatMap((s) => [...(steps.length > 1 ? [stepLabel(s.number, s.title)] : []), ...testsTable(s)]),
|
|
225
|
+
lastRedRun(testFiles.every((f) => carried.whole.has(f)), testFiles.map((f) => `\`${f}\``).join(", "), red.log),
|
|
224
226
|
"```",
|
|
225
227
|
red.tail,
|
|
226
228
|
"```",
|
|
227
229
|
"",
|
|
228
|
-
|
|
230
|
+
PRODUCTION_HEADING,
|
|
229
231
|
...production.filter((r) => !seen.has(refLine(r)) && seen.add(refLine(r)) !== undefined).map((r) => `- ${shown(r)}`),
|
|
230
|
-
|
|
232
|
+
CODE_ELEMENTS_LINE,
|
|
231
233
|
...elements,
|
|
232
|
-
|
|
234
|
+
appliedRulesLine(sheet.appliedRules, sheet.accessCost),
|
|
233
235
|
...carried.lines,
|
|
234
236
|
"",
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
237
|
+
RULES_HEADING,
|
|
238
|
+
neverWriteTestRule(testsWhere(layout)),
|
|
239
|
+
LEAST_CODE_RULE,
|
|
240
|
+
greenRunRule(input.testCommand),
|
|
239
241
|
`- ${NODE_READ_RULE}`,
|
|
240
242
|
`- ${BOUNDED_READ_RULE}`,
|
|
241
243
|
`- ${NODE_EDIT_RULE}`,
|
|
242
244
|
`- ${ASSUMPTION_RULE}`,
|
|
243
245
|
"",
|
|
244
|
-
|
|
246
|
+
GREEN_ANSWER,
|
|
245
247
|
].join("\n");
|
|
246
248
|
}
|
|
247
249
|
|
|
248
|
-
/** The first line of the stale block: what the review of the batch left open once its dependencies merged. */
|
|
249
|
-
export const STALE_HEADING = "Stale after the merged dependencies (the reviewer's open questions; settle each by the delivered value it names, or say why not):";
|
|
250
|
-
|
|
251
250
|
/** The block that ends a role's prompt with the `stale:` lines the next batch's review handed the launch (its Major
|
|
252
251
|
* rows); "" without any. */
|
|
253
252
|
export function staleBlock(lines: readonly string[]): string {
|
|
@@ -3,16 +3,21 @@
|
|
|
3
3
|
// `## Anchors` row copied from the step it corrects, so that it runs as any step, RED first. The earlier steps
|
|
4
4
|
// and their evidence stay as they are. A finding naming an id the sheet does not carry changes the scope: it is
|
|
5
5
|
// refused and routed. Pure, never throws.
|
|
6
|
+
import { OPEN_TDD_LINE, STEP_TESTS_TABLE_HEAD } from "../../../shared/domain/dev/markers.ts";
|
|
6
7
|
import { unfencedLines } from "../../../shared/domain/dev/plan-format.ts";
|
|
7
8
|
import { parseImplementSheet } from "./step-section.ts";
|
|
8
9
|
import type { ImplementSheet, ImplementStep } from "./step-section.ts";
|
|
10
|
+
import { CORRECTION_TITLE, correctionTitle } from "./markers.ts";
|
|
11
|
+
import {
|
|
12
|
+
ANCHORS_HAVE_NO_ROW, CORRECTION_NAMES_NO_FINDING, NO_STEP_TO_CORRECT, SHEET_LACKS_TDD_OR_ANCHORS, correctionTestRow, correctsStep,
|
|
13
|
+
findingNamesUnknownIds,
|
|
14
|
+
} from "./messages.ts";
|
|
9
15
|
|
|
10
16
|
export type CorrectionEdit =
|
|
11
17
|
| { ok: true; text: string; step: number; title: string; appended: boolean }
|
|
12
18
|
| { ok: false; reason: string };
|
|
13
19
|
|
|
14
20
|
const IDS = /\b[A-Z][A-Z0-9]*-[0-9]+\b/g;
|
|
15
|
-
const CORRECTION_TITLE = /^Correction C(\d+) — (.*)$/;
|
|
16
21
|
const MAX_FINDING = 200;
|
|
17
22
|
|
|
18
23
|
/** The finding on one line, without the table's pipe, cut at 200 characters. */
|
|
@@ -47,17 +52,13 @@ const idPrefix = (id: string): string => id.replace(/-[0-9]+$/, "");
|
|
|
47
52
|
/** The sheet with the correction appended; an open correction with the same finding is kept, not appended again. */
|
|
48
53
|
export function addCorrection(text: string, findingRaw: string): CorrectionEdit {
|
|
49
54
|
const finding = cleanFinding(findingRaw);
|
|
50
|
-
if (finding === "") return { ok: false, reason:
|
|
55
|
+
if (finding === "") return { ok: false, reason: CORRECTION_NAMES_NO_FINDING };
|
|
51
56
|
// The ids the steps carry; a token of the same prefix they do not carry is a new id (`UTF-8`, `SHA-256` are not).
|
|
52
57
|
const carried = new Set(parseImplementSheet(text).steps.flatMap((s) => s.tests.flatMap((t) => t.ids)));
|
|
53
58
|
const prefixes = new Set([...carried].map(idPrefix));
|
|
54
59
|
const unknown = [...new Set(finding.match(IDS) ?? [])].filter((id) => prefixes.has(idPrefix(id)) && !carried.has(id));
|
|
55
60
|
if (unknown.length > 0) {
|
|
56
|
-
return {
|
|
57
|
-
ok: false,
|
|
58
|
-
reason: `the finding names ${unknown.join(", ")}, which the sheet does not carry: a new id changes the scope ` +
|
|
59
|
-
"(/dev-spec <code> <kind> for the change, then /dev-plan), never a correction",
|
|
60
|
-
};
|
|
61
|
+
return { ok: false, reason: findingNamesUnknownIds(unknown) };
|
|
61
62
|
}
|
|
62
63
|
const sheet = parseImplementSheet(text);
|
|
63
64
|
const corrections = sheet.steps.map((s) => CORRECTION_TITLE.exec(s.title)).filter((m): m is RegExpExecArray => m !== null);
|
|
@@ -66,10 +67,10 @@ export function addCorrection(text: string, findingRaw: string): CorrectionEdit
|
|
|
66
67
|
if (same !== undefined) return { ok: true, text, step: same.number, title: same.title, appended: false };
|
|
67
68
|
|
|
68
69
|
const target = targetStep(sheet, finding);
|
|
69
|
-
if (target === null || target.anchor === null) return { ok: false, reason:
|
|
70
|
+
if (target === null || target.anchor === null) return { ok: false, reason: NO_STEP_TO_CORRECT };
|
|
70
71
|
const k = corrections.reduce((max, m) => Math.max(max, Number(m[1])), 0) + 1;
|
|
71
72
|
const number = sheet.steps.reduce((max, s) => Math.max(max, s.number), 0) + 1;
|
|
72
|
-
const title =
|
|
73
|
+
const title = correctionTitle(k, finding);
|
|
73
74
|
const base = target.tests[0];
|
|
74
75
|
const ids = [...new Set(target.tests.flatMap((t) => t.ids))].join(", ") || "—";
|
|
75
76
|
|
|
@@ -77,19 +78,19 @@ export function addCorrection(text: string, findingRaw: string): CorrectionEdit
|
|
|
77
78
|
const lines = unfencedLines(text);
|
|
78
79
|
const tdd = sectionEnd(lines, "## TDD sequence", raw.length);
|
|
79
80
|
const anchors = sectionEnd(lines, "## Anchors", raw.length);
|
|
80
|
-
if (tdd === null || anchors === null) return { ok: false, reason:
|
|
81
|
+
if (tdd === null || anchors === null) return { ok: false, reason: SHEET_LACKS_TDD_OR_ANCHORS };
|
|
81
82
|
const lastRow = lines.filter((l) => l.line > anchors.start && l.line < anchors.end && l.text.startsWith("|")).pop();
|
|
82
|
-
if (lastRow === undefined) return { ok: false, reason:
|
|
83
|
+
if (lastRow === undefined) return { ok: false, reason: ANCHORS_HAVE_NO_ROW };
|
|
83
84
|
|
|
84
85
|
const cell = (refs: NonNullable<ImplementStep["anchor"]>["testFiles"]): string => refs.length === 0 ? "—"
|
|
85
86
|
: refs.map((r) => `\`${r.line === undefined ? r.path : `${r.path}:${r.line}`}\` — ${r.state === "member" ? `\`${r.member}\`` : "existing"}`).join("; ");
|
|
86
87
|
const anchorRow = `| ${number} — Correction C${k} | ${cell(target.anchor.testFiles)} | ${target.anchor.doubles || "—"} | ${cell(target.anchor.production)} |`;
|
|
87
88
|
const stepBlock = [
|
|
88
89
|
`### Step ${number} — ${title}`,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
correctsStep(target.number, target.title),
|
|
91
|
+
...STEP_TESTS_TABLE_HEAD,
|
|
92
|
+
correctionTestRow(k, base?.level ?? "unit", base?.project ?? "", ids),
|
|
93
|
+
OPEN_TDD_LINE, "",
|
|
93
94
|
];
|
|
94
95
|
// Anchors first (it may lie after the TDD sequence), so the TDD insertion point keeps its index.
|
|
95
96
|
const out = [...raw];
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// on its file is a cycle of one. Pure.
|
|
5
5
|
import type { ImplementStep } from "./step-section.ts";
|
|
6
6
|
import { testFileOf } from "./contracts.ts";
|
|
7
|
+
import { NO_TEST_FILE } from "./messages.ts";
|
|
7
8
|
|
|
8
9
|
export interface Cycle { steps: ImplementStep[]; testFile: string | null }
|
|
9
10
|
|
|
@@ -31,5 +32,5 @@ export function stepsLabel(steps: readonly ImplementStep[]): string {
|
|
|
31
32
|
|
|
32
33
|
/** The line announcing the mapping, before the first RED. */
|
|
33
34
|
export function cyclesLine(cycles: readonly Cycle[]): string {
|
|
34
|
-
return cycles.map((c, i) => `cycle ${i + 1}/${cycles.length} — ${stepsLabel(c.steps)} (${c.testFile ??
|
|
35
|
+
return cycles.map((c, i) => `cycle ${i + 1}/${cycles.length} — ${stepsLabel(c.steps)} (${c.testFile ?? NO_TEST_FILE})`).join("; ");
|
|
35
36
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// The markers of /dev-implement: the headings, titles and lines a brief or a sheet edit writes and a parser of the
|
|
2
|
+
// crew reads back (ADR 0026).
|
|
3
|
+
|
|
4
|
+
/** The title of a correction step, `Correction C<k> — <finding>`, written by correction.ts and read by the briefs. */
|
|
5
|
+
export const CORRECTION_TITLE = /^Correction C(\d+) — (.*)$/;
|
|
6
|
+
|
|
7
|
+
/** The same title read by the briefs, its label (`C<k>`) whole. */
|
|
8
|
+
export const CORRECTION_LABEL = /^Correction (C\d+) — (.*)$/;
|
|
9
|
+
|
|
10
|
+
export const correctionTitle = (k: number, finding: string): string => `Correction C${k} — ${finding}`;
|
|
11
|
+
|
|
12
|
+
/** The first line of the stale block: what the review of the batch left open once its dependencies merged. */
|
|
13
|
+
export const STALE_HEADING = "Stale after the merged dependencies (the reviewer's open questions; settle each by the delivered value it names, or say why not):";
|
|
14
|
+
|
|
15
|
+
// ── The implementer's Cost line ─────────────────────────────────────────────
|
|
16
|
+
|
|
17
|
+
const PLACE = "(?:a |any |one )?(?:loops?|lambdas?|memory filters?)";
|
|
18
|
+
/** The one "where" that clears a line naming a loop, a lambda or a memory filter: none of them holds a port call. */
|
|
19
|
+
export const NONE_WHERE = new RegExp(
|
|
20
|
+
`^(?:none|nothing|no port call(?: (?:in|inside|within) ${PLACE}(?:,? (?:or |nor )?${PLACE})*)?)\\.?$`, "i");
|
|
21
|
+
|
|
22
|
+
/** The opening of every stop at a batch's close: the close writes it, /dev-batches reads it to tell a close stop. */
|
|
23
|
+
export const CLOSE_STOP = "BLOCKED — close:";
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// The problems the domain of /dev-implement states: why a test command, a correction, a tick or a step check does
|
|
2
|
+
// not hold (ADR 0026).
|
|
3
|
+
|
|
4
|
+
// ── Test commands (contracts.ts) ────────────────────────────────────────────
|
|
5
|
+
|
|
6
|
+
export const stepNamesNoTestFile = (step: number): string => `step ${step} names no test file in ## Anchors`;
|
|
7
|
+
export const PACK_HAS_NO_CLASS_OR_PROJECT_TEST = "the pack has no commands.test_class or commands.test_project";
|
|
8
|
+
export const PACK_HAS_NO_TEST_PROJECT = "the pack has no commands.test_project";
|
|
9
|
+
|
|
10
|
+
// ── Corrections (correction.ts) ─────────────────────────────────────────────
|
|
11
|
+
|
|
12
|
+
export const CORRECTION_NAMES_NO_FINDING = "the correction names no finding: — correction: <finding>";
|
|
13
|
+
export const findingNamesUnknownIds = (ids: readonly string[]): string =>
|
|
14
|
+
`the finding names ${ids.join(", ")}, which the sheet does not carry: a new id changes the scope ` +
|
|
15
|
+
"(/dev-spec <code> <kind> for the change, then /dev-plan), never a correction";
|
|
16
|
+
export const NO_STEP_TO_CORRECT = "the sheet has no step with a test file to correct";
|
|
17
|
+
export const SHEET_LACKS_TDD_OR_ANCHORS = "the sheet lacks ## TDD sequence or ## Anchors";
|
|
18
|
+
export const ANCHORS_HAVE_NO_ROW = "the sheet's ## Anchors has no row";
|
|
19
|
+
export const correctsStep = (number: number, title: string): string => `Corrects step ${number} (${title}); its earlier evidence stays.`;
|
|
20
|
+
export const correctionTestRow = (k: number, level: string, project: string, ids: string): string =>
|
|
21
|
+
`| 1 | \`C${k}: the test the author names\` | ${level} | \`${project}\` | ${ids} |`;
|
|
22
|
+
|
|
23
|
+
// ── Cycles (cycles.ts) ──────────────────────────────────────────────────────
|
|
24
|
+
|
|
25
|
+
export const NO_TEST_FILE = "no test file";
|
|
26
|
+
|
|
27
|
+
// ── Ticks (sheet-ticks.ts) ──────────────────────────────────────────────────
|
|
28
|
+
|
|
29
|
+
export const sheetHasNoStep = (step: number): string => `the sheet has no step ${step}`;
|
|
30
|
+
export const stepHasNoTddLine = (step: number): string => `step ${step} has no TDD line`;
|
|
31
|
+
export const notTheTddLine = (line: number, step: number): string => `line ${line} is not step ${step}'s TDD line`;
|
|
32
|
+
export const tddLineHasNoBox = (step: number, box: string): string => `step ${step}'s TDD line has no ${box} box`;
|
|
33
|
+
|
|
34
|
+
// ── Step checks (step-checks.ts) ────────────────────────────────────────────
|
|
35
|
+
|
|
36
|
+
export const testsDidNotRun = (reason: string): string => `the step's tests did not run: ${reason}`;
|
|
37
|
+
export const TESTS_TIMED_OUT = "the step's tests timed out";
|
|
38
|
+
export const TEST_AUTHOR_CHANGED_NOTHING = "the test author changed no file";
|
|
39
|
+
export const productionChangedBeforeRed = (paths: readonly string[]): string =>
|
|
40
|
+
`a production path changed before a red test: ${paths.join(", ")}`;
|
|
41
|
+
export const onlyStubsChanged = (paths: readonly string[]): string =>
|
|
42
|
+
`the test author changed no test file, only stubs: ${paths.join(", ")}`;
|
|
43
|
+
export const NEW_TESTS_PASS_AT_ONCE = "the new tests pass at once: a test green before its code is never kept";
|
|
44
|
+
export const noFailureAdded = (before: number, after: number): string =>
|
|
45
|
+
`the new tests add no failure (failures ${before} → ${after}): a test green before its code is never kept`;
|
|
46
|
+
export const testFileChangedAtGreen = (paths: readonly string[]): string =>
|
|
47
|
+
`a test file changed while turning it green: ${paths.join(", ")}`;
|
|
48
|
+
export const testsStillFail = (exit: number): string => `the step's tests still fail (exit ${exit})`;
|
|
49
|
+
export const GREEN_BY_ITSELF =
|
|
50
|
+
"the implementer changed no file, yet the tests that failed before now pass: a test that turns green by itself is flaky";
|
|
51
|
+
export const NO_COST_LINE = "the implementer stated no Cost line";
|
|
52
|
+
export const portCallInLoop = (line: string): string =>
|
|
53
|
+
`a port call in a loop, a lambda or a memory filter: back to /dev-plan (${line})`;
|
|
54
|
+
|
|
55
|
+
// ── The sheet (step-section.ts) ─────────────────────────────────────────────
|
|
56
|
+
|
|
57
|
+
export const anchorsRowNamesMissingStep = (step: string): string => `an Anchors row names step ${step}, which the sheet lacks`;
|
|
58
|
+
export const tddLineWithoutTest = (step: number): string => `step ${step} has a TDD line and no test`;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// The prompts of /dev-implement: the system texts of its two roles and the prose of the RED and GREEN briefs that
|
|
2
|
+
// contracts.ts assembles from the sheet (ADR 0026).
|
|
3
|
+
|
|
4
|
+
// ── The roles (roles.ts) ────────────────────────────────────────────────────
|
|
5
|
+
|
|
6
|
+
export const TEST_AUTHOR_SYSTEM = [
|
|
7
|
+
"You are the test author of one step of a dev batch. You write the failing tests the brief names, in the test",
|
|
8
|
+
"file it names, and nothing else: no production line. The one exception is the signature stubs the brief allows",
|
|
9
|
+
"in production files still to create: declarations that throw \"not implemented\", no logic, so that the tests",
|
|
10
|
+
"compile. A test that fails on a missing symbol is red.",
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
export const IMPLEMENTER_SYSTEM = [
|
|
14
|
+
"You are the implementer of one step of a dev batch. You write the least production code that turns the red",
|
|
15
|
+
"tests of the brief green, then refactor and delete what that orphaned. Test files are read-only to you.",
|
|
16
|
+
"You end your answer with the step's Cost line.",
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
// ── The parts of a brief (contracts.ts) ─────────────────────────────────────
|
|
20
|
+
|
|
21
|
+
export const STUB_EXISTING = "existing: only a declaration the new tests import and it lacks";
|
|
22
|
+
export const STUB_OF_EARLIER_RED = "a stub an earlier RED of this cycle wrote";
|
|
23
|
+
export const THE_TEST_FILES = "the test files";
|
|
24
|
+
export const NONE_NAMED = "none named";
|
|
25
|
+
export const NO_ID = "no id";
|
|
26
|
+
|
|
27
|
+
export const ASSUMPTION_RULE = "A question that changes no scope, id or design decision is settled by you: say it as a line " +
|
|
28
|
+
"`Assumption: <what you assumed>`, only for a behaviour the plan leaves open (an error, a rounding, an edge), once. " +
|
|
29
|
+
"A test value, a stub's wording or a file's state is your choice or a fact, never an assumption. Never one the " +
|
|
30
|
+
"sheet's `## Assumptions` already holds, in any wording: the sheet is in your brief, and an assumption is recorded " +
|
|
31
|
+
"once per batch.";
|
|
32
|
+
|
|
33
|
+
export const memberRefLine = (at: string, member: string | undefined): string =>
|
|
34
|
+
`\`${at}\` — \`${member}\` (read that member with node_read, never the file whole)`;
|
|
35
|
+
|
|
36
|
+
export const TEST_FILE_IN_BRIEF = "its text is in this brief (node_outline for the anchor at most): add the tests with node_insert inside its suite, never rewrite it whole";
|
|
37
|
+
export const TEST_FILE_TO_CREATE = "create it with file_write; once it exists, add to it by node";
|
|
38
|
+
export const TEST_FILE_EXISTING = "read it by node (node_outline, then node_read), add the tests with node_insert inside its suite, never rewrite it whole";
|
|
39
|
+
|
|
40
|
+
export const UNIT_LEVEL_RULE = "- unit: no IO; the ports are the doubles the Anchors row names, the builders it names reused, never a new double of the same port.";
|
|
41
|
+
export const INTEGRATION_LEVEL_RULE = "- integration: the real adapter the test policy names, its fixture shared, nothing faked inside the adapter.";
|
|
42
|
+
export const ANY_LEVEL_RULE = "- the level the table names";
|
|
43
|
+
|
|
44
|
+
export const oneStep = (number: number, title: string): string => `step ${number}: ${title}`;
|
|
45
|
+
export const stepsOfOneBehaviour = (numbers: string, titles: string): string => `steps ${numbers} (one behaviour): ${titles}`;
|
|
46
|
+
export const briefTitle = (role: string, code: string, batch: string, what: string): string => `# ${role} — ${code} batch ${batch}, ${what}`;
|
|
47
|
+
export const sheetLine = (sheetPath: string, ids: string): string =>
|
|
48
|
+
`Sheet: \`${sheetPath}\` (do not edit it: code ticks its boxes). Ids: ${ids}.`;
|
|
49
|
+
export const testRow = (index: number, name: string, level: string, project: string, ids: string): string =>
|
|
50
|
+
`${index}. \`${name}\` — ${level}, project \`${project}\`, ${ids}`;
|
|
51
|
+
|
|
52
|
+
export const IN_THIS_BRIEF_HEADING = "## In this brief (do not open these files again)";
|
|
53
|
+
|
|
54
|
+
// ── The RED brief ───────────────────────────────────────────────────────────
|
|
55
|
+
|
|
56
|
+
export const TESTS_TO_WRITE_HEADING = "## The tests to write";
|
|
57
|
+
export const correctionOfFinding = (label: string, finding: string): string => `A correction (${label}) of an audit's finding: ${finding}`;
|
|
58
|
+
export const WRITE_FAILING_TESTS_FOR_FINDING = "Write the test (or tests) that fail on this finding today; the names are yours, in the style of the file.";
|
|
59
|
+
export const FILES_HEADING = "## Files";
|
|
60
|
+
export const testFileLine = (ref: string, rule: string): string => `- test file: ${ref} — ${rule}`;
|
|
61
|
+
export const doublesLine = (doubles: string): string => `- shared doubles and builders: ${doubles}`;
|
|
62
|
+
export const SIGNATURE_STUB_AT_MOST = "a signature stub at most";
|
|
63
|
+
export const READ_ONLY_NEVER_WRITE = "read only, never write";
|
|
64
|
+
export const productionLine = (access: string, ref: string): string => `- production it will drive (${access}): ${ref}`;
|
|
65
|
+
export const RULES_HEADING = "## Rules";
|
|
66
|
+
export const testFilesOnlyRule = (where: string): string =>
|
|
67
|
+
`- Write test files only (${where}): no production line; a test failing on a missing symbol is red.`;
|
|
68
|
+
export const stubsRule = (stubs: string): string =>
|
|
69
|
+
`- The one exception: signature stubs, declarations that throw "not implemented" and hold no logic, in ${stubs}.`;
|
|
70
|
+
export const STUB_IMPORT_RULE = "- A test whose import of a missing declaration fails the whole test file is not the red asked: stub the declaration, never work around the import.";
|
|
71
|
+
export const ONE_TEST_PER_ROW_RULE = "- One test per row of the table, its name as written; the passing path first, then the refusals.";
|
|
72
|
+
export const redRunRule = (command: string): string =>
|
|
73
|
+
`- Run \`${command}\` with run_tests once the tests are written: every new test must fail; the result lists the failed tests, so the log stays closed. Code runs it again after you.`;
|
|
74
|
+
export const RED_ANSWER = "Answer with the test names you wrote, the test file, and the reason each one fails.";
|
|
75
|
+
|
|
76
|
+
// ── The GREEN brief ─────────────────────────────────────────────────────────
|
|
77
|
+
|
|
78
|
+
export const STUBBED_AT_RED = "existing (stubbed at RED)";
|
|
79
|
+
export const inThisBrief = (line: string): string => `${line}, in this brief`;
|
|
80
|
+
export const RED_TESTS_HEADING = "## The red tests";
|
|
81
|
+
export const stepLabel = (number: number, title: string): string => `Step ${number} — ${title}:`;
|
|
82
|
+
export const lastRedRun = (inBrief: boolean, files: string, log: string | null): string =>
|
|
83
|
+
`Test file (read only${inBrief ? ", in this brief" : ""}): ${files}. Last red run${log === null ? "" : ` (whole output: \`${log}\`)`}:`;
|
|
84
|
+
export const PRODUCTION_HEADING = "## Production";
|
|
85
|
+
export const NONE_LISTED = "none listed";
|
|
86
|
+
export const CODE_ELEMENTS_LINE = "Code elements of the batch:";
|
|
87
|
+
export const appliedRulesLine = (rules: string, cost: string): string =>
|
|
88
|
+
`Applied rules: ${rules || NONE_NAMED}. Expected access cost: ${cost || "not stated"}.`;
|
|
89
|
+
export const neverWriteTestRule = (where: string): string => `- Never write a test file (${where}): the tests are read-only to you.`;
|
|
90
|
+
export const LEAST_CODE_RULE = "- The least code that turns these tests green; then refactor, and delete what that orphaned.";
|
|
91
|
+
export const greenRunRule = (command: string): string =>
|
|
92
|
+
`- Run \`${command}\` with run_tests until it passes; run_build when the build is in doubt. Code runs the tests again after you.`;
|
|
93
|
+
export const GREEN_ANSWER = "Answer with the files you changed and one line `Cost: <reads> reads, <writes> writes; <where a port call sits in a loop, a lambda or a memory filter, or none>`.";
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// file, and neither rewrites an existing source file whole (the rewrite rule): both read and edit by
|
|
5
5
|
// node. Neither gets shell_command: tests and builds go through run_tests and run_build. Pure.
|
|
6
6
|
import { BOUNDED_READ_RULE, KNOWN_TOOLS_RULE, NODE_EDIT_RULE, NODE_READ_RULE } from "../../../shared/domain/dev/reading-rule.ts";
|
|
7
|
+
import { IMPLEMENTER_SYSTEM, TEST_AUTHOR_SYSTEM } from "./prompts.ts";
|
|
7
8
|
|
|
8
9
|
export type RoleName = "test-author" | "implementer";
|
|
9
10
|
|
|
@@ -20,10 +21,7 @@ const WRITE_TOOLS = ["file_write", "edit_file", "node_replace", "node_insert", "
|
|
|
20
21
|
export const TEST_AUTHOR: RoleSpec = {
|
|
21
22
|
name: "test-author",
|
|
22
23
|
system: [
|
|
23
|
-
|
|
24
|
-
"file it names, and nothing else: no production line. The one exception is the signature stubs the brief allows",
|
|
25
|
-
"in production files still to create: declarations that throw \"not implemented\", no logic, so that the tests",
|
|
26
|
-
"compile. A test that fails on a missing symbol is red.",
|
|
24
|
+
...TEST_AUTHOR_SYSTEM,
|
|
27
25
|
NODE_READ_RULE,
|
|
28
26
|
BOUNDED_READ_RULE,
|
|
29
27
|
NODE_EDIT_RULE,
|
|
@@ -36,9 +34,7 @@ export const TEST_AUTHOR: RoleSpec = {
|
|
|
36
34
|
export const IMPLEMENTER: RoleSpec = {
|
|
37
35
|
name: "implementer",
|
|
38
36
|
system: [
|
|
39
|
-
|
|
40
|
-
"tests of the brief green, then refactor and delete what that orphaned. Test files are read-only to you.",
|
|
41
|
-
"You end your answer with the step's Cost line.",
|
|
37
|
+
...IMPLEMENTER_SYSTEM,
|
|
42
38
|
NODE_READ_RULE,
|
|
43
39
|
BOUNDED_READ_RULE,
|
|
44
40
|
NODE_EDIT_RULE,
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
// role settled mid-batch (rows `| H<n> | <text> | the user |` of `## Assumptions`), and at the close
|
|
3
3
|
// the done marks - the sheet's title ` — done (<date>)`, the plan's `### Batch F<n> — <Name> — done (<date>)` and
|
|
4
4
|
// its step boxes ticked. Each edit is idempotent. Pure, never throws.
|
|
5
|
+
import {
|
|
6
|
+
ASSUMPTIONS_SECTION, ASSUMPTIONS_TABLE_HEAD as TABLE_HEAD, DECISIONS_SECTION,
|
|
7
|
+
} from "../../../shared/domain/dev/markers.ts";
|
|
5
8
|
import { parseBatchSheet, unfencedLines } from "../../../shared/domain/dev/plan-format.ts";
|
|
6
9
|
|
|
7
10
|
/** An answer's way of saying it assumed nothing: `none`, `none needed — …`, `n/a`, `nothing`. */
|
|
@@ -18,8 +21,6 @@ export function assumptionsOf(answer: string): string[] {
|
|
|
18
21
|
return out;
|
|
19
22
|
}
|
|
20
23
|
|
|
21
|
-
const TABLE_HEAD = ["| # | Assumption | To be validated by |", "|---|------------|--------------------|"];
|
|
22
|
-
|
|
23
24
|
/** The sheet with each new assumption as an `H<n>` row of the `## Assumptions` table (`/dev-plan` renders it empty;
|
|
24
25
|
* the section created before `## Decisions`, else at the end), numbered after the rows it holds, the list lines of
|
|
25
26
|
* older sheets counted; an assumption already written is not written again. */
|
|
@@ -33,7 +34,7 @@ export function addAssumptions(text: string, assumptions: readonly string[]): {
|
|
|
33
34
|
const rows = added.map((a) => `| H${++n} | ${a} | the user |`);
|
|
34
35
|
const raw = text.split("\n");
|
|
35
36
|
const lines = unfencedLines(text);
|
|
36
|
-
const at = lines.findIndex((l) => l.text.trim() ===
|
|
37
|
+
const at = lines.findIndex((l) => l.text.trim() === ASSUMPTIONS_SECTION);
|
|
37
38
|
if (at >= 0) {
|
|
38
39
|
const next = lines.slice(at + 1).find((l) => l.text.startsWith("## "));
|
|
39
40
|
let end = next === undefined ? raw.length : next.line - 1;
|
|
@@ -44,8 +45,8 @@ export function addAssumptions(text: string, assumptions: readonly string[]): {
|
|
|
44
45
|
raw.splice(end, 0, ...(table ? rows : [...(body.length > 0 ? [""] : []), ...TABLE_HEAD, ...rows]));
|
|
45
46
|
return { text: raw.join("\n"), added };
|
|
46
47
|
}
|
|
47
|
-
const decisions = lines.find((l) => l.text.trim() ===
|
|
48
|
-
const block = [
|
|
48
|
+
const decisions = lines.find((l) => l.text.trim() === DECISIONS_SECTION);
|
|
49
|
+
const block = [ASSUMPTIONS_SECTION, ...TABLE_HEAD, ...rows, ""];
|
|
49
50
|
if (decisions !== undefined) raw.splice(decisions.line - 1, 0, ...block);
|
|
50
51
|
else raw.push(...(raw[raw.length - 1]?.trim() === "" ? [] : [""]), ...block);
|
|
51
52
|
return { text: raw.join("\n"), added };
|