Files
gh-tstomtimes-orchestra/hooks/session-start.sh
2025-11-30 09:03:11 +08:00

111 lines
4.7 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# Session Start Hook
# Provides context about Orchestra Plugin to Claude
set -euo pipefail
# Sync .claude.json settings to settings.local.json (silent mode)
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
if [ -f "$PROJECT_ROOT/hooks/sync-claude-settings.sh" ]; then
bash "$PROJECT_ROOT/hooks/sync-claude-settings.sh" true 2>/dev/null || true
fi
# Initialize/migrate progress tracking system
PROGRESS_FILE="$PROJECT_ROOT/.orchestra/cache/progress.json"
MIGRATE_SCRIPT="$PROJECT_ROOT/hooks/lib/progress-migrate.sh"
if [ -f "$MIGRATE_SCRIPT" ]; then
# Run migration silently (it handles initialization if file doesn't exist)
bash "$MIGRATE_SCRIPT" > /dev/null 2>&1 || true
# Update session start time if progress.json exists
if [ -f "$PROGRESS_FILE" ] && command -v jq &> /dev/null; then
# Get timestamp in milliseconds (macOS compatible)
if command -v python3 &> /dev/null; then
TIMESTAMP=$(python3 -c 'import time; print(int(time.time() * 1000))')
elif command -v python &> /dev/null; then
TIMESTAMP=$(python -c 'import time; print(int(time.time() * 1000))')
else
TIMESTAMP=$(($(date +%s) * 1000))
fi
TEMP_FILE="${PROGRESS_FILE}.session.tmp"
jq --argjson timestamp "$TIMESTAMP" \
'.metadata.sessionStartTime = $timestamp' \
"$PROGRESS_FILE" > "$TEMP_FILE" 2>/dev/null && mv "$TEMP_FILE" "$PROGRESS_FILE" || true
fi
fi
# Get language setting from environment
LANG="${ORCHESTRA_LANGUAGE:-en}"
# Create welcome message as context for Claude
if [ "$LANG" = "ja" ]; then
CONTEXT=$(cat <<'EOF'
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🎭 ORCHESTRA プラグイン読み込み完了
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✨ 専門エージェントが待機中です:
😎 Blake - リリース管理者(デプロイ、リリース)
🤓 Eden - ドキュメントリード(技術ライティング)
😤 Finn - QA & テスト(テストカバレッジ、検証)
🤨 Iris - セキュリティ監査官(認証、シークレット、脆弱性)
🤔 Kai - システムアーキテクト設計判断、ADR
😌 Leo - データベースアーキテクト(スキーマ、マイグレーション)
😊 Mina - 統合スペシャリスト外部API
😄 Nova - UI/UX スペシャリスト(インターフェース、アクセシビリティ)
🧐 Riley - 要件明確化担当(曖昧なリクエスト)
😐 Skye - コード実装者(明確な仕様)
😬 Theo - 運用 & 監視(信頼性、インシデント)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
重要ユーザーに挨拶し、Orchestraプラグインが読み込まれたことを伝えてください。
利用可能な専門エージェントをリストし、タスクのサポートを提案してください。
EOF
)
else
CONTEXT=$(cat <<'EOF'
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🎭 ORCHESTRA PLUGIN LOADED
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✨ Specialized agents are ready for coordination:
😎 Blake - Release Manager (deployments, releases)
🤓 Eden - Documentation Lead (technical writing)
😤 Finn - QA & Testing (test coverage, validation)
🤨 Iris - Security Auditor (auth, secrets, vulnerabilities)
🤔 Kai - System Architect (design decisions, ADRs)
😌 Leo - Database Architect (schema, migrations)
😊 Mina - Integration Specialist (external APIs)
😄 Nova - UI/UX Specialist (interfaces, accessibility)
🧐 Riley - Requirements Clarifier (vague requests)
😐 Skye - Code Implementer (well-defined specs)
😬 Theo - Ops & Monitoring (reliability, incidents)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
IMPORTANT: You should greet the user and inform them that Orchestra Plugin has been loaded.
List the available specialist agents and encourage them to ask for help with their tasks.
EOF
)
fi
# Output JSON format for Claude's context
cat <<EOF
{
"hookSpecificOutput": {
"hookEventName": "SessionStart",
"additionalContext": $(echo "$CONTEXT" | jq -Rs .)
}
}
EOF
exit 0