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,109 @@
|
|
|
1
|
+
// Which rule sets each dev step puts in the gate before its crew runs (and its crew's callback checks
|
|
2
|
+
// again, call-guard.ts), the rules of a role on the repository pack's roots, and what a step does when
|
|
3
|
+
// the host's gate is off — pure, no IO.
|
|
4
|
+
import { pathRules, patternWriteRules, rewriteRules, rulesOf } from "../agent-policy/rule-sets.ts";
|
|
5
|
+
import type { PathRules, RuleSetId } from "../agent-policy/rule-sets.ts";
|
|
6
|
+
import type { PermissionRule } from "../agent-policy/permission.ts";
|
|
7
|
+
import type { RepoPackLayout } from "./repo-pack.ts";
|
|
8
|
+
import { GATE_ONLY_HINT, gateIsOff } from "./messages.ts";
|
|
9
|
+
|
|
10
|
+
/** A dev step whose crew runs a model under the gate and its callback. */
|
|
11
|
+
export type DevStep = "dev-verify" | "dev-plan" | "dev-spec" | "dev-change" | "dev-implement";
|
|
12
|
+
export const DEV_STEPS: readonly DevStep[] = ["dev-verify", "dev-plan", "dev-spec", "dev-change", "dev-implement"];
|
|
13
|
+
|
|
14
|
+
/** The command a step runs under, named where a line tells the person what to type: a change brief is /dev-spec with
|
|
15
|
+
* a kind, a batch and its audit are shapes of /dev-batches. Any other name is a command already. */
|
|
16
|
+
export function stepCommand(step: string): string {
|
|
17
|
+
if (step === "dev-change") return "dev-spec";
|
|
18
|
+
return step === "dev-implement" || step === "dev-verify" ? "dev-batches" : step;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** The sets every dev step holds today. */
|
|
22
|
+
export const DEV_STEP_RULE_SETS: readonly RuleSetId[] = [
|
|
23
|
+
"git-readonly", "inline-interpreters", "read-noise", "secrets", "state-files",
|
|
24
|
+
];
|
|
25
|
+
export const STEP_RULE_SETS: Readonly<Record<DevStep, readonly RuleSetId[]>> = {
|
|
26
|
+
"dev-verify": DEV_STEP_RULE_SETS,
|
|
27
|
+
"dev-plan": DEV_STEP_RULE_SETS,
|
|
28
|
+
"dev-spec": DEV_STEP_RULE_SETS,
|
|
29
|
+
"dev-change": DEV_STEP_RULE_SETS,
|
|
30
|
+
"dev-implement": DEV_STEP_RULE_SETS,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/** The calls a step lets run without a question. dev-implement's roles act in acceptEdits, where a tool
|
|
34
|
+
* declared `execute` would be asked at every test run: run_tests and run_build check their own commands
|
|
35
|
+
* (application/dev/wrapped-tools.ts). The gate is not cleared when a step completes (its `completed` hook is
|
|
36
|
+
* synchronous and reads no session; reapplyStepRules in commands/_lib/dev-step.ts): an earlier hop's allows stay
|
|
37
|
+
* until the next rule change or /assistant turn, and every deny comes before them. The crews' callback reads deny
|
|
38
|
+
* rules only. */
|
|
39
|
+
export const STEP_ALLOW_RULES: Readonly<Record<DevStep, readonly PermissionRule[]>> = {
|
|
40
|
+
"dev-verify": [],
|
|
41
|
+
"dev-plan": [],
|
|
42
|
+
"dev-spec": [],
|
|
43
|
+
"dev-change": [],
|
|
44
|
+
"dev-implement": [{ effect: "allow", tool: "run_tests" }, { effect: "allow", tool: "run_build" }],
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/** rulesOf(STEP_RULE_SETS[step]) then the step's allow rules: 479 deny rules for each step today, and two allow
|
|
48
|
+
* rules for dev-implement. */
|
|
49
|
+
export function stepRules(step: DevStep): PermissionRule[] {
|
|
50
|
+
return [...rulesOf(STEP_RULE_SETS[step]), ...STEP_ALLOW_RULES[step]];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** A role of a batch (L-6): the pilot reads no source or test file, the test author writes no
|
|
54
|
+
* source file, the implementer writes no test file. */
|
|
55
|
+
export type DevRole = "pilot" | "test-author" | "implementer";
|
|
56
|
+
export type LayoutRootKey = "domain" | "application" | "infrastructure" | "tests";
|
|
57
|
+
export const ROLE_ROOTS: Readonly<Record<DevRole, { access: "read" | "write"; keys: readonly LayoutRootKey[] }>> = {
|
|
58
|
+
pilot: { access: "read", keys: ["domain", "application", "infrastructure", "tests"] },
|
|
59
|
+
"test-author": { access: "write", keys: ["domain", "application", "infrastructure"] },
|
|
60
|
+
implementer: { access: "write", keys: ["tests"] },
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/** The pack keys a writing role's rewrite rule covers: every source root, whatever the role writes. */
|
|
64
|
+
export const REWRITE_KEYS: readonly LayoutRootKey[] = ["domain", "application", "infrastructure", "tests"];
|
|
65
|
+
|
|
66
|
+
/** pathRules over the role's roots the pack gives, the pack keys it lacks (`layout.tests`), and the patterns its
|
|
67
|
+
* root denies leave writable: the test author writes the test files beside the code (`layout.test_files`). A
|
|
68
|
+
* writing role also gets its `rewrite` rules: no whole write of an existing source file (rewriteRules). */
|
|
69
|
+
export interface RoleRules extends PathRules { missing: string[]; writable: string[]; rewrite: PermissionRule[] }
|
|
70
|
+
|
|
71
|
+
export function roleRules(role: DevRole, layout: Pick<RepoPackLayout, LayoutRootKey | "testFiles">): RoleRules {
|
|
72
|
+
const { access, keys } = ROLE_ROOTS[role];
|
|
73
|
+
const testFiles = (layout.testFiles ?? []).map((p) => p.trim()).filter((p) => p !== "");
|
|
74
|
+
const roots: string[] = [];
|
|
75
|
+
const missing: string[] = [];
|
|
76
|
+
for (const key of keys) {
|
|
77
|
+
const value = layout[key];
|
|
78
|
+
// A pack that names its tests by pattern only lacks no test folder.
|
|
79
|
+
if (value === undefined || value === "") { if (!(key === "tests" && testFiles.length > 0)) missing.push(`layout.${key}`); }
|
|
80
|
+
else roots.push(value);
|
|
81
|
+
}
|
|
82
|
+
const own = pathRules(access, roots);
|
|
83
|
+
if (role === "implementer" && testFiles.length > 0) {
|
|
84
|
+
const byPattern = patternWriteRules(testFiles);
|
|
85
|
+
const unscoped = new Set(own.rules.filter((r) => r.argument === undefined).map((r) => r.tool));
|
|
86
|
+
own.rules.push(...byPattern.rules.filter((r) => r.argument !== undefined || !unscoped.has(r.tool)));
|
|
87
|
+
own.problems.push(...byPattern.problems);
|
|
88
|
+
}
|
|
89
|
+
const rewrite = access === "write"
|
|
90
|
+
? rewriteRules(REWRITE_KEYS.flatMap((key) => layout[key]?.trim() ? [layout[key] as string] : []), testFiles)
|
|
91
|
+
: [];
|
|
92
|
+
return { ...own, missing, writable: role === "test-author" ? testFiles : [], rewrite };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export const GATE_SETTING = "Orkeon:Security:PermissionGate:Enabled";
|
|
96
|
+
|
|
97
|
+
/** What the step says before launching: refuse (no crew), or warn and launch. */
|
|
98
|
+
export interface GateProblem { refuse: boolean; line: string }
|
|
99
|
+
|
|
100
|
+
/** null when the host's gate is on, or when the host keeps no session rules (undefined), which the
|
|
101
|
+
* command reports itself. */
|
|
102
|
+
export function gateProblem(enabled: boolean | undefined, step: DevStep): GateProblem | null {
|
|
103
|
+
if (enabled !== false) return null;
|
|
104
|
+
const gateOnly = step === "dev-verify" ? GATE_ONLY_HINT : "";
|
|
105
|
+
return {
|
|
106
|
+
refuse: true,
|
|
107
|
+
line: gateIsOff(step, GATE_SETTING, stepCommand(step), gateOnly),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// The narrow test commands a validation (run_validation) or a run_tests call may run: one runs
|
|
2
|
+
// only when it is exactly one of the pack's narrow test commands, each placeholder filled with
|
|
3
|
+
// one plain relative value and nothing appended - never the whole suite, never a build, never an
|
|
4
|
+
// option or a shell operator. Pure.
|
|
5
|
+
import type { RepoPackCommands } from "./repo-pack.ts";
|
|
6
|
+
import {
|
|
7
|
+
AS_THE_PACK_NAMES_IT, INTEGRATION_WITHOUT_FILTER, NOT_A_PACK_TEST_COMMAND, NOT_ONE_LINE, nothingMayFollow,
|
|
8
|
+
PACK_HAS_NO_TEST_COMMAND, SHELL_OPERATOR_OUTSIDE_QUOTES, validationLineText, valueHoldsDotDot, valueNotPlain,
|
|
9
|
+
} from "./messages.ts";
|
|
10
|
+
|
|
11
|
+
export type ValidationCheck =
|
|
12
|
+
| { ok: true; command: string; key: "commands.test_class" | "commands.test_project" | "commands.test_integration"; scope: string }
|
|
13
|
+
| { ok: false; command: string; reason: string };
|
|
14
|
+
|
|
15
|
+
const MAX_COMMAND_CHARS = 400;
|
|
16
|
+
export const PLACEHOLDER = /<[^<>]+>/g;
|
|
17
|
+
const ANY_WORD = "(\\S+)";
|
|
18
|
+
/** One placeholder value: a plain relative name, no leading "-", no "~", no glob, no quote. */
|
|
19
|
+
const PLAIN_VALUE = /^[A-Za-z0-9_][A-Za-z0-9_.:/-]*$/;
|
|
20
|
+
const OUTSIDE_FORBIDDEN = new Set([...";&|<>$`\\()'"]);
|
|
21
|
+
const INSIDE_FORBIDDEN = new Set([..."`$\\"]);
|
|
22
|
+
|
|
23
|
+
/** True when the text holds no shell operator outside double quotes and no expansion inside them. */
|
|
24
|
+
export function plainWords(text: string): boolean {
|
|
25
|
+
let quoted = false;
|
|
26
|
+
for (const c of text) {
|
|
27
|
+
if (c === '"') { quoted = !quoted; continue; }
|
|
28
|
+
if (quoted ? INSIDE_FORBIDDEN.has(c) : OUTSIDE_FORBIDDEN.has(c)) return false;
|
|
29
|
+
}
|
|
30
|
+
return !quoted;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function escapeRegExp(text: string): string {
|
|
34
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function templateSource(template: string): string {
|
|
38
|
+
return template.split(PLACEHOLDER).map(escapeRegExp).join(ANY_WORD);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Why a placeholder value is refused, or null when it is one plain relative value. */
|
|
42
|
+
export function valueProblem(value: string): string | null {
|
|
43
|
+
if (value.split("/").includes("..")) return valueHoldsDotDot(value);
|
|
44
|
+
if (!PLAIN_VALUE.test(value)) return valueNotPlain(value);
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
type Key = "commands.test_class" | "commands.test_project" | "commands.test_integration";
|
|
49
|
+
|
|
50
|
+
export function checkValidation(command: string, commands: RepoPackCommands): ValidationCheck {
|
|
51
|
+
const c = command.trim();
|
|
52
|
+
const refuse = (reason: string): ValidationCheck => ({ ok: false, command: c, reason });
|
|
53
|
+
if (c === "" || /[\r\n]/.test(c) || c.length > MAX_COMMAND_CHARS) return refuse(NOT_ONE_LINE);
|
|
54
|
+
if (!plainWords(c)) return refuse(SHELL_OPERATOR_OUTSIDE_QUOTES);
|
|
55
|
+
|
|
56
|
+
const templates: Array<[Key, string | undefined]> = [
|
|
57
|
+
["commands.test_class", commands.testClass],
|
|
58
|
+
["commands.test_project", commands.testProject],
|
|
59
|
+
["commands.test_integration", commands.testIntegration],
|
|
60
|
+
];
|
|
61
|
+
if (templates.every(([, t]) => t === undefined || t.trim() === "")) {
|
|
62
|
+
return refuse(PACK_HAS_NO_TEST_COMMAND);
|
|
63
|
+
}
|
|
64
|
+
let bareIntegration = false;
|
|
65
|
+
let problem: string | null = null;
|
|
66
|
+
for (const [key, template] of templates) {
|
|
67
|
+
if (template === undefined || template.trim() === "") continue;
|
|
68
|
+
const source = templateSource(template.trim());
|
|
69
|
+
const whole = new RegExp(`^${source}$`).exec(c);
|
|
70
|
+
if (whole) {
|
|
71
|
+
const values = whole.slice(1);
|
|
72
|
+
if (key === "commands.test_integration" && values.length === 0) { bareIntegration = true; continue; }
|
|
73
|
+
const bad = values.map(valueProblem).find((p) => p !== null) ?? null;
|
|
74
|
+
if (bad !== null) { problem ??= bad; continue; }
|
|
75
|
+
return { ok: true, command: c, key, scope: scopeOf(values) };
|
|
76
|
+
}
|
|
77
|
+
const suffixed = new RegExp(`^${source} (.+)$`).exec(c);
|
|
78
|
+
if (suffixed) problem ??= nothingMayFollow(suffixed[suffixed.length - 1]);
|
|
79
|
+
}
|
|
80
|
+
if (problem !== null) return refuse(problem);
|
|
81
|
+
return refuse(bareIntegration
|
|
82
|
+
? INTEGRATION_WITHOUT_FILTER
|
|
83
|
+
: NOT_A_PACK_TEST_COMMAND);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function scopeOf(values: readonly string[]): string {
|
|
87
|
+
const named = values.join(", ");
|
|
88
|
+
return named === "" ? AS_THE_PACK_NAMES_IT : named;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** `\`<command>\` — exit <n>, scope <scope>, <count> tests` (SK:72); count "not counted" when unknown. */
|
|
92
|
+
export function validationLine(command: string, exit: number, scope: string, tests: number | null): string {
|
|
93
|
+
return validationLineText(command, exit, scope, tests === null ? "not counted" : tests);
|
|
94
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// The failed tests a test run's output names. Listed in the run_tests result, they tell a role which tests
|
|
2
|
+
// failed without a read of the log: the test author checks that the new tests are the red ones from the
|
|
3
|
+
// result alone. Pure.
|
|
4
|
+
|
|
5
|
+
const MAX_FAILED = 20;
|
|
6
|
+
const MAX_NAME = 120;
|
|
7
|
+
|
|
8
|
+
/** One failed test per line, in the formats the packs run: TAP (`not ok 3 - name`, node:test, tap, prove), pytest
|
|
9
|
+
* (`FAILED tests/test_a.py::test_mean - …`), dotnet (`Failed Ns.Class.Method [12 ms]`), go (`--- FAIL: TestName`),
|
|
10
|
+
* jest and vitest (`✕ name (2 ms)`). */
|
|
11
|
+
const FAILED_LINES: readonly RegExp[] = [
|
|
12
|
+
/^\s*not ok \d+(?: - | )(.+?)\s*(?:#.*)?$/u,
|
|
13
|
+
/^\s*FAILED\s+(\S+)/u,
|
|
14
|
+
/^\s*Failed\s+(\S+)\s*\[[^\]]*\]\s*$/u,
|
|
15
|
+
/^\s*--- FAIL: (\S+)/u,
|
|
16
|
+
/^\s*[✕✗×]\s+(.+?)\s*(?:\(\d+ ?m?s\))?$/u,
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
/** The failed tests `output` names, each once, in order, at most 20 of 120 characters; empty when it names none. */
|
|
20
|
+
export function failedTests(output: string): string[] {
|
|
21
|
+
const out = new Set<string>();
|
|
22
|
+
for (const line of output.split(/\r?\n/u)) {
|
|
23
|
+
for (const re of FAILED_LINES) {
|
|
24
|
+
const m = re.exec(line);
|
|
25
|
+
if (m !== null) {
|
|
26
|
+
out.add(m[1].trim().slice(0, MAX_NAME));
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (out.size >= MAX_FAILED) break;
|
|
31
|
+
}
|
|
32
|
+
return [...out];
|
|
33
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Which paths of a repository are its tests, by its pack: under `layout.tests`, or matching one pattern of
|
|
2
|
+
// `layout.test_files` (tests beside the code, `src/*.test.ts`; `*` spans folders, as the gate reads a pattern).
|
|
3
|
+
// dev-implement reads it to tell the test author's changes from the implementer's. Pure.
|
|
4
|
+
import { globMatches } from "../agent-policy/permission.ts";
|
|
5
|
+
import type { RepoPackLayout } from "./repo-pack.ts";
|
|
6
|
+
import { workspaceRelative } from "../vfs.ts";
|
|
7
|
+
|
|
8
|
+
/** A path relative to the project: no `/workspace/` or `./` in front, no `/` behind. */
|
|
9
|
+
export function relativePath(path: string): string {
|
|
10
|
+
let p = path.trim();
|
|
11
|
+
p = workspaceRelative(p);
|
|
12
|
+
while (p.startsWith("./")) p = p.slice(2);
|
|
13
|
+
return p.replace(/\/+$/, "");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Whether `path` lies under `folder` (a relative folder of the pack's layout). */
|
|
17
|
+
export function under(path: string, folder: string): boolean {
|
|
18
|
+
const f = folder.replace(/^\.\//, "").replace(/\/+$/, "");
|
|
19
|
+
return f === "" || f === "." || path === f || path.startsWith(`${f}/`);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function matchesAny(path: string, patterns: readonly string[]): boolean {
|
|
23
|
+
const p = relativePath(path);
|
|
24
|
+
return patterns.some((raw) => {
|
|
25
|
+
const pattern = relativePath(raw);
|
|
26
|
+
return pattern !== "" && globMatches(pattern, p);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Whether the pack can tell a test file at all: a test folder or a test file pattern. */
|
|
31
|
+
export function hasTestLayout(layout: Pick<RepoPackLayout, "tests" | "testFiles">): boolean {
|
|
32
|
+
return (layout.tests?.trim() ?? "") !== "" || (layout.testFiles ?? []).some((p) => p.trim() !== "");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function isTestPath(path: string, layout: Pick<RepoPackLayout, "tests" | "testFiles">): boolean {
|
|
36
|
+
const p = relativePath(path);
|
|
37
|
+
const folder = layout.tests?.trim() ?? "";
|
|
38
|
+
if (folder !== "" && under(p, relativePath(folder))) return true;
|
|
39
|
+
return matchesAny(p, layout.testFiles ?? []);
|
|
40
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// The guard chain of the tools Orkeon Code defines (run_validation, run_tests, run_build). The host
|
|
2
|
+
// gate is asked once, for the tool call itself; the shell commands the tool's body then runs are
|
|
3
|
+
// not asked again (toolBuilder, orkeon.d.ts), so the body applies the rules it is given before each
|
|
4
|
+
// one, with the gate's own reading (matchesRule). A guard returns a refusal or null; the first
|
|
5
|
+
// refusal is terminal and a guard that throws refuses (fail-closed). Pure.
|
|
6
|
+
import type { PermissionRule } from "../agent-policy/permission.ts";
|
|
7
|
+
import { ruleDecision, shellCommandForms } from "../agent-policy/permission.ts";
|
|
8
|
+
import { gitConfigSets, holdsGitReadonly } from "../agent-policy/rule-sets.ts";
|
|
9
|
+
import { WORKSPACE } from "../vfs.ts";
|
|
10
|
+
import { argumentNotAString, argumentNotOneLine, stepRulesDenyShell } from "./messages.ts";
|
|
11
|
+
|
|
12
|
+
/** One check of a call: the reason it is refused, or null when it passes. */
|
|
13
|
+
export type Guard<T> = (call: T) => string | null;
|
|
14
|
+
|
|
15
|
+
/** The first refusal of `guards`, in order; a guard that throws refuses with its message. */
|
|
16
|
+
export function runGuards<T>(guards: ReadonlyArray<Guard<T>>, call: T): string | null {
|
|
17
|
+
for (const guard of guards) {
|
|
18
|
+
let refusal: string | null;
|
|
19
|
+
try {
|
|
20
|
+
refusal = guard(call);
|
|
21
|
+
} catch (error) {
|
|
22
|
+
refusal = `a guard failed: ${error instanceof Error ? error.message : String(error)}`;
|
|
23
|
+
}
|
|
24
|
+
if (refusal !== null) return refusal;
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Refuses a shell command a deny rule covers, as the gate would refuse the model's own shell_command, in any of
|
|
30
|
+
* the forms the program receives it in (shellCommandForms). */
|
|
31
|
+
export function shellRuleGuard(rules: readonly PermissionRule[]): Guard<string> {
|
|
32
|
+
const gitConfig = holdsGitReadonly(rules);
|
|
33
|
+
return (command) =>
|
|
34
|
+
shellCommandForms(command).some((form) =>
|
|
35
|
+
ruleDecision(rules, "shell_command", { command: form, working_directory: WORKSPACE }) === "deny")
|
|
36
|
+
|| (gitConfig && gitConfigSets(command))
|
|
37
|
+
? stepRulesDenyShell(command)
|
|
38
|
+
: null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** The longest text a tool's string argument may be. */
|
|
42
|
+
export const MAX_ARGUMENT_CHARS = 400;
|
|
43
|
+
|
|
44
|
+
/** The string `key` of a tool's input, or the reason it is not one line of at most 400 characters. */
|
|
45
|
+
export function stringArgument(input: unknown, key: string, required: boolean): { value?: string } | { refused: string } {
|
|
46
|
+
const value = input !== null && typeof input === "object" ? (input as Record<string, unknown>)[key] : undefined;
|
|
47
|
+
if (value === undefined || value === null || value === "") {
|
|
48
|
+
return required ? { refused: `'${key}' is required` } : {};
|
|
49
|
+
}
|
|
50
|
+
if (typeof value !== "string") return { refused: argumentNotAString(key) };
|
|
51
|
+
if (/[\r\n]/.test(value) || value.length > MAX_ARGUMENT_CHARS) {
|
|
52
|
+
return { refused: argumentNotOneLine(key, MAX_ARGUMENT_CHARS) };
|
|
53
|
+
}
|
|
54
|
+
return { value: value.trim() };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const TAIL_LINES = 15;
|
|
58
|
+
const TAIL_CHARS = 1_500;
|
|
59
|
+
|
|
60
|
+
/** At most 15 lines and 1 500 characters of the output, stderr after stdout: what a tool hands back. */
|
|
61
|
+
export function outputTail(stdout: string, stderr: string): string {
|
|
62
|
+
const joined = [stdout.trimEnd(), stderr.trimEnd()].filter((t) => t !== "").join("\n");
|
|
63
|
+
const text = joined === "" ? "" : joined.split(/\r?\n/).slice(-TAIL_LINES).join("\n");
|
|
64
|
+
return text.length <= TAIL_CHARS ? text : text.slice(-TAIL_CHARS);
|
|
65
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// The trait marker: how a test says which sheet id it covers. The repository pack gives
|
|
2
|
+
// a trait name (tests.rule_trait) and, optionally, a one-line pattern (tests.trait_pattern)
|
|
3
|
+
// holding <id> once and <name> at most once; the pattern compiles to the POSIX ERE that
|
|
4
|
+
// git grep -E runs over the test roots. Pure.
|
|
5
|
+
import {
|
|
6
|
+
PATTERN_ANGLES, PATTERN_EMPTY, PATTERN_NO_PIPE, PATTERN_NO_SINGLE_QUOTE, PATTERN_NO_TAB_OR_BREAK, PATTERN_ONE_ID,
|
|
7
|
+
PATTERN_ONE_NAME, PATTERN_TOO_LONG, PATTERN_TOO_SHORT, TRAIT_NAME_CHARS,
|
|
8
|
+
} from "./messages.ts";
|
|
9
|
+
|
|
10
|
+
export const DEFAULT_TRAIT_PATTERN = '[Trait("<name>", "<id>")]';
|
|
11
|
+
/** The sheet ids the gate checks (AC:166). */
|
|
12
|
+
export const SHEET_ID_SOURCE = "\\b(BR|UC|CH)-[0-9]+\\b";
|
|
13
|
+
|
|
14
|
+
// No alternation: the runtime's shell tool refuses a '|' even quoted, so the ERE
|
|
15
|
+
// over-matches (BH-1, UR-2) and idsInMatch keeps the sheet ids alone.
|
|
16
|
+
const ID_ERE = "[BCU][CHR]-[0-9]+";
|
|
17
|
+
const ID_TOKEN = "<id>";
|
|
18
|
+
const NAME_TOKEN = "<name>";
|
|
19
|
+
const ERE_SPECIALS = new Set([..."\\.[]()*+?{}|^$"]);
|
|
20
|
+
|
|
21
|
+
export interface TraitMarker {
|
|
22
|
+
pattern: string; // the pattern used (trait_pattern, else the default)
|
|
23
|
+
name: string | null; // tests.rule_trait
|
|
24
|
+
ere: string; // the POSIX ERE handed to git grep -E
|
|
25
|
+
shown: string; // the pattern with <name> replaced, <id> kept: [Trait("BR", "<id>")]
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function count(text: string, token: string): number {
|
|
29
|
+
return text.split(token).length - 1;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function ruleTraitProblem(name: string): string | undefined {
|
|
33
|
+
return /^[A-Za-z0-9_-]+$/.test(name) ? undefined : TRAIT_NAME_CHARS;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function traitPatternProblem(pattern: string): string | undefined {
|
|
37
|
+
if (pattern.trim() === "") return PATTERN_EMPTY;
|
|
38
|
+
if (pattern.length > 80) return PATTERN_TOO_LONG;
|
|
39
|
+
if (/[\t\r\n]/.test(pattern)) return PATTERN_NO_TAB_OR_BREAK;
|
|
40
|
+
if (pattern.includes("'")) return PATTERN_NO_SINGLE_QUOTE;
|
|
41
|
+
if (pattern.includes("|")) return PATTERN_NO_PIPE;
|
|
42
|
+
if (count(pattern, ID_TOKEN) !== 1) return PATTERN_ONE_ID;
|
|
43
|
+
if (count(pattern, NAME_TOKEN) > 1) return PATTERN_ONE_NAME;
|
|
44
|
+
const rest = pattern.split(ID_TOKEN).join("").split(NAME_TOKEN).join("");
|
|
45
|
+
if (/[<>]/.test(rest)) return PATTERN_ANGLES;
|
|
46
|
+
if (rest.replace(/\s/g, "").length < 2) return PATTERN_TOO_SHORT;
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function compile(pattern: string, name: string | null): string {
|
|
51
|
+
let ere = "";
|
|
52
|
+
let i = 0;
|
|
53
|
+
while (i < pattern.length) {
|
|
54
|
+
if (pattern.startsWith(ID_TOKEN, i)) { ere += ID_ERE; i += ID_TOKEN.length; continue; }
|
|
55
|
+
if (pattern.startsWith(NAME_TOKEN, i)) { ere += name ?? ""; i += NAME_TOKEN.length; continue; }
|
|
56
|
+
const c = pattern[i];
|
|
57
|
+
if (c === " ") {
|
|
58
|
+
while (pattern[i] === " ") i++;
|
|
59
|
+
ere += " *";
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
ere += ERE_SPECIALS.has(c) ? `\\${c}` : c;
|
|
63
|
+
i++;
|
|
64
|
+
}
|
|
65
|
+
return ere;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** null when no marker applies: no rule_trait and no trait_pattern, or <name> in the pattern without rule_trait. */
|
|
69
|
+
export function traitMarker(ruleTrait: string | undefined, traitPattern: string | undefined): TraitMarker | null {
|
|
70
|
+
const pattern = traitPattern ?? (ruleTrait !== undefined ? DEFAULT_TRAIT_PATTERN : undefined);
|
|
71
|
+
if (pattern === undefined) return null;
|
|
72
|
+
if (pattern.includes(NAME_TOKEN) && ruleTrait === undefined) return null;
|
|
73
|
+
const name = ruleTrait ?? null;
|
|
74
|
+
return { pattern, name, ere: compile(pattern, name), shown: pattern.split(NAME_TOKEN).join(name ?? "") };
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Ids carried by one git grep hit `path:line:match`: whole-token ids of the match part. */
|
|
78
|
+
export function idsInMatch(hit: string): string[] {
|
|
79
|
+
const first = hit.indexOf(":");
|
|
80
|
+
const second = first < 0 ? -1 : hit.indexOf(":", first + 1);
|
|
81
|
+
if (second < 0) return [];
|
|
82
|
+
const ids: string[] = [];
|
|
83
|
+
for (const m of hit.slice(second + 1).matchAll(/(^|[^0-9A-Za-z])((BR|UC|CH)-[0-9]+)(?![0-9])/g)) {
|
|
84
|
+
if (!ids.includes(m[2])) ids.push(m[2]);
|
|
85
|
+
}
|
|
86
|
+
return ids;
|
|
87
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
// Dev workflow verdicts: `<CODE>-VERIFY-F<n>.md`, one dated section per audit (a
|
|
2
|
+
// resume appends one). Pure, no IO, never throws. Gap rows are cut as the harness's
|
|
3
|
+
// learning script cuts them, so both read the same rows from the same file.
|
|
4
|
+
import type { FormatProblem } from "./plan-format.ts";
|
|
5
|
+
import {
|
|
6
|
+
AUDIT_UNFINISHED_GAP, CLOSE_LINE, CORRECTION_LINE, MEASURE_LINE, NOT_RUN_LINE, VALIDATIONS_LINE, VERDICT_HEADING,
|
|
7
|
+
VERDICT_TITLE,
|
|
8
|
+
} from "./markers.ts";
|
|
9
|
+
import { malformedGapRow, unknownSeverity, unknownVerdictLine, unknownVerdictTitle } from "./messages.ts";
|
|
10
|
+
|
|
11
|
+
export type Verdict = "VALID" | "GAPS";
|
|
12
|
+
|
|
13
|
+
export function isAuditUnfinishedGap(gap: string): boolean {
|
|
14
|
+
return gap.trim() === AUDIT_UNFINISHED_GAP;
|
|
15
|
+
}
|
|
16
|
+
export type Severity = "Blocking" | "Major" | "Minor";
|
|
17
|
+
/** The axes, as the verdict files spell them (LC:34-35). Moved here from crews/dev-verify/domain/audit-answer.ts. */
|
|
18
|
+
export const AXES = [
|
|
19
|
+
"Correctness", "Reuse", "Simplification", "Cost", "Placement", "Conventions", "Test", "Plan", "Scope",
|
|
20
|
+
] as const;
|
|
21
|
+
export type Axis = (typeof AXES)[number];
|
|
22
|
+
export interface GapRow { severity: Severity; axis: string; gap: string; evidence: string; expectedFix: string; line: number }
|
|
23
|
+
export interface VerdictSection {
|
|
24
|
+
prefix?: string; batch?: string; when?: string; mode?: string;
|
|
25
|
+
verdict: Verdict | null; rows: GapRow[]; none: boolean;
|
|
26
|
+
validations: string[]; notRun: string[]; measure?: string; line: number;
|
|
27
|
+
}
|
|
28
|
+
export interface VerdictFile { sections: VerdictSection[]; problems: FormatProblem[] }
|
|
29
|
+
|
|
30
|
+
const SEVERITIES: ReadonlySet<string> = new Set(["Blocking", "Major", "Minor"]);
|
|
31
|
+
|
|
32
|
+
function emptySection(line: number): VerdictSection {
|
|
33
|
+
return { verdict: null, rows: [], none: false, validations: [], notRun: [], line };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function parseVerdictFile(text: string): VerdictFile {
|
|
37
|
+
const file: VerdictFile = { sections: [], problems: [] };
|
|
38
|
+
let section: VerdictSection | null = null;
|
|
39
|
+
let inside = false;
|
|
40
|
+
text.split(/\r?\n/).forEach((raw, i) => {
|
|
41
|
+
const t = raw.trimEnd();
|
|
42
|
+
const line = i + 1;
|
|
43
|
+
if (t.startsWith("#")) {
|
|
44
|
+
inside = false;
|
|
45
|
+
const title = VERDICT_TITLE.exec(t);
|
|
46
|
+
if (title) {
|
|
47
|
+
section = { ...emptySection(line), prefix: title[1], batch: title[2], when: title[3], mode: title[4] };
|
|
48
|
+
file.sections.push(section);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const v = VERDICT_HEADING.exec(t);
|
|
52
|
+
if (v) {
|
|
53
|
+
if (!section || section.verdict !== null) { section = emptySection(line); file.sections.push(section); }
|
|
54
|
+
section.verdict = v[1] as Verdict;
|
|
55
|
+
inside = true;
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (/-VERIFY-/.test(t) && t.startsWith("# ")) file.problems.push({ line, message: unknownVerdictTitle(t) });
|
|
59
|
+
else if (/^##\s+Verdict\b/.test(t)) file.problems.push({ line, message: unknownVerdictLine(t) });
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (!section) return;
|
|
63
|
+
const current: VerdictSection = section;
|
|
64
|
+
let m: RegExpExecArray | null;
|
|
65
|
+
if ((m = VALIDATIONS_LINE.exec(t))) { current.validations.push(m[1]); return; }
|
|
66
|
+
if ((m = NOT_RUN_LINE.exec(t))) { current.notRun.push(m[1]); return; }
|
|
67
|
+
if ((m = MEASURE_LINE.exec(t))) { current.measure = m[1]; return; }
|
|
68
|
+
if (!inside) return;
|
|
69
|
+
if (t.trim() === "None.") { current.none = true; return; }
|
|
70
|
+
const s = t.trim();
|
|
71
|
+
// A row may omit its edge pipes, as the harness reads it: then its first cell must
|
|
72
|
+
// be a severity, so prose holding a pipe stays silent.
|
|
73
|
+
if (!s.startsWith("|") && !(s.includes("|") && SEVERITIES.has(s.slice(0, s.indexOf("|")).trim()))) return;
|
|
74
|
+
const cells = s.replace(/^\|+/, "").replace(/\|+$/, "").split("|").map((c) => c.trim());
|
|
75
|
+
if (cells[0] === "Severity" || /^-+$/.test(cells[0].replace(/:/g, ""))) return;
|
|
76
|
+
if (!SEVERITIES.has(cells[0])) { file.problems.push({ line, message: unknownSeverity(cells[0]) }); return; }
|
|
77
|
+
if (cells.length < 5) { file.problems.push({ line, message: malformedGapRow(s) }); return; }
|
|
78
|
+
current.rows.push({
|
|
79
|
+
severity: cells[0] as Severity, axis: cells[1], gap: cells.slice(2, -2).join(" | "),
|
|
80
|
+
evidence: cells[cells.length - 2], expectedFix: cells[cells.length - 1], line,
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
return file;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** The last section that carries a verdict heading; null when none. */
|
|
87
|
+
export function lastVerdict(file: VerdictFile): VerdictSection | null {
|
|
88
|
+
for (let i = file.sections.length - 1; i >= 0; i--) if (file.sections[i].verdict !== null) return file.sections[i];
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** A section an audit the step's budget stopped wrote: its row judges nothing of the code. */
|
|
93
|
+
export function isUnfinishedSection(section: VerdictSection): boolean {
|
|
94
|
+
return section.rows.some((r) => isAuditUnfinishedGap(r.gap));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** The last verdict a finished audit wrote, skipping the sections of audits the budget stopped; null when none. */
|
|
98
|
+
export function lastFinishedVerdict(file: VerdictFile): VerdictSection | null {
|
|
99
|
+
for (let i = file.sections.length - 1; i >= 0; i--) {
|
|
100
|
+
const s = file.sections[i];
|
|
101
|
+
if (s.verdict !== null && !isUnfinishedSection(s)) return s;
|
|
102
|
+
}
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** The audit rounds in GAPS a batch is relaunched through by itself: the third still GAPS goes to a human. */
|
|
107
|
+
export const GAPS_ROUNDS_MAX = 3;
|
|
108
|
+
|
|
109
|
+
/** The audit rounds in GAPS since the last VALID: every trailing GAPS section, an audit the budget stopped included
|
|
110
|
+
* (three audits that cannot finish hand the batch over too). */
|
|
111
|
+
export function gapsRoundsOf(text: string): number {
|
|
112
|
+
const sections = parseVerdictFile(text).sections.filter((s) => s.verdict !== null);
|
|
113
|
+
let rounds = 0;
|
|
114
|
+
for (let i = sections.length - 1; i >= 0 && sections[i].verdict === "GAPS"; i--) rounds++;
|
|
115
|
+
return rounds;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** The correction a GAPS verdict hands its batch's relaunch: the Blocking and Major rows of its last section, one
|
|
119
|
+
* `<severity> — <gap> (<evidence>)` each, joined on one line; undefined when the last verdict is not GAPS, when the
|
|
120
|
+
* budget stopped that audit (its resume runs, no correction) or when it holds no such row. */
|
|
121
|
+
export function gapsFinding(text: string): string | undefined {
|
|
122
|
+
const last = lastVerdict(parseVerdictFile(text));
|
|
123
|
+
if (last === null || last.verdict !== "GAPS" || isUnfinishedSection(last)) return undefined;
|
|
124
|
+
const rows = last.rows.filter((r) => r.severity === "Blocking" || r.severity === "Major");
|
|
125
|
+
if (rows.length === 0) return undefined;
|
|
126
|
+
return rows.map((r) => `${r.severity} — ${r.gap} (${r.evidence})`.replace(/\s+/g, " ").trim()).join("; ");
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export function severityCounts(section: VerdictSection): Record<Severity, number> {
|
|
130
|
+
const counts: Record<Severity, number> = { Blocking: 0, Major: 0, Minor: 0 };
|
|
131
|
+
for (const r of section.rows) counts[r.severity]++;
|
|
132
|
+
return counts;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// The next step a verdict hands on, one shape per line: the audit prints them, the chain of /dev-batches and its
|
|
136
|
+
// waves read them back with the parsers below, so the printer and the readers cannot drift. `code` is the plan's
|
|
137
|
+
// code, or its `<path>/<CODE>-PLAN.md` when the line comes from a chain that holds the path.
|
|
138
|
+
|
|
139
|
+
/** The command that runs a batch again with an audit's gap appended to its sheet as a new step. */
|
|
140
|
+
export const correctionCommand = (code: string, batch: string, finding: string): string =>
|
|
141
|
+
`/dev-batches ${code} ${batch} — correction: ${finding}`;
|
|
142
|
+
/** The command that closes a VALID batch: its commit. */
|
|
143
|
+
export const closeCommand = (code: string, batch: string): string => `/dev-batches ${code} ${batch} --close`;
|
|
144
|
+
/** The command that audits a batch, `resume` adding one section to its verdict file. */
|
|
145
|
+
export const auditCommand = (code: string, batch: string, mode?: "fast" | "full" | "resume"): string =>
|
|
146
|
+
`/dev-batches ${code} ${batch} --audit${mode === undefined || mode === "fast" ? "" : ` ${mode}`}`;
|
|
147
|
+
|
|
148
|
+
/** The line a GAPS verdict ends on: the correction to run. */
|
|
149
|
+
export const correctionLine = (code: string, batch: string, finding: string): string => `→ ${correctionCommand(code, batch, finding)}`;
|
|
150
|
+
/** The line a VALID verdict ends on: the close to run. */
|
|
151
|
+
export const closeLine = (code: string, batch: string): string => `→ ${closeCommand(code, batch)}`;
|
|
152
|
+
|
|
153
|
+
/** The first correction line of `text`: its code, batch and finding; null when it holds none. */
|
|
154
|
+
export function parseCorrectionLine(text: string): { code: string; batch: string; finding: string } | null {
|
|
155
|
+
const m = CORRECTION_LINE.exec(text);
|
|
156
|
+
return m === null ? null : { code: m[1], batch: m[2], finding: m[3].trim() };
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** True for a line that names a batch's next step: its correction or its close. */
|
|
160
|
+
export function isNextStepLine(line: string): boolean {
|
|
161
|
+
return CORRECTION_LINE.test(line.split("\n")[0]) || CLOSE_LINE.test(line);
|
|
162
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// The whitespace `git diff --check` refuses, put right by code in a file a role wrote: trailing
|
|
2
|
+
// spaces or tabs at the end of a line, blank lines at the end of the file. A node insert at the end
|
|
3
|
+
// of a module leaves a blank line after the last member; the gate would stop the batch for it. Pure.
|
|
4
|
+
import { blankLinesAtEof, ONE_BLANK_LINE_AT_EOF, trailingWhitespace } from "./messages.ts";
|
|
5
|
+
|
|
6
|
+
export interface TidyResult {
|
|
7
|
+
text: string;
|
|
8
|
+
/** What changed, one phrase each ("trailing whitespace on 2 lines", "a blank line at EOF removed"); empty: nothing. */
|
|
9
|
+
fixed: string[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** `text` without trailing whitespace on its lines nor blank lines at its end (its final newline kept as it was). */
|
|
13
|
+
export function tidyWhitespace(text: string): TidyResult {
|
|
14
|
+
const fixed: string[] = [];
|
|
15
|
+
const lines = text.split("\n");
|
|
16
|
+
let trailing = 0;
|
|
17
|
+
const stripped = lines.map((line) => {
|
|
18
|
+
const clean = line.replace(/[ \t]+$/u, "");
|
|
19
|
+
if (clean !== line) trailing += 1;
|
|
20
|
+
return clean;
|
|
21
|
+
});
|
|
22
|
+
if (trailing > 0) fixed.push(trailingWhitespace(trailing));
|
|
23
|
+
const endsWithNewline = text.endsWith("\n");
|
|
24
|
+
// The split's last element is "" when the text ends with a newline: the blank lines at EOF are the empty
|
|
25
|
+
// elements before it.
|
|
26
|
+
let end = stripped.length - (endsWithNewline ? 1 : 0);
|
|
27
|
+
let blank = 0;
|
|
28
|
+
while (end > 1 && stripped[end - 1] === "") {
|
|
29
|
+
end -= 1;
|
|
30
|
+
blank += 1;
|
|
31
|
+
}
|
|
32
|
+
if (blank > 0) fixed.push(blank === 1 ? ONE_BLANK_LINE_AT_EOF : blankLinesAtEof(blank));
|
|
33
|
+
const body = stripped.slice(0, end).join("\n");
|
|
34
|
+
return { text: endsWithNewline ? `${body}\n` : body, fixed };
|
|
35
|
+
}
|