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,122 @@
|
|
|
1
|
+
// The trace of a turn's tool calls: the history keeps what was said, and this message says which calls produced it
|
|
2
|
+
// (docs/architecture.md, One turn of the loop, step 7). A call is its tool, its main arguments cut short and a
|
|
3
|
+
// one-line outcome; never a file's content nor a command's output.
|
|
4
|
+
import { secretPatternsIn } from "./secret-patterns.ts";
|
|
5
|
+
|
|
6
|
+
/** The marker of the stored message; the header names it as material. */
|
|
7
|
+
export const TOOL_TRACE_MARKER = "[tools]";
|
|
8
|
+
/** The lines of one message, the line that counts the calls left out included. */
|
|
9
|
+
export const MAX_TRACE_LINES = 20;
|
|
10
|
+
/** An argument's value is cut past this many characters. */
|
|
11
|
+
export const MAX_ARG_CHARS = 60;
|
|
12
|
+
|
|
13
|
+
/** The arguments a line keeps, in this order: where a call looked and how, never what it wrote. */
|
|
14
|
+
const ARG_KEYS: readonly string[] = [
|
|
15
|
+
"path", "paths", "file_path", "pattern", "glob", "output_mode", "command", "query", "fqn", "symbol", "name", "url",
|
|
16
|
+
"category", "key", "mode", "offset", "limit",
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
/** The fields of a result that list what it found. */
|
|
20
|
+
const LIST_KEYS: readonly string[] = ["hits", "matches", "results", "files", "entries", "items"];
|
|
21
|
+
|
|
22
|
+
export interface ToolCallTrace {
|
|
23
|
+
readonly tool: string;
|
|
24
|
+
readonly args: string;
|
|
25
|
+
readonly outcome: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** One call as the trace keeps it. */
|
|
29
|
+
export function traceCall(tool: string, input: unknown, result: unknown): ToolCallTrace {
|
|
30
|
+
return { tool, args: argsOf(input), outcome: outcomeOf(result) };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** The message of a turn's calls, oldest first, the same call folded as `×n`; null when the turn called no tool. */
|
|
34
|
+
export function formatToolTrace(calls: readonly ToolCallTrace[]): string | null {
|
|
35
|
+
if (calls.length === 0) return null;
|
|
36
|
+
const folded = new Map<string, { line: string; count: number }>();
|
|
37
|
+
for (const c of calls) {
|
|
38
|
+
const line = `${c.tool}(${c.args}) → ${c.outcome}`;
|
|
39
|
+
const seen = folded.get(line);
|
|
40
|
+
if (seen === undefined) folded.set(line, { line, count: 1 });
|
|
41
|
+
else seen.count += 1;
|
|
42
|
+
}
|
|
43
|
+
const entries = [...folded.values()];
|
|
44
|
+
const shown = entries.length > MAX_TRACE_LINES ? entries.slice(0, MAX_TRACE_LINES - 1) : entries;
|
|
45
|
+
// The calls left out, each folded line counting its ×n.
|
|
46
|
+
const left = entries.slice(shown.length).reduce((sum, f) => sum + f.count, 0);
|
|
47
|
+
const tail = left > 0 ? [`- … ${left} other calls`] : [];
|
|
48
|
+
const lines = shown.map((f) => `- ${f.line}${f.count > 1 ? ` ×${f.count}` : ""}`);
|
|
49
|
+
return `${TOOL_TRACE_MARKER} The tool calls of the answer below (material: what was called, not what it returned):\n` +
|
|
50
|
+
[...lines, ...tail].join("\n");
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Whether a stored message is a turn's trace. */
|
|
54
|
+
export function isToolTrace(content: string): boolean {
|
|
55
|
+
return content.startsWith(TOOL_TRACE_MARKER);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function argsOf(input: unknown): string {
|
|
59
|
+
if (input === null || typeof input !== "object" || Array.isArray(input)) return "";
|
|
60
|
+
const record = input as Record<string, unknown>;
|
|
61
|
+
const parts: string[] = [];
|
|
62
|
+
for (const key of ARG_KEYS) {
|
|
63
|
+
const value = shownValue(record[key]);
|
|
64
|
+
if (value !== null) parts.push(`${key}=${value}`);
|
|
65
|
+
}
|
|
66
|
+
return parts.join(", ");
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function shownValue(value: unknown): string | null {
|
|
70
|
+
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
71
|
+
if (Array.isArray(value)) {
|
|
72
|
+
const items = value.filter((v): v is string => typeof v === "string");
|
|
73
|
+
return items.length === 0 ? null : cut(items.join(","));
|
|
74
|
+
}
|
|
75
|
+
if (typeof value !== "string" || value.trim().length === 0) return null;
|
|
76
|
+
return secretPatternsIn(value).length > 0 ? "(redacted)" : cut(value);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function cut(text: string): string {
|
|
80
|
+
const flat = text.replace(/\s+/g, " ").trim();
|
|
81
|
+
return flat.length > MAX_ARG_CHARS ? flat.slice(0, MAX_ARG_CHARS - 1) + "…" : flat;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function outcomeOf(result: unknown): string {
|
|
85
|
+
if (result === null || result === undefined) return "no result";
|
|
86
|
+
if (typeof result === "string") return textOutcome(result);
|
|
87
|
+
if (typeof result !== "object") return cut(String(result));
|
|
88
|
+
if (Array.isArray(result)) return `${result.length} results`;
|
|
89
|
+
const r = result as Record<string, unknown>;
|
|
90
|
+
if (typeof r.error === "string" && r.error.trim().length > 0) return `error: ${cut(firstLine(r.error))}`;
|
|
91
|
+
const parts = [mainOutcome(r)];
|
|
92
|
+
if (r.scan_complete === false) parts.push("incomplete scan");
|
|
93
|
+
if (r.truncated === true) parts.push("truncated");
|
|
94
|
+
return parts.join(", ");
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function mainOutcome(r: Record<string, unknown>): string {
|
|
98
|
+
if (typeof r.total_matches === "number") {
|
|
99
|
+
return typeof r.files_matched === "number"
|
|
100
|
+
? `${r.total_matches} matches in ${r.files_matched} files`
|
|
101
|
+
: `${r.total_matches} matches`;
|
|
102
|
+
}
|
|
103
|
+
const exit = typeof r.exit_code === "number" ? r.exit_code : r.exitCode;
|
|
104
|
+
if (typeof exit === "number") return `exit ${exit}`;
|
|
105
|
+
for (const key of LIST_KEYS) {
|
|
106
|
+
const list = r[key];
|
|
107
|
+
if (Array.isArray(list)) return `${list.length} ${key}`;
|
|
108
|
+
}
|
|
109
|
+
return "ok";
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function textOutcome(text: string): string {
|
|
113
|
+
const line = firstLine(text);
|
|
114
|
+
if (/^error\b/i.test(line)) return `error: ${cut(line.replace(/^error:?\s*/i, ""))}`;
|
|
115
|
+
if (text.trim().length === 0) return "empty";
|
|
116
|
+
const count = text.split("\n").filter((l) => l.trim().length > 0).length;
|
|
117
|
+
return count === 1 ? "1 line" : `${count} lines`;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function firstLine(text: string): string {
|
|
121
|
+
return text.trim().split("\n")[0] ?? "";
|
|
122
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Pure shared types — no IO, no runtime globals. Imported by every layer.
|
|
2
|
+
//
|
|
3
|
+
// These were previously inline shapes scattered across the crew bodies
|
|
4
|
+
// (code-review findings, git-commit draft, project-init conventions,
|
|
5
|
+
// session buffer messages). Centralised so the domain helpers + tests can
|
|
6
|
+
// reference one definition.
|
|
7
|
+
|
|
8
|
+
/** Severity ladder used by the code-review crew (and any finding producer). */
|
|
9
|
+
export type Severity = "blocker" | "high" | "medium" | "low" | "nit";
|
|
10
|
+
|
|
11
|
+
/** A single review finding (code-review crew). */
|
|
12
|
+
export interface Finding {
|
|
13
|
+
severity: Severity | string;
|
|
14
|
+
file: string;
|
|
15
|
+
line?: number;
|
|
16
|
+
category?: string;
|
|
17
|
+
finding: string;
|
|
18
|
+
suggestion?: string;
|
|
19
|
+
/** Which review lens surfaced it (correctness | security | style). */
|
|
20
|
+
lens?: string;
|
|
21
|
+
/** Whether the diff shows what triggers it (`shown`), or the trigger lies outside the
|
|
22
|
+
* text the lens read and the finding names what would confirm it (`plausible`). */
|
|
23
|
+
confidence?: "shown" | "plausible";
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Detected build/test/lint conventions (project-init crew). */
|
|
27
|
+
export interface DetectedConventions {
|
|
28
|
+
buildCommand?: string;
|
|
29
|
+
testCommand?: string;
|
|
30
|
+
/** How to run one test file or case, when the configuration shows it. */
|
|
31
|
+
singleTestCommand?: string;
|
|
32
|
+
lintCommand?: string;
|
|
33
|
+
frameworks: string[];
|
|
34
|
+
conventions: string[];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Test-readiness classification (init-verifiers crew). */
|
|
38
|
+
export interface TestReadiness {
|
|
39
|
+
appTypes: string[];
|
|
40
|
+
frameworks: string[];
|
|
41
|
+
hasUnitTests?: boolean;
|
|
42
|
+
hasE2E?: boolean;
|
|
43
|
+
zonesNeedingVerifier: string[];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** One conversation-buffer turn (session_store messages). */
|
|
47
|
+
export interface SessionMsg {
|
|
48
|
+
role: string;
|
|
49
|
+
content: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Typed post-compaction boundary marker (E-9) — lets the scrollback and
|
|
53
|
+
* session-memory tracking distinguish pre- vs post-compact messages. The
|
|
54
|
+
* content marker doubles as the detector because the C# session store may
|
|
55
|
+
* round-trip only role/content. */
|
|
56
|
+
export interface CompactBoundaryMessage extends SessionMsg {
|
|
57
|
+
role: "system";
|
|
58
|
+
subtype: "compact_boundary";
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** A prompt as two messages: the instructions (the system message) and the
|
|
62
|
+
* material they apply to (the user message), so text inside the material never
|
|
63
|
+
* carries the authority of an instruction. */
|
|
64
|
+
export interface PromptPair {
|
|
65
|
+
system: string;
|
|
66
|
+
user: string;
|
|
67
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Verification skills — where /init-verifiers writes them and how /verify asks the
|
|
2
|
+
// main loop to follow them. Pure, no IO.
|
|
3
|
+
|
|
4
|
+
/** Where /init-verifiers writes one skill per zone, and where /verify reads them. */
|
|
5
|
+
export const VERIFIERS_DIR = "/output/verifiers";
|
|
6
|
+
|
|
7
|
+
/** The file-name slug of a zone: `Web UI` → `web-ui`. */
|
|
8
|
+
export function safeZoneName(zone: string): string {
|
|
9
|
+
return zone.replace(/[^a-z0-9]+/gi, "-").toLowerCase();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** The path of a zone's skill. */
|
|
13
|
+
export function verifierPath(zone: string): string {
|
|
14
|
+
return `${VERIFIERS_DIR}/verify-${safeZoneName(zone)}.md`;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The request /verify sends to the main loop: follow one zone's skill, or every
|
|
19
|
+
* skill, by running it — the check the tests cannot make — and report as the skill
|
|
20
|
+
* says; a failure ends in the report, never in a fix. Without a skill it says so
|
|
21
|
+
* instead of improvising a check.
|
|
22
|
+
*/
|
|
23
|
+
export function buildVerifyRequest(zone: string): string {
|
|
24
|
+
const z = zone.trim();
|
|
25
|
+
const which = z.length > 0
|
|
26
|
+
? `the verification skill ${verifierPath(z)}`
|
|
27
|
+
: `every verification skill under ${VERIFIERS_DIR}/, one after the other`;
|
|
28
|
+
const missing = z.length > 0 ? "If that file does not exist" : "If there is none";
|
|
29
|
+
return (
|
|
30
|
+
`Check that the project works by running it: follow ${which}, written by /init-verifiers, step by ` +
|
|
31
|
+
"step. Run each step's command, compare what you observe with the skill's Pass section, and report " +
|
|
32
|
+
"as its Report section says, quoting the output of a failure. A failed check ends in that report: a " +
|
|
33
|
+
"fix is a separate request, so never edit code to make a step pass. " +
|
|
34
|
+
`${missing}, say so and suggest ` +
|
|
35
|
+
"/init-verifiers instead of improvising a check."
|
|
36
|
+
);
|
|
37
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// The mount of the Orkeon VFS the code works in (docs/architecture.md, "The VFS"): the project's checkout. Pure.
|
|
2
|
+
|
|
3
|
+
/** The project's checkout: where the file tools name a project file `/workspace/<path>`, where the shell runs, and
|
|
4
|
+
* the root the code index holds every path under. */
|
|
5
|
+
export const WORKSPACE = "/workspace";
|
|
6
|
+
|
|
7
|
+
/** `path` relative to the checkout when it lies under it; any other path as given. */
|
|
8
|
+
export const workspaceRelative = (path: string): string =>
|
|
9
|
+
path.startsWith(`${WORKSPACE}/`) ? path.slice(WORKSPACE.length + 1) : path;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// The state of a dev batch written before a compaction, `.orkeon/dev/<code>/state-<phase>.md`,
|
|
2
|
+
// and the session's pointer to the batch in progress. Pure, no IO.
|
|
3
|
+
//
|
|
4
|
+
// A compaction may keep the batch sheet in its summary or lose it, and nothing in the
|
|
5
|
+
// summary says which steps were closed or which reports came back. The facts are on
|
|
6
|
+
// disk, so code writes them before the buffer is rewritten: the TDD lines of the sheet
|
|
7
|
+
// and the first open one, the batch's events in Code's own log, the reports recorded,
|
|
8
|
+
// the working tree. The file is rewritten at every compaction; the session's start
|
|
9
|
+
// script names it again at the next start (scripts/session-start.sh reads its
|
|
10
|
+
// `First open:` line and its header's date).
|
|
11
|
+
import type { BatchSheet } from "../dev/plan-format.ts";
|
|
12
|
+
import { isCode } from "../dev/artefacts.ts";
|
|
13
|
+
|
|
14
|
+
/** Code's own state folder, in the project. */
|
|
15
|
+
export const DEV_STATE_DIR = ".orkeon/dev";
|
|
16
|
+
|
|
17
|
+
/** The batch a workflow step works on: `code` null when the step did not name it. */
|
|
18
|
+
export interface ActiveWorkflow {
|
|
19
|
+
code: string | null;
|
|
20
|
+
phase: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const PHASE = /^F\d+$/;
|
|
24
|
+
|
|
25
|
+
/** The pointer as stored (JSON), or null when absent or malformed. */
|
|
26
|
+
export function parseActiveWorkflow(raw: string | null): ActiveWorkflow | null {
|
|
27
|
+
if (raw === null || raw.trim().length === 0) return null;
|
|
28
|
+
let value: unknown;
|
|
29
|
+
try {
|
|
30
|
+
value = JSON.parse(raw);
|
|
31
|
+
} catch {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
if (value === null || typeof value !== "object") return null;
|
|
35
|
+
const v = value as { code?: unknown; phase?: unknown };
|
|
36
|
+
if (typeof v.phase !== "string" || !PHASE.test(v.phase)) return null;
|
|
37
|
+
const code = typeof v.code === "string" && isCode(v.code) ? v.code : null;
|
|
38
|
+
return { code, phase: v.phase };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function formatActiveWorkflow(active: ActiveWorkflow): string {
|
|
42
|
+
return JSON.stringify({ code: active.code, phase: active.phase });
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** The state file of a batch, relative to the project root. */
|
|
46
|
+
export function stateFilePath(code: string, phase: string): string {
|
|
47
|
+
return `${DEV_STATE_DIR}/${code}/state-${phase}.md`;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Code's event log of a work code, relative to the project root. */
|
|
51
|
+
export function batchesStatePath(code: string): string {
|
|
52
|
+
return `${DEV_STATE_DIR}/${code}/batches-state.md`;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface StateStep {
|
|
56
|
+
label: string;
|
|
57
|
+
tdd: string;
|
|
58
|
+
open: boolean;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** A step title, an event line: cut to this many characters, so a sheet cannot flood the prompt. */
|
|
62
|
+
export const MAX_STATE_LINE_CHARS = 160;
|
|
63
|
+
/** At most this many event lines go into the file (the last ones). */
|
|
64
|
+
export const MAX_EVENT_LINES = 40;
|
|
65
|
+
|
|
66
|
+
export function boundLine(line: string): string {
|
|
67
|
+
return line.length <= MAX_STATE_LINE_CHARS ? line : line.slice(0, MAX_STATE_LINE_CHARS - 1) + "…";
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** The steps of a sheet that carry a TDD line, in order. */
|
|
71
|
+
export function sheetStateSteps(sheet: BatchSheet): StateStep[] {
|
|
72
|
+
const box = (ticked: boolean): string => (ticked ? "[x]" : "[ ]");
|
|
73
|
+
return sheet.steps
|
|
74
|
+
.filter((s) => s.tdd !== null)
|
|
75
|
+
.map((s) => {
|
|
76
|
+
const t = s.tdd!;
|
|
77
|
+
return {
|
|
78
|
+
label: boundLine(`Step ${s.number} — ${s.title}`),
|
|
79
|
+
tdd: `RED ${box(t.red)} GREEN ${box(t.green)} COST ${box(t.cost)}`,
|
|
80
|
+
open: !(t.red && t.green && t.cost),
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function firstOpenStep(steps: readonly StateStep[]): string | null {
|
|
86
|
+
return steps.find((s) => s.open)?.label ?? null;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** At most this many lines of `git status --short` go into the file. */
|
|
90
|
+
export const MAX_TREE_LINES = 40;
|
|
91
|
+
|
|
92
|
+
export interface StateFacts {
|
|
93
|
+
code: string;
|
|
94
|
+
phase: string;
|
|
95
|
+
/** When the file was written (ISO 8601, UTC). */
|
|
96
|
+
at: string;
|
|
97
|
+
trigger: "manual" | "auto";
|
|
98
|
+
/** The sheet, as the work folder shows it ("workbench/demo/DEMO-PLAN-F2.md"). */
|
|
99
|
+
sheet: string;
|
|
100
|
+
steps: StateStep[];
|
|
101
|
+
/** The batch's lines of Code's event log, as written there. */
|
|
102
|
+
events: string[];
|
|
103
|
+
/** The reports recorded for the batch (file names). */
|
|
104
|
+
reports: string[];
|
|
105
|
+
/** `git status --short`, or why there is none. */
|
|
106
|
+
tree: { lines: string[] } | { note: string };
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** The file's text. */
|
|
110
|
+
export function renderStateFile(f: StateFacts): string {
|
|
111
|
+
const first = firstOpenStep(f.steps);
|
|
112
|
+
const out: string[] = [
|
|
113
|
+
`# State of batch ${f.phase} of ${f.code} — written at ${f.at} before a ${f.trigger} compaction`,
|
|
114
|
+
"",
|
|
115
|
+
`> Read this file first after a compaction. The sheet is \`${f.sheet}\`: resume at its first open step, and`,
|
|
116
|
+
"> tick nothing that was not observed. A report listed below came back already: do not ask for it again.",
|
|
117
|
+
"> Rewritten at every compaction; Orkeon Code never commits it.",
|
|
118
|
+
"",
|
|
119
|
+
"## Steps of the sheet (TDD lines)",
|
|
120
|
+
"",
|
|
121
|
+
];
|
|
122
|
+
if (f.steps.length === 0) out.push("(the sheet has no step with a TDD line)");
|
|
123
|
+
for (const s of f.steps) out.push(`- ${s.label}: ${s.tdd}`);
|
|
124
|
+
out.push("", first === null ? "No open step: every TDD line is ticked." : `First open: ${first}`, "");
|
|
125
|
+
out.push(`## Events of ${f.phase} in \`${batchesStatePath(f.code)}\``, "");
|
|
126
|
+
const events = f.events.slice(-MAX_EVENT_LINES).map(boundLine);
|
|
127
|
+
if (f.events.length > MAX_EVENT_LINES) out.push(`(${f.events.length - MAX_EVENT_LINES} earlier line(s) left out)`);
|
|
128
|
+
out.push(...(events.length === 0 ? ["(none)"] : events), "");
|
|
129
|
+
out.push(`## Reports recorded for ${f.phase}`, "");
|
|
130
|
+
out.push(...(f.reports.length === 0 ? ["(none)"] : f.reports.map((r) => `- ${boundLine(r)}`)), "");
|
|
131
|
+
out.push("## Working tree (`git status --short`)", "");
|
|
132
|
+
if ("note" in f.tree) {
|
|
133
|
+
out.push(`(${f.tree.note})`);
|
|
134
|
+
} else {
|
|
135
|
+
const shown = f.tree.lines.slice(0, MAX_TREE_LINES).map(boundLine);
|
|
136
|
+
out.push("```text", ...(shown.length === 0 ? ["(clean)"] : shown), "```");
|
|
137
|
+
if (f.tree.lines.length > MAX_TREE_LINES) out.push(`(${f.tree.lines.length - MAX_TREE_LINES} more line(s) left out)`);
|
|
138
|
+
}
|
|
139
|
+
return out.join("\n") + "\n";
|
|
140
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Typed bridge to the runtime globals injected by Orkeon.Scripting.Cli /
|
|
2
|
+
// Orkeon.Cli.Scripting (Jint engine). Declared ONCE here and re-exported as
|
|
3
|
+
// typed aliases so the rest of the codebase never writes `(globalThis as any)`.
|
|
4
|
+
// Esbuild bundles every module into a single script for Jint, so these
|
|
5
|
+
// declarations resolve at runtime against the engine's globalThis.
|
|
6
|
+
//
|
|
7
|
+
// This is the ONLY module allowed to reach into the runtime globals — the
|
|
8
|
+
// source-layer analogue of the C# "all IO through IFileSystemService" rule.
|
|
9
|
+
// (Mirrors exp 02 crews/unified/infrastructure/globals.ts.)
|
|
10
|
+
//
|
|
11
|
+
// `Tools` is typed (OrkeonTools plus the local declarations of orkeon/runtime-tools.ts)
|
|
12
|
+
// and read by the adapters of orkeon/ and by entry points only.
|
|
13
|
+
|
|
14
|
+
declare const agentBuilder: () => any;
|
|
15
|
+
declare const crewBuilder: () => any;
|
|
16
|
+
declare const toolBuilder: () => ToolBuilder<unknown, unknown>;
|
|
17
|
+
|
|
18
|
+
/** `tools.<camelCase>(args)` namespace bridging IBaseTool implementations, as the
|
|
19
|
+
* generated typings declare it: every built-in tool typed (Orkeon #125). */
|
|
20
|
+
export const Tools: OrkeonTools = tools;
|
|
21
|
+
/** Domain DSL: build an agent. */
|
|
22
|
+
export const AgentBuilder: () => any = agentBuilder;
|
|
23
|
+
/** Domain DSL: build a crew. */
|
|
24
|
+
export const CrewBuilder: () => any = crewBuilder;
|
|
25
|
+
/** Domain DSL: build a tool Orkeon Code defines (orkeon/script-tools.ts). */
|
|
26
|
+
export const ToolBuilder: () => ToolBuilder<unknown, unknown> = toolBuilder;
|
|
27
|
+
|
|
28
|
+
/** The RAG namespace (`rag.retrieve`, `rag.ingest`), or undefined when the host declares none (it needs
|
|
29
|
+
* AddOrkeonRag): orkeon/shared-memory.ts then calls the rag_search and rag_ingest tools. */
|
|
30
|
+
export const Rag: typeof rag | undefined = typeof rag === "undefined" ? undefined : rag;
|
|
31
|
+
|
|
32
|
+
/** The `llm` namespace (`llm.profile`, `llm.default_`), or undefined where the host declares none (a command
|
|
33
|
+
* engine): orkeon/llm-profile.ts builds an agent on the profile the crew input names. */
|
|
34
|
+
export const Llm: typeof llm | undefined = typeof llm === "undefined" ? undefined : llm;
|
|
35
|
+
|
|
36
|
+
/** Typed accessor for `globalThis.inputs` (crew/command invocation payload).
|
|
37
|
+
*
|
|
38
|
+
* ⚠️ The implementation binding is deliberately NOT named `inputs`: esbuild
|
|
39
|
+
* bundles to a flat esm script that Jint evaluates in SCRIPT mode, where a
|
|
40
|
+
* top-level `function inputs()` becomes a GLOBAL binding and clobbers the
|
|
41
|
+
* `globalThis.inputs` object the host injects before evaluation (`--inputs`
|
|
42
|
+
* then reads back as the function itself → empty payload). Exporting under
|
|
43
|
+
* the public name keeps every call site unchanged. */
|
|
44
|
+
function readInputs<T = Record<string, any>>(): T {
|
|
45
|
+
return ((globalThis as any).inputs ?? {}) as T;
|
|
46
|
+
}
|
|
47
|
+
export { readInputs as inputs };
|
|
48
|
+
|
|
49
|
+
/** Publish the assembled crew back to the runtime (`globalThis.crew = ...`). */
|
|
50
|
+
export function publishCrew(crew: any): void {
|
|
51
|
+
(globalThis as any).crew = crew;
|
|
52
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// PendingApprovals adapter over orkeon-repl's `approvals` service (Orkeon #198). Like the
|
|
2
|
+
// permissions service, it is reached through the command context the runtime hands each
|
|
3
|
+
// command (`ctx.services`), so the adapter takes the context's service locator rather than
|
|
4
|
+
// being bound in wiring.ts. A host that does not register the service has no approval to show.
|
|
5
|
+
|
|
6
|
+
import type { PendingApproval, PendingApprovals } from "../../application/ports.ts";
|
|
7
|
+
import type { PendingApprovals as HostApprovals, ServiceLocator } from "../../../commands/.orkeon/orkeon-cli.d.ts";
|
|
8
|
+
|
|
9
|
+
/** The service name; orkeon-repl registers it when it watches the tool approvals. */
|
|
10
|
+
const APPROVALS = "approvals";
|
|
11
|
+
|
|
12
|
+
export function createPendingApprovals(services: Pick<ServiceLocator, "get" | "has">): PendingApprovals {
|
|
13
|
+
return {
|
|
14
|
+
list(): PendingApproval[] {
|
|
15
|
+
if (!services.has(APPROVALS)) return [];
|
|
16
|
+
return services.get<HostApprovals>(APPROVALS).list().map((a) => ({
|
|
17
|
+
taskId: a.taskId ?? null,
|
|
18
|
+
command: a.command ?? null,
|
|
19
|
+
tool: String(a.tool),
|
|
20
|
+
input: String(a.input ?? ""),
|
|
21
|
+
}));
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/// <reference path="../../../crews/.orkeon/orkeon.d.ts" />
|
|
2
|
+
// The children of a crew run (A-3) over the runtime: `ctx.spawnBackground`, the crew's
|
|
3
|
+
// `instances()`/`stop()`, the crew's memory and `ctx.receive({ timeout })` as the pause (it
|
|
4
|
+
// rejects with a ReceiveTimeoutError when nothing arrives, which is the whole point here). The
|
|
5
|
+
// crew entry builds them from the context its body receives and the crew object it published;
|
|
6
|
+
// withChildAct hands the use cases an Llm whose act runs in such a child, the rest unchanged.
|
|
7
|
+
// A parallel /dev-batches' batch agent uses none of this: its audit acts inline on its own Llm, no child
|
|
8
|
+
// and no board, so /tasks does not list it (dev-batches/crew.ork.ts, L8P-D2).
|
|
9
|
+
|
|
10
|
+
import type { ActRequest, ChildRuntime, Llm, Logger } from "../../application/ports.ts";
|
|
11
|
+
import { createChildBoard, instanceKey, parseChildInput, runChildAct } from "../../application/agents/child-agent.ts";
|
|
12
|
+
import type { BoardDeps, ChildBoard } from "../../application/agents/child-agent.ts";
|
|
13
|
+
import { createLlm } from "./llm.ts";
|
|
14
|
+
import type { ToolCallbacks } from "../../application/dev/tool-callbacks.ts";
|
|
15
|
+
|
|
16
|
+
type ChildContext = Pick<AgentContext, "spawnBackground" | "memory" | "receive">;
|
|
17
|
+
type ChildCrew = Pick<Crew, "instances" | "stop">;
|
|
18
|
+
|
|
19
|
+
const firstLine = (error: unknown): string => String((error as Error)?.message ?? error).split("\n")[0];
|
|
20
|
+
|
|
21
|
+
/** A rejection of `receive` that is its timeout, the expected end of a pause. */
|
|
22
|
+
function isTimeout(error: unknown): boolean {
|
|
23
|
+
const e = error as { name?: unknown; message?: unknown; code?: unknown } | null;
|
|
24
|
+
return /timeout/i.test(`${e?.name ?? ""} ${e?.code ?? ""} ${e?.message ?? error}`);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** The runtime's children for this run; null on a host without background children (the act then runs inline, A1). */
|
|
28
|
+
export function createChildRuntime(ctx: ChildContext, crew: ChildCrew): ChildRuntime | null {
|
|
29
|
+
if (typeof ctx.spawnBackground !== "function" || typeof crew?.instances !== "function") return null;
|
|
30
|
+
return {
|
|
31
|
+
spawn(agent, input) {
|
|
32
|
+
ctx.spawnBackground(agent, input);
|
|
33
|
+
},
|
|
34
|
+
instances: () => [...crew.instances()].map((i) => ({ id: String(i.id), agent: String(i.agent), state: String(i.state) })),
|
|
35
|
+
stop: (id) => id !== "" && crew.stop(id) === true,
|
|
36
|
+
read: (key) => ctx.memory.crew.get(key),
|
|
37
|
+
async pause(ms) {
|
|
38
|
+
try {
|
|
39
|
+
// Nothing sends the parent an event; one that arrives anyway is left unread.
|
|
40
|
+
await ctx.receive({ timeout: ms });
|
|
41
|
+
} catch (error) {
|
|
42
|
+
if (!isTimeout(error)) throw error;
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The body of a child agent: it acts on the call its input carries, under the callbacks of its
|
|
50
|
+
* step, and leaves the outcome in the crew's memory for the parent before it returns.
|
|
51
|
+
*/
|
|
52
|
+
export function childAgentBody(
|
|
53
|
+
callbacksFor: (ctx: AgentContext) => ToolCallbacks | undefined,
|
|
54
|
+
): (input: unknown, ctx: AgentContext) => Promise<string> {
|
|
55
|
+
return async (input, ctx) => {
|
|
56
|
+
const call = parseChildInput(input);
|
|
57
|
+
if (call === null) throw new Error("child agent: its input is not a child call");
|
|
58
|
+
// The parent cannot match the runtime's rows by agent name (they hold the agent's id): say which instance this is.
|
|
59
|
+
if (typeof ctx.instanceId === "string") await ctx.memory.crew.store(instanceKey(call.key), ctx.instanceId).catch(() => undefined);
|
|
60
|
+
try {
|
|
61
|
+
const reply = await createLlm(ctx.llm, callbacksFor(ctx)).act(call.prompt, call.request);
|
|
62
|
+
await ctx.memory.crew.store(call.key, { ok: true, reply });
|
|
63
|
+
return reply;
|
|
64
|
+
} catch (error) {
|
|
65
|
+
await ctx.memory.crew.store(call.key, { ok: false, error: firstLine(error) }).catch(() => undefined);
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface ChildActSpec {
|
|
72
|
+
/** The crew agent the child runs as, added to the crew by `ctx.spawn(builder())` at its first act. */
|
|
73
|
+
agent: string;
|
|
74
|
+
charter: string;
|
|
75
|
+
task: string;
|
|
76
|
+
builder: () => AgentBuilder;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* `base` with its act run by a background child (approach A2), or `base` itself, the act inline in
|
|
81
|
+
* the same body (approach A1), when the host has no background children.
|
|
82
|
+
*/
|
|
83
|
+
export function withChildAct(
|
|
84
|
+
base: Llm,
|
|
85
|
+
ctx: ChildContext & Pick<AgentContext, "crew" | "spawn">,
|
|
86
|
+
crew: ChildCrew,
|
|
87
|
+
deps: { board: ChildBoard; clock: () => Date; log: Logger; effort?: ActRequest["effort"] },
|
|
88
|
+
spec: ChildActSpec,
|
|
89
|
+
): Llm {
|
|
90
|
+
const runtime = createChildRuntime(ctx, crew);
|
|
91
|
+
if (runtime === null) {
|
|
92
|
+
deps.log.warn(`${spec.agent}: this host runs no background child; the act runs inline in the step's own agent`);
|
|
93
|
+
return base;
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
...base,
|
|
97
|
+
act(prompt: string, request: ActRequest) {
|
|
98
|
+
if (!ctx.crew.has(spec.agent)) ctx.spawn(spec.builder());
|
|
99
|
+
return runChildAct(
|
|
100
|
+
{ runtime, board: deps.board, clock: deps.clock, log: deps.log },
|
|
101
|
+
{
|
|
102
|
+
agent: spec.agent, charter: spec.charter, task: spec.task, prompt,
|
|
103
|
+
// The crew's effort when the request names none, as createLlm fills it for an inline act.
|
|
104
|
+
request: request.effort === undefined && deps.effort !== undefined ? { ...request, effort: deps.effort } : request,
|
|
105
|
+
},
|
|
106
|
+
);
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* A step run whose act goes to a background child (A2), from its board to its close: the board
|
|
113
|
+
* /tasks reads under `run.crew`, and withChildAct over it. The caller closes it once the run ended,
|
|
114
|
+
* whatever the outcome (`finally`), so /tasks no longer shows the run as open.
|
|
115
|
+
*/
|
|
116
|
+
export function openChildAct(
|
|
117
|
+
base: Llm,
|
|
118
|
+
ctx: ChildContext & Pick<AgentContext, "crew" | "spawn">,
|
|
119
|
+
crew: ChildCrew,
|
|
120
|
+
deps: BoardDeps & { effort?: ActRequest["effort"] },
|
|
121
|
+
run: { crew: string; step: string },
|
|
122
|
+
spec: ChildActSpec,
|
|
123
|
+
): { llm: Llm; close: () => Promise<void> } {
|
|
124
|
+
const board = createChildBoard({ state: deps.state, clock: deps.clock, log: deps.log }, run);
|
|
125
|
+
const llm = withChildAct(base, ctx, crew, { board, clock: deps.clock, log: deps.log, effort: deps.effort }, spec);
|
|
126
|
+
return { llm, close: () => board.close() };
|
|
127
|
+
}
|