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,356 @@
|
|
|
1
|
+
// B-14 — the VERIFIED request/response contract of the five code-intel tools.
|
|
2
|
+
// Pure, no IO.
|
|
3
|
+
//
|
|
4
|
+
// Every name below was read off a live call on 2026-08-05 (via `/debug-tool-call
|
|
5
|
+
// <tool> {json}`, which prints the raw result), not from a doc or a guess. That
|
|
6
|
+
// matters more than it sounds: the first draft of the code-intel probe assumed
|
|
7
|
+
// `symbol_name` and `direction: "callees"`, and read counts from `files_indexed`.
|
|
8
|
+
// All three were wrong —
|
|
9
|
+
// • `symbol_source` takes `fqn`;
|
|
10
|
+
// • `flow_trace.direction` is Forward | Backward | Both, and 'callees' is a
|
|
11
|
+
// typed deserialization failure;
|
|
12
|
+
// • `index_codebase` reports `file_count` / `node_count`, so a reader looking
|
|
13
|
+
// for `files_indexed` gets 0 from a successful index.
|
|
14
|
+
// The last one is the dangerous shape: the call SUCCEEDS and the caller reports
|
|
15
|
+
// "indexed 0 files", which reads exactly like an empty workspace. A wrong
|
|
16
|
+
// parameter name at least throws.
|
|
17
|
+
//
|
|
18
|
+
// So the readers live here, one per tool, with the field names pinned by tests
|
|
19
|
+
// against payloads captured from that live run. If the framework renames a field,
|
|
20
|
+
// a test fails instead of a probe quietly reporting zero.
|
|
21
|
+
|
|
22
|
+
/** The eleven tools the main-loop catalogue grants for code intelligence.
|
|
23
|
+
* The first five were pinned 2026-08-05; the analysis five (dependency_graph,
|
|
24
|
+
* impact_analysis, package_summary, sub_graph, symbol_detail) were pinned
|
|
25
|
+
* 2026-08-06 from the extended probe's live run on the fixture; edge_list
|
|
26
|
+
* (Orkeon #280) from its published schema. */
|
|
27
|
+
export const CODE_INTEL_TOOLS = [
|
|
28
|
+
"index_codebase", "codebase_map", "codebase_search", "symbol_source", "flow_trace",
|
|
29
|
+
"dependency_graph", "impact_analysis", "package_summary", "sub_graph", "symbol_detail", "edge_list",
|
|
30
|
+
] as const;
|
|
31
|
+
|
|
32
|
+
// ── Hybrid search + lazy freshness (captured live 2026-08-05, post-hybrid) ──
|
|
33
|
+
//
|
|
34
|
+
// codebase_search gained three surfaces, all read off live calls:
|
|
35
|
+
// - request `mode`: "Hybrid" (default) | "Vector" | "Lexical";
|
|
36
|
+
// - hit `match_origin`: "hybrid" | "vector" | "bm25" — WHY a hit ranked (an exact
|
|
37
|
+
// identifier reads hybrid/bm25; scores are RRF rank aggregates in hybrid mode,
|
|
38
|
+
// ~0.03 scale, NOT cosine);
|
|
39
|
+
// - response `refreshed_files`: how many edited files the lazy freshness pass
|
|
40
|
+
// reindexed BEFORE answering. Non-zero right after the agent's own edits.
|
|
41
|
+
// And rag_search takes `question` — NOT `query`. Session-4/5 lesson, third
|
|
42
|
+
// occurrence: the probe caught `{"query": ...} → "question parameter is required"`
|
|
43
|
+
// before any wiring shipped the wrong name.
|
|
44
|
+
|
|
45
|
+
/** `codebase_search.mode` vocabulary (the C# SearchMode enum, PascalCase). */
|
|
46
|
+
export const SEARCH_MODES = ["Hybrid", "Vector", "Lexical"] as const;
|
|
47
|
+
|
|
48
|
+
/** Hit origins the hybrid search reports. */
|
|
49
|
+
export const MATCH_ORIGINS = ["hybrid", "vector", "bm25"] as const;
|
|
50
|
+
|
|
51
|
+
/** `rag_search` request parameter names (verified live). */
|
|
52
|
+
export const RAG_SEARCH_PARAMS = ["question", "collection", "top_n"] as const;
|
|
53
|
+
|
|
54
|
+
/** Hit origin of one search hit; unknown/absent → "vector" (the pre-hybrid reading). */
|
|
55
|
+
export function readMatchOrigin(hit: any): string {
|
|
56
|
+
const v = String(hit?.match_origin ?? "").trim();
|
|
57
|
+
return (MATCH_ORIGINS as readonly string[]).includes(v) ? v : "vector";
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Files the lazy freshness pass reindexed before this response. */
|
|
61
|
+
export function readRefreshedFiles(raw: any): number {
|
|
62
|
+
const v = Number(raw?.refreshed_files ?? 0);
|
|
63
|
+
return Number.isFinite(v) && v > 0 ? v : 0;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** `flow_trace.direction` — the tool's own enum. Not caller/callee vocabulary. */
|
|
67
|
+
export const FLOW_DIRECTIONS = ["Forward", "Backward", "Both"] as const;
|
|
68
|
+
export type FlowDirection = (typeof FLOW_DIRECTIONS)[number];
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The request parameter names, per tool, as the tools actually accept them.
|
|
72
|
+
* Kept as data so a probe cannot spell one differently from the pin.
|
|
73
|
+
*/
|
|
74
|
+
export const CODE_INTEL_PARAMS = {
|
|
75
|
+
index_codebase: ["root_path"],
|
|
76
|
+
codebase_map: ["level", "include_metrics"],
|
|
77
|
+
codebase_search: ["query", "top_k", "filter_kinds"],
|
|
78
|
+
symbol_source: ["fqn"],
|
|
79
|
+
flow_trace: ["from", "to", "direction", "max_depth", "edge_kinds"],
|
|
80
|
+
// The analysis five — the subset each probe/command actually exercises, and the
|
|
81
|
+
// parameters code-intel-routing.ts names in the prompts (filter_kinds, edge_kinds, expand).
|
|
82
|
+
// `scope` is a NodeLevel ("L1_Package" | "L2_Module" | "L3_Symbol"), the same
|
|
83
|
+
// vocabulary codebase_map's `level` takes; `direction` reuses FLOW_DIRECTIONS.
|
|
84
|
+
dependency_graph: ["scope", "max_nodes", "include_mermaid"],
|
|
85
|
+
impact_analysis: ["target", "direction", "max_depth"],
|
|
86
|
+
package_summary: ["fqn"],
|
|
87
|
+
sub_graph: ["seeds", "depth", "direction", "edge_kinds"],
|
|
88
|
+
symbol_detail: ["fqn", "include_signature", "expand"],
|
|
89
|
+
// Every edge of the kinds across the index, or under root_fqn, page_size at a time (200, up to 1000); the
|
|
90
|
+
// response's next_cursor goes back as cursor until it is absent, and total counts them all (Orkeon #280).
|
|
91
|
+
edge_list: ["edge_kinds", "root_fqn", "page_size", "cursor"],
|
|
92
|
+
} as const;
|
|
93
|
+
|
|
94
|
+
function num(raw: any, key: string): number {
|
|
95
|
+
const v = raw?.[key];
|
|
96
|
+
return typeof v === "number" ? v : Number(v ?? 0) || 0;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function arr(raw: any, key: string): any[] {
|
|
100
|
+
const v = raw?.[key];
|
|
101
|
+
return Array.isArray(v) ? v : [];
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface IndexSummary {
|
|
105
|
+
files: number;
|
|
106
|
+
nodes: number;
|
|
107
|
+
edges: number;
|
|
108
|
+
statements: number;
|
|
109
|
+
errors: string[];
|
|
110
|
+
/** What the index cache did (Orkeon #244): `hit`, `refreshed`, `miss` or `bypassed`; absent before #244. */
|
|
111
|
+
cache?: string;
|
|
112
|
+
/** The files a `refreshed` cache reindexed (`reindexed_file_count`), read when `cache` is. */
|
|
113
|
+
reindexed?: number;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** `index_codebase` → counts. `file_count`, NOT `files_indexed`. */
|
|
117
|
+
export function readIndexSummary(raw: any): IndexSummary {
|
|
118
|
+
const cache = typeof raw?.cache === "string" && raw.cache !== "" ? raw.cache : undefined;
|
|
119
|
+
return {
|
|
120
|
+
files: num(raw, "file_count"),
|
|
121
|
+
nodes: num(raw, "node_count"),
|
|
122
|
+
edges: num(raw, "edge_count"),
|
|
123
|
+
statements: num(raw, "statement_count"),
|
|
124
|
+
errors: arr(raw, "errors").map((e) => String(e)),
|
|
125
|
+
...(cache === undefined ? {} : { cache, reindexed: num(raw, "reindexed_file_count") }),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** What the index cache did, in words: empty on a runtime without the cache (before Orkeon #244). */
|
|
130
|
+
export function indexCacheNote(idx: IndexSummary): string {
|
|
131
|
+
switch (idx.cache) {
|
|
132
|
+
case undefined: return "";
|
|
133
|
+
case "hit": return "cache hit: the index an earlier session saved, no file changed";
|
|
134
|
+
case "refreshed": return `cache refreshed: ${idx.reindexed ?? 0} changed file(s) reindexed`;
|
|
135
|
+
case "miss": return "cache miss: built, then saved";
|
|
136
|
+
case "bypassed": return "cache bypassed: rebuilt, then saved";
|
|
137
|
+
default: return `cache ${idx.cache}`;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export interface MapEntry {
|
|
142
|
+
fqn: string;
|
|
143
|
+
name: string;
|
|
144
|
+
kind: string;
|
|
145
|
+
/** `children_count`, when the node has children: the modules of a package, the symbols of a module. */
|
|
146
|
+
children?: number;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** `codebase_map` → `entries[]` (+ `totals`), NOT `nodes[]`. */
|
|
150
|
+
export function readMapEntries(raw: any): MapEntry[] {
|
|
151
|
+
return arr(raw, "entries").map((e) => {
|
|
152
|
+
const children = Number(e?.children_count);
|
|
153
|
+
return {
|
|
154
|
+
fqn: String(e?.fqn ?? ""),
|
|
155
|
+
name: String(e?.name ?? ""),
|
|
156
|
+
kind: String(e?.kind ?? ""),
|
|
157
|
+
...(Number.isFinite(children) && children > 0 ? { children } : {}),
|
|
158
|
+
};
|
|
159
|
+
}).filter((e) => e.fqn.length > 0);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** `codebase_map.totals.symbol_count`. */
|
|
163
|
+
export function readMapSymbolCount(raw: any): number {
|
|
164
|
+
return num(raw?.totals, "symbol_count");
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export interface SearchHit {
|
|
168
|
+
fqn: string;
|
|
169
|
+
score: number;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/** `codebase_search` → `hits[] { fqn, score }`, NOT `results[]`. */
|
|
173
|
+
export function readSearchHits(raw: any): SearchHit[] {
|
|
174
|
+
return arr(raw, "hits").map((h) => ({ fqn: String(h?.fqn ?? ""), score: Number(h?.score ?? 0) }))
|
|
175
|
+
.filter((h) => h.fqn.length > 0);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** `symbol_source` → the source text (`source`; `markdown_ready_block` is the fenced form). */
|
|
179
|
+
export function readSymbolSource(raw: any): { source: string; file: string; lines: string } {
|
|
180
|
+
return {
|
|
181
|
+
source: String(raw?.source ?? ""),
|
|
182
|
+
file: String(raw?.virtual_file_path ?? ""),
|
|
183
|
+
lines: `${num(raw, "start_line")}-${num(raw, "end_line")}`,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export interface SearchHitWithOrigin {
|
|
188
|
+
fqn: string;
|
|
189
|
+
score: number;
|
|
190
|
+
origin: string;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/** `codebase_search` → hits with their origin; a hit without fqn is dropped. The
|
|
194
|
+
* origin is read on the same raw hit, so a dropped hit cannot shift the others. */
|
|
195
|
+
export function readSearchHitsWithOrigin(raw: any): SearchHitWithOrigin[] {
|
|
196
|
+
return arr(raw, "hits").map((h) => ({
|
|
197
|
+
fqn: String(h?.fqn ?? ""), score: Number(h?.score ?? 0), origin: readMatchOrigin(h),
|
|
198
|
+
})).filter((h) => h.fqn.length > 0);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/** The longest first line a location keeps: enough to recognise a declaration. */
|
|
202
|
+
const FIRST_LINE_MAX = 160;
|
|
203
|
+
|
|
204
|
+
/** `symbol_source` → path, lines, language and the first non-blank source line
|
|
205
|
+
* (at most 160 characters). The live payload carries no `fqn`: the requested one
|
|
206
|
+
* stands in when the field is absent or empty. */
|
|
207
|
+
export function readSymbolLocation(raw: any, requestedFqn: string): {
|
|
208
|
+
fqn: string; path: string; startLine: number; endLine: number; language: string; firstLine: string;
|
|
209
|
+
} {
|
|
210
|
+
const fqn = String(raw?.fqn ?? "");
|
|
211
|
+
const first = String(raw?.source ?? "").split("\n").map((l) => l.trim()).find((l) => l.length > 0) ?? "";
|
|
212
|
+
return {
|
|
213
|
+
fqn: fqn.length > 0 ? fqn : requestedFqn,
|
|
214
|
+
path: String(raw?.virtual_file_path ?? ""),
|
|
215
|
+
startLine: num(raw, "start_line"),
|
|
216
|
+
endLine: num(raw, "end_line"),
|
|
217
|
+
language: String(raw?.language ?? ""),
|
|
218
|
+
firstLine: first.slice(0, FIRST_LINE_MAX),
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/** `flow_trace` → `paths[]`, NOT `edges[]`. An empty array is a valid answer. */
|
|
223
|
+
export function readFlowPathCount(raw: any): number {
|
|
224
|
+
return arr(raw, "paths").length;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* The FQN to use for the symbol-level probes: taken from the map rather than
|
|
229
|
+
* invented, so the probe works on any mounted codebase. "" when the map is empty —
|
|
230
|
+
* the caller must then report a SKIP, not a pass on a query that asked nothing.
|
|
231
|
+
*/
|
|
232
|
+
export function firstSymbolFqn(mapRaw: any): string {
|
|
233
|
+
return readMapEntries(mapRaw)[0]?.fqn ?? "";
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// ── The analysis five (pinned from the extended probe's live run, 2026-08-06) ──
|
|
237
|
+
|
|
238
|
+
/** One cycle of the graph, as dependency_graph names it (Orkeon #272): its members' FQNs, sorted and capped by
|
|
239
|
+
* `max_cycle_members`, and its full size. */
|
|
240
|
+
export interface GraphCycle {
|
|
241
|
+
members: string[];
|
|
242
|
+
memberCount: number;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export interface GraphSummary {
|
|
246
|
+
nodes: Array<{ fqn: string; name: string; kind: string }>;
|
|
247
|
+
edges: Array<{ from: string; to: string; kind: string }>;
|
|
248
|
+
nodeCount: number;
|
|
249
|
+
edgeCount: number;
|
|
250
|
+
cycleCount: number;
|
|
251
|
+
/** The cycles named, the largest first (`max_cycles`); none on sub_graph or a runtime before #273. */
|
|
252
|
+
cycles: GraphCycle[];
|
|
253
|
+
/** True when the index cut the list of cycles or the members of one. */
|
|
254
|
+
cyclesTruncated: boolean;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/** `dependency_graph` / `sub_graph` → `nodes[] {fqn,name,kind}` + `edges[] {from,to,kind}`.
|
|
258
|
+
* dependency_graph additionally carries `metrics {node_count, edge_count, cycle_count}` and, since
|
|
259
|
+
* Orkeon #273, `cycles[] {fqns, member_count}` with `cycles_truncated`; sub_graph has no metrics block,
|
|
260
|
+
* so the counts fall back to the array lengths, and names no cycle.
|
|
261
|
+
* Two quirks pinned from the live capture (2026-08-06):
|
|
262
|
+
* • edge `kind` serialized as a NUMBER (the C# EdgeKind flags value, 1 = Imports) until
|
|
263
|
+
* Orkeon #275, and since as snake_case names ("imports, calls"); node `kind` is a
|
|
264
|
+
* string ("module") — both coerced to string here;
|
|
265
|
+
* • edge `from`/`to` are node IDs ("/path#module@0"), NOT the nodes' `fqn` —
|
|
266
|
+
* joining edges to nodes needs the ID prefix, not equality. */
|
|
267
|
+
export function readGraph(raw: any): GraphSummary {
|
|
268
|
+
const nodes = arr(raw, "nodes").map((n) => ({
|
|
269
|
+
fqn: String(n?.fqn ?? ""), name: String(n?.name ?? ""), kind: String(n?.kind ?? ""),
|
|
270
|
+
})).filter((n) => n.fqn.length > 0);
|
|
271
|
+
const edges = arr(raw, "edges").map((e) => ({
|
|
272
|
+
from: String(e?.from ?? ""), to: String(e?.to ?? ""), kind: String(e?.kind ?? ""),
|
|
273
|
+
})).filter((e) => e.from.length > 0 && e.to.length > 0);
|
|
274
|
+
const metrics = raw?.metrics;
|
|
275
|
+
const cycles = arr(raw, "cycles").map((c) => {
|
|
276
|
+
const members = arr(c, "fqns").map((m) => String(m ?? "")).filter((m) => m.length > 0);
|
|
277
|
+
return { members, memberCount: Math.max(num(c, "member_count"), members.length) };
|
|
278
|
+
}).filter((c) => c.members.length > 0);
|
|
279
|
+
return {
|
|
280
|
+
nodes,
|
|
281
|
+
edges,
|
|
282
|
+
nodeCount: metrics ? num(metrics, "node_count") : nodes.length,
|
|
283
|
+
edgeCount: metrics ? num(metrics, "edge_count") : edges.length,
|
|
284
|
+
cycleCount: metrics ? num(metrics, "cycle_count") : 0,
|
|
285
|
+
cycles,
|
|
286
|
+
cyclesTruncated: raw?.cycles_truncated === true,
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
export interface ImpactSummary {
|
|
291
|
+
target: string;
|
|
292
|
+
direct: string[];
|
|
293
|
+
transitive: string[];
|
|
294
|
+
byPackage: Record<string, number>;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/** `impact_analysis` → `direct_impact[]` / `transitive_impact[]` / `by_package{}`. */
|
|
298
|
+
export function readImpact(raw: any): ImpactSummary {
|
|
299
|
+
const byPackage: Record<string, number> = {};
|
|
300
|
+
const bp = raw?.by_package;
|
|
301
|
+
if (bp && typeof bp === "object" && !Array.isArray(bp)) {
|
|
302
|
+
for (const k of Object.keys(bp)) byPackage[k] = Number(bp[k] ?? 0) || 0;
|
|
303
|
+
}
|
|
304
|
+
return {
|
|
305
|
+
target: String(raw?.target ?? ""),
|
|
306
|
+
direct: arr(raw, "direct_impact").map((s) => String(s)),
|
|
307
|
+
transitive: arr(raw, "transitive_impact").map((s) => String(s)),
|
|
308
|
+
byPackage,
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export interface PackageSummary {
|
|
313
|
+
fqn: string;
|
|
314
|
+
name: string;
|
|
315
|
+
files: number;
|
|
316
|
+
symbols: number;
|
|
317
|
+
dependencies: string[];
|
|
318
|
+
/** `public_exports`: FQNs of the package's public symbols, at most 50, in the index's order. */
|
|
319
|
+
exports: string[];
|
|
320
|
+
/** `entry_points`: FQNs of the modules named after main, program or index. */
|
|
321
|
+
entryPoints: string[];
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/** `package_summary` → `file_count`/`symbol_count` (the index_codebase naming, not files_indexed). */
|
|
325
|
+
export function readPackageSummary(raw: any): PackageSummary {
|
|
326
|
+
return {
|
|
327
|
+
fqn: String(raw?.fqn ?? ""),
|
|
328
|
+
name: String(raw?.name ?? ""),
|
|
329
|
+
files: num(raw, "file_count"),
|
|
330
|
+
symbols: num(raw, "symbol_count"),
|
|
331
|
+
dependencies: arr(raw, "dependencies").map((s) => String(s)),
|
|
332
|
+
exports: arr(raw, "public_exports").map((s) => String(s)),
|
|
333
|
+
entryPoints: arr(raw, "entry_points").map((s) => String(s)),
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
export interface SymbolDetail {
|
|
338
|
+
fqn: string;
|
|
339
|
+
name: string;
|
|
340
|
+
kind: string;
|
|
341
|
+
signature: string;
|
|
342
|
+
callers: number;
|
|
343
|
+
callees: number;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/** `symbol_detail` → identity + `signature` + `top_callers[]`/`top_callees[]`. */
|
|
347
|
+
export function readSymbolDetail(raw: any): SymbolDetail {
|
|
348
|
+
return {
|
|
349
|
+
fqn: String(raw?.fqn ?? ""),
|
|
350
|
+
name: String(raw?.name ?? ""),
|
|
351
|
+
kind: String(raw?.kind ?? ""),
|
|
352
|
+
signature: String(raw?.signature ?? ""),
|
|
353
|
+
callers: arr(raw, "top_callers").length,
|
|
354
|
+
callees: arr(raw, "top_callees").length,
|
|
355
|
+
};
|
|
356
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// Which code-intelligence tool answers which question: pure, no IO.
|
|
2
|
+
//
|
|
3
|
+
// An agent handed the analysis tools with no rule of use answers a structural question ("every base class",
|
|
4
|
+
// "who inherits X") the way it knows best: a shell script of regular expressions over the files, slower than the
|
|
5
|
+
// index and blind to what the index has already resolved. This module states, per question, the tool that answers
|
|
6
|
+
// it and the parameter that makes it answer (the edge kind, the direction, the expansion), and nothing about a tool
|
|
7
|
+
// the agent was not given: each line is emitted only when every tool it names is in the agent's list.
|
|
8
|
+
//
|
|
9
|
+
// Parameter names and values are Orkeon's wire names as its schemas publish them (snake_case; `inherits` stands for
|
|
10
|
+
// extends and implements on the graph tools and edge_list; `expand` takes the PascalCase flags, `Inheritance` giving a
|
|
11
|
+
// type's bases and what derives from it since Orkeon #280). code-intel-contract.ts pins the parameter names.
|
|
12
|
+
|
|
13
|
+
/** One question and the tool that answers it: emitted when the agent holds every tool of `tools`. */
|
|
14
|
+
interface RoutingLine {
|
|
15
|
+
readonly tools: readonly string[];
|
|
16
|
+
readonly text: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const ROUTING_LINES: readonly RoutingLine[] = [
|
|
20
|
+
{
|
|
21
|
+
tools: ["codebase_map"],
|
|
22
|
+
text: "the repository's shape: `codebase_map` (level `L1_Package` first)",
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
tools: ["package_summary"],
|
|
26
|
+
text: "what one package holds and exposes: `package_summary(fqn)`",
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
tools: ["codebase_search"],
|
|
30
|
+
text: "a symbol by name or meaning: `codebase_search(query)`, `filter_kinds: [\"Class\"]` for one kind",
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
tools: ["symbol_detail"],
|
|
34
|
+
text: "one type's bases and what derives from or implements it: `symbol_detail(fqn, expand: \"Inheritance\")`; " +
|
|
35
|
+
"its callers: `expand: \"Callers\"`",
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
tools: ["sub_graph"],
|
|
39
|
+
text: "who calls or extends a symbol, over hops: `sub_graph(seeds: [fqn], direction: \"Backward\", " +
|
|
40
|
+
"edge_kinds: [\"calls\"])` or `[\"inherits\"]`",
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
tools: ["edge_list"],
|
|
44
|
+
text: "every edge of one kind, across the index or under a `root_fqn` (every base class, implementation or " +
|
|
45
|
+
"import): `edge_list(edge_kinds: [\"inherits\"])`, paged by `next_cursor`, `total` counts them",
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
tools: ["flow_trace"],
|
|
49
|
+
text: "a call chain over several hops from one symbol: `flow_trace(from, direction)`, `Forward`, `Backward` " +
|
|
50
|
+
"or `Both`",
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
tools: ["impact_analysis"],
|
|
54
|
+
text: "what breaks if a symbol changes: `impact_analysis(target)`",
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
tools: ["affected_tests"],
|
|
58
|
+
text: "the tests a change concerns: `affected_tests(changed_files)`, or `base` for a git ref",
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
tools: ["dependency_graph"],
|
|
62
|
+
text: "how packages or modules depend on each other: `dependency_graph` (scope `L1_Package`, `L2_Module`)",
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
tools: ["structural_search"],
|
|
66
|
+
text: "every place a code shape occurs (an await inside a loop): `structural_search` with its `language`",
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
tools: ["count_pattern"],
|
|
70
|
+
text: "how many times a text occurs in a file: `count_pattern`",
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
tools: ["grep"],
|
|
74
|
+
text: "a text across many files: `grep` with a `glob` (`output_mode: \"count\"` for how many)",
|
|
75
|
+
},
|
|
76
|
+
];
|
|
77
|
+
|
|
78
|
+
/** The analysis tools whose answer can be cut: an agent holding one gets the exhaustiveness rule. */
|
|
79
|
+
const BOUNDED_TOOLS: readonly string[] = [
|
|
80
|
+
"codebase_map", "codebase_search", "dependency_graph", "grep", "structural_search", "sub_graph",
|
|
81
|
+
];
|
|
82
|
+
|
|
83
|
+
/** The analysis tools that take a `root_fqn`, the subtree they answer for: the rule names it only to their holder. */
|
|
84
|
+
const ROOT_FQN_TOOLS: readonly string[] = ["codebase_map", "dependency_graph", "edge_list"];
|
|
85
|
+
|
|
86
|
+
/** The agent's shell, the tool a script over the files would run in: the rules speak of scripting only to its holder. */
|
|
87
|
+
const SHELL_TOOL = "shell_command";
|
|
88
|
+
|
|
89
|
+
/** The exhaustiveness rule; `shell` adds the script it replaces, for an agent that could write one; `rootFqn` names
|
|
90
|
+
* the parameter that narrows to a subtree, for an agent holding a tool that takes it. */
|
|
91
|
+
function exhaustivenessRule(shell: boolean, rootFqn: boolean): string {
|
|
92
|
+
const narrowers = ["one package", ...(rootFqn ? ["a `root_fqn`"] : []), "a `glob`"].join(", ");
|
|
93
|
+
return `A result marked \`truncated\` is a sample: say so in the answer, and narrow the question (${narrowers}) to ` +
|
|
94
|
+
`see the rest${shell ? ", rather than writing a script over every file" : ""}.`;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** The question-to-tool lines for an agent holding `tools`, one line each, then the exhaustiveness rule when it
|
|
98
|
+
* applies; empty when the agent holds none of the analysis tools. Scripting is named only to an agent holding the
|
|
99
|
+
* shell, `root_fqn` only to one holding a tool that takes it. */
|
|
100
|
+
export function describeCodeIntelRouting(tools: readonly string[]): string {
|
|
101
|
+
const lines = ROUTING_LINES
|
|
102
|
+
.filter((line) => line.tools.every((tool) => tools.includes(tool)))
|
|
103
|
+
.map((line) => `- ${line.text}.`);
|
|
104
|
+
if (lines.length === 0) return "";
|
|
105
|
+
const bounded = BOUNDED_TOOLS.some((tool) => tools.includes(tool));
|
|
106
|
+
const shell = tools.includes(SHELL_TOOL);
|
|
107
|
+
const rootFqn = ROOT_FQN_TOOLS.some((tool) => tools.includes(tool));
|
|
108
|
+
return [
|
|
109
|
+
shell ? "Ask the index before reading or scripting, by question:" : "Ask the index before reading, by question:",
|
|
110
|
+
...lines,
|
|
111
|
+
...(bounded ? [exhaustivenessRule(shell, rootFqn)] : []),
|
|
112
|
+
].join("\n");
|
|
113
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// The outcome of one compaction attempt, and the line that reports it. Pure — no IO.
|
|
2
|
+
// The pipeline (shared/application/compaction/) returns it, the main-loop circuit
|
|
3
|
+
// breaker counts its status, and the session-compact crew prints its line.
|
|
4
|
+
|
|
5
|
+
/** Status of one compaction attempt; the main-loop circuit breaker counts the
|
|
6
|
+
* consecutive `failed` ones. */
|
|
7
|
+
export type CompactStatus = "skipped" | "compacted" | "failed";
|
|
8
|
+
|
|
9
|
+
/** Outcome of one compaction attempt — a value, never an exception (the
|
|
10
|
+
* main-loop circuit breaker consumes `status`). */
|
|
11
|
+
export interface CompactOutcome {
|
|
12
|
+
status: CompactStatus;
|
|
13
|
+
reason?: string;
|
|
14
|
+
before?: number;
|
|
15
|
+
after?: number;
|
|
16
|
+
usedTokens?: number;
|
|
17
|
+
/** A failed summary whose buffer was snipped instead: the earlier turns removed without a summary. */
|
|
18
|
+
fallback?: "snip";
|
|
19
|
+
/** The state file written before the compaction (a dev batch in progress), or why none was. */
|
|
20
|
+
state?: { path: string } | { skipped: string };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Human-readable outcome line (session-compact crew output / logs). */
|
|
24
|
+
export function formatOutcome(o: CompactOutcome): string {
|
|
25
|
+
return outcomeLine(o) + stateLine(o);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function stateLine(o: CompactOutcome): string {
|
|
29
|
+
if (o.state === undefined) return "";
|
|
30
|
+
return "path" in o.state ? `\nstate of the batch in progress: ${o.state.path}` : `\nno state file written: ${o.state.skipped}`;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function outcomeLine(o: CompactOutcome): string {
|
|
34
|
+
switch (o.status) {
|
|
35
|
+
case "compacted":
|
|
36
|
+
return `✓ compacted ${o.before} → ${o.after} messages` +
|
|
37
|
+
(o.usedTokens !== undefined ? ` (was ~${o.usedTokens} tokens)` : "");
|
|
38
|
+
case "skipped":
|
|
39
|
+
return o.reason === "buffer too small" ? "Buffer too small to compact." : `Compaction skipped (${o.reason}).`;
|
|
40
|
+
default:
|
|
41
|
+
return `Compaction failed: ${o.reason}` +
|
|
42
|
+
(o.fallback === "snip" ? "\nThe buffer was snipped instead: the earlier turns were removed without a summary." : "");
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
// Compaction thresholds and budgets — pure constants and the trigger math.
|
|
2
|
+
//
|
|
3
|
+
// Every number is derived from a fact of this project, stated next to it: the
|
|
4
|
+
// runtime's cut of a file_read result, the answer size of the example settings,
|
|
5
|
+
// the ceiling of the main loop's header, the skills block's cap. Change the fact
|
|
6
|
+
// and the number follows; a number with no such reason does not belong here.
|
|
7
|
+
//
|
|
8
|
+
// Run tests: node --test src/shared/domain/compaction-thresholds.test.ts
|
|
9
|
+
|
|
10
|
+
/** chars→tokens heuristic shared with the token_budget tool. */
|
|
11
|
+
export const CHARS_PER_TOKEN = 4;
|
|
12
|
+
|
|
13
|
+
/** The largest single tool result a turn receives: the runtime cuts a file_read
|
|
14
|
+
* result at 32 000 characters. */
|
|
15
|
+
export const FILE_READ_CUT_TOKENS = 32_000 / CHARS_PER_TOKEN;
|
|
16
|
+
|
|
17
|
+
/** The longest answer a turn may write: `Llm:MaxTokens` of config/appsettings.example.json. */
|
|
18
|
+
export const ANSWER_RESERVE_TOKENS = 24_576;
|
|
19
|
+
|
|
20
|
+
/** The parts of a turn that are not the history: the system header (at most
|
|
21
|
+
* 9 500 characters, MAX_STATIC_HEADER_CHARS) and the user body's fixed blocks,
|
|
22
|
+
* rounded up. */
|
|
23
|
+
export const TURN_FIXED_TOKENS = 4_000;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Room a turn needs above the buffer it starts from: its fixed parts, one file
|
|
27
|
+
* read at the runtime's cut and an answer at the example settings' size.
|
|
28
|
+
* Compaction triggers when the buffer leaves less room than that.
|
|
29
|
+
*/
|
|
30
|
+
export const AUTOCOMPACT_BUFFER_TOKENS = TURN_FIXED_TOKENS + FILE_READ_CUT_TOKENS + ANSWER_RESERVE_TOKENS;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The window assumed when token_budget reports none. Erring small is the safe
|
|
34
|
+
* side: an underestimate compacts early, an overestimate overflows. 128 000
|
|
35
|
+
* tokens is a window most current chat models offer.
|
|
36
|
+
*/
|
|
37
|
+
export const DEFAULT_CONTEXT_WINDOW = 128_000;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Failed compactions in a row before the breaker opens. One failure can be a
|
|
41
|
+
* provider hiccup; several in a row mean the summary call itself is broken, and
|
|
42
|
+
* retrying it at the head and the tail of every turn would triple each turn's cost.
|
|
43
|
+
*/
|
|
44
|
+
export const MAX_CONSECUTIVE_FAILURES = 3;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The transcript fed to the summary and to the memory extraction, in characters
|
|
48
|
+
* (12 000 tokens). With the instructions and a summary at its word cap it fits any
|
|
49
|
+
* window this code assumes, and cut in the middle (head and tail kept) it still
|
|
50
|
+
* holds the task and the current work of a long session.
|
|
51
|
+
*/
|
|
52
|
+
export const TRANSCRIPT_CAP_CHARS = 48_000;
|
|
53
|
+
|
|
54
|
+
/** Turns the fallback of a failed summary keeps, besides the head: a turn is a user request with the tool traces and
|
|
55
|
+
* the answer that follow it, kept whole (Orkeon #287). Two, below the runtime's default of three: the snip runs with
|
|
56
|
+
* the window past the trigger, where three whole turns may free little; two keep the exchange a short reply answers
|
|
57
|
+
* ("yes, do it") with the request still waiting at the head of a turn, about what the five messages kept before #287.
|
|
58
|
+
* `/compact --snip` keeps SNIP_COMMAND_TURNS unless told otherwise. */
|
|
59
|
+
export const SNIP_RETAIN_COUNT = 2;
|
|
60
|
+
|
|
61
|
+
/** Turns `/compact --snip` keeps whole when it names no count: three, the runtime's own default (Orkeon #287). */
|
|
62
|
+
export const SNIP_COMMAND_TURNS = 3;
|
|
63
|
+
|
|
64
|
+
/** Facts extracted per compaction: a session yields a handful of durable facts;
|
|
65
|
+
* more is task state passing for memory. */
|
|
66
|
+
export const MAX_EXTRACTED_MEMORIES = 8;
|
|
67
|
+
|
|
68
|
+
// ── After a compaction: files and skills read back ──────────────────────
|
|
69
|
+
|
|
70
|
+
/** Files read back after a compaction, the most recently named first: the
|
|
71
|
+
* current step's file and a few it depends on. Anything older the agent reads
|
|
72
|
+
* again when it needs it. */
|
|
73
|
+
export const POST_COMPACT_MAX_FILES_TO_RESTORE = 5;
|
|
74
|
+
|
|
75
|
+
/** Largest file read back whole (20 000 characters, inside file_read's cut). A
|
|
76
|
+
* larger file comes back as its path with a note to read it, never cut: a cut
|
|
77
|
+
* copy could feed a whole-file write and erase the rest. */
|
|
78
|
+
export const POST_COMPACT_PER_FILE_TOKENS = 5_000;
|
|
79
|
+
|
|
80
|
+
/** Token budget for all restored files together: bounded by construction. */
|
|
81
|
+
export const POST_COMPACT_TOKEN_BUDGET = POST_COMPACT_MAX_FILES_TO_RESTORE * POST_COMPACT_PER_FILE_TOKENS;
|
|
82
|
+
|
|
83
|
+
/** A skill read back after a compaction is capped like the skills block of a turn
|
|
84
|
+
* (4 000 characters, MAX_SKILL_FRAGMENT_CHARS), so the copy is never longer than
|
|
85
|
+
* what the turn shows. */
|
|
86
|
+
export const POST_COMPACT_PER_SKILL_TOKENS = 1_000;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Skills read back after a compaction get their OWN budget, five skills at their
|
|
90
|
+
* cap, separate from the files'. The two restores serve different reasons: files
|
|
91
|
+
* are what the agent was just touching, skills are what the operator decided
|
|
92
|
+
* should always apply. Sharing one budget would let a handful of large files
|
|
93
|
+
* silently evict every playbook — the failure would look like "the agent forgot
|
|
94
|
+
* the rules after a compaction".
|
|
95
|
+
*/
|
|
96
|
+
export const POST_COMPACT_SKILLS_TOKEN_BUDGET = 5 * POST_COMPACT_PER_SKILL_TOKENS;
|
|
97
|
+
|
|
98
|
+
// ── Pressure tiers ──────────────────────────────────────────────────────
|
|
99
|
+
|
|
100
|
+
/** Warning tier: the room left is below what a turn needs. Compaction is due; if
|
|
101
|
+
* it could not run (the breaker is open), the turn must wind down. */
|
|
102
|
+
export const WARNING_THRESHOLD_BUFFER_TOKENS = AUTOCOMPACT_BUFFER_TOKENS;
|
|
103
|
+
|
|
104
|
+
/** Error tier: one more file read at the runtime's cut could overflow the window. */
|
|
105
|
+
export const ERROR_THRESHOLD_BUFFER_TOKENS = FILE_READ_CUT_TOKENS;
|
|
106
|
+
|
|
107
|
+
/** Normalise a possibly-unreported window to the default (shared by the tiers). */
|
|
108
|
+
function effectiveWindow(contextWindow: number): number {
|
|
109
|
+
return contextWindow > 0 ? contextWindow : DEFAULT_CONTEXT_WINDOW;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** The setting that moves the automatic compaction's trigger (`/config set compaction.trigger 90k`). */
|
|
113
|
+
export const COMPACTION_TRIGGER_CONFIG_KEY = "compaction.trigger";
|
|
114
|
+
|
|
115
|
+
/** A token count as the setting writes it: `90000` or `90k`; undefined when it is not one. */
|
|
116
|
+
export function parseTokenCount(value: unknown): number | undefined {
|
|
117
|
+
const m = /^\s*(\d+(?:\.\d+)?)\s*(k)?\s*$/i.exec(String(value ?? ""));
|
|
118
|
+
if (!m) return undefined;
|
|
119
|
+
const n = Math.round(Number(m[1]) * (m[2] ? 1_000 : 1));
|
|
120
|
+
return n > 0 ? n : undefined;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** Why a compaction.trigger value is refused; undefined when it is a token count. */
|
|
124
|
+
export function compactionTriggerProblem(value: string): string | undefined {
|
|
125
|
+
return parseTokenCount(value) === undefined ? "a token count such as 90000 or 90k" : undefined;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Token count at which auto-compaction triggers for a given window: the
|
|
129
|
+
* `compaction.trigger` setting when one is given, else the window minus the buffer. */
|
|
130
|
+
export function computeTrigger(contextWindow: number, trigger?: number): number {
|
|
131
|
+
if (trigger !== undefined && trigger > 0) return trigger;
|
|
132
|
+
return effectiveWindow(contextWindow) - AUTOCOMPACT_BUFFER_TOKENS;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** True when the used tokens have reached the trigger (equality counts). */
|
|
136
|
+
export function shouldCompact(usedTokens: number, contextWindow: number, trigger?: number): boolean {
|
|
137
|
+
return usedTokens >= computeTrigger(contextWindow, trigger);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** Warning tier reached: used ≥ window − WARNING_THRESHOLD_BUFFER_TOKENS. */
|
|
141
|
+
export function isAboveWarningThreshold(usedTokens: number, contextWindow: number): boolean {
|
|
142
|
+
return usedTokens >= effectiveWindow(contextWindow) - WARNING_THRESHOLD_BUFFER_TOKENS;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Error tier reached: used ≥ window − ERROR_THRESHOLD_BUFFER_TOKENS. */
|
|
146
|
+
export function isAboveErrorThreshold(usedTokens: number, contextWindow: number): boolean {
|
|
147
|
+
return usedTokens >= effectiveWindow(contextWindow) - ERROR_THRESHOLD_BUFFER_TOKENS;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** Percentage of the window still free, clamped to [0, 100]. */
|
|
151
|
+
export function percentLeft(usedTokens: number, contextWindow: number): number {
|
|
152
|
+
const window = effectiveWindow(contextWindow);
|
|
153
|
+
return Math.max(0, Math.min(100, Math.round(100 * (window - usedTokens) / window)));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** The graduated pressure tier (`/context`, `/usage`, the turn's gauge): ok | warning | error. */
|
|
157
|
+
export function pressureTier(usedTokens: number, contextWindow: number): "ok" | "warning" | "error" {
|
|
158
|
+
if (isAboveErrorThreshold(usedTokens, contextWindow)) return "error";
|
|
159
|
+
if (isAboveWarningThreshold(usedTokens, contextWindow)) return "warning";
|
|
160
|
+
return "ok";
|
|
161
|
+
}
|