Skip to content

Commit f2d4364

Browse files
author
catlog22
committed
Refactor multi-CLI planning documentation, enhance analyze-with-file skill, and implement timeout for DeepWiki API requests
- Updated SKILL.md for workflow-multi-cli-plan to streamline sections, clarify processes, and improve user decision points. - Enhanced analyze-with-file skill to include hypothesis impact in key findings and refined recording principles for better documentation. - Added fetchWithTimeout function to DeepWiki API calls to handle request timeouts, ensuring more robust error handling. - Introduced new DeepWiki routes in server.ts to manage API requests effectively. - Updated tsconfig.tsbuildinfo to reflect recent changes in the codebase structure.
1 parent 88149b6 commit f2d4364

8 files changed

Lines changed: 479 additions & 641 deletions

File tree

.claude/commands/workflow/analyze-with-file.md

Lines changed: 89 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ When `--yes` or `-y`: Auto-confirm exploration decisions, use recommended analys
1919

2020
| Phase | Artifact | Description |
2121
|-------|----------|-------------|
22-
| 1 | `discussion.md` | Evolution of understanding & discussions (initialized) |
22+
| 1 | `discussion.md` | Initialized with TOC, Current Understanding block, timeline, metadata |
2323
| 1 | Session variables | Dimensions, focus areas, analysis depth |
2424
| 2 | `exploration-codebase.json` | Single codebase context from cli-explore-agent |
2525
| 2 | `explorations/*.json` | Multi-perspective codebase explorations (parallel, up to 4) |
2626
| 2 | `explorations.json` | Single perspective aggregated findings |
2727
| 2 | `perspectives.json` | Multi-perspective findings (up to 4) with synthesis |
28-
| 2 | Updated `discussion.md` | Round 1 with exploration results |
29-
| 3 | Updated `discussion.md` | Round 2-N with user feedback and insights |
30-
| 4 | `conclusions.json` | Final synthesis with recommendations |
31-
| 4 | Final `discussion.md` | Complete analysis with conclusions |
28+
| 2 | Updated `discussion.md` | Round 1 + Initial Intent Coverage Check + Current Understanding replaced |
29+
| 3 | Updated `discussion.md` | Round 2-N: feedback, insights, narrative synthesis; TOC + Current Understanding updated each round |
30+
| 4 | `conclusions.json` | Final synthesis with recommendations (incl. steps[] + review_status) |
31+
| 4 | Final `discussion.md` | Complete analysis with conclusions, recommendation review summary, intent coverage matrix |
3232

3333
### Decision Recording Protocol
3434

@@ -37,7 +37,7 @@ When `--yes` or `-y`: Auto-confirm exploration decisions, use recommended analys
3737
| Trigger | What to Record | Target Section |
3838
|---------|---------------|----------------|
3939
| **Direction choice** | What chosen, why, alternatives discarded | `#### Decision Log` |
40-
| **Key finding** | Content, impact scope, confidence level | `#### Key Findings` |
40+
| **Key finding** | Content, impact scope, confidence level, hypothesis impact | `#### Key Findings` |
4141
| **Assumption change** | Old → new understanding, reason, impact | `#### Corrected Assumptions` |
4242
| **User feedback** | Input, rationale for adoption/adjustment | `#### User Input` |
4343
| **Disagreement & trade-off** | Conflicting views, trade-off basis, final choice | `#### Decision Log` |
@@ -49,10 +49,19 @@ When `--yes` or `-y`: Auto-confirm exploration decisions, use recommended analys
4949
> - **Context**: [Trigger]
5050
> - **Options considered**: [Alternatives]
5151
> - **Chosen**: [Approach]**Reason**: [Rationale]
52+
> - **Rejected**: [Why other options were discarded]
5253
> - **Impact**: [Effect on analysis]
5354
```
5455

55-
**Principles**: Immediacy (record as-it-happens), Completeness (context+options+chosen+reason), Traceability (later phases trace back)
56+
**Key Finding Record Format**:
57+
```markdown
58+
> **Finding**: [Content]
59+
> - **Confidence**: [High/Medium/Low]**Why**: [Evidence basis]
60+
> - **Hypothesis Impact**: [Confirms/Refutes/Modifies] hypothesis "[name]"
61+
> - **Scope**: [What areas this affects]
62+
```
63+
64+
**Principles**: Immediacy (record as-it-happens), Completeness (context+options+chosen+reason+rejected), Traceability (later phases trace back), Depth (capture reasoning, not just outcomes)
5665

5766
## Implementation
5867

@@ -74,7 +83,10 @@ When `--yes` or `-y`: Auto-confirm exploration decisions, use recommended analys
7483
- **Focus**: Multi-select from Dimension-Direction Mapping directions
7584
- **Perspectives**: Multi-select up to 4 (see Analysis Perspectives), default: single comprehensive
7685
- **Depth**: Quick Overview (10-15min) / Standard (30-60min) / Deep Dive (1-2hr)
77-
3. **Initialize discussion.md** — Session metadata, user context, initial understanding, empty discussion timeline, initial dimension selection rationale
86+
3. **Initialize discussion.md** — Structure includes:
87+
- **Dynamic TOC** (top of file, updated after each round/phase): `## Table of Contents` with links to major sections
88+
- **Current Understanding** (replaceable block, overwritten each round — NOT appended): `## Current Understanding` initialized as "To be populated after exploration"
89+
- Session metadata, user context, initial questions, empty discussion timeline, initial dimension selection rationale
7890
4. **Record Phase 1 Decisions** — Dimension selection reasoning, depth rationale, any user adjustments
7991

