1.0.0 release

This commit is contained in:
2026-06-01 18:27:40 -07:00
parent b1ab0f102c
commit 1f20fcab20
1151 changed files with 230703 additions and 14 deletions
+63
View File
@@ -0,0 +1,63 @@
#!/usr/bin/env bash
# Install Lyrebird Xcode file templates.
#
# Copies every .xctemplate under Sources/LyrebirdCLI/Resources/XcodeTemplates/ into
# ~/Library/Developer/Xcode/Templates/File Templates/Lyrebird/
#
# Equivalent to `lyrebird install-templates` once that binary is on PATH.
#
# After install, Xcode's New File dialog (⌘N) shows a "Lyrebird" section with
# the templates listed. No Xcode restart required — Xcode rescans on next ⌘N.
#
# Run from repo root:
# bash scripts/install-xcode-templates.sh
# bash scripts/install-xcode-templates.sh --dry-run # show actions only
#
# Uninstall via scripts/uninstall-xcode-templates.sh.
set -euo pipefail
DRY_RUN=false
case "${1:-}" in
--dry-run|-n) DRY_RUN=true ;;
"") ;;
*) echo "usage: $0 [--dry-run]" >&2; exit 2 ;;
esac
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
SRC="$REPO_ROOT/Sources/LyrebirdCLI/Resources/XcodeTemplates"
DEST="$HOME/Library/Developer/Xcode/Templates/File Templates/Lyrebird"
if [[ ! -d "$SRC" ]]; then
echo "error: source dir not found: $SRC" >&2
exit 1
fi
# Count templates being installed for the summary line.
COUNT=$(find "$SRC" -maxdepth 1 -type d -name "*.xctemplate" | wc -l | tr -d ' ')
if [[ "$COUNT" -eq 0 ]]; then
echo "error: no .xctemplate directories found under $SRC" >&2
exit 1
fi
echo "Installing $COUNT Lyrebird templates"
echo " from: $SRC"
echo " to: $DEST"
if [[ "$DRY_RUN" == "true" ]]; then
echo
echo "(dry-run — no changes made)"
find "$SRC" -maxdepth 1 -type d -name "*.xctemplate" -exec basename {} \; | sort | sed 's/^/ + /'
exit 0
fi
mkdir -p "$DEST"
# rsync with --delete so the destination is a faithful mirror of the repo's
# templates dir — stale templates removed by a `git rm` upstream get cleaned
# up on next install. Trailing slash on $SRC/ copies contents, not the dir.
rsync -a --delete "$SRC/" "$DEST/"
echo
echo "✓ Installed. Open Xcode → File → New → File from Template…"
echo " → scroll to the 'Lyrebird' section."
+137
View File
@@ -0,0 +1,137 @@
#!/usr/bin/env bash
# sync-claude-from-working.sh
#
# Source of truth: ~/.claude/agents/ + ~/.claude/skills/ (the maintainer's
# live working copies). This script mirrors them into the repo so contributors
# cloning Lyrebird get an up-to-date reference snapshot.
#
# Repo destinations:
# .claude/agents/ .claude/skills/ — auto-discovered by Claude Code per-project
# claude/agents/ claude/skills/ — installer source for `claude/install.sh`
# (copies into a contributor's ~/.claude)
#
# Usage:
# bash scripts/sync-claude-from-working.sh # dry-run: show what would change
# bash scripts/sync-claude-from-working.sh --apply # perform copies
# bash scripts/sync-claude-from-working.sh --check # exit 1 if any drift exists (CI)
#
# Behaviour:
# - Only files whose name matches an existing repo entry are copied. New
# agents/skills must be added to the repo by hand the first time, then
# this script will keep them in sync.
# - Files in the repo with no working-copy counterpart are reported as
# "orphan" — script does NOT delete them; investigate manually.
# - Lists every Action: COPY / SAME / MISSING-IN-WORKING / ORPHAN-IN-REPO.
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
SRC_AGENTS="$HOME/.claude/agents"
SRC_SKILLS="$HOME/.claude/skills"
REPO_DIRS=(".claude" "claude")
MODE="dry-run"
for arg in "$@"; do
case "$arg" in
--apply) MODE="apply" ;;
--check) MODE="check" ;;
-h|--help) sed -n '2,25p' "$0" | sed 's/^# \?//'; exit 0 ;;
*) echo "Unknown argument: $arg" >&2; exit 1 ;;
esac
done
if [[ ! -d "$SRC_AGENTS" ]]; then
echo "ERROR: working agents dir not found: $SRC_AGENTS" >&2
exit 1
fi
drift_count=0
copy_count=0
same_count=0
orphan_count=0
missing_count=0
log() { printf " %-26s %s\n" "$1" "$2"; }
sync_file() {
local src="$1" dst="$2"
if [[ ! -f "$src" ]]; then
log "MISSING-IN-WORKING" "$dst (working copy gone — not deleting from repo)"
((missing_count++)) || true
return
fi
if [[ -f "$dst" ]] && cmp -s "$src" "$dst"; then
log "SAME" "$dst"
((same_count++)) || true
return
fi
log "COPY" "$dst"
((copy_count++)) || true
((drift_count++)) || true
if [[ "$MODE" == "apply" ]]; then
mkdir -p "$(dirname "$dst")"
cp "$src" "$dst"
fi
}
for repo_dir in "${REPO_DIRS[@]}"; do
echo ""
echo "=== $repo_dir/agents/ ==="
if [[ -d "$REPO_ROOT/$repo_dir/agents" ]]; then
for repo_file in "$REPO_ROOT/$repo_dir/agents"/*.md; do
[[ -e "$repo_file" ]] || continue
name="$(basename "$repo_file")"
sync_file "$SRC_AGENTS/$name" "$repo_file"
done
# Report working-copy agents that aren't yet in this repo dir.
for src_file in "$SRC_AGENTS"/*.md; do
[[ -e "$src_file" ]] || continue
name="$(basename "$src_file")"
if [[ ! -f "$REPO_ROOT/$repo_dir/agents/$name" ]]; then
log "NEW-IN-WORKING" "$repo_dir/agents/$name (add manually if intended)"
((orphan_count++)) || true
fi
done
fi
echo ""
echo "=== $repo_dir/skills/ ==="
if [[ -d "$REPO_ROOT/$repo_dir/skills" ]]; then
for repo_skill_dir in "$REPO_ROOT/$repo_dir/skills"/*/; do
[[ -d "$repo_skill_dir" ]] || continue
skill_name="$(basename "$repo_skill_dir")"
sync_file "$SRC_SKILLS/$skill_name/skill.md" "$repo_skill_dir/skill.md"
done
for src_skill_dir in "$SRC_SKILLS"/*/; do
[[ -d "$src_skill_dir" ]] || continue
skill_name="$(basename "$src_skill_dir")"
if [[ ! -d "$REPO_ROOT/$repo_dir/skills/$skill_name" ]]; then
log "NEW-IN-WORKING" "$repo_dir/skills/$skill_name (add manually if intended)"
((orphan_count++)) || true
fi
done
fi
done
echo ""
echo "── summary ──────────────────────────────────────────────"
printf " same: %d\n" "$same_count"
printf " copy needed/applied: %d\n" "$copy_count"
printf " new-in-working: %d\n" "$orphan_count"
printf " missing-in-working: %d\n" "$missing_count"
printf " mode: %s\n" "$MODE"
if [[ "$MODE" == "check" ]]; then
if (( drift_count > 0 || orphan_count > 0 )); then
echo ""
echo "DRIFT detected. Run: bash scripts/sync-claude-from-working.sh --apply"
exit 1
fi
echo ""
echo "Repo agent/skill mirror is up to date."
fi
if [[ "$MODE" == "dry-run" && $drift_count -gt 0 ]]; then
echo ""
echo "Dry-run only. To apply: bash scripts/sync-claude-from-working.sh --apply"
fi
+41
View File
@@ -0,0 +1,41 @@
#!/usr/bin/env bash
# Remove Lyrebird Xcode file templates from the user template dir.
#
# Deletes
# ~/Library/Developer/Xcode/Templates/File Templates/Lyrebird/
#
# Run from repo root (or anywhere — script uses absolute home path):
# bash scripts/uninstall-xcode-templates.sh
# bash scripts/uninstall-xcode-templates.sh --dry-run
set -euo pipefail
DRY_RUN=false
case "${1:-}" in
--dry-run|-n) DRY_RUN=true ;;
"") ;;
*) echo "usage: $0 [--dry-run]" >&2; exit 2 ;;
esac
DEST="$HOME/Library/Developer/Xcode/Templates/File Templates/Lyrebird"
if [[ ! -d "$DEST" ]]; then
echo "Nothing to remove. Templates not installed at:"
echo " $DEST"
exit 0
fi
COUNT=$(find "$DEST" -maxdepth 1 -type d -name "*.xctemplate" 2>/dev/null | wc -l | tr -d ' ')
echo "Removing Lyrebird template dir ($COUNT templates):"
echo " $DEST"
if [[ "$DRY_RUN" == "true" ]]; then
echo
echo "(dry-run — no changes made)"
exit 0
fi
rm -rf "$DEST"
echo
echo "✓ Removed."
+240
View File
@@ -0,0 +1,240 @@
#!/usr/bin/env bash
# Validate every .xctemplate under Xcode/Templates/Lyrebird/.
#
# Three modes:
# (default / --quick)
# 1. plutil -lint TemplateInfo.plist — plist syntax + structure
# 2. expand placeholders with Probe — sed-substitute the canonical fields
# 3. swift -frontend -parse — Swift grammar check
#
# --full
# adds:
# 4. drop expanded file into Sources/Lyrebird/Generators/Math/Probe.swift
# 5. swift build — verifies every API reference resolves
# in-tree (sees module-internal helpers + bases). Templates importing
# LyrebirdUI skip this step (LyrebirdUI is a separate module).
# 6. clean up Probe.swift unconditionally — trap on exit
#
# --external
# for every template whose body contains `import Lyrebird` (with or without
# an @_spi attribute), additionally:
# 7. create a temporary SPM package depending on the local Lyrebird path
# (and LyrebirdUI when the template also imports LyrebirdUI)
# 8. swift build that package — proves the template works for users
# who consume Lyrebird as a package
# Templates with no `import Lyrebird` line are skipped here (they are in-tree
# contributor templates and use module-internal symbols by design). Templates
# containing top-level statements or @Suite are skipped too — those compile
# only inside an executableTarget / Test target respectively.
#
# Run from repo root:
# bash scripts/validate-xcode-templates.sh
# bash scripts/validate-xcode-templates.sh --full
# bash scripts/validate-xcode-templates.sh --external
set -euo pipefail
MODE="${1:-quick}"
case "$MODE" in
--full|full) MODE="full" ;;
--external|external) MODE="external" ;;
--quick|quick|"") MODE="quick" ;;
*) echo "usage: $0 [--quick|--full|--external]" >&2; exit 2 ;;
esac
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
TEMPLATES_DIR="$REPO_ROOT/Sources/LyrebirdCLI/Resources/XcodeTemplates"
PROBE_PATH="$REPO_ROOT/Sources/Lyrebird/Generators/Math/Probe.swift"
EXT_DIR="$(mktemp -d -t xctmpl-extprobe)"
if [[ ! -d "$TEMPLATES_DIR" ]]; then
echo "error: $TEMPLATES_DIR not found" >&2
exit 1
fi
cleanup() {
rm -f "$PROBE_PATH"
rm -rf "$EXT_DIR"
}
trap cleanup EXIT
# Rewrite the external-probe Package.swift each time we switch between
# Lyrebird-only and Lyrebird+LyrebirdUI dependency shapes.
write_external_package() {
local extra_deps="$1" # "" or ".product(name: \"LyrebirdUI\", package: \"LyrebirdII\"),"
mkdir -p "$EXT_DIR/Sources/extprobe"
cat > "$EXT_DIR/Package.swift" <<EOF
// swift-tools-version:6.0
import PackageDescription
let package = Package(
name: "extprobe",
platforms: [.macOS(.v15), .iOS(.v18)],
dependencies: [.package(path: "$REPO_ROOT")],
targets: [
.target(
name: "extprobe",
dependencies: [
.product(name: "Lyrebird", package: "LyrebirdII"),
$extra_deps
]
)
]
)
EOF
}
PROBE_NAME="Probe"
FAIL=0
COUNT=0
expand_template() {
local src="$1"
local dst="$2"
local strip_lyrebird_imports="$3"
sed \
-e "s/___FILEBASENAMEASIDENTIFIER___/$PROBE_NAME/g" \
-e "s/___FILEBASENAME___/$PROBE_NAME/g" \
-e "s|//___FILEHEADER___|// $PROBE_NAME.swift|g" \
-e "s/___FULLUSERNAME___/Joe Schmoe/g" \
-e "s/___DATE___/2026-05-13/g" \
-e "s/___YEAR___/2026/g" \
"$src" > "$dst"
if [[ "$strip_lyrebird_imports" == "true" ]]; then
# In-tree compile: the file lives inside the Lyrebird module so any
# `import Lyrebird` (with or without SPI annotation) is a self-import.
sed -i.bak -E '/^@_spi\([^)]*\) import Lyrebird$/d; /^import Lyrebird$/d' "$dst"
rm -f "${dst}.bak"
fi
}
template_imports_lyrebird() {
grep -qE '^(@_spi\([^)]*\) )?(@testable )?(@_spi\([^)]*\) )?import Lyrebird$' "$1"
}
template_imports_lyrebird_ui() {
grep -qE '^import LyrebirdUI$' "$1"
}
# Reject from in-tree compile + external compile when the file has top-level
# code (not inside a class/struct/enum/func) or declares an `@Suite` — those
# compile only inside an executableTarget / Test target respectively.
template_has_top_level_code() {
# Crude heuristic: a non-import top-level `let engine`, `try engine.start`,
# `print(`, or `exit(` outside a block.
grep -qE '^(let|var) [A-Za-z_]+ =|^try engine\.start|^engine\.add|^print\(|^exit\(' "$1"
}
template_is_test_suite() {
grep -qE '^@Suite\b' "$1"
}
while IFS= read -r -d '' template; do
COUNT=$((COUNT + 1))
name="$(basename "$template" .xctemplate)"
echo "── $name"
plist="$template/TemplateInfo.plist"
if [[ ! -f "$plist" ]]; then
echo " FAIL: missing TemplateInfo.plist"
FAIL=$((FAIL + 1))
continue
fi
if ! plutil -lint "$plist" >/dev/null; then
echo " FAIL: plutil -lint $plist"
FAIL=$((FAIL + 1))
continue
fi
main_swift="$template/___FILEBASENAME___.swift"
if [[ ! -f "$main_swift" ]]; then
echo " note: no ___FILEBASENAME___.swift (skipping Swift checks)"
continue
fi
# ── Quick: parse only ─────────────────────────────────────────────────────
tmp_parse="$(mktemp -t xctmpl).swift"
expand_template "$main_swift" "$tmp_parse" false
parse_log="${tmp_parse}.log"
if swift -frontend -parse "$tmp_parse" 2> "$parse_log"; then
lines=$(wc -l < "$tmp_parse" | tr -d ' ')
echo " parse: OK ($lines lines)"
else
echo " FAIL: swift -frontend -parse"
cat "$parse_log"
FAIL=$((FAIL + 1))
rm -f "$tmp_parse" "$parse_log"
continue
fi
rm -f "$tmp_parse" "$parse_log"
# ── Full: compile against Lyrebird in-tree ────────────────────────────────
# Skip in-tree compile for templates that import LyrebirdUI (separate module
# not visible from Sources/Lyrebird/), for test suites (need a Test target),
# and for executable main.swift (need an executableTarget).
if [[ "$MODE" == "full" || "$MODE" == "external" ]]; then
if template_imports_lyrebird_ui "$main_swift"; then
echo " build (in-tree): SKIP (imports LyrebirdUI)"
elif template_is_test_suite "$main_swift"; then
echo " build (in-tree): SKIP (test suite — needs Test target)"
elif template_has_top_level_code "$main_swift"; then
echo " build (in-tree): SKIP (top-level code — needs executableTarget)"
else
expand_template "$main_swift" "$PROBE_PATH" true
build_log="$(mktemp -t xctmpl-build).log"
if (cd "$REPO_ROOT" && swift build) > "$build_log" 2>&1; then
echo " build (in-tree): OK"
else
echo " FAIL: swift build (in-tree)"
tail -40 "$build_log"
FAIL=$((FAIL + 1))
rm -f "$build_log"
rm -f "$PROBE_PATH"
continue
fi
rm -f "$build_log"
rm -f "$PROBE_PATH"
fi
fi
# ── External: compile against Lyrebird as a package dependency ────────────
if [[ "$MODE" == "external" ]]; then
if ! template_imports_lyrebird "$main_swift"; then
echo " build (external): SKIP (in-tree-only template)"
continue
fi
if template_is_test_suite "$main_swift"; then
echo " build (external): SKIP (test suite — needs Test target)"
continue
fi
if template_has_top_level_code "$main_swift"; then
echo " build (external): SKIP (top-level code — needs executableTarget)"
continue
fi
if template_imports_lyrebird_ui "$main_swift"; then
write_external_package '.product(name: "LyrebirdUI", package: "LyrebirdII"),'
else
write_external_package ''
fi
expand_template "$main_swift" "$EXT_DIR/Sources/extprobe/Probe.swift" false
ext_log="$(mktemp -t xctmpl-ext).log"
if (cd "$EXT_DIR" && swift build) > "$ext_log" 2>&1; then
echo " build (external): OK"
else
echo " FAIL: swift build (external)"
tail -60 "$ext_log"
FAIL=$((FAIL + 1))
fi
rm -f "$ext_log"
fi
done < <(find "$TEMPLATES_DIR" -type d -name "*.xctemplate" -print0)
echo
if [[ $FAIL -gt 0 ]]; then
echo "✗ $FAIL of $COUNT templates failed"
exit 1
else
echo "✓ $COUNT templates validated ($MODE)"
fi