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,147 @@
|
|
|
1
|
+
// The bodies of run_tests and run_build, the two tools a writing role of a dev step is offered in
|
|
2
|
+
// place of shell_command for its test runs and builds. Each runs one command of the pack, after the
|
|
3
|
+
// guard chain (shared/domain/dev/tool-guards.ts): the pack's own command or nothing (the integration
|
|
4
|
+
// rule of test-commands.ts, plain values in its placeholders), never a restore, never a command the
|
|
5
|
+
// step's rules deny. The whole output goes to a log file; the model gets its tail and the log's path.
|
|
6
|
+
// A refusal or a command that cannot run comes back as `{ok: false}`, never thrown: the tool's
|
|
7
|
+
// result is what the model reads. The tools themselves are built in
|
|
8
|
+
// shared/infrastructure/orkeon/script-tools.ts.
|
|
9
|
+
import type { Files, Shell, ShellResult } from "../ports.ts";
|
|
10
|
+
import type { PermissionRule } from "../../domain/agent-policy/permission.ts";
|
|
11
|
+
import type { RepoPackCommands } from "../../domain/dev/repo-pack.ts";
|
|
12
|
+
import { checkValidation } from "../../domain/dev/test-commands.ts";
|
|
13
|
+
import { buildCommandFor, coldTree, isRestore } from "../../domain/dev/build-commands.ts";
|
|
14
|
+
import { outputTail, runGuards, shellRuleGuard, stringArgument } from "../../domain/dev/tool-guards.ts";
|
|
15
|
+
import { failedTests } from "../../domain/dev/test-output.ts";
|
|
16
|
+
import type { Guard } from "../../domain/dev/tool-guards.ts";
|
|
17
|
+
import { noRoleRestores } from "./prompts.ts";
|
|
18
|
+
import { restoreNotRun } from "./messages.ts";
|
|
19
|
+
|
|
20
|
+
export const RUN_TESTS_TIMEOUT_SECONDS = 600;
|
|
21
|
+
export const RUN_BUILD_TIMEOUT_SECONDS = 900;
|
|
22
|
+
|
|
23
|
+
/** What a run_tests or run_build call hands back to the model. */
|
|
24
|
+
export type WrappedRun =
|
|
25
|
+
| {
|
|
26
|
+
ok: true;
|
|
27
|
+
command: string;
|
|
28
|
+
exit: number;
|
|
29
|
+
timedOut: boolean;
|
|
30
|
+
/** run_build only: true when a red build on a cold tree made it restore once and build again. */
|
|
31
|
+
restored?: boolean;
|
|
32
|
+
/** run_tests only: the failed tests the output names (TAP `not ok`, pytest FAILED, dotnet Failed…), at most 20,
|
|
33
|
+
* so the role sees which tests failed without opening the log. */
|
|
34
|
+
failed?: string[];
|
|
35
|
+
/** At most 15 lines and 1 500 characters of the last command's output. */
|
|
36
|
+
tail: string;
|
|
37
|
+
/** The whole output, `/workspace/…`; null when it could not be written. */
|
|
38
|
+
log: string | null;
|
|
39
|
+
}
|
|
40
|
+
| { ok: false; refused: string };
|
|
41
|
+
|
|
42
|
+
/** What the tools are set up with, once the step knows its pack. */
|
|
43
|
+
export interface WrappedToolsSetup {
|
|
44
|
+
commands: RepoPackCommands;
|
|
45
|
+
/** The rules the step runs under: a shell command one of them denies is never run. */
|
|
46
|
+
rules: readonly PermissionRule[];
|
|
47
|
+
/** Where the logs go, e.g. `/workspace/todo/<code>/logs`. */
|
|
48
|
+
logFolder: string;
|
|
49
|
+
/** The batch, in front of each log's name (`F2-run_tests-1.log`): the batches of a parallel wave share no log name. */
|
|
50
|
+
batch?: string;
|
|
51
|
+
/** The step restored the tree itself already: run_build then never restores a cold tree again. */
|
|
52
|
+
restored?: boolean;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface WrappedTools {
|
|
56
|
+
runTests(input: unknown): Promise<WrappedRun>;
|
|
57
|
+
runBuild(input: unknown): Promise<WrappedRun>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const firstLine = (error: unknown): string => (error instanceof Error ? error.message : String(error)).split("\n")[0];
|
|
61
|
+
|
|
62
|
+
function output(command: string, result: ShellResult): string {
|
|
63
|
+
return [`$ ${command}`, `exit ${result.exitCode}${result.timedOut === true ? " (timed out)" : ""}`,
|
|
64
|
+
result.stdout.trimEnd(), result.stderr.trimEnd()].filter((l) => l !== "").join("\n");
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function createWrappedTools(deps: { shell: Pick<Shell, "run">; files: Pick<Files, "write"> }, setup: WrappedToolsSetup): WrappedTools {
|
|
68
|
+
let runs = 0;
|
|
69
|
+
let restoreTried = setup.restored === true; // the one restore of the step, whatever came of it
|
|
70
|
+
const notRestore: Guard<string> = (command) =>
|
|
71
|
+
isRestore(command, setup.commands) ? noRoleRestores(command) : null;
|
|
72
|
+
const shellGuards: ReadonlyArray<Guard<string>> = [notRestore, shellRuleGuard(setup.rules)];
|
|
73
|
+
|
|
74
|
+
async function writeLog(tool: string, text: string): Promise<string | null> {
|
|
75
|
+
runs += 1;
|
|
76
|
+
const path = `${setup.logFolder}/${setup.batch === undefined ? "" : `${setup.batch}-`}${tool}-${runs}.log`;
|
|
77
|
+
try {
|
|
78
|
+
await deps.files.write(path, `${text}\n`);
|
|
79
|
+
return path;
|
|
80
|
+
} catch {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Runs `command`, or the reason it could not run. */
|
|
86
|
+
async function run(command: string, timeoutSeconds: number): Promise<ShellResult | string> {
|
|
87
|
+
try {
|
|
88
|
+
return await deps.shell.run(command, { timeoutSeconds });
|
|
89
|
+
} catch (error) {
|
|
90
|
+
return `not run: ${firstLine(error)}`;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return {
|
|
95
|
+
async runTests(input) {
|
|
96
|
+
const arg = stringArgument(input, "command", true);
|
|
97
|
+
if ("refused" in arg) return { ok: false, refused: arg.refused };
|
|
98
|
+
const check = checkValidation(arg.value as string, setup.commands);
|
|
99
|
+
if (!check.ok) return { ok: false, refused: check.reason };
|
|
100
|
+
const refusal = runGuards(shellGuards, check.command);
|
|
101
|
+
if (refusal !== null) return { ok: false, refused: refusal };
|
|
102
|
+
const result = await run(check.command, RUN_TESTS_TIMEOUT_SECONDS);
|
|
103
|
+
if (typeof result === "string") return { ok: false, refused: result };
|
|
104
|
+
return {
|
|
105
|
+
ok: true, command: check.command, exit: result.exitCode, timedOut: result.timedOut === true,
|
|
106
|
+
failed: failedTests(`${result.stdout}\n${result.stderr}`),
|
|
107
|
+
tail: outputTail(result.stdout, result.stderr), log: await writeLog("run_tests", output(check.command, result)),
|
|
108
|
+
};
|
|
109
|
+
},
|
|
110
|
+
|
|
111
|
+
async runBuild(input) {
|
|
112
|
+
const arg = stringArgument(input, "project", false);
|
|
113
|
+
if ("refused" in arg) return { ok: false, refused: arg.refused };
|
|
114
|
+
const build = buildCommandFor(setup.commands, arg.value);
|
|
115
|
+
if (!build.ok) return { ok: false, refused: build.reason };
|
|
116
|
+
const refusal = runGuards(shellGuards, build.command);
|
|
117
|
+
if (refusal !== null) return { ok: false, refused: refusal };
|
|
118
|
+
const first = await run(build.command, RUN_BUILD_TIMEOUT_SECONDS);
|
|
119
|
+
if (typeof first === "string") return { ok: false, refused: first };
|
|
120
|
+
const log = [output(build.command, first)];
|
|
121
|
+
let last = first;
|
|
122
|
+
let restored = false;
|
|
123
|
+
const restore = setup.commands.restore?.trim();
|
|
124
|
+
if (!restoreTried && first.exitCode !== 0 && first.timedOut !== true && restore && coldTree(`${first.stdout}\n${first.stderr}`)) {
|
|
125
|
+
restoreTried = true;
|
|
126
|
+
// The one restore: the tree was never restored, so no flag of the pack's build can pass.
|
|
127
|
+
const denied = shellRuleGuard(setup.rules)(restore);
|
|
128
|
+
const restoring = denied === null ? await run(restore, RUN_BUILD_TIMEOUT_SECONDS) : denied;
|
|
129
|
+
if (typeof restoring === "string") {
|
|
130
|
+
log.push(restoreNotRun(restoring));
|
|
131
|
+
} else {
|
|
132
|
+
log.push(output(restore, restoring));
|
|
133
|
+
if (restoring.exitCode === 0) {
|
|
134
|
+
restored = true;
|
|
135
|
+
const again = await run(build.command, RUN_BUILD_TIMEOUT_SECONDS);
|
|
136
|
+
if (typeof again === "string") log.push(again);
|
|
137
|
+
else { log.push(output(build.command, again)); last = again; }
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
ok: true, command: build.command, exit: last.exitCode, timedOut: last.timedOut === true, restored,
|
|
143
|
+
tail: outputTail(last.stdout, last.stderr), log: await writeLog("run_build", log.join("\n\n")),
|
|
144
|
+
};
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// The extra tools the main agent may use (the `tools.extra` setting), read from
|
|
2
|
+
// /config and checked against the tools the host registers. A tool whose MCP
|
|
3
|
+
// server did not connect, whose plugin did not load, or whose name is mistyped is
|
|
4
|
+
// left out of the catalogue: Orkeon fails the act call of an agent that names a
|
|
5
|
+
// tool the host does not register (UnknownToolError). A setting that cannot be read
|
|
6
|
+
// configures no tool and says why: the callers report it, and the stored rules on
|
|
7
|
+
// extra tools stay as written, dormant (permission-rules.ts).
|
|
8
|
+
|
|
9
|
+
import type { ToolCatalogue } from "./ports.ts";
|
|
10
|
+
import { CONFIG_FILE_PATH } from "./config-store.ts";
|
|
11
|
+
import type { ConfigStore } from "./config-store.ts";
|
|
12
|
+
import { EXTRA_TOOLS_CONFIG_KEY, parseExtraTools } from "../domain/agent-policy/extra-tools.ts";
|
|
13
|
+
import type { ExtraToolsParse } from "../domain/agent-policy/extra-tools.ts";
|
|
14
|
+
import type { ExtraTool } from "../domain/agent-policy/permission.ts";
|
|
15
|
+
import { couldNotBeReadOrParsed } from "./messages.ts";
|
|
16
|
+
|
|
17
|
+
/** The setting as read: its entries, or why it could not be read. */
|
|
18
|
+
export interface ExtraToolsRead extends ExtraToolsParse {
|
|
19
|
+
/** Why the setting could not be read; it then configures no tool, which the caller reports. */
|
|
20
|
+
unreadable?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** The configured extra tools; an unreadable setting configures none, and says why. The
|
|
24
|
+
* config store reads a settings file it cannot read or parse as empty: an unset
|
|
25
|
+
* setting is told apart from one that file may hold. */
|
|
26
|
+
export async function readExtraTools(config: Pick<ConfigStore, "readValue" | "readFile">): Promise<ExtraToolsRead> {
|
|
27
|
+
try {
|
|
28
|
+
const { value, source } = await config.readValue(EXTRA_TOOLS_CONFIG_KEY);
|
|
29
|
+
if (source === "unset" && (await config.readFile()).malformed) {
|
|
30
|
+
return { tools: [], invalid: [], unreadable: couldNotBeReadOrParsed(CONFIG_FILE_PATH) };
|
|
31
|
+
}
|
|
32
|
+
return parseExtraTools(value);
|
|
33
|
+
} catch (e: unknown) {
|
|
34
|
+
return { tools: [], invalid: [], unreadable: String((e as { message?: unknown })?.message ?? e) };
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface ExtraToolsResolution {
|
|
39
|
+
/** Configured and registered, each under the name the host registers it by
|
|
40
|
+
* (found case-insensitively, as Orkeon finds it): what the catalogue may offer. */
|
|
41
|
+
present: ExtraTool[];
|
|
42
|
+
/** Configured, but no tool of the host answers to the name. */
|
|
43
|
+
missing: ExtraTool[];
|
|
44
|
+
/** Entries of the setting that do not parse, as written. */
|
|
45
|
+
invalid: string[];
|
|
46
|
+
/** Why the setting could not be read, when it could not: no extra tool is configured. */
|
|
47
|
+
unreadable?: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** The configured extra tools, split by whether the host registers them. A
|
|
51
|
+
* registered one takes the registered name: the catalogue offers it, and the rules
|
|
52
|
+
* name it, as the host spells it. */
|
|
53
|
+
export async function resolveExtraTools(deps: {
|
|
54
|
+
config: Pick<ConfigStore, "readValue" | "readFile">;
|
|
55
|
+
catalogue: Pick<ToolCatalogue, "find">;
|
|
56
|
+
}): Promise<ExtraToolsResolution> {
|
|
57
|
+
const { tools, invalid, unreadable } = await readExtraTools(deps.config);
|
|
58
|
+
const present: ExtraTool[] = [];
|
|
59
|
+
const missing: ExtraTool[] = [];
|
|
60
|
+
for (const tool of tools) {
|
|
61
|
+
const registered = deps.catalogue.find(tool.name);
|
|
62
|
+
if (registered === undefined) missing.push(tool);
|
|
63
|
+
else present.push({ ...tool, name: registered });
|
|
64
|
+
}
|
|
65
|
+
return { present, missing, invalid, ...(unreadable === undefined ? {} : { unreadable }) };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Every configured name, registered or not: the names a permission rule may use. */
|
|
69
|
+
export function configuredNames(extras: Pick<ExtraToolsResolution, "present" | "missing">): string[] {
|
|
70
|
+
return [...extras.present, ...extras.missing].map((t) => t.name);
|
|
71
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// A batch's worktree over the Shell port: created on its own branch under /workspace/.orkeon/worktrees/<name>,
|
|
2
|
+
// removed with its branch once its work is merged, and its branch merged into the work branch by fast-forward
|
|
3
|
+
// once its audit is VALID. The removal is refused while the worktree holds uncommitted or untracked files or
|
|
4
|
+
// its branch commits the work branch lacks, as the harness's `worktree-create.sh --remove`. Never `--force`,
|
|
5
|
+
// never a push: the plan's close pushes once (crews/dev-batches/application/plan-close.ts).
|
|
6
|
+
// The worktree is created with `git worktree add --relative-paths` (git 2.48 and later, no fallback: an older git
|
|
7
|
+
// fails the create with its own message), so that its `.git` file names the main git dir relatively and git works in
|
|
8
|
+
// it inside the runtime's sandbox, where the host's absolute path does not exist (Orkeon/orkeon#188).
|
|
9
|
+
// Called by a parallel /dev-batches (crews/dev-batches/application/run-wave.ts), whose batch agents each run
|
|
10
|
+
// under their worktree as a working root.
|
|
11
|
+
import type { Shell } from "../ports.ts";
|
|
12
|
+
import { shellUnsafe } from "../../domain/git/close.ts";
|
|
13
|
+
import {
|
|
14
|
+
gitBranchDelete, gitBranchExists, gitCommitsNotIn, gitIsIgnored, gitIsMergedInto, gitWorktreeAdd, gitWorktreeHead,
|
|
15
|
+
gitWorktreeRemove, gitWorktreeStatus,
|
|
16
|
+
worktreePlace,
|
|
17
|
+
} from "../../domain/git/worktree.ts";
|
|
18
|
+
import type { WorktreePlace } from "../../domain/git/worktree.ts";
|
|
19
|
+
import { gitReason, runGit } from "./commit-files.ts";
|
|
20
|
+
import { mergeFastForward } from "./merge-batch.ts";
|
|
21
|
+
import type { MergeOutcome } from "./merge-batch.ts";
|
|
22
|
+
import {
|
|
23
|
+
DETACHED_HEAD, branchExists, branchNotMerged, cannotGoThroughTheShell, mergedUnreadable, notAWorktreeNameExplained, orkeonNotIgnoredByGit,
|
|
24
|
+
notMergedNotAWorktreeName, notMergedVerdict, worktreeAndBranchRemoved, worktreeCreated, worktreeHoldsChanges, worktreeNotCreated,
|
|
25
|
+
worktreeNotOnBranch, worktreeNotRemoved, worktreeRemovedBranchKept, worktreeStateUnreadable,
|
|
26
|
+
} from "./messages.ts";
|
|
27
|
+
|
|
28
|
+
export type WorktreeOutcome =
|
|
29
|
+
| { ok: true; place: WorktreePlace; line: string }
|
|
30
|
+
| { ok: false; line: string };
|
|
31
|
+
|
|
32
|
+
const refused = (line: string): { ok: false; line: string } => ({ ok: false, line: `refused: ${line}` });
|
|
33
|
+
|
|
34
|
+
// A leading `-` would be read by git as an option (`--detach` for a base).
|
|
35
|
+
function unsafeOf(values: readonly string[]): string | null {
|
|
36
|
+
const bad = values.filter((v) => shellUnsafe(v) || v.startsWith("-"));
|
|
37
|
+
return bad.length === 0 ? null : cannotGoThroughTheShell(bad.map((v) => `'${v}'`).join(", "));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Creates worktree `name` on a new branch `branch` from `base`. */
|
|
41
|
+
export async function createBatchWorktree(
|
|
42
|
+
shell: Pick<Shell, "run">, req: { name: string; branch: string; base: string },
|
|
43
|
+
): Promise<WorktreeOutcome> {
|
|
44
|
+
const place = worktreePlace(req.name);
|
|
45
|
+
if (place === null) return refused(notAWorktreeNameExplained(req.name));
|
|
46
|
+
const unsafe = unsafeOf([req.branch, req.base]);
|
|
47
|
+
if (unsafe !== null) return refused(unsafe);
|
|
48
|
+
const exists = await runGit(shell, gitBranchExists(req.branch));
|
|
49
|
+
if (exists.exitCode === 0) return refused(branchExists(req.branch));
|
|
50
|
+
// Not ignored, the worktree would sit in the checkout's own status as an embedded repository.
|
|
51
|
+
const ignored = await runGit(shell, gitIsIgnored(place.path));
|
|
52
|
+
if (ignored.exitCode !== 0) {
|
|
53
|
+
return refused(orkeonNotIgnoredByGit(place.path));
|
|
54
|
+
}
|
|
55
|
+
const add = await runGit(shell, gitWorktreeAdd(place.path, req.branch, req.base));
|
|
56
|
+
if (add.exitCode !== 0) return { ok: false, line: worktreeNotCreated(place.path, gitReason(add)) };
|
|
57
|
+
return { ok: true, place, line: worktreeCreated(place.path, req.branch, req.base) };
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Removes worktree `name` and its branch once nothing in it is lost: no change, every commit in `into`. */
|
|
61
|
+
export async function removeBatchWorktree(
|
|
62
|
+
shell: Pick<Shell, "run">, req: { name: string; branch: string; into: string },
|
|
63
|
+
): Promise<WorktreeOutcome> {
|
|
64
|
+
const place = worktreePlace(req.name);
|
|
65
|
+
if (place === null) return refused(notAWorktreeNameExplained(req.name));
|
|
66
|
+
const unsafe = unsafeOf([req.branch, req.into]);
|
|
67
|
+
if (unsafe !== null) return refused(unsafe);
|
|
68
|
+
const status = await runGit(shell, gitWorktreeStatus(place.path));
|
|
69
|
+
if (status.exitCode !== 0) return refused(worktreeStateUnreadable(place.path, gitReason(status)));
|
|
70
|
+
const changed = status.stdout.split("\n").filter((l) => l.trim() !== "").length;
|
|
71
|
+
if (changed > 0) return refused(worktreeHoldsChanges(place.path, changed));
|
|
72
|
+
// The worktree must stand on its branch: commits on another HEAD would go with it, the merge check not seeing them.
|
|
73
|
+
const head = await runGit(shell, gitWorktreeHead(place.path));
|
|
74
|
+
if (head.exitCode !== 0 || head.stdout.trim() !== `refs/heads/${req.branch}`) {
|
|
75
|
+
return refused(worktreeNotOnBranch(place.path, req.branch, head.exitCode === 0 ? head.stdout.trim() : DETACHED_HEAD));
|
|
76
|
+
}
|
|
77
|
+
const merged = await runGit(shell, gitIsMergedInto(req.branch, req.into));
|
|
78
|
+
if (merged.exitCode === 1) {
|
|
79
|
+
const count = await runGit(shell, gitCommitsNotIn(req.branch, req.into));
|
|
80
|
+
const n = count.exitCode === 0 ? count.stdout.trim() : "?";
|
|
81
|
+
return refused(branchNotMerged(req.branch, n, req.into));
|
|
82
|
+
}
|
|
83
|
+
if (merged.exitCode !== 0) return refused(mergedUnreadable(req.branch, req.into, gitReason(merged)));
|
|
84
|
+
const remove = await runGit(shell, gitWorktreeRemove(place.path));
|
|
85
|
+
if (remove.exitCode !== 0) return { ok: false, line: worktreeNotRemoved(place.path, gitReason(remove)) };
|
|
86
|
+
const branch = await runGit(shell, gitBranchDelete(req.branch));
|
|
87
|
+
return branch.exitCode === 0
|
|
88
|
+
? { ok: true, place, line: worktreeAndBranchRemoved(place.path, req.branch) }
|
|
89
|
+
: { ok: true, place, line: worktreeRemovedBranchKept(place.path, req.branch, gitReason(branch)) };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Merges a batch's branch into the work branch (`--ff-only`, rebased in its worktree when needed) on a VALID verdict only. */
|
|
93
|
+
export async function mergeValidBatch(
|
|
94
|
+
shell: Pick<Shell, "run">, req: { batch: string; verdict: string | null; branch: string; workBranch: string; name: string },
|
|
95
|
+
): Promise<MergeOutcome> {
|
|
96
|
+
if (req.verdict !== "VALID") {
|
|
97
|
+
return { merged: false, line: notMergedVerdict(req.batch, req.verdict ?? "missing"), handOver: [] };
|
|
98
|
+
}
|
|
99
|
+
const place = worktreePlace(req.name);
|
|
100
|
+
if (place === null) return { merged: false, line: notMergedNotAWorktreeName(req.name), handOver: [] };
|
|
101
|
+
return mergeFastForward(shell, { ref: req.branch, workBranch: req.workBranch, worktree: place.path });
|
|
102
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
// The git close shared by /commit (crews/git-commit) and the dev close
|
|
2
|
+
// (shared/application/dev/close-batch.ts): git's identity checked before
|
|
3
|
+
// anything is spent, an explicit file list committed, the branch pushed, and the
|
|
4
|
+
// pull request handed over. The rules and the command lines live in
|
|
5
|
+
// shared/domain/git/close.ts; this file runs them through the Shell and Files ports.
|
|
6
|
+
|
|
7
|
+
import type { Files, Shell, ShellResult } from "../ports.ts";
|
|
8
|
+
import type { GitIdent, PrSummary } from "../../domain/git/close.ts";
|
|
9
|
+
import {
|
|
10
|
+
COMMIT_MESSAGE_FALLBACK, COMMIT_MESSAGE_FILE, GIT_COMMITTER_IDENT_COMMAND, GIT_IN_PROGRESS_PROBES, GIT_DEFAULT_BRANCH_COMMAND, GIT_HEAD_COMMAND, GIT_IDENT_COMMAND,
|
|
11
|
+
ghPrCreateCommand, gitAddCommand, gitCommitCommand, gitPushCommand, indexDeletedPaths, parseDefaultBranch,
|
|
12
|
+
parseGitIdent, prBodyPath, prSlug, renderPrBody, shellUnsafe,
|
|
13
|
+
} from "../../domain/git/close.ts";
|
|
14
|
+
import { WORKSPACE } from "../../domain/vfs.ts";
|
|
15
|
+
import {
|
|
16
|
+
MERGE_IN_PROGRESS, NOTHING_TO_COMMIT, NOT_PUSHED_DETACHED, NO_GITHUB_TOOL, TO_OPEN_IN_A_TERMINAL, bodyNotWritten, bodyOutsideMounts,
|
|
17
|
+
cannotGoThroughShell, commitMessageNotWritten, gitAddFailed, gitCommitFailed, noEmailInAnswer, notPushedUnsafeBranch,
|
|
18
|
+
pullRequestBody, pullRequestNotOpened, pullRequestOpened, pushRefused, refusedByRuntime, removeByHand,
|
|
19
|
+
} from "./messages.ts";
|
|
20
|
+
|
|
21
|
+
export type Step = { ok: true } | { ok: false; line: string };
|
|
22
|
+
|
|
23
|
+
function firstLine(text: unknown): string {
|
|
24
|
+
return String(text ?? "").split("\n").map((l) => l.trim()).find((l) => l.length > 0) ?? "";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Runs `command`; a runtime refusal (a throw) comes back as a failed result carrying its message. */
|
|
28
|
+
export async function runGit(shell: Pick<Shell, "run">, command: string): Promise<ShellResult> {
|
|
29
|
+
try {
|
|
30
|
+
return await shell.run(command);
|
|
31
|
+
} catch (e) {
|
|
32
|
+
return { stdout: "", stderr: refusedByRuntime(firstLine((e as Error)?.message ?? e)), exitCode: -1 };
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** The first line git gave for a failure. */
|
|
37
|
+
export const gitReason = (r: ShellResult): string => firstLine(r.stderr) || firstLine(r.stdout) || `exit ${r.exitCode}`;
|
|
38
|
+
|
|
39
|
+
export type IdentityCheck = { ok: true; ident: GitIdent } | { ok: false; detail: string };
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* git's own identity, author then committer (`git var`): the commit needs both.
|
|
43
|
+
* None, or a check that cannot run, is not ok; nothing is ever invented.
|
|
44
|
+
*/
|
|
45
|
+
export async function readIdentity(shell: Pick<Shell, "run">): Promise<IdentityCheck> {
|
|
46
|
+
let author: GitIdent | null = null;
|
|
47
|
+
for (const command of [GIT_IDENT_COMMAND, GIT_COMMITTER_IDENT_COMMAND]) {
|
|
48
|
+
const r = await runGit(shell, command);
|
|
49
|
+
const ident = r.exitCode === 0 ? parseGitIdent(r.stdout) : null;
|
|
50
|
+
if (ident === null) return { ok: false, detail: r.exitCode === 0 ? noEmailInAnswer(command) : gitReason(r) };
|
|
51
|
+
author ??= ident;
|
|
52
|
+
}
|
|
53
|
+
return { ok: true, ident: author! };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** `note`: what is left to do by hand once the commit is made (the message file it could not remove). */
|
|
57
|
+
export type CommitOutcome = { ok: true; hash: string; note?: string } | { ok: false; line: string };
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Stages and commits `files` alone, with `message` passed through a file (no
|
|
61
|
+
* shell escaping). `status` is the one the list was selected from: a path it
|
|
62
|
+
* shows gone from the index is left out of `git add`, which refuses it, and
|
|
63
|
+
* stays in the commit's path list, which takes it from HEAD.
|
|
64
|
+
*/
|
|
65
|
+
export async function commitFiles(
|
|
66
|
+
deps: { shell: Pick<Shell, "run">; files: Pick<Files, "write"> },
|
|
67
|
+
req: { files: readonly string[]; status: string; message: string },
|
|
68
|
+
): Promise<CommitOutcome> {
|
|
69
|
+
if (req.files.length === 0) return { ok: false, line: NOTHING_TO_COMMIT };
|
|
70
|
+
const unsafe = req.files.filter(shellUnsafe);
|
|
71
|
+
if (unsafe.length > 0) return { ok: false, line: cannotGoThroughShell(unsafe.join(", ")) };
|
|
72
|
+
for (const probe of GIT_IN_PROGRESS_PROBES) {
|
|
73
|
+
const r = await runGit(deps.shell, probe);
|
|
74
|
+
if (r.exitCode === 0 && r.stdout.trim().length > 0) {
|
|
75
|
+
return { ok: false, line: MERGE_IN_PROGRESS };
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// The message is written before anything is staged: a write that fails leaves the index as it was.
|
|
79
|
+
const messageFile = await writeMessage(deps.files, req.message);
|
|
80
|
+
if (!messageFile.ok) return messageFile;
|
|
81
|
+
const gone = indexDeletedPaths(req.status);
|
|
82
|
+
const toAdd = req.files.filter((p) => !gone.includes(p));
|
|
83
|
+
if (toAdd.length > 0) {
|
|
84
|
+
const add = await runGit(deps.shell, gitAddCommand(toAdd));
|
|
85
|
+
if (add.exitCode !== 0) return { ok: false, line: gitAddFailed(gitReason(add)) };
|
|
86
|
+
}
|
|
87
|
+
const commit = await runGit(deps.shell, gitCommitCommand(req.files, messageFile.path));
|
|
88
|
+
const note = messageFile.path === COMMIT_MESSAGE_FALLBACK ? await removeFallback(deps.shell) : null;
|
|
89
|
+
if (commit.exitCode !== 0) return { ok: false, line: gitCommitFailed(gitReason(commit), note) };
|
|
90
|
+
const hash = (await runGit(deps.shell, GIT_HEAD_COMMAND)).stdout.trim();
|
|
91
|
+
return note === null ? { ok: true, hash } : { ok: true, hash, note };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Removes the message written under `.orkeon/`; a removal that fails is said, never silent (the file holds the message). */
|
|
95
|
+
async function removeFallback(shell: Pick<Shell, "run">): Promise<string | null> {
|
|
96
|
+
const rm = await runGit(shell, `rm -f ${COMMIT_MESSAGE_FALLBACK}`);
|
|
97
|
+
return rm.exitCode === 0 ? null : removeByHand(COMMIT_MESSAGE_FALLBACK, gitReason(rm));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** The message under `.git/`, else - a linked worktree, whose `.git` is a file - under `.orkeon/`. */
|
|
101
|
+
async function writeMessage(files: Pick<Files, "write">, message: string): Promise<{ ok: true; path: string } | { ok: false; line: string }> {
|
|
102
|
+
let reason = "";
|
|
103
|
+
for (const path of [COMMIT_MESSAGE_FILE, COMMIT_MESSAGE_FALLBACK]) {
|
|
104
|
+
try {
|
|
105
|
+
await files.write(`${WORKSPACE}/${path}`, message);
|
|
106
|
+
return { ok: true, path };
|
|
107
|
+
} catch (e) {
|
|
108
|
+
reason = firstLine((e as Error)?.message ?? e);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return { ok: false, line: commitMessageNotWritten(COMMIT_MESSAGE_FILE, COMMIT_MESSAGE_FALLBACK, reason) };
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** `git push -u origin <branch>`; a refusal is said with git's line, nothing is forced. */
|
|
115
|
+
export async function pushBranch(shell: Pick<Shell, "run">, branch: string): Promise<Step> {
|
|
116
|
+
if (branch.trim().length === 0) return { ok: false, line: NOT_PUSHED_DETACHED };
|
|
117
|
+
if (shellUnsafe(branch)) return { ok: false, line: notPushedUnsafeBranch(branch) };
|
|
118
|
+
const r = await runGit(shell, gitPushCommand(branch));
|
|
119
|
+
return r.exitCode === 0 ? { ok: true } : { ok: false, line: pushRefused(gitReason(r)) };
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** The remote's default branch, null when origin/HEAD is unset: never guessed. */
|
|
123
|
+
export async function defaultBranch(shell: Pick<Shell, "run">): Promise<string | null> {
|
|
124
|
+
const r = await runGit(shell, GIT_DEFAULT_BRANCH_COMMAND);
|
|
125
|
+
return r.exitCode === 0 ? parseDefaultBranch(r.stdout) : null;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export interface PullRequest {
|
|
129
|
+
base: string | null;
|
|
130
|
+
head: string;
|
|
131
|
+
title: string;
|
|
132
|
+
/** The body file as the user reads it (the handed-over command names it). */
|
|
133
|
+
bodyFile: string;
|
|
134
|
+
/** The body itself, which the opener sends. */
|
|
135
|
+
body: string;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** The pull request opened by Orkeon Code itself: open-pull-request.ts, over the github tool.
|
|
139
|
+
* A throw is the reason it was not opened; the command is then handed over. */
|
|
140
|
+
export interface PullRequestOpener {
|
|
141
|
+
open(pr: PullRequest): Promise<{ url: string }>;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface PullRequestHandOver {
|
|
145
|
+
/** The work folder: `folder` as the user reads it, `vfsPath` where it is written (null outside the mounts). */
|
|
146
|
+
work: { folder: string; vfsPath: string | null };
|
|
147
|
+
branch: string;
|
|
148
|
+
base: string | null;
|
|
149
|
+
title: string;
|
|
150
|
+
pushed: boolean;
|
|
151
|
+
/** `--pr` or `dev.prAuto`: open it rather than hand it over. */
|
|
152
|
+
open: boolean;
|
|
153
|
+
summary: PrSummary;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** Writes `<work>/pr-<slug>/PR.md`, then opens the pull request through the seam, or prints the command. */
|
|
157
|
+
export async function handOverPullRequest(
|
|
158
|
+
deps: { files: Pick<Files, "write">; opener?: PullRequestOpener },
|
|
159
|
+
req: PullRequestHandOver,
|
|
160
|
+
): Promise<string[]> {
|
|
161
|
+
const slug = prSlug(req.branch);
|
|
162
|
+
const bodyFile = prBodyPath(req.work.folder, slug);
|
|
163
|
+
const lines: string[] = [];
|
|
164
|
+
const body = renderPrBody(req.summary);
|
|
165
|
+
if (req.work.vfsPath === null) {
|
|
166
|
+
lines.push(bodyOutsideMounts(req.work.folder, bodyFile));
|
|
167
|
+
} else {
|
|
168
|
+
// After the commit and the push: a body that cannot be written is said, never thrown.
|
|
169
|
+
try {
|
|
170
|
+
await deps.files.write(`${req.work.vfsPath.replace(/\/+$/, "")}/pr-${slug}/PR.md`, body);
|
|
171
|
+
lines.push(pullRequestBody(bodyFile));
|
|
172
|
+
} catch (e) {
|
|
173
|
+
lines.push(bodyNotWritten(firstLine((e as Error)?.message ?? e), bodyFile));
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
const pr: PullRequest = { base: req.base, head: req.branch, title: req.title, bodyFile, body };
|
|
177
|
+
if (req.open && req.pushed && deps.opener !== undefined) {
|
|
178
|
+
try {
|
|
179
|
+
return [...lines, pullRequestOpened((await deps.opener.open(pr)).url)];
|
|
180
|
+
} catch (e) {
|
|
181
|
+
lines.push(pullRequestNotOpened(firstLine((e as Error)?.message ?? e)));
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
lines.push(TO_OPEN_IN_A_TERMINAL);
|
|
185
|
+
if (!req.pushed) lines.push(` ${gitPushCommand(req.branch)}`);
|
|
186
|
+
lines.push(` ${ghPrCreateCommand(pr)}`);
|
|
187
|
+
if (req.open && deps.opener === undefined) {
|
|
188
|
+
lines.push(NO_GITHUB_TOOL);
|
|
189
|
+
}
|
|
190
|
+
return lines;
|
|
191
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// The merge of a local batch branch into the work branch (R-16): fast-forward
|
|
2
|
+
// only. Refused while the batch has its own worktree: the branch, never pushed, is
|
|
3
|
+
// rebased there on the work branch and the fast-forward tried again; a conflict
|
|
4
|
+
// aborts the rebase and the merge is handed over. Without a worktree nothing is
|
|
5
|
+
// rewritten here (a rebase would check the batch branch out in the user's own
|
|
6
|
+
// checkout): the merge is handed over. Never a forced update, never a push.
|
|
7
|
+
// Reached through batch-worktree.ts (mergeValidBatch), which a parallel /dev-batches calls for each VALID batch.
|
|
8
|
+
|
|
9
|
+
import type { Shell } from "../ports.ts";
|
|
10
|
+
import {
|
|
11
|
+
GIT_CURRENT_BRANCH_COMMAND, gitMergeFfOnly, gitRebaseAbortIn, gitRebaseIn, isNotFastForward, shellUnsafe,
|
|
12
|
+
} from "../../domain/git/close.ts";
|
|
13
|
+
import { gitReason, runGit } from "./commit-files.ts";
|
|
14
|
+
import {
|
|
15
|
+
DETACHED_HEAD, mergedFastForward, notMergedAfterRebase, notMergedCheckoutElsewhere, notMergedUnsafe, rebaseAbortFailed, rebaseStopped,
|
|
16
|
+
rebasedAndMerged,
|
|
17
|
+
} from "./messages.ts";
|
|
18
|
+
|
|
19
|
+
export type MergeOutcome =
|
|
20
|
+
| { merged: true; rebased: boolean; line: string }
|
|
21
|
+
| { merged: false; line: string; handOver: string[] };
|
|
22
|
+
|
|
23
|
+
/** Merges `ref` into the checked-out `workBranch` by fast-forward, rebasing it in `worktree` when it has one. */
|
|
24
|
+
export async function mergeFastForward(
|
|
25
|
+
shell: Pick<Shell, "run">,
|
|
26
|
+
req: { ref: string; workBranch: string; worktree?: string },
|
|
27
|
+
): Promise<MergeOutcome> {
|
|
28
|
+
const merge = gitMergeFfOnly(req.ref);
|
|
29
|
+
// A leading `-` would be read by git as an option, as batch-worktree.ts refuses it.
|
|
30
|
+
const unsafe = [req.ref, req.workBranch, ...(req.worktree === undefined ? [] : [req.worktree])]
|
|
31
|
+
.filter((v) => shellUnsafe(v) || v.startsWith("-"));
|
|
32
|
+
if (unsafe.length > 0) {
|
|
33
|
+
return { merged: false, line: notMergedUnsafe(unsafe.join(", ")), handOver: [merge] };
|
|
34
|
+
}
|
|
35
|
+
const current = (await runGit(shell, GIT_CURRENT_BRANCH_COMMAND)).stdout.trim();
|
|
36
|
+
if (current !== req.workBranch) {
|
|
37
|
+
return {
|
|
38
|
+
merged: false, line: notMergedCheckoutElsewhere(current || DETACHED_HEAD, req.workBranch),
|
|
39
|
+
handOver: [`git checkout ${req.workBranch}`, merge],
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
const first = await runGit(shell, merge);
|
|
43
|
+
if (first.exitCode === 0) return { merged: true, rebased: false, line: mergedFastForward(req.ref, req.workBranch) };
|
|
44
|
+
// Only a refusal for not being a fast-forward is cured by a rebase: a dirty tree or an unknown ref is said as it is.
|
|
45
|
+
if (!isNotFastForward(first.stderr + first.stdout)) {
|
|
46
|
+
return { merged: false, line: `not merged: ${gitReason(first)}`, handOver: [merge] };
|
|
47
|
+
}
|
|
48
|
+
if (req.worktree === undefined) {
|
|
49
|
+
return {
|
|
50
|
+
merged: false,
|
|
51
|
+
line: `not merged: ${gitReason(first)}`,
|
|
52
|
+
handOver: [`git rebase ${req.workBranch} ${req.ref}`, `git checkout ${req.workBranch}`, merge],
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
const rebase = gitRebaseIn(req.worktree, req.workBranch);
|
|
56
|
+
const rebased = await runGit(shell, rebase);
|
|
57
|
+
if (rebased.exitCode !== 0) {
|
|
58
|
+
const abort = await runGit(shell, gitRebaseAbortIn(req.worktree));
|
|
59
|
+
const aborted = abort.exitCode === 0 ? "rebase aborted" : rebaseAbortFailed(gitReason(abort));
|
|
60
|
+
return { merged: false, line: rebaseStopped(gitReason(rebased), aborted), handOver: [rebase, merge] };
|
|
61
|
+
}
|
|
62
|
+
const second = await runGit(shell, merge);
|
|
63
|
+
if (second.exitCode === 0) {
|
|
64
|
+
return { merged: true, rebased: true, line: rebasedAndMerged(req.ref, req.workBranch) };
|
|
65
|
+
}
|
|
66
|
+
return { merged: false, line: notMergedAfterRebase(gitReason(second)), handOver: [merge] };
|
|
67
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// The lines the git services report: a commit, a push, a pull request, a batch's worktree and its merge.
|
|
2
|
+
|
|
3
|
+
export const DETACHED_HEAD = "a detached HEAD";
|
|
4
|
+
|
|
5
|
+
// commit-files.ts
|
|
6
|
+
export const refusedByRuntime = (reason: string): string => `refused by the runtime: ${reason}`;
|
|
7
|
+
export const noEmailInAnswer = (command: string): string => `${command}: no email in its answer`;
|
|
8
|
+
export const NOTHING_TO_COMMIT = "nothing to commit";
|
|
9
|
+
export const cannotGoThroughShell = (paths: string): string => `cannot go through the shell: ${paths}`;
|
|
10
|
+
export const MERGE_IN_PROGRESS = "a merge or a cherry-pick is in progress: conclude it with git commit in a terminal";
|
|
11
|
+
export const gitAddFailed = (reason: string): string => `git add failed: ${reason}`;
|
|
12
|
+
export const gitCommitFailed = (reason: string, note: string | null): string =>
|
|
13
|
+
`git commit failed: ${reason}${note === null ? "" : `; ${note}`}`;
|
|
14
|
+
export const removeByHand = (path: string, reason: string): string => `${path} could not be removed (${reason}): remove it by hand`;
|
|
15
|
+
export const commitMessageNotWritten = (file: string, fallback: string, reason: string): string =>
|
|
16
|
+
`the commit message could not be written (${file}, ${fallback}): ${reason}`;
|
|
17
|
+
export const NOT_PUSHED_DETACHED = "not pushed: no branch is checked out (detached HEAD)";
|
|
18
|
+
export const notPushedUnsafeBranch = (branch: string): string => `not pushed: the branch name '${branch}' cannot go through the shell`;
|
|
19
|
+
export const pushRefused = (reason: string): string => `push refused, the commit stays local: ${reason}`;
|
|
20
|
+
export const bodyOutsideMounts = (folder: string, bodyFile: string): string =>
|
|
21
|
+
`the body could not be written (${folder} is outside the mounts): write ${bodyFile} first`;
|
|
22
|
+
export const pullRequestBody = (bodyFile: string): string => `pull request body: ${bodyFile}`;
|
|
23
|
+
export const bodyNotWritten = (reason: string, bodyFile: string): string =>
|
|
24
|
+
`⚠ the body could not be written (${reason}): write ${bodyFile} first`;
|
|
25
|
+
export const pullRequestOpened = (url: string): string => `✓ pull request opened: ${url}`;
|
|
26
|
+
export const pullRequestNotOpened = (reason: string): string => `✗ the pull request was not opened: ${reason}`;
|
|
27
|
+
export const TO_OPEN_IN_A_TERMINAL = "to open the pull request, in a terminal:";
|
|
28
|
+
export const NO_GITHUB_TOOL =
|
|
29
|
+
"the pull request is opened here only through the github tool, which this host does not offer: run the command above";
|
|
30
|
+
|
|
31
|
+
// open-pull-request.ts
|
|
32
|
+
export const BASE_BRANCH_UNKNOWN = "the base branch is unknown (origin/HEAD is unset): git remote set-head origin --auto sets it";
|
|
33
|
+
export const originUrlUnreadable = (reason: string): string => `origin's URL could not be read: ${reason}`;
|
|
34
|
+
export const notAGitHubRepository = (url: string): string => `origin is not a github.com repository (${url})`;
|
|
35
|
+
|
|
36
|
+
// merge-batch.ts
|
|
37
|
+
export const notMergedUnsafe = (values: string): string => `not merged: ${values} cannot go through the shell`;
|
|
38
|
+
export const notMergedCheckoutElsewhere = (current: string, workBranch: string): string =>
|
|
39
|
+
`not merged: the checkout is on '${current}', not on ${workBranch}`;
|
|
40
|
+
export const mergedFastForward = (ref: string, workBranch: string): string => `${ref} merged into ${workBranch} (fast-forward)`;
|
|
41
|
+
export const rebaseAbortFailed = (reason: string): string => `rebase --abort failed too: ${reason}`;
|
|
42
|
+
export const rebaseStopped = (reason: string, aborted: string): string => `not merged, the rebase stopped (${reason}); ${aborted}`;
|
|
43
|
+
export const rebasedAndMerged = (ref: string, workBranch: string): string =>
|
|
44
|
+
`${ref} rebased on ${workBranch} and merged (fast-forward)`;
|
|
45
|
+
export const notMergedAfterRebase = (reason: string): string => `not merged after the rebase: ${reason}`;
|
|
46
|
+
|
|
47
|
+
// batch-worktree.ts
|
|
48
|
+
export const cannotGoThroughTheShell = (values: string): string => `${values} cannot go through the shell`;
|
|
49
|
+
export const notAWorktreeNameExplained = (name: string): string => `'${name}' is not a worktree name (one folder: letters, digits, . _ -)`;
|
|
50
|
+
export const branchExists = (branch: string): string => `branch ${branch} exists already: remove it or choose another name`;
|
|
51
|
+
export const orkeonNotIgnoredByGit = (path: string): string =>
|
|
52
|
+
`${path} is not ignored by git: add \`.orkeon/\` to .gitignore or .git/info/exclude first`;
|
|
53
|
+
export const worktreeNotCreated = (path: string, reason: string): string => `worktree ${path} not created: ${reason}`;
|
|
54
|
+
export const worktreeCreated = (path: string, branch: string, base: string): string => `✓ worktree ${path} on ${branch}, from ${base}`;
|
|
55
|
+
export const worktreeStateUnreadable = (path: string, reason: string): string => `the state of ${path} could not be read (${reason})`;
|
|
56
|
+
export const worktreeHoldsChanges = (path: string, changed: number): string =>
|
|
57
|
+
`${path} holds ${changed} uncommitted or untracked file(s): commit or discard them first`;
|
|
58
|
+
export const worktreeNotOnBranch = (path: string, branch: string, head: string): string =>
|
|
59
|
+
`${path} is not on ${branch} (${head}): check it out there first`;
|
|
60
|
+
export const branchNotMerged = (branch: string, count: string, into: string): string =>
|
|
61
|
+
`${branch} holds ${count} commit(s) not in ${into}: merge it first`;
|
|
62
|
+
export const mergedUnreadable = (branch: string, into: string, reason: string): string =>
|
|
63
|
+
`whether ${branch} is merged into ${into} could not be read (${reason})`;
|
|
64
|
+
export const worktreeNotRemoved = (path: string, reason: string): string => `worktree ${path} not removed: ${reason}`;
|
|
65
|
+
export const worktreeAndBranchRemoved = (path: string, branch: string): string => `✓ worktree ${path} and branch ${branch} removed`;
|
|
66
|
+
export const worktreeRemovedBranchKept = (path: string, branch: string, reason: string): string =>
|
|
67
|
+
`✓ worktree ${path} removed; branch ${branch} kept (${reason})`;
|
|
68
|
+
export const notMergedVerdict = (batch: string, verdict: string): string => `not merged: ${batch}'s audit is ${verdict}, not VALID`;
|
|
69
|
+
export const notMergedNotAWorktreeName = (name: string): string => `not merged: '${name}' is not a worktree name`;
|
|
70
|
+
|
|
71
|
+
// Shared by the crews that branch and push
|
|
72
|
+
export const refusedLine = (reason: string) => `✗ refused: ${reason}`;
|
|
73
|
+
export const branchCreated = (branch: string, from: string, pattern: string): string =>
|
|
74
|
+
`✓ branch ${branch} created from ${from} (contrib.branch ${pattern})`;
|
|
75
|
+
export const pushedToOrigin = (branch: string): string => `✓ pushed ${branch} to origin`;
|