Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
USER vscode
RUN --mount=type=secret,id=claude_credentials \
/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 <plugin>@<marketplace>" \
)
USER root

RUN chsh -s /bin/bash vscode
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,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"]
}
52 changes: 52 additions & 0 deletions script/post-create-plugins.sh
Original file line number Diff line number Diff line change
@@ -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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Fix plugin existence check to use exact matching.

The current grep -q "$plugin" performs substring matching, which can produce false positives. For example, if the plugins list contains both "git" and "github", checking for "git" would incorrectly match "github".

🔎 Proposed fix using exact matching
-    if ! claude plugin list 2>/dev/null | grep -q "$plugin"; then
+    if ! claude plugin list 2>/dev/null | grep -qE "^${plugin}(\s|$)"; then

Alternatively, use word boundary matching:

-    if ! claude plugin list 2>/dev/null | grep -q "$plugin"; then
+    if ! claude plugin list 2>/dev/null | grep -qw "$plugin"; then

Note: The best approach depends on the exact output format of claude plugin list. You may need to verify the output format to ensure the pattern matches correctly.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if ! claude plugin list 2>/dev/null | grep -q "$plugin"; then
if ! claude plugin list 2>/dev/null | grep -qw "$plugin"; then
🤖 Prompt for AI Agents
In script/post-create-plugins.sh around line 31, the existence check uses grep
-q "$plugin" which does substring matching and can yield false positives (e.g.,
"git" matching "github"); change the check to an exact whole-line match such as
using grep -xF -q "$plugin" (or grep -wF -q "$plugin" if word boundaries are
needed) so the plugin name must match exactly, ensure the variable is quoted and
escaped appropriately, and if claude plugin list prints additional columns
adjust the pattern (or trim/parse the output) to match only the plugin name
field.

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 <plugin>@<marketplace>"
fi

exit 0