Team Ai
Apppublic

sin601/claude-code

sourceHugging Faceupdated 7mo agoView on Hugging Face
0likes
init-config.sh170 linesDownload Raw Back to scripts
1#!/bin/bash2# 初始化配置脚本3 4set -e5 6CONFIG_DIR="${CONFIG_DIR:-/config}"7WORK_DIR="${WORK_DIR:-/workspace}"8HOME="${HOME:-/root}"9 10echo "=== Initializing Configuration ==="11 12# 创建配置目录13mkdir -p "${CONFIG_DIR}"14mkdir -p "${WORK_DIR}"15mkdir -p "${HOME}/.claude"16mkdir -p "${HOME}/.cli-proxy-api"17 18# 创建默认配置文件19if [ ! -f "${CONFIG_DIR}/config.env" ]; then20    cat > "${CONFIG_DIR}/config.env" << 'EOF'21# Claude Code HF Space Configuration22# ===================================23 24# API Configuration25# =================26# API_KEY - Your API Key (supports multiple keys separated by comma)27# Example: sk-key1,sk-key2,sk-key328API_KEY=""29 30# API_BASE_URL - API service URL31# Example: https://api.anthropic.com/v132# Or use a proxy: https://your-proxy.hf.space/v133API_BASE_URL=""34 35# Git Repository Configuration36# ============================37# GIT_REPO_URL - Your Git repository URL38# Example: https://github.com/username/repo.git39GIT_REPO_URL=""40 41# GIT_TOKEN - Git access token42# For GitHub: ghp_xxxx (Personal Access Token with repo scope)43# For HF: hf_xxxx (HF Token with write access)44GIT_TOKEN=""45 46# GIT_BRANCH - Branch to sync (default: main)47GIT_BRANCH="main"48 49# GIT_SYNC_INTERVAL - Sync interval in seconds (default: 300 = 5 minutes)50GIT_SYNC_INTERVAL=30051 52# CLIProxyAPI Configuration53# =========================54# Enable CLIProxyAPI (true/false)55ENABLE_PROXY="true"56 57# Proxy port (default: 8080)58PROXY_PORT=808059 60# Management API port (default: 8081)61MANAGEMENT_PORT=808162 63# Management key for API access64MANAGEMENT_KEY=""65 66# Sync Configuration67# ==================68# Files to exclude from sync (space-separated)69SYNC_EXCLUDE="node_modules .git __pycache__ *.pyc .env *.log .cache tmp"70 71# Auto-commit message prefix72COMMIT_PREFIX="[HF-Space]"73 74EOF75    echo "Created default config.env"76fi77 78# 创建 .gitignore79if [ ! -f "${WORK_DIR}/.gitignore" ]; then80    cat > "${WORK_DIR}/.gitignore" << 'EOF'81# Dependencies82node_modules/83__pycache__/84*.pyc85.pyo86.pyd87 88# Environment89.env90.env.local91.env.*.local92 93# IDE94.idea/95.vscode/96*.swp97*.swo98 99# Logs100*.log101logs/102 103# Cache104.cache/105tmp/106temp/107 108# OS109.DS_Store110Thumbs.db111 112# Build113dist/114build/115*.egg-info/116 117# Secrets (never commit these)118*.pem119*.key120secrets/121EOF122    echo "Created .gitignore"123fi124 125# 创建 CLAUDE.md 项目规则模板126if [ ! -f "${WORK_DIR}/CLAUDE.md" ]; then127    cat > "${WORK_DIR}/CLAUDE.md" << 'EOF'128# Claude Code Project Rules129 130This file contains project-specific rules for Claude Code.131 132## Project Information133 134- **Environment**: Hugging Face Spaces135- **Workspace**: /workspace136- **Persistence**: Git-based sync137 138## Coding Standards139 140- Follow existing code style141- Write clear commit messages142- Document complex logic143 144## Important Notes145 146- Sensitive files (API keys, tokens) are stored in environment variables147- Changes are automatically synced to the configured Git repository148- Use `git-sync` command for manual sync operations149 150## Available Commands151 152- `git-sync push` - Force push changes to remote153- `git-sync pull` - Pull latest changes from remote154- `git-sync status` - Check sync status155- `status` - Show system status156- `help` - Show available commands157 158EOF159    echo "Created CLAUDE.md"160fi161 162# 初始化工作目录 Git 仓库163if [ ! -d "${WORK_DIR}/.git" ]; then164    cd "${WORK_DIR}"165    git init166    echo "Initialized Git repository in workspace"167fi168 169echo "=== Configuration Initialization Complete ==="170