feat: 增强会话管理功能,添加会话状态跟踪和进程披露,优化钩子管理界面

This commit is contained in:
catlog22
2025-12-20 23:14:07 +08:00
parent fd4a15c84e
commit 775928456d
9 changed files with 356 additions and 138 deletions

View File

@@ -56,6 +56,7 @@ Phase 2: Planning Document Validation
└─ Validate .task/ contains IMPL-*.json files
Phase 3: TodoWrite Generation
├─ Update session status to "active" (Step 0)
├─ Parse TODO_LIST.md for task statuses
├─ Generate TodoWrite for entire workflow
└─ Prepare session context paths
@@ -80,6 +81,7 @@ Phase 5: Completion
Resume Mode (--resume-session):
├─ Skip Phase 1 & Phase 2
└─ Entry Point: Phase 3 (TodoWrite Generation)
├─ Update session status to "active" (if not already)
└─ Continue: Phase 4 → Phase 5
```
@@ -179,6 +181,16 @@ bash(cat .workflow/active/${sessionId}/workflow-session.json)
### Phase 3: TodoWrite Generation
**Applies to**: Both normal and resume modes (resume mode entry point)
**Step 0: Update Session Status to Active**
Before generating TodoWrite, update session status from "planning" to "active":
```bash
# Update session status (idempotent - safe to run if already active)
jq '.status = "active" | .execution_started_at = (.execution_started_at // now | todate)' \
.workflow/active/${sessionId}/workflow-session.json > tmp.json && \
mv tmp.json .workflow/active/${sessionId}/workflow-session.json
```
This ensures the dashboard shows the session as "ACTIVE" during execution.
**Process**:
1. **Create TodoWrite List**: Generate task list from TODO_LIST.md (not from task JSONs)
- Parse TODO_LIST.md to extract all tasks with current statuses

View File

@@ -1,8 +1,19 @@
## MCP Tools Usage
### smart_search - Code Search (REQUIRED)
### smart_search - Code Search (REQUIRED - HIGHEST PRIORITY)
**When**: Find code, understand codebase structure, locate implementations
**OVERRIDES**: All other search/discovery rules in other workflow files
**When**: ANY code discovery task, including:
- Find code, understand codebase structure, locate implementations
- Explore unknown locations
- Verify file existence before reading
- Pattern-based file discovery
**Priority Rule**:
1. **Always use smart_search FIRST** for any code/file discovery
2. Only use Built-in Grep for single-file exact line search (after location confirmed)
3. Only use Built-in Read for known, confirmed file paths
**Workflow** (search first, init if needed):
```javascript

View File

@@ -40,27 +40,25 @@ write_file(path="/existing.ts", content="...", backup=true) // Create backup fi
## Priority Logic
> **Note**: Search priority is defined in `context-tools.md` - smart_search has HIGHEST PRIORITY for all discovery tasks.
**Search & Discovery** (defer to context-tools.md):
1. **smart_search FIRST** for any code/file discovery
2. Built-in Grep only for single-file exact line search (location already confirmed)
3. Exa for external/public knowledge
**File Reading**:
1. Known single file → Built-in Read
2. Multiple files OR pattern matching → smart_search (MCP)
3. Unknown location → smart_search then Read
4. Large codebase + repeated access → smart_search (indexed)
1. Unknown location → **smart_search first**, then Read
2. Known confirmed file → Built-in Read directly
3. Pattern matching → smart_search (action="find_files")
**File Editing**:
1. Always try built-in Edit first
2. Fails 1+ times → edit_file (MCP)
3. Still fails → write_file (MCP)
**Search**:
1. External knowledge → Exa (MCP)
2. Exact pattern in small codebase → Built-in Grep
3. Semantic/unknown location → smart_search (MCP)
4. Large codebase + repeated searches → smart_search (indexed)
## Decision Triggers
**Start with simplest tool** (Read, Edit, Grep)
**Escalate to MCP tools** when built-ins fail or inappropriate
**Use semantic search** for exploratory tasks
**Use indexed search** for large, stable codebases
**Use Exa** for external/public knowledge
**Search tasks** → Always start with smart_search (per context-tools.md)
**Known file edits** → Start with built-in Edit, escalate to MCP if fails
**External knowledge** → Use Exa