11---
22name : complete
3- description : Mark the active workflow session as complete and remove active flag
3+ description : Mark the active workflow session as complete, archive it with lessons learned, and remove active flag
44examples :
55 - /workflow:session:complete
66 - /workflow:session:complete --detailed
@@ -9,7 +9,7 @@ examples:
99# Complete Workflow Session (/workflow:session: complete )
1010
1111## Overview
12- Mark the currently active workflow session as complete, update its status , and remove the active flag marker.
12+ Mark the currently active workflow session as complete, analyze it for lessons learned, move it to the archive directory , and remove the active flag marker.
1313
1414## Usage
1515``` bash
@@ -19,87 +19,129 @@ Mark the currently active workflow session as complete, update its status, and r
1919
2020## Implementation Flow
2121
22- ### Step 1: Find Active Session
23- ``` bash
24- ls .workflow/.active-* 2> /dev/null | head -1
25- ```
22+ ### Phase 1: Prepare for Archival (Minimal Manual Operations)
2623
27- ### Step 2: Get Session Name
28- ``` bash
29- basename .workflow/.active-WFS-session-name | sed ' s/^\.active-//'
30- ```
24+ ** Purpose** : Find active session, move to archive location, pass control to agent. Minimal operations.
3125
32- ### Step 3: Update Session Status
26+ #### Step 1.1: Find Active Session and Get Name
3327``` bash
34- jq ' .status = "completed"' .workflow/WFS-session/workflow-session.json > temp.json
35- mv temp.json .workflow/WFS-session/workflow-session.json
36- ```
28+ # Find active marker
29+ bash(find .workflow/ -name " .active-*" -type f | head -1)
3730
38- ### Step 4: Add Completion Timestamp
39- ``` bash
40- jq ' .completed_at = "' $( date -u +%Y-%m-%dT%H:%M:%SZ) ' "' .workflow/WFS-session/workflow-session.json > temp.json
41- mv temp.json .workflow/WFS-session/workflow-session.json
31+ # Extract session name from marker path
32+ bash(basename .workflow/.active-WFS-session-name | sed ' s/^\.active-//' )
4233```
34+ ** Output** : Session name ` WFS-session-name `
4335
44- ### Step 5: Count Final Statistics
36+ #### Step 1.2: Move Session to Archive
4537``` bash
46- find .workflow/WFS-session/.task/ -name " *.json" -type f 2> /dev/null | wc -l
47- find .workflow/WFS-session/.summaries/ -name " *.md" -type f 2> /dev/null | wc -l
48- ```
38+ # Create archive directory if needed
39+ bash(mkdir -p .workflow/.archives/)
4940
50- ### Step 6: Remove Active Marker
51- ``` bash
52- rm .workflow/.active-WFS-session-name
41+ # Move session to archive location
42+ bash(mv .workflow/WFS-session-name .workflow/.archives/WFS-session-name)
5343```
44+ ** Result** : Session now at ` .workflow/.archives/WFS-session-name/ `
5445
55- ## Simple Bash Commands
46+ ### Phase 2: Agent-Orchestrated Completion (All Data Processing)
5647
57- ### Basic Operations
58- - ** Find active session** : ` find .workflow/ -name ".active-*" -type f `
59- - ** Get session name** : ` basename marker | sed 's/^\.active-//' `
60- - ** Update status** : ` jq '.status = "completed"' session.json > temp.json `
61- - ** Add timestamp** : ` jq '.completed_at = "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"' `
62- - ** Count tasks** : ` find .task/ -name "*.json" -type f | wc -l `
63- - ** Count completed** : ` find .summaries/ -name "*.md" -type f 2>/dev/null | wc -l `
64- - ** Remove marker** : ` rm .workflow/.active-session `
48+ ** Purpose** : Agent analyzes archived session, generates metadata, updates manifest, and removes active marker.
6549
66- ### Completion Result
67- ```
68- Session WFS-user-auth completed
69- - Status: completed
70- - Started: 2025-09-15T10:00:00Z
71- - Completed: 2025-09-15T16:30:00Z
72- - Duration: 6h 30m
73- - Total tasks: 8
74- - Completed tasks: 8
75- - Success rate: 100%
50+ #### Agent Invocation
51+
52+ Invoke ` universal-executor ` agent to complete the archival process.
53+
54+ ** Agent Task** :
7655```
56+ Task(
57+ subagent_type="universal-executor",
58+ description="Complete session archival",
59+ prompt=`
60+ Complete workflow session archival. Session already moved to archive location.
61+
62+ ## Context
63+ - Session: .workflow/.archives/WFS-session-name/
64+ - Active marker: .workflow/.active-WFS-session-name
65+
66+ ## Tasks
67+
68+ 1. **Extract session data** from workflow-session.json (session_id, description/topic, started_at/timestamp, completed_at, status)
69+ - If status != "completed", update it with timestamp
70+
71+ 2. **Count files**: tasks (.task/*.json) and summaries (.summaries/*.md)
72+
73+ 3. **Generate lessons**: Use gemini with ~/.claude/workflows/cli-templates/prompts/archive/analysis-simple.txt (fallback: analyze files directly)
74+ - Return: {successes, challenges, watch_patterns}
7775
78- ### Detailed Summary (--detailed flag)
76+ 4. **Build archive entry**:
77+ - Calculate: duration_hours, success_rate, tags (3-5 keywords)
78+ - Construct complete JSON with session_id, description, archived_at, archive_path, metrics, tags, lessons
79+
80+ 5. **Update manifest**: Initialize .workflow/.archives/manifest.json if needed, append entry
81+
82+ 6. **Remove active marker**
83+
84+ 7. **Return result**: {"status": "success", "session_id": "...", "archived_at": "...", "metrics": {...}, "lessons_summary": {...}}
85+
86+ ## Error Handling
87+ - On failure: return {"status": "error", "task": "...", "message": "..."}
88+ - Do NOT remove marker if failed
89+ `
90+ )
7991```
80- Session Completion Summary:
81- ├── Session: WFS-user-auth
82- ├── Project: User authentication system
83- ├── Total time: 6h 30m
84- ├── Tasks completed: 8/8 (100%)
85- ├── Files generated: 24 files
86- ├── Summaries created: 8 summaries
87- ├── Status: All tasks completed successfully
88- └── Location: .workflow/WFS-user-auth/
92+
93+ ** Expected Output** :
94+ - Agent returns JSON result confirming successful archival
95+ - Display completion summary to user based on agent response
96+
97+ ## Workflow Execution Strategy
98+
99+ ### Two-Phase Approach (Optimized)
100+
101+ ** Phase 1: Minimal Manual Setup** (2 simple operations)
102+ - Find active session and extract name
103+ - Move session to archive location
104+ - ** No data extraction** - agent handles all data processing
105+ - ** No counting** - agent does this from archive location
106+ - ** Total** : 2 bash commands (find + move)
107+
108+ ** Phase 2: Agent-Driven Completion** (1 agent invocation)
109+ - Extract all session data from archived location
110+ - Count tasks and summaries
111+ - Generate lessons learned analysis
112+ - Build complete archive metadata
113+ - Update manifest
114+ - Remove active marker
115+ - Return success/error result
116+
117+ ## Quick Commands
118+
119+ ``` bash
120+ # Phase 1: Find and move
121+ bash(find .workflow/ -name " .active-*" -type f | head -1)
122+ bash(basename .workflow/.active-WFS-session-name | sed ' s/^\.active-//' )
123+ bash(mkdir -p .workflow/.archives/)
124+ bash(mv .workflow/WFS-session-name .workflow/.archives/WFS-session-name)
125+
126+ # Phase 2: Agent completes archival
127+ Task(subagent_type=" universal-executor" , description=" Complete session archival" , prompt=` ...` )
89128```
90129
91- ### Error Handling
130+ ## Archive Query Commands
131+
132+ After archival, you can query the manifest:
133+
92134``` bash
93- # No active session
94- find .workflow/ -name " .active-*" -type f 2> /dev/null || echo " No active session found"
135+ # List all archived sessions
136+ jq ' .archives[].session_id' .workflow/.archives/manifest.json
137+
138+ # Find sessions by keyword
139+ jq ' .archives[] | select(.description | test("auth"; "i"))' .workflow/.archives/manifest.json
140+
141+ # Get specific session details
142+ jq ' .archives[] | select(.session_id == "WFS-user-auth")' .workflow/.archives/manifest.json
95143
96- # Incomplete tasks
97- task_count=$( find .task/ -name " *.json" -type f | wc -l)
98- summary_count=$( find .summaries/ -name " *.md" -type f 2> /dev/null | wc -l)
99- test $task_count -eq $summary_count || echo " Warning: Not all tasks completed"
144+ # List all watch patterns across sessions
145+ jq ' .archives[].lessons.watch_patterns[]' .workflow/.archives/manifest.json
100146```
101147
102- ## Related Commands
103- - ` /workflow:session:list ` - View all sessions including completed
104- - ` /workflow:session:start ` - Start new session
105- - ` /workflow:status ` - Check completion status before completing
0 commit comments