mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-12 02:37:45 +08:00
Refactor workflow session commands to utilize ccw CLI for session management
- Updated session completion process to use `ccw session` commands for listing, reading, and updating session statuses. - Enhanced session listing command to provide metadata and statistics using `ccw session list` and `ccw session stats`. - Streamlined session resume functionality with `ccw session` commands for checking status and updating session state. - Improved session creation process by replacing manual directory and metadata handling with `ccw session init`. - Introduced `session_manager` tool for simplified session operations, including listing, updating, and archiving sessions. - Updated conflict resolution tools to generate structured output in `conflict-resolution.json` instead of markdown files. - Enhanced TDD and UI design tools to utilize `ccw cli exec` for executing analysis commands, improving integration with the workflow.
This commit is contained in:
@@ -25,11 +25,9 @@ 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`
|
||||
|
||||
@@ -199,7 +197,7 @@ manifest.push(archiveEntry);
|
||||
Write('.workflow/archives/manifest.json', JSON.stringify(manifest, null, 2));
|
||||
```
|
||||
|
||||
#### Step 3.3: Remove Archiving Marker
|
||||
#### Step 3.5: Remove Archiving Marker
|
||||
```bash
|
||||
# Remove archiving marker from archived session (use bash rm as ccw has no delete)
|
||||
rm .workflow/archives/WFS-session-name/.process/.archiving 2>/dev/null || true
|
||||
@@ -223,7 +221,8 @@ rm .workflow/archives/WFS-session-name/.process/.archiving 2>/dev/null || true
|
||||
|
||||
#### Step 4.1: Check Project State Exists
|
||||
```bash
|
||||
bash(test -f .workflow/project.json && echo "EXISTS" || echo "SKIP")
|
||||
# Check project state using ccw
|
||||
ccw session read project --type project 2>/dev/null && echo "EXISTS" || echo "SKIP"
|
||||
```
|
||||
|
||||
**If SKIP**: Output warning and skip Phase 4
|
||||
@@ -251,8 +250,8 @@ const featureId = title.toLowerCase().replace(/[^a-z0-9]+/g, '-').substring(0, 5
|
||||
#### Step 4.3: Update project.json
|
||||
|
||||
```bash
|
||||
# Read current project state
|
||||
bash(cat .workflow/project.json)
|
||||
# Read current project state using ccw
|
||||
ccw session read project --type project --raw
|
||||
```
|
||||
|
||||
**JSON Update Logic**:
|
||||
@@ -366,8 +365,8 @@ function getLatestCommitHash() {
|
||||
**Recovery Steps**:
|
||||
```bash
|
||||
# Session still in .workflow/active/WFS-session-name
|
||||
# Remove archiving marker
|
||||
bash(rm .workflow/active/WFS-session-name/.archiving)
|
||||
# Remove archiving marker using bash
|
||||
rm .workflow/active/WFS-session-name/.process/.archiving 2>/dev/null || true
|
||||
```
|
||||
|
||||
**User Notification**:
|
||||
@@ -464,11 +463,12 @@ Session state: PARTIALLY COMPLETE (session archived, manifest needs update)
|
||||
|
||||
**Phase 3: Atomic Commit** (Transactional file operations)
|
||||
- Create archive directory
|
||||
- Update session status to "completed"
|
||||
- Move session to archive location
|
||||
- Update manifest.json with archive entry
|
||||
- Remove `.archiving` marker
|
||||
- **All-or-nothing**: Either all succeed or session remains in safe state
|
||||
- **Total**: 4 bash commands + JSON manipulation
|
||||
- **Total**: 5 bash commands + JSON manipulation
|
||||
|
||||
**Phase 4: Project Registry Update** (Optional feature tracking)
|
||||
- Check project.json exists
|
||||
@@ -498,3 +498,55 @@ Session state: PARTIALLY COMPLETE (session archived, manifest needs update)
|
||||
- Idempotent operations (safe to retry)
|
||||
|
||||
|
||||
|
||||
## session_manager Tool Alternative
|
||||
|
||||
Use `ccw tool exec session_manager` for session completion operations:
|
||||
|
||||
### List Active Sessions
|
||||
```bash
|
||||
ccw tool exec session_manager '{"operation":"list","location":"active"}'
|
||||
```
|
||||
|
||||
### Update Session Status to Completed
|
||||
```bash
|
||||
ccw tool exec session_manager '{
|
||||
"operation": "update",
|
||||
"session_id": "WFS-xxx",
|
||||
"content_type": "session",
|
||||
"content": {
|
||||
"status": "completed",
|
||||
"archived_at": "2025-12-10T08:00:00Z"
|
||||
}
|
||||
}'
|
||||
```
|
||||
|
||||
### Archive Session
|
||||
```bash
|
||||
ccw tool exec session_manager '{"operation":"archive","session_id":"WFS-xxx"}'
|
||||
|
||||
# This operation:
|
||||
# 1. Updates status to "completed" if update_status=true (default)
|
||||
# 2. Moves session from .workflow/active/ to .workflow/archives/
|
||||
```
|
||||
|
||||
### Read Session Data
|
||||
```bash
|
||||
# Read workflow-session.json
|
||||
ccw tool exec session_manager '{"operation":"read","session_id":"WFS-xxx","content_type":"session"}'
|
||||
|
||||
# Read IMPL_PLAN.md
|
||||
ccw tool exec session_manager '{"operation":"read","session_id":"WFS-xxx","content_type":"plan"}'
|
||||
```
|
||||
|
||||
### Write Archiving Marker
|
||||
```bash
|
||||
ccw tool exec session_manager '{
|
||||
"operation": "write",
|
||||
"session_id": "WFS-xxx",
|
||||
"content_type": "process",
|
||||
"path_params": {"filename": ".archiving"},
|
||||
"content": ""
|
||||
}'
|
||||
```
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -94,4 +83,32 @@ ccw session list --location active --no-metadata
|
||||
|
||||
# Show recent sessions
|
||||
ccw session list --location active
|
||||
```
|
||||
```
|
||||
## session_manager Tool Alternative
|
||||
|
||||
Use `ccw tool exec session_manager` for simplified session listing:
|
||||
|
||||
### List All Sessions (Active + Archived)
|
||||
```bash
|
||||
ccw tool exec session_manager '{"operation":"list","location":"both","include_metadata":true}'
|
||||
|
||||
# Response:
|
||||
# {
|
||||
# "success": true,
|
||||
# "result": {
|
||||
# "active": [{"session_id":"WFS-xxx","metadata":{...}}],
|
||||
# "archived": [{"session_id":"WFS-yyy","metadata":{...}}],
|
||||
# "total": 2
|
||||
# }
|
||||
# }
|
||||
```
|
||||
|
||||
### List Active Sessions Only
|
||||
```bash
|
||||
ccw tool exec session_manager '{"operation":"list","location":"active","include_metadata":true}'
|
||||
```
|
||||
|
||||
### Read Specific Session
|
||||
```bash
|
||||
ccw tool exec session_manager '{"operation":"read","session_id":"WFS-xxx","content_type":"session"}'
|
||||
```
|
||||
|
||||
@@ -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
|
||||
```
|
||||
@@ -58,4 +54,26 @@ Session WFS-user-auth resumed
|
||||
- Paused at: 2025-09-15T14:30:00Z
|
||||
- Resumed at: 2025-09-15T15:45:00Z
|
||||
- Ready for: /workflow:execute
|
||||
```
|
||||
```
|
||||
## session_manager Tool Alternative
|
||||
|
||||
Use `ccw tool exec session_manager` for session resume:
|
||||
|
||||
### Update Session Status
|
||||
```bash
|
||||
# Update status to active
|
||||
ccw tool exec session_manager '{
|
||||
"operation": "update",
|
||||
"session_id": "WFS-xxx",
|
||||
"content_type": "session",
|
||||
"content": {
|
||||
"status": "active",
|
||||
"resumed_at": "2025-12-10T08:00:00Z"
|
||||
}
|
||||
}'
|
||||
```
|
||||
|
||||
### Read Session Status
|
||||
```bash
|
||||
ccw tool exec session_manager '{"operation":"read","session_id":"WFS-xxx","content_type":"session"}'
|
||||
```
|
||||
|
||||
@@ -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`
|
||||
@@ -197,4 +184,36 @@ SESSION_ID: WFS-promptmaster-platform
|
||||
- Pattern: `WFS-[lowercase-slug]`
|
||||
- Characters: `a-z`, `0-9`, `-` only
|
||||
- Max length: 50 characters
|
||||
- Uniqueness: Add numeric suffix if collision (`WFS-auth-2`, `WFS-auth-3`)
|
||||
- Uniqueness: Add numeric suffix if collision (`WFS-auth-2`, `WFS-auth-3`)
|
||||
|
||||
## session_manager Tool Alternative
|
||||
|
||||
The above bash commands can be replaced with `ccw tool exec session_manager`:
|
||||
|
||||
### List Sessions
|
||||
```bash
|
||||
# List active sessions with metadata
|
||||
ccw tool exec session_manager '{"operation":"list","location":"active","include_metadata":true}'
|
||||
|
||||
# Response: {"success":true,"result":{"active":[{"session_id":"WFS-xxx","metadata":{...}}],"total":1}}
|
||||
```
|
||||
|
||||
### Create Session (replaces mkdir + echo)
|
||||
```bash
|
||||
# Single command creates directories + metadata
|
||||
ccw tool exec session_manager '{
|
||||
"operation": "init",
|
||||
"session_id": "WFS-my-session",
|
||||
"metadata": {
|
||||
"project": "my project description",
|
||||
"status": "planning",
|
||||
"type": "workflow",
|
||||
"created_at": "2025-12-10T08:00:00Z"
|
||||
}
|
||||
}'
|
||||
```
|
||||
|
||||
### Read Session Metadata
|
||||
```bash
|
||||
ccw tool exec session_manager '{"operation":"read","session_id":"WFS-xxx","content_type":"session"}'
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user