agile-context-engineering 0.5.0 → 0.5.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 (102) hide show
  1. package/.claude-plugin/marketplace.json +18 -0
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +7 -1
  4. package/README.md +16 -12
  5. package/agents/ace-code-discovery-analyst.md +245 -245
  6. package/agents/ace-code-integration-analyst.md +248 -248
  7. package/agents/ace-code-reviewer.md +375 -375
  8. package/agents/ace-product-owner.md +365 -361
  9. package/agents/ace-project-researcher.md +606 -606
  10. package/agents/ace-technical-application-architect.md +315 -315
  11. package/bin/install.js +587 -173
  12. package/hooks/ace-check-update.js +15 -14
  13. package/hooks/ace-statusline.js +30 -12
  14. package/hooks/hooks.json +14 -0
  15. package/package.json +3 -2
  16. package/shared/lib/ace-core.js +53 -0
  17. package/shared/lib/ace-core.test.js +308 -308
  18. package/shared/lib/ace-story.test.js +250 -250
  19. package/skills/execute-story/SKILL.md +116 -110
  20. package/skills/execute-story/script.js +13 -27
  21. package/skills/execute-story/script.test.js +261 -261
  22. package/skills/execute-story/story-template.xml +451 -451
  23. package/skills/execute-story/workflow.xml +3 -1
  24. package/skills/help/SKILL.md +71 -69
  25. package/skills/help/script.js +32 -35
  26. package/skills/help/script.test.js +183 -183
  27. package/skills/help/workflow.xml +14 -3
  28. package/skills/init-coding-standards/SKILL.md +91 -72
  29. package/skills/init-coding-standards/coding-standards-template.xml +531 -531
  30. package/skills/init-coding-standards/script.js +50 -59
  31. package/skills/init-coding-standards/script.test.js +70 -70
  32. package/skills/init-coding-standards/workflow.xml +1 -1
  33. package/skills/map-cross-cutting/SKILL.md +126 -89
  34. package/skills/map-cross-cutting/workflow.xml +1 -1
  35. package/skills/map-guide/SKILL.md +126 -89
  36. package/skills/map-guide/workflow.xml +1 -1
  37. package/skills/map-pattern/SKILL.md +125 -89
  38. package/skills/map-pattern/workflow.xml +1 -1
  39. package/skills/map-story/SKILL.md +180 -127
  40. package/skills/map-story/templates/tech-debt-index.xml +125 -125
  41. package/skills/map-story/workflow.xml +2 -2
  42. package/skills/map-subsystem/SKILL.md +155 -111
  43. package/skills/map-subsystem/script.js +51 -60
  44. package/skills/map-subsystem/script.test.js +68 -68
  45. package/skills/map-subsystem/templates/subsystem-architecture.xml +343 -343
  46. package/skills/map-subsystem/templates/subsystem-structure.xml +234 -234
  47. package/skills/map-subsystem/workflow.xml +1173 -1173
  48. package/skills/map-sys-doc/SKILL.md +125 -90
  49. package/skills/map-sys-doc/workflow.xml +1 -1
  50. package/skills/map-system/SKILL.md +103 -85
  51. package/skills/map-system/script.js +75 -84
  52. package/skills/map-system/script.test.js +73 -73
  53. package/skills/map-system/templates/system-structure.xml +177 -177
  54. package/skills/map-system/templates/testing-framework.xml +283 -283
  55. package/skills/map-system/workflow.xml +667 -667
  56. package/skills/map-walkthrough/SKILL.md +140 -92
  57. package/skills/map-walkthrough/workflow.xml +457 -457
  58. package/skills/plan-backlog/SKILL.md +93 -75
  59. package/skills/plan-backlog/script.js +121 -136
  60. package/skills/plan-backlog/script.test.js +83 -83
  61. package/skills/plan-backlog/workflow.xml +1348 -1348
  62. package/skills/plan-feature/SKILL.md +99 -76
  63. package/skills/plan-feature/feature-template.xml +361 -361
  64. package/skills/plan-feature/script.js +131 -148
  65. package/skills/plan-feature/script.test.js +80 -80
  66. package/skills/plan-feature/workflow.xml +1 -1
  67. package/skills/plan-product-vision/SKILL.md +91 -75
  68. package/skills/plan-product-vision/product-vision-template.xml +227 -227
  69. package/skills/plan-product-vision/script.js +51 -60
  70. package/skills/plan-product-vision/script.test.js +69 -69
  71. package/skills/plan-product-vision/workflow.xml +337 -337
  72. package/skills/plan-story/SKILL.md +125 -102
  73. package/skills/plan-story/script.js +18 -49
  74. package/skills/plan-story/story-template.xml +8 -1
  75. package/skills/plan-story/workflow.xml +17 -1
  76. package/skills/research-external-solution/SKILL.md +120 -107
  77. package/skills/research-external-solution/external-solution-template.xml +832 -832
  78. package/skills/research-external-solution/script.js +229 -238
  79. package/skills/research-external-solution/script.test.js +134 -134
  80. package/skills/research-external-solution/workflow.xml +657 -657
  81. package/skills/research-integration-solution/SKILL.md +121 -98
  82. package/skills/research-integration-solution/integration-solution-template.xml +1015 -1015
  83. package/skills/research-integration-solution/script.js +223 -231
  84. package/skills/research-integration-solution/script.test.js +134 -134
  85. package/skills/research-integration-solution/workflow.xml +711 -711
  86. package/skills/research-story-wiki/SKILL.md +101 -92
  87. package/skills/research-story-wiki/script.js +223 -231
  88. package/skills/research-story-wiki/script.test.js +138 -138
  89. package/skills/research-story-wiki/story-wiki-template.xml +194 -194
  90. package/skills/research-story-wiki/workflow.xml +473 -473
  91. package/skills/research-technical-solution/SKILL.md +131 -103
  92. package/skills/research-technical-solution/script.js +223 -231
  93. package/skills/research-technical-solution/script.test.js +134 -134
  94. package/skills/research-technical-solution/technical-solution-template.xml +1025 -1025
  95. package/skills/research-technical-solution/workflow.xml +761 -761
  96. package/skills/review-story/SKILL.md +99 -100
  97. package/skills/review-story/script.js +8 -16
  98. package/skills/review-story/script.test.js +169 -169
  99. package/skills/review-story/story-template.xml +451 -451
  100. package/skills/review-story/workflow.xml +1 -1
  101. package/skills/update/SKILL.md +65 -53
  102. package/skills/update/workflow.xml +21 -5
