From 29ded9b0fa27004b1e48ca4edc0cb63d32d424a0 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 2 Oct 2026 03:41:24 -0700 Subject: [PATCH 01/58] chore(deps): update github-actions (#3934) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(deps): update github-actions * ci: re-pin producer test job hash after the checkout action bump --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Miguel Ángel --- .github/workflows/canary-sunset.yml | 2 +- .github/workflows/catalog-previews.yml | 4 +- .github/workflows/catalog-publish.yml | 2 +- .github/workflows/ci.yml | 68 ++++++++++---------- .github/workflows/codeql.yml | 6 +- .github/workflows/comments.yml | 4 +- .github/workflows/docs.yml | 2 +- .github/workflows/fast-video-validation.yml | 2 +- .github/workflows/player-perf.yml | 8 +-- .github/workflows/pr-captures.yml | 2 +- .github/workflows/preview-regression.yml | 8 +-- .github/workflows/publish.yml | 2 +- .github/workflows/regression.yml | 8 +-- .github/workflows/studio-drag-frames.yml | 2 +- .github/workflows/sync-skills-to-clawhub.yml | 2 +- .github/workflows/windows-render.yml | 10 +-- scripts/test-reachability.json | 2 +- 17 files changed, 67 insertions(+), 67 deletions(-) diff --git a/.github/workflows/canary-sunset.yml b/.github/workflows/canary-sunset.yml index 5883f997be..9fbca63566 100644 --- a/.github/workflows/canary-sunset.yml +++ b/.github/workflows/canary-sunset.yml @@ -23,7 +23,7 @@ jobs: sunset: runs-on: ubuntu-latest steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2 with: bun-version: latest diff --git a/.github/workflows/catalog-previews.yml b/.github/workflows/catalog-previews.yml index 1c0feff3e4..5eec507648 100644 --- a/.github/workflows/catalog-previews.yml +++ b/.github/workflows/catalog-previews.yml @@ -32,7 +32,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 5 steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - uses: ./.github/actions/preflight render-previews: @@ -41,7 +41,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 30 steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: fetch-depth: 0 diff --git a/.github/workflows/catalog-publish.yml b/.github/workflows/catalog-publish.yml index bbe9b33acc..25730ac324 100644 --- a/.github/workflows/catalog-publish.yml +++ b/.github/workflows/catalog-publish.yml @@ -22,7 +22,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 30 steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: ref: main fetch-depth: 0 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4a1fd55011..b8eb54d469 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 2 steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: fetch-depth: 0 - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 @@ -79,13 +79,13 @@ jobs: # Force git-based change detection instead of the pull_request REST API. # The API path can fail the whole workflow on transient listFiles # timeouts before any real CI work starts. - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: fetch-depth: 0 - name: Reject accidental file deletions if: github.event_name == 'pull_request' run: node scripts/check-no-main-deletions.mjs --base origin/main - - uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4 + - uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4 id: filter with: token: "" @@ -206,15 +206,15 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 15 steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: lfs: true - - uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3 + - uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3 - name: Build BeginFrame contract image # A hung bun install (Dockerfile.test, run 35468046055) would # otherwise eat the whole job timeout instead of failing at this step. timeout-minutes: 10 - uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6 + uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6 with: context: . file: packages/gcp-cloud-run/Dockerfile @@ -236,7 +236,7 @@ jobs: run: | echo "::error::Change detection did not succeed, so this required check cannot pass." exit 1 - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: lfs: true - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2 @@ -265,7 +265,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 5 steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: lfs: true fetch-depth: 0 @@ -288,7 +288,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 15 steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: fetch-depth: 0 - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2 @@ -341,7 +341,7 @@ jobs: contents: read pull-requests: write steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: # Full history so `--base origin/main` can diff against the merge # base on stacked PRs, not just the shallow tip. @@ -399,7 +399,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 5 steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: lfs: true - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2 @@ -423,7 +423,7 @@ jobs: run: | echo "::error::Change detection did not succeed, so this required check cannot pass." exit 1 - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: lfs: true - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2 @@ -443,7 +443,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 10 steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: lfs: true fetch-depth: 0 @@ -467,7 +467,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 10 steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: lfs: true - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2 @@ -489,7 +489,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 10 steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: lfs: true fetch-depth: 0 @@ -557,7 +557,7 @@ jobs: matrix: lane: [unit, integration] steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: lfs: true - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2 @@ -589,7 +589,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 5 steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 with: node-version: 22 @@ -622,7 +622,7 @@ jobs: runs-on: windows-latest timeout-minutes: 5 steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 with: node-version: 24 @@ -645,7 +645,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 3 steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2 - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 with: @@ -661,7 +661,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 3 steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2 - name: Verify skills-manifest.json matches skills/ run: bun packages/cli/scripts/gen-skills-manifest.ts --check @@ -678,7 +678,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 3 steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2 - name: Lint SKILL.md files across skills/, .claude/skills/, .agents/skills/ run: bun scripts/lint-skills.ts @@ -692,7 +692,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 3 steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 with: node-version: 22 @@ -716,7 +716,7 @@ jobs: matrix: os: [ubuntu-latest, macos-latest, windows-latest] steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2 - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 with: @@ -736,7 +736,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 5 steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2 - run: bash scripts/ci/install-workspace-dependencies.sh # Build workspace deps so the sdk's @hyperframes/parsers + core subpath @@ -758,7 +758,7 @@ jobs: run: | echo "::error::Change detection did not succeed, so this required check cannot pass." exit 1 - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: lfs: true - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2 @@ -779,7 +779,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 5 steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: lfs: true - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2 @@ -825,7 +825,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 18 steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2 - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 with: @@ -1023,7 +1023,7 @@ jobs: matrix: shard: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2 - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 with: @@ -1071,7 +1071,7 @@ jobs: contents: read pull-requests: write steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 with: node-version: 22 @@ -1119,7 +1119,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 10 steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: lfs: true - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2 @@ -1191,7 +1191,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 25 steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: lfs: true - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2 @@ -1316,7 +1316,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 1 steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: fetch-depth: 0 - name: Check file sizes (max 600 lines) @@ -1378,7 +1378,7 @@ jobs: with: types: ${{ env.PR_TITLE_TYPES }} - if: github.event_name == 'workflow_dispatch' - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: persist-credentials: false - if: github.event_name == 'workflow_dispatch' @@ -1387,7 +1387,7 @@ jobs: env: GH_TOKEN: ${{ github.token }} - if: github.event_name == 'workflow_dispatch' - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: repository: amannn/action-semantic-pull-request ref: e32d7e603df1aa1ba07e981f2a23455dee596825 # v5 diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 159b501b68..94a0529ebe 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -43,16 +43,16 @@ jobs: build-mode: none steps: - name: Checkout - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - name: Initialize CodeQL - uses: github/codeql-action/init@7211b7c8077ea37d8641b6271f6a365a22a5fbfa # v4 + uses: github/codeql-action/init@2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2 # v4 with: languages: ${{ matrix.language }} build-mode: ${{ matrix.build-mode }} config-file: ./.github/codeql/codeql-config.yml - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@7211b7c8077ea37d8641b6271f6a365a22a5fbfa # v4 + uses: github/codeql-action/analyze@2892aa5e19bbd11bc0cff5427e3b750a04d9e3c2 # v4 with: category: "/language:${{ matrix.language }}" diff --git a/.github/workflows/comments.yml b/.github/workflows/comments.yml index 5c0a048b90..188a62501b 100644 --- a/.github/workflows/comments.yml +++ b/.github/workflows/comments.yml @@ -25,7 +25,7 @@ jobs: scripts/check-comment-citations.mjs scripts/check-comment-citations.test.mjs scripts/comment-ratchet.mjs scripts/comment-ratchet.test.mjs steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: # The PR's own head, graded against its merge-base: not the merge preview, which would # charge the branch for every comment main changed since it forked. @@ -40,7 +40,7 @@ jobs: for script in $COMMENT_SCRIPTS; do [ -f "pr/$script" ] || dir=base; done echo "CHECKS_DIR=$dir" >> "$GITHUB_ENV" - if: env.CHECKS_DIR == 'base' - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: ref: ${{ github.event.pull_request.base.sha }} path: base diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 3ca7a00ea7..9417b77a0f 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -34,7 +34,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 5 steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 with: diff --git a/.github/workflows/fast-video-validation.yml b/.github/workflows/fast-video-validation.yml index c73e3ced4e..09ca7c46d5 100644 --- a/.github/workflows/fast-video-validation.yml +++ b/.github/workflows/fast-video-validation.yml @@ -28,7 +28,7 @@ jobs: validate: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3 diff --git a/.github/workflows/player-perf.yml b/.github/workflows/player-perf.yml index 7bcfd1aa71..f8310a70f1 100644 --- a/.github/workflows/player-perf.yml +++ b/.github/workflows/player-perf.yml @@ -27,10 +27,10 @@ jobs: steps: # Force git-based change detection instead of the pull_request REST API. # The API path can fail the perf workflow on transient listFiles timeouts. - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: fetch-depth: 0 - - uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4 + - uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4 id: filter with: token: "" @@ -49,7 +49,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 5 steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - uses: ./.github/actions/preflight perf-shards: @@ -78,7 +78,7 @@ jobs: scenarios: parity runs: "3" steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2 diff --git a/.github/workflows/pr-captures.yml b/.github/workflows/pr-captures.yml index 2d81404a67..67e7896900 100644 --- a/.github/workflows/pr-captures.yml +++ b/.github/workflows/pr-captures.yml @@ -25,7 +25,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 10 steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: fetch-depth: 0 - id: pr diff --git a/.github/workflows/preview-regression.yml b/.github/workflows/preview-regression.yml index 8ab6b25085..f7666d8361 100644 --- a/.github/workflows/preview-regression.yml +++ b/.github/workflows/preview-regression.yml @@ -26,10 +26,10 @@ jobs: outputs: preview: ${{ steps.filter.outputs.preview }} steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: fetch-depth: 0 - - uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4 + - uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4 id: filter with: token: "" @@ -56,7 +56,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 5 steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - uses: ./.github/actions/preflight preview-parity: @@ -66,7 +66,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 20 steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index de0544ae4e..6ce255bb8e 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -33,7 +33,7 @@ jobs: (github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/v')) steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: fetch-depth: 0 # Pin every release to an immutable ref. In particular, a merged diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index 0c486b046f..5b42d5515e 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -47,10 +47,10 @@ jobs: # Force git-based change detection instead of the pull_request REST API. # The API path can fail the whole workflow on transient listFiles # timeouts before any regression shard even starts. - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: fetch-depth: 0 - - uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4 + - uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4 id: filter if: github.event_name != 'schedule' with: @@ -79,7 +79,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 5 steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - uses: ./.github/actions/preflight regression-shards: @@ -95,7 +95,7 @@ jobs: matrix: ${{ fromJSON(needs.changes.outputs.matrix) }} steps: - name: Checkout (with LFS) - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: lfs: true diff --git a/.github/workflows/studio-drag-frames.yml b/.github/workflows/studio-drag-frames.yml index 9c95f2cd75..f5bc7f1eaf 100644 --- a/.github/workflows/studio-drag-frames.yml +++ b/.github/workflows/studio-drag-frames.yml @@ -26,7 +26,7 @@ jobs: env: BENCH_REF: ${{ inputs.ref || 'main' }} steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: ref: ${{ env.BENCH_REF }} lfs: true diff --git a/.github/workflows/sync-skills-to-clawhub.yml b/.github/workflows/sync-skills-to-clawhub.yml index 33bb87cae3..ec6eb1be3f 100644 --- a/.github/workflows/sync-skills-to-clawhub.yml +++ b/.github/workflows/sync-skills-to-clawhub.yml @@ -33,7 +33,7 @@ jobs: env: CLAWHUB_DISABLE_TELEMETRY: "1" steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 with: diff --git a/.github/workflows/windows-render.yml b/.github/workflows/windows-render.yml index 28ee42a7c7..6b79739d68 100644 --- a/.github/workflows/windows-render.yml +++ b/.github/workflows/windows-render.yml @@ -50,10 +50,10 @@ jobs: # Force git-based change detection instead of the pull_request REST API. # The API path can fail the workflow on transient listFiles timeouts # before the Windows render jobs even start. - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: fetch-depth: 0 - - uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4 + - uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4 id: filter with: token: "" @@ -74,7 +74,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 5 steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: ref: ${{ inputs.ref || github.sha }} - uses: ./.github/actions/preflight @@ -101,7 +101,7 @@ jobs: run: Set-MpPreference -DisableRealtimeMonitoring $true - name: Checkout - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: ref: ${{ inputs.ref || github.sha }} lfs: true @@ -426,7 +426,7 @@ jobs: run: Set-MpPreference -DisableRealtimeMonitoring $true - name: Checkout - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 + uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4 with: ref: ${{ inputs.ref || github.sha }} # Only the engine-cli lane reads an LFS file (engine's ffprobe test parses a producer HDR PNG). diff --git a/scripts/test-reachability.json b/scripts/test-reachability.json index 3f904a6f66..cc7f617470 100644 --- a/scripts/test-reachability.json +++ b/scripts/test-reachability.json @@ -62,7 +62,7 @@ "sources": { "packages/producer/scripts/run-test-lane.mjs": "bff02680f19eebcce0df72cdeedbbc05edfdcede3f3f60658fc0cb18ed8c59f6", "packages/producer/scripts/test-classification.mjs": "fa9452d63a9f3b76ab6be7ff001acddfbf3eb117159d932dcd1510eb88b4b5c6", - ".github/workflows/ci.yml#job#producer-source-tests": "3709c6ac6c9f5c7c66f57fc6c1c106aec4ffe906f919eb7cdf2a6ce1d4e0974c", + ".github/workflows/ci.yml#job#producer-source-tests": "45da72aa6cf08cdfd5bcf5311e89f12af4842f9eebc6735df19da8c02f4d4864", "packages/producer/package.json#script#test:unit": "ae6beda8319d166774be958ea5593cd27dbf7f6c9bce1d787a3fe28dfc3477b1", "packages/producer/package.json#script#test:integration": "008589f37d026877595a13501cbb66abd5cbe50e21fdcac6904f45466c3f475d", "packages/producer/package.json#script#test:classification": "4ad50d88c81de374dd6ef8a53d702a4b1901483837ecd3d833b1cb0c9a29a058", From 6090f539e6b14e024c9281eebff8c7c87f436862 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel?= Date: Fri, 2 Oct 2026 04:10:33 -0700 Subject: [PATCH 02/58] chore(renovate): stop raising engines and peer dependency floors (#4900) --- .github/renovate.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/renovate.json b/.github/renovate.json index 56277761f0..820d0e57fc 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -15,6 +15,10 @@ "labels": ["security"] }, "packageRules": [ + { + "matchDepTypes": ["engines", "peerDependencies"], + "rangeStrategy": "widen" + }, { "matchUpdateTypes": ["minor", "patch"], "matchDepTypes": ["devDependencies"], From 9d6ca4585794f430901269109df4a66a873134ce Mon Sep 17 00:00:00 2001 From: Bforbtay Date: Fri, 2 Oct 2026 19:14:36 +0800 Subject: [PATCH 03/58] fix: unbreak the regression suite on Windows (PSNR filtergraph escaping + console window popups) (#3839) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: hide console windows spawned by ffmpeg and nvidia-smi on Windows Node's `windowsHide` defaults to false, so every child process that is a console application pops a window on the user's desktop. During a render or a regression run that is a stream of black windows stealing focus. The repo already sets `windowsHide: true` across cli, studio-server and most of engine; these were the remaining gaps, all on paths that run during a normal render: - core/mediaGradeAnalyzer: ffprobe + ffmpeg, once per analyzed media file - engine/browserManager: `nvidia-smi` VRAM probe. This one goes through a shell (`execSync`), so it flashes a cmd.exe window even on machines with no NVIDIA GPU, where the command exists only to fail - producer: the regression harness ffmpeg runner, PSNR/audio comparison helpers, fixture synthesis, and the ffprobe call in audioPadTrim No behavior change on POSIX, where the flag is ignored. Co-Authored-By: Claude Opus 5 * fix(producer): escape PSNR stats_file for ffmpeg's two-pass filtergraph parse An ffmpeg filtergraph argument is unescaped twice: once when the graph is split into filters and their options, then again when the option value is read. `psnrAtFrames` escaped `\` and `:` a single time, which only survives the first pass. On POSIX that is invisible, because mkdtemp under tmpdir() produces neither character. On Windows the stats path is always `C:\Users\...`, so it reaches the option parser with a bare `:`, which starts a new option and fails the whole graph: [AVFilterGraph] No option name near '\Users\...\psnr.log' Error parsing filterchain '[rv][gv]psnr=...:stats_file=C\:\Users\...' Every suite that got as far as quality validation died there, so a Windows regression run reported 0 passes with only 2 genuine compilation failures. Escaping for both passes fixes it and stays a no-op on POSIX. Co-Authored-By: Claude Opus 5 * test(producer): pin PSNR stats path escaping with a colon and backslash path * fix(producer): keep the PSNR stats path out of the filtergraph --------- Co-authored-by: Claude Opus 5 Co-authored-by: Miguel Ángel --- packages/core/src/mediaGradeAnalyzer.ts | 3 ++- .../engine/src/services/browserManager.ts | 1 + packages/engine/src/utils/psnr.ts | 2 +- .../src/utils/psnrFilterAvailability.ts | 1 + packages/producer/src/parity-harness.ts | 2 +- packages/producer/src/plan-parity-analysis.ts | 3 ++- .../src/regression-harness-psnr.test.ts | 14 ++++++++++- packages/producer/src/regression-harness.ts | 24 ++++++++++++------- .../src/services/mediaTypeTestFixtures.ts | 4 +++- .../src/services/render/audioPadTrim.ts | 5 +++- .../producer/src/utils/audioRegression.ts | 4 ++-- 11 files changed, 45 insertions(+), 18 deletions(-) diff --git a/packages/core/src/mediaGradeAnalyzer.ts b/packages/core/src/mediaGradeAnalyzer.ts index 522f68bde3..0d918793e2 100644 --- a/packages/core/src/mediaGradeAnalyzer.ts +++ b/packages/core/src/mediaGradeAnalyzer.ts @@ -124,7 +124,7 @@ function probeMedia(mediaPath: string, ffprobePath: string): GradeMediaProbe { "--", mediaPath, ], - { encoding: "utf8", timeout: 5_000, stdio: ["ignore", "pipe", "pipe"] }, + { encoding: "utf8", timeout: 5_000, stdio: ["ignore", "pipe", "pipe"], windowsHide: true }, ); const parsed = asRecord(JSON.parse(raw)); const streams = Array.isArray(parsed.streams) ? parsed.streams : []; @@ -341,6 +341,7 @@ export function analyzeMediaGrade( encoding: "utf8", timeout: Number(process.env.HYPERFRAMES_ANALYZE_TIMEOUT_MS) || DEFAULT_TIMEOUT_MS, stdio: ["ignore", "pipe", "pipe"], + windowsHide: true, }, ); return summarizeMediaTreatmentAnalysis(probe, parseMediaTreatmentSignalStats(raw)); diff --git a/packages/engine/src/services/browserManager.ts b/packages/engine/src/services/browserManager.ts index 5f26e0e47b..6eda90a05b 100644 --- a/packages/engine/src/services/browserManager.ts +++ b/packages/engine/src/services/browserManager.ts @@ -830,6 +830,7 @@ function probeNvidiaVramMb(): number | null { timeout: 3000, encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"], + windowsHide: true, }).trim(); const mb = parseInt(out.split("\n")[0] ?? "", 10); if (Number.isFinite(mb) && mb > 0) { diff --git a/packages/engine/src/utils/psnr.ts b/packages/engine/src/utils/psnr.ts index 675594ec47..389d686d99 100644 --- a/packages/engine/src/utils/psnr.ts +++ b/packages/engine/src/utils/psnr.ts @@ -24,7 +24,7 @@ export async function psnrDb(a: Buffer, b: Buffer): Promise { const { stderr } = await execFileP( getFfmpegBinary(), ["-hide_banner", "-i", pa, "-i", pb, "-lavfi", "psnr", "-f", "null", "-"], - { maxBuffer: 4 * 1024 * 1024 }, + { maxBuffer: 4 * 1024 * 1024, windowsHide: true }, ); const m = /average:(inf|[\d.]+)/.exec(stderr); if (!m) throw new Error(`psnr parse failed: ${stderr.slice(-300)}`); diff --git a/packages/engine/src/utils/psnrFilterAvailability.ts b/packages/engine/src/utils/psnrFilterAvailability.ts index def9e1c5ba..3e1941b29f 100644 --- a/packages/engine/src/utils/psnrFilterAvailability.ts +++ b/packages/engine/src/utils/psnrFilterAvailability.ts @@ -52,6 +52,7 @@ async function listFilters(): Promise { const { stdout } = await execFileP(getFfmpegBinary(), ["-hide_banner", "-filters"], { maxBuffer: 4 * 1024 * 1024, timeout: 5_000, + windowsHide: true, }); return stdout; } catch { diff --git a/packages/producer/src/parity-harness.ts b/packages/producer/src/parity-harness.ts index e390ac81f8..b0b7eb696f 100644 --- a/packages/producer/src/parity-harness.ts +++ b/packages/producer/src/parity-harness.ts @@ -116,7 +116,7 @@ function writeImageDiff(basePath: string, comparePath: string, outputPath: strin "[0:v][1:v]blend=all_mode=difference", outputPath, ], - { stdio: "pipe" }, + { stdio: "pipe", windowsHide: true }, ); if (ffmpeg.status !== 0) { const stderr = (ffmpeg.stderr || Buffer.from("")).toString("utf-8"); diff --git a/packages/producer/src/plan-parity-analysis.ts b/packages/producer/src/plan-parity-analysis.ts index 1d7579fc4c..bc15285ca8 100644 --- a/packages/producer/src/plan-parity-analysis.ts +++ b/packages/producer/src/plan-parity-analysis.ts @@ -40,6 +40,7 @@ function requireCommandSuccess( encoding: "buffer", maxBuffer, stdio: ["ignore", "pipe", "pipe"], + windowsHide: true, }); if (result.error) throw result.error; if (result.status !== 0) { @@ -218,7 +219,7 @@ async function canonicalPcmAudio( "s16le", "-", ], - { stdio: ["ignore", "pipe", "pipe"] }, + { stdio: ["ignore", "pipe", "pipe"], windowsHide: true }, ); const hash = createHash("sha256"); const stderr: Buffer[] = []; diff --git a/packages/producer/src/regression-harness-psnr.test.ts b/packages/producer/src/regression-harness-psnr.test.ts index 4b9572bbec..b65d6074a3 100644 --- a/packages/producer/src/regression-harness-psnr.test.ts +++ b/packages/producer/src/regression-harness-psnr.test.ts @@ -12,7 +12,7 @@ import { afterAll, beforeAll, describe, expect, it } from "bun:test"; import { spawnSync } from "node:child_process"; -import { mkdtempSync, rmSync } from "node:fs"; +import { mkdirSync, mkdtempSync, rmSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; import { frameIndexForCheckpoint, psnrAtCheckpoint, psnrAtFrames } from "./regression-harness.js"; @@ -168,6 +168,18 @@ describe("psnrAtFrames()", () => { expect([...byFrame.keys()].sort((a, b) => a - b)).toEqual(SAMPLE_FRAMES); }); + it("writes its stats file under a temp dir whose path holds filtergraph syntax", () => { + const savedTmp = process.env.TMPDIR; + try { + process.env.TMPDIR = join(workDir, "tmp:with\\backslash, [o'brien];"); + mkdirSync(process.env.TMPDIR, { recursive: true }); + expect(psnrAtFrames(referenceVideo, degradedVideo, [0, 59]).size).toBe(2); + } finally { + if (savedTmp === undefined) delete process.env.TMPDIR; + else process.env.TMPDIR = savedTmp; + } + }); + it("matches the per-checkpoint ffmpeg method it replaced", () => { const byFrame = psnrAtFrames(referenceVideo, degradedVideo, SAMPLE_FRAMES); // Sample across the whole range: the old method's cost grew with frame diff --git a/packages/producer/src/regression-harness.ts b/packages/producer/src/regression-harness.ts index 57eee5c9da..555b7520d0 100644 --- a/packages/producer/src/regression-harness.ts +++ b/packages/producer/src/regression-harness.ts @@ -539,11 +539,17 @@ function copyFixtureSupportFiles(suite: TestSuite, tempRoot: string): void { // ── FFmpeg Utilities ───────────────────────────────────────────────────────── -function runFfmpeg(args: string[], label: string): { stdout: Buffer; stderr: string } { +function runFfmpeg( + args: string[], + label: string, + cwd?: string, +): { stdout: Buffer; stderr: string } { const result = spawnSync("ffmpeg", args, { + cwd, stdio: ["ignore", "pipe", "pipe"], maxBuffer: 256 * 1024 * 1024, encoding: "buffer", + windowsHide: true, }); const stderr = result.stderr.toString("utf-8"); if (result.status !== 0) { @@ -582,6 +588,8 @@ export function frameIndexForCheckpoint(checkpointSec: number, fps: number): num return Math.max(0, Math.round(checkpointSec * fps)); } +const STATS_FILE_NAME = "psnr.log"; + /** * PSNR for a set of frame indices, in a single ffmpeg pass. * @@ -628,12 +636,8 @@ export function psnrAtFrames( if (wanted.length === 0) return new Map(); const statsDir = mkdtempSync(join(tmpdir(), "hf-psnr-")); - const statsFile = join(statsDir, "psnr.log"); + const statsFile = join(statsDir, STATS_FILE_NAME); try { - // ffmpeg treats `:` and `\` in filter option values as syntax, so a temp - // path containing either would break the filtergraph. mkdtemp under - // tmpdir() does not produce those on POSIX, but escape defensively. - const escaped = statsFile.replace(/\\/g, "\\\\").replace(/:/g, "\\:"); const selectExpr = wanted.map((frame) => `eq(n\\,${frame})`).join("+"); const stream = (index: number, label: string) => `[${index}:v]select='${selectExpr}',settb=1/1,setpts=N[${label}]`; @@ -643,9 +647,9 @@ export function psnrAtFrames( "-loglevel", "error", "-i", - renderedVideo, + resolve(renderedVideo), "-i", - snapshotVideo, + resolve(snapshotVideo), "-filter_complex", // shortest=1:repeatlast=0 makes framesync stop at the first stream to // end instead of holding its last frame. Without them, an input that @@ -656,12 +660,14 @@ export function psnrAtFrames( // [0,15,45] emit 3 rows under the defaults (row 3 comparing frame 45 // against a repeated frame 15, 16.65 dB) and 2 rows with these set. `${stream(0, "rv")};${stream(1, "gv")};` + - `[rv][gv]psnr=shortest=1:repeatlast=0:stats_file=${escaped}`, + `[rv][gv]psnr=shortest=1:repeatlast=0:stats_file=${STATS_FILE_NAME}`, "-f", "null", "-", ], "Checkpoint PSNR", + // A bare name in cwd keeps every path out of the filtergraph and its escaping rules. + statsDir, ); const values: number[] = []; diff --git a/packages/producer/src/services/mediaTypeTestFixtures.ts b/packages/producer/src/services/mediaTypeTestFixtures.ts index a658c04791..d0fec208b4 100644 --- a/packages/producer/src/services/mediaTypeTestFixtures.ts +++ b/packages/producer/src/services/mediaTypeTestFixtures.ts @@ -1,7 +1,9 @@ import { spawnSync } from "node:child_process"; export function synthesizeMediaFixture(args: string[]): void { - const result = spawnSync("ffmpeg", ["-y", "-hide_banner", "-loglevel", "error", ...args]); + const result = spawnSync("ffmpeg", ["-y", "-hide_banner", "-loglevel", "error", ...args], { + windowsHide: true, + }); if (result.status !== 0) { throw new Error(`ffmpeg fixture synthesis failed: ${result.stderr.toString().slice(-400)}`); } diff --git a/packages/producer/src/services/render/audioPadTrim.ts b/packages/producer/src/services/render/audioPadTrim.ts index b8481ad2b7..9b834b922b 100644 --- a/packages/producer/src/services/render/audioPadTrim.ts +++ b/packages/producer/src/services/render/audioPadTrim.ts @@ -651,7 +651,10 @@ async function runFfprobeJson(args: string[], signal?: AbortSignal): Promise< if (!args.includes("--")) { throw new Error('[audioPadTrim] ffprobe args must terminate options with "--".'); } - const proc = spawn(getFfprobeBinary(), args, { stdio: ["ignore", "pipe", "pipe"] }); + const proc = spawn(getFfprobeBinary(), args, { + stdio: ["ignore", "pipe", "pipe"], + windowsHide: true, + }); trackChildProcess(proc); let stdout = ""; proc.stdout.on("data", (data: Buffer) => { diff --git a/packages/producer/src/utils/audioRegression.ts b/packages/producer/src/utils/audioRegression.ts index 8017b0298a..2fc3bfc971 100644 --- a/packages/producer/src/utils/audioRegression.ts +++ b/packages/producer/src/utils/audioRegression.ts @@ -200,7 +200,7 @@ export function computeAudioResidualRmsDb( "null", "-", ], - { encoding: "utf-8" }, + { encoding: "utf-8", windowsHide: true }, ); // `spawnSync` swallows `ENOENT`, signal kills, and non-zero exits @@ -318,7 +318,7 @@ function probeAudioDuration(file: string): { seconds: number; error?: string } { "--", file, ], - { encoding: "utf-8" }, + { encoding: "utf-8", windowsHide: true }, ); if (proc.error) { return { From e0d4c960033514d5582f643c975d435f367fabd2 Mon Sep 17 00:00:00 2001 From: miga-heygen Date: Fri, 2 Oct 2026 11:26:10 +0000 Subject: [PATCH 04/58] fix(producer): honor FFMPEG_PROCESS_TIMEOUT_MS during video-frame extraction (#3918) * fix: honor FFMPEG_PROCESS_TIMEOUT_MS during video-frame extraction FFMPEG_PROCESS_TIMEOUT_MS resolves correctly into EngineConfig and is correctly forwarded to the audio-extraction ffmpeg call, but runExtractVideosStage (shared by both the in-process renderer and distributed plan()) built the config object it passes to extractAllVideoFrames with only { extractCacheDir, extractCacheMaxBytes }, silently dropping ffmpegProcessTimeout even though the full EngineConfig was already in scope. That config flows straight into extractVideoFramesRange, which falls back to a hardcoded 300s deadline whenever the field is undefined -- so video-frame extraction always used a fixed 300s timeout no matter what the env var was set to. Threads cfg.ffmpegProcessTimeout into that config literal the same way the two cache fields already are. Co-Authored-By: Miguel Angel * fix(producer): pass the whole engine config to video-frame extraction The stage hand-picked fields from its resolved config, so any field it forgot (the ffmpeg process timeout) silently fell back to the engine default. --------- Co-authored-by: Miguel Angel --- .../extractVideosStage.ffmpegTimeout.test.ts | 109 ++++++++++++++++++ .../render/stages/extractVideosStage.ts | 2 +- 2 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 packages/producer/src/services/render/stages/extractVideosStage.ffmpegTimeout.test.ts diff --git a/packages/producer/src/services/render/stages/extractVideosStage.ffmpegTimeout.test.ts b/packages/producer/src/services/render/stages/extractVideosStage.ffmpegTimeout.test.ts new file mode 100644 index 0000000000..cff87e99c2 --- /dev/null +++ b/packages/producer/src/services/render/stages/extractVideosStage.ffmpegTimeout.test.ts @@ -0,0 +1,109 @@ +import { resolveConfig, type EngineConfig, type ExtractionResult } from "@hyperframes/engine"; +import { beforeEach, describe, expect, it, vi } from "vitest"; + +/** The optional engine-config argument the stage passes to `extractAllVideoFrames`. */ +type ExtractionConfigArg = Partial | undefined; + +const capturedConfigs = vi.hoisted(() => new Array()); + +vi.mock("@hyperframes/engine", async (importOriginal) => { + const real = await importOriginal(); + return { + ...real, + extractAllVideoFrames: async ( + _videos: unknown, + _baseDir: unknown, + _options: unknown, + _signal: unknown, + config: ExtractionConfigArg, + ): Promise => { + capturedConfigs.push(config); + return { + success: true, + extracted: [], + errors: [], + totalFramesExtracted: 0, + durationMs: 0, + phaseBreakdown: { + resolveMs: 0, + cachePublishFailures: 0, + cacheGcEvictions: 0, + cacheGcBytesFreed: 0, + cacheAgedPartialsCleared: 0, + hdrProbeMs: 0, + hdrPreflightMs: 0, + hdrPreflightCount: 0, + vfrProbeMs: 0, + vfrPreflightMs: 0, + vfrPreflightCount: 0, + extractMs: 0, + cacheHits: 0, + cacheMisses: 0, + transientRetries: 0, + }, + }; + }, + }; +}); + +import { createRenderJob } from "../../renderOrchestrator.js"; +import { runExtractVideosStage } from "./extractVideosStage.js"; + +async function runStage(cfg: EngineConfig): Promise { + const composition = { + duration: 5, + videos: [ + { + id: "root-video", + src: "clip.mp4", + start: 0, + end: 5, + mediaStart: 0, + loop: false, + hasAudio: false, + }, + ], + audios: [], + images: [], + width: 1920, + height: 1080, + }; + await runExtractVideosStage({ + projectDir: "/tmp/hf-ffmpeg-timeout-project", + compiledDir: "/tmp/hf-ffmpeg-timeout-compiled", + job: createRenderJob({ + fps: { num: 30, den: 1 }, + quality: "standard", + hdrMode: "force-sdr", + }), + cfg, + composition, + abortSignal: undefined, + assertNotAborted: () => {}, + materializeSymlinks: false, + }); +} + +describe("video extraction ffmpeg timeout threading", () => { + beforeEach(() => { + capturedConfigs.splice(0); + }); + + it("forwards every resolved extraction setting, including FFMPEG_PROCESS_TIMEOUT_MS", async () => { + await runStage( + resolveConfig({ + ffmpegProcessTimeout: 5_000, + extractCacheDir: "/tmp/hf-ffmpeg-timeout-cache", + extractCacheMaxBytes: 1234, + }), + ); + + expect(capturedConfigs).toEqual([ + expect.objectContaining({ + ffmpegProcessTimeout: 5_000, + extractCacheDir: "/tmp/hf-ffmpeg-timeout-cache", + extractCacheMaxBytes: 1234, + }), + ]); + }); +}); diff --git a/packages/producer/src/services/render/stages/extractVideosStage.ts b/packages/producer/src/services/render/stages/extractVideosStage.ts index a2c27774d8..adb435b972 100644 --- a/packages/producer/src/services/render/stages/extractVideosStage.ts +++ b/packages/producer/src/services/render/stages/extractVideosStage.ts @@ -503,7 +503,7 @@ export async function runExtractVideosStage( collectProbeFailures: extractionPolicy.failureMode === "enforce", }, abortSignal, - { extractCacheDir: cfg.extractCacheDir, extractCacheMaxBytes: cfg.extractCacheMaxBytes }, + cfg, compiledDir, ); extractionResult.phaseBreakdown.transientRetries = From 924b9334566436be358b4ff0958a583e053fceec Mon Sep 17 00:00:00 2001 From: lorenzozane Date: Fri, 2 Oct 2026 19:26:16 +0800 Subject: [PATCH 05/58] fix(lint): ignore attribute values when checking media attributes (#4396) --- packages/lint/src/rules/media.test.ts | 34 +++++++++++++++++++++++++++ packages/lint/src/utils.ts | 4 +--- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/packages/lint/src/rules/media.test.ts b/packages/lint/src/rules/media.test.ts index ab940d8d95..81054940fb 100644 --- a/packages/lint/src/rules/media.test.ts +++ b/packages/lint/src/rules/media.test.ts @@ -2,6 +2,40 @@ import { describe, it, expect } from "vitest"; import { lintHyperframeHtml } from "../hyperframeLinter.js"; describe("media rules", () => { + it.each([ + 'title="an unmuted muted crossorigin clip"', + "title='an unmuted muted crossorigin clip'", + ])("does not treat words in %s as media attributes", async (tooltip) => { + const html = ` + +
+ + +
+`; + const result = await lintHyperframeHtml(html); + const codes = result.findings.map((finding) => finding.code); + + expect(codes).toContain("video_missing_muted"); + expect(codes).toContain("video_audio_double_source"); + expect(codes).not.toContain("media_crossorigin_breaks_preview"); + }); + + it.each(["muted", 'muted=""', 'muted="false"', "MUTED"])( + "keeps %s as a present Boolean attribute", + async (mutedAttr) => { + const html = ` + +
+ +
+`; + const result = await lintHyperframeHtml(html); + + expect(result.findings.some((finding) => finding.code === "video_missing_muted")).toBe(false); + }, + ); + it("reports error for duplicate media ids", async () => { const html = ` diff --git a/packages/lint/src/utils.ts b/packages/lint/src/utils.ts index 57f0fc0bc4..a34397ae6c 100644 --- a/packages/lint/src/utils.ts +++ b/packages/lint/src/utils.ts @@ -234,9 +234,7 @@ export function readAttr(tagSource: string, attr: string): string | null { } export function hasAttrName(tagSource: string, attr: string): boolean { - const escaped = attr.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); - const attrs = tagSource.replace(/^<\s*[a-z][\w:-]*/i, ""); - return new RegExp(`(?:^|\\s)${escaped}(?:\\s*=|\\s|/?>)`, "i").test(attrs); + return readDecodedAttr(tagSource, attr) !== null; } // An explicit data-has-audio is authoritative for the compiler; only the exact value "true" means audible. From 0b88cd0537f6710b8e153a5cf3dca0bb19529cc0 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 2 Oct 2026 04:38:31 -0700 Subject: [PATCH 06/58] chore(deps): update node.js (#4245) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(deps): update node.js * fix(deps): keep the Node 22 engines floor at >=22 --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Miguel Ángel --- Dockerfile.test | 2 +- bun.lock | 26 +++++++++++------------ packages/cli/src/docker/Dockerfile.render | 2 +- packages/gcp-cloud-run/Dockerfile | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Dockerfile.test b/Dockerfile.test index 47f9061f64..e85da3f21e 100644 --- a/Dockerfile.test +++ b/Dockerfile.test @@ -10,7 +10,7 @@ # docker run --rm -v ./packages/producer/tests:/app/packages/producer/tests hyperframes-producer:test # docker run --rm -v ./packages/producer/tests:/app/packages/producer/tests hyperframes-producer:test --update -FROM node:22-bookworm-slim +FROM node:22.23.3-bookworm-slim # ── System dependencies (identical to production) ──────────────────────────── RUN apt-get update && apt-get install -y --no-install-recommends \ diff --git a/bun.lock b/bun.lock index ca3e7512e1..11a5bc144b 100644 --- a/bun.lock +++ b/bun.lock @@ -24,7 +24,7 @@ }, "packages/aws-lambda": { "name": "@hyperframes/aws-lambda", - "version": "0.8.62", + "version": "0.8.111", "dependencies": { "@aws-sdk/client-s3": "^3.700.0", "@aws-sdk/client-sfn": "^3.700.0", @@ -57,7 +57,7 @@ }, "packages/cli": { "name": "@hyperframes/cli", - "version": "0.8.62", + "version": "0.8.111", "bin": { "hyperframes": "./bin/hyperframes.mjs", "hyperframes-localize-fonts": "./bin/hyperframes-localize-fonts.mjs", @@ -109,7 +109,7 @@ }, "packages/core": { "name": "@hyperframes/core", - "version": "0.8.62", + "version": "0.8.111", "dependencies": { "@chenglou/pretext": "^0.0.5", "@hyperframes/lint": "workspace:*", @@ -135,7 +135,7 @@ }, "packages/engine": { "name": "@hyperframes/engine", - "version": "0.8.62", + "version": "0.8.111", "dependencies": { "@hono/node-server": "^2.0.5", "@hyperframes/core": "workspace:^", @@ -154,7 +154,7 @@ }, "packages/gcp-cloud-run": { "name": "@hyperframes/gcp-cloud-run", - "version": "0.8.62", + "version": "0.8.111", "dependencies": { "@google-cloud/storage": "^7.14.0", "@google-cloud/workflows": "^4.2.0", @@ -175,7 +175,7 @@ }, "packages/lint": { "name": "@hyperframes/lint", - "version": "0.8.62", + "version": "0.8.111", "dependencies": { "@hyperframes/parsers": "workspace:*", "acorn": "^8.17.0", @@ -195,7 +195,7 @@ }, "packages/parsers": { "name": "@hyperframes/parsers", - "version": "0.8.62", + "version": "0.8.111", "dependencies": { "@babel/parser": "^7.27.0", "acorn": "^8.17.0", @@ -215,7 +215,7 @@ }, "packages/player": { "name": "@hyperframes/player", - "version": "0.8.62", + "version": "0.8.111", "dependencies": { "@hyperframes/core": "workspace:*", }, @@ -230,7 +230,7 @@ }, "packages/producer": { "name": "@hyperframes/producer", - "version": "0.8.62", + "version": "0.8.111", "dependencies": { "@fontsource/archivo-black": "^5.2.8", "@fontsource/eb-garamond": "^5.2.7", @@ -275,7 +275,7 @@ }, "packages/sdk": { "name": "@hyperframes/sdk", - "version": "0.8.62", + "version": "0.8.111", "dependencies": { "@hyperframes/core": "workspace:*", "@hyperframes/parsers": "workspace:*", @@ -305,7 +305,7 @@ }, "packages/shader-transitions": { "name": "@hyperframes/shader-transitions", - "version": "0.8.62", + "version": "0.8.111", "dependencies": { "html2canvas": "^1.4.1", }, @@ -317,7 +317,7 @@ }, "packages/studio": { "name": "@hyperframes/studio", - "version": "0.8.62", + "version": "0.8.111", "dependencies": { "@base-ui/react": "1.7.0", "@codemirror/autocomplete": "^6.20.1", @@ -370,7 +370,7 @@ }, "packages/studio-server": { "name": "@hyperframes/studio-server", - "version": "0.8.62", + "version": "0.8.111", "dependencies": { "@hyperframes/core": "workspace:*", "@hyperframes/parsers": "workspace:*", diff --git a/packages/cli/src/docker/Dockerfile.render b/packages/cli/src/docker/Dockerfile.render index 11b9b9c42e..6ce515cd21 100644 --- a/packages/cli/src/docker/Dockerfile.render +++ b/packages/cli/src/docker/Dockerfile.render @@ -1,4 +1,4 @@ -FROM node:22-bookworm-slim +FROM node:22.23.3-bookworm-slim ARG HYPERFRAMES_VERSION=latest # Set automatically by `docker build --platform` (BuildKit); selects the diff --git a/packages/gcp-cloud-run/Dockerfile b/packages/gcp-cloud-run/Dockerfile index f30f18f01f..26196e803d 100644 --- a/packages/gcp-cloud-run/Dockerfile +++ b/packages/gcp-cloud-run/Dockerfile @@ -21,7 +21,7 @@ # Unlike the AWS Lambda adapter there is no ZIP-size ceiling and no runtime # Chrome decompression step — the binary lives in the image at a fixed path. -FROM node:22-bookworm-slim AS beginframe-contract +FROM node:22.23.3-bookworm-slim AS beginframe-contract # ── System dependencies (identical set to the producer's render image) ─────── RUN apt-get update && apt-get install -y --no-install-recommends \ From 0eba8d6a06aafae286f9cbb784a121d1669d84a3 Mon Sep 17 00:00:00 2001 From: miga-heygen Date: Fri, 2 Oct 2026 11:54:30 +0000 Subject: [PATCH 07/58] fix(cli): route FFmpeg exec-failure hint through getFFmpegInstallHint() (#3877) * fix(cli): route FFmpeg exec-failure hint through getFFmpegInstallHint() checkFFmpeg()'s "cannot start" branch (binary found but fails to run -version) hardcoded a Windows/DLL-flavored install hint on every platform instead of delegating to the already platform-aware getFFmpegInstallHint() used by every other branch in this file. * test(cli): pin the ffmpeg cannot-start hint through the async probe mock * fix(cli): keep the runtime-DLL cannot-start hint on Windows --------- Co-authored-by: Miguel Angel Simon Sierra --- packages/cli/src/browser/preflight.test.ts | 32 +++++++++++++++++++++- packages/cli/src/browser/preflight.ts | 5 +++- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/browser/preflight.test.ts b/packages/cli/src/browser/preflight.test.ts index fa55b8c79d..13ef3a2b32 100644 --- a/packages/cli/src/browser/preflight.test.ts +++ b/packages/cli/src/browser/preflight.test.ts @@ -162,10 +162,40 @@ describe("runEnvironmentChecks", () => { }); expect(ffmpeg?.detail).toContain(process.execPath); expect(ffmpeg?.detail).toContain("3221225781"); - expect(ffmpeg?.hint).toContain("working 64-bit FFmpeg build"); expect(result.ffmpegPath).toBeUndefined(); }); + // Windows DLL advice only on Windows; elsewhere the platform install hint. + describe("FFmpeg cannot-start hint is platform-specific", () => { + const realPlatform = process.platform; + + afterEach(() => { + Object.defineProperty(process, "platform", { value: realPlatform, configurable: true }); + }); + + it.each([ + { platform: "darwin" as const, expectedHint: "brew install ffmpeg" }, + { platform: "sunos" as const, expectedHint: "https://ffmpeg.org/download.html" }, + { + platform: "win32" as const, + expectedHint: "Install a working 64-bit FFmpeg build with all required runtime DLLs.", + }, + ])("gives the $platform cannot-start hint", async ({ platform, expectedHint }) => { + Object.defineProperty(process, "platform", { value: platform, configurable: true }); + runProcess.mockImplementation((binaryPath: string) => { + if (binaryPath !== process.env.HYPERFRAMES_FFMPEG_PATH) + return Promise.resolve({ stdout: "ffprobe version 7.1.1\n", stderr: "" }); + throw Object.assign(new Error("cannot execute binary file"), { status: 126 }); + }); + + const result = await runEnvironmentChecks(); + const ffmpeg = result.outcomes.find((outcome) => outcome.name === "FFmpeg"); + + expect(ffmpeg?.title).toBe("FFmpeg cannot start"); + expect(ffmpeg?.hint).toBe(expectedHint); + }); + }); + it("validates an explicit browser path without needing browser discovery", async () => { const result = await runEnvironmentChecks({ includeBrowser: true, diff --git a/packages/cli/src/browser/preflight.ts b/packages/cli/src/browser/preflight.ts index 40afdc2f09..d706192baa 100644 --- a/packages/cli/src/browser/preflight.ts +++ b/packages/cli/src/browser/preflight.ts @@ -122,7 +122,10 @@ async function checkFFmpeg(signal?: AbortSignal): Promise Date: Fri, 2 Oct 2026 17:29:16 +0530 Subject: [PATCH 08/58] fix(engine): warn when a video input declares alpha but decodes opaque (#3771) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(engine): warn when a video input declares alpha but decodes opaque - Problem: a video input whose alpha_mode=1 tag outlives its alpha plane (a remux drops the BlockAdditional sidecar while keeping the tag) composites as a solid rectangle, and nothing tells the user their file, not the renderer, is the problem (#3220 / #3226). - Fix: during extraction preflight, when an input declares alpha (hasAlpha) and its codec can carry alpha, sample the decoded alpha plane (up to 3 frames at 8x8 rgba, bounded 30s, ~768-byte ceiling). If uniformly opaque, emit a non-blocking stderr warning naming the file with the re-export remedy. Inconclusive probes stay silent; opaque full-frame backgrounds are legitimate and never fail the render. - Verification: 8 new unit tests (byte logic + message); engine suite 1483/1487 with 4 pre-existing failures on clean main (missing hdr-regression PNG fixture in this clone); typecheck/lint/format clean; real-fixture checks: lying-tag WebM warns, genuine-alpha WebM stays silent, both agree with ffmpeg alphaextract. Signed-off-by: Santhi Prakash * fix(engine): probe input alpha with the decoder that matches its codec * style(engine): format the alpha probe test * fix(engine): keep the alpha probe from failing or racing a render --------- Signed-off-by: Santhi Prakash Co-authored-by: Miguel Ángel --- .../src/services/videoFrameExtractor.ts | 18 +++ .../engine/src/utils/alphaPlaneProbe.test.ts | 115 ++++++++++++++++++ packages/engine/src/utils/alphaPlaneProbe.ts | 74 +++++++++++ 3 files changed, 207 insertions(+) create mode 100644 packages/engine/src/utils/alphaPlaneProbe.test.ts create mode 100644 packages/engine/src/utils/alphaPlaneProbe.ts diff --git a/packages/engine/src/services/videoFrameExtractor.ts b/packages/engine/src/services/videoFrameExtractor.ts index 3b8879f87d..d5de062553 100644 --- a/packages/engine/src/services/videoFrameExtractor.ts +++ b/packages/engine/src/services/videoFrameExtractor.ts @@ -41,6 +41,7 @@ import { extractMediaMetadata, type VideoMetadata, } from "../utils/ffprobe.js"; +import { inputAlphaOpaqueWarning, probeInputAlphaPlane } from "../utils/alphaPlaneProbe.js"; import { analyzeCompositionHdr, isHdrColorSpace as isHdrColorSpaceUtil, @@ -1844,6 +1845,23 @@ export async function extractAllVideoFrames( const sdrToHdrTransfers: Array = resolvedVideos.map(() => undefined); breakdown.hdrProbeMs = Date.now() - phase2ProbeStart; + // Warning only: an opaque video used as a full-frame background is legitimate. + const alphaWarnedSrcs = new Set(); + if (resolvedVideos.length > 0) { + await Promise.all( + resolvedVideos.map(async ({ video, videoPath }, index) => { + if (signal?.aborted) return; + const metadata = videoMetadata[index]; + if (!metadata?.hasAlpha || !codecMayHaveAlpha(metadata.videoCodec)) return; + if (alphaWarnedSrcs.has(video.src)) return; + alphaWarnedSrcs.add(video.src); + const decoder = decoderForCodec(metadata.videoCodec); + if ((await probeInputAlphaPlane(videoPath, decoder, signal)) !== true) return; + process.stderr.write(inputAlphaOpaqueWarning(video.src)); + }), + ); + } + const hdrPreflightStart = Date.now(); const hdrInfo = analyzeCompositionHdr(videoColorSpaces); // Track entries the HDR preflight validated as non-extractable so they can diff --git a/packages/engine/src/utils/alphaPlaneProbe.test.ts b/packages/engine/src/utils/alphaPlaneProbe.test.ts new file mode 100644 index 0000000000..85d8ff117e --- /dev/null +++ b/packages/engine/src/utils/alphaPlaneProbe.test.ts @@ -0,0 +1,115 @@ +import { spawnSync } from "node:child_process"; +import { mkdtempSync, rmSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import { afterAll, beforeAll, describe, expect, it } from "vitest"; +import { decoderForCodec } from "../services/videoFrameExtractor.js"; +import { + inputAlphaOpaqueWarning, + probeInputAlphaPlane, + sampledRgbaAlphaIsFullyOpaque, +} from "./alphaPlaneProbe.js"; +import { getFfmpegBinary } from "./ffmpegBinaries.js"; + +const BYTES_PER_FRAME = 8 * 8 * 4; // 256 — one 8x8 rgba frame + +/** Build a raw rgba sample where the alpha byte of every pixel is `alpha`. */ +function sample(alpha: number, frameCount: number): Buffer { + const buf = Buffer.alloc(BYTES_PER_FRAME * frameCount, 0); + for (let i = 3; i < buf.length; i += 4) { + buf[i] = alpha; + } + return buf; +} + +describe("sampledRgbaAlphaIsFullyOpaque", () => { + it("returns true when every alpha byte in a single frame is 255", () => { + expect(sampledRgbaAlphaIsFullyOpaque(sample(255, 1))).toBe(true); + }); + + it("returns true across a multi-frame sample (2 and 3 frames)", () => { + expect(sampledRgbaAlphaIsFullyOpaque(sample(255, 2))).toBe(true); + expect(sampledRgbaAlphaIsFullyOpaque(sample(255, 3))).toBe(true); + }); + + it("returns false when any pixel shows full transparency", () => { + const buf = sample(255, 1); + buf[3] = 0; // first pixel's alpha + expect(sampledRgbaAlphaIsFullyOpaque(buf)).toBe(false); + }); + + it("returns false when any pixel shows partial transparency", () => { + const buf = sample(255, 2); + buf[3 + 4 * 10] = 254; // partial alpha on the 11th pixel + expect(sampledRgbaAlphaIsFullyOpaque(buf)).toBe(false); + }); + + it("returns undefined for an empty sample (inconclusive, not a warning)", () => { + expect(sampledRgbaAlphaIsFullyOpaque(Buffer.alloc(0))).toBeUndefined(); + }); + + it("returns undefined for a byte count that is not a whole-frame multiple", () => { + expect(sampledRgbaAlphaIsFullyOpaque(Buffer.alloc(BYTES_PER_FRAME - 1))).toBeUndefined(); + }); + + it("returns undefined for an oversized sample beyond the 3-frame ceiling", () => { + expect(sampledRgbaAlphaIsFullyOpaque(Buffer.alloc(BYTES_PER_FRAME * 4))).toBeUndefined(); + }); +}); + +describe("inputAlphaOpaqueWarning", () => { + it("names the offending file and carries the re-export remedy", () => { + const line = inputAlphaOpaqueWarning("avatar.webm"); + expect(line).toContain('src="avatar.webm"'); + expect(line).toContain("declares an alpha channel"); + expect(line).toContain("first frames decode fully opaque"); + expect(line).toContain("alpha pixel format"); + expect(line).not.toContain("yuva420p"); + expect(line.endsWith("\n")).toBe(true); + }); +}); + +const HAS_FFMPEG = spawnSync(getFfmpegBinary(), ["-version"], { encoding: "utf-8" }).status === 0; + +describe.skipIf(!HAS_FFMPEG)("probeInputAlphaPlane on real files", () => { + let dir: string; + beforeAll(() => { + dir = mkdtempSync(join(tmpdir(), "hf-alpha-probe-test-")); + }); + afterAll(() => { + rmSync(dir, { recursive: true, force: true }); + }); + + const encode = (name: string, color: string, codecArgs: string[]): string => { + const out = join(dir, name); + const args = [ + "-v", + "error", + "-f", + "lavfi", + "-i", + `color=c=${color}:s=32x32:d=0.2,format=rgba`, + ...codecArgs, + ]; + const res = spawnSync(getFfmpegBinary(), [...args, "-y", out]); + expect(res.status).toBe(0); + return out; + }; + const vp9 = ["-c:v", "libvpx-vp9", "-pix_fmt", "yuva420p"]; + const prores = ["-c:v", "prores_ks", "-profile:v", "4", "-pix_fmt", "yuva444p10le"]; + + it("reports a VP9 input whose alpha is all opaque", async () => { + const file = encode("opaque.webm", "red", vp9); + expect(await probeInputAlphaPlane(file, decoderForCodec("vp9"))).toBe(true); + }); + + it("does not flag a VP9 input that is really transparent", async () => { + const file = encode("clear.webm", "red@0.0", vp9); + expect(await probeInputAlphaPlane(file, decoderForCodec("vp9"))).toBe(false); + }); + + it("probes ProRes 4444 with its own decoder, not the VP9 one", async () => { + const file = encode("opaque.mov", "red", prores); + expect(await probeInputAlphaPlane(file, decoderForCodec("prores"))).toBe(true); + }); +}); diff --git a/packages/engine/src/utils/alphaPlaneProbe.ts b/packages/engine/src/utils/alphaPlaneProbe.ts new file mode 100644 index 0000000000..b963ca1156 --- /dev/null +++ b/packages/engine/src/utils/alphaPlaneProbe.ts @@ -0,0 +1,74 @@ +import { mkdtempSync, readFileSync, rmSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import { runFfmpeg } from "./runFfmpeg.js"; + +// Up to 3 frames at 8x8 rgba; a 1- or 2-frame clip is still a whole sample. +const BYTES_PER_SAMPLE_FRAME = 8 * 8 * 4; +const MAX_SAMPLE_BYTES = BYTES_PER_SAMPLE_FRAME * 3; + +/** true: every sampled alpha byte is 255; false: some transparency; undefined: malformed sample. */ +export function sampledRgbaAlphaIsFullyOpaque(buf: Buffer): boolean | undefined { + if ( + buf.length === 0 || + buf.length > MAX_SAMPLE_BYTES || + buf.length % BYTES_PER_SAMPLE_FRAME !== 0 + ) { + return undefined; + } + for (let i = 3; i < buf.length; i += 4) { + if (buf[i] !== 255) return false; + } + return true; +} + +/** + * Whether a video input that declares alpha decodes fully opaque (a remux can keep `alpha_mode=1` + * while dropping the alpha sidecar). `decoder` must keep alpha. Any failure returns undefined. + */ +export async function probeInputAlphaPlane( + videoPath: string, + decoder: string, + signal?: AbortSignal, +): Promise { + let probeDir: string | undefined; + try { + probeDir = mkdtempSync(join(tmpdir(), "hf-alpha-probe-")); + const samplePath = join(probeDir, "alpha.raw"); + const result = await runFfmpeg( + [ + "-v", + "error", + "-c:v", + decoder, + "-i", + videoPath, + "-frames:v", + "3", + "-vf", + "scale=8:8", + "-pix_fmt", + "rgba", + "-f", + "rawvideo", + samplePath, + ], + { timeout: 30_000, signal }, + ); + if (!result.success) return undefined; + return sampledRgbaAlphaIsFullyOpaque(readFileSync(samplePath)); + } catch { + return undefined; + } finally { + if (probeDir) rmSync(probeDir, { recursive: true, force: true }); + } +} + +export function inputAlphaOpaqueWarning(src: string): string { + return ( + `[hyperframes:render] WARNING: video src="${src}" declares an alpha channel ` + + "but its first frames decode fully opaque. If it should be transparent, re-export " + + "it with an alpha pixel format and avoid remuxing afterward, which can drop the " + + "alpha while keeping the tag.\n" + ); +} From 9afafa79ec13cc52f14a83cadb3ec310a194b9c4 Mon Sep 17 00:00:00 2001 From: miga-heygen Date: Fri, 2 Oct 2026 12:06:11 +0000 Subject: [PATCH 09/58] fix(lint): flag an id override written with reduced-specificity selector forms (#3871) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(lint): flag an id override written with reduced-specificity selector forms An attribute selector on id (`[id="x"]`, class-level specificity) or a `:where(#x)`-wrapped id selector (spec-defined zero specificity) genuinely loses to a compound class selector like `.parent .row` under standard CSS cascade rules — unlike a bare `#id`, which always wins regardless of how the competing class rule is written. When either form is used to override a position property (left/top/right/bottom), the element can silently render at the class-default position instead of its authored one, with lint, validate, inspect, and layout all reporting clean (a real, resolved position exists, it's just the wrong one). No existing check performs any CSS rule-specificity analysis — confirmed at the source level (dist/cli.js has zero "specificity" occurrences, and createInspectCommand reports position via getBoundingClientRect() only). Adds `id_override_reduced_specificity`, a new core lint rule flagging this authoring pattern specifically (not general cascade-conflict detection, which would require full rule-graph modeling well beyond this P3's scope). Extracted `rightmostCompoundNodes()` out of `selectorAliasesRuntimeHiddenStyle` so the new rule's selector-subject walk doesn't duplicate it. * fix(lint): share the selector-safety parse and skip compounds that keep a bare id * style(lint): wrap the id attribute check for oxfmt * refactor(lint): move the reduced-specificity id check into its own helper * fix(lint): hint an escaped #id and skip prefix and !important id overrides * style(lint): wrap the prefix-selector test for oxfmt * refactor(lint): split the weak-id node check out of the selector walk --------- Co-authored-by: Miguel Angel Simon Sierra --- packages/lint/src/rules/core.test.ts | 74 +++++++++++++++++++++++++ packages/lint/src/rules/core.ts | 81 ++++++++++++++++++++++++++-- 2 files changed, 150 insertions(+), 5 deletions(-) diff --git a/packages/lint/src/rules/core.test.ts b/packages/lint/src/rules/core.test.ts index 5cef1f332d..beb7f39449 100644 --- a/packages/lint/src/rules/core.test.ts +++ b/packages/lint/src/rules/core.test.ts @@ -1068,6 +1068,80 @@ describe("core rules", () => { }); }); + describe("id_override_reduced_specificity", () => { + const comp = (css: string) => ` + +
+
text
+
+ +`; + + it("warns when an attribute selector on id sets a position property", async () => { + const result = await lintHyperframeHtml( + comp(`.parent .row { position: absolute; left: 0; } [id="line1"] { left: 40px; }`), + ); + const finding = result.findings.find((f) => f.code === "id_override_reduced_specificity"); + expect(finding).toBeDefined(); + expect(finding?.severity).toBe("warning"); + expect(finding?.selector).toBe(`[id="line1"]`); + expect(finding?.fixHint).toContain("`#line1`"); + }); + + it("warns when a :where()-wrapped id selector sets a position property", async () => { + const result = await lintHyperframeHtml( + comp(`.parent .row { position: absolute; top: 0; } :where(#line1) { top: 20px; }`), + ); + const finding = result.findings.find((f) => f.code === "id_override_reduced_specificity"); + expect(finding).toBeDefined(); + expect(finding?.selector).toBe(`:where(#line1)`); + }); + + it("does not flag a bare #id selector, which always wins regardless of specificity", async () => { + const result = await lintHyperframeHtml( + comp(`.parent .row { position: absolute; left: 0; } #line1 { left: 40px; }`), + ); + expect( + result.findings.find((f) => f.code === "id_override_reduced_specificity"), + ).toBeUndefined(); + }); + + it("hints an escaped #id for a digit-leading id, where a bare #01-intro is invalid CSS", async () => { + const result = await lintHyperframeHtml( + comp(`.parent .row { position: absolute; left: 0; } [id="01-intro"] { left: 40px; }`), + ); + const finding = result.findings.find((f) => f.code === "id_override_reduced_specificity"); + expect(finding?.fixHint).toContain("`#\\30 1-intro`"); + }); + + it("does not flag prefix-matching id selectors or !important position overrides", async () => { + const result = await lintHyperframeHtml( + comp( + `[id^="line"] { top: 0; } [id*="ine"] { left: 0; } [id="line1"] { left: 40px !important; }`, + ), + ); + expect( + result.findings.find((f) => f.code === "id_override_reduced_specificity"), + ).toBeUndefined(); + }); + + it("does not flag a compound that also carries a bare #id, or a nested rule's position", async () => { + const result = await lintHyperframeHtml( + comp(`#line1[id="line1"] { left: 40px; } [id="root"] { color: red; .row { left: 0; } }`), + ); + expect( + result.findings.find((f) => f.code === "id_override_reduced_specificity"), + ).toBeUndefined(); + }); + + it("does not flag an attribute selector on id for a non-position property", async () => { + const result = await lintHyperframeHtml(comp(`[id="line1"] { color: red; }`)); + expect( + result.findings.find((f) => f.code === "id_override_reduced_specificity"), + ).toBeUndefined(); + }); + }); + describe("unclosed_tag_swallowed_element", () => { it("flags an tag whose unclosed start tag swallows a nested
as bogus attribute text", async () => { const html = compositionWithBodyPrefix( diff --git a/packages/lint/src/rules/core.ts b/packages/lint/src/rules/core.ts index e634afe968..df942c84a1 100644 --- a/packages/lint/src/rules/core.ts +++ b/packages/lint/src/rules/core.ts @@ -103,16 +103,22 @@ function resolvedRuleSelectors(rule: postcss.Rule): string[] { ); } +// The rightmost compound: the nodes that match the styled element itself. +function rightmostCompoundNodes(selectorNode: selectorParser.Selector): selectorParser.Node[] { + const subject: selectorParser.Node[] = []; + selectorNode.each((node) => { + if (node.type === "combinator") subject.length = 0; + else subject.push(node); + }); + return subject; +} + function selectorAliasesRuntimeHiddenStyle(selector: string): boolean { let unsafe = false; try { selectorParser((root) => { root.each((selectorNode) => { - const subject: selectorParser.Node[] = []; - selectorNode.each((node) => { - if (node.type === "combinator") subject.length = 0; - else subject.push(node); - }); + const subject = rightmostCompoundNodes(selectorNode); const hostScoped = subject.some( (node) => @@ -142,6 +148,69 @@ function selectorAliasesRuntimeHiddenStyle(selector: string): boolean { return unsafe; } +const POSITION_PROPERTIES = new Set(["left", "top", "right", "bottom", "inset"]); + +function weakIdOf(node: selectorParser.Node): string | null { + if (node.type === "attribute" && node.attribute.toLowerCase() === "id") { + return node.operator === "=" && node.value ? node.value : null; + } + if (node.type !== "pseudo" || node.value.toLowerCase() !== ":where") return null; + const inner = node.nodes.flatMap((option) => option.nodes).find((n) => n.type === "id"); + return inner ? inner.value : null; +} + +// The id a subject targets only via `[id="x"]` or `:where(#x)`, which carry class-level or zero specificity +// and so lose to a compound class rule like `.parent .row`. A bare `#id` never does. +function reducedSpecificityId(selector: string): string | null { + let matched: string | null = null; + try { + selectorParser((root) => { + root.each((selectorNode) => { + const subject = rightmostCompoundNodes(selectorNode); + if (subject.some((node) => node.type === "id")) return; + for (const node of subject) matched = weakIdOf(node) ?? matched; + }); + }).processSync(selector); + } catch { + return null; + } + return matched; +} + +// `#id` with the characters a bare id selector cannot hold (a leading digit, punctuation) hex-escaped. +function cssIdSelector(id: string): string { + return `#${id.replace(/[^a-zA-Z0-9_-]|^-?\d/g, (match) => + Array.from(match, (char) => `\\${char.codePointAt(0)?.toString(16)} `).join(""), + )}`; +} + +function reducedSpecificityIdFindings( + rule: postcss.Rule, + reported: Set, +): HyperframeLintFinding[] { + const positionProps = rule.nodes.flatMap((node) => + node.type === "decl" && !node.important && POSITION_PROPERTIES.has(node.prop.toLowerCase()) + ? [node.prop] + : [], + ); + if (positionProps.length === 0) return []; + const findings: HyperframeLintFinding[] = []; + for (const selector of resolvedRuleSelectors(rule)) { + const id = reported.has(selector) ? null : reducedSpecificityId(selector); + if (id === null) continue; + reported.add(selector); + findings.push({ + code: "id_override_reduced_specificity", + severity: "warning", + message: `Selector "${selector}" sets ${positionProps.join("/")} through [id=...] or :where(#id), which has class-level or zero specificity, so a compound class rule (e.g. ".parent .row") on the same element can silently win over this override.`, + selector, + fixHint: `Use \`${cssIdSelector(id)}\` instead; id specificity beats any selector built only from classes.`, + snippet: truncateSnippet(rule.toString()), + }); + } + return findings; +} + function ruleForcesOpacityZero(rule: postcss.Rule): boolean { let forcesOpacityZero = false; rule.walkDecls(/^opacity$/i, (declaration) => { @@ -501,6 +570,7 @@ export const coreRules: Array<(ctx: LintContext) => HyperframeLintFinding[]> = [ const findings: HyperframeLintFinding[] = []; const reportedRepeatedIds = new Set(); const reportedHiddenStyleSelectors = new Set(); + const reportedReducedIdSelectors = new Set(); for (const style of styles) { let root: postcss.Root; try { @@ -521,6 +591,7 @@ export const coreRules: Array<(ctx: LintContext) => HyperframeLintFinding[]> = [ } root.walkRules((rule) => { const forcesOpacityZero = ruleForcesOpacityZero(rule); + findings.push(...reducedSpecificityIdFindings(rule, reportedReducedIdSelectors)); for (const selector of resolvedRuleSelectors(rule)) { const repeatedId = repeatedDescendantId(selector); if (repeatedId && !reportedRepeatedIds.has(repeatedId)) { From 1248639e71e08fd87722f9e5b186cf3fc514ca07 Mon Sep 17 00:00:00 2001 From: miga-heygen Date: Fri, 2 Oct 2026 12:06:17 +0000 Subject: [PATCH 10/58] fix(lint): point the repeated fromTo baseline hint at immediateRender: false (#3895) The repeated fromTo baseline lint hint now points at immediateRender: false. Hint text only; rule logic unchanged. --- packages/lint/src/rules/gsap.test.ts | 23 +++++++++++++++++++++++ packages/lint/src/rules/gsap.ts | 7 ++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/packages/lint/src/rules/gsap.test.ts b/packages/lint/src/rules/gsap.test.ts index e4a0798cd2..0f8dc49499 100644 --- a/packages/lint/src/rules/gsap.test.ts +++ b/packages/lint/src/rules/gsap.test.ts @@ -3056,6 +3056,29 @@ describe("SVG draw-on rules", () => { expect(finding?.severity).toBe("warning"); expect(finding?.selector).toBe("#ring"); + expect(finding?.fixHint).toContain("every fromTo except the earliest-positioned one (at 5s)"); + expect(finding?.fixHint).toContain("gsap_timeline_set_initial_hide"); + }); + + it("gsap_repeated_fromto_without_baseline: accepts the hinted shape when the later tween is authored first", async () => { + const html = ` + +
+ + +`; + const result = await lintHyperframeHtml(html); + const finding = result.findings.find( + (candidate) => candidate.code === "gsap_repeated_fromto_without_baseline", + ); + + expect(finding).toBeUndefined(); }); it("gsap_repeated_fromto_without_baseline: accepts explicit immediateRender false", async () => { diff --git a/packages/lint/src/rules/gsap.ts b/packages/lint/src/rules/gsap.ts index 215669de77..721d282578 100644 --- a/packages/lint/src/rules/gsap.ts +++ b/packages/lint/src/rules/gsap.ts @@ -1148,9 +1148,10 @@ export const gsapRules: LintRule[] = [ `(immediateRender), not at tween position.`, selector, fixHint: - `Add \`immediateRender: false\` to the destination vars of each future fromTo, or set a safe ` + - `resting state with an earlier \`tl.set("${selector}", { ... }, 0)\`. Pre-first-tween seeks must not ` + - `inherit whichever fromTo call happened to author last.`, + `Add \`immediateRender: false\` to every fromTo except the earliest-positioned one ` + + `(at ${firstFromToPosition}s), so pre-first-tween seeks keep its "from" values. ` + + `A hiding \`tl.set(..., 0)\` baseline trips gsap_timeline_set_initial_hide, and a \`gsap.set\` ` + + `authored before the fromTo calls is overwritten by them.`, snippet: truncateSnippet(fromToWindows.map((win) => win.raw).join("\n")), }); } From 385e9cf337c103d0918f9ea962c4e3859a2cc75f Mon Sep 17 00:00:00 2001 From: miga-heygen Date: Fri, 2 Oct 2026 12:32:52 +0000 Subject: [PATCH 11/58] fix(lint): error on digit-leading ids only when a selector targets them (#3980) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(lint): block on digit-leading ids instead of only warning A digit-leading id (e.g. id="1-hook") breaks any bare `#1-hook` CSS selector with a SyntaxError, including inline GSAP string selectors like tl.fromTo("#1-hook", ...). That throw silently aborts the rest of the + `; const result = await lintHyperframeHtml(html); const finding = result.findings.find((item) => item.code === "id_requires_css_escape"); - expect(finding?.severity).toBe("warning"); + expect(finding?.severity).toBe(severity); expect(finding?.elementId).toBe("123-frame"); expect(finding?.fixHint).toContain("CSS.escape"); }); diff --git a/packages/lint/src/rules/core.ts b/packages/lint/src/rules/core.ts index df942c84a1..adcf8c93ca 100644 --- a/packages/lint/src/rules/core.ts +++ b/packages/lint/src/rules/core.ts @@ -83,6 +83,44 @@ function repeatedDescendantId(selector: string): string | null { return repeated; } +// Unescaped `#` id selectors: what querySelector and GSAP reject. `#\31 -x` is valid and skipped. +function addUnescapedDigitIds(selector: string, ids: Set): void { + try { + selectorParser((root) => { + root.walkIds((node) => { + if (/^#\d/.test(node.toString().trim())) ids.add(node.value); + }); + }).processSync(selector); + } catch { + // An unparseable selector targets nothing we can name. + } +} + +const SELECTOR_CALL_PATTERN = + /\.(?:querySelector(?:All)?|closest|matches|to|from|fromTo|set)\s*\(\s*(["'`])((?:\\.|(?!\1)[^\\])*)\1/g; + +function digitIdsTargetedBySelectors( + styles: LintContext["styles"], + scripts: LintContext["scripts"], +): Set { + const ids = new Set(); + for (const style of styles) { + try { + postcss.parse(style.content).walkRules((rule) => { + for (const selector of rule.selectors) addUnescapedDigitIds(selector, ids); + }); + } catch { + // css_parse_error reports this block. + } + } + for (const script of scripts) { + for (const match of stripJsComments(script.content).matchAll(SELECTOR_CALL_PATTERN)) { + addUnescapedDigitIds(match[2] ?? "", ids); + } + } + return ids; +} + function resolvedRuleSelectors(rule: postcss.Rule): string[] { let ancestor: postcss.AnyNode | undefined = rule.parent; while (ancestor && ancestor.type !== "rule") ancestor = ancestor.parent; @@ -382,15 +420,20 @@ function describeRootDimensionsDrift( export const coreRules: Array<(ctx: LintContext) => HyperframeLintFinding[]> = [ // id_requires_css_escape - ({ tags }) => { + ({ tags, styles, scripts }) => { const findings: HyperframeLintFinding[] = []; + let targeted: Set | undefined; for (const tag of tags) { const id = readAttr(tag.raw, "id"); if (!id || !/^\d/.test(id)) continue; + targeted ??= digitIdsTargetedBySelectors(styles, scripts); + const used = targeted.has(id); findings.push({ code: "id_requires_css_escape", - severity: "warning", - message: `id="${id}" starts with a digit, so the common selector \`#${id}\` throws a SyntaxError in querySelector().`, + severity: used ? "error" : "warning", + message: used + ? `id="${id}" starts with a digit, and the selector \`#${id}\` used in this composition is invalid: querySelector and GSAP throw a SyntaxError, and CSS drops the rule.` + : `id="${id}" starts with a digit, so the common selector \`#${id}\` throws a SyntaxError in querySelector().`, elementId: id, fixHint: "Rename the id to start with a letter (recommended), or build selectors with `#${CSS.escape(id)}` at runtime.", From efdabb758d05f2666b1e4e13f32e447c4edfe760 Mon Sep 17 00:00:00 2001 From: miga-heygen Date: Fri, 2 Oct 2026 12:38:42 +0000 Subject: [PATCH 12/58] fix(cli): connector_detached now skips fully dash-hidden connector shafts (#3912) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(cli): connector_detached now skips dash-hidden connector shafts connector_detached fired on SVG connector paths that were 100% hidden via stroke-dashoffset/stroke-dasharray draw-on entrances, evaluating rendered/user-space geometry unconditionally. The sibling connector_orphan check already gates on shaftDashHidden(path); add the same gate here, in the same position. Co-Authored-By: Miguel Angel * fix(cli): connector dash gate reads the whole stroke-dasharray; one owner for connector enumeration `shaftDashHidden` read only the first `stroke-dasharray` entry, so any pattern starting with 0 (`0 4` dotted) or a long first dash counted as hidden and suppressed both connector findings on a visible stroke. It now resolves the full computed list (comma/space separated, units, percentages against the SVG viewport diagonal, odd lists repeated; `none`, all-zero and negative lists render solid) and treats the shaft as hidden only when the window `[dashoffset, dashoffset + length]` sits in a single gap, with up to 10% of the length overlapping a neighbouring dash. Zero-length dashes paint only under `stroke-linecap: round | square`; under the default `butt` they render nothing, which also covers the `0px, 999999px` state a finished draw-off tween leaves behind. `connector_detached` and `connector_orphan` each walked SVG paths with their own copy of the candidate/gate logic, which had already drifted. A single `connectorShafts(root)` generator now owns enumeration, the dash gate and endpoint resolution, and yields the `painted` verdict; both findings consume it. The path length is queried once per shaft (`pathUserEndpoints` returns it) instead of twice, and the attach threshold formula has one owner. Tests pin `0 4` (butt and round), `0, 4`, `4 0`, `0`, `none`, px units, negative offsets, a draw-off end state, and both sides of the 10% boundary. Co-Authored-By: Miguel Ángel * refactor(cli): shorten the connector and dash-window comments * test(cli): shorten the dash-gate table comment --------- Co-authored-by: Miguel Angel --- .../cli/src/commands/layout-audit.browser.js | 299 ++++++++++-------- .../src/commands/layout-audit.browser.test.ts | 78 ++++- 2 files changed, 233 insertions(+), 144 deletions(-) diff --git a/packages/cli/src/commands/layout-audit.browser.js b/packages/cli/src/commands/layout-audit.browser.js index be2a90de05..091c6c432b 100644 --- a/packages/cli/src/commands/layout-audit.browser.js +++ b/packages/cli/src/commands/layout-audit.browser.js @@ -1436,7 +1436,7 @@ ); } - /** Raw `d`-space endpoints (no CTM) — the mapping authors use when they paste screen coords into `d`. */ + // Raw `d`-space endpoints (no CTM), as authors paste screen coords into `d`, plus the path length. function pathUserEndpoints(path) { if (typeof path.getTotalLength !== "function" || typeof path.getPointAtLength !== "function") { return null; @@ -1450,7 +1450,7 @@ if (!Number.isFinite(total) || total <= 0) return null; const start = path.getPointAtLength(0); const end = path.getPointAtLength(total); - return { start: { x: start.x, y: start.y }, end: { x: end.x, y: end.y } }; + return { start: { x: start.x, y: start.y }, end: { x: end.x, y: end.y }, total }; } // Screen endpoints via getScreenCTM (viewBox, preserveAspectRatio, group transforms). @@ -1502,86 +1502,98 @@ return { compact, painted }; } - // Flag only the documented bug: rendered endpoints miss, but user-space-as-screen would attach. - function connectorDetachmentIssues(root, rootRect, time) { - const issues = []; - let anchors = null; - // Attach near-miss tolerance (screen px). Separate from the closed-glyph chord floor. - const threshold = Math.max(32, Math.min(rootRect.width, rootRect.height) * 0.02); - const MIN_CONNECTOR_CHORD_PX = 8; + // Attach near-miss tolerance (screen px) for both connector findings; not the glyph chord floor. + function connectorAttachThreshold(rootRect) { + return Math.max(32, Math.min(rootRect.width, rootRect.height) * 0.02); + } + + // The one connector enumeration for connector_detached and connector_orphan. Skips dash-hidden + // shafts; reports `painted` for callers to gate on, and `chord`, the rendered span in screen px. + function* connectorShafts(root) { for (const svg of Array.from(root.querySelectorAll("svg"))) { if (!isVisibleElement(svg)) continue; for (const path of Array.from(svg.querySelectorAll("path"))) { if (path.closest(CONNECTOR_SKIP_CONTAINERS)) continue; if (!isConnectorPath(svg, path)) continue; const user = pathUserEndpoints(path); + if (!user || shaftDashHidden(path, user.total)) continue; const rendered = pathScreenEndpoints(svg, path, user); - if (!user || !rendered) continue; - // Closed/glyph paths collapse to one point — compare in screen px (not user units). - const renderedChord = Math.hypot( + if (!rendered) continue; + const chord = Math.hypot( rendered.end.x - rendered.start.x, rendered.end.y - rendered.start.y, ); - if (renderedChord < MIN_CONNECTOR_CHORD_PX) continue; - if (anchors === null) anchors = connectorAnchorRects(root, rootRect); - if (anchors.compact.length < 2) return issues; - // Stable DOM identity across painted (inside) and compact (near-miss) tiers. - const attachmentKey = (point) => { - for (const anchor of anchors.painted) { - if (!anchor.element.contains(svg) && distanceToRect(point, anchor.rect) === 0) { - return anchor.element; - } - } - for (const anchor of anchors.compact) { - if (distanceToRect(point, anchor.rect) <= threshold) return anchor.element; - } - return null; - }; - const attached = (point) => attachmentKey(point) !== null; - // Half-attached as drawn is allowed; only full render-miss proceeds. - if (attached(rendered.start) || attached(rendered.end)) continue; - // Paste-into-`d` bug: both raw endpoints land on distinct anchors as screen pixels. - const userStartKey = attachmentKey(user.start); - const userEndKey = attachmentKey(user.end); - const pasteBug = Boolean(userStartKey && userEndKey && userStartKey !== userEndKey); - // Guessed marked shaft: both frames miss. Same-anchor grazes attach in user-space - // and must stay skipped. Name-only decorative flow/arrow paths stay skipped. - // 80px keeps short marker glyphs (chevrons, tips) out. - const markedMiss = - renderedChord >= 80 && - !userStartKey && - !userEndKey && - (path.hasAttribute("marker-start") || path.hasAttribute("marker-end")); - if (!pasteBug && !markedMiss) continue; - const gap = Math.round( - Math.min( - Math.min(...anchors.compact.map((a) => distanceToRect(rendered.start, a.rect))), - Math.min(...anchors.compact.map((a) => distanceToRect(rendered.end, a.rect))), - ), - ); - issues.push({ - code: "connector_detached", - severity: "warning", - time, - selector: selectorFor(path), - containerSelector: selectorFor(svg), - message: pasteBug - ? `Connector path endpoints render ${gap}px from the nearest anchorable element, but the path's user-space coordinates would attach if read as screen pixels — screen/viewport numbers were likely written into SVG \`d\` without inverting the CTM.` - : `Connector path endpoints render ${gap}px from the nearest anchorable element — a marked shaft that meets no node.`, - rect: toRect({ - left: Math.min(rendered.start.x, rendered.end.x), - top: Math.min(rendered.start.y, rendered.end.y), - right: Math.max(rendered.start.x, rendered.end.x), - bottom: Math.max(rendered.start.y, rendered.end.y), - width: Math.abs(rendered.end.x - rendered.start.x), - height: Math.abs(rendered.end.y - rendered.start.y), - }), - fixHint: pasteBug - ? "Convert measured screen coordinates into the SVG's user space (subtract the SVG rect / invert getScreenCTM) before writing path `d`, and keep the SVG a direct child of the stage." - : "Measure the settled node boxes and write `d` in the SVG's user space (invert getScreenCTM), or grow a layout-owned shaft from the source node.", - }); + yield { svg, path, user, rendered, chord, painted: shaftIsPainted(path) }; } } + } + + // Flag only the documented bug: rendered endpoints miss, but user-space-as-screen would attach. + function connectorDetachmentIssues(root, rootRect, time) { + const issues = []; + let anchors = null; + const threshold = connectorAttachThreshold(rootRect); + const MIN_CONNECTOR_CHORD_PX = 8; + for (const { svg, path, user, rendered, chord } of connectorShafts(root)) { + if (chord < MIN_CONNECTOR_CHORD_PX) continue; + if (anchors === null) anchors = connectorAnchorRects(root, rootRect); + if (anchors.compact.length < 2) return issues; + // Stable DOM identity across painted (inside) and compact (near-miss) tiers. + const attachmentKey = (point) => { + for (const anchor of anchors.painted) { + if (!anchor.element.contains(svg) && distanceToRect(point, anchor.rect) === 0) { + return anchor.element; + } + } + for (const anchor of anchors.compact) { + if (distanceToRect(point, anchor.rect) <= threshold) return anchor.element; + } + return null; + }; + const attached = (point) => attachmentKey(point) !== null; + // Half-attached as drawn is allowed; only full render-miss proceeds. + if (attached(rendered.start) || attached(rendered.end)) continue; + // Paste-into-`d` bug: both raw endpoints land on distinct anchors as screen pixels. + const userStartKey = attachmentKey(user.start); + const userEndKey = attachmentKey(user.end); + const pasteBug = Boolean(userStartKey && userEndKey && userStartKey !== userEndKey); + // Guessed marked shaft: both frames miss. Same-anchor grazes attach in user-space + // and must stay skipped. Name-only decorative flow/arrow paths stay skipped. + // 80px keeps short marker glyphs (chevrons, tips) out. + const markedMiss = + chord >= 80 && + !userStartKey && + !userEndKey && + (path.hasAttribute("marker-start") || path.hasAttribute("marker-end")); + if (!pasteBug && !markedMiss) continue; + const gap = Math.round( + Math.min( + Math.min(...anchors.compact.map((a) => distanceToRect(rendered.start, a.rect))), + Math.min(...anchors.compact.map((a) => distanceToRect(rendered.end, a.rect))), + ), + ); + issues.push({ + code: "connector_detached", + severity: "warning", + time, + selector: selectorFor(path), + containerSelector: selectorFor(svg), + message: pasteBug + ? `Connector path endpoints render ${gap}px from the nearest anchorable element, but the path's user-space coordinates would attach if read as screen pixels — screen/viewport numbers were likely written into SVG \`d\` without inverting the CTM.` + : `Connector path endpoints render ${gap}px from the nearest anchorable element — a marked shaft that meets no node.`, + rect: toRect({ + left: Math.min(rendered.start.x, rendered.end.x), + top: Math.min(rendered.start.y, rendered.end.y), + right: Math.max(rendered.start.x, rendered.end.x), + bottom: Math.max(rendered.start.y, rendered.end.y), + width: Math.abs(rendered.end.x - rendered.start.x), + height: Math.abs(rendered.end.y - rendered.start.y), + }), + fixHint: pasteBug + ? "Convert measured screen coordinates into the SVG's user space (subtract the SVG rect / invert getScreenCTM) before writing path `d`, and keep the SVG a direct child of the stage." + : "Measure the settled node boxes and write `d` in the SVG's user space (invert getScreenCTM), or grow a layout-owned shaft from the source node.", + }); + } return issues; } @@ -1598,19 +1610,58 @@ return opacityChain(path) >= 0.2; } - function shaftDashHidden(path) { - if (typeof path.getTotalLength !== "function") return false; - let total; - try { - total = path.getTotalLength(); - } catch { - return false; - } - if (!Number.isFinite(total) || total <= 0) return false; + // True when the visible dash window [offset, offset + length] sits in one gap (an unstarted + // draw-on), allowing 10% overlap. Zero-length dashes paint only with a round or square linecap. + function shaftDashHidden(path, total) { const style = getComputedStyle(path); - const offset = Number.parseFloat(style.strokeDashoffset || "0"); - const dash = Number.parseFloat(String(style.strokeDasharray || "").split(/[\s,]+/)[0] || "0"); - return offset >= total * 0.9 && dash >= total * 0.9; + const dashes = dashArrayLengths(style.strokeDasharray, path); + if (dashes === null) return false; + const dotsPaint = (style.strokeLinecap || "butt") !== "butt"; + const dashPaints = (index) => index % 2 === 0 && (dashes[index] > 0 || dotsPaint); + if (!dashes.some((_, index) => dashPaints(index))) return true; // only butt-capped dots + const period = dashes.reduce((sum, length) => sum + length, 0); + if (total > period) return false; // a full period of dash paints — call it visible + const offset = dashLength(style.strokeDashoffset, path); // unparseable reads as 0 + const start = Number.isFinite(offset) ? ((offset % period) + period) % period : 0; + const end = start + total; + let painted = 0; + let segmentStart = 0; + // Two periods cover any window that starts inside the first. + for (let i = 0; i < dashes.length * 2; i++) { + const segmentEnd = segmentStart + dashes[i % dashes.length]; + if (dashPaints(i % dashes.length)) { + if (segmentStart >= start && segmentEnd <= end) return false; + painted += Math.max(0, Math.min(segmentEnd, end) - Math.max(segmentStart, start)); + } + segmentStart = segmentEnd; + } + return painted <= total * 0.1; + } + + // Computed `stroke-dasharray` as an even-length list of user-unit lengths, or null when the + // stroke is solid: `none`, an all-zero list, or any negative/unparseable entry (which the spec + // renders as `none`). Odd lists repeat, per spec. + function dashArrayLengths(value, path) { + const text = String(value || "none").trim(); + if (text === "none") return null; + const lengths = text.split(/[\s,]+/).map((token) => dashLength(token, path)); + if (lengths.some((length) => !Number.isFinite(length) || length < 0)) return null; + if (lengths.every((length) => length === 0)) return null; + return lengths.length % 2 === 0 ? lengths : lengths.concat(lengths); + } + + // One dash length in user units. Computed lengths are already px; a percentage is relative to + // the normalised diagonal of the owning SVG viewport (viewBox when set, else the layout box). + function dashLength(token, path) { + const text = String(token).trim(); + const value = Number.parseFloat(text); + if (!Number.isFinite(value) || !text.endsWith("%")) return value; + const svg = path.ownerSVGElement; + if (!svg) return NaN; + const box = svg.viewBox && svg.viewBox.baseVal; + const { width, height } = + box && box.width > 0 && box.height > 0 ? box : svg.getBoundingClientRect(); + return (value / 100) * (Math.hypot(width, height) / Math.SQRT2); } function connectorEndpointCandidates(root, rootRect) { @@ -1633,57 +1684,45 @@ function connectorOrphanIssues(root, rootRect, time) { const issues = []; let candidates = null; - const threshold = Math.max(32, Math.min(rootRect.width, rootRect.height) * 0.02); - for (const svg of Array.from(root.querySelectorAll("svg"))) { - if (!isVisibleElement(svg)) continue; - for (const path of Array.from(svg.querySelectorAll("path"))) { - if (path.closest(CONNECTOR_SKIP_CONTAINERS)) continue; - if (!isConnectorPath(svg, path)) continue; - if (!shaftIsPainted(path) || shaftDashHidden(path)) continue; - const user = pathUserEndpoints(path); - const rendered = pathScreenEndpoints(svg, path, user); - if (!user || !rendered) continue; - const renderedChord = Math.hypot( - rendered.end.x - rendered.start.x, - rendered.end.y - rendered.start.y, - ); - if (renderedChord < 80) continue; - if (candidates === null) candidates = connectorEndpointCandidates(root, rootRect); - const dark = []; - for (const point of [rendered.start, rendered.end]) { - let best = null; - let attached = false; - for (const candidate of candidates) { - const gap = distanceToRect(point, candidate.rect); - if (gap > threshold) continue; - if (isVisibleElement(candidate.element)) { - attached = true; - break; - } - if (best === null || gap < best.gap) best = { gap, candidate }; + const threshold = connectorAttachThreshold(rootRect); + for (const { svg, path, rendered, chord, painted } of connectorShafts(root)) { + if (!painted) continue; + if (chord < 80) continue; + if (candidates === null) candidates = connectorEndpointCandidates(root, rootRect); + const dark = []; + for (const point of [rendered.start, rendered.end]) { + let best = null; + let attached = false; + for (const candidate of candidates) { + const gap = distanceToRect(point, candidate.rect); + if (gap > threshold) continue; + if (isVisibleElement(candidate.element)) { + attached = true; + break; } - if (!attached && best !== null) dark.push(best.candidate); + if (best === null || gap < best.gap) best = { gap, candidate }; } - if (dark.length === 0) continue; - issues.push({ - code: "connector_orphan", - severity: "warning", - time, - selector: selectorFor(path), - containerSelector: selectorFor(svg), - message: `Connector shaft is visible while ${dark.length === 2 ? "both endpoints are" : `its endpoint ${selectorFor(dark[0].element)} is`} not on stage.`, - rect: toRect({ - left: Math.min(rendered.start.x, rendered.end.x), - top: Math.min(rendered.start.y, rendered.end.y), - right: Math.max(rendered.start.x, rendered.end.x), - bottom: Math.max(rendered.start.y, rendered.end.y), - width: Math.abs(rendered.end.x - rendered.start.x), - height: Math.abs(rendered.end.y - rendered.start.y), - }), - fixHint: - "Show the shaft only after both ends are on, and hide it with the earlier exit. Do not give the line its own clock.", - }); + if (!attached && best !== null) dark.push(best.candidate); } + if (dark.length === 0) continue; + issues.push({ + code: "connector_orphan", + severity: "warning", + time, + selector: selectorFor(path), + containerSelector: selectorFor(svg), + message: `Connector shaft is visible while ${dark.length === 2 ? "both endpoints are" : `its endpoint ${selectorFor(dark[0].element)} is`} not on stage.`, + rect: toRect({ + left: Math.min(rendered.start.x, rendered.end.x), + top: Math.min(rendered.start.y, rendered.end.y), + right: Math.max(rendered.start.x, rendered.end.x), + bottom: Math.max(rendered.start.y, rendered.end.y), + width: Math.abs(rendered.end.x - rendered.start.x), + height: Math.abs(rendered.end.y - rendered.start.y), + }), + fixHint: + "Show the shaft only after both ends are on, and hide it with the earlier exit. Do not give the line its own clock.", + }); } return issues; } diff --git a/packages/cli/src/commands/layout-audit.browser.test.ts b/packages/cli/src/commands/layout-audit.browser.test.ts index d6427853b7..7978057d74 100644 --- a/packages/cli/src/commands/layout-audit.browser.test.ts +++ b/packages/cli/src/commands/layout-audit.browser.test.ts @@ -1462,8 +1462,7 @@ describe("layout-audit.browser coordinate-frame findings", () => { expect(issues.some((issue) => issue.code === "canvas_overflow")).toBe(true); }); - it("flags connector paths drawn in a foreign frame and passes anchored ones", () => { - document.body.innerHTML = ` + const foreignFrameDom = `
@@ -1474,18 +1473,20 @@ describe("layout-audit.browser coordinate-frame findings", () => {
`; - installGeometry( - { - root: rect({ left: 0, top: 0, width: 1920, height: 1080 }), - n1: rect({ left: 900, top: 500, width: 160, height: 160 }), - n2: rect({ left: 300, top: 200, width: 160, height: 160 }), - "connector-svg": rect({ left: 80, top: 227, width: 1740, height: 830 }), - }, - { - n1: { backgroundColor: "rgb(30, 40, 50)" }, - n2: { backgroundColor: "rgb(30, 40, 50)" }, - }, - ); + const foreignFrameRects = { + root: rect({ left: 0, top: 0, width: 1920, height: 1080 }), + n1: rect({ left: 900, top: 500, width: 160, height: 160 }), + n2: rect({ left: 300, top: 200, width: 160, height: 160 }), + "connector-svg": rect({ left: 80, top: 227, width: 1740, height: 830 }), + }; + const foreignFrameStyles = { + n1: { backgroundColor: "rgb(30, 40, 50)" }, + n2: { backgroundColor: "rgb(30, 40, 50)" }, + }; + + it("flags connector paths drawn in a foreign frame and passes anchored ones", () => { + document.body.innerHTML = foreignFrameDom; + installGeometry(foreignFrameRects, foreignFrameStyles); // Screen CTM translates svg user space by the svg's offset (80, 227): the detached path's // start (980, 580) renders at (1060, 807) — 147px below #n1's box — while the anchored // path's start (900, 353) renders at (980, 580), inside #n1. @@ -1500,6 +1501,55 @@ describe("layout-audit.browser coordinate-frame findings", () => { expect(issues[0]?.fixHint).toContain("invert getScreenCTM"); }); + it("does not flag a paste-bug connector still hidden behind its dash offset", () => { + document.body.innerHTML = foreignFrameDom; + // The fixture above, with #detached fully dash-hidden — draw-on entrance not yet advanced. + installGeometry(foreignFrameRects, { + ...foreignFrameStyles, + detached: { strokeDasharray: "100", strokeDashoffset: "100" }, + }); + installConnectorGeometry({ e: 80, f: 227 }); + installAuditScript(); + + expect(runAudit().filter((issue) => issue.code === "connector_detached")).toEqual([]); + }); + + // Hidden only when the visible window sits in one gap; a zero-length dash paints only with a + // round/square cap. Path length is 100, so `50 100` at offset 40 is the 10% boundary. + it.each([ + { dasharray: "0 4", offset: "0", count: 0 }, + { dasharray: "0 4", offset: "0", linecap: "round", count: 1 }, + { dasharray: "0, 4", offset: "0", linecap: "square", count: 1 }, + { dasharray: "0px, 999999px", offset: "-99.999px", count: 0 }, + { dasharray: "0 400", offset: "0", linecap: "round", count: 1 }, + { dasharray: "0 400", offset: "1", linecap: "round", count: 0 }, + { dasharray: "4 0", offset: "0", count: 1 }, + { dasharray: "0", offset: "0", count: 1 }, + { dasharray: "none", offset: "0", count: 1 }, + { dasharray: "100px", offset: "100px", count: 0 }, + { dasharray: "100", offset: "-100", count: 0 }, + { dasharray: "50 100", offset: "50", count: 0 }, + { dasharray: "50 100", offset: "40", count: 0 }, + { dasharray: "50 100", offset: "30", count: 1 }, + ])( + "stroke-dasharray $dasharray, dashoffset $offset, linecap $linecap → $count connector_detached", + ({ dasharray, offset, linecap, count }) => { + document.body.innerHTML = foreignFrameDom; + installGeometry(foreignFrameRects, { + ...foreignFrameStyles, + detached: { + strokeDasharray: dasharray, + strokeDashoffset: offset, + ...(linecap ? { strokeLinecap: linecap } : {}), + }, + }); + installConnectorGeometry({ e: 80, f: 227 }); + installAuditScript(); + + expect(runAudit().filter((issue) => issue.code === "connector_detached")).toHaveLength(count); + }, + ); + it("skips svgs and paths without connector intent", () => { document.body.innerHTML = `
From 8aefd91bf82c687222082a80a3c5845ff37e6ca6 Mon Sep 17 00:00:00 2001 From: HEOJUNFO <100739943+HEOJUNFO@users.noreply.github.com> Date: Fri, 2 Oct 2026 21:48:06 +0900 Subject: [PATCH 13/58] fix(cli): capture snapshot --at at the exact requested instant (#4827) snapshot --at captures the frame at the exact requested instant instead of the nearest seek step. --- .../capture/captureCompositionFrame.test.ts | 17 +++++-- .../src/capture/captureCompositionFrame.ts | 9 ++-- packages/cli/src/commands/snapshot.test.ts | 44 ++++++++++++++++++- packages/cli/src/commands/snapshot.ts | 5 ++- packages/core/src/runtime/init.test.ts | 36 +++++++++++++++ packages/core/src/runtime/init.ts | 10 ++--- packages/core/src/runtime/player.test.ts | 9 ++++ packages/core/src/runtime/player.ts | 19 +++++--- packages/core/src/runtime/types.ts | 1 + .../services/frameCapture-motionBlur.test.ts | 20 ++++++++- packages/parsers/src/types.ts | 2 +- 11 files changed, 150 insertions(+), 22 deletions(-) diff --git a/packages/cli/src/capture/captureCompositionFrame.test.ts b/packages/cli/src/capture/captureCompositionFrame.test.ts index 1fd125fbcc..7c3c0699cb 100644 --- a/packages/cli/src/capture/captureCompositionFrame.test.ts +++ b/packages/cli/src/capture/captureCompositionFrame.test.ts @@ -56,7 +56,7 @@ describe("seekCompositionTimeline", () => { expect(waitForFunction).not.toHaveBeenCalled(); expect(evaluate).toHaveBeenCalledTimes(4); - expect(evaluate).toHaveBeenNthCalledWith(1, expect.any(Function), 1.25, false); + expect(evaluate).toHaveBeenNthCalledWith(1, expect.any(Function), 1.25, false, false); expect(evaluate).toHaveBeenNthCalledWith(2, expect.any(Function)); expect(evaluate.mock.calls[2]?.[0]).toContain("window.setTimeout(finish, 100)"); // Post-seek font settle: a seek can reveal glyphs whose unicode-range @@ -93,6 +93,17 @@ describe("seekCompositionTimeline", () => { expect(timelineSeek).not.toHaveBeenCalled(); }); + it("asks renderSeek for the exact instant when exactTime is set", async () => { + const { page, evaluate } = fakeSeekPage(); + const renderSeek = vi.fn(); + vi.stubGlobal("window", { __player: { renderSeek } }); + + await seekCompositionTimeline(page, 19.019018, { exactTime: true }); + runBrowserSeek(evaluate); + + expect(renderSeek).toHaveBeenCalledWith(19.019018, { exact: true }); + }); + function fakeBridgeOnlySeekPage() { const { page, evaluate } = fakeSeekPage(); const bridgeSeek = vi.fn(); @@ -150,7 +161,7 @@ describe("seekCompositionTimeline", () => { expect(waitForFunction).toHaveBeenCalledWith(expect.any(Function), { timeout: 500 }); expect(evaluate).toHaveBeenCalledTimes(2); - expect(evaluate).toHaveBeenCalledWith(expect.any(Function), 3, true); + expect(evaluate).toHaveBeenCalledWith(expect.any(Function), 3, true, false); }); it("supports layout's ordered double-frame, bounded font, and sleep settles", async () => { @@ -167,7 +178,7 @@ describe("seekCompositionTimeline", () => { await pending; expect(evaluate).toHaveBeenCalledTimes(4); - expect(evaluate).toHaveBeenNthCalledWith(1, expect.any(Function), 4, true); + expect(evaluate).toHaveBeenNthCalledWith(1, expect.any(Function), 4, true, false); expect(evaluate).toHaveBeenNthCalledWith(2, expect.any(Function)); expect(evaluate).toHaveBeenNthCalledWith(3, expect.any(Function)); expect(evaluate).toHaveBeenNthCalledWith(4, expect.any(Function), 500); diff --git a/packages/cli/src/capture/captureCompositionFrame.ts b/packages/cli/src/capture/captureCompositionFrame.ts index df0b49b4eb..4b0aa39211 100644 --- a/packages/cli/src/capture/captureCompositionFrame.ts +++ b/packages/cli/src/capture/captureCompositionFrame.ts @@ -37,6 +37,7 @@ export const DENSE_GEOMETRY_SEEK_OPTIONS = { export interface SeekCompositionTimelineOptions { fallbackToBridgeAndTimelines?: boolean; + exactTime?: boolean; waitForPreferredSeekTargetMs?: number; animationFrameSettle?: "race" | "double" | "none"; waitForFontsMs?: number; @@ -47,13 +48,14 @@ type CompositionPageFunction = | string | (() => unknown) | ((value: number) => unknown) - | ((value: number, fallbackToBridgeAndTimelines: boolean) => unknown); + | ((value: number, fallbackToBridgeAndTimelines: boolean, exactTime: boolean) => unknown); export interface CompositionEvaluationPage { evaluate( pageFunction: CompositionPageFunction, value?: number, fallbackToBridgeAndTimelines?: boolean, + exactTime?: boolean, ): Promise; } @@ -247,7 +249,7 @@ export async function seekCompositionTimeline( await page.evaluate( // Serialized into the page; the seek-target cascade must stay one function. // fallow-ignore-next-line complexity - (t: number, fallbackToBridgeAndTimelines: boolean) => { + (t: number, fallbackToBridgeAndTimelines: boolean, exactTime: boolean) => { const getProperty = (target: unknown, key: string): unknown => { if ((typeof target !== "object" || target === null) && typeof target !== "function") { return undefined; @@ -271,7 +273,7 @@ export async function seekCompositionTimeline( // Prefer renderSeek because it also runs the runtime's data-start/data-duration // visibility sync; raw timeline seeks leave off-window clips visible to audits. - if (call(renderSeek, player, [safe])) { + if (call(renderSeek, player, exactTime ? [safe, { exact: true }] : [safe])) { // Preferred runtime target handled the seek. } else if (fallbackToBridgeAndTimelines && call(bridgeSeek, hf, [safe])) { // Producer bridge handled the seek. @@ -294,6 +296,7 @@ export async function seekCompositionTimeline( }, timeSeconds, options.fallbackToBridgeAndTimelines === true, + options.exactTime === true, ); await page.evaluate(async () => { diff --git a/packages/cli/src/commands/snapshot.test.ts b/packages/cli/src/commands/snapshot.test.ts index 7fd4db398c..992de2bbc9 100644 --- a/packages/cli/src/commands/snapshot.test.ts +++ b/packages/cli/src/commands/snapshot.test.ts @@ -8,15 +8,19 @@ import { findFFmpeg } from "../browser/ffmpeg.js"; import { sourceTimeAt } from "@hyperframes/core"; const snapshotState = vi.hoisted(() => ({ - openSettledPage: vi.fn(async () => { + openSettledPage: vi.fn(async (): Promise => { throw new Error("browser capture reached"); }), + seek: vi.fn(async (_page: unknown, _time: number, _options?: unknown): Promise => { + throw new Error("seek reached"); + }), closeServer: vi.fn(async () => undefined), })); vi.mock("../capture/captureCompositionFrame.js", async (importOriginal) => ({ ...(await importOriginal()), openSettledCompositionPage: snapshotState.openSettledPage, + seekCompositionTimeline: snapshotState.seek, })); vi.mock("../utils/staticProjectServer.js", () => ({ @@ -150,6 +154,44 @@ describe("snapshot lint preflight", () => { }); }); +describe("snapshot --at seeks", () => { + it("asks the runtime for the exact requested instant, not its 30fps grid", async () => { + const project = mkdtempSync(join(tmpdir(), "hf-snapshot-exact-at-")); + writeFileSync( + join(project, "index.html"), + `
Visible
`, + ); + const evaluate = vi + .fn() + .mockResolvedValueOnce({ loaded: [], errored: [], unused: [] }) + .mockResolvedValueOnce(20) + .mockResolvedValueOnce(true); + const close = vi.fn(async () => undefined); + snapshotState.openSettledPage.mockResolvedValueOnce({ + browser: { close }, + page: { evaluate }, + renderReadyTimedOut: false, + }); + snapshotState.seek.mockClear(); + const log = vi.spyOn(console, "log").mockImplementation(() => undefined); + + try { + await expect( + snapshotCommand.run?.({ + args: { dir: project, at: "19.019018", end: false, output: join(project, "out") }, + } as never), + ).rejects.toBeDefined(); + expect(snapshotState.seek).toHaveBeenCalledWith(expect.anything(), 19.019018, { + exactTime: true, + }); + expect(close).toHaveBeenCalled(); + } finally { + log.mockRestore(); + rmSync(project, { recursive: true, force: true }); + } + }); +}); + describe("resolveSnapshotVideoFrameTime", () => { it("holds a clip ending with the composition on its last decodable frame", () => { expect( diff --git a/packages/cli/src/commands/snapshot.ts b/packages/cli/src/commands/snapshot.ts index b091b3c6c1..f086ae6b3c 100644 --- a/packages/cli/src/commands/snapshot.ts +++ b/packages/cli/src/commands/snapshot.ts @@ -453,7 +453,7 @@ async function captureSnapshots( for (let i = 0; i < positions.length; i++) { const time = positions[i]!; - await seekCompositionTimeline(page, time); + await seekCompositionTimeline(page, time, { exactTime: true }); if (cameraExpr) await page.evaluate(cameraExpr); @@ -684,7 +684,8 @@ export default defineCommand({ }, at: { type: "string", - description: "Comma-separated timestamps in seconds (e.g., --at 3.0,10.5,18.0)", + description: + "Comma-separated timestamps in seconds (e.g., --at 3.0,10.5,18.0). Each is captured at that exact instant, not snapped to a frame.", }, timeout: { type: "string", diff --git a/packages/core/src/runtime/init.test.ts b/packages/core/src/runtime/init.test.ts index 76a95cbb2d..dcdf597591 100644 --- a/packages/core/src/runtime/init.test.ts +++ b/packages/core/src/runtime/init.test.ts @@ -1023,6 +1023,42 @@ describe("initSandboxRuntimeModular", () => { expect(timeline.time()).toBe(0); }); + describe("issue #4430 sweep on a 29.97fps project", () => { + // `snapshot --at` times from the issue, with where the 30fps grid floors each one. + const sweep = [ + { at: 19.019018, grid: 19 }, + { at: 19.05, grid: 571 / 30 }, + ]; + + function seekOnNtscProject(at: number, options?: { exact?: boolean }): number { + const root = document.createElement("div"); + root.setAttribute("data-composition-id", "main"); + root.setAttribute("data-root", "true"); + root.setAttribute("data-start", "0"); + root.setAttribute("data-duration", "20"); + root.setAttribute("data-fps", "29.97"); + root.setAttribute("data-width", "1920"); + root.setAttribute("data-height", "1080"); + document.body.appendChild(root); + + const timeline = createMockTimeline(20); + window.__timelines = { main: timeline }; + + initSandboxRuntimeModular(); + window.__player?.renderSeek(at, options); + return timeline.time(); + } + + it.each(sweep)("an exact renderSeek to $at lands on $at", ({ at }) => { + expect(seekOnNtscProject(at, { exact: true })).toBe(at); + }); + + // Frame export never passes `exact`, so its seeks keep flooring onto the frame grid. + it.each(sweep)("a default renderSeek to $at still floors to $grid", ({ at, grid }) => { + expect(seekOnNtscProject(at)).toBeCloseTo(grid, 9); + }); + }); + it("uses live child timeline duration when a composition host has no authored duration", () => { const root = document.createElement("div"); root.setAttribute("data-composition-id", "main"); diff --git a/packages/core/src/runtime/init.ts b/packages/core/src/runtime/init.ts index e5b60f33d5..8e10b5b0eb 100644 --- a/packages/core/src/runtime/init.ts +++ b/packages/core/src/runtime/init.ts @@ -44,7 +44,7 @@ import { import { handleErrorForProxy, handleMetadataForProxy, maybeProxyProactively } from "./mediaProxy"; import { probeAndCacheElementVolume, type VolumeKeyframe } from "./mediaVolumeEnvelope.js"; import { createPickerModule } from "./picker"; -import { createRuntimePlayer, type RuntimePlayerTransport } from "./player"; +import { createRuntimePlayer, resolveRenderSeekTime, type RuntimePlayerTransport } from "./player"; import { createRuntimeState } from "./state"; import { collectRuntimeTimelinePayload, @@ -97,7 +97,7 @@ import { isMemberGroupHidden, } from "../audioGroups"; import { clampNativeMediaVolume } from "../audioGain"; -import { quantizeSeekTime, quantizeTimeToFrame } from "../inline-scripts/parityContract"; +import { quantizeTimeToFrame } from "../inline-scripts/parityContract"; import { createManualEditGestureWatch } from "./manualEditGestureWatch"; import type { HeldSeek, @@ -3905,15 +3905,15 @@ export function initSandboxRuntimeModular(): void { renderSeek: (timeSeconds, options) => { heldSeek = null; renderCaptureSeekStarted = true; - const quantized = quantizeSeekTime( + const seekTime = resolveRenderSeekTime( Math.max(0, Number(timeSeconds) || 0), state.canonicalFps, - options?.subFrameDivisions, + options, ); webAudio.stopAll(); clock.detachAudioSource(); if (clock.isPlaying()) clock.pause(); - clock.seek(quantized); + clock.seek(seekTime); state.currentTime = clock.now(); state.isPlaying = false; state.mediaForceSyncNextTick = true; diff --git a/packages/core/src/runtime/player.test.ts b/packages/core/src/runtime/player.test.ts index fde3b30e61..0a29309172 100644 --- a/packages/core/src/runtime/player.test.ts +++ b/packages/core/src/runtime/player.test.ts @@ -709,6 +709,15 @@ describe("renderSeek sub-frame grid (issue #4010 motion blur)", () => { expect(timeline.time()).toBe(10 / 30); }); + it("lands on the requested instant, off every frame grid, for an exact seek", () => { + const timeline = createMockTimeline(); + const player = createRuntimePlayer(createMockDeps(timeline)); + + player.renderSeek(10 / 30 + 0.017, { exact: true }); + + expect(timeline.time()).toBe(10 / 30 + 0.017); + }); + it("suppresses timeline events on a sub-frame sample seek", () => { const timeline = createMockTimeline(); const player = createRuntimePlayer(createMockDeps(timeline)); diff --git a/packages/core/src/runtime/player.ts b/packages/core/src/runtime/player.ts index 7217dcea47..89a13e665d 100644 --- a/packages/core/src/runtime/player.ts +++ b/packages/core/src/runtime/player.ts @@ -83,13 +83,24 @@ function forEachSiblingTimeline( } } +export function resolveRenderSeekTime( + timeSeconds: number, + canonicalFps: number, + options?: RuntimeSeekOptions, +): number { + if (options?.exact === true) { + return Number.isFinite(timeSeconds) && timeSeconds > 0 ? timeSeconds : 0; + } + return quantizeSeekTime(timeSeconds, canonicalFps, options?.subFrameDivisions); +} + function seekTimelineDeterministically( timeline: RuntimeTimelineLike, timeSeconds: number, canonicalFps: number, options?: RuntimeSeekOptions, ): number { - const quantized = quantizeSeekTime(timeSeconds, canonicalFps, options?.subFrameDivisions); + const quantized = resolveRenderSeekTime(timeSeconds, canonicalFps, options); const suppressEvents = options?.suppressEvents === true; safeVoid(timeline, "pause"); if (typeof timeline.totalTime === "function") { @@ -248,11 +259,7 @@ export function createRuntimePlayer(deps: PlayerDeps): RuntimePlayer { activateSiblingTimelines(deps.getTimelineRegistry?.(), timeline); return seekTimelineDeterministically(timeline, timeSeconds, canonicalFps, options); })() - : quantizeSeekTime( - Math.max(0, Number(timeSeconds) || 0), - canonicalFps, - options?.subFrameDivisions, - ); + : resolveRenderSeekTime(Math.max(0, Number(timeSeconds) || 0), canonicalFps, options); deps.onDeterministicSeek(quantized, options); deps.setIsPlaying(false); deps.onSyncMedia(quantized, false); diff --git a/packages/core/src/runtime/types.ts b/packages/core/src/runtime/types.ts index eecdda6ce4..1c38578372 100644 --- a/packages/core/src/runtime/types.ts +++ b/packages/core/src/runtime/types.ts @@ -286,6 +286,7 @@ export type RuntimeSeekOptions = { * engine's sub-frame tick count so a fractional sample time survives quantization. */ subFrameDivisions?: number; + exact?: boolean; }; export type RuntimeTimelineChildLike = { diff --git a/packages/engine/src/services/frameCapture-motionBlur.test.ts b/packages/engine/src/services/frameCapture-motionBlur.test.ts index 15c7db60bd..320d6c3204 100644 --- a/packages/engine/src/services/frameCapture-motionBlur.test.ts +++ b/packages/engine/src/services/frameCapture-motionBlur.test.ts @@ -28,13 +28,14 @@ interface RecordedSeek { time: number; suppressEvents?: boolean; subFrameDivisions?: number; + exact?: boolean; } function installPageGlobals(seeks: RecordedSeek[]): void { const root = globalThis as Record; root.window = { __hf: { - seek: (time: number, options?: { suppressEvents?: boolean; subFrameDivisions?: number }) => { + seek: (time: number, options?: Omit) => { seeks.push({ time, ...options }); }, }, @@ -175,6 +176,23 @@ describe("sub-frame accumulation reaches the page with distinct sample times", ( }); }); +describe("frame export keeps its frame grid (issue #4430)", () => { + // `exact` is the snapshot-only opt-out of the runtime's seek quantization. Export must + // never send it, or frames would land between grid points instead of on them. + it("never asks for an exact seek with motion blur off", async () => { + await captureFrameToBuffer(makeSession({ motionBlur: undefined }), 10, 10 / 30); + + expect(seeks).toEqual([{ time: 10 / 30 }]); + }); + + it("never asks for an exact seek on any motion-blur sample", async () => { + await captureFrameToBuffer(makeSession(), 10, 10 / 30); + + expect(seeks.length).toBeGreaterThan(1); + expect(seeks.every((s) => !("exact" in s))).toBe(true); + }); +}); + describe("accumulation composes with static-frame dedup", () => { // 720 degrees is the widest shutter After Effects offers, and the AD5 reference export // uses it, so it is the case a reader is most likely to check the frame ranges against. diff --git a/packages/parsers/src/types.ts b/packages/parsers/src/types.ts index d6588ae977..9f964a7ff6 100644 --- a/packages/parsers/src/types.ts +++ b/packages/parsers/src/types.ts @@ -439,7 +439,7 @@ export interface PlayerAPI { disableRenderMode(): void; renderSeek( time: number, - options?: { suppressEvents?: boolean; subFrameDivisions?: number }, + options?: { suppressEvents?: boolean; subFrameDivisions?: number; exact?: boolean }, ): void; getElementVisibility(elementId: string): { visible: boolean; opacity?: number }; getVisibleElements(): Array<{ id: string; tagName: string; start: number; end: number }>; From f1b79d8e7bdb2f17224737e6b9990e9ace3dd5c6 Mon Sep 17 00:00:00 2001 From: Poetry Of Code <101225909+poetryofcode@users.noreply.github.com> Date: Fri, 2 Oct 2026 08:51:30 -0400 Subject: [PATCH 14/58] fix(media-use): honour HYPERFRAMES_PYTHON in the audio engine (#4614) (#4723) * fix(media-use): honour HYPERFRAMES_PYTHON in the audio engine (#4614) resolvePythonCommand() only probed python3/python on PATH, so on PEP 668 systems set up with a venv via HYPERFRAMES_PYTHON (the documented setup), doctor reported MusicGen installed while BGM was silently skipped. Check HYPERFRAMES_PYTHON first, as the CLI's findPython() does, and fall through to the PATH probe when the override doesn't run. * fix(media-use): require a Python 3 version from the interpreter probe Address review on #4723: - The probe accepted any executable that exits 0, so a Python 2 HYPERFRAMES_PYTHON (or python on PATH) was taken while the CLI's validatePythonOverride() rejects it. Require "Python 3" in the --version output, reading stderr too since Python 2 prints there. - Regenerate skills-manifest.json for the media-use change. * chore(skills): regenerate manifest without local __pycache__ * chore(media-use): trim python resolver comments to the comment limit * style(media-use): format the python probe test --------- Co-authored-by: Miguel Angel Simon Sierra --- skills-manifest.json | 2 +- skills/media-use/audio/scripts/lib/python.mjs | 24 +++++-- .../audio/scripts/lib/python.test.mjs | 70 ++++++++++++++++++- 3 files changed, 89 insertions(+), 7 deletions(-) diff --git a/skills-manifest.json b/skills-manifest.json index 27cc9fe3c6..83d6b79b6c 100644 --- a/skills-manifest.json +++ b/skills-manifest.json @@ -54,7 +54,7 @@ "files": 1 }, "media-use": { - "hash": "0744050e3114e60a", + "hash": "bf88c1a47da67cfa", "files": 104 }, "motion-graphics": { diff --git a/skills/media-use/audio/scripts/lib/python.mjs b/skills/media-use/audio/scripts/lib/python.mjs index a11c0151ce..f5cd7fe6c7 100644 --- a/skills/media-use/audio/scripts/lib/python.mjs +++ b/skills/media-use/audio/scripts/lib/python.mjs @@ -11,12 +11,20 @@ // Resolve once, per process: probe the platform's candidates in order and take // the first that actually runs. `py` is the launcher, so it needs a `-3` arg to // select Python 3 — hence candidates are argv PREFIXES, not bare names. +// +// `HYPERFRAMES_PYTHON` (the documented PEP 668 venv setup) wins over the PATH probe, matching +// the CLI's `findPython()`; ignoring it made BGM silently disable itself (#4614). import { spawnSync } from "node:child_process"; -function defaultProbe(cmd, args) { +// Accept only an interpreter whose `--version` reports Python 3, as the CLI's +// `validatePythonOverride()` does. Exit status alone would take a Python 2 +// `python` (or any executable that exits 0) that `doctor` rejects. Python 2 +// prints its version to stderr, so read both streams. +export function defaultProbe(cmd, args) { try { - return spawnSync(cmd, args, { stdio: "ignore" }).status === 0; + const result = spawnSync(cmd, args, { encoding: "utf-8", timeout: 5000 }); + return result.status === 0 && /Python 3/.test(`${result.stdout}${result.stderr}`); } catch { return false; } @@ -26,12 +34,18 @@ function defaultProbe(cmd, args) { * Pick the argv prefix that launches Python 3 on this platform. * Returns e.g. `["python3"]`, `["python"]`, or `["py", "-3"]`. * - * Pure except for `probe` (which runs ` … --version`); both `platform` - * and `probe` are injectable so every branch is unit-testable without spawning. + * Pure except for `probe` (which runs ` … --version`); `platform`, `probe` + * and `env` are injectable so every branch is unit-testable without spawning. * If nothing probes OK, falls back to the canonical name for the platform so * the eventual spawn fails loudly exactly as it did before — never worse. */ -export function resolvePythonCommand(platform = process.platform, probe = defaultProbe) { +export function resolvePythonCommand( + platform = process.platform, + probe = defaultProbe, + env = process.env, +) { + const override = env.HYPERFRAMES_PYTHON; + if (override && probe(override, ["--version"])) return [override]; const candidates = platform === "win32" ? [["python3"], ["python"], ["py", "-3"]] : [["python3"], ["python"]]; for (const prefix of candidates) { diff --git a/skills/media-use/audio/scripts/lib/python.test.mjs b/skills/media-use/audio/scripts/lib/python.test.mjs index 4598d02e03..babea4efc6 100644 --- a/skills/media-use/audio/scripts/lib/python.test.mjs +++ b/skills/media-use/audio/scripts/lib/python.test.mjs @@ -1,6 +1,9 @@ import { test } from "node:test"; import assert from "node:assert/strict"; -import { resolvePythonCommand, pythonInvocation } from "./python.mjs"; +import { chmodSync, mkdtempSync, rmSync, writeFileSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import { defaultProbe, resolvePythonCommand, pythonInvocation } from "./python.mjs"; // Regression: on Windows a standard python.org install has no `python3.exe` // (only `python.exe` + the `py` launcher), so `spawn("python3", …)` ENOENTs and @@ -55,6 +58,71 @@ test("falls back to the canonical name (loud failure, unchanged) when nothing ru ); }); +// Regression (#4614): on PEP 668 systems the documented setup is a venv named +// by HYPERFRAMES_PYTHON; the audio engine ignored it and probed the bare +// system python3, so MusicGen BGM was skipped while `doctor` said installed. +const VENV = "/home/u/.venvs/hf/bin/python"; + +test("HYPERFRAMES_PYTHON wins over python3 on PATH when it runs", () => { + const env = { HYPERFRAMES_PYTHON: VENV }; + assert.deepEqual(resolvePythonCommand("darwin", probeFor(VENV, "python3"), env), [VENV]); + assert.deepEqual(resolvePythonCommand("win32", probeFor(VENV, "python", "py"), env), [VENV]); +}); + +test("a HYPERFRAMES_PYTHON that doesn't run falls through to the PATH probe", () => { + const env = { HYPERFRAMES_PYTHON: "/nope/python" }; + assert.deepEqual(resolvePythonCommand("linux", probeFor("python3"), env), ["python3"]); +}); + +test("an empty HYPERFRAMES_PYTHON is ignored without being probed", () => { + const seen = []; + const probe = (cmd) => { + seen.push(cmd); + return cmd === "python3"; + }; + assert.deepEqual(resolvePythonCommand("linux", probe, { HYPERFRAMES_PYTHON: "" }), ["python3"]); + assert.deepEqual(seen, ["python3"]); +}); + +// defaultProbe must match the CLI's validatePythonOverride(): exiting 0 is not +// enough, `--version` has to report Python 3. Stubs are shell scripts, so +// these run on POSIX only. +function withStub(script, fn) { + const dir = mkdtempSync(join(tmpdir(), "hf-python-probe-")); + try { + const stub = join(dir, "python"); + writeFileSync(stub, `#!/bin/sh\n${script}\n`); + chmodSync(stub, 0o755); + fn(stub); + } finally { + rmSync(dir, { recursive: true, force: true }); + } +} + +const posixOnly = { skip: process.platform === "win32" && "stub scripts need a POSIX shell" }; + +test("defaultProbe accepts an interpreter reporting Python 3", posixOnly, () => { + withStub('echo "Python 3.12.4"', (stub) => assert.equal(defaultProbe(stub, ["--version"]), true)); +}); + +test("defaultProbe rejects Python 2, which prints its version to stderr", posixOnly, () => { + withStub('echo "Python 2.7.18" >&2', (stub) => + assert.equal(defaultProbe(stub, ["--version"]), false), + ); +}); + +test( + "defaultProbe rejects an executable that exits 0 without a Python 3 version", + posixOnly, + () => { + withStub("exit 0", (stub) => assert.equal(defaultProbe(stub, ["--version"]), false)); + }, +); + +test("defaultProbe rejects a command that doesn't exist", () => { + assert.equal(defaultProbe("/nonexistent/hf-python", ["--version"]), false); +}); + test("pythonInvocation prepends the resolved prefix ahead of caller args", () => { assert.deepEqual(pythonInvocation(["-c", "import x"], ["python"]), { cmd: "python", From d2cdad418a633cf686b7a7ff784b8e2db7da520f Mon Sep 17 00:00:00 2001 From: Leonel Rivas Date: Fri, 2 Oct 2026 05:53:31 -0700 Subject: [PATCH 15/58] fix(cli): refuse capture folders that resolve outside the output root (#4789) * fix(cli): refuse capture directories that resolve outside the output root writeCaptureFileSync guards the final path entry, but a directory in the path that is itself a planted symlink (assets -> ~/somewhere) still carried the staging directory and the rename into wherever it pointed, with a filename the captured page chose. Every capture directory is now created through ensureCaptureDirSync(root, dir), which walks from the output root one level at a time and refuses any directory whose real path is not the one it has under the root, before creating anything inside it. The root itself stays trusted as given, so a symlinked root like /tmp on macOS keeps working. Fixes #4304 * fix(cli): vet assets/svgs before the SVG contact sheet writes into it Under --skip-assets, downloadAssets never runs, so nothing checked assets/svgs before createSvgContactSheet wrote its thumbnails and contact-sheet.jpg into it; a planted assets/svgs link received them. The sheet now runs ensureCaptureDirSync on the directory first, and a refusal just skips the sheet. A dangling or looping directory link is now refused with the same message instead of a raw ENOENT/ELOOP, and a comment records why the check uses the JS realpathSync rather than realpathSync.native. Refs #4304 * fix(cli): vet capture --video's download folder Video mode created assets/videos (or capture/assets/videos in a W2H project) with a plain mkdirSync, so a planted assets or capture link carried the downloaded clip outside the project. It now goes through ensureCaptureDirSync with the project folder as the trusted root, and a refused folder is reported before anything is downloaded. * fix(cli): warn when a best-effort capture phase refuses a folder Folder refusals now throw CaptureDirRefusedError. The contact sheets and the video manifest still skip on any error, but a refusal adds a warning so a planted link doesn't go unnoticed. saveLottieAnimations now vets assets/lottie itself, taking the output root like renderLottiePreviews, and every folder check in the capture pipeline is pinned by a test. * style(cli): trim the ensureCaptureDirSync doc comment to two lines --------- Co-authored-by: Miguel Angel Simon Sierra --- .../cli/src/capture/assetDownloader.test.ts | 73 +++++++++++++- packages/cli/src/capture/assetDownloader.ts | 9 +- .../cli/src/capture/captureAttempt.test.ts | 47 +++++++++ packages/cli/src/capture/captureAttempt.ts | 9 +- packages/cli/src/capture/captureErrors.ts | 7 ++ packages/cli/src/capture/captureFile.test.ts | 75 +++++++++++++- packages/cli/src/capture/captureFile.ts | 69 ++++++++++++- .../cli/src/capture/coreExtractionPhase.ts | 16 ++- packages/cli/src/capture/mediaCapture.test.ts | 97 ++++++++++++++++++- packages/cli/src/capture/mediaCapture.ts | 12 ++- .../cli/src/capture/partialCapture.test.ts | 36 ++++++- packages/cli/src/capture/partialCapture.ts | 7 +- .../src/capture/postExtractionPhase.test.ts | 58 +++++++++++ .../cli/src/capture/postExtractionPhase.ts | 13 ++- .../cli/src/capture/screenshotCapture.test.ts | 31 +++++- packages/cli/src/capture/screenshotCapture.ts | 5 +- .../cli/src/commands/capture/video.test.ts | 48 ++++++++- packages/cli/src/commands/capture/video.ts | 11 ++- 18 files changed, 581 insertions(+), 42 deletions(-) create mode 100644 packages/cli/src/capture/captureAttempt.test.ts create mode 100644 packages/cli/src/capture/postExtractionPhase.test.ts diff --git a/packages/cli/src/capture/assetDownloader.test.ts b/packages/cli/src/capture/assetDownloader.test.ts index 158551a445..715965485d 100644 --- a/packages/cli/src/capture/assetDownloader.test.ts +++ b/packages/cli/src/capture/assetDownloader.test.ts @@ -1,5 +1,13 @@ import { afterEach, describe, expect, it, vi } from "vitest"; -import { mkdtempSync, readFileSync, readdirSync, rmSync } from "node:fs"; +import { + existsSync, + mkdirSync, + mkdtempSync, + readFileSync, + readdirSync, + rmSync, + symlinkSync, +} from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; import { @@ -9,6 +17,7 @@ import { safeFetch, toStandaloneSvg, } from "./assetDownloader.js"; +import { CaptureDirRefusedError } from "./captureErrors.js"; import type { DesignTokens } from "./types.js"; import type { IconCandidate } from "./faviconRanker.js"; import { CAPTURE_USER_AGENT } from "./userAgent.js"; @@ -741,3 +750,65 @@ describe("capture download security boundaries", () => { }); }); }); + +describe("a planted directory link inside the capture directory (#4304)", () => { + // Creating symlinks needs elevated rights on Windows. + const posixOnly = it.skipIf(process.platform === "win32"); + + function plantedLink(root: string, link: string): { outputDir: string; outside: string } { + const outputDir = join(root, "capture"); + const outside = join(root, "outside"); + mkdirSync(join(outputDir, link, ".."), { recursive: true }); + mkdirSync(outside); + symlinkSync(outside, join(outputDir, link)); + return { outputDir, outside }; + } + + posixOnly.each(["assets", "assets/svgs"])( + "refuses to write page-derived assets through a planted %s/ symlink", + async (link) => { + await withTempDir(async (root) => { + const { outputDir, outside } = plantedLink(root, link); + const svgs = [ + { + outerHTML: ``, + isLogo: false, + }, + ]; + + await expect( + downloadAssets({ svgs, sections: [], ogImage: "" } as unknown as DesignTokens, outputDir), + ).rejects.toThrow(/outside the capture directory/); + expect(readdirSync(outside)).toEqual([]); + }); + }, + ); + + posixOnly("refuses a dangling assets/ symlink before its svgs folder", async () => { + await withTempDir(async (root) => { + const outputDir = join(root, "capture"); + const target = join(root, "missing"); + mkdirSync(outputDir); + symlinkSync(target, join(outputDir, "assets")); + + await expect( + downloadAssets( + { svgs: [], sections: [], ogImage: "" } as unknown as DesignTokens, + outputDir, + ), + ).rejects.toThrow(CaptureDirRefusedError); + expect(existsSync(target)).toBe(false); + }); + }); + + posixOnly("refuses to create the fonts directory through a planted assets/ symlink", async () => { + await withTempDir(async (root) => { + const { outputDir, outside } = plantedLink(root, "assets"); + + await expect(downloadAndRewriteFonts("", outputDir)).rejects.toThrow( + /outside the capture directory/, + ); + expect(readdirSync(outside)).toEqual([]); + }); + }); +}); diff --git a/packages/cli/src/capture/assetDownloader.ts b/packages/cli/src/capture/assetDownloader.ts index c0d8d9bd5b..3dbf6188a1 100644 --- a/packages/cli/src/capture/assetDownloader.ts +++ b/packages/cli/src/capture/assetDownloader.ts @@ -6,8 +6,7 @@ */ import { isBlockedNetworkHost } from "@hyperframes/engine"; -import { mkdirSync } from "node:fs"; -import { writeCaptureFileSync } from "./captureFile.js"; +import { ensureCaptureDirSync, writeCaptureFileSync } from "./captureFile.js"; import { join, extname } from "node:path"; import { createHash } from "node:crypto"; import type { DesignTokens, DownloadedAsset } from "./types.js"; @@ -317,14 +316,14 @@ export async function downloadAssets( ): Promise<{ assets: DownloadedAsset[]; drops: AssetDropCounts; icons: IconManifest }> { options = { ...options, byteBudget: options.byteBudget ?? createCaptureDownloadBudget() }; const assetsDir = join(outputDir, "assets"); - mkdirSync(assetsDir, { recursive: true }); + ensureCaptureDirSync(outputDir, assetsDir); const assets: DownloadedAsset[] = []; const drops = noDrops(); const downloadedUrls = new Set(); let icons: IconManifest = emptyIconManifest(); - mkdirSync(join(outputDir, "assets", "svgs"), { recursive: true }); + ensureCaptureDirSync(outputDir, join(outputDir, "assets", "svgs")); const usedSvgNames = new Set(); const MAX_INLINE_SVGS = 30; drops["cap-reached"] += Math.max(0, tokens.svgs.length - MAX_INLINE_SVGS); @@ -542,7 +541,7 @@ export async function downloadAndRewriteFonts( ): Promise<{ css: string; drops: AssetDropCounts }> { options = { ...options, byteBudget: options.byteBudget ?? createCaptureDownloadBudget() }; const assetsDir = join(outputDir, "assets", "fonts"); - mkdirSync(assetsDir, { recursive: true }); + ensureCaptureDirSync(outputDir, assetsDir); const drops = noDrops(); const fontUrlRegex = /url\(['"]?(https?:\/\/[^'")\s]+\.(?:woff2?|ttf|otf)[^'")\s]*?)['"]?\)/g; diff --git a/packages/cli/src/capture/captureAttempt.test.ts b/packages/cli/src/capture/captureAttempt.test.ts new file mode 100644 index 0000000000..c78ca995bc --- /dev/null +++ b/packages/cli/src/capture/captureAttempt.test.ts @@ -0,0 +1,47 @@ +import { mkdirSync, mkdtempSync, readdirSync, rmSync, symlinkSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import { describe, expect, it, onTestFinished, vi } from "vitest"; +import { captureWebsiteAttempt } from "./captureAttempt.js"; +import { CaptureDirRefusedError } from "./captureErrors.js"; +import type { CaptureWatchdog } from "./captureWatchdog.js"; +import { createPartialCaptureState } from "./partialCapture.js"; + +const { ensureBrowserMock } = vi.hoisted(() => ({ + ensureBrowserMock: vi.fn(async () => { + throw new Error("the browser must not start"); + }), +})); +vi.mock("../browser/manager.js", () => ({ ensureBrowser: ensureBrowserMock })); + +const watchdog: CaptureWatchdog = { + expired: () => false, + promise: new Promise(() => {}), + registerBrowser: () => {}, + unregisterBrowser: () => {}, + dispose: () => {}, +}; + +describe("captureWebsiteAttempt output folders", () => { + // Creating symlinks needs elevated rights on Windows. + it.skipIf(process.platform === "win32").each(["extracted", "screenshots", "assets"])( + "refuses a planted %s/ symlink before the browser starts (#4304)", + async (link) => { + const root = mkdtempSync(join(tmpdir(), "hf-capture-attempt-")); + onTestFinished(() => rmSync(root, { recursive: true, force: true })); + const outputDir = join(root, "capture"); + const outside = join(root, "outside"); + mkdirSync(outputDir); + mkdirSync(outside); + symlinkSync(outside, join(outputDir, link)); + const opts = { url: "https://example.com", outputDir }; + + await expect( + captureWebsiteAttempt(opts, undefined, false, watchdog, createPartialCaptureState(opts)), + ).rejects.toThrow(CaptureDirRefusedError); + + expect(readdirSync(outside)).toEqual([]); + expect(ensureBrowserMock).not.toHaveBeenCalled(); + }, + ); +}); diff --git a/packages/cli/src/capture/captureAttempt.ts b/packages/cli/src/capture/captureAttempt.ts index 9c333c5d2f..9303d642cb 100644 --- a/packages/cli/src/capture/captureAttempt.ts +++ b/packages/cli/src/capture/captureAttempt.ts @@ -5,9 +5,10 @@ import { createCaptureDownloadBudget } from "./readBoundedResponse.js"; * - Rich animation metadata for Claude Code to recreate */ -import { mkdirSync, existsSync } from "node:fs"; +import { existsSync } from "node:fs"; import { join } from "node:path"; import { noDrops } from "./assetDownloader.js"; +import { ensureCaptureDirSync } from "./captureFile.js"; import type { IconCandidate } from "./faviconRanker.js"; import { CAPTURE_USER_AGENT } from "./userAgent.js"; import { setupAnimationCapture, startCdpAnimationCapture } from "./animationCataloger.js"; @@ -101,9 +102,9 @@ export async function captureWebsiteAttempt( loadEnvFile(outputDir); // Create output directories - mkdirSync(join(outputDir, "extracted"), { recursive: true }); - mkdirSync(join(outputDir, "screenshots"), { recursive: true }); - mkdirSync(join(outputDir, "assets"), { recursive: true }); + ensureCaptureDirSync(outputDir, join(outputDir, "extracted")); + ensureCaptureDirSync(outputDir, join(outputDir, "screenshots")); + ensureCaptureDirSync(outputDir, join(outputDir, "assets")); // Launch browser progress("browser", "Launching headless Chrome..."); diff --git a/packages/cli/src/capture/captureErrors.ts b/packages/cli/src/capture/captureErrors.ts index e8a051bc54..e3733d2a45 100644 --- a/packages/cli/src/capture/captureErrors.ts +++ b/packages/cli/src/capture/captureErrors.ts @@ -7,3 +7,10 @@ export class NavigationDeadlineError extends Error { this.name = "NavigationDeadlineError"; } } + +export class CaptureDirRefusedError extends Error { + constructor(message: string) { + super(message); + this.name = "CaptureDirRefusedError"; + } +} diff --git a/packages/cli/src/capture/captureFile.test.ts b/packages/cli/src/capture/captureFile.test.ts index fb83b61763..60b70cadb3 100644 --- a/packages/cli/src/capture/captureFile.test.ts +++ b/packages/cli/src/capture/captureFile.test.ts @@ -12,7 +12,7 @@ import { import { tmpdir } from "node:os"; import { join } from "node:path"; import { afterEach, describe, expect, it } from "vitest"; -import { writeCaptureFileSync } from "./captureFile.js"; +import { ensureCaptureDirSync, writeCaptureFileSync } from "./captureFile.js"; const temporaryDirectories: string[] = []; @@ -122,3 +122,76 @@ describe("writeCaptureFileSync", () => { expect(readdirSync(outputDir).sort()).toEqual(["a.txt", "occupied"]); }); }); + +describe("ensureCaptureDirSync", () => { + it("creates nested directories under the root, and accepts them again on a re-run", () => { + const { outputDir } = scratch(); + const fonts = join(outputDir, "assets", "fonts"); + + expect(ensureCaptureDirSync(outputDir, fonts)).toBe(fonts); + expect(ensureCaptureDirSync(outputDir, fonts)).toBe(fonts); + + expect(lstatSync(fonts).isDirectory()).toBe(true); + }); + + posixOnly("refuses a planted directory symlink and creates nothing in its target", () => { + const { outputDir } = scratch(); + const outside = join(outputDir, "..", "outside"); + mkdirSync(outside); + symlinkSync(outside, join(outputDir, "assets")); + + expect(() => ensureCaptureDirSync(outputDir, join(outputDir, "assets", "fonts"))).toThrow( + /outside the capture directory/, + ); + expect(readdirSync(outside)).toEqual([]); + }); + + posixOnly("refuses a directory symlink even when it points elsewhere inside the root", () => { + const { outputDir } = scratch(); + mkdirSync(join(outputDir, "extracted")); + symlinkSync(join(outputDir, "extracted"), join(outputDir, "assets")); + + expect(() => ensureCaptureDirSync(outputDir, join(outputDir, "assets"))).toThrow( + /outside the capture directory/, + ); + }); + + posixOnly("refuses a dangling or looping directory symlink with the same message", () => { + const { outputDir } = scratch(); + symlinkSync(join(outputDir, "..", "missing"), join(outputDir, "assets")); + symlinkSync(join(outputDir, "screenshots"), join(outputDir, "screenshots")); + + for (const name of ["assets", "screenshots"]) { + expect(() => ensureCaptureDirSync(outputDir, join(outputDir, name))).toThrow( + /outside the capture directory/, + ); + } + }); + + posixOnly("trusts a root that is itself a symlink, as /tmp is on macOS", () => { + const { outputDir } = scratch(); + const linkedRoot = join(outputDir, "..", "linked-capture"); + symlinkSync(outputDir, linkedRoot); + + ensureCaptureDirSync(linkedRoot, join(linkedRoot, "assets", "svgs")); + + expect(lstatSync(join(outputDir, "assets", "svgs")).isDirectory()).toBe(true); + }); + + it("refuses a file sitting where a directory belongs", () => { + const { outputDir } = scratch(); + writeFileSync(join(outputDir, "assets"), "not a directory"); + + expect(() => ensureCaptureDirSync(outputDir, join(outputDir, "assets"))).toThrow( + /not a directory/, + ); + }); + + it("refuses a directory that is not under the root", () => { + const { outputDir } = scratch(); + + expect(() => ensureCaptureDirSync(outputDir, join(outputDir, "..", "elsewhere"))).toThrow( + /outside the capture directory/, + ); + }); +}); diff --git a/packages/cli/src/capture/captureFile.ts b/packages/cli/src/capture/captureFile.ts index a1128d53ce..a483e107ef 100644 --- a/packages/cli/src/capture/captureFile.ts +++ b/packages/cli/src/capture/captureFile.ts @@ -1,5 +1,14 @@ -import { mkdtempSync, renameSync, rmSync, writeFileSync } from "node:fs"; -import { basename, dirname, join } from "node:path"; +import { + mkdirSync, + mkdtempSync, + realpathSync, + renameSync, + rmSync, + statSync, + writeFileSync, +} from "node:fs"; +import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path"; +import { CaptureDirRefusedError } from "./captureErrors.js"; type WriteOptions = Parameters[2]; @@ -40,3 +49,59 @@ export function writeCaptureFileSync( } writeFileSync(path, data, { ...normalized, mode: 0o600 }); } + +function hasCode(error: unknown, ...codes: string[]): boolean { + return ( + error instanceof Error && + "code" in error && + typeof error.code === "string" && + codes.includes(error.code) + ); +} + +// The JS `realpathSync`, deliberately not `realpathSync.native`: native returns the on-disk case +// on macOS/Windows, so an existing `Assets/` asked for as `assets` would be falsely refused. The +// JS walk only rewrites the components that are links, which is exactly what is being checked. +function resolvedPath(path: string): string | undefined { + try { + return realpathSync(path); + } catch (error) { + // A dangling or looping link resolves nowhere: refuse it like any other escaping link. + if (hasCode(error, "ENOENT", "ELOOP")) return undefined; + throw error; + } +} + +// Creates `dir` under the trusted capture root, refusing any directory whose real path leaves it (#4304). +// Checked on creation, not on every write: a link swapped in later by a racing process is out of scope. +export function ensureCaptureDirSync(root: string, dir: string): string { + const rootPath = resolve(root); + const target = resolve(dir); + const rel = relative(rootPath, target); + if (rel === ".." || rel.startsWith(`..${sep}`) || isAbsolute(rel)) { + throw new CaptureDirRefusedError( + `Refusing to create ${target}: it is outside the capture directory ${rootPath}`, + ); + } + mkdirSync(rootPath, { recursive: true }); + let current = rootPath; + let expected = realpathSync(rootPath); + for (const segment of rel.split(sep).filter(Boolean)) { + current = join(current, segment); + expected = join(expected, segment); + try { + mkdirSync(current); + } catch (error) { + if (!hasCode(error, "EEXIST")) throw error; + } + if (resolvedPath(current) !== expected) { + throw new CaptureDirRefusedError( + `Refusing to write into ${current}: it resolves outside the capture directory ${rootPath}`, + ); + } + if (!statSync(current).isDirectory()) { + throw new CaptureDirRefusedError(`Refusing to write into ${current}: it is not a directory`); + } + } + return target; +} diff --git a/packages/cli/src/capture/coreExtractionPhase.ts b/packages/cli/src/capture/coreExtractionPhase.ts index d64ef31014..717923ff33 100644 --- a/packages/cli/src/capture/coreExtractionPhase.ts +++ b/packages/cli/src/capture/coreExtractionPhase.ts @@ -9,8 +9,8 @@ import type { IconCandidate } from "./faviconRanker.js"; import { startCdpAnimationCapture } from "./animationCataloger.js"; import { createCaptureDownloadBudget } from "./readBoundedResponse.js"; import { detectLibraries } from "./contentExtractor.js"; -import { mkdirSync } from "node:fs"; import { writeCaptureFileSync } from "./captureFile.js"; +import { CaptureDirRefusedError } from "./captureErrors.js"; import { join } from "node:path"; import { extractHtml } from "./htmlExtractor.js"; import { extractTokens } from "./tokenExtractor.js"; @@ -176,9 +176,13 @@ export async function runCoreExtraction(input: CoreExtractionInput): Promise 0 && remainingMs() > 0) { const lottieDir = join(outputDir, "assets", "lottie"); if (!canWrite()) return; - mkdirSync(lottieDir, { recursive: true }); const lottieBudget = { remainingMs, byteBudget: downloadByteBudget }; - const savedCount = await saveLottieAnimations(discoveredLotties, lottieDir, lottieBudget); + const savedCount = await saveLottieAnimations( + discoveredLotties, + lottieDir, + outputDir, + lottieBudget, + ); // Generate manifest + preview thumbnails so the agent can SEE what each animation is if (savedCount > 0 && remainingMs() > 0 && canWrite()) { await renderLottiePreviews(chromeBrowser, lottieDir, outputDir, lottieBudget); @@ -348,8 +352,10 @@ export async function runCoreExtraction(input: CoreExtractionInput): Promise { const saved = await saveLottieAnimations( [{ url: "https://one.example/a.json" }, { url: "https://two.example/b.json" }], dir, + dir, { remainingMs: () => remainingMs }, ); @@ -207,7 +209,9 @@ describe("Lottie capture rejects unsafe persistence", () => { "fetch", vi.fn(async () => new Response("not a zip")), ); - expect(await saveLottieAnimations([{ url: "https://public.example/bad.lottie" }], dir)).toBe(0); + expect( + await saveLottieAnimations([{ url: "https://public.example/bad.lottie" }], dir, dir), + ).toBe(0); expect(readdirSync(dir)).toEqual([]); }); it("does not publish truthy non-array layers", async () => { @@ -216,7 +220,9 @@ describe("Lottie capture rejects unsafe persistence", () => { "fetch", vi.fn(async () => new Response('{"w":100,"h":100,"layers":true}')), ); - expect(await saveLottieAnimations([{ url: "https://public.example/bad.json" }], dir)).toBe(0); + expect(await saveLottieAnimations([{ url: "https://public.example/bad.json" }], dir, dir)).toBe( + 0, + ); expect(readdirSync(dir)).toEqual([]); }); }); @@ -299,3 +305,90 @@ describe("media previews replace pre-planted links", () => { }, ); }); + +describe("media folders refuse a planted directory link (#4304)", () => { + // captureVideoManifest keeps any http(s) video it finds; only the URL matters here. + const descriptor = { src: "https://video.example/planted.mp4", filename: "planted.mp4" }; + + function plantedCapture(link: string): { dir: string; outside: string } { + const dir = tempDir(); + const outside = join(dir, "outside"); + mkdirSync(outside); + mkdirSync(join(dir, "extracted")); + mkdirSync(join(dir, link, ".."), { recursive: true }); + symlinkSync(outside, join(dir, link)); + return { dir, outside }; + } + + // Creating symlinks needs elevated rights on Windows. + it.skipIf(process.platform === "win32").each(["assets/videos", "assets/videos/previews"])( + "does not write the video manifest through a planted %s link", + async (link) => { + const { dir, outside } = plantedCapture(link); + const screenshot = vi.fn(); + const page = { evaluate: vi.fn(async () => [descriptor]), screenshot } as unknown as Page; + vi.stubGlobal( + "fetch", + vi.fn(async () => new Response(null, { status: 404 })), + ); + + await expect(captureVideoManifest(page, dir, () => {})).rejects.toThrow( + CaptureDirRefusedError, + ); + expect(readdirSync(outside)).toEqual([]); + expect(screenshot).not.toHaveBeenCalled(); + }, + ); + + it.skipIf(process.platform === "win32")( + "refuses a dangling assets/videos link before its previews folder", + async () => { + const dir = tempDir(); + const target = join(dir, "missing"); + mkdirSync(join(dir, "assets"), { recursive: true }); + symlinkSync(target, join(dir, "assets", "videos")); + const page = { + evaluate: vi.fn(async () => [descriptor]), + screenshot: vi.fn(), + } as unknown as Page; + + await expect(captureVideoManifest(page, dir, () => {})).rejects.toThrow( + CaptureDirRefusedError, + ); + expect(existsSync(target)).toBe(false); + }, + ); + + it.skipIf(process.platform === "win32")( + "does not save Lottie files through a planted assets/lottie link", + async () => { + const { dir, outside } = plantedCapture("assets/lottie"); + const fetchMock = vi.fn(); + vi.stubGlobal("fetch", fetchMock); + + await expect( + saveLottieAnimations( + [{ url: "https://public.example/a.json" }], + join(dir, "assets", "lottie"), + dir, + ), + ).rejects.toThrow(CaptureDirRefusedError); + expect(readdirSync(outside)).toEqual([]); + expect(fetchMock).not.toHaveBeenCalled(); + }, + ); + + it.skipIf(process.platform === "win32")( + "does not render Lottie previews through a planted previews link", + async () => { + const { dir, outside } = plantedCapture("assets/lottie/previews"); + const browser = { newPage: vi.fn() } as unknown as Browser; + + await expect( + renderLottiePreviews(browser, join(dir, "assets", "lottie"), dir), + ).rejects.toThrow(CaptureDirRefusedError); + expect(readdirSync(outside)).toEqual([]); + expect(browser.newPage).not.toHaveBeenCalled(); + }, + ); +}); diff --git a/packages/cli/src/capture/mediaCapture.ts b/packages/cli/src/capture/mediaCapture.ts index bf178b86df..4005962cb5 100644 --- a/packages/cli/src/capture/mediaCapture.ts +++ b/packages/cli/src/capture/mediaCapture.ts @@ -8,8 +8,8 @@ */ import type { Browser, Page } from "puppeteer-core"; -import { mkdirSync, readdirSync, readFileSync, statSync } from "node:fs"; -import { writeCaptureFileSync } from "./captureFile.js"; +import { readdirSync, readFileSync, statSync } from "node:fs"; +import { ensureCaptureDirSync, writeCaptureFileSync } from "./captureFile.js"; import { join, extname } from "node:path"; import { isPrivateUrl, safeFetch } from "./assetDownloader.js"; import { CAPTURE_USER_AGENT } from "./userAgent.js"; @@ -50,8 +50,10 @@ function liveRemainingMs(budget: RemainingBudget, fallbackMs: number): number { export async function saveLottieAnimations( discoveredLotties: DiscoveredLottie[], lottieDir: string, + outputDir: string, budget: RemainingBudget = {}, ): Promise { + ensureCaptureDirSync(outputDir, lottieDir); const byteBudget = budget.byteBudget ?? createCaptureDownloadBudget(); let savedCount = 0; const savedHashes = new Set(); // Deduplicate by content @@ -130,7 +132,7 @@ export async function renderLottiePreviews( layers: number; }> = []; const previewDir = join(lottieDir, "previews"); - mkdirSync(previewDir, { recursive: true }); + ensureCaptureDirSync(outputDir, previewDir); for (const file of readdirSync(lottieDir)) { if (!file.endsWith(".json")) continue; @@ -470,9 +472,9 @@ export async function captureVideoManifest( if (merged.length === 0) return; const videoManifestDir = join(outputDir, "assets", "videos"); - mkdirSync(videoManifestDir, { recursive: true }); + ensureCaptureDirSync(outputDir, videoManifestDir); const previewDir = join(videoManifestDir, "previews"); - mkdirSync(previewDir, { recursive: true }); + ensureCaptureDirSync(outputDir, previewDir); const videoManifest: Array<{ index: number; diff --git a/packages/cli/src/capture/partialCapture.test.ts b/packages/cli/src/capture/partialCapture.test.ts index 17392b228f..d23ea384fd 100644 --- a/packages/cli/src/capture/partialCapture.test.ts +++ b/packages/cli/src/capture/partialCapture.test.ts @@ -1,4 +1,12 @@ -import { existsSync, mkdtempSync, readFileSync, rmSync } from "node:fs"; +import { + existsSync, + mkdirSync, + mkdtempSync, + readFileSync, + readdirSync, + rmSync, + symlinkSync, +} from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; import { afterEach, describe, expect, it } from "vitest"; @@ -45,4 +53,30 @@ describe("writePartialCaptureBundle", () => { partial: true, }); }); + + // Creating symlinks needs elevated rights on Windows. + it.skipIf(process.platform === "win32")( + "refuses to write through a planted extracted/ symlink (#4304)", + () => { + const root = mkdtempSync(join(tmpdir(), "hyperframes-partial-capture-")); + temporaryDirectories.push(root); + const outputDir = join(root, "capture"); + const outside = join(root, "outside"); + mkdirSync(outputDir); + mkdirSync(outside); + symlinkSync(outside, join(outputDir, "extracted")); + const opts = { url: "https://example.com", outputDir }; + + expect(() => + writePartialCaptureBundle(opts, createPartialCaptureState(opts), { + schema: CAPTURE_PHASE_SCHEMA, + phase: "complete", + status: "degraded", + remainingMs: null, + reason: "deadline", + }), + ).toThrow(/outside the capture directory/); + expect(readdirSync(outside)).toEqual([]); + }, + ); }); diff --git a/packages/cli/src/capture/partialCapture.ts b/packages/cli/src/capture/partialCapture.ts index 08156e610a..63239d5abc 100644 --- a/packages/cli/src/capture/partialCapture.ts +++ b/packages/cli/src/capture/partialCapture.ts @@ -1,5 +1,4 @@ -import { mkdirSync } from "node:fs"; -import { writeCaptureFileSync } from "./captureFile.js"; +import { ensureCaptureDirSync, writeCaptureFileSync } from "./captureFile.js"; import { join } from "node:path"; import { noDrops } from "./assetDownloader.js"; import type { @@ -74,9 +73,7 @@ export function writePartialCaptureBundle( lastPhase: CaptureResult["lastPhase"], ): CaptureResult { const hostname = new URL(opts.url).hostname.replace(/^www\./, ""); - mkdirSync(opts.outputDir, { recursive: true }); - const extractedDir = join(opts.outputDir, "extracted"); - mkdirSync(extractedDir, { recursive: true }); + const extractedDir = ensureCaptureDirSync(opts.outputDir, join(opts.outputDir, "extracted")); writeCaptureFileSync(join(extractedDir, "tokens.json"), serializeTokensForCapture(state.tokens)); writeCaptureFileSync( join(extractedDir, "design-styles.json"), diff --git a/packages/cli/src/capture/postExtractionPhase.test.ts b/packages/cli/src/capture/postExtractionPhase.test.ts new file mode 100644 index 0000000000..454ebe1dac --- /dev/null +++ b/packages/cli/src/capture/postExtractionPhase.test.ts @@ -0,0 +1,58 @@ +import { mkdirSync, mkdtempSync, readdirSync, rmSync, symlinkSync, writeFileSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import { describe, expect, it, onTestFinished } from "vitest"; +import { noDrops } from "./assetDownloader.js"; +import { createPartialCaptureState } from "./partialCapture.js"; +import { runPostExtraction } from "./postExtractionPhase.js"; +import { createCaptureDownloadBudget } from "./readBoundedResponse.js"; + +const PLANTED_SVG = ``; + +describe("runPostExtraction", () => { + // Creating symlinks needs elevated rights on Windows. + it.skipIf(process.platform === "win32")( + "does not write the SVG contact sheet through a planted assets/svgs symlink under --skip-assets (#4304)", + async () => { + const root = mkdtempSync(join(tmpdir(), "hyperframes-post-extraction-")); + onTestFinished(() => rmSync(root, { recursive: true, force: true })); + const outputDir = join(root, "capture"); + const outside = join(root, "outside"); + for (const dir of ["extracted", "screenshots", "assets"]) { + mkdirSync(join(outputDir, dir), { recursive: true }); + } + mkdirSync(outside); + writeFileSync(join(outside, "planted.svg"), PLANTED_SVG); + symlinkSync(outside, join(outputDir, "assets", "svgs")); + + const state = createPartialCaptureState({ url: "https://example.com", outputDir }); + const warnings: string[] = []; + await runPostExtraction({ + state, + outputDir, + warnings, + progress: () => {}, + remainingMs: () => 60_000, + phase: () => {}, + animationCatalog: undefined, + catalogedAssets: [], + visibleTextContent: "", + faviconLinks: [], + tokens: state.tokens, + extracted: state.extracted, + skipAssets: true, + skipVision: true, + downloadByteBudget: createCaptureDownloadBudget(), + assets: [], + dropped: noDrops(), + fontDrops: noDrops(), + canWrite: () => true, + }); + + expect(readdirSync(outside)).toEqual(["planted.svg"]); + expect(warnings).toEqual([ + expect.stringMatching(/^SVG contact sheet skipped: Refusing to write/), + ]); + }, + ); +}); diff --git a/packages/cli/src/capture/postExtractionPhase.ts b/packages/cli/src/capture/postExtractionPhase.ts index 1163e1f18d..8733462c53 100644 --- a/packages/cli/src/capture/postExtractionPhase.ts +++ b/packages/cli/src/capture/postExtractionPhase.ts @@ -1,5 +1,6 @@ import { existsSync } from "node:fs"; -import { writeCaptureFileSync } from "./captureFile.js"; +import { ensureCaptureDirSync, writeCaptureFileSync } from "./captureFile.js"; +import { CaptureDirRefusedError } from "./captureErrors.js"; import { join } from "node:path"; import { downloadAssets, @@ -404,7 +405,9 @@ export async function runPostExtraction(input: PostExtractionInput): Promise { + // Creating symlinks needs elevated rights on Windows. + it.skipIf(process.platform === "win32")( + "refuses a planted screenshots/ symlink before touching the page", + async () => { + const dir = tempDir("hf-scroll-planted-"); + const outside = join(dir, "outside"); + mkdirSync(outside); + symlinkSync(outside, join(dir, "screenshots")); + const { page, evaluate, screenshot } = fakePage(); + + await expect(captureScrollScreenshots(page, dir)).rejects.toThrow(CaptureDirRefusedError); + + expect(readdirSync(outside)).toEqual([]); + expect(evaluate).not.toHaveBeenCalled(); + expect(screenshot).not.toHaveBeenCalled(); + }, + ); +}); diff --git a/packages/cli/src/capture/screenshotCapture.ts b/packages/cli/src/capture/screenshotCapture.ts index 57b36c00f1..bdde074316 100644 --- a/packages/cli/src/capture/screenshotCapture.ts +++ b/packages/cli/src/capture/screenshotCapture.ts @@ -7,9 +7,8 @@ import type { Page } from "puppeteer-core"; import { isDegradableEvaluateTimeoutError } from "./captureTimeout.js"; -import { mkdirSync } from "node:fs"; import { join } from "node:path"; -import { writeCaptureFileSync } from "./captureFile.js"; +import { ensureCaptureDirSync, writeCaptureFileSync } from "./captureFile.js"; /** * Capture viewport screenshots covering the entire page height. @@ -118,7 +117,7 @@ export async function captureScrollScreenshots( budget: { remainingMs?: () => number } = {}, ): Promise { const screenshotsDir = join(outputDir, "screenshots"); - mkdirSync(screenshotsDir, { recursive: true }); + ensureCaptureDirSync(outputDir, screenshotsDir); const MAX_SCREENSHOTS = 20; const filePaths: string[] = []; diff --git a/packages/cli/src/commands/capture/video.test.ts b/packages/cli/src/commands/capture/video.test.ts index 4cfc0f50f5..a3f7c15444 100644 --- a/packages/cli/src/commands/capture/video.test.ts +++ b/packages/cli/src/commands/capture/video.test.ts @@ -1,9 +1,14 @@ -import { describe, expect, it } from "vitest"; +import { existsSync, mkdirSync, mkdtempSync, rmSync, symlinkSync, writeFileSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import { describe, expect, it, onTestFinished, vi } from "vitest"; +import { consumeCommandResult } from "../../utils/commandResult.js"; import { MAX_VIDEO_BYTES, VIDEO_CONTENT_TYPE_RE, findFilenameCollision, pickManifestEntry, + runVideoMode, safeFilename, type ManifestEntry, } from "./video.js"; @@ -160,3 +165,44 @@ describe("findFilenameCollision", () => { expect(collisions.every((c) => c.index !== 0)).toBe(true); }); }); + +describe("runVideoMode", () => { + // Creating symlinks needs elevated rights on Windows. + it.skipIf(process.platform === "win32").each([ + { layout: "capture output", manifestDir: "extracted", planted: "assets" }, + { layout: "W2H project", manifestDir: "capture/extracted", planted: "capture" }, + ])( + "refuses to download through a planted $planted symlink in a $layout (#4304)", + async ({ manifestDir, planted }) => { + const root = mkdtempSync(join(tmpdir(), "hf-video-mode-")); + onTestFinished(() => rmSync(root, { recursive: true, force: true })); + const projectDir = join(root, "project"); + const outside = join(root, "outside"); + mkdirSync(projectDir); + mkdirSync(outside); + symlinkSync(outside, join(projectDir, planted)); + mkdirSync(join(projectDir, manifestDir), { recursive: true }); + writeFileSync( + join(projectDir, manifestDir, "video-manifest.json"), + JSON.stringify([ENTRY(0)]), + ); + const fetchMock = vi.fn(async () => { + throw new Error("no network in tests"); + }); + vi.stubGlobal("fetch", fetchMock); + vi.spyOn(console, "log").mockImplementation(() => {}); + const error = vi.spyOn(console, "error").mockImplementation(() => {}); + onTestFinished(() => { + vi.unstubAllGlobals(); + vi.restoreAllMocks(); + }); + + await runVideoMode({ project: projectDir, index: "0" }); + + expect(consumeCommandResult().exitCode).toBe(1); + expect(String(error.mock.calls[0]?.[0])).toContain("resolves outside the capture directory"); + expect(fetchMock).not.toHaveBeenCalled(); + expect(existsSync(join(outside, planted === "assets" ? "videos" : "assets"))).toBe(false); + }, + ); +}); diff --git a/packages/cli/src/commands/capture/video.ts b/packages/cli/src/commands/capture/video.ts index a62d0f27a7..ebb0dcf9c9 100644 --- a/packages/cli/src/commands/capture/video.ts +++ b/packages/cli/src/commands/capture/video.ts @@ -1,8 +1,9 @@ import { setCommandExitCode } from "../../utils/commandResult.js"; -import { createWriteStream, existsSync, mkdirSync, readFileSync, unlinkSync } from "node:fs"; +import { createWriteStream, existsSync, readFileSync, unlinkSync } from "node:fs"; import { resolve, join, basename } from "node:path"; import { c } from "../../ui/colors.js"; import { safeFetch } from "../../capture/assetDownloader.js"; +import { ensureCaptureDirSync } from "../../capture/captureFile.js"; import { CAPTURE_USER_AGENT } from "../../capture/userAgent.js"; const MAX_VIDEO_BYTES = 250 * 1024 * 1024; @@ -254,7 +255,13 @@ export async function runVideoMode(args: VideoModeArgs): Promise { const outDir = isW2hLayout ? join(projectDir, "capture", "assets", "videos") : join(projectDir, "assets", "videos"); - mkdirSync(outDir, { recursive: true }); + try { + ensureCaptureDirSync(projectDir, outDir); + } catch (e) { + console.error(`${c.error("✗")} ${(e as Error).message}`); + setCommandExitCode(1); + return; + } const fname = safeFilename(entry.filename || basename(entry.url)); const outPath = join(outDir, fname); const relPath = isW2hLayout ? `capture/assets/videos/${fname}` : `assets/videos/${fname}`; From ecfcbb0c61420ee67f8febf0e17e4d6c4f507c9b Mon Sep 17 00:00:00 2001 From: "heygengenesis[bot]" <262951085+heygengenesis[bot]@users.noreply.github.com> Date: Fri, 2 Oct 2026 05:56:34 -0700 Subject: [PATCH 16/58] docs: clarify skills installer behavior (#3863) * docs: clarify internal skill installation behavior Co-authored-by: miguel.sierra <229591595+miguel-heygen@users.noreply.github.com> * docs: clarify --all checkout safety --------- Co-authored-by: heygengenesis[bot] <262951085+heygengenesis[bot]@users.noreply.github.com> --- .agents/skills/README.md | 10 ++++++---- .claude/skills/README.md | 12 ++++++++---- CLAUDE.md | 7 +++++-- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/.agents/skills/README.md b/.agents/skills/README.md index 2effc3c4de..dbf7a8459a 100644 --- a/.agents/skills/README.md +++ b/.agents/skills/README.md @@ -49,7 +49,9 @@ Claude Code users get the same auto-discover behaviour — keep the two in sync when editing. A `scripts/check-skill-mirror.mjs` check enforces this at CI time. -Each repo-native skill declares `metadata.internal: true`, so `npx skills add` -skips it during normal installs (including `--all`). This does not change local -agent discovery. To explicitly install these skills elsewhere, set -`INSTALL_INTERNAL_SKILLS=1` when running the installer. +Each repo-native skill declares `metadata.internal: true`. That excludes it from +normal `npx skills add` discovery and from `npx skills add ... --all`. A named +`npx skills add ... --skill ` still installs a matching skill regardless of +`metadata.internal`; no environment variable is needed. `INSTALL_INTERNAL_SKILLS=1` +opts internal skills into normal discovery and bulk installation. This does not +change local agent discovery. diff --git a/.claude/skills/README.md b/.claude/skills/README.md index 435cec5bb6..08e55f384b 100644 --- a/.claude/skills/README.md +++ b/.claude/skills/README.md @@ -11,6 +11,8 @@ manifested by `.claude-plugin/`). Two separate namespaces, on purpose: - `skills/` — **marketplace-distributable**, installed into other projects via `npx hyperframes skills` or `npx skills add heygen-com/hyperframes`. +> **Warning:** Never run `npx skills add ... --all` from inside a HyperFrames checkout: it selects the OpenClaw target, whose `skills/` directory is the repo's own `skills/`, and removes each existing `skills/` destination before linking. A fresh clone restores tracked source, but uncommitted work under `skills/` does not recover. Run it from an empty directory or from your own project root. This happens regardless of `metadata.internal`. + ## Weekly changelog video The `changelog-video` skill turns a weekly changelog markdown into a @@ -47,7 +49,9 @@ CLI users get the same auto-discover behaviour — keep the two in sync when editing. A `scripts/check-skill-mirror.mjs` check enforces this at CI time. -Each repo-native skill declares `metadata.internal: true`, so `npx skills add` -skips it during normal installs (including `--all`). This does not change local -agent discovery. To explicitly install these skills elsewhere, set -`INSTALL_INTERNAL_SKILLS=1` when running the installer. +Each repo-native skill declares `metadata.internal: true`. That excludes it from +normal `npx skills add` discovery and from `npx skills add ... --all`. A named +`npx skills add ... --skill ` still installs a matching skill regardless of +`metadata.internal`; no environment variable is needed. `INSTALL_INTERNAL_SKILLS=1` +opts internal skills into normal discovery and bulk installation. This does not +change local agent discovery. diff --git a/CLAUDE.md b/CLAUDE.md index 64c77db284..a7c5ef381a 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -9,10 +9,13 @@ This repo ships 21 AI agent skills via [vercel-labs/skills](https://github.com/v ```bash npx hyperframes skills update # default: installs/refreshes the core set — workflows install on demand npx hyperframes skills # all 21 published skills at once — only on explicit request -npx skills add heygen-com/hyperframes # interactive picker (terminal only; --all also pulls the 6 repo-internal skills under .claude/skills) -npx skills add heygen-com/hyperframes --skill # just one (bare name, no leading slash) +npx skills add heygen-com/hyperframes # interactive picker; internal skills require INSTALL_INTERNAL_SKILLS=1 for discovery +npx skills add heygen-com/hyperframes --all # excludes internal skills unless INSTALL_INTERNAL_SKILLS=1 +npx skills add heygen-com/hyperframes --skill # a named match installs regardless of metadata.internal (bare name, no leading slash) ``` +> **Warning:** Never run `npx skills add ... --all` from inside a HyperFrames checkout: it selects the OpenClaw target, whose `skills/` directory is the repo's own `skills/`, and removes each existing `skills/` destination before linking. A fresh clone restores tracked source, but uncommitted work under `skills/` does not recover. Run it from an empty directory or from your own project root. This happens regardless of `metadata.internal`. + `skills add` resolves the skills.sh registry blob, which can lag `main` by hours, so a freshly added skill may be a little behind. `npx hyperframes skills update` installs from the current `main`; prefer it when freshness matters. **`/hyperframes` is the entry skill — read it first.** It's the capability map for the domain skills below, the intent layer that confirms every creation brief up front, AND the intent router for the creation workflows. The full README skills section mirrors this list; keep them in sync (see "Skill catalog maintenance" below). From 6f799aaa41d5874222aece2f4b78b759dfb1c913 Mon Sep 17 00:00:00 2001 From: jbernard077 Date: Fri, 2 Oct 2026 08:59:04 -0400 Subject: [PATCH 17/58] docs: align infinite-repeat guidance with bounded repeat: -1 lint (#3795) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since v0.7.71 (#2763), gsap_infinite_repeat demotes to a warning when the root declares a finite data-duration: deterministic seeking and export clip to that explicit window. Without one it remains a hard error (unbounded timeline duration breaks render planning). Update every doc site that still teaches the old absolute ban — the core determinism contract, the animation adapter notes, and the design-guide tables/checklists — to state the bounded allowance and keep the finite-count formula for loops that must end before the composition does. skills/hyperframes-animation/rules/ambient-glow-bloom.md is intentionally untouched: its shimmer must stop before the composition ends, which is exactly the case where a computed finite count is still required. Co-authored-by: Miguel Ángel --- docs/guides/claude-design-hyperframes.md | 4 ++-- docs/guides/claude-design-send-to-hyperframes.md | 4 ++-- skills-manifest.json | 12 ++++++------ skills/embedded-captions/modes/standard/_anatomy.md | 4 ++-- skills/figma/SKILL.md | 2 +- skills/hyperframes-animation/SKILL.md | 2 +- .../adapters/gsap-timeline-and-labels.md | 2 +- skills/hyperframes-animation/adapters/gsap.md | 2 +- skills/hyperframes-animation/rules-index.md | 2 +- skills/hyperframes-core/SKILL.md | 2 +- .../hyperframes-core/references/determinism-rules.md | 2 +- .../references/limitations.md | 2 +- skills/talking-head-recut/SKILL.md | 2 +- 13 files changed, 21 insertions(+), 21 deletions(-) diff --git a/docs/guides/claude-design-hyperframes.md b/docs/guides/claude-design-hyperframes.md index b16df8953e..d385055488 100644 --- a/docs/guides/claude-design-hyperframes.md +++ b/docs/guides/claude-design-hyperframes.md @@ -374,7 +374,7 @@ The skeleton handles most structural rules. These are the runtime rules the skel | `Math.random()` | Seeded PRNG (only if you need randomness) | | `Date.now()`, `performance.now()` | Hard-coded timing or `tl.time()` in `onUpdate` | | `setInterval`, `setTimeout` | Timeline tweens + `onUpdate` | -| `repeat: -1` | `repeat: Math.max(0, Math.floor(duration / cycle) - 1)` | +| `repeat: -1` without root `data-duration` | a finite root `data-duration` (export clips to it), or `repeat: Math.max(0, Math.floor(duration / cycle) - 1)` | | `stagger: { from: "random" }` | `from: "start"`, `"center"`, `"end"` | | Async timeline construction | Synchronous at page load | @@ -416,7 +416,7 @@ Run before delivering. Check with actual code, not assumptions. - [ ] Shader transitions have boundary INSIDE the window: `time < boundary < time + duration` - [ ] No transition shorter than 0.3s - [ ] No exit tweens except on the final scene -- [ ] No `Date.now()`, unseeded `Math.random()`, `repeat: -1` +- [ ] No `Date.now()`, unseeded `Math.random()`, or `repeat: -1` without a finite root `data-duration` - [ ] No SVG filter data URLs as `background-image` - [ ] `window.__timelines["main"] = tl` matches `data-composition-id` diff --git a/docs/guides/claude-design-send-to-hyperframes.md b/docs/guides/claude-design-send-to-hyperframes.md index bfb3aa8077..17c4a8defc 100644 --- a/docs/guides/claude-design-send-to-hyperframes.md +++ b/docs/guides/claude-design-send-to-hyperframes.md @@ -371,7 +371,7 @@ The cloud renderer seeks the timeline frame-by-frame. Non-deterministic or self- | `Date.now()`, `performance.now()` | hard-coded timing or `tl.time()` in `onUpdate` | | `setInterval`, `setTimeout` | timeline tweens + `onUpdate` | | `requestAnimationFrame` | GSAP tweens | -| `repeat: -1` | `repeat: Math.max(0, Math.floor(duration / cycle) - 1)` | +| `repeat: -1` without root `data-duration` | a finite root `data-duration` (export clips to it), or `repeat: Math.max(0, Math.floor(duration / cycle) - 1)` | | `stagger: { from: "random" }` | `from: "start"`, `"center"`, or `"end"` | | async timeline construction | build synchronously at page load | | `video.play()` / `audio.play()` | the framework owns playback | @@ -429,6 +429,6 @@ You don't author any of this. Produce a clean, on-brand, correctly-timed silent - [ ] No exit tweens except on the final scene **Renders correctly:** -- [ ] No `Date.now()`, unseeded `Math.random()`, `setInterval/Timeout`, `requestAnimationFrame`, `repeat: -1` +- [ ] No `Date.now()`, unseeded `Math.random()`, `setInterval/Timeout`, `requestAnimationFrame`, or `repeat: -1` without a finite root `data-duration` - [ ] Timeline built synchronously; paused; framework owns playback - [ ] Colors and fonts exact; brand substance preserved: real headline/copy, distinctive figures/stats/data points, product names, and signature visuals carried over verbatim (form adapted, never genericized or invented); no placeholders; ≥2 animation patterns + mid-scene activity per scene diff --git a/skills-manifest.json b/skills-manifest.json index 83d6b79b6c..8f68b27feb 100644 --- a/skills-manifest.json +++ b/skills-manifest.json @@ -2,7 +2,7 @@ "source": "heygen-com/hyperframes", "skills": { "embedded-captions": { - "hash": "9ae9e4e06bf4b61e", + "hash": "ebef42b483d02ab6", "files": 144 }, "faceless-explainer": { @@ -10,7 +10,7 @@ "files": 27 }, "figma": { - "hash": "1639b96642ac26c6", + "hash": "ade0258f3cb1f378", "files": 2 }, "general-video": { @@ -22,7 +22,7 @@ "files": 29 }, "hyperframes-animation": { - "hash": "2a567656b9291f5a", + "hash": "8c183924c57c2801", "files": 122 }, "hyperframes-audio": { @@ -34,7 +34,7 @@ "files": 11 }, "hyperframes-core": { - "hash": "96756e9138ed43d9", + "hash": "010a65915fc7b45e", "files": 11 }, "hyperframes-creative": { @@ -74,7 +74,7 @@ "files": 34 }, "remotion-to-hyperframes": { - "hash": "e13e3681d9b0dd75", + "hash": "833bb7855cd99d4f", "files": 77 }, "slideshow": { @@ -82,7 +82,7 @@ "files": 2 }, "talking-head-recut": { - "hash": "865d98665f0011da", + "hash": "c9b7ab6112feb4e3", "files": 28 } } diff --git a/skills/embedded-captions/modes/standard/_anatomy.md b/skills/embedded-captions/modes/standard/_anatomy.md index 0eb3fa0232..74a0e9a207 100644 --- a/skills/embedded-captions/modes/standard/_anatomy.md +++ b/skills/embedded-captions/modes/standard/_anatomy.md @@ -17,7 +17,7 @@ HyperFrames-native, so anyone can reproduce it: - **One paused GSAP timeline per composition**, registered to `window.__timelines[data-composition-id]`. - All timing in **seconds**; `data-start` / `data-duration` carry the scene window. -- **Deterministic + seek-safe** only — no `Math.random()`, no `Date.now()`, no infinite repeats, no un-seekable CSS animations. Every state is reachable by seeking the timeline to a time `t`. +- **Deterministic + seek-safe** only — no `Math.random()`, no `Date.now()`, no `repeat: -1` without a finite root `data-duration`, no un-seekable CSS animations. Every state is reachable by seeking the timeline to a time `t`. - GSAP transform aliases (`x`, `y`, `scale`, `rotation`); animate `opacity`, `filter`, `clipPath`, `textShadow`, `backgroundPosition`, `letterSpacing` — never layout props (width/top/left/margin). For the composition contract see `hyperframes-core`; eases + the animated-property allowlist see `hyperframes-gsap`; caption grouping/positioning/exit guarantees see `hyperframes-captions`. @@ -218,7 +218,7 @@ The gallery used a `setInterval` loop; HyperFrames needs the same beats as **abs - Timeline **paused**; registry key = `data-composition-id`. - **No CSS keyframe animation** on caption elements — all motion is GSAP tweens at absolute times (seek-safe). -- No `Math.random` / `Date.now` / infinite repeats. +- No `Math.random` / `Date.now` / `repeat: -1` without a finite root `data-duration`. - `display:inline-block` on every `.w` and the climax `span`. - **Hard-hide** each flow group at its end time; **CLIMAX_OUT ends at `opacity:0`** (or fully-clipped) so nothing lingers. - Gradient / `background-clip:text` / stroke fills go on `.climax span`, not the transformed `.climax`. diff --git a/skills/figma/SKILL.md b/skills/figma/SKILL.md index 9381ca33d4..cda8aec4db 100644 --- a/skills/figma/SKILL.md +++ b/skills/figma/SKILL.md @@ -131,4 +131,4 @@ Storyboard files follow a grammar you can parse mechanically — don't eyeball, ## Determinism -Never leave a Figma URL in the composition — freeze first. Never emit `repeat: -1`. Timelines paused, finite, literal `window.__timelines` keys. All Figma I/O at import time; render sees local files only. +Never leave a Figma URL in the composition — freeze first. Never emit `repeat: -1` without a finite root `data-duration`. Timelines paused, finite, literal `window.__timelines` keys. All Figma I/O at import time; render sees local files only. diff --git a/skills/hyperframes-animation/SKILL.md b/skills/hyperframes-animation/SKILL.md index 23ae488791..9cd8938f66 100644 --- a/skills/hyperframes-animation/SKILL.md +++ b/skills/hyperframes-animation/SKILL.md @@ -63,7 +63,7 @@ Multiple runtimes can coexist in one composition. Each registers its instances o ## Critical Constraints -**Prerequisite: `hyperframes-core` → Non-Negotiable Rules** (single paused timeline, `data-duration` governs length, no `Math.random` / `Date.now` / `performance.now`, no `repeat: -1`, no page-load `gsap.set` on later-scene clips, no `display` or raw `visibility` tweens, and no timeline construction inside `async` / `setTimeout` / `Promise`). GSAP `autoAlpha` and zero-duration visibility sets at explicit timeline boundaries remain allowed by core. Use those exceptions only on non-clip elements or wrappers inside a clip; the framework owns `.clip` lifecycle. Don't restate the full contract here. +**Prerequisite: `hyperframes-core` → Non-Negotiable Rules** (single paused timeline, `data-duration` governs length, no `Math.random` / `Date.now` / `performance.now`, no `repeat: -1` without a finite root `data-duration`, no page-load `gsap.set` on later-scene clips, no `display` or raw `visibility` tweens, and no timeline construction inside `async` / `setTimeout` / `Promise`). GSAP `autoAlpha` and zero-duration visibility sets at explicit timeline boundaries remain allowed by core. Use those exceptions only on non-clip elements or wrappers inside a clip; the framework owns `.clip` lifecycle. Don't restate the full contract here. Animation-craft additions on top of core's contract: diff --git a/skills/hyperframes-animation/adapters/gsap-timeline-and-labels.md b/skills/hyperframes-animation/adapters/gsap-timeline-and-labels.md index 98256c8560..504b9256a1 100644 --- a/skills/hyperframes-animation/adapters/gsap-timeline-and-labels.md +++ b/skills/hyperframes-animation/adapters/gsap-timeline-and-labels.md @@ -16,7 +16,7 @@ tl.to(".a", { x: 100 }).to(".b", { y: 50 }).to(".c", { opacity: 0 }); Timeline options: - **paused: true** — required in HyperFrames. The framework drives the playhead. -- **repeat**, **yoyo** — apply to the whole timeline. `repeat: -1` is forbidden; use finite counts. +- **repeat**, **yoyo** — apply to the whole timeline. `repeat: -1` requires a finite root `data-duration` (export clips to it); otherwise use finite counts. - **defaults** — vars merged into every child tween. Use this instead of repeating `ease` and `duration` on every line. ## Position Parameter diff --git a/skills/hyperframes-animation/adapters/gsap.md b/skills/hyperframes-animation/adapters/gsap.md index 53dddf92f0..c7824de33e 100644 --- a/skills/hyperframes-animation/adapters/gsap.md +++ b/skills/hyperframes-animation/adapters/gsap.md @@ -96,7 +96,7 @@ HyperFrames is stricter than vanilla GSAP. Animate only: - Use both `svgOrigin` and `transformOrigin` on the same SVG element. - Chain animations with `delay` when a timeline can sequence them. - Create tweens before the DOM exists. -- Use infinite `repeat: -1` in HyperFrames compositions — use finite repeat counts computed from the visible duration. +- Use infinite `repeat: -1` without a finite root `data-duration` (with one, export clips to that window); when a loop must end before the composition does, use a finite repeat count computed from the visible duration. ## Credits And References diff --git a/skills/hyperframes-animation/rules-index.md b/skills/hyperframes-animation/rules-index.md index 8568d22791..48327c8840 100644 --- a/skills/hyperframes-animation/rules-index.md +++ b/skills/hyperframes-animation/rules-index.md @@ -8,7 +8,7 @@ Stated once here so individual rules don't repeat it. Every recipe in `rules/`: - runs on ONE **paused** GSAP timeline registered on `window.__timelines` (never autoplay, never a second timeline); - is **seek-safe both directions**: `fromTo` with explicit from-states (t=0 correct under seek; `immediateRender: false` when re-owning a target), absolute values — never relative `+=` tweens; state readable as a pure function of timeline time, no mutable trackers; -- is **deterministic**: no `Math.random()`, no `Date.now()` — index-derived pseudo-random and baked schedules only; finite repeats, never `repeat: -1`; +- is **deterministic**: no `Math.random()`, no `Date.now()` — index-derived pseudo-random and baked schedules only; finite repeats (`repeat: -1` only under a finite root `data-duration`); - animates **transforms and paint-only properties** — `width`/`height`/`top`/`left` tweens are forbidden (use scale/translate proxies, masks, or `anchored-layout-expand`); - caps group staggers so an arrival reads as one beat (`items × stagger ≤ ~0.5s`); - puts **no CSS `transition`** on animated elements (they interpolate independently of seek and flicker) and hints compositors with `will-change: transform` where many tweens run at once; diff --git a/skills/hyperframes-core/SKILL.md b/skills/hyperframes-core/SKILL.md index 9f4ea91acf..97e68da11f 100644 --- a/skills/hyperframes-core/SKILL.md +++ b/skills/hyperframes-core/SKILL.md @@ -73,7 +73,7 @@ A lint **error** also switches off the layout and contrast audits: `check` then Surfaced here; full rationale in the linked reference. Do not violate: -- No render-time clocks / unseeded `Math.random` / network / input-state; no `repeat: -1` (use a finite count). → `determinism-rules.md` +- No render-time clocks / unseeded `Math.random` / network / input-state; `repeat: -1` only under a finite root `data-duration` (export clips to it — otherwise use a finite count). → `determinism-rules.md` - Never tween `display`, `visibility`, or `autoAlpha` on a `.clip` element. The framework owns clip visibility, and `lint` rejects it (`gsap_animates_clip_element`). Animate a child instead. → `determinism-rules.md` - No `
` in body text; transformed elements must be block-level + sized; pulsing absolute decoratives need peak clearance. → `determinism-rules.md` - `