fix(workflow): complete path migration and enhance session:complete

Comprehensive update to eliminate all old path references and implement transactional archival in session:complete.

## Part 1: Complete Path Migration (43 files)

### Files Updated
- action-plan-verify.md
- session/list.md, session/resume.md
- tdd-verify.md, tdd-plan.md, test-*.md
- All brainstorm/*.md files (13 files)
- All tools/*.md files (10 files)
- All ui-design/*.md files (10 files)
- lite-plan.md, lite-execute.md, plan.md

### Path Changes
- `.workflow/.active-*` → `find .workflow/sessions/ -name "WFS-*" -type d`
- `.workflow/WFS-{session}` → `.workflow/sessions/WFS-{session}`
- `.workflow/.archives/` → `.workflow/archives/`
- Removed all marker file operations (touch/rm .active-*)

### Verification
-  0 references to .active-* markers remain
-  0 references to direct .workflow/WFS-* paths
-  0 references to .workflow/.archives/ (dot prefix)

## Part 2: Transactional Archival Enhancement

### session/complete.md - Complete Rewrite

**New Four-Phase Architecture**:

1. **Phase 1: Pre-Archival Preparation**
   - Find active session in .workflow/sessions/
   - Check for existing .archiving marker (resume detection)
   - Create .archiving marker to prevent concurrent operations

2. **Phase 2: Agent Analysis (In-Place)**
   - Agent processes session WHILE STILL in sessions/ directory
   - Pure analysis - no file moves or manifest updates
   - Returns complete metadata package for atomic commit
   - Failure here → session remains active, safe to retry

3. **Phase 3: Atomic Commit**
   - Only executes if Phase 2 succeeds
   - Move session to archives/
   - Update manifest.json
   - Remove .archiving marker
   - All-or-nothing guarantee

4. **Phase 4: Project Registry Update**
   - Extract feature metadata and update project.json

**Key Improvements**:
- **Agent-first, move-second**: Prevents inconsistent states
- **Transactional guarantees**: All-or-nothing file operations
- **Resume capability**: .archiving marker enables safe retry
- **Error recovery**: Comprehensive failure handling documented

**Old Design Flaw (Fixed)**:
- Old: Move first → Agent processes → If agent fails, session moved but metadata incomplete
- New: Agent processes → If success, atomic commit → Guaranteed consistency

## Benefits

1. **Consistency**: All commands use identical path patterns
2. **Robustness**: Transactional archival prevents data loss
3. **Maintainability**: Single source of truth for directory structure
4. **Recoverability**: Failed operations can be safely retried
5. **Alignment**: Closer to OpenSpec's clean three-layer model

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
catlog22
2025-11-18 12:39:23 +08:00
parent d9fcdad949
commit 19ebb2dc82
37 changed files with 471 additions and 252 deletions

View File

@@ -3,8 +3,8 @@ name: conflict-resolution
description: Detect and resolve conflicts between plan and existing codebase using CLI-powered analysis with Gemini/Qwen
argument-hint: "--session WFS-session-id --context path/to/context-package.json"
examples:
- /workflow:tools:conflict-resolution --session WFS-auth --context .workflow/WFS-auth/.process/context-package.json
- /workflow:tools:conflict-resolution --session WFS-payment --context .workflow/WFS-payment/.process/context-package.json
- /workflow:tools:conflict-resolution --session WFS-auth --context .workflow/sessions/WFS-auth/.process/context-package.json
- /workflow:tools:conflict-resolution --session WFS-payment --context .workflow/sessions/WFS-payment/.process/context-package.json
---
# Conflict Resolution Command

View File

@@ -156,7 +156,7 @@ The context-search-agent MUST perform historical archive analysis as Track 1 in
**Step 1: Check for Archive Manifest**
```bash
# Check if archive manifest exists
if [[ -f .workflow/.archives/manifest.json ]]; then
if [[ -f .workflow/archives/manifest.json ]]; then
# Manifest available for querying
fi
```
@@ -235,7 +235,7 @@ if (historicalConflicts.length > 0 && currentRisk === "low") {
### Archive Query Algorithm
```markdown
1. IF .workflow/.archives/manifest.json does NOT exist → Skip Track 1, continue to Track 2
1. IF .workflow/archives/manifest.json does NOT exist → Skip Track 1, continue to Track 2
2. IF manifest exists:
a. Load manifest.json
b. Extract keywords from task_description (nouns, verbs, technical terms)

View File

@@ -231,13 +231,13 @@ const agentContext = {
// Use memory if available, else load
session_metadata: memory.has("workflow-session.json")
? memory.get("workflow-session.json")
: Read(.workflow/WFS-[id]/workflow-session.json),
: Read(.workflow/sessions/WFS-[id]/workflow-session.json),
context_package_path: ".workflow/WFS-[id]/.process/context-package.json",
context_package_path: ".workflow/sessions/WFS-[id]/.process/context-package.json",
context_package: memory.has("context-package.json")
? memory.get("context-package.json")
: Read(".workflow/WFS-[id]/.process/context-package.json"),
: Read(".workflow/sessions/WFS-[id]/.process/context-package.json"),
// Extract brainstorm artifacts from context package
brainstorm_artifacts: extractBrainstormArtifacts(context_package),

View File

@@ -338,19 +338,19 @@ const agentContext = {
// Use memory if available, else load
session_metadata: memory.has("workflow-session.json")
? memory.get("workflow-session.json")
: Read(.workflow/WFS-[id]/workflow-session.json),
: Read(.workflow/sessions/WFS-[id]/workflow-session.json),
context_package_path: ".workflow/WFS-[id]/.process/context-package.json",
context_package_path: ".workflow/sessions/WFS-[id]/.process/context-package.json",
context_package: memory.has("context-package.json")
? memory.get("context-package.json")
: Read(".workflow/WFS-[id]/.process/context-package.json"),
: Read(".workflow/sessions/WFS-[id]/.process/context-package.json"),
test_context_package_path: ".workflow/WFS-[id]/.process/test-context-package.json",
test_context_package_path: ".workflow/sessions/WFS-[id]/.process/test-context-package.json",
test_context_package: memory.has("test-context-package.json")
? memory.get("test-context-package.json")
: Read(".workflow/WFS-[id]/.process/test-context-package.json"),
: Read(".workflow/sessions/WFS-[id]/.process/test-context-package.json"),
// Extract brainstorm artifacts from context package
brainstorm_artifacts: extractBrainstormArtifacts(context_package),

View File

@@ -224,7 +224,7 @@ Each task JSON embeds all necessary context, artifacts, and execution steps usin
- `id`: Task identifier (format: `IMPL-N` or `IMPL-N.M` for subtasks)
- `title`: Descriptive task name
- `status`: Task state (`pending|active|completed|blocked|container`)
- `context_package_path`: Path to context package (`.workflow/WFS-[session]/.process/context-package.json`)
- `context_package_path`: Path to context package (`.workflow/sessions/WFS-[session]/.process/context-package.json`)
- `meta`: Task metadata
- `context`: Task-specific context and requirements
- `flow_control`: Execution steps and workflow
@@ -269,7 +269,7 @@ Each task JSON embeds all necessary context, artifacts, and execution steps usin
"id": "IMPL-1",
"title": "Implement feature X with Y components",
"status": "pending",
"context_package_path": ".workflow/WFS-session/.process/context-package.json",
"context_package_path": ".workflow/sessions/WFS-session/.process/context-package.json",
"meta": {
"type": "feature",
"agent": "@code-developer",
@@ -291,7 +291,7 @@ Each task JSON embeds all necessary context, artifacts, and execution steps usin
"depends_on": [],
"artifacts": [
{
"path": ".workflow/WFS-session/.brainstorming/system-architect/analysis.md",
"path": ".workflow/sessions/WFS-session/.brainstorming/system-architect/analysis.md",
"priority": "highest",
"usage": "Architecture decisions and API specifications"
}

View File

@@ -272,6 +272,6 @@ Function Coverage: 91%
Overall Compliance: 93/100
Detailed report: .workflow/WFS-auth/.process/tdd-cycle-report.md
Detailed report: .workflow/sessions/WFS-auth/.process/tdd-cycle-report.md
```

View File

@@ -3,7 +3,7 @@ name: test-concept-enhanced
description: Analyze test requirements and generate test generation strategy using Gemini with test-context package
argument-hint: "--session WFS-test-session-id --context path/to/test-context-package.json"
examples:
- /workflow:tools:test-concept-enhanced --session WFS-test-auth --context .workflow/WFS-test-auth/.process/test-context-package.json
- /workflow:tools:test-concept-enhanced --session WFS-test-auth --context .workflow/sessions/WFS-test-auth/.process/test-context-package.json
---
# Test Concept Enhanced Command

View File

@@ -273,19 +273,19 @@ const agentContext = {
// Use memory if available, else load
session_metadata: memory.has("workflow-session.json")
? memory.get("workflow-session.json")
: Read(.workflow/WFS-test-[id]/workflow-session.json),
: Read(.workflow/sessions/WFS-test-[id]/workflow-session.json),
test_analysis_results_path: ".workflow/WFS-test-[id]/.process/TEST_ANALYSIS_RESULTS.md",
test_analysis_results_path: ".workflow/sessions/WFS-test-[id]/.process/TEST_ANALYSIS_RESULTS.md",
test_analysis_results: memory.has("TEST_ANALYSIS_RESULTS.md")
? memory.get("TEST_ANALYSIS_RESULTS.md")
: Read(".workflow/WFS-test-[id]/.process/TEST_ANALYSIS_RESULTS.md"),
: Read(".workflow/sessions/WFS-test-[id]/.process/TEST_ANALYSIS_RESULTS.md"),
test_context_package_path: ".workflow/WFS-test-[id]/.process/test-context-package.json",
test_context_package_path: ".workflow/sessions/WFS-test-[id]/.process/test-context-package.json",
test_context_package: memory.has("test-context-package.json")
? memory.get("test-context-package.json")
: Read(".workflow/WFS-test-[id]/.process/test-context-package.json"),
: Read(".workflow/sessions/WFS-test-[id]/.process/test-context-package.json"),
// Load source session summaries if exists
source_session_id: session_metadata.source_session_id || null,
@@ -312,7 +312,7 @@ This section provides quick reference for test task JSON structure. For complete
## Output Files Structure
```
.workflow/WFS-test-[session]/
.workflow/sessions/WFS-test-[session]/
├── workflow-session.json # Test session metadata
├── IMPL_PLAN.md # Test validation plan
├── TODO_LIST.md # Progress tracking