Enhance LLM sandbox with persistent caching, helper scripts, and improved UX

Added comprehensive improvements to ClawdBox for better LLM agent experience:

- Tools: Added tree, tmux, htop, strace, file, less for enhanced debugging
- Python packages: httpie, pyyaml, requests, black, ipython pre-installed
- Persistent caching: pip/npm caches now survive container restarts
- Git config persistence: .gitconfig auto-links from /data volume
- Shell improvements: colored prompt, aliases (ll, k, dc), 10k line history
- Helper scripts: ConfigMap with disk-usage, health-check, clean-workspace, install-tools
- Environment variables: TERM, TZ, DEBIAN_FRONTEND for better compatibility
- Makefile: Common operations (build, deploy, logs, shell, health-check)
- Documentation: Comprehensive README with troubleshooting and workflows

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-03-07 23:51:26 +11:00
parent 8fe712cda7
commit e039f77f0e
5 changed files with 562 additions and 8 deletions

189
manifests/configmap.yaml Normal file
View File

@@ -0,0 +1,189 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: clawdbox-scripts
namespace: clawdbox
labels:
app: clawdbox
data:
disk-usage.sh: |
#!/bin/bash
# Quick disk usage report for /data volume
echo "=== Data Volume Usage ==="
df -h /data
echo -e "\n=== Top 10 Largest Directories ==="
du -h /data 2>/dev/null | sort -rh | head -10
echo -e "\n=== Cache Sizes ==="
if [ -d /data/.cache/pip ]; then
echo "pip cache: $(du -sh /data/.cache/pip 2>/dev/null | cut -f1)"
fi
if [ -d /data/.cache/npm ]; then
echo "npm cache: $(du -sh /data/.cache/npm 2>/dev/null | cut -f1)"
fi
health-check.sh: |
#!/bin/bash
# Comprehensive health diagnostics for troubleshooting
echo "=== ClawdBox Health Check ==="
echo "Timestamp: $(date)"
echo ""
echo "=== SSH Daemon Status ==="
if ps aux | grep -v grep | grep sshd > /dev/null; then
echo "✓ SSH daemon is running"
ps aux | grep sshd | grep -v grep
else
echo "✗ SSH daemon is NOT running"
fi
echo ""
echo "=== Disk Space ==="
df -h /data
echo ""
echo "=== Memory Usage ==="
free -h
echo ""
echo "=== Network Connectivity ==="
if ping -c 1 8.8.8.8 > /dev/null 2>&1; then
echo "✓ Internet connectivity OK"
else
echo "✗ No internet connectivity"
fi
echo ""
echo "=== Environment Variables ==="
echo "PIP_CACHE_DIR: $PIP_CACHE_DIR"
echo "npm_config_cache: $npm_config_cache"
echo "HISTFILE: $HISTFILE"
echo ""
echo "=== Persistent Directories ==="
ls -lah /data/.cache/ 2>/dev/null || echo "No .cache directory"
echo ""
echo "=== Current Working Directory ==="
pwd
echo ""
echo "=== User Information ==="
whoami
id
clean-workspace.sh: |
#!/bin/bash
# Interactive workspace cleanup helper
echo "=== ClawdBox Workspace Cleanup ==="
echo ""
# Show current usage
echo "Current disk usage:"
df -h /data
echo ""
# Offer cleanup options
echo "What would you like to clean?"
echo "1) Package caches (pip + npm)"
echo "2) Temporary files"
echo "3) Both caches and temp files"
echo "4) Show what's using space (no deletion)"
echo "5) Cancel"
echo ""
read -p "Enter choice [1-5]: " choice
case $choice in
1)
echo "Cleaning package caches..."
rm -rf /data/.cache/pip/* /data/.cache/npm/*
echo "✓ Package caches cleared"
;;
2)
echo "Cleaning temporary files..."
find /data -type f -name "*.tmp" -delete 2>/dev/null
find /data -type f -name "*.log" -mtime +7 -delete 2>/dev/null
echo "✓ Temporary files cleaned"
;;
3)
echo "Cleaning caches and temporary files..."
rm -rf /data/.cache/pip/* /data/.cache/npm/*
find /data -type f -name "*.tmp" -delete 2>/dev/null
find /data -type f -name "*.log" -mtime +7 -delete 2>/dev/null
echo "✓ All cleaned"
;;
4)
echo "Analyzing disk usage..."
du -h /data | sort -rh | head -20
;;
5)
echo "Cleanup cancelled"
exit 0
;;
*)
echo "Invalid choice"
exit 1
;;
esac
echo ""
echo "New disk usage:"
df -h /data
install-tools.sh: |
#!/bin/bash
# Helper script to install common additional tools
echo "=== ClawdBox Additional Tools Installer ==="
echo ""
echo "This script helps install commonly requested tools."
echo "All installations are temporary and will be lost on container restart."
echo ""
echo "Available tool categories:"
echo "1) Data science (pandas, numpy, matplotlib)"
echo "2) Web scraping (beautifulsoup4, selenium)"
echo "3) CLI tools (fzf, bat, fd-find)"
echo "4) Custom (specify packages)"
echo "5) Exit"
echo ""
read -p "Enter choice [1-5]: " choice
case $choice in
1)
echo "Installing data science packages..."
pip3 install --user pandas numpy matplotlib scipy
;;
2)
echo "Installing web scraping packages..."
pip3 install --user beautifulsoup4 selenium requests-html
;;
3)
echo "Installing CLI tools..."
echo "Note: These require sudo and apt-get"
sudo apt-get update
sudo apt-get install -y fzf bat fd-find
;;
4)
read -p "Enter package names (space-separated): " packages
echo "Installing: $packages"
pip3 install --user $packages
;;
5)
echo "Exiting"
exit 0
;;
*)
echo "Invalid choice"
exit 1
;;
esac
echo ""
echo "✓ Installation complete"

View File

@@ -51,6 +51,13 @@ spec:
ports:
- containerPort: 2222
name: ssh
env:
- name: TERM
value: xterm-256color
- name: DEBIAN_FRONTEND
value: noninteractive
- name: TZ
value: UTC
startupProbe:
tcpSocket:
port: ssh
@@ -77,6 +84,8 @@ spec:
name: ssh-working
- mountPath: /home/claw/.kube
name: kubeconfig-secret
- mountPath: /data/scripts
name: helper-scripts
resources:
limits:
memory: "2Gi"
@@ -103,3 +112,7 @@ spec:
secretName: kube
- name: ssh-working
emptyDir: {}
- name: helper-scripts
configMap:
name: clawdbox-scripts
defaultMode: 0755