Repository navigation
chore: 共有Claude設定を全CLAUDE_CONFIG_DIRへ同期する #977
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -31,6 +31,12 @@ KNOWN_MARKETPLACES="${PLUGINS_DIR}/known_marketplaces.json" | |||||||||||||||||||||||||
| REPO_PLUGINS_DIR="${REPO_ROOT}/.claude/plugins" | ||||||||||||||||||||||||||
| SETTINGS_LOCAL_FILE="${CLAUDE_DIR}/settings.local.json" | ||||||||||||||||||||||||||
| DEFAULT_SETTINGS_LOCAL="${REPO_ROOT}/.devcontainer/claude-settings.local.json" | ||||||||||||||||||||||||||
| SETTINGS_FILE="${CLAUDE_DIR}/settings.json" | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # 複数の CLAUDE_CONFIG_DIR に共有設定を配るためのキー。 | ||||||||||||||||||||||||||
| # ここに無いキー(model / theme / tui 等)は各 dir 固有として保持される。 | ||||||||||||||||||||||||||
| # shellcheck disable=SC2016 # jq に渡すJSONリテラル。$schema はシェル変数ではない | ||||||||||||||||||||||||||
| CLAUDE_SHARED_SETTINGS_KEYS='["$schema","hooks","permissions","enabledPlugins","extraKnownMarketplaces","attribution"]' | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # settings.local.json のセットアップ | ||||||||||||||||||||||||||
| # ホストに settings.local.json がない場合、デフォルトをコピー | ||||||||||||||||||||||||||
|
|
@@ -52,6 +58,78 @@ setup_settings_local() { | |||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # 追加の CLAUDE_CONFIG_DIR を列挙する | ||||||||||||||||||||||||||
| # Agent Deck の config.toml が group ごとに config_dir を切り替えるため、 | ||||||||||||||||||||||||||
| # ~/.claude 以外の dir が存在しうる(例: ~/.claude-private, ~/.claude-elu)。 | ||||||||||||||||||||||||||
| # CLAUDE_EXTRA_CONFIG_DIRS で明示指定も可能(スペース区切り)。 | ||||||||||||||||||||||||||
| list_extra_config_dirs() { | ||||||||||||||||||||||||||
| if [[ -n "${CLAUDE_EXTRA_CONFIG_DIRS:-}" ]]; then | ||||||||||||||||||||||||||
| local -a explicit_dirs | ||||||||||||||||||||||||||
| read -r -a explicit_dirs <<< "$CLAUDE_EXTRA_CONFIG_DIRS" | ||||||||||||||||||||||||||
| printf '%s\n' "${explicit_dirs[@]}" | ||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
| local dir | ||||||||||||||||||||||||||
| for dir in "${HOME}"/.claude-*; do | ||||||||||||||||||||||||||
| [[ -d "$dir" ]] || continue | ||||||||||||||||||||||||||
| printf '%s\n' "$dir" | ||||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # 共有設定を追加の CLAUDE_CONFIG_DIR に同期する | ||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||
| # なぜ必要か: settings.json は CLAUDE_CONFIG_DIR ごとに独立しており、 | ||||||||||||||||||||||||||
| # ~/.claude の hooks / permissions / plugins は他の dir では一切読まれない。 | ||||||||||||||||||||||||||
| # 2026-07-15 時点で ~/.claude-private は hooks 1個・~/.claude-elu は 0個と、 | ||||||||||||||||||||||||||
| # Quality Gates も permissions も attribution も効かない状態になっていた。 | ||||||||||||||||||||||||||
| sync_settings_to_extra_config_dirs() { | ||||||||||||||||||||||||||
| if [[ ! -f "$SETTINGS_FILE" ]]; then | ||||||||||||||||||||||||||
| log_warn "正本の settings.json が見つかりません: ${SETTINGS_FILE}(同期をスキップ)" | ||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
| if ! command -v jq &> /dev/null; then | ||||||||||||||||||||||||||
| log_warn "jq が見つかりません。追加 config dir への設定同期をスキップします" | ||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| local target_dir target_file tmp_file | ||||||||||||||||||||||||||
| while IFS= read -r target_dir; do | ||||||||||||||||||||||||||
| [[ -n "$target_dir" ]] || continue | ||||||||||||||||||||||||||
| target_file="${target_dir}/settings.json" | ||||||||||||||||||||||||||
|
Comment on lines
+96
to
+98
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Expand tildes in explicit directory paths. If a user specifies paths starting with 💡 Proposed fix while IFS= read -r target_dir; do
[[ -n "$target_dir" ]] || continue
+
+ # Handle tilde expansion for explicitly provided paths
+ if [[ "$target_dir" == "~" ]] || [[ "$target_dir" == "~/"* ]]; then
+ target_dir="${target_dir/#\~/$HOME}"
+ fi
+
target_file="${target_dir}/settings.json"📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| if [[ -e "$target_file" ]] && ! jq -e . "$target_file" > /dev/null 2>&1; then | ||||||||||||||||||||||||||
| log_warn " ${target_file} が不正なJSONのためスキップします" | ||||||||||||||||||||||||||
| continue | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| tmp_file="$(mktemp)" | ||||||||||||||||||||||||||
| if ! jq --argjson keys "$CLAUDE_SHARED_SETTINGS_KEYS" \ | ||||||||||||||||||||||||||
| 'with_entries(select(.key as $k | $keys | index($k)))' \ | ||||||||||||||||||||||||||
| "$SETTINGS_FILE" > "$tmp_file" 2>/dev/null; then | ||||||||||||||||||||||||||
| log_warn " 共有設定の抽出に失敗しました: ${SETTINGS_FILE}" | ||||||||||||||||||||||||||
| rm -f "$tmp_file" | ||||||||||||||||||||||||||
| continue | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| local merged_file | ||||||||||||||||||||||||||
| merged_file="$(mktemp)" | ||||||||||||||||||||||||||
| if jq -s '(.[0] // {}) + .[1]' \ | ||||||||||||||||||||||||||
| <(if [[ -f "$target_file" ]]; then cat "$target_file"; else echo '{}'; fi) \ | ||||||||||||||||||||||||||
| "$tmp_file" > "$merged_file" 2>/dev/null && jq -e . "$merged_file" > /dev/null 2>&1; then | ||||||||||||||||||||||||||
| if [[ -f "$target_file" ]] && cmp -s "$target_file" "$merged_file"; then | ||||||||||||||||||||||||||
| log_info " ${target_dir} は最新です" | ||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||
| mkdir -p "$target_dir" | ||||||||||||||||||||||||||
| cp "$merged_file" "$target_file" | ||||||||||||||||||||||||||
| log_success " ${target_dir} に共有設定を同期しました" | ||||||||||||||||||||||||||
|
Comment on lines
+123
to
+124
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win Verify the exit status of If the 🛡️ Proposed fix to handle copy failures- cp "$merged_file" "$target_file"
- log_success " ${target_dir} に共有設定を同期しました"
+ if cp "$merged_file" "$target_file"; then
+ log_success " ${target_dir} に共有設定を同期しました"
+ else
+ log_warn " ${target_dir} への共有設定の同期に失敗しました"
+ fi📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||
| log_warn " ${target_file} のマージに失敗しました" | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
| rm -f "$tmp_file" "$merged_file" | ||||||||||||||||||||||||||
| done < <(list_extra_config_dirs) | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| main() { | ||||||||||||||||||||||||||
| log_info "Claude Code セットアップを開始します..." | ||||||||||||||||||||||||||
| log_info "環境: HOME=${HOME}" | ||||||||||||||||||||||||||
|
|
@@ -70,6 +148,10 @@ main() { | |||||||||||||||||||||||||
| # settings.local.json のセットアップ | ||||||||||||||||||||||||||
| setup_settings_local | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # 追加の CLAUDE_CONFIG_DIR(~/.claude-private 等)へ共有設定を同期 | ||||||||||||||||||||||||||
| log_info "追加の CLAUDE_CONFIG_DIR に共有設定を同期します..." | ||||||||||||||||||||||||||
| sync_settings_to_extra_config_dirs | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
Comment on lines
+151
to
+154
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Execute synchronization after the canonical Running Remove these lines from their current position and place them at the very end of the ✂️ Remove from here- # 追加の CLAUDE_CONFIG_DIR(~/.claude-private 等)へ共有設定を同期
- log_info "追加の CLAUDE_CONFIG_DIR に共有設定を同期します..."
- sync_settings_to_extra_config_dirs
-🤖 Prompt for AI Agents |
||||||||||||||||||||||||||
| # Claude CLI の存在確認 | ||||||||||||||||||||||||||
| if ! command -v claude &> /dev/null; then | ||||||||||||||||||||||||||
| log_warn "Claude CLI が見つかりません。プラグインのインストールはスキップされます。" | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When setup is run from the normal shell, this copies
enabledPlugins/extraKnownMarketplacesinto~/.claude-*, but the laterclaude plugin installflow still runs only for the active Claude config and never installs plugin artifacts under those target dirs. I checked the Claude Code docs:CLAUDE_CONFIG_DIRstores plugins under that path, andenabledPluginsdoes not by itself install external plugins. As a result, Agent Deck sessions usingCLAUDE_CONFIG_DIR=~/.claude-privatecan get settings that claim plugins are enabled while the plugin commands/hooks/LSPs remain absent until a separate per-dir install is run.Useful? React with 👍 / 👎.