agile-context-engineering 0.1.0 → 0.2.1

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 (84) hide show
  1. package/LICENSE +30 -0
  2. package/README.md +272 -78
  3. package/agents/ace-code-discovery-analyst.md +245 -0
  4. package/agents/ace-code-integration-analyst.md +248 -0
  5. package/agents/ace-code-reviewer.md +375 -0
  6. package/agents/ace-product-owner.md +361 -0
  7. package/agents/ace-project-researcher.md +606 -0
  8. package/agents/ace-research-synthesizer.md +228 -0
  9. package/agents/ace-technical-application-architect.md +287 -0
  10. package/agents/ace-wiki-mapper.md +334 -0
  11. package/agile-context-engineering/src/ace-tools.js +2881 -0
  12. package/agile-context-engineering/src/ace-tools.test.js +1089 -0
  13. package/agile-context-engineering/templates/_command.md +54 -0
  14. package/agile-context-engineering/templates/_workflow.xml +17 -0
  15. package/agile-context-engineering/templates/config.json +0 -0
  16. package/agile-context-engineering/templates/product/external-solution.xml +832 -0
  17. package/agile-context-engineering/templates/product/feature.xml +361 -0
  18. package/agile-context-engineering/templates/product/integration-solution.xml +0 -0
  19. package/agile-context-engineering/templates/product/product-backlog.xml +231 -0
  20. package/agile-context-engineering/templates/product/product-vision.xml +227 -0
  21. package/agile-context-engineering/templates/product/story-integration-solution.xml +1014 -0
  22. package/agile-context-engineering/templates/product/story-technical-solution.xml +1025 -0
  23. package/agile-context-engineering/templates/product/story-wiki.xml +190 -0
  24. package/agile-context-engineering/templates/product/story.xml +451 -0
  25. package/agile-context-engineering/templates/wiki/coding-standards.xml +493 -0
  26. package/agile-context-engineering/templates/wiki/decizions.xml +115 -0
  27. package/agile-context-engineering/templates/wiki/guide.xml +137 -0
  28. package/agile-context-engineering/templates/wiki/module-discovery.xml +174 -0
  29. package/agile-context-engineering/templates/wiki/pattern.xml +159 -0
  30. package/agile-context-engineering/templates/wiki/subsystem-architecture.xml +343 -0
  31. package/agile-context-engineering/templates/wiki/subsystem-structure.xml +235 -0
  32. package/agile-context-engineering/templates/wiki/system-architecture.xml +254 -0
  33. package/agile-context-engineering/templates/wiki/system-cross-cutting.xml +197 -0
  34. package/agile-context-engineering/templates/wiki/system-structure.xml +178 -0
  35. package/agile-context-engineering/templates/wiki/system.xml +381 -0
  36. package/agile-context-engineering/templates/wiki/tech-debt-index.xml +125 -0
  37. package/agile-context-engineering/templates/wiki/testing-framework.xml +283 -0
  38. package/agile-context-engineering/templates/wiki/wiki-readme.xml +276 -0
  39. package/agile-context-engineering/utils/questioning.xml +111 -0
  40. package/agile-context-engineering/utils/ui-formatting.md +300 -0
  41. package/agile-context-engineering/workflows/execute-story.xml +1145 -0
  42. package/agile-context-engineering/workflows/help.xml +540 -0
  43. package/agile-context-engineering/workflows/init-coding-standards.xml +386 -0
  44. package/agile-context-engineering/workflows/map-story.xml +797 -0
  45. package/agile-context-engineering/workflows/map-subsystem.xml +1177 -0
  46. package/agile-context-engineering/workflows/map-system.xml +672 -0
  47. package/agile-context-engineering/workflows/plan-backlog.xml +1356 -0
  48. package/agile-context-engineering/workflows/plan-feature.xml +1495 -0
  49. package/agile-context-engineering/workflows/plan-product-vision.xml +342 -0
  50. package/agile-context-engineering/workflows/plan-story.xml +909 -0
  51. package/agile-context-engineering/workflows/research-external-solution.xml +659 -0
  52. package/agile-context-engineering/workflows/research-integration-solution.xml +712 -0
  53. package/agile-context-engineering/workflows/research-story-wiki.xml +474 -0
  54. package/agile-context-engineering/workflows/research-technical-solution.xml +762 -0
  55. package/agile-context-engineering/workflows/review-story.xml +281 -0
  56. package/bin/install.js +102 -166
  57. package/commands/ace/execute-story.md +137 -0
  58. package/commands/ace/help.md +93 -0
  59. package/commands/ace/init-coding-standards.md +83 -0
  60. package/commands/ace/map-story.md +156 -0
  61. package/commands/ace/map-subsystem.md +138 -0
  62. package/commands/ace/map-system.md +92 -0
  63. package/commands/ace/plan-backlog.md +83 -0
  64. package/commands/ace/plan-feature.md +89 -0
  65. package/commands/ace/plan-product-vision.md +81 -0
  66. package/commands/ace/plan-story.md +145 -0
  67. package/commands/ace/research-external-solution.md +138 -0
  68. package/commands/ace/research-integration-solution.md +135 -0
  69. package/commands/ace/research-story-wiki.md +116 -0
  70. package/commands/ace/research-technical-solution.md +147 -0
  71. package/commands/ace/review-story.md +109 -0
  72. package/package.json +5 -8
  73. package/agents/executor.md +0 -88
  74. package/agents/planner.md +0 -78
  75. package/agents/researcher.md +0 -77
  76. package/agents/verifier.md +0 -116
  77. package/commands/ace-execute-story.md +0 -114
  78. package/commands/ace-init.md +0 -254
  79. package/commands/ace-plan-epic.md +0 -79
  80. package/commands/ace-plan-feature.md +0 -78
  81. package/commands/ace-plan-project.md +0 -205
  82. package/commands/ace-plan-story.md +0 -97
  83. package/commands/ace-refine-story.md +0 -90
  84. package/commands/ace-verify-story.md +0 -127
