claude-code-workflow 7.2.29 → 7.3.0

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 (169) 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/commands/workflow-skill.md +130 -0
  9. package/.claude/skills/ccw-chain/SKILL.md +92 -0
  10. package/.claude/skills/ccw-chain/chains/ccw-cycle.json +31 -0
  11. package/.claude/skills/ccw-chain/chains/ccw-exploration.json +58 -0
  12. package/.claude/skills/ccw-chain/chains/ccw-issue.json +44 -0
  13. package/.claude/skills/ccw-chain/chains/ccw-lightweight.json +71 -0
  14. package/.claude/skills/ccw-chain/chains/ccw-main.json +65 -0
  15. package/.claude/skills/ccw-chain/chains/ccw-standard.json +51 -0
  16. package/.claude/skills/ccw-chain/chains/ccw-team.json +15 -0
  17. package/.claude/skills/ccw-chain/chains/ccw-with-file.json +47 -0
  18. package/.claude/skills/ccw-chain/specs/auto-mode.md +47 -0
  19. package/.claude/skills/chain-loader/SKILL.md +78 -0
  20. package/.claude/skills/chain-loader/phases/01-analyze-skill.md +53 -0
  21. package/.claude/skills/chain-loader/phases/02-design-graph.md +73 -0
  22. package/.claude/skills/chain-loader/phases/03-generate-validate.md +75 -0
  23. package/.claude/skills/chain-loader/specs/chain-schema.md +126 -0
  24. package/.claude/skills/chain-loader/specs/design-patterns.md +99 -0
  25. package/.claude/skills/chain-loader/templates/chain-json.md +63 -0
  26. package/.claude/skills/review-cycle/phases/review-module.md +764 -764
  27. package/.claude/skills/review-cycle/phases/review-session.md +775 -775
  28. package/.claude/skills/workflow-multi-cli-plan/SKILL.md +2 -2
  29. package/.claude/skills/workflow-plan/SKILL.md +1 -0
  30. package/.claude/skills/workflow-plan/phases/01-session-discovery.md +19 -2
  31. package/.claude/skills/workflow-plan/phases/02-context-gathering.md +2 -2
  32. package/.claude/skills/workflow-plan/phases/03-conflict-resolution.md +422 -422
  33. package/.claude/skills/workflow-plan/phases/04-task-generation.md +9 -1
  34. package/.claude/skills/workflow-plan/phases/05-plan-verify.md +395 -395
  35. package/.claude/skills/workflow-tdd-plan/phases/02-context-gathering.md +407 -407
  36. package/.claude/skills/workflow-tdd-plan/phases/04-conflict-resolution.md +426 -426
  37. package/.claude/skills/workflow-test-fix/phases/02-test-context-gather.md +493 -493
  38. package/.codex/skills/analyze-with-file/SKILL.md +383 -134
  39. package/.codex/skills/brainstorm/SKILL.md +3 -3
  40. package/.codex/skills/brainstorm-with-file/SKILL.md +208 -88
  41. package/.codex/skills/clean/SKILL.md +1 -1
  42. package/.codex/skills/csv-wave-pipeline/SKILL.md +2 -2
  43. package/.codex/skills/investigate/orchestrator.md +24 -0
  44. package/.codex/skills/issue-discover/SKILL.md +374 -361
  45. package/.codex/skills/issue-discover/phases/01-issue-new.md +1 -1
  46. package/.codex/skills/issue-discover/phases/02-discover.md +2 -2
  47. package/.codex/skills/issue-discover/phases/03-discover-by-prompt.md +1 -1
  48. package/.codex/skills/issue-discover/phases/04-quick-execute.md +2 -2
  49. package/.codex/skills/parallel-dev-cycle/SKILL.md +44 -37
  50. package/.codex/skills/project-documentation-workflow/SKILL.md +1 -1
  51. package/.codex/skills/review-cycle/SKILL.md +31 -12
  52. package/.codex/skills/roadmap-with-file/SKILL.md +141 -133
  53. package/.codex/skills/security-audit/orchestrator.md +29 -0
  54. package/.codex/skills/session-sync/SKILL.md +1 -1
  55. package/.codex/skills/ship/orchestrator.md +24 -0
  56. package/.codex/skills/spec-add/SKILL.md +5 -5
  57. package/.codex/skills/spec-generator/SKILL.md +33 -2
  58. package/.codex/skills/spec-generator/phases/01-5-requirement-clarification.md +3 -3
  59. package/.codex/skills/spec-generator/phases/01-discovery.md +1 -1
  60. package/.codex/skills/spec-generator/phases/02-product-brief.md +1 -1
  61. package/.codex/skills/spec-generator/phases/03-requirements.md +1 -1
  62. package/.codex/skills/spec-generator/phases/04-architecture.md +1 -1
  63. package/.codex/skills/spec-generator/phases/05-epics-stories.md +1 -1
  64. package/.codex/skills/spec-generator/phases/06-readiness-check.md +1 -1
  65. package/.codex/skills/spec-generator/phases/07-issue-export.md +1 -1
  66. package/.codex/skills/spec-setup/SKILL.md +669 -669
  67. package/.codex/skills/team-arch-opt/specs/team-config.json +1 -1
  68. package/.codex/skills/team-brainstorm/SKILL.md +259 -259
  69. package/.codex/skills/team-coordinate/SKILL.md +359 -359
  70. package/.codex/skills/team-coordinate/roles/coordinator/commands/monitor.md +1 -1
  71. package/.codex/skills/team-designer/SKILL.md +27 -1
  72. package/.codex/skills/team-designer/phases/01-requirements-analysis.md +2 -2
  73. package/.codex/skills/team-designer/phases/02-scaffold-generation.md +1 -1
  74. package/.codex/skills/team-designer/phases/04-validation.md +1 -1
  75. package/.codex/skills/team-executor/SKILL.md +218 -218
  76. package/.codex/skills/team-frontend/SKILL.md +227 -227
  77. package/.codex/skills/team-frontend-debug/SKILL.md +278 -278
  78. package/.codex/skills/team-frontend-debug/roles/coordinator/commands/analyze.md +2 -2
  79. package/.codex/skills/team-interactive-craft/SKILL.md +220 -220
  80. package/.codex/skills/team-interactive-craft/roles/coordinator/role.md +209 -209
  81. package/.codex/skills/team-issue/SKILL.md +269 -269
  82. package/.codex/skills/team-issue/roles/coordinator/role.md +1 -1
  83. package/.codex/skills/team-lifecycle-v4/SKILL.md +305 -305
  84. package/.codex/skills/team-motion-design/SKILL.md +222 -222
  85. package/.codex/skills/team-motion-design/roles/coordinator/role.md +210 -210
  86. package/.codex/skills/team-perf-opt/SKILL.md +258 -258
  87. package/.codex/skills/team-perf-opt/specs/team-config.json +1 -1
  88. package/.codex/skills/team-planex/SKILL.md +216 -216
  89. package/.codex/skills/team-quality-assurance/SKILL.md +229 -229
  90. package/.codex/skills/team-review/SKILL.md +227 -227
  91. package/.codex/skills/team-roadmap-dev/SKILL.md +238 -238
  92. package/.codex/skills/team-roadmap-dev/roles/coordinator/commands/roadmap-discuss.md +5 -5
  93. package/.codex/skills/team-tech-debt/SKILL.md +206 -206
  94. package/.codex/skills/team-tech-debt/roles/coordinator/commands/monitor.md +1 -1
  95. package/.codex/skills/team-testing/SKILL.md +237 -237
  96. package/.codex/skills/team-ui-polish/SKILL.md +218 -218
  97. package/.codex/skills/team-ui-polish/roles/coordinator/role.md +213 -213
  98. package/.codex/skills/team-uidesign/SKILL.md +219 -219
  99. package/.codex/skills/team-uidesign/roles/coordinator/role.md +2 -2
  100. package/.codex/skills/team-ultra-analyze/SKILL.md +260 -260
  101. package/.codex/skills/team-ultra-analyze/roles/coordinator/commands/monitor.md +1 -1
  102. package/.codex/skills/team-ultra-analyze/roles/coordinator/role.md +1 -1
  103. package/.codex/skills/team-ux-improve/SKILL.md +227 -227
  104. package/.codex/skills/team-ux-improve/roles/coordinator/role.md +1 -1
  105. package/.codex/skills/team-ux-improve/specs/team-config.json +1 -1
  106. package/.codex/skills/team-visual-a11y/SKILL.md +319 -319
  107. package/.codex/skills/team-visual-a11y/roles/coordinator/role.md +213 -213
  108. package/.codex/skills/workflow-execute/SKILL.md +5 -5
  109. package/.codex/skills/workflow-lite-planex/SKILL.md +3 -3
  110. package/.codex/skills/workflow-plan/SKILL.md +3 -3
  111. package/.codex/skills/workflow-tdd-plan/SKILL.md +4 -4
  112. package/.codex/skills/workflow-test-fix-cycle/SKILL.md +403 -402
  113. package/README.md +14 -0
  114. package/ccw/dist/cli.d.ts.map +1 -1
  115. package/ccw/dist/cli.js +16 -0
  116. package/ccw/dist/cli.js.map +1 -1
  117. package/ccw/dist/commands/chain-loader.d.ts +2 -0
  118. package/ccw/dist/commands/chain-loader.d.ts.map +1 -0
  119. package/ccw/dist/commands/chain-loader.js +11 -0
  120. package/ccw/dist/commands/chain-loader.js.map +1 -0
  121. package/ccw/dist/commands/install.d.ts.map +1 -1
  122. package/ccw/dist/commands/install.js +52 -1
  123. package/ccw/dist/commands/install.js.map +1 -1
  124. package/ccw/dist/commands/launcher.d.ts +2 -0
  125. package/ccw/dist/commands/launcher.d.ts.map +1 -0
  126. package/ccw/dist/commands/launcher.js +434 -0
  127. package/ccw/dist/commands/launcher.js.map +1 -0
  128. package/ccw/dist/core/routes/litellm-api-routes.d.ts.map +1 -1
  129. package/ccw/dist/core/routes/litellm-api-routes.js +0 -23
  130. package/ccw/dist/core/routes/litellm-api-routes.js.map +1 -1
  131. package/ccw/dist/tools/chain-loader.d.ts +10 -0
  132. package/ccw/dist/tools/chain-loader.d.ts.map +1 -0
  133. package/ccw/dist/tools/chain-loader.js +1054 -0
  134. package/ccw/dist/tools/chain-loader.js.map +1 -0
  135. package/ccw/dist/tools/index.d.ts.map +1 -1
  136. package/ccw/dist/tools/index.js +2 -0
  137. package/ccw/dist/tools/index.js.map +1 -1
  138. package/ccw/dist/tools/json-builder.js +20 -0
  139. package/ccw/dist/tools/json-builder.js.map +1 -1
  140. package/ccw/dist/tools/skill-context-loader.d.ts.map +1 -1
  141. package/ccw/dist/tools/skill-context-loader.js +12 -26
  142. package/ccw/dist/tools/skill-context-loader.js.map +1 -1
  143. package/ccw/dist/types/chain-types.d.ts +112 -0
  144. package/ccw/dist/types/chain-types.d.ts.map +1 -0
  145. package/ccw/dist/types/chain-types.js +5 -0
  146. package/ccw/dist/types/chain-types.js.map +1 -0
  147. package/ccw/dist/utils/chain-visualizer.d.ts +13 -0
  148. package/ccw/dist/utils/chain-visualizer.d.ts.map +1 -0
  149. package/ccw/dist/utils/chain-visualizer.js +164 -0
  150. package/ccw/dist/utils/chain-visualizer.js.map +1 -0
  151. package/ccw/scripts/prepublish-clean.mjs +0 -1
  152. package/package.json +1 -3
  153. package/.claude/commands/cli/cli-init.md +0 -441
  154. package/.claude/commands/cli/codex-review.md +0 -361
  155. package/.claude/commands/flow-create.md +0 -663
  156. package/.claude/skills/team-edict.zip +0 -0
  157. package/ccw-litellm/README.md +0 -180
  158. package/ccw-litellm/pyproject.toml +0 -35
  159. package/ccw-litellm/src/ccw_litellm/__init__.py +0 -47
  160. package/ccw-litellm/src/ccw_litellm/cli.py +0 -108
  161. package/ccw-litellm/src/ccw_litellm/clients/__init__.py +0 -12
  162. package/ccw-litellm/src/ccw_litellm/clients/litellm_embedder.py +0 -270
  163. package/ccw-litellm/src/ccw_litellm/clients/litellm_llm.py +0 -198
  164. package/ccw-litellm/src/ccw_litellm/config/__init__.py +0 -22
  165. package/ccw-litellm/src/ccw_litellm/config/loader.py +0 -343
  166. package/ccw-litellm/src/ccw_litellm/config/models.py +0 -162
  167. package/ccw-litellm/src/ccw_litellm/interfaces/__init__.py +0 -14
  168. package/ccw-litellm/src/ccw_litellm/interfaces/embedder.py +0 -52
  169. package/ccw-litellm/src/ccw_litellm/interfaces/llm.py +0 -45
