orkeon-code 0.0.0-stage → 1.0.0-rc.1
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-version +1 -0
- package/LICENSE.md +21 -0
- package/NOTICE.md +17 -0
- package/README.fr.md +169 -0
- package/README.md +162 -2
- package/config/appsettings.anthropic.example.json +77 -0
- package/config/appsettings.example.json +71 -0
- package/config/appsettings.jev.example.json +128 -0
- package/config/appsettings.kev.example.json +130 -0
- package/config/appsettings.liquid.example.json +129 -0
- package/config/appsettings.ollama-whisper.example.json +92 -0
- package/config/appsettings.ollama.example.json +70 -0
- package/config/appsettings.whisper.example.json +31 -0
- package/mcp/whisper/README.md +293 -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 +897 -0
- package/orkeon-code.mjs +71 -0
- package/orkeon-code.ps1 +837 -0
- package/package.json +57 -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 +562 -0
- package/src/commands/_lib/args.ts +193 -0
- package/src/commands/_lib/dev/dev-batches.ts +368 -0
- package/src/commands/_lib/dev/dev-implement.ts +188 -0
- package/src/commands/_lib/dev/dev-source.ts +65 -0
- package/src/commands/_lib/dev/dev.ts +344 -0
- package/src/commands/_lib/dev-step.ts +142 -0
- package/src/commands/_lib/dispatch.ts +231 -0
- package/src/commands/_lib/effort.ts +15 -0
- package/src/commands/_lib/git/branch.ts +95 -0
- package/src/commands/_lib/git/commit.ts +94 -0
- package/src/commands/_lib/git/diff.ts +97 -0
- package/src/commands/_lib/git/review.ts +109 -0
- package/src/commands/_lib/memory/memory-admit.ts +150 -0
- package/src/commands/_lib/memory/memory.ts +51 -0
- package/src/commands/_lib/pr-context.ts +32 -0
- package/src/commands/_lib/project/analyze.ts +24 -0
- package/src/commands/_lib/session/export.ts +104 -0
- package/src/commands/_lib/session/resume.ts +160 -0
- package/src/commands/_lib/session/tasks.ts +184 -0
- package/src/commands/_lib/settings/advisor.ts +80 -0
- package/src/commands/_lib/settings/agents.ts +147 -0
- package/src/commands/_lib/settings/config.ts +141 -0
- package/src/commands/_lib/settings/hooks.ts +58 -0
- package/src/commands/_lib/settings/mode.ts +91 -0
- package/src/commands/_lib/settings/model.ts +146 -0
- package/src/commands/_lib/settings/permissions.ts +309 -0
- package/src/commands/_lib/settings/session-config.ts +49 -0
- package/src/commands/_lib/settings/skills.ts +51 -0
- package/src/commands/_lib/speech/say.ts +96 -0
- package/src/commands/_lib/speech/transcribe.ts +130 -0
- package/src/commands/_lib/speech/voice.ts +146 -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 +186 -0
- package/src/commands/_lib/status/meta.ts +45 -0
- package/src/commands/_lib/status/status.ts +129 -0
- package/src/commands/_lib/status/usage-tools.ts +49 -0
- package/src/commands/_lib/status/usage.ts +139 -0
- package/src/commands/_lib/view.ts +29 -0
- package/src/commands/dev/dev-batches.cmd.ts +108 -0
- package/src/commands/dev/dev-learn.cmd.ts +29 -0
- package/src/commands/dev/dev-plan.cmd.ts +52 -0
- package/src/commands/dev/dev-spec.cmd.ts +55 -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 +67 -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 +44 -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 +17 -0
- package/src/commands/session/resume.cmd.ts +19 -0
- package/src/commands/session/rewind.cmd.ts +26 -0
- package/src/commands/session/summary.cmd.ts +27 -0
- package/src/commands/session/tasks.cmd.ts +44 -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 +17 -0
- package/src/commands/settings/effort.cmd.ts +40 -0
- package/src/commands/settings/fast.cmd.ts +17 -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 +20 -0
- package/src/commands/settings/output-style.cmd.ts +48 -0
- package/src/commands/settings/permissions.cmd.ts +25 -0
- package/src/commands/settings/proactive.cmd.ts +15 -0
- package/src/commands/settings/skills.cmd.ts +17 -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 +3946 -0
- package/src/crews/_probe-shared-memory/domain/probe-verdict.ts +183 -0
- package/src/crews/_probe-shared-memory/probe.ork.ts +98 -0
- package/src/crews/advisor/application/run-advisor.ts +40 -0
- package/src/crews/advisor/crew.ork.ts +43 -0
- package/src/crews/advisor/domain/advice.ts +135 -0
- package/src/crews/agent-run/application/run-agent-run.ts +42 -0
- package/src/crews/agent-run/crew.ork.ts +67 -0
- package/src/crews/analyze/application/run-analyze.ts +118 -0
- package/src/crews/analyze/crew.ork.ts +40 -0
- package/src/crews/analyze/domain/harvest.ts +301 -0
- package/src/crews/code-review/application/prompts.ts +133 -0
- package/src/crews/code-review/application/review.ts +71 -0
- package/src/crews/code-review/application/run-code-review.ts +123 -0
- package/src/crews/code-review/crew.ork.ts +51 -0
- package/src/crews/code-review/domain/lenses.ts +193 -0
- package/src/crews/code-review/domain/report.ts +59 -0
- package/src/crews/code-review/domain/scope.ts +112 -0
- package/src/crews/dev-batches/application/plan-close.ts +181 -0
- package/src/crews/dev-batches/application/run-dev-batches.ts +669 -0
- package/src/crews/dev-batches/application/run-wave.ts +450 -0
- package/src/crews/dev-batches/application/seed-harvest.ts +162 -0
- package/src/crews/dev-batches/crew.ork.ts +143 -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 +54 -0
- package/src/crews/dev-batches/domain/wave-order.ts +43 -0
- package/src/crews/dev-change/application/change-prompt.ts +104 -0
- package/src/crews/dev-change/application/evidence.ts +169 -0
- package/src/crews/dev-change/application/run-dev-change.ts +315 -0
- package/src/crews/dev-change/crew.ork.ts +112 -0
- package/src/crews/dev-change/domain/change-answer.ts +159 -0
- package/src/crews/dev-change/domain/change-render.ts +79 -0
- package/src/crews/dev-implement/application/close.ts +183 -0
- package/src/crews/dev-implement/application/count-open-steps.ts +24 -0
- package/src/crews/dev-implement/application/locate-sheet.ts +80 -0
- package/src/crews/dev-implement/application/observe.ts +50 -0
- package/src/crews/dev-implement/application/report-writes.ts +41 -0
- package/src/crews/dev-implement/application/run-dev-implement.ts +811 -0
- package/src/crews/dev-implement/application/run-role.ts +27 -0
- package/src/crews/dev-implement/application/suite-job.ts +118 -0
- package/src/crews/dev-implement/application/touched.ts +74 -0
- package/src/crews/dev-implement/crew.ork.ts +68 -0
- package/src/crews/dev-implement/domain/contracts.ts +256 -0
- package/src/crews/dev-implement/domain/correction.ts +102 -0
- package/src/crews/dev-implement/domain/cycles.ts +35 -0
- package/src/crews/dev-implement/domain/implement-budget.ts +29 -0
- package/src/crews/dev-implement/domain/roles.ts +53 -0
- package/src/crews/dev-implement/domain/sheet-edits.ts +75 -0
- package/src/crews/dev-implement/domain/sheet-ticks.ts +22 -0
- package/src/crews/dev-implement/domain/step-checks.ts +136 -0
- package/src/crews/dev-implement/domain/step-section.ts +127 -0
- package/src/crews/dev-learn/application/learn-backlog.ts +58 -0
- package/src/crews/dev-learn/application/learn-prompt.ts +140 -0
- package/src/crews/dev-learn/application/run-dev-learn.ts +553 -0
- package/src/crews/dev-learn/crew.ork.ts +52 -0
- package/src/crews/dev-learn/domain/learn-answer.ts +235 -0
- package/src/crews/dev-learn/domain/owner-lines.ts +86 -0
- package/src/crews/dev-learn/domain/proposals-render.ts +96 -0
- package/src/crews/dev-plan/application/anchor-paths.ts +76 -0
- package/src/crews/dev-plan/application/inventory.ts +170 -0
- package/src/crews/dev-plan/application/plan-prompt.ts +159 -0
- package/src/crews/dev-plan/application/run-dev-plan.ts +455 -0
- package/src/crews/dev-plan/crew.ork.ts +109 -0
- package/src/crews/dev-plan/domain/inventory-model.ts +95 -0
- package/src/crews/dev-plan/domain/plan-answer.ts +738 -0
- package/src/crews/dev-plan/domain/plan-render.ts +307 -0
- package/src/crews/dev-spec/application/run-dev-spec.ts +206 -0
- package/src/crews/dev-spec/application/spec-prompt.ts +98 -0
- package/src/crews/dev-spec/crew.ork.ts +108 -0
- package/src/crews/dev-spec/domain/spec-answer.ts +253 -0
- package/src/crews/dev-spec/domain/spec-render.ts +76 -0
- package/src/crews/dev-verify/application/audit.ts +259 -0
- package/src/crews/dev-verify/application/auditor-prompt.ts +323 -0
- package/src/crews/dev-verify/application/capture.ts +303 -0
- package/src/crews/dev-verify/application/run-dev-verify.ts +409 -0
- package/src/crews/dev-verify/application/run-gate.ts +202 -0
- package/src/crews/dev-verify/crew.ork.ts +103 -0
- package/src/crews/dev-verify/domain/audit-answer.ts +150 -0
- package/src/crews/dev-verify/domain/auditor-charter.ts +21 -0
- package/src/crews/dev-verify/domain/capture-sections.ts +137 -0
- package/src/crews/dev-verify/domain/commands.ts +103 -0
- package/src/crews/dev-verify/domain/gate.ts +126 -0
- package/src/crews/dev-verify/domain/mechanical-table.ts +163 -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 +154 -0
- package/src/crews/git-commit/application/run-git-commit.ts +116 -0
- package/src/crews/git-commit/crew.ork.ts +52 -0
- package/src/crews/git-commit/domain/commit.ts +220 -0
- package/src/crews/init-verifiers/application/authoring.ts +89 -0
- package/src/crews/init-verifiers/application/prompts.ts +103 -0
- package/src/crews/init-verifiers/application/run-init-verifiers.ts +25 -0
- package/src/crews/init-verifiers/crew.ork.ts +34 -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 +77 -0
- package/src/crews/main-loop/application/context-gather.ts +133 -0
- package/src/crews/main-loop/application/run-main-loop.ts +350 -0
- package/src/crews/main-loop/application/turn-prompt.ts +112 -0
- package/src/crews/main-loop/crew.ork.ts +119 -0
- package/src/crews/main-loop/domain/autocompact.ts +27 -0
- package/src/crews/main-loop/domain/prompt-assembly.ts +521 -0
- package/src/crews/main-loop/domain/turn-chains.ts +129 -0
- package/src/crews/project-init/application/detect.ts +122 -0
- package/src/crews/project-init/application/prompts.ts +101 -0
- package/src/crews/project-init/application/run-project-init.ts +31 -0
- package/src/crews/project-init/crew.ork.ts +35 -0
- package/src/crews/project-init/domain/conventions.ts +36 -0
- package/src/crews/project-init/domain/existing-files.ts +63 -0
- package/src/crews/project-init/domain/package-map.ts +73 -0
- package/src/crews/session-compact/crew.ork.ts +55 -0
- package/src/crews/shared-memory-admit/crew.ork.ts +48 -0
- package/src/crews/speech/application/run-speech.ts +25 -0
- package/src/crews/speech/crew.ork.ts +37 -0
- package/src/shared/application/agents/child-agent.ts +255 -0
- package/src/shared/application/agents/run-sub-agent.ts +96 -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 +237 -0
- package/src/shared/application/compaction/extract-memories.ts +38 -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 +113 -0
- package/src/shared/application/dev/close-batch.ts +83 -0
- package/src/shared/application/dev/find-repo-pack.ts +77 -0
- package/src/shared/application/dev/learn-decision.ts +252 -0
- package/src/shared/application/dev/load-dev-context.ts +266 -0
- package/src/shared/application/dev/measure-access-cost.ts +68 -0
- package/src/shared/application/dev/plan-source.ts +112 -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/question-round.ts +52 -0
- package/src/shared/application/dev/resolve-work-folder.ts +133 -0
- package/src/shared/application/dev/script-tool-slot.ts +27 -0
- package/src/shared/application/dev/settle-questions.ts +55 -0
- package/src/shared/application/dev/source-review.ts +63 -0
- package/src/shared/application/dev/source-step.ts +150 -0
- package/src/shared/application/dev/spend.ts +42 -0
- package/src/shared/application/dev/step-precedents.ts +89 -0
- package/src/shared/application/dev/tool-call-policy.ts +89 -0
- package/src/shared/application/dev/tool-callbacks.ts +215 -0
- package/src/shared/application/dev/tool-trace-recorder.ts +45 -0
- package/src/shared/application/dev/verdict-sources.ts +48 -0
- package/src/shared/application/dev/wrapped-tools.ts +145 -0
- package/src/shared/application/extra-tools.ts +70 -0
- package/src/shared/application/git/batch-worktree.ts +97 -0
- package/src/shared/application/git/commit-files.ts +186 -0
- package/src/shared/application/git/merge-batch.ts +63 -0
- package/src/shared/application/git/open-pull-request.ts +51 -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 +35 -0
- package/src/shared/application/permission-rules.ts +159 -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/files.ts +21 -0
- package/src/shared/application/ports/human.ts +13 -0
- package/src/shared/application/ports/llm.ts +54 -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/tools.ts +46 -0
- package/src/shared/application/ports/usage.ts +45 -0
- package/src/shared/application/ports.ts +27 -0
- package/src/shared/application/project-manifests.ts +106 -0
- package/src/shared/application/session-io.ts +84 -0
- package/src/shared/application/session-state.ts +36 -0
- package/src/shared/application/shared-memory/admit-entries.ts +177 -0
- package/src/shared/application/shared-memory/harvest-after-gaps.ts +72 -0
- package/src/shared/application/shared-memory/harvest-mistakes.ts +44 -0
- package/src/shared/application/shared-memory/import-agent-memory.ts +117 -0
- package/src/shared/application/shared-memory/memory-files.ts +110 -0
- package/src/shared/application/shared-memory/memory-settings.ts +93 -0
- package/src/shared/application/shared-memory/push-candidate.ts +146 -0
- package/src/shared/application/shared-memory/recall-precedents.ts +69 -0
- package/src/shared/application/state-snapshot.ts +38 -0
- package/src/shared/application/workflow/workflow-state.ts +135 -0
- package/src/shared/domain/agent-policy/behavior-flags.ts +168 -0
- package/src/shared/domain/agent-policy/extra-tools.ts +69 -0
- package/src/shared/domain/agent-policy/memory-categories.ts +6 -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/permission.ts +623 -0
- package/src/shared/domain/agent-policy/rule-sets.ts +412 -0
- package/src/shared/domain/agent-policy/tool-access.ts +77 -0
- package/src/shared/domain/agent-registry.ts +142 -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 +61 -0
- package/src/shared/domain/agents/exclusive.ts +24 -0
- package/src/shared/domain/agents/instances.ts +249 -0
- package/src/shared/domain/code-intel-contract.ts +356 -0
- package/src/shared/domain/code-intel-routing.ts +113 -0
- package/src/shared/domain/compact-outcome.ts +44 -0
- package/src/shared/domain/compaction-thresholds.ts +161 -0
- package/src/shared/domain/compaction.ts +379 -0
- package/src/shared/domain/config-schema.ts +421 -0
- package/src/shared/domain/dev/access-cost.ts +226 -0
- package/src/shared/domain/dev/artefacts.ts +50 -0
- package/src/shared/domain/dev/batches-concurrency.ts +36 -0
- package/src/shared/domain/dev/batches-state.ts +49 -0
- package/src/shared/domain/dev/build-commands.ts +44 -0
- package/src/shared/domain/dev/call-guard.ts +341 -0
- package/src/shared/domain/dev/carried-text.ts +49 -0
- package/src/shared/domain/dev/design-rules.ts +100 -0
- package/src/shared/domain/dev/learn-proposals.ts +175 -0
- package/src/shared/domain/dev/learn-state.ts +93 -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/plan-checks.ts +190 -0
- package/src/shared/domain/dev/plan-format.ts +180 -0
- package/src/shared/domain/dev/project-files.ts +43 -0
- package/src/shared/domain/dev/questions.ts +249 -0
- package/src/shared/domain/dev/reading-rule.ts +41 -0
- package/src/shared/domain/dev/repo-pack.ts +237 -0
- package/src/shared/domain/dev/review-answer.ts +150 -0
- package/src/shared/domain/dev/review-prompt.ts +221 -0
- package/src/shared/domain/dev/reviewer-charter.ts +31 -0
- package/src/shared/domain/dev/sheet-facts.ts +83 -0
- package/src/shared/domain/dev/spec-format.ts +183 -0
- package/src/shared/domain/dev/step-budget.ts +72 -0
- package/src/shared/domain/dev/step-rules.ts +110 -0
- package/src/shared/domain/dev/test-commands.ts +90 -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 +64 -0
- package/src/shared/domain/dev/trait-pattern.ts +83 -0
- package/src/shared/domain/dev/verdict-format.ts +169 -0
- package/src/shared/domain/dev/whitespace.ts +34 -0
- package/src/shared/domain/dev/work-folder.ts +67 -0
- package/src/shared/domain/dev/yaml-subset.ts +403 -0
- package/src/shared/domain/git/close.ts +273 -0
- package/src/shared/domain/git/pull-request.ts +96 -0
- package/src/shared/domain/git/worktree.ts +46 -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 +106 -0
- package/src/shared/domain/llm-profile.ts +25 -0
- package/src/shared/domain/marked-message.ts +33 -0
- package/src/shared/domain/model-catalog.ts +86 -0
- package/src/shared/domain/permission-modes.ts +103 -0
- package/src/shared/domain/prelude.ts +92 -0
- package/src/shared/domain/project-manifests.ts +83 -0
- package/src/shared/domain/search-routing.ts +85 -0
- package/src/shared/domain/secret-patterns.ts +45 -0
- package/src/shared/domain/session-keys.ts +85 -0
- package/src/shared/domain/session-start.ts +60 -0
- package/src/shared/domain/session-summary.ts +13 -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 +143 -0
- package/src/shared/domain/shared-memory/candidates.ts +41 -0
- package/src/shared/domain/shared-memory/entry.ts +145 -0
- package/src/shared/domain/shared-memory/front-matter.ts +183 -0
- package/src/shared/domain/shared-memory/gate.ts +44 -0
- package/src/shared/domain/shared-memory/harvest.ts +61 -0
- package/src/shared/domain/shared-memory/layout.ts +187 -0
- package/src/shared/domain/shared-memory/precedents-block.ts +93 -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/snip-turns.ts +45 -0
- package/src/shared/domain/speech.ts +20 -0
- package/src/shared/domain/strip.ts +88 -0
- package/src/shared/domain/tool-trace.ts +122 -0
- package/src/shared/domain/types.ts +67 -0
- package/src/shared/domain/verifiers.ts +37 -0
- package/src/shared/domain/vfs.ts +9 -0
- package/src/shared/domain/workflow/state-file.ts +140 -0
- package/src/shared/infrastructure/globals.ts +52 -0
- package/src/shared/infrastructure/orkeon/approvals.ts +24 -0
- package/src/shared/infrastructure/orkeon/child-agents.ts +127 -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/dev-deps.ts +172 -0
- package/src/shared/infrastructure/orkeon/files.ts +40 -0
- package/src/shared/infrastructure/orkeon/github-pull-requests.ts +29 -0
- package/src/shared/infrastructure/orkeon/host-provider.ts +22 -0
- package/src/shared/infrastructure/orkeon/human-input.ts +59 -0
- package/src/shared/infrastructure/orkeon/llm-profile.ts +38 -0
- package/src/shared/infrastructure/orkeon/llm.ts +109 -0
- package/src/shared/infrastructure/orkeon/memory-store.ts +41 -0
- package/src/shared/infrastructure/orkeon/memory-tools.ts +131 -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/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 +134 -0
- package/src/shared/infrastructure/orkeon/session-store.ts +138 -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 +75 -0
- package/src/shared/infrastructure/orkeon/shell.ts +31 -0
- package/src/shared/infrastructure/orkeon/telemetry.ts +63 -0
- package/src/shared/infrastructure/orkeon/tool-catalogue.ts +75 -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 +118 -0
|
@@ -0,0 +1,139 @@
|
|
|
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
|
+
|
|
19
|
+
export interface UsageDeps {
|
|
20
|
+
session: Pick<SessionStore, "readBudget">;
|
|
21
|
+
telemetry: Pick<Telemetry, "readStats" | "readCost">;
|
|
22
|
+
config: Pick<ConfigStore, "readValue">;
|
|
23
|
+
/** The host's account by model and by command; absent, or answering nothing: the breakdown says so. */
|
|
24
|
+
usage?: UsageReader;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** What a host without the usage service leaves the breakdown with. */
|
|
28
|
+
export const NO_USAGE_SERVICE = "usage by model and command: not reported by this host (no usage service)";
|
|
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 ? `${unpricedCalls} call(s) unpriced: the cost is a lower bound` : 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 ? "" : ` (${s.cacheHitTokens} from the cache)`;
|
|
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:" : "by model: none named by the provider yet",
|
|
60
|
+
...report.byModel.map(modelLine),
|
|
61
|
+
report.byCommand.length > 0 ? "by command:" : "by command: no command instance yet",
|
|
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
|
+
/** What the row's columns count, and which are estimates: the closing text opens with it. */
|
|
70
|
+
export const USAGE_LEGEND = [
|
|
71
|
+
"usedTokens, estTokens: the conversation's size in the context window, estimated by the host.",
|
|
72
|
+
"llm*: counted by the providers over every call: llmInTokens sent, llmOutTokens received (llmReasoningTokens a part of",
|
|
73
|
+
"them), llmTokens = in + out. cacheRead and cacheWrite are parts of llmInTokens; cacheRatio = cacheRead / llmInTokens.",
|
|
74
|
+
"n/a: not reported, never a measured 0.",
|
|
75
|
+
].join("\n");
|
|
76
|
+
|
|
77
|
+
/** The share of the prompt tokens read from the cache, to two decimals; `n/a` when no call reported a cache read, or
|
|
78
|
+
* no prompt token is counted: an unmeasured cache never reads as a ratio of 0. */
|
|
79
|
+
export function cacheRatio(cacheRead: number | Unreported, promptTokens: number | Unreported): string {
|
|
80
|
+
return cacheRead !== UNREPORTED && promptTokens !== UNREPORTED && promptTokens > 0
|
|
81
|
+
? (cacheRead / promptTokens).toFixed(2)
|
|
82
|
+
: UNREPORTED;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** The total of the tokens sent and received: the host's account when it keeps one; else in + out when the telemetry
|
|
86
|
+
* splits both over its models, since its total also counts the calls no model was named for and would break
|
|
87
|
+
* `llmTokens = in + out`; else the telemetry's total, `n/a` when nothing counts it. */
|
|
88
|
+
function llmTokens(report: UsageReport | undefined, s: SessionStats): number | Unreported {
|
|
89
|
+
if (report) return report.totalTokens;
|
|
90
|
+
if (s.promptTokens !== undefined && s.completionTokens !== undefined) return s.promptTokens + s.completionTokens;
|
|
91
|
+
return shown(s.totalTokens);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** `/usage`: the one row, each figure read best effort, then the breakdown. */
|
|
95
|
+
export async function runUsage(deps: UsageDeps): Promise<CommandView> {
|
|
96
|
+
const [{ used, window }, s, c, trigger] = await Promise.all([
|
|
97
|
+
deps.session.readBudget().catch(() => ({ used: 0, window: 0 })),
|
|
98
|
+
deps.telemetry.readStats().catch((): SessionStats => ({})),
|
|
99
|
+
deps.telemetry.readCost().catch((): SessionCost => ({})),
|
|
100
|
+
readCompactionTrigger(deps.config),
|
|
101
|
+
]);
|
|
102
|
+
const report = deps.usage?.report();
|
|
103
|
+
// The cache figures come from the host's account alone when it keeps one (`n/a` for what it did not measure), else
|
|
104
|
+
// from session_stats: the same source as the tokens sent, so the ratio never mixes two sources.
|
|
105
|
+
const { cacheRead, cacheWrite } = cacheColumns(s, report);
|
|
106
|
+
const promptTokens = shown(report?.promptTokens ?? s.promptTokens);
|
|
107
|
+
return {
|
|
108
|
+
table: [{
|
|
109
|
+
usedTokens: used,
|
|
110
|
+
contextWindow: window || `(default ${DEFAULT_CONTEXT_WINDOW})`,
|
|
111
|
+
percentLeft: percentLeft(used, window) + "%",
|
|
112
|
+
pressure: pressureTier(used, window),
|
|
113
|
+
autocompactAt: computeTrigger(window, trigger) + (trigger ? " (compaction.trigger)" : ""),
|
|
114
|
+
messages: shown(s.messageCount),
|
|
115
|
+
estTokens: shown(s.estimatedTokens),
|
|
116
|
+
llmCalls: shown(report?.calls ?? s.totalCalls),
|
|
117
|
+
llmInTokens: promptTokens,
|
|
118
|
+
llmOutTokens: shown(report?.completionTokens ?? s.completionTokens),
|
|
119
|
+
llmReasoningTokens: shown(report?.reasoningTokens ?? s.reasoningTokens),
|
|
120
|
+
llmTokens: llmTokens(report, s),
|
|
121
|
+
costUsd: report ? (report.cost ?? "(unpriced)") : shown(c.costUsd),
|
|
122
|
+
...(report ? { unpricedCalls: report.unpricedCalls } : {}),
|
|
123
|
+
cacheRead,
|
|
124
|
+
cacheWrite,
|
|
125
|
+
cacheRatio: cacheRatio(cacheRead, promptTokens),
|
|
126
|
+
}],
|
|
127
|
+
text: `${USAGE_LEGEND}\n${usageBreakdown(report)}`,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** What a sub-verb /usage does not know answers. */
|
|
132
|
+
export const USAGE_SYNTAX = "usage: /usage, or /usage tools [text] (the tool calls of this session's turns)";
|
|
133
|
+
|
|
134
|
+
/** /usage with its tokens: the usage view bare, the session's tool calls after `tools`. */
|
|
135
|
+
export async function runUsageCommand(tokens: readonly string[], deps: UsageDeps & UsageToolsDeps): Promise<CommandView> {
|
|
136
|
+
if (tokens.length === 0) return runUsage(deps);
|
|
137
|
+
if (tokens[0] === "tools") return runUsageTools(tokens.slice(1).join(" "), deps);
|
|
138
|
+
return { text: USAGE_SYNTAX };
|
|
139
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// What a command's use case returns for its entry point to show. A use case never
|
|
2
|
+
// touches the command context: it takes its ports and returns a view, so it runs
|
|
3
|
+
// in a test over the fakes of tests/support/; the *.cmd.ts renders the view with
|
|
4
|
+
// showView. Lives under commands/_lib/ — the loader's SearchPattern is "*.cmd.ts",
|
|
5
|
+
// so this file is never loaded as a command.
|
|
6
|
+
|
|
7
|
+
/** Optional lines and table, then the closing message. */
|
|
8
|
+
export interface CommandView {
|
|
9
|
+
/** Lines written with ctx.writeLine, first (a command's own output: a diff). */
|
|
10
|
+
lines?: string[];
|
|
11
|
+
/** Rows shown with ctx.table, before the message. */
|
|
12
|
+
table?: object[];
|
|
13
|
+
/** The closing message; absent when the table says it all. */
|
|
14
|
+
text?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** The part of the command context a view is shown with. */
|
|
18
|
+
export interface ViewContext<R> {
|
|
19
|
+
writeLine(text: string): void;
|
|
20
|
+
table(rows: readonly object[]): void;
|
|
21
|
+
continue(message?: string): R;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Write the lines, show the table, if any, then close with the message. */
|
|
25
|
+
export function showView<R>(ctx: ViewContext<R>, view: CommandView): R {
|
|
26
|
+
for (const line of view.lines ?? []) ctx.writeLine(line);
|
|
27
|
+
if (view.table) ctx.table(view.table);
|
|
28
|
+
return view.text === undefined ? ctx.continue() : ctx.continue(view.text);
|
|
29
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/// <reference path="../.orkeon/orkeon-cli.d.ts" />
|
|
2
|
+
// /dev-batches — three shapes, read by _lib/dev/dev-batches.ts (parseDevBatchesArgs):
|
|
3
|
+
// /dev-batches [<code>] [--pr] [--concurrency n] run a plan's batches in the order their dependencies allow and
|
|
4
|
+
// close the plan with one push and one pull request; n from 2 to 4 runs each wave of disjoint batches at once,
|
|
5
|
+
// each under its own worktree (refused before any launch in a mode that asks before shell commands);
|
|
6
|
+
// /dev-batches <code> F<n> [--close [--pr]] [— correction: <finding>] run one batch sheet test-first (the
|
|
7
|
+
// dev-implement crew), then its audit and, on VALID, its close; --close runs the close alone; a correction
|
|
8
|
+
// appends the finding to the sheet as a new step, then runs it;
|
|
9
|
+
// /dev-batches <code> F<n> --audit [fast|full|resume] [--gate-only] audit one batch (the dev-verify crew).
|
|
10
|
+
// The aliases /dev-implement and /dev-verify keep the lines typed before they folded in here. Before each launch
|
|
11
|
+
// the host's gate is checked and the step's rule sets put in it (_lib/dev-step.ts). The dispatch records the chain
|
|
12
|
+
// it launches in the session, and `completed`, awaited by the host (Orkeon #220), reads it to tell apart the answers
|
|
13
|
+
// of a run, of one batch and of one audit (devBatchesCompleted): a run's hops keep the depth of the instance they
|
|
14
|
+
// run for (`{ chain: "continue" }`, Orkeon #221), so a plan of any length closes in one `/dev-batches`; a batch's
|
|
15
|
+
// chain climbs (at most three hops). Before each hop that writes, the session's mode and rules are read again: a
|
|
16
|
+
// mode that no longer allows it refuses the hop with the command to type, else the fresh context rides in the launch
|
|
17
|
+
// input. A batch's close inside a run never pushes (sent push: false); the plan's close pushes once and opens the
|
|
18
|
+
// one pull request. Every launch goes through launchCrew (its chain-depth refusal).
|
|
19
|
+
import { rawTokens, typedCommand } from "../_lib/args.ts";
|
|
20
|
+
import {
|
|
21
|
+
batchesHopFailedLine, batchesLaunchInput, batchesModeRefusal, devBatchesCompleted, launchCompletedHop,
|
|
22
|
+
parseDevBatchesArgs, recordChain, runDevVerifyDispatch,
|
|
23
|
+
} from "../_lib/dev/dev-batches.ts";
|
|
24
|
+
import { runDevImplementDispatch } from "../_lib/dev/dev-implement.ts";
|
|
25
|
+
import { reapplyStepRules, startDevStep, writeModeRefusal } from "../_lib/dev-step.ts";
|
|
26
|
+
import { launchCrew, withLlmProfile } from "../_lib/dispatch.ts";
|
|
27
|
+
import { storedEffort } from "../_lib/effort.ts";
|
|
28
|
+
import { readPullRequestContext } from "../_lib/pr-context.ts";
|
|
29
|
+
import { createCrewHost } from "../../shared/infrastructure/orkeon/crew-host.ts";
|
|
30
|
+
import { createPermissionRules } from "../../shared/infrastructure/orkeon/permission-rules.ts";
|
|
31
|
+
import {
|
|
32
|
+
orkeonConfigStore, orkeonFiles, orkeonSessionIo, orkeonShell, orkeonToolCatalogue,
|
|
33
|
+
} from "../../shared/infrastructure/orkeon/wiring.ts";
|
|
34
|
+
import type { CommandRuntimeContext } from "../.orkeon/orkeon-cli.d.ts";
|
|
35
|
+
|
|
36
|
+
const deps = { session: orkeonSessionIo(), config: orkeonConfigStore() };
|
|
37
|
+
|
|
38
|
+
/** The session's context as it is now: the mode, the rules and the github tool, read at the dispatch and before each hop. */
|
|
39
|
+
const contextReader = (ctx: CommandRuntimeContext) => () => readPullRequestContext({
|
|
40
|
+
catalogue: () => orkeonToolCatalogue(ctx.services), rules: () => createPermissionRules(ctx.services), session: deps.session,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
/** The run of a plan: the mode checked, the step started, what was read riding in the crew's input. */
|
|
44
|
+
async function runDispatch(args: Parameters<typeof batchesLaunchInput>[0], ctx: CommandRuntimeContext) {
|
|
45
|
+
const prContext = await contextReader(ctx)();
|
|
46
|
+
const line = writeModeRefusal(String(prContext.permissionMode ?? ""), "dev-batches", "writes files, commits and pushes")
|
|
47
|
+
?? batchesModeRefusal(args, String(prContext.permissionMode ?? ""));
|
|
48
|
+
if (line !== null) {
|
|
49
|
+
ctx.writeLine(line);
|
|
50
|
+
return { refused: line };
|
|
51
|
+
}
|
|
52
|
+
// The batches run the dev-implement step: its rule sets and its two allow rules (run_tests, run_build).
|
|
53
|
+
const start = await startDevStep("dev-implement", {
|
|
54
|
+
...deps, gate: createPermissionRules(ctx.services), catalogue: orkeonToolCatalogue(ctx.services),
|
|
55
|
+
});
|
|
56
|
+
if (!start.ok) {
|
|
57
|
+
ctx.writeLine(start.line);
|
|
58
|
+
return { refused: start.line };
|
|
59
|
+
}
|
|
60
|
+
for (const line of start.lines) ctx.writeLine(line);
|
|
61
|
+
const input = batchesLaunchInput(args, { ...start.input, effort: await storedEffort(deps.session), ...prContext });
|
|
62
|
+
return { input, details: { ruleSets: start.sets.join(" "), rules: start.rules, hooks: start.hooks.length } };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
defineAsyncCommand({
|
|
66
|
+
name: "dev-batches",
|
|
67
|
+
aliases: ["dev-implement", "dev-verify"],
|
|
68
|
+
description: "Run a plan's batches in dependency order (implement, audit, commit each), --concurrency n at once in worktrees, then one PR; <code> F<n>: one batch; F<n> --audit: its audit.",
|
|
69
|
+
maxConcurrent: 1,
|
|
70
|
+
dispatch: async (args, ctx) => {
|
|
71
|
+
const parsed = parseDevBatchesArgs(rawTokens(args), typedCommand(ctx.command?.rawInput, "dev-batches"));
|
|
72
|
+
if (!parsed.ok) {
|
|
73
|
+
ctx.writeLine(parsed.text);
|
|
74
|
+
return { refused: parsed.text };
|
|
75
|
+
}
|
|
76
|
+
const dispatchDeps = {
|
|
77
|
+
...deps, gate: () => createPermissionRules(ctx.services), catalogue: () => orkeonToolCatalogue(ctx.services),
|
|
78
|
+
write: (line: string) => ctx.writeLine(line),
|
|
79
|
+
};
|
|
80
|
+
const outcome = parsed.route === "run"
|
|
81
|
+
? await runDispatch(parsed.args, ctx)
|
|
82
|
+
: parsed.route === "batch"
|
|
83
|
+
? await runDevImplementDispatch(parsed.args, { ...dispatchDeps, files: orkeonFiles(), shell: orkeonShell() })
|
|
84
|
+
: await runDevVerifyDispatch(parsed.args, dispatchDeps);
|
|
85
|
+
if ("refused" in outcome) return outcome;
|
|
86
|
+
const unrecorded = await recordChain(deps.session, parsed.route);
|
|
87
|
+
if (unrecorded !== null) {
|
|
88
|
+
ctx.writeLine(unrecorded);
|
|
89
|
+
return { refused: unrecorded };
|
|
90
|
+
}
|
|
91
|
+
const crew = parsed.route === "run" ? "dev-batches" : parsed.route === "batch" ? "dev-implement" : "dev-verify";
|
|
92
|
+
return launchCrew(await withLlmProfile({ crews: createCrewHost(ctx.services), log: ctx.log }, orkeonConfigStore()), crew, outcome.input, outcome.details);
|
|
93
|
+
},
|
|
94
|
+
// Async: the host awaits it before the next completion (Orkeon #220). Caught whole: a failure prints its line
|
|
95
|
+
// and the command to type, never a bare `Error in completed('dev-batches')`.
|
|
96
|
+
completed: async (result, ctx) => {
|
|
97
|
+
try {
|
|
98
|
+
// No dispatch runs before a chained launch: the gate is checked and the step's rules put back here.
|
|
99
|
+
const completion = await devBatchesCompleted(result, {
|
|
100
|
+
session: deps.session, reapply: (crew) => reapplyStepRules(createPermissionRules(ctx.services), crew), context: contextReader(ctx),
|
|
101
|
+
});
|
|
102
|
+
for (const line of completion.lines) ctx.writeLine(line);
|
|
103
|
+
for (const line of await launchCompletedHop(completion, { crews: createCrewHost(ctx.services), log: ctx.log }, orkeonConfigStore())) ctx.writeLine(line);
|
|
104
|
+
} catch (e) {
|
|
105
|
+
ctx.writeLine(batchesHopFailedLine(e));
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/// <reference path="../.orkeon/orkeon-cli.d.ts" />
|
|
2
|
+
// /dev-learn [<axis>] [--list] | --accept <ids> | --refuse <id | text> — turn gaps that recur across dev batches into
|
|
3
|
+
// proposals. Proposing and listing read every verdict file, so they run in crews/dev-learn; --accept and --refuse are a
|
|
4
|
+
// few reads and one write, answered here.
|
|
5
|
+
import { rawTokens } from "../_lib/args.ts";
|
|
6
|
+
import { parseDevLearnArgs, runDevLearnDecision } from "../_lib/dev/dev.ts";
|
|
7
|
+
import { launchCrew, withLlmProfile, writeCompleted } from "../_lib/dispatch.ts";
|
|
8
|
+
import { createCrewHost } from "../../shared/infrastructure/orkeon/crew-host.ts";
|
|
9
|
+
import { orkeonClock, orkeonConfigStore, orkeonFiles, orkeonShell } from "../../shared/infrastructure/orkeon/wiring.ts";
|
|
10
|
+
|
|
11
|
+
const deps = { files: orkeonFiles(), shell: orkeonShell(), config: orkeonConfigStore(), clock: orkeonClock() };
|
|
12
|
+
|
|
13
|
+
defineAsyncCommand({
|
|
14
|
+
name: "dev-learn",
|
|
15
|
+
description: "Turn gaps that recur across dev batches into proposals (--list: the backlog; --accept/--refuse: decide).",
|
|
16
|
+
maxConcurrent: 1,
|
|
17
|
+
dispatch: async (args, ctx) => {
|
|
18
|
+
const parsed = parseDevLearnArgs(rawTokens(args));
|
|
19
|
+
if (!parsed.ok) {
|
|
20
|
+
ctx.writeLine(parsed.text);
|
|
21
|
+
return { refused: parsed.text };
|
|
22
|
+
}
|
|
23
|
+
const a = parsed.args;
|
|
24
|
+
if (a.kind === "accept" || a.kind === "refuse") return { message: await runDevLearnDecision(a, deps) };
|
|
25
|
+
return launchCrew(await withLlmProfile({ crews: createCrewHost(ctx.services), log: ctx.log }, orkeonConfigStore()), "dev-learn",
|
|
26
|
+
{ axis: a.axis, list: a.kind === "list" });
|
|
27
|
+
},
|
|
28
|
+
completed: (result, ctx) => writeCompleted(ctx, result, "dev-learn"),
|
|
29
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/// <reference path="../.orkeon/orkeon-cli.d.ts" />
|
|
2
|
+
// /dev-plan [<code> | <path>] [--replace] — turn a settled spec or change brief into a plan of batches. A Blocking
|
|
3
|
+
// open question stops it here, with no crew; the inventory, the model and the review run in crews/dev-plan.
|
|
4
|
+
// The host's gate must be on; the dev rule sets are put in it before the crew (_lib/dev-step.ts), and the crew's
|
|
5
|
+
// tool callbacks check them again and run the /hooks the input carries.
|
|
6
|
+
import { rawTokens } from "../_lib/args.ts";
|
|
7
|
+
import { devPlanGate, parseDevPlanArgs } from "../_lib/dev/dev.ts";
|
|
8
|
+
import { readWriteModeRefusal, startDevStep } from "../_lib/dev-step.ts";
|
|
9
|
+
import { storedEffort } from "../_lib/effort.ts";
|
|
10
|
+
import { launchCrew, withLlmProfile, writeCompleted } from "../_lib/dispatch.ts";
|
|
11
|
+
import { createCrewHost } from "../../shared/infrastructure/orkeon/crew-host.ts";
|
|
12
|
+
import { createPermissionRules } from "../../shared/infrastructure/orkeon/permission-rules.ts";
|
|
13
|
+
import {
|
|
14
|
+
orkeonConfigStore, orkeonFiles, orkeonSessionIo, orkeonShell, orkeonToolCatalogue,
|
|
15
|
+
} from "../../shared/infrastructure/orkeon/wiring.ts";
|
|
16
|
+
|
|
17
|
+
const deps = { files: orkeonFiles(), shell: orkeonShell(), config: orkeonConfigStore(), session: orkeonSessionIo() };
|
|
18
|
+
|
|
19
|
+
defineAsyncCommand({
|
|
20
|
+
name: "dev-plan",
|
|
21
|
+
description: "Plan a settled spec or change brief as batches: plan, one sheet per batch, a read-only review (--replace: plan again).",
|
|
22
|
+
maxConcurrent: 1,
|
|
23
|
+
dispatch: async (args, ctx) => {
|
|
24
|
+
const parsed = parseDevPlanArgs(rawTokens(args));
|
|
25
|
+
if (!parsed.ok) {
|
|
26
|
+
ctx.writeLine(parsed.text);
|
|
27
|
+
return { refused: parsed.text };
|
|
28
|
+
}
|
|
29
|
+
const stop = await devPlanGate(parsed.args, deps);
|
|
30
|
+
if (stop !== null) return { message: stop };
|
|
31
|
+
// The crew writes files through its own port, which no mode gates: a read-only mode refuses it here.
|
|
32
|
+
const readOnly = await readWriteModeRefusal(deps.session, "dev-plan", "writes files");
|
|
33
|
+
if (readOnly !== null) {
|
|
34
|
+
ctx.writeLine(readOnly);
|
|
35
|
+
return { refused: readOnly };
|
|
36
|
+
}
|
|
37
|
+
const start = await startDevStep("dev-plan", {
|
|
38
|
+
...deps, gate: createPermissionRules(ctx.services), catalogue: orkeonToolCatalogue(ctx.services),
|
|
39
|
+
});
|
|
40
|
+
if (!start.ok) {
|
|
41
|
+
ctx.writeLine(start.line);
|
|
42
|
+
return { refused: start.line };
|
|
43
|
+
}
|
|
44
|
+
for (const line of start.lines) ctx.writeLine(line);
|
|
45
|
+
const details = { ruleSets: start.sets.join(" "), rules: start.rules, hooks: start.hooks.length };
|
|
46
|
+
return launchCrew(
|
|
47
|
+
await withLlmProfile({ crews: createCrewHost(ctx.services), log: ctx.log }, orkeonConfigStore()), "dev-plan",
|
|
48
|
+
{ ...parsed.args, ...start.input, effort: await storedEffort(deps.session) }, details,
|
|
49
|
+
);
|
|
50
|
+
},
|
|
51
|
+
completed: (result, ctx) => writeCompleted(ctx, result, "dev-plan"),
|
|
52
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/// <reference path="../.orkeon/orkeon-cli.d.ts" />
|
|
2
|
+
// /dev-spec <code> [bug|refactor|perf] [--run "<command>"] [<brief> | <path>.md | <#issue> | <revision request>] —
|
|
3
|
+
// write or revise the source of a piece of work, then settle its open questions with the person, one at a time.
|
|
4
|
+
// Without a kind it is a business spec (crews/dev-spec); with one it is a change brief (crews/dev-change): the bug
|
|
5
|
+
// reproduced or the cost measured first, and a request the model finds to be a feature goes on as a spec in the same
|
|
6
|
+
// run. /dev-change is an alias that keeps its own shape (_lib/dev/dev-source.ts). The step runs in a crew of its own,
|
|
7
|
+
// never in the conversation: a fresh context and the reviewer's read tools. The host's gate must be on; the dev rule
|
|
8
|
+
// sets are put in it before the crew (_lib/dev-step.ts), and the crew's tool callbacks check them again and run the /hooks.
|
|
9
|
+
import { rawTokens, typedCommand } from "../_lib/args.ts";
|
|
10
|
+
import { parseDevSpecArgs } from "../_lib/dev/dev-source.ts";
|
|
11
|
+
import { readWriteModeRefusal, startDevStep } from "../_lib/dev-step.ts";
|
|
12
|
+
import { launchCrew, withLlmProfile, writeCompleted } from "../_lib/dispatch.ts";
|
|
13
|
+
import { storedEffort } from "../_lib/effort.ts";
|
|
14
|
+
import { createCrewHost } from "../../shared/infrastructure/orkeon/crew-host.ts";
|
|
15
|
+
import { createPermissionRules } from "../../shared/infrastructure/orkeon/permission-rules.ts";
|
|
16
|
+
import {
|
|
17
|
+
orkeonConfigStore, orkeonFiles, orkeonSessionIo, orkeonShell, orkeonToolCatalogue,
|
|
18
|
+
} from "../../shared/infrastructure/orkeon/wiring.ts";
|
|
19
|
+
|
|
20
|
+
const deps = { files: orkeonFiles(), shell: orkeonShell(), config: orkeonConfigStore(), session: orkeonSessionIo() };
|
|
21
|
+
|
|
22
|
+
defineAsyncCommand({
|
|
23
|
+
name: "dev-spec",
|
|
24
|
+
aliases: ["dev-change"],
|
|
25
|
+
description: "Write or revise a business spec, or with a kind (bug, refactor, perf) a change brief proven by running; its open questions one at a time, then a read-only review.",
|
|
26
|
+
maxConcurrent: 1,
|
|
27
|
+
dispatch: async (args, ctx) => {
|
|
28
|
+
const parsed = parseDevSpecArgs(rawTokens(args), typedCommand(ctx.command?.rawInput, "dev-spec"));
|
|
29
|
+
if (!parsed.ok) {
|
|
30
|
+
ctx.writeLine(parsed.text);
|
|
31
|
+
return { refused: parsed.text };
|
|
32
|
+
}
|
|
33
|
+
const crew = parsed.crew;
|
|
34
|
+
// The crew writes files through its own port, which no mode gates: a read-only mode refuses it here.
|
|
35
|
+
const readOnly = await readWriteModeRefusal(deps.session, crew, "writes files");
|
|
36
|
+
if (readOnly !== null) {
|
|
37
|
+
ctx.writeLine(readOnly);
|
|
38
|
+
return { refused: readOnly };
|
|
39
|
+
}
|
|
40
|
+
const start = await startDevStep(crew, {
|
|
41
|
+
...deps, gate: createPermissionRules(ctx.services), catalogue: orkeonToolCatalogue(ctx.services),
|
|
42
|
+
});
|
|
43
|
+
if (!start.ok) {
|
|
44
|
+
ctx.writeLine(start.line);
|
|
45
|
+
return { refused: start.line };
|
|
46
|
+
}
|
|
47
|
+
for (const line of start.lines) ctx.writeLine(line);
|
|
48
|
+
const details = { ruleSets: start.sets.join(" "), rules: start.rules, hooks: start.hooks.length };
|
|
49
|
+
return launchCrew(
|
|
50
|
+
await withLlmProfile({ crews: createCrewHost(ctx.services), log: ctx.log }, orkeonConfigStore()), crew,
|
|
51
|
+
{ ...parsed.args, ...start.input, effort: await storedEffort(deps.session) }, details,
|
|
52
|
+
);
|
|
53
|
+
},
|
|
54
|
+
completed: (result, ctx) => writeCompleted(ctx, result, String(result.intent || "dev-spec")),
|
|
55
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference path="../.orkeon/orkeon-cli.d.ts" />
|
|
2
|
+
// /dev-status — where a piece of dev work stands: the work folder, the pack, and per batch the
|
|
3
|
+
// plan state, the TDD ticks and the last verdict. Read-only. Entry point: wires the files, the
|
|
4
|
+
// shell and the config store into _lib/dev/dev.ts (runDevStatus).
|
|
5
|
+
import { rawTokens } from "../_lib/args.ts";
|
|
6
|
+
import { runDevStatus } from "../_lib/dev/dev.ts";
|
|
7
|
+
import { showView } from "../_lib/view.ts";
|
|
8
|
+
import { orkeonConfigStore, orkeonFiles, orkeonShell } from "../../shared/infrastructure/orkeon/wiring.ts";
|
|
9
|
+
|
|
10
|
+
const deps = { files: orkeonFiles(), shell: orkeonShell(), config: orkeonConfigStore() };
|
|
11
|
+
|
|
12
|
+
defineCommand({
|
|
13
|
+
name: "dev-status",
|
|
14
|
+
description: "Show where a piece of dev work stands: batches, TDD ticks and last verdict (read-only).",
|
|
15
|
+
handler: async (args, ctx) => showView(ctx, await runDevStatus(rawTokens(args), deps)),
|
|
16
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/// <reference path="../.orkeon/orkeon-cli.d.ts" />
|
|
2
|
+
// /branch [name] — show the current git branch, or check out the given one
|
|
3
|
+
// (baseline 04 §/branch).
|
|
4
|
+
//
|
|
5
|
+
// B-11 finding, fixed here rather than only tabled: the baseline says the handler
|
|
6
|
+
// "optionally prompts the user for confirmation (especially if uncommitted changes
|
|
7
|
+
// exist)" and the first version checked out unconditionally. `git checkout` on a dirty tree
|
|
8
|
+
// either fails with git's own error or CARRIES the changes onto the new branch —
|
|
9
|
+
// and the second outcome is the one that loses work quietly, because it looks like
|
|
10
|
+
// a successful switch.
|
|
11
|
+
//
|
|
12
|
+
// A refusal, not a prompt: the REPL's confirmation channel is not available to a
|
|
13
|
+
// synchronous command handler here (the same reason /commit's gate is a separate
|
|
14
|
+
// step), and between refusing and silently carrying changes across, refusing is the
|
|
15
|
+
// one that cannot cost work. The message names both ways out.
|
|
16
|
+
import { orkeonShell } from "../../shared/infrastructure/orkeon/wiring.ts";
|
|
17
|
+
import { rawTokens } from "../_lib/args.ts";
|
|
18
|
+
import { runBranch } from "../_lib/git/branch.ts";
|
|
19
|
+
import { showView } from "../_lib/view.ts";
|
|
20
|
+
|
|
21
|
+
const shell = orkeonShell();
|
|
22
|
+
|
|
23
|
+
defineCommand({
|
|
24
|
+
name: "branch",
|
|
25
|
+
description: "Show the current git branch, or check out the given one (refuses on a dirty tree).",
|
|
26
|
+
handler: async (args, ctx) => showView(ctx, await runBranch(rawTokens(args), { shell, log: ctx.log })),
|
|
27
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/// <reference path="../.orkeon/orkeon-cli.d.ts" />
|
|
2
|
+
// /commit — draft + create a Conventional-Commits commit via the git-commit crew (SPEC §5.1).
|
|
3
|
+
//
|
|
4
|
+
// B-1: the launch is GATED. Until this item, `/commit` staged the entire working
|
|
5
|
+
// tree and committed it with no confirmation and no permission check — the
|
|
6
|
+
// framework's IPermissionGate only fires inside the `act` tool-calling loop, and
|
|
7
|
+
// the git-commit crew commits from its body, so nothing consulted anything
|
|
8
|
+
// (round-40 finding `commit-no-confirmation`). The original gates every
|
|
9
|
+
// destructive action through its decision table (baseline 08 §Decision table).
|
|
10
|
+
//
|
|
11
|
+
// Three things now stand between the command and a rewritten repository:
|
|
12
|
+
// 1. the effective permission mode is threaded into the crew inputs, exactly
|
|
13
|
+
// as assistant.cmd.ts threads it to main-loop, and the crew refuses the
|
|
14
|
+
// read-only modes before spending anything;
|
|
15
|
+
// 2. an interactive session must confirm a plan that names the file list (every
|
|
16
|
+
// change, untracked files too, or the paths named; never the work folder);
|
|
17
|
+
// 3. a NON-interactive session without `--yes` is refused, not auto-approved —
|
|
18
|
+
// the one case where a confirmation prompt silently degrades into consent.
|
|
19
|
+
//
|
|
20
|
+
// The gate is _lib/git/commit.ts; this file wires it to the session, the prompt and the
|
|
21
|
+
// pull-request context, then launches the crew with the input it builds.
|
|
22
|
+
import { rawTokens } from "../_lib/args.ts";
|
|
23
|
+
import { runCommitCommand } from "../_lib/git/commit.ts";
|
|
24
|
+
import { launchCrew, withLlmProfile, writeCompleted } from "../_lib/dispatch.ts";
|
|
25
|
+
import { createCrewHost } from "../../shared/infrastructure/orkeon/crew-host.ts";
|
|
26
|
+
import { createPermissionRules } from "../../shared/infrastructure/orkeon/permission-rules.ts";
|
|
27
|
+
import { orkeonConfigStore, orkeonSessionIo, orkeonToolCatalogue } from "../../shared/infrastructure/orkeon/wiring.ts";
|
|
28
|
+
|
|
29
|
+
const session = orkeonSessionIo();
|
|
30
|
+
|
|
31
|
+
defineAsyncCommand({
|
|
32
|
+
name: "commit",
|
|
33
|
+
description: "Draft and create a conventional commit of the changes or the paths named, the work folder only if named (confirms; --yes skips; --push pushes; --pr opens the PR; --note \"<why>\", several words quoted).",
|
|
34
|
+
maxConcurrent: 1,
|
|
35
|
+
dispatch: async (args, ctx) => {
|
|
36
|
+
const outcome = await runCommitCommand(rawTokens(args), {
|
|
37
|
+
session,
|
|
38
|
+
// ctx.prompt needs an interactive console: in a headless session it throws or answers no boolean.
|
|
39
|
+
confirm: (question) => ctx.prompt({ type: "confirm", message: question, default: false }),
|
|
40
|
+
write: (line) => ctx.writeLine(line),
|
|
41
|
+
log: ctx.log,
|
|
42
|
+
pr: { catalogue: () => orkeonToolCatalogue(ctx.services), rules: () => createPermissionRules(ctx.services), session },
|
|
43
|
+
});
|
|
44
|
+
if ("refused" in outcome) return outcome;
|
|
45
|
+
return launchCrew(await withLlmProfile({ crews: createCrewHost(ctx.services), log: ctx.log }, orkeonConfigStore()), "git-commit", outcome.input);
|
|
46
|
+
},
|
|
47
|
+
completed: (result, ctx) => writeCompleted(ctx, result, "commit"),
|
|
48
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/// <reference path="../.orkeon/orkeon-cli.d.ts" />
|
|
2
|
+
// /diff [--staged] [pathspec…] — unified diff of the working tree, or of the
|
|
3
|
+
// staged changes (baseline 04 §/diff).
|
|
4
|
+
//
|
|
5
|
+
// B-11 deepening. Two gaps against the baseline:
|
|
6
|
+
// 1. `staged` is a DECLARED option there; here every token was appended to
|
|
7
|
+
// `git diff` verbatim. Not an injection (the shell tool bans operators and
|
|
8
|
+
// allowlists git) but an unbounded surface: `--output=/tmp/x` is a plain git
|
|
9
|
+
// option that writes a file, and nothing stood in the way.
|
|
10
|
+
// 2. an empty diff printed "(no output)", where the baseline says
|
|
11
|
+
// "No changes to show." — the difference matters because "(no output)" reads
|
|
12
|
+
// like the command itself failed to produce any.
|
|
13
|
+
// Options and pathspecs are now allowlisted, refusals are named, and the scope is
|
|
14
|
+
// stated so `--staged` shows up in the OUTPUT and not only in the input.
|
|
15
|
+
import { orkeonShell } from "../../shared/infrastructure/orkeon/wiring.ts";
|
|
16
|
+
import { rawTokens } from "../_lib/args.ts";
|
|
17
|
+
import { runDiff } from "../_lib/git/diff.ts";
|
|
18
|
+
import { showView } from "../_lib/view.ts";
|
|
19
|
+
|
|
20
|
+
const shell = orkeonShell();
|
|
21
|
+
|
|
22
|
+
defineCommand({
|
|
23
|
+
name: "diff",
|
|
24
|
+
description: "Show the working-tree diff, or the staged diff with --staged.",
|
|
25
|
+
handler: async (args, ctx) => showView(ctx, await runDiff(rawTokens(args), { shell, log: ctx.log })),
|
|
26
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/// <reference path="../.orkeon/orkeon-cli.d.ts" />
|
|
2
|
+
// /review [<path>…] [--commit <sha>] [--lens <lens>] [--passes <1-5>] — multi-lens code review of the staged changes
|
|
3
|
+
// via the code-review crew; --lens narrows it to one lens (correctness for a bug hunt), outranking the review.lenses
|
|
4
|
+
// setting, and --passes sets this run's round count, outranking the session's. Two aliases keep their own shape
|
|
5
|
+
// (_lib/git/review.ts): /security-review is the review narrowed to the security lens — not a second crew but one
|
|
6
|
+
// facet of this one, passed as a crew input so it outranks review.lenses, and so a security pass inherits the scope
|
|
7
|
+
// validation (a review asked to look at two paths looks at those two); /passes [n] shows or sets the session's pass
|
|
8
|
+
// count, answered here without launching a review. The crew is launched exclusively (Orkeon #239): the host refuses
|
|
9
|
+
// a review while one runs, with its ticket; the command has no instance quota, so /passes still answers meanwhile.
|
|
10
|
+
import { rawTokens, typedCommand } from "../_lib/args.ts";
|
|
11
|
+
import { launchCrew, withLlmProfile, writeCompleted } from "../_lib/dispatch.ts";
|
|
12
|
+
import { REVIEW_CREW, parseReviewArgs, runPasses } from "../_lib/git/review.ts";
|
|
13
|
+
import { showView } from "../_lib/view.ts";
|
|
14
|
+
import { createCrewHost } from "../../shared/infrastructure/orkeon/crew-host.ts";
|
|
15
|
+
import { orkeonConfigStore, orkeonSessionIo } from "../../shared/infrastructure/orkeon/wiring.ts";
|
|
16
|
+
|
|
17
|
+
const session = orkeonSessionIo();
|
|
18
|
+
|
|
19
|
+
defineAsyncCommand({
|
|
20
|
+
name: "review",
|
|
21
|
+
aliases: ["security-review", "passes"],
|
|
22
|
+
description: "Run a multi-lens code review on staged changes; --lens correctness|security|style keeps one lens, --passes 1-5 sets this run's rounds.",
|
|
23
|
+
dispatch: async (args, ctx) => {
|
|
24
|
+
const parsed = parseReviewArgs(rawTokens(args), typedCommand(ctx.command?.rawInput, "review"));
|
|
25
|
+
if (parsed.route === "refused") {
|
|
26
|
+
ctx.writeLine(parsed.text);
|
|
27
|
+
return { refused: parsed.text };
|
|
28
|
+
}
|
|
29
|
+
if (parsed.route === "passes") return showView(ctx, await runPasses(parsed.token, { session }));
|
|
30
|
+
return launchCrew(await withLlmProfile({ crews: createCrewHost(ctx.services), log: ctx.log }, orkeonConfigStore()), REVIEW_CREW, { ...parsed.input }, {}, { exclusive: true });
|
|
31
|
+
},
|
|
32
|
+
completed: (result, ctx) => {
|
|
33
|
+
const name = typedCommand(ctx.command?.rawInput, "review");
|
|
34
|
+
writeCompleted(ctx, result, name, `✓ ${name} → `);
|
|
35
|
+
},
|
|
36
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/// <reference path="../.orkeon/orkeon-cli.d.ts" />
|
|
2
|
+
// /memory <list|add|delete|get> ... — typed memory CRUD (SPEC §5.2), answered here; /memory admit [<id>…] |
|
|
3
|
+
// --refuse <id> [<motif>] | --list | --import — decide the shared memory's candidates (_lib/memory/memory-admit.ts):
|
|
4
|
+
// the list, a refusal and the import are answered here, an admission is confirmed here, then written and indexed
|
|
5
|
+
// by the crew shared-memory-admit. Two aliases keep their own shape (_lib/memory/memory.ts): /feedback <text> is a
|
|
6
|
+
// 'feedback' memory, /memory-admit … the admit sub-verb. The crew is launched exclusively (Orkeon #239): the host
|
|
7
|
+
// refuses an admission while it still writes the previous one, with its ticket; the command has no instance quota,
|
|
8
|
+
// so the CRUD, /feedback and the other admit verbs still answer meanwhile.
|
|
9
|
+
import { rawTokens, typedCommand } from "../_lib/args.ts";
|
|
10
|
+
import { launchCrew, withLlmProfile, writeCompleted } from "../_lib/dispatch.ts";
|
|
11
|
+
import { admitTokens, runMemory } from "../_lib/memory/memory.ts";
|
|
12
|
+
import { MEMORY_ADMIT_CREW, parseMemoryAdmitArgs, runMemoryAdmit } from "../_lib/memory/memory-admit.ts";
|
|
13
|
+
import { showView } from "../_lib/view.ts";
|
|
14
|
+
import { createCrewHost } from "../../shared/infrastructure/orkeon/crew-host.ts";
|
|
15
|
+
import {
|
|
16
|
+
orkeonClock, orkeonConfigStore, orkeonFiles, orkeonMemoryStore, orkeonShell,
|
|
17
|
+
} from "../../shared/infrastructure/orkeon/wiring.ts";
|
|
18
|
+
|
|
19
|
+
const memory = orkeonMemoryStore();
|
|
20
|
+
const admitDeps = { files: orkeonFiles(), shell: orkeonShell(), config: orkeonConfigStore(), clock: orkeonClock() };
|
|
21
|
+
|
|
22
|
+
defineAsyncCommand({
|
|
23
|
+
name: "memory",
|
|
24
|
+
aliases: ["feedback", "memory-admit"],
|
|
25
|
+
description: "List, add, delete, or get typed memory entries (user/project/feedback/reference); admit decides the shared memory's candidates (--list, --refuse <id>, --import).",
|
|
26
|
+
dispatch: async (args, ctx) => {
|
|
27
|
+
const tokens = rawTokens(args);
|
|
28
|
+
const typed = typedCommand(ctx.command?.rawInput, "memory");
|
|
29
|
+
const admit = admitTokens(tokens, typed);
|
|
30
|
+
if (admit === null) return showView(ctx, await runMemory(tokens, { memory }, typed));
|
|
31
|
+
const parsed = parseMemoryAdmitArgs(admit);
|
|
32
|
+
if (!parsed.ok) {
|
|
33
|
+
ctx.writeLine(parsed.text);
|
|
34
|
+
return { refused: parsed.text };
|
|
35
|
+
}
|
|
36
|
+
const result = await runMemoryAdmit(parsed.args, admitDeps, {
|
|
37
|
+
writeLine: (text) => ctx.writeLine(text),
|
|
38
|
+
confirm: (message) => ctx.prompt({ type: "confirm", message, default: false }),
|
|
39
|
+
});
|
|
40
|
+
if ("admit" in result) {
|
|
41
|
+
if (result.refusedQuestions !== undefined) ctx.writeLine(`✗ ${result.refusedQuestions}`);
|
|
42
|
+
return launchCrew(await withLlmProfile({ crews: createCrewHost(ctx.services), log: ctx.log }, orkeonConfigStore()), MEMORY_ADMIT_CREW, { admit: result.admit }, {}, { exclusive: true });
|
|
43
|
+
}
|
|
44
|
+
if ("refused" in result) ctx.writeLine(`✗ ${result.refused}`);
|
|
45
|
+
return result;
|
|
46
|
+
},
|
|
47
|
+
completed: (result, ctx) => writeCompleted(ctx, result, "memory admit"),
|
|
48
|
+
});
|