@@ -0,0 +1,659 @@
1
+ <workflow>
2
+
3
+ <purpose>
4
+ Perform COMPREHENSIVE, IN-DEPTH, CODE-LEVEL analysis of how a specific story
5
+ is implemented in an external reference system. Load the story requirements, validate
6
+ the external codebase, optionally load external documentation, then execute exhaustive
7
+ code analysis following the template's analysis-process phases. Write the analysis to
8
+ external-analysis.md in the story's artifact directory.
9
+
10
+ Produces `.ace/artifacts/product/<id-epic_name>/<id-feature_name>/<id-story_name>/external-analysis.md`
11
+ — a comprehensive code-level analysis with algorithms, patterns, formulas, and
12
+ implementation details extracted verbatim from the external system's code.
13
+
14
+ This is pass 3 of the story specification pipeline (see story.xml composition).
15
+ All output is written ONLY to the analysis file — no GitHub updates, no modifications
16
+ to the story file.
17
+
18
+ This workflow is executed by the `ace-code-discovery-analyst` agent
19
+ (spawned via `subagent_type="ace-code-discovery-analyst"`).
20
+ </purpose>
21
+
22
+ <mandatory-context>
23
+ Read all files referenced by the invoking command's execution-context before starting.
24
+ Also read any document or text passed as parameter ($ARGUMENTS) in the invoking command.
25
+ </mandatory-context>
26
+
27
+ <process>
28
+
29
+ <!-- ══════════════════════════════════════════════════════════════════ -->
30
+ <!-- STEP 1: SETUP -->
31
+ <!-- ══════════════════════════════════════════════════════════════════ -->
32
+
33
+ <step name="setup" order="1">
34
+ **MANDATORY FIRST STEP — Execute environment detection and story initialization:**
35
+
36
+ ```bash
37
+ INIT=$(node ~/.claude/agile-context-engineering/src/ace-tools.js init research-story {story_param})
38
+ ```
39
+
40
+ This single call validates the story parameter, extracts metadata/requirements/wiki
41
+ references, computes all paths and slugs, and checks artifact existence.
42
+
43
+ Parse INIT JSON for:
44
+ - **Environment**: `has_git`, `has_gh_cli`, `github_project`, `analyst_model`
45
+ - **Story validation**: `story_valid`, `story_error`, `story_source`
46
+ - **Story metadata**: `story` (id, title, status, size), `feature` (id, title), `epic` (id, title)
47
+ - **Requirements**: `user_story`, `description`, `acceptance_criteria_count`
48
+ - **Paths**: `paths.*` (story_dir, story_file, external_analysis_file, feature_dir, feature_file, etc.)
49
+ - **Artifacts**: `has_external_analysis`, `has_integration_analysis`, `has_feature_file`
50
+
51
+ Display stage banner:
52
+
53
+ ```
54
+ ╔══════════════════════════════════════════════════╗
55
+ ║ ACE > Research External Solution ║
56
+ ╚══════════════════════════════════════════════════╝
57
+ ```
58
+
59
+ **If `has_git` is false:** Initialize git:
60
+ ```bash
61
+ git init
62
+ ```
63
+
64
+ **If `INIT.story_valid` is false:**
65
+ Display error using `INIT.story_error` and exit.
66
+ </step>
67
+
68
+ <!-- ══════════════════════════════════════════════════════════════════ -->
69
+ <!-- STEP 2: VALIDATE & LOAD STORY -->
70
+ <!-- ══════════════════════════════════════════════════════════════════ -->
71
+
72
+ <step name="validate-story" order="2">
73
+
74
+ **Story validation, parsing, and path computation were completed by
75
+ `init research-story` in step 1.** All metadata, requirements, and
76
+ paths are available in the INIT JSON.
77
+
78
+ Read the story file content for analysis context:
79
+
80
+ **If `INIT.story_source` is `file`:**
81
+ Read the file at `INIT.paths.story_file`. Store as STORY_CONTENT.
82
+
83
+ **If `INIT.story_source` is `github-url` or `issue-number`:**
84
+ Fetch the issue body using INIT's GitHub project context:
85
+ ```bash
86
+ GH_STORY=$(gh issue view {issue_number} --repo {INIT.github_project.owner}/{INIT.github_project.repo} --json body -q .body)
87
+ ```
88
+ Store as STORY_CONTENT.
89
+
90
+ The story's User Story, Description, and Acceptance Criteria define
91
+ WHAT functionality to analyze in the external codebase. These are the
92
+ requirements — do NOT seek requirements from other sources.
93
+ Wiki references from `INIT.wiki_references` may inform exploration.
94
+
95
+ <!-- ── 2b: Read parent feature document ───────────────────────── -->
96
+
97
+ **If `INIT.has_feature_file` is true:**
98
+ Read the feature document at `INIT.paths.feature_file` and extract:
99
+ - Feature description and scope
100
+ - List of all stories in the feature (IDs, titles, descriptions)
101
+ - Dependencies between stories
102
+ - Shared components or services mentioned
103
+ This informs the "Story Integration Within Feature" section.
104
+
105
+ **If `INIT.has_feature_file` is false:**
106
+ Proceed without — the analysis can still be done without feature context.
107
+
108
+ <!-- ── 2c: Display ───────────────────────────────────────────────── -->
109
+
110
+ Set pre-computed paths from INIT:
111
+ - `STORY_FILE = INIT.paths.story_file`
112
+ - `STORY_DIR = INIT.paths.story_dir`
113
+
114
+ Display:
115
+ ```
116
+ i Story loaded: {INIT.story.id} — {INIT.story.title}
117
+ Feature: {INIT.feature.id} — {INIT.feature.title}
118
+ Epic: {INIT.epic.id} — {INIT.epic.title}
119
+ Requirements: {INIT.acceptance_criteria_count} acceptance criteria scenarios
120
+ ```
121
+ </step>
122
+
123
+ <!-- ══════════════════════════════════════════════════════════════════ -->
124
+ <!-- STEP 3: VALIDATE EXTERNAL CODEBASE -->
125
+ <!-- ══════════════════════════════════════════════════════════════════ -->
126
+
127
+ <step name="validate-external-codebase" order="3">
128
+
129
+ Parse the `external-codebase` parameter from $ARGUMENTS.
130
+
131
+ <!-- ── 3a: Local path ────────────────────────────────────────────── -->
132
+
133
+ **If local path:**
134
+
135
+ Confirm folder exists and contains source code:
136
+ ```bash
137
+ ls {external_codebase_path}/
138
+ ```
139
+
140
+ **If not valid:** Display error and exit:
141
+ ```
142
+ x External codebase not found: {external_codebase_path}
143
+ Provide a valid local path to a source code directory
144
+ or a GitHub repository URL.
145
+ ```
146
+
147
+ Set `EXTERNAL_CODEBASE_PATH = {external_codebase_path}`
148
+
149
+ <!-- ── 3b: GitHub URL ────────────────────────────────────────────── -->
150
+
151
+ **If GitHub URL:**
152
+
153
+ Verify repository accessibility:
154
+ ```bash
155
+ gh repo view {repo_identifier} --json name,url 2>/dev/null
156
+ ```
157
+
158
+ **If not accessible:** Display error and exit:
159
+ ```
160
+ x External repository not accessible: {repo_url}
161
+ Verify the URL is correct and the repository is public
162
+ or you have access.
163
+ ```
164
+
165
+ Set `EXTERNAL_CODEBASE_PATH = {resolved path or URL}`
166
+
167
+ <!-- ── 3c: Display ───────────────────────────────────────────────── -->
168
+
169
+ Display:
170
+ ```
171
+ i External codebase: {EXTERNAL_CODEBASE_PATH}
172
+ ```
173
+ </step>
174
+
175
+ <!-- ══════════════════════════════════════════════════════════════════ -->
176
+ <!-- STEP 4: LOAD EXTERNAL DOCS (OPTIONAL) -->
177
+ <!-- ══════════════════════════════════════════════════════════════════ -->
178
+
179
+ <step name="load-external-docs" order="4">
180
+
181
+ Parse the `external-docs` parameter from $ARGUMENTS.
182
+
183
+ <!-- ── 4a: Not provided ──────────────────────────────────────────── -->
184
+
185
+ **If not provided:**
186
+
187
+ Check if context7 MCP server is available (check if `mcp__context7__resolve-library-id`
188
+ or similar context7 tools are available in the current tool set).
189
+
190
+ **If context7 available:**
191
+ Set `USE_CONTEXT7 = true`
192
+ Display:
193
+ ```
194
+ i No external docs provided.
195
+ context7 MCP server detected — will use it for library documentation.
196
+ ```
197
+
198
+ **If context7 not available:**
199
+ Set `USE_CONTEXT7 = false`
200
+ Display:
201
+ ```
202
+ i No external docs provided. Analysis will rely on code exploration.
203
+ TIP: Provide external-docs= for richer analysis,
204
+ or install context7 MCP server for automatic library docs.
205
+ ```
206
+
207
+ <!-- ── 4b: Provided as weblink ───────────────────────────────────── -->
208
+
209
+ **If provided as weblink:**
210
+
211
+ Verify URL accessibility (attempt a fetch or HEAD request).
212
+
213
+ **If not accessible:** Display warning (non-fatal):
214
+ ```
215
+ ! External docs URL not accessible: {url}
216
+ Continuing without external docs.
217
+ ```
218
+
219
+ **If accessible:**
220
+ Store as `EXTERNAL_DOCS_URL = {url}`
221
+ Display:
222
+ ```
223
+ i External docs: {url}
224
+ ```
225
+
226
+ <!-- ── 4c: Provided as filepath ──────────────────────────────────── -->
227
+
228
+ **If provided as filepath:**
229
+
230
+ Verify file exists:
231
+ ```bash
232
+ DOCS_EXISTS=$(node ~/.claude/agile-context-engineering/src/ace-tools.js verify-path-exists {filepath} --raw)
233
+ ```
234
+
235
+ **If not exists:** Display warning (non-fatal):
236
+ ```
237
+ ! External docs file not found: {filepath}
238
+ Continuing without external docs.
239
+ ```
240
+
241
+ **If exists:** Read the file. Store as `EXTERNAL_DOCS_CONTENT`.
242
+ Display:
243
+ ```
244
+ i External docs: {filepath}
245
+ ```
246
+ </step>
247
+
248
+ <!-- ══════════════════════════════════════════════════════════════════ -->
249
+ <!-- STEP 5: RESOLVE OUTPUT PATH -->
250
+ <!-- ══════════════════════════════════════════════════════════════════ -->
251
+
252
+ <step name="resolve-output-path" order="5">
253
+
254
+ **Paths were pre-computed by `init research-story` in step 1.**
255
+
256
+ Set from INIT JSON:
257
+ - `STORY_DIR = INIT.paths.story_dir`
258
+ - `OUTPUT_FILE = INIT.paths.external_analysis_file`
259
+
260
+ Ensure directory exists:
261
+ ```bash
262
+ mkdir -p {STORY_DIR}
263
+ ```
264
+
265
+ Display:
266
+ ```
267
+ i Output: {OUTPUT_FILE}
268
+ ```
269
+ </step>
270
+
271
+ <!-- ══════════════════════════════════════════════════════════════════ -->
272
+ <!-- STEP 6: CHECK EXISTING ANALYSIS -->
273
+ <!-- ══════════════════════════════════════════════════════════════════ -->
274
+
275
+ <step name="check-existing" order="6">
276
+
277
+ **If `INIT.has_external_analysis` is true:**
278
+
279
+ Use AskUserQuestion:
280
+ - header: "Existing"
281
+ - question: "An external analysis already exists at `{OUTPUT_FILE}`. What would you like to do?"
282
+ - options:
283
+ - "Overwrite" — Discard and create a new analysis from scratch
284
+ - "Skip" — Keep the current analysis as-is
285
+
286
+ **If "Overwrite":** Continue to step 7.
287
+ **If "Skip":** Display message and exit workflow:
288
+ ```
289
+ i Keeping existing analysis. No changes made.
290
+ ```
291
+
292
+ **If not exists:** Continue to step 7.
293
+ </step>
294
+
295
+ <!-- ══════════════════════════════════════════════════════════════════ -->
296
+ <!-- STEP 7: EXECUTE ANALYSIS -->
297
+ <!-- ══════════════════════════════════════════════════════════════════ -->
298
+
299
+ <step name="execute-analysis" order="7">
300
+
301
+ Display:
302
+ ```
303
+ ┌──────────────────────────────────────────────────┐
304
+ │ ACE > Research External Solution > Analysis │
305
+ └──────────────────────────────────────────────────┘
306
+
307
+ i Starting deep code-level analysis.
308
+ Reading 30+ files and tracing execution paths
309
+ 5+ levels deep. This may take several minutes.
310
+ ```
311
+
312
+ **Execute the complete analysis following the template's `<analysis-process>` section.**
313
+ The template (`external-solution.xml`) defines 3 mandatory phases with 16 total items.
314
+ You ARE the code-discovery-analyst — perform the analysis directly.
315
+
316
+ <!-- ── 7a: Phase 1 — Initial Discovery (3 mandatory items) ───────── -->
317
+
318
+ **Phase 1: Initial Discovery**
319
+
320
+ 1. **[MANDATORY] Understand the story requirements:**
321
+ - Re-read STORY_CONTENT thoroughly — User Story, Description, all AC scenarios
322
+ - These define WHAT functionality to analyze in the external codebase
323
+ - Extract the key behaviors, algorithms, and patterns to look for
324
+ - If parent feature document was loaded (step 2c), understand:
325
+ - The broader feature context
326
+ - What other stories exist and how they relate
327
+ - Dependencies and shared components between stories
328
+
329
+ 2. **[MANDATORY] Explore available documentation:**
330
+ - **external-docs** (if EXTERNAL_DOCS_URL or EXTERNAL_DOCS_CONTENT set):
331
+ Review for implementation context, API documentation, architecture overview.
332
+ If URL: use WebFetch to retrieve content.
333
+ Use documentation to guide code exploration.
334
+ - **context7 MCP server** (if USE_CONTEXT7 is true — PREFERRED):
335
+ Use `mcp__context7__resolve-library-id` to find the library,
336
+ then `mcp__context7__get-library-docs` to fetch relevant docs.
337
+ **ALWAYS prefer context7** when the external system is a known library/framework.
338
+ - If neither available: rely entirely on code exploration.
339
+
340
+ 3. **[MANDATORY] Locate the implementation:**
341
+ - Find where the story's functionality is implemented in `EXTERNAL_CODEBASE_PATH`
342
+ - Start with likely entry points: exports, public APIs, event handlers
343
+ - Use Grep/Glob to find relevant files by keywords from the story
344
+ - Read README files and documentation in the external codebase for structural guidance
345
+ - Build an initial map of involved files before deep diving
346
+
347
+ <!-- ── 7b: Phase 2 — Deep Implementation Analysis (9 mandatory items) ── -->
348
+
349
+ **Phase 2: Deep Implementation Analysis — ALL 9 items MANDATORY, skip NONE:**
350
+
351
+ 1. **[MANDATORY] Complete Entry Points & Triggers Identification (CRITICAL):**
352
+ Document ALL entry points into the story functionality:
353
+ - **User Action Triggers**: button clicks, form submissions, keyboard shortcuts
354
+ - **API Entry Points**: REST endpoints, GraphQL mutations, RPC calls
355
+ - **Event-Based Triggers**: WebSocket messages, system events, pub/sub messages
356
+ - **Scheduled/Automated Triggers**: cron jobs, timers, intervals
357
+ - **External System Triggers**: webhooks, callbacks, integrations
358
+ For EACH entry point document:
359
+ ```typescript
360
+ // Entry Point Type: [User Action/API/Event/etc.]
361
+ // File: src/path/file.ts:45-60
362
+ // Trigger: [Exact trigger description]
363
+ // Parameters: [List all parameters with types]
364
+ // Example usage: [Show actual usage example]
365
+ ```
366
+
367
+ 2. **[MANDATORY] Complete Code Path Mapping:**
368
+ - Follow EVERY code path from entry to completion
369
+ - Include ALL branches, conditionals, and edge cases
370
+ - Document every file, class, method, and function involved
371
+ - Track all data transformations and state changes
372
+ - Minimum call depth: 5+ levels
373
+
374
+ 3. **[MANDATORY] Story-Specific File Tree:**
375
+ - Document ONLY files involved in this story (NOT entire codebase)
376
+ - Categorize as: CORE, SUPPORT, CONFIG, TEST
377
+ - Include line counts and one-line purpose for each file
378
+ - Include total file count and line count at bottom
379
+
380
+ 4. **[MANDATORY] Constants & Configuration Extraction:**
381
+ - Extract ALL constants and configuration values used by the story
382
+ - Include ACTUAL values from code, NOT placeholders
383
+ - Group by category: performance limits, business thresholds, magic numbers
384
+ - Always include source file path and line numbers
385
+
386
+ 5. **[MANDATORY] Algorithm & Formula Documentation:**
387
+ For each calculation or algorithm found:
388
+ - **Purpose**: What it calculates/achieves
389
+ - **Formula**: Exact mathematical formula or logic
390
+ - **Implementation**: Code snippet showing implementation
391
+ - **Example**: Sample input/output with explanation
392
+ - **Edge Cases**: How they handle special cases
393
+
394
+ 6. **[MANDATORY] Comprehensive Flow Diagram:**
395
+ Create a detailed Mermaid sequence diagram showing:
396
+ - Complete execution flow with ALL branches
397
+ - Actual method names and parameters (NOT generic names)
398
+ - Data flow between components
399
+ - State changes and side effects
400
+ - Error handling paths
401
+
402
+ 7. **[MANDATORY] Test Patterns Extraction:**
403
+ - Extract actual test cases from the external system
404
+ - Include test code snippets with assertions
405
+ - Document test scenarios covered
406
+ - Note edge cases tested
407
+ - Extract test data patterns
408
+ - Identify mocking strategies used
409
+
410
+ 8. **[MANDATORY] Performance Considerations:**
411
+ - Caching strategies used
412
+ - Algorithm optimizations
413
+ - Throttling/debouncing patterns
414
+ - Memory management techniques
415
+ - Batch processing approaches
416
+ Include code references for each optimization.
417
+
418
+ 9. **[MANDATORY] Validation & Security:**
419
+ - Input validation rules with actual validation code
420
+ - Data sanitization methods
421
+ - Security checks implemented
422
+ - Error boundaries
423
+ Include actual code snippets showing validation logic.
424
+
425
+ <!-- ── 7c: Phase 3 — Pattern & Architecture Analysis (4 mandatory items) ── -->
426
+
427
+ **Phase 3: Pattern & Architecture Analysis — ALL 4 items MANDATORY:**
428
+
429
+ 1. **[MANDATORY] Design Patterns Identified:**
430
+ - Document all design patterns used (Strategy, Observer, Factory, etc.)
431
+ - Explain WHY they chose each pattern
432
+ - Include code examples of pattern implementation
433
+ - Note patterns shared with other parts of the system
434
+ - Identify if patterns enable component integration/communication
435
+
436
+ 2. **[MANDATORY] Component Lifecycle:**
437
+ - Initialization sequence
438
+ - State management approach
439
+ - Cleanup/disposal mechanisms
440
+ - Memory management considerations
441
+
442
+ 3. **[MANDATORY] Performance Optimizations:**
443
+ - Caching strategies
444
+ - Algorithm optimizations
445
+ - Rendering optimizations (if applicable)
446
+ - Data structure choices for performance
447
+
448
+ 4. **[MANDATORY] Error Handling & Edge Cases:**
449
+ - How they handle errors at each architectural level
450
+ - Validation approaches
451
+ - Fallback mechanisms
452
+ - Boundary conditions
453
+
454
+ **CRITICAL REQUIREMENTS:**
455
+ - **NO ASSUMPTIONS**: Only document what you actually find in the code
456
+ - **STORY SCOPE ONLY**: Focus exclusively on code paths related to the story
457
+ - **COMPLETE COVERAGE**: Every file and method involved must be documented
458
+ - **EXACT IMPLEMENTATIONS**: Include actual code snippets, not descriptions
459
+ - **FORMULAS & CALCULATIONS**: Extract and explain ALL mathematical operations
460
+ - **METRICS**: Minimum 30+ files read, 50+ code references, 5+ call depth
461
+ </step>
462
+
463
+ <!-- ══════════════════════════════════════════════════════════════════ -->
464
+ <!-- STEP 8: WRITE OUTPUT -->
465
+ <!-- ══════════════════════════════════════════════════════════════════ -->
466
+
467
+ <step name="write-output" order="8">
468
+
469
+ Write the complete analysis to `{OUTPUT_FILE}` following the template's
470
+ `<output-format>` section exactly. Include ALL sections:
471
+
472
+ 1. Header (repository, version, story, date, metrics)
473
+ 2. Implementation Overview
474
+ 3. Entry Points & Triggers (categorized by type)
475
+ 4. Story-Specific File Tree
476
+ 5. Constants & Configuration
477
+ 6. Core Implementation (Algorithms, Data Flow with Mermaid diagram, Key Components)
478
+ 7. Code Examples
479
+ 8. Test Patterns
480
+ 9. Validation & Security
481
+ 10. Performance Optimizations
482
+ 11. Architecture Decisions (Design Patterns, Lifecycle, Error Handling)
483
+ 12. Story Integration Within Feature
484
+ 13. Lessons for Our Implementation
485
+ 14. Complete File Reference
486
+
487
+ Use the Write tool to create the file. Include all findings from step 7.
488
+
489
+ This is NOT a summary — it is a COMPLETE CODE EXTRACTION. Every section
490
+ must contain actual code snippets, file paths with line numbers, and
491
+ concrete implementation details.
492
+
493
+ Display:
494
+ ```
495
+ + Analysis written to {OUTPUT_FILE}
496
+ ```
497
+ </step>
498
+
499
+ <!-- ══════════════════════════════════════════════════════════════════ -->
500
+ <!-- STEP 9: VALIDATION -->
501
+ <!-- ══════════════════════════════════════════════════════════════════ -->
502
+
503
+ <step name="validation" order="9">
504
+
505
+ Read the output file and verify against the validation checklist
506
+ defined in the template (external-solution.xml):
507
+
508
+ **File Creation Requirements:**
509
+ - [ ] Analysis file created at {OUTPUT_FILE}
510
+ - [ ] Story directory exists
511
+ - [ ] File contains all required sections from template
512
+
513
+ **Content Requirements — Core Analysis:**
514
+ - [ ] CRITICAL: No assumptions — analysis reflects 100% accurate code, no guessing
515
+ - [ ] Complete Entry Points & Triggers section with ALL trigger types
516
+ - [ ] Story-Specific File Tree showing ONLY files involved in story
517
+ - [ ] Constants & Configuration section with actual values
518
+ - [ ] Mermaid sequence diagram showing complete data flow
519
+ - [ ] All algorithms and formulas extracted with explanations
520
+ - [ ] Code examples included from external implementation
521
+ - [ ] Architecture patterns identified and documented
522
+
523
+ **Content Requirements — Enhanced Sections:**
524
+ - [ ] Test Patterns section with actual test code
525
+ - [ ] Validation & Security section with validation rules
526
+ - [ ] Performance Optimizations documented
527
+ - [ ] Story Integration Within Feature section completed
528
+ - [ ] Complete File Reference with file roles
529
+
530
+ **Analysis Quality Requirements:**
531
+ - [ ] All entry points categorized (User/API/Event/External)
532
+ - [ ] Complete code path mapping documented (5+ levels deep)
533
+ - [ ] Error handling approaches analyzed
534
+ - [ ] No assumptions made — only documented what was found in code
535
+ - [ ] Lessons for our implementation clearly stated
536
+
537
+ **Metrics Requirements:**
538
+ - [ ] Minimum 30+ files read for the story
539
+ - [ ] Minimum 50+ code references documented
540
+ - [ ] Minimum 5+ call depth traced
541
+ - [ ] All metrics reported in output header
542
+
543
+ **Total: 23 mandatory checklist items**
544
+
545
+ If the output is incomplete or missing sections, go back and fill in
546
+ the missing content before proceeding.
547
+
548
+ Display:
549
+ ```
550
+ {check_mark} Analysis validated. {passed}/{total} checks passed.
551
+ ```
552
+ </step>
553
+
554
+ <!-- ══════════════════════════════════════════════════════════════════ -->
555
+ <!-- STEP 10: REVIEW AND APPROVE -->
556
+ <!-- ══════════════════════════════════════════════════════════════════ -->
557
+
558
+ <step name="review" order="10">
559
+
560
+ Display a summary of the analysis:
561
+ ```
562
+ Analysis Summary:
563
+ ────────
564
+ Files analyzed: {N} | Code references: {M} | Call depth: {D}
565
+ Sections: {count}/14 | Checklist: {passed}/23
566
+ ```
567
+
568
+ Use AskUserQuestion:
569
+ - header: "Analysis"
570
+ - question: "External analysis written to `{OUTPUT_FILE}`. Review the file in your editor — does the analysis look comprehensive?"
571
+ - options:
572
+ - "Approve" — Looks good, commit it
573
+ - "Refine" — Some sections need more depth
574
+ - "Skip commit" — Keep the file but don't commit yet
575
+
576
+ **If "Approve":**
577
+ Continue to step 11.
578
+
579
+ **If "Refine":**
580
+ - Ask what sections need more depth or what's missing
581
+ - Go back to the relevant analysis phase, read more code, and update OUTPUT_FILE
582
+ - Re-run validation (step 9)
583
+ - Present for review again
584
+
585
+ **If "Skip commit":**
586
+ Display completion without commit:
587
+ ```
588
+ ╔══════════════════════════════════════════════════╗
589
+ ║ ACE > External Analysis Complete (uncommitted) ║
590
+ ║ {Story ID} "{Story Title}" ║
591
+ ╚══════════════════════════════════════════════════╝
592
+
593
+ i Analysis written to {OUTPUT_FILE}
594
+ File not committed — commit manually when ready.
595
+ ```
596
+ Exit workflow.
597
+ </step>
598
+
599
+ <!-- ══════════════════════════════════════════════════════════════════ -->
600
+ <!-- STEP 11: COMMIT -->
601
+ <!-- ══════════════════════════════════════════════════════════════════ -->
602
+
603
+ <step name="commit" order="11">
604
+
605
+ Stage and commit the analysis file:
606
+
607
+ ```bash
608
+ git add {OUTPUT_FILE}
609
+ ```
610
+
611
+ ```bash
612
+ git commit -m "docs: external analysis for {Story ID} — {Story Title}"
613
+ ```
614
+
615
+ Display completion:
616
+
617
+ ```
618
+ ╔══════════════════════════════════════════════════╗
619
+ ║ ACE > External Analysis Complete ║
620
+ ║ {Story ID} "{Story Title}" ║
621
+ ╚══════════════════════════════════════════════════╝
622
+
623
+ + {OUTPUT_FILE} committed.
624
+
625
+ Metrics:
626
+ ────────
627
+ Files analyzed: {N} | Code references: {M} | Call depth: {D}
628
+
629
+ i External analysis complete. This artifact will be consumed
630
+ by the technical solution (pass 5) when running plan-story.
631
+
632
+ Next > Continue with story refinement:
633
+ - Integration analysis (pass 4)
634
+ - Technical solution (pass 5)
635
+ > /ace:research-external-solution story=... external-codebase=...
636
+ Analyze another story's external implementation.
637
+ ```
638
+ </step>
639
+
640
+ </process>
641
+
642
+ <success_criteria>
643
+ - Story loaded and requirements extracted (User Story, Description, Acceptance Criteria)
644
+ - Parent feature document loaded for broader context (if available)
645
+ - External codebase validated and accessible (local path or GitHub URL)
646
+ - External docs loaded if provided, or context7 used if available
647
+ - Output path resolved from story context
648
+ - All 3 analysis phases executed directly (16 mandatory items completed)
649
+ - Analysis file written with ALL template sections populated
650
+ - NO assumptions made — all findings backed by actual code references
651
+ - Minimum metrics met: 30+ files read, 50+ code references, 5+ call depth
652
+ - Mermaid sequence diagram included in the analysis
653
+ - All 23 validation checklist items verified
654
+ - User reviewed and approved the analysis
655
+ - Document committed with appropriate message
656
+ - No modifications made to the story file or GitHub issues
657
+ </success_criteria>
658
+
659
+ </workflow>