Skip to content

Commit c5c36a2

Browse files
catlog22claude
andcommitted
fix: Optimize version command API calls and data extraction
- Change API endpoint from /branches/main to /commits/main for reliable commit info - Add 30-second timeout to all network calls for slow connections - Extract release name and published date from latest release - Extract commit message (first line only) using improved parsing - Add commit date extraction from main branch - Update documentation with API endpoints and timeout configuration - Fix commit message extraction to handle JSON escape sequences 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent a03415b commit c5c36a2

File tree

1 file changed

+60
-11
lines changed

1 file changed

+60
-11
lines changed

.claude/commands/version.md

Lines changed: 60 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,36 +76,60 @@ Installed: 2025-10-03T12:00:00Z
7676

7777
## Step 3: Fetch Latest Stable Release
7878

79-
### Call GitHub API for latest release
79+
### Call GitHub API for latest release (with timeout)
8080
```bash
81-
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/releases/latest" 2>/dev/null)
81+
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/releases/latest" 2>/dev/null, timeout: 30000)
8282
```
8383

8484
### Extract tag name (version)
8585
```bash
86-
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/releases/latest" 2>/dev/null | grep -o '"tag_name": *"[^"]*"' | head -1 | cut -d'"' -f4)
86+
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/releases/latest" 2>/dev/null | grep -o '"tag_name": *"[^"]*"' | head -1 | cut -d'"' -f4, timeout: 30000)
87+
```
88+
89+
### Extract release name
90+
```bash
91+
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/releases/latest" 2>/dev/null | grep -o '"name": *"[^"]*"' | head -1 | cut -d'"' -f4, timeout: 30000)
92+
```
93+
94+
### Extract published date
95+
```bash
96+
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/releases/latest" 2>/dev/null | grep -o '"published_at": *"[^"]*"' | cut -d'"' -f4, timeout: 30000)
8797
```
8898

8999
**Output Format**:
90100
```
91101
Latest Stable: v3.2.2
102+
Release: v3.2.2: Independent Test-Gen Workflow with Cross-Session Context
103+
Published: 2025-10-03T04:10:08Z
92104
```
93105

94106
## Step 4: Fetch Latest Main Branch
95107

96-
### Call GitHub API for main branch
108+
### Call GitHub API for latest commit on main (with timeout)
97109
```bash
98-
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/branches/main" 2>/dev/null)
110+
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/commits/main" 2>/dev/null, timeout: 30000)
99111
```
100112

101113
### Extract commit SHA (short)
102114
```bash
103-
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/branches/main" 2>/dev/null | grep -o '"sha": *"[^"]*"' | head -1 | cut -d'"' -f4 | cut -c1-7)
115+
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/commits/main" 2>/dev/null | grep -o '"sha": *"[^"]*"' | head -1 | cut -d'"' -f4 | cut -c1-7, timeout: 30000)
116+
```
117+
118+
### Extract commit message (first line only)
119+
```bash
120+
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/commits/main" 2>/dev/null | grep '"message":' | cut -d'"' -f4 | cut -d'\' -f1, timeout: 30000)
121+
```
122+
123+
### Extract commit date
124+
```bash
125+
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/commits/main" 2>/dev/null | grep -o '"date": *"[^"]*"' | head -1 | cut -d'"' -f4, timeout: 30000)
104126
```
105127

106128
**Output Format**:
107129
```
108-
Latest Dev: a1b2c3d
130+
Latest Dev: a03415b
131+
Message: feat: Add version tracking and upgrade check system
132+
Date: 2025-10-03T04:46:44Z
109133
```
110134

111135
## Step 5: Compare Versions and Suggest Upgrade
@@ -166,11 +190,23 @@ bash(cat version.json | grep -o '"version": *"[^"]*"' | cut -d'"' -f4)
166190
# Extract date from JSON
167191
bash(cat version.json | grep -o '"installation_date_utc": *"[^"]*"' | cut -d'"' -f4)
168192

169-
# Fetch latest release
170-
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/releases/latest")
193+
# Fetch latest release (with timeout)
194+
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/releases/latest" 2>/dev/null, timeout: 30000)
171195

172196
# Extract tag name
173-
bash(curl -s https://api.github.com/repos/catlog22/Claude-Code-Workflow/releases/latest | grep -o '"tag_name": *"[^"]*"' | cut -d'"' -f4)
197+
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/releases/latest" 2>/dev/null | grep -o '"tag_name": *"[^"]*"' | cut -d'"' -f4, timeout: 30000)
198+
199+
# Extract release name
200+
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/releases/latest" 2>/dev/null | grep -o '"name": *"[^"]*"' | head -1 | cut -d'"' -f4, timeout: 30000)
201+
202+
# Fetch latest commit (with timeout)
203+
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/commits/main" 2>/dev/null, timeout: 30000)
204+
205+
# Extract commit SHA
206+
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/commits/main" 2>/dev/null | grep -o '"sha": *"[^"]*"' | head -1 | cut -d'"' -f4 | cut -c1-7, timeout: 30000)
207+
208+
# Extract commit message (first line)
209+
bash(curl -fsSL "https://api.github.com/repos/catlog22/Claude-Code-Workflow/commits/main" 2>/dev/null | grep '"message":' | cut -d'"' -f4 | cut -d'\' -f1, timeout: 30000)
174210

175211
# Compare versions
176212
bash(printf "%s\n%s" "3.2.1" "3.2.2" | sort -V | tail -n 1)
@@ -204,8 +240,21 @@ ERROR: version.json is invalid or corrupted
204240
- Uses simple, direct bash commands instead of complex functions
205241
- Each step is independent and can be executed separately
206242
- Fallback to grep/sed for JSON parsing (no jq dependency required)
207-
- Network calls use curl with error suppression
243+
- Network calls use curl with error suppression and 30-second timeout
208244
- Version comparison uses `sort -V` for accurate semantic versioning
245+
- Use `/commits/main` API instead of `/branches/main` for more reliable commit info
246+
- Extract first line of commit message using `cut -d'\' -f1` to handle JSON escape sequences
247+
248+
## API Endpoints
249+
250+
### GitHub API Used
251+
- **Latest Release**: `https://api.github.com/repos/catlog22/Claude-Code-Workflow/releases/latest`
252+
- Fields: `tag_name`, `name`, `published_at`
253+
- **Latest Commit**: `https://api.github.com/repos/catlog22/Claude-Code-Workflow/commits/main`
254+
- Fields: `sha`, `commit.message`, `commit.author.date`
255+
256+
### Timeout Configuration
257+
All network calls should use `timeout: 30000` (30 seconds) to handle slow connections.
209258

210259
## Related Commands
211260
- `/cli:cli-init` - Initialize CLI configurations

0 commit comments

Comments
 (0)