refactor: add DesignIR distillation pipeline

This commit is contained in:
Jerry
2026-07-27 17:24:04 +08:00
parent 0adaac2b2a
commit 550b339bcc
1128 changed files with 10248 additions and 426666 deletions
@@ -1,119 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
MODE="write"
CLEAN=0
CHECK_DIR="${DXF_SKILL_CHECK_DIR:-$REPO_ROOT/tmp/dxf-skill-runtime-check}"
CADPY_PACKAGE_DIR="$REPO_ROOT/packages/cadpy"
CADPY_RUNTIME_DIR="$REPO_ROOT/skills/dxf/scripts/packages/cadpy"
usage() {
cat <<'EOF'
Usage:
scripts/bundle/bundle-skill.sh dxf [--check] [--clean]
Vendors packages/cadpy into skills/dxf/scripts/packages/cadpy.
Options:
--check Fail if the generated DXF skill runtime copy is stale.
--clean Remove the temporary check directory first.
-h, --help
Show this help.
EOF
}
while [ "$#" -gt 0 ]; do
case "$1" in
--check)
MODE="check"
;;
--clean)
CLEAN=1
;;
-h|--help)
usage
exit 0
;;
*)
echo "Unknown argument: $1" >&2
usage >&2
exit 2
;;
esac
shift
done
if [ ! -f "$CADPY_PACKAGE_DIR/pyproject.toml" ] || [ ! -d "$CADPY_PACKAGE_DIR/src/cadpy" ]; then
echo "Missing cadpy package source: $CADPY_PACKAGE_DIR" >&2
echo "The DXF skill Python runtime is bundled from packages/cadpy." >&2
exit 1
fi
if ! command -v rsync >/dev/null 2>&1; then
echo "rsync is required to vendor cadpy into the DXF skill runtime." >&2
exit 1
fi
if [ "$CLEAN" -eq 1 ]; then
rm -rf "$CHECK_DIR"
fi
sync_cadpy_runtime() {
local target_dir="$1"
rm -rf "$target_dir"
mkdir -p "$target_dir"
rsync -a --delete \
--delete-excluded \
--exclude __pycache__ \
--exclude .pytest_cache \
--exclude '*.pyc' \
--exclude '*.md' \
--exclude build \
--exclude dist \
--exclude '*.egg-info' \
--exclude tests \
--exclude __tests__ \
--exclude 'test_*.py' \
--exclude '*_test.py' \
"$CADPY_PACKAGE_DIR/" "$target_dir/"
}
check_cadpy_runtime() {
local check_dir="$CHECK_DIR/packages/cadpy"
if [ ! -d "$CADPY_RUNTIME_DIR" ]; then
echo "Missing generated cadpy runtime: skills/dxf/scripts/packages/cadpy" >&2
echo "" >&2
echo "Run scripts/bundle/bundle-skill.sh dxf and commit the updated runtime files." >&2
exit 1
fi
if ! diff -qr \
-x __pycache__ \
-x .pytest_cache \
-x '*.pyc' \
-x '*.egg-info' \
-x '*.md' \
-x tests \
-x __tests__ \
-x 'test_*.py' \
-x '*_test.py' \
"$check_dir" "$CADPY_RUNTIME_DIR" >/tmp/dxf-skill-cadpy-runtime-diff.txt; then
cat /tmp/dxf-skill-cadpy-runtime-diff.txt >&2
echo "" >&2
echo "DXF skill cadpy runtime is stale." >&2
echo "Run scripts/bundle/bundle-skill.sh dxf and commit skills/dxf/scripts/packages/cadpy." >&2
exit 1
fi
echo "DXF skill cadpy runtime is up to date."
}
if [ "$MODE" = "check" ]; then
sync_cadpy_runtime "$CHECK_DIR/packages/cadpy"
check_cadpy_runtime
else
sync_cadpy_runtime "$CADPY_RUNTIME_DIR"
echo "Bundled skills/dxf/scripts/packages/cadpy"
fi
@@ -1,144 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
MODE="write"
CLEAN=0
IMPLICITJS_PACKAGE_DIR="$REPO_ROOT/packages/implicitjs"
IMPLICITJS_RUNTIME_DIR="$REPO_ROOT/skills/implicit-cad/scripts/packages/implicitjs"
CHECK_DIR="${IMPLICIT_CAD_SKILL_BUNDLE_CHECK_DIR:-$REPO_ROOT/tmp/implicit-cad-skill-runtime-check}"
usage() {
cat <<'EOF'
Usage:
scripts/bundle/bundle-skill.sh implicit-cad [--check] [--clean]
Bundles the implicitjs package copy used by skills/implicit-cad in production
layouts.
Options:
--check Bundle into tmp/ and fail if checked-in production outputs are stale.
--clean Remove temporary check directories first.
-h, --help
Show this help.
EOF
}
while [ "$#" -gt 0 ]; do
case "$1" in
--check)
MODE="check"
;;
--clean)
CLEAN=1
;;
-h|--help)
usage
exit 0
;;
*)
echo "Unknown argument: $1" >&2
usage >&2
exit 2
;;
esac
shift
done
require_file() {
local path_to_check="$1"
local label="$2"
if [ ! -f "$path_to_check" ]; then
echo "Missing $label: $path_to_check" >&2
exit 1
fi
}
require_dir() {
local path_to_check="$1"
local label="$2"
if [ ! -d "$path_to_check" ]; then
echo "Missing $label: $path_to_check" >&2
exit 1
fi
}
sync_implicitjs_package() {
local target_dir="$1"
rm -rf "$target_dir"
mkdir -p "$target_dir"
rsync -a --delete \
--prune-empty-dirs \
--delete-excluded \
--exclude node_modules \
--exclude dist \
--exclude coverage \
--exclude tmp \
--exclude .vite \
--exclude .DS_Store \
"$IMPLICITJS_PACKAGE_DIR/" "$target_dir/"
}
check_implicitjs_package() {
local expected_dir="$CHECK_DIR/packages/implicitjs"
local label="${IMPLICITJS_RUNTIME_DIR#$REPO_ROOT/}"
local diff_path="${TMPDIR:-/tmp}/implicit-cad-skill-implicitjs-package-diff.txt"
if [ ! -d "$IMPLICITJS_RUNTIME_DIR" ]; then
echo "Missing generated implicitjs package runtime: $label" >&2
return 1
fi
if ! diff -qr \
-x node_modules \
-x dist \
-x coverage \
-x tmp \
-x .vite \
-x .DS_Store \
"$expected_dir" "$IMPLICITJS_RUNTIME_DIR" >"$diff_path"; then
cat "$diff_path" >&2
echo "" >&2
echo "Implicit CAD skill implicitjs package runtime is stale." >&2
return 1
fi
return 0
}
check_development_layout() {
"$REPO_ROOT/scripts/dev/setup-skill-symlink.sh" implicit-cad --check
echo "Implicit CAD skill is in development symlink layout; production package freshness is checked on build-test/main."
}
require_file "$IMPLICITJS_PACKAGE_DIR/package.json" "implicitjs package"
require_dir "$IMPLICITJS_PACKAGE_DIR/src" "implicitjs source"
require_file "$IMPLICITJS_PACKAGE_DIR/scripts/snapshot.mjs" "implicit CAD snapshot CLI"
require_file "$IMPLICITJS_PACKAGE_DIR/scripts/export.mjs" "implicit CAD export CLI"
if [ "$MODE" = "check" ] && [ -L "$IMPLICITJS_RUNTIME_DIR" ]; then
check_development_layout
exit 0
fi
if [ "$CLEAN" -eq 1 ]; then
rm -rf "$CHECK_DIR"
fi
if [ "$MODE" = "check" ]; then
rm -rf "$CHECK_DIR"
sync_implicitjs_package "$CHECK_DIR/packages/implicitjs"
stale=0
check_implicitjs_package || stale=1
if [ "$stale" -ne 0 ]; then
echo "" >&2
echo "Run scripts/bundle/bundle-skill.sh implicit-cad and commit the updated production package copy." >&2
exit 1
fi
echo "Implicit CAD skill production outputs are up to date."
else
sync_implicitjs_package "$IMPLICITJS_RUNTIME_DIR"
echo "Bundled skills/implicit-cad/scripts/packages/implicitjs"
fi
@@ -1,115 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
MODE="write"
CLEAN=0
PACKAGE_DIR="$REPO_ROOT/packages/cadpy_metadata"
RUNTIME_DIR="$REPO_ROOT/skills/sdf/scripts/packages/cadpy_metadata"
usage() {
cat <<'EOF'
Usage:
scripts/bundle/bundle-skill.sh sdf [--check] [--clean]
Vendors packages/cadpy_metadata into skills/sdf/scripts/packages/cadpy_metadata.
Options:
--check Fail if the generated SDF skill runtime copy is stale.
--clean Remove the generated runtime copy before writing it.
-h, --help
Show this help.
EOF
}
while [ "$#" -gt 0 ]; do
case "$1" in
--check)
MODE="check"
;;
--clean)
CLEAN=1
;;
-h|--help)
usage
exit 0
;;
*)
echo "Unknown argument: $1" >&2
usage >&2
exit 2
;;
esac
shift
done
if [ ! -f "$PACKAGE_DIR/pyproject.toml" ] || [ ! -d "$PACKAGE_DIR/src/cadpy_metadata" ]; then
echo "Missing cadpy_metadata package source: $PACKAGE_DIR" >&2
exit 1
fi
if ! command -v rsync >/dev/null 2>&1; then
echo "rsync is required to vendor cadpy_metadata into the SDF skill runtime." >&2
exit 1
fi
sync_runtime() {
rm -rf "$RUNTIME_DIR"
mkdir -p "$RUNTIME_DIR"
rsync -a --delete \
--delete-excluded \
--exclude __pycache__ \
--exclude .pytest_cache \
--exclude '*.pyc' \
--exclude '*.egg-info' \
--exclude '*.md' \
--exclude build \
--exclude dist \
--exclude tests \
--exclude __tests__ \
--exclude 'test_*.py' \
--exclude '*_test.py' \
"$PACKAGE_DIR/" "$RUNTIME_DIR/"
}
check_runtime() {
local label="${RUNTIME_DIR#$REPO_ROOT/}"
local diff_path="${TMPDIR:-/tmp}/sdf-skill-cadpy-metadata-diff.txt"
if [ ! -d "$RUNTIME_DIR" ]; then
echo "Missing generated cadpy_metadata runtime: $label" >&2
echo "Run scripts/bundle/bundle-skill.sh sdf and commit the generated copy." >&2
exit 1
fi
if ! diff -qr \
-x __pycache__ \
-x .pytest_cache \
-x '*.pyc' \
-x '*.egg-info' \
-x '*.md' \
-x build \
-x dist \
-x tests \
-x __tests__ \
-x 'test_*.py' \
-x '*_test.py' \
"$PACKAGE_DIR" "$RUNTIME_DIR" >"$diff_path"; then
cat "$diff_path" >&2
echo "" >&2
echo "Stale generated cadpy_metadata runtime: $label" >&2
echo "Run scripts/bundle/bundle-skill.sh sdf and commit the generated copy." >&2
exit 1
fi
echo "$label is up to date."
}
if [ "$MODE" = "check" ]; then
check_runtime
else
if [ "$CLEAN" -eq 1 ]; then
rm -rf "$RUNTIME_DIR"
fi
sync_runtime
echo "Bundled ${RUNTIME_DIR#$REPO_ROOT/}"
fi
@@ -1,115 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
MODE="write"
CLEAN=0
PACKAGE_DIR="$REPO_ROOT/packages/cadpy_metadata"
RUNTIME_DIR="$REPO_ROOT/skills/srdf/scripts/packages/cadpy_metadata"
usage() {
cat <<'EOF'
Usage:
scripts/bundle/bundle-skill.sh srdf [--check] [--clean]
Vendors packages/cadpy_metadata into skills/srdf/scripts/packages/cadpy_metadata.
Options:
--check Fail if the generated SRDF skill runtime copy is stale.
--clean Remove the generated runtime copy before writing it.
-h, --help
Show this help.
EOF
}
while [ "$#" -gt 0 ]; do
case "$1" in
--check)
MODE="check"
;;
--clean)
CLEAN=1
;;
-h|--help)
usage
exit 0
;;
*)
echo "Unknown argument: $1" >&2
usage >&2
exit 2
;;
esac
shift
done
if [ ! -f "$PACKAGE_DIR/pyproject.toml" ] || [ ! -d "$PACKAGE_DIR/src/cadpy_metadata" ]; then
echo "Missing cadpy_metadata package source: $PACKAGE_DIR" >&2
exit 1
fi
if ! command -v rsync >/dev/null 2>&1; then
echo "rsync is required to vendor cadpy_metadata into the SRDF skill runtime." >&2
exit 1
fi
sync_runtime() {
rm -rf "$RUNTIME_DIR"
mkdir -p "$RUNTIME_DIR"
rsync -a --delete \
--delete-excluded \
--exclude __pycache__ \
--exclude .pytest_cache \
--exclude '*.pyc' \
--exclude '*.egg-info' \
--exclude '*.md' \
--exclude build \
--exclude dist \
--exclude tests \
--exclude __tests__ \
--exclude 'test_*.py' \
--exclude '*_test.py' \
"$PACKAGE_DIR/" "$RUNTIME_DIR/"
}
check_runtime() {
local label="${RUNTIME_DIR#$REPO_ROOT/}"
local diff_path="${TMPDIR:-/tmp}/srdf-skill-cadpy-metadata-diff.txt"
if [ ! -d "$RUNTIME_DIR" ]; then
echo "Missing generated cadpy_metadata runtime: $label" >&2
echo "Run scripts/bundle/bundle-skill.sh srdf and commit the generated copy." >&2
exit 1
fi
if ! diff -qr \
-x __pycache__ \
-x .pytest_cache \
-x '*.pyc' \
-x '*.egg-info' \
-x '*.md' \
-x build \
-x dist \
-x tests \
-x __tests__ \
-x 'test_*.py' \
-x '*_test.py' \
"$PACKAGE_DIR" "$RUNTIME_DIR" >"$diff_path"; then
cat "$diff_path" >&2
echo "" >&2
echo "Stale generated cadpy_metadata runtime: $label" >&2
echo "Run scripts/bundle/bundle-skill.sh srdf and commit the generated copy." >&2
exit 1
fi
echo "$label is up to date."
}
if [ "$MODE" = "check" ]; then
check_runtime
else
if [ "$CLEAN" -eq 1 ]; then
rm -rf "$RUNTIME_DIR"
fi
sync_runtime
echo "Bundled ${RUNTIME_DIR#$REPO_ROOT/}"
fi
@@ -1,115 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
MODE="write"
CLEAN=0
PACKAGE_DIR="$REPO_ROOT/packages/cadpy_metadata"
RUNTIME_DIR="$REPO_ROOT/skills/urdf/scripts/packages/cadpy_metadata"
usage() {
cat <<'EOF'
Usage:
scripts/bundle/bundle-skill.sh urdf [--check] [--clean]
Vendors packages/cadpy_metadata into skills/urdf/scripts/packages/cadpy_metadata.
Options:
--check Fail if the generated URDF skill runtime copy is stale.
--clean Remove the generated runtime copy before writing it.
-h, --help
Show this help.
EOF
}
while [ "$#" -gt 0 ]; do
case "$1" in
--check)
MODE="check"
;;
--clean)
CLEAN=1
;;
-h|--help)
usage
exit 0
;;
*)
echo "Unknown argument: $1" >&2
usage >&2
exit 2
;;
esac
shift
done
if [ ! -f "$PACKAGE_DIR/pyproject.toml" ] || [ ! -d "$PACKAGE_DIR/src/cadpy_metadata" ]; then
echo "Missing cadpy_metadata package source: $PACKAGE_DIR" >&2
exit 1
fi
if ! command -v rsync >/dev/null 2>&1; then
echo "rsync is required to vendor cadpy_metadata into the URDF skill runtime." >&2
exit 1
fi
sync_runtime() {
rm -rf "$RUNTIME_DIR"
mkdir -p "$RUNTIME_DIR"
rsync -a --delete \
--delete-excluded \
--exclude __pycache__ \
--exclude .pytest_cache \
--exclude '*.pyc' \
--exclude '*.egg-info' \
--exclude '*.md' \
--exclude build \
--exclude dist \
--exclude tests \
--exclude __tests__ \
--exclude 'test_*.py' \
--exclude '*_test.py' \
"$PACKAGE_DIR/" "$RUNTIME_DIR/"
}
check_runtime() {
local label="${RUNTIME_DIR#$REPO_ROOT/}"
local diff_path="${TMPDIR:-/tmp}/urdf-skill-cadpy-metadata-diff.txt"
if [ ! -d "$RUNTIME_DIR" ]; then
echo "Missing generated cadpy_metadata runtime: $label" >&2
echo "Run scripts/bundle/bundle-skill.sh urdf and commit the generated copy." >&2
exit 1
fi
if ! diff -qr \
-x __pycache__ \
-x .pytest_cache \
-x '*.pyc' \
-x '*.egg-info' \
-x '*.md' \
-x build \
-x dist \
-x tests \
-x __tests__ \
-x 'test_*.py' \
-x '*_test.py' \
"$PACKAGE_DIR" "$RUNTIME_DIR" >"$diff_path"; then
cat "$diff_path" >&2
echo "" >&2
echo "Stale generated cadpy_metadata runtime: $label" >&2
echo "Run scripts/bundle/bundle-skill.sh urdf and commit the generated copy." >&2
exit 1
fi
echo "$label is up to date."
}
if [ "$MODE" = "check" ]; then
check_runtime
else
if [ "$CLEAN" -eq 1 ]; then
rm -rf "$RUNTIME_DIR"
fi
sync_runtime
echo "Bundled ${RUNTIME_DIR#$REPO_ROOT/}"
fi