@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,500 @@
|
|
|
1
|
+
// Finds `git … commit` and `git … add` invocations in one shell command, says
|
|
2
|
+
// which directory each ran in and which paths it names, and lists the files
|
|
3
|
+
// the command writes with `>`, `>>` and `tee`. Binding (M3-4) matches a desk commit to the
|
|
4
|
+
// session's own `git commit` calls by time, because agents commit with
|
|
5
|
+
// `git commit -q`, which prints no hash.
|
|
6
|
+
//
|
|
7
|
+
// Privacy. The command is read in memory only. `gitCommitCwds` returns
|
|
8
|
+
// directories and nothing else; `shellEffects` returns directories and
|
|
9
|
+
// absolute paths: never the command, the commit message, an option or any
|
|
10
|
+
// other argument. Callers keep the directories in binding
|
|
11
|
+
// events, which never leave the machine and never reach facts.
|
|
12
|
+
//
|
|
13
|
+
// What it understands. It splits the command into simple commands on
|
|
14
|
+
// unquoted `&&`, `||`, `;`, `|`, `&`, parentheses and newlines, unquoting
|
|
15
|
+
// words like the shell would (single and double quotes, backslash escapes in
|
|
16
|
+
// POSIX shells, backtick escapes and doubled single quotes in PowerShell),
|
|
17
|
+
// and skips comments and heredoc bodies. In each simple command it skips
|
|
18
|
+
// `NAME=value` assignments and the wrappers `env`, `command`, `builtin`,
|
|
19
|
+
// `time`, `nohup` and `exec`, then:
|
|
20
|
+
// - `cd` (PowerShell also `Set-Location`, `sl`, `chdir`) moves the
|
|
21
|
+
// directory for the rest of the command;
|
|
22
|
+
// - `git` with its global options (`-C <dir>` applied in order, and the
|
|
23
|
+
// value-taking `-c`, `--namespace`, `--super-prefix`, `--config-env`
|
|
24
|
+
// skipped) followed by the subcommand `commit` is a commit in the
|
|
25
|
+
// resulting directory.
|
|
26
|
+
// Some things are not modeled, and make the directory unknown instead:
|
|
27
|
+
// - `pushd` and `popd` (PowerShell `Push-Location`, `Pop-Location`), and a
|
|
28
|
+
// subshell's `(` or `)`: from there on the directory is unknown until an
|
|
29
|
+
// absolute `cd`;
|
|
30
|
+
// - `--git-dir` or `--work-tree` on the commit, or `GIT_DIR` or
|
|
31
|
+
// `GIT_WORK_TREE` set for it (a `NAME=value` prefix, `env`), set bare or
|
|
32
|
+
// exported earlier in the command (PowerShell `$env:GIT_DIR`): Git then
|
|
33
|
+
// commits somewhere the directory does not say, so that commit and every
|
|
34
|
+
// later one in the command are unknown.
|
|
35
|
+
// A command run through another program (`bash -c "…"`, an alias, a script)
|
|
36
|
+
// or inside a command substitution (`$(…)`, backticks) is not seen, and a
|
|
37
|
+
// background `&` is read as a plain separator.
|
|
38
|
+
//
|
|
39
|
+
// Directories. A directory word resolves against the current one. `~` and
|
|
40
|
+
// `$HOME` (PowerShell also `$env:HOME`, `$env:USERPROFILE`) expand to `home`.
|
|
41
|
+
// `$DESK` (PowerShell `$env:DESK`) becomes `DESK_MARKER`, a placeholder the
|
|
42
|
+
// binder replaces with the desk root, since `$DESK` is by definition the
|
|
43
|
+
// desk checkout. Any other variable, command substitution, `cd -`, a
|
|
44
|
+
// relative word with no known current directory, or a bare `cd` in
|
|
45
|
+
// PowerShell makes the directory unknown: that commit is reported with a
|
|
46
|
+
// `null` directory rather than a guess.
|
|
47
|
+
//
|
|
48
|
+
// `src/factory/**` imports only `node:` built-ins and other `src/factory/`
|
|
49
|
+
// files.
|
|
50
|
+
|
|
51
|
+
import * as path from "node:path"
|
|
52
|
+
|
|
53
|
+
/** The placeholder for `$DESK` in a returned directory; `DESK_MARKER + "/rest"` below it. */
|
|
54
|
+
export const DESK_MARKER = "$DESK"
|
|
55
|
+
|
|
56
|
+
const WRAPPERS = new Set(["env", "command", "builtin", "time", "nohup", "exec"])
|
|
57
|
+
const POSIX_CD = new Set(["cd"])
|
|
58
|
+
const POWERSHELL_CD = new Set(["cd", "sl", "chdir", "set-location"])
|
|
59
|
+
const POSIX_STACK = new Set(["pushd", "popd"])
|
|
60
|
+
const POWERSHELL_STACK = new Set(["pushd", "popd", "push-location", "pop-location"])
|
|
61
|
+
const GIT_OPTIONS_WITH_VALUE = new Set(["-c", "--namespace", "--super-prefix", "--config-env"])
|
|
62
|
+
const GIT_ELSEWHERE_OPTION = /^--(?:git-dir|work-tree)(?:=|$)/u
|
|
63
|
+
const ASSIGNMENT = /^[A-Za-z_][A-Za-z0-9_]*=/u
|
|
64
|
+
const EXPORTS = new Set(["export", "declare", "typeset", "readonly"])
|
|
65
|
+
const PATH_SUBCOMMANDS = new Set(["commit", "add"])
|
|
66
|
+
const WRITE_OPERATORS = new Set([">", ">>", ">|"])
|
|
67
|
+
// Per subcommand: flags that mean "the whole tree", and options whose value is
|
|
68
|
+
// the next word (and so is not a path).
|
|
69
|
+
const WHOLE_TREE_SHORT = { commit: new Set(["a"]), add: new Set(["A", "u"]) }
|
|
70
|
+
const WHOLE_TREE_LONG = { commit: new Set(["all"]), add: new Set(["all", "update"]) }
|
|
71
|
+
const VALUE_SHORT = { commit: new Set(["m", "F", "C", "c", "t"]), add: new Set() }
|
|
72
|
+
const VALUE_LONG = {
|
|
73
|
+
commit: new Set(["message", "file", "author", "date", "reuse-message", "reedit-message", "template", "cleanup", "trailer", "fixup", "squash", "pathspec-from-file"]),
|
|
74
|
+
add: new Set(["pathspec-from-file"]),
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const DIALECTS = {
|
|
78
|
+
posix: {
|
|
79
|
+
path: path,
|
|
80
|
+
escape: "\\",
|
|
81
|
+
separators: new Set([";", "|", "&", "\n"]),
|
|
82
|
+
cd: POSIX_CD,
|
|
83
|
+
stack: POSIX_STACK,
|
|
84
|
+
gitEnv: /^GIT_(?:DIR|WORK_TREE)=/u,
|
|
85
|
+
desk: /^\$(?:DESK|\{DESK\})(?=[/\\]|$)/u,
|
|
86
|
+
home: /^(?:~|\$HOME|\$\{HOME\})(?=[/\\]|$)/u,
|
|
87
|
+
bareCdGoesHome: true,
|
|
88
|
+
},
|
|
89
|
+
powershell: {
|
|
90
|
+
path: path.win32,
|
|
91
|
+
escape: "`",
|
|
92
|
+
separators: new Set([";", "|", "&", "\n"]),
|
|
93
|
+
cd: POWERSHELL_CD,
|
|
94
|
+
stack: POWERSHELL_STACK,
|
|
95
|
+
gitEnv: /^\$env:GIT_(?:DIR|WORK_TREE)(?:=|$)/iu,
|
|
96
|
+
desk: /^\$env:DESK(?=[/\\]|$)/iu,
|
|
97
|
+
home: /^(?:~|\$HOME|\$env:HOME|\$env:USERPROFILE)(?=[/\\]|$)/iu,
|
|
98
|
+
bareCdGoesHome: false,
|
|
99
|
+
},
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// ---------------------------------------------------------------------------
|
|
103
|
+
// Tokenizing: a list of simple commands, each a list of words. A word is
|
|
104
|
+
// `{ text, dynamic, op }`: `text` is the unquoted value, `dynamic` is true
|
|
105
|
+
// when an unescaped `$` or backtick (command substitution) outside single
|
|
106
|
+
// quotes means the shell would expand it, and `op` marks a redirection
|
|
107
|
+
// operator, whose target word is dropped before a command is read.
|
|
108
|
+
// ---------------------------------------------------------------------------
|
|
109
|
+
|
|
110
|
+
function tokenize(command, dialect) {
|
|
111
|
+
const { escape, separators } = dialect
|
|
112
|
+
const commands = [[]]
|
|
113
|
+
let word = null
|
|
114
|
+
let quote = null
|
|
115
|
+
let pendingHeredocs = []
|
|
116
|
+
let index = 0
|
|
117
|
+
|
|
118
|
+
const current = () => {
|
|
119
|
+
if (word === null) word = { text: "", dynamic: false, op: false }
|
|
120
|
+
return word
|
|
121
|
+
}
|
|
122
|
+
const endWord = () => {
|
|
123
|
+
if (word !== null) commands[commands.length - 1].push(word)
|
|
124
|
+
word = null
|
|
125
|
+
}
|
|
126
|
+
const endCommand = () => {
|
|
127
|
+
endWord()
|
|
128
|
+
if (commands[commands.length - 1].length > 0) commands.push([])
|
|
129
|
+
}
|
|
130
|
+
// Skips heredoc bodies that start after the newline at `index`.
|
|
131
|
+
const skipHeredocs = () => {
|
|
132
|
+
for (const { delimiter, stripTabs } of pendingHeredocs) {
|
|
133
|
+
for (;;) {
|
|
134
|
+
if (index >= command.length) return
|
|
135
|
+
const lineEnd = command.indexOf("\n", index)
|
|
136
|
+
const end = lineEnd === -1 ? command.length : lineEnd
|
|
137
|
+
const line = command.slice(index, end)
|
|
138
|
+
index = end + 1
|
|
139
|
+
if ((stripTabs ? line.replace(/^\t+/u, "") : line) === delimiter) break
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
// Reads the heredoc delimiter word after `<<` / `<<-`; with none, the
|
|
144
|
+
// operator is ignored.
|
|
145
|
+
const readHeredocDelimiter = () => {
|
|
146
|
+
let stripTabs = false
|
|
147
|
+
if (command[index] === "-") {
|
|
148
|
+
stripTabs = true
|
|
149
|
+
index += 1
|
|
150
|
+
}
|
|
151
|
+
while (command[index] === " " || command[index] === "\t") index += 1
|
|
152
|
+
let delimiter = ""
|
|
153
|
+
while (index < command.length && !/[\s;&|()<>]/u.test(command[index])) {
|
|
154
|
+
const char = command[index]
|
|
155
|
+
if (char !== "'" && char !== "\"" && char !== "\\") delimiter += char
|
|
156
|
+
index += 1
|
|
157
|
+
}
|
|
158
|
+
if (delimiter === "") return
|
|
159
|
+
pendingHeredocs.push({ delimiter, stripTabs })
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
while (index < command.length) {
|
|
163
|
+
const char = command[index]
|
|
164
|
+
if (quote === "'") {
|
|
165
|
+
if (char === "'") {
|
|
166
|
+
if (dialect === DIALECTS.powershell && command[index + 1] === "'") {
|
|
167
|
+
current().text += "'"
|
|
168
|
+
index += 2
|
|
169
|
+
continue
|
|
170
|
+
}
|
|
171
|
+
quote = null
|
|
172
|
+
} else {
|
|
173
|
+
current().text += char
|
|
174
|
+
}
|
|
175
|
+
index += 1
|
|
176
|
+
continue
|
|
177
|
+
}
|
|
178
|
+
if (quote === "\"") {
|
|
179
|
+
if (char === "\"") {
|
|
180
|
+
quote = null
|
|
181
|
+
} else if (char === escape && index + 1 < command.length) {
|
|
182
|
+
const next = command[index + 1]
|
|
183
|
+
if (escape === "`" || "\"\\$`".includes(next)) current().text += next
|
|
184
|
+
else if (next !== "\n") current().text += char + next
|
|
185
|
+
index += 1
|
|
186
|
+
} else {
|
|
187
|
+
if (char === "$" || (char === "`" && escape !== "`")) current().dynamic = true
|
|
188
|
+
current().text += char
|
|
189
|
+
}
|
|
190
|
+
index += 1
|
|
191
|
+
continue
|
|
192
|
+
}
|
|
193
|
+
if (char === " " || char === "\t" || char === "\r") {
|
|
194
|
+
endWord()
|
|
195
|
+
index += 1
|
|
196
|
+
continue
|
|
197
|
+
}
|
|
198
|
+
if (char === "#" && word === null) {
|
|
199
|
+
while (index < command.length && command[index] !== "\n") index += 1
|
|
200
|
+
continue
|
|
201
|
+
}
|
|
202
|
+
if (char === "<" && command[index + 1] === "<" && command[index + 2] !== "<") {
|
|
203
|
+
endWord()
|
|
204
|
+
index += 2
|
|
205
|
+
readHeredocDelimiter()
|
|
206
|
+
continue
|
|
207
|
+
}
|
|
208
|
+
if (char === "<" || char === ">") {
|
|
209
|
+
endWord()
|
|
210
|
+
let op = ""
|
|
211
|
+
while (index < command.length && "<>&|".includes(command[index])) {
|
|
212
|
+
op += command[index]
|
|
213
|
+
index += 1
|
|
214
|
+
}
|
|
215
|
+
commands[commands.length - 1].push({ text: op, dynamic: false, op: true })
|
|
216
|
+
continue
|
|
217
|
+
}
|
|
218
|
+
if (char === "(" || char === ")") {
|
|
219
|
+
// A subshell boundary: its own marker command.
|
|
220
|
+
endCommand()
|
|
221
|
+
commands[commands.length - 1].push({ text: char, dynamic: false, op: false, scope: true })
|
|
222
|
+
endCommand()
|
|
223
|
+
index += 1
|
|
224
|
+
continue
|
|
225
|
+
}
|
|
226
|
+
if (separators.has(char)) {
|
|
227
|
+
endCommand()
|
|
228
|
+
index += 1
|
|
229
|
+
if (char === "\n" && pendingHeredocs.length > 0) {
|
|
230
|
+
skipHeredocs()
|
|
231
|
+
pendingHeredocs = []
|
|
232
|
+
}
|
|
233
|
+
continue
|
|
234
|
+
}
|
|
235
|
+
if (char === escape) {
|
|
236
|
+
if (index + 1 < command.length && command[index + 1] !== "\n") current().text += command[index + 1]
|
|
237
|
+
index += 2
|
|
238
|
+
continue
|
|
239
|
+
}
|
|
240
|
+
if (char === "'" || char === "\"") {
|
|
241
|
+
current()
|
|
242
|
+
quote = char
|
|
243
|
+
index += 1
|
|
244
|
+
continue
|
|
245
|
+
}
|
|
246
|
+
if (char === "$" && command[index + 1] === "(") {
|
|
247
|
+
// A command substitution is one dynamic word; its inside is never read as commands.
|
|
248
|
+
const substitution = current()
|
|
249
|
+
substitution.dynamic = true
|
|
250
|
+
substitution.text += "$"
|
|
251
|
+
index += 1
|
|
252
|
+
let depth = 0
|
|
253
|
+
do {
|
|
254
|
+
const inner = command[index]
|
|
255
|
+
if (inner === "(") depth += 1
|
|
256
|
+
else if (inner === ")") depth -= 1
|
|
257
|
+
substitution.text += inner
|
|
258
|
+
index += 1
|
|
259
|
+
} while (index < command.length && depth > 0)
|
|
260
|
+
continue
|
|
261
|
+
}
|
|
262
|
+
if (char === "`" && escape !== "`") {
|
|
263
|
+
const close = command.indexOf("`", index + 1)
|
|
264
|
+
const end = close === -1 ? command.length : close + 1
|
|
265
|
+
current().dynamic = true
|
|
266
|
+
current().text += command.slice(index, end)
|
|
267
|
+
index = end
|
|
268
|
+
continue
|
|
269
|
+
}
|
|
270
|
+
if (char === "$") current().dynamic = true
|
|
271
|
+
current().text += char
|
|
272
|
+
index += 1
|
|
273
|
+
}
|
|
274
|
+
endCommand()
|
|
275
|
+
return commands.filter((words) => words.length > 0)
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// Drops each redirection operator and the word it redirects to.
|
|
279
|
+
function withoutRedirections(words) {
|
|
280
|
+
const kept = []
|
|
281
|
+
for (let index = 0; index < words.length; index += 1) {
|
|
282
|
+
if (words[index].op) index += 1
|
|
283
|
+
else kept.push(words[index])
|
|
284
|
+
}
|
|
285
|
+
return kept
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// ---------------------------------------------------------------------------
|
|
289
|
+
// Directories.
|
|
290
|
+
// ---------------------------------------------------------------------------
|
|
291
|
+
|
|
292
|
+
function isDeskMarked(directory) {
|
|
293
|
+
return directory === DESK_MARKER || directory.startsWith(`${DESK_MARKER}/`)
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// Joins a relative word onto the desk marker, keeping `/` separators.
|
|
297
|
+
function underDeskMarker(base, relative) {
|
|
298
|
+
const joined = path.posix.join(base, relative.replaceAll("\\", "/"))
|
|
299
|
+
return isDeskMarked(joined) ? joined : null
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/** Moves `current` (a directory, the desk marker form, or null) by one directory word. */
|
|
303
|
+
function applyStep(current, word, { dialect, home }) {
|
|
304
|
+
const { text } = word
|
|
305
|
+
const deskMatch = dialect.desk.exec(text)
|
|
306
|
+
if (deskMatch) return underDeskMarker(DESK_MARKER, `.${text.slice(deskMatch[0].length)}`)
|
|
307
|
+
const homeMatch = dialect.home.exec(text)
|
|
308
|
+
if (homeMatch) {
|
|
309
|
+
if (typeof home !== "string") return null
|
|
310
|
+
return dialect.path.join(home, text.slice(homeMatch[0].length))
|
|
311
|
+
}
|
|
312
|
+
if (word.dynamic) return null
|
|
313
|
+
if (dialect.path.isAbsolute(text)) return dialect.path.normalize(text)
|
|
314
|
+
if (typeof current !== "string") return null
|
|
315
|
+
if (isDeskMarked(current)) return underDeskMarker(current, text)
|
|
316
|
+
return dialect.path.resolve(current, text)
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function commandName(text, dialect) {
|
|
320
|
+
const base = text.split(/[/\\]/u).pop()
|
|
321
|
+
return dialect === DIALECTS.powershell ? base.toLowerCase().replace(/\.exe$/u, "") : base
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// The index of the command word, after assignments and wrapper words.
|
|
325
|
+
function commandStart(words) {
|
|
326
|
+
let index = 0
|
|
327
|
+
while (index < words.length && (ASSIGNMENT.test(words[index].text) || WRAPPERS.has(words[index].text))) index += 1
|
|
328
|
+
return index
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// The `git … commit` or `git … add` invocation in `words` (starting after
|
|
332
|
+
// `git`): its subcommand, the `-C` steps, whether `--git-dir`/`--work-tree`
|
|
333
|
+
// points Git elsewhere, and the words after the subcommand. `undefined` when
|
|
334
|
+
// it is neither.
|
|
335
|
+
function gitInvocation(words, start) {
|
|
336
|
+
const steps = []
|
|
337
|
+
let elsewhere = false
|
|
338
|
+
let index = start
|
|
339
|
+
while (index < words.length) {
|
|
340
|
+
const text = words[index].text
|
|
341
|
+
if (text === "-C") {
|
|
342
|
+
steps.push(words[index + 1])
|
|
343
|
+
index += 2
|
|
344
|
+
} else if (GIT_ELSEWHERE_OPTION.test(text)) {
|
|
345
|
+
elsewhere = true
|
|
346
|
+
index += text.includes("=") ? 1 : 2
|
|
347
|
+
} else if (GIT_OPTIONS_WITH_VALUE.has(text)) {
|
|
348
|
+
index += 2
|
|
349
|
+
} else if (text.startsWith("-")) {
|
|
350
|
+
index += 1
|
|
351
|
+
} else {
|
|
352
|
+
break
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
if (index >= words.length || !PATH_SUBCOMMANDS.has(words[index].text)) return undefined
|
|
356
|
+
return { subcommand: words[index].text, steps, elsewhere, operands: words.slice(index + 1) }
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
// The absolute paths a `git add` or `git commit` names, resolved against
|
|
360
|
+
// `directory`. Option words and the values of options that take one are
|
|
361
|
+
// skipped; `--` ends the options and is not itself a path. A whole-tree
|
|
362
|
+
// flag (`-A`, `--all`, `-u`, `-a`, `-am`) or the operand `.` names no
|
|
363
|
+
// specific path, so the list is empty then.
|
|
364
|
+
function gitNamedPaths(subcommand, operands, directory, options) {
|
|
365
|
+
const wholeShort = WHOLE_TREE_SHORT[subcommand]
|
|
366
|
+
const wholeLong = WHOLE_TREE_LONG[subcommand]
|
|
367
|
+
const valueShort = VALUE_SHORT[subcommand]
|
|
368
|
+
const valueLong = VALUE_LONG[subcommand]
|
|
369
|
+
const named = []
|
|
370
|
+
let wholeTree = false
|
|
371
|
+
let optionsDone = false
|
|
372
|
+
for (let index = 0; index < operands.length; index += 1) {
|
|
373
|
+
const { text } = operands[index]
|
|
374
|
+
if (!optionsDone && text === "--") {
|
|
375
|
+
optionsDone = true
|
|
376
|
+
} else if (!optionsDone && text.startsWith("--")) {
|
|
377
|
+
const [name, ...attached] = text.slice(2).split("=")
|
|
378
|
+
if (wholeLong.has(name)) wholeTree = true
|
|
379
|
+
else if (attached.length === 0 && valueLong.has(name)) index += 1
|
|
380
|
+
} else if (!optionsDone && text.startsWith("-") && text.length > 1) {
|
|
381
|
+
for (let at = 1; at < text.length; at += 1) {
|
|
382
|
+
if (wholeShort.has(text[at])) {
|
|
383
|
+
wholeTree = true
|
|
384
|
+
} else if (valueShort.has(text[at])) {
|
|
385
|
+
if (at === text.length - 1) index += 1
|
|
386
|
+
break
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
} else if (text !== "" && text !== ".") {
|
|
390
|
+
named.push(operands[index])
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
if (wholeTree) return []
|
|
394
|
+
const paths = []
|
|
395
|
+
for (const word of named) {
|
|
396
|
+
const resolved = applyStep(directory, word, options)
|
|
397
|
+
if (resolved !== null && !paths.includes(resolved)) paths.push(resolved)
|
|
398
|
+
}
|
|
399
|
+
return paths
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
// Resolves the file a redirection or `tee` writes, or `null` when it is not a
|
|
403
|
+
// literal path (`/dev/...`, a variable, a command substitution).
|
|
404
|
+
function writeTarget(current, word, options) {
|
|
405
|
+
if (word === undefined || word.op || word.scope) return null
|
|
406
|
+
// `/dev/null` as written, before it is resolved: Git Bash on Windows turns it into `D:\dev\null`, which no longer starts with `/dev/`.
|
|
407
|
+
if (word.text.startsWith("/dev/")) return null
|
|
408
|
+
const resolved = applyStep(current, word, options)
|
|
409
|
+
if (resolved === null || resolved.startsWith("/dev/")) return null
|
|
410
|
+
return resolved
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
function changeDirectory(args, current, options) {
|
|
414
|
+
const targets = args.filter((word) => word.text === "-" || !word.text.startsWith("-"))
|
|
415
|
+
if (targets.length === 0) {
|
|
416
|
+
if (!options.dialect.bareCdGoesHome) return null
|
|
417
|
+
return typeof options.home === "string" ? options.home : null
|
|
418
|
+
}
|
|
419
|
+
if (targets[0].text === "-") return null
|
|
420
|
+
return applyStep(current, targets[0], options)
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* `shellEffects({ command, cwd, home, dialect }) -> { commits, adds, writes }`:
|
|
425
|
+
* what one shell command does that the factory binds a session by, in order.
|
|
426
|
+
* `commits` and `adds` hold one `{ cwd, paths }` per `git … commit` and
|
|
427
|
+
* `git … add`: `cwd` as in `gitCommitCwds` (`null` when unknown) and `paths`
|
|
428
|
+
* the absolute files the command names (`[]` for `-A`, `.`, `-a`, `-am`).
|
|
429
|
+
* `writes` lists the absolute files that `>`, `>>` and `tee` write. It never
|
|
430
|
+
* throws: a command it cannot read gives empty lists.
|
|
431
|
+
*/
|
|
432
|
+
export function shellEffects({ command, cwd, home, dialect = "bash" }) {
|
|
433
|
+
const effects = { commits: [], adds: [], writes: [] }
|
|
434
|
+
// Most shell calls never touch any of these; they are not tokenized at all.
|
|
435
|
+
if (typeof command !== "string" || !/commit|add|tee|>/u.test(command)) return effects
|
|
436
|
+
const options = { dialect: DIALECTS[dialect] ?? DIALECTS.posix, home }
|
|
437
|
+
const { dialect: shell } = options
|
|
438
|
+
let current = typeof cwd === "string" ? cwd : null
|
|
439
|
+
// Once GIT_DIR or GIT_WORK_TREE is set for the rest of the command.
|
|
440
|
+
let elsewhere = false
|
|
441
|
+
const note = (target) => {
|
|
442
|
+
if (target !== null && !effects.writes.includes(target)) effects.writes.push(target)
|
|
443
|
+
}
|
|
444
|
+
for (const raw of tokenize(command, shell)) {
|
|
445
|
+
if (raw[0].scope) {
|
|
446
|
+
current = null
|
|
447
|
+
continue
|
|
448
|
+
}
|
|
449
|
+
raw.forEach((word, index) => {
|
|
450
|
+
if (word.op && WRITE_OPERATORS.has(word.text)) note(writeTarget(current, raw[index + 1], options))
|
|
451
|
+
})
|
|
452
|
+
const words = withoutRedirections(raw)
|
|
453
|
+
const start = commandStart(words)
|
|
454
|
+
const prefixSetsGitEnv = words.slice(0, start).some((word) => shell.gitEnv.test(word.text))
|
|
455
|
+
if (start >= words.length) {
|
|
456
|
+
if (prefixSetsGitEnv) elsewhere = true
|
|
457
|
+
continue
|
|
458
|
+
}
|
|
459
|
+
const name = commandName(words[start].text, shell)
|
|
460
|
+
if (shell === DIALECTS.powershell && words.some((word) => shell.gitEnv.test(word.text))) elsewhere = true
|
|
461
|
+
if (EXPORTS.has(name) && words.slice(start + 1).some((word) => shell.gitEnv.test(word.text))) elsewhere = true
|
|
462
|
+
if (shell.cd.has(name)) {
|
|
463
|
+
current = changeDirectory(words.slice(start + 1), current, options)
|
|
464
|
+
} else if (shell.stack.has(name)) {
|
|
465
|
+
current = null
|
|
466
|
+
} else if (name === "tee") {
|
|
467
|
+
let optionsDone = false
|
|
468
|
+
for (const word of words.slice(start + 1)) {
|
|
469
|
+
if (!optionsDone && word.text === "--") optionsDone = true
|
|
470
|
+
else if (optionsDone || !word.text.startsWith("-")) note(writeTarget(current, word, options))
|
|
471
|
+
}
|
|
472
|
+
} else if (name === "git") {
|
|
473
|
+
const invocation = gitInvocation(words, start + 1)
|
|
474
|
+
if (invocation === undefined) continue
|
|
475
|
+
const directory =
|
|
476
|
+
invocation.elsewhere || elsewhere || prefixSetsGitEnv
|
|
477
|
+
? null
|
|
478
|
+
: invocation.steps.reduce((where, step) => applyStep(where, step, options), current)
|
|
479
|
+
const paths = gitNamedPaths(invocation.subcommand, invocation.operands, directory, options)
|
|
480
|
+
effects[invocation.subcommand === "commit" ? "commits" : "adds"].push({ cwd: directory, paths })
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
return effects
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* `gitCommitCwds({ command, cwd, home, dialect }) -> Array<string | null>`:
|
|
488
|
+
* the directory of each `git … commit` in `command`, in order and without
|
|
489
|
+
* repeats; `null` for one whose directory can't be known. `cwd` is the
|
|
490
|
+
* directory the command started in, `home` the user's home folder, and
|
|
491
|
+
* `dialect` is `"posix"` (default) or `"powershell"`. Nothing else from the
|
|
492
|
+
* command is ever returned.
|
|
493
|
+
*/
|
|
494
|
+
export function gitCommitCwds({ command, cwd, home, dialect = "posix" }) {
|
|
495
|
+
const found = []
|
|
496
|
+
for (const { cwd: directory } of shellEffects({ command, cwd, home, dialect }).commits) {
|
|
497
|
+
if (!found.includes(directory)) found.push(directory)
|
|
498
|
+
}
|
|
499
|
+
return found
|
|
500
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
// A factory store's issues, through `gh api`: what the kaizen check, andon
|
|
2
|
+
// and the friction drain read and write. Every call goes through a runner
|
|
3
|
+
// with the `flush.js` `ghRunner` shape, `(args, { token, input, timeoutMs })
|
|
4
|
+
// -> { code, stdout, stderr, spawnError?, timedOut? }`, so the token reaches
|
|
5
|
+
// `gh` only as `GH_TOKEN` and never as an argument. Answers are parsed as
|
|
6
|
+
// data and reduced to the few fields the callers use.
|
|
7
|
+
//
|
|
8
|
+
// Failures throw an `Error` whose `code` is one stable value: `gh_missing`,
|
|
9
|
+
// `timeout`, `http_<status>` for an HTTP error, `unexpected_answer` for an
|
|
10
|
+
// answer of the wrong shape, `too_many_issues` or `too_many_comments` past
|
|
11
|
+
// the page limit of the list that overflowed, or `gh_failed`.
|
|
12
|
+
//
|
|
13
|
+
// `src/factory/**` imports only `node:` built-ins and other `src/factory/`
|
|
14
|
+
// files.
|
|
15
|
+
|
|
16
|
+
import { PATTERNS } from "./schema.js"
|
|
17
|
+
|
|
18
|
+
const PER_PAGE = 100
|
|
19
|
+
const MAX_PAGES = 20
|
|
20
|
+
const DEFAULT_TIMEOUT_MS = 60000
|
|
21
|
+
const HTTP_STATUS = /\(HTTP (\d{3})\)/u
|
|
22
|
+
const STATES = new Set(["open", "closed", "all"])
|
|
23
|
+
|
|
24
|
+
function failure(code) {
|
|
25
|
+
const error = Object.assign(new Error(`factory issues: ${code}`), { code: "store_issues_factory_issues" })
|
|
26
|
+
error.code = code
|
|
27
|
+
return error
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const isObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value)
|
|
31
|
+
|
|
32
|
+
function issueView(raw) {
|
|
33
|
+
if (!isObject(raw) || !Number.isSafeInteger(raw.number) || !Array.isArray(raw.labels)) throw failure("unexpected_answer")
|
|
34
|
+
return {
|
|
35
|
+
number: raw.number,
|
|
36
|
+
url: typeof raw.html_url === "string" ? raw.html_url : null,
|
|
37
|
+
title: typeof raw.title === "string" ? raw.title : "",
|
|
38
|
+
body: typeof raw.body === "string" ? raw.body : "",
|
|
39
|
+
labels: raw.labels.map((label) => (isObject(label) ? label.name : label)).filter((name) => typeof name === "string"),
|
|
40
|
+
state: raw.state === "closed" ? "closed" : "open",
|
|
41
|
+
author: typeof raw.user?.login === "string" ? raw.user.login : null,
|
|
42
|
+
pull_request: raw.pull_request !== undefined && raw.pull_request !== null,
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function commentView(raw) {
|
|
47
|
+
if (!isObject(raw) || !Number.isSafeInteger(raw.id)) throw failure("unexpected_answer")
|
|
48
|
+
return { id: raw.id, author: typeof raw.user?.login === "string" ? raw.user.login : null, body: typeof raw.body === "string" ? raw.body : "" }
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* `issuesClient({ runner, repo, token, timeoutMs }) -> client`: `listIssues({
|
|
53
|
+
* label, state })`, `listComments(number)`, `createComment(number, body)`,
|
|
54
|
+
* `updateComment(id, body)`, `addLabels(number, labels)`,
|
|
55
|
+
* `removeLabel(number, label)`, `createIssue({ title, body, labels }) -> {
|
|
56
|
+
* number, url }`, `updateIssue(number, patch)`, `readFile(file) -> text | null` (a file
|
|
57
|
+
* on the default branch, `null` when it does not exist) and `visibility() ->
|
|
58
|
+
* "public" | "private" | "unknown"` (the repository's, where anything but
|
|
59
|
+
* GitHub's explicit `private: true` or `private: false` is `unknown`) for
|
|
60
|
+
* the store `repo`.
|
|
61
|
+
*/
|
|
62
|
+
export function issuesClient({ runner, repo, token, timeoutMs = DEFAULT_TIMEOUT_MS }) {
|
|
63
|
+
if (typeof runner !== "function") throw Object.assign(new TypeError("issuesClient: Pass runner as a function"), { code: "store_issues_issuesclient_pass_runner_as_a" })
|
|
64
|
+
if (typeof repo !== "string" || !PATTERNS.prRepo.test(repo)) throw Object.assign(new TypeError("issuesClient: Pass repo as owner/repo"), { code: "store_issues_issuesclient_pass_repo_as_owner" })
|
|
65
|
+
if (typeof token !== "string" || token === "") throw Object.assign(new TypeError("issuesClient: Pass token as a non-empty string"), { code: "store_issues_issuesclient_pass_token_as_a" })
|
|
66
|
+
|
|
67
|
+
async function api(method, route, body) {
|
|
68
|
+
const args = ["api", "--method", method, "-H", "Accept: application/vnd.github+json", "-H", "X-GitHub-Api-Version: 2022-11-28", route]
|
|
69
|
+
if (body !== undefined) args.push("--input", "-")
|
|
70
|
+
const result = await runner(args, { token, input: body === undefined ? undefined : JSON.stringify(body), timeoutMs })
|
|
71
|
+
if (result.spawnError === "ENOENT") throw failure("gh_missing")
|
|
72
|
+
if (result.timedOut === true) throw failure("timeout")
|
|
73
|
+
if (result.code !== 0) {
|
|
74
|
+
const status = HTTP_STATUS.exec(String(result.stderr ?? ""))?.[1]
|
|
75
|
+
throw failure(status === undefined ? "gh_failed" : `http_${status}`)
|
|
76
|
+
}
|
|
77
|
+
const text = String(result.stdout ?? "")
|
|
78
|
+
if (text.trim() === "") return null
|
|
79
|
+
try {
|
|
80
|
+
return JSON.parse(text)
|
|
81
|
+
} catch {
|
|
82
|
+
throw failure("unexpected_answer")
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async function pages(route, view, overflow) {
|
|
87
|
+
const items = []
|
|
88
|
+
for (let page = 1; page <= MAX_PAGES; page += 1) {
|
|
89
|
+
const answer = await api("GET", `${route}${route.includes("?") ? "&" : "?"}per_page=${PER_PAGE}&page=${page}`)
|
|
90
|
+
if (!Array.isArray(answer)) throw failure("unexpected_answer")
|
|
91
|
+
items.push(...answer.map(view))
|
|
92
|
+
if (answer.length < PER_PAGE) return items
|
|
93
|
+
}
|
|
94
|
+
throw failure(overflow)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const base = `repos/${repo}`
|
|
98
|
+
return {
|
|
99
|
+
async listIssues({ label, state }) {
|
|
100
|
+
if (typeof label !== "string" || !STATES.has(state)) throw Object.assign(new TypeError("listIssues: Pass a label and a state"), { code: "store_issues_listissues_pass_a_label_and" })
|
|
101
|
+
return pages(`${base}/issues?state=${state}&labels=${encodeURIComponent(label)}`, issueView, "too_many_issues")
|
|
102
|
+
},
|
|
103
|
+
async listComments(number) {
|
|
104
|
+
return pages(`${base}/issues/${number}/comments`, commentView, "too_many_comments")
|
|
105
|
+
},
|
|
106
|
+
async createComment(number, body) {
|
|
107
|
+
await api("POST", `${base}/issues/${number}/comments`, { body })
|
|
108
|
+
},
|
|
109
|
+
async updateComment(id, body) {
|
|
110
|
+
await api("PATCH", `${base}/issues/comments/${id}`, { body })
|
|
111
|
+
},
|
|
112
|
+
async addLabels(number, labels) {
|
|
113
|
+
await api("POST", `${base}/issues/${number}/labels`, { labels })
|
|
114
|
+
},
|
|
115
|
+
async removeLabel(number, label) {
|
|
116
|
+
await api("DELETE", `${base}/issues/${number}/labels/${encodeURIComponent(label)}`)
|
|
117
|
+
},
|
|
118
|
+
async createIssue({ title, body, labels }) {
|
|
119
|
+
const answer = await api("POST", `${base}/issues`, { title, body, labels })
|
|
120
|
+
if (!isObject(answer) || !Number.isSafeInteger(answer.number) || typeof answer.html_url !== "string") throw failure("unexpected_answer")
|
|
121
|
+
return { number: answer.number, url: answer.html_url }
|
|
122
|
+
},
|
|
123
|
+
async updateIssue(number, patch) {
|
|
124
|
+
await api("PATCH", `${base}/issues/${number}`, patch)
|
|
125
|
+
},
|
|
126
|
+
async readFile(file) {
|
|
127
|
+
if (typeof file !== "string" || !/^[A-Za-z0-9_-][A-Za-z0-9._-]*(?:\/[A-Za-z0-9_-][A-Za-z0-9._-]*)*$/u.test(file)) throw Object.assign(new TypeError("readFile: file must be a relative path"), { code: "store_issues_readfile_file_must_be_a" })
|
|
128
|
+
let answer
|
|
129
|
+
try {
|
|
130
|
+
answer = await api("GET", `${base}/contents/${file}`)
|
|
131
|
+
} catch (error) {
|
|
132
|
+
if (error.code === "http_404") return null
|
|
133
|
+
throw error
|
|
134
|
+
}
|
|
135
|
+
if (!isObject(answer) || answer.encoding !== "base64" || typeof answer.content !== "string") throw failure("unexpected_answer")
|
|
136
|
+
return Buffer.from(answer.content, "base64").toString("utf8")
|
|
137
|
+
},
|
|
138
|
+
async visibility() {
|
|
139
|
+
const answer = await api("GET", base)
|
|
140
|
+
return answer?.private === true ? "private" : answer?.private === false ? "public" : "unknown"
|
|
141
|
+
},
|
|
142
|
+
}
|
|
143
|
+
}
|