@@ -1,493 +1,493 @@
1
- # Phase 2: Test Context Gather (test-context-gather)
2
-
3
- Gather test context via coverage analysis or codebase scan.
4
-
5
- ## Objective
6
-
7
- - Gather test context (coverage analysis or codebase scan)
8
- - Generate context package for downstream analysis
9
-
10
- ## Execution
11
-
12
- ### Step 1.2: Gather Test Context
13
-
14
- Two modes are available depending on whether a source session exists:
15
-
16
- ---
17
-
18
- ### Mode A: Session Mode (gather from source session)
19
-
20
- Collect test coverage context using test-context-search-agent and package into standardized test-context JSON.
21
-
22
- #### Core Philosophy
23
-
24
- - **Agent Delegation**: Delegate all test coverage analysis to `test-context-search-agent` for autonomous execution
25
- - **Detection-First**: Check for existing test-context-package before executing
26
- - **Coverage-First**: Analyze existing test coverage before planning new tests
27
- - **Source Context Loading**: Import implementation summaries from source session
28
- - **Standardized Output**: Generate `.workflow/active/{test_session_id}/.process/test-context-package.json`
29
-
30
- #### Step A.1: Test-Context-Package Detection
31
-
32
- **Execute First** - Check if valid package already exists:
33
-
34
- ```javascript
35
- const testContextPath = `.workflow/${test_session_id}/.process/test-context-package.json`;
36
-
37
- if (file_exists(testContextPath)) {
38
- const existing = Read(testContextPath);
39
-
40
- // Validate package belongs to current test session
41
- if (existing?.metadata?.test_session_id === test_session_id) {
42
- console.log("Valid test-context-package found for session:", test_session_id);
43
- console.log("Coverage Stats:", existing.test_coverage.coverage_stats);
44
- console.log("Framework:", existing.test_framework.framework);
45
- console.log("Missing Tests:", existing.test_coverage.missing_tests.length);
46
- return existing; // Skip execution, return existing
47
- } else {
48
- console.warn("Invalid test_session_id in existing package, re-generating...");
49
- }
50
- }
51
- ```
52
-
53
- #### Step A.2: Invoke Test-Context-Search Agent
54
-
55
- **Only execute if Step A.1 finds no valid package**
56
-
57
- ```javascript
58
- Task(
59
- subagent_type="test-context-search-agent",
60
- run_in_background=false,
61
- description="Gather test coverage context",
62
- prompt=`
63
-
64
- ## Execution Mode
65
- **PLAN MODE** (Comprehensive) - Full Phase 1-3 execution
66
-
67
- ## Session Information
68
- - **Test Session ID**: ${test_session_id}
69
- - **Output Path**: .workflow/${test_session_id}/.process/test-context-package.json
70
-
71
- ## Mission
72
- Execute complete test-context-search-agent workflow for test generation planning:
73
-
74
- ### Phase 1: Session Validation & Source Context Loading
75
- 1. **Detection**: Check for existing test-context-package (early exit if valid)
76
- 2. **Test Session Validation**: Load test session metadata, extract source_session reference
77
- 3. **Source Context Loading**: Load source session implementation summaries, changed files, tech stack
78
-
79
- ### Phase 2: Test Coverage Analysis
80
- Execute coverage discovery:
81
- - **Track 1**: Existing test discovery (find *.test.*, *.spec.* files)
82
- - **Track 2**: Coverage gap analysis (match implementation files to test files)
83
- - **Track 3**: Coverage statistics (calculate percentages, identify gaps by module)
84
-
85
- ### Phase 3: Framework Detection & Packaging
86
- 1. Framework identification from package.json/requirements.txt
87
- 2. Convention analysis from existing test patterns
88
- 3. Generate and validate test-context-package.json
89
-
90
- ## Output Requirements
91
- Complete test-context-package.json with:
92
- - **metadata**: test_session_id, source_session_id, task_type, complexity
93
- - **source_context**: implementation_summaries, tech_stack, project_patterns
94
- - **test_coverage**: existing_tests[], missing_tests[], coverage_stats
95
- - **test_framework**: framework, version, test_pattern, conventions
96
- - **assets**: implementation_summary[], existing_test[], source_code[] with priorities
97
- - **focus_areas**: Test generation guidance based on coverage gaps
98
-
99
- ## Quality Validation
100
- Before completion verify:
101
- - [ ] Valid JSON format with all required fields
102
- - [ ] Source session context loaded successfully
103
- - [ ] Test coverage gaps identified
104
- - [ ] Test framework detected (or marked as 'unknown')
105
- - [ ] Coverage percentage calculated correctly
106
- - [ ] Missing tests catalogued with priority
107
- - [ ] Execution time < 30 seconds (< 60s for large codebases)
108
-
109
- Execute autonomously following agent documentation.
110
- Report completion with coverage statistics.
111
- `
112
- )
113
- ```
114
-
115
- #### Step A.3: Output Verification
116
-
117
- After agent completes, verify output:
118
-
119
- ```javascript
120
- // Verify file was created
121
- const outputPath = `.workflow/${test_session_id}/.process/test-context-package.json`;
122
- if (!file_exists(outputPath)) {
123
- throw new Error("Agent failed to generate test-context-package.json");
124
- }
125
-
126
- // Load and display summary
127
- const testContext = Read(outputPath);
128
- console.log("Test context package generated successfully");
129
- console.log("Coverage:", testContext.test_coverage.coverage_stats.coverage_percentage + "%");
130
- console.log("Tests to generate:", testContext.test_coverage.missing_tests.length);
131
- ```
132
-
133
- ---
134
-
135
- ### Mode B: Prompt Mode (gather from codebase)
136
-
137
- Intelligently collect project context using context-search-agent based on task description, packages into standardized JSON.
138
-
139
- #### Core Philosophy
140
-
141
- - **Agent Delegation**: Delegate all discovery to `context-search-agent` for autonomous execution
142
- - **Detection-First**: Check for existing context-package before executing
143
- - **Plan Mode**: Full comprehensive analysis (vs lightweight brainstorm mode)
144
- - **Standardized Output**: Generate `.workflow/active/{session}/.process/context-package.json`
145
-
146
- #### Step B.1: Context-Package Detection
147
-
148
- **Execute First** - Check if valid package already exists:
149
-
150
- ```javascript
151
- const contextPackagePath = `.workflow/${session_id}/.process/context-package.json`;
152
-
153
- if (file_exists(contextPackagePath)) {
154
- const existing = Read(contextPackagePath);
155
-
156
- // Validate package belongs to current session
157
- if (existing?.metadata?.session_id === session_id) {
158
- console.log("Valid context-package found for session:", session_id);
159
- console.log("Stats:", existing.statistics);
160
- console.log("Conflict Risk:", existing.conflict_detection.risk_level);
161
- return existing; // Skip execution, return existing
162
- } else {
163
- console.warn("Invalid session_id in existing package, re-generating...");
164
- }
165
- }
166
- ```
167
-
168
- #### Step B.2: Complexity Assessment & Parallel Explore
169
-
170
- **Only execute if Step B.1 finds no valid package**
171
-
172
- ```javascript
173
- // B.2.1 Complexity Assessment
174
- function analyzeTaskComplexity(taskDescription) {
175
- const text = taskDescription.toLowerCase();
176
- if (/architect|refactor|restructure|modular|cross-module/.test(text)) return 'High';
177
- if (/multiple|several|integrate|migrate|extend/.test(text)) return 'Medium';
178
- return 'Low';
179
- }
180
-
181
- const ANGLE_PRESETS = {
182
- architecture: ['architecture', 'dependencies', 'modularity', 'integration-points'],
183
- security: ['security', 'auth-patterns', 'dataflow', 'validation'],
184
- performance: ['performance', 'bottlenecks', 'caching', 'data-access'],
185
- bugfix: ['error-handling', 'dataflow', 'state-management', 'edge-cases'],
186
- feature: ['patterns', 'integration-points', 'testing', 'dependencies'],
187
- refactor: ['architecture', 'patterns', 'dependencies', 'testing']
188
- };
189
-
190
- function selectAngles(taskDescription, complexity) {
191
- const text = taskDescription.toLowerCase();
192
- let preset = 'feature';
193
- if (/refactor|architect|restructure/.test(text)) preset = 'architecture';
194
- else if (/security|auth|permission/.test(text)) preset = 'security';
195
- else if (/performance|slow|optimi/.test(text)) preset = 'performance';
196
- else if (/fix|bug|error|issue/.test(text)) preset = 'bugfix';
197
-
198
- const count = complexity === 'High' ? 4 : (complexity === 'Medium' ? 3 : 1);
199
- return ANGLE_PRESETS[preset].slice(0, count);
200
- }
201
-
202
- const complexity = analyzeTaskComplexity(task_description);
203
- const selectedAngles = selectAngles(task_description, complexity);
204
- const sessionFolder = `.workflow/active/${session_id}/.process`;
205
-
206
- // B.2.2 Launch Parallel Explore Agents
207
- const explorationTasks = selectedAngles.map((angle, index) =>
208
- Task(
209
- subagent_type="cli-explore-agent",
210
- run_in_background=false,
211
- description=`Explore: ${angle}`,
212
- prompt=`
213
- ## Task Objective
214
- Execute **${angle}** exploration for task planning context. Analyze codebase from this specific angle to discover relevant structure, patterns, and constraints.
215
-
216
- ## Assigned Context
217
- - **Exploration Angle**: ${angle}
218
- - **Task Description**: ${task_description}
219
- - **Session ID**: ${session_id}
220
- - **Exploration Index**: ${index + 1} of ${selectedAngles.length}
221
- - **Output File**: ${sessionFolder}/exploration-${angle}.json
222
-
223
- ## MANDATORY FIRST STEPS (Execute by Agent)
224
- 1. Run: ccw tool exec get_modules_by_depth '{}' (project structure)
225
- 2. Run: rg -l "{keyword_from_task}" --type ts (locate relevant files)
226
- 3. Execute: ccw tool exec json_builder '{"cmd":"init","schema":"explore","output":"${sessionFolder}/exploration-${angle}.json"}' (init output + get schema info)
227
-
228
- ## Exploration Strategy (${angle} focus)
229
-
230
- **Step 1: Structural Scan** (Bash)
231
- - get_modules_by_depth.sh -> identify modules related to ${angle}
232
- - find/rg -> locate files relevant to ${angle} aspect
233
- - Analyze imports/dependencies from ${angle} perspective
234
-
235
- **Step 2: Semantic Analysis** (Gemini CLI)
236
- - How does existing code handle ${angle} concerns?
237
- - What patterns are used for ${angle}?
238
- - Where would new code integrate from ${angle} viewpoint?
239
-
240
- **Step 3: Write Output**
241
- - Consolidate ${angle} findings into JSON
242
- - Identify ${angle}-specific clarification needs
243
-
244
- ## Expected Output
245
-
246
- **File**: ${sessionFolder}/exploration-${angle}.json
247
-
248
- **Schema Reference**: Schema obtained in MANDATORY FIRST STEPS step 3, follow schema exactly
249
-
250
- **Required Fields** (all ${angle} focused):
251
- - project_structure: Modules/architecture relevant to ${angle}
252
- - relevant_files: Files affected from ${angle} perspective
253
- **MANDATORY**: Every file MUST use structured object format with ALL required fields:
254
- [{path: "src/file.ts", relevance: 0.85, rationale: "Contains AuthService.login() - entry point for JWT token generation", role: "modify_target", discovery_source: "bash-scan", key_symbols: ["AuthService", "login"]}]
255
- - **rationale** (required): Specific selection basis tied to ${angle} topic (>10 chars, not generic)
256
- - **role** (required): modify_target|dependency|pattern_reference|test_target|type_definition|integration_point|config|context_only
257
- - **discovery_source** (recommended): bash-scan|cli-analysis|ace-search|dependency-trace|manual
258
- - **key_symbols** (recommended): Key functions/classes/types in the file relevant to the task
259
- - Scores: 0.7+ high priority, 0.5-0.7 medium, <0.5 low
260
- - patterns: ${angle}-related patterns to follow
261
- - dependencies: Dependencies relevant to ${angle}
262
- - integration_points: Where to integrate from ${angle} viewpoint (include file:line locations)
263
- - constraints: ${angle}-specific limitations/conventions
264
- - clarification_needs: ${angle}-related ambiguities (options array + recommended index)
265
- - _metadata.exploration_angle: "${angle}"
266
-
267
- ## Success Criteria
268
- - [ ] Schema initialized via json_builder init
269
- - [ ] get_modules_by_depth.sh executed
270
- - [ ] At least 3 relevant files identified with ${angle} rationale
271
- - [ ] Patterns are actionable (code examples, not generic advice)
272
- - [ ] Integration points include file:line locations
273
- - [ ] Constraints are project-specific to ${angle}
274
- - [ ] JSON output follows schema exactly
275
- - [ ] clarification_needs includes options + recommended
276
-
277
- ## Output
278
- Write: ${sessionFolder}/exploration-${angle}.json
279
- Return: 2-3 sentence summary of ${angle} findings
280
- `
281
- )
282
- );
283
-
284
- // B.2.3 Generate Manifest after all complete
285
- const explorationFiles = bash(`find ${sessionFolder} -name "exploration-*.json" -type f`).split('\n').filter(f => f.trim());
286
- const explorationManifest = {
287
- session_id,
288
- task_description,
289
- timestamp: new Date().toISOString(),
290
- complexity,
291
- exploration_count: selectedAngles.length,
292
- angles_explored: selectedAngles,
293
- explorations: explorationFiles.map(file => {
294
- const data = JSON.parse(Read(file));
295
- return { angle: data._metadata.exploration_angle, file: file.split('/').pop(), path: file, index: data._metadata.exploration_index };
296
- })
297
- };
298
- Write(`${sessionFolder}/explorations-manifest.json`, JSON.stringify(explorationManifest, null, 2));
299
- ```
300
-
301
- #### Step B.3: Invoke Context-Search Agent
302
-
303
- **Only execute after Step B.2 completes**
304
-
305
- ```javascript
306
- // Load user intent from planning-notes.md (from Phase 1)
307
- const planningNotesPath = `.workflow/active/${session_id}/planning-notes.md`;
308
- let userIntent = { goal: task_description, key_constraints: "None specified" };
309
-
310
- if (file_exists(planningNotesPath)) {
311
- const notesContent = Read(planningNotesPath);
312
- const goalMatch = notesContent.match(/\*\*GOAL\*\*:\s*(.+)/);
313
- const constraintsMatch = notesContent.match(/\*\*KEY_CONSTRAINTS\*\*:\s*(.+)/);
314
- if (goalMatch) userIntent.goal = goalMatch[1].trim();
315
- if (constraintsMatch) userIntent.key_constraints = constraintsMatch[1].trim();
316
- }
317
-
318
- Task(
319
- subagent_type="context-search-agent",
320
- run_in_background=false,
321
- description="Gather comprehensive context for plan",
322
- prompt=`
323
- ## Execution Mode
324
- **PLAN MODE** (Comprehensive) - Full Phase 1-3 execution with priority sorting
325
-
326
- ## Session Information
327
- - **Session ID**: ${session_id}
328
- - **Task Description**: ${task_description}
329
- - **Output Path**: .workflow/${session_id}/.process/context-package.json
330
-
331
- ## User Intent (from Phase 1 - Planning Notes)
332
- **GOAL**: ${userIntent.goal}
333
- **KEY_CONSTRAINTS**: ${userIntent.key_constraints}
334
-
335
- This is the PRIMARY context source - all subsequent analysis must align with user intent.
336
-
337
- ## Exploration Input (from Step B.2)
338
- - **Manifest**: ${sessionFolder}/explorations-manifest.json
339
- - **Exploration Count**: ${explorationManifest.exploration_count}
340
- - **Angles**: ${explorationManifest.angles_explored.join(', ')}
341
- - **Complexity**: ${complexity}
342
-
343
- ## Mission
344
- Execute complete context-search-agent workflow for implementation planning:
345
-
346
- ### Phase 1: Initialization & Pre-Analysis
347
- 1. **Project State Loading**:
348
- - Run: \`ccw spec load --category execution\` to load project context, tech stack, and guidelines.
349
- - Run: \`ccw spec load --category test\` to load test framework conventions, coverage targets, and fixtures.
350
- - If files don't exist, proceed with fresh analysis.
351
- 2. **Detection**: Check for existing context-package (early exit if valid)
352
- 3. **Foundation**: Initialize CodexLens, get project structure, load docs
353
- 4. **Analysis**: Extract keywords, determine scope, classify complexity based on task description and project state
354
-
355
- ### Phase 2: Multi-Source Context Discovery
356
- Execute all discovery tracks (WITH USER INTENT INTEGRATION):
357
- - **Track -1**: User Intent & Priority Foundation (EXECUTE FIRST)
358
- - Load user intent (GOAL, KEY_CONSTRAINTS) from session input
359
- - Map user requirements to codebase entities (files, modules, patterns)
360
- - Establish baseline priority scores based on user goal alignment
361
- - Output: user_intent_mapping.json with preliminary priority scores
362
-
363
- - **Track 0**: Exploration Synthesis (load explorations-manifest.json, prioritize critical_files, deduplicate patterns/integration_points)
364
- - **Track 1**: Historical archive analysis (query manifest.json for lessons learned)
365
- - **Track 2**: Reference documentation (CLAUDE.md, architecture docs)
366
- - **Track 3**: Web examples (use Exa MCP for unfamiliar tech/APIs)
367
- - **Track 4**: Codebase analysis (5-layer discovery: files, content, patterns, deps, config/tests)
368
-
369
- ### Phase 3: Synthesis, Assessment & Packaging
370
- 1. Apply relevance scoring and build dependency graph
371
- 2. **Synthesize 5-source data** (including Track -1): Merge findings from all sources
372
- - Priority order: User Intent > Archive > Docs > Exploration > Code > Web
373
- - **Prioritize the context from project-tech.json** for architecture and tech stack unless code analysis reveals it's outdated
374
- 3. **Context Priority Sorting**:
375
- a. Combine scores from Track -1 (user intent alignment) + relevance scores + exploration critical_files
376
- b. Classify files into priority tiers:
377
- - **Critical** (score >= 0.85): Directly mentioned in user goal OR exploration critical_files
378
- - **High** (0.70-0.84): Key dependencies, patterns required for goal
379
- - **Medium** (0.50-0.69): Supporting files, indirect dependencies
380
- - **Low** (< 0.50): Contextual awareness only
381
- c. Generate dependency_order: Based on dependency graph + user goal sequence
382
- d. Document sorting_rationale: Explain prioritization logic
383
- 4. **Populate project_context**: Directly use the overview from project-tech.json
384
- 5. **Populate project_guidelines**: Load from specs/*.md
385
- 6. Integrate brainstorm artifacts (if .brainstorming/ exists, read content)
386
- 7. Perform conflict detection with risk assessment
387
- 8. **Inject historical conflicts** from archive analysis into conflict_detection
388
- 9. **Generate prioritized_context section**:
389
- {
390
- "prioritized_context": {
391
- "user_intent": { "goal": "...", "scope": "...", "key_constraints": ["..."] },
392
- "priority_tiers": {
393
- "critical": [{ "path": "...", "relevance": 0.95, "rationale": "..." }],
394
- "high": [...], "medium": [...], "low": [...]
395
- },
396
- "dependency_order": ["module1", "module2", "module3"],
397
- "sorting_rationale": "Based on user goal alignment, exploration critical files, and dependency graph"
398
- }
399
- }
400
- 10. Generate and validate context-package.json with prioritized_context field
401
-
402
- ## Output Requirements
403
- Complete context-package.json with:
404
- - **metadata**: task_description, keywords, complexity, tech_stack, session_id
405
- - **project_context**: description, technology_stack, architecture, key_components (from project-tech.json)
406
- - **project_guidelines**: {conventions, constraints, quality_rules, learnings} (from specs/*.md)
407
- - **assets**: {documentation[], source_code[], config[], tests[]} with relevance scores
408
- - **dependencies**: {internal[], external[]} with dependency graph
409
- - **brainstorm_artifacts**: {guidance_specification, role_analyses[], synthesis_output} with content
410
- - **conflict_detection**: {risk_level, risk_factors, affected_modules[], mitigation_strategy, historical_conflicts[]}
411
- - **exploration_results**: {manifest_path, exploration_count, angles, explorations[], aggregated_insights}
412
- - **prioritized_context**: {user_intent, priority_tiers{critical, high, medium, low}, dependency_order[], sorting_rationale}
413
-
414
- ## Quality Validation
415
- Before completion verify:
416
- - [ ] Valid JSON format with all required fields
417
- - [ ] File relevance accuracy >80%
418
- - [ ] Dependency graph complete (max 2 transitive levels)
419
- - [ ] Conflict risk level calculated correctly
420
- - [ ] No sensitive data exposed
421
- - [ ] Total files <= 50 (prioritize high-relevance)
422
-
423
- Execute autonomously following agent documentation.
424
- Report completion with statistics.
425
- `
426
- )
427
- ```
428
-
429
- #### Step B.4: Output Verification
430
-
431
- After agent completes, verify output:
432
-
433
- ```javascript
434
- // Verify file was created
435
- const outputPath = `.workflow/${session_id}/.process/context-package.json`;
436
- if (!file_exists(outputPath)) {
437
- throw new Error("Agent failed to generate context-package.json");
438
- }
439
-
440
- // Verify exploration_results included
441
- const pkg = JSON.parse(Read(outputPath));
442
- if (pkg.exploration_results?.exploration_count > 0) {
443
- console.log(`Exploration results aggregated: ${pkg.exploration_results.exploration_count} angles`);
444
- }
445
- ```
446
-
447
- ---
448
-
449
- **Input**: `testSessionId` from Phase 1
450
-
451
- **Parse Output**:
452
- - Extract: context package path (store as `contextPath`)
453
- - Pattern: `.workflow/active/[testSessionId]/.process/[test-]context-package.json`
454
-
455
- **Validation**:
456
- - Context package file exists and is valid JSON
457
- - Contains coverage analysis (session mode) or codebase analysis (prompt mode)
458
- - Test framework detected
459
-
460
- **TodoWrite Update (tasks attached)**:
461
- ```json
462
- [
463
- {"content": "Phase 1: Test Generation", "status": "in_progress"},
464
- {"content": " -> Create test session", "status": "completed"},
465
- {"content": " -> Gather test context", "status": "in_progress"},
466
- {"content": " -> Load source/codebase context", "status": "in_progress"},
467
- {"content": " -> Analyze test coverage", "status": "pending"},
468
- {"content": " -> Generate context package", "status": "pending"},
469
- {"content": " -> Test analysis (Gemini)", "status": "pending"},
470
- {"content": " -> Generate test tasks", "status": "pending"},
471
- {"content": "Phase 2: Test Cycle Execution", "status": "pending"}
472
- ]
473
- ```
474
-
475
- **TodoWrite Update (tasks collapsed)**:
476
- ```json
477
- [
478
- {"content": "Phase 1: Test Generation", "status": "in_progress"},
479
- {"content": " -> Create test session", "status": "completed"},
480
- {"content": " -> Gather test context", "status": "completed"},
481
- {"content": " -> Test analysis (Gemini)", "status": "pending"},
482
- {"content": " -> Generate test tasks", "status": "pending"},
483
- {"content": "Phase 2: Test Cycle Execution", "status": "pending"}
484
- ]
485
- ```
486
-
487
- ## Output
488
-
489
- - **Variable**: `contextPath` (context-package.json path)
490
-
491
- ## Next Phase
492
-
493
- Continue to [Phase 3: Test Concept Enhanced](03-test-concept-enhanced.md).
1
+ # Phase 2: Test Context Gather (test-context-gather)
2
+
3
+ Gather test context via coverage analysis or codebase scan.
4
+
5
+ ## Objective
6
+
7
+ - Gather test context (coverage analysis or codebase scan)
8
+ - Generate context package for downstream analysis
9
+
10
+ ## Execution
11
+
12
+ ### Step 1.2: Gather Test Context
13
+
14
+ Two modes are available depending on whether a source session exists:
15
+
16
+ ---
17
+
18
+ ### Mode A: Session Mode (gather from source session)
19
+
20
+ Collect test coverage context using test-context-search-agent and package into standardized test-context JSON.
21
+
22
+ #### Core Philosophy
23
+
24
+ - **Agent Delegation**: Delegate all test coverage analysis to `test-context-search-agent` for autonomous execution
25
+ - **Detection-First**: Check for existing test-context-package before executing
26
+ - **Coverage-First**: Analyze existing test coverage before planning new tests
27
+ - **Source Context Loading**: Import implementation summaries from source session
28
+ - **Standardized Output**: Generate `.workflow/active/{test_session_id}/.process/test-context-package.json`
29
+
30
+ #### Step A.1: Test-Context-Package Detection
31
+
32
+ **Execute First** - Check if valid package already exists:
33
+
34
+ ```javascript
35
+ const testContextPath = `.workflow/${test_session_id}/.process/test-context-package.json`;
36
+
37
+ if (file_exists(testContextPath)) {
38
+ const existing = Read(testContextPath);
39
+
40
+ // Validate package belongs to current test session
41
+ if (existing?.metadata?.test_session_id === test_session_id) {
42
+ console.log("Valid test-context-package found for session:", test_session_id);
43
+ console.log("Coverage Stats:", existing.test_coverage.coverage_stats);
44
+ console.log("Framework:", existing.test_framework.framework);
45
+ console.log("Missing Tests:", existing.test_coverage.missing_tests.length);
46
+ return existing; // Skip execution, return existing
47
+ } else {
48
+ console.warn("Invalid test_session_id in existing package, re-generating...");
49
+ }
50
+ }
51
+ ```
52
+
53
+ #### Step A.2: Invoke Test-Context-Search Agent
54
+
55
+ **Only execute if Step A.1 finds no valid package**
56
+
57
+ ```javascript
58
+ Task(
59
+ subagent_type="test-context-search-agent",
60
+ run_in_background=false,
61
+ description="Gather test coverage context",
62
+ prompt=`
63
+
64
+ ## Execution Mode
65
+ **PLAN MODE** (Comprehensive) - Full Phase 1-3 execution
66
+
67
+ ## Session Information
68
+ - **Test Session ID**: ${test_session_id}
69
+ - **Output Path**: .workflow/${test_session_id}/.process/test-context-package.json
70
+
71
+ ## Mission
72
+ Execute complete test-context-search-agent workflow for test generation planning:
73
+
74
+ ### Phase 1: Session Validation & Source Context Loading
75
+ 1. **Detection**: Check for existing test-context-package (early exit if valid)
76
+ 2. **Test Session Validation**: Load test session metadata, extract source_session reference
77
+ 3. **Source Context Loading**: Load source session implementation summaries, changed files, tech stack
78
+
79
+ ### Phase 2: Test Coverage Analysis
80
+ Execute coverage discovery:
81
+ - **Track 1**: Existing test discovery (find *.test.*, *.spec.* files)
82
+ - **Track 2**: Coverage gap analysis (match implementation files to test files)
83
+ - **Track 3**: Coverage statistics (calculate percentages, identify gaps by module)
84
+
85
+ ### Phase 3: Framework Detection & Packaging
86
+ 1. Framework identification from package.json/requirements.txt
87
+ 2. Convention analysis from existing test patterns
88
+ 3. Generate and validate test-context-package.json
89
+
90
+ ## Output Requirements
91
+ Complete test-context-package.json with:
92
+ - **metadata**: test_session_id, source_session_id, task_type, complexity
93
+ - **source_context**: implementation_summaries, tech_stack, project_patterns
94
+ - **test_coverage**: existing_tests[], missing_tests[], coverage_stats
95
+ - **test_framework**: framework, version, test_pattern, conventions
96
+ - **assets**: implementation_summary[], existing_test[], source_code[] with priorities
97
+ - **focus_areas**: Test generation guidance based on coverage gaps
98
+
99
+ ## Quality Validation
100
+ Before completion verify:
101
+ - [ ] Valid JSON format with all required fields
102
+ - [ ] Source session context loaded successfully
103
+ - [ ] Test coverage gaps identified
104
+ - [ ] Test framework detected (or marked as 'unknown')
105
+ - [ ] Coverage percentage calculated correctly
106
+ - [ ] Missing tests catalogued with priority
107
+ - [ ] Execution time < 30 seconds (< 60s for large codebases)
108
+
109
+ Execute autonomously following agent documentation.
110
+ Report completion with coverage statistics.
111
+ `
112
+ )
113
+ ```
114
+
115
+ #### Step A.3: Output Verification
116
+
117
+ After agent completes, verify output:
118
+
119
+ ```javascript
120
+ // Verify file was created
121
+ const outputPath = `.workflow/${test_session_id}/.process/test-context-package.json`;
122
+ if (!file_exists(outputPath)) {
123
+ throw new Error("Agent failed to generate test-context-package.json");
124
+ }
125
+
126
+ // Load and display summary
127
+ const testContext = Read(outputPath);
128
+ console.log("Test context package generated successfully");
129
+ console.log("Coverage:", testContext.test_coverage.coverage_stats.coverage_percentage + "%");
130
+ console.log("Tests to generate:", testContext.test_coverage.missing_tests.length);
131
+ ```
132
+
133
+ ---
134
+
135
+ ### Mode B: Prompt Mode (gather from codebase)
136
+
137
+ Intelligently collect project context using context-search-agent based on task description, packages into standardized JSON.
138
+
139
+ #### Core Philosophy
140
+
141
+ - **Agent Delegation**: Delegate all discovery to `context-search-agent` for autonomous execution
142
+ - **Detection-First**: Check for existing context-package before executing
143
+ - **Plan Mode**: Full comprehensive analysis (vs lightweight brainstorm mode)
144
+ - **Standardized Output**: Generate `.workflow/active/{session}/.process/context-package.json`
145
+
146
+ #### Step B.1: Context-Package Detection
147
+
148
+ **Execute First** - Check if valid package already exists:
149
+
150
+ ```javascript
151
+ const contextPackagePath = `.workflow/${session_id}/.process/context-package.json`;
152
+
153
+ if (file_exists(contextPackagePath)) {
154
+ const existing = Read(contextPackagePath);
155
+
156
+ // Validate package belongs to current session
157
+ if (existing?.metadata?.session_id === session_id) {
158
+ console.log("Valid context-package found for session:", session_id);
159
+ console.log("Stats:", existing.statistics);
160
+ console.log("Conflict Risk:", existing.conflict_detection.risk_level);
161
+ return existing; // Skip execution, return existing
162
+ } else {
163
+ console.warn("Invalid session_id in existing package, re-generating...");
164
+ }
165
+ }
166
+ ```
167
+
168
+ #### Step B.2: Complexity Assessment & Parallel Explore
169
+
170
+ **Only execute if Step B.1 finds no valid package**
171
+
172
+ ```javascript
173
+ // B.2.1 Complexity Assessment
174
+ function analyzeTaskComplexity(taskDescription) {
175
+ const text = taskDescription.toLowerCase();
176
+ if (/architect|refactor|restructure|modular|cross-module/.test(text)) return 'High';
177
+ if (/multiple|several|integrate|migrate|extend/.test(text)) return 'Medium';
178
+ return 'Low';
179
+ }
180
+
181
+ const ANGLE_PRESETS = {
182
+ architecture: ['architecture', 'dependencies', 'modularity', 'integration-points'],
183
+ security: ['security', 'auth-patterns', 'dataflow', 'validation'],
184
+ performance: ['performance', 'bottlenecks', 'caching', 'data-access'],
185
+ bugfix: ['error-handling', 'dataflow', 'state-management', 'edge-cases'],
186
+ feature: ['patterns', 'integration-points', 'testing', 'dependencies'],
187
+ refactor: ['architecture', 'patterns', 'dependencies', 'testing']
188
+ };
189
+
190
+ function selectAngles(taskDescription, complexity) {
191
+ const text = taskDescription.toLowerCase();
192
+ let preset = 'feature';
193
+ if (/refactor|architect|restructure/.test(text)) preset = 'architecture';
194
+ else if (/security|auth|permission/.test(text)) preset = 'security';
195
+ else if (/performance|slow|optimi/.test(text)) preset = 'performance';
196
+ else if (/fix|bug|error|issue/.test(text)) preset = 'bugfix';
197
+
198
+ const count = complexity === 'High' ? 4 : (complexity === 'Medium' ? 3 : 1);
199
+ return ANGLE_PRESETS[preset].slice(0, count);
200
+ }
201
+
202
+ const complexity = analyzeTaskComplexity(task_description);
203
+ const selectedAngles = selectAngles(task_description, complexity);
204
+ const sessionFolder = `.workflow/active/${session_id}/.process`;
205
+
206
+ // B.2.2 Launch Parallel Explore Agents
207
+ const explorationTasks = selectedAngles.map((angle, index) =>
208
+ Task(
209
+ subagent_type="cli-explore-agent",
210
+ run_in_background=false,
211
+ description=`Explore: ${angle}`,
212
+ prompt=`
213
+ ## Task Objective
214
+ Execute **${angle}** exploration for task planning context. Analyze codebase from this specific angle to discover relevant structure, patterns, and constraints.
215
+
216
+ ## Assigned Context
217
+ - **Exploration Angle**: ${angle}
218
+ - **Task Description**: ${task_description}
219
+ - **Session ID**: ${session_id}
220
+ - **Exploration Index**: ${index + 1} of ${selectedAngles.length}
221
+ - **Output File**: ${sessionFolder}/exploration-${angle}.json
222
+
223
+ ## MANDATORY FIRST STEPS (Execute by Agent)
224
+ 1. Run: ccw tool exec get_modules_by_depth '{}' (project structure)
225
+ 2. Run: rg -l "{keyword_from_task}" --type ts (locate relevant files)
226
+ 3. Execute: cat ~/.ccw/workflows/cli-templates/schemas/explore-json-schema.json (get output schema reference)
227
+
228
+ ## Exploration Strategy (${angle} focus)
229
+
230
+ **Step 1: Structural Scan** (Bash)
231
+ - get_modules_by_depth.sh -> identify modules related to ${angle}
232
+ - find/rg -> locate files relevant to ${angle} aspect
233
+ - Analyze imports/dependencies from ${angle} perspective
234
+
235
+ **Step 2: Semantic Analysis** (Gemini CLI)
236
+ - How does existing code handle ${angle} concerns?
237
+ - What patterns are used for ${angle}?
238
+ - Where would new code integrate from ${angle} viewpoint?
239
+
240
+ **Step 3: Write Output**
241
+ - Consolidate ${angle} findings into JSON
242
+ - Identify ${angle}-specific clarification needs
243
+
244
+ ## Expected Output
245
+
246
+ **File**: ${sessionFolder}/exploration-${angle}.json
247
+
248
+ **Schema Reference**: Schema obtained in MANDATORY FIRST STEPS step 3, follow schema exactly
249
+
250
+ **Required Fields** (all ${angle} focused):
251
+ - project_structure: Modules/architecture relevant to ${angle}
252
+ - relevant_files: Files affected from ${angle} perspective
253
+ **MANDATORY**: Every file MUST use structured object format with ALL required fields:
254
+ [{path: "src/file.ts", relevance: 0.85, rationale: "Contains AuthService.login() - entry point for JWT token generation", role: "modify_target", discovery_source: "bash-scan", key_symbols: ["AuthService", "login"]}]
255
+ - **rationale** (required): Specific selection basis tied to ${angle} topic (>10 chars, not generic)
256
+ - **role** (required): modify_target|dependency|pattern_reference|test_target|type_definition|integration_point|config|context_only
257
+ - **discovery_source** (recommended): bash-scan|cli-analysis|ace-search|dependency-trace|manual
258
+ - **key_symbols** (recommended): Key functions/classes/types in the file relevant to the task
259
+ - Scores: 0.7+ high priority, 0.5-0.7 medium, <0.5 low
260
+ - patterns: ${angle}-related patterns to follow
261
+ - dependencies: Dependencies relevant to ${angle}
262
+ - integration_points: Where to integrate from ${angle} viewpoint (include file:line locations)
263
+ - constraints: ${angle}-specific limitations/conventions
264
+ - clarification_needs: ${angle}-related ambiguities (options array + recommended index)
265
+ - _metadata.exploration_angle: "${angle}"
266
+
267
+ ## Success Criteria
268
+ - [ ] Schema obtained via cat explore-json-schema.json
269
+ - [ ] get_modules_by_depth.sh executed
270
+ - [ ] At least 3 relevant files identified with ${angle} rationale
271
+ - [ ] Patterns are actionable (code examples, not generic advice)
272
+ - [ ] Integration points include file:line locations
273
+ - [ ] Constraints are project-specific to ${angle}
274
+ - [ ] JSON output follows schema exactly
275
+ - [ ] clarification_needs includes options + recommended
276
+
277
+ ## Output
278
+ Write: ${sessionFolder}/exploration-${angle}.json
279
+ Return: 2-3 sentence summary of ${angle} findings
280
+ `
281
+ )
282
+ );
283
+
284
+ // B.2.3 Generate Manifest after all complete
285
+ const explorationFiles = bash(`find ${sessionFolder} -name "exploration-*.json" -type f`).split('\n').filter(f => f.trim());
286
+ const explorationManifest = {
287
+ session_id,
288
+ task_description,
289
+ timestamp: new Date().toISOString(),
290
+ complexity,
291
+ exploration_count: selectedAngles.length,
292
+ angles_explored: selectedAngles,
293
+ explorations: explorationFiles.map(file => {
294
+ const data = JSON.parse(Read(file));
295
+ return { angle: data._metadata.exploration_angle, file: file.split('/').pop(), path: file, index: data._metadata.exploration_index };
296
+ })
297
+ };
298
+ Write(`${sessionFolder}/explorations-manifest.json`, JSON.stringify(explorationManifest, null, 2));
299
+ ```
300
+
301
+ #### Step B.3: Invoke Context-Search Agent
302
+
303
+ **Only execute after Step B.2 completes**
304
+
305
+ ```javascript
306
+ // Load user intent from planning-notes.md (from Phase 1)
307
+ const planningNotesPath = `.workflow/active/${session_id}/planning-notes.md`;
308
+ let userIntent = { goal: task_description, key_constraints: "None specified" };
309
+
310
+ if (file_exists(planningNotesPath)) {
311
+ const notesContent = Read(planningNotesPath);
312
+ const goalMatch = notesContent.match(/\*\*GOAL\*\*:\s*(.+)/);
313
+ const constraintsMatch = notesContent.match(/\*\*KEY_CONSTRAINTS\*\*:\s*(.+)/);
314
+ if (goalMatch) userIntent.goal = goalMatch[1].trim();
315
+ if (constraintsMatch) userIntent.key_constraints = constraintsMatch[1].trim();
316
+ }
317
+
318
+ Task(
319
+ subagent_type="context-search-agent",
320
+ run_in_background=false,
321
+ description="Gather comprehensive context for plan",
322
+ prompt=`
323
+ ## Execution Mode
324
+ **PLAN MODE** (Comprehensive) - Full Phase 1-3 execution with priority sorting
325
+
326
+ ## Session Information
327
+ - **Session ID**: ${session_id}
328
+ - **Task Description**: ${task_description}
329
+ - **Output Path**: .workflow/${session_id}/.process/context-package.json
330
+
331
+ ## User Intent (from Phase 1 - Planning Notes)
332
+ **GOAL**: ${userIntent.goal}
333
+ **KEY_CONSTRAINTS**: ${userIntent.key_constraints}
334
+
335
+ This is the PRIMARY context source - all subsequent analysis must align with user intent.
336
+
337
+ ## Exploration Input (from Step B.2)
338
+ - **Manifest**: ${sessionFolder}/explorations-manifest.json
339
+ - **Exploration Count**: ${explorationManifest.exploration_count}
340
+ - **Angles**: ${explorationManifest.angles_explored.join(', ')}
341
+ - **Complexity**: ${complexity}
342
+
343
+ ## Mission
344
+ Execute complete context-search-agent workflow for implementation planning:
345
+
346
+ ### Phase 1: Initialization & Pre-Analysis
347
+ 1. **Project State Loading**:
348
+ - Run: \`ccw spec load --category execution\` to load project context, tech stack, and guidelines.
349
+ - Run: \`ccw spec load --category test\` to load test framework conventions, coverage targets, and fixtures.
350
+ - If files don't exist, proceed with fresh analysis.
351
+ 2. **Detection**: Check for existing context-package (early exit if valid)
352
+ 3. **Foundation**: Initialize CodexLens, get project structure, load docs
353
+ 4. **Analysis**: Extract keywords, determine scope, classify complexity based on task description and project state
354
+
355
+ ### Phase 2: Multi-Source Context Discovery
356
+ Execute all discovery tracks (WITH USER INTENT INTEGRATION):
357
+ - **Track -1**: User Intent & Priority Foundation (EXECUTE FIRST)
358
+ - Load user intent (GOAL, KEY_CONSTRAINTS) from session input
359
+ - Map user requirements to codebase entities (files, modules, patterns)
360
+ - Establish baseline priority scores based on user goal alignment
361
+ - Output: user_intent_mapping.json with preliminary priority scores
362
+
363
+ - **Track 0**: Exploration Synthesis (load explorations-manifest.json, prioritize critical_files, deduplicate patterns/integration_points)
364
+ - **Track 1**: Historical archive analysis (query manifest.json for lessons learned)
365
+ - **Track 2**: Reference documentation (CLAUDE.md, architecture docs)
366
+ - **Track 3**: Web examples (use Exa MCP for unfamiliar tech/APIs)
367
+ - **Track 4**: Codebase analysis (5-layer discovery: files, content, patterns, deps, config/tests)
368
+
369
+ ### Phase 3: Synthesis, Assessment & Packaging
370
+ 1. Apply relevance scoring and build dependency graph
371
+ 2. **Synthesize 5-source data** (including Track -1): Merge findings from all sources
372
+ - Priority order: User Intent > Archive > Docs > Exploration > Code > Web
373
+ - **Prioritize the context from project-tech.json** for architecture and tech stack unless code analysis reveals it's outdated
374
+ 3. **Context Priority Sorting**:
375
+ a. Combine scores from Track -1 (user intent alignment) + relevance scores + exploration critical_files
376
+ b. Classify files into priority tiers:
377
+ - **Critical** (score >= 0.85): Directly mentioned in user goal OR exploration critical_files
378
+ - **High** (0.70-0.84): Key dependencies, patterns required for goal
379
+ - **Medium** (0.50-0.69): Supporting files, indirect dependencies
380
+ - **Low** (< 0.50): Contextual awareness only
381
+ c. Generate dependency_order: Based on dependency graph + user goal sequence
382
+ d. Document sorting_rationale: Explain prioritization logic
383
+ 4. **Populate project_context**: Directly use the overview from project-tech.json
384
+ 5. **Populate project_guidelines**: Load from specs/*.md
385
+ 6. Integrate brainstorm artifacts (if .brainstorming/ exists, read content)
386
+ 7. Perform conflict detection with risk assessment
387
+ 8. **Inject historical conflicts** from archive analysis into conflict_detection
388
+ 9. **Generate prioritized_context section**:
389
+ {
390
+ "prioritized_context": {
391
+ "user_intent": { "goal": "...", "scope": "...", "key_constraints": ["..."] },
392
+ "priority_tiers": {
393
+ "critical": [{ "path": "...", "relevance": 0.95, "rationale": "..." }],
394
+ "high": [...], "medium": [...], "low": [...]
395
+ },
396
+ "dependency_order": ["module1", "module2", "module3"],
397
+ "sorting_rationale": "Based on user goal alignment, exploration critical files, and dependency graph"
398
+ }
399
+ }
400
+ 10. Generate and validate context-package.json with prioritized_context field
401
+
402
+ ## Output Requirements
403
+ Complete context-package.json with:
404
+ - **metadata**: task_description, keywords, complexity, tech_stack, session_id
405
+ - **project_context**: description, technology_stack, architecture, key_components (from project-tech.json)
406
+ - **project_guidelines**: {conventions, constraints, quality_rules, learnings} (from specs/*.md)
407
+ - **assets**: {documentation[], source_code[], config[], tests[]} with relevance scores
408
+ - **dependencies**: {internal[], external[]} with dependency graph
409
+ - **brainstorm_artifacts**: {guidance_specification, role_analyses[], synthesis_output} with content
410
+ - **conflict_detection**: {risk_level, risk_factors, affected_modules[], mitigation_strategy, historical_conflicts[]}
411
+ - **exploration_results**: {manifest_path, exploration_count, angles, explorations[], aggregated_insights}
412
+ - **prioritized_context**: {user_intent, priority_tiers{critical, high, medium, low}, dependency_order[], sorting_rationale}
413
+
414
+ ## Quality Validation
415
+ Before completion verify:
416
+ - [ ] Valid JSON format with all required fields
417
+ - [ ] File relevance accuracy >80%
418
+ - [ ] Dependency graph complete (max 2 transitive levels)
419
+ - [ ] Conflict risk level calculated correctly
420
+ - [ ] No sensitive data exposed
421
+ - [ ] Total files <= 50 (prioritize high-relevance)
422
+
423
+ Execute autonomously following agent documentation.
424
+ Report completion with statistics.
425
+ `
426
+ )
427
+ ```
428
+
429
+ #### Step B.4: Output Verification
430
+
431
+ After agent completes, verify output:
432
+
433
+ ```javascript
434
+ // Verify file was created
435
+ const outputPath = `.workflow/${session_id}/.process/context-package.json`;
436
+ if (!file_exists(outputPath)) {
437
+ throw new Error("Agent failed to generate context-package.json");
438
+ }
439
+
440
+ // Verify exploration_results included
441
+ const pkg = JSON.parse(Read(outputPath));
442
+ if (pkg.exploration_results?.exploration_count > 0) {
443
+ console.log(`Exploration results aggregated: ${pkg.exploration_results.exploration_count} angles`);
444
+ }
445
+ ```
446
+
447
+ ---
448
+
449
+ **Input**: `testSessionId` from Phase 1
450
+
451
+ **Parse Output**:
452
+ - Extract: context package path (store as `contextPath`)
453
+ - Pattern: `.workflow/active/[testSessionId]/.process/[test-]context-package.json`
454
+
455
+ **Validation**:
456
+ - Context package file exists and is valid JSON
457
+ - Contains coverage analysis (session mode) or codebase analysis (prompt mode)
458
+ - Test framework detected
459
+
460
+ **TodoWrite Update (tasks attached)**:
461
+ ```json
462
+ [
463
+ {"content": "Phase 1: Test Generation", "status": "in_progress"},
464
+ {"content": " -> Create test session", "status": "completed"},
465
+ {"content": " -> Gather test context", "status": "in_progress"},
466
+ {"content": " -> Load source/codebase context", "status": "in_progress"},
467
+ {"content": " -> Analyze test coverage", "status": "pending"},
468
+ {"content": " -> Generate context package", "status": "pending"},
469
+ {"content": " -> Test analysis (Gemini)", "status": "pending"},
470
+ {"content": " -> Generate test tasks", "status": "pending"},
471
+ {"content": "Phase 2: Test Cycle Execution", "status": "pending"}
472
+ ]
473
+ ```
474
+
475
+ **TodoWrite Update (tasks collapsed)**:
476
+ ```json
477
+ [
478
+ {"content": "Phase 1: Test Generation", "status": "in_progress"},
479
+ {"content": " -> Create test session", "status": "completed"},
480
+ {"content": " -> Gather test context", "status": "completed"},
481
+ {"content": " -> Test analysis (Gemini)", "status": "pending"},
482
+ {"content": " -> Generate test tasks", "status": "pending"},
483
+ {"content": "Phase 2: Test Cycle Execution", "status": "pending"}
484
+ ]
485
+ ```
486
+
487
+ ## Output
488
+
489
+ - **Variable**: `contextPath` (context-package.json path)
490
+
491
+ ## Next Phase
492
+
493
+ Continue to [Phase 3: Test Concept Enhanced](03-test-concept-enhanced.md).