orkeon-code 0.0.0-stage → 1.0.0-rc.1
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-version +1 -0
- package/LICENSE.md +21 -0
- package/NOTICE.md +17 -0
- package/README.fr.md +169 -0
- package/README.md +162 -2
- package/config/appsettings.anthropic.example.json +77 -0
- package/config/appsettings.example.json +71 -0
- package/config/appsettings.jev.example.json +128 -0
- package/config/appsettings.kev.example.json +130 -0
- package/config/appsettings.liquid.example.json +129 -0
- package/config/appsettings.ollama-whisper.example.json +92 -0
- package/config/appsettings.ollama.example.json +70 -0
- package/config/appsettings.whisper.example.json +31 -0
- package/mcp/whisper/README.md +293 -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 +897 -0
- package/orkeon-code.mjs +71 -0
- package/orkeon-code.ps1 +837 -0
- package/package.json +57 -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 +562 -0
- package/src/commands/_lib/args.ts +193 -0
- package/src/commands/_lib/dev/dev-batches.ts +368 -0
- package/src/commands/_lib/dev/dev-implement.ts +188 -0
- package/src/commands/_lib/dev/dev-source.ts +65 -0
- package/src/commands/_lib/dev/dev.ts +344 -0
- package/src/commands/_lib/dev-step.ts +142 -0
- package/src/commands/_lib/dispatch.ts +231 -0
- package/src/commands/_lib/effort.ts +15 -0
- package/src/commands/_lib/git/branch.ts +95 -0
- package/src/commands/_lib/git/commit.ts +94 -0
- package/src/commands/_lib/git/diff.ts +97 -0
- package/src/commands/_lib/git/review.ts +109 -0
- package/src/commands/_lib/memory/memory-admit.ts +150 -0
- package/src/commands/_lib/memory/memory.ts +51 -0
- package/src/commands/_lib/pr-context.ts +32 -0
- package/src/commands/_lib/project/analyze.ts +24 -0
- package/src/commands/_lib/session/export.ts +104 -0
- package/src/commands/_lib/session/resume.ts +160 -0
- package/src/commands/_lib/session/tasks.ts +184 -0
- package/src/commands/_lib/settings/advisor.ts +80 -0
- package/src/commands/_lib/settings/agents.ts +147 -0
- package/src/commands/_lib/settings/config.ts +141 -0
- package/src/commands/_lib/settings/hooks.ts +58 -0
- package/src/commands/_lib/settings/mode.ts +91 -0
- package/src/commands/_lib/settings/model.ts +146 -0
- package/src/commands/_lib/settings/permissions.ts +309 -0
- package/src/commands/_lib/settings/session-config.ts +49 -0
- package/src/commands/_lib/settings/skills.ts +51 -0
- package/src/commands/_lib/speech/say.ts +96 -0
- package/src/commands/_lib/speech/transcribe.ts +130 -0
- package/src/commands/_lib/speech/voice.ts +146 -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 +186 -0
- package/src/commands/_lib/status/meta.ts +45 -0
- package/src/commands/_lib/status/status.ts +129 -0
- package/src/commands/_lib/status/usage-tools.ts +49 -0
- package/src/commands/_lib/status/usage.ts +139 -0
- package/src/commands/_lib/view.ts +29 -0
- package/src/commands/dev/dev-batches.cmd.ts +108 -0
- package/src/commands/dev/dev-learn.cmd.ts +29 -0
- package/src/commands/dev/dev-plan.cmd.ts +52 -0
- package/src/commands/dev/dev-spec.cmd.ts +55 -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 +67 -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 +44 -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 +17 -0
- package/src/commands/session/resume.cmd.ts +19 -0
- package/src/commands/session/rewind.cmd.ts +26 -0
- package/src/commands/session/summary.cmd.ts +27 -0
- package/src/commands/session/tasks.cmd.ts +44 -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 +17 -0
- package/src/commands/settings/effort.cmd.ts +40 -0
- package/src/commands/settings/fast.cmd.ts +17 -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 +20 -0
- package/src/commands/settings/output-style.cmd.ts +48 -0
- package/src/commands/settings/permissions.cmd.ts +25 -0
- package/src/commands/settings/proactive.cmd.ts +15 -0
- package/src/commands/settings/skills.cmd.ts +17 -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 +3946 -0
- package/src/crews/_probe-shared-memory/domain/probe-verdict.ts +183 -0
- package/src/crews/_probe-shared-memory/probe.ork.ts +98 -0
- package/src/crews/advisor/application/run-advisor.ts +40 -0
- package/src/crews/advisor/crew.ork.ts +43 -0
- package/src/crews/advisor/domain/advice.ts +135 -0
- package/src/crews/agent-run/application/run-agent-run.ts +42 -0
- package/src/crews/agent-run/crew.ork.ts +67 -0
- package/src/crews/analyze/application/run-analyze.ts +118 -0
- package/src/crews/analyze/crew.ork.ts +40 -0
- package/src/crews/analyze/domain/harvest.ts +301 -0
- package/src/crews/code-review/application/prompts.ts +133 -0
- package/src/crews/code-review/application/review.ts +71 -0
- package/src/crews/code-review/application/run-code-review.ts +123 -0
- package/src/crews/code-review/crew.ork.ts +51 -0
- package/src/crews/code-review/domain/lenses.ts +193 -0
- package/src/crews/code-review/domain/report.ts +59 -0
- package/src/crews/code-review/domain/scope.ts +112 -0
- package/src/crews/dev-batches/application/plan-close.ts +181 -0
- package/src/crews/dev-batches/application/run-dev-batches.ts +669 -0
- package/src/crews/dev-batches/application/run-wave.ts +450 -0
- package/src/crews/dev-batches/application/seed-harvest.ts +162 -0
- package/src/crews/dev-batches/crew.ork.ts +143 -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 +54 -0
- package/src/crews/dev-batches/domain/wave-order.ts +43 -0
- package/src/crews/dev-change/application/change-prompt.ts +104 -0
- package/src/crews/dev-change/application/evidence.ts +169 -0
- package/src/crews/dev-change/application/run-dev-change.ts +315 -0
- package/src/crews/dev-change/crew.ork.ts +112 -0
- package/src/crews/dev-change/domain/change-answer.ts +159 -0
- package/src/crews/dev-change/domain/change-render.ts +79 -0
- package/src/crews/dev-implement/application/close.ts +183 -0
- package/src/crews/dev-implement/application/count-open-steps.ts +24 -0
- package/src/crews/dev-implement/application/locate-sheet.ts +80 -0
- package/src/crews/dev-implement/application/observe.ts +50 -0
- package/src/crews/dev-implement/application/report-writes.ts +41 -0
- package/src/crews/dev-implement/application/run-dev-implement.ts +811 -0
- package/src/crews/dev-implement/application/run-role.ts +27 -0
- package/src/crews/dev-implement/application/suite-job.ts +118 -0
- package/src/crews/dev-implement/application/touched.ts +74 -0
- package/src/crews/dev-implement/crew.ork.ts +68 -0
- package/src/crews/dev-implement/domain/contracts.ts +256 -0
- package/src/crews/dev-implement/domain/correction.ts +102 -0
- package/src/crews/dev-implement/domain/cycles.ts +35 -0
- package/src/crews/dev-implement/domain/implement-budget.ts +29 -0
- package/src/crews/dev-implement/domain/roles.ts +53 -0
- package/src/crews/dev-implement/domain/sheet-edits.ts +75 -0
- package/src/crews/dev-implement/domain/sheet-ticks.ts +22 -0
- package/src/crews/dev-implement/domain/step-checks.ts +136 -0
- package/src/crews/dev-implement/domain/step-section.ts +127 -0
- package/src/crews/dev-learn/application/learn-backlog.ts +58 -0
- package/src/crews/dev-learn/application/learn-prompt.ts +140 -0
- package/src/crews/dev-learn/application/run-dev-learn.ts +553 -0
- package/src/crews/dev-learn/crew.ork.ts +52 -0
- package/src/crews/dev-learn/domain/learn-answer.ts +235 -0
- package/src/crews/dev-learn/domain/owner-lines.ts +86 -0
- package/src/crews/dev-learn/domain/proposals-render.ts +96 -0
- package/src/crews/dev-plan/application/anchor-paths.ts +76 -0
- package/src/crews/dev-plan/application/inventory.ts +170 -0
- package/src/crews/dev-plan/application/plan-prompt.ts +159 -0
- package/src/crews/dev-plan/application/run-dev-plan.ts +455 -0
- package/src/crews/dev-plan/crew.ork.ts +109 -0
- package/src/crews/dev-plan/domain/inventory-model.ts +95 -0
- package/src/crews/dev-plan/domain/plan-answer.ts +738 -0
- package/src/crews/dev-plan/domain/plan-render.ts +307 -0
- package/src/crews/dev-spec/application/run-dev-spec.ts +206 -0
- package/src/crews/dev-spec/application/spec-prompt.ts +98 -0
- package/src/crews/dev-spec/crew.ork.ts +108 -0
- package/src/crews/dev-spec/domain/spec-answer.ts +253 -0
- package/src/crews/dev-spec/domain/spec-render.ts +76 -0
- package/src/crews/dev-verify/application/audit.ts +259 -0
- package/src/crews/dev-verify/application/auditor-prompt.ts +323 -0
- package/src/crews/dev-verify/application/capture.ts +303 -0
- package/src/crews/dev-verify/application/run-dev-verify.ts +409 -0
- package/src/crews/dev-verify/application/run-gate.ts +202 -0
- package/src/crews/dev-verify/crew.ork.ts +103 -0
- package/src/crews/dev-verify/domain/audit-answer.ts +150 -0
- package/src/crews/dev-verify/domain/auditor-charter.ts +21 -0
- package/src/crews/dev-verify/domain/capture-sections.ts +137 -0
- package/src/crews/dev-verify/domain/commands.ts +103 -0
- package/src/crews/dev-verify/domain/gate.ts +126 -0
- package/src/crews/dev-verify/domain/mechanical-table.ts +163 -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 +154 -0
- package/src/crews/git-commit/application/run-git-commit.ts +116 -0
- package/src/crews/git-commit/crew.ork.ts +52 -0
- package/src/crews/git-commit/domain/commit.ts +220 -0
- package/src/crews/init-verifiers/application/authoring.ts +89 -0
- package/src/crews/init-verifiers/application/prompts.ts +103 -0
- package/src/crews/init-verifiers/application/run-init-verifiers.ts +25 -0
- package/src/crews/init-verifiers/crew.ork.ts +34 -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 +77 -0
- package/src/crews/main-loop/application/context-gather.ts +133 -0
- package/src/crews/main-loop/application/run-main-loop.ts +350 -0
- package/src/crews/main-loop/application/turn-prompt.ts +112 -0
- package/src/crews/main-loop/crew.ork.ts +119 -0
- package/src/crews/main-loop/domain/autocompact.ts +27 -0
- package/src/crews/main-loop/domain/prompt-assembly.ts +521 -0
- package/src/crews/main-loop/domain/turn-chains.ts +129 -0
- package/src/crews/project-init/application/detect.ts +122 -0
- package/src/crews/project-init/application/prompts.ts +101 -0
- package/src/crews/project-init/application/run-project-init.ts +31 -0
- package/src/crews/project-init/crew.ork.ts +35 -0
- package/src/crews/project-init/domain/conventions.ts +36 -0
- package/src/crews/project-init/domain/existing-files.ts +63 -0
- package/src/crews/project-init/domain/package-map.ts +73 -0
- package/src/crews/session-compact/crew.ork.ts +55 -0
- package/src/crews/shared-memory-admit/crew.ork.ts +48 -0
- package/src/crews/speech/application/run-speech.ts +25 -0
- package/src/crews/speech/crew.ork.ts +37 -0
- package/src/shared/application/agents/child-agent.ts +255 -0
- package/src/shared/application/agents/run-sub-agent.ts +96 -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 +237 -0
- package/src/shared/application/compaction/extract-memories.ts +38 -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 +113 -0
- package/src/shared/application/dev/close-batch.ts +83 -0
- package/src/shared/application/dev/find-repo-pack.ts +77 -0
- package/src/shared/application/dev/learn-decision.ts +252 -0
- package/src/shared/application/dev/load-dev-context.ts +266 -0
- package/src/shared/application/dev/measure-access-cost.ts +68 -0
- package/src/shared/application/dev/plan-source.ts +112 -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/question-round.ts +52 -0
- package/src/shared/application/dev/resolve-work-folder.ts +133 -0
- package/src/shared/application/dev/script-tool-slot.ts +27 -0
- package/src/shared/application/dev/settle-questions.ts +55 -0
- package/src/shared/application/dev/source-review.ts +63 -0
- package/src/shared/application/dev/source-step.ts +150 -0
- package/src/shared/application/dev/spend.ts +42 -0
- package/src/shared/application/dev/step-precedents.ts +89 -0
- package/src/shared/application/dev/tool-call-policy.ts +89 -0
- package/src/shared/application/dev/tool-callbacks.ts +215 -0
- package/src/shared/application/dev/tool-trace-recorder.ts +45 -0
- package/src/shared/application/dev/verdict-sources.ts +48 -0
- package/src/shared/application/dev/wrapped-tools.ts +145 -0
- package/src/shared/application/extra-tools.ts +70 -0
- package/src/shared/application/git/batch-worktree.ts +97 -0
- package/src/shared/application/git/commit-files.ts +186 -0
- package/src/shared/application/git/merge-batch.ts +63 -0
- package/src/shared/application/git/open-pull-request.ts +51 -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 +35 -0
- package/src/shared/application/permission-rules.ts +159 -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/files.ts +21 -0
- package/src/shared/application/ports/human.ts +13 -0
- package/src/shared/application/ports/llm.ts +54 -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/tools.ts +46 -0
- package/src/shared/application/ports/usage.ts +45 -0
- package/src/shared/application/ports.ts +27 -0
- package/src/shared/application/project-manifests.ts +106 -0
- package/src/shared/application/session-io.ts +84 -0
- package/src/shared/application/session-state.ts +36 -0
- package/src/shared/application/shared-memory/admit-entries.ts +177 -0
- package/src/shared/application/shared-memory/harvest-after-gaps.ts +72 -0
- package/src/shared/application/shared-memory/harvest-mistakes.ts +44 -0
- package/src/shared/application/shared-memory/import-agent-memory.ts +117 -0
- package/src/shared/application/shared-memory/memory-files.ts +110 -0
- package/src/shared/application/shared-memory/memory-settings.ts +93 -0
- package/src/shared/application/shared-memory/push-candidate.ts +146 -0
- package/src/shared/application/shared-memory/recall-precedents.ts +69 -0
- package/src/shared/application/state-snapshot.ts +38 -0
- package/src/shared/application/workflow/workflow-state.ts +135 -0
- package/src/shared/domain/agent-policy/behavior-flags.ts +168 -0
- package/src/shared/domain/agent-policy/extra-tools.ts +69 -0
- package/src/shared/domain/agent-policy/memory-categories.ts +6 -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/permission.ts +623 -0
- package/src/shared/domain/agent-policy/rule-sets.ts +412 -0
- package/src/shared/domain/agent-policy/tool-access.ts +77 -0
- package/src/shared/domain/agent-registry.ts +142 -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 +61 -0
- package/src/shared/domain/agents/exclusive.ts +24 -0
- package/src/shared/domain/agents/instances.ts +249 -0
- package/src/shared/domain/code-intel-contract.ts +356 -0
- package/src/shared/domain/code-intel-routing.ts +113 -0
- package/src/shared/domain/compact-outcome.ts +44 -0
- package/src/shared/domain/compaction-thresholds.ts +161 -0
- package/src/shared/domain/compaction.ts +379 -0
- package/src/shared/domain/config-schema.ts +421 -0
- package/src/shared/domain/dev/access-cost.ts +226 -0
- package/src/shared/domain/dev/artefacts.ts +50 -0
- package/src/shared/domain/dev/batches-concurrency.ts +36 -0
- package/src/shared/domain/dev/batches-state.ts +49 -0
- package/src/shared/domain/dev/build-commands.ts +44 -0
- package/src/shared/domain/dev/call-guard.ts +341 -0
- package/src/shared/domain/dev/carried-text.ts +49 -0
- package/src/shared/domain/dev/design-rules.ts +100 -0
- package/src/shared/domain/dev/learn-proposals.ts +175 -0
- package/src/shared/domain/dev/learn-state.ts +93 -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/plan-checks.ts +190 -0
- package/src/shared/domain/dev/plan-format.ts +180 -0
- package/src/shared/domain/dev/project-files.ts +43 -0
- package/src/shared/domain/dev/questions.ts +249 -0
- package/src/shared/domain/dev/reading-rule.ts +41 -0
- package/src/shared/domain/dev/repo-pack.ts +237 -0
- package/src/shared/domain/dev/review-answer.ts +150 -0
- package/src/shared/domain/dev/review-prompt.ts +221 -0
- package/src/shared/domain/dev/reviewer-charter.ts +31 -0
- package/src/shared/domain/dev/sheet-facts.ts +83 -0
- package/src/shared/domain/dev/spec-format.ts +183 -0
- package/src/shared/domain/dev/step-budget.ts +72 -0
- package/src/shared/domain/dev/step-rules.ts +110 -0
- package/src/shared/domain/dev/test-commands.ts +90 -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 +64 -0
- package/src/shared/domain/dev/trait-pattern.ts +83 -0
- package/src/shared/domain/dev/verdict-format.ts +169 -0
- package/src/shared/domain/dev/whitespace.ts +34 -0
- package/src/shared/domain/dev/work-folder.ts +67 -0
- package/src/shared/domain/dev/yaml-subset.ts +403 -0
- package/src/shared/domain/git/close.ts +273 -0
- package/src/shared/domain/git/pull-request.ts +96 -0
- package/src/shared/domain/git/worktree.ts +46 -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 +106 -0
- package/src/shared/domain/llm-profile.ts +25 -0
- package/src/shared/domain/marked-message.ts +33 -0
- package/src/shared/domain/model-catalog.ts +86 -0
- package/src/shared/domain/permission-modes.ts +103 -0
- package/src/shared/domain/prelude.ts +92 -0
- package/src/shared/domain/project-manifests.ts +83 -0
- package/src/shared/domain/search-routing.ts +85 -0
- package/src/shared/domain/secret-patterns.ts +45 -0
- package/src/shared/domain/session-keys.ts +85 -0
- package/src/shared/domain/session-start.ts +60 -0
- package/src/shared/domain/session-summary.ts +13 -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 +143 -0
- package/src/shared/domain/shared-memory/candidates.ts +41 -0
- package/src/shared/domain/shared-memory/entry.ts +145 -0
- package/src/shared/domain/shared-memory/front-matter.ts +183 -0
- package/src/shared/domain/shared-memory/gate.ts +44 -0
- package/src/shared/domain/shared-memory/harvest.ts +61 -0
- package/src/shared/domain/shared-memory/layout.ts +187 -0
- package/src/shared/domain/shared-memory/precedents-block.ts +93 -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/snip-turns.ts +45 -0
- package/src/shared/domain/speech.ts +20 -0
- package/src/shared/domain/strip.ts +88 -0
- package/src/shared/domain/tool-trace.ts +122 -0
- package/src/shared/domain/types.ts +67 -0
- package/src/shared/domain/verifiers.ts +37 -0
- package/src/shared/domain/vfs.ts +9 -0
- package/src/shared/domain/workflow/state-file.ts +140 -0
- package/src/shared/infrastructure/globals.ts +52 -0
- package/src/shared/infrastructure/orkeon/approvals.ts +24 -0
- package/src/shared/infrastructure/orkeon/child-agents.ts +127 -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/dev-deps.ts +172 -0
- package/src/shared/infrastructure/orkeon/files.ts +40 -0
- package/src/shared/infrastructure/orkeon/github-pull-requests.ts +29 -0
- package/src/shared/infrastructure/orkeon/host-provider.ts +22 -0
- package/src/shared/infrastructure/orkeon/human-input.ts +59 -0
- package/src/shared/infrastructure/orkeon/llm-profile.ts +38 -0
- package/src/shared/infrastructure/orkeon/llm.ts +109 -0
- package/src/shared/infrastructure/orkeon/memory-store.ts +41 -0
- package/src/shared/infrastructure/orkeon/memory-tools.ts +131 -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/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 +134 -0
- package/src/shared/infrastructure/orkeon/session-store.ts +138 -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 +75 -0
- package/src/shared/infrastructure/orkeon/shell.ts +31 -0
- package/src/shared/infrastructure/orkeon/telemetry.ts +63 -0
- package/src/shared/infrastructure/orkeon/tool-catalogue.ts +75 -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 +118 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// The cycles of a run: consecutive open steps whose `## Anchors` row names the same first test file are one
|
|
2
|
+
// behaviour, run as one cycle - every step's RED before any production line, then one GREEN and one Cost for
|
|
3
|
+
// them all (the harness groups the steps that share a test class; the file is what code can see). A step alone
|
|
4
|
+
// on its file is a cycle of one. Pure.
|
|
5
|
+
import type { ImplementStep } from "./step-section.ts";
|
|
6
|
+
import { testFileOf } from "./contracts.ts";
|
|
7
|
+
|
|
8
|
+
export interface Cycle { steps: ImplementStep[]; testFile: string | null }
|
|
9
|
+
|
|
10
|
+
export function cyclesOf(open: readonly ImplementStep[]): Cycle[] {
|
|
11
|
+
const out: Cycle[] = [];
|
|
12
|
+
for (const step of open) {
|
|
13
|
+
const file = testFileOf(step);
|
|
14
|
+
const last = out[out.length - 1];
|
|
15
|
+
if (last !== undefined && file !== null && last.testFile === file && last.steps[last.steps.length - 1].number + 1 === step.number) {
|
|
16
|
+
last.steps.push(step);
|
|
17
|
+
} else {
|
|
18
|
+
out.push({ steps: [step], testFile: file });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return out;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** `steps 1-2`, `step 3`, `steps 1, 3`. */
|
|
25
|
+
export function stepsLabel(steps: readonly ImplementStep[]): string {
|
|
26
|
+
if (steps.length === 1) return `step ${steps[0].number}`;
|
|
27
|
+
const numbers = steps.map((s) => s.number);
|
|
28
|
+
const run = numbers.every((n, i) => i === 0 || n === numbers[i - 1] + 1);
|
|
29
|
+
return run ? `steps ${numbers[0]}-${numbers[numbers.length - 1]}` : `steps ${numbers.join(", ")}`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** The line announcing the mapping, before the first RED. */
|
|
33
|
+
export function cyclesLine(cycles: readonly Cycle[]): string {
|
|
34
|
+
return cycles.map((c, i) => `cycle ${i + 1}/${cycles.length} — ${stepsLabel(c.steps)} (${c.testFile ?? "no test file"})`).join("; ");
|
|
35
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// The budget of one dev-implement run, sized to the steps it has to run (temp/02 G-29): each step
|
|
2
|
+
// is two acts and two test runs; the batch ends with the build and the whole suite, each bounded
|
|
3
|
+
// by SUITE_LIMIT_SECONDS. The close run (commit, push, pull request) gets a fixed budget. Pure.
|
|
4
|
+
import type { StepBudget } from "../../../shared/domain/dev/step-budget.ts";
|
|
5
|
+
import { IMPLEMENTER, TEST_AUTHOR } from "./roles.ts";
|
|
6
|
+
|
|
7
|
+
/** The longest a final build or suite may run before the batch stops, in seconds. */
|
|
8
|
+
export const SUITE_LIMIT_SECONDS = 3600;
|
|
9
|
+
/** The longest wait between two looks at a running suite, in seconds; the first waits are shorter. */
|
|
10
|
+
export const SLICE_SECONDS = 20;
|
|
11
|
+
export const DEFAULT_STEPS = 3;
|
|
12
|
+
export const MAX_STEPS = 12;
|
|
13
|
+
|
|
14
|
+
export const CLOSE_BUDGET: StepBudget = { toolCalls: 40, wallTime: 900, contextTokens: 50_000, delegationDepth: 0 };
|
|
15
|
+
|
|
16
|
+
/** The steps to size for: a whole number from 1 to MAX_STEPS; DEFAULT_STEPS when not given or not a number. */
|
|
17
|
+
export function stepsToSize(value: unknown): number {
|
|
18
|
+
const n = typeof value === "number" && Number.isFinite(value) ? Math.floor(value) : DEFAULT_STEPS;
|
|
19
|
+
return Math.max(1, Math.min(MAX_STEPS, n));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** One step's tool calls: both roles' whole iterations, the Cost re-ask and code's own test runs. */
|
|
23
|
+
export const STEP_TOOL_CALLS = TEST_AUTHOR.maxIterations + IMPLEMENTER.maxIterations + 10;
|
|
24
|
+
|
|
25
|
+
export function implementBudget(input: { steps?: unknown; close?: unknown }): StepBudget {
|
|
26
|
+
if (input.close === true) return CLOSE_BUDGET;
|
|
27
|
+
const s = stepsToSize(input.steps);
|
|
28
|
+
return { toolCalls: STEP_TOOL_CALLS * s + 40, wallTime: 900 * s + 2 * SUITE_LIMIT_SECONDS, contextTokens: 150_000 * s, delegationDepth: 0 };
|
|
29
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// The two writing roles of a batch step, run as two acts of the crew's one agent (RT-04): each act
|
|
2
|
+
// is offered its own tools out of the agent's, and runs under its own role's deny rules
|
|
3
|
+
// (step-rules.ts ROLE_ROOTS): the test author writes no production file, the implementer no test
|
|
4
|
+
// file, and neither rewrites an existing source file whole (the rewrite rule): both read and edit by
|
|
5
|
+
// node. Neither gets shell_command: tests and builds go through run_tests and run_build. Pure.
|
|
6
|
+
import { BOUNDED_READ_RULE, KNOWN_TOOLS_RULE, NODE_EDIT_RULE, NODE_READ_RULE } from "../../../shared/domain/dev/reading-rule.ts";
|
|
7
|
+
|
|
8
|
+
export type RoleName = "test-author" | "implementer";
|
|
9
|
+
|
|
10
|
+
export interface RoleSpec {
|
|
11
|
+
name: RoleName;
|
|
12
|
+
system: string;
|
|
13
|
+
tools: readonly string[];
|
|
14
|
+
maxIterations: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const READ_TOOLS = ["file_read", "node_outline", "node_read", "glob", "grep"] as const;
|
|
18
|
+
const WRITE_TOOLS = ["file_write", "edit_file", "node_replace", "node_insert", "node_ensure", "edit_batch"] as const;
|
|
19
|
+
|
|
20
|
+
export const TEST_AUTHOR: RoleSpec = {
|
|
21
|
+
name: "test-author",
|
|
22
|
+
system: [
|
|
23
|
+
"You are the test author of one step of a dev batch. You write the failing tests the brief names, in the test",
|
|
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.",
|
|
27
|
+
NODE_READ_RULE,
|
|
28
|
+
BOUNDED_READ_RULE,
|
|
29
|
+
NODE_EDIT_RULE,
|
|
30
|
+
KNOWN_TOOLS_RULE,
|
|
31
|
+
].join(" "),
|
|
32
|
+
tools: [...READ_TOOLS, ...WRITE_TOOLS, "run_tests", "memory_recall"],
|
|
33
|
+
maxIterations: 40,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const IMPLEMENTER: RoleSpec = {
|
|
37
|
+
name: "implementer",
|
|
38
|
+
system: [
|
|
39
|
+
"You are the implementer of one step of a dev batch. You write the least production code that turns the red",
|
|
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.",
|
|
42
|
+
NODE_READ_RULE,
|
|
43
|
+
BOUNDED_READ_RULE,
|
|
44
|
+
NODE_EDIT_RULE,
|
|
45
|
+
KNOWN_TOOLS_RULE,
|
|
46
|
+
].join(" "),
|
|
47
|
+
tools: [...READ_TOOLS, ...WRITE_TOOLS, "run_tests", "run_build", "memory_recall"],
|
|
48
|
+
maxIterations: 60,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/** Every tool the crew's agent holds: the union of the two roles' tools, the script tools apart
|
|
52
|
+
* (run_tests, run_build, memory_recall: attached, never named). */
|
|
53
|
+
export const CREW_TOOLS: readonly string[] = [...READ_TOOLS, ...WRITE_TOOLS];
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// The other lines code writes into a batch sheet and its global plan, besides the TDD boxes: the assumptions a
|
|
2
|
+
// role settled mid-batch (rows `| H<n> | <text> | the user |` of `## Assumptions`), and at the close
|
|
3
|
+
// the done marks - the sheet's title ` — done (<date>)`, the plan's `### Batch F<n> — <Name> — done (<date>)` and
|
|
4
|
+
// its step boxes ticked. Each edit is idempotent. Pure, never throws.
|
|
5
|
+
import { parseBatchSheet, unfencedLines } from "../../../shared/domain/dev/plan-format.ts";
|
|
6
|
+
|
|
7
|
+
/** An answer's way of saying it assumed nothing: `none`, `none needed — …`, `n/a`, `nothing`. */
|
|
8
|
+
const NO_ASSUMPTION = /^(?:none|n\/a|nothing)\b/i;
|
|
9
|
+
|
|
10
|
+
/** The `Assumption: <text>` lines of a role's answer, in order, once each; a line that assumes nothing is no row. */
|
|
11
|
+
export function assumptionsOf(answer: string): string[] {
|
|
12
|
+
const out: string[] = [];
|
|
13
|
+
for (const raw of answer.split("\n")) {
|
|
14
|
+
const m = /^\s*(?:[-*]\s*)?\**Assumption\**\s*:\s*(.+)$/i.exec(raw);
|
|
15
|
+
const text = m?.[1].replace(/\s+/g, " ").replace(/\|/g, "/").trim();
|
|
16
|
+
if (text && !NO_ASSUMPTION.test(text) && !out.includes(text)) out.push(text);
|
|
17
|
+
}
|
|
18
|
+
return out;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const TABLE_HEAD = ["| # | Assumption | To be validated by |", "|---|------------|--------------------|"];
|
|
22
|
+
|
|
23
|
+
/** The sheet with each new assumption as an `H<n>` row of the `## Assumptions` table (`/dev-plan` renders it empty;
|
|
24
|
+
* the section created before `## Decisions`, else at the end), numbered after the rows it holds, the list lines of
|
|
25
|
+
* older sheets counted; an assumption already written is not written again. */
|
|
26
|
+
export function addAssumptions(text: string, assumptions: readonly string[]): { text: string; added: string[] } {
|
|
27
|
+
if (assumptions.length === 0) return { text, added: [] };
|
|
28
|
+
const held = parseBatchSheet(text).assumptions ?? [];
|
|
29
|
+
const known = new Set(held.map((a) => a.assumption));
|
|
30
|
+
let n = held.reduce((max, a) => Math.max(max, Number(a.id.slice(1))), 0);
|
|
31
|
+
const added = assumptions.filter((a) => !known.has(a));
|
|
32
|
+
if (added.length === 0) return { text, added: [] };
|
|
33
|
+
const rows = added.map((a) => `| H${++n} | ${a} | the user |`);
|
|
34
|
+
const raw = text.split("\n");
|
|
35
|
+
const lines = unfencedLines(text);
|
|
36
|
+
const at = lines.findIndex((l) => l.text.trim() === "## Assumptions");
|
|
37
|
+
if (at >= 0) {
|
|
38
|
+
const next = lines.slice(at + 1).find((l) => l.text.startsWith("## "));
|
|
39
|
+
let end = next === undefined ? raw.length : next.line - 1;
|
|
40
|
+
while (end > lines[at].line && raw[end - 1].trim() === "") end--;
|
|
41
|
+
const body = raw.slice(lines[at].line, end);
|
|
42
|
+
// A section without the table (or with list lines after it) gets a table of its own after what it holds.
|
|
43
|
+
const table = body.length > 0 && body.at(-1)!.trim().startsWith("|") && body.some((l) => l.trim() === TABLE_HEAD[0]);
|
|
44
|
+
raw.splice(end, 0, ...(table ? rows : [...(body.length > 0 ? [""] : []), ...TABLE_HEAD, ...rows]));
|
|
45
|
+
return { text: raw.join("\n"), added };
|
|
46
|
+
}
|
|
47
|
+
const decisions = lines.find((l) => l.text.trim() === "## Decisions");
|
|
48
|
+
const block = ["## Assumptions", ...TABLE_HEAD, ...rows, ""];
|
|
49
|
+
if (decisions !== undefined) raw.splice(decisions.line - 1, 0, ...block);
|
|
50
|
+
else raw.push(...(raw[raw.length - 1]?.trim() === "" ? [] : [""]), ...block);
|
|
51
|
+
return { text: raw.join("\n"), added };
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** The sheet's title with ` — done (<date>)`; unchanged when it already says done. */
|
|
55
|
+
export function markSheetDone(text: string, date: string): string {
|
|
56
|
+
const lines = text.split("\n");
|
|
57
|
+
const at = lines.findIndex((l) => /^# \S+-PLAN-F\d+ — /.test(l));
|
|
58
|
+
if (at < 0 || / — done \(\d{4}-\d{2}-\d{2}\)$/.test(lines[at].trimEnd())) return text;
|
|
59
|
+
lines[at] = `${lines[at].trimEnd()} — done (${date})`;
|
|
60
|
+
return lines.join("\n");
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** The global plan with `### Batch <batch> — <Name> — open` made `— done (<date>)` and that batch's `- [ ]` boxes
|
|
64
|
+
* ticked; unchanged when the batch is not found or is done already. */
|
|
65
|
+
export function markPlanBatchDone(text: string, batch: string, date: string): string {
|
|
66
|
+
const lines = text.split("\n");
|
|
67
|
+
const head = new RegExp(`^### Batch ${batch} — (.+) — open$`);
|
|
68
|
+
const at = lines.findIndex((l) => head.test(l.trimEnd()));
|
|
69
|
+
if (at < 0) return text;
|
|
70
|
+
lines[at] = lines[at].trimEnd().replace(/ — open$/, ` — done (${date})`);
|
|
71
|
+
for (let i = at + 1; i < lines.length && !lines[i].startsWith("#"); i++) {
|
|
72
|
+
lines[i] = lines[i].replace(/^(\s*)- \[ \] /, "$1- [x] ");
|
|
73
|
+
}
|
|
74
|
+
return lines.join("\n");
|
|
75
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Ticking one box of one step's `TDD:` line, after code observed what the box stands for: the
|
|
2
|
+
// line of that step only, nothing else of the sheet. Idempotent: a box already ticked stays.
|
|
3
|
+
// Pure, never throws: what cannot be ticked comes back as a problem.
|
|
4
|
+
import { parseBatchSheet } from "../../../shared/domain/dev/plan-format.ts";
|
|
5
|
+
|
|
6
|
+
export type TddBox = "RED" | "GREEN" | "COST";
|
|
7
|
+
|
|
8
|
+
export type Ticked = { ok: true; text: string } | { ok: false; problem: string };
|
|
9
|
+
|
|
10
|
+
export function tickBox(sheet: string, step: number, box: TddBox): Ticked {
|
|
11
|
+
const found = parseBatchSheet(sheet).steps.find((s) => s.number === step);
|
|
12
|
+
if (found === undefined) return { ok: false, problem: `the sheet has no step ${step}` };
|
|
13
|
+
if (found.tdd === null) return { ok: false, problem: `step ${step} has no TDD line` };
|
|
14
|
+
const lines = sheet.split("\n");
|
|
15
|
+
const at = found.tdd.line - 1;
|
|
16
|
+
const line = lines[at] ?? "";
|
|
17
|
+
if (!line.startsWith("TDD:")) return { ok: false, problem: `line ${found.tdd.line} is not step ${step}'s TDD line` };
|
|
18
|
+
const box_ = new RegExp(`${box} \\[[ xX]\\]`);
|
|
19
|
+
if (!box_.test(line)) return { ok: false, problem: `step ${step}'s TDD line has no ${box} box` };
|
|
20
|
+
lines[at] = line.replace(new RegExp(`${box} \\[[ xX]\\]`), `${box} [x]`);
|
|
21
|
+
return { ok: true, text: lines.join("\n") };
|
|
22
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// The hard checks between two acts of a step, on what code observed, never on a role's word: the
|
|
2
|
+
// paths the act changed (two snapshots of the tree), and the narrow test run code made after it.
|
|
3
|
+
// RED holds when only test files changed and the tests fail; GREEN when no test file changed and
|
|
4
|
+
// the tests pass. The implementer's Cost line is read here too. Pure.
|
|
5
|
+
|
|
6
|
+
/** A tree snapshot: path → hash of its content; null when the content was not read. */
|
|
7
|
+
export type Snapshot = ReadonlyMap<string, string | null>;
|
|
8
|
+
|
|
9
|
+
/** What code's own test run gave: its exit, or why it did not run. */
|
|
10
|
+
export type ObservedRun = { ran: true; exit: number; timedOut: boolean; log: string | null } | { ran: false; reason: string };
|
|
11
|
+
|
|
12
|
+
/** Paths `git status --porcelain=v1` lists: both sides of a rename, quotes removed, `.orkeon/` left out. */
|
|
13
|
+
export function statusPaths(porcelain: string): string[] {
|
|
14
|
+
const out: string[] = [];
|
|
15
|
+
for (const raw of porcelain.split("\n")) {
|
|
16
|
+
if (raw.length < 4) continue;
|
|
17
|
+
for (const part of raw.slice(3).split(" -> ")) {
|
|
18
|
+
const path = unquote(part.trim());
|
|
19
|
+
if (path !== "" && !path.startsWith(".orkeon/") && !out.includes(path)) out.push(path);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return out;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function unquote(path: string): string {
|
|
26
|
+
if (!(path.startsWith('"') && path.endsWith('"'))) return path;
|
|
27
|
+
return path.slice(1, -1).replace(/\\(["\\])/g, "$1");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** The paths whose presence or content differs between two snapshots, sorted. */
|
|
31
|
+
export function changedPaths(before: Snapshot, after: Snapshot): string[] {
|
|
32
|
+
const paths = new Set([...before.keys(), ...after.keys()]);
|
|
33
|
+
return [...paths].filter((p) => {
|
|
34
|
+
if (!before.has(p) || !after.has(p)) return true;
|
|
35
|
+
const a = before.get(p);
|
|
36
|
+
const b = after.get(p);
|
|
37
|
+
// Unread on both sides (too large, binary, or past the snapshot's cap): not a change code saw; a role's
|
|
38
|
+
// own write to it is still counted, from the paths its write tools named.
|
|
39
|
+
if (a === null && b === null) return false;
|
|
40
|
+
return a !== b;
|
|
41
|
+
}).sort();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { under } from "../../../shared/domain/dev/test-paths.ts";
|
|
45
|
+
|
|
46
|
+
/** Tells a test file from a production one, by the pack (shared/domain/dev/test-paths.ts). */
|
|
47
|
+
export type IsTest = (path: string) => boolean;
|
|
48
|
+
|
|
49
|
+
function runProblem(run: ObservedRun): string | null {
|
|
50
|
+
if (!run.ran) return `the step's tests did not run: ${run.reason}`;
|
|
51
|
+
if (run.timedOut) return "the step's tests timed out";
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Why RED does not hold; null when it does. `stubs` are the production files the step marks `to create`, which
|
|
56
|
+
* the test author may write as signature stubs. */
|
|
57
|
+
export function redProblem(changed: readonly string[], isTest: IsTest, run: ObservedRun, stubs: readonly string[] = []): string | null {
|
|
58
|
+
if (changed.length === 0) return "the test author changed no file";
|
|
59
|
+
const outside = changed.filter((p) => !isTest(p) && !stubs.includes(p));
|
|
60
|
+
if (outside.length > 0) return `a production path changed before a red test: ${outside.join(", ")}`;
|
|
61
|
+
if (!changed.some(isTest)) return `the test author changed no test file, only stubs: ${changed.join(", ")}`;
|
|
62
|
+
const problem = runProblem(run);
|
|
63
|
+
if (problem !== null) return problem;
|
|
64
|
+
if (run.ran && run.exit === 0) return "the new tests pass at once: a test green before its code is never kept";
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const FAILURE_COUNTS = [
|
|
69
|
+
/\b(\d+)\s+(?:failed|failing|failures?)\b/gi,
|
|
70
|
+
/\b(?:failed|failures?|fail)\s*[:=]?\s+(\d+)\b/gi,
|
|
71
|
+
];
|
|
72
|
+
|
|
73
|
+
/** The failure count a test run's tail shows last (`2 failed`, `fail 2`, `Failed: 2`), or null when it shows none. */
|
|
74
|
+
export function failureCount(tail: string): number | null {
|
|
75
|
+
let last: { at: number; n: number } | null = null;
|
|
76
|
+
for (const re of FAILURE_COUNTS) {
|
|
77
|
+
for (const m of tail.matchAll(re)) {
|
|
78
|
+
if (last === null || (m.index ?? 0) >= last.at) last = { at: m.index ?? 0, n: Number(m[1]) };
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return last === null ? null : last.n;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Whether a later RED step of a cycle added a failure: its file failed already (the earlier step's tests), so the
|
|
85
|
+
* exit code alone cannot tell a new test that passes at once. A problem when both counts are read and none was
|
|
86
|
+
* added; `unknown` when a count cannot be read. `beforeTail` is the earlier run's tail, or a count already read. */
|
|
87
|
+
export function addedFailure(beforeTail: string | number | null, afterTail: string): { problem: string } | "ok" | "unknown" {
|
|
88
|
+
const before = typeof beforeTail === "string" ? failureCount(beforeTail) : beforeTail;
|
|
89
|
+
const after = failureCount(afterTail);
|
|
90
|
+
if (before === null || after === null) return "unknown";
|
|
91
|
+
if (after > before) return "ok";
|
|
92
|
+
return { problem: `the new tests add no failure (failures ${before} → ${after}): a test green before its code is never kept` };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Why GREEN does not hold; null when it does. `before` is code's run just before the act: tests that failed then
|
|
96
|
+
* and pass now with no file changed turned green by themselves (flaky), which is never kept. */
|
|
97
|
+
export function greenProblem(changed: readonly string[], isTest: IsTest, run: ObservedRun, before?: ObservedRun): string | null {
|
|
98
|
+
const tests = changed.filter(isTest);
|
|
99
|
+
if (tests.length > 0) return `a test file changed while turning it green: ${tests.join(", ")}`;
|
|
100
|
+
const problem = runProblem(run);
|
|
101
|
+
if (problem !== null) return problem;
|
|
102
|
+
if (run.ran && run.exit !== 0) return `the step's tests still fail (exit ${run.exit})`;
|
|
103
|
+
if (changed.length === 0 && before?.ran === true && before.exit !== 0) {
|
|
104
|
+
return "the implementer changed no file, yet the tests that failed before now pass: a test that turns green by itself is flaky";
|
|
105
|
+
}
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export type CostRead = { ok: true; line: string } | { ok: false; problem: string; line?: string };
|
|
110
|
+
|
|
111
|
+
const BLOCKING_ACCESS = /\b(loops?|lambdas?|memory filters?)\b/i;
|
|
112
|
+
const PLACE = "(?:a |any |one )?(?:loops?|lambdas?|memory filters?)";
|
|
113
|
+
/** The one "where" that clears a line naming a loop, a lambda or a memory filter: none of them holds a port call. */
|
|
114
|
+
const NONE_WHERE = new RegExp(
|
|
115
|
+
`^(?:none|nothing|no port call(?: (?:in|inside|within) ${PLACE}(?:,? (?:or |nor )?${PLACE})*)?)\\.?$`, "i");
|
|
116
|
+
/** A none the model explains (`none — no port, no loop over a port call`): cleared unless the reason takes it back. */
|
|
117
|
+
const NONE_EXPLAINED = /^(?:none|nothing)\s*(?:[—–:(]|-\s|,\s)/i;
|
|
118
|
+
const TAKEN_BACK = /\b(?:but|except|however|apart from|save for)\b/i;
|
|
119
|
+
const clearsWhere = (where: string): boolean => NONE_WHERE.test(where) || (NONE_EXPLAINED.test(where) && !TAKEN_BACK.test(where));
|
|
120
|
+
|
|
121
|
+
/** The implementer's `Cost:` line; refused when absent, or when it names a loop, a lambda or a memory filter
|
|
122
|
+
* anywhere but in a "where" that says no port call sits in one (`…; none`, `…; none — <its reason>`, `…; no port call in a
|
|
123
|
+
* loop`). */
|
|
124
|
+
export function readCost(answer: string): CostRead {
|
|
125
|
+
const match = /^\s*\**Cost\**\s*:\s*(.+)$/im.exec(answer);
|
|
126
|
+
if (match === null) return { ok: false, problem: "the implementer stated no Cost line" };
|
|
127
|
+
const body = match[1].trim();
|
|
128
|
+
const line = `Cost: ${body}`;
|
|
129
|
+
const cut = body.indexOf(";");
|
|
130
|
+
const counts = cut < 0 ? body : body.slice(0, cut);
|
|
131
|
+
const where = cut < 0 ? "" : body.slice(cut + 1).trim();
|
|
132
|
+
if (BLOCKING_ACCESS.test(counts) || (BLOCKING_ACCESS.test(where) && !clearsWhere(where))) {
|
|
133
|
+
return { ok: false, problem: `a port call in a loop, a lambda or a memory filter: back to /dev-plan (${line})`, line };
|
|
134
|
+
}
|
|
135
|
+
return { ok: true, line };
|
|
136
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// What dev-implement reads off one batch sheet: per step its tests table, its TDD line and its
|
|
2
|
+
// `## Anchors` row, and for the whole batch the `## Code elements`, the `Applied rules` and
|
|
3
|
+
// `Access cost` rows of `## Design` and the `## Test policy and scopes` text. Line-based over
|
|
4
|
+
// plan-format's unfenced lines, as the sheet is written by /dev-plan. Pure, never throws.
|
|
5
|
+
import { parseBatchSheet, unfencedLines } from "../../../shared/domain/dev/plan-format.ts";
|
|
6
|
+
import type { TddTicks } from "../../../shared/domain/dev/plan-format.ts";
|
|
7
|
+
|
|
8
|
+
export interface StepTest { name: string; level: string; project: string; ids: string[] }
|
|
9
|
+
/** One path of an Anchors cell: `to create`, `existing`, or the member it names; its line when given. */
|
|
10
|
+
export interface AnchorRef { path: string; line?: number; state: "to create" | "existing" | "member"; member?: string }
|
|
11
|
+
export interface StepAnchor { testFiles: AnchorRef[]; doubles: string; production: AnchorRef[] }
|
|
12
|
+
export interface ImplementStep {
|
|
13
|
+
number: number; title: string; tests: StepTest[]; tdd: TddTicks | null; anchor: StepAnchor | null; note: string[];
|
|
14
|
+
}
|
|
15
|
+
export interface ImplementSheet {
|
|
16
|
+
prefix?: string; batch?: string; name?: string;
|
|
17
|
+
steps: ImplementStep[]; codeElements: string[]; appliedRules: string; accessCost: string; testPolicy: string;
|
|
18
|
+
problems: string[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const STEP_HEADING = /^### Step (\d+) — (.+)$/;
|
|
22
|
+
const SEPARATOR_ROW = /^\|[-: |]+$/;
|
|
23
|
+
const IDS = /\b[A-Z][A-Z0-9]*-[0-9]+\b/g;
|
|
24
|
+
const REF = /`([^`]+)`(?:\s*—\s*(to create|existing|`([^`]+)`))?/;
|
|
25
|
+
|
|
26
|
+
function cellsOf(row: string): string[] {
|
|
27
|
+
return row.replace(/^\|/, "").replace(/\|$/, "").split("|").map((c) => c.trim());
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function unquote(cell: string): string {
|
|
31
|
+
const m = /^`([^`]*)`$/.exec(cell.trim());
|
|
32
|
+
return m ? m[1] : cell.trim();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** `path:line` split; a path without a trailing `:<n>` keeps no line. */
|
|
36
|
+
function pathAndLine(text: string): { path: string; line?: number } {
|
|
37
|
+
const m = /^(.*):(\d+)$/.exec(text);
|
|
38
|
+
return m ? { path: m[1], line: Number(m[2]) } : { path: text };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** The references of one Anchors cell: `—` alone is none; parts are split on `;`. */
|
|
42
|
+
export function anchorRefs(cell: string): AnchorRef[] {
|
|
43
|
+
const out: AnchorRef[] = [];
|
|
44
|
+
for (const part of cell.split(";")) {
|
|
45
|
+
const m = REF.exec(part.trim());
|
|
46
|
+
if (!m) continue;
|
|
47
|
+
const at = pathAndLine(m[1].trim());
|
|
48
|
+
if (m[3] !== undefined) out.push({ ...at, state: "member", member: m[3] });
|
|
49
|
+
else out.push({ ...at, state: m[2] === "to create" ? "to create" : "existing" });
|
|
50
|
+
}
|
|
51
|
+
return out;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** The lines of the `## <name>` section, heading excluded, up to the next `## `. */
|
|
55
|
+
function section(lines: readonly string[], name: string): string[] {
|
|
56
|
+
const out: string[] = [];
|
|
57
|
+
let inside = false;
|
|
58
|
+
for (const l of lines) {
|
|
59
|
+
if (l.startsWith("## ")) { inside = l.trim() === `## ${name}`; continue; }
|
|
60
|
+
if (inside) out.push(l);
|
|
61
|
+
}
|
|
62
|
+
return out;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function designRow(design: readonly string[], point: string): string {
|
|
66
|
+
const row = design.find((l) => new RegExp(`^\\| *${point} *\\|`).test(l));
|
|
67
|
+
return row === undefined ? "" : cellsOf(row).slice(1).join(" | ");
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function parseImplementSheet(text: string): ImplementSheet {
|
|
71
|
+
const base = parseBatchSheet(text);
|
|
72
|
+
const lines = unfencedLines(text).map((l) => l.text);
|
|
73
|
+
const sheet: ImplementSheet = {
|
|
74
|
+
prefix: base.prefix, batch: base.batch, name: base.name, steps: [],
|
|
75
|
+
codeElements: section(lines, "Code elements").filter((l) => l.trim() !== ""),
|
|
76
|
+
appliedRules: designRow(section(lines, "Design"), "Applied rules"),
|
|
77
|
+
accessCost: designRow(section(lines, "Design"), "Access cost"),
|
|
78
|
+
testPolicy: section(lines, "Test policy and scopes").filter((l) => l.trim() !== "").join("\n"),
|
|
79
|
+
problems: base.problems.map((p) => `line ${p.line}: ${p.message}`),
|
|
80
|
+
};
|
|
81
|
+
const ticks = new Map(base.steps.map((s) => [s.number, s.tdd]));
|
|
82
|
+
|
|
83
|
+
let current: ImplementStep | null = null;
|
|
84
|
+
for (const l of section(lines, "TDD sequence")) {
|
|
85
|
+
const heading = STEP_HEADING.exec(l);
|
|
86
|
+
if (heading) {
|
|
87
|
+
current = {
|
|
88
|
+
number: Number(heading[1]), title: heading[2], tests: [], tdd: ticks.get(Number(heading[1])) ?? null,
|
|
89
|
+
anchor: null, note: [],
|
|
90
|
+
};
|
|
91
|
+
sheet.steps.push(current);
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (current === null || l.startsWith("TDD:") || l.trim() === "") continue;
|
|
95
|
+
if (l.startsWith("|")) {
|
|
96
|
+
const cells = cellsOf(l);
|
|
97
|
+
if (SEPARATOR_ROW.test(l) || cells[0] === "#" || cells.length < 5) continue;
|
|
98
|
+
current.tests.push({
|
|
99
|
+
name: unquote(cells[1]), level: cells[2], project: unquote(cells[3]), ids: cells[4].match(IDS) ?? [],
|
|
100
|
+
});
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
current.note.push(l.trim());
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
for (const row of section(lines, "Anchors")) {
|
|
107
|
+
if (!row.startsWith("|") || SEPARATOR_ROW.test(row)) continue;
|
|
108
|
+
const cells = cellsOf(row);
|
|
109
|
+
const number = /^(\d+)\b/.exec(cells[0] ?? "");
|
|
110
|
+
if (number === null || cells.length < 4) continue;
|
|
111
|
+
const step = sheet.steps.find((s) => s.number === Number(number[1]));
|
|
112
|
+
if (step === undefined) { sheet.problems.push(`an Anchors row names step ${number[1]}, which the sheet lacks`); continue; }
|
|
113
|
+
step.anchor = { testFiles: anchorRefs(cells[1]), doubles: cells[2] === "—" ? "" : cells[2], production: anchorRefs(cells[3]) };
|
|
114
|
+
}
|
|
115
|
+
for (const s of sheet.steps) {
|
|
116
|
+
if (s.tdd !== null && s.tests.length === 0) sheet.problems.push(`step ${s.number} has a TDD line and no test`);
|
|
117
|
+
if (s.tdd !== null && (s.anchor === null || s.anchor.testFiles.length === 0)) {
|
|
118
|
+
sheet.problems.push(`step ${s.number} names no test file in ## Anchors`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return sheet;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** The steps still to run: a TDD line with a box left open, in order. */
|
|
125
|
+
export function openSteps(sheet: ImplementSheet): ImplementStep[] {
|
|
126
|
+
return sheet.steps.filter((s) => s.tdd !== null && !(s.tdd.red && s.tdd.green && s.tdd.cost));
|
|
127
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// What /dev-learn reads before it judges anything: every verdict file of the work
|
|
2
|
+
// folder (shared/application/dev/verdict-sources.ts), the two learning states and the
|
|
3
|
+
// refused motifs. It reads only; a file that cannot be read becomes a warning, never a failure.
|
|
4
|
+
import type { Files } from "../../../shared/application/ports.ts";
|
|
5
|
+
import type { WorkFolder } from "../../../shared/application/dev/resolve-work-folder.ts";
|
|
6
|
+
import { collectLearnRows, untreated as untreatedRows } from "../../../shared/domain/shared-memory/verdict-rows.ts";
|
|
7
|
+
import type { LearnRow } from "../../../shared/domain/shared-memory/verdict-rows.ts";
|
|
8
|
+
import { readVerdictSources } from "../../../shared/application/dev/verdict-sources.ts";
|
|
9
|
+
import {
|
|
10
|
+
HARNESS_LEARN_STATE_FILE, LEARN_STATE_FILE, emptyLearnState, parseHarnessLearnState, parseLearnState,
|
|
11
|
+
} from "../../../shared/domain/dev/learn-state.ts";
|
|
12
|
+
import type { HarnessLearnState, LearnState } from "../../../shared/domain/dev/learn-state.ts";
|
|
13
|
+
import { REFUSED_FILE, parseRefused } from "../../../shared/domain/shared-memory/refused.ts";
|
|
14
|
+
import type { RefusedMotif } from "../../../shared/domain/shared-memory/refused.ts";
|
|
15
|
+
import { WORKSPACE } from "../../../shared/domain/vfs.ts";
|
|
16
|
+
|
|
17
|
+
export { FOLDER_LIST_CAP, WORK_LIST_CAP } from "../../../shared/application/dev/verdict-sources.ts";
|
|
18
|
+
|
|
19
|
+
export interface Backlog {
|
|
20
|
+
rows: LearnRow[]; // every row, collected (§ 1.3)
|
|
21
|
+
untreated: LearnRow[];
|
|
22
|
+
files: number;
|
|
23
|
+
orkeon: LearnState; harness: HarnessLearnState; refused: RefusedMotif[];
|
|
24
|
+
refusedFile: string; // refused.md under memory.dir, relative to the project
|
|
25
|
+
warnings: string[];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** The file's text, or null when it cannot be read (an absent file reads as absent). */
|
|
29
|
+
async function readOrNull(files: Pick<Files, "read">, path: string): Promise<string | null> {
|
|
30
|
+
try {
|
|
31
|
+
return await files.read(path);
|
|
32
|
+
} catch {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** `refusedFile`: refused.md under memory.dir, relative to the project (readRefusedFile). */
|
|
38
|
+
export async function readBacklog(files: Pick<Files, "read" | "list">, work: WorkFolder, refusedFile: string = REFUSED_FILE): Promise<Backlog> {
|
|
39
|
+
const { sources, warnings } = await readVerdictSources(files, work);
|
|
40
|
+
const rows = collectLearnRows(sources);
|
|
41
|
+
|
|
42
|
+
let orkeon = emptyLearnState();
|
|
43
|
+
const read = parseLearnState(await readOrNull(files, `${WORKSPACE}/${LEARN_STATE_FILE}`));
|
|
44
|
+
if (read.ok) orkeon = read.state;
|
|
45
|
+
else warnings.push(read.problem);
|
|
46
|
+
|
|
47
|
+
const harness = parseHarnessLearnState(await readOrNull(files, `${WORKSPACE}/${HARNESS_LEARN_STATE_FILE}`));
|
|
48
|
+
|
|
49
|
+
const refusedText = await readOrNull(files, `${WORKSPACE}/${refusedFile}`);
|
|
50
|
+
const list = refusedText === null ? { motifs: [], problems: [] } : parseRefused(refusedText);
|
|
51
|
+
for (const p of list.problems) warnings.push(`${refusedFile}:${p.message}`);
|
|
52
|
+
|
|
53
|
+
const treated = new Set([...orkeon.treated, ...harness.treated]);
|
|
54
|
+
return {
|
|
55
|
+
rows, untreated: untreatedRows(rows, treated), files: sources.length,
|
|
56
|
+
orkeon, harness, refused: list.motifs, refusedFile, warnings,
|
|
57
|
+
};
|
|
58
|
+
}
|