mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-12 02:37:45 +08:00
refactor(commands): replace bash/jq operations with ccw session commands
- session/start.md: Replace find/mkdir/echo with ccw session list/init - session/list.md: Replace find/jq with ccw session list/stats/read - session/resume.md: Replace jq status updates with ccw session status - session/complete.md: Replace jq/mv with ccw session archive - execute.md: Replace session discovery with ccw session list/status - code-developer.md: Replace jq context-package read with ccw session read Benefits: - Atomic operations (no temp files) - Auto workspace detection (works from subdirectories) - Auto session location detection (active/archived/lite) - Status history auto-tracking for tasks - Consistent error handling 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -25,17 +25,15 @@ Mark the currently active workflow session as complete, analyze it for lessons l
|
||||
|
||||
#### Step 1.1: Find Active Session and Get Name
|
||||
```bash
|
||||
# Find active session directory
|
||||
bash(find .workflow/active/ -name "WFS-*" -type d | head -1)
|
||||
|
||||
# Extract session name from directory path
|
||||
bash(basename .workflow/active/WFS-session-name)
|
||||
# Find active session
|
||||
ccw session list --location active
|
||||
# Extract first session_id from result.active array
|
||||
```
|
||||
**Output**: Session name `WFS-session-name`
|
||||
|
||||
#### Step 1.2: Check for Existing Archiving Marker (Resume Detection)
|
||||
```bash
|
||||
# Check if session is already being archived
|
||||
# Check if session is already being archived (marker file exists)
|
||||
bash(test -f .workflow/active/WFS-session-name/.archiving && echo "RESUMING" || echo "NEW")
|
||||
```
|
||||
|
||||
@@ -161,26 +159,17 @@ Analyze workflow session for archival preparation. Session is STILL in active lo
|
||||
|
||||
**Purpose**: Atomically commit all changes. Only execute if Phase 2 succeeds.
|
||||
|
||||
#### Step 3.1: Create Archive Directory
|
||||
#### Step 3.1: Update Session Status and Archive
|
||||
```bash
|
||||
bash(mkdir -p .workflow/archives/)
|
||||
```
|
||||
|
||||
#### Step 3.2: Update Session Status to Completed
|
||||
**Purpose**: Update workflow-session.json status to "completed" for dashboard display.
|
||||
|
||||
```bash
|
||||
# Update status atomically using jq
|
||||
bash(jq '.status = "completed"' .workflow/active/WFS-session-name/workflow-session.json > /tmp/ws.json && mv /tmp/ws.json .workflow/active/WFS-session-name/workflow-session.json)
|
||||
```
|
||||
|
||||
#### Step 3.3: Move Session to Archive
|
||||
```bash
|
||||
bash(mv .workflow/active/WFS-session-name .workflow/archives/WFS-session-name)
|
||||
# Archive session (updates status to "completed" and moves to archives)
|
||||
ccw session archive WFS-session-name
|
||||
# This operation atomically:
|
||||
# 1. Updates workflow-session.json status to "completed"
|
||||
# 2. Moves session from .workflow/active/ to .workflow/archives/
|
||||
```
|
||||
**Result**: Session now at `.workflow/archives/WFS-session-name/`
|
||||
|
||||
#### Step 3.4: Update Manifest
|
||||
#### Step 3.2: Update Manifest
|
||||
```bash
|
||||
# Read current manifest (or create empty array if not exists)
|
||||
bash(test -f .workflow/archives/manifest.json && cat .workflow/archives/manifest.json || echo "[]")
|
||||
|
||||
@@ -17,41 +17,30 @@ Display all workflow sessions with their current status, progress, and metadata.
|
||||
|
||||
## Implementation Flow
|
||||
|
||||
### Step 1: Find All Sessions
|
||||
### Step 1: List All Sessions
|
||||
```bash
|
||||
ls .workflow/active/WFS-* 2>/dev/null
|
||||
ccw session list --location both
|
||||
```
|
||||
|
||||
### Step 2: Check Active Session
|
||||
### Step 2: Get Session Statistics
|
||||
```bash
|
||||
find .workflow/active/ -name "WFS-*" -type d 2>/dev/null | head -1
|
||||
ccw session stats WFS-session
|
||||
# Returns: tasks count by status, summaries count, has_plan
|
||||
```
|
||||
|
||||
### Step 3: Read Session Metadata
|
||||
```bash
|
||||
jq -r '.session_id, .status, .project' .workflow/active/WFS-session/workflow-session.json
|
||||
ccw session read WFS-session --type session
|
||||
# Returns: session_id, status, project, created_at, etc.
|
||||
```
|
||||
|
||||
### Step 4: Count Task Progress
|
||||
```bash
|
||||
find .workflow/active/WFS-session/.task/ -name "*.json" -type f 2>/dev/null | wc -l
|
||||
find .workflow/active/WFS-session/.summaries/ -name "*.md" -type f 2>/dev/null | wc -l
|
||||
```
|
||||
|
||||
### Step 5: Get Creation Time
|
||||
```bash
|
||||
jq -r '.created_at // "unknown"' .workflow/active/WFS-session/workflow-session.json
|
||||
```
|
||||
|
||||
## Simple Bash Commands
|
||||
## Simple Commands
|
||||
|
||||
### Basic Operations
|
||||
- **List sessions**: `find .workflow/active/ -name "WFS-*" -type d`
|
||||
- **Find active**: `find .workflow/active/ -name "WFS-*" -type d`
|
||||
- **Read session data**: `jq -r '.session_id, .status' session.json`
|
||||
- **Count tasks**: `find .task/ -name "*.json" -type f | wc -l`
|
||||
- **Count completed**: `find .summaries/ -name "*.md" -type f 2>/dev/null | wc -l`
|
||||
- **Get timestamp**: `jq -r '.created_at' session.json`
|
||||
- **List all sessions**: `ccw session list`
|
||||
- **List active only**: `ccw session list --location active`
|
||||
- **Read session data**: `ccw session read WFS-xxx --type session`
|
||||
- **Get task stats**: `ccw session stats WFS-xxx`
|
||||
|
||||
## Simple Output Format
|
||||
|
||||
|
||||
@@ -17,39 +17,35 @@ Resume the most recently paused workflow session, restoring all context and stat
|
||||
|
||||
### Step 1: Find Paused Sessions
|
||||
```bash
|
||||
ls .workflow/active/WFS-* 2>/dev/null
|
||||
ccw session list --location active
|
||||
# Filter for sessions with status="paused"
|
||||
```
|
||||
|
||||
### Step 2: Check Session Status
|
||||
```bash
|
||||
jq -r '.status' .workflow/active/WFS-session/workflow-session.json
|
||||
ccw session read WFS-session --type session
|
||||
# Check .status field in response
|
||||
```
|
||||
|
||||
### Step 3: Find Most Recent Paused
|
||||
```bash
|
||||
ls -t .workflow/active/WFS-*/workflow-session.json | head -1
|
||||
ccw session list --location active
|
||||
# Sort by created_at, filter for paused status
|
||||
```
|
||||
|
||||
### Step 4: Update Session Status
|
||||
### Step 4: Update Session Status to Active
|
||||
```bash
|
||||
jq '.status = "active"' .workflow/active/WFS-session/workflow-session.json > temp.json
|
||||
mv temp.json .workflow/active/WFS-session/workflow-session.json
|
||||
ccw session status WFS-session active
|
||||
# Or with full update:
|
||||
ccw session update WFS-session --type session --content '{"status":"active","resumed_at":"2025-12-10T08:00:00Z"}'
|
||||
```
|
||||
|
||||
### Step 5: Add Resume Timestamp
|
||||
```bash
|
||||
jq '.resumed_at = "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"' .workflow/active/WFS-session/workflow-session.json > temp.json
|
||||
mv temp.json .workflow/active/WFS-session/workflow-session.json
|
||||
```
|
||||
|
||||
## Simple Bash Commands
|
||||
## Simple Commands
|
||||
|
||||
### Basic Operations
|
||||
- **List sessions**: `ls .workflow/active/WFS-*`
|
||||
- **Check status**: `jq -r '.status' session.json`
|
||||
- **Find recent**: `ls -t .workflow/active/*/workflow-session.json | head -1`
|
||||
- **Update status**: `jq '.status = "active"' session.json > temp.json`
|
||||
- **Add timestamp**: `jq '.resumed_at = "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"'`
|
||||
- **List sessions**: `ccw session list --location active`
|
||||
- **Check status**: `ccw session read WFS-xxx --type session`
|
||||
- **Update status**: `ccw session status WFS-xxx active`
|
||||
|
||||
### Resume Result
|
||||
```
|
||||
|
||||
@@ -70,12 +70,12 @@ SlashCommand({command: "/workflow:init"});
|
||||
|
||||
### Step 1: List Active Sessions
|
||||
```bash
|
||||
bash(ls -1 .workflow/active/ 2>/dev/null | head -5)
|
||||
ccw session list --location active
|
||||
```
|
||||
|
||||
### Step 2: Display Session Metadata
|
||||
```bash
|
||||
bash(cat .workflow/active/WFS-promptmaster-platform/workflow-session.json)
|
||||
ccw session read WFS-promptmaster-platform --type session
|
||||
```
|
||||
|
||||
### Step 4: User Decision
|
||||
@@ -92,34 +92,29 @@ Present session information and wait for user to select or create session.
|
||||
|
||||
### Step 1: Check Active Sessions Count
|
||||
```bash
|
||||
bash(find .workflow/active/ -name "WFS-*" -type d 2>/dev/null | wc -l)
|
||||
ccw session list --location active
|
||||
# Check result.total in response
|
||||
```
|
||||
|
||||
### Step 2a: No Active Sessions → Create New
|
||||
```bash
|
||||
# Generate session slug
|
||||
bash(echo "implement OAuth2 auth" | sed 's/[^a-zA-Z0-9]/-/g' | tr '[:upper:]' '[:lower:]' | cut -c1-50)
|
||||
# Generate session slug from description
|
||||
# Pattern: WFS-{lowercase-slug-from-description}
|
||||
|
||||
# Create directory structure
|
||||
bash(mkdir -p .workflow/active/WFS-implement-oauth2-auth/.process)
|
||||
bash(mkdir -p .workflow/active/WFS-implement-oauth2-auth/.task)
|
||||
bash(mkdir -p .workflow/active/WFS-implement-oauth2-auth/.summaries)
|
||||
|
||||
# Create metadata (include type field, default to "workflow" if not specified)
|
||||
bash(echo '{"session_id":"WFS-implement-oauth2-auth","project":"implement OAuth2 auth","status":"planning","type":"workflow","created_at":"2024-12-04T08:00:00Z"}' > .workflow/active/WFS-implement-oauth2-auth/workflow-session.json)
|
||||
# Create session with ccw (creates directories + metadata atomically)
|
||||
ccw session init WFS-implement-oauth2-auth --type workflow --content '{"project":"implement OAuth2 auth","status":"planning"}'
|
||||
```
|
||||
|
||||
**Output**: `SESSION_ID: WFS-implement-oauth2-auth`
|
||||
|
||||
### Step 2b: Single Active Session → Check Relevance
|
||||
```bash
|
||||
# Extract session ID
|
||||
bash(find .workflow/active/ -name "WFS-*" -type d 2>/dev/null | head -1 | xargs basename)
|
||||
# Get session list with metadata
|
||||
ccw session list --location active
|
||||
|
||||
# Read project name from metadata
|
||||
bash(cat .workflow/active/WFS-promptmaster-platform/workflow-session.json | grep -o '"project":"[^"]*"' | cut -d'"' -f4)
|
||||
# Read session metadata for relevance check
|
||||
ccw session read WFS-promptmaster-platform --type session
|
||||
|
||||
# Check keyword match (manual comparison)
|
||||
# If task contains project keywords → Reuse session
|
||||
# If task unrelated → Create new session (use Step 2a)
|
||||
```
|
||||
@@ -129,8 +124,9 @@ bash(cat .workflow/active/WFS-promptmaster-platform/workflow-session.json | grep
|
||||
|
||||
### Step 2c: Multiple Active Sessions → Use First
|
||||
```bash
|
||||
# Get first active session
|
||||
bash(find .workflow/active/ -name "WFS-*" -type d 2>/dev/null | head -1 | xargs basename)
|
||||
# Get first active session from list
|
||||
ccw session list --location active
|
||||
# Use first session_id from result.active array
|
||||
|
||||
# Output warning and session ID
|
||||
# WARNING: Multiple active sessions detected
|
||||
@@ -146,24 +142,15 @@ bash(find .workflow/active/ -name "WFS-*" -type d 2>/dev/null | head -1 | xargs
|
||||
|
||||
### Step 1: Generate Unique Session Slug
|
||||
```bash
|
||||
# Convert to slug
|
||||
bash(echo "fix login bug" | sed 's/[^a-zA-Z0-9]/-/g' | tr '[:upper:]' '[:lower:]' | cut -c1-50)
|
||||
|
||||
# Check if exists, add counter if needed
|
||||
bash(ls .workflow/active/WFS-fix-login-bug 2>/dev/null && echo "WFS-fix-login-bug-2" || echo "WFS-fix-login-bug")
|
||||
# Convert description to slug: lowercase, alphanumeric + hyphen, max 50 chars
|
||||
# Check if exists via ccw session list, add counter if collision
|
||||
ccw session list --location active
|
||||
```
|
||||
|
||||
### Step 2: Create Session Structure
|
||||
```bash
|
||||
bash(mkdir -p .workflow/active/WFS-fix-login-bug/.process)
|
||||
bash(mkdir -p .workflow/active/WFS-fix-login-bug/.task)
|
||||
bash(mkdir -p .workflow/active/WFS-fix-login-bug/.summaries)
|
||||
```
|
||||
|
||||
### Step 3: Create Metadata
|
||||
```bash
|
||||
# Include type field from --type parameter (default: "workflow")
|
||||
bash(echo '{"session_id":"WFS-fix-login-bug","project":"fix login bug","status":"planning","type":"workflow","created_at":"2024-12-04T08:00:00Z"}' > .workflow/active/WFS-fix-login-bug/workflow-session.json)
|
||||
# Single command creates directories (.process, .task, .summaries) + metadata
|
||||
ccw session init WFS-fix-login-bug --type workflow --content '{"project":"fix login bug","status":"planning"}'
|
||||
```
|
||||
|
||||
**Output**: `SESSION_ID: WFS-fix-login-bug`
|
||||
|
||||
Reference in New Issue
Block a user