feat: implement bootstrap conversion and installer updates (Phase 1-3)

Phase 1 - Bootstrap Scripts:
- Convert lib/ccs to 32-line bootstrap (was 1919 lines)
- Convert lib/ccs.ps1 to 39-line bootstrap (was 1826 lines)
- Delegate all functionality to Node.js via npx

Phase 2 - Help Text Updates:
- Add Requirements section to Node.js help (lines 172-175)
- Bootstrap scripts delegate --help to npx

Phase 3 - Installer Updates:
- Add Node.js 14+ detection with clear warning messages
- Remove deprecated shell deps (bootstrap handles all)
- Update completion messages with Requirements/First Run sections
- Update docs with new architecture

Total code reduction: 3745 → 71 lines (98.1%)
This commit is contained in:
kaitranntt committed 2025-11-27 10:24:37 -05:00
1 parent d56df0a95e
commit 046a37b2a9
8 files changed
+181 -3816

No files matched your search

+6
View File
@@ -740,4 +740,10 @@ These code standards ensure the CCS codebase remains:
- **Subsystem organization**: Clear separation (auth, delegation, glmt, management, utils)
- **Naming conventions**: handler, executor, manager, validator, formatter, parser suffixes
**v4.5.0 Installation Standards**:
- **Bootstrap-based installers**: Native shell wrappers delegate to Node.js via npx
- **Node.js requirement**: 14+ required (checked during install)
- **No shell dependencies**: error-codes.sh, progress-indicator.sh, prompt.sh removed
- **First-run bootstrap**: Auto-installs @kaitranntt/ccs npm package globally
Following these standards helps maintain the quality, modularity, and extensibility of the v4.x architecture while enabling future development with AI delegation, shared data management, and comprehensive diagnostics.
+6 -4
View File
@@ -1,21 +1,23 @@
# CCS Codebase Summary (v4.3.2)
# CCS Codebase Summary (v4.5.0)
## Overview
CCS (Claude Code Switch) v4.3.2 is a lightweight CLI wrapper enabling instant profile switching between Claude Sonnet 4.5, GLM 4.6, GLMT (GLM with Thinking), and Kimi for Coding models. Version 4.x introduces AI-powered delegation, selective .claude/ directory symlinking, stream-JSON output, and enhanced shell completion.
CCS (Claude Code Switch) v4.5.0 is a lightweight CLI wrapper enabling instant profile switching between Claude Sonnet 4.5, GLM 4.6, GLMT (GLM with Thinking), and Kimi for Coding models. Version 4.x introduces AI-powered delegation, selective .claude/ directory symlinking, stream-JSON output, and enhanced shell completion. v4.5.0 completes transition to Node.js-first architecture with bootstrap-based installers.
## Version Evolution
### v4.3.2 Architecture (Current)
### v4.5.0 Architecture (Current)
- **Total LOC**: ~8,477 lines (JavaScript only)
- **Key Features**: AI delegation, stream-JSON output, shell completion, doctor diagnostics, sync command
- **New Components**: delegation/, utils/claude-symlink-manager.js, utils/delegation-validator.js, utils/update-checker.js
- **Architecture**: Modular design with clear separation: auth/, delegation/, glmt/, management/, utils/
- **Installation**: Bootstrap-based native installers (requires Node.js 14+, no shell dependencies)
### Evolution Summary
- **v2.x**: Vault-based credential encryption (~1,700 LOC)
- **v3.0**: Vault removal, login-per-profile (~1,100 LOC, 40% reduction)
- **v4.0-4.3.2**: Delegation system, .claude/ sharing, stream-JSON (~8,477 LOC including tests/utils)
- **v4.0-4.4.x**: Delegation system, .claude/ sharing, stream-JSON (~8,477 LOC including tests/utils)
- **v4.5.0**: Bootstrap-based installers, TypeScript npm package with quality gates
## Core Components (v4.3.2)
+17 -1
View File
@@ -2,7 +2,7 @@
## Overview
CCS (Claude Code Switch) is a lightweight CLI wrapper that provides instant profile switching between Claude Sonnet 4.5, GLM 4.6, GLMT (GLM with Thinking), and Kimi for Coding models. Current version **v4.3.2** features AI-powered delegation system, selective .claude/ directory symlinking, stream-JSON output, shell completion (4 shells), and comprehensive diagnostics (doctor, sync, update commands).
CCS (Claude Code Switch) is a lightweight CLI wrapper that provides instant profile switching between Claude Sonnet 4.5, GLM 4.6, GLMT (GLM with Thinking), and Kimi for Coding models. Current version **v4.5.0** features AI-powered delegation system, selective .claude/ directory symlinking, stream-JSON output, shell completion (4 shells), and comprehensive diagnostics (doctor, sync, update commands). v4.5.0 completes transition to Node.js-first architecture with bootstrap-based installers.
## Core Architecture Principles
@@ -997,6 +997,9 @@ graph LR
### Installation Process
**Two installation methods available:**
**Method 1: npm Package (Recommended)**
1. **Package Download**: User installs via npm/yarn/pnpm/bun
2. **Post-install Script** (`scripts/postinstall.js`):
- Creates `~/.ccs/` directory structure
@@ -1013,6 +1016,19 @@ graph LR
3. **Path Configuration**: npm automatically adds to PATH
4. **Ready State**: System ready for profile switching
**Method 2: Native Installers (v4.5.0)**
1. **Requirements Check**: Validates Node.js 14+ available
2. **Bootstrap Installation**:
- Installs lightweight shell wrappers (lib/ccs, lib/ccs.ps1)
- Shell wrappers delegate to Node.js via npx on first run
- No shell dependencies (error-codes, progress-indicator, prompt removed)
3. **First Run**: Bootstrap auto-installs @kaitranntt/ccs npm package globally
4. **Completion Message**: Shows requirements section with Node.js version
**Requirements (v4.5.0+)**:
- Node.js 14+ (checked during install, enforced by bootstrap)
- npm 5.2+ (for npx, comes with Node.js 8.2+)
**Idempotency**: Safe to run multiple times, preserves existing configs
**Migration Logic** (v3.3.0):
+55 -58
View File
@@ -1,4 +1,6 @@
# CCS Installation Script (Windows PowerShell)
# CCS Installation Script (v4.5.0) - Windows PowerShell
# Bootstrap-based: Installs lightweight shell wrappers that delegate to Node.js
# Requires: Node.js 14+ (checked during install, enforced by bootstrap)
# https://github.com/kaitranntt/ccs
param(
@@ -85,6 +87,42 @@ function Write-Section {
Write-Host ""
}
# --- Node.js Detection (v4.5) ---
function Test-NodeJs {
$MIN_VERSION = 14
if (-not (Get-Command node -ErrorAction SilentlyContinue)) {
Write-WarningMsg @"
Node.js not found
CCS v4.5+ requires Node.js 14+ to run.
The bootstrap scripts will check and install the npm package on first use.
Install Node.js: https://nodejs.org (LTS recommended)
Installation will continue, but 'ccs' will not work until Node.js is installed.
"@
return $false
}
$nodeVersion = (node -v) -replace 'v', ''
$nodeMajor = [int]($nodeVersion -split '\.')[0]
if ($nodeMajor -lt $MIN_VERSION) {
Write-WarningMsg @"
Node.js 14+ required (found: $(node -v))
CCS v4.5+ requires Node.js 14 or newer.
Upgrade from: https://nodejs.org
Installation will continue, but 'ccs' may not work correctly.
"@
return $false
}
Write-Success "Node.js $(node -v) detected"
return $true
}
# Helper Functions
function Detect-CurrentProvider {
@@ -261,6 +299,9 @@ function Install-ClaudeFolder {
# Main Installation
# Check Node.js requirement (warn if missing, continue anyway)
$null = Test-NodeJs
Write-Host '===== Installing CCS (Windows) ====='
# Create directories
@@ -276,32 +317,8 @@ if ($InstallMethod -eq "standalone") {
Invoke-WebRequest -Uri "$BaseUrl/lib/ccs.ps1" -OutFile "$CcsDir\ccs.ps1" -UseBasicParsing
Write-Host "| [OK] Downloaded ccs.ps1"
# Download required dependencies
$LibDir = "$CcsDir\lib"
if (-not (Test-Path $LibDir)) {
New-Item -ItemType Directory -Path $LibDir -Force | Out-Null
}
try {
Invoke-WebRequest -Uri "$BaseUrl/lib/error-codes.ps1" -OutFile "$LibDir\error-codes.ps1" -UseBasicParsing
Write-Host "| [OK] Downloaded error-codes.ps1"
} catch {
Write-Host "| [!] Warning: Failed to download error-codes.ps1"
}
try {
Invoke-WebRequest -Uri "$BaseUrl/lib/progress-indicator.ps1" -OutFile "$LibDir\progress-indicator.ps1" -UseBasicParsing
Write-Host "| [OK] Downloaded progress-indicator.ps1"
} catch {
Write-Host "| [!] Warning: Failed to download progress-indicator.ps1"
}
try {
Invoke-WebRequest -Uri "$BaseUrl/lib/prompt.ps1" -OutFile "$LibDir\prompt.ps1" -UseBasicParsing
Write-Host "| [OK] Downloaded prompt.ps1"
} catch {
Write-Host "| [!] Warning: Failed to download prompt.ps1"
}
# Note: Shell dependencies (error-codes.ps1, progress-indicator.ps1, prompt.ps1) no longer needed
# Bootstrap delegates all functionality to Node.js via npx
# Download shell completion files
$CompletionsDir = "$CcsDir\completions"
@@ -333,36 +350,8 @@ if ($InstallMethod -eq "standalone") {
Copy-Item $CcsPs1Path "$CcsDir\ccs.ps1" -Force
Write-Host "| [OK] Installed ccs.ps1"
# Copy required dependencies
$LibDir = "$CcsDir\lib"
if (-not (Test-Path $LibDir)) {
New-Item -ItemType Directory -Path $LibDir -Force | Out-Null
}
$SourceLibDir = if (Test-Path "$ScriptDir\lib") {
"$ScriptDir\lib"
} elseif (Test-Path "$ScriptDir\..\lib") {
"$ScriptDir\..\lib"
} else {
$null
}
if ($SourceLibDir) {
if (Test-Path "$SourceLibDir\error-codes.ps1") {
Copy-Item "$SourceLibDir\error-codes.ps1" "$LibDir\error-codes.ps1" -Force
Write-Host "| [OK] Copied error-codes.ps1"
}
if (Test-Path "$SourceLibDir\progress-indicator.ps1") {
Copy-Item "$SourceLibDir\progress-indicator.ps1" "$LibDir\progress-indicator.ps1" -Force
Write-Host "| [OK] Copied progress-indicator.ps1"
}
if (Test-Path "$SourceLibDir\prompt.ps1") {
Copy-Item "$SourceLibDir\prompt.ps1" "$LibDir\prompt.ps1" -Force
Write-Host "| [OK] Copied prompt.ps1"
}
}
# Note: Shell dependencies (error-codes.ps1, progress-indicator.ps1, prompt.ps1) no longer needed
# Bootstrap delegates all functionality to Node.js via npx
# Copy shell completion files
$CompletionsDir = "$CcsDir\completions"
@@ -751,11 +740,19 @@ Write-Host " * glm profile -> $CcsDir\glm.settings.json"
Write-Host " * kimi profile -> $CcsDir\kimi.settings.json"
Write-Host " * .claude/ folder -> $CcsDir\.claude\"
Write-Host ""
Write-Host " Requirements:"
$nodeVer = if (Get-Command node -ErrorAction SilentlyContinue) { node -v } else { "NOT FOUND" }
Write-Host " * Node.js 14+ (detected: $nodeVer)"
Write-Host " * npm 5.2+ (for npx, comes with Node.js 8.2+)"
Write-Host ""
Write-Host " First Run:"
Write-Host " The first time you run 'ccs', it will automatically install"
Write-Host " the @kaitranntt/ccs npm package globally via npx."
Write-Host ""
Write-Host " Quick start:"
Write-Host " ccs # Use Claude subscription (default)"
Write-Host " ccs glm # Use GLM fallback"
Write-Host " ccs kimi # Use Kimi for Coding"
Write-Host ""
Write-Host ""
Write-Host " To uninstall: ccs-uninstall"
Write-Host ""
+48 -37
View File
@@ -2,7 +2,9 @@
set -euo pipefail
# ============================================================================
# CCS Installation Script
# CCS Installation Script (v4.5.0)
# Bootstrap-based: Installs lightweight shell wrappers that delegate to Node.js
# Requires: Node.js 14+ (checked during install, enforced by bootstrap)
# ============================================================================
# --- Configuration ---
@@ -139,6 +141,36 @@ msg_section() {
setup_colors
# --- Node.js Detection (v4.5) ---
check_nodejs() {
if ! command -v node &> /dev/null; then
msg_warning "Node.js not found
CCS v4.5+ requires Node.js 14+ to run.
The bootstrap scripts will check and install the npm package on first use.
Install Node.js: https://nodejs.org (LTS recommended)
Installation will continue, but 'ccs' will not work until Node.js is installed."
return 1
fi
local node_major
node_major=$(node -v | cut -d'v' -f2 | cut -d'.' -f1)
if [[ $node_major -lt 14 ]]; then
msg_warning "Node.js 14+ required (found: $(node -v))
CCS v4.5+ requires Node.js 14 or newer.
Upgrade from: https://nodejs.org
Installation will continue, but 'ccs' may not work correctly."
return 1
fi
msg_success "Node.js $(node -v) detected"
return 0
}
# --- Shell Profile Management ---
detect_shell_profile() {
@@ -456,6 +488,9 @@ create_kimi_profile() {
# --- Main Installation ---
# Check Node.js requirement (warn if missing, continue anyway)
check_nodejs || true
echo "┌─ Installing CCS"
# Create directories
@@ -482,25 +517,8 @@ if [[ "$INSTALL_METHOD" == "standalone" ]]; then
exit 1
fi
# Download required dependencies
mkdir -p "$CCS_DIR/lib"
if curl -fsSL "$BASE_URL/lib/error-codes.sh" -o "$CCS_DIR/lib/error-codes.sh" 2>/dev/null; then
echo "| [OK] Downloaded error-codes.sh"
else
echo "| [!] Warning: Failed to download error-codes.sh"
fi
if curl -fsSL "$BASE_URL/lib/progress-indicator.sh" -o "$CCS_DIR/lib/progress-indicator.sh" 2>/dev/null; then
echo "| [OK] Downloaded progress-indicator.sh"
else
echo "| [!] Warning: Failed to download progress-indicator.sh"
fi
if curl -fsSL "$BASE_URL/lib/prompt.sh" -o "$CCS_DIR/lib/prompt.sh" 2>/dev/null; then
echo "| [OK] Downloaded prompt.sh"
else
echo "| [!] Warning: Failed to download prompt.sh"
fi
# Note: Shell dependencies (error-codes.sh, progress-indicator.sh, prompt.sh) no longer needed
# Bootstrap delegates all functionality to Node.js via npx
# Download shell completion files
mkdir -p "$CCS_DIR/completions"
@@ -528,22 +546,8 @@ else
fi
echo "| [OK] Installed executable"
# Copy required dependencies
mkdir -p "$CCS_DIR/lib"
if [[ -f "$LIB_DIR/error-codes.sh" ]]; then
cp "$LIB_DIR/error-codes.sh" "$CCS_DIR/lib/error-codes.sh"
echo "| [OK] Copied error-codes.sh"
fi
if [[ -f "$LIB_DIR/progress-indicator.sh" ]]; then
cp "$LIB_DIR/progress-indicator.sh" "$CCS_DIR/lib/progress-indicator.sh"
echo "| [OK] Copied progress-indicator.sh"
fi
if [[ -f "$LIB_DIR/prompt.sh" ]]; then
cp "$LIB_DIR/prompt.sh" "$CCS_DIR/lib/prompt.sh"
echo "| [OK] Copied prompt.sh"
fi
# Note: Shell dependencies (error-codes.sh, progress-indicator.sh, prompt.sh) no longer needed
# Bootstrap delegates all functionality to Node.js via npx
# Copy shell completion files
mkdir -p "$CCS_DIR/completions"
@@ -856,11 +860,18 @@ echo " * glm profile -> ~/.ccs/glm.settings.json"
echo " * kimi profile -> ~/.ccs/kimi.settings.json"
echo " * .claude/ folder -> ~/.ccs/.claude/"
echo ""
echo " Requirements:"
echo " * Node.js 14+ (detected: $(node -v 2>/dev/null || echo 'NOT FOUND'))"
echo " * npm 5.2+ (for npx, comes with Node.js 8.2+)"
echo ""
echo " First Run:"
echo " The first time you run 'ccs', it will automatically install"
echo " the @kaitranntt/ccs npm package globally via npx."
echo ""
echo " Quick start:"
echo " ccs # Use Claude subscription (default)"
echo " ccs glm # Use GLM fallback"
echo " ccs kimi # Use Kimi for Coding"
echo ""
echo ""
echo " To uninstall: ccs-uninstall"
echo ""
+21 -1907
View File
File diff suppressed because it is too large. Load diff
+23 -1809
View File
File diff suppressed because it is too large. Load diff
+5
View File
@@ -169,6 +169,11 @@ function handleHelpCommand(): void {
console.log(' with auto-recovery. Zero downtime.');
console.log('');
console.log(colored('Requirements:', 'cyan'));
console.log(' Node.js 14+ (detected automatically by bootstrap)');
console.log(' npm 5.2+ (for npx, comes with Node.js 8.2+)');
console.log('');
console.log(colored('Model Switching:', 'cyan'));
console.log(` ${colored('ccs', 'yellow')} Use default Claude account`);
console.log(` ${colored('ccs glm', 'yellow')} Switch to GLM 4.6 model`);