first commit

This commit is contained in:
2026-07-22 13:48:46 +08:00
commit c87751c3dc
2820 changed files with 726976 additions and 0 deletions
+340
View File
@@ -0,0 +1,340 @@
#!/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
SOURCE_SKILLS_ROOT="$REPO_ROOT/skills"
PLUGIN_ROOT="$REPO_ROOT/plugins/cad"
TARGET_SKILLS_ROOT="$PLUGIN_ROOT/skills"
CHECK_DIR="${PLUGIN_BUNDLE_CHECK_DIR:-${PLUGIN_BUILD_CHECK_DIR:-$REPO_ROOT/tmp/plugin-cad-check}}"
LIST_SKILLS_SCRIPT="$REPO_ROOT/scripts/utils/list-skills.sh"
PYTHON_BIN="${PYTHON_BIN:-python3}"
usage() {
cat <<'EOF'
Usage:
scripts/bundle/bundle-plugin.sh [--check] [--clean]
Bundles the installable cad plugin package by copying the root skills/
sources into plugins/cad/skills. The plugin package must not contain symlinks
because provider installers cache plugin roots independently of this checkout.
Options:
--check Bundle into tmp/ and fail if plugin outputs or metadata are stale.
--clean Remove temporary bundle/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
ensure_deps() {
if ! command -v rsync >/dev/null 2>&1; then
echo "rsync is required to bundle plugin skill copies." >&2
exit 1
fi
if [ ! -d "$SOURCE_SKILLS_ROOT" ]; then
echo "Missing source skills directory: $SOURCE_SKILLS_ROOT" >&2
exit 1
fi
if [ ! -d "$PLUGIN_ROOT" ]; then
echo "Missing plugin directory: $PLUGIN_ROOT" >&2
exit 1
fi
if [ ! -x "$LIST_SKILLS_SCRIPT" ]; then
echo "Missing skill list script: $LIST_SKILLS_SCRIPT" >&2
exit 1
fi
}
list_skills() {
"$LIST_SKILLS_SCRIPT"
}
assert_no_symlinks() {
local target_dir="$1"
local first_link
first_link="$(find "$target_dir" -type l -print -quit)"
if [ -n "$first_link" ]; then
echo "Plugin skill copy contains a symlink: $first_link" >&2
echo "Run scripts/bundle/bundle-plugin.sh to bundle plugin skill copies." >&2
exit 1
fi
}
sync_skills() {
local target_root="$1"
local skill
rm -rf "$target_root"
mkdir -p "$target_root"
while IFS= read -r skill; do
local source_dir="$SOURCE_SKILLS_ROOT/$skill"
local target_dir="$target_root/$skill"
if [ ! -d "$source_dir" ]; then
echo "Missing source skill directory: skills/$skill" >&2
exit 1
fi
if [ ! -f "$source_dir/SKILL.md" ]; then
echo "Missing source skill manifest: skills/$skill/SKILL.md" >&2
exit 1
fi
mkdir -p "$target_dir"
rsync -aL --delete \
--delete-excluded \
--exclude __pycache__ \
--exclude .pytest_cache \
--exclude node_modules \
--exclude '*.pyc' \
--exclude tests \
--exclude __tests__ \
--exclude 'test_*.py' \
--exclude '*_test.py' \
--exclude '*.test.js' \
--exclude '*.test.mjs' \
--exclude '*.test.ts' \
--exclude '*.test.tsx' \
--exclude '*.spec.js' \
--exclude '*.spec.mjs' \
--exclude '*.spec.ts' \
--exclude '*.spec.tsx' \
"$source_dir/" "$target_dir/"
done < <(list_skills)
assert_no_symlinks "$target_root"
}
check_skill_names() {
local target_root="$1"
local expected actual
expected="$(list_skills)"
actual="$(find "$target_root" -maxdepth 1 -mindepth 1 -type d -exec basename {} \; | sort)"
if [ "$actual" != "$expected" ]; then
echo "Plugin skill list is stale." >&2
echo "Expected:" >&2
printf '%s\n' "$expected" >&2
echo "Actual:" >&2
printf '%s\n' "$actual" >&2
exit 1
fi
}
check_skills() {
local check_skills_root="$CHECK_DIR/skills"
local first_link
if [ ! -d "$TARGET_SKILLS_ROOT" ]; then
echo "Missing generated plugin skill copy: plugins/cad/skills" >&2
echo "Run scripts/bundle/bundle-plugin.sh and commit plugins/cad/skills." >&2
exit 1
fi
first_link="$(find "$TARGET_SKILLS_ROOT" -type l -print -quit)"
if [ -n "$first_link" ]; then
"$REPO_ROOT/scripts/dev/setup-plugin-symlink.sh" --check
echo "Plugin skill copy is in development symlink layout; production copy freshness is checked on build-test/main."
return
fi
assert_no_symlinks "$TARGET_SKILLS_ROOT"
check_skill_names "$TARGET_SKILLS_ROOT"
if ! diff -qr \
-x __pycache__ \
-x .pytest_cache \
-x '*.pyc' \
"$check_skills_root" "$TARGET_SKILLS_ROOT" >/tmp/plugin-cad-skills-diff.txt; then
cat /tmp/plugin-cad-skills-diff.txt >&2
echo "" >&2
echo "Plugin skill copy is stale." >&2
echo "Run scripts/bundle/bundle-plugin.sh and commit plugins/cad/skills." >&2
exit 1
fi
echo "Plugin skill copy is up to date."
}
validate_plugin() {
"$PYTHON_BIN" - "$REPO_ROOT" <<'PY'
from __future__ import annotations
import json
import sys
from pathlib import Path
repo_root = Path(sys.argv[1])
plugin_name = "cad"
skills = sorted(
path.name
for path in (repo_root / "skills").iterdir()
if path.is_dir() and (path / "SKILL.md").is_file()
)
plugin_root = repo_root / "plugins" / plugin_name
codex_manifest_path = plugin_root / ".codex-plugin" / "plugin.json"
claude_manifest_path = plugin_root / ".claude-plugin" / "plugin.json"
claude_marketplace_path = repo_root / ".claude-plugin" / "marketplace.json"
codex_marketplace_path = repo_root / ".codex-plugin" / "marketplace.json"
version_path = plugin_root / "VERSION"
errors: list[str] = []
def require(condition: bool, message: str) -> None:
if not condition:
errors.append(message)
require(plugin_root.is_dir(), f"missing plugin directory: {plugin_root}")
require(codex_manifest_path.is_file(), f"missing Codex plugin manifest: {codex_manifest_path}")
require(claude_manifest_path.is_file(), f"missing Claude plugin manifest: {claude_manifest_path}")
require(claude_marketplace_path.is_file(), f"missing Claude marketplace: {claude_marketplace_path}")
require(codex_marketplace_path.is_file(), f"missing Codex marketplace: {codex_marketplace_path}")
require(version_path.is_file(), f"missing plugin version file: {version_path}")
def load_json_object(path: Path) -> dict[str, object]:
if not path.is_file():
return {}
try:
payload = json.loads(path.read_text(encoding="utf-8"))
except json.JSONDecodeError as exc:
errors.append(f"invalid JSON in {path}: {exc}")
return {}
if not isinstance(payload, dict):
errors.append(f"{path} must contain a JSON object")
return {}
return payload
def plugin_version() -> str:
if not version_path.is_file():
return ""
return version_path.read_text(encoding="utf-8").strip()
version = plugin_version()
def validate_plugin_manifest(path: Path, provider: str) -> None:
manifest = load_json_object(path)
if not manifest:
return
require(manifest.get("name") == plugin_name, f"{provider} plugin manifest name is stale")
require(manifest.get("version") == version, f"{provider} plugin manifest version is stale")
require(manifest.get("skills") in {"./skills/", "./skills", "skills"}, f"{provider} plugin manifest must point at ./skills/")
validate_plugin_manifest(codex_manifest_path, "Codex")
validate_plugin_manifest(claude_manifest_path, "Claude")
codex_marketplace = load_json_object(codex_marketplace_path)
if codex_marketplace:
require(codex_marketplace.get("name") == "text-to-cad", "Codex marketplace name is stale")
plugins = codex_marketplace.get("plugins")
if not isinstance(plugins, list):
errors.append("Codex marketplace plugins must be an array")
else:
cad_entries = [
entry for entry in plugins
if isinstance(entry, dict) and entry.get("name") == plugin_name
]
require(len(cad_entries) == 1, "Codex marketplace must contain exactly one cad plugin entry")
if cad_entries:
source = cad_entries[0].get("source")
if not isinstance(source, dict):
errors.append("Codex marketplace cad source must be an object")
else:
require(source.get("path") == "./plugins/cad", "Codex marketplace cad source path is stale")
claude_marketplace = load_json_object(claude_marketplace_path)
if claude_marketplace:
require(claude_marketplace.get("name") == "text-to-cad", "Claude marketplace name is stale")
require(claude_marketplace.get("version") == version, "Claude marketplace version is stale")
plugins = claude_marketplace.get("plugins")
if not isinstance(plugins, list):
errors.append("Claude marketplace plugins must be an array")
else:
cad_entries = [
entry for entry in plugins
if isinstance(entry, dict) and entry.get("name") == plugin_name
]
require(len(cad_entries) == 1, "Claude marketplace must contain exactly one cad plugin entry")
if cad_entries:
entry = cad_entries[0]
require(entry.get("source") == "./plugins/cad", "Claude marketplace cad source is stale")
require(entry.get("version") == version, "Claude marketplace cad version is stale")
skills_root = plugin_root / "skills"
for skill in skills:
root_skill = repo_root / "skills" / skill
bundled_skill = skills_root / skill
require(root_skill.is_dir(), f"missing source skill: {root_skill}")
require((root_skill / "SKILL.md").is_file(), f"missing source skill manifest: {root_skill / 'SKILL.md'}")
require(bundled_skill.is_dir(), f"plugin skill copy must be a directory: {bundled_skill}")
if bundled_skill.is_symlink():
require(
bundled_skill.resolve() == root_skill.resolve(),
f"plugin development symlink points at the wrong skill: {bundled_skill}",
)
require((bundled_skill / "SKILL.md").is_file(), f"missing plugin skill manifest: {bundled_skill / 'SKILL.md'}")
if skills_root.is_dir():
for path in skills_root.rglob("*"):
if path.is_symlink():
if path.parent != skills_root:
errors.append(f"plugin skill copy must not contain nested symlinks: {path}")
if skills_root.is_dir():
bundled_names = sorted(path.name for path in skills_root.iterdir() if not path.name.startswith("."))
require(bundled_names == skills, f"cad plugin bundled skill list is stale: {bundled_names}")
if errors:
print("Plugin validation failed:")
for error in errors:
print(f"- {error}")
raise SystemExit(1)
print(f"Plugin validation passed: {plugin_root}")
PY
}
ensure_deps
if [ "$CLEAN" -eq 1 ]; then
rm -rf "$CHECK_DIR"
fi
if [ "$MODE" = "check" ]; then
sync_skills "$CHECK_DIR/skills"
check_skills
validate_plugin
else
sync_skills "$TARGET_SKILLS_ROOT"
echo "Bundled plugins/cad/skills"
fi
+81
View File
@@ -0,0 +1,81 @@
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
SKILL_BUNDLE_DIR="$SCRIPT_DIR/skills"
usage() {
cat <<'EOF'
Usage:
scripts/bundle/bundle-skill.sh <skill-id> [skill-bundle-args...]
scripts/bundle/bundle-skill.sh --all [shared-skill-bundle-args...]
Runs bundle logic for one skill. Skill IDs map to
scripts/bundle/skills/bundle-<skill-id>.sh.
Options:
--all Run every skill bundle script under scripts/bundle/skills.
-h, --help Show this help.
Skill-specific arguments are passed through to the selected bundle script.
If a skill has no bundle script, this command fails.
EOF
}
list_bundleable_skills() {
find "$SKILL_BUNDLE_DIR" -maxdepth 1 -type f -name 'bundle-*.sh' -print |
while IFS= read -r script; do
basename "$script" | sed -e 's/^bundle-//' -e 's/\.sh$//'
done |
LC_ALL=C sort
}
run_skill_bundle() {
local skill_id="$1"
shift
local bundle_script="$SKILL_BUNDLE_DIR/bundle-$skill_id.sh"
if [ ! -f "$REPO_ROOT/skills/$skill_id/SKILL.md" ]; then
echo "Unknown skill: $skill_id" >&2
echo "Known skills:" >&2
"$REPO_ROOT/scripts/utils/list-skills.sh" | sed 's/^/- /' >&2
exit 1
fi
if [ ! -x "$bundle_script" ]; then
echo "Skill has no bundle logic: $skill_id" >&2
echo "Expected bundle script: ${bundle_script#$REPO_ROOT/}" >&2
exit 1
fi
"$bundle_script" "$@"
}
if [ "$#" -eq 0 ]; then
usage >&2
exit 2
fi
case "$1" in
-h|--help)
usage
exit 0
;;
--all)
shift
while IFS= read -r skill_id; do
run_skill_bundle "$skill_id" "$@"
done < <(list_bundleable_skills)
;;
-*)
echo "Unknown option: $1" >&2
usage >&2
exit 2
;;
*)
skill_id="$1"
shift
run_skill_bundle "$skill_id" "$@"
;;
esac
+85
View File
@@ -0,0 +1,85 @@
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
MODE="write"
SKILL_ARGS=()
PLUGIN_ARGS=()
usage() {
cat <<'EOF'
Usage:
scripts/bundle/bundle.sh [--check] [--clean]
Universal generated-runtime and plugin package bundle wrapper.
Options:
--check Bundle into tmp/ and fail if checked-in outputs are stale.
--clean Remove temporary bundle/check directories first.
-h, --help Show this help.
EOF
}
while [ "$#" -gt 0 ]; do
case "$1" in
--check)
MODE="check"
SKILL_ARGS+=("--check")
PLUGIN_ARGS+=("--check")
;;
--clean)
SKILL_ARGS+=("--clean")
PLUGIN_ARGS+=("--clean")
;;
-h|--help)
usage
exit 0
;;
*)
echo "Unknown argument: $1" >&2
usage >&2
exit 2
;;
esac
shift
done
cd "$REPO_ROOT"
if [ "$MODE" = "check" ]; then
echo "Checking derived version metadata..."
node "$REPO_ROOT/scripts/release/sync-version.mjs" --check
else
echo "Syncing derived version metadata..."
node "$REPO_ROOT/scripts/release/sync-version.mjs"
fi
if [ "$MODE" = "check" ]; then
echo "Checking bundle-capable skill outputs..."
else
echo "Bundling skill outputs..."
fi
if [ "${#SKILL_ARGS[@]}" -gt 0 ]; then
"$SCRIPT_DIR/bundle-skill.sh" --all "${SKILL_ARGS[@]}"
else
"$SCRIPT_DIR/bundle-skill.sh" --all
fi
if [ "$MODE" = "check" ]; then
echo "Checking plugin package skill copy..."
else
echo "Bundling plugin package skill copy..."
fi
if [ "${#PLUGIN_ARGS[@]}" -gt 0 ]; then
"$SCRIPT_DIR/bundle-plugin.sh" "${PLUGIN_ARGS[@]}"
else
"$SCRIPT_DIR/bundle-plugin.sh"
fi
if [ "$MODE" = "check" ]; then
echo "All bundle outputs are up to date."
else
echo "Bundled all production outputs."
fi
+513
View File
@@ -0,0 +1,513 @@
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
MODE="write"
BUILD=1
CLEAN=0
CADJS_PACKAGE_DIR="$REPO_ROOT/packages/cadjs"
CADPY_PACKAGE_DIR="$REPO_ROOT/packages/cadpy"
IMPLICITJS_PACKAGE_DIR="$REPO_ROOT/packages/implicitjs"
VIEWER_DIR="$REPO_ROOT/viewer"
VIEWER_CADJS_DIR="$VIEWER_DIR/packages/cadjs"
VIEWER_CADPY_DIR="$VIEWER_DIR/packages/cadpy"
VIEWER_IMPLICITJS_DIR="$VIEWER_DIR/packages/implicitjs"
RUNTIME_DIR="$REPO_ROOT/skills/cad-viewer/scripts/viewer"
CHECK_DIR="${CAD_VIEWER_RUNTIME_CHECK_DIR:-${RENDER_VIEWER_RUNTIME_CHECK_DIR:-$REPO_ROOT/tmp/cad-viewer-runtime-check}}"
VIEWER_PACKAGE_MANAGER="${CAD_VIEWER_PACKAGE_MANAGER:-}"
ESBUILD_BIN="${CAD_VIEWER_ESBUILD_BIN:-}"
RELEASE_VERSION="$(tr -d '[:space:]' < "$REPO_ROOT/plugins/cad/VERSION")"
usage() {
cat <<'EOF'
Usage:
scripts/bundle/bundle-skill.sh cad-viewer [--check] [--clean] [--no-build]
Bundles the viewer-local package copies and the self-contained production CAD
Viewer runtime used by skills/cad-viewer. Client sourcemaps are included so
installed skill runtimes can be debugged from browser DevTools.
Options:
--check Bundle into tmp/ and fail if viewer package copies or
skills/cad-viewer/scripts/viewer are stale.
--clean Remove generated package copies and temporary check directories first.
--no-build Reuse the current viewer/dist instead of rebuilding the viewer.
The existing dist must already include client sourcemaps.
-h, --help Show this help.
EOF
}
while [ "$#" -gt 0 ]; do
case "$1" in
--check)
MODE="check"
;;
--clean)
CLEAN=1
;;
--no-build)
BUILD=0
;;
-h|--help)
usage
exit 0
;;
*)
echo "Unknown argument: $1" >&2
usage >&2
exit 2
;;
esac
shift
done
require_path() {
local path_to_check="$1"
local label="$2"
if [ ! -e "$path_to_check" ]; then
echo "Missing $label: $path_to_check" >&2
exit 1
fi
}
require_command() {
if ! command -v "$1" >/dev/null 2>&1; then
echo "$1 is required to build the CAD Viewer runtime." >&2
exit 1
fi
}
resolve_viewer_package_manager() {
if [ -n "$VIEWER_PACKAGE_MANAGER" ]; then
echo "$VIEWER_PACKAGE_MANAGER"
return
fi
if command -v pnpm >/dev/null 2>&1; then
echo "pnpm"
return
fi
echo "npm"
}
run_viewer_build() {
local package_manager
package_manager="$(resolve_viewer_package_manager)"
require_command "$package_manager"
case "$package_manager" in
pnpm)
CI=true pnpm --dir "$VIEWER_DIR" run build --sourcemap true
;;
npm)
npm --prefix "$VIEWER_DIR" run build -- --sourcemap true
;;
*)
echo "Unsupported CAD Viewer package manager: $package_manager" >&2
echo "Set CAD_VIEWER_PACKAGE_MANAGER to pnpm or npm." >&2
exit 1
;;
esac
}
resolve_esbuild_bin() {
if [ -n "$ESBUILD_BIN" ]; then
echo "$ESBUILD_BIN"
return
fi
if [ -x "$VIEWER_DIR/node_modules/.bin/esbuild" ]; then
echo "$VIEWER_DIR/node_modules/.bin/esbuild"
return
fi
local pnpm_esbuild_bin
pnpm_esbuild_bin="$(find "$VIEWER_DIR/node_modules/.pnpm" -path '*/node_modules/esbuild/bin/esbuild' -type f -perm -111 -print -quit 2>/dev/null || true)"
if [ -n "$pnpm_esbuild_bin" ]; then
echo "$pnpm_esbuild_bin"
return
fi
echo "$VIEWER_DIR/node_modules/.bin/esbuild"
}
require_client_sourcemaps() {
local dist_dir="$1"
local map_count
if [ ! -d "$dist_dir/assets" ]; then
echo "Missing Viewer dist assets directory: $dist_dir/assets" >&2
exit 1
fi
map_count="$(find "$dist_dir/assets" -type f -name '*.map' | wc -l | tr -d '[:space:]')"
if [ "$map_count" -eq 0 ]; then
echo "Missing Viewer client sourcemaps in $dist_dir/assets." >&2
echo "Run scripts/bundle/bundle-skill.sh cad-viewer without --no-build to regenerate viewer/dist with sourcemaps." >&2
exit 1
fi
}
sync_cadjs_package() {
local target_dir="${1:-$VIEWER_CADJS_DIR}"
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 /common \
--exclude /lib \
--exclude .DS_Store \
--exclude tests \
--exclude __tests__ \
--exclude '*.test.js' \
--exclude '*.test.mjs' \
--exclude '*.test.ts' \
--exclude '*.test.tsx' \
--exclude '*.spec.js' \
--exclude '*.spec.mjs' \
--exclude '*.spec.ts' \
--exclude '*.spec.tsx' \
"$CADJS_PACKAGE_DIR/" "$target_dir/"
}
sync_implicitjs_package() {
local target_dir="${1:-$VIEWER_IMPLICITJS_DIR}"
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/"
}
sync_cadpy_package() {
local source_dir="$1"
local target_dir="$2"
rm -rf "$target_dir"
mkdir -p "$target_dir"
rsync -a --delete \
--prune-empty-dirs \
--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' \
"$source_dir/" "$target_dir/"
}
check_cadjs_package() {
local label="${VIEWER_CADJS_DIR#$REPO_ROOT/}"
local diff_path="${TMPDIR:-/tmp}/viewer-cadjs-package-diff.txt"
local expected_dir="${TMPDIR:-/tmp}/viewer-cadjs-package-check"
if [ ! -d "$VIEWER_CADJS_DIR" ]; then
echo "Missing generated viewer cadjs package: $label" >&2
echo "Run scripts/bundle/bundle-skill.sh cad-viewer and commit the generated copy." >&2
exit 1
fi
rm -rf "$expected_dir"
sync_cadjs_package "$expected_dir"
if ! diff -qr \
-x node_modules \
-x dist \
-x coverage \
-x tmp \
-x .vite \
-x .DS_Store \
-x tests \
-x __tests__ \
-x '*.test.js' \
-x '*.test.mjs' \
-x '*.test.ts' \
-x '*.test.tsx' \
-x '*.spec.js' \
-x '*.spec.mjs' \
-x '*.spec.ts' \
-x '*.spec.tsx' \
"$expected_dir" "$VIEWER_CADJS_DIR" >"$diff_path"; then
cat "$diff_path" >&2
echo "" >&2
echo "Viewer cadjs package is stale." >&2
echo "Run scripts/bundle/bundle-skill.sh cad-viewer and commit viewer/packages/cadjs." >&2
exit 1
fi
echo "$label is up to date."
}
check_implicitjs_package() {
local label="${VIEWER_IMPLICITJS_DIR#$REPO_ROOT/}"
local diff_path="${TMPDIR:-/tmp}/viewer-implicitjs-package-diff.txt"
local expected_dir="${TMPDIR:-/tmp}/viewer-implicitjs-package-check"
if [ ! -d "$VIEWER_IMPLICITJS_DIR" ]; then
echo "Missing generated viewer implicitjs package: $label" >&2
echo "Run scripts/bundle/bundle-skill.sh cad-viewer and commit the generated copy." >&2
exit 1
fi
rm -rf "$expected_dir"
sync_implicitjs_package "$expected_dir"
if ! diff -qr \
-x node_modules \
-x dist \
-x coverage \
-x tmp \
-x .vite \
-x .DS_Store \
"$expected_dir" "$VIEWER_IMPLICITJS_DIR" >"$diff_path"; then
cat "$diff_path" >&2
echo "" >&2
echo "Viewer implicitjs package is stale." >&2
echo "Run scripts/bundle/bundle-skill.sh cad-viewer and commit viewer/packages/implicitjs." >&2
exit 1
fi
echo "$label is up to date."
}
check_cadpy_package() {
local label="${VIEWER_CADPY_DIR#$REPO_ROOT/}"
local diff_path="${TMPDIR:-/tmp}/viewer-cadpy-package-diff.txt"
local expected_dir="${TMPDIR:-/tmp}/viewer-cadpy-package-check"
if [ ! -d "$VIEWER_CADPY_DIR" ]; then
echo "Missing generated viewer cadpy package: $label" >&2
echo "Run scripts/bundle/bundle-skill.sh cad-viewer and commit the generated copy." >&2
exit 1
fi
rm -rf "$expected_dir"
sync_cadpy_package "$CADPY_PACKAGE_DIR" "$expected_dir"
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' \
"$expected_dir" "$VIEWER_CADPY_DIR" >"$diff_path"; then
cat "$diff_path" >&2
echo "" >&2
echo "Viewer cadpy package is stale." >&2
echo "Run scripts/bundle/bundle-skill.sh cad-viewer and commit viewer/packages/cadpy." >&2
exit 1
fi
echo "$label is up to date."
}
build_viewer_packages() {
if [ "$CLEAN" -eq 1 ]; then
rm -rf "$VIEWER_CADJS_DIR"
rm -rf "$VIEWER_CADPY_DIR"
rm -rf "$VIEWER_IMPLICITJS_DIR"
fi
sync_cadjs_package
sync_cadpy_package "$CADPY_PACKAGE_DIR" "$VIEWER_CADPY_DIR"
sync_implicitjs_package
echo "Bundled ${VIEWER_CADJS_DIR#$REPO_ROOT/}"
echo "Bundled ${VIEWER_CADPY_DIR#$REPO_ROOT/}"
echo "Bundled ${VIEWER_IMPLICITJS_DIR#$REPO_ROOT/}"
}
ensure_viewer_cadjs_node_module_subpaths() {
local cadjs_node_module="$VIEWER_DIR/node_modules/cadjs"
if [ ! -d "$cadjs_node_module" ]; then
return
fi
if [ -L "$cadjs_node_module" ]; then
return
fi
local subpath
for subpath in common lib; do
if [ -d "$VIEWER_CADJS_DIR/src/$subpath" ] && [ ! -e "$cadjs_node_module/$subpath/stepSidecars.mjs" ] && [ ! -e "$cadjs_node_module/$subpath/pathUtils.mjs" ]; then
rm -rf "$cadjs_node_module/$subpath"
ln -s "$VIEWER_CADJS_DIR/src/$subpath" "$cadjs_node_module/$subpath"
fi
done
}
check_viewer_packages() {
check_cadjs_package
check_cadpy_package
check_implicitjs_package
}
write_runtime_package_json() {
local target_dir="$1"
cat > "$target_dir/package.json" <<EOF
{
"name": "cad-viewer-runtime",
"private": true,
"type": "module",
"version": "$RELEASE_VERSION",
"scripts": {
"serve": "node backend/server.mjs",
"start": "node backend/server.mjs",
"moveit2:setup": "moveit2_server/setup.sh",
"moveit2:check": "moveit2_server/check-moveit2-server.sh",
"moveit2:serve": "moveit2_server/run-moveit2-server.sh"
}
}
EOF
}
write_runtime_gitignore() {
local target_dir="$1"
cat > "$target_dir/.gitignore" <<'EOF'
node_modules
.env
.env.*
!.env.example
!.env.*.example
__pycache__
*.py[cod]
.pytest_cache
tmp
!dist
!dist/**
EOF
}
write_runtime_requirements() {
local target_dir="$1"
cat > "$target_dir/requirements.txt" <<'EOF'
--editable ./packages/cadpy
EOF
}
sync_dir() {
local source_dir="$1"
local target_dir="$2"
mkdir -p "$target_dir"
rsync -a --delete \
--prune-empty-dirs \
--delete-excluded \
--exclude node_modules \
--exclude build \
--exclude dist \
--exclude .vite \
--exclude .pytest_cache \
--exclude __pycache__ \
--exclude '*.pyc' \
--exclude '*.egg-info' \
--exclude '*.md' \
--exclude '*.test.js' \
--exclude '*.test.mjs' \
--exclude '*.test.ts' \
--exclude '*.test.tsx' \
--exclude '*.spec.js' \
--exclude '*.spec.mjs' \
--exclude '*.spec.ts' \
--exclude '*.spec.tsx' \
--exclude tests \
--exclude __tests__ \
--exclude 'test_*.py' \
--exclude '*_test.py' \
"$source_dir/" "$target_dir/"
}
build_runtime() {
local target_dir="$1"
rm -rf "$target_dir"
mkdir -p "$target_dir/backend"
sync_dir "$VIEWER_DIR/dist" "$target_dir/dist"
if [ -d "$VIEWER_DIR/moveit2_server" ]; then
sync_dir "$VIEWER_DIR/moveit2_server" "$target_dir/moveit2_server"
fi
sync_dir "$VIEWER_DIR/packages" "$target_dir/packages"
(
cd "$REPO_ROOT"
"$(resolve_esbuild_bin)" "$VIEWER_DIR/src/server/server.mjs" \
--bundle \
--format=esm \
--platform=node \
--target=node22 \
--main-fields=module,main \
--legal-comments=none \
--outfile="$target_dir/backend/server.mjs"
)
write_runtime_package_json "$target_dir"
write_runtime_gitignore "$target_dir"
write_runtime_requirements "$target_dir"
}
check_runtime() {
if [ -L "$RUNTIME_DIR" ]; then
echo "CAD Viewer runtime is in development symlink layout; production runtime diff is checked on build-test/main."
return
fi
if ! diff -qr \
-x __pycache__ \
-x .pytest_cache \
-x '*.pyc' \
-x '*.egg-info' \
"$CHECK_DIR" "$RUNTIME_DIR" >/tmp/cad-viewer-runtime-diff.txt; then
cat /tmp/cad-viewer-runtime-diff.txt >&2
echo "" >&2
echo "CAD Viewer runtime is stale." >&2
echo "Run scripts/bundle/bundle-skill.sh cad-viewer and commit skills/cad-viewer/scripts/viewer." >&2
exit 1
fi
echo "CAD Viewer runtime is up to date."
}
require_command rsync
require_path "$CADJS_PACKAGE_DIR/package.json" "cadjs package"
require_path "$CADJS_PACKAGE_DIR/src" "cadjs source"
require_path "$CADPY_PACKAGE_DIR/pyproject.toml" "cadpy package"
require_path "$CADPY_PACKAGE_DIR/src/cadpy" "cadpy source"
require_path "$IMPLICITJS_PACKAGE_DIR/package.json" "implicitjs package"
require_path "$IMPLICITJS_PACKAGE_DIR/src" "implicitjs source"
require_path "$VIEWER_DIR/package.json" "viewer package"
require_path "$(resolve_esbuild_bin)" "viewer esbuild binary; install viewer dependencies"
if [ "$MODE" = "check" ]; then
check_viewer_packages
else
build_viewer_packages
fi
require_path "$VIEWER_CADPY_DIR/pyproject.toml" "viewer cadpy package"
require_path "$VIEWER_CADPY_DIR/src/cadpy" "viewer cadpy source"
require_path "$VIEWER_IMPLICITJS_DIR/package.json" "viewer implicitjs package"
require_path "$VIEWER_IMPLICITJS_DIR/src" "viewer implicitjs source"
if [ "$CLEAN" -eq 1 ]; then
rm -rf "$CHECK_DIR"
fi
if [ "$BUILD" -eq 1 ]; then
ensure_viewer_cadjs_node_module_subpaths
run_viewer_build
fi
require_path "$VIEWER_DIR/dist/index.html" "viewer production bundle"
require_client_sourcemaps "$VIEWER_DIR/dist"
if [ "$MODE" = "check" ]; then
build_runtime "$CHECK_DIR"
check_runtime
else
build_runtime "$RUNTIME_DIR"
echo "Bundled skills/cad-viewer/scripts/viewer"
fi
+249
View File
@@ -0,0 +1,249 @@
#!/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
INSTALL_DEPS=1
ESBUILD_VERSION="${CAD_SNAPSHOT_ESBUILD_VERSION:-0.27.7}"
THREE_VERSION="${CAD_SNAPSHOT_THREE_VERSION:-0.160.0}"
GIFENC_VERSION="${CAD_SNAPSHOT_GIFENC_VERSION:-1.0.3}"
BUILD_DEPS_DIR="${CAD_SNAPSHOT_BUILD_DEPS_DIR:-$REPO_ROOT/tmp/cad-snapshot-build}"
CHECK_DIR="${CAD_SNAPSHOT_CHECK_DIR:-$REPO_ROOT/tmp/cad-snapshot-runtime-check}"
RUNTIME_DIR="$REPO_ROOT/skills/cad/scripts/snapshot/runtime"
ENTRYPOINT="$REPO_ROOT/packages/cadjs/src/common/headlessRenderEntry.js"
CADPY_PACKAGE_DIR="$REPO_ROOT/packages/cadpy"
CADPY_RUNTIME_DIR="$REPO_ROOT/skills/cad/scripts/packages/cadpy"
usage() {
cat <<'EOF'
Usage:
scripts/bundle/bundle-skill.sh cad [--check] [--clean] [--no-install]
Bundles the self-contained browser runtime used by skills/cad/scripts/snapshot
and the bundled Python package runtime used by skills/cad/scripts.
Options:
--check Bundle into tmp/ and fail if snapshot/runtime is stale.
--clean Remove the temporary dependency/build directories first.
--no-install Require existing build dependencies in tmp/cad-snapshot-build.
-h, --help Show this help.
EOF
}
while [ "$#" -gt 0 ]; do
case "$1" in
--check)
MODE="check"
;;
--clean)
CLEAN=1
;;
--no-install)
INSTALL_DEPS=0
;;
-h|--help)
usage
exit 0
;;
*)
echo "Unknown argument: $1" >&2
usage >&2
exit 2
;;
esac
shift
done
if [ ! -f "$ENTRYPOINT" ]; then
echo "Missing snapshot render entrypoint: $ENTRYPOINT" >&2
echo "The CAD snapshot runtime is built from the same shared render entrypoint used by CAD Viewer." >&2
exit 1
fi
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 CAD skill Python runtime is bundled from packages/cadpy." >&2
exit 1
fi
if [ "$CLEAN" -eq 1 ]; then
rm -rf "$BUILD_DEPS_DIR" "$CHECK_DIR"
fi
need_install() {
[ -x "$BUILD_DEPS_DIR/node_modules/.bin/esbuild" ] || return 0
node <<EOF || return 0
const deps = {
esbuild: "$ESBUILD_VERSION",
three: "$THREE_VERSION",
gifenc: "$GIFENC_VERSION",
};
for (const [name, expected] of Object.entries(deps)) {
const actual = require("$BUILD_DEPS_DIR/node_modules/" + name + "/package.json").version;
if (actual !== expected) {
process.exit(1);
}
}
EOF
return 1
}
ensure_deps() {
if ! command -v rsync >/dev/null 2>&1; then
echo "rsync is required to build the CAD skill Python runtime." >&2
exit 1
fi
if ! command -v npm >/dev/null 2>&1; then
echo "npm is required to build the CAD snapshot runtime." >&2
exit 1
fi
if ! command -v node >/dev/null 2>&1; then
echo "node is required to build the CAD snapshot runtime." >&2
exit 1
fi
if need_install; then
if [ "$INSTALL_DEPS" -eq 0 ]; then
echo "Missing or stale build dependencies in $BUILD_DEPS_DIR." >&2
echo "Run without --no-install to install them." >&2
exit 1
fi
mkdir -p "$BUILD_DEPS_DIR"
npm install --prefix "$BUILD_DEPS_DIR" --no-audit --no-fund \
--fetch-retries=1 --fetch-timeout=10000 \
"esbuild@$ESBUILD_VERSION" \
"three@$THREE_VERSION" \
"gifenc@$GIFENC_VERSION"
fi
}
write_render_html() {
local target_dir="$1"
cat > "$target_dir/render.html" <<'EOF'
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>CAD snapshot render</title>
<style>
html,
body {
margin: 0;
min-width: 100%;
min-height: 100%;
overflow: hidden;
background: transparent;
}
</style>
</head>
<body>
<script type="module" src="/snapshot-render.js"></script>
</body>
</html>
EOF
}
build_runtime() {
local target_dir="$1"
rm -rf "$target_dir"
mkdir -p "$target_dir"
write_render_html "$target_dir"
"$BUILD_DEPS_DIR/node_modules/.bin/esbuild" "$ENTRYPOINT" \
--bundle \
--format=esm \
--platform=browser \
--target=es2022 \
--main-fields=module,main \
--minify \
--legal-comments=none \
--alias:three="$BUILD_DEPS_DIR/node_modules/three" \
--alias:gifenc="$BUILD_DEPS_DIR/node_modules/gifenc/dist/gifenc.esm.js" \
--outfile="$target_dir/snapshot-render.js"
}
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_runtime() {
local stale=0
for file in render.html snapshot-render.js; do
if [ ! -f "$RUNTIME_DIR/$file" ]; then
echo "Missing generated runtime file: skills/cad/scripts/snapshot/runtime/$file" >&2
stale=1
continue
fi
if ! cmp -s "$CHECK_DIR/$file" "$RUNTIME_DIR/$file"; then
echo "Stale generated runtime file: skills/cad/scripts/snapshot/runtime/$file" >&2
stale=1
fi
done
if [ "$stale" -ne 0 ]; then
echo "" >&2
echo "Run scripts/bundle/bundle-skill.sh cad and commit the updated runtime files." >&2
exit 1
fi
echo "CAD snapshot runtime is up to date."
}
check_cadpy_runtime() {
local check_dir="$CHECK_DIR/packages/cadpy"
if [ ! -d "$CADPY_RUNTIME_DIR" ]; then
echo "Missing generated cadpy runtime: skills/cad/scripts/packages/cadpy" >&2
echo "" >&2
echo "Run scripts/bundle/bundle-skill.sh cad 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/cad-skill-cadpy-runtime-diff.txt; then
cat /tmp/cad-skill-cadpy-runtime-diff.txt >&2
echo "" >&2
echo "CAD skill cadpy runtime is stale." >&2
echo "Run scripts/bundle/bundle-skill.sh cad and commit skills/cad/scripts/packages/cadpy." >&2
exit 1
fi
echo "CAD skill cadpy runtime is up to date."
}
ensure_deps
if [ "$MODE" = "check" ]; then
build_runtime "$CHECK_DIR"
sync_cadpy_runtime "$CHECK_DIR/packages/cadpy"
check_runtime
check_cadpy_runtime
else
build_runtime "$RUNTIME_DIR"
sync_cadpy_runtime "$CADPY_RUNTIME_DIR"
echo "Bundled skills/cad/scripts/snapshot/runtime"
echo "Bundled skills/cad/scripts/packages/cadpy"
fi
+119
View File
@@ -0,0 +1,119 @@
#!/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
@@ -0,0 +1,144 @@
#!/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
+115
View File
@@ -0,0 +1,115 @@
#!/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
+115
View File
@@ -0,0 +1,115 @@
#!/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
+115
View File
@@ -0,0 +1,115 @@
#!/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