diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index ea9f7f5a..793dc91a 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -82,7 +82,10 @@ COPY --chown=vscode:vscode script/install-claude-plugins.sh /tmp/install-claude- # Build with: DOCKER_BUILDKIT=1 docker build --secret id=claude_credentials,src=$HOME/.claude/.credentials.json . # Note: Run as root to access BuildKit secret, then change ownership to vscode RUN --mount=type=secret,id=claude_credentials,uid=0,gid=0 \ - /tmp/install-claude-plugins.sh /home/vscode/.claude/plugins/plugins.txt || true \ + /tmp/install-claude-plugins.sh /home/vscode/.claude/plugins/plugins.txt || ( \ + echo "[WARN] Claude プラグインのインストールに失敗しました(認証情報が不足している可能性があります)" && \ + echo "[INFO] コンテナ起動後に手動でインストールしてください: claude plugin install @" \ + ) \ && chown -R vscode:vscode /home/vscode/.claude RUN chsh -s /bin/bash vscode diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index a6490da8..a5c7557a 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -43,6 +43,6 @@ } } }, - "postCreateCommand": "sudo chown -R vscode:vscode /workspaces/config && npm ci && npm run prepare && cp -r /tmp/.husky /workspaces/config/ && cp /tmp/commitlint.config.js /workspaces/config/ && ./script/setup-claude.sh --sync-only || true", + "postCreateCommand": "sudo chown -R vscode:vscode /workspaces/config && npm ci && npm run prepare && cp -r /tmp/.husky /workspaces/config/ && cp /tmp/commitlint.config.js /workspaces/config/ && ./script/setup-claude.sh || true", "runArgs": ["--env-file=${localEnv:HOME}/.devcontainer.env"] } diff --git a/script/post-create-plugins.sh b/script/post-create-plugins.sh new file mode 100755 index 00000000..788395a7 --- /dev/null +++ b/script/post-create-plugins.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash +# ============================================================================ +# Post-Create Plugin Installer +# DevContainer 起動後にプラグインが不足している場合に自動インストール +# ============================================================================ + +set -euo pipefail + +PLUGINS_FILE="${1:-/home/vscode/.claude/plugins/plugins.txt}" + +echo "[INFO] Claude プラグインの状態を確認中..." + +# プラグインリストが存在するか確認 +if [[ ! -f "$PLUGINS_FILE" ]]; then + echo "[WARN] plugins.txt が見つかりません: ${PLUGINS_FILE}" + exit 0 +fi + +installed=0 +missing=0 + +while IFS= read -r line || [[ -n "$line" ]]; do + # 空行とコメント行をスキップ + [[ -z "$line" || "$line" =~ ^[[:space:]]*# ]] && continue + + # 前後の空白を除去 + plugin=$(echo "$line" | xargs) + [[ -z "$plugin" ]] && continue + + # プラグインがインストール済みかチェック + if ! claude plugin list 2>/dev/null | grep -q "$plugin"; then + echo "[INFO] インストール中: ${plugin}" + if claude plugin install "$plugin" 2>/dev/null; then + echo "[SUCCESS] 完了: ${plugin}" + installed=$((installed + 1)) + else + echo "[WARN] スキップまたは失敗: ${plugin}" + missing=$((missing + 1)) + fi + fi +done < "$PLUGINS_FILE" + +if [[ $installed -gt 0 ]]; then + echo "[SUCCESS] ${installed} 個のプラグインをインストールしました" +fi + +if [[ $missing -gt 0 ]]; then + echo "[WARN] ${missing} 個のプラグインのインストールに失敗しました" + echo "[INFO] 手動でインストールするには: claude plugin install @" +fi + +exit 0