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,188 @@
|
|
|
1
|
+
// One batch of /dev-batches (`/dev-batches <code> F<n> …`, its alias /dev-implement): its dispatch, and what its
|
|
2
|
+
// `completed` does with each answer of the batch's chain. The dev-implement crew answers JSON `{ lines, next? }`: the
|
|
3
|
+
// lines are printed and `next` (the audit, its input as the crew wrote it: mode, hooks, effort) is launched. The
|
|
4
|
+
// audit (the dev-verify crew), launched from here, drains to the same `completed` as plain text: printed, and on its
|
|
5
|
+
// VALID line the close is launched (`/dev-batches <plan> F<n> --close`). A launch that cannot run prints the command
|
|
6
|
+
// for the user instead. Before a hop that writes (the close), the session's context is read again (Orkeon #220,
|
|
7
|
+
// `completed` awaited by the host): a mode that no longer allows it refuses the hop with the command to type, else the
|
|
8
|
+
// fresh mode, rules and github tool ride in the launch input, so the crew reads them rather than the context its
|
|
9
|
+
// record kept at the launch; a context that cannot be read leaves the record's in force, said in a line. The dispatch
|
|
10
|
+
// (runDevImplementDispatch) checks the mode, starts the step and sizes the run to the sheet's open steps over the
|
|
11
|
+
// ports it is handed; the chain's launch is handed to it too.
|
|
12
|
+
import type { CrewLaunchOptions, Files, PermissionRules, Shell, ToolCatalogue } from "../../../shared/application/ports.ts";
|
|
13
|
+
import type { ConfigStore } from "../../../shared/application/config-store.ts";
|
|
14
|
+
import type { SessionIo } from "../../../shared/application/session-io.ts";
|
|
15
|
+
import { auditCommand, closeCommand } from "../../../shared/domain/dev/verdict-format.ts";
|
|
16
|
+
import type { DevStep } from "../../../shared/domain/dev/step-rules.ts";
|
|
17
|
+
import { countOpenSteps } from "../../../crews/dev-implement/application/count-open-steps.ts";
|
|
18
|
+
import { markActiveWorkflow, startDevStep, writeModeRefusal } from "../dev-step.ts";
|
|
19
|
+
import type { CrewCompletion, LaunchResult } from "../dispatch.ts";
|
|
20
|
+
import { storedEffort } from "../effort.ts";
|
|
21
|
+
import { readPullRequestContext } from "../pr-context.ts";
|
|
22
|
+
import type { PullRequestContext } from "../pr-context.ts";
|
|
23
|
+
|
|
24
|
+
/** One batch of a plan, as `/dev-batches <code> F<n> [--close [--pr]] [— correction: <finding>]` reads it
|
|
25
|
+
* (dev-batches.ts parseDevBatchesArgs): the batch, its plan (a code or a `<path>/<CODE>-PLAN.md`, null to find it). */
|
|
26
|
+
export interface DevImplementArgs { batch: string; plan: string | null; close: boolean; pr: boolean; correction: string | null }
|
|
27
|
+
|
|
28
|
+
export interface ChainLaunch { crew: string; input: Record<string, unknown>; instead: string }
|
|
29
|
+
export interface ChainStep { lines: string[]; launch?: ChainLaunch }
|
|
30
|
+
|
|
31
|
+
const VALID_LINE = /^→ Batch (F\d+) VALID\./m;
|
|
32
|
+
const WRITTEN_LINE = /^written: (\S+)\/([A-Za-z0-9][A-Za-z0-9._-]*)-VERIFY-(F\d+)\.md\b/m;
|
|
33
|
+
|
|
34
|
+
/** What `completed` prints and launches for one answer of the chain. */
|
|
35
|
+
export function chainStep(payload: string): ChainStep {
|
|
36
|
+
let parsed: unknown = null;
|
|
37
|
+
try {
|
|
38
|
+
parsed = JSON.parse(payload);
|
|
39
|
+
} catch {
|
|
40
|
+
parsed = null;
|
|
41
|
+
}
|
|
42
|
+
const answer = parsed as { lines?: unknown; next?: { crew?: unknown; input?: Record<string, unknown> } } | null;
|
|
43
|
+
if (answer !== null && typeof answer === "object" && Array.isArray(answer.lines)) {
|
|
44
|
+
const lines = answer.lines.map(String);
|
|
45
|
+
const next = answer.next;
|
|
46
|
+
if (next?.crew === "dev-verify" && next.input !== undefined) {
|
|
47
|
+
const { batch, plan, mode } = next.input;
|
|
48
|
+
const instead = auditCommand(String(plan ?? "<code>"), String(batch), mode === "resume" ? "resume" : undefined);
|
|
49
|
+
return { lines, launch: { crew: "dev-verify", input: { ...next.input }, instead } };
|
|
50
|
+
}
|
|
51
|
+
return { lines };
|
|
52
|
+
}
|
|
53
|
+
// The audit's own answer, drained here by the chain.
|
|
54
|
+
const lines = payload.split("\n");
|
|
55
|
+
// The VALID line is the audit's own: at the start of a line, after the verdict file's, for that file's batch; a
|
|
56
|
+
// gap that quotes it from model text launches nothing.
|
|
57
|
+
const written = WRITTEN_LINE.exec(payload);
|
|
58
|
+
const valid = written === null ? null : VALID_LINE.exec(payload.slice(written.index + written[0].length));
|
|
59
|
+
if (valid === null || written === null || valid[1] !== written[3]) return { lines };
|
|
60
|
+
const plan = `${written[1]}/${written[2]}-PLAN.md`;
|
|
61
|
+
return {
|
|
62
|
+
lines: [...lines, `→ the close follows: ${closeCommand(plan, valid[1])}`],
|
|
63
|
+
launch: { crew: "dev-implement", input: { batch: valid[1], plan, close: true }, instead: closeCommand(plan, valid[1]) },
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface DevImplementDispatchDeps {
|
|
68
|
+
session: Pick<SessionIo, "resolveEffectiveSessionMode" | "readState" | "writeState">;
|
|
69
|
+
config: Pick<ConfigStore, "readValue" | "readFile">;
|
|
70
|
+
files: Files;
|
|
71
|
+
shell: Shell;
|
|
72
|
+
/** The host's gate and its tools, each made when read: a host without the service fails there. */
|
|
73
|
+
gate: () => PermissionRules;
|
|
74
|
+
catalogue: () => Pick<ToolCatalogue, "find">;
|
|
75
|
+
write(line: string): void;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export type DevImplementDispatch =
|
|
79
|
+
| { refused: string }
|
|
80
|
+
| { input: Record<string, unknown>; details: { ruleSets: string; rules: number; hooks: number } };
|
|
81
|
+
|
|
82
|
+
/** One batch's dispatch, from its parsed arguments: the refusal, written, or the crew's input and the launch's details. */
|
|
83
|
+
export async function runDevImplementDispatch(args: DevImplementArgs, deps: DevImplementDispatchDeps): Promise<DevImplementDispatch> {
|
|
84
|
+
const prContext = await readPullRequestContext({ catalogue: deps.catalogue, rules: deps.gate, session: deps.session });
|
|
85
|
+
const line = writeModeRefusal(String(prContext.permissionMode ?? ""), "dev-batches", "writes files, commits and pushes");
|
|
86
|
+
if (line !== null) {
|
|
87
|
+
deps.write(line);
|
|
88
|
+
return { refused: line };
|
|
89
|
+
}
|
|
90
|
+
const start = await startDevStep("dev-implement", {
|
|
91
|
+
session: deps.session, config: deps.config, gate: deps.gate(), catalogue: deps.catalogue(),
|
|
92
|
+
});
|
|
93
|
+
if (!start.ok) {
|
|
94
|
+
deps.write(start.line);
|
|
95
|
+
return { refused: start.line };
|
|
96
|
+
}
|
|
97
|
+
for (const line of start.lines) deps.write(line);
|
|
98
|
+
const unrecorded = await markActiveWorkflow(deps.session, args);
|
|
99
|
+
if (unrecorded !== null) deps.write(unrecorded);
|
|
100
|
+
// The budget is sized to the open steps of the sheet (the crew sizes for its default when they cannot be counted).
|
|
101
|
+
// A correction adds one step, appended by the crew after this count.
|
|
102
|
+
const open = args.close
|
|
103
|
+
? undefined
|
|
104
|
+
: await countOpenSteps({ files: deps.files, shell: deps.shell, config: deps.config }, args.batch, args.plan);
|
|
105
|
+
const steps = open === undefined || args.correction === null ? open : open + 1;
|
|
106
|
+
const input = {
|
|
107
|
+
...args, ...start.input, effort: await storedEffort(deps.session), ...(steps === undefined ? {} : { steps }), ...prContext,
|
|
108
|
+
};
|
|
109
|
+
return { input, details: { ruleSets: start.sets.join(" "), rules: start.rules, hooks: start.hooks.length } };
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** What a hop of a chain reads before it launches: the gate put back, the session's context read again. */
|
|
113
|
+
export interface ChainHopDeps {
|
|
114
|
+
/** Puts the step's rules back in the gate; its refusal launches nothing. */
|
|
115
|
+
reapply: (step: DevStep) => string | null;
|
|
116
|
+
/** The session's context as it is now (readPullRequestContext); a read that fails leaves the record's in force. */
|
|
117
|
+
context: () => Promise<PullRequestContext>;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** The line a hop prints when the session's context could not be read again: the crew reads its record. */
|
|
121
|
+
export const CONTEXT_NOT_READ_LINE = "⚠ the session's mode could not be read again: the context read at the launch applies";
|
|
122
|
+
|
|
123
|
+
/** What the close writes, for the refusal of a read-only mode. */
|
|
124
|
+
const CLOSE_WRITES = { step: "dev-batches", what: "commits (the close of the batch)" };
|
|
125
|
+
|
|
126
|
+
/** The session's context now, or null when it cannot be read (a throw, an empty mode). */
|
|
127
|
+
export async function freshContext(read: () => Promise<PullRequestContext>): Promise<PullRequestContext | null> {
|
|
128
|
+
try {
|
|
129
|
+
const context = await read();
|
|
130
|
+
return context.permissionMode.trim() === "" ? null : context;
|
|
131
|
+
} catch {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** The launch input with the fresh mode and rules; the github tool as the input names it, else as the session has it. */
|
|
137
|
+
export function withContext(input: Record<string, unknown>, context: PullRequestContext): Record<string, unknown> {
|
|
138
|
+
return {
|
|
139
|
+
...input, permissionMode: context.permissionMode, permissionRules: [...context.permissionRules],
|
|
140
|
+
githubTool: typeof input.githubTool === "boolean" ? input.githubTool : context.githubTool,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* A hop that writes, with the session's context read again (Orkeon #220): refused, with the command to type, when
|
|
146
|
+
* the mode no longer lets `writes.step` write; the launch with the fresh context in its input otherwise; the launch
|
|
147
|
+
* as it is, said in a line, when the context cannot be read.
|
|
148
|
+
*/
|
|
149
|
+
export async function writingHop(
|
|
150
|
+
launch: ChainLaunch, read: () => Promise<PullRequestContext>, writes: { step: string; what: string },
|
|
151
|
+
): Promise<ChainStep> {
|
|
152
|
+
const context = await freshContext(read);
|
|
153
|
+
if (context === null) return { lines: [CONTEXT_NOT_READ_LINE], launch };
|
|
154
|
+
const refusal = writeModeRefusal(context.permissionMode, writes.step, writes.what);
|
|
155
|
+
if (refusal !== null) return { lines: [refusal, `then type ${launch.instead}`] };
|
|
156
|
+
return { lines: [], launch: { ...launch, input: withContext(launch.input, context) } };
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* What `completed` prints for one answer of the chain, and the launch that follows. No dispatch runs before a
|
|
161
|
+
* chained launch: the gate is checked and the step's rules put back by `reapply`, whose refusal launches nothing;
|
|
162
|
+
* the close then reads the session's context again (writingHop); the audit is launched as the crew named it.
|
|
163
|
+
*/
|
|
164
|
+
export async function nextLaunch(result: CrewCompletion, deps: ChainHopDeps): Promise<ChainStep> {
|
|
165
|
+
if (!result.success) return { lines: [`✗ the batch's chain failed: ${result.error ?? "unknown"}`] };
|
|
166
|
+
const step = chainStep(String(result.payload ?? ""));
|
|
167
|
+
if (step.launch === undefined) return step;
|
|
168
|
+
const refusal = deps.reapply(step.launch.crew === "dev-verify" ? "dev-verify" : "dev-implement");
|
|
169
|
+
if (refusal !== null) return { lines: [...step.lines, `✗ ${refusal}`, `then type ${step.launch.instead}`] };
|
|
170
|
+
if (step.launch.crew !== "dev-implement") return step;
|
|
171
|
+
const hop = await writingHop(step.launch, deps.context, CLOSE_WRITES);
|
|
172
|
+
return hop.launch === undefined ? { lines: [...step.lines, ...hop.lines] } : { lines: [...step.lines, ...hop.lines], launch: hop.launch };
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** The lines a chained launch leaves: none once launched; its refusal or its failure, and the command to type instead.
|
|
176
|
+
* `options` go to the launch as they are (`{ chain: "continue" }` for a driver that relaunches itself). */
|
|
177
|
+
export function launchChained(
|
|
178
|
+
launch: ChainLaunch,
|
|
179
|
+
run: (crew: string, input: Record<string, unknown>, options?: CrewLaunchOptions) => LaunchResult,
|
|
180
|
+
options?: CrewLaunchOptions,
|
|
181
|
+
): string[] {
|
|
182
|
+
try {
|
|
183
|
+
const launched = run(launch.crew, launch.input, options);
|
|
184
|
+
return "refused" in launched ? [`✗ ${launched.refused}`, `then type ${launch.instead}`] : [];
|
|
185
|
+
} catch (e) {
|
|
186
|
+
return [`✗ ${launch.crew} could not be launched (${String((e as Error)?.message ?? e).split("\n")[0]}): type ${launch.instead}`];
|
|
187
|
+
}
|
|
188
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// The arguments of /dev-spec and of its alias /dev-change, read from the line the REPL hands over (quotes kept, so a
|
|
2
|
+
// --run command stays whole). A code first, then a kind (bug, refactor or perf: a change brief, run by the dev-change
|
|
3
|
+
// crew), a --run "<command>" after the kind and before the text, and the rest as one text: the brief, the origin or a
|
|
4
|
+
// revision request. Without a kind the line is a spec, run by the dev-spec crew, and --run is refused. Typed as
|
|
5
|
+
// /dev-change (the alias), the line keeps that command's shape: always the dev-change crew, the kind optional on a
|
|
6
|
+
// revision of a brief (the crew checks it).
|
|
7
|
+
import { commandLine, isOption, splitWords } from "../args.ts";
|
|
8
|
+
import { isCode } from "../../../shared/domain/dev/artefacts.ts";
|
|
9
|
+
|
|
10
|
+
export const DEV_SPEC_USAGE =
|
|
11
|
+
'usage: /dev-spec <code> [bug | refactor | perf] [--run "<command>"] [<brief text> | <path>.md | <#issue> | <revision request>]';
|
|
12
|
+
export interface DevSpecArgs { code: string; request: string }
|
|
13
|
+
export interface DevChangeArgs { code: string; kind: string; run: string; text: string }
|
|
14
|
+
/** The crew the line runs, with its input: a spec without a kind, a change brief with one. */
|
|
15
|
+
export type DevSourceParse =
|
|
16
|
+
| { ok: true; crew: "dev-spec"; args: DevSpecArgs }
|
|
17
|
+
| { ok: true; crew: "dev-change"; args: DevChangeArgs }
|
|
18
|
+
| { ok: false; text: string };
|
|
19
|
+
|
|
20
|
+
const MAX_CODE = 64;
|
|
21
|
+
const KINDS = new Set(["bug", "refactor", "perf"]);
|
|
22
|
+
/** The alias that keeps /dev-change's own shape. */
|
|
23
|
+
export const DEV_CHANGE_ALIAS = "dev-change";
|
|
24
|
+
|
|
25
|
+
/** Why --run needs a kind, said where it is refused. */
|
|
26
|
+
export const RUN_NEEDS_KIND =
|
|
27
|
+
"--run goes with a kind: bug (the command that reproduces it) or perf (the command that measures it); a feature is a spec and runs nothing";
|
|
28
|
+
|
|
29
|
+
function codeOf(word: string | undefined): { ok: true; code: string } | { ok: false; text: string } {
|
|
30
|
+
if (word === undefined || word.trim() === "") return { ok: false, text: DEV_SPEC_USAGE };
|
|
31
|
+
if (word.length > MAX_CODE || !isCode(word)) return { ok: false, text: `'${word}' is not a code (letters, digits, '.', '_', '-')\n${DEV_SPEC_USAGE}` };
|
|
32
|
+
return { ok: true, code: word };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** The text after the word at `from`: what the person typed, as typed. */
|
|
36
|
+
const restOf = (line: string, words: ReturnType<typeof splitWords>, from: number): string =>
|
|
37
|
+
from >= words.length ? "" : line.slice(from === 0 ? 0 : words[from - 1].end).trim();
|
|
38
|
+
|
|
39
|
+
/** The line after /dev-spec (or `typed`, the name the person typed: /dev-change keeps its own shape). */
|
|
40
|
+
export function parseDevSpecArgs(tokens: readonly string[], typed = "dev-spec"): DevSourceParse {
|
|
41
|
+
const line = commandLine(tokens);
|
|
42
|
+
const words = splitWords(line);
|
|
43
|
+
const code = codeOf(words[0]?.text);
|
|
44
|
+
if (!code.ok) return code;
|
|
45
|
+
let at = 1;
|
|
46
|
+
let kind = "";
|
|
47
|
+
if (words[at] !== undefined && !words[at].quoted && KINDS.has(words[at].text)) { kind = words[at].text; at++; }
|
|
48
|
+
let run = "";
|
|
49
|
+
if (isOption(words[at])) {
|
|
50
|
+
if (words[at].text !== "--run") return { ok: false, text: `unknown option ${words[at].text}\n${DEV_SPEC_USAGE}` };
|
|
51
|
+
const value = words[at + 1];
|
|
52
|
+
if (value === undefined || isOption(value) || value.text.trim() === "") return { ok: false, text: `--run needs the command, quoted\n${DEV_SPEC_USAGE}` };
|
|
53
|
+
run = value.text.trim();
|
|
54
|
+
at += 2;
|
|
55
|
+
}
|
|
56
|
+
if (words.slice(at).some((w) => !w.quoted && w.text === "--run")) {
|
|
57
|
+
return { ok: false, text: `--run comes before the text\n${DEV_SPEC_USAGE}` };
|
|
58
|
+
}
|
|
59
|
+
const text = words.length === at + 1 && words[at].quoted ? words[at].text : restOf(line, words, at);
|
|
60
|
+
if (kind === "" && typed !== DEV_CHANGE_ALIAS) {
|
|
61
|
+
if (run !== "") return { ok: false, text: `${RUN_NEEDS_KIND}\n${DEV_SPEC_USAGE}` };
|
|
62
|
+
return { ok: true, crew: "dev-spec", args: { code: code.code, request: text } };
|
|
63
|
+
}
|
|
64
|
+
return { ok: true, crew: "dev-change", args: { code: code.code, kind, run, text } };
|
|
65
|
+
}
|
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
// /dev-status: where a piece of dev work stands, read from the files the dev workflow
|
|
2
|
+
// leaves in the work folder (the global plan, the batch sheets, the verdicts and the
|
|
3
|
+
// batches log). Read-only. The use case takes its ports and returns a CommandView;
|
|
4
|
+
// dev-status.cmd.ts wires the real ports and shows it.
|
|
5
|
+
import type { CommandView } from "../view.ts";
|
|
6
|
+
import type { CodeSummary, DevCode, DevContext, DevContextDeps } from "../../../shared/application/dev/load-dev-context.ts";
|
|
7
|
+
import { loadDevCode, loadDevContext, probeDevCodes } from "../../../shared/application/dev/load-dev-context.ts";
|
|
8
|
+
import { workFolderLabel } from "../../../shared/application/dev/resolve-work-folder.ts";
|
|
9
|
+
import { PROPOSAL_ID, runDevLearnDecision } from "../../../shared/application/dev/learn-decision.ts";
|
|
10
|
+
export { runDevLearnDecision };
|
|
11
|
+
export type { DevLearnDecisionDeps } from "../../../shared/application/dev/learn-decision.ts";
|
|
12
|
+
import { compareBatchIds, isCode } from "../../../shared/domain/dev/artefacts.ts";
|
|
13
|
+
import { sheetProgress } from "../../../shared/domain/dev/plan-format.ts";
|
|
14
|
+
import type { BatchState, PlanBatch } from "../../../shared/domain/dev/plan-format.ts";
|
|
15
|
+
import { lastVerdict, severityCounts } from "../../../shared/domain/dev/verdict-format.ts";
|
|
16
|
+
import { readPlanSource, resolvePlanSource } from "../../../shared/application/dev/plan-source.ts";
|
|
17
|
+
import { blockingStop } from "../../../shared/domain/dev/spec-format.ts";
|
|
18
|
+
|
|
19
|
+
export type DevStatusDeps = DevContextDeps;
|
|
20
|
+
export const DEV_STATUS_USAGE = "usage: /dev-status [<code>]";
|
|
21
|
+
const MAX_BATCH_LINES = 20;
|
|
22
|
+
export const MAX_WARNING_LINES = 5;
|
|
23
|
+
export const MAX_LINE_CHARS = 160;
|
|
24
|
+
|
|
25
|
+
const MAX_WARNING_CHARS = 200;
|
|
26
|
+
const MAX_NAME_CHARS = 40;
|
|
27
|
+
const MAX_CODES_LISTED = 30;
|
|
28
|
+
const MAX_CODE_ENTRY_CHARS = 60;
|
|
29
|
+
const TEXT_BUDGET = 3900;
|
|
30
|
+
const SHRUNK_BATCH_LINES = 15;
|
|
31
|
+
const SHRUNK_WARNING_LINES = 3;
|
|
32
|
+
|
|
33
|
+
const messageOf = (e: unknown): string => (e instanceof Error ? e.message : String(e));
|
|
34
|
+
|
|
35
|
+
function cut(text: string, max: number): string {
|
|
36
|
+
return text.length <= max ? text : `${text.slice(0, max - 1)}…`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function contextLines(ctx: DevContext): string[] {
|
|
40
|
+
const packShown = ctx.pack?.shown ?? null;
|
|
41
|
+
return [
|
|
42
|
+
cut(`work folder: ${workFolderLabel(ctx.work, packShown)}`, MAX_LINE_CHARS),
|
|
43
|
+
cut(`pack: ${packShown ?? "none"}`, MAX_LINE_CHARS),
|
|
44
|
+
];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function warningLines(warnings: readonly string[], max: number): string[] {
|
|
48
|
+
const shown = warnings.slice(0, max).map((w) => cut(`warning: ${w}`, MAX_WARNING_CHARS));
|
|
49
|
+
if (warnings.length > max) shown.push(`… ${warnings.length - max} more warnings`);
|
|
50
|
+
return shown;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function refusal(ctx: DevContext, text: string): CommandView {
|
|
54
|
+
return { lines: [...contextLines(ctx), ...warningLines(ctx.warnings, MAX_WARNING_LINES)], text };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function stateText(batch: PlanBatch | undefined): string {
|
|
58
|
+
if (!batch) return "not in the plan";
|
|
59
|
+
const s: BatchState = batch.state;
|
|
60
|
+
if (s.kind === "open") return "open";
|
|
61
|
+
if (s.kind === "done") return `done ${s.date}`;
|
|
62
|
+
return s.text;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function verdictText(code: DevCode, id: string): { text: string; valid: boolean } {
|
|
66
|
+
let section = null;
|
|
67
|
+
for (const v of code.verdicts) if (v.batch === id) section = lastVerdict(v.file) ?? section;
|
|
68
|
+
if (section === null || section.verdict === null) return { text: "no verdict", valid: false };
|
|
69
|
+
const head = [section.verdict, section.when, section.mode].filter((p) => p !== undefined && p !== "").join(" ");
|
|
70
|
+
const counts = severityCounts(section);
|
|
71
|
+
if (section.verdict === "VALID") {
|
|
72
|
+
return { text: counts.Minor > 0 ? `${head} (${counts.Minor} Minor)` : head, valid: true };
|
|
73
|
+
}
|
|
74
|
+
const gaps = [
|
|
75
|
+
counts.Blocking > 0 ? `${counts.Blocking} Blocking` : "",
|
|
76
|
+
counts.Major > 0 ? `${counts.Major} Major` : "",
|
|
77
|
+
].filter((p) => p !== "");
|
|
78
|
+
return { text: gaps.length > 0 ? `${head}: ${gaps.join(", ")}` : head, valid: false };
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function runningText(code: DevCode, id: string): string | null {
|
|
82
|
+
const state = code.state?.state;
|
|
83
|
+
if (!state || !state.open.includes(id)) return null;
|
|
84
|
+
const last = [...state.entries].reverse().find((e) => e.batch === id);
|
|
85
|
+
return last ? `running (${last.event} ${last.date} ${last.time})` : "running";
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** The batch lines (all of them) and the consistency warnings they raise. */
|
|
89
|
+
function batchLines(code: DevCode): { ids: string[]; lines: string[]; warnings: string[] } {
|
|
90
|
+
const planBatches = code.plan?.plan.batches ?? [];
|
|
91
|
+
const ids = [...new Set([
|
|
92
|
+
...planBatches.map((b) => b.id), ...code.sheets.map((s) => s.batch), ...code.verdicts.map((v) => v.batch),
|
|
93
|
+
])].filter((id) => id !== "").sort(compareBatchIds);
|
|
94
|
+
const lines: string[] = [];
|
|
95
|
+
const warnings: string[] = [];
|
|
96
|
+
for (const id of ids) {
|
|
97
|
+
const batch = planBatches.find((b) => b.id === id);
|
|
98
|
+
const sheet = code.sheets.find((s) => s.batch === id);
|
|
99
|
+
const name = cut(batch?.name ?? sheet?.sheet.name ?? "", MAX_NAME_CHARS);
|
|
100
|
+
const parts = [name === "" ? id : `${id} ${name}`, stateText(batch)];
|
|
101
|
+
if (batch) parts.push(`boxes ${batch.steps.filter((s) => s.done).length}/${batch.steps.length}`);
|
|
102
|
+
if (sheet) {
|
|
103
|
+
const p = sheetProgress(sheet.sheet);
|
|
104
|
+
const n = p.behaviourSteps;
|
|
105
|
+
parts.push(`sheet RED ${p.red}/${n} GREEN ${p.green}/${n} COST ${p.cost}/${n}`);
|
|
106
|
+
if (batch?.state.kind === "done" && p.complete < n) {
|
|
107
|
+
warnings.push(`${id} is done in the plan but its sheet has open ticks (RED ${p.red}/${n})`);
|
|
108
|
+
}
|
|
109
|
+
} else {
|
|
110
|
+
parts.push("no sheet");
|
|
111
|
+
}
|
|
112
|
+
const verdict = verdictText(code, id);
|
|
113
|
+
parts.push(verdict.text);
|
|
114
|
+
if (verdict.valid && batch?.state.kind === "open") warnings.push(`${id} is VALID but the plan still says open`);
|
|
115
|
+
const running = runningText(code, id);
|
|
116
|
+
if (running !== null) parts.push(running);
|
|
117
|
+
lines.push(cut(parts.join(" — "), MAX_LINE_CHARS));
|
|
118
|
+
}
|
|
119
|
+
if (code.plan) {
|
|
120
|
+
const planned = new Set(planBatches.map((b) => b.id));
|
|
121
|
+
for (const f of [...code.sheets, ...code.verdicts]) {
|
|
122
|
+
if (!planned.has(f.batch)) warnings.push(`${f.name} has no batch line in the plan`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return { ids, lines, warnings };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function codeLine(code: DevCode): string {
|
|
129
|
+
const what = code.spec !== null ? `spec ${code.spec}` : code.change !== null ? `change ${code.change}` : "no spec";
|
|
130
|
+
let plan = "no plan";
|
|
131
|
+
if (code.plan) {
|
|
132
|
+
const p = code.plan.plan;
|
|
133
|
+
const done = p.batches.filter((b) => b.state.kind === "done").length;
|
|
134
|
+
const feature = p.feature === undefined ? "" : ` "${p.feature}"`;
|
|
135
|
+
plan = `plan ${code.plan.name}${feature} (${p.batches.length} batches, ${done} done)`;
|
|
136
|
+
}
|
|
137
|
+
return cut(`code: ${code.shown}/ — ${what} — ${plan}`, MAX_LINE_CHARS);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** The lines of § 3.1; adds the consistency warnings to code.warnings. */
|
|
141
|
+
function renderDevStatus(ctx: DevContext, code: DevCode): string[] {
|
|
142
|
+
const batches = batchLines(code);
|
|
143
|
+
for (const w of batches.warnings) if (!code.warnings.includes(w)) code.warnings.push(w);
|
|
144
|
+
const warnings = [...ctx.warnings, ...code.warnings];
|
|
145
|
+
const head = [...contextLines(ctx), codeLine(code)];
|
|
146
|
+
|
|
147
|
+
const build = (maxBatches: number, maxWarnings: number): string[] => {
|
|
148
|
+
const out = [...head, ...batches.lines.slice(0, maxBatches)];
|
|
149
|
+
const hidden = batches.ids.slice(maxBatches);
|
|
150
|
+
if (hidden.length > 0) out.push(`… ${hidden.length} more batches (${hidden[0]} to ${hidden[hidden.length - 1]})`);
|
|
151
|
+
return [...out, ...warningLines(warnings, maxWarnings)];
|
|
152
|
+
};
|
|
153
|
+
const full = build(MAX_BATCH_LINES, MAX_WARNING_LINES);
|
|
154
|
+
return full.join("\n").length <= TEXT_BUDGET ? full : build(SHRUNK_BATCH_LINES, SHRUNK_WARNING_LINES);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function plural(n: number, word: string): string {
|
|
158
|
+
return `${n} ${word}${n === 1 ? "" : "s"}`;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function codeEntry(c: CodeSummary): string {
|
|
162
|
+
const what = [
|
|
163
|
+
c.spec ? "spec" : "", c.change ? "change" : "", c.plan ? "plan" : "",
|
|
164
|
+
c.sheets > 0 ? plural(c.sheets, "sheet") : "", c.verdicts > 0 ? plural(c.verdicts, "verdict") : "",
|
|
165
|
+
].filter((p) => p !== "");
|
|
166
|
+
return cut(`${c.code} — ${what.join(", ")}`, MAX_CODE_ENTRY_CHARS);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** The codes line of § 3.2: at most MAX_CODES_LISTED entries, fewer when the line would pass MAX_LINE_CHARS. */
|
|
170
|
+
function codesLine(codes: readonly CodeSummary[]): string {
|
|
171
|
+
const entries = codes.slice(0, MAX_CODES_LISTED).map(codeEntry);
|
|
172
|
+
const line = (k: number): string => {
|
|
173
|
+
const shown = entries.slice(0, k);
|
|
174
|
+
if (codes.length > k) shown.push(`… ${codes.length - k} more`);
|
|
175
|
+
return `codes (${codes.length}): ${shown.join(" · ")}`;
|
|
176
|
+
};
|
|
177
|
+
let k = entries.length;
|
|
178
|
+
while (k > 1 && line(k).length > MAX_LINE_CHARS) k--;
|
|
179
|
+
return cut(line(k), MAX_LINE_CHARS);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/** The lines of § 3.2; `notProbed` counts the folders the probe cap left out. */
|
|
183
|
+
function renderCodeList(ctx: DevContext, codes: readonly CodeSummary[], notProbed = 0): string[] {
|
|
184
|
+
const lines = contextLines(ctx);
|
|
185
|
+
if (codes.length === 0 && notProbed === 0) {
|
|
186
|
+
lines.push(`no code under ${ctx.work.folder}/ (a code is a folder holding SPEC-, CHANGE- or *-PLAN.md files)`);
|
|
187
|
+
} else {
|
|
188
|
+
if (codes.length > 0) lines.push(codesLine(codes));
|
|
189
|
+
if (notProbed > 0) lines.push(`… ${notProbed} more folders not probed`);
|
|
190
|
+
}
|
|
191
|
+
return [...lines, ...warningLines(ctx.warnings, MAX_WARNING_LINES)];
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export async function runDevStatus(tokens: readonly string[], deps: DevStatusDeps): Promise<CommandView> {
|
|
195
|
+
if (tokens.length > 1) return { text: DEV_STATUS_USAGE };
|
|
196
|
+
const ctx = await loadDevContext(deps);
|
|
197
|
+
const work = ctx.work;
|
|
198
|
+
const code = tokens[0];
|
|
199
|
+
if (code !== undefined && !isCode(code)) {
|
|
200
|
+
return refusal(ctx,
|
|
201
|
+
`dev-status: '${code}' is not a code: letters, digits, '.', '_' and '-', starting with a letter or a digit`);
|
|
202
|
+
}
|
|
203
|
+
const mainWorktree =
|
|
204
|
+
`dev-status: the work folder ${work.folder} is in the main worktree, outside the mounts: run /dev-status from the main checkout`;
|
|
205
|
+
if (work.outcome === "main-worktree") return refusal(ctx, mainWorktree);
|
|
206
|
+
|
|
207
|
+
if (code === undefined) {
|
|
208
|
+
let probe: { codes: CodeSummary[]; notProbed: number } = { codes: [], notProbed: 0 };
|
|
209
|
+
if (work.exists) {
|
|
210
|
+
try {
|
|
211
|
+
probe = await probeDevCodes(deps, work);
|
|
212
|
+
} catch (e) {
|
|
213
|
+
return refusal(ctx, `dev-status: ${work.folder}/ cannot be listed (${messageOf(e).split("\n")[0]})`);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return { lines: renderCodeList(ctx, probe.codes, probe.notProbed) };
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const lookup = await loadDevCode(deps, work, code);
|
|
220
|
+
if (lookup.found !== null) return { lines: renderDevStatus(ctx, lookup.found) };
|
|
221
|
+
if (lookup.reason === "unreachable") return refusal(ctx, mainWorktree);
|
|
222
|
+
if (lookup.reason === "empty") {
|
|
223
|
+
return refusal(ctx, `dev-status: ${work.folder}/${code}/ holds no SPEC-, CHANGE- or *-PLAN.md file`);
|
|
224
|
+
}
|
|
225
|
+
const here = lookup.codes.length > 0 ? `codes here: ${lookup.codes.join(", ")}` : "no code here";
|
|
226
|
+
return refusal(ctx, `dev-status: no folder ${work.folder}/${code}/ (${here})`);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// /dev-learn: the arguments, and the two decisions (--accept, --refuse). Proposing and
|
|
230
|
+
// listing read every verdict file, so they run in crews/dev-learn; a decision is a few
|
|
231
|
+
// reads and one or two writes, answered by the command itself through
|
|
232
|
+
// shared/application/dev/learn-decision.ts (re-exported here). Nothing there edits the
|
|
233
|
+
// file a proposal names: --accept prints the change to make.
|
|
234
|
+
export const DEV_LEARN_USAGE = "usage: /dev-learn [<axis>] [--list] | --accept <id>[,<id>…] | --refuse <id | motif text>";
|
|
235
|
+
export type DevLearnArgs =
|
|
236
|
+
| { kind: "propose"; axis: string | null }
|
|
237
|
+
| { kind: "list"; axis: string | null }
|
|
238
|
+
| { kind: "accept"; ids: string[] }
|
|
239
|
+
| { kind: "refuse"; target: string };
|
|
240
|
+
|
|
241
|
+
const MAX_AXIS_CHARS = 40;
|
|
242
|
+
const MAX_REFUSED_CHARS = 200;
|
|
243
|
+
const ALONE = "dev-learn: --accept and --refuse each come alone";
|
|
244
|
+
|
|
245
|
+
type DevLearnParse = { ok: true; args: DevLearnArgs } | { ok: false; text: string };
|
|
246
|
+
|
|
247
|
+
function parseAcceptIds(rest: readonly string[]): DevLearnParse {
|
|
248
|
+
const ids: string[] = [];
|
|
249
|
+
for (const tok of rest) {
|
|
250
|
+
if (tok === "--refuse" || tok === "--accept" || tok === "--list") return { ok: false, text: ALONE };
|
|
251
|
+
for (const piece of tok.split(",")) {
|
|
252
|
+
if (piece === "") continue;
|
|
253
|
+
const id = piece.toLowerCase();
|
|
254
|
+
if (!PROPOSAL_ID.test(id)) {
|
|
255
|
+
return { ok: false, text: `dev-learn: '${piece}' is not a proposal id (8 or 10 hex digits, from PROPOSALS.md)` };
|
|
256
|
+
}
|
|
257
|
+
ids.push(id);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
if (ids.length === 0) return { ok: false, text: "dev-learn: --accept needs at least one proposal id, e.g. --accept 3f2a9c1e" };
|
|
261
|
+
return { ok: true, args: { kind: "accept", ids } };
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function parseRefuseTarget(rest: readonly string[]): DevLearnParse {
|
|
265
|
+
if (rest.includes("--accept") || rest.includes("--refuse") || rest.includes("--list")) return { ok: false, text: ALONE };
|
|
266
|
+
const joined = rest.join(" ").trim();
|
|
267
|
+
// An id is read as one whatever its case, as --accept reads it; the motif's words keep theirs.
|
|
268
|
+
const target = PROPOSAL_ID.test(joined.toLowerCase()) ? joined.toLowerCase() : joined;
|
|
269
|
+
if (target === "") return { ok: false, text: "dev-learn: --refuse needs a proposal id or the motif's words" };
|
|
270
|
+
if (Array.from(target).length > MAX_REFUSED_CHARS) return { ok: false, text: "dev-learn: a refused motif is at most 200 characters" };
|
|
271
|
+
return { ok: true, args: { kind: "refuse", target } };
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/** `--accept` and `--refuse` take the rest of the line; `--list` is a flag; one other word is the axis. */
|
|
275
|
+
export function parseDevLearnArgs(tokens: readonly string[]): DevLearnParse {
|
|
276
|
+
let axis: string | null = null;
|
|
277
|
+
let list = false;
|
|
278
|
+
for (const [i, tok] of tokens.entries()) {
|
|
279
|
+
if (tok === "--accept" || tok === "--refuse") {
|
|
280
|
+
if (axis !== null || list) return { ok: false, text: ALONE };
|
|
281
|
+
const rest = tokens.slice(i + 1);
|
|
282
|
+
return tok === "--accept" ? parseAcceptIds(rest) : parseRefuseTarget(rest);
|
|
283
|
+
}
|
|
284
|
+
if (tok === "--list") {
|
|
285
|
+
list = true;
|
|
286
|
+
} else if (tok.startsWith("--")) {
|
|
287
|
+
return { ok: false, text: `dev-learn: unknown option '${tok}' (--list, --accept, --refuse)` };
|
|
288
|
+
} else if (axis !== null) {
|
|
289
|
+
return { ok: false, text: `dev-learn: one axis at most, not '${axis}' and '${tok}'` };
|
|
290
|
+
} else if (tok.includes("|") || /[\r\n]/.test(tok) || Array.from(tok).length > MAX_AXIS_CHARS) {
|
|
291
|
+
return { ok: false, text: `dev-learn: '${tok}' is not an axis` };
|
|
292
|
+
} else {
|
|
293
|
+
axis = tok;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
return { ok: true, args: list ? { kind: "list", axis } : { kind: "propose", axis } };
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// files and the review run in crews/dev-plan, which runs the same gate again.
|
|
300
|
+
export const DEV_PLAN_USAGE = "usage: /dev-plan [<code> | <path>/SPEC-<code>.md | <path>/CHANGE-<code>.md] [--replace]";
|
|
301
|
+
export interface DevPlanArgs { source: string | null; replace: boolean }
|
|
302
|
+
export type DevPlanGateDeps = DevContextDeps;
|
|
303
|
+
|
|
304
|
+
/** A spec or change brief named by its path: ends .md, with no ".." segment (plan-source checks the name). */
|
|
305
|
+
function isSourcePath(token: string): boolean {
|
|
306
|
+
return token.endsWith(".md") && !token.split("/").includes("..");
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/** At most one source (a code or a .md path) and the flag --replace, in any order. */
|
|
310
|
+
export function parseDevPlanArgs(tokens: readonly string[]): { ok: true; args: DevPlanArgs } | { ok: false; text: string } {
|
|
311
|
+
let source: string | null = null;
|
|
312
|
+
let replace = false;
|
|
313
|
+
for (const tok of tokens) {
|
|
314
|
+
if (tok === "--replace") {
|
|
315
|
+
if (replace) return { ok: false, text: "dev-plan: --replace once at most" };
|
|
316
|
+
replace = true;
|
|
317
|
+
} else if (tok.startsWith("--")) {
|
|
318
|
+
return { ok: false, text: `dev-plan: unknown option '${tok}' (only --replace)` };
|
|
319
|
+
} else if (isCode(tok) || isSourcePath(tok)) {
|
|
320
|
+
if (source !== null) return { ok: false, text: `dev-plan: one source at most, not '${source}' and '${tok}'` };
|
|
321
|
+
source = tok;
|
|
322
|
+
} else {
|
|
323
|
+
return { ok: false, text: `dev-plan: '${tok}' is neither a code nor a SPEC-<code>.md / CHANGE-<code>.md path` };
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
return { ok: true, args: { source, replace } };
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/** The Blocking gate, in the handler: null to launch the crew, else the message to print. */
|
|
330
|
+
export async function devPlanGate(args: DevPlanArgs, deps: DevPlanGateDeps): Promise<string | null> {
|
|
331
|
+
try {
|
|
332
|
+
const ctx = await loadDevContext(deps);
|
|
333
|
+
const resolution = await resolvePlanSource(deps.files, ctx.work, args.source);
|
|
334
|
+
if (!resolution.ok) return resolution.text;
|
|
335
|
+
const source = resolution.source;
|
|
336
|
+
const read = await readPlanSource(deps.files, source);
|
|
337
|
+
if (!read.ok) return read.text;
|
|
338
|
+
const rows = read.parsed.blocking;
|
|
339
|
+
return rows.length === 0 ? null : blockingStop(source.sourceShown, source.kind, source.code, rows);
|
|
340
|
+
} catch {
|
|
341
|
+
// The crew runs the same checks and reports what went wrong; the handler never fails on its own gate.
|
|
342
|
+
return null;
|
|
343
|
+
}
|
|
344
|
+
}
|