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,233 @@
|
|
|
1
|
+
// The learner's answer for one axis: the JSON schema it is extracted into (snake_case
|
|
2
|
+
// on the wire), and the check that turns the extraction into a LearnAnswer or the list
|
|
3
|
+
// of what is wrong with it, so the crew can ask once more. Pure, no IO.
|
|
4
|
+
import type { Checked } from "../../../shared/domain/agents/charter.ts";
|
|
5
|
+
import type { CheckKind, MotifStatus, OwnerKind } from "../../../shared/domain/dev/learn-proposals.ts";
|
|
6
|
+
import { MAX_TOPIC_CHARS, TOPIC_PATTERN } from "../../../shared/domain/shared-memory/refused.ts";
|
|
7
|
+
import { MOTIFS_MUST_BE_LIST, SEEN_LINES_ONLY, addsLines, atProblem, checkIsOneOf, deployedCopy, droppedNeeds, harnessOwnerUnder, lineLength, needsRemovedLine, ownerKindIs, ownerPathNotRelative, removesLines, rowNotGiven, rowTwice, rowsEmpty, sameRows, statusIs, titleLength, tooManyMotifs, topicNotSlug } from "./messages.ts";
|
|
8
|
+
import { ANSWER_NOT_AN_OBJECT as NOT_AN_OBJECT, fieldEmpty } from "../../../shared/domain/dev/messages.ts";
|
|
9
|
+
|
|
10
|
+
export { MAX_TOPIC_CHARS };
|
|
11
|
+
|
|
12
|
+
export const MAX_MOTIFS_PER_AXIS = 3;
|
|
13
|
+
export const MAX_LINES_PER_MOTIF = 5;
|
|
14
|
+
export const MAX_LINE_CHARS = 300;
|
|
15
|
+
const MAX_TITLE_CHARS = 80;
|
|
16
|
+
/** A title longer than this is cut in a label: its first LABEL_TITLE_CHARS characters, then an ellipsis. */
|
|
17
|
+
export const LABEL_TITLE_CHARS = 60;
|
|
18
|
+
const ADDS_LINES = addsLines(MAX_LINES_PER_MOTIF);
|
|
19
|
+
const REMOVES_LINES = removesLines(MAX_LINES_PER_MOTIF);
|
|
20
|
+
|
|
21
|
+
export interface AnswerMotif {
|
|
22
|
+
title: string; topic: string; rows: string[]; preventiveLine: string;
|
|
23
|
+
owner: { kind: OwnerKind; path: string }; check: CheckKind; status: MotifStatus;
|
|
24
|
+
linesRemoved: string[]; linesAdded: string[]; novelty: string; keyTerm: string;
|
|
25
|
+
}
|
|
26
|
+
export interface AnswerDropped { title: string; filter: "recurrence" | "prevention" | "novelty"; reason: string }
|
|
27
|
+
export interface LearnAnswer { motifs: AnswerMotif[]; dropped: AnswerDropped[] }
|
|
28
|
+
|
|
29
|
+
const OWNER_KINDS: readonly OwnerKind[] = ["repository", "harness"];
|
|
30
|
+
const CHECK_KINDS: readonly CheckKind[] = ["test", "analyzer", "architecture-test", "gate", "rule"];
|
|
31
|
+
const STATUSES: readonly MotifStatus[] = ["new", "refines", "replaces", "removes"];
|
|
32
|
+
const FILTERS: ReadonlyArray<AnswerDropped["filter"]> = ["recurrence", "prevention", "novelty"];
|
|
33
|
+
const HARNESS_PACKS = ".devcontainer/harness/packs/";
|
|
34
|
+
|
|
35
|
+
const stringList = { type: "array", items: { type: "string" } };
|
|
36
|
+
|
|
37
|
+
export const LEARN_ANSWER_SCHEMA: object = {
|
|
38
|
+
type: "object",
|
|
39
|
+
properties: {
|
|
40
|
+
motifs: {
|
|
41
|
+
type: "array",
|
|
42
|
+
items: {
|
|
43
|
+
type: "object",
|
|
44
|
+
properties: {
|
|
45
|
+
title: { type: "string" },
|
|
46
|
+
topic: { type: "string" },
|
|
47
|
+
rows: stringList,
|
|
48
|
+
preventive_line: { type: "string" },
|
|
49
|
+
owner_kind: { type: "string", enum: [...OWNER_KINDS] },
|
|
50
|
+
owner_path: { type: "string" },
|
|
51
|
+
check: { type: "string", enum: [...CHECK_KINDS] },
|
|
52
|
+
status: { type: "string", enum: [...STATUSES] },
|
|
53
|
+
lines_removed: stringList,
|
|
54
|
+
lines_added: stringList,
|
|
55
|
+
novelty: { type: "string" },
|
|
56
|
+
key_term: { type: "string" },
|
|
57
|
+
},
|
|
58
|
+
required: [
|
|
59
|
+
"title", "topic", "rows", "preventive_line", "owner_kind", "owner_path", "check", "status",
|
|
60
|
+
"lines_added", "novelty", "key_term",
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
dropped: {
|
|
65
|
+
type: "array",
|
|
66
|
+
items: {
|
|
67
|
+
type: "object",
|
|
68
|
+
properties: {
|
|
69
|
+
title: { type: "string" },
|
|
70
|
+
filter: { type: "string", enum: [...FILTERS] },
|
|
71
|
+
reason: { type: "string" },
|
|
72
|
+
},
|
|
73
|
+
required: ["title", "filter", "reason"],
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
required: ["motifs"],
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
type Obj = Record<string, unknown>;
|
|
81
|
+
|
|
82
|
+
function isPlainObject(value: unknown): value is Obj {
|
|
83
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function text(value: unknown): string {
|
|
87
|
+
return typeof value === "string" ? value.trim() : "";
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const chars = (s: string): number => Array.from(s).length;
|
|
91
|
+
|
|
92
|
+
/** `motif k "<title>"`, the title cut at 60 characters, a `"` of it written `'`, or `motif k` without a title: the
|
|
93
|
+
* re-ask never shows the earlier answer, so a problem names the motif by what it was called. */
|
|
94
|
+
export function motifLabel(k: number, title: string): string {
|
|
95
|
+
const t = Array.from(title.trim().replace(/"/g, "'"));
|
|
96
|
+
if (t.length === 0) return `motif ${k}`;
|
|
97
|
+
const shown = t.length <= LABEL_TITLE_CHARS ? t.join("") : t.slice(0, LABEL_TITLE_CHARS).join("") + "…";
|
|
98
|
+
return `motif ${k} "${shown}"`;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** An absent list is empty; a list keeps its strings trimmed; anything else is null (wrong shape). */
|
|
102
|
+
function lines(value: unknown): string[] | null {
|
|
103
|
+
if (value === undefined) return [];
|
|
104
|
+
if (!Array.isArray(value)) return null;
|
|
105
|
+
return value.map(text);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function isRelativePath(raw: unknown): boolean {
|
|
109
|
+
if (typeof raw !== "string") return false;
|
|
110
|
+
const p = raw;
|
|
111
|
+
if (p === "" || p !== p.trim()) return false;
|
|
112
|
+
if (p.startsWith("/") || p.includes("\\")) return false;
|
|
113
|
+
return !p.split("/").includes("..");
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function checkMotif(
|
|
117
|
+
value: unknown, k: number, shownIds: ReadonlySet<string>, ownerLinesShown: boolean, problems: string[],
|
|
118
|
+
): AnswerMotif | undefined {
|
|
119
|
+
const item = isPlainObject(value) ? value : {};
|
|
120
|
+
const before = problems.length;
|
|
121
|
+
const title = text(item.title);
|
|
122
|
+
const at = motifLabel(k, title);
|
|
123
|
+
|
|
124
|
+
if (title === "" || chars(title) > MAX_TITLE_CHARS) problems.push(titleLength(at));
|
|
125
|
+
const topic = text(item.topic);
|
|
126
|
+
if (!TOPIC_PATTERN.test(topic)) problems.push(topicNotSlug(at, topic, MAX_TOPIC_CHARS));
|
|
127
|
+
|
|
128
|
+
const rows = Array.isArray(item.rows) ? item.rows.map(text) : [];
|
|
129
|
+
if (rows.length === 0) problems.push(rowsEmpty(at));
|
|
130
|
+
const seen = new Set<string>();
|
|
131
|
+
for (const id of rows) {
|
|
132
|
+
if (!shownIds.has(id)) problems.push(rowNotGiven(at, id));
|
|
133
|
+
else if (seen.has(id)) problems.push(rowTwice(at, id));
|
|
134
|
+
seen.add(id);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const preventiveLine = text(item.preventive_line);
|
|
138
|
+
const novelty = text(item.novelty);
|
|
139
|
+
const keyTerm = text(item.key_term);
|
|
140
|
+
for (const [field, v] of [["preventive_line", preventiveLine], ["novelty", novelty], ["key_term", keyTerm]] as const) {
|
|
141
|
+
if (v === "") problems.push(fieldEmpty(at, field));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const kind = text(item.owner_kind) as OwnerKind;
|
|
145
|
+
const path = typeof item.owner_path === "string" ? item.owner_path : "";
|
|
146
|
+
if (!OWNER_KINDS.includes(kind)) problems.push(ownerKindIs(at));
|
|
147
|
+
if (!isRelativePath(item.owner_path)) {
|
|
148
|
+
problems.push(ownerPathNotRelative(at, path));
|
|
149
|
+
} else if (kind === "repository" && (path === ".claude" || path.startsWith(".claude/"))) {
|
|
150
|
+
problems.push(deployedCopy(at));
|
|
151
|
+
} else if (kind === "harness" && !path.startsWith(HARNESS_PACKS)) {
|
|
152
|
+
problems.push(harnessOwnerUnder(at, HARNESS_PACKS));
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const check = text(item.check) as CheckKind;
|
|
156
|
+
if (!CHECK_KINDS.includes(check)) problems.push(checkIsOneOf(at, CHECK_KINDS.join(", ")));
|
|
157
|
+
const status = text(item.status) as MotifStatus;
|
|
158
|
+
if (!STATUSES.includes(status)) problems.push(statusIs(at));
|
|
159
|
+
else if (status !== "new" && !ownerLinesShown) problems.push(atProblem(at, SEEN_LINES_ONLY(status)));
|
|
160
|
+
|
|
161
|
+
const removed = lines(item.lines_removed);
|
|
162
|
+
const added = lines(item.lines_added);
|
|
163
|
+
const linesRule = status === "removes" ? REMOVES_LINES : ADDS_LINES;
|
|
164
|
+
if (added === null || removed === null || removed.length > MAX_LINES_PER_MOTIF) {
|
|
165
|
+
problems.push(`${at}: ${linesRule}`);
|
|
166
|
+
} else if (status === "removes") {
|
|
167
|
+
if (added.length > 0 || removed.filter((l) => l !== "").length === 0) problems.push(`${at}: ${linesRule}`);
|
|
168
|
+
} else if (added.length === 0 || added.length > MAX_LINES_PER_MOTIF) {
|
|
169
|
+
problems.push(`${at}: ${linesRule}`);
|
|
170
|
+
}
|
|
171
|
+
const rawLines = [
|
|
172
|
+
...(Array.isArray(item.lines_added) ? item.lines_added : []),
|
|
173
|
+
...(Array.isArray(item.lines_removed) ? item.lines_removed : []),
|
|
174
|
+
];
|
|
175
|
+
if (rawLines.some((l) => typeof l !== "string" || chars(l.trim()) > MAX_LINE_CHARS || /[\r\n]/.test(l.trim()))) {
|
|
176
|
+
problems.push(lineLength(at));
|
|
177
|
+
}
|
|
178
|
+
if ((status === "refines" || status === "replaces") && (removed ?? []).filter((l) => l !== "").length === 0) {
|
|
179
|
+
problems.push(needsRemovedLine(at, status));
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (problems.length > before) return undefined;
|
|
183
|
+
return {
|
|
184
|
+
title, topic, rows, preventiveLine, owner: { kind, path }, check, status,
|
|
185
|
+
linesRemoved: removed ?? [], linesAdded: added ?? [], novelty, keyTerm,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function checkDropped(value: unknown, problems: string[]): AnswerDropped[] {
|
|
190
|
+
if (value === undefined) return [];
|
|
191
|
+
if (!Array.isArray(value)) {
|
|
192
|
+
problems.push(droppedNeeds(1));
|
|
193
|
+
return [];
|
|
194
|
+
}
|
|
195
|
+
const out: AnswerDropped[] = [];
|
|
196
|
+
value.forEach((v, i) => {
|
|
197
|
+
const item = isPlainObject(v) ? v : {};
|
|
198
|
+
const title = text(item.title);
|
|
199
|
+
const filter = text(item.filter) as AnswerDropped["filter"];
|
|
200
|
+
const reason = text(item.reason);
|
|
201
|
+
if (title === "" || reason === "" || !FILTERS.includes(filter)) {
|
|
202
|
+
problems.push(droppedNeeds(i + 1));
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
out.push({ title, filter, reason });
|
|
206
|
+
});
|
|
207
|
+
return out;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/** shownIds: the ids handed to the model; an id outside them is a problem. ownerLinesShown: whether the prompt that
|
|
211
|
+
* gave this answer showed owner lines; without them, a status other than new is a problem. */
|
|
212
|
+
export function checkLearnAnswer(
|
|
213
|
+
value: unknown, shownIds: ReadonlySet<string>, ownerLinesShown: boolean,
|
|
214
|
+
): Checked<LearnAnswer> {
|
|
215
|
+
if (!isPlainObject(value)) return { ok: false, problems: [NOT_AN_OBJECT] };
|
|
216
|
+
if (!Array.isArray(value.motifs)) return { ok: false, problems: [MOTIFS_MUST_BE_LIST] };
|
|
217
|
+
const problems: string[] = [];
|
|
218
|
+
if (value.motifs.length > MAX_MOTIFS_PER_AXIS) problems.push(tooManyMotifs(value.motifs.length));
|
|
219
|
+
const motifs: AnswerMotif[] = [];
|
|
220
|
+
// A motif's id hashes its axis and its rows: two motifs of one set of rows would share it, and one decision.
|
|
221
|
+
const rowSets = new Map<string, number>();
|
|
222
|
+
value.motifs.forEach((m, i) => {
|
|
223
|
+
const motif = checkMotif(m, i + 1, shownIds, ownerLinesShown, problems);
|
|
224
|
+
if (!motif) return;
|
|
225
|
+
motifs.push(motif);
|
|
226
|
+
const key = [...motif.rows].sort().join(",");
|
|
227
|
+
const first = rowSets.get(key);
|
|
228
|
+
if (first === undefined) rowSets.set(key, i + 1);
|
|
229
|
+
else problems.push(sameRows(motifLabel(i + 1, motif.title), first));
|
|
230
|
+
});
|
|
231
|
+
const dropped = checkDropped(value.dropped, problems);
|
|
232
|
+
return problems.length > 0 ? { ok: false, problems } : { ok: true, value: { motifs, dropped } };
|
|
233
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// The messages of dev-learn's domain: the problems the check of a learner's answer and the review of its owner
|
|
2
|
+
// report (the model reads them back on a re-ask), and the lines of PROPOSALS.md the person reads (ADR 0026).
|
|
3
|
+
|
|
4
|
+
// ── The problems of a learner's answer ──────────────────────────────────
|
|
5
|
+
|
|
6
|
+
export const addsLines = (max: number): string => `1 to ${max} lines added and at most ${max} removed`;
|
|
7
|
+
export const removesLines = (max: number): string => `removes takes out 1 to ${max} lines and adds none`;
|
|
8
|
+
/** Why a status other than new is refused on an answer given without owner lines: it copies a line it never saw. */
|
|
9
|
+
export const SEEN_LINES_ONLY = (status: string): string =>
|
|
10
|
+
`${status} copies a line of its owner, and this answer was given without the owner lines: give status new, ` +
|
|
11
|
+
"or copy the line from the owner lines when they are shown";
|
|
12
|
+
export const titleLength = (at: string): string => `${at}: title must be 1 to 80 characters`;
|
|
13
|
+
export const topicNotSlug = (at: string, topic: string, max: number): string =>
|
|
14
|
+
`${at}: topic '${topic}' is not a kebab slug of at most ${max} characters`;
|
|
15
|
+
export const rowsEmpty = (at: string): string => `${at}: rows is empty`;
|
|
16
|
+
export const rowNotGiven = (at: string, id: string): string => `${at}: row '${id}' is not one of the rows given`;
|
|
17
|
+
export const rowTwice = (at: string, id: string): string => `${at}: row '${id}' is listed twice`;
|
|
18
|
+
export const ownerKindIs = (at: string): string => `${at}: owner_kind must be repository or harness`;
|
|
19
|
+
export const ownerPathNotRelative = (at: string, path: string): string => `${at}: owner_path '${path}' is not a relative path`;
|
|
20
|
+
export const deployedCopy = (at: string): string =>
|
|
21
|
+
`${at}: .claude/ is the harness's deployed copy: name the orkeon-workshop file with owner_kind harness`;
|
|
22
|
+
export const harnessOwnerUnder = (at: string, packs: string): string =>
|
|
23
|
+
`${at}: a harness owner is a file of the orkeon-workshop repository under ${packs}`;
|
|
24
|
+
export const checkIsOneOf = (at: string, kinds: string): string => `${at}: check must be one of ${kinds}`;
|
|
25
|
+
export const statusIs = (at: string): string => `${at}: status must be new, refines, replaces or removes`;
|
|
26
|
+
export const atProblem = (at: string, problem: string): string => `${at}: ${problem}`;
|
|
27
|
+
export const lineLength = (at: string): string => `${at}: each line is one line of at most 300 characters`;
|
|
28
|
+
export const needsRemovedLine = (at: string, status: string): string => `${at}: ${status} needs the line it removes`;
|
|
29
|
+
export const droppedNeeds = (k: number): string => `dropped ${k}: title, filter and reason are needed`;
|
|
30
|
+
export const MOTIFS_MUST_BE_LIST = "motifs must be a list";
|
|
31
|
+
export const tooManyMotifs = (count: number): string => `at most 3 motifs, not ${count}`;
|
|
32
|
+
export const sameRows = (label: string, first: number): string => `${label}: the same rows as motif ${first}: merge them into one motif`;
|
|
33
|
+
|
|
34
|
+
// ── The owner review ────────────────────────────────────────────────────
|
|
35
|
+
|
|
36
|
+
export const keyTermNotFound = (term: string, path: string): string => `'${term}' not found in ${path}`;
|
|
37
|
+
export const keyTermFound = (term: string, count: number, path: string, first: number): string =>
|
|
38
|
+
`'${term}' on ${count} lines of ${path}, first ${path}:${first}`;
|
|
39
|
+
export const OWNER_MAY_SAY_IT = "; the owner may already say it";
|
|
40
|
+
export const removedNotFound = (line: string): string => `; removed line not found: ${line}`;
|
|
41
|
+
export const keyTermOnLines = (label: string, term: string, count: number, path: string): string =>
|
|
42
|
+
`${label}: '${term}' is on ${count} lines of ${path}, shown below: keep status new only ` +
|
|
43
|
+
"for what they miss; else refine, replace or remove one of them, or drop the motif under novelty";
|
|
44
|
+
export const nearestLine = (shown: string): string => `; nearest: ${shown}`;
|
|
45
|
+
export const keyTermFindsNoLine = (term: string): string => `; '${term}' finds no line there: give the motif status new`;
|
|
46
|
+
export const removedNotFoundIn = (label: string, path: string, line: string, where: string): string =>
|
|
47
|
+
`${label}: removed line not found in ${path}: "${line}"${where}`;
|
|
48
|
+
|
|
49
|
+
// ── PROPOSALS.md ────────────────────────────────────────────────────────
|
|
50
|
+
|
|
51
|
+
export const NO_MOTIF_KEPT = "No motif kept.";
|
|
52
|
+
export const noProposal = (reason: string | undefined): string =>
|
|
53
|
+
`No proposal: the answer did not parse after one re-ask (${reason ?? "no reason given"}).`;
|
|
54
|
+
export const unchangedSince = (since: string | undefined): string => `Unchanged since ${since ?? "an earlier run"}: not asked again.`;
|
|
55
|
+
export const MOTIF_TABLE_HEADER = [
|
|
56
|
+
"| Id | Motif | Batches | Status | Owner | Check | Reconcile |",
|
|
57
|
+
"|----|-------|---------|--------|-------|-------|-----------|",
|
|
58
|
+
];
|
|
59
|
+
export const notShown = (hidden: number, cap: number): string => `Not shown to the model: ${hidden} gaps (cap ${cap})`;
|
|
60
|
+
export const NOTHING_TO_DECIDE = "Nothing to decide.";
|
|
61
|
+
export const proposalsHead = (
|
|
62
|
+
work: string, gaps: number, batches: number, files: number, orkeon: number, harness: number, refused: number,
|
|
63
|
+
): string =>
|
|
64
|
+
`Work folder \`${work}\`: ${gaps} untreated gaps across ${batches} batches in ${files} verdict files. ` +
|
|
65
|
+
`Treated before: ${orkeon} by Orkeon Code, ${harness} by the harness. Refused motifs: ${refused}.`;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// A motif's owner file as code reads it: the lines its key term finds and the removed
|
|
2
|
+
// lines the file does not hold, turned into the summary written to the proposal and,
|
|
3
|
+
// when the answer cannot stand as it is, the problems and owner lines a re-ask shows.
|
|
4
|
+
// The learner sees the owner files by path only, so these lines are the first it sees
|
|
5
|
+
// of their content. Pure, no IO: the file is read by the use case.
|
|
6
|
+
import { foldText } from "../../../shared/domain/shared-memory/verdict-rows.ts";
|
|
7
|
+
import type { AnswerMotif } from "./learn-answer.ts";
|
|
8
|
+
import {
|
|
9
|
+
OWNER_MAY_SAY_IT, keyTermFindsNoLine, keyTermFound, keyTermNotFound, keyTermOnLines, nearestLine, removedNotFound,
|
|
10
|
+
removedNotFoundIn,
|
|
11
|
+
} from "./messages.ts";
|
|
12
|
+
|
|
13
|
+
export const MAX_OWNER_LINES_PER_MOTIF = 8;
|
|
14
|
+
export const MAX_OWNER_LINE_CHARS = 160;
|
|
15
|
+
const REMOVED_SHOWN = 60;
|
|
16
|
+
|
|
17
|
+
export interface OwnerHit { n: number; line: string }
|
|
18
|
+
/** hits: the lines holding the key term (1-based numbers); missing: the removed lines, trimmed, the file lacks. */
|
|
19
|
+
export interface OwnerMatch { hits: OwnerHit[]; missing: string[] }
|
|
20
|
+
/** The owner lines shown under the problems of a re-ask, each `<path>:<n>: <line>`; label: the motif as the
|
|
21
|
+
* problems name it. */
|
|
22
|
+
export interface OwnerLinesBlock { label: string; path: string; lines: string[] }
|
|
23
|
+
export interface OwnerReview { summary: string; problems: string[]; block: OwnerLinesBlock | null }
|
|
24
|
+
export type ReviewedMotif = Pick<AnswerMotif, "title" | "keyTerm" | "status" | "linesRemoved">;
|
|
25
|
+
|
|
26
|
+
const cut = (text: string, n: number): string => {
|
|
27
|
+
const chars = Array.from(text);
|
|
28
|
+
return chars.length <= n ? text : chars.slice(0, n - 1).join("") + "…";
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const words = (text: string): Set<string> => new Set(foldText(text).split(/[^\p{L}\p{N}]+/u).filter((w) => w.length >= 3));
|
|
32
|
+
|
|
33
|
+
export function matchOwner(text: string, keyTerm: string, removed: readonly string[]): OwnerMatch {
|
|
34
|
+
const lines = text.split(/\r?\n/);
|
|
35
|
+
const term = foldText(keyTerm);
|
|
36
|
+
const hits = lines.flatMap((line, i) => (foldText(line).includes(term) ? [{ n: i + 1, line }] : []));
|
|
37
|
+
const present = new Set(lines.map((l) => l.trim()));
|
|
38
|
+
const missing = removed.map((l) => l.trim()).filter((l) => !present.has(l));
|
|
39
|
+
return { hits, missing };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const shownLine = (path: string, hit: OwnerHit): string => `${path}:${hit.n}: ${cut(hit.line.trim(), MAX_OWNER_LINE_CHARS)}`;
|
|
43
|
+
|
|
44
|
+
/** The hit sharing the most words with `line`, the first on a tie. */
|
|
45
|
+
function nearest(hits: readonly OwnerHit[], line: string): OwnerHit {
|
|
46
|
+
const wanted = words(line);
|
|
47
|
+
let best = hits[0];
|
|
48
|
+
let bestScore = -1;
|
|
49
|
+
for (const hit of hits) {
|
|
50
|
+
const score = [...words(hit.line)].filter((w) => wanted.has(w)).length;
|
|
51
|
+
if (score > bestScore) {
|
|
52
|
+
best = hit;
|
|
53
|
+
bestScore = score;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return best;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** What code found in the owner, as the proposal records it. */
|
|
60
|
+
export function ownerSummary(motif: ReviewedMotif, path: string, match: OwnerMatch): string {
|
|
61
|
+
const { hits } = match;
|
|
62
|
+
let out = hits.length === 0
|
|
63
|
+
? keyTermNotFound(motif.keyTerm, path)
|
|
64
|
+
: keyTermFound(motif.keyTerm, hits.length, path, hits[0].n);
|
|
65
|
+
if (motif.status === "new" && hits.length > 0) out += OWNER_MAY_SAY_IT;
|
|
66
|
+
for (const removed of match.missing) out += removedNotFound(cut(removed, REMOVED_SHOWN));
|
|
67
|
+
return out;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** label: the motif as the problems name it (motifLabel). A new motif whose key term is in the owner, and a removed
|
|
71
|
+
* line the owner lacks, are problems; the owner lines go with them, and with a motif whose status copies an owner
|
|
72
|
+
* line, when the key term found any. path: the owner as the model names it, never the deployed copy read. */
|
|
73
|
+
export function reviewOwner(label: string, motif: ReviewedMotif, path: string, match: OwnerMatch): OwnerReview {
|
|
74
|
+
const { hits, missing } = match;
|
|
75
|
+
const problems: string[] = [];
|
|
76
|
+
if (motif.status === "new" && hits.length > 0) {
|
|
77
|
+
problems.push(keyTermOnLines(label, motif.keyTerm, hits.length, path));
|
|
78
|
+
}
|
|
79
|
+
for (const line of missing) {
|
|
80
|
+
const where = hits.length > 0
|
|
81
|
+
? nearestLine(shownLine(path, nearest(hits, line)))
|
|
82
|
+
: keyTermFindsNoLine(motif.keyTerm);
|
|
83
|
+
problems.push(removedNotFoundIn(label, path, cut(line, REMOVED_SHOWN), where));
|
|
84
|
+
}
|
|
85
|
+
const block = (problems.length > 0 || motif.status !== "new") && hits.length > 0
|
|
86
|
+
? { label, path, lines: hits.slice(0, MAX_OWNER_LINES_PER_MOTIF).map((h) => shownLine(path, h)) }
|
|
87
|
+
: null;
|
|
88
|
+
return { summary: ownerSummary(motif, path, match), problems, block };
|
|
89
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// PROPOSALS.md, rendered by code from the run's ProposalsFile: a head line, one section
|
|
2
|
+
// per axis (a table of the motifs kept, what was dropped, then one block per motif with
|
|
3
|
+
// its lines), and the commands that decide. The file is read by people; proposals.json
|
|
4
|
+
// beside it is the source the decisions read. Pure, no IO.
|
|
5
|
+
import type { AxisProposal, Motif, ProposalsFile } from "../../../shared/domain/dev/learn-proposals.ts";
|
|
6
|
+
import { MOTIF_TABLE_HEADER, NOTHING_TO_DECIDE, NO_MOTIF_KEPT, noProposal, notShown, proposalsHead, unchangedSince } from "./messages.ts";
|
|
7
|
+
|
|
8
|
+
const TITLE_CELL = 80;
|
|
9
|
+
const RECONCILE_CELL = 160;
|
|
10
|
+
const OWNER_CELL = 200;
|
|
11
|
+
/** The rows shown per axis (MAX_ROWS_PER_AXIS of run-dev-learn.ts), named in the "Not shown" line. */
|
|
12
|
+
const ROWS_CAP = 40;
|
|
13
|
+
const FENCE = "```";
|
|
14
|
+
|
|
15
|
+
/** "|" → "/", line breaks → " · ", cut at max characters with "…". */
|
|
16
|
+
export function escapeCell(text: string, max: number): string {
|
|
17
|
+
const flat = text.replace(/\r\n|\r|\n/g, " · ").replace(/\|/g, "/");
|
|
18
|
+
const chars = Array.from(flat);
|
|
19
|
+
return chars.length <= max ? flat : chars.slice(0, Math.max(0, max - 1)).join("") + "…";
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function tableRow(m: Motif): string {
|
|
23
|
+
const owner = `${m.owner.kind} \`${escapeCell(m.owner.path, OWNER_CELL)}\``;
|
|
24
|
+
const cells = [
|
|
25
|
+
m.id, escapeCell(m.title, TITLE_CELL), String(m.batches.length), m.status, owner, m.check,
|
|
26
|
+
escapeCell(m.reconcile, RECONCILE_CELL),
|
|
27
|
+
];
|
|
28
|
+
return `| ${cells.join(" | ")} |`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function motifBlock(m: Motif): string[] {
|
|
32
|
+
return [
|
|
33
|
+
`### ${m.id} — ${m.title}`,
|
|
34
|
+
"",
|
|
35
|
+
`- Rows: ${m.rows.join(", ")} (batches ${m.batches.join(", ")})`,
|
|
36
|
+
`- Preventive line: ${m.preventiveLine}`,
|
|
37
|
+
`- Why new: ${m.novelty}`,
|
|
38
|
+
"- Lines:",
|
|
39
|
+
"",
|
|
40
|
+
`${FENCE}diff`,
|
|
41
|
+
`file: ${m.owner.path}`,
|
|
42
|
+
...m.linesRemoved.map((l) => `- ${l}`),
|
|
43
|
+
...m.linesAdded.map((l) => `+ ${l}`),
|
|
44
|
+
FENCE,
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function outcomeLine(a: AxisProposal): string {
|
|
49
|
+
if (a.outcome === "no-motif") return NO_MOTIF_KEPT;
|
|
50
|
+
if (a.outcome === "no-proposal") return noProposal(a.reason);
|
|
51
|
+
return unchangedSince(a.reason);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function axisSection(a: AxisProposal): string[] {
|
|
55
|
+
const out = [`## ${a.axis} — ${a.batches} batches, ${a.gaps} gaps`, ""];
|
|
56
|
+
if (a.outcome === "proposed") {
|
|
57
|
+
out.push(
|
|
58
|
+
...MOTIF_TABLE_HEADER,
|
|
59
|
+
...a.motifs.map(tableRow),
|
|
60
|
+
);
|
|
61
|
+
} else {
|
|
62
|
+
out.push(outcomeLine(a));
|
|
63
|
+
}
|
|
64
|
+
const notes = [
|
|
65
|
+
...a.dropped.map((d) => `Dropped: ${d.title} — ${d.filter}: ${d.reason}`),
|
|
66
|
+
...(a.hiddenRows > 0 ? [notShown(a.hiddenRows, ROWS_CAP)] : []),
|
|
67
|
+
];
|
|
68
|
+
if (notes.length > 0) out.push("", ...notes);
|
|
69
|
+
if (a.outcome === "proposed") for (const m of a.motifs) out.push("", ...motifBlock(m));
|
|
70
|
+
return out;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function decideSection(file: ProposalsFile): string[] {
|
|
74
|
+
const ids = file.axes.flatMap((a) => (a.outcome === "proposed" ? a.motifs.map((m) => m.id) : []));
|
|
75
|
+
if (ids.length === 0) return ["## Decide", "", NOTHING_TO_DECIDE];
|
|
76
|
+
return [
|
|
77
|
+
"## Decide", "",
|
|
78
|
+
`${FENCE}text`,
|
|
79
|
+
`/dev-learn --accept ${ids.join(",")}`,
|
|
80
|
+
...ids.map((id) => `/dev-learn --refuse ${id}`),
|
|
81
|
+
FENCE,
|
|
82
|
+
];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function renderProposals(file: ProposalsFile): string {
|
|
86
|
+
const r = file.read;
|
|
87
|
+
const lines = [
|
|
88
|
+
`# Learn proposals — ${file.date}`,
|
|
89
|
+
"",
|
|
90
|
+
proposalsHead(file.work, r.gaps, r.batches, r.files, r.treatedOrkeon, r.treatedHarness, r.refused),
|
|
91
|
+
];
|
|
92
|
+
for (const a of file.axes) lines.push("", ...axisSection(a));
|
|
93
|
+
lines.push("", ...decideSection(file));
|
|
94
|
+
return lines.join("\n") + "\n";
|
|
95
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// The anchors of a checked plan answer against the repository: a path given as existing
|
|
2
|
+
// must be there, a path given as a file to create must not be. One listing per folder and
|
|
3
|
+
// per run (40 folders at most, the cache shared by the two attempts of a run); it reads
|
|
4
|
+
// listings only and writes nothing. Past the cap, or in a folder whose listing the entry cap
|
|
5
|
+
// cut short, an existing anchor it cannot see is refused as not checked, never let through. Its problems join the answer's, for the one re-ask.
|
|
6
|
+
import type { Files } from "../../../shared/application/ports.ts";
|
|
7
|
+
import { stepLabel } from "../domain/plan-answer.ts";
|
|
8
|
+
import type { AnchorRef, PlanAnswer } from "../domain/plan-answer.ts";
|
|
9
|
+
import { anchorKindSetRight, anchorPathColon, doesNotExist, existsAnchorIt, notCheckedEntries, notCheckedFolders } from "../domain/messages.ts";
|
|
10
|
+
import { WORKSPACE } from "../../../shared/domain/vfs.ts";
|
|
11
|
+
|
|
12
|
+
export const MAX_ANCHOR_FOLDERS = 40;
|
|
13
|
+
|
|
14
|
+
/** The folders listed in one run, relative to /workspace ("" for the top), with the names they hold. */
|
|
15
|
+
export type AnchorListings = Map<string, ReadonlySet<string>>;
|
|
16
|
+
|
|
17
|
+
export const LIST_CAP = 1000;
|
|
18
|
+
|
|
19
|
+
const folderOf = (path: string): string => {
|
|
20
|
+
const cut = path.lastIndexOf("/");
|
|
21
|
+
return cut < 0 ? "" : path.slice(0, cut);
|
|
22
|
+
};
|
|
23
|
+
const nameOf = (path: string): string => path.slice(path.lastIndexOf("/") + 1);
|
|
24
|
+
|
|
25
|
+
/** The names of `folder`, listed once per run; null past MAX_ANCHOR_FOLDERS folders. A listing that throws is empty. */
|
|
26
|
+
async function listingOf(files: Pick<Files, "list">, listings: AnchorListings, folder: string): Promise<ReadonlySet<string> | null> {
|
|
27
|
+
const known = listings.get(folder);
|
|
28
|
+
if (known !== undefined) return known;
|
|
29
|
+
if (listings.size >= MAX_ANCHOR_FOLDERS) return null;
|
|
30
|
+
let names: string[];
|
|
31
|
+
try {
|
|
32
|
+
names = await files.list(folder === "" ? WORKSPACE : `${WORKSPACE}/${folder}`, LIST_CAP);
|
|
33
|
+
} catch {
|
|
34
|
+
names = [];
|
|
35
|
+
}
|
|
36
|
+
const set = new Set(names.map((n) => n.replace(/\/+$/, "")));
|
|
37
|
+
listings.set(folder, set);
|
|
38
|
+
return set;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The anchor kind code knows better than the model, set right in `answer` instead of costing a second call: a test
|
|
43
|
+
* or double file given as existing that a whole listing does not hold becomes a file to create. A production file
|
|
44
|
+
* given as existing and absent stays for checkAnchorPaths to refuse (the step meant to change code that is not
|
|
45
|
+
* there), as does a file to create that exists (the plan did not see it). Returns one line per anchor set right.
|
|
46
|
+
*/
|
|
47
|
+
export async function repairAnchorKinds(
|
|
48
|
+
files: Pick<Files, "list">, answer: PlanAnswer, listings: AnchorListings = new Map(),
|
|
49
|
+
): Promise<string[]> {
|
|
50
|
+
const repaired: string[] = [];
|
|
51
|
+
for (const batch of answer.batches) {
|
|
52
|
+
for (const step of batch.steps) {
|
|
53
|
+
const anchors: Array<[AnchorRef, boolean]> = [
|
|
54
|
+
...step.anchors.tests.map((a): [AnchorRef, boolean] => [a, true]),
|
|
55
|
+
...step.anchors.doubles.map((a): [AnchorRef, boolean] => [a, true]),
|
|
56
|
+
...step.anchors.production.map((a): [AnchorRef, boolean] => [a, false]),
|
|
57
|
+
];
|
|
58
|
+
for (const [a, testSide] of anchors) {
|
|
59
|
+
if (!testSide || a.kind !== "existing" || a.path === undefined) continue;
|
|
60
|
+
const path = a.path.replace(/^\.\//, "");
|
|
61
|
+
if (path.includes(":")) continue;
|
|
62
|
+
const names = await listingOf(files, listings, folderOf(path));
|
|
63
|
+
if (names === null) continue;
|
|
64
|
+
if (a.kind === "existing" && !names.has(nameOf(path)) && names.size < LIST_CAP) {
|
|
65
|
+
a.kind = "create";
|
|
66
|
+
repaired.push(anchorKindSetRight(path));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return [...new Set(repaired)];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* `<step>: <path> does not exist` / `<step>: <path> exists: …` / `<step>: anchor "<path>" not checked: …`, the step
|
|
76
|
+
* labelled as the answer check labels it (`F1 "<name>" S2 "<title>"`),
|
|
77
|
+
* each once, in plan order. `listings` carries the folders already listed in this run, and gains the new ones.
|
|
78
|
+
*/
|
|
79
|
+
export async function checkAnchorPaths(
|
|
80
|
+
files: Pick<Files, "list">, answer: PlanAnswer, listings: AnchorListings = new Map(),
|
|
81
|
+
): Promise<string[]> {
|
|
82
|
+
const listing = (folder: string) => listingOf(files, listings, folder);
|
|
83
|
+
const problems: string[] = [];
|
|
84
|
+
const seen = new Set<string>();
|
|
85
|
+
for (const [k, batch] of answer.batches.entries()) {
|
|
86
|
+
for (const [j, step] of batch.steps.entries()) {
|
|
87
|
+
const anchors: AnchorRef[] = [...step.anchors.tests, ...step.anchors.doubles, ...step.anchors.production];
|
|
88
|
+
for (const a of anchors) {
|
|
89
|
+
if ((a.kind !== "create" && a.kind !== "existing") || a.path === undefined) continue;
|
|
90
|
+
const path = a.path.replace(/^\.\//, "");
|
|
91
|
+
const at = stepLabel(batch, k, j);
|
|
92
|
+
let problem: string | null = null;
|
|
93
|
+
if (path.includes(":")) {
|
|
94
|
+
problem = anchorPathColon(at, path);
|
|
95
|
+
} else {
|
|
96
|
+
const names = await listing(folderOf(path));
|
|
97
|
+
if (names === null) {
|
|
98
|
+
if (a.kind === "existing") problem = notCheckedFolders(at, path, MAX_ANCHOR_FOLDERS);
|
|
99
|
+
} else {
|
|
100
|
+
const present = names.has(nameOf(path));
|
|
101
|
+
// A listing the cap cut short may leave the name out: that is no proof it is absent.
|
|
102
|
+
if (a.kind === "existing" && !present && names.size >= LIST_CAP) {
|
|
103
|
+
problem = notCheckedEntries(at, path, LIST_CAP);
|
|
104
|
+
} else if (a.kind === "existing" && !present) problem = doesNotExist(at, path);
|
|
105
|
+
if (a.kind === "create" && present) problem = existsAnchorIt(at, path);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (problem !== null && !seen.has(problem)) { seen.add(problem); problems.push(problem); }
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return problems;
|
|
113
|
+
}
|