orkeon-code 1.0.0-rc.1 → 1.0.0-rc.3
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 +11 -0
- package/.orkeon-version +1 -1
- package/NOTICE.md +1 -1
- package/README.fr.md +16 -22
- package/README.md +16 -22
- package/config/appsettings.jev.example.json +4 -1
- package/config/appsettings.kev.example.json +4 -1
- package/config/appsettings.liquid.example.json +4 -1
- package/config/appsettings.ollama-whisper.example.json +1 -0
- package/config/appsettings.whisper.example.json +1 -0
- package/mcp/whisper/README.md +2 -1
- package/orkeon-code +508 -80
- package/orkeon-code.ps1 +129 -11
- package/package.json +3 -1
- package/scripts/dev-run.sh +139 -0
- package/src/commands/.orkeon/orkeon-cli.d.ts +1 -4
- package/src/commands/_lib/args.ts +5 -4
- package/src/commands/_lib/dev/dev-batches.ts +34 -36
- package/src/commands/_lib/dev/dev-implement.ts +11 -14
- package/src/commands/_lib/dev/dev-source.ts +7 -11
- package/src/commands/_lib/dev/dev.ts +34 -37
- 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 +16 -13
- package/src/commands/_lib/dispatch.ts +62 -39
- package/src/commands/_lib/git/branch.ts +9 -10
- package/src/commands/_lib/git/commit.ts +9 -13
- package/src/commands/_lib/git/diff.ts +22 -12
- package/src/commands/_lib/git/messages.ts +54 -0
- package/src/commands/_lib/git/review.ts +9 -10
- package/src/commands/_lib/memory/memory-admit.ts +19 -21
- package/src/commands/_lib/memory/memory.ts +3 -2
- package/src/commands/_lib/memory/messages.ts +32 -0
- package/src/commands/_lib/messages.ts +48 -0
- package/src/commands/_lib/project/messages.ts +8 -0
- package/src/commands/_lib/session/export.ts +3 -2
- 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 +15 -24
- package/src/commands/_lib/session/tasks.ts +20 -23
- package/src/commands/_lib/settings/advisor.ts +11 -16
- package/src/commands/_lib/settings/agents.ts +18 -28
- package/src/commands/_lib/settings/choices.ts +8 -0
- package/src/commands/_lib/settings/config.ts +43 -43
- package/src/commands/_lib/settings/effort.ts +147 -0
- package/src/commands/_lib/settings/hooks.ts +12 -20
- package/src/commands/_lib/settings/messages.ts +408 -0
- package/src/commands/_lib/settings/mode.ts +33 -24
- package/src/commands/_lib/settings/model.ts +71 -36
- package/src/commands/_lib/settings/output-style.ts +39 -0
- package/src/commands/_lib/settings/permissions.ts +71 -93
- package/src/commands/_lib/settings/route.ts +63 -0
- package/src/commands/_lib/settings/skills.ts +53 -11
- 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 +9 -10
- package/src/commands/_lib/speech/transcribe.ts +14 -23
- package/src/commands/_lib/speech/voice.ts +14 -18
- package/src/commands/_lib/status/doctor.ts +47 -28
- package/src/commands/_lib/status/messages.ts +101 -0
- package/src/commands/_lib/status/meta.ts +5 -25
- package/src/commands/_lib/status/status.ts +10 -11
- package/src/commands/_lib/status/usage-tools.ts +2 -3
- package/src/commands/_lib/status/usage.ts +7 -18
- package/src/commands/_lib/view.ts +6 -1
- package/src/commands/dev/dev-batches.cmd.ts +4 -3
- package/src/commands/dev/dev-learn.cmd.ts +3 -3
- package/src/commands/dev/dev-plan.cmd.ts +6 -7
- package/src/commands/dev/dev-spec.cmd.ts +6 -7
- package/src/commands/git/commit.cmd.ts +3 -3
- package/src/commands/git/review.cmd.ts +3 -3
- package/src/commands/memory/memory.cmd.ts +2 -2
- package/src/commands/project/analyze.cmd.ts +3 -3
- package/src/commands/project/debug-tool-call.cmd.ts +4 -9
- package/src/commands/project/init-verifiers.cmd.ts +3 -3
- package/src/commands/project/init.cmd.ts +3 -3
- package/src/commands/project/verify.cmd.ts +2 -2
- package/src/commands/session/assistant.cmd.ts +2 -2
- package/src/commands/session/compact.cmd.ts +1 -1
- package/src/commands/session/copy.cmd.ts +8 -7
- package/src/commands/session/rename.cmd.ts +3 -2
- package/src/commands/session/rewind.cmd.ts +3 -4
- package/src/commands/session/summary.cmd.ts +3 -3
- package/src/commands/session/tasks.cmd.ts +4 -2
- package/src/commands/settings/config.cmd.ts +4 -2
- package/src/commands/settings/effort.cmd.ts +10 -31
- package/src/commands/settings/fast.cmd.ts +2 -1
- package/src/commands/settings/mode.cmd.ts +3 -3
- package/src/commands/settings/model.cmd.ts +3 -2
- package/src/commands/settings/output-style.cmd.ts +9 -38
- package/src/commands/settings/permissions.cmd.ts +2 -2
- package/src/commands/settings/proactive.cmd.ts +2 -1
- package/src/commands/settings/route.cmd.ts +16 -0
- package/src/commands/settings/skills.cmd.ts +3 -3
- package/src/commands/settings/theme.cmd.ts +14 -0
- package/src/commands/speech/say.cmd.ts +2 -2
- package/src/commands/speech/transcribe.cmd.ts +2 -2
- package/src/commands/status/release-notes.cmd.ts +1 -1
- package/src/crews/.orkeon/orkeon.d.ts +539 -94
- package/src/crews/_probe-shared-memory/domain/messages.ts +54 -0
- package/src/crews/_probe-shared-memory/domain/probe-verdict.ts +17 -12
- package/src/crews/_probe-shared-memory/domain/prompts.ts +5 -0
- package/src/crews/_probe-shared-memory/probe.ork.ts +8 -6
- 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 +2 -1
- package/src/crews/advisor/crew.ork.ts +6 -5
- package/src/crews/advisor/domain/advice.ts +7 -23
- 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 +5 -4
- package/src/crews/agent-run/crew.ork.ts +4 -4
- 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 +16 -14
- package/src/crews/analyze/crew.ork.ts +5 -4
- package/src/crews/analyze/domain/harvest.ts +33 -65
- 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 +10 -17
- package/src/crews/code-review/application/review.ts +4 -1
- package/src/crews/code-review/application/run-code-review.ts +13 -15
- package/src/crews/code-review/crew.ork.ts +6 -5
- package/src/crews/code-review/domain/lenses.ts +6 -45
- 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 +5 -6
- package/src/crews/code-review/domain/scope.ts +6 -12
- package/src/crews/dev-batches/application/messages.ts +127 -0
- package/src/crews/dev-batches/application/plan-close.ts +12 -12
- package/src/crews/dev-batches/application/prompts.ts +10 -0
- package/src/crews/dev-batches/application/run-dev-batches.ts +57 -50
- package/src/crews/dev-batches/application/run-wave.ts +24 -22
- package/src/crews/dev-batches/application/seed-harvest.ts +8 -7
- package/src/crews/dev-batches/crew.ork.ts +13 -10
- package/src/crews/dev-batches/domain/batches-log.ts +1 -3
- 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 +3 -2
- package/src/crews/dev-change/application/change-material.ts +44 -0
- package/src/crews/dev-change/application/evidence.ts +25 -22
- package/src/crews/dev-change/application/messages.ts +81 -0
- package/src/crews/dev-change/application/{change-prompt.ts → prompts.ts} +40 -43
- package/src/crews/dev-change/application/run-dev-change.ts +43 -34
- package/src/crews/dev-change/crew.ork.ts +11 -9
- package/src/crews/dev-change/domain/change-answer.ts +24 -20
- package/src/crews/dev-change/domain/change-render.ts +14 -16
- 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 +21 -18
- package/src/crews/dev-implement/application/locate-sheet.ts +7 -5
- package/src/crews/dev-implement/application/messages.ts +161 -0
- package/src/crews/dev-implement/application/observe.ts +4 -2
- package/src/crews/dev-implement/application/prompts.ts +9 -0
- package/src/crews/dev-implement/application/report-writes.ts +14 -9
- package/src/crews/dev-implement/application/run-dev-implement.ts +84 -73
- package/src/crews/dev-implement/application/suite-job.ts +15 -11
- package/src/crews/dev-implement/crew.ork.ts +2 -1
- package/src/crews/dev-implement/domain/contracts.ts +59 -60
- package/src/crews/dev-implement/domain/correction.ts +16 -15
- package/src/crews/dev-implement/domain/cycles.ts +2 -1
- 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 +3 -7
- package/src/crews/dev-implement/domain/sheet-edits.ts +6 -5
- package/src/crews/dev-implement/domain/sheet-ticks.ts +5 -4
- package/src/crews/dev-implement/domain/step-checks.ts +17 -16
- package/src/crews/dev-implement/domain/step-section.ts +6 -4
- package/src/crews/dev-learn/application/learn-prompt-fit.ts +63 -0
- package/src/crews/dev-learn/application/messages.ts +56 -0
- package/src/crews/dev-learn/application/prompts.ts +96 -0
- package/src/crews/dev-learn/application/run-dev-learn.ts +51 -43
- package/src/crews/dev-learn/crew.ork.ts +5 -4
- package/src/crews/dev-learn/domain/learn-answer.ts +60 -37
- package/src/crews/dev-learn/domain/markers.ts +10 -0
- package/src/crews/dev-learn/domain/messages.ts +74 -0
- package/src/crews/dev-learn/domain/owner-lines.ts +12 -9
- package/src/crews/dev-learn/domain/proposals-render.ts +8 -9
- package/src/crews/dev-plan/application/anchor-paths.ts +57 -20
- package/src/crews/dev-plan/application/inventory.ts +17 -13
- 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/{plan-prompt.ts → prompts.ts} +37 -55
- package/src/crews/dev-plan/application/run-dev-plan.ts +103 -75
- package/src/crews/dev-plan/crew.ork.ts +12 -9
- package/src/crews/dev-plan/domain/inventory-model.ts +3 -3
- 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 +118 -103
- package/src/crews/dev-plan/domain/plan-render.ts +33 -34
- 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/{spec-prompt.ts → prompts.ts} +42 -47
- package/src/crews/dev-spec/application/run-dev-spec.ts +67 -36
- package/src/crews/dev-spec/application/spec-material.ts +42 -0
- package/src/crews/dev-spec/crew.ork.ts +11 -9
- 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 +46 -47
- package/src/crews/dev-spec/domain/spec-render.ts +21 -21
- package/src/crews/dev-verify/application/audit-brief.ts +187 -0
- package/src/crews/dev-verify/application/audit.ts +38 -30
- package/src/crews/dev-verify/application/capture.ts +34 -26
- 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 +60 -46
- package/src/crews/dev-verify/application/run-gate.ts +11 -9
- package/src/crews/dev-verify/crew.ork.ts +7 -7
- package/src/crews/dev-verify/domain/audit-answer.ts +16 -12
- package/src/crews/dev-verify/domain/capture-sections.ts +5 -4
- package/src/crews/dev-verify/domain/commands.ts +3 -3
- package/src/crews/dev-verify/domain/gate.ts +21 -16
- package/src/crews/dev-verify/domain/markers.ts +16 -0
- package/src/crews/dev-verify/domain/mechanical-table.ts +37 -44
- package/src/crews/dev-verify/domain/messages.ts +92 -0
- package/src/crews/dev-verify/domain/verdict.ts +4 -4
- package/src/crews/git-commit/application/draft.ts +38 -55
- package/src/crews/git-commit/application/messages.ts +17 -0
- package/src/crews/git-commit/application/prompts.ts +47 -0
- package/src/crews/git-commit/application/run-git-commit.ts +16 -13
- package/src/crews/git-commit/crew.ork.ts +6 -5
- package/src/crews/git-commit/domain/commit.ts +15 -35
- 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 +2 -1
- package/src/crews/init-verifiers/application/messages.ts +13 -0
- package/src/crews/init-verifiers/application/prompts.ts +5 -1
- package/src/crews/init-verifiers/application/run-init-verifiers.ts +3 -2
- package/src/crews/init-verifiers/crew.ork.ts +6 -5
- package/src/crews/main-loop/application/auto-compact.ts +2 -1
- 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 +64 -31
- package/src/crews/main-loop/application/{turn-prompt.ts → turn-context.ts} +7 -8
- package/src/crews/main-loop/crew.ork.ts +12 -7
- package/src/crews/main-loop/domain/prompt-assembly.ts +45 -228
- package/src/crews/main-loop/domain/prompts.ts +336 -0
- package/src/crews/main-loop/domain/turn-chains.ts +10 -9
- package/src/crews/project-init/application/detect.ts +5 -4
- package/src/crews/project-init/application/messages.ts +15 -0
- package/src/crews/project-init/application/prompts.ts +11 -7
- package/src/crews/project-init/crew.ork.ts +6 -5
- package/src/crews/project-init/domain/existing-files.ts +6 -4
- package/src/crews/project-init/domain/messages.ts +13 -0
- package/src/crews/project-init/domain/package-map.ts +3 -3
- 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 +6 -5
- package/src/crews/shared-memory-admit/application/prompts.ts +5 -0
- package/src/crews/shared-memory-admit/crew.ork.ts +4 -3
- 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 +2 -1
- package/src/crews/speech/crew.ork.ts +2 -1
- package/src/shared/application/agents/child-agent.ts +11 -7
- 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 +31 -8
- package/src/shared/application/compaction/compact-session.ts +19 -14
- 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/dev/brief-inventory.ts +6 -4
- package/src/shared/application/dev/close-batch.ts +9 -7
- package/src/shared/application/dev/find-repo-pack.ts +4 -3
- package/src/shared/application/dev/learn-decision.ts +20 -18
- package/src/shared/application/dev/load-dev-context.ts +7 -8
- package/src/shared/application/dev/measure-access-cost.ts +5 -4
- package/src/shared/application/dev/messages.ts +135 -0
- package/src/shared/application/dev/phase-timer.ts +54 -0
- package/src/shared/application/dev/plan-source.ts +12 -8
- package/src/shared/application/dev/preflight.ts +16 -11
- package/src/shared/application/dev/prompts.ts +34 -0
- package/src/shared/application/dev/question-round.ts +25 -17
- package/src/shared/application/dev/resolve-work-folder.ts +4 -3
- package/src/shared/application/dev/settle-questions.ts +4 -2
- package/src/shared/application/dev/source-review.ts +12 -8
- package/src/shared/application/dev/source-step.ts +12 -10
- package/src/shared/application/dev/spend.ts +17 -4
- package/src/shared/application/dev/step-precedents.ts +2 -1
- package/src/shared/application/dev/tool-call-policy.ts +9 -11
- package/src/shared/application/dev/tool-callbacks.ts +52 -5
- package/src/shared/application/dev/tool-trace-recorder.ts +2 -1
- package/src/shared/application/dev/verdict-sources.ts +5 -3
- package/src/shared/application/dev/wrapped-tools.ts +4 -2
- package/src/shared/application/extra-tools.ts +2 -1
- package/src/shared/application/git/batch-worktree.ts +22 -17
- package/src/shared/application/git/commit-files.ts +24 -19
- package/src/shared/application/git/merge-batch.ts +11 -7
- package/src/shared/application/git/messages.ts +75 -0
- package/src/shared/application/git/open-pull-request.ts +4 -3
- package/src/shared/application/host-context.ts +59 -0
- package/src/shared/application/host-layout-store.ts +45 -0
- package/src/shared/application/llm-profile.ts +4 -3
- package/src/shared/application/messages.ts +14 -0
- package/src/shared/application/permission-rules.ts +10 -0
- package/src/shared/application/ports/decision.ts +14 -0
- package/src/shared/application/ports/human.ts +25 -0
- package/src/shared/application/ports/llm.ts +32 -3
- package/src/shared/application/ports/memory.ts +1 -1
- package/src/shared/application/ports/theme.ts +11 -0
- package/src/shared/application/ports.ts +4 -2
- package/src/shared/application/session-io.ts +2 -1
- package/src/shared/application/shared-memory/admit-entries.ts +16 -14
- package/src/shared/application/shared-memory/harvest-after-gaps.ts +5 -8
- package/src/shared/application/shared-memory/harvest-mistakes.ts +3 -2
- package/src/shared/application/shared-memory/import-agent-memory.ts +9 -7
- package/src/shared/application/shared-memory/memory-files.ts +2 -1
- package/src/shared/application/shared-memory/memory-settings.ts +2 -1
- package/src/shared/application/shared-memory/messages.ts +63 -0
- package/src/shared/application/shared-memory/push-candidate.ts +14 -11
- package/src/shared/application/shared-memory/recall-precedents.ts +2 -1
- package/src/shared/application/skills/messages.ts +4 -0
- package/src/shared/application/skills/suggest-skills.ts +102 -0
- package/src/shared/application/workflow/messages.ts +8 -0
- package/src/shared/application/workflow/workflow-state.ts +7 -6
- package/src/shared/domain/agent-policy/behavior-flags.ts +4 -10
- package/src/shared/domain/agent-policy/extra-tools.ts +2 -4
- package/src/shared/domain/agent-policy/messages.ts +66 -0
- package/src/shared/domain/agent-policy/path-rules.ts +299 -0
- package/src/shared/domain/agent-policy/permission.ts +20 -18
- 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 +18 -14
- package/src/shared/domain/agent-policy/tool-access.ts +17 -3
- package/src/shared/domain/agent-registry.ts +6 -5
- package/src/shared/domain/agents/chain.ts +2 -2
- package/src/shared/domain/agents/charter.ts +8 -5
- package/src/shared/domain/agents/exclusive.ts +2 -1
- package/src/shared/domain/agents/instances.ts +18 -15
- 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 +5 -4
- package/src/shared/domain/code-intel-routing.ts +8 -61
- package/src/shared/domain/compact-outcome.ts +5 -3
- package/src/shared/domain/compaction-thresholds.ts +2 -1
- package/src/shared/domain/compaction.ts +22 -113
- package/src/shared/domain/config-schema.ts +94 -81
- 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 +19 -15
- package/src/shared/domain/dev/batches-concurrency.ts +5 -6
- package/src/shared/domain/dev/build-commands.ts +5 -4
- package/src/shared/domain/dev/call-guard.ts +29 -28
- package/src/shared/domain/dev/carried-text.ts +3 -5
- package/src/shared/domain/dev/learn-proposals.ts +51 -12
- package/src/shared/domain/dev/learn-state.ts +3 -2
- package/src/shared/domain/dev/markers.ts +127 -0
- package/src/shared/domain/dev/messages.ts +271 -0
- package/src/shared/domain/dev/phase-timing.ts +50 -0
- package/src/shared/domain/dev/plan-checks.ts +24 -23
- package/src/shared/domain/dev/plan-format.ts +15 -25
- package/src/shared/domain/dev/project-files.ts +1 -15
- package/src/shared/domain/dev/prompts/brief-blocks.ts +20 -0
- package/src/shared/domain/dev/{review-prompt.ts → prompts.ts} +91 -61
- package/src/shared/domain/dev/questions.ts +33 -15
- package/src/shared/domain/dev/repo-pack.ts +12 -9
- package/src/shared/domain/dev/review-answer.ts +40 -17
- package/src/shared/domain/dev/review-brief.ts +54 -0
- package/src/shared/domain/dev/reviewer-charter.ts +4 -0
- package/src/shared/domain/dev/sheet-facts.ts +2 -4
- package/src/shared/domain/dev/spec-format.ts +13 -14
- package/src/shared/domain/dev/step-budget.ts +4 -2
- package/src/shared/domain/dev/step-rules.ts +3 -4
- package/src/shared/domain/dev/test-commands.ts +14 -10
- package/src/shared/domain/dev/tool-guards.ts +4 -3
- package/src/shared/domain/dev/trait-pattern.ts +14 -10
- package/src/shared/domain/dev/verdict-format.ts +14 -21
- package/src/shared/domain/dev/whitespace.ts +3 -2
- package/src/shared/domain/dev/work-folder.ts +6 -4
- package/src/shared/domain/dev/yaml-subset.ts +8 -26
- package/src/shared/domain/error-text.ts +13 -0
- package/src/shared/domain/git/close.ts +14 -11
- package/src/shared/domain/git/messages.ts +41 -0
- package/src/shared/domain/git/pull-request.ts +5 -5
- package/src/shared/domain/host-layout.ts +147 -0
- package/src/shared/domain/host-paths.ts +399 -0
- package/src/shared/domain/llm-failure.ts +35 -7
- package/src/shared/domain/llm-profile.ts +22 -3
- package/src/shared/domain/marked-message.ts +1 -5
- package/src/shared/domain/markers.ts +30 -0
- package/src/shared/domain/messages.ts +291 -0
- package/src/shared/domain/model-catalog.ts +2 -9
- package/src/shared/domain/permission-modes.ts +4 -8
- package/src/shared/domain/prelude.ts +2 -2
- package/src/shared/domain/project-manifests.ts +3 -2
- package/src/shared/domain/prompts.ts +233 -0
- package/src/shared/domain/search-routing.ts +3 -11
- package/src/shared/domain/secret-patterns.ts +3 -2
- package/src/shared/domain/session-keys.ts +7 -0
- package/src/shared/domain/session-start.ts +3 -2
- package/src/shared/domain/shared-memory/agent-memory-import.ts +4 -2
- package/src/shared/domain/shared-memory/candidates.ts +3 -4
- package/src/shared/domain/shared-memory/entry.ts +26 -20
- package/src/shared/domain/shared-memory/front-matter.ts +17 -13
- package/src/shared/domain/shared-memory/gate.ts +4 -3
- package/src/shared/domain/shared-memory/harvest.ts +9 -6
- package/src/shared/domain/shared-memory/layout.ts +11 -8
- 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 +4 -15
- package/src/shared/domain/shared-memory/prompts.ts +28 -0
- package/src/shared/domain/shared-memory/refused.ts +3 -3
- 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 +2 -14
- package/src/shared/domain/speech.ts +2 -1
- package/src/shared/domain/tool-trace.ts +5 -7
- package/src/shared/domain/verifiers.ts +7 -11
- package/src/shared/domain/vfs.ts +8 -1
- package/src/shared/domain/workflow/prompts.ts +15 -0
- package/src/shared/domain/workflow/state-file.ts +14 -12
- package/src/shared/infrastructure/globals.ts +7 -2
- package/src/shared/infrastructure/orkeon/child-agents.ts +11 -16
- package/src/shared/infrastructure/orkeon/chooser.ts +32 -0
- package/src/shared/infrastructure/orkeon/decision-model.ts +31 -0
- package/src/shared/infrastructure/orkeon/dev-deps.ts +21 -14
- package/src/shared/infrastructure/orkeon/files.ts +24 -6
- package/src/shared/infrastructure/orkeon/github-pull-requests.ts +3 -2
- package/src/shared/infrastructure/orkeon/host-context.ts +36 -0
- package/src/shared/infrastructure/orkeon/human-input.ts +1 -5
- package/src/shared/infrastructure/orkeon/llm-profile.ts +36 -16
- package/src/shared/infrastructure/orkeon/llm.ts +85 -30
- package/src/shared/infrastructure/orkeon/markers.ts +6 -0
- package/src/shared/infrastructure/orkeon/memory-store.ts +1 -1
- package/src/shared/infrastructure/orkeon/memory-tools.ts +18 -20
- package/src/shared/infrastructure/orkeon/messages.ts +15 -0
- package/src/shared/infrastructure/orkeon/prompts.ts +47 -0
- package/src/shared/infrastructure/orkeon/reasoning.ts +40 -0
- package/src/shared/infrastructure/orkeon/script-tools.ts +14 -19
- package/src/shared/infrastructure/orkeon/session-store.ts +7 -51
- package/src/shared/infrastructure/orkeon/shell-jobs.ts +13 -7
- package/src/shared/infrastructure/orkeon/shell.ts +13 -5
- package/src/shared/infrastructure/orkeon/tool-catalogue.ts +3 -2
- package/src/shared/infrastructure/orkeon/wiring.ts +68 -12
- package/src/crews/dev-learn/application/learn-prompt.ts +0 -140
- package/src/crews/dev-verify/application/auditor-prompt.ts +0 -323
- package/src/shared/domain/session-summary.ts +0 -13
|
@@ -6,6 +6,8 @@ import type { Files } from "../ports.ts";
|
|
|
6
6
|
import type { WorkFolder } from "./resolve-work-folder.ts";
|
|
7
7
|
import { LEARN_FILE } from "../../domain/shared-memory/verdict-rows.ts";
|
|
8
8
|
import type { VerdictSource } from "../../domain/shared-memory/verdict-rows.ts";
|
|
9
|
+
import { folderListsTooMany, workListsTooMany } from "./messages.ts";
|
|
10
|
+
import { cannotBeRead } from "../messages.ts";
|
|
9
11
|
|
|
10
12
|
export const WORK_LIST_CAP = 1000;
|
|
11
13
|
export const FOLDER_LIST_CAP = 500;
|
|
@@ -31,18 +33,18 @@ export async function readVerdictSources(
|
|
|
31
33
|
for (const code of entries.map(bare).filter((e) => e !== "" && !e.startsWith("."))) {
|
|
32
34
|
const names = (await listOrEmpty(files, `${work.vfsPath}/${code}`, FOLDER_LIST_CAP)).map(bare);
|
|
33
35
|
if (names.length >= FOLDER_LIST_CAP) {
|
|
34
|
-
warnings.push(`${work.folder}/${code}
|
|
36
|
+
warnings.push(folderListsTooMany(`${work.folder}/${code}`, FOLDER_LIST_CAP));
|
|
35
37
|
}
|
|
36
38
|
for (const name of names.filter((n) => LEARN_FILE.test(n))) {
|
|
37
39
|
try {
|
|
38
40
|
sources.push({ code, name, text: await files.read(`${work.vfsPath}/${code}/${name}`) });
|
|
39
41
|
} catch (error) {
|
|
40
|
-
warnings.push(`${work.folder}/${code}/${name}
|
|
42
|
+
warnings.push(cannotBeRead(`${work.folder}/${code}/${name}`, firstLine(error)));
|
|
41
43
|
}
|
|
42
44
|
}
|
|
43
45
|
}
|
|
44
46
|
if (entries.length >= WORK_LIST_CAP) {
|
|
45
|
-
warnings.push(
|
|
47
|
+
warnings.push(workListsTooMany(work.folder, WORK_LIST_CAP));
|
|
46
48
|
}
|
|
47
49
|
return { sources, warnings };
|
|
48
50
|
}
|
|
@@ -14,6 +14,8 @@ import { buildCommandFor, coldTree, isRestore } from "../../domain/dev/build-com
|
|
|
14
14
|
import { outputTail, runGuards, shellRuleGuard, stringArgument } from "../../domain/dev/tool-guards.ts";
|
|
15
15
|
import { failedTests } from "../../domain/dev/test-output.ts";
|
|
16
16
|
import type { Guard } from "../../domain/dev/tool-guards.ts";
|
|
17
|
+
import { noRoleRestores } from "./prompts.ts";
|
|
18
|
+
import { restoreNotRun } from "./messages.ts";
|
|
17
19
|
|
|
18
20
|
export const RUN_TESTS_TIMEOUT_SECONDS = 600;
|
|
19
21
|
export const RUN_BUILD_TIMEOUT_SECONDS = 900;
|
|
@@ -66,7 +68,7 @@ export function createWrappedTools(deps: { shell: Pick<Shell, "run">; files: Pic
|
|
|
66
68
|
let runs = 0;
|
|
67
69
|
let restoreTried = setup.restored === true; // the one restore of the step, whatever came of it
|
|
68
70
|
const notRestore: Guard<string> = (command) =>
|
|
69
|
-
isRestore(command, setup.commands) ?
|
|
71
|
+
isRestore(command, setup.commands) ? noRoleRestores(command) : null;
|
|
70
72
|
const shellGuards: ReadonlyArray<Guard<string>> = [notRestore, shellRuleGuard(setup.rules)];
|
|
71
73
|
|
|
72
74
|
async function writeLog(tool: string, text: string): Promise<string | null> {
|
|
@@ -125,7 +127,7 @@ export function createWrappedTools(deps: { shell: Pick<Shell, "run">; files: Pic
|
|
|
125
127
|
const denied = shellRuleGuard(setup.rules)(restore);
|
|
126
128
|
const restoring = denied === null ? await run(restore, RUN_BUILD_TIMEOUT_SECONDS) : denied;
|
|
127
129
|
if (typeof restoring === "string") {
|
|
128
|
-
log.push(
|
|
130
|
+
log.push(restoreNotRun(restoring));
|
|
129
131
|
} else {
|
|
130
132
|
log.push(output(restore, restoring));
|
|
131
133
|
if (restoring.exitCode === 0) {
|
|
@@ -12,6 +12,7 @@ import type { ConfigStore } from "./config-store.ts";
|
|
|
12
12
|
import { EXTRA_TOOLS_CONFIG_KEY, parseExtraTools } from "../domain/agent-policy/extra-tools.ts";
|
|
13
13
|
import type { ExtraToolsParse } from "../domain/agent-policy/extra-tools.ts";
|
|
14
14
|
import type { ExtraTool } from "../domain/agent-policy/permission.ts";
|
|
15
|
+
import { couldNotBeReadOrParsed } from "./messages.ts";
|
|
15
16
|
|
|
16
17
|
/** The setting as read: its entries, or why it could not be read. */
|
|
17
18
|
export interface ExtraToolsRead extends ExtraToolsParse {
|
|
@@ -26,7 +27,7 @@ export async function readExtraTools(config: Pick<ConfigStore, "readValue" | "re
|
|
|
26
27
|
try {
|
|
27
28
|
const { value, source } = await config.readValue(EXTRA_TOOLS_CONFIG_KEY);
|
|
28
29
|
if (source === "unset" && (await config.readFile()).malformed) {
|
|
29
|
-
return { tools: [], invalid: [], unreadable:
|
|
30
|
+
return { tools: [], invalid: [], unreadable: couldNotBeReadOrParsed(CONFIG_FILE_PATH) };
|
|
30
31
|
}
|
|
31
32
|
return parseExtraTools(value);
|
|
32
33
|
} catch (e: unknown) {
|
|
@@ -19,6 +19,11 @@ import type { WorktreePlace } from "../../domain/git/worktree.ts";
|
|
|
19
19
|
import { gitReason, runGit } from "./commit-files.ts";
|
|
20
20
|
import { mergeFastForward } from "./merge-batch.ts";
|
|
21
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";
|
|
22
27
|
|
|
23
28
|
export type WorktreeOutcome =
|
|
24
29
|
| { ok: true; place: WorktreePlace; line: string }
|
|
@@ -29,7 +34,7 @@ const refused = (line: string): { ok: false; line: string } => ({ ok: false, lin
|
|
|
29
34
|
// A leading `-` would be read by git as an option (`--detach` for a base).
|
|
30
35
|
function unsafeOf(values: readonly string[]): string | null {
|
|
31
36
|
const bad = values.filter((v) => shellUnsafe(v) || v.startsWith("-"));
|
|
32
|
-
return bad.length === 0 ? null :
|
|
37
|
+
return bad.length === 0 ? null : cannotGoThroughTheShell(bad.map((v) => `'${v}'`).join(", "));
|
|
33
38
|
}
|
|
34
39
|
|
|
35
40
|
/** Creates worktree `name` on a new branch `branch` from `base`. */
|
|
@@ -37,19 +42,19 @@ export async function createBatchWorktree(
|
|
|
37
42
|
shell: Pick<Shell, "run">, req: { name: string; branch: string; base: string },
|
|
38
43
|
): Promise<WorktreeOutcome> {
|
|
39
44
|
const place = worktreePlace(req.name);
|
|
40
|
-
if (place === null) return refused(
|
|
45
|
+
if (place === null) return refused(notAWorktreeNameExplained(req.name));
|
|
41
46
|
const unsafe = unsafeOf([req.branch, req.base]);
|
|
42
47
|
if (unsafe !== null) return refused(unsafe);
|
|
43
48
|
const exists = await runGit(shell, gitBranchExists(req.branch));
|
|
44
|
-
if (exists.exitCode === 0) return refused(
|
|
49
|
+
if (exists.exitCode === 0) return refused(branchExists(req.branch));
|
|
45
50
|
// Not ignored, the worktree would sit in the checkout's own status as an embedded repository.
|
|
46
51
|
const ignored = await runGit(shell, gitIsIgnored(place.path));
|
|
47
52
|
if (ignored.exitCode !== 0) {
|
|
48
|
-
return refused(
|
|
53
|
+
return refused(orkeonNotIgnoredByGit(place.path));
|
|
49
54
|
}
|
|
50
55
|
const add = await runGit(shell, gitWorktreeAdd(place.path, req.branch, req.base));
|
|
51
|
-
if (add.exitCode !== 0) return { ok: false, line:
|
|
52
|
-
return { ok: true, place, line:
|
|
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) };
|
|
53
58
|
}
|
|
54
59
|
|
|
55
60
|
/** Removes worktree `name` and its branch once nothing in it is lost: no change, every commit in `into`. */
|
|
@@ -57,31 +62,31 @@ export async function removeBatchWorktree(
|
|
|
57
62
|
shell: Pick<Shell, "run">, req: { name: string; branch: string; into: string },
|
|
58
63
|
): Promise<WorktreeOutcome> {
|
|
59
64
|
const place = worktreePlace(req.name);
|
|
60
|
-
if (place === null) return refused(
|
|
65
|
+
if (place === null) return refused(notAWorktreeNameExplained(req.name));
|
|
61
66
|
const unsafe = unsafeOf([req.branch, req.into]);
|
|
62
67
|
if (unsafe !== null) return refused(unsafe);
|
|
63
68
|
const status = await runGit(shell, gitWorktreeStatus(place.path));
|
|
64
|
-
if (status.exitCode !== 0) return refused(
|
|
69
|
+
if (status.exitCode !== 0) return refused(worktreeStateUnreadable(place.path, gitReason(status)));
|
|
65
70
|
const changed = status.stdout.split("\n").filter((l) => l.trim() !== "").length;
|
|
66
|
-
if (changed > 0) return refused(
|
|
71
|
+
if (changed > 0) return refused(worktreeHoldsChanges(place.path, changed));
|
|
67
72
|
// The worktree must stand on its branch: commits on another HEAD would go with it, the merge check not seeing them.
|
|
68
73
|
const head = await runGit(shell, gitWorktreeHead(place.path));
|
|
69
74
|
if (head.exitCode !== 0 || head.stdout.trim() !== `refs/heads/${req.branch}`) {
|
|
70
|
-
return refused(
|
|
75
|
+
return refused(worktreeNotOnBranch(place.path, req.branch, head.exitCode === 0 ? head.stdout.trim() : DETACHED_HEAD));
|
|
71
76
|
}
|
|
72
77
|
const merged = await runGit(shell, gitIsMergedInto(req.branch, req.into));
|
|
73
78
|
if (merged.exitCode === 1) {
|
|
74
79
|
const count = await runGit(shell, gitCommitsNotIn(req.branch, req.into));
|
|
75
80
|
const n = count.exitCode === 0 ? count.stdout.trim() : "?";
|
|
76
|
-
return refused(
|
|
81
|
+
return refused(branchNotMerged(req.branch, n, req.into));
|
|
77
82
|
}
|
|
78
|
-
if (merged.exitCode !== 0) return refused(
|
|
83
|
+
if (merged.exitCode !== 0) return refused(mergedUnreadable(req.branch, req.into, gitReason(merged)));
|
|
79
84
|
const remove = await runGit(shell, gitWorktreeRemove(place.path));
|
|
80
|
-
if (remove.exitCode !== 0) return { ok: false, line:
|
|
85
|
+
if (remove.exitCode !== 0) return { ok: false, line: worktreeNotRemoved(place.path, gitReason(remove)) };
|
|
81
86
|
const branch = await runGit(shell, gitBranchDelete(req.branch));
|
|
82
87
|
return branch.exitCode === 0
|
|
83
|
-
? { ok: true, place, line:
|
|
84
|
-
: { ok: true, place, line:
|
|
88
|
+
? { ok: true, place, line: worktreeAndBranchRemoved(place.path, req.branch) }
|
|
89
|
+
: { ok: true, place, line: worktreeRemovedBranchKept(place.path, req.branch, gitReason(branch)) };
|
|
85
90
|
}
|
|
86
91
|
|
|
87
92
|
/** Merges a batch's branch into the work branch (`--ff-only`, rebased in its worktree when needed) on a VALID verdict only. */
|
|
@@ -89,9 +94,9 @@ export async function mergeValidBatch(
|
|
|
89
94
|
shell: Pick<Shell, "run">, req: { batch: string; verdict: string | null; branch: string; workBranch: string; name: string },
|
|
90
95
|
): Promise<MergeOutcome> {
|
|
91
96
|
if (req.verdict !== "VALID") {
|
|
92
|
-
return { merged: false, line:
|
|
97
|
+
return { merged: false, line: notMergedVerdict(req.batch, req.verdict ?? "missing"), handOver: [] };
|
|
93
98
|
}
|
|
94
99
|
const place = worktreePlace(req.name);
|
|
95
|
-
if (place === null) return { merged: false, line:
|
|
100
|
+
if (place === null) return { merged: false, line: notMergedNotAWorktreeName(req.name), handOver: [] };
|
|
96
101
|
return mergeFastForward(shell, { ref: req.branch, workBranch: req.workBranch, worktree: place.path });
|
|
97
102
|
}
|
|
@@ -12,6 +12,11 @@ import {
|
|
|
12
12
|
parseGitIdent, prBodyPath, prSlug, renderPrBody, shellUnsafe,
|
|
13
13
|
} from "../../domain/git/close.ts";
|
|
14
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";
|
|
15
20
|
|
|
16
21
|
export type Step = { ok: true } | { ok: false; line: string };
|
|
17
22
|
|
|
@@ -24,7 +29,7 @@ export async function runGit(shell: Pick<Shell, "run">, command: string): Promis
|
|
|
24
29
|
try {
|
|
25
30
|
return await shell.run(command);
|
|
26
31
|
} catch (e) {
|
|
27
|
-
return { stdout: "", stderr:
|
|
32
|
+
return { stdout: "", stderr: refusedByRuntime(firstLine((e as Error)?.message ?? e)), exitCode: -1 };
|
|
28
33
|
}
|
|
29
34
|
}
|
|
30
35
|
|
|
@@ -42,7 +47,7 @@ export async function readIdentity(shell: Pick<Shell, "run">): Promise<IdentityC
|
|
|
42
47
|
for (const command of [GIT_IDENT_COMMAND, GIT_COMMITTER_IDENT_COMMAND]) {
|
|
43
48
|
const r = await runGit(shell, command);
|
|
44
49
|
const ident = r.exitCode === 0 ? parseGitIdent(r.stdout) : null;
|
|
45
|
-
if (ident === null) return { ok: false, detail: r.exitCode === 0 ?
|
|
50
|
+
if (ident === null) return { ok: false, detail: r.exitCode === 0 ? noEmailInAnswer(command) : gitReason(r) };
|
|
46
51
|
author ??= ident;
|
|
47
52
|
}
|
|
48
53
|
return { ok: true, ident: author! };
|
|
@@ -61,13 +66,13 @@ export async function commitFiles(
|
|
|
61
66
|
deps: { shell: Pick<Shell, "run">; files: Pick<Files, "write"> },
|
|
62
67
|
req: { files: readonly string[]; status: string; message: string },
|
|
63
68
|
): Promise<CommitOutcome> {
|
|
64
|
-
if (req.files.length === 0) return { ok: false, line:
|
|
69
|
+
if (req.files.length === 0) return { ok: false, line: NOTHING_TO_COMMIT };
|
|
65
70
|
const unsafe = req.files.filter(shellUnsafe);
|
|
66
|
-
if (unsafe.length > 0) return { ok: false, line:
|
|
71
|
+
if (unsafe.length > 0) return { ok: false, line: cannotGoThroughShell(unsafe.join(", ")) };
|
|
67
72
|
for (const probe of GIT_IN_PROGRESS_PROBES) {
|
|
68
73
|
const r = await runGit(deps.shell, probe);
|
|
69
74
|
if (r.exitCode === 0 && r.stdout.trim().length > 0) {
|
|
70
|
-
return { ok: false, line:
|
|
75
|
+
return { ok: false, line: MERGE_IN_PROGRESS };
|
|
71
76
|
}
|
|
72
77
|
}
|
|
73
78
|
// The message is written before anything is staged: a write that fails leaves the index as it was.
|
|
@@ -77,11 +82,11 @@ export async function commitFiles(
|
|
|
77
82
|
const toAdd = req.files.filter((p) => !gone.includes(p));
|
|
78
83
|
if (toAdd.length > 0) {
|
|
79
84
|
const add = await runGit(deps.shell, gitAddCommand(toAdd));
|
|
80
|
-
if (add.exitCode !== 0) return { ok: false, line:
|
|
85
|
+
if (add.exitCode !== 0) return { ok: false, line: gitAddFailed(gitReason(add)) };
|
|
81
86
|
}
|
|
82
87
|
const commit = await runGit(deps.shell, gitCommitCommand(req.files, messageFile.path));
|
|
83
88
|
const note = messageFile.path === COMMIT_MESSAGE_FALLBACK ? await removeFallback(deps.shell) : null;
|
|
84
|
-
if (commit.exitCode !== 0) return { ok: false, line:
|
|
89
|
+
if (commit.exitCode !== 0) return { ok: false, line: gitCommitFailed(gitReason(commit), note) };
|
|
85
90
|
const hash = (await runGit(deps.shell, GIT_HEAD_COMMAND)).stdout.trim();
|
|
86
91
|
return note === null ? { ok: true, hash } : { ok: true, hash, note };
|
|
87
92
|
}
|
|
@@ -89,7 +94,7 @@ export async function commitFiles(
|
|
|
89
94
|
/** Removes the message written under `.orkeon/`; a removal that fails is said, never silent (the file holds the message). */
|
|
90
95
|
async function removeFallback(shell: Pick<Shell, "run">): Promise<string | null> {
|
|
91
96
|
const rm = await runGit(shell, `rm -f ${COMMIT_MESSAGE_FALLBACK}`);
|
|
92
|
-
return rm.exitCode === 0 ? null :
|
|
97
|
+
return rm.exitCode === 0 ? null : removeByHand(COMMIT_MESSAGE_FALLBACK, gitReason(rm));
|
|
93
98
|
}
|
|
94
99
|
|
|
95
100
|
/** The message under `.git/`, else - a linked worktree, whose `.git` is a file - under `.orkeon/`. */
|
|
@@ -103,15 +108,15 @@ async function writeMessage(files: Pick<Files, "write">, message: string): Promi
|
|
|
103
108
|
reason = firstLine((e as Error)?.message ?? e);
|
|
104
109
|
}
|
|
105
110
|
}
|
|
106
|
-
return { ok: false, line:
|
|
111
|
+
return { ok: false, line: commitMessageNotWritten(COMMIT_MESSAGE_FILE, COMMIT_MESSAGE_FALLBACK, reason) };
|
|
107
112
|
}
|
|
108
113
|
|
|
109
114
|
/** `git push -u origin <branch>`; a refusal is said with git's line, nothing is forced. */
|
|
110
115
|
export async function pushBranch(shell: Pick<Shell, "run">, branch: string): Promise<Step> {
|
|
111
|
-
if (branch.trim().length === 0) return { ok: false, line:
|
|
112
|
-
if (shellUnsafe(branch)) return { ok: false, line:
|
|
116
|
+
if (branch.trim().length === 0) return { ok: false, line: NOT_PUSHED_DETACHED };
|
|
117
|
+
if (shellUnsafe(branch)) return { ok: false, line: notPushedUnsafeBranch(branch) };
|
|
113
118
|
const r = await runGit(shell, gitPushCommand(branch));
|
|
114
|
-
return r.exitCode === 0 ? { ok: true } : { ok: false, line:
|
|
119
|
+
return r.exitCode === 0 ? { ok: true } : { ok: false, line: pushRefused(gitReason(r)) };
|
|
115
120
|
}
|
|
116
121
|
|
|
117
122
|
/** The remote's default branch, null when origin/HEAD is unset: never guessed. */
|
|
@@ -158,29 +163,29 @@ export async function handOverPullRequest(
|
|
|
158
163
|
const lines: string[] = [];
|
|
159
164
|
const body = renderPrBody(req.summary);
|
|
160
165
|
if (req.work.vfsPath === null) {
|
|
161
|
-
lines.push(
|
|
166
|
+
lines.push(bodyOutsideMounts(req.work.folder, bodyFile));
|
|
162
167
|
} else {
|
|
163
168
|
// After the commit and the push: a body that cannot be written is said, never thrown.
|
|
164
169
|
try {
|
|
165
170
|
await deps.files.write(`${req.work.vfsPath.replace(/\/+$/, "")}/pr-${slug}/PR.md`, body);
|
|
166
|
-
lines.push(
|
|
171
|
+
lines.push(pullRequestBody(bodyFile));
|
|
167
172
|
} catch (e) {
|
|
168
|
-
lines.push(
|
|
173
|
+
lines.push(bodyNotWritten(firstLine((e as Error)?.message ?? e), bodyFile));
|
|
169
174
|
}
|
|
170
175
|
}
|
|
171
176
|
const pr: PullRequest = { base: req.base, head: req.branch, title: req.title, bodyFile, body };
|
|
172
177
|
if (req.open && req.pushed && deps.opener !== undefined) {
|
|
173
178
|
try {
|
|
174
|
-
return [...lines,
|
|
179
|
+
return [...lines, pullRequestOpened((await deps.opener.open(pr)).url)];
|
|
175
180
|
} catch (e) {
|
|
176
|
-
lines.push(
|
|
181
|
+
lines.push(pullRequestNotOpened(firstLine((e as Error)?.message ?? e)));
|
|
177
182
|
}
|
|
178
183
|
}
|
|
179
|
-
lines.push(
|
|
184
|
+
lines.push(TO_OPEN_IN_A_TERMINAL);
|
|
180
185
|
if (!req.pushed) lines.push(` ${gitPushCommand(req.branch)}`);
|
|
181
186
|
lines.push(` ${ghPrCreateCommand(pr)}`);
|
|
182
187
|
if (req.open && deps.opener === undefined) {
|
|
183
|
-
lines.push(
|
|
188
|
+
lines.push(NO_GITHUB_TOOL);
|
|
184
189
|
}
|
|
185
190
|
return lines;
|
|
186
191
|
}
|
|
@@ -11,6 +11,10 @@ import {
|
|
|
11
11
|
GIT_CURRENT_BRANCH_COMMAND, gitMergeFfOnly, gitRebaseAbortIn, gitRebaseIn, isNotFastForward, shellUnsafe,
|
|
12
12
|
} from "../../domain/git/close.ts";
|
|
13
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";
|
|
14
18
|
|
|
15
19
|
export type MergeOutcome =
|
|
16
20
|
| { merged: true; rebased: boolean; line: string }
|
|
@@ -26,17 +30,17 @@ export async function mergeFastForward(
|
|
|
26
30
|
const unsafe = [req.ref, req.workBranch, ...(req.worktree === undefined ? [] : [req.worktree])]
|
|
27
31
|
.filter((v) => shellUnsafe(v) || v.startsWith("-"));
|
|
28
32
|
if (unsafe.length > 0) {
|
|
29
|
-
return { merged: false, line:
|
|
33
|
+
return { merged: false, line: notMergedUnsafe(unsafe.join(", ")), handOver: [merge] };
|
|
30
34
|
}
|
|
31
35
|
const current = (await runGit(shell, GIT_CURRENT_BRANCH_COMMAND)).stdout.trim();
|
|
32
36
|
if (current !== req.workBranch) {
|
|
33
37
|
return {
|
|
34
|
-
merged: false, line:
|
|
38
|
+
merged: false, line: notMergedCheckoutElsewhere(current || DETACHED_HEAD, req.workBranch),
|
|
35
39
|
handOver: [`git checkout ${req.workBranch}`, merge],
|
|
36
40
|
};
|
|
37
41
|
}
|
|
38
42
|
const first = await runGit(shell, merge);
|
|
39
|
-
if (first.exitCode === 0) return { merged: true, rebased: false, line:
|
|
43
|
+
if (first.exitCode === 0) return { merged: true, rebased: false, line: mergedFastForward(req.ref, req.workBranch) };
|
|
40
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.
|
|
41
45
|
if (!isNotFastForward(first.stderr + first.stdout)) {
|
|
42
46
|
return { merged: false, line: `not merged: ${gitReason(first)}`, handOver: [merge] };
|
|
@@ -52,12 +56,12 @@ export async function mergeFastForward(
|
|
|
52
56
|
const rebased = await runGit(shell, rebase);
|
|
53
57
|
if (rebased.exitCode !== 0) {
|
|
54
58
|
const abort = await runGit(shell, gitRebaseAbortIn(req.worktree));
|
|
55
|
-
const aborted = abort.exitCode === 0 ? "rebase aborted" :
|
|
56
|
-
return { merged: false, line:
|
|
59
|
+
const aborted = abort.exitCode === 0 ? "rebase aborted" : rebaseAbortFailed(gitReason(abort));
|
|
60
|
+
return { merged: false, line: rebaseStopped(gitReason(rebased), aborted), handOver: [rebase, merge] };
|
|
57
61
|
}
|
|
58
62
|
const second = await runGit(shell, merge);
|
|
59
63
|
if (second.exitCode === 0) {
|
|
60
|
-
return { merged: true, rebased: true, line:
|
|
64
|
+
return { merged: true, rebased: true, line: rebasedAndMerged(req.ref, req.workBranch) };
|
|
61
65
|
}
|
|
62
|
-
return { merged: false, line:
|
|
66
|
+
return { merged: false, line: notMergedAfterRebase(gitReason(second)), handOver: [merge] };
|
|
63
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`;
|
|
@@ -10,6 +10,7 @@ import type { CreatePrArgs } from "../../domain/git/pull-request.ts";
|
|
|
10
10
|
import { GITHUB_CREATE_PR, GIT_REMOTE_URL_COMMAND, parseGitHubRemote, pullRequestPermission } from "../../domain/git/pull-request.ts";
|
|
11
11
|
import type { PullRequest, PullRequestOpener } from "./commit-files.ts";
|
|
12
12
|
import { gitReason, runGit } from "./commit-files.ts";
|
|
13
|
+
import { BASE_BRANCH_UNKNOWN, notAGitHubRepository, originUrlUnreadable } from "./messages.ts";
|
|
13
14
|
|
|
14
15
|
/** The `create_pr` call of the github tool: the url of the pull request opened, or a throw with GitHub's reason. */
|
|
15
16
|
export interface GitHubPullRequests {
|
|
@@ -34,12 +35,12 @@ export function createPullRequestOpener(
|
|
|
34
35
|
): PullRequestOpener {
|
|
35
36
|
return {
|
|
36
37
|
async open(pr: PullRequest): Promise<{ url: string }> {
|
|
37
|
-
if (pr.base === null) throw new Error(
|
|
38
|
+
if (pr.base === null) throw new Error(BASE_BRANCH_UNKNOWN);
|
|
38
39
|
const remote = await runGit(deps.shell, GIT_REMOTE_URL_COMMAND);
|
|
39
|
-
if (remote.exitCode !== 0) throw new Error(
|
|
40
|
+
if (remote.exitCode !== 0) throw new Error(originUrlUnreadable(gitReason(remote)));
|
|
40
41
|
const repo = parseGitHubRemote(remote.stdout);
|
|
41
42
|
// The URL is echoed without its user part: a token written there never reaches the terminal.
|
|
42
|
-
if (repo === null) throw new Error(
|
|
43
|
+
if (repo === null) throw new Error(notAGitHubRepository(withoutUserInfo(remote.stdout)));
|
|
43
44
|
const args: CreatePrArgs = {
|
|
44
45
|
action: GITHUB_CREATE_PR, owner: repo.owner, repo: repo.repo, base: pr.base, head: pr.head, title: pr.title, body: pr.body,
|
|
45
46
|
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// What every act's callbacks know of the host: its layout (host-layout-store.ts) and the user's path lists
|
|
2
|
+
// (agent-policy/path-rules.ts), read together once a run. The identity context, a posix host without mounts and
|
|
3
|
+
// without a list, means the callbacks have nothing to do.
|
|
4
|
+
import type { Files } from "./ports.ts";
|
|
5
|
+
import type { ConfigStore } from "./config-store.ts";
|
|
6
|
+
import { readHostLayout } from "./host-layout-store.ts";
|
|
7
|
+
import { IDENTITY_HOST, isIdentityHost } from "../domain/host-layout.ts";
|
|
8
|
+
import type { HostLayout } from "../domain/host-layout.ts";
|
|
9
|
+
import {
|
|
10
|
+
EMPTY_PATH_LISTS, PATHS_ALLOW_CONFIG_KEY, PATHS_DENY_CONFIG_KEY, readPathLists,
|
|
11
|
+
} from "../domain/agent-policy/path-rules.ts";
|
|
12
|
+
import type { PathListValues, PathLists } from "../domain/agent-policy/path-rules.ts";
|
|
13
|
+
|
|
14
|
+
/** How an adapter reads this run's context: once asked, at the first operation that needs it. */
|
|
15
|
+
export type HostSource = () => Promise<HostContext>;
|
|
16
|
+
|
|
17
|
+
export interface HostContext {
|
|
18
|
+
layout: HostLayout;
|
|
19
|
+
lists: PathLists;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const IDENTITY_CONTEXT: HostContext = Object.freeze({ layout: IDENTITY_HOST, lists: EMPTY_PATH_LISTS }) as HostContext;
|
|
23
|
+
|
|
24
|
+
/** True when the context gives the callbacks nothing to do: no host fact, no list. */
|
|
25
|
+
export function isIdentityContext(host: HostContext): boolean {
|
|
26
|
+
return isIdentityHost(host.layout) && host.lists.deny.length === 0 && host.lists.allow.length === 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** The lists of a run's context, for a command's gate: none when no source is given. */
|
|
30
|
+
export async function listsOf(host: HostSource | undefined): Promise<PathLists> {
|
|
31
|
+
return host === undefined ? EMPTY_PATH_LISTS : (await host()).lists;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface HostContextRead extends HostContext {
|
|
35
|
+
/** The layout's problems, then the lists', each named for /doctor. */
|
|
36
|
+
problems: string[];
|
|
37
|
+
/** launch.json is not JSON. */
|
|
38
|
+
malformed: boolean;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** The two keys of one settings map, string values only (another type is no value: the schema reports it). */
|
|
42
|
+
function pathListValues(map: Record<string, unknown>): PathListValues {
|
|
43
|
+
const text = (key: string): string | undefined => typeof map[key] === "string" ? map[key] as string : undefined;
|
|
44
|
+
return { deny: text(PATHS_DENY_CONFIG_KEY), allow: text(PATHS_ALLOW_CONFIG_KEY) };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** The host context of a run: launch.json, then the lists of the user settings and of the project file over it. */
|
|
48
|
+
export async function readHostContext(
|
|
49
|
+
files: Pick<Files, "read">, config: Pick<ConfigStore, "readFile" | "readUserFile">,
|
|
50
|
+
): Promise<HostContextRead> {
|
|
51
|
+
const [layout, user, project] = await Promise.all([readHostLayout(files), config.readUserFile(), config.readFile()]);
|
|
52
|
+
const lists = readPathLists(pathListValues(user.map), pathListValues(project.map), layout.layout);
|
|
53
|
+
return {
|
|
54
|
+
layout: layout.layout,
|
|
55
|
+
lists: { deny: lists.deny, allow: lists.allow },
|
|
56
|
+
problems: [...layout.problems, ...lists.problems],
|
|
57
|
+
malformed: layout.malformed,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// The host layout the launcher wrote: /user-config/launch.json, beside the user settings, read through the Files
|
|
2
|
+
// port and parsed by the domain (host-layout.ts). A file that is absent, empty or unreadable (no mount, an older
|
|
3
|
+
// launcher, docker mode's empty layout) is the identity: today's behaviour, a posix host whose paths need no
|
|
4
|
+
// spelling back. One that is not JSON is malformed, named for /doctor, and the identity too.
|
|
5
|
+
import type { Files } from "./ports.ts";
|
|
6
|
+
import { IDENTITY_HOST, parseHostLayout } from "../domain/host-layout.ts";
|
|
7
|
+
import type { HostLayout } from "../domain/host-layout.ts";
|
|
8
|
+
import { notJsonNoHostLayout } from "./messages.ts";
|
|
9
|
+
|
|
10
|
+
export const HOST_LAYOUT_FILE_PATH = "/user-config/launch.json";
|
|
11
|
+
|
|
12
|
+
export interface HostLayoutRead {
|
|
13
|
+
layout: HostLayout;
|
|
14
|
+
/** What the parse left out, each named (host-layout.ts), and the file itself when it is not JSON. */
|
|
15
|
+
problems: string[];
|
|
16
|
+
/** The file holds text that is not JSON: nothing of it applies. */
|
|
17
|
+
malformed: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const IDENTITY_READ: HostLayoutRead = { layout: IDENTITY_HOST, problems: [], malformed: false };
|
|
21
|
+
|
|
22
|
+
/** The layout of launch.json, the identity when the file is absent, empty, unreadable or malformed. */
|
|
23
|
+
export async function readHostLayout(files: Pick<Files, "read">): Promise<HostLayoutRead> {
|
|
24
|
+
let content: string;
|
|
25
|
+
try {
|
|
26
|
+
content = (await files.read(HOST_LAYOUT_FILE_PATH)).trim();
|
|
27
|
+
} catch {
|
|
28
|
+
return IDENTITY_READ;
|
|
29
|
+
}
|
|
30
|
+
if (content.length === 0) return IDENTITY_READ;
|
|
31
|
+
let raw: unknown;
|
|
32
|
+
try {
|
|
33
|
+
raw = JSON.parse(content);
|
|
34
|
+
} catch {
|
|
35
|
+
return { layout: IDENTITY_HOST, problems: [notJsonNoHostLayout(HOST_LAYOUT_FILE_PATH)], malformed: true };
|
|
36
|
+
}
|
|
37
|
+
const { layout, problems } = parseHostLayout(raw);
|
|
38
|
+
return { layout, problems, malformed: false };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** A reader of the layout that reads once: every call of every act needs it, and the launcher writes it once a run. */
|
|
42
|
+
export function onceHostLayout(read: () => Promise<HostLayoutRead>): () => Promise<HostLayoutRead> {
|
|
43
|
+
let layout: Promise<HostLayoutRead> | null = null;
|
|
44
|
+
return () => (layout ??= read());
|
|
45
|
+
}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import type { ConfigStore } from "./config-store.ts";
|
|
6
6
|
import { CONFIG_FILE_PATH } from "./config-store.ts";
|
|
7
7
|
import { LLM_PROFILE_CONFIG_KEY, llmProfileProblem } from "../domain/llm-profile.ts";
|
|
8
|
+
import { couldNotBeReadOrParsed, llmProfileRejected, llmProfileUnreadable } from "./messages.ts";
|
|
8
9
|
|
|
9
10
|
export interface LlmProfileRead {
|
|
10
11
|
/** The profile every agent of the crew runs on; null when the session names none. */
|
|
@@ -17,12 +18,12 @@ export async function readLlmProfile(config: Pick<ConfigStore, "readValue" | "re
|
|
|
17
18
|
try {
|
|
18
19
|
const { value, source } = await config.readValue(LLM_PROFILE_CONFIG_KEY);
|
|
19
20
|
if (source === "unset" && (await config.readFile()).malformed) {
|
|
20
|
-
return unreadable(
|
|
21
|
+
return unreadable(couldNotBeReadOrParsed(CONFIG_FILE_PATH));
|
|
21
22
|
}
|
|
22
23
|
if (typeof value !== "string") return { profile: null };
|
|
23
24
|
const problem = llmProfileProblem(value);
|
|
24
25
|
if (problem !== undefined) {
|
|
25
|
-
return { profile: null, warning:
|
|
26
|
+
return { profile: null, warning: llmProfileRejected(LLM_PROFILE_CONFIG_KEY, problem) };
|
|
26
27
|
}
|
|
27
28
|
return { profile: value.trim() };
|
|
28
29
|
} catch (e: unknown) {
|
|
@@ -31,5 +32,5 @@ export async function readLlmProfile(config: Pick<ConfigStore, "readValue" | "re
|
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
function unreadable(why: string): LlmProfileRead {
|
|
34
|
-
return { profile: null, warning:
|
|
35
|
+
return { profile: null, warning: llmProfileUnreadable(LLM_PROFILE_CONFIG_KEY, why) };
|
|
35
36
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// The text the shared application services report to the user: unreadable settings, warnings, where a mode came from.
|
|
2
|
+
|
|
3
|
+
export const couldNotBeReadOrParsed = (path: string): string => `${path} could not be read or parsed`;
|
|
4
|
+
export const notJsonNoHostLayout = (path: string): string => `${path} is not JSON: no host layout applies`;
|
|
5
|
+
export const llmProfileRejected = (key: string, problem: string): string =>
|
|
6
|
+
`${key}: ${problem}; the host's default model this launch`;
|
|
7
|
+
export const llmProfileUnreadable = (key: string, why: string): string =>
|
|
8
|
+
`${key} could not be read (${why}): the host's default model this launch`;
|
|
9
|
+
export const SESSION_DEFAULT_VIA_MODE = "session default via /mode";
|
|
10
|
+
|
|
11
|
+
// Shared by several application folders
|
|
12
|
+
export const cannotBeRead = (path: string, reason: string): string => `${path} cannot be read (${reason})`;
|
|
13
|
+
export const prefixedCannotBeRead = (prefix: string, path: string, reason: string): string => `${prefix}: ${path} cannot be read (${reason})`;
|
|
14
|
+
export const couldNotRun = (command: string, reason: string): string => `${command} could not run: ${reason}`;
|
|
@@ -19,6 +19,9 @@ import { readJsonArray, writeJson } from "./session-state.ts";
|
|
|
19
19
|
import { formatRule, parseStoredRule, readRule, sameCalls } from "../domain/agent-policy/permission.ts";
|
|
20
20
|
import type { PermissionRule } from "../domain/agent-policy/permission.ts";
|
|
21
21
|
import { PERMISSION_RULES_STATE_KEY } from "../domain/session-keys.ts";
|
|
22
|
+
import { memoryWriteRules } from "../domain/shared-memory/layout.ts";
|
|
23
|
+
import { pathListRules, userConfigRules } from "../domain/agent-policy/path-rules.ts";
|
|
24
|
+
import type { PathLists } from "../domain/agent-policy/path-rules.ts";
|
|
22
25
|
|
|
23
26
|
/** The stored rules, sorted by what the session can do with them. */
|
|
24
27
|
export interface StoredRules {
|
|
@@ -157,3 +160,10 @@ export async function syncStepRules(deps: {
|
|
|
157
160
|
for (const rule of builtIn) deps.gate.add(rule);
|
|
158
161
|
return { ...stored, applied: true, step: [...deps.rules], builtIn, overridden };
|
|
159
162
|
}
|
|
163
|
+
|
|
164
|
+
/** The rules every sync puts in the gate after the session's: the shared memory's guard (no tool of the model writes
|
|
165
|
+
* its candidates or entries), the whole /user-config mount closed, and the user's paths.deny on the canonical
|
|
166
|
+
* spelling (agent-policy/path-rules.ts). */
|
|
167
|
+
export function builtInRules(memoryDir: string, lists: PathLists): PermissionRule[] {
|
|
168
|
+
return [...memoryWriteRules(memoryDir), ...userConfigRules(), ...pathListRules(lists)];
|
|
169
|
+
}
|