@@ -1,711 +1,711 @@
1
- <workflow>
2
-
3
- <purpose>
4
- Perform COMPREHENSIVE, IN-DEPTH System Integration Analysis of how a specific story
5
- should integrate into the existing codebase. Load the story requirements and wiki
6
- references, validate inputs, load wiki documents and optional external analysis,
7
- then execute exhaustive codebase analysis following the template's analysis-process
8
- phases. Write the analysis to integration-analysis.md in the story's artifact directory.
9
-
10
- Produces `.ace/artifacts/product/<id-epic_name>/<id-feature_name>/<id-story_name>/integration-analysis.md`
11
- — a comprehensive integration analysis with architecture compatibility, refactoring needs,
12
- hardcoded values discovery, integration points, and implementation guidelines extracted
13
- from deep analysis of the existing codebase.
14
-
15
- This is pass 4 of the story specification pipeline (see story.xml composition).
16
- All output is written ONLY to the analysis file — no GitHub updates, no modifications
17
- to the story file.
18
-
19
- This workflow is executed by the `ace-code-integration-analyst` agent
20
- (spawned via `subagent_type="ace-code-integration-analyst"`).
21
- </purpose>
22
-
23
- <mandatory-context>
24
- Read all files referenced by the invoking command's execution-context before starting.
25
- Also read any document or text passed as parameter ($ARGUMENTS) in the invoking command.
26
- </mandatory-context>
27
-
28
- <process>
29
-
30
- <!-- ══════════════════════════════════════════════════════════════════ -->
31
- <!-- STEP 1: SETUP -->
32
- <!-- ══════════════════════════════════════════════════════════════════ -->
33
-
34
- <step name="setup" order="1">
35
- **MANDATORY FIRST STEP — Execute environment detection and story initialization:**
36
-
37
- INIT is available from the preprocessed Environment Context above — do NOT re-run init.
38
-
39
- This preprocessing validated the story parameter, extracted metadata/requirements/wiki
40
- references, computed all paths and slugs, and checked artifact existence.
41
-
42
- Parse INIT JSON for:
43
- - **Environment**: `has_git`, `has_gh_cli`, `github_project`, `analyst_model`
44
- - **Story validation**: `story_valid`, `story_error`, `story_source`
45
- - **Story metadata**: `story` (id, title, status, size), `feature` (id, title), `epic` (id, title)
46
- - **Requirements**: `user_story`, `description`, `acceptance_criteria_count`
47
- - **Paths**: `paths.*` (story_dir, story_file, integration_analysis_file, external_analysis_file, feature_dir, feature_file, etc.)
48
- - **Wiki**: `wiki_references` (system_wide, subsystem_docs, total_count), `wiki_docs_exist`
49
- - **Artifacts**: `has_external_analysis`, `has_integration_analysis`, `has_feature_file`
50
-
51
- Display stage banner:
52
-
53
- ```
54
- ╔══════════════════════════════════════════════════╗
55
- ║ ACE > Research Integration 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, metadata extraction, wiki reference extraction,
75
- and path computation were all completed by `init research-story` in step 1.**
76
- All data is 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 (from `INIT.user_story`,
91
- `INIT.description`, `INIT.acceptance_criteria_count`) define WHAT functionality to
92
- analyze for integration. The wiki references (from `INIT.wiki_references`) define
93
- WHICH wiki documents to read for codebase context.
94
-
95
- <!-- ── 2b: Load 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
-
104
- **If `INIT.has_feature_file` is false:**
105
- Proceed without — the analysis can still be done without feature context.
106
-
107
- <!-- ── 2c: Display ───────────────────────────────────────────────── -->
108
-
109
- Set pre-computed paths from INIT:
110
- - `STORY_FILE = INIT.paths.story_file`
111
- - `STORY_DIR = INIT.paths.story_dir`
112
-
113
- Display:
114
- ```
115
- i Story loaded: {INIT.story.id} — {INIT.story.title}
116
- Feature: {INIT.feature.id} — {INIT.feature.title}
117
- Epic: {INIT.epic.id} — {INIT.epic.title}
118
- Requirements: {INIT.acceptance_criteria_count} acceptance criteria scenarios
119
- Wiki references: {INIT.wiki_references.total_count} documents to load
120
- ```
121
- </step>
122
-
123
- <!-- ══════════════════════════════════════════════════════════════════ -->
124
- <!-- STEP 3: LOAD WIKI DOCUMENTS -->
125
- <!-- ══════════════════════════════════════════════════════════════════ -->
126
-
127
- <step name="load-wiki-documents" order="3">
128
-
129
- **[MANDATORY] Read ALL wiki documents referenced in the story's Relevant Wiki section.**
130
-
131
- Wiki references were pre-extracted by `init research-story` and are available in
132
- `INIT.wiki_references` (system_wide list + subsystem_docs list). File existence
133
- was also pre-checked — see `INIT.wiki_docs_exist` (existing[] and missing[]).
134
-
135
- The wiki IS the single source of codebase knowledge.
136
-
137
- <!-- ── 3a: System-Wide documents (mandatory) ────────────────────── -->
138
-
139
- **System-Wide documents — ALWAYS load these (from `INIT.wiki_references.system_wide`):**
140
-
141
- Read each file and store its content:
142
- - `.docs/wiki/system-wide/system-structure.md` — High-level tree showing where code is
143
- - `.docs/wiki/system-wide/system-architecture.md` — Complete architectural overview
144
- - `.docs/wiki/system-wide/coding-standards.md` — CRITICAL: coding standards — NO EXCEPTIONS
145
- - `.docs/wiki/system-wide/testing-framework.md` — Testing patterns and frameworks
146
-
147
- **For any file in `INIT.wiki_docs_exist.missing`:** Display warning (non-fatal):
148
- ```
149
- ! Wiki document not found: {path}
150
- Continuing without it.
151
- ```
152
-
153
- <!-- ── 3b: Subsystem documents ──────────────────────────────────── -->
154
-
155
- **Subsystem documents — load all from `INIT.wiki_references.subsystem_docs`:**
156
-
157
- For EACH entry in `INIT.wiki_references.subsystem_docs`:
158
- 1. Check if the path is in `INIT.wiki_docs_exist.existing` (already verified)
159
- 2. If exists: read the file completely, store its content keyed by file path
160
- 3. If missing: display warning (non-fatal) and continue
161
-
162
- These subsystem documents provide the context that replaces:
163
- - "documentation" parameter — wiki docs cover all relevant documentation
164
- - "related-stories-implementations" — wiki documents capture knowledge from all stories
165
- - "documented-features" — wiki documents catalog existing feature implementations
166
-
167
- <!-- ── 3c: Display ───────────────────────────────────────────────── -->
168
-
169
- Display:
170
- ```
171
- i Wiki documents loaded: {INIT.wiki_docs_exist.existing.length}/{INIT.wiki_references.total_count} files
172
- System-wide: {count}/4 | Subsystem: {INIT.wiki_references.subsystem_docs.length} documents
173
- Missing: {INIT.wiki_docs_exist.missing.length} (warnings shown above if any)
174
- ```
175
- </step>
176
-
177
- <!-- ══════════════════════════════════════════════════════════════════ -->
178
- <!-- STEP 4: CHECK FOR EXTERNAL ANALYSIS -->
179
- <!-- ══════════════════════════════════════════════════════════════════ -->
180
-
181
- <step name="check-external-analysis" order="4">
182
-
183
- **External analysis existence was pre-checked by `init research-story`.**
184
-
185
- The external analysis is produced by pass 3 (`/ace:research-external-solution`).
186
- It is NOT a required input, but when present it provides valuable context about
187
- how external/industry-standard systems implement this functionality.
188
-
189
- **If `INIT.has_external_analysis` is true:**
190
- Read the file at `INIT.paths.external_analysis_file`. Store as EXTERNAL_ANALYSIS_CONTENT.
191
- Display:
192
- ```
193
- i External analysis found: {INIT.paths.external_analysis_file}
194
- Will incorporate external system insights into integration analysis.
195
- ```
196
-
197
- **If `INIT.has_external_analysis` is false:**
198
- Set EXTERNAL_ANALYSIS_CONTENT = null.
199
- Display:
200
- ```
201
- i No external analysis found. Integration analysis will rely on
202
- wiki documents and direct codebase exploration.
203
- ```
204
- </step>
205
-
206
- <!-- ══════════════════════════════════════════════════════════════════ -->
207
- <!-- STEP 5: RESOLVE OUTPUT PATH -->
208
- <!-- ══════════════════════════════════════════════════════════════════ -->
209
-
210
- <step name="resolve-output-path" order="5">
211
-
212
- **Paths were pre-computed by `init research-story` in step 1.**
213
-
214
- Set from INIT JSON:
215
- - `STORY_DIR = INIT.paths.story_dir`
216
- - `OUTPUT_FILE = INIT.paths.integration_analysis_file`
217
-
218
- Ensure directory exists:
219
- ```bash
220
- mkdir -p {STORY_DIR}
221
- ```
222
-
223
- Display:
224
- ```
225
- i Output: {OUTPUT_FILE}
226
- ```
227
- </step>
228
-
229
- <!-- ══════════════════════════════════════════════════════════════════ -->
230
- <!-- STEP 6: CHECK EXISTING ANALYSIS -->
231
- <!-- ══════════════════════════════════════════════════════════════════ -->
232
-
233
- <step name="check-existing" order="6">
234
-
235
- **If `INIT.has_integration_analysis` is true:**
236
-
237
- Use AskUserQuestion:
238
- - header: "Existing"
239
- - question: "An integration analysis already exists at `{OUTPUT_FILE}`. What would you like to do?"
240
- - options:
241
- - "Overwrite" — Discard and create a new analysis from scratch
242
- - "Skip" — Keep the current analysis as-is
243
-
244
- **If "Overwrite":** Continue to step 7.
245
- **If "Skip":** Display message and exit workflow:
246
- ```
247
- i Keeping existing analysis. No changes made.
248
- ```
249
-
250
- **If not exists:** Continue to step 7.
251
- </step>
252
-
253
- <!-- ══════════════════════════════════════════════════════════════════ -->
254
- <!-- STEP 7: EXECUTE ANALYSIS -->
255
- <!-- ══════════════════════════════════════════════════════════════════ -->
256
-
257
- <step name="execute-analysis" order="7">
258
-
259
- Display:
260
- ```
261
- ┌──────────────────────────────────────────────────┐
262
- │ ACE > Research Integration Solution > Analysis │
263
- └──────────────────────────────────────────────────┘
264
-
265
- i Starting deep codebase integration analysis.
266
- Reading wiki documents, exploring source code,
267
- and tracing integration points. This may take
268
- several minutes.
269
- ```
270
-
271
- **Execute the complete analysis following the template's `<analysis-process>` section.**
272
- The template (`story-integration-solution.xml`) defines 4 mandatory phases.
273
- You ARE the code-integration-analyst — perform the analysis directly.
274
-
275
- <!-- ── 7a: Phase 1 — Context Loading (4 mandatory items) ─────────── -->
276
-
277
- **Phase 1: Context Loading**
278
-
279
- 1. **[MANDATORY] Understand the story requirements:**
280
- - Re-read STORY_CONTENT thoroughly — User Story, Description, all AC scenarios
281
- - These define WHAT functionality needs to integrate into the codebase
282
- - Extract the key behaviors, components, and patterns that will be needed
283
- - If parent feature document was loaded, understand:
284
- - The broader feature context
285
- - What other stories exist and how they relate
286
- - Dependencies and shared components between stories
287
-
288
- 2. **[MANDATORY] Load and study wiki documents:**
289
- - **Coding Standards** (from system-wide): STRONG EMPHASIS — NO EXCEPTIONS!
290
- New code MUST strictly follow all coding standards.
291
- - **System Architecture** (from system-wide): Understand the complete system
292
- architecture and how this story fits into Clean Architecture layers.
293
- - **System Structure** (from system-wide): Understand the codebase layout,
294
- where relevant code lives, and the project file organization.
295
- - **Testing Framework** (from system-wide): Understand testing patterns,
296
- frameworks, and conventions.
297
- - **All subsystem documents**: Read EVERY subsystem document referenced in the
298
- story's Relevant Wiki section. These contain:
299
- - System descriptions and boundaries
300
- - Design patterns in use
301
- - Cross-cutting concerns to respect
302
- - Architecture Decision Records (ADRs) that constrain design
303
- - Guides for common implementation tasks
304
- - Walkthroughs of complex multi-class flows
305
-
306
- 3. **[MANDATORY] Load external analysis (if available):**
307
- - If EXTERNAL_ANALYSIS_CONTENT is set, study it for:
308
- - How industry-standard systems implement this functionality
309
- - Algorithms and formulas to reuse
310
- - Design patterns from external implementations
311
- - Best practices that should inform our integration
312
-
313
- 4. **[MANDATORY] Load the parent feature document:**
314
- - Understand the feature planning context
315
- - Identify how this story fits within the broader feature
316
- - Identify dependencies and integration points with other stories
317
-
318
- <!-- ── 7b: Phase 2 — Deep Codebase Analysis (8 mandatory items) ──── -->
319
-
320
- **Phase 2: Deep Codebase Analysis — ALL 8 items MANDATORY, skip NONE:**
321
-
322
- 1. **[MANDATORY] Architecture Compatibility Analysis:**
323
- - Map how the new story fits into Clean Architecture layers:
324
- - **Domain Layer**: New entities, value objects, constants needed
325
- - **Application Layer**: Use cases, interfaces to create
326
- - **Infrastructure Layer**: Services and implementations required
327
- - **Presentation Layer**: UI components and API endpoints needed
328
- - Verify Clean Architecture compliance: dependencies point inward
329
- - Identify layer boundary violations that must be avoided
330
-
331
- 2. **[MANDATORY] Pattern Recognition & Existing Patterns:**
332
- - Search for similar features/patterns in the codebase
333
- - Reference them with specific file paths and line numbers
334
- - Document:
335
- - Similar implementations to use as reference
336
- - Established naming conventions
337
- - Design patterns already in use (Strategy, Factory, Observer, etc.)
338
- - Error handling patterns
339
- - Logging approaches
340
-
341
- 3. **[MANDATORY] Integration Point Discovery (Layer-by-Layer):**
342
- Examine each architectural layer for integration opportunities:
343
- - **Domain Layer**: Entity extensions, value objects, business rules
344
- - **Application Layer**: Service interfaces, use cases, DTOs
345
- - **Infrastructure Layer**: Repository patterns, external services
346
- - **Presentation Layer**: UI components, view models, controllers
347
- Find:
348
- - Existing interfaces that can be extended
349
- - Abstract classes available for inheritance
350
- - Event systems for loose coupling
351
- - Middleware or pipeline patterns
352
- - Plugin or extension points
353
- - Configuration-based feature toggles
354
-
355
- 4. **[MANDATORY] File Dependency Analysis:**
356
- - Identify ALL files that will be referenced or modified
357
- - Document supporting files for the new implementation
358
- - Map import chains and dependency graphs
359
- - Identify potential circular dependency risks
360
-
361
- 5. **[MANDATORY] Convention Compliance Analysis:**
362
- - Document existing conventions that MUST be followed
363
- - Verify the new implementation doesn't violate coding standards
364
- - Check naming conventions, file organization, error handling
365
-
366
- 6. **[MANDATORY] Testing Pattern Analysis:**
367
- - Analyze current test patterns to ensure consistent validation approach
368
- - Identify test utilities and helpers available for reuse
369
- - Document testing conventions (unit, integration, e2e)
370
- - Identify tests that need modification due to the new implementation
371
-
372
- 7. **[MANDATORY] CRITICAL: Hardcoded Values & Placeholder Code Discovery:**
373
-
374
- THIS IS THE MOST CRITICAL PART OF THE INTEGRATION ANALYSIS!
375
-
376
- When a new story implements a feature, there are ALWAYS existing hardcoded
377
- values or placeholder implementations that the new feature is MEANT TO REPLACE.
378
-
379
- YOU MUST EXHAUSTIVELY SEARCH FOR:
380
-
381
- a. **Hardcoded Domain/Range Values:**
382
- - Search for hardcoded number ranges, dimensions, colors, sizes, offsets
383
- - Search for values that should come from the new entity/service
384
- - Use grep patterns like: `domain\(\[`, `= 0;`, `= 100`, `MIN_`, `MAX_`, `DEFAULT_`
385
-
386
- b. **Placeholder/Stub Implementations:**
387
- - Search for TODO comments mentioning the feature being implemented
388
- - Search for "temporary", "placeholder", "stub", "mock" in comments
389
- - Search for methods that return hardcoded values instead of computed ones
390
- - Use grep patterns: `TODO`, `TEMPORARY`, `placeholder`, `HARDCODED`
391
-
392
- c. **Disconnected Wiring:**
393
- - Search for classes/services that EXIST but are NOT USED where they should be
394
- - Find where the NEW entity/service SHOULD be injected but currently isn't
395
- - For every new entity/service being created, ask:
396
- - "What existing code currently does this job (probably poorly/hardcoded)?"
397
- - "Where should this entity be INJECTED that it currently ISN'T?"
398
- - "What hardcoded values exist that this entity should REPLACE?"
399
-
400
- d. **Inline Calculations That Should Use New Service:**
401
- - Search for inline calculations done manually instead of using the new entity
402
- - Search for duplicate calculation logic across multiple files
403
- - Use grep patterns: `Math.min`, `Math.max`, inline formulas
404
-
405
- e. **Manager/Service Classes with Hardcoded Defaults:**
406
- - Search manager/service classes that initialize with dummy values
407
- - These MUST be updated to receive values from the new entity
408
- - Find all `*Manager`, `*Service` classes in Infrastructure layer
409
-
410
- f. **Renderer/Handler Classes Not Using New Entity:**
411
- - When implementing a new feature, ALL relevant renderers/handlers must be checked
412
- - Verify they use the new entity instead of hardcoded values or direct calculations
413
-
414
- Output format for EACH discovered item:
415
- ```yaml
416
- FILE: [exact file path]
417
- LINE: [line number(s)]
418
- CURRENT CODE: |
419
- [actual code snippet from the file]
420
- PROBLEM: [why this is wrong]
421
- SHOULD BE: [what it should become after implementation]
422
- FIX REQUIRED: [specific action to take]
423
- ```
424
-
425
- 8. **[MANDATORY] Impact Analysis:**
426
- - Discover ALL code flows that might be impacted by the new implementation
427
- - Include specific file references for each impacted flow
428
- - Identify tests that need modification (include file paths)
429
- - Document all documentation files/flows requiring updates
430
-
431
- <!-- ── 7c: Phase 3 — Refactoring & Strategy (4 mandatory items) ──── -->
432
-
433
- **Phase 3: Refactoring & Strategy Analysis — ALL 4 items MANDATORY:**
434
-
435
- 1. **[MANDATORY] Refactoring Requirements:**
436
- Determine if existing code needs refactoring to support the new implementation
437
- in a MAINTAINABLE / EXTENSIBLE way. Check for:
438
-
439
- - **Consolidation**: Duplicate code that should be unified
440
- - **Abstraction**: Concrete implementations that need interfaces
441
- - **Separation**: Mixed concerns that need splitting
442
- - **Generalization**: Specific code that could be made reusable
443
- - **Simplification**: Complex code that could be streamlined
444
- - **Standardization**: Inconsistent patterns needing alignment
445
-
446
- Common refactoring scenarios:
447
- - Pattern implementation violations (e.g., adding a new type when Strategy pattern should be used)
448
- - Constants/configuration scattered across files (centralize in Domain layer)
449
- - Model proliferation (extend existing models instead of creating duplicates)
450
- - Method duplication (reuse existing methods, don't recreate)
451
- - Incorrect layer violations (business logic in wrong layer)
452
- - Service sprawl (extend existing services if cohesive)
453
- - Event handler inconsistencies (follow established event patterns)
454
- - State management violations (follow established state patterns)
455
- - API integration inconsistencies (use existing API client services)
456
- - Type definition duplication (import and reuse existing types)
457
-
458
- **Even if no refactoring is needed, this section MUST be completed
459
- with the conclusion "no refactoring required" and justification.**
460
-
461
- 2. **[MANDATORY] Implementation Guidelines:**
462
- - Step-by-step implementation approach following coding standards
463
- - Optimal architectural placement for new code
464
- - Interface design for maximum flexibility
465
- - Dependency management approach
466
- - State management strategy
467
- - Error handling patterns to follow
468
- - Recommended implementation order
469
-
470
- 3. **[MANDATORY] Testing Strategy:**
471
- - How to test without breaking existing tests
472
- - Test patterns to follow (from testing framework doc)
473
- - Required test types (unit, integration, e2e)
474
- - Mocking strategies based on existing test patterns
475
- - Edge cases to cover
476
-
477
- 4. **[MANDATORY] Risk Mitigation:**
478
- - Backward compatibility considerations
479
- - Migration path for existing functionality
480
- - What existing functionality might be impacted
481
- - Performance implications
482
- - Breaking change risks
483
-
484
- <!-- ── 7d: Phase 4 — AI Implementation Context (2 mandatory items) ── -->
485
-
486
- **Phase 4: AI Implementation Context — ALL 2 items MANDATORY:**
487
-
488
- 1. **[MANDATORY] Complete Analysis Findings:**
489
- Include ALL findings from the deep analysis:
490
- - Every discovered pattern with file references
491
- - Every relevant code snippet
492
- - Every architectural decision
493
- - Every potential issue
494
- - Every integration consideration
495
-
496
- 2. **[MANDATORY] Implementation References:**
497
- - **Internal Documentation**: List all relevant internal docs with full paths
498
- - **Code References**: List all files that should be studied before implementation,
499
- including specific functions/classes to use as examples and utility functions to reuse
500
- - **Design Patterns & Best Practices**: Link to specific design pattern documentation
501
- (e.g., https://refactoring.guru/design-patterns/strategy for Strategy pattern)
502
- - **Domain knowledge**: All naming conventions, error handling patterns,
503
- logging standards, performance considerations
504
-
505
- **CRITICAL REQUIREMENTS:**
506
- - **STORY SCOPE ONLY**: Focus exclusively on code relevant to the story
507
- - **COMPLETE COVERAGE**: Every file and method involved must be documented
508
- - **EXACT IMPLEMENTATIONS**: Include actual code snippets with file paths and line numbers
509
- - **CODING STANDARDS FIRST**: Verify ALL analysis against coding standards
510
- - **NO ASSUMPTIONS**: Only document what you actually find in the code
511
- </step>
512
-
513
- <!-- ══════════════════════════════════════════════════════════════════ -->
514
- <!-- STEP 8: WRITE OUTPUT -->
515
- <!-- ══════════════════════════════════════════════════════════════════ -->
516
-
517
- <step name="write-output" order="8">
518
-
519
- Write the complete analysis to `{OUTPUT_FILE}` following the template's
520
- `<output-format>` section exactly. Include ALL sections:
521
-
522
- 1. Header (story, date, metrics)
523
- 2. Use Case Overview
524
- 3. Architecture Compatibility (layer-by-layer analysis)
525
- 4. Existing Patterns to Follow (with file references)
526
- 5. Required Refactoring (even if "none needed")
527
- 6. CRITICAL: Hardcoded Values & Placeholder Code (with actual code snippets)
528
- 7. Integration Points (all touchpoints with existing system)
529
- 8. Impact Analysis (all affected flows and components)
530
- 9. Implementation Guidelines (step-by-step approach)
531
- 10. Testing Strategy (preserving existing tests)
532
- 11. Complete Analysis Findings
533
- 12. Implementation References (internal docs, code refs, patterns)
534
- 13. AI Implementation Context (complete context for executing agent)
535
-
536
- Use the Write tool to create the file. Include all findings from step 7.
537
-
538
- This is NOT a summary — it is a COMPLETE INTEGRATION ANALYSIS. Every section
539
- must contain actual code snippets, file paths with line numbers, and
540
- concrete implementation details.
541
-
542
- Display:
543
- ```
544
- + Analysis written to {OUTPUT_FILE}
545
- ```
546
- </step>
547
-
548
- <!-- ══════════════════════════════════════════════════════════════════ -->
549
- <!-- STEP 9: VALIDATION -->
550
- <!-- ══════════════════════════════════════════════════════════════════ -->
551
-
552
- <step name="validation" order="9">
553
-
554
- Read the output file and verify against the validation checklist
555
- defined in the template (story-integration-solution.xml):
556
-
557
- **File Creation Requirements:**
558
- - [ ] Analysis file created at {OUTPUT_FILE}
559
- - [ ] Story directory exists
560
- - [ ] File contains all required sections from template
561
-
562
- **Content Requirements — Core Analysis:**
563
- - [ ] Tree structure showing current codebase structure
564
- - [ ] Tree structure showing proposed changes with new files
565
- - [ ] Architecture compatibility analysis completed (layer-by-layer)
566
- - [ ] All existing patterns identified with file references
567
- - [ ] Integration points clearly documented
568
- - [ ] Impact analysis showing affected components
569
-
570
- **Architecture Analysis Requirements:**
571
- - [ ] Clean Architecture compliance verified
572
- - [ ] Dependency injection strategy documented
573
- - [ ] Design patterns identified and documented
574
- - [ ] Coding standards compliance verified
575
- - [ ] Testing strategy that preserves existing tests
576
-
577
- **Hardcoded Values & Placeholder Discovery (CRITICAL!):**
578
- - [ ] Searched for hardcoded domain/range values
579
- - [ ] Searched for placeholder/TODO comments related to the feature
580
- - [ ] Identified ALL renderers/handlers that should use the new entity but don't
581
- - [ ] Identified ALL manager/service classes with hardcoded defaults
582
- - [ ] Found disconnected wiring (entity exists but not injected where needed)
583
- - [ ] Hardcoded values section filled with ACTUAL CODE SNIPPETS (not placeholders!)
584
- - [ ] Every hardcoded value includes: file path, line number, current code, fix required
585
-
586
- **Refactoring Requirements:**
587
- - [ ] Refactoring analysis completed (even if "no refactoring needed")
588
- - [ ] Implementation guidelines provided
589
- - [ ] Testing strategy documented
590
- - [ ] Risk mitigation considered
591
-
592
- **Total: 22 mandatory checklist items**
593
-
594
- If the output is incomplete or missing sections, go back and fill in
595
- the missing content before proceeding.
596
-
597
- Display:
598
- ```
599
- {check_mark} Analysis validated. {passed}/{total} checks passed.
600
- ```
601
- </step>
602
-
603
- <!-- ══════════════════════════════════════════════════════════════════ -->
604
- <!-- STEP 10: REVIEW AND APPROVE -->
605
- <!-- ══════════════════════════════════════════════════════════════════ -->
606
-
607
- <step name="review" order="10">
608
-
609
- Display a summary of the analysis:
610
- ```
611
- Analysis Summary:
612
- ────────
613
- Sections: {count}/13 | Checklist: {passed}/22
614
- Wiki docs loaded: {N} | Code references: {M}
615
- Hardcoded values found: {H} | Refactoring items: {R}
616
- ```
617
-
618
- Use AskUserQuestion:
619
- - header: "Analysis"
620
- - question: "Integration analysis written to `{OUTPUT_FILE}`. Review the file in your editor — does the analysis look comprehensive?"
621
- - options:
622
- - "Approve" — Looks good, commit it
623
- - "Refine" — Some sections need more depth
624
- - "Skip commit" — Keep the file but don't commit yet
625
-
626
- **If "Approve":**
627
- Continue to step 11.
628
-
629
- **If "Refine":**
630
- - Ask what sections need more depth or what's missing
631
- - Go back to the relevant analysis phase, read more code, and update OUTPUT_FILE
632
- - Re-run validation (step 9)
633
- - Present for review again
634
-
635
- **If "Skip commit":**
636
- Display completion without commit:
637
- ```
638
- ╔══════════════════════════════════════════════════╗
639
- ║ ACE > Integration Analysis Complete (uncommitted)║
640
- ║ {Story ID} "{Story Title}" ║
641
- ╚══════════════════════════════════════════════════╝
642
-
643
- i Analysis written to {OUTPUT_FILE}
644
- File not committed — commit manually when ready.
645
- ```
646
- Exit workflow.
647
- </step>
648
-
649
- <!-- ══════════════════════════════════════════════════════════════════ -->
650
- <!-- STEP 11: COMMIT -->
651
- <!-- ══════════════════════════════════════════════════════════════════ -->
652
-
653
- <step name="commit" order="11">
654
-
655
- Stage and commit the analysis file:
656
-
657
- ```bash
658
- git add {OUTPUT_FILE}
659
- ```
660
-
661
- ```bash
662
- git commit -m "docs: integration analysis for {Story ID} — {Story Title}"
663
- ```
664
-
665
- Display completion:
666
-
667
- ```
668
- ╔══════════════════════════════════════════════════╗
669
- ║ ACE > Integration Analysis Complete ║
670
- ║ {Story ID} "{Story Title}" ║
671
- ╚══════════════════════════════════════════════════╝
672
-
673
- + {OUTPUT_FILE} committed.
674
-
675
- Metrics:
676
- ────────
677
- Wiki docs loaded: {N} | Code references: {M}
678
- Hardcoded values found: {H} | Refactoring items: {R}
679
-
680
- i Integration analysis complete. This artifact will be consumed
681
- by the technical solution (pass 5) when running plan-story.
682
-
683
- Next > Continue with story refinement:
684
- - Technical solution (pass 5)
685
- > /ace:research-integration-solution story=...
686
- Analyze another story's codebase integration.
687
- ```
688
- </step>
689
-
690
- </process>
691
-
692
- <success_criteria>
693
- - Story loaded and requirements extracted (User Story, Description, Acceptance Criteria)
694
- - All wiki references extracted from story's Relevant Wiki section
695
- - All wiki documents loaded (system-wide mandatory, subsystem as referenced)
696
- - Parent feature document loaded for broader context (if available)
697
- - External analysis loaded if present in story directory (auto-detected)
698
- - Output path resolved from story context
699
- - All 4 analysis phases executed directly (18 mandatory items completed)
700
- - Analysis file written with ALL template sections populated
701
- - NO assumptions made — all findings backed by actual code references
702
- - Hardcoded values section filled with ACTUAL CODE SNIPPETS
703
- - Refactoring analysis completed (even if "no refactoring needed")
704
- - Coding standards compliance verified throughout
705
- - All 22 validation checklist items verified
706
- - User reviewed and approved the analysis
707
- - Document committed with appropriate message
708
- - No modifications made to the story file or GitHub issues
709
- </success_criteria>
710
-
711
- </workflow>
1
+ <workflow>
2
+
3
+ <purpose>
4
+ Perform COMPREHENSIVE, IN-DEPTH System Integration Analysis of how a specific story
5
+ should integrate into the existing codebase. Load the story requirements and wiki
6
+ references, validate inputs, load wiki documents and optional external analysis,
7
+ then execute exhaustive codebase analysis following the template's analysis-process
8
+ phases. Write the analysis to integration-analysis.md in the story's artifact directory.
9
+
10
+ Produces `.ace/artifacts/product/<id-epic_name>/<id-feature_name>/<id-story_name>/integration-analysis.md`
11
+ — a comprehensive integration analysis with architecture compatibility, refactoring needs,
12
+ hardcoded values discovery, integration points, and implementation guidelines extracted
13
+ from deep analysis of the existing codebase.
14
+
15
+ This is pass 4 of the story specification pipeline (see story.xml composition).
16
+ All output is written ONLY to the analysis file — no GitHub updates, no modifications
17
+ to the story file.
18
+
19
+ This workflow is executed by the `ace-code-integration-analyst` agent
20
+ (spawned via `subagent_type="ace-code-integration-analyst"`).
21
+ </purpose>
22
+
23
+ <mandatory-context>
24
+ All supporting resource files are auto-loaded in the skill prompt above. Do NOT re-read them.
25
+ Also read any document or text passed as parameter ($ARGUMENTS) in the invoking command.
26
+ </mandatory-context>
27
+
28
+ <process>
29
+
30
+ <!-- ══════════════════════════════════════════════════════════════════ -->
31
+ <!-- STEP 1: SETUP -->
32
+ <!-- ══════════════════════════════════════════════════════════════════ -->
33
+
34
+ <step name="setup" order="1">
35
+ **MANDATORY FIRST STEP — Execute environment detection and story initialization:**
36
+
37
+ INIT is available from the preprocessed Environment Context above — do NOT re-run init.
38
+
39
+ This preprocessing validated the story parameter, extracted metadata/requirements/wiki
40
+ references, computed all paths and slugs, and checked artifact existence.
41
+
42
+ Parse INIT JSON for:
43
+ - **Environment**: `has_git`, `has_gh_cli`, `github_project`, `analyst_model`
44
+ - **Story validation**: `story_valid`, `story_error`, `story_source`
45
+ - **Story metadata**: `story` (id, title, status, size), `feature` (id, title), `epic` (id, title)
46
+ - **Requirements**: `user_story`, `description`, `acceptance_criteria_count`
47
+ - **Paths**: `paths.*` (story_dir, story_file, integration_analysis_file, external_analysis_file, feature_dir, feature_file, etc.)
48
+ - **Wiki**: `wiki_references` (system_wide, subsystem_docs, total_count), `wiki_docs_exist`
49
+ - **Artifacts**: `has_external_analysis`, `has_integration_analysis`, `has_feature_file`
50
+
51
+ Display stage banner:
52
+
53
+ ```
54
+ ╔══════════════════════════════════════════════════╗
55
+ ║ ACE > Research Integration 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, metadata extraction, wiki reference extraction,
75
+ and path computation were all completed by `init research-story` in step 1.**
76
+ All data is 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 (from `INIT.user_story`,
91
+ `INIT.description`, `INIT.acceptance_criteria_count`) define WHAT functionality to
92
+ analyze for integration. The wiki references (from `INIT.wiki_references`) define
93
+ WHICH wiki documents to read for codebase context.
94
+
95
+ <!-- ── 2b: Load 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
+
104
+ **If `INIT.has_feature_file` is false:**
105
+ Proceed without — the analysis can still be done without feature context.
106
+
107
+ <!-- ── 2c: Display ───────────────────────────────────────────────── -->
108
+
109
+ Set pre-computed paths from INIT:
110
+ - `STORY_FILE = INIT.paths.story_file`
111
+ - `STORY_DIR = INIT.paths.story_dir`
112
+
113
+ Display:
114
+ ```
115
+ i Story loaded: {INIT.story.id} — {INIT.story.title}
116
+ Feature: {INIT.feature.id} — {INIT.feature.title}
117
+ Epic: {INIT.epic.id} — {INIT.epic.title}
118
+ Requirements: {INIT.acceptance_criteria_count} acceptance criteria scenarios
119
+ Wiki references: {INIT.wiki_references.total_count} documents to load
120
+ ```
121
+ </step>
122
+
123
+ <!-- ══════════════════════════════════════════════════════════════════ -->
124
+ <!-- STEP 3: LOAD WIKI DOCUMENTS -->
125
+ <!-- ══════════════════════════════════════════════════════════════════ -->
126
+
127
+ <step name="load-wiki-documents" order="3">
128
+
129
+ **[MANDATORY] Read ALL wiki documents referenced in the story's Relevant Wiki section.**
130
+
131
+ Wiki references were pre-extracted by `init research-story` and are available in
132
+ `INIT.wiki_references` (system_wide list + subsystem_docs list). File existence
133
+ was also pre-checked — see `INIT.wiki_docs_exist` (existing[] and missing[]).
134
+
135
+ The wiki IS the single source of codebase knowledge.
136
+
137
+ <!-- ── 3a: System-Wide documents (mandatory) ────────────────────── -->
138
+
139
+ **System-Wide documents — ALWAYS load these (from `INIT.wiki_references.system_wide`):**
140
+
141
+ Read each file and store its content:
142
+ - `.docs/wiki/system-wide/system-structure.md` — High-level tree showing where code is
143
+ - `.docs/wiki/system-wide/system-architecture.md` — Complete architectural overview
144
+ - `.docs/wiki/system-wide/coding-standards.md` — CRITICAL: coding standards — NO EXCEPTIONS
145
+ - `.docs/wiki/system-wide/testing-framework.md` — Testing patterns and frameworks
146
+
147
+ **For any file in `INIT.wiki_docs_exist.missing`:** Display warning (non-fatal):
148
+ ```
149
+ ! Wiki document not found: {path}
150
+ Continuing without it.
151
+ ```
152
+
153
+ <!-- ── 3b: Subsystem documents ──────────────────────────────────── -->
154
+
155
+ **Subsystem documents — load all from `INIT.wiki_references.subsystem_docs`:**
156
+
157
+ For EACH entry in `INIT.wiki_references.subsystem_docs`:
158
+ 1. Check if the path is in `INIT.wiki_docs_exist.existing` (already verified)
159
+ 2. If exists: read the file completely, store its content keyed by file path
160
+ 3. If missing: display warning (non-fatal) and continue
161
+
162
+ These subsystem documents provide the context that replaces:
163
+ - "documentation" parameter — wiki docs cover all relevant documentation
164
+ - "related-stories-implementations" — wiki documents capture knowledge from all stories
165
+ - "documented-features" — wiki documents catalog existing feature implementations
166
+
167
+ <!-- ── 3c: Display ───────────────────────────────────────────────── -->
168
+
169
+ Display:
170
+ ```
171
+ i Wiki documents loaded: {INIT.wiki_docs_exist.existing.length}/{INIT.wiki_references.total_count} files
172
+ System-wide: {count}/4 | Subsystem: {INIT.wiki_references.subsystem_docs.length} documents
173
+ Missing: {INIT.wiki_docs_exist.missing.length} (warnings shown above if any)
174
+ ```
175
+ </step>
176
+
177
+ <!-- ══════════════════════════════════════════════════════════════════ -->
178
+ <!-- STEP 4: CHECK FOR EXTERNAL ANALYSIS -->
179
+ <!-- ══════════════════════════════════════════════════════════════════ -->
180
+
181
+ <step name="check-external-analysis" order="4">
182
+
183
+ **External analysis existence was pre-checked by `init research-story`.**
184
+
185
+ The external analysis is produced by pass 3 (`/ace:research-external-solution`).
186
+ It is NOT a required input, but when present it provides valuable context about
187
+ how external/industry-standard systems implement this functionality.
188
+
189
+ **If `INIT.has_external_analysis` is true:**
190
+ Read the file at `INIT.paths.external_analysis_file`. Store as EXTERNAL_ANALYSIS_CONTENT.
191
+ Display:
192
+ ```
193
+ i External analysis found: {INIT.paths.external_analysis_file}
194
+ Will incorporate external system insights into integration analysis.
195
+ ```
196
+
197
+ **If `INIT.has_external_analysis` is false:**
198
+ Set EXTERNAL_ANALYSIS_CONTENT = null.
199
+ Display:
200
+ ```
201
+ i No external analysis found. Integration analysis will rely on
202
+ wiki documents and direct codebase exploration.
203
+ ```
204
+ </step>
205
+
206
+ <!-- ══════════════════════════════════════════════════════════════════ -->
207
+ <!-- STEP 5: RESOLVE OUTPUT PATH -->
208
+ <!-- ══════════════════════════════════════════════════════════════════ -->
209
+
210
+ <step name="resolve-output-path" order="5">
211
+
212
+ **Paths were pre-computed by `init research-story` in step 1.**
213
+
214
+ Set from INIT JSON:
215
+ - `STORY_DIR = INIT.paths.story_dir`
216
+ - `OUTPUT_FILE = INIT.paths.integration_analysis_file`
217
+
218
+ Ensure directory exists:
219
+ ```bash
220
+ mkdir -p {STORY_DIR}
221
+ ```
222
+
223
+ Display:
224
+ ```
225
+ i Output: {OUTPUT_FILE}
226
+ ```
227
+ </step>
228
+
229
+ <!-- ══════════════════════════════════════════════════════════════════ -->
230
+ <!-- STEP 6: CHECK EXISTING ANALYSIS -->
231
+ <!-- ══════════════════════════════════════════════════════════════════ -->
232
+
233
+ <step name="check-existing" order="6">
234
+
235
+ **If `INIT.has_integration_analysis` is true:**
236
+
237
+ Use AskUserQuestion:
238
+ - header: "Existing"
239
+ - question: "An integration analysis already exists at `{OUTPUT_FILE}`. What would you like to do?"
240
+ - options:
241
+ - "Overwrite" — Discard and create a new analysis from scratch
242
+ - "Skip" — Keep the current analysis as-is
243
+
244
+ **If "Overwrite":** Continue to step 7.
245
+ **If "Skip":** Display message and exit workflow:
246
+ ```
247
+ i Keeping existing analysis. No changes made.
248
+ ```
249
+
250
+ **If not exists:** Continue to step 7.
251
+ </step>
252
+
253
+ <!-- ══════════════════════════════════════════════════════════════════ -->
254
+ <!-- STEP 7: EXECUTE ANALYSIS -->
255
+ <!-- ══════════════════════════════════════════════════════════════════ -->
256
+
257
+ <step name="execute-analysis" order="7">
258
+
259
+ Display:
260
+ ```
261
+ ┌──────────────────────────────────────────────────┐
262
+ │ ACE > Research Integration Solution > Analysis │
263
+ └──────────────────────────────────────────────────┘
264
+
265
+ i Starting deep codebase integration analysis.
266
+ Reading wiki documents, exploring source code,
267
+ and tracing integration points. This may take
268
+ several minutes.
269
+ ```
270
+
271
+ **Execute the complete analysis following the template's `<analysis-process>` section.**
272
+ The template (`story-integration-solution.xml`) defines 4 mandatory phases.
273
+ You ARE the code-integration-analyst — perform the analysis directly.
274
+
275
+ <!-- ── 7a: Phase 1 — Context Loading (4 mandatory items) ─────────── -->
276
+
277
+ **Phase 1: Context Loading**
278
+
279
+ 1. **[MANDATORY] Understand the story requirements:**
280
+ - Re-read STORY_CONTENT thoroughly — User Story, Description, all AC scenarios
281
+ - These define WHAT functionality needs to integrate into the codebase
282
+ - Extract the key behaviors, components, and patterns that will be needed
283
+ - If parent feature document was loaded, understand:
284
+ - The broader feature context
285
+ - What other stories exist and how they relate
286
+ - Dependencies and shared components between stories
287
+
288
+ 2. **[MANDATORY] Load and study wiki documents:**
289
+ - **Coding Standards** (from system-wide): STRONG EMPHASIS — NO EXCEPTIONS!
290
+ New code MUST strictly follow all coding standards.
291
+ - **System Architecture** (from system-wide): Understand the complete system
292
+ architecture and how this story fits into Clean Architecture layers.
293
+ - **System Structure** (from system-wide): Understand the codebase layout,
294
+ where relevant code lives, and the project file organization.
295
+ - **Testing Framework** (from system-wide): Understand testing patterns,
296
+ frameworks, and conventions.
297
+ - **All subsystem documents**: Read EVERY subsystem document referenced in the
298
+ story's Relevant Wiki section. These contain:
299
+ - System descriptions and boundaries
300
+ - Design patterns in use
301
+ - Cross-cutting concerns to respect
302
+ - Architecture Decision Records (ADRs) that constrain design
303
+ - Guides for common implementation tasks
304
+ - Walkthroughs of complex multi-class flows
305
+
306
+ 3. **[MANDATORY] Load external analysis (if available):**
307
+ - If EXTERNAL_ANALYSIS_CONTENT is set, study it for:
308
+ - How industry-standard systems implement this functionality
309
+ - Algorithms and formulas to reuse
310
+ - Design patterns from external implementations
311
+ - Best practices that should inform our integration
312
+
313
+ 4. **[MANDATORY] Load the parent feature document:**
314
+ - Understand the feature planning context
315
+ - Identify how this story fits within the broader feature
316
+ - Identify dependencies and integration points with other stories
317
+
318
+ <!-- ── 7b: Phase 2 — Deep Codebase Analysis (8 mandatory items) ──── -->
319
+
320
+ **Phase 2: Deep Codebase Analysis — ALL 8 items MANDATORY, skip NONE:**
321
+
322
+ 1. **[MANDATORY] Architecture Compatibility Analysis:**
323
+ - Map how the new story fits into Clean Architecture layers:
324
+ - **Domain Layer**: New entities, value objects, constants needed
325
+ - **Application Layer**: Use cases, interfaces to create
326
+ - **Infrastructure Layer**: Services and implementations required
327
+ - **Presentation Layer**: UI components and API endpoints needed
328
+ - Verify Clean Architecture compliance: dependencies point inward
329
+ - Identify layer boundary violations that must be avoided
330
+
331
+ 2. **[MANDATORY] Pattern Recognition & Existing Patterns:**
332
+ - Search for similar features/patterns in the codebase
333
+ - Reference them with specific file paths and line numbers
334
+ - Document:
335
+ - Similar implementations to use as reference
336
+ - Established naming conventions
337
+ - Design patterns already in use (Strategy, Factory, Observer, etc.)
338
+ - Error handling patterns
339
+ - Logging approaches
340
+
341
+ 3. **[MANDATORY] Integration Point Discovery (Layer-by-Layer):**
342
+ Examine each architectural layer for integration opportunities:
343
+ - **Domain Layer**: Entity extensions, value objects, business rules
344
+ - **Application Layer**: Service interfaces, use cases, DTOs
345
+ - **Infrastructure Layer**: Repository patterns, external services
346
+ - **Presentation Layer**: UI components, view models, controllers
347
+ Find:
348
+ - Existing interfaces that can be extended
349
+ - Abstract classes available for inheritance
350
+ - Event systems for loose coupling
351
+ - Middleware or pipeline patterns
352
+ - Plugin or extension points
353
+ - Configuration-based feature toggles
354
+
355
+ 4. **[MANDATORY] File Dependency Analysis:**
356
+ - Identify ALL files that will be referenced or modified
357
+ - Document supporting files for the new implementation
358
+ - Map import chains and dependency graphs
359
+ - Identify potential circular dependency risks
360
+
361
+ 5. **[MANDATORY] Convention Compliance Analysis:**
362
+ - Document existing conventions that MUST be followed
363
+ - Verify the new implementation doesn't violate coding standards
364
+ - Check naming conventions, file organization, error handling
365
+
366
+ 6. **[MANDATORY] Testing Pattern Analysis:**
367
+ - Analyze current test patterns to ensure consistent validation approach
368
+ - Identify test utilities and helpers available for reuse
369
+ - Document testing conventions (unit, integration, e2e)
370
+ - Identify tests that need modification due to the new implementation
371
+
372
+ 7. **[MANDATORY] CRITICAL: Hardcoded Values & Placeholder Code Discovery:**
373
+
374
+ THIS IS THE MOST CRITICAL PART OF THE INTEGRATION ANALYSIS!
375
+
376
+ When a new story implements a feature, there are ALWAYS existing hardcoded
377
+ values or placeholder implementations that the new feature is MEANT TO REPLACE.
378
+
379
+ YOU MUST EXHAUSTIVELY SEARCH FOR:
380
+
381
+ a. **Hardcoded Domain/Range Values:**
382
+ - Search for hardcoded number ranges, dimensions, colors, sizes, offsets
383
+ - Search for values that should come from the new entity/service
384
+ - Use grep patterns like: `domain\(\[`, `= 0;`, `= 100`, `MIN_`, `MAX_`, `DEFAULT_`
385
+
386
+ b. **Placeholder/Stub Implementations:**
387
+ - Search for TODO comments mentioning the feature being implemented
388
+ - Search for "temporary", "placeholder", "stub", "mock" in comments
389
+ - Search for methods that return hardcoded values instead of computed ones
390
+ - Use grep patterns: `TODO`, `TEMPORARY`, `placeholder`, `HARDCODED`
391
+
392
+ c. **Disconnected Wiring:**
393
+ - Search for classes/services that EXIST but are NOT USED where they should be
394
+ - Find where the NEW entity/service SHOULD be injected but currently isn't
395
+ - For every new entity/service being created, ask:
396
+ - "What existing code currently does this job (probably poorly/hardcoded)?"
397
+ - "Where should this entity be INJECTED that it currently ISN'T?"
398
+ - "What hardcoded values exist that this entity should REPLACE?"
399
+
400
+ d. **Inline Calculations That Should Use New Service:**
401
+ - Search for inline calculations done manually instead of using the new entity
402
+ - Search for duplicate calculation logic across multiple files
403
+ - Use grep patterns: `Math.min`, `Math.max`, inline formulas
404
+
405
+ e. **Manager/Service Classes with Hardcoded Defaults:**
406
+ - Search manager/service classes that initialize with dummy values
407
+ - These MUST be updated to receive values from the new entity
408
+ - Find all `*Manager`, `*Service` classes in Infrastructure layer
409
+
410
+ f. **Renderer/Handler Classes Not Using New Entity:**
411
+ - When implementing a new feature, ALL relevant renderers/handlers must be checked
412
+ - Verify they use the new entity instead of hardcoded values or direct calculations
413
+
414
+ Output format for EACH discovered item:
415
+ ```yaml
416
+ FILE: [exact file path]
417
+ LINE: [line number(s)]
418
+ CURRENT CODE: |
419
+ [actual code snippet from the file]
420
+ PROBLEM: [why this is wrong]
421
+ SHOULD BE: [what it should become after implementation]
422
+ FIX REQUIRED: [specific action to take]
423
+ ```
424
+
425
+ 8. **[MANDATORY] Impact Analysis:**
426
+ - Discover ALL code flows that might be impacted by the new implementation
427
+ - Include specific file references for each impacted flow
428
+ - Identify tests that need modification (include file paths)
429
+ - Document all documentation files/flows requiring updates
430
+
431
+ <!-- ── 7c: Phase 3 — Refactoring & Strategy (4 mandatory items) ──── -->
432
+
433
+ **Phase 3: Refactoring & Strategy Analysis — ALL 4 items MANDATORY:**
434
+
435
+ 1. **[MANDATORY] Refactoring Requirements:**
436
+ Determine if existing code needs refactoring to support the new implementation
437
+ in a MAINTAINABLE / EXTENSIBLE way. Check for:
438
+
439
+ - **Consolidation**: Duplicate code that should be unified
440
+ - **Abstraction**: Concrete implementations that need interfaces
441
+ - **Separation**: Mixed concerns that need splitting
442
+ - **Generalization**: Specific code that could be made reusable
443
+ - **Simplification**: Complex code that could be streamlined
444
+ - **Standardization**: Inconsistent patterns needing alignment
445
+
446
+ Common refactoring scenarios:
447
+ - Pattern implementation violations (e.g., adding a new type when Strategy pattern should be used)
448
+ - Constants/configuration scattered across files (centralize in Domain layer)
449
+ - Model proliferation (extend existing models instead of creating duplicates)
450
+ - Method duplication (reuse existing methods, don't recreate)
451
+ - Incorrect layer violations (business logic in wrong layer)
452
+ - Service sprawl (extend existing services if cohesive)
453
+ - Event handler inconsistencies (follow established event patterns)
454
+ - State management violations (follow established state patterns)
455
+ - API integration inconsistencies (use existing API client services)
456
+ - Type definition duplication (import and reuse existing types)
457
+
458
+ **Even if no refactoring is needed, this section MUST be completed
459
+ with the conclusion "no refactoring required" and justification.**
460
+
461
+ 2. **[MANDATORY] Implementation Guidelines:**
462
+ - Step-by-step implementation approach following coding standards
463
+ - Optimal architectural placement for new code
464
+ - Interface design for maximum flexibility
465
+ - Dependency management approach
466
+ - State management strategy
467
+ - Error handling patterns to follow
468
+ - Recommended implementation order
469
+
470
+ 3. **[MANDATORY] Testing Strategy:**
471
+ - How to test without breaking existing tests
472
+ - Test patterns to follow (from testing framework doc)
473
+ - Required test types (unit, integration, e2e)
474
+ - Mocking strategies based on existing test patterns
475
+ - Edge cases to cover
476
+
477
+ 4. **[MANDATORY] Risk Mitigation:**
478
+ - Backward compatibility considerations
479
+ - Migration path for existing functionality
480
+ - What existing functionality might be impacted
481
+ - Performance implications
482
+ - Breaking change risks
483
+
484
+ <!-- ── 7d: Phase 4 — AI Implementation Context (2 mandatory items) ── -->
485
+
486
+ **Phase 4: AI Implementation Context — ALL 2 items MANDATORY:**
487
+
488
+ 1. **[MANDATORY] Complete Analysis Findings:**
489
+ Include ALL findings from the deep analysis:
490
+ - Every discovered pattern with file references
491
+ - Every relevant code snippet
492
+ - Every architectural decision
493
+ - Every potential issue
494
+ - Every integration consideration
495
+
496
+ 2. **[MANDATORY] Implementation References:**
497
+ - **Internal Documentation**: List all relevant internal docs with full paths
498
+ - **Code References**: List all files that should be studied before implementation,
499
+ including specific functions/classes to use as examples and utility functions to reuse
500
+ - **Design Patterns & Best Practices**: Link to specific design pattern documentation
501
+ (e.g., https://refactoring.guru/design-patterns/strategy for Strategy pattern)
502
+ - **Domain knowledge**: All naming conventions, error handling patterns,
503
+ logging standards, performance considerations
504
+
505
+ **CRITICAL REQUIREMENTS:**
506
+ - **STORY SCOPE ONLY**: Focus exclusively on code relevant to the story
507
+ - **COMPLETE COVERAGE**: Every file and method involved must be documented
508
+ - **EXACT IMPLEMENTATIONS**: Include actual code snippets with file paths and line numbers
509
+ - **CODING STANDARDS FIRST**: Verify ALL analysis against coding standards
510
+ - **NO ASSUMPTIONS**: Only document what you actually find in the code
511
+ </step>
512
+
513
+ <!-- ══════════════════════════════════════════════════════════════════ -->
514
+ <!-- STEP 8: WRITE OUTPUT -->
515
+ <!-- ══════════════════════════════════════════════════════════════════ -->
516
+
517
+ <step name="write-output" order="8">
518
+
519
+ Write the complete analysis to `{OUTPUT_FILE}` following the template's
520
+ `<output-format>` section exactly. Include ALL sections:
521
+
522
+ 1. Header (story, date, metrics)
523
+ 2. Use Case Overview
524
+ 3. Architecture Compatibility (layer-by-layer analysis)
525
+ 4. Existing Patterns to Follow (with file references)
526
+ 5. Required Refactoring (even if "none needed")
527
+ 6. CRITICAL: Hardcoded Values & Placeholder Code (with actual code snippets)
528
+ 7. Integration Points (all touchpoints with existing system)
529
+ 8. Impact Analysis (all affected flows and components)
530
+ 9. Implementation Guidelines (step-by-step approach)
531
+ 10. Testing Strategy (preserving existing tests)
532
+ 11. Complete Analysis Findings
533
+ 12. Implementation References (internal docs, code refs, patterns)
534
+ 13. AI Implementation Context (complete context for executing agent)
535
+
536
+ Use the Write tool to create the file. Include all findings from step 7.
537
+
538
+ This is NOT a summary — it is a COMPLETE INTEGRATION ANALYSIS. Every section
539
+ must contain actual code snippets, file paths with line numbers, and
540
+ concrete implementation details.
541
+
542
+ Display:
543
+ ```
544
+ + Analysis written to {OUTPUT_FILE}
545
+ ```
546
+ </step>
547
+
548
+ <!-- ══════════════════════════════════════════════════════════════════ -->
549
+ <!-- STEP 9: VALIDATION -->
550
+ <!-- ══════════════════════════════════════════════════════════════════ -->
551
+
552
+ <step name="validation" order="9">
553
+
554
+ Read the output file and verify against the validation checklist
555
+ defined in the template (story-integration-solution.xml):
556
+
557
+ **File Creation Requirements:**
558
+ - [ ] Analysis file created at {OUTPUT_FILE}
559
+ - [ ] Story directory exists
560
+ - [ ] File contains all required sections from template
561
+
562
+ **Content Requirements — Core Analysis:**
563
+ - [ ] Tree structure showing current codebase structure
564
+ - [ ] Tree structure showing proposed changes with new files
565
+ - [ ] Architecture compatibility analysis completed (layer-by-layer)
566
+ - [ ] All existing patterns identified with file references
567
+ - [ ] Integration points clearly documented
568
+ - [ ] Impact analysis showing affected components
569
+
570
+ **Architecture Analysis Requirements:**
571
+ - [ ] Clean Architecture compliance verified
572
+ - [ ] Dependency injection strategy documented
573
+ - [ ] Design patterns identified and documented
574
+ - [ ] Coding standards compliance verified
575
+ - [ ] Testing strategy that preserves existing tests
576
+
577
+ **Hardcoded Values & Placeholder Discovery (CRITICAL!):**
578
+ - [ ] Searched for hardcoded domain/range values
579
+ - [ ] Searched for placeholder/TODO comments related to the feature
580
+ - [ ] Identified ALL renderers/handlers that should use the new entity but don't
581
+ - [ ] Identified ALL manager/service classes with hardcoded defaults
582
+ - [ ] Found disconnected wiring (entity exists but not injected where needed)
583
+ - [ ] Hardcoded values section filled with ACTUAL CODE SNIPPETS (not placeholders!)
584
+ - [ ] Every hardcoded value includes: file path, line number, current code, fix required
585
+
586
+ **Refactoring Requirements:**
587
+ - [ ] Refactoring analysis completed (even if "no refactoring needed")
588
+ - [ ] Implementation guidelines provided
589
+ - [ ] Testing strategy documented
590
+ - [ ] Risk mitigation considered
591
+
592
+ **Total: 22 mandatory checklist items**
593
+
594
+ If the output is incomplete or missing sections, go back and fill in
595
+ the missing content before proceeding.
596
+
597
+ Display:
598
+ ```
599
+ {check_mark} Analysis validated. {passed}/{total} checks passed.
600
+ ```
601
+ </step>
602
+
603
+ <!-- ══════════════════════════════════════════════════════════════════ -->
604
+ <!-- STEP 10: REVIEW AND APPROVE -->
605
+ <!-- ══════════════════════════════════════════════════════════════════ -->
606
+
607
+ <step name="review" order="10">
608
+
609
+ Display a summary of the analysis:
610
+ ```
611
+ Analysis Summary:
612
+ ────────
613
+ Sections: {count}/13 | Checklist: {passed}/22
614
+ Wiki docs loaded: {N} | Code references: {M}
615
+ Hardcoded values found: {H} | Refactoring items: {R}
616
+ ```
617
+
618
+ Use AskUserQuestion:
619
+ - header: "Analysis"
620
+ - question: "Integration analysis written to `{OUTPUT_FILE}`. Review the file in your editor — does the analysis look comprehensive?"
621
+ - options:
622
+ - "Approve" — Looks good, commit it
623
+ - "Refine" — Some sections need more depth
624
+ - "Skip commit" — Keep the file but don't commit yet
625
+
626
+ **If "Approve":**
627
+ Continue to step 11.
628
+
629
+ **If "Refine":**
630
+ - Ask what sections need more depth or what's missing
631
+ - Go back to the relevant analysis phase, read more code, and update OUTPUT_FILE
632
+ - Re-run validation (step 9)
633
+ - Present for review again
634
+
635
+ **If "Skip commit":**
636
+ Display completion without commit:
637
+ ```
638
+ ╔══════════════════════════════════════════════════╗
639
+ ║ ACE > Integration Analysis Complete (uncommitted)║
640
+ ║ {Story ID} "{Story Title}" ║
641
+ ╚══════════════════════════════════════════════════╝
642
+
643
+ i Analysis written to {OUTPUT_FILE}
644
+ File not committed — commit manually when ready.
645
+ ```
646
+ Exit workflow.
647
+ </step>
648
+
649
+ <!-- ══════════════════════════════════════════════════════════════════ -->
650
+ <!-- STEP 11: COMMIT -->
651
+ <!-- ══════════════════════════════════════════════════════════════════ -->
652
+
653
+ <step name="commit" order="11">
654
+
655
+ Stage and commit the analysis file:
656
+
657
+ ```bash
658
+ git add {OUTPUT_FILE}
659
+ ```
660
+
661
+ ```bash
662
+ git commit -m "docs: integration analysis for {Story ID} — {Story Title}"
663
+ ```
664
+
665
+ Display completion:
666
+
667
+ ```
668
+ ╔══════════════════════════════════════════════════╗
669
+ ║ ACE > Integration Analysis Complete ║
670
+ ║ {Story ID} "{Story Title}" ║
671
+ ╚══════════════════════════════════════════════════╝
672
+
673
+ + {OUTPUT_FILE} committed.
674
+
675
+ Metrics:
676
+ ────────
677
+ Wiki docs loaded: {N} | Code references: {M}
678
+ Hardcoded values found: {H} | Refactoring items: {R}
679
+
680
+ i Integration analysis complete. This artifact will be consumed
681
+ by the technical solution (pass 5) when running plan-story.
682
+
683
+ Next > Continue with story refinement:
684
+ - Technical solution (pass 5)
685
+ > /ace:research-integration-solution story=...
686
+ Analyze another story's codebase integration.
687
+ ```
688
+ </step>
689
+
690
+ </process>
691
+
692
+ <success_criteria>
693
+ - Story loaded and requirements extracted (User Story, Description, Acceptance Criteria)
694
+ - All wiki references extracted from story's Relevant Wiki section
695
+ - All wiki documents loaded (system-wide mandatory, subsystem as referenced)
696
+ - Parent feature document loaded for broader context (if available)
697
+ - External analysis loaded if present in story directory (auto-detected)
698
+ - Output path resolved from story context
699
+ - All 4 analysis phases executed directly (18 mandatory items completed)
700
+ - Analysis file written with ALL template sections populated
701
+ - NO assumptions made — all findings backed by actual code references
702
+ - Hardcoded values section filled with ACTUAL CODE SNIPPETS
703
+ - Refactoring analysis completed (even if "no refactoring needed")
704
+ - Coding standards compliance verified throughout
705
+ - All 22 validation checklist items verified
706
+ - User reviewed and approved the analysis
707
+ - Document committed with appropriate message
708
+ - No modifications made to the story file or GitHub issues
709
+ </success_criteria>
710
+
711
+ </workflow>