From c67817f46e2ace215326ec1e7332369bad48dcef Mon Sep 17 00:00:00 2001 From: catlog22 Date: Sat, 29 Nov 2025 20:25:48 +0800 Subject: [PATCH] fix: Clarify multi-round clarification and enforce session timestamp format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Phase 2 Clarification: max 4 questions per round, multiple rounds allowed - Session Setup: MANDATORY timestamp in sessionId format (slug-YYYY-MM-DD-HH-mm-ss) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .claude/commands/workflow/lite-fix.md | 50 +++++++++++++++----------- .claude/commands/workflow/lite-plan.md | 50 +++++++++++++++----------- 2 files changed, 60 insertions(+), 40 deletions(-) diff --git a/.claude/commands/workflow/lite-fix.md b/.claude/commands/workflow/lite-fix.md index ac7951d9..d8b4e340 100644 --- a/.claude/commands/workflow/lite-fix.md +++ b/.claude/commands/workflow/lite-fix.md @@ -43,11 +43,11 @@ Phase 1: Bug Analysis & Diagnosis |- needsDiagnosis=true -> Launch parallel cli-explore-agents (1-4 based on severity) +- needsDiagnosis=false (hotfix) -> Skip directly to Phase 3 (Fix Planning) -Phase 2: Clarification (optional) +Phase 2: Clarification (optional, multi-round) |- Aggregate clarification_needs from all diagnosis angles |- Deduplicate similar questions +- Decision: - |- Has clarifications -> AskUserQuestion (max 4 questions) + |- Has clarifications -> AskUserQuestion (max 4 questions per round, multiple rounds allowed) +- No clarifications -> Skip to Phase 3 Phase 3: Fix Planning (NO CODE EXECUTION - planning only) @@ -71,15 +71,17 @@ Phase 5: Dispatch ### Phase 1: Intelligent Multi-Angle Diagnosis -**Session Setup**: +**Session Setup** (MANDATORY - follow exactly): ```javascript // Helper: Get UTC+8 (China Standard Time) ISO string const getUtc8ISOString = () => new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString() const bugSlug = bug_description.toLowerCase().replace(/[^a-z0-9]+/g, '-').substring(0, 40) const timestamp = getUtc8ISOString().replace(/[:.]/g, '-') -const shortTimestamp = timestamp.substring(0, 19).replace('T', '-') -const sessionId = `${bugSlug}-${shortTimestamp}` +const shortTimestamp = timestamp.substring(0, 19).replace('T', '-') // Format: 2025-11-29-14-30-25 + +// ⚠️ CRITICAL: sessionId MUST include both slug AND timestamp +const sessionId = `${bugSlug}-${shortTimestamp}` // e.g., "user-avatar-upload-fails-2025-11-29-14-30-25" const sessionFolder = `.workflow/.lite-fix/${sessionId}` bash(`mkdir -p ${sessionFolder}`) @@ -287,7 +289,7 @@ Angles diagnosed: ${diagnosisManifest.diagnoses.map(d => d.angle).join(', ')} --- -### Phase 2: Clarification (Optional) +### Phase 2: Clarification (Optional, Multi-Round) **Skip if**: No diagnosis or `clarification_needs` is empty across all diagnoses @@ -327,21 +329,29 @@ function deduplicateClarifications(clarifications) { const uniqueClarifications = deduplicateClarifications(allClarifications) +// Multi-round clarification: batch questions (max 4 per round) if (uniqueClarifications.length > 0) { - AskUserQuestion({ - questions: uniqueClarifications.map(need => ({ - question: `[${need.source_angle}] ${need.question}\n\nContext: ${need.context}`, - header: need.source_angle, - multiSelect: false, - options: need.options.map((opt, index) => { - const isRecommended = need.recommended === index - return { - label: isRecommended ? `${opt} ★` : opt, - description: isRecommended ? `Use ${opt} approach (Recommended)` : `Use ${opt} approach` - } - }) - })) - }) + const BATCH_SIZE = 4 + for (let i = 0; i < uniqueClarifications.length; i += BATCH_SIZE) { + const batch = uniqueClarifications.slice(i, i + BATCH_SIZE) + + AskUserQuestion({ + questions: batch.map(need => ({ + question: `[${need.source_angle}] ${need.question}\n\nContext: ${need.context}`, + header: need.source_angle, + multiSelect: false, + options: need.options.map((opt, index) => { + const isRecommended = need.recommended === index + return { + label: isRecommended ? `${opt} ★` : opt, + description: isRecommended ? `Use ${opt} approach (Recommended)` : `Use ${opt} approach` + } + }) + })) + }) + + // Store batch responses in clarificationContext before next round + } } ``` diff --git a/.claude/commands/workflow/lite-plan.md b/.claude/commands/workflow/lite-plan.md index 21276c10..52c83424 100644 --- a/.claude/commands/workflow/lite-plan.md +++ b/.claude/commands/workflow/lite-plan.md @@ -43,11 +43,11 @@ Phase 1: Task Analysis & Exploration ├─ needsExploration=true → Launch parallel cli-explore-agents (1-4 based on complexity) └─ needsExploration=false → Skip to Phase 2/3 -Phase 2: Clarification (optional) +Phase 2: Clarification (optional, multi-round) ├─ Aggregate clarification_needs from all exploration angles ├─ Deduplicate similar questions └─ Decision: - ├─ Has clarifications → AskUserQuestion (max 4 questions) + ├─ Has clarifications → AskUserQuestion (max 4 questions per round, multiple rounds allowed) └─ No clarifications → Skip to Phase 3 Phase 3: Planning (NO CODE EXECUTION - planning only) @@ -71,15 +71,17 @@ Phase 5: Dispatch ### Phase 1: Intelligent Multi-Angle Exploration -**Session Setup**: +**Session Setup** (MANDATORY - follow exactly): ```javascript // Helper: Get UTC+8 (China Standard Time) ISO string const getUtc8ISOString = () => new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString() const taskSlug = task_description.toLowerCase().replace(/[^a-z0-9]+/g, '-').substring(0, 40) const timestamp = getUtc8ISOString().replace(/[:.]/g, '-') -const shortTimestamp = timestamp.substring(0, 19).replace('T', '-') -const sessionId = `${taskSlug}-${shortTimestamp}` +const shortTimestamp = timestamp.substring(0, 19).replace('T', '-') // Format: 2025-11-29-14-30-25 + +// ⚠️ CRITICAL: sessionId MUST include both slug AND timestamp +const sessionId = `${taskSlug}-${shortTimestamp}` // e.g., "implement-jwt-refresh-2025-11-29-14-30-25" const sessionFolder = `.workflow/.lite-plan/${sessionId}` bash(`mkdir -p ${sessionFolder}`) @@ -276,7 +278,7 @@ Angles explored: ${explorationManifest.explorations.map(e => e.angle).join(', ') --- -### Phase 2: Clarification (Optional) +### Phase 2: Clarification (Optional, Multi-Round) **Skip if**: No exploration or `clarification_needs` is empty across all explorations @@ -316,21 +318,29 @@ function deduplicateClarifications(clarifications) { const uniqueClarifications = deduplicateClarifications(allClarifications) +// Multi-round clarification: batch questions (max 4 per round) if (uniqueClarifications.length > 0) { - AskUserQuestion({ - questions: uniqueClarifications.map(need => ({ - question: `[${need.source_angle}] ${need.question}\n\nContext: ${need.context}`, - header: need.source_angle, - multiSelect: false, - options: need.options.map((opt, index) => { - const isRecommended = need.recommended === index - return { - label: isRecommended ? `${opt} ★` : opt, - description: isRecommended ? `Use ${opt} approach (Recommended)` : `Use ${opt} approach` - } - }) - })) - }) + const BATCH_SIZE = 4 + for (let i = 0; i < uniqueClarifications.length; i += BATCH_SIZE) { + const batch = uniqueClarifications.slice(i, i + BATCH_SIZE) + + AskUserQuestion({ + questions: batch.map(need => ({ + question: `[${need.source_angle}] ${need.question}\n\nContext: ${need.context}`, + header: need.source_angle, + multiSelect: false, + options: need.options.map((opt, index) => { + const isRecommended = need.recommended === index + return { + label: isRecommended ? `${opt} ★` : opt, + description: isRecommended ? `Use ${opt} approach (Recommended)` : `Use ${opt} approach` + } + }) + })) + }) + + // Store batch responses in clarificationContext before next round + } } ```