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,173 @@
|
|
|
1
|
+
// The reviewer's answer: the JSON schema its review is extracted into, and the
|
|
2
|
+
// check that turns the extraction into a ReviewAnswer or the list of what is wrong
|
|
3
|
+
// with it. Pure, no IO. Only two severities exist: wording is never reported, so a
|
|
4
|
+
// review has no Minor row. Each row targets what the caller says it may (in plan
|
|
5
|
+
// mode the global plan or one of its batches) and cites where it comes from. Once re-asked, a row whose evidence
|
|
6
|
+
// still cites nothing is kept, marked NO_CITATION, rather than one row dropping the whole review (reviewChecks).
|
|
7
|
+
|
|
8
|
+
import type { Checked } from "../agents/charter.ts";
|
|
9
|
+
import {
|
|
10
|
+
ANSWER_NOT_AN_OBJECT, atMostRows, NO_CITATION, QUESTION_EMPTY, QUESTION_NO_MARK, questionLongerThan, ROWS_MUST_BE_A_LIST,
|
|
11
|
+
rowEvidenceCitesNothing, rowEvidenceEmpty, rowOneClosedQuestion, rowRepeats, rowSeverityMustBe, rowTargetNotOneOf,
|
|
12
|
+
rowTwoTargets, VERDICT_CLEAR_OR_GAPS,
|
|
13
|
+
} from "./messages.ts";
|
|
14
|
+
|
|
15
|
+
export type ReviewSeverity = "Blocking" | "Major";
|
|
16
|
+
export interface ReviewRow { severity: ReviewSeverity; question: string; evidence: string; target: string }
|
|
17
|
+
export interface ReviewAnswer { verdict: "CLEAR" | "GAPS"; rows: ReviewRow[] }
|
|
18
|
+
/** What a row may target. Plan mode: ["plan", "F1", …, "Fn"]. A target is one of them, alone or followed by a
|
|
19
|
+
* qualifier (`F2 (step 1)` is F2); one that names two of them is refused. */
|
|
20
|
+
export interface ReviewCheckContext {
|
|
21
|
+
targets: readonly string[];
|
|
22
|
+
/** Keep a row whose evidence cites nothing, marked NO_CITATION, instead of refusing it (the last try). */
|
|
23
|
+
uncitedKept?: boolean;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const MAX_REVIEW_ROWS = 12;
|
|
27
|
+
const MAX_QUESTION_CHARS = 300;
|
|
28
|
+
const SEVERITIES: readonly ReviewSeverity[] = ["Blocking", "Major"];
|
|
29
|
+
|
|
30
|
+
export const REVIEW_ANSWER_SCHEMA: object = {
|
|
31
|
+
type: "object",
|
|
32
|
+
properties: {
|
|
33
|
+
verdict: { type: "string", enum: ["CLEAR", "GAPS"] },
|
|
34
|
+
rows: {
|
|
35
|
+
type: "array",
|
|
36
|
+
items: {
|
|
37
|
+
type: "object",
|
|
38
|
+
properties: {
|
|
39
|
+
severity: { type: "string", enum: [...SEVERITIES] },
|
|
40
|
+
question: { type: "string" },
|
|
41
|
+
evidence: { type: "string" },
|
|
42
|
+
target: { type: "string" },
|
|
43
|
+
},
|
|
44
|
+
required: ["severity", "question", "evidence", "target"],
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
required: ["verdict", "rows"],
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/** A path:line, a section (§ 3, §3, § Anchors) or a heading of the plan (## …). */
|
|
52
|
+
const PATH_LINE = /[A-Za-z0-9_./-]+:\d+/;
|
|
53
|
+
const SECTION = /§ ?\S/;
|
|
54
|
+
const HEADING = /##\s*\S/;
|
|
55
|
+
|
|
56
|
+
/** `value` as one table cell: a line break becomes a space, a `\` then a `|` are escaped (the backslash first, so
|
|
57
|
+
* that a `\` before a `|` cannot undo the pipe's escape). A quoted design row or a path with a `|` is no reason
|
|
58
|
+
* to refuse the row and run the extraction again. */
|
|
59
|
+
function cell(value: string): string {
|
|
60
|
+
return value.replace(/\s*[\r\n]+\s*/g, " ").replace(/\\/g, "\\\\").replace(/\|/g, "\\|").trim();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function isPlainObject(value: unknown): value is Record<string, unknown> {
|
|
64
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function text(value: unknown): string {
|
|
68
|
+
return typeof value === "string" ? value.trim() : "";
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function fold(question: string): string {
|
|
72
|
+
return question.toLowerCase().replace(/\s+/g, " ");
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** "plan, F1…F3" for a plan's targets; the plain list when there are fewer than three. */
|
|
76
|
+
function targetList(targets: readonly string[]): string {
|
|
77
|
+
if (targets.length < 3) return targets.join(", ");
|
|
78
|
+
return `${targets[0]}, ${targets[1]}…${targets[targets.length - 1]}`;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const WORD = "[A-Za-z0-9_]";
|
|
82
|
+
const escaped = (id: string): string => id.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
83
|
+
/** Whether `id` stands in `text` as a whole word (`F1` in `F1-F3`, not in `F12`). */
|
|
84
|
+
const wholeWord = (text: string, id: string): boolean => new RegExp(`(?:^|(?!${WORD}).)${escaped(id)}(?!${WORD})`, "i").test(text);
|
|
85
|
+
|
|
86
|
+
/** The allowed id a target names: equal to one, or one followed by a qualifier (`F2 (step 1)`, `F3: step 2`), case
|
|
87
|
+
* folded, the longest id first; `{ two: true }` when the qualifier names a second allowed id as a whole word
|
|
88
|
+
* (`plan (F2)`, `F1-F3`); null when none (`F4`, `F12` when F1 alone is allowed). */
|
|
89
|
+
export function targetId(target: string, targets: readonly string[]): { id: string } | { two: true } | null {
|
|
90
|
+
const named = target.trim();
|
|
91
|
+
const byLength = [...targets].sort((a, b) => b.length - a.length);
|
|
92
|
+
const id = byLength.find((t) => new RegExp(`^${escaped(t)}(?!${WORD})`, "i").test(named));
|
|
93
|
+
if (id === undefined) return null;
|
|
94
|
+
const rest = named.slice(id.length);
|
|
95
|
+
return byLength.some((t) => wholeWord(rest, t)) ? { two: true } : { id };
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Why a question is not one closed question fitting a table cell, or undefined when it is. */
|
|
99
|
+
function questionFault(question: string): string | undefined {
|
|
100
|
+
if (question === "") return QUESTION_EMPTY;
|
|
101
|
+
if (question.length > MAX_QUESTION_CHARS) return questionLongerThan(MAX_QUESTION_CHARS);
|
|
102
|
+
if (!question.endsWith("?")) return QUESTION_NO_MARK;
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function citesSource(evidence: string): boolean {
|
|
107
|
+
return PATH_LINE.test(evidence) || SECTION.test(evidence) || HEADING.test(evidence);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function checkRow(value: unknown, k: number, ctx: ReviewCheckContext, problems: string[]): ReviewRow | undefined {
|
|
111
|
+
const item = isPlainObject(value) ? value : {};
|
|
112
|
+
const before = problems.length;
|
|
113
|
+
const severity = text(item.severity);
|
|
114
|
+
if (!SEVERITIES.includes(severity as ReviewSeverity)) problems.push(rowSeverityMustBe(k));
|
|
115
|
+
const question = cell(text(item.question));
|
|
116
|
+
const fault = questionFault(question);
|
|
117
|
+
if (fault !== undefined) problems.push(rowOneClosedQuestion(k, fault));
|
|
118
|
+
let evidence = cell(text(item.evidence));
|
|
119
|
+
if (evidence === "") problems.push(rowEvidenceEmpty(k));
|
|
120
|
+
else if (!citesSource(evidence)) {
|
|
121
|
+
if (ctx.uncitedKept === true) evidence = `${evidence} ${NO_CITATION}`;
|
|
122
|
+
else problems.push(rowEvidenceCitesNothing(k));
|
|
123
|
+
}
|
|
124
|
+
const named = text(item.target);
|
|
125
|
+
const target = targetId(named, ctx.targets);
|
|
126
|
+
if (target === null) problems.push(rowTargetNotOneOf(k, named, targetList(ctx.targets)));
|
|
127
|
+
else if ("two" in target) problems.push(rowTwoTargets(k, named));
|
|
128
|
+
if (problems.length > before || target === null || "two" in target) return undefined;
|
|
129
|
+
return { severity: severity as ReviewSeverity, question, evidence, target: target.id };
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export function checkReviewAnswer(value: unknown, ctx: ReviewCheckContext): Checked<ReviewAnswer> {
|
|
133
|
+
if (!isPlainObject(value)) return { ok: false, problems: [ANSWER_NOT_AN_OBJECT] };
|
|
134
|
+
const problems: string[] = [];
|
|
135
|
+
const said = text(value.verdict);
|
|
136
|
+
if (said !== "CLEAR" && said !== "GAPS") problems.push(VERDICT_CLEAR_OR_GAPS);
|
|
137
|
+
|
|
138
|
+
const rows: ReviewRow[] = [];
|
|
139
|
+
// The rows are the substance: the verdict follows them. A review that opens with "CLEAR" and then asks two
|
|
140
|
+
// questions is GAPS, whatever word the extraction copied.
|
|
141
|
+
let verdict: ReviewAnswer["verdict"] = said === "GAPS" ? "GAPS" : "CLEAR";
|
|
142
|
+
if (!Array.isArray(value.rows)) {
|
|
143
|
+
problems.push(ROWS_MUST_BE_A_LIST);
|
|
144
|
+
} else {
|
|
145
|
+
verdict = value.rows.length > 0 ? "GAPS" : "CLEAR";
|
|
146
|
+
if (value.rows.length > MAX_REVIEW_ROWS) problems.push(atMostRows(MAX_REVIEW_ROWS, value.rows.length));
|
|
147
|
+
const seen = new Map<string, number>();
|
|
148
|
+
value.rows.forEach((item, i) => {
|
|
149
|
+
const k = i + 1;
|
|
150
|
+
const checked = checkRow(item, k, ctx, problems);
|
|
151
|
+
const question = isPlainObject(item) ? text(item.question) : "";
|
|
152
|
+
if (question !== "") {
|
|
153
|
+
const first = seen.get(fold(question));
|
|
154
|
+
if (first !== undefined) problems.push(rowRepeats(k, first));
|
|
155
|
+
else seen.set(fold(question), k);
|
|
156
|
+
}
|
|
157
|
+
if (checked) rows.push(checked);
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (problems.length > 0) return { ok: false, problems };
|
|
162
|
+
return { ok: true, value: { verdict, rows } };
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** The checks of a review over `targets`: the first try refuses an uncited row, the last one keeps it marked. */
|
|
166
|
+
export function reviewChecks(targets: readonly string[]): {
|
|
167
|
+
check: (value: unknown) => Checked<ReviewAnswer>; lastCheck: (value: unknown) => Checked<ReviewAnswer>;
|
|
168
|
+
} {
|
|
169
|
+
return {
|
|
170
|
+
check: (value) => checkReviewAnswer(value, { targets }),
|
|
171
|
+
lastCheck: (value) => checkReviewAnswer(value, { targets, uncitedKept: true }),
|
|
172
|
+
};
|
|
173
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// The reviewer's brief and answer prompt, assembled: the carried texts fitted to their room, what the brief says
|
|
2
|
+
// is in it, the project list, the reply cut to its end. The wording is in ./prompts.ts.
|
|
3
|
+
|
|
4
|
+
import { carry } from "./carried-text.ts";
|
|
5
|
+
import type { CarriedText } from "./carried-text.ts";
|
|
6
|
+
import { projectFileLines } from "./project-files.ts";
|
|
7
|
+
import { earlierTextCut, reviewAnswerPrompt, reviewBrief } from "./prompts.ts";
|
|
8
|
+
import type { ReviewMode } from "./prompts.ts";
|
|
9
|
+
|
|
10
|
+
export const MAX_REVIEW_REPLY_CHARS = 12_000;
|
|
11
|
+
|
|
12
|
+
/** The most carried text a review brief holds, in characters (MAX_BRIEF_CHARS less the brief's own lines). */
|
|
13
|
+
export const CARRIED_REVIEW_CHARS = 18_000;
|
|
14
|
+
|
|
15
|
+
export interface ReviewBriefInput {
|
|
16
|
+
mode: ReviewMode;
|
|
17
|
+
/** The folder under review, relative ("workbench/prune"). */
|
|
18
|
+
folder: string;
|
|
19
|
+
/** The files to review, relative, in reading order. */
|
|
20
|
+
files: readonly string[];
|
|
21
|
+
/** The spec or brief the work was planned from, relative; for a spec or a brief, its origin ("" when none). */
|
|
22
|
+
source: string;
|
|
23
|
+
/** The inventory text: the plan's I<n> refs, the path:line rows of a spec or a brief. */
|
|
24
|
+
inventory: string;
|
|
25
|
+
/** What a row may target. */
|
|
26
|
+
targets: readonly string[];
|
|
27
|
+
/** Texts carried in the brief, each under its title (next-batch: the batch's sheet, then what each closed batch
|
|
28
|
+
* changed), so the reviewer opens no file for them; the whole room of CARRIED_REVIEW_CHARS for them. */
|
|
29
|
+
carried?: readonly CarriedText[];
|
|
30
|
+
/** The project's files (tracked and untracked, the work folder left out), listed so that the reviewer guesses no
|
|
31
|
+
* name; absent or empty: no list. */
|
|
32
|
+
projectFiles?: readonly string[];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function buildReviewBrief(input: ReviewBriefInput): string {
|
|
36
|
+
const { blocks, whole } = carry(input.carried ?? [], CARRIED_REVIEW_CHARS);
|
|
37
|
+
return reviewBrief({
|
|
38
|
+
mode: input.mode,
|
|
39
|
+
folder: input.folder.endsWith("/") ? input.folder : `${input.folder}/`,
|
|
40
|
+
files: input.files,
|
|
41
|
+
filesInBrief: input.files.length > 0 && input.files.every((file) => whole.has(file)),
|
|
42
|
+
source: input.source,
|
|
43
|
+
sourceInBrief: whole.has(input.source),
|
|
44
|
+
inventory: input.inventory.trimEnd(),
|
|
45
|
+
blocks,
|
|
46
|
+
project: projectFileLines(input.projectFiles ?? []),
|
|
47
|
+
targets: input.targets,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function buildReviewAnswerPrompt(reply: string, problems: readonly string[], targets: readonly string[]): string {
|
|
52
|
+
const text = reply.length > MAX_REVIEW_REPLY_CHARS ? earlierTextCut(reply.slice(-MAX_REVIEW_REPLY_CHARS)) : reply;
|
|
53
|
+
return reviewAnswerPrompt(text, problems, targets);
|
|
54
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// The adversarial reviewer's charter: a read-only sub-agent in plan mode with ten read tools — files,
|
|
2
|
+
// their nodes, folders, a file pattern lookup (glob, which the cut project list names), the code index, a
|
|
3
|
+
// structural pattern search and its impact view — and no shell,
|
|
4
|
+
// no write and no index build. It lives in the shared domain because more than one
|
|
5
|
+
// crew reviews (a plan now; a specification, a change brief and the next batch later).
|
|
6
|
+
|
|
7
|
+
import type { Charter } from "../agents/charter.ts";
|
|
8
|
+
|
|
9
|
+
export const REVIEWER_TOOLS: readonly string[] = [
|
|
10
|
+
"file_read", "node_outline", "node_read", "directory_read", "glob", "codebase_search", "structural_search",
|
|
11
|
+
"symbol_source", "symbol_detail", "impact_analysis",
|
|
12
|
+
];
|
|
13
|
+
|
|
14
|
+
export const REVIEWER_CHARTER: Charter = {
|
|
15
|
+
name: "dev-reviewer",
|
|
16
|
+
role: "Adversarial reviewer",
|
|
17
|
+
goal: "Find what a plan, a specification or a change brief leaves undecided, and ask it as closed questions",
|
|
18
|
+
mode: "plan",
|
|
19
|
+
tools: REVIEWER_TOOLS,
|
|
20
|
+
disallowed: ["shell_command", "file_write", "rag_ingest", "index_codebase"],
|
|
21
|
+
maxIterations: 20,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/** The look-ups (tool calls) a review of a plan, a spec or a brief may make: past them every call is refused and the
|
|
25
|
+
* reviewer writes its findings, so that a review always concludes inside its charter's turns. */
|
|
26
|
+
export const REVIEWER_LOOKUPS = 16;
|
|
27
|
+
|
|
28
|
+
/** The review of the next batch of /dev-batches: its brief carries the batch's sheet and what the closed batches
|
|
29
|
+
* changed, so five read tools and eight turns are enough (a plan's review keeps the ten and its twenty); glob is one
|
|
30
|
+
* of them, since its brief lists the project's files and a cut list sends the reader to it. */
|
|
31
|
+
export const NEXT_BATCH_REVIEWER_CHARTER: Charter = {
|
|
32
|
+
...REVIEWER_CHARTER,
|
|
33
|
+
tools: ["file_read", "node_outline", "node_read", "glob", "codebase_search"],
|
|
34
|
+
maxIterations: 8,
|
|
35
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// The facts the gate and the mechanical table read off one batch sheet: the ids of its
|
|
2
|
+
// `## TDD sequence`, the test methods of its step tables, its `Applied rules` row and its
|
|
3
|
+
// `TDD:` lines. Line-based, as the harness's greps read the file. Pure.
|
|
4
|
+
import { SHEET_ID_SOURCE } from "./trait-pattern.ts";
|
|
5
|
+
import { APPLIED_ROW, OPEN_BOX, TICKED_TDD_LINE } from "./markers.ts";
|
|
6
|
+
|
|
7
|
+
export interface SheetFacts {
|
|
8
|
+
ids: string[]; // ids of `## TDD sequence`, sorted, unique (AC:166)
|
|
9
|
+
methods: string[]; // step-table Test methods, first-seen order, unique (AC:380-388)
|
|
10
|
+
appliedRulesRow: string | null; // the first line matching /^\| *Applied rules *\|/ (AC:450)
|
|
11
|
+
appliedIds: string[]; // /\b[A-Z]+-[0-9]+\b/ after "Applied rules", first-seen order (AC:454)
|
|
12
|
+
tickedLines: number; // lines holding "TDD: RED [x] GREEN [x] COST [x]" (AC:448)
|
|
13
|
+
closed: boolean; // check 1 (AC:119)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const SEPARATOR_ROW = /^\|[-: |]+$/;
|
|
17
|
+
const IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
18
|
+
|
|
19
|
+
function unique(values: Iterable<string>): string[] {
|
|
20
|
+
return [...new Set(values)];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** The lines of the `## TDD sequence` section, heading excluded; it ends at the next `## ` heading. */
|
|
24
|
+
function tddSection(lines: readonly string[]): string[] {
|
|
25
|
+
const out: string[] = [];
|
|
26
|
+
let inside = false;
|
|
27
|
+
for (const l of lines) {
|
|
28
|
+
if (l.startsWith("## TDD sequence")) { inside = true; continue; }
|
|
29
|
+
if (l.startsWith("## ")) inside = false;
|
|
30
|
+
if (inside) out.push(l);
|
|
31
|
+
}
|
|
32
|
+
return out;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** The method of one Test cell: the first backticked text, call and class cut; null when none. */
|
|
36
|
+
function methodOf(cell: string): string | null {
|
|
37
|
+
const open = cell.indexOf("`");
|
|
38
|
+
if (open < 0) return null;
|
|
39
|
+
let v = cell.slice(open + 1);
|
|
40
|
+
const close = v.indexOf("`");
|
|
41
|
+
if (close >= 0) v = v.slice(0, close);
|
|
42
|
+
const paren = v.indexOf("(");
|
|
43
|
+
if (paren >= 0) v = v.slice(0, paren);
|
|
44
|
+
if (/[<>]/.test(v)) return null;
|
|
45
|
+
const last = v.split(".").at(-1) ?? "";
|
|
46
|
+
return IDENTIFIER.test(last) ? last : null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function stepMethods(section: readonly string[]): string[] {
|
|
50
|
+
const methods: string[] = [];
|
|
51
|
+
let column = 0;
|
|
52
|
+
for (const l of section) {
|
|
53
|
+
if (!l.startsWith("|")) { column = 0; continue; }
|
|
54
|
+
if (SEPARATOR_ROW.test(l)) continue;
|
|
55
|
+
const cells = l.split("|");
|
|
56
|
+
if (column === 0) {
|
|
57
|
+
for (let i = 1; i < cells.length - 1; i++) if (cells[i].trim() === "Test") column = i;
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
const method = methodOf(cells[column] ?? "");
|
|
61
|
+
if (method !== null) methods.push(method);
|
|
62
|
+
}
|
|
63
|
+
return unique(methods);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function sheetFacts(sheet: string): SheetFacts {
|
|
67
|
+
const lines = sheet.split("\n");
|
|
68
|
+
const section = tddSection(lines);
|
|
69
|
+
const ids = unique(section.flatMap((l) => l.match(new RegExp(SHEET_ID_SOURCE, "g")) ?? [])).sort();
|
|
70
|
+
const appliedRulesRow = lines.find((l) => APPLIED_ROW.test(l)) ?? null;
|
|
71
|
+
const afterLabel = appliedRulesRow === null ? "" : appliedRulesRow.slice(appliedRulesRow.indexOf("Applied rules") + "Applied rules".length);
|
|
72
|
+
const tickedLines = lines.filter((l) => l.includes(TICKED_TDD_LINE)).length;
|
|
73
|
+
return {
|
|
74
|
+
ids,
|
|
75
|
+
methods: stepMethods(section),
|
|
76
|
+
appliedRulesRow,
|
|
77
|
+
appliedIds: unique(afterLabel.match(/\b[A-Z]+-[0-9]+\b/g) ?? []),
|
|
78
|
+
tickedLines,
|
|
79
|
+
closed: tickedLines > 0 && !lines.some((l) => OPEN_BOX.test(l)),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
// The source of a plan: a spec (`SPEC-<code>.md`) or a change brief (`CHANGE-<code>.md`),
|
|
2
|
+
// read line by line - its title, its UC/BR/CH ids, its open questions and, for a brief,
|
|
3
|
+
// what must not change - and the Blocking gate that stops a plan while an open question
|
|
4
|
+
// is Blocking. Pure, no IO, never throws: what does not match becomes a FormatProblem.
|
|
5
|
+
// The gate keeps the harness's own line test and adds a reading by the Severity column,
|
|
6
|
+
// so it is never less strict than the harness.
|
|
7
|
+
import type { FormatProblem } from "./plan-format.ts";
|
|
8
|
+
import {
|
|
9
|
+
BLOCKING_CELL, BRIEF_TITLE, ID_HEADING, MUST_NOT_CHANGE, OPEN_QUESTIONS_HEADING, SPEC_TITLE, STATEMENT,
|
|
10
|
+
} from "./markers.ts";
|
|
11
|
+
import {
|
|
12
|
+
blockingQuestionsOpen, BRIEF_TITLE_NAMES_NO_KIND, duplicatedId, idInChangeBrief, settleThemFirst,
|
|
13
|
+
} from "./messages.ts";
|
|
14
|
+
|
|
15
|
+
export type SourceKind = "spec" | "change";
|
|
16
|
+
export type ChangeKind = "bug" | "refactor" | "perf";
|
|
17
|
+
export interface SourceId { id: string; title: string; statement: string; line: number } // statement "" when none
|
|
18
|
+
export interface OpenQuestion { line: number; raw: string; severity: string; cells: string[] }
|
|
19
|
+
export interface MustNotChangeRow { line: number; behaviour: string; pinnedBy: string | null } // null: unpinned
|
|
20
|
+
export interface PlanSource {
|
|
21
|
+
kind: SourceKind;
|
|
22
|
+
code?: string; name?: string; changeKind?: ChangeKind; // from the title line
|
|
23
|
+
ids: SourceId[]; // UC, then BR, then CH, each by number
|
|
24
|
+
openQuestions: OpenQuestion[];
|
|
25
|
+
blocking: OpenQuestion[]; // the gate's rows
|
|
26
|
+
mustNotChange: MustNotChangeRow[]; // change brief only
|
|
27
|
+
problems: FormatProblem[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const SEPARATOR_ROW = /^\|?[-: |]+$/;
|
|
31
|
+
const MAX_STATEMENT = 200;
|
|
32
|
+
const MAX_SHOWN_ROW = 200;
|
|
33
|
+
const MAX_SHOWN_ROWS = 8;
|
|
34
|
+
const FAMILY_ORDER = ["UC", "BR", "CH"];
|
|
35
|
+
|
|
36
|
+
const linesOf = (text: string): string[] => text.split(/\r?\n/);
|
|
37
|
+
const isTableRow = (line: string): boolean => line.includes("|");
|
|
38
|
+
|
|
39
|
+
function cellsOf(row: string): string[] {
|
|
40
|
+
return row.trim().replace(/^\|/, "").replace(/\|$/, "").split("|").map((c) => c.trim());
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** A severity or a pinned-by cell with its emphasis and code marks removed. */
|
|
44
|
+
const plain = (cell: string): string => cell.replace(/[*_`]/g, "").trim();
|
|
45
|
+
|
|
46
|
+
/** The lines of each `## ` section whose heading matches, numbered from 1, heading excluded. */
|
|
47
|
+
function sectionLines(lines: readonly string[], heading: RegExp): Array<{ text: string; line: number }> {
|
|
48
|
+
const out: Array<{ text: string; line: number }> = [];
|
|
49
|
+
let inside = false;
|
|
50
|
+
lines.forEach((text, i) => {
|
|
51
|
+
if (text.startsWith("## ")) { inside = heading.test(text); return; }
|
|
52
|
+
if (inside) out.push({ text, line: i + 1 });
|
|
53
|
+
});
|
|
54
|
+
return out;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
interface TableRow { text: string; line: number; cells: string[]; header: string[] }
|
|
58
|
+
|
|
59
|
+
/** The data rows of the tables of a section, each with its table's header cells. */
|
|
60
|
+
function tableRows(section: ReadonlyArray<{ text: string; line: number }>): TableRow[] {
|
|
61
|
+
const out: TableRow[] = [];
|
|
62
|
+
let header: string[] | null = null;
|
|
63
|
+
for (const { text, line } of section) {
|
|
64
|
+
if (!isTableRow(text)) { header = null; continue; }
|
|
65
|
+
if (SEPARATOR_ROW.test(text.trim())) continue;
|
|
66
|
+
const cells = cellsOf(text);
|
|
67
|
+
if (header === null) { header = cells; continue; }
|
|
68
|
+
out.push({ text, line, cells, header });
|
|
69
|
+
}
|
|
70
|
+
return out;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function openQuestions(lines: readonly string[]): OpenQuestion[] {
|
|
74
|
+
return tableRows(sectionLines(lines, OPEN_QUESTIONS_HEADING)).map((r) => {
|
|
75
|
+
const column = r.header.indexOf("Severity");
|
|
76
|
+
return { line: r.line, raw: r.text, severity: column >= 0 ? (r.cells[column] ?? "") : "", cells: r.cells };
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** The gate alone, run before any other read: the raw lines that stop a plan. */
|
|
81
|
+
export function blockingRows(text: string): OpenQuestion[] {
|
|
82
|
+
const lines = linesOf(text);
|
|
83
|
+
const section = sectionLines(lines, OPEN_QUESTIONS_HEADING);
|
|
84
|
+
const bySeverity = new Map<number, OpenQuestion>();
|
|
85
|
+
for (const q of openQuestions(lines)) if (plain(q.severity).toLowerCase() === "blocking") bySeverity.set(q.line, q);
|
|
86
|
+
const out: OpenQuestion[] = [];
|
|
87
|
+
for (const { text: raw, line } of section) {
|
|
88
|
+
const counted = bySeverity.get(line);
|
|
89
|
+
if (counted !== undefined) { out.push(counted); continue; }
|
|
90
|
+
if (BLOCKING_CELL.test(raw)) out.push({ line, raw, severity: "Blocking", cells: cellsOf(raw) });
|
|
91
|
+
}
|
|
92
|
+
return out;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function statementOf(lines: readonly string[], from: number): string {
|
|
96
|
+
for (const l of lines.slice(from)) {
|
|
97
|
+
if (l.startsWith("#")) return "";
|
|
98
|
+
const t = l.trim();
|
|
99
|
+
if (!/^[-*] /.test(t)) continue;
|
|
100
|
+
const at = t.indexOf(STATEMENT);
|
|
101
|
+
if (at < 0) return "";
|
|
102
|
+
let s = t.slice(at + STATEMENT.length).replace(/^[\s:*]+/, "");
|
|
103
|
+
for (const stop of [" · ", " **"]) {
|
|
104
|
+
const cut = s.indexOf(stop);
|
|
105
|
+
if (cut >= 0) s = s.slice(0, cut);
|
|
106
|
+
}
|
|
107
|
+
return s.trim().slice(0, MAX_STATEMENT);
|
|
108
|
+
}
|
|
109
|
+
return "";
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function readIds(lines: readonly string[], kind: SourceKind, problems: FormatProblem[]): SourceId[] {
|
|
113
|
+
const seen = new Set<string>();
|
|
114
|
+
const ids: SourceId[] = [];
|
|
115
|
+
lines.forEach((text, i) => {
|
|
116
|
+
const m = ID_HEADING.exec(text);
|
|
117
|
+
if (!m) return;
|
|
118
|
+
const id = `${m[1]}-${m[2]}`;
|
|
119
|
+
const line = i + 1;
|
|
120
|
+
if (seen.has(id)) { problems.push({ line, message: duplicatedId(id) }); return; }
|
|
121
|
+
seen.add(id);
|
|
122
|
+
if (kind === "change" && m[1] !== "CH") { problems.push({ line, message: idInChangeBrief(id) }); return; }
|
|
123
|
+
if (kind === "spec" && m[1] === "CH") return;
|
|
124
|
+
ids.push({ id, title: m[3].trim(), statement: statementOf(lines, i + 1), line });
|
|
125
|
+
});
|
|
126
|
+
const rank = (s: SourceId): [number, number] => [FAMILY_ORDER.indexOf(s.id.split("-")[0]), Number(s.id.split("-")[1])];
|
|
127
|
+
return ids.sort((a, b) => {
|
|
128
|
+
const [fa, na] = rank(a);
|
|
129
|
+
const [fb, nb] = rank(b);
|
|
130
|
+
return fa !== fb ? fa - fb : na - nb;
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function mustNotChange(lines: readonly string[]): MustNotChangeRow[] {
|
|
135
|
+
const out: MustNotChangeRow[] = [];
|
|
136
|
+
for (const r of tableRows(sectionLines(lines, MUST_NOT_CHANGE))) {
|
|
137
|
+
const behaviour = r.header.indexOf("Behaviour");
|
|
138
|
+
const pinned = r.header.indexOf("Pinned by");
|
|
139
|
+
if (behaviour < 0 || pinned < 0) continue;
|
|
140
|
+
const by = (r.cells[pinned] ?? "").replace(/`/g, "").trim();
|
|
141
|
+
out.push({ line: r.line, behaviour: (r.cells[behaviour] ?? "").trim(), pinnedBy: by.toLowerCase() === "unpinned" ? null : by });
|
|
142
|
+
}
|
|
143
|
+
return out;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export function parsePlanSource(text: string, kind: SourceKind): PlanSource {
|
|
147
|
+
const lines = linesOf(text);
|
|
148
|
+
const problems: FormatProblem[] = [];
|
|
149
|
+
const source: PlanSource = {
|
|
150
|
+
kind, ids: [], openQuestions: openQuestions(lines), blocking: blockingRows(text), mustNotChange: [], problems,
|
|
151
|
+
};
|
|
152
|
+
const titleIndex = lines.findIndex((l) => l.startsWith("# "));
|
|
153
|
+
if (titleIndex >= 0) {
|
|
154
|
+
const t = lines[titleIndex].trimEnd();
|
|
155
|
+
const brief = kind === "change" ? BRIEF_TITLE.exec(t) : null;
|
|
156
|
+
const plainTitle = SPEC_TITLE.exec(t);
|
|
157
|
+
if (brief) {
|
|
158
|
+
source.code = brief[1]; source.name = brief[2]; source.changeKind = brief[3] as ChangeKind;
|
|
159
|
+
} else if (plainTitle) {
|
|
160
|
+
source.code = plainTitle[1]; source.name = plainTitle[2];
|
|
161
|
+
}
|
|
162
|
+
if (kind === "change" && !brief) {
|
|
163
|
+
problems.push({ line: titleIndex + 1, message: BRIEF_TITLE_NAMES_NO_KIND });
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
source.ids = readIds(lines, kind, problems);
|
|
167
|
+
if (kind === "change") source.mustNotChange = mustNotChange(lines);
|
|
168
|
+
return source;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** The stop message: the rows, then the next command. Pure text, shared by the command and the crew. */
|
|
172
|
+
export function blockingStop(shown: string, kind: SourceKind, code: string, rows: readonly OpenQuestion[]): string {
|
|
173
|
+
const settle = "/dev-spec";
|
|
174
|
+
const shownRows = rows.slice(0, MAX_SHOWN_ROWS).map((r) => ` ${r.raw.trim().slice(0, MAX_SHOWN_ROW)}`);
|
|
175
|
+
const more = rows.length > MAX_SHOWN_ROWS ? [` … ${rows.length - MAX_SHOWN_ROWS} more`] : [];
|
|
176
|
+
return [
|
|
177
|
+
blockingQuestionsOpen(shown, rows.length),
|
|
178
|
+
...shownRows,
|
|
179
|
+
...more,
|
|
180
|
+
settleThemFirst(settle, code, kind === "change"),
|
|
181
|
+
].join("\n");
|
|
182
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// The budget of each dev step crew, sized to one unit (temp/02 G-29: never one long turn, a chain
|
|
2
|
+
// of short steps over a state file), and the reader of the runtime's refusal when one is spent. A
|
|
3
|
+
// spent budget throws BudgetExhaustedError with its `dimension`; once an agent's act turned it into
|
|
4
|
+
// a plain failure, only its message is left, and the runtime's messages name the dimension
|
|
5
|
+
// (AgentExecutionBudget.cs). Pure.
|
|
6
|
+
|
|
7
|
+
/** `cost` is the host's own budget (`Orkeon:CostTracking:DefaultCrewBudget`), no step sets it. */
|
|
8
|
+
export type BudgetDimension = "toolCalls" | "delegationDepth" | "wallTime" | "tokens" | "spawnedAgents" | "cost";
|
|
9
|
+
|
|
10
|
+
export interface StepBudget {
|
|
11
|
+
toolCalls: number;
|
|
12
|
+
/** Seconds. */
|
|
13
|
+
wallTime: number;
|
|
14
|
+
/** The context counted once (Orkeon #224): each call's completion plus what its prompt grew by, or the part the
|
|
15
|
+
* provider's cache did not serve; a spent one is reported on the `tokens` dimension, as the running sum is. */
|
|
16
|
+
contextTokens: number;
|
|
17
|
+
delegationDepth: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The context a tool call adds, rounded up: a live audit of a 3-file batch grew by about 3 300 tokens a call (its
|
|
22
|
+
* result and the model's turn around it). The context counted once (Orkeon #224) charges each call its completion
|
|
23
|
+
* plus that growth, so a step sizes its context tokens from its calls, and the tool calls stay the limit it meets
|
|
24
|
+
* first.
|
|
25
|
+
*/
|
|
26
|
+
export const TOKENS_PER_CALL = 3_500;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* dev-verify: under full, the build (900 s), the whole suite (900 s) and three validations (300 s
|
|
30
|
+
* each), whether code or run_validation runs them, plus the auditor's own time; its 200 calls ask for
|
|
31
|
+
* 700 000 context tokens. dev-plan: the inventory's index queries, the planner and the reviewer, whose calls count
|
|
32
|
+
* against the step's (A-3 Q3): 240 calls ask for 840 000 context tokens. delegationDepth 1: the reviewer and the
|
|
33
|
+
* auditor run as background children of the step's agent (A-3), one level down, never deeper. dev-spec and
|
|
34
|
+
* dev-change: the inventory (about 40 index calls), three extract calls, the reproduction (600 s at most) and one
|
|
35
|
+
* review of 20 iterations, by the reviewer as a background child whose calls count against the step's
|
|
36
|
+
* (delegationDepth 1, as dev-plan): 200 calls ask for 700 000 context tokens; the wall time
|
|
37
|
+
* counts the time a person takes to answer the questions, hence an hour.
|
|
38
|
+
*/
|
|
39
|
+
export const STEP_BUDGETS: Readonly<Record<"dev-verify" | "dev-plan" | "dev-spec" | "dev-change", StepBudget>> = {
|
|
40
|
+
"dev-verify": { toolCalls: 200, wallTime: 3600, contextTokens: 200 * TOKENS_PER_CALL, delegationDepth: 1 },
|
|
41
|
+
"dev-plan": { toolCalls: 240, wallTime: 1800, contextTokens: 240 * TOKENS_PER_CALL, delegationDepth: 1 },
|
|
42
|
+
"dev-spec": { toolCalls: 200, wallTime: 3600, contextTokens: 200 * TOKENS_PER_CALL, delegationDepth: 1 },
|
|
43
|
+
"dev-change": { toolCalls: 200, wallTime: 3600, contextTokens: 200 * TOKENS_PER_CALL, delegationDepth: 1 },
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/** The budget of a repair by a new run (/tasks repair, crew agent-run): the step's own that runs the charter as a
|
|
47
|
+
* child, so that a repaired audit or review stops where the original would; no child of its own. */
|
|
48
|
+
export function repairBudget(step: keyof typeof STEP_BUDGETS): StepBudget {
|
|
49
|
+
return { ...STEP_BUDGETS[step], delegationDepth: 0 };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const DIMENSIONS: readonly BudgetDimension[] = ["toolCalls", "delegationDepth", "wallTime", "tokens", "spawnedAgents", "cost"];
|
|
53
|
+
|
|
54
|
+
/** The runtime's messages, by dimension. */
|
|
55
|
+
const MESSAGES: ReadonlyArray<[BudgetDimension, RegExp]> = [
|
|
56
|
+
["toolCalls", /exceeded \d+ tool calls|tool-call budget exhausted/i],
|
|
57
|
+
["tokens", /token budget exhausted/i],
|
|
58
|
+
["wallTime", /wall time exceeded/i],
|
|
59
|
+
["delegationDepth", /delegation depth \d+ exceeds max/i],
|
|
60
|
+
["spawnedAgents", /exceeded \d+ spawned sub-agents/i],
|
|
61
|
+
["cost", /cost budget spent/i],
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
/** The dimension a spent budget names: the error's own `dimension`, else its message; null for any other failure. */
|
|
65
|
+
export function readBudgetExhausted(failure: unknown): BudgetDimension | null {
|
|
66
|
+
if (failure !== null && typeof failure === "object") {
|
|
67
|
+
const dimension = (failure as { dimension?: unknown }).dimension;
|
|
68
|
+
if (typeof dimension === "string" && (DIMENSIONS as readonly string[]).includes(dimension)) {
|
|
69
|
+
return dimension as BudgetDimension;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const text = failure instanceof Error ? failure.message : typeof failure === "string" ? failure : "";
|
|
73
|
+
return MESSAGES.find(([, pattern]) => pattern.test(text))?.[0] ?? null;
|
|
74
|
+
}
|