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,71 @@
|
|
|
1
|
+
// The preflight of a /dev-batches run, before it launches a batch: one line per check. The plan read
|
|
2
|
+
// without format problems, a sheet for every batch not done, an order the dependencies allow, git's
|
|
3
|
+
// identity (each batch's close commits) and a current branch. A ✗ stops the run before any launch; a
|
|
4
|
+
// tree changed outside the work folder and `.orkeon/` is a ⚠ only (a close commits the files its batch
|
|
5
|
+
// touched, by name). The plan's facts come read; git is asked here.
|
|
6
|
+
import type { Shell } from "../ports.ts";
|
|
7
|
+
import { readIdentity, runGit } from "../git/commit-files.ts";
|
|
8
|
+
import { GIT_CURRENT_BRANCH_COMMAND, GIT_STATUS_COMMAND, changedPaths } from "../../domain/git/close.ts";
|
|
9
|
+
import { BRANCH_NONE, PLAN_NONE, SHEETS_OK, changesOutsideWorkFolder, identityMissing, identityOk, noSheetFor } from "./messages.ts";
|
|
10
|
+
|
|
11
|
+
export interface PreflightInput {
|
|
12
|
+
/** The plan as the user reads it, `workbench/demo/DEMO-PLAN.md`; null when the code has none. */
|
|
13
|
+
planShown: string | null;
|
|
14
|
+
/** The format problems read in the plan and its sheets. */
|
|
15
|
+
problems: readonly string[];
|
|
16
|
+
batches: number;
|
|
17
|
+
/** The batches not done that have no sheet. */
|
|
18
|
+
missingSheets: readonly string[];
|
|
19
|
+
/** The order the dependencies allow, or why there is none. */
|
|
20
|
+
order: { ok: true; order: readonly string[] } | { ok: false; problem: string };
|
|
21
|
+
/** The work folder, relative to the checkout: its changes are the workflow's own. */
|
|
22
|
+
workFolder: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface PreflightResult { ok: boolean; lines: string[] }
|
|
26
|
+
|
|
27
|
+
const MAX_LISTED = 5;
|
|
28
|
+
|
|
29
|
+
function listed(items: readonly string[]): string {
|
|
30
|
+
return items.length <= MAX_LISTED ? items.join(", ") : `${items.slice(0, MAX_LISTED).join(", ")} and ${items.length - MAX_LISTED} more`;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export async function preflight(deps: { shell: Pick<Shell, "run"> }, input: PreflightInput): Promise<PreflightResult> {
|
|
34
|
+
const lines: string[] = [];
|
|
35
|
+
let ok = true;
|
|
36
|
+
const fail = (line: string): void => { ok = false; lines.push(`preflight ✗ ${line}`); };
|
|
37
|
+
|
|
38
|
+
if (input.planShown === null) fail(PLAN_NONE);
|
|
39
|
+
else if (input.problems.length > 0) fail(`plan: ${input.problems.length} format problem(s): ${listed(input.problems)}`);
|
|
40
|
+
else lines.push(`preflight ✓ plan: ${input.planShown} (${input.batches} batch(es))`);
|
|
41
|
+
|
|
42
|
+
if (input.missingSheets.length > 0) fail(noSheetFor(input.missingSheets.join(", ")));
|
|
43
|
+
else lines.push(SHEETS_OK);
|
|
44
|
+
|
|
45
|
+
if (!input.order.ok) fail(`order: ${input.order.problem}`);
|
|
46
|
+
else lines.push(`preflight ✓ order: ${input.order.order.join(" → ") || "(no batch)"}`);
|
|
47
|
+
|
|
48
|
+
const identity = await readIdentity(deps.shell);
|
|
49
|
+
// A Bubblewrap shell runs with HOME=/tmp and a cleared environment: only the repository's own
|
|
50
|
+
// configuration reaches git there, so the hint names it.
|
|
51
|
+
if (!identity.ok) {
|
|
52
|
+
fail(identityMissing(identity.detail));
|
|
53
|
+
}
|
|
54
|
+
else lines.push(identityOk(identity.ident.name, identity.ident.email));
|
|
55
|
+
|
|
56
|
+
const branch = await runGit(deps.shell, GIT_CURRENT_BRANCH_COMMAND);
|
|
57
|
+
const name = branch.exitCode === 0 ? branch.stdout.trim() : "";
|
|
58
|
+
if (name === "") fail(BRANCH_NONE);
|
|
59
|
+
else lines.push(`preflight ✓ branch: ${name}`);
|
|
60
|
+
|
|
61
|
+
const status = await runGit(deps.shell, GIT_STATUS_COMMAND);
|
|
62
|
+
if (status.exitCode === 0) {
|
|
63
|
+
const work = input.workFolder.replace(/\/+$/, "");
|
|
64
|
+
const own = (p: string): boolean => p === work || p.startsWith(`${work}/`) || p.startsWith(".orkeon/");
|
|
65
|
+
const others = changedPaths(status.stdout).filter((p) => !own(p));
|
|
66
|
+
if (others.length > 0) {
|
|
67
|
+
lines.push(changesOutsideWorkFolder(others.length, listed(others)));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return { ok, lines };
|
|
71
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// The project's files, read with git for the briefs that list them (the audit's, the next batch's review's):
|
|
2
|
+
// tracked and untracked files alike, the ignored ones aside, under the shell's own root (a batch's worktree
|
|
3
|
+
// when the shell is rooted). A git that fails or throws lists nothing: the brief then carries no list.
|
|
4
|
+
import type { Shell } from "../ports.ts";
|
|
5
|
+
import { parseTrackedFiles } from "../../domain/dev/project-files.ts";
|
|
6
|
+
|
|
7
|
+
/** The listing: the tracked files and the untracked ones git does not ignore. */
|
|
8
|
+
export const PROJECT_FILES_COMMAND = "git ls-files --cached --others --exclude-standard";
|
|
9
|
+
|
|
10
|
+
export async function listProjectFiles(shell: Pick<Shell, "run">, work: string): Promise<string[]> {
|
|
11
|
+
try {
|
|
12
|
+
const r = await shell.run(PROJECT_FILES_COMMAND);
|
|
13
|
+
return r.exitCode === 0 ? parseTrackedFiles(r.stdout, work) : [];
|
|
14
|
+
} catch {
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// The text the dev services hand to the model: the refusals of a tool call (the guard, the hooks, the budget, a
|
|
2
|
+
// restore), the notes on the access cost an auditor reads, and the inventory of a draft brief.
|
|
3
|
+
|
|
4
|
+
// tool-call-policy.ts, tool-callbacks.ts
|
|
5
|
+
export const MEMORY_GUARD = "refused by the shared memory's guard";
|
|
6
|
+
export const MEMORY_CONTEXT =
|
|
7
|
+
"The shared memory's candidates and entries are written by memory_push and /memory-admit only: do without this call.";
|
|
8
|
+
export const hookMountCheckDeny = (step: string, text: string): string =>
|
|
9
|
+
`${step}: ${text}\nThe call did not run: a hook's command line may name no path its ` +
|
|
10
|
+
"program may not write; ask the user to change the hook.";
|
|
11
|
+
export const hookRefusedDeny = (step: string, text: string): string =>
|
|
12
|
+
`${step}: refused by ${text}\nThe call did not run: change it, or ask the user to fix the hook.`;
|
|
13
|
+
export const callbackFailed = (step: string, reason: string): string => `${step}: the callback failed: ${reason}`;
|
|
14
|
+
export const memoryGuardFailed = (reason: string): string => `the shared memory's guard failed: ${reason}`;
|
|
15
|
+
export const mountCheckRefusedHook = (label: string, denial: string): string =>
|
|
16
|
+
`the runtime's mount check refused the command line of ${label}, which did not run: ${denial}`;
|
|
17
|
+
|
|
18
|
+
// spend.ts, wrapped-tools.ts
|
|
19
|
+
export const budgetSpent = (limit: number): string =>
|
|
20
|
+
`budget: this batch has spent its ${limit} tool calls; end the act and say what is left`;
|
|
21
|
+
export const lookupsSpent = (limit: number): string =>
|
|
22
|
+
`review: your ${limit} look-ups are spent; open nothing more and write your findings now, from what you read: ` +
|
|
23
|
+
"CLEAR, or each question with its severity, evidence and target";
|
|
24
|
+
export const noRoleRestores = (command: string): string => `'${command}' restores: no role restores, the step did it once`;
|
|
25
|
+
|
|
26
|
+
// measure-access-cost.ts
|
|
27
|
+
export const toolFailedJudgeFromDiff = (tool: string, reason: string): string =>
|
|
28
|
+
`${tool} failed (${reason}); judge the Cost axis from the diff`;
|
|
29
|
+
export const reindexErrorJudgeFromDiff = (error: string): string => `incremental_reindex: ${error}; judge the Cost axis from the diff`;
|
|
30
|
+
export const accessCostErrorJudgeFromDiff = (error: string): string => `access_cost: ${error}; judge the Cost axis from the diff`;
|
|
31
|
+
export const NO_READABLE_REPORT = "access_cost returned no readable report; judge the Cost axis from the diff";
|
|
32
|
+
|
|
33
|
+
// brief-inventory.ts
|
|
34
|
+
export const INDEX_FOUND_NOTHING = "(the index found nothing for this request)";
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// One round of questions on a written spec or change brief: the questions asked one at a time (settleQuestions),
|
|
2
|
+
// the file's open-questions and decisions sections rewritten and written after each answer, then - when anything
|
|
3
|
+
// was decided and the caller gave a fold - one fold: the caller's model call rewrites the body with the decisions,
|
|
4
|
+
// and the folded file is written (foldDecisions). A caller that gives none folds itself, once, when its rounds are
|
|
5
|
+
// over. A fold that fails leaves the decisions recorded in their section and says so in a warning: an answer a
|
|
6
|
+
// person gave is never lost.
|
|
7
|
+
import type { HumanInput } from "../ports.ts";
|
|
8
|
+
import { withQuestionSections } from "../../domain/dev/questions.ts";
|
|
9
|
+
import type { Decision, Question } from "../../domain/dev/questions.ts";
|
|
10
|
+
import { settleQuestions } from "./settle-questions.ts";
|
|
11
|
+
import { REWRITE_REFUSED, decisionsNotFolded } from "./messages.ts";
|
|
12
|
+
|
|
13
|
+
export interface RoundState { text: string; open: Question[]; decisions: Decision[] }
|
|
14
|
+
export type Folded = { ok: true; text: string; open: Question[] } | { ok: false; problems: string[] };
|
|
15
|
+
|
|
16
|
+
export type Fold = (state: RoundState, fresh: readonly Decision[]) => Promise<Folded>;
|
|
17
|
+
|
|
18
|
+
export interface RoundDeps {
|
|
19
|
+
human: HumanInput;
|
|
20
|
+
today: string;
|
|
21
|
+
/** The label of each question ("dev-spec prune"). */
|
|
22
|
+
label: string;
|
|
23
|
+
/** The headings the two sections are written under ("## 12. Open questions", "## 13. Decisions"). */
|
|
24
|
+
headings: { questions: string; decisions: string };
|
|
25
|
+
write: (text: string) => Promise<void>;
|
|
26
|
+
/** Rewrites the body with the decisions of the round; `open` are the questions still open. Absent: the round
|
|
27
|
+
* records the answers and rewrites nothing. */
|
|
28
|
+
fold?: Fold;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface RoundOutcome { state: RoundState; made: Decision[]; blocked: boolean; warnings: string[] }
|
|
32
|
+
|
|
33
|
+
export async function questionRound(
|
|
34
|
+
state: RoundState, deps: RoundDeps, which: (q: Question) => boolean = () => true,
|
|
35
|
+
): Promise<RoundOutcome> {
|
|
36
|
+
let text = state.text;
|
|
37
|
+
const settled = await settleQuestions(deps.label, state.open, state.decisions, {
|
|
38
|
+
human: deps.human, today: deps.today,
|
|
39
|
+
save: async (open, decisions) => {
|
|
40
|
+
text = withQuestionSections(text, open, decisions, deps.headings);
|
|
41
|
+
await deps.write(text);
|
|
42
|
+
},
|
|
43
|
+
}, which);
|
|
44
|
+
const next: RoundState = { text, open: settled.open, decisions: settled.decisions };
|
|
45
|
+
if (deps.fold === undefined) return { state: next, made: settled.made, blocked: settled.blocked, warnings: [] };
|
|
46
|
+
const folded = await foldDecisions(next, settled.made, deps.fold, deps.write);
|
|
47
|
+
return { state: folded.state, made: settled.made, blocked: settled.blocked, warnings: folded.warnings };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** One fold of `made` into the body of `state`, the folded file written: nothing to do when nothing was decided, a
|
|
51
|
+
* warning and the state as it was when the rewrite is refused. */
|
|
52
|
+
export async function foldDecisions(
|
|
53
|
+
state: RoundState, made: readonly Decision[], fold: Fold, write: (text: string) => Promise<void>,
|
|
54
|
+
): Promise<{ state: RoundState; warnings: string[] }> {
|
|
55
|
+
if (made.length === 0) return { state, warnings: [] };
|
|
56
|
+
const folded = await fold(state, made);
|
|
57
|
+
if (!folded.ok) return { state, warnings: [decisionsNotFolded(folded.problems[0] ?? REWRITE_REFUSED)] };
|
|
58
|
+
await write(folded.text);
|
|
59
|
+
return { state: { ...state, text: folded.text, open: folded.open }, warnings: [] };
|
|
60
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// Resolves the work folder of the checkout from the request that applies (the
|
|
2
|
+
// dev.workDir config key, else the pack's layout.work; see pickWorkDirRequest),
|
|
3
|
+
// with the outcomes of the harness's own resolution: the default, the folder
|
|
4
|
+
// asked, an absent or invalid request falling back to the default with a note,
|
|
5
|
+
// and the case of a secondary worktree, where the folder found in the primary
|
|
6
|
+
// checkout applies. It reads directory listings and runs git; it creates nothing.
|
|
7
|
+
|
|
8
|
+
import type { Files, Shell } from "../ports.ts";
|
|
9
|
+
import type { WorkDirRequest } from "../../domain/dev/work-folder.ts";
|
|
10
|
+
import {
|
|
11
|
+
DEFAULT_WORK_FOLDER, isSamePath, mainWorktreeOf, normalizeWorkDir,
|
|
12
|
+
} from "../../domain/dev/work-folder.ts";
|
|
13
|
+
import { WORKSPACE } from "../../domain/vfs.ts";
|
|
14
|
+
import { absentFromCheckout, linkedWorktreeNote, notARelativeFolderFallback } from "./messages.ts";
|
|
15
|
+
|
|
16
|
+
export const GIT_WORKTREE_LIST = "git worktree list --porcelain";
|
|
17
|
+
export const GIT_TOPLEVEL = "git rev-parse --show-toplevel";
|
|
18
|
+
|
|
19
|
+
/** `git -C <folder> rev-parse --git-dir`: exit 0 iff the folder exists (inside the repository). */
|
|
20
|
+
export function gitDirProbe(absoluteFolder: string): string {
|
|
21
|
+
return `git -C ${absoluteFolder} rev-parse --git-dir`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type WorkFolderOutcome = "default" | "applied" | "absent" | "invalid" | "main-worktree";
|
|
25
|
+
|
|
26
|
+
export interface WorkFolder {
|
|
27
|
+
/** "workbench", "backstage/tasks", or the main worktree's absolute folder. */
|
|
28
|
+
folder: string;
|
|
29
|
+
/** "/workspace/<folder>"; null for "main-worktree" (outside the mounts). */
|
|
30
|
+
vfsPath: string | null;
|
|
31
|
+
outcome: WorkFolderOutcome;
|
|
32
|
+
request: WorkDirRequest | null;
|
|
33
|
+
exists: boolean;
|
|
34
|
+
/** A warning text, null when nothing to say. */
|
|
35
|
+
note: string | null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Characters a path must not hold to go unquoted into the probe's command line. */
|
|
39
|
+
const UNSAFE_FOR_SHELL = /[\s'"`$\;&|<>()*?[\]{}!#~]/;
|
|
40
|
+
|
|
41
|
+
/** True when the parent's listing (cap 1000) holds the last segment; a listing that throws = false. */
|
|
42
|
+
export async function entryExists(files: Pick<Files, "list">, vfsPath: string): Promise<boolean> {
|
|
43
|
+
const path = vfsPath.replace(/\/+$/, "");
|
|
44
|
+
const cut = path.lastIndexOf("/");
|
|
45
|
+
if (cut < 0) return false;
|
|
46
|
+
const parent = cut === 0 ? "/" : path.slice(0, cut);
|
|
47
|
+
const name = path.slice(cut + 1);
|
|
48
|
+
if (name === "") return false;
|
|
49
|
+
try {
|
|
50
|
+
const entries = await files.list(parent, 1000);
|
|
51
|
+
return entries.some((e) => e === name || e === `${name}/`);
|
|
52
|
+
} catch {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async function gitStdout(shell: Pick<Shell, "run">, command: string): Promise<string | null> {
|
|
58
|
+
try {
|
|
59
|
+
const result = await shell.run(command);
|
|
60
|
+
return result.exitCode === 0 ? result.stdout : null;
|
|
61
|
+
} catch {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async function probeSucceeds(shell: Pick<Shell, "run">, command: string): Promise<boolean> {
|
|
67
|
+
try {
|
|
68
|
+
return (await shell.run(command)).exitCode === 0;
|
|
69
|
+
} catch {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export async function resolveWorkFolder(
|
|
75
|
+
deps: { files: Pick<Files, "list">; shell: Pick<Shell, "run"> },
|
|
76
|
+
request: WorkDirRequest | null,
|
|
77
|
+
): Promise<WorkFolder> {
|
|
78
|
+
const defaultVfs = `${WORKSPACE}/${DEFAULT_WORK_FOLDER}`;
|
|
79
|
+
const fallback = async (outcome: WorkFolderOutcome, note: string | null): Promise<WorkFolder> => ({
|
|
80
|
+
folder: DEFAULT_WORK_FOLDER,
|
|
81
|
+
vfsPath: defaultVfs,
|
|
82
|
+
outcome,
|
|
83
|
+
request,
|
|
84
|
+
exists: await entryExists(deps.files, defaultVfs),
|
|
85
|
+
note,
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
if (request === null) return fallback("default", null);
|
|
89
|
+
const check = normalizeWorkDir(request.value);
|
|
90
|
+
if (!check.ok) {
|
|
91
|
+
return fallback("invalid",
|
|
92
|
+
notARelativeFolderFallback(request.source, request.value, check.reason, DEFAULT_WORK_FOLDER));
|
|
93
|
+
}
|
|
94
|
+
const value = check.folder;
|
|
95
|
+
if (value === "") return fallback("default", null);
|
|
96
|
+
|
|
97
|
+
const vfsPath = `${WORKSPACE}/${value}`;
|
|
98
|
+
if (value === DEFAULT_WORK_FOLDER) {
|
|
99
|
+
return { folder: value, vfsPath, outcome: "applied", request, exists: await entryExists(deps.files, vfsPath), note: null };
|
|
100
|
+
}
|
|
101
|
+
if (await entryExists(deps.files, vfsPath)) {
|
|
102
|
+
return { folder: value, vfsPath, outcome: "applied", request, exists: true, note: null };
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const absentNote = absentFromCheckout(request.source, value, DEFAULT_WORK_FOLDER);
|
|
106
|
+
const porcelain = await gitStdout(deps.shell, GIT_WORKTREE_LIST);
|
|
107
|
+
const toplevel = await gitStdout(deps.shell, GIT_TOPLEVEL);
|
|
108
|
+
const main = porcelain === null ? null : mainWorktreeOf(porcelain);
|
|
109
|
+
if (main === null || toplevel === null || isSamePath(main, toplevel.trim())) {
|
|
110
|
+
return fallback("absent", absentNote);
|
|
111
|
+
}
|
|
112
|
+
const folder = `${main.replace(/\/+$/, "")}/${value}`;
|
|
113
|
+
if (UNSAFE_FOR_SHELL.test(folder) || !(await probeSucceeds(deps.shell, gitDirProbe(folder)))) {
|
|
114
|
+
return fallback("absent", absentNote);
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
folder,
|
|
118
|
+
vfsPath: null,
|
|
119
|
+
outcome: "main-worktree",
|
|
120
|
+
request,
|
|
121
|
+
exists: true,
|
|
122
|
+
note: linkedWorktreeNote(folder),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** "workbench/ (default)", "backstage/tasks/ (layout.work, .orkeon/repo.yaml)", "todo/ (dev.workDir)". */
|
|
127
|
+
export function workFolderLabel(work: WorkFolder, packShown: string | null): string {
|
|
128
|
+
const applied = work.outcome === "applied" || work.outcome === "main-worktree";
|
|
129
|
+
if (!applied || work.request === null) return `${work.folder}/ (default)`;
|
|
130
|
+
if (work.request.source === "layout.work") {
|
|
131
|
+
return `${work.folder}/ (layout.work${packShown === null ? "" : `, ${packShown}`})`;
|
|
132
|
+
}
|
|
133
|
+
return `${work.folder}/ (dev.workDir)`;
|
|
134
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// The slot a script tool reads what it calls from (shared/infrastructure/orkeon/script-tools.ts): a crew
|
|
2
|
+
// builds its tools before its agent's body runs, and the body, once it knows its pack and its rules,
|
|
3
|
+
// binds the slot for its run and releases it at the end. Two runs of one crew bound at once would mix
|
|
4
|
+
// their calls, so the slot then gives nothing until one of them releases it.
|
|
5
|
+
|
|
6
|
+
/** What a tool calls, filled by the agent's body once it knows its pack. */
|
|
7
|
+
export interface ScriptToolSlot<T> {
|
|
8
|
+
/** Binds `value` for one run; the function returned releases it. */
|
|
9
|
+
bind(value: T): () => void;
|
|
10
|
+
/** The value of the one run bound; undefined when none is, or when two are. */
|
|
11
|
+
get(): T | undefined;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function scriptToolSlot<T>(): ScriptToolSlot<T> {
|
|
15
|
+
const bound: Array<{ value: T }> = [];
|
|
16
|
+
return {
|
|
17
|
+
bind(value) {
|
|
18
|
+
const entry = { value };
|
|
19
|
+
bound.push(entry);
|
|
20
|
+
return () => {
|
|
21
|
+
const at = bound.indexOf(entry);
|
|
22
|
+
if (at >= 0) bound.splice(at, 1);
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
get: () => (bound.length === 1 ? bound[0].value : undefined),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// The questions of a spec or a change brief asked to the person, one at a time, Blocking first: a question with
|
|
2
|
+
// options is a choice (the recommended answer first, then the others, then "Leave it open"), one without is free
|
|
3
|
+
// text. Each answer becomes a decision and its row leaves the open questions, and the file is written (`save`)
|
|
4
|
+
// before the next question is asked. When nobody answers (an unattended run, an empty text) the asking stops at
|
|
5
|
+
// once: nothing is decided on anyone's behalf, the questions stay in the file and the step reads BLOCKED.
|
|
6
|
+
import type { HumanInput } from "../ports.ts";
|
|
7
|
+
import { askingOrder, decide, questionPrompt } from "../../domain/dev/questions.ts";
|
|
8
|
+
import { LEAVE_OPEN } from "../../domain/dev/markers.ts";
|
|
9
|
+
import type { Decision, Question } from "../../domain/dev/questions.ts";
|
|
10
|
+
import { EMPTY_ANSWER_LEAVES_OPEN } from "./messages.ts";
|
|
11
|
+
|
|
12
|
+
export interface SettleDeps {
|
|
13
|
+
human: HumanInput;
|
|
14
|
+
/** The day a decision is recorded, yyyy-mm-dd. */
|
|
15
|
+
today: string;
|
|
16
|
+
/** Writes the file with these open questions and decisions; a throw stops the asking and is the caller's. */
|
|
17
|
+
save: (open: Question[], decisions: Decision[]) => Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface Settled {
|
|
21
|
+
open: Question[];
|
|
22
|
+
decisions: Decision[];
|
|
23
|
+
/** The decisions of this call, in the order they were made. */
|
|
24
|
+
made: Decision[];
|
|
25
|
+
/** True when nobody answered a question that was asked. */
|
|
26
|
+
blocked: boolean;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Asks the open questions `which` selects (all by default), in asking order. */
|
|
30
|
+
export async function settleQuestions(
|
|
31
|
+
label: string, open: readonly Question[], decisions: readonly Decision[], deps: SettleDeps,
|
|
32
|
+
which: (q: Question) => boolean = () => true,
|
|
33
|
+
): Promise<Settled> {
|
|
34
|
+
let left = [...open];
|
|
35
|
+
let all = [...decisions];
|
|
36
|
+
const made: Decision[] = [];
|
|
37
|
+
for (const q of askingOrder(open).filter(which)) {
|
|
38
|
+
const prompt = questionPrompt(label, q);
|
|
39
|
+
let answer: string | null;
|
|
40
|
+
if (q.options.length > 0) {
|
|
41
|
+
const r = await deps.human.choice(prompt, [...q.options, LEAVE_OPEN]);
|
|
42
|
+
if (!r.answered) return { open: left, decisions: all, made, blocked: true };
|
|
43
|
+
answer = r.value === LEAVE_OPEN ? null : r.value;
|
|
44
|
+
} else {
|
|
45
|
+
const r = await deps.human.text(`${prompt}${EMPTY_ANSWER_LEAVES_OPEN}`);
|
|
46
|
+
if (!r.answered) return { open: left, decisions: all, made, blocked: true };
|
|
47
|
+
answer = r.value;
|
|
48
|
+
}
|
|
49
|
+
if (answer === null) continue;
|
|
50
|
+
const decision = decide(q, answer, deps.today);
|
|
51
|
+
left = left.filter((o) => o.id !== q.id);
|
|
52
|
+
all = [...all, decision];
|
|
53
|
+
made.push(decision);
|
|
54
|
+
await deps.save(left, all);
|
|
55
|
+
}
|
|
56
|
+
return { open: left, decisions: all, made, blocked: false };
|
|
57
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// The read-only review of a written spec or change brief, once per run: the reviewer's sub-agent questions the
|
|
2
|
+
// file, and its rows join the open questions (a row asking what an open question or a decision already holds is
|
|
3
|
+
// not added), the file written again. The rows' ids are returned so the caller asks the Blocking ones.
|
|
4
|
+
import type { Llm, Logger } from "../ports.ts";
|
|
5
|
+
import { runSubAgent } from "../agents/run-sub-agent.ts";
|
|
6
|
+
import type { ActRoute } from "../agents/route-agent.ts";
|
|
7
|
+
import { REVIEWER_CHARTER } from "../../domain/dev/reviewer-charter.ts";
|
|
8
|
+
import { REVIEW_ANSWER_SCHEMA, reviewChecks } from "../../domain/dev/review-answer.ts";
|
|
9
|
+
import type { ReviewAnswer } from "../../domain/dev/review-answer.ts";
|
|
10
|
+
import { reviewSystem } from "../../domain/dev/prompts.ts";
|
|
11
|
+
import { buildReviewAnswerPrompt, buildReviewBrief } from "../../domain/dev/review-brief.ts";
|
|
12
|
+
import { numberQuestions, reviewDrafts, withQuestionSections } from "../../domain/dev/questions.ts";
|
|
13
|
+
import type { RoundState } from "./question-round.ts";
|
|
14
|
+
import { addedAsOpenQuestions, reviewCounts, reviewNotRun } from "./messages.ts";
|
|
15
|
+
|
|
16
|
+
export interface SourceReviewRequest {
|
|
17
|
+
mode: "spec" | "change";
|
|
18
|
+
/** "spec" or "brief": the target naming the whole file. */
|
|
19
|
+
whole: string;
|
|
20
|
+
folder: string;
|
|
21
|
+
fileShown: string;
|
|
22
|
+
origin: string;
|
|
23
|
+
inventory: string;
|
|
24
|
+
ids: readonly string[];
|
|
25
|
+
headings: { questions: string; decisions: string };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type SourceReviewOutcome =
|
|
29
|
+
| { ran: true; review: ReviewAnswer; state: RoundState; added: string[] }
|
|
30
|
+
| { ran: false; reason: string };
|
|
31
|
+
|
|
32
|
+
export async function reviewSource(
|
|
33
|
+
llm: Pick<Llm, "act" | "extract">, state: RoundState, request: SourceReviewRequest, write: (text: string) => Promise<void>,
|
|
34
|
+
route?: ActRoute, log?: Pick<Logger, "info">,
|
|
35
|
+
): Promise<SourceReviewOutcome> {
|
|
36
|
+
const targets = [request.whole, ...request.ids];
|
|
37
|
+
const outcome = await runSubAgent(llm, {
|
|
38
|
+
charter: REVIEWER_CHARTER,
|
|
39
|
+
system: reviewSystem(request.mode),
|
|
40
|
+
brief: buildReviewBrief({
|
|
41
|
+
mode: request.mode, folder: request.folder, files: [request.fileShown], source: request.origin,
|
|
42
|
+
inventory: request.inventory, targets,
|
|
43
|
+
}),
|
|
44
|
+
schema: REVIEW_ANSWER_SCHEMA,
|
|
45
|
+
answerPrompt: (reply, problems) => buildReviewAnswerPrompt(reply, problems, targets),
|
|
46
|
+
...reviewChecks(targets),
|
|
47
|
+
}, route, log);
|
|
48
|
+
if (!outcome.ok) return { ran: false, reason: `${outcome.reason}: ${outcome.problems[0] ?? "no detail"}` };
|
|
49
|
+
const review = outcome.value;
|
|
50
|
+
if (review.rows.length === 0) return { ran: true, review, state, added: [] };
|
|
51
|
+
const before = new Set(state.open.map((q) => q.id));
|
|
52
|
+
const open = numberQuestions(reviewDrafts(review.rows, request.whole), state.decisions, state.open);
|
|
53
|
+
const added = open.filter((q) => !before.has(q.id)).map((q) => q.id);
|
|
54
|
+
if (added.length === 0) return { ran: true, review, state, added };
|
|
55
|
+
const text = withQuestionSections(state.text, open, state.decisions, request.headings);
|
|
56
|
+
await write(text);
|
|
57
|
+
return { ran: true, review, state: { text, open, decisions: state.decisions }, added };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function reviewLine(outcome: SourceReviewOutcome): string {
|
|
61
|
+
if (!outcome.ran) return reviewNotRun(outcome.reason);
|
|
62
|
+
const rows = outcome.review.rows;
|
|
63
|
+
if (rows.length === 0) return `review: ${outcome.review.verdict}`;
|
|
64
|
+
const blocking = rows.filter((r) => r.severity === "Blocking").length;
|
|
65
|
+
const kept = outcome.added.length === rows.length ? "" : addedAsOpenQuestions(outcome.added.length);
|
|
66
|
+
return reviewCounts(outcome.review.verdict, blocking, rows.length - blocking, kept);
|
|
67
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
// What /dev-spec and dev-change share before and after their own draft: the inputs' code, the checkout check,
|
|
2
|
+
// the code's folder under the work folder, a request given as a path read whole, the self-check of a written
|
|
3
|
+
// source against the parser /dev-plan uses, and the end-message pieces. No model call here.
|
|
4
|
+
import type { Files, Shell } from "../ports.ts";
|
|
5
|
+
import { GIT_TOPLEVEL } from "./resolve-work-folder.ts";
|
|
6
|
+
import type { WorkFolder } from "./resolve-work-folder.ts";
|
|
7
|
+
import { isCode } from "../../domain/dev/artefacts.ts";
|
|
8
|
+
import { parseDecisions } from "../../domain/dev/questions.ts";
|
|
9
|
+
import type { Decision, Question } from "../../domain/dev/questions.ts";
|
|
10
|
+
import { parsePlanSource } from "../../domain/dev/spec-format.ts";
|
|
11
|
+
import type { SourceKind } from "../../domain/dev/spec-format.ts";
|
|
12
|
+
import { WORKSPACE } from "../../domain/vfs.ts";
|
|
13
|
+
import { DECISIONS_DO_NOT_READ_BACK, NO_WORK_TREE, idsReadBack, invalidCode, invalidInput, openQuestionsReadBack, outsideCheckout, runFromCheckout, titleDoesNotReadCode, workFolderOutsideCheckoutMounts } from "./messages.ts";
|
|
14
|
+
import { prefixedCannotBeRead as stepCannotRead } from "../messages.ts";
|
|
15
|
+
|
|
16
|
+
export const MAX_CODE_CHARS = 64;
|
|
17
|
+
export const MAX_REQUEST_CHARS = 20_000;
|
|
18
|
+
const MAX_WARNINGS = 5;
|
|
19
|
+
const MAX_PROBLEM_LINES = 12;
|
|
20
|
+
const LIST_CAP = 1000;
|
|
21
|
+
const PATH_TOKEN = /^[A-Za-z0-9._\-/]+\.(md|txt)$/;
|
|
22
|
+
|
|
23
|
+
export const firstLine = (e: unknown): string => (e instanceof Error ? e.message : String(e)).split("\n")[0];
|
|
24
|
+
const pad2 = (n: number): string => String(n).padStart(2, "0");
|
|
25
|
+
/** A write of the source file that failed: the one failure the step reports as "could not be written"; any other
|
|
26
|
+
* (a question cancelled, a model call that failed) goes up as it is. */
|
|
27
|
+
export class SourceWriteFailure extends Error {
|
|
28
|
+
constructor(cause: unknown) {
|
|
29
|
+
super(firstLine(cause));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** The write of a source file, its failure a SourceWriteFailure. */
|
|
34
|
+
export const sourceWriter = (files: Pick<Files, "write">, vfs: string) => async (text: string): Promise<void> => {
|
|
35
|
+
try {
|
|
36
|
+
await files.write(vfs, text);
|
|
37
|
+
} catch (e) {
|
|
38
|
+
throw new SourceWriteFailure(e);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const dateOf = (d: Date): string => `${d.getFullYear()}-${pad2(d.getMonth() + 1)}-${pad2(d.getDate())}`;
|
|
43
|
+
export const plural = (n: number, one: string, many: string): string => `${n} ${n === 1 ? one : many}`;
|
|
44
|
+
|
|
45
|
+
export function warningLines(warnings: readonly string[]): string[] {
|
|
46
|
+
const lines = warnings.slice(0, MAX_WARNINGS).map((w) => `warning: ${w}`);
|
|
47
|
+
if (warnings.length > MAX_WARNINGS) lines.push(` … ${warnings.length - MAX_WARNINGS} more warnings`);
|
|
48
|
+
return lines;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function problemLines(problems: readonly string[]): string[] {
|
|
52
|
+
const lines = problems.slice(0, MAX_PROBLEM_LINES).map((p) => ` ${p}`);
|
|
53
|
+
if (problems.length > MAX_PROBLEM_LINES) lines.push(` … ${problems.length - MAX_PROBLEM_LINES} more`);
|
|
54
|
+
return lines;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** The code of the inputs, or the refusal. */
|
|
58
|
+
export function inputCode(step: string, value: unknown): string | { refused: string } {
|
|
59
|
+
if (typeof value !== "string" || value.length > MAX_CODE_CHARS || !isCode(value)) return { refused: invalidCode(step) };
|
|
60
|
+
return value;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** A free text input: "" when absent, the refusal when it is not a string or too long. */
|
|
64
|
+
export function inputText(step: string, name: string, value: unknown): string | { refused: string } {
|
|
65
|
+
if (value === undefined || value === null) return "";
|
|
66
|
+
if (typeof value !== "string" || value.length > MAX_REQUEST_CHARS) return { refused: invalidInput(step, name) };
|
|
67
|
+
return value.trim();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export async function toplevelRefusal(step: string, shell: Pick<Shell, "run">): Promise<string | null> {
|
|
71
|
+
let top: string;
|
|
72
|
+
try {
|
|
73
|
+
const r = await shell.run(GIT_TOPLEVEL);
|
|
74
|
+
top = r.exitCode === 0 ? r.stdout.trim() : "";
|
|
75
|
+
} catch {
|
|
76
|
+
top = "";
|
|
77
|
+
}
|
|
78
|
+
if (top === WORKSPACE) return null;
|
|
79
|
+
return runFromCheckout(step, WORKSPACE, top === "" ? NO_WORK_TREE : top);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface CodeFolder {
|
|
83
|
+
/** "/workspace/workbench/prune". */
|
|
84
|
+
vfs: string;
|
|
85
|
+
/** "workbench/prune". */
|
|
86
|
+
shown: string;
|
|
87
|
+
names: string[];
|
|
88
|
+
file: (name: string) => { vfs: string; shown: string };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** The code's folder under the work folder and the names it holds ([] when it does not exist yet). */
|
|
92
|
+
export async function codeFolder(step: string, files: Pick<Files, "list">, work: WorkFolder, code: string): Promise<CodeFolder | { refused: string }> {
|
|
93
|
+
if (work.vfsPath === null) {
|
|
94
|
+
return { refused: workFolderOutsideCheckoutMounts(step, work.folder) };
|
|
95
|
+
}
|
|
96
|
+
const vfs = `${work.vfsPath}/${code}`;
|
|
97
|
+
const shown = `${work.folder}/${code}`;
|
|
98
|
+
let names: string[];
|
|
99
|
+
try {
|
|
100
|
+
names = (await files.list(vfs, LIST_CAP)).map((n) => n.replace(/\/+$/, ""));
|
|
101
|
+
} catch {
|
|
102
|
+
names = [];
|
|
103
|
+
}
|
|
104
|
+
return { vfs, shown, names, file: (name) => ({ vfs: `${vfs}/${name}`, shown: `${shown}/${name}` }) };
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* A request given as one token naming a .md or .txt file of the checkout is read whole; anything else is the text
|
|
109
|
+
* itself. A path out of the checkout is refused.
|
|
110
|
+
*/
|
|
111
|
+
export async function readRequest(step: string, files: Pick<Files, "read">, request: string): Promise<{ text: string; from: string } | { refused: string }> {
|
|
112
|
+
if (!PATH_TOKEN.test(request)) return { text: request, from: "" };
|
|
113
|
+
const relative = request.startsWith(`${WORKSPACE}/`) ? request.slice(WORKSPACE.length + 1) : request.replace(/^\.\//, "");
|
|
114
|
+
if (relative.startsWith("/") || relative.split("/").includes("..")) {
|
|
115
|
+
return { refused: outsideCheckout(step, request, WORKSPACE) };
|
|
116
|
+
}
|
|
117
|
+
try {
|
|
118
|
+
const text = await files.read(`${WORKSPACE}/${relative}`, MAX_REQUEST_CHARS);
|
|
119
|
+
if (text.trim() === "") return { refused: `${step}: ${relative} is empty` };
|
|
120
|
+
return { text, from: relative };
|
|
121
|
+
} catch (e) {
|
|
122
|
+
return { refused: stepCannotRead(step, relative, firstLine(e)) };
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* The written file read back by /dev-plan's parser: the title's code, every id the answer gave, as many open
|
|
128
|
+
* questions and decisions as rendered, no format problem. [] when the file reads as written.
|
|
129
|
+
*/
|
|
130
|
+
export function sourceSelfCheck(
|
|
131
|
+
text: string, kind: SourceKind, expect: { code: string; ids: readonly string[]; open: readonly Question[]; decisions: readonly Decision[] },
|
|
132
|
+
): string[] {
|
|
133
|
+
const parsed = parsePlanSource(text, kind);
|
|
134
|
+
const problems = parsed.problems.map((p) => `line ${p.line}: ${p.message}`);
|
|
135
|
+
if (parsed.code !== expect.code) problems.push(titleDoesNotReadCode(expect.code));
|
|
136
|
+
const read = parsed.ids.map((i) => i.id).join(",");
|
|
137
|
+
if (read !== expect.ids.join(",")) {
|
|
138
|
+
problems.push(idsReadBack(read || "none", expect.ids.join(",")));
|
|
139
|
+
}
|
|
140
|
+
if (parsed.openQuestions.length !== expect.open.length) {
|
|
141
|
+
problems.push(openQuestionsReadBack(parsed.openQuestions.length, expect.open.length));
|
|
142
|
+
}
|
|
143
|
+
if (parseDecisions(text).length !== expect.decisions.length) problems.push(DECISIONS_DO_NOT_READ_BACK);
|
|
144
|
+
return problems;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** "2 Blocking, 1 Major" for the open questions, "none" when there is none. */
|
|
148
|
+
export function openLine(open: readonly Question[]): string {
|
|
149
|
+
if (open.length === 0) return "none";
|
|
150
|
+
const blocking = open.filter((q) => q.severity === "Blocking").length;
|
|
151
|
+
return `${blocking} Blocking, ${open.length - blocking} Major (${open.map((q) => q.id).join(", ")})`;
|
|
152
|
+
}
|