@prestyj/cli 5.28.0 → 5.29.0
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 +2 -2
- package/assets/motion/THIRD-PARTY.md +14 -19
- package/assets/motion/bin/contact-sheet.mjs +9 -3
- package/assets/motion/bin/cues.mjs +337 -0
- package/assets/motion/bin/flash-check.mjs +314 -0
- package/assets/motion/bin/fonts.mjs +17 -13
- package/assets/motion/bin/library.mjs +61 -18
- package/assets/motion/bin/motion-blur.mjs +943 -0
- package/assets/motion/bin/motion-check.mjs +366 -9
- package/assets/motion/bin/music-fit.mjs +436 -0
- package/assets/motion/bin/pdf-extract.mjs +22 -10
- package/assets/motion/bin/reference-study.mjs +346 -0
- package/assets/motion/bin/score-synth.mjs +1052 -93
- package/assets/motion/fonts/finger-paint/OFL.txt +93 -0
- package/assets/motion/fonts/finger-paint/finger-paint-normal.woff2 +0 -0
- package/assets/motion/fonts/fonts.json +56 -0
- package/assets/motion/fonts/short-stack/OFL.txt +94 -0
- package/assets/motion/fonts/short-stack/short-stack-normal.woff2 +0 -0
- package/assets/motion/fonts/sora/OFL.txt +93 -0
- package/assets/motion/fonts/sora/sora-normal.woff2 +0 -0
- package/assets/motion/fonts/specimen.jpg +0 -0
- package/assets/motion/fonts/unbounded/OFL.txt +93 -0
- package/assets/motion/fonts/unbounded/unbounded-normal.woff2 +0 -0
- package/assets/motion/library/README.md +52 -14
- package/assets/motion/library/kit/moves.js +1981 -0
- package/assets/motion/library/library.json +232 -0
- package/assets/motion/library/pieces/camera-rig/meta.json +13 -0
- package/assets/motion/library/pieces/camera-rig/piece.html +153 -0
- package/assets/motion/library/pieces/camera-rig/preview.jpg +0 -0
- package/assets/motion/library/pieces/chain-knock/meta.json +13 -0
- package/assets/motion/library/pieces/chain-knock/piece.html +195 -0
- package/assets/motion/library/pieces/chain-knock/preview.jpg +0 -0
- package/assets/motion/library/pieces/gather-to-logo/meta.json +13 -0
- package/assets/motion/library/pieces/gather-to-logo/piece.html +159 -0
- package/assets/motion/library/pieces/gather-to-logo/preview.jpg +0 -0
- package/assets/motion/library/pieces/morph-carry/meta.json +13 -0
- package/assets/motion/library/pieces/morph-carry/piece.html +173 -0
- package/assets/motion/library/pieces/morph-carry/preview.jpg +0 -0
- package/assets/motion/library/pieces/one-shape-journey/meta.json +13 -0
- package/assets/motion/library/pieces/one-shape-journey/piece.html +195 -0
- package/assets/motion/library/pieces/one-shape-journey/preview.jpg +0 -0
- package/assets/motion/library/pieces/open-from-subject/meta.json +13 -0
- package/assets/motion/library/pieces/open-from-subject/piece.html +168 -0
- package/assets/motion/library/pieces/open-from-subject/preview.jpg +0 -0
- package/assets/motion/library/pieces/request-to-result/meta.json +13 -0
- package/assets/motion/library/pieces/request-to-result/piece.html +212 -0
- package/assets/motion/library/pieces/request-to-result/preview.jpg +0 -0
- package/assets/motion/library/pieces/scale-dive/meta.json +13 -0
- package/assets/motion/library/pieces/scale-dive/piece.html +321 -0
- package/assets/motion/library/pieces/scale-dive/preview.jpg +0 -0
- package/assets/motion/library/pieces/screen-replica-steps/meta.json +13 -0
- package/assets/motion/library/pieces/screen-replica-steps/piece.html +366 -0
- package/assets/motion/library/pieces/screen-replica-steps/preview.jpg +0 -0
- package/assets/motion/library/pieces/zoom-into-card/meta.json +13 -0
- package/assets/motion/library/pieces/zoom-into-card/piece.html +179 -0
- package/assets/motion/library/pieces/zoom-into-card/preview.jpg +0 -0
- package/assets/motion/library/sheets/diagram.jpg +0 -0
- package/assets/motion/library/sheets/frame.jpg +0 -0
- package/assets/motion/library/sheets/transition.jpg +0 -0
- package/assets/motion/library/sheets/ui.jpg +0 -0
- package/assets/motion/plugin.json +1 -1
- package/assets/motion/references/build-sheet.md +206 -0
- package/assets/motion/references/runtime/determinism-rules.md +3 -3
- package/assets/motion/references/runtime/gsap-easing-and-stagger.md +28 -28
- package/assets/motion/references/runtime/gsap.md +3 -3
- package/assets/motion/references/runtime/inputs-and-assets.md +21 -16
- package/assets/motion/references/runtime/lint-validate-inspect.md +3 -3
- package/assets/motion/references/runtime/minimal-composition.md +6 -0
- package/assets/motion/references/runtime/preview-render.md +3 -3
- package/assets/motion/skills/app-walkthrough/SKILL.md +66 -0
- package/assets/motion/skills/before-after/SKILL.md +53 -0
- package/assets/motion/skills/brand-kit/SKILL.md +17 -16
- package/assets/motion/skills/dev-tool-video/SKILL.md +57 -0
- package/assets/motion/skills/launch-video/SKILL.md +62 -0
- package/assets/motion/skills/match-reference/SKILL.md +58 -0
- package/assets/motion/skills/motion/SKILL.md +167 -98
- package/assets/motion/skills/source-ingest/SKILL.md +23 -15
- package/assets/motion/skills/website-video/SKILL.md +59 -0
- package/assets/skills/bulletproof/SKILL.md +36 -11
- package/assets/skills/bulletproof/references/agent-surface.md +19 -9
- package/assets/skills/bulletproof/references/audit-protocol.md +20 -5
- package/assets/skills/bulletproof/references/platform-playbooks.md +5 -4
- package/assets/skills/bulletproof/references/provenance.md +26 -1
- package/assets/skills/bulletproof/references/secure-defaults.md +6 -5
- package/assets/skills/bulletproof/references/supply-chain.md +21 -17
- package/assets/skills/bulletproof/references/threat-landscape.md +28 -26
- package/assets/skills/bulletproof/references/verification.md +2 -0
- package/assets/skills/clarify/SKILL.md +25 -16
- package/assets/skills/code-review/SKILL.md +71 -13
- package/assets/skills/code-review/references/agent-diffs.md +27 -0
- package/assets/skills/code-review/references/tests.md +19 -0
- package/assets/skills/compliance-guard/SKILL.md +20 -5
- package/assets/skills/compliance-guard/references/artifacts.md +1 -1
- package/assets/skills/compliance-guard/references/eu-uk.md +16 -16
- package/assets/skills/compliance-guard/references/lawsuit-vectors.md +5 -5
- package/assets/skills/compliance-guard/references/provenance.md +41 -2
- package/assets/skills/compliance-guard/references/sector-gates.md +3 -3
- package/assets/skills/compliance-guard/references/security-baseline.md +2 -2
- package/assets/skills/compliance-guard/references/trigger-map.md +5 -5
- package/assets/skills/compliance-guard/references/us.md +27 -21
- package/assets/skills/durable/SKILL.md +87 -79
- package/assets/skills/durable/references/agent-db-safety.md +69 -0
- package/assets/skills/durable/references/backups-and-runtime.md +19 -12
- package/assets/skills/durable/references/migrations-and-schema.md +13 -6
- package/assets/skills/evidence-led-ui/SKILL.md +69 -127
- package/assets/skills/evidence-led-ui/references/anti-defaults.md +107 -208
- package/assets/skills/evidence-led-ui/references/direction.md +124 -0
- package/assets/skills/evidence-led-ui/references/production-contract.md +8 -0
- package/assets/skills/evidence-led-ui/references/provenance.md +24 -1
- package/assets/skills/lean/SKILL.md +90 -71
- package/assets/skills/lean/references/memory-and-processes.md +3 -2
- package/assets/skills/lean/references/playbooks.md +37 -12
- package/assets/skills/refactoring/SKILL.md +24 -3
- package/assets/skills/refactoring/references/agent-pitfalls.md +4 -1
- package/assets/skills/refactoring/references/legacy.md +21 -0
- package/assets/skills/root-cause/SKILL.md +20 -10
- package/assets/skills/shared-language/SKILL.md +16 -14
- package/assets/skills/tdd/SKILL.md +27 -15
- package/dist/app-sidecar.js +203 -47
- package/dist/app-sidecar.js.map +1 -1
- package/dist/cli.js +20 -28
- package/dist/cli.js.map +1 -1
- package/dist/core/acceptance-checks.d.ts +48 -0
- package/dist/core/acceptance-checks.js +144 -0
- package/dist/core/acceptance-checks.js.map +1 -0
- package/dist/core/agent-session.d.ts +119 -75
- package/dist/core/agent-session.js +561 -395
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/agents.d.ts +6 -5
- package/dist/core/agents.js +12 -3
- package/dist/core/agents.js.map +1 -1
- package/dist/core/ask-user.d.ts +90 -8
- package/dist/core/ask-user.js +124 -13
- package/dist/core/ask-user.js.map +1 -1
- package/dist/core/auth-providers.js +1 -1
- package/dist/core/auth-providers.js.map +1 -1
- package/dist/core/autopilot-verdict.d.ts +5 -1
- package/dist/core/autopilot-verdict.js +30 -13
- package/dist/core/autopilot-verdict.js.map +1 -1
- package/dist/core/bundled-agents.js +1 -3
- package/dist/core/bundled-agents.js.map +1 -1
- package/dist/core/cache-diagnostics.d.ts +68 -0
- package/dist/core/cache-diagnostics.js +196 -0
- package/dist/core/cache-diagnostics.js.map +1 -0
- package/dist/core/cache-expiry.d.ts +87 -0
- package/dist/core/cache-expiry.js +111 -0
- package/dist/core/cache-expiry.js.map +1 -0
- package/dist/core/compaction/compactor.js +78 -48
- package/dist/core/compaction/compactor.js.map +1 -1
- package/dist/core/compaction/plan-step-policy.d.ts +46 -0
- package/dist/core/compaction/plan-step-policy.js +57 -0
- package/dist/core/compaction/plan-step-policy.js.map +1 -0
- package/dist/core/destructive-git-guard.d.ts +90 -0
- package/dist/core/destructive-git-guard.js +871 -0
- package/dist/core/destructive-git-guard.js.map +1 -0
- package/dist/core/event-bus.d.ts +3 -0
- package/dist/core/event-bus.js +5 -0
- package/dist/core/event-bus.js.map +1 -1
- package/dist/core/fast-apply-benchmark.d.ts +1 -1
- package/dist/core/fast-apply-benchmark.js +2 -2
- package/dist/core/fast-apply-benchmark.js.map +1 -1
- package/dist/core/injection-detect.d.ts +38 -0
- package/dist/core/injection-detect.js +232 -0
- package/dist/core/injection-detect.js.map +1 -0
- package/dist/core/keep-awake.d.ts +88 -0
- package/dist/core/keep-awake.js +251 -0
- package/dist/core/keep-awake.js.map +1 -0
- package/dist/core/mcp/client.d.ts +72 -0
- package/dist/core/mcp/client.js +264 -41
- package/dist/core/mcp/client.js.map +1 -1
- package/dist/core/mcp/content.js +6 -2
- package/dist/core/mcp/content.js.map +1 -1
- package/dist/core/mcp/store.d.ts +6 -1
- package/dist/core/mcp/store.js +12 -1
- package/dist/core/mcp/store.js.map +1 -1
- package/dist/core/mcp/types.d.ts +18 -0
- package/dist/core/model-unavailable.d.ts +14 -0
- package/dist/core/model-unavailable.js +23 -0
- package/dist/core/model-unavailable.js.map +1 -0
- package/dist/core/node-debugger.d.ts +148 -0
- package/dist/core/node-debugger.js +642 -0
- package/dist/core/node-debugger.js.map +1 -0
- package/dist/core/nolan-context.d.ts +7 -5
- package/dist/core/nolan-context.js +106 -16
- package/dist/core/nolan-context.js.map +1 -1
- package/dist/core/nolan-prompt.js +24 -21
- package/dist/core/nolan-prompt.js.map +1 -1
- package/dist/core/package-threats.d.ts +18 -0
- package/dist/core/package-threats.js +168 -0
- package/dist/core/package-threats.js.map +1 -0
- package/dist/core/persistent-shell.d.ts +58 -6
- package/dist/core/persistent-shell.js +331 -49
- package/dist/core/persistent-shell.js.map +1 -1
- package/dist/core/process-manager.d.ts +14 -0
- package/dist/core/process-manager.js +61 -0
- package/dist/core/process-manager.js.map +1 -1
- package/dist/core/progress/git-xp.js +8 -14
- package/dist/core/progress/git-xp.js.map +1 -1
- package/dist/core/project-discovery.js +77 -26
- package/dist/core/project-discovery.js.map +1 -1
- package/dist/core/semantic-search-benchmark.d.ts +1 -1
- package/dist/core/semantic-search-benchmark.js +2 -2
- package/dist/core/semantic-search-benchmark.js.map +1 -1
- package/dist/core/session-history.d.ts +12 -0
- package/dist/core/session-history.js +27 -0
- package/dist/core/session-history.js.map +1 -1
- package/dist/core/session-manager.d.ts +13 -1
- package/dist/core/session-manager.js +38 -18
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/session-summary-index.d.ts +37 -0
- package/dist/core/session-summary-index.js +172 -0
- package/dist/core/session-summary-index.js.map +1 -0
- package/dist/core/settings-manager.d.ts +2 -0
- package/dist/core/settings-manager.js +10 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/shell-threats-popular-packages.d.ts +11 -0
- package/dist/core/shell-threats-popular-packages.js +675 -0
- package/dist/core/shell-threats-popular-packages.js.map +1 -0
- package/dist/core/shell-threats.d.ts +8 -0
- package/dist/core/shell-threats.js +186 -0
- package/dist/core/shell-threats.js.map +1 -0
- package/dist/core/skills.js +16 -4
- package/dist/core/skills.js.map +1 -1
- package/dist/core/stream-rules.d.ts +30 -0
- package/dist/core/stream-rules.js +151 -0
- package/dist/core/stream-rules.js.map +1 -0
- package/dist/core/subagent-manager.d.ts +23 -6
- package/dist/core/subagent-manager.js +25 -9
- package/dist/core/subagent-manager.js.map +1 -1
- package/dist/core/subagent-policy.js +1 -1
- package/dist/core/subagent-policy.js.map +1 -1
- package/dist/core/subagent-receipt.d.ts +54 -0
- package/dist/core/subagent-receipt.js +276 -0
- package/dist/core/subagent-receipt.js.map +1 -0
- package/dist/core/subagent-turn-record.d.ts +2 -0
- package/dist/core/subagent-turn-record.js.map +1 -1
- package/dist/core/test-impact.d.ts +73 -0
- package/dist/core/test-impact.js +467 -0
- package/dist/core/test-impact.js.map +1 -0
- package/dist/core/thinking-level.d.ts +1 -1
- package/dist/core/thinking-level.js +1 -1
- package/dist/core/thinking-level.js.map +1 -1
- package/dist/core/verification-gate.d.ts +2 -0
- package/dist/core/verification-gate.js +4 -0
- package/dist/core/verification-gate.js.map +1 -1
- package/dist/core/verification-snapshot.js +3 -5
- package/dist/core/verification-snapshot.js.map +1 -1
- package/dist/core/workspace-guard.d.ts +18 -7
- package/dist/core/workspace-guard.js +227 -60
- package/dist/core/workspace-guard.js.map +1 -1
- package/dist/core/worktree-setup.d.ts +23 -0
- package/dist/core/worktree-setup.js +128 -9
- package/dist/core/worktree-setup.js.map +1 -1
- package/dist/core/worktree.d.ts +20 -2
- package/dist/core/worktree.js +74 -31
- package/dist/core/worktree.js.map +1 -1
- package/dist/interactive.js +2 -1
- package/dist/interactive.js.map +1 -1
- package/dist/modes/json-mode.js +11 -2
- package/dist/modes/json-mode.js.map +1 -1
- package/dist/modes/subagent-worker-mode.d.ts +36 -1
- package/dist/modes/subagent-worker-mode.js +100 -42
- package/dist/modes/subagent-worker-mode.js.map +1 -1
- package/dist/motion-agent/motion-agent.d.ts +7 -3
- package/dist/motion-agent/motion-agent.js +6 -8
- package/dist/motion-agent/motion-agent.js.map +1 -1
- package/dist/motion-agent/motion-prompt.d.ts +1 -1
- package/dist/motion-agent/motion-prompt.js +16 -25
- package/dist/motion-agent/motion-prompt.js.map +1 -1
- package/dist/motion-agent/motion-review-session.js +1 -1
- package/dist/motion-agent/motion-review-session.js.map +1 -1
- package/dist/motion-agent/motion-review.d.ts +10 -3
- package/dist/motion-agent/motion-review.js +15 -7
- package/dist/motion-agent/motion-review.js.map +1 -1
- package/dist/motion-agent/motion-studio-context.js +1 -1
- package/dist/motion-agent/motion-studio-context.js.map +1 -1
- package/dist/system-prompt.d.ts +2 -1
- package/dist/system-prompt.js +15 -4
- package/dist/system-prompt.js.map +1 -1
- package/dist/test-support/keep-alive.d.ts +14 -0
- package/dist/test-support/keep-alive.js +17 -0
- package/dist/test-support/keep-alive.js.map +1 -0
- package/dist/tools/ask-user.js +3 -3
- package/dist/tools/ask-user.js.map +1 -1
- package/dist/tools/bash-read-evidence.d.ts +10 -0
- package/dist/tools/bash-read-evidence.js +133 -0
- package/dist/tools/bash-read-evidence.js.map +1 -0
- package/dist/tools/bash.d.ts +10 -1
- package/dist/tools/bash.js +179 -7
- package/dist/tools/bash.js.map +1 -1
- package/dist/tools/debug.d.ts +54 -0
- package/dist/tools/debug.js +233 -0
- package/dist/tools/debug.js.map +1 -0
- package/dist/tools/edit.js +13 -5
- package/dist/tools/edit.js.map +1 -1
- package/dist/tools/goals.d.ts +1 -1
- package/dist/tools/index.d.ts +25 -2
- package/dist/tools/index.js +48 -7
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/prompt-hints.js +2 -0
- package/dist/tools/prompt-hints.js.map +1 -1
- package/dist/tools/read-tracker.d.ts +35 -2
- package/dist/tools/read-tracker.js +108 -11
- package/dist/tools/read-tracker.js.map +1 -1
- package/dist/tools/read.js +39 -7
- package/dist/tools/read.js.map +1 -1
- package/dist/tools/skill.js +5 -0
- package/dist/tools/skill.js.map +1 -1
- package/dist/tools/subagent-control.js +44 -8
- package/dist/tools/subagent-control.js.map +1 -1
- package/dist/tools/subagent-shared.d.ts +48 -8
- package/dist/tools/subagent-shared.js +75 -14
- package/dist/tools/subagent-shared.js.map +1 -1
- package/dist/tools/subagent.d.ts +8 -2
- package/dist/tools/subagent.js +28 -10
- package/dist/tools/subagent.js.map +1 -1
- package/dist/tools/task-output.js +3 -2
- package/dist/tools/task-output.js.map +1 -1
- package/dist/tools/task-send.d.ts +1 -1
- package/dist/tools/task-send.js +15 -1
- package/dist/tools/task-send.js.map +1 -1
- package/dist/tools/tool-tiers.d.ts +2 -2
- package/dist/tools/tool-tiers.js +3 -2
- package/dist/tools/tool-tiers.js.map +1 -1
- package/dist/tools/truncate.d.ts +21 -0
- package/dist/tools/truncate.js +187 -0
- package/dist/tools/truncate.js.map +1 -1
- package/dist/tools/ui-adopt.js +2 -0
- package/dist/tools/ui-adopt.js.map +1 -1
- package/dist/tools/write.js +4 -3
- package/dist/tools/write.js.map +1 -1
- package/dist/ui/App.d.ts +0 -4
- package/dist/ui/App.js +5 -28
- package/dist/ui/App.js.map +1 -1
- package/dist/ui/components/ActivityIndicator.js +1 -0
- package/dist/ui/components/ActivityIndicator.js.map +1 -1
- package/dist/ui/components/Footer.js +1 -1
- package/dist/ui/components/Footer.js.map +1 -1
- package/dist/ui/hooks/useAgentLoop.d.ts +1 -8
- package/dist/ui/hooks/useAgentLoop.js +1 -119
- package/dist/ui/hooks/useAgentLoop.js.map +1 -1
- package/dist/ui/render.d.ts +2 -4
- package/dist/ui/render.js +3 -2
- package/dist/ui/render.js.map +1 -1
- package/dist/utils/git.d.ts +77 -0
- package/dist/utils/git.js +285 -21
- package/dist/utils/git.js.map +1 -1
- package/dist/utils/github-ci.js +2 -1
- package/dist/utils/github-ci.js.map +1 -1
- package/dist/utils/github.js +11 -9
- package/dist/utils/github.js.map +1 -1
- package/dist/utils/image.d.ts +14 -0
- package/dist/utils/image.js +16 -0
- package/dist/utils/image.js.map +1 -1
- package/dist/utils/process.d.ts +20 -0
- package/dist/utils/process.js +98 -0
- package/dist/utils/process.js.map +1 -1
- package/dist/utils/text.d.ts +12 -0
- package/dist/utils/text.js +11 -0
- package/dist/utils/text.js.map +1 -1
- package/package.json +6 -6
- package/assets/motion/skills/mixkit-split-text-617/SKILL.md +0 -115
- package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-480.json +0 -1
- package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-494.json +0 -1
- package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-5.json +0 -1
- package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-508.json +0 -1
- package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-6525.json +0 -1
- package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-6539.json +0 -1
- package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-6647.json +0 -1
- package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-6663.json +0 -1
- package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-6677.json +0 -1
- package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-6691.json +0 -1
- package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-6706.json +0 -1
- package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-6722.json +0 -1
- package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-6736.json +0 -1
- package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-6750.json +0 -1
- package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-6764.json +0 -1
- package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-6780.json +0 -1
- package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-6794.json +0 -1
- package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-6810.json +0 -1
- package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-6823.json +0 -1
- package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-6872.json +0 -1
- package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-6936.json +0 -1
- package/assets/motion/skills/mixkit-split-text-617/data/compositions/comp-76.json +0 -1
- package/assets/motion/skills/mixkit-split-text-617/data/manifest.json +0 -495
- package/assets/motion/skills/mixkit-split-text-617/references/RECONSTRUCTION.md +0 -201
- package/assets/motion/skills/mixkit-split-text-617/references/VERIFICATION.md +0 -107
- package/assets/motion/skills/mixkit-split-text-617/tools/inspect_motion.py +0 -130
- package/assets/motion/skills/video-qa/SKILL.md +0 -66
- package/dist/core/ideal-review-subagent.d.ts +0 -42
- package/dist/core/ideal-review-subagent.js +0 -95
- package/dist/core/ideal-review-subagent.js.map +0 -1
- package/dist/core/ideal-review.d.ts +0 -82
- package/dist/core/ideal-review.js +0 -242
- package/dist/core/ideal-review.js.map +0 -1
- package/dist/motion-agent/motion-check-tool.d.ts +0 -21
- package/dist/motion-agent/motion-check-tool.js +0 -206
- package/dist/motion-agent/motion-check-tool.js.map +0 -1
|
@@ -6,14 +6,89 @@
|
|
|
6
6
|
* per call vs ~6.4ms for spawn-per-call (see bash-spawn-benchmark.ts), and —
|
|
7
7
|
* the real win — cd/env/shell state survive across calls.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
9
|
+
* Losing that state silently is the failure mode this file guards against:
|
|
10
|
+
*
|
|
11
|
+
* - Timeout / abort stops only the running command: the shell gets SIGUSR1
|
|
12
|
+
* (its trap breaks out of the wrapper loop, so the rest of the command list
|
|
13
|
+
* is skipped) and every descendant of the shell is SIGTERM'd, then
|
|
14
|
+
* SIGKILL'd. The shell itself survives with its cwd/env. Only if it still
|
|
15
|
+
* has not printed the sentinel after a grace period (a builtin busy loop, a
|
|
16
|
+
* user trap) is the whole shell killed.
|
|
17
|
+
* - After every command the sentinel line snapshots the physical cwd and
|
|
18
|
+
* `export -p` to a private temp file (builtins + one redirect, no fork).
|
|
19
|
+
* - When the shell dies (`exit`, `kill -9 $$`, OOM, or the fallback kill
|
|
20
|
+
* above) a fresh shell is started at once and restored from that snapshot,
|
|
21
|
+
* and the result carries a one-line note saying so. The command that killed
|
|
22
|
+
* it is never re-run.
|
|
23
|
+
*
|
|
24
|
+
* Callers must fall back to spawn-per-call when bash is unavailable (Windows
|
|
25
|
+
* cmd.exe fallback path). On Windows (Git Bash) a command cannot be stopped
|
|
26
|
+
* without the shell — MSYS pids are not native pids and there are no POSIX
|
|
27
|
+
* signals — so timeout/abort still kills the shell tree, but the restart
|
|
28
|
+
* restores cwd/env the same way.
|
|
11
29
|
*/
|
|
12
30
|
import { spawn } from "node:child_process";
|
|
13
31
|
import { randomUUID } from "node:crypto";
|
|
32
|
+
import { mkdtempSync, readFileSync, rmSync } from "node:fs";
|
|
33
|
+
import os from "node:os";
|
|
34
|
+
import path from "node:path";
|
|
14
35
|
import { sliceHead } from "@prestyj/ai";
|
|
15
36
|
import { resolveShell } from "./shell.js";
|
|
16
|
-
import { killProcessTree } from "../utils/process.js";
|
|
37
|
+
import { killProcessTree, listDescendantPids, signalDescendants } from "../utils/process.js";
|
|
38
|
+
/** How long a stopped command's shell gets to print its sentinel before it is killed. */
|
|
39
|
+
const INTERRUPT_GRACE_MS = 2_000;
|
|
40
|
+
/** Re-sweep for descendants the command forked after the first signal. */
|
|
41
|
+
const INTERRUPT_SWEEP_MS = 200;
|
|
42
|
+
/** Startup handshake / state restore of a freshly spawned shell. */
|
|
43
|
+
const SETUP_TIMEOUT_MS = 10_000;
|
|
44
|
+
/** Interrupt trap: `break` out of every loop, including the per-command wrapper loop. */
|
|
45
|
+
const SETUP_SCRIPT = "trap 'break 1000 2>/dev/null' USR1";
|
|
46
|
+
const stateDirs = new Set();
|
|
47
|
+
let exitHookInstalled = false;
|
|
48
|
+
function trackStateDir(dir) {
|
|
49
|
+
stateDirs.add(dir);
|
|
50
|
+
if (exitHookInstalled)
|
|
51
|
+
return;
|
|
52
|
+
exitHookInstalled = true;
|
|
53
|
+
process.once("exit", () => {
|
|
54
|
+
for (const d of stateDirs)
|
|
55
|
+
rmSync(d, { recursive: true, force: true });
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/** Single-quote for bash. */
|
|
59
|
+
export function shellQuote(value) {
|
|
60
|
+
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Split a state file (`pwd -P` line, then `export -p`) into cwd + env script.
|
|
64
|
+
* Variables the new shell must own (PWD, OLDPWD, SHLVL) are dropped.
|
|
65
|
+
*/
|
|
66
|
+
export function parseStateSnapshot(text) {
|
|
67
|
+
if (!text.trim())
|
|
68
|
+
return null;
|
|
69
|
+
// The cwd may in theory contain a newline, so split at the first export line.
|
|
70
|
+
const m = /\n(?=declare -|export )/.exec(text);
|
|
71
|
+
const cwd = (m ? text.slice(0, m.index) : text.replace(/\n$/, "")) || null;
|
|
72
|
+
const env = m
|
|
73
|
+
? text
|
|
74
|
+
.slice(m.index + 1)
|
|
75
|
+
.split("\n")
|
|
76
|
+
.filter((line) => !/^(declare -\S+|export) (PWD|OLDPWD|SHLVL)(=|$)/.test(line))
|
|
77
|
+
.join("\n")
|
|
78
|
+
: "";
|
|
79
|
+
return { cwd, env };
|
|
80
|
+
}
|
|
81
|
+
/** Restore script: env first (its PWD is filtered), then cd, then report where we landed. */
|
|
82
|
+
export function buildRestoreScript(snapshot) {
|
|
83
|
+
const env = snapshot.env.trim() ? `{ ${snapshot.env}\n} >/dev/null 2>&1\n` : "";
|
|
84
|
+
const cd = snapshot.cwd ? `builtin cd -- ${shellQuote(snapshot.cwd)} >/dev/null 2>&1\n` : "";
|
|
85
|
+
return `${env}${cd}builtin pwd -P`;
|
|
86
|
+
}
|
|
87
|
+
function describeExit(code, signal) {
|
|
88
|
+
if (signal)
|
|
89
|
+
return `killed by ${signal}`;
|
|
90
|
+
return code === null ? "exited" : `exited with code ${code}`;
|
|
91
|
+
}
|
|
17
92
|
export class PersistentShell {
|
|
18
93
|
cwd;
|
|
19
94
|
env;
|
|
@@ -21,8 +96,17 @@ export class PersistentShell {
|
|
|
21
96
|
shellOpts;
|
|
22
97
|
launch;
|
|
23
98
|
child = null;
|
|
24
|
-
|
|
99
|
+
/** The shell's own `$$`, used to stop just its command. */
|
|
100
|
+
shellPid = null;
|
|
25
101
|
busy = false;
|
|
102
|
+
stateDir = null;
|
|
103
|
+
/**
|
|
104
|
+
* One-line notes about restarts, kept until `takeRestartNote()` so a helper
|
|
105
|
+
* run (e.g. a guard's `pwd`) cannot swallow the note meant for the model.
|
|
106
|
+
*/
|
|
107
|
+
pendingNotes = [];
|
|
108
|
+
/** Bumped by kill(): a run cut short by an explicit kill must not restart the shell. */
|
|
109
|
+
generation = 0;
|
|
26
110
|
constructor(cwd, env, maxOutputBytes, shellOpts, launch) {
|
|
27
111
|
this.cwd = cwd;
|
|
28
112
|
this.env = env;
|
|
@@ -30,14 +114,45 @@ export class PersistentShell {
|
|
|
30
114
|
this.shellOpts = shellOpts;
|
|
31
115
|
this.launch = launch;
|
|
32
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* Consume the note(s) for the model about shell restarts since the last
|
|
119
|
+
* call, e.g. `[Shell exited with code 3, so it was restarted; restored
|
|
120
|
+
* working directory /x and exported environment variables. …]`.
|
|
121
|
+
*/
|
|
122
|
+
takeRestartNote() {
|
|
123
|
+
const note = this.pendingNotes.join("\n") || undefined;
|
|
124
|
+
this.pendingNotes = [];
|
|
125
|
+
return note;
|
|
126
|
+
}
|
|
33
127
|
/** True while a previous persistent command is still running. */
|
|
34
128
|
get isBusy() {
|
|
35
129
|
return this.busy;
|
|
36
130
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
131
|
+
/** Private 0700 temp dir holding the state snapshot; null if unavailable. */
|
|
132
|
+
get statePath() {
|
|
133
|
+
if (!this.stateDir) {
|
|
134
|
+
try {
|
|
135
|
+
this.stateDir = mkdtempSync(path.join(os.tmpdir(), "ez-psh-"));
|
|
136
|
+
trackStateDir(this.stateDir);
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return path.join(this.stateDir, "state.sh");
|
|
143
|
+
}
|
|
144
|
+
readSnapshot() {
|
|
145
|
+
const file = this.stateDir ? path.join(this.stateDir, "state.sh") : null;
|
|
146
|
+
if (!file)
|
|
147
|
+
return null;
|
|
148
|
+
try {
|
|
149
|
+
return parseStateSnapshot(readFileSync(file, "utf-8"));
|
|
40
150
|
}
|
|
151
|
+
catch {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
spawnChild() {
|
|
41
156
|
// Fresh session: no rc files so startup is fast and deterministic.
|
|
42
157
|
//
|
|
43
158
|
// Spawn the SAME bash the one-shot path resolved, not a bare `bash`: on
|
|
@@ -56,36 +171,101 @@ export class PersistentShell {
|
|
|
56
171
|
// past a parent crash instead of grouping it for a clean tree-kill.
|
|
57
172
|
detached: process.platform !== "win32",
|
|
58
173
|
});
|
|
174
|
+
// Writing to a shell that just died is EPIPE on stdin; the exit handler
|
|
175
|
+
// reports it, so don't let the stream error crash the process.
|
|
176
|
+
child.stdin?.on("error", () => { });
|
|
59
177
|
// Don't let a lingering session shell keep the parent process alive.
|
|
60
178
|
child.unref();
|
|
61
179
|
this.child = child;
|
|
62
|
-
this.
|
|
180
|
+
this.shellPid = null;
|
|
63
181
|
return child;
|
|
64
182
|
}
|
|
183
|
+
/** Spawn a shell, install the interrupt trap and learn its pid. */
|
|
184
|
+
async startShell() {
|
|
185
|
+
const child = this.spawnChild();
|
|
186
|
+
const res = await this.send(child, `${SETUP_SCRIPT}; builtin echo "$$"`, SETUP_TIMEOUT_MS);
|
|
187
|
+
if (res.kind !== "done") {
|
|
188
|
+
this.hardKill(child);
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
const pid = parseInt(res.output.trim().split("\n").pop() ?? "", 10);
|
|
192
|
+
this.shellPid = Number.isNaN(pid) ? null : pid;
|
|
193
|
+
return true;
|
|
194
|
+
}
|
|
65
195
|
/**
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
* skipped within the same shell.
|
|
196
|
+
* Replace a dead (or killed) shell with a fresh one restored from the
|
|
197
|
+
* snapshot taken after the last completed command. Returns the one-line
|
|
198
|
+
* note for the tool result: `[Shell <how>, so it was restarted; <restored>.
|
|
199
|
+
* <lost> <tail>]`.
|
|
71
200
|
*/
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
201
|
+
async restart(how, tail) {
|
|
202
|
+
const snapshot = this.readSnapshot();
|
|
203
|
+
const lost = "Shell functions, aliases, unexported variables and background jobs are gone.";
|
|
204
|
+
const started = await this.startShell().catch(() => false);
|
|
205
|
+
if (!started || !this.child) {
|
|
206
|
+
this.child = null;
|
|
207
|
+
return `[Shell ${how}, and starting a new shell failed; the next command starts a fresh shell in ${this.cwd} without the previous cwd/env. ${tail}]`;
|
|
78
208
|
}
|
|
79
|
-
|
|
80
|
-
|
|
209
|
+
if (!snapshot) {
|
|
210
|
+
return `[Shell ${how}, so it was restarted in ${this.cwd}; there was no saved state, so earlier cd/exported variables are gone. ${tail}]`;
|
|
211
|
+
}
|
|
212
|
+
const res = await this.send(this.child, buildRestoreScript(snapshot), SETUP_TIMEOUT_MS);
|
|
213
|
+
if (res.kind !== "done") {
|
|
214
|
+
this.hardKill(this.child);
|
|
215
|
+
return `[Shell ${how}, and restoring its state failed; the next command starts a fresh shell in ${this.cwd} without the previous cwd/env. ${tail}]`;
|
|
216
|
+
}
|
|
217
|
+
const landed = res.output.trim().split("\n").pop() || this.cwd;
|
|
218
|
+
const restored = snapshot.cwd && landed === snapshot.cwd
|
|
219
|
+
? `restored working directory ${landed} and exported environment variables`
|
|
220
|
+
: `restored exported environment variables; the previous working directory ${snapshot.cwd ?? "(unknown)"} no longer exists, so it is ${landed}`;
|
|
221
|
+
return `[Shell ${how}, so it was restarted; ${restored}. ${lost} ${tail}]`;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* The shell's own pid, if it is a real descendant of the spawned process
|
|
225
|
+
* (inside a Linux sandbox's pid namespace `$$` is not a host pid). Never on
|
|
226
|
+
* Windows, where MSYS pids are not native pids.
|
|
227
|
+
*/
|
|
228
|
+
verifiedShellPid(child) {
|
|
229
|
+
const pid = this.shellPid;
|
|
230
|
+
if (process.platform === "win32" || !pid || !child.pid)
|
|
231
|
+
return null;
|
|
232
|
+
if (pid === child.pid)
|
|
233
|
+
return pid;
|
|
234
|
+
return listDescendantPids(child.pid).includes(pid) ? pid : null;
|
|
235
|
+
}
|
|
236
|
+
hardKill(child) {
|
|
237
|
+
if (child.pid)
|
|
238
|
+
killProcessTree(child.pid);
|
|
239
|
+
if (this.child === child) {
|
|
240
|
+
this.child = null;
|
|
241
|
+
this.shellPid = null;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Write one script and wait for its sentinel. `run()` passes a signal and
|
|
246
|
+
* gets the stop-the-command-not-the-shell interrupt; setup scripts don't.
|
|
247
|
+
*/
|
|
248
|
+
send(child, script, timeoutMs, signal, onChunk) {
|
|
81
249
|
const sentinel = `__EZ_PSH_${randomUUID()}__`;
|
|
82
|
-
|
|
83
|
-
//
|
|
84
|
-
|
|
250
|
+
const statePath = this.statePath;
|
|
251
|
+
// Snapshot cwd + exported env before the sentinel, so a shell that dies
|
|
252
|
+
// in the next command can be restored to exactly this point. Builtins and
|
|
253
|
+
// one redirect only — no fork. On Windows Git Bash accepts `C:/…` paths.
|
|
254
|
+
const snapshot = statePath
|
|
255
|
+
? `{ builtin pwd -P; builtin export -p; } >${shellQuote(statePath.replace(/\\/g, "/"))} 2>/dev/null; `
|
|
256
|
+
: "";
|
|
257
|
+
// The one-iteration loop is what the USR1 trap breaks out of, skipping the
|
|
258
|
+
// rest of an interrupted command list. `</dev/null` keeps stdin-reading
|
|
259
|
+
// commands (cat, read) from eating the next sentinel line.
|
|
260
|
+
const wrapped = `for __ez_psh_once in 1; do { ${script}\n} </dev/null; done; ` +
|
|
261
|
+
`__ez_psh_rc=$?; ${snapshot}builtin echo "${sentinel}$__ez_psh_rc"\n`;
|
|
85
262
|
return new Promise((resolve) => {
|
|
86
263
|
let out = "";
|
|
87
264
|
let capped = false;
|
|
88
265
|
let done = false;
|
|
266
|
+
let interrupted = null;
|
|
267
|
+
let sweep;
|
|
268
|
+
let grace;
|
|
89
269
|
const finish = (result) => {
|
|
90
270
|
if (done)
|
|
91
271
|
return;
|
|
@@ -95,10 +275,12 @@ export class PersistentShell {
|
|
|
95
275
|
child.off("exit", onExit);
|
|
96
276
|
child.off("error", onError);
|
|
97
277
|
clearTimeout(timer);
|
|
98
|
-
|
|
99
|
-
|
|
278
|
+
clearInterval(sweep);
|
|
279
|
+
clearTimeout(grace);
|
|
280
|
+
signal?.removeEventListener("abort", onAbort);
|
|
100
281
|
resolve(result);
|
|
101
282
|
};
|
|
283
|
+
const capNote = () => `\n[Output capped at ${this.maxOutputBytes} bytes]`;
|
|
102
284
|
// When output is capped we stop growing `out` but MUST keep scanning for
|
|
103
285
|
// the sentinel — otherwise an over-cap command hangs until timeout and
|
|
104
286
|
// needlessly destroys the session. `scanTail` keeps a small rolling
|
|
@@ -109,12 +291,13 @@ export class PersistentShell {
|
|
|
109
291
|
if (idx === -1)
|
|
110
292
|
return;
|
|
111
293
|
const code = parseInt(scan.slice(idx + sentinel.length), 10);
|
|
112
|
-
const body = fromCapped ? out : scan.slice(0, idx);
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
294
|
+
const body = (fromCapped ? out : scan.slice(0, idx)).replace(/\n$/, "");
|
|
295
|
+
const output = body + (fromCapped ? capNote() : "");
|
|
296
|
+
if (interrupted) {
|
|
297
|
+
finish({ kind: interrupted, shellKept: true, output });
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
finish({ kind: "done", code: Number.isNaN(code) ? 1 : code, output });
|
|
118
301
|
};
|
|
119
302
|
const onData = (d) => {
|
|
120
303
|
const text = d.toString("utf-8");
|
|
@@ -134,36 +317,135 @@ export class PersistentShell {
|
|
|
134
317
|
onChunk?.(text);
|
|
135
318
|
checkSentinel(capped ? scanTail : out, capped);
|
|
136
319
|
};
|
|
137
|
-
const
|
|
138
|
-
this.
|
|
139
|
-
finish({
|
|
140
|
-
}
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
320
|
+
const giveUp = (kind, stuck = false) => {
|
|
321
|
+
this.hardKill(child);
|
|
322
|
+
finish({ kind, shellKept: false, stuck, output: out + (capped ? capNote() : "") });
|
|
323
|
+
};
|
|
324
|
+
const interrupt = (kind) => {
|
|
325
|
+
if (done || interrupted)
|
|
326
|
+
return;
|
|
327
|
+
interrupted = kind;
|
|
328
|
+
if (!signal) {
|
|
329
|
+
// Setup scripts: nothing worth preserving yet.
|
|
330
|
+
giveUp(kind);
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
const pid = this.verifiedShellPid(child);
|
|
334
|
+
if (pid === null) {
|
|
335
|
+
giveUp(kind);
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
// Order matters: the trap is deferred until the foreground child dies,
|
|
339
|
+
// so it must be pending before the children are killed.
|
|
340
|
+
try {
|
|
341
|
+
process.kill(pid, "SIGUSR1");
|
|
342
|
+
}
|
|
343
|
+
catch {
|
|
344
|
+
giveUp(kind);
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
signalDescendants(pid, "SIGTERM");
|
|
348
|
+
// Anything that ignored SIGTERM, or was forked since, gets SIGKILL.
|
|
349
|
+
sweep = setInterval(() => signalDescendants(pid, "SIGKILL"), INTERRUPT_SWEEP_MS);
|
|
350
|
+
grace = setTimeout(() => giveUp(kind, true), INTERRUPT_GRACE_MS);
|
|
144
351
|
};
|
|
145
|
-
|
|
352
|
+
const timer = setTimeout(() => interrupt("timeout"), timeoutMs);
|
|
353
|
+
const onAbort = () => interrupt("abort");
|
|
354
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
146
355
|
// `exit N` (or a crash) ends the session shell itself — the sentinel
|
|
147
|
-
// never prints, so settle from the shell's own exit
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
356
|
+
// never prints, so settle from the shell's own exit status.
|
|
357
|
+
const onExit = (code, sig) => {
|
|
358
|
+
if (this.child === child) {
|
|
359
|
+
this.child = null;
|
|
360
|
+
this.shellPid = null;
|
|
361
|
+
}
|
|
362
|
+
const output = out.replace(/\n$/, "") + (capped ? capNote() : "");
|
|
363
|
+
if (interrupted)
|
|
364
|
+
finish({ kind: interrupted, shellKept: false, output });
|
|
365
|
+
else
|
|
366
|
+
finish({ kind: "exited", code, signal: sig, output });
|
|
152
367
|
};
|
|
153
368
|
child.on("exit", onExit);
|
|
154
|
-
const onError = () => finish({
|
|
369
|
+
const onError = () => finish({ kind: "error", output: "failed to spawn session bash" });
|
|
155
370
|
child.on("error", onError);
|
|
156
371
|
child.stdout?.on("data", onData);
|
|
157
372
|
child.stderr?.on("data", onData);
|
|
158
373
|
child.stdin?.write(wrapped);
|
|
159
374
|
});
|
|
160
375
|
}
|
|
161
|
-
/**
|
|
376
|
+
/**
|
|
377
|
+
* Run one command in the session shell. Serialized by the tool's sequential
|
|
378
|
+
* execution mode; a concurrent call while busy is rejected defensively.
|
|
379
|
+
*/
|
|
380
|
+
async run(command, timeoutMs, signal, onChunk) {
|
|
381
|
+
if (this.busy) {
|
|
382
|
+
return { exitCode: 1, output: "persistent shell is busy with a previous command" };
|
|
383
|
+
}
|
|
384
|
+
this.busy = true;
|
|
385
|
+
try {
|
|
386
|
+
const notes = this.pendingNotes;
|
|
387
|
+
const current = this.child;
|
|
388
|
+
if (current && (current.exitCode !== null || current.signalCode !== null)) {
|
|
389
|
+
// Died between commands (external kill, OOM). Nothing has been sent,
|
|
390
|
+
// so restarting here cannot double-execute anything.
|
|
391
|
+
this.child = null;
|
|
392
|
+
notes.push(await this.restart(`had ${describeExit(current.exitCode, current.signalCode)} since the last command`, "This command ran in the new shell."));
|
|
393
|
+
}
|
|
394
|
+
if (!this.child && !(await this.startShell().catch(() => false))) {
|
|
395
|
+
this.child = null;
|
|
396
|
+
return { exitCode: 1, output: "failed to spawn session bash" };
|
|
397
|
+
}
|
|
398
|
+
const child = this.child;
|
|
399
|
+
const generation = this.generation;
|
|
400
|
+
const res = await this.send(child, command, timeoutMs, signal, onChunk);
|
|
401
|
+
if (generation !== this.generation) {
|
|
402
|
+
return { exitCode: res.kind === "done" ? res.code : 1, output: res.output };
|
|
403
|
+
}
|
|
404
|
+
switch (res.kind) {
|
|
405
|
+
case "done":
|
|
406
|
+
return { exitCode: res.code, output: res.output };
|
|
407
|
+
case "error":
|
|
408
|
+
this.hardKill(child);
|
|
409
|
+
return { exitCode: 1, output: res.output };
|
|
410
|
+
case "exited": {
|
|
411
|
+
notes.push(await this.restart(describeExit(res.code, res.signal), "The command was not re-run."));
|
|
412
|
+
// A signal death has no code; report it the way bash would (128+n).
|
|
413
|
+
const code = res.code ?? (res.signal ? 128 + (os.constants.signals[res.signal] ?? 0) : 1);
|
|
414
|
+
return { exitCode: code, output: res.output };
|
|
415
|
+
}
|
|
416
|
+
case "timeout":
|
|
417
|
+
case "abort": {
|
|
418
|
+
const exitCode = res.kind === "timeout" ? "TIMEOUT" : 1;
|
|
419
|
+
if (res.shellKept) {
|
|
420
|
+
return { exitCode, output: res.output, shellKept: true };
|
|
421
|
+
}
|
|
422
|
+
const event = res.kind === "timeout" ? "timed out" : "was aborted";
|
|
423
|
+
const how = res.stuck
|
|
424
|
+
? `did not stop when the command ${event}, so it was killed`
|
|
425
|
+
: `was killed to stop the command that ${event}`;
|
|
426
|
+
notes.push(await this.restart(how, "The command was not re-run."));
|
|
427
|
+
return { exitCode, output: res.output, shellKept: false };
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
finally {
|
|
432
|
+
this.busy = false;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
/** Kill the session shell and drop its saved state; the next run() starts fresh. */
|
|
162
436
|
kill() {
|
|
163
|
-
|
|
164
|
-
|
|
437
|
+
this.generation++;
|
|
438
|
+
if (this.child)
|
|
439
|
+
this.hardKill(this.child);
|
|
165
440
|
this.child = null;
|
|
441
|
+
this.shellPid = null;
|
|
166
442
|
this.busy = false;
|
|
443
|
+
this.pendingNotes = [];
|
|
444
|
+
if (this.stateDir) {
|
|
445
|
+
rmSync(this.stateDir, { recursive: true, force: true });
|
|
446
|
+
stateDirs.delete(this.stateDir);
|
|
447
|
+
this.stateDir = null;
|
|
448
|
+
}
|
|
167
449
|
}
|
|
168
450
|
}
|
|
169
451
|
//# sourceMappingURL=persistent-shell.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persistent-shell.js","sourceRoot":"","sources":["../../src/core/persistent-shell.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,YAAY,EAA+C,MAAM,YAAY,CAAC;AACvF,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAOtD,MAAM,OAAO,eAAe;IAMP;IACA;IACA;IACA;IACA;IATX,KAAK,GAAwB,IAAI,CAAC;IAClC,MAAM,GAAG,EAAE,CAAC;IACZ,IAAI,GAAG,KAAK,CAAC;IAErB,YACmB,GAAW,EACX,GAAsB,EACtB,cAAsB,EACtB,SAA4B,EAC5B,MAAwB;QAJxB,QAAG,GAAH,GAAG,CAAQ;QACX,QAAG,GAAH,GAAG,CAAmB;QACtB,mBAAc,GAAd,cAAc,CAAQ;QACtB,cAAS,GAAT,SAAS,CAAmB;QAC5B,WAAM,GAAN,MAAM,CAAkB;IACxC,CAAC;IAEJ,iEAAiE;IACjE,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAEO,WAAW;QACjB,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;YACrE,OAAO,IAAI,C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,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,aAAa,CAAC;oBACnE,MAAM,GAAG,GAAG,GAAG,CAAC,KAAK;wBACnB,CAAC,CAAC,iCAAiC,KAAK,oBAAoB;wBAC5D,CAAC,CAAC,uCAAuC,KAAK,EAAE,CAAC;oBACnD,KAAK,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,6BAA6B,CAAC,CAAC,CAAC;oBACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;gBAC5D,CAAC;YACH,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;QACpB,CAAC;IACH,CAAC;IAED,oFAAoF;IACpF,IAAI;QACF,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,IAAI,IAAI,CAAC,KAAK;YAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC1C,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;QAClB,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC;QACvB,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YACxD,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAChC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACvB,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { spawnSync } from "node:child_process";
|
|
2
|
+
import { type ChildProcess } from "node:child_process";
|
|
2
3
|
import { type ShellResolution } from "./shell.js";
|
|
3
4
|
import type { AgentNotificationQueue } from "./agent-notifications.js";
|
|
4
5
|
export interface BackgroundProcess {
|
|
@@ -108,6 +109,19 @@ export declare class ProcessManager {
|
|
|
108
109
|
*/
|
|
109
110
|
private pruneOldLogs;
|
|
110
111
|
start(command: string, cwd: string, launch?: ShellResolution, wake?: WakeRules): Promise<StartResult>;
|
|
112
|
+
/**
|
|
113
|
+
* Take over a foreground command that is still running, so the caller can
|
|
114
|
+
* return without killing it. Output captured so far seeds the log (its last
|
|
115
|
+
* {@link ADOPTED_PRIOR_OUTPUT_BYTES} only); later stdout/stderr is appended
|
|
116
|
+
* as it arrives. The process keeps its cwd and environment because it is the
|
|
117
|
+
* same process. Its stdin was never a pipe, so `sendInput` reports it closed.
|
|
118
|
+
*
|
|
119
|
+
* Synchronous on purpose: the caller hands over a live child whose 'close'
|
|
120
|
+
* has not fired yet, and an `await` here could let it fire unobserved.
|
|
121
|
+
*/
|
|
122
|
+
adopt(child: ChildProcess, command: string, startedAt: number, priorOutput: Buffer): StartResult;
|
|
123
|
+
/** Register a running child and arm its exit bookkeeping and watchers. */
|
|
124
|
+
private track;
|
|
111
125
|
/**
|
|
112
126
|
* Arm a backing-off, budgeted progress watcher for one background process.
|
|
113
127
|
* Emits at most one latest-only checkpoint per interval, only when the log
|
|
@@ -58,6 +58,9 @@ const CHECKPOINT_TAIL_CHARS = 320;
|
|
|
58
58
|
/** Ceiling on a single blocking `waitForExitOrWake`, so one wedged process cannot
|
|
59
59
|
* hold the agent loop indefinitely; callers re-wait if they still want to. */
|
|
60
60
|
export const MAX_PROCESS_WAIT_MS = 600_000;
|
|
61
|
+
/** Output a foreground command produced before {@link ProcessManager.adopt} that
|
|
62
|
+
* is kept in its log; the rest was already shown to nobody and only costs disk. */
|
|
63
|
+
const ADOPTED_PRIOR_OUTPUT_BYTES = 1024 * 1024;
|
|
61
64
|
/** Chars of the matched log line carried in a pattern-wake notification. */
|
|
62
65
|
const WAKE_LINE_CHARS = 200;
|
|
63
66
|
/** One log line, whitespace-collapsed and tail-bounded — never the raw log. */
|
|
@@ -179,6 +182,64 @@ export class ProcessManager {
|
|
|
179
182
|
lastReadOffset: 0,
|
|
180
183
|
logSize: 0,
|
|
181
184
|
};
|
|
185
|
+
return this.track(child, proc, wake);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Take over a foreground command that is still running, so the caller can
|
|
189
|
+
* return without killing it. Output captured so far seeds the log (its last
|
|
190
|
+
* {@link ADOPTED_PRIOR_OUTPUT_BYTES} only); later stdout/stderr is appended
|
|
191
|
+
* as it arrives. The process keeps its cwd and environment because it is the
|
|
192
|
+
* same process. Its stdin was never a pipe, so `sendInput` reports it closed.
|
|
193
|
+
*
|
|
194
|
+
* Synchronous on purpose: the caller hands over a live child whose 'close'
|
|
195
|
+
* has not fired yet, and an `await` here could let it fire unobserved.
|
|
196
|
+
*/
|
|
197
|
+
adopt(child, command, startedAt, priorOutput) {
|
|
198
|
+
fs.mkdirSync(this.bgDir, { recursive: true });
|
|
199
|
+
void this.pruneOldLogs();
|
|
200
|
+
const id = crypto.randomUUID().slice(0, 8);
|
|
201
|
+
const logFile = path.join(this.bgDir, `${id}.log`);
|
|
202
|
+
const prior = priorOutput.length > ADOPTED_PRIOR_OUTPUT_BYTES
|
|
203
|
+
? Buffer.concat([
|
|
204
|
+
Buffer.from(`[earlier output dropped; last ${ADOPTED_PRIOR_OUTPUT_BYTES / 1024 / 1024} MiB kept]\n`),
|
|
205
|
+
priorOutput.subarray(priorOutput.length - ADOPTED_PRIOR_OUTPUT_BYTES),
|
|
206
|
+
])
|
|
207
|
+
: priorOutput;
|
|
208
|
+
const fd = fs.openSync(logFile, "w");
|
|
209
|
+
fs.writeSync(fd, prior);
|
|
210
|
+
// Synchronous appends keep the log ordered and complete by the time
|
|
211
|
+
// 'close' fires, which the exit bookkeeping and waiters rely on.
|
|
212
|
+
const append = (data) => {
|
|
213
|
+
try {
|
|
214
|
+
fs.writeSync(fd, data);
|
|
215
|
+
}
|
|
216
|
+
catch {
|
|
217
|
+
// Disk full or log removed: drop output rather than crash the host.
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
child.stdout?.on("data", append);
|
|
221
|
+
child.stderr?.on("data", append);
|
|
222
|
+
child.once("close", () => fs.closeSync(fd));
|
|
223
|
+
// Never hold the host's event loop open for a process it no longer awaits.
|
|
224
|
+
child.unref();
|
|
225
|
+
for (const stream of [child.stdout, child.stderr]) {
|
|
226
|
+
stream?.unref?.();
|
|
227
|
+
}
|
|
228
|
+
const proc = {
|
|
229
|
+
id,
|
|
230
|
+
pid: child.pid ?? 0,
|
|
231
|
+
command,
|
|
232
|
+
logFile,
|
|
233
|
+
startedAt,
|
|
234
|
+
exitCode: null,
|
|
235
|
+
lastReadOffset: 0,
|
|
236
|
+
logSize: prior.length,
|
|
237
|
+
};
|
|
238
|
+
return this.track(child, proc);
|
|
239
|
+
}
|
|
240
|
+
/** Register a running child and arm its exit bookkeeping and watchers. */
|
|
241
|
+
track(child, proc, wake) {
|
|
242
|
+
const { id, pid, logFile } = proc;
|
|
182
243
|
this.processes.set(id, proc);
|
|
183
244
|
this.children.set(id, child);
|
|
184
245
|
// A child that fails to spawn emits 'error', and an 'error' with no listener
|