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,103 @@
|
|
|
1
|
+
// @orkeon-script 1.0
|
|
2
|
+
/// <reference path="../.orkeon/orkeon.d.ts" />
|
|
3
|
+
//
|
|
4
|
+
// DevVerify crew (dev-verify). Composition root: it builds the auditor agent from its
|
|
5
|
+
// charter and wires application/run-dev-verify, which checks the batch's gate, writes
|
|
6
|
+
// the capture under <work>/<code>/capture-F<n>/, measures the access cost over the code index
|
|
7
|
+
// (index_status, incremental_reindex, access_cost), runs the whole suite under full, asks
|
|
8
|
+
// the read-only auditor (its read tools and run_validation, plan mode) - its brief carries the shared memory's
|
|
9
|
+
// mistake precedents (T4) - and writes <CODE>-VERIFY-F<n>.md; after a GAPS verdict, the mistakes that recur in three
|
|
10
|
+
// batches become candidates under memory.dir and /dev-learn is nudged at two (M-7).
|
|
11
|
+
// A red gate or --gate-only returns the gate lines without any model call. The auditor's act runs in a
|
|
12
|
+
// background child, `dev-auditor`, which /tasks lists and stops while it runs (A-3,
|
|
13
|
+
// shared/application/agents/child-agent.ts).
|
|
14
|
+
//
|
|
15
|
+
// Input (globalThis.inputs): { batch: "F<n>", plan?: string | null, mode?: "fast" | "full" | "resume", gateOnly?: boolean,
|
|
16
|
+
// hooks?: the /hooks registry, effort?: "low" | "medium" | "high" | "xhigh" | "max" | null,
|
|
17
|
+
// concurrency?: number, maxInstances?: number, memoryRecall?: false (a session rule denies it) }
|
|
18
|
+
// Run standalone: bash scripts/run-crew.sh src/crews/dev-verify/crew.ork.ts --inputs '{"batch":"F1","gateOnly":true}'
|
|
19
|
+
//
|
|
20
|
+
// Budget: under full, the build (900 s), the whole suite (900 s) and three validations
|
|
21
|
+
// (300 s each) can all run, plus the model's own time: one hour of wall time.
|
|
22
|
+
|
|
23
|
+
import { CrewBuilder, publishCrew, inputs, ToolBuilder } from "../../shared/infrastructure/globals.ts";
|
|
24
|
+
import { runValidationTool, scriptToolSlot } from "../../shared/infrastructure/orkeon/script-tools.ts";
|
|
25
|
+
import type { ValidationCalls } from "../../shared/infrastructure/orkeon/script-tools.ts";
|
|
26
|
+
import { STEP_BUDGETS } from "../../shared/domain/dev/step-budget.ts";
|
|
27
|
+
import { orkeonActRoute, orkeonAgent, orkeonClock, orkeonPrunedLlm, orkeonSessionIo } from "../../shared/infrastructure/orkeon/wiring.ts";
|
|
28
|
+
import { memoryRecallOn, memoryRecallTools } from "../../shared/infrastructure/orkeon/memory-tools.ts";
|
|
29
|
+
import { agentTools, verifyCallbacks, verifyDeps } from "../../shared/infrastructure/orkeon/dev-deps.ts";
|
|
30
|
+
import { childAgentBody, withChildAct } from "../../shared/infrastructure/orkeon/child-agents.ts";
|
|
31
|
+
import { createChildBoard } from "../../shared/application/agents/child-agent.ts";
|
|
32
|
+
import { charterCatalogue } from "../../shared/domain/agents/charter.ts";
|
|
33
|
+
import { instanceLimits } from "../../shared/domain/agents/instances.ts";
|
|
34
|
+
import { providerEffort } from "../../shared/domain/agent-policy/behavior-flags.ts";
|
|
35
|
+
import { AUDITOR_CHARTER } from "./domain/auditor-charter.ts";
|
|
36
|
+
import { runDevVerify } from "./application/run-dev-verify.ts";
|
|
37
|
+
|
|
38
|
+
// memory_recall is attached unless a session rule denies every call of it (the command says so).
|
|
39
|
+
const memoryOn = memoryRecallOn(inputs());
|
|
40
|
+
const effort = providerEffort(inputs().effort);
|
|
41
|
+
const limits = instanceLimits(inputs());
|
|
42
|
+
// The auditor's run_validation: built here, bound by the body to the run's recording runner (audit.ts) and
|
|
43
|
+
// released when the audit ends; two runs bound at once make it refuse (script-tool-slot.ts).
|
|
44
|
+
const validationSlot = scriptToolSlot<ValidationCalls>();
|
|
45
|
+
// memory_recall's ports: over the tools of the verifier's body (dev-deps.ts), never the global's.
|
|
46
|
+
const bodyTools = agentTools();
|
|
47
|
+
// These callbacks, then the host's gate on the input they return (Orkeon #303): the step's rule sets again and the /hooks the command passed,
|
|
48
|
+
// over the tools of the body that acts (the verifier's, or the background auditor's own).
|
|
49
|
+
const options = { hooks: inputs().hooks, effort, memoryOn };
|
|
50
|
+
const callbacksFor = (ctx: any) => verifyCallbacks(ctx, options);
|
|
51
|
+
|
|
52
|
+
/** The auditor as a child, added to the crew by its first act (a sequential crew would run an agent it holds from the start). */
|
|
53
|
+
const auditorChild = () => {
|
|
54
|
+
const builder = orkeonAgent()
|
|
55
|
+
.name(AUDITOR_CHARTER.name)
|
|
56
|
+
.role(AUDITOR_CHARTER.role)
|
|
57
|
+
.goal(AUDITOR_CHARTER.goal)
|
|
58
|
+
.tools(charterCatalogue(AUDITOR_CHARTER))
|
|
59
|
+
.withAutonomousTool(runValidationTool(ToolBuilder, validationSlot))
|
|
60
|
+
.withAutonomousTools(memoryRecallTools(ToolBuilder, bodyTools.memoryPorts(), memoryOn))
|
|
61
|
+
.maxIterations(AUDITOR_CHARTER.maxIterations)
|
|
62
|
+
.body(childAgentBody(callbacksFor, (llm, ctx) => orkeonPrunedLlm(llm, ctx.log, ctx.tools)));
|
|
63
|
+
return effort === undefined ? builder : builder.effort(effort);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const verifier = orkeonAgent()
|
|
67
|
+
.name("dev-verifier")
|
|
68
|
+
.role(AUDITOR_CHARTER.role)
|
|
69
|
+
.goal(AUDITOR_CHARTER.goal)
|
|
70
|
+
// The auditor's tools.
|
|
71
|
+
.tools(charterCatalogue(AUDITOR_CHARTER))
|
|
72
|
+
.withAutonomousTool(runValidationTool(ToolBuilder, validationSlot))
|
|
73
|
+
.withAutonomousTools(memoryRecallTools(ToolBuilder, bodyTools.memoryPorts(), memoryOn))
|
|
74
|
+
.maxIterations(AUDITOR_CHARTER.maxIterations)
|
|
75
|
+
.body(async (_input: any, ctx: any) => {
|
|
76
|
+
bodyTools.bind(ctx.tools);
|
|
77
|
+
const clock = orkeonClock();
|
|
78
|
+
const board = createChildBoard({ state: orkeonSessionIo(ctx.tools), clock, log: ctx.log }, { crew: "dev-verify", step: "dev-verify" });
|
|
79
|
+
try {
|
|
80
|
+
// The ports over this body's tools (dev-deps.ts); the audit's act in a background child, /tasks listing it;
|
|
81
|
+
// T4's precedents in its brief, and after a GAPS verdict the mistakes that recur become candidates (M-7).
|
|
82
|
+
const deps = verifyDeps(ctx, {
|
|
83
|
+
...options, validationSlot, harvest: true,
|
|
84
|
+
wrapLlm: (llm) => withChildAct(llm, ctx, crew, { board, clock, log: ctx.log, effort },
|
|
85
|
+
{ agent: AUDITOR_CHARTER.name, charter: AUDITOR_CHARTER.name, task: `audit of ${String(inputs().batch ?? "the batch")}`, builder: auditorChild }),
|
|
86
|
+
});
|
|
87
|
+
return await runDevVerify(inputs(), { ...deps, route: orkeonActRoute(ctx.log, ctx.tools) });
|
|
88
|
+
} finally {
|
|
89
|
+
await board.close();
|
|
90
|
+
}
|
|
91
|
+
})
|
|
92
|
+
.build();
|
|
93
|
+
|
|
94
|
+
const crew = CrewBuilder()
|
|
95
|
+
.name("dev-verify")
|
|
96
|
+
.process("sequential")
|
|
97
|
+
.budget(STEP_BUDGETS["dev-verify"])
|
|
98
|
+
.concurrency(limits.concurrency)
|
|
99
|
+
.maxInstances(limits.maxInstances)
|
|
100
|
+
.withAgent(verifier)
|
|
101
|
+
.build();
|
|
102
|
+
|
|
103
|
+
publishCrew(crew);
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
// The auditor's answer: the JSON schema it is extracted into, and the check that
|
|
2
|
+
// turns the extraction into an AuditAnswer or the list of what is wrong with it.
|
|
3
|
+
// Pure, no IO. Axes are spelt as the verdict files spell them, so the learning
|
|
4
|
+
// pass reads the rows this answer becomes.
|
|
5
|
+
|
|
6
|
+
import type { Severity } from "../../../shared/domain/dev/verdict-format.ts";
|
|
7
|
+
import { AXES } from "../../../shared/domain/dev/verdict-format.ts";
|
|
8
|
+
import type { Axis } from "../../../shared/domain/dev/verdict-format.ts";
|
|
9
|
+
import type { Checked } from "../../../shared/domain/agents/charter.ts";
|
|
10
|
+
import { rowAxis, rowFieldEmpty, rowNoCitation, rowSeverity, tooManyValidations, UNDECIDED_NOT_LIST, undecidedIncomplete, VALIDATIONS_NOT_LIST, VERDICT_VALID_OR_GAPS } from "./messages.ts";
|
|
11
|
+
import {
|
|
12
|
+
ANSWER_NOT_AN_OBJECT as ANSWER_NOT_OBJECT, atMostRows as tooManyRows, ROWS_MUST_BE_A_LIST as ROWS_NOT_LIST,
|
|
13
|
+
} from "../../../shared/domain/dev/messages.ts";
|
|
14
|
+
|
|
15
|
+
/** The axes live with the verdict format; re-exported for this crew's importers. */
|
|
16
|
+
export { AXES };
|
|
17
|
+
export type { Axis };
|
|
18
|
+
export const SEVERITY_ORDER: readonly Severity[] = ["Blocking", "Major", "Minor"];
|
|
19
|
+
|
|
20
|
+
export interface AuditRow { severity: Severity; axis: Axis; gap: string; evidence: string; fix: string }
|
|
21
|
+
export interface Undecided { check: string; reason: string }
|
|
22
|
+
export interface AuditAnswer { verdict: "VALID" | "GAPS"; rows: AuditRow[]; validations: string[]; undecided: Undecided[] }
|
|
23
|
+
|
|
24
|
+
export const MAX_ANSWER_ROWS = 40;
|
|
25
|
+
export const MAX_VALIDATIONS = 3;
|
|
26
|
+
|
|
27
|
+
export const AUDIT_ANSWER_SCHEMA: object = {
|
|
28
|
+
type: "object",
|
|
29
|
+
properties: {
|
|
30
|
+
verdict: { type: "string", enum: ["VALID", "GAPS"] },
|
|
31
|
+
rows: {
|
|
32
|
+
type: "array",
|
|
33
|
+
items: {
|
|
34
|
+
type: "object",
|
|
35
|
+
properties: {
|
|
36
|
+
severity: { type: "string", enum: [...SEVERITY_ORDER] },
|
|
37
|
+
axis: { type: "string", enum: [...AXES] },
|
|
38
|
+
gap: { type: "string" },
|
|
39
|
+
evidence: { type: "string" },
|
|
40
|
+
fix: { type: "string" },
|
|
41
|
+
},
|
|
42
|
+
required: ["severity", "axis", "gap", "evidence", "fix"],
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
validations: { type: "array", items: { type: "string" } },
|
|
46
|
+
undecided: {
|
|
47
|
+
type: "array",
|
|
48
|
+
items: {
|
|
49
|
+
type: "object",
|
|
50
|
+
properties: { check: { type: "string" }, reason: { type: "string" } },
|
|
51
|
+
required: ["check", "reason"],
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
required: ["verdict", "rows", "validations"],
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/** A path:line citation, or the capture it comes from. */
|
|
59
|
+
const CITATION = /[A-Za-z0-9_./-]+:\d+/;
|
|
60
|
+
/** An axis label that names the plan by its staleness (LC:36). */
|
|
61
|
+
const PLAN_ALIAS = "stale plan";
|
|
62
|
+
|
|
63
|
+
function isPlainObject(value: unknown): value is Record<string, unknown> {
|
|
64
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function text(value: unknown): string {
|
|
68
|
+
return typeof value === "string" ? value.trim() : "";
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** The tool's name written around one quoted command: `run_validation "<command>"`, its '…' and `…` forms, or the
|
|
72
|
+
* same between parentheses, where the argument may also be named (`command="<command>"`). A quote may hold its own
|
|
73
|
+
* kind escaped (`\"`), read back unescaped; an unescaped one ends it, so the form has one reading. */
|
|
74
|
+
const TOOL_WRAPPED =
|
|
75
|
+
/^run_validation\s*(\(\s*(?:command\s*[=:]\s*)?)?(?:"((?:[^"\\]|\\.)+)"|'((?:[^'\\]|\\.)+)'|`([^`]+)`)\s*(\))?$/;
|
|
76
|
+
|
|
77
|
+
/** A validation as the pack's commands read it: the command alone, the tool's name around it taken off. */
|
|
78
|
+
export function validationCommand(written: string): string {
|
|
79
|
+
const trimmed = written.trim();
|
|
80
|
+
const m = TOOL_WRAPPED.exec(trimmed);
|
|
81
|
+
if (m === null) return trimmed;
|
|
82
|
+
if ((m[1] !== undefined) !== (m[5] !== undefined)) return trimmed; // an unbalanced parenthesis: no single reading
|
|
83
|
+
if (m[2] !== undefined) return m[2].replace(/\\(["\\])/g, "$1").trim();
|
|
84
|
+
if (m[3] !== undefined) return m[3].replace(/\\(['\\])/g, "$1").trim();
|
|
85
|
+
return m[4].trim();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function axisOf(label: string): Axis | undefined {
|
|
89
|
+
const folded = label.toLowerCase();
|
|
90
|
+
if (folded.startsWith(PLAN_ALIAS)) return "Plan";
|
|
91
|
+
return AXES.find((a) => a.toLowerCase() === folded);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function citesEvidence(evidence: string): boolean {
|
|
95
|
+
return CITATION.test(evidence) || evidence.includes("table.md") || evidence.includes("capture-");
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function checkRow(value: unknown, k: number, problems: string[]): AuditRow | undefined {
|
|
99
|
+
const item = isPlainObject(value) ? value : {};
|
|
100
|
+
const before = problems.length;
|
|
101
|
+
const severity = text(item.severity);
|
|
102
|
+
if (!SEVERITY_ORDER.includes(severity as Severity)) problems.push(rowSeverity(k));
|
|
103
|
+
const label = text(item.axis);
|
|
104
|
+
const axis = axisOf(label);
|
|
105
|
+
if (axis === undefined) problems.push(rowAxis(k, label, AXES.join(", ")));
|
|
106
|
+
const fields = { gap: text(item.gap), evidence: text(item.evidence), fix: text(item.fix) };
|
|
107
|
+
for (const [field, value] of Object.entries(fields)) {
|
|
108
|
+
if (value === "") problems.push(rowFieldEmpty(k, field));
|
|
109
|
+
}
|
|
110
|
+
if (fields.evidence !== "" && !citesEvidence(fields.evidence)) problems.push(rowNoCitation(k));
|
|
111
|
+
if (problems.length > before || axis === undefined) return undefined;
|
|
112
|
+
return { severity: severity as Severity, axis, ...fields };
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function checkAuditAnswer(value: unknown): Checked<AuditAnswer> {
|
|
116
|
+
if (!isPlainObject(value)) return { ok: false, problems: [ANSWER_NOT_OBJECT] };
|
|
117
|
+
const problems: string[] = [];
|
|
118
|
+
const verdict = text(value.verdict);
|
|
119
|
+
if (verdict !== "VALID" && verdict !== "GAPS") problems.push(VERDICT_VALID_OR_GAPS);
|
|
120
|
+
|
|
121
|
+
const rows: AuditRow[] = [];
|
|
122
|
+
if (!Array.isArray(value.rows)) {
|
|
123
|
+
problems.push(ROWS_NOT_LIST);
|
|
124
|
+
} else {
|
|
125
|
+
if (value.rows.length > MAX_ANSWER_ROWS) problems.push(tooManyRows(MAX_ANSWER_ROWS, value.rows.length));
|
|
126
|
+
value.rows.forEach((item, i) => {
|
|
127
|
+
const checked = checkRow(item, i + 1, problems);
|
|
128
|
+
if (checked) rows.push(checked);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
let validations: string[] = [];
|
|
133
|
+
if (!Array.isArray(value.validations) || value.validations.some((v) => typeof v !== "string")) {
|
|
134
|
+
problems.push(VALIDATIONS_NOT_LIST);
|
|
135
|
+
} else {
|
|
136
|
+
validations = value.validations.map((v: string) => validationCommand(v));
|
|
137
|
+
if (validations.length > MAX_VALIDATIONS) problems.push(tooManyValidations(MAX_VALIDATIONS, validations.length));
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const undecided: Undecided[] = [];
|
|
141
|
+
const items = value.undecided ?? [];
|
|
142
|
+
if (!Array.isArray(items)) {
|
|
143
|
+
problems.push(UNDECIDED_NOT_LIST);
|
|
144
|
+
} else {
|
|
145
|
+
items.forEach((item, i) => {
|
|
146
|
+
const entry = isPlainObject(item) ? { check: text(item.check), reason: text(item.reason) } : { check: "", reason: "" };
|
|
147
|
+
if (entry.check === "" || entry.reason === "") problems.push(undecidedIncomplete(i + 1));
|
|
148
|
+
else undecided.push(entry);
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (problems.length > 0) return { ok: false, problems };
|
|
153
|
+
return { ok: true, value: { verdict: verdict as AuditAnswer["verdict"], rows, validations, undecided } };
|
|
154
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// The auditor's charter: a read-only sub-agent in plan mode, with seven read
|
|
2
|
+
// tools and no shell: a command it doubts runs through the read-class
|
|
3
|
+
// run_validation tool when its crew offers it, or is named back to code. glob
|
|
4
|
+
// decides a name past the cut of the brief's project list; affected_tests gives
|
|
5
|
+
// the test class a validation is built on.
|
|
6
|
+
|
|
7
|
+
import type { Charter } from "../../../shared/domain/agents/charter.ts";
|
|
8
|
+
|
|
9
|
+
export const AUDITOR_TOOLS: readonly string[] = [
|
|
10
|
+
"file_read", "node_read", "glob", "codebase_search", "symbol_detail", "symbol_source", "affected_tests",
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
export const AUDITOR_CHARTER: Charter = {
|
|
14
|
+
name: "dev-auditor",
|
|
15
|
+
role: "Batch auditor",
|
|
16
|
+
goal: "Weigh one delivered batch against its code and its sheet, and answer with evidenced gaps",
|
|
17
|
+
mode: "plan",
|
|
18
|
+
tools: AUDITOR_TOOLS,
|
|
19
|
+
disallowed: ["shell_command", "file_write", "rag_ingest"],
|
|
20
|
+
maxIterations: 12,
|
|
21
|
+
};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
// The sections of a dev-verify capture: how one section text is split into files the
|
|
2
|
+
// model can read whole, and the small readings each section is made of (a build log, a
|
|
3
|
+
// test tail, the classes of a test file). Pure.
|
|
4
|
+
export { isTestFile, isTestRoot } from "../../../shared/domain/dev/access-cost.ts";
|
|
5
|
+
import { cutNotCaptured, idsOfTheSheet, NO_CLASS_FOUND, TRAITS_NOT_CHECKED } from "./messages.ts";
|
|
6
|
+
|
|
7
|
+
export const MAX_SECTION_CHARS = 32_000;
|
|
8
|
+
export const SECTION_CUT_CHARS = 31_000;
|
|
9
|
+
export const MAX_SECTION_PARTS = 10;
|
|
10
|
+
export const MAX_DIFF_FILES = 40;
|
|
11
|
+
export const MAX_CLASS_FILES = 40; // AC:354
|
|
12
|
+
export const TEST_TAIL_LINES = 15; // AC:315
|
|
13
|
+
export const BUILD_ERROR_LINES = 6; // AC:211
|
|
14
|
+
export const TRAIT_HIT_LINES = 40; // AC:305
|
|
15
|
+
|
|
16
|
+
const WHY_CHARS = 120;
|
|
17
|
+
const BUILD_LOG_ERROR = /Build FAILED|(^|[^A-Za-z])error [A-Z]+[0-9]+|^exit=[1-9]/m;
|
|
18
|
+
const FAILURE_LINE = /error|Error|failed|Failed|FAIL/;
|
|
19
|
+
const CLASS_DECL = /\b(class|record)\s+([A-Za-z_][A-Za-z0-9_]*)/g;
|
|
20
|
+
const DESCRIBE_CALL = /\bdescribe\(\s*["'`]([^"'`]+)["'`]/g;
|
|
21
|
+
|
|
22
|
+
export interface SectionFile { name: string; content: string } // "build.txt", "diff-003-2.txt"
|
|
23
|
+
|
|
24
|
+
function partName(base: string, k: number): string {
|
|
25
|
+
return k === 1 ? `${base}.txt` : `${base}-${k}.txt`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** One file when the content fits in 32 000 characters, else parts cut on a line break (§ 2.3). */
|
|
29
|
+
export function splitSection(base: string, content: string): SectionFile[] {
|
|
30
|
+
if (content.length <= MAX_SECTION_CHARS) return [{ name: partName(base, 1), content }];
|
|
31
|
+
const files: SectionFile[] = [];
|
|
32
|
+
let rest = content;
|
|
33
|
+
for (let k = 1; ; k++) {
|
|
34
|
+
if (rest.length <= MAX_SECTION_CHARS) {
|
|
35
|
+
files.push({ name: partName(base, k), content: rest });
|
|
36
|
+
return files;
|
|
37
|
+
}
|
|
38
|
+
const lastBreak = rest.lastIndexOf("\n", SECTION_CUT_CHARS);
|
|
39
|
+
const end = lastBreak >= 0 ? lastBreak + 1 : SECTION_CUT_CHARS;
|
|
40
|
+
const part = rest.slice(0, end);
|
|
41
|
+
rest = rest.slice(end);
|
|
42
|
+
if (k === MAX_SECTION_PARTS) {
|
|
43
|
+
files.push({ name: partName(base, k), content: `${part}${cutNotCaptured(rest.length)}` });
|
|
44
|
+
return files;
|
|
45
|
+
}
|
|
46
|
+
files.push({ name: partName(base, k), content: `${part}\n[continued in ${partName(base, k + 1)}]\n` });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** 1 → "diff-001". */
|
|
51
|
+
export function diffBase(index: number): string {
|
|
52
|
+
return `diff-${String(index).padStart(3, "0")}`;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function lines(text: string): string[] {
|
|
56
|
+
const all = text.split("\n").map((l) => l.replace(/\r$/, ""));
|
|
57
|
+
if (all.length > 0 && all[all.length - 1] === "") all.pop();
|
|
58
|
+
return all;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** The first line of the log that marks a failed build (AC:246); null when the log reads green. */
|
|
62
|
+
export function buildLogProblem(log: string): string | null {
|
|
63
|
+
for (const l of lines(log)) if (BUILD_LOG_ERROR.test(l)) return l;
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** The lines a failed build shows, and why it failed in one line of at most 120 characters (AC:274-275). */
|
|
68
|
+
export function buildFailure(output: string): { why: string; lines: string[] } {
|
|
69
|
+
const all = lines(output);
|
|
70
|
+
const failing = all.filter((l) => FAILURE_LINE.test(l));
|
|
71
|
+
const shown = failing.length > 0 ? failing.slice(0, BUILD_ERROR_LINES) : all.slice(-BUILD_ERROR_LINES);
|
|
72
|
+
const why = (failing[0] ?? all[all.length - 1] ?? "").slice(0, WHY_CHARS);
|
|
73
|
+
return { why, lines: shown };
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function tailLines(text: string, n: number): string[] {
|
|
77
|
+
return n <= 0 ? [] : lines(text).slice(-n);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface TestRunSummary { passed: number | null; failed: number | null; exit: number | null }
|
|
81
|
+
|
|
82
|
+
/** The summary of a test run's tail: VSTest, Microsoft.Testing.Platform and Node's runner, and `exit=` (AC:415-420). */
|
|
83
|
+
export function testRunSummary(tail: readonly string[]): TestRunSummary {
|
|
84
|
+
let passed = 0;
|
|
85
|
+
let failed = 0;
|
|
86
|
+
let seen = false;
|
|
87
|
+
let exit: number | null = null;
|
|
88
|
+
for (const raw of tail) {
|
|
89
|
+
const l = raw.replace(/\r$/, "");
|
|
90
|
+
const vstest = /Failed: *([0-9]+), *Passed: *([0-9]+)/.exec(l);
|
|
91
|
+
if (vstest) { failed += Number(vstest[1]); passed += Number(vstest[2]); seen = true; }
|
|
92
|
+
let m: RegExpExecArray | null;
|
|
93
|
+
if ((m = /^ *failed: *([0-9]+) *$/.exec(l))) { failed += Number(m[1]); seen = true; }
|
|
94
|
+
if ((m = /^ *succeeded: *([0-9]+) *$/.exec(l))) { passed += Number(m[1]); seen = true; }
|
|
95
|
+
if ((m = /^(ℹ|#) (pass|fail) ([0-9]+)\s*$/.exec(l))) {
|
|
96
|
+
if (m[2] === "pass") passed += Number(m[3]);
|
|
97
|
+
else failed += Number(m[3]);
|
|
98
|
+
seen = true;
|
|
99
|
+
}
|
|
100
|
+
if ((m = /^exit=([0-9]+)/.exec(l))) exit = Number(m[1]);
|
|
101
|
+
}
|
|
102
|
+
return { passed: seen ? passed : null, failed: seen ? failed : null, exit };
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** The classes and records a test file declares, sorted, then the names of its describe() calls. */
|
|
106
|
+
export function classesIn(source: string): string[] {
|
|
107
|
+
const classes = [...new Set([...source.matchAll(CLASS_DECL)].map((m) => m[2]))].sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
|
|
108
|
+
const out = [...classes];
|
|
109
|
+
for (const m of source.matchAll(DESCRIBE_CALL)) if (!out.includes(m[1])) out.push(m[1]);
|
|
110
|
+
return out;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** The basename up to its first "." (AC:341). */
|
|
114
|
+
export function typeNameOf(path: string): string {
|
|
115
|
+
const base = path.slice(path.lastIndexOf("/") + 1);
|
|
116
|
+
const dot = base.indexOf(".");
|
|
117
|
+
return dot < 0 ? base : base.slice(0, dot);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** The `traits` section: the marker, the sheet's ids, then the first 40 hits as `path:line text`. */
|
|
121
|
+
export function traitsSection(marker: string | null, ids: readonly string[], hits: readonly string[] | null): string {
|
|
122
|
+
if (marker === null) return TRAITS_NOT_CHECKED;
|
|
123
|
+
const out = [`marker: ${marker}`, idsOfTheSheet(ids.join(" "))];
|
|
124
|
+
for (const h of (hits ?? []).filter((x) => x !== "").slice(0, TRAIT_HIT_LINES)) out.push(h.replace(/:([0-9]*):/, ":$1 "));
|
|
125
|
+
return `${out.join("\n")}\n`;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* One line of the `test-classes` section. A test file gives its classes; another file gives the
|
|
130
|
+
* test files naming its type, or `why` when they were not searched.
|
|
131
|
+
*/
|
|
132
|
+
export function testClassesLine(
|
|
133
|
+
path: string, classes: readonly string[] | null, testFiles: readonly string[] | null, why?: string,
|
|
134
|
+
): string {
|
|
135
|
+
if (classes !== null) return `${path}: ${classes.length > 0 ? classes.join(", ") : NO_CLASS_FOUND}`;
|
|
136
|
+
const found = testFiles === null ? (why ?? "none") : testFiles.length > 0 ? testFiles.join(", ") : "none";
|
|
137
|
+
return `${path} -> tests naming ${typeNameOf(path)}: ${found}`;
|
|
138
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// The shell lines dev-verify runs, every one frozen here so that the gate, the capture
|
|
2
|
+
// and their tests share one spelling. The runtime's shell runs a command line without
|
|
3
|
+
// operators: quoting is the only syntax used. A builder gives null when a path or name
|
|
4
|
+
// cannot be quoted, or when a list it needs is left empty once the unquotable entries are
|
|
5
|
+
// dropped; its caller says the item is not captured. Pure.
|
|
6
|
+
|
|
7
|
+
import { buildOutputsNotPaths } from "./messages.ts";
|
|
8
|
+
|
|
9
|
+
const PLAIN_WORD = /^[A-Za-z0-9_./@+,:=-]+$/;
|
|
10
|
+
const IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
11
|
+
const MAX_FIND_PATHS = 200;
|
|
12
|
+
|
|
13
|
+
/** The word as the shell gets it: as is when /^[A-Za-z0-9_./@+,:=-]+$/, else single-quoted; null when it holds a "'". */
|
|
14
|
+
export function shellWord(value: string): string | null {
|
|
15
|
+
if (PLAIN_WORD.test(value)) return value;
|
|
16
|
+
if (value.includes("'")) return null;
|
|
17
|
+
return `'${value}'`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** AC:104: a folder name, not a path. */
|
|
21
|
+
export function buildOutputProblem(name: string): string | undefined {
|
|
22
|
+
return name === "" || name === "." || name === ".." || name.includes("/")
|
|
23
|
+
? buildOutputsNotPaths(name)
|
|
24
|
+
: undefined;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** ["':(exclude,glob)**\/bin/**'", …], one per layout.build_outputs entry (AC:101-106). */
|
|
28
|
+
export function excludePathspecs(buildOutputs: readonly string[]): string[] {
|
|
29
|
+
const out: string[] = [];
|
|
30
|
+
for (const o of buildOutputs) {
|
|
31
|
+
const word = shellWord(`:(exclude,glob)**/${o}/**`);
|
|
32
|
+
if (word !== null) out.push(word);
|
|
33
|
+
}
|
|
34
|
+
return out;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const GIT_CHANGED_TRACKED = "git diff --name-only HEAD";
|
|
38
|
+
export const GIT_DIFF_CHECK = "git diff --check HEAD";
|
|
39
|
+
|
|
40
|
+
function line(parts: ReadonlyArray<string | readonly string[]>): string {
|
|
41
|
+
return parts.flat().filter((p) => p !== "").join(" ");
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** The quotable words of `values`; null when a non-empty list keeps none. */
|
|
45
|
+
function words(values: readonly string[]): string[] | null {
|
|
46
|
+
const out = values.map(shellWord).filter((w): w is string => w !== null);
|
|
47
|
+
return values.length > 0 && out.length === 0 ? null : out;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
export function gitUntracked(excludes: readonly string[]): string {
|
|
52
|
+
return line(["git ls-files --others --exclude-standard -- .", excludes]);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function gitTraitGrep(ere: string, scope: readonly string[], excludes: readonly string[]): string | null {
|
|
56
|
+
const scopeWords = words(scope);
|
|
57
|
+
return scopeWords === null ? null : line([`git grep --untracked -I -noE -e '${ere}' --`, scopeWords, excludes]);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function gitStatusShort(excludes: readonly string[]): string {
|
|
61
|
+
return line(["git status --short -- .", excludes]);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function gitDiffTracked(path: string): string | null {
|
|
65
|
+
const word = shellWord(path);
|
|
66
|
+
return word === null ? null : `git diff HEAD -- ${word}`;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function gitDiffUntracked(path: string): string | null {
|
|
70
|
+
const word = shellWord(path);
|
|
71
|
+
return word === null ? null : `git diff --no-index -- /dev/null ${word}`;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function gitMethodGrep(methods: readonly string[], testDirs: readonly string[], excludes: readonly string[]): string | null {
|
|
75
|
+
const methodWords = words(methods);
|
|
76
|
+
const dirWords = words(testDirs);
|
|
77
|
+
if (methodWords === null || dirWords === null) return null;
|
|
78
|
+
return line(["git grep --untracked -I -n -o -w -F", methodWords.flatMap((m) => ["-e", m]), "--", dirWords, excludes]);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function gitTestFilesNaming(
|
|
82
|
+
type: string, testDirs: readonly string[], ext: string, excludes: readonly string[],
|
|
83
|
+
): string | null {
|
|
84
|
+
if (!IDENTIFIER.test(type)) return null;
|
|
85
|
+
const specs: string[] = [];
|
|
86
|
+
for (const dir of testDirs) {
|
|
87
|
+
const d = dir.replace(/\/+$/, "");
|
|
88
|
+
const word = shellWord(d === "" || d === "." ? `:(glob)**/*.${ext}` : `:(glob)${d}/**/*.${ext}`);
|
|
89
|
+
if (word === null) return null;
|
|
90
|
+
specs.push(word);
|
|
91
|
+
}
|
|
92
|
+
return line([`git grep --untracked -I -lw -e ${type} --`, specs, excludes]);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** `find ./<path>… -maxdepth 0 -newer <log>`: "./" keeps a name such as "-delete" a path; null for an absolute path. */
|
|
96
|
+
export function findNewer(paths: readonly string[], log: string): string | null {
|
|
97
|
+
if (paths.length === 0 || paths.length > MAX_FIND_PATHS) return null;
|
|
98
|
+
if (paths.some((p) => p.startsWith("/"))) return null;
|
|
99
|
+
const pathWords = paths.map((p) => shellWord(p.startsWith("./") ? p : `./${p}`));
|
|
100
|
+
const logWord = shellWord(log);
|
|
101
|
+
if (logWord === null || pathWords.some((w) => w === null)) return null;
|
|
102
|
+
return line(["find", pathWords as string[], `-maxdepth 0 -newer ${logWord}`]);
|
|
103
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
// The gate of dev-verify: five mechanical checks on a batch before any audit - the sheet
|
|
2
|
+
// closed, every design id classified, every changed file in scope, every sheet id carried
|
|
3
|
+
// by a test trait, no whitespace error. The ok/FAIL lines keep the harness's wording, so
|
|
4
|
+
// that both gates print the same lines on the same batch. Pure: the application gathers
|
|
5
|
+
// the inputs (run-gate.ts).
|
|
6
|
+
import type { SheetFacts } from "./sheet-facts.ts";
|
|
7
|
+
import type { TraitMarker } from "../../../shared/domain/dev/trait-pattern.ts";
|
|
8
|
+
import { SHEET_ID_SOURCE, idsInMatch } from "../../../shared/domain/dev/trait-pattern.ts";
|
|
9
|
+
import { missingDesignIds } from "../../../shared/domain/dev/plan-checks.ts";
|
|
10
|
+
import type { PlanFolderTexts } from "../../../shared/domain/dev/plan-checks.ts";
|
|
11
|
+
export type { PlanFolderTexts } from "../../../shared/domain/dev/plan-checks.ts";
|
|
12
|
+
import {
|
|
13
|
+
DESIGN_IDS_CLASSIFIED, designIdsUnclassified, DIFF_CHECK_CLEAN, DIFF_CHECK_DIRTY, filesOutsideRoots, gateGreen, gateHeader,
|
|
14
|
+
gateRed, idsNotCarried, SCOPE_NO_ROOT, scopeInRoots, SHEET_CLOSED, SHEET_NOT_CLOSED, strayTraitIds, TRAITS_NO_ID,
|
|
15
|
+
TRAITS_NO_RULE, traitsCarried,
|
|
16
|
+
} from "./messages.ts";
|
|
17
|
+
|
|
18
|
+
export type GateLineKind = "ok" | "FAIL" | "note";
|
|
19
|
+
export interface GateLine { kind: GateLineKind; text: string }
|
|
20
|
+
export interface GateInput {
|
|
21
|
+
batch: string;
|
|
22
|
+
sheetShown: string; // relative to the top
|
|
23
|
+
sheet: string;
|
|
24
|
+
facts: SheetFacts; // sheetFacts(sheet)
|
|
25
|
+
plan: PlanFolderTexts;
|
|
26
|
+
planDirShown: string; // relative, no trailing "/"
|
|
27
|
+
planDirAbsolute: string; // "/workspace/" + planDirShown (printed by the stray note, AC:194)
|
|
28
|
+
roots: readonly string[];
|
|
29
|
+
changedFiles: readonly string[]; // sorted, unique
|
|
30
|
+
trait: TraitMarker | null;
|
|
31
|
+
traitHits: readonly string[] | null; // lines of gitTraitGrep; null when it was not run
|
|
32
|
+
diffCheckExit: number;
|
|
33
|
+
}
|
|
34
|
+
export interface GateReport {
|
|
35
|
+
green: boolean;
|
|
36
|
+
lines: string[]; // header, check lines, final line: what --gate-only prints
|
|
37
|
+
checks: GateLine[];
|
|
38
|
+
missingDesignIds: string[]; outside: string[]; untested: string[]; stray: string[];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const ok = (text: string): GateLine => ({ kind: "ok", text });
|
|
42
|
+
const fail = (text: string): GateLine => ({ kind: "FAIL", text });
|
|
43
|
+
const note = (text: string): GateLine => ({ kind: "note", text });
|
|
44
|
+
|
|
45
|
+
function checkClosed(facts: SheetFacts): GateLine {
|
|
46
|
+
return facts.closed
|
|
47
|
+
? ok(SHEET_CLOSED)
|
|
48
|
+
: fail(SHEET_NOT_CLOSED);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function outsideFiles(input: GateInput): string[] {
|
|
52
|
+
const prefixes = input.roots.map((r) => `${r.replace(/\/+$/, "")}/`);
|
|
53
|
+
const planPrefix = `${input.planDirShown}/`;
|
|
54
|
+
return input.changedFiles.filter((f) => {
|
|
55
|
+
if (f === "") return false;
|
|
56
|
+
if (prefixes.some((p) => f.startsWith(p))) return false;
|
|
57
|
+
if (f.startsWith(planPrefix)) return false;
|
|
58
|
+
const base = f.slice(f.lastIndexOf("/") + 1);
|
|
59
|
+
return !input.sheet.includes(base);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function knownIds(texts: readonly string[]): Set<string> {
|
|
64
|
+
const known = new Set<string>();
|
|
65
|
+
for (const t of texts) for (const id of t.match(new RegExp(SHEET_ID_SOURCE, "g")) ?? []) known.add(id);
|
|
66
|
+
return known;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function runGateChecks(input: GateInput): GateReport {
|
|
70
|
+
const checks: GateLine[] = [checkClosed(input.facts)];
|
|
71
|
+
|
|
72
|
+
const missing = missingDesignIds(input.plan);
|
|
73
|
+
checks.push(missing.length === 0
|
|
74
|
+
? ok(DESIGN_IDS_CLASSIFIED)
|
|
75
|
+
: fail(designIdsUnclassified(missing)));
|
|
76
|
+
|
|
77
|
+
let outside: string[] = [];
|
|
78
|
+
if (input.roots.length === 0) {
|
|
79
|
+
checks.push(note(SCOPE_NO_ROOT));
|
|
80
|
+
} else {
|
|
81
|
+
const roots = input.roots.join(" ");
|
|
82
|
+
outside = outsideFiles(input);
|
|
83
|
+
if (outside.length === 0) {
|
|
84
|
+
checks.push(ok(scopeInRoots(roots)));
|
|
85
|
+
} else {
|
|
86
|
+
checks.push(fail(filesOutsideRoots(roots)));
|
|
87
|
+
for (const f of outside) checks.push(note(f));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
let untested: string[] = [];
|
|
92
|
+
let stray: string[] = [];
|
|
93
|
+
if (input.trait === null) {
|
|
94
|
+
checks.push(note(TRAITS_NO_RULE));
|
|
95
|
+
} else if (input.facts.ids.length === 0) {
|
|
96
|
+
checks.push(note(TRAITS_NO_ID));
|
|
97
|
+
} else {
|
|
98
|
+
const hits = input.traitHits ?? [];
|
|
99
|
+
const carried = new Set(hits.flatMap(idsInMatch));
|
|
100
|
+
untested = input.facts.ids.filter((id) => !carried.has(id));
|
|
101
|
+
const shown = input.trait.shown;
|
|
102
|
+
checks.push(untested.length === 0
|
|
103
|
+
? ok(traitsCarried(shown))
|
|
104
|
+
: fail(idsNotCarried(shown, untested)));
|
|
105
|
+
const known = knownIds(input.plan.all);
|
|
106
|
+
const cited = [...new Set(hits.flatMap((h) => h.match(/(BR|UC|CH)-[0-9]+/g) ?? []))].sort();
|
|
107
|
+
stray = cited.filter((id) => !known.has(id));
|
|
108
|
+
if (stray.length > 0) {
|
|
109
|
+
checks.push(note(strayTraitIds(input.planDirAbsolute, stray)));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
checks.push(input.diffCheckExit === 0
|
|
114
|
+
? ok(DIFF_CHECK_CLEAN)
|
|
115
|
+
: fail(DIFF_CHECK_DIRTY));
|
|
116
|
+
|
|
117
|
+
const green = !checks.some((c) => c.kind === "FAIL");
|
|
118
|
+
const lines = [
|
|
119
|
+
gateHeader(input.batch, input.sheetShown),
|
|
120
|
+
...checks.map(gateLineText),
|
|
121
|
+
green ? gateGreen(input.batch) : gateRed(input.batch),
|
|
122
|
+
];
|
|
123
|
+
return { green, lines, checks, missingDesignIds: missing, outside, untested, stray };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** " ok <t>", " FAIL <t>", " <t>" (AC:96-98). */
|
|
127
|
+
export function gateLineText(line: GateLine): string {
|
|
128
|
+
if (line.kind === "ok") return ` ok ${line.text}`;
|
|
129
|
+
if (line.kind === "FAIL") return ` FAIL ${line.text}`;
|
|
130
|
+
return ` ${line.text}`;
|
|
131
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// The values dev-verify's writers and readers share: the check names of the mechanical table, which the verdict and
|
|
2
|
+
// the capture look rows up by.
|
|
3
|
+
|
|
4
|
+
export const CHECK_BUILD = "capture `build`";
|
|
5
|
+
export const CHECK_TRAITS = "ids carried by traits";
|
|
6
|
+
export const CHECK_METHODS = "step-table methods in the test roots";
|
|
7
|
+
export const CHECK_TEST_RUN = "last test run";
|
|
8
|
+
export const CHECK_SCOPE = "changed files in the batch";
|
|
9
|
+
export const CHECK_COST = "capture `cost`";
|
|
10
|
+
export const CHECK_CONVENTIONS = "layer rules of the changed layers";
|
|
11
|
+
export const CHECK_TICKED = "`TDD:` lines ticked";
|
|
12
|
+
export const CHECK_DESIGN_IDS = "design ids classified";
|
|
13
|
+
export const CHECK_APPLIED = "`Applied rules` ids are design-rule ids";
|
|
14
|
+
|
|
15
|
+
/** The header of the verdict table, which the verdict parsers read back. */
|
|
16
|
+
export const VERDICT_TABLE_HEADER = "| Severity | Axis | Gap | Evidence | Expected fix |";
|