mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-04-28 11:59:29 +00:00
Restructure the repo as a Bun workspace monorepo: - Move cli/ → packages/cli/ - Create packages/shared/ (@openrouter/spawn-shared) with type-guards and parse utilities - Add root package.json with workspace configuration - Update all CLI imports to use @openrouter/spawn-shared - Deduplicate toRecord/toObjectArray helpers from 4 cloud modules - Update SPA (slack-bot) to use shared package instead of local toObj() - Update 48 agent shell scripts for new packages/cli/ path - Update install.sh, install.ps1, e2e, and test scripts - Update all GitHub workflows, .gitignore, pre-commit hooks - Update CLAUDE.md, README.md, and skill prompt references - Pin all dependency versions (no ^ ranges) - Bump CLI version 0.9.1 → 0.10.0 All 1908 tests pass. Lint clean. All 8 cloud bundles build. Co-authored-by: Claude <claude@anthropic.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
72 lines
2.6 KiB
Bash
Executable file
72 lines
2.6 KiB
Bash
Executable file
#!/bin/bash
|
|
# Pre-commit hook: validates staged .sh and .ts files
|
|
# Install: git config core.hooksPath .githooks
|
|
|
|
set -eo pipefail
|
|
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
NC='\033[0m'
|
|
|
|
errors=0
|
|
|
|
# ─── Shell script validation ──────────────────────────────────────────
|
|
|
|
staged_sh=$(git diff --cached --name-only --diff-filter=ACM | grep '\.sh$' || true)
|
|
|
|
if [[ -n "$staged_sh" ]]; then
|
|
echo "Validating staged shell scripts..."
|
|
|
|
for file in $staged_sh; do
|
|
# 1. Syntax check
|
|
if ! bash -n "$file" 2>/dev/null; then
|
|
printf "${RED}FAIL${NC} %s: syntax error\n" "$file"
|
|
bash -n "$file" 2>&1 | head -3
|
|
errors=$((errors + 1))
|
|
continue
|
|
fi
|
|
|
|
# 2. No relative source (breaks curl|bash)
|
|
if grep -qn 'source \.\./' "$file" 2>/dev/null || grep -qn 'source \./' "$file" 2>/dev/null; then
|
|
printf "${RED}FAIL${NC} %s: relative source path (breaks curl|bash)\n" "$file"
|
|
grep -n 'source \.\.' "$file" 2>/dev/null || true
|
|
errors=$((errors + 1))
|
|
fi
|
|
|
|
# 3. No echo -e (breaks macOS bash 3.x)
|
|
if grep -qn 'echo -e ' "$file" 2>/dev/null; then
|
|
printf "${RED}FAIL${NC} %s: echo -e (use printf for macOS compat)\n" "$file"
|
|
errors=$((errors + 1))
|
|
fi
|
|
|
|
# 4. No set -u / set -euo (breaks env var checks)
|
|
if grep -qn 'set -euo' "$file" 2>/dev/null; then
|
|
printf "${RED}FAIL${NC} %s: set -euo pipefail (drop the 'u', use set -eo pipefail)\n" "$file"
|
|
errors=$((errors + 1))
|
|
fi
|
|
done
|
|
|
|
if [[ $errors -gt 0 ]]; then
|
|
echo ""
|
|
printf "${RED}%d error(s) found. Commit blocked.${NC}\n" "$errors"
|
|
echo "Fix the issues above and try again."
|
|
exit 1
|
|
fi
|
|
|
|
printf "${GREEN}All %d scripts passed validation.${NC}\n" "$(echo "$staged_sh" | wc -w | tr -d ' ')"
|
|
fi
|
|
|
|
# ─── Biome lint for TypeScript ─────────────────────────────────────────
|
|
|
|
staged_ts=$(git diff --cached --name-only --diff-filter=ACM | grep '^packages/cli/src/.*\.ts$' || true)
|
|
|
|
if [[ -n "$staged_ts" ]]; then
|
|
echo "Running Biome lint on staged TypeScript files..."
|
|
if ! (cd packages/cli && bunx @biomejs/biome lint src/); then
|
|
echo ""
|
|
printf "${RED}Biome lint failed. Commit blocked.${NC}\n"
|
|
echo "Run 'cd packages/cli && bunx @biomejs/biome lint src/' to see details."
|
|
exit 1
|
|
fi
|
|
printf "${GREEN}Biome lint passed.${NC}\n"
|
|
fi
|