claude-code-workflow 7.2.29 → 7.2.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/.ccw/workflows/cli-templates/schemas/plan-overview-base-schema.json +2 -2
  2. package/.ccw/workflows/cli-templates/schemas/task-schema.json +14 -7
  3. package/.claude/agents/action-planning-agent.md +7 -4
  4. package/.claude/agents/cli-explore-agent.md +77 -63
  5. package/.claude/agents/cli-lite-planning-agent.md +11 -10
  6. package/.claude/agents/issue-plan-agent.md +421 -426
  7. package/.claude/commands/workflow/spec/setup.md +1 -1
  8. package/.claude/skills/ccw-chain/SKILL.md +119 -0
  9. package/.claude/skills/ccw-chain/chains/ccw-cycle.json +21 -0
  10. package/.claude/skills/ccw-chain/chains/ccw-exploration.json +47 -0
  11. package/.claude/skills/ccw-chain/chains/ccw-issue.json +33 -0
  12. package/.claude/skills/ccw-chain/chains/ccw-lightweight.json +57 -0
  13. package/.claude/skills/ccw-chain/chains/ccw-main.json +52 -0
  14. package/.claude/skills/ccw-chain/chains/ccw-standard.json +39 -0
  15. package/.claude/skills/ccw-chain/chains/ccw-team.json +10 -0
  16. package/.claude/skills/ccw-chain/chains/ccw-with-file.json +31 -0
  17. package/.claude/skills/ccw-chain/phases/analyze-with-file.md +788 -0
  18. package/.claude/skills/ccw-chain/phases/brainstorm/SKILL.md +408 -0
  19. package/.claude/skills/ccw-chain/phases/brainstorm/phases/01-mode-routing.md +207 -0
  20. package/.claude/skills/ccw-chain/phases/brainstorm/phases/02-artifacts.md +567 -0
  21. package/.claude/skills/ccw-chain/phases/brainstorm/phases/03-role-analysis.md +748 -0
  22. package/.claude/skills/ccw-chain/phases/brainstorm/phases/04-synthesis.md +827 -0
  23. package/.claude/skills/ccw-chain/phases/brainstorm-with-file.md +482 -0
  24. package/.claude/skills/ccw-chain/phases/collaborative-plan-with-file.md +639 -0
  25. package/.claude/skills/ccw-chain/phases/debug-with-file.md +656 -0
  26. package/.claude/skills/ccw-chain/phases/integration-test-cycle.md +936 -0
  27. package/.claude/skills/ccw-chain/phases/issue-convert-to-plan.md +720 -0
  28. package/.claude/skills/ccw-chain/phases/issue-discover.md +483 -0
  29. package/.claude/skills/ccw-chain/phases/issue-execute.md +629 -0
  30. package/.claude/skills/ccw-chain/phases/issue-from-brainstorm.md +382 -0
  31. package/.claude/skills/ccw-chain/phases/issue-plan.md +343 -0
  32. package/.claude/skills/ccw-chain/phases/issue-queue.md +464 -0
  33. package/.claude/skills/ccw-chain/phases/refactor-cycle.md +852 -0
  34. package/.claude/skills/ccw-chain/phases/review-cycle/SKILL.md +132 -0
  35. package/.claude/skills/ccw-chain/phases/review-cycle/phases/review-fix.md +760 -0
  36. package/.claude/skills/ccw-chain/phases/review-cycle/phases/review-module.md +764 -0
  37. package/.claude/skills/ccw-chain/phases/review-cycle/phases/review-session.md +775 -0
  38. package/.claude/skills/ccw-chain/phases/roadmap-with-file.md +544 -0
  39. package/.claude/skills/ccw-chain/phases/spec-generator/SKILL.md +338 -0
  40. package/.claude/skills/ccw-chain/phases/spec-generator/phases/01-5-requirement-clarification.md +404 -0
  41. package/.claude/skills/ccw-chain/phases/spec-generator/phases/01-discovery.md +257 -0
  42. package/.claude/skills/ccw-chain/phases/spec-generator/phases/02-product-brief.md +274 -0
  43. package/.claude/skills/ccw-chain/phases/spec-generator/phases/03-requirements.md +184 -0
  44. package/.claude/skills/ccw-chain/phases/spec-generator/phases/04-architecture.md +248 -0
  45. package/.claude/skills/ccw-chain/phases/spec-generator/phases/05-epics-stories.md +178 -0
  46. package/.claude/skills/ccw-chain/phases/spec-generator/phases/06-5-auto-fix.md +144 -0
  47. package/.claude/skills/ccw-chain/phases/spec-generator/phases/06-readiness-check.md +480 -0
  48. package/.claude/skills/ccw-chain/phases/team-planex.md +123 -0
  49. package/.claude/skills/ccw-chain/phases/ui-design-explore-auto.md +678 -0
  50. package/.claude/skills/ccw-chain/phases/unified-execute-with-file.md +870 -0
  51. package/.claude/skills/ccw-chain/phases/workflow-execute/SKILL.md +625 -0
  52. package/.claude/skills/ccw-chain/phases/workflow-execute/phases/06-review.md +215 -0
  53. package/.claude/skills/ccw-chain/phases/workflow-lite-plan.md +616 -0
  54. package/.claude/skills/ccw-chain/phases/workflow-multi-cli-plan.md +424 -0
  55. package/.claude/skills/ccw-chain/phases/workflow-plan/SKILL.md +466 -0
  56. package/.claude/skills/ccw-chain/phases/workflow-plan/phases/01-session-discovery.md +99 -0
  57. package/.claude/skills/ccw-chain/phases/workflow-plan/phases/02-context-gathering.md +338 -0
  58. package/.claude/skills/ccw-chain/phases/workflow-plan/phases/03-conflict-resolution.md +422 -0
  59. package/.claude/skills/ccw-chain/phases/workflow-plan/phases/04-task-generation.md +440 -0
  60. package/.claude/skills/ccw-chain/phases/workflow-plan/phases/05-plan-verify.md +395 -0
  61. package/.claude/skills/ccw-chain/phases/workflow-plan/phases/06-replan.md +594 -0
  62. package/.claude/skills/ccw-chain/phases/workflow-tdd-plan/SKILL.md +527 -0
  63. package/.claude/skills/ccw-chain/phases/workflow-tdd-plan/phases/01-session-discovery.md +57 -0
  64. package/.claude/skills/ccw-chain/phases/workflow-tdd-plan/phases/02-context-gathering.md +407 -0
  65. package/.claude/skills/ccw-chain/phases/workflow-tdd-plan/phases/03-test-coverage-analysis.md +172 -0
  66. package/.claude/skills/ccw-chain/phases/workflow-tdd-plan/phases/04-conflict-resolution.md +426 -0
  67. package/.claude/skills/ccw-chain/phases/workflow-tdd-plan/phases/05-tdd-task-generation.md +473 -0
  68. package/.claude/skills/ccw-chain/phases/workflow-tdd-plan/phases/06-tdd-structure-validation.md +189 -0
  69. package/.claude/skills/ccw-chain/phases/workflow-tdd-plan/phases/07-tdd-verify.md +635 -0
  70. package/.claude/skills/ccw-chain/phases/workflow-test-fix/SKILL.md +482 -0
  71. package/.claude/skills/ccw-chain/phases/workflow-test-fix/phases/01-session-start.md +60 -0
  72. package/.claude/skills/ccw-chain/phases/workflow-test-fix/phases/02-test-context-gather.md +493 -0
  73. package/.claude/skills/ccw-chain/phases/workflow-test-fix/phases/03-test-concept-enhanced.md +150 -0
  74. package/.claude/skills/ccw-chain/phases/workflow-test-fix/phases/04-test-task-generate.md +346 -0
  75. package/.claude/skills/ccw-chain/phases/workflow-test-fix/phases/05-test-cycle-execute.md +538 -0
  76. package/.claude/skills/ccw-chain/specs/auto-mode.md +47 -0
  77. package/.claude/skills/ccw-chain/specs/intent-patterns.md +60 -0
  78. package/.claude/skills/chain-loader/SKILL.md +78 -0
  79. package/.claude/skills/chain-loader/phases/01-analyze-skill.md +53 -0
  80. package/.claude/skills/chain-loader/phases/02-design-graph.md +73 -0
  81. package/.claude/skills/chain-loader/phases/03-generate-validate.md +75 -0
  82. package/.claude/skills/chain-loader/specs/chain-schema.md +99 -0
  83. package/.claude/skills/chain-loader/specs/design-patterns.md +99 -0
  84. package/.claude/skills/chain-loader/templates/chain-json.md +63 -0
  85. package/.claude/skills/review-cycle/phases/review-module.md +764 -764
  86. package/.claude/skills/review-cycle/phases/review-session.md +775 -775
  87. package/.claude/skills/workflow-multi-cli-plan/SKILL.md +2 -2
  88. package/.claude/skills/workflow-plan/phases/03-conflict-resolution.md +422 -422
  89. package/.claude/skills/workflow-plan/phases/05-plan-verify.md +395 -395
  90. package/.claude/skills/workflow-tdd-plan/phases/02-context-gathering.md +407 -407
  91. package/.claude/skills/workflow-tdd-plan/phases/04-conflict-resolution.md +426 -426
  92. package/.claude/skills/workflow-test-fix/phases/02-test-context-gather.md +493 -493
  93. package/README.md +14 -0
  94. package/ccw/dist/core/routes/litellm-api-routes.d.ts.map +1 -1
  95. package/ccw/dist/core/routes/litellm-api-routes.js +0 -23
  96. package/ccw/dist/core/routes/litellm-api-routes.js.map +1 -1
  97. package/ccw/dist/tools/chain-loader.d.ts +10 -0
  98. package/ccw/dist/tools/chain-loader.d.ts.map +1 -0
  99. package/ccw/dist/tools/chain-loader.js +642 -0
  100. package/ccw/dist/tools/chain-loader.js.map +1 -0
  101. package/ccw/dist/tools/index.d.ts.map +1 -1
  102. package/ccw/dist/tools/index.js +2 -0
  103. package/ccw/dist/tools/index.js.map +1 -1
  104. package/ccw/dist/tools/json-builder.js +20 -0
  105. package/ccw/dist/tools/json-builder.js.map +1 -1
  106. package/ccw/dist/types/chain-types.d.ts +72 -0
  107. package/ccw/dist/types/chain-types.d.ts.map +1 -0
  108. package/ccw/dist/types/chain-types.js +5 -0
  109. package/ccw/dist/types/chain-types.js.map +1 -0
  110. package/ccw/scripts/prepublish-clean.mjs +0 -1
  111. package/package.json +1 -3
  112. package/ccw-litellm/README.md +0 -180
  113. package/ccw-litellm/pyproject.toml +0 -35
  114. package/ccw-litellm/src/ccw_litellm/__init__.py +0 -47
  115. package/ccw-litellm/src/ccw_litellm/cli.py +0 -108
  116. package/ccw-litellm/src/ccw_litellm/clients/__init__.py +0 -12
  117. package/ccw-litellm/src/ccw_litellm/clients/litellm_embedder.py +0 -270
  118. package/ccw-litellm/src/ccw_litellm/clients/litellm_llm.py +0 -198
  119. package/ccw-litellm/src/ccw_litellm/config/__init__.py +0 -22
  120. package/ccw-litellm/src/ccw_litellm/config/loader.py +0 -343
  121. package/ccw-litellm/src/ccw_litellm/config/models.py +0 -162
  122. package/ccw-litellm/src/ccw_litellm/interfaces/__init__.py +0 -14
  123. package/ccw-litellm/src/ccw_litellm/interfaces/embedder.py +0 -52
  124. package/ccw-litellm/src/ccw_litellm/interfaces/llm.py +0 -45
