Skip to content

Commit a9469a5

Browse files
author
catlog22
committed
feat: add spec-setup command for project initialization and interactive configuration
- Introduced a new command `spec-setup` to initialize project-level state. - Generates `.workflow/project-tech.json` and `.ccw/specs/*.md` files. - Implements a multi-round interactive questionnaire for configuring project guidelines. - Supports flags for regeneration, skipping specs, and resetting existing content. - Integrates analysis via `cli-explore-agent` for comprehensive project understanding. - Provides detailed execution process and error handling for various scenarios.
1 parent f2d4364 commit a9469a5

25 files changed

Lines changed: 3473 additions & 1820 deletions

File tree

.claude/commands/ccw-coordinator.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -923,8 +923,9 @@ Task: <description>
923923
**Cycle Workflows**: workflow:integration-test-cycle, workflow:refactor-cycle
924924
**Execution**: workflow:unified-execute-with-file
925925
**Design**: workflow:ui-design:*
926-
**Session Management**: workflow:session:start, workflow:session:resume, workflow:session:complete, workflow:session:solidify, workflow:session:list, workflow:session:sync
927-
**Utility**: workflow:clean, workflow:init, workflow:init-guidelines, workflow:status
926+
**Session Management**: workflow:session:start, workflow:session:resume, workflow:session:complete, workflow:session:list, workflow:session:sync
927+
**Utility**: workflow:clean, workflow:spec:setup, workflow:status
928+
**Spec Management**: workflow:spec:setup, workflow:spec:add
928929
**Issue Workflow**: issue:discover, issue:discover-by-prompt, issue:plan, issue:queue, issue:execute, issue:convert-to-plan, issue:from-brainstorm, issue:new
929930
930931
### Testing Commands Distinction

