diff --git a/.claude/settings.local.json b/.claude/settings.local.json index 97393f7..8409758 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -5,7 +5,9 @@ "Bash(tmux list-windows:*)", "Bash(ls:*)", "Bash(cat:*)", - "Bash(grep:*)" + "Bash(grep:*)", + "Bash(test:*)", + "Bash(shellcheck:*)" ] }, "enableAllProjectMcpServers": true, diff --git a/build/docker-entrypoint b/build/docker-entrypoint index 1964b1b..5e24391 100644 --- a/build/docker-entrypoint +++ b/build/docker-entrypoint @@ -306,6 +306,14 @@ else fi fi + # Create symlink from ~/.claude/agents to ~/.claudebox/agents + # The ~/.claudebox folder is mounted from the host + if [ -d "$HOME/.claudebox/agents" ]; then + if [ ! -e "$HOME/.claude/agents" ]; then + ln -s "$HOME/.claudebox/agents" "$HOME/.claude/agents" + fi + fi + cd /workspace # Check if .claude/projects exists and filter out -c/--continue if not diff --git a/lib/project.sh b/lib/project.sh index 4c76ea7..5fc801e 100755 --- a/lib/project.sh +++ b/lib/project.sh @@ -594,6 +594,56 @@ sync_commands_to_project() { echo "$user_checksum" > "$user_checksum_file" fi + # Sync user agents (similar to commands) + local agents_source="$HOME/.claude/agents" + local agents_dir="$project_parent/agents" + local agents_checksum_file="$project_parent/.agents_checksum" + local agents_checksum="" + + # Calculate checksum for agents if directory exists + if [[ -d "$agents_source" ]]; then + agents_checksum=$(find "$agents_source" -type f -exec stat -f "%m" {} \; 2>/dev/null | sort | md5 2>/dev/null || \ + find "$agents_source" -type f -exec stat -c "%Y" {} \; 2>/dev/null | sort | md5sum | cut -d' ' -f1) + + # Check if sync needed + local sync_agents=false + if [[ ! -f "$agents_checksum_file" ]]; then + sync_agents=true + elif [[ "$(cat "$agents_checksum_file" 2>/dev/null)" != "$agents_checksum" ]]; then + sync_agents=true + fi + + # Sync agents if needed + if [[ "$sync_agents" == "true" ]]; then + if [[ "$VERBOSE" == "true" ]]; then + echo "[DEBUG] Syncing agents to $agents_dir" >&2 + fi + + # Remove old agents and recreate + rm -rf "$agents_dir" + mkdir -p "$agents_dir" + + # Copy preserving directory structure + if cd "$agents_source"; then + find . -type f | while read -r file; do + local dir=$(dirname "$file") + mkdir -p "$agents_dir/$dir" + cp "$file" "$agents_dir/$file" + done + cd - >/dev/null + fi + + # Save checksum + echo "$agents_checksum" > "$agents_checksum_file" + fi + fi + + # Clean up agents directory if source doesn't exist + if [[ ! -d "$agents_source" ]] && [[ -d "$agents_dir" ]]; then + rm -rf "$agents_dir" + rm -f "$agents_checksum_file" + fi + # Clean up empty directories if sources don't exist if [[ ! -d "$cbox_source" ]] && [[ -d "$commands_dir/cbox" ]]; then rm -rf "$commands_dir/cbox"