feat(ccw): add session manager tool with auto workspace detection

- Add session_manager tool for workflow session lifecycle management
- Add ccw session CLI command with subcommands:
  - list, init, status, task, stats, delete, read, write, update, archive, mkdir
- Implement auto workspace detection (traverse up to find .workflow)
- Implement auto session location detection (active, archived, lite-plan, lite-fix)
- Add dashboard notifications for tool executions via WebSocket
- Add granular event types (SESSION_CREATED, TASK_UPDATED, etc.)
- Add status_history auto-tracking for task status changes
- Update workflow session commands to document ccw session usage

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
catlog22
2025-12-10 19:26:53 +08:00
parent df104d6e9b
commit 598bea9b21
11 changed files with 2003 additions and 6 deletions

View File

@@ -507,3 +507,64 @@ 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": ""
}'
```
### Operation Reference
| Old Pattern | session_manager |
|------------|-----------------|
| `find .workflow/active/ -name "WFS-*"` | `{"operation":"list","location":"active"}` |
| `jq '.status = "completed"' ...` | `{"operation":"update","content":{"status":"completed"}}` |
| `mv .workflow/active/WFS-xxx .workflow/archives/` | `{"operation":"archive","session_id":"WFS-xxx"}` |
| `touch .archiving` | `{"operation":"write","content_type":"process","path_params":{"filename":".archiving"}}` |
| `rm .archiving` | Use bash `rm` directly (no delete operation in tool) |
| `cat manifest.json` | Read manifest directly with bash (outside session scope) |