orkeon-code 0.0.0-stage → 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 -0
- package/LICENSE.md +21 -0
- package/NOTICE.md +17 -0
- package/README.fr.md +163 -0
- package/README.md +156 -2
- package/config/appsettings.anthropic.example.json +77 -0
- package/config/appsettings.example.json +71 -0
- package/config/appsettings.jev.example.json +131 -0
- package/config/appsettings.kev.example.json +133 -0
- package/config/appsettings.liquid.example.json +132 -0
- package/config/appsettings.ollama-whisper.example.json +93 -0
- package/config/appsettings.ollama.example.json +70 -0
- package/config/appsettings.whisper.example.json +32 -0
- package/mcp/whisper/README.md +294 -0
- package/mcp/whisper/pyproject.toml +32 -0
- package/mcp/whisper/uv.lock +1641 -0
- package/mcp/whisper/whisper_mcp.py +1053 -0
- package/orkeon-code +1092 -0
- package/orkeon-code.mjs +71 -0
- package/orkeon-code.ps1 +939 -0
- package/package.json +58 -4
- package/scripts/install.ps1 +156 -0
- package/scripts/install.sh +148 -0
- package/scripts/session-start.ork.ts +90 -0
- package/scripts/session-start.sh +74 -0
- package/scripts/setup-fixture.sh +88 -0
- package/src/commands/.orkeon/orkeon-cli.d.ts +559 -0
- package/src/commands/_lib/args.ts +194 -0
- package/src/commands/_lib/dev/dev-batches.ts +366 -0
- package/src/commands/_lib/dev/dev-implement.ts +185 -0
- package/src/commands/_lib/dev/dev-source.ts +61 -0
- package/src/commands/_lib/dev/dev.ts +341 -0
- 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 +145 -0
- package/src/commands/_lib/dispatch.ts +254 -0
- package/src/commands/_lib/effort.ts +15 -0
- package/src/commands/_lib/git/branch.ts +94 -0
- package/src/commands/_lib/git/commit.ts +90 -0
- package/src/commands/_lib/git/diff.ts +107 -0
- package/src/commands/_lib/git/messages.ts +54 -0
- package/src/commands/_lib/git/review.ts +108 -0
- package/src/commands/_lib/memory/memory-admit.ts +148 -0
- package/src/commands/_lib/memory/memory.ts +52 -0
- package/src/commands/_lib/memory/messages.ts +32 -0
- package/src/commands/_lib/messages.ts +48 -0
- package/src/commands/_lib/pr-context.ts +32 -0
- package/src/commands/_lib/project/analyze.ts +24 -0
- package/src/commands/_lib/project/messages.ts +8 -0
- package/src/commands/_lib/session/export.ts +105 -0
- 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 +151 -0
- package/src/commands/_lib/session/tasks.ts +181 -0
- package/src/commands/_lib/settings/advisor.ts +75 -0
- package/src/commands/_lib/settings/agents.ts +137 -0
- package/src/commands/_lib/settings/choices.ts +8 -0
- package/src/commands/_lib/settings/config.ts +141 -0
- package/src/commands/_lib/settings/effort.ts +147 -0
- package/src/commands/_lib/settings/hooks.ts +50 -0
- package/src/commands/_lib/settings/messages.ts +408 -0
- package/src/commands/_lib/settings/mode.ts +100 -0
- package/src/commands/_lib/settings/model.ts +181 -0
- package/src/commands/_lib/settings/output-style.ts +39 -0
- package/src/commands/_lib/settings/permissions.ts +287 -0
- package/src/commands/_lib/settings/route.ts +63 -0
- package/src/commands/_lib/settings/session-config.ts +49 -0
- package/src/commands/_lib/settings/skills.ts +93 -0
- 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 +95 -0
- package/src/commands/_lib/speech/transcribe.ts +121 -0
- package/src/commands/_lib/speech/voice.ts +142 -0
- package/src/commands/_lib/status/cache.ts +31 -0
- package/src/commands/_lib/status/context.ts +57 -0
- package/src/commands/_lib/status/doctor.ts +205 -0
- package/src/commands/_lib/status/messages.ts +100 -0
- package/src/commands/_lib/status/meta.ts +24 -0
- package/src/commands/_lib/status/status.ts +128 -0
- package/src/commands/_lib/status/usage-tools.ts +48 -0
- package/src/commands/_lib/status/usage.ts +128 -0
- package/src/commands/_lib/view.ts +34 -0
- package/src/commands/dev/dev-batches.cmd.ts +109 -0
- package/src/commands/dev/dev-learn.cmd.ts +29 -0
- package/src/commands/dev/dev-plan.cmd.ts +51 -0
- package/src/commands/dev/dev-spec.cmd.ts +54 -0
- package/src/commands/dev/dev-status.cmd.ts +16 -0
- package/src/commands/git/branch.cmd.ts +27 -0
- package/src/commands/git/commit.cmd.ts +48 -0
- package/src/commands/git/diff.cmd.ts +26 -0
- package/src/commands/git/review.cmd.ts +36 -0
- package/src/commands/memory/memory.cmd.ts +48 -0
- package/src/commands/project/analyze.cmd.ts +32 -0
- package/src/commands/project/debug-tool-call.cmd.ts +62 -0
- package/src/commands/project/files.cmd.ts +22 -0
- package/src/commands/project/init-verifiers.cmd.ts +14 -0
- package/src/commands/project/init.cmd.ts +14 -0
- package/src/commands/project/verify.cmd.ts +27 -0
- package/src/commands/session/assistant.cmd.ts +40 -0
- package/src/commands/session/btw.cmd.ts +18 -0
- package/src/commands/session/clear.cmd.ts +19 -0
- package/src/commands/session/compact.cmd.ts +16 -0
- package/src/commands/session/copy.cmd.ts +45 -0
- package/src/commands/session/exit.cmd.ts +9 -0
- package/src/commands/session/export.cmd.ts +28 -0
- package/src/commands/session/rename.cmd.ts +18 -0
- package/src/commands/session/resume.cmd.ts +19 -0
- package/src/commands/session/rewind.cmd.ts +25 -0
- package/src/commands/session/summary.cmd.ts +27 -0
- package/src/commands/session/tasks.cmd.ts +46 -0
- package/src/commands/settings/advisor.cmd.ts +38 -0
- package/src/commands/settings/agents.cmd.ts +19 -0
- package/src/commands/settings/config.cmd.ts +19 -0
- package/src/commands/settings/effort.cmd.ts +19 -0
- package/src/commands/settings/fast.cmd.ts +18 -0
- package/src/commands/settings/hooks.cmd.ts +17 -0
- package/src/commands/settings/mode.cmd.ts +20 -0
- package/src/commands/settings/model.cmd.ts +21 -0
- package/src/commands/settings/output-style.cmd.ts +19 -0
- package/src/commands/settings/permissions.cmd.ts +25 -0
- package/src/commands/settings/proactive.cmd.ts +16 -0
- package/src/commands/settings/route.cmd.ts +16 -0
- package/src/commands/settings/skills.cmd.ts +17 -0
- package/src/commands/settings/theme.cmd.ts +14 -0
- package/src/commands/speech/say.cmd.ts +24 -0
- package/src/commands/speech/transcribe.cmd.ts +29 -0
- package/src/commands/speech/voice.cmd.ts +30 -0
- package/src/commands/status/context.cmd.ts +18 -0
- package/src/commands/status/doctor.cmd.ts +27 -0
- package/src/commands/status/release-notes.cmd.ts +9 -0
- package/src/commands/status/status.cmd.ts +25 -0
- package/src/commands/status/usage.cmd.ts +21 -0
- package/src/crews/.orkeon/orkeon.d.ts +4391 -0
- package/src/crews/_probe-shared-memory/domain/messages.ts +54 -0
- package/src/crews/_probe-shared-memory/domain/probe-verdict.ts +188 -0
- package/src/crews/_probe-shared-memory/domain/prompts.ts +5 -0
- package/src/crews/_probe-shared-memory/probe.ork.ts +100 -0
- 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 +41 -0
- package/src/crews/advisor/crew.ork.ts +44 -0
- package/src/crews/advisor/domain/advice.ts +119 -0
- 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 +43 -0
- package/src/crews/agent-run/crew.ork.ts +67 -0
- 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 +120 -0
- package/src/crews/analyze/crew.ork.ts +41 -0
- package/src/crews/analyze/domain/harvest.ts +269 -0
- 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 +126 -0
- package/src/crews/code-review/application/review.ts +74 -0
- package/src/crews/code-review/application/run-code-review.ts +121 -0
- package/src/crews/code-review/crew.ork.ts +52 -0
- package/src/crews/code-review/domain/lenses.ts +154 -0
- 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 +58 -0
- package/src/crews/code-review/domain/scope.ts +106 -0
- package/src/crews/dev-batches/application/messages.ts +127 -0
- package/src/crews/dev-batches/application/plan-close.ts +181 -0
- package/src/crews/dev-batches/application/prompts.ts +10 -0
- package/src/crews/dev-batches/application/run-dev-batches.ts +676 -0
- package/src/crews/dev-batches/application/run-wave.ts +452 -0
- package/src/crews/dev-batches/application/seed-harvest.ts +163 -0
- package/src/crews/dev-batches/crew.ork.ts +146 -0
- package/src/crews/dev-batches/domain/batch-waves.ts +70 -0
- package/src/crews/dev-batches/domain/batches-budget.ts +52 -0
- package/src/crews/dev-batches/domain/batches-log.ts +52 -0
- 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 +44 -0
- package/src/crews/dev-change/application/change-material.ts +44 -0
- package/src/crews/dev-change/application/evidence.ts +172 -0
- package/src/crews/dev-change/application/messages.ts +81 -0
- package/src/crews/dev-change/application/prompts.ts +101 -0
- package/src/crews/dev-change/application/run-dev-change.ts +324 -0
- package/src/crews/dev-change/crew.ork.ts +114 -0
- package/src/crews/dev-change/domain/change-answer.ts +163 -0
- package/src/crews/dev-change/domain/change-render.ts +77 -0
- 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 +186 -0
- package/src/crews/dev-implement/application/count-open-steps.ts +24 -0
- package/src/crews/dev-implement/application/locate-sheet.ts +82 -0
- package/src/crews/dev-implement/application/messages.ts +161 -0
- package/src/crews/dev-implement/application/observe.ts +52 -0
- package/src/crews/dev-implement/application/prompts.ts +9 -0
- package/src/crews/dev-implement/application/report-writes.ts +46 -0
- package/src/crews/dev-implement/application/run-dev-implement.ts +822 -0
- package/src/crews/dev-implement/application/run-role.ts +27 -0
- package/src/crews/dev-implement/application/suite-job.ts +122 -0
- package/src/crews/dev-implement/application/touched.ts +74 -0
- package/src/crews/dev-implement/crew.ork.ts +69 -0
- package/src/crews/dev-implement/domain/contracts.ts +255 -0
- package/src/crews/dev-implement/domain/correction.ts +103 -0
- package/src/crews/dev-implement/domain/cycles.ts +36 -0
- package/src/crews/dev-implement/domain/implement-budget.ts +29 -0
- 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 +49 -0
- package/src/crews/dev-implement/domain/sheet-edits.ts +76 -0
- package/src/crews/dev-implement/domain/sheet-ticks.ts +23 -0
- package/src/crews/dev-implement/domain/step-checks.ts +137 -0
- package/src/crews/dev-implement/domain/step-section.ts +129 -0
- package/src/crews/dev-learn/application/learn-backlog.ts +58 -0
- 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/prompts.ts +99 -0
- package/src/crews/dev-learn/application/run-dev-learn.ts +558 -0
- package/src/crews/dev-learn/crew.ork.ts +53 -0
- package/src/crews/dev-learn/domain/learn-answer.ts +233 -0
- package/src/crews/dev-learn/domain/messages.ts +65 -0
- package/src/crews/dev-learn/domain/owner-lines.ts +89 -0
- package/src/crews/dev-learn/domain/proposals-render.ts +95 -0
- package/src/crews/dev-plan/application/anchor-paths.ts +113 -0
- package/src/crews/dev-plan/application/inventory.ts +174 -0
- 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/prompts.ts +141 -0
- package/src/crews/dev-plan/application/run-dev-plan.ts +483 -0
- package/src/crews/dev-plan/crew.ork.ts +112 -0
- package/src/crews/dev-plan/domain/inventory-model.ts +95 -0
- 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 +753 -0
- package/src/crews/dev-plan/domain/plan-render.ts +306 -0
- 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/prompts.ts +93 -0
- package/src/crews/dev-spec/application/run-dev-spec.ts +237 -0
- package/src/crews/dev-spec/application/spec-material.ts +42 -0
- package/src/crews/dev-spec/crew.ork.ts +110 -0
- 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 +252 -0
- package/src/crews/dev-spec/domain/spec-render.ts +76 -0
- package/src/crews/dev-verify/application/audit-brief.ts +187 -0
- package/src/crews/dev-verify/application/audit.ts +267 -0
- package/src/crews/dev-verify/application/capture.ts +311 -0
- 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 +423 -0
- package/src/crews/dev-verify/application/run-gate.ts +204 -0
- package/src/crews/dev-verify/crew.ork.ts +103 -0
- package/src/crews/dev-verify/domain/audit-answer.ts +154 -0
- package/src/crews/dev-verify/domain/auditor-charter.ts +21 -0
- package/src/crews/dev-verify/domain/capture-sections.ts +138 -0
- package/src/crews/dev-verify/domain/commands.ts +103 -0
- package/src/crews/dev-verify/domain/gate.ts +131 -0
- package/src/crews/dev-verify/domain/markers.ts +16 -0
- package/src/crews/dev-verify/domain/mechanical-table.ts +156 -0
- package/src/crews/dev-verify/domain/messages.ts +92 -0
- package/src/crews/dev-verify/domain/runtime-cut.ts +13 -0
- package/src/crews/dev-verify/domain/sheet-facts.ts +4 -0
- package/src/crews/dev-verify/domain/text.ts +20 -0
- package/src/crews/dev-verify/domain/verdict.ts +127 -0
- package/src/crews/git-commit/application/draft.ts +133 -0
- 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 +117 -0
- package/src/crews/git-commit/crew.ork.ts +53 -0
- package/src/crews/git-commit/domain/commit.ts +200 -0
- 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 +90 -0
- package/src/crews/init-verifiers/application/messages.ts +13 -0
- package/src/crews/init-verifiers/application/prompts.ts +107 -0
- package/src/crews/init-verifiers/application/run-init-verifiers.ts +26 -0
- package/src/crews/init-verifiers/crew.ork.ts +35 -0
- package/src/crews/init-verifiers/domain/commands-section.ts +36 -0
- package/src/crews/init-verifiers/domain/readiness.ts +23 -0
- package/src/crews/main-loop/application/auto-compact.ts +78 -0
- package/src/crews/main-loop/application/context-gather.ts +133 -0
- 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 +383 -0
- package/src/crews/main-loop/application/turn-context.ts +111 -0
- package/src/crews/main-loop/crew.ork.ts +124 -0
- package/src/crews/main-loop/domain/autocompact.ts +27 -0
- package/src/crews/main-loop/domain/prompt-assembly.ts +338 -0
- package/src/crews/main-loop/domain/prompts.ts +336 -0
- package/src/crews/main-loop/domain/turn-chains.ts +130 -0
- package/src/crews/project-init/application/detect.ts +123 -0
- package/src/crews/project-init/application/messages.ts +15 -0
- package/src/crews/project-init/application/prompts.ts +105 -0
- package/src/crews/project-init/application/run-project-init.ts +31 -0
- package/src/crews/project-init/crew.ork.ts +36 -0
- package/src/crews/project-init/domain/conventions.ts +36 -0
- package/src/crews/project-init/domain/existing-files.ts +65 -0
- package/src/crews/project-init/domain/messages.ts +13 -0
- package/src/crews/project-init/domain/package-map.ts +73 -0
- 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 +56 -0
- package/src/crews/shared-memory-admit/application/prompts.ts +5 -0
- package/src/crews/shared-memory-admit/crew.ork.ts +49 -0
- 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 +26 -0
- package/src/crews/speech/crew.ork.ts +38 -0
- package/src/shared/application/agents/child-agent.ts +259 -0
- 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 +119 -0
- package/src/shared/application/answer-language.ts +14 -0
- package/src/shared/application/attached-skills.ts +36 -0
- package/src/shared/application/compaction/compact-session.ts +242 -0
- package/src/shared/application/compaction/extract-memories.ts +38 -0
- 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/compaction/restore-context.ts +78 -0
- package/src/shared/application/config-store.ts +123 -0
- package/src/shared/application/dev/brief-inventory.ts +115 -0
- package/src/shared/application/dev/close-batch.ts +85 -0
- package/src/shared/application/dev/find-repo-pack.ts +78 -0
- package/src/shared/application/dev/learn-decision.ts +254 -0
- package/src/shared/application/dev/load-dev-context.ts +265 -0
- package/src/shared/application/dev/measure-access-cost.ts +69 -0
- 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 +116 -0
- package/src/shared/application/dev/preflight.ts +71 -0
- package/src/shared/application/dev/project-files.ts +17 -0
- package/src/shared/application/dev/prompts.ts +34 -0
- package/src/shared/application/dev/question-round.ts +60 -0
- package/src/shared/application/dev/resolve-work-folder.ts +134 -0
- package/src/shared/application/dev/script-tool-slot.ts +27 -0
- package/src/shared/application/dev/settle-questions.ts +57 -0
- package/src/shared/application/dev/source-review.ts +67 -0
- package/src/shared/application/dev/source-step.ts +152 -0
- package/src/shared/application/dev/spend.ts +55 -0
- package/src/shared/application/dev/step-precedents.ts +90 -0
- package/src/shared/application/dev/tool-call-policy.ts +87 -0
- package/src/shared/application/dev/tool-callbacks.ts +262 -0
- package/src/shared/application/dev/tool-trace-recorder.ts +46 -0
- package/src/shared/application/dev/verdict-sources.ts +50 -0
- package/src/shared/application/dev/wrapped-tools.ts +147 -0
- package/src/shared/application/extra-tools.ts +71 -0
- package/src/shared/application/git/batch-worktree.ts +102 -0
- package/src/shared/application/git/commit-files.ts +191 -0
- package/src/shared/application/git/merge-batch.ts +67 -0
- package/src/shared/application/git/messages.ts +75 -0
- package/src/shared/application/git/open-pull-request.ts +52 -0
- package/src/shared/application/host-context.ts +59 -0
- package/src/shared/application/host-layout-store.ts +45 -0
- package/src/shared/application/instructions-file.ts +19 -0
- package/src/shared/application/json-file.ts +34 -0
- package/src/shared/application/llm-profile.ts +36 -0
- package/src/shared/application/messages.ts +14 -0
- package/src/shared/application/permission-rules.ts +169 -0
- package/src/shared/application/ports/approvals.ts +20 -0
- package/src/shared/application/ports/clock.ts +5 -0
- package/src/shared/application/ports/code-index.ts +93 -0
- package/src/shared/application/ports/crew.ts +60 -0
- package/src/shared/application/ports/decision.ts +14 -0
- package/src/shared/application/ports/files.ts +21 -0
- package/src/shared/application/ports/human.ts +38 -0
- package/src/shared/application/ports/llm.ts +83 -0
- package/src/shared/application/ports/memory.ts +30 -0
- package/src/shared/application/ports/progress.ts +23 -0
- package/src/shared/application/ports/runtime.ts +15 -0
- package/src/shared/application/ports/session.ts +74 -0
- package/src/shared/application/ports/shared-memory.ts +26 -0
- package/src/shared/application/ports/shell.ts +40 -0
- package/src/shared/application/ports/telemetry.ts +45 -0
- package/src/shared/application/ports/theme.ts +11 -0
- package/src/shared/application/ports/tools.ts +46 -0
- package/src/shared/application/ports/usage.ts +45 -0
- package/src/shared/application/ports.ts +29 -0
- package/src/shared/application/project-manifests.ts +106 -0
- package/src/shared/application/session-io.ts +85 -0
- package/src/shared/application/session-state.ts +36 -0
- package/src/shared/application/shared-memory/admit-entries.ts +179 -0
- package/src/shared/application/shared-memory/harvest-after-gaps.ts +69 -0
- package/src/shared/application/shared-memory/harvest-mistakes.ts +45 -0
- package/src/shared/application/shared-memory/import-agent-memory.ts +119 -0
- package/src/shared/application/shared-memory/memory-files.ts +111 -0
- package/src/shared/application/shared-memory/memory-settings.ts +94 -0
- package/src/shared/application/shared-memory/messages.ts +63 -0
- package/src/shared/application/shared-memory/push-candidate.ts +149 -0
- package/src/shared/application/shared-memory/recall-precedents.ts +70 -0
- package/src/shared/application/skills/messages.ts +4 -0
- package/src/shared/application/skills/suggest-skills.ts +102 -0
- package/src/shared/application/state-snapshot.ts +38 -0
- package/src/shared/application/workflow/messages.ts +8 -0
- package/src/shared/application/workflow/workflow-state.ts +136 -0
- package/src/shared/domain/agent-policy/behavior-flags.ts +162 -0
- package/src/shared/domain/agent-policy/extra-tools.ts +67 -0
- package/src/shared/domain/agent-policy/memory-categories.ts +6 -0
- package/src/shared/domain/agent-policy/messages.ts +66 -0
- package/src/shared/domain/agent-policy/mode-policy.ts +51 -0
- package/src/shared/domain/agent-policy/output-styles.ts +11 -0
- package/src/shared/domain/agent-policy/path-rules.ts +299 -0
- package/src/shared/domain/agent-policy/permission.ts +625 -0
- 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 +416 -0
- package/src/shared/domain/agent-policy/tool-access.ts +91 -0
- package/src/shared/domain/agent-registry.ts +143 -0
- package/src/shared/domain/agents/built-in-charters.ts +43 -0
- package/src/shared/domain/agents/chain.ts +30 -0
- package/src/shared/domain/agents/charter.ts +64 -0
- package/src/shared/domain/agents/exclusive.ts +25 -0
- package/src/shared/domain/agents/instances.ts +252 -0
- 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 +357 -0
- package/src/shared/domain/code-intel-routing.ts +60 -0
- package/src/shared/domain/compact-outcome.ts +46 -0
- package/src/shared/domain/compaction-thresholds.ts +162 -0
- package/src/shared/domain/compaction.ts +288 -0
- package/src/shared/domain/config-schema.ts +434 -0
- 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 +230 -0
- package/src/shared/domain/dev/artefacts.ts +50 -0
- package/src/shared/domain/dev/batches-concurrency.ts +35 -0
- package/src/shared/domain/dev/batches-state.ts +49 -0
- package/src/shared/domain/dev/build-commands.ts +45 -0
- package/src/shared/domain/dev/call-guard.ts +342 -0
- package/src/shared/domain/dev/carried-text.ts +47 -0
- package/src/shared/domain/dev/design-rules.ts +100 -0
- package/src/shared/domain/dev/learn-proposals.ts +176 -0
- package/src/shared/domain/dev/learn-state.ts +94 -0
- package/src/shared/domain/dev/markers.ts +107 -0
- package/src/shared/domain/dev/messages.ts +259 -0
- package/src/shared/domain/dev/path-args.ts +42 -0
- package/src/shared/domain/dev/path-rebase.ts +93 -0
- package/src/shared/domain/dev/phase-timing.ts +50 -0
- package/src/shared/domain/dev/plan-checks.ts +191 -0
- package/src/shared/domain/dev/plan-format.ts +170 -0
- package/src/shared/domain/dev/project-files.ts +29 -0
- package/src/shared/domain/dev/prompts/brief-blocks.ts +20 -0
- package/src/shared/domain/dev/prompts.ts +251 -0
- package/src/shared/domain/dev/questions.ts +267 -0
- package/src/shared/domain/dev/reading-rule.ts +41 -0
- package/src/shared/domain/dev/repo-pack.ts +240 -0
- package/src/shared/domain/dev/review-answer.ts +173 -0
- package/src/shared/domain/dev/review-brief.ts +54 -0
- package/src/shared/domain/dev/reviewer-charter.ts +35 -0
- package/src/shared/domain/dev/sheet-facts.ts +81 -0
- package/src/shared/domain/dev/spec-format.ts +182 -0
- package/src/shared/domain/dev/step-budget.ts +74 -0
- package/src/shared/domain/dev/step-rules.ts +109 -0
- package/src/shared/domain/dev/test-commands.ts +94 -0
- package/src/shared/domain/dev/test-output.ts +33 -0
- package/src/shared/domain/dev/test-paths.ts +40 -0
- package/src/shared/domain/dev/tool-guards.ts +65 -0
- package/src/shared/domain/dev/trait-pattern.ts +87 -0
- package/src/shared/domain/dev/verdict-format.ts +162 -0
- package/src/shared/domain/dev/whitespace.ts +35 -0
- package/src/shared/domain/dev/work-folder.ts +68 -0
- package/src/shared/domain/dev/yaml-subset.ts +385 -0
- package/src/shared/domain/error-text.ts +13 -0
- package/src/shared/domain/git/close.ts +274 -0
- package/src/shared/domain/git/messages.ts +20 -0
- package/src/shared/domain/git/pull-request.ts +96 -0
- package/src/shared/domain/git/worktree.ts +46 -0
- package/src/shared/domain/host-layout.ts +147 -0
- package/src/shared/domain/host-paths.ts +399 -0
- package/src/shared/domain/index-languages.ts +16 -0
- package/src/shared/domain/instructions-file.ts +18 -0
- package/src/shared/domain/iso-day.ts +4 -0
- package/src/shared/domain/llm-failure.ts +134 -0
- package/src/shared/domain/llm-profile.ts +44 -0
- package/src/shared/domain/marked-message.ts +29 -0
- package/src/shared/domain/markers.ts +30 -0
- package/src/shared/domain/messages.ts +291 -0
- package/src/shared/domain/model-catalog.ts +79 -0
- package/src/shared/domain/permission-modes.ts +99 -0
- package/src/shared/domain/prelude.ts +92 -0
- package/src/shared/domain/project-manifests.ts +84 -0
- package/src/shared/domain/prompts.ts +233 -0
- package/src/shared/domain/search-routing.ts +77 -0
- package/src/shared/domain/secret-patterns.ts +46 -0
- package/src/shared/domain/session-keys.ts +92 -0
- package/src/shared/domain/session-start.ts +61 -0
- package/src/shared/domain/severity.ts +72 -0
- package/src/shared/domain/sha1.ts +61 -0
- package/src/shared/domain/shared-memory/agent-memory-import.ts +145 -0
- package/src/shared/domain/shared-memory/candidates.ts +40 -0
- package/src/shared/domain/shared-memory/entry.ts +151 -0
- package/src/shared/domain/shared-memory/front-matter.ts +187 -0
- package/src/shared/domain/shared-memory/gate.ts +45 -0
- package/src/shared/domain/shared-memory/harvest.ts +64 -0
- package/src/shared/domain/shared-memory/layout.ts +190 -0
- 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 +82 -0
- package/src/shared/domain/shared-memory/prompts.ts +28 -0
- package/src/shared/domain/shared-memory/refused.ts +84 -0
- package/src/shared/domain/shared-memory/verdict-rows.ts +134 -0
- 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 +33 -0
- package/src/shared/domain/speech.ts +21 -0
- package/src/shared/domain/strip.ts +88 -0
- package/src/shared/domain/tool-trace.ts +120 -0
- package/src/shared/domain/types.ts +67 -0
- package/src/shared/domain/verifiers.ts +33 -0
- package/src/shared/domain/vfs.ts +16 -0
- package/src/shared/domain/workflow/prompts.ts +15 -0
- package/src/shared/domain/workflow/state-file.ts +142 -0
- package/src/shared/infrastructure/globals.ts +57 -0
- package/src/shared/infrastructure/orkeon/approvals.ts +24 -0
- package/src/shared/infrastructure/orkeon/child-agents.ts +122 -0
- package/src/shared/infrastructure/orkeon/chooser.ts +32 -0
- package/src/shared/infrastructure/orkeon/code-index.ts +120 -0
- package/src/shared/infrastructure/orkeon/crew-host.ts +27 -0
- package/src/shared/infrastructure/orkeon/crew-memory.ts +12 -0
- package/src/shared/infrastructure/orkeon/decision-model.ts +31 -0
- package/src/shared/infrastructure/orkeon/dev-deps.ts +179 -0
- package/src/shared/infrastructure/orkeon/files.ts +58 -0
- package/src/shared/infrastructure/orkeon/github-pull-requests.ts +30 -0
- package/src/shared/infrastructure/orkeon/host-context.ts +36 -0
- package/src/shared/infrastructure/orkeon/host-provider.ts +22 -0
- package/src/shared/infrastructure/orkeon/human-input.ts +55 -0
- package/src/shared/infrastructure/orkeon/llm-profile.ts +58 -0
- package/src/shared/infrastructure/orkeon/llm.ts +164 -0
- package/src/shared/infrastructure/orkeon/markers.ts +6 -0
- package/src/shared/infrastructure/orkeon/memory-store.ts +41 -0
- package/src/shared/infrastructure/orkeon/memory-tools.ts +129 -0
- package/src/shared/infrastructure/orkeon/messages.ts +15 -0
- package/src/shared/infrastructure/orkeon/permission-rules.ts +42 -0
- package/src/shared/infrastructure/orkeon/progress.ts +24 -0
- package/src/shared/infrastructure/orkeon/prompts.ts +47 -0
- package/src/shared/infrastructure/orkeon/reasoning.ts +40 -0
- package/src/shared/infrastructure/orkeon/run-state.ts +17 -0
- package/src/shared/infrastructure/orkeon/runtime-info.ts +30 -0
- package/src/shared/infrastructure/orkeon/runtime-tools.ts +60 -0
- package/src/shared/infrastructure/orkeon/script-tools.ts +129 -0
- package/src/shared/infrastructure/orkeon/session-store.ts +94 -0
- package/src/shared/infrastructure/orkeon/session-switch.ts +23 -0
- package/src/shared/infrastructure/orkeon/shared-memory.ts +61 -0
- package/src/shared/infrastructure/orkeon/shell-jobs.ts +81 -0
- package/src/shared/infrastructure/orkeon/shell.ts +39 -0
- package/src/shared/infrastructure/orkeon/telemetry.ts +63 -0
- package/src/shared/infrastructure/orkeon/tool-catalogue.ts +76 -0
- package/src/shared/infrastructure/orkeon/tool-results.ts +120 -0
- package/src/shared/infrastructure/orkeon/usage.ts +74 -0
- package/src/shared/infrastructure/orkeon/wiring.ts +174 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
// The model's change brief as JSON: the schema it is extracted into, and the check that turns the extraction into
|
|
2
|
+
// a ChangeAnswer or the list of what is wrong with it - the harness's change-template self-check as code: a bug has
|
|
3
|
+
// a criterion, a perf change a criterion with a number, a refactor at least one behaviour that must not change;
|
|
4
|
+
// every criterion is one testable line with its proof; the brief names no design; every cell fits its table.
|
|
5
|
+
// `route: "feature"` says the request is a new promise, for /dev-spec. CH ids are code's, by position. Pure.
|
|
6
|
+
import type { Checked } from "../../../shared/domain/agents/charter.ts";
|
|
7
|
+
import type { ChangeKind } from "../../../shared/domain/dev/spec-format.ts";
|
|
8
|
+
import { MAX_QUESTIONS, QUESTION_SCHEMA, breaksCell, draftQuestionProblems, tidyOptions } from "../../../shared/domain/dev/questions.ts";
|
|
9
|
+
import type { DraftQuestion } from "../../../shared/domain/dev/questions.ts";
|
|
10
|
+
import { NO_CRITERION, NO_CHANGE_SUMMARY, PERF_NEEDS_NUMBER, REFACTOR_NEEDS_PIN, cellOneLine, noBehaviour, noDesign, noProof, severityIsBlockingOrWarning, tooManyCriteria, tooManyLines } from "./messages.ts";
|
|
11
|
+
import {
|
|
12
|
+
ANSWER_NOT_AN_OBJECT as NOT_AN_OBJECT, idNameOneLine, nameOneLine, rowIsEmpty, statementOneLine, TBD_WITHOUT_QUESTION, tooManyQuestions,
|
|
13
|
+
} from "../../../shared/domain/dev/messages.ts";
|
|
14
|
+
|
|
15
|
+
export type CriterionSeverity = "blocking" | "warning";
|
|
16
|
+
export interface ChangeCriterion { name: string; statement: string; proof: string; severity: CriterionSeverity }
|
|
17
|
+
export type ProtectedRow = { behaviour: string; pinnedBy: string };
|
|
18
|
+
export interface ChangeAnswer {
|
|
19
|
+
route: "change" | "feature";
|
|
20
|
+
name: string; summary: string;
|
|
21
|
+
/** Facts the model read (a path:line, a number), one per line; the reproduction itself is code's. */
|
|
22
|
+
evidence: string[];
|
|
23
|
+
/** The suspected cause, a path:line and a sentence; "" when none. */
|
|
24
|
+
suspected: string;
|
|
25
|
+
criteria: ChangeCriterion[];
|
|
26
|
+
mustNotChange: ProtectedRow[];
|
|
27
|
+
scope: Array<{ in: string; out: string }>;
|
|
28
|
+
constraints: string[];
|
|
29
|
+
assumptions: Array<{ assumption: string; validatedBy: string }>;
|
|
30
|
+
questions: DraftQuestion[];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const CRITERION_SEVERITIES: readonly CriterionSeverity[] = ["blocking", "warning"];
|
|
34
|
+
export const MAX_CRITERIA = 12;
|
|
35
|
+
const MAX_NAME_CHARS = 80;
|
|
36
|
+
const MAX_STATEMENT_CHARS = 200;
|
|
37
|
+
const MAX_LIST = 20;
|
|
38
|
+
const DESIGN = /\b(new|create[sd]?|add(s|ed)?|introduce[sd]?)\b[^.;]{0,40}\b(class|type|interface|file|module|library|pattern)\b/i;
|
|
39
|
+
|
|
40
|
+
const str = { type: "string" };
|
|
41
|
+
const strings = { type: "array", items: str };
|
|
42
|
+
const table = (keys: readonly string[]): object => ({
|
|
43
|
+
type: "array",
|
|
44
|
+
items: { type: "object", properties: Object.fromEntries(keys.map((k) => [k, str])), required: [...keys] },
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
export const CHANGE_ANSWER_SCHEMA: object = {
|
|
48
|
+
type: "object",
|
|
49
|
+
properties: {
|
|
50
|
+
route: { type: "string", enum: ["change", "feature"] },
|
|
51
|
+
name: str, summary: str, evidence: strings, suspected: str,
|
|
52
|
+
criteria: {
|
|
53
|
+
type: "array",
|
|
54
|
+
items: {
|
|
55
|
+
type: "object",
|
|
56
|
+
properties: { name: str, statement: str, proof: str, severity: { type: "string", enum: [...CRITERION_SEVERITIES] } },
|
|
57
|
+
required: ["name", "statement", "proof", "severity"],
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
mustNotChange: table(["behaviour", "pinnedBy"]),
|
|
61
|
+
scope: table(["in", "out"]),
|
|
62
|
+
constraints: strings,
|
|
63
|
+
assumptions: table(["assumption", "validatedBy"]),
|
|
64
|
+
questions: { type: "array", items: QUESTION_SCHEMA },
|
|
65
|
+
},
|
|
66
|
+
required: ["route", "name", "summary", "evidence", "suspected", "criteria", "mustNotChange", "scope", "constraints", "assumptions", "questions"],
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const isObject = (v: unknown): v is Record<string, unknown> => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
70
|
+
const text = (v: unknown): string => (typeof v === "string" ? v.trim() : "");
|
|
71
|
+
const list = (v: unknown): unknown[] => (Array.isArray(v) ? v : []);
|
|
72
|
+
const textList = (v: unknown): string[] => list(v).map(text).filter((t) => t !== "");
|
|
73
|
+
function rows<K extends string>(v: unknown, keys: readonly K[]): Array<Record<K, string>> {
|
|
74
|
+
return list(v).map((item) => {
|
|
75
|
+
const o = isObject(item) ? item : {};
|
|
76
|
+
return Object.fromEntries(keys.map((k) => [k, text(o[k])])) as Record<K, string>;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export const criterionId = (k: number): string => `CH-${String(k + 1).padStart(2, "0")}`;
|
|
81
|
+
|
|
82
|
+
function readChangeAnswer(value: unknown): ChangeAnswer {
|
|
83
|
+
const o = isObject(value) ? value : {};
|
|
84
|
+
return {
|
|
85
|
+
route: text(o.route) === "feature" ? "feature" : "change",
|
|
86
|
+
name: text(o.name), summary: text(o.summary), evidence: textList(o.evidence), suspected: text(o.suspected),
|
|
87
|
+
criteria: list(o.criteria).map((c) => {
|
|
88
|
+
const x = isObject(c) ? c : {};
|
|
89
|
+
return { name: text(x.name), statement: text(x.statement), proof: text(x.proof), severity: text(x.severity).toLowerCase() as CriterionSeverity };
|
|
90
|
+
}),
|
|
91
|
+
mustNotChange: rows(o.mustNotChange, ["behaviour", "pinnedBy"]),
|
|
92
|
+
scope: rows(o.scope, ["in", "out"]),
|
|
93
|
+
constraints: textList(o.constraints),
|
|
94
|
+
assumptions: rows(o.assumptions, ["assumption", "validatedBy"]),
|
|
95
|
+
questions: list(o.questions).map((q) => {
|
|
96
|
+
const x = isObject(q) ? q : {};
|
|
97
|
+
return { severity: text(x.severity), question: text(x.question), impact: text(x.impact), options: tidyOptions(textList(x.options)) };
|
|
98
|
+
}),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function checkChangeAnswer(value: unknown, kind: ChangeKind): Checked<ChangeAnswer> {
|
|
103
|
+
if (!isObject(value)) return { ok: false, problems: [NOT_AN_OBJECT] };
|
|
104
|
+
const a = readChangeAnswer(value);
|
|
105
|
+
if (a.route === "feature") return { ok: true, value: a };
|
|
106
|
+
const problems: string[] = [];
|
|
107
|
+
const oneLine = (t: string): boolean => !/[\r\n]/.test(t);
|
|
108
|
+
if (a.name === "" || !oneLine(a.name) || a.name.length > MAX_NAME_CHARS || a.name.includes("—")) {
|
|
109
|
+
problems.push(nameOneLine(MAX_NAME_CHARS));
|
|
110
|
+
}
|
|
111
|
+
if (a.summary === "") problems.push(NO_CHANGE_SUMMARY);
|
|
112
|
+
if (a.criteria.length === 0) problems.push(NO_CRITERION);
|
|
113
|
+
if (a.criteria.length > MAX_CRITERIA) problems.push(tooManyCriteria(MAX_CRITERIA));
|
|
114
|
+
a.criteria.forEach((c, i) => {
|
|
115
|
+
const id = criterionId(i);
|
|
116
|
+
if (c.name === "" || !oneLine(c.name) || c.name.length > MAX_NAME_CHARS) problems.push(idNameOneLine(id, MAX_NAME_CHARS));
|
|
117
|
+
if (c.statement === "" || !oneLine(c.statement) || c.statement.length > MAX_STATEMENT_CHARS || c.statement.includes(" · ")) {
|
|
118
|
+
problems.push(statementOneLine(id, MAX_STATEMENT_CHARS));
|
|
119
|
+
}
|
|
120
|
+
if (c.proof === "" || !oneLine(c.proof)) problems.push(noProof(id));
|
|
121
|
+
if (!CRITERION_SEVERITIES.includes(c.severity)) problems.push(severityIsBlockingOrWarning(id));
|
|
122
|
+
});
|
|
123
|
+
if (kind === "perf" && !a.criteria.some((c) => /\d/.test(`${c.statement} ${c.proof}`))) {
|
|
124
|
+
problems.push(PERF_NEEDS_NUMBER);
|
|
125
|
+
}
|
|
126
|
+
if (kind === "refactor" && a.mustNotChange.length === 0) {
|
|
127
|
+
problems.push(REFACTOR_NEEDS_PIN);
|
|
128
|
+
}
|
|
129
|
+
const tables: Array<[string, ReadonlyArray<Record<string, string>>]> = [
|
|
130
|
+
["mustNotChange", a.mustNotChange], ["scope", a.scope], ["assumptions", a.assumptions],
|
|
131
|
+
];
|
|
132
|
+
for (const [name, items] of tables) {
|
|
133
|
+
items.forEach((row, i) => {
|
|
134
|
+
if (Object.values(row).some(breaksCell)) problems.push(cellOneLine(name, i + 1));
|
|
135
|
+
if (Object.values(row).every((v) => v === "")) problems.push(rowIsEmpty(name, i + 1));
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
a.mustNotChange.forEach((r, i) => { if (r.behaviour === "") problems.push(noBehaviour(i + 1)); });
|
|
139
|
+
if (a.constraints.length > MAX_LIST || a.evidence.length > MAX_LIST) problems.push(tooManyLines(MAX_LIST));
|
|
140
|
+
const all = [
|
|
141
|
+
a.name, a.summary, ...a.evidence, a.suspected, ...a.criteria.flatMap((c) => [c.name, c.statement, c.proof]),
|
|
142
|
+
...a.scope.flatMap((s) => [s.in, s.out]), ...a.constraints,
|
|
143
|
+
];
|
|
144
|
+
const design = all.find((t) => DESIGN.test(t));
|
|
145
|
+
if (design !== undefined) problems.push(noDesign(design.slice(0, 60)));
|
|
146
|
+
if (/\bTBD\b/.test(all.join("\n")) && a.questions.length === 0) problems.push(TBD_WITHOUT_QUESTION);
|
|
147
|
+
if (a.questions.length > MAX_QUESTIONS) problems.push(tooManyQuestions(MAX_QUESTIONS));
|
|
148
|
+
a.questions.forEach((q, i) => problems.push(...draftQuestionProblems(q, i + 1)));
|
|
149
|
+
return problems.length > 0 ? { ok: false, problems } : { ok: true, value: a };
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** The answer with each pinned test the inventory does not show turned into "unpinned", and those names. */
|
|
153
|
+
export function pinOnlyKnown(a: ChangeAnswer, known: (name: string) => boolean): { answer: ChangeAnswer; unknown: string[] } {
|
|
154
|
+
const unknown: string[] = [];
|
|
155
|
+
const mustNotChange = a.mustNotChange.map((r) => {
|
|
156
|
+
const by = r.pinnedBy.replace(/`/g, "").trim();
|
|
157
|
+
if (by === "" || by.toLowerCase() === "unpinned") return { behaviour: r.behaviour, pinnedBy: "unpinned" };
|
|
158
|
+
if (known(by)) return { behaviour: r.behaviour, pinnedBy: by };
|
|
159
|
+
unknown.push(by);
|
|
160
|
+
return { behaviour: r.behaviour, pinnedBy: "unpinned" };
|
|
161
|
+
});
|
|
162
|
+
return { answer: { ...a, mustNotChange }, unknown };
|
|
163
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// The change brief as code writes it: the harness's template (sections 1 to 8) with a section 9 of decisions, an
|
|
2
|
+
// empty section left out. § 1 (the origin, quoted) and the facts of § 2 (the reproduction or the measurement that
|
|
3
|
+
// ran) are code's and carried over from the file on a revision or a fold; the model adds its own facts after them.
|
|
4
|
+
// A criterion carries a `- **Statement**:` line first, which spec-format.ts reads for /dev-plan. Pure, no IO.
|
|
5
|
+
import { STATEMENT } from "../../../shared/domain/dev/markers.ts";
|
|
6
|
+
import { decisionTable, questionTable } from "../../../shared/domain/dev/questions.ts";
|
|
7
|
+
import type { Decision, Question } from "../../../shared/domain/dev/questions.ts";
|
|
8
|
+
import type { ChangeKind } from "../../../shared/domain/dev/spec-format.ts";
|
|
9
|
+
import { criterionId } from "./change-answer.ts";
|
|
10
|
+
import type { ChangeAnswer } from "./change-answer.ts";
|
|
11
|
+
import { CHANGE_COLUMNS, CHANGE_DECISIONS_SECTION, CHANGE_QUESTIONS_SECTION, CHANGE_SECTIONS, SUSPECTED_CAUSE } from "./markers.ts";
|
|
12
|
+
|
|
13
|
+
export const changeFileName = (code: string): string => `CHANGE-${code}.md`;
|
|
14
|
+
export const reproFileName = (code: string): string => `repro-${code}.txt`;
|
|
15
|
+
const MAX_ORIGIN_LINES = 12;
|
|
16
|
+
|
|
17
|
+
export interface ChangeRenderInput {
|
|
18
|
+
code: string; kind: ChangeKind; answer: ChangeAnswer;
|
|
19
|
+
/** The body of § 1 and the code's lines of § 2, as written (from the file, or built for a new brief). */
|
|
20
|
+
origin: readonly string[];
|
|
21
|
+
facts: readonly string[];
|
|
22
|
+
open: readonly Question[]; decisions: readonly Decision[];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const section = (heading: string, body: readonly string[]): string[] => (body.length === 0 ? [] : [heading, "", ...body, ""]);
|
|
26
|
+
const table = (header: readonly string[], rows: ReadonlyArray<readonly string[]>): string[] =>
|
|
27
|
+
rows.length === 0 ? [] : [
|
|
28
|
+
`| ${header.join(" | ")} |`, `|${header.map(() => "---").join("|")}|`,
|
|
29
|
+
...rows.map((r) => `| ${r.map((c) => c || "—").join(" | ")} |`),
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
/** The origin as § 1 quotes it: its first lines, each as a quote. */
|
|
33
|
+
export function originLines(text: string, from: string): string[] {
|
|
34
|
+
const lines = text.trim().split(/\r?\n/);
|
|
35
|
+
const shown = lines.slice(0, MAX_ORIGIN_LINES).map((l) => `> ${l}`.trimEnd());
|
|
36
|
+
if (lines.length > MAX_ORIGIN_LINES) shown.push(`> … (${lines.length - MAX_ORIGIN_LINES} more lines${from === "" ? "" : ` in ${from}`})`);
|
|
37
|
+
return from === "" ? shown : [`From ${from}:`, "", ...shown];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** The body of the `## ` section whose heading matches, without its surrounding blank lines; [] when absent. */
|
|
41
|
+
export function sectionBody(text: string, heading: RegExp): string[] {
|
|
42
|
+
const out: string[] = [];
|
|
43
|
+
let inside = false;
|
|
44
|
+
for (const line of text.split(/\r?\n/)) {
|
|
45
|
+
if (line.startsWith("## ")) { if (inside) break; inside = heading.test(line); continue; }
|
|
46
|
+
if (inside) out.push(line);
|
|
47
|
+
}
|
|
48
|
+
while (out.length > 0 && out[0].trim() === "") out.shift();
|
|
49
|
+
while (out.length > 0 && out[out.length - 1].trim() === "") out.pop();
|
|
50
|
+
return out;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function renderChange(input: ChangeRenderInput): string {
|
|
54
|
+
const a = input.answer;
|
|
55
|
+
const lines: string[] = [`# ${input.code} — ${a.name} — ${input.kind}`, ""];
|
|
56
|
+
if (a.summary !== "") lines.push(...a.summary.split(/\r?\n/).map((l) => `> ${l}`.trimEnd()), "");
|
|
57
|
+
lines.push(...section(CHANGE_SECTIONS.origin, input.origin));
|
|
58
|
+
const known = input.facts.join("\n");
|
|
59
|
+
const own = a.evidence.filter((e) => !known.includes(e)).map((e) => `- ${e}`);
|
|
60
|
+
const suspected = a.suspected === "" || known.includes(a.suspected) ? [] : [`${SUSPECTED_CAUSE} (suspected): ${a.suspected}`];
|
|
61
|
+
lines.push(...section(CHANGE_SECTIONS.evidence, [...input.facts, ...(input.facts.length > 0 && own.length + suspected.length > 0 ? [""] : []), ...own, ...suspected]));
|
|
62
|
+
lines.push(CHANGE_SECTIONS.acceptance, "");
|
|
63
|
+
a.criteria.forEach((c, i) => {
|
|
64
|
+
lines.push(`### ${criterionId(i)} — ${c.name}`, `- ${STATEMENT}: ${c.statement} · **Proof**: ${c.proof} · **Severity**: ${c.severity}`, "");
|
|
65
|
+
});
|
|
66
|
+
lines.push(...section(CHANGE_SECTIONS.mustNotChange, table(
|
|
67
|
+
CHANGE_COLUMNS.mustNotChange, a.mustNotChange.map((r) => [r.behaviour, r.pinnedBy === "unpinned" ? "unpinned" : `\`${r.pinnedBy}\``]),
|
|
68
|
+
)));
|
|
69
|
+
lines.push(...section(CHANGE_SECTIONS.scope, table(CHANGE_COLUMNS.scope, a.scope.map((s) => [s.in, s.out]))));
|
|
70
|
+
lines.push(...section(CHANGE_SECTIONS.constraints, a.constraints.map((c) => `- ${c}`)));
|
|
71
|
+
lines.push(...section(CHANGE_SECTIONS.assumptions, table(
|
|
72
|
+
CHANGE_COLUMNS.assumptions, a.assumptions.map((r, i) => [`A${i + 1}`, r.assumption, r.validatedBy]),
|
|
73
|
+
)));
|
|
74
|
+
lines.push(...section(CHANGE_QUESTIONS_SECTION, questionTable(input.open)));
|
|
75
|
+
lines.push(...section(CHANGE_DECISIONS_SECTION, decisionTable(input.decisions)));
|
|
76
|
+
return `${lines.join("\n").replace(/\n{3,}/g, "\n\n").trimEnd()}\n`;
|
|
77
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// The markers of a change brief: the headings and table headers the renderer writes and the run, /dev-plan, the
|
|
2
|
+
// review and the question round read back (ADR 0026).
|
|
3
|
+
|
|
4
|
+
export const CHANGE_QUESTIONS_SECTION = "## 8. Open questions";
|
|
5
|
+
export const CHANGE_DECISIONS_SECTION = "## 9. Decisions";
|
|
6
|
+
export const ORIGIN_HEADING = /^## 1\. Origin\s*$/;
|
|
7
|
+
export const EVIDENCE_HEADING = /^## 2\. Evidence\s*$/;
|
|
8
|
+
|
|
9
|
+
/** The template's sections, numbered as /dev-plan expects them. */
|
|
10
|
+
export const CHANGE_SECTIONS = {
|
|
11
|
+
origin: "## 1. Origin",
|
|
12
|
+
evidence: "## 2. Evidence",
|
|
13
|
+
acceptance: "## 3. Acceptance",
|
|
14
|
+
mustNotChange: "## 4. What must not change",
|
|
15
|
+
scope: "## 5. Scope",
|
|
16
|
+
constraints: "## 6. Constraints",
|
|
17
|
+
assumptions: "## 7. Assumptions",
|
|
18
|
+
} as const;
|
|
19
|
+
|
|
20
|
+
/** The column headers of the template's tables. */
|
|
21
|
+
export const CHANGE_COLUMNS = {
|
|
22
|
+
mustNotChange: ["Behaviour", "Pinned by"],
|
|
23
|
+
scope: ["In", "Out"],
|
|
24
|
+
assumptions: ["#", "Assumption", "To be validated by"],
|
|
25
|
+
} as const;
|
|
26
|
+
|
|
27
|
+
/** The model's own cause in § 2, which a revision drops from the facts it carries over. */
|
|
28
|
+
export const SUSPECTED_CAUSE = "- **Suspected cause**";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// The messages of dev-change's domain: the problems the check of a change answer reports, which the model reads back
|
|
2
|
+
// on a re-ask and the person in the refusal (ADR 0026).
|
|
3
|
+
|
|
4
|
+
export const NO_CHANGE_SUMMARY = "summary: what is wrong or costly, where it shows, why now";
|
|
5
|
+
export const NO_CRITERION = "criteria: at least one acceptance criterion";
|
|
6
|
+
export const tooManyCriteria = (max: number): string => `criteria: at most ${max}`;
|
|
7
|
+
export const noProof = (id: string): string =>
|
|
8
|
+
`${id}: no proof (the test that reproduces, the measurement and its target, or "no observable behaviour changes")`;
|
|
9
|
+
export const severityIsBlockingOrWarning = (id: string): string => `${id}: severity is blocking or warning`;
|
|
10
|
+
export const PERF_NEEDS_NUMBER = "a performance change has a criterion with a number as its target";
|
|
11
|
+
export const REFACTOR_NEEDS_PIN = "a refactor names at least one behaviour that must not change, and the test pinning it or unpinned";
|
|
12
|
+
export const cellOneLine = (name: string, row: number): string => `${name} ${row}: every cell is one line, no '|'`;
|
|
13
|
+
export const noBehaviour = (row: number): string => `mustNotChange ${row}: no behaviour`;
|
|
14
|
+
export const tooManyLines = (max: number): string => `evidence and constraints: at most ${max} lines each`;
|
|
15
|
+
export const noDesign = (hit: string): string =>
|
|
16
|
+
`no design: "${hit}" names a new type, file, pattern or library; say what is observed and expected`;
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
// The close of a batch the audit found VALID (`/dev-batches <code> F<n> --close`, or the chain
|
|
2
|
+
// after the audit): the last verdict of `<CODE>-VERIFY-F<n>.md` must be VALID, then the files the
|
|
3
|
+
// roles changed (touched.ts) are committed by name, pushed, and the pull request opened or handed
|
|
4
|
+
// over (shared/application/dev/close-batch.ts). Nothing is committed without that verdict. On the default
|
|
5
|
+
// branch, when the pack asks for a work branch, the close creates `<prefix>/<code>-f<n>` first. Once
|
|
6
|
+
// committed, the batch is marked done: the sheet's title and the global plan's batch (never committed,
|
|
7
|
+
// the work folder stays out of git).
|
|
8
|
+
import type { Files, Shell } from "../../../shared/application/ports.ts";
|
|
9
|
+
import type { ConfigStore } from "../../../shared/application/config-store.ts";
|
|
10
|
+
import type { PullRequestOpener } from "../../../shared/application/git/commit-files.ts";
|
|
11
|
+
import { runGit } from "../../../shared/application/git/commit-files.ts";
|
|
12
|
+
import { closeBatch } from "../../../shared/application/dev/close-batch.ts";
|
|
13
|
+
import type { WorkFolder } from "../../../shared/application/dev/resolve-work-folder.ts";
|
|
14
|
+
import { auditCommand, closeCommand, lastVerdict, parseVerdictFile } from "../../../shared/domain/dev/verdict-format.ts";
|
|
15
|
+
import { parseBatchSheet } from "../../../shared/domain/dev/plan-format.ts";
|
|
16
|
+
import type { RepoPack } from "../../../shared/domain/dev/repo-pack.ts";
|
|
17
|
+
import {
|
|
18
|
+
DEV_PR_AUTO_CONFIG_KEY, GIT_CURRENT_BRANCH_COMMAND, GIT_DEFAULT_BRANCH_COMMAND, parseDefaultBranch, shellQuote, workBranchFromPattern,
|
|
19
|
+
} from "../../../shared/domain/git/close.ts";
|
|
20
|
+
import type { PrSummary } from "../../../shared/domain/git/close.ts";
|
|
21
|
+
import type { PermissionRule } from "../../../shared/domain/agent-policy/permission.ts";
|
|
22
|
+
import { under } from "../domain/step-checks.ts";
|
|
23
|
+
import { openSteps, parseImplementSheet } from "../domain/step-section.ts";
|
|
24
|
+
import { markPlanBatchDone, markSheetDone } from "../domain/sheet-edits.ts";
|
|
25
|
+
import { verdictMarkOf } from "./touched.ts";
|
|
26
|
+
import type { LocatedSheet } from "./locate-sheet.ts";
|
|
27
|
+
import { WORKSPACE } from "../../../shared/domain/vfs.ts";
|
|
28
|
+
import { NO_CURRENT_BRANCH, branchExistsSwitchToIt, defaultBranchAsksWorkBranch, noBranchName, noFileRecorded, notAudited, notValid, planBatchMarkedDone, planNotFound, sheetMarkedDone, sheetNotMarkedDone, sheetUnreadableAtClose, switchFailed, tddBoxOpen, verdictNotRewritten } from "./messages.ts";
|
|
29
|
+
import { branchCreated } from "../../../shared/application/git/messages.ts";
|
|
30
|
+
|
|
31
|
+
export interface CloseInput {
|
|
32
|
+
pack: RepoPack;
|
|
33
|
+
work: WorkFolder;
|
|
34
|
+
located: LocatedSheet;
|
|
35
|
+
batch: string;
|
|
36
|
+
touched: string[];
|
|
37
|
+
/** The verdict file's mark when the touched list was last written (touched.ts). */
|
|
38
|
+
verdictMark: string | null;
|
|
39
|
+
openPr: boolean;
|
|
40
|
+
push: boolean;
|
|
41
|
+
/** The session's rules at the launch (a deny on the push keeps the commit local). */
|
|
42
|
+
rules?: readonly PermissionRule[];
|
|
43
|
+
/** Today, `YYYY-MM-DD`: the date of the done marks. */
|
|
44
|
+
today: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const LAYERS = ["domain", "application", "infrastructure", "tests"] as const;
|
|
48
|
+
|
|
49
|
+
/** The touched paths grouped by the pack's layout roots, the others last. */
|
|
50
|
+
export function layersOf(pack: RepoPack, touched: readonly string[]): PrSummary["layers"] {
|
|
51
|
+
const left = new Set(touched);
|
|
52
|
+
const out: PrSummary["layers"] = [];
|
|
53
|
+
for (const layer of LAYERS) {
|
|
54
|
+
const root = pack.layout[layer];
|
|
55
|
+
if (!root) continue;
|
|
56
|
+
const paths = [...left].filter((p) => under(p, root)).sort();
|
|
57
|
+
paths.forEach((p) => left.delete(p));
|
|
58
|
+
out.push({ layer, paths });
|
|
59
|
+
}
|
|
60
|
+
out.push({ layer: "other", paths: [...left].sort() });
|
|
61
|
+
return out;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async function prAuto(config: Pick<ConfigStore, "readValue">): Promise<boolean> {
|
|
65
|
+
try {
|
|
66
|
+
return (await config.readValue(DEV_PR_AUTO_CONFIG_KEY)).value?.trim() === "true";
|
|
67
|
+
} catch {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export async function closeDevBatch(
|
|
73
|
+
deps: { files: Files; shell: Shell; config: Pick<ConfigStore, "readValue">; opener?: PullRequestOpener },
|
|
74
|
+
input: CloseInput,
|
|
75
|
+
): Promise<string[]> {
|
|
76
|
+
const { located, batch } = input;
|
|
77
|
+
const rerun = closeCommand(located.code, batch);
|
|
78
|
+
const verdictName = `${located.prefix}-VERIFY-${batch}.md`;
|
|
79
|
+
let verdictText: string;
|
|
80
|
+
try {
|
|
81
|
+
verdictText = await deps.files.read(`${WORKSPACE}/${located.dir}/${verdictName}`);
|
|
82
|
+
} catch {
|
|
83
|
+
return [notAudited(`${located.dir}/${verdictName}`, auditCommand(located.code, batch))];
|
|
84
|
+
}
|
|
85
|
+
const verdict = lastVerdict(parseVerdictFile(verdictText));
|
|
86
|
+
if (verdict?.verdict !== "VALID") {
|
|
87
|
+
return [notValid(verdictName, verdict?.verdict ?? "missing")];
|
|
88
|
+
}
|
|
89
|
+
if (input.touched.length === 0) {
|
|
90
|
+
return [noFileRecorded(batch, located.code)];
|
|
91
|
+
}
|
|
92
|
+
if (input.verdictMark === null || input.verdictMark === verdictMarkOf(verdictText)) {
|
|
93
|
+
return [verdictNotRewritten(verdictName, batch, auditCommand(located.code, batch))];
|
|
94
|
+
}
|
|
95
|
+
let sheetText: string;
|
|
96
|
+
try {
|
|
97
|
+
sheetText = await deps.files.read(`${WORKSPACE}/${located.dir}/${located.name}`);
|
|
98
|
+
} catch {
|
|
99
|
+
return [sheetUnreadableAtClose(`${located.dir}/${located.name}`)];
|
|
100
|
+
}
|
|
101
|
+
const open = openSteps(parseImplementSheet(sheetText)).map((s) => s.number);
|
|
102
|
+
if (open.length > 0) {
|
|
103
|
+
return [tddBoxOpen(open.join(", "), located.name, located.code, batch)];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const current = await runGit(deps.shell, GIT_CURRENT_BRANCH_COMMAND);
|
|
107
|
+
const branch = current.exitCode === 0 ? current.stdout.trim() : "";
|
|
108
|
+
if (branch === "") return [NO_CURRENT_BRANCH + rerun];
|
|
109
|
+
const base = await runGit(deps.shell, GIT_DEFAULT_BRANCH_COMMAND);
|
|
110
|
+
const defaultBranch = base.exitCode === 0 ? parseDefaultBranch(base.stdout) : null;
|
|
111
|
+
const wanted = input.pack.contrib.branch?.trim();
|
|
112
|
+
let onBranch = branch;
|
|
113
|
+
const notes: string[] = [];
|
|
114
|
+
if (wanted && defaultBranch !== null && branch === defaultBranch) {
|
|
115
|
+
const made = await createWorkBranch(deps.shell, wanted, located.code, batch);
|
|
116
|
+
if (!made.ok) return [defaultBranchAsksWorkBranch(branch, wanted, made.reason, rerun)];
|
|
117
|
+
onBranch = made.branch;
|
|
118
|
+
notes.push(branchCreated(made.branch, branch, wanted));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const parsed = parseBatchSheet(sheetText);
|
|
122
|
+
const sheetName = parsed.name ?? located.name;
|
|
123
|
+
const message = `feat(${located.code}): ${sheetName} (batch ${batch})`;
|
|
124
|
+
const summary: PrSummary = {
|
|
125
|
+
batch: `${located.prefix} ${batch} — ${sheetName}, from \`${located.dir}/${located.name}\`.`,
|
|
126
|
+
layers: layersOf(input.pack, input.touched),
|
|
127
|
+
validations: verdict.validations,
|
|
128
|
+
assumptions: parsed.assumptions ?? [],
|
|
129
|
+
audit: `VALID${verdict.when ? ` (${verdict.when})` : ""}, \`${located.dir}/${verdictName}\`.`,
|
|
130
|
+
notRun: verdict.notRun.join("; "),
|
|
131
|
+
};
|
|
132
|
+
const result = await closeBatch(
|
|
133
|
+
{ shell: deps.shell, files: deps.files, opener: deps.opener },
|
|
134
|
+
{
|
|
135
|
+
touched: input.touched, message, branch: onBranch, work: { folder: input.work.folder, vfsPath: input.work.vfsPath },
|
|
136
|
+
push: input.push, ...(input.rules === undefined ? {} : { rules: input.rules }), openPr: input.openPr || (await prAuto(deps.config)), summary, rerun,
|
|
137
|
+
},
|
|
138
|
+
);
|
|
139
|
+
if (!result.committed) return [...notes, ...result.lines];
|
|
140
|
+
return [...notes, ...result.lines, ...await markDone(deps.files, located, batch, sheetText, input.today)];
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** The work branch's name from the pack's pattern: its first alternative before `/`, then `<code>-f<n>`. */
|
|
144
|
+
export function workBranchName(pattern: string, code: string, batch: string): string | null {
|
|
145
|
+
return workBranchFromPattern(pattern, `${code}-${batch.toLowerCase()}`);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
async function createWorkBranch(
|
|
149
|
+
shell: Pick<Shell, "run">, pattern: string, code: string, batch: string,
|
|
150
|
+
): Promise<{ ok: true; branch: string } | { ok: false; reason: string }> {
|
|
151
|
+
const name = workBranchName(pattern, code, batch);
|
|
152
|
+
if (name === null) return { ok: false, reason: noBranchName(pattern) };
|
|
153
|
+
const exists = await runGit(shell, `git rev-parse --verify --quiet ${shellQuote(`refs/heads/${name}`)}`);
|
|
154
|
+
if (exists.exitCode === 0) return { ok: false, reason: branchExistsSwitchToIt(name) };
|
|
155
|
+
const made = await runGit(shell, `git switch -c ${shellQuote(name)}`);
|
|
156
|
+
if (made.exitCode !== 0) {
|
|
157
|
+
return { ok: false, reason: switchFailed(name, (made.stderr || made.stdout).trim().split("\n")[0] || `exit ${made.exitCode}`) };
|
|
158
|
+
}
|
|
159
|
+
return { ok: true, branch: name };
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** The sheet's title and the global plan's batch marked done; a file that cannot be written is said. */
|
|
163
|
+
async function markDone(files: Files, located: LocatedSheet, batch: string, sheetText: string, today: string): Promise<string[]> {
|
|
164
|
+
const out: string[] = [];
|
|
165
|
+
const sheetPath = `${WORKSPACE}/${located.dir}/${located.name}`;
|
|
166
|
+
const planName = `${located.prefix}-PLAN.md`;
|
|
167
|
+
try {
|
|
168
|
+
const now = await files.read(sheetPath).catch(() => sheetText);
|
|
169
|
+
const marked = markSheetDone(now, today);
|
|
170
|
+
if (marked !== now) await files.write(sheetPath, marked);
|
|
171
|
+
out.push(sheetMarkedDone(located.name, today));
|
|
172
|
+
} catch (e) {
|
|
173
|
+
out.push(sheetNotMarkedDone(located.name, String((e as Error)?.message ?? e).split("\n")[0]));
|
|
174
|
+
}
|
|
175
|
+
try {
|
|
176
|
+
const plan = await files.read(`${WORKSPACE}/${located.dir}/${planName}`);
|
|
177
|
+
const marked = markPlanBatchDone(plan, batch, today);
|
|
178
|
+
if (marked !== plan) {
|
|
179
|
+
await files.write(`${WORKSPACE}/${located.dir}/${planName}`, marked);
|
|
180
|
+
out.push(planBatchMarkedDone(planName, batch));
|
|
181
|
+
}
|
|
182
|
+
} catch {
|
|
183
|
+
out.push(planNotFound(planName, batch));
|
|
184
|
+
}
|
|
185
|
+
return out;
|
|
186
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// The open steps of the batch sheet a dev-implement run will take, counted before the crew starts so
|
|
2
|
+
// that its budget is sized to them (implement-budget.ts). Undefined when the sheet cannot be found or
|
|
3
|
+
// read: the crew then sizes for the default, and its own run says what is wrong.
|
|
4
|
+
import type { Files, Shell } from "../../../shared/application/ports.ts";
|
|
5
|
+
import type { ConfigStore } from "../../../shared/application/config-store.ts";
|
|
6
|
+
import { loadDevContext } from "../../../shared/application/dev/load-dev-context.ts";
|
|
7
|
+
import { openSteps, parseImplementSheet } from "../domain/step-section.ts";
|
|
8
|
+
import { locateSheet } from "./locate-sheet.ts";
|
|
9
|
+
import { WORKSPACE } from "../../../shared/domain/vfs.ts";
|
|
10
|
+
|
|
11
|
+
export async function countOpenSteps(
|
|
12
|
+
deps: { files: Files; shell: Shell; config: Pick<ConfigStore, "readValue"> },
|
|
13
|
+
batch: string, plan: string | null,
|
|
14
|
+
): Promise<number | undefined> {
|
|
15
|
+
try {
|
|
16
|
+
const context = await loadDevContext(deps);
|
|
17
|
+
const located = await locateSheet(deps.files, context.work.folder, batch, plan);
|
|
18
|
+
if (typeof located === "string") return undefined;
|
|
19
|
+
const sheet = parseImplementSheet(await deps.files.read(`${WORKSPACE}/${located.dir}/${located.name}`));
|
|
20
|
+
return sheet.problems.length > 0 ? undefined : openSteps(sheet).length;
|
|
21
|
+
} catch {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// The batch sheet the command names: by its code (`<work>/<code>/<CODE>-PLAN-F<n>.md`), by the path
|
|
2
|
+
// of its global plan (the sheet beside it), or, with neither, the one sheet of that batch under the
|
|
3
|
+
// work folder. Paths are relative to /workspace.
|
|
4
|
+
import type { Files } from "../../../shared/application/ports.ts";
|
|
5
|
+
import { classifyArtefact, isCode } from "../../../shared/domain/dev/artefacts.ts";
|
|
6
|
+
import { WORKSPACE, workspaceRelative } from "../../../shared/domain/vfs.ts";
|
|
7
|
+
import { noSheetBeside, noSheetUnder, planHoldsNoSheet, severalSheets } from "./messages.ts";
|
|
8
|
+
import { neitherCodeNorPlan } from "../../../shared/application/dev/messages.ts";
|
|
9
|
+
|
|
10
|
+
const ENTRIES_PROBED = 50;
|
|
11
|
+
const LIST_CAP = 500;
|
|
12
|
+
|
|
13
|
+
export interface LocatedSheet {
|
|
14
|
+
/** Folder of the plan, relative to /workspace, e.g. `workbench/prune`. */
|
|
15
|
+
dir: string;
|
|
16
|
+
name: string;
|
|
17
|
+
prefix: string;
|
|
18
|
+
/** The code: the plan folder's own name. */
|
|
19
|
+
code: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const bare = (entry: string): string => entry.replace(/\/+$/, "");
|
|
23
|
+
const byName = (a: string, b: string): number => (a < b ? -1 : a > b ? 1 : 0);
|
|
24
|
+
|
|
25
|
+
async function listOrEmpty(files: Pick<Files, "list">, path: string): Promise<string[]> {
|
|
26
|
+
try {
|
|
27
|
+
return (await files.list(path, LIST_CAP)).map(bare).sort(byName);
|
|
28
|
+
} catch {
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function located(dir: string, name: string, prefix: string): LocatedSheet {
|
|
34
|
+
return { dir, name, prefix, code: dir.slice(dir.lastIndexOf("/") + 1) };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async function sheetsIn(files: Pick<Files, "list">, dir: string, batch: string): Promise<LocatedSheet[]> {
|
|
38
|
+
const out: LocatedSheet[] = [];
|
|
39
|
+
for (const name of await listOrEmpty(files, `${WORKSPACE}/${dir}`)) {
|
|
40
|
+
const a = classifyArtefact(name);
|
|
41
|
+
if (a !== null && a.kind === "sheet" && a.batch === batch) out.push(located(dir, name, a.prefix));
|
|
42
|
+
}
|
|
43
|
+
return out;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function several(batch: string, sheets: readonly LocatedSheet[]): string {
|
|
47
|
+
return severalSheets(batch, sheets.map((s) => `${s.dir}/${s.name}`).join(", "));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** The sheet, or why none is found. */
|
|
51
|
+
export async function locateSheet(
|
|
52
|
+
files: Pick<Files, "read" | "list">, work: string, batch: string, plan: string | null,
|
|
53
|
+
): Promise<LocatedSheet | string> {
|
|
54
|
+
if (plan === null) {
|
|
55
|
+
const found: LocatedSheet[] = [];
|
|
56
|
+
for (const entry of (await listOrEmpty(files, `${WORKSPACE}/${work}`)).slice(0, ENTRIES_PROBED)) {
|
|
57
|
+
found.push(...(await sheetsIn(files, `${work}/${entry}`, batch)));
|
|
58
|
+
}
|
|
59
|
+
if (found.length === 0) return noSheetUnder(work, batch);
|
|
60
|
+
return found.length === 1 ? found[0] : several(batch, found);
|
|
61
|
+
}
|
|
62
|
+
if (isCode(plan)) {
|
|
63
|
+
const found = await sheetsIn(files, `${work}/${plan}`, batch);
|
|
64
|
+
if (found.length === 0) return planHoldsNoSheet(`${work}/${plan}`, batch);
|
|
65
|
+
if (found.length === 1) return found[0];
|
|
66
|
+
const named = found.filter((s) => s.prefix === plan.toUpperCase());
|
|
67
|
+
return named.length === 1 ? named[0] : several(batch, found);
|
|
68
|
+
}
|
|
69
|
+
const neither = neitherCodeNorPlan(plan);
|
|
70
|
+
const relative = workspaceRelative(plan);
|
|
71
|
+
const slash = relative.lastIndexOf("/");
|
|
72
|
+
if (relative.startsWith("/") || relative.split("/").includes("..") || slash <= 0) return neither;
|
|
73
|
+
const classified = classifyArtefact(relative.slice(slash + 1));
|
|
74
|
+
if (classified === null || classified.kind !== "plan") return neither;
|
|
75
|
+
const sheet = located(relative.slice(0, slash), `${classified.prefix}-PLAN-${batch}.md`, classified.prefix);
|
|
76
|
+
try {
|
|
77
|
+
await files.read(`${WORKSPACE}/${sheet.dir}/${sheet.name}`, 1);
|
|
78
|
+
} catch {
|
|
79
|
+
return noSheetBeside(`${sheet.dir}/${sheet.name}`, relative);
|
|
80
|
+
}
|
|
81
|
+
return sheet;
|
|
82
|
+
}
|