orkeon-code 0.0.0-stage → 1.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.orkeon-runtime +10 -0
- package/.orkeon-version +1 -0
- package/LICENSE.md +21 -0
- package/NOTICE.md +17 -0
- package/README.fr.md +163 -0
- package/README.md +156 -2
- package/config/appsettings.anthropic.example.json +77 -0
- package/config/appsettings.example.json +71 -0
- package/config/appsettings.jev.example.json +131 -0
- package/config/appsettings.kev.example.json +133 -0
- package/config/appsettings.liquid.example.json +132 -0
- package/config/appsettings.ollama-whisper.example.json +93 -0
- package/config/appsettings.ollama.example.json +70 -0
- package/config/appsettings.whisper.example.json +32 -0
- package/mcp/whisper/README.md +294 -0
- package/mcp/whisper/pyproject.toml +32 -0
- package/mcp/whisper/uv.lock +1641 -0
- package/mcp/whisper/whisper_mcp.py +1053 -0
- package/orkeon-code +1092 -0
- package/orkeon-code.mjs +71 -0
- package/orkeon-code.ps1 +939 -0
- package/package.json +58 -4
- package/scripts/install.ps1 +156 -0
- package/scripts/install.sh +148 -0
- package/scripts/session-start.ork.ts +90 -0
- package/scripts/session-start.sh +74 -0
- package/scripts/setup-fixture.sh +88 -0
- package/src/commands/.orkeon/orkeon-cli.d.ts +559 -0
- package/src/commands/_lib/args.ts +194 -0
- package/src/commands/_lib/dev/dev-batches.ts +366 -0
- package/src/commands/_lib/dev/dev-implement.ts +185 -0
- package/src/commands/_lib/dev/dev-source.ts +61 -0
- package/src/commands/_lib/dev/dev.ts +341 -0
- package/src/commands/_lib/dev/markers.ts +7 -0
- package/src/commands/_lib/dev/messages.ts +112 -0
- package/src/commands/_lib/dev-step.ts +145 -0
- package/src/commands/_lib/dispatch.ts +254 -0
- package/src/commands/_lib/effort.ts +15 -0
- package/src/commands/_lib/git/branch.ts +94 -0
- package/src/commands/_lib/git/commit.ts +90 -0
- package/src/commands/_lib/git/diff.ts +107 -0
- package/src/commands/_lib/git/messages.ts +54 -0
- package/src/commands/_lib/git/review.ts +108 -0
- package/src/commands/_lib/memory/memory-admit.ts +148 -0
- package/src/commands/_lib/memory/memory.ts +52 -0
- package/src/commands/_lib/memory/messages.ts +32 -0
- package/src/commands/_lib/messages.ts +48 -0
- package/src/commands/_lib/pr-context.ts +32 -0
- package/src/commands/_lib/project/analyze.ts +24 -0
- package/src/commands/_lib/project/messages.ts +8 -0
- package/src/commands/_lib/session/export.ts +105 -0
- package/src/commands/_lib/session/messages.ts +87 -0
- package/src/commands/_lib/session/prompts.ts +4 -0
- package/src/commands/_lib/session/resume.ts +151 -0
- package/src/commands/_lib/session/tasks.ts +181 -0
- package/src/commands/_lib/settings/advisor.ts +75 -0
- package/src/commands/_lib/settings/agents.ts +137 -0
- package/src/commands/_lib/settings/choices.ts +8 -0
- package/src/commands/_lib/settings/config.ts +141 -0
- package/src/commands/_lib/settings/effort.ts +147 -0
- package/src/commands/_lib/settings/hooks.ts +50 -0
- package/src/commands/_lib/settings/messages.ts +408 -0
- package/src/commands/_lib/settings/mode.ts +100 -0
- package/src/commands/_lib/settings/model.ts +181 -0
- package/src/commands/_lib/settings/output-style.ts +39 -0
- package/src/commands/_lib/settings/permissions.ts +287 -0
- package/src/commands/_lib/settings/route.ts +63 -0
- package/src/commands/_lib/settings/session-config.ts +49 -0
- package/src/commands/_lib/settings/skills.ts +93 -0
- package/src/commands/_lib/settings/theme.ts +42 -0
- package/src/commands/_lib/speech/messages.ts +58 -0
- package/src/commands/_lib/speech/prompts.ts +4 -0
- package/src/commands/_lib/speech/say.ts +95 -0
- package/src/commands/_lib/speech/transcribe.ts +121 -0
- package/src/commands/_lib/speech/voice.ts +142 -0
- package/src/commands/_lib/status/cache.ts +31 -0
- package/src/commands/_lib/status/context.ts +57 -0
- package/src/commands/_lib/status/doctor.ts +205 -0
- package/src/commands/_lib/status/messages.ts +100 -0
- package/src/commands/_lib/status/meta.ts +24 -0
- package/src/commands/_lib/status/status.ts +128 -0
- package/src/commands/_lib/status/usage-tools.ts +48 -0
- package/src/commands/_lib/status/usage.ts +128 -0
- package/src/commands/_lib/view.ts +34 -0
- package/src/commands/dev/dev-batches.cmd.ts +109 -0
- package/src/commands/dev/dev-learn.cmd.ts +29 -0
- package/src/commands/dev/dev-plan.cmd.ts +51 -0
- package/src/commands/dev/dev-spec.cmd.ts +54 -0
- package/src/commands/dev/dev-status.cmd.ts +16 -0
- package/src/commands/git/branch.cmd.ts +27 -0
- package/src/commands/git/commit.cmd.ts +48 -0
- package/src/commands/git/diff.cmd.ts +26 -0
- package/src/commands/git/review.cmd.ts +36 -0
- package/src/commands/memory/memory.cmd.ts +48 -0
- package/src/commands/project/analyze.cmd.ts +32 -0
- package/src/commands/project/debug-tool-call.cmd.ts +62 -0
- package/src/commands/project/files.cmd.ts +22 -0
- package/src/commands/project/init-verifiers.cmd.ts +14 -0
- package/src/commands/project/init.cmd.ts +14 -0
- package/src/commands/project/verify.cmd.ts +27 -0
- package/src/commands/session/assistant.cmd.ts +40 -0
- package/src/commands/session/btw.cmd.ts +18 -0
- package/src/commands/session/clear.cmd.ts +19 -0
- package/src/commands/session/compact.cmd.ts +16 -0
- package/src/commands/session/copy.cmd.ts +45 -0
- package/src/commands/session/exit.cmd.ts +9 -0
- package/src/commands/session/export.cmd.ts +28 -0
- package/src/commands/session/rename.cmd.ts +18 -0
- package/src/commands/session/resume.cmd.ts +19 -0
- package/src/commands/session/rewind.cmd.ts +25 -0
- package/src/commands/session/summary.cmd.ts +27 -0
- package/src/commands/session/tasks.cmd.ts +46 -0
- package/src/commands/settings/advisor.cmd.ts +38 -0
- package/src/commands/settings/agents.cmd.ts +19 -0
- package/src/commands/settings/config.cmd.ts +19 -0
- package/src/commands/settings/effort.cmd.ts +19 -0
- package/src/commands/settings/fast.cmd.ts +18 -0
- package/src/commands/settings/hooks.cmd.ts +17 -0
- package/src/commands/settings/mode.cmd.ts +20 -0
- package/src/commands/settings/model.cmd.ts +21 -0
- package/src/commands/settings/output-style.cmd.ts +19 -0
- package/src/commands/settings/permissions.cmd.ts +25 -0
- package/src/commands/settings/proactive.cmd.ts +16 -0
- package/src/commands/settings/route.cmd.ts +16 -0
- package/src/commands/settings/skills.cmd.ts +17 -0
- package/src/commands/settings/theme.cmd.ts +14 -0
- package/src/commands/speech/say.cmd.ts +24 -0
- package/src/commands/speech/transcribe.cmd.ts +29 -0
- package/src/commands/speech/voice.cmd.ts +30 -0
- package/src/commands/status/context.cmd.ts +18 -0
- package/src/commands/status/doctor.cmd.ts +27 -0
- package/src/commands/status/release-notes.cmd.ts +9 -0
- package/src/commands/status/status.cmd.ts +25 -0
- package/src/commands/status/usage.cmd.ts +21 -0
- package/src/crews/.orkeon/orkeon.d.ts +4391 -0
- package/src/crews/_probe-shared-memory/domain/messages.ts +54 -0
- package/src/crews/_probe-shared-memory/domain/probe-verdict.ts +188 -0
- package/src/crews/_probe-shared-memory/domain/prompts.ts +5 -0
- package/src/crews/_probe-shared-memory/probe.ork.ts +100 -0
- package/src/crews/advisor/application/messages.ts +4 -0
- package/src/crews/advisor/application/prompts.ts +4 -0
- package/src/crews/advisor/application/run-advisor.ts +41 -0
- package/src/crews/advisor/crew.ork.ts +44 -0
- package/src/crews/advisor/domain/advice.ts +119 -0
- package/src/crews/advisor/domain/messages.ts +8 -0
- package/src/crews/advisor/domain/prompts.ts +26 -0
- package/src/crews/agent-run/application/messages.ts +18 -0
- package/src/crews/agent-run/application/run-agent-run.ts +43 -0
- package/src/crews/agent-run/crew.ork.ts +67 -0
- package/src/crews/analyze/application/messages.ts +27 -0
- package/src/crews/analyze/application/prompts.ts +4 -0
- package/src/crews/analyze/application/run-analyze.ts +120 -0
- package/src/crews/analyze/crew.ork.ts +41 -0
- package/src/crews/analyze/domain/harvest.ts +269 -0
- package/src/crews/analyze/domain/prompts.ts +86 -0
- package/src/crews/code-review/application/lens-material.ts +24 -0
- package/src/crews/code-review/application/messages.ts +17 -0
- package/src/crews/code-review/application/prompts.ts +126 -0
- package/src/crews/code-review/application/review.ts +74 -0
- package/src/crews/code-review/application/run-code-review.ts +121 -0
- package/src/crews/code-review/crew.ork.ts +52 -0
- package/src/crews/code-review/domain/lenses.ts +154 -0
- package/src/crews/code-review/domain/messages.ts +25 -0
- package/src/crews/code-review/domain/prompts.ts +58 -0
- package/src/crews/code-review/domain/report.ts +58 -0
- package/src/crews/code-review/domain/scope.ts +106 -0
- package/src/crews/dev-batches/application/messages.ts +127 -0
- package/src/crews/dev-batches/application/plan-close.ts +181 -0
- package/src/crews/dev-batches/application/prompts.ts +10 -0
- package/src/crews/dev-batches/application/run-dev-batches.ts +676 -0
- package/src/crews/dev-batches/application/run-wave.ts +452 -0
- package/src/crews/dev-batches/application/seed-harvest.ts +163 -0
- package/src/crews/dev-batches/crew.ork.ts +146 -0
- package/src/crews/dev-batches/domain/batch-waves.ts +70 -0
- package/src/crews/dev-batches/domain/batches-budget.ts +52 -0
- package/src/crews/dev-batches/domain/batches-log.ts +52 -0
- package/src/crews/dev-batches/domain/markers.ts +5 -0
- package/src/crews/dev-batches/domain/messages.ts +6 -0
- package/src/crews/dev-batches/domain/wave-order.ts +44 -0
- package/src/crews/dev-change/application/change-material.ts +44 -0
- package/src/crews/dev-change/application/evidence.ts +172 -0
- package/src/crews/dev-change/application/messages.ts +81 -0
- package/src/crews/dev-change/application/prompts.ts +101 -0
- package/src/crews/dev-change/application/run-dev-change.ts +324 -0
- package/src/crews/dev-change/crew.ork.ts +114 -0
- package/src/crews/dev-change/domain/change-answer.ts +163 -0
- package/src/crews/dev-change/domain/change-render.ts +77 -0
- package/src/crews/dev-change/domain/markers.ts +28 -0
- package/src/crews/dev-change/domain/messages.ts +16 -0
- package/src/crews/dev-implement/application/close.ts +186 -0
- package/src/crews/dev-implement/application/count-open-steps.ts +24 -0
- package/src/crews/dev-implement/application/locate-sheet.ts +82 -0
- package/src/crews/dev-implement/application/messages.ts +161 -0
- package/src/crews/dev-implement/application/observe.ts +52 -0
- package/src/crews/dev-implement/application/prompts.ts +9 -0
- package/src/crews/dev-implement/application/report-writes.ts +46 -0
- package/src/crews/dev-implement/application/run-dev-implement.ts +822 -0
- package/src/crews/dev-implement/application/run-role.ts +27 -0
- package/src/crews/dev-implement/application/suite-job.ts +122 -0
- package/src/crews/dev-implement/application/touched.ts +74 -0
- package/src/crews/dev-implement/crew.ork.ts +69 -0
- package/src/crews/dev-implement/domain/contracts.ts +255 -0
- package/src/crews/dev-implement/domain/correction.ts +103 -0
- package/src/crews/dev-implement/domain/cycles.ts +36 -0
- package/src/crews/dev-implement/domain/implement-budget.ts +29 -0
- package/src/crews/dev-implement/domain/markers.ts +23 -0
- package/src/crews/dev-implement/domain/messages.ts +58 -0
- package/src/crews/dev-implement/domain/prompts.ts +93 -0
- package/src/crews/dev-implement/domain/roles.ts +49 -0
- package/src/crews/dev-implement/domain/sheet-edits.ts +76 -0
- package/src/crews/dev-implement/domain/sheet-ticks.ts +23 -0
- package/src/crews/dev-implement/domain/step-checks.ts +137 -0
- package/src/crews/dev-implement/domain/step-section.ts +129 -0
- package/src/crews/dev-learn/application/learn-backlog.ts +58 -0
- package/src/crews/dev-learn/application/learn-prompt-fit.ts +63 -0
- package/src/crews/dev-learn/application/messages.ts +51 -0
- package/src/crews/dev-learn/application/prompts.ts +99 -0
- package/src/crews/dev-learn/application/run-dev-learn.ts +558 -0
- package/src/crews/dev-learn/crew.ork.ts +53 -0
- package/src/crews/dev-learn/domain/learn-answer.ts +233 -0
- package/src/crews/dev-learn/domain/messages.ts +65 -0
- package/src/crews/dev-learn/domain/owner-lines.ts +89 -0
- package/src/crews/dev-learn/domain/proposals-render.ts +95 -0
- package/src/crews/dev-plan/application/anchor-paths.ts +113 -0
- package/src/crews/dev-plan/application/inventory.ts +174 -0
- package/src/crews/dev-plan/application/messages.ts +88 -0
- package/src/crews/dev-plan/application/plan-prompt-fit.ts +44 -0
- package/src/crews/dev-plan/application/prompts.ts +141 -0
- package/src/crews/dev-plan/application/run-dev-plan.ts +483 -0
- package/src/crews/dev-plan/crew.ork.ts +112 -0
- package/src/crews/dev-plan/domain/inventory-model.ts +95 -0
- package/src/crews/dev-plan/domain/markers.ts +18 -0
- package/src/crews/dev-plan/domain/messages.ts +118 -0
- package/src/crews/dev-plan/domain/plan-answer.ts +753 -0
- package/src/crews/dev-plan/domain/plan-render.ts +306 -0
- package/src/crews/dev-plan/domain/prompts.ts +44 -0
- package/src/crews/dev-spec/application/messages.ts +30 -0
- package/src/crews/dev-spec/application/prompts.ts +93 -0
- package/src/crews/dev-spec/application/run-dev-spec.ts +237 -0
- package/src/crews/dev-spec/application/spec-material.ts +42 -0
- package/src/crews/dev-spec/crew.ork.ts +110 -0
- package/src/crews/dev-spec/domain/markers.ts +30 -0
- package/src/crews/dev-spec/domain/messages.ts +39 -0
- package/src/crews/dev-spec/domain/spec-answer.ts +252 -0
- package/src/crews/dev-spec/domain/spec-render.ts +76 -0
- package/src/crews/dev-verify/application/audit-brief.ts +187 -0
- package/src/crews/dev-verify/application/audit.ts +267 -0
- package/src/crews/dev-verify/application/capture.ts +311 -0
- package/src/crews/dev-verify/application/messages.ts +119 -0
- package/src/crews/dev-verify/application/prompts.ts +209 -0
- package/src/crews/dev-verify/application/run-dev-verify.ts +423 -0
- package/src/crews/dev-verify/application/run-gate.ts +204 -0
- package/src/crews/dev-verify/crew.ork.ts +103 -0
- package/src/crews/dev-verify/domain/audit-answer.ts +154 -0
- package/src/crews/dev-verify/domain/auditor-charter.ts +21 -0
- package/src/crews/dev-verify/domain/capture-sections.ts +138 -0
- package/src/crews/dev-verify/domain/commands.ts +103 -0
- package/src/crews/dev-verify/domain/gate.ts +131 -0
- package/src/crews/dev-verify/domain/markers.ts +16 -0
- package/src/crews/dev-verify/domain/mechanical-table.ts +156 -0
- package/src/crews/dev-verify/domain/messages.ts +92 -0
- package/src/crews/dev-verify/domain/runtime-cut.ts +13 -0
- package/src/crews/dev-verify/domain/sheet-facts.ts +4 -0
- package/src/crews/dev-verify/domain/text.ts +20 -0
- package/src/crews/dev-verify/domain/verdict.ts +127 -0
- package/src/crews/git-commit/application/draft.ts +133 -0
- package/src/crews/git-commit/application/messages.ts +15 -0
- package/src/crews/git-commit/application/prompts.ts +47 -0
- package/src/crews/git-commit/application/run-git-commit.ts +117 -0
- package/src/crews/git-commit/crew.ork.ts +53 -0
- package/src/crews/git-commit/domain/commit.ts +200 -0
- package/src/crews/git-commit/domain/markers.ts +4 -0
- package/src/crews/git-commit/domain/messages.ts +48 -0
- package/src/crews/init-verifiers/application/authoring.ts +90 -0
- package/src/crews/init-verifiers/application/messages.ts +13 -0
- package/src/crews/init-verifiers/application/prompts.ts +107 -0
- package/src/crews/init-verifiers/application/run-init-verifiers.ts +26 -0
- package/src/crews/init-verifiers/crew.ork.ts +35 -0
- package/src/crews/init-verifiers/domain/commands-section.ts +36 -0
- package/src/crews/init-verifiers/domain/readiness.ts +23 -0
- package/src/crews/main-loop/application/auto-compact.ts +78 -0
- package/src/crews/main-loop/application/context-gather.ts +133 -0
- package/src/crews/main-loop/application/messages.ts +81 -0
- package/src/crews/main-loop/application/prompts.ts +12 -0
- package/src/crews/main-loop/application/run-main-loop.ts +383 -0
- package/src/crews/main-loop/application/turn-context.ts +111 -0
- package/src/crews/main-loop/crew.ork.ts +124 -0
- package/src/crews/main-loop/domain/autocompact.ts +27 -0
- package/src/crews/main-loop/domain/prompt-assembly.ts +338 -0
- package/src/crews/main-loop/domain/prompts.ts +336 -0
- package/src/crews/main-loop/domain/turn-chains.ts +130 -0
- package/src/crews/project-init/application/detect.ts +123 -0
- package/src/crews/project-init/application/messages.ts +15 -0
- package/src/crews/project-init/application/prompts.ts +105 -0
- package/src/crews/project-init/application/run-project-init.ts +31 -0
- package/src/crews/project-init/crew.ork.ts +36 -0
- package/src/crews/project-init/domain/conventions.ts +36 -0
- package/src/crews/project-init/domain/existing-files.ts +65 -0
- package/src/crews/project-init/domain/messages.ts +13 -0
- package/src/crews/project-init/domain/package-map.ts +73 -0
- package/src/crews/project-init/domain/prompts.ts +10 -0
- package/src/crews/session-compact/application/prompts.ts +5 -0
- package/src/crews/session-compact/crew.ork.ts +56 -0
- package/src/crews/shared-memory-admit/application/prompts.ts +5 -0
- package/src/crews/shared-memory-admit/crew.ork.ts +49 -0
- package/src/crews/speech/application/messages.ts +3 -0
- package/src/crews/speech/application/prompts.ts +3 -0
- package/src/crews/speech/application/run-speech.ts +26 -0
- package/src/crews/speech/crew.ork.ts +38 -0
- package/src/shared/application/agents/child-agent.ts +259 -0
- package/src/shared/application/agents/messages.ts +35 -0
- package/src/shared/application/agents/route-agent.ts +115 -0
- package/src/shared/application/agents/run-sub-agent.ts +119 -0
- package/src/shared/application/answer-language.ts +14 -0
- package/src/shared/application/attached-skills.ts +36 -0
- package/src/shared/application/compaction/compact-session.ts +242 -0
- package/src/shared/application/compaction/extract-memories.ts +38 -0
- package/src/shared/application/compaction/messages.ts +20 -0
- package/src/shared/application/compaction/prune-context.ts +94 -0
- package/src/shared/application/compaction/pruned-llm.ts +35 -0
- package/src/shared/application/compaction/restore-context.ts +78 -0
- package/src/shared/application/config-store.ts +123 -0
- package/src/shared/application/dev/brief-inventory.ts +115 -0
- package/src/shared/application/dev/close-batch.ts +85 -0
- package/src/shared/application/dev/find-repo-pack.ts +78 -0
- package/src/shared/application/dev/learn-decision.ts +254 -0
- package/src/shared/application/dev/load-dev-context.ts +265 -0
- package/src/shared/application/dev/measure-access-cost.ts +69 -0
- package/src/shared/application/dev/messages.ts +132 -0
- package/src/shared/application/dev/phase-timer.ts +54 -0
- package/src/shared/application/dev/plan-source.ts +116 -0
- package/src/shared/application/dev/preflight.ts +71 -0
- package/src/shared/application/dev/project-files.ts +17 -0
- package/src/shared/application/dev/prompts.ts +34 -0
- package/src/shared/application/dev/question-round.ts +60 -0
- package/src/shared/application/dev/resolve-work-folder.ts +134 -0
- package/src/shared/application/dev/script-tool-slot.ts +27 -0
- package/src/shared/application/dev/settle-questions.ts +57 -0
- package/src/shared/application/dev/source-review.ts +67 -0
- package/src/shared/application/dev/source-step.ts +152 -0
- package/src/shared/application/dev/spend.ts +55 -0
- package/src/shared/application/dev/step-precedents.ts +90 -0
- package/src/shared/application/dev/tool-call-policy.ts +87 -0
- package/src/shared/application/dev/tool-callbacks.ts +262 -0
- package/src/shared/application/dev/tool-trace-recorder.ts +46 -0
- package/src/shared/application/dev/verdict-sources.ts +50 -0
- package/src/shared/application/dev/wrapped-tools.ts +147 -0
- package/src/shared/application/extra-tools.ts +71 -0
- package/src/shared/application/git/batch-worktree.ts +102 -0
- package/src/shared/application/git/commit-files.ts +191 -0
- package/src/shared/application/git/merge-batch.ts +67 -0
- package/src/shared/application/git/messages.ts +75 -0
- package/src/shared/application/git/open-pull-request.ts +52 -0
- package/src/shared/application/host-context.ts +59 -0
- package/src/shared/application/host-layout-store.ts +45 -0
- package/src/shared/application/instructions-file.ts +19 -0
- package/src/shared/application/json-file.ts +34 -0
- package/src/shared/application/llm-profile.ts +36 -0
- package/src/shared/application/messages.ts +14 -0
- package/src/shared/application/permission-rules.ts +169 -0
- package/src/shared/application/ports/approvals.ts +20 -0
- package/src/shared/application/ports/clock.ts +5 -0
- package/src/shared/application/ports/code-index.ts +93 -0
- package/src/shared/application/ports/crew.ts +60 -0
- package/src/shared/application/ports/decision.ts +14 -0
- package/src/shared/application/ports/files.ts +21 -0
- package/src/shared/application/ports/human.ts +38 -0
- package/src/shared/application/ports/llm.ts +83 -0
- package/src/shared/application/ports/memory.ts +30 -0
- package/src/shared/application/ports/progress.ts +23 -0
- package/src/shared/application/ports/runtime.ts +15 -0
- package/src/shared/application/ports/session.ts +74 -0
- package/src/shared/application/ports/shared-memory.ts +26 -0
- package/src/shared/application/ports/shell.ts +40 -0
- package/src/shared/application/ports/telemetry.ts +45 -0
- package/src/shared/application/ports/theme.ts +11 -0
- package/src/shared/application/ports/tools.ts +46 -0
- package/src/shared/application/ports/usage.ts +45 -0
- package/src/shared/application/ports.ts +29 -0
- package/src/shared/application/project-manifests.ts +106 -0
- package/src/shared/application/session-io.ts +85 -0
- package/src/shared/application/session-state.ts +36 -0
- package/src/shared/application/shared-memory/admit-entries.ts +179 -0
- package/src/shared/application/shared-memory/harvest-after-gaps.ts +69 -0
- package/src/shared/application/shared-memory/harvest-mistakes.ts +45 -0
- package/src/shared/application/shared-memory/import-agent-memory.ts +119 -0
- package/src/shared/application/shared-memory/memory-files.ts +111 -0
- package/src/shared/application/shared-memory/memory-settings.ts +94 -0
- package/src/shared/application/shared-memory/messages.ts +63 -0
- package/src/shared/application/shared-memory/push-candidate.ts +149 -0
- package/src/shared/application/shared-memory/recall-precedents.ts +70 -0
- package/src/shared/application/skills/messages.ts +4 -0
- package/src/shared/application/skills/suggest-skills.ts +102 -0
- package/src/shared/application/state-snapshot.ts +38 -0
- package/src/shared/application/workflow/messages.ts +8 -0
- package/src/shared/application/workflow/workflow-state.ts +136 -0
- package/src/shared/domain/agent-policy/behavior-flags.ts +162 -0
- package/src/shared/domain/agent-policy/extra-tools.ts +67 -0
- package/src/shared/domain/agent-policy/memory-categories.ts +6 -0
- package/src/shared/domain/agent-policy/messages.ts +66 -0
- package/src/shared/domain/agent-policy/mode-policy.ts +51 -0
- package/src/shared/domain/agent-policy/output-styles.ts +11 -0
- package/src/shared/domain/agent-policy/path-rules.ts +299 -0
- package/src/shared/domain/agent-policy/permission.ts +625 -0
- package/src/shared/domain/agent-policy/prompts.ts +17 -0
- package/src/shared/domain/agent-policy/reasoning.ts +59 -0
- package/src/shared/domain/agent-policy/rule-sets.ts +416 -0
- package/src/shared/domain/agent-policy/tool-access.ts +91 -0
- package/src/shared/domain/agent-registry.ts +143 -0
- package/src/shared/domain/agents/built-in-charters.ts +43 -0
- package/src/shared/domain/agents/chain.ts +30 -0
- package/src/shared/domain/agents/charter.ts +64 -0
- package/src/shared/domain/agents/exclusive.ts +25 -0
- package/src/shared/domain/agents/instances.ts +252 -0
- package/src/shared/domain/agents/messages.ts +39 -0
- package/src/shared/domain/agents/model-route.ts +199 -0
- package/src/shared/domain/agents/prompts.ts +20 -0
- package/src/shared/domain/code-intel-contract.ts +357 -0
- package/src/shared/domain/code-intel-routing.ts +60 -0
- package/src/shared/domain/compact-outcome.ts +46 -0
- package/src/shared/domain/compaction-thresholds.ts +162 -0
- package/src/shared/domain/compaction.ts +288 -0
- package/src/shared/domain/config-schema.ts +434 -0
- package/src/shared/domain/context-prune.ts +176 -0
- package/src/shared/domain/decision/questions.ts +102 -0
- package/src/shared/domain/dev/access-cost.ts +230 -0
- package/src/shared/domain/dev/artefacts.ts +50 -0
- package/src/shared/domain/dev/batches-concurrency.ts +35 -0
- package/src/shared/domain/dev/batches-state.ts +49 -0
- package/src/shared/domain/dev/build-commands.ts +45 -0
- package/src/shared/domain/dev/call-guard.ts +342 -0
- package/src/shared/domain/dev/carried-text.ts +47 -0
- package/src/shared/domain/dev/design-rules.ts +100 -0
- package/src/shared/domain/dev/learn-proposals.ts +176 -0
- package/src/shared/domain/dev/learn-state.ts +94 -0
- package/src/shared/domain/dev/markers.ts +107 -0
- package/src/shared/domain/dev/messages.ts +259 -0
- package/src/shared/domain/dev/path-args.ts +42 -0
- package/src/shared/domain/dev/path-rebase.ts +93 -0
- package/src/shared/domain/dev/phase-timing.ts +50 -0
- package/src/shared/domain/dev/plan-checks.ts +191 -0
- package/src/shared/domain/dev/plan-format.ts +170 -0
- package/src/shared/domain/dev/project-files.ts +29 -0
- package/src/shared/domain/dev/prompts/brief-blocks.ts +20 -0
- package/src/shared/domain/dev/prompts.ts +251 -0
- package/src/shared/domain/dev/questions.ts +267 -0
- package/src/shared/domain/dev/reading-rule.ts +41 -0
- package/src/shared/domain/dev/repo-pack.ts +240 -0
- package/src/shared/domain/dev/review-answer.ts +173 -0
- package/src/shared/domain/dev/review-brief.ts +54 -0
- package/src/shared/domain/dev/reviewer-charter.ts +35 -0
- package/src/shared/domain/dev/sheet-facts.ts +81 -0
- package/src/shared/domain/dev/spec-format.ts +182 -0
- package/src/shared/domain/dev/step-budget.ts +74 -0
- package/src/shared/domain/dev/step-rules.ts +109 -0
- package/src/shared/domain/dev/test-commands.ts +94 -0
- package/src/shared/domain/dev/test-output.ts +33 -0
- package/src/shared/domain/dev/test-paths.ts +40 -0
- package/src/shared/domain/dev/tool-guards.ts +65 -0
- package/src/shared/domain/dev/trait-pattern.ts +87 -0
- package/src/shared/domain/dev/verdict-format.ts +162 -0
- package/src/shared/domain/dev/whitespace.ts +35 -0
- package/src/shared/domain/dev/work-folder.ts +68 -0
- package/src/shared/domain/dev/yaml-subset.ts +385 -0
- package/src/shared/domain/error-text.ts +13 -0
- package/src/shared/domain/git/close.ts +274 -0
- package/src/shared/domain/git/messages.ts +20 -0
- package/src/shared/domain/git/pull-request.ts +96 -0
- package/src/shared/domain/git/worktree.ts +46 -0
- package/src/shared/domain/host-layout.ts +147 -0
- package/src/shared/domain/host-paths.ts +399 -0
- package/src/shared/domain/index-languages.ts +16 -0
- package/src/shared/domain/instructions-file.ts +18 -0
- package/src/shared/domain/iso-day.ts +4 -0
- package/src/shared/domain/llm-failure.ts +134 -0
- package/src/shared/domain/llm-profile.ts +44 -0
- package/src/shared/domain/marked-message.ts +29 -0
- package/src/shared/domain/markers.ts +30 -0
- package/src/shared/domain/messages.ts +291 -0
- package/src/shared/domain/model-catalog.ts +79 -0
- package/src/shared/domain/permission-modes.ts +99 -0
- package/src/shared/domain/prelude.ts +92 -0
- package/src/shared/domain/project-manifests.ts +84 -0
- package/src/shared/domain/prompts.ts +233 -0
- package/src/shared/domain/search-routing.ts +77 -0
- package/src/shared/domain/secret-patterns.ts +46 -0
- package/src/shared/domain/session-keys.ts +92 -0
- package/src/shared/domain/session-start.ts +61 -0
- package/src/shared/domain/severity.ts +72 -0
- package/src/shared/domain/sha1.ts +61 -0
- package/src/shared/domain/shared-memory/agent-memory-import.ts +145 -0
- package/src/shared/domain/shared-memory/candidates.ts +40 -0
- package/src/shared/domain/shared-memory/entry.ts +151 -0
- package/src/shared/domain/shared-memory/front-matter.ts +187 -0
- package/src/shared/domain/shared-memory/gate.ts +45 -0
- package/src/shared/domain/shared-memory/harvest.ts +64 -0
- package/src/shared/domain/shared-memory/layout.ts +190 -0
- package/src/shared/domain/shared-memory/markers.ts +9 -0
- package/src/shared/domain/shared-memory/messages.ts +66 -0
- package/src/shared/domain/shared-memory/precedents-block.ts +82 -0
- package/src/shared/domain/shared-memory/prompts.ts +28 -0
- package/src/shared/domain/shared-memory/refused.ts +84 -0
- package/src/shared/domain/shared-memory/verdict-rows.ts +134 -0
- package/src/shared/domain/skills/prompts.ts +4 -0
- package/src/shared/domain/skills/shortlist.ts +149 -0
- package/src/shared/domain/snip-turns.ts +33 -0
- package/src/shared/domain/speech.ts +21 -0
- package/src/shared/domain/strip.ts +88 -0
- package/src/shared/domain/tool-trace.ts +120 -0
- package/src/shared/domain/types.ts +67 -0
- package/src/shared/domain/verifiers.ts +33 -0
- package/src/shared/domain/vfs.ts +16 -0
- package/src/shared/domain/workflow/prompts.ts +15 -0
- package/src/shared/domain/workflow/state-file.ts +142 -0
- package/src/shared/infrastructure/globals.ts +57 -0
- package/src/shared/infrastructure/orkeon/approvals.ts +24 -0
- package/src/shared/infrastructure/orkeon/child-agents.ts +122 -0
- package/src/shared/infrastructure/orkeon/chooser.ts +32 -0
- package/src/shared/infrastructure/orkeon/code-index.ts +120 -0
- package/src/shared/infrastructure/orkeon/crew-host.ts +27 -0
- package/src/shared/infrastructure/orkeon/crew-memory.ts +12 -0
- package/src/shared/infrastructure/orkeon/decision-model.ts +31 -0
- package/src/shared/infrastructure/orkeon/dev-deps.ts +179 -0
- package/src/shared/infrastructure/orkeon/files.ts +58 -0
- package/src/shared/infrastructure/orkeon/github-pull-requests.ts +30 -0
- package/src/shared/infrastructure/orkeon/host-context.ts +36 -0
- package/src/shared/infrastructure/orkeon/host-provider.ts +22 -0
- package/src/shared/infrastructure/orkeon/human-input.ts +55 -0
- package/src/shared/infrastructure/orkeon/llm-profile.ts +58 -0
- package/src/shared/infrastructure/orkeon/llm.ts +164 -0
- package/src/shared/infrastructure/orkeon/markers.ts +6 -0
- package/src/shared/infrastructure/orkeon/memory-store.ts +41 -0
- package/src/shared/infrastructure/orkeon/memory-tools.ts +129 -0
- package/src/shared/infrastructure/orkeon/messages.ts +15 -0
- package/src/shared/infrastructure/orkeon/permission-rules.ts +42 -0
- package/src/shared/infrastructure/orkeon/progress.ts +24 -0
- package/src/shared/infrastructure/orkeon/prompts.ts +47 -0
- package/src/shared/infrastructure/orkeon/reasoning.ts +40 -0
- package/src/shared/infrastructure/orkeon/run-state.ts +17 -0
- package/src/shared/infrastructure/orkeon/runtime-info.ts +30 -0
- package/src/shared/infrastructure/orkeon/runtime-tools.ts +60 -0
- package/src/shared/infrastructure/orkeon/script-tools.ts +129 -0
- package/src/shared/infrastructure/orkeon/session-store.ts +94 -0
- package/src/shared/infrastructure/orkeon/session-switch.ts +23 -0
- package/src/shared/infrastructure/orkeon/shared-memory.ts +61 -0
- package/src/shared/infrastructure/orkeon/shell-jobs.ts +81 -0
- package/src/shared/infrastructure/orkeon/shell.ts +39 -0
- package/src/shared/infrastructure/orkeon/telemetry.ts +63 -0
- package/src/shared/infrastructure/orkeon/tool-catalogue.ts +76 -0
- package/src/shared/infrastructure/orkeon/tool-results.ts +120 -0
- package/src/shared/infrastructure/orkeon/usage.ts +74 -0
- package/src/shared/infrastructure/orkeon/wiring.ts +174 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// /commit: the gate before the git-commit crew is launched (B-1). The arguments, the effective permission mode
|
|
2
|
+
// (the read-only modes are refused here, so the operator learns why without a crew round-trip; the crew
|
|
3
|
+
// re-checks), the plan and its confirmation, then the crew's input: the mode, the paths, push and pull request,
|
|
4
|
+
// the author's note when one is given, and what the crew needs to open the pull request itself (pr-context.ts), read only when the run may reach it.
|
|
5
|
+
import type { Logger } from "../../../shared/application/ports.ts";
|
|
6
|
+
import type { SessionIo } from "../../../shared/application/session-io.ts";
|
|
7
|
+
import { pullRequestCrewInputs } from "../../../shared/domain/git/pull-request.ts";
|
|
8
|
+
import { buildCommitPlan, isCommitPermitted, parseCommitArgs } from "../../../crews/git-commit/domain/commit.ts";
|
|
9
|
+
import { commandLine, splitWords } from "../args.ts";
|
|
10
|
+
import { readPullRequestContext } from "../pr-context.ts";
|
|
11
|
+
import type { PullRequestContext, PullRequestContextPorts } from "../pr-context.ts";
|
|
12
|
+
import { COMMIT_CANCELLED, NO_ANSWER_REFUSAL, cannotPromptRefusal, commitApproved } from "./messages.ts";
|
|
13
|
+
import { refusedLine } from "../../../shared/application/git/messages.ts";
|
|
14
|
+
import { failedLine } from "../messages.ts";
|
|
15
|
+
|
|
16
|
+
export interface CommitCommandDeps {
|
|
17
|
+
session: Pick<SessionIo, "resolveEffectiveSessionMode">;
|
|
18
|
+
/** Asks the yes/no question: true approves; anything else, or a throw, refuses. */
|
|
19
|
+
confirm(question: string): Promise<unknown>;
|
|
20
|
+
write(line: string): void;
|
|
21
|
+
log: Pick<Logger, "info">;
|
|
22
|
+
pr: PullRequestContextPorts;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type CommitDispatch = { refused: string } | { input: Record<string, unknown> };
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Asks for confirmation, distinguishing "declined" from "cannot ask".
|
|
29
|
+
*
|
|
30
|
+
* A headless session's prompt throws (or returns something that is not a boolean), and
|
|
31
|
+
* treating that as approval is how an unattended run commits a whole tree. Anything that
|
|
32
|
+
* is not an explicit `true` refuses, and the two cases are reported differently because
|
|
33
|
+
* the remedy differs: one is "answer yes", the other is "pass --yes".
|
|
34
|
+
*/
|
|
35
|
+
async function confirmOrRefuse(deps: Pick<CommitCommandDeps, "confirm" | "write">, notice: string, question: string): Promise<string | null> {
|
|
36
|
+
deps.write(notice);
|
|
37
|
+
let answer: unknown;
|
|
38
|
+
try {
|
|
39
|
+
answer = await deps.confirm(question);
|
|
40
|
+
} catch (e: any) {
|
|
41
|
+
return cannotPromptRefusal(String(e?.message ?? e));
|
|
42
|
+
}
|
|
43
|
+
if (answer === true) return null;
|
|
44
|
+
if (typeof answer !== "boolean") {
|
|
45
|
+
return NO_ANSWER_REFUSAL;
|
|
46
|
+
}
|
|
47
|
+
return COMMIT_CANCELLED;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** `/commit [--yes] [--push] [--pr] [--note <text>] [<path>…]`, from the command's raw tokens: the refusal, written,
|
|
51
|
+
* or the crew's input. The REPL keeps the quotes in the raw tokens: the line is split again, so
|
|
52
|
+
* `--note "the reason in several words"` reads as one note. */
|
|
53
|
+
export async function runCommitCommand(tokens: readonly string[], deps: CommitCommandDeps): Promise<CommitDispatch> {
|
|
54
|
+
const parsed = parseCommitArgs(splitWords(commandLine(tokens)).map((w) => w.text));
|
|
55
|
+
if (!parsed.ok) {
|
|
56
|
+
deps.write(parsed.text);
|
|
57
|
+
return { refused: parsed.text };
|
|
58
|
+
}
|
|
59
|
+
const { yes, push, pr, paths, note } = parsed.args;
|
|
60
|
+
const { mode, via } = await deps.session.resolveEffectiveSessionMode();
|
|
61
|
+
|
|
62
|
+
const permitted = isCommitPermitted(mode);
|
|
63
|
+
if (!permitted.allowed) {
|
|
64
|
+
deps.write(refusedLine(permitted.reason));
|
|
65
|
+
return { refused: permitted.reason };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (!yes) {
|
|
69
|
+
const plan = buildCommitPlan({ push, pr, paths });
|
|
70
|
+
const refusal = await confirmOrRefuse(deps, plan.notice, plan.question);
|
|
71
|
+
if (refusal !== null) {
|
|
72
|
+
deps.write(failedLine(refusal));
|
|
73
|
+
return { refused: refusal };
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
deps.log.info(commitApproved(mode, via));
|
|
78
|
+
const context: PullRequestContext | null = pr || push ? await readPullRequestContext(deps.pr) : null;
|
|
79
|
+
// A yes to a plan that named the pull request is the question the github call needs; --yes asked nothing.
|
|
80
|
+
return {
|
|
81
|
+
input: {
|
|
82
|
+
permissionMode: mode, paths, push, pr,
|
|
83
|
+
...(note === undefined ? {} : { note }),
|
|
84
|
+
...pullRequestCrewInputs({
|
|
85
|
+
pr, push, yes,
|
|
86
|
+
read: () => ({ githubTool: context?.githubTool ?? false, permissionRules: context?.permissionRules ?? [] }),
|
|
87
|
+
}),
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
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
|
+
import {
|
|
9
|
+
NOT_A_PATHSPEC, STAGED_CHANGES, WORKING_TREE_CHANGES, argumentsIgnored, diffFailed, diffIgnored, exitCode, noChanges,
|
|
10
|
+
notAnAllowedDiffOption, scopeLine,
|
|
11
|
+
} from "./messages.ts";
|
|
12
|
+
|
|
13
|
+
export interface DiffPlan {
|
|
14
|
+
/** The git argument string, already assembled. */
|
|
15
|
+
args: string;
|
|
16
|
+
staged: boolean;
|
|
17
|
+
/** Whether git answers with a unified diff, which the console can colour, rather than a summary. */
|
|
18
|
+
unified: boolean;
|
|
19
|
+
/** Tokens that were dropped, with the reason — never silently ignored. */
|
|
20
|
+
rejected: Array<{ value: string; reason: string }>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Only these git-diff options are honoured.
|
|
25
|
+
*
|
|
26
|
+
* The pre-B-11 handler appended `raw` verbatim: `git diff <anything the operator
|
|
27
|
+
* typed>`. The shell tool forbids operators, so this was not an injection hole,
|
|
28
|
+
* but it was an unbounded surface — `--output=/etc/x` is a plain git option that
|
|
29
|
+
* writes a file, and no allowlist stood in the way. The baseline specifies exactly
|
|
30
|
+
* one flag (`staged`); the extra safe options below are the ones a diff reader
|
|
31
|
+
* actually reaches for, and anything else is refused BY NAME so the operator knows.
|
|
32
|
+
*/
|
|
33
|
+
export const ALLOWED_DIFF_FLAGS = [
|
|
34
|
+
"--staged", "--cached", "--stat", "--name-only", "--name-status",
|
|
35
|
+
"--numstat", "--shortstat", "-p", "--unified", "--word-diff",
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
/** The allowed options under which git answers with something other than a unified diff. */
|
|
39
|
+
const NOT_UNIFIED_FLAGS = ["--stat", "--name-only", "--name-status", "--numstat", "--shortstat", "--word-diff"];
|
|
40
|
+
|
|
41
|
+
/** A pathspec: no leading dash, no shell metacharacter, no parent traversal. */
|
|
42
|
+
const SAFE_PATHSPEC = /^[A-Za-z0-9._/\-*]+$/;
|
|
43
|
+
|
|
44
|
+
export function planDiff(tokens: readonly string[]): DiffPlan {
|
|
45
|
+
const rejected: Array<{ value: string; reason: string }> = [];
|
|
46
|
+
const flags: string[] = [];
|
|
47
|
+
const paths: string[] = [];
|
|
48
|
+
|
|
49
|
+
for (const raw of tokens ?? []) {
|
|
50
|
+
const token = String(raw ?? "").trim();
|
|
51
|
+
if (token.length === 0) continue;
|
|
52
|
+
|
|
53
|
+
if (token.startsWith("-")) {
|
|
54
|
+
// `--unified=3` and `-U3` carry a value; compare on the option part.
|
|
55
|
+
const head = token.split("=")[0];
|
|
56
|
+
if (ALLOWED_DIFF_FLAGS.includes(head)) flags.push(token);
|
|
57
|
+
else rejected.push({ value: token, reason: notAnAllowedDiffOption(ALLOWED_DIFF_FLAGS.join(" ")) });
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (!SAFE_PATHSPEC.test(token) || token.includes("..")) {
|
|
62
|
+
rejected.push({ value: token, reason: NOT_A_PATHSPEC });
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
paths.push(token);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const staged = flags.some((f) => f === "--staged" || f === "--cached");
|
|
69
|
+
// `--` separates options from pathspecs, so a path that looks like a ref stays a path.
|
|
70
|
+
const args = [...flags, ...(paths.length > 0 ? ["--", ...paths] : [])].join(" ");
|
|
71
|
+
const unified = !flags.some((f) => NOT_UNIFIED_FLAGS.includes(f.split("=")[0]));
|
|
72
|
+
return { args, staged, unified, rejected };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function describeDiffScope(plan: DiffPlan): string {
|
|
76
|
+
return plan.staged ? STAGED_CHANGES : WORKING_TREE_CHANGES;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface DiffDeps {
|
|
80
|
+
shell: Shell;
|
|
81
|
+
log: Pick<Logger, "warn">;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** `/diff [--staged] [pathspec…]`, from the command's raw tokens: the diff as lines,
|
|
85
|
+
* each ignored token logged and counted in the closing message. */
|
|
86
|
+
export async function runDiff(tokens: readonly string[], deps: DiffDeps): Promise<CommandView> {
|
|
87
|
+
const plan = planDiff(tokens);
|
|
88
|
+
for (const r of plan.rejected) deps.log.warn(diffIgnored(r.value, r.reason));
|
|
89
|
+
|
|
90
|
+
const r = await deps.shell.run(`git diff ${plan.args}`.trim());
|
|
91
|
+
if (r.exitCode !== 0) {
|
|
92
|
+
const err = r.stderr.trim();
|
|
93
|
+
return { text: diffFailed(err || exitCode(r.exitCode)) };
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const out = r.stdout;
|
|
97
|
+
if (out.trim().length === 0) {
|
|
98
|
+
return { text: noChanges(describeDiffScope(plan)) };
|
|
99
|
+
}
|
|
100
|
+
const scope = scopeLine(describeDiffScope(plan));
|
|
101
|
+
// A merge conflict's combined diff (`@@@`, two columns of signs) is not the unified form the block numbers.
|
|
102
|
+
const unified = plan.unified && !/^@@@ /m.test(out);
|
|
103
|
+
return {
|
|
104
|
+
...(unified ? { lines: [scope], diff: out } : { lines: [scope, out] }),
|
|
105
|
+
...(plan.rejected.length > 0 ? { text: argumentsIgnored(plan.rejected.length) } : {}),
|
|
106
|
+
};
|
|
107
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// The text /branch, /commit, /diff, /review and /passes show the user (ADR 0026): their refusals and their answers.
|
|
2
|
+
// Read by branch.ts, commit.ts, diff.ts and review.ts.
|
|
3
|
+
|
|
4
|
+
// /branch
|
|
5
|
+
export const looksLikeOption = (name: string) => `'${name}' looks like an option, not a branch name`;
|
|
6
|
+
export const notABranchName = (name: string) =>
|
|
7
|
+
`'${name}' is not a plausible branch name (letters, digits, '.', '_', '/', '-')`;
|
|
8
|
+
export const dirtyTreeRefusal = (branch: string, count: number, shown: string, more: string) =>
|
|
9
|
+
`refusing to check out '${branch}': ${count} uncommitted change(s) in the working tree.\n` +
|
|
10
|
+
`${shown}${more}\n` +
|
|
11
|
+
"Commit them (/commit) or stash them first — a checkout would either fail or carry them across.";
|
|
12
|
+
export const andMore = (count: number) => `\n … and ${count} more`;
|
|
13
|
+
export const branchRefusedLog = (branch: string) =>
|
|
14
|
+
`/branch refused: uncommitted changes block the checkout of '${branch}'`;
|
|
15
|
+
export const checkoutFailed = (reason: string) => `checkout failed: ${reason}`;
|
|
16
|
+
export const switchedTo = (branch: string) => `switched to '${branch}'`;
|
|
17
|
+
export const exitCode = (code: number) => `exit code ${code}`;
|
|
18
|
+
|
|
19
|
+
// /commit
|
|
20
|
+
export const cannotPromptRefusal = (reason: string) =>
|
|
21
|
+
"refused: /commit needs a confirmation and this session cannot prompt " +
|
|
22
|
+
`(${reason}). Re-run as '/commit --yes' if you intend to stage ` +
|
|
23
|
+
"and commit the changed files unattended.";
|
|
24
|
+
export const NO_ANSWER_REFUSAL =
|
|
25
|
+
"refused: the confirmation prompt returned no answer (non-interactive session). " +
|
|
26
|
+
"Re-run as '/commit --yes' to stage and commit the changed files unattended.";
|
|
27
|
+
export const COMMIT_CANCELLED = "cancelled — nothing was staged and nothing was committed.";
|
|
28
|
+
export const commitApproved = (mode: string, via: string) => `commit approved — permission mode '${mode}' (${via})`;
|
|
29
|
+
|
|
30
|
+
// /diff
|
|
31
|
+
/** Baseline wording for an empty diff — a distinct sentence, not "(no output)". */
|
|
32
|
+
export const NO_CHANGES_MESSAGE = "No changes to show.";
|
|
33
|
+
export const notAnAllowedDiffOption = (allowed: string) => `not an allowed diff option (allowed: ${allowed})`;
|
|
34
|
+
export const NOT_A_PATHSPEC = "not a plausible pathspec (letters, digits, '.', '_', '/', '-', '*'; no '..')";
|
|
35
|
+
export const STAGED_CHANGES = "staged changes";
|
|
36
|
+
export const WORKING_TREE_CHANGES = "working-tree changes since the last commit";
|
|
37
|
+
export const diffIgnored = (value: string, reason: string) => `/diff ignored '${value}' — ${reason}`;
|
|
38
|
+
export const diffFailed = (reason: string) => `git diff failed: ${reason}`;
|
|
39
|
+
export const noChanges = (scope: string) => `${NO_CHANGES_MESSAGE} (${scope})`;
|
|
40
|
+
export const scopeLine = (scope: string) => `── ${scope}`;
|
|
41
|
+
export const argumentsIgnored = (count: number) => `${count} argument(s) ignored — see the log.`;
|
|
42
|
+
|
|
43
|
+
// /review and /passes
|
|
44
|
+
export const invalidPassCount = (token: string, min: number, max: number) =>
|
|
45
|
+
`invalid pass count '${token}' — expected an integer between ${min} and ${max}.`;
|
|
46
|
+
export const reviewUnknownOption = (token: string) =>
|
|
47
|
+
`review: unknown option '${token}' (--files, --commit, --lens, --passes)`;
|
|
48
|
+
export const reviewTakesValue = (name: string) => `review: ${name} takes a value`;
|
|
49
|
+
export const reviewLensTakes = (lenses: string, lens: string) => `review: --lens takes ${lenses}, not '${lens}'`;
|
|
50
|
+
export const passesShown = (current: string, min: number, max: number) =>
|
|
51
|
+
`reasoning passes: ${current}\n/review runs that many lens rounds.\n` +
|
|
52
|
+
`usage: /passes <${min}-${max}> (this session) or /review --passes <${min}-${max}> (one run)`;
|
|
53
|
+
export const passesSet = (n: number, calls: number) =>
|
|
54
|
+
`reasoning passes set to ${n} — /review will make ${calls} lens calls per run (session-scoped; /clear clears it).`;
|
|
@@ -0,0 +1,108 @@
|
|
|
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
|
+
import { invalidPassCount, passesSet, passesShown, reviewLensTakes, reviewTakesValue, reviewUnknownOption } from "./messages.ts";
|
|
14
|
+
import { markedDefault as defaultPasses } from "../messages.ts";
|
|
15
|
+
|
|
16
|
+
export const REVIEW_LENSES: readonly string[] = ["correctness", "security", "style"];
|
|
17
|
+
|
|
18
|
+
/** The crew a review runs in, launched exclusively: the host refuses a review while one runs (any alias:
|
|
19
|
+
* /security-review is the same crew), so two never run side by side; /passes launches nothing and always answers. */
|
|
20
|
+
export const REVIEW_CREW = "code-review";
|
|
21
|
+
|
|
22
|
+
/** What the code-review crew is launched with. */
|
|
23
|
+
export interface ReviewInput {
|
|
24
|
+
files: string[];
|
|
25
|
+
commit: string;
|
|
26
|
+
lenses: string;
|
|
27
|
+
passes?: number;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type ReviewRoute =
|
|
31
|
+
| { route: "review"; input: ReviewInput }
|
|
32
|
+
| { route: "passes"; token: string }
|
|
33
|
+
| { route: "refused"; text: string };
|
|
34
|
+
|
|
35
|
+
/** The refusal of a pass count that is not an integer from 1 to 5. */
|
|
36
|
+
export function invalidPassesText(token: string): string {
|
|
37
|
+
return invalidPassCount(token, MIN_PASSES, MAX_PASSES);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** A pass count from 1 to 5, or null. */
|
|
41
|
+
function passCount(token: string): number | null {
|
|
42
|
+
const n = Number(token);
|
|
43
|
+
return token !== "" && Number.isInteger(n) && n >= MIN_PASSES && n <= MAX_PASSES ? n : null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** `--name=value` split, or the bare option with no value. */
|
|
47
|
+
function option(token: string): { name: string; value: string | null } {
|
|
48
|
+
const at = token.indexOf("=");
|
|
49
|
+
return at < 0 ? { name: token, value: null } : { name: token.slice(0, at), value: token.slice(at + 1) };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** The line of /review, or of the alias it was typed by (`security-review`, `passes`). The REPL keeps the quotes in
|
|
53
|
+
* the raw tokens: the line is split again, so `--commit "abc123"` reads `abc123` and a quoted path stays one file. */
|
|
54
|
+
export function parseReviewArgs(raw: readonly string[], typed: string): ReviewRoute {
|
|
55
|
+
const tokens = splitWords(commandLine(raw)).map((w) => w.text);
|
|
56
|
+
if (typed === "passes") return { route: "passes", token: (tokens[0] ?? "").trim() };
|
|
57
|
+
const files: string[] = [];
|
|
58
|
+
let commit = "";
|
|
59
|
+
let lens = "";
|
|
60
|
+
let passes: number | undefined;
|
|
61
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
62
|
+
const token = tokens[i];
|
|
63
|
+
if (!token.startsWith("--")) {
|
|
64
|
+
files.push(token);
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
const { name, value: inline } = option(token);
|
|
68
|
+
if (name === "--files") {
|
|
69
|
+
if (inline !== null && inline !== "") files.push(inline);
|
|
70
|
+
while (i + 1 < tokens.length && !tokens[i + 1].startsWith("--")) files.push(tokens[++i]);
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
if (name !== "--commit" && name !== "--lens" && name !== "--passes") {
|
|
74
|
+
return { route: "refused", text: reviewUnknownOption(token) };
|
|
75
|
+
}
|
|
76
|
+
const value = inline ?? (i + 1 < tokens.length && !tokens[i + 1].startsWith("--") ? tokens[++i] : "");
|
|
77
|
+
if (value === "") return { route: "refused", text: reviewTakesValue(name) };
|
|
78
|
+
if (name === "--commit") commit = value;
|
|
79
|
+
else if (name === "--lens") lens = value;
|
|
80
|
+
else {
|
|
81
|
+
const n = passCount(value);
|
|
82
|
+
if (n === null) return { route: "refused", text: invalidPassesText(value) };
|
|
83
|
+
passes = n;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (typed === "security-review") lens = "security";
|
|
87
|
+
else if (lens !== "" && !REVIEW_LENSES.includes(lens)) {
|
|
88
|
+
return { route: "refused", text: reviewLensTakes(REVIEW_LENSES.join(", "), lens) };
|
|
89
|
+
}
|
|
90
|
+
return { route: "review", input: { files, commit, lenses: lens, ...(passes === undefined ? {} : { passes }) } };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface PassesDeps {
|
|
94
|
+
session: Pick<SessionStore, "readState" | "writeState">;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** `/passes [n]`: the session's pass count shown, or set from 1 to 5 (session-scoped; /clear clears it). */
|
|
98
|
+
export async function runPasses(token: string, deps: PassesDeps): Promise<CommandView> {
|
|
99
|
+
if (token === "") {
|
|
100
|
+
const current = (await deps.session.readState(PASSES_STATE_KEY).catch(() => null)) ?? defaultPasses(MIN_PASSES);
|
|
101
|
+
return { text: passesShown(current, MIN_PASSES, MAX_PASSES) };
|
|
102
|
+
}
|
|
103
|
+
const n = passCount(token);
|
|
104
|
+
if (n === null) return { text: invalidPassesText(token) };
|
|
105
|
+
await deps.session.writeState(PASSES_STATE_KEY, String(n));
|
|
106
|
+
// n rounds × 3 lenses is n × 3 LLM calls: say so, the cost is the operator's.
|
|
107
|
+
return { text: passesSet(n, n * 3) };
|
|
108
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
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
|
+
import {
|
|
21
|
+
ADMITTED_UNASKED, HEADLESS, IMPORT_TAKES_NOTHING, LEFT_AS_CANDIDATE, LIST_TAKES_NOTHING, NOTHING_ADMITTED,
|
|
22
|
+
NO_INGESTION_ON_REFUSAL, REFUSE_USAGE, admitQuestion, motifTooLong, noPendingCandidate, notACandidateId, notPending,
|
|
23
|
+
stoppedAt, unknownAdmitOption,
|
|
24
|
+
} from "./messages.ts";
|
|
25
|
+
|
|
26
|
+
/** The crew that writes an admission, launched exclusively: the host refuses an admission while the previous one is
|
|
27
|
+
* still being written, so two never write the shared memory side by side; the list, a refusal and the import launch
|
|
28
|
+
* no crew and always answer. */
|
|
29
|
+
export const MEMORY_ADMIT_CREW = "shared-memory-admit";
|
|
30
|
+
const ID = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
31
|
+
const MAX_MOTIF_CHARS = 200;
|
|
32
|
+
const SHOWN_BODY_LINES = 6;
|
|
33
|
+
|
|
34
|
+
export type MemoryAdmitArgs =
|
|
35
|
+
| { kind: "list" }
|
|
36
|
+
| { kind: "import" }
|
|
37
|
+
| { kind: "refuse"; id: string; motif?: string }
|
|
38
|
+
| { kind: "admit"; ids: string[] };
|
|
39
|
+
|
|
40
|
+
export function parseMemoryAdmitArgs(tokens: readonly string[]): { ok: true; args: MemoryAdmitArgs } | { ok: false; text: string } {
|
|
41
|
+
if (tokens[0] === "--list") {
|
|
42
|
+
return tokens.length === 1 ? { ok: true, args: { kind: "list" } } : { ok: false, text: LIST_TAKES_NOTHING };
|
|
43
|
+
}
|
|
44
|
+
if (tokens[0] === "--import") {
|
|
45
|
+
return tokens.length === 1 ? { ok: true, args: { kind: "import" } } : { ok: false, text: IMPORT_TAKES_NOTHING };
|
|
46
|
+
}
|
|
47
|
+
if (tokens[0] === "--refuse") {
|
|
48
|
+
const id = tokens[1];
|
|
49
|
+
if (id === undefined || !ID.test(id)) return { ok: false, text: REFUSE_USAGE };
|
|
50
|
+
const motif = tokens.slice(2).join(" ").replace(/\s+/g, " ").trim();
|
|
51
|
+
if (Array.from(motif).length > MAX_MOTIF_CHARS) return { ok: false, text: motifTooLong(MAX_MOTIF_CHARS) };
|
|
52
|
+
return { ok: true, args: motif === "" ? { kind: "refuse", id } : { kind: "refuse", id, motif } };
|
|
53
|
+
}
|
|
54
|
+
for (const tok of tokens) {
|
|
55
|
+
if (tok.startsWith("--")) return { ok: false, text: unknownAdmitOption(tok) };
|
|
56
|
+
if (!ID.test(tok)) return { ok: false, text: notACandidateId(tok) };
|
|
57
|
+
}
|
|
58
|
+
return { ok: true, args: { kind: "admit", ids: [...new Set(tokens)] } };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface MemoryAdmitDeps {
|
|
62
|
+
files: Pick<Files, "read" | "write" | "list">;
|
|
63
|
+
config: Pick<ConfigStore, "readValue">;
|
|
64
|
+
shell: Pick<Shell, "run">;
|
|
65
|
+
clock: () => Date;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** What the session offers the command: a line out, and the confirm prompt (throws when it cannot ask). */
|
|
69
|
+
export interface MemoryAdmitIo {
|
|
70
|
+
writeLine(text: string): void;
|
|
71
|
+
confirm(question: string): Promise<unknown>;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export type MemoryAdmitResult =
|
|
75
|
+
| { message: string }
|
|
76
|
+
| { refused: string }
|
|
77
|
+
| { admit: Confirmed[]; settings: MemorySettings; refusedQuestions?: string };
|
|
78
|
+
|
|
79
|
+
/** What the operator reads before deciding: the candidate's fields and the first lines of its body. */
|
|
80
|
+
function candidateNotice(c: StoredEntry): string {
|
|
81
|
+
const e = c.entry;
|
|
82
|
+
const lines = [`${e.id} (${e.type}, topic ${e.topic})`, ` title: ${e.title}`, ` applies when: ${e.appliesWhen}`,
|
|
83
|
+
` rationale: ${e.rationale}`];
|
|
84
|
+
if (e.correction !== undefined) lines.push(` correction: ${e.correction}`);
|
|
85
|
+
if (e.detectionSignal !== undefined) lines.push(` signal: ${e.detectionSignal}`);
|
|
86
|
+
if (e.supersedes.length > 0) lines.push(` supersedes: ${e.supersedes.join(", ")}`);
|
|
87
|
+
lines.push(` source: ${e.source}`, ` file: ${c.path}`);
|
|
88
|
+
const body = e.body.split("\n").filter((l) => l.trim() !== "").slice(0, SHOWN_BODY_LINES);
|
|
89
|
+
return [...lines, ...body.map((l) => ` | ${l}`)].join("\n");
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** No answer: the questions left are refused, the admissions already made - unasked or confirmed - still go. */
|
|
93
|
+
function headless(admit: Confirmed[], settings: MemorySettings, why: string): MemoryAdmitResult {
|
|
94
|
+
return admit.length === 0 ? { refused: why } : { admit, settings, refusedQuestions: why };
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export async function runMemoryAdmit(args: MemoryAdmitArgs, deps: MemoryAdmitDeps, io: MemoryAdmitIo): Promise<MemoryAdmitResult> {
|
|
98
|
+
const settings = await readMemorySettings(deps);
|
|
99
|
+
for (const warning of settings.warnings) io.writeLine(`warning: ${warning}`);
|
|
100
|
+
if (args.kind === "import") {
|
|
101
|
+
const outcome = await importAgentMemory(deps, settings);
|
|
102
|
+
return { message: importReport(outcome) };
|
|
103
|
+
}
|
|
104
|
+
const pending = await pendingCandidates(deps.files, settings.layout);
|
|
105
|
+
if (args.kind === "list") {
|
|
106
|
+
return { message: pending.length === 0 ? noPendingCandidate(settings.layout.candidates) : candidatesList(pending.map((c) => c.entry)).trimEnd() };
|
|
107
|
+
}
|
|
108
|
+
if (args.kind === "refuse") {
|
|
109
|
+
const outcome = await admitEntries({ ...deps, memory: { ingest: async () => { throw new Error(NO_INGESTION_ON_REFUSAL); } } },
|
|
110
|
+
settings, { admit: [], refuse: [{ id: args.id, ...(args.motif === undefined ? {} : { motif: args.motif }) }] });
|
|
111
|
+
return outcome.refused.length > 0 ? { message: admitReport(outcome) } : { refused: admitReport(outcome) };
|
|
112
|
+
}
|
|
113
|
+
const chosen: StoredEntry[] = [];
|
|
114
|
+
for (const id of args.ids) {
|
|
115
|
+
const hit = pending.find((c) => c.entry.id === id);
|
|
116
|
+
if (hit === undefined) io.writeLine(notPending(id));
|
|
117
|
+
else chosen.push(hit);
|
|
118
|
+
}
|
|
119
|
+
const asked = args.ids.length === 0 ? pending : chosen;
|
|
120
|
+
if (asked.length === 0) return { message: args.ids.length === 0 ? noPendingCandidate(settings.layout.candidates) : NOTHING_ADMITTED };
|
|
121
|
+
const admit: Confirmed[] = [];
|
|
122
|
+
const confirmed = (c: StoredEntry): Confirmed => ({ id: c.entry.id, sha1: sha1Hex(c.text) });
|
|
123
|
+
// The admissions that need no question first: a session that cannot prompt still applies them.
|
|
124
|
+
const unasked = asked.filter((c) => admissionProblem(c.entry) === undefined && !asksConfirmation(c.entry, settings.autoAdmitAudited));
|
|
125
|
+
for (const c of unasked) {
|
|
126
|
+
io.writeLine(candidateNotice(c));
|
|
127
|
+
io.writeLine(ADMITTED_UNASKED);
|
|
128
|
+
admit.push(confirmed(c));
|
|
129
|
+
}
|
|
130
|
+
let answered = false;
|
|
131
|
+
for (const c of asked.filter((x) => !unasked.includes(x))) {
|
|
132
|
+
io.writeLine(candidateNotice(c));
|
|
133
|
+
const problem = admissionProblem(c.entry);
|
|
134
|
+
if (problem !== undefined) { io.writeLine(` not admissible: ${problem}`); continue; }
|
|
135
|
+
let answer: unknown;
|
|
136
|
+
try {
|
|
137
|
+
answer = await io.confirm(admitQuestion(c.entry.id));
|
|
138
|
+
} catch {
|
|
139
|
+
answer = undefined;
|
|
140
|
+
}
|
|
141
|
+
// Every admission confirmed so far is kept: only the first question tells a session that cannot prompt.
|
|
142
|
+
if (typeof answer !== "boolean") return headless(admit, settings, answered ? stoppedAt(c.entry.id) : HEADLESS);
|
|
143
|
+
answered = true;
|
|
144
|
+
if (answer) admit.push(confirmed(c));
|
|
145
|
+
else io.writeLine(LEFT_AS_CANDIDATE);
|
|
146
|
+
}
|
|
147
|
+
return admit.length === 0 ? { message: NOTHING_ADMITTED } : { admit, settings };
|
|
148
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
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
|
+
import { FEEDBACK_RECORDED, FEEDBACK_USAGE } from "./messages.ts";
|
|
12
|
+
|
|
13
|
+
export interface MemoryDeps {
|
|
14
|
+
memory: MemoryStore;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** The admit arguments of a line typed `/memory admit …` or `/memory-admit …`; null when the line is not an admission. */
|
|
18
|
+
export function admitTokens(tokens: readonly string[], typed: string): string[] | null {
|
|
19
|
+
if (typed === "memory-admit") return [...tokens];
|
|
20
|
+
if (typed === "memory" && (tokens[0] ?? "").toLowerCase() === "admit") return tokens.slice(1);
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** `/feedback <text>`: a 'feedback' memory, the reply saying the agent replays it. */
|
|
25
|
+
async function runFeedback(tokens: string[], deps: MemoryDeps): Promise<CommandView> {
|
|
26
|
+
if (tokens.join(" ").trim() === "") return { text: FEEDBACK_USAGE };
|
|
27
|
+
await runMemory(["add", "feedback", ...tokens], deps);
|
|
28
|
+
return { text: FEEDBACK_RECORDED };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** `/memory [list|add|delete|get] …`, from the command's raw tokens; typed by its alias `feedback`, an add of a feedback. */
|
|
32
|
+
export async function runMemory(tokens: string[], deps: MemoryDeps, typed = "memory"): Promise<CommandView> {
|
|
33
|
+
if (typed === "feedback") return runFeedback(tokens, deps);
|
|
34
|
+
const { memory } = deps;
|
|
35
|
+
const parsed = parseMemoryArgs(tokens);
|
|
36
|
+
|
|
37
|
+
if (parsed.sub === "add") {
|
|
38
|
+
if (!parsed.content) return { text: "usage: /memory add <category> <content>" };
|
|
39
|
+
return { text: "added memory #" + (await memory.add(parsed.category, parsed.content)) };
|
|
40
|
+
}
|
|
41
|
+
if (parsed.sub === "delete") {
|
|
42
|
+
return { text: (await memory.remove(parsed.id)) ? "deleted #" + parsed.id : "not found: #" + parsed.id };
|
|
43
|
+
}
|
|
44
|
+
if (parsed.sub === "get") {
|
|
45
|
+
return { text: JSON.stringify((await memory.get(parsed.id)) ?? "not found") };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// list
|
|
49
|
+
const entries = await memory.list(parsed.category);
|
|
50
|
+
if (entries.length === 0) return { text: "(no memories)" };
|
|
51
|
+
return { table: entries.map((e) => ({ id: e.id, category: e.category, content: e.content })) };
|
|
52
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// The text the memory commands show the user (ADR 0026): /memory, /feedback and /memory-admit.
|
|
2
|
+
|
|
3
|
+
// /memory and /feedback
|
|
4
|
+
|
|
5
|
+
export const FEEDBACK_USAGE = "usage: /feedback <what should change or keep happening>";
|
|
6
|
+
export const FEEDBACK_RECORDED = "feedback recorded — the agent replays feedback memories on every /assistant turn.";
|
|
7
|
+
|
|
8
|
+
// /memory-admit
|
|
9
|
+
|
|
10
|
+
export const LIST_TAKES_NOTHING = "memory-admit: --list takes nothing else";
|
|
11
|
+
export const IMPORT_TAKES_NOTHING = "memory-admit: --import takes nothing else";
|
|
12
|
+
export const REFUSE_USAGE = "memory-admit: --refuse <id> [<motif>]: the id of a pending candidate";
|
|
13
|
+
export const motifTooLong = (max: number): string => `memory-admit: a motif of at most ${max} characters`;
|
|
14
|
+
export const unknownAdmitOption = (option: string): string =>
|
|
15
|
+
`memory-admit: unknown option '${option}' (--list, --refuse, --import)`;
|
|
16
|
+
export const notACandidateId = (token: string): string => `memory-admit: '${token}' is not a candidate id`;
|
|
17
|
+
|
|
18
|
+
export const HEADLESS =
|
|
19
|
+
"refused: /memory-admit asks before admitting and this session cannot prompt: no asked candidate was admitted. " +
|
|
20
|
+
"Run it in an interactive session (an audited candidate admits unasked when memory.autoAdmitAudited is true).";
|
|
21
|
+
|
|
22
|
+
/** A question cancelled after another was answered: the session can prompt, the person stopped. */
|
|
23
|
+
export const stoppedAt = (id: string): string =>
|
|
24
|
+
`refused: the question about ${id} got no answer: it and the candidates after it stay candidates. Run /memory-admit again for them.`;
|
|
25
|
+
|
|
26
|
+
export const noPendingCandidate = (dir: string): string => `No pending candidate in ${dir}.`;
|
|
27
|
+
export const NO_INGESTION_ON_REFUSAL = "no ingestion on a refusal";
|
|
28
|
+
export const notPending = (id: string): string => `${id}: not a pending candidate (/memory-admit --list)`;
|
|
29
|
+
export const NOTHING_ADMITTED = "Nothing admitted.";
|
|
30
|
+
export const ADMITTED_UNASKED = " admitted without a question (audited, memory.autoAdmitAudited is true)";
|
|
31
|
+
export const admitQuestion = (id: string): string => `Admit ${id} into the shared memory?`;
|
|
32
|
+
export const LEFT_AS_CANDIDATE = " left as a candidate";
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// The text the shared helpers of commands/_lib/ show the user (ADR 0026): the warnings of a launch, the refusals of a
|
|
2
|
+
// dev step. Read by dispatch.ts, dev-step.ts and args.ts.
|
|
3
|
+
|
|
4
|
+
// dispatch.ts: the main loop's launch
|
|
5
|
+
export const extraToolMissing = (name: string) =>
|
|
6
|
+
`extra tool '${name}' is not registered by the host and is left out ` +
|
|
7
|
+
"(its MCP server did not connect, its plugin did not load, or the name is mistyped)";
|
|
8
|
+
export const extraToolIgnored = (key: string, entry: string, rule: string) => `${key}: '${entry}' is ignored (${rule})`;
|
|
9
|
+
export const extraToolsUnreadable = (key: string, reason: string) =>
|
|
10
|
+
`${key} could not be read (${reason}): no extra tool this turn`;
|
|
11
|
+
export const ruleOverridden = (rule: string) =>
|
|
12
|
+
`permission rule '${rule}' is left out of the gate: a built-in rule denies the same calls (the shared memory's candidates and entries, the user configuration, paths.deny)`;
|
|
13
|
+
export const ruleDormant = (rule: string, key: string) =>
|
|
14
|
+
`permission rule '${rule}' is dormant: ${key} does not list its tool, the gate does not get it`;
|
|
15
|
+
export const invalidPermissionEntries = (count: number) =>
|
|
16
|
+
`${count} stored permission entr(ies) are not rules and were ignored`;
|
|
17
|
+
export const NO_SESSION_RULES = "the host keeps no session rules: the gate decides each call from the mode alone";
|
|
18
|
+
export const voiceReplyUnreadable = (key: string, reason: string) =>
|
|
19
|
+
`${key} could not be read (${reason}): the answer is not read aloud this turn`;
|
|
20
|
+
export const voiceReplyNoSpeakTool = (key: string, tool: string) =>
|
|
21
|
+
`${key} is on but the host registers no '${tool}': the answer is not read aloud ` +
|
|
22
|
+
"(start orkeon-code with ORKEON_CODE_AUDIO_DIR and ORKEON_CODE_VOICE=1)";
|
|
23
|
+
|
|
24
|
+
// dev-step.ts: the start of a dev step
|
|
25
|
+
export const stepRulesNotInGate = (command: string) =>
|
|
26
|
+
`warning: the host keeps no session rules: /${command}'s rule sets are not in the host's gate, the crew's callback alone checks them.`;
|
|
27
|
+
export const sessionRuleLeftOut = (rule: string, command: string) =>
|
|
28
|
+
`warning: the session's rule '${rule}' is left out of the gate during /${command}: the step denies the same calls.`;
|
|
29
|
+
export const modeUnreadableRefusal = (command: string, writes: string) =>
|
|
30
|
+
`✗ refused: the session mode could not be read, and /${command} ${writes}: run it again`;
|
|
31
|
+
export const modeUnknownRefusal = (mode: string, command: string, writes: string) =>
|
|
32
|
+
`✗ refused: the session mode ${mode} is not one Orkeon Code knows, and /${command} ${writes}: /mode default, then run it again`;
|
|
33
|
+
export const modeReadOnlyRefusal = (mode: string, command: string, writes: string) =>
|
|
34
|
+
`✗ refused: the session mode ${mode} is read-only, and /${command} ${writes}: /mode default, then run it again`;
|
|
35
|
+
export const batchNotRecorded = (reason: string) =>
|
|
36
|
+
`warning: the batch in progress could not be recorded (${reason}): a compaction will write no state file for it.`;
|
|
37
|
+
|
|
38
|
+
// args.ts: /debug-tool-call
|
|
39
|
+
export const DEBUG_TOOL_CALL_USAGE = "usage: /debug-tool-call <tool_name> [{\"arg\": \"value\"}]";
|
|
40
|
+
export const notAToolName = (tool: string) => `'${tool}' is not a tool name (expected snake_case, e.g. file_read)`;
|
|
41
|
+
export const argumentsNotJson = (reason: string, payload: string) =>
|
|
42
|
+
`arguments are not valid JSON (${reason}): ${payload}`;
|
|
43
|
+
export const argumentsNotObject = (got: string) => `arguments must be a JSON OBJECT, got ${got}`;
|
|
44
|
+
|
|
45
|
+
// Shared by several command groups
|
|
46
|
+
export const failedLine = (reason: string) => `✗ ${reason}`;
|
|
47
|
+
export const unknownOption = (word: string) => `unknown option ${word}`;
|
|
48
|
+
export const markedDefault = (value: number | string) => `${value} (default)`;
|