8092
**Success**: Session folder + discussion.md created, dimensions identified, preferences captured, decisions recorded
@@ -178,6 +190,13 @@ CONSTRAINTS: Focus on ${dimensions.join(', ')}
178190

179191
**Step 4: Update discussion.md** — Append Round 1 with sources, key findings, discussion points, open questions
180192

193+
**Step 5: Initial Intent Coverage Check** (FIRST check, before entering Phase 3):
194+
- Re-read original "User Intent" / "Analysis Context" from discussion.md header
195+
- Check each intent item against Round 1 findings: ✅ addressed / 🔄 in-progress / ❌ not yet touched
196+
- Append initial Intent Coverage Check to discussion.md
197+
- Present to user at beginning of Phase 3: "初始探索完成后,以下意图的覆盖情况:[list]。接下来的讨论将重点关注未覆盖的部分。"
198+
- Purpose: Early course correction — catch drift before spending multiple interactive rounds
199+
181200
**explorations.json Schema** (single):
182201
- `session_id`, `timestamp`, `topic`, `dimensions[]`
183202
- `sources[]`: {type, file/summary}
@@ -198,32 +217,54 @@ CONSTRAINTS: Focus on ${dimensions.join(', ')}
198217

199218
**Loop** (max 5 rounds):
200219

201-
1. **Present Findings** from explorations.json
202-
2. **Gather Feedback** (AskUserQuestion, single-select):
220+
1. **Current Understanding Summary** (Round >= 2, BEFORE presenting new findings):
221+
- Generate 1-2 sentence recap: "到目前为止,我们已确认 [established facts]。上一轮 [key action/direction]。现在,这是新一轮的发现:"
222+
- Purpose: Reset context, prevent cognitive overload, make incremental progress visible
223+
224+
2. **Present Findings** from explorations.json
225+
226+
3. **Gather Feedback** (AskUserQuestion, single-select):
203227
- **同意,继续深入**: Direction correct, deepen
228+
- **同意,并建议下一步**: Agree with direction, but user has specific next step in mind
204229
- **需要调整方向**: Different focus
205230
- **分析完成**: Sufficient → exit to Phase 4
206231
- **有具体问题**: Specific questions
207232

208-
3. **Process Response** (always record user choice + impact to discussion.md):
233+
4. **Process Response** (always record user choice + impact to discussion.md):
209234

