Skip to content

Commit 045d1e7

Browse files
Alex J Lennoncursoragent
andcommitted
Merge development: iOS CI/CD, QR config, zero-warnings lint/build
Squashed from development: - iOS CI workflow, SwiftLint, iPhone install docs and scripts - QR code config (Settings + generate-config-qr.py) - Zero warnings: StreamSessionView, GeminiLiveService, OpenClawBridge, GeminiSessionViewModel, AudioManager, SettingsView (extract QR scanner) - CI enforces zero SwiftLint and zero Swift compiler warnings - Docs: quickstart, install from Linux, Windows VM, Scaleway, SwiftLint - Pre-commit hooks and secrets setup scripts Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent e572f5a commit 045d1e7

40 files changed

Lines changed: 6021 additions & 143 deletions

.github/hooks/pre-commit

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/bin/bash
2+
#
3+
# Pre-commit hook for VisionClaw
4+
# Runs SwiftLint on staged Swift files
5+
#
6+
7+
set -e
8+
9+
# Colors for output
10+
RED='\033[0;31m'
11+
GREEN='\033[0;32m'
12+
YELLOW='\033[1;33m'
13+
NC='\033[0m' # No Color
14+
15+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
16+
echo "🔍 Running pre-commit checks..."
17+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
18+
echo ""
19+
20+
# Check if SwiftLint is installed
21+
if ! command -v swiftlint &> /dev/null; then
22+
echo -e "${YELLOW}⚠️ SwiftLint not installed${NC}"
23+
echo ""
24+
echo "Install with: brew install swiftlint"
25+
echo ""
26+
echo "Skipping lint check (install SwiftLint to enable)"
27+
echo ""
28+
exit 0
29+
fi
30+
31+
# Get list of staged Swift files
32+
SWIFT_FILES=$(git diff --cached --name-only --diff-filter=d | grep "\.swift$" | grep -v "samples/CameraAccess/CameraAccessTests" || true)
33+
34+
if [ -z "$SWIFT_FILES" ]; then
35+
echo -e "${GREEN}✅ No Swift files staged for commit${NC}"
36+
echo ""
37+
exit 0
38+
fi
39+
40+
echo "📝 Staged Swift files:"
41+
echo "$SWIFT_FILES" | sed 's/^/ - /'
42+
echo ""
43+
44+
# Run SwiftLint on staged files
45+
echo "🔍 Running SwiftLint..."
46+
echo ""
47+
48+
LINT_ERRORS=0
49+
for file in $SWIFT_FILES; do
50+
if [ -f "$file" ]; then
51+
# Lint the file
52+
if ! swiftlint lint --path "$file" --quiet; then
53+
LINT_ERRORS=$((LINT_ERRORS + 1))
54+
fi
55+
fi
56+
done
57+
58+
echo ""
59+
60+
if [ $LINT_ERRORS -gt 0 ]; then
61+
echo -e "${RED}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
62+
echo -e "${RED}❌ SwiftLint found $LINT_ERRORS issue(s)${NC}"
63+
echo -e "${RED}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
64+
echo ""
65+
echo "Fix the issues above, or:"
66+
echo " • Run 'swiftlint autocorrect' to auto-fix some issues"
67+
echo " • Use 'git commit --no-verify' to bypass (not recommended)"
68+
echo ""
69+
exit 1
70+
fi
71+
72+
echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
73+
echo -e "${GREEN}✅ All pre-commit checks passed!${NC}"
74+
echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
75+
echo ""
76+
77+
exit 0

.github/scripts/install-hooks.sh

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/bin/bash
2+
#
3+
# install-hooks.sh
4+
# Install git hooks for VisionClaw development
5+
#
6+
7+
set -e
8+
9+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
10+
HOOKS_DIR="$SCRIPT_DIR/hooks"
11+
GIT_HOOKS_DIR="$(git rev-parse --git-path hooks 2>/dev/null)"
12+
13+
if [ -z "$GIT_HOOKS_DIR" ]; then
14+
echo "❌ Error: Not in a git repository"
15+
exit 1
16+
fi
17+
18+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
19+
echo "🪝 Installing Git Hooks"
20+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
21+
echo ""
22+
echo "Git hooks directory: $GIT_HOOKS_DIR"
23+
echo ""
24+
25+
# Check if SwiftLint is installed
26+
if ! command -v swiftlint &> /dev/null; then
27+
echo "⚠️ SwiftLint not installed"
28+
echo ""
29+
echo "Pre-commit hook will be installed but will skip linting until SwiftLint is installed."
30+
echo ""
31+
echo "To install SwiftLint:"
32+
echo " brew install swiftlint"
33+
echo ""
34+
read -p "Continue anyway? (y/N): " -n 1 -r
35+
echo ""
36+
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
37+
echo "❌ Installation cancelled"
38+
exit 0
39+
fi
40+
echo ""
41+
fi
42+
43+
# Install pre-commit hook
44+
if [ -f "$HOOKS_DIR/pre-commit" ]; then
45+
if [ -f "$GIT_HOOKS_DIR/pre-commit" ]; then
46+
# Backup existing hook
47+
BACKUP="$GIT_HOOKS_DIR/pre-commit.backup.$(date +%s)"
48+
echo "📦 Backing up existing pre-commit hook to:"
49+
echo " $(basename $BACKUP)"
50+
mv "$GIT_HOOKS_DIR/pre-commit" "$BACKUP"
51+
echo ""
52+
fi
53+
54+
cp "$HOOKS_DIR/pre-commit" "$GIT_HOOKS_DIR/pre-commit"
55+
chmod +x "$GIT_HOOKS_DIR/pre-commit"
56+
echo "✅ Installed pre-commit hook"
57+
else
58+
echo "❌ Error: pre-commit hook not found at $HOOKS_DIR/pre-commit"
59+
exit 1
60+
fi
61+
62+
echo ""
63+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
64+
echo "✅ Git hooks installed successfully!"
65+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
66+
echo ""
67+
echo "The pre-commit hook will now:"
68+
echo " • Run SwiftLint on staged Swift files"
69+
echo " • Block commits if linting fails"
70+
echo " • Keep your code clean and consistent"
71+
echo ""
72+
echo "To bypass the hook (not recommended):"
73+
echo " git commit --no-verify"
74+
echo ""
75+
echo "To uninstall:"
76+
echo " rm $GIT_HOOKS_DIR/pre-commit"
77+
echo ""

