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