From c256fd937947860feeb71fcbb7264588f15a815a Mon Sep 17 00:00:00 2001 From: catlog22 Date: Thu, 11 Dec 2025 15:08:55 +0800 Subject: [PATCH] refactor(session): migrate remaining bash commands to ccw session MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace legacy bash operations in session commands with ccw session commands for consistency and better maintainability. Changes: - session/list.md: Replace ls/wc with ccw session list - session/complete.md: Replace bash marker/manifest ops with ccw session - skills/command-guide reference docs: Mirror all changes Commands replaced: - `ls .workflow/active/WFS-*` → `ccw session list --location active` - `test -f .archiving` → `ccw session read --type process --filename .archiving` - `touch .archiving` → `ccw session write --type process --filename .archiving` - `cat manifest.json` → `ccw session read manifest --type manifest` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .claude/commands/workflow/session/complete.md | 22 +++++++------- .claude/commands/workflow/session/list.md | 7 +++-- .../commands/workflow/session/complete.md | 30 +++++++++---------- .../commands/workflow/session/list.md | 7 +++-- 4 files changed, 35 insertions(+), 31 deletions(-) diff --git a/.claude/commands/workflow/session/complete.md b/.claude/commands/workflow/session/complete.md index f7337586..5676573f 100644 --- a/.claude/commands/workflow/session/complete.md +++ b/.claude/commands/workflow/session/complete.md @@ -34,7 +34,7 @@ ccw session list --location active #### Step 1.2: Check for Existing Archiving Marker (Resume Detection) ```bash # Check if session is already being archived (marker file exists) -bash(test -f .workflow/active/WFS-session-name/.archiving && echo "RESUMING" || echo "NEW") +ccw session read WFS-session-name --type process --filename .archiving 2>/dev/null && echo "RESUMING" || echo "NEW" ``` **If RESUMING**: @@ -47,7 +47,7 @@ bash(test -f .workflow/active/WFS-session-name/.archiving && echo "RESUMING" || #### Step 1.3: Create Archiving Marker ```bash # Mark session as "archiving in progress" -bash(touch .workflow/active/WFS-session-name/.archiving) +ccw session write WFS-session-name --type process --filename .archiving --content '' ``` **Purpose**: - Prevents concurrent operations on this session @@ -171,8 +171,8 @@ ccw session archive WFS-session-name #### 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 "[]") +# Read current manifest using ccw (or create empty array if not exists) +ccw session read manifest --type manifest --raw 2>/dev/null || echo "[]" ``` **JSON Update Logic**: @@ -199,7 +199,8 @@ Write('.workflow/archives/manifest.json', JSON.stringify(manifest, null, 2)); #### Step 3.5: Remove Archiving Marker ```bash -bash(rm .workflow/archives/WFS-session-name/.archiving) +# 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 ``` **Result**: Clean archived session without temporary markers @@ -220,7 +221,8 @@ bash(rm .workflow/archives/WFS-session-name/.archiving) #### 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 @@ -248,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**: @@ -363,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**: diff --git a/.claude/commands/workflow/session/list.md b/.claude/commands/workflow/session/list.md index 630b4b0a..1f9d8c2d 100644 --- a/.claude/commands/workflow/session/list.md +++ b/.claude/commands/workflow/session/list.md @@ -77,11 +77,12 @@ Total: 3 sessions (1 active, 1 paused, 1 completed) ### Quick Commands ```bash -# Count all sessions -ls .workflow/active/WFS-* | wc -l +# Count active sessions using ccw +ccw session list --location active --no-metadata +# Returns session count in result.total # Show recent sessions -ls -t .workflow/active/WFS-*/workflow-session.json | head -3 +ccw session list --location active ``` ## session_manager Tool Alternative diff --git a/.claude/skills/command-guide/reference/commands/workflow/session/complete.md b/.claude/skills/command-guide/reference/commands/workflow/session/complete.md index 40d803f1..369a8107 100644 --- a/.claude/skills/command-guide/reference/commands/workflow/session/complete.md +++ b/.claude/skills/command-guide/reference/commands/workflow/session/complete.md @@ -35,8 +35,8 @@ bash(basename .workflow/active/WFS-session-name) #### Step 1.2: Check for Existing Archiving Marker (Resume Detection) ```bash -# Check if session is already being archived -bash(test -f .workflow/active/WFS-session-name/.archiving && echo "RESUMING" || echo "NEW") +# Check if session is already being archived (marker file exists) +ccw session read WFS-session-name --type process --filename .archiving 2>/dev/null && echo "RESUMING" || echo "NEW" ``` **If RESUMING**: @@ -49,7 +49,7 @@ bash(test -f .workflow/active/WFS-session-name/.archiving && echo "RESUMING" || #### Step 1.3: Create Archiving Marker ```bash # Mark session as "archiving in progress" -bash(touch .workflow/active/WFS-session-name/.archiving) +ccw session write WFS-session-name --type process --filename .archiving --content '' ``` **Purpose**: - Prevents concurrent operations on this session @@ -161,21 +161,20 @@ 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: 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.3: 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 "[]") +# Read current manifest using ccw (or create empty array if not exists) +ccw session read manifest --type manifest --raw 2>/dev/null || echo "[]" ``` **JSON Update Logic**: @@ -200,9 +199,10 @@ manifest.push(archiveEntry); Write('.workflow/archives/manifest.json', JSON.stringify(manifest, null, 2)); ``` -#### Step 3.4: Remove Archiving Marker +#### Step 3.3: Remove Archiving Marker ```bash -bash(rm .workflow/archives/WFS-session-name/.archiving) +# 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 ``` **Result**: Clean archived session without temporary markers diff --git a/.claude/skills/command-guide/reference/commands/workflow/session/list.md b/.claude/skills/command-guide/reference/commands/workflow/session/list.md index d22bb59d..34cbeea7 100644 --- a/.claude/skills/command-guide/reference/commands/workflow/session/list.md +++ b/.claude/skills/command-guide/reference/commands/workflow/session/list.md @@ -88,9 +88,10 @@ Total: 3 sessions (1 active, 1 paused, 1 completed) ### Quick Commands ```bash -# Count all sessions -ls .workflow/active/WFS-* | wc -l +# Count active sessions using ccw +ccw session list --location active --no-metadata +# Returns session count in result.total # Show recent sessions -ls -t .workflow/active/WFS-*/workflow-session.json | head -3 +ccw session list --location active ``` \ No newline at end of file