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,32 @@
|
|
|
1
|
+
// What a close needs to open the pull request itself: the github tool, the session's mode and rules. Read at
|
|
2
|
+
// a dev command's dispatch, and again by its `completed` before each hop that writes (Orkeon #220: the host awaits
|
|
3
|
+
// an async `completed`); the crew keeps the dispatch's reading (the batch record, the /dev-batches run record) for
|
|
4
|
+
// a typed close and for the hop whose read failed. Not a command file: the loader reads *.cmd.ts only. The entry point hands the ports, each made when read: a host
|
|
5
|
+
// without the service fails there, and that read says nothing.
|
|
6
|
+
import type { SessionIo } from "../../shared/application/session-io.ts";
|
|
7
|
+
import { GITHUB_TOOL } from "../../shared/domain/git/pull-request.ts";
|
|
8
|
+
|
|
9
|
+
export interface PullRequestContext { githubTool: boolean; permissionRules: string[]; permissionMode: string }
|
|
10
|
+
|
|
11
|
+
export interface PullRequestContextPorts {
|
|
12
|
+
catalogue: () => { find(name: string): unknown };
|
|
13
|
+
rules: () => { available(): boolean; list(): string[] };
|
|
14
|
+
session: Pick<SessionIo, "resolveEffectiveSessionMode">;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export async function readPullRequestContext(ports: PullRequestContextPorts): Promise<PullRequestContext> {
|
|
18
|
+
let githubTool = false;
|
|
19
|
+
let permissionRules: string[] = [];
|
|
20
|
+
let permissionMode = "";
|
|
21
|
+
try {
|
|
22
|
+
githubTool = ports.catalogue().find(GITHUB_TOOL) !== undefined;
|
|
23
|
+
} catch { /* no tools service: the command is handed over */ }
|
|
24
|
+
try {
|
|
25
|
+
const rules = ports.rules();
|
|
26
|
+
if (rules.available()) permissionRules = rules.list();
|
|
27
|
+
} catch { /* no rules service: none */ }
|
|
28
|
+
try {
|
|
29
|
+
permissionMode = (await ports.session.resolveEffectiveSessionMode()).mode;
|
|
30
|
+
} catch { /* unknown mode, "": the opener refuses and hands the command over, and writeModeRefusal (dev-step.ts) refuses the step */ }
|
|
31
|
+
return { githubTool, permissionRules, permissionMode };
|
|
32
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// /analyze's use case: the crew input built from the command's flags and the session's `answer.language`, so the
|
|
2
|
+
// synthesis is written in the language the session answers in (crews/analyze).
|
|
3
|
+
import type { ConfigStore } from "../../../shared/application/config-store.ts";
|
|
4
|
+
import { readLanguage } from "../../../shared/application/answer-language.ts";
|
|
5
|
+
|
|
6
|
+
/** The flags of /analyze as the runtime parses them. */
|
|
7
|
+
export interface AnalyzeArgs {
|
|
8
|
+
raw?: unknown;
|
|
9
|
+
parallel?: unknown;
|
|
10
|
+
rebuild?: unknown;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** The input of the analyze crew: the flags, plus `language` when the session sets `answer.language`. */
|
|
14
|
+
export async function analyzeInput(
|
|
15
|
+
args: AnalyzeArgs, config: Pick<ConfigStore, "readValue">,
|
|
16
|
+
): Promise<{ raw: boolean; parallel: unknown; rebuild: boolean; language?: string }> {
|
|
17
|
+
const language = await readLanguage(config);
|
|
18
|
+
return {
|
|
19
|
+
raw: args.raw === true,
|
|
20
|
+
parallel: args.parallel,
|
|
21
|
+
rebuild: args.rebuild === true,
|
|
22
|
+
...(language !== "" ? { language } : {}),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// The text the project commands show the user (ADR 0026): /debug-tool-call.
|
|
2
|
+
|
|
3
|
+
export const toolCatalogue = (names: readonly string[]): string =>
|
|
4
|
+
`${names.length} registered tools:\n${names.join(", ")}\n` +
|
|
5
|
+
"usage: /debug-tool-call <tool_name> [{\"arg\": \"value\"}]\n" +
|
|
6
|
+
"(argument schemas are not exposed to script-land — # TBD_tool_schema)";
|
|
7
|
+
export const noRegisteredToolSeeList = (tool: string): string =>
|
|
8
|
+
`no registered tool '${tool}'. /debug-tool-call list shows what this host has.`;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// /export — conversation, memory and cost as one markdown document, as the
|
|
2
|
+
// baseline specifies (B-11 deepening); runExport reads them over the ports and
|
|
3
|
+
// writes the file. Lives under commands/_lib/ — the loader's SearchPattern is
|
|
4
|
+
// "*.cmd.ts", so this file is never loaded as a command.
|
|
5
|
+
|
|
6
|
+
import type {
|
|
7
|
+
Files, MemoryStore, SessionCost, SessionMessages, SessionStore, Telemetry,
|
|
8
|
+
} from "../../../shared/application/ports.ts";
|
|
9
|
+
import { MEMORY_CATEGORIES } from "../../../shared/domain/agent-policy/memory-categories.ts";
|
|
10
|
+
import type { CommandView } from "../view.ts";
|
|
11
|
+
import { EMPTY_SESSION_BUFFER, exported } from "./messages.ts";
|
|
12
|
+
|
|
13
|
+
export interface ExportInputs {
|
|
14
|
+
messages: ReadonlyArray<{ role?: unknown; content?: unknown }>;
|
|
15
|
+
memory: Readonly<Record<string, readonly string[]>>;
|
|
16
|
+
cost: { totalTokens?: unknown; costUsd?: unknown; calls?: unknown };
|
|
17
|
+
/** Passed in rather than read here: this module is pure. */
|
|
18
|
+
generatedAt?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The exported markdown.
|
|
23
|
+
*
|
|
24
|
+
* Baseline 04 §/export: "conversation history, typed memory entries, and cost/token
|
|
25
|
+
* usage". The pre-B-11 handler wrote the conversation alone, which is the part that
|
|
26
|
+
* is already recoverable from the session; the memory and the cost are the two an
|
|
27
|
+
* export exists to preserve. Sections are omitted when empty rather than rendered
|
|
28
|
+
* as headings over nothing — an export with "## Memory" and no entries reads as
|
|
29
|
+
* data loss.
|
|
30
|
+
*/
|
|
31
|
+
export function renderSessionExport(i: ExportInputs): string {
|
|
32
|
+
const out: string[] = ["# Session Export", ""];
|
|
33
|
+
if (i.generatedAt) out.push(`_generated ${i.generatedAt}_`, "");
|
|
34
|
+
|
|
35
|
+
const cost = Number(i.cost?.costUsd ?? 0) || 0;
|
|
36
|
+
out.push(
|
|
37
|
+
"## Usage",
|
|
38
|
+
"",
|
|
39
|
+
`- Messages: ${i.messages.length}`,
|
|
40
|
+
`- LLM calls: ${Number(i.cost?.calls ?? 0) || 0}`,
|
|
41
|
+
`- Tokens: ${Number(i.cost?.totalTokens ?? 0) || 0}`,
|
|
42
|
+
`- Cost: $${cost.toFixed(4)}`,
|
|
43
|
+
"",
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const categories = Object.entries(i.memory ?? {}).filter(([, v]) => (v?.length ?? 0) > 0);
|
|
47
|
+
if (categories.length > 0) {
|
|
48
|
+
out.push("## Memory", "");
|
|
49
|
+
for (const [category, entries] of categories) {
|
|
50
|
+
out.push(`### ${category}`, "");
|
|
51
|
+
for (const e of entries) out.push(`- ${e}`);
|
|
52
|
+
out.push("");
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
out.push("## Conversation", "");
|
|
57
|
+
if (i.messages.length === 0) {
|
|
58
|
+
out.push(EMPTY_SESSION_BUFFER, "");
|
|
59
|
+
} else {
|
|
60
|
+
for (const m of i.messages) {
|
|
61
|
+
out.push(`**${String(m.role ?? "?")}:** ${String(m.content ?? "")}`, "");
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return out.join("\n");
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export const DEFAULT_EXPORT_PATH = "/output/session-export.md";
|
|
68
|
+
|
|
69
|
+
export interface ExportDeps {
|
|
70
|
+
session: Pick<SessionStore, "readMessages">;
|
|
71
|
+
telemetry: Pick<Telemetry, "readCost">;
|
|
72
|
+
memory: Pick<MemoryStore, "list">;
|
|
73
|
+
files: Pick<Files, "write">;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** `/export [path]`, from the command's raw tokens: the session written as markdown. */
|
|
77
|
+
export async function runExport(tokens: readonly string[], deps: ExportDeps): Promise<CommandView> {
|
|
78
|
+
const path = tokens[0] ?? DEFAULT_EXPORT_PATH;
|
|
79
|
+
|
|
80
|
+
const [buffer, cost] = await Promise.all([
|
|
81
|
+
deps.session.readMessages().catch((): SessionMessages => ({ stored: [], messages: [] })),
|
|
82
|
+
deps.telemetry.readCost().catch((): SessionCost => ({})),
|
|
83
|
+
]);
|
|
84
|
+
|
|
85
|
+
// Per-category, and per-category tolerant: one unavailable category must not
|
|
86
|
+
// cost the export its other three.
|
|
87
|
+
const memory: Record<string, string[]> = {};
|
|
88
|
+
for (const category of MEMORY_CATEGORIES) {
|
|
89
|
+
try {
|
|
90
|
+
const contents = (await deps.memory.list(category)).map((e) => e.content).filter((c) => c.length > 0);
|
|
91
|
+
if (contents.length > 0) memory[category] = contents;
|
|
92
|
+
} catch { /* category unavailable → omitted, not empty-headed */ }
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const messages = buffer.stored as Array<{ role?: unknown; content?: unknown }>;
|
|
96
|
+
const md = renderSessionExport({
|
|
97
|
+
messages,
|
|
98
|
+
memory,
|
|
99
|
+
cost: { totalTokens: cost.totalTokens, costUsd: cost.costUsd, calls: cost.totalCalls },
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
await deps.files.write(path, md);
|
|
103
|
+
const memoryCount = Object.values(memory).reduce((n, v) => n + v.length, 0);
|
|
104
|
+
return { text: exported(path, messages.length, memoryCount) };
|
|
105
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// The text the session commands show the user (ADR 0026): /resume, /tasks, /export, /copy, /rename and /rewind.
|
|
2
|
+
|
|
3
|
+
// /resume
|
|
4
|
+
|
|
5
|
+
/** What the listing says under the table. */
|
|
6
|
+
export const HOW_TO_RESUME =
|
|
7
|
+
"`/resume <number or id>` brings one back in place of this session, which is archived; " +
|
|
8
|
+
"`orkeon-code --resume <id>` does the same at start, `orkeon-code --continue` brings back the session you quit.";
|
|
9
|
+
|
|
10
|
+
/** What a host that does not persist the session leaves `/resume <n|id>` with. */
|
|
11
|
+
export const NO_SWITCH =
|
|
12
|
+
"cannot switch in place: the REPL runs without a persisted session (Orkeon:Cli:Session:Persist off); " +
|
|
13
|
+
"quit (/exit), then start `orkeon-code --resume <id>`.";
|
|
14
|
+
|
|
15
|
+
export const ambiguousSession = (choice: string): string =>
|
|
16
|
+
`more than one saved session starts with '${choice}': give more of its id.`;
|
|
17
|
+
export const noSavedSession = (choice: string): string => `no saved session '${choice}' (/resume lists them).`;
|
|
18
|
+
export const sessionLoaded = (id: string, count: number, archive: string): string =>
|
|
19
|
+
`loaded ${id} (${count} message(s)): the next turn continues it. ` +
|
|
20
|
+
`The session you left is archived at ${archive}; the next start of orkeon-code moves it to the history.`;
|
|
21
|
+
export const loadFailed = (id: string, reason: string, archive: string): string =>
|
|
22
|
+
`could not load ${id}: ${reason}. This session is unchanged${archive ? `; its archive ${archive} stays` : ""}.`;
|
|
23
|
+
export const historyNotMountedToLoad = (root: string): string =>
|
|
24
|
+
`no saved session to load: ${root} is not mounted (start the REPL with orkeon-code).`;
|
|
25
|
+
export const NOTHING_TO_LOAD = "no saved session to load: this project has none yet.";
|
|
26
|
+
export const historyNotMountedToList = (root: string): string =>
|
|
27
|
+
`no saved sessions to list: ${root} is not mounted (start the REPL with orkeon-code).`;
|
|
28
|
+
export const NO_SAVED_SESSIONS = "no saved session for this project yet: the next start of orkeon-code keeps this one.";
|
|
29
|
+
export const savedSessionsHeader = (count: number, more: number): string =>
|
|
30
|
+
`${count} saved session(s) of this project, newest first${more > 0 ? ` (${more} more: orkeon-code --resume lists them all)` : ""}.`;
|
|
31
|
+
export const EMPTY_BUFFER = "this session's buffer is empty.";
|
|
32
|
+
export const bufferTail = (count: number, tail: readonly string[]): string =>
|
|
33
|
+
`this session: ${count} message(s) in the buffer. Last turns:\n${tail.join("\n")}`;
|
|
34
|
+
|
|
35
|
+
// /tasks
|
|
36
|
+
|
|
37
|
+
export const TASKS_USAGE =
|
|
38
|
+
"usage: /tasks [list | add <subject> | done <n> | clear | show <id> | stop <id> | send <id> <message> | repair <id> [note]]";
|
|
39
|
+
|
|
40
|
+
/** What to do with an approval listed: the answers the main prompt takes. */
|
|
41
|
+
export const ANSWER_TEXT = "answer it from the main prompt: [y] once / [s] session / [n] no";
|
|
42
|
+
|
|
43
|
+
export const waitsForApproval = (task: string, tool: string, input: string): string =>
|
|
44
|
+
`${task}: waits for approval of ${tool} · ${input}`;
|
|
45
|
+
export const NO_TASKS = "no tasks and no agent instances. usage: /tasks add <subject>";
|
|
46
|
+
export const WAITING_FOR_APPROVAL = "waiting for approval:";
|
|
47
|
+
export const INSTANCE_VERBS = "/tasks show <id> · stop <id> · send <id> <message> · repair <id> [note]";
|
|
48
|
+
export const requestAlreadyWaiting = (ref: string, id: string): string =>
|
|
49
|
+
`${ref}: a request the crew has not read yet is already waiting; /tasks show ${id} once it has`;
|
|
50
|
+
export const repairByNewRun = (ref: string, charter: string): string =>
|
|
51
|
+
`${ref} has ended: a new run of ${charter} answers, with the previous report in its brief (not its live context).`;
|
|
52
|
+
export const TASKS_ADD_USAGE = "usage: /tasks add <subject>";
|
|
53
|
+
export const taskAdded = (n: number, subject: string): string => `task #${n} added: ${subject}`;
|
|
54
|
+
export const tasksDoneUsage = (max: number): string => `usage: /tasks done <1-${max}>`;
|
|
55
|
+
export const taskDone = (n: number, subject: string): string => `task #${n} done: ${subject}`;
|
|
56
|
+
export const tasksCleared = (count: number): string => `task list cleared (${count} removed).`;
|
|
57
|
+
export const stopAsked = (ref: string): string =>
|
|
58
|
+
`stop asked for ${ref}: the crew ends it at its next look (about a second); /tasks shows it`;
|
|
59
|
+
export const TASKS_SEND_USAGE = "usage: /tasks send <id> <message>";
|
|
60
|
+
export const repairWhileRunning = (ref: string, id: string): string =>
|
|
61
|
+
`${ref} is running: a repair is for an ended instance (/tasks stop ${id} first)`;
|
|
62
|
+
|
|
63
|
+
// /export
|
|
64
|
+
|
|
65
|
+
export const EMPTY_SESSION_BUFFER = "_(the session buffer is empty)_";
|
|
66
|
+
export const exported = (path: string, messages: number, memory: number): string =>
|
|
67
|
+
`exported → ${path} (${messages} message(s), ${memory} memory entr(y/ies), cost included)`;
|
|
68
|
+
|
|
69
|
+
// /copy
|
|
70
|
+
|
|
71
|
+
export const LAST_OUTPUT_HEADER = "── last assistant output (full) ──";
|
|
72
|
+
export const alsoInFile = (path: string): string => ` It is also in ${path} (mounted volume).`;
|
|
73
|
+
export const copyNotWritten = (path: string, reason: string): string => `/copy could not write ${path}: ${reason}`;
|
|
74
|
+
export const selectToCopy = (written: string): string =>
|
|
75
|
+
`(select in your terminal to copy — headless REPL has no OS clipboard)${written}`;
|
|
76
|
+
export const NO_ASSISTANT_OUTPUT = "no assistant output in the buffer yet.";
|
|
77
|
+
|
|
78
|
+
// /rename
|
|
79
|
+
|
|
80
|
+
export const RENAME_USAGE = "usage: /rename <title>";
|
|
81
|
+
export const renamed = (title: string): string => "renamed session to: " + title;
|
|
82
|
+
|
|
83
|
+
// /rewind
|
|
84
|
+
|
|
85
|
+
export const NOTHING_TO_REWIND = "nothing to rewind — no user turn in the buffer.";
|
|
86
|
+
export const rewound = (dropped: number, kept: number): string =>
|
|
87
|
+
`rewound 1 exchange (${dropped} message(s) dropped, ${kept} kept).`;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// The text /tasks hands the model (ADR 0026): the note a repair's brief carries.
|
|
2
|
+
|
|
3
|
+
/** The note a repair carries when the operator gives none. */
|
|
4
|
+
export const DEFAULT_REPAIR_NOTE = "Check your previous report against the brief again and correct what is wrong or missing.";
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
// /resume — the sessions of this project the launcher kept, and the one to bring back. The runtime
|
|
2
|
+
// saves the conversation after each turn and when the REPL ends (Persist), outside the project; the
|
|
3
|
+
// next start of `orkeon-code` moves it to the project's history and starts fresh, and mounts that
|
|
4
|
+
// history read-only on /session-history. `/resume` lists them; `/resume <n | id>` loads one in place
|
|
5
|
+
// (Orkeon #227): the session of now is saved to an archive beside its own file first (the launcher
|
|
6
|
+
// moves it to the history at the next start), then the chosen file replaces the buffer, the state bag,
|
|
7
|
+
// the id and the title. `orkeon-code --resume <id>` (or `--continue` for the last one) does the same
|
|
8
|
+
// at start. Lives under commands/_lib/ — the loader's SearchPattern is "*.cmd.ts", so this file is
|
|
9
|
+
// never loaded as a command.
|
|
10
|
+
|
|
11
|
+
import type { Clock, Files, SessionMessages, SessionStore, SessionSwitch } from "../../../shared/application/ports.ts";
|
|
12
|
+
import { LOADED_SESSION_STATE_KEY } from "../../../shared/domain/session-keys.ts";
|
|
13
|
+
import type { CommandView } from "../view.ts";
|
|
14
|
+
import {
|
|
15
|
+
EMPTY_BUFFER, HOW_TO_RESUME, NOTHING_TO_LOAD, NO_SAVED_SESSIONS, NO_SWITCH, ambiguousSession, bufferTail,
|
|
16
|
+
historyNotMountedToList, historyNotMountedToLoad, loadFailed, noSavedSession, savedSessionsHeader, sessionLoaded,
|
|
17
|
+
} from "./messages.ts";
|
|
18
|
+
|
|
19
|
+
/** Where the launcher mounts the project's saved sessions. */
|
|
20
|
+
export const HISTORY_ROOT = "/session-history";
|
|
21
|
+
/** The newest sessions read and shown; the launcher's --resume lists them all. */
|
|
22
|
+
export const SHOWN_SESSIONS = 10;
|
|
23
|
+
/** The names listed at most (the launcher keeps 50 by default). */
|
|
24
|
+
const MAX_LISTED = 500;
|
|
25
|
+
const TAIL_TURNS = 3;
|
|
26
|
+
|
|
27
|
+
export interface ResumeDeps {
|
|
28
|
+
files: Pick<Files, "read" | "list">;
|
|
29
|
+
session: Pick<SessionStore, "readMessages" | "readState" | "writeState">;
|
|
30
|
+
/** The session saved and loaded in place; absent when the host does not persist the session. */
|
|
31
|
+
switch?: SessionSwitch;
|
|
32
|
+
clock: Clock;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type SessionRow = { id: string; saved: string; title: string; messages: string };
|
|
36
|
+
|
|
37
|
+
/** `<yyyymmddTHHMMSSZ>-<id>.json`, as the launcher names a saved session. */
|
|
38
|
+
const SAVED_NAME = /^(\d{8}T\d{6}Z)-(.+)\.json$/;
|
|
39
|
+
|
|
40
|
+
/** `20261024T101500Z` as `2026-10-24 10:15 UTC`. */
|
|
41
|
+
function savedAt(stamp: string): string {
|
|
42
|
+
return `${stamp.slice(0, 4)}-${stamp.slice(4, 6)}-${stamp.slice(6, 8)} ${stamp.slice(9, 11)}:${stamp.slice(11, 13)} UTC`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** The time now as the launcher stamps a saved session, `20261024T101500Z`. */
|
|
46
|
+
export function stampOf(clock: Clock): string {
|
|
47
|
+
return clock().toISOString().replace(/[-:]/g, "").slice(0, 15) + "Z";
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** One row per saved session: its id, when it was saved, its title and its number of messages. */
|
|
51
|
+
async function readRow(files: ResumeDeps["files"], name: string, stamp: string, id: string, current: boolean): Promise<SessionRow> {
|
|
52
|
+
const row = { id, saved: savedAt(stamp) };
|
|
53
|
+
const mark = current ? " (this session)" : "";
|
|
54
|
+
try {
|
|
55
|
+
const saved = JSON.parse(await files.read(`${HISTORY_ROOT}/${name}`));
|
|
56
|
+
const title = typeof saved?.Title === "string" && saved.Title.trim() ? saved.Title.trim() : "(untitled)";
|
|
57
|
+
const messages = Array.isArray(saved?.Messages) ? String(saved.Messages.length) : "?";
|
|
58
|
+
return { ...row, title: title + mark, messages };
|
|
59
|
+
} catch (e: any) {
|
|
60
|
+
return { ...row, title: `(unreadable: ${String(e?.message ?? e).split("\n")[0]})${mark}`, messages: "?" };
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** The saved sessions' file names, newest first; null when the history is not mounted. */
|
|
65
|
+
async function savedNames(files: ResumeDeps["files"]): Promise<string[] | null> {
|
|
66
|
+
try {
|
|
67
|
+
return (await files.list(HISTORY_ROOT, MAX_LISTED))
|
|
68
|
+
// A name, or a path when the host lists paths.
|
|
69
|
+
.map((n) => n.replace(/\/$/, "").split("/").pop() ?? "")
|
|
70
|
+
.filter((n) => SAVED_NAME.test(n))
|
|
71
|
+
.sort()
|
|
72
|
+
.reverse();
|
|
73
|
+
} catch {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const idOf = (name: string): string => SAVED_NAME.exec(name)![2];
|
|
79
|
+
|
|
80
|
+
/** The file `choice` names: a number of the shown list, else the start of an id that matches one session. */
|
|
81
|
+
export function chooseSaved(names: readonly string[], choice: string): { name: string } | { refused: string } {
|
|
82
|
+
const shown = names.slice(0, SHOWN_SESSIONS);
|
|
83
|
+
if (/^[1-9]\d{0,3}$/.test(choice)) {
|
|
84
|
+
const n = Number(choice);
|
|
85
|
+
if (n <= shown.length) return { name: shown[n - 1] };
|
|
86
|
+
}
|
|
87
|
+
const matches = names.filter((name) => idOf(name).startsWith(choice));
|
|
88
|
+
if (matches.length === 1) return { name: matches[0] };
|
|
89
|
+
if (matches.length > 1) return { refused: ambiguousSession(choice) };
|
|
90
|
+
return { refused: noSavedSession(choice) };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Load `name` in place: the session of now archived beside its own file first, then the swap. */
|
|
94
|
+
async function loadSaved(deps: ResumeDeps, name: string): Promise<CommandView> {
|
|
95
|
+
const id = idOf(name);
|
|
96
|
+
if (deps.switch === undefined) return { text: NO_SWITCH };
|
|
97
|
+
let archive = "";
|
|
98
|
+
try {
|
|
99
|
+
const own = await deps.switch.save();
|
|
100
|
+
archive = `${own.slice(0, own.lastIndexOf("/") + 1)}${stampOf(deps.clock)}-archived.json`;
|
|
101
|
+
await deps.switch.save(archive);
|
|
102
|
+
const count = await deps.switch.load(`${HISTORY_ROOT}/${name}`);
|
|
103
|
+
await deps.session.writeState(LOADED_SESSION_STATE_KEY, name).catch(() => undefined);
|
|
104
|
+
return { text: sessionLoaded(id, count, archive) };
|
|
105
|
+
} catch (e: any) {
|
|
106
|
+
const reason = String(e?.message ?? e).split("\n")[0];
|
|
107
|
+
return { text: loadFailed(id, reason, archive) };
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** The saved sessions, newest first, then the current buffer's last turns; with `choice`, that one loaded in place. */
|
|
112
|
+
export async function runResume(deps: ResumeDeps, choice?: string): Promise<CommandView> {
|
|
113
|
+
const names = await savedNames(deps.files);
|
|
114
|
+
const wanted = choice?.trim() ?? "";
|
|
115
|
+
|
|
116
|
+
if (wanted.length > 0) {
|
|
117
|
+
if (names === null) return { text: historyNotMountedToLoad(HISTORY_ROOT) };
|
|
118
|
+
if (names.length === 0) return { text: NOTHING_TO_LOAD };
|
|
119
|
+
const chosen = chooseSaved(names, wanted);
|
|
120
|
+
return "refused" in chosen ? { text: chosen.refused } : loadSaved(deps, chosen.name);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const lines: string[] = [];
|
|
124
|
+
let table: SessionRow[] | undefined;
|
|
125
|
+
if (names === null) {
|
|
126
|
+
lines.push(historyNotMountedToList(HISTORY_ROOT));
|
|
127
|
+
} else if (names.length === 0) {
|
|
128
|
+
lines.push(NO_SAVED_SESSIONS);
|
|
129
|
+
} else {
|
|
130
|
+
const loadedFrom = await deps.session.readState(LOADED_SESSION_STATE_KEY).catch(() => null);
|
|
131
|
+
table = [];
|
|
132
|
+
for (const name of names.slice(0, SHOWN_SESSIONS)) {
|
|
133
|
+
const [, stamp, id] = SAVED_NAME.exec(name)!;
|
|
134
|
+
table.push(await readRow(deps.files, name, stamp, id, name === loadedFrom));
|
|
135
|
+
}
|
|
136
|
+
const more = names.length - table.length;
|
|
137
|
+
lines.push(
|
|
138
|
+
savedSessionsHeader(names.length, more),
|
|
139
|
+
HOW_TO_RESUME,
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const { messages } = await deps.session.readMessages()
|
|
144
|
+
.catch((): SessionMessages => ({ stored: [], messages: [] }));
|
|
145
|
+
const tail = messages.slice(-TAIL_TURNS)
|
|
146
|
+
.map((m) => ` ${m.role}: ${m.content.slice(0, 200)}${m.content.length > 200 ? "…" : ""}`);
|
|
147
|
+
const text = messages.length === 0
|
|
148
|
+
? EMPTY_BUFFER
|
|
149
|
+
: bufferTail(messages.length, tail);
|
|
150
|
+
return { lines, table, text };
|
|
151
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
// /tasks (E-1, A-3) — the session task list, and the agent instances of the dev crews. The task
|
|
2
|
+
// list is one JSON array in the state bag (add, done, clear; /clear empties it). The instances are
|
|
3
|
+
// the children a dev crew runs (the reviewer of /dev-plan, the auditor of dev-verify): the crew
|
|
4
|
+
// writes its run in the state bag while they run (shared/application/agents/child-agent.ts), and
|
|
5
|
+
// reads there the stop /tasks leaves for one of them, at its next look. A send to a running instance
|
|
6
|
+
// is refused; to an ended one it is a repair by a new run (crews/agent-run), whose brief carries the
|
|
7
|
+
// previous report: the entry point launches it and its completion prints the answer. A repair runs
|
|
8
|
+
// at the effort /effort holds now. The list also shows the tool approvals the background tasks wait
|
|
9
|
+
// on (Orkeon #198), read from the host: a task blocked on the operator reads as such.
|
|
10
|
+
|
|
11
|
+
import type { PendingApproval, PendingApprovals, SessionStore } from "../../../shared/application/ports.ts";
|
|
12
|
+
import { readJsonArray, writeJson } from "../../../shared/application/session-state.ts";
|
|
13
|
+
import { TASKS_STATE_KEY } from "../../../shared/domain/session-keys.ts";
|
|
14
|
+
import {
|
|
15
|
+
CHILD_CREWS, buildRepairBrief, describeInstance, instanceRows, locateInstance, parseRequest, parseSnapshot,
|
|
16
|
+
requestKey, sendVerdict, settleSnapshot, snapshotKey, stopVerdict,
|
|
17
|
+
} from "../../../shared/domain/agents/instances.ts";
|
|
18
|
+
import type { InstanceRequest, Located, RunSnapshot } from "../../../shared/domain/agents/instances.ts";
|
|
19
|
+
import { storedEffort } from "../effort.ts";
|
|
20
|
+
import type { CommandView } from "../view.ts";
|
|
21
|
+
import {
|
|
22
|
+
INSTANCE_VERBS, NO_TASKS, TASKS_ADD_USAGE, TASKS_SEND_USAGE, TASKS_USAGE, WAITING_FOR_APPROVAL, ANSWER_TEXT,
|
|
23
|
+
repairByNewRun, repairWhileRunning, requestAlreadyWaiting, stopAsked, taskAdded, taskDone, tasksCleared,
|
|
24
|
+
tasksDoneUsage, waitsForApproval,
|
|
25
|
+
} from "./messages.ts";
|
|
26
|
+
import { DEFAULT_REPAIR_NOTE } from "./prompts.ts";
|
|
27
|
+
|
|
28
|
+
/** The crew that repairs an instance by a new run. */
|
|
29
|
+
export const REPAIR_CREW = "agent-run";
|
|
30
|
+
|
|
31
|
+
export interface TasksDeps {
|
|
32
|
+
session: Pick<SessionStore, "readState" | "writeState">;
|
|
33
|
+
clock: () => Date;
|
|
34
|
+
/** The tool approvals waiting for the operator, as the host shows them. */
|
|
35
|
+
approvals: PendingApprovals;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** What the entry point shows, and the crew it launches for a repair. */
|
|
39
|
+
export interface TasksOutcome {
|
|
40
|
+
view: CommandView;
|
|
41
|
+
launch?: { crew: string; input: Record<string, unknown>; details: Record<string, unknown> };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
interface Task { subject: string; done: boolean }
|
|
45
|
+
|
|
46
|
+
async function readSnapshots({ session, clock }: TasksDeps): Promise<RunSnapshot[]> {
|
|
47
|
+
const read = async (crew: string) => {
|
|
48
|
+
try {
|
|
49
|
+
const s = parseSnapshot(await session.readState(snapshotKey(crew)));
|
|
50
|
+
return s === null ? null : settleSnapshot(s, clock());
|
|
51
|
+
} catch {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
return (await Promise.all(CHILD_CREWS.map(read))).filter((s): s is RunSnapshot => s !== null);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** One approval as the list shows it: the task's ticket and command (the status line's words), the tool, the input. */
|
|
59
|
+
const approvalLine = (a: PendingApproval): string =>
|
|
60
|
+
waitsForApproval(a.taskId === null ? "no task" : `${a.taskId} ${a.command ?? "?"}`, a.tool, a.input);
|
|
61
|
+
|
|
62
|
+
/** The approvals waiting, as lines; a host whose read fails shows none. */
|
|
63
|
+
function approvalLines({ approvals }: TasksDeps): string[] {
|
|
64
|
+
try {
|
|
65
|
+
return approvals.list().map(approvalLine);
|
|
66
|
+
} catch {
|
|
67
|
+
return [];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async function list(tasks: Task[], deps: TasksDeps): Promise<TasksOutcome> {
|
|
72
|
+
const rows = instanceRows(await readSnapshots(deps));
|
|
73
|
+
const waiting = approvalLines(deps);
|
|
74
|
+
const taskLines = tasks.map((t, i) => `#${i + 1} [${t.done ? "done" : "open"}] ${t.subject}`);
|
|
75
|
+
if (rows.length === 0 && waiting.length === 0) {
|
|
76
|
+
if (tasks.length === 0) return { view: { text: NO_TASKS } };
|
|
77
|
+
return { view: { table: tasks.map((t, i) => ({ n: i + 1, status: t.done ? "done" : "open", subject: t.subject })) } };
|
|
78
|
+
}
|
|
79
|
+
const lines = [tasks.length === 0 ? "tasks: none" : "tasks:", ...taskLines];
|
|
80
|
+
if (waiting.length > 0) lines.push(WAITING_FOR_APPROVAL, ...waiting);
|
|
81
|
+
if (rows.length === 0) return { view: { lines, text: ANSWER_TEXT } };
|
|
82
|
+
return {
|
|
83
|
+
view: {
|
|
84
|
+
lines: [...lines, "agent instances:"],
|
|
85
|
+
table: rows,
|
|
86
|
+
text: INSTANCE_VERBS,
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const ref = (l: Located) => `${l.snapshot.crew}:${l.record.id}`;
|
|
92
|
+
|
|
93
|
+
async function locate(deps: TasksDeps, id: string | undefined): Promise<{ ok: true; found: Located } | { ok: false; view: CommandView }> {
|
|
94
|
+
if (!id) return { ok: false, view: { text: TASKS_USAGE } };
|
|
95
|
+
const located = locateInstance(await readSnapshots(deps), id);
|
|
96
|
+
return located.ok ? located : { ok: false, view: { text: located.text } };
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Leaves `request` for the crew, unless one of the same run it has not read yet is already there. */
|
|
100
|
+
async function leaveRequest(deps: TasksDeps, l: Located, request: InstanceRequest): Promise<string | null> {
|
|
101
|
+
const key = requestKey(l.snapshot.crew, l.record.id);
|
|
102
|
+
if (parseRequest(await deps.session.readState(key).catch(() => null))?.run === request.run) {
|
|
103
|
+
return requestAlreadyWaiting(ref(l), l.record.id);
|
|
104
|
+
}
|
|
105
|
+
await deps.session.writeState(key, JSON.stringify(request));
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
async function repair(deps: TasksDeps, l: Located, message: string): Promise<TasksOutcome> {
|
|
110
|
+
return {
|
|
111
|
+
view: {
|
|
112
|
+
lines: [repairByNewRun(ref(l), l.record.charter)],
|
|
113
|
+
},
|
|
114
|
+
launch: {
|
|
115
|
+
crew: REPAIR_CREW,
|
|
116
|
+
input: {
|
|
117
|
+
charter: l.record.charter, step: l.snapshot.step, system: l.record.system, brief: buildRepairBrief(l.record, message),
|
|
118
|
+
effort: await storedEffort(deps.session),
|
|
119
|
+
},
|
|
120
|
+
details: { instance: ref(l), charter: l.record.charter },
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** `/tasks …` from the command's raw tokens. */
|
|
126
|
+
export async function runTasks(tokens: readonly string[], deps: TasksDeps): Promise<TasksOutcome> {
|
|
127
|
+
const [sub, ...rest] = tokens;
|
|
128
|
+
const tasks = (await readJsonArray(deps.session, TASKS_STATE_KEY)) as Task[];
|
|
129
|
+
switch ((sub ?? "list").toLowerCase()) {
|
|
130
|
+
case "list":
|
|
131
|
+
return list(tasks, deps);
|
|
132
|
+
case "add": {
|
|
133
|
+
const subject = rest.join(" ");
|
|
134
|
+
if (!subject) return { view: { text: TASKS_ADD_USAGE } };
|
|
135
|
+
tasks.push({ subject, done: false });
|
|
136
|
+
await writeJson(deps.session, TASKS_STATE_KEY, tasks);
|
|
137
|
+
return { view: { text: taskAdded(tasks.length, subject) } };
|
|
138
|
+
}
|
|
139
|
+
case "done": {
|
|
140
|
+
const n = Number(rest[0]);
|
|
141
|
+
if (!Number.isInteger(n) || n < 1 || n > tasks.length) return { view: { text: tasksDoneUsage(tasks.length || 1) } };
|
|
142
|
+
tasks[n - 1].done = true;
|
|
143
|
+
await writeJson(deps.session, TASKS_STATE_KEY, tasks);
|
|
144
|
+
return { view: { text: taskDone(n, tasks[n - 1].subject) } };
|
|
145
|
+
}
|
|
146
|
+
case "clear":
|
|
147
|
+
await writeJson(deps.session, TASKS_STATE_KEY, []);
|
|
148
|
+
return { view: { text: tasksCleared(tasks.length) } };
|
|
149
|
+
case "show": {
|
|
150
|
+
const l = await locate(deps, rest[0]);
|
|
151
|
+
return l.ok ? { view: { lines: describeInstance(l.found) } } : { view: l.view };
|
|
152
|
+
}
|
|
153
|
+
case "stop": {
|
|
154
|
+
const l = await locate(deps, rest[0]);
|
|
155
|
+
if (!l.ok) return { view: l.view };
|
|
156
|
+
const verdict = stopVerdict(l.found);
|
|
157
|
+
if (!verdict.ok) return { view: { text: verdict.text } };
|
|
158
|
+
const waiting = await leaveRequest(deps, l.found, { action: "stop", run: l.found.snapshot.startedAt, at: deps.clock().toISOString() });
|
|
159
|
+
return { view: { text: waiting ?? stopAsked(ref(l.found)) } };
|
|
160
|
+
}
|
|
161
|
+
case "send": {
|
|
162
|
+
const l = await locate(deps, rest[0]);
|
|
163
|
+
if (!l.ok) return { view: l.view };
|
|
164
|
+
const message = rest.slice(1).join(" ").trim();
|
|
165
|
+
if (!message) return { view: { text: TASKS_SEND_USAGE } };
|
|
166
|
+
const verdict = sendVerdict(l.found);
|
|
167
|
+
if (verdict.kind === "refused") return { view: { text: verdict.text } };
|
|
168
|
+
return repair(deps, l.found, message);
|
|
169
|
+
}
|
|
170
|
+
case "repair": {
|
|
171
|
+
const l = await locate(deps, rest[0]);
|
|
172
|
+
if (!l.ok) return { view: l.view };
|
|
173
|
+
if (l.found.record.state === "running") {
|
|
174
|
+
return { view: { text: repairWhileRunning(ref(l.found), l.found.record.id) } };
|
|
175
|
+
}
|
|
176
|
+
return repair(deps, l.found, rest.slice(1).join(" ").trim() || DEFAULT_REPAIR_NOTE);
|
|
177
|
+
}
|
|
178
|
+
default:
|
|
179
|
+
return { view: { text: TASKS_USAGE } };
|
|
180
|
+
}
|
|
181
|
+
}
|