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,112 @@
|
|
|
1
|
+
// Which spec or change brief a /dev-plan run plans, and its text: the token the user typed
|
|
2
|
+
// (a work code, a path, or nothing) resolved against the work folder, then the file read
|
|
3
|
+
// and parsed. It reads listings and one file; it writes nothing. Every refusal is a text
|
|
4
|
+
// the command and the crew print as they are.
|
|
5
|
+
import type { Files } from "../ports.ts";
|
|
6
|
+
import type { WorkFolder } from "./resolve-work-folder.ts";
|
|
7
|
+
import { listDevCodes } from "./load-dev-context.ts";
|
|
8
|
+
import { classifyArtefact, isCode } from "../../domain/dev/artefacts.ts";
|
|
9
|
+
import { parsePlanSource } from "../../domain/dev/spec-format.ts";
|
|
10
|
+
import type { PlanSource, SourceKind } from "../../domain/dev/spec-format.ts";
|
|
11
|
+
import { WORKSPACE } from "../../domain/vfs.ts";
|
|
12
|
+
|
|
13
|
+
export interface ResolvedSource {
|
|
14
|
+
kind: SourceKind;
|
|
15
|
+
code: string; // "prune"
|
|
16
|
+
prefix: string; // code.toUpperCase(): the <CODE> of the file names, "PRUNE"
|
|
17
|
+
folderShown: string; // "workbench/prune"
|
|
18
|
+
sourceShown: string; // "workbench/prune/SPEC-prune.md"
|
|
19
|
+
}
|
|
20
|
+
export const MAX_SOURCE_CHARS = 200_000;
|
|
21
|
+
|
|
22
|
+
type Resolution = { ok: true; source: ResolvedSource } | { ok: false; text: string };
|
|
23
|
+
|
|
24
|
+
const LIST_CAP = 500;
|
|
25
|
+
const firstLine = (e: unknown): string => (e instanceof Error ? e.message : String(e)).split("\n")[0];
|
|
26
|
+
const refuse = (text: string): Resolution => ({ ok: false, text });
|
|
27
|
+
|
|
28
|
+
function resolved(kind: SourceKind, code: string, folderShown: string, fileName: string): Resolution {
|
|
29
|
+
const sourceShown = folderShown === "" ? fileName : `${folderShown}/${fileName}`;
|
|
30
|
+
return { ok: true, source: { kind, code, prefix: code.toUpperCase(), folderShown, sourceShown } };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** The spec or the brief of one code folder, found by listing it. */
|
|
34
|
+
async function byCode(files: Pick<Files, "list">, work: WorkFolder, vfsPath: string, code: string): Promise<Resolution> {
|
|
35
|
+
let names: string[];
|
|
36
|
+
try {
|
|
37
|
+
names = await files.list(`${vfsPath}/${code}`, LIST_CAP);
|
|
38
|
+
} catch {
|
|
39
|
+
names = [];
|
|
40
|
+
}
|
|
41
|
+
const spec = names.includes(`SPEC-${code}.md`);
|
|
42
|
+
const change = names.includes(`CHANGE-${code}.md`);
|
|
43
|
+
const shown = `${work.folder}/${code}`;
|
|
44
|
+
if (spec && change) return refuse(`dev-plan: ${shown}/ holds both SPEC-${code}.md and CHANGE-${code}.md: name the file`);
|
|
45
|
+
if (!spec && !change) return refuse(`dev-plan: ${shown}/ holds no SPEC-${code}.md nor CHANGE-${code}.md`);
|
|
46
|
+
return resolved(spec ? "spec" : "change", code, shown, spec ? `SPEC-${code}.md` : `CHANGE-${code}.md`);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** A path relative to the checkout, or under /workspace/, naming a spec or a brief. */
|
|
50
|
+
function byPath(token: string): Resolution {
|
|
51
|
+
const notSource = refuse(`dev-plan: '${token}' is neither a code nor a SPEC-<code>.md / CHANGE-<code>.md path`);
|
|
52
|
+
let relative = token.replace(/^\.\//, "");
|
|
53
|
+
if (relative.startsWith("/")) {
|
|
54
|
+
if (!relative.startsWith(`${WORKSPACE}/`)) return notSource;
|
|
55
|
+
relative = relative.slice(WORKSPACE.length + 1);
|
|
56
|
+
}
|
|
57
|
+
// `/workspace/./.claude/x` and `/workspace//.claude/x` name `.claude/x`: the `.` and empty segments go first.
|
|
58
|
+
const segments = relative.split("/").filter((s) => s !== "" && s !== ".");
|
|
59
|
+
if (segments.some((s) => s === "..")) return notSource;
|
|
60
|
+
const fileName = segments.at(-1) ?? "";
|
|
61
|
+
const artefact = classifyArtefact(fileName);
|
|
62
|
+
if (artefact === null || (artefact.kind !== "spec" && artefact.kind !== "change") || !isCode(artefact.prefix)) return notSource;
|
|
63
|
+
if (segments[0] === ".claude") {
|
|
64
|
+
return refuse("dev-plan: a source under .claude/ is the harness's own: copy it to the work folder first");
|
|
65
|
+
}
|
|
66
|
+
return resolved(artefact.kind, artefact.prefix, segments.slice(0, -1).join("/"), fileName);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const looksLikePath = (token: string): boolean => {
|
|
70
|
+
const kind = classifyArtefact(token.slice(token.lastIndexOf("/") + 1))?.kind;
|
|
71
|
+
return token.includes("/") || kind === "spec" || kind === "change";
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/** The source the token names (a code, a path, or nothing); the refusal text otherwise. */
|
|
75
|
+
export async function resolvePlanSource(
|
|
76
|
+
files: Pick<Files, "list" | "read">, work: WorkFolder, token: string | null,
|
|
77
|
+
): Promise<{ ok: true; source: ResolvedSource } | { ok: false; text: string }> {
|
|
78
|
+
if (work.vfsPath === null) {
|
|
79
|
+
return refuse(`dev-plan: the work folder ${work.folder} is outside ${WORKSPACE}: run /dev-plan from the main worktree`);
|
|
80
|
+
}
|
|
81
|
+
if (token !== null && looksLikePath(token)) return byPath(token);
|
|
82
|
+
if (token !== null) {
|
|
83
|
+
if (!isCode(token)) return byPath(token);
|
|
84
|
+
return byCode(files, work, work.vfsPath, token);
|
|
85
|
+
}
|
|
86
|
+
let codes: string[];
|
|
87
|
+
try {
|
|
88
|
+
codes = (await listDevCodes({ files }, work)).filter((c) => (c.spec || c.change) && !c.plan).map((c) => c.code);
|
|
89
|
+
} catch {
|
|
90
|
+
codes = [];
|
|
91
|
+
}
|
|
92
|
+
if (codes.length === 0) {
|
|
93
|
+
return refuse(`dev-plan: no SPEC- or CHANGE- file without a plan in ${work.folder}/: name one, e.g. /dev-plan <code>`);
|
|
94
|
+
}
|
|
95
|
+
if (codes.length > 1) {
|
|
96
|
+
return refuse(`dev-plan: several codes could be planned (${codes.join(", ")}): name one, e.g. /dev-plan ${codes[0]}`);
|
|
97
|
+
}
|
|
98
|
+
return byCode(files, work, work.vfsPath, codes[0]);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** Reads the source (≤ MAX_SOURCE_CHARS) and parses it; the refusal text when it cannot be read. */
|
|
102
|
+
export async function readPlanSource(
|
|
103
|
+
files: Pick<Files, "read">, source: ResolvedSource,
|
|
104
|
+
): Promise<{ ok: true; text: string; parsed: PlanSource } | { ok: false; text: string }> {
|
|
105
|
+
let text: string;
|
|
106
|
+
try {
|
|
107
|
+
text = await files.read(`${WORKSPACE}/${source.sourceShown}`, MAX_SOURCE_CHARS);
|
|
108
|
+
} catch (e) {
|
|
109
|
+
return { ok: false, text: `dev-plan: ${source.sourceShown} cannot be read (${firstLine(e)})` };
|
|
110
|
+
}
|
|
111
|
+
return { ok: true, text, parsed: parsePlanSource(text, source.kind) };
|
|
112
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// The preflight of a /dev-batches run, before it launches a batch: one line per check. The plan read
|
|
2
|
+
// without format problems, a sheet for every batch not done, an order the dependencies allow, git's
|
|
3
|
+
// identity (each batch's close commits) and a current branch. A ✗ stops the run before any launch; a
|
|
4
|
+
// tree changed outside the work folder and `.orkeon/` is a ⚠ only (a close commits the files its batch
|
|
5
|
+
// touched, by name). The plan's facts come read; git is asked here.
|
|
6
|
+
import type { Shell } from "../ports.ts";
|
|
7
|
+
import { readIdentity, runGit } from "../git/commit-files.ts";
|
|
8
|
+
import { GIT_CURRENT_BRANCH_COMMAND, GIT_STATUS_COMMAND, changedPaths } from "../../domain/git/close.ts";
|
|
9
|
+
|
|
10
|
+
export interface PreflightInput {
|
|
11
|
+
/** The plan as the user reads it, `workbench/demo/DEMO-PLAN.md`; null when the code has none. */
|
|
12
|
+
planShown: string | null;
|
|
13
|
+
/** The format problems read in the plan and its sheets. */
|
|
14
|
+
problems: readonly string[];
|
|
15
|
+
batches: number;
|
|
16
|
+
/** The batches not done that have no sheet. */
|
|
17
|
+
missingSheets: readonly string[];
|
|
18
|
+
/** The order the dependencies allow, or why there is none. */
|
|
19
|
+
order: { ok: true; order: readonly string[] } | { ok: false; problem: string };
|
|
20
|
+
/** The work folder, relative to the checkout: its changes are the workflow's own. */
|
|
21
|
+
workFolder: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface PreflightResult { ok: boolean; lines: string[] }
|
|
25
|
+
|
|
26
|
+
const MAX_LISTED = 5;
|
|
27
|
+
|
|
28
|
+
function listed(items: readonly string[]): string {
|
|
29
|
+
return items.length <= MAX_LISTED ? items.join(", ") : `${items.slice(0, MAX_LISTED).join(", ")} and ${items.length - MAX_LISTED} more`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export async function preflight(deps: { shell: Pick<Shell, "run"> }, input: PreflightInput): Promise<PreflightResult> {
|
|
33
|
+
const lines: string[] = [];
|
|
34
|
+
let ok = true;
|
|
35
|
+
const fail = (line: string): void => { ok = false; lines.push(`preflight ✗ ${line}`); };
|
|
36
|
+
|
|
37
|
+
if (input.planShown === null) fail("plan: none in the code's folder: /dev-plan first");
|
|
38
|
+
else if (input.problems.length > 0) fail(`plan: ${input.problems.length} format problem(s): ${listed(input.problems)}`);
|
|
39
|
+
else lines.push(`preflight ✓ plan: ${input.planShown} (${input.batches} batch(es))`);
|
|
40
|
+
|
|
41
|
+
if (input.missingSheets.length > 0) fail(`sheets: no sheet for ${input.missingSheets.join(", ")}`);
|
|
42
|
+
else lines.push("preflight ✓ sheets: one for every batch not done");
|
|
43
|
+
|
|
44
|
+
if (!input.order.ok) fail(`order: ${input.order.problem}`);
|
|
45
|
+
else lines.push(`preflight ✓ order: ${input.order.order.join(" → ") || "(no batch)"}`);
|
|
46
|
+
|
|
47
|
+
const identity = await readIdentity(deps.shell);
|
|
48
|
+
// A Bubblewrap shell runs with HOME=/tmp and a cleared environment: only the repository's own
|
|
49
|
+
// configuration reaches git there, so the hint names it.
|
|
50
|
+
if (!identity.ok) {
|
|
51
|
+
fail(`git identity: ${identity.detail} (each batch's close commits): git config user.name and user.email in the repository ` +
|
|
52
|
+
"(a confined shell reads no --global file)");
|
|
53
|
+
}
|
|
54
|
+
else lines.push(`preflight ✓ git identity: ${identity.ident.name} <${identity.ident.email}>`);
|
|
55
|
+
|
|
56
|
+
const branch = await runGit(deps.shell, GIT_CURRENT_BRANCH_COMMAND);
|
|
57
|
+
const name = branch.exitCode === 0 ? branch.stdout.trim() : "";
|
|
58
|
+
if (name === "") fail("branch: none checked out (a detached HEAD?): check out the work branch");
|
|
59
|
+
else lines.push(`preflight ✓ branch: ${name}`);
|
|
60
|
+
|
|
61
|
+
const status = await runGit(deps.shell, GIT_STATUS_COMMAND);
|
|
62
|
+
if (status.exitCode === 0) {
|
|
63
|
+
const work = input.workFolder.replace(/\/+$/, "");
|
|
64
|
+
const own = (p: string): boolean => p === work || p.startsWith(`${work}/`) || p.startsWith(".orkeon/");
|
|
65
|
+
const others = changedPaths(status.stdout).filter((p) => !own(p));
|
|
66
|
+
if (others.length > 0) {
|
|
67
|
+
lines.push(`preflight ⚠ tree: ${others.length} change(s) outside the work folder (${listed(others)}): a close commits only its batch's files`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return { ok, lines };
|
|
71
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// The project's files, read with git for the briefs that list them (the audit's, the next batch's review's):
|
|
2
|
+
// tracked and untracked files alike, the ignored ones aside, under the shell's own root (a batch's worktree
|
|
3
|
+
// when the shell is rooted). A git that fails or throws lists nothing: the brief then carries no list.
|
|
4
|
+
import type { Shell } from "../ports.ts";
|
|
5
|
+
import { parseTrackedFiles } from "../../domain/dev/project-files.ts";
|
|
6
|
+
|
|
7
|
+
/** The listing: the tracked files and the untracked ones git does not ignore. */
|
|
8
|
+
export const PROJECT_FILES_COMMAND = "git ls-files --cached --others --exclude-standard";
|
|
9
|
+
|
|
10
|
+
export async function listProjectFiles(shell: Pick<Shell, "run">, work: string): Promise<string[]> {
|
|
11
|
+
try {
|
|
12
|
+
const r = await shell.run(PROJECT_FILES_COMMAND);
|
|
13
|
+
return r.exitCode === 0 ? parseTrackedFiles(r.stdout, work) : [];
|
|
14
|
+
} catch {
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// One round of questions on a written spec or change brief: the questions asked one at a time (settleQuestions),
|
|
2
|
+
// the file's open-questions and decisions sections rewritten and written after each answer, then - when anything
|
|
3
|
+
// was decided - one fold: the caller's model call rewrites the body with the decisions, and the folded file is
|
|
4
|
+
// written. A fold that fails leaves the decisions recorded in their section and says so in a warning: an answer a
|
|
5
|
+
// person gave is never lost.
|
|
6
|
+
import type { HumanInput } from "../ports.ts";
|
|
7
|
+
import { withQuestionSections } from "../../domain/dev/questions.ts";
|
|
8
|
+
import type { Decision, Question } from "../../domain/dev/questions.ts";
|
|
9
|
+
import { settleQuestions } from "./settle-questions.ts";
|
|
10
|
+
|
|
11
|
+
export interface RoundState { text: string; open: Question[]; decisions: Decision[] }
|
|
12
|
+
export type Folded = { ok: true; text: string; open: Question[] } | { ok: false; problems: string[] };
|
|
13
|
+
|
|
14
|
+
export interface RoundDeps {
|
|
15
|
+
human: HumanInput;
|
|
16
|
+
today: string;
|
|
17
|
+
/** The label of each question ("dev-spec prune"). */
|
|
18
|
+
label: string;
|
|
19
|
+
/** The headings the two sections are written under ("## 12. Open questions", "## 13. Decisions"). */
|
|
20
|
+
headings: { questions: string; decisions: string };
|
|
21
|
+
write: (text: string) => Promise<void>;
|
|
22
|
+
/** Rewrites the body with the decisions of the round; `open` are the questions still open. */
|
|
23
|
+
fold: (state: RoundState, fresh: readonly Decision[]) => Promise<Folded>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface RoundOutcome { state: RoundState; made: Decision[]; blocked: boolean; warnings: string[] }
|
|
27
|
+
|
|
28
|
+
export async function questionRound(
|
|
29
|
+
state: RoundState, deps: RoundDeps, which: (q: Question) => boolean = () => true,
|
|
30
|
+
): Promise<RoundOutcome> {
|
|
31
|
+
let text = state.text;
|
|
32
|
+
const settled = await settleQuestions(deps.label, state.open, state.decisions, {
|
|
33
|
+
human: deps.human, today: deps.today,
|
|
34
|
+
save: async (open, decisions) => {
|
|
35
|
+
text = withQuestionSections(text, open, decisions, deps.headings);
|
|
36
|
+
await deps.write(text);
|
|
37
|
+
},
|
|
38
|
+
}, which);
|
|
39
|
+
let next: RoundState = { text, open: settled.open, decisions: settled.decisions };
|
|
40
|
+
const warnings: string[] = [];
|
|
41
|
+
if (settled.made.length > 0) {
|
|
42
|
+
const folded = await deps.fold(next, settled.made);
|
|
43
|
+
if (folded.ok) {
|
|
44
|
+
next = { ...next, text: folded.text, open: folded.open };
|
|
45
|
+
await deps.write(folded.text);
|
|
46
|
+
} else {
|
|
47
|
+
warnings.push(`the body does not say the decisions yet (${folded.problems[0] ?? "the rewrite was refused"}); ` +
|
|
48
|
+
"they are recorded under Decisions");
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return { state: next, made: settled.made, blocked: settled.blocked, warnings };
|
|
52
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
// Resolves the work folder of the checkout from the request that applies (the
|
|
2
|
+
// dev.workDir config key, else the pack's layout.work; see pickWorkDirRequest),
|
|
3
|
+
// with the outcomes of the harness's own resolution: the default, the folder
|
|
4
|
+
// asked, an absent or invalid request falling back to the default with a note,
|
|
5
|
+
// and the case of a secondary worktree, where the folder found in the primary
|
|
6
|
+
// checkout applies. It reads directory listings and runs git; it creates nothing.
|
|
7
|
+
|
|
8
|
+
import type { Files, Shell } from "../ports.ts";
|
|
9
|
+
import type { WorkDirRequest } from "../../domain/dev/work-folder.ts";
|
|
10
|
+
import {
|
|
11
|
+
DEFAULT_WORK_FOLDER, isSamePath, mainWorktreeOf, normalizeWorkDir,
|
|
12
|
+
} from "../../domain/dev/work-folder.ts";
|
|
13
|
+
import { WORKSPACE } from "../../domain/vfs.ts";
|
|
14
|
+
|
|
15
|
+
export const GIT_WORKTREE_LIST = "git worktree list --porcelain";
|
|
16
|
+
export const GIT_TOPLEVEL = "git rev-parse --show-toplevel";
|
|
17
|
+
|
|
18
|
+
/** `git -C <folder> rev-parse --git-dir`: exit 0 iff the folder exists (inside the repository). */
|
|
19
|
+
export function gitDirProbe(absoluteFolder: string): string {
|
|
20
|
+
return `git -C ${absoluteFolder} rev-parse --git-dir`;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type WorkFolderOutcome = "default" | "applied" | "absent" | "invalid" | "main-worktree";
|
|
24
|
+
|
|
25
|
+
export interface WorkFolder {
|
|
26
|
+
/** "workbench", "backstage/tasks", or the main worktree's absolute folder. */
|
|
27
|
+
folder: string;
|
|
28
|
+
/** "/workspace/<folder>"; null for "main-worktree" (outside the mounts). */
|
|
29
|
+
vfsPath: string | null;
|
|
30
|
+
outcome: WorkFolderOutcome;
|
|
31
|
+
request: WorkDirRequest | null;
|
|
32
|
+
exists: boolean;
|
|
33
|
+
/** A warning text, null when nothing to say. */
|
|
34
|
+
note: string | null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Characters a path must not hold to go unquoted into the probe's command line. */
|
|
38
|
+
const UNSAFE_FOR_SHELL = /[\s'"`$\;&|<>()*?[\]{}!#~]/;
|
|
39
|
+
|
|
40
|
+
/** True when the parent's listing (cap 1000) holds the last segment; a listing that throws = false. */
|
|
41
|
+
export async function entryExists(files: Pick<Files, "list">, vfsPath: string): Promise<boolean> {
|
|
42
|
+
const path = vfsPath.replace(/\/+$/, "");
|
|
43
|
+
const cut = path.lastIndexOf("/");
|
|
44
|
+
if (cut < 0) return false;
|
|
45
|
+
const parent = cut === 0 ? "/" : path.slice(0, cut);
|
|
46
|
+
const name = path.slice(cut + 1);
|
|
47
|
+
if (name === "") return false;
|
|
48
|
+
try {
|
|
49
|
+
const entries = await files.list(parent, 1000);
|
|
50
|
+
return entries.some((e) => e === name || e === `${name}/`);
|
|
51
|
+
} catch {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async function gitStdout(shell: Pick<Shell, "run">, command: string): Promise<string | null> {
|
|
57
|
+
try {
|
|
58
|
+
const result = await shell.run(command);
|
|
59
|
+
return result.exitCode === 0 ? result.stdout : null;
|
|
60
|
+
} catch {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async function probeSucceeds(shell: Pick<Shell, "run">, command: string): Promise<boolean> {
|
|
66
|
+
try {
|
|
67
|
+
return (await shell.run(command)).exitCode === 0;
|
|
68
|
+
} catch {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export async function resolveWorkFolder(
|
|
74
|
+
deps: { files: Pick<Files, "list">; shell: Pick<Shell, "run"> },
|
|
75
|
+
request: WorkDirRequest | null,
|
|
76
|
+
): Promise<WorkFolder> {
|
|
77
|
+
const defaultVfs = `${WORKSPACE}/${DEFAULT_WORK_FOLDER}`;
|
|
78
|
+
const fallback = async (outcome: WorkFolderOutcome, note: string | null): Promise<WorkFolder> => ({
|
|
79
|
+
folder: DEFAULT_WORK_FOLDER,
|
|
80
|
+
vfsPath: defaultVfs,
|
|
81
|
+
outcome,
|
|
82
|
+
request,
|
|
83
|
+
exists: await entryExists(deps.files, defaultVfs),
|
|
84
|
+
note,
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
if (request === null) return fallback("default", null);
|
|
88
|
+
const check = normalizeWorkDir(request.value);
|
|
89
|
+
if (!check.ok) {
|
|
90
|
+
return fallback("invalid",
|
|
91
|
+
`${request.source} '${request.value}' is not a relative folder of the checkout (${check.reason}): ${DEFAULT_WORK_FOLDER}/ applies`);
|
|
92
|
+
}
|
|
93
|
+
const value = check.folder;
|
|
94
|
+
if (value === "") return fallback("default", null);
|
|
95
|
+
|
|
96
|
+
const vfsPath = `${WORKSPACE}/${value}`;
|
|
97
|
+
if (value === DEFAULT_WORK_FOLDER) {
|
|
98
|
+
return { folder: value, vfsPath, outcome: "applied", request, exists: await entryExists(deps.files, vfsPath), note: null };
|
|
99
|
+
}
|
|
100
|
+
if (await entryExists(deps.files, vfsPath)) {
|
|
101
|
+
return { folder: value, vfsPath, outcome: "applied", request, exists: true, note: null };
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const absentNote = `${request.source} '${value}' is absent from the checkout: ${DEFAULT_WORK_FOLDER}/ applies`;
|
|
105
|
+
const porcelain = await gitStdout(deps.shell, GIT_WORKTREE_LIST);
|
|
106
|
+
const toplevel = await gitStdout(deps.shell, GIT_TOPLEVEL);
|
|
107
|
+
const main = porcelain === null ? null : mainWorktreeOf(porcelain);
|
|
108
|
+
if (main === null || toplevel === null || isSamePath(main, toplevel.trim())) {
|
|
109
|
+
return fallback("absent", absentNote);
|
|
110
|
+
}
|
|
111
|
+
const folder = `${main.replace(/\/+$/, "")}/${value}`;
|
|
112
|
+
if (UNSAFE_FOR_SHELL.test(folder) || !(await probeSucceeds(deps.shell, gitDirProbe(folder)))) {
|
|
113
|
+
return fallback("absent", absentNote);
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
folder,
|
|
117
|
+
vfsPath: null,
|
|
118
|
+
outcome: "main-worktree",
|
|
119
|
+
request,
|
|
120
|
+
exists: true,
|
|
121
|
+
note: `this checkout is a linked worktree: the work folder is the main worktree's ${folder}`,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** "workbench/ (default)", "backstage/tasks/ (layout.work, .orkeon/repo.yaml)", "todo/ (dev.workDir)". */
|
|
126
|
+
export function workFolderLabel(work: WorkFolder, packShown: string | null): string {
|
|
127
|
+
const applied = work.outcome === "applied" || work.outcome === "main-worktree";
|
|
128
|
+
if (!applied || work.request === null) return `${work.folder}/ (default)`;
|
|
129
|
+
if (work.request.source === "layout.work") {
|
|
130
|
+
return `${work.folder}/ (layout.work${packShown === null ? "" : `, ${packShown}`})`;
|
|
131
|
+
}
|
|
132
|
+
return `${work.folder}/ (dev.workDir)`;
|
|
133
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// The slot a script tool reads what it calls from (shared/infrastructure/orkeon/script-tools.ts): a crew
|
|
2
|
+
// builds its tools before its agent's body runs, and the body, once it knows its pack and its rules,
|
|
3
|
+
// binds the slot for its run and releases it at the end. Two runs of one crew bound at once would mix
|
|
4
|
+
// their calls, so the slot then gives nothing until one of them releases it.
|
|
5
|
+
|
|
6
|
+
/** What a tool calls, filled by the agent's body once it knows its pack. */
|
|
7
|
+
export interface ScriptToolSlot<T> {
|
|
8
|
+
/** Binds `value` for one run; the function returned releases it. */
|
|
9
|
+
bind(value: T): () => void;
|
|
10
|
+
/** The value of the one run bound; undefined when none is, or when two are. */
|
|
11
|
+
get(): T | undefined;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function scriptToolSlot<T>(): ScriptToolSlot<T> {
|
|
15
|
+
const bound: Array<{ value: T }> = [];
|
|
16
|
+
return {
|
|
17
|
+
bind(value) {
|
|
18
|
+
const entry = { value };
|
|
19
|
+
bound.push(entry);
|
|
20
|
+
return () => {
|
|
21
|
+
const at = bound.indexOf(entry);
|
|
22
|
+
if (at >= 0) bound.splice(at, 1);
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
get: () => (bound.length === 1 ? bound[0].value : undefined),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// The questions of a spec or a change brief asked to the person, one at a time, Blocking first: a question with
|
|
2
|
+
// options is a choice (the recommended answer first, then the others, then "Leave it open"), one without is free
|
|
3
|
+
// text. Each answer becomes a decision and its row leaves the open questions, and the file is written (`save`)
|
|
4
|
+
// before the next question is asked. When nobody answers (an unattended run, an empty text) the asking stops at
|
|
5
|
+
// once: nothing is decided on anyone's behalf, the questions stay in the file and the step reads BLOCKED.
|
|
6
|
+
import type { HumanInput } from "../ports.ts";
|
|
7
|
+
import { LEAVE_OPEN, askingOrder, decide, questionPrompt } from "../../domain/dev/questions.ts";
|
|
8
|
+
import type { Decision, Question } from "../../domain/dev/questions.ts";
|
|
9
|
+
|
|
10
|
+
export interface SettleDeps {
|
|
11
|
+
human: HumanInput;
|
|
12
|
+
/** The day a decision is recorded, yyyy-mm-dd. */
|
|
13
|
+
today: string;
|
|
14
|
+
/** Writes the file with these open questions and decisions; a throw stops the asking and is the caller's. */
|
|
15
|
+
save: (open: Question[], decisions: Decision[]) => Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface Settled {
|
|
19
|
+
open: Question[];
|
|
20
|
+
decisions: Decision[];
|
|
21
|
+
/** The decisions of this call, in the order they were made. */
|
|
22
|
+
made: Decision[];
|
|
23
|
+
/** True when nobody answered a question that was asked. */
|
|
24
|
+
blocked: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Asks the open questions `which` selects (all by default), in asking order. */
|
|
28
|
+
export async function settleQuestions(
|
|
29
|
+
label: string, open: readonly Question[], decisions: readonly Decision[], deps: SettleDeps,
|
|
30
|
+
which: (q: Question) => boolean = () => true,
|
|
31
|
+
): Promise<Settled> {
|
|
32
|
+
let left = [...open];
|
|
33
|
+
let all = [...decisions];
|
|
34
|
+
const made: Decision[] = [];
|
|
35
|
+
for (const q of askingOrder(open).filter(which)) {
|
|
36
|
+
const prompt = questionPrompt(label, q);
|
|
37
|
+
let answer: string | null;
|
|
38
|
+
if (q.options.length > 0) {
|
|
39
|
+
const r = await deps.human.choice(prompt, [...q.options, LEAVE_OPEN]);
|
|
40
|
+
if (!r.answered) return { open: left, decisions: all, made, blocked: true };
|
|
41
|
+
answer = r.value === LEAVE_OPEN ? null : r.value;
|
|
42
|
+
} else {
|
|
43
|
+
const r = await deps.human.text(`${prompt}\n(an empty answer leaves the questions in the file)`);
|
|
44
|
+
if (!r.answered) return { open: left, decisions: all, made, blocked: true };
|
|
45
|
+
answer = r.value;
|
|
46
|
+
}
|
|
47
|
+
if (answer === null) continue;
|
|
48
|
+
const decision = decide(q, answer, deps.today);
|
|
49
|
+
left = left.filter((o) => o.id !== q.id);
|
|
50
|
+
all = [...all, decision];
|
|
51
|
+
made.push(decision);
|
|
52
|
+
await deps.save(left, all);
|
|
53
|
+
}
|
|
54
|
+
return { open: left, decisions: all, made, blocked: false };
|
|
55
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// The read-only review of a written spec or change brief, once per run: the reviewer's sub-agent questions the
|
|
2
|
+
// file, and its rows join the open questions (a row asking what an open question or a decision already holds is
|
|
3
|
+
// not added), the file written again. The rows' ids are returned so the caller asks the Blocking ones.
|
|
4
|
+
import type { Llm } from "../ports.ts";
|
|
5
|
+
import { runSubAgent } from "../agents/run-sub-agent.ts";
|
|
6
|
+
import { REVIEWER_CHARTER } from "../../domain/dev/reviewer-charter.ts";
|
|
7
|
+
import { REVIEW_ANSWER_SCHEMA, checkReviewAnswer } from "../../domain/dev/review-answer.ts";
|
|
8
|
+
import type { ReviewAnswer } from "../../domain/dev/review-answer.ts";
|
|
9
|
+
import { buildReviewAnswerPrompt, buildReviewBrief, reviewSystem } from "../../domain/dev/review-prompt.ts";
|
|
10
|
+
import { numberQuestions, reviewDrafts, withQuestionSections } from "../../domain/dev/questions.ts";
|
|
11
|
+
import type { RoundState } from "./question-round.ts";
|
|
12
|
+
|
|
13
|
+
export interface SourceReviewRequest {
|
|
14
|
+
mode: "spec" | "change";
|
|
15
|
+
/** "spec" or "brief": the target naming the whole file. */
|
|
16
|
+
whole: string;
|
|
17
|
+
folder: string;
|
|
18
|
+
fileShown: string;
|
|
19
|
+
origin: string;
|
|
20
|
+
inventory: string;
|
|
21
|
+
ids: readonly string[];
|
|
22
|
+
headings: { questions: string; decisions: string };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type SourceReviewOutcome =
|
|
26
|
+
| { ran: true; review: ReviewAnswer; state: RoundState; added: string[] }
|
|
27
|
+
| { ran: false; reason: string };
|
|
28
|
+
|
|
29
|
+
export async function reviewSource(
|
|
30
|
+
llm: Pick<Llm, "act" | "extract">, state: RoundState, request: SourceReviewRequest, write: (text: string) => Promise<void>,
|
|
31
|
+
): Promise<SourceReviewOutcome> {
|
|
32
|
+
const targets = [request.whole, ...request.ids];
|
|
33
|
+
const outcome = await runSubAgent(llm, {
|
|
34
|
+
charter: REVIEWER_CHARTER,
|
|
35
|
+
system: reviewSystem(request.mode),
|
|
36
|
+
brief: buildReviewBrief({
|
|
37
|
+
mode: request.mode, folder: request.folder, files: [request.fileShown], source: request.origin,
|
|
38
|
+
inventory: request.inventory, targets,
|
|
39
|
+
}),
|
|
40
|
+
schema: REVIEW_ANSWER_SCHEMA,
|
|
41
|
+
answerPrompt: (reply, problems) => buildReviewAnswerPrompt(reply, problems, targets),
|
|
42
|
+
check: (v) => checkReviewAnswer(v, { targets }),
|
|
43
|
+
});
|
|
44
|
+
if (!outcome.ok) return { ran: false, reason: `${outcome.reason}: ${outcome.problems[0] ?? "no detail"}` };
|
|
45
|
+
const review = outcome.value;
|
|
46
|
+
if (review.rows.length === 0) return { ran: true, review, state, added: [] };
|
|
47
|
+
const before = new Set(state.open.map((q) => q.id));
|
|
48
|
+
const open = numberQuestions(reviewDrafts(review.rows, request.whole), state.decisions, state.open);
|
|
49
|
+
const added = open.filter((q) => !before.has(q.id)).map((q) => q.id);
|
|
50
|
+
if (added.length === 0) return { ran: true, review, state, added };
|
|
51
|
+
const text = withQuestionSections(state.text, open, state.decisions, request.headings);
|
|
52
|
+
await write(text);
|
|
53
|
+
return { ran: true, review, state: { text, open, decisions: state.decisions }, added };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function reviewLine(outcome: SourceReviewOutcome): string {
|
|
57
|
+
if (!outcome.ran) return `review: not run (${outcome.reason})`;
|
|
58
|
+
const rows = outcome.review.rows;
|
|
59
|
+
if (rows.length === 0) return `review: ${outcome.review.verdict}`;
|
|
60
|
+
const blocking = rows.filter((r) => r.severity === "Blocking").length;
|
|
61
|
+
const kept = outcome.added.length === rows.length ? "" : `, ${outcome.added.length} added as open questions`;
|
|
62
|
+
return `review: ${outcome.review.verdict} — ${blocking} Blocking, ${rows.length - blocking} Major${kept}`;
|
|
63
|
+
}
|