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,74 @@
|
|
|
1
|
+
// The session port: the conversation buffer, the state bag and the context window's budget.
|
|
2
|
+
// Types only, re-exported by ../ports.ts.
|
|
3
|
+
|
|
4
|
+
import type { SessionMsg } from "../../domain/types.ts";
|
|
5
|
+
|
|
6
|
+
/** A conversation-buffer entry as the session holds it. Its field casing is the
|
|
7
|
+
* runtime's, so it is read through `SessionMessages.messages`; written back as
|
|
8
|
+
* read, it stays untouched. */
|
|
9
|
+
export type StoredMessage = unknown;
|
|
10
|
+
|
|
11
|
+
/** The conversation buffer, read once. */
|
|
12
|
+
export interface SessionMessages {
|
|
13
|
+
/** Each entry as stored, in order. */
|
|
14
|
+
stored: StoredMessage[];
|
|
15
|
+
/** The same entries, as role and content. */
|
|
16
|
+
messages: SessionMsg[];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** The tokens of the context window by kind of entry (Orkeon #226). */
|
|
20
|
+
export interface TokenKinds {
|
|
21
|
+
system: number;
|
|
22
|
+
user: number;
|
|
23
|
+
assistant: number;
|
|
24
|
+
tool: number;
|
|
25
|
+
other: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Tokens used in the context window, and the window's size; by kind when the host reports it. */
|
|
29
|
+
export interface TokenBudget {
|
|
30
|
+
used: number;
|
|
31
|
+
window: number;
|
|
32
|
+
byKind?: TokenKinds;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** What a snip of the conversation buffer removed and kept, in entries. */
|
|
36
|
+
export interface SnipResult {
|
|
37
|
+
removed: number;
|
|
38
|
+
retained: number;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** The session saved now, and a saved one loaded in place (Orkeon #227): served while the host persists the
|
|
42
|
+
* session per project (`Orkeon:Cli:Session:Persist`), at virtual paths the file system mounts. */
|
|
43
|
+
export interface SessionSwitch {
|
|
44
|
+
/** Write the session now: to its own file, resolving to that virtual path, or to `path` in the same shape. */
|
|
45
|
+
save(path?: string): Promise<string>;
|
|
46
|
+
/** Swap the buffer, the state bag, the id and the title for those of the file at `path`; resolves to the number
|
|
47
|
+
* of messages loaded. A missing, unreadable or ill-shaped file rejects and the session stays as it was. */
|
|
48
|
+
load(path: string): Promise<number>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** The session: its conversation buffer, its state bag (string values that survive
|
|
52
|
+
* crew runs and are cleared by /clear), the context window's budget and
|
|
53
|
+
* the session's title. */
|
|
54
|
+
export interface SessionStore {
|
|
55
|
+
readMessages(): Promise<SessionMessages>;
|
|
56
|
+
/** Replace the conversation buffer. */
|
|
57
|
+
writeMessages(messages: readonly StoredMessage[]): Promise<void>;
|
|
58
|
+
/** Add one entry at the end of the buffer, which is neither read nor rewritten (Orkeon #263). */
|
|
59
|
+
appendMessage(role: string, content: string): Promise<void>;
|
|
60
|
+
/** Empty the conversation buffer; resolves to how many entries it removed. */
|
|
61
|
+
reset(): Promise<number>;
|
|
62
|
+
/** Cut the buffer down to its head and its last `turns` turns as the runtime counts them (Orkeon #287): a turn opens
|
|
63
|
+
* at each user message, the stored [turn-context] included, and is never split. Fewer turns than asked, or none
|
|
64
|
+
* after the head, leave the buffer untouched (0 removed). */
|
|
65
|
+
snip(turns: number): Promise<SnipResult>;
|
|
66
|
+
setTitle(title: string): Promise<void>;
|
|
67
|
+
/** A state value; null when unset. */
|
|
68
|
+
readState(key: string): Promise<string | null>;
|
|
69
|
+
/** Several state values in one read (Orkeon #263): every key asked, null when unset. */
|
|
70
|
+
readStates(keys: readonly string[]): Promise<Record<string, string | null>>;
|
|
71
|
+
/** Set a state value; null removes the key. */
|
|
72
|
+
writeState(key: string, value: string | null): Promise<void>;
|
|
73
|
+
readBudget(): Promise<TokenBudget>;
|
|
74
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// The shared-memory port: the RAG index of the project's shared memory.
|
|
2
|
+
// Types only, re-exported by ../ports.ts.
|
|
3
|
+
|
|
4
|
+
/** A passage of the shared memory's index: the file it comes from (virtual path) and its score. */
|
|
5
|
+
export interface SharedHit {
|
|
6
|
+
sourceId: string;
|
|
7
|
+
score: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** What an ingestion of the shared memory's index did, by source. */
|
|
11
|
+
export interface SharedIngest {
|
|
12
|
+
added: number;
|
|
13
|
+
reingested: number;
|
|
14
|
+
unchanged: number;
|
|
15
|
+
pruned: number;
|
|
16
|
+
errors: string[];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** The RAG index of the shared memory (one collection per project, `memory-<project>`); its files are read and
|
|
20
|
+
* written through Files. Each call throws when the host cannot answer it (no RAG subsystem). */
|
|
21
|
+
export interface SharedMemory {
|
|
22
|
+
/** The best passages for `query`, one per source file, best first. */
|
|
23
|
+
search(collection: string, query: string, topN: number): Promise<SharedHit[]>;
|
|
24
|
+
/** Index `sources` (virtual paths or globs); `prune` drops the sources of the collection absent from them. */
|
|
25
|
+
ingest(collection: string, sources: readonly string[], options: { prune: boolean }): Promise<SharedIngest>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// The shell ports: one command run to its end, and the commands run detached as jobs.
|
|
2
|
+
// Types only, re-exported by ../ports.ts.
|
|
3
|
+
|
|
4
|
+
/** The outcome of one shell command. */
|
|
5
|
+
export interface ShellResult {
|
|
6
|
+
stdout: string;
|
|
7
|
+
stderr: string;
|
|
8
|
+
/** -1 when the runtime reported none. */
|
|
9
|
+
exitCode: number;
|
|
10
|
+
/** True when the runtime stopped the command at its timeout; absent otherwise. */
|
|
11
|
+
timedOut?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** How one command runs. */
|
|
15
|
+
export interface ShellOptions {
|
|
16
|
+
/** Whole seconds before the runtime stops the command; the runtime's default when absent. */
|
|
17
|
+
timeoutSeconds?: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Runs shell commands in the project's working directory, /workspace. A command
|
|
21
|
+
* the runtime refuses or cannot run throws; a failing one returns its exit code. */
|
|
22
|
+
export interface Shell {
|
|
23
|
+
run(command: string, options?: ShellOptions): Promise<ShellResult>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Where a detached job stands: running, or exited with its code (-1 when it ended without one). */
|
|
27
|
+
export interface ShellJobStatus { running: boolean; exitCode: number }
|
|
28
|
+
|
|
29
|
+
/** Commands run detached (the runtime's shell jobs): a long suite outlives no shell timeout, its whole
|
|
30
|
+
* output goes to a log file, and the caller reads its tail. A job belongs to the running crew and is
|
|
31
|
+
* stopped when the crew's run ends. A call the runtime refuses throws. */
|
|
32
|
+
export interface ShellJobs {
|
|
33
|
+
/** Starts `command` in /workspace; its id and the virtual path of its log. */
|
|
34
|
+
start(command: string): Promise<{ id: string; log: string }>;
|
|
35
|
+
status(id: string): Promise<ShellJobStatus>;
|
|
36
|
+
/** The last `lines` lines of the job's log (500 at most). */
|
|
37
|
+
tail(id: string, lines: number): Promise<string>;
|
|
38
|
+
/** Waits about `seconds` (code has no timer of its own); false when it cannot wait here. */
|
|
39
|
+
wait(seconds: number): Promise<boolean>;
|
|
40
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// The telemetry port: what the host reports about the session and its LLM usage.
|
|
2
|
+
// Types only, re-exported by ../ports.ts.
|
|
3
|
+
|
|
4
|
+
/** What the host reports about the session. A field it did not report is undefined. */
|
|
5
|
+
export interface SessionMetadata {
|
|
6
|
+
title?: string;
|
|
7
|
+
/** The model the host booted with. */
|
|
8
|
+
model?: string;
|
|
9
|
+
messageCount?: number;
|
|
10
|
+
estimatedTokens?: number;
|
|
11
|
+
/** The models the host declares (`Llm:AvailableModels`), trimmed and deduplicated. */
|
|
12
|
+
availableModels?: string[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** The session's cumulative LLM usage. */
|
|
16
|
+
export interface SessionCost {
|
|
17
|
+
costUsd?: number;
|
|
18
|
+
totalTokens?: number;
|
|
19
|
+
totalCalls?: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** The session's telemetry: its LLM usage plus the buffer's counters. */
|
|
23
|
+
export interface SessionStats extends SessionCost {
|
|
24
|
+
messageCount?: number;
|
|
25
|
+
estimatedTokens?: number;
|
|
26
|
+
/** Prompt tokens sent, over every model, as the providers counted them, when the host reports them. */
|
|
27
|
+
promptTokens?: number;
|
|
28
|
+
/** Completion tokens received, over every model, as the providers counted them, when the host reports them. */
|
|
29
|
+
completionTokens?: number;
|
|
30
|
+
/** Prompt tokens read from the provider's cache (the hits), summed over the models that report them; undefined
|
|
31
|
+
* when none does (Orkeon #254: not measured, never 0). */
|
|
32
|
+
cacheHitTokens?: number;
|
|
33
|
+
/** Prompt tokens written to the provider's cache, summed over the models that report them; undefined when none does. */
|
|
34
|
+
cacheWriteTokens?: number;
|
|
35
|
+
/** Completion tokens spent reasoning, summed over the models that report them; undefined when none does. */
|
|
36
|
+
reasoningTokens?: number;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** The host's account of the session. Each read throws when the host cannot
|
|
40
|
+
* answer it; callers that only display a value catch and show what they have. */
|
|
41
|
+
export interface Telemetry {
|
|
42
|
+
readMetadata(): Promise<SessionMetadata>;
|
|
43
|
+
readCost(): Promise<SessionCost>;
|
|
44
|
+
readStats(): Promise<SessionStats>;
|
|
45
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// The tool ports: the host's registered tools, a tool call read as text, and the permission gate's session rules.
|
|
2
|
+
// Types only, re-exported by ../ports.ts.
|
|
3
|
+
|
|
4
|
+
import type { PermissionRule } from "../../domain/agent-policy/permission.ts";
|
|
5
|
+
|
|
6
|
+
/** One tool call read as text: the tool's text, or its own failure message, the
|
|
7
|
+
* runtime's wrapping gone. */
|
|
8
|
+
export type ToolOutcome = { ok: true; text: string } | { ok: false; failure: string };
|
|
9
|
+
|
|
10
|
+
/** The tools the host registers, by the names it registers them under (`file_read`,
|
|
11
|
+
* an MCP server's `get-file-contents` or `listIssues`): a diagnostic view and the
|
|
12
|
+
* check of the extra tools, apart from the catalogue a mode hands the model
|
|
13
|
+
* (shared/domain/agent-policy). Orkeon matches a tool name case-insensitively (an
|
|
14
|
+
* agent's `.tools([...])`, the gate's rules), and so does `find`. */
|
|
15
|
+
export interface ToolCatalogue {
|
|
16
|
+
/** Every registered name, as registered, sorted. */
|
|
17
|
+
names(): string[];
|
|
18
|
+
/** The registered name `name` designates, compared case-insensitively; undefined
|
|
19
|
+
* when the host registers no such tool. */
|
|
20
|
+
find(name: string): string | undefined;
|
|
21
|
+
/** Call the tool `name` designates with `args` as given; resolves to its raw
|
|
22
|
+
* result, throws its failure, or that no registered tool answers to `name`. */
|
|
23
|
+
call(name: string, args: Record<string, unknown>): Promise<unknown>;
|
|
24
|
+
/** The same call, decoded: the result as text, or the tool's own failure message
|
|
25
|
+
* (that no registered tool answers to `name` included). Never throws. */
|
|
26
|
+
callText(name: string, args: Record<string, unknown>): Promise<ToolOutcome>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** The session rules of the host's permission gate, which it reads at every tool
|
|
30
|
+
* call before the mode: a deny refuses a matching call in every mode, an allow
|
|
31
|
+
* lets it run without asking in every mode but `plan`. The host keeps them until
|
|
32
|
+
* it exits, and removes them only all at once. */
|
|
33
|
+
export interface PermissionRules {
|
|
34
|
+
/** Whether the host keeps session rules (orkeon-repl does). When it does not,
|
|
35
|
+
* the gate decides from the mode alone and every other call throws. */
|
|
36
|
+
available(): boolean;
|
|
37
|
+
/** Whether the host's gate is on (`Orkeon:Security:PermissionGate:Enabled`): false, no rule
|
|
38
|
+
* and no mode is enforced; undefined when the host keeps no session rules. */
|
|
39
|
+
enabled(): boolean | undefined;
|
|
40
|
+
/** Put a rule in force; a rule already in force is kept once. */
|
|
41
|
+
add(rule: PermissionRule): void;
|
|
42
|
+
/** Remove every rule. */
|
|
43
|
+
clear(): void;
|
|
44
|
+
/** The rules in force, one line each: `allow shell_command command=npm test*`. */
|
|
45
|
+
list(): string[];
|
|
46
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// The usage port: the session's LLM usage by category, as the host accounts it (Orkeon #226).
|
|
2
|
+
// Types only, re-exported by ../ports.ts.
|
|
3
|
+
|
|
4
|
+
/** The tokens of a set of calls: the cache counts are a part of the prompt, the reasoning a part of the completion.
|
|
5
|
+
* A cache or reasoning count is null when no call of the set reported it (Orkeon #254): not measured, never 0. */
|
|
6
|
+
export interface UsageTokens {
|
|
7
|
+
promptTokens: number;
|
|
8
|
+
completionTokens: number;
|
|
9
|
+
cacheHitTokens: number | null;
|
|
10
|
+
cacheWriteTokens: number | null;
|
|
11
|
+
reasoningTokens: number | null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** What a set of calls spent: `cost` is null when no call of the set was priced; `unpricedCalls` counts the calls
|
|
15
|
+
* nobody priced, which `cost` counts as 0 (while it is not 0, the cost is a lower bound). */
|
|
16
|
+
export interface UsageSpent extends UsageTokens {
|
|
17
|
+
calls: number;
|
|
18
|
+
unpricedCalls: number;
|
|
19
|
+
cost: number | null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** One model the provider named in its answers. */
|
|
23
|
+
export interface ModelUsage extends UsageSpent {
|
|
24
|
+
model: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** One command instance the session keeps, the newest first. */
|
|
28
|
+
export interface CommandUsage extends UsageSpent {
|
|
29
|
+
ticket: string;
|
|
30
|
+
name: string;
|
|
31
|
+
state: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** The session's usage of the moment: the totals over every recorded call (a call whose provider named no model is
|
|
35
|
+
* in the totals and in no model row), then by model and by command. */
|
|
36
|
+
export interface UsageReport extends UsageSpent {
|
|
37
|
+
totalTokens: number;
|
|
38
|
+
byModel: ModelUsage[];
|
|
39
|
+
byCommand: CommandUsage[];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** The reader of the session's usage; undefined when the host keeps no account, or the read fails. */
|
|
43
|
+
export interface UsageReader {
|
|
44
|
+
report(): UsageReport | undefined;
|
|
45
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// The ports: what the application layer needs from outside, named after that need
|
|
2
|
+
// rather than after the runtime that provides it. One file per concern under ports/,
|
|
3
|
+
// re-exported here so that every importer names this module; types only, so it is
|
|
4
|
+
// erased from every bundle. A new port goes in ports/<concern>.ts, plus its line below.
|
|
5
|
+
// The Orkeon adapters live in shared/infrastructure/orkeon/ (and are wired by entry
|
|
6
|
+
// points), the test doubles in tests/support/doubles/.
|
|
7
|
+
|
|
8
|
+
export type { Clock } from "./ports/clock.ts";
|
|
9
|
+
export type { ShellResult, ShellOptions, Shell, ShellJobStatus, ShellJobs } from "./ports/shell.ts";
|
|
10
|
+
export type { Mount, Files } from "./ports/files.ts";
|
|
11
|
+
export type { ProgressSpec, Progress } from "./ports/progress.ts";
|
|
12
|
+
export type {
|
|
13
|
+
StoredMessage, SessionMessages, TokenKinds, TokenBudget, SnipResult, SessionStore, SessionSwitch,
|
|
14
|
+
} from "./ports/session.ts";
|
|
15
|
+
export type { SessionMetadata, SessionCost, SessionStats, Telemetry } from "./ports/telemetry.ts";
|
|
16
|
+
export type { RuntimeInfo, RuntimeInfoReader } from "./ports/runtime.ts";
|
|
17
|
+
export type { UsageTokens, UsageSpent, ModelUsage, CommandUsage, UsageReport, UsageReader } from "./ports/usage.ts";
|
|
18
|
+
export type { MemoryEntry, MemoryStore } from "./ports/memory.ts";
|
|
19
|
+
export type { ToolOutcome, ToolCatalogue, PermissionRules } from "./ports/tools.ts";
|
|
20
|
+
export type { CrewHost, CrewLaunchOptions, ChildRuntime, Logger, RunState, CrewMemory } from "./ports/crew.ts";
|
|
21
|
+
export type { ModelOverride, CompleteRequest, ActRequest, Llm } from "./ports/llm.ts";
|
|
22
|
+
export type { HumanInput } from "./ports/human.ts";
|
|
23
|
+
export type { PendingApproval, PendingApprovals } from "./ports/approvals.ts";
|
|
24
|
+
export type {
|
|
25
|
+
MapLevel, CodeMap, CodeSearchHit, SymbolLocation, CodeIndex, AnchorClosure, AnchorIndex, CostIndex, AffectedTests,
|
|
26
|
+
} from "./ports/code-index.ts";
|
|
27
|
+
export type { SharedHit, SharedIngest, SharedMemory } from "./ports/shared-memory.ts";
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// Reading the project manifests and the CI workflows, shared by /init (project-init) and
|
|
2
|
+
// /init-verifiers: the files that exist, each cut at MAX_CONFIG_FILE_CHARS, in the order of the domain
|
|
3
|
+
// module (commands first, rules after), and their rendering as material, bounded as a whole.
|
|
4
|
+
|
|
5
|
+
import type { Files } from "./ports.ts";
|
|
6
|
+
import {
|
|
7
|
+
CI_WORKFLOWS_DIR, COMMAND_MANIFESTS, CONFIG_CANDIDATES, MAX_CONFIG_FILE_CHARS, MAX_MANIFESTS_MATERIAL_CHARS,
|
|
8
|
+
RULE_CONFIGS, cutLine, expandCandidates, isSuffixCandidate, leftOutLine,
|
|
9
|
+
} from "../domain/project-manifests.ts";
|
|
10
|
+
import { WORKSPACE } from "../domain/vfs.ts";
|
|
11
|
+
|
|
12
|
+
/** Entries of the workspace root listed to match the suffix candidates (`*.csproj`). */
|
|
13
|
+
const MAX_TOP_LEVEL_ENTRIES = 200;
|
|
14
|
+
/** Workflow files listed under CI_WORKFLOWS_DIR. */
|
|
15
|
+
const MAX_WORKFLOWS = 20;
|
|
16
|
+
|
|
17
|
+
/** A manifest as read: its path relative to the workspace root, its content cut at MAX_CONFIG_FILE_CHARS;
|
|
18
|
+
* `cut`, when set, the characters left out of its end. */
|
|
19
|
+
export interface ManifestText { path: string; content: string; cut?: number }
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The manifests of `candidates` that exist and are not empty, in candidate order. A suffix candidate
|
|
23
|
+
* (`*.csproj`) is matched against one listing of the workspace root, made only when `files` can list
|
|
24
|
+
* and a suffix candidate is asked; without `list` it is skipped. An absent or unreadable file is skipped.
|
|
25
|
+
*/
|
|
26
|
+
export async function readManifests(
|
|
27
|
+
files: Pick<Files, "read"> & Partial<Pick<Files, "list">>,
|
|
28
|
+
candidates: readonly string[] = CONFIG_CANDIDATES,
|
|
29
|
+
): Promise<ManifestText[]> {
|
|
30
|
+
let topLevel: string[] = [];
|
|
31
|
+
if (files.list && candidates.some(isSuffixCandidate)) {
|
|
32
|
+
try {
|
|
33
|
+
topLevel = await files.list(WORKSPACE, MAX_TOP_LEVEL_ENTRIES);
|
|
34
|
+
} catch { /* unlistable — the suffix candidates match nothing */ }
|
|
35
|
+
}
|
|
36
|
+
const found: ManifestText[] = [];
|
|
37
|
+
for (const path of expandCandidates(candidates, topLevel)) {
|
|
38
|
+
try {
|
|
39
|
+
const content = await files.read(`${WORKSPACE}/${path}`);
|
|
40
|
+
if (content.length === 0) continue;
|
|
41
|
+
const cut = content.length - MAX_CONFIG_FILE_CHARS;
|
|
42
|
+
found.push(cut > 0 ? { path, content: content.slice(0, MAX_CONFIG_FILE_CHARS), cut } : { path, content });
|
|
43
|
+
} catch { /* absent or unreadable — skip */ }
|
|
44
|
+
}
|
|
45
|
+
return found;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** The file names under CI_WORKFLOWS_DIR; none when the folder is absent. */
|
|
49
|
+
export async function listCiWorkflows(files: Pick<Files, "list">): Promise<string[]> {
|
|
50
|
+
try {
|
|
51
|
+
return await files.list(`${WORKSPACE}/${CI_WORKFLOWS_DIR}`, MAX_WORKFLOWS);
|
|
52
|
+
} catch {
|
|
53
|
+
return [];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The CI workflows under CI_WORKFLOWS_DIR as manifests (path `.github/workflows/<name>`), in listing
|
|
59
|
+
* order, each cut at MAX_CONFIG_FILE_CHARS: often the only place the project's real check sequence is
|
|
60
|
+
* written. None when the folder is absent; an empty or unreadable file is skipped.
|
|
61
|
+
*/
|
|
62
|
+
export async function readCiWorkflows(files: Pick<Files, "list" | "read">): Promise<ManifestText[]> {
|
|
63
|
+
const paths = (await listCiWorkflows(files)).map((name) => `${CI_WORKFLOWS_DIR}/${name}`);
|
|
64
|
+
return await readManifests(files, paths);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Every configuration both crews read, in the domain's order rule: the manifests that state commands, then
|
|
69
|
+
* the CI workflows, then the configurations that state rules, `CONTRIBUTING.md` last.
|
|
70
|
+
*/
|
|
71
|
+
export async function readConfigFiles(files: Pick<Files, "list" | "read">): Promise<ManifestText[]> {
|
|
72
|
+
return [
|
|
73
|
+
...await readManifests(files, COMMAND_MANIFESTS),
|
|
74
|
+
...await readCiWorkflows(files),
|
|
75
|
+
...await readManifests(files, RULE_CONFIGS),
|
|
76
|
+
];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** One `<file path="…">` block, its cut line closing it when the manifest was cut. */
|
|
80
|
+
function fileBlock(m: ManifestText): string {
|
|
81
|
+
const cut = (m.cut ?? 0) > 0 ? `\n${cutLine(m.cut ?? 0)}` : "";
|
|
82
|
+
return `<file path="${m.path}">\n${m.content}${cut}\n</file>`;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* The manifests as material: one `<file path="…">` block each, in order, whole files kept while the total
|
|
87
|
+
* stays within `max` characters (a block that does not fit is left out, a later smaller one may still fit),
|
|
88
|
+
* then a line naming the files left out when there are any.
|
|
89
|
+
*/
|
|
90
|
+
export function manifestsAsMaterial(manifests: readonly ManifestText[], max = MAX_MANIFESTS_MATERIAL_CHARS): string {
|
|
91
|
+
const kept: string[] = [];
|
|
92
|
+
const leftOut: string[] = [];
|
|
93
|
+
let size = 0;
|
|
94
|
+
for (const m of manifests) {
|
|
95
|
+
const block = fileBlock(m);
|
|
96
|
+
const added = block.length + (kept.length > 0 ? 1 : 0);
|
|
97
|
+
if (size + added > max) {
|
|
98
|
+
leftOut.push(m.path);
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
kept.push(block);
|
|
102
|
+
size += added;
|
|
103
|
+
}
|
|
104
|
+
if (leftOut.length > 0) kept.push(leftOutLine(leftOut, max));
|
|
105
|
+
return kept.join("\n");
|
|
106
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// Session IO shared by commands and crews: the conversation buffer, the state
|
|
2
|
+
// bag and the token budget of the SessionStore port, plus the permission mode a
|
|
3
|
+
// session runs in, which reads the state bag and the layered /config.
|
|
4
|
+
//
|
|
5
|
+
// Built over ports (createSessionIo); the instance wired to the runtime is
|
|
6
|
+
// orkeonSessionIo() in shared/infrastructure/orkeon/. The dependency runs one
|
|
7
|
+
// way: this module reads the config store, the config store reads only the
|
|
8
|
+
// session's state bag (the port), never this module.
|
|
9
|
+
|
|
10
|
+
import type { SessionStore } from "./ports.ts";
|
|
11
|
+
import type { ConfigStore } from "./config-store.ts";
|
|
12
|
+
import { PERMISSION_FALLBACK_CONFIG_KEY, isPermissionMode, resolveFallbackMode } from "../domain/permission-modes.ts";
|
|
13
|
+
import type { FallbackResolution } from "../domain/permission-modes.ts";
|
|
14
|
+
import { DEFAULT_MODE_STATE_KEY } from "../domain/session-keys.ts";
|
|
15
|
+
|
|
16
|
+
export interface SessionIo extends SessionStore {
|
|
17
|
+
/** The session-default permission mode set by /mode, or null when unset/invalid
|
|
18
|
+
* (never throws — callers fall back to "default"). */
|
|
19
|
+
readDefaultPermissionMode(): Promise<string | null>;
|
|
20
|
+
/**
|
|
21
|
+
* Resolves the session fallback permission mode from the `permissions.fallback`
|
|
22
|
+
* config key.
|
|
23
|
+
*
|
|
24
|
+
* Reads the LAYERED value (settings file, overridden by the session bag) since
|
|
25
|
+
* B-6. Going through the layered read is not optional: a value persisted in the
|
|
26
|
+
* file and ignored here would be a setting that reports itself as effective and
|
|
27
|
+
* changes nothing — the failure mode B-6 exists to remove.
|
|
28
|
+
*
|
|
29
|
+
* Anything unreadable yields the built-in fallback: a config store that cannot be
|
|
30
|
+
* read must never be able to LOOSEN the policy. The decision itself is pure
|
|
31
|
+
* (`resolveFallbackMode`); this only fetches its input.
|
|
32
|
+
*/
|
|
33
|
+
resolveSessionFallbackMode(): Promise<FallbackResolution>;
|
|
34
|
+
/**
|
|
35
|
+
* The mode a prompt runs in when it carries no explicit "mode:" prefix: the
|
|
36
|
+
* /mode session default if set, otherwise the resolved fallback.
|
|
37
|
+
*/
|
|
38
|
+
resolveEffectiveSessionMode(): Promise<{ mode: string; via: string }>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function createSessionIo(deps: {
|
|
42
|
+
store: SessionStore;
|
|
43
|
+
config: Pick<ConfigStore, "readValue">;
|
|
44
|
+
}): SessionIo {
|
|
45
|
+
const { store, config } = deps;
|
|
46
|
+
|
|
47
|
+
async function readDefaultPermissionMode(): Promise<string | null> {
|
|
48
|
+
try {
|
|
49
|
+
const v = await store.readState(DEFAULT_MODE_STATE_KEY);
|
|
50
|
+
if (v != null && isPermissionMode(v)) return v;
|
|
51
|
+
} catch { /* session store optional */ }
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function resolveSessionFallbackMode(): Promise<FallbackResolution> {
|
|
56
|
+
let configured: unknown;
|
|
57
|
+
try {
|
|
58
|
+
configured = (await config.readValue(PERMISSION_FALLBACK_CONFIG_KEY)).value;
|
|
59
|
+
} catch { /* absent, malformed or unavailable → built-in */ }
|
|
60
|
+
return resolveFallbackMode(configured);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
readMessages: () => store.readMessages(),
|
|
65
|
+
writeMessages: (messages) => store.writeMessages(messages),
|
|
66
|
+
reset: () => store.reset(),
|
|
67
|
+
snip: (retain) => store.snip(retain),
|
|
68
|
+
setTitle: (title) => store.setTitle(title),
|
|
69
|
+
readState: (key) => store.readState(key),
|
|
70
|
+
readStates: (keys) => store.readStates(keys),
|
|
71
|
+
writeState: (key, value) => store.writeState(key, value),
|
|
72
|
+
readBudget: () => store.readBudget(),
|
|
73
|
+
// Throws when the session store cannot write; best-effort callers catch.
|
|
74
|
+
appendMessage: (role, content) => store.appendMessage(role, content),
|
|
75
|
+
readDefaultPermissionMode,
|
|
76
|
+
resolveSessionFallbackMode,
|
|
77
|
+
async resolveEffectiveSessionMode() {
|
|
78
|
+
const sessionDefault = await readDefaultPermissionMode();
|
|
79
|
+
if (sessionDefault) return { mode: sessionDefault, via: "session default via /mode" };
|
|
80
|
+
const fallback = await resolveSessionFallbackMode();
|
|
81
|
+
return { mode: fallback.mode, via: fallback.explanation };
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// JSON values of the session's state bag, over the SessionStore port. The bag
|
|
2
|
+
// holds strings, so a list or a map is stored as JSON; every reader of one goes
|
|
3
|
+
// through here so that they all agree on what an unusable value reads as.
|
|
4
|
+
|
|
5
|
+
import type { SessionStore } from "./ports.ts";
|
|
6
|
+
|
|
7
|
+
/** The parsed value of `key`; undefined when unset, malformed, or when the
|
|
8
|
+
* session store is unavailable (a host without the session tools). */
|
|
9
|
+
async function readJson(session: Pick<SessionStore, "readState">, key: string): Promise<unknown> {
|
|
10
|
+
try {
|
|
11
|
+
const raw = await session.readState(key);
|
|
12
|
+
return raw ? JSON.parse(raw) : undefined;
|
|
13
|
+
} catch {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** A JSON-array state value; unset, malformed, not an array or unreadable → []. */
|
|
19
|
+
export async function readJsonArray(session: Pick<SessionStore, "readState">, key: string): Promise<unknown[]> {
|
|
20
|
+
const value = await readJson(session, key);
|
|
21
|
+
return Array.isArray(value) ? value : [];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** A JSON-object state value; unset, malformed, not an object or unreadable → {}. */
|
|
25
|
+
export async function readJsonObject(
|
|
26
|
+
session: Pick<SessionStore, "readState">,
|
|
27
|
+
key: string,
|
|
28
|
+
): Promise<Record<string, unknown>> {
|
|
29
|
+
const value = await readJson(session, key);
|
|
30
|
+
return value && typeof value === "object" && !Array.isArray(value) ? (value as Record<string, unknown>) : {};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Persist a JSON state value. */
|
|
34
|
+
export async function writeJson(session: Pick<SessionStore, "writeState">, key: string, value: unknown): Promise<void> {
|
|
35
|
+
await session.writeState(key, JSON.stringify(value));
|
|
36
|
+
}
|