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,146 @@
|
|
|
1
|
+
// @orkeon-script 1.0
|
|
2
|
+
/// <reference path="../.orkeon/orkeon.d.ts" />
|
|
3
|
+
//
|
|
4
|
+
// DevBatches crew (/dev-batches). Composition root: one agent, the reviewer's read tools, whose body is
|
|
5
|
+
// application/run-dev-batches: it reads the plan, its sheets, its verdicts and the log
|
|
6
|
+
// `.orkeon/dev/<code>/batches-state.md`, logs what came of the batch the chain just ran, then stops (a human
|
|
7
|
+
// decides), closes the plan (one push, one pull request) or names the next batch in the dependencies' order,
|
|
8
|
+
// after the preflight and, for a batch whose dependencies just closed, one review of its sheet (inline, read
|
|
9
|
+
// tools only). Sequential, it launches nothing: a crew cannot (crew-host.ts), the command's `completed` does.
|
|
10
|
+
// With `concurrency` 2 to 4, the driver runs a wave itself (application/run-wave.ts): each batch in a batch agent
|
|
11
|
+
// spawned under its own worktree (`.workingRoot`), its steps, its audit inline and its close run in code there
|
|
12
|
+
// (runBatchChain), every batch at once; the driver, only writer of the main checkout, merges them in id order.
|
|
13
|
+
//
|
|
14
|
+
// Input (globalThis.inputs): { code?: string (absent: the run .orkeon/dev/batches-active.json names),
|
|
15
|
+
// pr?: boolean, after?: string[] (the last lines the batch's chain answered),
|
|
16
|
+
// concurrency?: 1 to 4 (absent: 1, or the record's; above 1 in bypassPermissions),
|
|
17
|
+
// permissionMode?, permissionRules?, githubTool?, hooks?, effort?, memoryRecall? }
|
|
18
|
+
// Answer: JSON { lines: string[], next?: { crew: "dev-implement" | "dev-batches", input } }, read by the command's
|
|
19
|
+
// completed: dev-implement for the next batch of a sequential run, dev-batches for a parallel run's next wave.
|
|
20
|
+
// Run standalone: bash scripts/run-crew.sh src/crews/dev-batches/crew.ork.ts --inputs '{"code":"prune"}'
|
|
21
|
+
// (it logs the batch it names as launched and launches nothing: drive that batch with dev-implement)
|
|
22
|
+
//
|
|
23
|
+
// Budget: domain/batches-budget.ts (the driver's, and each batch agent's run: L8P-D12, Orkeon/orkeon#189).
|
|
24
|
+
|
|
25
|
+
import { CrewBuilder, publishCrew, inputs, ToolBuilder } from "../../shared/infrastructure/globals.ts";
|
|
26
|
+
import {
|
|
27
|
+
orkeonActRoute,
|
|
28
|
+
orkeonPrunedLlm,
|
|
29
|
+
orkeonAgent,
|
|
30
|
+
orkeonClock,
|
|
31
|
+
orkeonConfigStore,
|
|
32
|
+
orkeonFiles,
|
|
33
|
+
orkeonPullRequestOpener,
|
|
34
|
+
orkeonShell,
|
|
35
|
+
} from "../../shared/infrastructure/orkeon/wiring.ts";
|
|
36
|
+
import { agentLlm } from "../../shared/infrastructure/orkeon/llm.ts";
|
|
37
|
+
import { memoryDirOf } from "../../shared/application/shared-memory/memory-settings.ts";
|
|
38
|
+
import { harvestAfterGaps } from "../../shared/application/shared-memory/harvest-after-gaps.ts";
|
|
39
|
+
import { devToolCallbacks } from "../../shared/application/dev/tool-callbacks.ts";
|
|
40
|
+
import { batchAgentParts, gitTopUnder, implementDeps, verifyDeps } from "../../shared/infrastructure/orkeon/dev-deps.ts";
|
|
41
|
+
import { charterCatalogue } from "../../shared/domain/agents/charter.ts";
|
|
42
|
+
import { providerEffort } from "../../shared/domain/agent-policy/behavior-flags.ts";
|
|
43
|
+
import { REVIEWER_CHARTER } from "../../shared/domain/dev/reviewer-charter.ts";
|
|
44
|
+
import { parseSessionRules } from "../../shared/domain/git/pull-request.ts";
|
|
45
|
+
import { CREW_TOOLS } from "../dev-implement/domain/roles.ts";
|
|
46
|
+
import { implementInputs, runDevImplement } from "../dev-implement/application/run-dev-implement.ts";
|
|
47
|
+
import { AUDITOR_CHARTER } from "../dev-verify/domain/auditor-charter.ts";
|
|
48
|
+
import { runDevVerify } from "../dev-verify/application/run-dev-verify.ts";
|
|
49
|
+
import { batchLimits, driverBudget } from "./domain/batches-budget.ts";
|
|
50
|
+
import { outcomeOf, runBatchChain } from "./application/run-wave.ts";
|
|
51
|
+
import type { BatchRun } from "./application/run-wave.ts";
|
|
52
|
+
import type { BatchesContext } from "./application/run-dev-batches.ts";
|
|
53
|
+
import { runDevBatches } from "./application/run-dev-batches.ts";
|
|
54
|
+
import { DEV_BATCHES_GOAL, GIT_TOP_PROBE_GOAL, batchAgentGoal } from "./application/prompts.ts";
|
|
55
|
+
|
|
56
|
+
const effort = providerEffort(inputs().effort);
|
|
57
|
+
// A batch agent writes and audits: the implementer's tools and the auditor's read tools.
|
|
58
|
+
const BATCH_TOOLS = [...new Set([...CREW_TOOLS, ...charterCatalogue(AUDITOR_CHARTER)])];
|
|
59
|
+
|
|
60
|
+
/** One batch's agent, under its worktree: its own script-tool slots, spend and tools bound by its body. */
|
|
61
|
+
function batchAgent(run: BatchRun, context: BatchesContext) {
|
|
62
|
+
const limits = batchLimits(run.steps);
|
|
63
|
+
const memoryOn = context.memoryRecall !== false;
|
|
64
|
+
const { spend, toolSlot, validationSlot, bodyTools, tools } = batchAgentParts(ToolBuilder, { root: run.root, toolCalls: limits.toolCalls, memoryOn });
|
|
65
|
+
const batchEffort = providerEffort(context.effort ?? undefined);
|
|
66
|
+
const options = { hooks: context.hooks, effort: batchEffort, memoryOn, root: run.root, spend };
|
|
67
|
+
// What the sequential run hands dev-implement (run-dev-batches.ts): no github tool, its close never pushed.
|
|
68
|
+
const launch = {
|
|
69
|
+
plan: run.code, hooks: context.hooks, effort: context.effort,
|
|
70
|
+
permissionMode: context.permissionMode, permissionRules: context.permissionRules, githubTool: false,
|
|
71
|
+
...(context.memoryRecall === false ? { memoryRecall: false } : {}),
|
|
72
|
+
};
|
|
73
|
+
const builder = orkeonAgent()
|
|
74
|
+
.name(`batch-${run.batch}`)
|
|
75
|
+
.role("Batch runner")
|
|
76
|
+
.goal(batchAgentGoal(run.batch, run.code))
|
|
77
|
+
.workingRoot(run.root)
|
|
78
|
+
.tools(BATCH_TOOLS)
|
|
79
|
+
.withAutonomousTools(tools)
|
|
80
|
+
.maxIterations(Math.max(60, AUDITOR_CHARTER.maxIterations))
|
|
81
|
+
.body(async (_input: any, ctx: any) => {
|
|
82
|
+
bodyTools.bind(ctx.tools);
|
|
83
|
+
// The audit acts inline on this agent's Llm (no background child, no board: L8P-D2); the harvest after
|
|
84
|
+
// GAPS is the driver's, on the main checkout.
|
|
85
|
+
const outcome = await runBatchChain(run, launch, {
|
|
86
|
+
implement: (input) => runDevImplement(implementInputs(input), implementDeps(ctx, { ...options, toolSlot })),
|
|
87
|
+
verify: (input) => runDevVerify(input, { ...verifyDeps(ctx, { ...options, validationSlot }), route: orkeonActRoute(ctx.log, ctx.tools, run.root) }),
|
|
88
|
+
spend,
|
|
89
|
+
});
|
|
90
|
+
return JSON.stringify(outcome);
|
|
91
|
+
});
|
|
92
|
+
return { builder: batchEffort === undefined ? builder : builder.effort(batchEffort), limits };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const builder = orkeonAgent()
|
|
96
|
+
.name("dev-batches")
|
|
97
|
+
.role("Batch driver")
|
|
98
|
+
.goal(DEV_BATCHES_GOAL)
|
|
99
|
+
// The reviewer's read tools, for the review of the next batch; the rest is code's.
|
|
100
|
+
.tools(charterCatalogue(REVIEWER_CHARTER))
|
|
101
|
+
.maxIterations(REVIEWER_CHARTER.maxIterations)
|
|
102
|
+
.body(async (_input: any, ctx: any) => {
|
|
103
|
+
// The ports over this body's tools: a parallel wave's batch agents run beside it under other roots, where the
|
|
104
|
+
// global `tools` refuses a call.
|
|
105
|
+
const ports = { shell: orkeonShell(ctx.tools), files: orkeonFiles(ctx.tools), config: orkeonConfigStore(ctx.tools) };
|
|
106
|
+
const clock = orkeonClock();
|
|
107
|
+
return await runDevBatches(inputs(), {
|
|
108
|
+
...ports, log: ctx.log, clock, route: orkeonActRoute(ctx.log, ctx.tools),
|
|
109
|
+
// These callbacks, then the host's gate on the input they return: the dev rule sets again and the run's /hooks (a chained run
|
|
110
|
+
// reads them from its record, as it does the /effort). The reviewer only reads: the plan step's guard fits it.
|
|
111
|
+
reviewerFor: (c) => orkeonPrunedLlm(agentLlm(ctx, devToolCallbacks({ step: "dev-plan", hooks: c.hooks }, { shell: ports.shell, log: ctx.log, memoryDir: memoryDirOf(ports.config) }),
|
|
112
|
+
{ effort: providerEffort(c.effort ?? undefined) }), ctx.log, ctx.tools),
|
|
113
|
+
openerFor: (c) => orkeonPullRequestOpener({ mode: c.permissionMode, rules: parseSessionRules(c.permissionRules), asked: false }, ctx.tools),
|
|
114
|
+
// A parallel wave: each batch in its own agent under its worktree and its own budget (batches-budget.ts).
|
|
115
|
+
runBatch: async (run, context) => {
|
|
116
|
+
const agent = batchAgent(run, context);
|
|
117
|
+
const answered = await crew.runAgent(ctx.spawn(agent.builder), {},
|
|
118
|
+
{ signal: ctx.signal, timeout: agent.limits.wallTime * 1000, budget: agent.limits });
|
|
119
|
+
return outcomeOf(run.batch, answered);
|
|
120
|
+
},
|
|
121
|
+
// git under the first worktree, as an agent rooted there sees it (L8P-D11, Orkeon/orkeon#188).
|
|
122
|
+
probe: async (root) => {
|
|
123
|
+
const probe = orkeonAgent()
|
|
124
|
+
.name(`probe-${root.slice(root.lastIndexOf("/") + 1)}`)
|
|
125
|
+
.role("Worktree probe")
|
|
126
|
+
.goal(GIT_TOP_PROBE_GOAL)
|
|
127
|
+
.workingRoot(root)
|
|
128
|
+
.tools(["shell_command"])
|
|
129
|
+
.body(async (_i: any, pctx: any) => JSON.stringify(await gitTopUnder(pctx.tools, root)));
|
|
130
|
+
const answered = await crew.runAgent(ctx.spawn(probe), {}, { signal: ctx.signal, timeout: 60_000 });
|
|
131
|
+
return JSON.parse(String(answered)) as { exitCode: number; top: string };
|
|
132
|
+
},
|
|
133
|
+
// M-7 after a batch's GAPS, on the main checkout's verdicts (a batch agent never harvests).
|
|
134
|
+
afterGaps: (work) => harvestAfterGaps({ ...ports, clock, log: ctx.log }, work),
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
const driver = (effort === undefined ? builder : builder.effort(effort)).build();
|
|
138
|
+
|
|
139
|
+
const crew = CrewBuilder()
|
|
140
|
+
.name("dev-batches")
|
|
141
|
+
.process("sequential")
|
|
142
|
+
.budget(driverBudget(inputs().concurrency))
|
|
143
|
+
.withAgent(driver)
|
|
144
|
+
.build();
|
|
145
|
+
|
|
146
|
+
publishCrew(crew);
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// The waves a parallel /dev-batches would run a plan's open batches in: a wave holds the batches whose
|
|
2
|
+
// dependencies are done or in an earlier wave, taken by batch number, each kept only when the paths its
|
|
3
|
+
// sheet anchors are disjoint from those of the batches already in the wave; one left out waits for the
|
|
4
|
+
// next wave. A batch that anchors no path cannot be shown disjoint and runs alone. An unknown dependency
|
|
5
|
+
// or a cycle refuses the plan, as the sequential order does (wave-order.ts). Pure.
|
|
6
|
+
//
|
|
7
|
+
// A parallel /dev-batches (`--concurrency n`, n from 2) runs the first wave, at most n of it, each batch under its
|
|
8
|
+
// own worktree (application/run-wave.ts).
|
|
9
|
+
import { compareBatchIds } from "../../../shared/domain/dev/artefacts.ts";
|
|
10
|
+
import { anchorRefs, parseImplementSheet } from "../../dev-implement/domain/step-section.ts";
|
|
11
|
+
import { waveOrder } from "./wave-order.ts";
|
|
12
|
+
|
|
13
|
+
export interface WaveBatch {
|
|
14
|
+
id: string;
|
|
15
|
+
dependsOn: readonly string[];
|
|
16
|
+
/** The paths its sheet's `## Anchors` names (any column), as written. */
|
|
17
|
+
anchors: readonly string[];
|
|
18
|
+
done: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type Waves = { ok: true; waves: string[][] } | { ok: false; problem: string };
|
|
22
|
+
|
|
23
|
+
/** A path as compared: `./` and a trailing `:<line>` cut. */
|
|
24
|
+
export function barePath(path: string): string {
|
|
25
|
+
return path.trim().replace(/^(\.\/)+/, "").replace(/:\d+$/, "");
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** The paths of a sheet's `## Anchors`: its test, doubles and production columns, bare, unique, sorted. A doubles
|
|
29
|
+
* part's note in parentheses (`(\`writes\` to add)`) names a member, not a path. */
|
|
30
|
+
export function sheetAnchorPaths(sheet: string): string[] {
|
|
31
|
+
const out = new Set<string>();
|
|
32
|
+
for (const step of parseImplementSheet(sheet).steps) {
|
|
33
|
+
if (step.anchor === null) continue;
|
|
34
|
+
const doubles = step.anchor.doubles.split(";").flatMap((part) => anchorRefs(part.split("(")[0]));
|
|
35
|
+
for (const ref of [...step.anchor.testFiles, ...step.anchor.production, ...doubles]) {
|
|
36
|
+
const path = barePath(ref.path);
|
|
37
|
+
if (path !== "") out.add(path);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return [...out].sort();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** The open batches in waves; done batches count as met dependencies and are in no wave. */
|
|
44
|
+
export function batchWaves(batches: readonly WaveBatch[]): Waves {
|
|
45
|
+
const order = waveOrder(batches.map((b) => ({ id: b.id, dependsOn: b.dependsOn, done: b.done })));
|
|
46
|
+
if (!order.ok) return order;
|
|
47
|
+
const met = new Set(batches.filter((b) => b.done).map((b) => b.id));
|
|
48
|
+
const left = batches.filter((b) => !b.done).sort((a, b) => compareBatchIds(a.id, b.id));
|
|
49
|
+
const waves: string[][] = [];
|
|
50
|
+
while (left.length > 0) {
|
|
51
|
+
const ready = left.filter((b) => b.dependsOn.every((d) => met.has(d)));
|
|
52
|
+
// waveOrder refused cycles: something is always ready.
|
|
53
|
+
const wave: WaveBatch[] = [];
|
|
54
|
+
const taken = new Set<string>();
|
|
55
|
+
for (const b of ready) {
|
|
56
|
+
const paths = b.anchors.map(barePath).filter((p) => p !== "");
|
|
57
|
+
const alone = paths.length === 0;
|
|
58
|
+
if (wave.length > 0 && (alone || paths.some((p) => taken.has(p)))) continue;
|
|
59
|
+
wave.push(b);
|
|
60
|
+
for (const p of paths) taken.add(p);
|
|
61
|
+
if (alone) break;
|
|
62
|
+
}
|
|
63
|
+
waves.push(wave.map((b) => b.id));
|
|
64
|
+
for (const b of wave) {
|
|
65
|
+
met.add(b.id);
|
|
66
|
+
left.splice(left.indexOf(b), 1);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return { ok: true, waves };
|
|
70
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// The budget of one /dev-batches run (temp/02 G-29): code reads the plan, its sheets, verdicts and log,
|
|
2
|
+
// runs a few git commands, and at most one review of the next batch (NEXT_BATCH_REVIEWER_CHARTER's 8 iterations,
|
|
3
|
+
// about 3 tool calls each, inline: no child) plus its extract call; the close of the plan adds a push and
|
|
4
|
+
// the pull request. 60 + 40 file and git calls = 100; 120 leaves a margin. Pure.
|
|
5
|
+
//
|
|
6
|
+
// A parallel wave (`concurrency` above 1): each batch agent is run by `crew.runAgent` under its own budget (the
|
|
7
|
+
// runtime's since Orkeon/orkeon#189): batchLimits, its tool calls, wall time and context tokens. Its tool calls are also
|
|
8
|
+
// counted in code, by the spend guard that denies past the same limit, so the act ends and the batch says what is
|
|
9
|
+
// left before the runtime would stop it; the runtime's bound is what holds its context tokens. Not charged to the driver's. The driver waits for the wave: its wall time adds the largest batch's and a margin, not their sum.
|
|
10
|
+
// Its own work grows with each batch of a wave: one review of its sheet (about 60 calls, as above) and the batch's
|
|
11
|
+
// git and file calls (its worktree made or reused, the seed's reads and writes, the log, the merge and its rebase,
|
|
12
|
+
// the harvest, the removal: about 16, 20 counted), so its tool calls and context tokens add that much per batch.
|
|
13
|
+
// No batch spawns and runAgent checks no depth: delegationDepth stays 0.
|
|
14
|
+
import type { StepBudget } from "../../../shared/domain/dev/step-budget.ts";
|
|
15
|
+
import { STEP_BUDGETS, TOKENS_PER_CALL } from "../../../shared/domain/dev/step-budget.ts";
|
|
16
|
+
import { CLOSE_BUDGET, MAX_STEPS, implementBudget } from "../../dev-implement/domain/implement-budget.ts";
|
|
17
|
+
|
|
18
|
+
export const BATCHES_BUDGET: StepBudget = { toolCalls: 120, wallTime: 1800, contextTokens: 200_000, delegationDepth: 0 };
|
|
19
|
+
|
|
20
|
+
/** One batch of a wave, for the driver: the review of its sheet, and its git and file calls. */
|
|
21
|
+
export const WAVE_REVIEW_CALLS = 60;
|
|
22
|
+
export const WAVE_BATCH_CALLS = 20;
|
|
23
|
+
|
|
24
|
+
/** The driver's time beyond its own and the longest batch's: the harvest, the merges, the removals. */
|
|
25
|
+
export const WAVE_MARGIN_SECONDS = 600;
|
|
26
|
+
|
|
27
|
+
export interface BatchLimits { toolCalls: number; wallTime: number; contextTokens: number }
|
|
28
|
+
|
|
29
|
+
/** One batch of a wave: its implement run sized to `steps`, its audit and its close, summed; the budget of its run. */
|
|
30
|
+
export function batchLimits(steps: unknown): BatchLimits {
|
|
31
|
+
const implement = implementBudget({ steps });
|
|
32
|
+
const verify = STEP_BUDGETS["dev-verify"];
|
|
33
|
+
return {
|
|
34
|
+
toolCalls: implement.toolCalls + verify.toolCalls + CLOSE_BUDGET.toolCalls,
|
|
35
|
+
wallTime: implement.wallTime + verify.wallTime + CLOSE_BUDGET.wallTime,
|
|
36
|
+
contextTokens: implement.contextTokens + verify.contextTokens + CLOSE_BUDGET.contextTokens,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** The driver's budget for a run of `concurrency` batches at once (the steps of a wave's batches are not known when
|
|
41
|
+
* the crew is built: the largest a batch can be sized to counts). */
|
|
42
|
+
export function driverBudget(concurrency: unknown): StepBudget {
|
|
43
|
+
const n = typeof concurrency === "number" ? concurrency : Number(concurrency);
|
|
44
|
+
if (!(Number.isFinite(n) && n > 1)) return BATCHES_BUDGET;
|
|
45
|
+
const calls = n * (WAVE_REVIEW_CALLS + WAVE_BATCH_CALLS);
|
|
46
|
+
return {
|
|
47
|
+
...BATCHES_BUDGET,
|
|
48
|
+
toolCalls: BATCHES_BUDGET.toolCalls + calls,
|
|
49
|
+
contextTokens: BATCHES_BUDGET.contextTokens + calls * TOKENS_PER_CALL,
|
|
50
|
+
wallTime: BATCHES_BUDGET.wallTime + batchLimits(MAX_STEPS).wallTime + WAVE_MARGIN_SECONDS,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// The lines /dev-batches appends to its log, `.orkeon/dev/<code>/batches-state.md`: the harness's
|
|
2
|
+
// shape, read back by shared/domain/dev/batches-state.ts, the start scripts and scripts/dev-run.sh.
|
|
3
|
+
// `- YYYY-MM-DD HH:MM F<n> <event> <detail>`, and `- YYYY-MM-DD HH:MM closed` last. Pure.
|
|
4
|
+
import type { BatchesLogEntry } from "../../../shared/domain/dev/batches-state.ts";
|
|
5
|
+
import { batchesStatePath } from "../../../shared/domain/workflow/state-file.ts";
|
|
6
|
+
import { WORKSPACE } from "../../../shared/domain/vfs.ts";
|
|
7
|
+
import { REVIEW_NOT_RUN } from "./markers.ts";
|
|
8
|
+
|
|
9
|
+
export type BatchEvent = "launched" | "relaunched" | "returned" | "merged" | "stopped";
|
|
10
|
+
|
|
11
|
+
/** The log's path under the workspace: Code's own state, never the harness's `<CODE>-BATCHES-STATE.md`. */
|
|
12
|
+
export function batchesLogPath(code: string): string {
|
|
13
|
+
return `${WORKSPACE}/${batchesStatePath(code)}`;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const pad = (n: number): string => String(n).padStart(2, "0");
|
|
17
|
+
|
|
18
|
+
/** `YYYY-MM-DD HH:MM` of a date, in UTC (the runtime's clock carries no zone the log could name). */
|
|
19
|
+
export function stamp(at: Date): string {
|
|
20
|
+
return `${at.getUTCFullYear()}-${pad(at.getUTCMonth() + 1)}-${pad(at.getUTCDate())} ${pad(at.getUTCHours())}:${pad(at.getUTCMinutes())}`;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** One line; the detail is kept on one line and bounded. */
|
|
24
|
+
export function eventLine(at: Date, batch: string, event: BatchEvent, detail = ""): string {
|
|
25
|
+
const d = detail.replace(/\s+/g, " ").trim().slice(0, 200);
|
|
26
|
+
return `- ${stamp(at)} ${batch} ${event}${d === "" ? "" : ` ${d}`}`;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function closedLine(at: Date): string {
|
|
30
|
+
return `- ${stamp(at)} closed`;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** The log with `lines` appended; a new log starts with its title and its `## Log` heading. */
|
|
34
|
+
export function appendToLog(text: string | null, code: string, lines: readonly string[]): string {
|
|
35
|
+
const base = text === null || text.trim() === ""
|
|
36
|
+
? `# ${code.toUpperCase()}-BATCHES-STATE\n\n## Log\n\n`
|
|
37
|
+
: text.endsWith("\n") ? text : `${text}\n`;
|
|
38
|
+
return base + lines.map((l) => `${l}\n`).join("");
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** The batch's last entry; undefined when it has none. */
|
|
42
|
+
export function lastEntryOf(entries: readonly BatchesLogEntry[], batch: string): BatchesLogEntry | undefined {
|
|
43
|
+
for (let i = entries.length - 1; i >= 0; i--) if (entries[i].batch === batch) return entries[i];
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** True when the batch's review is still owed before its launch: the batch has no entry yet, or its last entry is a
|
|
48
|
+
* stop because the review could not run. A stop for Blocking questions settles the review: the human settled them. */
|
|
49
|
+
export function reviewPending(entries: readonly BatchesLogEntry[], batch: string): boolean {
|
|
50
|
+
const last = lastEntryOf(entries, batch);
|
|
51
|
+
return last === undefined || (last.event === "stopped" && last.detail.startsWith(REVIEW_NOT_RUN));
|
|
52
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// The problems the domain of /dev-batches states: why a plan's batches have no order (ADR 0026).
|
|
2
|
+
|
|
3
|
+
// ── The order of the batches (wave-order.ts) ────────────────────────────────
|
|
4
|
+
|
|
5
|
+
export const selfDependency = (ids: string): string => `a batch depends on itself: ${ids}`;
|
|
6
|
+
export const dependencyCycle = (ids: string): string => `the dependencies form a cycle: ${ids}`;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// The order /dev-batches runs a plan's batches in: each after the batches it depends on, ties by
|
|
2
|
+
// batch number. A batch's dependencies are its summary row's `Depends on`, else its sheet's. An
|
|
3
|
+
// unknown dependency or a cycle refuses the plan. Pure.
|
|
4
|
+
import { compareBatchIds } from "../../../shared/domain/dev/artefacts.ts";
|
|
5
|
+
import { dependencyCycle, selfDependency } from "./messages.ts";
|
|
6
|
+
|
|
7
|
+
export interface BatchNode {
|
|
8
|
+
id: string;
|
|
9
|
+
dependsOn: readonly string[];
|
|
10
|
+
done: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type WaveOrder = { ok: true; order: string[] } | { ok: false; problem: string };
|
|
14
|
+
|
|
15
|
+
/** Kahn's order over the batches; the smallest batch number first among those ready. */
|
|
16
|
+
export function waveOrder(batches: readonly BatchNode[]): WaveOrder {
|
|
17
|
+
const ids = new Set(batches.map((b) => b.id));
|
|
18
|
+
const unknown: string[] = [];
|
|
19
|
+
for (const b of batches) {
|
|
20
|
+
for (const d of b.dependsOn) if (!ids.has(d)) unknown.push(`${b.id} depends on ${d}`);
|
|
21
|
+
}
|
|
22
|
+
if (unknown.length > 0) return { ok: false, problem: `unknown dependency: ${unknown.join(", ")}` };
|
|
23
|
+
const left = new Map(batches.map((b) => [b.id, new Set(b.dependsOn.filter((d) => d !== b.id))]));
|
|
24
|
+
const self = batches.filter((b) => b.dependsOn.includes(b.id)).map((b) => b.id);
|
|
25
|
+
if (self.length > 0) return { ok: false, problem: selfDependency(self.join(", ")) };
|
|
26
|
+
const order: string[] = [];
|
|
27
|
+
while (left.size > 0) {
|
|
28
|
+
const ready = [...left].filter(([, deps]) => deps.size === 0).map(([id]) => id).sort(compareBatchIds);
|
|
29
|
+
if (ready.length === 0) {
|
|
30
|
+
return { ok: false, problem: dependencyCycle([...left.keys()].sort(compareBatchIds).join(", ")) };
|
|
31
|
+
}
|
|
32
|
+
const next = ready[0];
|
|
33
|
+
order.push(next);
|
|
34
|
+
left.delete(next);
|
|
35
|
+
for (const deps of left.values()) deps.delete(next);
|
|
36
|
+
}
|
|
37
|
+
return { ok: true, order };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** The first batch of the order not done; null when every batch is. */
|
|
41
|
+
export function nextBatch(order: readonly string[], batches: readonly BatchNode[]): string | null {
|
|
42
|
+
const done = new Set(batches.filter((b) => b.done).map((b) => b.id));
|
|
43
|
+
return order.find((id) => !done.has(id)) ?? null;
|
|
44
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// The change writer's prompts, assembled for one extract call each: the brief's head, then its material cut to the
|
|
2
|
+
// room the cap leaves - past the cap the current file is cut first, then the origin, then the inventory - and the
|
|
3
|
+
// reproduction prompt with its origin cut. The text is ./prompts.ts's.
|
|
4
|
+
import type { Decision } from "../../../shared/domain/dev/questions.ts";
|
|
5
|
+
import type { ChangeKind } from "../../../shared/domain/dev/spec-format.ts";
|
|
6
|
+
import { NO_INVENTORY, changePromptHead, changePromptMaterial, cutByCode, reproPrompt } from "./prompts.ts";
|
|
7
|
+
import type { ChangePromptMode } from "./prompts.ts";
|
|
8
|
+
|
|
9
|
+
export interface ChangePromptInput {
|
|
10
|
+
mode: ChangePromptMode; code: string; kind: ChangeKind;
|
|
11
|
+
origin: string; facts: string; request: string; current: string;
|
|
12
|
+
decisions: readonly Decision[]; fresh: readonly Decision[]; inventory: string;
|
|
13
|
+
/** The "## Precedents" block the step recalled (T1), "" or absent when none: material, placed last. */
|
|
14
|
+
precedents?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const MAX_CHANGE_PROMPT_CHARS = 60_000;
|
|
18
|
+
const MIN_PART = 2_000;
|
|
19
|
+
/** The most of the origin the reproduction prompt carries. */
|
|
20
|
+
const MAX_REPRO_ORIGIN_CHARS = 12_000;
|
|
21
|
+
|
|
22
|
+
function cut(text: string, max: number): string {
|
|
23
|
+
return text.length <= max ? text : cutByCode(text.slice(0, Math.max(0, max - 20)));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function buildChangePrompt(input: ChangePromptInput, problems: readonly string[]): string {
|
|
27
|
+
const head = changePromptHead(input.code, input.kind, input.mode, problems, input.decisions, input.fresh);
|
|
28
|
+
const precedents = (input.precedents ?? "").trimEnd();
|
|
29
|
+
let room = MAX_CHANGE_PROMPT_CHARS - head.join("\n").length - input.facts.length - precedents.length - 400;
|
|
30
|
+
const inventory = cut(input.inventory.trimEnd() || NO_INVENTORY, Math.max(MIN_PART, Math.floor(room / 4)));
|
|
31
|
+
room -= inventory.length;
|
|
32
|
+
const origin = cut(input.origin.trim(), Math.max(MIN_PART, Math.floor(room / 3)));
|
|
33
|
+
room -= origin.length;
|
|
34
|
+
const current = cut(input.current.trimEnd(), Math.max(MIN_PART, room));
|
|
35
|
+
const material = changePromptMaterial({
|
|
36
|
+
current, origin, request: input.request.trim(), facts: input.facts.trim(), inventory, precedents,
|
|
37
|
+
});
|
|
38
|
+
return [...head, ...material].join("\n");
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** The prompt asking for the one command that shows the bug or measures the cost. */
|
|
42
|
+
export function buildReproPrompt(kind: "bug" | "perf", origin: string, commands: readonly string[], problems: readonly string[]): string {
|
|
43
|
+
return reproPrompt(kind, cut(origin.trim(), MAX_REPRO_ORIGIN_CHARS), commands, problems);
|
|
44
|
+
}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
// The facts a change brief stands on, gathered by code before anything is written: the origin read whole (an issue
|
|
2
|
+
// by `gh issue view`, a file of the checkout, or the text typed), and for a bug or a perf change the one command
|
|
3
|
+
// run - the `--run` one, else one the model proposes - accepted only when it is a narrow test command of the pack
|
|
4
|
+
// or the product's CLI followed by plain words (no path out of the checkout, no glob or expansion). Its output goes
|
|
5
|
+
// to repro-<code>.txt. A bug that does not fail - or whose command never ran (exit 126, 127) or was killed - a
|
|
6
|
+
// measurement that fails, or a run that times out stops the step: nothing else is written.
|
|
7
|
+
import type { Files, Llm, Shell } from "../../../shared/application/ports.ts";
|
|
8
|
+
import { firstLine, readRequest } from "../../../shared/application/dev/source-step.ts";
|
|
9
|
+
import type { RepoPackCommands } from "../../../shared/domain/dev/repo-pack.ts";
|
|
10
|
+
import { checkValidation, plainWords } from "../../../shared/domain/dev/test-commands.ts";
|
|
11
|
+
import { REPRO_SCHEMA } from "./prompts.ts";
|
|
12
|
+
import { buildReproPrompt } from "./change-material.ts";
|
|
13
|
+
import { GLOB_OR_EXPANSION, MEASURES_THE_COST, PATH_OUT_OF_CHECKOUT, REPRODUCES_THE_BUG, SHELL_OPERATOR_AFTER_CLI, evidenceCouldNotRun, couldNotStart, didNotReproduce, issuePrintedNoJson, issueViewFailed, measuredFact, measurementFailed, noCommandPicked, ranOutOfTime, reproductionFact, runMayNotRun, runtimeRefused, wasKilled } from "./messages.ts";
|
|
14
|
+
import { NOT_ONE_LINE } from "../../../shared/domain/dev/messages.ts";
|
|
15
|
+
import { errorText } from "../../../shared/domain/error-text.ts";
|
|
16
|
+
import { answerDidNotParse } from "../../../shared/application/agents/messages.ts";
|
|
17
|
+
|
|
18
|
+
export const REPRO_TIMEOUT_SECONDS = 600;
|
|
19
|
+
const MAX_COMMAND_CHARS = 400;
|
|
20
|
+
const MAX_OUTPUT_CHARS = 200_000;
|
|
21
|
+
const TAIL_LINES = 15;
|
|
22
|
+
const ISSUE = /^#(\d{1,7})$/;
|
|
23
|
+
/** Exits of a shell that never ran the command: 126 not executable, 127 not found. */
|
|
24
|
+
const NOT_RUN_EXITS = new Set([126, 127]);
|
|
25
|
+
|
|
26
|
+
export const issueCommand = (n: string): string => `gh issue view ${n} --json number,title,body,url`;
|
|
27
|
+
|
|
28
|
+
export type Origin = { text: string; from: string } | { refused: string };
|
|
29
|
+
|
|
30
|
+
export async function readOrigin(step: string, deps: { shell: Pick<Shell, "run">; files: Pick<Files, "read"> }, origin: string): Promise<Origin> {
|
|
31
|
+
const issue = ISSUE.exec(origin);
|
|
32
|
+
if (issue === null) return readRequest(step, deps.files, origin);
|
|
33
|
+
const command = issueCommand(issue[1]);
|
|
34
|
+
let out: string;
|
|
35
|
+
try {
|
|
36
|
+
const r = await deps.shell.run(command);
|
|
37
|
+
if (r.exitCode !== 0) throw new Error((r.stderr || r.stdout).trim() || `exit ${r.exitCode}`);
|
|
38
|
+
out = r.stdout;
|
|
39
|
+
} catch (e) {
|
|
40
|
+
return { refused: issueViewFailed(step, command, firstLine(e)) };
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
const v = JSON.parse(out) as { number?: number; title?: string; body?: string; url?: string };
|
|
44
|
+
return { text: [`#${v.number ?? issue[1]} ${v.title ?? ""}`.trim(), v.url ?? "", "", v.body ?? ""].join("\n").trim(), from: `issue #${issue[1]}` };
|
|
45
|
+
} catch {
|
|
46
|
+
return { refused: issuePrintedNoJson(step, command) };
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** The values a word of the CLI may carry a path in: the word, what follows each `=` (`--out=x`, `out=x`,
|
|
51
|
+
* `--a=b=/x`) and, for short options, what follows each letter of the cluster (`-o/x`, `-xf/x`). */
|
|
52
|
+
function pathValues(word: string): string[] {
|
|
53
|
+
const values = [word];
|
|
54
|
+
for (let i = word.indexOf("="); i >= 0; i = word.indexOf("=", i + 1)) values.push(word.slice(i + 1));
|
|
55
|
+
const cluster = /^-[A-Za-z]+/.exec(word);
|
|
56
|
+
if (cluster !== null) for (let i = 2; i <= cluster[0].length; i++) values.push(word.slice(i));
|
|
57
|
+
return values;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const outOfCheckout = (value: string): boolean =>
|
|
61
|
+
value.split(/[\\/]/).includes("..") || value.startsWith("/") || value.startsWith("~") || /^[A-Za-z]:/.test(value) || value.includes("\\");
|
|
62
|
+
|
|
63
|
+
/** Why a command may not run, null when it may: a narrow test command of the pack, or the CLI and plain words. */
|
|
64
|
+
export function commandProblem(command: string, commands: RepoPackCommands): string | null {
|
|
65
|
+
const c = command.trim();
|
|
66
|
+
if (c === "" || /[\r\n]/.test(c) || c.length > MAX_COMMAND_CHARS) return NOT_ONE_LINE;
|
|
67
|
+
const cli = commands.cli?.trim() ?? "";
|
|
68
|
+
if (cli !== "" && (c === cli || c.startsWith(`${cli} `))) {
|
|
69
|
+
if (!plainWords(c)) return SHELL_OPERATOR_AFTER_CLI;
|
|
70
|
+
const tail = c.slice(cli.length);
|
|
71
|
+
let quoted = false;
|
|
72
|
+
for (const ch of tail) {
|
|
73
|
+
if (ch === '"') quoted = !quoted;
|
|
74
|
+
else if (/[$`]/.test(ch) || (!quoted && /[*?[\]{}]/.test(ch))) return GLOB_OR_EXPANSION;
|
|
75
|
+
}
|
|
76
|
+
for (const word of tail.trim().split(/\s+/).filter((w) => w !== "")) {
|
|
77
|
+
if (pathValues(word.replace(/"/g, "")).some(outOfCheckout)) return PATH_OUT_OF_CHECKOUT;
|
|
78
|
+
}
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
const check = checkValidation(c, commands);
|
|
82
|
+
return check.ok ? null : check.reason;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function packCommandList(commands: RepoPackCommands): string[] {
|
|
86
|
+
return [commands.testClass, commands.testProject, commands.testIntegration, commands.cli === undefined ? undefined : `${commands.cli} <arguments>`]
|
|
87
|
+
.filter((c): c is string => c !== undefined && c.trim() !== "");
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface Ran { command: string; exitCode: number; seconds: number; timedOut: boolean; output: string; refused: boolean }
|
|
91
|
+
|
|
92
|
+
/** The command to run: the --run one, else the model's (re-asked once), checked by commandProblem. */
|
|
93
|
+
export async function pickCommand(
|
|
94
|
+
step: string, llm: Pick<Llm, "extract">, kind: "bug" | "perf", given: string, origin: string, commands: RepoPackCommands,
|
|
95
|
+
): Promise<{ command: string } | { refused: string }> {
|
|
96
|
+
if (given !== "") {
|
|
97
|
+
const problem = commandProblem(given, commands);
|
|
98
|
+
return problem === null ? { command: given.trim() } : {
|
|
99
|
+
refused: runMayNotRun(step, given, problem),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
let problems: string[] = [];
|
|
103
|
+
for (let attempt = 1; attempt <= 2; attempt++) {
|
|
104
|
+
let command = "";
|
|
105
|
+
try {
|
|
106
|
+
const v = await llm.extract(buildReproPrompt(kind, origin, packCommandList(commands), problems), REPRO_SCHEMA) as { command?: unknown };
|
|
107
|
+
command = typeof v?.command === "string" ? v.command.trim() : "";
|
|
108
|
+
} catch (e) {
|
|
109
|
+
problems = [answerDidNotParse(errorText(e))];
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
const problem = commandProblem(command, commands);
|
|
113
|
+
if (problem === null) return { command };
|
|
114
|
+
problems = [`'${command}': ${problem}`];
|
|
115
|
+
}
|
|
116
|
+
const what = kind === "bug" ? REPRODUCES_THE_BUG : MEASURES_THE_COST;
|
|
117
|
+
return { refused: noCommandPicked(step, what, problems[0] ?? "none") };
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export async function runEvidence(shell: Pick<Shell, "run">, command: string, clock: () => Date): Promise<Ran> {
|
|
121
|
+
const start = clock().getTime();
|
|
122
|
+
let exitCode = -1;
|
|
123
|
+
let timedOut = false;
|
|
124
|
+
let output = "";
|
|
125
|
+
let refused = false;
|
|
126
|
+
try {
|
|
127
|
+
const r = await shell.run(command, { timeoutSeconds: REPRO_TIMEOUT_SECONDS });
|
|
128
|
+
exitCode = r.exitCode;
|
|
129
|
+
timedOut = r.timedOut === true;
|
|
130
|
+
output = [r.stdout, r.stderr].filter((s) => s !== "").join("\n");
|
|
131
|
+
} catch (e) {
|
|
132
|
+
output = runtimeRefused(firstLine(e));
|
|
133
|
+
refused = true;
|
|
134
|
+
}
|
|
135
|
+
const seconds = Math.round((clock().getTime() - start) / 100) / 10;
|
|
136
|
+
return { command, exitCode, seconds, timedOut, output: output.slice(0, MAX_OUTPUT_CHARS), refused };
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export function reproFile(ran: Ran, date: string): string {
|
|
140
|
+
return [
|
|
141
|
+
`command: ${ran.command}`, `date: ${date}`, `exit: ${ran.timedOut ? "timed out" : ran.exitCode}`, `seconds: ${ran.seconds}`, "",
|
|
142
|
+
ran.output,
|
|
143
|
+
].join("\n").trimEnd() + "\n";
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** The lines of § 2 code writes from the run. */
|
|
147
|
+
export function factLines(kind: "bug" | "perf", ran: Ran, fileName: string): string[] {
|
|
148
|
+
const tail = ran.output.trimEnd().split(/\r?\n/).slice(-TAIL_LINES).map((l) => ` ${l.replace(/```/g, "'''")}`.trimEnd());
|
|
149
|
+
const head = kind === "bug"
|
|
150
|
+
? reproductionFact(ran.command, ran.exitCode, ran.seconds, fileName)
|
|
151
|
+
: measuredFact(ran.command, ran.seconds, ran.exitCode, fileName);
|
|
152
|
+
return ran.output.trim() === "" ? [head] : [head, "- **Observed** (last lines):", "", " ```text", ...tail, " ```"];
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** Why the run stops the step, null when it stands as evidence. */
|
|
156
|
+
export function runStop(step: string, kind: "bug" | "perf", ran: Ran, shown: string): string | null {
|
|
157
|
+
if (ran.refused) return evidenceCouldNotRun(step, ran.command, ran.output);
|
|
158
|
+
if (ran.timedOut) return ranOutOfTime(step, ran.command, REPRO_TIMEOUT_SECONDS, shown);
|
|
159
|
+
if (kind === "bug" && NOT_RUN_EXITS.has(ran.exitCode)) {
|
|
160
|
+
return couldNotStart(step, ran.command, ran.exitCode, shown);
|
|
161
|
+
}
|
|
162
|
+
if (kind === "bug" && ran.exitCode > 128) {
|
|
163
|
+
return wasKilled(step, ran.command, ran.exitCode, shown);
|
|
164
|
+
}
|
|
165
|
+
if (kind === "bug" && ran.exitCode === 0) {
|
|
166
|
+
return didNotReproduce(step, ran.command, shown);
|
|
167
|
+
}
|
|
168
|
+
if (kind === "perf" && ran.exitCode !== 0) {
|
|
169
|
+
return measurementFailed(step, ran.command, ran.exitCode, shown);
|
|
170
|
+
}
|
|
171
|
+
return null;
|
|
172
|
+
}
|