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,421 @@
|
|
|
1
|
+
// Pure /config key space and layering — no IO.
|
|
2
|
+
//
|
|
3
|
+
// B-6: the original's `/config` operates over a VALIDATED key space with
|
|
4
|
+
// settings-file persistence (baseline 04 §/config). Exp07's was a free-form
|
|
5
|
+
// session map: any key was accepted, nothing survived `/clear`, and a
|
|
6
|
+
// typo'd key was indistinguishable from a real one — it was simply stored and
|
|
7
|
+
// never read by anything.
|
|
8
|
+
//
|
|
9
|
+
// A typo mattering silently is not hypothetical here: B-2 introduced
|
|
10
|
+
// `permissions.fallback`, whose whole job is to loosen or tighten the session's
|
|
11
|
+
// permission posture. `/config set permissions.fallbck bypassPermissions` used to
|
|
12
|
+
// report success and change nothing.
|
|
13
|
+
|
|
14
|
+
import { PERMISSION_FALLBACK_CONFIG_KEY, PERMISSION_MODES } from "./permission-modes.ts";
|
|
15
|
+
import { EXTRA_TOOLS_CONFIG_KEY, extraToolsProblem, formatExtraTool, parseExtraTools } from "./agent-policy/extra-tools.ts";
|
|
16
|
+
import { sameToolName } from "./agent-policy/permission.ts";
|
|
17
|
+
import { VOICE_REPLY_CONFIG_KEY } from "./speech.ts";
|
|
18
|
+
import { ANSWER_LANGUAGE_CONFIG_KEY } from "./agent-policy/output-styles.ts";
|
|
19
|
+
import { COMPACTION_TRIGGER_CONFIG_KEY, compactionTriggerProblem } from "./compaction-thresholds.ts";
|
|
20
|
+
import { DEV_WORK_DIR_CONFIG_KEY, workFolderProblem } from "./dev/work-folder.ts";
|
|
21
|
+
import { DEV_PR_AUTO_CONFIG_KEY } from "./git/close.ts";
|
|
22
|
+
import { LLM_PROFILE_CONFIG_KEY, llmProfileProblem } from "./llm-profile.ts";
|
|
23
|
+
import {
|
|
24
|
+
MEMORY_AUTO_ADMIT_CONFIG_KEY, MEMORY_DIR_CONFIG_KEY, MEMORY_PROJECT_CONFIG_KEY, memoryDirProblem, memoryProjectProblem,
|
|
25
|
+
} from "./shared-memory/layout.ts";
|
|
26
|
+
|
|
27
|
+
export interface ConfigKeySpec {
|
|
28
|
+
key: string;
|
|
29
|
+
description: string;
|
|
30
|
+
/** Allowed values; omitted = any non-empty string. */
|
|
31
|
+
allowed?: readonly string[];
|
|
32
|
+
/** Why a value is refused, for a key whose values have a notation; undefined = valid. */
|
|
33
|
+
problem?: (value: string) => string | undefined;
|
|
34
|
+
/** Who reads the value, as the user meets it — the commands, and the crew when
|
|
35
|
+
* one reads it — so `/config keys` can say what a setting changes. */
|
|
36
|
+
consumedBy: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The declared key space. Adding a key here is what makes it settable — and the
|
|
41
|
+
* point is that the list is short and every entry names its consumer. A key
|
|
42
|
+
* nothing reads is a key that should not be settable.
|
|
43
|
+
*/
|
|
44
|
+
export const CONFIG_KEYS: readonly ConfigKeySpec[] = [
|
|
45
|
+
{
|
|
46
|
+
key: PERMISSION_FALLBACK_CONFIG_KEY,
|
|
47
|
+
description:
|
|
48
|
+
"Permission mode for a session where neither /mode nor a 'mode:' prefix set one. " +
|
|
49
|
+
"Omitted = 'default' (asks on writes, like the original).",
|
|
50
|
+
allowed: PERMISSION_MODES,
|
|
51
|
+
consumedBy: "/assistant (main-loop crew), /commit, /mode, /permissions",
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
key: "review.lenses",
|
|
55
|
+
description:
|
|
56
|
+
"Comma-separated review lenses for /review (correctness, security, style). " +
|
|
57
|
+
"Omitted = all three.",
|
|
58
|
+
consumedBy: "/review (code-review crew)",
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
key: "advisor.model",
|
|
62
|
+
description:
|
|
63
|
+
"Model used for the secondary opinion of /advisor. Omitted = the session's own " +
|
|
64
|
+
"model, which makes the review a self-review and worth far less.",
|
|
65
|
+
consumedBy: "/advisor (advisor crew)",
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
key: LLM_PROFILE_CONFIG_KEY,
|
|
69
|
+
description:
|
|
70
|
+
"The host profile the agents of every crew run on: an LLM profile (Llm:Profiles:<name>) or a decision " +
|
|
71
|
+
"profile (Orkeon:Decision:Profiles:<name>, a decision model such as Jev in front of one), e.g. 'guarded'. " +
|
|
72
|
+
"A name the host does not declare fails the crew's load, listing the profiles it knows. Omitted = the host's " +
|
|
73
|
+
"default model.",
|
|
74
|
+
problem: llmProfileProblem,
|
|
75
|
+
consumedBy: "/assistant, /review, /commit, /advisor, /memory admit, the dev steps and every other command that launches a crew (the model its agents run on)",
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
key: "commit.requireConfirm",
|
|
79
|
+
description:
|
|
80
|
+
"'false' lets /commit launch without a confirmation prompt. Omitted = 'true' " +
|
|
81
|
+
"(a confirmation is required; see B-1).",
|
|
82
|
+
allowed: ["true", "false"],
|
|
83
|
+
consumedBy: "/commit",
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
key: "spinnerVerbs",
|
|
87
|
+
description:
|
|
88
|
+
"Comma-separated verbs the TUI status line rotates through while a turn runs " +
|
|
89
|
+
"(tweakcc vocabulary: 'thinking verbs'), e.g. 'Reticulating, Percolating'. " +
|
|
90
|
+
"Omitted = the built-in Orkeon gerunds.",
|
|
91
|
+
consumedBy: "the orkeon-repl TUI status line (read by the host)",
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
key: EXTRA_TOOLS_CONFIG_KEY,
|
|
95
|
+
description:
|
|
96
|
+
"Tools of an MCP server or a plugin the assistant may use, e.g. 'transcribe_audio:read, " +
|
|
97
|
+
"search_issues': each <name>[:read|:write], write when the class is left out, so plan " +
|
|
98
|
+
"and dontAsk offer only the read ones. A name the host does not register is left out " +
|
|
99
|
+
"with a warning. Omitted = none.",
|
|
100
|
+
problem: extraToolsProblem,
|
|
101
|
+
consumedBy: "/assistant and /summary (the tools offered), /permissions (rules may name them)",
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
key: VOICE_REPLY_CONFIG_KEY,
|
|
105
|
+
description:
|
|
106
|
+
"'on' reads every answer of the assistant aloud, through the speech MCP server's speak " +
|
|
107
|
+
"(the launcher's ORKEON_CODE_VOICE=1 opens the speaker); code blocks and tables are not read. " +
|
|
108
|
+
"Omitted = 'off'.",
|
|
109
|
+
allowed: ["on", "off"],
|
|
110
|
+
consumedBy: "/assistant, /summary, /transcribe --then, /voice send and /voice --go (each answer read aloud)",
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
key: ANSWER_LANGUAGE_CONFIG_KEY,
|
|
114
|
+
description:
|
|
115
|
+
"The language the assistant answers in, e.g. 'French', unless the user writes in another one. " +
|
|
116
|
+
"Omitted = the language of each request.",
|
|
117
|
+
consumedBy: "/assistant, /summary, /transcribe --then, /voice send and /voice --go (the main loop's prompt)",
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
key: COMPACTION_TRIGGER_CONFIG_KEY,
|
|
121
|
+
description:
|
|
122
|
+
"The token count at which the automatic compaction runs, e.g. '90000' or '90k'. Omitted = the " +
|
|
123
|
+
"context window minus the room one turn needs.",
|
|
124
|
+
problem: compactionTriggerProblem,
|
|
125
|
+
consumedBy: "/assistant (the automatic compaction at the head and the tail of a turn), /usage",
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
key: DEV_WORK_DIR_CONFIG_KEY,
|
|
129
|
+
description:
|
|
130
|
+
"The work folder of the dev workflow, relative to the checkout, e.g. 'backstage/tasks'. Omitted = the " +
|
|
131
|
+
"repository pack's layout.work, else 'workbench'. A folder absent from the checkout falls back to 'workbench'.",
|
|
132
|
+
problem: workFolderProblem,
|
|
133
|
+
consumedBy: "/dev-status (the work folder it reads), /commit (the work folder it leaves out)",
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
key: DEV_PR_AUTO_CONFIG_KEY,
|
|
137
|
+
description:
|
|
138
|
+
"'true' asks /commit to open the pull request of a pushed branch, as --pr does: through the github tool when " +
|
|
139
|
+
"it is registered and the permission gate lets it, else the gh pr create command is printed. Omitted = 'false': " +
|
|
140
|
+
"the command is printed. Set in the user settings; a project file may only narrow it to 'false'.",
|
|
141
|
+
allowed: ["true", "false"],
|
|
142
|
+
consumedBy: "/commit (the pull request of the branch)",
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
key: MEMORY_DIR_CONFIG_KEY,
|
|
146
|
+
description:
|
|
147
|
+
"The folder of the shared memory, relative to the project: its candidates, admitted entries and refused " +
|
|
148
|
+
"topics. Omitted = '.orkeon/memory'. Never the agent memory's '.orkeon/agent-memory'.",
|
|
149
|
+
problem: memoryDirProblem,
|
|
150
|
+
consumedBy: "/memory-admit, /assistant (the memory_recall and memory_push tools)",
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
key: MEMORY_PROJECT_CONFIG_KEY,
|
|
154
|
+
description:
|
|
155
|
+
"The project name the shared memory's entries carry and its index is named after (memory-<project>), " +
|
|
156
|
+
"e.g. 'orkeon-code'. Omitted = the name of the origin remote, else 'local'.",
|
|
157
|
+
problem: memoryProjectProblem,
|
|
158
|
+
consumedBy: "/memory-admit, /assistant (the memory_recall and memory_push tools)",
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
key: MEMORY_AUTO_ADMIT_CONFIG_KEY,
|
|
162
|
+
description:
|
|
163
|
+
"'true' lets /memory-admit admit a candidate an audit verdict backs without asking. Omitted = 'false': " +
|
|
164
|
+
"every candidate is confirmed. A project file may set it to 'true' only when the user settings do.",
|
|
165
|
+
allowed: ["true", "false"],
|
|
166
|
+
consumedBy: "/memory-admit",
|
|
167
|
+
},
|
|
168
|
+
];
|
|
169
|
+
|
|
170
|
+
/** Where an effective value came from: the session bag, the project's settings file
|
|
171
|
+
* (`file`), the user settings the launcher mounts read-only (`user`), or nowhere. */
|
|
172
|
+
export type ConfigSource = "session" | "file" | "user" | "unset";
|
|
173
|
+
|
|
174
|
+
export interface ConfigResolution {
|
|
175
|
+
key: string;
|
|
176
|
+
value: string | undefined;
|
|
177
|
+
source: ConfigSource;
|
|
178
|
+
/** The project file's value, or the part of it, set aside because a project file
|
|
179
|
+
* widens nothing (QL-06), and why. */
|
|
180
|
+
ignored?: { value: string; reason: string };
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** The modes a project file may set as the fallback; a wider one comes from the user. */
|
|
184
|
+
export const PROJECT_FALLBACK_MODES: readonly string[] = ["default", "plan", "acceptEdits"];
|
|
185
|
+
|
|
186
|
+
/** What a project value leaves in force once narrowed: the value that applies (undefined
|
|
187
|
+
* = none, the user's then applies only when `fallThrough`), and what was set aside. */
|
|
188
|
+
interface Narrowed {
|
|
189
|
+
value: string | undefined;
|
|
190
|
+
fallThrough: boolean;
|
|
191
|
+
ignored?: { value: string; reason: string };
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** How far a fallback mode lets a session act without asking: the read-only modes
|
|
195
|
+
* first. A mode that is not one ranks as `default`, which it resolves to. */
|
|
196
|
+
const MODE_WIDTH: Readonly<Record<string, number>> = {
|
|
197
|
+
plan: 0, dontAsk: 0, default: 1, acceptEdits: 2, bypassPermissions: 3,
|
|
198
|
+
};
|
|
199
|
+
const modeWidth = (mode: string): number => MODE_WIDTH[mode] ?? MODE_WIDTH.default;
|
|
200
|
+
|
|
201
|
+
/** The project's fallback: one of PROJECT_FALLBACK_MODES, and never wider than the
|
|
202
|
+
* mode the user settings set (with none, QL-06 lets it set acceptEdits). */
|
|
203
|
+
function narrowFallback(project: string, user: string | undefined): Narrowed {
|
|
204
|
+
const ignore = (reason: string): Narrowed => ({ value: undefined, fallThrough: true, ignored: { value: project, reason } });
|
|
205
|
+
if (!PROJECT_FALLBACK_MODES.includes(project)) {
|
|
206
|
+
return ignore("a project file may set only default, plan or acceptEdits; another mode comes from the " +
|
|
207
|
+
"user settings (orkeonCode) or /mode");
|
|
208
|
+
}
|
|
209
|
+
if (user !== undefined && modeWidth(project) > modeWidth(user)) {
|
|
210
|
+
return ignore(`it is wider than the user settings' '${user}' (orkeonCode); a project file may only narrow it`);
|
|
211
|
+
}
|
|
212
|
+
return { value: project, fallThrough: false };
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const ALL_TOOLS = "*";
|
|
216
|
+
|
|
217
|
+
/** The entries of a `tools.extra` value, `*` apart. */
|
|
218
|
+
function userToolEntries(user: string | undefined): { all: boolean; rest: string[] } {
|
|
219
|
+
const entries = String(user ?? "").split(/[\s,]+/).filter((e) => e.length > 0);
|
|
220
|
+
return { all: entries.includes(ALL_TOOLS), rest: entries.filter((e) => e !== ALL_TOOLS) };
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/** The project's extra tools the user lists too (or every one, under `*`), each `read`
|
|
224
|
+
* only when both lists say `read` — a read tool is the wider grant, offered in plan and
|
|
225
|
+
* dontAsk too — and `write` under `*`, which grants the tools, not their class; the
|
|
226
|
+
* others set aside. An entry that does not parse stays, as written, for the reader to
|
|
227
|
+
* warn about, unless it names a tool the project lists in a valid entry: a second
|
|
228
|
+
* entry of a dropped tool would parse once its twin is gone. Never the user's list in
|
|
229
|
+
* place of the project's: narrowing a list never widens it. */
|
|
230
|
+
function narrowExtraTools(project: string, user: string | undefined): Narrowed {
|
|
231
|
+
const { all, rest } = userToolEntries(user);
|
|
232
|
+
const allowed = parseExtraTools(rest).tools;
|
|
233
|
+
const { tools, invalid } = parseExtraTools(project);
|
|
234
|
+
const kept: string[] = [];
|
|
235
|
+
const dropped: string[] = [];
|
|
236
|
+
for (const tool of tools) {
|
|
237
|
+
const listed = allowed.find((t) => sameToolName(t.name, tool.name));
|
|
238
|
+
if (listed === undefined && !all) {
|
|
239
|
+
dropped.push(formatExtraTool(tool));
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
const read = listed?.access === "read" && tool.access === "read";
|
|
243
|
+
kept.push(formatExtraTool({ name: tool.name, access: read ? "read" : "write" }));
|
|
244
|
+
}
|
|
245
|
+
// `evil:write, evil:read`: the read twin is invalid only while the write one stands.
|
|
246
|
+
const named = (entry: string): boolean => tools.some((t) => sameToolName(t.name, entry.split(":", 1)[0]));
|
|
247
|
+
const value = [...kept, ...invalid.filter((entry) => !named(entry))];
|
|
248
|
+
return {
|
|
249
|
+
value: value.length > 0 ? value.join(", ") : undefined,
|
|
250
|
+
fallThrough: false,
|
|
251
|
+
...(dropped.length > 0
|
|
252
|
+
? { ignored: { value: dropped.join(", "), reason: "the user settings do not allow (orkeonCode tools.extra, or *)" } }
|
|
253
|
+
: {}),
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/** The user's value as it applies: `tools.extra` without its `*`, which grants, names no tool. */
|
|
258
|
+
function userValue(key: string, user: string): string | undefined {
|
|
259
|
+
if (key !== EXTRA_TOOLS_CONFIG_KEY) return user;
|
|
260
|
+
const { rest } = userToolEntries(user);
|
|
261
|
+
return rest.length > 0 ? rest.join(", ") : undefined;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/** The project's memory.autoAdmitAudited: 'true' asks nothing, so it applies only when the user's says 'true'. */
|
|
265
|
+
function narrowAutoAdmit(project: string, user: string | undefined): Narrowed {
|
|
266
|
+
if (project !== "true" || user === "true") return { value: project, fallThrough: false };
|
|
267
|
+
return {
|
|
268
|
+
value: undefined, fallThrough: true,
|
|
269
|
+
ignored: { value: project, reason: "admitting without asking comes from the user settings (orkeonCode); a project file may only narrow it" },
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/** The project's dev.prAuto: 'true' opens a pull request without asking, so it applies only when the user's says 'true'. */
|
|
274
|
+
function narrowPrAuto(project: string, user: string | undefined): Narrowed {
|
|
275
|
+
if (project !== "true" || user === "true") return { value: project, fallThrough: false };
|
|
276
|
+
return {
|
|
277
|
+
value: undefined, fallThrough: true,
|
|
278
|
+
ignored: { value: project, reason: "opening a pull request without asking comes from the user settings (orkeonCode); a project file may only narrow it" },
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/** The project value as it applies over the user's: narrowed for the keys that widen. */
|
|
283
|
+
function narrowProject(key: string, project: string, user: string | undefined): Narrowed {
|
|
284
|
+
if (key === DEV_PR_AUTO_CONFIG_KEY) return narrowPrAuto(project, user);
|
|
285
|
+
if (key === PERMISSION_FALLBACK_CONFIG_KEY) return narrowFallback(project, user);
|
|
286
|
+
if (key === EXTRA_TOOLS_CONFIG_KEY) return narrowExtraTools(project, user);
|
|
287
|
+
if (key === MEMORY_AUTO_ADMIT_CONFIG_KEY) return narrowAutoAdmit(project, user);
|
|
288
|
+
return { value: project, fallThrough: false };
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
export function configKeySpec(key: unknown): ConfigKeySpec | undefined {
|
|
292
|
+
const k = String(key ?? "").trim();
|
|
293
|
+
return CONFIG_KEYS.find((s) => s.key === k);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export function isKnownConfigKey(key: unknown): boolean {
|
|
297
|
+
return configKeySpec(key) !== undefined;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/** The valid-key list, for the rejection message (acceptance 1). */
|
|
301
|
+
export function knownConfigKeys(): string[] {
|
|
302
|
+
return CONFIG_KEYS.map((s) => s.key);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
export interface ValueVerdict {
|
|
306
|
+
ok: boolean;
|
|
307
|
+
/** Why not, naming the allowed values when the key constrains them. */
|
|
308
|
+
reason: string;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Validates a value against its key's spec.
|
|
313
|
+
*
|
|
314
|
+
* An unknown KEY is rejected with the whole list, because the useful reply to a
|
|
315
|
+
* typo is the nearby correct spelling. An invalid VALUE is rejected with that
|
|
316
|
+
* key's allowed set, for the same reason.
|
|
317
|
+
*/
|
|
318
|
+
export function validateConfigEntry(key: unknown, value: unknown): ValueVerdict {
|
|
319
|
+
const spec = configKeySpec(key);
|
|
320
|
+
if (!spec) {
|
|
321
|
+
return {
|
|
322
|
+
ok: false,
|
|
323
|
+
reason: `unknown config key '${String(key ?? "")}'. Valid keys: ${knownConfigKeys().join(", ")}`,
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
const v = String(value ?? "").trim();
|
|
327
|
+
if (v.length === 0) return { ok: false, reason: `'${spec.key}' needs a value.` };
|
|
328
|
+
if (spec.allowed && !spec.allowed.includes(v)) {
|
|
329
|
+
return {
|
|
330
|
+
ok: false,
|
|
331
|
+
reason: `'${v}' is not valid for '${spec.key}'. Allowed: ${spec.allowed.join(", ")}`,
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
const problem = spec.problem?.(v);
|
|
335
|
+
if (problem !== undefined) return { ok: false, reason: `'${v}' is not valid for '${spec.key}': ${problem}` };
|
|
336
|
+
return { ok: true, reason: "" };
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Layers the session map over the project file's map over the user settings' map, key
|
|
341
|
+
* by key.
|
|
342
|
+
*
|
|
343
|
+
* The session wins where it is set: a `/config set --session` is a deliberate,
|
|
344
|
+
* temporary override of a persisted setting, and `/clear` drops it back to
|
|
345
|
+
* the file value. The project file comes next, but widens nothing (QL-06): its
|
|
346
|
+
* `permissions.fallback` applies only as default, plan or acceptEdits, its
|
|
347
|
+
* `tools.extra` only for the tools the user settings list, its `dev.prAuto` and
|
|
348
|
+
* `memory.autoAdmitAudited` 'true' only when the user settings say 'true'; what it
|
|
349
|
+
* loses is returned as `ignored`. The user map is a required argument: a caller that forgets
|
|
350
|
+
* it must not read a project value unnarrowed. Unknown keys present in any map are
|
|
351
|
+
* NOT returned — they can only be residue from before the schema existed, and
|
|
352
|
+
* surfacing them as effective settings would suggest something reads them.
|
|
353
|
+
*/
|
|
354
|
+
export function layerConfig(
|
|
355
|
+
fileMap: Record<string, unknown> | null | undefined,
|
|
356
|
+
sessionMap: Record<string, unknown> | null | undefined,
|
|
357
|
+
userMap: Record<string, unknown> | null | undefined,
|
|
358
|
+
): ConfigResolution[] {
|
|
359
|
+
return CONFIG_KEYS.map((spec): ConfigResolution => {
|
|
360
|
+
const s = stringValue(sessionMap?.[spec.key]);
|
|
361
|
+
if (s !== undefined) return { key: spec.key, value: s, source: "session" };
|
|
362
|
+
const rawUser = stringValue(userMap?.[spec.key]);
|
|
363
|
+
const user = rawUser === undefined ? undefined : userValue(spec.key, rawUser);
|
|
364
|
+
const fromUser: ConfigResolution = user === undefined
|
|
365
|
+
? { key: spec.key, value: undefined, source: "unset" }
|
|
366
|
+
: { key: spec.key, value: user, source: "user" };
|
|
367
|
+
const f = stringValue(fileMap?.[spec.key]);
|
|
368
|
+
if (f === undefined) return fromUser;
|
|
369
|
+
const narrowed = narrowProject(spec.key, f, rawUser);
|
|
370
|
+
const ignored = narrowed.ignored === undefined ? {} : { ignored: narrowed.ignored };
|
|
371
|
+
if (narrowed.value !== undefined) return { key: spec.key, value: narrowed.value, source: "file", ...ignored };
|
|
372
|
+
if (narrowed.fallThrough) return { ...fromUser, ...ignored };
|
|
373
|
+
return { key: spec.key, value: undefined, source: "unset", ...ignored };
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/** A map's value as a setting: a non-blank string, trimmed. */
|
|
378
|
+
function stringValue(raw: unknown): string | undefined {
|
|
379
|
+
return typeof raw === "string" && raw.trim().length > 0 ? raw.trim() : undefined;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/** The effective value of one key, or undefined when unset in every layer. */
|
|
383
|
+
export function resolveConfigEntry(
|
|
384
|
+
key: string,
|
|
385
|
+
fileMap: Record<string, unknown> | null | undefined,
|
|
386
|
+
sessionMap: Record<string, unknown> | null | undefined,
|
|
387
|
+
userMap: Record<string, unknown> | null | undefined,
|
|
388
|
+
): ConfigResolution {
|
|
389
|
+
return layerConfig(fileMap, sessionMap, userMap).find((r) => r.key === key)
|
|
390
|
+
?? { key, value: undefined, source: "unset" };
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Keys present in a stored map that the schema does not know.
|
|
395
|
+
*
|
|
396
|
+
* Reported rather than deleted: they are someone's data, written when any key was
|
|
397
|
+
* accepted, and silently dropping them on the next write is how a free-form map
|
|
398
|
+
* becomes a schema with data loss in between.
|
|
399
|
+
*/
|
|
400
|
+
export function unknownStoredKeys(map: Record<string, unknown> | null | undefined): string[] {
|
|
401
|
+
return Object.keys(map ?? {}).filter((k) => !isKnownConfigKey(k)).sort();
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Known keys a stored map holds nested (`{"permissions": {"fallback": "plan"}}`) instead
|
|
406
|
+
* of flat (`{"permissions.fallback": "plan"}`): nothing reads them, so they are named
|
|
407
|
+
* with the flat spelling a hand-written file needs.
|
|
408
|
+
*/
|
|
409
|
+
export function nestedConfigKeys(map: Record<string, unknown> | null | undefined): string[] {
|
|
410
|
+
const found: string[] = [];
|
|
411
|
+
const walk = (prefix: string, value: unknown): void => {
|
|
412
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return;
|
|
413
|
+
for (const [k, v] of Object.entries(value as Record<string, unknown>)) {
|
|
414
|
+
const key = `${prefix}.${k}`;
|
|
415
|
+
if (isKnownConfigKey(key)) found.push(key);
|
|
416
|
+
else walk(key, v);
|
|
417
|
+
}
|
|
418
|
+
};
|
|
419
|
+
for (const [k, v] of Object.entries(map ?? {})) if (!isKnownConfigKey(k)) walk(k, v);
|
|
420
|
+
return found.sort();
|
|
421
|
+
}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
// The access cost of a batch, measured by the runtime's `access_cost` over the code index: the
|
|
2
|
+
// reader of its report, the added lines of a diff, the mapping to `exit 0|2`, the flagged calls,
|
|
3
|
+
// the `Cost` line of the harness's access-cost.py, and the text of the capture's `cost` section.
|
|
4
|
+
// A port call, or an in-memory filter, inside a loop or a lambda blocks only on an added line, as
|
|
5
|
+
// `access-cost.py --diff` does. Pure.
|
|
6
|
+
import { WORKSPACE, workspaceRelative } from "../vfs.ts";
|
|
7
|
+
|
|
8
|
+
export type AccessCost =
|
|
9
|
+
| { state: "not-computed"; reason: string }
|
|
10
|
+
| { state: "measured"; exit: 0 | 2; flagged: string[]; costLine: string; detail: string };
|
|
11
|
+
|
|
12
|
+
export interface PortCall { receiver: string; method: string; line: number; inLoop: boolean; inLambda: boolean }
|
|
13
|
+
export interface MemoryFilter { line: number; method: string }
|
|
14
|
+
export interface CostTotals { reads: number; writes: number; loops: number; lambdas: number; memoryFilters: number }
|
|
15
|
+
export interface MemberCost { member: string; portCalls: PortCall[]; memoryFilters: MemoryFilter[]; cost: CostTotals }
|
|
16
|
+
export interface AccessCostReport { members: MemberCost[]; cost: CostTotals }
|
|
17
|
+
|
|
18
|
+
/** A root is a test root when its lower-case path holds "test" (AC:92,324). */
|
|
19
|
+
export function isTestRoot(root: string): boolean {
|
|
20
|
+
return root.toLowerCase().includes("test");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Under a test root, or a path that says test (AC:326-331). */
|
|
24
|
+
export function isTestFile(path: string, testRoots: readonly string[]): boolean {
|
|
25
|
+
for (const r of testRoots) if (path.startsWith(`${r.replace(/\/+$/, "")}/`)) return true;
|
|
26
|
+
return path.toLowerCase().includes("test");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** The cost when the crew wires no code index. */
|
|
30
|
+
export const COST_NOT_WIRED: AccessCost = {
|
|
31
|
+
state: "not-computed",
|
|
32
|
+
reason: "the crew wires no code index; judge the Cost axis from the diff",
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export function notComputed(reason: string): AccessCost {
|
|
36
|
+
return { state: "not-computed", reason };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** No `/workspace` root in the index: the use case says so itself, the tool would answer an empty report. */
|
|
40
|
+
export function notIndexed(roots: readonly string[]): AccessCost {
|
|
41
|
+
const holds = roots.length === 0 ? "the code index is empty" : `the code index holds ${roots.join(", ")}, not ${WORKSPACE}`;
|
|
42
|
+
return notComputed(`not indexed — ${holds}: run /analyze, then audit the batch again; judge the Cost axis from the diff`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The runtime's default receivers (AccessCostService.cs:13-17), which a `receivers` argument replaces. Kept
|
|
47
|
+
* here so that the pack's regex adds to it, as access-cost.py reads `tools.access_cost.receivers`.
|
|
48
|
+
*/
|
|
49
|
+
export const DEFAULT_RECEIVERS =
|
|
50
|
+
"repositor|service|wrapper|client|provider|unitofwork|dbcontext|dbset|gateway|store|" +
|
|
51
|
+
"publisher|bus|mediator|cache|queue|adapter|channel|hub|sandbox|filesystem|" +
|
|
52
|
+
"^(this\\.)?_?(db|context|fs)$";
|
|
53
|
+
|
|
54
|
+
/** The `receivers` argument: none without the pack's regex, else the default or the pack's, case-insensitive. */
|
|
55
|
+
export function receiversArgument(pack: string | undefined): string | undefined {
|
|
56
|
+
if (pack === undefined || pack.trim() === "") return undefined;
|
|
57
|
+
return `(?i)(?:${DEFAULT_RECEIVERS})|(?:${pack.trim()})`;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** The changed files the cost reads: under one of `roots` (all of them when `roots` is empty). */
|
|
61
|
+
export function underRoots(files: readonly string[], roots: readonly string[]): string[] {
|
|
62
|
+
const kept = roots.map((r) => r.trim().replace(/^\.\//, "").replace(/\/+$/, ""));
|
|
63
|
+
if (kept.length === 0 || kept.some((r) => r === "" || r === ".")) return [...files];
|
|
64
|
+
return files.filter((f) => kept.some((r) => f === r || f.startsWith(`${r}/`)));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** The 1-based line numbers a unified diff adds to the new file; null when the text holds no hunk. */
|
|
68
|
+
export function addedLines(diff: string): Set<number> | null {
|
|
69
|
+
const added = new Set<number>();
|
|
70
|
+
let line = 0;
|
|
71
|
+
let inHunk = false;
|
|
72
|
+
let hunks = 0;
|
|
73
|
+
for (const text of diff.split("\n")) {
|
|
74
|
+
const hunk = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(text);
|
|
75
|
+
if (hunk !== null) { line = Number(hunk[1]); inHunk = true; hunks++; continue; }
|
|
76
|
+
if (!inHunk) continue;
|
|
77
|
+
if (text.startsWith("diff --git ")) { inHunk = false; continue; }
|
|
78
|
+
if (text.startsWith("+")) { added.add(line); line++; }
|
|
79
|
+
else if (text.startsWith(" ")) line++;
|
|
80
|
+
}
|
|
81
|
+
return hunks === 0 ? null : added;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function num(v: unknown): number | null {
|
|
85
|
+
return typeof v === "number" && Number.isFinite(v) ? v : null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function totals(raw: unknown): CostTotals | null {
|
|
89
|
+
if (raw === null || typeof raw !== "object") return null;
|
|
90
|
+
const r = raw as Record<string, unknown>;
|
|
91
|
+
const reads = num(r.reads), writes = num(r.writes), loops = num(r.loops), lambdas = num(r.lambdas);
|
|
92
|
+
const memoryFilters = num(r.memory_filters);
|
|
93
|
+
if (reads === null || writes === null || loops === null || lambdas === null || memoryFilters === null) return null;
|
|
94
|
+
return { reads, writes, loops, lambdas, memoryFilters };
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** The `report` of `access_cost` (AccessCostDtos.cs, snake_case); null when a field is missing or mistyped. */
|
|
98
|
+
export function readAccessCostReport(raw: unknown): AccessCostReport | null {
|
|
99
|
+
if (raw === null || typeof raw !== "object") return null;
|
|
100
|
+
const r = raw as Record<string, unknown>;
|
|
101
|
+
const cost = totals(r.cost);
|
|
102
|
+
if (cost === null || !Array.isArray(r.members)) return null;
|
|
103
|
+
const members: MemberCost[] = [];
|
|
104
|
+
for (const m of r.members as unknown[]) {
|
|
105
|
+
if (m === null || typeof m !== "object") return null;
|
|
106
|
+
const o = m as Record<string, unknown>;
|
|
107
|
+
const memberCost = totals(o.cost);
|
|
108
|
+
if (typeof o.member !== "string" || memberCost === null || !Array.isArray(o.port_calls) || !Array.isArray(o.in_memory_filters)) return null;
|
|
109
|
+
const portCalls: PortCall[] = [];
|
|
110
|
+
for (const c of o.port_calls as unknown[]) {
|
|
111
|
+
const p = (c ?? {}) as Record<string, unknown>;
|
|
112
|
+
const line = num(p.line);
|
|
113
|
+
if (typeof p.receiver !== "string" || typeof p.method !== "string" || line === null) return null;
|
|
114
|
+
portCalls.push({ receiver: p.receiver, method: p.method, line, inLoop: p.in_loop === true, inLambda: p.in_lambda === true });
|
|
115
|
+
}
|
|
116
|
+
const memoryFilters: MemoryFilter[] = [];
|
|
117
|
+
for (const f of o.in_memory_filters as unknown[]) {
|
|
118
|
+
const p = (f ?? {}) as Record<string, unknown>;
|
|
119
|
+
const line = num(p.line);
|
|
120
|
+
if (typeof p.method !== "string" || line === null) return null;
|
|
121
|
+
memoryFilters.push({ line, method: p.method });
|
|
122
|
+
}
|
|
123
|
+
members.push({ member: o.member, portCalls, memoryFilters, cost: memberCost });
|
|
124
|
+
}
|
|
125
|
+
return { members, cost };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const LIST_MAX = 12;
|
|
129
|
+
|
|
130
|
+
function plural(n: number, word: string): string {
|
|
131
|
+
return `${n} ${word}${n === 1 ? "" : "s"}`;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** The member as the capture shows it: its path relative to the checkout. */
|
|
135
|
+
function shownMember(fqn: string): string {
|
|
136
|
+
return workspaceRelative(fqn);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** The file of a member: its FQN up to the first `::` (UniversalSemanticMapper.cs:371). */
|
|
140
|
+
function fileOf(fqn: string): string {
|
|
141
|
+
const at = fqn.indexOf("::");
|
|
142
|
+
return at < 0 ? fqn : fqn.slice(0, at);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** The `Cost` line of access-cost.py:261. */
|
|
146
|
+
export function costLineOf(reads: number, writes: number, blocking: number): string {
|
|
147
|
+
const verdict = blocking === 0 ? "none" : `${blocking} - back to design`;
|
|
148
|
+
return `Cost: ${plural(reads, "read")} + ${plural(writes, "write")} through ports outside loops; ` +
|
|
149
|
+
`in a loop, a lambda or a memory filter: ${verdict}`;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* The measured cost of `report`. `added` maps a member's file (its virtual path) to the lines its diff adds;
|
|
154
|
+
* a file absent from it, or mapped to null, has unknown lines, which count as added.
|
|
155
|
+
*/
|
|
156
|
+
export function measuredCost(report: AccessCostReport, added: ReadonlyMap<string, Set<number> | null>): AccessCost {
|
|
157
|
+
const detail: string[] = [];
|
|
158
|
+
const flagged: string[] = [];
|
|
159
|
+
const isAdded = (fqn: string, line: number): boolean => {
|
|
160
|
+
const lines = added.get(fileOf(fqn));
|
|
161
|
+
return lines === undefined || lines === null || lines.has(line);
|
|
162
|
+
};
|
|
163
|
+
const show = (title: string, items: string[]): void => {
|
|
164
|
+
if (items.length === 0) return;
|
|
165
|
+
const more = items.length > LIST_MAX ? ` / … +${items.length - LIST_MAX}` : "";
|
|
166
|
+
detail.push(`${title} (${items.length}): ${items.slice(0, LIST_MAX).join(" / ")}${more}`);
|
|
167
|
+
};
|
|
168
|
+
for (const m of report.members) {
|
|
169
|
+
if (m.portCalls.length === 0 && m.memoryFilters.length === 0) continue;
|
|
170
|
+
const member = shownMember(m.member);
|
|
171
|
+
const flat: string[] = [], loop: string[] = [], lambda: string[] = [], filters: string[] = [];
|
|
172
|
+
for (const c of m.portCalls) {
|
|
173
|
+
const label = `${c.receiver}.${c.method} L${c.line}`;
|
|
174
|
+
if (!c.inLoop && !c.inLambda) { flat.push(label); continue; }
|
|
175
|
+
const where = c.inLoop ? "in a loop" : "in a lambda";
|
|
176
|
+
const blocks = isAdded(m.member, c.line);
|
|
177
|
+
(c.inLoop ? loop : lambda).push(blocks ? label : `${label} (pre-existing)`);
|
|
178
|
+
if (blocks) flagged.push(`${member} L${c.line} ${c.receiver}.${c.method} ${where}`);
|
|
179
|
+
}
|
|
180
|
+
for (const f of m.memoryFilters) {
|
|
181
|
+
const blocks = isAdded(m.member, f.line);
|
|
182
|
+
filters.push(blocks ? `L${f.line} ${f.method}` : `L${f.line} ${f.method} (pre-existing)`);
|
|
183
|
+
if (blocks) flagged.push(`${member} L${f.line} ${f.method} memory filter`);
|
|
184
|
+
}
|
|
185
|
+
detail.push(`[${member}]`);
|
|
186
|
+
show("Ports outside loops", flat);
|
|
187
|
+
show("Ports in a loop", loop);
|
|
188
|
+
show("Ports in a lambda", lambda);
|
|
189
|
+
show("Memory filter on an awaited result", filters);
|
|
190
|
+
}
|
|
191
|
+
if (detail.length === 0) {
|
|
192
|
+
detail.push(report.members.length === 0
|
|
193
|
+
? "no member of the changed files in the code index"
|
|
194
|
+
: `${plural(report.members.length, "member")}, none awaits a port or filters in memory`);
|
|
195
|
+
}
|
|
196
|
+
return {
|
|
197
|
+
state: "measured",
|
|
198
|
+
exit: flagged.length > 0 ? 2 : 0,
|
|
199
|
+
flagged,
|
|
200
|
+
costLine: costLineOf(report.cost.reads, report.cost.writes, flagged.length),
|
|
201
|
+
detail: `${detail.join("\n")}\n`,
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** A batch that changes no file under the cost roots: nothing to measure, nothing blocks. */
|
|
206
|
+
export function nothingChanged(roots: readonly string[]): AccessCost {
|
|
207
|
+
const where = roots.length === 0 ? "" : ` under ${roots.join(" ")}`;
|
|
208
|
+
return { state: "measured", exit: 0, flagged: [], costLine: costLineOf(0, 0, 0), detail: `no changed file${where}\n` };
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** The line the command prints under the gate's green line. */
|
|
212
|
+
export function costSummary(cost: AccessCost): string {
|
|
213
|
+
return cost.state === "measured" ? cost.costLine : `Cost: not computed — ${cost.reason}`;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const DETAIL_LINES = 60;
|
|
217
|
+
|
|
218
|
+
export function costSection(cost: AccessCost): string {
|
|
219
|
+
if (cost.state === "not-computed") return `not computed: ${cost.reason}\n`;
|
|
220
|
+
const detail = cost.detail.split("\n");
|
|
221
|
+
if (detail.length > 0 && detail[detail.length - 1] === "") detail.pop();
|
|
222
|
+
const out = [`exit: ${cost.exit}`, ...detail.slice(0, DETAIL_LINES)];
|
|
223
|
+
if (detail.length > DETAIL_LINES) out.push(`[cut at ${DETAIL_LINES} lines]`);
|
|
224
|
+
out.push(cost.costLine);
|
|
225
|
+
return `${out.join("\n")}\n`;
|
|
226
|
+
}
|