orkeon-code 0.0.0-stage → 1.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.orkeon-runtime +10 -0
- package/.orkeon-version +1 -0
- package/LICENSE.md +21 -0
- package/NOTICE.md +17 -0
- package/README.fr.md +163 -0
- package/README.md +156 -2
- package/config/appsettings.anthropic.example.json +77 -0
- package/config/appsettings.example.json +71 -0
- package/config/appsettings.jev.example.json +131 -0
- package/config/appsettings.kev.example.json +133 -0
- package/config/appsettings.liquid.example.json +132 -0
- package/config/appsettings.ollama-whisper.example.json +93 -0
- package/config/appsettings.ollama.example.json +70 -0
- package/config/appsettings.whisper.example.json +32 -0
- package/mcp/whisper/README.md +294 -0
- package/mcp/whisper/pyproject.toml +32 -0
- package/mcp/whisper/uv.lock +1641 -0
- package/mcp/whisper/whisper_mcp.py +1053 -0
- package/orkeon-code +1092 -0
- package/orkeon-code.mjs +71 -0
- package/orkeon-code.ps1 +939 -0
- package/package.json +58 -4
- package/scripts/install.ps1 +156 -0
- package/scripts/install.sh +148 -0
- package/scripts/session-start.ork.ts +90 -0
- package/scripts/session-start.sh +74 -0
- package/scripts/setup-fixture.sh +88 -0
- package/src/commands/.orkeon/orkeon-cli.d.ts +559 -0
- package/src/commands/_lib/args.ts +194 -0
- package/src/commands/_lib/dev/dev-batches.ts +366 -0
- package/src/commands/_lib/dev/dev-implement.ts +185 -0
- package/src/commands/_lib/dev/dev-source.ts +61 -0
- package/src/commands/_lib/dev/dev.ts +341 -0
- package/src/commands/_lib/dev/markers.ts +7 -0
- package/src/commands/_lib/dev/messages.ts +112 -0
- package/src/commands/_lib/dev-step.ts +145 -0
- package/src/commands/_lib/dispatch.ts +254 -0
- package/src/commands/_lib/effort.ts +15 -0
- package/src/commands/_lib/git/branch.ts +94 -0
- package/src/commands/_lib/git/commit.ts +90 -0
- package/src/commands/_lib/git/diff.ts +107 -0
- package/src/commands/_lib/git/messages.ts +54 -0
- package/src/commands/_lib/git/review.ts +108 -0
- package/src/commands/_lib/memory/memory-admit.ts +148 -0
- package/src/commands/_lib/memory/memory.ts +52 -0
- package/src/commands/_lib/memory/messages.ts +32 -0
- package/src/commands/_lib/messages.ts +48 -0
- package/src/commands/_lib/pr-context.ts +32 -0
- package/src/commands/_lib/project/analyze.ts +24 -0
- package/src/commands/_lib/project/messages.ts +8 -0
- package/src/commands/_lib/session/export.ts +105 -0
- package/src/commands/_lib/session/messages.ts +87 -0
- package/src/commands/_lib/session/prompts.ts +4 -0
- package/src/commands/_lib/session/resume.ts +151 -0
- package/src/commands/_lib/session/tasks.ts +181 -0
- package/src/commands/_lib/settings/advisor.ts +75 -0
- package/src/commands/_lib/settings/agents.ts +137 -0
- package/src/commands/_lib/settings/choices.ts +8 -0
- package/src/commands/_lib/settings/config.ts +141 -0
- package/src/commands/_lib/settings/effort.ts +147 -0
- package/src/commands/_lib/settings/hooks.ts +50 -0
- package/src/commands/_lib/settings/messages.ts +408 -0
- package/src/commands/_lib/settings/mode.ts +100 -0
- package/src/commands/_lib/settings/model.ts +181 -0
- package/src/commands/_lib/settings/output-style.ts +39 -0
- package/src/commands/_lib/settings/permissions.ts +287 -0
- package/src/commands/_lib/settings/route.ts +63 -0
- package/src/commands/_lib/settings/session-config.ts +49 -0
- package/src/commands/_lib/settings/skills.ts +93 -0
- package/src/commands/_lib/settings/theme.ts +42 -0
- package/src/commands/_lib/speech/messages.ts +58 -0
- package/src/commands/_lib/speech/prompts.ts +4 -0
- package/src/commands/_lib/speech/say.ts +95 -0
- package/src/commands/_lib/speech/transcribe.ts +121 -0
- package/src/commands/_lib/speech/voice.ts +142 -0
- package/src/commands/_lib/status/cache.ts +31 -0
- package/src/commands/_lib/status/context.ts +57 -0
- package/src/commands/_lib/status/doctor.ts +205 -0
- package/src/commands/_lib/status/messages.ts +100 -0
- package/src/commands/_lib/status/meta.ts +24 -0
- package/src/commands/_lib/status/status.ts +128 -0
- package/src/commands/_lib/status/usage-tools.ts +48 -0
- package/src/commands/_lib/status/usage.ts +128 -0
- package/src/commands/_lib/view.ts +34 -0
- package/src/commands/dev/dev-batches.cmd.ts +109 -0
- package/src/commands/dev/dev-learn.cmd.ts +29 -0
- package/src/commands/dev/dev-plan.cmd.ts +51 -0
- package/src/commands/dev/dev-spec.cmd.ts +54 -0
- package/src/commands/dev/dev-status.cmd.ts +16 -0
- package/src/commands/git/branch.cmd.ts +27 -0
- package/src/commands/git/commit.cmd.ts +48 -0
- package/src/commands/git/diff.cmd.ts +26 -0
- package/src/commands/git/review.cmd.ts +36 -0
- package/src/commands/memory/memory.cmd.ts +48 -0
- package/src/commands/project/analyze.cmd.ts +32 -0
- package/src/commands/project/debug-tool-call.cmd.ts +62 -0
- package/src/commands/project/files.cmd.ts +22 -0
- package/src/commands/project/init-verifiers.cmd.ts +14 -0
- package/src/commands/project/init.cmd.ts +14 -0
- package/src/commands/project/verify.cmd.ts +27 -0
- package/src/commands/session/assistant.cmd.ts +40 -0
- package/src/commands/session/btw.cmd.ts +18 -0
- package/src/commands/session/clear.cmd.ts +19 -0
- package/src/commands/session/compact.cmd.ts +16 -0
- package/src/commands/session/copy.cmd.ts +45 -0
- package/src/commands/session/exit.cmd.ts +9 -0
- package/src/commands/session/export.cmd.ts +28 -0
- package/src/commands/session/rename.cmd.ts +18 -0
- package/src/commands/session/resume.cmd.ts +19 -0
- package/src/commands/session/rewind.cmd.ts +25 -0
- package/src/commands/session/summary.cmd.ts +27 -0
- package/src/commands/session/tasks.cmd.ts +46 -0
- package/src/commands/settings/advisor.cmd.ts +38 -0
- package/src/commands/settings/agents.cmd.ts +19 -0
- package/src/commands/settings/config.cmd.ts +19 -0
- package/src/commands/settings/effort.cmd.ts +19 -0
- package/src/commands/settings/fast.cmd.ts +18 -0
- package/src/commands/settings/hooks.cmd.ts +17 -0
- package/src/commands/settings/mode.cmd.ts +20 -0
- package/src/commands/settings/model.cmd.ts +21 -0
- package/src/commands/settings/output-style.cmd.ts +19 -0
- package/src/commands/settings/permissions.cmd.ts +25 -0
- package/src/commands/settings/proactive.cmd.ts +16 -0
- package/src/commands/settings/route.cmd.ts +16 -0
- package/src/commands/settings/skills.cmd.ts +17 -0
- package/src/commands/settings/theme.cmd.ts +14 -0
- package/src/commands/speech/say.cmd.ts +24 -0
- package/src/commands/speech/transcribe.cmd.ts +29 -0
- package/src/commands/speech/voice.cmd.ts +30 -0
- package/src/commands/status/context.cmd.ts +18 -0
- package/src/commands/status/doctor.cmd.ts +27 -0
- package/src/commands/status/release-notes.cmd.ts +9 -0
- package/src/commands/status/status.cmd.ts +25 -0
- package/src/commands/status/usage.cmd.ts +21 -0
- package/src/crews/.orkeon/orkeon.d.ts +4391 -0
- package/src/crews/_probe-shared-memory/domain/messages.ts +54 -0
- package/src/crews/_probe-shared-memory/domain/probe-verdict.ts +188 -0
- package/src/crews/_probe-shared-memory/domain/prompts.ts +5 -0
- package/src/crews/_probe-shared-memory/probe.ork.ts +100 -0
- package/src/crews/advisor/application/messages.ts +4 -0
- package/src/crews/advisor/application/prompts.ts +4 -0
- package/src/crews/advisor/application/run-advisor.ts +41 -0
- package/src/crews/advisor/crew.ork.ts +44 -0
- package/src/crews/advisor/domain/advice.ts +119 -0
- package/src/crews/advisor/domain/messages.ts +8 -0
- package/src/crews/advisor/domain/prompts.ts +26 -0
- package/src/crews/agent-run/application/messages.ts +18 -0
- package/src/crews/agent-run/application/run-agent-run.ts +43 -0
- package/src/crews/agent-run/crew.ork.ts +67 -0
- package/src/crews/analyze/application/messages.ts +27 -0
- package/src/crews/analyze/application/prompts.ts +4 -0
- package/src/crews/analyze/application/run-analyze.ts +120 -0
- package/src/crews/analyze/crew.ork.ts +41 -0
- package/src/crews/analyze/domain/harvest.ts +269 -0
- package/src/crews/analyze/domain/prompts.ts +86 -0
- package/src/crews/code-review/application/lens-material.ts +24 -0
- package/src/crews/code-review/application/messages.ts +17 -0
- package/src/crews/code-review/application/prompts.ts +126 -0
- package/src/crews/code-review/application/review.ts +74 -0
- package/src/crews/code-review/application/run-code-review.ts +121 -0
- package/src/crews/code-review/crew.ork.ts +52 -0
- package/src/crews/code-review/domain/lenses.ts +154 -0
- package/src/crews/code-review/domain/messages.ts +25 -0
- package/src/crews/code-review/domain/prompts.ts +58 -0
- package/src/crews/code-review/domain/report.ts +58 -0
- package/src/crews/code-review/domain/scope.ts +106 -0
- package/src/crews/dev-batches/application/messages.ts +127 -0
- package/src/crews/dev-batches/application/plan-close.ts +181 -0
- package/src/crews/dev-batches/application/prompts.ts +10 -0
- package/src/crews/dev-batches/application/run-dev-batches.ts +676 -0
- package/src/crews/dev-batches/application/run-wave.ts +452 -0
- package/src/crews/dev-batches/application/seed-harvest.ts +163 -0
- package/src/crews/dev-batches/crew.ork.ts +146 -0
- package/src/crews/dev-batches/domain/batch-waves.ts +70 -0
- package/src/crews/dev-batches/domain/batches-budget.ts +52 -0
- package/src/crews/dev-batches/domain/batches-log.ts +52 -0
- package/src/crews/dev-batches/domain/markers.ts +5 -0
- package/src/crews/dev-batches/domain/messages.ts +6 -0
- package/src/crews/dev-batches/domain/wave-order.ts +44 -0
- package/src/crews/dev-change/application/change-material.ts +44 -0
- package/src/crews/dev-change/application/evidence.ts +172 -0
- package/src/crews/dev-change/application/messages.ts +81 -0
- package/src/crews/dev-change/application/prompts.ts +101 -0
- package/src/crews/dev-change/application/run-dev-change.ts +324 -0
- package/src/crews/dev-change/crew.ork.ts +114 -0
- package/src/crews/dev-change/domain/change-answer.ts +163 -0
- package/src/crews/dev-change/domain/change-render.ts +77 -0
- package/src/crews/dev-change/domain/markers.ts +28 -0
- package/src/crews/dev-change/domain/messages.ts +16 -0
- package/src/crews/dev-implement/application/close.ts +186 -0
- package/src/crews/dev-implement/application/count-open-steps.ts +24 -0
- package/src/crews/dev-implement/application/locate-sheet.ts +82 -0
- package/src/crews/dev-implement/application/messages.ts +161 -0
- package/src/crews/dev-implement/application/observe.ts +52 -0
- package/src/crews/dev-implement/application/prompts.ts +9 -0
- package/src/crews/dev-implement/application/report-writes.ts +46 -0
- package/src/crews/dev-implement/application/run-dev-implement.ts +822 -0
- package/src/crews/dev-implement/application/run-role.ts +27 -0
- package/src/crews/dev-implement/application/suite-job.ts +122 -0
- package/src/crews/dev-implement/application/touched.ts +74 -0
- package/src/crews/dev-implement/crew.ork.ts +69 -0
- package/src/crews/dev-implement/domain/contracts.ts +255 -0
- package/src/crews/dev-implement/domain/correction.ts +103 -0
- package/src/crews/dev-implement/domain/cycles.ts +36 -0
- package/src/crews/dev-implement/domain/implement-budget.ts +29 -0
- package/src/crews/dev-implement/domain/markers.ts +23 -0
- package/src/crews/dev-implement/domain/messages.ts +58 -0
- package/src/crews/dev-implement/domain/prompts.ts +93 -0
- package/src/crews/dev-implement/domain/roles.ts +49 -0
- package/src/crews/dev-implement/domain/sheet-edits.ts +76 -0
- package/src/crews/dev-implement/domain/sheet-ticks.ts +23 -0
- package/src/crews/dev-implement/domain/step-checks.ts +137 -0
- package/src/crews/dev-implement/domain/step-section.ts +129 -0
- package/src/crews/dev-learn/application/learn-backlog.ts +58 -0
- package/src/crews/dev-learn/application/learn-prompt-fit.ts +63 -0
- package/src/crews/dev-learn/application/messages.ts +51 -0
- package/src/crews/dev-learn/application/prompts.ts +99 -0
- package/src/crews/dev-learn/application/run-dev-learn.ts +558 -0
- package/src/crews/dev-learn/crew.ork.ts +53 -0
- package/src/crews/dev-learn/domain/learn-answer.ts +233 -0
- package/src/crews/dev-learn/domain/messages.ts +65 -0
- package/src/crews/dev-learn/domain/owner-lines.ts +89 -0
- package/src/crews/dev-learn/domain/proposals-render.ts +95 -0
- package/src/crews/dev-plan/application/anchor-paths.ts +113 -0
- package/src/crews/dev-plan/application/inventory.ts +174 -0
- package/src/crews/dev-plan/application/messages.ts +88 -0
- package/src/crews/dev-plan/application/plan-prompt-fit.ts +44 -0
- package/src/crews/dev-plan/application/prompts.ts +141 -0
- package/src/crews/dev-plan/application/run-dev-plan.ts +483 -0
- package/src/crews/dev-plan/crew.ork.ts +112 -0
- package/src/crews/dev-plan/domain/inventory-model.ts +95 -0
- package/src/crews/dev-plan/domain/markers.ts +18 -0
- package/src/crews/dev-plan/domain/messages.ts +118 -0
- package/src/crews/dev-plan/domain/plan-answer.ts +753 -0
- package/src/crews/dev-plan/domain/plan-render.ts +306 -0
- package/src/crews/dev-plan/domain/prompts.ts +44 -0
- package/src/crews/dev-spec/application/messages.ts +30 -0
- package/src/crews/dev-spec/application/prompts.ts +93 -0
- package/src/crews/dev-spec/application/run-dev-spec.ts +237 -0
- package/src/crews/dev-spec/application/spec-material.ts +42 -0
- package/src/crews/dev-spec/crew.ork.ts +110 -0
- package/src/crews/dev-spec/domain/markers.ts +30 -0
- package/src/crews/dev-spec/domain/messages.ts +39 -0
- package/src/crews/dev-spec/domain/spec-answer.ts +252 -0
- package/src/crews/dev-spec/domain/spec-render.ts +76 -0
- package/src/crews/dev-verify/application/audit-brief.ts +187 -0
- package/src/crews/dev-verify/application/audit.ts +267 -0
- package/src/crews/dev-verify/application/capture.ts +311 -0
- package/src/crews/dev-verify/application/messages.ts +119 -0
- package/src/crews/dev-verify/application/prompts.ts +209 -0
- package/src/crews/dev-verify/application/run-dev-verify.ts +423 -0
- package/src/crews/dev-verify/application/run-gate.ts +204 -0
- package/src/crews/dev-verify/crew.ork.ts +103 -0
- package/src/crews/dev-verify/domain/audit-answer.ts +154 -0
- package/src/crews/dev-verify/domain/auditor-charter.ts +21 -0
- package/src/crews/dev-verify/domain/capture-sections.ts +138 -0
- package/src/crews/dev-verify/domain/commands.ts +103 -0
- package/src/crews/dev-verify/domain/gate.ts +131 -0
- package/src/crews/dev-verify/domain/markers.ts +16 -0
- package/src/crews/dev-verify/domain/mechanical-table.ts +156 -0
- package/src/crews/dev-verify/domain/messages.ts +92 -0
- package/src/crews/dev-verify/domain/runtime-cut.ts +13 -0
- package/src/crews/dev-verify/domain/sheet-facts.ts +4 -0
- package/src/crews/dev-verify/domain/text.ts +20 -0
- package/src/crews/dev-verify/domain/verdict.ts +127 -0
- package/src/crews/git-commit/application/draft.ts +133 -0
- package/src/crews/git-commit/application/messages.ts +15 -0
- package/src/crews/git-commit/application/prompts.ts +47 -0
- package/src/crews/git-commit/application/run-git-commit.ts +117 -0
- package/src/crews/git-commit/crew.ork.ts +53 -0
- package/src/crews/git-commit/domain/commit.ts +200 -0
- package/src/crews/git-commit/domain/markers.ts +4 -0
- package/src/crews/git-commit/domain/messages.ts +48 -0
- package/src/crews/init-verifiers/application/authoring.ts +90 -0
- package/src/crews/init-verifiers/application/messages.ts +13 -0
- package/src/crews/init-verifiers/application/prompts.ts +107 -0
- package/src/crews/init-verifiers/application/run-init-verifiers.ts +26 -0
- package/src/crews/init-verifiers/crew.ork.ts +35 -0
- package/src/crews/init-verifiers/domain/commands-section.ts +36 -0
- package/src/crews/init-verifiers/domain/readiness.ts +23 -0
- package/src/crews/main-loop/application/auto-compact.ts +78 -0
- package/src/crews/main-loop/application/context-gather.ts +133 -0
- package/src/crews/main-loop/application/messages.ts +81 -0
- package/src/crews/main-loop/application/prompts.ts +12 -0
- package/src/crews/main-loop/application/run-main-loop.ts +383 -0
- package/src/crews/main-loop/application/turn-context.ts +111 -0
- package/src/crews/main-loop/crew.ork.ts +124 -0
- package/src/crews/main-loop/domain/autocompact.ts +27 -0
- package/src/crews/main-loop/domain/prompt-assembly.ts +338 -0
- package/src/crews/main-loop/domain/prompts.ts +336 -0
- package/src/crews/main-loop/domain/turn-chains.ts +130 -0
- package/src/crews/project-init/application/detect.ts +123 -0
- package/src/crews/project-init/application/messages.ts +15 -0
- package/src/crews/project-init/application/prompts.ts +105 -0
- package/src/crews/project-init/application/run-project-init.ts +31 -0
- package/src/crews/project-init/crew.ork.ts +36 -0
- package/src/crews/project-init/domain/conventions.ts +36 -0
- package/src/crews/project-init/domain/existing-files.ts +65 -0
- package/src/crews/project-init/domain/messages.ts +13 -0
- package/src/crews/project-init/domain/package-map.ts +73 -0
- package/src/crews/project-init/domain/prompts.ts +10 -0
- package/src/crews/session-compact/application/prompts.ts +5 -0
- package/src/crews/session-compact/crew.ork.ts +56 -0
- package/src/crews/shared-memory-admit/application/prompts.ts +5 -0
- package/src/crews/shared-memory-admit/crew.ork.ts +49 -0
- package/src/crews/speech/application/messages.ts +3 -0
- package/src/crews/speech/application/prompts.ts +3 -0
- package/src/crews/speech/application/run-speech.ts +26 -0
- package/src/crews/speech/crew.ork.ts +38 -0
- package/src/shared/application/agents/child-agent.ts +259 -0
- package/src/shared/application/agents/messages.ts +35 -0
- package/src/shared/application/agents/route-agent.ts +115 -0
- package/src/shared/application/agents/run-sub-agent.ts +119 -0
- package/src/shared/application/answer-language.ts +14 -0
- package/src/shared/application/attached-skills.ts +36 -0
- package/src/shared/application/compaction/compact-session.ts +242 -0
- package/src/shared/application/compaction/extract-memories.ts +38 -0
- package/src/shared/application/compaction/messages.ts +20 -0
- package/src/shared/application/compaction/prune-context.ts +94 -0
- package/src/shared/application/compaction/pruned-llm.ts +35 -0
- package/src/shared/application/compaction/restore-context.ts +78 -0
- package/src/shared/application/config-store.ts +123 -0
- package/src/shared/application/dev/brief-inventory.ts +115 -0
- package/src/shared/application/dev/close-batch.ts +85 -0
- package/src/shared/application/dev/find-repo-pack.ts +78 -0
- package/src/shared/application/dev/learn-decision.ts +254 -0
- package/src/shared/application/dev/load-dev-context.ts +265 -0
- package/src/shared/application/dev/measure-access-cost.ts +69 -0
- package/src/shared/application/dev/messages.ts +132 -0
- package/src/shared/application/dev/phase-timer.ts +54 -0
- package/src/shared/application/dev/plan-source.ts +116 -0
- package/src/shared/application/dev/preflight.ts +71 -0
- package/src/shared/application/dev/project-files.ts +17 -0
- package/src/shared/application/dev/prompts.ts +34 -0
- package/src/shared/application/dev/question-round.ts +60 -0
- package/src/shared/application/dev/resolve-work-folder.ts +134 -0
- package/src/shared/application/dev/script-tool-slot.ts +27 -0
- package/src/shared/application/dev/settle-questions.ts +57 -0
- package/src/shared/application/dev/source-review.ts +67 -0
- package/src/shared/application/dev/source-step.ts +152 -0
- package/src/shared/application/dev/spend.ts +55 -0
- package/src/shared/application/dev/step-precedents.ts +90 -0
- package/src/shared/application/dev/tool-call-policy.ts +87 -0
- package/src/shared/application/dev/tool-callbacks.ts +262 -0
- package/src/shared/application/dev/tool-trace-recorder.ts +46 -0
- package/src/shared/application/dev/verdict-sources.ts +50 -0
- package/src/shared/application/dev/wrapped-tools.ts +147 -0
- package/src/shared/application/extra-tools.ts +71 -0
- package/src/shared/application/git/batch-worktree.ts +102 -0
- package/src/shared/application/git/commit-files.ts +191 -0
- package/src/shared/application/git/merge-batch.ts +67 -0
- package/src/shared/application/git/messages.ts +75 -0
- package/src/shared/application/git/open-pull-request.ts +52 -0
- package/src/shared/application/host-context.ts +59 -0
- package/src/shared/application/host-layout-store.ts +45 -0
- package/src/shared/application/instructions-file.ts +19 -0
- package/src/shared/application/json-file.ts +34 -0
- package/src/shared/application/llm-profile.ts +36 -0
- package/src/shared/application/messages.ts +14 -0
- package/src/shared/application/permission-rules.ts +169 -0
- package/src/shared/application/ports/approvals.ts +20 -0
- package/src/shared/application/ports/clock.ts +5 -0
- package/src/shared/application/ports/code-index.ts +93 -0
- package/src/shared/application/ports/crew.ts +60 -0
- package/src/shared/application/ports/decision.ts +14 -0
- package/src/shared/application/ports/files.ts +21 -0
- package/src/shared/application/ports/human.ts +38 -0
- package/src/shared/application/ports/llm.ts +83 -0
- package/src/shared/application/ports/memory.ts +30 -0
- package/src/shared/application/ports/progress.ts +23 -0
- package/src/shared/application/ports/runtime.ts +15 -0
- package/src/shared/application/ports/session.ts +74 -0
- package/src/shared/application/ports/shared-memory.ts +26 -0
- package/src/shared/application/ports/shell.ts +40 -0
- package/src/shared/application/ports/telemetry.ts +45 -0
- package/src/shared/application/ports/theme.ts +11 -0
- package/src/shared/application/ports/tools.ts +46 -0
- package/src/shared/application/ports/usage.ts +45 -0
- package/src/shared/application/ports.ts +29 -0
- package/src/shared/application/project-manifests.ts +106 -0
- package/src/shared/application/session-io.ts +85 -0
- package/src/shared/application/session-state.ts +36 -0
- package/src/shared/application/shared-memory/admit-entries.ts +179 -0
- package/src/shared/application/shared-memory/harvest-after-gaps.ts +69 -0
- package/src/shared/application/shared-memory/harvest-mistakes.ts +45 -0
- package/src/shared/application/shared-memory/import-agent-memory.ts +119 -0
- package/src/shared/application/shared-memory/memory-files.ts +111 -0
- package/src/shared/application/shared-memory/memory-settings.ts +94 -0
- package/src/shared/application/shared-memory/messages.ts +63 -0
- package/src/shared/application/shared-memory/push-candidate.ts +149 -0
- package/src/shared/application/shared-memory/recall-precedents.ts +70 -0
- package/src/shared/application/skills/messages.ts +4 -0
- package/src/shared/application/skills/suggest-skills.ts +102 -0
- package/src/shared/application/state-snapshot.ts +38 -0
- package/src/shared/application/workflow/messages.ts +8 -0
- package/src/shared/application/workflow/workflow-state.ts +136 -0
- package/src/shared/domain/agent-policy/behavior-flags.ts +162 -0
- package/src/shared/domain/agent-policy/extra-tools.ts +67 -0
- package/src/shared/domain/agent-policy/memory-categories.ts +6 -0
- package/src/shared/domain/agent-policy/messages.ts +66 -0
- package/src/shared/domain/agent-policy/mode-policy.ts +51 -0
- package/src/shared/domain/agent-policy/output-styles.ts +11 -0
- package/src/shared/domain/agent-policy/path-rules.ts +299 -0
- package/src/shared/domain/agent-policy/permission.ts +625 -0
- package/src/shared/domain/agent-policy/prompts.ts +17 -0
- package/src/shared/domain/agent-policy/reasoning.ts +59 -0
- package/src/shared/domain/agent-policy/rule-sets.ts +416 -0
- package/src/shared/domain/agent-policy/tool-access.ts +91 -0
- package/src/shared/domain/agent-registry.ts +143 -0
- package/src/shared/domain/agents/built-in-charters.ts +43 -0
- package/src/shared/domain/agents/chain.ts +30 -0
- package/src/shared/domain/agents/charter.ts +64 -0
- package/src/shared/domain/agents/exclusive.ts +25 -0
- package/src/shared/domain/agents/instances.ts +252 -0
- package/src/shared/domain/agents/messages.ts +39 -0
- package/src/shared/domain/agents/model-route.ts +199 -0
- package/src/shared/domain/agents/prompts.ts +20 -0
- package/src/shared/domain/code-intel-contract.ts +357 -0
- package/src/shared/domain/code-intel-routing.ts +60 -0
- package/src/shared/domain/compact-outcome.ts +46 -0
- package/src/shared/domain/compaction-thresholds.ts +162 -0
- package/src/shared/domain/compaction.ts +288 -0
- package/src/shared/domain/config-schema.ts +434 -0
- package/src/shared/domain/context-prune.ts +176 -0
- package/src/shared/domain/decision/questions.ts +102 -0
- package/src/shared/domain/dev/access-cost.ts +230 -0
- package/src/shared/domain/dev/artefacts.ts +50 -0
- package/src/shared/domain/dev/batches-concurrency.ts +35 -0
- package/src/shared/domain/dev/batches-state.ts +49 -0
- package/src/shared/domain/dev/build-commands.ts +45 -0
- package/src/shared/domain/dev/call-guard.ts +342 -0
- package/src/shared/domain/dev/carried-text.ts +47 -0
- package/src/shared/domain/dev/design-rules.ts +100 -0
- package/src/shared/domain/dev/learn-proposals.ts +176 -0
- package/src/shared/domain/dev/learn-state.ts +94 -0
- package/src/shared/domain/dev/markers.ts +107 -0
- package/src/shared/domain/dev/messages.ts +259 -0
- package/src/shared/domain/dev/path-args.ts +42 -0
- package/src/shared/domain/dev/path-rebase.ts +93 -0
- package/src/shared/domain/dev/phase-timing.ts +50 -0
- package/src/shared/domain/dev/plan-checks.ts +191 -0
- package/src/shared/domain/dev/plan-format.ts +170 -0
- package/src/shared/domain/dev/project-files.ts +29 -0
- package/src/shared/domain/dev/prompts/brief-blocks.ts +20 -0
- package/src/shared/domain/dev/prompts.ts +251 -0
- package/src/shared/domain/dev/questions.ts +267 -0
- package/src/shared/domain/dev/reading-rule.ts +41 -0
- package/src/shared/domain/dev/repo-pack.ts +240 -0
- package/src/shared/domain/dev/review-answer.ts +173 -0
- package/src/shared/domain/dev/review-brief.ts +54 -0
- package/src/shared/domain/dev/reviewer-charter.ts +35 -0
- package/src/shared/domain/dev/sheet-facts.ts +81 -0
- package/src/shared/domain/dev/spec-format.ts +182 -0
- package/src/shared/domain/dev/step-budget.ts +74 -0
- package/src/shared/domain/dev/step-rules.ts +109 -0
- package/src/shared/domain/dev/test-commands.ts +94 -0
- package/src/shared/domain/dev/test-output.ts +33 -0
- package/src/shared/domain/dev/test-paths.ts +40 -0
- package/src/shared/domain/dev/tool-guards.ts +65 -0
- package/src/shared/domain/dev/trait-pattern.ts +87 -0
- package/src/shared/domain/dev/verdict-format.ts +162 -0
- package/src/shared/domain/dev/whitespace.ts +35 -0
- package/src/shared/domain/dev/work-folder.ts +68 -0
- package/src/shared/domain/dev/yaml-subset.ts +385 -0
- package/src/shared/domain/error-text.ts +13 -0
- package/src/shared/domain/git/close.ts +274 -0
- package/src/shared/domain/git/messages.ts +20 -0
- package/src/shared/domain/git/pull-request.ts +96 -0
- package/src/shared/domain/git/worktree.ts +46 -0
- package/src/shared/domain/host-layout.ts +147 -0
- package/src/shared/domain/host-paths.ts +399 -0
- package/src/shared/domain/index-languages.ts +16 -0
- package/src/shared/domain/instructions-file.ts +18 -0
- package/src/shared/domain/iso-day.ts +4 -0
- package/src/shared/domain/llm-failure.ts +134 -0
- package/src/shared/domain/llm-profile.ts +44 -0
- package/src/shared/domain/marked-message.ts +29 -0
- package/src/shared/domain/markers.ts +30 -0
- package/src/shared/domain/messages.ts +291 -0
- package/src/shared/domain/model-catalog.ts +79 -0
- package/src/shared/domain/permission-modes.ts +99 -0
- package/src/shared/domain/prelude.ts +92 -0
- package/src/shared/domain/project-manifests.ts +84 -0
- package/src/shared/domain/prompts.ts +233 -0
- package/src/shared/domain/search-routing.ts +77 -0
- package/src/shared/domain/secret-patterns.ts +46 -0
- package/src/shared/domain/session-keys.ts +92 -0
- package/src/shared/domain/session-start.ts +61 -0
- package/src/shared/domain/severity.ts +72 -0
- package/src/shared/domain/sha1.ts +61 -0
- package/src/shared/domain/shared-memory/agent-memory-import.ts +145 -0
- package/src/shared/domain/shared-memory/candidates.ts +40 -0
- package/src/shared/domain/shared-memory/entry.ts +151 -0
- package/src/shared/domain/shared-memory/front-matter.ts +187 -0
- package/src/shared/domain/shared-memory/gate.ts +45 -0
- package/src/shared/domain/shared-memory/harvest.ts +64 -0
- package/src/shared/domain/shared-memory/layout.ts +190 -0
- package/src/shared/domain/shared-memory/markers.ts +9 -0
- package/src/shared/domain/shared-memory/messages.ts +66 -0
- package/src/shared/domain/shared-memory/precedents-block.ts +82 -0
- package/src/shared/domain/shared-memory/prompts.ts +28 -0
- package/src/shared/domain/shared-memory/refused.ts +84 -0
- package/src/shared/domain/shared-memory/verdict-rows.ts +134 -0
- package/src/shared/domain/skills/prompts.ts +4 -0
- package/src/shared/domain/skills/shortlist.ts +149 -0
- package/src/shared/domain/snip-turns.ts +33 -0
- package/src/shared/domain/speech.ts +21 -0
- package/src/shared/domain/strip.ts +88 -0
- package/src/shared/domain/tool-trace.ts +120 -0
- package/src/shared/domain/types.ts +67 -0
- package/src/shared/domain/verifiers.ts +33 -0
- package/src/shared/domain/vfs.ts +16 -0
- package/src/shared/domain/workflow/prompts.ts +15 -0
- package/src/shared/domain/workflow/state-file.ts +142 -0
- package/src/shared/infrastructure/globals.ts +57 -0
- package/src/shared/infrastructure/orkeon/approvals.ts +24 -0
- package/src/shared/infrastructure/orkeon/child-agents.ts +122 -0
- package/src/shared/infrastructure/orkeon/chooser.ts +32 -0
- package/src/shared/infrastructure/orkeon/code-index.ts +120 -0
- package/src/shared/infrastructure/orkeon/crew-host.ts +27 -0
- package/src/shared/infrastructure/orkeon/crew-memory.ts +12 -0
- package/src/shared/infrastructure/orkeon/decision-model.ts +31 -0
- package/src/shared/infrastructure/orkeon/dev-deps.ts +179 -0
- package/src/shared/infrastructure/orkeon/files.ts +58 -0
- package/src/shared/infrastructure/orkeon/github-pull-requests.ts +30 -0
- package/src/shared/infrastructure/orkeon/host-context.ts +36 -0
- package/src/shared/infrastructure/orkeon/host-provider.ts +22 -0
- package/src/shared/infrastructure/orkeon/human-input.ts +55 -0
- package/src/shared/infrastructure/orkeon/llm-profile.ts +58 -0
- package/src/shared/infrastructure/orkeon/llm.ts +164 -0
- package/src/shared/infrastructure/orkeon/markers.ts +6 -0
- package/src/shared/infrastructure/orkeon/memory-store.ts +41 -0
- package/src/shared/infrastructure/orkeon/memory-tools.ts +129 -0
- package/src/shared/infrastructure/orkeon/messages.ts +15 -0
- package/src/shared/infrastructure/orkeon/permission-rules.ts +42 -0
- package/src/shared/infrastructure/orkeon/progress.ts +24 -0
- package/src/shared/infrastructure/orkeon/prompts.ts +47 -0
- package/src/shared/infrastructure/orkeon/reasoning.ts +40 -0
- package/src/shared/infrastructure/orkeon/run-state.ts +17 -0
- package/src/shared/infrastructure/orkeon/runtime-info.ts +30 -0
- package/src/shared/infrastructure/orkeon/runtime-tools.ts +60 -0
- package/src/shared/infrastructure/orkeon/script-tools.ts +129 -0
- package/src/shared/infrastructure/orkeon/session-store.ts +94 -0
- package/src/shared/infrastructure/orkeon/session-switch.ts +23 -0
- package/src/shared/infrastructure/orkeon/shared-memory.ts +61 -0
- package/src/shared/infrastructure/orkeon/shell-jobs.ts +81 -0
- package/src/shared/infrastructure/orkeon/shell.ts +39 -0
- package/src/shared/infrastructure/orkeon/telemetry.ts +63 -0
- package/src/shared/infrastructure/orkeon/tool-catalogue.ts +76 -0
- package/src/shared/infrastructure/orkeon/tool-results.ts +120 -0
- package/src/shared/infrastructure/orkeon/usage.ts +74 -0
- package/src/shared/infrastructure/orkeon/wiring.ts +174 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// The learning view of the verdict files: the Blocking and Major rows of every GAPS
|
|
2
|
+
// section, each with the id the harness's learning script gives it, so a row the
|
|
3
|
+
// harness treated is treated here too (the harness reads no state of this tool). Pure, no IO, never throws.
|
|
4
|
+
//
|
|
5
|
+
// Known divergences from the script, accepted (the files the dev workflow writes hold
|
|
6
|
+
// none of them):
|
|
7
|
+
// - the script also splits lines on \v, \f, \x1c-\x1e, \x85, U+2028, U+2029 and a lone
|
|
8
|
+
// \r; parseVerdictFile splits on \r?\n only;
|
|
9
|
+
// - Python's strip() and String.prototype.trim() disagree on U+FEFF, U+001C-U+001F and
|
|
10
|
+
// U+0085 at the edge of a cell;
|
|
11
|
+
// - toLowerCase() and Python's lower() disagree on a few special casings (e.g. U+0130).
|
|
12
|
+
// One divergence the files do hold: the row of an audit the budget stopped (AUDIT_UNFINISHED_GAP) is left out here,
|
|
13
|
+
// while the script, until the harness repository skips it too, harvests it as a Blocking mistake.
|
|
14
|
+
import { AXES, isAuditUnfinishedGap, parseVerdictFile } from "../dev/verdict-format.ts";
|
|
15
|
+
import type { Severity, VerdictFile } from "../dev/verdict-format.ts";
|
|
16
|
+
import { sha1Hex } from "../sha1.ts";
|
|
17
|
+
|
|
18
|
+
export type LearnSeverity = Extract<Severity, "Blocking" | "Major">;
|
|
19
|
+
export interface LearnRow {
|
|
20
|
+
id: string; // 10 hex digits
|
|
21
|
+
batch: string; // "<code folder>/F<n>", e.g. "demo/F2"
|
|
22
|
+
severity: LearnSeverity;
|
|
23
|
+
axis: string; // canonicalAxis(cell 2): one of AXES, or the trimmed label when none matches
|
|
24
|
+
gap: string; evidence: string; fix: string;
|
|
25
|
+
source: string; // "<code folder>/<file name>", for messages
|
|
26
|
+
line: number; // the row's line in its file
|
|
27
|
+
}
|
|
28
|
+
export interface VerdictSource { code: string; name: string; text: string }
|
|
29
|
+
export interface AxisBacklog { axis: string; rows: LearnRow[]; batches: string[]; blocking: number }
|
|
30
|
+
|
|
31
|
+
/** Three distinct batches make a motif (temp/05 § 3.2 MISTAKE_MIN_BATCHES; SK:29). */
|
|
32
|
+
export const MIN_MOTIF_BATCHES = 3;
|
|
33
|
+
/** The backlog nudge of LC:38, kept for M-7. Unused by L-3. */
|
|
34
|
+
export const NUDGE_BATCHES = 2;
|
|
35
|
+
/** The harness's verdict file name (LC:40), Unicode-aware as Python's str regex is. */
|
|
36
|
+
export const LEARN_FILE: RegExp = /^([A-Za-z0-9][\p{L}\p{N}_.-]*)-VERIFY-(F\p{Nd}+)\.md$/u;
|
|
37
|
+
|
|
38
|
+
const PLAN_ALIAS = "stale plan";
|
|
39
|
+
const CELL = 200;
|
|
40
|
+
|
|
41
|
+
/** Lower case, then canonical decomposition, then no combining mark (LC:85-86). */
|
|
42
|
+
export function foldText(text: string): string {
|
|
43
|
+
return text.toLowerCase().normalize("NFD").replace(/\p{Mn}/gu, "");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** The axis a label names: a folded prefix match on AXES, `stale plan` for Plan, else the label trimmed (LC:89-92). */
|
|
47
|
+
export function canonicalAxis(label: string): string {
|
|
48
|
+
const trimmed = label.trim();
|
|
49
|
+
const folded = foldText(trimmed);
|
|
50
|
+
if (folded.startsWith(PLAN_ALIAS)) return "Plan";
|
|
51
|
+
return AXES.find((a) => folded.startsWith(foldText(a))) ?? trimmed;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function rowIdSource(batch: string, axis: string, gap: string): string {
|
|
55
|
+
return `${batch}|${axis}|${gap}`;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function rowId(batch: string, axis: string, gap: string): string {
|
|
59
|
+
return sha1Hex(rowIdSource(batch, axis, gap)).slice(0, 10);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function isLearnSeverity(severity: Severity): severity is LearnSeverity {
|
|
63
|
+
return severity === "Blocking" || severity === "Major";
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** The learning rows of one parsed verdict file: GAPS sections only, Blocking/Major only, an unfinished audit's row left out. */
|
|
67
|
+
export function learnRowsOf(file: VerdictFile, code: string, name: string): LearnRow[] {
|
|
68
|
+
const m = LEARN_FILE.exec(name);
|
|
69
|
+
if (!m) return [];
|
|
70
|
+
const batch = `${code}/${m[2]}`;
|
|
71
|
+
const source = `${code}/${name}`;
|
|
72
|
+
const out: LearnRow[] = [];
|
|
73
|
+
for (const section of file.sections) {
|
|
74
|
+
if (section.verdict !== "GAPS") continue;
|
|
75
|
+
for (const r of section.rows) {
|
|
76
|
+
if (!isLearnSeverity(r.severity) || isAuditUnfinishedGap(r.gap)) continue;
|
|
77
|
+
const axis = canonicalAxis(r.axis);
|
|
78
|
+
out.push({
|
|
79
|
+
id: rowId(batch, axis, r.gap), batch, severity: r.severity, axis,
|
|
80
|
+
gap: r.gap, evidence: r.evidence, fix: r.expectedFix, source, line: r.line,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return out;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Every row of every source: sorted by `${code}/${name}`, parsed with parseVerdictFile, deduplicated by id (first kept). */
|
|
88
|
+
export function collectLearnRows(sources: readonly VerdictSource[]): LearnRow[] {
|
|
89
|
+
const key = (s: VerdictSource): string => `${s.code}/${s.name}`;
|
|
90
|
+
const sorted = [...sources].sort((a, b) => (key(a) < key(b) ? -1 : key(a) > key(b) ? 1 : 0));
|
|
91
|
+
const seen = new Set<string>();
|
|
92
|
+
const out: LearnRow[] = [];
|
|
93
|
+
for (const s of sorted) {
|
|
94
|
+
for (const row of learnRowsOf(parseVerdictFile(s.text), s.code, s.name)) {
|
|
95
|
+
if (seen.has(row.id)) continue;
|
|
96
|
+
seen.add(row.id);
|
|
97
|
+
out.push(row);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return out;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function untreated(rows: readonly LearnRow[], treated: ReadonlySet<string>): LearnRow[] {
|
|
104
|
+
return rows.filter((r) => !treated.has(r.id));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** Per axis: rows in order, distinct batches in first-seen order, Blocking count; sorted by batches descending, stable. */
|
|
108
|
+
export function backlogByAxis(rows: readonly LearnRow[]): AxisBacklog[] {
|
|
109
|
+
const byAxis = new Map<string, AxisBacklog>();
|
|
110
|
+
for (const r of rows) {
|
|
111
|
+
let entry = byAxis.get(r.axis);
|
|
112
|
+
if (!entry) { entry = { axis: r.axis, rows: [], batches: [], blocking: 0 }; byAxis.set(r.axis, entry); }
|
|
113
|
+
entry.rows.push(r);
|
|
114
|
+
if (!entry.batches.includes(r.batch)) entry.batches.push(r.batch);
|
|
115
|
+
if (r.severity === "Blocking") entry.blocking++;
|
|
116
|
+
}
|
|
117
|
+
return [...byAxis.values()].sort((a, b) => b.batches.length - a.batches.length);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** LC:154-156: split on whitespace runs and re-joined with one space (so also trimmed); when longer than n, the
|
|
121
|
+
* first n - 3 characters plus "..." (three dots), n characters in all. Characters are code points, as in Python. */
|
|
122
|
+
export function shortCell(text: string, n: number = CELL): string {
|
|
123
|
+
const joined = text.split(/\s+/u).filter((w) => w !== "").join(" ");
|
|
124
|
+
const chars = Array.from(joined);
|
|
125
|
+
return chars.length <= n ? joined : chars.slice(0, n - 3).join("") + "...";
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** The lines LC:187-188 prints for one axis: "- [<sev>] <short gap>" and " fix: <short fix 120> · <batch> · <short evidence 80>". */
|
|
129
|
+
export function axisListing(rows: readonly LearnRow[]): string[] {
|
|
130
|
+
return rows.flatMap((r) => [
|
|
131
|
+
`- [${r.severity}] ${shortCell(r.gap)}`,
|
|
132
|
+
` fix: ${shortCell(r.fix, 120)} · ${r.batch} · ${shortCell(r.evidence, 80)}`,
|
|
133
|
+
]);
|
|
134
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// What the decision model reads to suggest skills for a request.
|
|
2
|
+
export const SUGGEST_INSTRUCTIONS = "Which of the following playbooks would help an assistant carry out the request of the text?";
|
|
3
|
+
export const skillLine = (name: string, description: string): string => (description.length === 0 ? name : `${name}: ${description}`);
|
|
4
|
+
export const NO_SKILL_FITS = "None of these playbooks helps with this request.";
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
// Suggesting skills for a turn (ADR 0027). A project keeps skills as markdown files: `.orkeon/skills/<name>.md`, or
|
|
2
|
+
// a folder of `.claude/skills/` holding a `SKILL.md`. With `skills.suggest` on, the host's decision model reads the
|
|
3
|
+
// request and one line per skill (its name and what it is for) and the few that fit join the turn's attached skills,
|
|
4
|
+
// for that turn. The skills a person attached with /skills stay, first. Every number is stated with its reason. Pure.
|
|
5
|
+
import type { DecisionAnswers, DecisionQuestions } from "../decision/questions.ts";
|
|
6
|
+
import { NO_SKILL_FITS, skillLine, SUGGEST_INSTRUCTIONS } from "./prompts.ts";
|
|
7
|
+
|
|
8
|
+
/** The setting that turns the suggestion on: `on`, anything else is off. */
|
|
9
|
+
export const SKILLS_SUGGEST_CONFIG_KEY = "skills.suggest";
|
|
10
|
+
/** A project's own skills, one markdown file each. */
|
|
11
|
+
export const ORKEON_SKILLS_DIR = ".orkeon/skills";
|
|
12
|
+
/** Skills written for another assistant, one folder each with its SKILL.md. */
|
|
13
|
+
export const CLAUDE_SKILLS_DIR = ".claude/skills";
|
|
14
|
+
export const CLAUDE_SKILL_FILE = "SKILL.md";
|
|
15
|
+
/** Skills suggested for one turn at most: each may add 4 000 characters to the turn (the skills block's cap). */
|
|
16
|
+
export const SUGGEST_MAX_PICKS = 3;
|
|
17
|
+
/** The share of the model's probability from which a skill is suggested: three skills at most can reach it. The
|
|
18
|
+
* question is one choice, so skills that all fit split the probability: four that fit equally reach none. */
|
|
19
|
+
export const SUGGEST_MIN_SHARE = 0.3;
|
|
20
|
+
/** Skills offered to the decision model in one question, in name order: past it the options crowd each other out. */
|
|
21
|
+
export const SUGGEST_MAX_CANDIDATES = 24;
|
|
22
|
+
/** Entries read of a skills folder before its skills are picked out: a folder holds other files too. */
|
|
23
|
+
export const SKILLS_LISTING_MAX = 200;
|
|
24
|
+
/** What is read of a skill file to find its name and description. */
|
|
25
|
+
export const SKILL_HEAD_CHARS = 2_000;
|
|
26
|
+
/** A skill's description, as the decision model reads it. */
|
|
27
|
+
export const SKILL_DESCRIPTION_CHARS = 300;
|
|
28
|
+
/** The request, as the decision model reads it. */
|
|
29
|
+
export const SUGGEST_REQUEST_CHARS = 2_000;
|
|
30
|
+
/** The name of the question asked, and the option that says no skill fits. */
|
|
31
|
+
export const SUGGEST_QUESTION = "skill";
|
|
32
|
+
export const NO_SKILL_OPTION = "none";
|
|
33
|
+
|
|
34
|
+
/** One skill as the decision model is told of it. */
|
|
35
|
+
export interface SkillCard {
|
|
36
|
+
path: string;
|
|
37
|
+
name: string;
|
|
38
|
+
description: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** One suggested skill and the share of probability it got. */
|
|
42
|
+
export interface SkillPick {
|
|
43
|
+
path: string;
|
|
44
|
+
share: number;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Whether the setting's value turns the suggestion on. */
|
|
48
|
+
export function suggestOn(value: unknown): boolean {
|
|
49
|
+
return typeof value === "string" && value.trim().toLowerCase() === "on";
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function cut(text: string, max: number): string {
|
|
53
|
+
return text.length <= max ? text : `${text.slice(0, max)}...`;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** The name a path gives a skill: the file's, or its folder's for a SKILL.md. */
|
|
57
|
+
function nameOfPath(path: string): string {
|
|
58
|
+
const parts = path.split("/");
|
|
59
|
+
const file = parts[parts.length - 1] ?? "";
|
|
60
|
+
return file === CLAUDE_SKILL_FILE ? parts[parts.length - 2] ?? file : file.replace(/\.md$/i, "");
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** The fields of a file's front matter, a folded or literal value (`description: >`) read from its indented lines;
|
|
64
|
+
* null when the file opens with none. A front matter the head cuts short is read as far as it goes. */
|
|
65
|
+
function frontmatter(head: string): { fields: Record<string, string>; body: string } | null {
|
|
66
|
+
const lines = head.split(/\r?\n/);
|
|
67
|
+
if (lines[0]?.trim() !== "---") return null;
|
|
68
|
+
const fields: Record<string, string> = {};
|
|
69
|
+
let i = 1;
|
|
70
|
+
for (; i < lines.length && lines[i].trim() !== "---"; i += 1) {
|
|
71
|
+
const field = /^([A-Za-z][\w-]*):\s*(.*)$/.exec(lines[i]);
|
|
72
|
+
if (field === null) continue;
|
|
73
|
+
let value = field[2].trim();
|
|
74
|
+
if (/^[>|][+-]?$/.test(value)) {
|
|
75
|
+
const folded: string[] = [];
|
|
76
|
+
while (i + 1 < lines.length && /^\s+\S/.test(lines[i + 1])) folded.push(lines[(i += 1)].trim());
|
|
77
|
+
value = folded.join(" ");
|
|
78
|
+
}
|
|
79
|
+
fields[field[1].toLowerCase()] = value.replace(/^["']|["']$/g, "");
|
|
80
|
+
}
|
|
81
|
+
return { fields, body: lines.slice(i + 1).join("\n") };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** The lines of a body outside its code fences, trimmed. */
|
|
85
|
+
function prose(body: string): string[] {
|
|
86
|
+
const out: string[] = [];
|
|
87
|
+
let fenced = false;
|
|
88
|
+
for (const line of body.split(/\r?\n/).map((l) => l.trim())) {
|
|
89
|
+
if (/^(```|~~~)/.test(line)) fenced = !fenced;
|
|
90
|
+
else if (!fenced) out.push(line);
|
|
91
|
+
}
|
|
92
|
+
return out;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Whether the model may be offered a skill: not one its front matter keeps for a person to invoke
|
|
96
|
+
* (`disable-model-invocation: true`, the mark other assistants' skills carry). */
|
|
97
|
+
export function offerable(head: string): boolean {
|
|
98
|
+
return frontmatter(head.replace(/^\uFEFF/, ""))?.fields["disable-model-invocation"]?.toLowerCase() !== "true";
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** A skill's card from the head of its file: the `name` and `description` of its front matter; else its first
|
|
102
|
+
* heading and the first line of text under it, code fences left out. A missing name is the path's; a missing
|
|
103
|
+
* description is empty. */
|
|
104
|
+
export function skillCard(path: string, head: string): SkillCard {
|
|
105
|
+
const text = head.replace(/^\uFEFF/, "");
|
|
106
|
+
const front = frontmatter(text);
|
|
107
|
+
const lines = prose(front === null ? text : front.body);
|
|
108
|
+
const heading = lines.find((line) => /^#{1,6}\s+\S/.test(line))?.replace(/^#+\s+/, "");
|
|
109
|
+
const paragraph = lines.find((line) => line.length > 0 && !line.startsWith("#") && line !== "---") ?? "";
|
|
110
|
+
return {
|
|
111
|
+
path,
|
|
112
|
+
name: front?.fields.name || heading || nameOfPath(path),
|
|
113
|
+
description: cut((front?.fields.description || paragraph).replace(/\s+/g, " "), SKILL_DESCRIPTION_CHARS),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** A skill's path as two spellings of it compare: no `/workspace/` nor `./` in front. */
|
|
118
|
+
export function skillKey(path: string): string {
|
|
119
|
+
return path.trim().replace(/^\/workspace\//, "").replace(/^\.\//, "");
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const option = (n: number): string => `s${n}`;
|
|
123
|
+
|
|
124
|
+
/** The state the decision model judges: the request alone. */
|
|
125
|
+
export function suggestState(request: string): string {
|
|
126
|
+
return cut(request.trim(), SUGGEST_REQUEST_CHARS);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** One choice among the skills, numbered from 1, and the option that none fits. */
|
|
130
|
+
export function shortlistQuestion(cards: readonly SkillCard[]): DecisionQuestions {
|
|
131
|
+
const criteria: Record<string, string> = {};
|
|
132
|
+
cards.forEach((card, i) => {
|
|
133
|
+
criteria[option(i + 1)] = skillLine(card.name, card.description);
|
|
134
|
+
});
|
|
135
|
+
criteria[NO_SKILL_OPTION] = NO_SKILL_FITS;
|
|
136
|
+
return { [SUGGEST_QUESTION]: { type: "choice", criteria, instructions: SUGGEST_INSTRUCTIONS } };
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** The skills whose share reaches SUGGEST_MIN_SHARE, the largest first, SUGGEST_MAX_PICKS at most; none when the
|
|
140
|
+
* model chose that none fits, or did not answer. */
|
|
141
|
+
export function shortlistOf(answers: DecisionAnswers | null, cards: readonly SkillCard[]): SkillPick[] {
|
|
142
|
+
const answer = answers?.[SUGGEST_QUESTION];
|
|
143
|
+
if (answer?.type !== "choice" || answer.choice === NO_SKILL_OPTION) return [];
|
|
144
|
+
return cards
|
|
145
|
+
.map((card, i) => ({ path: card.path, share: answer.probabilities[option(i + 1)] ?? 0 }))
|
|
146
|
+
.filter((pick) => pick.share >= SUGGEST_MIN_SHARE)
|
|
147
|
+
.sort((a, b) => b.share - a.share)
|
|
148
|
+
.slice(0, SUGGEST_MAX_PICKS);
|
|
149
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// The turns of this harness as session_snip counts them. The runtime keeps the head message and the last N turns, a
|
|
2
|
+
// turn opening at each user message (Orkeon #287); a turn here stores its [turn-context] as a user message just before
|
|
3
|
+
// the request, so one turn of this harness can be two of the runtime's. The cut asks for as many of the runtime's turns
|
|
4
|
+
// as the last turns of this harness hold, so none of them loses its [turn-context].
|
|
5
|
+
|
|
6
|
+
import { isMarkedMessage } from "./marked-message.ts";
|
|
7
|
+
import { TURN_CONTEXT_MARKER } from "./markers.ts";
|
|
8
|
+
import type { SessionMsg } from "./types.ts";
|
|
9
|
+
|
|
10
|
+
const isUser = (m: SessionMsg): boolean => String(m.role).toLowerCase() === "user";
|
|
11
|
+
|
|
12
|
+
/** How many of the runtime's turns session_snip must keep for the last `turns` turns of `messages` to stay whole: the
|
|
13
|
+
* user messages from the first kept request (its [turn-context] included) to the end. A turn is a request the user
|
|
14
|
+
* typed with what follows it; the head (the first message) is never one. null when the buffer holds fewer turns
|
|
15
|
+
* than asked after its head: the runtime would remove nothing. */
|
|
16
|
+
export function runtimeTurnsToKeep(messages: readonly SessionMsg[], turns: number): number | null {
|
|
17
|
+
if (turns <= 0) return 0;
|
|
18
|
+
let users = 0;
|
|
19
|
+
let found = 0;
|
|
20
|
+
for (let i = messages.length - 1; i >= 1; i--) {
|
|
21
|
+
const m = messages[i];
|
|
22
|
+
if (!isUser(m)) continue;
|
|
23
|
+
users++;
|
|
24
|
+
if (isMarkedMessage(String(m.content))) continue;
|
|
25
|
+
found++;
|
|
26
|
+
if (found < turns) continue;
|
|
27
|
+
const before = messages[i - 1];
|
|
28
|
+
const hasContext = i >= 2 && isUser(before) && String(before.content).startsWith(TURN_CONTEXT_MARKER);
|
|
29
|
+
return hasContext ? users + 1 : users;
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Speech output in the turn: the session key voice.reply and the epilogue it adds.
|
|
2
|
+
// On, every answer of the main loop is read aloud by the speech MCP server's speak
|
|
3
|
+
// (mcp/whisper), as a call of the command that launched the turn. Pure.
|
|
4
|
+
import type { EpilogueCall } from "./prelude.ts";
|
|
5
|
+
import { REPLY_READ_ALOUD } from "./messages.ts";
|
|
6
|
+
|
|
7
|
+
/** The session key: "on" reads every answer aloud; anything else, or unset, does not. */
|
|
8
|
+
export const VOICE_REPLY_CONFIG_KEY = "voice.reply";
|
|
9
|
+
|
|
10
|
+
/** The speech server's tool that reads a text aloud. */
|
|
11
|
+
export const SPEAK_TOOL = "speak";
|
|
12
|
+
|
|
13
|
+
/** Whether a value of voice.reply turns the reading on. */
|
|
14
|
+
export function voiceReplyOn(value: string | undefined): boolean {
|
|
15
|
+
return (value ?? "").trim().toLowerCase() === "on";
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** The epilogue that reads the answer aloud, with speak under the name the host registers. */
|
|
19
|
+
export function voiceReplyEpilogue(registeredSpeak: string): EpilogueCall {
|
|
20
|
+
return { tool: registeredSpeak, args: {}, textArg: "text", label: REPLY_READ_ALOUD };
|
|
21
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// Strip-chain for LLM text output — pure, no IO. Ported from exp 02
|
|
2
|
+
// (crews/unified/domain/metrics.ts), keeping ONLY the in-domain helpers a
|
|
3
|
+
// coding agent needs. The design-spec-specific helpers (FQN citation
|
|
4
|
+
// counting, verifier floors, table-row counting) are deliberately NOT
|
|
5
|
+
// ported — they are out of the coding-agent domain (PLAN §R4).
|
|
6
|
+
//
|
|
7
|
+
// Today 07 strips fences ad-hoc and inline in three crews
|
|
8
|
+
// (git-commit:45, project-init:79, init-verifiers:78). This centralises
|
|
9
|
+
// that, and adds the thinking/preamble salvage DeepSeek output needs.
|
|
10
|
+
//
|
|
11
|
+
// Run tests: node --test src/shared/domain/strip.test.ts
|
|
12
|
+
|
|
13
|
+
// Remove a single pair of code fences WRAPPING the whole text, e.g. a model
|
|
14
|
+
// that answered ```markdown\n<doc>\n``` instead of the bare document. Only the
|
|
15
|
+
// outermost wrapping fence is stripped (inner fenced blocks are preserved).
|
|
16
|
+
export function unwrapFences(text: string): string {
|
|
17
|
+
if (!text) return text;
|
|
18
|
+
return text
|
|
19
|
+
.replace(/^\s*```[a-z0-9-]*\n?/i, "")
|
|
20
|
+
.replace(/\n?```\s*$/i, "")
|
|
21
|
+
.trim();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Strip a `<thinking>...</thinking>` reasoning region. The opening tag is
|
|
25
|
+
// matched case-insensitively; we strip from the first opener to the LAST
|
|
26
|
+
// matching closer (greedy) so a writer that re-opens scratch mid-document is
|
|
27
|
+
// fully cleaned. No closer → the rest of the string was scratch; drop it.
|
|
28
|
+
export function stripThinking(md: string): string {
|
|
29
|
+
if (!md) return md;
|
|
30
|
+
const openIdx = md.search(/<thinking>/i);
|
|
31
|
+
if (openIdx < 0) return md;
|
|
32
|
+
const closeMatch = md.match(/<\/thinking>(?![\s\S]*<\/thinking>)/i);
|
|
33
|
+
if (!closeMatch || closeMatch.index === undefined) return md.slice(0, openIdx);
|
|
34
|
+
const closeEnd = closeMatch.index + closeMatch[0].length;
|
|
35
|
+
return md.slice(0, openIdx) + md.slice(closeEnd);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Salvage a "draft-then-real" leak: the writer emits the document twice — a
|
|
39
|
+
// skeleton, a self-narration monologue, then the real document with an
|
|
40
|
+
// IDENTICAL H1. Conservative: only fires when the same `# title` appears ≥2×
|
|
41
|
+
// AND first-person planning prose precedes the last duplicate. Otherwise the
|
|
42
|
+
// text is returned byte-identical (idempotent on clean output).
|
|
43
|
+
const SCRATCH_OPENER = /^(?:Now (?:let|I)|Wait,|Actually,|OK,|Let me|Let's|I'll |I need to|I should|I want to|I'm going to|Here goes|One more|First,? (?:I|let)|Hmm,)/m;
|
|
44
|
+
export function stripLeakedScratch(md: string): string {
|
|
45
|
+
if (!md) return md;
|
|
46
|
+
const h1Re = /^# .+$/gm;
|
|
47
|
+
const matches: Array<{ text: string; index: number }> = [];
|
|
48
|
+
let m: RegExpExecArray | null;
|
|
49
|
+
while ((m = h1Re.exec(md)) !== null) matches.push({ text: m[0].trim(), index: m.index });
|
|
50
|
+
if (matches.length < 2) return md;
|
|
51
|
+
const firstTitle = matches[0].text;
|
|
52
|
+
let lastDupIndex = -1;
|
|
53
|
+
for (let i = matches.length - 1; i >= 1; i--) {
|
|
54
|
+
if (matches[i].text === firstTitle) { lastDupIndex = matches[i].index; break; }
|
|
55
|
+
}
|
|
56
|
+
if (lastDupIndex < 0) return md;
|
|
57
|
+
const head = md.slice(0, lastDupIndex);
|
|
58
|
+
if (!SCRATCH_OPENER.test(head)) return md;
|
|
59
|
+
return md.slice(lastDupIndex);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Strip any LLM preamble before the first markdown heading so the deliverable's
|
|
63
|
+
// first non-whitespace char is `#` (or `<!--`).
|
|
64
|
+
export function stripPreamble(md: string): string {
|
|
65
|
+
if (!md) return md;
|
|
66
|
+
const trimmed = md.replace(/^\s+/, "");
|
|
67
|
+
if (trimmed.startsWith("#") || trimmed.startsWith("<!--")) return trimmed;
|
|
68
|
+
const hIdx = md.search(/\n#\s/);
|
|
69
|
+
if (hIdx >= 0) return md.slice(hIdx + 1);
|
|
70
|
+
// Scratchpad glued to heading without a newline ("Let me write it.# Title").
|
|
71
|
+
// Guards: `#` preceded by ws/punct/SOL, and followed by uppercase/digit.
|
|
72
|
+
const gluedMatch = md.match(/(?:^|[\s.!?])(#\s+[A-Z0-9])/);
|
|
73
|
+
if (gluedMatch && gluedMatch.index !== undefined) {
|
|
74
|
+
const headStart = gluedMatch.index + gluedMatch[0].length - gluedMatch[1].length;
|
|
75
|
+
return md.slice(headStart);
|
|
76
|
+
}
|
|
77
|
+
const cIdx = md.indexOf("<!--");
|
|
78
|
+
if (cIdx >= 0) return md.slice(cIdx);
|
|
79
|
+
return md;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// The full chain for a markdown deliverable produced by an LLM: drop scratch,
|
|
83
|
+
// salvage a draft-then-real leak, drop preamble, then unwrap any wrapping fence.
|
|
84
|
+
// Trailing newline normalised by the caller. Idempotent on clean output.
|
|
85
|
+
export function cleanLlmMarkdown(raw: string): string {
|
|
86
|
+
if (!raw) return raw;
|
|
87
|
+
return unwrapFences(stripPreamble(stripLeakedScratch(stripThinking(raw)))).trim();
|
|
88
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
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/turn.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
|
+
import { TOOL_TRACE_MARKER } from "./markers.ts";
|
|
6
|
+
import { matchesInFiles, TOOL_TRACE_HEADING } from "./prompts.ts";
|
|
7
|
+
/** The lines of one message, the line that counts the calls left out included. */
|
|
8
|
+
export const MAX_TRACE_LINES = 20;
|
|
9
|
+
/** An argument's value is cut past this many characters. */
|
|
10
|
+
export const MAX_ARG_CHARS = 60;
|
|
11
|
+
|
|
12
|
+
/** The arguments a line keeps, in this order: where a call looked and how, never what it wrote. */
|
|
13
|
+
const ARG_KEYS: readonly string[] = [
|
|
14
|
+
"path", "paths", "file_path", "pattern", "glob", "output_mode", "command", "query", "fqn", "symbol", "name", "url",
|
|
15
|
+
"category", "key", "mode", "offset", "limit",
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
/** The fields of a result that list what it found. */
|
|
19
|
+
const LIST_KEYS: readonly string[] = ["hits", "matches", "results", "files", "entries", "items"];
|
|
20
|
+
|
|
21
|
+
export interface ToolCallTrace {
|
|
22
|
+
readonly tool: string;
|
|
23
|
+
readonly args: string;
|
|
24
|
+
readonly outcome: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** One call as the trace keeps it. */
|
|
28
|
+
export function traceCall(tool: string, input: unknown, result: unknown): ToolCallTrace {
|
|
29
|
+
return { tool, args: argsOf(input), outcome: outcomeOf(result) };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** The message of a turn's calls, oldest first, the same call folded as `×n`; null when the turn called no tool. */
|
|
33
|
+
export function formatToolTrace(calls: readonly ToolCallTrace[]): string | null {
|
|
34
|
+
if (calls.length === 0) return null;
|
|
35
|
+
const folded = new Map<string, { line: string; count: number }>();
|
|
36
|
+
for (const c of calls) {
|
|
37
|
+
const line = `${c.tool}(${c.args}) → ${c.outcome}`;
|
|
38
|
+
const seen = folded.get(line);
|
|
39
|
+
if (seen === undefined) folded.set(line, { line, count: 1 });
|
|
40
|
+
else seen.count += 1;
|
|
41
|
+
}
|
|
42
|
+
const entries = [...folded.values()];
|
|
43
|
+
const shown = entries.length > MAX_TRACE_LINES ? entries.slice(0, MAX_TRACE_LINES - 1) : entries;
|
|
44
|
+
// The calls left out, each folded line counting its ×n.
|
|
45
|
+
const left = entries.slice(shown.length).reduce((sum, f) => sum + f.count, 0);
|
|
46
|
+
const tail = left > 0 ? [`- … ${left} other calls`] : [];
|
|
47
|
+
const lines = shown.map((f) => `- ${f.line}${f.count > 1 ? ` ×${f.count}` : ""}`);
|
|
48
|
+
return TOOL_TRACE_MARKER + TOOL_TRACE_HEADING + [...lines, ...tail].join("\n");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Whether a stored message is a turn's trace. */
|
|
52
|
+
export function isToolTrace(content: string): boolean {
|
|
53
|
+
return content.startsWith(TOOL_TRACE_MARKER);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function argsOf(input: unknown): string {
|
|
57
|
+
if (input === null || typeof input !== "object" || Array.isArray(input)) return "";
|
|
58
|
+
const record = input as Record<string, unknown>;
|
|
59
|
+
const parts: string[] = [];
|
|
60
|
+
for (const key of ARG_KEYS) {
|
|
61
|
+
const value = shownValue(record[key]);
|
|
62
|
+
if (value !== null) parts.push(`${key}=${value}`);
|
|
63
|
+
}
|
|
64
|
+
return parts.join(", ");
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function shownValue(value: unknown): string | null {
|
|
68
|
+
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
69
|
+
if (Array.isArray(value)) {
|
|
70
|
+
const items = value.filter((v): v is string => typeof v === "string");
|
|
71
|
+
return items.length === 0 ? null : cut(items.join(","));
|
|
72
|
+
}
|
|
73
|
+
if (typeof value !== "string" || value.trim().length === 0) return null;
|
|
74
|
+
return secretPatternsIn(value).length > 0 ? "(redacted)" : cut(value);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function cut(text: string): string {
|
|
78
|
+
const flat = text.replace(/\s+/g, " ").trim();
|
|
79
|
+
return flat.length > MAX_ARG_CHARS ? flat.slice(0, MAX_ARG_CHARS - 1) + "…" : flat;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function outcomeOf(result: unknown): string {
|
|
83
|
+
if (result === null || result === undefined) return "no result";
|
|
84
|
+
if (typeof result === "string") return textOutcome(result);
|
|
85
|
+
if (typeof result !== "object") return cut(String(result));
|
|
86
|
+
if (Array.isArray(result)) return `${result.length} results`;
|
|
87
|
+
const r = result as Record<string, unknown>;
|
|
88
|
+
if (typeof r.error === "string" && r.error.trim().length > 0) return `error: ${cut(firstLine(r.error))}`;
|
|
89
|
+
const parts = [mainOutcome(r)];
|
|
90
|
+
if (r.scan_complete === false) parts.push("incomplete scan");
|
|
91
|
+
if (r.truncated === true) parts.push("truncated");
|
|
92
|
+
return parts.join(", ");
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function mainOutcome(r: Record<string, unknown>): string {
|
|
96
|
+
if (typeof r.total_matches === "number") {
|
|
97
|
+
return typeof r.files_matched === "number"
|
|
98
|
+
? matchesInFiles(r.total_matches, r.files_matched)
|
|
99
|
+
: `${r.total_matches} matches`;
|
|
100
|
+
}
|
|
101
|
+
const exit = typeof r.exit_code === "number" ? r.exit_code : r.exitCode;
|
|
102
|
+
if (typeof exit === "number") return `exit ${exit}`;
|
|
103
|
+
for (const key of LIST_KEYS) {
|
|
104
|
+
const list = r[key];
|
|
105
|
+
if (Array.isArray(list)) return `${list.length} ${key}`;
|
|
106
|
+
}
|
|
107
|
+
return "ok";
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function textOutcome(text: string): string {
|
|
111
|
+
const line = firstLine(text);
|
|
112
|
+
if (/^error\b/i.test(line)) return `error: ${cut(line.replace(/^error:?\s*/i, ""))}`;
|
|
113
|
+
if (text.trim().length === 0) return "empty";
|
|
114
|
+
const count = text.split("\n").filter((l) => l.trim().length > 0).length;
|
|
115
|
+
return count === 1 ? "1 line" : `${count} lines`;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function firstLine(text: string): string {
|
|
119
|
+
return text.trim().split("\n")[0] ?? "";
|
|
120
|
+
}
|
|
@@ -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,33 @@
|
|
|
1
|
+
// Verification skills — where /init-verifiers writes them and how /verify asks the
|
|
2
|
+
// main loop to follow them. Pure, no IO.
|
|
3
|
+
import {
|
|
4
|
+
everyVerificationSkill, IF_THAT_FILE_IS_MISSING, IF_THERE_IS_NONE, verificationSkill, verifyRequest,
|
|
5
|
+
} from "./prompts.ts";
|
|
6
|
+
|
|
7
|
+
/** Where /init-verifiers writes one skill per zone, and where /verify reads them. */
|
|
8
|
+
export const VERIFIERS_DIR = "/output/verifiers";
|
|
9
|
+
|
|
10
|
+
/** The file-name slug of a zone: `Web UI` → `web-ui`. */
|
|
11
|
+
export function safeZoneName(zone: string): string {
|
|
12
|
+
return zone.replace(/[^a-z0-9]+/gi, "-").toLowerCase();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** The path of a zone's skill. */
|
|
16
|
+
export function verifierPath(zone: string): string {
|
|
17
|
+
return `${VERIFIERS_DIR}/verify-${safeZoneName(zone)}.md`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The request /verify sends to the main loop: follow one zone's skill, or every
|
|
22
|
+
* skill, by running it — the check the tests cannot make — and report as the skill
|
|
23
|
+
* says; a failure ends in the report, never in a fix. Without a skill it says so
|
|
24
|
+
* instead of improvising a check.
|
|
25
|
+
*/
|
|
26
|
+
export function buildVerifyRequest(zone: string): string {
|
|
27
|
+
const z = zone.trim();
|
|
28
|
+
const which = z.length > 0
|
|
29
|
+
? verificationSkill(verifierPath(z))
|
|
30
|
+
: everyVerificationSkill(VERIFIERS_DIR);
|
|
31
|
+
const missing = z.length > 0 ? IF_THAT_FILE_IS_MISSING : IF_THERE_IS_NONE;
|
|
32
|
+
return verifyRequest(which, missing);
|
|
33
|
+
}
|