orkeon-code 0.0.0-stage → 1.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.orkeon-version +1 -0
- package/LICENSE.md +21 -0
- package/NOTICE.md +17 -0
- package/README.fr.md +169 -0
- package/README.md +162 -2
- package/config/appsettings.anthropic.example.json +77 -0
- package/config/appsettings.example.json +71 -0
- package/config/appsettings.jev.example.json +128 -0
- package/config/appsettings.kev.example.json +130 -0
- package/config/appsettings.liquid.example.json +129 -0
- package/config/appsettings.ollama-whisper.example.json +92 -0
- package/config/appsettings.ollama.example.json +70 -0
- package/config/appsettings.whisper.example.json +31 -0
- package/mcp/whisper/README.md +293 -0
- package/mcp/whisper/pyproject.toml +32 -0
- package/mcp/whisper/uv.lock +1641 -0
- package/mcp/whisper/whisper_mcp.py +1053 -0
- package/orkeon-code +897 -0
- package/orkeon-code.mjs +71 -0
- package/orkeon-code.ps1 +837 -0
- package/package.json +57 -4
- package/scripts/install.ps1 +156 -0
- package/scripts/install.sh +148 -0
- package/scripts/session-start.ork.ts +90 -0
- package/scripts/session-start.sh +74 -0
- package/scripts/setup-fixture.sh +88 -0
- package/src/commands/.orkeon/orkeon-cli.d.ts +562 -0
- package/src/commands/_lib/args.ts +193 -0
- package/src/commands/_lib/dev/dev-batches.ts +368 -0
- package/src/commands/_lib/dev/dev-implement.ts +188 -0
- package/src/commands/_lib/dev/dev-source.ts +65 -0
- package/src/commands/_lib/dev/dev.ts +344 -0
- package/src/commands/_lib/dev-step.ts +142 -0
- package/src/commands/_lib/dispatch.ts +231 -0
- package/src/commands/_lib/effort.ts +15 -0
- package/src/commands/_lib/git/branch.ts +95 -0
- package/src/commands/_lib/git/commit.ts +94 -0
- package/src/commands/_lib/git/diff.ts +97 -0
- package/src/commands/_lib/git/review.ts +109 -0
- package/src/commands/_lib/memory/memory-admit.ts +150 -0
- package/src/commands/_lib/memory/memory.ts +51 -0
- package/src/commands/_lib/pr-context.ts +32 -0
- package/src/commands/_lib/project/analyze.ts +24 -0
- package/src/commands/_lib/session/export.ts +104 -0
- package/src/commands/_lib/session/resume.ts +160 -0
- package/src/commands/_lib/session/tasks.ts +184 -0
- package/src/commands/_lib/settings/advisor.ts +80 -0
- package/src/commands/_lib/settings/agents.ts +147 -0
- package/src/commands/_lib/settings/config.ts +141 -0
- package/src/commands/_lib/settings/hooks.ts +58 -0
- package/src/commands/_lib/settings/mode.ts +91 -0
- package/src/commands/_lib/settings/model.ts +146 -0
- package/src/commands/_lib/settings/permissions.ts +309 -0
- package/src/commands/_lib/settings/session-config.ts +49 -0
- package/src/commands/_lib/settings/skills.ts +51 -0
- package/src/commands/_lib/speech/say.ts +96 -0
- package/src/commands/_lib/speech/transcribe.ts +130 -0
- package/src/commands/_lib/speech/voice.ts +146 -0
- package/src/commands/_lib/status/cache.ts +31 -0
- package/src/commands/_lib/status/context.ts +57 -0
- package/src/commands/_lib/status/doctor.ts +186 -0
- package/src/commands/_lib/status/meta.ts +45 -0
- package/src/commands/_lib/status/status.ts +129 -0
- package/src/commands/_lib/status/usage-tools.ts +49 -0
- package/src/commands/_lib/status/usage.ts +139 -0
- package/src/commands/_lib/view.ts +29 -0
- package/src/commands/dev/dev-batches.cmd.ts +108 -0
- package/src/commands/dev/dev-learn.cmd.ts +29 -0
- package/src/commands/dev/dev-plan.cmd.ts +52 -0
- package/src/commands/dev/dev-spec.cmd.ts +55 -0
- package/src/commands/dev/dev-status.cmd.ts +16 -0
- package/src/commands/git/branch.cmd.ts +27 -0
- package/src/commands/git/commit.cmd.ts +48 -0
- package/src/commands/git/diff.cmd.ts +26 -0
- package/src/commands/git/review.cmd.ts +36 -0
- package/src/commands/memory/memory.cmd.ts +48 -0
- package/src/commands/project/analyze.cmd.ts +32 -0
- package/src/commands/project/debug-tool-call.cmd.ts +67 -0
- package/src/commands/project/files.cmd.ts +22 -0
- package/src/commands/project/init-verifiers.cmd.ts +14 -0
- package/src/commands/project/init.cmd.ts +14 -0
- package/src/commands/project/verify.cmd.ts +27 -0
- package/src/commands/session/assistant.cmd.ts +40 -0
- package/src/commands/session/btw.cmd.ts +18 -0
- package/src/commands/session/clear.cmd.ts +19 -0
- package/src/commands/session/compact.cmd.ts +16 -0
- package/src/commands/session/copy.cmd.ts +44 -0
- package/src/commands/session/exit.cmd.ts +9 -0
- package/src/commands/session/export.cmd.ts +28 -0
- package/src/commands/session/rename.cmd.ts +17 -0
- package/src/commands/session/resume.cmd.ts +19 -0
- package/src/commands/session/rewind.cmd.ts +26 -0
- package/src/commands/session/summary.cmd.ts +27 -0
- package/src/commands/session/tasks.cmd.ts +44 -0
- package/src/commands/settings/advisor.cmd.ts +38 -0
- package/src/commands/settings/agents.cmd.ts +19 -0
- package/src/commands/settings/config.cmd.ts +17 -0
- package/src/commands/settings/effort.cmd.ts +40 -0
- package/src/commands/settings/fast.cmd.ts +17 -0
- package/src/commands/settings/hooks.cmd.ts +17 -0
- package/src/commands/settings/mode.cmd.ts +20 -0
- package/src/commands/settings/model.cmd.ts +20 -0
- package/src/commands/settings/output-style.cmd.ts +48 -0
- package/src/commands/settings/permissions.cmd.ts +25 -0
- package/src/commands/settings/proactive.cmd.ts +15 -0
- package/src/commands/settings/skills.cmd.ts +17 -0
- package/src/commands/speech/say.cmd.ts +24 -0
- package/src/commands/speech/transcribe.cmd.ts +29 -0
- package/src/commands/speech/voice.cmd.ts +30 -0
- package/src/commands/status/context.cmd.ts +18 -0
- package/src/commands/status/doctor.cmd.ts +27 -0
- package/src/commands/status/release-notes.cmd.ts +9 -0
- package/src/commands/status/status.cmd.ts +25 -0
- package/src/commands/status/usage.cmd.ts +21 -0
- package/src/crews/.orkeon/orkeon.d.ts +3946 -0
- package/src/crews/_probe-shared-memory/domain/probe-verdict.ts +183 -0
- package/src/crews/_probe-shared-memory/probe.ork.ts +98 -0
- package/src/crews/advisor/application/run-advisor.ts +40 -0
- package/src/crews/advisor/crew.ork.ts +43 -0
- package/src/crews/advisor/domain/advice.ts +135 -0
- package/src/crews/agent-run/application/run-agent-run.ts +42 -0
- package/src/crews/agent-run/crew.ork.ts +67 -0
- package/src/crews/analyze/application/run-analyze.ts +118 -0
- package/src/crews/analyze/crew.ork.ts +40 -0
- package/src/crews/analyze/domain/harvest.ts +301 -0
- package/src/crews/code-review/application/prompts.ts +133 -0
- package/src/crews/code-review/application/review.ts +71 -0
- package/src/crews/code-review/application/run-code-review.ts +123 -0
- package/src/crews/code-review/crew.ork.ts +51 -0
- package/src/crews/code-review/domain/lenses.ts +193 -0
- package/src/crews/code-review/domain/report.ts +59 -0
- package/src/crews/code-review/domain/scope.ts +112 -0
- package/src/crews/dev-batches/application/plan-close.ts +181 -0
- package/src/crews/dev-batches/application/run-dev-batches.ts +669 -0
- package/src/crews/dev-batches/application/run-wave.ts +450 -0
- package/src/crews/dev-batches/application/seed-harvest.ts +162 -0
- package/src/crews/dev-batches/crew.ork.ts +143 -0
- package/src/crews/dev-batches/domain/batch-waves.ts +70 -0
- package/src/crews/dev-batches/domain/batches-budget.ts +52 -0
- package/src/crews/dev-batches/domain/batches-log.ts +54 -0
- package/src/crews/dev-batches/domain/wave-order.ts +43 -0
- package/src/crews/dev-change/application/change-prompt.ts +104 -0
- package/src/crews/dev-change/application/evidence.ts +169 -0
- package/src/crews/dev-change/application/run-dev-change.ts +315 -0
- package/src/crews/dev-change/crew.ork.ts +112 -0
- package/src/crews/dev-change/domain/change-answer.ts +159 -0
- package/src/crews/dev-change/domain/change-render.ts +79 -0
- package/src/crews/dev-implement/application/close.ts +183 -0
- package/src/crews/dev-implement/application/count-open-steps.ts +24 -0
- package/src/crews/dev-implement/application/locate-sheet.ts +80 -0
- package/src/crews/dev-implement/application/observe.ts +50 -0
- package/src/crews/dev-implement/application/report-writes.ts +41 -0
- package/src/crews/dev-implement/application/run-dev-implement.ts +811 -0
- package/src/crews/dev-implement/application/run-role.ts +27 -0
- package/src/crews/dev-implement/application/suite-job.ts +118 -0
- package/src/crews/dev-implement/application/touched.ts +74 -0
- package/src/crews/dev-implement/crew.ork.ts +68 -0
- package/src/crews/dev-implement/domain/contracts.ts +256 -0
- package/src/crews/dev-implement/domain/correction.ts +102 -0
- package/src/crews/dev-implement/domain/cycles.ts +35 -0
- package/src/crews/dev-implement/domain/implement-budget.ts +29 -0
- package/src/crews/dev-implement/domain/roles.ts +53 -0
- package/src/crews/dev-implement/domain/sheet-edits.ts +75 -0
- package/src/crews/dev-implement/domain/sheet-ticks.ts +22 -0
- package/src/crews/dev-implement/domain/step-checks.ts +136 -0
- package/src/crews/dev-implement/domain/step-section.ts +127 -0
- package/src/crews/dev-learn/application/learn-backlog.ts +58 -0
- package/src/crews/dev-learn/application/learn-prompt.ts +140 -0
- package/src/crews/dev-learn/application/run-dev-learn.ts +553 -0
- package/src/crews/dev-learn/crew.ork.ts +52 -0
- package/src/crews/dev-learn/domain/learn-answer.ts +235 -0
- package/src/crews/dev-learn/domain/owner-lines.ts +86 -0
- package/src/crews/dev-learn/domain/proposals-render.ts +96 -0
- package/src/crews/dev-plan/application/anchor-paths.ts +76 -0
- package/src/crews/dev-plan/application/inventory.ts +170 -0
- package/src/crews/dev-plan/application/plan-prompt.ts +159 -0
- package/src/crews/dev-plan/application/run-dev-plan.ts +455 -0
- package/src/crews/dev-plan/crew.ork.ts +109 -0
- package/src/crews/dev-plan/domain/inventory-model.ts +95 -0
- package/src/crews/dev-plan/domain/plan-answer.ts +738 -0
- package/src/crews/dev-plan/domain/plan-render.ts +307 -0
- package/src/crews/dev-spec/application/run-dev-spec.ts +206 -0
- package/src/crews/dev-spec/application/spec-prompt.ts +98 -0
- package/src/crews/dev-spec/crew.ork.ts +108 -0
- package/src/crews/dev-spec/domain/spec-answer.ts +253 -0
- package/src/crews/dev-spec/domain/spec-render.ts +76 -0
- package/src/crews/dev-verify/application/audit.ts +259 -0
- package/src/crews/dev-verify/application/auditor-prompt.ts +323 -0
- package/src/crews/dev-verify/application/capture.ts +303 -0
- package/src/crews/dev-verify/application/run-dev-verify.ts +409 -0
- package/src/crews/dev-verify/application/run-gate.ts +202 -0
- package/src/crews/dev-verify/crew.ork.ts +103 -0
- package/src/crews/dev-verify/domain/audit-answer.ts +150 -0
- package/src/crews/dev-verify/domain/auditor-charter.ts +21 -0
- package/src/crews/dev-verify/domain/capture-sections.ts +137 -0
- package/src/crews/dev-verify/domain/commands.ts +103 -0
- package/src/crews/dev-verify/domain/gate.ts +126 -0
- package/src/crews/dev-verify/domain/mechanical-table.ts +163 -0
- package/src/crews/dev-verify/domain/runtime-cut.ts +13 -0
- package/src/crews/dev-verify/domain/sheet-facts.ts +4 -0
- package/src/crews/dev-verify/domain/text.ts +20 -0
- package/src/crews/dev-verify/domain/verdict.ts +127 -0
- package/src/crews/git-commit/application/draft.ts +154 -0
- package/src/crews/git-commit/application/run-git-commit.ts +116 -0
- package/src/crews/git-commit/crew.ork.ts +52 -0
- package/src/crews/git-commit/domain/commit.ts +220 -0
- package/src/crews/init-verifiers/application/authoring.ts +89 -0
- package/src/crews/init-verifiers/application/prompts.ts +103 -0
- package/src/crews/init-verifiers/application/run-init-verifiers.ts +25 -0
- package/src/crews/init-verifiers/crew.ork.ts +34 -0
- package/src/crews/init-verifiers/domain/commands-section.ts +36 -0
- package/src/crews/init-verifiers/domain/readiness.ts +23 -0
- package/src/crews/main-loop/application/auto-compact.ts +77 -0
- package/src/crews/main-loop/application/context-gather.ts +133 -0
- package/src/crews/main-loop/application/run-main-loop.ts +350 -0
- package/src/crews/main-loop/application/turn-prompt.ts +112 -0
- package/src/crews/main-loop/crew.ork.ts +119 -0
- package/src/crews/main-loop/domain/autocompact.ts +27 -0
- package/src/crews/main-loop/domain/prompt-assembly.ts +521 -0
- package/src/crews/main-loop/domain/turn-chains.ts +129 -0
- package/src/crews/project-init/application/detect.ts +122 -0
- package/src/crews/project-init/application/prompts.ts +101 -0
- package/src/crews/project-init/application/run-project-init.ts +31 -0
- package/src/crews/project-init/crew.ork.ts +35 -0
- package/src/crews/project-init/domain/conventions.ts +36 -0
- package/src/crews/project-init/domain/existing-files.ts +63 -0
- package/src/crews/project-init/domain/package-map.ts +73 -0
- package/src/crews/session-compact/crew.ork.ts +55 -0
- package/src/crews/shared-memory-admit/crew.ork.ts +48 -0
- package/src/crews/speech/application/run-speech.ts +25 -0
- package/src/crews/speech/crew.ork.ts +37 -0
- package/src/shared/application/agents/child-agent.ts +255 -0
- package/src/shared/application/agents/run-sub-agent.ts +96 -0
- package/src/shared/application/answer-language.ts +14 -0
- package/src/shared/application/attached-skills.ts +36 -0
- package/src/shared/application/compaction/compact-session.ts +237 -0
- package/src/shared/application/compaction/extract-memories.ts +38 -0
- package/src/shared/application/compaction/restore-context.ts +78 -0
- package/src/shared/application/config-store.ts +123 -0
- package/src/shared/application/dev/brief-inventory.ts +113 -0
- package/src/shared/application/dev/close-batch.ts +83 -0
- package/src/shared/application/dev/find-repo-pack.ts +77 -0
- package/src/shared/application/dev/learn-decision.ts +252 -0
- package/src/shared/application/dev/load-dev-context.ts +266 -0
- package/src/shared/application/dev/measure-access-cost.ts +68 -0
- package/src/shared/application/dev/plan-source.ts +112 -0
- package/src/shared/application/dev/preflight.ts +71 -0
- package/src/shared/application/dev/project-files.ts +17 -0
- package/src/shared/application/dev/question-round.ts +52 -0
- package/src/shared/application/dev/resolve-work-folder.ts +133 -0
- package/src/shared/application/dev/script-tool-slot.ts +27 -0
- package/src/shared/application/dev/settle-questions.ts +55 -0
- package/src/shared/application/dev/source-review.ts +63 -0
- package/src/shared/application/dev/source-step.ts +150 -0
- package/src/shared/application/dev/spend.ts +42 -0
- package/src/shared/application/dev/step-precedents.ts +89 -0
- package/src/shared/application/dev/tool-call-policy.ts +89 -0
- package/src/shared/application/dev/tool-callbacks.ts +215 -0
- package/src/shared/application/dev/tool-trace-recorder.ts +45 -0
- package/src/shared/application/dev/verdict-sources.ts +48 -0
- package/src/shared/application/dev/wrapped-tools.ts +145 -0
- package/src/shared/application/extra-tools.ts +70 -0
- package/src/shared/application/git/batch-worktree.ts +97 -0
- package/src/shared/application/git/commit-files.ts +186 -0
- package/src/shared/application/git/merge-batch.ts +63 -0
- package/src/shared/application/git/open-pull-request.ts +51 -0
- package/src/shared/application/instructions-file.ts +19 -0
- package/src/shared/application/json-file.ts +34 -0
- package/src/shared/application/llm-profile.ts +35 -0
- package/src/shared/application/permission-rules.ts +159 -0
- package/src/shared/application/ports/approvals.ts +20 -0
- package/src/shared/application/ports/clock.ts +5 -0
- package/src/shared/application/ports/code-index.ts +93 -0
- package/src/shared/application/ports/crew.ts +60 -0
- package/src/shared/application/ports/files.ts +21 -0
- package/src/shared/application/ports/human.ts +13 -0
- package/src/shared/application/ports/llm.ts +54 -0
- package/src/shared/application/ports/memory.ts +30 -0
- package/src/shared/application/ports/progress.ts +23 -0
- package/src/shared/application/ports/runtime.ts +15 -0
- package/src/shared/application/ports/session.ts +74 -0
- package/src/shared/application/ports/shared-memory.ts +26 -0
- package/src/shared/application/ports/shell.ts +40 -0
- package/src/shared/application/ports/telemetry.ts +45 -0
- package/src/shared/application/ports/tools.ts +46 -0
- package/src/shared/application/ports/usage.ts +45 -0
- package/src/shared/application/ports.ts +27 -0
- package/src/shared/application/project-manifests.ts +106 -0
- package/src/shared/application/session-io.ts +84 -0
- package/src/shared/application/session-state.ts +36 -0
- package/src/shared/application/shared-memory/admit-entries.ts +177 -0
- package/src/shared/application/shared-memory/harvest-after-gaps.ts +72 -0
- package/src/shared/application/shared-memory/harvest-mistakes.ts +44 -0
- package/src/shared/application/shared-memory/import-agent-memory.ts +117 -0
- package/src/shared/application/shared-memory/memory-files.ts +110 -0
- package/src/shared/application/shared-memory/memory-settings.ts +93 -0
- package/src/shared/application/shared-memory/push-candidate.ts +146 -0
- package/src/shared/application/shared-memory/recall-precedents.ts +69 -0
- package/src/shared/application/state-snapshot.ts +38 -0
- package/src/shared/application/workflow/workflow-state.ts +135 -0
- package/src/shared/domain/agent-policy/behavior-flags.ts +168 -0
- package/src/shared/domain/agent-policy/extra-tools.ts +69 -0
- package/src/shared/domain/agent-policy/memory-categories.ts +6 -0
- package/src/shared/domain/agent-policy/mode-policy.ts +51 -0
- package/src/shared/domain/agent-policy/output-styles.ts +11 -0
- package/src/shared/domain/agent-policy/permission.ts +623 -0
- package/src/shared/domain/agent-policy/rule-sets.ts +412 -0
- package/src/shared/domain/agent-policy/tool-access.ts +77 -0
- package/src/shared/domain/agent-registry.ts +142 -0
- package/src/shared/domain/agents/built-in-charters.ts +43 -0
- package/src/shared/domain/agents/chain.ts +30 -0
- package/src/shared/domain/agents/charter.ts +61 -0
- package/src/shared/domain/agents/exclusive.ts +24 -0
- package/src/shared/domain/agents/instances.ts +249 -0
- package/src/shared/domain/code-intel-contract.ts +356 -0
- package/src/shared/domain/code-intel-routing.ts +113 -0
- package/src/shared/domain/compact-outcome.ts +44 -0
- package/src/shared/domain/compaction-thresholds.ts +161 -0
- package/src/shared/domain/compaction.ts +379 -0
- package/src/shared/domain/config-schema.ts +421 -0
- package/src/shared/domain/dev/access-cost.ts +226 -0
- package/src/shared/domain/dev/artefacts.ts +50 -0
- package/src/shared/domain/dev/batches-concurrency.ts +36 -0
- package/src/shared/domain/dev/batches-state.ts +49 -0
- package/src/shared/domain/dev/build-commands.ts +44 -0
- package/src/shared/domain/dev/call-guard.ts +341 -0
- package/src/shared/domain/dev/carried-text.ts +49 -0
- package/src/shared/domain/dev/design-rules.ts +100 -0
- package/src/shared/domain/dev/learn-proposals.ts +175 -0
- package/src/shared/domain/dev/learn-state.ts +93 -0
- package/src/shared/domain/dev/path-args.ts +42 -0
- package/src/shared/domain/dev/path-rebase.ts +93 -0
- package/src/shared/domain/dev/plan-checks.ts +190 -0
- package/src/shared/domain/dev/plan-format.ts +180 -0
- package/src/shared/domain/dev/project-files.ts +43 -0
- package/src/shared/domain/dev/questions.ts +249 -0
- package/src/shared/domain/dev/reading-rule.ts +41 -0
- package/src/shared/domain/dev/repo-pack.ts +237 -0
- package/src/shared/domain/dev/review-answer.ts +150 -0
- package/src/shared/domain/dev/review-prompt.ts +221 -0
- package/src/shared/domain/dev/reviewer-charter.ts +31 -0
- package/src/shared/domain/dev/sheet-facts.ts +83 -0
- package/src/shared/domain/dev/spec-format.ts +183 -0
- package/src/shared/domain/dev/step-budget.ts +72 -0
- package/src/shared/domain/dev/step-rules.ts +110 -0
- package/src/shared/domain/dev/test-commands.ts +90 -0
- package/src/shared/domain/dev/test-output.ts +33 -0
- package/src/shared/domain/dev/test-paths.ts +40 -0
- package/src/shared/domain/dev/tool-guards.ts +64 -0
- package/src/shared/domain/dev/trait-pattern.ts +83 -0
- package/src/shared/domain/dev/verdict-format.ts +169 -0
- package/src/shared/domain/dev/whitespace.ts +34 -0
- package/src/shared/domain/dev/work-folder.ts +67 -0
- package/src/shared/domain/dev/yaml-subset.ts +403 -0
- package/src/shared/domain/git/close.ts +273 -0
- package/src/shared/domain/git/pull-request.ts +96 -0
- package/src/shared/domain/git/worktree.ts +46 -0
- package/src/shared/domain/index-languages.ts +16 -0
- package/src/shared/domain/instructions-file.ts +18 -0
- package/src/shared/domain/iso-day.ts +4 -0
- package/src/shared/domain/llm-failure.ts +106 -0
- package/src/shared/domain/llm-profile.ts +25 -0
- package/src/shared/domain/marked-message.ts +33 -0
- package/src/shared/domain/model-catalog.ts +86 -0
- package/src/shared/domain/permission-modes.ts +103 -0
- package/src/shared/domain/prelude.ts +92 -0
- package/src/shared/domain/project-manifests.ts +83 -0
- package/src/shared/domain/search-routing.ts +85 -0
- package/src/shared/domain/secret-patterns.ts +45 -0
- package/src/shared/domain/session-keys.ts +85 -0
- package/src/shared/domain/session-start.ts +60 -0
- package/src/shared/domain/session-summary.ts +13 -0
- package/src/shared/domain/severity.ts +72 -0
- package/src/shared/domain/sha1.ts +61 -0
- package/src/shared/domain/shared-memory/agent-memory-import.ts +143 -0
- package/src/shared/domain/shared-memory/candidates.ts +41 -0
- package/src/shared/domain/shared-memory/entry.ts +145 -0
- package/src/shared/domain/shared-memory/front-matter.ts +183 -0
- package/src/shared/domain/shared-memory/gate.ts +44 -0
- package/src/shared/domain/shared-memory/harvest.ts +61 -0
- package/src/shared/domain/shared-memory/layout.ts +187 -0
- package/src/shared/domain/shared-memory/precedents-block.ts +93 -0
- package/src/shared/domain/shared-memory/refused.ts +84 -0
- package/src/shared/domain/shared-memory/verdict-rows.ts +134 -0
- package/src/shared/domain/snip-turns.ts +45 -0
- package/src/shared/domain/speech.ts +20 -0
- package/src/shared/domain/strip.ts +88 -0
- package/src/shared/domain/tool-trace.ts +122 -0
- package/src/shared/domain/types.ts +67 -0
- package/src/shared/domain/verifiers.ts +37 -0
- package/src/shared/domain/vfs.ts +9 -0
- package/src/shared/domain/workflow/state-file.ts +140 -0
- package/src/shared/infrastructure/globals.ts +52 -0
- package/src/shared/infrastructure/orkeon/approvals.ts +24 -0
- package/src/shared/infrastructure/orkeon/child-agents.ts +127 -0
- package/src/shared/infrastructure/orkeon/code-index.ts +120 -0
- package/src/shared/infrastructure/orkeon/crew-host.ts +27 -0
- package/src/shared/infrastructure/orkeon/crew-memory.ts +12 -0
- package/src/shared/infrastructure/orkeon/dev-deps.ts +172 -0
- package/src/shared/infrastructure/orkeon/files.ts +40 -0
- package/src/shared/infrastructure/orkeon/github-pull-requests.ts +29 -0
- package/src/shared/infrastructure/orkeon/host-provider.ts +22 -0
- package/src/shared/infrastructure/orkeon/human-input.ts +59 -0
- package/src/shared/infrastructure/orkeon/llm-profile.ts +38 -0
- package/src/shared/infrastructure/orkeon/llm.ts +109 -0
- package/src/shared/infrastructure/orkeon/memory-store.ts +41 -0
- package/src/shared/infrastructure/orkeon/memory-tools.ts +131 -0
- package/src/shared/infrastructure/orkeon/permission-rules.ts +42 -0
- package/src/shared/infrastructure/orkeon/progress.ts +24 -0
- package/src/shared/infrastructure/orkeon/run-state.ts +17 -0
- package/src/shared/infrastructure/orkeon/runtime-info.ts +30 -0
- package/src/shared/infrastructure/orkeon/runtime-tools.ts +60 -0
- package/src/shared/infrastructure/orkeon/script-tools.ts +134 -0
- package/src/shared/infrastructure/orkeon/session-store.ts +138 -0
- package/src/shared/infrastructure/orkeon/session-switch.ts +23 -0
- package/src/shared/infrastructure/orkeon/shared-memory.ts +61 -0
- package/src/shared/infrastructure/orkeon/shell-jobs.ts +75 -0
- package/src/shared/infrastructure/orkeon/shell.ts +31 -0
- package/src/shared/infrastructure/orkeon/telemetry.ts +63 -0
- package/src/shared/infrastructure/orkeon/tool-catalogue.ts +75 -0
- package/src/shared/infrastructure/orkeon/tool-results.ts +120 -0
- package/src/shared/infrastructure/orkeon/usage.ts +74 -0
- package/src/shared/infrastructure/orkeon/wiring.ts +118 -0
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
// /dev-learn's decisions: --accept <ids> and --refuse <id | motif text>, and the same
|
|
2
|
+
// decisions taken in the run that wrote PROPOSALS.md (crews/dev-learn). Reads the
|
|
3
|
+
// proposals and the learning state, writes Orkeon Code's state or refused.md; nothing
|
|
4
|
+
// here edits the file a proposal names: an accepted motif prints the change to make.
|
|
5
|
+
import type { DevContextDeps } from "./load-dev-context.ts";
|
|
6
|
+
import { loadDevContext } from "./load-dev-context.ts";
|
|
7
|
+
import type { WorkFolder } from "./resolve-work-folder.ts";
|
|
8
|
+
import type { Files, Shell } from "../ports.ts";
|
|
9
|
+
import { LEARN_FOLDER_PATTERN, PROPOSALS_JSON, acceptLines, parseProposalsFile } from "../../domain/dev/learn-proposals.ts";
|
|
10
|
+
import type { AxisProposal, Motif, ProposalsFile } from "../../domain/dev/learn-proposals.ts";
|
|
11
|
+
import { LEARN_STATE_FILE, decisionOf, parseLearnState, serializeLearnState, withDecision } from "../../domain/dev/learn-state.ts";
|
|
12
|
+
import type { LearnState } from "../../domain/dev/learn-state.ts";
|
|
13
|
+
import { appendRefused, parseRefused, projectFromRemote, topicOf } from "../../domain/shared-memory/refused.ts";
|
|
14
|
+
import { readRefusedFile } from "../shared-memory/memory-settings.ts";
|
|
15
|
+
import { WORKSPACE } from "../../domain/vfs.ts";
|
|
16
|
+
|
|
17
|
+
export type DevLearnDecisionArgs = { kind: "accept"; ids: string[] } | { kind: "refuse"; target: string };
|
|
18
|
+
export type DevLearnDecisionDeps = DevContextDeps & { files: Pick<Files, "read" | "list" | "write">; clock: () => Date };
|
|
19
|
+
export interface ProposalsLookup { files: Array<{ folder: string; file: ProposalsFile }>; warnings: string[] }
|
|
20
|
+
|
|
21
|
+
/** A proposal id: 8 hex digits, 10 on a collision in one file. */
|
|
22
|
+
export const PROPOSAL_ID = /^[0-9a-f]{8}([0-9a-f]{2})?$/;
|
|
23
|
+
|
|
24
|
+
const PROPOSALS_LOOKED_UP = 10;
|
|
25
|
+
const LEARN_LIST_CAP = 1000;
|
|
26
|
+
const GIT_REMOTE_ORIGIN = "git remote get-url origin";
|
|
27
|
+
const MAX_WARNING_LINES = 5;
|
|
28
|
+
const MAX_WARNING_CHARS = 200;
|
|
29
|
+
|
|
30
|
+
const messageOf = (e: unknown): string => (e instanceof Error ? e.message : String(e));
|
|
31
|
+
const isNotFound = (e: unknown): boolean => /not found/i.test(messageOf(e));
|
|
32
|
+
const firstLineOf = (e: unknown): string => messageOf(e).split("\n")[0];
|
|
33
|
+
|
|
34
|
+
function cut(text: string, max: number): string {
|
|
35
|
+
return text.length <= max ? text : `${text.slice(0, max - 1)}…`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function warningLines(warnings: readonly string[], max: number): string[] {
|
|
39
|
+
const shown = warnings.slice(0, max).map((w) => cut(`warning: ${w}`, MAX_WARNING_CHARS));
|
|
40
|
+
if (warnings.length > max) shown.push(`… ${warnings.length - max} more warnings`);
|
|
41
|
+
return shown;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function two(n: number): string {
|
|
45
|
+
return String(n).padStart(2, "0");
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function dayOf(date: Date): string {
|
|
49
|
+
return `${date.getFullYear()}-${two(date.getMonth() + 1)}-${two(date.getDate())}`;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** The file's text, null when it does not exist; any other read failure throws. */
|
|
53
|
+
async function readOrNull(files: Pick<Files, "read">, path: string): Promise<string | null> {
|
|
54
|
+
try {
|
|
55
|
+
return await files.read(path);
|
|
56
|
+
} catch (e) {
|
|
57
|
+
if (isNotFound(e)) return null;
|
|
58
|
+
throw e;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
interface FoundMotif { motif: Motif; axis: AxisProposal; key: string }
|
|
63
|
+
|
|
64
|
+
/** The proposals.json of the 10 newest learn-<date>/ folders, newest first; a bad one is a warning. */
|
|
65
|
+
export async function readProposals(files: Pick<Files, "read" | "list">, work: WorkFolder, vfsPath: string): Promise<ProposalsLookup> {
|
|
66
|
+
const lookup: ProposalsLookup = { files: [], warnings: [] };
|
|
67
|
+
let names: string[];
|
|
68
|
+
try {
|
|
69
|
+
names = await files.list(vfsPath, LEARN_LIST_CAP);
|
|
70
|
+
} catch (e) {
|
|
71
|
+
lookup.warnings.push(`${work.folder}/ cannot be listed (${firstLineOf(e)})`);
|
|
72
|
+
return lookup;
|
|
73
|
+
}
|
|
74
|
+
const folders = names.filter((n) => LEARN_FOLDER_PATTERN.test(n)).sort().reverse().slice(0, PROPOSALS_LOOKED_UP);
|
|
75
|
+
for (const folder of folders) {
|
|
76
|
+
const shown = `${work.folder}/${folder}/${PROPOSALS_JSON}`;
|
|
77
|
+
let text: string;
|
|
78
|
+
try {
|
|
79
|
+
text = await files.read(`${vfsPath}/${folder}/${PROPOSALS_JSON}`);
|
|
80
|
+
} catch (e) {
|
|
81
|
+
lookup.warnings.push(`${shown} cannot be read (${firstLineOf(e)})`);
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
const parsed = parseProposalsFile(text);
|
|
85
|
+
if (!parsed.ok) lookup.warnings.push(`${shown} cannot be read (${parsed.problem})`);
|
|
86
|
+
else lookup.files.push({ folder, file: parsed.file });
|
|
87
|
+
}
|
|
88
|
+
return lookup;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function findMotif(lookup: ProposalsLookup, id: string): FoundMotif | null {
|
|
92
|
+
for (const { folder, file } of lookup.files) {
|
|
93
|
+
for (const axis of file.axes) {
|
|
94
|
+
const motif = axis.motifs.find((m) => m.id === id);
|
|
95
|
+
if (motif) return { motif, axis, key: `${folder}\n${axis.axis}` };
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** The port of --treat-axis: an axis whose every motif is decided has its shown rows treated. */
|
|
102
|
+
function completeAxes(state: LearnState, touched: ReadonlyMap<string, AxisProposal>, lines: string[]): LearnState {
|
|
103
|
+
let next = state;
|
|
104
|
+
for (const axis of touched.values()) {
|
|
105
|
+
if (axis.motifs.length === 0 || !axis.motifs.every((m) => decisionOf(next, m.id) !== undefined)) continue;
|
|
106
|
+
next = { ...next, treated: [...new Set([...next.treated, ...axis.shownRows])].sort() };
|
|
107
|
+
lines.push(`axis ${axis.axis} done: ${axis.shownRows.length} gaps marked treated`);
|
|
108
|
+
}
|
|
109
|
+
return next;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
type StateLoad = { ok: true; state: LearnState } | { ok: false; text: string };
|
|
113
|
+
|
|
114
|
+
async function loadLearnState(files: Pick<Files, "read">): Promise<StateLoad> {
|
|
115
|
+
let text: string | null;
|
|
116
|
+
try {
|
|
117
|
+
text = await readOrNull(files, `${WORKSPACE}/${LEARN_STATE_FILE}`);
|
|
118
|
+
} catch (e) {
|
|
119
|
+
return { ok: false, text: `dev-learn: ${LEARN_STATE_FILE} cannot be read (${firstLineOf(e)}): fix or delete it; nothing was written` };
|
|
120
|
+
}
|
|
121
|
+
const read = parseLearnState(text);
|
|
122
|
+
return read.ok ? { ok: true, state: read.state } : { ok: false, text: `dev-learn: ${read.problem}: fix or delete it; nothing was written` };
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** Writes the state; the BLOCKED text when the write throws, null when it went through. */
|
|
126
|
+
async function saveLearnState(files: Pick<Files, "write">, state: LearnState): Promise<string | null> {
|
|
127
|
+
try {
|
|
128
|
+
await files.write(`${WORKSPACE}/${LEARN_STATE_FILE}`, serializeLearnState(state));
|
|
129
|
+
return null;
|
|
130
|
+
} catch (e) {
|
|
131
|
+
return `dev-learn: BLOCKED — ${LEARN_STATE_FILE} cannot be written (${firstLineOf(e)})`;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const notFoundText = (work: WorkFolder, id: string): string =>
|
|
136
|
+
`dev-learn: no proposal ${id} in the 10 newest ${work.folder}/learn-*/ folders`;
|
|
137
|
+
const stateLine = (state: LearnState): string => `state: ${LEARN_STATE_FILE} — ${state.treated.length} gaps treated in all`;
|
|
138
|
+
|
|
139
|
+
async function acceptMotifs(ids: readonly string[], lookup: ProposalsLookup, work: WorkFolder, deps: DevLearnDecisionDeps): Promise<string[]> {
|
|
140
|
+
const load = await loadLearnState(deps.files);
|
|
141
|
+
if (!load.ok) return [load.text];
|
|
142
|
+
const date = dayOf(deps.clock());
|
|
143
|
+
let state = load.state;
|
|
144
|
+
const lines: string[] = [];
|
|
145
|
+
const touched = new Map<string, AxisProposal>();
|
|
146
|
+
for (const id of ids) {
|
|
147
|
+
const found = findMotif(lookup, id);
|
|
148
|
+
const earlier = decisionOf(state, id);
|
|
149
|
+
if (found === null) {
|
|
150
|
+
lines.push(notFoundText(work, id));
|
|
151
|
+
} else if (earlier !== undefined) {
|
|
152
|
+
lines.push(`${id} was already ${earlier.decision} on ${earlier.date}`);
|
|
153
|
+
} else {
|
|
154
|
+
const { motif, axis } = found;
|
|
155
|
+
lines.push(...acceptLines(motif));
|
|
156
|
+
state = withDecision(state, { motif: id, decision: "accepted", date, axis: axis.axis, title: motif.title }, motif.rows);
|
|
157
|
+
touched.set(found.key, axis);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
state = completeAxes(state, touched, lines);
|
|
161
|
+
if (state !== load.state) {
|
|
162
|
+
const blocked = await saveLearnState(deps.files, state);
|
|
163
|
+
if (blocked !== null) return [...lines, blocked];
|
|
164
|
+
}
|
|
165
|
+
return [...lines, stateLine(state)];
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
async function projectName(shell: Pick<Shell, "run">): Promise<string> {
|
|
169
|
+
try {
|
|
170
|
+
const result = await shell.run(GIT_REMOTE_ORIGIN);
|
|
171
|
+
return result.exitCode === 0 ? projectFromRemote(result.stdout) ?? "local" : "local";
|
|
172
|
+
} catch {
|
|
173
|
+
return "local";
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** Appends the topic to refused.md unless it is there already; the line to print. */
|
|
178
|
+
async function recordRefusal(topic: string, motifText: string, date: string, deps: DevLearnDecisionDeps): Promise<{ ok: boolean; line: string }> {
|
|
179
|
+
// refused.md of memory.dir, the one /memory-admit reads too.
|
|
180
|
+
const refusedFile = await readRefusedFile(deps.config);
|
|
181
|
+
const path = `${WORKSPACE}/${refusedFile}`;
|
|
182
|
+
let previous: string | null;
|
|
183
|
+
try {
|
|
184
|
+
previous = await readOrNull(deps.files, path);
|
|
185
|
+
} catch (e) {
|
|
186
|
+
return { ok: false, line: `dev-learn: ${refusedFile} cannot be read (${firstLineOf(e)}): nothing was written` };
|
|
187
|
+
}
|
|
188
|
+
const already = previous === null ? undefined : parseRefused(previous).motifs.find((m) => m.topic === topic);
|
|
189
|
+
if (already !== undefined) return { ok: true, line: `${topic} was already refused on ${already.date}` };
|
|
190
|
+
const project = await projectName(deps.shell);
|
|
191
|
+
try {
|
|
192
|
+
await deps.files.write(path, appendRefused(previous, { topic, project, date, motif: motifText }));
|
|
193
|
+
} catch (e) {
|
|
194
|
+
return { ok: false, line: `dev-learn: BLOCKED — ${refusedFile} cannot be written (${firstLineOf(e)})` };
|
|
195
|
+
}
|
|
196
|
+
return { ok: true, line: `refused: ${topic} — left out of future proposals (${refusedFile})` };
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
async function refuseMotif(target: string, lookup: ProposalsLookup, work: WorkFolder, deps: DevLearnDecisionDeps): Promise<string[]> {
|
|
200
|
+
const date = dayOf(deps.clock());
|
|
201
|
+
if (!PROPOSAL_ID.test(target)) {
|
|
202
|
+
return [(await recordRefusal(topicOf(target), target, date, deps)).line];
|
|
203
|
+
}
|
|
204
|
+
const found = findMotif(lookup, target);
|
|
205
|
+
if (found === null) return [`${notFoundText(work, target)} (to refuse a motif by its words, write more than an id)`];
|
|
206
|
+
const load = await loadLearnState(deps.files);
|
|
207
|
+
if (!load.ok) return [load.text];
|
|
208
|
+
const earlier = decisionOf(load.state, target);
|
|
209
|
+
if (earlier !== undefined) return [`${target} was already ${earlier.decision} on ${earlier.date}`];
|
|
210
|
+
const { motif, axis } = found;
|
|
211
|
+
const refusal = await recordRefusal(motif.topic, motif.title, date, deps);
|
|
212
|
+
if (!refusal.ok) return [refusal.line];
|
|
213
|
+
const lines = [refusal.line];
|
|
214
|
+
let state = withDecision(load.state, { motif: target, decision: "refused", date, axis: axis.axis, title: motif.title }, motif.rows);
|
|
215
|
+
state = completeAxes(state, new Map([[found.key, axis]]), lines);
|
|
216
|
+
const blocked = await saveLearnState(deps.files, state);
|
|
217
|
+
return blocked !== null ? [...lines, blocked] : [...lines, stateLine(state)];
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/** --accept / --refuse: reads the proposals and the states, writes Orkeon Code's state or refused.md, returns the text. */
|
|
221
|
+
export async function runDevLearnDecision(
|
|
222
|
+
args: DevLearnDecisionArgs,
|
|
223
|
+
deps: DevLearnDecisionDeps,
|
|
224
|
+
): Promise<string> {
|
|
225
|
+
const ctx = await loadDevContext(deps);
|
|
226
|
+
const work = ctx.work;
|
|
227
|
+
if (work.vfsPath === null) {
|
|
228
|
+
return `dev-learn: the work folder ${work.folder} is in the main worktree, outside the mounts: run /dev-learn from the main checkout`;
|
|
229
|
+
}
|
|
230
|
+
if (!work.exists) return `dev-learn: no work folder ${work.folder}/: nothing to learn from`;
|
|
231
|
+
const lookup = await readProposals(deps.files, work, work.vfsPath);
|
|
232
|
+
const lines = args.kind === "accept"
|
|
233
|
+
? await acceptMotifs(args.ids, lookup, work, deps)
|
|
234
|
+
: await refuseMotif(args.target, lookup, work, deps);
|
|
235
|
+
return [...warningLines([...ctx.warnings, ...lookup.warnings], MAX_WARNING_LINES), ...lines].join("\n");
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
const isStateLine = (line: string): boolean => line.startsWith("state: ");
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* The decisions taken in the run that wrote the proposals: `accept` as --accept would take
|
|
242
|
+
* them, then each of `refuse` as --refuse would; one state line, the last, at the end.
|
|
243
|
+
*/
|
|
244
|
+
export async function decideMotifs(
|
|
245
|
+
accept: readonly string[], refuse: readonly string[], lookup: ProposalsLookup, work: WorkFolder, deps: DevLearnDecisionDeps,
|
|
246
|
+
): Promise<string[]> {
|
|
247
|
+
const lines: string[] = [];
|
|
248
|
+
if (accept.length > 0) lines.push(...await acceptMotifs(accept, lookup, work, deps));
|
|
249
|
+
for (const id of refuse) lines.push(...await refuseMotif(id, lookup, work, deps));
|
|
250
|
+
const last = lines.filter(isStateLine).at(-1);
|
|
251
|
+
return [...lines.filter((l) => !isStateLine(l)), ...(last === undefined ? [] : [last])];
|
|
252
|
+
}
|
|
@@ -0,0 +1,266 @@
|
|
|
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
|
+
|
|
22
|
+
export interface DevContextDeps {
|
|
23
|
+
files: Pick<Files, "read" | "list">; shell: Pick<Shell, "run">; config: Pick<ConfigStore, "readValue">;
|
|
24
|
+
}
|
|
25
|
+
export interface DevContext { pack: FoundPack | null; work: WorkFolder; warnings: string[] }
|
|
26
|
+
export const ORKEON_IGNORE_PROBE = ".orkeon/config.json";
|
|
27
|
+
export const HARNESS_SETTINGS_LOCAL = `${WORKSPACE}/.claude/settings.local.json`;
|
|
28
|
+
export const HARNESS_TODO = `${WORKSPACE}/todo`;
|
|
29
|
+
|
|
30
|
+
const TODO_LIST_CAP = 200;
|
|
31
|
+
const TODO_SUBFOLDERS_PROBED = 20;
|
|
32
|
+
const CODE_LIST_CAP = 500;
|
|
33
|
+
const CODES_PROBED = 50;
|
|
34
|
+
/** A loose file of the work folder (README.md, notes.txt): never a code folder, so never probed. */
|
|
35
|
+
const FILE_LIKE = /\.(md|markdown|txt|json|jsonl|ya?ml|toml|sh|log|html?|csv|tsv)$/i;
|
|
36
|
+
const HARNESS_WORK_PREFIX = /^(pr|quality|release|docs-audit)-/;
|
|
37
|
+
|
|
38
|
+
const messageOf = (e: unknown): string => (e instanceof Error ? e.message : String(e));
|
|
39
|
+
const firstLine = (e: unknown): string => messageOf(e).split("\n")[0];
|
|
40
|
+
const bare = (entry: string): string => entry.replace(/\/+$/, "");
|
|
41
|
+
const byName = (a: string, b: string): number => (a < b ? -1 : a > b ? 1 : 0);
|
|
42
|
+
|
|
43
|
+
/** "git check-ignore -- " + paths.join(" ") */
|
|
44
|
+
export function checkIgnoreCommand(paths: readonly string[]): string {
|
|
45
|
+
return `git check-ignore -- ${paths.join(" ")}`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async function readWorkDirSetting(config: Pick<ConfigStore, "readValue">, warnings: string[]): Promise<string | undefined> {
|
|
49
|
+
try {
|
|
50
|
+
return (await config.readValue(DEV_WORK_DIR_CONFIG_KEY)).value;
|
|
51
|
+
} catch (e) {
|
|
52
|
+
warnings.push(`${DEV_WORK_DIR_CONFIG_KEY} could not be read (${firstLine(e)}): the pack or the default decides`);
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async function checkIgnored(shell: Pick<Shell, "run">, work: WorkFolder, warnings: string[]): Promise<void> {
|
|
58
|
+
const paths = [ORKEON_IGNORE_PROBE];
|
|
59
|
+
if (work.folder === DEFAULT_WORK_FOLDER && (work.request === null || work.outcome !== "applied")) {
|
|
60
|
+
paths.push(`${DEFAULT_WORK_FOLDER}/`);
|
|
61
|
+
}
|
|
62
|
+
let result: ShellResult;
|
|
63
|
+
try {
|
|
64
|
+
result = await shell.run(checkIgnoreCommand(paths));
|
|
65
|
+
} catch {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (result.exitCode !== 0 && result.exitCode !== 1) return;
|
|
69
|
+
const ignored = new Set(result.stdout.split(/\r?\n/).map((l) => l.trim()).filter((l) => l !== ""));
|
|
70
|
+
for (const path of paths) {
|
|
71
|
+
if (!ignored.has(path)) warnings.push(`${path} is not ignored by git: add it to .gitignore (Orkeon Code never edits it)`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The harness's HARNESS_WORK_DIR from .claude/settings.local.json env; undefined when unreadable or unset. */
|
|
76
|
+
async function harnessWorkDir(files: Pick<Files, "read">): Promise<string | undefined> {
|
|
77
|
+
try {
|
|
78
|
+
const parsed: unknown = JSON.parse(await files.read(HARNESS_SETTINGS_LOCAL));
|
|
79
|
+
if (typeof parsed !== "object" || parsed === null) return undefined;
|
|
80
|
+
const env = (parsed as { env?: unknown }).env;
|
|
81
|
+
if (typeof env !== "object" || env === null) return undefined;
|
|
82
|
+
const value = (env as Record<string, unknown>).HARNESS_WORK_DIR;
|
|
83
|
+
return typeof value === "string" ? value : undefined;
|
|
84
|
+
} catch {
|
|
85
|
+
return undefined;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async function listOrEmpty(files: Pick<Files, "list">, path: string, cap: number): Promise<string[]> {
|
|
90
|
+
try {
|
|
91
|
+
return await files.list(path, cap);
|
|
92
|
+
} catch {
|
|
93
|
+
return [];
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
async function todoHoldsHarnessWork(files: Pick<Files, "list">): Promise<boolean> {
|
|
98
|
+
const entries = (await listOrEmpty(files, HARNESS_TODO, TODO_LIST_CAP)).map(bare);
|
|
99
|
+
if (entries.some((e) => HARNESS_WORK_PREFIX.test(e))) return true;
|
|
100
|
+
for (const entry of entries.slice(0, TODO_SUBFOLDERS_PROBED)) {
|
|
101
|
+
const inner = await listOrEmpty(files, `${HARNESS_TODO}/${entry}`, TODO_LIST_CAP);
|
|
102
|
+
if (inner.some((name) => classifyArtefact(bare(name)) !== null)) return true;
|
|
103
|
+
}
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export async function loadDevContext(deps: DevContextDeps): Promise<DevContext> {
|
|
108
|
+
const lookup = await findRepoPack(deps.files);
|
|
109
|
+
const warnings = [...lookup.warnings];
|
|
110
|
+
const pack = lookup.found;
|
|
111
|
+
|
|
112
|
+
const configValue = await readWorkDirSetting(deps.config, warnings);
|
|
113
|
+
const request = pickWorkDirRequest(configValue, pack?.pack.layout.work);
|
|
114
|
+
const work = await resolveWorkFolder(deps, request);
|
|
115
|
+
if (work.note !== null) warnings.push(work.note);
|
|
116
|
+
|
|
117
|
+
await checkIgnored(deps.shell, work, warnings);
|
|
118
|
+
|
|
119
|
+
if (request === null) {
|
|
120
|
+
const named = (await harnessWorkDir(deps.files))?.trim().replace(/^\.\//, "").replace(/\/+$/, "");
|
|
121
|
+
if (named !== DEFAULT_WORK_FOLDER && (await todoHoldsHarnessWork(deps.files))) {
|
|
122
|
+
warnings.push(
|
|
123
|
+
"todo/ holds harness artefacts and nothing names workbench/: set layout.work: workbench in the pack, " +
|
|
124
|
+
"or HARNESS_WORK_DIR=workbench in .claude/settings.local.json env (W-01)",
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return { pack, work, warnings };
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export interface CodeSheet { batch: string; name: string; sheet: BatchSheet }
|
|
132
|
+
export interface CodeVerdict { batch: string; name: string; file: VerdictFile }
|
|
133
|
+
export interface DevCode {
|
|
134
|
+
code: string; shown: string; // "workbench/demo"
|
|
135
|
+
spec: string | null; change: string | null; // file names
|
|
136
|
+
plan: { name: string; plan: GlobalPlan } | null;
|
|
137
|
+
sheets: CodeSheet[]; verdicts: CodeVerdict[];
|
|
138
|
+
state: { name: string; state: BatchesState } | null;
|
|
139
|
+
warnings: string[];
|
|
140
|
+
}
|
|
141
|
+
export type DevCodeLookup =
|
|
142
|
+
| { found: DevCode }
|
|
143
|
+
| { found: null; reason: "absent" | "empty" | "unreachable"; codes: string[] };
|
|
144
|
+
|
|
145
|
+
function classifyAll(entries: readonly string[]): ArtefactName[] {
|
|
146
|
+
const out: ArtefactName[] = [];
|
|
147
|
+
for (const entry of [...entries].map(bare).sort()) {
|
|
148
|
+
const a = classifyArtefact(entry);
|
|
149
|
+
if (a) out.push(a);
|
|
150
|
+
}
|
|
151
|
+
return out;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const byBatch = (a: { batch: string; name: string }, b: { batch: string; name: string }): number =>
|
|
155
|
+
compareBatchIds(a.batch, b.batch) || (a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
|
|
156
|
+
|
|
157
|
+
export async function loadDevCode(deps: Pick<DevContextDeps, "files">, work: WorkFolder, code: string): Promise<DevCodeLookup> {
|
|
158
|
+
if (work.vfsPath === null) return { found: null, reason: "unreachable", codes: [] };
|
|
159
|
+
const folder = `${work.vfsPath}/${code}`;
|
|
160
|
+
if (!(await entryExists(deps.files, folder))) {
|
|
161
|
+
let codes: string[] = [];
|
|
162
|
+
try {
|
|
163
|
+
codes = (await listDevCodes(deps, work)).map((c) => c.code);
|
|
164
|
+
} catch {
|
|
165
|
+
codes = [];
|
|
166
|
+
}
|
|
167
|
+
return { found: null, reason: "absent", codes };
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const artefacts = classifyAll(await listOrEmpty(deps.files, folder, CODE_LIST_CAP));
|
|
171
|
+
const of = (kind: ArtefactName["kind"]): ArtefactName[] => artefacts.filter((a) => a.kind === kind);
|
|
172
|
+
const plans = of("plan");
|
|
173
|
+
const specs = of("spec");
|
|
174
|
+
const changes = of("change");
|
|
175
|
+
if (plans.length === 0 && specs.length === 0 && changes.length === 0) {
|
|
176
|
+
return { found: null, reason: "empty", codes: [] };
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const shown = `${work.folder}/${code}`;
|
|
180
|
+
const warnings: string[] = [];
|
|
181
|
+
const read = async (name: string): Promise<string | null> => {
|
|
182
|
+
try {
|
|
183
|
+
return await deps.files.read(`${folder}/${name}`);
|
|
184
|
+
} catch (e) {
|
|
185
|
+
warnings.push(`${shown}/${name} cannot be read (${firstLine(e)})`);
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
const report = (name: string, problems: readonly FormatProblem[]): void => {
|
|
190
|
+
for (const p of problems) warnings.push(`${shown}/${name}:${p.line}: ${p.message}`);
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
let plan: DevCode["plan"] = null;
|
|
194
|
+
if (plans.length > 0) {
|
|
195
|
+
const chosen = plans.find((p) => p.prefix.toUpperCase() === code.toUpperCase()) ?? plans[0];
|
|
196
|
+
if (plans.length > 1) {
|
|
197
|
+
warnings.push(`several plans in ${shown}/: ${plans.map((p) => p.name).join(", ")}: ${chosen.name} is read`);
|
|
198
|
+
}
|
|
199
|
+
const text = await read(chosen.name);
|
|
200
|
+
if (text !== null) {
|
|
201
|
+
const parsed = parseGlobalPlan(text);
|
|
202
|
+
report(chosen.name, parsed.problems);
|
|
203
|
+
plan = { name: chosen.name, plan: parsed };
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const sheets: CodeSheet[] = [];
|
|
208
|
+
for (const a of of("sheet")) {
|
|
209
|
+
const text = await read(a.name);
|
|
210
|
+
if (text === null) continue;
|
|
211
|
+
const sheet = parseBatchSheet(text);
|
|
212
|
+
report(a.name, sheet.problems);
|
|
213
|
+
sheets.push({ batch: a.batch ?? "", name: a.name, sheet });
|
|
214
|
+
}
|
|
215
|
+
const verdicts: CodeVerdict[] = [];
|
|
216
|
+
for (const a of of("verdict")) {
|
|
217
|
+
const text = await read(a.name);
|
|
218
|
+
if (text === null) continue;
|
|
219
|
+
const file = parseVerdictFile(text);
|
|
220
|
+
report(a.name, file.problems);
|
|
221
|
+
verdicts.push({ batch: a.batch ?? "", name: a.name, file });
|
|
222
|
+
}
|
|
223
|
+
let state: DevCode["state"] = null;
|
|
224
|
+
for (const a of of("batches-state")) {
|
|
225
|
+
const text = await read(a.name);
|
|
226
|
+
if (text === null) continue;
|
|
227
|
+
state = { name: a.name, state: parseBatchesState(text) };
|
|
228
|
+
break;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
return {
|
|
232
|
+
found: {
|
|
233
|
+
code, shown,
|
|
234
|
+
spec: specs[0]?.name ?? null, change: changes[0]?.name ?? null,
|
|
235
|
+
plan, sheets: sheets.sort(byBatch), verdicts: verdicts.sort(byBatch), state, warnings,
|
|
236
|
+
},
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export interface CodeSummary { code: string; spec: boolean; change: boolean; plan: boolean; sheets: number; verdicts: number }
|
|
241
|
+
|
|
242
|
+
/** The codes of the work folder; throws when the work folder itself cannot be listed. */
|
|
243
|
+
export async function listDevCodes(deps: Pick<DevContextDeps, "files">, work: WorkFolder): Promise<CodeSummary[]> {
|
|
244
|
+
return (await probeDevCodes(deps, work)).codes;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/** listDevCodes, plus how many candidate folders the cap of CODES_PROBED left unprobed. */
|
|
248
|
+
export async function probeDevCodes(
|
|
249
|
+
deps: Pick<DevContextDeps, "files">, work: WorkFolder,
|
|
250
|
+
): Promise<{ codes: CodeSummary[]; notProbed: number }> {
|
|
251
|
+
if (work.vfsPath === null) return { codes: [], notProbed: 0 };
|
|
252
|
+
const listed = await deps.files.list(work.vfsPath, CODE_LIST_CAP);
|
|
253
|
+
const candidates = [...new Set(listed.filter((e) => e.endsWith("/") || !FILE_LIKE.test(e)).map(bare).filter(isCode))]
|
|
254
|
+
.sort(byName);
|
|
255
|
+
const out: CodeSummary[] = [];
|
|
256
|
+
for (const entry of candidates.slice(0, CODES_PROBED)) {
|
|
257
|
+
const kinds = classifyAll(await listOrEmpty(deps.files, `${work.vfsPath}/${entry}`, CODE_LIST_CAP)).map((a) => a.kind);
|
|
258
|
+
const count = (k: ArtefactName["kind"]): number => kinds.filter((x) => x === k).length;
|
|
259
|
+
const summary: CodeSummary = {
|
|
260
|
+
code: entry, spec: count("spec") > 0, change: count("change") > 0, plan: count("plan") > 0,
|
|
261
|
+
sheets: count("sheet"), verdicts: count("verdict"),
|
|
262
|
+
};
|
|
263
|
+
if (summary.spec || summary.change || summary.plan) out.push(summary);
|
|
264
|
+
}
|
|
265
|
+
return { codes: out, notProbed: Math.max(0, candidates.length - CODES_PROBED) };
|
|
266
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
|
|
11
|
+
const firstLine = (text: string): string => (text.split("\n")[0] ?? "").trim();
|
|
12
|
+
|
|
13
|
+
/** A changed file outside the plan folder, and the lines its captured diff adds (null: not known). */
|
|
14
|
+
export interface CostFile { path: string; added: Set<number> | null }
|
|
15
|
+
|
|
16
|
+
/** `tools.access_cost.roots`, else none: every changed file that is not a test. */
|
|
17
|
+
export function costRoots(pack: RepoPack | null): string[] {
|
|
18
|
+
return [...(pack?.accessCost.roots ?? [])];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function failed(tool: string, error: unknown): AccessCost {
|
|
22
|
+
return notComputed(`${tool} failed (${firstLine(error instanceof Error ? error.message : String(error))}); judge the Cost axis from the diff`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function normalRoot(root: string): string {
|
|
26
|
+
return root.length > 1 ? root.replace(/\/+$/, "") : root;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export async function measureAccessCost(
|
|
30
|
+
index: CostIndex | undefined, pack: RepoPack | null, gateRoots: readonly string[], changed: readonly CostFile[],
|
|
31
|
+
isTest?: (path: string) => boolean,
|
|
32
|
+
): Promise<AccessCost> {
|
|
33
|
+
if (index === undefined) return COST_NOT_WIRED;
|
|
34
|
+
const roots = costRoots(pack);
|
|
35
|
+
const testRoots = gateRoots.filter(isTestRoot);
|
|
36
|
+
// A caller that knows the pack's test paths says which they are; else a path that says test is one (AC:326-331).
|
|
37
|
+
const test = isTest ?? ((p: string) => isTestFile(p, testRoots));
|
|
38
|
+
const kept = underRoots(changed.map((f) => f.path).filter((p) => !test(p)), roots);
|
|
39
|
+
if (kept.length === 0) return nothingChanged(roots);
|
|
40
|
+
const files = kept.map((p) => `${WORKSPACE}/${p}`);
|
|
41
|
+
|
|
42
|
+
let indexed: string[];
|
|
43
|
+
try {
|
|
44
|
+
indexed = await index.roots();
|
|
45
|
+
} catch (error) {
|
|
46
|
+
return failed("index_status", error);
|
|
47
|
+
}
|
|
48
|
+
if (!indexed.map(normalRoot).includes(WORKSPACE)) return notIndexed(indexed);
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
const errors = await index.refresh(WORKSPACE, files);
|
|
52
|
+
if (errors.length > 0) return notComputed(`incremental_reindex: ${firstLine(errors[0])}; judge the Cost axis from the diff`);
|
|
53
|
+
} catch (error) {
|
|
54
|
+
return failed("incremental_reindex", error);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
let answer: Awaited<ReturnType<CostIndex["accessCost"]>>;
|
|
58
|
+
try {
|
|
59
|
+
answer = await index.accessCost(files, receiversArgument(pack?.accessCost.receivers));
|
|
60
|
+
} catch (error) {
|
|
61
|
+
return failed("access_cost", error);
|
|
62
|
+
}
|
|
63
|
+
if (answer.errors.length > 0) return notComputed(`access_cost: ${firstLine(answer.errors[0])}; judge the Cost axis from the diff`);
|
|
64
|
+
if (answer.report === null) return notComputed("access_cost returned no readable report; judge the Cost axis from the diff");
|
|
65
|
+
|
|
66
|
+
const added = new Map(changed.map((f) => [`${WORKSPACE}/${f.path}`, f.added] as const));
|
|
67
|
+
return measuredCost(answer.report, added);
|
|
68
|
+
}
|