@ouro.bot/cli 0.1.0-alpha.1469 → 0.1.0-alpha.1470
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/README.md +1 -1
- package/changelog.json +6 -2
- package/deploy/unraid/sanctuary.ouro/bundle-meta.json +1 -1
- package/deploy/unraid/sanctuary.xml +1 -1
- package/desk.lock.json +8 -0
- package/dist/heart/identity.js +27 -1
- package/dist/mind/desk-section.js +33 -43
- package/dist/repertoire/desk-mcp.js +140 -0
- package/dist/repertoire/mcp-manager.js +22 -0
- package/dist/repertoire/mcp-tools.js +11 -7
- package/npm-shrinkwrap.json +2 -2
- package/package.json +4 -1
- package/vendor/desk/.claude-plugin/plugin.json +35 -0
- package/vendor/desk/.mcp.claude-codex.json +28 -0
- package/vendor/desk/.mcp.copilot.json +16 -0
- package/vendor/desk/.ouro-desk.json +6 -0
- package/vendor/desk/CHANGELOG.md +7004 -0
- package/vendor/desk/README.md +195 -0
- package/vendor/desk/activation/README.md +98 -0
- package/vendor/desk/activation/copilot-root.flattened-bundle.json +38 -0
- package/vendor/desk/activation/desk.activation.json +251 -0
- package/vendor/desk/activation/host-capability-evidence.md +46 -0
- package/vendor/desk/activation/support-matrix.json +84 -0
- package/vendor/desk/agency.json +20 -0
- package/vendor/desk/agents/observer.agent.md +26 -0
- package/vendor/desk/agents/observer.md +29 -0
- package/vendor/desk/agents/worker.agent.md +32 -0
- package/vendor/desk/agents/worker.md +40 -0
- package/vendor/desk/artifacts/tombstones/tombstone.schema.json +53 -0
- package/vendor/desk/artifacts/tombstones/tombstones.jsonl +1 -0
- package/vendor/desk/changelog.d/README.md +12 -0
- package/vendor/desk/docs/agent-files.md +104 -0
- package/vendor/desk/docs/agentic-engineering-v2-rfc.md +206 -0
- package/vendor/desk/docs/agentic-engineering-v3-rfc.md +109 -0
- package/vendor/desk/docs/browser-remote-desktops.md +69 -0
- package/vendor/desk/docs/dependency-activation-stories-and-criteria.md +500 -0
- package/vendor/desk/docs/evaluation-packet.md +363 -0
- package/vendor/desk/docs/factory-local-capture.md +651 -0
- package/vendor/desk/docs/factory-store-playbook.md +927 -0
- package/vendor/desk/docs/images/factory-site.png +0 -0
- package/vendor/desk/docs/issue-drains.md +79 -0
- package/vendor/desk/docs/lfs-inspection.md +55 -0
- package/vendor/desk/docs/preview-diagnostics.md +11 -0
- package/vendor/desk/docs/relays.md +88 -0
- package/vendor/desk/docs/schedules.md +69 -0
- package/vendor/desk/docs/search-recovery.md +22 -0
- package/vendor/desk/docs/session-labels.md +157 -0
- package/vendor/desk/docs/session-retention.md +125 -0
- package/vendor/desk/docs/sessions.md +17 -0
- package/vendor/desk/docs/stalled-nudges.md +54 -0
- package/vendor/desk/docs/webhooks.md +80 -0
- package/vendor/desk/docs/workspace-tidy.md +74 -0
- package/vendor/desk/hooks/boot-checks.cjs +7 -0
- package/vendor/desk/hooks/claude-session-start.cjs +123 -0
- package/vendor/desk/hooks/compatible-node.cjs +97 -0
- package/vendor/desk/hooks/copilot-boot-prompt.cjs +69 -0
- package/vendor/desk/hooks/copilot-durable-files.cjs +8 -0
- package/vendor/desk/hooks/copilot-hooks.json +61 -0
- package/vendor/desk/hooks/copilot-intake-context.cjs +5 -0
- package/vendor/desk/hooks/copilot-lane-model.cjs +8 -0
- package/vendor/desk/hooks/copilot-session-start.cjs +264 -0
- package/vendor/desk/hooks/copilot-skill-current.cjs +28 -0
- package/vendor/desk/hooks/factory-end.cjs +5 -0
- package/vendor/desk/hooks/factory-start.cjs +27 -0
- package/vendor/desk/hooks/hooks.json +40 -0
- package/vendor/desk/hooks/lib/boot-checks.cjs +643 -0
- package/vendor/desk/hooks/lib/child-agent.cjs +14 -0
- package/vendor/desk/hooks/lib/copilot-intake-context.cjs +73 -0
- package/vendor/desk/hooks/lib/current-release.cjs +162 -0
- package/vendor/desk/hooks/lib/delivery-stop.cjs +326 -0
- package/vendor/desk/hooks/lib/detach-worker.cjs +43 -0
- package/vendor/desk/hooks/lib/durable-files.cjs +102 -0
- package/vendor/desk/hooks/lib/factory-end.cjs +327 -0
- package/vendor/desk/hooks/lib/lane-model.cjs +82 -0
- package/vendor/desk/hooks/lib/node-required.cjs +56 -0
- package/vendor/desk/hooks/lib/orca-session-title.cjs +60 -0
- package/vendor/desk/hooks/lib/session-end.cjs +30 -0
- package/vendor/desk/hooks/lib/sync-end.cjs +89 -0
- package/vendor/desk/hooks/loop-start.cjs +105 -0
- package/vendor/desk/hooks/node-missing.sh +78 -0
- package/vendor/desk/hooks/orca-session-title.cjs +8 -0
- package/vendor/desk/hooks/session-end.cjs +8 -0
- package/vendor/desk/mcp/README.md +269 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/darwin-arm64-node-127/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/darwin-arm64-node-127/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/darwin-arm64-node-127/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/darwin-arm64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/darwin-arm64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/darwin-arm64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-127/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-127/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-127/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-147/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-147/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/linux-x64-node-147/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/support-matrix.json +72 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/win32-x64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/win32-x64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/win32-x64-node-137/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/win32-x64-node-147/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.manifest.json +881 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/win32-x64-node-147/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.sha256 +1 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/1.4.0-alpha.6/win32-x64-node-147/3b0cb8b1e7dd77a982b38375fe88a5278bd77974213e18be025d7dc8deea800f/runtime-deps.tgz +0 -0
- package/vendor/desk/mcp/artifacts/runtime-deps/README.md +25 -0
- package/vendor/desk/mcp/bootstrap.cjs +761 -0
- package/vendor/desk/mcp/docs/private-feedback.md +13 -0
- package/vendor/desk/mcp/idle-proxy.cjs +423 -0
- package/vendor/desk/mcp/index.js +813 -0
- package/vendor/desk/mcp/package-lock.json +3717 -0
- package/vendor/desk/mcp/package.json +44 -0
- package/vendor/desk/mcp/scripts/agency-desk-channel.js +7 -0
- package/vendor/desk/mcp/scripts/build-runtime-deps-pack.js +5 -0
- package/vendor/desk/mcp/scripts/crew.js +89 -0
- package/vendor/desk/mcp/scripts/drains-launcher.mjs +329 -0
- package/vendor/desk/mcp/scripts/drains.js +5 -0
- package/vendor/desk/mcp/scripts/factory.js +657 -0
- package/vendor/desk/mcp/scripts/file-desk-problem.js +9 -0
- package/vendor/desk/mcp/scripts/finish-commit.js +7 -0
- package/vendor/desk/mcp/scripts/lfs.js +37 -0
- package/vendor/desk/mcp/scripts/local-recovery.js +363 -0
- package/vendor/desk/mcp/scripts/migrations.js +11 -0
- package/vendor/desk/mcp/scripts/private-view.js +177 -0
- package/vendor/desk/mcp/scripts/resolve-desk-root.js +106 -0
- package/vendor/desk/mcp/scripts/session-boot.js +22 -0
- package/vendor/desk/mcp/scripts/session-retention.js +5 -0
- package/vendor/desk/mcp/scripts/session-sync.js +10 -0
- package/vendor/desk/mcp/scripts/sessions.js +5 -0
- package/vendor/desk/mcp/scripts/sync-push.js +13 -0
- package/vendor/desk/mcp/scripts/tidy-status.js +8 -0
- package/vendor/desk/mcp/scripts/verify-runtime-deps-pack.js +5 -0
- package/vendor/desk/mcp/src/actions/desk-read.actions.mts +73 -0
- package/vendor/desk/mcp/src/actions/desk-session.actions.mts +42 -0
- package/vendor/desk/mcp/src/actions/desk-web.actions.mts +52 -0
- package/vendor/desk/mcp/src/actions/desk.actions.mts +5 -0
- package/vendor/desk/mcp/src/actions/generated/desk/OuroActions.swift +649 -0
- package/vendor/desk/mcp/src/actions/generated/desk/OuroActionsReins.swift +61 -0
- package/vendor/desk/mcp/src/actions/generated/desk/actions.json +280 -0
- package/vendor/desk/mcp/src/actions/generated/desk/commands.json +145 -0
- package/vendor/desk/mcp/src/actions/generated/desk/mcp.json +256 -0
- package/vendor/desk/mcp/src/actions/generated/desk/web.ts +59 -0
- package/vendor/desk/mcp/src/actions/generated/desk/webmcp.json +250 -0
- package/vendor/desk/mcp/src/actions/generated/desk-web/OuroActions.swift +241 -0
- package/vendor/desk/mcp/src/actions/generated/desk-web/OuroActionsReins.swift +25 -0
- package/vendor/desk/mcp/src/actions/generated/desk-web/actions.json +73 -0
- package/vendor/desk/mcp/src/actions/generated/desk-web/commands.json +53 -0
- package/vendor/desk/mcp/src/actions/generated/desk-web/mcp.json +83 -0
- package/vendor/desk/mcp/src/actions/generated/desk-web/web.ts +47 -0
- package/vendor/desk/mcp/src/actions/generated/desk-web/webmcp.json +81 -0
- package/vendor/desk/mcp/src/actions/served.js +5 -0
- package/vendor/desk/mcp/src/activation/admit.js +77 -0
- package/vendor/desk/mcp/src/activation/failures.js +65 -0
- package/vendor/desk/mcp/src/activation/readiness-policy.js +102 -0
- package/vendor/desk/mcp/src/activation/schema.js +17 -0
- package/vendor/desk/mcp/src/activation/superpowers-context.js +265 -0
- package/vendor/desk/mcp/src/activation/validate.js +540 -0
- package/vendor/desk/mcp/src/artifacts/tombstones.js +61 -0
- package/vendor/desk/mcp/src/crew/initiative.js +287 -0
- package/vendor/desk/mcp/src/crew/workspace.js +1259 -0
- package/vendor/desk/mcp/src/db/init.js +75 -0
- package/vendor/desk/mcp/src/db/schema.sql +83 -0
- package/vendor/desk/mcp/src/desk/active-tasks.js +408 -0
- package/vendor/desk/mcp/src/desk/card-commit-guard.js +281 -0
- package/vendor/desk/mcp/src/desk/cleanup-index.js +53 -0
- package/vendor/desk/mcp/src/desk/content-home.js +246 -0
- package/vendor/desk/mcp/src/desk/crew-config.js +102 -0
- package/vendor/desk/mcp/src/desk/crew-member.js +196 -0
- package/vendor/desk/mcp/src/desk/crew-roster.js +151 -0
- package/vendor/desk/mcp/src/desk/frontmatter-lite.js +228 -0
- package/vendor/desk/mcp/src/desk/gh-logins.js +109 -0
- package/vendor/desk/mcp/src/desk/handles.js +123 -0
- package/vendor/desk/mcp/src/desk/handoff-reference.js +35 -0
- package/vendor/desk/mcp/src/desk/improvement-authority.js +3 -0
- package/vendor/desk/mcp/src/desk/improvement-cards.js +704 -0
- package/vendor/desk/mcp/src/desk/improvement-person.js +51 -0
- package/vendor/desk/mcp/src/desk/lifecycle.js +16 -0
- package/vendor/desk/mcp/src/desk/machine-desks.js +119 -0
- package/vendor/desk/mcp/src/desk/naming.js +333 -0
- package/vendor/desk/mcp/src/desk/organization.js +592 -0
- package/vendor/desk/mcp/src/desk/resources.js +274 -0
- package/vendor/desk/mcp/src/desk/runtime-resolver.js +30 -0
- package/vendor/desk/mcp/src/desk/scratch-paths.js +44 -0
- package/vendor/desk/mcp/src/desk/step-delivery.js +140 -0
- package/vendor/desk/mcp/src/desk/steps.js +263 -0
- package/vendor/desk/mcp/src/desk/tidy.js +930 -0
- package/vendor/desk/mcp/src/desk/unsigned-deliveries.js +359 -0
- package/vendor/desk/mcp/src/factory/agent-types.js +45 -0
- package/vendor/desk/mcp/src/factory/andon-watch.js +109 -0
- package/vendor/desk/mcp/src/factory/binding.js +612 -0
- package/vendor/desk/mcp/src/factory/boot-check.js +645 -0
- package/vendor/desk/mcp/src/factory/capture-classify.js +158 -0
- package/vendor/desk/mcp/src/factory/capture-count.js +183 -0
- package/vendor/desk/mcp/src/factory/capture-flush.js +268 -0
- package/vendor/desk/mcp/src/factory/capture-publish.js +141 -0
- package/vendor/desk/mcp/src/factory/capture-schema.js +193 -0
- package/vendor/desk/mcp/src/factory/capture-sweep.js +239 -0
- package/vendor/desk/mcp/src/factory/catch-point.js +60 -0
- package/vendor/desk/mcp/src/factory/commit-resolve.js +94 -0
- package/vendor/desk/mcp/src/factory/consent-answer.js +37 -0
- package/vendor/desk/mcp/src/factory/context-capability.js +15 -0
- package/vendor/desk/mcp/src/factory/context-outbox.js +885 -0
- package/vendor/desk/mcp/src/factory/context-run.js +386 -0
- package/vendor/desk/mcp/src/factory/context-schema.js +249 -0
- package/vendor/desk/mcp/src/factory/copilot-turn-index.js +93 -0
- package/vendor/desk/mcp/src/factory/copilot-usage.js +148 -0
- package/vendor/desk/mcp/src/factory/credential.js +45 -0
- package/vendor/desk/mcp/src/factory/derive-claude.js +960 -0
- package/vendor/desk/mcp/src/factory/derive-codex.js +734 -0
- package/vendor/desk/mcp/src/factory/derive-common.js +279 -0
- package/vendor/desk/mcp/src/factory/derive-copilot.js +1057 -0
- package/vendor/desk/mcp/src/factory/derive-run.js +807 -0
- package/vendor/desk/mcp/src/factory/desk-problem-file.js +310 -0
- package/vendor/desk/mcp/src/factory/desk-problem-fingerprint.js +70 -0
- package/vendor/desk/mcp/src/factory/desk-problem-known.js +246 -0
- package/vendor/desk/mcp/src/factory/desk-problem-template.js +107 -0
- package/vendor/desk/mcp/src/factory/desk-repo.js +1223 -0
- package/vendor/desk/mcp/src/factory/desk-task-line.js +28 -0
- package/vendor/desk/mcp/src/factory/desk-visibility.js +48 -0
- package/vendor/desk/mcp/src/factory/end-hook.js +14 -0
- package/vendor/desk/mcp/src/factory/evaluate-kick.js +164 -0
- package/vendor/desk/mcp/src/factory/evaluate-run.js +678 -0
- package/vendor/desk/mcp/src/factory/evaluator-step.js +484 -0
- package/vendor/desk/mcp/src/factory/filer-launch.js +79 -0
- package/vendor/desk/mcp/src/factory/flush-health.js +26 -0
- package/vendor/desk/mcp/src/factory/flush.js +1758 -0
- package/vendor/desk/mcp/src/factory/focus.js +326 -0
- package/vendor/desk/mcp/src/factory/headless-flag.cjs +32 -0
- package/vendor/desk/mcp/src/factory/headless-flag.js +25 -0
- package/vendor/desk/mcp/src/factory/headless-ledger.js +743 -0
- package/vendor/desk/mcp/src/factory/headless.js +567 -0
- package/vendor/desk/mcp/src/factory/held-route.js +93 -0
- package/vendor/desk/mcp/src/factory/host-flags.js +36 -0
- package/vendor/desk/mcp/src/factory/improvement-verify.js +429 -0
- package/vendor/desk/mcp/src/factory/kaizen-file.js +231 -0
- package/vendor/desk/mcp/src/factory/label-binding.js +90 -0
- package/vendor/desk/mcp/src/factory/label-schema.js +426 -0
- package/vendor/desk/mcp/src/factory/local-status.js +368 -0
- package/vendor/desk/mcp/src/factory/loop-conditions.js +121 -0
- package/vendor/desk/mcp/src/factory/loop-health.js +500 -0
- package/vendor/desk/mcp/src/factory/loop-slot.js +90 -0
- package/vendor/desk/mcp/src/factory/loop-status.js +100 -0
- package/vendor/desk/mcp/src/factory/loop-switch.cjs +14 -0
- package/vendor/desk/mcp/src/factory/loop-worker-state.js +96 -0
- package/vendor/desk/mcp/src/factory/loop-worker.js +290 -0
- package/vendor/desk/mcp/src/factory/marker.js +61 -0
- package/vendor/desk/mcp/src/factory/mirror-step.js +145 -0
- package/vendor/desk/mcp/src/factory/os-protect.js +243 -0
- package/vendor/desk/mcp/src/factory/outbox.js +2231 -0
- package/vendor/desk/mcp/src/factory/outcome.js +431 -0
- package/vendor/desk/mcp/src/factory/pipeline/andon.js +319 -0
- package/vendor/desk/mcp/src/factory/pipeline/attention-rollup.js +158 -0
- package/vendor/desk/mcp/src/factory/pipeline/attention.js +146 -0
- package/vendor/desk/mcp/src/factory/pipeline/build.js +299 -0
- package/vendor/desk/mcp/src/factory/pipeline/compare.js +148 -0
- package/vendor/desk/mcp/src/factory/pipeline/formulas.js +652 -0
- package/vendor/desk/mcp/src/factory/pipeline/kaizen.js +387 -0
- package/vendor/desk/mcp/src/factory/pipeline/lifecycle-clocks.js +345 -0
- package/vendor/desk/mcp/src/factory/pipeline/normalize.js +73 -0
- package/vendor/desk/mcp/src/factory/pipeline/number-states.js +154 -0
- package/vendor/desk/mcp/src/factory/pipeline/outcomes.js +268 -0
- package/vendor/desk/mcp/src/factory/pipeline/report.js +737 -0
- package/vendor/desk/mcp/src/factory/pipeline/rollups.js +883 -0
- package/vendor/desk/mcp/src/factory/pipeline/stretches.js +523 -0
- package/vendor/desk/mcp/src/factory/pipeline/timeline.js +199 -0
- package/vendor/desk/mcp/src/factory/pipeline/validate-pr.js +238 -0
- package/vendor/desk/mcp/src/factory/pipeline/versions.js +42 -0
- package/vendor/desk/mcp/src/factory/pipeline/walk.js +1177 -0
- package/vendor/desk/mcp/src/factory/plugin-registry.js +72 -0
- package/vendor/desk/mcp/src/factory/plugin-sources.cjs +249 -0
- package/vendor/desk/mcp/src/factory/pr-green.js +77 -0
- package/vendor/desk/mcp/src/factory/process-lock.js +142 -0
- package/vendor/desk/mcp/src/factory/proof-session.js +75 -0
- package/vendor/desk/mcp/src/factory/publish.js +637 -0
- package/vendor/desk/mcp/src/factory/published-schema.js +648 -0
- package/vendor/desk/mcp/src/factory/reconcile-reasons.js +22 -0
- package/vendor/desk/mcp/src/factory/reconcile-step.js +251 -0
- package/vendor/desk/mcp/src/factory/reconcile.js +808 -0
- package/vendor/desk/mcp/src/factory/release-version.js +134 -0
- package/vendor/desk/mcp/src/factory/repo-name.js +13 -0
- package/vendor/desk/mcp/src/factory/retention.js +60 -0
- package/vendor/desk/mcp/src/factory/route-desk.js +40 -0
- package/vendor/desk/mcp/src/factory/route-issues.js +251 -0
- package/vendor/desk/mcp/src/factory/route-local.js +264 -0
- package/vendor/desk/mcp/src/factory/schema.js +957 -0
- package/vendor/desk/mcp/src/factory/session-kind.js +16 -0
- package/vendor/desk/mcp/src/factory/session-lifetime.js +56 -0
- package/vendor/desk/mcp/src/factory/session-route.js +183 -0
- package/vendor/desk/mcp/src/factory/shell-git.js +500 -0
- package/vendor/desk/mcp/src/factory/store-issues.js +143 -0
- package/vendor/desk/mcp/src/factory/store-route.js +208 -0
- package/vendor/desk/mcp/src/factory/test-state-guard.js +103 -0
- package/vendor/desk/mcp/src/factory/time.js +36 -0
- package/vendor/desk/mcp/src/factory/tool-issue-file.js +84 -0
- package/vendor/desk/mcp/src/factory/tool-kinds.js +87 -0
- package/vendor/desk/mcp/src/factory/triage-schema.js +233 -0
- package/vendor/desk/mcp/src/factory/windows-acl.js +679 -0
- package/vendor/desk/mcp/src/indexer/chunk.js +232 -0
- package/vendor/desk/mcp/src/indexer/discover.js +434 -0
- package/vendor/desk/mcp/src/indexer/exclusions.js +247 -0
- package/vendor/desk/mcp/src/indexer/index.js +167 -0
- package/vendor/desk/mcp/src/indexer/refs.js +0 -0
- package/vendor/desk/mcp/src/indexer/text-hash.js +18 -0
- package/vendor/desk/mcp/src/lib/ouro-actions/actions.claims.json +75 -0
- package/vendor/desk/mcp/src/lib/ouro-actions/dist-manifest.json +70 -0
- package/vendor/desk/mcp/src/lib/ouro-actions/ouro-actions.mts +1416 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/LICENSE +21 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/ax-claims.ts +190 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/ax-command.ts +1020 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/checks.ts +343 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/cli.ts +240 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/component.ts +430 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/dev-commands.ts +204 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/doctor.ts +126 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/effects.ts +68 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/exit-codes.ts +75 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/help.ts +220 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/mcp.ts +268 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/outcome.ts +265 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/output.ts +67 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/precise-copy.ts +235 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/problem.ts +124 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/surfaces.kit.mts +8 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/surfaces.ts +568 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/terminal.ts +245 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/voice.ts +136 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/wait.ts +226 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/work-event.ts +181 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/xray.kit.mts +18 -0
- package/vendor/desk/mcp/src/lib/ouro-ui/registry/ouro/ax/xray.ts +2072 -0
- package/vendor/desk/mcp/src/package-metadata.js +20 -0
- package/vendor/desk/mcp/src/protected/legacy-ledger.js +55 -0
- package/vendor/desk/mcp/src/readiness/leftovers.js +75 -0
- package/vendor/desk/mcp/src/readiness/process-start.js +149 -0
- package/vendor/desk/mcp/src/runtime/admission-worker.js +194 -0
- package/vendor/desk/mcp/src/runtime/admission.js +177 -0
- package/vendor/desk/mcp/src/runtime/agency-desk-channel.js +342 -0
- package/vendor/desk/mcp/src/runtime/agents-md.js +62 -0
- package/vendor/desk/mcp/src/runtime/append-lane.js +68 -0
- package/vendor/desk/mcp/src/runtime/argv-safe-reason.js +55 -0
- package/vendor/desk/mcp/src/runtime/boot-dependencies.js +75 -0
- package/vendor/desk/mcp/src/runtime/boot-text.js +504 -0
- package/vendor/desk/mcp/src/runtime/boot.js +1677 -0
- package/vendor/desk/mcp/src/runtime/bootstrap.js +1455 -0
- package/vendor/desk/mcp/src/runtime/chunked-import.js +102 -0
- package/vendor/desk/mcp/src/runtime/copilot-commit-trailer.js +133 -0
- package/vendor/desk/mcp/src/runtime/copilot-session.js +155 -0
- package/vendor/desk/mcp/src/runtime/deliver.js +469 -0
- package/vendor/desk/mcp/src/runtime/desk-channel.js +86 -0
- package/vendor/desk/mcp/src/runtime/desk-failure.js +26 -0
- package/vendor/desk/mcp/src/runtime/desk-health.js +168 -0
- package/vendor/desk/mcp/src/runtime/desk-session.js +1451 -0
- package/vendor/desk/mcp/src/runtime/diagnostic-server.js +72 -0
- package/vendor/desk/mcp/src/runtime/diagnostics.js +241 -0
- package/vendor/desk/mcp/src/runtime/drains-cli.js +187 -0
- package/vendor/desk/mcp/src/runtime/drains.js +781 -0
- package/vendor/desk/mcp/src/runtime/elsewhere-note.js +9 -0
- package/vendor/desk/mcp/src/runtime/failure-evidence.js +21 -0
- package/vendor/desk/mcp/src/runtime/fast-refs.js +209 -0
- package/vendor/desk/mcp/src/runtime/filer-throttle.js +66 -0
- package/vendor/desk/mcp/src/runtime/focused-card.js +147 -0
- package/vendor/desk/mcp/src/runtime/front-door.js +204 -0
- package/vendor/desk/mcp/src/runtime/gate-wait.js +2 -0
- package/vendor/desk/mcp/src/runtime/git-inspection.js +201 -0
- package/vendor/desk/mcp/src/runtime/git-read-worker.js +157 -0
- package/vendor/desk/mcp/src/runtime/health.js +50 -0
- package/vendor/desk/mcp/src/runtime/hooks.js +353 -0
- package/vendor/desk/mcp/src/runtime/hosted.js +163 -0
- package/vendor/desk/mcp/src/runtime/inbox.js +102 -0
- package/vendor/desk/mcp/src/runtime/index-drift.js +118 -0
- package/vendor/desk/mcp/src/runtime/last-start.js +133 -0
- package/vendor/desk/mcp/src/runtime/lesson-section.js +92 -0
- package/vendor/desk/mcp/src/runtime/lessons-shelf.js +100 -0
- package/vendor/desk/mcp/src/runtime/lfs.js +319 -0
- package/vendor/desk/mcp/src/runtime/native-path.js +12 -0
- package/vendor/desk/mcp/src/runtime/newest-release.js +197 -0
- package/vendor/desk/mcp/src/runtime/node-selection.js +233 -0
- package/vendor/desk/mcp/src/runtime/orca-session-title.js +225 -0
- package/vendor/desk/mcp/src/runtime/other-sessions.js +183 -0
- package/vendor/desk/mcp/src/runtime/pending-migrations.js +653 -0
- package/vendor/desk/mcp/src/runtime/plugin-update.js +215 -0
- package/vendor/desk/mcp/src/runtime/pluginless-runtimes.js +34 -0
- package/vendor/desk/mcp/src/runtime/pr-publication.js +226 -0
- package/vendor/desk/mcp/src/runtime/preview-snapshot.js +23 -0
- package/vendor/desk/mcp/src/runtime/publication-mode.js +19 -0
- package/vendor/desk/mcp/src/runtime/relays.js +974 -0
- package/vendor/desk/mcp/src/runtime/release-alert.js +148 -0
- package/vendor/desk/mcp/src/runtime/remote-identity.js +140 -0
- package/vendor/desk/mcp/src/runtime/resolve-here.js +4 -0
- package/vendor/desk/mcp/src/runtime/runtime-deps-cli.js +65 -0
- package/vendor/desk/mcp/src/runtime/runtime-deps.js +1109 -0
- package/vendor/desk/mcp/src/runtime/runtime-identity.js +22 -0
- package/vendor/desk/mcp/src/runtime/runtime-swap.js +101 -0
- package/vendor/desk/mcp/src/runtime/schedules.js +235 -0
- package/vendor/desk/mcp/src/runtime/session-activity.js +190 -0
- package/vendor/desk/mcp/src/runtime/session-label.js +30 -0
- package/vendor/desk/mcp/src/runtime/session-retention.js +662 -0
- package/vendor/desk/mcp/src/runtime/session-sync.js +333 -0
- package/vendor/desk/mcp/src/runtime/session-trailer.js +126 -0
- package/vendor/desk/mcp/src/runtime/sessions-cli.js +301 -0
- package/vendor/desk/mcp/src/runtime/signoff-listed.js +81 -0
- package/vendor/desk/mcp/src/runtime/skills.js +76 -0
- package/vendor/desk/mcp/src/runtime/stale-card-lead.js +52 -0
- package/vendor/desk/mcp/src/runtime/stale-desk-refresh.js +198 -0
- package/vendor/desk/mcp/src/runtime/stale-desk.js +219 -0
- package/vendor/desk/mcp/src/runtime/stalled.js +255 -0
- package/vendor/desk/mcp/src/runtime/standing-authority.js +79 -0
- package/vendor/desk/mcp/src/runtime/startup-boot.js +341 -0
- package/vendor/desk/mcp/src/runtime/startup-resolve.js +140 -0
- package/vendor/desk/mcp/src/runtime/state-branch.js +203 -0
- package/vendor/desk/mcp/src/runtime/status-compact.js +165 -0
- package/vendor/desk/mcp/src/runtime/status-inspection-child.js +26 -0
- package/vendor/desk/mcp/src/runtime/status-inspection.js +147 -0
- package/vendor/desk/mcp/src/runtime/status-root.js +39 -0
- package/vendor/desk/mcp/src/runtime/sync-worker.js +911 -0
- package/vendor/desk/mcp/src/runtime/test-state-guard.js +107 -0
- package/vendor/desk/mcp/src/runtime/unmerged-saves.js +247 -0
- package/vendor/desk/mcp/src/runtime/workspace-claim.js +53 -0
- package/vendor/desk/mcp/src/runtime/workspace-evidence.js +96 -0
- package/vendor/desk/mcp/src/runtime/workspace-tidy.js +509 -0
- package/vendor/desk/mcp/src/search/direct-lexical.js +54 -0
- package/vendor/desk/mcp/src/search/embedder.js +108 -0
- package/vendor/desk/mcp/src/search/engine.js +406 -0
- package/vendor/desk/mcp/src/search/files-router.js +22 -0
- package/vendor/desk/mcp/src/search/old-index.js +46 -0
- package/vendor/desk/mcp/src/search/vectors.js +60 -0
- package/vendor/desk/mcp/src/server.js +389 -0
- package/vendor/desk/mcp/src/tool-names.js +73 -0
- package/vendor/desk/mcp/src/tool-refusal.cjs +35 -0
- package/vendor/desk/mcp/src/tool-schema-parts.js +12 -0
- package/vendor/desk/mcp/src/tool-schemas.js +325 -0
- package/vendor/desk/mcp/src/tools/_card-commit.js +148 -0
- package/vendor/desk/mcp/src/tools/archive-links.js +185 -0
- package/vendor/desk/mcp/src/tools/archive-move.js +18 -0
- package/vendor/desk/mcp/src/tools/archive-native-session.js +728 -0
- package/vendor/desk/mcp/src/tools/archive-state.js +513 -0
- package/vendor/desk/mcp/src/tools/delivery-gate.js +251 -0
- package/vendor/desk/mcp/src/tools/desk-save.js +444 -0
- package/vendor/desk/mcp/src/tools/doctor.js +122 -0
- package/vendor/desk/mcp/src/tools/done-evidence.js +260 -0
- package/vendor/desk/mcp/src/tools/factory-context.js +204 -0
- package/vendor/desk/mcp/src/tools/friction.js +332 -0
- package/vendor/desk/mcp/src/tools/improvement.js +156 -0
- package/vendor/desk/mcp/src/tools/lesson-lines.js +22 -0
- package/vendor/desk/mcp/src/tools/lesson-owners.js +137 -0
- package/vendor/desk/mcp/src/tools/lesson-team.js +169 -0
- package/vendor/desk/mcp/src/tools/lesson.js +254 -0
- package/vendor/desk/mcp/src/tools/local-only.js +151 -0
- package/vendor/desk/mcp/src/tools/move.js +794 -0
- package/vendor/desk/mcp/src/tools/native-stage-context.js +32 -0
- package/vendor/desk/mcp/src/tools/note.js +267 -0
- package/vendor/desk/mcp/src/tools/search.js +634 -0
- package/vendor/desk/mcp/src/tools/shared-write.js +196 -0
- package/vendor/desk/mcp/src/tools/sibling-desk.js +37 -0
- package/vendor/desk/mcp/src/tools/status.js +233 -0
- package/vendor/desk/mcp/src/tools/task-archive-due.js +9 -0
- package/vendor/desk/mcp/src/tools/task-archived-resource.js +53 -0
- package/vendor/desk/mcp/src/tools/task-body.js +141 -0
- package/vendor/desk/mcp/src/tools/task-focus.js +164 -0
- package/vendor/desk/mcp/src/tools/task-log.js +76 -0
- package/vendor/desk/mcp/src/tools/task-signoff.js +155 -0
- package/vendor/desk/mcp/src/tools/task.js +1768 -0
- package/vendor/desk/mcp/src/tools/track-row.js +89 -0
- package/vendor/desk/mcp/src/tools/track.js +240 -0
- package/vendor/desk/mcp/src/util/agency-session.cjs +29 -0
- package/vendor/desk/mcp/src/util/archive-links.js +105 -0
- package/vendor/desk/mcp/src/util/bash.js +36 -0
- package/vendor/desk/mcp/src/util/capture-record.js +73 -0
- package/vendor/desk/mcp/src/util/cas-commit.js +252 -0
- package/vendor/desk/mcp/src/util/created-dirs.js +71 -0
- package/vendor/desk/mcp/src/util/deferred-tools.js +51 -0
- package/vendor/desk/mcp/src/util/desk-owner.js +99 -0
- package/vendor/desk/mcp/src/util/env-value.js +13 -0
- package/vendor/desk/mcp/src/util/file-identity.js +40 -0
- package/vendor/desk/mcp/src/util/finish-commit.js +145 -0
- package/vendor/desk/mcp/src/util/fm.js +410 -0
- package/vendor/desk/mcp/src/util/git-config-file.js +85 -0
- package/vendor/desk/mcp/src/util/git-stage.js +440 -0
- package/vendor/desk/mcp/src/util/main-publish.js +240 -0
- package/vendor/desk/mcp/src/util/markdown-links.cjs +555 -0
- package/vendor/desk/mcp/src/util/object-input.js +59 -0
- package/vendor/desk/mcp/src/util/paths.js +647 -0
- package/vendor/desk/mcp/src/util/rank.js +189 -0
- package/vendor/desk/mcp/src/util/redact.js +92 -0
- package/vendor/desk/mcp/src/util/remove-retry.js +35 -0
- package/vendor/desk/mcp/src/util/rename-retry.js +73 -0
- package/vendor/desk/mcp/src/util/route-around.js +265 -0
- package/vendor/desk/mcp/src/util/shell-quote.js +18 -0
- package/vendor/desk/mcp/src/util/startup-direction.js +124 -0
- package/vendor/desk/mcp/src/util/state-ignore.js +33 -0
- package/vendor/desk/mcp/src/util/tool-commits.js +64 -0
- package/vendor/desk/mcp/src/util/unicode-16/LICENSE-MIT.txt +7 -0
- package/vendor/desk/mcp/src/util/unicode-16/README.md +9 -0
- package/vendor/desk/mcp/src/util/unicode-16/letter.cjs +1 -0
- package/vendor/desk/mcp/src/util/unicode-16/mark.cjs +1 -0
- package/vendor/desk/mcp/src/util/unicode-16/number.cjs +1 -0
- package/vendor/desk/mcp/web-auth.cjs +1897 -0
- package/vendor/desk/mcp/web-browser-discovery.cjs +53 -0
- package/vendor/desk/mcp/web-catalog.json +34 -0
- package/vendor/desk/mcp/web-launch.cjs +101 -0
- package/vendor/desk/mcp/web.cjs +1239 -0
- package/vendor/desk/migrations/01-move-to-ourostack-desk.md +188 -0
- package/vendor/desk/migrations/02-tidy-desk.md +87 -0
- package/vendor/desk/migrations/03-desk-release-channel.md +38 -0
- package/vendor/desk/optional/session-label/consumer.mjs +237 -0
- package/vendor/desk/optional/session-label/extension.mjs +32 -0
- package/vendor/desk/plugin.json +54 -0
- package/vendor/desk/settings.json +3 -0
- package/vendor/desk/skills/add-workspace-mcp/SKILL.md +180 -0
- package/vendor/desk/skills/adopt-inflight-work/SKILL.md +212 -0
- package/vendor/desk/skills/archive-workflow/SKILL.md +132 -0
- package/vendor/desk/skills/content-routing/SKILL.md +95 -0
- package/vendor/desk/skills/core-meeting-capture/SKILL.md +47 -0
- package/vendor/desk/skills/core-meeting-capture/references/capture-contract.md +175 -0
- package/vendor/desk/skills/curator/SKILL.md +103 -0
- package/vendor/desk/skills/delightful-decks/SKILL.md +67 -0
- package/vendor/desk/skills/desk-problem/SKILL.md +87 -0
- package/vendor/desk/skills/directory-structure/SKILL.md +169 -0
- package/vendor/desk/skills/doc-review-rigor/SKILL.md +63 -0
- package/vendor/desk/skills/draining-issues/SKILL.md +62 -0
- package/vendor/desk/skills/evaluate-release/SKILL.md +96 -0
- package/vendor/desk/skills/evidence-discipline/SKILL.md +150 -0
- package/vendor/desk/skills/factory-evaluator/SKILL.md +122 -0
- package/vendor/desk/skills/factory-task-context/SKILL.md +116 -0
- package/vendor/desk/skills/factory-work/SKILL.md +16 -0
- package/vendor/desk/skills/fast-honest-ci/SKILL.md +70 -0
- package/vendor/desk/skills/fast-honest-ci/examples.md +49 -0
- package/vendor/desk/skills/first-run-bootstrap/SKILL.md +95 -0
- package/vendor/desk/skills/friction-management/SKILL.md +98 -0
- package/vendor/desk/skills/git-hygiene/SKILL.md +253 -0
- package/vendor/desk/skills/independent-review/SKILL.md +34 -0
- package/vendor/desk/skills/interaction-style/SKILL.md +239 -0
- package/vendor/desk/skills/lesson-capture/SKILL.md +85 -0
- package/vendor/desk/skills/lesson-capture/agents-md-budget.mjs +61 -0
- package/vendor/desk/skills/online-evaluation/SKILL.md +81 -0
- package/vendor/desk/skills/operator-voice-comments/LICENSE-humanize +21 -0
- package/vendor/desk/skills/operator-voice-comments/SKILL.md +90 -0
- package/vendor/desk/skills/operator-voice-comments/human-voice.md +43 -0
- package/vendor/desk/skills/peer-pr-review/SKILL.md +104 -0
- package/vendor/desk/skills/pr-feedback-on-own-pr/SKILL.md +145 -0
- package/vendor/desk/skills/pr-review-interrogation/SKILL.md +121 -0
- package/vendor/desk/skills/pr-reviewer-audit/SKILL.md +68 -0
- package/vendor/desk/skills/pr-reviewer-audit/helpers/audit.py +335 -0
- package/vendor/desk/skills/pr-reviewer-audit/helpers/test_audit.py +486 -0
- package/vendor/desk/skills/pr-self-review/SKILL.md +86 -0
- package/vendor/desk/skills/pr-surface-hygiene/SKILL.md +105 -0
- package/vendor/desk/skills/pr-surface-hygiene/check-visual-proof.cjs +99 -0
- package/vendor/desk/skills/pr-surface-hygiene/repository-setup.md +19 -0
- package/vendor/desk/skills/pr-surface-hygiene/resources/pr-visual-proof.yml +29 -0
- package/vendor/desk/skills/pr-surface-hygiene/resources/pull-request-template.md +5 -0
- package/vendor/desk/skills/preflight-actions/SKILL.md +60 -0
- package/vendor/desk/skills/preview-feedback/SKILL.md +70 -0
- package/vendor/desk/skills/repo-handling/SKILL.md +67 -0
- package/vendor/desk/skills/rnd-lab/SKILL.md +52 -0
- package/vendor/desk/skills/runtime-symptom-investigation/SKILL.md +106 -0
- package/vendor/desk/skills/session-resumption/SKILL.md +126 -0
- package/vendor/desk/skills/session-start/SKILL.md +54 -0
- package/vendor/desk/skills/session-start/details.md +150 -0
- package/vendor/desk/skills/session-start-migrations/README.md +71 -0
- package/vendor/desk/skills/session-start-migrations/SKILL.md +108 -0
- package/vendor/desk/skills/start-task/SKILL.md +88 -0
- package/vendor/desk/skills/task-card-format/SKILL.md +198 -0
- package/vendor/desk/skills/task-lifecycle/SKILL.md +217 -0
- package/vendor/desk/skills/track-card-format/SKILL.md +90 -0
- package/vendor/desk/skills/using-desk/SKILL.md +58 -0
- package/vendor/desk/skills/using-superpowers-with-desk/SKILL.md +156 -0
- package/vendor/desk/skills/work-orchestration/SKILL.md +162 -0
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
export { CHECKS_VERSION, checksText, defineChecks, isChecksReport, printChecks };
|
|
2
|
+
export type { CheckDef, CheckFix, CheckResult, CheckRow, CheckState, Checks, ChecksDef, ChecksReport, ChecksRunOptions, Verdict };
|
|
3
|
+
|
|
4
|
+
// The export list comes first because the shadcn CLI drops comments before a file's
|
|
5
|
+
// first statement, which would take the JSDoc below with it.
|
|
6
|
+
|
|
7
|
+
import type { NextStep } from "./outcome.ts";
|
|
8
|
+
import { preciseFailureProblem } from "./precise-copy.ts";
|
|
9
|
+
import { devCommandsIn } from "./dev-commands.ts";
|
|
10
|
+
import { BASE_EXIT_CODES, FINDINGS_EXIT_CODE, type ExitTable } from "./exit-codes.ts";
|
|
11
|
+
import { createProgress, markOf, nextStepsText, paint, terminalStyle, timeText, type ProgressStream, type TerminalStyle, type Timers } from "./terminal.ts";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A tool's checks, such as a doctor or a self-check, declared once: progress while they run, the verdict first and the
|
|
15
|
+
* results grouped for a person, the same facts as `--json` for an agent, the time taken and the exit code. A problem
|
|
16
|
+
* comes with its fix: the exact command, or the thing to do by hand, and never a developer command or a repository
|
|
17
|
+
* path (ax-dev-commands) unless the fix is marked `sourceCheckout: true`.
|
|
18
|
+
*
|
|
19
|
+
* @claim "never a developer command or a repository path" registry/ouro/ax/checks.test.mts verify:testExists(registry/ouro/ax/checks.test.mts::a fix or next step that asks for a developer command throws, unless it is marked sourceCheckout)
|
|
20
|
+
*/
|
|
21
|
+
type CheckFix = NextStep | { byHand: string; sourceCheckout?: true };
|
|
22
|
+
|
|
23
|
+
/** The version of the report's shape; `--json` carries it as `ax`, as an outcome or a wait does. */
|
|
24
|
+
const CHECKS_VERSION = "checks/1";
|
|
25
|
+
|
|
26
|
+
/** `errored` is a check that threw before finishing, so the tool broke rather than found something. */
|
|
27
|
+
type CheckState = "passed" | "warned" | "failed" | "errored" | "skipped";
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* What a check found. A warning or a failure carries its fix; a check that was not run says why, and `kind` names what
|
|
31
|
+
* it waits on, read after a count ("waiting on something you name", "by hand"), so the not-run line groups them.
|
|
32
|
+
*/
|
|
33
|
+
type CheckResult =
|
|
34
|
+
| { state: "passed"; detail?: string }
|
|
35
|
+
| { state: "warned" | "failed"; detail: string; fix: CheckFix; preciseFailure?: string }
|
|
36
|
+
| { state: "skipped"; detail: string; kind?: string; fix?: CheckFix; preciseFailure?: string };
|
|
37
|
+
|
|
38
|
+
interface CheckDef<C> {
|
|
39
|
+
/** Stable, for `--json` and `needs`. */
|
|
40
|
+
id: string;
|
|
41
|
+
/**
|
|
42
|
+
* What it checks, in words a person reads, named so it reads after "failed:": "Send a picture" or "Cache freshness",
|
|
43
|
+
* not `send_picture` or "The cache is fresh".
|
|
44
|
+
*/
|
|
45
|
+
label: string;
|
|
46
|
+
/** Checks that must pass (or warn) first; when one didn't, this one is not run and says which to fix first. */
|
|
47
|
+
needs?: readonly string[];
|
|
48
|
+
run(context: C): CheckResult | Promise<CheckResult>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
interface ChecksDef<C> {
|
|
52
|
+
/** The command a person runs, as in `app doctor`: the `--verbose` hint uses it, and a fix may not be it. */
|
|
53
|
+
command: string;
|
|
54
|
+
/** What one check is called in the verdict, singular and plural. Default `["check", "checks"]`. */
|
|
55
|
+
noun?: readonly [string, string];
|
|
56
|
+
checks: readonly CheckDef<C>[];
|
|
57
|
+
/**
|
|
58
|
+
* The tool's own exit table (ax-exit-codes), for a tool that gives Ouro AX's findings code another meaning, such as
|
|
59
|
+
* "not running". A finding then exits with the table's `findings` code, and a check that threw with its `error` code.
|
|
60
|
+
* Leave it out for Ouro AX's own `findings` and `error` codes.
|
|
61
|
+
*/
|
|
62
|
+
exits?: ExitTable;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
type Verdict = "passed" | "warned" | "failed" | "errored";
|
|
66
|
+
|
|
67
|
+
interface CheckRow {
|
|
68
|
+
id: string;
|
|
69
|
+
label: string;
|
|
70
|
+
state: CheckState;
|
|
71
|
+
detail: string;
|
|
72
|
+
fix: CheckFix | null;
|
|
73
|
+
kind: string | null;
|
|
74
|
+
durationMs: number;
|
|
75
|
+
/** Why the detail is precise though it is short or holds a vague phrase; the vague-failure check and the X-ray pass it with this reason. */
|
|
76
|
+
preciseFailure?: string;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** One run's facts, the same for the person's text and the agent's `--json`. */
|
|
80
|
+
interface ChecksReport {
|
|
81
|
+
ax: typeof CHECKS_VERSION;
|
|
82
|
+
verdict: Verdict;
|
|
83
|
+
summary: string;
|
|
84
|
+
durationMs: number;
|
|
85
|
+
counts: Record<CheckState, number>;
|
|
86
|
+
rows: CheckRow[];
|
|
87
|
+
next: NextStep[];
|
|
88
|
+
exitCode: number;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
interface ChecksRunOptions {
|
|
92
|
+
/** Where progress goes, normally `process.stderr`; leave it out, or pass `off`, to show nothing. */
|
|
93
|
+
progress?: ProgressStream;
|
|
94
|
+
env?: Readonly<Record<string, string | undefined>>;
|
|
95
|
+
/** Turn progress off, as under `--json` or `--quiet`. */
|
|
96
|
+
off?: boolean;
|
|
97
|
+
timers?: Timers;
|
|
98
|
+
/** Steps to offer after the fixes, such as running the checks that need something the person names. */
|
|
99
|
+
next?: readonly NextStep[];
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
interface Checks<C> {
|
|
103
|
+
readonly def: ChecksDef<C>;
|
|
104
|
+
/** Runs the checks in order, with progress for a slow one, and reports. */
|
|
105
|
+
run(context: C, options?: ChecksRunOptions): Promise<ChecksReport>;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const isCommandFix = (fix: CheckFix): fix is NextStep => "command" in fix;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Declares a tool's checks once: from this one definition come the progress while they run, the verdict and the
|
|
112
|
+
* grouped results for a person, the `--json` for an agent, the timing and the exit code. Throws at definition time on
|
|
113
|
+
* an empty list, a repeated id, an empty label or a `needs` that names no earlier check, and at run time when a warning or failure
|
|
114
|
+
* has no fix, or its fix is the command just run, so a tool's own tests catch both. A fix or a next step that asks for
|
|
115
|
+
* a developer command or a repository path throws too, so a doctor never tells a person to run a repository script.
|
|
116
|
+
* Given the tool's own exit table as `exits`, a finding exits with that table's `findings` code, and a table without
|
|
117
|
+
* one is refused, so every code the checks give is one the tool's help documents.
|
|
118
|
+
*
|
|
119
|
+
* @claim "a finding exits with that table's `findings` code" registry/ouro/ax/checks.test.mts verify:testExists(registry/ouro/ax/checks.test.mts::a tool's own exit table gives a finding its findings code, wherever the table puts it)
|
|
120
|
+
* @claim "a table without one is refused" registry/ouro/ax/checks.test.mts verify:testExists(registry/ouro/ax/checks.test.mts::a tool's exit table without a findings code is refused, naming the code that took 3)
|
|
121
|
+
* @claim "an empty list, a repeated id, an empty label or a `needs` that names no earlier check" registry/ouro/ax/checks.test.mts verify:testExists(registry/ouro/ax/checks.test.mts::defineChecks refuses an empty list, a repeated id, an empty label and a needs that names no earlier check)
|
|
122
|
+
* @claim "at run time when a warning or failure has no fix, or its fix is the command just run" registry/ouro/ax/checks.test.mts verify:testExists(registry/ouro/ax/checks.test.mts::a warning or failure without a fix, or with the command just run as its fix, fails the run)
|
|
123
|
+
* @claim "A fix or a next step that asks for a developer command or a repository path throws too" registry/ouro/ax/checks.test.mts verify:testExists(registry/ouro/ax/checks.test.mts::a fix or next step that asks for a developer command throws, unless it is marked sourceCheckout)
|
|
124
|
+
* @example
|
|
125
|
+
* const doctor = defineChecks({
|
|
126
|
+
* command: "notes doctor",
|
|
127
|
+
* checks: [
|
|
128
|
+
* { id: "store", label: "Notes file", run: () => ({ state: "passed" }) },
|
|
129
|
+
* { id: "sync", label: "Last sync", needs: ["store"], run: () => ({ state: "warned", detail: "last synced 3 days ago", fix: { command: "notes sync", why: "Sync now" } }) },
|
|
130
|
+
* ],
|
|
131
|
+
* });
|
|
132
|
+
* const report = await doctor.run(context, { progress: process.stderr, env: process.env });
|
|
133
|
+
* // A tool whose exit 3 means "not running" puts findings after its own codes:
|
|
134
|
+
* const exits = defineExitCodes([...BASE_EXIT_CODES, { code: 3, name: "unavailable", short: "not running", meaning: "not running: open the app" }, { ...FINDINGS_EXIT_CODE, code: 4 }]);
|
|
135
|
+
* defineChecks({ command: "chat doctor", exits, checks }); // a finding exits 4
|
|
136
|
+
*/
|
|
137
|
+
function defineChecks<C>(def: ChecksDef<C>): Checks<C> {
|
|
138
|
+
if (!def.checks.length) throw new Error(`defineChecks: ${def.command} declares no checks. Fix: declare the checks it runs.`);
|
|
139
|
+
const seen = new Set<string>();
|
|
140
|
+
for (const check of def.checks) {
|
|
141
|
+
if (seen.has(check.id)) throw new Error(`defineChecks: the id ${check.id} is used twice. Fix: give each check its own id.`);
|
|
142
|
+
if (!check.label.trim()) throw new Error(`defineChecks: ${check.id} has no label. Fix: name what it checks, in words a person reads.`);
|
|
143
|
+
for (const need of check.needs ?? []) if (!seen.has(need)) throw new Error(`defineChecks: ${check.id} needs ${need}, which is not an earlier check. Fix: list ${need} before ${check.id}.`);
|
|
144
|
+
seen.add(check.id);
|
|
145
|
+
}
|
|
146
|
+
const exits = exitsOf(def.command, def.exits);
|
|
147
|
+
return Object.freeze({ def, run: (context: C, options: ChecksRunOptions = {}) => runChecks(def, exits, context, options) });
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const wallClock = (): Pick<Timers, "now"> => ({ now: () => Date.now() });
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* The exit code for a verdict: 0 when nothing failed, warnings included; the declared `findings` code when a check
|
|
154
|
+
* found a problem; and the base `error` code when a check threw before finishing, since then the tool broke.
|
|
155
|
+
*
|
|
156
|
+
* @claim "the declared `findings` code when a check found a problem" registry/ouro/ax/checks.test.mts verify:testExists(registry/ouro/ax/checks.test.mts::findings exit with the declared findings code and a check that couldn't run exits 1, never the same code)
|
|
157
|
+
*/
|
|
158
|
+
const EXITS: Readonly<Record<Verdict, number>> = Object.freeze({ passed: 0, warned: 0, failed: FINDINGS_EXIT_CODE.code, errored: BASE_EXIT_CODES[1]!.code });
|
|
159
|
+
|
|
160
|
+
/** The exit codes under the tool's own table, checked when the checks are declared. */
|
|
161
|
+
function exitsOf(command: string, table: ExitTable | undefined): Readonly<Record<Verdict, number>> {
|
|
162
|
+
if (!table) return EXITS;
|
|
163
|
+
if (!table.has(FINDINGS_EXIT_CODE.name)) {
|
|
164
|
+
const taken = table.codes.find((entry) => entry.code === FINDINGS_EXIT_CODE.code);
|
|
165
|
+
const clash = taken ? ` Its code ${taken.code} is "${taken.name}", so Ouro AX's findings code can't be used.` : "";
|
|
166
|
+
throw new Error(`defineChecks: ${command}'s exit table has no "findings" code for a check that finds a problem.${clash} Fix: add { ...FINDINGS_EXIT_CODE, code: ${table.codes.length} } to the table.`);
|
|
167
|
+
}
|
|
168
|
+
return Object.freeze({ passed: 0, warned: 0, failed: table.code(FINDINGS_EXIT_CODE.name), errored: table.code(BASE_EXIT_CODES[1]!.name) });
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** What a row records: a check's result, or what it threw. */
|
|
172
|
+
type RowResult = CheckResult | { state: "errored"; detail: string; fix: CheckFix };
|
|
173
|
+
|
|
174
|
+
async function runChecks<C>(def: ChecksDef<C>, exits: Readonly<Record<Verdict, number>>, context: C, options: ChecksRunOptions): Promise<ChecksReport> {
|
|
175
|
+
const clock = options.timers ?? wallClock();
|
|
176
|
+
const progress = options.progress
|
|
177
|
+
? createProgress(options.progress, { env: options.env ?? {}, off: options.off ?? false, ...(options.timers ? { timers: options.timers } : {}) })
|
|
178
|
+
: null;
|
|
179
|
+
const began = clock.now();
|
|
180
|
+
const rows: CheckRow[] = [];
|
|
181
|
+
const byId = new Map<string, CheckRow>();
|
|
182
|
+
try {
|
|
183
|
+
for (const [i, check] of def.checks.entries()) {
|
|
184
|
+
const unmet = (check.needs ?? []).map((id) => byId.get(id)!).find((r) => r.state !== "passed" && r.state !== "warned");
|
|
185
|
+
const why = { skipped: "was not run", errored: "threw before finishing", failed: "failed" } as const;
|
|
186
|
+
let result: RowResult;
|
|
187
|
+
const start = clock.now();
|
|
188
|
+
if (unmet) {
|
|
189
|
+
result = { state: "skipped", detail: `not checked: ${unmet.label} ${why[unmet.state as keyof typeof why]}`, kind: "after an earlier problem" };
|
|
190
|
+
} else {
|
|
191
|
+
progress?.start(check.label, { index: i + 1, total: def.checks.length });
|
|
192
|
+
try {
|
|
193
|
+
result = await check.run(context);
|
|
194
|
+
} catch (error) {
|
|
195
|
+
result = {
|
|
196
|
+
state: "errored",
|
|
197
|
+
detail: error instanceof Error ? error.message : String(error),
|
|
198
|
+
fix: { byHand: "Report this error to the tool's maintainers; the check itself broke." },
|
|
199
|
+
};
|
|
200
|
+
} finally {
|
|
201
|
+
progress?.stop();
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
const row = rowOf(def, check, result, clock.now() - start);
|
|
205
|
+
rows.push(row);
|
|
206
|
+
byId.set(check.id, row);
|
|
207
|
+
}
|
|
208
|
+
} finally {
|
|
209
|
+
progress?.stop();
|
|
210
|
+
}
|
|
211
|
+
const durationMs = clock.now() - began;
|
|
212
|
+
const counts: Record<CheckState, number> = { passed: 0, warned: 0, failed: 0, errored: 0, skipped: 0 };
|
|
213
|
+
for (const r of rows) counts[r.state]++;
|
|
214
|
+
const verdict: Verdict = counts.errored ? "errored" : counts.failed ? "failed" : counts.warned ? "warned" : "passed";
|
|
215
|
+
const problems = rows.filter((r) => r.state === "failed" || r.state === "warned" || r.state === "errored");
|
|
216
|
+
const fixes = problems.flatMap((r) => (isCommandFix(r.fix!) ? [r.fix as NextStep] : []));
|
|
217
|
+
const again = problems.length ? [{ command: def.command, why: "Check again once it's fixed" }] : [];
|
|
218
|
+
const dev = devCommandsIn(options.next ?? [])[0];
|
|
219
|
+
if (dev) throw new Error(`${def.command}: the next step \`${dev.text}\` asks for ${dev.match}, which only works in a source checkout. Fix: name the command the installed tool runs, or mark the step sourceCheckout: true.`);
|
|
220
|
+
const next = [...fixes, ...(options.next ?? []), ...again].filter((s, i, all) => all.findIndex((t) => t.command === s.command) === i);
|
|
221
|
+
return { ax: CHECKS_VERSION, verdict, summary: summaryOf(def, rows, counts, verdict, durationMs), durationMs, counts, rows, next, exitCode: exits[verdict] };
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function rowOf<C>(def: ChecksDef<C>, check: CheckDef<C>, result: RowResult, durationMs: number): CheckRow {
|
|
225
|
+
const fix = "fix" in result && result.fix ? result.fix : null;
|
|
226
|
+
if ((result.state === "failed" || result.state === "warned") && !fix) {
|
|
227
|
+
throw new Error(`${def.command}: ${check.id} ${result.state} without a fix. Fix: give it the command that fixes it, or { byHand } when no command can.`);
|
|
228
|
+
}
|
|
229
|
+
if (fix && isCommandFix(fix) && fix.command.trim() === def.command.trim()) {
|
|
230
|
+
throw new Error(`${def.command}: ${check.id}'s fix is \`${def.command}\`, the command just run. Fix: name the command that changes something.`);
|
|
231
|
+
}
|
|
232
|
+
const precise = "preciseFailure" in result ? { preciseFailure: result.preciseFailure } : {};
|
|
233
|
+
if (preciseFailureProblem(precise)) throw new Error(`${def.command}: ${check.id}'s ${preciseFailureProblem(precise)}. Fix: say why the detail is precise, or leave preciseFailure out.`);
|
|
234
|
+
const dev = devCommandsIn(fix)[0];
|
|
235
|
+
if (dev) throw new Error(`${def.command}: ${check.id}'s fix \`${dev.text}\` asks for ${dev.match}, which only works in a source checkout. Fix: name the command the installed tool runs, or mark the fix sourceCheckout: true.`);
|
|
236
|
+
return { id: check.id, label: check.label, state: result.state, detail: result.detail ?? "", fix, kind: result.state === "skipped" ? (result.kind ?? null) : null, durationMs, ...(precise.preciseFailure ? { preciseFailure: precise.preciseFailure.trim() } : {}) };
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/** A check that ran this long shows its time beside it without `verbose`. */
|
|
240
|
+
const SLOW_MS = 1000;
|
|
241
|
+
|
|
242
|
+
const plural = (n: number, [one, many]: readonly [string, string]) => `${n} ${n === 1 ? one : many}`;
|
|
243
|
+
|
|
244
|
+
/** The first labels, then how many more. */
|
|
245
|
+
const someOf = (labels: readonly string[]) => (labels.length > 3 ? `${labels.slice(0, 3).join(", ")} and ${labels.length - 3} more` : labels.join(", "));
|
|
246
|
+
|
|
247
|
+
/** How long the run took, for the verdict: "under 0.1s" rather than "0.0s". */
|
|
248
|
+
const tookText = (ms: number) => (ms < 100 ? "under 0.1s" : timeText(ms));
|
|
249
|
+
|
|
250
|
+
function summaryOf<C>(def: ChecksDef<C>, rows: readonly CheckRow[], counts: Record<CheckState, number>, verdict: Verdict, ms: number): string {
|
|
251
|
+
const noun = def.noun ?? ["check", "checks"];
|
|
252
|
+
const all = plural(rows.length, noun);
|
|
253
|
+
const took = tookText(ms);
|
|
254
|
+
const labels = (state: CheckState) => someOf(rows.filter((r) => r.state === state).map((r) => r.label));
|
|
255
|
+
const notRun = counts.skipped ? `, ${counts.skipped} not run` : "";
|
|
256
|
+
const warned = counts.warned ? `, ${counts.warned} warned` : "";
|
|
257
|
+
const failed = counts.failed ? `, ${counts.failed} failed` : "";
|
|
258
|
+
const says = { failed: "failed", warned: "needs a look", errored: "threw before finishing" } as const;
|
|
259
|
+
if (rows.length === 1 && verdict !== "passed") return `The ${noun[0]} ${says[verdict]}: ${labels(verdict)}, in ${took}.`;
|
|
260
|
+
if (verdict === "errored") return `${counts.errored} of ${all} threw before finishing: ${labels("errored")}. ${counts.passed} passed${failed}${warned}${notRun}, in ${took}.`;
|
|
261
|
+
if (verdict === "failed") return `${counts.failed} of ${all} failed: ${labels("failed")}. ${counts.passed} passed${warned}${notRun}, in ${took}.`;
|
|
262
|
+
if (verdict === "warned") return `${counts.warned} of ${all} ${counts.warned === 1 ? "needs" : "need"} a look: ${labels("warned")}. ${counts.passed} passed${notRun}, in ${took}.`;
|
|
263
|
+
if (!counts.passed) return `${rows.length === 1 ? `The ${noun[0]} was not run` : `None of the ${plural(rows.length, noun)} were run`}, in ${took}.`;
|
|
264
|
+
if (counts.skipped) return `${counts.passed} of ${all} passed${notRun}, in ${took}.`;
|
|
265
|
+
return `${rows.length === 1 ? `The ${noun[0]}` : rows.length === 2 ? `Both ${noun[1]}` : `All ${all}`} passed in ${took}.`;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/** What the checks not run wait on, the bigger groups first, or "" when they don't say. */
|
|
269
|
+
function notRunLine(rows: readonly CheckRow[]): string {
|
|
270
|
+
const kinds = new Map<string, number>();
|
|
271
|
+
for (const r of rows) if (r.state === "skipped" && r.kind) kinds.set(r.kind, (kinds.get(r.kind) ?? 0) + 1);
|
|
272
|
+
const groups = [...kinds.entries()].sort((a, b) => b[1] - a[1]).map(([kind, n]) => `${n} ${kind}`);
|
|
273
|
+
return groups.length ? `Not run: ${groups.join(", ")}` : "";
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* A fix under its row: the reason, then the command alone on its line so it can be copied whole; or the step by hand.
|
|
278
|
+
* A check not run says how to run it, without the word "Fix", since nothing broke.
|
|
279
|
+
*/
|
|
280
|
+
function fixLines(fix: CheckFix, style: TerminalStyle, broke: boolean): string[] {
|
|
281
|
+
const lead = broke ? "Fix: " : "";
|
|
282
|
+
return isCommandFix(fix) ? [`${lead}${fix.why}`, ` ${paint(style).cyan(fix.command)}`] : [`${lead}${fix.byHand}`];
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* The report for a person: the verdict on the first line, then the results grouped (what failed, what warned, what
|
|
287
|
+
* was not run, and what passed with `verbose`), each problem with its fix, then the next steps. On success it prints
|
|
288
|
+
* the verdict and what is left to act on, and with `verbose` every check and its time. Off a terminal the marks are
|
|
289
|
+
* words and there is no colour, so the first line reads `FAIL 1 of 12 checks failed: …`.
|
|
290
|
+
*
|
|
291
|
+
* @claim "the verdict on the first line" registry/ouro/ax/checks.test.mts verify:testExists(registry/ouro/ax/checks.test.mts::the text puts the verdict first, then failures with their fixes, warnings, what was not run, and the next steps)
|
|
292
|
+
* @claim "On success it prints the verdict and what is left to act on" registry/ouro/ax/checks.test.mts verify:testExists(registry/ouro/ax/checks.test.mts::quiet on success: the verdict alone, and every check with its time under --verbose)
|
|
293
|
+
* @claim "Off a terminal the marks are words and there is no colour" registry/ouro/ax/checks.test.mts verify:testExists(registry/ouro/ax/checks.test.mts::off a terminal the report is in words, and under NO_COLOR it has no escape codes)
|
|
294
|
+
*/
|
|
295
|
+
function checksText(report: ChecksReport, style: TerminalStyle, options: { verbose?: boolean; command?: string } = {}): string {
|
|
296
|
+
const p = paint(style);
|
|
297
|
+
const time = (r: CheckRow) => (r.durationMs >= SLOW_MS || (options.verbose && r.durationMs >= 100) ? ` ${p.dim(timeText(r.durationMs))}` : "");
|
|
298
|
+
const lead = report.verdict === "passed" && !report.counts.passed ? "skipped" : report.verdict;
|
|
299
|
+
const out: string[] = [`${markOf(lead, style)} ${p.bold(report.summary)}`];
|
|
300
|
+
const waits = options.verbose || report.rows.every((r) => r.state !== "skipped" || r.fix) ? "" : notRunLine(report.rows);
|
|
301
|
+
if (waits) out.push(` ${waits}`);
|
|
302
|
+
const section = (title: string, rows: readonly CheckRow[], body: (r: CheckRow) => string[]) => {
|
|
303
|
+
if (!rows.length) return;
|
|
304
|
+
out.push("", p.bold(title), ...rows.flatMap((r) => [` ${markOf(r.state, style)} ${r.label}${time(r)}`, ...body(r).map((l) => ` ${l}`)]));
|
|
305
|
+
};
|
|
306
|
+
const problem = (r: CheckRow) => [...(r.detail ? [r.detail] : []), ...(r.fix ? fixLines(r.fix, style, r.state !== "skipped") : [])];
|
|
307
|
+
section("Threw before finishing", report.rows.filter((r) => r.state === "errored"), problem);
|
|
308
|
+
section("Found a problem", report.rows.filter((r) => r.state === "failed"), problem);
|
|
309
|
+
section("Warnings", report.rows.filter((r) => r.state === "warned"), problem);
|
|
310
|
+
const skipped = report.rows.filter((r) => r.state === "skipped");
|
|
311
|
+
section("Still to check", options.verbose ? skipped : skipped.filter((r) => r.fix), problem);
|
|
312
|
+
if (options.verbose) section("Passed", report.rows.filter((r) => r.state === "passed"), (r) => (r.detail ? [p.dim(r.detail)] : []));
|
|
313
|
+
const hidden = skipped.some((r) => !r.fix) || (report.verdict !== "passed" && report.counts.passed > 0);
|
|
314
|
+
const hint = !options.verbose && options.command && hidden ? [{ command: `${options.command} --verbose`, why: "See every check" }] : [];
|
|
315
|
+
const shown = new Set(report.rows.flatMap((r) => (r.fix && isCommandFix(r.fix) ? [r.fix.command] : [])));
|
|
316
|
+
const next = [...report.next.filter((s) => !shown.has(s.command)), ...hint];
|
|
317
|
+
const steps = nextStepsText(next, style);
|
|
318
|
+
if (steps) out.push("", steps);
|
|
319
|
+
return out.join("\n");
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/** Whether a value is a checks report: what the X-ray looks for in a read's `--json`. */
|
|
323
|
+
function isChecksReport(value: unknown): value is ChecksReport {
|
|
324
|
+
if (typeof value !== "object" || value === null) return false;
|
|
325
|
+
const v = value as Record<string, unknown>;
|
|
326
|
+
return v["ax"] === CHECKS_VERSION && typeof v["verdict"] === "string" && typeof v["summary"] === "string" && typeof v["counts"] === "object" && Array.isArray(v["rows"]);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Prints a report the way the kit's commands print a result: `--json` as one JSON document, otherwise the text for the
|
|
331
|
+
* stream it goes to, each with one trailing newline. Returns the exit code.
|
|
332
|
+
*
|
|
333
|
+
* @claim "each with one trailing newline" registry/ouro/ax/checks.test.mts verify:testExists(registry/ouro/ax/checks.test.mts::printChecks writes the JSON or the text with one trailing newline, and returns the exit code)
|
|
334
|
+
* @claim "Returns the exit code" registry/ouro/ax/checks.test.mts verify:testExists(registry/ouro/ax/checks.test.mts::printChecks writes the JSON or the text with one trailing newline, and returns the exit code)
|
|
335
|
+
*/
|
|
336
|
+
function printChecks(
|
|
337
|
+
report: ChecksReport,
|
|
338
|
+
io: { stdout: { write(s: string): unknown; isTTY?: boolean }; env: Readonly<Record<string, string | undefined>> },
|
|
339
|
+
options: { json?: boolean; verbose?: boolean; command?: string } = {},
|
|
340
|
+
): number {
|
|
341
|
+
io.stdout.write(options.json ? `${JSON.stringify(report, null, 2)}\n` : `${checksText(report, terminalStyle(io.stdout, io.env), options)}\n`);
|
|
342
|
+
return report.exitCode;
|
|
343
|
+
}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
export { dispatch, isEmptyResult, printResult, quietPipes, runCli };
|
|
2
|
+
export type { CliIo, RunOptions };
|
|
3
|
+
|
|
4
|
+
// The export list comes first because the shadcn CLI drops comments before a file's
|
|
5
|
+
// first statement, which would take the JSDoc below with it.
|
|
6
|
+
|
|
7
|
+
import { checksText, isChecksReport } from "./checks.ts";
|
|
8
|
+
import { doctorText, isDoctorReport } from "./doctor.ts";
|
|
9
|
+
import { checkOwner, flagsOf, findCommand, invocation, parse, type ArgSpec, type Cli, type CommandDef, type Input, type InputValue, type Parsed, type RunContext } from "./ax-command.ts";
|
|
10
|
+
import { DRY_RUN_FLAG } from "./effects.ts";
|
|
11
|
+
import { AxError, errorJson, errorLine, errorMessage, isAxError, type AxErrorShape } from "./problem.ts";
|
|
12
|
+
import { commandManifest, helpJson, renderCommand, renderOverview, type OverviewOptions } from "./help.ts";
|
|
13
|
+
import { isOutcome, outcome, outcomeExit, outcomeText, type Outcome } from "./outcome.ts";
|
|
14
|
+
import { render } from "./output.ts";
|
|
15
|
+
import { terminalStyle } from "./terminal.ts";
|
|
16
|
+
import { isWait, waitExit, waitText } from "./wait.ts";
|
|
17
|
+
import { createVoice, type Voice, type VoiceMemory, type VoiceSlot } from "./voice.ts";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The whole front door for a tool built on the kit: parse, help, run (or, on `--dry-run`, plan), print the result as
|
|
21
|
+
* text or `--json`, and turn every failure into the one error line and its exit code. An outcome or a wait sets the
|
|
22
|
+
* exit code from its state.
|
|
23
|
+
*
|
|
24
|
+
* @claim "turn every failure into" registry/ouro/ax/cli.test.mts verify:testExists(registry/ouro/ax/cli.test.mts::an error is one stderr line with the fix and its exit code; --json also prints the error shape)
|
|
25
|
+
*/
|
|
26
|
+
interface CliIo {
|
|
27
|
+
/** `isTTY` says stdout is a terminal, the one place a voice line may print. */
|
|
28
|
+
stdout: { write(s: string): unknown; isTTY?: boolean };
|
|
29
|
+
stderr: { write(s: string): unknown };
|
|
30
|
+
stdin?: AsyncIterable<string | Uint8Array> | Iterable<string | Uint8Array>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface RunOptions {
|
|
34
|
+
overview?: OverviewOptions;
|
|
35
|
+
/** Help topics that are not commands, as finished text. */
|
|
36
|
+
topics?: Readonly<Record<string, string>>;
|
|
37
|
+
/** The environment the voice reads `CI` from; defaults to the process's. */
|
|
38
|
+
env?: Readonly<Record<string, string | undefined>>;
|
|
39
|
+
/** Keeps the last variant of a voice slot between runs, so variants rotate across runs too. */
|
|
40
|
+
voiceMemory?: VoiceMemory;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async function readAll(stream: AsyncIterable<string | Uint8Array> | Iterable<string | Uint8Array> | undefined): Promise<string> {
|
|
44
|
+
if (!stream) return "";
|
|
45
|
+
let text = "";
|
|
46
|
+
const decoder = new TextDecoder();
|
|
47
|
+
for await (const chunk of stream) text += typeof chunk === "string" ? chunk : decoder.decode(chunk, { stream: true });
|
|
48
|
+
return text + decoder.decode();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Replaces the one "-" value with stdin's text; a second "-" is a usage error. */
|
|
52
|
+
async function withStdin(cli: Cli, cmd: CommandDef, input: Input, stdin: () => Promise<string>): Promise<Input> {
|
|
53
|
+
const out: Record<string, InputValue> = { ...input };
|
|
54
|
+
const stdinNames = [...(cmd.args ?? []).filter((a: ArgSpec) => a.stdin).map((a) => a.name), ...Object.entries(flagsOf(cli, cmd)).filter(([, s]) => s.stdin).map(([n]) => n)];
|
|
55
|
+
const dashes = stdinNames.filter((n) => out[n] === "-");
|
|
56
|
+
if (dashes.length > 1) throw new AxError({ code: "two-stdin", exit: cli.exits.code("usage"), thing: cmd.name, problem: `only one "-" (stdin) per command, and ${dashes.map((n) => n).join(" and ")} both ask for it`, fix: `${invocation(cli, cmd)} ... with the shorter text on the command line` });
|
|
57
|
+
for (const n of dashes) out[n] = (await stdin()).replace(/\r?\n$/, "");
|
|
58
|
+
return out;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Runs a parsed command as runCli does, for a tool that reads stdin and prints errors its own way: on `--dry-run` the
|
|
63
|
+
* command's plan(), refused ("no-preview") when it has none, else its run(). A self-scoped command is refused first
|
|
64
|
+
* when its item is not the calling agent's (`checkOwner`). It prints nothing and reads no stdin.
|
|
65
|
+
*
|
|
66
|
+
* @claim "It prints nothing and reads" registry/ouro/ax/cli.test.mts verify:testExists(registry/ouro/ax/cli.test.mts::dispatch runs the plan or run() with the tool's own context, and prints nothing)
|
|
67
|
+
* @claim "on `--dry-run` the command's plan()" registry/ouro/ax/cli.test.mts verify:testExists(registry/ouro/ax/cli.test.mts::dispatch runs the plan or run() with the tool's own context, and prints nothing)
|
|
68
|
+
*/
|
|
69
|
+
async function dispatch<C extends RunContext>(cli: Cli<C>, parsed: Parsed, ctx: C): Promise<unknown> {
|
|
70
|
+
const cmd = parsed.command as CommandDef<unknown, C>;
|
|
71
|
+
const dryRun = parsed.input[DRY_RUN_FLAG] === true;
|
|
72
|
+
if (dryRun && !cmd.plan) throw new AxError({ code: "no-preview", exit: cli.exits.code("usage"), thing: `${cmd.name} --${DRY_RUN_FLAG}`, problem: "this command has no preview, so nothing was done", fix: null });
|
|
73
|
+
if (!dryRun && !cmd.run) throw new AxError({ code: "not-runnable", exit: cli.exits.code("error"), thing: cmd.name, problem: "this command has no run() in its definition", fix: null });
|
|
74
|
+
await checkOwner(cli, cmd, parsed.input, ctx);
|
|
75
|
+
return dryRun ? cmd.plan!(parsed.input, ctx) : cmd.run!(parsed.input, ctx);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Whether a result is an empty list: an empty array, or a page (`{ items }`) whose items are empty. */
|
|
79
|
+
function isEmptyResult(result: unknown): boolean {
|
|
80
|
+
if (Array.isArray(result)) return result.length === 0;
|
|
81
|
+
const items = typeof result === "object" && result !== null ? (result as { items?: unknown }).items : undefined;
|
|
82
|
+
return Array.isArray(items) && items.length === 0;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Prints a command's result as runCli does and returns the exit code: an outcome by its state (a refusal or failure in
|
|
87
|
+
* text is the one error line on stderr), a wait by its state, a checks report (ax-checks) by its verdict, with its text
|
|
88
|
+
* styled for stdout and every check under `--verbose`, anything else as its text or `--json`, with the exit code its
|
|
89
|
+
* command's `exit` names (0 when it names none). A report whose checks
|
|
90
|
+
* all ran and passed may get the voice's `healthy` line. Given the
|
|
91
|
+
* process's voice, a voice line may follow the text on stdout, never before it: after a done or queued outcome, an
|
|
92
|
+
* empty list, or the summary command.
|
|
93
|
+
*
|
|
94
|
+
* @claim "never before it" registry/ouro/ax/cli.test.mts verify:testExists(registry/ouro/ax/cli.test.mts::a voice line follows the fact it adds to: a done outcome, an empty list, the summary, and one celebration at most)
|
|
95
|
+
* @claim "may get the voice's `healthy` line" registry/ouro/ax/cli.test.mts verify:testExists(registry/ouro/ax/cli.test.mts::a command that returns a checks report prints its verdict first, styled for stdout, and exits with its code)
|
|
96
|
+
* @claim "a checks report (ax-checks) by its verdict" registry/ouro/ax/cli.test.mts verify:testExists(registry/ouro/ax/cli.test.mts::a command that returns a checks report prints its verdict first, styled for stdout, and exits with its code)
|
|
97
|
+
*/
|
|
98
|
+
function printResult(
|
|
99
|
+
cli: Cli,
|
|
100
|
+
cmd: CommandDef,
|
|
101
|
+
input: Input,
|
|
102
|
+
result: unknown,
|
|
103
|
+
json: boolean,
|
|
104
|
+
io: Pick<CliIo, "stdout" | "stderr">,
|
|
105
|
+
voice?: Voice,
|
|
106
|
+
env: Readonly<Record<string, string | undefined>> = processEnv(),
|
|
107
|
+
): number {
|
|
108
|
+
const say = (slot: VoiceSlot, outcome?: Outcome) => {
|
|
109
|
+
const line = json || !voice ? null : voice.line(slot, outcome);
|
|
110
|
+
if (line !== null) io.stdout.write(`${line}\n`);
|
|
111
|
+
};
|
|
112
|
+
if (isOutcome(result)) {
|
|
113
|
+
const exit = outcomeExit(result, cli.exits, cli.outcomeExits);
|
|
114
|
+
if (!json && result.error && (result.state === "refused" || result.state === "failed")) io.stderr.write(`${outcomeText(result, cli.name)}\n`);
|
|
115
|
+
else {
|
|
116
|
+
io.stdout.write(render(result, { json, text: (o) => outcomeText(o, cli.name) }));
|
|
117
|
+
if (result.state === "done" || result.state === "queued") say("done", result);
|
|
118
|
+
}
|
|
119
|
+
return exit;
|
|
120
|
+
}
|
|
121
|
+
if (isChecksReport(result)) {
|
|
122
|
+
const style = terminalStyle(io.stdout, env);
|
|
123
|
+
// The --verbose hint is offered only by a command that takes the flag.
|
|
124
|
+
const command = "verbose" in flagsOf(cli, cmd) ? { command: invocation(cli, cmd) } : {};
|
|
125
|
+
const options = { ...command, verbose: input["verbose"] === true };
|
|
126
|
+
io.stdout.write(render(result, { json, text: (r) => (isDoctorReport(r) ? doctorText(r, style, options) : checksText(r, style, options)) }));
|
|
127
|
+
if (result.verdict === "passed" && result.counts.passed && !result.counts.skipped) say("healthy");
|
|
128
|
+
return result.exitCode;
|
|
129
|
+
}
|
|
130
|
+
const own = cmd.text;
|
|
131
|
+
const text = own ? (r: unknown) => own.call(cmd, r, input) : isWait(result) ? () => waitText(result) : undefined;
|
|
132
|
+
const exit = isWait(result) ? waitExit(result, cli.exits, cli.waitExits) : dataExit(cli, cmd, result, input);
|
|
133
|
+
io.stdout.write(render(result, { json, ...(text ? { text } : {}) }));
|
|
134
|
+
if (isWait(result)) {
|
|
135
|
+
if (result.state === "satisfied") say("waited");
|
|
136
|
+
return exit;
|
|
137
|
+
}
|
|
138
|
+
if (isEmptyResult(result)) say("empty");
|
|
139
|
+
else if (cmd.summarizes) say("summary");
|
|
140
|
+
return exit;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* The exit code a data result's command names in the tool's table, or 0 when it names none.
|
|
145
|
+
*
|
|
146
|
+
* @claim "or 0 when it names none" registry/ouro/ax/cli.test.mts verify:testExists(registry/ouro/ax/cli.test.mts::a data result exits with the code its command names in the tool's table, and --json prints the data unchanged)
|
|
147
|
+
*/
|
|
148
|
+
function dataExit(cli: Cli, cmd: CommandDef, result: unknown, input: Input): number {
|
|
149
|
+
if (!cmd.exit) return 0;
|
|
150
|
+
const name = cmd.exit(result, input);
|
|
151
|
+
if (!cli.exits.has(name)) throw new AxError({ code: "bad-exit", exit: cli.exits.code("error"), thing: cmd.name, problem: `its exit "${name}" is not one of the tool's exit codes`, fix: `name one of ${cli.exits.codes.map((code) => code.name).join(", ")}` });
|
|
152
|
+
return cli.exits.code(name);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** The process's environment, read without Node's types so the kit also type-checks without them. */
|
|
156
|
+
// Node always has a process; the fallback is for a runtime without one.
|
|
157
|
+
/* node:coverage ignore next */
|
|
158
|
+
const processEnv = (): Readonly<Record<string, string | undefined>> => (globalThis as unknown as { process?: { env?: Record<string, string | undefined> } }).process?.env ?? {};
|
|
159
|
+
|
|
160
|
+
async function runCli(cli: Cli, argv: readonly string[], io: CliIo, options: RunOptions = {}): Promise<number> {
|
|
161
|
+
let json = argv.includes("--json");
|
|
162
|
+
try {
|
|
163
|
+
const parsed = parse(cli, argv);
|
|
164
|
+
json = parsed.json;
|
|
165
|
+
const voice = createVoice(cli.voice, {
|
|
166
|
+
tty: io.stdout.isTTY === true,
|
|
167
|
+
json,
|
|
168
|
+
quiet: parsed.kind === "run" ? parsed.input["quiet"] === true : argv.includes("--quiet"),
|
|
169
|
+
env: options.env ?? processEnv(),
|
|
170
|
+
...(options.voiceMemory ? { memory: options.voiceMemory } : {}),
|
|
171
|
+
});
|
|
172
|
+
if (parsed.kind === "help") {
|
|
173
|
+
const topic = parsed.topic;
|
|
174
|
+
if (topic === undefined) {
|
|
175
|
+
if (parsed.json) io.stdout.write(`${JSON.stringify(helpJson(cli), null, 2)}\n`);
|
|
176
|
+
else {
|
|
177
|
+
const banner = voice.line("banner");
|
|
178
|
+
io.stdout.write(`${banner === null ? "" : `${banner}\n`}${renderOverview(cli, options.overview)}`);
|
|
179
|
+
}
|
|
180
|
+
return 0;
|
|
181
|
+
}
|
|
182
|
+
const found = parsed.command ? { command: parsed.command } : cli.single ? null : findCommand(cli, topic.split(" "));
|
|
183
|
+
if (found) {
|
|
184
|
+
io.stdout.write(parsed.json ? `${JSON.stringify(commandManifest(cli, found.command), null, 2)}\n` : renderCommand(cli, found.command));
|
|
185
|
+
return 0;
|
|
186
|
+
}
|
|
187
|
+
if (Object.hasOwn(cli.personOnly, topic)) {
|
|
188
|
+
const p = cli.personOnly[topic]!;
|
|
189
|
+
io.stdout.write(parsed.json ? `${JSON.stringify({ name: topic, reason: p.reason, how: p.how }, null, 2)}\n` : `${cli.name} ${topic}: only the person does this, never you.\n Why: ${p.reason}\n How the person does it: ${p.how}\n`);
|
|
190
|
+
return 0;
|
|
191
|
+
}
|
|
192
|
+
const text = options.topics && Object.hasOwn(options.topics, topic) ? options.topics[topic] : undefined;
|
|
193
|
+
if (text !== undefined) {
|
|
194
|
+
io.stdout.write(text.endsWith("\n") ? text : `${text}\n`);
|
|
195
|
+
return 0;
|
|
196
|
+
}
|
|
197
|
+
throw new AxError({ code: "unknown-topic", exit: cli.exits.code("usage"), thing: "help", problem: `there is no help for "${topic}"`, fix: `${cli.name} --help` });
|
|
198
|
+
}
|
|
199
|
+
const cmd = parsed.command;
|
|
200
|
+
let taken = false;
|
|
201
|
+
const stdin = async () => {
|
|
202
|
+
if (taken) throw new AxError({ code: "two-stdin", exit: cli.exits.code("usage"), thing: cmd.name, problem: 'stdin was already read; only one "-" per command', fix: null });
|
|
203
|
+
taken = true;
|
|
204
|
+
return readAll(io.stdin);
|
|
205
|
+
};
|
|
206
|
+
const input = await withStdin(cli, cmd, parsed.input, stdin);
|
|
207
|
+
const result = await dispatch(cli, { ...parsed, input }, { stdin, json });
|
|
208
|
+
return printResult(cli, cmd, input, result, json, io, voice, options.env ?? processEnv());
|
|
209
|
+
} catch (e) {
|
|
210
|
+
const shape: AxErrorShape = isAxError(e) ? e.shape : { code: "error", exit: cli.exits.code("error"), thing: cli.name, problem: e instanceof Error ? e.message : String(e), fix: null };
|
|
211
|
+
// A message that is already a whole `<tool>: ...` line (a failure the tool's own code built) is printed as it is, not prefixed again.
|
|
212
|
+
const whole = !isAxError(e) && e instanceof Error && /^[a-z][a-z0-9-]*: /.test(e.message);
|
|
213
|
+
io.stderr.write(`${whole ? shape.problem.replace(/\s*[\r\n]+\s*/g, " ") : errorLine(cli.name, shape)}\n`);
|
|
214
|
+
// A person-only word, or another agent's item, is a refusal of an action, so --json answers with its outcome, which
|
|
215
|
+
// carries the same error.
|
|
216
|
+
if (json) io.stdout.write(`${JSON.stringify(shape.code === "person-only" || shape.code === "not-yours" ? outcome({ action: shape.thing, state: "refused", summary: errorMessage(shape), error: shape }) : errorJson(shape), null, 2)}\n`);
|
|
217
|
+
return shape.exit;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/** A stream that reports its errors as events, as Node's process.stdout and process.stderr do. */
|
|
222
|
+
interface ErrorEvents {
|
|
223
|
+
on(event: "error", listener: (error: { code?: string }) => void): unknown;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Ends the tool quietly when whatever reads its output goes away, as in `tool help | head -1`: on `EPIPE` it exits with
|
|
228
|
+
* the exit code so far (0 when none was set) and prints nothing, instead of a stack trace. Call it once in the tool's
|
|
229
|
+
* bin, before runCli: `quietPipes(process)`. Any other stream error is thrown as before.
|
|
230
|
+
*
|
|
231
|
+
* @claim "prints nothing, instead of a stack trace" registry/ouro/ax/cli.test.mts verify:testExists(registry/ouro/ax/cli.test.mts::a closed pipe ends the tool quietly with the exit code so far, and any other stream error still throws)
|
|
232
|
+
*/
|
|
233
|
+
function quietPipes(proc: { stdout: ErrorEvents; stderr: ErrorEvents; exitCode?: number | string | null | undefined; exit(code?: number): unknown }): void {
|
|
234
|
+
for (const stream of [proc.stdout, proc.stderr]) {
|
|
235
|
+
stream.on("error", (error) => {
|
|
236
|
+
if (error.code !== "EPIPE") throw error;
|
|
237
|
+
proc.exit(typeof proc.exitCode === "number" ? proc.exitCode : 0);
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
}
|