claudepod 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,112 @@
1
+ #!/bin/bash
2
+
3
+ # Claude Code Installation Module
4
+ # Handles Claude Code installation using focused functions
5
+
6
+ # State tracking directory
7
+ STATE_DIR="/workspace/.devcontainer/state"
8
+
9
+ # Function to create state marker
10
+ create_state_marker() {
11
+ local component="$1"
12
+ local method="${2:-unknown}"
13
+
14
+ mkdir -p "$STATE_DIR"
15
+ echo "$(date '+%Y-%m-%d %H:%M:%S') - $method" > "$STATE_DIR/${component}.installed"
16
+ chown -R node:node "$STATE_DIR"
17
+ }
18
+
19
+ # Function to check if component is already installed
20
+ is_component_installed() {
21
+ local component="$1"
22
+
23
+ [ -f "$STATE_DIR/${component}.installed" ]
24
+ }
25
+
26
+ # Function to verify Claude Code installation
27
+ verify_claude_installation() {
28
+ local installation_method="$1"
29
+
30
+ if command -v claude &> /dev/null || [ -f "/home/node/.local/bin/claude" ]; then
31
+ local version=$(claude --version 2>/dev/null || echo "installed")
32
+ echo "📌 Claude Code version: $version"
33
+ echo "✅ Claude Code verification successful ($installation_method)"
34
+ return 0
35
+ else
36
+ echo "⚠️ Claude Code installed via $installation_method but 'claude' command not found"
37
+ echo "📍 Checking installation location..."
38
+ find /home/node/.local -name "claude" -type f 2>/dev/null || echo " No claude binary found"
39
+ return 1
40
+ fi
41
+ }
42
+
43
+ # Function to install Claude Code via native binary
44
+ install_claude_code_native() {
45
+ echo "📦 Installing Claude Code via native binary..."
46
+
47
+ if retry_command 3 5 bash -c 'curl -fsSL claude.ai/install.sh | bash'; then
48
+ echo "✅ Claude Code native binary installation completed"
49
+ return 0
50
+ else
51
+ echo "❌ Failed to install Claude Code native binary after multiple attempts"
52
+ return 1
53
+ fi
54
+ }
55
+
56
+ # Function to install Claude Code via npm fallback
57
+ install_claude_code_npm() {
58
+ echo "📦 Installing Claude Code via npm fallback..."
59
+
60
+ # Ensure npm environment is configured
61
+ export npm_config_prefix="/home/node/.local"
62
+
63
+ if retry_command 3 5 npm install -g @anthropic-ai/claude-code; then
64
+ echo "✅ Claude Code npm installation completed"
65
+ return 0
66
+ else
67
+ echo "❌ Failed to install Claude Code via npm"
68
+ return 1
69
+ fi
70
+ }
71
+
72
+ # Main Claude Code installation function
73
+ install_claude_code() {
74
+ # Check if Claude Code is already installed
75
+ if is_component_installed "claude-code"; then
76
+ echo "✅ Claude Code already installed (marker found)"
77
+ if verify_claude_installation "cached"; then
78
+ return 0
79
+ else
80
+ echo "⚠️ Marker exists but verification failed, reinstalling..."
81
+ rm -f "$STATE_DIR/claude-code.installed"
82
+ fi
83
+ fi
84
+
85
+ echo "📦 Installing Claude Code (Native Binary)..."
86
+
87
+ # Attempt native binary installation first
88
+ if install_claude_code_native; then
89
+ if verify_claude_installation "native binary"; then
90
+ create_state_marker "claude-code" "native binary"
91
+ return 0
92
+ else
93
+ echo "⚠️ Native binary installation completed but verification failed"
94
+ fi
95
+ fi
96
+
97
+ # Fallback to npm installation
98
+ echo "⚠️ Falling back to npm installation..."
99
+
100
+ if install_claude_code_npm; then
101
+ if verify_claude_installation "npm fallback"; then
102
+ create_state_marker "claude-code" "npm fallback"
103
+ return 0
104
+ else
105
+ echo "❌ npm installation completed but verification failed"
106
+ return 1
107
+ fi
108
+ else
109
+ echo "❌ Failed to install Claude Code via both native binary and npm"
110
+ return 1
111
+ fi
112
+ }
@@ -0,0 +1,271 @@
1
+ #!/bin/bash
2
+
3
+ # ZSH Configuration Module
4
+ # Handles focused ZSH configuration generation
5
+
6
+ # Function to generate basic ZSH configuration
7
+ generate_zsh_basic_config() {
8
+ cat << 'EOF'
9
+ # ClaudePod ZSH Configuration
10
+ # Path to your oh-my-zsh installation
11
+ export ZSH="$HOME/.oh-my-zsh"
12
+
13
+ # Set name of the theme to load
14
+ ZSH_THEME="powerlevel10k/powerlevel10k"
15
+
16
+ # Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
17
+ if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
18
+ source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
19
+ fi
20
+
21
+ # Disable P10k configuration wizard
22
+ export POWERLEVEL9K_DISABLE_CONFIGURATION_WIZARD=true
23
+
24
+ # Suppress P10k instant prompt warnings (quiet mode)
25
+ export POWERLEVEL9K_INSTANT_PROMPT=quiet
26
+
27
+ # ZSH Configuration
28
+ CASE_SENSITIVE="false"
29
+ HYPHEN_INSENSITIVE="true"
30
+ DISABLE_AUTO_UPDATE="false"
31
+ DISABLE_UPDATE_PROMPT="true"
32
+ export UPDATE_ZSH_DAYS=7
33
+ DISABLE_MAGIC_FUNCTIONS="false"
34
+ DISABLE_LS_COLORS="false"
35
+ DISABLE_AUTO_TITLE="false"
36
+ ENABLE_CORRECTION="true"
37
+ COMPLETION_WAITING_DOTS="true"
38
+ DISABLE_UNTRACKED_FILES_DIRTY="false"
39
+ HIST_STAMPS="yyyy-mm-dd"
40
+
41
+ # ZSH Plugins
42
+ plugins=(
43
+ git
44
+ docker
45
+ docker-compose
46
+ node
47
+ npm
48
+ python
49
+ pip
50
+ vscode
51
+ zsh-syntax-highlighting
52
+ zsh-autosuggestions
53
+ zsh-completions
54
+ fast-syntax-highlighting
55
+ history-substring-search
56
+ colored-man-pages
57
+ command-not-found
58
+ extract
59
+ z
60
+ )
61
+
62
+ # Load Oh My Zsh
63
+ source $ZSH/oh-my-zsh.sh
64
+
65
+ # User configuration
66
+ export LANG=en_US.UTF-8
67
+ export EDITOR='code'
68
+ export ARCHFLAGS="-arch x86_64"
69
+
70
+ # History configuration
71
+ HISTSIZE=50000
72
+ SAVEHIST=50000
73
+ setopt HIST_EXPIRE_DUPS_FIRST
74
+ setopt HIST_IGNORE_DUPS
75
+ setopt HIST_IGNORE_ALL_DUPS
76
+ setopt HIST_IGNORE_SPACE
77
+ setopt HIST_FIND_NO_DUPS
78
+ setopt HIST_SAVE_NO_DUPS
79
+ setopt HIST_BEEP
80
+ setopt SHARE_HISTORY
81
+
82
+ # Path configuration
83
+ export PATH="$HOME/.local/bin:$PATH"
84
+ export PATH="/usr/local/share/npm-global/bin:$PATH"
85
+
86
+ # Node.js/NVM configuration
87
+ export NVM_DIR="/usr/local/share/nvm"
88
+ [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
89
+ [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
90
+
91
+ # Python configuration
92
+ if command -v python3 &> /dev/null; then
93
+ alias python=python3
94
+ alias pip=pip3
95
+ fi
96
+
97
+ EOF
98
+ }
99
+
100
+ # Function to generate ZSH aliases
101
+ generate_zsh_aliases() {
102
+ cat << 'EOF'
103
+ # ClaudePod aliases
104
+ alias ll='ls -alF'
105
+ alias la='ls -A'
106
+ alias l='ls -CF'
107
+ alias gs='git status'
108
+ alias gd='git diff'
109
+ alias gc='git commit'
110
+ alias gco='git checkout'
111
+ alias gp='git push'
112
+ alias gl='git log --oneline --graph --decorate'
113
+ alias ga='git add'
114
+ alias gb='git branch'
115
+ alias gm='git merge'
116
+ alias gr='git rebase'
117
+ alias gf='git fetch'
118
+ alias gpl='git pull'
119
+
120
+ # Development aliases
121
+ alias c='code .'
122
+ alias cls='clear'
123
+ alias h='history'
124
+ alias ..='cd ..'
125
+ alias ...='cd ../..'
126
+ alias ....='cd ../../..'
127
+ alias ~='cd ~'
128
+
129
+ # Claude Code aliases with optimized configuration
130
+ claude() {
131
+ local mcp_config="/workspace/.devcontainer/config/claude/mcp.json"
132
+ local system_prompt_file="/workspace/.devcontainer/config/claude/system-prompt.md"
133
+ local system_prompt=""
134
+
135
+ # Generate sanitized system prompt if file exists
136
+ if [ -f "$system_prompt_file" ]; then
137
+ system_prompt=$(/workspace/.devcontainer/sanitize-system-prompt.sh "$system_prompt_file" 2>/dev/null || echo "")
138
+ fi
139
+
140
+ # Build command with conditional arguments
141
+ local cmd_args=(
142
+ --model sonnet
143
+ --dangerously-skip-permissions
144
+ )
145
+
146
+ # Add MCP config if file exists
147
+ if [ -f "$mcp_config" ]; then
148
+ cmd_args+=(--mcp-config "$mcp_config")
149
+ fi
150
+
151
+ # Add system prompt if successfully generated
152
+ if [ -n "$system_prompt" ]; then
153
+ cmd_args+=(--append-system-prompt "$system_prompt")
154
+ fi
155
+
156
+ # Execute claude with all arguments
157
+ command claude "${cmd_args[@]}" "$@"
158
+ }
159
+
160
+ alias claude-help='claude --help'
161
+ alias claude-mcp='claude mcp list'
162
+ alias claude-version='claude --version'
163
+ alias claude-basic='command claude' # Access original claude without optimizations
164
+
165
+ EOF
166
+
167
+ # Add Docker aliases conditionally
168
+ cat << 'EOF'
169
+ # Docker aliases (if docker is available)
170
+ if command -v docker &> /dev/null; then
171
+ alias d='docker'
172
+ alias dc='docker-compose'
173
+ alias dps='docker ps'
174
+ alias dpsa='docker ps -a'
175
+ alias di='docker images'
176
+ alias drm='docker rm'
177
+ alias drmi='docker rmi'
178
+ fi
179
+
180
+ EOF
181
+ }
182
+
183
+ # Function to generate ZSH utility functions
184
+ generate_zsh_functions() {
185
+ cat << 'EOF'
186
+ # Useful functions
187
+ # Extract various archive formats
188
+ extract() {
189
+ if [ -f $1 ]; then
190
+ case $1 in
191
+ *.tar.bz2) tar xjf $1 ;;
192
+ *.tar.gz) tar xzf $1 ;;
193
+ *.bz2) bunzip2 $1 ;;
194
+ *.rar) unrar e $1 ;;
195
+ *.gz) gunzip $1 ;;
196
+ *.tar) tar xf $1 ;;
197
+ *.tbz2) tar xjf $1 ;;
198
+ *.tgz) tar xzf $1 ;;
199
+ *.zip) unzip $1 ;;
200
+ *.Z) uncompress $1 ;;
201
+ *.7z) 7z x $1 ;;
202
+ *) echo "'$1' cannot be extracted via extract()" ;;
203
+ esac
204
+ else
205
+ echo "'$1' is not a valid file"
206
+ fi
207
+ }
208
+
209
+ # Create directory and cd into it
210
+ mkcd() {
211
+ mkdir -p "$1" && cd "$1"
212
+ }
213
+
214
+ # Find process by name
215
+ findp() {
216
+ ps aux | grep -v grep | grep "$1"
217
+ }
218
+
219
+ # Quick HTTP server
220
+ serve() {
221
+ local port="${1:-8000}"
222
+ python3 -m http.server "$port"
223
+ }
224
+
225
+ EOF
226
+ }
227
+
228
+ # Function to generate ZSH welcome and final configuration
229
+ generate_zsh_welcome() {
230
+ cat << 'EOF'
231
+ # Load Powerlevel10k configuration
232
+ if [[ -r ~/.p10k.zsh ]]; then
233
+ source ~/.p10k.zsh
234
+ fi
235
+
236
+ # Auto-suggestions configuration
237
+ ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#666666"
238
+ ZSH_AUTOSUGGEST_STRATEGY=(history completion)
239
+ ZSH_AUTOSUGGEST_USE_ASYNC=true
240
+
241
+ # Syntax highlighting configuration
242
+ ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern)
243
+
244
+ # Welcome message
245
+ if [[ -n "$ZSH_VERSION" ]]; then
246
+ echo "🚀 Welcome to ClaudePod!"
247
+ echo "💡 Type 'claude' to start using Claude Code"
248
+ echo "📋 Run 'claude mcp list' to see available MCP servers"
249
+ fi
250
+ EOF
251
+ }
252
+
253
+ # Main function to create enhanced .zshrc using focused generators
254
+ create_zshrc() {
255
+ echo "📝 Creating enhanced .zshrc configuration..."
256
+
257
+ # Backup existing .zshrc if it exists
258
+ if [ -f "$HOME/.zshrc" ]; then
259
+ cp "$HOME/.zshrc" "$HOME/.zshrc.backup.$(date +%s)" 2>/dev/null || true
260
+ fi
261
+
262
+ # Generate complete .zshrc using focused components
263
+ {
264
+ generate_zsh_basic_config
265
+ generate_zsh_aliases
266
+ generate_zsh_functions
267
+ generate_zsh_welcome
268
+ } > "$HOME/.zshrc"
269
+
270
+ echo "✅ Enhanced .zshrc created"
271
+ }
@@ -0,0 +1,44 @@
1
+ #!/bin/bash
2
+
3
+ # ClaudePod Shared Utilities
4
+ # Common functions used across multiple setup scripts
5
+
6
+ # Function to retry a command with exponential backoff
7
+ # Usage: retry_command <max_attempts> <delay_seconds> <command> [args...]
8
+ # Example: retry_command 3 5 npm install -g some-package
9
+ retry_command() {
10
+ local max_attempts=${1:-3}
11
+ local delay=${2:-5}
12
+ shift 2
13
+ local attempt=1
14
+
15
+ while [ $attempt -le $max_attempts ]; do
16
+ if "$@"; then
17
+ return 0
18
+ fi
19
+ echo "⚠️ Command failed (attempt $attempt/$max_attempts): $*"
20
+ if [ $attempt -lt $max_attempts ]; then
21
+ echo " Retrying in ${delay}s..."
22
+ sleep $delay
23
+ fi
24
+ ((attempt++))
25
+ done
26
+ return 1
27
+ }
28
+
29
+ # Function to add directory to PATH without duplication
30
+ # Usage: add_to_path <directory>
31
+ # Example: add_to_path "/home/node/.local/bin"
32
+ add_to_path() {
33
+ local dir="$1"
34
+ case ":$PATH:" in
35
+ *":$dir:"*)
36
+ # Directory already in PATH
37
+ return 0
38
+ ;;
39
+ *)
40
+ # Add directory to PATH
41
+ export PATH="$dir:$PATH"
42
+ ;;
43
+ esac
44
+ }