From f320f1fe32e80dbea9bd7ab74399808d2fb802bc Mon Sep 17 00:00:00 2001 From: catlog22 Date: Wed, 17 Sep 2025 23:48:16 +0800 Subject: [PATCH] feat: Add multi-session support to workflow system MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Enable multiple active workflow sessions to coexist - Add session detection logic for multiple .active-* markers - Update execute command to prompt user selection when multiple sessions found - Update plan command with multi-session awareness - Maintain session isolation while allowing parallel workflow instances 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .claude/commands/workflow/execute.md | 12 +++++++----- .claude/commands/workflow/plan.md | 8 +++++--- .claude/workflows/workflow-architecture.md | 19 +++++++++++++++---- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/.claude/commands/workflow/execute.md b/.claude/commands/workflow/execute.md index 858560f6..e7044fd1 100644 --- a/.claude/commands/workflow/execute.md +++ b/.claude/commands/workflow/execute.md @@ -31,11 +31,13 @@ Coordinates agents for executing workflow tasks through automatic discovery and ### 1. Discovery Phase ``` -├── Locate workflow folder (current session) -├── Load workflow-session.json and IMPL_PLAN.md -├── Scan .task/ directory for task JSON files -├── Analyze task statuses and dependencies -└── Build execution queue of ready tasks +├── Check for .active-* markers in .workflow/ +├── If multiple active sessions found → Prompt user to select +├── Locate selected session's workflow folder +├── Load selected session's workflow-session.json and IMPL_PLAN.md +├── Scan selected session's .task/ directory for task JSON files +├── Analyze task statuses and dependencies for selected session only +└── Build execution queue of ready tasks from selected session ``` ### 2. TodoWrite Coordination diff --git a/.claude/commands/workflow/plan.md b/.claude/commands/workflow/plan.md index 238fb5a6..913b9d48 100644 --- a/.claude/commands/workflow/plan.md +++ b/.claude/commands/workflow/plan.md @@ -89,10 +89,12 @@ examples: 4. **Quantity prediction**: Estimate main tasks, subtasks, container vs leaf ratio ### Session Management ⚠️ CRITICAL -- **⚡ FIRST ACTION**: Always check for `.workflow/.active-*` marker before any planning +- **⚡ FIRST ACTION**: Check for all `.workflow/.active-*` markers before any planning +- **Multiple sessions support**: Different Claude instances can have different active sessions +- **User selection**: If multiple active sessions found, prompt user to select which one to work with - **Auto-session creation**: `WFS-[topic-slug]` only if no active session exists -- **Session continuity**: MUST use existing active session to maintain context -- **⚠️ Dependency context**: MUST read ALL previous task summary documents before planning +- **Session continuity**: MUST use selected active session to maintain context +- **⚠️ Dependency context**: MUST read ALL previous task summary documents from selected session before planning - **Session isolation**: Each session maintains independent context and state ### Project Structure Analysis & Engineering Enhancement diff --git a/.claude/workflows/workflow-architecture.md b/.claude/workflows/workflow-architecture.md index 348f12fa..1a48f3ed 100644 --- a/.claude/workflows/workflow-architecture.md +++ b/.claude/workflows/workflow-architecture.md @@ -43,12 +43,23 @@ This document defines the complete workflow system architecture using a **JSON-o ### Session Operations -#### Detect Active Session +#### Detect Active Session(s) ```bash -active_session=$(find .workflow -name ".active-*" | head -1) -if [ -n "$active_session" ]; then - session_name=$(basename "$active_session" | sed 's/^\.active-//') +active_sessions=$(find .workflow -name ".active-*" 2>/dev/null) +count=$(echo "$active_sessions" | wc -l) + +if [ -z "$active_sessions" ]; then + echo "No active session" +elif [ "$count" -eq 1 ]; then + session_name=$(basename "$active_sessions" | sed 's/^\.active-//') echo "Active session: $session_name" +else + echo "Multiple active sessions found:" + echo "$active_sessions" | while read marker; do + session=$(basename "$marker" | sed 's/^\.active-//') + echo " - $session" + done + echo "Please specify which session to work with" fi ```