.github/scripts/setup-secrets.sh

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
#!/bin/bash
2+
#
3+
# setup-secrets.sh
4+
# Helper script to create Secrets.swift from template
5+
#
6+
7+
set -e
8+
9+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
10+
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
11+
SECRETS_DIR="$PROJECT_ROOT/samples/CameraAccess/CameraAccess"
12+
TEMPLATE="$SECRETS_DIR/Secrets.swift.template"
13+
SECRETS="$SECRETS_DIR/Secrets.swift"
14+
15+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
16+
echo "🔐 VisionClaw Secrets Configuration Setup"
17+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
18+
echo ""
19+
20+
# Check if Secrets.swift already exists
21+
if [ -f "$SECRETS" ]; then
22+
echo "⚠️ Secrets.swift already exists at:"
23+
echo " $SECRETS"
24+
echo ""
25+
read -p "Do you want to overwrite it? (y/N): " -n 1 -r
26+
echo ""
27+
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
28+
echo "❌ Setup cancelled. Existing Secrets.swift preserved."
29+
exit 0
30+
fi
31+
fi
32+
33+
# Copy template to Secrets.swift
34+
if [ ! -f "$TEMPLATE" ]; then
35+
echo "❌ Error: Template not found at:"
36+
echo " $TEMPLATE"
37+
exit 1
38+
fi
39+
40+
cp "$TEMPLATE" "$SECRETS"
41+
echo "✅ Created Secrets.swift from template"
42+
echo ""
43+
44+
# Prompt for Gemini API key
45+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
46+
echo "📝 Configuration"
47+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
48+
echo ""
49+
echo "1. Gemini API Key (required)"
50+
echo " Get yours at: https://aistudio.google.com/apikey"
51+
echo ""
52+
read -p "Enter your Gemini API key (or press Enter to skip): " GEMINI_KEY
53+
54+
if [ -n "$GEMINI_KEY" ]; then
55+
# Escape special characters for sed
56+
GEMINI_KEY_ESCAPED=$(printf '%s\n' "$GEMINI_KEY" | sed 's/[[\.*^$/]/\\&/g')
57+
sed -i "s/YOUR_GEMINI_API_KEY/$GEMINI_KEY_ESCAPED/g" "$SECRETS"
58+
echo "✅ Gemini API key configured"
59+
else
60+
echo "⏭️ Skipped Gemini API key (you can edit Secrets.swift manually later)"
61+
fi
62+
63+
echo ""
64+
echo "2. OpenClaw Configuration (optional)"
65+
echo " Only needed if you want agentic actions (send messages, search web, etc.)"
66+
echo ""
67+
read -p "Configure OpenClaw now? (y/N): " -n 1 -r
68+
echo ""
69+
70+
if [[ $REPLY =~ ^[Yy]$ ]]; then
71+
read -p "OpenClaw host (e.g., http://192.168.1.100): " OPENCLAW_HOST
72+
read -p "OpenClaw port (default 18789): " OPENCLAW_PORT
73+
read -p "OpenClaw gateway token: " OPENCLAW_TOKEN
74+
75+
if [ -n "$OPENCLAW_HOST" ]; then
76+
sed -i "s|http://YOUR_MAC_HOSTNAME.local|$OPENCLAW_HOST|g" "$SECRETS"
77+
echo "✅ OpenClaw host configured"
78+
fi
79+
80+
if [ -n "$OPENCLAW_PORT" ]; then
81+
sed -i "s/18789/$OPENCLAW_PORT/g" "$SECRETS"
82+
echo "✅ OpenClaw port configured"
83+
fi
84+
85+
if [ -n "$OPENCLAW_TOKEN" ]; then
86+
OPENCLAW_TOKEN_ESCAPED=$(printf '%s\n' "$OPENCLAW_TOKEN" | sed 's/[[\.*^$/]/\\&/g')
87+
sed -i "s/YOUR_OPENCLAW_GATEWAY_TOKEN/$OPENCLAW_TOKEN_ESCAPED/g" "$SECRETS"
88+
echo "✅ OpenClaw gateway token configured"
89+
fi
90+
else
91+
echo "⏭️ Skipped OpenClaw configuration"
92+
fi
93+
94+
echo ""
95+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
96+
echo "✅ Setup Complete!"
97+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
98+
echo ""
99+
echo "Secrets.swift created at:"
100+
echo " $SECRETS"
101+
echo ""
102+
echo "Next steps:"
103+
echo " 1. Open project: open samples/CameraAccess/CameraAccess.xcodeproj"
104+
echo " 2. Select your Apple ID for signing (free provisioning)"
105+
echo " 3. Build and run on your iPhone (Cmd+R)"
106+
echo ""
107+
echo "For detailed instructions, see: docs/DEVELOPMENT.md"
108+
echo ""

0 commit comments

Comments
 (0)