mirror of
https://github.com/shinyobjectz/raea.git
synced 2026-12-01 06:53:19 -10:00
Compare commits
127
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
78897a1539 | ||
|
|
35267727b8 | ||
|
|
c72717a635 | ||
|
|
0256cb9673 | ||
|
|
b9b0d76568 | ||
|
|
bda521b3ce | ||
|
|
740f3c2cf4 | ||
|
|
dea4d75c8a | ||
|
|
2563c183e7 | ||
|
|
95b2c01a24 | ||
|
|
c81b4e8c23 | ||
|
|
1430731bf3 | ||
|
|
d873402ac5 | ||
|
|
14cdac0687 | ||
|
|
036a2ddb5e | ||
|
|
e5f4743dee | ||
|
|
4aff22e31a | ||
|
|
c863adef82 | ||
|
|
8627ba7ab4 | ||
|
|
456fd1e153 | ||
|
|
3afc53d45b | ||
|
|
7d79a24f33 | ||
|
|
6af8bfa5bb | ||
|
|
4b2225163e | ||
|
|
57373a9901 | ||
|
|
9ce8f53466 | ||
|
|
28af820668 | ||
|
|
ea5640de8f | ||
|
|
3ac738884c | ||
|
|
096f87d153 | ||
|
|
845f7438d5 | ||
|
|
6f96c78a8b | ||
|
|
e70d9c79c1 | ||
|
|
f4db12c1d0 | ||
|
|
cd159fe0be | ||
|
|
316b612d70 | ||
|
|
aa40a2fa86 | ||
|
|
48705982b6 | ||
|
|
7580433cd2 | ||
|
|
28f3fd814b | ||
|
|
1905dc723c | ||
|
|
c41dd64516 | ||
|
|
1fc3a07655 | ||
|
|
986bd33463 | ||
|
|
c41ec580a9 | ||
|
|
7e25dcc56e | ||
|
|
561e7a569c | ||
|
|
0649788f7f | ||
|
|
1a77da4980 | ||
|
|
1a913e6b06 | ||
|
|
7db0e7e149 | ||
|
|
ab63120653 | ||
|
|
8938819947 | ||
|
|
79cda1dc8c | ||
|
|
f0a266718e | ||
|
|
c8af179033 | ||
|
|
a0f6a95fe7 | ||
|
|
afaeaa0a7a | ||
|
|
65f2a6ae1e | ||
|
|
00deff035c | ||
|
|
7611a96e34 | ||
|
|
6fb27ef9e8 | ||
|
|
0c0de9b3d6 | ||
|
|
84f6c59dd0 | ||
|
|
96adb3ecfb | ||
|
|
4e12541984 | ||
|
|
4cc8f58e0a | ||
|
|
1873676251 | ||
|
|
374426411e | ||
|
|
e435bff43e | ||
|
|
4b2b39edd3 | ||
|
|
063ae93f30 | ||
|
|
2a63d75e1b | ||
|
|
2a005e0e30 | ||
|
|
04098af5af | ||
|
|
22834de9b1 | ||
|
|
300e094b9d | ||
|
|
7e214fedbb | ||
|
|
280437c111 | ||
|
|
11f28ffc52 | ||
|
|
107b591555 | ||
|
|
b7cc2694aa | ||
|
|
2bd30c5fad | ||
|
|
d169848689 | ||
|
|
0d92089f7d | ||
|
|
5885f86ff3 | ||
|
|
e02151cf49 | ||
|
|
49c2c96a1a | ||
|
|
346cacd71a | ||
|
|
ad766214e0 | ||
|
|
745c5f98c8 | ||
|
|
d36b0604bc | ||
|
|
03c2e2ee15 | ||
|
|
21859a5a31 | ||
|
|
f02348c397 | ||
|
|
64d97bac8f | ||
|
|
b9d1beaa2f | ||
|
|
b1a8d57616 | ||
|
|
9adc87dcd9 | ||
|
|
3a1cff770b | ||
|
|
09d87cfa1c | ||
|
|
afa6702c05 | ||
|
|
38f49d623f | ||
|
|
7ded6a7612 | ||
|
|
6416e4ec1b | ||
|
|
2556f42366 | ||
|
|
f2351359c8 | ||
|
|
7595c81782 | ||
|
|
1926af81a5 | ||
|
|
5d5da4f3d8 | ||
|
|
760d8e53c1 | ||
|
|
40757526f8 | ||
|
|
50a7e94f5e | ||
|
|
6735bd940f | ||
|
|
b250367b6c | ||
|
|
813bc24097 | ||
|
|
2127b369d3 | ||
|
|
5650d65c65 | ||
|
|
974148442e | ||
|
|
89fd926258 | ||
|
|
dd9be82976 | ||
|
|
784e156895 | ||
|
|
2161fa0ba0 | ||
|
|
e745f91ae4 | ||
|
|
a0f685b043 | ||
|
|
5c4ddb6989 | ||
|
|
17518a3ac1 |
No files matched your search
@@ -68,6 +68,9 @@ jobs:
|
||||
run: bash tools/layers.sh
|
||||
- name: names
|
||||
run: bash tools/names.sh
|
||||
- name: legacy names
|
||||
# nothing names what raea's one loop replaced (docs/goal.feature MK41)
|
||||
run: bash tools/legacy-names.sh
|
||||
- name: size
|
||||
run: bash tools/size.sh
|
||||
- name: one-version
|
||||
@@ -118,7 +121,12 @@ jobs:
|
||||
# debug info off: with it the test binaries of the app crates filled 27 GB of a runner's disk (#90)
|
||||
env:
|
||||
CARGO_PROFILE_TEST_DEBUG: "0"
|
||||
run: cargo test --locked -p raea-runtime-plugins -p raea-io-media -p raea-core-fonts -p raea-native -p raea-core-brief -p raea-core-k -p raea-bundle -p raea-app-check -p raea-app-check-flash -p raea-io-ffmpeg -p raea-app-workspace -p raea-app-tools -p raea-app-targets
|
||||
# raea-bundle in a call of its own: Rolldown's crates turn on serde_json's arbitrary_precision, features unify
|
||||
# across one cargo call, and with it on an untagged enum can't read a number (raea-core-brief's make dials failed
|
||||
# here from 11-23 while passing alone). raea itself never links Rolldown: it loads it as a library at run time
|
||||
run: |
|
||||
cargo test --locked -p raea-runtime-plugins -p raea-io-media -p raea-core-fonts -p raea-native -p raea-core-brief -p raea-core-k -p raea-app-check -p raea-app-check-flash -p raea-io-ffmpeg -p raea-app-workspace -p raea-app-tools -p raea-app-targets
|
||||
cargo test --locked -p raea-bundle
|
||||
- name: Windows' and Linux's own (#169)
|
||||
# what a Windows or Linux user meets that no other step ran: QuickJS's Intl (raea-runtime-jsengine's
|
||||
# quickjs_formats_as_javascriptcore_does, on Linux), openh264 at --quality master (raea-io-soft), git found or
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
# Apple Silicon, Linux on x86_64 and Windows on x86_64 are built from the tag on GitHub's runners, packed by
|
||||
# tools/release.sh, checked by tools/release-check.sh, attested (anyone can check a download with
|
||||
# `gh attestation verify raea-VERSION-macos-arm64.tar.gz -R shinyobjectz/raea`) and attached to the tag's release.
|
||||
# Linux also packages and checks an AppImage from the same verified archive (tools/release-appimage.sh).
|
||||
# The skills gate reads the feed app, which is private, so it runs in a maintainer's checkout first
|
||||
# (tools/skills.sh check), and the tag names the commit it passed on; tools/release.sh checks the gate's inputs haven't
|
||||
# changed since (tools/release/skills-passed.sh):
|
||||
@@ -181,6 +182,11 @@ jobs:
|
||||
v=${TAG#v}
|
||||
if [ "$RUNNER_OS" = Linux ]; then xvfb-run -a -s "-screen 0 1280x1024x24" bash tools/release.sh "$v" ship HEAD
|
||||
else bash tools/release.sh "$v" ship HEAD; fi
|
||||
- name: Package and check the Linux AppImage
|
||||
if: runner.os == 'Linux'
|
||||
env:
|
||||
RAEA_CHECK_DIR: ${{ runner.temp }}/appimage-check
|
||||
run: xvfb-run -a -s "-screen 0 1280x1024x24" bash tools/release-appimage.sh "${TAG#v}" "dist/raea-${TAG#v}-linux-x86_64.tar.gz"
|
||||
# a failed check's own files (the app check's frames, every step's log), not the unpacked release
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: failure()
|
||||
@@ -189,6 +195,8 @@ jobs:
|
||||
path: |
|
||||
${{ runner.temp }}/release-check/app
|
||||
${{ runner.temp }}/release-check/**/*.log
|
||||
${{ runner.temp }}/appimage-check/app
|
||||
${{ runner.temp }}/appimage-check/**/*.log
|
||||
retention-days: 7
|
||||
if-no-files-found: ignore
|
||||
# the stripped binaries' symbols (#88), for symbolicating a crash report from this release; never published
|
||||
@@ -202,6 +210,10 @@ jobs:
|
||||
if: ${{ !inputs.dry_run }}
|
||||
with:
|
||||
subject-path: dist/raea-*.tar.gz
|
||||
- uses: actions/attest-build-provenance@v2
|
||||
if: ${{ runner.os == 'Linux' && !inputs.dry_run }}
|
||||
with:
|
||||
subject-path: dist/raea-*.AppImage
|
||||
- name: Attach to the release
|
||||
if: ${{ !inputs.dry_run }}
|
||||
env:
|
||||
@@ -209,11 +221,16 @@ jobs:
|
||||
run: |
|
||||
gh release view "$TAG" >/dev/null 2>&1 || gh release create "$TAG" ${{ contains(env.TAG, '-') && '--prerelease' || '' }} --title "raea ${TAG#v}" --notes "Built by .github/workflows/release.yml; notes follow."
|
||||
gh release upload "$TAG" dist/raea-*.tar.gz dist/raea-*.tar.gz.sha256 --clobber
|
||||
if [ "$RUNNER_OS" = Linux ]; then
|
||||
gh release upload "$TAG" dist/raea-*.AppImage dist/raea-*.AppImage.sha256 --clobber
|
||||
fi
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: ${{ inputs.dry_run }}
|
||||
with:
|
||||
name: dry-run-${{ runner.os }}
|
||||
path: dist/raea-*.tar.gz*
|
||||
path: |
|
||||
dist/raea-*.tar.gz*
|
||||
dist/raea-*.AppImage*
|
||||
retention-days: 3
|
||||
compression-level: 0
|
||||
|
||||
@@ -223,6 +240,9 @@ jobs:
|
||||
# (tools/release/win-bundle.sh), as Microsoft documents for app-local deployment.
|
||||
windows:
|
||||
runs-on: ${{ (vars.RELEASE_WINDOWS_RUNNER && fromJSON(vars.RELEASE_WINDOWS_RUNNER)) || 'windows-latest' }}
|
||||
# the signing identity's federated credential trusts this repository's environment "signing" and nothing else
|
||||
# (Azure app raea-release-signing); with no identity set there is no environment, and the zip is unsigned
|
||||
environment: ${{ vars.AZURE_SIGN_CLIENT_ID != '' && 'signing' || '' }}
|
||||
timeout-minutes: 350
|
||||
env:
|
||||
# the compile cache, as build's
|
||||
@@ -352,9 +372,24 @@ jobs:
|
||||
run: bash tools/release/lavapipe.sh
|
||||
- name: Where the skills gate passed
|
||||
run: bash tools/release/skills-passed.sh "$TAG" "${{ inputs.skills_passed }}"
|
||||
# raea's own Windows programs signed (#221), once the repository has the signing identity: the variables
|
||||
# AZURE_SIGN_CLIENT_ID, AZURE_SIGN_TENANT_ID and AZURE_SIGN_SUBSCRIPTION_ID name an Azure app whose federated
|
||||
# credential trusts this workflow and which holds the Artifact Signing Certificate Profile Signer role on the
|
||||
# account (no secret is stored: the job's own token is exchanged). Without them the zip is unsigned, as before
|
||||
- name: Sign in to Azure for signing
|
||||
if: ${{ vars.AZURE_SIGN_CLIENT_ID != '' }}
|
||||
uses: azure/login@v2
|
||||
with:
|
||||
client-id: ${{ vars.AZURE_SIGN_CLIENT_ID }}
|
||||
tenant-id: ${{ vars.AZURE_SIGN_TENANT_ID }}
|
||||
subscription-id: ${{ vars.AZURE_SIGN_SUBSCRIPTION_ID }}
|
||||
- name: jsign (signs raea's programs)
|
||||
if: ${{ vars.AZURE_SIGN_CLIENT_ID != '' }}
|
||||
run: choco install jsign -y --no-progress
|
||||
- name: Pack and check (tools/release.sh)
|
||||
env:
|
||||
RAEA_CHECK_DIR: ${{ runner.temp }}/release-check
|
||||
RAEA_WIN_SIGN: ${{ vars.AZURE_SIGN_CLIENT_ID != '' && '1' || '' }}
|
||||
run: bash tools/release.sh "${TAG#v}" target/dist HEAD
|
||||
# live play on Windows (PT20 left it unproven): bevy-ts's play cases, `play --offscreen` with an input script and
|
||||
# a snapshot's pixels probed, run by the raea just built; check.sh reads the pixels with ImageMagick, which the
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
# raea built natively for Windows on ARM (#82: a Snapdragon X runs the x64 build under emulation, and asked for its
|
||||
# own). GitHub's windows-11-arm runner builds what release.yml's windows job builds, for aarch64-pc-windows-msvc, runs
|
||||
# `raea --version`, packs and checks raea-VERSION-windows-arm64.zip with tools/release.sh (RAEA_WIN_ARCH=arm64)
|
||||
# without drawing (RAEA_CHECK_NO_GPU=1: WARP segfaults in Bevy's compute shaders here as on x64, and Mesa's lavapipe has
|
||||
# no ARM64 build; a Snapdragon PC is what draws, #82), and on a v* tag attaches it to that
|
||||
# release. It runs beside release.yml, not in it, so a release never waits on or fails with the ARM64 build; a
|
||||
# promoted release (release-go.sh) builds it again from the tag. install.ps1 takes it on an ARM64 PC when it's there.
|
||||
name: windows-arm
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
ref:
|
||||
description: "commit, branch or tag to build"
|
||||
required: false
|
||||
version:
|
||||
description: "the version the zip is named for (raea-VERSION-windows-arm64.zip)"
|
||||
required: false
|
||||
push:
|
||||
branches: [windows-arm64]
|
||||
tags: ["v*"]
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: windows-11-arm
|
||||
timeout-minutes: 350
|
||||
env:
|
||||
# the release builds' compile cache (tools/release/compile-cache.sh), under this OS and architecture's own prefix
|
||||
RELEASE_CACHE_ENDPOINT: ${{ secrets.RELEASE_CACHE_ENDPOINT }}
|
||||
AWS_ACCESS_KEY_ID: ${{ secrets.RELEASE_CACHE_KEY_ID }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.RELEASE_CACHE_SECRET }}
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ inputs.ref || github.sha }}
|
||||
submodules: true
|
||||
lfs: false
|
||||
- name: Toolchain (rust-toolchain.toml's pin)
|
||||
run: |
|
||||
if ! command -v rustup >/dev/null; then
|
||||
curl -fsSL --retry 3 -o "$RUNNER_TEMP/rustup-init.exe" https://static.rust-lang.org/rustup/dist/aarch64-pc-windows-msvc/rustup-init.exe
|
||||
"$RUNNER_TEMP/rustup-init.exe" -y --default-toolchain none --profile minimal
|
||||
echo "$USERPROFILE/.cargo/bin" >> "$GITHUB_PATH"
|
||||
export PATH="$USERPROFILE/.cargo/bin:$PATH"
|
||||
fi
|
||||
rustup show active-toolchain || rustup toolchain install
|
||||
rustc -vV
|
||||
# ring builds its aarch64 assembly with clang (and only clang) on Windows
|
||||
- name: clang (ring's assembly)
|
||||
run: |
|
||||
if ! command -v clang >/dev/null; then
|
||||
for d in "/c/Program Files/LLVM/bin" "/c/Program Files/Microsoft Visual Studio"/*/*/VC/Tools/Llvm/ARM64/bin; do
|
||||
[ -x "$d/clang.exe" ] && { echo "$d" >> "$GITHUB_PATH"; export PATH="$d:$PATH"; break; }
|
||||
done
|
||||
fi
|
||||
command -v clang >/dev/null || { winget install -e --id LLVM.LLVM --accept-source-agreements --accept-package-agreements --silent; echo "/c/Program Files/LLVM/bin" >> "$GITHUB_PATH"; export PATH="/c/Program Files/LLVM/bin:$PATH"; }
|
||||
clang --version
|
||||
- name: jq that writes LF
|
||||
run: |
|
||||
mkdir -p "$RUNNER_TEMP/jq"
|
||||
printf '#!/bin/bash\nexec "%s" -b "$@"\n' "$(command -v jq)" > "$RUNNER_TEMP/jq/jq"
|
||||
chmod +x "$RUNNER_TEMP/jq/jq"
|
||||
echo "$RUNNER_TEMP/jq" >> "$GITHUB_PATH"
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
bun-version: 1.4.2
|
||||
- name: The runtime's packages
|
||||
run: for d in sdk/react/js sdk/react/tw; do (cd "$d" && bun install --frozen-lockfile); done
|
||||
# (an sccache the action can't fetch for ARM64 Windows leaves the build uncached, as compile-cache.sh does)
|
||||
- name: Compile cache (sccache, as release.yml's)
|
||||
if: env.AWS_ACCESS_KEY_ID != ''
|
||||
continue-on-error: true
|
||||
uses: mozilla-actions/[email protected]
|
||||
- name: Use the compile cache
|
||||
if: env.AWS_ACCESS_KEY_ID != ''
|
||||
run: bash tools/release/compile-cache.sh
|
||||
- name: Build
|
||||
run: |
|
||||
feat=$(bash tools/bevy-plugins.sh features sdk/raea/bench/bevy-plugins)
|
||||
t() { s=$SECONDS; "$@"; echo "::notice::Windows ARM64 $(( (SECONDS - s) / 60 )) min: ${*:7}"; }
|
||||
t cargo build --profile dist --locked -p raea-cli --bin raea --no-default-features --features "$feat"
|
||||
t cargo build --profile dist --locked -p raea-rune-host
|
||||
t cargo build --profile dist --locked -p raea-page-host --features window
|
||||
t cargo build --profile dist --locked -p raea-perceive
|
||||
- name: What raea.exe is and imports
|
||||
run: |
|
||||
file target/dist/raea.exe || true
|
||||
dumpbin=$(ls "/c/Program Files/Microsoft Visual Studio"/*/*/VC/Tools/MSVC/*/bin/Hostarm64/arm64/dumpbin.exe 2>/dev/null | head -1)
|
||||
[ -n "$dumpbin" ] && "$dumpbin" -nologo -headers -dependents target/dist/raea.exe | grep -iE 'machine|\.dll$' | sed 's/^ *//' | tee -a "$GITHUB_STEP_SUMMARY" || true
|
||||
target/dist/raea.exe --version | tee -a "$GITHUB_STEP_SUMMARY"
|
||||
- name: Models (pinned by URL and sha256 in tools/release/models.tsv)
|
||||
run: |
|
||||
while IFS=$'\t' read -r path url sha; do
|
||||
case $path in ''|'#'*) continue ;; esac
|
||||
mkdir -p "$HOME/.local/share/raea-models/$(dirname "$path")"
|
||||
curl -fsSL "$url" -o "$HOME/.local/share/raea-models/$path"
|
||||
echo "$sha $HOME/.local/share/raea-models/$path" | sha256sum -c -
|
||||
done < <(tr -d '\r' < tools/release/models.tsv)
|
||||
# bin\ as release.yml's windows job fills it, with the ARM64 runtime, uv and DXC (RAEA_WIN_ARCH=arm64), then the
|
||||
# zip packed and checked by tools/release.sh as raea-VERSION-windows-arm64.zip. The skills gate is this commit's
|
||||
# (public raea has no feed app; cli.md is still checked against this build's help); nothing is drawn
|
||||
- name: Pack and check (tools/release.sh)
|
||||
env:
|
||||
RAEA_WIN_ARCH: arm64
|
||||
RAEA_CHECK_DIR: ${{ runner.temp }}/release-check
|
||||
RAEA_CHECK_NO_GPU: "1"
|
||||
run: |
|
||||
bash tools/release/onnxruntime.sh target/dist
|
||||
bash tools/release/win-bundle.sh target/dist
|
||||
v="${{ inputs.version }}"
|
||||
case $GITHUB_REF in
|
||||
refs/tags/v*)
|
||||
v=${v:-${GITHUB_REF_NAME#v}}
|
||||
# where the skills gate passed, as release.yml reads it (the tag's skills-passed line)
|
||||
eval "$(GITHUB_ENV= bash tools/release/skills-passed.sh "$GITHUB_REF_NAME" | grep '^RAEA_SKILLS_PASSED=')" ;;
|
||||
*) RAEA_SKILLS_PASSED=$(git rev-parse HEAD) ;;
|
||||
esac
|
||||
export RAEA_SKILLS_PASSED
|
||||
bash tools/release.sh "${v:-0.0.0-arm64}" target/dist HEAD
|
||||
# on a v* tag, beside release.yml's archives (the release made here if release.yml hasn't yet)
|
||||
- name: Attach to the release
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
pre=; case $GITHUB_REF_NAME in *-*) pre=--prerelease ;; esac
|
||||
gh release view "$GITHUB_REF_NAME" -R "$GITHUB_REPOSITORY" >/dev/null 2>&1 ||
|
||||
gh release create "$GITHUB_REF_NAME" -R "$GITHUB_REPOSITORY" $pre --title "raea ${GITHUB_REF_NAME#v}" --notes "Built by .github/workflows/release.yml; notes follow." ||
|
||||
gh release view "$GITHUB_REF_NAME" -R "$GITHUB_REPOSITORY" >/dev/null
|
||||
gh release upload "$GITHUB_REF_NAME" -R "$GITHUB_REPOSITORY" dist/raea-*-windows-arm64.zip dist/raea-*-windows-arm64.zip.sha256 --clobber
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: always()
|
||||
with:
|
||||
name: windows-arm64-zip
|
||||
path: dist/raea-*-windows-arm64.zip*
|
||||
retention-days: 7
|
||||
compression-level: 0
|
||||
if-no-files-found: ignore
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: always()
|
||||
with:
|
||||
name: windows-arm64-bins
|
||||
path: |
|
||||
target/dist/raea.exe
|
||||
target/dist/raea_bundle.dll
|
||||
target/dist/raea-rune-host.exe
|
||||
target/dist/raea-page-host.exe
|
||||
target/dist/raea-perceive.exe
|
||||
retention-days: 7
|
||||
if-no-files-found: ignore
|
||||
|
||||
# vendor/metis-sys's header change reaches release.yml's x64 build too (windows-latest's Visual Studio): metis-sys
|
||||
# alone, in a scratch crate, compiled there
|
||||
metis-x64:
|
||||
runs-on: windows-latest
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ inputs.ref || github.sha }}
|
||||
sparse-checkout: vendor/metis-sys
|
||||
- name: metis-sys on x64 MSVC
|
||||
run: |
|
||||
c="$RUNNER_TEMP/metis-x64"; mkdir -p "$c/src" && : > "$c/src/lib.rs"
|
||||
printf '[package]\nname = "metis-x64"\nversion = "0.0.0"\nedition = "2021"\n[dependencies]\nmetis-sys = { path = "%s" }\n[workspace]\n' "$(cygpath -m "$GITHUB_WORKSPACE/vendor/metis-sys")" > "$c/Cargo.toml"
|
||||
cl 2>&1 | head -1 || true
|
||||
cd "$c" && cargo build
|
||||
@@ -0,0 +1,55 @@
|
||||
# Code of conduct
|
||||
|
||||
raea's issues, pull requests, reviews and other project-managed community spaces
|
||||
should let people discuss and improve the work without harassment. This applies
|
||||
to maintainers, contributors and people using automated or AI-assisted tools.
|
||||
Participants remain responsible for the material they submit through those tools.
|
||||
|
||||
## Expected behavior
|
||||
|
||||
- Discuss the code, evidence and ideas respectfully. Technical disagreement is
|
||||
welcome; personal attacks and assumptions about another person's motives are not.
|
||||
- Give actionable feedback, accept corrections and respect requests to stop a
|
||||
conversation or move it out of a thread.
|
||||
- Make room for different experience levels, backgrounds and communication styles.
|
||||
- Respect privacy. Share only logs, screenshots and other information you have
|
||||
permission to publish, with credentials and personal information removed.
|
||||
|
||||
Harassment, discriminatory insults, threats, sexual harassment, unwanted repeated
|
||||
contact, disclosure of private information, deliberate disruption and retaliation
|
||||
against someone raising a concern are unacceptable.
|
||||
|
||||
## Reporting a concern
|
||||
|
||||
For content on GitHub, use the content menu's **Report content** action where it
|
||||
is available. Choose **Report to repository admins** if GitHub offers it.
|
||||
Maintainer reporting depends on repository settings and the reporter's access.
|
||||
For abuse covered by GitHub's rules, use **Report abuse to GitHub Support** or
|
||||
[GitHub's abuse-reporting route](https://docs.github.com/en/communities/maintaining-your-safety-on-github/reporting-abuse-or-spam).
|
||||
GitHub handles those reports under its own policies; it is not the project's
|
||||
appeal body for every technical or moderation disagreement.
|
||||
|
||||
A separate private maintainer inbox for conduct reports has not been designated
|
||||
in this repository. If GitHub's maintainer-reporting option is unavailable, ask
|
||||
for a private contact without posting the incident, personal information or
|
||||
accusations in a public issue. Maintainers can document an additional contact
|
||||
after confirming who will handle it. Use [the security policy](SECURITY.md) for vulnerabilities,
|
||||
not as a general conduct-report channel.
|
||||
|
||||
Include links, the relevant context and your preferred way to be contacted when
|
||||
reporting privately. Do not retaliate, publicly investigate the reporter or
|
||||
pressure someone to disclose an incident.
|
||||
|
||||
## Moderation
|
||||
|
||||
Repository maintainers may clarify expectations, ask participants to change
|
||||
behavior, close or remove disruptive content, restrict interactions, or block
|
||||
continued participation as appropriate to severity and repetition. A technical
|
||||
disagreement or a rejected contribution alone is not misconduct.
|
||||
|
||||
Maintainers should consider context and available evidence, protect sensitive
|
||||
information, explain decisions when doing so does not compromise privacy, and
|
||||
allow a participant to provide relevant additional context privately through the
|
||||
same reporting route. A maintainer involved in a concern should seek an uninvolved
|
||||
reviewer where one is available. This policy does not promise a response deadline
|
||||
or confidentiality beyond what the chosen reporting service and process provide.
|
||||
Generated
+235
-17
@@ -8490,6 +8490,15 @@ dependencies = [
|
||||
"generic-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "intel_tex_2"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7980d359170e7da4bc2421aa74c49d338a3153313e006d732a3430f1af375a60"
|
||||
dependencies = [
|
||||
"ispc_rt",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "interpolate_name"
|
||||
version = "0.2.4"
|
||||
@@ -8573,6 +8582,16 @@ version = "1.70.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695"
|
||||
|
||||
[[package]]
|
||||
name = "ispc_rt"
|
||||
version = "2.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a396f76fd253fab9945bb4c6080f515d0c4036bc30219462d199b58886fd37b4"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"num_cpus",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.10.5"
|
||||
@@ -10263,8 +10282,6 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "metis-sys"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "769ee6be814b21c52afcc631f07051f578487d642f3e89a45f2a086fd94fffa9"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
@@ -13896,6 +13913,7 @@ dependencies = [
|
||||
"raea-core-facts",
|
||||
"raea-core-review",
|
||||
"raea-io-home",
|
||||
"raea-runtime-lod-plan",
|
||||
"resvg 0.48.1",
|
||||
"serde_json",
|
||||
]
|
||||
@@ -13918,6 +13936,7 @@ dependencies = [
|
||||
name = "raea-app-motion"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"glam 0.33.12",
|
||||
"raea-io-home",
|
||||
"raea-runtime-bundle",
|
||||
"raea-sys-kimodo",
|
||||
@@ -13955,6 +13974,18 @@ dependencies = [
|
||||
"winit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-app-playable"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"raea-io-home",
|
||||
"raea-runtime-bundle",
|
||||
"regex",
|
||||
"serde_json",
|
||||
"zip",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-app-registry"
|
||||
version = "0.1.0"
|
||||
@@ -13972,12 +14003,17 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
"dunce",
|
||||
"image",
|
||||
"raea-core-facts",
|
||||
"raea-core-scene",
|
||||
"raea-runtime-bundle",
|
||||
"raea-runtime-export",
|
||||
"raea-runtime-lod-plan",
|
||||
"raea-sys-body",
|
||||
"raea-sys-contact",
|
||||
"raea-sys-light-meter",
|
||||
"raea-sys-motionfaults",
|
||||
"raea-sys-notice",
|
||||
"raea-sys-stage",
|
||||
"serde_json",
|
||||
]
|
||||
@@ -14042,6 +14078,7 @@ dependencies = [
|
||||
"anyhow",
|
||||
"cpal 0.15.3",
|
||||
"ort",
|
||||
"raea-io-trace",
|
||||
"raea-sys-ml",
|
||||
"raea-sys-speech",
|
||||
"serde_json",
|
||||
@@ -14237,6 +14274,7 @@ name = "raea-bundle"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"base64 0.22.1",
|
||||
"dunce",
|
||||
"lightningcss",
|
||||
"oxc",
|
||||
@@ -14289,6 +14327,7 @@ dependencies = [
|
||||
"raea-app-media",
|
||||
"raea-app-notes",
|
||||
"raea-app-play",
|
||||
"raea-app-playable",
|
||||
"raea-app-scene",
|
||||
"raea-app-solid",
|
||||
"raea-app-sound",
|
||||
@@ -14297,6 +14336,8 @@ dependencies = [
|
||||
"raea-app-voice",
|
||||
"raea-app-workspace",
|
||||
"raea-bevy-plugins",
|
||||
"raea-cli-goal",
|
||||
"raea-cli-refused",
|
||||
"raea-core-alloc",
|
||||
"raea-core-animate",
|
||||
"raea-core-brief",
|
||||
@@ -14325,6 +14366,26 @@ dependencies = [
|
||||
"wsx",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-cli-goal"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"raea-app-make",
|
||||
"raea-core-brief",
|
||||
"raea-io-home",
|
||||
"raea-native",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-cli-refused"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"dunce",
|
||||
"raea-io-home",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-core-alloc"
|
||||
version = "0.1.0"
|
||||
@@ -14452,6 +14513,7 @@ version = "0.1.0"
|
||||
name = "raea-core-shape"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"blake3",
|
||||
"manifold-rust",
|
||||
"raea-core-fonts",
|
||||
"raea-core-grow",
|
||||
@@ -14470,6 +14532,15 @@ dependencies = [
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-core-tables"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
"raea-core-program",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-core-wire"
|
||||
version = "0.1.0"
|
||||
@@ -14804,7 +14875,9 @@ name = "raea-light"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"image",
|
||||
"raea-core-facts",
|
||||
"raea-io-home",
|
||||
"raea-io-trace",
|
||||
"raea-runtime-bundle",
|
||||
"serde_json",
|
||||
]
|
||||
@@ -15009,29 +15082,62 @@ dependencies = [
|
||||
"raea-gpu-device",
|
||||
"raea-io-media",
|
||||
"raea-io-trace",
|
||||
"raea-render-plugins",
|
||||
"raea-render-raytrace",
|
||||
"raea-runtime-gpuframe",
|
||||
"raea-runtime-plugins",
|
||||
"raea-runtime-scene3d",
|
||||
"raea-runtime-view",
|
||||
"raea-sys-compose",
|
||||
"raea-sys-compute",
|
||||
"raea-sys-engine-shaders",
|
||||
"raea-sys-environment",
|
||||
"raea-sys-fog",
|
||||
"raea-sys-frame",
|
||||
"raea-sys-grass",
|
||||
"raea-sys-grid",
|
||||
"raea-sys-hold",
|
||||
"raea-sys-look",
|
||||
"raea-sys-matchmove",
|
||||
"raea-sys-material",
|
||||
"raea-sys-memtally",
|
||||
"raea-sys-meshseq",
|
||||
"raea-sys-page",
|
||||
"raea-sys-post",
|
||||
"raea-sys-procmat",
|
||||
"raea-sys-screen",
|
||||
"raea-sys-shader",
|
||||
"raea-sys-splat",
|
||||
"raea-sys-sprite",
|
||||
"raea-sys-text3d",
|
||||
"raea-sys-three-shader",
|
||||
"raea-sys-toon",
|
||||
"raea-sys-viewbox",
|
||||
"serde_json",
|
||||
"wgpu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-render-plugins"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
"raea-core-program",
|
||||
"raea-runtime-plugins",
|
||||
"raea-runtime-scene3d",
|
||||
"raea-sys-compose",
|
||||
"raea-sys-compute",
|
||||
"raea-sys-environment",
|
||||
"raea-sys-fog",
|
||||
"raea-sys-fog-half",
|
||||
"raea-sys-frame",
|
||||
"raea-sys-framepass",
|
||||
"raea-sys-gi",
|
||||
"raea-sys-grass",
|
||||
"raea-sys-grid",
|
||||
"raea-sys-hold",
|
||||
"raea-sys-lod",
|
||||
"raea-sys-look",
|
||||
"raea-sys-matchmove",
|
||||
"raea-sys-material",
|
||||
"raea-sys-meshseq",
|
||||
"raea-sys-page",
|
||||
"raea-sys-parity",
|
||||
"raea-sys-phase",
|
||||
"raea-sys-post",
|
||||
@@ -15045,10 +15151,8 @@ dependencies = [
|
||||
"raea-sys-sprite",
|
||||
"raea-sys-text3d",
|
||||
"raea-sys-three-shader",
|
||||
"raea-sys-viewbox",
|
||||
"raea-sys-toon",
|
||||
"raea-sys-volume",
|
||||
"serde_json",
|
||||
"wgpu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -15063,6 +15167,7 @@ dependencies = [
|
||||
"raea-sys-engine-shaders",
|
||||
"raea-sys-post",
|
||||
"raea-sys-rt",
|
||||
"raea-sys-viewbox",
|
||||
"serde_json",
|
||||
"wgpu",
|
||||
]
|
||||
@@ -15249,7 +15354,6 @@ name = "raea-runtime-calls"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"bevy",
|
||||
"image",
|
||||
"manifold-rust",
|
||||
"parley",
|
||||
@@ -15260,6 +15364,7 @@ dependencies = [
|
||||
"raea-io-net",
|
||||
"raea-io-trace",
|
||||
"raea-native",
|
||||
"raea-runtime-ecs",
|
||||
"raea-runtime-plugins",
|
||||
"raea-runtime-wear",
|
||||
"raea-sys-fonts",
|
||||
@@ -15325,6 +15430,14 @@ dependencies = [
|
||||
"vello",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-runtime-ecs"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-runtime-edit"
|
||||
version = "0.1.0"
|
||||
@@ -15364,7 +15477,9 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"raea-core-facts",
|
||||
"raea-core-scene",
|
||||
"raea-runtime-lod-plan",
|
||||
"raea-sys-contact",
|
||||
"raea-sys-notice",
|
||||
"raea-sys-stage",
|
||||
"serde_json",
|
||||
]
|
||||
@@ -15394,6 +15509,7 @@ dependencies = [
|
||||
"raea-runtime-page",
|
||||
"raea-runtime-pagestore",
|
||||
"raea-runtime-react",
|
||||
"raea-runtime-review",
|
||||
"raea-runtime-scene",
|
||||
"raea-runtime-scene3d",
|
||||
"raea-runtime-sound",
|
||||
@@ -15476,6 +15592,17 @@ dependencies = [
|
||||
"rquickjs",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-runtime-kinds"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
"raea-core-program",
|
||||
"raea-core-scene",
|
||||
"raea-runtime-look",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-runtime-live"
|
||||
version = "0.1.0"
|
||||
@@ -15504,6 +15631,18 @@ dependencies = [
|
||||
"winit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-runtime-lod-plan"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
"dunce",
|
||||
"raea-core-facts",
|
||||
"raea-core-scene",
|
||||
"raea-sys-stage",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-runtime-look"
|
||||
version = "0.1.0"
|
||||
@@ -15520,12 +15659,9 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"bevy",
|
||||
"image",
|
||||
"raea-core-scene",
|
||||
"raea-core-wire",
|
||||
"raea-io-assets",
|
||||
"raea-io-home",
|
||||
"raea-io-media",
|
||||
"raea-io-net",
|
||||
"raea-page",
|
||||
"raea-render",
|
||||
@@ -15534,8 +15670,8 @@ dependencies = [
|
||||
"raea-runtime-react",
|
||||
"raea-runtime-twins",
|
||||
"raea-runtime-view",
|
||||
"raea-sys-facetrack",
|
||||
"raea-sys-fonts",
|
||||
"raea-sys-frame",
|
||||
"raea-sys-image",
|
||||
"raea-sys-page",
|
||||
"raea-sys-screen",
|
||||
@@ -15587,6 +15723,7 @@ dependencies = [
|
||||
"raea-core-alloc",
|
||||
"raea-core-animate",
|
||||
"raea-core-scene",
|
||||
"raea-core-shape",
|
||||
"raea-core-wire",
|
||||
"raea-io-assets",
|
||||
"raea-io-media",
|
||||
@@ -15611,6 +15748,18 @@ dependencies = [
|
||||
"raea-sys-light-meter",
|
||||
"raea-sys-page",
|
||||
"serde_json",
|
||||
"xxhash-rust",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-runtime-review"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"image",
|
||||
"raea-core-facts",
|
||||
"raea-core-review",
|
||||
"raea-sys-light-meter",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -15621,6 +15770,7 @@ dependencies = [
|
||||
"raea-core-program",
|
||||
"raea-core-review",
|
||||
"raea-core-scene",
|
||||
"raea-runtime-kinds",
|
||||
"raea-runtime-look",
|
||||
"raea-runtime-scene2d",
|
||||
"raea-sys-frame",
|
||||
@@ -15659,6 +15809,7 @@ dependencies = [
|
||||
"raea-sys-sampler",
|
||||
"raea-sys-shader",
|
||||
"raea-sys-share",
|
||||
"raea-sys-toon",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
@@ -15997,6 +16148,17 @@ dependencies = [
|
||||
"parry3d",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-sys-facetrack"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"image",
|
||||
"raea-io-assets",
|
||||
"raea-io-media",
|
||||
"raea-sys-frame",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-sys-filters"
|
||||
version = "0.1.0"
|
||||
@@ -16004,7 +16166,9 @@ dependencies = [
|
||||
"anyrender",
|
||||
"anyrender_vello",
|
||||
"blitz-paint",
|
||||
"png 0.18.1",
|
||||
"rustc-hash 2.1.3",
|
||||
"skrifa 0.44.0",
|
||||
"vello",
|
||||
"wgpu",
|
||||
]
|
||||
@@ -16133,6 +16297,7 @@ dependencies = [
|
||||
"bevy",
|
||||
"raea-core-program",
|
||||
"raea-core-scene",
|
||||
"raea-core-tables",
|
||||
"raea-io-media",
|
||||
"raea-sys-layers",
|
||||
"raea-sys-shots",
|
||||
@@ -16145,6 +16310,7 @@ name = "raea-sys-framepass"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
"raea-sys-compose",
|
||||
"raea-sys-frame",
|
||||
"raea-sys-material",
|
||||
"raea-sys-sampler",
|
||||
@@ -16353,9 +16519,11 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"bevy",
|
||||
"blake3",
|
||||
"image",
|
||||
"intel_tex_2",
|
||||
"raea-core-program",
|
||||
"raea-core-shape",
|
||||
"raea-io-home",
|
||||
"raea-io-net",
|
||||
"raea-io-trace",
|
||||
"raea-sys-frame",
|
||||
@@ -16369,6 +16537,13 @@ dependencies = [
|
||||
name = "raea-sys-measure"
|
||||
version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
name = "raea-sys-memtally"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-sys-mesh"
|
||||
version = "0.1.0"
|
||||
@@ -16399,11 +16574,22 @@ dependencies = [
|
||||
"raea-io-home",
|
||||
"raea-io-media",
|
||||
"raea-io-trace",
|
||||
"raea-sys-mix-device",
|
||||
"raea-sys-mix-level",
|
||||
"raea-sys-tone",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-sys-mix-device"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"audioadapter-buffers",
|
||||
"cpal 0.15.3",
|
||||
"firewheel",
|
||||
"raea-io-trace",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-sys-mix-level"
|
||||
version = "0.1.0"
|
||||
@@ -16431,6 +16617,27 @@ dependencies = [
|
||||
"mlx-rs",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-sys-motionfaults"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"glam 0.33.12",
|
||||
"raea-core-ease",
|
||||
"raea-sys-body",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-sys-notice"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
"raea-core-ease",
|
||||
"raea-core-scene",
|
||||
"raea-io-home",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-sys-page"
|
||||
version = "0.1.0"
|
||||
@@ -16651,6 +16858,7 @@ name = "raea-sys-splat"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
"raea-core-ease",
|
||||
"raea-core-program",
|
||||
"raea-sys-frame",
|
||||
"serde_json",
|
||||
@@ -16716,6 +16924,17 @@ dependencies = [
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-sys-toon"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
"raea-core-program",
|
||||
"raea-core-shape",
|
||||
"raea-sys-frame",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-sys-touch"
|
||||
version = "0.1.0"
|
||||
@@ -16736,6 +16955,7 @@ name = "raea-sys-viewbox"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
"raea-sys-compose",
|
||||
"raea-sys-frame",
|
||||
]
|
||||
|
||||
@@ -20378,8 +20598,6 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "taffy"
|
||||
version = "0.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3c8480887e8803986d96a7173729565520d4bbb721ad6b7ad6941a22897207aa"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"slotmap",
|
||||
|
||||
+23
@@ -12,6 +12,7 @@ members = [
|
||||
"core/ease",
|
||||
"core/fonts",
|
||||
"core/program",
|
||||
"core/tables",
|
||||
"core/scene",
|
||||
"core/shape",
|
||||
"core/meshcheck",
|
||||
@@ -30,6 +31,7 @@ members = [
|
||||
"systems/phase",
|
||||
"systems/shader/wgsl",
|
||||
"systems/sampler",
|
||||
"systems/memtally",
|
||||
"systems/parity",
|
||||
"systems/shader",
|
||||
"systems/three-shader",
|
||||
@@ -41,6 +43,8 @@ members = [
|
||||
"engine/bevy-world",
|
||||
"engine/bundle",
|
||||
"engine/cli",
|
||||
"engine/cli/goal",
|
||||
"engine/cli/refused",
|
||||
"engine/neural",
|
||||
"engine/light",
|
||||
"engine/modules",
|
||||
@@ -86,6 +90,7 @@ members = [
|
||||
"systems/tone",
|
||||
"systems/mix",
|
||||
"systems/mix/level",
|
||||
"systems/mix/device",
|
||||
"systems/ml",
|
||||
"systems/mlx",
|
||||
"systems/kimodo",
|
||||
@@ -104,6 +109,8 @@ members = [
|
||||
"systems/a11y",
|
||||
"systems/bake",
|
||||
"systems/contact",
|
||||
"systems/notice",
|
||||
"systems/motionfaults",
|
||||
"systems/light-meter",
|
||||
"systems/measure",
|
||||
"systems/canvas",
|
||||
@@ -120,6 +127,7 @@ members = [
|
||||
"systems/page-net",
|
||||
"systems/page-ops",
|
||||
"systems/frame",
|
||||
"systems/facetrack",
|
||||
"systems/engine-shaders",
|
||||
"systems/shots",
|
||||
"systems/hold",
|
||||
@@ -148,6 +156,7 @@ members = [
|
||||
"systems/look",
|
||||
"systems/compose",
|
||||
"systems/material",
|
||||
"systems/toon",
|
||||
"systems/mesh",
|
||||
"systems/post",
|
||||
"systems/fog",
|
||||
@@ -169,12 +178,14 @@ members = [
|
||||
"tools/perceive",
|
||||
"engine/render",
|
||||
"engine/render/raytrace",
|
||||
"engine/render/plugins",
|
||||
"engine/render/denoise/bench",
|
||||
"engine/seedling",
|
||||
"engine/web",
|
||||
"runtime/react",
|
||||
"runtime/track",
|
||||
"runtime/pagestore",
|
||||
"runtime/review",
|
||||
"runtime/cssurls",
|
||||
"runtime/pid",
|
||||
"bench/bridge",
|
||||
@@ -188,17 +199,20 @@ members = [
|
||||
"runtime/bundle/lib",
|
||||
"engine/shape-web",
|
||||
"runtime/calls",
|
||||
"runtime/ecs",
|
||||
"runtime/shots",
|
||||
"runtime/wear",
|
||||
"runtime/canvas",
|
||||
"runtime/export",
|
||||
"runtime/endchecks",
|
||||
"runtime/lod-plan",
|
||||
"runtime/live",
|
||||
"runtime/page",
|
||||
"runtime/appscreen",
|
||||
"runtime/sound",
|
||||
"runtime/look",
|
||||
"runtime/scene",
|
||||
"runtime/kinds",
|
||||
"runtime/scene2d",
|
||||
"runtime/shared",
|
||||
"apps/ask",
|
||||
@@ -235,6 +249,7 @@ members = [
|
||||
"apps/capcut",
|
||||
"apps/layers",
|
||||
"apps/play",
|
||||
"apps/playable",
|
||||
"tools/sdk-props",
|
||||
"tools/hands-audit",
|
||||
]
|
||||
@@ -343,6 +358,10 @@ split-debuginfo = "packed"
|
||||
[patch.crates-io]
|
||||
# the MP4 muxer, vendored
|
||||
muxide = { path = "vendor/muxide" }
|
||||
# metis-sys 0.3.2 (bevy_pbr's meshlets) with GKlib's own stdint.h and inttypes.h stand-ins used only before Visual
|
||||
# Studio 2013: Visual Studio 18's stdint.h types int_fast16_t differently, and every C file failed (raea#82; the change
|
||||
# is marked "raea:" in vendor/GKlib/gk_arch.h). Its test graphs, manual and programs are left out
|
||||
metis-sys = { path = "vendor/metis-sys" }
|
||||
# usvg 0.48.1 spacing a chunk's last letter as Chrome does (changes marked "raea:", docs/layout-reads.feature LR10)
|
||||
usvg = { path = "vendor/usvg" }
|
||||
# bevy_seedling 0.8.0 without its cpal 0.18 paths, ported to Bevy 0.20 (changes marked "raea:")
|
||||
@@ -399,6 +418,10 @@ vello_encoding = { path = "vendor/vello_encoding" }
|
||||
# (changes marked "raea:"): raea-page blends a bevy_ui page as Bevy does (bevy_ui on Blitz). No upstream
|
||||
# equivalent yet (linebender/vello blends the encoded values).
|
||||
vello_shaders = { path = "vendor/vello_shaders" }
|
||||
# taffy 0.15.0 (Blitz's, Bevy UI's, rune-taffy's) with a flex line whose items overflow its container by less than
|
||||
# Chrome's layout unit, 1/64 px, kept on one line: f32 rounding wrapped items that add up to the container's width
|
||||
# (changes marked "raea:", raea #252). Back to upstream once Taffy breaks flex lines with a tolerance.
|
||||
taffy = { path = "vendor/taffy" }
|
||||
# Firewheel 0.12 on Bevy 0.20: bevy_reflect 0.20 and a glam-33 feature (BillyDM/Firewheel#144; changes marked "raea:")
|
||||
firewheel = { path = "vendor/firewheel" }
|
||||
firewheel-core = { path = "vendor/firewheel-core" }
|
||||
|
||||
@@ -32,10 +32,10 @@
|
||||
|
||||
---
|
||||
|
||||
> **0.1.6** (17 November 2026) is the latest release: the engine and the desktop app on macOS (Apple Silicon), Linux
|
||||
> (x86_64) and, newest and least tested, Windows 10 and 11 (x86_64). raea is young and moves fast, with a release most
|
||||
> days since 0.1.1 on 11 November: expect rough edges, and tell us what you hit in an
|
||||
> [issue](https://github.com/shinyobjectz/raea/issues), or from your agent with `raea bug`.
|
||||
> raea releases experimentally and often, so the newest release is always on
|
||||
> [Releases](https://github.com/shinyobjectz/raea/releases). The app is unstable for now, especially on Linux and
|
||||
> Windows: expect rough edges, and tell us what you hit in an [issue](https://github.com/shinyobjectz/raea/issues), or
|
||||
> from your agent with `raea bug`.
|
||||
|
||||
## The app
|
||||
|
||||
@@ -80,6 +80,13 @@ The installer puts the `raea` command under `~/.raea`, links it into `~/.local/b
|
||||
work. Run it again to update. The engine is free and needs no account. Tarballs and checksums are on the
|
||||
[releases page](https://github.com/shinyobjectz/raea/releases).
|
||||
|
||||
Linux release builds also package an x86_64 AppImage of the engine command and
|
||||
attach it and its SHA256 checksum beside the release archives.
|
||||
Make it executable with `chmod +x raea-*.AppImage`, then run
|
||||
`./raea-VERSION-linux-x86_64.AppImage --help` or pass the usual `raea` arguments.
|
||||
See [the AppImage release recipe](tools/release/README.md#linux-appimage) for build
|
||||
instructions, runtime requirements and running without FUSE.
|
||||
|
||||
On Windows 10 or 11, in PowerShell:
|
||||
|
||||
```powershell
|
||||
@@ -123,7 +130,7 @@ floor (`raea check hello.mp4`). `raea init` starts a project, and `raea --help`
|
||||
Gaussian splats, and Bevy plugins compiled into the engine. three.js work runs as it's written: a React Three Fiber
|
||||
scene inside `<R3F>`, or a three.js page's script inside `<Three program>`.
|
||||
- **Sound.** One mixer for live play and offline render, instruments and effects, and local models for foley and
|
||||
instrument notes (`raea sao`, `raea tokensynth`).
|
||||
instrument notes (`raea make sao`, `raea make tokensynth`).
|
||||
- **Built for agents.** Everything it draws stays queryable as data, so an agent can render a frame, look at it, and
|
||||
fix what's wrong without a person in the loop.
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ fn hex(digest: &[u8]) -> String {
|
||||
digest.iter().take(16).map(|b| format!("{b:02x}")).collect()
|
||||
}
|
||||
|
||||
/// What a file is, cheaply, and the size an ident names (raea-core-ask, so `raea make status` reads the same).
|
||||
/// What a file is, cheaply, and the size an ident names (raea-core-ask, so `raea goal gates` reads the same).
|
||||
pub use raea_core_ask::ident::{ident, ident_len};
|
||||
|
||||
/// One of the record's files written whole, through a temporary file, so a reader never sees half of it.
|
||||
|
||||
@@ -28,6 +28,6 @@ raea-app-check-text = { path = "text" }
|
||||
raea-app-check-flash = { path = "flash" }
|
||||
# what the person sent from the raea app, handed to the agent (split out to keep this crate small)
|
||||
raea-app-check-inbox = { path = "inbox" }
|
||||
# the Stop gate for a `make` job (docs/make.feature MK2; split out to keep this crate small)
|
||||
# the Stop gate for a `make` job (docs/goal.feature MK2; split out to keep this crate small)
|
||||
raea-app-check-make = { path = "make" }
|
||||
serde_json = "1"
|
||||
@@ -55,6 +55,11 @@ fn said(l: &Value) -> String {
|
||||
"result" => format!("a result{on}: {text}"),
|
||||
"correction" => format!("a correction{on}: {text}"),
|
||||
"sign" => format!("a sign-off{on} (ask {})", l["ask"]),
|
||||
// a show only to be looked at (raea show --fyi), looked at: Got it, with a word or none
|
||||
"seen" => {
|
||||
let word = text.strip_prefix("Seen").unwrap_or(&text).trim_start_matches(':').trim();
|
||||
if word.is_empty() { format!("seen{on}") } else { format!("seen{on}: {word}") }
|
||||
}
|
||||
k => format!("{}{on}: {text}", if k.is_empty() { "something" } else { k }),
|
||||
};
|
||||
format!("- {what}")
|
||||
@@ -68,6 +73,17 @@ pub fn told(agent: &str, v: &Value) -> Option<String> {
|
||||
return None;
|
||||
}
|
||||
let list = lines.iter().map(said).collect::<Vec<_>>().join("\n");
|
||||
// only Got it on what was shown to look at: nothing to take up
|
||||
if !lines.iter().any(|l| l["kind"] != "seen") {
|
||||
return Some(format!("raea: the person has looked at what you showed them (your inbox, ~/.raea/inbox/{inbox}.jsonl):\n{list}\nNothing to do about it; carry on."));
|
||||
}
|
||||
// a session started again (resumed) after the person wrote to it while it was closed (Shane 11-28: "notes reach
|
||||
// closed sessions"): what waited is handed over before anything else
|
||||
if v["hook_event_name"].as_str() == Some("SessionStart") {
|
||||
return Some(format!(
|
||||
"raea: while this session was closed, the person sent this from the raea app (your inbox, ~/.raea/inbox/{inbox}.jsonl; marked read, so the app shows it as read):\n{list}\nTake it up first, before anything else. Answer an item with raea show --on ITEM --note LINE, or post the next version with raea show FILE --replaces ITEM."
|
||||
));
|
||||
}
|
||||
Some(format!(
|
||||
"raea: the person just sent this from the raea app (your inbox, ~/.raea/inbox/{inbox}.jsonl; marked read, so the app shows it as read):\n{list}\nTake it up now, before going on: it may change what you're doing. What you say next shows under your session in their feed; answer an item with raea show --on ITEM --note LINE, or post the next version with raea show FILE --replaces ITEM."
|
||||
))
|
||||
@@ -78,11 +94,17 @@ mod tests {
|
||||
use super::*;
|
||||
use serde_json::json;
|
||||
|
||||
#[test]
|
||||
fn each_line_is_handed_over_once_and_a_half_written_one_waits() {
|
||||
let d = std::env::temp_dir().join(format!("raea-inbox-{}", std::process::id()));
|
||||
/// an empty inbox folder of the test's own
|
||||
fn scratch(tag: &str) -> std::path::PathBuf {
|
||||
let d = std::env::temp_dir().join(format!("raea-inbox-{tag}-{}", std::process::id()));
|
||||
let _ = std::fs::remove_dir_all(&d);
|
||||
std::fs::create_dir_all(&d).unwrap();
|
||||
d
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn each_line_is_handed_over_once_and_a_half_written_one_waits() {
|
||||
let d = scratch("once");
|
||||
let f = d.join("claude-code-abcd1234.jsonl");
|
||||
std::fs::write(&f, "{\"kind\":\"message\",\"text\":\"more epic\"}\n{\"kind\":\"no").unwrap();
|
||||
let first = unread(&d, "claude-code-abcd1234");
|
||||
@@ -97,6 +119,25 @@ mod tests {
|
||||
let _ = std::fs::remove_dir_all(&d);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn seen_is_said_as_seen_and_asks_nothing() {
|
||||
assert_eq!(said(&json!({"kind": "seen", "item": "i-2", "title": "Lobby", "text": "Seen"})), "- seen on item i-2 \"Lobby\"");
|
||||
assert_eq!(said(&json!({"kind": "seen", "item": "i-2", "title": "Lobby", "text": "Seen: lovely"})), "- seen on item i-2 \"Lobby\": lovely");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn what_waited_while_it_was_closed_is_handed_over_as_it_starts_again() {
|
||||
let d = scratch("start");
|
||||
std::fs::write(d.join("claude-code-5e55a0ff.jsonl"), "{\"kind\":\"edits\",\"item\":\"i-9\",\"title\":\"Cut\",\"text\":\"tighter open\"}\n").unwrap();
|
||||
// SAFETY: tests in this crate don't read RAEA_INBOX_DIR concurrently
|
||||
unsafe { std::env::set_var("RAEA_INBOX_DIR", &d) };
|
||||
let start = told("claude", &json!({"hook_event_name": "SessionStart", "source": "resume", "session_id": "5e55a0ff-1"})).unwrap();
|
||||
assert!(start.starts_with("raea: while this session was closed") && start.contains("- edits on item i-9 \"Cut\":\ntighter open"), "{start}");
|
||||
assert_eq!(told("claude", &json!({"hook_event_name": "UserPromptSubmit", "session_id": "5e55a0ff-1"})), None, "handed over once");
|
||||
unsafe { std::env::remove_var("RAEA_INBOX_DIR") };
|
||||
let _ = std::fs::remove_dir_all(&d);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_inbox_is_named_as_raea_show_names_it() {
|
||||
assert_eq!(name("claude", &json!({"session_id": "15cd6bb0-8829-466f-a28a-bbca3d35be92"})).as_deref(), Some("claude-code-15cd6bb0"));
|
||||
|
||||
@@ -4,7 +4,7 @@ version = "0.1.0"
|
||||
edition = "2024"
|
||||
license = "FSL-1.1-ALv2"
|
||||
publish = false
|
||||
description = "`raea hook`'s Stop gate for a `make` job (docs/make.feature MK2): an agent can't end its turn until `raea make status` says the job is done"
|
||||
description = "`raea hook`'s Stop gate for a `make` job (docs/goal.feature MK36): an agent can't end its turn until `raea goal check --at done` passes"
|
||||
|
||||
[dependencies]
|
||||
serde_json = "1"
|
||||
|
||||
+40
-34
@@ -1,8 +1,8 @@
|
||||
//! raea-app-check-make: the Stop hook's half of `raea make` (docs/make.feature MK2): an agent working in a project whose brief.ts has a
|
||||
//! `make` job can't end its turn until `raea make status` says the job is done. Cheap when there's no job: the brief's
|
||||
//! words are read, and only a brief with `make:` is evaluated (by `raea make status`, a child process, so this crate
|
||||
//! doesn't carry the judge). A session blocked three times with the same open items goes through: it's going in
|
||||
//! circles, and the person is better told than the agent looped (PL7's keeper stops the same way).
|
||||
//! raea-app-check-make: the Stop hook's moment of the loop (docs/goal.feature MK36): an agent working in a project with a
|
||||
//! brief.ts can't end its turn until `raea goal check --at done` passes: every goal the brief holds (or, with none, the
|
||||
//! floor) and every raea file reached from the brief (`registered`). Run by `raea goal check`, a child process, so this
|
||||
//! crate carries none of the rules. A session blocked three times with the same open items goes through: it's going in
|
||||
//! circles, and the person is better told than the agent looped.
|
||||
|
||||
use std::hash::{DefaultHasher, Hash, Hasher};
|
||||
use std::path::{Path, PathBuf};
|
||||
@@ -12,13 +12,13 @@ use serde_json::Value;
|
||||
/// How many times the same open items may block one session before the stop goes through.
|
||||
pub const SAME_BLOCKS: u32 = 3;
|
||||
|
||||
/// The brief.ts with a job, at or above `cwd` inside its raea project.
|
||||
/// The project's brief.ts, at or above `cwd` inside its raea project: every brief is held, none is an outlier.
|
||||
pub fn brief_with_job(cwd: &Path) -> Option<PathBuf> {
|
||||
let project = raea_core_facts::record::up(cwd, ".raea/project");
|
||||
for d in dunce::canonicalize(cwd).ok()?.ancestors() {
|
||||
let p = d.join("brief.ts");
|
||||
if p.is_file() {
|
||||
return std::fs::read_to_string(&p).is_ok_and(|t| t.contains("make:") || t.contains("make :")).then_some(p);
|
||||
return Some(p);
|
||||
}
|
||||
if project.as_deref() == Some(d) {
|
||||
return None;
|
||||
@@ -46,37 +46,42 @@ pub fn may_block(guard: &Path, items: &str) -> bool {
|
||||
next <= SAME_BLOCKS
|
||||
}
|
||||
|
||||
/// What the agent is told when its turn may not end, or None to let it end: no job here, the job is done, the job
|
||||
/// didn't load (never block on raea's own failure), or the same items have blocked it three times already.
|
||||
/// Each turn's status also brings the job's task in plan.org up to date (`--plan`, docs/make.feature MK3).
|
||||
/// What the agent is told when its turn may not end, or None to let it end: no job here, the job passes, the runner
|
||||
/// didn't run (never block on raea's own failure), or the same items have blocked it three times already.
|
||||
pub fn stop(v: &Value) -> Option<String> {
|
||||
let cwd = PathBuf::from(v["cwd"].as_str()?);
|
||||
let brief = brief_with_job(&cwd)?;
|
||||
let exe = std::env::current_exe().ok()?;
|
||||
let out = std::process::Command::new(exe).args(["make", "status"]).arg(brief.parent()?).args(["--json", "--plan"]).env("RAEA_RECORD", "off").output().ok()?;
|
||||
let s: Value = serde_json::from_slice(&out.stdout).ok()?;
|
||||
let out = std::process::Command::new(exe).args(["goal", "check", "--at", "done", "--json"]).current_dir(brief.parent()?).env("RAEA_RECORD", "off").output().ok()?;
|
||||
let r: Value = serde_json::from_slice(&out.stdout).ok()?;
|
||||
let home = raea_io_home::user_home()?;
|
||||
let session = v["session_id"].as_str().unwrap_or("");
|
||||
let guard = home.join(".raea/hooks/make").join(format!("{:x}", hash(&[session, &brief.display().to_string()])));
|
||||
if s["done"] == true {
|
||||
let guard = home.join(".raea/hooks/goal").join(format!("{:x}", hash(&[session, &brief.display().to_string()])));
|
||||
if r["passed"] == true {
|
||||
let _ = std::fs::remove_file(&guard);
|
||||
return None;
|
||||
}
|
||||
let items = open_items(&s);
|
||||
let items = open_items(&r);
|
||||
if !may_block(&guard, &items) {
|
||||
return None;
|
||||
}
|
||||
Some(format!(
|
||||
"Not done ({} job, {}): {items}. Keep going: `raea make status` lists what's open; a defect you judge wrong is answered in NOTES.md by its name.",
|
||||
s["kind"].as_str().unwrap_or("make"),
|
||||
brief.display()
|
||||
))
|
||||
let goals: Vec<String> = r["goals"].as_array().into_iter().flatten().filter(|g| g["passed"] != true).filter_map(|g| g["name"].as_str().map(String::from)).collect();
|
||||
let open = if goals.is_empty() { String::new() } else { format!("goal {}, ", goals.join(", ")) };
|
||||
Some(format!("Not done ({open}{}): {items}. Keep going: `raea goal check` lists each with its fix; review/goal.json holds them all.", brief.display()))
|
||||
}
|
||||
|
||||
/// The open items, one line each: what's missing, then each gate that isn't clear.
|
||||
pub fn open_items(s: &Value) -> String {
|
||||
let mut items: Vec<String> = s["missing"].as_array().into_iter().flatten().filter_map(|m| m.as_str().map(String::from)).collect();
|
||||
items.extend(s["gates"].as_array().into_iter().flatten().filter(|g| g["clear"] != true).map(|g| format!("{}{}: {}", g["gate"].as_str().unwrap_or(""), g["of"].as_str().map(|o| format!(" {o}")).unwrap_or_default(), g["says"].as_str().unwrap_or(""))));
|
||||
/// The open items, one line each: each error-level finding (its check and file), then each check that broke.
|
||||
pub fn open_items(r: &Value) -> String {
|
||||
let mut items: Vec<String> = r["findings"]
|
||||
.as_array()
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.filter(|x| x["level"] == "error")
|
||||
.map(|x| format!("{}{}: {}", x["check"].as_str().unwrap_or(""), x["file"].as_str().map(|f| format!(" {f}")).unwrap_or_default(), x["says"].as_str().unwrap_or("")))
|
||||
.collect();
|
||||
for b in r["broke"].as_array().into_iter().flatten() {
|
||||
items.push(format!("{} broke: {}", b["check"].as_str().unwrap_or(""), b["says"].as_str().unwrap_or("")));
|
||||
}
|
||||
items.join("; ")
|
||||
}
|
||||
|
||||
@@ -86,19 +91,18 @@ mod tests {
|
||||
use serde_json::json;
|
||||
|
||||
fn tmp(name: &str) -> PathBuf {
|
||||
let d = std::env::temp_dir().join(format!("raea-make-gate-{name}-{}", std::process::id()));
|
||||
let d = std::env::temp_dir().join(format!("raea-goal-gate-{name}-{}", std::process::id()));
|
||||
let _ = std::fs::remove_dir_all(&d);
|
||||
std::fs::create_dir_all(d.join("compositions")).unwrap();
|
||||
d
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn only_a_brief_with_a_job_is_held() {
|
||||
fn every_brief_is_held_with_or_without_a_goal() {
|
||||
let d = tmp("job");
|
||||
assert_eq!(brief_with_job(&d.join("compositions")), None, "no brief, nothing held");
|
||||
std::fs::write(d.join("brief.ts"), "export default brief({ title: \"x\" })").unwrap();
|
||||
assert_eq!(brief_with_job(&d.join("compositions")), None, "a brief without make is never held");
|
||||
std::fs::write(d.join("brief.ts"), "export default brief({ title: \"x\", make: kit({ objects: [] }) })").unwrap();
|
||||
assert_eq!(brief_with_job(&d.join("compositions")).map(|p| p.file_name().unwrap().to_owned()), Some("brief.ts".into()));
|
||||
assert_eq!(brief_with_job(&d.join("compositions")).map(|p| p.file_name().unwrap().to_owned()), Some("brief.ts".into()), "a brief without a goal is held to the floor and registered");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -110,10 +114,12 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn open_items_list_what_is_missing_then_the_gates_that_are_not_clear() {
|
||||
let s = json!({"missing": ["out/kit/lineup.png"], "gates": [
|
||||
{"gate": "checks", "of": "scene.tsx", "clear": false, "says": "never rendered"},
|
||||
{"gate": "critic", "clear": true, "says": "ok"}]});
|
||||
assert_eq!(open_items(&s), "out/kit/lineup.png; checks scene.tsx: never rendered");
|
||||
fn open_items_list_each_error_then_each_broken_check() {
|
||||
let r = json!({"findings": [
|
||||
{"check": "deliverables", "level": "error", "file": null, "says": "missing: out/kit/lineup.png"},
|
||||
{"check": "cta", "level": "error", "file": "out/cuts/a_9x16.mp4", "says": "no CTA in its last 8 s"},
|
||||
{"check": "place", "level": "warn", "file": "out/cuts/a_9x16.mp4", "says": "a warning holds nothing"}],
|
||||
"broke": [{"check": "mine", "says": "x is undefined"}]});
|
||||
assert_eq!(open_items(&r), "deliverables: missing: out/kit/lineup.png; cta out/cuts/a_9x16.mp4: no CTA in its last 8 s; mine broke: x is undefined");
|
||||
}
|
||||
}
|
||||
+29
-10
@@ -3,9 +3,10 @@
|
||||
//! --agent A` adds them, and they hold inside the raea app too, which leaves each agent its own shell). Before a shell
|
||||
//! command: media opened in the Mac's viewer or a browser is stopped once while the raea app is installed, the reason
|
||||
//! naming `raea show`; the same command tried again goes through, so an agent that means it says so twice. After a
|
||||
//! file is saved: the quick check on a composition. After any tool, and as a turn ends: what the person sent from the raea
|
||||
//! app (inbox.rs). A stop is exit 2 with the reason on stderr, which every harness
|
||||
//! hands its agent; the quick check's findings go back in the shape each one reads.
|
||||
//! file is saved: `raea goal check --at edit` on a composition, or on a file under a brief. As a turn ends: `raea
|
||||
//! goal check --at done` on the brief's goals (apps/check/make). After any tool, and as a turn ends: what the person sent from
|
||||
//! the raea app (inbox.rs). A stop is exit 2 with the reason on stderr, which every harness hands its agent; the edit
|
||||
//! moment's findings go back in the shape each one reads.
|
||||
use serde_json::{Value, json};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
@@ -124,6 +125,12 @@ fn saved(v: &Value) -> Vec<String> {
|
||||
patch.lines().filter_map(|l| ["*** Add File: ", "*** Update File: "].iter().find_map(|head| l.strip_prefix(head))).map(str::trim).map(String::from).collect()
|
||||
}
|
||||
|
||||
/// Whether a saved file is held at the edit moment: a composition (a .tsx that registers a root), or any file under a
|
||||
/// brief.ts
|
||||
fn held_at_edit(p: &Path) -> bool {
|
||||
(p.extension().is_some_and(|e| e == "tsx") && std::fs::read_to_string(p).is_ok_and(|t| t.contains("registerRoot"))) || p.parent().is_some_and(|d| raea_app_check_make::brief_with_job(d).is_some())
|
||||
}
|
||||
|
||||
/// Findings for the agent in the shape its harness reads after a tool: Gemini CLI's AfterTool context, Kimi Code's
|
||||
/// plain stdout, Claude Code's and Codex's PostToolUse context.
|
||||
fn after(agent: &str, text: &str) -> String {
|
||||
@@ -148,9 +155,15 @@ pub fn hook(args: &[String]) -> R<String> {
|
||||
let event = v["hook_event_name"].as_str().unwrap_or("");
|
||||
// what the person sent from the raea app since the last look (inbox.rs): handed over after any tool, and a turn about
|
||||
// to end goes on to take it up
|
||||
let sent = if matches!(event, "PostToolUse" | "AfterTool" | "Stop") { crate::inbox::told(agent, &v) } else { None };
|
||||
let sent = if matches!(event, "PostToolUse" | "AfterTool" | "Stop" | "SessionStart" | "UserPromptSubmit") { crate::inbox::told(agent, &v) } else { None };
|
||||
// a session starting again, or the person writing to it in its terminal: what they sent from raea while it was
|
||||
// closed or idle goes in as context first (Claude Code's and Codex's SessionStart and UserPromptSubmit read
|
||||
// hookSpecificOutput.additionalContext)
|
||||
if matches!(event, "SessionStart" | "UserPromptSubmit") {
|
||||
return Ok(sent.map(|t| json!({"hookSpecificOutput": {"hookEventName": event, "additionalContext": t}}).to_string()).unwrap_or_default());
|
||||
}
|
||||
if event == "Stop" {
|
||||
// what the person sent, and a `make` job that isn't done (docs/make.feature MK2): either keeps the turn going
|
||||
// what the person sent, and a brief whose goals don't pass at done (docs/goal.feature MK36): either keeps the turn going
|
||||
let reasons: Vec<String> = [sent, raea_app_check_make::stop(&v)].into_iter().flatten().collect();
|
||||
return Ok(if reasons.is_empty() { String::new() } else { json!({"decision": "block", "reason": reasons.join("\n\n")}).to_string() });
|
||||
}
|
||||
@@ -165,13 +178,19 @@ pub fn hook(args: &[String]) -> R<String> {
|
||||
}
|
||||
return Ok(String::new());
|
||||
}
|
||||
// the edit moment of the loop (docs/goal.feature MK33): `raea goal check FILE --at edit` on a saved composition, or
|
||||
// on any file under a brief; a save that passes says nothing
|
||||
let me = std::env::current_exe().map_err(|e| e.to_string())?;
|
||||
let mut found = Vec::new();
|
||||
for path in saved(&v).iter().filter(|p| p.ends_with(".tsx") && std::fs::read_to_string(p).is_ok_and(|t| t.contains("registerRoot"))) {
|
||||
let (report, _) = crate::quick::quick(std::slice::from_ref(path), Vec::new())?;
|
||||
found.extend(report.lines().skip(1).filter(|l| !l.starts_with("ok ")).map(String::from));
|
||||
for path in saved(&v).iter().filter(|p| held_at_edit(Path::new(p))) {
|
||||
let dir = Path::new(path).parent().filter(|d| d.is_dir()).map(Path::to_path_buf).unwrap_or_else(|| PathBuf::from(v["cwd"].as_str().unwrap_or(".")));
|
||||
let Ok(out) = std::process::Command::new(&me).args(["goal", "check", "--at", "edit"]).arg(path).current_dir(dir).env("RAEA_RECORD", "off").output() else { continue };
|
||||
if out.status.code() == Some(1) {
|
||||
found.extend(String::from_utf8_lossy(&out.stdout).lines().filter(|l| !l.starts_with("PASSED")).map(String::from));
|
||||
}
|
||||
}
|
||||
let quick = (!found.is_empty()).then(|| format!("raea check --quick after this save:\n{}", found.join("\n")));
|
||||
let text = [sent, quick].into_iter().flatten().collect::<Vec<_>>().join("\n\n");
|
||||
let edit = (!found.is_empty()).then(|| format!("raea goal check --at edit after this save:\n{}", found.join("\n")));
|
||||
let text = [sent, edit].into_iter().flatten().collect::<Vec<_>>().join("\n\n");
|
||||
Ok(if text.is_empty() { String::new() } else { after(agent, &text) })
|
||||
}
|
||||
|
||||
|
||||
@@ -218,7 +218,7 @@ fn report(video: &str, issues: Vec<Issue>, more: Vec<Finding>, passed: Vec<Strin
|
||||
std::fs::write(out, serde_json::to_string_pretty(&j).unwrap()).map_err(|e| format!("{out}: {e}"))?;
|
||||
}
|
||||
let mut s = format!("raea check {video}\n");
|
||||
// kept in its project's record beside its renders (DR3), what `raea findings` and `raea next` read
|
||||
// kept in its project's record beside its renders (DR3), what `raea findings` and `raea goal next` read
|
||||
let kept = raea_core_facts::record::keep("raea check", std::path::Path::new(video), out.map(std::path::Path::new), &found, vec![], &raea_io_trace::utc(std::time::SystemTime::now()).1);
|
||||
let kept = kept.map(|e| format!("raea check: kept in the project's record as {} (raea findings reads it)", e.id));
|
||||
for line in found.iter().map(Finding::line).chain(passed.iter().map(|p| format!("ok {p}"))).chain(kept) {
|
||||
|
||||
@@ -240,6 +240,16 @@ fn check_one(tsx: &Path, id: Option<String>, rules: &[Rule], args: &[String], wh
|
||||
None => hows.iter().filter(|(_, h)| matches!(h, How::Named(n) if n.render && n.name != "text-read")).for_each(|(r, _)| needs(&mut waits, r)),
|
||||
}
|
||||
}
|
||||
// traced light held still (raea light steady): with the floor, a composition lit by Solari carries what its newest
|
||||
// hold of each frame found, kept in the project's record; with none yet, it waits for one
|
||||
if floor && traced(tsx) {
|
||||
let held = light_held(tsx, id.as_deref());
|
||||
if held.is_empty() {
|
||||
let c = id.as_ref().map(|i| format!(" --composition {i}")).unwrap_or_default();
|
||||
waits.push(("light-steady".into(), format!("a held frame of its traced light (raea light steady {}{c} --frame N -o DIR)", tsx.display())));
|
||||
}
|
||||
found.extend(held.into_iter().filter(|f| f.level != Level::Note));
|
||||
}
|
||||
// the project's own checks, in one run
|
||||
let mut files: Vec<PathBuf> = Vec::new();
|
||||
let mut plan = Vec::new();
|
||||
@@ -269,6 +279,46 @@ fn check_one(tsx: &Path, id: Option<String>, rules: &[Rule], args: &[String], wh
|
||||
Ok(Checked { file: tsx.to_path_buf(), id, found: finding::ranked(found), waits, render, shots, fps })
|
||||
}
|
||||
|
||||
/// Whether a composition is lit by traced light: its file, or a .tsx beside it or a folder down, names SolariLighting.
|
||||
fn traced(tsx: &Path) -> bool {
|
||||
let mut files = vec![tsx.to_path_buf()];
|
||||
let tsxs = |d: &Path| -> Vec<PathBuf> { std::fs::read_dir(d).into_iter().flatten().flatten().map(|e| e.path()).collect() };
|
||||
if let Some(dir) = tsx.parent() {
|
||||
files.extend(tsxs(dir).into_iter().flat_map(|p| if p.is_dir() { tsxs(&p) } else { vec![p] }).filter(|p| p.extension().is_some_and(|x| x == "tsx")));
|
||||
}
|
||||
for f in files {
|
||||
if let Ok(text) = std::fs::read_to_string(&f) {
|
||||
if text.contains("SolariLighting") {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
/// The findings of the newest hold of each frame of a composition (`raea light steady`), from its project's record.
|
||||
fn light_held(tsx: &Path, id: Option<&str>) -> Vec<Finding> {
|
||||
let Some(project) = dunce::canonicalize(tsx).ok().and_then(|t| record::up(t.parent()?, ".raea/project")) else { return Vec::new() };
|
||||
let of = record::rel(&project, tsx);
|
||||
let mut newest: std::collections::BTreeMap<i64, Vec<Finding>> = std::collections::BTreeMap::new();
|
||||
for e in record::read(&project) {
|
||||
if e.by != "raea light steady" || e.of != of {
|
||||
continue;
|
||||
}
|
||||
let mut mine = Vec::new();
|
||||
for f in e.findings {
|
||||
let mut about = f.about.iter().map(|a| a.name.as_str());
|
||||
if id.is_none_or(|id| about.any(|n| n == id)) {
|
||||
mine.push(f);
|
||||
}
|
||||
}
|
||||
if let Some(frame) = mine.first().and_then(|f| f.frames) {
|
||||
newest.insert(frame[0], mine);
|
||||
}
|
||||
}
|
||||
newest.into_values().flatten().collect()
|
||||
}
|
||||
|
||||
/// Where `f` is in `files`, added at the end when it isn't yet: the one run's checks, each file once.
|
||||
fn file_index(files: &mut Vec<PathBuf>, f: &Path) -> usize {
|
||||
if let Some(at) = files.iter().position(|x| x == f) {
|
||||
@@ -360,7 +410,7 @@ pub fn check(args: &[String], host: &Host) -> R<(String, bool)> {
|
||||
// a note's ask's finding says which ask, as two asks can run one check
|
||||
out.extend(c.found.iter().map(|f| if f.by.starts_with("note ") { format!("{} [{}]", f.line(), f.by) } else { f.line() }));
|
||||
out.extend(c.waits.iter().map(|(r, w)| format!("waits {r}: needs {w}")));
|
||||
// kept in its project's record (DR3), what raea findings and raea next read
|
||||
// kept in its project's record (DR3), what raea findings and raea goal next read
|
||||
if let Some(e) = record::keep("raea check", &c.file, None, &c.found, vec![], &stamp) {
|
||||
out.push(format!("raea check: kept in the project's record as {} (raea findings reads it)", e.id));
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ fn shape(expr: &str, out: &Path, meshes: &mut BTreeMap<String, String>) -> R<Val
|
||||
// a mesh given by its own vertices (a <BufferMesh>, a three.js geometry through raea/r3f): written as it
|
||||
// is, with its normals and texture coordinates, since it needn't be a closed solid
|
||||
Some(b) => {
|
||||
let (t, uv) = raea_core_shape::buffer_tris(b)?;
|
||||
let (t, uv) = raea_core_shape::buffer_tris(&raea_core_shape::buffer_json(b)?)?;
|
||||
raea_core_shape::export_tris(&t, uv.as_deref(), &glb, "glb")?;
|
||||
raea_core_shape::export_tris(&t, uv.as_deref(), &obj, "obj")?;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ use crate::rubric::{BAR, scores};
|
||||
pub const BY: [&str; 2] = ["kimi", "claude"];
|
||||
|
||||
/// The judge prompt: the sheets by name, the brief's words, and the JSON to answer. A `raea make` job's kind asks its
|
||||
/// own categories and the bar (docs/make.feature MK5); none asks the rubric raea judge has always asked.
|
||||
/// own categories and the bar (docs/goal.feature MK5); none asks the rubric raea judge has always asked.
|
||||
pub fn prompt(kind: Option<&str>, dir: &Path, brief: &Value, target: Option<&Path>) -> String {
|
||||
match kind {
|
||||
None => prompt_default(dir, brief, target),
|
||||
|
||||
@@ -17,7 +17,7 @@ fn home() -> PathBuf {
|
||||
}
|
||||
|
||||
/// A kind's calibration file: calibration.json for the default rubric, calibration.KIND.json for a `raea make` kind's
|
||||
/// (docs/make.feature MK6), each fitted on that kind's rounds alone.
|
||||
/// (docs/goal.feature MK6), each fitted on that kind's rounds alone.
|
||||
fn file_of(kind: Option<&str>) -> PathBuf {
|
||||
home().join(kind.map_or_else(|| "calibration.json".to_string(), |k| format!("calibration.{k}.json")))
|
||||
}
|
||||
|
||||
+11
-4
@@ -6,7 +6,7 @@
|
||||
//! raea judge eye DIR composition=6 form=5 ... [--pass yes|no] (or --by kimi: an agent's reading as the eye)
|
||||
//! raea judge calibrate [--kind scene|kit|shot] [--json]
|
||||
//!
|
||||
//! `--kind` asks a `raea make` job's own rubric (docs/make.feature MK5): a scene's, a kit's or a shot list's categories,
|
||||
//! `--kind` asks a `raea make` job's own rubric (docs/goal.feature MK5): a scene's, a kit's or a shot list's categories,
|
||||
//! with the bar AnyKit's critic is given; each kind is calibrated on its own rounds (MK6).
|
||||
//!
|
||||
//! DIR/judge.json is the verdict; DIR's parent's judge.log.jsonl holds every round's, so "done" (two passes in a row,
|
||||
@@ -16,7 +16,7 @@ mod agent;
|
||||
mod eye;
|
||||
|
||||
/// Whether the judge's score gates a `raea make` kind's jobs: its calibration (`raea judge calibrate --kind KIND`)
|
||||
/// agreed with the person's eye (docs/make.feature MK6).
|
||||
/// agreed with the person's eye (docs/goal.feature MK6).
|
||||
pub fn kind_gates(kind: &str) -> bool {
|
||||
eye::calibration(Some(kind)).is_some_and(|c| c["gate"] == true)
|
||||
}
|
||||
@@ -30,7 +30,7 @@ use raea_core_facts::{Finding, Level, finding};
|
||||
use raea_runtime_bundle::flag;
|
||||
use serde_json::{Value, json};
|
||||
|
||||
pub const USAGE: &str = "raea judge DIR [--kind scene|kit|shot] [--by clef|kimi|claude] [--brief brief.ts] [--target T.png] [--json] [--dry] | judge eye DIR (CATEGORY=SCORE ... [--pass yes|no] | --by kimi|claude) | judge calibrate [--kind scene|kit|shot] [--json] (a --review folder's sheets judged blind: clef-omni on the frozen rubric, or a fresh kimi or claude session on the judge prompt; --kind asks a raea make job's own rubric (a shot list's framing.png); the pass decided in code; clef advises until calibrated against your eye or an agent's, each kind on its own)";
|
||||
pub const USAGE: &str = "raea judge DIR [--kind scene|kit|shot] [--by clef|kimi|claude] [--brief brief.ts] [--target T.png] [--json] [--dry] | judge eye DIR (CATEGORY=SCORE ... [--pass yes|no] | --by kimi|claude) | judge calibrate [--kind scene|kit|shot] [--json] (a --review folder's sheets judged blind: clef-omni on the frozen rubric, or a fresh kimi or claude session on the judge prompt; --kind asks a scene, kit or shot goal's own rubric (a shot list's framing.png); the pass decided in code; clef advises until calibrated against your eye or an agent's, each kind on its own)";
|
||||
|
||||
/// `--kind`, checked: one of the rubric's kinds, or none (the default rubric).
|
||||
pub fn kind_of(args: &[String]) -> Result<Option<String>, String> {
|
||||
@@ -58,7 +58,7 @@ fn brief_of(path: Option<&str>) -> Result<Value, String> {
|
||||
let exe = std::env::current_exe().map_err(|e| e.to_string())?;
|
||||
let out = std::process::Command::new(exe).args(["spec", p, "--as", "brief"]).output().map_err(|e| e.to_string())?;
|
||||
let text = String::from_utf8_lossy(&out.stdout);
|
||||
let start = text.find('{').ok_or_else(|| format!("judge: {p} didn't read as a brief: {}", String::from_utf8_lossy(&out.stderr).lines().last().unwrap_or("")))?;
|
||||
let start = text.find('{').ok_or_else(|| format!("judge: {p} didn't read as a brief: {}", why_refused(&out)))?;
|
||||
let v: Value = serde_json::from_str(&text[start..]).map_err(|e| format!("judge: {p}: {e}"))?;
|
||||
Ok(v.get("brief").cloned().unwrap_or(v))
|
||||
}
|
||||
@@ -226,3 +226,10 @@ fn finish(args: &[String], kind: Option<&str>, dir: &Path, scores: serde_json::M
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
/// Why `raea spec` refused a brief, in its own words: its refusal is the last line it printed, on whichever stream
|
||||
/// (a REFUSED line goes to stdout, a thrown module's error to stderr). Reading stderr alone left the reason empty.
|
||||
pub fn why_refused(out: &std::process::Output) -> String {
|
||||
let last = |b: &[u8]| String::from_utf8_lossy(b).lines().rev().find(|l| !l.trim().is_empty()).map(|l| l.trim().trim_start_matches("REFUSED").trim().to_string());
|
||||
last(&out.stderr).or_else(|| last(&out.stdout)).unwrap_or_else(|| "raea spec printed nothing".into())
|
||||
}
|
||||
@@ -32,7 +32,7 @@ pub const SCORES: [Score; 7] = [
|
||||
("world", "colour", "World: one coherent real place matching the brief; nothing off-era, no real brands, nothing invented beyond the brief."),
|
||||
];
|
||||
|
||||
/// The job kinds with a rubric of their own (docs/make.feature MK5): `raea judge DIR --kind scene|kit|shot`.
|
||||
/// The job kinds with a rubric of their own (docs/goal.feature MK5): `raea judge DIR --kind scene|kit|shot`.
|
||||
pub const KINDS: [&str; 3] = ["scene", "kit", "shot"];
|
||||
|
||||
/// A scene made to a plan (AnyScene's categories): judged on the six-camera sheets.
|
||||
@@ -79,7 +79,7 @@ pub fn scores(kind: Option<&str>) -> &'static [Score] {
|
||||
}
|
||||
}
|
||||
|
||||
/// What a kind's critic is told the bar is (AnyKit's own words, docs/make.feature MK5).
|
||||
/// What a kind's critic is told the bar is (AnyKit's own words, docs/goal.feature MK5).
|
||||
pub const BAR: &str = "The bar is a production base an artist then refines, judged at normal viewing distance: take no points off for choices that differ from the reference, don't nitpick, and name at most five fixes, most damaging first.";
|
||||
|
||||
/// The sheets a kind is judged on: the six-camera colour and clay sheets, or a shot list's framing sheet alone.
|
||||
|
||||
@@ -78,7 +78,7 @@ fn an_agent_verdict_is_read_from_the_end_of_its_thinking() {
|
||||
|
||||
#[test]
|
||||
fn each_make_kind_has_its_own_rubric_and_the_default_is_unchanged() {
|
||||
// docs/make.feature MK5: a kit's categories, a shot list's on the framing sheet alone, the bar said to each
|
||||
// docs/goal.feature MK5: a kit's categories, a shot list's on the framing sheet alone, the bar said to each
|
||||
let kit = rubric::questions_for(Some("kit"), "clay");
|
||||
for k in ["score_mesh", "score_assembly", "score_scale"] {
|
||||
assert!(kit.get(k).is_some(), "{k} in {kit}");
|
||||
@@ -117,7 +117,7 @@ fn an_agent_critic_is_asked_its_kinds_categories() {
|
||||
|
||||
#[test]
|
||||
fn a_kind_is_calibrated_on_its_own_categories() {
|
||||
// docs/make.feature MK6
|
||||
// docs/goal.feature MK6
|
||||
let s = |j: f64| -> serde_json::Map<String, Value> { rubric::KIT.iter().map(|c| (c.0.to_string(), json!(j))).collect() };
|
||||
let rows: Vec<Value> = (0..12).map(|i| if i % 2 == 0 { json!({"kind": "kit", "judge": s(8.0), "eye": s(5.0), "eye_pass": false, "defects": []}) } else { json!({"kind": "kit", "judge": s(9.0), "eye": s(8.0), "eye_pass": true, "defects": []}) }).collect();
|
||||
let cal = eye::fit_rows_for(Some("kit"), &rows);
|
||||
|
||||
@@ -4,7 +4,7 @@ version = "0.1.0"
|
||||
edition = "2024"
|
||||
license = "FSL-1.1-ALv2"
|
||||
publish = false
|
||||
description = "raea bake light: bounce light baked into lightmaps on raea's own ray tracer, and the bar it is held to against Cycles (docs/bake.feature)"
|
||||
description = "raea make bake light: bounce light baked into lightmaps on raea's own ray tracer, and the bar it is held to against Cycles (docs/bake.feature)"
|
||||
|
||||
[dependencies]
|
||||
# the frames' distance in stops, as raea light check measures it (LT1)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"about": "the bake's test set (docs/bake.feature BK0), for `raea bake light --compare DIR`: each set's Cycles still (blender/look.py, given the composition's own sky, tone and lens) and Cycles bake (blender/lightbake.py), and raea's frames beside them",
|
||||
"about": "the bake's test set (docs/bake.feature BK0), for `raea make bake light --compare DIR`: each set's Cycles still (blender/look.py, given the composition's own sky, tone and lens) and Cycles bake (blender/lightbake.py), and raea's frames beside them",
|
||||
"sets": [
|
||||
{ "name": "table", "dir": "bench/bake", "file": "table.tsx", "composition": "table", "cycles": ["table-cycles.tsx", "table-cycles"], "bar": true, "texels": 128,
|
||||
"look": ["--hdri", "media/kloofendal_48d_partly_cloudy_puresky_1k.hdr", "--strength", "0.25", "--rotation", "0.6", "--tone", "agx", "--exposure", "-0.8", "--focus", "2.5", "--fstop", "2.8", "--size", "1280x720"] },
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! `raea bake light EDIT.tsx [--composition ID] [--samples N] [--compare DIR]` (docs/bake.feature): raea's own bake of a
|
||||
//! `raea make bake light EDIT.tsx [--composition ID] [--samples N] [--compare DIR]` (docs/bake.feature): raea's own bake of a
|
||||
//! composition's static parts (BK1-BK5), and the bar it is held to (BK0). `--compare DIR` runs the test set (sets.json)
|
||||
//! through Cycles (blender/look.py's still and blender/lightbake.py's bake, both at --samples, 1024 by default) and
|
||||
//! through raea, then writes DIR/report.json and a table: each frame's RMSE and stops against the Cycles still, each
|
||||
@@ -16,7 +16,7 @@ use serde_json::{json, Value};
|
||||
use sha2::{Digest, Sha256};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
pub const USAGE: &str = "raea bake light EDIT.tsx [--composition ID] [--samples N] | raea bake light --compare DIR [--sets FILE] [--set NAME] [--samples N] [--fresh] (bounce light baked into lightmaps on raea's ray tracer; --compare measures the test set against Cycles' bake and still, docs/bake.feature)";
|
||||
pub const USAGE: &str = "raea make bake light EDIT.tsx [--composition ID] [--samples N] | raea make bake light --compare DIR [--sets FILE] [--set NAME] [--samples N] [--fresh] (bounce light baked into lightmaps on raea's ray tracer; --compare measures the test set against Cycles' bake and still, docs/bake.feature)";
|
||||
|
||||
/// One set of the test set, as sets.json lists it.
|
||||
pub struct Set {
|
||||
@@ -136,8 +136,8 @@ pub fn cli(args: &[String]) -> R<String> {
|
||||
}
|
||||
let samples: u32 = flag(args, "--samples").map(|v| v.parse().map_err(|_| format!("--samples {v}: a count of samples a texel"))).transpose()?.unwrap_or(1024);
|
||||
let Some(out) = flag(args, "--compare").map(PathBuf::from) else {
|
||||
// rask: BK5 `raea bake light EDIT.tsx` bakes a composition's <LightBake> ahead of a render and says what it baked
|
||||
return Err("raea's own bake isn't built yet (docs/bake.feature BK1-BK5); `raea bake light --compare DIR` measures the test set against Cycles".into());
|
||||
// rask: BK5 `raea make bake light EDIT.tsx` bakes a composition's <LightBake> ahead of a render and says what it baked
|
||||
return Err("raea's own bake isn't built yet (docs/bake.feature BK1-BK5); `raea make bake light --compare DIR` measures the test set against Cycles".into());
|
||||
};
|
||||
let list = sets(&flag(args, "--sets").map_or_else(|| raea_io_home::home().join("apps/lightbake/sets.json"), PathBuf::from))?;
|
||||
let only = flag(args, "--set");
|
||||
@@ -145,7 +145,7 @@ pub fn cli(args: &[String]) -> R<String> {
|
||||
std::fs::create_dir_all(&out).map_err(|e| format!("{}: {e}", out.display()))?;
|
||||
let mut reports = Vec::new();
|
||||
for s in list.iter().filter(|s| only.is_none() || only.as_deref() == Some(s.name.as_str())) {
|
||||
eprintln!("raea bake light: {} ...", s.name);
|
||||
eprintln!("raea make bake light: {} ...", s.name);
|
||||
reports.push(compare::set(s, samples, &out.join(&s.name), fresh)?);
|
||||
}
|
||||
if reports.is_empty() {
|
||||
@@ -154,5 +154,5 @@ pub fn cli(args: &[String]) -> R<String> {
|
||||
let report = json!({ "samples": samples, "sets": reports });
|
||||
let path = out.join("report.json");
|
||||
std::fs::write(&path, serde_json::to_string_pretty(&report).unwrap_or_default()).map_err(|e| e.to_string())?;
|
||||
Ok(format!("{}raea bake light: wrote {}", compare::table(&reports), path.display()))
|
||||
Ok(format!("{}raea make bake light: wrote {}", compare::table(&reports), path.display()))
|
||||
}
|
||||
@@ -4,13 +4,15 @@ version = "0.1.0"
|
||||
edition = "2024"
|
||||
license = "FSL-1.1-ALv2"
|
||||
publish = false
|
||||
description = "raea make: a scene, kit or shot held to its frozen plan; what's missing and whether it's done, decided in code (docs/make.feature)"
|
||||
description = "raea make's Rust: a scene, kit or shot job's steps, and the record and critic gates raea/goal's packs read (docs/goal.feature)"
|
||||
|
||||
[dependencies]
|
||||
# the plan: `make` on brief.ts
|
||||
raea-core-brief = { path = "../../core/brief" }
|
||||
# the project's record of renders and checks, and the folder it lives in
|
||||
raea-core-facts = { path = "../../core/facts" }
|
||||
# the parts a render showed closer than their planned detail (MK24)
|
||||
raea-runtime-lod-plan = { path = "../../runtime/lod-plan" }
|
||||
# the judge's rounds, passes and blocking defects, read as it keeps them
|
||||
raea-app-judge = { path = "../judge" }
|
||||
# the make questions, their calibrations and a sheet's ident, as raea ask keeps them (MK4)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! The second tier of the gate (docs/make.feature MK4): the `make` set of `raea ask` questions (core/ask
|
||||
//! The second tier of the gate (docs/goal.feature MK4): the `make` set of `raea ask` questions (core/ask
|
||||
//! library/make.json), asked of the job's newest sheets. A question gates once it is calibrated on the person's labels
|
||||
//! (`raea ask calibrate`: 16 problem, 16 clean, an AUC of 0.8); until then what it says is advice in the status. An
|
||||
//! (`raea ask calibrate`: 16 problem, 16 clean, an AUC of 0.8); until then what it says is advice in the gates. An
|
||||
//! answer counts for a sheet only when its call was about exactly that sheet's bytes (the ledger's `ident`), so a sheet
|
||||
//! rendered again must be asked again.
|
||||
|
||||
@@ -10,7 +10,7 @@ use std::path::{Path, PathBuf};
|
||||
use raea_core_ask::{Calibration, Question};
|
||||
use serde_json::{Value, json};
|
||||
|
||||
/// The ledger as status reads it: every call's ident by id, every answer, and the person's calibrations.
|
||||
/// The ledger as the gates read it: every call's ident by id, every answer, and the person's calibrations.
|
||||
#[derive(Default)]
|
||||
pub struct Ledger {
|
||||
pub idents: HashMap<String, String>,
|
||||
|
||||
+13
-11
@@ -1,14 +1,14 @@
|
||||
//! The plan stop (docs/make.feature MK18, from AnyScene's endpoint/floorplan.py, MIT): before anything is generated,
|
||||
//! The plan stop (docs/goal.feature MK18, from AnyScene's endpoint/floorplan.py, MIT): before anything is generated,
|
||||
//! the plan drawn so a person can approve it. A floor plan from above (every object's footprint at its `at`, turned by
|
||||
//! its `rot`, labelled; invented ones dashed, so what came from the reference and what was added are told apart), a
|
||||
//! grey-box blockout of the same plan rendered from the entrance and through `raea render --review`, and the
|
||||
//! reference beside the blockout on one comparison sheet.
|
||||
//!
|
||||
//! raea make plan [DIR] -> review/plan/floor-plan.png, blockout.tsx, blockout.png, comparison.png, colour/clay sheets
|
||||
//! raea make blockout [DIR] -> review/plan/floor-plan.png, blockout.tsx, blockout.png, comparison.png, colour/clay sheets
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use raea_core_brief::make::{Make, Object, Origin};
|
||||
use raea_core_brief::goal::{Goal, Object, Origin};
|
||||
|
||||
use crate::sheet::{Tile, esc, sheet, svg_png};
|
||||
use crate::shots::raea;
|
||||
@@ -27,7 +27,7 @@ fn height(o: &Object) -> f64 {
|
||||
}
|
||||
|
||||
/// The placed objects and the floor they span: (objects with an `at`, [x0, z0, x1, z1] with half a metre around).
|
||||
pub fn extent(m: &Make) -> (Vec<&Object>, [f64; 4]) {
|
||||
pub fn extent(m: &Goal) -> (Vec<&Object>, [f64; 4]) {
|
||||
let placed: Vec<&Object> = m.objects.iter().filter(|o| o.at.is_some()).collect();
|
||||
let mut b = [0.0f64, 0.0, 1.0, 1.0];
|
||||
for o in &placed {
|
||||
@@ -40,10 +40,10 @@ pub fn extent(m: &Make) -> (Vec<&Object>, [f64; 4]) {
|
||||
}
|
||||
|
||||
/// The floor plan as SVG: the entrance (z = 0) at the bottom, a metre grid, each footprint turned and labelled.
|
||||
pub fn floor_svg(m: &Make) -> Result<String, String> {
|
||||
pub fn floor_svg(m: &Goal) -> Result<String, String> {
|
||||
let (placed, [x0, z0, x1, z1]) = extent(m);
|
||||
if placed.is_empty() {
|
||||
return Err("raea make plan: no object has an `at` (where it stands, in metres: x right, z away from the entrance)".into());
|
||||
return Err("raea make blockout: no object has an `at` (where it stands, in metres: x right, z away from the entrance)".into());
|
||||
}
|
||||
let px = (1400.0 / (x1 - x0).max(z1 - z0)).min(260.0);
|
||||
let (w, h) = (((x1 - x0) * px).ceil() as u32 + 40, ((z1 - z0) * px).ceil() as u32 + 130);
|
||||
@@ -85,7 +85,7 @@ pub fn floor_svg(m: &Make) -> Result<String, String> {
|
||||
fd * px / 2.0
|
||||
);
|
||||
s += &format!("<text x=\"{:.1}\" y=\"{:.1}\" font-size=\"{:.0}\" fill=\"#111\" text-anchor=\"middle\">{}</text>", sx(at[0]), sy(at[2]) - t * 0.25, t, esc(&o.label));
|
||||
s += &format!("<text x=\"{:.1}\" y=\"{:.1}\" font-size=\"{:.0}\" fill=\"#555\" text-anchor=\"middle\">{:.2} m</text>", sx(at[0]), sy(at[2]) + t * 0.9, t * 0.8, height(o));
|
||||
s += &format!("<text x=\"{:.1}\" y=\"{:.1}\" font-size=\"{:.0}\" fill=\"#555\" text-anchor=\"middle\">{:.2} m{}</text>", sx(at[0]), sy(at[2]) + t * 0.9, t * 0.8, height(o), o.lod.map(|l| format!(", LOD {l}")).unwrap_or_default());
|
||||
}
|
||||
s += &format!("<line x1=\"20\" y1=\"{0}\" x2=\"{1:.1}\" y2=\"{0}\" stroke=\"#111\" stroke-width=\"5\"/><text x=\"20\" y=\"{2:.0}\" font-size=\"{3:.0}\" fill=\"#111\">1 m</text>", h - 18, 20.0 + px, h as f64 - 26.0, t * 0.9);
|
||||
s += "</svg>";
|
||||
@@ -93,7 +93,7 @@ pub fn floor_svg(m: &Make) -> Result<String, String> {
|
||||
}
|
||||
|
||||
/// The blockout: a grey box for each placed object at its place and turn on a floor, seen from the entrance.
|
||||
pub fn blockout_tsx(m: &Make) -> String {
|
||||
pub fn blockout_tsx(m: &Goal) -> String {
|
||||
let (placed, [x0, z0, x1, z1]) = extent(m);
|
||||
let mut boxes = String::new();
|
||||
for o in &placed {
|
||||
@@ -102,8 +102,10 @@ pub fn blockout_tsx(m: &Make) -> String {
|
||||
let h = height(o);
|
||||
let colour = if o.source == Some(Origin::Invented) { "#b4b0bd" } else { "#bdbdb8" };
|
||||
let a = -o.rot.unwrap_or(0.0).to_radians() / 2.0;
|
||||
let lod = o.lod.map(|l| format!(" lod={{{l}}}")).unwrap_or_default();
|
||||
boxes += &format!(
|
||||
" <Mesh3d transform={{Transform.fromXyz({:.3}, {:.3}, {:.3}).withRotation([0, {:.5}, 0, {:.5}])}}>\n <Cuboid half_size={{[{:.3}, {:.3}, {:.3}]}} />\n <StandardMaterial base_color=\"{colour}\" perceptual_roughness={{0.9}} />\n </Mesh3d>\n",
|
||||
" <Mesh3d name=\"{}\"{lod} transform={{Transform.fromXyz({:.3}, {:.3}, {:.3}).withRotation([0, {:.5}, 0, {:.5}])}}>\n <Cuboid half_size={{[{:.3}, {:.3}, {:.3}]}} />\n <StandardMaterial base_color=\"{colour}\" perceptual_roughness={{0.9}} />\n </Mesh3d>\n",
|
||||
o.id,
|
||||
at[0],
|
||||
at[1] + h / 2.0,
|
||||
at[2],
|
||||
@@ -117,7 +119,7 @@ pub fn blockout_tsx(m: &Make) -> String {
|
||||
let (cx, cz) = ((x0 + x1) / 2.0, (z0 + z1) / 2.0);
|
||||
let (fw, fd) = ((x1 - x0) / 2.0, (z1 - z0) / 2.0);
|
||||
format!(
|
||||
"// written by raea make plan: the plan as grey boxes, seen from the entrance (approve it before anything is made)\nimport {{ AbsoluteFill, Composition, registerRoot }} from \"raea\";\nimport {{ StandardMaterial }} from \"raea/pbr\";\nimport {{ Cuboid, Mesh3d }} from \"raea/mesh\";\nimport {{ AmbientLight, DirectionalLight }} from \"raea/light\";\nimport {{ Transform }} from \"raea/transform\";\nimport {{ Camera3d }} from \"raea/camera\";\n\nfunction Blockout() {{\n return (\n <AbsoluteFill style={{{{ background: \"#cfd3d6\" }}}}>\n <Camera3d transform={{Transform.fromXyz({cx:.3}, 1.6, {ez:.3}).lookingAt([{cx:.3}, 0.9, {cz:.3}])}} projection={{{{ Perspective: {{ fov: (50 * Math.PI) / 180 }} }}}} />\n <AmbientLight brightness={{350}} />\n <DirectionalLight transform={{Transform.fromXyz({lx:.3}, 6, -2).lookingAt([{cx:.3}, 0, {cz:.3}])}} illuminance={{8000}} shadow_maps_enabled />\n <Mesh3d transform={{Transform.fromXyz({cx:.3}, -0.01, {cz:.3})}}>\n <Cuboid half_size={{[{fw:.3}, 0.01, {fd:.3}]}} />\n <StandardMaterial base_color=\"#e6e3dc\" perceptual_roughness={{0.95}} />\n </Mesh3d>\n{boxes} </AbsoluteFill>\n );\n}}\n\nregisterRoot(() => <Composition id=\"blockout\" component={{Blockout}} width={{1280}} height={{720}} fps={{30}} durationInFrames={{1}} />);\n",
|
||||
"// written by raea make blockout: the plan as grey boxes, seen from the entrance (approve it before anything is made)\nimport {{ AbsoluteFill, Composition, registerRoot }} from \"raea\";\nimport {{ StandardMaterial }} from \"raea/pbr\";\nimport {{ Cuboid, Mesh3d }} from \"raea/mesh\";\nimport {{ AmbientLight, DirectionalLight }} from \"raea/light\";\nimport {{ Transform }} from \"raea/transform\";\nimport {{ Camera3d }} from \"raea/camera\";\n\nfunction Blockout() {{\n return (\n <AbsoluteFill style={{{{ background: \"#cfd3d6\" }}}}>\n <Camera3d transform={{Transform.fromXyz({cx:.3}, 1.6, {ez:.3}).lookingAt([{cx:.3}, 0.9, {cz:.3}])}} projection={{{{ Perspective: {{ fov: (50 * Math.PI) / 180 }} }}}} />\n <AmbientLight brightness={{350}} />\n <DirectionalLight transform={{Transform.fromXyz({lx:.3}, 6, -2).lookingAt([{cx:.3}, 0, {cz:.3}])}} illuminance={{8000}} shadow_maps_enabled />\n <Mesh3d transform={{Transform.fromXyz({cx:.3}, -0.01, {cz:.3})}}>\n <Cuboid half_size={{[{fw:.3}, 0.01, {fd:.3}]}} />\n <StandardMaterial base_color=\"#e6e3dc\" perceptual_roughness={{0.95}} />\n </Mesh3d>\n{boxes} </AbsoluteFill>\n );\n}}\n\nregisterRoot(() => <Composition id=\"blockout\" component={{Blockout}} width={{1280}} height={{720}} fps={{30}} durationInFrames={{1}} />);\n",
|
||||
ez = z0 - 0.4,
|
||||
lx = cx + 2.0,
|
||||
)
|
||||
@@ -128,7 +130,7 @@ pub fn plan_dir(dir: &Path) -> PathBuf {
|
||||
}
|
||||
|
||||
/// The plan stop's pictures: floor plan, blockout (and its review sheets), and the comparison with reference 0.
|
||||
pub fn draw_plan(dir: &Path, m: &Make, review: bool) -> Result<String, String> {
|
||||
pub fn draw_plan(dir: &Path, m: &Goal, review: bool) -> Result<String, String> {
|
||||
let out = plan_dir(dir);
|
||||
std::fs::create_dir_all(&out).map_err(|e| format!("{}: {e}", out.display()))?;
|
||||
let floor = out.join("floor-plan.png");
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
//! Whether a job is done (docs/make.feature MK1), from what's on disk and nothing the agent says: the deliverables, the
|
||||
//! notes, the record of renders and checks, and the judge's rounds. Pure over a `Job` so it is tested on fixtures.
|
||||
//! A scene, kit or shot job's record and critic gates (docs/goal.feature MK38), from what's on disk and nothing the agent
|
||||
//! says: the record of renders and checks, the parts seen closer than planned, the judge's rounds on the kind's rubric
|
||||
//! and the make questions asked of its sheets. `raea goal gates --json` prints them, and raea/goal's record and critic
|
||||
//! packs hold the job to them (sdk/goal/src/packs/job.ts); deliverables and notes are packs of their own. Pure over a
|
||||
//! `Job` so it is tested on fixtures.
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::time::SystemTime;
|
||||
use std::{path::{Path, PathBuf}, time::SystemTime};
|
||||
|
||||
use raea_core_brief::make::{self, Make};
|
||||
use raea_core_brief::goal::{self, Goal};
|
||||
use raea_core_facts::{Level, record::Entry};
|
||||
use serde_json::{Value, json};
|
||||
|
||||
/// The heading the notes end with, so the next job (and the skill) learns from this one.
|
||||
pub const SKILL_HEADING: &str = "What the skill got wrong";
|
||||
|
||||
/// Everything status reads, gathered by `lib.rs` (or a test).
|
||||
/// Everything the gates read, gathered by `lib.rs` (or a test).
|
||||
pub struct Job<'a> {
|
||||
pub make: &'a Make,
|
||||
pub make: &'a Goal,
|
||||
/// the brief's folder: deliverables, NOTES.md and review/ are relative to it
|
||||
pub dir: &'a Path,
|
||||
/// the project's folder (record paths are relative to it), when it is a raea project
|
||||
@@ -46,27 +45,19 @@ pub fn round_dir(dir: &Path, round: &Value) -> Option<PathBuf> {
|
||||
pub fn sheets(job: &Job) -> Vec<(&'static str, PathBuf)> {
|
||||
let mut out = Vec::new();
|
||||
if let Some(r) = job.rounds.last().and_then(|r| round_dir(job.dir, r)) {
|
||||
if job.make.kind == make::Kind::Shot {
|
||||
if job.make.kind == goal::Kind::Shot {
|
||||
out.push(("framing", r.join("framing.png")));
|
||||
} else {
|
||||
out.push(("clay", r.join("clay.png")));
|
||||
out.push(("colour", r.join("colour.png")));
|
||||
}
|
||||
}
|
||||
if job.make.kind == make::Kind::Kit {
|
||||
if job.make.kind == goal::Kind::Kit {
|
||||
out.push(("refs", job.dir.join("review/refs.png")));
|
||||
}
|
||||
out.into_iter().filter(|(_, f)| f.is_file()).collect()
|
||||
}
|
||||
|
||||
pub(crate) fn kind_name(k: make::Kind) -> &'static str {
|
||||
match k {
|
||||
make::Kind::Scene => "scene",
|
||||
make::Kind::Kit => "kit",
|
||||
make::Kind::Shot => "shot",
|
||||
}
|
||||
}
|
||||
|
||||
/// When a file last changed, and that as seconds since 1970 (a record entry's clock).
|
||||
fn mtime(p: &Path) -> Option<SystemTime> {
|
||||
std::fs::metadata(p).ok()?.modified().ok()
|
||||
@@ -136,15 +127,22 @@ fn checks(job: &Job) -> Vec<Value> {
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// MK24: parts a composition's last render showed closer than planned, held until replanned or answered (raea-runtime-lod-plan)
|
||||
fn lods(job: &Job, notes: &str) -> Vec<Value> {
|
||||
let plans = job.make.objects.iter().any(|o| o.lod.is_some());
|
||||
let last = |c: &String| job.record.iter().rev().find(|e| e.of == job.project.map(|p| raea_core_facts::record::rel(p, &job.dir.join(c))).unwrap_or_else(|| c.clone()));
|
||||
job.make.compositions.iter().filter_map(|c| last(c).and_then(|l| raea_runtime_lod_plan::gate(c, &l.id, &l.findings, notes, plans)).map(|(clear, says)| gate("lod", Some(c), clear, says))).collect()
|
||||
}
|
||||
|
||||
/// Tier 3: a fresh critic has judged a round newer than the newest deliverable, and each blocking defect it named is
|
||||
/// fixed (the round passed) or answered in NOTES.md by its name. Its score gates once the judge is calibrated.
|
||||
fn critic(job: &Job, newest: Option<SystemTime>, notes: &str) -> Vec<Value> {
|
||||
let Some(last) = job.rounds.last() else {
|
||||
let kind = kind_name(job.make.kind);
|
||||
let kind = job.make.kind.name();
|
||||
let what = match job.make.kind {
|
||||
make::Kind::Kit => "raea render shared/components/KIT/lineup.tsx --review review/r1",
|
||||
make::Kind::Shot => "raea make framing --out review/r1",
|
||||
make::Kind::Scene => "raea render EDIT.tsx --review review/r1",
|
||||
goal::Kind::Kit => "raea render shared/components/KIT/lineup.tsx --review review/r1",
|
||||
goal::Kind::Shot => "raea make framing --out review/r1",
|
||||
goal::Kind::Scene | goal::Kind::Cut | goal::Kind::Rules => "raea render EDIT.tsx --review review/r1",
|
||||
};
|
||||
return vec![gate("critic", None, false, format!("no round yet: {what}, then raea judge review/r1 --kind {kind} --by claude --brief brief.ts"))];
|
||||
};
|
||||
@@ -156,7 +154,7 @@ fn critic(job: &Job, newest: Option<SystemTime>, notes: &str) -> Vec<Value> {
|
||||
};
|
||||
out.push(gate("critic", None, fresh, if fresh { format!("round {} judged after the newest deliverable", job.rounds.len()) } else { "the newest deliverable came after the last round: review and judge it again".into() }));
|
||||
// the kind's own rubric (MK5): a round judged on another's doesn't count
|
||||
let kind = kind_name(job.make.kind);
|
||||
let kind = job.make.kind.name();
|
||||
if last["kind"].as_str() != Some(kind) {
|
||||
let dir = last["dir"].as_str().unwrap_or("review/rN");
|
||||
out.push(gate("rubric", None, false, format!("the last round wasn't judged on the {kind} rubric: raea judge {dir} --kind {kind} --by claude")));
|
||||
@@ -173,68 +171,32 @@ fn critic(job: &Job, newest: Option<SystemTime>, notes: &str) -> Vec<Value> {
|
||||
out
|
||||
}
|
||||
|
||||
/// The job's status: what's missing, each gate, the judge's rounds, and whether the agent may stop.
|
||||
pub fn status(job: &Job) -> Value {
|
||||
let mut missing = Vec::new();
|
||||
let mut newest: Option<SystemTime> = None;
|
||||
for want in make::deliverables(job.make) {
|
||||
match answered(job.dir, &want) {
|
||||
Ok(files) => newest = files.iter().filter_map(|f| mtime(f)).chain(newest).max(),
|
||||
Err(why) => missing.push(why),
|
||||
}
|
||||
}
|
||||
/// The job's gates: each, whether all are clear, and why it's delivered short (out of rounds, or stalled) when it is.
|
||||
pub fn gates(job: &Job) -> Value {
|
||||
// the newest deliverable: a round judged before it is stale (the deliverables pack says what's missing)
|
||||
let newest = goal::deliverables(job.make).iter().filter_map(|w| answered(job.dir, w).ok()).flatten().filter_map(|f| mtime(&f)).max();
|
||||
let notes = notes_text(job.dir).unwrap_or_default();
|
||||
if !notes.to_lowercase().contains(&SKILL_HEADING.to_lowercase()) {
|
||||
missing.push(format!("NOTES.md with a \"{SKILL_HEADING}\" section (one line per thing that cost time; what the guide got wrong for this job)"));
|
||||
}
|
||||
let mut gates = checks(job);
|
||||
gates.extend(lods(job, ¬es));
|
||||
gates.extend(critic(job, newest, ¬es));
|
||||
let (asks, said) = crate::asked::gates(&sheets(job), job.ledger, ¬es);
|
||||
gates.extend(asks);
|
||||
let cap = job.make.rounds.unwrap_or(make::ROUNDS) as usize;
|
||||
let capped = job.rounds.len() >= cap;
|
||||
let stalled = stalled(job.rounds);
|
||||
let clear = missing.is_empty() && gates.iter().all(|g| g["clear"] == true);
|
||||
let mut why = Vec::new();
|
||||
if capped && !clear {
|
||||
why.push(format!("capped: {} critic rounds, the most this job gets; delivered with what's still missing", job.rounds.len()));
|
||||
let cap = job.make.rounds.unwrap_or(goal::ROUNDS) as usize;
|
||||
let clear = gates.iter().all(|g| g["clear"] == true);
|
||||
let mut short = Vec::new();
|
||||
if job.rounds.len() >= cap && !clear {
|
||||
short.push(format!("capped: {} critic rounds, the most this job gets; delivered with what's still open", job.rounds.len()));
|
||||
}
|
||||
if stalled && !clear {
|
||||
why.push("stalled: three rounds without beating the best before them; delivered with what's still missing".into());
|
||||
if stalled(job.rounds) && !clear {
|
||||
short.push("stalled: three rounds without beating the best before them; delivered with what's still open".to_string());
|
||||
}
|
||||
let advice = raea_app_judge::progress(job.rounds);
|
||||
json!({
|
||||
"kind": job.make.kind,
|
||||
"done": clear || capped || stalled,
|
||||
"short": !clear && (capped || stalled),
|
||||
"missing": missing,
|
||||
"clear": clear,
|
||||
"short": short,
|
||||
"gates": gates,
|
||||
"judge": {"rounds": job.rounds.len(), "cap": cap, "passesInARow": advice["passesInARow"], "changeApproach": advice["stall"], "again": advice["again"]},
|
||||
"plan": make::doctor(job.make),
|
||||
"advice": said,
|
||||
"why": why,
|
||||
})
|
||||
}
|
||||
|
||||
/// The status for a person or an agent to read.
|
||||
pub fn text(s: &Value) -> String {
|
||||
let mut t = vec![format!("make: {} {}", s["kind"].as_str().unwrap_or("?"), if s["done"] == true { if s["short"] == true { "delivered short" } else { "done" } } else { "not done" })];
|
||||
for w in s["why"].as_array().into_iter().flatten() {
|
||||
t.push(format!(" {}", w.as_str().unwrap_or("")));
|
||||
}
|
||||
for (key, head) in [("plan", "plan:"), ("missing", "missing:"), ("advice", "advice (raea ask, not calibrated yet):")] {
|
||||
let items: Vec<&str> = s[key].as_array().into_iter().flatten().filter_map(Value::as_str).collect();
|
||||
if !items.is_empty() {
|
||||
t.push(head.into());
|
||||
t.extend(items.iter().map(|i| format!(" {i}")));
|
||||
}
|
||||
}
|
||||
t.push("gates:".into());
|
||||
for g in s["gates"].as_array().into_iter().flatten() {
|
||||
let of = g["of"].as_str().map(|o| format!(" {o}")).unwrap_or_default();
|
||||
t.push(format!(" {} {}{of}: {}", if g["clear"] == true { "ok " } else { "open" }, g["gate"].as_str().unwrap_or(""), g["says"].as_str().unwrap_or("")));
|
||||
}
|
||||
let j = &s["judge"];
|
||||
t.push(format!("judge: {} of {} rounds, {} passes in a row{}", j["rounds"], j["cap"], j["passesInARow"], if j["changeApproach"] == true { "; the same defect keeps coming back: change the approach for that part, not the dose" } else { "" }));
|
||||
t.join("\n")
|
||||
}
|
||||
+11
-11
@@ -1,4 +1,4 @@
|
||||
//! A kit's steps (docs/make.feature MK10-MK12, from AnyKit): every object's reference made in one style from the
|
||||
//! A kit's steps (docs/goal.feature MK10-MK12, from AnyKit): every object's reference made in one style from the
|
||||
//! style images, checked on one sheet before any 3D; each reference to both generators (Tripo H3.1 and Meshy, on fal)
|
||||
//! and the pick made on clay renders (kitout.rs draws the pick sheets); the pick fitted to its real size with a
|
||||
//! quarter-triangle LOD beside it, each with a sidecar saying how it was made.
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use raea_core_brief::make::{Make, Object};
|
||||
use raea_core_brief::goal::{Goal, Object};
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use crate::sheet::{Tile, sheet};
|
||||
@@ -27,12 +27,12 @@ const HERO_FACES: u32 = 150_000;
|
||||
const PROP_FACES: u32 = 60_000;
|
||||
|
||||
/// The objects named in `--only` (all when it's empty).
|
||||
pub fn objects<'a>(m: &'a Make, only: &[String]) -> Vec<&'a Object> {
|
||||
pub fn objects<'a>(m: &'a Goal, only: &[String]) -> Vec<&'a Object> {
|
||||
crate::only(&m.objects, only, |o| o.id.as_str())
|
||||
}
|
||||
|
||||
/// The prompt a reference is made from: the plan's style paragraph, the object's own words, the scan template.
|
||||
pub fn ref_prompt(m: &Make, o: &Object) -> String {
|
||||
pub fn ref_prompt(m: &Goal, o: &Object) -> String {
|
||||
let style = m.style.as_deref().unwrap_or("").trim().trim_end_matches('.');
|
||||
let what = o.prompt.as_deref().unwrap_or(&o.label).trim().trim_end_matches('.');
|
||||
format!("{style}. {what}. {SCAN}")
|
||||
@@ -105,7 +105,7 @@ pub fn refs_dir(dir: &Path) -> PathBuf {
|
||||
}
|
||||
|
||||
/// Every object's reference, made from the style images (`references`) in the plan's style; then the sheet.
|
||||
pub fn refs(dir: &Path, m: &Make, only: &[String], model: Option<&str>, dry: bool) -> Result<String, String> {
|
||||
pub fn refs(dir: &Path, m: &Goal, only: &[String], model: Option<&str>, dry: bool) -> Result<String, String> {
|
||||
if m.references.is_empty() {
|
||||
return Err("raea make refs: the plan has no `references` (the style images every reference is made from)".into());
|
||||
}
|
||||
@@ -144,7 +144,7 @@ pub fn refs(dir: &Path, m: &Make, only: &[String], model: Option<&str>, dry: boo
|
||||
}
|
||||
|
||||
/// The reference sheet: the style images first, then every object's reference, labelled with its id and size.
|
||||
pub fn sheet_refs(dir: &Path, m: &Make) -> Result<String, String> {
|
||||
pub fn sheet_refs(dir: &Path, m: &Goal) -> Result<String, String> {
|
||||
let style: Vec<Tile> = m.references.iter().enumerate().map(|(i, r)| Tile { img: dir.join(r), label: format!("style {}", i + 1) }).collect();
|
||||
let refs: Vec<Tile> = m
|
||||
.objects
|
||||
@@ -162,7 +162,7 @@ pub fn sheet_refs(dir: &Path, m: &Make) -> Result<String, String> {
|
||||
}
|
||||
|
||||
/// The flow that sends one reference to both generators, each at its face limit.
|
||||
pub fn gen_flow(m: &Make, o: &Object, reference: &Path, tripo: &str, meshy: &str) -> Value {
|
||||
pub fn gen_flow(m: &Goal, o: &Object, reference: &Path, tripo: &str, meshy: &str) -> Value {
|
||||
let faces = if o.hero == Some(true) { HERO_FACES } else { PROP_FACES };
|
||||
let prompt = o.prompt.clone().unwrap_or_else(|| o.label.clone());
|
||||
let _ = m;
|
||||
@@ -178,7 +178,7 @@ pub fn gen_dir(dir: &Path, id: &str) -> PathBuf {
|
||||
}
|
||||
|
||||
/// Every reference to both generators: out/kit/gen/ID/tripo.glb and meshy.glb.
|
||||
pub fn generate(dir: &Path, m: &Make, only: &[String], tripo: &str, meshy: &str, dry: bool) -> Result<String, String> {
|
||||
pub fn generate(dir: &Path, m: &Goal, only: &[String], tripo: &str, meshy: &str, dry: bool) -> Result<String, String> {
|
||||
let mut said = Vec::new();
|
||||
let mut spent = 0.0;
|
||||
for o in objects(m, only) {
|
||||
@@ -229,7 +229,7 @@ pub fn picks(dir: &Path) -> serde_json::Map<String, Value> {
|
||||
}
|
||||
|
||||
/// One object's pick and why, recorded (MK11).
|
||||
pub fn choose(dir: &Path, m: &Make, id: &str, generator: &str, why: &str) -> Result<String, String> {
|
||||
pub fn choose(dir: &Path, m: &Goal, id: &str, generator: &str, why: &str) -> Result<String, String> {
|
||||
if !m.objects.iter().any(|o| o.id == id) {
|
||||
return Err(format!("raea make pick: no object `{id}` in the plan"));
|
||||
}
|
||||
@@ -256,7 +256,7 @@ fn triangles(glb: &Path) -> Result<u64, String> {
|
||||
|
||||
/// Each pick fitted to its real size (front -Y, bottom-centre, metres) and a quarter-triangle LOD1 beside it, each
|
||||
/// with a sidecar saying how it was made (MK12).
|
||||
pub fn prep(dir: &Path, m: &Make, only: &[String]) -> Result<String, String> {
|
||||
pub fn prep(dir: &Path, m: &Goal, only: &[String]) -> Result<String, String> {
|
||||
let p = picks(dir);
|
||||
let mut said = Vec::new();
|
||||
for o in objects(m, only) {
|
||||
@@ -284,7 +284,7 @@ pub fn prep(dir: &Path, m: &Make, only: &[String]) -> Result<String, String> {
|
||||
// the sidecar the Blender scripts carry along (source, licence, credit) and how it was made: ours, generated
|
||||
let made = |what: &str, tris: u64| {
|
||||
json!({"source": format!("generated by raea make: {model} from out/kit/refs/{}.png", o.id), "license": "ours (generated for this project)", "credit": "",
|
||||
"made": {"by": "raea make (docs/make.feature)", "route": "gen", "generator": generator, "model": model, "why": pick["why"], "prompt": o.prompt, "reference": format!("out/kit/refs/{}.png", o.id),
|
||||
"made": {"by": "raea make (docs/goal.feature)", "route": "gen", "generator": generator, "model": model, "why": pick["why"], "prompt": o.prompt, "reference": format!("out/kit/refs/{}.png", o.id),
|
||||
"style": m.style, "what": what, "triangles": tris, "source": if o.source.is_some() { json!(o.source) } else { Value::Null }}})
|
||||
};
|
||||
std::fs::write(full.with_extension("glb.json"), serde_json::to_string_pretty(&made("fitted to its real size", tris)).unwrap_or_default()).map_err(|e| e.to_string())?;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! The kit's sheets and its landing (docs/make.feature MK11, MK13): the pick sheet (each object's reference beside
|
||||
//! The kit's sheets and its landing (docs/goal.feature MK11, MK13): the pick sheet (each object's reference beside
|
||||
//! both generators' models, each in colour and in clay, drawn in raea), and the kit landed as a component set (one
|
||||
//! component per object, its model and LOD imported beside it, so it travels as one folder), a `<Lineup>` of them all
|
||||
//! with a scale bar, a thumb each, and kit.json.
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use raea_core_brief::make::{Make, Object};
|
||||
use raea_core_brief::goal::{Goal, Object};
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use crate::kit::{gen_dir, objects, picks};
|
||||
@@ -53,7 +53,7 @@ pub fn draw(model: &Path, h: f64) -> Result<(PathBuf, PathBuf), String> {
|
||||
}
|
||||
|
||||
/// The pick sheet: a row an object, its reference, then each generator's model fitted to size, in colour and in clay.
|
||||
pub fn pick_sheet(dir: &Path, m: &Make, only: &[String]) -> Result<String, String> {
|
||||
pub fn pick_sheet(dir: &Path, m: &Goal, only: &[String]) -> Result<String, String> {
|
||||
let mut rows = Vec::new();
|
||||
for o in objects(m, only) {
|
||||
let g = gen_dir(dir, &o.id);
|
||||
@@ -99,7 +99,7 @@ pub fn component_name(id: &str) -> String {
|
||||
pub fn component(o: &Object, why: &str) -> String {
|
||||
let n = component_name(&o.id);
|
||||
format!(
|
||||
"// raea component add: {label}, {h} m, from the kit's style (raea make kit; {why})\nimport {{ Model }} from \"raea/3d\";\nimport full from \"./{id}.glb\";\nimport far from \"./{id}_lod1.glb\";\n\ntype Props = {{\n position?: [number, number, number];\n rotation?: [number, number, number];\n /** the quarter-triangle model, for when it's small on screen */\n lod?: boolean;\n}};\n\n/** {label}: fitted to its real size, its bottom at the origin, its front toward +z. */\nexport default function {n}({{ position = [0, 0, 0], rotation = [0, 0, 0], lod = false }}: Props) {{\n return <Model src={{lod ? far : full}} position={{position}} rotation={{rotation}} />;\n}}\n",
|
||||
"// raea make component add: {label}, {h} m, from the kit's style (raea make kit; {why})\nimport {{ Model }} from \"raea/3d\";\nimport full from \"./{id}.glb\";\nimport far from \"./{id}_lod1.glb\";\n\ntype Props = {{\n position?: [number, number, number];\n rotation?: [number, number, number];\n /** the quarter-triangle model, for when it's small on screen */\n lod?: boolean;\n}};\n\n/** {label}: fitted to its real size, its bottom at the origin, its front toward +z. */\nexport default function {n}({{ position = [0, 0, 0], rotation = [0, 0, 0], lod = false }}: Props) {{\n return <Model src={{lod ? far : full}} position={{position}} rotation={{rotation}} />;\n}}\n",
|
||||
label = o.label,
|
||||
h = tall(o),
|
||||
id = o.id,
|
||||
@@ -109,7 +109,7 @@ pub fn component(o: &Object, why: &str) -> String {
|
||||
|
||||
/// The lineup: every component side by side in the plan's order, gaps between, a label each lying in front of the pieces and a
|
||||
/// scale bar (the longest round length the set covers), seen from a little right of centre and above.
|
||||
pub fn lineup(m: &Make, kit: &str) -> String {
|
||||
pub fn lineup(m: &Goal, kit: &str) -> String {
|
||||
let mut imports = String::new();
|
||||
let mut parts = String::new();
|
||||
let mut x = 0.0;
|
||||
@@ -176,7 +176,7 @@ fn copy(a: &Path, b: &Path) -> Result<(), String> {
|
||||
|
||||
/// The kit landed: each prepped object's model, LOD and sidecars, its component and thumb; the lineup and its cover
|
||||
/// render; kit.json. Objects not prepped yet are named, not skipped silently.
|
||||
pub fn land(dir: &Path, m: &Make, name: Option<&str>, to: Option<&str>) -> Result<String, String> {
|
||||
pub fn land(dir: &Path, m: &Goal, name: Option<&str>, to: Option<&str>) -> Result<String, String> {
|
||||
let kit = name.map(str::to_string).unwrap_or_else(|| dir.file_name().map(|f| f.to_string_lossy().to_string()).unwrap_or("kit".into()));
|
||||
let dest = kit_dir(dir, &kit, to);
|
||||
std::fs::create_dir_all(dest.join("thumbs")).map_err(|e| format!("{}: {e}", dest.display()))?;
|
||||
@@ -214,10 +214,10 @@ pub fn land(dir: &Path, m: &Make, name: Option<&str>, to: Option<&str>) -> Resul
|
||||
std::fs::write(&lineup_tsx, lineup(m, &kit)).map_err(|e| e.to_string())?;
|
||||
let cover = dest.join("cover.png");
|
||||
raea(&["render".into(), lineup_tsx.display().to_string(), "-o".into(), cover.display().to_string(), "--frame".into(), "0".into()], &[])?;
|
||||
let doc = json!({"kit": kit, "style": m.style, "references": m.references, "items": items, "lineup": "lineup.tsx", "cover": "cover.png", "landed": dest.display().to_string(), "made": {"by": "raea make kit (docs/make.feature MK13)"}});
|
||||
let doc = json!({"kit": kit, "style": m.style, "references": m.references, "items": items, "lineup": "lineup.tsx", "cover": "cover.png", "landed": dest.display().to_string(), "made": {"by": "raea make kit (docs/goal.feature MK13)"}});
|
||||
let text = serde_json::to_string_pretty(&doc).unwrap_or_default();
|
||||
std::fs::write(dest.join("kit.json"), &text).map_err(|e| e.to_string())?;
|
||||
// the job's own record of it, what `raea make status` counts (core/brief deliverables)
|
||||
// the job's own record of it, what raea/goal's deliverables pack counts
|
||||
std::fs::write(dir.join("out/kit/kit.json"), &text).map_err(|e| e.to_string())?;
|
||||
copy(&cover, &dir.join("out/kit/lineup.png"))?;
|
||||
Ok(format!("landed the {kit} kit ({} pieces) in {}: components, lineup.tsx, cover.png, thumbs/, kit.json", items.len(), dest.display()))
|
||||
|
||||
+61
-60
@@ -1,26 +1,27 @@
|
||||
//! `raea make`: a scene, kit or shot made to its frozen plan (`make` on brief.ts, core/brief make.rs) and held to the
|
||||
//! review loop (docs/make.feature). `status` decides, in code, what's missing and whether the agent may stop; the Stop
|
||||
//! hook (apps/check hook.rs) asks it at the end of every turn.
|
||||
//! The asset tools for a scene, kit or shot goal (docs/goal.feature): `raea make blockout|refs|...` build to the goal's
|
||||
//! frozen plan (`goal` on brief.ts, core/brief goal.rs), and `raea goal gates` gives the record and critic gates
|
||||
//! raea/goal's packs read. The loop itself, every rule at its moments, is TypeScript: `raea goal check|tasks|seen|judge`
|
||||
//! run sdk/goal/src/run.ts (engine/cli verbs.rs goal_ts).
|
||||
//!
|
||||
//! raea make status [DIR] [--json] [--plan] (--plan: the gates as check lines in plan.org, MK3)
|
||||
//! raea make plan|refs|sheet refs|gen|pick-sheet|pick|prep|kit|framing|lenschart ... (the steps, USAGE)
|
||||
//! raea goal gates [DIR] [--goal NAME] --json (the record and critic gates of a scene, kit or shot goal)
|
||||
//! raea make blockout|refs|sheet refs|gen|pick-sheet|pick|prep|kit|framing|lenschart ... (the steps, USAGE)
|
||||
|
||||
pub mod asked;
|
||||
pub mod floor;
|
||||
pub mod kit;
|
||||
pub mod kitout;
|
||||
pub mod plan;
|
||||
pub mod sheet;
|
||||
pub mod shots;
|
||||
pub mod status;
|
||||
pub mod gates;
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use raea_core_brief::make::Make;
|
||||
use raea_core_brief::goal::Goal;
|
||||
use serde_json::Value;
|
||||
|
||||
pub const USAGE: &str = "raea make status [DIR] [--json] [--plan] (a scene, kit or shot held to its plan, `make` on brief.ts: what's missing, each gate (renders and checks, raea ask's calibrated questions, the critic on the kind's rubric), the judge's rounds, and whether it's done, decided in code; --plan writes the gates as check lines under the job's task in plan.org; the agent's Stop hook holds it there)
|
||||
raea make plan [DIR] [--no-review] (the plan stop: review/plan/floor-plan.png, a grey-box blockout from the entrance and its review sheets, comparison.png beside reference 0)
|
||||
pub const USAGE: &str = "raea make place FILE [--at S[,S...]] [--box WxH] (the clearest places in a shot for a text box that size, in a 1080-wide frame)
|
||||
raea goal gates [DIR] [--goal NAME] --json (a scene, kit or shot goal's record and critic gates, as raea/goal's packs read them)
|
||||
raea make blockout [DIR] [--no-review] (a scene's blockout stop: review/plan/floor-plan.png, a grey-box blockout from the entrance and its review sheets, comparison.png beside reference 0)
|
||||
raea make refs [DIR] [--only ID,...] [--model M] [--dry] (a kit: every object's reference from the style images, in the plan's style, then review/refs.png; --dry quotes it)
|
||||
raea make sheet refs [DIR] (review/refs.png again: the style images, then every reference)
|
||||
raea make gen [DIR] [--only ID,...] [--tripo M] [--meshy M] [--dry] (each reference to both generators, Tripo H3.1 and Meshy on fal: out/kit/gen/ID/)
|
||||
@@ -47,23 +48,45 @@ pub fn brief_path(dir: &Path) -> Option<PathBuf> {
|
||||
None
|
||||
}
|
||||
|
||||
/// Whether a brief.ts has a job at all, read from its words: cheap enough for a hook at every turn's end, so the
|
||||
/// Whether a brief.ts has a goal at all, read from its words: cheap enough for a hook at every turn's end, so the
|
||||
/// module is only evaluated when it can matter.
|
||||
pub fn has_make(brief: &Path) -> bool {
|
||||
std::fs::read_to_string(brief).is_ok_and(|t| t.contains("make:") || t.contains("make :"))
|
||||
pub fn has_goal(brief: &Path) -> bool {
|
||||
std::fs::read_to_string(brief).is_ok_and(|t| t.contains("goal:") || t.contains("goal :"))
|
||||
}
|
||||
|
||||
/// The plan from brief.ts, evaluated by `raea spec FILE --as brief` (the module runs; Rust checks it against core/brief).
|
||||
pub fn read_make(brief: &Path) -> Result<Option<Make>, String> {
|
||||
/// The goals of brief.ts, evaluated by `raea spec FILE --as brief` (the module runs; Rust checks it against core/brief).
|
||||
pub fn read_goals(brief: &Path) -> Result<Vec<Goal>, String> {
|
||||
let exe = std::env::current_exe().map_err(|e| e.to_string())?;
|
||||
let out = std::process::Command::new(exe).arg("spec").arg(brief).args(["--as", "brief"]).env("RAEA_RECORD", "off").output().map_err(|e| e.to_string())?;
|
||||
let text = String::from_utf8_lossy(&out.stdout);
|
||||
let start = text.find('{').ok_or_else(|| format!("{} didn't read as a brief: {}", brief.display(), String::from_utf8_lossy(&out.stderr).lines().last().unwrap_or("")))?;
|
||||
let start = text.find('{').ok_or_else(|| format!("{} didn't read as a brief: {}", brief.display(), raea_app_judge::why_refused(&out)))?;
|
||||
let v: Value = serde_json::from_str(&text[start..]).map_err(|e| format!("{}: {e}", brief.display()))?;
|
||||
let b = v.get("brief").cloned().unwrap_or(v);
|
||||
match b.get("make") {
|
||||
None | Some(Value::Null) => Ok(None),
|
||||
Some(m) => serde_json::from_value(m.clone()).map(Some).map_err(|e| format!("{}: make: {e}", brief.display())),
|
||||
match b.get("goal") {
|
||||
None | Some(Value::Null) => Ok(vec![]),
|
||||
Some(g) => {
|
||||
let gs: raea_core_brief::goal::Goals = serde_json::from_value(g.clone()).map_err(|e| format!("{}: goal: {e}", brief.display()))?;
|
||||
Ok(gs.all().into_iter().cloned().collect())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The scene, kit or shot goal the asset tools build to: the one named, else the only one of those kinds.
|
||||
pub fn read_goal(brief: &Path) -> Result<Option<Goal>, String> {
|
||||
read_goal_named(brief, None)
|
||||
}
|
||||
|
||||
pub fn read_goal_named(brief: &Path, name: Option<&str>) -> Result<Option<Goal>, String> {
|
||||
use raea_core_brief::goal::{name_of, Kind};
|
||||
let all = read_goals(brief)?;
|
||||
if let Some(n) = name {
|
||||
return all.into_iter().find(|g| name_of(g) == n).map(Some).ok_or_else(|| format!("{}: no goal is named {n}", brief.display()));
|
||||
}
|
||||
let mut built: Vec<Goal> = all.into_iter().filter(|g| matches!(g.kind, Kind::Scene | Kind::Kit | Kind::Shot)).collect();
|
||||
match built.len() {
|
||||
0 => Ok(None),
|
||||
1 => Ok(built.pop()),
|
||||
_ => Err(format!("{}: several scene, kit or shot goals ({}): name one with --goal", brief.display(), built.iter().map(name_of).collect::<Vec<_>>().join(", "))),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +96,7 @@ fn judged(dir: &Path) -> (Vec<Value>, Option<Value>, Option<std::time::SystemTim
|
||||
let log = dir.join("review").join("judge.log.jsonl");
|
||||
let rounds: Vec<Value> = std::fs::read_to_string(&log).unwrap_or_default().lines().filter_map(|l| serde_json::from_str(l).ok()).collect();
|
||||
let verdict = rounds.last().and_then(|r| {
|
||||
let d = status::round_dir(dir, r)?;
|
||||
let d = gates::round_dir(dir, r)?;
|
||||
let file = r["by"].as_str().filter(|b| *b != "clef").map_or_else(|| "judge.json".to_string(), |b| format!("judge.{b}.json"));
|
||||
serde_json::from_str(&std::fs::read_to_string(d.join(file)).ok()?).ok()
|
||||
});
|
||||
@@ -81,28 +104,21 @@ fn judged(dir: &Path) -> (Vec<Value>, Option<Value>, Option<std::time::SystemTim
|
||||
(rounds, verdict, at)
|
||||
}
|
||||
|
||||
/// The status of the job whose brief is at `brief`, with its plan already read.
|
||||
pub fn status_of(brief: &Path, make: &Make) -> Value {
|
||||
/// The record and critic gates of the job whose brief is at `brief`, with its plan already read.
|
||||
pub fn gates_of(brief: &Path, make: &Goal) -> Value {
|
||||
let dir = brief.parent().unwrap_or(Path::new("."));
|
||||
let project = raea_core_facts::record::up(dir, ".raea/project");
|
||||
let record = project.as_deref().map(raea_core_facts::record::read).unwrap_or_default();
|
||||
let (rounds, verdict, judged_at) = judged(dir);
|
||||
let ledger = asked::Ledger::read();
|
||||
let job = status::Job { make, dir, project: project.as_deref(), record: &record, rounds: &rounds, verdict: verdict.as_ref(), judged_at, ledger: &ledger, score_gates: raea_app_judge::kind_gates(status::kind_name(make.kind)) };
|
||||
let mut s = status::status(&job);
|
||||
let job = gates::Job { make, dir, project: project.as_deref(), record: &record, rounds: &rounds, verdict: verdict.as_ref(), judged_at, ledger: &ledger, score_gates: raea_app_judge::kind_gates(make.kind.name()) };
|
||||
let mut s = gates::gates(&job);
|
||||
s["brief"] = Value::String(brief.display().to_string());
|
||||
s
|
||||
}
|
||||
|
||||
/// For the hook: the job's status from a folder, None when there's no job there (no brief.ts, or no `make` on it).
|
||||
pub fn status_in(dir: &Path) -> Result<Option<Value>, String> {
|
||||
let Some(brief) = brief_path(dir).filter(|b| has_make(b)) else { return Ok(None) };
|
||||
let Some(make) = read_make(&brief)? else { return Ok(None) };
|
||||
Ok(Some(status_of(&brief, &make)))
|
||||
}
|
||||
|
||||
/// The flags that take a value: what follows them isn't a positional argument.
|
||||
const VALUED: [&str; 7] = ["--only", "--model", "--tripo", "--meshy", "--name", "--to", "--out"];
|
||||
const VALUED: [&str; 9] = ["--only", "--model", "--tripo", "--meshy", "--name", "--to", "--out", "--by", "--goal"];
|
||||
|
||||
fn flag<'a>(args: &'a [String], k: &str) -> Option<&'a str> {
|
||||
args.iter().position(|a| a == k).and_then(|i| args.get(i + 1)).map(String::as_str)
|
||||
@@ -137,10 +153,10 @@ pub(crate) fn only<'a, T>(all: &'a [T], only: &[String], name: impl Fn(&T) -> &s
|
||||
}
|
||||
|
||||
/// The job's brief and plan from a folder.
|
||||
fn job(dir: &Path) -> Result<(PathBuf, Make), String> {
|
||||
let brief = brief_path(dir).ok_or_else(|| format!("raea make: no brief.ts at or above {} in its project", dir.display()))?;
|
||||
let make = read_make(&brief)?.ok_or_else(|| format!("raea make: {} has no `make` (scene(), kit() or shot() from raea/brief)", brief.display()))?;
|
||||
Ok((brief, make))
|
||||
fn job(dir: &Path, name: Option<&str>) -> Result<(PathBuf, Goal), String> {
|
||||
let brief = brief_path(dir).ok_or_else(|| format!("no brief.ts at or above {} in its project", dir.display()))?;
|
||||
let goal = read_goal_named(&brief, name)?.ok_or_else(|| format!("{} has no scene, kit or shot goal (`goal: scene({{...}})`, kit() or shot() from raea/brief)", brief.display()))?;
|
||||
Ok((brief, goal))
|
||||
}
|
||||
|
||||
/// The steps: each reads the plan from DIR's brief.ts and works beside it.
|
||||
@@ -156,13 +172,13 @@ fn step(verb: &str, args: &[String]) -> Result<String, String> {
|
||||
return Err(USAGE.into());
|
||||
}
|
||||
let dir = pos.get(dir_at).map(PathBuf::from).unwrap_or_else(|| PathBuf::from("."));
|
||||
let (brief, m) = job(&dir)?;
|
||||
let (brief, m) = job(&dir, flag(args, "--goal"))?;
|
||||
let here = brief.parent().unwrap_or(Path::new(".")).to_path_buf();
|
||||
let only = list(args, "--only");
|
||||
let dry = args.iter().any(|a| a == "--dry");
|
||||
let out_or = |d: PathBuf| flag(args, "--out").map(PathBuf::from).unwrap_or(d);
|
||||
match verb {
|
||||
"plan" => floor::draw_plan(&here, &m, !args.iter().any(|a| a == "--no-review")),
|
||||
"blockout" => floor::draw_plan(&here, &m, !args.iter().any(|a| a == "--no-review")),
|
||||
"refs" => kit::refs(&here, &m, &only, flag(args, "--model"), dry),
|
||||
"sheet" => match args.get(2).map(String::as_str) {
|
||||
Some("refs") => kit::sheet_refs(&here, &m),
|
||||
@@ -183,29 +199,14 @@ fn step(verb: &str, args: &[String]) -> Result<String, String> {
|
||||
|
||||
pub fn cli(args: &[String]) -> Result<String, String> {
|
||||
match args.get(1).map(String::as_str) {
|
||||
Some("status") => {}
|
||||
Some(v @ ("plan" | "refs" | "sheet" | "gen" | "pick-sheet" | "pick" | "prep" | "kit" | "framing" | "lenschart")) => return step(v, args),
|
||||
_ => return Err(USAGE.into()),
|
||||
Some("gates") => {
|
||||
let dir = positional(args, 2).first().map(PathBuf::from).unwrap_or_else(|| PathBuf::from("."));
|
||||
let (brief, make) = job(&dir, flag(args, "--goal"))?;
|
||||
Ok(serde_json::to_string_pretty(&gates_of(&brief, &make)).unwrap_or_default())
|
||||
}
|
||||
Some(v @ ("blockout" | "refs" | "sheet" | "gen" | "pick-sheet" | "pick" | "prep" | "kit" | "framing" | "lenschart")) => step(v, args),
|
||||
_ => Err(USAGE.into()),
|
||||
}
|
||||
let dir = positional(args, 2).first().map(PathBuf::from).unwrap_or_else(|| PathBuf::from("."));
|
||||
let (brief, make) = job(&dir)?;
|
||||
let mut s = status_of(&brief, &make);
|
||||
if args.iter().any(|a| a == "--plan") {
|
||||
let dir = brief.parent().unwrap_or(Path::new("."));
|
||||
let root = raea_core_facts::record::up(dir, ".raea/project").unwrap_or_else(|| dir.to_path_buf());
|
||||
let kind = s["kind"].as_str().unwrap_or("make").to_string();
|
||||
let (file, task) = plan::write(&root, &brief, &kind, &s)?;
|
||||
s["planOrg"] = Value::String(file.display().to_string());
|
||||
s["planTask"] = Value::String(task);
|
||||
}
|
||||
if args.iter().any(|a| a == "--json") {
|
||||
return Ok(serde_json::to_string_pretty(&s).unwrap_or_default());
|
||||
}
|
||||
let mut t = status::text(&s);
|
||||
if let (Some(p), Some(task)) = (s["planOrg"].as_str(), s["planTask"].as_str()) {
|
||||
t.push_str(&format!("\nplan.org: the gates are check lines under task {task} in {p}"));
|
||||
}
|
||||
Ok(t)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
//! The job's gates in the project's plan.org (docs/make.feature MK3; docs/plan.feature PL1): one task, its :ID: from the
|
||||
//! brief's path, each gate and each missing thing a check line under it with a progress cookie, so the person, the app
|
||||
//! and raea cloud read the same list the Stop hook holds the agent to. MAKING while it isn't done, REVIEW once it is
|
||||
//! (the person closes it); a task the person marked DONE or DROPPED keeps their mark, and their own lines under it stay.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use serde_json::Value;
|
||||
|
||||
/// The task's id: t- and eight letters and digits (PL1b), the same for the same brief.
|
||||
pub fn task_id(brief_rel: &str) -> String {
|
||||
let h = brief_rel.bytes().fold(0xcbf2_9ce4_8422_2325u64, |h, b| (h ^ b as u64).wrapping_mul(0x0100_0000_01b3));
|
||||
format!("t-mk{:06x}", h & 0xff_ffff)
|
||||
}
|
||||
|
||||
fn is_check(line: &str) -> bool {
|
||||
let t = line.trim_start();
|
||||
let rest = t.strip_prefix("- ").or_else(|| t.strip_prefix("+ "));
|
||||
rest.is_some_and(|r| r.starts_with("[ ]") || r.starts_with("[X]") || r.starts_with("[x]") || r.starts_with("[-]"))
|
||||
}
|
||||
|
||||
fn short(s: &str) -> String {
|
||||
let s = s.replace('\n', " ");
|
||||
if s.chars().count() > 140 { format!("{}…", s.chars().take(139).collect::<String>()) } else { s }
|
||||
}
|
||||
|
||||
/// The check lines for a status: what's missing, then each gate.
|
||||
pub fn checks(status: &Value) -> Vec<(bool, String)> {
|
||||
let mut out: Vec<(bool, String)> = Vec::new();
|
||||
for m in status["missing"].as_array().into_iter().flatten().filter_map(Value::as_str) {
|
||||
out.push((false, format!("missing: {}", short(m))));
|
||||
}
|
||||
for g in status["gates"].as_array().into_iter().flatten() {
|
||||
let of = g["of"].as_str().map(|o| format!(" {o}")).unwrap_or_default();
|
||||
out.push((g["clear"] == true, format!("{}{of}: {}", g["gate"].as_str().unwrap_or("gate"), short(g["says"].as_str().unwrap_or("")))));
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// plan.org's text with the job's task brought up to date (made at the end when it isn't there).
|
||||
pub fn update(text: &str, title: &str, brief_rel: &str, kind: &str, status: &Value) -> String {
|
||||
let id = task_id(brief_rel);
|
||||
let lines: Vec<&str> = text.lines().collect();
|
||||
let done = status["done"] == true;
|
||||
let cs = checks(status);
|
||||
let cookie = format!("[{}/{}]", cs.iter().filter(|c| c.0).count(), cs.len());
|
||||
let check_lines: Vec<String> = cs.iter().map(|(d, t)| format!("- [{}] {t}", if *d { "X" } else { " " })).collect();
|
||||
let id_line = lines.iter().position(|l| l.trim() == format!(":ID: {id}") || l.trim() == format!(":ID: {id}"));
|
||||
let Some(id_at) = id_line else {
|
||||
let mut out = if text.trim().is_empty() { format!("#+TITLE: {title}\n#+TODO: TODO MAKING REVIEW | DONE DROPPED\n") } else { text.trim_end().to_string() + "\n" };
|
||||
out.push_str(&format!("\n* {} make: {kind} ({brief_rel}) {cookie}\n:PROPERTIES:\n:ID: {id}\n:KIND: make\n:VERB: {kind}\n:END:\n", if done { "REVIEW" } else { "MAKING" }));
|
||||
out.push_str(&(check_lines.join("\n") + "\n"));
|
||||
return out;
|
||||
};
|
||||
let head = (0..id_at).rev().find(|&i| lines[i].starts_with('*')).unwrap_or(0);
|
||||
let stars = lines[head].chars().take_while(|c| *c == '*').count();
|
||||
let end = (id_at + 1..lines.len()).find(|&i| lines[i].starts_with('*') && lines[i].chars().take_while(|c| *c == '*').count() <= stars).unwrap_or(lines.len());
|
||||
let drawer_end = (id_at..end).find(|&i| lines[i].trim() == ":END:").unwrap_or(id_at);
|
||||
// the headline: its keyword brought up to date unless the person closed it, its cookie replaced
|
||||
let words: Vec<&str> = lines[head][stars..].split_whitespace().collect();
|
||||
let kw = words.first().copied().unwrap_or("");
|
||||
let closed = kw == "DONE" || kw == "DROPPED";
|
||||
let rest: Vec<&str> = words.iter().skip(if ["TODO", "MAKING", "REVIEW", "DONE", "DROPPED"].contains(&kw) { 1 } else { 0 }).copied().filter(|w| !(w.starts_with('[') && w.ends_with(']') && w.contains('/'))).collect();
|
||||
let kw = if closed { kw } else if done { "REVIEW" } else { "MAKING" };
|
||||
let headline = format!("{} {kw} {} {cookie}", "*".repeat(stars), rest.join(" "));
|
||||
let theirs: Vec<&str> = lines[drawer_end + 1..end].iter().copied().filter(|l| !is_check(l)).collect();
|
||||
let mut out: Vec<String> = lines[..head].iter().map(|l| l.to_string()).collect();
|
||||
out.push(headline);
|
||||
out.extend(lines[head + 1..=drawer_end].iter().map(|l| l.to_string()));
|
||||
out.extend(check_lines);
|
||||
out.extend(theirs.iter().map(|l| l.to_string()));
|
||||
out.extend(lines[end..].iter().map(|l| l.to_string()));
|
||||
out.join("\n") + "\n"
|
||||
}
|
||||
|
||||
/// Writes the job's task into plan.org at the top of `root` (the project's folder, else the brief's): the file and the
|
||||
/// task's id.
|
||||
pub fn write(root: &Path, brief: &Path, kind: &str, status: &Value) -> Result<(std::path::PathBuf, String), String> {
|
||||
let file = root.join("plan.org");
|
||||
let rel = brief.strip_prefix(root).unwrap_or(brief).to_string_lossy().replace('\\', "/");
|
||||
let title = root.file_name().map(|n| n.to_string_lossy().to_string()).unwrap_or_else(|| "plan".into());
|
||||
let text = std::fs::read_to_string(&file).unwrap_or_default();
|
||||
let next = update(&text, &title, &rel, kind, status);
|
||||
if next != text {
|
||||
replace(&file, &next).map_err(|e| format!("{}: {e}", file.display()))?;
|
||||
}
|
||||
Ok((file, task_id(&rel)))
|
||||
}
|
||||
|
||||
/// A file's text replaced: written beside it, then moved over it, so a reader never sees half a plan.
|
||||
fn replace(file: &Path, text: &str) -> std::io::Result<()> {
|
||||
let tmp = file.with_extension("org.tmp");
|
||||
std::fs::write(&tmp, text)?;
|
||||
std::fs::rename(&tmp, file)
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
//! The contact sheets a gate looks at (docs/make.feature MK10, MK11, MK15): pictures in rows, each labelled under it,
|
||||
//! The contact sheets a gate looks at (docs/goal.feature MK10, MK11, MK15): pictures in rows, each labelled under it,
|
||||
//! a title over them, on one PNG a person, `raea ask` and the critic read at once. Labels are drawn by resvg in the
|
||||
//! system's own fonts; an SVG drawn whole (the floor plan, MK18) goes through `svg_png`.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! Blocking a shot list (docs/make.feature MK15): `raea make framing` renders each shot's first, middle and last
|
||||
//! Blocking a shot list (docs/goal.feature MK15): `raea make framing` renders each shot's first, middle and last
|
||||
//! frame and puts them on one sheet, a row a shot, each stamped with its name and time, so the person, `raea ask`
|
||||
//! (make.framing.*) and the critic (`raea judge --kind shot`) see every shot's start and end at once; `raea make
|
||||
//! lenschart SHOT` renders a shot's first frame at 18, 24, 35, 50, 85 and 135 mm (RAEA_LENS, core/review) to choose its
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use raea_core_brief::make::{Make, Shot};
|
||||
use raea_core_brief::goal::{Goal, Shot};
|
||||
|
||||
use crate::sheet::{Tile, sheet};
|
||||
|
||||
@@ -62,7 +62,7 @@ fn composition(dir: &Path, s: &Shot) -> Result<PathBuf, String> {
|
||||
}
|
||||
|
||||
/// The framing sheet of the plan's shots (or those named in `only`), written to `out` (OUT/framing.png).
|
||||
pub fn framing(dir: &Path, m: &Make, only: &[String], out: &Path) -> Result<String, String> {
|
||||
pub fn framing(dir: &Path, m: &Goal, only: &[String], out: &Path) -> Result<String, String> {
|
||||
let shots: Vec<&Shot> = crate::only(&m.shots, only, |s| s.name.as_str());
|
||||
if shots.is_empty() {
|
||||
return Err("raea make framing: no shots in the plan (or none named)".into());
|
||||
@@ -86,7 +86,7 @@ pub fn framing(dir: &Path, m: &Make, only: &[String], out: &Path) -> Result<Stri
|
||||
}
|
||||
|
||||
/// One shot's first frame at every lens of the chart, on one sheet (OUT/lens-SHOT.png).
|
||||
pub fn lenschart(dir: &Path, m: &Make, name: &str, out: &Path) -> Result<String, String> {
|
||||
pub fn lenschart(dir: &Path, m: &Goal, name: &str, out: &Path) -> Result<String, String> {
|
||||
let s = m.shots.iter().find(|s| s.name == name).ok_or_else(|| format!("raea make lenschart: no shot `{name}` in the plan"))?;
|
||||
let tsx = composition(dir, s)?;
|
||||
let work = out.join("lens-frames").join(name);
|
||||
|
||||
+39
-65
@@ -1,12 +1,12 @@
|
||||
use std::path::PathBuf;
|
||||
use std::time::{Duration, SystemTime};
|
||||
|
||||
use raea_core_brief::{make::Make, read};
|
||||
use raea_core_brief::{goal::Goal, read};
|
||||
use raea_core_facts::record::Entry;
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use crate::asked::Ledger;
|
||||
use crate::status::{Job, status, stalled};
|
||||
use crate::gates::{Job, gates, stalled};
|
||||
|
||||
fn dir(name: &str) -> PathBuf {
|
||||
let d = std::env::temp_dir().join(format!("raea-make-{name}-{}", std::process::id()));
|
||||
@@ -21,7 +21,7 @@ fn put(d: &PathBuf, rel: &str, text: &str) {
|
||||
std::fs::write(p, text).unwrap();
|
||||
}
|
||||
|
||||
fn kit() -> Make {
|
||||
fn kit() -> Goal {
|
||||
read("make", r#"{"kind": "kit", "style": "1970s desk, maker Aurora", "objects": [{"id": "phone", "label": "Phone", "h": 0.12, "prompt": "a rotary phone"}]}"#).unwrap()
|
||||
}
|
||||
|
||||
@@ -36,35 +36,25 @@ fn round(pass: bool, mean: f64, defects: Value) -> Value {
|
||||
json!({"dir": "review/r1", "kind": "kit", "pass": pass, "mean": mean, "defects": defects})
|
||||
}
|
||||
|
||||
fn run(make: &Make, d: &PathBuf, record: &[Entry], rounds: &[Value], judged_at: Option<SystemTime>) -> Value {
|
||||
fn run(make: &Goal, d: &PathBuf, record: &[Entry], rounds: &[Value], judged_at: Option<SystemTime>) -> Value {
|
||||
run_with(make, d, record, rounds, judged_at, &Ledger::default())
|
||||
}
|
||||
|
||||
fn run_with(make: &Make, d: &PathBuf, record: &[Entry], rounds: &[Value], judged_at: Option<SystemTime>, ledger: &Ledger) -> Value {
|
||||
status(&Job { make, dir: d, project: None, record, rounds, verdict: None, judged_at, ledger, score_gates: false })
|
||||
fn run_with(make: &Goal, d: &PathBuf, record: &[Entry], rounds: &[Value], judged_at: Option<SystemTime>, ledger: &Ledger) -> Value {
|
||||
gates(&Job { make, dir: d, project: None, record, rounds, verdict: None, judged_at, ledger, score_gates: false })
|
||||
}
|
||||
|
||||
fn later() -> Option<SystemTime> {
|
||||
Some(SystemTime::now() + Duration::from_secs(5))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nothing_made_is_not_done_and_says_what_is_missing() {
|
||||
let d = dir("empty");
|
||||
let s = run(&kit(), &d, &[], &[], None);
|
||||
assert_eq!(s["done"], false);
|
||||
let missing = s["missing"].to_string();
|
||||
assert!(missing.contains("out/kit/phone/phone_lod1.glb") && missing.contains("NOTES.md"), "{missing}");
|
||||
assert!(s["gates"].as_array().unwrap().iter().any(|g| g["gate"] == "critic" && g["clear"] == false));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn delivered_and_judged_after_is_done() {
|
||||
let d = dir("done");
|
||||
delivered(&d);
|
||||
let s = run(&kit(), &d, &[], &[round(true, 7.5, json!([]))], later());
|
||||
assert_eq!(s["done"], true, "{s:#}");
|
||||
assert_eq!(s["short"], false);
|
||||
assert_eq!(s["clear"], true, "{s:#}");
|
||||
assert_eq!(s["short"], json!([]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -72,7 +62,7 @@ fn a_round_older_than_the_newest_deliverable_is_stale() {
|
||||
let d = dir("stale");
|
||||
delivered(&d);
|
||||
let s = run(&kit(), &d, &[], &[round(true, 7.5, json!([]))], Some(SystemTime::UNIX_EPOCH));
|
||||
assert_eq!(s["done"], false);
|
||||
assert_eq!(s["clear"], false);
|
||||
assert!(s["gates"].to_string().contains("came after the last round"), "{s:#}");
|
||||
}
|
||||
|
||||
@@ -82,25 +72,27 @@ fn a_blocking_defect_must_be_fixed_or_answered_in_the_notes() {
|
||||
delivered(&d);
|
||||
let defects = json!([{"defect": "floating", "present": true, "level": "blocking"}]);
|
||||
let s = run(&kit(), &d, &[], &[round(false, 6.0, defects.clone())], later());
|
||||
assert_eq!(s["done"], false);
|
||||
assert_eq!(s["clear"], false);
|
||||
assert!(s["gates"].to_string().contains("floating"));
|
||||
put(&d, "NOTES.md", "## What the skill got wrong\n- floating: the handset rests in its cradle; the judge read its shadow as a gap\n");
|
||||
let s = run(&kit(), &d, &[], &[round(false, 6.0, defects.clone())], later());
|
||||
assert_eq!(s["done"], true, "{s:#}");
|
||||
assert_eq!(s["clear"], true, "{s:#}");
|
||||
// once the judge is calibrated for kits, its score gates too: two passes in a row (MK6)
|
||||
let (rounds, ledger) = ([round(false, 6.0, defects)], Ledger::default());
|
||||
let s = status(&Job { make: &kit(), dir: &d, project: None, record: &[], rounds: &rounds, verdict: None, judged_at: later(), ledger: &ledger, score_gates: true });
|
||||
assert_eq!(s["done"], false, "{s:#}");
|
||||
let s = gates(&Job { make: &kit(), dir: &d, project: None, record: &[], rounds: &rounds, verdict: None, judged_at: later(), ledger: &ledger, score_gates: true });
|
||||
assert_eq!(s["clear"], false, "{s:#}");
|
||||
assert!(s["gates"].to_string().contains("two needed"), "{s:#}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn at_the_cap_it_is_delivered_short() {
|
||||
let d = dir("cap");
|
||||
let rounds: Vec<Value> = (0..8).map(|i| round(false, 5.0 + i as f64 * 0.5, json!([]))).collect();
|
||||
// eight rounds, the last still blocked by a defect no one answered
|
||||
let blocked = json!([{"defect": "floating", "present": true, "level": "blocking"}]);
|
||||
let rounds: Vec<Value> = (0..8).map(|i| round(false, 5.0 + i as f64 * 0.5, blocked.clone())).collect();
|
||||
let s = run(&kit(), &d, &[], &rounds, later());
|
||||
assert_eq!((s["done"].clone(), s["short"].clone()), (json!(true), json!(true)), "{s:#}");
|
||||
assert!(s["why"].to_string().contains("capped"));
|
||||
assert_eq!(s["clear"], false, "{s:#}");
|
||||
assert!(s["short"].to_string().contains("capped"), "{s:#}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -129,34 +121,41 @@ fn a_composition_needs_a_clean_check_newer_than_it() {
|
||||
let s = run(&make, &d, &[entry(future, "error")], &rounds, later());
|
||||
assert!(s["gates"].to_string().contains("the mug floats"), "{s:#}");
|
||||
let s = run(&make, &d, &[entry(future, "warn")], &rounds, later());
|
||||
assert_eq!(s["done"], true, "a warn doesn't block: {s:#}");
|
||||
assert_eq!(s["clear"], true, "a warn doesn't block: {s:#}");
|
||||
let s = run(&make, &d, &[entry(1, "warn")], &rounds, later());
|
||||
assert!(s["gates"].to_string().contains("changed since"), "{s:#}");
|
||||
}
|
||||
|
||||
// MK24: a part a render showed closer than planned holds the job until it's replanned or answered in the notes
|
||||
#[test]
|
||||
fn a_scene_wants_three_stills() {
|
||||
let d = dir("scene");
|
||||
let make: Make = read("make", r#"{"kind": "scene", "objects": [{"id": "stool", "label": "Stool", "h": 0.45, "route": "gen", "prompt": "a red stool"}]}"#).unwrap();
|
||||
put(&d, "out/stills/a.png", "x");
|
||||
let s = run(&make, &d, &[], &[], None);
|
||||
assert!(s["missing"].to_string().contains("holds 1 picture"), "{s:#}");
|
||||
fn a_part_seen_closer_than_planned_holds_the_job() {
|
||||
let d = dir("lod");
|
||||
delivered(&d);
|
||||
put(&d, "scene.tsx", "x");
|
||||
let mut make = kit();
|
||||
make.compositions = vec!["scene.tsx".into()];
|
||||
let future = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap().as_secs() + 60;
|
||||
let entry: Entry = serde_json::from_value(json!({"id": "r1", "at": future, "by": "raea render", "of": "scene.tsx", "findings": [{"check": "lod-closer", "level": "warn", "about": [{"name": "kiosk"}], "says": "'kiosk' is planned at LOD 3", "by": "raea render"}]})).unwrap();
|
||||
let s = run(&make, &d, &[entry.clone()], &[round(true, 7.5, json!([]))], later());
|
||||
assert!(s["clear"] == false && s["gates"].to_string().contains("seen closer than planned at r1: kiosk"), "{s:#}");
|
||||
put(&d, "NOTES.md", "- lod kiosk: one frame at the cut, left as a box\n## What the skill got wrong\n- nothing\n");
|
||||
assert_eq!(run(&make, &d, &[entry], &[round(true, 7.5, json!([]))], later())["clear"], true);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_round_judged_on_another_kinds_rubric_does_not_count() {
|
||||
// docs/make.feature MK5: a kit is judged on the kit's rubric
|
||||
// docs/goal.feature MK5: a kit is judged on the kit's rubric
|
||||
let d = dir("rubric");
|
||||
delivered(&d);
|
||||
let old = json!({"dir": "review/r1", "pass": true, "mean": 8.0, "defects": []});
|
||||
let s = run(&kit(), &d, &[], &[old], later());
|
||||
assert_eq!(s["done"], false);
|
||||
assert_eq!(s["clear"], false);
|
||||
assert!(s["gates"].to_string().contains("--kind kit"), "{s:#}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_calibrated_ask_question_gates_and_an_uncalibrated_one_advises() {
|
||||
// docs/make.feature MK4
|
||||
// docs/goal.feature MK4
|
||||
let d = dir("ask");
|
||||
delivered(&d);
|
||||
put(&d, "review/r1/clay.png", "clay sheet bytes");
|
||||
@@ -166,12 +165,12 @@ fn a_calibrated_ask_question_gates_and_an_uncalibrated_one_advises() {
|
||||
let mut ledger = Ledger::default();
|
||||
// nothing calibrated: every question is advice, and the job is done
|
||||
let s = run_with(&kit(), &d, &[], &rounds, later(), &ledger);
|
||||
assert_eq!(s["done"], true, "{s:#}");
|
||||
assert_eq!(s["clear"], true, "{s:#}");
|
||||
assert!(s["gates"].to_string().contains("advice only"), "{s:#}");
|
||||
// floating calibrated on the person's labels: it must be asked of this exact clay sheet
|
||||
ledger.calibrations.insert(floating.version(), serde_json::from_value(json!({"auc": 0.9, "n": 40, "positives": 16, "threshold": 0.4, "date": "2026-11-23", "by": "you"})).unwrap());
|
||||
let s = run_with(&kit(), &d, &[], &rounds, later(), &ledger);
|
||||
assert_eq!(s["done"], false);
|
||||
assert_eq!(s["clear"], false);
|
||||
let gates = s["gates"].to_string();
|
||||
assert!(gates.contains("not asked of this clay sheet") && gates.contains("--std make.clay.floating"), "{gates}");
|
||||
// asked, and it flagged: open until fixed or answered by its id in NOTES.md
|
||||
@@ -179,11 +178,11 @@ fn a_calibrated_ask_question_gates_and_an_uncalibrated_one_advises() {
|
||||
ledger.idents.insert("c-1".into(), ident);
|
||||
ledger.answers.push(json!({"id": "a-1", "at": "100", "call": "c-1", "question": "make.clay.floating", "flagged": true, "problem": 0.8}));
|
||||
let s = run_with(&kit(), &d, &[], &rounds, later(), &ledger);
|
||||
assert_eq!(s["done"], false);
|
||||
assert_eq!(s["clear"], false);
|
||||
assert!(s["gates"].to_string().contains("make.clay.floating flagged (p 0.80)"), "{s:#}");
|
||||
put(&d, "NOTES.md", "## What the skill got wrong\n- make.clay.floating: the handset's shadow, not a gap; checked on the low tile\n");
|
||||
let s = run_with(&kit(), &d, &[], &rounds, later(), &ledger);
|
||||
assert_eq!(s["done"], true, "{s:#}");
|
||||
assert_eq!(s["clear"], true, "{s:#}");
|
||||
// the sheet rendered again: the old answer was about other bytes, so it's asked again
|
||||
put(&d, "review/r1/clay.png", "a new clay sheet");
|
||||
let s = run_with(&kit(), &d, &[], &rounds, later(), &ledger);
|
||||
@@ -195,28 +194,3 @@ fn a_calibrated_ask_question_gates_and_an_uncalibrated_one_advises() {
|
||||
let s = run_with(&kit(), &d, &[], &rounds, later(), &ledger);
|
||||
assert!(s["advice"].to_string().contains("make.colour.plastic says yes"), "{s:#}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_gates_are_check_lines_under_the_jobs_task_in_plan_org() {
|
||||
// docs/make.feature MK3
|
||||
let not_done = json!({"done": false, "missing": ["out/kit/lineup.png"], "gates": [{"gate": "critic", "clear": false, "says": "no round yet"}, {"gate": "checks", "of": "kit.tsx", "clear": true, "says": "clean"}]});
|
||||
let t = crate::plan::update("", "desk", "brief.ts", "kit", ¬_done);
|
||||
let id = crate::plan::task_id("brief.ts");
|
||||
assert!(id.len() == 10 && id.starts_with("t-") && id[2..].chars().all(|c| c.is_ascii_alphanumeric()), "{id}");
|
||||
assert!(t.starts_with("#+TITLE: desk\n#+TODO: TODO MAKING REVIEW | DONE DROPPED\n"), "{t}");
|
||||
assert!(t.contains("* MAKING make: kit (brief.ts) [1/3]") && t.contains(&format!(":ID: {id}")), "{t}");
|
||||
assert!(t.contains("- [ ] missing: out/kit/lineup.png") && t.contains("- [X] checks kit.tsx: clean"), "{t}");
|
||||
// the person's own line under it stays; the checks are brought up to date; done is REVIEW
|
||||
let mut mine = t.replace("- [X] checks kit.tsx: clean\n", "- [X] checks kit.tsx: clean\nShane: keep the phone's cord\n");
|
||||
mine = format!("{mine}* TODO another task\n");
|
||||
let done = json!({"done": true, "missing": [], "gates": [{"gate": "critic", "clear": true, "says": "round 2 judged"}]});
|
||||
let t2 = crate::plan::update(&mine, "desk", "brief.ts", "kit", &done);
|
||||
assert!(t2.contains("* REVIEW make: kit (brief.ts) [1/1]") && t2.contains("Shane: keep the phone's cord") && t2.contains("* TODO another task"), "{t2}");
|
||||
assert!(!t2.contains("missing:"), "{t2}");
|
||||
assert_eq!(t2.matches(":ID: ").count(), 1);
|
||||
// a task the person closed keeps their mark
|
||||
let closed = t2.replace("* REVIEW make", "* DONE make");
|
||||
assert!(crate::plan::update(&closed, "desk", "brief.ts", "kit", ¬_done).contains("* DONE make: kit (brief.ts) [1/3]"));
|
||||
// once written, writing the same again changes nothing
|
||||
assert_eq!(crate::plan::update(&t2, "desk", "brief.ts", "kit", &done), t2);
|
||||
}
|
||||
@@ -109,7 +109,7 @@ fn the_kit_lands_as_components_and_a_lineup() {
|
||||
let m = kit();
|
||||
assert_eq!(crate::kitout::component_name("rotary_phone"), "RotaryPhone");
|
||||
let c = crate::kitout::component(&m.objects[0], "sharper numerals");
|
||||
assert!(c.starts_with("// raea component add: Rotary phone, 0.12 m"), "{c}");
|
||||
assert!(c.starts_with("// raea make component add: Rotary phone, 0.12 m"), "{c}");
|
||||
assert!(c.contains("import full from \"./rotary_phone.glb\";") && c.contains("import far from \"./rotary_phone_lod1.glb\";"));
|
||||
assert!(c.contains("export default function RotaryPhone("));
|
||||
let l = crate::kitout::lineup(&m, "desk");
|
||||
@@ -156,7 +156,7 @@ fn a_shot_frames_its_start_middle_and_end() {
|
||||
fn the_plan_draws_a_floor_plan_and_a_blockout() {
|
||||
let m: Make = read("make", r#"{"kind": "scene", "references": ["media/ref.png"], "objects": [
|
||||
{"id": "desk", "label": "Desk", "dims": [1.6, 0.8, 0.75], "at": [2, 0, 3], "rot": 90, "source": "reference", "hero": true},
|
||||
{"id": "plant", "label": "Plant", "h": 1.2, "at": [0.5, 0, 4], "source": "invented"},
|
||||
{"id": "plant", "label": "Plant", "h": 1.2, "at": [0.5, 0, 4], "source": "invented", "lod": 3},
|
||||
{"id": "pen", "label": "Pen", "max": 0.14}]}"#)
|
||||
.unwrap();
|
||||
let (placed, b) = crate::floor::extent(&m);
|
||||
@@ -172,6 +172,7 @@ fn the_plan_draws_a_floor_plan_and_a_blockout() {
|
||||
let t = crate::floor::blockout_tsx(&m);
|
||||
assert_eq!(t.matches("<Cuboid").count(), 3, "the floor and two boxes");
|
||||
assert!(t.contains("half_size={[0.800, 0.375, 0.400]}"), "{t}");
|
||||
assert!(t.contains("<Mesh3d name=\"plant\" lod={3} transform=") && svg.contains("1.20 m, LOD 3<"), "MK22, each box named with its planned detail: {t}");
|
||||
let none: Make = read("make", r#"{"kind": "scene", "objects": [{"id": "pen", "label": "Pen"}]}"#).unwrap();
|
||||
assert!(crate::floor::floor_svg(&none).unwrap_err().contains("no object has an `at`"));
|
||||
}
|
||||
|
||||
@@ -4,9 +4,11 @@ version = "0.1.0"
|
||||
edition = "2024"
|
||||
license = "FSL-1.1-ALv2"
|
||||
publish = false
|
||||
description = "`raea motion` and `raea setup motion`: body motion made by Kimodo on this machine, on MLX on a Mac, on PyTorch elsewhere"
|
||||
description = "`raea make motion` and `raea setup motion`: body motion made by Kimodo on this machine, on MLX on a Mac, on PyTorch elsewhere"
|
||||
|
||||
[dependencies]
|
||||
# a take's joints as vectors (score.rs)
|
||||
glam = "0.33"
|
||||
# raea's models folder, where the models and the PyTorch environment go
|
||||
raea-io-home = { path = "../../io/home" }
|
||||
serde_json = "1"
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
//! `raea make motion` without the rest of the CLI, for working on this crate while the workspace's other crates are mid-change:
|
||||
//! `lane build -- cargo run --release -p raea-app-motion --example motion -- "LINE" --seeds 4 -o CLIP.json`
|
||||
fn main() {
|
||||
let args: Vec<String> = std::iter::once("motion".to_string()).chain(std::env::args().skip(1)).collect();
|
||||
match raea_app_motion::motion(&args) {
|
||||
Ok(s) => println!("{s}"),
|
||||
Err(e) => {
|
||||
eprintln!("{e}");
|
||||
std::process::exit(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
+67
-24
@@ -1,4 +1,4 @@
|
||||
//! `raea motion "LINE" [--keys KEYS.json] ...`: body motion made on this machine by Kimodo (raea-sys-kimodo): a SOMA clip
|
||||
//! `raea make motion "LINE" [--keys KEYS.json] ...`: body motion made on this machine by Kimodo (raea-sys-kimodo): a SOMA clip
|
||||
//! from a line of words and, with --keys, Kimodo constraints (full-body keyframes, hand or foot targets, a root path:
|
||||
//! what sdk/body/tools/between.ts writes). The clip is the file sdk/body/tools/fromkimodo.ts reads, the same one the
|
||||
//! cloud runner wrote (docs/character.feature CH15b, CH15c).
|
||||
@@ -9,15 +9,17 @@
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
mod score;
|
||||
|
||||
use raea_runtime_bundle::flag;
|
||||
|
||||
type R<T> = Result<T, String>;
|
||||
|
||||
pub const USAGE: &str = "raea motion \"LINE\" [--keys KEYS.json] [--seconds 5 | --frames N] [--seed 1] [--steps 100] [-o CLIP.json]";
|
||||
pub const ABOUT: &str = "body motion made on this machine by Kimodo (NVIDIA): a SOMA clip from a line of words and, with --keys, Kimodo constraints (full-body keyframes, hand or foot targets, a root path, as sdk/body/tools/between.ts writes them), as the clip sdk/body/tools/fromkimodo.ts reads. On a Mac it runs on MLX (Apple silicon's GPU): the first use fetches the motion model (1.1 GB) into raea's models folder, and the first new line its text encoder (8.8 GB: Llama 3 8B in 8 bits with LLM2Vec's adapters). On Linux and Windows it runs upstream Kimodo on PyTorch, set up once by raea setup motion: on an NVIDIA GPU with CUDA (the text encoder, 16 GB in bf16, on the CPU unless the card has 18 GB or more), else on the CPU alone; reading a new line on the CPU takes about 18 GB of memory. A line's words are read once and kept. Licences: Kimodo's weights NVIDIA's Open Model License, Meta Llama 3 the Meta Llama 3 Community License, LLM2Vec's adapters MIT, Kimodo's code Apache-2.0";
|
||||
pub const USAGE: &str = "raea make motion \"LINE\" [--keys KEYS.json] [--seconds 5 | --frames N] [--seed 1] [--seeds 1] [--steps 100] [-o CLIP.json]";
|
||||
pub const ABOUT: &str = "body motion made on this machine by Kimodo (NVIDIA): a SOMA clip from a line of words and, with --keys, Kimodo constraints (full-body keyframes, hand or foot targets, a root path, as sdk/body/tools/between.ts writes them), as the clip sdk/body/tools/fromkimodo.ts reads. On a Mac it runs on MLX (Apple silicon's GPU): the first use fetches the motion model (1.1 GB) into raea's models folder, and the first new line its text encoder (8.8 GB: Llama 3 8B in 8 bits with LLM2Vec's adapters). On Linux and Windows it runs upstream Kimodo on PyTorch, set up once by raea setup motion: on an NVIDIA GPU with CUDA (the text encoder, 16 GB in bf16, on the CPU unless the card has 18 GB or more), else on the CPU alone; reading a new line on the CPU takes about 18 GB of memory. A line's words are read once and kept. --seeds N makes N takes (seeds SEED to SEED+N-1) and keeps the one with the fewest faults: a foot sliding while planted, the shoulders shrugging, the hips sinking, a hand or forearm into the torso or head (a skeletal check; each take's score is printed and the kept one's written into the clip). Licences: Kimodo's weights NVIDIA's Open Model License, Meta Llama 3 the Meta Llama 3 Community License, LLM2Vec's adapters MIT, Kimodo's code Apache-2.0";
|
||||
|
||||
pub const SETUP_USAGE: &str = "raea setup motion [--check]";
|
||||
pub const SETUP_ABOUT: &str = "what raea motion runs on, made where missing (--check only says): on a Mac the MLX models in raea's models folder (the motion model 1.1 GB, the text encoder 8.8 GB); on Linux and Windows, in raea's models folder's kimodo-torch, a Python 3.11 environment made by uv (which it needs on PATH: https://docs.astral.sh/uv) with PyTorch (its CUDA build where there is an NVIDIA driver, about 8 GB, else CPU only, about 2 GB) and upstream Kimodo (nv-tlabs/kimodo at e1c219c, Apache-2.0), then the weights: Kimodo-SOMA-RP-v1 (1.1 GB, NVIDIA Open Model License), LLM2Vec's two adapters (0.3 GB, MIT) and Meta Llama 3 8B Instruct in bf16 (16 GB, Meta Llama 3 Community License, from NousResearch's ungated copy, checked file by file against Meta's SHA-256); about 26 GB in all. It says what this machine has and where each network runs: the denoiser on CUDA when there is an NVIDIA GPU, else the CPU; the text encoder beside it on a GPU of 18 GB or more, else the CPU";
|
||||
pub const SETUP_ABOUT: &str = "what raea make motion runs on, made where missing (--check only says): on a Mac the MLX models in raea's models folder (the motion model 1.1 GB, the text encoder 8.8 GB); on Linux and Windows, in raea's models folder's kimodo-torch, a Python 3.11 environment made by uv (which it needs on PATH: https://docs.astral.sh/uv) with PyTorch (its CUDA build where there is an NVIDIA driver, about 8 GB, else CPU only, about 2 GB) and upstream Kimodo (nv-tlabs/kimodo at e1c219c, Apache-2.0), then the weights: Kimodo-SOMA-RP-v1 (1.1 GB, NVIDIA Open Model License), LLM2Vec's two adapters (0.3 GB, MIT) and Meta Llama 3 8B Instruct in bf16 (16 GB, Meta Llama 3 Community License, from NousResearch's ungated copy, checked file by file against Meta's SHA-256); about 26 GB in all. It says what this machine has and where each network runs: the denoiser on CUDA when there is an NVIDIA GPU, else the CPU; the text encoder beside it on a GPU of 18 GB or more, else the CPU";
|
||||
|
||||
fn number(args: &[String], name: &str, default: f64) -> R<f64> {
|
||||
match flag(args, name) {
|
||||
@@ -27,7 +29,7 @@ fn number(args: &[String], name: &str, default: f64) -> R<f64> {
|
||||
}
|
||||
|
||||
fn line(args: &[String]) -> String {
|
||||
const WITH_VALUE: [&str; 6] = ["--keys", "--seconds", "--frames", "--seed", "--steps", "-o"];
|
||||
const WITH_VALUE: [&str; 7] = ["--keys", "--seconds", "--frames", "--seed", "--seeds", "--steps", "-o"];
|
||||
let mut out = Vec::new();
|
||||
let mut i = 1;
|
||||
while i < args.len() {
|
||||
@@ -50,6 +52,7 @@ struct Ask {
|
||||
constraints: Option<serde_json::Value>,
|
||||
frames: usize,
|
||||
seed: u64,
|
||||
seeds: usize,
|
||||
steps: usize,
|
||||
out: Option<String>,
|
||||
}
|
||||
@@ -64,15 +67,21 @@ pub fn motion(args: &[String]) -> R<String> {
|
||||
Some(_) => number(args, "--frames", 150.0)? as usize,
|
||||
None => (number(args, "--seconds", 5.0)? * 30.0).round() as usize,
|
||||
};
|
||||
if !(2..=600).contains(&frames) {
|
||||
return Err(format!("a clip is 2 to 600 frames (20 s at 30 a second), asked {frames}"));
|
||||
// Kimodo's own limit (its docs, key_concepts/limitations.md): past 10 s a clip drifts and breaks up (11-27: a
|
||||
// 12.3 s talk clip's feet spread 47 -> 69 cm, shoulders rose 9 cm, the last half second glitched)
|
||||
if !(2..=300).contains(&frames) {
|
||||
return Err(format!(
|
||||
"a clip is 2 to 300 frames (10 s at 30 a second, Kimodo's limit: longer clips drift and break up), asked {frames}; \
|
||||
for longer, make 10 s clips one after another, each from --keys holding the last frames of the one before"
|
||||
));
|
||||
}
|
||||
let constraints = match &keys {
|
||||
Some(p) => Some(serde_json::from_str::<serde_json::Value>(&std::fs::read_to_string(p).map_err(|e| format!("{p}: {e}"))?).map_err(|e| format!("{p}: {e}"))?),
|
||||
None => None,
|
||||
};
|
||||
let (seed, steps) = (number(args, "--seed", 1.0)? as u64, (number(args, "--steps", 100.0)? as usize).max(2));
|
||||
make(Ask { words, keys, constraints, frames, seed, steps, out: flag(args, "-o") })
|
||||
let seeds = (number(args, "--seeds", 1.0)? as usize).clamp(1, 32);
|
||||
make(Ask { words, keys, constraints, frames, seed, seeds, steps, out: flag(args, "-o") })
|
||||
}
|
||||
|
||||
/// -o, else a file named by the line's words in the working folder
|
||||
@@ -83,6 +92,25 @@ fn out_path(out: Option<String>, clean: &str) -> PathBuf {
|
||||
}))
|
||||
}
|
||||
|
||||
/// the take with the lowest score of those made, its seed, and a line per take ("" for a single take)
|
||||
fn keep_best(takes: Vec<(u64, raea_sys_kimodo::decode::Motion)>, sk: &raea_sys_kimodo::skeleton::Skeleton) -> (u64, raea_sys_kimodo::decode::Motion, Option<score::Score>, String) {
|
||||
let one = takes.len() == 1;
|
||||
let mut scored: Vec<(u64, raea_sys_kimodo::decode::Motion, score::Score)> = takes.into_iter().map(|(s, m)| { let sc = score::score(&m, sk); (s, m, sc) }).collect();
|
||||
let report = if one { String::new() } else { scored.iter().map(|(s, _, sc)| format!("\n seed {s}: {}", sc.line())).collect::<String>() };
|
||||
scored.sort_by(|a, b| a.2.total.total_cmp(&b.2.total));
|
||||
let (s, m, sc) = scored.remove(0);
|
||||
(s, m, Some(sc), report)
|
||||
}
|
||||
|
||||
/// the kept take's score, written into the clip
|
||||
fn with_score(mut clip: serde_json::Value, sc: &Option<score::Score>, tried: usize) -> serde_json::Value {
|
||||
if let Some(sc) = sc {
|
||||
clip["score"] = serde_json::json!({"total": sc.total, "foot_drift_cm": sc.foot_drift_cm, "shoulder_rise_cm": sc.shoulder_rise_cm,
|
||||
"hip_drop_cm": sc.hip_drop_cm, "collision_cm": sc.collision_cm, "takes": tried});
|
||||
}
|
||||
clip
|
||||
}
|
||||
|
||||
/// how far the hips end from where they start, on the ground
|
||||
fn travel(m: &raea_sys_kimodo::decode::Motion) -> f32 {
|
||||
let r = &m.root;
|
||||
@@ -103,16 +131,23 @@ fn make(ask: Ask) -> R<String> {
|
||||
let missing = t.missing();
|
||||
if !missing.is_empty() {
|
||||
return Err(format!(
|
||||
"raea motion runs Kimodo on PyTorch on this machine (MLX is Apple silicon's), and its {} isn't set up in {} yet: raea setup motion makes it (uv, then about 26 GB: PyTorch, Kimodo's code and weights, Llama 3 8B Instruct for the text encoder)",
|
||||
"raea make motion runs Kimodo on PyTorch on this machine (MLX is Apple silicon's), and its {} isn't set up in {} yet: raea setup motion makes it (uv, then about 26 GB: PyTorch, Kimodo's code and weights, Llama 3 8B Instruct for the text encoder)",
|
||||
missing.join(", the "),
|
||||
t.dir.display()
|
||||
));
|
||||
}
|
||||
let keys = ask.keys.as_ref().map(std::path::Path::new);
|
||||
let job = torch::Job { line: &ask.words, frames: ask.frames, seed: ask.seed, steps: ask.steps, keys, cfg: (2.0, 2.0) };
|
||||
let made = t.make(&job).map_err(|e| format!("raea motion: {e}"))?;
|
||||
let (stats, sk) = (Stats::load(&t.checkpoint).map_err(|e| format!("raea motion: {e}"))?, Skeleton::soma().map_err(|e| format!("raea motion: {e}"))?);
|
||||
let motion = decode::decode(&made.features, &stats, &sk);
|
||||
let mut takes = Vec::new();
|
||||
let mut last = None;
|
||||
for s in ask.seed..ask.seed + ask.seeds as u64 {
|
||||
let job = torch::Job { line: &ask.words, frames: ask.frames, seed: s, steps: ask.steps, keys, cfg: (2.0, 2.0) };
|
||||
let made = t.make(&job).map_err(|e| format!("raea motion: {e}"))?;
|
||||
takes.push((s, decode::decode(&made.features, &stats, &sk)));
|
||||
last = Some(made);
|
||||
}
|
||||
let made = last.ok_or("raea motion: no take")?;
|
||||
let (seed, motion, sc, report) = keep_best(takes, &sk);
|
||||
let info = &made.info;
|
||||
let clean = info["line"].as_str().unwrap_or(&ask.words).to_string();
|
||||
let (dev, text_dev) = (info["motion"].as_str().unwrap_or("?"), info["text"].as_str().unwrap_or("?"));
|
||||
@@ -120,26 +155,28 @@ fn make(ask: Ask) -> R<String> {
|
||||
Some(g) => format!("on PyTorch {} with CUDA ({g}; the text encoder on {text_dev}), upstream nv-tlabs/kimodo {}", info["torch"].as_str().unwrap_or("?"), &torch::KIMODO[..7]),
|
||||
None => format!("on PyTorch {} on the CPU, upstream nv-tlabs/kimodo {}", info["torch"].as_str().unwrap_or("?"), &torch::KIMODO[..7]),
|
||||
};
|
||||
let clip = decode::clip_json_on(&motion, &sk, ask.seed, ask.steps, &clean, ask.constraints.is_some(), &on);
|
||||
let clip = with_score(decode::clip_json_on(&motion, &sk, seed, ask.steps, &clean, ask.constraints.is_some(), &on), &sc, ask.seeds);
|
||||
let out = out_path(ask.out, &clean);
|
||||
std::fs::write(&out, serde_json::to_string(&clip).unwrap_or_default()).map_err(|e| format!("{}: {e}", out.display()))?;
|
||||
// the hips as PyTorch decoded them against decode.rs's: the features were read as Kimodo wrote them
|
||||
let ours: Vec<[f32; 3]> = motion.joints77.iter().map(|f| f[0]).collect();
|
||||
let gap = torch::root_gap(&info["root"], &ours).map(|g| format!(", decoded here within {:.3} mm of PyTorch's own", g * 1000.0)).unwrap_or_default();
|
||||
let gap = if ask.seeds > 1 { String::new() } else { torch::root_gap(&info["root"], &ours).map(|g| format!(", decoded here within {:.3} mm of PyTorch's own", g * 1000.0)).unwrap_or_default() };
|
||||
let f = |k: &str| info[k].as_f64().unwrap_or(0.0);
|
||||
let read = if f("read_s") > 0.0 { format!(", reading the line {:.1} s after {:.1} s loading its encoder", f("read_s"), f("text_load_s")) } else { String::new() };
|
||||
Ok(format!(
|
||||
"APPLIED motion {:?}{}, {} frames ({:.1} s), seed {}, {} steps -> {} (made {on} in {:.1} s after {:.1} s loading{read}; the hips end {:.2} m from where they start{gap})",
|
||||
"APPLIED motion {:?}{}, {} frames ({:.1} s), seed {}{}, {} steps -> {} (made {on} in {:.1} s after {:.1} s loading{read}; the hips end {:.2} m from where they start{gap}; {}){report}",
|
||||
clean,
|
||||
if ask.keys.is_some() { " with keys" } else { "" },
|
||||
ask.frames,
|
||||
ask.frames as f64 / 30.0,
|
||||
ask.seed,
|
||||
seed,
|
||||
if ask.seeds > 1 { format!(", the best of {} takes", ask.seeds) } else { String::new() },
|
||||
ask.steps,
|
||||
out.display(),
|
||||
f("gen_s"),
|
||||
f("load_s"),
|
||||
travel(&motion),
|
||||
sc.as_ref().map(|s| s.line()).unwrap_or_default(),
|
||||
))
|
||||
}
|
||||
|
||||
@@ -154,23 +191,29 @@ fn make(ask: Ask) -> R<String> {
|
||||
let mut k = raea_sys_kimodo::Kimodo::fetch(&mut progress).map_err(|e| format!("raea motion: {e}"))?;
|
||||
let (clean, emb) = k.encode(&ask.words).map_err(|e| format!("raea motion: {e}"))?;
|
||||
let load_s = t0.elapsed().as_secs_f64();
|
||||
let made_from = raea_sys_kimodo::Ask { line: &ask.words, frames: ask.frames, seed: ask.seed, steps: ask.steps, constraints: ask.constraints.as_ref(), cfg: (2.0, 2.0) };
|
||||
let t1 = std::time::Instant::now();
|
||||
let made = k.make(&made_from, emb.as_deref(), None).map_err(|e| format!("raea motion: {e}"))?;
|
||||
let mut takes = Vec::new();
|
||||
for s in ask.seed..ask.seed + ask.seeds as u64 {
|
||||
let made_from = raea_sys_kimodo::Ask { line: &ask.words, frames: ask.frames, seed: s, steps: ask.steps, constraints: ask.constraints.as_ref(), cfg: (2.0, 2.0) };
|
||||
takes.push((s, k.make(&made_from, emb.as_deref(), None).map_err(|e| format!("raea motion: {e}"))?.motion));
|
||||
}
|
||||
let gen_s = t1.elapsed().as_secs_f64();
|
||||
let clip = raea_sys_kimodo::decode::clip_json(&made.motion, &k.skeleton, ask.seed, ask.steps, &clean, ask.constraints.is_some());
|
||||
let (seed, motion, sc, report) = keep_best(takes, &k.skeleton);
|
||||
let clip = with_score(raea_sys_kimodo::decode::clip_json(&motion, &k.skeleton, seed, ask.steps, &clean, ask.constraints.is_some()), &sc, ask.seeds);
|
||||
let out = out_path(ask.out, &clean);
|
||||
std::fs::write(&out, serde_json::to_string(&clip).unwrap_or_default()).map_err(|e| format!("{}: {e}", out.display()))?;
|
||||
Ok(format!(
|
||||
"APPLIED motion {:?}{}, {} frames ({:.1} s), seed {}, {} steps -> {} (made on this Mac in {gen_s:.1} s after {load_s:.1} s loading and reading the line; the hips end {:.2} m from where they start)",
|
||||
"APPLIED motion {:?}{}, {} frames ({:.1} s), seed {}{}, {} steps -> {} (made on this Mac in {gen_s:.1} s after {load_s:.1} s loading and reading the line; the hips end {:.2} m from where they start; {}){report}",
|
||||
clean,
|
||||
if ask.keys.is_some() { " with keys" } else { "" },
|
||||
ask.frames,
|
||||
ask.frames as f64 / 30.0,
|
||||
ask.seed,
|
||||
seed,
|
||||
if ask.seeds > 1 { format!(", the best of {} takes", ask.seeds) } else { String::new() },
|
||||
ask.steps,
|
||||
out.display(),
|
||||
travel(&made.motion)
|
||||
travel(&motion),
|
||||
sc.as_ref().map(|s| s.line()).unwrap_or_default(),
|
||||
))
|
||||
}
|
||||
|
||||
@@ -190,7 +233,7 @@ fn disk(dir: &std::path::Path) -> String {
|
||||
raea_io_home::disk_use(dir, true)
|
||||
}
|
||||
|
||||
/// `raea setup motion [--check]`: what raea motion runs on here, made where missing (--check only says), and where it is.
|
||||
/// `raea setup motion [--check]`: what raea make motion runs on here, made where missing (--check only says), and where it is.
|
||||
pub fn setup(args: &[String]) -> R<String> {
|
||||
let check = args.iter().any(|a| a == "--check");
|
||||
if let Some(a) = args.iter().find(|a| *a != "--check") {
|
||||
@@ -214,7 +257,7 @@ fn setup_here(check: bool) -> R<String> {
|
||||
let state = match (had, has) {
|
||||
(true, _) => "installed",
|
||||
(false, true) => "installed now",
|
||||
(false, false) => "not installed: raea setup motion fetches it (raea motion does too, the first time it needs it)",
|
||||
(false, false) => "not installed: raea setup motion fetches it (raea make motion does too, the first time it needs it)",
|
||||
};
|
||||
lines.push(format!(" {name:<12} {state}; {what}\n {} ({})", dir.display(), if *has { disk(dir) } else { "-".into() }));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
//! A take scored for the faults a body shows (sheet3d plan E3), so `raea make motion --seeds N` can keep the best of N:
|
||||
//! a foot sliding while it's planted, the shoulders shrugging up, the hips sinking, and a hand or forearm inside the
|
||||
//! torso or head. Read from the take's own joints (Kimodo's SOMA skeleton, metres, Y up) and its foot contacts.
|
||||
//! Collision is a skeletal proxy: capsules round the spine and a sphere for the head, sized for SOMA's average adult;
|
||||
//! the mesh check on the body a clip drives is the join's (sheet3d's join.py: head-in-body frames).
|
||||
|
||||
use raea_sys_kimodo::decode::Motion;
|
||||
use raea_sys_kimodo::skeleton::Skeleton;
|
||||
|
||||
use glam::Vec3;
|
||||
|
||||
/// each fault in centimetres (collision: the deepest a hand or forearm point goes into the torso or head), and
|
||||
/// their sum, each over its own allowance: 1 cm of drift, 3 cm of shrug, 5 cm of sinking, 1 cm into the body
|
||||
pub struct Score {
|
||||
pub foot_drift_cm: f32,
|
||||
pub shoulder_rise_cm: f32,
|
||||
pub hip_drop_cm: f32,
|
||||
pub collision_cm: f32,
|
||||
pub total: f32,
|
||||
}
|
||||
|
||||
fn idx(sk: &Skeleton, n: &str) -> usize {
|
||||
sk.names77.iter().position(|x| x == n).unwrap_or(0)
|
||||
}
|
||||
|
||||
/// how far p is inside the capsule a-b of radius r (0 outside)
|
||||
fn inside(p: [f32; 3], a: [f32; 3], b: [f32; 3], r: f32) -> f32 {
|
||||
let (p, a, b) = (Vec3::from(p), Vec3::from(a), Vec3::from(b));
|
||||
let ab = b - a;
|
||||
let t = ((p - a).dot(ab) / ab.length_squared().max(1e-9)).clamp(0.0, 1.0);
|
||||
(r - p.distance(a + t * ab)).max(0.0)
|
||||
}
|
||||
|
||||
fn median(mut v: Vec<f32>) -> f32 {
|
||||
if v.is_empty() {
|
||||
return 0.0;
|
||||
}
|
||||
v.sort_by(|a, b| a.total_cmp(b));
|
||||
v[v.len() / 2]
|
||||
}
|
||||
|
||||
pub fn score(m: &Motion, sk: &Skeleton) -> Score {
|
||||
let j = &m.joints77;
|
||||
let n = j.len();
|
||||
// a foot planted: its horizontal travel over each run of contact frames, the worst run
|
||||
let feet = [("LeftFoot", 0), ("LeftToeBase", 1), ("RightFoot", 3), ("RightToeBase", 4)];
|
||||
let mut drift = 0f32;
|
||||
for (name, c) in feet {
|
||||
let k = idx(sk, name);
|
||||
let mut start: Option<usize> = None;
|
||||
for f in 0..=n {
|
||||
let on = f < n && m.contacts[f][c];
|
||||
match (on, start) {
|
||||
(true, None) => start = Some(f),
|
||||
(false, Some(s)) => {
|
||||
let mut far = 0f32;
|
||||
for g in s..f {
|
||||
let d = Vec3::from(j[g][k]) - Vec3::from(j[s][k]);
|
||||
far = far.max(d.x.hypot(d.z));
|
||||
}
|
||||
drift = drift.max(far);
|
||||
start = None;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
// shoulders above the chest: the highest against the take's own usual, both sides
|
||||
let chest = idx(sk, "Chest");
|
||||
let mut rise = 0f32;
|
||||
for s in ["LeftShoulder", "RightShoulder"] {
|
||||
let k = idx(sk, s);
|
||||
let h: Vec<f32> = j.iter().map(|f| f[k][1] - f[chest][1]).collect();
|
||||
let med = median(h.clone());
|
||||
rise = rise.max(h.iter().fold(f32::MIN, |a, &b| a.max(b)) - med);
|
||||
}
|
||||
// hips below where they stand: the lowest against the first second's median
|
||||
let hips = idx(sk, "Hips");
|
||||
let stand = median(j.iter().take(30).map(|f| f[hips][1]).collect());
|
||||
let drop = (stand - j.iter().fold(f32::MAX, |a, f| a.min(f[hips][1]))).max(0.0);
|
||||
// hands and forearms against the torso (hips to chest, chest to neck) and the head
|
||||
let (spine1, neck, head) = (idx(sk, "Spine1"), idx(sk, "Neck1"), idx(sk, "Head"));
|
||||
let limbs: Vec<usize> = ["LeftHand", "RightHand", "LeftHandMiddle1", "RightHandMiddle1"].iter().map(|x| idx(sk, x)).collect();
|
||||
let fore = [("LeftArm", "LeftForeArm", "LeftHand"), ("RightArm", "RightForeArm", "RightHand")];
|
||||
let mut deep = 0f32;
|
||||
for f in j {
|
||||
let mut pts: Vec<[f32; 3]> = limbs.iter().map(|&k| f[k]).collect();
|
||||
for (_, e, h) in fore {
|
||||
let (a, b) = (f[idx(sk, e)], f[idx(sk, h)]);
|
||||
pts.push([(a[0] + b[0]) / 2.0, (a[1] + b[1]) / 2.0, (a[2] + b[2]) / 2.0]);
|
||||
}
|
||||
for p in pts {
|
||||
let d = inside(p, f[hips], f[spine1], 0.12)
|
||||
.max(inside(p, f[spine1], f[chest], 0.13))
|
||||
.max(inside(p, f[chest], f[neck], 0.11))
|
||||
.max(inside(p, f[head], f[head], 0.09));
|
||||
deep = deep.max(d);
|
||||
}
|
||||
}
|
||||
let (d, r, h, c) = (drift * 100.0, rise * 100.0, drop * 100.0, deep * 100.0);
|
||||
Score { foot_drift_cm: d, shoulder_rise_cm: r, hip_drop_cm: h, collision_cm: c, total: d / 1.0 + r / 3.0 + h / 5.0 + c / 1.0 }
|
||||
}
|
||||
|
||||
impl Score {
|
||||
pub fn line(&self) -> String {
|
||||
format!(
|
||||
"score {:.2} (foot drift {:.1} cm, shoulder rise {:.1} cm, hip drop {:.1} cm, hand into body {:.1} cm)",
|
||||
self.total, self.foot_drift_cm, self.shoulder_rise_cm, self.hip_drop_cm, self.collision_cm
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
[package]
|
||||
name = "raea-app-playable"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
license = "FSL-1.1-ALv2"
|
||||
publish = false
|
||||
description = "`raea playable`: a raea game exported as a playable ad, one page or ZIP per ad network (docs/playables.feature)"
|
||||
|
||||
[dependencies]
|
||||
dunce = "1"
|
||||
# the game and sdk/playable's host bundled into one page by raea's own bundler (Rolldown, in process)
|
||||
raea-runtime-bundle = { path = "../../runtime/bundle" }
|
||||
# where raea's files are: an install's share/raea, else this checkout
|
||||
raea-io-home = { path = "../../io/home" }
|
||||
regex = "1"
|
||||
serde_json = "1"
|
||||
zip = { version = "9", default-features = false, features = ["deflate-flate2"] }
|
||||
@@ -0,0 +1,102 @@
|
||||
//! `raea playable GAME.tsx -o DIR`: a raea game exported as a playable ad (docs/playables.feature PA13). The same TSX
|
||||
//! that renders with `raea render` as the video ad (it plays itself) is linted (lint.rs), bundled once with
|
||||
//! sdk/playable's browser host by raea's own bundler (Rolldown, in process: minified, its pictures and tables carried
|
||||
//! in the script, one three.js), and written as each network's page or ZIP (pages.rs), each checked against its cap.
|
||||
mod lint;
|
||||
mod pages;
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
type R<T> = Result<T, String>;
|
||||
|
||||
pub const USAGE: &str = "raea playable GAME.tsx -o DIR [--networks LIST] [--ios URL] [--android URL] [--title TEXT] [--cta TEXT] [--orientation portrait|landscape|both]";
|
||||
pub const ABOUT: &str = "a game as a playable ad: one page or ZIP per network (applovin, unity, google, meta, moloco, mintegral, tiktok, liftoff, preview), each under its 5 MB cap, from the TSX that renders as the video ad";
|
||||
|
||||
/// A path as an import specifier (no Windows verbatim prefix, which Rolldown can't open): raea-bundle's own
|
||||
pub(crate) use raea_runtime_bundle::spec;
|
||||
|
||||
fn flag<'a>(args: &'a [String], name: &str) -> Option<&'a str> {
|
||||
args.iter().position(|a| a == name).and_then(|i| args.get(i + 1)).map(String::as_str)
|
||||
}
|
||||
|
||||
/// The folder whose node_modules holds the three.js a playable draws with: the project's own (`raea add [email protected]`),
|
||||
/// else the copy beside sdk/playable or sdk/r3f in raea's own files
|
||||
fn three_dir(game: &Path, home: &Path) -> R<PathBuf> {
|
||||
let mut d = game.parent();
|
||||
while let Some(dir) = d {
|
||||
if dir.join("node_modules/three/package.json").is_file() {
|
||||
return Ok(dir.to_path_buf());
|
||||
}
|
||||
d = dir.parent();
|
||||
}
|
||||
["sdk/playable", "sdk/r3f"]
|
||||
.iter()
|
||||
.map(|p| home.join(p))
|
||||
.find(|d| d.join("node_modules/three/package.json").is_file())
|
||||
.ok_or_else(|| "a playable draws its 3D with three.js, which this project doesn't have: `raea add [email protected]` in it".into())
|
||||
}
|
||||
|
||||
/// The game and the host in one minified script that carries its files
|
||||
fn bundle(game: &Path, home: &Path) -> R<String> {
|
||||
let host = home.join("sdk/playable/src/host/main.tsx");
|
||||
if !host.is_file() {
|
||||
return Err(format!("{}: raea's playable host isn't there", host.display()));
|
||||
}
|
||||
let three = three_dir(game, home)?;
|
||||
let out = std::env::temp_dir().join(format!("raea-playable-{}.js", std::process::id()));
|
||||
let entry = format!("import {:?};\nimport {:?};\n", spec(game), spec(&host));
|
||||
let alias = format!("three/={}", three.display());
|
||||
let r = raea_runtime_bundle::bundle_entry(&entry, &out, &["--minify", "1", "--inline", "1", "--alias", &alias]);
|
||||
let js = r.and_then(|_| std::fs::read_to_string(&out).map_err(|e| e.to_string()));
|
||||
let _ = std::fs::remove_file(&out);
|
||||
js
|
||||
}
|
||||
|
||||
pub fn cli(args: &[String]) -> R<String> {
|
||||
let game = args.get(1).filter(|a| !a.starts_with('-')).ok_or(USAGE)?;
|
||||
let game = dunce::canonicalize(game).map_err(|e| format!("{game}: {e}"))?;
|
||||
let out = PathBuf::from(flag(args, "-o").ok_or(format!("-o DIR is required: {USAGE}"))?);
|
||||
let networks: Vec<&str> = flag(args, "--networks").map(|n| n.split(',').filter(|s| !s.is_empty()).collect()).unwrap_or_else(|| pages::NETWORKS.to_vec());
|
||||
if let Some(bad) = networks.iter().find(|n| !pages::NETWORKS.contains(n)) {
|
||||
return Err(format!("raea playable: no network {bad} (one of {})", pages::NETWORKS.join(", ")));
|
||||
}
|
||||
let orientation = flag(args, "--orientation").unwrap_or("both");
|
||||
if !["portrait", "landscape", "both"].contains(&orientation) {
|
||||
return Err("--orientation is portrait, landscape or both".into());
|
||||
}
|
||||
let store = serde_json::json!({"ios": flag(args, "--ios").unwrap_or(""), "android": flag(args, "--android").unwrap_or("")}).to_string();
|
||||
let card = serde_json::json!({"title": flag(args, "--title").unwrap_or(""), "cta": flag(args, "--cta").unwrap_or("Play now")}).to_string();
|
||||
let name = game.file_stem().and_then(|s| s.to_str()).unwrap_or("playable").to_string();
|
||||
|
||||
let mut report = Vec::new();
|
||||
let found = lint::lint(&game)?;
|
||||
report.push(format!("3D kinds: {}", if found.kinds.is_empty() { "none".into() } else { found.kinds.join(", ") }));
|
||||
for c in &found.comps {
|
||||
let shape = if c.height > c.width { "portrait" } else { "landscape" };
|
||||
report.push(format!("composition {}: {}x{} {shape}, {} fps, {:.0} s", c.id, c.width, c.height, c.fps, c.frames as f64 / c.fps.max(1.0)));
|
||||
}
|
||||
report.extend(found.notes.iter().map(|n| format!("note: {n}")));
|
||||
if !found.refusals.is_empty() {
|
||||
// the reasons first: the CLI marks an error's first line REFUSED
|
||||
let mut why = found.refusals.clone();
|
||||
why.extend(report);
|
||||
return Err(why.join("\n"));
|
||||
}
|
||||
|
||||
let js = bundle(&game, &raea_io_home::home())?;
|
||||
std::fs::create_dir_all(&out).map_err(|e| format!("{}: {e}", out.display()))?;
|
||||
let mut over = false;
|
||||
for net in networks {
|
||||
let script = format!("{}\n{js}", pages::preamble(net, &store, &card));
|
||||
let w = pages::write(net, &name, &script, &out, orientation)?;
|
||||
let ok = w.bytes <= pages::CAP;
|
||||
over |= !ok;
|
||||
report.push(format!("{:<10} {:<40} {:>6} KB / {} KB {}", w.network, w.file.display(), w.bytes / 1024, pages::CAP / 1024, if ok { "ok" } else { "OVER" }));
|
||||
}
|
||||
if over {
|
||||
report.insert(0, format!("a page is over its network's {} KB cap", pages::CAP / 1024));
|
||||
return Err(report.join("\n"));
|
||||
}
|
||||
report.push(format!("APPLIED {name} exported as a playable to {}", out.display()));
|
||||
Ok(report.join("\n"))
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
//! What a playable can't have, refused before it is bundled (docs/playables.feature PA4): the source read for files
|
||||
//! from disk, the network and the native engine's modules; the compositions rendered (sdk/playable/src/export/walk.ts,
|
||||
//! through `raea run` in a process of its own) for their shapes and the 3D kinds the host doesn't draw.
|
||||
use super::R;
|
||||
use serde_json::Value;
|
||||
use std::path::Path;
|
||||
|
||||
/// One composition the game registers
|
||||
pub struct Comp {
|
||||
pub id: String,
|
||||
pub width: u32,
|
||||
pub height: u32,
|
||||
pub fps: f64,
|
||||
pub frames: u64,
|
||||
}
|
||||
|
||||
/// What the lint found: refusals stop the export, notes don't
|
||||
pub struct Found {
|
||||
pub comps: Vec<Comp>,
|
||||
pub kinds: Vec<String>,
|
||||
pub notes: Vec<String>,
|
||||
pub refusals: Vec<String>,
|
||||
}
|
||||
|
||||
const SOURCE_RULES: &[(&str, &str)] = &[
|
||||
(r"\bstaticFile\s*\(", "staticFile() reads the edit's folder at render time; import the file instead (`import icon from \"./icon.png\"`), which the export carries in the page"),
|
||||
(r"https?://", "a URL in the source: a playable makes no network requests (every network refuses one)"),
|
||||
(r"\bfetch\s*\(|XMLHttpRequest|WebSocket", "fetch/XHR/WebSocket: a playable makes no network requests"),
|
||||
(r#"from\s+["']raea/(native|ml|character|physics|media|matchmove|modelling)["']"#, "a module that needs the native engine (native calls, models, physics, footage)"),
|
||||
(r"<(Video|Audio)\b", "<Video>/<Audio> play through the native media stack; a playable's sound is PA6 (not yet)"),
|
||||
];
|
||||
|
||||
/// The game's source and its compositions, judged
|
||||
pub fn lint(game: &Path) -> R<Found> {
|
||||
let src = std::fs::read_to_string(game).map_err(|e| format!("{}: {e}", game.display()))?;
|
||||
let mut refusals = Vec::new();
|
||||
let mut notes = Vec::new();
|
||||
// a URL the SVG namespace names is a name, not a request
|
||||
let src_no_ns = src.replace("http://www.w3.org", "");
|
||||
for (re, why) in SOURCE_RULES {
|
||||
if regex::Regex::new(re).map_err(|e| e.to_string())?.is_match(&src_no_ns) {
|
||||
refusals.push(why.to_string());
|
||||
}
|
||||
}
|
||||
if !src.contains("raea/playable") {
|
||||
notes.push("no raea/playable import: the game never opens the store itself (add an <EndCard> or <InstallButton>); the host's own end card shows at the last frame".into());
|
||||
}
|
||||
let walked = match walk(game) {
|
||||
Ok(w) => w,
|
||||
// what the source can't have (a fetch, a URL) often stops the render too: the refusal says why, the render's end doesn't
|
||||
Err(_) if !refusals.is_empty() => return Ok(Found { comps: vec![], kinds: vec![], notes, refusals }),
|
||||
Err(e) => return Err(e),
|
||||
};
|
||||
let comps: Vec<Comp> = walked["comps"]
|
||||
.as_array()
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.map(|c| Comp {
|
||||
id: c["id"].as_str().unwrap_or("").into(),
|
||||
width: c["width"].as_u64().unwrap_or(0) as u32,
|
||||
height: c["height"].as_u64().unwrap_or(0) as u32,
|
||||
fps: c["fps"].as_f64().unwrap_or(30.0),
|
||||
frames: c["frames"].as_u64().unwrap_or(0),
|
||||
})
|
||||
.collect();
|
||||
let strings = |k: &str| walked[k].as_array().into_iter().flatten().filter_map(|v| v.as_str().map(String::from)).collect::<Vec<_>>();
|
||||
if comps.is_empty() {
|
||||
refusals.push("no composition registered (registerRoot)".into());
|
||||
}
|
||||
if comps.len() == 1 {
|
||||
notes.push("one composition: the other orientation is letterboxed (Unity, AppLovin, Moloco and Mintegral want both; register a second one at the other shape)".into());
|
||||
}
|
||||
for k in strings("refused") {
|
||||
refusals.push(format!("3D kind {k} isn't drawn in a playable"));
|
||||
}
|
||||
Ok(Found { comps, kinds: strings("kinds"), notes, refusals })
|
||||
}
|
||||
|
||||
/// sdk/playable's walk run on the engine (`raea run`) after the game, in a process of its own so the game's React stays
|
||||
/// out of this one; its answer is the JSON it prints
|
||||
fn walk(game: &Path) -> R<Value> {
|
||||
let walk = raea_io_home::home().join("sdk/playable/src/export/walk.ts");
|
||||
if !walk.is_file() {
|
||||
return Err(format!("{}: raea's playable SDK isn't there", walk.display()));
|
||||
}
|
||||
let work = std::env::temp_dir().join(format!("raea-playable-lint-{}", std::process::id()));
|
||||
std::fs::create_dir_all(&work).map_err(|e| e.to_string())?;
|
||||
let entry = work.join("lint.ts");
|
||||
std::fs::write(&entry, format!("import {:?};\nexport {{ default }} from {:?};\n", super::spec(game), super::spec(&walk))).map_err(|e| e.to_string())?;
|
||||
let exe = std::env::current_exe().map_err(|e| e.to_string())?;
|
||||
let run = std::process::Command::new(exe).arg("run").arg(&entry).output().map_err(|e| format!("raea run: {e}"));
|
||||
let _ = std::fs::remove_dir_all(&work);
|
||||
let run = run?;
|
||||
let out = String::from_utf8_lossy(&run.stdout);
|
||||
if !run.status.success() {
|
||||
let err = String::from_utf8_lossy(&run.stderr);
|
||||
let said: Vec<&str> = err.lines().chain(out.lines()).filter(|l| !l.trim().is_empty()).collect();
|
||||
// the line that names the error, else the last one ("… ended with exit 1" says nothing)
|
||||
let why = said.iter().find(|l| l.contains("Error") || l.contains("error:")).or(said.last()).unwrap_or(&"").trim().to_string();
|
||||
return Err(format!("the game didn't render for the lint: {why}"));
|
||||
}
|
||||
let at = out.find('{').ok_or("the lint's walk printed no answer")?;
|
||||
serde_json::from_str(&out[at..]).map_err(|e| format!("the lint's walk: {e}"))
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
//! Each network's package around the one script (docs/playables.feature, the Background's table): the page every
|
||||
//! network gets, with that network's own tags, as one HTML file or a ZIP, checked against its cap.
|
||||
use super::R;
|
||||
use std::io::Write;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
pub const NETWORKS: &[&str] = &["applovin", "unity", "google", "meta", "moloco", "mintegral", "tiktok", "liftoff", "preview"];
|
||||
|
||||
/// Every network's cap, 5 MB (TikTok's counted zipped, which is what's written)
|
||||
pub const CAP: u64 = 5 * 1024 * 1024;
|
||||
|
||||
/// What one network got: the file and its size
|
||||
pub struct Written {
|
||||
pub network: String,
|
||||
pub file: PathBuf,
|
||||
pub bytes: u64,
|
||||
}
|
||||
|
||||
/// The settings a page starts with, as the globals the host reads (sdk/playable network.ts, host/main.tsx): the network,
|
||||
/// the store links, the end card's words
|
||||
pub fn preamble(network: &str, store: &str, card: &str) -> String {
|
||||
format!("var __RAEA_NETWORK__={},__RAEA_STORE__={store},__RAEA_PLAYABLE__={card};", serde_json::to_string(network).unwrap_or_default())
|
||||
}
|
||||
|
||||
/// The page: the network's head and body tags, then the script (a page's inline script ends at the first "</script")
|
||||
pub fn page(title: &str, head: &str, body: &str, script: &str) -> String {
|
||||
let title = title.replace('&', "&").replace('<', "<");
|
||||
format!(
|
||||
"<!DOCTYPE html>\n<html>\n<head>\n<meta charset=\"utf-8\">\n<meta name=\"viewport\" content=\"width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no,viewport-fit=cover\">\n<title>{title}</title>\n{head}\n</head>\n<body>\n{body}\n<script>\n{}\n</script>\n</body>\n</html>\n",
|
||||
script.replace("</script", "<\\/script")
|
||||
)
|
||||
}
|
||||
|
||||
fn zip(file: &Path, entries: &[(String, String)]) -> R<()> {
|
||||
let f = std::fs::File::create(file).map_err(|e| format!("{}: {e}", file.display()))?;
|
||||
let mut w = zip::ZipWriter::new(f);
|
||||
let o = zip::write::SimpleFileOptions::default().compression_method(zip::CompressionMethod::Deflated);
|
||||
for (name, text) in entries {
|
||||
w.start_file(name.as_str(), o).map_err(|e| e.to_string())?;
|
||||
w.write_all(text.as_bytes()).map_err(|e| e.to_string())?;
|
||||
}
|
||||
w.finish().map_err(|e| e.to_string())?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// `network`'s package of `script` (its preamble already first) written into `out` as NAME-NETWORK.html or .zip
|
||||
pub fn write(network: &str, name: &str, script: &str, out: &Path, orientation: &str) -> R<Written> {
|
||||
let html = |head: &str, body: &str| page(name, head, body, script);
|
||||
let file = match network {
|
||||
// a ZIP with index.html; exitapi.js and the orientation tag in the head (Google Ads help 9981650)
|
||||
"google" => {
|
||||
let o = if orientation == "both" { "portrait,landscape" } else { orientation };
|
||||
let head = format!("<meta name=\"ad.orientation\" content=\"{o}\">\n<script type=\"text/javascript\" src=\"https://tpc.googlesyndication.com/pagead/gadgets/html5/api/exitapi.js\"></script>");
|
||||
let f = out.join(format!("{name}-google.zip"));
|
||||
zip(&f, &[("index.html".into(), html(&head, ""))])?;
|
||||
f
|
||||
}
|
||||
// a ZIP with index.html and config.json; TikTok's playable SDK before the game's script (TikTok Ads help)
|
||||
"tiktok" => {
|
||||
let o = match orientation {
|
||||
"portrait" => 1,
|
||||
"landscape" => 2,
|
||||
_ => 0,
|
||||
};
|
||||
let body = "<script src=\"https://sf16-muse-va.ibytedtos.com/obj/union-fe-nc-i18n/playable/sdk/playable-sdk.js\"></script>";
|
||||
let f = out.join(format!("{name}-tiktok.zip"));
|
||||
zip(&f, &[("index.html".into(), html("", body)), ("config.json".into(), format!("{{\"playable_orientation\": {o}}}\n"))])?;
|
||||
f
|
||||
}
|
||||
// a ZIP holding a folder and a page of the same name
|
||||
"mintegral" => {
|
||||
let f = out.join(format!("{name}-mintegral.zip"));
|
||||
zip(&f, &[(format!("{name}/{name}.html"), html("", ""))])?;
|
||||
f
|
||||
}
|
||||
// one HTML file, everything inlined; MRAID is injected by the network's webview (Meta: data URIs only)
|
||||
"applovin" | "unity" | "meta" | "moloco" | "liftoff" | "preview" => {
|
||||
let f = out.join(format!("{name}-{network}.html"));
|
||||
std::fs::write(&f, html("", "")).map_err(|e| format!("{}: {e}", f.display()))?;
|
||||
f
|
||||
}
|
||||
other => return Err(format!("raea playable: no network {other} (one of {})", NETWORKS.join(", "))),
|
||||
};
|
||||
let bytes = std::fs::metadata(&file).map(|m| m.len()).unwrap_or(0);
|
||||
Ok(Written { network: network.into(), file, bytes })
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn a_script_cannot_end_its_page_early() {
|
||||
let p = super::page("t", "", "", "a('</script>')");
|
||||
assert_eq!(p.matches("</script").count(), 1, "{p}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_preamble_names_the_network_as_a_string() {
|
||||
assert_eq!(super::preamble("applovin", "{}", "{}"), "var __RAEA_NETWORK__=\"applovin\",__RAEA_STORE__={},__RAEA_PLAYABLE__={};");
|
||||
}
|
||||
}
|
||||
+10
-1
@@ -4,7 +4,7 @@ version = "0.1.0"
|
||||
edition = "2024"
|
||||
license = "FSL-1.1-ALv2"
|
||||
publish = false
|
||||
description = "raea scene lint|explain|light|stage: a composition's frames stepped without drawing and held to the contact, light and stage checks"
|
||||
description = "raea scene lint|explain|faults|light|stage|lod: a composition's frames stepped without drawing and held to the contact, light and stage checks"
|
||||
|
||||
[dependencies]
|
||||
raea-runtime-bundle = { path = "../../runtime/bundle" }
|
||||
@@ -12,10 +12,19 @@ raea-runtime-export = { path = "../../runtime/export" }
|
||||
raea-sys-contact = { path = "../../systems/contact" }
|
||||
raea-sys-light-meter = { path = "../../systems/light-meter" }
|
||||
raea-sys-stage = { path = "../../systems/stage" }
|
||||
# raea scene faults: whether a viewer would notice each lint finding, and the judge learning from verdicts
|
||||
raea-sys-notice = { path = "../../systems/notice" }
|
||||
# raea scene faults --clip: a character's motion held to what a body does
|
||||
raea-sys-motionfaults = { path = "../../systems/motionfaults" }
|
||||
raea-sys-body = { path = "../../systems/body" }
|
||||
# each part's planned detail beside how large the frames show it (MK21, MK23)
|
||||
raea-runtime-lod-plan = { path = "../../runtime/lod-plan" }
|
||||
# its results as Findings (docs/direction.feature DR3)
|
||||
raea-core-facts = { path = "../../core/facts" }
|
||||
# camera clearance (MK16): the parts, their models' triangles, and the camera's point in space
|
||||
raea-core-scene = { path = "../../core/scene" }
|
||||
bevy = { version = "=0.20.0", default-features = false, features = ["std"] }
|
||||
dunce = "1"
|
||||
# --ask: the fault ringed on its frame for the vision model
|
||||
image = { version = "0.25", default-features = false, features = ["png"] }
|
||||
serde_json = "1"
|
||||
@@ -0,0 +1,109 @@
|
||||
//! `raea scene faults EDIT.tsx --composition ID --ask N` (docs/notice.feature NT12): a vision model asked only what
|
||||
//! geometry can't say, whether a likely fault is meant. The judge has already found it, measured it and found the
|
||||
//! frame it shows largest on; that frame is rendered, the fault's spots ringed on it, and `raea ask` (clef-omni) is
|
||||
//! handed the picture with the scene's own words for it: which part, what it's on or in, by how much. Its answer,
|
||||
//! meant or a mistake, is kept as a verdict (`by: "ask"`) when it's SURE or more, and any person's verdict on the same
|
||||
//! finding outranks it.
|
||||
//! The ringed pictures stay in the project's review/faults-ask/ for a person to look at.
|
||||
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
|
||||
use serde_json::Value;
|
||||
|
||||
use raea_sys_notice::{FAULT, Judged, labels};
|
||||
|
||||
/// Rendered this wide (its height kept to the composition's shape).
|
||||
const WIDE: u32 = 960;
|
||||
/// An answer this sure or more is kept as a verdict; under it, said as unsure and kept out of training. On room
|
||||
/// 106's shot-window (2026-11-27) the model was 0.52-0.65 sure on chair feet pressed into carpet and a leg through a
|
||||
/// strap, and 0.72-0.78 on a sunk kit, a floating hat and a part sunk into a door.
|
||||
const SURE: f64 = 0.7;
|
||||
|
||||
/// One ring around every spot of the fault on the picture, a little out from them, in red.
|
||||
fn ring(png: &Path, marks: &[[f32; 2]]) -> Result<(), String> {
|
||||
let mut img = image::open(png).map_err(|e| format!("{}: {e}", png.display()))?.to_rgb8();
|
||||
let (w, h) = (img.width() as f32, img.height() as f32);
|
||||
let pts: Vec<(f32, f32)> = marks.iter().map(|m| ((m[0] + 1.0) * 0.5 * w, (1.0 - m[1]) * 0.5 * h)).collect();
|
||||
let (cx, cy) = (pts.iter().map(|p| p.0).sum::<f32>() / pts.len() as f32, pts.iter().map(|p| p.1).sum::<f32>() / pts.len() as f32);
|
||||
let r = pts.iter().map(|p| (p.0 - cx).hypot(p.1 - cy)).fold(0.0f32, f32::max) + 0.03 * w;
|
||||
for y in 0..img.height() {
|
||||
for x in 0..img.width() {
|
||||
let d = (x as f32 - cx).hypot(y as f32 - cy);
|
||||
if (d - r).abs() <= 2.5 {
|
||||
img.put_pixel(x, y, image::Rgb([255, 30, 30]));
|
||||
}
|
||||
}
|
||||
}
|
||||
img.save(png).map_err(|e| format!("{}: {e}", png.display()))
|
||||
}
|
||||
|
||||
fn question(j: &Judged) -> String {
|
||||
let f = &j.fault;
|
||||
let what = match &f.into {
|
||||
Some(into) => format!("{} (against {into})", f.part),
|
||||
None => f.part.clone(),
|
||||
};
|
||||
format!(
|
||||
"This is a frame of a 3D scene. Inside the red ring is {what}. A geometry check measured: {}. Judge only what is inside the ring. Is it meant to be like this (cloth draped over an edge, something hung, feet pressed into soft carpet, something set into a wall), or a mistake a viewer would notice (something floating, sunk into something, passing through something, faces flickering)?",
|
||||
f.says
|
||||
)
|
||||
}
|
||||
|
||||
/// The likeliest `n` faults asked about, their answers kept as verdicts.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn run(tsx: &Path, shot: &str, judged: &[Judged], frames: &[i64], w: u32, h: u32, n: usize, dry: bool) -> Result<String, String> {
|
||||
let project = labels::project_of(tsx);
|
||||
let dir = project.join("review").join("faults-ask");
|
||||
std::fs::create_dir_all(&dir).map_err(|e| format!("{}: {e}", dir.display()))?;
|
||||
let me = std::env::current_exe().map_err(|e| e.to_string())?;
|
||||
let tall = ((WIDE as f32 * h as f32 / w as f32 / 2.0).round() as u32 * 2).max(2);
|
||||
let (mut out, mut rows) = (Vec::new(), Vec::new());
|
||||
for j in judged.iter().filter(|j| j.p >= FAULT && j.seen.best.is_some() && !j.seen.marks.is_empty()).take(n) {
|
||||
let frame = frames[j.seen.best.unwrap()];
|
||||
let name = format!("{shot}-{}", j.fault.key).replace(|c: char| !(c.is_ascii_alphanumeric() || c == '-'), "_");
|
||||
let (png, mp4) = (dir.join(format!("{name}.png")), dir.join(format!("{name}.mp4")));
|
||||
// the frame as the render draws it, its own end checks left out (they'd judge the scene again)
|
||||
let drawn = Command::new(&me)
|
||||
.args(["render", &tsx.to_string_lossy(), "--composition", shot, "--frame", &frame.to_string(), "--w", &WIDE.to_string(), "--h", &tall.to_string(), "-o", &png.to_string_lossy()])
|
||||
.env("RAEA_FAULTS_CHECK", "0")
|
||||
.env("RAEA_CLIP_CHECK", "0")
|
||||
.output()
|
||||
.map_err(|e| format!("raea render: {e}"))?;
|
||||
if !drawn.status.success() {
|
||||
return Err(format!("raea render frame {frame}: {}", String::from_utf8_lossy(&drawn.stderr).lines().last().unwrap_or("")));
|
||||
}
|
||||
ring(&png, &j.seen.marks)?;
|
||||
// raea ask watches a picture move: the still as a second of video
|
||||
let made = Command::new("ffmpeg").args(["-y", "-loglevel", "error", "-loop", "1", "-i", &png.to_string_lossy(), "-t", "1", "-r", "10", "-pix_fmt", "yuv420p", &mp4.to_string_lossy()]).status().map_err(|e| format!("ffmpeg: {e}"))?;
|
||||
if !made.success() {
|
||||
return Err(format!("ffmpeg couldn't make {}", mp4.display()));
|
||||
}
|
||||
let mut cmd = Command::new(&me);
|
||||
cmd.args(["ask", &mp4.to_string_lossy(), &question(j), "--choose", "meant,mistake", "--brief", "none", "--json"]);
|
||||
if dry {
|
||||
cmd.arg("--dry");
|
||||
}
|
||||
let asked = cmd.output().map_err(|e| format!("raea ask: {e}"))?;
|
||||
let text = String::from_utf8_lossy(&asked.stdout);
|
||||
let first: Value = text.lines().find_map(|l| serde_json::from_str::<Value>(l).ok()).unwrap_or(Value::Null);
|
||||
let choice = first["choice"].as_str().or_else(|| first["answer"].as_str()).map(str::to_lowercase);
|
||||
let says = first["says"].as_str().unwrap_or("").to_string();
|
||||
let sure = first["value"].as_f64().unwrap_or(0.0);
|
||||
match choice.as_deref() {
|
||||
Some(c) if (c.contains("mistake") || c.contains("meant")) && sure < SURE => {
|
||||
out.push(format!("{:.2} {} -> unsure ({says}), not kept (frame {frame}, {})", j.p, j.fault.key, png.display()));
|
||||
}
|
||||
Some(c) if c.contains("mistake") || c.contains("meant") => {
|
||||
let real = c.contains("mistake");
|
||||
rows.push(labels::row(&j.fault.key, real, "ask", shot, &j.x, &j.toks));
|
||||
out.push(format!("{:.2} {} -> {}{} (frame {frame}, {})", j.p, j.fault.key, if real { "a mistake" } else { "meant" }, if says.is_empty() { String::new() } else { format!(": {says}") }, png.display()));
|
||||
}
|
||||
_ if dry => out.push(format!("{:.2} {} would be asked on frame {frame} ({})", j.p, j.fault.key, png.display())),
|
||||
_ => out.push(format!("{:.2} {} not answered: {}", j.p, j.fault.key, first["not_asked"].as_str().or(first["problem"].as_str()).unwrap_or(text.lines().next().unwrap_or("")))),
|
||||
}
|
||||
}
|
||||
labels::append(&project, &rows)?;
|
||||
out.push(format!("{} asked, {} answers kept as verdicts (by ask; a person's verdict outranks them) in {}", out.len(), rows.len(), project.join("review").join("faults.labels.jsonl").display()));
|
||||
Ok(out.join("\n"))
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
//! `raea scene faults EDIT.tsx --composition ID --motion`: the composition's characters held to what a body does
|
||||
//! (raea-sys-motionfaults), read from the scene itself, with no clip written out. raea/character's `<Character>` draws
|
||||
//! each joint as a marker part named `<name>-<joint>` (its joint.glb) at the joint's place and turn, and every joint's
|
||||
//! rest frame is the world's, so a joint's turn from rest against its parent is its parent's world turn undone from its
|
||||
//! own: each frame's pose comes back exactly. The skeleton is the body's skeleton.json beside its joint.glb.
|
||||
//!
|
||||
//! And the hands against the scene: each finger bone, the thumb's too, as a segment from its joint toward its tip,
|
||||
//! tested against every other part's real triangles (raea-sys-notice's BVH). A bone that crosses a surface has gone in
|
||||
//! at least a finger's half thickness: a thumb through a grip, fingers through a mug's wall. And the other way: while
|
||||
//! two or more fingertips rest on a surface (the hand holds something), a tip left 3 cm or more off it hasn't closed:
|
||||
//! the thumb not wrapping round a post.
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use bevy::math::{Quat, Vec3};
|
||||
use raea_core_scene::Item;
|
||||
use raea_sys_body::rig::{FINGERS, Pose, Side, Skeleton};
|
||||
use raea_sys_motionfaults::{Clip, Fault, Hit, grip, stretches};
|
||||
use serde_json::Value;
|
||||
|
||||
/// A distal bone is tested this far toward its tip (its tip is the skin's end, which rests on what it touches).
|
||||
const ALONG: f32 = 0.85;
|
||||
|
||||
fn name(it: &Item) -> Option<&str> {
|
||||
it.props.get("name").and_then(Value::as_str)
|
||||
}
|
||||
|
||||
/// The characters on a frame: each one's name and the folder its joint.glb is in.
|
||||
fn characters(its: &[Item]) -> Vec<(String, String)> {
|
||||
let mut out: Vec<(String, String)> = Vec::new();
|
||||
for it in its {
|
||||
let (Some(n), Some(src)) = (name(it), it.props.get("src").and_then(Value::as_str)) else { continue };
|
||||
if let (Some(body), true) = (n.strip_suffix("-body"), src.ends_with("/body.glb")) {
|
||||
let folder = src.trim_end_matches("/body.glb").to_string();
|
||||
if !out.iter().any(|o| o.0 == body) {
|
||||
out.push((body.to_string(), folder));
|
||||
}
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// The body's skeleton.json, its folder as the scene names it found from the composition's folder up.
|
||||
fn skeleton(dir: &Path, folder: &str) -> Option<(PathBuf, Skeleton)> {
|
||||
let rel = folder.trim_start_matches('/');
|
||||
for up in dir.ancestors().take(4) {
|
||||
for sub in ["", "media", "assets", "public", "compositions/media"] {
|
||||
let p = up.join(sub).join(rel).join("skeleton.json");
|
||||
if let Ok(t) = std::fs::read_to_string(&p) {
|
||||
return Skeleton::from_json(&t).ok().map(|s| (p, s));
|
||||
}
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
/// A part's place and turn (its scale taken out).
|
||||
fn placed(it: &Item) -> (Vec3, Quat) {
|
||||
let (_, r, t) = it.world.to_scale_rotation_translation();
|
||||
(t, r)
|
||||
}
|
||||
|
||||
/// One character's frames as a clip, and each frame's joint places in the scene (for the hands against it).
|
||||
fn clip_of(skel: &Skeleton, who: &str, frames: &[Vec<Item>], fps: f32) -> (Clip, Vec<Vec<Option<(Vec3, Quat)>>>) {
|
||||
let (mut poses, mut places) = (Vec::new(), Vec::new());
|
||||
for its in frames {
|
||||
let at: Vec<Option<(Vec3, Quat)>> = skel.joints.iter().map(|j| its.iter().find(|it| name(it) == Some(&format!("{who}-{}", j.name))).map(placed)).collect();
|
||||
let mut p: Pose = skel.rest();
|
||||
for (i, j) in skel.joints.iter().enumerate() {
|
||||
let Some((pos, rot)) = at[i] else { continue };
|
||||
match j.parent.and_then(|q| at[q]) {
|
||||
Some((_, prot)) => p.turns[i] = (prot.inverse() * rot).normalize(),
|
||||
None if j.parent.is_none() => {
|
||||
p.turns[i] = rot;
|
||||
p.root = pos;
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
}
|
||||
poses.push(p);
|
||||
places.push(at);
|
||||
}
|
||||
(Clip { skel: skel.clone(), fps, poses, held: None }, places)
|
||||
}
|
||||
|
||||
/// The hands against the scene's other parts, frame by frame: finger bones through a surface (`through`), and tips
|
||||
/// left off what the hand holds (`grip`), as faults over the stretches they last.
|
||||
fn hands(skel: &Skeleton, who: &str, frames: &[Vec<Item>], places: &[Vec<Option<(Vec3, Quat)>>], numbers: &[i64]) -> Vec<Fault> {
|
||||
let mut hits: Vec<Hit> = Vec::new();
|
||||
let bones: Vec<usize> = Side::BOTH.iter().flat_map(|&s| FINGERS.iter().filter_map(move |f| skel.finger(f, s))).flatten().collect();
|
||||
let tips: Vec<Vec<usize>> = Side::BOTH.iter().map(|&s| FINGERS.iter().filter_map(|f| skel.finger(f, s).map(|b| b[2])).collect()).collect();
|
||||
for (k, its) in frames.iter().enumerate() {
|
||||
// the scene but the character itself (its skin is drawn at its bind pose in the parts, its markers are specks)
|
||||
let mine = format!("{who}-");
|
||||
let others: Vec<Item> = its.iter().filter(|it| !name(it).is_some_and(|n| n.starts_with(&mine))).cloned().collect();
|
||||
// every part: a mesh's place is often in its own vertices, its transform the world's origin (gambit's ladder lab),
|
||||
// so nothing can be left out by where its transform sits
|
||||
if bones.iter().all(|&i| places[k][i].is_none()) {
|
||||
continue;
|
||||
}
|
||||
let near: Vec<Item> = others.into_iter().filter(|it| it.kind != "camera").collect();
|
||||
let scene = raea_sys_notice::Scene::of(&near);
|
||||
let bone = |i: usize, along: f32| places[k][i].map(|(a, rot)| (a, a + rot * ((skel.joints[i].tail - skel.joints[i].head) * along)));
|
||||
for &i in &bones {
|
||||
if let Some((a, b)) = bone(i, ALONG)
|
||||
&& scene.blocked(a, b, 0.0)
|
||||
{
|
||||
hits.push(Hit { check: "through", joint: skel.joints[i].name.clone(), f: k, value: 0.0, unit: "m", what: String::new() });
|
||||
}
|
||||
}
|
||||
for side in &tips {
|
||||
let off: Vec<(usize, f32)> = side.iter().filter_map(|&i| bone(i, 1.0).map(|(_, tip)| (i, scene.reach(tip, grip::LOOK)))).collect();
|
||||
for o in grip::open(&off.iter().map(|o| o.1).collect::<Vec<_>>()) {
|
||||
hits.push(Hit { check: "grip", joint: skel.joints[off[o].0].name.clone(), f: k, value: off[o].1, unit: "m", what: String::new() });
|
||||
}
|
||||
}
|
||||
}
|
||||
// one fault per check and joint while the frames run on, as a clip's are (motionfaults' stretches)
|
||||
let mut out = stretches(hits);
|
||||
for f in &mut out {
|
||||
(f.from, f.to, f.peak) = (numbers[f.from] as usize, numbers[f.to] as usize, numbers[f.peak] as usize);
|
||||
f.says = match f.check {
|
||||
"grip" => format!("{} is {:.0} mm off what the hand holds (it hasn't closed on it), frames {}-{}", f.joint, f.value * 1000.0, f.from, f.to),
|
||||
_ => format!("{} passes through a part of the scene, frames {}-{}", f.joint, f.from, f.to),
|
||||
};
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// One character's findings over the composition's frames.
|
||||
pub struct Found {
|
||||
pub who: String,
|
||||
pub skeleton: PathBuf,
|
||||
pub frames: usize,
|
||||
pub faults: Vec<Fault>,
|
||||
}
|
||||
|
||||
/// Every character's motion faults over the frames given (their numbers alongside); a character whose skeleton.json
|
||||
/// can't be found is said in the second list.
|
||||
pub fn run(dir: &Path, frames: &[(i64, Vec<Item>)], fps: f32) -> Result<(Vec<Found>, Vec<String>), String> {
|
||||
let Some((_, first)) = frames.first() else { return Err("no frames".into()) };
|
||||
let found = characters(first);
|
||||
if found.is_empty() {
|
||||
return Err("no characters in the composition (a <Character> draws <name>-body and <name>-<joint> parts)".into());
|
||||
}
|
||||
let numbers: Vec<i64> = frames.iter().map(|f| f.0).collect();
|
||||
let items: Vec<Vec<Item>> = frames.iter().map(|f| f.1.clone()).collect();
|
||||
let (mut out, mut missing) = (Vec::new(), Vec::new());
|
||||
for (who, folder) in found {
|
||||
let Some((path, skel)) = skeleton(dir, &folder) else {
|
||||
missing.push(format!("{who}: no skeleton.json for {folder}, not checked"));
|
||||
continue;
|
||||
};
|
||||
let (clip, places) = clip_of(&skel, &who, &items, fps);
|
||||
let mut faults = raea_sys_motionfaults::check(&clip);
|
||||
// the clip's frames are the composition's from its first
|
||||
for f in &mut faults {
|
||||
(f.from, f.to, f.peak) = (numbers[f.from] as usize, numbers[f.to.min(numbers.len() - 1)] as usize, numbers[f.peak] as usize);
|
||||
}
|
||||
faults.extend(hands(&skel, &who, &items, &places, &numbers));
|
||||
out.push(Found { who, skeleton: path, frames: clip.poses.len(), faults });
|
||||
}
|
||||
Ok((out, missing))
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
//! Camera clearance (docs/make.feature MK16, from AnyShot's clearance pass): every frame, how near the camera passes to
|
||||
//! Camera clearance (docs/goal.feature MK16, from AnyShot's clearance pass): every frame, how near the camera passes to
|
||||
//! each solid part, and where it comes closer than a person carrying it could (0.45 m by default). A camera that
|
||||
//! grazes a door frame or pushes into a desk draws the inside of the part, or a wall filling the frame; the boxes the
|
||||
//! stage keeps say it without drawing. Only solids count: volumes, decals, footage, 2D, see-through parts (glass) and
|
||||
|
||||
@@ -0,0 +1,172 @@
|
||||
//! `raea scene faults EDIT.tsx`: the lint's findings judged as a viewer of the shot would see them (raea-sys-notice):
|
||||
//! every frame's camera asked where each one shows and how large, a small model saying how likely it is to read as a
|
||||
//! fault, the likeliest first. Hidden ones (walls meeting the ceiling inside the slab) are counted, not listed.
|
||||
//!
|
||||
//! It learns: `--real KEY` and `--fine KEY` keep a verdict on a finding beside the project (review/
|
||||
//! faults.labels.jsonl), and a finding the last run said that's gone while both its parts remain is kept as fixed,
|
||||
//! so real. `raea scene faults train [FOLDER]` fits the model to every project's verdicts under FOLDER.
|
||||
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use raea_runtime_bundle::{bundle_composition, comp_opts};
|
||||
use raea_runtime_export::{frame_of, items};
|
||||
use raea_sys_notice::{FAULT, Judged, Model, labels};
|
||||
|
||||
/// The most frames whose cameras are asked (evenly over the shot).
|
||||
const CAMERAS: usize = 48;
|
||||
|
||||
pub fn cli(args: &[String]) -> Result<String, String> {
|
||||
let Some(edit) = args.get(2) else { return Err(crate::USAGE.into()) };
|
||||
if edit == "train" {
|
||||
return train(args.get(3).map(String::as_str));
|
||||
}
|
||||
if edit == "--clip" {
|
||||
return crate::motion::cli(args);
|
||||
}
|
||||
let tsx = dunce::canonicalize(std::path::PathBuf::from(edit)).map_err(|e| format!("{edit}: {e}"))?;
|
||||
let dir = tsx.parent().unwrap().to_path_buf();
|
||||
let frame = frame_of(args)?;
|
||||
let opts = comp_opts(args)?;
|
||||
let shot = opts.composition.clone().unwrap_or_default();
|
||||
let js = std::env::temp_dir().join(format!("raea-faults-{}.js", std::process::id()));
|
||||
bundle_composition(&tsx, &js, &opts, None)?;
|
||||
let got = raea_runtime_export::scene_frames(&js, &dir, 0, true, &[]);
|
||||
let _ = std::fs::remove_file(&js);
|
||||
let (frames, w, h, fps) = got?.ok_or("the composition has no 3D")?;
|
||||
// the composition's characters held to what a body does, read from the scene (chars.rs)
|
||||
if args.iter().any(|a| a == "--motion") {
|
||||
let all: Vec<(i64, Vec<raea_core_scene::Item>)> = frames.iter().map(|fr| (fr.0, items(&fr.1))).collect();
|
||||
let (text, v, n) = crate::motion::composition(&tsx, &shot, &dir, &all, fps as f32, args)?;
|
||||
return finish(if args.iter().any(|a| a == "--json") { serde_json::to_string_pretty(&v).unwrap_or_default() } else { text }, n);
|
||||
}
|
||||
let k = frames.iter().position(|(f, _)| *f == frame).ok_or_else(|| format!("no frame {frame}"))?;
|
||||
let other = if k + 1 < frames.len() { k + 1 } else { k.saturating_sub(1) };
|
||||
let (now, next) = (items(&frames[k].1), items(&frames[other].1));
|
||||
let (found, _) = raea_sys_contact::lint(&now, &next);
|
||||
// the cameras: the frame's own and evenly over the rest of the shot
|
||||
let step = frames.len().div_ceil(CAMERAS).max(1);
|
||||
// and each view's frame number, for the frame a fault shows largest on (--ask)
|
||||
let (mut views, mut view_frames) = (vec![now.clone()], vec![frame]);
|
||||
for (i, (f, fr)) in frames.iter().enumerate() {
|
||||
if i != k && i % step == 0 {
|
||||
views.push(items(fr));
|
||||
view_frames.push(*f);
|
||||
}
|
||||
}
|
||||
let model = Model::load();
|
||||
let judged = raea_sys_notice::judge(&found, &views, w, h, &model);
|
||||
// faults of known size planted and judged: the judge measured, nothing kept (seed.rs)
|
||||
if let Some(n) = raea_runtime_bundle::flag(args, "--seed") {
|
||||
let n = n.parse::<usize>().map_err(|_| "--seed takes how many faults to plant")?;
|
||||
return Ok(crate::seed::run(&now, &next, &views, &found, w, h, &model, n));
|
||||
}
|
||||
|
||||
// a vision model asked whether the likeliest faults are meant (ask.rs), its answers kept as verdicts
|
||||
if let Some(n) = raea_runtime_bundle::flag(args, "--ask") {
|
||||
let n = n.parse::<usize>().map_err(|_| "--ask takes how many of the likeliest faults to ask about")?;
|
||||
return crate::ask::run(&tsx, &shot, &judged, &view_frames, w, h, n, args.iter().any(|a| a == "--dry"));
|
||||
}
|
||||
|
||||
// what it learns from: this run against the last, and any verdict given now
|
||||
let project = labels::project_of(&tsx);
|
||||
let keys: Vec<String> = judged.iter().map(|j| j.fault.key.clone()).collect();
|
||||
let parts: Vec<String> = found.iter().flat_map(|v| ["part", "on", "into"].into_iter().filter_map(move |n| v[n].as_str())).map(String::from).collect();
|
||||
let mut rows = labels::fixed(&labels::last(&project, &shot), &keys, &parts);
|
||||
let fixed = rows.len();
|
||||
for (name, real) in [("--real", true), ("--fine", false)] {
|
||||
for key in raea_runtime_bundle::flags(args, name) {
|
||||
let j = judged.iter().find(|j| j.fault.key == key).ok_or_else(|| format!("{name} {key}: no finding by that key on this shot (keys are listed with --json, or after each line)"))?;
|
||||
rows.push(labels::row(&key, real, "marked", &shot, &j.x, &j.toks));
|
||||
}
|
||||
}
|
||||
labels::append(&project, &rows)?;
|
||||
let last: Vec<Value> = judged.iter().map(|j| json!({"key": j.fault.key, "part": j.fault.part, "into": j.fault.into, "x": j.x, "toks": j.toks, "shot": shot})).collect();
|
||||
labels::keep_last(&project, &shot, last)?;
|
||||
|
||||
let faults: Vec<&Judged> = judged.iter().filter(|j| j.p >= FAULT).collect();
|
||||
let hidden = judged.iter().filter(|j| j.seen.shown == 0).count();
|
||||
if args.iter().any(|a| a == "--json") {
|
||||
let rows: Vec<Value> = judged
|
||||
.iter()
|
||||
.map(|j| json!({"key": j.fault.key, "check": j.fault.check, "part": j.fault.part, "into": j.fault.into, "p": (j.p * 1e3).round() / 1e3, "fault": j.p >= FAULT,
|
||||
"seen": {"frames": j.seen.frames, "shown": j.seen.shown, "px": (j.seen.px * 10.0).round() / 10.0, "near": (j.seen.near * 1e3).round() / 1e3}, "says": j.fault.says}))
|
||||
.collect();
|
||||
let text = serde_json::to_string_pretty(&json!({"frame": frame, "model": model.from, "labels": model.labels, "findings": rows, "faults": faults.len(), "hidden": hidden, "fixed": fixed})).unwrap_or_default();
|
||||
return finish(text, faults.len());
|
||||
}
|
||||
let mut out: Vec<String> = Vec::new();
|
||||
for j in &judged {
|
||||
if j.seen.shown == 0 && j.p < FAULT {
|
||||
continue;
|
||||
}
|
||||
let tag = if j.p >= FAULT { "FAULT" } else { "maybe" };
|
||||
out.push(format!("{:.2} {tag} {} (seen on {}/{} frames, {:.1} px, {:.2} m off) key: {}", j.p, j.fault.says, j.seen.shown, j.seen.frames, j.seen.px, j.seen.near, j.fault.key));
|
||||
}
|
||||
out.push(format!(
|
||||
"frame {frame}: {} findings, {} likely faults, {} seen but likely fine, {hidden} no camera sees; judged by {} ({} labels){}",
|
||||
judged.len(),
|
||||
faults.len(),
|
||||
judged.len() - faults.len() - judged.iter().filter(|j| j.seen.shown == 0 && j.p < FAULT).count(),
|
||||
model.from,
|
||||
model.labels,
|
||||
if fixed > 0 { format!("; {fixed} fixed since the last run, kept as real") } else { String::new() }
|
||||
));
|
||||
finish(out.join("\n"), faults.len())
|
||||
}
|
||||
|
||||
/// Faults fail it, as the lint's errors do.
|
||||
fn finish(text: String, faults: usize) -> Result<String, String> {
|
||||
if faults > 0 {
|
||||
println!("{text}");
|
||||
std::process::exit(1);
|
||||
}
|
||||
Ok(text)
|
||||
}
|
||||
|
||||
/// `raea scene faults train [FOLDER]`: every project's verdicts under FOLDER (default: here) fitted, the model kept in
|
||||
/// raea's models folder for every run after.
|
||||
fn train(root: Option<&str>) -> Result<String, String> {
|
||||
let root = std::path::PathBuf::from(root.unwrap_or("."));
|
||||
let files = labels::files(&root, 4);
|
||||
let ex: Vec<_> = files.iter().flat_map(|f| labels::examples(f)).collect();
|
||||
if ex.is_empty() {
|
||||
return Err(format!("no verdicts under {} (review/faults.labels.jsonl: --real KEY, --fine KEY, and fixes)", root.display()));
|
||||
}
|
||||
let m = Model::fit(&ex);
|
||||
let right = ex.iter().filter(|(x, t, y)| (m.score(x, t) >= FAULT) == (*y >= 0.5)).count();
|
||||
let before = ex.iter().filter(|(x, t, y)| (Model::prior().score(x, t) >= FAULT) == (*y >= 0.5)).count();
|
||||
let p = raea_sys_notice::model::path();
|
||||
std::fs::create_dir_all(p.parent().unwrap()).map_err(|e| e.to_string())?;
|
||||
std::fs::write(&p, serde_json::to_string_pretty(&m.to_json()).unwrap_or_default()).map_err(|e| format!("{}: {e}", p.display()))?;
|
||||
let real = ex.iter().filter(|e| e.2 >= 0.5).count();
|
||||
// held out: each finding (one finding judged on two shots shares its words) fitted without, then asked
|
||||
let (held, finds) = held_out(&ex.iter().map(|e| (e.1.clone(), e.0.clone(), e.1.clone(), e.2)).collect::<Vec<_>>());
|
||||
// and a shot at a time (each project's own shot names, so a shot is a project's view): a scene it has never seen
|
||||
let by_shot: Vec<_> = files.iter().enumerate().flat_map(|(n, f)| labels::shots(f).into_iter().map(move |(s, x, t, y)| (format!("{n}/{s}"), x, t, y))).collect();
|
||||
let (unseen, names) = held_out(&by_shot);
|
||||
Ok(format!(
|
||||
"{} verdicts on {} findings from {} projects ({real} real, {} fine): the prior agreed with {before}, the fitted judge with {right}, with {held} each fitted without its own finding (held out), and with {unseen} each fitted without its whole shot ({} shots, a scene it hasn't seen); kept in {}\n{}",
|
||||
ex.len(),
|
||||
finds,
|
||||
files.len(),
|
||||
ex.len() - real,
|
||||
names,
|
||||
p.display(),
|
||||
crate::motion::train()?
|
||||
))
|
||||
}
|
||||
|
||||
/// Verdicts a judge gets right fitted without their own group (a finding's words, a shot): each group left out in
|
||||
/// turn, fitted on the rest, then asked. With how many groups there were.
|
||||
fn held_out<K: Ord>(rows: &[(K, Vec<f32>, Vec<String>, f32)]) -> (usize, usize) {
|
||||
let mut groups: Vec<&K> = rows.iter().map(|r| &r.0).collect();
|
||||
groups.sort();
|
||||
groups.dedup();
|
||||
let (mut right, n) = (0, groups.len());
|
||||
for g in groups {
|
||||
let rest: Vec<_> = rows.iter().filter(|r| &r.0 != g).map(|r| (r.1.clone(), r.2.clone(), r.3)).collect();
|
||||
let m = Model::fit(&rest);
|
||||
right += rows.iter().filter(|r| &r.0 == g && (m.score(&r.1, &r.2) >= FAULT) == (r.3 >= 0.5)).count();
|
||||
}
|
||||
(right, n)
|
||||
}
|
||||
+15
-3
@@ -1,6 +1,7 @@
|
||||
//! `raea scene lint|explain|light|stage`: a composition's frames stepped without drawing and handed to raea-sys-contact
|
||||
//! `raea scene lint|explain|light|stage|lod`: a composition's frames stepped without drawing and handed to raea-sys-contact
|
||||
//! (what each part rests on, and parts that clip), raea-sys-light-meter (the light on a subject) and raea-sys-stage (3D
|
||||
//! type that can't be read, parts that snap, a camera that lurches, empty frames: docs/stage-guards.feature).
|
||||
//! type that can't be read, parts that snap, a camera that lurches, empty frames: docs/stage-guards.feature). `lod` is
|
||||
//! each part's planned detail beside how large the frames show it (docs/goal.feature MK23).
|
||||
|
||||
use serde_json::json;
|
||||
|
||||
@@ -9,10 +10,19 @@ use raea_runtime_export::{frame_of, items};
|
||||
|
||||
// how near the camera passes to each solid part, every frame (`--clearance M`, MK16)
|
||||
pub mod clearance;
|
||||
// the lint's findings judged as a viewer of the shot would see them, learning from verdicts (raea-sys-notice)
|
||||
mod ask;
|
||||
mod chars;
|
||||
mod faults;
|
||||
mod motion;
|
||||
// faults of known size planted, to measure the judge (`faults --seed N`)
|
||||
mod seed;
|
||||
mod light;
|
||||
// each part's planned detail beside how large the frames show it (MK23)
|
||||
pub mod lod;
|
||||
mod stage;
|
||||
|
||||
pub const USAGE: &str = "raea scene lint|explain|light|stage EDIT.tsx [--composition ID] [--frame N] [--part NAME] [--from N] [--to N] [--clearance M] [--json]";
|
||||
pub const USAGE: &str = "raea scene lint|explain|faults|light|stage|lod EDIT.tsx [--composition ID] [--frame N] [--part NAME] [--from N] [--to N] [--clearance M] [--real KEY] [--fine KEY] [--seed N] [--ask N [--dry]] [--motion] [--json] | raea scene faults train [FOLDER] | raea scene faults --clip CLIP.json|FOLDER [--real KEY] [--fine KEY] [--fine-from N] [--fine-upto N] [--real-from N] [--real-upto N] [--by NAME] [--seed N] [--json]";
|
||||
|
||||
/// `raea scene lint|explain EDIT.tsx [--composition ID] [--frame N] [--json]`: the frame's parts measured
|
||||
/// (frame 0 by default). `lint` says the faults (errors fail it: floating, sunk, clipping; warnings: in the air,
|
||||
@@ -24,6 +34,8 @@ pub fn cli(args: &[String]) -> Result<String, String> {
|
||||
match mode {
|
||||
"light" => return light::cli(args),
|
||||
"stage" => return stage::cli(args),
|
||||
"lod" => return lod::cli(args),
|
||||
"faults" => return faults::cli(args),
|
||||
"lint" | "explain" => {}
|
||||
_ => return Err(usage.into()),
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
//! `raea scene lod EDIT.tsx [--composition ID] [--from N] [--to N] [--json]` (docs/goal.feature MK23): every part's
|
||||
//! planned detail beside how large the frames show it. A part's plan is its own `lod` (0 the hero to 4 far), else its
|
||||
//! name's on the job's plan (`lod` on brief.ts's make objects); what a frame shows is how much of it the part's box
|
||||
//! spans (raea-runtime-lod-plan). The table lists the planned parts first, the ones seen closer than planned on top,
|
||||
//! then the parts nobody planned by how large they get, so a part forgotten since the plan was written is found by
|
||||
//! reading down it. A part seen two or more levels finer than planned fails it, as it fails a render.
|
||||
|
||||
use raea_core_facts::{Finding, Level, finding};
|
||||
use raea_runtime_lod_plan::{ordered, table};
|
||||
use serde_json::json;
|
||||
|
||||
pub(crate) fn cli(args: &[String]) -> Result<String, String> {
|
||||
let crate::stage::Stepped { items, nums, size: (w, h, fps), dir } = crate::stage::stepped(args, "raea scene lod EDIT.tsx [--composition ID] [--from N] [--to N] [--json]")?;
|
||||
let (first, last) = (nums[0], nums[nums.len() - 1]);
|
||||
let plan = raea_runtime_lod_plan::plan::lods(&dir);
|
||||
let mut unseen: Vec<String> = plan.keys().cloned().collect();
|
||||
let (seen, fs) = raea_runtime_lod_plan::lods(&items, &nums, w, h, fps, "raea scene lod", plan);
|
||||
let seen = ordered(seen);
|
||||
// a level the plan gives a name no part in these frames goes by holds nothing: said, so the part gets its name
|
||||
unseen.retain(|n| !seen.iter().any(|s| s.planned.is_some() && (s.name == *n || s.name.starts_with(&format!("{n} (lod ")))));
|
||||
unseen.sort();
|
||||
let text = if args.iter().any(|a| a == "--json") {
|
||||
let parts: Vec<_> = seen.iter().map(|s| json!({"part": s.name, "planned": s.planned, "seen": s.level(), "largest": s.finest.map(|f| f.1), "at": s.finest.map(|f| f.0), "frames": s.frames, "closer": s.closer})).collect();
|
||||
serde_json::to_string_pretty(&json!({"frames": [first, last], "parts": parts, "unseen": unseen, "findings": fs})).unwrap_or_default()
|
||||
} else {
|
||||
let levels = "levels, by how much of the frame a part spans: 0 hero 50%+, 1 featured 20%+, 2 dressing 8%+, 3 background 2%+, 4 far";
|
||||
let none = seen.iter().filter(|s| s.planned.is_none()).count();
|
||||
let missing = (!unseen.is_empty()).then(|| format!("planned in brief.ts, but no part of that name is in these frames (name the part as its object's id, or its plan holds nothing): {}", unseen.join(", ")));
|
||||
let sum = format!("frames {first} to {last}: {} parts, {none} with no plan; {}", seen.len(), finding::count(&fs));
|
||||
table(&seen).into_iter().chain(fs.iter().map(Finding::line)).chain(missing).chain([levels.to_string(), sum]).collect::<Vec<_>>().join("\n")
|
||||
};
|
||||
if fs.iter().any(|f| f.level == Level::Error) {
|
||||
println!("{text}");
|
||||
std::process::exit(1);
|
||||
}
|
||||
Ok(text)
|
||||
}
|
||||
@@ -0,0 +1,245 @@
|
||||
//! `raea scene faults --clip CLIP.json|FOLDER [--clip ...]`: a character's motion held to what a body does, frame by frame
|
||||
//! (raea-sys-motionfaults): knees that buckle while the foot stands, feet that skate, joints past their range, fingers
|
||||
//! twisted or bent back, jolts, and fingers through what the hand holds. A clip is the skeleton's `joints` (and its
|
||||
//! `surface`, for the palm), `fps`, and `frames` of `{ root, turns }` (with `thing` for what the hand holds).
|
||||
//!
|
||||
//! It learns: `--fine KEY` and `--real KEY` on a clip's finding (each line ends with its key: check and joint role)
|
||||
//! move that key's line for every run after (raea-sys-motionfaults' verdicts, kept beside the scene judge's model).
|
||||
|
||||
use raea_sys_motionfaults::critic;
|
||||
use serde_json::{Value, json};
|
||||
|
||||
pub fn cli(args: &[String]) -> Result<String, String> {
|
||||
// each --clip a clip's JSON, or a folder of them
|
||||
let mut files: Vec<String> = Vec::new();
|
||||
for given in args.windows(2).filter(|w| w[0] == "--clip").map(|w| &w[1]) {
|
||||
match std::fs::read_dir(given) {
|
||||
Ok(dir) => {
|
||||
let mut v: Vec<String> = dir.flatten().map(|e| e.path()).filter(|p| p.extension().is_some_and(|x| x == "json")).map(|p| p.to_string_lossy().into()).collect();
|
||||
v.sort();
|
||||
files.extend(v);
|
||||
}
|
||||
Err(_) => files.push(given.clone()),
|
||||
}
|
||||
}
|
||||
if let Some(n) = args.windows(2).find(|w| w[0] == "--seed").map(|w| &w[1]) {
|
||||
let n = n.parse::<usize>().map_err(|_| "--seed takes how many faults of each kind to plant in each clip")?;
|
||||
return seed(&files, n);
|
||||
}
|
||||
let as_json = args.iter().any(|a| a == "--json");
|
||||
let (mut text, mut out, mut faults) = (String::new(), Vec::new(), 0);
|
||||
let store = verdicts_path();
|
||||
let mut verdicts = raea_sys_motionfaults::verdicts::Verdicts::load(&store);
|
||||
let (cpath, epath) = critic::paths(&store);
|
||||
let judge = critic::Critic::load(&cpath);
|
||||
let mut examples = Vec::new();
|
||||
let (mut given, mut held) = (0usize, 0usize);
|
||||
for file in &files {
|
||||
let v: Value = serde_json::from_str(&std::fs::read_to_string(file).map_err(|e| format!("{file}: {e}"))?).map_err(|e| format!("{file}: {e}"))?;
|
||||
let clip = raea_sys_motionfaults::clip_of(&v).map_err(|e| format!("{file}: {e}"))?;
|
||||
let mut found = raea_sys_motionfaults::check(&clip);
|
||||
// verdicts given now, on this clip's findings by key, then every verdict's lines applied
|
||||
for (flag, real) in [("--real", true), ("--fine", false)] {
|
||||
for k in args.windows(2).filter(|w| w[0] == flag).map(|w| &w[1]) {
|
||||
let hit: Vec<_> = found.iter().filter(|f| raea_sys_motionfaults::verdicts::key(f) == *k).collect();
|
||||
if hit.is_empty() {
|
||||
return Err(format!("{file}: no finding has the key {k} (each line ends with its key)"));
|
||||
}
|
||||
let (from, upto) = sizes(args, real);
|
||||
for f in hit {
|
||||
if f.value < from || f.value > upto {
|
||||
continue;
|
||||
}
|
||||
verdicts.give(f, real);
|
||||
examples.push(critic::row(f, real, by(args)));
|
||||
given += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
let before = found.len();
|
||||
found.retain(|f| stands(f, &verdicts, &judge));
|
||||
held += before - found.len();
|
||||
faults += found.len();
|
||||
let name = std::path::Path::new(file).file_stem().map_or(file.to_string(), |s| s.to_string_lossy().into());
|
||||
text += &format!("{name}: {} frames, {} fault{}\n", clip.poses.len(), found.len(), if found.len() == 1 { "" } else { "s" });
|
||||
for f in &found {
|
||||
text += &format!(" {:<8} {} key: {}\n", f.check, f.says, raea_sys_motionfaults::verdicts::key(f));
|
||||
}
|
||||
out.push(json!({"clip": file, "frames": clip.poses.len(), "faults": found.iter().map(|f| f.to_json()).collect::<Vec<_>>()}));
|
||||
}
|
||||
if out.is_empty() {
|
||||
return Err("--clip takes a clip's JSON (joints, fps, frames of root and turns)".into());
|
||||
}
|
||||
if given > 0 {
|
||||
if let Some(dir) = store.parent() {
|
||||
std::fs::create_dir_all(dir).map_err(|e| format!("{}: {e}", dir.display()))?;
|
||||
}
|
||||
std::fs::write(&store, serde_json::to_string_pretty(&verdicts.to_json()).unwrap()).map_err(|e| format!("{}: {e}", store.display()))?;
|
||||
critic::append(&epath, &examples)?;
|
||||
text += &format!("{given} verdict{} kept in {}\n", if given == 1 { "" } else { "s" }, store.display());
|
||||
}
|
||||
if held > 0 {
|
||||
text += &format!("{held} finding{} held back by earlier verdicts (fine at that size)\n", if held == 1 { " is" } else { "s are" });
|
||||
}
|
||||
if as_json {
|
||||
return Ok(serde_json::to_string_pretty(&json!({"clips": out, "faults": faults, "held": held})).unwrap());
|
||||
}
|
||||
if faults > 0 {
|
||||
eprint!("{text}");
|
||||
return Err(format!("{faults} motion fault{} in {} clip{}", if faults == 1 { "" } else { "s" }, out.len(), if out.len() == 1 { "" } else { "s" }));
|
||||
}
|
||||
Ok(text)
|
||||
}
|
||||
|
||||
/// Faults of each kind planted in every clip (raea-sys-motionfaults' plant), and how many `check` finds: one that is
|
||||
/// new against the clip's own faults, of its kind, on its joint (any joint for a grip), over its frame.
|
||||
fn seed(files: &[String], n: usize) -> Result<String, String> {
|
||||
use raea_sys_motionfaults::plant::{KINDS, Rng, plant};
|
||||
use std::collections::BTreeMap;
|
||||
let mut tally: BTreeMap<&str, (usize, usize, Vec<f32>, Vec<f32>)> = BTreeMap::new();
|
||||
let mut text = String::new();
|
||||
for (k, file) in files.iter().enumerate() {
|
||||
let v: Value = serde_json::from_str(&std::fs::read_to_string(file).map_err(|e| format!("{file}: {e}"))?).map_err(|e| format!("{file}: {e}"))?;
|
||||
let clip = raea_sys_motionfaults::clip_of(&v).map_err(|e| format!("{file}: {e}"))?;
|
||||
let own = raea_sys_motionfaults::check(&clip);
|
||||
let mut rng = Rng(0x9e37_79b9_7f4a_7c15 ^ (k as u64 + 1) * 0x1000_0001);
|
||||
for kind in KINDS {
|
||||
for _ in 0..n {
|
||||
let Some((moved, p)) = plant(&clip, kind, &mut rng) else { continue };
|
||||
let near = |f: &raea_sys_motionfaults::Fault| f.check == p.check && (p.check == "through" || p.check == "skate" || f.joint == p.joint) && f.from <= p.frame + 2 && p.frame <= f.to + 2;
|
||||
let found = raea_sys_motionfaults::check(&moved);
|
||||
let caught = found.iter().any(|f| near(f) && !own.iter().any(|o| o.check == f.check && o.joint == f.joint && o.from <= f.to && f.from <= o.to));
|
||||
let t = tally.entry(p.check).or_default();
|
||||
t.0 += 1;
|
||||
if caught {
|
||||
t.1 += 1;
|
||||
t.2.push(p.size);
|
||||
} else {
|
||||
t.3.push(p.size);
|
||||
let name = std::path::Path::new(file).file_stem().map_or(String::new(), |s| s.to_string_lossy().into());
|
||||
text += &format!(" missed in {name}: {}\n", p.says);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut out = format!("planted in {} clips:\n", files.len());
|
||||
for (kind, (planted, caught, got, missed)) in &tally {
|
||||
out += &format!(" {kind:<8} {caught}/{planted} caught{}{}\n", if got.is_empty() { String::new() } else { format!(", smallest caught {:.3}", raea_sys_motionfaults::bounds(got).0) }, if missed.is_empty() { String::new() } else { format!(", smallest missed {:.3}", raea_sys_motionfaults::bounds(missed).0) });
|
||||
}
|
||||
Ok(out + text.as_str())
|
||||
}
|
||||
|
||||
/// Where the motion verdicts are kept: beside the scene judge's model (notice/motion.json), or RAEA_NOTICE_MOTION.
|
||||
/// `raea scene faults EDIT.tsx --composition ID --motion`: the composition's characters (chars.rs) held to the motion
|
||||
/// checks, verdicts given (`--real`/`--fine KEY`) and applied as `--clip`'s are. And what a change shows: each run's
|
||||
/// findings are kept (review/motion.last/<shot>.json), and one the last run reported that's gone now, the character
|
||||
/// and its frames the same, was fixed, so it's kept as a real verdict at its size (raea-sys-motionfaults `fixed`).
|
||||
pub fn composition(tsx: &std::path::Path, shot: &str, dir: &std::path::Path, frames: &[(i64, Vec<raea_core_scene::Item>)], fps: f32, args: &[String]) -> Result<(String, Value, usize), String> {
|
||||
use raea_sys_motionfaults::verdicts::{fixed, key, record};
|
||||
let (found, missing) = crate::chars::run(dir, frames, fps)?;
|
||||
let store = verdicts_path();
|
||||
let mut verdicts = raea_sys_motionfaults::verdicts::Verdicts::load(&store);
|
||||
let (cpath, epath) = critic::paths(&store);
|
||||
let judge = critic::Critic::load(&cpath);
|
||||
let mut examples = Vec::new();
|
||||
let lastp = raea_sys_notice::labels::project_of(tsx).join("review").join("motion.last").join(format!("{shot}.json"));
|
||||
let last: Value = std::fs::read_to_string(&lastp).ok().and_then(|t| serde_json::from_str(&t).ok()).unwrap_or(Value::Null);
|
||||
let (mut text, mut rows, mut total, mut given, mut fixes, mut held) = (missing.join("\n"), Vec::new(), 0, 0, 0, 0);
|
||||
let mut keep = serde_json::Map::new();
|
||||
for c in &found {
|
||||
for (flag, real) in [("--real", true), ("--fine", false)] {
|
||||
for k in args.windows(2).filter(|w| w[0] == flag).map(|w| &w[1]) {
|
||||
let (from, upto) = sizes(args, real);
|
||||
for f in c.faults.iter().filter(|f| key(f) == *k && f.value >= from && f.value <= upto) {
|
||||
verdicts.give(f, real);
|
||||
examples.push(critic::row(f, real, by(args)));
|
||||
given += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut lines = String::new();
|
||||
let was = &last["characters"][&c.who];
|
||||
if was["frames"].as_u64() == Some(c.frames as u64) && last["checks"] == raea_sys_motionfaults::CHECKS {
|
||||
for (k, v, n) in fixed(was["faults"].as_array().map(Vec::as_slice).unwrap_or(&[]), &c.faults) {
|
||||
verdicts.give_at(&k, v, true);
|
||||
let (check, joint) = k.split_once(':').unwrap_or((&k, ""));
|
||||
examples.push(critic::row_of(check, joint, v, n, true, "fixed"));
|
||||
fixes += 1;
|
||||
lines += &format!(" fixed {k} at {v:.3}: gone since the last run, kept as real\n");
|
||||
}
|
||||
}
|
||||
keep.insert(c.who.clone(), json!({"frames": c.frames, "faults": c.faults.iter().map(record).collect::<Vec<_>>()}));
|
||||
let mut stand: Vec<&raea_sys_motionfaults::Fault> = Vec::new();
|
||||
for f in &c.faults {
|
||||
if stands(f, &verdicts, &judge) {
|
||||
stand.push(f);
|
||||
}
|
||||
}
|
||||
held += c.faults.len() - stand.len();
|
||||
total += stand.len();
|
||||
for f in &stand {
|
||||
lines += &format!(" {:<8} {} key: {}\n", f.check, f.says, key(f));
|
||||
}
|
||||
text += &format!("{} ({}): {} frames, {} fault{}\n{lines}", c.who, c.skeleton.display(), c.frames, stand.len(), if stand.len() == 1 { "" } else { "s" });
|
||||
rows.push(json!({"character": c.who, "skeleton": c.skeleton, "frames": c.frames, "faults": stand.iter().map(|f| f.to_json()).collect::<Vec<_>>()}));
|
||||
}
|
||||
if given + fixes > 0 {
|
||||
std::fs::create_dir_all(store.parent().unwrap_or(std::path::Path::new("."))).map_err(|e| e.to_string())?;
|
||||
std::fs::write(&store, serde_json::to_string_pretty(&verdicts.to_json()).unwrap_or_default()).map_err(|e| format!("{}: {e}", store.display()))?;
|
||||
}
|
||||
critic::append(&epath, &examples)?;
|
||||
if let Some(dir) = lastp.parent() {
|
||||
std::fs::create_dir_all(dir).map_err(|e| e.to_string())?;
|
||||
}
|
||||
std::fs::write(&lastp, serde_json::to_string_pretty(&json!({"checks": raea_sys_motionfaults::CHECKS, "characters": keep})).unwrap_or_default()).map_err(|e| format!("{}: {e}", lastp.display()))?;
|
||||
text += &format!("{held} held back by verdicts and the critic ({} labels), {given} verdicts given, {fixes} fixed since the last run (kept as real) in {}", judge.labels, store.display());
|
||||
Ok((text, json!({"characters": rows, "faults": total, "held": held, "fixed": fixes}), total))
|
||||
}
|
||||
|
||||
/// `--fine-upto N` / `--fine-from N` (`--real-upto`, `--real-from`): that call's verdicts only on findings of the key
|
||||
/// within those sizes, in the finding's own units (degrees past the range for a finger or a limit): a pinky's small
|
||||
/// bends fine, its big one real.
|
||||
/// A fault that stands: marked real, or not marked fine and scored a fault by the judge.
|
||||
fn stands(f: &raea_sys_motionfaults::Fault, verdicts: &raea_sys_motionfaults::verdicts::Verdicts, judge: &critic::Critic) -> bool {
|
||||
verdicts.real_at(f) || (verdicts.stands(f) && judge.score(f) >= critic::SAY)
|
||||
}
|
||||
|
||||
fn sizes(args: &[String], real: bool) -> (f32, f32) {
|
||||
let (a, b) = if real { ("--real-from", "--real-upto") } else { ("--fine-from", "--fine-upto") };
|
||||
let get = |flag: &str, or: f32| args.windows(2).find(|w| w[0] == flag).and_then(|w| w[1].parse().ok()).unwrap_or(or);
|
||||
(get(a, f32::NEG_INFINITY), get(b, f32::INFINITY))
|
||||
}
|
||||
|
||||
/// Who a verdict is by: `--by NAME` (an agent that looked: claude), else a person (marked).
|
||||
fn by(args: &[String]) -> &str {
|
||||
args.windows(2).find(|w| w[0] == "--by").map_or("marked", |w| w[1].as_str())
|
||||
}
|
||||
|
||||
/// The motion critic fitted to every example kept, held out by key, written beside the verdicts.
|
||||
pub fn train() -> Result<String, String> {
|
||||
let (cpath, epath) = critic::paths(&verdicts_path());
|
||||
let ex = critic::examples(&std::fs::read_to_string(&epath).unwrap_or_default());
|
||||
if ex.is_empty() {
|
||||
return Ok(format!("motion critic: no examples yet ({})", epath.display()));
|
||||
}
|
||||
let c = critic::Critic::fit(&ex);
|
||||
let right = ex.iter().filter(|e| (c.score_x(&e.0, &e.1) >= critic::SAY) == (e.2 >= 0.5)).count();
|
||||
let prior = ex.iter().filter(|e| (critic::Critic::prior().score_x(&e.0, &e.1) >= critic::SAY) == (e.2 >= 0.5)).count();
|
||||
let mut keys: Vec<&String> = ex.iter().map(|e| &e.1[2]).collect();
|
||||
keys.sort();
|
||||
keys.dedup();
|
||||
let held = keys.iter().map(|k| {
|
||||
let m = critic::Critic::fit(&ex.iter().filter(|e| &e.1[2] != *k).cloned().collect::<Vec<_>>());
|
||||
ex.iter().filter(|e| &e.1[2] == *k && (m.score_x(&e.0, &e.1) >= critic::SAY) == (e.2 >= 0.5)).count()
|
||||
}).sum::<usize>();
|
||||
std::fs::write(&cpath, serde_json::to_string_pretty(&c.to_json()).unwrap_or_default()).map_err(|e| format!("{}: {e}", cpath.display()))?;
|
||||
let real = ex.iter().filter(|e| e.2 >= 0.5).count();
|
||||
Ok(format!("motion critic: {} examples on {} keys ({real} real, {} fine): the prior agreed with {prior}, the fitted critic with {right}, and with {held} each fitted without its own key (held out); kept in {}", ex.len(), keys.len(), ex.len() - real, cpath.display()))
|
||||
}
|
||||
|
||||
fn verdicts_path() -> std::path::PathBuf {
|
||||
match std::env::var_os("RAEA_NOTICE_MOTION").filter(|v| !v.is_empty()) {
|
||||
Some(p) => p.into(),
|
||||
None => raea_sys_notice::model::path().with_file_name("motion.json"),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
//! `raea scene faults EDIT.tsx --seed N`: the judge measured on faults of known size. N props that rest as they should
|
||||
//! are each moved once (sunk into what they stand on, lifted a few millimetres off it, or lifted into the air), the
|
||||
//! lint run again, and the planted fault's finding judged. What it says: how many the lint found, and of those a camera
|
||||
//! sees at two pixels or more, how many the judge calls faults; of those no camera sees, how many it still calls one.
|
||||
//! Nothing is written: a planted fault's truth is its size, which the judge's own features already carry, so it
|
||||
//! measures the judge rather than teaching it.
|
||||
|
||||
use bevy::math::{Mat4, Vec3};
|
||||
use serde_json::Value;
|
||||
|
||||
use raea_core_scene::{Item, label};
|
||||
use raea_sys_motionfaults::plant::Rng;
|
||||
use raea_sys_notice::{Cam, FAULT, Model, Scene, camera};
|
||||
|
||||
/// Props this big across or smaller are moved.
|
||||
const PROP: f32 = 1.2;
|
||||
/// Pixels a planted fault covers at the least to count as plain to see.
|
||||
const PLAIN: f32 = 2.0;
|
||||
|
||||
|
||||
fn moved(its: &[Item], name: &str, by: Vec3) -> Vec<Item> {
|
||||
its.iter().cloned().map(|mut it| {
|
||||
if (it.kind == "mesh" || it.kind == "model") && label(&it, "") == name {
|
||||
it.world = Mat4::from_translation(by) * it.world;
|
||||
}
|
||||
it
|
||||
}).collect()
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn run(now: &[Item], next: &[Item], views: &[Vec<Item>], found: &[Value], w: u32, h: u32, model: &Model, n: usize) -> String {
|
||||
let count = |name: &str| now.iter().filter(|it| (it.kind == "mesh" || it.kind == "model") && label(it, "") == name).count();
|
||||
let props: Vec<&str> = found
|
||||
.iter()
|
||||
.filter(|v| v["check"] == "rests")
|
||||
.filter(|v| {
|
||||
let (lo, hi) = (&v["box"]["min"], &v["box"]["max"]);
|
||||
(0..3).all(|k| hi[k].as_f64().unwrap_or(9.0) - lo[k].as_f64().unwrap_or(0.0) <= PROP as f64)
|
||||
})
|
||||
.filter_map(|v| v["part"].as_str())
|
||||
.filter(|p| count(p) == 1)
|
||||
.collect();
|
||||
let cams: Vec<Cam> = views.iter().filter_map(|f| camera(f)).collect();
|
||||
// only props some camera of the shot sees (the middle of the box's top): a fault planted out of view tells
|
||||
// nothing of how the judge weighs one in it
|
||||
let scene = Scene::of(now);
|
||||
let in_view = |p: &str| {
|
||||
let Some(v) = found.iter().find(|v| v["part"] == p) else { return false };
|
||||
let at = |k: usize, e: &str| v["box"][e][k].as_f64().unwrap_or(0.0) as f32;
|
||||
let top = Vec3::new((at(0, "min") + at(0, "max")) / 2.0, at(1, "max") + 0.01, (at(2, "min") + at(2, "max")) / 2.0);
|
||||
raea_sys_notice::seen(&[raea_sys_notice::sight::Spot { at: top, facing: None, size: 0.0 }], false, &cams, &scene, w as f32, h as f32).shown > 0
|
||||
};
|
||||
let props: Vec<&str> = props.into_iter().filter(|p| in_view(p)).collect();
|
||||
if props.is_empty() {
|
||||
return "no prop the shot sees rests on anything to plant a fault in".into();
|
||||
}
|
||||
let mut rng = Rng(0x9e37_79b9_7f4a_7c15);
|
||||
let (mut lines, mut lint_found, mut plain, mut plain_flagged, mut hidden, mut hidden_flagged, mut small, mut small_flagged) = (Vec::new(), 0, 0, 0, 0, 0, 0, 0);
|
||||
for i in 0..n {
|
||||
let part = props[(rng.next() * props.len() as f32) as usize % props.len()];
|
||||
let r = rng.next();
|
||||
let (kind, d) = if r < 0.4 { ("floats", 0.002 + rng.next() * 0.028) } else if r < 0.8 { ("sunk", 0.005 + rng.next() * 0.035) } else { ("air", 0.08 + rng.next() * 0.22) };
|
||||
let by = Vec3::new(0.0, if kind == "sunk" { -d } else { d }, 0.0);
|
||||
let (a, b) = (moved(now, part, by), moved(next, part, by));
|
||||
let (again, _) = raea_sys_contact::lint(&a, &b);
|
||||
let want = |c: &str| c == kind || (kind == "sunk" && c == "seated") || (kind == "air" && c == "floats") || (kind != "sunk" && c == "mounted");
|
||||
let Some(f) = again.iter().find(|v| v["part"] == part && v["check"].as_str().is_some_and(want)) else {
|
||||
// what it said of the part instead (a prop lifted against a wall reads as mounted on it)
|
||||
let said: Vec<&str> = again.iter().filter(|v| v["part"] == part).filter_map(|v| v["check"].as_str()).collect();
|
||||
lines.push(format!("{i:>3} {kind:<6} {:>6.1} mm {part}: not found as {kind} (the lint said {})", d * 1000.0, said.join(", ")));
|
||||
eprintln!("{}", lines.last().unwrap());
|
||||
continue;
|
||||
};
|
||||
lint_found += 1;
|
||||
let scene = Scene::of(&a);
|
||||
let j = raea_sys_notice::judge_in(std::slice::from_ref(f), &scene, &cams, w, h, model);
|
||||
let Some(j) = j.first() else { continue };
|
||||
let flagged = j.p >= FAULT;
|
||||
if j.seen.shown == 0 {
|
||||
hidden += 1;
|
||||
hidden_flagged += flagged as usize;
|
||||
} else if j.seen.px >= PLAIN {
|
||||
plain += 1;
|
||||
plain_flagged += flagged as usize;
|
||||
} else {
|
||||
small += 1;
|
||||
small_flagged += flagged as usize;
|
||||
}
|
||||
lines.push(format!("{i:>3} {kind:<6} {:>6.1} mm {part}: seen {}/{} frames, {:.1} px -> {:.2}{}", d * 1000.0, j.seen.shown, j.seen.frames, j.seen.px, j.p, if flagged { " FAULT" } else { "" }));
|
||||
// each trial lints the scene again (half a minute on a furnished room): said as it goes
|
||||
eprintln!("{}", lines.last().unwrap());
|
||||
}
|
||||
lines.push(format!(
|
||||
"planted {n} in {} props: the lint found {lint_found}; plain to see (>= {PLAIN} px) {plain}, judged faults {plain_flagged}; seen under {PLAIN} px {small}, judged faults {small_flagged}; no camera sees {hidden}, judged faults {hidden_flagged}",
|
||||
props.len()
|
||||
));
|
||||
lines.join("\n")
|
||||
}
|
||||
+23
-6
@@ -1,7 +1,7 @@
|
||||
//! `raea scene stage EDIT.tsx [--composition ID] [--from N] [--to N] [--json]`: every frame's scene stepped without
|
||||
//! drawing and held to the stage checks a render runs at its end (raea-sys-stage, docs/stage-guards.feature SG10-SG14):
|
||||
//! 3D type that can't be read, parts that snap, a camera that lurches or reverses, frames with nothing composed in
|
||||
//! them. Errors fail it, as they fail a render, so it's the cheap look before one. It lays out no page, so what the
|
||||
//! them, a part shown closer than its planned detail (MK21). Errors fail it, as they fail a render, so it's the cheap look before one. It lays out no page, so what the
|
||||
//! page holds waits for a render: its words over the parts (type-over-part), a Label's part as the shot's subject, and
|
||||
//! a frame its words or pictures fill, which reads empty here and is said as a warning, not failed (SG11).
|
||||
//! `--clearance M` holds the camera M metres off every solid part on every frame (0.45 for a carried camera, MK16).
|
||||
@@ -12,8 +12,16 @@ use raea_core_facts::{Level, finding};
|
||||
use raea_runtime_bundle::{bundle_composition, comp_opts, flag};
|
||||
use raea_runtime_export::{all_items, scene_frames_to};
|
||||
|
||||
pub(crate) fn cli(args: &[String]) -> Result<String, String> {
|
||||
let usage = "raea scene stage EDIT.tsx [--composition ID] [--from N] [--to N] [--clearance M] [--json]";
|
||||
/// A composition's frames stepped without drawing, for `stage` and `lod`: each frame's parts from --from to --to (every
|
||||
/// frame before is still stepped), their numbers, the frame's size and rate, and the composition's folder.
|
||||
pub(crate) struct Stepped {
|
||||
pub items: Vec<Vec<raea_core_scene::Item>>,
|
||||
pub nums: Vec<i64>,
|
||||
pub size: (u32, u32, f64),
|
||||
pub dir: std::path::PathBuf,
|
||||
}
|
||||
|
||||
pub(crate) fn stepped(args: &[String], usage: &str) -> Result<Stepped, String> {
|
||||
let Some(edit) = args.get(2) else { return Err(usage.into()) };
|
||||
let tsx = dunce::canonicalize(&std::path::PathBuf::from(edit)).map_err(|e| format!("{edit}: {e}"))?;
|
||||
let dir = tsx.parent().unwrap().to_path_buf();
|
||||
@@ -25,10 +33,19 @@ pub(crate) fn cli(args: &[String]) -> Result<String, String> {
|
||||
let _ = std::fs::remove_file(&js);
|
||||
let (frames, w, h, fps) = got?.ok_or("the composition has no 3D")?;
|
||||
let frames: Vec<_> = frames.into_iter().filter(|(f, _)| *f >= from && to.is_none_or(|t| *f <= t)).collect();
|
||||
let (Some(first), Some(last)) = (frames.first().map(|f| f.0), frames.last().map(|f| f.0)) else { return Err(format!("no frames from {from}")) };
|
||||
let nums: Vec<i64> = frames.iter().map(|(f, _)| *f).collect();
|
||||
let items = all_items(&frames);
|
||||
if frames.is_empty() {
|
||||
return Err(format!("no frames from {from}"));
|
||||
}
|
||||
Ok(Stepped { nums: frames.iter().map(|(f, _)| *f).collect(), items: all_items(&frames), size: (w, h, fps), dir })
|
||||
}
|
||||
|
||||
pub(crate) fn cli(args: &[String]) -> Result<String, String> {
|
||||
let Stepped { items, nums, size: (w, h, fps), dir } = stepped(args, "raea scene stage EDIT.tsx [--composition ID] [--from N] [--to N] [--clearance M] [--json]")?;
|
||||
let (first, last) = (nums[0], nums[nums.len() - 1]);
|
||||
let mut fs = raea_sys_stage::check(&items, &nums, w, h, fps, "raea scene stage");
|
||||
// and each part held to its planned detail (its own `lod`, or its name's on the plan above it: MK21), as a render does
|
||||
fs.extend(raea_runtime_lod_plan::lods(&items, &nums, w, h, fps, "raea scene stage", raea_runtime_lod_plan::plan::lods(&dir)).1.into_iter().filter(|f| f.check == "lod-closer"));
|
||||
fs = raea_core_facts::finding::ranked(fs);
|
||||
// the camera held off every solid part, when asked: the number after the flag, else a carried camera's 0.45 m
|
||||
if let Some(v) = flag(args, "--clearance") {
|
||||
let min = v.parse::<f32>().ok().filter(|m| *m >= 0.0).ok_or_else(|| format!("--clearance takes metres (0.45 for a carried camera), got {v:?}"))?;
|
||||
|
||||
@@ -4,7 +4,7 @@ version = "0.1.0"
|
||||
edition = "2024"
|
||||
license = "FSL-1.1-ALv2"
|
||||
publish = false
|
||||
description = "raea solid info and raea solid view: a solid file run, its parts measured (raea-core-solidinfo), and its review sheets in colour and clay"
|
||||
description = "raea make solid info and raea make solid view: a solid file run, its parts measured (raea-core-solidinfo), and its review sheets in colour and clay"
|
||||
|
||||
[dependencies]
|
||||
dunce = "1"
|
||||
@@ -14,11 +14,11 @@ raea-core-facts = { path = "../../core/facts" }
|
||||
serde_json = "1"
|
||||
# --set's and the CLI's flags, read as the bundler reads them
|
||||
raea-runtime-bundle = { path = "../../runtime/bundle" }
|
||||
# `raea judge`, dispatched with `raea solid` (verb())
|
||||
# `raea judge`, dispatched with `raea make solid` (verb())
|
||||
raea-app-judge = { path = "../judge" }
|
||||
raea-app-ask = { path = "../ask" }
|
||||
# a scene, kit or shot held to its plan (docs/make.feature)
|
||||
# a scene, kit or shot held to its plan (docs/goal.feature)
|
||||
raea-app-make = { path = "../make" }
|
||||
# `raea solid export`: the solid built, written as .glb and read back (core/shape), named and coloured (core/meshcheck)
|
||||
# `raea make solid export`: the solid built, written as .glb and read back (core/shape), named and coloured (core/meshcheck)
|
||||
raea-core-shape = { path = "../../core/shape" }
|
||||
raea-core-meshcheck = { path = "../../core/meshcheck" }
|
||||
@@ -1,4 +1,4 @@
|
||||
//! `raea solid export FILE.ts -o OUT.glb [--set k=v,...] [--part NAME] [--colour #RRGGBB]` (docs/blender.feature BL1):
|
||||
//! `raea make solid export FILE.ts -o OUT.glb [--set k=v,...] [--part NAME] [--colour #RRGGBB]` (docs/blender.feature BL1):
|
||||
//! a solid written as one .glb, metres, y up, so a Blender step can take it (bake.py for real UVs and baked maps, a
|
||||
//! cloth to fall on). The solid stays the source: the .glb is made again from it whenever it changes. An empty solid,
|
||||
//! or one solid info finds an error in, is refused with the findings. The file is read back and measured against the
|
||||
@@ -52,7 +52,7 @@ fn said(info: &Value, level: &str, part: Option<&str>) -> Vec<String> {
|
||||
}
|
||||
|
||||
pub fn export(file: &Path, parts: &[(String, String)], info: &Value, args: &[String]) -> Result<String, String> {
|
||||
let out = flag(args, "-o").filter(|o| o.ends_with(".glb")).ok_or("raea solid export FILE.ts -o OUT.glb: give the .glb to write")?;
|
||||
let out = flag(args, "-o").filter(|o| o.ends_with(".glb")).ok_or("raea make solid export FILE.ts -o OUT.glb: give the .glb to write")?;
|
||||
let part = flag(args, "--part");
|
||||
let chosen: Vec<&(String, String)> = parts.iter().filter(|(n, _)| part.as_deref().is_none_or(|p| p == n)).collect();
|
||||
if chosen.is_empty() {
|
||||
@@ -79,7 +79,7 @@ pub fn export(file: &Path, parts: &[(String, String)], info: &Value, args: &[Str
|
||||
let name = part.clone().unwrap_or_else(|| file.file_stem().and_then(|s| s.to_str()).unwrap_or("solid").to_string());
|
||||
j["nodes"][0]["name"] = json!(name);
|
||||
j["meshes"][0]["name"] = json!(name);
|
||||
j["asset"]["generator"] = json!("raea solid export");
|
||||
j["asset"]["generator"] = json!("raea make solid export");
|
||||
if let Some(c) = flag(args, "--colour") {
|
||||
j["materials"] = json!([{"name": name, "pbrMetallicRoughness": {"baseColorFactor": linear(&c)?, "metallicFactor": 0.0, "roughnessFactor": 0.8}}]);
|
||||
j["meshes"][0]["primitives"][0]["material"] = json!(0);
|
||||
@@ -92,7 +92,7 @@ pub fn export(file: &Path, parts: &[(String, String)], info: &Value, args: &[Str
|
||||
if !diff.is_empty() {
|
||||
return Err(format!("solid export: {out} doesn't read back as the solid: {}", diff.join("; ")));
|
||||
}
|
||||
let side = json!({"source": format!("raea solid export {}{}", file.display(), part.as_ref().map(|p| format!(" --part {p}")).unwrap_or_default()), "license": "built in code for this project", "credit": ""});
|
||||
let side = json!({"source": format!("raea make solid export {}{}", file.display(), part.as_ref().map(|p| format!(" --part {p}")).unwrap_or_default()), "license": "built in code for this project", "credit": ""});
|
||||
std::fs::write(format!("{out}.json"), serde_json::to_string_pretty(&side).unwrap_or_default()).map_err(|e| e.to_string())?;
|
||||
let r = |x: f64| (x * 1e5).round() / 1e5;
|
||||
let mut t = vec![format!(
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
//! `raea solid info FILE.ts [--json] [--set k=v,...] [--expect E.json] [--walk]`: the file's solid measured
|
||||
//! `raea make solid info FILE.ts [--json] [--set k=v,...] [--expect E.json] [--walk]`: the file's solid measured
|
||||
//! (raea-core-solidinfo). FILE.ts exports `default`: a Solid, an object of named Solids (the parts), or a function
|
||||
//! of the params returning either; and optionally `params`, each a number, a boolean, or `[low, high, default]`. The
|
||||
//! file is run by `raea run` (a wrapper that prints each part's shape expression), then measured natively. --set
|
||||
//! builds it at other params and says what moved from the defaults; --walk moves each ranged param alone to each end
|
||||
//! and says which break it (more pieces, empty) and which reach no geometry. FILE.expect.json beside it is read when
|
||||
//! --expect isn't given. Errors exit 1, as scene lint. A part's `role` comes from the file's `roles` export ({body:
|
||||
//! "contain"}), its `at` from the line that names it. `raea solid view` takes its pictures (view.rs); `raea solid export`
|
||||
//! "contain"}), its `at` from the line that names it. `raea make solid view` takes its pictures (view.rs); `raea make solid export`
|
||||
//! writes it as a .glb for a Blender step (export.rs). Its `needs` export ({textured: true}) asks for what solids can't
|
||||
//! give yet: real UVs and baked maps name bake.py (docs/blender.feature BL14).
|
||||
|
||||
@@ -18,7 +18,7 @@ use serde_json::{Map, Value, json};
|
||||
mod export;
|
||||
mod view;
|
||||
|
||||
pub const USAGE: &str = "raea solid info FILE.ts [--json] [--set k=v,...] [--expect E.json] [--walk] (volume, box, pieces, genus per part; joints; predictions and mutants)\n raea solid view FILE.ts -o DIR [--set k=v,...] [--json] (the solid's parts in colour and clay from fixed cameras)\n raea solid export FILE.ts -o OUT.glb [--set k=v,...] [--part NAME] [--colour #RRGGBB] (the solid as one .glb for a Blender step, read back and checked)";
|
||||
pub const USAGE: &str = "raea make solid info FILE.ts [--json] [--set k=v,...] [--expect E.json] [--walk] (volume, box, pieces, genus per part; joints; predictions and mutants)\n raea make solid view FILE.ts -o DIR [--set k=v,...] [--json] (the solid's parts in colour and clay from fixed cameras)\n raea make solid export FILE.ts -o OUT.glb [--set k=v,...] [--part NAME] [--colour #RRGGBB] (the solid as one .glb for a Blender step, read back and checked)";
|
||||
|
||||
thread_local! {
|
||||
/// the last run file's `roles` and `needs` exports
|
||||
@@ -68,7 +68,7 @@ print("RAEA_SOLID_INFO " + JSON.stringify({{ params: p, spec, parts: exprs, role
|
||||
fn textured(out: &mut Value, file: &Path) {
|
||||
let stem = file.file_stem().and_then(|s| s.to_str()).unwrap_or("solid");
|
||||
let f = raea_core_meshcheck::blender::fix("bake.py", &format!("media/{stem}.glb media/{stem}-baked.glb --into-colour"));
|
||||
let run = format!("raea solid export {} -o media/{stem}.glb --colour #RRGGBB && {}", file.display(), f["run"].as_str().unwrap_or(""));
|
||||
let run = format!("raea make solid export {} -o media/{stem}.glb --colour #RRGGBB && {}", file.display(), f["run"].as_str().unwrap_or(""));
|
||||
let says = format!("its file asks for textures (needs.textured), and a solid's UVs are box projections: export it and bake real UVs and maps; fix: {run}");
|
||||
if let Some(a) = out["found"].as_array_mut() {
|
||||
a.push(json!({"check": "textures", "level": "warning", "says": says, "fix": {"blender": "bake.py", "run": run}}));
|
||||
@@ -91,7 +91,7 @@ fn parse_set(s: &str) -> Result<Map<String, Value>, String> {
|
||||
Ok(m)
|
||||
}
|
||||
|
||||
/// `raea solid ...`, `raea judge ...`, `raea make ...` (docs/make.feature) and `raea ask ...` (docs/ask.feature AK3, which prints as it goes and exits with
|
||||
/// `raea make solid ...`, `raea judge ...`, `raea make ...` (docs/goal.feature) and `raea ask ...` (docs/ask.feature AK3, which prints as it goes and exits with
|
||||
/// its own code), the verbs that build and judge a piece (engine/cli hands them over), or None for another verb.
|
||||
pub fn verb(args: &[String]) -> Option<Result<String, String>> {
|
||||
match args.first().map(String::as_str) {
|
||||
@@ -134,7 +134,7 @@ pub fn cli(args: &[String]) -> Result<String, String> {
|
||||
return export::export(&file, &parts, &out, args);
|
||||
}
|
||||
if verb == "view" {
|
||||
let dir = crate::view::out_dir(args).ok_or("raea solid view FILE.ts -o DIR: give the folder for the sheets")?;
|
||||
let dir = crate::view::out_dir(args).ok_or("raea make solid view FILE.ts -o DIR: give the folder for the sheets")?;
|
||||
return crate::view::view(&file, &set, &out, &dir, json_out);
|
||||
}
|
||||
out["params"] = params;
|
||||
@@ -179,7 +179,7 @@ pub fn cli(args: &[String]) -> Result<String, String> {
|
||||
}
|
||||
// what it found as raea's one Finding (docs/direction.feature DR3), about the part, or the solid's file
|
||||
let name = file.file_name().map(|n| n.to_string_lossy().to_string()).unwrap_or_default();
|
||||
let found = finding::ranked(out["found"].as_array().into_iter().flatten().filter_map(|v| Finding::of_value(v, "raea solid info")).map(|f| if f.about.is_empty() { f.about(&name, None) } else { f }).collect());
|
||||
let found = finding::ranked(out["found"].as_array().into_iter().flatten().filter_map(|v| Finding::of_value(v, "raea make solid info")).map(|f| if f.about.is_empty() { f.about(&name, None) } else { f }).collect());
|
||||
let errors = found.iter().any(|f| f.level == Level::Error);
|
||||
if let Some(o) = out.as_object_mut() {
|
||||
for k in ["found", "errors", "warnings"] {
|
||||
@@ -200,7 +200,7 @@ pub fn cli(args: &[String]) -> Result<String, String> {
|
||||
t.push(format!("walk {} = {}: {}{}", w["param"].as_str().unwrap_or(""), w["value"], w["verdict"].as_str().unwrap_or(""), w["says"].as_str().map(|s| format!(" ({s})")).unwrap_or_default()));
|
||||
}
|
||||
t.push(format!("solid: {} m³, size {} m, {} pieces, genus {}, {} triangles", s["volume"], s["box"]["size"], s["pieces"], s["genus"], s["tris"]));
|
||||
t.push(format!("raea solid info: {}", finding::count(&found)));
|
||||
t.push(format!("raea make solid info: {}", finding::count(&found)));
|
||||
t.join("\n")
|
||||
};
|
||||
if errors {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! `raea solid view FILE.ts -o DIR [--set k=v,...]`: one solid's review sheets (research note agent-tool-surface.md's
|
||||
//! `raea make solid view FILE.ts -o DIR [--set k=v,...]`: one solid's review sheets (research note agent-tool-surface.md's
|
||||
//! `solid view`). The file's parts are put in a small scene, each on its own clay-friendly colour, on a slab under
|
||||
//! a key and fill light, with a hero camera from the front-right corner, and `raea render --review` takes the fixed
|
||||
//! views of it in colour and clay. It prints a sidecar: the sheets, the solid's box, whether it is in more than one
|
||||
|
||||
@@ -17,5 +17,5 @@ serde_json = "1"
|
||||
# the verbs' flags read as a render reads its own
|
||||
raea-runtime-bundle = { path = "../../runtime/bundle" }
|
||||
raea-runtime-export = { path = "../../runtime/export" }
|
||||
# `raea motion` and `raea setup motion` (apps/motion), still reached as tools::motion
|
||||
# `raea make motion` and `raea setup motion` (apps/motion), still reached as tools::motion
|
||||
raea-app-motion = { path = "../motion" }
|
||||
@@ -21,8 +21,10 @@ struct Hook {
|
||||
fn hooks(agent: &str) -> R<Vec<Hook>> {
|
||||
let h = |event, matcher, secs| Hook { event, matcher, secs };
|
||||
Ok(match agent {
|
||||
"claude" => vec![h("PreToolUse", "Bash", 30), h("PostToolUse", "*", 60), h("Stop", "", 30)],
|
||||
"codex" => vec![h("PreToolUse", "^(Bash|shell|shell_command|exec_command)$", 30), h("PostToolUse", "^(apply_patch|Edit|Write)$", 60)],
|
||||
// SessionStart and UserPromptSubmit: notes sent from raea while the session was closed or idle reach it when it
|
||||
// starts again or is next written to (Shane 11-28: "notes reach closed sessions")
|
||||
"claude" => vec![h("PreToolUse", "Bash", 30), h("PostToolUse", "*", 60), h("Stop", "", 30), h("SessionStart", "", 10), h("UserPromptSubmit", "", 10)],
|
||||
"codex" => vec![h("PreToolUse", "^(Bash|shell|shell_command|exec_command)$", 30), h("PostToolUse", "^(apply_patch|Edit|Write)$", 60), h("Stop", "", 30), h("SessionStart", "", 10), h("UserPromptSubmit", "", 10)],
|
||||
"gemini" => vec![h("BeforeTool", "run_shell_command", 30), h("AfterTool", "write_file|replace", 60)],
|
||||
"kimi" => vec![h("PreToolUse", "Bash|Shell", 30), h("PostToolUse", "Write|Edit|WriteFile|StrReplaceFile", 60)],
|
||||
a => return Err(format!("no agent {a:?}: claude, codex, kimi or gemini")),
|
||||
@@ -124,7 +126,8 @@ mod tests {
|
||||
let c = d.join("claude/settings.json");
|
||||
std::fs::create_dir_all(c.parent().unwrap()).unwrap();
|
||||
std::fs::write(&c, r#"{"model":"x","hooks":{"PostToolUse":[{"matcher":"Bash","hooks":[{"type":"command","command":"other"}]},{"matcher":"Write","hooks":[{"type":"command","command":"raea hook claude"}]}]}}"#).unwrap();
|
||||
let [pre, post, stop] = <[Hook; 3]>::try_from(hooks("claude").unwrap()).ok().unwrap();
|
||||
let [pre, post, stop, start, prompt] = <[Hook; 5]>::try_from(hooks("claude").unwrap()).ok().unwrap();
|
||||
assert!(add_json(&c, "claude", &start).unwrap() && add_json(&c, "claude", &prompt).unwrap() && !add_json(&c, "claude", &start).unwrap());
|
||||
assert!(add_json(&c, "claude", &pre).unwrap() && !add_json(&c, "claude", &pre).unwrap());
|
||||
assert!(add_json(&c, "claude", &post).unwrap() && !add_json(&c, "claude", &post).unwrap(), "an older raea's after-save hook is widened to every tool, once");
|
||||
assert!(add_json(&c, "claude", &stop).unwrap() && !add_json(&c, "claude", &stop).unwrap());
|
||||
@@ -133,6 +136,9 @@ mod tests {
|
||||
assert_eq!((v["hooks"]["PostToolUse"][0]["matcher"].as_str(), v["hooks"]["PostToolUse"][1]["matcher"].as_str()), (Some("Bash"), Some("*")));
|
||||
assert_eq!(v["hooks"]["PreToolUse"][0]["hooks"][0]["command"], "raea hook claude");
|
||||
assert_eq!(v["hooks"]["Stop"][0]["hooks"][0]["command"], "raea hook claude");
|
||||
assert_eq!(v["hooks"]["SessionStart"][0]["hooks"][0]["command"], "raea hook claude");
|
||||
assert_eq!(v["hooks"]["UserPromptSubmit"][0]["hooks"][0]["command"], "raea hook claude");
|
||||
assert_eq!(hooks("codex").unwrap().iter().map(|h| h.event).collect::<Vec<_>>(), ["PreToolUse", "PostToolUse", "Stop", "SessionStart", "UserPromptSubmit"]);
|
||||
let g = d.join("gemini/settings.json");
|
||||
let [before, _] = <[Hook; 2]>::try_from(hooks("gemini").unwrap()).ok().unwrap();
|
||||
assert!(add_json(&g, "gemini", &before).unwrap());
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
//! The verbs that run raea's local tools: sound (`raea sao`, `tokensynth`, `setup-audio`, `sounds`: foley and an
|
||||
//! instrument's notes made by local models, and the open sample libraries), `raea splat` (footage trained into a
|
||||
//! The verbs that run raea's local tools: sound (`raea make sao`, `tokensynth`, `setup-audio`, `sounds`: foley and an
|
||||
//! instrument's notes made by local models, and the open sample libraries), `raea make splat` (footage trained into a
|
||||
//! Gaussian splat), `raea song` (a song's energy map, apps/tools/src/song.rs) and `raea gen` (generation flows on
|
||||
//! made.app, fal, Replicate, OpenRouter, Modal and ComfyUI, with sao as the local model: apps/tools/src/generate.rs).
|
||||
|
||||
pub mod generate;
|
||||
/// `raea motion` and `raea setup motion`: body motion made by Kimodo, on MLX on a Mac, on PyTorch elsewhere (apps/motion)
|
||||
/// `raea make motion` and `raea setup motion`: body motion made by Kimodo, on MLX on a Mac, on PyTorch elsewhere (apps/motion)
|
||||
pub use raea_app_motion as motion;
|
||||
pub mod song;
|
||||
pub mod sound;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
//! raea's sound tools from the command line: the two local models (SAO for foley, TokenSynth for an instrument's notes)
|
||||
//! and the open sample libraries a Tone.js Sampler can play.
|
||||
//!
|
||||
//! raea sao "PROMPT" [--seconds 2] [--seed 1] [--dir EDIT_DIR] [-o OUT.wav]
|
||||
//! raea tokensynth "TIMBRE" [--notes C2,C3,C4] [--seconds 2] [--velocity 100] [--seed 1234] [--precision fp16]
|
||||
//! raea make sao "PROMPT" [--seconds 2] [--seed 1] [--dir EDIT_DIR] [-o OUT.wav]
|
||||
//! raea make tokensynth "TIMBRE" [--notes C2,C3,C4] [--seconds 2] [--velocity 100] [--seed 1234] [--precision fp16]
|
||||
//! [--dir EDIT_DIR] [-o OUT_DIR]
|
||||
//! raea setup-audio [--check] [sao|tokensynth]
|
||||
//! raea sounds [WORDS...]
|
||||
//! raea sounds get PACK/INSTRUMENT [--notes C2,C4 | --all] [--dir EDIT_DIR] [-o OUT_DIR]
|
||||
//! raea make sounds [WORDS...]
|
||||
//! raea make sounds get PACK/INSTRUMENT [--notes C2,C4 | --all] [--dir EDIT_DIR] [-o OUT_DIR]
|
||||
//!
|
||||
//! sao and tokensynth make through the same asset store a composition's render does (raea_io_assets::Store beside
|
||||
//! EDIT_DIR/edit.tsx, default the working folder), with the same parameters, so a sound made here is the one
|
||||
@@ -126,9 +126,9 @@ fn deliver(from: &Path, to: &Path) -> R<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub const SAO_USAGE: &str = "raea sao \"PROMPT\" [--seconds 2] [--seed 1] [--dir EDIT_DIR] [-o OUT.wav]";
|
||||
pub const SAO_USAGE: &str = "raea make sao \"PROMPT\" [--seconds 2] [--seed 1] [--dir EDIT_DIR] [-o OUT.wav]";
|
||||
|
||||
/// `raea sao "PROMPT" [--seconds 2] [--seed 1] [--dir D] [-o OUT.wav]`: one foley sound, made once.
|
||||
/// `raea make sao "PROMPT" [--seconds 2] [--seed 1] [--dir D] [-o OUT.wav]`: one foley sound, made once.
|
||||
pub fn sao(args: &[String]) -> R<String> {
|
||||
const USAGE: &str = SAO_USAGE;
|
||||
let prompt = positional(&args[1..], &["--seconds", "--seed", "--dir", "-o"]).join(" ");
|
||||
@@ -159,9 +159,9 @@ pub fn sao(args: &[String]) -> R<String> {
|
||||
Ok(format!("APPLIED sao {prompt:?}, {} s, seed {seed} -> {at} ({how}; asset {}){reuse}", js_num(seconds), &a.hash[..12]))
|
||||
}
|
||||
|
||||
pub const TOKENSYNTH_USAGE: &str = "raea tokensynth \"TIMBRE\" [--notes C2,C3,C4] [--seconds 2] [--velocity 100] [--seed 1234] [--precision fp16] [--dir EDIT_DIR] [-o OUT_DIR]";
|
||||
pub const TOKENSYNTH_USAGE: &str = "raea make tokensynth \"TIMBRE\" [--notes C2,C3,C4] [--seconds 2] [--velocity 100] [--seed 1234] [--precision fp16] [--dir EDIT_DIR] [-o OUT_DIR]";
|
||||
|
||||
/// `raea tokensynth "TIMBRE" [--notes C2,C3,C4] ... [-o OUT_DIR]`: an instrument's root notes, one WAV each.
|
||||
/// `raea make tokensynth "TIMBRE" [--notes C2,C3,C4] ... [-o OUT_DIR]`: an instrument's root notes, one WAV each.
|
||||
pub fn tokensynth(args: &[String]) -> R<String> {
|
||||
const USAGE: &str = TOKENSYNTH_USAGE;
|
||||
let timbre = positional(&args[1..], &["--notes", "--seconds", "--velocity", "--seed", "--precision", "--dir", "-o"]).join(" ");
|
||||
|
||||
@@ -24,7 +24,7 @@ pub(crate) fn synonyms(word: &str) -> Vec<&str> {
|
||||
}
|
||||
}
|
||||
|
||||
/// `raea sounds [WORDS...]`: the instruments whose names hold every word (all of them with no words, by pack).
|
||||
/// `raea make sounds [WORDS...]`: the instruments whose names hold every word (all of them with no words, by pack).
|
||||
pub fn sounds(args: &[String]) -> R<String> {
|
||||
if args.get(1).map(String::as_str) == Some("get") {
|
||||
return sounds_get(args);
|
||||
@@ -70,7 +70,7 @@ pub fn sounds(args: &[String]) -> R<String> {
|
||||
if out.is_empty() {
|
||||
return Ok(format!("no instrument in the sample libraries matches {:?}: try one word (piano, snare, strings, marimba)", words.join(" ")));
|
||||
}
|
||||
Ok(format!("{}\n\nraea sounds get PACK/INSTRUMENT [--notes C2,C4] copies one into media/sounds/ and prints the Sampler for it", out.join("\n\n")))
|
||||
Ok(format!("{}\n\nraea make sounds get PACK/INSTRUMENT [--notes C2,C4] copies one into media/sounds/ and prints the Sampler for it", out.join("\n\n")))
|
||||
}
|
||||
|
||||
/// Percent-encode a URL path (spaces, commas and `#` in VCSL's names), keeping its slashes.
|
||||
@@ -106,16 +106,16 @@ pub(crate) fn static_path(p: &Path) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
/// `raea sounds get PACK/INSTRUMENT [--notes ..|--all] [-o DIR]`: an instrument's samples into the edit's
|
||||
/// `raea make sounds get PACK/INSTRUMENT [--notes ..|--all] [-o DIR]`: an instrument's samples into the edit's
|
||||
/// media (default media/sounds/PACK-INSTRUMENT/), its licence beside them, and the TSX that plays them.
|
||||
pub(crate) fn sounds_get(args: &[String]) -> R<String> {
|
||||
const USAGE: &str = "raea sounds get PACK/INSTRUMENT [--notes C2,C4 | --all] [--dir EDIT_DIR] [-o OUT_DIR] (raea sounds WORDS finds one)";
|
||||
const USAGE: &str = "raea make sounds get PACK/INSTRUMENT [--notes C2,C4 | --all] [--dir EDIT_DIR] [-o OUT_DIR] (raea make sounds WORDS finds one)";
|
||||
let id = *positional(&args[2..], &["--notes", "--dir", "-o"]).first().ok_or(USAGE)?;
|
||||
let (pid, iid) = id.split_once('/').ok_or(USAGE)?;
|
||||
let c = catalog()?;
|
||||
let pack = c["packs"].as_array().into_iter().flatten().find(|p| p["id"] == pid).ok_or(format!("no sample library `{pid}`: raea sounds lists them"))?;
|
||||
let pack = c["packs"].as_array().into_iter().flatten().find(|p| p["id"] == pid).ok_or(format!("no sample library `{pid}`: raea make sounds lists them"))?;
|
||||
let inst = pack["instruments"].as_array().into_iter().flatten().find(|i| i["id"] == iid)
|
||||
.ok_or(format!("{pid} has no instrument `{iid}`: raea sounds {iid} searches for it"))?;
|
||||
.ok_or(format!("{pid} has no instrument `{iid}`: raea make sounds {iid} searches for it"))?;
|
||||
let files = files_of(pack, inst);
|
||||
let pitched_files: Vec<_> = files.iter().filter(|f| f.0.is_some()).cloned().collect();
|
||||
let pitched = pitched_files.iter().map(|f| f.0).collect::<std::collections::BTreeSet<_>>().len() >= 3;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
//! Splats from footage: a video (or a folder of pictures) of a real place or thing trained into a 3D Gaussian splat for
|
||||
//! `<Splat src>` (raea_io_assets::Store::splat; tools/splat: frames, COLMAP, Brush on Metal).
|
||||
//!
|
||||
//! raea splat train VIDEO|IMAGE_DIR -o OUT.ply [--frames N] [--steps N] [--max-res PX] [--from S]
|
||||
//! raea make splat train VIDEO|IMAGE_DIR -o OUT.ply [--frames N] [--steps N] [--max-res PX] [--from S]
|
||||
//! [--seconds N] [--max-splats N] [--matte black] [--match sequential|exhaustive]
|
||||
//! [--credit TEXT] [--license TEXT] [--dir EDIT_DIR]
|
||||
//! raea splat setup
|
||||
//! raea make splat setup
|
||||
//!
|
||||
//! Goes through the asset store beside EDIT_DIR/edit.tsx (default the working folder), so the same footage and params
|
||||
//! train once; OUT.ply is a copy of the store's `<hash>.ply` and OUT.ply.json of its sidecar (with --credit and
|
||||
@@ -17,7 +17,7 @@ use raea_runtime_bundle::flag;
|
||||
|
||||
type R<T> = Result<T, String>;
|
||||
|
||||
pub const USAGE: &str = "raea splat train VIDEO|IMAGE_DIR -o OUT.ply [--frames 150] [--steps 20000] [--max-res 1600] [--from S] [--seconds N] [--max-splats 2000000] [--matte none|black] [--match sequential|exhaustive] [--credit TEXT] [--license TEXT] [--dir EDIT_DIR]\n raea splat setup";
|
||||
pub const USAGE: &str = "raea make splat train VIDEO|IMAGE_DIR -o OUT.ply [--frames 150] [--steps 20000] [--max-res 1600] [--from S] [--seconds N] [--max-splats 2000000] [--matte none|black] [--match sequential|exhaustive] [--credit TEXT] [--license TEXT] [--dir EDIT_DIR]\n raea make splat setup";
|
||||
const WITH_VALUE: [&str; 13] = ["--frames", "--steps", "--max-res", "--from", "--seconds", "--max-splats", "--matte", "--match", "--credit", "--license", "--dir", "-o", "--o"];
|
||||
|
||||
/// The CLI's input and params (what Store::splat is asked), checked: (input, params JSON).
|
||||
@@ -57,7 +57,7 @@ pub fn parse(args: &[String]) -> R<(PathBuf, Value)> {
|
||||
Ok((input, raea_io_assets::splat_params(&Value::Object(p))?))
|
||||
}
|
||||
|
||||
/// `raea splat ...`
|
||||
/// `raea make splat ...`
|
||||
pub fn splat(args: &[String]) -> R<String> {
|
||||
match args.get(1).map(String::as_str) {
|
||||
Some("setup") => {
|
||||
|
||||
@@ -12,6 +12,7 @@ path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
# Pocket TTS and its word clock
|
||||
raea-io-trace = { path = "../../io/trace" }
|
||||
raea-sys-speech = { path = "../../systems/speech" }
|
||||
# ort sessions the way raea builds them, and the model cache
|
||||
raea-sys-ml = { path = "../../systems/ml" }
|
||||
|
||||
+2
-42
@@ -108,7 +108,7 @@ pub fn microphone(tx: Sender<Vec<f32>>) -> anyhow::Result<cpal::Stream> {
|
||||
rs.push(&mono, &mut out);
|
||||
let _ = tx.send(out);
|
||||
};
|
||||
let bad = said_once::<cpal::StreamError>("raea voice: the microphone");
|
||||
let bad = raea_io_trace::once::said_once::<cpal::StreamError>("raea voice: the microphone");
|
||||
let stream = match cfg.sample_format() {
|
||||
cpal::SampleFormat::F32 => {
|
||||
dev.build_input_stream(&cfg.config(), move |d: &[f32], _: &cpal::InputCallbackInfo| take(mono(d, ch)), bad, None)
|
||||
@@ -242,7 +242,7 @@ impl Speaker {
|
||||
f.fill(ready.pop_front().unwrap_or(0.0));
|
||||
}
|
||||
};
|
||||
let stream = dev.build_output_stream(&cfg.config(), play, said_once::<cpal::StreamError>("raea voice: the speakers"), None).map_err(|e| anyhow!("the speakers didn't open: {e}"))?;
|
||||
let stream = dev.build_output_stream(&cfg.config(), play, raea_io_trace::once::said_once::<cpal::StreamError>("raea voice: the speakers"), None).map_err(|e| anyhow!("the speakers didn't open: {e}"))?;
|
||||
stream.play().map_err(|e| anyhow!("the speakers didn't start: {e}"))?;
|
||||
Ok(Speaker { line, rate, to, _stream: Some(stream) })
|
||||
}
|
||||
@@ -286,43 +286,3 @@ mod tests {
|
||||
assert!(x.iter().zip(&y).all(|(a, b)| (a - b).abs() < 1e-3));
|
||||
}
|
||||
}
|
||||
|
||||
/// A device's error said once, then only how often it came back (at its 10th, 100th, ... time, and never more than once
|
||||
/// a second): a failing ALSA device calls a stream's error callback without pause, and every call printed a line: #239's
|
||||
/// app.log reached 40 GB of one line in two days.
|
||||
fn said_once<E: std::fmt::Display>(what: &'static str) -> impl FnMut(E) + Send + 'static {
|
||||
let mut seen = Repeats::default();
|
||||
move |e| {
|
||||
let m = e.to_string();
|
||||
match seen.hit(&m, std::time::Instant::now()) {
|
||||
Some(1) => eprintln!("{what}: {m}"),
|
||||
Some(n) => eprintln!("{what}: {m} ({n} times now)"),
|
||||
None => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Which of an error's repeats get said: `hit` answers with the count to print, or nothing.
|
||||
#[derive(Default)]
|
||||
struct Repeats {
|
||||
last: String,
|
||||
n: u64,
|
||||
next: u64,
|
||||
at: Option<std::time::Instant>,
|
||||
}
|
||||
|
||||
impl Repeats {
|
||||
fn hit(&mut self, m: &str, now: std::time::Instant) -> Option<u64> {
|
||||
if m != self.last || self.n == 0 {
|
||||
(self.last, self.n, self.next) = (m.to_string(), 0, 1);
|
||||
}
|
||||
self.n += 1;
|
||||
let soon = self.at.is_some_and(|t| now.duration_since(t).as_secs() < 1);
|
||||
if self.n < self.next || (soon && self.n > 1) {
|
||||
return None;
|
||||
}
|
||||
self.next = self.n.saturating_mul(10);
|
||||
self.at = Some(now);
|
||||
Some(self.n)
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ raea-io-assets = { path = "../../io/assets" }
|
||||
serde_json = "1"
|
||||
# a project's compositions and components read from their source (docs/projects.feature PJ8)
|
||||
raea-app-registry = { path = "registry" }
|
||||
# the project's record of what renders and checks found, which raea next reads (docs/direction.feature DR3)
|
||||
# the project's record of what renders and checks found, which raea goal next reads (docs/direction.feature DR3)
|
||||
raea-core-facts = { path = "../../core/facts" }
|
||||
# a command's words (its arguments that aren't flags or their values), read as raea check reads them
|
||||
raea-app-check = { path = "../check" }
|
||||
@@ -1,11 +1,11 @@
|
||||
//! A project's compositions and components, registered by reading its files (docs/projects.feature PJ8),
|
||||
//! so the raea app, `raea project scan`, `raea doctor` and `raea next` agree on what each file is:
|
||||
//! so the raea app, `raea project scan`, `raea doctor` and `raea goal next` agree on what each file is:
|
||||
//! - a composition is each <Composition> a registerRoot registers (its props read from the source, not rendered), or a
|
||||
//! .tsx's default export with none that no other file imports, registered for it under its file's name (versions
|
||||
//! NAME-vN.tsx are one composition), sized from its newest render's manifest when it has one;
|
||||
//! - a component is a .tsx a composition imports, directly or through another.
|
||||
//! What isn't connected is linted (lint.rs), each with its file and line and the fix. raea-app-workspace runs `scan`
|
||||
//! for `raea project scan`, `raea doctor`, `raea next` and `raea context`.
|
||||
//! for `raea project scan`, `raea doctor`, `raea goal next` and `raea context`.
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ pub(super) fn lint(reg: &Registry, files: &[File], used_by: &BTreeMap<String, BT
|
||||
format!("imports {} from outside the project", tilde(&to)),
|
||||
&match in_shared {
|
||||
Some(r) => format!("import it by the workspace's name for it: \"@shared/{}\"", r.with_extension("").to_string_lossy().replace(std::path::MAIN_SEPARATOR, "/")),
|
||||
None => "move it to the workspace's shared/ and import it as @shared/<kind>/<name>, or copy it into the project (raea component add, for raea's sets)".into(),
|
||||
None => "move it to the workspace's shared/ and import it as @shared/<kind>/<name>, or copy it into the project (raea make component add, for raea's sets)".into(),
|
||||
},
|
||||
))
|
||||
}
|
||||
|
||||
@@ -86,12 +86,12 @@ fn old_controllers(base: &Path, ws: Option<&Path>, out: &mut Vec<Finding>) {
|
||||
}
|
||||
}
|
||||
|
||||
/// A brief.ts that still keeps tasks in `stages` (docs/plan.feature PL8a): they read, unread, and belong in plan.org.
|
||||
/// A brief.ts that still keeps tasks in `stages` (docs/plan.feature PL8a): they read, unread, and belong in plan.ts.
|
||||
fn briefs_with_tasks(base: &Path, out: &mut Vec<Finding>) {
|
||||
let f = base.join("brief.ts");
|
||||
let Ok(text) = std::fs::read_to_string(&f) else { return };
|
||||
if text.lines().any(|l| l.trim_start().starts_with("stages:") || l.trim_start().starts_with("\"stages\":")) {
|
||||
let says = format!("{}: keeps tasks in `stages`, which raea no longer reads; move each to the project's plan.org (an Org heading under its stage, its mark as TODO, DONE or DROPPED), then delete `stages`", f.display());
|
||||
let says = format!("{}: keeps tasks in `stages`, which raea no longer reads; move each to the project's plan.ts (a task under its stage, its mark as its keyword: TODO, DONE or DROPPED), then delete `stages`", f.display());
|
||||
out.push(Finding { says, fix: Fix::No });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! `raea next` (docs/skills.feature SK10): the two or three useful next steps for a project, read from its files: the
|
||||
//! `raea goal next` (docs/skills.feature SK10): the two or three useful next steps for a project, read from its files: the
|
||||
//! brief (what it still needs, from the raea CLI's brief doctor), the storyboard its modes want, its compositions, and
|
||||
//! from the project's record (docs/direction.feature DR3) its renders and their checks and what each found. A menu for
|
||||
//! the agent or the person to pick from; nothing runs.
|
||||
@@ -97,10 +97,10 @@ pub fn steps(dir: &Path, brief: &Brief, stale: usize) -> Vec<String> {
|
||||
out
|
||||
}
|
||||
|
||||
/// `raea next`'s text.
|
||||
/// `raea goal next`'s text.
|
||||
pub fn text(dir: &Path, brief: &Brief, stale: usize) -> String {
|
||||
let s = steps(dir, brief, stale);
|
||||
let mut t = format!("raea next: {}\n", dir.display());
|
||||
let mut t = format!("raea goal next: {}\n", dir.display());
|
||||
for (i, line) in s.iter().enumerate() {
|
||||
t.push_str(&format!("{}. {line}\n", i + 1));
|
||||
}
|
||||
|
||||
@@ -91,8 +91,8 @@ fn doctor_connects_a_projects_files() {
|
||||
// a controller from before 11-20 is told where its parts go, and kept
|
||||
let out = doctor::doctor(&["--fix".into(), d.display().to_string()], &[], "0.0.1", &|_| Ok(String::new())).unwrap();
|
||||
assert!(out.starts_with("APPLIED 2 of 5 fixed") && out.contains("controllers/pace.ts: a controller, which raea no longer reads") && out.contains("taste.ts"), "{out}");
|
||||
// a brief's old tasks are said to belong in plan.org (docs/plan.feature PL8a), and kept
|
||||
assert!(out.contains("brief.ts: keeps tasks in `stages`") && out.contains("plan.org"), "{out}");
|
||||
// a brief's old tasks are said to belong in plan.ts (docs/plan.feature PL8a), and kept
|
||||
assert!(out.contains("brief.ts: keeps tasks in `stages`") && out.contains("plan.ts"), "{out}");
|
||||
assert!(d.join("controllers/pace.ts").is_file() && std::fs::read_to_string(d.join("brief.ts")).unwrap().contains("stages"), "nothing of the person's is deleted");
|
||||
let _ = std::fs::remove_dir_all(&d);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// A set as blender/lightbake.py left it (docs/bake.feature BK0): one <Model> of its meshes, each with its Cycles
|
||||
// lightmap and the exposure that puts the bake at raea's brightness, from the .lightmaps.json lightbake.py wrote. A
|
||||
// mesh lightbake.py left unbaked (a metal) is drawn as raea draws it. `raea bake light --compare` makes media/baked/.
|
||||
// mesh lightbake.py left unbaked (a metal) is drawn as raea draws it. `raea make bake light --compare` makes media/baked/.
|
||||
import { staticFile } from "raea";
|
||||
import { Model } from "raea/3d";
|
||||
import { Lightmap, StandardMaterial } from "raea/pbr";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// The cornell set with Cycles' bounce light baked into its lightmaps by blender/lightbake.py, any sun left live: what raea's
|
||||
// own bake is measured against (docs/bake.feature BK0). `raea bake light --compare` makes media/baked/cornell/.
|
||||
// own bake is measured against (docs/bake.feature BK0). `raea make bake light --compare` makes media/baked/cornell/.
|
||||
import { AbsoluteFill, Composition, registerRoot } from "raea";
|
||||
import { Baked } from "./baked";
|
||||
import { Look } from "./parts/cornell";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// The table set with Cycles' bounce light baked into its lightmaps by blender/lightbake.py, any sun left live: what raea's
|
||||
// own bake is measured against (docs/bake.feature BK0). `raea bake light --compare` makes media/baked/table/.
|
||||
// own bake is measured against (docs/bake.feature BK0). `raea make bake light --compare` makes media/baked/table/.
|
||||
import { AbsoluteFill, Composition, registerRoot } from "raea";
|
||||
import { Baked } from "./baked";
|
||||
import { Look } from "./parts/table";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// The window set with Cycles' bounce light baked into its lightmaps by blender/lightbake.py, any sun left live: what raea's
|
||||
// own bake is measured against (docs/bake.feature BK0). `raea bake light --compare` makes media/baked/window/.
|
||||
// own bake is measured against (docs/bake.feature BK0). `raea make bake light --compare` makes media/baked/window/.
|
||||
import { AbsoluteFill, Composition, registerRoot } from "raea";
|
||||
import { Baked } from "./baked";
|
||||
import { Look } from "./parts/window";
|
||||
|
||||
@@ -16,7 +16,7 @@ mkdir -p "$OUT"
|
||||
export RAEA_SIGN=0 RAEA_MARK=0 RAEA_EXPORT_CACHE=0
|
||||
expected() { case $1 in
|
||||
examples/games/animated-character.tsx) echo "its media/RobotExpressive.glb was deleted" ;;
|
||||
examples/playables/brick-rush.tsx) echo "a playable: it needs the playable host's raea_playable (sdk/playable)" ;;
|
||||
examples/playables/brick-rush.tsx) echo "RAEA_LIVE3D_CHECK panics on frame 1: the fast rows carry the sun's rotation and the full rows don't (runtime/scene/src/live.rs; docs/playables.feature PA18)" ;;
|
||||
sdk/raea/bench/bevy-parity/3d/rotate_environment_map.tsx) echo "clearcoat textures need raea-sys-material's multi-layer feature, off by default (as bench/bevy-parity/runs.tsv leaves it out)" ;;
|
||||
esac; }
|
||||
SAME=0 DIFF=0 ERR=0 SKIP=0
|
||||
|
||||
Executable
+30
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
# Two paint bugs, each held to what Chrome draws. Exits 1 on a failure.
|
||||
# #241 z.html: a stacking context's z-index: -1 child goes under its text. White pixels (the word) must be there:
|
||||
# before the fix the box covered the word and the frame had none.
|
||||
# #240 miter.html: a stroked rounded rect under a negative viewBox origin. Nothing blue left of the outline (x 0-60,
|
||||
# y 84-130: the outline starts at x 92), and the outline's top-left corner is round (dark at its square corner).
|
||||
# bench/paint-order/check.sh (RAEA_BIN: the raea to run, default target/release/raea)
|
||||
cd "$(dirname "$0")/../.." || exit 2
|
||||
BIN=${RAEA_BIN:-$PWD/target/release/raea}
|
||||
export RAEA_SIGN=0 RAEA_MARK=0 RAEA_EXPORT_CACHE=0
|
||||
OUT=$(mktemp -d "${TMPDIR:-/tmp}/raea-paint-order.XXXXXX")
|
||||
trap 'rm -rf "${OUT:?}"' EXIT
|
||||
status=0
|
||||
for p in z miter; do
|
||||
"$BIN" render "bench/paint-order/$p.html" -o "$OUT/$p.png" > "$OUT/$p.log" 2>&1 || { echo "FAIL render $p (log below)"; sed 's/^/ /' "$OUT/$p.log"; exit 1; }
|
||||
done
|
||||
# how many pixels of a region are near a colour
|
||||
count() { magick "$OUT/$1.png" -alpha off -crop "$2" +repage -fuzz "${4:-6}%" -fill black +opaque "$3" -fill white -opaque "$3" -colorspace Gray -format "%[fx:int(mean*w*h+0.5)]" info:; }
|
||||
white=$(count z 600x300+0+0 "#ffffff")
|
||||
(( white > 2000 )) || { echo "FAIL #241: $white white pixels, the word is under its z-index: -1 child"; status=1; }
|
||||
box=$(count z 600x300+0+0 "#10203C" 3)
|
||||
(( box > 3000 )) || { echo "FAIL #241: $box pixels of the box behind the word"; status=1; }
|
||||
bar=$(count miter 60x46+0+84 "#3c82f0")
|
||||
(( bar == 0 )) || { echo "FAIL #240: $bar blue pixels left of the outline (the miter join's bar)"; status=1; }
|
||||
corner=$(count miter 6x6+91+99 "#3c82f0")
|
||||
(( corner == 0 )) || { echo "FAIL #240: the outline's top-left corner is square ($corner blue pixels at its corner)"; status=1; }
|
||||
edge=$(count miter 200x6+400+97 "#3c82f0")
|
||||
(( edge > 300 )) || { echo "FAIL #240: the outline's top edge isn't drawn ($edge pixels)"; status=1; }
|
||||
[ $status = 0 ] && echo "PASS paint order: #241 text over a negative z-index child, #240 a miter join after an arc"
|
||||
exit $status
|
||||
@@ -0,0 +1,7 @@
|
||||
<!doctype html>
|
||||
<!-- #240: a thin rounded outline, nothing left of it (896 wide under a viewBox that starts at -20 drew a bar from x=0) -->
|
||||
<html><body style="margin:0;background:#111">
|
||||
<div data-composition-id="main" data-start="0" data-duration="1" data-width="1080" data-height="600" style="position:relative;width:1080px;height:600px;background:#111">
|
||||
<svg width="936" height="440" viewBox="-20 -20 936 440" style="position:absolute;left:72px;top:80px"><rect x="0" y="0" width="896" height="400" rx="24" fill="none" stroke="#3c82f0" stroke-width="3"/></svg>
|
||||
</div>
|
||||
</body></html>
|
||||
@@ -0,0 +1,7 @@
|
||||
<!doctype html>
|
||||
<!-- #241: white "Hollow" over a blue box that is its own z-index: -1 child -->
|
||||
<html><body style="margin:0;background:#111">
|
||||
<div data-composition-id="main" data-start="0" data-duration="1" data-width="600" data-height="300" style="position:relative;width:600px;height:300px;background:#111;display:flex;align-items:center;justify-content:center">
|
||||
<span style="position:relative;display:inline-block;z-index:1;color:#fff;font:700 80px sans-serif"><div style="position:absolute;inset:0;z-index:-1;background:#10203C;border:3px solid #3474D6"></div>Hollow</span>
|
||||
</div>
|
||||
</body></html>
|
||||
@@ -42,7 +42,7 @@ run() {
|
||||
frames=$(ffprobe -v error -count_frames -select_streams v:0 -show_entries stream=nb_read_frames -of csv=p=0 "$out" 2>/dev/null)
|
||||
secs=$(ffprobe -v error -show_entries format=duration -of csv=p=0 "$out" 2>/dev/null)
|
||||
local bake
|
||||
bake=$(grep -m1 '^raea bake:' "$log" | sed 's/^raea bake: //')
|
||||
bake=$(grep -m1 '^raea make bake:' "$log" | sed 's/^raea make bake: //')
|
||||
printf '%s\texit %s\t%.2f s\t%s ms a frame\t%s frames, %s s of video\tbake: %s\tstartup: %s\n' "$tag" "$rc" "$(echo "$t1 - $t0" | bc)" "${per:-?}" "${frames:-?}" "${secs:-?}" "${bake:-none}" "$marks"
|
||||
}
|
||||
while IFS=$'\t' read -r path comp from to scale sign; do
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! What a file is, cheaply: its size and a hash of its first and last MB. The ledger keeps it on every call
|
||||
//! (apps/ask record.rs), so a render is known again by its copy in the feed, a later render to the same path isn't
|
||||
//! taken for it, and `raea make status` knows an answer was about exactly the sheet on disk now (docs/make.feature MK4).
|
||||
//! taken for it, and `raea goal gates` knows an answer was about exactly the sheet on disk now (docs/goal.feature MK4).
|
||||
|
||||
use std::io::{Read as _, Seek as _, SeekFrom};
|
||||
use std::path::Path;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! The questions that come standard (docs/ask.feature AK1), each set named: `rubric` (the craft rubric's own questions,
|
||||
//! read from sdk/guides/craft/rubric.md, so there's one copy), `av` (picture with sound), `defects` (the fingerprint's
|
||||
//! axes with no labels yet), `platform` (the check packs' questions with their calibration), `decide` (picks and
|
||||
//! comparisons) and `make` (the review loop's gate questions, asked of a job's sheets: docs/make.feature MK4; each id
|
||||
//! comparisons) and `make` (the review loop's gate questions, asked of a job's sheets: docs/goal.feature MK4; each id
|
||||
//! says its sheet, make.clay.*, make.colour.*, make.refs.*, make.framing.*). The JSON sets ship inside raea; the
|
||||
//! rubric is read from the guide the caller hands in.
|
||||
|
||||
|
||||
+12
-7
@@ -1,5 +1,5 @@
|
||||
//! A project's brief: who it's for, the one thing they should believe and what it delivers. The facts an agent guessed
|
||||
//! are listed in `assumed`, for the person to confirm. Its tasks are in the project's plan.org, not here
|
||||
//! are listed in `assumed`, for the person to confirm. Its tasks are in the project's plan.ts, not here
|
||||
//! (docs/plan.feature PL8a).
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -48,7 +48,7 @@ pub struct Brief {
|
||||
#[serde(default)]
|
||||
#[ts(as = "Option<Vec<Reference>>", optional)]
|
||||
pub references: Vec<Reference>,
|
||||
/// an older brief's tasks, read only so it still loads: they belong in plan.org (docs/plan.feature PL8a), and
|
||||
/// an older brief's tasks, read only so it still loads: they belong in plan.ts (docs/plan.feature PL8a), and
|
||||
/// `raea doctor` says so; never written, and not in the schema an agent writes to
|
||||
#[serde(default, skip_serializing)]
|
||||
#[ts(skip)]
|
||||
@@ -61,11 +61,16 @@ pub struct Brief {
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(type = "unknown", optional)]
|
||||
pub story: Option<serde_json::Value>,
|
||||
/// a scene, kit or shot made to a frozen plan and held to the review loop (docs/make.feature): `scene()`, `kit()`
|
||||
/// or `shot()` from "raea/brief"; `raea make status` decides when it's done
|
||||
/// the project's tasks (raea/task `plan({...})`, docs/plan.feature): written inline or imported from a module, read
|
||||
/// from the brief's run by `raea goal tasks`; kept as written, raea/task reads it
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(type = "import(\"raea/task\").PlanFile", optional)]
|
||||
pub plan: Option<serde_json::Value>,
|
||||
/// what the work is held to (docs/goal.feature): one goal, or several in order (a workflow inline), each a `cut()`,
|
||||
/// `shot()`, `kit()`, `scene()` or `rules()` from "raea/brief"; `raea goal check` decides when each is done
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub make: Option<crate::make::Make>,
|
||||
pub goal: Option<crate::goal::Goals>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, TS)]
|
||||
@@ -129,8 +134,8 @@ pub fn doctor(b: &Brief) -> Vec<String> {
|
||||
for a in &b.assumed {
|
||||
out.push(format!("`{a}` is assumed: confirm it with the person"));
|
||||
}
|
||||
if let Some(m) = &b.make {
|
||||
out.extend(crate::make::doctor(m).into_iter().map(|d| format!("make: {d}")));
|
||||
if let Some(g) = &b.goal {
|
||||
out.extend(crate::goal::doctor_all(g).into_iter().map(|d| format!("goal: {d}")));
|
||||
}
|
||||
out
|
||||
}
|
||||
@@ -0,0 +1,281 @@
|
||||
//! A cut goal's contract (docs/goal.feature MK25): `goal: cut({...})` on brief.ts, the client's brief made into rules
|
||||
//! before anything is planned or cut. A brief read as context gets lost (11-25, Shane, on StreetTalk's street interview
|
||||
//! ads: "you need to make the process of ingesting the brief more direct, or else it's just context that gets lost. It
|
||||
//! needs to be written as a brief typescript rule that is then enforced"). Every rule quotes the brief line it came
|
||||
//! from (`from`), and raea/goal's quotes pack (sdk/goal) finds each quote in the brief's text, so a rule can't be
|
||||
//! invented and a brief line can't drift; then it holds every delivered file to the rules, from what's on disk.
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use ts_rs::TS;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, TS)]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
#[ts(optional_fields)]
|
||||
#[ts(rename = "CutGoal")]
|
||||
pub struct Cut {
|
||||
/// the brief as text, relative to brief.ts (`pdftotext -layout brief.pdf media/brief.txt`): every `from` is found in it
|
||||
pub brief: String,
|
||||
/// how many cuts the brief asks for; fewer planned is held open until an answered `open` item about "count" says why
|
||||
pub count: Option<Quoted<u32>>,
|
||||
/// a cut's length when its own `seconds` says none: [least, most]
|
||||
pub seconds: Option<[f64; 2]>,
|
||||
/// the formats every cut is delivered in when its own `formats` says none: "9:16", "16:9", "1:1", "4:5"
|
||||
#[serde(default)]
|
||||
#[ts(as = "Option<Vec<String>>", optional)]
|
||||
pub formats: Vec<String>,
|
||||
#[serde(default)]
|
||||
#[ts(as = "Option<Vec<CutPlan>>", optional)]
|
||||
pub cuts: Vec<CutPlan>,
|
||||
/// what is said or shown: in every cut unless `every: false` (then in one or more)
|
||||
#[serde(default)]
|
||||
#[ts(as = "Option<Vec<Phrase>>", optional)]
|
||||
pub say: Vec<Phrase>,
|
||||
/// what no cut says or shows: a banned claim, a word, a name
|
||||
#[serde(default)]
|
||||
#[ts(as = "Option<Vec<Phrase>>", optional)]
|
||||
pub never: Vec<Phrase>,
|
||||
/// the line every cut ends on, heard or on screen in its last `within` seconds
|
||||
pub cta: Option<Cta>,
|
||||
/// the brief's open items ([TO CONFIRM]): each holds the job open until it has an answer
|
||||
#[serde(default)]
|
||||
#[ts(as = "Option<Vec<Open>>", optional)]
|
||||
pub open: Vec<Open>,
|
||||
/// every face whole and every text big enough, by the frames check of each file (true when left out)
|
||||
pub frames: Option<bool>,
|
||||
}
|
||||
|
||||
/// A value with the brief's words for it.
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, TS)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
#[ts(rename = "Quoted")]
|
||||
pub struct Quoted<T: TS> {
|
||||
pub value: T,
|
||||
/// the brief's own words, as they are in its text
|
||||
pub from: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, TS)]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
#[ts(optional_fields)]
|
||||
#[ts(rename = "CutPlan")]
|
||||
pub struct CutPlan {
|
||||
/// [a-z0-9_], unique: each format lands as out/cuts/<id>_<W>x<H>.mp4 ("a1_s1_9x16.mp4")
|
||||
pub id: String,
|
||||
pub angle: Option<String>,
|
||||
/// solo or mashup
|
||||
pub kind: Option<String>,
|
||||
/// one of the brief's hook types ("Direct Problem", "Reaction")
|
||||
pub hook: Option<String>,
|
||||
/// captions, hook (a text hook) or none
|
||||
pub text: Option<String>,
|
||||
#[serde(default)]
|
||||
#[ts(as = "Option<Vec<String>>", optional)]
|
||||
pub formats: Vec<String>,
|
||||
pub seconds: Option<[f64; 2]>,
|
||||
/// the cut's beats in order (docs/goal.feature MK48): what each must make the viewer feel and understand, decided
|
||||
/// before the cut (Murch: emotion and story weigh most), and its pace
|
||||
#[serde(default)]
|
||||
#[ts(as = "Option<Vec<Beat>>", optional)]
|
||||
pub beats: Vec<Beat>,
|
||||
}
|
||||
|
||||
/// One beat of a cut, from `at` seconds to the next beat's (or the end).
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, TS)]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
#[ts(optional_fields)]
|
||||
#[ts(rename = "Beat")]
|
||||
pub struct Beat {
|
||||
/// where it starts, in seconds from the cut's start (0 for the first)
|
||||
pub at: f64,
|
||||
/// what the viewer feels here, in the person's words ("the itch of a chore left undone")
|
||||
pub feel: String,
|
||||
/// what the viewer understands by its end ("the app does the reminding")
|
||||
pub story: Option<String>,
|
||||
/// its average shot length in seconds: the shots inside it average within a third of this
|
||||
pub asl: Option<f64>,
|
||||
/// how its shot lengths move: "build" (shorter as it goes), "release" (longer) or "hold" (even)
|
||||
pub tempo: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, TS)]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
#[ts(optional_fields)]
|
||||
#[ts(rename = "Phrase")]
|
||||
pub struct Phrase {
|
||||
/// as it's said or shown; compared in lower case, by letters and digits ("24/7" and "24-7" are the same)
|
||||
pub text: String,
|
||||
pub from: String,
|
||||
/// `say` only: false when one cut saying it is enough
|
||||
pub every: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, TS)]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
#[ts(optional_fields)]
|
||||
#[ts(rename = "Cta")]
|
||||
pub struct Cta {
|
||||
pub text: String,
|
||||
pub from: String,
|
||||
/// the other lines a brief rotates (two host lines, a paid take's): any one lands it, each found in the brief
|
||||
#[serde(default)]
|
||||
#[ts(as = "Option<Vec<String>>", optional)]
|
||||
pub also: Vec<String>,
|
||||
/// how near the end it must land, in seconds (8 when left out)
|
||||
pub within: Option<f64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, TS)]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
#[ts(optional_fields)]
|
||||
#[ts(rename = "CutOpen")]
|
||||
pub struct Open {
|
||||
pub question: String,
|
||||
pub from: String,
|
||||
/// what it decides: "count", "cta", "offer", a cut's id...
|
||||
pub about: Option<String>,
|
||||
/// the person's answer, as they gave it, and who gave it: until then the job can't be done
|
||||
pub answer: Option<String>,
|
||||
pub by: Option<String>,
|
||||
}
|
||||
|
||||
/// A format's frame shape, "9:16" -> (9, 16).
|
||||
pub fn ratio(f: &str) -> Option<(u32, u32)> {
|
||||
let (w, h) = f.split_once(':')?;
|
||||
Some((w.trim().parse().ok().filter(|&w| w > 0)?, h.trim().parse().ok().filter(|&h| h > 0)?))
|
||||
}
|
||||
|
||||
/// A cut's formats and its length: its own, else the contract's.
|
||||
pub fn formats<'a>(c: &'a Cut, p: &'a CutPlan) -> &'a [String] {
|
||||
if p.formats.is_empty() { &c.formats } else { &p.formats }
|
||||
}
|
||||
pub fn seconds(c: &Cut, p: &CutPlan) -> Option<[f64; 2]> {
|
||||
p.seconds.or(c.seconds)
|
||||
}
|
||||
|
||||
/// Where a cut's format lands, relative to the brief: out/cuts/a1_s1_9x16.mp4.
|
||||
pub fn file(p: &CutPlan, format: &str) -> String {
|
||||
format!("out/cuts/{}_{}.mp4", p.id, format.replace(':', "x"))
|
||||
}
|
||||
|
||||
/// Every file the contract asks for.
|
||||
pub fn deliverables(c: &Cut) -> Vec<String> {
|
||||
c.cuts.iter().flat_map(|p| formats(c, p).iter().map(move |f| file(p, f))).collect()
|
||||
}
|
||||
|
||||
/// Every `from` in the contract, with what it backs: what doctor holds to have a quote (raea/goal's quotes pack finds
|
||||
/// each in the brief's text).
|
||||
pub fn quotes(c: &Cut) -> Vec<(String, &str)> {
|
||||
let mut q: Vec<(String, &str)> = Vec::new();
|
||||
if let Some(n) = &c.count {
|
||||
q.push(("count".into(), &n.from));
|
||||
}
|
||||
for (what, list) in [("say", &c.say), ("never", &c.never)] {
|
||||
for p in list {
|
||||
q.push((format!("{what} \"{}\"", p.text), &p.from));
|
||||
}
|
||||
}
|
||||
if let Some(cta) = &c.cta {
|
||||
q.push(("cta".into(), &cta.from));
|
||||
for line in &cta.also {
|
||||
q.push((format!("cta \"{line}\""), line));
|
||||
}
|
||||
}
|
||||
for o in &c.open {
|
||||
q.push((format!("open \"{}\"", o.question), &o.from));
|
||||
}
|
||||
q
|
||||
}
|
||||
|
||||
/// What the contract lacks before it can be cut against, each with what to do.
|
||||
pub fn doctor(c: &Cut) -> Vec<String> {
|
||||
let mut out = Vec::new();
|
||||
if c.brief.trim().is_empty() {
|
||||
out.push("no `brief`: the brief as text beside brief.ts (pdftotext -layout BRIEF.pdf media/brief.txt), which every `from` quotes".into());
|
||||
}
|
||||
if c.cuts.is_empty() {
|
||||
out.push("no cuts: list every cut the brief asks for, with its id, angle, hook and formats".into());
|
||||
}
|
||||
if c.count.is_none() {
|
||||
out.push("no `count`: how many cuts the brief asks for, with its words".into());
|
||||
}
|
||||
if c.cta.is_none() {
|
||||
out.push("no `cta`: the line the brief says every cut ends on (or an `open` item asking for it)".into());
|
||||
}
|
||||
let mut seen = std::collections::BTreeSet::new();
|
||||
for p in &c.cuts {
|
||||
if !seen.insert(p.id.as_str()) {
|
||||
out.push(format!("cut `{}` is listed twice", p.id));
|
||||
}
|
||||
if !crate::goal::is_name(&p.id) {
|
||||
out.push(format!("cut `{}`: ids are [a-z0-9_], the file it lands as", p.id));
|
||||
}
|
||||
let fs = formats(c, p);
|
||||
if fs.is_empty() {
|
||||
out.push(format!("cut `{}` has no formats: give it `formats`, or the contract's", p.id));
|
||||
}
|
||||
for f in fs.iter().filter(|f| ratio(f).is_none()) {
|
||||
out.push(format!("cut `{}`: format `{f}` isn't W:H (\"9:16\", \"16:9\", \"1:1\", \"4:5\")", p.id));
|
||||
}
|
||||
match seconds(c, p) {
|
||||
None => out.push(format!("cut `{}` has no length: `seconds: [least, most]`, its own or the contract's", p.id)),
|
||||
Some([a, b]) if !(a > 0.0 && a <= b) => out.push(format!("cut `{}`: seconds [{a}, {b}] isn't [least, most]", p.id)),
|
||||
_ => {}
|
||||
}
|
||||
if let Some(t) = &p.text
|
||||
&& !matches!(t.as_str(), "captions" | "hook" | "none")
|
||||
{
|
||||
out.push(format!("cut `{}`: text is captions, hook or none, not `{t}`", p.id));
|
||||
}
|
||||
let mut last = -1.0;
|
||||
for (i, b) in p.beats.iter().enumerate() {
|
||||
if b.at < 0.0 || b.at <= last || (i == 0 && b.at != 0.0) {
|
||||
out.push(format!("cut `{}`: beat {} at {} s: beats start at 0 and go in order", p.id, i + 1, b.at));
|
||||
}
|
||||
last = b.at;
|
||||
if b.feel.trim().is_empty() {
|
||||
out.push(format!("cut `{}`: beat {} has no `feel`: what the viewer feels there, in the person's words", p.id, i + 1));
|
||||
}
|
||||
if let Some(t) = &b.tempo
|
||||
&& !matches!(t.as_str(), "build" | "release" | "hold")
|
||||
{
|
||||
out.push(format!("cut `{}`: beat {}'s tempo is build, release or hold, not `{t}`", p.id, i + 1));
|
||||
}
|
||||
if b.asl.is_some_and(|a| !(a > 0.0)) {
|
||||
out.push(format!("cut `{}`: beat {}'s asl is seconds a shot, above 0", p.id, i + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
for (what, from) in quotes(c) {
|
||||
if from.trim().is_empty() {
|
||||
out.push(format!("{what} has no `from`: the brief's own words for it"));
|
||||
}
|
||||
}
|
||||
for p in c.say.iter().chain(&c.never) {
|
||||
if norm(&p.text).is_empty() {
|
||||
out.push(format!("phrase `{}` has no letters or digits to find", p.text));
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Text as it's compared: lower case, letters and digits, one space between words ("24/7" -> "24 7").
|
||||
pub fn norm(s: &str) -> String {
|
||||
let mut out = String::with_capacity(s.len());
|
||||
let mut gap = false;
|
||||
for ch in s.chars().flat_map(char::to_lowercase) {
|
||||
// a curly apostrophe or a plain one joins its word ("it's" is one word, "its" is another)
|
||||
if ch == '\'' || ch == '\u{2019}' {
|
||||
continue;
|
||||
}
|
||||
if ch.is_alphanumeric() {
|
||||
if gap && !out.is_empty() {
|
||||
out.push(' ');
|
||||
}
|
||||
gap = false;
|
||||
out.push(ch);
|
||||
} else {
|
||||
gap = true;
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
//! A job made to a frozen plan (docs/make.feature MK0): `make` on a project's brief.ts, written with `scene()`, `kit()`
|
||||
//! or `shot()` from "raea/brief" before anything is built, and read here. One loop, three kinds: a scene (a dressed,
|
||||
//! lit place), a kit (props that belong together) and a shot (stills or camera moves of a built scene). Every object
|
||||
//! carries its real size and whether it came from the reference or was invented; every dial its value, where the value
|
||||
//! came from, and what it meant here. `raea make status` (apps/make) holds the job to it.
|
||||
//! A goal (docs/goal.feature): one step of the work, on a project's brief.ts as `goal:` (one, or several in order: a
|
||||
//! workflow), written with `cut()`, `shot()`, `kit()`, `scene()` or `rules()` from "raea/brief" before anything is
|
||||
//! built, and read here. Each kind turns its packs on: a scene (a dressed, lit place), a kit (props that belong
|
||||
//! together), a shot (stills or camera moves of a built scene), a cut (ads from footage to a client's brief), and
|
||||
//! rules (any other work: only its own rules). Any goal can carry `rules` and an `aim`. Every object carries its real
|
||||
//! size and whether it came from the reference or was invented; every dial its value, where the value came from, and
|
||||
//! what it meant here. `raea goal check` (sdk/goal) holds each goal to it.
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
@@ -11,7 +13,7 @@ use ts_rs::TS;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, TS)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
#[ts(rename = "MakeKind")]
|
||||
#[ts(rename = "GoalKind")]
|
||||
pub enum Kind {
|
||||
/// a dressed, lit place from references or a brief
|
||||
Scene,
|
||||
@@ -19,13 +21,31 @@ pub enum Kind {
|
||||
Kit,
|
||||
/// stills or camera moves of a built scene, from words
|
||||
Shot,
|
||||
/// ads cut from footage to a client's brief: its deliverables, phrases, claims and CTA as rules (cut.rs, MK25)
|
||||
Cut,
|
||||
/// any other work, held only to its rules: commands that must pass, files that must exist, words a critic judges
|
||||
Rules,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, TS)]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
#[ts(optional_fields)]
|
||||
pub struct Make {
|
||||
pub struct Goal {
|
||||
pub kind: Kind,
|
||||
/// how the plan, the report and other goals' `after` name it ([a-z0-9_]); the kind when left out
|
||||
pub name: Option<String>,
|
||||
/// the workflow step it serves, by the workflow's name for it (`edit`, `deliver`)
|
||||
pub step: Option<String>,
|
||||
/// the goals that must be done before this one starts, by name
|
||||
#[serde(default)]
|
||||
#[ts(as = "Option<Vec<String>>", optional)]
|
||||
pub after: Vec<String>,
|
||||
/// what the goal is, in the person's words
|
||||
pub aim: Option<String>,
|
||||
/// what must hold before the agent may stop, beside the kind's packs: each checked in code or by a fresh critic
|
||||
#[serde(default)]
|
||||
#[ts(as = "Option<Vec<crate::rules::Rule>>", optional)]
|
||||
pub rules: Vec<crate::rules::Rule>,
|
||||
/// the pictures the job answers to (paths beside the brief): what is in it and where for a scene, the style for a kit
|
||||
#[serde(default)]
|
||||
#[ts(as = "Option<Vec<String>>", optional)]
|
||||
@@ -52,11 +72,28 @@ pub struct Make {
|
||||
pub deliverables: Vec<String>,
|
||||
/// the most critic rounds the job gets; at the cap it is delivered with what's still missing (8 by default)
|
||||
pub rounds: Option<u32>,
|
||||
/// a cut job's contract: the brief as rules (cut.rs)
|
||||
pub cut: Option<crate::cut::Cut>,
|
||||
/// what the job shows but never delivers, relative to the brief (pictures, render tests, examples): each a file or a
|
||||
/// `dir/` (review/ and previews/ when left out). Deliverables are what it hands over; previews are how it got there
|
||||
#[serde(default)]
|
||||
#[ts(as = "Option<Vec<String>>", optional)]
|
||||
pub previews: Vec<String>,
|
||||
/// raea's packs switched by name over the kind's defaults (`{ surprise: true, place: false }`): which of
|
||||
/// raea/goal's rules hold this goal (docs/goal.feature)
|
||||
#[serde(default)]
|
||||
#[ts(as = "Option<BTreeMap<String, bool>>", optional)]
|
||||
pub packs: BTreeMap<String, bool>,
|
||||
/// the project's own checks (raea/check `check()`, imported into brief.ts), run by `raea goal check`; as data, only
|
||||
/// their declarations (id, text, over, at) reach Rust
|
||||
#[serde(default)]
|
||||
#[ts(type = "Array<unknown>", optional)]
|
||||
pub checks: Vec<serde_json::Value>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, TS)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
#[ts(rename = "MakeSource")]
|
||||
#[ts(rename = "GoalSource")]
|
||||
pub enum Source {
|
||||
/// set by the person who asked: an instruction, even when the reference says otherwise
|
||||
Customer,
|
||||
@@ -66,7 +103,7 @@ pub enum Source {
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, TS)]
|
||||
#[serde(untagged)]
|
||||
#[ts(rename = "MakeDialValue")]
|
||||
#[ts(rename = "GoalDialValue")]
|
||||
pub enum DialValue {
|
||||
Number(f64),
|
||||
Text(String),
|
||||
@@ -74,7 +111,7 @@ pub enum DialValue {
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, TS)]
|
||||
#[serde(untagged)]
|
||||
#[ts(rename = "MakeDial")]
|
||||
#[ts(rename = "GoalDial")]
|
||||
pub enum Dial {
|
||||
/// `wear: 0.4`: the value alone, set by the person
|
||||
Bare(DialValue),
|
||||
@@ -91,7 +128,7 @@ pub enum Dial {
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, TS)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
#[ts(rename = "MakeRoute")]
|
||||
#[ts(rename = "GoalRoute")]
|
||||
pub enum Route {
|
||||
/// defined by numbers: Manifold solids, raea/room
|
||||
Solid,
|
||||
@@ -107,7 +144,7 @@ pub enum Route {
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, TS)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
#[ts(rename = "MakeOrigin")]
|
||||
#[ts(rename = "GoalOrigin")]
|
||||
pub enum Origin {
|
||||
/// seen in a reference
|
||||
Reference,
|
||||
@@ -118,7 +155,7 @@ pub enum Origin {
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, TS)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
#[ts(optional_fields)]
|
||||
#[ts(rename = "MakePick")]
|
||||
#[ts(rename = "GoalPick")]
|
||||
pub struct Pick {
|
||||
/// "tripo-h31", "meshy", ...
|
||||
pub generator: String,
|
||||
@@ -129,7 +166,7 @@ pub struct Pick {
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, TS)]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
#[ts(optional_fields)]
|
||||
#[ts(rename = "MakeObject")]
|
||||
#[ts(rename = "GoalObject")]
|
||||
pub struct Object {
|
||||
/// snake_case, unique in the job
|
||||
pub id: String,
|
||||
@@ -150,6 +187,10 @@ pub struct Object {
|
||||
pub at: Option<[f64; 3]>,
|
||||
pub rot: Option<f64>,
|
||||
pub hero: Option<bool>,
|
||||
/// how large it is planned to be seen, which is how much of it gets built: 0 the hero (half the frame or more),
|
||||
/// 1 featured (under 50%), 2 dressing (under 20%), 3 background (under 8%: a grey box reads), 4 far (under 2%: a
|
||||
/// silhouette). A render that shows it finer than this says so (`lod-closer`; `raea scene lod` lists every part)
|
||||
pub lod: Option<u8>,
|
||||
pub pick: Option<Pick>,
|
||||
/// what was fixed by script ("glass made transmissive, label kept opaque")
|
||||
#[serde(default)]
|
||||
@@ -160,7 +201,7 @@ pub struct Object {
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, TS)]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
#[ts(optional_fields)]
|
||||
#[ts(rename = "MakeShot")]
|
||||
#[ts(rename = "GoalShot")]
|
||||
pub struct Shot {
|
||||
/// [a-z0-9_]: the file it lands as (out/shots/<name>.png or .mp4)
|
||||
pub name: String,
|
||||
@@ -176,29 +217,47 @@ pub struct Shot {
|
||||
pub handheld: Option<String>,
|
||||
/// a still rather than a move
|
||||
pub still: Option<bool>,
|
||||
/// the composition that renders it (relative to the brief): `raea make framing` and `lenschart` draw it
|
||||
/// the composition that renders it (relative to the brief): `raea make shots` draws its framing sheet and lens chart
|
||||
pub composition: Option<String>,
|
||||
/// its frame rate, for the frames `seconds` spans (30 when left out)
|
||||
pub fps: Option<f64>,
|
||||
}
|
||||
|
||||
impl Kind {
|
||||
/// as brief.ts writes it, and as raea judge's rubrics are named
|
||||
pub fn name(self) -> &'static str {
|
||||
// in the enum's order
|
||||
["scene", "kit", "shot", "cut", "rules"][self as usize]
|
||||
}
|
||||
}
|
||||
|
||||
/// Each kind's dials: what may be set, and what an unset one is read from the references as.
|
||||
pub fn dials(kind: Kind) -> &'static [&'static str] {
|
||||
match kind {
|
||||
Kind::Scene => &["density", "tidiness", "wear", "wetness", "time_of_day", "weather", "atmosphere", "power", "warmth", "look"],
|
||||
Kind::Kit => &["count", "variety", "detail", "wear", "wetness", "warmth", "look"],
|
||||
Kind::Shot => &["res", "seconds", "lens", "handheld", "look"],
|
||||
Kind::Cut => &["look"],
|
||||
Kind::Rules => &[],
|
||||
}
|
||||
}
|
||||
|
||||
/// The round cap when the plan names none: AnyKit's and raea judge's 8.
|
||||
pub const ROUNDS: u32 = 8;
|
||||
|
||||
/// What must exist when the job is done, relative to the brief's folder: the plan's own list, else the kind's.
|
||||
pub fn deliverables(m: &Make) -> Vec<String> {
|
||||
if !m.deliverables.is_empty() {
|
||||
return m.deliverables.clone();
|
||||
/// What must exist when the goal is done, relative to the brief's folder: its own list, else its kind's; and each of
|
||||
/// its `file` rules.
|
||||
pub fn deliverables(m: &Goal) -> Vec<String> {
|
||||
let mut out = if m.deliverables.is_empty() { by_kind(m) } else { m.deliverables.clone() };
|
||||
for f in m.rules.iter().filter_map(|r| r.file.clone()) {
|
||||
if !out.contains(&f) {
|
||||
out.push(f);
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
fn by_kind(m: &Goal) -> Vec<String> {
|
||||
match m.kind {
|
||||
// the stills are counted (three or more), not named: apps/make checks the folder
|
||||
Kind::Scene => vec!["out/stills/".into()],
|
||||
@@ -214,11 +273,24 @@ pub fn deliverables(m: &Make) -> Vec<String> {
|
||||
}
|
||||
// a shot is a still or a move, so either file answers; apps/make reads `a|b`
|
||||
Kind::Shot => m.shots.iter().map(|s| format!("out/shots/{0}.png|out/shots/{0}.mp4", s.name)).collect(),
|
||||
Kind::Cut => m.cut.as_ref().map(crate::cut::deliverables).unwrap_or_default(),
|
||||
// only its `file` rules, added above
|
||||
Kind::Rules => vec![],
|
||||
}
|
||||
}
|
||||
|
||||
/// What the job shows but doesn't deliver: the plan's own list, else review/ and previews/.
|
||||
pub fn previews(m: &Goal) -> Vec<String> {
|
||||
if m.previews.is_empty() { vec!["review/".into(), "previews/".into()] } else { m.previews.clone() }
|
||||
}
|
||||
|
||||
/// A name a file lands as: [a-z0-9_], not empty.
|
||||
pub fn is_name(s: &str) -> bool {
|
||||
!s.is_empty() && s.chars().all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || c == '_')
|
||||
}
|
||||
|
||||
/// What the plan still lacks before it can be built against, each with what to do. Empty when it's ready.
|
||||
pub fn doctor(m: &Make) -> Vec<String> {
|
||||
pub fn doctor(m: &Goal) -> Vec<String> {
|
||||
let mut out = Vec::new();
|
||||
let allowed = dials(m.kind);
|
||||
for name in m.dials.keys().filter(|k| !allowed.contains(&k.as_str())) {
|
||||
@@ -229,6 +301,24 @@ pub fn doctor(m: &Make) -> Vec<String> {
|
||||
Kind::Scene | Kind::Kit if m.objects.is_empty() => out.push("no objects: list every object with its real size and route".into()),
|
||||
_ => {}
|
||||
}
|
||||
match (&m.cut, m.kind) {
|
||||
(Some(c), Kind::Cut) => out.extend(crate::cut::doctor(c)),
|
||||
(None, Kind::Cut) => out.push("no `cut`: the brief as rules (count, cuts, say, never, cta, open), each quoting it".into()),
|
||||
(Some(_), k) => out.push(format!("`cut` is for a cut job, not a {k:?}: drop it, or make this `cut({{...}})`")),
|
||||
_ => {}
|
||||
}
|
||||
out.extend(crate::rules::doctor(&m.rules));
|
||||
if m.kind == Kind::Rules {
|
||||
if m.aim.as_deref().is_none_or(|a| a.trim().is_empty()) {
|
||||
out.push("no `aim`: the goal in the person's own words".into());
|
||||
}
|
||||
if m.rules.is_empty() {
|
||||
out.push("no `rules`: what must hold before you stop, each a `run` command, a `file` or words a critic judges (`says`)".into());
|
||||
}
|
||||
}
|
||||
if let Some(n) = m.name.as_deref().filter(|n| !is_name(n)) {
|
||||
out.push(format!("name `{n}`: names are [a-z0-9_]"));
|
||||
}
|
||||
if m.kind == Kind::Kit && m.style.is_none() {
|
||||
out.push("no `style`: one paragraph (era, palette, materials, wear, one fictional maker) every reference carries".into());
|
||||
}
|
||||
@@ -240,6 +330,9 @@ pub fn doctor(m: &Make) -> Vec<String> {
|
||||
if o.h.is_none() && o.dims.is_none() && o.max.is_none() {
|
||||
out.push(format!("object `{}` has no size: give `h` (metres), `dims` for boxy things or `max` for flat ones", o.id));
|
||||
}
|
||||
if o.lod.is_some_and(|l| l > 4) {
|
||||
out.push(format!("object `{}` has lod {}: 0 (the hero, half the frame or more) to 4 (far, under 2% of it)", o.id, o.lod.unwrap_or(0)));
|
||||
}
|
||||
if o.route.is_none() && m.kind == Kind::Scene {
|
||||
out.push(format!("object `{}` has no route: solid, rule, gen, library or picture", o.id));
|
||||
}
|
||||
@@ -254,7 +347,7 @@ pub fn doctor(m: &Make) -> Vec<String> {
|
||||
if !names.insert(s.name.as_str()) {
|
||||
out.push(format!("shot `{}` is listed twice", s.name));
|
||||
}
|
||||
if !s.name.chars().all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || c == '_') {
|
||||
if !is_name(&s.name) {
|
||||
out.push(format!("shot `{}`: names are [a-z0-9_], the file it lands as", s.name));
|
||||
}
|
||||
if s.composition.is_none() {
|
||||
@@ -263,3 +356,48 @@ pub fn doctor(m: &Make) -> Vec<String> {
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
|
||||
/// A brief's `goal`: one goal, or several in order (a workflow inline). `after` orders them past the list's order.
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, TS)]
|
||||
#[serde(untagged)]
|
||||
pub enum Goals {
|
||||
One(Box<Goal>),
|
||||
Many(Vec<Goal>),
|
||||
}
|
||||
|
||||
impl Goals {
|
||||
/// every goal, in the order written
|
||||
pub fn all(&self) -> Vec<&Goal> {
|
||||
match self {
|
||||
Goals::One(g) => vec![g.as_ref()],
|
||||
Goals::Many(v) => v.iter().collect(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A goal's name: its own, else its kind's.
|
||||
pub fn name_of(g: &Goal) -> String {
|
||||
g.name.clone().unwrap_or_else(|| g.kind.name().to_string())
|
||||
}
|
||||
|
||||
/// What the goals still lack together: names given twice, an `after` naming no goal.
|
||||
pub fn doctor_all(gs: &Goals) -> Vec<String> {
|
||||
let all = gs.all();
|
||||
let mut out = Vec::new();
|
||||
let names: Vec<String> = all.iter().map(|g| name_of(g)).collect();
|
||||
let mut seen = std::collections::BTreeSet::new();
|
||||
for n in &names {
|
||||
if !seen.insert(n.as_str()) && all.len() > 1 {
|
||||
out.push(format!("two goals are named `{n}`: give each its own `name`"));
|
||||
}
|
||||
}
|
||||
for g in &all {
|
||||
for a in g.after.iter().filter(|a| !names.contains(a)) {
|
||||
out.push(format!("goal `{}` comes after `{a}`, which no goal is named", name_of(g)));
|
||||
}
|
||||
let n = name_of(g);
|
||||
out.extend(doctor(g).into_iter().map(|d| if all.len() > 1 { format!("{n}: {d}") } else { d }));
|
||||
}
|
||||
out
|
||||
}
|
||||
@@ -4,13 +4,15 @@
|
||||
//! types (`declarations`), so what tsc checks is exactly what this crate reads.
|
||||
|
||||
pub mod brief;
|
||||
pub mod make;
|
||||
pub mod cut;
|
||||
pub mod goal;
|
||||
pub mod parts;
|
||||
pub mod rules;
|
||||
pub mod script;
|
||||
pub mod taste;
|
||||
|
||||
pub use brief::Brief;
|
||||
pub use make::Make;
|
||||
pub use goal::{Goal, Goals};
|
||||
pub use parts::Parts;
|
||||
pub use script::Script;
|
||||
pub use taste::Taste;
|
||||
@@ -38,7 +40,9 @@ pub fn declarations() -> String {
|
||||
script::Script, script::Scene, script::Beat, script::Line,
|
||||
taste::Taste, taste::TasteSection, taste::Rule, taste::RuleCheck, taste::RuleLevel, taste::Check,
|
||||
parts::Parts, parts::Concept, parts::Level, parts::Count, parts::Part,
|
||||
make::Make, make::Kind, make::Source, make::DialValue, make::Dial, make::Route, make::Origin, make::Pick, make::Object, make::Shot,
|
||||
goal::Goal, goal::Kind, goal::Source, goal::DialValue, goal::Dial, goal::Route, goal::Origin, goal::Pick, goal::Object, goal::Shot, goal::Goals,
|
||||
cut::Cut, cut::Quoted<u32>, cut::CutPlan, cut::Phrase, cut::Cta, cut::Open,
|
||||
rules::Rule,
|
||||
));
|
||||
out.join("\n\n") + "\n"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! An object's parts (NAME.parts.ts, `parts()` from "raea/brief"), written before any geometry and frozen when
|
||||
//! building starts (docs/handoff/solids.md, "The plan is the contract"; named parts since 11-20, so "plan" is only a
|
||||
//! project's plan.org, docs/plan.feature PL8a). Generic over what's made: a crown, a feather and a rocking horse are all a concept and a tree of
|
||||
//! project's plan.ts, docs/plan.feature PL8a). Generic over what's made: a crown, a feather and a rocking horse are all a concept and a tree of
|
||||
//! named parts, each with a level, a count, and a material and style it has or inherits.
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
//! A goal's rules (docs/goal.feature): what must hold before the agent may stop, on any goal of brief.ts (11-26, Shane:
|
||||
//! "we essentially just need to make sure that it can't stop unless all the goals pass, or all the rules in the
|
||||
//! brief"). `/goal` in raea.app and an agent's own goal are this: the goal's `aim` in the person's words, then each
|
||||
//! thing that must hold, as a command that must pass, a file that must exist, or words a fresh critic must find true.
|
||||
//! raea/goal's rule packs (sdk/goal/src/packs/goal.ts) decide from them whether the agent may stop; the agent saying so
|
||||
//! never does.
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use ts_rs::TS;
|
||||
|
||||
/// One thing that must hold. Exactly one of `run`, `file` or `says`.
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, TS)]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
#[ts(optional_fields)]
|
||||
#[ts(rename = "GoalRule")]
|
||||
pub struct Rule {
|
||||
/// a short name: [a-z0-9_], how status, the critic and NOTES.md name it
|
||||
pub id: String,
|
||||
/// a command that must exit 0, run in the brief's folder (`bun test`, `raea check edit.tsx`)
|
||||
pub run: Option<String>,
|
||||
/// the seconds `run` gets before it counts as failed (300 when left out)
|
||||
pub timeout: Option<u32>,
|
||||
/// a file that must exist, relative to the brief (`a|b`: either; `dir/`: three or more pictures in it)
|
||||
pub file: Option<String>,
|
||||
/// words that must be true of the work, judged by a fresh critic (`raea goal judge`), never by the agent that did it
|
||||
pub says: Option<String>,
|
||||
}
|
||||
|
||||
/// What a goal's rules still lack, each with what to do. Empty when they're ready.
|
||||
pub fn doctor(rules: &[Rule]) -> Vec<String> {
|
||||
let mut out = Vec::new();
|
||||
let mut seen = std::collections::BTreeSet::new();
|
||||
for r in rules {
|
||||
if !crate::goal::is_name(&r.id) {
|
||||
out.push(format!("rule `{}`: ids are [a-z0-9_]", r.id));
|
||||
}
|
||||
if !seen.insert(r.id.as_str()) {
|
||||
out.push(format!("rule `{}` is listed twice", r.id));
|
||||
}
|
||||
let n = [r.run.is_some(), r.file.is_some(), r.says.is_some()].iter().filter(|x| **x).count();
|
||||
if n != 1 {
|
||||
out.push(format!("rule `{}` needs exactly one of `run`, `file` or `says` (it has {n})", r.id));
|
||||
}
|
||||
if r.timeout.is_some() && r.run.is_none() {
|
||||
out.push(format!("rule `{}` has a `timeout` but no `run`", r.id));
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
+40
-10
@@ -99,27 +99,57 @@ fn an_older_brief_with_stages_still_reads_and_never_writes_them() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_make_plan_reads_and_its_doctor_names_what_it_lacks() {
|
||||
let b: Brief = read("brief.ts", r#"{"title": "Flight desk kit", "make": {"kind": "kit",
|
||||
fn a_goal_reads_and_its_doctor_names_what_it_lacks() {
|
||||
let b: Brief = read("brief.ts", r#"{"title": "Flight desk kit", "goal": {"kind": "kit",
|
||||
"dials": {"count": 2, "wear": {"value": 0.4, "source": "customer", "means": "scuffed bakelite"}, "time_of_day": "night"},
|
||||
"objects": [{"id": "phone", "label": "Rotary phone", "h": 0.12, "prompt": "a rotary desk phone", "source": "invented"},
|
||||
{"id": "ashtray", "label": "Glass ashtray"}]}}"#).unwrap();
|
||||
let m = b.make.as_ref().unwrap();
|
||||
assert_eq!(m.kind, make::Kind::Kit);
|
||||
let d = make::doctor(m);
|
||||
let gs = b.goal.as_ref().unwrap();
|
||||
let m = gs.all()[0];
|
||||
assert_eq!(m.kind, goal::Kind::Kit);
|
||||
let d = goal::doctor(m);
|
||||
assert!(d.iter().any(|x| x.contains("`time_of_day`")), "a scene's dial on a kit: {d:?}");
|
||||
assert!(d.iter().any(|x| x.contains("no `style`")), "{d:?}");
|
||||
assert!(d.iter().any(|x| x.contains("`ashtray` has no size")), "{d:?}");
|
||||
assert!(d.iter().any(|x| x.contains("`ashtray` is generated but has no prompt")), "{d:?}");
|
||||
assert!(!d.iter().any(|x| x.contains("`phone`")), "{d:?}");
|
||||
assert!(brief::doctor(&b).iter().any(|x| x.starts_with("make: ")));
|
||||
let want = make::deliverables(m);
|
||||
assert!(brief::doctor(&b).iter().any(|x| x.starts_with("goal: ")));
|
||||
let want = goal::deliverables(m);
|
||||
assert!(want.contains(&"out/kit/phone/phone_lod1.glb".to_string()) && want.contains(&"out/kit/kit.json".to_string()), "{want:?}");
|
||||
}
|
||||
|
||||
// MK22: an object's planned detail, 0 (the hero) to 4 (far)
|
||||
#[test]
|
||||
fn an_object_plans_its_detail_and_the_doctor_holds_it_to_five_levels() {
|
||||
let m: goal::Goal = read("goal", r#"{"kind": "scene", "objects": [
|
||||
{"id": "kiosk", "label": "Kiosk", "h": 2.4, "route": "solid", "lod": 3},
|
||||
{"id": "tower", "label": "Tower", "h": 40, "route": "picture", "lod": 7}]}"#).unwrap();
|
||||
assert_eq!(m.objects[0].lod, Some(3));
|
||||
let d = goal::doctor(&m);
|
||||
assert!(d.iter().any(|x| x.contains("`tower` has lod 7")) && !d.iter().any(|x| x.contains("`kiosk`")), "{d:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_shot_plan_wants_a_still_or_a_move_per_shot() {
|
||||
let m: make::Make = read("make", r#"{"kind": "shot", "shots": [{"name": "counter_push", "move": "push_in"}, {"name": "Bad Name"}]}"#).unwrap();
|
||||
assert_eq!(make::deliverables(&m)[0], "out/shots/counter_push.png|out/shots/counter_push.mp4");
|
||||
assert!(make::doctor(&m).iter().any(|x| x.contains("`Bad Name`")));
|
||||
let m: goal::Goal = read("goal", r#"{"kind": "shot", "shots": [{"name": "counter_push", "move": "push_in"}, {"name": "Bad Name"}]}"#).unwrap();
|
||||
assert_eq!(goal::deliverables(&m)[0], "out/shots/counter_push.png|out/shots/counter_push.mp4");
|
||||
assert!(goal::doctor(&m).iter().any(|x| x.contains("`Bad Name`")));
|
||||
}
|
||||
|
||||
// goal.feature GL2: several goals in order are a workflow inline; names, `after` and rules on any kind are held
|
||||
#[test]
|
||||
fn several_goals_are_a_workflow_and_each_is_held_to_its_rules() {
|
||||
let b: Brief = read("brief.ts", r#"{"title": "Spring", "goal": [
|
||||
{"kind": "cut", "name": "cut", "step": "edit", "rules": [{"id": "tests", "run": "bun test"}]},
|
||||
{"kind": "rules", "name": "deliver", "after": ["cut", "grade"], "rules": [{"id": "Bad", "file": "out/a.mp4", "says": "x"}]}]}"#).unwrap();
|
||||
let gs = b.goal.as_ref().unwrap();
|
||||
assert_eq!(gs.all().len(), 2);
|
||||
assert_eq!(gs.all()[0].rules[0].run.as_deref(), Some("bun test"));
|
||||
let d = goal::doctor_all(gs);
|
||||
assert!(d.iter().any(|x| x.contains("after `grade`, which no goal is named")), "{d:?}");
|
||||
assert!(d.iter().any(|x| x.starts_with("deliver: no `aim`")), "{d:?}");
|
||||
assert!(d.iter().any(|x| x.starts_with("deliver: rule `Bad`: ids are")), "{d:?}");
|
||||
assert!(d.iter().any(|x| x.contains("needs exactly one of")), "{d:?}");
|
||||
let one: Brief = read("brief.ts", r#"{"title": "x", "goal": {"kind": "rules", "aim": "ship it", "rules": [{"id": "ok", "run": "true"}]}}"#).unwrap();
|
||||
assert!(goal::doctor_all(one.goal.as_ref().unwrap()).is_empty());
|
||||
}
|
||||
@@ -8,6 +8,11 @@ pub mod easing;
|
||||
pub mod interpolate;
|
||||
pub mod spring;
|
||||
|
||||
/// The logistic curve, 1 / (1 + e^-z): a score in log-odds as a chance (a judge's), or a stored logit as an opacity.
|
||||
pub fn sigmoid(z: f32) -> f32 {
|
||||
1.0 / (1.0 + (-z).exp())
|
||||
}
|
||||
|
||||
/// 0 below `a`, 1 above `b`, and between them the cubic Hermite ease (WGSL's smoothstep), for a value that fades in
|
||||
/// over a range rather than a key's time.
|
||||
pub fn smoothstep(a: f32, b: f32, x: f32) -> f32 {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! The project's record (docs/direction.feature DR3): what each render and each `raea check` found, one JSON file
|
||||
//! apiece under the project's .raea/record/, with the commit the project was at. `raea findings` reads it back across
|
||||
//! renders (what was fixed, what is new, what is carried) and `raea next` reads what stands. A file outside a raea
|
||||
//! renders (what was fixed, what is new, what is carried) and `raea goal next` reads what stands. A file outside a raea
|
||||
//! project (no .raea/project at or above it) has no record.
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
@@ -64,7 +64,7 @@ fn real(p: &Path) -> PathBuf {
|
||||
}
|
||||
|
||||
/// A path as the record names it: relative to the project when it's in it, with '/' between its parts on Windows too (a
|
||||
/// project's record moves between machines, and `raea next` quotes it in commands).
|
||||
/// project's record moves between machines, and `raea goal next` quotes it in commands).
|
||||
pub fn rel(project: &Path, p: &Path) -> String {
|
||||
let full = real(p);
|
||||
full.strip_prefix(project).map(|r| r.to_string_lossy().replace(std::path::MAIN_SEPARATOR, "/")).unwrap_or_else(|_| full.display().to_string())
|
||||
|
||||
@@ -120,7 +120,7 @@ fn wanted() -> Option<&'static ([f64; 3], [f64; 3], Option<f64>)> {
|
||||
}
|
||||
|
||||
/// RAEA_LENS="mm": the scene's own camera kept where it is, with that focal length's field of view on a full-frame
|
||||
/// sensor (a lens chart, docs/make.feature MK15).
|
||||
/// sensor (a lens chart, docs/goal.feature MK15).
|
||||
fn lens() -> Option<f64> {
|
||||
static LENS: OnceLock<Option<f64>> = OnceLock::new();
|
||||
*LENS.get_or_init(|| std::env::var("RAEA_LENS").ok()?.trim().parse::<f64>().ok().filter(|mm| *mm > 0.0).map(fov_of_lens))
|
||||
|
||||
+29
-7
@@ -109,10 +109,26 @@ fn hash_props(m: &Map<String, Value>, h: &mut impl Hasher, take: impl Fn(&str) -
|
||||
}
|
||||
}
|
||||
|
||||
/// A standard material's maps whose picture a render swaps frame by frame (raea-sys-material's SwappedMaps,
|
||||
/// docs/render-memory.feature RM6): a change of picture keys the map's column instead of cutting the part's track.
|
||||
/// The packed roughness and metalness maps are one texture made from two pictures, so they still cut.
|
||||
pub const SWAPPED_MAPS: [(&str, &str); 5] = [("map", "map"), ("normalMap", "normal_map"), ("metallicRoughnessMap", "mr_map"), ("aoMap", "ao_map"), ("emissiveMap", "emissive_map")];
|
||||
|
||||
/// Whether a part's standard material takes its pictures frame by frame in a render (SWAPPED_MAPS): a plain
|
||||
/// standard or physical surface, none of the surfaces built over it (a grid, paint, wear, a procedural pattern, a
|
||||
/// shader), whose maps are made into their own material once.
|
||||
pub fn swaps_maps(it: &Item) -> bool {
|
||||
let Some(m) = &it.material else { return false };
|
||||
matches!(&*m.kind, "MeshStandardMaterial" | "MeshPhysicalMaterial")
|
||||
&& !["grid", "paint", "wear", "procedural", "shader", "toon"].iter().any(|k| m.props.contains_key(*k))
|
||||
&& !["shader", "three", "surface"].iter().any(|k| it.props.contains_key(*k))
|
||||
}
|
||||
|
||||
/// A part's kept inputs as one number: what its row takes from the frame it's spawned in (its shape, its material's
|
||||
/// maps and modes, its words and their glyphs, a model's file). Two frames of a part with the same number make the
|
||||
/// same kept columns.
|
||||
pub fn spawn_sig(it: &Item) -> u64 {
|
||||
/// same kept columns. With `swapped`, a swapped map's picture is left out (whether it has one still counts), as a
|
||||
/// render keys it (SWAPPED_MAPS) rather than cutting the part's track for it; without, every picture counts.
|
||||
pub fn spawn_sig(it: &Item, swapped: bool) -> u64 {
|
||||
let mut h = std::collections::hash_map::DefaultHasher::new();
|
||||
it.kind.hash(&mut h);
|
||||
match it.kind {
|
||||
@@ -120,9 +136,14 @@ pub fn spawn_sig(it: &Item) -> u64 {
|
||||
it.shape.hash(&mut h);
|
||||
if let Some(m) = &it.material {
|
||||
m.kind.hash(&mut h);
|
||||
let swap = swapped && swaps_maps(it);
|
||||
let picture = |k: &str| swap && SWAPPED_MAPS.iter().any(|(p, _)| *p == k) && m.props.get(k).and_then(Value::as_str).is_some_and(|s| !s.starts_with("render:"));
|
||||
// a three.js shader's spec is its uniforms and its source, the one keyed and the other its identity
|
||||
if &*m.kind != "ThreeShaderMaterial" {
|
||||
hash_props(&m.props, &mut h, |k| !MAT_LIVE.contains(&k));
|
||||
hash_props(&m.props, &mut h, |k| !MAT_LIVE.contains(&k) && !picture(k));
|
||||
}
|
||||
for (p, _) in SWAPPED_MAPS.iter().filter(|(p, _)| picture(p)) {
|
||||
p.hash(&mut h);
|
||||
}
|
||||
}
|
||||
hash_props(&it.props, &mut h, |k| MESH_KEPT.contains(&k));
|
||||
@@ -147,7 +168,7 @@ pub fn spawn_sig(it: &Item) -> u64 {
|
||||
h.finish()
|
||||
}
|
||||
|
||||
/// Tracks cut where a part's kept inputs change: each run of frames with the same spawn_sig is a track of its own
|
||||
/// Tracks cut where a part's kept inputs change: each run of frames with the same spawn_sig (swapped maps left out) is a track of its own
|
||||
/// (`ID~1`, `ID~2` after the first), so a render's row never holds one frame's shape or words over another frame's.
|
||||
pub fn split_kept(tracks: Vec<(String, Vec<Option<Item>>)>) -> Vec<(String, Vec<Option<Item>>)> {
|
||||
let mut out = Vec::with_capacity(tracks.len());
|
||||
@@ -161,7 +182,8 @@ pub fn split_kept(tracks: Vec<(String, Vec<Option<Item>>)>) -> Vec<(String, Vec<
|
||||
let mut runs: Vec<(u64, Vec<Option<Item>>)> = Vec::new();
|
||||
for (i, slot) in track.into_iter().enumerate() {
|
||||
let Some(it) = slot else { continue };
|
||||
let s = spawn_sig(&it);
|
||||
// a render keys a swapped map's picture (SWAPPED_MAPS) rather than cutting for it
|
||||
let s = spawn_sig(&it, true);
|
||||
if runs.last().is_none_or(|(r, _)| *r != s) {
|
||||
runs.push((s, vec![None; n]));
|
||||
}
|
||||
@@ -197,7 +219,7 @@ pub struct KeptInputs {
|
||||
|
||||
impl KeptInputs {
|
||||
pub fn of(it: &Item) -> KeptInputs {
|
||||
KeptInputs { sig: spawn_sig(it), props: it.props.clone(), mat: it.material.as_ref().map(|m| m.props.clone()), shape: it.shape.clone() }
|
||||
KeptInputs { sig: spawn_sig(it, false), props: it.props.clone(), mat: it.material.as_ref().map(|m| m.props.clone()), shape: it.shape.clone() }
|
||||
}
|
||||
|
||||
/// Whether `it` has the kept inputs these were taken from; when it has, its props are held from now on.
|
||||
@@ -210,7 +232,7 @@ impl KeptInputs {
|
||||
if Arc::ptr_eq(&self.props, &it.props) && held(&self.mat, it.material.as_ref().map(|m| &m.props)) && self.shape == it.shape {
|
||||
return true;
|
||||
}
|
||||
if spawn_sig(it) != self.sig {
|
||||
if spawn_sig(it, false) != self.sig {
|
||||
return false;
|
||||
}
|
||||
*self = KeptInputs::of(it);
|
||||
|
||||
@@ -224,3 +224,131 @@ pub fn ray_tri(o: Vec3, d: Vec3, [a, b, c]: [Vec3; 3]) -> Option<f32> {
|
||||
let t = e2.dot(q) / det;
|
||||
(t >= 0.0).then_some(t)
|
||||
}
|
||||
|
||||
/// The part's lowest points (its feet): its vertices within a millimetre (or 2% of its height) of its lowest, and
|
||||
/// points across the faces lying there (a slab's corners overhang what holds it up; its middle doesn't), about 4 n at most.
|
||||
pub fn feet(p: &Part, n: usize) -> Vec<Vec3> {
|
||||
let tol = (0.02 * (p.hi.y - p.lo.y)).clamp(0.0005, 0.003);
|
||||
let low = |q: &Vec3| q.y <= p.lo.y + tol;
|
||||
let mut v: Vec<Vec3> = p.tris.iter().flatten().filter(|q| low(q)).copied().collect();
|
||||
let bases: Vec<&[Vec3; 3]> = p.tris.iter().filter(|t| t.iter().all(low)).collect();
|
||||
let area: f32 = bases.iter().map(|t| 0.5 * (t[1] - t[0]).cross(t[2] - t[0]).length()).sum();
|
||||
if area > 0.0 {
|
||||
// about n points over the base, spread by area
|
||||
let step = (area / n as f32).sqrt();
|
||||
for t in bases {
|
||||
let long = (t[1] - t[0]).length().max((t[2] - t[1]).length()).max((t[0] - t[2]).length());
|
||||
let m = ((long / step).ceil() as usize).clamp(1, 32);
|
||||
for i in 0..=m {
|
||||
for j in 0..=(m - i) {
|
||||
let (a, b) = (i as f32 / m as f32, j as f32 / m as f32);
|
||||
v.push(t[0] + (t[1] - t[0]) * a + (t[2] - t[0]) * b);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
v.sort_by(|a, b| (a.x, a.z, a.y).partial_cmp(&(b.x, b.z, b.y)).unwrap_or(std::cmp::Ordering::Equal));
|
||||
v.dedup_by(|a, b| (*a - *b).length() < 1e-4);
|
||||
if v.len() > 4 * n {
|
||||
let k = v.len() as f32 / (4 * n) as f32;
|
||||
v = (0..4 * n).map(|i| v[(i as f32 * k) as usize]).collect();
|
||||
}
|
||||
v
|
||||
}
|
||||
|
||||
/// A wall, or a piece of one (the strip of wall over a window, the window in it): no thicker than WALL_THICK, at least
|
||||
/// WALL_WIDE across and WALL_TALL high (metres; the kitchen's strip over its back window is 9.6 cm).
|
||||
const WALL_THICK: f32 = 0.35;
|
||||
const WALL_WIDE: f32 = 0.8;
|
||||
const WALL_TALL: f32 = 0.05;
|
||||
/// Whether a part is a wall or a piece of one: thin, wide and high.
|
||||
pub fn wall(p: &Part) -> bool {
|
||||
let e = p.hi - p.lo;
|
||||
e.y >= WALL_TALL && e.x.min(e.z) <= WALL_THICK && e.x.max(e.z) >= WALL_WIDE
|
||||
}
|
||||
|
||||
/// A wall's face area, for which of two is set into the other.
|
||||
pub fn face(p: &Part) -> f32 {
|
||||
let e = p.hi - p.lo;
|
||||
e.y * e.x.max(e.z)
|
||||
}
|
||||
|
||||
/// Whether a part's own material gives off light (a lamp's panel, a neon tube): any of its emissive's red, green or
|
||||
/// blue above zero. A model's materials are in its file and aren't read here.
|
||||
pub fn glows(it: &Item) -> bool {
|
||||
it.material.as_ref().and_then(|m| m.props.get("emissive")).is_some_and(glows_in)
|
||||
}
|
||||
|
||||
fn above_zero(v: &Value) -> bool {
|
||||
v.as_f64().unwrap_or(0.0) > 0.0
|
||||
}
|
||||
|
||||
/// A colour as the SDK writes one: [r, g, b, a], { red, green, blue, alpha }, a tagged one ({ LinearRgba: {...} }) or a
|
||||
/// CSS string.
|
||||
fn glows_in(v: &Value) -> bool {
|
||||
match v {
|
||||
Value::Array(a) => a.iter().take(3).any(above_zero),
|
||||
Value::Object(o) => {
|
||||
let own = ["red", "green", "blue", "r", "g", "b"].iter().filter_map(|k| o.get(*k)).any(above_zero);
|
||||
own || o.values().any(|v| (v.is_object() || v.is_array()) && glows_in(v))
|
||||
}
|
||||
Value::String(c) => !matches!(c.trim_start_matches('#').to_ascii_lowercase().as_str(), "000" | "000000" | "black" | ""),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// How far from the scene a part is parked: a piece swaps a flipbook's frames (MALL RAT's fountain, 88 water models) by
|
||||
/// moving the ones not shown hundreds of metres away, where they lie in one another and read as faces fighting.
|
||||
const PARKED: f32 = 500.0;
|
||||
|
||||
/// The parts in the scene, without those parked far from it (further than PARKED from the median of every part's
|
||||
/// centre), each of those said once as not checked.
|
||||
pub fn unparked<T>(parts: Vec<Part>, items: Vec<T>, skipped: &mut Vec<String>) -> (Vec<Part>, Vec<T>) {
|
||||
if parts.len() < 3 {
|
||||
return (parts, items);
|
||||
}
|
||||
let mid = |k: usize| {
|
||||
let mut v: Vec<f32> = parts.iter().map(|p| ((p.lo + p.hi) * 0.5)[k]).collect();
|
||||
v.sort_by(f32::total_cmp);
|
||||
v[v.len() / 2]
|
||||
};
|
||||
let centre = Vec3::new(mid(0), mid(1), mid(2));
|
||||
let mut parked = 0;
|
||||
let kept: (Vec<Part>, Vec<T>) = parts.into_iter().zip(items).filter(|(p, _)| {
|
||||
let far = ((p.lo + p.hi) * 0.5).distance(centre) > PARKED;
|
||||
parked += far as usize;
|
||||
!far
|
||||
}).unzip();
|
||||
if parked > 0 {
|
||||
skipped.push(format!("{parked} part{} parked over {PARKED} m from the scene (a flipbook's frames not shown)", if parked == 1 { "" } else { "s" }));
|
||||
}
|
||||
kept
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn a_flipbooks_frames_parked_far_away_are_left_out() {
|
||||
let part = |name: &str, c: Vec3, s: Vec3| Part { label: name.into(), tris: Vec::new(), node: Vec::new(), nodes: Vec::new(), lo: c - s / 2.0, hi: c + s / 2.0, excused: false, moving: false };
|
||||
let mut parts = vec![part("floor", Vec3::ZERO, Vec3::new(20.0, 0.1, 20.0)), part("bench", Vec3::new(1.0, 0.3, 0.0), Vec3::new(1.5, 0.5, 0.4)), part("water0", Vec3::new(0.0, 0.5, 3.0), Vec3::ONE)];
|
||||
for i in 1..4 {
|
||||
parts.push(part(&format!("water{i}"), Vec3::new(0.0, -900.0, 3.0), Vec3::ONE));
|
||||
}
|
||||
let mut skipped = Vec::new();
|
||||
let (kept, _) = unparked(parts, vec![(); 6], &mut skipped);
|
||||
assert_eq!(kept.iter().map(|p| p.label.as_str()).collect::<Vec<_>>(), ["floor", "bench", "water0"]);
|
||||
assert!(skipped[0].starts_with("3 parts parked"), "{skipped:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_colour_with_any_light_in_it_glows() {
|
||||
use serde_json::json;
|
||||
assert!(glows_in(&json!({"red": 0.0, "green": 120.0, "blue": 0.0, "alpha": 1.0})));
|
||||
assert!(glows_in(&json!([2200.0, 120.0, 80.0, 1.0])));
|
||||
// black with an alpha of 1 doesn't
|
||||
assert!(!glows_in(&json!({"red": 0.0, "green": 0.0, "blue": 0.0, "alpha": 1.0})));
|
||||
assert!(!glows_in(&json!([0.0, 0.0, 0.0, 1.0])));
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,8 @@ manifold-rust = "0.16.0"
|
||||
skrifa = "0.44"
|
||||
raea-core-fonts = { path = "../fonts" }
|
||||
serde_json = "1"
|
||||
# content names for kept BufferMesh text (buffer.rs kept_buffer)
|
||||
blake3 = "1.8"
|
||||
# blended distance fields and generators (trees, lofts, terrain, rosettes), meshed then closed into solids
|
||||
raea-core-sdf = { path = "../sdf" }
|
||||
raea-core-grow = { path = "../grow" }
|
||||
@@ -128,6 +128,42 @@ pub fn export_tris(t: &Tris, uvs: Option<&[[f32; 2]]>, path: &str, format: &str)
|
||||
Ok(bytes.len())
|
||||
}
|
||||
|
||||
/// A <BufferMesh>'s text from this long on is kept on disk and named by its content (kept_buffer).
|
||||
pub const KEEP_BUFFER_AT: usize = 1 << 16;
|
||||
|
||||
/// A long BufferMesh shape (`buffer:{json}`) as `buffer:@NAME`: its JSON written once to raea's caches
|
||||
/// (buffers/NAME.json, NAME its content's BLAKE3), so what holds the shape holds 40 characters
|
||||
/// (docs/render-memory.feature RM8). halcyon's palms were 263 MB of vertex arrays as text, held by the React scene,
|
||||
/// every frame's program row, the store and the evaluator: two of them 51 MB each. None for a short one, one already
|
||||
/// kept, or when the caches folder can't be written (the text then goes as it is).
|
||||
pub fn kept_buffer(expr: &str) -> Option<String> {
|
||||
let json = expr.strip_prefix("buffer:")?;
|
||||
if json.len() < KEEP_BUFFER_AT || json.starts_with('@') {
|
||||
return None;
|
||||
}
|
||||
let hex = blake3::hash(json.as_bytes()).to_hex();
|
||||
let name = &hex.as_str()[..32];
|
||||
let dir = crate::kept::caches()?.join("buffers");
|
||||
let p = dir.join(format!("{name}.json"));
|
||||
if !p.exists() {
|
||||
let part = dir.join(format!(".{name}.{}.part", std::process::id()));
|
||||
std::fs::create_dir_all(&dir).ok()?;
|
||||
std::fs::write(&part, json).ok()?;
|
||||
std::fs::rename(&part, &p).ok()?;
|
||||
}
|
||||
Some(format!("buffer:@{name}"))
|
||||
}
|
||||
|
||||
/// A buffer shape's JSON (what follows `buffer:`): its own text, or the kept file `@NAME` names (kept_buffer).
|
||||
pub fn buffer_json(b: &str) -> Result<std::borrow::Cow<'_, str>, String> {
|
||||
let Some(name) = b.strip_prefix('@') else { return Ok(std::borrow::Cow::Borrowed(b)) };
|
||||
if name.len() != 32 || !name.bytes().all(|c| c.is_ascii_hexdigit()) {
|
||||
return Err(format!("buffer:@{name}: not a kept buffer's name"));
|
||||
}
|
||||
let p = crate::kept::caches().ok_or("no caches folder for a kept buffer")?.join("buffers").join(format!("{name}.json"));
|
||||
std::fs::read_to_string(&p).map(std::borrow::Cow::Owned).map_err(|e| format!("buffer:@{name}: {}: {e}", p.display()))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -160,4 +196,16 @@ mod tests {
|
||||
assert_eq!((v.len(), i.len()), (18, 6));
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_long_buffer_is_kept_by_its_content_and_read_back() {
|
||||
let pos: Vec<String> = (0..36000).map(|i| format!("{}", i % 7)).collect();
|
||||
let expr = format!("buffer:{{\"positions\": [{}]}}", pos.join(", "));
|
||||
assert!(expr.len() > KEEP_BUFFER_AT);
|
||||
let Some(k) = kept_buffer(&expr) else { return }; // no caches folder here: nothing to check
|
||||
assert!(k.starts_with("buffer:@") && k.len() == 8 + 32, "{k}");
|
||||
assert_eq!(kept_buffer(&expr).as_deref(), Some(k.as_str()), "the same text, the same name");
|
||||
assert_eq!(buffer_json(&k[7..]).unwrap(), &expr[7..]);
|
||||
assert!(kept_buffer("buffer:{\"positions\": [0, 0, 0]}").is_none(), "a short one stays as it is");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
//! A cache by key in two generations of at most `cap` bytes each, for what's costly to make and too big to keep all
|
||||
//! of: core/shape's meshes (`cached`) and runtime/calls' built Manifolds (docs/render-memory.feature). One asked for
|
||||
//! again moves to the newest generation and stays; one made and never asked for again goes a generation later, so two
|
||||
//! generations at most are held. An entry's weight is its holder's to say; its key counts too.
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
pub struct Generations<V> {
|
||||
now: HashMap<String, (V, usize)>,
|
||||
old: HashMap<String, (V, usize)>,
|
||||
/// the newest generation's bytes
|
||||
bytes: usize,
|
||||
cap: usize,
|
||||
}
|
||||
|
||||
impl<V: Clone> Generations<V> {
|
||||
pub fn new(cap: usize) -> Self {
|
||||
Generations { now: HashMap::new(), old: HashMap::new(), bytes: 0, cap }
|
||||
}
|
||||
|
||||
/// What's held for `key`, in either generation: one from the older is held again in the newest.
|
||||
pub fn get(&mut self, key: &str) -> Option<V> {
|
||||
if let Some((v, _)) = self.now.get(key) {
|
||||
return Some(v.clone());
|
||||
}
|
||||
let (v, weight) = self.old.remove(key)?;
|
||||
self.hold(key, v.clone(), weight);
|
||||
Some(v)
|
||||
}
|
||||
|
||||
/// `v`, weighing `weight` bytes, held for `key` in the newest generation, which becomes the older one when it
|
||||
/// would pass the cap.
|
||||
pub fn hold(&mut self, key: &str, v: V, weight: usize) {
|
||||
let bytes = weight + key.len();
|
||||
if self.bytes + bytes > self.cap && !self.now.is_empty() {
|
||||
self.old = std::mem::take(&mut self.now);
|
||||
self.bytes = 0;
|
||||
}
|
||||
self.bytes += bytes;
|
||||
self.now.insert(key.to_string(), (v, weight));
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn held_entries_go_a_generation_at_a_time_and_what_is_asked_again_stays() {
|
||||
// entries of a quarter of a generation each
|
||||
let mut g = Generations::new(4000);
|
||||
g.hold("kept", 1u8, 996);
|
||||
for i in 0..12 {
|
||||
g.hold(&format!("bar {i:02}"), 1u8, 994);
|
||||
assert!(g.get("kept").is_some(), "asked each time, it stays (after bar {i})");
|
||||
}
|
||||
assert!(g.get("bar 00").is_none(), "made once and never asked again, it went");
|
||||
assert!(g.now.len() + g.old.len() <= 8, "two generations at most: {} + {}", g.now.len(), g.old.len());
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ use std::path::PathBuf;
|
||||
|
||||
/// raea's caches folder, as raea-io-home names it (this crate is below it): ~/Library/Caches/raea on macOS,
|
||||
/// %LOCALAPPDATA%\raea\cache on Windows, $XDG_CACHE_HOME/raea or ~/.cache/raea elsewhere.
|
||||
fn caches() -> Option<PathBuf> {
|
||||
pub(crate) fn caches() -> Option<PathBuf> {
|
||||
let base = PathBuf::from(std::env::var_os(if cfg!(windows) { "LOCALAPPDATA" } else { "HOME" })?);
|
||||
if base.as_os_str().is_empty() {
|
||||
return None;
|
||||
|
||||
+12
-48
@@ -34,9 +34,12 @@ mod kept;
|
||||
mod mesh;
|
||||
mod parse;
|
||||
mod sphere;
|
||||
pub mod generations;
|
||||
|
||||
pub use generations::Generations;
|
||||
pub use sphere::{SphereOf, cuboid_of, cylinder_of, plane_of, sphere_of};
|
||||
|
||||
pub use buffer::{buffer_tris, export_tris};
|
||||
pub use buffer::{buffer_json, buffer_tris, export_tris, kept_buffer, KEEP_BUFFER_AT};
|
||||
pub use mesh::{export, from_mesh, read_glb, read_obj, to_mesh};
|
||||
|
||||
use std::collections::HashMap;
|
||||
@@ -211,47 +214,22 @@ const KEEP_MS: f64 = 2.0;
|
||||
/// and the end checks once more.
|
||||
const GEN_BYTES: usize = 16 << 20;
|
||||
|
||||
/// The shapes held, the newest generation and the one before, and the newest's bytes.
|
||||
#[derive(Default)]
|
||||
struct Held {
|
||||
now: HashMap<String, std::sync::Arc<Tris>>,
|
||||
old: HashMap<String, std::sync::Arc<Tris>>,
|
||||
bytes: usize,
|
||||
}
|
||||
|
||||
impl Held {
|
||||
fn get(&mut self, expr: &str) -> Option<std::sync::Arc<Tris>> {
|
||||
if let Some(t) = self.now.get(expr) {
|
||||
return Some(t.clone());
|
||||
}
|
||||
let t = self.old.remove(expr)?;
|
||||
self.hold(expr, &t);
|
||||
Some(t)
|
||||
}
|
||||
|
||||
/// `t` held for `expr` in the newest generation, which becomes the one before when it would pass GEN_BYTES.
|
||||
fn hold(&mut self, expr: &str, t: &std::sync::Arc<Tris>) {
|
||||
let bytes = (t.positions.len() + t.normals.len()) * 12 + expr.len();
|
||||
if self.bytes + bytes > GEN_BYTES && !self.now.is_empty() {
|
||||
self.old = std::mem::take(&mut self.now);
|
||||
self.bytes = 0;
|
||||
}
|
||||
self.bytes += bytes;
|
||||
self.now.insert(expr.to_string(), t.clone());
|
||||
}
|
||||
/// What a mesh weighs as it's held: its positions and normals.
|
||||
fn tris_bytes(t: &Tris) -> usize {
|
||||
(t.positions.len() + t.normals.len()) * 12
|
||||
}
|
||||
|
||||
/// The mesh for an expression, built once per expression (a re-cut or a key that doesn't change the shape costs nothing).
|
||||
pub fn cached(expr: &str) -> Result<std::sync::Arc<Tris>, String> {
|
||||
static CACHE: OnceLock<Mutex<Held>> = OnceLock::new();
|
||||
let cache = CACHE.get_or_init(Default::default);
|
||||
static CACHE: OnceLock<Mutex<Generations<std::sync::Arc<Tris>>>> = OnceLock::new();
|
||||
let cache = CACHE.get_or_init(|| Mutex::new(Generations::new(GEN_BYTES)));
|
||||
if let Some(t) = cache.lock().unwrap().get(expr) {
|
||||
return Ok(t);
|
||||
}
|
||||
// a buffer mesh's own triangles (buffer.rs): data already, so nothing is kept on disk for it
|
||||
if let Some(b) = expr.strip_prefix("buffer:") {
|
||||
let t = std::sync::Arc::new(buffer_tris(b)?.0);
|
||||
cache.lock().unwrap().hold(expr, &t);
|
||||
let t = std::sync::Arc::new(buffer_tris(&buffer_json(b)?)?.0);
|
||||
cache.lock().unwrap().hold(expr, t.clone(), tris_bytes(&t));
|
||||
return Ok(t);
|
||||
}
|
||||
// made by this build before, on disk (kept.rs): read back as it was written
|
||||
@@ -267,7 +245,7 @@ pub fn cached(expr: &str) -> Result<std::sync::Arc<Tris>, String> {
|
||||
t
|
||||
}
|
||||
};
|
||||
cache.lock().unwrap().hold(expr, &t);
|
||||
cache.lock().unwrap().hold(expr, t.clone(), tris_bytes(&t));
|
||||
Ok(t)
|
||||
}
|
||||
|
||||
@@ -275,20 +253,6 @@ pub fn cached(expr: &str) -> Result<std::sync::Arc<Tris>, String> {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn held_shapes_go_a_generation_at_a_time_and_what_is_asked_again_stays() {
|
||||
let mut h = Held::default();
|
||||
// a shape of a quarter of a generation
|
||||
let t = std::sync::Arc::new(Tris { positions: vec![[0.0; 3]; GEN_BYTES / 96], normals: vec![[0.0; 3]; GEN_BYTES / 96] });
|
||||
h.hold("kept", &t);
|
||||
for i in 0..12 {
|
||||
h.hold(&format!("bar {i}"), &t);
|
||||
assert!(h.get("kept").is_some(), "asked each time, it stays (after bar {i})");
|
||||
}
|
||||
assert!(h.get("bar 0").is_none(), "made once and never asked again, it went");
|
||||
assert!(h.now.len() + h.old.len() <= 8, "two generations at most: {} + {}", h.now.len(), h.old.len());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_kept_mesh_reads_back_as_it_was_written() {
|
||||
let dir = std::env::temp_dir().join(format!("raea-shape-kept-{}", std::process::id()));
|
||||
|
||||
Loaded 100 of 2084 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user