210235
**Agree, Deepen** → Dynamically generate deepen directions from current analysis context:
211-
- Extract 3-4 options from: unresolved questions in explorations.json, low-confidence findings, unexplored dimensions, user-highlighted areas
236+
- Extract 2-3 context-driven options from: unresolved questions in explorations.json, low-confidence findings, unexplored dimensions, user-highlighted areas
237+
- Generate 1-2 heuristic options that break current frame: e.g., "compare with best practices in [related domain]", "analyze under extreme load scenarios", "review from security audit perspective", "explore simpler architectural alternatives"
212238
- Each option specifies: label, description, tool (cli-explore-agent for code-level / Gemini CLI for pattern-level), scope
213239
- AskUserQuestion with generated options (single-select)
214240
- Execute selected direction via corresponding tool
215241
- Merge new code_anchors/call_chains into existing results
216242
- Record confirmed assumptions + deepen angle
217243

244+
**Agree, Suggest Next Step** → AskUserQuestion (free text: "请描述您希望下一步深入的方向") → Execute user's specific direction via cli-explore-agent or CLI → Record user-driven exploration rationale
245+
218246
**Adjust Direction** → AskUserQuestion for new focus → new CLI exploration → Record Decision (old vs new direction, reason, impact)
219247

220248
**Specific Questions** → Capture, answer via CLI/analysis, document Q&A → Record gaps revealed + new understanding
221249

222250
**Complete** → Exit loop → Record why concluding
223251

224-
4. **Update discussion.md** — Append Round N: user input, direction adjustment, Q&A, updated understanding, corrections, new insights
252+
5. **Update discussion.md**:
253+
- **Append** Round N: user input, direction adjustment, Q&A, corrections, new insights
254+
- **Replace** `## Current Understanding` block with latest consolidated understanding (follow Consolidation Rules: promote confirmed, track corrections, focus on NOW)
255+
- **Update** `## Table of Contents` with links to new Round N sections
225256

226-
5. **Intent Drift Check** (every round >= 2):
257+
6. **Round Narrative Synthesis** (append to discussion.md after each round update):
258+
```markdown
259+
### Round N: Narrative Synthesis
260+
**起点**: 基于上一轮的 [conclusions/questions],本轮从 [starting point] 切入。
261+
**关键进展**: [New findings] [confirmed/refuted/modified] 了之前关于 [hypothesis] 的理解。
262+
**决策影响**: 用户选择 [feedback type],导致分析方向 [adjusted/deepened/maintained]
263+
**当前理解**: 经过本轮,核心认知更新为 [updated understanding]
264+
**遗留问题**: [remaining questions driving next round]
265+
```
266+
267+
7. **Intent Drift Check** (every round >= 2):
227268
- Re-read original "User Intent" from discussion.md header
228269
- Check each item: addressed / in-progress / implicitly absorbed / not yet discussed
229270
```markdown
@@ -233,9 +274,9 @@ CONSTRAINTS: Focus on ${dimensions.join(', ')}
233274
- ⚠️ Intent 3: [implicitly absorbed by X — needs confirmation]
234275
- ❌ Intent 4: [not yet discussed]
235276
```
236-
- If ❌ or ⚠️ after 3+ rounds → surface to user in next round
277+
- If ❌ or ⚠️ items exist → **proactively surface** to user at start of next round: "以下原始意图尚未充分覆盖:[list]。是否需要调整优先级?"
237278

238-
**Success**: All rounds documented, assumptions corrected, all decisions recorded, direction changes with before/after
279+
**Success**: All rounds documented with narrative synthesis, assumptions corrected, all decisions recorded with rejection reasoning, direction changes with before/after
239280

240281
### Phase 4: Synthesis & Conclusion
241282

@@ -267,13 +308,33 @@ CONSTRAINTS: Focus on ${dimensions.join(', ')}
267308
- Session statistics: rounds, duration, sources, artifacts, decision count
268309

269310
4. **Display Conclusions Summary** — Present to user:
270-
- **Analysis Report**: summary, key conclusions (numbered, with confidence), recommendations (numbered, with priority + rationale)
311+
- **Analysis Report**: summary, key conclusions (numbered, with confidence), recommendations (numbered, with priority + rationale + steps)
271312
- Open questions if any
272313
- Link to full report: `{sessionFolder}/discussion.md`
273314

