orkeon-code 0.0.0-stage → 1.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.orkeon-version +1 -0
- package/LICENSE.md +21 -0
- package/NOTICE.md +17 -0
- package/README.fr.md +169 -0
- package/README.md +162 -2
- package/config/appsettings.anthropic.example.json +77 -0
- package/config/appsettings.example.json +71 -0
- package/config/appsettings.jev.example.json +128 -0
- package/config/appsettings.kev.example.json +130 -0
- package/config/appsettings.liquid.example.json +129 -0
- package/config/appsettings.ollama-whisper.example.json +92 -0
- package/config/appsettings.ollama.example.json +70 -0
- package/config/appsettings.whisper.example.json +31 -0
- package/mcp/whisper/README.md +293 -0
- package/mcp/whisper/pyproject.toml +32 -0
- package/mcp/whisper/uv.lock +1641 -0
- package/mcp/whisper/whisper_mcp.py +1053 -0
- package/orkeon-code +897 -0
- package/orkeon-code.mjs +71 -0
- package/orkeon-code.ps1 +837 -0
- package/package.json +57 -4
- package/scripts/install.ps1 +156 -0
- package/scripts/install.sh +148 -0
- package/scripts/session-start.ork.ts +90 -0
- package/scripts/session-start.sh +74 -0
- package/scripts/setup-fixture.sh +88 -0
- package/src/commands/.orkeon/orkeon-cli.d.ts +562 -0
- package/src/commands/_lib/args.ts +193 -0
- package/src/commands/_lib/dev/dev-batches.ts +368 -0
- package/src/commands/_lib/dev/dev-implement.ts +188 -0
- package/src/commands/_lib/dev/dev-source.ts +65 -0
- package/src/commands/_lib/dev/dev.ts +344 -0
- package/src/commands/_lib/dev-step.ts +142 -0
- package/src/commands/_lib/dispatch.ts +231 -0
- package/src/commands/_lib/effort.ts +15 -0
- package/src/commands/_lib/git/branch.ts +95 -0
- package/src/commands/_lib/git/commit.ts +94 -0
- package/src/commands/_lib/git/diff.ts +97 -0
- package/src/commands/_lib/git/review.ts +109 -0
- package/src/commands/_lib/memory/memory-admit.ts +150 -0
- package/src/commands/_lib/memory/memory.ts +51 -0
- package/src/commands/_lib/pr-context.ts +32 -0
- package/src/commands/_lib/project/analyze.ts +24 -0
- package/src/commands/_lib/session/export.ts +104 -0
- package/src/commands/_lib/session/resume.ts +160 -0
- package/src/commands/_lib/session/tasks.ts +184 -0
- package/src/commands/_lib/settings/advisor.ts +80 -0
- package/src/commands/_lib/settings/agents.ts +147 -0
- package/src/commands/_lib/settings/config.ts +141 -0
- package/src/commands/_lib/settings/hooks.ts +58 -0
- package/src/commands/_lib/settings/mode.ts +91 -0
- package/src/commands/_lib/settings/model.ts +146 -0
- package/src/commands/_lib/settings/permissions.ts +309 -0
- package/src/commands/_lib/settings/session-config.ts +49 -0
- package/src/commands/_lib/settings/skills.ts +51 -0
- package/src/commands/_lib/speech/say.ts +96 -0
- package/src/commands/_lib/speech/transcribe.ts +130 -0
- package/src/commands/_lib/speech/voice.ts +146 -0
- package/src/commands/_lib/status/cache.ts +31 -0
- package/src/commands/_lib/status/context.ts +57 -0
- package/src/commands/_lib/status/doctor.ts +186 -0
- package/src/commands/_lib/status/meta.ts +45 -0
- package/src/commands/_lib/status/status.ts +129 -0
- package/src/commands/_lib/status/usage-tools.ts +49 -0
- package/src/commands/_lib/status/usage.ts +139 -0
- package/src/commands/_lib/view.ts +29 -0
- package/src/commands/dev/dev-batches.cmd.ts +108 -0
- package/src/commands/dev/dev-learn.cmd.ts +29 -0
- package/src/commands/dev/dev-plan.cmd.ts +52 -0
- package/src/commands/dev/dev-spec.cmd.ts +55 -0
- package/src/commands/dev/dev-status.cmd.ts +16 -0
- package/src/commands/git/branch.cmd.ts +27 -0
- package/src/commands/git/commit.cmd.ts +48 -0
- package/src/commands/git/diff.cmd.ts +26 -0
- package/src/commands/git/review.cmd.ts +36 -0
- package/src/commands/memory/memory.cmd.ts +48 -0
- package/src/commands/project/analyze.cmd.ts +32 -0
- package/src/commands/project/debug-tool-call.cmd.ts +67 -0
- package/src/commands/project/files.cmd.ts +22 -0
- package/src/commands/project/init-verifiers.cmd.ts +14 -0
- package/src/commands/project/init.cmd.ts +14 -0
- package/src/commands/project/verify.cmd.ts +27 -0
- package/src/commands/session/assistant.cmd.ts +40 -0
- package/src/commands/session/btw.cmd.ts +18 -0
- package/src/commands/session/clear.cmd.ts +19 -0
- package/src/commands/session/compact.cmd.ts +16 -0
- package/src/commands/session/copy.cmd.ts +44 -0
- package/src/commands/session/exit.cmd.ts +9 -0
- package/src/commands/session/export.cmd.ts +28 -0
- package/src/commands/session/rename.cmd.ts +17 -0
- package/src/commands/session/resume.cmd.ts +19 -0
- package/src/commands/session/rewind.cmd.ts +26 -0
- package/src/commands/session/summary.cmd.ts +27 -0
- package/src/commands/session/tasks.cmd.ts +44 -0
- package/src/commands/settings/advisor.cmd.ts +38 -0
- package/src/commands/settings/agents.cmd.ts +19 -0
- package/src/commands/settings/config.cmd.ts +17 -0
- package/src/commands/settings/effort.cmd.ts +40 -0
- package/src/commands/settings/fast.cmd.ts +17 -0
- package/src/commands/settings/hooks.cmd.ts +17 -0
- package/src/commands/settings/mode.cmd.ts +20 -0
- package/src/commands/settings/model.cmd.ts +20 -0
- package/src/commands/settings/output-style.cmd.ts +48 -0
- package/src/commands/settings/permissions.cmd.ts +25 -0
- package/src/commands/settings/proactive.cmd.ts +15 -0
- package/src/commands/settings/skills.cmd.ts +17 -0
- package/src/commands/speech/say.cmd.ts +24 -0
- package/src/commands/speech/transcribe.cmd.ts +29 -0
- package/src/commands/speech/voice.cmd.ts +30 -0
- package/src/commands/status/context.cmd.ts +18 -0
- package/src/commands/status/doctor.cmd.ts +27 -0
- package/src/commands/status/release-notes.cmd.ts +9 -0
- package/src/commands/status/status.cmd.ts +25 -0
- package/src/commands/status/usage.cmd.ts +21 -0
- package/src/crews/.orkeon/orkeon.d.ts +3946 -0
- package/src/crews/_probe-shared-memory/domain/probe-verdict.ts +183 -0
- package/src/crews/_probe-shared-memory/probe.ork.ts +98 -0
- package/src/crews/advisor/application/run-advisor.ts +40 -0
- package/src/crews/advisor/crew.ork.ts +43 -0
- package/src/crews/advisor/domain/advice.ts +135 -0
- package/src/crews/agent-run/application/run-agent-run.ts +42 -0
- package/src/crews/agent-run/crew.ork.ts +67 -0
- package/src/crews/analyze/application/run-analyze.ts +118 -0
- package/src/crews/analyze/crew.ork.ts +40 -0
- package/src/crews/analyze/domain/harvest.ts +301 -0
- package/src/crews/code-review/application/prompts.ts +133 -0
- package/src/crews/code-review/application/review.ts +71 -0
- package/src/crews/code-review/application/run-code-review.ts +123 -0
- package/src/crews/code-review/crew.ork.ts +51 -0
- package/src/crews/code-review/domain/lenses.ts +193 -0
- package/src/crews/code-review/domain/report.ts +59 -0
- package/src/crews/code-review/domain/scope.ts +112 -0
- package/src/crews/dev-batches/application/plan-close.ts +181 -0
- package/src/crews/dev-batches/application/run-dev-batches.ts +669 -0
- package/src/crews/dev-batches/application/run-wave.ts +450 -0
- package/src/crews/dev-batches/application/seed-harvest.ts +162 -0
- package/src/crews/dev-batches/crew.ork.ts +143 -0
- package/src/crews/dev-batches/domain/batch-waves.ts +70 -0
- package/src/crews/dev-batches/domain/batches-budget.ts +52 -0
- package/src/crews/dev-batches/domain/batches-log.ts +54 -0
- package/src/crews/dev-batches/domain/wave-order.ts +43 -0
- package/src/crews/dev-change/application/change-prompt.ts +104 -0
- package/src/crews/dev-change/application/evidence.ts +169 -0
- package/src/crews/dev-change/application/run-dev-change.ts +315 -0
- package/src/crews/dev-change/crew.ork.ts +112 -0
- package/src/crews/dev-change/domain/change-answer.ts +159 -0
- package/src/crews/dev-change/domain/change-render.ts +79 -0
- package/src/crews/dev-implement/application/close.ts +183 -0
- package/src/crews/dev-implement/application/count-open-steps.ts +24 -0
- package/src/crews/dev-implement/application/locate-sheet.ts +80 -0
- package/src/crews/dev-implement/application/observe.ts +50 -0
- package/src/crews/dev-implement/application/report-writes.ts +41 -0
- package/src/crews/dev-implement/application/run-dev-implement.ts +811 -0
- package/src/crews/dev-implement/application/run-role.ts +27 -0
- package/src/crews/dev-implement/application/suite-job.ts +118 -0
- package/src/crews/dev-implement/application/touched.ts +74 -0
- package/src/crews/dev-implement/crew.ork.ts +68 -0
- package/src/crews/dev-implement/domain/contracts.ts +256 -0
- package/src/crews/dev-implement/domain/correction.ts +102 -0
- package/src/crews/dev-implement/domain/cycles.ts +35 -0
- package/src/crews/dev-implement/domain/implement-budget.ts +29 -0
- package/src/crews/dev-implement/domain/roles.ts +53 -0
- package/src/crews/dev-implement/domain/sheet-edits.ts +75 -0
- package/src/crews/dev-implement/domain/sheet-ticks.ts +22 -0
- package/src/crews/dev-implement/domain/step-checks.ts +136 -0
- package/src/crews/dev-implement/domain/step-section.ts +127 -0
- package/src/crews/dev-learn/application/learn-backlog.ts +58 -0
- package/src/crews/dev-learn/application/learn-prompt.ts +140 -0
- package/src/crews/dev-learn/application/run-dev-learn.ts +553 -0
- package/src/crews/dev-learn/crew.ork.ts +52 -0
- package/src/crews/dev-learn/domain/learn-answer.ts +235 -0
- package/src/crews/dev-learn/domain/owner-lines.ts +86 -0
- package/src/crews/dev-learn/domain/proposals-render.ts +96 -0
- package/src/crews/dev-plan/application/anchor-paths.ts +76 -0
- package/src/crews/dev-plan/application/inventory.ts +170 -0
- package/src/crews/dev-plan/application/plan-prompt.ts +159 -0
- package/src/crews/dev-plan/application/run-dev-plan.ts +455 -0
- package/src/crews/dev-plan/crew.ork.ts +109 -0
- package/src/crews/dev-plan/domain/inventory-model.ts +95 -0
- package/src/crews/dev-plan/domain/plan-answer.ts +738 -0
- package/src/crews/dev-plan/domain/plan-render.ts +307 -0
- package/src/crews/dev-spec/application/run-dev-spec.ts +206 -0
- package/src/crews/dev-spec/application/spec-prompt.ts +98 -0
- package/src/crews/dev-spec/crew.ork.ts +108 -0
- package/src/crews/dev-spec/domain/spec-answer.ts +253 -0
- package/src/crews/dev-spec/domain/spec-render.ts +76 -0
- package/src/crews/dev-verify/application/audit.ts +259 -0
- package/src/crews/dev-verify/application/auditor-prompt.ts +323 -0
- package/src/crews/dev-verify/application/capture.ts +303 -0
- package/src/crews/dev-verify/application/run-dev-verify.ts +409 -0
- package/src/crews/dev-verify/application/run-gate.ts +202 -0
- package/src/crews/dev-verify/crew.ork.ts +103 -0
- package/src/crews/dev-verify/domain/audit-answer.ts +150 -0
- package/src/crews/dev-verify/domain/auditor-charter.ts +21 -0
- package/src/crews/dev-verify/domain/capture-sections.ts +137 -0
- package/src/crews/dev-verify/domain/commands.ts +103 -0
- package/src/crews/dev-verify/domain/gate.ts +126 -0
- package/src/crews/dev-verify/domain/mechanical-table.ts +163 -0
- package/src/crews/dev-verify/domain/runtime-cut.ts +13 -0
- package/src/crews/dev-verify/domain/sheet-facts.ts +4 -0
- package/src/crews/dev-verify/domain/text.ts +20 -0
- package/src/crews/dev-verify/domain/verdict.ts +127 -0
- package/src/crews/git-commit/application/draft.ts +154 -0
- package/src/crews/git-commit/application/run-git-commit.ts +116 -0
- package/src/crews/git-commit/crew.ork.ts +52 -0
- package/src/crews/git-commit/domain/commit.ts +220 -0
- package/src/crews/init-verifiers/application/authoring.ts +89 -0
- package/src/crews/init-verifiers/application/prompts.ts +103 -0
- package/src/crews/init-verifiers/application/run-init-verifiers.ts +25 -0
- package/src/crews/init-verifiers/crew.ork.ts +34 -0
- package/src/crews/init-verifiers/domain/commands-section.ts +36 -0
- package/src/crews/init-verifiers/domain/readiness.ts +23 -0
- package/src/crews/main-loop/application/auto-compact.ts +77 -0
- package/src/crews/main-loop/application/context-gather.ts +133 -0
- package/src/crews/main-loop/application/run-main-loop.ts +350 -0
- package/src/crews/main-loop/application/turn-prompt.ts +112 -0
- package/src/crews/main-loop/crew.ork.ts +119 -0
- package/src/crews/main-loop/domain/autocompact.ts +27 -0
- package/src/crews/main-loop/domain/prompt-assembly.ts +521 -0
- package/src/crews/main-loop/domain/turn-chains.ts +129 -0
- package/src/crews/project-init/application/detect.ts +122 -0
- package/src/crews/project-init/application/prompts.ts +101 -0
- package/src/crews/project-init/application/run-project-init.ts +31 -0
- package/src/crews/project-init/crew.ork.ts +35 -0
- package/src/crews/project-init/domain/conventions.ts +36 -0
- package/src/crews/project-init/domain/existing-files.ts +63 -0
- package/src/crews/project-init/domain/package-map.ts +73 -0
- package/src/crews/session-compact/crew.ork.ts +55 -0
- package/src/crews/shared-memory-admit/crew.ork.ts +48 -0
- package/src/crews/speech/application/run-speech.ts +25 -0
- package/src/crews/speech/crew.ork.ts +37 -0
- package/src/shared/application/agents/child-agent.ts +255 -0
- package/src/shared/application/agents/run-sub-agent.ts +96 -0
- package/src/shared/application/answer-language.ts +14 -0
- package/src/shared/application/attached-skills.ts +36 -0
- package/src/shared/application/compaction/compact-session.ts +237 -0
- package/src/shared/application/compaction/extract-memories.ts +38 -0
- package/src/shared/application/compaction/restore-context.ts +78 -0
- package/src/shared/application/config-store.ts +123 -0
- package/src/shared/application/dev/brief-inventory.ts +113 -0
- package/src/shared/application/dev/close-batch.ts +83 -0
- package/src/shared/application/dev/find-repo-pack.ts +77 -0
- package/src/shared/application/dev/learn-decision.ts +252 -0
- package/src/shared/application/dev/load-dev-context.ts +266 -0
- package/src/shared/application/dev/measure-access-cost.ts +68 -0
- package/src/shared/application/dev/plan-source.ts +112 -0
- package/src/shared/application/dev/preflight.ts +71 -0
- package/src/shared/application/dev/project-files.ts +17 -0
- package/src/shared/application/dev/question-round.ts +52 -0
- package/src/shared/application/dev/resolve-work-folder.ts +133 -0
- package/src/shared/application/dev/script-tool-slot.ts +27 -0
- package/src/shared/application/dev/settle-questions.ts +55 -0
- package/src/shared/application/dev/source-review.ts +63 -0
- package/src/shared/application/dev/source-step.ts +150 -0
- package/src/shared/application/dev/spend.ts +42 -0
- package/src/shared/application/dev/step-precedents.ts +89 -0
- package/src/shared/application/dev/tool-call-policy.ts +89 -0
- package/src/shared/application/dev/tool-callbacks.ts +215 -0
- package/src/shared/application/dev/tool-trace-recorder.ts +45 -0
- package/src/shared/application/dev/verdict-sources.ts +48 -0
- package/src/shared/application/dev/wrapped-tools.ts +145 -0
- package/src/shared/application/extra-tools.ts +70 -0
- package/src/shared/application/git/batch-worktree.ts +97 -0
- package/src/shared/application/git/commit-files.ts +186 -0
- package/src/shared/application/git/merge-batch.ts +63 -0
- package/src/shared/application/git/open-pull-request.ts +51 -0
- package/src/shared/application/instructions-file.ts +19 -0
- package/src/shared/application/json-file.ts +34 -0
- package/src/shared/application/llm-profile.ts +35 -0
- package/src/shared/application/permission-rules.ts +159 -0
- package/src/shared/application/ports/approvals.ts +20 -0
- package/src/shared/application/ports/clock.ts +5 -0
- package/src/shared/application/ports/code-index.ts +93 -0
- package/src/shared/application/ports/crew.ts +60 -0
- package/src/shared/application/ports/files.ts +21 -0
- package/src/shared/application/ports/human.ts +13 -0
- package/src/shared/application/ports/llm.ts +54 -0
- package/src/shared/application/ports/memory.ts +30 -0
- package/src/shared/application/ports/progress.ts +23 -0
- package/src/shared/application/ports/runtime.ts +15 -0
- package/src/shared/application/ports/session.ts +74 -0
- package/src/shared/application/ports/shared-memory.ts +26 -0
- package/src/shared/application/ports/shell.ts +40 -0
- package/src/shared/application/ports/telemetry.ts +45 -0
- package/src/shared/application/ports/tools.ts +46 -0
- package/src/shared/application/ports/usage.ts +45 -0
- package/src/shared/application/ports.ts +27 -0
- package/src/shared/application/project-manifests.ts +106 -0
- package/src/shared/application/session-io.ts +84 -0
- package/src/shared/application/session-state.ts +36 -0
- package/src/shared/application/shared-memory/admit-entries.ts +177 -0
- package/src/shared/application/shared-memory/harvest-after-gaps.ts +72 -0
- package/src/shared/application/shared-memory/harvest-mistakes.ts +44 -0
- package/src/shared/application/shared-memory/import-agent-memory.ts +117 -0
- package/src/shared/application/shared-memory/memory-files.ts +110 -0
- package/src/shared/application/shared-memory/memory-settings.ts +93 -0
- package/src/shared/application/shared-memory/push-candidate.ts +146 -0
- package/src/shared/application/shared-memory/recall-precedents.ts +69 -0
- package/src/shared/application/state-snapshot.ts +38 -0
- package/src/shared/application/workflow/workflow-state.ts +135 -0
- package/src/shared/domain/agent-policy/behavior-flags.ts +168 -0
- package/src/shared/domain/agent-policy/extra-tools.ts +69 -0
- package/src/shared/domain/agent-policy/memory-categories.ts +6 -0
- package/src/shared/domain/agent-policy/mode-policy.ts +51 -0
- package/src/shared/domain/agent-policy/output-styles.ts +11 -0
- package/src/shared/domain/agent-policy/permission.ts +623 -0
- package/src/shared/domain/agent-policy/rule-sets.ts +412 -0
- package/src/shared/domain/agent-policy/tool-access.ts +77 -0
- package/src/shared/domain/agent-registry.ts +142 -0
- package/src/shared/domain/agents/built-in-charters.ts +43 -0
- package/src/shared/domain/agents/chain.ts +30 -0
- package/src/shared/domain/agents/charter.ts +61 -0
- package/src/shared/domain/agents/exclusive.ts +24 -0
- package/src/shared/domain/agents/instances.ts +249 -0
- package/src/shared/domain/code-intel-contract.ts +356 -0
- package/src/shared/domain/code-intel-routing.ts +113 -0
- package/src/shared/domain/compact-outcome.ts +44 -0
- package/src/shared/domain/compaction-thresholds.ts +161 -0
- package/src/shared/domain/compaction.ts +379 -0
- package/src/shared/domain/config-schema.ts +421 -0
- package/src/shared/domain/dev/access-cost.ts +226 -0
- package/src/shared/domain/dev/artefacts.ts +50 -0
- package/src/shared/domain/dev/batches-concurrency.ts +36 -0
- package/src/shared/domain/dev/batches-state.ts +49 -0
- package/src/shared/domain/dev/build-commands.ts +44 -0
- package/src/shared/domain/dev/call-guard.ts +341 -0
- package/src/shared/domain/dev/carried-text.ts +49 -0
- package/src/shared/domain/dev/design-rules.ts +100 -0
- package/src/shared/domain/dev/learn-proposals.ts +175 -0
- package/src/shared/domain/dev/learn-state.ts +93 -0
- package/src/shared/domain/dev/path-args.ts +42 -0
- package/src/shared/domain/dev/path-rebase.ts +93 -0
- package/src/shared/domain/dev/plan-checks.ts +190 -0
- package/src/shared/domain/dev/plan-format.ts +180 -0
- package/src/shared/domain/dev/project-files.ts +43 -0
- package/src/shared/domain/dev/questions.ts +249 -0
- package/src/shared/domain/dev/reading-rule.ts +41 -0
- package/src/shared/domain/dev/repo-pack.ts +237 -0
- package/src/shared/domain/dev/review-answer.ts +150 -0
- package/src/shared/domain/dev/review-prompt.ts +221 -0
- package/src/shared/domain/dev/reviewer-charter.ts +31 -0
- package/src/shared/domain/dev/sheet-facts.ts +83 -0
- package/src/shared/domain/dev/spec-format.ts +183 -0
- package/src/shared/domain/dev/step-budget.ts +72 -0
- package/src/shared/domain/dev/step-rules.ts +110 -0
- package/src/shared/domain/dev/test-commands.ts +90 -0
- package/src/shared/domain/dev/test-output.ts +33 -0
- package/src/shared/domain/dev/test-paths.ts +40 -0
- package/src/shared/domain/dev/tool-guards.ts +64 -0
- package/src/shared/domain/dev/trait-pattern.ts +83 -0
- package/src/shared/domain/dev/verdict-format.ts +169 -0
- package/src/shared/domain/dev/whitespace.ts +34 -0
- package/src/shared/domain/dev/work-folder.ts +67 -0
- package/src/shared/domain/dev/yaml-subset.ts +403 -0
- package/src/shared/domain/git/close.ts +273 -0
- package/src/shared/domain/git/pull-request.ts +96 -0
- package/src/shared/domain/git/worktree.ts +46 -0
- package/src/shared/domain/index-languages.ts +16 -0
- package/src/shared/domain/instructions-file.ts +18 -0
- package/src/shared/domain/iso-day.ts +4 -0
- package/src/shared/domain/llm-failure.ts +106 -0
- package/src/shared/domain/llm-profile.ts +25 -0
- package/src/shared/domain/marked-message.ts +33 -0
- package/src/shared/domain/model-catalog.ts +86 -0
- package/src/shared/domain/permission-modes.ts +103 -0
- package/src/shared/domain/prelude.ts +92 -0
- package/src/shared/domain/project-manifests.ts +83 -0
- package/src/shared/domain/search-routing.ts +85 -0
- package/src/shared/domain/secret-patterns.ts +45 -0
- package/src/shared/domain/session-keys.ts +85 -0
- package/src/shared/domain/session-start.ts +60 -0
- package/src/shared/domain/session-summary.ts +13 -0
- package/src/shared/domain/severity.ts +72 -0
- package/src/shared/domain/sha1.ts +61 -0
- package/src/shared/domain/shared-memory/agent-memory-import.ts +143 -0
- package/src/shared/domain/shared-memory/candidates.ts +41 -0
- package/src/shared/domain/shared-memory/entry.ts +145 -0
- package/src/shared/domain/shared-memory/front-matter.ts +183 -0
- package/src/shared/domain/shared-memory/gate.ts +44 -0
- package/src/shared/domain/shared-memory/harvest.ts +61 -0
- package/src/shared/domain/shared-memory/layout.ts +187 -0
- package/src/shared/domain/shared-memory/precedents-block.ts +93 -0
- package/src/shared/domain/shared-memory/refused.ts +84 -0
- package/src/shared/domain/shared-memory/verdict-rows.ts +134 -0
- package/src/shared/domain/snip-turns.ts +45 -0
- package/src/shared/domain/speech.ts +20 -0
- package/src/shared/domain/strip.ts +88 -0
- package/src/shared/domain/tool-trace.ts +122 -0
- package/src/shared/domain/types.ts +67 -0
- package/src/shared/domain/verifiers.ts +37 -0
- package/src/shared/domain/vfs.ts +9 -0
- package/src/shared/domain/workflow/state-file.ts +140 -0
- package/src/shared/infrastructure/globals.ts +52 -0
- package/src/shared/infrastructure/orkeon/approvals.ts +24 -0
- package/src/shared/infrastructure/orkeon/child-agents.ts +127 -0
- package/src/shared/infrastructure/orkeon/code-index.ts +120 -0
- package/src/shared/infrastructure/orkeon/crew-host.ts +27 -0
- package/src/shared/infrastructure/orkeon/crew-memory.ts +12 -0
- package/src/shared/infrastructure/orkeon/dev-deps.ts +172 -0
- package/src/shared/infrastructure/orkeon/files.ts +40 -0
- package/src/shared/infrastructure/orkeon/github-pull-requests.ts +29 -0
- package/src/shared/infrastructure/orkeon/host-provider.ts +22 -0
- package/src/shared/infrastructure/orkeon/human-input.ts +59 -0
- package/src/shared/infrastructure/orkeon/llm-profile.ts +38 -0
- package/src/shared/infrastructure/orkeon/llm.ts +109 -0
- package/src/shared/infrastructure/orkeon/memory-store.ts +41 -0
- package/src/shared/infrastructure/orkeon/memory-tools.ts +131 -0
- package/src/shared/infrastructure/orkeon/permission-rules.ts +42 -0
- package/src/shared/infrastructure/orkeon/progress.ts +24 -0
- package/src/shared/infrastructure/orkeon/run-state.ts +17 -0
- package/src/shared/infrastructure/orkeon/runtime-info.ts +30 -0
- package/src/shared/infrastructure/orkeon/runtime-tools.ts +60 -0
- package/src/shared/infrastructure/orkeon/script-tools.ts +134 -0
- package/src/shared/infrastructure/orkeon/session-store.ts +138 -0
- package/src/shared/infrastructure/orkeon/session-switch.ts +23 -0
- package/src/shared/infrastructure/orkeon/shared-memory.ts +61 -0
- package/src/shared/infrastructure/orkeon/shell-jobs.ts +75 -0
- package/src/shared/infrastructure/orkeon/shell.ts +31 -0
- package/src/shared/infrastructure/orkeon/telemetry.ts +63 -0
- package/src/shared/infrastructure/orkeon/tool-catalogue.ts +75 -0
- package/src/shared/infrastructure/orkeon/tool-results.ts +120 -0
- package/src/shared/infrastructure/orkeon/usage.ts +74 -0
- package/src/shared/infrastructure/orkeon/wiring.ts +118 -0
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
// The change brief's use case (/dev-spec with a kind, or its alias /dev-change): checks the inputs and the checkout,
|
|
2
|
+
// finds the code's folder (a spec there refuses: one source per code), reads the origin whole, runs the reproduction of a bug or the measurement of a perf change
|
|
3
|
+
// before anything else is written (a bug that does not fail stops), inventories the code by the index, asks the
|
|
4
|
+
// model for the brief as JSON (once more on a refused answer; a new brief the model routes as a feature goes on as
|
|
5
|
+
// a spec in the same run, runDevSpec over the same ports),
|
|
6
|
+
// renders, self-checks and writes CHANGE-<code>.md, then asks its open questions through human_input - each answer
|
|
7
|
+
// written before the next question - folds them in, and has the read-only reviewer question the brief once. With
|
|
8
|
+
// nobody to answer, the questions stay in the file and the run ends BLOCKED. An existing brief is revised.
|
|
9
|
+
import type { CodeIndex, Files, HumanInput, Llm, Logger, Shell } from "../../../shared/application/ports.ts";
|
|
10
|
+
import { stepRules } from "../../../shared/domain/dev/step-rules.ts";
|
|
11
|
+
import { shellRuleGuard } from "../../../shared/domain/dev/tool-guards.ts";
|
|
12
|
+
import type { ConfigStore } from "../../../shared/application/config-store.ts";
|
|
13
|
+
import { loadDevContext } from "../../../shared/application/dev/load-dev-context.ts";
|
|
14
|
+
import { briefInventory, briefInventoryLine, briefPhrases, renderBriefInventory } from "../../../shared/application/dev/brief-inventory.ts";
|
|
15
|
+
import type { BriefInventory } from "../../../shared/application/dev/brief-inventory.ts";
|
|
16
|
+
import { questionRound } from "../../../shared/application/dev/question-round.ts";
|
|
17
|
+
import type { Folded, RoundState } from "../../../shared/application/dev/question-round.ts";
|
|
18
|
+
import { reviewLine, reviewSource } from "../../../shared/application/dev/source-review.ts";
|
|
19
|
+
import type { SourceReviewOutcome } from "../../../shared/application/dev/source-review.ts";
|
|
20
|
+
import {
|
|
21
|
+
codeFolder, dateOf, firstLine, inputCode, inputText, openLine, plural, problemLines, sourceSelfCheck,
|
|
22
|
+
SourceWriteFailure, sourceWriter, toplevelRefusal, warningLines,
|
|
23
|
+
} from "../../../shared/application/dev/source-step.ts";
|
|
24
|
+
import { numberQuestions, parseDecisions, parseOpenQuestions } from "../../../shared/domain/dev/questions.ts";
|
|
25
|
+
import type { Decision, Question } from "../../../shared/domain/dev/questions.ts";
|
|
26
|
+
import { parsePlanSource } from "../../../shared/domain/dev/spec-format.ts";
|
|
27
|
+
import type { ChangeKind } from "../../../shared/domain/dev/spec-format.ts";
|
|
28
|
+
import { CHANGE_ANSWER_SCHEMA, checkChangeAnswer, criterionId, pinOnlyKnown } from "../domain/change-answer.ts";
|
|
29
|
+
import {
|
|
30
|
+
CHANGE_DECISIONS_SECTION, CHANGE_QUESTIONS_SECTION, EVIDENCE_HEADING, ORIGIN_HEADING, changeFileName, originLines,
|
|
31
|
+
renderChange, reproFileName, sectionBody,
|
|
32
|
+
} from "../domain/change-render.ts";
|
|
33
|
+
import { noPrecedents, precedentsLine, recallQuery } from "../../../shared/application/dev/step-precedents.ts";
|
|
34
|
+
import type { StepPrecedents } from "../../../shared/application/dev/step-precedents.ts";
|
|
35
|
+
import { runDevSpec } from "../../dev-spec/application/run-dev-spec.ts";
|
|
36
|
+
import { buildChangePrompt } from "./change-prompt.ts";
|
|
37
|
+
import type { ChangePromptInput } from "./change-prompt.ts";
|
|
38
|
+
import { factLines, pickCommand, readOrigin, reproFile, runEvidence, runStop } from "./evidence.ts";
|
|
39
|
+
|
|
40
|
+
export interface DevChangeInputs { code?: unknown; kind?: unknown; run?: unknown; text?: unknown }
|
|
41
|
+
export interface DevChangeDeps {
|
|
42
|
+
files: Files; shell: Pick<Shell, "run">; config: Pick<ConfigStore, "readValue">; index: CodeIndex;
|
|
43
|
+
llm: Pick<Llm, "extract" | "act" | "permissionGateEnabled">; human: HumanInput; log: Logger; clock: () => Date;
|
|
44
|
+
/** The shared memory's code-triggered recall (T1); absent, nothing is recalled. */
|
|
45
|
+
precedents?: StepPrecedents;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const STEP = "dev-change";
|
|
49
|
+
const KINDS: readonly ChangeKind[] = ["bug", "refactor", "perf"];
|
|
50
|
+
const HEADINGS = { questions: CHANGE_QUESTIONS_SECTION, decisions: CHANGE_DECISIONS_SECTION };
|
|
51
|
+
export const DEV_CHANGE_NEXT = "→ Next step, once you have validated the brief: /dev-plan {code}";
|
|
52
|
+
export const FEATURE_LINE = "→ a feature, not a change: the spec SPEC-{code}.md follows";
|
|
53
|
+
|
|
54
|
+
type Drafted = { feature: true } | { feature: false; text: string; open: Question[]; unknown: string[] };
|
|
55
|
+
|
|
56
|
+
/** The last segment of a qualified name (`AccountTests.loads` → `loads`, `a/b.ts::loads` → `loads`), or a path's
|
|
57
|
+
* file name whole (`tests/a.test.ts` → `a.test.ts`). */
|
|
58
|
+
function lastSegment(name: string): string {
|
|
59
|
+
const tail = name.split(/::|#/).filter((s) => s !== "").pop() ?? name;
|
|
60
|
+
const parts = /[/\\]/.test(tail) ? tail.split(/[/\\]/) : tail.split(".");
|
|
61
|
+
return parts.filter((s) => s !== "").pop() ?? tail;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** What qualifies the last segment of a name: the pieces before it (`a/b.ts::C::m` → `a/b.ts`, `C`; `N.C.m` → `N.C`).
|
|
65
|
+
* `null` for a name that is a path (its last segment is its file name, nothing qualifies it). */
|
|
66
|
+
function qualifiers(name: string): string[] | null {
|
|
67
|
+
const pieces = name.split(/::|#/).filter((s) => s !== "");
|
|
68
|
+
const tail = pieces.pop() ?? name;
|
|
69
|
+
if (/[/\\]/.test(tail)) return null;
|
|
70
|
+
const dots = tail.split(".").filter((s) => s !== "");
|
|
71
|
+
dots.pop();
|
|
72
|
+
return dots.length > 0 ? [...pieces, dots.join(".")] : pieces;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** True when one qualifier names the entry's file: its path (`tests/a.test.ts`, or its end), or a dotted part equal to
|
|
76
|
+
* the file's stem (`Bank.AccountTests` for `tests/AccountTests.cs`, `tests.test_a.TestA` for `tests/test_a.py`). */
|
|
77
|
+
function qualifiesFile(quals: readonly string[], path: string): boolean {
|
|
78
|
+
const base = path.slice(path.lastIndexOf("/") + 1);
|
|
79
|
+
const stem = base.split(".")[0];
|
|
80
|
+
return quals.some((q) => /[/\\]/.test(q)
|
|
81
|
+
? path === q.replace(/\\/g, "/") || path.endsWith(`/${q.replace(/\\/g, "/")}`)
|
|
82
|
+
: q.split(".").includes(stem));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* True when the inventory shows a test of that name: an entry named so, a file of that path or name, or - for a
|
|
87
|
+
* qualified name - an entry named by its last segment in a file its qualifier names (`AccountTests.loads` is known from
|
|
88
|
+
* `tests/AccountTests.cs`, never from a `loads` another class's file holds). Never a part of a name: `Account` does not
|
|
89
|
+
* show `AccountTests.never_written`.
|
|
90
|
+
*/
|
|
91
|
+
export const knownIn = (inventory: Pick<BriefInventory, "entries">) => (name: string): boolean => {
|
|
92
|
+
const segment = lastSegment(name);
|
|
93
|
+
const quals = qualifiers(name);
|
|
94
|
+
return inventory.entries.some((e) =>
|
|
95
|
+
e.name === name || name === e.path || name === e.path.slice(e.path.lastIndexOf("/") + 1)
|
|
96
|
+
|| (segment !== name && e.name === segment && (quals === null || qualifiesFile(quals, e.path))));
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export async function runDevChange(input: DevChangeInputs, deps: DevChangeDeps): Promise<string> {
|
|
100
|
+
// 1. Inputs and checkout.
|
|
101
|
+
const code = inputCode(STEP, input.code);
|
|
102
|
+
if (typeof code !== "string") return code.refused;
|
|
103
|
+
const kindIn = inputText(STEP, "kind", input.kind);
|
|
104
|
+
if (typeof kindIn !== "string" || (kindIn !== "" && !KINDS.includes(kindIn as ChangeKind))) return `${STEP}: invalid crew input: kind`;
|
|
105
|
+
const given = inputText(STEP, "run", input.run);
|
|
106
|
+
if (typeof given !== "string") return given.refused;
|
|
107
|
+
const typed = inputText(STEP, "text", input.text);
|
|
108
|
+
if (typeof typed !== "string") return typed.refused;
|
|
109
|
+
const top = await toplevelRefusal(STEP, deps.shell);
|
|
110
|
+
if (top !== null) return top;
|
|
111
|
+
const ctx = await loadDevContext(deps);
|
|
112
|
+
const folder = await codeFolder(STEP, deps.files, ctx.work, code);
|
|
113
|
+
if ("refused" in folder) return folder.refused;
|
|
114
|
+
|
|
115
|
+
// 2. One source per code; an existing brief is revised, its kind kept.
|
|
116
|
+
if (folder.names.includes(`SPEC-${code}.md`)) {
|
|
117
|
+
return `${STEP}: ${folder.shown}/SPEC-${code}.md exists: a code has one source; revise it with /dev-spec ${code} (no kind), or pick another code`;
|
|
118
|
+
}
|
|
119
|
+
const brief = folder.file(changeFileName(code));
|
|
120
|
+
let existing: string | null = null;
|
|
121
|
+
if (folder.names.includes(changeFileName(code))) {
|
|
122
|
+
try {
|
|
123
|
+
existing = await deps.files.read(brief.vfs);
|
|
124
|
+
} catch (e) {
|
|
125
|
+
return `${STEP}: ${brief.shown} cannot be read (${firstLine(e)}); nothing is written`;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
const fileKind = existing === null ? undefined : parsePlanSource(existing, "change").changeKind;
|
|
129
|
+
if (existing !== null && fileKind === undefined) return `${STEP}: ${brief.shown}: the title names no kind (bug, refactor or perf); fix the title first`;
|
|
130
|
+
if (fileKind !== undefined && kindIn !== "" && kindIn !== fileKind) {
|
|
131
|
+
return `${STEP}: ${brief.shown} is a ${fileKind} change: a brief keeps its kind; pick another code for a ${kindIn}`;
|
|
132
|
+
}
|
|
133
|
+
const kind = (fileKind ?? kindIn) as ChangeKind | "";
|
|
134
|
+
if (kind === "") return `${STEP}: name the kind: /dev-spec ${code} bug|refactor|perf [--run "<command>"] <origin>`;
|
|
135
|
+
if (given !== "" && kind === "refactor") return `${STEP}: --run is for a bug or a perf change; a refactor is pinned by its tests`;
|
|
136
|
+
|
|
137
|
+
// 3. The origin (a new brief) or the request (a revision).
|
|
138
|
+
let originText = "";
|
|
139
|
+
let originFrom = "";
|
|
140
|
+
let request = "";
|
|
141
|
+
if (existing === null) {
|
|
142
|
+
if (typed === "") return `${STEP}: a new brief needs its origin: /dev-spec ${code} ${kind} <#issue | path | text>`;
|
|
143
|
+
const origin = await readOrigin(STEP, deps, typed);
|
|
144
|
+
if ("refused" in origin) return origin.refused;
|
|
145
|
+
originText = origin.text;
|
|
146
|
+
originFrom = origin.from;
|
|
147
|
+
} else {
|
|
148
|
+
request = typed;
|
|
149
|
+
originText = sectionBody(existing, ORIGIN_HEADING).map((l) => l.replace(/^> ?/, "")).join("\n");
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// 4. Evidence by running, before anything else is written.
|
|
153
|
+
const today = dateOf(deps.clock());
|
|
154
|
+
const commands = ctx.pack?.pack.commands ?? {};
|
|
155
|
+
let facts: string[] = existing === null ? [] : sectionBody(existing, EVIDENCE_HEADING).filter((l) => !l.startsWith("- **Suspected cause**"));
|
|
156
|
+
let ran: { command: string; seconds: number } | null = null;
|
|
157
|
+
if (kind !== "refactor" && (existing === null || given !== "")) {
|
|
158
|
+
const picked = await pickCommand(STEP, deps.llm, kind, given, originText, commands);
|
|
159
|
+
if ("refused" in picked) return picked.refused;
|
|
160
|
+
const denied = shellRuleGuard(stepRules("dev-change"))(picked.command);
|
|
161
|
+
if (denied !== null) return `${STEP}: ${denied}; nothing is written`;
|
|
162
|
+
const result = await runEvidence(deps.shell, picked.command, deps.clock);
|
|
163
|
+
const repro = folder.file(reproFileName(code));
|
|
164
|
+
try {
|
|
165
|
+
await deps.files.write(repro.vfs, reproFile(result, today));
|
|
166
|
+
} catch (e) {
|
|
167
|
+
return `${STEP}: ${repro.shown} could not be written (${firstLine(e)}); nothing else is written`;
|
|
168
|
+
}
|
|
169
|
+
const stop = runStop(STEP, kind, result, repro.shown);
|
|
170
|
+
if (stop !== null) return stop;
|
|
171
|
+
facts = factLines(kind, result, reproFileName(code));
|
|
172
|
+
ran = { command: result.command, seconds: result.seconds };
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// 5. Inventory by code.
|
|
176
|
+
const inventory = await briefInventory(deps.index, {
|
|
177
|
+
phrases: briefPhrases(code, `${originText}\n${request}`),
|
|
178
|
+
excluded: [ctx.work.folder, ...(ctx.pack?.pack.layout.buildOutputs ?? [])],
|
|
179
|
+
});
|
|
180
|
+
const inventoryText = renderBriefInventory(inventory);
|
|
181
|
+
const warnings = [...ctx.warnings, ...inventory.warnings];
|
|
182
|
+
const origin = existing === null ? originLines(originText, originFrom) : sectionBody(existing, ORIGIN_HEADING);
|
|
183
|
+
// T1: the decisions and methods of earlier work on the same topic, before the draft; the same block in every ask.
|
|
184
|
+
const recalled = await (deps.precedents ?? noPrecedents)("T1", recallQuery([code, kind, originText, request]));
|
|
185
|
+
|
|
186
|
+
// 6. Draft: checked, the unknown pins made unpinned, rendered, read back.
|
|
187
|
+
const ask = async (prompt: ChangePromptInput, open: (q: ReturnType<typeof checkChangeAnswer>) => Question[], decisions: readonly Decision[]):
|
|
188
|
+
Promise<{ ok: true; drafted: Drafted } | { ok: false; problems: string[] }> => {
|
|
189
|
+
let problems: string[] = [];
|
|
190
|
+
for (let attempt = 1; attempt <= 2; attempt++) {
|
|
191
|
+
let value: unknown;
|
|
192
|
+
try {
|
|
193
|
+
value = await deps.llm.extract(buildChangePrompt(prompt, problems), CHANGE_ANSWER_SCHEMA);
|
|
194
|
+
} catch (e) {
|
|
195
|
+
problems = [`the answer did not parse: ${firstLine(e)}`];
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
const checked = checkChangeAnswer(value, kind);
|
|
199
|
+
if (!checked.ok) { problems = checked.problems; continue; }
|
|
200
|
+
if (checked.value.route === "feature") return { ok: true, drafted: { feature: true } };
|
|
201
|
+
const pinned = pinOnlyKnown(checked.value, knownIn(inventory));
|
|
202
|
+
const questions = open(checked);
|
|
203
|
+
const text = renderChange({ code, kind, answer: pinned.answer, origin, facts, open: questions, decisions });
|
|
204
|
+
const ids = pinned.answer.criteria.map((_, i) => criterionId(i));
|
|
205
|
+
const self = sourceSelfCheck(text, "change", { code, ids, open: questions, decisions });
|
|
206
|
+
if (self.length > 0) {
|
|
207
|
+
deps.log.warn(`${STEP}: a checked answer rendered a brief that fails its self-check (a renderer defect): ${self[0]}`);
|
|
208
|
+
problems = self;
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
return { ok: true, drafted: { feature: false, text, open: questions, unknown: pinned.unknown } };
|
|
212
|
+
}
|
|
213
|
+
return { ok: false, problems };
|
|
214
|
+
};
|
|
215
|
+
const questionsOf = (decisions: readonly Decision[], kept: readonly Question[]) =>
|
|
216
|
+
(c: ReturnType<typeof checkChangeAnswer>): Question[] => (c.ok ? numberQuestions(c.value.questions, decisions, kept) : [...kept]);
|
|
217
|
+
|
|
218
|
+
const write = sourceWriter(deps.files, brief.vfs);
|
|
219
|
+
const decisions0 = existing === null ? [] : parseDecisions(existing);
|
|
220
|
+
const open0 = existing === null ? [] : parseOpenQuestions(existing, decisions0.map((d) => d.id));
|
|
221
|
+
const factsText = facts.join("\n");
|
|
222
|
+
|
|
223
|
+
let state: RoundState;
|
|
224
|
+
let verb: string;
|
|
225
|
+
try {
|
|
226
|
+
if (existing !== null && request === "" && ran === null) {
|
|
227
|
+
state = { text: existing, open: open0, decisions: decisions0 };
|
|
228
|
+
verb = "read";
|
|
229
|
+
} else {
|
|
230
|
+
const asked = await ask({
|
|
231
|
+
mode: existing === null ? "draft" : "revision", code, kind, origin: originText, facts: factsText, request,
|
|
232
|
+
current: existing ?? "", decisions: decisions0, fresh: [], inventory: inventoryText, precedents: recalled.block,
|
|
233
|
+
}, questionsOf(decisions0, open0), decisions0);
|
|
234
|
+
if (!asked.ok) return [`${STEP}: the brief was refused twice; nothing is written.`, ...problemLines(asked.problems)].join("\n");
|
|
235
|
+
if (asked.drafted.feature) {
|
|
236
|
+
// A new brief goes on as a spec in the same run, over the same ports; a brief that exists keeps its code.
|
|
237
|
+
if (existing !== null) {
|
|
238
|
+
return `${STEP}: the request is a new promise, not a change of what exists; ${brief.shown} is kept: a feature takes a code of its own (/dev-spec <code> <brief>)`;
|
|
239
|
+
}
|
|
240
|
+
return [FEATURE_LINE.replace("{code}", code), await runDevSpec({ code, request: originText }, deps)].join("\n");
|
|
241
|
+
}
|
|
242
|
+
warnings.push(...asked.drafted.unknown.map((n) => `'${n}' is no test the code index shows: its row reads unpinned`));
|
|
243
|
+
state = { text: asked.drafted.text, open: asked.drafted.open, decisions: decisions0 };
|
|
244
|
+
await write(state.text);
|
|
245
|
+
verb = existing === null ? "written" : "revised";
|
|
246
|
+
deps.log.info(`${STEP}: ${brief.shown} ${verb}`);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// 7. Questions, fold, review - as /dev-spec.
|
|
250
|
+
const fold = async (st: RoundState, fresh: readonly Decision[]): Promise<Folded> => {
|
|
251
|
+
const r = await ask({
|
|
252
|
+
mode: "fold", code, kind, origin: originText, facts: factsText, request: "", current: st.text,
|
|
253
|
+
decisions: st.decisions, fresh, inventory: inventoryText, precedents: recalled.block,
|
|
254
|
+
}, questionsOf(st.decisions, st.open), st.decisions);
|
|
255
|
+
if (!r.ok) return { ok: false, problems: r.problems };
|
|
256
|
+
if (r.drafted.feature) return { ok: false, problems: ["the rewrite routed the brief to a spec"] };
|
|
257
|
+
return { ok: true, text: r.drafted.text, open: r.drafted.open };
|
|
258
|
+
};
|
|
259
|
+
const round = { human: deps.human, today, label: `${STEP} ${code}`, headings: HEADINGS, write, fold };
|
|
260
|
+
const first = await questionRound(state, round);
|
|
261
|
+
state = first.state;
|
|
262
|
+
warnings.push(...first.warnings);
|
|
263
|
+
const made = [...first.made];
|
|
264
|
+
let blocked = first.blocked;
|
|
265
|
+
let review: SourceReviewOutcome | null = null;
|
|
266
|
+
if (!blocked) {
|
|
267
|
+
const ids = parsePlanSource(state.text, "change").ids.map((i) => i.id);
|
|
268
|
+
review = await reviewSource(deps.llm, state, {
|
|
269
|
+
mode: "change", whole: "brief", folder: folder.shown, fileShown: brief.shown, origin: originFrom,
|
|
270
|
+
inventory: inventoryText, ids, headings: HEADINGS,
|
|
271
|
+
}, write);
|
|
272
|
+
if (deps.llm.permissionGateEnabled() === false) warnings.push("the host's permission gate is off; the reviewer was offered read tools only");
|
|
273
|
+
if (review.ran && review.added.length > 0) {
|
|
274
|
+
state = review.state;
|
|
275
|
+
const added = new Set(review.added);
|
|
276
|
+
const second = await questionRound(state, round, (q) => added.has(q.id) && q.severity === "Blocking");
|
|
277
|
+
state = second.state;
|
|
278
|
+
warnings.push(...second.warnings);
|
|
279
|
+
made.push(...second.made);
|
|
280
|
+
blocked = second.blocked;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// 8. The end message.
|
|
285
|
+
const parsed = parsePlanSource(state.text, "change");
|
|
286
|
+
const ids = parsed.ids.map((i) => i.id);
|
|
287
|
+
const unpinned = parsed.mustNotChange.filter((r) => r.pinnedBy === null).length;
|
|
288
|
+
const lines = [
|
|
289
|
+
`${STEP}: ${brief.shown} ${verb} — ${kind}, ${plural(ids.length, "criterion", "criteria")} (${ids.join(", ") || "none"})`,
|
|
290
|
+
...(ran === null ? [] : [`evidence: \`${ran.command}\` (${ran.seconds} s), output in ${folder.shown}/${reproFileName(code)}`]),
|
|
291
|
+
`must not change: ${plural(parsed.mustNotChange.length, "row", "rows")}, ${unpinned} unpinned`,
|
|
292
|
+
`decisions this run: ${made.length === 0 ? "none" : made.map((d) => `${d.id} → ${d.answer}`).join("; ")}`,
|
|
293
|
+
`open questions: ${openLine(state.open)}`,
|
|
294
|
+
...(review === null ? [] : [reviewLine(review)]),
|
|
295
|
+
briefInventoryLine(inventory),
|
|
296
|
+
...[precedentsLine([recalled])].filter((l) => l !== ""),
|
|
297
|
+
...warningLines(warnings),
|
|
298
|
+
];
|
|
299
|
+
const blockingLeft = state.open.filter((q) => q.severity === "Blocking");
|
|
300
|
+
if (blocked) {
|
|
301
|
+
lines.push(
|
|
302
|
+
`${STEP}: BLOCKED — a question went unanswered; the open questions are in ${brief.shown} § 8.`,
|
|
303
|
+
`→ Answer them: /dev-spec ${code} ${kind} in an interactive session, or edit the file; nothing was decided for you.`,
|
|
304
|
+
);
|
|
305
|
+
} else if (blockingLeft.length > 0) {
|
|
306
|
+
lines.push(`→ ${blockingLeft.map((q) => q.id).join(", ")} still Blocking: /dev-plan refuses the brief until settled: /dev-spec ${code} ${kind}, or edit the file.`);
|
|
307
|
+
} else {
|
|
308
|
+
lines.push(DEV_CHANGE_NEXT.replace("{code}", code));
|
|
309
|
+
}
|
|
310
|
+
return lines.join("\n");
|
|
311
|
+
} catch (e) {
|
|
312
|
+
if (!(e instanceof SourceWriteFailure)) throw e;
|
|
313
|
+
return `${STEP}: ${brief.shown} could not be written (${e.message}); the answers given so far are in the file when it was written before`;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// @orkeon-script 1.0
|
|
2
|
+
/// <reference path="../.orkeon/orkeon.d.ts" />
|
|
3
|
+
//
|
|
4
|
+
// DevChange crew (/dev-spec with a kind; its alias /dev-change). Composition root: it builds one agent from the
|
|
5
|
+
// reviewer's charter (read tools only) and wires application/run-dev-change, which reads the origin whole (an issue
|
|
6
|
+
// by gh, a file, the text), runs the reproduction of a bug or the measurement of a perf change before anything else (a bug that does not fail stops),
|
|
7
|
+
// inventories the code by the index, asks the model for the brief as JSON, writes <work>/<code>/CHANGE-<code>.md,
|
|
8
|
+
// asks its open questions one at a time through human_input (each answer written before the next question), folds
|
|
9
|
+
// the answers in, then has the read-only reviewer question the brief once. Unattended: BLOCKED, questions in the file.
|
|
10
|
+
// A new brief the model routes as a feature goes on as a spec in the same run (runDevSpec, over the same ports).
|
|
11
|
+
// The reviewer's act runs in a background child, `dev-reviewer` (its charter: read tools only, plan mode), which
|
|
12
|
+
// /tasks lists and stops while it runs, as /dev-plan's (A-3, approach A2); on a host without background children
|
|
13
|
+
// it runs inline.
|
|
14
|
+
//
|
|
15
|
+
// Input (globalThis.inputs): { code: string, kind?: "bug" | "refactor" | "perf", run?: string (the command to run),
|
|
16
|
+
// text?: string (the origin of a new brief, or a revision request), hooks?: /hooks,
|
|
17
|
+
// effort?: "low" | "medium" | "high" | "xhigh" | "max" | null, memoryRecall?: false (a session rule denies it),
|
|
18
|
+
// concurrency?: number, maxInstances?: number }
|
|
19
|
+
// Run standalone: orkeon run src/crews/dev-change/crew.ork.ts --inputs '{"code":"cache","kind":"refactor","text":"…"}'
|
|
20
|
+
//
|
|
21
|
+
// Budget (STEP_BUDGETS["dev-change"]): one gh call, one run of at most 600 s, about 50 index calls, about 20 file
|
|
22
|
+
// and git calls, at most nine extract calls and one review of 20 iterations: well under 200 tool calls. The
|
|
23
|
+
// reviewer runs as a child (delegationDepth 1): the runtime gives it what the parent has left at its spawn, so its
|
|
24
|
+
// 60 calls are an estimate, not a cap. The wall time counts the run and the person's answers: one hour. A feature
|
|
25
|
+
// routed at the first draft goes on as a spec within the same budget: by then the change spent its inventory and one
|
|
26
|
+
// extract call, at most one run.
|
|
27
|
+
|
|
28
|
+
import { CrewBuilder, publishCrew, inputs, ToolBuilder } from "../../shared/infrastructure/globals.ts";
|
|
29
|
+
import {
|
|
30
|
+
orkeonAgent,
|
|
31
|
+
orkeonClock,
|
|
32
|
+
orkeonCodeIndex,
|
|
33
|
+
orkeonConfigStore,
|
|
34
|
+
orkeonFiles,
|
|
35
|
+
orkeonHumanInput,
|
|
36
|
+
orkeonMemoryToolPorts,
|
|
37
|
+
orkeonSessionIo,
|
|
38
|
+
orkeonSharedMemory,
|
|
39
|
+
orkeonShell,
|
|
40
|
+
} from "../../shared/infrastructure/orkeon/wiring.ts";
|
|
41
|
+
import { memoryReadTools, memoryRecallOn, memoryRecallTools } from "../../shared/infrastructure/orkeon/memory-tools.ts";
|
|
42
|
+
import { createLlm } from "../../shared/infrastructure/orkeon/llm.ts";
|
|
43
|
+
import { providerEffort } from "../../shared/domain/agent-policy/behavior-flags.ts";
|
|
44
|
+
import { memoryDirOf } from "../../shared/application/shared-memory/memory-settings.ts";
|
|
45
|
+
import { devToolCallbacks } from "../../shared/application/dev/tool-callbacks.ts";
|
|
46
|
+
import { childAgentBody, openChildAct } from "../../shared/infrastructure/orkeon/child-agents.ts";
|
|
47
|
+
import { charterCatalogue } from "../../shared/domain/agents/charter.ts";
|
|
48
|
+
import { instanceLimits } from "../../shared/domain/agents/instances.ts";
|
|
49
|
+
import { REVIEWER_CHARTER } from "../../shared/domain/dev/reviewer-charter.ts";
|
|
50
|
+
import { STEP_BUDGETS } from "../../shared/domain/dev/step-budget.ts";
|
|
51
|
+
import { stepPrecedents } from "../../shared/application/dev/step-precedents.ts";
|
|
52
|
+
import { runDevChange } from "./application/run-dev-change.ts";
|
|
53
|
+
|
|
54
|
+
const ports = { shell: orkeonShell(), files: orkeonFiles(), config: orkeonConfigStore(), index: orkeonCodeIndex(), human: orkeonHumanInput() };
|
|
55
|
+
// memory_recall is attached unless a session rule denies every call of it (the command says so).
|
|
56
|
+
const memoryOn = memoryRecallOn(inputs());
|
|
57
|
+
const effort = providerEffort(inputs().effort);
|
|
58
|
+
const session = orkeonSessionIo();
|
|
59
|
+
const limits = instanceLimits(inputs());
|
|
60
|
+
// The host's gate first, then these callbacks: the step's rule sets again and the /hooks the command passed.
|
|
61
|
+
const callbacksFor = (ctx: any) => devToolCallbacks(
|
|
62
|
+
{ step: "dev-change", hooks: inputs().hooks, readTools: memoryReadTools(memoryOn) }, { shell: ports.shell, log: ctx.log, memoryDir: memoryDirOf(ports.config) },
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
/** The reviewer, added to the crew by its first act (a sequential crew would run an agent it holds from the start). */
|
|
66
|
+
const reviewer = () => {
|
|
67
|
+
const builder = orkeonAgent()
|
|
68
|
+
.name(REVIEWER_CHARTER.name)
|
|
69
|
+
.role(REVIEWER_CHARTER.role)
|
|
70
|
+
.goal(REVIEWER_CHARTER.goal)
|
|
71
|
+
.tools(charterCatalogue(REVIEWER_CHARTER))
|
|
72
|
+
.withAutonomousTools(memoryRecallTools(ToolBuilder, orkeonMemoryToolPorts, memoryOn))
|
|
73
|
+
.maxIterations(REVIEWER_CHARTER.maxIterations)
|
|
74
|
+
.body(childAgentBody(callbacksFor));
|
|
75
|
+
return effort === undefined ? builder : builder.effort(effort);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const builder = orkeonAgent()
|
|
79
|
+
.name("dev-change-writer")
|
|
80
|
+
.role("Change analyst")
|
|
81
|
+
.goal("Write what is wrong or costly in code that exists, the evidence that shows it and what must survive, and settle its open questions with the person")
|
|
82
|
+
// The catalogue is the reviewer's: read tools only. The brief itself is an extract call, which offers none.
|
|
83
|
+
.tools(charterCatalogue(REVIEWER_CHARTER))
|
|
84
|
+
.withAutonomousTools(memoryRecallTools(ToolBuilder, orkeonMemoryToolPorts, memoryOn))
|
|
85
|
+
.maxIterations(REVIEWER_CHARTER.maxIterations)
|
|
86
|
+
.body(async (_input: any, ctx: any) => {
|
|
87
|
+
const clock = orkeonClock();
|
|
88
|
+
const child = openChildAct(
|
|
89
|
+
createLlm(ctx.llm, callbacksFor(ctx), { effort }), ctx, crew, { state: session, clock, log: ctx.log, effort },
|
|
90
|
+
{ crew: "dev-change", step: "dev-change" },
|
|
91
|
+
{ agent: REVIEWER_CHARTER.name, charter: REVIEWER_CHARTER.name, task: "review of the brief", builder: reviewer },
|
|
92
|
+
);
|
|
93
|
+
try {
|
|
94
|
+
// T1: the shared memory's precedents in the draft's prompt, unless memory_recall is denied.
|
|
95
|
+
const precedents = stepPrecedents({ ...ports, memory: orkeonSharedMemory(), log: ctx.log }, { on: memoryOn });
|
|
96
|
+
return await runDevChange(inputs(), { ...ports, llm: child.llm, log: ctx.log, clock, precedents });
|
|
97
|
+
} finally {
|
|
98
|
+
await child.close();
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
const writer = (effort === undefined ? builder : builder.effort(effort)).build();
|
|
102
|
+
|
|
103
|
+
const crew = CrewBuilder()
|
|
104
|
+
.name("dev-change")
|
|
105
|
+
.process("sequential")
|
|
106
|
+
.budget(STEP_BUDGETS["dev-change"])
|
|
107
|
+
.concurrency(limits.concurrency)
|
|
108
|
+
.maxInstances(limits.maxInstances)
|
|
109
|
+
.withAgent(writer)
|
|
110
|
+
.build();
|
|
111
|
+
|
|
112
|
+
publishCrew(crew);
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
// The model's change brief as JSON: the schema it is extracted into, and the check that turns the extraction into
|
|
2
|
+
// a ChangeAnswer or the list of what is wrong with it - the harness's change-template self-check as code: a bug has
|
|
3
|
+
// a criterion, a perf change a criterion with a number, a refactor at least one behaviour that must not change;
|
|
4
|
+
// every criterion is one testable line with its proof; the brief names no design; every cell fits its table.
|
|
5
|
+
// `route: "feature"` says the request is a new promise, for /dev-spec. CH ids are code's, by position. Pure.
|
|
6
|
+
import type { Checked } from "../../../shared/domain/agents/charter.ts";
|
|
7
|
+
import type { ChangeKind } from "../../../shared/domain/dev/spec-format.ts";
|
|
8
|
+
import { MAX_QUESTIONS, QUESTION_SCHEMA, breaksCell, draftQuestionProblems } from "../../../shared/domain/dev/questions.ts";
|
|
9
|
+
import type { DraftQuestion } from "../../../shared/domain/dev/questions.ts";
|
|
10
|
+
|
|
11
|
+
export type CriterionSeverity = "blocking" | "warning";
|
|
12
|
+
export interface ChangeCriterion { name: string; statement: string; proof: string; severity: CriterionSeverity }
|
|
13
|
+
export type ProtectedRow = { behaviour: string; pinnedBy: string };
|
|
14
|
+
export interface ChangeAnswer {
|
|
15
|
+
route: "change" | "feature";
|
|
16
|
+
name: string; summary: string;
|
|
17
|
+
/** Facts the model read (a path:line, a number), one per line; the reproduction itself is code's. */
|
|
18
|
+
evidence: string[];
|
|
19
|
+
/** The suspected cause, a path:line and a sentence; "" when none. */
|
|
20
|
+
suspected: string;
|
|
21
|
+
criteria: ChangeCriterion[];
|
|
22
|
+
mustNotChange: ProtectedRow[];
|
|
23
|
+
scope: Array<{ in: string; out: string }>;
|
|
24
|
+
constraints: string[];
|
|
25
|
+
assumptions: Array<{ assumption: string; validatedBy: string }>;
|
|
26
|
+
questions: DraftQuestion[];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const CRITERION_SEVERITIES: readonly CriterionSeverity[] = ["blocking", "warning"];
|
|
30
|
+
export const MAX_CRITERIA = 12;
|
|
31
|
+
const MAX_NAME_CHARS = 80;
|
|
32
|
+
const MAX_STATEMENT_CHARS = 200;
|
|
33
|
+
const MAX_LIST = 20;
|
|
34
|
+
const DESIGN = /\b(new|create[sd]?|add(s|ed)?|introduce[sd]?)\b[^.;]{0,40}\b(class|type|interface|file|module|library|pattern)\b/i;
|
|
35
|
+
|
|
36
|
+
const str = { type: "string" };
|
|
37
|
+
const strings = { type: "array", items: str };
|
|
38
|
+
const table = (keys: readonly string[]): object => ({
|
|
39
|
+
type: "array",
|
|
40
|
+
items: { type: "object", properties: Object.fromEntries(keys.map((k) => [k, str])), required: [...keys] },
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export const CHANGE_ANSWER_SCHEMA: object = {
|
|
44
|
+
type: "object",
|
|
45
|
+
properties: {
|
|
46
|
+
route: { type: "string", enum: ["change", "feature"] },
|
|
47
|
+
name: str, summary: str, evidence: strings, suspected: str,
|
|
48
|
+
criteria: {
|
|
49
|
+
type: "array",
|
|
50
|
+
items: {
|
|
51
|
+
type: "object",
|
|
52
|
+
properties: { name: str, statement: str, proof: str, severity: { type: "string", enum: [...CRITERION_SEVERITIES] } },
|
|
53
|
+
required: ["name", "statement", "proof", "severity"],
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
mustNotChange: table(["behaviour", "pinnedBy"]),
|
|
57
|
+
scope: table(["in", "out"]),
|
|
58
|
+
constraints: strings,
|
|
59
|
+
assumptions: table(["assumption", "validatedBy"]),
|
|
60
|
+
questions: { type: "array", items: QUESTION_SCHEMA },
|
|
61
|
+
},
|
|
62
|
+
required: ["route", "name", "summary", "evidence", "suspected", "criteria", "mustNotChange", "scope", "constraints", "assumptions", "questions"],
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const isObject = (v: unknown): v is Record<string, unknown> => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
66
|
+
const text = (v: unknown): string => (typeof v === "string" ? v.trim() : "");
|
|
67
|
+
const list = (v: unknown): unknown[] => (Array.isArray(v) ? v : []);
|
|
68
|
+
const textList = (v: unknown): string[] => list(v).map(text).filter((t) => t !== "");
|
|
69
|
+
function rows<K extends string>(v: unknown, keys: readonly K[]): Array<Record<K, string>> {
|
|
70
|
+
return list(v).map((item) => {
|
|
71
|
+
const o = isObject(item) ? item : {};
|
|
72
|
+
return Object.fromEntries(keys.map((k) => [k, text(o[k])])) as Record<K, string>;
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export const criterionId = (k: number): string => `CH-${String(k + 1).padStart(2, "0")}`;
|
|
77
|
+
|
|
78
|
+
function readChangeAnswer(value: unknown): ChangeAnswer {
|
|
79
|
+
const o = isObject(value) ? value : {};
|
|
80
|
+
return {
|
|
81
|
+
route: text(o.route) === "feature" ? "feature" : "change",
|
|
82
|
+
name: text(o.name), summary: text(o.summary), evidence: textList(o.evidence), suspected: text(o.suspected),
|
|
83
|
+
criteria: list(o.criteria).map((c) => {
|
|
84
|
+
const x = isObject(c) ? c : {};
|
|
85
|
+
return { name: text(x.name), statement: text(x.statement), proof: text(x.proof), severity: text(x.severity).toLowerCase() as CriterionSeverity };
|
|
86
|
+
}),
|
|
87
|
+
mustNotChange: rows(o.mustNotChange, ["behaviour", "pinnedBy"]),
|
|
88
|
+
scope: rows(o.scope, ["in", "out"]),
|
|
89
|
+
constraints: textList(o.constraints),
|
|
90
|
+
assumptions: rows(o.assumptions, ["assumption", "validatedBy"]),
|
|
91
|
+
questions: list(o.questions).map((q) => {
|
|
92
|
+
const x = isObject(q) ? q : {};
|
|
93
|
+
return { severity: text(x.severity), question: text(x.question), impact: text(x.impact), options: textList(x.options) };
|
|
94
|
+
}),
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export function checkChangeAnswer(value: unknown, kind: ChangeKind): Checked<ChangeAnswer> {
|
|
99
|
+
if (!isObject(value)) return { ok: false, problems: ["the answer is not an object"] };
|
|
100
|
+
const a = readChangeAnswer(value);
|
|
101
|
+
if (a.route === "feature") return { ok: true, value: a };
|
|
102
|
+
const problems: string[] = [];
|
|
103
|
+
const oneLine = (t: string): boolean => !/[\r\n]/.test(t);
|
|
104
|
+
if (a.name === "" || !oneLine(a.name) || a.name.length > MAX_NAME_CHARS || a.name.includes("—")) {
|
|
105
|
+
problems.push(`name: one line of at most ${MAX_NAME_CHARS} characters, no '—'`);
|
|
106
|
+
}
|
|
107
|
+
if (a.summary === "") problems.push("summary: what is wrong or costly, where it shows, why now");
|
|
108
|
+
if (a.criteria.length === 0) problems.push("criteria: at least one acceptance criterion");
|
|
109
|
+
if (a.criteria.length > MAX_CRITERIA) problems.push(`criteria: at most ${MAX_CRITERIA}`);
|
|
110
|
+
a.criteria.forEach((c, i) => {
|
|
111
|
+
const id = criterionId(i);
|
|
112
|
+
if (c.name === "" || !oneLine(c.name) || c.name.length > MAX_NAME_CHARS) problems.push(`${id}: the name is one line of at most ${MAX_NAME_CHARS} characters`);
|
|
113
|
+
if (c.statement === "" || !oneLine(c.statement) || c.statement.length > MAX_STATEMENT_CHARS || c.statement.includes(" · ")) {
|
|
114
|
+
problems.push(`${id}: the statement is one testable line of at most ${MAX_STATEMENT_CHARS} characters`);
|
|
115
|
+
}
|
|
116
|
+
if (c.proof === "" || !oneLine(c.proof)) problems.push(`${id}: no proof (the test that reproduces, the measurement and its target, or "no observable behaviour changes")`);
|
|
117
|
+
if (!CRITERION_SEVERITIES.includes(c.severity)) problems.push(`${id}: severity is blocking or warning`);
|
|
118
|
+
});
|
|
119
|
+
if (kind === "perf" && !a.criteria.some((c) => /\d/.test(`${c.statement} ${c.proof}`))) {
|
|
120
|
+
problems.push("a performance change has a criterion with a number as its target");
|
|
121
|
+
}
|
|
122
|
+
if (kind === "refactor" && a.mustNotChange.length === 0) {
|
|
123
|
+
problems.push("a refactor names at least one behaviour that must not change, and the test pinning it or unpinned");
|
|
124
|
+
}
|
|
125
|
+
const tables: Array<[string, ReadonlyArray<Record<string, string>>]> = [
|
|
126
|
+
["mustNotChange", a.mustNotChange], ["scope", a.scope], ["assumptions", a.assumptions],
|
|
127
|
+
];
|
|
128
|
+
for (const [name, items] of tables) {
|
|
129
|
+
items.forEach((row, i) => {
|
|
130
|
+
if (Object.values(row).some(breaksCell)) problems.push(`${name} ${i + 1}: every cell is one line, no '|'`);
|
|
131
|
+
if (Object.values(row).every((v) => v === "")) problems.push(`${name} ${i + 1} is empty`);
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
a.mustNotChange.forEach((r, i) => { if (r.behaviour === "") problems.push(`mustNotChange ${i + 1}: no behaviour`); });
|
|
135
|
+
if (a.constraints.length > MAX_LIST || a.evidence.length > MAX_LIST) problems.push(`evidence and constraints: at most ${MAX_LIST} lines each`);
|
|
136
|
+
const all = [
|
|
137
|
+
a.name, a.summary, ...a.evidence, a.suspected, ...a.criteria.flatMap((c) => [c.name, c.statement, c.proof]),
|
|
138
|
+
...a.scope.flatMap((s) => [s.in, s.out]), ...a.constraints,
|
|
139
|
+
];
|
|
140
|
+
const design = all.find((t) => DESIGN.test(t));
|
|
141
|
+
if (design !== undefined) problems.push(`no design: "${design.slice(0, 60)}" names a new type, file, pattern or library; say what is observed and expected`);
|
|
142
|
+
if (/\bTBD\b/.test(all.join("\n")) && a.questions.length === 0) problems.push("a TBD in the body has no open question");
|
|
143
|
+
if (a.questions.length > MAX_QUESTIONS) problems.push(`questions: at most ${MAX_QUESTIONS}`);
|
|
144
|
+
a.questions.forEach((q, i) => problems.push(...draftQuestionProblems(q, i + 1)));
|
|
145
|
+
return problems.length > 0 ? { ok: false, problems } : { ok: true, value: a };
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** The answer with each pinned test the inventory does not show turned into "unpinned", and those names. */
|
|
149
|
+
export function pinOnlyKnown(a: ChangeAnswer, known: (name: string) => boolean): { answer: ChangeAnswer; unknown: string[] } {
|
|
150
|
+
const unknown: string[] = [];
|
|
151
|
+
const mustNotChange = a.mustNotChange.map((r) => {
|
|
152
|
+
const by = r.pinnedBy.replace(/`/g, "").trim();
|
|
153
|
+
if (by === "" || by.toLowerCase() === "unpinned") return { behaviour: r.behaviour, pinnedBy: "unpinned" };
|
|
154
|
+
if (known(by)) return { behaviour: r.behaviour, pinnedBy: by };
|
|
155
|
+
unknown.push(by);
|
|
156
|
+
return { behaviour: r.behaviour, pinnedBy: "unpinned" };
|
|
157
|
+
});
|
|
158
|
+
return { answer: { ...a, mustNotChange }, unknown };
|
|
159
|
+
}
|