orkeon-code 0.0.0-stage → 1.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.orkeon-runtime +10 -0
- package/.orkeon-version +1 -0
- package/LICENSE.md +21 -0
- package/NOTICE.md +17 -0
- package/README.fr.md +163 -0
- package/README.md +156 -2
- package/config/appsettings.anthropic.example.json +77 -0
- package/config/appsettings.example.json +71 -0
- package/config/appsettings.jev.example.json +131 -0
- package/config/appsettings.kev.example.json +133 -0
- package/config/appsettings.liquid.example.json +132 -0
- package/config/appsettings.ollama-whisper.example.json +93 -0
- package/config/appsettings.ollama.example.json +70 -0
- package/config/appsettings.whisper.example.json +32 -0
- package/mcp/whisper/README.md +294 -0
- package/mcp/whisper/pyproject.toml +32 -0
- package/mcp/whisper/uv.lock +1641 -0
- package/mcp/whisper/whisper_mcp.py +1053 -0
- package/orkeon-code +1092 -0
- package/orkeon-code.mjs +71 -0
- package/orkeon-code.ps1 +939 -0
- package/package.json +58 -4
- package/scripts/install.ps1 +156 -0
- package/scripts/install.sh +148 -0
- package/scripts/session-start.ork.ts +90 -0
- package/scripts/session-start.sh +74 -0
- package/scripts/setup-fixture.sh +88 -0
- package/src/commands/.orkeon/orkeon-cli.d.ts +559 -0
- package/src/commands/_lib/args.ts +194 -0
- package/src/commands/_lib/dev/dev-batches.ts +366 -0
- package/src/commands/_lib/dev/dev-implement.ts +185 -0
- package/src/commands/_lib/dev/dev-source.ts +61 -0
- package/src/commands/_lib/dev/dev.ts +341 -0
- package/src/commands/_lib/dev/markers.ts +7 -0
- package/src/commands/_lib/dev/messages.ts +112 -0
- package/src/commands/_lib/dev-step.ts +145 -0
- package/src/commands/_lib/dispatch.ts +254 -0
- package/src/commands/_lib/effort.ts +15 -0
- package/src/commands/_lib/git/branch.ts +94 -0
- package/src/commands/_lib/git/commit.ts +90 -0
- package/src/commands/_lib/git/diff.ts +107 -0
- package/src/commands/_lib/git/messages.ts +54 -0
- package/src/commands/_lib/git/review.ts +108 -0
- package/src/commands/_lib/memory/memory-admit.ts +148 -0
- package/src/commands/_lib/memory/memory.ts +52 -0
- package/src/commands/_lib/memory/messages.ts +32 -0
- package/src/commands/_lib/messages.ts +48 -0
- package/src/commands/_lib/pr-context.ts +32 -0
- package/src/commands/_lib/project/analyze.ts +24 -0
- package/src/commands/_lib/project/messages.ts +8 -0
- package/src/commands/_lib/session/export.ts +105 -0
- package/src/commands/_lib/session/messages.ts +87 -0
- package/src/commands/_lib/session/prompts.ts +4 -0
- package/src/commands/_lib/session/resume.ts +151 -0
- package/src/commands/_lib/session/tasks.ts +181 -0
- package/src/commands/_lib/settings/advisor.ts +75 -0
- package/src/commands/_lib/settings/agents.ts +137 -0
- package/src/commands/_lib/settings/choices.ts +8 -0
- package/src/commands/_lib/settings/config.ts +141 -0
- package/src/commands/_lib/settings/effort.ts +147 -0
- package/src/commands/_lib/settings/hooks.ts +50 -0
- package/src/commands/_lib/settings/messages.ts +408 -0
- package/src/commands/_lib/settings/mode.ts +100 -0
- package/src/commands/_lib/settings/model.ts +181 -0
- package/src/commands/_lib/settings/output-style.ts +39 -0
- package/src/commands/_lib/settings/permissions.ts +287 -0
- package/src/commands/_lib/settings/route.ts +63 -0
- package/src/commands/_lib/settings/session-config.ts +49 -0
- package/src/commands/_lib/settings/skills.ts +93 -0
- package/src/commands/_lib/settings/theme.ts +42 -0
- package/src/commands/_lib/speech/messages.ts +58 -0
- package/src/commands/_lib/speech/prompts.ts +4 -0
- package/src/commands/_lib/speech/say.ts +95 -0
- package/src/commands/_lib/speech/transcribe.ts +121 -0
- package/src/commands/_lib/speech/voice.ts +142 -0
- package/src/commands/_lib/status/cache.ts +31 -0
- package/src/commands/_lib/status/context.ts +57 -0
- package/src/commands/_lib/status/doctor.ts +205 -0
- package/src/commands/_lib/status/messages.ts +100 -0
- package/src/commands/_lib/status/meta.ts +24 -0
- package/src/commands/_lib/status/status.ts +128 -0
- package/src/commands/_lib/status/usage-tools.ts +48 -0
- package/src/commands/_lib/status/usage.ts +128 -0
- package/src/commands/_lib/view.ts +34 -0
- package/src/commands/dev/dev-batches.cmd.ts +109 -0
- package/src/commands/dev/dev-learn.cmd.ts +29 -0
- package/src/commands/dev/dev-plan.cmd.ts +51 -0
- package/src/commands/dev/dev-spec.cmd.ts +54 -0
- package/src/commands/dev/dev-status.cmd.ts +16 -0
- package/src/commands/git/branch.cmd.ts +27 -0
- package/src/commands/git/commit.cmd.ts +48 -0
- package/src/commands/git/diff.cmd.ts +26 -0
- package/src/commands/git/review.cmd.ts +36 -0
- package/src/commands/memory/memory.cmd.ts +48 -0
- package/src/commands/project/analyze.cmd.ts +32 -0
- package/src/commands/project/debug-tool-call.cmd.ts +62 -0
- package/src/commands/project/files.cmd.ts +22 -0
- package/src/commands/project/init-verifiers.cmd.ts +14 -0
- package/src/commands/project/init.cmd.ts +14 -0
- package/src/commands/project/verify.cmd.ts +27 -0
- package/src/commands/session/assistant.cmd.ts +40 -0
- package/src/commands/session/btw.cmd.ts +18 -0
- package/src/commands/session/clear.cmd.ts +19 -0
- package/src/commands/session/compact.cmd.ts +16 -0
- package/src/commands/session/copy.cmd.ts +45 -0
- package/src/commands/session/exit.cmd.ts +9 -0
- package/src/commands/session/export.cmd.ts +28 -0
- package/src/commands/session/rename.cmd.ts +18 -0
- package/src/commands/session/resume.cmd.ts +19 -0
- package/src/commands/session/rewind.cmd.ts +25 -0
- package/src/commands/session/summary.cmd.ts +27 -0
- package/src/commands/session/tasks.cmd.ts +46 -0
- package/src/commands/settings/advisor.cmd.ts +38 -0
- package/src/commands/settings/agents.cmd.ts +19 -0
- package/src/commands/settings/config.cmd.ts +19 -0
- package/src/commands/settings/effort.cmd.ts +19 -0
- package/src/commands/settings/fast.cmd.ts +18 -0
- package/src/commands/settings/hooks.cmd.ts +17 -0
- package/src/commands/settings/mode.cmd.ts +20 -0
- package/src/commands/settings/model.cmd.ts +21 -0
- package/src/commands/settings/output-style.cmd.ts +19 -0
- package/src/commands/settings/permissions.cmd.ts +25 -0
- package/src/commands/settings/proactive.cmd.ts +16 -0
- package/src/commands/settings/route.cmd.ts +16 -0
- package/src/commands/settings/skills.cmd.ts +17 -0
- package/src/commands/settings/theme.cmd.ts +14 -0
- package/src/commands/speech/say.cmd.ts +24 -0
- package/src/commands/speech/transcribe.cmd.ts +29 -0
- package/src/commands/speech/voice.cmd.ts +30 -0
- package/src/commands/status/context.cmd.ts +18 -0
- package/src/commands/status/doctor.cmd.ts +27 -0
- package/src/commands/status/release-notes.cmd.ts +9 -0
- package/src/commands/status/status.cmd.ts +25 -0
- package/src/commands/status/usage.cmd.ts +21 -0
- package/src/crews/.orkeon/orkeon.d.ts +4391 -0
- package/src/crews/_probe-shared-memory/domain/messages.ts +54 -0
- package/src/crews/_probe-shared-memory/domain/probe-verdict.ts +188 -0
- package/src/crews/_probe-shared-memory/domain/prompts.ts +5 -0
- package/src/crews/_probe-shared-memory/probe.ork.ts +100 -0
- package/src/crews/advisor/application/messages.ts +4 -0
- package/src/crews/advisor/application/prompts.ts +4 -0
- package/src/crews/advisor/application/run-advisor.ts +41 -0
- package/src/crews/advisor/crew.ork.ts +44 -0
- package/src/crews/advisor/domain/advice.ts +119 -0
- package/src/crews/advisor/domain/messages.ts +8 -0
- package/src/crews/advisor/domain/prompts.ts +26 -0
- package/src/crews/agent-run/application/messages.ts +18 -0
- package/src/crews/agent-run/application/run-agent-run.ts +43 -0
- package/src/crews/agent-run/crew.ork.ts +67 -0
- package/src/crews/analyze/application/messages.ts +27 -0
- package/src/crews/analyze/application/prompts.ts +4 -0
- package/src/crews/analyze/application/run-analyze.ts +120 -0
- package/src/crews/analyze/crew.ork.ts +41 -0
- package/src/crews/analyze/domain/harvest.ts +269 -0
- package/src/crews/analyze/domain/prompts.ts +86 -0
- package/src/crews/code-review/application/lens-material.ts +24 -0
- package/src/crews/code-review/application/messages.ts +17 -0
- package/src/crews/code-review/application/prompts.ts +126 -0
- package/src/crews/code-review/application/review.ts +74 -0
- package/src/crews/code-review/application/run-code-review.ts +121 -0
- package/src/crews/code-review/crew.ork.ts +52 -0
- package/src/crews/code-review/domain/lenses.ts +154 -0
- package/src/crews/code-review/domain/messages.ts +25 -0
- package/src/crews/code-review/domain/prompts.ts +58 -0
- package/src/crews/code-review/domain/report.ts +58 -0
- package/src/crews/code-review/domain/scope.ts +106 -0
- package/src/crews/dev-batches/application/messages.ts +127 -0
- package/src/crews/dev-batches/application/plan-close.ts +181 -0
- package/src/crews/dev-batches/application/prompts.ts +10 -0
- package/src/crews/dev-batches/application/run-dev-batches.ts +676 -0
- package/src/crews/dev-batches/application/run-wave.ts +452 -0
- package/src/crews/dev-batches/application/seed-harvest.ts +163 -0
- package/src/crews/dev-batches/crew.ork.ts +146 -0
- package/src/crews/dev-batches/domain/batch-waves.ts +70 -0
- package/src/crews/dev-batches/domain/batches-budget.ts +52 -0
- package/src/crews/dev-batches/domain/batches-log.ts +52 -0
- package/src/crews/dev-batches/domain/markers.ts +5 -0
- package/src/crews/dev-batches/domain/messages.ts +6 -0
- package/src/crews/dev-batches/domain/wave-order.ts +44 -0
- package/src/crews/dev-change/application/change-material.ts +44 -0
- package/src/crews/dev-change/application/evidence.ts +172 -0
- package/src/crews/dev-change/application/messages.ts +81 -0
- package/src/crews/dev-change/application/prompts.ts +101 -0
- package/src/crews/dev-change/application/run-dev-change.ts +324 -0
- package/src/crews/dev-change/crew.ork.ts +114 -0
- package/src/crews/dev-change/domain/change-answer.ts +163 -0
- package/src/crews/dev-change/domain/change-render.ts +77 -0
- package/src/crews/dev-change/domain/markers.ts +28 -0
- package/src/crews/dev-change/domain/messages.ts +16 -0
- package/src/crews/dev-implement/application/close.ts +186 -0
- package/src/crews/dev-implement/application/count-open-steps.ts +24 -0
- package/src/crews/dev-implement/application/locate-sheet.ts +82 -0
- package/src/crews/dev-implement/application/messages.ts +161 -0
- package/src/crews/dev-implement/application/observe.ts +52 -0
- package/src/crews/dev-implement/application/prompts.ts +9 -0
- package/src/crews/dev-implement/application/report-writes.ts +46 -0
- package/src/crews/dev-implement/application/run-dev-implement.ts +822 -0
- package/src/crews/dev-implement/application/run-role.ts +27 -0
- package/src/crews/dev-implement/application/suite-job.ts +122 -0
- package/src/crews/dev-implement/application/touched.ts +74 -0
- package/src/crews/dev-implement/crew.ork.ts +69 -0
- package/src/crews/dev-implement/domain/contracts.ts +255 -0
- package/src/crews/dev-implement/domain/correction.ts +103 -0
- package/src/crews/dev-implement/domain/cycles.ts +36 -0
- package/src/crews/dev-implement/domain/implement-budget.ts +29 -0
- package/src/crews/dev-implement/domain/markers.ts +23 -0
- package/src/crews/dev-implement/domain/messages.ts +58 -0
- package/src/crews/dev-implement/domain/prompts.ts +93 -0
- package/src/crews/dev-implement/domain/roles.ts +49 -0
- package/src/crews/dev-implement/domain/sheet-edits.ts +76 -0
- package/src/crews/dev-implement/domain/sheet-ticks.ts +23 -0
- package/src/crews/dev-implement/domain/step-checks.ts +137 -0
- package/src/crews/dev-implement/domain/step-section.ts +129 -0
- package/src/crews/dev-learn/application/learn-backlog.ts +58 -0
- package/src/crews/dev-learn/application/learn-prompt-fit.ts +63 -0
- package/src/crews/dev-learn/application/messages.ts +51 -0
- package/src/crews/dev-learn/application/prompts.ts +99 -0
- package/src/crews/dev-learn/application/run-dev-learn.ts +558 -0
- package/src/crews/dev-learn/crew.ork.ts +53 -0
- package/src/crews/dev-learn/domain/learn-answer.ts +233 -0
- package/src/crews/dev-learn/domain/messages.ts +65 -0
- package/src/crews/dev-learn/domain/owner-lines.ts +89 -0
- package/src/crews/dev-learn/domain/proposals-render.ts +95 -0
- package/src/crews/dev-plan/application/anchor-paths.ts +113 -0
- package/src/crews/dev-plan/application/inventory.ts +174 -0
- package/src/crews/dev-plan/application/messages.ts +88 -0
- package/src/crews/dev-plan/application/plan-prompt-fit.ts +44 -0
- package/src/crews/dev-plan/application/prompts.ts +141 -0
- package/src/crews/dev-plan/application/run-dev-plan.ts +483 -0
- package/src/crews/dev-plan/crew.ork.ts +112 -0
- package/src/crews/dev-plan/domain/inventory-model.ts +95 -0
- package/src/crews/dev-plan/domain/markers.ts +18 -0
- package/src/crews/dev-plan/domain/messages.ts +118 -0
- package/src/crews/dev-plan/domain/plan-answer.ts +753 -0
- package/src/crews/dev-plan/domain/plan-render.ts +306 -0
- package/src/crews/dev-plan/domain/prompts.ts +44 -0
- package/src/crews/dev-spec/application/messages.ts +30 -0
- package/src/crews/dev-spec/application/prompts.ts +93 -0
- package/src/crews/dev-spec/application/run-dev-spec.ts +237 -0
- package/src/crews/dev-spec/application/spec-material.ts +42 -0
- package/src/crews/dev-spec/crew.ork.ts +110 -0
- package/src/crews/dev-spec/domain/markers.ts +30 -0
- package/src/crews/dev-spec/domain/messages.ts +39 -0
- package/src/crews/dev-spec/domain/spec-answer.ts +252 -0
- package/src/crews/dev-spec/domain/spec-render.ts +76 -0
- package/src/crews/dev-verify/application/audit-brief.ts +187 -0
- package/src/crews/dev-verify/application/audit.ts +267 -0
- package/src/crews/dev-verify/application/capture.ts +311 -0
- package/src/crews/dev-verify/application/messages.ts +119 -0
- package/src/crews/dev-verify/application/prompts.ts +209 -0
- package/src/crews/dev-verify/application/run-dev-verify.ts +423 -0
- package/src/crews/dev-verify/application/run-gate.ts +204 -0
- package/src/crews/dev-verify/crew.ork.ts +103 -0
- package/src/crews/dev-verify/domain/audit-answer.ts +154 -0
- package/src/crews/dev-verify/domain/auditor-charter.ts +21 -0
- package/src/crews/dev-verify/domain/capture-sections.ts +138 -0
- package/src/crews/dev-verify/domain/commands.ts +103 -0
- package/src/crews/dev-verify/domain/gate.ts +131 -0
- package/src/crews/dev-verify/domain/markers.ts +16 -0
- package/src/crews/dev-verify/domain/mechanical-table.ts +156 -0
- package/src/crews/dev-verify/domain/messages.ts +92 -0
- package/src/crews/dev-verify/domain/runtime-cut.ts +13 -0
- package/src/crews/dev-verify/domain/sheet-facts.ts +4 -0
- package/src/crews/dev-verify/domain/text.ts +20 -0
- package/src/crews/dev-verify/domain/verdict.ts +127 -0
- package/src/crews/git-commit/application/draft.ts +133 -0
- package/src/crews/git-commit/application/messages.ts +15 -0
- package/src/crews/git-commit/application/prompts.ts +47 -0
- package/src/crews/git-commit/application/run-git-commit.ts +117 -0
- package/src/crews/git-commit/crew.ork.ts +53 -0
- package/src/crews/git-commit/domain/commit.ts +200 -0
- package/src/crews/git-commit/domain/markers.ts +4 -0
- package/src/crews/git-commit/domain/messages.ts +48 -0
- package/src/crews/init-verifiers/application/authoring.ts +90 -0
- package/src/crews/init-verifiers/application/messages.ts +13 -0
- package/src/crews/init-verifiers/application/prompts.ts +107 -0
- package/src/crews/init-verifiers/application/run-init-verifiers.ts +26 -0
- package/src/crews/init-verifiers/crew.ork.ts +35 -0
- package/src/crews/init-verifiers/domain/commands-section.ts +36 -0
- package/src/crews/init-verifiers/domain/readiness.ts +23 -0
- package/src/crews/main-loop/application/auto-compact.ts +78 -0
- package/src/crews/main-loop/application/context-gather.ts +133 -0
- package/src/crews/main-loop/application/messages.ts +81 -0
- package/src/crews/main-loop/application/prompts.ts +12 -0
- package/src/crews/main-loop/application/run-main-loop.ts +383 -0
- package/src/crews/main-loop/application/turn-context.ts +111 -0
- package/src/crews/main-loop/crew.ork.ts +124 -0
- package/src/crews/main-loop/domain/autocompact.ts +27 -0
- package/src/crews/main-loop/domain/prompt-assembly.ts +338 -0
- package/src/crews/main-loop/domain/prompts.ts +336 -0
- package/src/crews/main-loop/domain/turn-chains.ts +130 -0
- package/src/crews/project-init/application/detect.ts +123 -0
- package/src/crews/project-init/application/messages.ts +15 -0
- package/src/crews/project-init/application/prompts.ts +105 -0
- package/src/crews/project-init/application/run-project-init.ts +31 -0
- package/src/crews/project-init/crew.ork.ts +36 -0
- package/src/crews/project-init/domain/conventions.ts +36 -0
- package/src/crews/project-init/domain/existing-files.ts +65 -0
- package/src/crews/project-init/domain/messages.ts +13 -0
- package/src/crews/project-init/domain/package-map.ts +73 -0
- package/src/crews/project-init/domain/prompts.ts +10 -0
- package/src/crews/session-compact/application/prompts.ts +5 -0
- package/src/crews/session-compact/crew.ork.ts +56 -0
- package/src/crews/shared-memory-admit/application/prompts.ts +5 -0
- package/src/crews/shared-memory-admit/crew.ork.ts +49 -0
- package/src/crews/speech/application/messages.ts +3 -0
- package/src/crews/speech/application/prompts.ts +3 -0
- package/src/crews/speech/application/run-speech.ts +26 -0
- package/src/crews/speech/crew.ork.ts +38 -0
- package/src/shared/application/agents/child-agent.ts +259 -0
- package/src/shared/application/agents/messages.ts +35 -0
- package/src/shared/application/agents/route-agent.ts +115 -0
- package/src/shared/application/agents/run-sub-agent.ts +119 -0
- package/src/shared/application/answer-language.ts +14 -0
- package/src/shared/application/attached-skills.ts +36 -0
- package/src/shared/application/compaction/compact-session.ts +242 -0
- package/src/shared/application/compaction/extract-memories.ts +38 -0
- package/src/shared/application/compaction/messages.ts +20 -0
- package/src/shared/application/compaction/prune-context.ts +94 -0
- package/src/shared/application/compaction/pruned-llm.ts +35 -0
- package/src/shared/application/compaction/restore-context.ts +78 -0
- package/src/shared/application/config-store.ts +123 -0
- package/src/shared/application/dev/brief-inventory.ts +115 -0
- package/src/shared/application/dev/close-batch.ts +85 -0
- package/src/shared/application/dev/find-repo-pack.ts +78 -0
- package/src/shared/application/dev/learn-decision.ts +254 -0
- package/src/shared/application/dev/load-dev-context.ts +265 -0
- package/src/shared/application/dev/measure-access-cost.ts +69 -0
- package/src/shared/application/dev/messages.ts +132 -0
- package/src/shared/application/dev/phase-timer.ts +54 -0
- package/src/shared/application/dev/plan-source.ts +116 -0
- package/src/shared/application/dev/preflight.ts +71 -0
- package/src/shared/application/dev/project-files.ts +17 -0
- package/src/shared/application/dev/prompts.ts +34 -0
- package/src/shared/application/dev/question-round.ts +60 -0
- package/src/shared/application/dev/resolve-work-folder.ts +134 -0
- package/src/shared/application/dev/script-tool-slot.ts +27 -0
- package/src/shared/application/dev/settle-questions.ts +57 -0
- package/src/shared/application/dev/source-review.ts +67 -0
- package/src/shared/application/dev/source-step.ts +152 -0
- package/src/shared/application/dev/spend.ts +55 -0
- package/src/shared/application/dev/step-precedents.ts +90 -0
- package/src/shared/application/dev/tool-call-policy.ts +87 -0
- package/src/shared/application/dev/tool-callbacks.ts +262 -0
- package/src/shared/application/dev/tool-trace-recorder.ts +46 -0
- package/src/shared/application/dev/verdict-sources.ts +50 -0
- package/src/shared/application/dev/wrapped-tools.ts +147 -0
- package/src/shared/application/extra-tools.ts +71 -0
- package/src/shared/application/git/batch-worktree.ts +102 -0
- package/src/shared/application/git/commit-files.ts +191 -0
- package/src/shared/application/git/merge-batch.ts +67 -0
- package/src/shared/application/git/messages.ts +75 -0
- package/src/shared/application/git/open-pull-request.ts +52 -0
- package/src/shared/application/host-context.ts +59 -0
- package/src/shared/application/host-layout-store.ts +45 -0
- package/src/shared/application/instructions-file.ts +19 -0
- package/src/shared/application/json-file.ts +34 -0
- package/src/shared/application/llm-profile.ts +36 -0
- package/src/shared/application/messages.ts +14 -0
- package/src/shared/application/permission-rules.ts +169 -0
- package/src/shared/application/ports/approvals.ts +20 -0
- package/src/shared/application/ports/clock.ts +5 -0
- package/src/shared/application/ports/code-index.ts +93 -0
- package/src/shared/application/ports/crew.ts +60 -0
- package/src/shared/application/ports/decision.ts +14 -0
- package/src/shared/application/ports/files.ts +21 -0
- package/src/shared/application/ports/human.ts +38 -0
- package/src/shared/application/ports/llm.ts +83 -0
- package/src/shared/application/ports/memory.ts +30 -0
- package/src/shared/application/ports/progress.ts +23 -0
- package/src/shared/application/ports/runtime.ts +15 -0
- package/src/shared/application/ports/session.ts +74 -0
- package/src/shared/application/ports/shared-memory.ts +26 -0
- package/src/shared/application/ports/shell.ts +40 -0
- package/src/shared/application/ports/telemetry.ts +45 -0
- package/src/shared/application/ports/theme.ts +11 -0
- package/src/shared/application/ports/tools.ts +46 -0
- package/src/shared/application/ports/usage.ts +45 -0
- package/src/shared/application/ports.ts +29 -0
- package/src/shared/application/project-manifests.ts +106 -0
- package/src/shared/application/session-io.ts +85 -0
- package/src/shared/application/session-state.ts +36 -0
- package/src/shared/application/shared-memory/admit-entries.ts +179 -0
- package/src/shared/application/shared-memory/harvest-after-gaps.ts +69 -0
- package/src/shared/application/shared-memory/harvest-mistakes.ts +45 -0
- package/src/shared/application/shared-memory/import-agent-memory.ts +119 -0
- package/src/shared/application/shared-memory/memory-files.ts +111 -0
- package/src/shared/application/shared-memory/memory-settings.ts +94 -0
- package/src/shared/application/shared-memory/messages.ts +63 -0
- package/src/shared/application/shared-memory/push-candidate.ts +149 -0
- package/src/shared/application/shared-memory/recall-precedents.ts +70 -0
- package/src/shared/application/skills/messages.ts +4 -0
- package/src/shared/application/skills/suggest-skills.ts +102 -0
- package/src/shared/application/state-snapshot.ts +38 -0
- package/src/shared/application/workflow/messages.ts +8 -0
- package/src/shared/application/workflow/workflow-state.ts +136 -0
- package/src/shared/domain/agent-policy/behavior-flags.ts +162 -0
- package/src/shared/domain/agent-policy/extra-tools.ts +67 -0
- package/src/shared/domain/agent-policy/memory-categories.ts +6 -0
- package/src/shared/domain/agent-policy/messages.ts +66 -0
- package/src/shared/domain/agent-policy/mode-policy.ts +51 -0
- package/src/shared/domain/agent-policy/output-styles.ts +11 -0
- package/src/shared/domain/agent-policy/path-rules.ts +299 -0
- package/src/shared/domain/agent-policy/permission.ts +625 -0
- package/src/shared/domain/agent-policy/prompts.ts +17 -0
- package/src/shared/domain/agent-policy/reasoning.ts +59 -0
- package/src/shared/domain/agent-policy/rule-sets.ts +416 -0
- package/src/shared/domain/agent-policy/tool-access.ts +91 -0
- package/src/shared/domain/agent-registry.ts +143 -0
- package/src/shared/domain/agents/built-in-charters.ts +43 -0
- package/src/shared/domain/agents/chain.ts +30 -0
- package/src/shared/domain/agents/charter.ts +64 -0
- package/src/shared/domain/agents/exclusive.ts +25 -0
- package/src/shared/domain/agents/instances.ts +252 -0
- package/src/shared/domain/agents/messages.ts +39 -0
- package/src/shared/domain/agents/model-route.ts +199 -0
- package/src/shared/domain/agents/prompts.ts +20 -0
- package/src/shared/domain/code-intel-contract.ts +357 -0
- package/src/shared/domain/code-intel-routing.ts +60 -0
- package/src/shared/domain/compact-outcome.ts +46 -0
- package/src/shared/domain/compaction-thresholds.ts +162 -0
- package/src/shared/domain/compaction.ts +288 -0
- package/src/shared/domain/config-schema.ts +434 -0
- package/src/shared/domain/context-prune.ts +176 -0
- package/src/shared/domain/decision/questions.ts +102 -0
- package/src/shared/domain/dev/access-cost.ts +230 -0
- package/src/shared/domain/dev/artefacts.ts +50 -0
- package/src/shared/domain/dev/batches-concurrency.ts +35 -0
- package/src/shared/domain/dev/batches-state.ts +49 -0
- package/src/shared/domain/dev/build-commands.ts +45 -0
- package/src/shared/domain/dev/call-guard.ts +342 -0
- package/src/shared/domain/dev/carried-text.ts +47 -0
- package/src/shared/domain/dev/design-rules.ts +100 -0
- package/src/shared/domain/dev/learn-proposals.ts +176 -0
- package/src/shared/domain/dev/learn-state.ts +94 -0
- package/src/shared/domain/dev/markers.ts +107 -0
- package/src/shared/domain/dev/messages.ts +259 -0
- package/src/shared/domain/dev/path-args.ts +42 -0
- package/src/shared/domain/dev/path-rebase.ts +93 -0
- package/src/shared/domain/dev/phase-timing.ts +50 -0
- package/src/shared/domain/dev/plan-checks.ts +191 -0
- package/src/shared/domain/dev/plan-format.ts +170 -0
- package/src/shared/domain/dev/project-files.ts +29 -0
- package/src/shared/domain/dev/prompts/brief-blocks.ts +20 -0
- package/src/shared/domain/dev/prompts.ts +251 -0
- package/src/shared/domain/dev/questions.ts +267 -0
- package/src/shared/domain/dev/reading-rule.ts +41 -0
- package/src/shared/domain/dev/repo-pack.ts +240 -0
- package/src/shared/domain/dev/review-answer.ts +173 -0
- package/src/shared/domain/dev/review-brief.ts +54 -0
- package/src/shared/domain/dev/reviewer-charter.ts +35 -0
- package/src/shared/domain/dev/sheet-facts.ts +81 -0
- package/src/shared/domain/dev/spec-format.ts +182 -0
- package/src/shared/domain/dev/step-budget.ts +74 -0
- package/src/shared/domain/dev/step-rules.ts +109 -0
- package/src/shared/domain/dev/test-commands.ts +94 -0
- package/src/shared/domain/dev/test-output.ts +33 -0
- package/src/shared/domain/dev/test-paths.ts +40 -0
- package/src/shared/domain/dev/tool-guards.ts +65 -0
- package/src/shared/domain/dev/trait-pattern.ts +87 -0
- package/src/shared/domain/dev/verdict-format.ts +162 -0
- package/src/shared/domain/dev/whitespace.ts +35 -0
- package/src/shared/domain/dev/work-folder.ts +68 -0
- package/src/shared/domain/dev/yaml-subset.ts +385 -0
- package/src/shared/domain/error-text.ts +13 -0
- package/src/shared/domain/git/close.ts +274 -0
- package/src/shared/domain/git/messages.ts +20 -0
- package/src/shared/domain/git/pull-request.ts +96 -0
- package/src/shared/domain/git/worktree.ts +46 -0
- package/src/shared/domain/host-layout.ts +147 -0
- package/src/shared/domain/host-paths.ts +399 -0
- package/src/shared/domain/index-languages.ts +16 -0
- package/src/shared/domain/instructions-file.ts +18 -0
- package/src/shared/domain/iso-day.ts +4 -0
- package/src/shared/domain/llm-failure.ts +134 -0
- package/src/shared/domain/llm-profile.ts +44 -0
- package/src/shared/domain/marked-message.ts +29 -0
- package/src/shared/domain/markers.ts +30 -0
- package/src/shared/domain/messages.ts +291 -0
- package/src/shared/domain/model-catalog.ts +79 -0
- package/src/shared/domain/permission-modes.ts +99 -0
- package/src/shared/domain/prelude.ts +92 -0
- package/src/shared/domain/project-manifests.ts +84 -0
- package/src/shared/domain/prompts.ts +233 -0
- package/src/shared/domain/search-routing.ts +77 -0
- package/src/shared/domain/secret-patterns.ts +46 -0
- package/src/shared/domain/session-keys.ts +92 -0
- package/src/shared/domain/session-start.ts +61 -0
- package/src/shared/domain/severity.ts +72 -0
- package/src/shared/domain/sha1.ts +61 -0
- package/src/shared/domain/shared-memory/agent-memory-import.ts +145 -0
- package/src/shared/domain/shared-memory/candidates.ts +40 -0
- package/src/shared/domain/shared-memory/entry.ts +151 -0
- package/src/shared/domain/shared-memory/front-matter.ts +187 -0
- package/src/shared/domain/shared-memory/gate.ts +45 -0
- package/src/shared/domain/shared-memory/harvest.ts +64 -0
- package/src/shared/domain/shared-memory/layout.ts +190 -0
- package/src/shared/domain/shared-memory/markers.ts +9 -0
- package/src/shared/domain/shared-memory/messages.ts +66 -0
- package/src/shared/domain/shared-memory/precedents-block.ts +82 -0
- package/src/shared/domain/shared-memory/prompts.ts +28 -0
- package/src/shared/domain/shared-memory/refused.ts +84 -0
- package/src/shared/domain/shared-memory/verdict-rows.ts +134 -0
- package/src/shared/domain/skills/prompts.ts +4 -0
- package/src/shared/domain/skills/shortlist.ts +149 -0
- package/src/shared/domain/snip-turns.ts +33 -0
- package/src/shared/domain/speech.ts +21 -0
- package/src/shared/domain/strip.ts +88 -0
- package/src/shared/domain/tool-trace.ts +120 -0
- package/src/shared/domain/types.ts +67 -0
- package/src/shared/domain/verifiers.ts +33 -0
- package/src/shared/domain/vfs.ts +16 -0
- package/src/shared/domain/workflow/prompts.ts +15 -0
- package/src/shared/domain/workflow/state-file.ts +142 -0
- package/src/shared/infrastructure/globals.ts +57 -0
- package/src/shared/infrastructure/orkeon/approvals.ts +24 -0
- package/src/shared/infrastructure/orkeon/child-agents.ts +122 -0
- package/src/shared/infrastructure/orkeon/chooser.ts +32 -0
- package/src/shared/infrastructure/orkeon/code-index.ts +120 -0
- package/src/shared/infrastructure/orkeon/crew-host.ts +27 -0
- package/src/shared/infrastructure/orkeon/crew-memory.ts +12 -0
- package/src/shared/infrastructure/orkeon/decision-model.ts +31 -0
- package/src/shared/infrastructure/orkeon/dev-deps.ts +179 -0
- package/src/shared/infrastructure/orkeon/files.ts +58 -0
- package/src/shared/infrastructure/orkeon/github-pull-requests.ts +30 -0
- package/src/shared/infrastructure/orkeon/host-context.ts +36 -0
- package/src/shared/infrastructure/orkeon/host-provider.ts +22 -0
- package/src/shared/infrastructure/orkeon/human-input.ts +55 -0
- package/src/shared/infrastructure/orkeon/llm-profile.ts +58 -0
- package/src/shared/infrastructure/orkeon/llm.ts +164 -0
- package/src/shared/infrastructure/orkeon/markers.ts +6 -0
- package/src/shared/infrastructure/orkeon/memory-store.ts +41 -0
- package/src/shared/infrastructure/orkeon/memory-tools.ts +129 -0
- package/src/shared/infrastructure/orkeon/messages.ts +15 -0
- package/src/shared/infrastructure/orkeon/permission-rules.ts +42 -0
- package/src/shared/infrastructure/orkeon/progress.ts +24 -0
- package/src/shared/infrastructure/orkeon/prompts.ts +47 -0
- package/src/shared/infrastructure/orkeon/reasoning.ts +40 -0
- package/src/shared/infrastructure/orkeon/run-state.ts +17 -0
- package/src/shared/infrastructure/orkeon/runtime-info.ts +30 -0
- package/src/shared/infrastructure/orkeon/runtime-tools.ts +60 -0
- package/src/shared/infrastructure/orkeon/script-tools.ts +129 -0
- package/src/shared/infrastructure/orkeon/session-store.ts +94 -0
- package/src/shared/infrastructure/orkeon/session-switch.ts +23 -0
- package/src/shared/infrastructure/orkeon/shared-memory.ts +61 -0
- package/src/shared/infrastructure/orkeon/shell-jobs.ts +81 -0
- package/src/shared/infrastructure/orkeon/shell.ts +39 -0
- package/src/shared/infrastructure/orkeon/telemetry.ts +63 -0
- package/src/shared/infrastructure/orkeon/tool-catalogue.ts +76 -0
- package/src/shared/infrastructure/orkeon/tool-results.ts +120 -0
- package/src/shared/infrastructure/orkeon/usage.ts +74 -0
- package/src/shared/infrastructure/orkeon/wiring.ts +174 -0
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
// /doctor — health check: runtime, LLM reachability, tools, mounts
|
|
2
|
+
// (baseline 04 §/doctor: "validate the runtime environment, configuration
|
|
3
|
+
// integrity, API connectivity, and tool availability; emit a per-check
|
|
4
|
+
// pass/fail report").
|
|
5
|
+
//
|
|
6
|
+
// B-11 deepening. The pre-B-11 version probed three binary versions
|
|
7
|
+
// (node/git/dotnet) and stopped, so the four checks the baseline asks for were one:
|
|
8
|
+
// nothing looked at the LLM configuration, the tool catalogue or the VFS mounts.
|
|
9
|
+
//
|
|
10
|
+
// Today's debugging round is the argument for this: a REPL booted with no `Llm`
|
|
11
|
+
// section answered every turn with silence, and /doctor — the command whose entire
|
|
12
|
+
// job is to say "this host is not going to work" — reported three green rows.
|
|
13
|
+
//
|
|
14
|
+
// What "LLM" can honestly check from script-land: whether the host reports a model
|
|
15
|
+
// at all. Reachability would need a real call, i.e. money and a wait, so the check
|
|
16
|
+
// says what it verified and what it did not rather than implying a ping.
|
|
17
|
+
|
|
18
|
+
import type {
|
|
19
|
+
Files, RuntimeInfo, RuntimeInfoReader, SessionMetadata, Shell, Telemetry, ToolCatalogue,
|
|
20
|
+
} from "../../../shared/application/ports.ts";
|
|
21
|
+
import type { ConfigStore } from "../../../shared/application/config-store.ts";
|
|
22
|
+
import { CODE_INTEL_TOOLS } from "../../../shared/domain/code-intel-contract.ts";
|
|
23
|
+
import { knownConfigKeys } from "../../../shared/domain/config-schema.ts";
|
|
24
|
+
import { readHostContext } from "../../../shared/application/host-context.ts";
|
|
25
|
+
import { describeHostLayout } from "../../../shared/domain/host-layout.ts";
|
|
26
|
+
import { listedEntries } from "../../../shared/domain/agent-policy/path-rules.ts";
|
|
27
|
+
import { CLI_BUILD, CLI_NAME, CLI_VERSION, isPinnedCommit } from "./meta.ts";
|
|
28
|
+
import type { CommandView } from "../view.ts";
|
|
29
|
+
import { WORKSPACE } from "../../../shared/domain/vfs.ts";
|
|
30
|
+
import {
|
|
31
|
+
ALL_CHECKS_PASSED, CHECK_CODE_INTEL, CHECK_LLM_CATALOGUE, CHECK_LLM_MODEL, CHECK_PROJECT_FILE, CHECK_SESSIONS,
|
|
32
|
+
NO_AVAILABLE_MODELS, NO_MODEL, NO_PATH_LIST, checksFailed, checksPassedWarned, codeIntelAbsent, essentialsPresent,
|
|
33
|
+
modelNotPinged, oldSessionsLeft, projectSettingIgnored, versionNoRuntime, versionNotPinned, versionPinned,
|
|
34
|
+
workspaceNotWritable,
|
|
35
|
+
} from "./messages.ts";
|
|
36
|
+
|
|
37
|
+
/** Tools the coding agent cannot work without — absence is a FAIL, not a note. */
|
|
38
|
+
export const ESSENTIAL_TOOLS = ["file_read", "file_write", "shell_command", "directory_read", "session_store"];
|
|
39
|
+
|
|
40
|
+
/** Where the runtime kept the sessions before the launcher mounted them outside the project. */
|
|
41
|
+
export const OLD_SESSIONS_DIR = `${WORKSPACE}/.orkeon/sessions`;
|
|
42
|
+
|
|
43
|
+
export type DoctorRow = { check: string; result: string; detail: string };
|
|
44
|
+
export const PASS = "✅";
|
|
45
|
+
export const WARN = "⚠";
|
|
46
|
+
export const FAIL = "❌";
|
|
47
|
+
|
|
48
|
+
export interface DoctorDeps {
|
|
49
|
+
shell: Shell;
|
|
50
|
+
telemetry: Pick<Telemetry, "readMetadata">;
|
|
51
|
+
catalogue: Pick<ToolCatalogue, "names">;
|
|
52
|
+
/** The mounts, the old sessions folder, and launch.json (the host's layout). */
|
|
53
|
+
files: Pick<Files, "mounts" | "list" | "read">;
|
|
54
|
+
/** What the project file could not widen, and the two settings files' path lists. */
|
|
55
|
+
config: Pick<ConfigStore, "readValue" | "readFile" | "readUserFile">;
|
|
56
|
+
/** The running runtime's reader (Orkeon #225); absent, or answering nothing: the version row names the pin alone. */
|
|
57
|
+
runtime?: RuntimeInfoReader;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Code's own version, the version row starts with. */
|
|
61
|
+
export const CODE_VERSION_DETAIL = `${CLI_NAME} ${CLI_VERSION} (${CLI_BUILD})`;
|
|
62
|
+
|
|
63
|
+
/** The version row: Code's own, then the running Orkeon, by the commit its build carries, against the commit
|
|
64
|
+
* pinned by .orkeon-version: a pass when they are the same, a warning when they differ or the runtime reports no
|
|
65
|
+
* commit; when the host names no runtime, the pin alone and where the launcher says what it found. */
|
|
66
|
+
export function versionRow(runtime: RuntimeInfo | undefined): DoctorRow {
|
|
67
|
+
if (runtime === undefined) {
|
|
68
|
+
return {
|
|
69
|
+
check: "version",
|
|
70
|
+
result: PASS,
|
|
71
|
+
detail: versionNoRuntime(CODE_VERSION_DETAIL),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
const found = `Orkeon ${runtime.version}${runtime.commit ? `+${runtime.commit}` : ""} (${runtime.channel})`;
|
|
75
|
+
return isPinnedCommit(runtime.commit)
|
|
76
|
+
? { check: "version", result: PASS, detail: versionPinned(CODE_VERSION_DETAIL, found) }
|
|
77
|
+
: {
|
|
78
|
+
check: "version",
|
|
79
|
+
result: WARN,
|
|
80
|
+
detail: versionNotPinned(CODE_VERSION_DETAIL, found),
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Every check, one row each, and the verdict over them. */
|
|
85
|
+
export async function runDoctor(deps: DoctorDeps): Promise<CommandView> {
|
|
86
|
+
const { shell, telemetry, catalogue, files } = deps;
|
|
87
|
+
const rows: DoctorRow[] = [versionRow(deps.runtime?.read())];
|
|
88
|
+
|
|
89
|
+
// 1. Toolchain (unchanged in intent, now one row per binary with the version).
|
|
90
|
+
for (const p of [
|
|
91
|
+
{ tool: "node", cmd: "node --version" },
|
|
92
|
+
{ tool: "git", cmd: "git --version" },
|
|
93
|
+
{ tool: "dotnet", cmd: "dotnet --version" },
|
|
94
|
+
]) {
|
|
95
|
+
try {
|
|
96
|
+
const r = await shell.run(p.cmd);
|
|
97
|
+
const ok = r.exitCode === 0;
|
|
98
|
+
rows.push({ check: `toolchain: ${p.tool}`, result: ok ? PASS : FAIL, detail: r.stdout.trim() || "(no output)" });
|
|
99
|
+
} catch (e: any) {
|
|
100
|
+
rows.push({ check: `toolchain: ${p.tool}`, result: FAIL, detail: String(e?.message ?? e).split("\n")[0] });
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// 2. LLM configuration — the check that was missing when it was needed.
|
|
105
|
+
const md = await telemetry.readMetadata().catch((): SessionMetadata => ({}));
|
|
106
|
+
const model = (md.model ?? "").trim();
|
|
107
|
+
const declared = md.availableModels ?? [];
|
|
108
|
+
rows.push({
|
|
109
|
+
check: CHECK_LLM_MODEL,
|
|
110
|
+
result: model ? PASS : FAIL,
|
|
111
|
+
detail: model ? modelNotPinged(model) : NO_MODEL,
|
|
112
|
+
});
|
|
113
|
+
rows.push({
|
|
114
|
+
check: CHECK_LLM_CATALOGUE,
|
|
115
|
+
result: declared.length > 0 ? PASS : WARN,
|
|
116
|
+
detail: declared.length > 0 ? declared.join(", ") : NO_AVAILABLE_MODELS,
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
// 3. Tool catalogue.
|
|
120
|
+
const available = new Set(catalogue.names());
|
|
121
|
+
const missingEssential = ESSENTIAL_TOOLS.filter((t) => !available.has(t));
|
|
122
|
+
rows.push({
|
|
123
|
+
check: "tools: essential",
|
|
124
|
+
result: missingEssential.length === 0 ? PASS : FAIL,
|
|
125
|
+
detail: missingEssential.length === 0
|
|
126
|
+
? essentialsPresent(available.size, ESSENTIAL_TOOLS.length)
|
|
127
|
+
: `MISSING: ${missingEssential.join(", ")}`,
|
|
128
|
+
});
|
|
129
|
+
const missingIntel = CODE_INTEL_TOOLS.filter((t) => !available.has(t));
|
|
130
|
+
rows.push({
|
|
131
|
+
check: CHECK_CODE_INTEL,
|
|
132
|
+
result: missingIntel.length === 0 ? PASS : WARN,
|
|
133
|
+
detail: missingIntel.length === 0
|
|
134
|
+
? `all ${CODE_INTEL_TOOLS.length} present`
|
|
135
|
+
: codeIntelAbsent(missingIntel),
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
// 4. VFS mounts — /workspace read-write is the precondition for everything.
|
|
139
|
+
try {
|
|
140
|
+
const list = await files.mounts();
|
|
141
|
+
const described = list.map((m) => `${m.path}(${m.rights ?? "?"})`);
|
|
142
|
+
const workspace = list.find((m) => m.path === WORKSPACE);
|
|
143
|
+
const hasWorkspace = workspace !== undefined
|
|
144
|
+
&& (workspace.rights === "rw" || workspace.rights === "rwnd");
|
|
145
|
+
rows.push({
|
|
146
|
+
check: "vfs: mounts",
|
|
147
|
+
result: hasWorkspace ? PASS : FAIL,
|
|
148
|
+
// /workspace read-WRITE is the precondition for everything the agent does;
|
|
149
|
+
// a read-only mount would fail every edit with a permissions error later.
|
|
150
|
+
detail: (described.join(" ") || "(none)") +
|
|
151
|
+
(hasWorkspace ? "" : workspaceNotWritable(WORKSPACE)),
|
|
152
|
+
});
|
|
153
|
+
} catch (e: any) {
|
|
154
|
+
rows.push({ check: "vfs: mounts", result: WARN, detail: `list_mounts unavailable: ${String(e?.message ?? e).split("\n")[0]}` });
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// 4b. The host the launcher described (launch.json) and the user's path lists, as every act's callbacks read them:
|
|
158
|
+
// the layout with each mount's base, the lists, and every entry or file they could not read.
|
|
159
|
+
const host = await readHostContext(files, deps.config);
|
|
160
|
+
const lists = [
|
|
161
|
+
...(host.lists.deny.length > 0 ? [`deny: ${listedEntries(host.lists.deny).join(", ")}`] : []),
|
|
162
|
+
...(host.lists.allow.length > 0 ? [`allow: ${listedEntries(host.lists.allow).join(", ")}`] : []),
|
|
163
|
+
];
|
|
164
|
+
rows.push({
|
|
165
|
+
check: "host: paths",
|
|
166
|
+
result: host.problems.length === 0 ? PASS : WARN,
|
|
167
|
+
detail: [
|
|
168
|
+
describeHostLayout(host.layout), ...(lists.length > 0 ? lists : [NO_PATH_LIST]), ...host.problems.map((p) => `⚠ ${p}`),
|
|
169
|
+
].join("; "),
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
// 5. Sessions left in the project: the runtime kept them in /workspace/.orkeon/sessions
|
|
173
|
+
// before the launcher mounted /sessions outside the project (QL-04). Left alone, named here.
|
|
174
|
+
const inProject = await files.list(OLD_SESSIONS_DIR, 1).catch((): string[] => []);
|
|
175
|
+
rows.push({
|
|
176
|
+
check: CHECK_SESSIONS,
|
|
177
|
+
result: inProject.length === 0 ? PASS : WARN,
|
|
178
|
+
detail: inProject.length === 0
|
|
179
|
+
? "nothing in .orkeon/sessions"
|
|
180
|
+
: oldSessionsLeft(OLD_SESSIONS_DIR),
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
// 6. What the project file set and could not widen (QL-06): said here as /permissions says it.
|
|
184
|
+
const ignored: string[] = [];
|
|
185
|
+
for (const key of knownConfigKeys()) {
|
|
186
|
+
const r = await deps.config.readValue(key).catch(() => undefined);
|
|
187
|
+
if (r?.ignored !== undefined) ignored.push(projectSettingIgnored(key, r.ignored.value, r.ignored.reason));
|
|
188
|
+
}
|
|
189
|
+
rows.push({
|
|
190
|
+
check: CHECK_PROJECT_FILE,
|
|
191
|
+
result: ignored.length === 0 ? PASS : WARN,
|
|
192
|
+
detail: ignored.length === 0 ? "widens nothing" : ignored.join("; "),
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
const failed = rows.filter((r) => r.result === FAIL).length;
|
|
196
|
+
const warned = rows.filter((r) => r.result === WARN).length;
|
|
197
|
+
return {
|
|
198
|
+
table: rows,
|
|
199
|
+
text: failed > 0
|
|
200
|
+
? checksFailed(failed, warned)
|
|
201
|
+
: warned > 0
|
|
202
|
+
? checksPassedWarned(warned)
|
|
203
|
+
: ALL_CHECKS_PASSED,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// The text the status commands show the user (ADR 0026): the rows of /doctor and /status, the /usage legend and
|
|
2
|
+
// breakdown, the release notes.
|
|
3
|
+
import { CLI_BUILD, CLI_NAME, CLI_VERSION, ORKEON_RUNTIME_PIN } from "./meta.ts";
|
|
4
|
+
|
|
5
|
+
// /doctor
|
|
6
|
+
|
|
7
|
+
export const versionNoRuntime = (code: string): string =>
|
|
8
|
+
`${code}; Orkeon expected at commit ${ORKEON_RUNTIME_PIN} (.orkeon-version), the host names no runtime: ` +
|
|
9
|
+
"orkeon-code --version in a terminal says the one found";
|
|
10
|
+
export const versionPinned = (code: string, found: string): string => `${code}; ${found}, the pin of .orkeon-version`;
|
|
11
|
+
export const versionNotPinned = (code: string, found: string): string =>
|
|
12
|
+
`${code}; ${found} runs, commit ${ORKEON_RUNTIME_PIN} expected (.orkeon-version): ` +
|
|
13
|
+
"the commands were checked against the pin";
|
|
14
|
+
export const CHECK_LLM_MODEL = "llm: model configured";
|
|
15
|
+
export const modelNotPinged = (model: string): string => `${model} (not pinged — a reachability test costs a real call)`;
|
|
16
|
+
export const NO_MODEL =
|
|
17
|
+
"the host reports NO model: expect every /assistant turn to no-op. Check the `Llm` section of the settings file.";
|
|
18
|
+
export const CHECK_LLM_CATALOGUE = "llm: declared catalogue";
|
|
19
|
+
export const NO_AVAILABLE_MODELS = "no Llm:AvailableModels — /model cannot offer a choice or flag an unserved name";
|
|
20
|
+
export const essentialsPresent = (registered: number, essentials: number): string =>
|
|
21
|
+
`${registered} registered, all ${essentials} essentials present`;
|
|
22
|
+
export const CHECK_CODE_INTEL = "tools: code intelligence";
|
|
23
|
+
export const codeIntelAbsent = (tools: readonly string[]): string =>
|
|
24
|
+
`absent: ${tools.join(", ")} — the agent falls back to reading files`;
|
|
25
|
+
export const workspaceNotWritable = (workspace: string): string => ` ← ${workspace} is missing or not writable`;
|
|
26
|
+
export const NO_PATH_LIST = "no path list";
|
|
27
|
+
export const CHECK_SESSIONS = "sessions: outside the project";
|
|
28
|
+
export const oldSessionsLeft = (dir: string): string =>
|
|
29
|
+
`${dir} holds sessions of an older start, left alone: sessions now live in the launcher's state folder, outside the project ` +
|
|
30
|
+
"(orkeon-code --resume lists them); delete the folder once you no longer need it";
|
|
31
|
+
export const projectSettingIgnored = (key: string, value: string, reason: string): string =>
|
|
32
|
+
`the project file sets ${key} '${value}': ignored, ${reason}`;
|
|
33
|
+
export const CHECK_PROJECT_FILE = "settings: project file";
|
|
34
|
+
export const checksFailed = (failed: number, warned: number): string =>
|
|
35
|
+
`${failed} check(s) FAILED, ${warned} warning(s) — the host is not fully usable.`;
|
|
36
|
+
export const checksPassedWarned = (warned: number): string => `all checks passed, ${warned} warning(s).`;
|
|
37
|
+
export const ALL_CHECKS_PASSED = "all checks passed.";
|
|
38
|
+
|
|
39
|
+
// /status
|
|
40
|
+
|
|
41
|
+
export const RUNTIME_PIN_ONLY = `Orkeon ${ORKEON_RUNTIME_PIN} (the commit pinned by .orkeon-version)`;
|
|
42
|
+
export const runtimePinned = (found: string): string => `${found}, the pin of .orkeon-version`;
|
|
43
|
+
export const runtimeNotPinned = (found: string): string => `${found}, NOT the pin ${ORKEON_RUNTIME_PIN} of .orkeon-version`;
|
|
44
|
+
|
|
45
|
+
/** How Orkeon Code is updated: there is no self-update channel. */
|
|
46
|
+
export const UPDATE_NOTE =
|
|
47
|
+
"no self-update: update the orkeon-code checkout (git pull, or a newer release archive) and relaunch; " +
|
|
48
|
+
"the Orkeon runtime it runs on is pinned to a commit of Orkeon's main by its .orkeon-version";
|
|
49
|
+
export const MODEL_UNREPORTED = "(unreported by the host — see /model)";
|
|
50
|
+
export const hostDefaultProvider = (provider: string): string => `${provider} (the host's default)`;
|
|
51
|
+
export const UNREPORTED_BY_HOST = "(unreported by the host)";
|
|
52
|
+
|
|
53
|
+
// /usage
|
|
54
|
+
|
|
55
|
+
/** What a host without the usage service leaves the breakdown with. */
|
|
56
|
+
export const NO_USAGE_SERVICE = "usage by model and command: not reported by this host (no usage service)";
|
|
57
|
+
export const unpricedCalls = (count: number): string => `${count} call(s) unpriced: the cost is a lower bound`;
|
|
58
|
+
export const fromCache = (tokens: number): string => ` (${tokens} from the cache)`;
|
|
59
|
+
export const NO_MODEL_USAGE = "by model: none named by the provider yet";
|
|
60
|
+
export const NO_COMMAND_USAGE = "by command: no command instance yet";
|
|
61
|
+
|
|
62
|
+
/** What the row's columns count, and which are estimates: the closing text opens with it. */
|
|
63
|
+
export const USAGE_LEGEND = [
|
|
64
|
+
"usedTokens, estTokens: the conversation's size in the context window, estimated by the host.",
|
|
65
|
+
"llm*: counted by the providers over every call: llmInTokens sent, llmOutTokens received (llmReasoningTokens a part of",
|
|
66
|
+
"them), llmTokens = in + out. cacheRead and cacheWrite are parts of llmInTokens; cacheRatio = cacheRead / llmInTokens.",
|
|
67
|
+
"n/a: not reported, never a measured 0.",
|
|
68
|
+
].join("\n");
|
|
69
|
+
|
|
70
|
+
/** What a sub-verb /usage does not know answers. */
|
|
71
|
+
export const USAGE_SYNTAX = "usage: /usage, or /usage tools [text] (the tool calls of this session's turns)";
|
|
72
|
+
|
|
73
|
+
export const NO_TOOL_TRACE = "no tool call recorded in this session yet";
|
|
74
|
+
export const noToolCallHolds = (text: string): string => `no tool call holds '${text}' in this session`;
|
|
75
|
+
|
|
76
|
+
// /release-notes
|
|
77
|
+
|
|
78
|
+
export const RELEASE_NOTES = [
|
|
79
|
+
`${CLI_NAME} ${CLI_VERSION} (${CLI_BUILD})`,
|
|
80
|
+
"",
|
|
81
|
+
`Second release candidate of 1.0.0, on Orkeon 1.2.0 (main ${ORKEON_RUNTIME_PIN}).`,
|
|
82
|
+
"",
|
|
83
|
+
"Crews: main-loop (the interactive loop behind /assistant), code-review, git-commit,",
|
|
84
|
+
" project-init, init-verifiers, session-compact, advisor, analyze, speech,",
|
|
85
|
+
" dev-verify, dev-learn, dev-plan, dev-spec, dev-change, dev-implement, dev-batches,",
|
|
86
|
+
" shared-memory-admit, agent-run.",
|
|
87
|
+
"Commands: 50 slash commands; free text without a leading / goes to /assistant.",
|
|
88
|
+
"Permissions: five modes (default, acceptEdits, plan, dontAsk, bypassPermissions),",
|
|
89
|
+
" deny/allow rules (argument patterns too) enforced by the host gate,",
|
|
90
|
+
" questions before writes and commands, /mode for the session default.",
|
|
91
|
+
"Extra tools: tools.extra offers an MCP server's or a plugin's tools to the assistant.",
|
|
92
|
+
"Speech: the MCP server of mcp/whisper, /transcribe [--then], /voice (dictation), /say (read aloud).",
|
|
93
|
+
"Context: automatic compaction with a persistent breaker, snip-first /compact,",
|
|
94
|
+
" file restore after compaction, context pressure tiers.",
|
|
95
|
+
"Models: /model switches the model per turn; /model list offers Llm:AvailableModels;",
|
|
96
|
+
" /effort sets the reasoning effort among the levels the model takes.",
|
|
97
|
+
"Decision model (off by default): /route runs a crew on the cheapest profile that fits,",
|
|
98
|
+
" /skills suggest offers the skills that fit a turn, compaction.prune drops stale tool results.",
|
|
99
|
+
"Code intelligence: index, maps, dependency graph and symbol tools of the Orkeon runtime.",
|
|
100
|
+
].join("\n");
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Static CLI metadata shared by /status (version) and /release-notes. No IO.
|
|
2
|
+
//
|
|
3
|
+
// Orkeon Code versions independently of the Orkeon runtime it runs on: the
|
|
4
|
+
// runtime is pinned to a commit of Orkeon's main in .orkeon-version, this one follows
|
|
5
|
+
// package.json (tests/repository/version.test.ts keeps the two equal). The counts and crew names in
|
|
6
|
+
// RELEASE_NOTES (messages.ts) are pinned by tests/commands/_lib/status/messages.test.ts, which keeps them true.
|
|
7
|
+
|
|
8
|
+
export const CLI_NAME = "orkeon-code";
|
|
9
|
+
export const CLI_VERSION = "1.0.0-rc.2";
|
|
10
|
+
export const CLI_BUILD = "source";
|
|
11
|
+
/** The Orkeon runtime this version runs on: the commit of Orkeon's `main` pinned in .orkeon-version, which the
|
|
12
|
+
* launcher announces (tests/repository/version.test.ts keeps the two equal). A release tag is never the pin: the
|
|
13
|
+
* commands are checked against the sources at this commit (ADR 0013). /status and /doctor compare it with the
|
|
14
|
+
* commit of the runtime that runs them, read from the host's `runtime` service (Orkeon #225). */
|
|
15
|
+
export const ORKEON_RUNTIME_COMMIT = "a9f3878aca94c81d5c23fa0b858b59b8a78d5122";
|
|
16
|
+
/** The pin as the launcher and the rows print it: its first seven characters. */
|
|
17
|
+
export const ORKEON_RUNTIME_PIN = ORKEON_RUNTIME_COMMIT.slice(0, 7);
|
|
18
|
+
|
|
19
|
+
/** Whether a runtime's commit (as its build metadata carries it, short or full; null when none) is the pin: the
|
|
20
|
+
* pin, or at least seven leading characters of it. A commit with a suffix (`-dirty`: a build with local changes)
|
|
21
|
+
* is not the pin. */
|
|
22
|
+
export function isPinnedCommit(commit: string | null): boolean {
|
|
23
|
+
return commit !== null && commit.length >= 7 && ORKEON_RUNTIME_COMMIT.startsWith(commit);
|
|
24
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// /status — the session's status in one table: the model, the workspace, the
|
|
2
|
+
// context, the cost, the crews, and the version and platform that /version, /env,
|
|
3
|
+
// /session and /upgrade (its aliases now) used to show apart. runStatus reads the
|
|
4
|
+
// rows over the ports. Lives under commands/_lib/ — the loader's SearchPattern is
|
|
5
|
+
// "*.cmd.ts", so this file is never loaded as a command.
|
|
6
|
+
|
|
7
|
+
import type {
|
|
8
|
+
CrewHost, RuntimeInfo, RuntimeInfoReader, SessionCost, SessionMetadata, SessionStats, SessionStore, Shell, Telemetry,
|
|
9
|
+
} from "../../../shared/application/ports.ts";
|
|
10
|
+
import { CLI_BUILD, CLI_NAME, CLI_VERSION, isPinnedCommit } from "./meta.ts";
|
|
11
|
+
import {
|
|
12
|
+
MODEL_UNREPORTED, RUNTIME_PIN_ONLY, UNREPORTED_BY_HOST, UPDATE_NOTE, hostDefaultProvider, runtimeNotPinned,
|
|
13
|
+
runtimePinned,
|
|
14
|
+
} from "./messages.ts";
|
|
15
|
+
import type { CommandView } from "../view.ts";
|
|
16
|
+
import { WORKSPACE } from "../../../shared/domain/vfs.ts";
|
|
17
|
+
|
|
18
|
+
export interface StatusInputs {
|
|
19
|
+
model?: unknown;
|
|
20
|
+
title?: unknown;
|
|
21
|
+
messages?: unknown;
|
|
22
|
+
usedTokens?: unknown;
|
|
23
|
+
windowTokens?: unknown;
|
|
24
|
+
totalTokens?: unknown;
|
|
25
|
+
costUsd?: unknown;
|
|
26
|
+
calls?: unknown;
|
|
27
|
+
crews?: readonly string[];
|
|
28
|
+
workspace?: unknown;
|
|
29
|
+
/** OS, architecture and node version, as the shell reports them. */
|
|
30
|
+
platform?: unknown;
|
|
31
|
+
/** The host's LLM provider, as its `llm` service names it. */
|
|
32
|
+
provider?: unknown;
|
|
33
|
+
/** The runtime that runs the command, as its `runtime` service names it; absent when the host names none. */
|
|
34
|
+
runtime?: RuntimeInfo;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** The runtime row: the running Orkeon, by the commit its build carries, against the commit pinned by
|
|
38
|
+
* .orkeon-version, or the pin alone when the host names no runtime (Orkeon #225). A runtime that reports no commit
|
|
39
|
+
* is not the pin. */
|
|
40
|
+
export function runtimeRow(runtime: RuntimeInfo | undefined): string {
|
|
41
|
+
if (runtime === undefined) return RUNTIME_PIN_ONLY;
|
|
42
|
+
const found = `Orkeon ${runtime.version}${runtime.commit ? `+${runtime.commit}` : ""} (${runtime.channel})`;
|
|
43
|
+
return isPinnedCommit(runtime.commit)
|
|
44
|
+
? runtimePinned(found)
|
|
45
|
+
: runtimeNotPinned(found);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The `/status` rows.
|
|
50
|
+
*
|
|
51
|
+
* Baseline 04 §/status names four things: model, cost, workspace and crew summary.
|
|
52
|
+
* The pre-B-11 handler showed messages/tokens/cost/calls — so the two the operator
|
|
53
|
+
* most often opens `/status` to check, the model and the workspace, were the two
|
|
54
|
+
* missing. `(unreported)` rather than `?` for the model: it is an absence with a
|
|
55
|
+
* cause (see /model), not an unknown value.
|
|
56
|
+
*/
|
|
57
|
+
export function buildStatusRows(i: StatusInputs): Array<{ field: string; value: string }> {
|
|
58
|
+
const used = Number(i.usedTokens ?? 0) || 0;
|
|
59
|
+
const window = Number(i.windowTokens ?? 0) || 0;
|
|
60
|
+
const pct = window > 0 ? ` (${Math.round((used / window) * 100)}% of ${window})` : "";
|
|
61
|
+
const cost = Number(i.costUsd ?? 0) || 0;
|
|
62
|
+
|
|
63
|
+
return [
|
|
64
|
+
{ field: "model", value: String(i.model ?? "").trim() || MODEL_UNREPORTED },
|
|
65
|
+
// The host's default provider: a turn on another profile runs on that profile's.
|
|
66
|
+
{ field: "provider", value: String(i.provider ?? "").trim() ? hostDefaultProvider(String(i.provider).trim()) : UNREPORTED_BY_HOST },
|
|
67
|
+
{ field: "workspace", value: String(i.workspace ?? WORKSPACE) },
|
|
68
|
+
{ field: "session", value: String(i.title ?? "").trim() || "(untitled)" },
|
|
69
|
+
{ field: "messages", value: String(Number(i.messages ?? 0) || 0) },
|
|
70
|
+
{ field: "context", value: `${used} tokens${pct}` },
|
|
71
|
+
{ field: "llm", value: `${Number(i.calls ?? 0) || 0} call(s), ${Number(i.totalTokens ?? 0) || 0} token(s)` },
|
|
72
|
+
{ field: "cost", value: `$${cost.toFixed(4)}` },
|
|
73
|
+
{
|
|
74
|
+
field: "crews",
|
|
75
|
+
value: (i.crews?.length ?? 0) > 0 ? [...i.crews!].sort().join(", ") : "(none discovered)",
|
|
76
|
+
},
|
|
77
|
+
{ field: "version", value: `${CLI_NAME} ${CLI_VERSION} (${CLI_BUILD})` },
|
|
78
|
+
{ field: "runtime", value: runtimeRow(i.runtime) },
|
|
79
|
+
{ field: "platform", value: String(i.platform ?? "").trim() || "(unavailable)" },
|
|
80
|
+
{ field: "updates", value: UPDATE_NOTE },
|
|
81
|
+
];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface StatusDeps {
|
|
85
|
+
session: Pick<SessionStore, "readBudget">;
|
|
86
|
+
telemetry: Telemetry;
|
|
87
|
+
crews: Pick<CrewHost, "listCrews">;
|
|
88
|
+
/** For the platform row; absent: the row says unavailable. */
|
|
89
|
+
shell?: Pick<Shell, "run">;
|
|
90
|
+
/** The provider row's reader; absent, or answering nothing: the row says unreported. */
|
|
91
|
+
provider?: () => string | undefined;
|
|
92
|
+
/** The running runtime's reader; absent, or answering nothing: the row names the pin alone. */
|
|
93
|
+
runtime?: RuntimeInfoReader;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** One allow-listed command (node), no shell operator: the shell tool refuses them. */
|
|
97
|
+
export const PLATFORM_COMMAND = "node -p \"[process.platform, process.arch, 'node ' + process.version].join(' ')\"";
|
|
98
|
+
|
|
99
|
+
/** `/status`: the rows, each read best effort and on its own, so a missing session
|
|
100
|
+
* store degrades one row, not the whole command. */
|
|
101
|
+
export async function runStatus(deps: StatusDeps): Promise<CommandView> {
|
|
102
|
+
const { session, telemetry } = deps;
|
|
103
|
+
const [md, cost, stats, budget, platform] = await Promise.all([
|
|
104
|
+
telemetry.readMetadata().catch((): SessionMetadata => ({})),
|
|
105
|
+
telemetry.readCost().catch((): SessionCost => ({})),
|
|
106
|
+
telemetry.readStats().catch((): SessionStats => ({})),
|
|
107
|
+
session.readBudget().catch(() => ({ used: 0, window: 0 })),
|
|
108
|
+
deps.shell ? deps.shell.run(PLATFORM_COMMAND).then((r) => r.stdout).catch(() => "") : Promise.resolve(""),
|
|
109
|
+
]);
|
|
110
|
+
|
|
111
|
+
return {
|
|
112
|
+
table: buildStatusRows({
|
|
113
|
+
model: md.model,
|
|
114
|
+
title: md.title,
|
|
115
|
+
messages: md.messageCount ?? stats.messageCount,
|
|
116
|
+
usedTokens: budget.used,
|
|
117
|
+
windowTokens: budget.window,
|
|
118
|
+
totalTokens: cost.totalTokens ?? stats.totalTokens,
|
|
119
|
+
costUsd: cost.costUsd,
|
|
120
|
+
calls: cost.totalCalls ?? stats.totalCalls,
|
|
121
|
+
crews: deps.crews.listCrews(),
|
|
122
|
+
workspace: WORKSPACE,
|
|
123
|
+
platform,
|
|
124
|
+
provider: deps.provider?.(),
|
|
125
|
+
runtime: deps.runtime?.read(),
|
|
126
|
+
}),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// /usage tools [text]: the session's [tools] messages (shared/domain/tool-trace.ts), each under the request it
|
|
2
|
+
// answered, the lines kept to those holding the text when one is given.
|
|
3
|
+
import type { SessionStore } from "../../../shared/application/ports.ts";
|
|
4
|
+
import type { SessionMsg } from "../../../shared/domain/types.ts";
|
|
5
|
+
import { isToolTrace } from "../../../shared/domain/tool-trace.ts";
|
|
6
|
+
import { isMarkedMessage } from "../../../shared/domain/marked-message.ts";
|
|
7
|
+
import type { CommandView } from "../view.ts";
|
|
8
|
+
import { NO_TOOL_TRACE, noToolCallHolds } from "./messages.ts";
|
|
9
|
+
|
|
10
|
+
/** A request is cut past this many characters on its line. */
|
|
11
|
+
export const MAX_REQUEST_CHARS = 100;
|
|
12
|
+
|
|
13
|
+
export interface UsageToolsDeps {
|
|
14
|
+
session: Pick<SessionStore, "readMessages">;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export async function runUsageTools(text: string, deps: UsageToolsDeps): Promise<CommandView> {
|
|
18
|
+
let messages: SessionMsg[];
|
|
19
|
+
try {
|
|
20
|
+
messages = (await deps.session.readMessages()).messages;
|
|
21
|
+
} catch {
|
|
22
|
+
messages = [];
|
|
23
|
+
}
|
|
24
|
+
const lines = toolTraceLines(messages, text.trim());
|
|
25
|
+
if (lines.length > 0) return { lines };
|
|
26
|
+
return { text: text.trim().length === 0 ? NO_TOOL_TRACE : noToolCallHolds(text.trim()) };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Each turn's request, then its calls, the calls holding `text` alone (case aside) when it is not empty. */
|
|
30
|
+
export function toolTraceLines(messages: readonly SessionMsg[], text: string): string[] {
|
|
31
|
+
const needle = text.toLowerCase();
|
|
32
|
+
const out: string[] = [];
|
|
33
|
+
let request = "(no request)";
|
|
34
|
+
for (const m of messages) {
|
|
35
|
+
const content = String(m.content ?? "");
|
|
36
|
+
if (m.role === "user" && !isMarkedMessage(content)) request = content;
|
|
37
|
+
if (m.role !== "system" || !isToolTrace(content)) continue;
|
|
38
|
+
const calls = content.split("\n").slice(1).filter((l) => needle.length === 0 || l.toLowerCase().includes(needle));
|
|
39
|
+
if (calls.length === 0) continue;
|
|
40
|
+
out.push(`> ${requestLine(request)}`, ...calls.map((c) => ` ${c}`));
|
|
41
|
+
}
|
|
42
|
+
return out;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function requestLine(request: string): string {
|
|
46
|
+
const flat = request.replace(/\s+/g, " ").trim();
|
|
47
|
+
return flat.length > MAX_REQUEST_CHARS ? flat.slice(0, MAX_REQUEST_CHARS - 1) + "…" : flat;
|
|
48
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// /usage — the token usage against the context window (pressure tier, compaction trigger) and the conversation's
|
|
2
|
+
// estimated tokens, then the session's calls, the tokens sent and received as the providers counted them, their total,
|
|
3
|
+
// the cost, the cache tokens and the cache ratio, in one row; then a legend and the usage by model and by command the
|
|
4
|
+
// host accounts (Orkeon #226). runUsage reads the rows over the ports. Lives under
|
|
5
|
+
// commands/_lib/ — the loader's SearchPattern is "*.cmd.ts", so this file is never loaded as a command.
|
|
6
|
+
|
|
7
|
+
import type {
|
|
8
|
+
CommandUsage, ModelUsage, SessionCost, SessionStats, SessionStore, Telemetry, UsageReader, UsageReport, UsageSpent,
|
|
9
|
+
} from "../../../shared/application/ports.ts";
|
|
10
|
+
import type { ConfigStore } from "../../../shared/application/config-store.ts";
|
|
11
|
+
import { readCompactionTrigger } from "../../../shared/application/compaction/compact-session.ts";
|
|
12
|
+
import {
|
|
13
|
+
DEFAULT_CONTEXT_WINDOW, computeTrigger, percentLeft, pressureTier,
|
|
14
|
+
} from "../../../shared/domain/compaction-thresholds.ts";
|
|
15
|
+
import { UNREPORTED, type Unreported, cacheColumns, shown } from "./cache.ts";
|
|
16
|
+
import type { CommandView } from "../view.ts";
|
|
17
|
+
import { runUsageTools, type UsageToolsDeps } from "./usage-tools.ts";
|
|
18
|
+
import {
|
|
19
|
+
NO_COMMAND_USAGE, NO_MODEL_USAGE, NO_USAGE_SERVICE, USAGE_LEGEND, USAGE_SYNTAX, fromCache, unpricedCalls as unpricedCallsNote,
|
|
20
|
+
} from "./messages.ts";
|
|
21
|
+
|
|
22
|
+
export interface UsageDeps {
|
|
23
|
+
session: Pick<SessionStore, "readBudget">;
|
|
24
|
+
telemetry: Pick<Telemetry, "readStats" | "readCost">;
|
|
25
|
+
config: Pick<ConfigStore, "readValue">;
|
|
26
|
+
/** The host's account by model and by command; absent, or answering nothing: the breakdown says so. */
|
|
27
|
+
usage?: UsageReader;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** A cost as the breakdown shows it: unpriced when the host priced no call of the set. */
|
|
31
|
+
export function costText(cost: number | null): string {
|
|
32
|
+
return cost === null ? "cost unpriced" : `$${cost.toFixed(4)}`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** The lower-bound note, when some calls were priced by nobody. */
|
|
36
|
+
export function unpricedNote(unpricedCalls: number): string | null {
|
|
37
|
+
return unpricedCalls > 0 ? unpricedCallsNote(unpricedCalls) : null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function spentText(s: UsageSpent): string {
|
|
41
|
+
// A cache read no call reported is left out; one measured, 0 included, is named.
|
|
42
|
+
const cached = s.cacheHitTokens === null ? "" : fromCache(s.cacheHitTokens);
|
|
43
|
+
return `${s.calls} call(s), ${s.promptTokens} prompt${cached}, ${s.completionTokens} completion, ${costText(s.cost)}`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function modelLine(m: ModelUsage): string {
|
|
47
|
+
return ` ${m.model || "(unnamed model)"}: ${spentText(m)}`;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function commandLine(c: CommandUsage): string {
|
|
51
|
+
return ` [${c.ticket}] ${c.name} (${c.state}): ${spentText(c)}`;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** The breakdown of a report, as the closing text: by model, by command, the lower-bound note; undefined when the
|
|
55
|
+
* host keeps no account. */
|
|
56
|
+
export function usageBreakdown(report: UsageReport | undefined): string {
|
|
57
|
+
if (report === undefined) return NO_USAGE_SERVICE;
|
|
58
|
+
const lines = [
|
|
59
|
+
report.byModel.length > 0 ? "by model:" : NO_MODEL_USAGE,
|
|
60
|
+
...report.byModel.map(modelLine),
|
|
61
|
+
report.byCommand.length > 0 ? "by command:" : NO_COMMAND_USAGE,
|
|
62
|
+
...report.byCommand.map(commandLine),
|
|
63
|
+
];
|
|
64
|
+
const note = unpricedNote(report.unpricedCalls);
|
|
65
|
+
if (note !== null) lines.push(note);
|
|
66
|
+
return lines.join("\n");
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** The share of the prompt tokens read from the cache, to two decimals; `n/a` when no call reported a cache read, or
|
|
70
|
+
* no prompt token is counted: an unmeasured cache never reads as a ratio of 0. */
|
|
71
|
+
export function cacheRatio(cacheRead: number | Unreported, promptTokens: number | Unreported): string {
|
|
72
|
+
return cacheRead !== UNREPORTED && promptTokens !== UNREPORTED && promptTokens > 0
|
|
73
|
+
? (cacheRead / promptTokens).toFixed(2)
|
|
74
|
+
: UNREPORTED;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** The total of the tokens sent and received: the host's account when it keeps one; else in + out when the telemetry
|
|
78
|
+
* splits both over its models, since its total also counts the calls no model was named for and would break
|
|
79
|
+
* `llmTokens = in + out`; else the telemetry's total, `n/a` when nothing counts it. */
|
|
80
|
+
function llmTokens(report: UsageReport | undefined, s: SessionStats): number | Unreported {
|
|
81
|
+
if (report) return report.totalTokens;
|
|
82
|
+
if (s.promptTokens !== undefined && s.completionTokens !== undefined) return s.promptTokens + s.completionTokens;
|
|
83
|
+
return shown(s.totalTokens);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** `/usage`: the one row, each figure read best effort, then the breakdown. */
|
|
87
|
+
export async function runUsage(deps: UsageDeps): Promise<CommandView> {
|
|
88
|
+
const [{ used, window }, s, c, trigger] = await Promise.all([
|
|
89
|
+
deps.session.readBudget().catch(() => ({ used: 0, window: 0 })),
|
|
90
|
+
deps.telemetry.readStats().catch((): SessionStats => ({})),
|
|
91
|
+
deps.telemetry.readCost().catch((): SessionCost => ({})),
|
|
92
|
+
readCompactionTrigger(deps.config),
|
|
93
|
+
]);
|
|
94
|
+
const report = deps.usage?.report();
|
|
95
|
+
// The cache figures come from the host's account alone when it keeps one (`n/a` for what it did not measure), else
|
|
96
|
+
// from session_stats: the same source as the tokens sent, so the ratio never mixes two sources.
|
|
97
|
+
const { cacheRead, cacheWrite } = cacheColumns(s, report);
|
|
98
|
+
const promptTokens = shown(report?.promptTokens ?? s.promptTokens);
|
|
99
|
+
return {
|
|
100
|
+
table: [{
|
|
101
|
+
usedTokens: used,
|
|
102
|
+
contextWindow: window || `(default ${DEFAULT_CONTEXT_WINDOW})`,
|
|
103
|
+
percentLeft: percentLeft(used, window) + "%",
|
|
104
|
+
pressure: pressureTier(used, window),
|
|
105
|
+
autocompactAt: computeTrigger(window, trigger) + (trigger ? " (compaction.trigger)" : ""),
|
|
106
|
+
messages: shown(s.messageCount),
|
|
107
|
+
estTokens: shown(s.estimatedTokens),
|
|
108
|
+
llmCalls: shown(report?.calls ?? s.totalCalls),
|
|
109
|
+
llmInTokens: promptTokens,
|
|
110
|
+
llmOutTokens: shown(report?.completionTokens ?? s.completionTokens),
|
|
111
|
+
llmReasoningTokens: shown(report?.reasoningTokens ?? s.reasoningTokens),
|
|
112
|
+
llmTokens: llmTokens(report, s),
|
|
113
|
+
costUsd: report ? (report.cost ?? "(unpriced)") : shown(c.costUsd),
|
|
114
|
+
...(report ? { unpricedCalls: report.unpricedCalls } : {}),
|
|
115
|
+
cacheRead,
|
|
116
|
+
cacheWrite,
|
|
117
|
+
cacheRatio: cacheRatio(cacheRead, promptTokens),
|
|
118
|
+
}],
|
|
119
|
+
text: `${USAGE_LEGEND}\n${usageBreakdown(report)}`,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** /usage with its tokens: the usage view bare, the session's tool calls after `tools`. */
|
|
124
|
+
export async function runUsageCommand(tokens: readonly string[], deps: UsageDeps & UsageToolsDeps): Promise<CommandView> {
|
|
125
|
+
if (tokens.length === 0) return runUsage(deps);
|
|
126
|
+
if (tokens[0] === "tools") return runUsageTools(tokens.slice(1).join(" "), deps);
|
|
127
|
+
return { text: USAGE_SYNTAX };
|
|
128
|
+
}
|