Refactor workflow directory structure to improve clarity and robustness by introducing dedicated sessions/ subdirectory for active sessions. ## Directory Structure Changes ### Before (Old Structure) ``` .workflow/ ├── .active-WFS-session-1 # Marker files (fragile) ├── WFS-session-1/ # Active sessions mixed with config ├── WFS-session-2/ ├── project.json └── .archives/ # Archived sessions ``` ### After (New Structure) ``` .workflow/ ├── project.json # Project metadata ├── sessions/ # [NEW] All active sessions │ └── WFS-session-1/ └── archives/ # Archived sessions (removed dot prefix) ``` ## Key Improvements 1. **Physical Isolation**: Active sessions now in dedicated sessions/ subdirectory 2. **No Marker Files**: Removed fragile .active-* marker file mechanism 3. **Directory-Based State**: Session state determined by directory location - In sessions/ = active - In archives/ = archived 4. **Simpler Discovery**: `ls .workflow/sessions/` instead of `find .workflow/ -name ".active-*"` 5. **Cleaner Root**: .workflow/ root now only contains project.json, sessions/, archives/ ## Path Transformations | Old Pattern | New Pattern | |-------------|-------------| | `find .workflow/ -name ".active-*"` | `find .workflow/sessions/ -name "WFS-*" -type d` | | `.workflow/WFS-[slug]/` | `.workflow/sessions/WFS-[slug]/` | | `.workflow/.archives/` | `.workflow/archives/` | | `touch .workflow/.active-*` | *Removed* | | `rm .workflow/.active-*` | *Removed* | ## Modified Commands ### session/start.md - Update session creation path to .workflow/sessions/WFS-*/ - Remove .active-* marker file creation - Update session discovery to use directory listing - Updated all 3 modes: Discovery, Auto, Force New ### session/complete.md - Update session move from sessions/ to archives/ - Remove .active-* marker file deletion - Update manifest path to archives/manifest.json - Update agent prompts with new paths ### status.md - Update session discovery to find .workflow/sessions/ - Update all session file path references - Update archive query examples ### execute.md - Update session discovery logic - Update all task file paths to include sessions/ prefix - Update context package paths - Update error handling documentation ## Benefits - **Robustness**: Eliminates marker file state inconsistency risk - **Clarity**: Clear separation between active and archived sessions - **Simplicity**: Session discovery is straightforward directory listing - **Alignment**: Closer to OpenSpec's three-layer structure (specs/changes/archive) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
5.8 KiB
Start Workflow Session (/workflow:session:start)
Overview
Manages workflow sessions with three operation modes: discovery (manual), auto (intelligent), and force-new.
Dual Responsibility:
- Project-level initialization (first-time only): Creates
.workflow/project.jsonfor feature registry - Session-level initialization (always): Creates session directory structure
Step 0: Initialize Project State (First-time Only)
Executed before all modes - Ensures project-level state file exists by calling /workflow:init.
Check and Initialize
# Check if project state exists
bash(test -f .workflow/project.json && echo "EXISTS" || echo "NOT_FOUND")
If NOT_FOUND, delegate to /workflow:init:
// Call workflow:init for intelligent project analysis
SlashCommand({command: "/workflow:init"});
// Wait for init completion
// project.json will be created with comprehensive project overview
Output:
- If EXISTS:
PROJECT_STATE: initialized - If NOT_FOUND: Calls
/workflow:init→ creates.workflow/project.jsonwith full project analysis
Note: /workflow:init uses cli-explore-agent to build comprehensive project understanding (technology stack, architecture, key components). This step runs once per project. Subsequent executions skip initialization.
Mode 1: Discovery Mode (Default)
Usage
/workflow:session:start
Step 1: List Active Sessions
bash(ls -1 .workflow/sessions/ 2>/dev/null | head -5)
Step 2: Display Session Metadata
bash(cat .workflow/sessions/WFS-promptmaster-platform/workflow-session.json)
Step 4: User Decision
Present session information and wait for user to select or create session.
Output: SESSION_ID: WFS-[user-selected-id]
Mode 2: Auto Mode (Intelligent)
Usage
/workflow:session:start --auto "task description"
Step 1: Check Active Sessions Count
bash(find .workflow/sessions/ -name "WFS-*" -type d 2>/dev/null | wc -l)
Step 2a: No Active Sessions → Create New
# Generate session slug
bash(echo "implement OAuth2 auth" | sed 's/[^a-zA-Z0-9]/-/g' | tr '[:upper:]' '[:lower:]' | cut -c1-50)
# Create directory structure
bash(mkdir -p .workflow/sessions/WFS-implement-oauth2-auth/.process)
bash(mkdir -p .workflow/sessions/WFS-implement-oauth2-auth/.task)
bash(mkdir -p .workflow/sessions/WFS-implement-oauth2-auth/.summaries)
# Create metadata
bash(echo '{"session_id":"WFS-implement-oauth2-auth","project":"implement OAuth2 auth","status":"planning"}' > .workflow/sessions/WFS-implement-oauth2-auth/workflow-session.json)
Output: SESSION_ID: WFS-implement-oauth2-auth
Step 2b: Single Active Session → Check Relevance
# Extract session ID
bash(find .workflow/sessions/ -name "WFS-*" -type d 2>/dev/null | head -1 | xargs basename)
# Read project name from metadata
bash(cat .workflow/sessions/WFS-promptmaster-platform/workflow-session.json | grep -o '"project":"[^"]*"' | cut -d'"' -f4)
# Check keyword match (manual comparison)
# If task contains project keywords → Reuse session
# If task unrelated → Create new session (use Step 2a)
Output (reuse): SESSION_ID: WFS-promptmaster-platform
Output (new): SESSION_ID: WFS-[new-slug]
Step 2c: Multiple Active Sessions → Use First
# Get first active session
bash(find .workflow/sessions/ -name "WFS-*" -type d 2>/dev/null | head -1 | xargs basename)
# Output warning and session ID
# WARNING: Multiple active sessions detected
# SESSION_ID: WFS-first-session
Mode 3: Force New Mode
Usage
/workflow:session:start --new "task description"
Step 1: Generate Unique Session Slug
# 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/sessions/WFS-fix-login-bug 2>/dev/null && echo "WFS-fix-login-bug-2" || echo "WFS-fix-login-bug")
Step 2: Create Session Structure
bash(mkdir -p .workflow/sessions/WFS-fix-login-bug/.process)
bash(mkdir -p .workflow/sessions/WFS-fix-login-bug/.task)
bash(mkdir -p .workflow/sessions/WFS-fix-login-bug/.summaries)
Step 3: Create Metadata
bash(echo '{"session_id":"WFS-fix-login-bug","project":"fix login bug","status":"planning"}' > .workflow/sessions/WFS-fix-login-bug/workflow-session.json)
Output: SESSION_ID: WFS-fix-login-bug
Output Format Specification
Success
SESSION_ID: WFS-session-slug
Error
ERROR: --auto mode requires task description
ERROR: Failed to create session directory
Analysis (Auto Mode)
ANALYSIS: Task relevance = high
DECISION: Reusing existing session
SESSION_ID: WFS-promptmaster-platform
Command Integration
For /workflow:plan (Use Auto Mode)
SlashCommand(command="/workflow:session:start --auto \"implement OAuth2 authentication\"")
# Parse session ID from output
grep "^SESSION_ID:" | awk '{print $2}'
For Interactive Workflows (Use Discovery Mode)
SlashCommand(command="/workflow:session:start")
For New Isolated Work (Use Force New Mode)
SlashCommand(command="/workflow:session:start --new \"experimental feature\"")
Session ID Format
- 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)