orkeon-code 0.0.0-stage → 1.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.orkeon-runtime +10 -0
- package/.orkeon-version +1 -0
- package/LICENSE.md +21 -0
- package/NOTICE.md +17 -0
- package/README.fr.md +163 -0
- package/README.md +156 -2
- package/config/appsettings.anthropic.example.json +77 -0
- package/config/appsettings.example.json +71 -0
- package/config/appsettings.jev.example.json +131 -0
- package/config/appsettings.kev.example.json +133 -0
- package/config/appsettings.liquid.example.json +132 -0
- package/config/appsettings.ollama-whisper.example.json +93 -0
- package/config/appsettings.ollama.example.json +70 -0
- package/config/appsettings.whisper.example.json +32 -0
- package/mcp/whisper/README.md +294 -0
- package/mcp/whisper/pyproject.toml +32 -0
- package/mcp/whisper/uv.lock +1641 -0
- package/mcp/whisper/whisper_mcp.py +1053 -0
- package/orkeon-code +1092 -0
- package/orkeon-code.mjs +71 -0
- package/orkeon-code.ps1 +939 -0
- package/package.json +58 -4
- package/scripts/install.ps1 +156 -0
- package/scripts/install.sh +148 -0
- package/scripts/session-start.ork.ts +90 -0
- package/scripts/session-start.sh +74 -0
- package/scripts/setup-fixture.sh +88 -0
- package/src/commands/.orkeon/orkeon-cli.d.ts +559 -0
- package/src/commands/_lib/args.ts +194 -0
- package/src/commands/_lib/dev/dev-batches.ts +366 -0
- package/src/commands/_lib/dev/dev-implement.ts +185 -0
- package/src/commands/_lib/dev/dev-source.ts +61 -0
- package/src/commands/_lib/dev/dev.ts +341 -0
- package/src/commands/_lib/dev/markers.ts +7 -0
- package/src/commands/_lib/dev/messages.ts +112 -0
- package/src/commands/_lib/dev-step.ts +145 -0
- package/src/commands/_lib/dispatch.ts +254 -0
- package/src/commands/_lib/effort.ts +15 -0
- package/src/commands/_lib/git/branch.ts +94 -0
- package/src/commands/_lib/git/commit.ts +90 -0
- package/src/commands/_lib/git/diff.ts +107 -0
- package/src/commands/_lib/git/messages.ts +54 -0
- package/src/commands/_lib/git/review.ts +108 -0
- package/src/commands/_lib/memory/memory-admit.ts +148 -0
- package/src/commands/_lib/memory/memory.ts +52 -0
- package/src/commands/_lib/memory/messages.ts +32 -0
- package/src/commands/_lib/messages.ts +48 -0
- package/src/commands/_lib/pr-context.ts +32 -0
- package/src/commands/_lib/project/analyze.ts +24 -0
- package/src/commands/_lib/project/messages.ts +8 -0
- package/src/commands/_lib/session/export.ts +105 -0
- package/src/commands/_lib/session/messages.ts +87 -0
- package/src/commands/_lib/session/prompts.ts +4 -0
- package/src/commands/_lib/session/resume.ts +151 -0
- package/src/commands/_lib/session/tasks.ts +181 -0
- package/src/commands/_lib/settings/advisor.ts +75 -0
- package/src/commands/_lib/settings/agents.ts +137 -0
- package/src/commands/_lib/settings/choices.ts +8 -0
- package/src/commands/_lib/settings/config.ts +141 -0
- package/src/commands/_lib/settings/effort.ts +147 -0
- package/src/commands/_lib/settings/hooks.ts +50 -0
- package/src/commands/_lib/settings/messages.ts +408 -0
- package/src/commands/_lib/settings/mode.ts +100 -0
- package/src/commands/_lib/settings/model.ts +181 -0
- package/src/commands/_lib/settings/output-style.ts +39 -0
- package/src/commands/_lib/settings/permissions.ts +287 -0
- package/src/commands/_lib/settings/route.ts +63 -0
- package/src/commands/_lib/settings/session-config.ts +49 -0
- package/src/commands/_lib/settings/skills.ts +93 -0
- package/src/commands/_lib/settings/theme.ts +42 -0
- package/src/commands/_lib/speech/messages.ts +58 -0
- package/src/commands/_lib/speech/prompts.ts +4 -0
- package/src/commands/_lib/speech/say.ts +95 -0
- package/src/commands/_lib/speech/transcribe.ts +121 -0
- package/src/commands/_lib/speech/voice.ts +142 -0
- package/src/commands/_lib/status/cache.ts +31 -0
- package/src/commands/_lib/status/context.ts +57 -0
- package/src/commands/_lib/status/doctor.ts +205 -0
- package/src/commands/_lib/status/messages.ts +100 -0
- package/src/commands/_lib/status/meta.ts +24 -0
- package/src/commands/_lib/status/status.ts +128 -0
- package/src/commands/_lib/status/usage-tools.ts +48 -0
- package/src/commands/_lib/status/usage.ts +128 -0
- package/src/commands/_lib/view.ts +34 -0
- package/src/commands/dev/dev-batches.cmd.ts +109 -0
- package/src/commands/dev/dev-learn.cmd.ts +29 -0
- package/src/commands/dev/dev-plan.cmd.ts +51 -0
- package/src/commands/dev/dev-spec.cmd.ts +54 -0
- package/src/commands/dev/dev-status.cmd.ts +16 -0
- package/src/commands/git/branch.cmd.ts +27 -0
- package/src/commands/git/commit.cmd.ts +48 -0
- package/src/commands/git/diff.cmd.ts +26 -0
- package/src/commands/git/review.cmd.ts +36 -0
- package/src/commands/memory/memory.cmd.ts +48 -0
- package/src/commands/project/analyze.cmd.ts +32 -0
- package/src/commands/project/debug-tool-call.cmd.ts +62 -0
- package/src/commands/project/files.cmd.ts +22 -0
- package/src/commands/project/init-verifiers.cmd.ts +14 -0
- package/src/commands/project/init.cmd.ts +14 -0
- package/src/commands/project/verify.cmd.ts +27 -0
- package/src/commands/session/assistant.cmd.ts +40 -0
- package/src/commands/session/btw.cmd.ts +18 -0
- package/src/commands/session/clear.cmd.ts +19 -0
- package/src/commands/session/compact.cmd.ts +16 -0
- package/src/commands/session/copy.cmd.ts +45 -0
- package/src/commands/session/exit.cmd.ts +9 -0
- package/src/commands/session/export.cmd.ts +28 -0
- package/src/commands/session/rename.cmd.ts +18 -0
- package/src/commands/session/resume.cmd.ts +19 -0
- package/src/commands/session/rewind.cmd.ts +25 -0
- package/src/commands/session/summary.cmd.ts +27 -0
- package/src/commands/session/tasks.cmd.ts +46 -0
- package/src/commands/settings/advisor.cmd.ts +38 -0
- package/src/commands/settings/agents.cmd.ts +19 -0
- package/src/commands/settings/config.cmd.ts +19 -0
- package/src/commands/settings/effort.cmd.ts +19 -0
- package/src/commands/settings/fast.cmd.ts +18 -0
- package/src/commands/settings/hooks.cmd.ts +17 -0
- package/src/commands/settings/mode.cmd.ts +20 -0
- package/src/commands/settings/model.cmd.ts +21 -0
- package/src/commands/settings/output-style.cmd.ts +19 -0
- package/src/commands/settings/permissions.cmd.ts +25 -0
- package/src/commands/settings/proactive.cmd.ts +16 -0
- package/src/commands/settings/route.cmd.ts +16 -0
- package/src/commands/settings/skills.cmd.ts +17 -0
- package/src/commands/settings/theme.cmd.ts +14 -0
- package/src/commands/speech/say.cmd.ts +24 -0
- package/src/commands/speech/transcribe.cmd.ts +29 -0
- package/src/commands/speech/voice.cmd.ts +30 -0
- package/src/commands/status/context.cmd.ts +18 -0
- package/src/commands/status/doctor.cmd.ts +27 -0
- package/src/commands/status/release-notes.cmd.ts +9 -0
- package/src/commands/status/status.cmd.ts +25 -0
- package/src/commands/status/usage.cmd.ts +21 -0
- package/src/crews/.orkeon/orkeon.d.ts +4391 -0
- package/src/crews/_probe-shared-memory/domain/messages.ts +54 -0
- package/src/crews/_probe-shared-memory/domain/probe-verdict.ts +188 -0
- package/src/crews/_probe-shared-memory/domain/prompts.ts +5 -0
- package/src/crews/_probe-shared-memory/probe.ork.ts +100 -0
- package/src/crews/advisor/application/messages.ts +4 -0
- package/src/crews/advisor/application/prompts.ts +4 -0
- package/src/crews/advisor/application/run-advisor.ts +41 -0
- package/src/crews/advisor/crew.ork.ts +44 -0
- package/src/crews/advisor/domain/advice.ts +119 -0
- package/src/crews/advisor/domain/messages.ts +8 -0
- package/src/crews/advisor/domain/prompts.ts +26 -0
- package/src/crews/agent-run/application/messages.ts +18 -0
- package/src/crews/agent-run/application/run-agent-run.ts +43 -0
- package/src/crews/agent-run/crew.ork.ts +67 -0
- package/src/crews/analyze/application/messages.ts +27 -0
- package/src/crews/analyze/application/prompts.ts +4 -0
- package/src/crews/analyze/application/run-analyze.ts +120 -0
- package/src/crews/analyze/crew.ork.ts +41 -0
- package/src/crews/analyze/domain/harvest.ts +269 -0
- package/src/crews/analyze/domain/prompts.ts +86 -0
- package/src/crews/code-review/application/lens-material.ts +24 -0
- package/src/crews/code-review/application/messages.ts +17 -0
- package/src/crews/code-review/application/prompts.ts +126 -0
- package/src/crews/code-review/application/review.ts +74 -0
- package/src/crews/code-review/application/run-code-review.ts +121 -0
- package/src/crews/code-review/crew.ork.ts +52 -0
- package/src/crews/code-review/domain/lenses.ts +154 -0
- package/src/crews/code-review/domain/messages.ts +25 -0
- package/src/crews/code-review/domain/prompts.ts +58 -0
- package/src/crews/code-review/domain/report.ts +58 -0
- package/src/crews/code-review/domain/scope.ts +106 -0
- package/src/crews/dev-batches/application/messages.ts +127 -0
- package/src/crews/dev-batches/application/plan-close.ts +181 -0
- package/src/crews/dev-batches/application/prompts.ts +10 -0
- package/src/crews/dev-batches/application/run-dev-batches.ts +676 -0
- package/src/crews/dev-batches/application/run-wave.ts +452 -0
- package/src/crews/dev-batches/application/seed-harvest.ts +163 -0
- package/src/crews/dev-batches/crew.ork.ts +146 -0
- package/src/crews/dev-batches/domain/batch-waves.ts +70 -0
- package/src/crews/dev-batches/domain/batches-budget.ts +52 -0
- package/src/crews/dev-batches/domain/batches-log.ts +52 -0
- package/src/crews/dev-batches/domain/markers.ts +5 -0
- package/src/crews/dev-batches/domain/messages.ts +6 -0
- package/src/crews/dev-batches/domain/wave-order.ts +44 -0
- package/src/crews/dev-change/application/change-material.ts +44 -0
- package/src/crews/dev-change/application/evidence.ts +172 -0
- package/src/crews/dev-change/application/messages.ts +81 -0
- package/src/crews/dev-change/application/prompts.ts +101 -0
- package/src/crews/dev-change/application/run-dev-change.ts +324 -0
- package/src/crews/dev-change/crew.ork.ts +114 -0
- package/src/crews/dev-change/domain/change-answer.ts +163 -0
- package/src/crews/dev-change/domain/change-render.ts +77 -0
- package/src/crews/dev-change/domain/markers.ts +28 -0
- package/src/crews/dev-change/domain/messages.ts +16 -0
- package/src/crews/dev-implement/application/close.ts +186 -0
- package/src/crews/dev-implement/application/count-open-steps.ts +24 -0
- package/src/crews/dev-implement/application/locate-sheet.ts +82 -0
- package/src/crews/dev-implement/application/messages.ts +161 -0
- package/src/crews/dev-implement/application/observe.ts +52 -0
- package/src/crews/dev-implement/application/prompts.ts +9 -0
- package/src/crews/dev-implement/application/report-writes.ts +46 -0
- package/src/crews/dev-implement/application/run-dev-implement.ts +822 -0
- package/src/crews/dev-implement/application/run-role.ts +27 -0
- package/src/crews/dev-implement/application/suite-job.ts +122 -0
- package/src/crews/dev-implement/application/touched.ts +74 -0
- package/src/crews/dev-implement/crew.ork.ts +69 -0
- package/src/crews/dev-implement/domain/contracts.ts +255 -0
- package/src/crews/dev-implement/domain/correction.ts +103 -0
- package/src/crews/dev-implement/domain/cycles.ts +36 -0
- package/src/crews/dev-implement/domain/implement-budget.ts +29 -0
- package/src/crews/dev-implement/domain/markers.ts +23 -0
- package/src/crews/dev-implement/domain/messages.ts +58 -0
- package/src/crews/dev-implement/domain/prompts.ts +93 -0
- package/src/crews/dev-implement/domain/roles.ts +49 -0
- package/src/crews/dev-implement/domain/sheet-edits.ts +76 -0
- package/src/crews/dev-implement/domain/sheet-ticks.ts +23 -0
- package/src/crews/dev-implement/domain/step-checks.ts +137 -0
- package/src/crews/dev-implement/domain/step-section.ts +129 -0
- package/src/crews/dev-learn/application/learn-backlog.ts +58 -0
- package/src/crews/dev-learn/application/learn-prompt-fit.ts +63 -0
- package/src/crews/dev-learn/application/messages.ts +51 -0
- package/src/crews/dev-learn/application/prompts.ts +99 -0
- package/src/crews/dev-learn/application/run-dev-learn.ts +558 -0
- package/src/crews/dev-learn/crew.ork.ts +53 -0
- package/src/crews/dev-learn/domain/learn-answer.ts +233 -0
- package/src/crews/dev-learn/domain/messages.ts +65 -0
- package/src/crews/dev-learn/domain/owner-lines.ts +89 -0
- package/src/crews/dev-learn/domain/proposals-render.ts +95 -0
- package/src/crews/dev-plan/application/anchor-paths.ts +113 -0
- package/src/crews/dev-plan/application/inventory.ts +174 -0
- package/src/crews/dev-plan/application/messages.ts +88 -0
- package/src/crews/dev-plan/application/plan-prompt-fit.ts +44 -0
- package/src/crews/dev-plan/application/prompts.ts +141 -0
- package/src/crews/dev-plan/application/run-dev-plan.ts +483 -0
- package/src/crews/dev-plan/crew.ork.ts +112 -0
- package/src/crews/dev-plan/domain/inventory-model.ts +95 -0
- package/src/crews/dev-plan/domain/markers.ts +18 -0
- package/src/crews/dev-plan/domain/messages.ts +118 -0
- package/src/crews/dev-plan/domain/plan-answer.ts +753 -0
- package/src/crews/dev-plan/domain/plan-render.ts +306 -0
- package/src/crews/dev-plan/domain/prompts.ts +44 -0
- package/src/crews/dev-spec/application/messages.ts +30 -0
- package/src/crews/dev-spec/application/prompts.ts +93 -0
- package/src/crews/dev-spec/application/run-dev-spec.ts +237 -0
- package/src/crews/dev-spec/application/spec-material.ts +42 -0
- package/src/crews/dev-spec/crew.ork.ts +110 -0
- package/src/crews/dev-spec/domain/markers.ts +30 -0
- package/src/crews/dev-spec/domain/messages.ts +39 -0
- package/src/crews/dev-spec/domain/spec-answer.ts +252 -0
- package/src/crews/dev-spec/domain/spec-render.ts +76 -0
- package/src/crews/dev-verify/application/audit-brief.ts +187 -0
- package/src/crews/dev-verify/application/audit.ts +267 -0
- package/src/crews/dev-verify/application/capture.ts +311 -0
- package/src/crews/dev-verify/application/messages.ts +119 -0
- package/src/crews/dev-verify/application/prompts.ts +209 -0
- package/src/crews/dev-verify/application/run-dev-verify.ts +423 -0
- package/src/crews/dev-verify/application/run-gate.ts +204 -0
- package/src/crews/dev-verify/crew.ork.ts +103 -0
- package/src/crews/dev-verify/domain/audit-answer.ts +154 -0
- package/src/crews/dev-verify/domain/auditor-charter.ts +21 -0
- package/src/crews/dev-verify/domain/capture-sections.ts +138 -0
- package/src/crews/dev-verify/domain/commands.ts +103 -0
- package/src/crews/dev-verify/domain/gate.ts +131 -0
- package/src/crews/dev-verify/domain/markers.ts +16 -0
- package/src/crews/dev-verify/domain/mechanical-table.ts +156 -0
- package/src/crews/dev-verify/domain/messages.ts +92 -0
- package/src/crews/dev-verify/domain/runtime-cut.ts +13 -0
- package/src/crews/dev-verify/domain/sheet-facts.ts +4 -0
- package/src/crews/dev-verify/domain/text.ts +20 -0
- package/src/crews/dev-verify/domain/verdict.ts +127 -0
- package/src/crews/git-commit/application/draft.ts +133 -0
- package/src/crews/git-commit/application/messages.ts +15 -0
- package/src/crews/git-commit/application/prompts.ts +47 -0
- package/src/crews/git-commit/application/run-git-commit.ts +117 -0
- package/src/crews/git-commit/crew.ork.ts +53 -0
- package/src/crews/git-commit/domain/commit.ts +200 -0
- package/src/crews/git-commit/domain/markers.ts +4 -0
- package/src/crews/git-commit/domain/messages.ts +48 -0
- package/src/crews/init-verifiers/application/authoring.ts +90 -0
- package/src/crews/init-verifiers/application/messages.ts +13 -0
- package/src/crews/init-verifiers/application/prompts.ts +107 -0
- package/src/crews/init-verifiers/application/run-init-verifiers.ts +26 -0
- package/src/crews/init-verifiers/crew.ork.ts +35 -0
- package/src/crews/init-verifiers/domain/commands-section.ts +36 -0
- package/src/crews/init-verifiers/domain/readiness.ts +23 -0
- package/src/crews/main-loop/application/auto-compact.ts +78 -0
- package/src/crews/main-loop/application/context-gather.ts +133 -0
- package/src/crews/main-loop/application/messages.ts +81 -0
- package/src/crews/main-loop/application/prompts.ts +12 -0
- package/src/crews/main-loop/application/run-main-loop.ts +383 -0
- package/src/crews/main-loop/application/turn-context.ts +111 -0
- package/src/crews/main-loop/crew.ork.ts +124 -0
- package/src/crews/main-loop/domain/autocompact.ts +27 -0
- package/src/crews/main-loop/domain/prompt-assembly.ts +338 -0
- package/src/crews/main-loop/domain/prompts.ts +336 -0
- package/src/crews/main-loop/domain/turn-chains.ts +130 -0
- package/src/crews/project-init/application/detect.ts +123 -0
- package/src/crews/project-init/application/messages.ts +15 -0
- package/src/crews/project-init/application/prompts.ts +105 -0
- package/src/crews/project-init/application/run-project-init.ts +31 -0
- package/src/crews/project-init/crew.ork.ts +36 -0
- package/src/crews/project-init/domain/conventions.ts +36 -0
- package/src/crews/project-init/domain/existing-files.ts +65 -0
- package/src/crews/project-init/domain/messages.ts +13 -0
- package/src/crews/project-init/domain/package-map.ts +73 -0
- package/src/crews/project-init/domain/prompts.ts +10 -0
- package/src/crews/session-compact/application/prompts.ts +5 -0
- package/src/crews/session-compact/crew.ork.ts +56 -0
- package/src/crews/shared-memory-admit/application/prompts.ts +5 -0
- package/src/crews/shared-memory-admit/crew.ork.ts +49 -0
- package/src/crews/speech/application/messages.ts +3 -0
- package/src/crews/speech/application/prompts.ts +3 -0
- package/src/crews/speech/application/run-speech.ts +26 -0
- package/src/crews/speech/crew.ork.ts +38 -0
- package/src/shared/application/agents/child-agent.ts +259 -0
- package/src/shared/application/agents/messages.ts +35 -0
- package/src/shared/application/agents/route-agent.ts +115 -0
- package/src/shared/application/agents/run-sub-agent.ts +119 -0
- package/src/shared/application/answer-language.ts +14 -0
- package/src/shared/application/attached-skills.ts +36 -0
- package/src/shared/application/compaction/compact-session.ts +242 -0
- package/src/shared/application/compaction/extract-memories.ts +38 -0
- package/src/shared/application/compaction/messages.ts +20 -0
- package/src/shared/application/compaction/prune-context.ts +94 -0
- package/src/shared/application/compaction/pruned-llm.ts +35 -0
- package/src/shared/application/compaction/restore-context.ts +78 -0
- package/src/shared/application/config-store.ts +123 -0
- package/src/shared/application/dev/brief-inventory.ts +115 -0
- package/src/shared/application/dev/close-batch.ts +85 -0
- package/src/shared/application/dev/find-repo-pack.ts +78 -0
- package/src/shared/application/dev/learn-decision.ts +254 -0
- package/src/shared/application/dev/load-dev-context.ts +265 -0
- package/src/shared/application/dev/measure-access-cost.ts +69 -0
- package/src/shared/application/dev/messages.ts +132 -0
- package/src/shared/application/dev/phase-timer.ts +54 -0
- package/src/shared/application/dev/plan-source.ts +116 -0
- package/src/shared/application/dev/preflight.ts +71 -0
- package/src/shared/application/dev/project-files.ts +17 -0
- package/src/shared/application/dev/prompts.ts +34 -0
- package/src/shared/application/dev/question-round.ts +60 -0
- package/src/shared/application/dev/resolve-work-folder.ts +134 -0
- package/src/shared/application/dev/script-tool-slot.ts +27 -0
- package/src/shared/application/dev/settle-questions.ts +57 -0
- package/src/shared/application/dev/source-review.ts +67 -0
- package/src/shared/application/dev/source-step.ts +152 -0
- package/src/shared/application/dev/spend.ts +55 -0
- package/src/shared/application/dev/step-precedents.ts +90 -0
- package/src/shared/application/dev/tool-call-policy.ts +87 -0
- package/src/shared/application/dev/tool-callbacks.ts +262 -0
- package/src/shared/application/dev/tool-trace-recorder.ts +46 -0
- package/src/shared/application/dev/verdict-sources.ts +50 -0
- package/src/shared/application/dev/wrapped-tools.ts +147 -0
- package/src/shared/application/extra-tools.ts +71 -0
- package/src/shared/application/git/batch-worktree.ts +102 -0
- package/src/shared/application/git/commit-files.ts +191 -0
- package/src/shared/application/git/merge-batch.ts +67 -0
- package/src/shared/application/git/messages.ts +75 -0
- package/src/shared/application/git/open-pull-request.ts +52 -0
- package/src/shared/application/host-context.ts +59 -0
- package/src/shared/application/host-layout-store.ts +45 -0
- package/src/shared/application/instructions-file.ts +19 -0
- package/src/shared/application/json-file.ts +34 -0
- package/src/shared/application/llm-profile.ts +36 -0
- package/src/shared/application/messages.ts +14 -0
- package/src/shared/application/permission-rules.ts +169 -0
- package/src/shared/application/ports/approvals.ts +20 -0
- package/src/shared/application/ports/clock.ts +5 -0
- package/src/shared/application/ports/code-index.ts +93 -0
- package/src/shared/application/ports/crew.ts +60 -0
- package/src/shared/application/ports/decision.ts +14 -0
- package/src/shared/application/ports/files.ts +21 -0
- package/src/shared/application/ports/human.ts +38 -0
- package/src/shared/application/ports/llm.ts +83 -0
- package/src/shared/application/ports/memory.ts +30 -0
- package/src/shared/application/ports/progress.ts +23 -0
- package/src/shared/application/ports/runtime.ts +15 -0
- package/src/shared/application/ports/session.ts +74 -0
- package/src/shared/application/ports/shared-memory.ts +26 -0
- package/src/shared/application/ports/shell.ts +40 -0
- package/src/shared/application/ports/telemetry.ts +45 -0
- package/src/shared/application/ports/theme.ts +11 -0
- package/src/shared/application/ports/tools.ts +46 -0
- package/src/shared/application/ports/usage.ts +45 -0
- package/src/shared/application/ports.ts +29 -0
- package/src/shared/application/project-manifests.ts +106 -0
- package/src/shared/application/session-io.ts +85 -0
- package/src/shared/application/session-state.ts +36 -0
- package/src/shared/application/shared-memory/admit-entries.ts +179 -0
- package/src/shared/application/shared-memory/harvest-after-gaps.ts +69 -0
- package/src/shared/application/shared-memory/harvest-mistakes.ts +45 -0
- package/src/shared/application/shared-memory/import-agent-memory.ts +119 -0
- package/src/shared/application/shared-memory/memory-files.ts +111 -0
- package/src/shared/application/shared-memory/memory-settings.ts +94 -0
- package/src/shared/application/shared-memory/messages.ts +63 -0
- package/src/shared/application/shared-memory/push-candidate.ts +149 -0
- package/src/shared/application/shared-memory/recall-precedents.ts +70 -0
- package/src/shared/application/skills/messages.ts +4 -0
- package/src/shared/application/skills/suggest-skills.ts +102 -0
- package/src/shared/application/state-snapshot.ts +38 -0
- package/src/shared/application/workflow/messages.ts +8 -0
- package/src/shared/application/workflow/workflow-state.ts +136 -0
- package/src/shared/domain/agent-policy/behavior-flags.ts +162 -0
- package/src/shared/domain/agent-policy/extra-tools.ts +67 -0
- package/src/shared/domain/agent-policy/memory-categories.ts +6 -0
- package/src/shared/domain/agent-policy/messages.ts +66 -0
- package/src/shared/domain/agent-policy/mode-policy.ts +51 -0
- package/src/shared/domain/agent-policy/output-styles.ts +11 -0
- package/src/shared/domain/agent-policy/path-rules.ts +299 -0
- package/src/shared/domain/agent-policy/permission.ts +625 -0
- package/src/shared/domain/agent-policy/prompts.ts +17 -0
- package/src/shared/domain/agent-policy/reasoning.ts +59 -0
- package/src/shared/domain/agent-policy/rule-sets.ts +416 -0
- package/src/shared/domain/agent-policy/tool-access.ts +91 -0
- package/src/shared/domain/agent-registry.ts +143 -0
- package/src/shared/domain/agents/built-in-charters.ts +43 -0
- package/src/shared/domain/agents/chain.ts +30 -0
- package/src/shared/domain/agents/charter.ts +64 -0
- package/src/shared/domain/agents/exclusive.ts +25 -0
- package/src/shared/domain/agents/instances.ts +252 -0
- package/src/shared/domain/agents/messages.ts +39 -0
- package/src/shared/domain/agents/model-route.ts +199 -0
- package/src/shared/domain/agents/prompts.ts +20 -0
- package/src/shared/domain/code-intel-contract.ts +357 -0
- package/src/shared/domain/code-intel-routing.ts +60 -0
- package/src/shared/domain/compact-outcome.ts +46 -0
- package/src/shared/domain/compaction-thresholds.ts +162 -0
- package/src/shared/domain/compaction.ts +288 -0
- package/src/shared/domain/config-schema.ts +434 -0
- package/src/shared/domain/context-prune.ts +176 -0
- package/src/shared/domain/decision/questions.ts +102 -0
- package/src/shared/domain/dev/access-cost.ts +230 -0
- package/src/shared/domain/dev/artefacts.ts +50 -0
- package/src/shared/domain/dev/batches-concurrency.ts +35 -0
- package/src/shared/domain/dev/batches-state.ts +49 -0
- package/src/shared/domain/dev/build-commands.ts +45 -0
- package/src/shared/domain/dev/call-guard.ts +342 -0
- package/src/shared/domain/dev/carried-text.ts +47 -0
- package/src/shared/domain/dev/design-rules.ts +100 -0
- package/src/shared/domain/dev/learn-proposals.ts +176 -0
- package/src/shared/domain/dev/learn-state.ts +94 -0
- package/src/shared/domain/dev/markers.ts +107 -0
- package/src/shared/domain/dev/messages.ts +259 -0
- package/src/shared/domain/dev/path-args.ts +42 -0
- package/src/shared/domain/dev/path-rebase.ts +93 -0
- package/src/shared/domain/dev/phase-timing.ts +50 -0
- package/src/shared/domain/dev/plan-checks.ts +191 -0
- package/src/shared/domain/dev/plan-format.ts +170 -0
- package/src/shared/domain/dev/project-files.ts +29 -0
- package/src/shared/domain/dev/prompts/brief-blocks.ts +20 -0
- package/src/shared/domain/dev/prompts.ts +251 -0
- package/src/shared/domain/dev/questions.ts +267 -0
- package/src/shared/domain/dev/reading-rule.ts +41 -0
- package/src/shared/domain/dev/repo-pack.ts +240 -0
- package/src/shared/domain/dev/review-answer.ts +173 -0
- package/src/shared/domain/dev/review-brief.ts +54 -0
- package/src/shared/domain/dev/reviewer-charter.ts +35 -0
- package/src/shared/domain/dev/sheet-facts.ts +81 -0
- package/src/shared/domain/dev/spec-format.ts +182 -0
- package/src/shared/domain/dev/step-budget.ts +74 -0
- package/src/shared/domain/dev/step-rules.ts +109 -0
- package/src/shared/domain/dev/test-commands.ts +94 -0
- package/src/shared/domain/dev/test-output.ts +33 -0
- package/src/shared/domain/dev/test-paths.ts +40 -0
- package/src/shared/domain/dev/tool-guards.ts +65 -0
- package/src/shared/domain/dev/trait-pattern.ts +87 -0
- package/src/shared/domain/dev/verdict-format.ts +162 -0
- package/src/shared/domain/dev/whitespace.ts +35 -0
- package/src/shared/domain/dev/work-folder.ts +68 -0
- package/src/shared/domain/dev/yaml-subset.ts +385 -0
- package/src/shared/domain/error-text.ts +13 -0
- package/src/shared/domain/git/close.ts +274 -0
- package/src/shared/domain/git/messages.ts +20 -0
- package/src/shared/domain/git/pull-request.ts +96 -0
- package/src/shared/domain/git/worktree.ts +46 -0
- package/src/shared/domain/host-layout.ts +147 -0
- package/src/shared/domain/host-paths.ts +399 -0
- package/src/shared/domain/index-languages.ts +16 -0
- package/src/shared/domain/instructions-file.ts +18 -0
- package/src/shared/domain/iso-day.ts +4 -0
- package/src/shared/domain/llm-failure.ts +134 -0
- package/src/shared/domain/llm-profile.ts +44 -0
- package/src/shared/domain/marked-message.ts +29 -0
- package/src/shared/domain/markers.ts +30 -0
- package/src/shared/domain/messages.ts +291 -0
- package/src/shared/domain/model-catalog.ts +79 -0
- package/src/shared/domain/permission-modes.ts +99 -0
- package/src/shared/domain/prelude.ts +92 -0
- package/src/shared/domain/project-manifests.ts +84 -0
- package/src/shared/domain/prompts.ts +233 -0
- package/src/shared/domain/search-routing.ts +77 -0
- package/src/shared/domain/secret-patterns.ts +46 -0
- package/src/shared/domain/session-keys.ts +92 -0
- package/src/shared/domain/session-start.ts +61 -0
- package/src/shared/domain/severity.ts +72 -0
- package/src/shared/domain/sha1.ts +61 -0
- package/src/shared/domain/shared-memory/agent-memory-import.ts +145 -0
- package/src/shared/domain/shared-memory/candidates.ts +40 -0
- package/src/shared/domain/shared-memory/entry.ts +151 -0
- package/src/shared/domain/shared-memory/front-matter.ts +187 -0
- package/src/shared/domain/shared-memory/gate.ts +45 -0
- package/src/shared/domain/shared-memory/harvest.ts +64 -0
- package/src/shared/domain/shared-memory/layout.ts +190 -0
- package/src/shared/domain/shared-memory/markers.ts +9 -0
- package/src/shared/domain/shared-memory/messages.ts +66 -0
- package/src/shared/domain/shared-memory/precedents-block.ts +82 -0
- package/src/shared/domain/shared-memory/prompts.ts +28 -0
- package/src/shared/domain/shared-memory/refused.ts +84 -0
- package/src/shared/domain/shared-memory/verdict-rows.ts +134 -0
- package/src/shared/domain/skills/prompts.ts +4 -0
- package/src/shared/domain/skills/shortlist.ts +149 -0
- package/src/shared/domain/snip-turns.ts +33 -0
- package/src/shared/domain/speech.ts +21 -0
- package/src/shared/domain/strip.ts +88 -0
- package/src/shared/domain/tool-trace.ts +120 -0
- package/src/shared/domain/types.ts +67 -0
- package/src/shared/domain/verifiers.ts +33 -0
- package/src/shared/domain/vfs.ts +16 -0
- package/src/shared/domain/workflow/prompts.ts +15 -0
- package/src/shared/domain/workflow/state-file.ts +142 -0
- package/src/shared/infrastructure/globals.ts +57 -0
- package/src/shared/infrastructure/orkeon/approvals.ts +24 -0
- package/src/shared/infrastructure/orkeon/child-agents.ts +122 -0
- package/src/shared/infrastructure/orkeon/chooser.ts +32 -0
- package/src/shared/infrastructure/orkeon/code-index.ts +120 -0
- package/src/shared/infrastructure/orkeon/crew-host.ts +27 -0
- package/src/shared/infrastructure/orkeon/crew-memory.ts +12 -0
- package/src/shared/infrastructure/orkeon/decision-model.ts +31 -0
- package/src/shared/infrastructure/orkeon/dev-deps.ts +179 -0
- package/src/shared/infrastructure/orkeon/files.ts +58 -0
- package/src/shared/infrastructure/orkeon/github-pull-requests.ts +30 -0
- package/src/shared/infrastructure/orkeon/host-context.ts +36 -0
- package/src/shared/infrastructure/orkeon/host-provider.ts +22 -0
- package/src/shared/infrastructure/orkeon/human-input.ts +55 -0
- package/src/shared/infrastructure/orkeon/llm-profile.ts +58 -0
- package/src/shared/infrastructure/orkeon/llm.ts +164 -0
- package/src/shared/infrastructure/orkeon/markers.ts +6 -0
- package/src/shared/infrastructure/orkeon/memory-store.ts +41 -0
- package/src/shared/infrastructure/orkeon/memory-tools.ts +129 -0
- package/src/shared/infrastructure/orkeon/messages.ts +15 -0
- package/src/shared/infrastructure/orkeon/permission-rules.ts +42 -0
- package/src/shared/infrastructure/orkeon/progress.ts +24 -0
- package/src/shared/infrastructure/orkeon/prompts.ts +47 -0
- package/src/shared/infrastructure/orkeon/reasoning.ts +40 -0
- package/src/shared/infrastructure/orkeon/run-state.ts +17 -0
- package/src/shared/infrastructure/orkeon/runtime-info.ts +30 -0
- package/src/shared/infrastructure/orkeon/runtime-tools.ts +60 -0
- package/src/shared/infrastructure/orkeon/script-tools.ts +129 -0
- package/src/shared/infrastructure/orkeon/session-store.ts +94 -0
- package/src/shared/infrastructure/orkeon/session-switch.ts +23 -0
- package/src/shared/infrastructure/orkeon/shared-memory.ts +61 -0
- package/src/shared/infrastructure/orkeon/shell-jobs.ts +81 -0
- package/src/shared/infrastructure/orkeon/shell.ts +39 -0
- package/src/shared/infrastructure/orkeon/telemetry.ts +63 -0
- package/src/shared/infrastructure/orkeon/tool-catalogue.ts +76 -0
- package/src/shared/infrastructure/orkeon/tool-results.ts +120 -0
- package/src/shared/infrastructure/orkeon/usage.ts +74 -0
- package/src/shared/infrastructure/orkeon/wiring.ts +174 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// The text the dev commands show the user (ADR 0026): their usage, their refusals, the lines of a chain and of
|
|
2
|
+
// /dev-status. Read by dev.ts, dev-batches.ts, dev-implement.ts, dev-source.ts and the *.cmd.ts of commands/dev/.
|
|
3
|
+
|
|
4
|
+
// A chain of crews (dev-implement.ts, dev-batches.ts)
|
|
5
|
+
export const thenType = (command: string) => `then type ${command}`;
|
|
6
|
+
export const closeFollows = (command: string) => `→ the close follows: ${command}`;
|
|
7
|
+
/** The line a hop prints when the session's context could not be read again: the crew reads its record. */
|
|
8
|
+
export const CONTEXT_NOT_READ_LINE = "⚠ the session's mode could not be read again: the context read at the launch applies";
|
|
9
|
+
export const WRITES_FILES = "writes files";
|
|
10
|
+
export const WRITES_COMMITS_PUSHES = "writes files, commits and pushes";
|
|
11
|
+
export const CLOSE_COMMITS = "commits (the close of the batch)";
|
|
12
|
+
export const batchChainFailed = (error: string) => `✗ the batch's chain failed: ${error}`;
|
|
13
|
+
export const couldNotBeLaunched = (crew: string, reason: string, command: string) =>
|
|
14
|
+
`✗ ${crew} could not be launched (${reason}): type ${command}`;
|
|
15
|
+
|
|
16
|
+
// /dev-batches
|
|
17
|
+
export const DEV_BATCHES_USAGE =
|
|
18
|
+
"usage: /dev-batches [<code>] [--pr] [--concurrency n] | <code> F<n> [--close [--pr]] [— correction: <finding>]" +
|
|
19
|
+
" | <code> F<n> --audit [fast | full | resume] [--gate-only]" +
|
|
20
|
+
" (no code: the run in progress goes on; n from 1 to 4, above 1 in bypassPermissions; with F<n>, <code> may be a <path>/<CODE>-PLAN.md)";
|
|
21
|
+
export const devBatchesRefusal = (text: string) => `dev-batches: ${text}`;
|
|
22
|
+
export const CONCURRENCY_NEEDS_NUMBER = "--concurrency needs a number";
|
|
23
|
+
export const namesItsBatch = (option: string) => `${option} names its batch: /dev-batches <code> F<n> ${option}`;
|
|
24
|
+
export const runUnknownOption = (option: string) =>
|
|
25
|
+
`unknown option '${option}' (--pr, --concurrency; with F<n>: --close, --audit)`;
|
|
26
|
+
export const notAWorkCodeExplained = (token: string) => `'${token}' is not a work code (a folder name of the work folder)`;
|
|
27
|
+
export const oneCodeAtMost = (code: string, token: string) => `one code at most, not '${code}' and '${token}'`;
|
|
28
|
+
export const correctionNamesFinding = (command: string) => `a correction names its finding: ${command}`;
|
|
29
|
+
export const goesWithAudit = (token: string, batch: string) =>
|
|
30
|
+
`'${token}' goes with --audit: /dev-batches <code> ${batch} --audit ${token}`;
|
|
31
|
+
export const batchUnknownOption = (option: string, batch: string) =>
|
|
32
|
+
`unknown option '${option}' with ${batch} (--close, --pr, --audit)`;
|
|
33
|
+
export const onePlanAtMost = (plan: string, token: string) => `one plan at most, not '${plan}' and '${token}'`;
|
|
34
|
+
export const prGoesWithClose = (batch: string) =>
|
|
35
|
+
`with ${batch}, --pr goes with --close (the pull request is opened at the close)`;
|
|
36
|
+
export const CORRECTION_OR_CLOSE = "a correction runs the batch, --close commits it: one at a time";
|
|
37
|
+
export const oneAuditMode = (mode: string, token: string) =>
|
|
38
|
+
`one audit mode at most (fast, full or resume), not '${mode}' and '${token}'`;
|
|
39
|
+
export const auditUnknownOption = (option: string) => `unknown option '${option}' with --audit (only --gate-only)`;
|
|
40
|
+
export const namesItsBatchFirst = (typed: string) => `/${typed} names its batch first: F<n>, e.g. F2`;
|
|
41
|
+
export const correctionNamesBatch = (command: string) => `a correction names its batch: ${command}`;
|
|
42
|
+
export const oneBatchAtMost = (batch: string, other: string) => `one batch at most, not ${batch} and ${other}`;
|
|
43
|
+
export const concurrencyNotWithBatch = (batch: string) =>
|
|
44
|
+
`--concurrency runs a plan's batches: it does not go with ${batch}`;
|
|
45
|
+
export const AUDIT_OR_CORRECTION = "--audit judges the batch, a correction runs it: one at a time";
|
|
46
|
+
export const CHAIN_FAILED_THEN = "then type /dev-batches: the run goes on from the first batch not done";
|
|
47
|
+
export const batchesChainFailed = (crew: string, error: string) => `✗ the dev-batches chain failed (${crew}): ${error}`;
|
|
48
|
+
export const A_CREW = "a crew";
|
|
49
|
+
export const batchesChainStopped = (reason: string) => `✗ the dev-batches chain stopped (${reason}): ${CHAIN_FAILED_THEN}`;
|
|
50
|
+
export const chainNotKept = (reason: string) =>
|
|
51
|
+
`dev-batches: the session could not keep which chain runs (${reason}): nothing was launched`;
|
|
52
|
+
export const auditFailed = (error: string) => `✗ the audit failed: ${error}`;
|
|
53
|
+
|
|
54
|
+
// /dev-spec and /dev-change
|
|
55
|
+
export const DEV_SPEC_USAGE =
|
|
56
|
+
'usage: /dev-spec <code> [bug | refactor | perf] [--run "<command>"] [<brief text> | <path>.md | <#issue> | <revision request>]';
|
|
57
|
+
/** Why --run needs a kind, said where it is refused. */
|
|
58
|
+
export const RUN_NEEDS_KIND =
|
|
59
|
+
"--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";
|
|
60
|
+
export const withUsage = (text: string, usage: string) => `${text}\n${usage}`;
|
|
61
|
+
export const notASpecCode = (word: string) => `'${word}' is not a code (letters, digits, '.', '_', '-')`;
|
|
62
|
+
export const RUN_NEEDS_COMMAND = "--run needs the command, quoted";
|
|
63
|
+
export const RUN_BEFORE_TEXT = "--run comes before the text";
|
|
64
|
+
|
|
65
|
+
// /dev-status
|
|
66
|
+
export const DEV_STATUS_USAGE = "usage: /dev-status [<code>]";
|
|
67
|
+
export const NOT_IN_THE_PLAN = "not in the plan";
|
|
68
|
+
export const NO_VERDICT = "no verdict";
|
|
69
|
+
export const NO_SHEET = "no sheet";
|
|
70
|
+
export const workFolderLine = (label: string) => `work folder: ${label}`;
|
|
71
|
+
export const packLine = (shown: string) => `pack: ${shown}`;
|
|
72
|
+
export const warningLine = (warning: string) => `warning: ${warning}`;
|
|
73
|
+
export const moreWarnings = (count: number) => `… ${count} more warnings`;
|
|
74
|
+
export const sheetOpenTicks = (id: string, red: number, steps: number) =>
|
|
75
|
+
`${id} is done in the plan but its sheet has open ticks (RED ${red}/${steps})`;
|
|
76
|
+
export const validButOpen = (id: string) => `${id} is VALID but the plan still says open`;
|
|
77
|
+
export const noBatchLine = (name: string) => `${name} has no batch line in the plan`;
|
|
78
|
+
export const planLine = (name: string, feature: string, batches: number, done: number) =>
|
|
79
|
+
`plan ${name}${feature} (${batches} batches, ${done} done)`;
|
|
80
|
+
export const moreBatches = (count: number, first: string, last: string) => `… ${count} more batches (${first} to ${last})`;
|
|
81
|
+
export const noCodeUnder = (folder: string) =>
|
|
82
|
+
`no code under ${folder}/ (a code is a folder holding SPEC-, CHANGE- or *-PLAN.md files)`;
|
|
83
|
+
export const moreFoldersNotProbed = (count: number) => `… ${count} more folders not probed`;
|
|
84
|
+
export const notAStatusCode = (code: string) =>
|
|
85
|
+
`dev-status: '${code}' is not a code: letters, digits, '.', '_' and '-', starting with a letter or a digit`;
|
|
86
|
+
export const workFolderInMainWorktree = (folder: string) =>
|
|
87
|
+
`dev-status: the work folder ${folder} is in the main worktree, outside the mounts: run /dev-status from the main checkout`;
|
|
88
|
+
export const devStatusCannotList = (folder: string, reason: string) => `dev-status: ${folder}/ cannot be listed (${reason})`;
|
|
89
|
+
export const holdsNoDevFile = (folder: string, code: string) =>
|
|
90
|
+
`dev-status: ${folder}/${code}/ holds no SPEC-, CHANGE- or *-PLAN.md file`;
|
|
91
|
+
export const codesHere = (codes: string) => `codes here: ${codes}`;
|
|
92
|
+
export const NO_CODE_HERE = "no code here";
|
|
93
|
+
export const noFolder = (folder: string, code: string, here: string) => `dev-status: no folder ${folder}/${code}/ (${here})`;
|
|
94
|
+
|
|
95
|
+
// /dev-learn
|
|
96
|
+
export const DEV_LEARN_USAGE = "usage: /dev-learn [<axis>] [--list] | --accept <id>[,<id>…] | --refuse <id | motif text>";
|
|
97
|
+
export const ACCEPT_REFUSE_ALONE = "dev-learn: --accept and --refuse each come alone";
|
|
98
|
+
export const notAProposalId = (piece: string) =>
|
|
99
|
+
`dev-learn: '${piece}' is not a proposal id (8 or 10 hex digits, from PROPOSALS.md)`;
|
|
100
|
+
export const ACCEPT_NEEDS_ID = "dev-learn: --accept needs at least one proposal id, e.g. --accept 3f2a9c1e";
|
|
101
|
+
export const REFUSE_NEEDS_TARGET = "dev-learn: --refuse needs a proposal id or the motif's words";
|
|
102
|
+
export const REFUSED_MOTIF_TOO_LONG = "dev-learn: a refused motif is at most 200 characters";
|
|
103
|
+
export const learnUnknownOption = (token: string) => `dev-learn: unknown option '${token}' (--list, --accept, --refuse)`;
|
|
104
|
+
export const oneAxisAtMost = (axis: string, token: string) => `dev-learn: one axis at most, not '${axis}' and '${token}'`;
|
|
105
|
+
export const notAnAxis = (token: string) => `dev-learn: '${token}' is not an axis`;
|
|
106
|
+
|
|
107
|
+
// /dev-plan
|
|
108
|
+
export const DEV_PLAN_USAGE = "usage: /dev-plan [<code> | <path>/SPEC-<code>.md | <path>/CHANGE-<code>.md] [--replace]";
|
|
109
|
+
export const REPLACE_ONCE = "dev-plan: --replace once at most";
|
|
110
|
+
export const planUnknownOption = (token: string) => `dev-plan: unknown option '${token}' (only --replace)`;
|
|
111
|
+
export const oneSourceAtMost = (source: string, token: string) =>
|
|
112
|
+
`dev-plan: one source at most, not '${source}' and '${token}'`;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
// The start of a dev step, in its command's dispatch: the host's gate must be on, then the gate is
|
|
2
|
+
// handed the session's rules and the step's rule sets (shared/domain/dev/step-rules.ts), just before
|
|
3
|
+
// the crew is launched; the /hooks registry is read for the crew's input (its tool callbacks run the hooks). Not a
|
|
4
|
+
// command file: the loader reads *.cmd.ts only.
|
|
5
|
+
import type { PermissionRules, SessionStore, ToolCatalogue } from "../../shared/application/ports.ts";
|
|
6
|
+
import type { SessionIo } from "../../shared/application/session-io.ts";
|
|
7
|
+
import type { ConfigStore } from "../../shared/application/config-store.ts";
|
|
8
|
+
import { configuredNames, resolveExtraTools } from "../../shared/application/extra-tools.ts";
|
|
9
|
+
import { builtInRules, syncStepRules } from "../../shared/application/permission-rules.ts";
|
|
10
|
+
import { readMemoryDir } from "../../shared/application/shared-memory/memory-settings.ts";
|
|
11
|
+
import { listsOf } from "../../shared/application/host-context.ts";
|
|
12
|
+
import type { HostSource } from "../../shared/application/host-context.ts";
|
|
13
|
+
import { readJsonArray } from "../../shared/application/session-state.ts";
|
|
14
|
+
import { HOOKS_STATE_KEY } from "../../shared/domain/session-keys.ts";
|
|
15
|
+
import { deniesEveryCall, formatRule } from "../../shared/domain/agent-policy/permission.ts";
|
|
16
|
+
import { parseSessionRules } from "../../shared/domain/git/pull-request.ts";
|
|
17
|
+
import type { RuleSetId } from "../../shared/domain/agent-policy/rule-sets.ts";
|
|
18
|
+
import { STEP_RULE_SETS, gateProblem, stepCommand, stepRules } from "../../shared/domain/dev/step-rules.ts";
|
|
19
|
+
import type { DevStep } from "../../shared/domain/dev/step-rules.ts";
|
|
20
|
+
import { isCode } from "../../shared/domain/dev/artefacts.ts";
|
|
21
|
+
import { policyFor } from "../../shared/domain/agent-policy/mode-policy.ts";
|
|
22
|
+
import { isPermissionMode } from "../../shared/domain/permission-modes.ts";
|
|
23
|
+
import type { ActiveWorkflow } from "../../shared/domain/workflow/state-file.ts";
|
|
24
|
+
import { writeActiveWorkflow } from "../../shared/application/workflow/workflow-state.ts";
|
|
25
|
+
import {
|
|
26
|
+
batchNotRecorded, modeReadOnlyRefusal, modeUnknownRefusal, modeUnreadableRefusal, sessionRuleLeftOut,
|
|
27
|
+
stepRulesNotInGate,
|
|
28
|
+
} from "./messages.ts";
|
|
29
|
+
|
|
30
|
+
export interface DevStepDeps {
|
|
31
|
+
session: Pick<SessionStore, "readState">;
|
|
32
|
+
gate: PermissionRules;
|
|
33
|
+
config: Pick<ConfigStore, "readValue" | "readFile">;
|
|
34
|
+
catalogue: Pick<ToolCatalogue, "find">;
|
|
35
|
+
/** This run's host context, for its path lists (paths.deny in the gate); absent: no list. */
|
|
36
|
+
host?: HostSource;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export type DevStepStart =
|
|
40
|
+
| {
|
|
41
|
+
ok: true; lines: string[]; sets: readonly RuleSetId[]; rules: number; hooks: unknown[];
|
|
42
|
+
/** What the crew's input carries besides the step's own arguments: the /hooks registry, and
|
|
43
|
+
* `memoryRecall: false` when a rule in the gate denies every call of memory_recall. */
|
|
44
|
+
input: { hooks: unknown[]; memoryRecall?: false };
|
|
45
|
+
}
|
|
46
|
+
| { ok: false; line: string };
|
|
47
|
+
|
|
48
|
+
/** The step dev-verify runs: none with --gate-only, which runs no model. */
|
|
49
|
+
export function devVerifyStep(args: { gateOnly: boolean }): DevStep | null {
|
|
50
|
+
return args.gateOnly ? null : "dev-verify";
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Refuses when the host says its gate is off; otherwise puts the session's rules, then the step's
|
|
54
|
+
* rule sets, in the gate, and returns the warning lines the command prints before launching and the
|
|
55
|
+
* /hooks registry the crew's input carries. */
|
|
56
|
+
export async function startDevStep(step: DevStep, deps: DevStepDeps): Promise<DevStepStart> {
|
|
57
|
+
const problem = gateProblem(deps.gate.enabled(), step);
|
|
58
|
+
if (problem?.refuse) return { ok: false, line: problem.line };
|
|
59
|
+
const lines = problem ? [problem.line] : [];
|
|
60
|
+
const extras = await resolveExtraTools(deps);
|
|
61
|
+
const sync = await syncStepRules({
|
|
62
|
+
session: deps.session, gate: deps.gate, extraNames: configuredNames(extras), rules: stepRules(step),
|
|
63
|
+
builtIn: builtInRules((await readMemoryDir(deps.config)).dir, await listsOf(deps.host)),
|
|
64
|
+
});
|
|
65
|
+
if (!sync.applied) lines.push(stepRulesNotInGate(stepCommand(step)));
|
|
66
|
+
for (const r of sync.overridden) lines.push(sessionRuleLeftOut(formatRule(r), stepCommand(step)));
|
|
67
|
+
const hooks = await readJsonArray(deps.session, HOOKS_STATE_KEY);
|
|
68
|
+
const memoryDenied = deniesEveryCall(gateRules(deps.gate), "memory_recall");
|
|
69
|
+
return {
|
|
70
|
+
ok: true, lines, sets: STEP_RULE_SETS[step], rules: sync.step.length, hooks,
|
|
71
|
+
input: { hooks, ...(memoryDenied ? { memoryRecall: false as const } : {}) },
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The rules in the gate, parsed; none when the host keeps none. */
|
|
76
|
+
function gateRules(gate: PermissionRules) {
|
|
77
|
+
try {
|
|
78
|
+
return gate.available() ? parseSessionRules(gate.list()) : [];
|
|
79
|
+
} catch {
|
|
80
|
+
return [];
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* The line refusing a step that writes files when the session's mode is read-only, or could not be read (`""`:
|
|
86
|
+
* a step never writes on a mode it does not know); null when it may run. `writes` says what the step writes.
|
|
87
|
+
*/
|
|
88
|
+
export function writeModeRefusal(mode: string, step: string, writes: string): string | null {
|
|
89
|
+
if (mode === "") return modeUnreadableRefusal(stepCommand(step), writes);
|
|
90
|
+
if (!isPermissionMode(mode)) return modeUnknownRefusal(mode, stepCommand(step), writes);
|
|
91
|
+
if (!policyFor(mode).readOnly) return null;
|
|
92
|
+
return modeReadOnlyRefusal(mode, stepCommand(step), writes);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** writeModeRefusal over the session's effective mode, read here: a read that fails refuses. */
|
|
96
|
+
export async function readWriteModeRefusal(
|
|
97
|
+
session: Pick<SessionIo, "resolveEffectiveSessionMode">, step: string, writes: string,
|
|
98
|
+
): Promise<string | null> {
|
|
99
|
+
let mode = "";
|
|
100
|
+
try {
|
|
101
|
+
mode = String((await session.resolveEffectiveSessionMode()).mode ?? "");
|
|
102
|
+
} catch { /* unknown: refused below */ }
|
|
103
|
+
return writeModeRefusal(mode, step, writes);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** Before a launch of dev-implement's chain (the audit, then the close), which runs no dispatch of its own: the
|
|
107
|
+
* gate must still be on, and the step's rules are put back on top of whatever the gate holds (an /assistant turn
|
|
108
|
+
* in between hands it the session's rules alone). The gate is not cleared: the rules an earlier hop added stay
|
|
109
|
+
* until the next sync (the next command, the next /assistant turn): an earlier hop's allows with them, but the
|
|
110
|
+
* gate puts every deny before an allow, so this step's denies still win. The session's own rules and mode are read
|
|
111
|
+
* again by the hop itself (readPullRequestContext, Orkeon #220) and handed to the crew. Null when the
|
|
112
|
+
* launch may go, else the line refusing it. */
|
|
113
|
+
export function reapplyStepRules(gate: PermissionRules, step: DevStep): string | null {
|
|
114
|
+
const problem = gateProblem(gate.enabled(), step);
|
|
115
|
+
if (problem?.refuse) return problem.line;
|
|
116
|
+
if (!gate.available()) return null;
|
|
117
|
+
for (const rule of stepRules(step)) gate.add(rule);
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** The batch a step works on, for the state file a compaction writes: the code is the plan
|
|
122
|
+
* token when it is a code, the folder of a `.../<CODE>-PLAN.md` path, else null (the writer
|
|
123
|
+
* then looks for the batch's open sheet). */
|
|
124
|
+
export function activeWorkflowOf(args: { batch: string; plan: string | null }): ActiveWorkflow {
|
|
125
|
+
const plan = args.plan;
|
|
126
|
+
if (plan === null) return { code: null, phase: args.batch };
|
|
127
|
+
if (!plan.endsWith("-PLAN.md")) return { code: isCode(plan) ? plan : null, phase: args.batch };
|
|
128
|
+
const parts = plan.replace(/\\/g, "/").split("/").filter((p) => p.length > 0);
|
|
129
|
+
const folder = parts.length >= 2 ? parts[parts.length - 2] : "";
|
|
130
|
+
return { code: isCode(folder) ? folder : null, phase: args.batch };
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** Records the batch in progress in the session; a session that cannot keep it costs the
|
|
134
|
+
* state file only, so the failure comes back as a warning line, never a refusal. */
|
|
135
|
+
export async function markActiveWorkflow(
|
|
136
|
+
session: Pick<SessionStore, "writeState">, args: { batch: string; plan: string | null },
|
|
137
|
+
): Promise<string | null> {
|
|
138
|
+
try {
|
|
139
|
+
await writeActiveWorkflow(session, activeWorkflowOf(args));
|
|
140
|
+
return null;
|
|
141
|
+
} catch (error) {
|
|
142
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
143
|
+
return batchNotRecorded(reason);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
// Presentation helpers shared by the slash-command handlers. Kept under
|
|
2
|
+
// commands/_lib/ — the loader's SearchPattern is "*.cmd.ts", so this file is
|
|
3
|
+
// never loaded as a command (it is only bundled into the handlers that import
|
|
4
|
+
// it). No domain logic here; just the control-plane glue (SPEC §2). The entry
|
|
5
|
+
// point wires the crew host and the permission gate from its context
|
|
6
|
+
// (createCrewHost(ctx.services), createPermissionRules(ctx.services)) and hands
|
|
7
|
+
// them over with the command's log.
|
|
8
|
+
|
|
9
|
+
import { routeAgent } from "../../shared/application/agents/route-agent.ts";
|
|
10
|
+
import type { RouteDeps, RouteTask } from "../../shared/application/agents/route-agent.ts";
|
|
11
|
+
import type { CrewHost, CrewLaunchOptions, PermissionRules, ToolCatalogue } from "../../shared/application/ports.ts";
|
|
12
|
+
import type { ConfigStore } from "../../shared/application/config-store.ts";
|
|
13
|
+
import type { SessionIo } from "../../shared/application/session-io.ts";
|
|
14
|
+
import { configuredNames, resolveExtraTools } from "../../shared/application/extra-tools.ts";
|
|
15
|
+
import { readLlmProfile } from "../../shared/application/llm-profile.ts";
|
|
16
|
+
import { builtInRules, syncPermissionRules } from "../../shared/application/permission-rules.ts";
|
|
17
|
+
import { readMemoryDir } from "../../shared/application/shared-memory/memory-settings.ts";
|
|
18
|
+
import { listsOf } from "../../shared/application/host-context.ts";
|
|
19
|
+
import type { HostSource } from "../../shared/application/host-context.ts";
|
|
20
|
+
import { formatRule } from "../../shared/domain/agent-policy/permission.ts";
|
|
21
|
+
import { chainDepthLine, chainDepthRefusal } from "../../shared/domain/agents/chain.ts";
|
|
22
|
+
import { exclusiveLine, exclusiveRefusal } from "../../shared/domain/agents/exclusive.ts";
|
|
23
|
+
import { LLM_PROFILE_FALLBACK_INPUT_KEY, LLM_PROFILE_INPUT_KEY } from "../../shared/domain/llm-profile.ts";
|
|
24
|
+
import { errorText } from "../../shared/domain/prelude.ts";
|
|
25
|
+
import type { EpilogueCall, PreludeCall } from "../../shared/domain/prelude.ts";
|
|
26
|
+
import type { StartOutput } from "../../shared/domain/session-start.ts";
|
|
27
|
+
import { SPEAK_TOOL, VOICE_REPLY_CONFIG_KEY, voiceReplyEpilogue, voiceReplyOn } from "../../shared/domain/speech.ts";
|
|
28
|
+
import { EXTRA_TOOLS_CONFIG_KEY, formatExtraTool } from "../../shared/domain/agent-policy/extra-tools.ts";
|
|
29
|
+
import { EXTRA_TOOL_ENTRY_RULE } from "../../shared/domain/agent-policy/messages.ts";
|
|
30
|
+
import {
|
|
31
|
+
extraToolIgnored, extraToolMissing, extraToolsUnreadable, invalidPermissionEntries, NO_SESSION_RULES, ruleDormant,
|
|
32
|
+
ruleOverridden, voiceReplyNoSpeakTool, voiceReplyUnreadable,
|
|
33
|
+
} from "./messages.ts";
|
|
34
|
+
|
|
35
|
+
/** The command's log as the runtime hands it to a command: a line and its details. */
|
|
36
|
+
export interface CommandLog {
|
|
37
|
+
info(message: string, data?: object): void;
|
|
38
|
+
warn(message: string, data?: object): void;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** What a crew launch needs: the host that runs crews, the command's log, and the session's `llm.profile` when
|
|
42
|
+
* the command read it (withLlmProfile): the crew input then carries it as `llmProfile`, and every agent of the
|
|
43
|
+
* crew runs on that profile. Undefined or null, the input carries nothing and the agents run on the host's default model. */
|
|
44
|
+
export interface LaunchDeps {
|
|
45
|
+
crews: Pick<CrewHost, "launch">;
|
|
46
|
+
log: Pick<CommandLog, "info">;
|
|
47
|
+
llmProfile?: string | null;
|
|
48
|
+
/** Set when the routing picked `llmProfile`: the session's own profile ("" for the host's default model), which the
|
|
49
|
+
* crew falls back on when the host declares no profile of the routed name. */
|
|
50
|
+
llmProfileFallback?: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** `deps` with the session's `llm.profile` read: what every command hands launchCrew. A setting that cannot be
|
|
54
|
+
* read, or holds no profile name, is warned about and the launch goes on without it. */
|
|
55
|
+
export async function withLlmProfile<D extends LaunchDeps & { log: Pick<CommandLog, "warn"> }>(
|
|
56
|
+
deps: D, config: Pick<ConfigStore, "readValue" | "readFile">,
|
|
57
|
+
): Promise<D & { llmProfile: string | null }> {
|
|
58
|
+
const read = await readLlmProfile(config);
|
|
59
|
+
if (read.warning !== undefined) deps.log.warn(read.warning);
|
|
60
|
+
return { ...deps, llmProfile: read.profile };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** `deps` with the profile the launch of `task.crew` runs on: the session's `llm.profile`, then, with `route.agents`
|
|
64
|
+
* on, the rung of the ladder the host's decision model picks for the command (shared/application/agents/route-agent). */
|
|
65
|
+
export async function withRoutedProfile<D extends LaunchDeps & { log: Pick<CommandLog, "warn" | "info"> }>(
|
|
66
|
+
deps: D, config: Pick<ConfigStore, "readValue" | "readFile">, routing: Omit<RouteDeps, "config" | "log">, task: RouteTask,
|
|
67
|
+
): Promise<D & { llmProfile: string | null }> {
|
|
68
|
+
const profiled = await withLlmProfile(deps, config);
|
|
69
|
+
const routed = await routeAgent({ ...routing, config, log: deps.log }, task, profiled.llmProfile);
|
|
70
|
+
return routed === profiled.llmProfile ? profiled : { ...profiled, llmProfile: routed, llmProfileFallback: profiled.llmProfile ?? "" };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** A crew's completion, as an async command's `completed` receives it; `intent` names the crew that answered,
|
|
74
|
+
* `streamed` says the console already showed the answer as it was generated (Orkeon #228). */
|
|
75
|
+
export interface CrewCompletion {
|
|
76
|
+
success: boolean;
|
|
77
|
+
intent?: string;
|
|
78
|
+
payload?: string;
|
|
79
|
+
error?: string;
|
|
80
|
+
streamed?: boolean;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** What a launch hands back to the runtime: the ticket, or the refusal of a hop past MaxChainDepth or of a crew
|
|
84
|
+
* already running; the runtime prints `message`. */
|
|
85
|
+
export type LaunchResult = { ticket: string } | { refused: string; message: string };
|
|
86
|
+
|
|
87
|
+
/** Launch a crew on the script-host and return its ticket (async commands). The
|
|
88
|
+
* launch is logged with the ticket, plus `details` when the caller has any. A
|
|
89
|
+
* launch from a `completed` past the chain's limit (V-A5, shared/domain/agents/chain.ts,
|
|
90
|
+
* `chain depth <d> reached (MaxChainDepth <l>, /<command>)`) comes back as `{ refused }`
|
|
91
|
+
* with the line saying so, as does a crew launched with `{ exclusive: true }` while its
|
|
92
|
+
* previous launch runs (Orkeon #239, shared/domain/agents/exclusive.ts, `crew '<name>'
|
|
93
|
+
* already running (ticket <t>)`); any other failure throws. A driver relaunching its own
|
|
94
|
+
* work passes `{ chain: "continue" }` as `options` (Orkeon #221) and keeps the parent's depth. */
|
|
95
|
+
export function launchCrew(
|
|
96
|
+
deps: LaunchDeps,
|
|
97
|
+
crew: string,
|
|
98
|
+
input: Record<string, unknown> = {},
|
|
99
|
+
details: Record<string, unknown> = {},
|
|
100
|
+
options?: CrewLaunchOptions,
|
|
101
|
+
): LaunchResult {
|
|
102
|
+
const profile = deps.llmProfile ?? null;
|
|
103
|
+
if (profile !== null) {
|
|
104
|
+
input = { ...input, [LLM_PROFILE_INPUT_KEY]: profile };
|
|
105
|
+
if (deps.llmProfileFallback !== undefined) input = { ...input, [LLM_PROFILE_FALLBACK_INPUT_KEY]: deps.llmProfileFallback };
|
|
106
|
+
details = { ...details, llmProfile: profile };
|
|
107
|
+
}
|
|
108
|
+
let ticket: string;
|
|
109
|
+
try {
|
|
110
|
+
ticket = deps.crews.launch(crew, input, options);
|
|
111
|
+
} catch (error) {
|
|
112
|
+
const busy = exclusiveRefusal(error);
|
|
113
|
+
if (busy !== null) {
|
|
114
|
+
const line = exclusiveLine(busy);
|
|
115
|
+
deps.log.info(line, { ...busy, ...details });
|
|
116
|
+
return { refused: line, message: line };
|
|
117
|
+
}
|
|
118
|
+
const refusal = chainDepthRefusal(error);
|
|
119
|
+
if (refusal === null) throw error;
|
|
120
|
+
const line = chainDepthLine(crew, refusal);
|
|
121
|
+
deps.log.info(line, { ...refusal, ...details });
|
|
122
|
+
return { refused: line, message: line };
|
|
123
|
+
}
|
|
124
|
+
deps.log.info(crew + " launched", { ticket, ...details });
|
|
125
|
+
return { ticket };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** What launching the main loop reads: the session (its mode and rules), the
|
|
129
|
+
* `tools.extra` setting and the tools the host registers; and what it drives:
|
|
130
|
+
* the host's permission gate and the crew launch. */
|
|
131
|
+
export interface MainLoopLaunchDeps extends LaunchDeps {
|
|
132
|
+
log: CommandLog;
|
|
133
|
+
session: Pick<SessionIo, "readState" | "resolveEffectiveSessionMode">;
|
|
134
|
+
config: Pick<ConfigStore, "readValue" | "readFile">;
|
|
135
|
+
catalogue: Pick<ToolCatalogue, "find">;
|
|
136
|
+
gate: PermissionRules;
|
|
137
|
+
/** This run's host context, for its path lists (paths.deny in the gate); absent: no list. */
|
|
138
|
+
host?: HostSource;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Launch the main loop with everything that decides its tool catalogue, which
|
|
143
|
+
* the crew builds at load time, synchronously, from its inputs alone:
|
|
144
|
+
* - the mode: the request's `mode:` prefix, else the session's (/mode, else the
|
|
145
|
+
* fallback), resolved here, with where it came from for the crew to log;
|
|
146
|
+
* - the extra tools the host registers, each configured one it does not
|
|
147
|
+
* register warned about and left out;
|
|
148
|
+
* - the session's rules, handed to the host gate first, so the turn runs under
|
|
149
|
+
* the rules the session holds whatever the gate kept from an earlier command,
|
|
150
|
+
* then the built-in denies on the shared memory's candidates and entries.
|
|
151
|
+
* A `prelude` (a tool call the crew makes before the turn: /transcribe --then,
|
|
152
|
+
* /voice --go) rides along as it is. With voice.reply on, an epilogue has the crew read the
|
|
153
|
+
* answer aloud with the speech server's speak, when the host registers it. The start
|
|
154
|
+
* script's output (`sessionStart`, the first turn of a session) rides along too.
|
|
155
|
+
*/
|
|
156
|
+
export async function launchMainLoop(
|
|
157
|
+
deps: MainLoopLaunchDeps,
|
|
158
|
+
input: { prompt: string; permissionMode: string | null; prelude?: PreludeCall; sessionStart?: StartOutput | null },
|
|
159
|
+
): Promise<LaunchResult> {
|
|
160
|
+
const { session, log } = deps;
|
|
161
|
+
const resolved = input.permissionMode === null ? await session.resolveEffectiveSessionMode() : null;
|
|
162
|
+
const permissionMode = resolved ? resolved.mode : input.permissionMode;
|
|
163
|
+
|
|
164
|
+
const extras = await resolveExtraTools(deps);
|
|
165
|
+
for (const tool of extras.missing) log.warn(extraToolMissing(tool.name));
|
|
166
|
+
for (const entry of extras.invalid) {
|
|
167
|
+
log.warn(extraToolIgnored(EXTRA_TOOLS_CONFIG_KEY, entry, EXTRA_TOOL_ENTRY_RULE));
|
|
168
|
+
}
|
|
169
|
+
if (extras.unreadable !== undefined) {
|
|
170
|
+
log.warn(extraToolsUnreadable(EXTRA_TOOLS_CONFIG_KEY, extras.unreadable));
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const builtIn = builtInRules((await readMemoryDir(deps.config)).dir, await listsOf(deps.host));
|
|
174
|
+
const sync = await syncPermissionRules({ session, gate: deps.gate, extraNames: configuredNames(extras), builtIn });
|
|
175
|
+
for (const rule of sync.overridden) log.warn(ruleOverridden(formatRule(rule)));
|
|
176
|
+
for (const rule of sync.dormant) log.warn(ruleDormant(rule, EXTRA_TOOLS_CONFIG_KEY));
|
|
177
|
+
if (sync.invalid.length > 0) log.warn(invalidPermissionEntries(sync.invalid.length));
|
|
178
|
+
if (!sync.applied) log.warn(NO_SESSION_RULES);
|
|
179
|
+
const epilogue = await voiceReply(deps);
|
|
180
|
+
const profiled = deps.llmProfile === undefined ? await withLlmProfile(deps, deps.config) : deps;
|
|
181
|
+
return launchCrew(
|
|
182
|
+
profiled,
|
|
183
|
+
"main-loop",
|
|
184
|
+
{
|
|
185
|
+
prompt: input.prompt,
|
|
186
|
+
permissionMode,
|
|
187
|
+
...(resolved ? { permissionModeVia: resolved.via } : {}),
|
|
188
|
+
permissionRules: sync.rules.map(formatRule),
|
|
189
|
+
extraTools: extras.present.map(formatExtraTool),
|
|
190
|
+
...(input.prelude ? { prelude: input.prelude } : {}),
|
|
191
|
+
...(epilogue ? { epilogue } : {}),
|
|
192
|
+
...(input.sessionStart ? { sessionStart: input.sessionStart } : {}),
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
permissionMode, permissionRules: sync.rules.length, extraTools: extras.present.length,
|
|
196
|
+
...(input.prelude ? { prelude: input.prelude.tool } : {}),
|
|
197
|
+
...(epilogue ? { epilogue: epilogue.tool } : {}),
|
|
198
|
+
...(input.sessionStart ? { sessionStartLines: input.sessionStart.lines.length } : {}),
|
|
199
|
+
},
|
|
200
|
+
{ onMain: true },
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/** The epilogue voice.reply asks for: speak under its registered name when the setting
|
|
205
|
+
* is on and the host registers it; none otherwise, with a warning when it is on. */
|
|
206
|
+
async function voiceReply(deps: Pick<MainLoopLaunchDeps, "config" | "catalogue" | "log">): Promise<EpilogueCall | undefined> {
|
|
207
|
+
let value: string | undefined;
|
|
208
|
+
try {
|
|
209
|
+
value = (await deps.config.readValue(VOICE_REPLY_CONFIG_KEY)).value;
|
|
210
|
+
} catch (error) {
|
|
211
|
+
deps.log.warn(voiceReplyUnreadable(VOICE_REPLY_CONFIG_KEY, errorText(error)));
|
|
212
|
+
return undefined;
|
|
213
|
+
}
|
|
214
|
+
if (!voiceReplyOn(value)) return undefined;
|
|
215
|
+
const speak = deps.catalogue.find(SPEAK_TOOL);
|
|
216
|
+
if (speak === undefined) {
|
|
217
|
+
deps.log.warn(voiceReplyNoSpeakTool(VOICE_REPLY_CONFIG_KEY, SPEAK_TOOL));
|
|
218
|
+
return undefined;
|
|
219
|
+
}
|
|
220
|
+
return voiceReplyEpilogue(speak);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/** The opening of a markdown block a prefix on the same line would turn into plain text. */
|
|
224
|
+
const OPENS_ON_A_BLOCK = /^\s*(#{1,6}\s|```|~~~|[-*+]\s|\d+\.\s|>|\|)/;
|
|
225
|
+
|
|
226
|
+
/** `<okPrefix><payload>`, the prefix on its own line when the payload opens on a block. */
|
|
227
|
+
function prefixed(okPrefix: string, payload: string): string {
|
|
228
|
+
const inline = !okPrefix || okPrefix.endsWith("\n") || !OPENS_ON_A_BLOCK.test(payload);
|
|
229
|
+
return inline ? okPrefix + payload : `${okPrefix.trimEnd()}\n\n${payload}`;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/** Write a crew's completion: `<okPrefix><payload>` as a markdown block, or the line `✗ <label> failed: …`; nothing
|
|
233
|
+
* for a success the console already streamed, or the answer would show twice (Orkeon #228). */
|
|
234
|
+
export function writeCompleted(
|
|
235
|
+
out: { writeLine(text: string): void; writeBlock(spec: { kind: "markdown"; text: string }): void },
|
|
236
|
+
result: CrewCompletion,
|
|
237
|
+
label: string,
|
|
238
|
+
okPrefix = "",
|
|
239
|
+
): void {
|
|
240
|
+
if (result.success && result.streamed === true) return;
|
|
241
|
+
if (result.success) out.writeBlock({ kind: "markdown", text: prefixed(okPrefix, String(result.payload)) });
|
|
242
|
+
else out.writeLine("✗ " + label + " failed: " + (result.error ?? "unknown"));
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/** `writeCompleted` for what a program wrote and no model did: a transcript, a count. Markdown would change it (the
|
|
246
|
+
* stars of `*.ts`, the underscores of `__init__.py`), so it stays a line. */
|
|
247
|
+
export function writePlainCompleted(
|
|
248
|
+
out: { writeLine(text: string): void },
|
|
249
|
+
result: CrewCompletion,
|
|
250
|
+
label: string,
|
|
251
|
+
): void {
|
|
252
|
+
if (result.success && result.streamed === true) return;
|
|
253
|
+
out.writeLine(result.success ? String(result.payload) : "✗ " + label + " failed: " + (result.error ?? "unknown"));
|
|
254
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// The effort level a command hands its crew (A-3): the one /effort stored, which the crew forwards to the
|
|
2
|
+
// provider (`act({effort})`, AgentBuilder.effort); null when none is stored or the session cannot say, so an
|
|
3
|
+
// unconfigured session turns no thinking on.
|
|
4
|
+
import type { SessionIo } from "../../shared/application/session-io.ts";
|
|
5
|
+
import { EFFORT_STATE_KEY } from "../../shared/domain/session-keys.ts";
|
|
6
|
+
import { providerEffort } from "../../shared/domain/agent-policy/behavior-flags.ts";
|
|
7
|
+
import type { EffortLevel } from "../../shared/domain/agent-policy/behavior-flags.ts";
|
|
8
|
+
|
|
9
|
+
export async function storedEffort(session: Pick<SessionIo, "readState">): Promise<EffortLevel | null> {
|
|
10
|
+
try {
|
|
11
|
+
return providerEffort(await session.readState(EFFORT_STATE_KEY)) ?? null;
|
|
12
|
+
} catch {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// /branch — the uncommitted-changes guard, and the validation of a branch name
|
|
2
|
+
// before it reaches the shell (B-11 deepening); runBranch runs them over the
|
|
3
|
+
// Shell port. Lives under commands/_lib/ — the loader's SearchPattern is
|
|
4
|
+
// "*.cmd.ts", so this file is never loaded as a command.
|
|
5
|
+
|
|
6
|
+
import type { Logger, Shell } from "../../../shared/application/ports.ts";
|
|
7
|
+
import type { CommandView } from "../view.ts";
|
|
8
|
+
import {
|
|
9
|
+
andMore, branchRefusedLog, checkoutFailed, dirtyTreeRefusal, exitCode, looksLikeOption, notABranchName, switchedTo,
|
|
10
|
+
} from "./messages.ts";
|
|
11
|
+
|
|
12
|
+
/** True when `git status --porcelain` reported at least one changed path. */
|
|
13
|
+
export function hasUncommittedChanges(porcelain: unknown): boolean {
|
|
14
|
+
return String(porcelain ?? "")
|
|
15
|
+
.split("\n")
|
|
16
|
+
.some((line) => line.trim().length > 0);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Branch names git itself accepts, minus anything a shell would reinterpret. */
|
|
20
|
+
const SAFE_BRANCH = /^[A-Za-z0-9._/\-]+$/;
|
|
21
|
+
|
|
22
|
+
export type BranchPlan =
|
|
23
|
+
| { action: "show" }
|
|
24
|
+
| { action: "checkout"; branch: string }
|
|
25
|
+
| { action: "refuse"; reason: string };
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* What `/branch [name]` should do.
|
|
29
|
+
*
|
|
30
|
+
* A bare `/branch` shows the current one (an addition of Orkeon Code: it is the question
|
|
31
|
+
* asked most often and it costs nothing). A name is validated before it reaches the
|
|
32
|
+
* shell — the tool allowlists `git`, so an unvalidated name is not an injection,
|
|
33
|
+
* but `git checkout --orphan` typed as a "branch" is a different operation than the
|
|
34
|
+
* one the operator asked for.
|
|
35
|
+
*/
|
|
36
|
+
export function planBranch(tokens: readonly string[]): BranchPlan {
|
|
37
|
+
const name = String((tokens ?? [])[0] ?? "").trim();
|
|
38
|
+
if (name.length === 0) return { action: "show" };
|
|
39
|
+
if (name.startsWith("-")) {
|
|
40
|
+
return { action: "refuse", reason: looksLikeOption(name) };
|
|
41
|
+
}
|
|
42
|
+
if (!SAFE_BRANCH.test(name)) {
|
|
43
|
+
return {
|
|
44
|
+
action: "refuse",
|
|
45
|
+
reason: notABranchName(name),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return { action: "checkout", branch: name };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The refusal text for a dirty working tree.
|
|
53
|
+
*
|
|
54
|
+
* A refusal, not a warning: `git checkout` with local modifications either fails
|
|
55
|
+
* with git's own error or carries the changes onto the new branch, and the second
|
|
56
|
+
* outcome is the one that loses work quietly. The message names both ways out.
|
|
57
|
+
*/
|
|
58
|
+
export function describeDirtyTreeRefusal(branch: string, porcelain: string): string {
|
|
59
|
+
const changed = porcelain.split("\n").filter((l) => l.trim().length > 0);
|
|
60
|
+
const shown = changed.slice(0, 5).map((l) => ` ${l.trim()}`).join("\n");
|
|
61
|
+
return dirtyTreeRefusal(branch, changed.length, shown, changed.length > 5 ? andMore(changed.length - 5) : "");
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface BranchDeps {
|
|
65
|
+
shell: Shell;
|
|
66
|
+
log: Pick<Logger, "warn">;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** `/branch [name]`, from the command's raw tokens: the current branch, or the
|
|
70
|
+
* checkout of the named one unless the working tree holds changes. */
|
|
71
|
+
export async function runBranch(tokens: readonly string[], deps: BranchDeps): Promise<CommandView> {
|
|
72
|
+
const { shell } = deps;
|
|
73
|
+
const plan = planBranch(tokens);
|
|
74
|
+
|
|
75
|
+
if (plan.action === "refuse") return { text: plan.reason };
|
|
76
|
+
|
|
77
|
+
if (plan.action === "show") {
|
|
78
|
+
const r = await shell.run("git branch --show-current");
|
|
79
|
+
return { text: r.stdout.trim() || r.stderr.trim() || "(detached HEAD)" };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const status = await shell.run("git status --porcelain");
|
|
83
|
+
const porcelain = status.stdout;
|
|
84
|
+
if (status.exitCode === 0 && hasUncommittedChanges(porcelain)) {
|
|
85
|
+
deps.log.warn(branchRefusedLog(plan.branch));
|
|
86
|
+
return { text: describeDirtyTreeRefusal(plan.branch, porcelain) };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const r = await shell.run(`git checkout ${plan.branch}`);
|
|
90
|
+
if (r.exitCode !== 0) {
|
|
91
|
+
return { text: checkoutFailed(r.stderr.trim() || r.stdout.trim() || exitCode(r.exitCode)) };
|
|
92
|
+
}
|
|
93
|
+
return { text: r.stderr.trim() || r.stdout.trim() || switchedTo(plan.branch) };
|
|
94
|
+
}
|