mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-05 01:50:27 +08:00
feat: 增强计划验证和上下文收集功能,支持自动执行和用户交互选择
This commit is contained in:
@@ -815,11 +815,48 @@ Next: Review full report at ${reportPath} for detailed findings and recommendati
|
||||
\`)
|
||||
```
|
||||
|
||||
**Step 6.3: Completion**
|
||||
**Step 6.3: Next Step Selection**
|
||||
|
||||
- ✅ Agent JSON findings saved to: \`${process_dir}/verification-findings.json\`
|
||||
- ✅ Human-readable report saved to: \`${process_dir}/PLAN_VERIFICATION.md\`
|
||||
- ✅ Quality gate decision: \`${recommendation}\`
|
||||
- ℹ️ No automatic modifications to IMPL_PLAN.md, tasks, or synthesis artifacts
|
||||
- ℹ️ User can review findings and decide on remediation approach
|
||||
- ℹ️ Re-run verification after fixes: \`/workflow:plan-verify --session ${session_id}\`
|
||||
```javascript
|
||||
const autoYes = $ARGUMENTS.includes('--yes') || $ARGUMENTS.includes('-y')
|
||||
const canExecute = recommendation !== 'BLOCK_EXECUTION'
|
||||
|
||||
// Auto mode
|
||||
if (autoYes) {
|
||||
if (canExecute) {
|
||||
SlashCommand("/workflow:execute --yes --resume-session=\"${session_id}\"")
|
||||
} else {
|
||||
console.log(`[--yes] BLOCK_EXECUTION - Fix ${critical_count} critical issues first.`)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Interactive mode - build options based on quality gate
|
||||
const options = canExecute
|
||||
? [
|
||||
{ label: canExecute && recommendation === 'PROCEED_WITH_FIXES' ? "Execute Anyway" : "Execute (Recommended)",
|
||||
description: "Proceed to /workflow:execute" },
|
||||
{ label: "Review Report", description: "Review findings before deciding" },
|
||||
{ label: "Re-verify", description: "Re-run after manual fixes" }
|
||||
]
|
||||
: [
|
||||
{ label: "Review Report", description: "Review critical issues" },
|
||||
{ label: "Re-verify", description: "Re-run after fixing issues" }
|
||||
]
|
||||
|
||||
const selection = AskUserQuestion({
|
||||
questions: [{
|
||||
question: `Quality gate: ${recommendation}. Next step?`,
|
||||
header: "Action",
|
||||
multiSelect: false,
|
||||
options
|
||||
}]
|
||||
})
|
||||
|
||||
// Handle selection
|
||||
if (selection.includes("Execute")) {
|
||||
SlashCommand("/workflow:execute --resume-session=\"${session_id}\"")
|
||||
} else if (selection === "Re-verify") {
|
||||
SlashCommand("/workflow:plan-verify --session ${session_id}")
|
||||
}
|
||||
```
|
||||
|
||||
@@ -547,11 +547,8 @@ Phase 1: session:start --auto "structured-description"
|
||||
↓ Write: planning-notes.md (User Intent section)
|
||||
↓
|
||||
Phase 2: context-gather --session sessionId "structured-description"
|
||||
↓ Input: sessionId + structured description + planning-notes.md (Phase 1 user intent)
|
||||
↓ CONTEXT PRIORITY SORTING IN CONTEXT-GATHER (Phase 2 Track -1 + Phase 3)
|
||||
↓ Input: sessionId + structured description
|
||||
↓ Output: contextPath (context-package.json with prioritized_context) + conflict_risk
|
||||
↓ - prioritized_context contains: user_intent, priority_tiers, dependency_order
|
||||
↓ - Eliminates redundant sorting in task-generate-agent Phase 1
|
||||
↓ Update: planning-notes.md (Context Findings + Consolidated Constraints)
|
||||
↓
|
||||
Phase 3: conflict-resolution [AUTO-TRIGGERED if conflict_risk ≥ medium]
|
||||
@@ -561,10 +558,7 @@ Phase 3: conflict-resolution [AUTO-TRIGGERED if conflict_risk ≥ medium]
|
||||
↓ Skip if conflict_risk is none/low → proceed directly to Phase 4
|
||||
↓
|
||||
Phase 4: task-generate-agent --session sessionId
|
||||
↓ Input: sessionId + planning-notes.md + context-package.json (with prioritized_context) + brainstorm artifacts
|
||||
↓ USE PRIORITIZED_CONTEXT DIRECTLY - NO REDUNDANT SORTING
|
||||
↓ - planning-notes.md provides: User Intent, Context Findings, Constraints
|
||||
↓ - context-package.prioritized_context provides: Pre-sorted priority_tiers, dependency_order
|
||||
↓ Input: sessionId + planning-notes.md + context-package.json + brainstorm artifacts
|
||||
↓ Output: IMPL_PLAN.md, task JSONs, TODO_LIST.md
|
||||
↓
|
||||
Return summary to user
|
||||
|
||||
@@ -25,10 +25,10 @@ Analyzes conflicts between implementation plans and existing codebase, **includi
|
||||
| Responsibility | Description |
|
||||
|---------------|-------------|
|
||||
| **Detect Conflicts** | Analyze plan vs existing code inconsistencies |
|
||||
| **Scenario Uniqueness** | **NEW**: Search and compare new modules with existing modules for functional overlaps |
|
||||
| **Scenario Uniqueness** | Search and compare new modules with existing modules for functional overlaps |
|
||||
| **Generate Strategies** | Provide 2-4 resolution options per conflict |
|
||||
| **Iterative Clarification** | **NEW**: Ask unlimited questions until scenario boundaries are clear and unique |
|
||||
| **Agent Re-analysis** | **NEW**: Dynamically update strategies based on user clarifications |
|
||||
| **Iterative Clarification** | Ask unlimited questions until scenario boundaries are clear and unique |
|
||||
| **Agent Re-analysis** | Dynamically update strategies based on user clarifications |
|
||||
| **CLI Analysis** | Use Gemini/Qwen (Claude fallback) |
|
||||
| **User Decision** | Present options ONE BY ONE, never auto-apply |
|
||||
| **Direct Text Output** | Output questions via text directly, NEVER use bash echo/printf |
|
||||
@@ -57,7 +57,7 @@ Analyzes conflicts between implementation plans and existing codebase, **includi
|
||||
- Breaking updates
|
||||
|
||||
### 5. Module Scenario Overlap
|
||||
- **NEW**: Functional overlap between new and existing modules
|
||||
- Functional overlap between new and existing modules
|
||||
- Scenario boundary ambiguity
|
||||
- Duplicate responsibility detection
|
||||
- Module merge/split decisions
|
||||
@@ -134,7 +134,7 @@ Task(subagent_type="cli-execution-agent", run_in_background=false, prompt=`
|
||||
### 1. Load Context
|
||||
- Read existing files from conflict_detection.existing_files
|
||||
- Load plan from .workflow/active/{session_id}/.process/context-package.json
|
||||
- **NEW**: Load exploration_results and use aggregated_insights for enhanced analysis
|
||||
- Load exploration_results and use aggregated_insights for enhanced analysis
|
||||
- Extract role analyses and requirements
|
||||
|
||||
### 2. Execute CLI Analysis (Enhanced with Exploration + Scenario Uniqueness)
|
||||
@@ -200,27 +200,6 @@ Task(subagent_type="cli-execution-agent", run_in_background=false, prompt=`
|
||||
`)
|
||||
```
|
||||
|
||||
**Agent Internal Flow** (Enhanced):
|
||||
```
|
||||
1. Load context package
|
||||
2. Check conflict_risk (exit if none/low)
|
||||
3. Read existing files + plan artifacts
|
||||
4. Run CLI analysis (Gemini→Qwen→Claude) with enhanced tasks:
|
||||
- Standard conflict detection (Architecture/API/Data/Dependency)
|
||||
- **NEW: Module scenario uniqueness detection**
|
||||
* Extract new module functionality from plan
|
||||
* Search all existing modules with similar keywords/functionality
|
||||
* Compare scenario coverage and responsibilities
|
||||
* Identify functional overlaps and boundary ambiguities
|
||||
* Generate ModuleOverlap conflicts with overlap_analysis
|
||||
5. Parse conflict findings (including ModuleOverlap category)
|
||||
6. Generate 2-4 strategies per conflict:
|
||||
- Include modifications for each strategy
|
||||
- **For ModuleOverlap**: Add clarification_needed questions for boundary definition
|
||||
7. Return JSON to stdout (NOT file write)
|
||||
8. Return execution log path
|
||||
```
|
||||
|
||||
### Phase 3: User Interaction Loop
|
||||
|
||||
```javascript
|
||||
|
||||
@@ -396,118 +396,9 @@ Refer to `context-search-agent.md` Phase 3.7 for complete `context-package.json`
|
||||
- **exploration_results**: Aggregated exploration insights (from parallel explore phase)
|
||||
- **prioritized_context**: Pre-sorted context with user intent and priority tiers (critical/high/medium/low)
|
||||
|
||||
## Historical Archive Analysis
|
||||
|
||||
### Track 1: Query Archive Manifest
|
||||
|
||||
The context-search-agent MUST perform historical archive analysis as Track 1 in Phase 2:
|
||||
|
||||
**Step 1: Check for Archive Manifest**
|
||||
```bash
|
||||
# Check if archive manifest exists
|
||||
if [[ -f .workflow/archives/manifest.json ]]; then
|
||||
# Manifest available for querying
|
||||
fi
|
||||
```
|
||||
|
||||
**Step 2: Extract Task Keywords**
|
||||
```javascript
|
||||
// From current task description, extract key entities and operations
|
||||
const keywords = extractKeywords(task_description);
|
||||
// Examples: ["User", "model", "authentication", "JWT", "reporting"]
|
||||
```
|
||||
|
||||
**Step 3: Search Archive for Relevant Sessions**
|
||||
```javascript
|
||||
// Query manifest for sessions with matching tags or descriptions
|
||||
const relevantArchives = archives.filter(archive => {
|
||||
return archive.tags.some(tag => keywords.includes(tag)) ||
|
||||
keywords.some(kw => archive.description.toLowerCase().includes(kw.toLowerCase()));
|
||||
});
|
||||
```
|
||||
|
||||
**Step 4: Extract Watch Patterns**
|
||||
```javascript
|
||||
// For each relevant archive, check watch_patterns for applicability
|
||||
const historicalConflicts = [];
|
||||
|
||||
relevantArchives.forEach(archive => {
|
||||
archive.lessons.watch_patterns?.forEach(pattern => {
|
||||
// Check if pattern trigger matches current task
|
||||
if (isPatternRelevant(pattern.pattern, task_description)) {
|
||||
historicalConflicts.push({
|
||||
source_session: archive.session_id,
|
||||
pattern: pattern.pattern,
|
||||
action: pattern.action,
|
||||
files_to_check: pattern.related_files,
|
||||
archived_at: archive.archived_at
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
**Step 5: Inject into Context Package**
|
||||
```json
|
||||
{
|
||||
"conflict_detection": {
|
||||
"risk_level": "medium",
|
||||
"risk_factors": ["..."],
|
||||
"affected_modules": ["..."],
|
||||
"mitigation_strategy": "...",
|
||||
"historical_conflicts": [
|
||||
{
|
||||
"source_session": "WFS-auth-feature",
|
||||
"pattern": "When modifying User model",
|
||||
"action": "Check reporting-service and auditing-service dependencies",
|
||||
"files_to_check": ["src/models/User.ts", "src/services/reporting.ts"],
|
||||
"archived_at": "2025-09-16T09:00:00Z"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Risk Level Escalation
|
||||
|
||||
If `historical_conflicts` array is not empty, minimum risk level should be "medium":
|
||||
|
||||
```javascript
|
||||
if (historicalConflicts.length > 0 && currentRisk === "low") {
|
||||
conflict_detection.risk_level = "medium";
|
||||
conflict_detection.risk_factors.push(
|
||||
`${historicalConflicts.length} historical conflict pattern(s) detected from past sessions`
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
### Archive Query Algorithm
|
||||
|
||||
```markdown
|
||||
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)
|
||||
c. Filter archives where:
|
||||
- ANY tag matches keywords (case-insensitive) OR
|
||||
- description contains keywords (case-insensitive substring match)
|
||||
d. For each relevant archive:
|
||||
- Read lessons.watch_patterns array
|
||||
- Check if pattern.pattern keywords overlap with task_description
|
||||
- If relevant: Add to historical_conflicts array
|
||||
e. IF historical_conflicts.length > 0:
|
||||
- Set risk_level = max(current_risk, "medium")
|
||||
- Add to risk_factors
|
||||
3. Continue to Track 2 (reference documentation)
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
- **Detection-first**: Always check for existing package before invoking agent
|
||||
- **User intent integration**: Load user intent from planning-notes.md (Phase 1 output) to ensure context aligns with user goals
|
||||
- **Priority sorting in Phase 2**: Track -1 (User Intent & Priority Foundation) establishes baseline priorities BEFORE other track analysis
|
||||
- **Dual project file integration**: Agent reads both `.workflow/project-tech.json` (tech analysis) and `.workflow/project-guidelines.json` (user constraints) as primary sources
|
||||
- **Guidelines injection**: Project guidelines are included in context-package to ensure task generation respects user-defined constraints
|
||||
- **Prioritized context output**: `prioritized_context` field provides pre-sorted context with priority tiers
|
||||
- **No redundancy**: Context sorting happens once (Phase 2 Track -1 + Phase 3), not duplicated in Phase 4
|
||||
- **User intent integration**: Load user intent from planning-notes.md (Phase 1 output)
|
||||
- **Output**: Generates `context-package.json` with `prioritized_context` field
|
||||
- **Plan-specific**: Use this for implementation planning; brainstorm mode uses direct agent call
|
||||
|
||||
@@ -664,5 +664,4 @@ function resolveCrossModuleDependency(placeholder, allTasks) {
|
||||
? candidates.sort((a, b) => a.id.localeCompare(b.id))[0].id
|
||||
: placeholder; // Keep for manual resolution
|
||||
}
|
||||
```
|
||||
|
||||
```
|
||||
Reference in New Issue
Block a user