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,265 @@
|
|
|
1
|
+
// What a dev status reads before it shows anything: the repository pack, the work
|
|
2
|
+
// folder and the warnings about the checkout (the context), then one work code's
|
|
3
|
+
// artefacts parsed (the code), or the list of codes the work folder holds. It reads
|
|
4
|
+
// files and directory listings and runs git; it writes nothing and creates nothing.
|
|
5
|
+
import type { Files, Shell, ShellResult } from "../ports.ts";
|
|
6
|
+
import type { ConfigStore } from "../config-store.ts";
|
|
7
|
+
import { findRepoPack } from "./find-repo-pack.ts";
|
|
8
|
+
import type { FoundPack } from "./find-repo-pack.ts";
|
|
9
|
+
import { entryExists, resolveWorkFolder } from "./resolve-work-folder.ts";
|
|
10
|
+
import type { WorkFolder } from "./resolve-work-folder.ts";
|
|
11
|
+
import { DEFAULT_WORK_FOLDER, DEV_WORK_DIR_CONFIG_KEY, pickWorkDirRequest } from "../../domain/dev/work-folder.ts";
|
|
12
|
+
import { classifyArtefact, compareBatchIds, isCode } from "../../domain/dev/artefacts.ts";
|
|
13
|
+
import type { ArtefactName } from "../../domain/dev/artefacts.ts";
|
|
14
|
+
import { parseBatchSheet, parseGlobalPlan } from "../../domain/dev/plan-format.ts";
|
|
15
|
+
import type { BatchSheet, FormatProblem, GlobalPlan } from "../../domain/dev/plan-format.ts";
|
|
16
|
+
import { parseVerdictFile } from "../../domain/dev/verdict-format.ts";
|
|
17
|
+
import type { VerdictFile } from "../../domain/dev/verdict-format.ts";
|
|
18
|
+
import { parseBatchesState } from "../../domain/dev/batches-state.ts";
|
|
19
|
+
import type { BatchesState } from "../../domain/dev/batches-state.ts";
|
|
20
|
+
import { WORKSPACE } from "../../domain/vfs.ts";
|
|
21
|
+
import { TODO_HOLDS_HARNESS_WORK, notIgnoredByGit, severalPlans, workDirUnreadable } from "./messages.ts";
|
|
22
|
+
import { cannotBeRead } from "../messages.ts";
|
|
23
|
+
|
|
24
|
+
export interface DevContextDeps {
|
|
25
|
+
files: Pick<Files, "read" | "list">; shell: Pick<Shell, "run">; config: Pick<ConfigStore, "readValue">;
|
|
26
|
+
}
|
|
27
|
+
export interface DevContext { pack: FoundPack | null; work: WorkFolder; warnings: string[] }
|
|
28
|
+
export const ORKEON_IGNORE_PROBE = ".orkeon/config.json";
|
|
29
|
+
export const HARNESS_SETTINGS_LOCAL = `${WORKSPACE}/.claude/settings.local.json`;
|
|
30
|
+
export const HARNESS_TODO = `${WORKSPACE}/todo`;
|
|
31
|
+
|
|
32
|
+
const TODO_LIST_CAP = 200;
|
|
33
|
+
const TODO_SUBFOLDERS_PROBED = 20;
|
|
34
|
+
const CODE_LIST_CAP = 500;
|
|
35
|
+
const CODES_PROBED = 50;
|
|
36
|
+
/** A loose file of the work folder (README.md, notes.txt): never a code folder, so never probed. */
|
|
37
|
+
const FILE_LIKE = /\.(md|markdown|txt|json|jsonl|ya?ml|toml|sh|log|html?|csv|tsv)$/i;
|
|
38
|
+
const HARNESS_WORK_PREFIX = /^(pr|quality|release|docs-audit)-/;
|
|
39
|
+
|
|
40
|
+
const messageOf = (e: unknown): string => (e instanceof Error ? e.message : String(e));
|
|
41
|
+
const firstLine = (e: unknown): string => messageOf(e).split("\n")[0];
|
|
42
|
+
const bare = (entry: string): string => entry.replace(/\/+$/, "");
|
|
43
|
+
const byName = (a: string, b: string): number => (a < b ? -1 : a > b ? 1 : 0);
|
|
44
|
+
|
|
45
|
+
/** "git check-ignore -- " + paths.join(" ") */
|
|
46
|
+
export function checkIgnoreCommand(paths: readonly string[]): string {
|
|
47
|
+
return `git check-ignore -- ${paths.join(" ")}`;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async function readWorkDirSetting(config: Pick<ConfigStore, "readValue">, warnings: string[]): Promise<string | undefined> {
|
|
51
|
+
try {
|
|
52
|
+
return (await config.readValue(DEV_WORK_DIR_CONFIG_KEY)).value;
|
|
53
|
+
} catch (e) {
|
|
54
|
+
warnings.push(workDirUnreadable(DEV_WORK_DIR_CONFIG_KEY, firstLine(e)));
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function checkIgnored(shell: Pick<Shell, "run">, work: WorkFolder, warnings: string[]): Promise<void> {
|
|
60
|
+
const paths = [ORKEON_IGNORE_PROBE];
|
|
61
|
+
if (work.folder === DEFAULT_WORK_FOLDER && (work.request === null || work.outcome !== "applied")) {
|
|
62
|
+
paths.push(`${DEFAULT_WORK_FOLDER}/`);
|
|
63
|
+
}
|
|
64
|
+
let result: ShellResult;
|
|
65
|
+
try {
|
|
66
|
+
result = await shell.run(checkIgnoreCommand(paths));
|
|
67
|
+
} catch {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (result.exitCode !== 0 && result.exitCode !== 1) return;
|
|
71
|
+
const ignored = new Set(result.stdout.split(/\r?\n/).map((l) => l.trim()).filter((l) => l !== ""));
|
|
72
|
+
for (const path of paths) {
|
|
73
|
+
if (!ignored.has(path)) warnings.push(notIgnoredByGit(path));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** The harness's HARNESS_WORK_DIR from .claude/settings.local.json env; undefined when unreadable or unset. */
|
|
78
|
+
async function harnessWorkDir(files: Pick<Files, "read">): Promise<string | undefined> {
|
|
79
|
+
try {
|
|
80
|
+
const parsed: unknown = JSON.parse(await files.read(HARNESS_SETTINGS_LOCAL));
|
|
81
|
+
if (typeof parsed !== "object" || parsed === null) return undefined;
|
|
82
|
+
const env = (parsed as { env?: unknown }).env;
|
|
83
|
+
if (typeof env !== "object" || env === null) return undefined;
|
|
84
|
+
const value = (env as Record<string, unknown>).HARNESS_WORK_DIR;
|
|
85
|
+
return typeof value === "string" ? value : undefined;
|
|
86
|
+
} catch {
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
async function listOrEmpty(files: Pick<Files, "list">, path: string, cap: number): Promise<string[]> {
|
|
92
|
+
try {
|
|
93
|
+
return await files.list(path, cap);
|
|
94
|
+
} catch {
|
|
95
|
+
return [];
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async function todoHoldsHarnessWork(files: Pick<Files, "list">): Promise<boolean> {
|
|
100
|
+
const entries = (await listOrEmpty(files, HARNESS_TODO, TODO_LIST_CAP)).map(bare);
|
|
101
|
+
if (entries.some((e) => HARNESS_WORK_PREFIX.test(e))) return true;
|
|
102
|
+
for (const entry of entries.slice(0, TODO_SUBFOLDERS_PROBED)) {
|
|
103
|
+
const inner = await listOrEmpty(files, `${HARNESS_TODO}/${entry}`, TODO_LIST_CAP);
|
|
104
|
+
if (inner.some((name) => classifyArtefact(bare(name)) !== null)) return true;
|
|
105
|
+
}
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export async function loadDevContext(deps: DevContextDeps): Promise<DevContext> {
|
|
110
|
+
const lookup = await findRepoPack(deps.files);
|
|
111
|
+
const warnings = [...lookup.warnings];
|
|
112
|
+
const pack = lookup.found;
|
|
113
|
+
|
|
114
|
+
const configValue = await readWorkDirSetting(deps.config, warnings);
|
|
115
|
+
const request = pickWorkDirRequest(configValue, pack?.pack.layout.work);
|
|
116
|
+
const work = await resolveWorkFolder(deps, request);
|
|
117
|
+
if (work.note !== null) warnings.push(work.note);
|
|
118
|
+
|
|
119
|
+
await checkIgnored(deps.shell, work, warnings);
|
|
120
|
+
|
|
121
|
+
if (request === null) {
|
|
122
|
+
const named = (await harnessWorkDir(deps.files))?.trim().replace(/^\.\//, "").replace(/\/+$/, "");
|
|
123
|
+
if (named !== DEFAULT_WORK_FOLDER && (await todoHoldsHarnessWork(deps.files))) {
|
|
124
|
+
warnings.push(TODO_HOLDS_HARNESS_WORK);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return { pack, work, warnings };
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export interface CodeSheet { batch: string; name: string; sheet: BatchSheet }
|
|
131
|
+
export interface CodeVerdict { batch: string; name: string; file: VerdictFile }
|
|
132
|
+
export interface DevCode {
|
|
133
|
+
code: string; shown: string; // "workbench/demo"
|
|
134
|
+
spec: string | null; change: string | null; // file names
|
|
135
|
+
plan: { name: string; plan: GlobalPlan } | null;
|
|
136
|
+
sheets: CodeSheet[]; verdicts: CodeVerdict[];
|
|
137
|
+
state: { name: string; state: BatchesState } | null;
|
|
138
|
+
warnings: string[];
|
|
139
|
+
}
|
|
140
|
+
export type DevCodeLookup =
|
|
141
|
+
| { found: DevCode }
|
|
142
|
+
| { found: null; reason: "absent" | "empty" | "unreachable"; codes: string[] };
|
|
143
|
+
|
|
144
|
+
function classifyAll(entries: readonly string[]): ArtefactName[] {
|
|
145
|
+
const out: ArtefactName[] = [];
|
|
146
|
+
for (const entry of [...entries].map(bare).sort()) {
|
|
147
|
+
const a = classifyArtefact(entry);
|
|
148
|
+
if (a) out.push(a);
|
|
149
|
+
}
|
|
150
|
+
return out;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const byBatch = (a: { batch: string; name: string }, b: { batch: string; name: string }): number =>
|
|
154
|
+
compareBatchIds(a.batch, b.batch) || (a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
|
|
155
|
+
|
|
156
|
+
export async function loadDevCode(deps: Pick<DevContextDeps, "files">, work: WorkFolder, code: string): Promise<DevCodeLookup> {
|
|
157
|
+
if (work.vfsPath === null) return { found: null, reason: "unreachable", codes: [] };
|
|
158
|
+
const folder = `${work.vfsPath}/${code}`;
|
|
159
|
+
if (!(await entryExists(deps.files, folder))) {
|
|
160
|
+
let codes: string[] = [];
|
|
161
|
+
try {
|
|
162
|
+
codes = (await listDevCodes(deps, work)).map((c) => c.code);
|
|
163
|
+
} catch {
|
|
164
|
+
codes = [];
|
|
165
|
+
}
|
|
166
|
+
return { found: null, reason: "absent", codes };
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const artefacts = classifyAll(await listOrEmpty(deps.files, folder, CODE_LIST_CAP));
|
|
170
|
+
const of = (kind: ArtefactName["kind"]): ArtefactName[] => artefacts.filter((a) => a.kind === kind);
|
|
171
|
+
const plans = of("plan");
|
|
172
|
+
const specs = of("spec");
|
|
173
|
+
const changes = of("change");
|
|
174
|
+
if (plans.length === 0 && specs.length === 0 && changes.length === 0) {
|
|
175
|
+
return { found: null, reason: "empty", codes: [] };
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const shown = `${work.folder}/${code}`;
|
|
179
|
+
const warnings: string[] = [];
|
|
180
|
+
const read = async (name: string): Promise<string | null> => {
|
|
181
|
+
try {
|
|
182
|
+
return await deps.files.read(`${folder}/${name}`);
|
|
183
|
+
} catch (e) {
|
|
184
|
+
warnings.push(cannotBeRead(`${shown}/${name}`, firstLine(e)));
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
const report = (name: string, problems: readonly FormatProblem[]): void => {
|
|
189
|
+
for (const p of problems) warnings.push(`${shown}/${name}:${p.line}: ${p.message}`);
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
let plan: DevCode["plan"] = null;
|
|
193
|
+
if (plans.length > 0) {
|
|
194
|
+
const chosen = plans.find((p) => p.prefix.toUpperCase() === code.toUpperCase()) ?? plans[0];
|
|
195
|
+
if (plans.length > 1) {
|
|
196
|
+
warnings.push(severalPlans(shown, plans.map((p) => p.name).join(", "), chosen.name));
|
|
197
|
+
}
|
|
198
|
+
const text = await read(chosen.name);
|
|
199
|
+
if (text !== null) {
|
|
200
|
+
const parsed = parseGlobalPlan(text);
|
|
201
|
+
report(chosen.name, parsed.problems);
|
|
202
|
+
plan = { name: chosen.name, plan: parsed };
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const sheets: CodeSheet[] = [];
|
|
207
|
+
for (const a of of("sheet")) {
|
|
208
|
+
const text = await read(a.name);
|
|
209
|
+
if (text === null) continue;
|
|
210
|
+
const sheet = parseBatchSheet(text);
|
|
211
|
+
report(a.name, sheet.problems);
|
|
212
|
+
sheets.push({ batch: a.batch ?? "", name: a.name, sheet });
|
|
213
|
+
}
|
|
214
|
+
const verdicts: CodeVerdict[] = [];
|
|
215
|
+
for (const a of of("verdict")) {
|
|
216
|
+
const text = await read(a.name);
|
|
217
|
+
if (text === null) continue;
|
|
218
|
+
const file = parseVerdictFile(text);
|
|
219
|
+
report(a.name, file.problems);
|
|
220
|
+
verdicts.push({ batch: a.batch ?? "", name: a.name, file });
|
|
221
|
+
}
|
|
222
|
+
let state: DevCode["state"] = null;
|
|
223
|
+
for (const a of of("batches-state")) {
|
|
224
|
+
const text = await read(a.name);
|
|
225
|
+
if (text === null) continue;
|
|
226
|
+
state = { name: a.name, state: parseBatchesState(text) };
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return {
|
|
231
|
+
found: {
|
|
232
|
+
code, shown,
|
|
233
|
+
spec: specs[0]?.name ?? null, change: changes[0]?.name ?? null,
|
|
234
|
+
plan, sheets: sheets.sort(byBatch), verdicts: verdicts.sort(byBatch), state, warnings,
|
|
235
|
+
},
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export interface CodeSummary { code: string; spec: boolean; change: boolean; plan: boolean; sheets: number; verdicts: number }
|
|
240
|
+
|
|
241
|
+
/** The codes of the work folder; throws when the work folder itself cannot be listed. */
|
|
242
|
+
export async function listDevCodes(deps: Pick<DevContextDeps, "files">, work: WorkFolder): Promise<CodeSummary[]> {
|
|
243
|
+
return (await probeDevCodes(deps, work)).codes;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/** listDevCodes, plus how many candidate folders the cap of CODES_PROBED left unprobed. */
|
|
247
|
+
export async function probeDevCodes(
|
|
248
|
+
deps: Pick<DevContextDeps, "files">, work: WorkFolder,
|
|
249
|
+
): Promise<{ codes: CodeSummary[]; notProbed: number }> {
|
|
250
|
+
if (work.vfsPath === null) return { codes: [], notProbed: 0 };
|
|
251
|
+
const listed = await deps.files.list(work.vfsPath, CODE_LIST_CAP);
|
|
252
|
+
const candidates = [...new Set(listed.filter((e) => e.endsWith("/") || !FILE_LIKE.test(e)).map(bare).filter(isCode))]
|
|
253
|
+
.sort(byName);
|
|
254
|
+
const out: CodeSummary[] = [];
|
|
255
|
+
for (const entry of candidates.slice(0, CODES_PROBED)) {
|
|
256
|
+
const kinds = classifyAll(await listOrEmpty(deps.files, `${work.vfsPath}/${entry}`, CODE_LIST_CAP)).map((a) => a.kind);
|
|
257
|
+
const count = (k: ArtefactName["kind"]): number => kinds.filter((x) => x === k).length;
|
|
258
|
+
const summary: CodeSummary = {
|
|
259
|
+
code: entry, spec: count("spec") > 0, change: count("change") > 0, plan: count("plan") > 0,
|
|
260
|
+
sheets: count("sheet"), verdicts: count("verdict"),
|
|
261
|
+
};
|
|
262
|
+
if (summary.spec || summary.change || summary.plan) out.push(summary);
|
|
263
|
+
}
|
|
264
|
+
return { codes: out, notProbed: Math.max(0, candidates.length - CODES_PROBED) };
|
|
265
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// The access cost of a batch, or of one dev-implement cycle: the changed files under the cost roots,
|
|
2
|
+
// refreshed in the code index, then measured by `access_cost` (dev-verify's capture, dev-implement's COST). The index is a precondition, never built here: without
|
|
3
|
+
// a /workspace root the cost is "not indexed" (the tool would answer an empty report). A call
|
|
4
|
+
// that fails leaves the cost not computed; nothing here refuses the step.
|
|
5
|
+
import type { CostIndex } from "../ports.ts";
|
|
6
|
+
import type { AccessCost } from "../../domain/dev/access-cost.ts";
|
|
7
|
+
import { COST_NOT_WIRED, isTestFile, isTestRoot, measuredCost, notComputed, notIndexed, nothingChanged, receiversArgument, underRoots } from "../../domain/dev/access-cost.ts";
|
|
8
|
+
import type { RepoPack } from "../../domain/dev/repo-pack.ts";
|
|
9
|
+
import { WORKSPACE } from "../../domain/vfs.ts";
|
|
10
|
+
import { NO_READABLE_REPORT, accessCostErrorJudgeFromDiff, reindexErrorJudgeFromDiff, toolFailedJudgeFromDiff } from "./prompts.ts";
|
|
11
|
+
|
|
12
|
+
const firstLine = (text: string): string => (text.split("\n")[0] ?? "").trim();
|
|
13
|
+
|
|
14
|
+
/** A changed file outside the plan folder, and the lines its captured diff adds (null: not known). */
|
|
15
|
+
export interface CostFile { path: string; added: Set<number> | null }
|
|
16
|
+
|
|
17
|
+
/** `tools.access_cost.roots`, else none: every changed file that is not a test. */
|
|
18
|
+
export function costRoots(pack: RepoPack | null): string[] {
|
|
19
|
+
return [...(pack?.accessCost.roots ?? [])];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function failed(tool: string, error: unknown): AccessCost {
|
|
23
|
+
return notComputed(toolFailedJudgeFromDiff(tool, firstLine(error instanceof Error ? error.message : String(error))));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function normalRoot(root: string): string {
|
|
27
|
+
return root.length > 1 ? root.replace(/\/+$/, "") : root;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export async function measureAccessCost(
|
|
31
|
+
index: CostIndex | undefined, pack: RepoPack | null, gateRoots: readonly string[], changed: readonly CostFile[],
|
|
32
|
+
isTest?: (path: string) => boolean,
|
|
33
|
+
): Promise<AccessCost> {
|
|
34
|
+
if (index === undefined) return COST_NOT_WIRED;
|
|
35
|
+
const roots = costRoots(pack);
|
|
36
|
+
const testRoots = gateRoots.filter(isTestRoot);
|
|
37
|
+
// A caller that knows the pack's test paths says which they are; else a path that says test is one (AC:326-331).
|
|
38
|
+
const test = isTest ?? ((p: string) => isTestFile(p, testRoots));
|
|
39
|
+
const kept = underRoots(changed.map((f) => f.path).filter((p) => !test(p)), roots);
|
|
40
|
+
if (kept.length === 0) return nothingChanged(roots);
|
|
41
|
+
const files = kept.map((p) => `${WORKSPACE}/${p}`);
|
|
42
|
+
|
|
43
|
+
let indexed: string[];
|
|
44
|
+
try {
|
|
45
|
+
indexed = await index.roots();
|
|
46
|
+
} catch (error) {
|
|
47
|
+
return failed("index_status", error);
|
|
48
|
+
}
|
|
49
|
+
if (!indexed.map(normalRoot).includes(WORKSPACE)) return notIndexed(indexed);
|
|
50
|
+
|
|
51
|
+
try {
|
|
52
|
+
const errors = await index.refresh(WORKSPACE, files);
|
|
53
|
+
if (errors.length > 0) return notComputed(reindexErrorJudgeFromDiff(firstLine(errors[0])));
|
|
54
|
+
} catch (error) {
|
|
55
|
+
return failed("incremental_reindex", error);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
let answer: Awaited<ReturnType<CostIndex["accessCost"]>>;
|
|
59
|
+
try {
|
|
60
|
+
answer = await index.accessCost(files, receiversArgument(pack?.accessCost.receivers));
|
|
61
|
+
} catch (error) {
|
|
62
|
+
return failed("access_cost", error);
|
|
63
|
+
}
|
|
64
|
+
if (answer.errors.length > 0) return notComputed(accessCostErrorJudgeFromDiff(firstLine(answer.errors[0])));
|
|
65
|
+
if (answer.report === null) return notComputed(NO_READABLE_REPORT);
|
|
66
|
+
|
|
67
|
+
const added = new Map(changed.map((f) => [`${WORKSPACE}/${f.path}`, f.added] as const));
|
|
68
|
+
return measuredCost(answer.report, added);
|
|
69
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// The text the dev services show the user: refusals of a step, warnings, preflight and close lines, the decisions of
|
|
2
|
+
// /dev-learn.
|
|
3
|
+
|
|
4
|
+
// brief-inventory.ts
|
|
5
|
+
export const indexUnavailable = (reason: string): string => `the code index is not available (${reason}): the draft has no inventory`;
|
|
6
|
+
export const searchFailed = (phrase: string, reason: string): string => `search failed for '${phrase}': ${reason}`;
|
|
7
|
+
export const inventoryLine = (entries: number, calls: number, cache: string): string =>
|
|
8
|
+
`inventory: ${entries} entries (${calls} index calls${cache})`;
|
|
9
|
+
|
|
10
|
+
// close-batch.ts
|
|
11
|
+
export const gitStatusFailedLine = (reason: string): string => `✗ git status failed: ${reason}`;
|
|
12
|
+
export const leftOutWorkFolder = (paths: string): string => `left out (the work folder is never committed): ${paths}`;
|
|
13
|
+
export const noChangeToCommit = (paths: string): string => `no change to commit: ${paths}`;
|
|
14
|
+
export const notCommittedUnsafe = (paths: string): string => `✗ not committed: ${paths} cannot go through the shell; commit by hand`;
|
|
15
|
+
export const NOTHING_TO_COMMIT_LINE = "✗ nothing to commit";
|
|
16
|
+
export const pushDeniedByRule = (command: string): string => `✗ not pushed: a session rule denies '${command}'; the commit stays local`;
|
|
17
|
+
|
|
18
|
+
// find-repo-pack.ts
|
|
19
|
+
export const packUnreadable = (path: string, reason: string): string => `${path} cannot be read (${reason}): no repository pack is used`;
|
|
20
|
+
export const packIgnored = (error: string): string => `${error}: the repository pack is ignored`;
|
|
21
|
+
export const severalPacks = (packs: string, path: string): string => `several repository packs are deployed (${packs}): ${path} is read`;
|
|
22
|
+
|
|
23
|
+
// learn-decision.ts
|
|
24
|
+
export const cannotBeListed = (folder: string, reason: string): string => `${folder}/ cannot be listed (${reason})`;
|
|
25
|
+
export const axisDone = (axis: string, count: number): string => `axis ${axis} done: ${count} gaps marked treated`;
|
|
26
|
+
export const learnStateUnreadable = (file: string, reason: string): string =>
|
|
27
|
+
`dev-learn: ${file} cannot be read (${reason}): fix or delete it; nothing was written`;
|
|
28
|
+
export const learnStateInvalid = (problem: string): string => `dev-learn: ${problem}: fix or delete it; nothing was written`;
|
|
29
|
+
export const learnBlockedNotWritten = (file: string, reason: string): string => `dev-learn: BLOCKED — ${file} cannot be written (${reason})`;
|
|
30
|
+
export const noProposalInNewestFolders = (id: string, folder: string): string => `dev-learn: no proposal ${id} in the 10 newest ${folder}/learn-*/ folders`;
|
|
31
|
+
export const learnStateLine = (file: string, treated: number): string => `state: ${file} — ${treated} gaps treated in all`;
|
|
32
|
+
export const alreadyDecided = (id: string, decision: string, date: string): string => `${id} was already ${decision} on ${date}`;
|
|
33
|
+
export const refusedUnreadable = (file: string, reason: string): string => `dev-learn: ${file} cannot be read (${reason}): nothing was written`;
|
|
34
|
+
export const alreadyRefused = (topic: string, date: string): string => `${topic} was already refused on ${date}`;
|
|
35
|
+
export const refusedLeftOut = (topic: string, file: string): string => `refused: ${topic} — left out of future proposals (${file})`;
|
|
36
|
+
export const refuseByWords = (notFound: string): string => `${notFound} (to refuse a motif by its words, write more than an id)`;
|
|
37
|
+
export const learnOutsideMounts = (folder: string): string =>
|
|
38
|
+
`dev-learn: the work folder ${folder} is in the main worktree, outside the mounts: run /dev-learn from the main checkout`;
|
|
39
|
+
export const learnNoWorkFolder = (folder: string): string => `dev-learn: no work folder ${folder}/: nothing to learn from`;
|
|
40
|
+
|
|
41
|
+
// load-dev-context.ts
|
|
42
|
+
export const workDirUnreadable = (key: string, reason: string): string =>
|
|
43
|
+
`${key} could not be read (${reason}): the pack or the default decides`;
|
|
44
|
+
export const notIgnoredByGit = (path: string): string => `${path} is not ignored by git: add it to .gitignore (Orkeon Code never edits it)`;
|
|
45
|
+
export const TODO_HOLDS_HARNESS_WORK =
|
|
46
|
+
"todo/ holds harness artefacts and nothing names workbench/: set layout.work: workbench in the pack, " +
|
|
47
|
+
"or HARNESS_WORK_DIR=workbench in .claude/settings.local.json env (W-01)";
|
|
48
|
+
export const severalPlans = (shown: string, names: string, chosen: string): string => `several plans in ${shown}/: ${names}: ${chosen} is read`;
|
|
49
|
+
|
|
50
|
+
// plan-source.ts
|
|
51
|
+
export const bothSpecAndChange = (shown: string, code: string): string =>
|
|
52
|
+
`dev-plan: ${shown}/ holds both SPEC-${code}.md and CHANGE-${code}.md: name the file`;
|
|
53
|
+
export const neitherSpecNorChange = (shown: string, code: string): string => `dev-plan: ${shown}/ holds no SPEC-${code}.md nor CHANGE-${code}.md`;
|
|
54
|
+
export const notASource = (token: string): string => `dev-plan: '${token}' is neither a code nor a SPEC-<code>.md / CHANGE-<code>.md path`;
|
|
55
|
+
export const SOURCE_UNDER_CLAUDE = "dev-plan: a source under .claude/ is the harness's own: copy it to the work folder first";
|
|
56
|
+
export const planOutsideWorkspace = (folder: string, workspace: string): string =>
|
|
57
|
+
`dev-plan: the work folder ${folder} is outside ${workspace}: run /dev-plan from the main worktree`;
|
|
58
|
+
export const noSourceToPlan = (folder: string): string =>
|
|
59
|
+
`dev-plan: no SPEC- or CHANGE- file without a plan in ${folder}/: name one, e.g. /dev-plan <code>`;
|
|
60
|
+
export const severalCodes = (codes: string, first: string): string =>
|
|
61
|
+
`dev-plan: several codes could be planned (${codes}): name one, e.g. /dev-plan ${first}`;
|
|
62
|
+
export const planSourceUnreadable = (path: string, reason: string): string => `dev-plan: ${path} cannot be read (${reason})`;
|
|
63
|
+
|
|
64
|
+
// preflight.ts
|
|
65
|
+
export const PLAN_NONE = "plan: none in the code's folder: /dev-plan first";
|
|
66
|
+
export const noSheetFor = (batches: string): string => `sheets: no sheet for ${batches}`;
|
|
67
|
+
export const SHEETS_OK = "preflight ✓ sheets: one for every batch not done";
|
|
68
|
+
export const identityMissing = (detail: string): string =>
|
|
69
|
+
`git identity: ${detail} (each batch's close commits): git config user.name and user.email in the repository ` +
|
|
70
|
+
"(a confined shell reads no --global file)";
|
|
71
|
+
export const identityOk = (name: string, email: string): string => `preflight ✓ git identity: ${name} <${email}>`;
|
|
72
|
+
export const BRANCH_NONE = "branch: none checked out (a detached HEAD?): check out the work branch";
|
|
73
|
+
export const changesOutsideWorkFolder = (count: number, paths: string): string =>
|
|
74
|
+
`preflight ⚠ tree: ${count} change(s) outside the work folder (${paths}): a close commits only its batch's files`;
|
|
75
|
+
|
|
76
|
+
// question-round.ts, settle-questions.ts
|
|
77
|
+
export const REWRITE_REFUSED = "the rewrite was refused";
|
|
78
|
+
export const decisionsNotFolded = (problem: string): string =>
|
|
79
|
+
`the body does not say the decisions yet (${problem}); ` +
|
|
80
|
+
"they are recorded under Decisions";
|
|
81
|
+
export const EMPTY_ANSWER_LEAVES_OPEN = "\n(an empty answer leaves the questions in the file)";
|
|
82
|
+
|
|
83
|
+
// resolve-work-folder.ts
|
|
84
|
+
export const notARelativeFolderFallback = (source: string, value: string, reason: string, fallback: string): string =>
|
|
85
|
+
`${source} '${value}' is not a relative folder of the checkout (${reason}): ${fallback}/ applies`;
|
|
86
|
+
export const absentFromCheckout = (source: string, value: string, fallback: string): string =>
|
|
87
|
+
`${source} '${value}' is absent from the checkout: ${fallback}/ applies`;
|
|
88
|
+
export const linkedWorktreeNote = (folder: string): string =>
|
|
89
|
+
`this checkout is a linked worktree: the work folder is the main worktree's ${folder}`;
|
|
90
|
+
|
|
91
|
+
// source-review.ts
|
|
92
|
+
export const reviewNotRun = (reason: string): string => `review: not run (${reason})`;
|
|
93
|
+
export const addedAsOpenQuestions = (count: number): string => `, ${count} added as open questions`;
|
|
94
|
+
export const reviewCounts = (verdict: string, blocking: number, major: number, kept: string): string =>
|
|
95
|
+
`review: ${verdict} — ${blocking} Blocking, ${major} Major${kept}`;
|
|
96
|
+
|
|
97
|
+
// source-step.ts
|
|
98
|
+
export const invalidCode = (step: string): string => `${step}: invalid crew input: code`;
|
|
99
|
+
export const invalidInput = (step: string, name: string): string => `${step}: invalid crew input: ${name}`;
|
|
100
|
+
export const NO_WORK_TREE = "no work tree";
|
|
101
|
+
export const runFromCheckout = (step: string, workspace: string, top: string): string =>
|
|
102
|
+
`${step}: run from the checkout at ${workspace} (git reports ${top})`;
|
|
103
|
+
export const workFolderOutsideCheckoutMounts = (step: string, folder: string): string =>
|
|
104
|
+
`${step}: the work folder ${folder} is outside the checkout's mounts: run from the main worktree`;
|
|
105
|
+
export const outsideCheckout = (step: string, request: string, workspace: string): string =>
|
|
106
|
+
`${step}: ${request} is outside the checkout: give a path under ${workspace}`;
|
|
107
|
+
export const titleDoesNotReadCode = (code: string): string => `the title does not read the code ${code}`;
|
|
108
|
+
export const idsReadBack = (read: string, expected: string): string => `the ids read back are ${read}, not ${expected}`;
|
|
109
|
+
export const openQuestionsReadBack = (read: number, written: number): string => `${read} open questions read back, ${written} written`;
|
|
110
|
+
export const DECISIONS_DO_NOT_READ_BACK = "the decisions do not read back";
|
|
111
|
+
|
|
112
|
+
// step-precedents.ts, tool-call-policy.ts, tool-callbacks.ts
|
|
113
|
+
export const namedRecallFailed = (trigger: string, reason: string): string => `shared memory: recall ${trigger} failed, no precedents (${reason})`;
|
|
114
|
+
export const relativePathResolved = (step: string, tool: string): string => `${step}: ${tool}: a relative path resolved under the checkout`;
|
|
115
|
+
export const mountCheckRefusedPreHook = (step: string, n: number, tool: string): string =>
|
|
116
|
+
`${step}: the runtime's mount check refused pre-tool hook #${n} for ${tool}`;
|
|
117
|
+
export const preHookRefused = (step: string, n: number, tool: string): string => `${step}: pre-tool hook #${n} refused ${tool}`;
|
|
118
|
+
export const postHooksFailed = (step: string, count: number, tool: string): string =>
|
|
119
|
+
`${step}: ${count} post-tool hook(s) failed after ${tool}`;
|
|
120
|
+
|
|
121
|
+
// verdict-sources.ts
|
|
122
|
+
export const folderListsTooMany = (folder: string, cap: number): string =>
|
|
123
|
+
`${folder}/ lists ${cap} entries or more: later files are not read`;
|
|
124
|
+
export const workListsTooMany = (folder: string, cap: number): string =>
|
|
125
|
+
`${folder}/ lists ${cap} entries or more: later folders are not read`;
|
|
126
|
+
|
|
127
|
+
// wrapped-tools.ts
|
|
128
|
+
export const restoreNotRun = (reason: string): string => `restore not run: ${reason}`;
|
|
129
|
+
|
|
130
|
+
// Shared by the dev crews
|
|
131
|
+
export const neitherCodeNorPlan = (plan: string): string => `'${plan}' is neither a code nor a <CODE>-PLAN.md path`;
|
|
132
|
+
export const PERMISSION_GATE_OFF = "the host's permission gate is off; the reviewer was offered read tools only";
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// The clock of a dev step's phases: each awaited step is timed with the Clock port and its time recorded under its
|
|
2
|
+
// phase (shared/domain/dev/phase-timing.ts), a step that throws included, its error rethrown. A step timed inside
|
|
3
|
+
// another counts for its own phase alone: the outer phase keeps the time its inner steps did not take. The line ends
|
|
4
|
+
// with `other`, what the run spent outside every phase.
|
|
5
|
+
import type { Clock, Llm } from "../ports.ts";
|
|
6
|
+
import { NO_TIMING, recordPhase, startPhase, timingLine, timingTotalMs } from "../../domain/dev/phase-timing.ts";
|
|
7
|
+
import type { PhaseTiming, RunUnit } from "../../domain/dev/phase-timing.ts";
|
|
8
|
+
|
|
9
|
+
/** The phase of what no step was timed under (the recall of precedents, the reads of the context). */
|
|
10
|
+
export const OTHER_PHASE = "other";
|
|
11
|
+
|
|
12
|
+
export class PhaseTimer {
|
|
13
|
+
private readonly clock: Clock;
|
|
14
|
+
private recorded: PhaseTiming = NO_TIMING;
|
|
15
|
+
|
|
16
|
+
private readonly started: number;
|
|
17
|
+
|
|
18
|
+
constructor(clock: Clock) {
|
|
19
|
+
this.clock = clock;
|
|
20
|
+
this.started = clock().getTime();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
get timing(): PhaseTiming {
|
|
24
|
+
return this.recorded;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** The summary's timing line ("" when no time was spent): the phases, then `other`, the time since the timer was
|
|
28
|
+
* made that no phase took, so that the total is the run's own. */
|
|
29
|
+
line(): string {
|
|
30
|
+
const other = this.clock().getTime() - this.started - timingTotalMs(this.recorded);
|
|
31
|
+
if (other <= 0) return timingLine(this.recorded);
|
|
32
|
+
return timingLine(recordPhase(startPhase(this.recorded, OTHER_PHASE, "attempt"), OTHER_PHASE, other, "attempt"));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async time<T>(phase: string, step: () => Promise<T>, unit: RunUnit = "attempt"): Promise<T> {
|
|
36
|
+
this.recorded = startPhase(this.recorded, phase, unit);
|
|
37
|
+
const inner = timingTotalMs(this.recorded);
|
|
38
|
+
const start = this.clock().getTime();
|
|
39
|
+
try {
|
|
40
|
+
return await step();
|
|
41
|
+
} finally {
|
|
42
|
+
const elapsed = this.clock().getTime() - start;
|
|
43
|
+
this.recorded = recordPhase(this.recorded, phase, elapsed - (timingTotalMs(this.recorded) - inner), unit);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** `llm` with each extraction timed under `phase`: its act is left as it is. */
|
|
48
|
+
timedExtract(llm: Pick<Llm, "act" | "extract">, phase: string): Pick<Llm, "act" | "extract"> {
|
|
49
|
+
return {
|
|
50
|
+
act: (prompt, request) => llm.act(prompt, request),
|
|
51
|
+
extract: (prompt, schema) => this.time(phase, () => llm.extract(prompt, schema)),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
// Which spec or change brief a /dev-plan run plans, and its text: the token the user typed
|
|
2
|
+
// (a work code, a path, or nothing) resolved against the work folder, then the file read
|
|
3
|
+
// and parsed. It reads listings and one file; it writes nothing. Every refusal is a text
|
|
4
|
+
// the command and the crew print as they are.
|
|
5
|
+
import type { Files } from "../ports.ts";
|
|
6
|
+
import type { WorkFolder } from "./resolve-work-folder.ts";
|
|
7
|
+
import { listDevCodes } from "./load-dev-context.ts";
|
|
8
|
+
import { classifyArtefact, isCode } from "../../domain/dev/artefacts.ts";
|
|
9
|
+
import { parsePlanSource } from "../../domain/dev/spec-format.ts";
|
|
10
|
+
import type { PlanSource, SourceKind } from "../../domain/dev/spec-format.ts";
|
|
11
|
+
import { WORKSPACE } from "../../domain/vfs.ts";
|
|
12
|
+
import {
|
|
13
|
+
SOURCE_UNDER_CLAUDE, bothSpecAndChange, neitherSpecNorChange, noSourceToPlan, notASource, planOutsideWorkspace, planSourceUnreadable,
|
|
14
|
+
severalCodes,
|
|
15
|
+
} from "./messages.ts";
|
|
16
|
+
|
|
17
|
+
export interface ResolvedSource {
|
|
18
|
+
kind: SourceKind;
|
|
19
|
+
code: string; // "prune"
|
|
20
|
+
prefix: string; // code.toUpperCase(): the <CODE> of the file names, "PRUNE"
|
|
21
|
+
folderShown: string; // "workbench/prune"
|
|
22
|
+
sourceShown: string; // "workbench/prune/SPEC-prune.md"
|
|
23
|
+
}
|
|
24
|
+
export const MAX_SOURCE_CHARS = 200_000;
|
|
25
|
+
|
|
26
|
+
type Resolution = { ok: true; source: ResolvedSource } | { ok: false; text: string };
|
|
27
|
+
|
|
28
|
+
const LIST_CAP = 500;
|
|
29
|
+
const firstLine = (e: unknown): string => (e instanceof Error ? e.message : String(e)).split("\n")[0];
|
|
30
|
+
const refuse = (text: string): Resolution => ({ ok: false, text });
|
|
31
|
+
|
|
32
|
+
function resolved(kind: SourceKind, code: string, folderShown: string, fileName: string): Resolution {
|
|
33
|
+
const sourceShown = folderShown === "" ? fileName : `${folderShown}/${fileName}`;
|
|
34
|
+
return { ok: true, source: { kind, code, prefix: code.toUpperCase(), folderShown, sourceShown } };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** The spec or the brief of one code folder, found by listing it. */
|
|
38
|
+
async function byCode(files: Pick<Files, "list">, work: WorkFolder, vfsPath: string, code: string): Promise<Resolution> {
|
|
39
|
+
let names: string[];
|
|
40
|
+
try {
|
|
41
|
+
names = await files.list(`${vfsPath}/${code}`, LIST_CAP);
|
|
42
|
+
} catch {
|
|
43
|
+
names = [];
|
|
44
|
+
}
|
|
45
|
+
const spec = names.includes(`SPEC-${code}.md`);
|
|
46
|
+
const change = names.includes(`CHANGE-${code}.md`);
|
|
47
|
+
const shown = `${work.folder}/${code}`;
|
|
48
|
+
if (spec && change) return refuse(bothSpecAndChange(shown, code));
|
|
49
|
+
if (!spec && !change) return refuse(neitherSpecNorChange(shown, code));
|
|
50
|
+
return resolved(spec ? "spec" : "change", code, shown, spec ? `SPEC-${code}.md` : `CHANGE-${code}.md`);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** A path relative to the checkout, or under /workspace/, naming a spec or a brief. */
|
|
54
|
+
function byPath(token: string): Resolution {
|
|
55
|
+
const notSource = refuse(notASource(token));
|
|
56
|
+
let relative = token.replace(/^\.\//, "");
|
|
57
|
+
if (relative.startsWith("/")) {
|
|
58
|
+
if (!relative.startsWith(`${WORKSPACE}/`)) return notSource;
|
|
59
|
+
relative = relative.slice(WORKSPACE.length + 1);
|
|
60
|
+
}
|
|
61
|
+
// `/workspace/./.claude/x` and `/workspace//.claude/x` name `.claude/x`: the `.` and empty segments go first.
|
|
62
|
+
const segments = relative.split("/").filter((s) => s !== "" && s !== ".");
|
|
63
|
+
if (segments.some((s) => s === "..")) return notSource;
|
|
64
|
+
const fileName = segments.at(-1) ?? "";
|
|
65
|
+
const artefact = classifyArtefact(fileName);
|
|
66
|
+
if (artefact === null || (artefact.kind !== "spec" && artefact.kind !== "change") || !isCode(artefact.prefix)) return notSource;
|
|
67
|
+
if (segments[0] === ".claude") {
|
|
68
|
+
return refuse(SOURCE_UNDER_CLAUDE);
|
|
69
|
+
}
|
|
70
|
+
return resolved(artefact.kind, artefact.prefix, segments.slice(0, -1).join("/"), fileName);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const looksLikePath = (token: string): boolean => {
|
|
74
|
+
const kind = classifyArtefact(token.slice(token.lastIndexOf("/") + 1))?.kind;
|
|
75
|
+
return token.includes("/") || kind === "spec" || kind === "change";
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/** The source the token names (a code, a path, or nothing); the refusal text otherwise. */
|
|
79
|
+
export async function resolvePlanSource(
|
|
80
|
+
files: Pick<Files, "list" | "read">, work: WorkFolder, token: string | null,
|
|
81
|
+
): Promise<{ ok: true; source: ResolvedSource } | { ok: false; text: string }> {
|
|
82
|
+
if (work.vfsPath === null) {
|
|
83
|
+
return refuse(planOutsideWorkspace(work.folder, WORKSPACE));
|
|
84
|
+
}
|
|
85
|
+
if (token !== null && looksLikePath(token)) return byPath(token);
|
|
86
|
+
if (token !== null) {
|
|
87
|
+
if (!isCode(token)) return byPath(token);
|
|
88
|
+
return byCode(files, work, work.vfsPath, token);
|
|
89
|
+
}
|
|
90
|
+
let codes: string[];
|
|
91
|
+
try {
|
|
92
|
+
codes = (await listDevCodes({ files }, work)).filter((c) => (c.spec || c.change) && !c.plan).map((c) => c.code);
|
|
93
|
+
} catch {
|
|
94
|
+
codes = [];
|
|
95
|
+
}
|
|
96
|
+
if (codes.length === 0) {
|
|
97
|
+
return refuse(noSourceToPlan(work.folder));
|
|
98
|
+
}
|
|
99
|
+
if (codes.length > 1) {
|
|
100
|
+
return refuse(severalCodes(codes.join(", "), codes[0]));
|
|
101
|
+
}
|
|
102
|
+
return byCode(files, work, work.vfsPath, codes[0]);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Reads the source (≤ MAX_SOURCE_CHARS) and parses it; the refusal text when it cannot be read. */
|
|
106
|
+
export async function readPlanSource(
|
|
107
|
+
files: Pick<Files, "read">, source: ResolvedSource,
|
|
108
|
+
): Promise<{ ok: true; text: string; parsed: PlanSource } | { ok: false; text: string }> {
|
|
109
|
+
let text: string;
|
|
110
|
+
try {
|
|
111
|
+
text = await files.read(`${WORKSPACE}/${source.sourceShown}`, MAX_SOURCE_CHARS);
|
|
112
|
+
} catch (e) {
|
|
113
|
+
return { ok: false, text: planSourceUnreadable(source.sourceShown, firstLine(e)) };
|
|
114
|
+
}
|
|
115
|
+
return { ok: true, text, parsed: parsePlanSource(text, source.kind) };
|
|
116
|
+
}
|