274-
5. **Post-Completion Options** (TERMINAL — analyze-with-file ends after selection):
315+
5. **Interactive Recommendation Review** (skip in auto mode):
316+
317+
Walk through each recommendation one-by-one for user confirmation:
318+
319+
```
320+
For each recommendation (ordered by priority high→medium→low):
321+
1. Present: action, rationale, priority, steps[] (numbered sub-steps)
322+
2. AskUserQuestion (single-select, header: "Rec #N"):
323+
- **确认**: Accept as-is → review_status = "accepted"
324+
- **修改**: User adjusts scope/steps → record modification → review_status = "modified"
325+
- **删除**: Not needed → record reason → review_status = "rejected"
326+
- **跳过逐条审议**: Accept all remaining as-is → break loop
327+
3. Record review decision to discussion.md Decision Log
328+
4. Update conclusions.json recommendation.review_status
329+
```
330+
331+
**After review loop**: Display summary of reviewed recommendations:
332+
- Accepted: N items | Modified: N items | Rejected: N items
333+
- Only accepted/modified recommendations proceed to next step
275334

276-
> **WORKFLOW BOUNDARY**: After selection, analyze-with-file is **COMPLETE**. If "执行任务" selected, workflow-lite-plan takes over exclusively.
335+
6. **Post-Completion Options** (analyze-with-file transitions based on user selection):
336+
337+
> **WORKFLOW TRANSITION**: "执行任务" MUST invoke `Skill(skill="workflow-lite-plan")` — do NOT end without calling it.
277338
278339
AskUserQuestion (single-select, header: "Next Step"):
279340
- **执行任务** (Recommended if high/medium priority recs exist): Launch workflow-lite-plan
@@ -286,24 +347,24 @@ CONSTRAINTS: Focus on ${dimensions.join(', ')}
286347
- Create via pipe: `echo '<issue-json>' | ccw issue create`
287348
2. Display created issue IDs with next step hint: `/issue:plan <id>`
288349

289-
**Handle "执行任务"** (TERMINAL — analyze-with-file ends here, lite-plan takes over):
350+
**Handle "执行任务"** — MUST invoke Skill tool (do NOT just display a summary and stop):
290351
1. Build `taskDescription` from high/medium priority recommendations (fallback: summary)
291352
2. Assemble context: `## Prior Analysis ({sessionId})` + summary + key files (up to 8) + key findings (up to 5) from exploration-codebase.json
292-
3. Output session termination boundary:
293-
```
294-
⛔ ANALYZE-WITH-FILE SESSION COMPLETE
295-
All Phase 1-4 are FINISHED. DO NOT reference analyze-with-file phase instructions beyond this point.
353+
3. **MANDATORY — Invoke Skill tool immediately** (this is the ONLY correct action, do NOT skip):
354+
```javascript
355+
Skill({ skill: "workflow-lite-plan", args: `${taskDescription}\n\n${contextLines}` })
296356
```
297-
4. Hand off: `Skill(skill="workflow-lite-plan", args="{taskDescription}\n\n{contextLines}")`
298-
5. Return — analyze-with-file terminates
357+
If Skill invocation is omitted, the workflow is BROKEN — user selected "执行任务" specifically to launch lite-plan.
358+
4. After Skill invocation, analyze-with-file is complete — do not output any additional content
299359

300360
**conclusions.json Schema**:
301361
- `session_id`, `topic`, `completed`, `total_rounds`, `summary`
302362
- `key_conclusions[]`: {point, evidence, confidence, code_anchor_refs[]}
303363
- `code_anchors[]`: {file, lines, snippet, significance}
304-
- `recommendations[]`: {action, rationale, priority}
364+
- `recommendations[]`: {action, rationale, priority, steps[]: {description, target, verification}, review_status: accepted|modified|rejected|pending}
305365
- `open_questions[]`, `follow_up_suggestions[]`: {type, summary}
306-
- `decision_trail[]`: {round, decision, context, options_considered, chosen, reason, impact}
366+
- `decision_trail[]`: {round, decision, context, options_considered, chosen, rejected_reasons, reason, impact}
367+
- `narrative_trail[]`: {round, starting_point, key_progress, hypothesis_impact, updated_understanding, remaining_questions}
307368
- `intent_coverage[]`: {intent, status, where_addressed, notes}
308369

309370
**Success**: conclusions.json created, discussion.md finalized, Intent Coverage Matrix verified, complete decision trail documented

0 commit comments

Comments
 (0)