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,38 @@
|
|
|
1
|
+
// Pre-compaction memory extraction: the model lists the durable facts of the
|
|
2
|
+
// conversation, and each one goes to the typed-memory store, so that nothing worth
|
|
3
|
+
// keeping is lost to the summary. What the store already holds is listed in the
|
|
4
|
+
// prompt by id, the newest first (the list is capped), so a fact is not saved twice
|
|
5
|
+
// and a fact that makes a known entry out of date replaces it in place; today's date
|
|
6
|
+
// is given, so a relative date is saved as an absolute one.
|
|
7
|
+
|
|
8
|
+
import type { Llm, MemoryEntry, MemoryStore } from "../ports.ts";
|
|
9
|
+
import {
|
|
10
|
+
buildMemoryExtractionPrompt,
|
|
11
|
+
MEMORY_EXTRACTION_SCHEMA,
|
|
12
|
+
sanitizeExtractedMemories,
|
|
13
|
+
type ExtractedMemory,
|
|
14
|
+
} from "../../domain/compaction.ts";
|
|
15
|
+
|
|
16
|
+
/** Extract + persist durable memories; failures degrade to an empty list. `today` is YYYY-MM-DD. */
|
|
17
|
+
export async function extractMemories(
|
|
18
|
+
llm: Pick<Llm, "extract">,
|
|
19
|
+
memory: Pick<MemoryStore, "add" | "list" | "replace">,
|
|
20
|
+
transcript: string,
|
|
21
|
+
today?: string,
|
|
22
|
+
): Promise<ExtractedMemory[]> {
|
|
23
|
+
try {
|
|
24
|
+
const known = await memory.list(undefined, { newestFirst: true }).catch(() => [] as MemoryEntry[]);
|
|
25
|
+
const raw = await llm.extract(buildMemoryExtractionPrompt(transcript, known, today), MEMORY_EXTRACTION_SCHEMA);
|
|
26
|
+
const items = sanitizeExtractedMemories(raw, known);
|
|
27
|
+
for (const it of items) {
|
|
28
|
+
try {
|
|
29
|
+
// A stale entry is replaced in place; a replacement the store refuses is added as a new entry.
|
|
30
|
+
if (it.replaces !== undefined && await memory.replace(it.replaces, it.content).catch(() => false)) continue;
|
|
31
|
+
await memory.add(it.category, it.content);
|
|
32
|
+
} catch { /* store unavailable → memory only lives in the recap message */ }
|
|
33
|
+
}
|
|
34
|
+
return items;
|
|
35
|
+
} catch {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// After a full synthesis, the compaction re-injects the working context the
|
|
2
|
+
// summary would lose: the files the conversation touched last and the attached
|
|
3
|
+
// skills, each under its own token budget (chars/4 heuristic).
|
|
4
|
+
|
|
5
|
+
import type { Files, SessionStore } from "../ports.ts";
|
|
6
|
+
import type { SessionMsg } from "../../domain/types.ts";
|
|
7
|
+
import {
|
|
8
|
+
buildRestoredFileMessage,
|
|
9
|
+
buildRestoredFileNotice,
|
|
10
|
+
buildRestoredSkillMessage,
|
|
11
|
+
extractRecentFilePaths,
|
|
12
|
+
} from "../../domain/compaction.ts";
|
|
13
|
+
import {
|
|
14
|
+
CHARS_PER_TOKEN,
|
|
15
|
+
POST_COMPACT_MAX_FILES_TO_RESTORE,
|
|
16
|
+
POST_COMPACT_PER_FILE_TOKENS,
|
|
17
|
+
POST_COMPACT_TOKEN_BUDGET,
|
|
18
|
+
POST_COMPACT_SKILLS_TOKEN_BUDGET,
|
|
19
|
+
POST_COMPACT_PER_SKILL_TOKENS,
|
|
20
|
+
} from "../../domain/compaction-thresholds.ts";
|
|
21
|
+
import { readAttachedSkills } from "../attached-skills.ts";
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Read back up to POST_COMPACT_MAX_FILES_TO_RESTORE recently-mentioned files
|
|
25
|
+
* (recency order) under the restore budget. A file larger than the per-file cap,
|
|
26
|
+
* or than what the budget has left, comes back as its path with a note, never as
|
|
27
|
+
* a cut copy: a cut copy reads as the whole file and could feed a whole-file
|
|
28
|
+
* write. Unreadable/gone paths are skipped silently — the harvest regex is
|
|
29
|
+
* conservative but the filesystem stays the arbiter.
|
|
30
|
+
*/
|
|
31
|
+
export async function restoreRecentFiles(
|
|
32
|
+
files: Pick<Files, "read">,
|
|
33
|
+
preCompaction: SessionMsg[],
|
|
34
|
+
): Promise<SessionMsg[]> {
|
|
35
|
+
const candidates = extractRecentFilePaths(preCompaction, POST_COMPACT_MAX_FILES_TO_RESTORE * 4);
|
|
36
|
+
const out: SessionMsg[] = [];
|
|
37
|
+
let budgetChars = POST_COMPACT_TOKEN_BUDGET * CHARS_PER_TOKEN;
|
|
38
|
+
const perFileChars = POST_COMPACT_PER_FILE_TOKENS * CHARS_PER_TOKEN;
|
|
39
|
+
for (const path of candidates) {
|
|
40
|
+
if (out.length >= POST_COMPACT_MAX_FILES_TO_RESTORE) break;
|
|
41
|
+
try {
|
|
42
|
+
const content = await files.read(path);
|
|
43
|
+
if (content.length === 0) continue;
|
|
44
|
+
if (content.length > Math.min(perFileChars, budgetChars)) {
|
|
45
|
+
out.push(buildRestoredFileNotice(path));
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
budgetChars -= content.length;
|
|
49
|
+
out.push(buildRestoredFileMessage(path, content));
|
|
50
|
+
} catch { /* not a real/readable file → skip */ }
|
|
51
|
+
}
|
|
52
|
+
return out;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Read back every attached skill under POST_COMPACT_SKILLS_TOKEN_BUDGET, each
|
|
57
|
+
* capped like the skills block of a turn.
|
|
58
|
+
*
|
|
59
|
+
* Reads the registry from the session bag rather than taking it as an argument:
|
|
60
|
+
* this runs inside the compaction, which has no caller able to supply it. A gone,
|
|
61
|
+
* unreadable or blank skill is skipped (readAttachedSkills) — a
|
|
62
|
+
* detached-then-deleted playbook must not fail a compaction.
|
|
63
|
+
*/
|
|
64
|
+
export async function restoreAttachedSkills(
|
|
65
|
+
session: Pick<SessionStore, "readState">,
|
|
66
|
+
files: Pick<Files, "read">,
|
|
67
|
+
): Promise<SessionMsg[]> {
|
|
68
|
+
const out: SessionMsg[] = [];
|
|
69
|
+
let budgetChars = POST_COMPACT_SKILLS_TOKEN_BUDGET * CHARS_PER_TOKEN;
|
|
70
|
+
const perSkillChars = POST_COMPACT_PER_SKILL_TOKENS * CHARS_PER_TOKEN;
|
|
71
|
+
for (const { path, content } of await readAttachedSkills(session, files)) {
|
|
72
|
+
if (budgetChars <= 0) break;
|
|
73
|
+
const capped = content.slice(0, Math.min(perSkillChars, budgetChars));
|
|
74
|
+
budgetChars -= capped.length;
|
|
75
|
+
out.push(buildRestoredSkillMessage(path, capped));
|
|
76
|
+
}
|
|
77
|
+
return out;
|
|
78
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
// Two-layer /config store (B-6): a VFS settings file that survives everything,
|
|
2
|
+
// and the session state bag that overrides it until /clear. Under both, the user
|
|
3
|
+
// settings the launcher mounts read-only (LI-6): the project file widens nothing past them.
|
|
4
|
+
//
|
|
5
|
+
// The original persists `/config` to a settings file (baseline 04 §/config);
|
|
6
|
+
// The first version had only the session bag, so nothing set with `/config` outlived a
|
|
7
|
+
// `/clear` — including `permissions.fallback`, whose entire purpose is to
|
|
8
|
+
// state a durable posture.
|
|
9
|
+
//
|
|
10
|
+
// Built over the Files and SessionStore ports (createConfigStore); the instance
|
|
11
|
+
// wired to the runtime is orkeonConfigStore() in shared/infrastructure/orkeon/.
|
|
12
|
+
|
|
13
|
+
import type { Files, SessionStore } from "./ports.ts";
|
|
14
|
+
import { layerConfig, resolveConfigEntry, unknownStoredKeys, nestedConfigKeys } from "../domain/config-schema.ts";
|
|
15
|
+
import type { ConfigResolution } from "../domain/config-schema.ts";
|
|
16
|
+
import { CONFIG_MAP_STATE_KEY } from "../domain/session-keys.ts";
|
|
17
|
+
import { readJsonFile, writeJsonFile } from "./json-file.ts";
|
|
18
|
+
import { readJsonObject, writeJson } from "./session-state.ts";
|
|
19
|
+
import { WORKSPACE } from "../domain/vfs.ts";
|
|
20
|
+
|
|
21
|
+
/** The persisted settings file. Under /workspace so it lives with the repo. */
|
|
22
|
+
export const CONFIG_FILE_PATH = `${WORKSPACE}/.orkeon/config.json`;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The user's settings: the `orkeonCode` block of the user settings file, which the
|
|
26
|
+
* launcher writes at each start to a folder it mounts here read-only. Outside the
|
|
27
|
+
* project, so a cloned repository cannot ship it; the project file widens nothing
|
|
28
|
+
* past it (QL-06, config-schema.ts layerConfig). A script reads neither the host
|
|
29
|
+
* settings nor the environment (V-04), so the launcher hands the block over as a file.
|
|
30
|
+
*/
|
|
31
|
+
export const USER_CONFIG_FILE_PATH = "/user-config/config.json";
|
|
32
|
+
|
|
33
|
+
function asMap(raw: unknown): Record<string, unknown> {
|
|
34
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return {};
|
|
35
|
+
return raw as Record<string, unknown>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface ConfigView {
|
|
39
|
+
entries: ConfigResolution[];
|
|
40
|
+
/** Keys stored by the pre-schema free-form map; reported, never deleted. */
|
|
41
|
+
unknown: string[];
|
|
42
|
+
/** Known keys the project or user file holds nested: nothing reads them (nestedConfigKeys). */
|
|
43
|
+
nested: string[];
|
|
44
|
+
fileMalformed: boolean;
|
|
45
|
+
/** The user settings file could not be read or parsed: no user setting applies. */
|
|
46
|
+
userMalformed: boolean;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface ConfigStore {
|
|
50
|
+
/**
|
|
51
|
+
* Reads the settings file. An absent file is the normal first state; a malformed
|
|
52
|
+
* one yields `{}` and a flag, because overwriting a file we could not parse would
|
|
53
|
+
* destroy whatever it did contain.
|
|
54
|
+
*/
|
|
55
|
+
readFile(): Promise<{ map: Record<string, unknown>; malformed: boolean }>;
|
|
56
|
+
/** Reads the user settings file, read-only: a failed read is an absent file, content
|
|
57
|
+
* that does not parse is malformed. */
|
|
58
|
+
readUserFile(): Promise<{ map: Record<string, unknown>; malformed: boolean }>;
|
|
59
|
+
/** Writes the settings file (pretty-printed — a human edits this by hand too). */
|
|
60
|
+
writeFile(map: Record<string, unknown>): Promise<void>;
|
|
61
|
+
/** Reads the session override map. */
|
|
62
|
+
readSession(): Promise<Record<string, unknown>>;
|
|
63
|
+
/** Writes the session override map. */
|
|
64
|
+
writeSession(map: Record<string, unknown>): Promise<void>;
|
|
65
|
+
/** The effective configuration: user settings, overridden by the project file
|
|
66
|
+
* (which widens nothing past them), overridden by the session. */
|
|
67
|
+
readView(): Promise<ConfigView>;
|
|
68
|
+
/** The effective value of one key, layered. */
|
|
69
|
+
readValue(key: string): Promise<ConfigResolution>;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function createConfigStore(deps: {
|
|
73
|
+
files: Files;
|
|
74
|
+
session: Pick<SessionStore, "readState" | "writeState">;
|
|
75
|
+
}): ConfigStore {
|
|
76
|
+
const { files, session } = deps;
|
|
77
|
+
|
|
78
|
+
async function readMap(path: string): Promise<{ map: Record<string, unknown>; malformed: boolean }> {
|
|
79
|
+
const { value, malformed } = await readJsonFile(files, path);
|
|
80
|
+
return { map: asMap(value), malformed };
|
|
81
|
+
}
|
|
82
|
+
const readFile = () => readMap(CONFIG_FILE_PATH);
|
|
83
|
+
// The user file is the launcher's, mounted read-only: nothing here ever writes it, so a
|
|
84
|
+
// read that fails (no mount, an older launcher) is the absent layer, not data to guard.
|
|
85
|
+
async function readUserFile(): Promise<{ map: Record<string, unknown>; malformed: boolean }> {
|
|
86
|
+
let content: string;
|
|
87
|
+
try {
|
|
88
|
+
content = (await files.read(USER_CONFIG_FILE_PATH)).trim();
|
|
89
|
+
} catch {
|
|
90
|
+
return { map: {}, malformed: false };
|
|
91
|
+
}
|
|
92
|
+
if (content.length === 0) return { map: {}, malformed: false };
|
|
93
|
+
try {
|
|
94
|
+
return { map: asMap(JSON.parse(content)), malformed: false };
|
|
95
|
+
} catch {
|
|
96
|
+
return { map: {}, malformed: true };
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const readSession = (): Promise<Record<string, unknown>> => readJsonObject(session, CONFIG_MAP_STATE_KEY);
|
|
101
|
+
|
|
102
|
+
return {
|
|
103
|
+
readFile,
|
|
104
|
+
readUserFile,
|
|
105
|
+
writeFile: (map) => writeJsonFile(files, CONFIG_FILE_PATH, map),
|
|
106
|
+
readSession,
|
|
107
|
+
writeSession: (map) => writeJson(session, CONFIG_MAP_STATE_KEY, map),
|
|
108
|
+
async readView() {
|
|
109
|
+
const [{ map: file, malformed }, overrides, user] = await Promise.all([readFile(), readSession(), readUserFile()]);
|
|
110
|
+
return {
|
|
111
|
+
entries: layerConfig(file, overrides, user.map),
|
|
112
|
+
unknown: [...new Set([file, overrides, user.map].flatMap(unknownStoredKeys))].sort(),
|
|
113
|
+
nested: [...new Set([file, user.map].flatMap(nestedConfigKeys))].sort(),
|
|
114
|
+
fileMalformed: malformed,
|
|
115
|
+
userMalformed: user.malformed,
|
|
116
|
+
};
|
|
117
|
+
},
|
|
118
|
+
async readValue(key) {
|
|
119
|
+
const [{ map: file }, overrides, { map: user }] = await Promise.all([readFile(), readSession(), readUserFile()]);
|
|
120
|
+
return resolveConfigEntry(key, file, overrides, user);
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// What the code already says about a feature or a change, looked up by code before a spec or a brief is drafted:
|
|
2
|
+
// the code index searched on a few phrases of the request, each hit kept once and located, at most 30 rows of
|
|
3
|
+
// `path:line — name`. A fact the code answers is then never asked. It builds the index when it holds no root and
|
|
4
|
+
// writes nothing else; a failing index is a warning and an empty inventory, never a stop.
|
|
5
|
+
import type { CodeIndex } from "../ports.ts";
|
|
6
|
+
import { WORKSPACE } from "../../domain/vfs.ts";
|
|
7
|
+
import { indexCacheNote } from "../../domain/code-intel-contract.ts";
|
|
8
|
+
|
|
9
|
+
export interface BriefInventoryEntry { path: string; line: number; name: string }
|
|
10
|
+
export interface BriefInventory {
|
|
11
|
+
entries: BriefInventoryEntry[];
|
|
12
|
+
/** The phrases searched, in order. */
|
|
13
|
+
phrases: string[];
|
|
14
|
+
calls: number;
|
|
15
|
+
warnings: string[];
|
|
16
|
+
/** What the index cache did when this inventory built the index (Orkeon #244); absent otherwise. */
|
|
17
|
+
cache?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface BriefInventoryRequest {
|
|
20
|
+
phrases: readonly string[];
|
|
21
|
+
/** Relative path prefixes never shown: the work folder, `.claude/`, the build outputs. */
|
|
22
|
+
excluded: readonly string[];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const BRIEF_INVENTORY_CAPS = { phrases: 6, phraseChars: 160, topK: 8, entries: 30 } as const;
|
|
26
|
+
const TOP = `${WORKSPACE}/`;
|
|
27
|
+
const ALWAYS_EXCLUDED = [".claude/", ".git/", "node_modules/"];
|
|
28
|
+
|
|
29
|
+
const firstLine = (e: unknown): string => (e instanceof Error ? e.message : String(e)).split("\n")[0];
|
|
30
|
+
const relative = (path: string): string => (path.startsWith(TOP) ? path.slice(TOP.length) : path.replace(/^\/+/, ""));
|
|
31
|
+
const pathPart = (fqn: string): string => {
|
|
32
|
+
const cut = fqn.indexOf("::");
|
|
33
|
+
return cut >= 0 ? fqn.slice(0, cut) : fqn;
|
|
34
|
+
};
|
|
35
|
+
const nameOf = (fqn: string): string => {
|
|
36
|
+
const cut = fqn.indexOf("::");
|
|
37
|
+
return cut >= 0 ? fqn.slice(cut + 2) : fqn.slice(fqn.lastIndexOf("/") + 1);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/** The phrases to search for a request: the code's words, then its first lines or sentences, distinct. */
|
|
41
|
+
export function briefPhrases(code: string, text: string): string[] {
|
|
42
|
+
const out: string[] = [];
|
|
43
|
+
const add = (phrase: string): void => {
|
|
44
|
+
const p = phrase.replace(/[#>*`_|]/g, " ").replace(/\s+/g, " ").trim().slice(0, BRIEF_INVENTORY_CAPS.phraseChars);
|
|
45
|
+
if (p.length >= 3 && !out.some((o) => o.toLowerCase() === p.toLowerCase())) out.push(p);
|
|
46
|
+
};
|
|
47
|
+
add(code.replace(/-/g, " "));
|
|
48
|
+
for (const piece of text.split(/\r?\n|(?<=[.!?])\s+/)) {
|
|
49
|
+
if (out.length >= BRIEF_INVENTORY_CAPS.phrases) break;
|
|
50
|
+
add(piece);
|
|
51
|
+
}
|
|
52
|
+
return out.slice(0, BRIEF_INVENTORY_CAPS.phrases);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function excludedBy(prefixes: readonly string[]): (path: string) => boolean {
|
|
56
|
+
const all = [...ALWAYS_EXCLUDED, ...prefixes.map((p) => (p.endsWith("/") ? p : `${p}/`))];
|
|
57
|
+
return (path) => all.some((p) => path.startsWith(p));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export async function briefInventory(index: CodeIndex, request: BriefInventoryRequest): Promise<BriefInventory> {
|
|
61
|
+
const out: BriefInventory = { entries: [], phrases: [...request.phrases], calls: 0, warnings: [] };
|
|
62
|
+
try {
|
|
63
|
+
out.calls++;
|
|
64
|
+
if ((await index.rootCount()) === 0) {
|
|
65
|
+
out.calls++;
|
|
66
|
+
const note = indexCacheNote(await index.index(WORKSPACE));
|
|
67
|
+
if (note !== "") out.cache = note;
|
|
68
|
+
}
|
|
69
|
+
} catch (e) {
|
|
70
|
+
out.warnings.push(`the code index is not available (${firstLine(e)}): the draft has no inventory`);
|
|
71
|
+
return out;
|
|
72
|
+
}
|
|
73
|
+
const excluded = excludedBy(request.excluded);
|
|
74
|
+
const seen = new Set<string>();
|
|
75
|
+
for (const phrase of request.phrases) {
|
|
76
|
+
if (out.entries.length >= BRIEF_INVENTORY_CAPS.entries) break;
|
|
77
|
+
let hits;
|
|
78
|
+
try {
|
|
79
|
+
out.calls++;
|
|
80
|
+
hits = await index.search(phrase, BRIEF_INVENTORY_CAPS.topK);
|
|
81
|
+
} catch (e) {
|
|
82
|
+
out.warnings.push(`search failed for '${phrase}': ${firstLine(e)}`);
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
for (const hit of hits) {
|
|
86
|
+
if (out.entries.length >= BRIEF_INVENTORY_CAPS.entries) break;
|
|
87
|
+
const path = relative(pathPart(hit.fqn));
|
|
88
|
+
if (seen.has(hit.fqn) || excluded(path)) continue;
|
|
89
|
+
seen.add(hit.fqn);
|
|
90
|
+
let line = 0;
|
|
91
|
+
try {
|
|
92
|
+
out.calls++;
|
|
93
|
+
line = (await index.symbolSource(hit.fqn)).startLine;
|
|
94
|
+
} catch {
|
|
95
|
+
line = 0;
|
|
96
|
+
}
|
|
97
|
+
out.entries.push({ path, line, name: nameOf(hit.fqn) });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return out;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** The inventory as the prompt shows it: one `path:line — name` per row, or a line saying it is empty. */
|
|
104
|
+
/** The inventory's line of a draft's end message: its entries, its index calls, what the index cache did. */
|
|
105
|
+
export function briefInventoryLine(inventory: BriefInventory): string {
|
|
106
|
+
const cache = inventory.cache === undefined ? "" : `; ${inventory.cache}`;
|
|
107
|
+
return `inventory: ${inventory.entries.length} entries (${inventory.calls} index calls${cache})`;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export function renderBriefInventory(inventory: BriefInventory): string {
|
|
111
|
+
if (inventory.entries.length === 0) return "(the index found nothing for this request)";
|
|
112
|
+
return inventory.entries.map((e) => `- ${e.path}${e.line > 0 ? `:${e.line}` : ""} — ${e.name}`).join("\n");
|
|
113
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// The close of a dev batch (04 L-6, R-32): git's identity, a commit of the files
|
|
2
|
+
// the batch touched (never the work folder, even when one is named), the push,
|
|
3
|
+
// and the pull request handed over. It shares the git close with /commit
|
|
4
|
+
// (../git/commit-files.ts) and never calls /commit. A crew cannot
|
|
5
|
+
// ask: the pull request is opened only under `openPr` (--pr or dev.prAuto, Q-10),
|
|
6
|
+
// through the opener when one is wired, else its command is handed over (04 § 7).
|
|
7
|
+
// The opener over the github tool is ../git/open-pull-request.ts, which the
|
|
8
|
+
// dev-implement crew wires with `asked: false`: only an allow rule on github, or
|
|
9
|
+
// bypassPermissions, opens it. Its caller is that crew's close
|
|
10
|
+
// (crews/dev-implement/application/close.ts).
|
|
11
|
+
|
|
12
|
+
import type { Files, Shell } from "../ports.ts";
|
|
13
|
+
import type { PrSummary } from "../../domain/git/close.ts";
|
|
14
|
+
import { GIT_STATUS_COMMAND, gitPushCommand, identityStop, selectCommitFiles } from "../../domain/git/close.ts";
|
|
15
|
+
import type { PermissionRule } from "../../domain/agent-policy/permission.ts";
|
|
16
|
+
import { ruleDecision } from "../../domain/agent-policy/permission.ts";
|
|
17
|
+
import type { PullRequestOpener } from "../git/commit-files.ts";
|
|
18
|
+
import {
|
|
19
|
+
commitFiles, defaultBranch, gitReason, handOverPullRequest, pushBranch, readIdentity, runGit,
|
|
20
|
+
} from "../git/commit-files.ts";
|
|
21
|
+
import { WORKSPACE } from "../../domain/vfs.ts";
|
|
22
|
+
|
|
23
|
+
export interface CloseBatchRequest {
|
|
24
|
+
/** The files the batch touched, from its sheet and its roles' diffs. */
|
|
25
|
+
touched: string[];
|
|
26
|
+
message: string;
|
|
27
|
+
branch: string;
|
|
28
|
+
work: { folder: string; vfsPath: string | null };
|
|
29
|
+
/** False in a batch worktree: the orchestrator merges and pushes once (D79). */
|
|
30
|
+
push: boolean;
|
|
31
|
+
/** The session's rules at the launch: a deny on the push keeps the commit local. */
|
|
32
|
+
rules?: readonly PermissionRule[];
|
|
33
|
+
openPr: boolean;
|
|
34
|
+
summary: PrSummary;
|
|
35
|
+
/** How the step is re-run, for the identity hand-over. */
|
|
36
|
+
rerun: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface CloseBatchResult {
|
|
40
|
+
committed: boolean;
|
|
41
|
+
hash?: string;
|
|
42
|
+
lines: string[];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export async function closeBatch(
|
|
46
|
+
deps: { shell: Pick<Shell, "run">; files: Pick<Files, "write">; opener?: PullRequestOpener },
|
|
47
|
+
req: CloseBatchRequest,
|
|
48
|
+
): Promise<CloseBatchResult> {
|
|
49
|
+
const identity = await readIdentity(deps.shell);
|
|
50
|
+
if (!identity.ok) return { committed: false, lines: [identityStop(identity.detail, req.rerun)] };
|
|
51
|
+
|
|
52
|
+
const status = await runGit(deps.shell, GIT_STATUS_COMMAND);
|
|
53
|
+
if (status.exitCode !== 0) return { committed: false, lines: [`✗ git status failed: ${gitReason(status)}`] };
|
|
54
|
+
const selection = selectCommitFiles({ status: status.stdout, workFolder: req.work.folder, named: req.touched });
|
|
55
|
+
const notes: string[] = [];
|
|
56
|
+
if (selection.inWorkFolder.length > 0) notes.push(`left out (the work folder is never committed): ${selection.inWorkFolder.join(", ")}`);
|
|
57
|
+
if (selection.unchanged.length > 0) notes.push(`no change to commit: ${selection.unchanged.join(", ")}`);
|
|
58
|
+
if (selection.unsafe.length > 0) {
|
|
59
|
+
return { committed: false, lines: [...notes, `✗ not committed: ${selection.unsafe.join(", ")} cannot go through the shell; commit by hand`] };
|
|
60
|
+
}
|
|
61
|
+
if (selection.files.length === 0) return { committed: false, lines: [...notes, "✗ nothing to commit"] };
|
|
62
|
+
|
|
63
|
+
const commit = await commitFiles(deps, { files: selection.files, status: status.stdout, message: req.message });
|
|
64
|
+
if (!commit.ok) return { committed: false, lines: [...notes, `✗ ${commit.line}`] };
|
|
65
|
+
const lines = [...notes, `✓ committed ${commit.hash} on ${req.branch}: ${selection.files.length} file(s)`];
|
|
66
|
+
if (commit.note !== undefined) lines.push(`⚠ ${commit.note}`);
|
|
67
|
+
if (!req.push) return { committed: true, hash: commit.hash, lines };
|
|
68
|
+
const pushCommand = gitPushCommand(req.branch);
|
|
69
|
+
if (req.rules !== undefined && ruleDecision(req.rules, "shell_command", { command: pushCommand, working_directory: WORKSPACE }) === "deny") {
|
|
70
|
+
lines.push(`✗ not pushed: a session rule denies '${pushCommand}'; the commit stays local`);
|
|
71
|
+
return { committed: true, hash: commit.hash, lines };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const pushed = await pushBranch(deps.shell, req.branch);
|
|
75
|
+
lines.push(pushed.ok ? `✓ pushed ${req.branch} to origin` : `✗ ${pushed.line}`);
|
|
76
|
+
const base = await defaultBranch(deps.shell);
|
|
77
|
+
if (base !== null && base === req.branch) return { committed: true, hash: commit.hash, lines };
|
|
78
|
+
lines.push(...await handOverPullRequest(deps, {
|
|
79
|
+
work: req.work, branch: req.branch, base, title: req.message.split("\n")[0], pushed: pushed.ok, open: req.openPr,
|
|
80
|
+
summary: req.summary,
|
|
81
|
+
}));
|
|
82
|
+
return { committed: true, hash: commit.hash, lines };
|
|
83
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// Finds the repository pack of the checkout: `.orkeon/repo.yaml` first, else the first
|
|
2
|
+
// `repo-*` pack the harness deployed under `.claude/harness/packs/`, in sorted order. The
|
|
3
|
+
// first file that exists decides: one that cannot be read or does not parse gives a
|
|
4
|
+
// warning and no pack, and no other file is tried after it.
|
|
5
|
+
import type { Files } from "../ports.ts";
|
|
6
|
+
import { parseRepoPack } from "../../domain/dev/repo-pack.ts";
|
|
7
|
+
import type { RepoPack, RepoPackIssue } from "../../domain/dev/repo-pack.ts";
|
|
8
|
+
import { formatYamlError } from "../../domain/dev/yaml-subset.ts";
|
|
9
|
+
import { WORKSPACE, workspaceRelative } from "../../domain/vfs.ts";
|
|
10
|
+
|
|
11
|
+
export const ORKEON_PACK_PATH = `${WORKSPACE}/.orkeon/repo.yaml`;
|
|
12
|
+
export const HARNESS_PACKS_DIR = `${WORKSPACE}/.claude/harness/packs`;
|
|
13
|
+
|
|
14
|
+
export interface FoundPack {
|
|
15
|
+
path: string; // VFS path read
|
|
16
|
+
shown: string; // path without "/workspace/", e.g. ".orkeon/repo.yaml"
|
|
17
|
+
origin: "orkeon" | "harness";
|
|
18
|
+
pack: RepoPack;
|
|
19
|
+
issues: RepoPackIssue[];
|
|
20
|
+
}
|
|
21
|
+
export interface PackLookup { found: FoundPack | null; warnings: string[] }
|
|
22
|
+
|
|
23
|
+
const LIST_CAP = 200;
|
|
24
|
+
|
|
25
|
+
const messageOf = (e: unknown): string => (e instanceof Error ? e.message : String(e));
|
|
26
|
+
const isNotFound = (e: unknown): boolean => /not found/i.test(messageOf(e));
|
|
27
|
+
const shownOf = (path: string): string => workspaceRelative(path);
|
|
28
|
+
|
|
29
|
+
type Attempt = { kind: "absent" } | { kind: "failed"; error: unknown } | { kind: "read"; text: string };
|
|
30
|
+
|
|
31
|
+
async function attempt(files: Pick<Files, "read">, path: string): Promise<Attempt> {
|
|
32
|
+
try {
|
|
33
|
+
return { kind: "read", text: await files.read(path) };
|
|
34
|
+
} catch (e) {
|
|
35
|
+
return isNotFound(e) ? { kind: "absent" } : { kind: "failed", error: e };
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function decide(path: string, origin: FoundPack["origin"], a: Exclude<Attempt, { kind: "absent" }>, warnings: string[]): PackLookup {
|
|
40
|
+
const shown = shownOf(path);
|
|
41
|
+
if (a.kind === "failed") {
|
|
42
|
+
const first = messageOf(a.error).split("\n")[0];
|
|
43
|
+
warnings.push(`${shown} cannot be read (${first}): no repository pack is used`);
|
|
44
|
+
return { found: null, warnings };
|
|
45
|
+
}
|
|
46
|
+
const parsed = parseRepoPack(a.text);
|
|
47
|
+
if (!parsed.ok) {
|
|
48
|
+
warnings.push(`${formatYamlError(shown, parsed.error)}: the repository pack is ignored`);
|
|
49
|
+
return { found: null, warnings };
|
|
50
|
+
}
|
|
51
|
+
for (const issue of parsed.issues) warnings.push(`${shown}: ${issue.key}: ${issue.message}`);
|
|
52
|
+
return { found: { path, shown, origin, pack: parsed.pack, issues: parsed.issues }, warnings };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export async function findRepoPack(files: Pick<Files, "read" | "list">): Promise<PackLookup> {
|
|
56
|
+
const warnings: string[] = [];
|
|
57
|
+
const own = await attempt(files, ORKEON_PACK_PATH);
|
|
58
|
+
if (own.kind !== "absent") return decide(ORKEON_PACK_PATH, "orkeon", own, warnings);
|
|
59
|
+
|
|
60
|
+
let entries: string[];
|
|
61
|
+
try {
|
|
62
|
+
entries = await files.list(HARNESS_PACKS_DIR, LIST_CAP);
|
|
63
|
+
} catch {
|
|
64
|
+
entries = [];
|
|
65
|
+
}
|
|
66
|
+
const packs = entries.filter((e) => /^repo-/.test(e)).sort();
|
|
67
|
+
for (const entry of packs) {
|
|
68
|
+
const path = `${HARNESS_PACKS_DIR}/${entry}/references/repo.yaml`;
|
|
69
|
+
const a = await attempt(files, path);
|
|
70
|
+
if (a.kind === "absent") continue;
|
|
71
|
+
if (packs.length > 1) {
|
|
72
|
+
warnings.push(`several repository packs are deployed (${packs.join(", ")}): ${shownOf(path)} is read`);
|
|
73
|
+
}
|
|
74
|
+
return decide(path, "harness", a, warnings);
|
|
75
|
+
}
|
|
76
|
+
return { found: null, warnings };
|
|
77
|
+
}
|