Skip to content

Commit 1b6ace0

Browse files
author
catlog22
committed
feat: 添加规划笔记功能以支持任务生成和约束管理
1 parent a3b303d commit 1b6ace0

7 files changed

Lines changed: 274 additions & 28 deletions

File tree

.claude/agents/action-planning-agent.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,17 @@ color: yellow
5555
**Step-by-step execution**:
5656

5757
```
58+
0. Load planning notes → Extract phase-level constraints (NEW)
59+
Commands: Read('.workflow/active/{session-id}/planning-notes.md')
60+
Output: Consolidated constraints from all workflow phases
61+
Structure:
62+
- User Intent: Original GOAL, KEY_CONSTRAINTS
63+
- Context Findings: Critical files, architecture notes, constraints
64+
- Conflict Decisions: Resolved conflicts, modified artifacts
65+
- Consolidated Constraints: Numbered list of ALL constraints (Phase 1-3)
66+
67+
USAGE: This is the PRIMARY source of constraints. All task generation MUST respect these constraints.
68+
5869
1. Load session metadata → Extract user input
5970
- User description: Original task/feature requirements
6071
- Project scope: User-specified boundaries and goals
@@ -826,6 +837,7 @@ Use `analysis_results.complexity` or task count to determine structure:
826837
### 3.3 Guidelines Checklist
827838
828839
**ALWAYS:**
840+
- **Load planning-notes.md FIRST**: Read planning-notes.md before context-package.json. Use its Consolidated Constraints as primary constraint source for all task generation
829841
- **Search Tool Priority**: ACE (`mcp__ace-tool__search_context`) → CCW (`mcp__ccw-tools__smart_search`) / Built-in (`Grep`, `Glob`, `Read`)
830842
- Apply Quantification Requirements to all requirements, acceptance criteria, and modification points
831843
- Load IMPL_PLAN template: `Read(~/.claude/workflows/cli-templates/prompts/workflow/impl-plan-template.txt)` before generating IMPL_PLAN.md

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Interactive brainstorming workflow with **multi-CLI collaboration** and **docume
1919

2020
**Key features**:
2121
- **brainstorm.md**: Complete thought evolution timeline
22-
- **Multi-CLI collaboration**: Gemini (creative), Codex (pragmatic), Qwen (systematic) perspectives
22+
- **Multi-CLI collaboration**: Gemini (creative), Codex (pragmatic), Claude (systematic) perspectives
2323
- **Idea expansion**: Progressive questioning and exploration
2424
- **Diverge-Converge cycles**: Generate options then focus on best paths
2525
- **Synthesis**: Merge multiple perspectives into coherent solutions
@@ -61,8 +61,8 @@ Phase 1: Seed Understanding
6161

6262
Phase 2: Divergent Exploration (Multi-CLI Parallel)
6363
├─ Gemini CLI: Creative/innovative perspectives
64-
├─ Codex CLI: Pragmatic/implementation perspectives
65-
├─ Qwen CLI: Systematic/architectural perspectives
64+
├─ Codex CLI: Pragmatic/implementation perspectives
65+
├─ Claude CLI: Systematic/architectural perspectives
6666
└─ Aggregate diverse viewpoints
6767

6868
Phase 3: Interactive Refinement (Multi-Round)
@@ -375,7 +375,7 @@ CONSTRAINTS: Focus on what can actually be built with current tech stack
375375
})
376376
)
377377
378-
// 3. Qwen: Systematic/Architectural Perspective
378+
// 3. Claude: Systematic/Architectural Perspective
379379
cliPromises.push(
380380
Bash({
381381
command: `ccw cli -p "
@@ -404,7 +404,7 @@ EXPECTED:
404404
- Risk matrix
405405
406406
CONSTRAINTS: Consider existing system architecture
407-
" --tool qwen --mode analysis`,
407+
" --tool claude --mode analysis`,
408408
run_in_background: true
409409
})
410410
)
@@ -436,7 +436,7 @@ const perspectives = {
436436
},
437437
438438
systematic: {
439-
source: 'qwen',
439+
source: 'claude',
440440
decomposition: [...],
441441
patterns: [...],
442442
tradeoffs: [...]
@@ -488,7 +488,7 @@ ${blockers.map(b => `- ⚠️ ${b}`).join('\n')}
488488
489489
---
490490
491-
#### Systematic Perspective (Qwen)
491+
#### Systematic Perspective (Claude)
492492
493493
**Problem Decomposition**:
494494
${decomposition}
@@ -956,7 +956,7 @@ ${decisionFramework}
956956
- **Total Rounds**: ${totalRounds}
957957
- **Ideas Generated**: ${totalIdeas}
958958
- **Ideas Survived**: ${survivedIdeas}
959-
- **Perspectives Used**: Gemini (creative), Codex (pragmatic), Qwen (systematic)
959+
- **Perspectives Used**: Gemini (creative), Codex (pragmatic), Claude (systematic)
960960
- **Duration**: ${duration}
961961
- **Artifacts**: brainstorm.md, perspectives.json, synthesis.json, ${ideaFiles.length} idea deep-dives
962962
```
@@ -1056,7 +1056,7 @@ if (selection.includes("导出分享")) {
10561056
#### Pragmatic Perspective (Codex)
10571057
...
10581058
1059-
#### Systematic Perspective (Qwen)
1059+
#### Systematic Perspective (Claude)
10601060
...
10611061
10621062
#### Perspective Synthesis
@@ -1105,7 +1105,7 @@ if (selection.includes("导出分享")) {
11051105
|-----|------|-------|----------|
11061106
| Gemini | Creative | Innovation, cross-domain | Generating novel ideas |
11071107
| Codex | Pragmatic | Implementation, feasibility | Reality-checking ideas |
1108-
| Qwen | Systematic | Architecture, structure | Organizing solutions |
1108+
| Claude | Systematic | Architecture, structure | Organizing solutions |
11091109
11101110
### Collaboration Patterns
11111111

.claude/commands/workflow/plan.md

Lines changed: 115 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,38 @@ CONTEXT: Existing user database schema, REST API endpoints
115115

116116
**TodoWrite**: Mark phase 1 completed, phase 2 in_progress
117117

118-
**After Phase 1**: Return to user showing Phase 1 results, then auto-continue to Phase 2
118+
**After Phase 1**: Initialize planning-notes.md with user intent
119+
120+
```javascript
121+
// Create minimal planning notes document
122+
const planningNotesPath = `.workflow/active/${sessionId}/planning-notes.md`
123+
const userGoal = structuredDescription.goal
124+
const userConstraints = structuredDescription.context || "None specified"
125+
126+
Write(planningNotesPath, `# Planning Notes
127+
128+
**Session**: ${sessionId}
129+
**Created**: ${new Date().toISOString()}
130+
131+
## User Intent (Phase 1)
132+
133+
- **GOAL**: ${userGoal}
134+
- **KEY_CONSTRAINTS**: ${userConstraints}
135+
136+
---
137+
138+
## Context Findings (Phase 2)
139+
(To be filled by context-gather)
140+
141+
## Conflict Decisions (Phase 3)
142+
(To be filled if conflicts detected)
143+
144+
## Consolidated Constraints (Phase 4 Input)
145+
1. ${userConstraints}
146+
`)
147+
```
148+
149+
Return to user showing Phase 1 results, then auto-continue to Phase 2
119150

120151
---
121152

@@ -168,7 +199,37 @@ SlashCommand(command="/workflow:tools:context-gather --session [sessionId] \"[st
168199

169200
**Note**: Phase 2 tasks completed and collapsed to summary.
170201

171-
**After Phase 2**: Return to user showing Phase 2 results, then auto-continue to Phase 3/4 (depending on conflict_risk)
202+
**After Phase 2**: Update planning-notes.md with context findings, then auto-continue
203+
204+
```javascript
205+
// Read context-package to extract key findings
206+
const contextPackage = JSON.parse(Read(contextPath))
207+
const conflictRisk = contextPackage.conflict_detection?.risk_level || 'low'
208+
const criticalFiles = (contextPackage.exploration_results?.aggregated_insights?.critical_files || [])
209+
.slice(0, 5).map(f => f.path)
210+
const archPatterns = contextPackage.project_context?.architecture_patterns || []
211+
const constraints = contextPackage.exploration_results?.aggregated_insights?.constraints || []
212+
213+
// Append Phase 2 findings to planning-notes.md
214+
Edit(planningNotesPath, {
215+
old: '## Context Findings (Phase 2)\n(To be filled by context-gather)',
216+
new: `## Context Findings (Phase 2)
217+
218+
- **CRITICAL_FILES**: ${criticalFiles.join(', ') || 'None identified'}
219+
- **ARCHITECTURE**: ${archPatterns.join(', ') || 'Not detected'}
220+
- **CONFLICT_RISK**: ${conflictRisk}
221+
- **CONSTRAINTS**: ${constraints.length > 0 ? constraints.join('; ') : 'None'}`
222+
})
223+
224+
// Append Phase 2 constraints to consolidated list
225+
Edit(planningNotesPath, {
226+
old: '## Consolidated Constraints (Phase 4 Input)',
227+
new: `## Consolidated Constraints (Phase 4 Input)
228+
${constraints.map((c, i) => `${i + 2}. [Context] ${c}`).join('\n')}`
229+
})
230+
```
231+
232+
Return to user showing Phase 2 results, then auto-continue to Phase 3/4 (depending on conflict_risk)
172233
173234
---
174235
@@ -229,7 +290,45 @@ SlashCommand(command="/workflow:tools:conflict-resolution --session [sessionId]
229290
230291
**Note**: Phase 3 tasks completed and collapsed to summary.
231292
232-
**After Phase 3**: Return to user showing conflict resolution results (if executed) and selected strategies, then auto-continue to Phase 3.5
293+
**After Phase 3**: Update planning-notes.md with conflict decisions (if executed), then auto-continue
294+
295+
```javascript
296+
// If Phase 3 was executed, update planning-notes.md
297+
if (conflictRisk >= 'medium') {
298+
const conflictResPath = `.workflow/active/${sessionId}/.process/conflict-resolution.json`
299+
300+
if (fs.existsSync(conflictResPath)) {
301+
const conflictRes = JSON.parse(Read(conflictResPath))
302+
const resolved = conflictRes.resolved_conflicts || []
303+
const modifiedArtifacts = conflictRes.modified_artifacts || []
304+
const planningConstraints = conflictRes.planning_constraints || []
305+
306+
// Update Phase 3 section
307+
Edit(planningNotesPath, {
308+
old: '## Conflict Decisions (Phase 3)\n(To be filled if conflicts detected)',
309+
new: `## Conflict Decisions (Phase 3)
310+
311+
- **RESOLVED**: ${resolved.map(r => `${r.type}${r.strategy}`).join('; ') || 'None'}
312+
- **MODIFIED_ARTIFACTS**: ${modifiedArtifacts.join(', ') || 'None'}
313+
- **CONSTRAINTS**: ${planningConstraints.join('; ') || 'None'}`
314+
})
315+
316+
// Append Phase 3 constraints to consolidated list
317+
if (planningConstraints.length > 0) {
318+
const currentNotes = Read(planningNotesPath)
319+
const constraintCount = (currentNotes.match(/^\d+\./gm) || []).length
320+
321+
Edit(planningNotesPath, {
322+
old: '## Consolidated Constraints (Phase 4 Input)',
323+
new: `## Consolidated Constraints (Phase 4 Input)
324+
${planningConstraints.map((c, i) => `${constraintCount + i + 1}. [Conflict] ${c}`).join('\n')}`
325+
})
326+
}
327+
}
328+
}
329+
```
330+
331+
Return to user showing conflict resolution results (if executed) and selected strategies, then auto-continue to Phase 3.5
233332
234333
**Memory State Check**:
235334
- Evaluate current context window usage and memory state
@@ -282,7 +381,12 @@ SlashCommand(command="/workflow:tools:task-generate-agent --session [sessionId]"
282381
283382
**CLI Execution Note**: CLI tool usage is now determined semantically by action-planning-agent based on user's task description. If user specifies "use Codex/Gemini/Qwen for X", the agent embeds `command` fields in relevant `implementation_approach` steps.
284383
285-
**Input**: `sessionId` from Phase 1
384+
**Input**:
385+
- `sessionId` from Phase 1
386+
- **planning-notes.md**: Consolidated constraints from all phases (Phase 1-3)
387+
- Path: `.workflow/active/[sessionId]/planning-notes.md`
388+
- Contains: User intent, context findings, conflict decisions, consolidated constraints
389+
- **Purpose**: Provides structured, minimal context summary to action-planning-agent
286390
287391
**Validation**:
288392
- `.workflow/active/[sessionId]/IMPL_PLAN.md` exists
@@ -404,26 +508,22 @@ User Input (task description)
404508
405509
Phase 1: session:start --auto "structured-description"
406510
↓ Output: sessionId
407-
Session Memory: Previous tasks, context, artifacts
511+
Write: planning-notes.md (User Intent section)
408512
409513
Phase 2: context-gather --session sessionId "structured-description"
410-
↓ Input: sessionId + session memory + structured description
514+
↓ Input: sessionId + structured description
411515
↓ Output: contextPath (context-package.json) + conflict_risk
516+
↓ Update: planning-notes.md (Context Findings + Consolidated Constraints)
412517
413518
Phase 3: conflict-resolution [AUTO-TRIGGERED if conflict_risk ≥ medium]
414519
↓ Input: sessionId + contextPath + conflict_risk
415-
↓ CLI-powered conflict detection (JSON output)
416-
↓ AskUserQuestion: Present conflicts + resolution strategies
417-
↓ User selects strategies (or skip)
418-
↓ Apply modifications via Edit tool:
419-
↓ - Update guidance-specification.md
420-
↓ - Update role analyses (*.md)
421-
↓ - Mark context-package.json as "resolved"
422-
↓ Output: Modified brainstorm artifacts (NO report file)
520+
↓ Output: Modified brainstorm artifacts
521+
↓ Update: planning-notes.md (Conflict Decisions + Consolidated Constraints)
423522
↓ Skip if conflict_risk is none/low → proceed directly to Phase 4
424523
425524
Phase 4: task-generate-agent --session sessionId
426-
↓ Input: sessionId + resolved brainstorm artifacts + session memory
525+
↓ Input: sessionId + planning-notes.md + context-package.json + brainstorm artifacts
526+
↓ planning-notes.md provides: User Intent, Context Findings, Constraints
427527
↓ Output: IMPL_PLAN.md, task JSONs, TODO_LIST.md
428528
429529
Return summary to user

.claude/commands/workflow/tools/task-generate-agent.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,13 @@ const userConfig = {
161161

162162
### Phase 1: Context Preparation & Module Detection (Command Responsibility)
163163

164-
**Command prepares session paths, metadata, and detects module structure.**
164+
**Command prepares session paths, metadata, detects module structure, and loads planning-notes.md.**
165165

166166
**Session Path Structure**:
167167
```
168168
.workflow/active/WFS-{session-id}/
169169
├── workflow-session.json # Session metadata
170+
├── planning-notes.md # Consolidated planning notes (NEW)
170171
├── .process/
171172
│ └── context-package.json # Context package with artifact catalog
172173
├── .task/ # Output: Task JSON files
@@ -248,9 +249,21 @@ IMPORTANT: This is PLANNING ONLY - you are generating planning documents, NOT im
248249
249250
CRITICAL: Follow the progressive loading strategy defined in agent specification (load analysis.md files incrementally due to file size)
250251
252+
## PLANNING NOTES (PHASE 1-3 CONTEXT)
253+
Load: .workflow/active/{session-id}/planning-notes.md
254+
255+
This document contains:
256+
- User Intent: Original GOAL and KEY_CONSTRAINTS from Phase 1
257+
- Context Findings: Critical files, architecture, and constraints from Phase 2
258+
- Conflict Decisions: Resolved conflicts and planning constraints from Phase 3
259+
- Consolidated Constraints: All constraints from all phases
260+
261+
**USAGE**: Read planning-notes.md FIRST. Use Consolidated Constraints list to guide task sequencing and dependencies.
262+
251263
## SESSION PATHS
252264
Input:
253265
- Session Metadata: .workflow/active/{session-id}/workflow-session.json
266+
- Planning Notes: .workflow/active/{session-id}/planning-notes.md (NEW)
254267
- Context Package: .workflow/active/{session-id}/.process/context-package.json
255268
256269
Output:
@@ -376,6 +389,11 @@ IMPORTANT: Generate Task JSONs ONLY. IMPL_PLAN.md and TODO_LIST.md by Phase 3 Co
376389
377390
CRITICAL: Follow the progressive loading strategy defined in agent specification (load analysis.md files incrementally due to file size)
378391
392+
## PLANNING NOTES (PHASE 1-3 CONTEXT)
393+
Load: .workflow/active/{session-id}/planning-notes.md
394+
395+
This document contains consolidated constraints and user intent to guide module-scoped task generation.
396+
379397
## MODULE SCOPE
380398
- Module: ${module.name} (${module.type})
381399
- Focus Paths: ${module.paths.join(', ')}
@@ -386,6 +404,7 @@ CRITICAL: Follow the progressive loading strategy defined in agent specification
386404
## SESSION PATHS
387405
Input:
388406
- Session Metadata: .workflow/active/{session-id}/workflow-session.json
407+
- Planning Notes: .workflow/active/{session-id}/planning-notes.md (NEW)
389408
- Context Package: .workflow/active/{session-id}/.process/context-package.json
390409
391410
Output:

ccw/src/core/routes/cli-routes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ export async function handleCliRoutes(ctx: RouteContext): Promise<boolean> {
302302
if (req.method === 'PUT') {
303303
handlePostRequest(req, res, async (body: unknown) => {
304304
try {
305-
const updates = body as { enabled?: boolean; primaryModel?: string; secondaryModel?: string; tags?: string[]; envFile?: string | null };
305+
const updates = body as { enabled?: boolean; primaryModel?: string; secondaryModel?: string; availableModels?: string[]; tags?: string[]; envFile?: string | null };
306306
const updated = updateToolConfig(initialPath, tool, updates);
307307

308308
// Broadcast config updated event

0 commit comments

Comments
 (0)