Skip to content

Commit 9a49a86

Browse files
catlog22claude
andcommitted
feat: Implement dynamic version detection and passing system
**Installation System Updates**: - install-remote.ps1: Auto-detect version from GitHub API and pass to installer - Install-Claude.ps1: Accept dynamic version via -SourceVersion parameter - install-remote.sh: Synchronize version detection logic with PowerShell version - Add installer_version field to version.json for tracking **Codex Agent Optimization** (.codex/AGENTS.md): - Add system optimization requirements for direct binary execution - Prioritize apply_patch tool over Python scripts for file editing - Add Windows UTF-8 encoding configuration for Chinese character support **Version Flow**: 1. install-remote.* detects version from GitHub API (latest release tag) 2. Passes version to Install-Claude.* via -SourceVersion/-SourceBranch 3. Installer writes accurate version to version.json 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 25a453d commit 9a49a86

File tree

3 files changed

+82
-8
lines changed

3 files changed

+82
-8
lines changed

Install-Claude.ps1

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ if ($PSVersionTable.PSVersion.Major -ge 6) {
7878

7979
# Script metadata
8080
$ScriptName = "Claude Code Workflow System Installer"
81-
$Version = "2.1.0"
81+
$ScriptVersion = "2.2.0" # Installer script version
82+
83+
# Default version (will be overridden by -SourceVersion from install-remote.ps1)
84+
$DefaultVersion = "unknown"
8285

8386
# Initialize backup behavior - backup is enabled by default unless NoBackup is specified
8487
if (-not $BackupAll -and -not $NoBackup) {
@@ -141,8 +144,15 @@ function Show-Banner {
141144
}
142145

143146
function Show-Header {
147+
param(
148+
[string]$InstallVersion = $DefaultVersion
149+
)
150+
144151
Show-Banner
145-
Write-ColorOutput " $ScriptName v$Version" $ColorInfo
152+
Write-ColorOutput " $ScriptName v$ScriptVersion" $ColorInfo
153+
if ($InstallVersion -ne "unknown") {
154+
Write-ColorOutput " Installing Claude Code Workflow v$InstallVersion" $ColorInfo
155+
}
146156
Write-ColorOutput " Unified workflow system with comprehensive coordination" $ColorInfo
147157
Write-ColorOutput "========================================================================" $ColorInfo
148158
if ($NoBackup) {
@@ -638,8 +648,8 @@ function Create-VersionJson {
638648
[string]$InstallationMode
639649
)
640650

641-
# Determine version from source or default
642-
$versionNumber = if ($SourceVersion) { $SourceVersion } else { $Version }
651+
# Determine version from source parameter (passed from install-remote.ps1)
652+
$versionNumber = if ($SourceVersion) { $SourceVersion } else { $DefaultVersion }
643653
$sourceBranch = if ($SourceBranch) { $SourceBranch } else { "unknown" }
644654

645655
# Create version.json content
@@ -649,6 +659,7 @@ function Create-VersionJson {
649659
installation_path = $TargetClaudeDir
650660
installation_date_utc = (Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
651661
source_branch = $sourceBranch
662+
installer_version = $ScriptVersion
652663
}
653664

654665
$versionJsonPath = Join-Path $TargetClaudeDir "version.json"
@@ -1024,7 +1035,10 @@ function Show-Summary {
10241035
}
10251036

10261037
function Main {
1027-
Show-Header
1038+
# Use SourceVersion parameter if provided, otherwise use default
1039+
$installVersion = if ($SourceVersion) { $SourceVersion } else { $DefaultVersion }
1040+
1041+
Show-Header -InstallVersion $installVersion
10281042

10291043
# Test prerequisites
10301044
Write-ColorOutput "Checking system requirements..." $ColorInfo

install-remote.ps1

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,23 @@ function Main {
563563
}
564564

565565
# Determine version and branch information to pass
566-
$versionToPass = if ($Tag) { $Tag } else { "latest" }
566+
$versionToPass = ""
567+
if ($Tag) {
568+
# Specific tag version
569+
$versionToPass = $Tag -replace '^v', '' # Remove 'v' prefix
570+
} elseif ($Version -eq "stable") {
571+
# Auto-detected latest stable
572+
$latestTag = Get-LatestRelease
573+
if ($latestTag) {
574+
$versionToPass = $latestTag -replace '^v', ''
575+
} else {
576+
$versionToPass = "latest"
577+
}
578+
} else {
579+
# Latest development or branch
580+
$versionToPass = "latest"
581+
}
582+
567583
$branchToPass = if ($Version -eq "branch") { $Branch } elseif ($Version -eq "latest") { "main" } elseif ($Tag) { $Tag } else { "main" }
568584

569585
Write-ColorOutput "Version info: $versionToPass (branch: $branchToPass)" $ColorInfo

install-remote.sh

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,8 @@ function extract_repository() {
209209

210210
function invoke_local_installer() {
211211
local repo_dir="$1"
212+
local version_info="$2"
213+
local branch_info="$3"
212214
local installer_path="${repo_dir}/Install-Claude.sh"
213215

214216
# Make installer executable
@@ -249,6 +251,15 @@ function invoke_local_installer() {
249251
params+=("-BackupAll")
250252
fi
251253

254+
# Pass version and branch information
255+
if [ -n "$version_info" ]; then
256+
params+=("-SourceVersion" "$version_info")
257+
fi
258+
259+
if [ -n "$branch_info" ]; then
260+
params+=("-SourceBranch" "$branch_info")
261+
fi
262+
252263
# Execute installer
253264
if (cd "$repo_dir" && "$installer_path" "${params[@]}"); then
254265
return 0
@@ -632,8 +643,41 @@ function main() {
632643
if [ $extract_status -eq 0 ] && [ -n "$repo_dir" ] && [ -d "$repo_dir" ]; then
633644
write_color "Extraction successful: $repo_dir" "$COLOR_SUCCESS"
634645

635-
# Run local installer
636-
if invoke_local_installer "$repo_dir"; then
646+
# Determine version and branch information to pass
647+
local version_to_pass=""
648+
local branch_to_pass=""
649+
650+
if [ -n "$TAG_VERSION" ]; then
651+
# Specific tag version - remove 'v' prefix
652+
version_to_pass="${TAG_VERSION#v}"
653+
elif [ "$VERSION_TYPE" = "stable" ]; then
654+
# Auto-detected latest stable
655+
local latest_tag
656+
latest_tag=$(get_latest_release)
657+
if [ -n "$latest_tag" ]; then
658+
version_to_pass="${latest_tag#v}"
659+
else
660+
version_to_pass="latest"
661+
fi
662+
else
663+
# Latest development or branch
664+
version_to_pass="latest"
665+
fi
666+
667+
if [ "$VERSION_TYPE" = "branch" ]; then
668+
branch_to_pass="$BRANCH"
669+
elif [ "$VERSION_TYPE" = "latest" ]; then
670+
branch_to_pass="main"
671+
elif [ -n "$TAG_VERSION" ]; then
672+
branch_to_pass="$TAG_VERSION"
673+
else
674+
branch_to_pass="main"
675+
fi
676+
677+
write_color "Version info: $version_to_pass (branch: $branch_to_pass)" "$COLOR_INFO"
678+
679+
# Run local installer with version information
680+
if invoke_local_installer "$repo_dir" "$version_to_pass" "$branch_to_pass"; then
637681
success=true
638682
echo ""
639683
write_color "✓ Remote installation completed successfully!" "$COLOR_SUCCESS"

0 commit comments

Comments
 (0)