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,97 @@
|
|
|
1
|
+
// /diff — the typed `--staged` flag the baseline specifies, and the allowlist
|
|
2
|
+
// of options and pathspecs that reach `git diff` (B-11 deepening); runDiff runs
|
|
3
|
+
// it over the Shell port. Lives under commands/_lib/ — the loader's SearchPattern
|
|
4
|
+
// is "*.cmd.ts", so this file is never loaded as a command.
|
|
5
|
+
|
|
6
|
+
import type { Logger, Shell } from "../../../shared/application/ports.ts";
|
|
7
|
+
import type { CommandView } from "../view.ts";
|
|
8
|
+
|
|
9
|
+
export interface DiffPlan {
|
|
10
|
+
/** The git argument string, already assembled. */
|
|
11
|
+
args: string;
|
|
12
|
+
staged: boolean;
|
|
13
|
+
/** Tokens that were dropped, with the reason — never silently ignored. */
|
|
14
|
+
rejected: Array<{ value: string; reason: string }>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Only these git-diff options are honoured.
|
|
19
|
+
*
|
|
20
|
+
* The pre-B-11 handler appended `raw` verbatim: `git diff <anything the operator
|
|
21
|
+
* typed>`. The shell tool forbids operators, so this was not an injection hole,
|
|
22
|
+
* but it was an unbounded surface — `--output=/etc/x` is a plain git option that
|
|
23
|
+
* writes a file, and no allowlist stood in the way. The baseline specifies exactly
|
|
24
|
+
* one flag (`staged`); the extra safe options below are the ones a diff reader
|
|
25
|
+
* actually reaches for, and anything else is refused BY NAME so the operator knows.
|
|
26
|
+
*/
|
|
27
|
+
export const ALLOWED_DIFF_FLAGS = [
|
|
28
|
+
"--staged", "--cached", "--stat", "--name-only", "--name-status",
|
|
29
|
+
"--numstat", "--shortstat", "-p", "--unified", "--word-diff",
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
/** A pathspec: no leading dash, no shell metacharacter, no parent traversal. */
|
|
33
|
+
const SAFE_PATHSPEC = /^[A-Za-z0-9._/\-*]+$/;
|
|
34
|
+
|
|
35
|
+
export function planDiff(tokens: readonly string[]): DiffPlan {
|
|
36
|
+
const rejected: Array<{ value: string; reason: string }> = [];
|
|
37
|
+
const flags: string[] = [];
|
|
38
|
+
const paths: string[] = [];
|
|
39
|
+
|
|
40
|
+
for (const raw of tokens ?? []) {
|
|
41
|
+
const token = String(raw ?? "").trim();
|
|
42
|
+
if (token.length === 0) continue;
|
|
43
|
+
|
|
44
|
+
if (token.startsWith("-")) {
|
|
45
|
+
// `--unified=3` and `-U3` carry a value; compare on the option part.
|
|
46
|
+
const head = token.split("=")[0];
|
|
47
|
+
if (ALLOWED_DIFF_FLAGS.includes(head)) flags.push(token);
|
|
48
|
+
else rejected.push({ value: token, reason: `not an allowed diff option (allowed: ${ALLOWED_DIFF_FLAGS.join(" ")})` });
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (!SAFE_PATHSPEC.test(token) || token.includes("..")) {
|
|
53
|
+
rejected.push({ value: token, reason: "not a plausible pathspec (letters, digits, '.', '_', '/', '-', '*'; no '..')" });
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
paths.push(token);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const staged = flags.some((f) => f === "--staged" || f === "--cached");
|
|
60
|
+
// `--` separates options from pathspecs, so a path that looks like a ref stays a path.
|
|
61
|
+
const args = [...flags, ...(paths.length > 0 ? ["--", ...paths] : [])].join(" ");
|
|
62
|
+
return { args, staged, rejected };
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Baseline wording for an empty diff — a distinct sentence, not "(no output)". */
|
|
66
|
+
export const NO_CHANGES_MESSAGE = "No changes to show.";
|
|
67
|
+
|
|
68
|
+
export function describeDiffScope(plan: DiffPlan): string {
|
|
69
|
+
return plan.staged ? "staged changes" : "working-tree changes since the last commit";
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface DiffDeps {
|
|
73
|
+
shell: Shell;
|
|
74
|
+
log: Pick<Logger, "warn">;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** `/diff [--staged] [pathspec…]`, from the command's raw tokens: the diff as lines,
|
|
78
|
+
* each ignored token logged and counted in the closing message. */
|
|
79
|
+
export async function runDiff(tokens: readonly string[], deps: DiffDeps): Promise<CommandView> {
|
|
80
|
+
const plan = planDiff(tokens);
|
|
81
|
+
for (const r of plan.rejected) deps.log.warn(`/diff ignored '${r.value}' — ${r.reason}`);
|
|
82
|
+
|
|
83
|
+
const r = await deps.shell.run(`git diff ${plan.args}`.trim());
|
|
84
|
+
if (r.exitCode !== 0) {
|
|
85
|
+
const err = r.stderr.trim();
|
|
86
|
+
return { text: `git diff failed: ${err || `exit code ${r.exitCode}`}` };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const out = r.stdout;
|
|
90
|
+
if (out.trim().length === 0) {
|
|
91
|
+
return { text: `${NO_CHANGES_MESSAGE} (${describeDiffScope(plan)})` };
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
lines: [`── ${describeDiffScope(plan)}`, out],
|
|
95
|
+
...(plan.rejected.length > 0 ? { text: `${plan.rejected.length} argument(s) ignored — see the log.` } : {}),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// /review [<path>…] [--files <path>…] [--commit <sha>] [--lens <lens>] [--passes <1-5>] — read the line of the review
|
|
2
|
+
// and of its two aliases. /security-review is the review narrowed to the security lens, whatever --lens says: one
|
|
3
|
+
// facet of the one crew, passed as a crew input so it outranks review.lenses, and inside the crew a security pass
|
|
4
|
+
// inherits the scope validation (a review asked to look at two paths looks at those two). /passes [n] shows or sets
|
|
5
|
+
// the session's pass count, answered here without a review; --passes sets this run's count only, the crew input
|
|
6
|
+
// outranking the session key. Lives under commands/_lib/ — the loader's SearchPattern is "*.cmd.ts".
|
|
7
|
+
|
|
8
|
+
import type { SessionStore } from "../../../shared/application/ports.ts";
|
|
9
|
+
import { MAX_PASSES, MIN_PASSES } from "../../../shared/domain/agent-policy/behavior-flags.ts";
|
|
10
|
+
import { PASSES_STATE_KEY } from "../../../shared/domain/session-keys.ts";
|
|
11
|
+
import { commandLine, splitWords } from "../args.ts";
|
|
12
|
+
import type { CommandView } from "../view.ts";
|
|
13
|
+
|
|
14
|
+
export const REVIEW_LENSES: readonly string[] = ["correctness", "security", "style"];
|
|
15
|
+
|
|
16
|
+
/** The crew a review runs in, launched exclusively: the host refuses a review while one runs (any alias:
|
|
17
|
+
* /security-review is the same crew), so two never run side by side; /passes launches nothing and always answers. */
|
|
18
|
+
export const REVIEW_CREW = "code-review";
|
|
19
|
+
|
|
20
|
+
/** What the code-review crew is launched with. */
|
|
21
|
+
export interface ReviewInput {
|
|
22
|
+
files: string[];
|
|
23
|
+
commit: string;
|
|
24
|
+
lenses: string;
|
|
25
|
+
passes?: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type ReviewRoute =
|
|
29
|
+
| { route: "review"; input: ReviewInput }
|
|
30
|
+
| { route: "passes"; token: string }
|
|
31
|
+
| { route: "refused"; text: string };
|
|
32
|
+
|
|
33
|
+
/** The refusal of a pass count that is not an integer from 1 to 5. */
|
|
34
|
+
export function invalidPassesText(token: string): string {
|
|
35
|
+
return `invalid pass count '${token}' — expected an integer between ${MIN_PASSES} and ${MAX_PASSES}.`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** A pass count from 1 to 5, or null. */
|
|
39
|
+
function passCount(token: string): number | null {
|
|
40
|
+
const n = Number(token);
|
|
41
|
+
return token !== "" && Number.isInteger(n) && n >= MIN_PASSES && n <= MAX_PASSES ? n : null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** `--name=value` split, or the bare option with no value. */
|
|
45
|
+
function option(token: string): { name: string; value: string | null } {
|
|
46
|
+
const at = token.indexOf("=");
|
|
47
|
+
return at < 0 ? { name: token, value: null } : { name: token.slice(0, at), value: token.slice(at + 1) };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** The line of /review, or of the alias it was typed by (`security-review`, `passes`). The REPL keeps the quotes in
|
|
51
|
+
* the raw tokens: the line is split again, so `--commit "abc123"` reads `abc123` and a quoted path stays one file. */
|
|
52
|
+
export function parseReviewArgs(raw: readonly string[], typed: string): ReviewRoute {
|
|
53
|
+
const tokens = splitWords(commandLine(raw)).map((w) => w.text);
|
|
54
|
+
if (typed === "passes") return { route: "passes", token: (tokens[0] ?? "").trim() };
|
|
55
|
+
const files: string[] = [];
|
|
56
|
+
let commit = "";
|
|
57
|
+
let lens = "";
|
|
58
|
+
let passes: number | undefined;
|
|
59
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
60
|
+
const token = tokens[i];
|
|
61
|
+
if (!token.startsWith("--")) {
|
|
62
|
+
files.push(token);
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
const { name, value: inline } = option(token);
|
|
66
|
+
if (name === "--files") {
|
|
67
|
+
if (inline !== null && inline !== "") files.push(inline);
|
|
68
|
+
while (i + 1 < tokens.length && !tokens[i + 1].startsWith("--")) files.push(tokens[++i]);
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (name !== "--commit" && name !== "--lens" && name !== "--passes") {
|
|
72
|
+
return { route: "refused", text: `review: unknown option '${token}' (--files, --commit, --lens, --passes)` };
|
|
73
|
+
}
|
|
74
|
+
const value = inline ?? (i + 1 < tokens.length && !tokens[i + 1].startsWith("--") ? tokens[++i] : "");
|
|
75
|
+
if (value === "") return { route: "refused", text: `review: ${name} takes a value` };
|
|
76
|
+
if (name === "--commit") commit = value;
|
|
77
|
+
else if (name === "--lens") lens = value;
|
|
78
|
+
else {
|
|
79
|
+
const n = passCount(value);
|
|
80
|
+
if (n === null) return { route: "refused", text: invalidPassesText(value) };
|
|
81
|
+
passes = n;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (typed === "security-review") lens = "security";
|
|
85
|
+
else if (lens !== "" && !REVIEW_LENSES.includes(lens)) {
|
|
86
|
+
return { route: "refused", text: `review: --lens takes ${REVIEW_LENSES.join(", ")}, not '${lens}'` };
|
|
87
|
+
}
|
|
88
|
+
return { route: "review", input: { files, commit, lenses: lens, ...(passes === undefined ? {} : { passes }) } };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface PassesDeps {
|
|
92
|
+
session: Pick<SessionStore, "readState" | "writeState">;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** `/passes [n]`: the session's pass count shown, or set from 1 to 5 (session-scoped; /clear clears it). */
|
|
96
|
+
export async function runPasses(token: string, deps: PassesDeps): Promise<CommandView> {
|
|
97
|
+
if (token === "") {
|
|
98
|
+
const current = (await deps.session.readState(PASSES_STATE_KEY).catch(() => null)) ?? `${MIN_PASSES} (default)`;
|
|
99
|
+
return {
|
|
100
|
+
text: `reasoning passes: ${current}\n/review runs that many lens rounds.\n` +
|
|
101
|
+
`usage: /passes <${MIN_PASSES}-${MAX_PASSES}> (this session) or /review --passes <${MIN_PASSES}-${MAX_PASSES}> (one run)`,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
const n = passCount(token);
|
|
105
|
+
if (n === null) return { text: invalidPassesText(token) };
|
|
106
|
+
await deps.session.writeState(PASSES_STATE_KEY, String(n));
|
|
107
|
+
// n rounds × 3 lenses is n × 3 LLM calls: say so, the cost is the operator's.
|
|
108
|
+
return { text: `reasoning passes set to ${n} — /review will make ${n * 3} lens calls per run (session-scoped; /clear clears it).` };
|
|
109
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
// /memory admit [<id>…] | --refuse <id> [<motif>] | --list | --import (alias /memory-admit) — the operator's gate of the shared
|
|
2
|
+
// memory (temp/05 § 3). Listing, refusing and importing the harness's agent memory into candidates (M-9)
|
|
3
|
+
// are a few reads and writes, answered here; an admission is
|
|
4
|
+
// confirmed here, one candidate at a time, then applied by the crew shared-memory-admit, which also
|
|
5
|
+
// re-indexes entries/. A session that cannot prompt admits nothing (as /commit refuses headless):
|
|
6
|
+
// only an audited candidate admits without a question, when memory.autoAdmitAudited is true.
|
|
7
|
+
|
|
8
|
+
import type { Files, Shell } from "../../../shared/application/ports.ts";
|
|
9
|
+
import type { ConfigStore } from "../../../shared/application/config-store.ts";
|
|
10
|
+
import { readMemorySettings } from "../../../shared/application/shared-memory/memory-settings.ts";
|
|
11
|
+
import type { MemorySettings } from "../../../shared/application/shared-memory/memory-settings.ts";
|
|
12
|
+
import { pendingCandidates } from "../../../shared/application/shared-memory/memory-files.ts";
|
|
13
|
+
import type { StoredEntry } from "../../../shared/application/shared-memory/memory-files.ts";
|
|
14
|
+
import type { Confirmed } from "../../../shared/application/shared-memory/admit-entries.ts";
|
|
15
|
+
import { sha1Hex } from "../../../shared/domain/sha1.ts";
|
|
16
|
+
import { admitEntries, admitReport } from "../../../shared/application/shared-memory/admit-entries.ts";
|
|
17
|
+
import { admissionProblem, asksConfirmation } from "../../../shared/domain/shared-memory/gate.ts";
|
|
18
|
+
import { candidatesList } from "../../../shared/domain/shared-memory/candidates.ts";
|
|
19
|
+
import { importAgentMemory, importReport } from "../../../shared/application/shared-memory/import-agent-memory.ts";
|
|
20
|
+
|
|
21
|
+
/** The crew that writes an admission, launched exclusively: the host refuses an admission while the previous one is
|
|
22
|
+
* still being written, so two never write the shared memory side by side; the list, a refusal and the import launch
|
|
23
|
+
* no crew and always answer. */
|
|
24
|
+
export const MEMORY_ADMIT_CREW = "shared-memory-admit";
|
|
25
|
+
const ID = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
26
|
+
const MAX_MOTIF_CHARS = 200;
|
|
27
|
+
const SHOWN_BODY_LINES = 6;
|
|
28
|
+
|
|
29
|
+
export type MemoryAdmitArgs =
|
|
30
|
+
| { kind: "list" }
|
|
31
|
+
| { kind: "import" }
|
|
32
|
+
| { kind: "refuse"; id: string; motif?: string }
|
|
33
|
+
| { kind: "admit"; ids: string[] };
|
|
34
|
+
|
|
35
|
+
export function parseMemoryAdmitArgs(tokens: readonly string[]): { ok: true; args: MemoryAdmitArgs } | { ok: false; text: string } {
|
|
36
|
+
if (tokens[0] === "--list") {
|
|
37
|
+
return tokens.length === 1 ? { ok: true, args: { kind: "list" } } : { ok: false, text: "memory-admit: --list takes nothing else" };
|
|
38
|
+
}
|
|
39
|
+
if (tokens[0] === "--import") {
|
|
40
|
+
return tokens.length === 1 ? { ok: true, args: { kind: "import" } } : { ok: false, text: "memory-admit: --import takes nothing else" };
|
|
41
|
+
}
|
|
42
|
+
if (tokens[0] === "--refuse") {
|
|
43
|
+
const id = tokens[1];
|
|
44
|
+
if (id === undefined || !ID.test(id)) return { ok: false, text: "memory-admit: --refuse <id> [<motif>]: the id of a pending candidate" };
|
|
45
|
+
const motif = tokens.slice(2).join(" ").replace(/\s+/g, " ").trim();
|
|
46
|
+
if (Array.from(motif).length > MAX_MOTIF_CHARS) return { ok: false, text: `memory-admit: a motif of at most ${MAX_MOTIF_CHARS} characters` };
|
|
47
|
+
return { ok: true, args: motif === "" ? { kind: "refuse", id } : { kind: "refuse", id, motif } };
|
|
48
|
+
}
|
|
49
|
+
for (const tok of tokens) {
|
|
50
|
+
if (tok.startsWith("--")) return { ok: false, text: `memory-admit: unknown option '${tok}' (--list, --refuse, --import)` };
|
|
51
|
+
if (!ID.test(tok)) return { ok: false, text: `memory-admit: '${tok}' is not a candidate id` };
|
|
52
|
+
}
|
|
53
|
+
return { ok: true, args: { kind: "admit", ids: [...new Set(tokens)] } };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface MemoryAdmitDeps {
|
|
57
|
+
files: Pick<Files, "read" | "write" | "list">;
|
|
58
|
+
config: Pick<ConfigStore, "readValue">;
|
|
59
|
+
shell: Pick<Shell, "run">;
|
|
60
|
+
clock: () => Date;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** What the session offers the command: a line out, and the confirm prompt (throws when it cannot ask). */
|
|
64
|
+
export interface MemoryAdmitIo {
|
|
65
|
+
writeLine(text: string): void;
|
|
66
|
+
confirm(question: string): Promise<unknown>;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export type MemoryAdmitResult =
|
|
70
|
+
| { message: string }
|
|
71
|
+
| { refused: string }
|
|
72
|
+
| { admit: Confirmed[]; settings: MemorySettings; refusedQuestions?: string };
|
|
73
|
+
|
|
74
|
+
/** What the operator reads before deciding: the candidate's fields and the first lines of its body. */
|
|
75
|
+
function candidateNotice(c: StoredEntry): string {
|
|
76
|
+
const e = c.entry;
|
|
77
|
+
const lines = [`${e.id} (${e.type}, topic ${e.topic})`, ` title: ${e.title}`, ` applies when: ${e.appliesWhen}`,
|
|
78
|
+
` rationale: ${e.rationale}`];
|
|
79
|
+
if (e.correction !== undefined) lines.push(` correction: ${e.correction}`);
|
|
80
|
+
if (e.detectionSignal !== undefined) lines.push(` signal: ${e.detectionSignal}`);
|
|
81
|
+
if (e.supersedes.length > 0) lines.push(` supersedes: ${e.supersedes.join(", ")}`);
|
|
82
|
+
lines.push(` source: ${e.source}`, ` file: ${c.path}`);
|
|
83
|
+
const body = e.body.split("\n").filter((l) => l.trim() !== "").slice(0, SHOWN_BODY_LINES);
|
|
84
|
+
return [...lines, ...body.map((l) => ` | ${l}`)].join("\n");
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const HEADLESS = "refused: /memory-admit asks before admitting and this session cannot prompt: no asked candidate was admitted. " +
|
|
88
|
+
"Run it in an interactive session (an audited candidate admits unasked when memory.autoAdmitAudited is true).";
|
|
89
|
+
|
|
90
|
+
/** No answer: the questions left are refused, the admissions already made - unasked or confirmed - still go. */
|
|
91
|
+
function headless(admit: Confirmed[], settings: MemorySettings, why: string): MemoryAdmitResult {
|
|
92
|
+
return admit.length === 0 ? { refused: why } : { admit, settings, refusedQuestions: why };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** A question cancelled after another was answered: the session can prompt, the person stopped. */
|
|
96
|
+
const stoppedAt = (id: string): string =>
|
|
97
|
+
`refused: the question about ${id} got no answer: it and the candidates after it stay candidates. Run /memory-admit again for them.`;
|
|
98
|
+
|
|
99
|
+
export async function runMemoryAdmit(args: MemoryAdmitArgs, deps: MemoryAdmitDeps, io: MemoryAdmitIo): Promise<MemoryAdmitResult> {
|
|
100
|
+
const settings = await readMemorySettings(deps);
|
|
101
|
+
for (const warning of settings.warnings) io.writeLine(`warning: ${warning}`);
|
|
102
|
+
if (args.kind === "import") {
|
|
103
|
+
const outcome = await importAgentMemory(deps, settings);
|
|
104
|
+
return { message: importReport(outcome) };
|
|
105
|
+
}
|
|
106
|
+
const pending = await pendingCandidates(deps.files, settings.layout);
|
|
107
|
+
if (args.kind === "list") {
|
|
108
|
+
return { message: pending.length === 0 ? `No pending candidate in ${settings.layout.candidates}.` : candidatesList(pending.map((c) => c.entry)).trimEnd() };
|
|
109
|
+
}
|
|
110
|
+
if (args.kind === "refuse") {
|
|
111
|
+
const outcome = await admitEntries({ ...deps, memory: { ingest: async () => { throw new Error("no ingestion on a refusal"); } } },
|
|
112
|
+
settings, { admit: [], refuse: [{ id: args.id, ...(args.motif === undefined ? {} : { motif: args.motif }) }] });
|
|
113
|
+
return outcome.refused.length > 0 ? { message: admitReport(outcome) } : { refused: admitReport(outcome) };
|
|
114
|
+
}
|
|
115
|
+
const chosen: StoredEntry[] = [];
|
|
116
|
+
for (const id of args.ids) {
|
|
117
|
+
const hit = pending.find((c) => c.entry.id === id);
|
|
118
|
+
if (hit === undefined) io.writeLine(`${id}: not a pending candidate (/memory-admit --list)`);
|
|
119
|
+
else chosen.push(hit);
|
|
120
|
+
}
|
|
121
|
+
const asked = args.ids.length === 0 ? pending : chosen;
|
|
122
|
+
if (asked.length === 0) return { message: args.ids.length === 0 ? `No pending candidate in ${settings.layout.candidates}.` : "Nothing admitted." };
|
|
123
|
+
const admit: Confirmed[] = [];
|
|
124
|
+
const confirmed = (c: StoredEntry): Confirmed => ({ id: c.entry.id, sha1: sha1Hex(c.text) });
|
|
125
|
+
// The admissions that need no question first: a session that cannot prompt still applies them.
|
|
126
|
+
const unasked = asked.filter((c) => admissionProblem(c.entry) === undefined && !asksConfirmation(c.entry, settings.autoAdmitAudited));
|
|
127
|
+
for (const c of unasked) {
|
|
128
|
+
io.writeLine(candidateNotice(c));
|
|
129
|
+
io.writeLine(" admitted without a question (audited, memory.autoAdmitAudited is true)");
|
|
130
|
+
admit.push(confirmed(c));
|
|
131
|
+
}
|
|
132
|
+
let answered = false;
|
|
133
|
+
for (const c of asked.filter((x) => !unasked.includes(x))) {
|
|
134
|
+
io.writeLine(candidateNotice(c));
|
|
135
|
+
const problem = admissionProblem(c.entry);
|
|
136
|
+
if (problem !== undefined) { io.writeLine(` not admissible: ${problem}`); continue; }
|
|
137
|
+
let answer: unknown;
|
|
138
|
+
try {
|
|
139
|
+
answer = await io.confirm(`Admit ${c.entry.id} into the shared memory?`);
|
|
140
|
+
} catch {
|
|
141
|
+
answer = undefined;
|
|
142
|
+
}
|
|
143
|
+
// Every admission confirmed so far is kept: only the first question tells a session that cannot prompt.
|
|
144
|
+
if (typeof answer !== "boolean") return headless(admit, settings, answered ? stoppedAt(c.entry.id) : HEADLESS);
|
|
145
|
+
answered = true;
|
|
146
|
+
if (answer) admit.push(confirmed(c));
|
|
147
|
+
else io.writeLine(" left as a candidate");
|
|
148
|
+
}
|
|
149
|
+
return admit.length === 0 ? { message: "Nothing admitted." } : { admit, settings };
|
|
150
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// /memory <list|add|delete|get|admit> ... — typed memory CRUD (SPEC §5.2), and the shared memory's gate.
|
|
2
|
+
// /memory list [category] /memory add <category> <content...>
|
|
3
|
+
// /memory delete <id> /memory get <id>
|
|
4
|
+
// /memory admit [<id>…] | --refuse <id> [motif] | --list | --import (memory-admit.ts)
|
|
5
|
+
// Two aliases keep their own shape: /feedback <text> adds a 'feedback' memory, the agent replays it on every
|
|
6
|
+
// /assistant turn; /memory-admit's tokens are the admit arguments.
|
|
7
|
+
|
|
8
|
+
import type { MemoryStore } from "../../../shared/application/ports.ts";
|
|
9
|
+
import { parseMemoryArgs } from "../args.ts";
|
|
10
|
+
import type { CommandView } from "../view.ts";
|
|
11
|
+
|
|
12
|
+
export interface MemoryDeps {
|
|
13
|
+
memory: MemoryStore;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** The admit arguments of a line typed `/memory admit …` or `/memory-admit …`; null when the line is not an admission. */
|
|
17
|
+
export function admitTokens(tokens: readonly string[], typed: string): string[] | null {
|
|
18
|
+
if (typed === "memory-admit") return [...tokens];
|
|
19
|
+
if (typed === "memory" && (tokens[0] ?? "").toLowerCase() === "admit") return tokens.slice(1);
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** `/feedback <text>`: a 'feedback' memory, the reply saying the agent replays it. */
|
|
24
|
+
async function runFeedback(tokens: string[], deps: MemoryDeps): Promise<CommandView> {
|
|
25
|
+
if (tokens.join(" ").trim() === "") return { text: "usage: /feedback <what should change or keep happening>" };
|
|
26
|
+
await runMemory(["add", "feedback", ...tokens], deps);
|
|
27
|
+
return { text: "feedback recorded — the agent replays feedback memories on every /assistant turn." };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** `/memory [list|add|delete|get] …`, from the command's raw tokens; typed by its alias `feedback`, an add of a feedback. */
|
|
31
|
+
export async function runMemory(tokens: string[], deps: MemoryDeps, typed = "memory"): Promise<CommandView> {
|
|
32
|
+
if (typed === "feedback") return runFeedback(tokens, deps);
|
|
33
|
+
const { memory } = deps;
|
|
34
|
+
const parsed = parseMemoryArgs(tokens);
|
|
35
|
+
|
|
36
|
+
if (parsed.sub === "add") {
|
|
37
|
+
if (!parsed.content) return { text: "usage: /memory add <category> <content>" };
|
|
38
|
+
return { text: "added memory #" + (await memory.add(parsed.category, parsed.content)) };
|
|
39
|
+
}
|
|
40
|
+
if (parsed.sub === "delete") {
|
|
41
|
+
return { text: (await memory.remove(parsed.id)) ? "deleted #" + parsed.id : "not found: #" + parsed.id };
|
|
42
|
+
}
|
|
43
|
+
if (parsed.sub === "get") {
|
|
44
|
+
return { text: JSON.stringify((await memory.get(parsed.id)) ?? "not found") };
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// list
|
|
48
|
+
const entries = await memory.list(parsed.category);
|
|
49
|
+
if (entries.length === 0) return { text: "(no memories)" };
|
|
50
|
+
return { table: entries.map((e) => ({ id: e.id, category: e.category, content: e.content })) };
|
|
51
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// What a close needs to open the pull request itself: the github tool, the session's mode and rules. Read at
|
|
2
|
+
// a dev command's dispatch, and again by its `completed` before each hop that writes (Orkeon #220: the host awaits
|
|
3
|
+
// an async `completed`); the crew keeps the dispatch's reading (the batch record, the /dev-batches run record) for
|
|
4
|
+
// a typed close and for the hop whose read failed. Not a command file: the loader reads *.cmd.ts only. The entry point hands the ports, each made when read: a host
|
|
5
|
+
// without the service fails there, and that read says nothing.
|
|
6
|
+
import type { SessionIo } from "../../shared/application/session-io.ts";
|
|
7
|
+
import { GITHUB_TOOL } from "../../shared/domain/git/pull-request.ts";
|
|
8
|
+
|
|
9
|
+
export interface PullRequestContext { githubTool: boolean; permissionRules: string[]; permissionMode: string }
|
|
10
|
+
|
|
11
|
+
export interface PullRequestContextPorts {
|
|
12
|
+
catalogue: () => { find(name: string): unknown };
|
|
13
|
+
rules: () => { available(): boolean; list(): string[] };
|
|
14
|
+
session: Pick<SessionIo, "resolveEffectiveSessionMode">;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export async function readPullRequestContext(ports: PullRequestContextPorts): Promise<PullRequestContext> {
|
|
18
|
+
let githubTool = false;
|
|
19
|
+
let permissionRules: string[] = [];
|
|
20
|
+
let permissionMode = "";
|
|
21
|
+
try {
|
|
22
|
+
githubTool = ports.catalogue().find(GITHUB_TOOL) !== undefined;
|
|
23
|
+
} catch { /* no tools service: the command is handed over */ }
|
|
24
|
+
try {
|
|
25
|
+
const rules = ports.rules();
|
|
26
|
+
if (rules.available()) permissionRules = rules.list();
|
|
27
|
+
} catch { /* no rules service: none */ }
|
|
28
|
+
try {
|
|
29
|
+
permissionMode = (await ports.session.resolveEffectiveSessionMode()).mode;
|
|
30
|
+
} catch { /* unknown mode, "": the opener refuses and hands the command over, and writeModeRefusal (dev-step.ts) refuses the step */ }
|
|
31
|
+
return { githubTool, permissionRules, permissionMode };
|
|
32
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// /analyze's use case: the crew input built from the command's flags and the session's `answer.language`, so the
|
|
2
|
+
// synthesis is written in the language the session answers in (crews/analyze).
|
|
3
|
+
import type { ConfigStore } from "../../../shared/application/config-store.ts";
|
|
4
|
+
import { readLanguage } from "../../../shared/application/answer-language.ts";
|
|
5
|
+
|
|
6
|
+
/** The flags of /analyze as the runtime parses them. */
|
|
7
|
+
export interface AnalyzeArgs {
|
|
8
|
+
raw?: unknown;
|
|
9
|
+
parallel?: unknown;
|
|
10
|
+
rebuild?: unknown;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** The input of the analyze crew: the flags, plus `language` when the session sets `answer.language`. */
|
|
14
|
+
export async function analyzeInput(
|
|
15
|
+
args: AnalyzeArgs, config: Pick<ConfigStore, "readValue">,
|
|
16
|
+
): Promise<{ raw: boolean; parallel: unknown; rebuild: boolean; language?: string }> {
|
|
17
|
+
const language = await readLanguage(config);
|
|
18
|
+
return {
|
|
19
|
+
raw: args.raw === true,
|
|
20
|
+
parallel: args.parallel,
|
|
21
|
+
rebuild: args.rebuild === true,
|
|
22
|
+
...(language !== "" ? { language } : {}),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// /export — conversation, memory and cost as one markdown document, as the
|
|
2
|
+
// baseline specifies (B-11 deepening); runExport reads them over the ports and
|
|
3
|
+
// writes the file. Lives under commands/_lib/ — the loader's SearchPattern is
|
|
4
|
+
// "*.cmd.ts", so this file is never loaded as a command.
|
|
5
|
+
|
|
6
|
+
import type {
|
|
7
|
+
Files, MemoryStore, SessionCost, SessionMessages, SessionStore, Telemetry,
|
|
8
|
+
} from "../../../shared/application/ports.ts";
|
|
9
|
+
import { MEMORY_CATEGORIES } from "../../../shared/domain/agent-policy/memory-categories.ts";
|
|
10
|
+
import type { CommandView } from "../view.ts";
|
|
11
|
+
|
|
12
|
+
export interface ExportInputs {
|
|
13
|
+
messages: ReadonlyArray<{ role?: unknown; content?: unknown }>;
|
|
14
|
+
memory: Readonly<Record<string, readonly string[]>>;
|
|
15
|
+
cost: { totalTokens?: unknown; costUsd?: unknown; calls?: unknown };
|
|
16
|
+
/** Passed in rather than read here: this module is pure. */
|
|
17
|
+
generatedAt?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The exported markdown.
|
|
22
|
+
*
|
|
23
|
+
* Baseline 04 §/export: "conversation history, typed memory entries, and cost/token
|
|
24
|
+
* usage". The pre-B-11 handler wrote the conversation alone, which is the part that
|
|
25
|
+
* is already recoverable from the session; the memory and the cost are the two an
|
|
26
|
+
* export exists to preserve. Sections are omitted when empty rather than rendered
|
|
27
|
+
* as headings over nothing — an export with "## Memory" and no entries reads as
|
|
28
|
+
* data loss.
|
|
29
|
+
*/
|
|
30
|
+
export function renderSessionExport(i: ExportInputs): string {
|
|
31
|
+
const out: string[] = ["# Session Export", ""];
|
|
32
|
+
if (i.generatedAt) out.push(`_generated ${i.generatedAt}_`, "");
|
|
33
|
+
|
|
34
|
+
const cost = Number(i.cost?.costUsd ?? 0) || 0;
|
|
35
|
+
out.push(
|
|
36
|
+
"## Usage",
|
|
37
|
+
"",
|
|
38
|
+
`- Messages: ${i.messages.length}`,
|
|
39
|
+
`- LLM calls: ${Number(i.cost?.calls ?? 0) || 0}`,
|
|
40
|
+
`- Tokens: ${Number(i.cost?.totalTokens ?? 0) || 0}`,
|
|
41
|
+
`- Cost: $${cost.toFixed(4)}`,
|
|
42
|
+
"",
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
const categories = Object.entries(i.memory ?? {}).filter(([, v]) => (v?.length ?? 0) > 0);
|
|
46
|
+
if (categories.length > 0) {
|
|
47
|
+
out.push("## Memory", "");
|
|
48
|
+
for (const [category, entries] of categories) {
|
|
49
|
+
out.push(`### ${category}`, "");
|
|
50
|
+
for (const e of entries) out.push(`- ${e}`);
|
|
51
|
+
out.push("");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
out.push("## Conversation", "");
|
|
56
|
+
if (i.messages.length === 0) {
|
|
57
|
+
out.push("_(the session buffer is empty)_", "");
|
|
58
|
+
} else {
|
|
59
|
+
for (const m of i.messages) {
|
|
60
|
+
out.push(`**${String(m.role ?? "?")}:** ${String(m.content ?? "")}`, "");
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return out.join("\n");
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export const DEFAULT_EXPORT_PATH = "/output/session-export.md";
|
|
67
|
+
|
|
68
|
+
export interface ExportDeps {
|
|
69
|
+
session: Pick<SessionStore, "readMessages">;
|
|
70
|
+
telemetry: Pick<Telemetry, "readCost">;
|
|
71
|
+
memory: Pick<MemoryStore, "list">;
|
|
72
|
+
files: Pick<Files, "write">;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** `/export [path]`, from the command's raw tokens: the session written as markdown. */
|
|
76
|
+
export async function runExport(tokens: readonly string[], deps: ExportDeps): Promise<CommandView> {
|
|
77
|
+
const path = tokens[0] ?? DEFAULT_EXPORT_PATH;
|
|
78
|
+
|
|
79
|
+
const [buffer, cost] = await Promise.all([
|
|
80
|
+
deps.session.readMessages().catch((): SessionMessages => ({ stored: [], messages: [] })),
|
|
81
|
+
deps.telemetry.readCost().catch((): SessionCost => ({})),
|
|
82
|
+
]);
|
|
83
|
+
|
|
84
|
+
// Per-category, and per-category tolerant: one unavailable category must not
|
|
85
|
+
// cost the export its other three.
|
|
86
|
+
const memory: Record<string, string[]> = {};
|
|
87
|
+
for (const category of MEMORY_CATEGORIES) {
|
|
88
|
+
try {
|
|
89
|
+
const contents = (await deps.memory.list(category)).map((e) => e.content).filter((c) => c.length > 0);
|
|
90
|
+
if (contents.length > 0) memory[category] = contents;
|
|
91
|
+
} catch { /* category unavailable → omitted, not empty-headed */ }
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const messages = buffer.stored as Array<{ role?: unknown; content?: unknown }>;
|
|
95
|
+
const md = renderSessionExport({
|
|
96
|
+
messages,
|
|
97
|
+
memory,
|
|
98
|
+
cost: { totalTokens: cost.totalTokens, costUsd: cost.costUsd, calls: cost.totalCalls },
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
await deps.files.write(path, md);
|
|
102
|
+
const memoryCount = Object.values(memory).reduce((n, v) => n + v.length, 0);
|
|
103
|
+
return { text: `exported → ${path} (${messages.length} message(s), ${memoryCount} memory entr(y/ies), cost included)` };
|
|
104
|
+
}
|