.claude/commands/ccw.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -760,8 +760,8 @@ todos = [
760760
|---------|---------|
761761
| `workflow:unified-execute-with-file` | Universal execution engine - consumes plan output from collaborative-plan, roadmap, brainstorm |
762762
| `workflow:clean` | Intelligent code cleanup - mainline detection, stale artifact removal |
763-
| `workflow:init` | Initialize `.workflow/project-tech.json` with project analysis |
764-
| `workflow:init-guidelines` | Interactive wizard to fill `specs/*.md` |
763+
| `workflow:spec:setup` | Initialize `.workflow/project-tech.json` with project analysis and specs scaffold |
764+
| `workflow:spec:add` | Interactive wizard to add individual specs with scope selection |
765765
| `workflow:status` | Generate on-demand views for project overview and workflow tasks |
766766
767767
---
@@ -817,7 +817,7 @@ todos = [
817817
# Utility commands (invoked directly, not auto-routed)
818818
# /workflow:unified-execute-with-file # 通用执行引擎(消费 plan 输出)
819819
# /workflow:clean # 智能代码清理
820-
# /workflow:init # 初始化项目状态
821-
# /workflow:init-guidelines # 交互式填充项目规范
820+
# /workflow:spec:setup # 初始化项目状态
821+
# /workflow:spec:add # 交互式填充项目规范
822822
# /workflow:status # 项目概览和工作流状态
823823
```

.claude/commands/flow-create.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ async function selectCommandCategory() {
9393
{ label: "Brainstorm", description: "brainstorm-with-file, brainstorm (unified skill)" },
9494
{ label: "Analysis", description: "analyze-with-file" },
9595
{ label: "Issue", description: "discover, plan, queue, execute, from-brainstorm, convert-to-plan" },
96-
{ label: "Utility", description: "clean, init, replan, status" }
96+
{ label: "Utility", description: "clean, spec:setup, spec:add, replan, status" }
9797
],
9898
multiSelect: false
9999
}]
@@ -153,7 +153,7 @@ async function selectCommand(category) {
153153
],
154154
'Utility': [
155155
{ label: "/workflow:clean", description: "Intelligent code cleanup" },
156-
{ label: "/workflow:init", description: "Initialize project-level state" },
156+
{ label: "/workflow:spec:setup", description: "Initialize project-level state" },
157157
{ label: "/workflow:replan", description: "Interactive workflow replanning" },
158158
{ label: "/workflow:status", description: "Generate workflow status views" }
159159
]

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

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ When `--yes` or `-y`: Auto-confirm exploration decisions, use recommended analys
6565

6666
## Implementation
6767

68+
### AskUserQuestion Constraints
69+
70+
All `AskUserQuestion` calls MUST comply:
71+
- **questions**: 1-4 questions per call
72+
- **options**: 2-4 per question (system auto-adds "Other" for free-text input)
73+
- **header**: max 12 characters
74+
- **label**: 1-5 words per option
75+
6876
### Session Initialization
6977

7078
1. Extract topic/question from `$ARGUMENTS`
@@ -79,10 +87,10 @@ When `--yes` or `-y`: Auto-confirm exploration decisions, use recommended analys
7987
### Phase 1: Topic Understanding
8088

8189
1. **Parse Topic & Identify Dimensions** — Match keywords against Analysis Dimensions table
82-
2. **Initial Scoping** (if new session + not auto mode):
83-
- **Focus**: Multi-select from Dimension-Direction Mapping directions
84-
- **Perspectives**: Multi-select up to 4 (see Analysis Perspectives), default: single comprehensive
85-
- **Depth**: Quick Overview (10-15min) / Standard (30-60min) / Deep Dive (1-2hr)
90+
2. **Initial Scoping** (if new session + not auto mode) — use **single AskUserQuestion call with up to 3 questions**:
91+
- Q1 **Focus** (multiSelect: true, header: "分析方向"): Top 3-4 directions from Dimension-Direction Mapping (options max 4)
92+
- Q2 **Perspectives** (multiSelect: true, header: "分析视角"): Up to 4 from Analysis Perspectives table (options max 4), default: single comprehensive
93+
- Q3 **Depth** (multiSelect: false, header: "分析深度"): Quick Overview / Standard / Deep Dive (3 options)
8694
3. **Initialize discussion.md** — Structure includes:
8795
- **Dynamic TOC** (top of file, updated after each round/phase): `## Table of Contents` with links to major sections
8896
- **Current Understanding** (replaceable block, overwritten each round — NOT appended): `## Current Understanding` initialized as "To be populated after exploration"
@@ -223,31 +231,26 @@ CONSTRAINTS: Focus on ${dimensions.join(', ')}
223231

224232
2. **Present Findings** from explorations.json
225233

226-
3. **Gather Feedback** (AskUserQuestion, single-select):
227-
- **同意,继续深入**: Direction correct, deepen
228-
- **同意,并建议下一步**: Agree with direction, but user has specific next step in mind
229-
- **需要调整方向**: Different focus
234+
3. **Gather Feedback** (AskUserQuestion, single-select, header: "分析反馈"):
235+
- **继续深入**: Direction correctdeepen automatically or user specifies direction (combines agree+deepen and agree+suggest)
236+
- **调整方向**: Different focus or specific questions to address
237+
- **补充信息**: User has additional context, constraints, or corrections to provide
230238
- **分析完成**: Sufficient → exit to Phase 4
231-
- **有具体问题**: Specific questions
232239

233240
4. **Process Response** (always record user choice + impact to discussion.md):
234241

235-
**Agree, Deepen** → Dynamically generate deepen directions from current analysis context:
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"
238-
- Each option specifies: label, description, tool (cli-explore-agent for code-level / Gemini CLI for pattern-level), scope
239-
- AskUserQuestion with generated options (single-select)
240-
- Execute selected direction via corresponding tool
241-
- Merge new code_anchors/call_chains into existing results
242-
- Record confirmed assumptions + deepen angle
243-
244-
**Agree, Suggest Next Step** → AskUserQuestion (free text: "请描述您希望下一步深入的方向") → Execute user's specific direction via cli-explore-agent or CLI → Record user-driven exploration rationale
242+
**继续深入** → Sub-question to choose direction (AskUserQuestion, single-select, header: "深入方向"):
243+
- Dynamically generate **max 3** context-driven options from: unresolved questions, low-confidence findings, unexplored dimensions, user-highlighted areas
244+
- Add **1** heuristic option that breaks current frame (e.g., "compare with best practices", "review from security perspective", "explore simpler alternatives")
245+
- Total: **max 4 options**. Each specifies: label, description, tool (cli-explore-agent for code-level / Gemini CLI for pattern-level), scope
246+
- **"Other" is auto-provided** by AskUserQuestion — covers user-specified custom direction (no need for separate "suggest next step" option)
247+
- Execute selected direction → merge new code_anchors/call_chains → record confirmed assumptions + deepen angle
245248

246-
**Adjust Direction** → AskUserQuestion for new focus → new CLI exploration → Record Decision (old vs new direction, reason, impact)
249+
**调整方向** → AskUserQuestion (header: "新方向", user selects or provides custom via "Other") → new CLI exploration → Record Decision (old vs new direction, reason, impact)
247250

248-
**Specific Questions** → Capture, answer via CLI/analysis, document Q&A → Record gaps revealed + new understanding
251+
**补充信息** → Capture user input, integrate into context, answer questions via CLI/analysis if needed → Record corrections/additions + updated understanding
249252

250-
**Complete** → Exit loop → Record why concluding
253+
**分析完成** → Exit loop → Record why concluding
251254

252255
5. **Update discussion.md**:
253256
- **Append** Round N: user input, direction adjustment, Q&A, corrections, new insights
@@ -319,11 +322,11 @@ CONSTRAINTS: Focus on ${dimensions.join(', ')}
319322
```
320323
For each recommendation (ordered by priority high→medium→low):
321324
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
325+
2. AskUserQuestion (single-select, header: "建议#N"):
326+
- **确认** (label: "确认", desc: "Accept as-is") → review_status = "accepted"
327+
- **修改** (label: "修改", desc: "Adjust scope/steps") → record modification → review_status = "modified"
328+
- **删除** (label: "删除", desc: "Not needed") → record reason → review_status = "rejected"
329+
- **跳过审议** (label: "跳过审议", desc: "Accept all remaining") → break loop
327330
3. Record review decision to discussion.md Decision Log
328331
4. Update conclusions.json recommendation.review_status
329332
```

.claude/commands/workflow/collaborative-plan-with-file.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,11 @@ Schema (tasks): ~/.ccw/workflows/cli-templates/schemas/task-schema.json
587587
- Execution command
588588
- Conflict status
589589

590-
6. **Update Todo**
590+
6. **Sync Session State**
591+
- Execute: `/workflow:session:sync -y "Plan complete: ${subDomains.length} domains, ${allTasks.length} tasks"`
592+
- Updates specs/*.md with planning insights and project-tech.json with planning session entry
593+
594+
7. **Update Todo**
591595
- Set Phase 4 status to `completed`
592596

593597
**plan.md Structure**:

0 commit comments

Comments
 (0)