@@ -0,0 +1,407 @@
1
+ # Phase 2: Context Gathering
2
+
3
+ Gather project context and analyze codebase via context-search-agent with parallel exploration for TDD planning.
4
+
5
+ ## Objective
6
+
7
+ - Gather project context using context-search-agent
8
+ - Identify critical files, architecture patterns, and constraints
9
+ - Detect conflict risk level for Phase 4 decision
10
+ - Update planning-notes.md with findings
11
+
12
+ ## Core Philosophy
13
+
14
+ - **Agent Delegation**: Delegate all discovery to `context-search-agent` for autonomous execution
15
+ - **Detection-First**: Check for existing context-package before executing
16
+ - **Plan Mode**: Full comprehensive analysis (vs lightweight brainstorm mode)
17
+ - **Standardized Output**: Generate `.workflow/active/{session}/.process/context-package.json`
18
+
19
+ ## Execution
20
+
21
+ ### Step 2.1: Context-Package Detection
22
+
23
+ **Execute First** - Check if valid package already exists:
24
+
25
+ ```javascript
26
+ const contextPackagePath = `.workflow/active/${sessionId}/.process/context-package.json`;
27
+
28
+ if (file_exists(contextPackagePath)) {
29
+ const existing = Read(contextPackagePath);
30
+
31
+ // Validate package belongs to current session
32
+ if (existing?.metadata?.session_id === sessionId) {
33
+ console.log("Valid context-package found for session:", sessionId);
34
+ console.log("Stats:", existing.statistics);
35
+ console.log("Conflict Risk:", existing.conflict_detection.risk_level);
36
+ // Skip execution, store variables and proceed to Step 2.5
37
+ contextPath = contextPackagePath;
38
+ conflictRisk = existing.conflict_detection.risk_level;
39
+ return; // Early exit - skip Steps 2.2-2.4
40
+ }
41
+ }
42
+ ```
43
+
44
+ ### Step 2.2: Complexity Assessment & Parallel Explore
45
+
46
+ **Only execute if Step 2.1 finds no valid package**
47
+
48
+ ```javascript
49
+ // 2.2.1 Complexity Assessment
50
+ function analyzeTaskComplexity(taskDescription) {
51
+ const text = taskDescription.toLowerCase();
52
+ if (/architect|refactor|restructure|modular|cross-module/.test(text)) return 'High';
53
+ if (/multiple|several|integrate|migrate|extend/.test(text)) return 'Medium';
54
+ return 'Low';
55
+ }
56
+
57
+ const ANGLE_PRESETS = {
58
+ architecture: ['architecture', 'dependencies', 'modularity', 'integration-points'],
59
+ security: ['security', 'auth-patterns', 'dataflow', 'validation'],
60
+ performance: ['performance', 'bottlenecks', 'caching', 'data-access'],
61
+ bugfix: ['error-handling', 'dataflow', 'state-management', 'edge-cases'],
62
+ feature: ['patterns', 'integration-points', 'testing', 'dependencies'],
63
+ refactor: ['architecture', 'patterns', 'dependencies', 'testing']
64
+ };
65
+
66
+ function selectAngles(taskDescription, complexity) {
67
+ const text = taskDescription.toLowerCase();
68
+ let preset = 'feature';
69
+ if (/refactor|architect|restructure/.test(text)) preset = 'architecture';
70
+ else if (/security|auth|permission/.test(text)) preset = 'security';
71
+ else if (/performance|slow|optimi/.test(text)) preset = 'performance';
72
+ else if (/fix|bug|error|issue/.test(text)) preset = 'bugfix';
73
+
74
+ const count = complexity === 'High' ? 4 : (complexity === 'Medium' ? 3 : 1);
75
+ return ANGLE_PRESETS[preset].slice(0, count);
76
+ }
77
+
78
+ const complexity = analyzeTaskComplexity(task_description);
79
+ const selectedAngles = selectAngles(task_description, complexity);
80
+ const sessionFolder = `.workflow/active/${sessionId}/.process`;
81
+
82
+ // 2.2.2 Launch Parallel Explore Agents
83
+ const explorationTasks = selectedAngles.map((angle, index) =>
84
+ Task(
85
+ subagent_type="cli-explore-agent",
86
+ run_in_background=false,
87
+ description=`Explore: ${angle}`,
88
+ prompt=`
89
+ ## Task Objective
90
+ Execute **${angle}** exploration for TDD task planning context. Analyze codebase from this specific angle to discover relevant structure, patterns, and constraints.
91
+
92
+ ## Assigned Context
93
+ - **Exploration Angle**: ${angle}
94
+ - **Task Description**: ${task_description}
95
+ - **Session ID**: ${sessionId}
96
+ - **Exploration Index**: ${index + 1} of ${selectedAngles.length}
97
+ - **Output File**: ${sessionFolder}/exploration-${angle}.json
98
+
99
+ ## MANDATORY FIRST STEPS (Execute by Agent)
100
+ 1. Run: ccw tool exec get_modules_by_depth '{}' (project structure)
101
+ 2. Run: rg -l "{keyword_from_task}" --type ts (locate relevant files)
102
+ 3. Execute: ccw tool exec json_builder '{"cmd":"init","schema":"explore","output":"${sessionFolder}/exploration-${angle}.json"}' (init output + get schema info)
103
+
104
+ ## Exploration Strategy (${angle} focus)
105
+
106
+ **Step 1: Structural Scan** (Bash)
107
+ - get_modules_by_depth.sh -> identify modules related to ${angle}
108
+ - find/rg -> locate files relevant to ${angle} aspect
109
+ - Analyze imports/dependencies from ${angle} perspective
110
+
111
+ **Step 2: Semantic Analysis** (Gemini CLI)
112
+ - How does existing code handle ${angle} concerns?
113
+ - What patterns are used for ${angle}?
114
+ - Where would new code integrate from ${angle} viewpoint?
115
+
116
+ **Step 3: Write Output**
117
+ - Consolidate ${angle} findings into JSON
118
+ - Identify ${angle}-specific clarification needs
119
+
120
+ ## Expected Output
121
+
122
+ **File**: ${sessionFolder}/exploration-${angle}.json
123
+
124
+ **Schema Reference**: Skeleton initialized via json_builder in step 3. Use `set` to populate fields, `validate` before returning.
125
+
126
+ **Required Fields** (all ${angle} focused):
127
+ - project_structure: Modules/architecture relevant to ${angle}
128
+ - relevant_files: Files affected from ${angle} perspective
129
+ **MANDATORY**: Every file MUST use structured object format with ALL required fields:
130
+ [{path: "src/file.ts", relevance: 0.85, rationale: "Contains AuthService.login()", role: "modify_target", discovery_source: "bash-scan", key_symbols: ["AuthService", "login"]}]
131
+ - **rationale** (required): Specific selection basis tied to ${angle} topic (>10 chars, not generic)
132
+ - **role** (required): modify_target|dependency|pattern_reference|test_target|type_definition|integration_point|config|context_only
133
+ - **discovery_source** (recommended): bash-scan|cli-analysis|ace-search|dependency-trace|manual
134
+ - **key_symbols** (recommended): Key functions/classes/types in the file relevant to the task
135
+ - Scores: 0.7+ high priority, 0.5-0.7 medium, <0.5 low
136
+ - patterns: ${angle}-related patterns to follow
137
+ - dependencies: Dependencies relevant to ${angle}
138
+ - integration_points: Where to integrate from ${angle} viewpoint (include file:line locations)
139
+ - constraints: ${angle}-specific limitations/conventions
140
+ - clarification_needs: ${angle}-related ambiguities (options array + recommended index)
141
+ - _metadata.exploration_angle: "${angle}"
142
+
143
+ ## Success Criteria
144
+ - [ ] Schema initialized via json_builder init
145
+ - [ ] get_modules_by_depth.sh executed
146
+ - [ ] At least 3 relevant files identified with ${angle} rationale
147
+ - [ ] Patterns are actionable (code examples, not generic advice)
148
+ - [ ] Integration points include file:line locations
149
+ - [ ] Constraints are project-specific to ${angle}
150
+ - [ ] JSON output follows schema exactly
151
+ - [ ] clarification_needs includes options + recommended
152
+
153
+ ## Output
154
+ Write: ${sessionFolder}/exploration-${angle}.json
155
+ Return: 2-3 sentence summary of ${angle} findings
156
+ `
157
+ )
158
+ );
159
+
160
+ // 2.2.3 Generate Manifest after all complete
161
+ const explorationFiles = bash(`find ${sessionFolder} -name "exploration-*.json" -type f`).split('\n').filter(f => f.trim());
162
+ const explorationManifest = {
163
+ session_id: sessionId,
164
+ task_description,
165
+ timestamp: new Date().toISOString(),
166
+ complexity,
167
+ exploration_count: selectedAngles.length,
168
+ angles_explored: selectedAngles,
169
+ explorations: explorationFiles.map(file => {
170
+ const data = JSON.parse(Read(file));
171
+ return { angle: data._metadata.exploration_angle, file: file.split('/').pop(), path: file, index: data._metadata.exploration_index };
172
+ })
173
+ };
174
+ Write(`${sessionFolder}/explorations-manifest.json`, JSON.stringify(explorationManifest, null, 2));
175
+ ```
176
+
177
+ ### Step 2.3: Invoke Context-Search Agent
178
+
179
+ **Only execute after Step 2.2 completes**
180
+
181
+ ```javascript
182
+ // Load user intent from planning-notes.md (from Phase 1)
183
+ const planningNotesPath = `.workflow/active/${sessionId}/planning-notes.md`;
184
+ let userIntent = { goal: task_description, key_constraints: "None specified" };
185
+
186
+ if (file_exists(planningNotesPath)) {
187
+ const notesContent = Read(planningNotesPath);
188
+ const goalMatch = notesContent.match(/\*\*GOAL\*\*:\s*(.+)/);
189
+ const constraintsMatch = notesContent.match(/\*\*KEY_CONSTRAINTS\*\*:\s*(.+)/);
190
+ if (goalMatch) userIntent.goal = goalMatch[1].trim();
191
+ if (constraintsMatch) userIntent.key_constraints = constraintsMatch[1].trim();
192
+ }
193
+
194
+ Task(
195
+ subagent_type="context-search-agent",
196
+ run_in_background=false,
197
+ description="Gather comprehensive context for TDD plan",
198
+ prompt=`
199
+ ## Execution Mode
200
+ **PLAN MODE** (Comprehensive) - Full Phase 1-3 execution with priority sorting
201
+
202
+ ## Session Information
203
+ - **Session ID**: ${sessionId}
204
+ - **Task Description**: ${task_description}
205
+ - **Output Path**: .workflow/${sessionId}/.process/context-package.json
206
+
207
+ ## User Intent (from Phase 1 - Planning Notes)
208
+ **GOAL**: ${userIntent.goal}
209
+ **KEY_CONSTRAINTS**: ${userIntent.key_constraints}
210
+
211
+ This is the PRIMARY context source - all subsequent analysis must align with user intent.
212
+
213
+ ## Exploration Input (from Step 2.2)
214
+ - **Manifest**: ${sessionFolder}/explorations-manifest.json
215
+ - **Exploration Count**: ${explorationManifest.exploration_count}
216
+ - **Angles**: ${explorationManifest.angles_explored.join(', ')}
217
+ - **Complexity**: ${complexity}
218
+
219
+ ## Mission
220
+ Execute complete context-search-agent workflow for TDD implementation planning:
221
+
222
+ ### Phase 1: Initialization & Pre-Analysis
223
+ 1. **Project State Loading**:
224
+ - Run: \`ccw spec load --category execution\` to load project context, tech stack, and guidelines.
225
+ - Run: \`ccw spec load --category test\` to load test framework conventions, coverage targets, and fixtures.
226
+ - If files don't exist, proceed with fresh analysis.
227
+ 2. **Detection**: Check for existing context-package (early exit if valid)
228
+ 3. **Foundation**: Initialize CodexLens, get project structure, load docs
229
+ 4. **Analysis**: Extract keywords, determine scope, classify complexity
230
+
231
+ ### Phase 2: Multi-Source Context Discovery
232
+ Execute all discovery tracks (WITH USER INTENT INTEGRATION):
233
+ - **Track -1**: User Intent & Priority Foundation (EXECUTE FIRST)
234
+ - Load user intent (GOAL, KEY_CONSTRAINTS) from session input
235
+ - Map user requirements to codebase entities (files, modules, patterns)
236
+ - Establish baseline priority scores based on user goal alignment
237
+ - Output: user_intent_mapping.json with preliminary priority scores
238
+
239
+ - **Track 0**: Exploration Synthesis (load explorations-manifest.json, prioritize critical_files, deduplicate patterns/integration_points)
240
+ - **Track 1**: Historical archive analysis (query manifest.json for lessons learned)
241
+ - **Track 2**: Reference documentation (CLAUDE.md, architecture docs)
242
+ - **Track 3**: Web examples (use Exa MCP for unfamiliar tech/APIs)
243
+ - **Track 4**: Codebase analysis (5-layer discovery: files, content, patterns, deps, config/tests)
244
+
245
+ ### Phase 3: Synthesis, Assessment & Packaging
246
+ 1. Apply relevance scoring and build dependency graph
247
+ 2. **Synthesize 5-source data**: Merge findings from all sources
248
+ - Priority order: User Intent > Archive > Docs > Exploration > Code > Web
249
+ - **Prioritize the context from project-tech.json** for architecture and tech stack
250
+ 3. **Context Priority Sorting**:
251
+ a. Combine scores from Track -1 (user intent alignment) + relevance scores + exploration critical_files
252
+ b. Classify files into priority tiers:
253
+ - **Critical** (score >= 0.85): Directly mentioned in user goal OR exploration critical_files
254
+ - **High** (0.70-0.84): Key dependencies, patterns required for goal
255
+ - **Medium** (0.50-0.69): Supporting files, indirect dependencies
256
+ - **Low** (< 0.50): Contextual awareness only
257
+ c. Generate dependency_order: Based on dependency graph + user goal sequence
258
+ d. Document sorting_rationale: Explain prioritization logic
259
+ 4. **Populate project_context**: Directly use the overview from project-tech.json
260
+ 5. **Populate project_guidelines**: Load from specs/*.md
261
+ 6. Integrate brainstorm artifacts (if .brainstorming/ exists, read content)
262
+ 7. Perform conflict detection with risk assessment
263
+ 8. **Inject historical conflicts** from archive analysis into conflict_detection
264
+ 9. **Generate prioritized_context section**:
265
+ {
266
+ "prioritized_context": {
267
+ "user_intent": { "goal": "...", "scope": "...", "key_constraints": ["..."] },
268
+ "priority_tiers": {
269
+ "critical": [{ "path": "...", "relevance": 0.95, "rationale": "..." }],
270
+ "high": [...], "medium": [...], "low": [...]
271
+ },
272
+ "dependency_order": ["module1", "module2", "module3"],
273
+ "sorting_rationale": "Based on user goal alignment, exploration critical files, and dependency graph"
274
+ }
275
+ }
276
+ 10. Generate and validate context-package.json with prioritized_context field
277
+
278
+ ## Output Requirements
279
+ Complete context-package.json with:
280
+ - **metadata**: task_description, keywords, complexity, tech_stack, session_id
281
+ - **project_context**: description, technology_stack, architecture, key_components (from project-tech.json)
282
+ - **project_guidelines**: {conventions, constraints, quality_rules, learnings} (from specs/*.md)
283
+ - **assets**: {documentation[], source_code[], config[], tests[]} with relevance scores
284
+ - **dependencies**: {internal[], external[]} with dependency graph
285
+ - **brainstorm_artifacts**: {guidance_specification, role_analyses[], synthesis_output} with content
286
+ - **conflict_detection**: {risk_level, risk_factors, affected_modules[], mitigation_strategy, historical_conflicts[]}
287
+ - **exploration_results**: {manifest_path, exploration_count, angles, explorations[], aggregated_insights}
288
+ - **prioritized_context**: {user_intent, priority_tiers{critical, high, medium, low}, dependency_order[], sorting_rationale}
289
+
290
+ ## Quality Validation
291
+ Before completion verify:
292
+ - [ ] Valid JSON format with all required fields
293
+ - [ ] File relevance accuracy >80%
294
+ - [ ] Dependency graph complete (max 2 transitive levels)
295
+ - [ ] Conflict risk level calculated correctly
296
+ - [ ] No sensitive data exposed
297
+ - [ ] Total files <= 50 (prioritize high-relevance)
298
+
299
+ ## Planning Notes Record (REQUIRED)
300
+ After completing context-package.json, append to planning-notes.md:
301
+
302
+ **File**: .workflow/active/${sessionId}/planning-notes.md
303
+ **Location**: Under "## Context Findings (Phase 2)" section
304
+ **Format**:
305
+ ### [Context-Search Agent] YYYY-MM-DD
306
+ - **Note**: [Brief summary of key findings]
307
+
308
+ Execute autonomously following agent documentation.
309
+ Report completion with statistics.
310
+ `
311
+ )
312
+ ```
313
+
314
+ ### Step 2.4: Output Verification
315
+
316
+ After agent completes, verify output:
317
+
318
+ ```javascript
319
+ // Verify file was created
320
+ const outputPath = `.workflow/active/${sessionId}/.process/context-package.json`;
321
+ if (!file_exists(outputPath)) {
322
+ throw new Error("Agent failed to generate context-package.json");
323
+ }
324
+
325
+ // Store variables for subsequent phases
326
+ contextPath = outputPath;
327
+
328
+ // Verify exploration_results included
329
+ const pkg = JSON.parse(Read(outputPath));
330
+ if (pkg.exploration_results?.exploration_count > 0) {
331
+ console.log(`Exploration results aggregated: ${pkg.exploration_results.exploration_count} angles`);
332
+ }
333
+
334
+ conflictRisk = pkg.conflict_detection?.risk_level || 'low';
335
+ ```
336
+
337
+ ### TodoWrite Update (Phase 2 in progress - tasks attached)
338
+
339
+ ```json
340
+ [
341
+ {"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
342
+ {"content": "Phase 2: Context Gathering", "status": "in_progress", "activeForm": "Executing context gathering"},
343
+ {"content": " -> Analyze codebase structure", "status": "in_progress", "activeForm": "Analyzing codebase structure"},
344
+ {"content": " -> Identify integration points", "status": "pending", "activeForm": "Identifying integration points"},
345
+ {"content": " -> Generate context package", "status": "pending", "activeForm": "Generating context package"},
346
+ {"content": "Phase 3: Test Coverage Analysis", "status": "pending", "activeForm": "Executing test coverage analysis"},
347
+ {"content": "Phase 5: TDD Task Generation", "status": "pending", "activeForm": "Executing TDD task generation"},
348
+ {"content": "Phase 6: TDD Structure Validation", "status": "pending", "activeForm": "Validating TDD structure"}
349
+ ]
350
+ ```
351
+
352
+ ### TodoWrite Update (Phase 2 completed - tasks collapsed)
353
+
354
+ ```json
355
+ [
356
+ {"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
357
+ {"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
358
+ {"content": "Phase 3: Test Coverage Analysis", "status": "pending", "activeForm": "Executing test coverage analysis"},
359
+ {"content": "Phase 5: TDD Task Generation", "status": "pending", "activeForm": "Executing TDD task generation"},
360
+ {"content": "Phase 6: TDD Structure Validation", "status": "pending", "activeForm": "Validating TDD structure"}
361
+ ]
362
+ ```
363
+
364
+ ### Step 2.5: Update Planning Notes
365
+
366
+ After context gathering completes, update planning-notes.md with findings:
367
+
368
+ ```javascript
369
+ // Read context-package to extract key findings
370
+ const contextPackage = JSON.parse(Read(contextPath))
371
+ const conflictRisk = contextPackage.conflict_detection?.risk_level || 'low'
372
+ const criticalFiles = (contextPackage.exploration_results?.aggregated_insights?.critical_files || [])
373
+ .slice(0, 5).map(f => f.path)
374
+ const archPatterns = contextPackage.project_context?.architecture_patterns || []
375
+ const constraints = contextPackage.exploration_results?.aggregated_insights?.constraints || []
376
+
377
+ // Append Phase 2 findings to planning-notes.md
378
+ Edit(planningNotesPath, {
379
+ old: '## Context Findings (Phase 2)\n(To be filled by context-gather)',
380
+ new: `## Context Findings (Phase 2)
381
+
382
+ - **CRITICAL_FILES**: ${criticalFiles.join(', ') || 'None identified'}
383
+ - **ARCHITECTURE**: ${archPatterns.join(', ') || 'Not detected'}
384
+ - **CONFLICT_RISK**: ${conflictRisk}
385
+ - **CONSTRAINTS**: ${constraints.length > 0 ? constraints.join('; ') : 'None'}`
386
+ })
387
+
388
+ // Append Phase 2 constraints to consolidated list
389
+ Edit(planningNotesPath, {
390
+ old: '## Consolidated Constraints (Phase 4 Input)',
391
+ new: `## Consolidated Constraints (Phase 4 Input)
392
+ ${constraints.map((c, i) => `${i + 2}. [Context] ${c}`).join('\n')}`
393
+ })
394
+ ```
395
+
396
+ **Auto-Continue**: Return to user showing Phase 2 results, then auto-continue to Phase 3.
397
+
398
+ ## Output
399
+
400
+ - **Variable**: `contextPath` (path to context-package.json)
401
+ - **Variable**: `conflictRisk` (none/low/medium/high)
402
+ - **File**: `context-package.json`
403
+ - **TodoWrite**: Mark Phase 2 completed, determine Phase 3 or Phase 4
404
+
405
+ ## Next Phase
406
+
407
+ Return to orchestrator. Orchestrator continues to [Phase 3: Test Coverage Analysis](03-test-coverage-analysis.md).
@@ -0,0 +1,172 @@
1
+ # Phase 3: Test Coverage Analysis
2
+
3
+ Analyze existing test coverage, detect test framework, and identify coverage gaps.
4
+
5
+ ## Objective
6
+
7
+ - Analyze existing codebase for test patterns and conventions
8
+ - Detect current test coverage and framework
9
+ - Identify related components and integration points
10
+ - Generate test-context-package.json
11
+
12
+ ## Core Philosophy
13
+
14
+ - **Agent Delegation**: Delegate all test coverage analysis to `test-context-search-agent` for autonomous execution
15
+ - **Detection-First**: Check for existing test-context-package before executing
16
+ - **Coverage-First**: Analyze existing test coverage before planning new tests
17
+ - **Source Context Loading**: Import implementation summaries from source session
18
+ - **Standardized Output**: Generate `.workflow/active/{session}/.process/test-context-package.json`
19
+
20
+ ## Execution
21
+
22
+ ### Step 3.1: Test-Context-Package Detection
23
+
24
+ **Execute First** - Check if valid package already exists:
25
+
26
+ ```javascript
27
+ const testContextPath = `.workflow/active/${sessionId}/.process/test-context-package.json`;
28
+
29
+ if (file_exists(testContextPath)) {
30
+ const existing = Read(testContextPath);
31
+
32
+ // Validate package belongs to current session
33
+ if (existing?.metadata?.test_session_id === sessionId) {
34
+ console.log("Valid test-context-package found for session:", sessionId);
35
+ console.log("Coverage Stats:", existing.test_coverage.coverage_stats);
36
+ console.log("Framework:", existing.test_framework.framework);
37
+ console.log("Missing Tests:", existing.test_coverage.missing_tests.length);
38
+ // Skip execution, store variable and proceed
39
+ testContextPath_var = testContextPath;
40
+ return; // Early exit - skip Steps 3.2-3.3
41
+ }
42
+ }
43
+ ```
44
+
45
+ ### Step 3.2: Invoke Test-Context-Search Agent
46
+
47
+ **Only execute if Step 3.1 finds no valid package**
48
+
49
+ ```javascript
50
+ Task(
51
+ subagent_type="test-context-search-agent",
52
+ run_in_background=false,
53
+ description="Gather test coverage context",
54
+ prompt=`
55
+
56
+ ## Execution Mode
57
+ **PLAN MODE** (Comprehensive) - Full Phase 1-3 execution
58
+
59
+ ## Session Information
60
+ - **Test Session ID**: ${sessionId}
61
+ - **Output Path**: .workflow/active/${sessionId}/.process/test-context-package.json
62
+
63
+ ## Mission
64
+ Execute complete test-context-search-agent workflow for test generation planning:
65
+
66
+ ### Phase 1: Session Validation & Source Context Loading
67
+ 1. **Detection**: Check for existing test-context-package (early exit if valid)
68
+ 2. **Test Session Validation**: Load test session metadata, extract source_session reference
69
+ 3. **Source Context Loading**: Load source session implementation summaries, changed files, tech stack
70
+
71
+ ### Phase 2: Test Coverage Analysis
72
+ Execute coverage discovery:
73
+ - **Track 1**: Existing test discovery (find *.test.*, *.spec.* files)
74
+ - **Track 2**: Coverage gap analysis (match implementation files to test files)
75
+ - **Track 3**: Coverage statistics (calculate percentages, identify gaps by module)
76
+
77
+ ### Phase 3: Framework Detection & Packaging
78
+ 1. Framework identification from package.json/requirements.txt
79
+ 2. Convention analysis from existing test patterns
80
+ 3. Generate and validate test-context-package.json
81
+
82
+ ## Output Requirements
83
+ Complete test-context-package.json with:
84
+ - **metadata**: test_session_id, source_session_id, task_type, complexity
85
+ - **source_context**: implementation_summaries, tech_stack, project_patterns
86
+ - **test_coverage**: existing_tests[], missing_tests[], coverage_stats
87
+ - **test_framework**: framework, version, test_pattern, conventions
88
+ - **assets**: implementation_summary[], existing_test[], source_code[] with priorities
89
+ - **focus_areas**: Test generation guidance based on coverage gaps
90
+
91
+ ## Quality Validation
92
+ Before completion verify:
93
+ - [ ] Valid JSON format with all required fields
94
+ - [ ] Source session context loaded successfully
95
+ - [ ] Test coverage gaps identified
96
+ - [ ] Test framework detected (or marked as 'unknown')
97
+ - [ ] Coverage percentage calculated correctly
98
+ - [ ] Missing tests catalogued with priority
99
+ - [ ] Execution time < 30 seconds (< 60s for large codebases)
100
+
101
+ Execute autonomously following agent documentation.
102
+ Report completion with coverage statistics.
103
+ `
104
+ )
105
+ ```
106
+
107
+ ### Step 3.3: Output Verification
108
+
109
+ After agent completes, verify output:
110
+
111
+ ```javascript
112
+ // Verify file was created
113
+ const outputPath = `.workflow/active/${sessionId}/.process/test-context-package.json`;
114
+ if (!file_exists(outputPath)) {
115
+ throw new Error("Agent failed to generate test-context-package.json");
116
+ }
117
+
118
+ // Load and display summary
119
+ const testContext = JSON.parse(Read(outputPath));
120
+ console.log("Test context package generated successfully");
121
+ console.log("Coverage:", testContext.test_coverage.coverage_stats.coverage_percentage + "%");
122
+ console.log("Tests to generate:", testContext.test_coverage.missing_tests.length);
123
+
124
+ // Store variable for subsequent phases
125
+ testContextPath_var = outputPath;
126
+ ```
127
+
128
+ ### TodoWrite Update (Phase 3 Skill executed - tasks attached)
129
+
130
+ ```json
131
+ [
132
+ {"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
133
+ {"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
134
+ {"content": "Phase 3: Test Coverage Analysis", "status": "in_progress", "activeForm": "Executing test coverage analysis"},
135
+ {"content": " -> Detect test framework and conventions", "status": "in_progress", "activeForm": "Detecting test framework"},
136
+ {"content": " -> Analyze existing test coverage", "status": "pending", "activeForm": "Analyzing test coverage"},
137
+ {"content": " -> Identify coverage gaps", "status": "pending", "activeForm": "Identifying coverage gaps"},
138
+ {"content": "Phase 5: TDD Task Generation", "status": "pending", "activeForm": "Executing TDD task generation"},
139
+ {"content": "Phase 6: TDD Structure Validation", "status": "pending", "activeForm": "Validating TDD structure"}
140
+ ]
141
+ ```
142
+
143
+ **Note**: Agent execution **attaches** test-context-search's 3 tasks. Orchestrator **executes** these tasks.
144
+
145
+ **Next Action**: Tasks attached -> **Execute Phase 3.1-3.3** sequentially
146
+
147
+ ### TodoWrite Update (Phase 3 completed - tasks collapsed)
148
+
149
+ ```json
150
+ [
151
+ {"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
152
+ {"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
153
+ {"content": "Phase 3: Test Coverage Analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
154
+ {"content": "Phase 5: TDD Task Generation", "status": "pending", "activeForm": "Executing TDD task generation"},
155
+ {"content": "Phase 6: TDD Structure Validation", "status": "pending", "activeForm": "Validating TDD structure"}
156
+ ]
157
+ ```
158
+
159
+ **Note**: Phase 3 tasks completed and collapsed to summary.
160
+
161
+ **After Phase 3**: Return to user showing test coverage results, then auto-continue to Phase 4/5 (depending on conflict_risk)
162
+
163
+ ## Output
164
+
165
+ - **Variable**: `testContextPath` (path to test-context-package.json)
166
+ - **TodoWrite**: Mark Phase 3 completed
167
+
168
+ ## Next Phase
169
+
170
+ Based on `conflictRisk` from Phase 2:
171
+ - If conflictRisk >= medium -> [Phase 4: Conflict Resolution](04-conflict-resolution.md)
172
+ - If conflictRisk < medium -> Skip to [Phase 5: TDD Task Generation](05-tdd-task-generation.md)