orkeon-code 1.0.0-rc.1 → 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 -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 +206 -11
- package/orkeon-code.ps1 +109 -7
- package/package.json +2 -1
- 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 +100 -0
- package/src/commands/_lib/status/meta.ts +3 -24
- 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 +538 -93
- 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 +5 -3
- 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 +5 -4
- 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 +3 -3
- 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 +5 -4
- 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 +12 -9
- 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 +13 -15
- 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 +51 -0
- package/src/crews/dev-learn/application/{learn-prompt.ts → prompts.ts} +24 -65
- package/src/crews/dev-learn/application/run-dev-learn.ts +37 -32
- package/src/crews/dev-learn/crew.ork.ts +4 -3
- package/src/crews/dev-learn/domain/learn-answer.ts +25 -27
- package/src/crews/dev-learn/domain/messages.ts +65 -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 +11 -8
- 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 +30 -31
- 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 +18 -18
- 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 +6 -6
- 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 +16 -37
- 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 +13 -12
- package/src/crews/git-commit/crew.ork.ts +5 -4
- 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 +5 -4
- 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 +63 -30
- 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 +5 -4
- 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 +5 -4
- package/src/crews/shared-memory-admit/application/prompts.ts +5 -0
- package/src/crews/shared-memory-admit/crew.ork.ts +3 -2
- 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 +132 -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 +8 -8
- 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 +5 -4
- package/src/shared/domain/dev/learn-state.ts +3 -2
- package/src/shared/domain/dev/markers.ts +107 -0
- package/src/shared/domain/dev/messages.ts +259 -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 +14 -24
- 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 +4 -3
- 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 +5 -4
- package/src/shared/domain/git/messages.ts +20 -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-verify/application/auditor-prompt.ts +0 -323
- package/src/shared/domain/session-summary.ts +0 -13
|
@@ -11,18 +11,19 @@
|
|
|
11
11
|
|
|
12
12
|
import { CrewBuilder, publishCrew } from "../../shared/infrastructure/globals.ts";
|
|
13
13
|
import { orkeonAgent, orkeonFiles } from "../../shared/infrastructure/orkeon/wiring.ts";
|
|
14
|
-
import {
|
|
14
|
+
import { agentLlm } from "../../shared/infrastructure/orkeon/llm.ts";
|
|
15
15
|
import { runInitVerifiers } from "./application/run-init-verifiers.ts";
|
|
16
|
+
import { AUTHOR_GOAL, AUTHOR_ROLE } from "./application/prompts.ts";
|
|
16
17
|
|
|
17
18
|
const files = orkeonFiles();
|
|
18
19
|
|
|
19
20
|
const author = orkeonAgent()
|
|
20
21
|
.name("verifier-author")
|
|
21
|
-
.role(
|
|
22
|
-
.goal(
|
|
22
|
+
.role(AUTHOR_ROLE)
|
|
23
|
+
.goal(AUTHOR_GOAL)
|
|
23
24
|
.tools([])
|
|
24
25
|
.body(async (_input: any, ctx: any) =>
|
|
25
|
-
await runInitVerifiers({ files, llm:
|
|
26
|
+
await runInitVerifiers({ files, llm: agentLlm(ctx), log: ctx.log }))
|
|
26
27
|
.build();
|
|
27
28
|
|
|
28
29
|
publishCrew(
|
|
@@ -9,6 +9,7 @@ import { AUTOCOMPACT_BREAKER_STATE_KEY } from "../../../shared/domain/session-ke
|
|
|
9
9
|
import type { ConfigStore } from "../../../shared/application/config-store.ts";
|
|
10
10
|
import { readCompactionTrigger } from "../../../shared/application/compaction/compact-session.ts";
|
|
11
11
|
import { isBreakerOpen, nextFailureCount } from "../domain/autocompact.ts";
|
|
12
|
+
import { autoCompactSuppressed } from "./messages.ts";
|
|
12
13
|
|
|
13
14
|
/** A turn's threshold-gated compaction: `compactAt` runs it at the `compaction.trigger` setting, read once, at the
|
|
14
15
|
* turn's first compaction, and shared by its head and its tail compactions (undefined: the computed trigger). */
|
|
@@ -64,7 +65,7 @@ export async function writeBreakerFailures(deps: Pick<AutoCompactDeps, "session"
|
|
|
64
65
|
export async function autoCompactGuarded(deps: AutoCompactDeps): Promise<void> {
|
|
65
66
|
const failures = await readBreakerFailures(deps);
|
|
66
67
|
if (isBreakerOpen(failures)) {
|
|
67
|
-
deps.log.warn(
|
|
68
|
+
deps.log.warn(autoCompactSuppressed(failures));
|
|
68
69
|
return;
|
|
69
70
|
}
|
|
70
71
|
const outcome = await deps.compact();
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// The text the operator reads from a main-loop turn: the answer's notes, the log lines, the crew's own failures.
|
|
2
|
+
|
|
3
|
+
// ── The turn's answer ────────────────────────────────────────────────────
|
|
4
|
+
|
|
5
|
+
export const NO_PROMPT = "No prompt provided.";
|
|
6
|
+
|
|
7
|
+
/** The answer when the prelude left nothing to send. */
|
|
8
|
+
export function nothingToSend(what: string): string {
|
|
9
|
+
return `Nothing to send: ${what} came back empty.`;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** The line the operator reads once per session when the host's permission gate is off. */
|
|
13
|
+
export function gateOffWarning(mode: string): string {
|
|
14
|
+
return "⚠ the host's permission gate is off (Orkeon:Security:PermissionGate:Enabled is not true): " +
|
|
15
|
+
`mode '${mode}' and the session's rules check nothing, every tool call runs. /permissions shows it.`;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** The line shown under an answer the token budget cut short (Orkeon #218, the context counted once since #224):
|
|
19
|
+
* the model's last call, made without tools once the crew's budget was spent. */
|
|
20
|
+
export const BUDGET_EXHAUSTED_LINE =
|
|
21
|
+
"⚠ the turn stopped on its token budget: the answer above is the model's wrap-up, made without tools, and may be cut short";
|
|
22
|
+
|
|
23
|
+
// ── Log lines ────────────────────────────────────────────────────────────
|
|
24
|
+
|
|
25
|
+
export const MODE_ORIGIN_BUILT_IN = "no mode given at launch, built-in 'default'";
|
|
26
|
+
|
|
27
|
+
/** The log line of a prelude about to run. */
|
|
28
|
+
export function preludeRunning(label: string, tool: string): string {
|
|
29
|
+
return `${label}: ${tool}, before the turn`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** The warning when the token budget ran out. */
|
|
33
|
+
export function budgetRanOut(error: string): string {
|
|
34
|
+
return `the token budget ran out: the model's wrap-up is the answer (${error})`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** The warning when the act stopped at its iteration cap. */
|
|
38
|
+
export function turnsRanOut(error: string): string {
|
|
39
|
+
return `the turn stopped without a final answer: ${error}`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** The log line of a stop check that sends the answer back. */
|
|
43
|
+
export function stopCheckSendsBack(guard: string, reason: string): string {
|
|
44
|
+
return `stop check '${guard}': the answer goes back once (${reason})`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** The warning when the stop check's retry failed. */
|
|
48
|
+
export function stopCheckRetryFailed(guard: string, error: string): string {
|
|
49
|
+
return `stop check '${guard}': the retry failed (${error}); the first answer stands`;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** The log line of the effort an act was given, and what the provider receives when it is not that level. */
|
|
53
|
+
export function actEffort(level: string, maxIterations: number, sent: string): string {
|
|
54
|
+
return `act — effort: ${level}${sent}, maxIterations: ${maxIterations}`;
|
|
55
|
+
}
|
|
56
|
+
/** The same line when the session stored no level and the host's own configuration asks for one. */
|
|
57
|
+
export function actHostEffort(level: string, maxIterations: number, sent: string): string {
|
|
58
|
+
return `act — effort: none stored, the host asks for ${level}${sent}, maxIterations: ${maxIterations}`;
|
|
59
|
+
}
|
|
60
|
+
export const effortSentAs = (sent: string, model: string): string => ` (sent as '${sent}' to ${model})`;
|
|
61
|
+
export const effortNotSent = (model: string): string => ` (none sent to ${model})`;
|
|
62
|
+
|
|
63
|
+
/** The warning when a /model override is dropped under an `llm.profile`. */
|
|
64
|
+
export function modelOverrideIgnored(model: string, profile: string): string {
|
|
65
|
+
return `/model override '${model}' ignored: llm.profile ${profile} is active`;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** The warning naming the tools the permission rules removed. */
|
|
69
|
+
export function rulesRemoved(tools: string): string {
|
|
70
|
+
return `permission rules removed: ${tools}`;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** The warning of a permission rule that changes nothing. */
|
|
74
|
+
export function ruleWithoutEffect(reason: string): string {
|
|
75
|
+
return `permission rule without effect: ${reason}`;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** The warning when the auto-compact breaker is open. */
|
|
79
|
+
export function autoCompactSuppressed(failures: number): string {
|
|
80
|
+
return `auto-compact suppressed (breaker open after ${failures} consecutive failures)`;
|
|
81
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// The text the main-loop agent is built with: its role and goal.
|
|
2
|
+
|
|
3
|
+
// Freshness note: the loop deliberately has NO post-edit reindex step.
|
|
4
|
+
/** The role and goal of the main-loop agent. */
|
|
5
|
+
export const CODER_ROLE = "Interactive Coding Agent";
|
|
6
|
+
export const CODER_GOAL = "Understand a coding request, explore/edit/run code via tool-calling under permission, and answer.";
|
|
7
|
+
|
|
8
|
+
// Coordination lives host-side — file_write marks the path dirty (the store hook),
|
|
9
|
+
// shell edits are caught by the git working-tree probe, and the search tools
|
|
10
|
+
// reindex the union BEFORE answering (lazy, grouped, single-flight). Adding a loop
|
|
11
|
+
// step here would double the work and re-introduce the "agent must remember"
|
|
12
|
+
// failure mode the lazy design exists to remove.
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// MainLoop use case — one turn of the interactive loop: run in the mode the
|
|
2
2
|
// launching command resolved, keep the session buffer, compact around the turn,
|
|
3
3
|
// assemble the prompt (F4) and run the autonomous act() call. The turn's messages are
|
|
4
|
-
// built by ./
|
|
4
|
+
// built by ./prompts, the breaker by ./auto-compact; every dependency comes
|
|
5
5
|
// in through the ports.
|
|
6
6
|
|
|
7
|
+
import type { ContextPruning } from "../../../shared/application/compaction/prune-context.ts";
|
|
7
8
|
import {
|
|
8
9
|
MEMORY_TOOLS, catalogueFor, parseStoredRule, resolvePermissionMode, scriptToolsFor,
|
|
9
10
|
} from "../../../shared/domain/agent-policy/permission.ts";
|
|
@@ -18,7 +19,7 @@ import {
|
|
|
18
19
|
applyPrelude, epilogueArgs, errorText, parseEpilogue, parsePrelude, toolFailure,
|
|
19
20
|
} from "../../../shared/domain/prelude.ts";
|
|
20
21
|
import type { PreludeCall } from "../../../shared/domain/prelude.ts";
|
|
21
|
-
import { budgetExhaustedAnswerOf, decisionBlockOf, decisionBlockText } from "../../../shared/domain/llm-failure.ts";
|
|
22
|
+
import { budgetExhaustedAnswerOf, decisionBlockOf, decisionBlockText, iterationsExhaustedOf } from "../../../shared/domain/llm-failure.ts";
|
|
22
23
|
import type { SessionIo } from "../../../shared/application/session-io.ts";
|
|
23
24
|
import { stateSnapshot } from "../../../shared/application/state-snapshot.ts";
|
|
24
25
|
import {
|
|
@@ -26,11 +27,18 @@ import {
|
|
|
26
27
|
OUTPUT_STYLE_STATE_KEY, PASSES_STATE_KEY, PROACTIVE_STATE_KEY, SKILLS_STATE_KEY,
|
|
27
28
|
} from "../../../shared/domain/session-keys.ts";
|
|
28
29
|
import type { ToolTrace } from "../../../shared/application/dev/tool-trace-recorder.ts";
|
|
30
|
+
import type { HostSource } from "../../../shared/application/host-context.ts";
|
|
31
|
+
import { IDENTITY_HOST } from "../../../shared/domain/host-layout.ts";
|
|
32
|
+
import { textToVirtual } from "../../../shared/domain/host-paths.ts";
|
|
29
33
|
import { readBehaviorFlags } from "./context-gather.ts";
|
|
30
34
|
import { autoCompactGuarded } from "./auto-compact.ts";
|
|
31
35
|
import type { AutoCompactDeps } from "./auto-compact.ts";
|
|
32
|
-
import { buildTurnPrompt } from "./turn-
|
|
33
|
-
import
|
|
36
|
+
import { buildTurnPrompt } from "./turn-context.ts";
|
|
37
|
+
import {
|
|
38
|
+
actEffort, actHostEffort, BUDGET_EXHAUSTED_LINE, budgetRanOut, turnsRanOut, effortNotSent, effortSentAs, gateOffWarning, MODE_ORIGIN_BUILT_IN, modelOverrideIgnored, NO_PROMPT,
|
|
39
|
+
nothingToSend, preludeRunning, rulesRemoved, ruleWithoutEffect, stopCheckRetryFailed, stopCheckSendsBack,
|
|
40
|
+
} from "./messages.ts";
|
|
41
|
+
import type { TurnContextDeps, TurnPrompt } from "./turn-context.ts";
|
|
34
42
|
import {
|
|
35
43
|
STOP_GUARDS, TURN_START_GUARDS, buildStopRetryPrompt, buildTurnContextMessage, readClosingLine, refusedTurnText,
|
|
36
44
|
runChain,
|
|
@@ -38,6 +46,7 @@ import {
|
|
|
38
46
|
import type { Guard, StopFacts, TurnStartFacts } from "../domain/turn-chains.ts";
|
|
39
47
|
import { readStartOutput } from "../../../shared/domain/session-start.ts";
|
|
40
48
|
import { llmProfileOf } from "../../../shared/domain/llm-profile.ts";
|
|
49
|
+
import type { EffortReport } from "../../../shared/domain/agent-policy/reasoning.ts";
|
|
41
50
|
|
|
42
51
|
/** The crew's input, as launchMainLoop (/assistant, /summary, /transcribe --then, /voice send and --go) passes it. */
|
|
43
52
|
export interface MainLoopInputs {
|
|
@@ -109,7 +118,7 @@ export function loadCatalogue(input: MainLoopInputs): LoadedCatalogue {
|
|
|
109
118
|
/** Where the mode of the turn came from, when the request did not name it. */
|
|
110
119
|
function modeOrigin(input: MainLoopInputs): string | null {
|
|
111
120
|
if (typeof input.permissionModeVia === "string" && input.permissionModeVia.length > 0) return input.permissionModeVia;
|
|
112
|
-
return input.permissionMode == null ?
|
|
121
|
+
return input.permissionMode == null ? MODE_ORIGIN_BUILT_IN : null;
|
|
113
122
|
}
|
|
114
123
|
|
|
115
124
|
/** Append one turn to the session buffer (best-effort — continuity across runs).
|
|
@@ -122,6 +131,12 @@ export async function appendTurn(session: Pick<SessionIo, "appendMessage">, role
|
|
|
122
131
|
} catch { /* session buffer optional */ }
|
|
123
132
|
}
|
|
124
133
|
|
|
134
|
+
/** What the provider receives when it is not the level asked (Orkeon #360); empty when it is, or unknown. */
|
|
135
|
+
function sentOf(report: EffortReport | null): string {
|
|
136
|
+
if (report === null || report.notice === null || report.notice === "unchecked") return "";
|
|
137
|
+
return report.sent === null ? effortNotSent(report.model) : effortSentAs(report.sent, report.model);
|
|
138
|
+
}
|
|
139
|
+
|
|
125
140
|
/**
|
|
126
141
|
* Run the autonomous tool-use loop and return its text output.
|
|
127
142
|
*
|
|
@@ -133,10 +148,11 @@ export async function appendTurn(session: Pick<SessionIo, "appendMessage">, role
|
|
|
133
148
|
* model name changes for this call.
|
|
134
149
|
*/
|
|
135
150
|
export async function runAct(
|
|
136
|
-
deps: { llm: Pick<Llm, "act">; log: Logger },
|
|
151
|
+
deps: { llm: Pick<Llm, "act" | "effortSent">; log: Logger },
|
|
137
152
|
turn: TurnPrompt,
|
|
138
153
|
mode: string,
|
|
139
154
|
flags: BehaviorFlags = DEFAULT_BEHAVIOR_FLAGS,
|
|
155
|
+
pruning: ContextPruning = {},
|
|
140
156
|
): Promise<string> {
|
|
141
157
|
const active = describeActiveFlags(flags);
|
|
142
158
|
// Anything off-default is announced: a turn that stops after 10 iterations, or
|
|
@@ -144,7 +160,11 @@ export async function runAct(
|
|
|
144
160
|
if (active) deps.log.info(`session flags — ${active}`);
|
|
145
161
|
const maxIterations = maxIterationsFor(flags.effort);
|
|
146
162
|
// A level /effort stored reaches the provider (A-3); the line says what this act was given.
|
|
147
|
-
|
|
163
|
+
// Judged on the agent's own provider and model (its profile included), the /model override over them. With no
|
|
164
|
+
// level stored, the host's own `Llm:Thinking:Effort` still goes out: the line says so when the runtime reports one.
|
|
165
|
+
const report = deps.llm.effortSent({ effort: flags.thinking ?? undefined, model: flags.model });
|
|
166
|
+
if (flags.thinking !== null) deps.log.info(actEffort(flags.thinking, maxIterations, sentOf(report)));
|
|
167
|
+
else if (report !== null) deps.log.info(actHostEffort(report.asked, maxIterations, sentOf(report)));
|
|
148
168
|
|
|
149
169
|
return await deps.llm.act(turn.request, {
|
|
150
170
|
maxIterations,
|
|
@@ -159,24 +179,32 @@ export async function runAct(
|
|
|
159
179
|
// (ActOptions.context, Orkeon #276): a decision guard judges the request alone.
|
|
160
180
|
context: turn.context,
|
|
161
181
|
model: flags.model,
|
|
182
|
+
// The pruning of the loop's stale tool results, when the session turned it on (compaction.prune).
|
|
183
|
+
...pruning,
|
|
162
184
|
});
|
|
163
185
|
}
|
|
164
186
|
|
|
165
187
|
/** The ports one turn runs on. */
|
|
166
188
|
export interface MainLoopDeps extends TurnContextDeps, Omit<AutoCompactDeps, "session"> {
|
|
167
189
|
session: SessionIo;
|
|
168
|
-
llm: Pick<Llm, "act" | "permissionGateEnabled">;
|
|
190
|
+
llm: Pick<Llm, "act" | "effortSent" | "permissionGateEnabled">;
|
|
169
191
|
/** The calls of a prelude and an epilogue, by the registered name the launching command found. */
|
|
170
192
|
tools: Pick<ToolCatalogue, "callText">;
|
|
171
193
|
/** The recorder of the act's tool calls (dev/tool-trace-recorder); absent, the turn stores no [tools] message. */
|
|
172
194
|
trace?: Pick<ToolTrace, "take">;
|
|
173
195
|
/** The guards of the two chains; absent, the built-in ones (domain/turn-chains). */
|
|
174
196
|
chains?: { turnStart?: ReadonlyArray<Guard<TurnStartFacts>>; stop?: ReadonlyArray<Guard<StopFacts>> };
|
|
197
|
+
/** This run's host context (shared/application/host-context): the request's disk spellings come back to the VFS
|
|
198
|
+
* before anything reads them; absent, the identity. */
|
|
199
|
+
host?: HostSource;
|
|
200
|
+
/** What the act carries to prune its loop's stale tool results (shared/application/compaction/prune-context),
|
|
201
|
+
* for the request it works on; absent, nothing is pruned. */
|
|
202
|
+
prune?: (request: string) => Promise<ContextPruning>;
|
|
175
203
|
}
|
|
176
204
|
|
|
177
205
|
/** The request once the prelude's call answered (applyPrelude). */
|
|
178
206
|
async function withPreludeResult(request: string, prelude: PreludeCall, deps: Pick<MainLoopDeps, "tools" | "log">): Promise<string> {
|
|
179
|
-
deps.log.info(
|
|
207
|
+
deps.log.info(preludeRunning(prelude.label, prelude.tool));
|
|
180
208
|
const outcome = await deps.tools.callText(prelude.tool, prelude.args);
|
|
181
209
|
if (!outcome.ok) throw toolFailure(prelude.tool, outcome.failure);
|
|
182
210
|
return applyPrelude(request, prelude, outcome.text);
|
|
@@ -202,17 +230,11 @@ async function gateWarning(mode: string, deps: Pick<MainLoopDeps, "llm" | "sessi
|
|
|
202
230
|
if (mode === "bypassPermissions" || deps.llm.permissionGateEnabled() !== false) return null;
|
|
203
231
|
if (await deps.session.readState(GATE_WARNED_KEY) !== null) return null;
|
|
204
232
|
await deps.session.writeState(GATE_WARNED_KEY, "1");
|
|
205
|
-
const text =
|
|
206
|
-
`mode '${mode}' and the session's rules check nothing, every tool call runs. /permissions shows it.`;
|
|
233
|
+
const text = gateOffWarning(mode);
|
|
207
234
|
deps.log.warn(text);
|
|
208
235
|
return text;
|
|
209
236
|
}
|
|
210
237
|
|
|
211
|
-
/** The line shown under an answer the token budget cut short (Orkeon #218, the context counted once since #224):
|
|
212
|
-
* the model's last call, made without tools once the crew's budget was spent. */
|
|
213
|
-
export const BUDGET_EXHAUSTED_LINE =
|
|
214
|
-
"⚠ the turn stopped on its token budget: the answer above is the model's wrap-up, made without tools, and may be cut short";
|
|
215
|
-
|
|
216
238
|
/** The answer of a turn, and whether the token budget cut it short. */
|
|
217
239
|
interface TurnAnswer { answer: string; cut: boolean }
|
|
218
240
|
|
|
@@ -220,29 +242,35 @@ interface TurnAnswer { answer: string; cut: boolean }
|
|
|
220
242
|
* with the reason, and the second answer stands whatever the chain would say of it. When that
|
|
221
243
|
* retry throws, a first answer that is not blank stands, with a warning. An act whose token
|
|
222
244
|
* budget ran out (BudgetExhaustedAnswer) gives its wrap-up as the answer, `cut`, and goes
|
|
223
|
-
* through no stop check: a second act would meet the same spent budget.
|
|
245
|
+
* through no stop check: a second act would meet the same spent budget. An act stopped at its
|
|
246
|
+
* iteration cap (IterationsExhausted) answers the runtime's notice, with no stop check either. */
|
|
224
247
|
async function stopChecked(
|
|
225
248
|
deps: Pick<MainLoopDeps, "llm" | "log" | "chains">, turn: TurnPrompt, mode: string, flags: BehaviorFlags,
|
|
226
|
-
request: string, closingLine: string | null,
|
|
249
|
+
request: string, closingLine: string | null, pruningOf: () => Promise<ContextPruning>,
|
|
227
250
|
): Promise<TurnAnswer> {
|
|
228
251
|
let answer: string;
|
|
229
252
|
try {
|
|
230
|
-
answer = await runAct(deps, turn, mode, flags);
|
|
253
|
+
answer = await runAct(deps, turn, mode, flags, await pruningOf());
|
|
231
254
|
} catch (error) {
|
|
255
|
+
const stopped = iterationsExhaustedOf(error);
|
|
256
|
+
if (stopped !== null) {
|
|
257
|
+
deps.log.warn(turnsRanOut(errorText(error)));
|
|
258
|
+
return { answer: stopped.notice, cut: false };
|
|
259
|
+
}
|
|
232
260
|
const exhausted = budgetExhaustedAnswerOf(error);
|
|
233
261
|
if (exhausted === null) throw error;
|
|
234
|
-
deps.log.warn(
|
|
262
|
+
deps.log.warn(budgetRanOut(errorText(error)));
|
|
235
263
|
return { answer: exhausted.answer, cut: true };
|
|
236
264
|
}
|
|
237
265
|
const stop = runChain("stop", deps.chains?.stop ?? STOP_GUARDS, { request, answer, closingLine });
|
|
238
266
|
if (stop.refusedBy === undefined) return { answer, cut: false };
|
|
239
|
-
deps.log.info(
|
|
267
|
+
deps.log.info(stopCheckSendsBack(stop.refusedBy, String(stop.reason)));
|
|
240
268
|
try {
|
|
241
|
-
return { answer: await runAct(deps, { ...turn, request: buildStopRetryPrompt(turn.request, answer, stop.reason ?? "") }, mode, flags), cut: false };
|
|
269
|
+
return { answer: await runAct(deps, { ...turn, request: buildStopRetryPrompt(turn.request, answer, stop.reason ?? "") }, mode, flags, await pruningOf()), cut: false };
|
|
242
270
|
} catch (error) {
|
|
243
271
|
// A retry that fails (a provider error) never costs the turn an answer it had: the first one stands, said.
|
|
244
272
|
if (answer.trim().length === 0) throw error;
|
|
245
|
-
deps.log.warn(
|
|
273
|
+
deps.log.warn(stopCheckRetryFailed(stop.refusedBy, errorText(error)));
|
|
246
274
|
return { answer, cut: false };
|
|
247
275
|
}
|
|
248
276
|
}
|
|
@@ -252,7 +280,7 @@ async function stopChecked(
|
|
|
252
280
|
* decision profile's escalation target with it (the runtime patches the same call configuration onto both). */
|
|
253
281
|
function underProfile(flags: BehaviorFlags, profile: string | null, log: Pick<Logger, "warn">): BehaviorFlags {
|
|
254
282
|
if (profile === null || flags.model === "") return flags;
|
|
255
|
-
log.warn(
|
|
283
|
+
log.warn(modelOverrideIgnored(flags.model, profile));
|
|
256
284
|
return { ...flags, model: "" };
|
|
257
285
|
}
|
|
258
286
|
|
|
@@ -266,9 +294,12 @@ const TURN_STATE_KEYS = [
|
|
|
266
294
|
|
|
267
295
|
/** One turn: the answer, or why there was none. */
|
|
268
296
|
export async function runMainLoop(input: MainLoopInputs, loaded: LoadedCatalogue, given: MainLoopDeps): Promise<string> {
|
|
269
|
-
|
|
297
|
+
// A path the user typed as the disk spells it names the VFS path from here on, in the transcript too; what a
|
|
298
|
+
// fenced block quotes stays as typed.
|
|
299
|
+
const layout = given.host === undefined ? IDENTITY_HOST : (await given.host()).layout;
|
|
300
|
+
const request = textToVirtual(String(input.prompt ?? "").trim(), layout, { keepFenced: true });
|
|
270
301
|
const prelude = parsePrelude(input.prelude);
|
|
271
|
-
if (request.length === 0 && prelude?.as !== "request") return
|
|
302
|
+
if (request.length === 0 && prelude?.as !== "request") return NO_PROMPT;
|
|
272
303
|
// Every reader of the turn reads the state bag through this session: its keys come from one batch read.
|
|
273
304
|
const session: SessionIo = { ...given.session, ...await stateSnapshot(given.session, TURN_STATE_KEYS) };
|
|
274
305
|
const deps: MainLoopDeps = { ...given, session };
|
|
@@ -276,7 +307,7 @@ export async function runMainLoop(input: MainLoopInputs, loaded: LoadedCatalogue
|
|
|
276
307
|
// The prelude runs first, as the launching command's call (the gate does not ask):
|
|
277
308
|
// a failure fails the run before any message is stored or any model is called.
|
|
278
309
|
const prompt = prelude === null ? request : await withPreludeResult(request, prelude, deps);
|
|
279
|
-
if (prompt.length === 0) return
|
|
310
|
+
if (prompt.length === 0) return nothingToSend(prelude?.label ?? "the request");
|
|
280
311
|
|
|
281
312
|
// The mode the catalogue was built for: the "mode:" prefix, else the session
|
|
282
313
|
// default set by /mode, else the fallback (B-2 — built-in 'default' like the
|
|
@@ -291,9 +322,9 @@ export async function runMainLoop(input: MainLoopInputs, loaded: LoadedCatalogue
|
|
|
291
322
|
// short of a tool is indistinguishable from a mode that never had it.
|
|
292
323
|
const { catalogue } = loaded;
|
|
293
324
|
if (catalogue.deniedByRule.length > 0) {
|
|
294
|
-
log.warn(
|
|
325
|
+
log.warn(rulesRemoved(catalogue.deniedByRule.join(", ")));
|
|
295
326
|
}
|
|
296
|
-
for (const r of catalogue.inert) log.warn(
|
|
327
|
+
for (const r of catalogue.inert) log.warn(ruleWithoutEffect(r.reason));
|
|
297
328
|
const warning = await gateWarning(mode, deps);
|
|
298
329
|
|
|
299
330
|
// B-9 / B-10: the persisted behavior flags, read ONCE per turn so prompt
|
|
@@ -326,9 +357,11 @@ export async function runMainLoop(input: MainLoopInputs, loaded: LoadedCatalogue
|
|
|
326
357
|
// ran before it (an edit made on disk stays on record), the run not failed.
|
|
327
358
|
// The calls of a head-of-turn compaction are not the answer's: the trace starts with the act.
|
|
328
359
|
deps.trace?.take();
|
|
360
|
+
// One binding per act: the runtime numbers the calls of each act from 1, and the binding remembers them.
|
|
361
|
+
const pruningOf = async (): Promise<ContextPruning> => deps.prune === undefined ? {} : await deps.prune(prompt);
|
|
329
362
|
let checked: { answer: string; cut: boolean };
|
|
330
363
|
try {
|
|
331
|
-
checked = await stopChecked(deps, assembled, mode, flags, prompt, readClosingLine(input.closingLine));
|
|
364
|
+
checked = await stopChecked(deps, assembled, mode, flags, prompt, readClosingLine(input.closingLine), pruningOf);
|
|
332
365
|
} catch (error) {
|
|
333
366
|
const block = decisionBlockOf(error);
|
|
334
367
|
if (block === null) throw error;
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
withoutCurrentRequest,
|
|
17
17
|
buildPreferencesBlock,
|
|
18
18
|
buildSkillsBlock,
|
|
19
|
+
buildSuggestedSkillsBlock,
|
|
19
20
|
buildHooksBlock,
|
|
20
21
|
} from "../domain/prompt-assembly.ts";
|
|
21
22
|
import {
|
|
@@ -41,6 +42,9 @@ export interface TurnContextDeps {
|
|
|
41
42
|
config?: Pick<ConfigStore, "readValue">;
|
|
42
43
|
/** The time now: the environment block carries its UTC day. */
|
|
43
44
|
clock: Clock;
|
|
45
|
+
/** The skills suggested for the request (shared/application/skills/suggest-skills), given the paths already
|
|
46
|
+
* attached; absent, none is suggested. */
|
|
47
|
+
suggest?: (request: string, attached: readonly string[]) => Promise<AttachedSkill[]>;
|
|
44
48
|
}
|
|
45
49
|
|
|
46
50
|
/** One act() turn's messages: the byte-stable system prompt, the volatile context, the request. */
|
|
@@ -83,6 +87,8 @@ export async function buildTurnPrompt(
|
|
|
83
87
|
wantAdvisory ? readAttachedSkills(session, files) : Promise.resolve([] as AttachedSkill[]),
|
|
84
88
|
readLanguage(deps.config),
|
|
85
89
|
]);
|
|
90
|
+
// The skills that fit this request come after the ones a person attached, in a block of their own, for this turn only.
|
|
91
|
+
const suggested = wantAdvisory && deps.suggest !== undefined ? await deps.suggest(prompt, skills.map((skill) => skill.path)) : [];
|
|
86
92
|
const today = isoDay(deps.clock());
|
|
87
93
|
|
|
88
94
|
return {
|
|
@@ -91,7 +97,7 @@ export async function buildTurnPrompt(
|
|
|
91
97
|
// All volatile, all in the context. An unconfigured session renders none
|
|
92
98
|
// of the optional blocks.
|
|
93
99
|
preferences: buildPreferencesBlock({ outputStyle, language }),
|
|
94
|
-
skills: buildSkillsBlock(skills),
|
|
100
|
+
skills: [buildSkillsBlock(skills), buildSuggestedSkillsBlock(suggested)].filter((block) => block.length > 0).join("\n\n"),
|
|
95
101
|
memory: buildMemoryBlock(memory),
|
|
96
102
|
hooks: buildHooksBlock(hooks),
|
|
97
103
|
userContext: buildUserContextBlock({ ...git, date: today }),
|
|
@@ -103,10 +109,3 @@ export async function buildTurnPrompt(
|
|
|
103
109
|
request: "## Request\n" + buildActPrompt(prompt, mode) + proactiveSuffix(flags.proactive),
|
|
104
110
|
};
|
|
105
111
|
}
|
|
106
|
-
|
|
107
|
-
// Freshness note: the loop deliberately has NO post-edit reindex step.
|
|
108
|
-
// Coordination lives host-side — file_write marks the path dirty (the store hook),
|
|
109
|
-
// shell edits are caught by the git working-tree probe, and the search tools
|
|
110
|
-
// reindex the union BEFORE answering (lazy, grouped, single-flight). Adding a loop
|
|
111
|
-
// step here would double the work and re-introduce the "agent must remember"
|
|
112
|
-
// failure mode the lazy design exists to remove.
|
|
@@ -33,14 +33,15 @@
|
|
|
33
33
|
|
|
34
34
|
import { CrewBuilder, publishCrew, inputs, ToolBuilder } from "../../shared/infrastructure/globals.ts";
|
|
35
35
|
import {
|
|
36
|
-
orkeonActTakesContext,
|
|
37
36
|
orkeonAgent,
|
|
38
37
|
orkeonClock,
|
|
39
38
|
orkeonCompactionDeps,
|
|
40
39
|
orkeonConfigStore,
|
|
41
40
|
orkeonFiles,
|
|
41
|
+
orkeonHostContext,
|
|
42
42
|
orkeonMemoryStore,
|
|
43
43
|
orkeonMemoryToolPorts,
|
|
44
|
+
orkeonDecisionModel,
|
|
44
45
|
orkeonProgress,
|
|
45
46
|
orkeonSessionIo,
|
|
46
47
|
orkeonShell,
|
|
@@ -48,13 +49,16 @@ import {
|
|
|
48
49
|
orkeonToolCalls,
|
|
49
50
|
} from "../../shared/infrastructure/orkeon/wiring.ts";
|
|
50
51
|
import { memoryTools } from "../../shared/infrastructure/orkeon/memory-tools.ts";
|
|
51
|
-
import {
|
|
52
|
+
import { agentLlm } from "../../shared/infrastructure/orkeon/llm.ts";
|
|
52
53
|
import { memoryGuardCallbacks } from "../../shared/application/dev/tool-callbacks.ts";
|
|
53
54
|
import { createToolTrace, tracedCallbacks } from "../../shared/application/dev/tool-trace-recorder.ts";
|
|
54
55
|
import { memoryDirOf } from "../../shared/application/shared-memory/memory-settings.ts";
|
|
55
56
|
import { createRunState } from "../../shared/infrastructure/orkeon/run-state.ts";
|
|
56
57
|
import { compactSession } from "../../shared/application/compaction/compact-session.ts";
|
|
57
58
|
import { loadCatalogue, runMainLoop } from "./application/run-main-loop.ts";
|
|
59
|
+
import { contextPruning } from "../../shared/application/compaction/prune-context.ts";
|
|
60
|
+
import { suggestSkills } from "../../shared/application/skills/suggest-skills.ts";
|
|
61
|
+
import { CODER_GOAL, CODER_ROLE } from "./application/prompts.ts";
|
|
58
62
|
import { BREAKER_RUN_FIELD, turnCompaction } from "./application/auto-compact.ts";
|
|
59
63
|
|
|
60
64
|
// The tool catalogue is decided at load time (module scope is synchronous), from
|
|
@@ -62,8 +66,6 @@ import { BREAKER_RUN_FIELD, turnCompaction } from "./application/auto-compact.ts
|
|
|
62
66
|
const loaded = loadCatalogue(inputs());
|
|
63
67
|
|
|
64
68
|
const clock = orkeonClock();
|
|
65
|
-
// The turn's context rides apart from its request where the runtime reads `act({context})` (Orkeon #277).
|
|
66
|
-
const contextApart = orkeonActTakesContext();
|
|
67
69
|
const progress = orkeonProgress();
|
|
68
70
|
const ports = {
|
|
69
71
|
shell: orkeonShell(), session: orkeonSessionIo(), files: orkeonFiles(), telemetry: orkeonTelemetry(),
|
|
@@ -72,8 +74,8 @@ const ports = {
|
|
|
72
74
|
|
|
73
75
|
const coder = orkeonAgent()
|
|
74
76
|
.name("coder")
|
|
75
|
-
.role(
|
|
76
|
-
.goal(
|
|
77
|
+
.role(CODER_ROLE)
|
|
78
|
+
.goal(CODER_GOAL)
|
|
77
79
|
.tools(loaded.catalogue.tools)
|
|
78
80
|
// The shared memory's tools the mode offers (memory_recall always, memory_push where it edits), attached, not named.
|
|
79
81
|
.withAutonomousTools(memoryTools(ToolBuilder, orkeonMemoryToolPorts, loaded.mode, loaded.scriptTools))
|
|
@@ -84,7 +86,7 @@ const coder = orkeonAgent()
|
|
|
84
86
|
// path in another case, a shell cd into the folder) is refused here (shared-memory/layout memoryWriteRefusal).
|
|
85
87
|
// Each result is recorded on the way (tool-trace-recorder): the turn stores its calls as a [tools] message.
|
|
86
88
|
const trace = createToolTrace();
|
|
87
|
-
const llm =
|
|
89
|
+
const llm = agentLlm(ctx, tracedCallbacks(memoryGuardCallbacks(memoryDirOf(ports.config)), trace));
|
|
88
90
|
const log = ctx.log;
|
|
89
91
|
return await runMainLoop(inputs(), loaded, {
|
|
90
92
|
...ports,
|
|
@@ -93,6 +95,9 @@ const coder = orkeonAgent()
|
|
|
93
95
|
trace,
|
|
94
96
|
run: createRunState(ctx),
|
|
95
97
|
clock,
|
|
98
|
+
host: orkeonHostContext,
|
|
99
|
+
suggest: (request, attached) => suggestSkills({ config: ports.config, decision: orkeonDecisionModel(), files: ports.files, session: ports.session, log }, request, attached),
|
|
100
|
+
prune: (request) => contextPruning({ config: ports.config, decision: orkeonDecisionModel(), session: ports.session, log }, request),
|
|
96
101
|
compact: turnCompaction(ports.config, (trigger) => compactSession(
|
|
97
102
|
{ force: false, trigger },
|
|
98
103
|
orkeonCompactionDeps({ llm, log }, { ...ports, progress }, clock),
|