id3-cli 0.9.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 (114) hide show
  1. package/README.ja-JP.md +769 -0
  2. package/README.ko-KR.md +769 -0
  3. package/README.md +769 -0
  4. package/README.tr-TR.md +769 -0
  5. package/README.zh-CN.md +769 -0
  6. package/dist/bin/cli.d.ts +2 -0
  7. package/dist/bin/cli.js +40 -0
  8. package/dist/bin/cli.js.map +1 -0
  9. package/dist/scripts/build-hooks.d.ts +1 -0
  10. package/dist/scripts/build-hooks.js +58 -0
  11. package/dist/scripts/build-hooks.js.map +1 -0
  12. package/dist/src/hooks/auto-audit.d.ts +4 -0
  13. package/dist/src/hooks/auto-audit.js +47 -0
  14. package/dist/src/hooks/auto-audit.js.map +1 -0
  15. package/dist/src/hooks/claude-pretool-entry.d.ts +1 -0
  16. package/dist/src/hooks/claude-pretool-entry.js +36 -0
  17. package/dist/src/hooks/claude-pretool-entry.js.map +1 -0
  18. package/dist/src/hooks/claude-stop-entry.d.ts +1 -0
  19. package/dist/src/hooks/claude-stop-entry.js +7 -0
  20. package/dist/src/hooks/claude-stop-entry.js.map +1 -0
  21. package/dist/src/hooks/post-commit-entry.d.ts +1 -0
  22. package/dist/src/hooks/post-commit-entry.js +7 -0
  23. package/dist/src/hooks/post-commit-entry.js.map +1 -0
  24. package/dist/src/hooks/pre-commit-entry.d.ts +1 -0
  25. package/dist/src/hooks/pre-commit-entry.js +16 -0
  26. package/dist/src/hooks/pre-commit-entry.js.map +1 -0
  27. package/dist/src/hooks/rule-check.d.ts +8 -0
  28. package/dist/src/hooks/rule-check.js +101 -0
  29. package/dist/src/hooks/rule-check.js.map +1 -0
  30. package/dist/src/hooks/schema-drift.d.ts +17 -0
  31. package/dist/src/hooks/schema-drift.js +151 -0
  32. package/dist/src/hooks/schema-drift.js.map +1 -0
  33. package/dist/src/hooks/shared.d.ts +43 -0
  34. package/dist/src/hooks/shared.js +98 -0
  35. package/dist/src/hooks/shared.js.map +1 -0
  36. package/dist/src/init.d.ts +20 -0
  37. package/dist/src/init.js +193 -0
  38. package/dist/src/init.js.map +1 -0
  39. package/dist/src/preview/mockup-generator.d.ts +56 -0
  40. package/dist/src/preview/mockup-generator.js +402 -0
  41. package/dist/src/preview/mockup-generator.js.map +1 -0
  42. package/dist/src/preview/renderer.d.ts +30 -0
  43. package/dist/src/preview/renderer.js +145 -0
  44. package/dist/src/preview/renderer.js.map +1 -0
  45. package/dist/src/preview/server.d.ts +9 -0
  46. package/dist/src/preview/server.js +55 -0
  47. package/dist/src/preview/server.js.map +1 -0
  48. package/dist/src/preview/ui-auditor.d.ts +27 -0
  49. package/dist/src/preview/ui-auditor.js +141 -0
  50. package/dist/src/preview/ui-auditor.js.map +1 -0
  51. package/dist/src/preview/ui-gate.d.ts +66 -0
  52. package/dist/src/preview/ui-gate.js +210 -0
  53. package/dist/src/preview/ui-gate.js.map +1 -0
  54. package/dist/src/utils/ascii.d.ts +7 -0
  55. package/dist/src/utils/ascii.js +41 -0
  56. package/dist/src/utils/ascii.js.map +1 -0
  57. package/dist/src/utils/fs.d.ts +6 -0
  58. package/dist/src/utils/fs.js +39 -0
  59. package/dist/src/utils/fs.js.map +1 -0
  60. package/dist/templates/hooks/iddd-auto-audit.js +121 -0
  61. package/dist/templates/hooks/iddd-schema-drift.js +279 -0
  62. package/dist/templates/hooks/post-commit +121 -0
  63. package/dist/templates/hooks/pre-commit +348 -0
  64. package/package.json +37 -0
  65. package/templates/.agents/skills/.gitkeep +0 -0
  66. package/templates/.claude/hooks/.gitkeep +0 -0
  67. package/templates/.claude/hooks/hook-config.json +34 -0
  68. package/templates/.claude/skills/.gitkeep +0 -0
  69. package/templates/.codex/.gitkeep +0 -0
  70. package/templates/.codex/hooks.json +40 -0
  71. package/templates/.iddd/commit-count +1 -0
  72. package/templates/.iddd/preview/.gitkeep +0 -0
  73. package/templates/AGENTS.md +204 -0
  74. package/templates/CLAUDE.md +215 -0
  75. package/templates/README.md +476 -0
  76. package/templates/docs/.gitkeep +0 -0
  77. package/templates/docs/business-rules.md +14 -0
  78. package/templates/docs/domain-glossary.md +8 -0
  79. package/templates/docs/info-debt.md +17 -0
  80. package/templates/docs/model-changelog.md +12 -0
  81. package/templates/hooks/.gitkeep +0 -0
  82. package/templates/hooks/iddd-auto-audit.js +121 -0
  83. package/templates/hooks/iddd-schema-drift.js +279 -0
  84. package/templates/hooks/post-commit +121 -0
  85. package/templates/hooks/pre-commit +348 -0
  86. package/templates/skills/id3-design-information/SKILL.md +170 -0
  87. package/templates/skills/id3-design-information/references/phase2-procedure.md +241 -0
  88. package/templates/skills/id3-design-ui/.gitkeep +0 -0
  89. package/templates/skills/id3-design-ui/SKILL.md +200 -0
  90. package/templates/skills/id3-design-ui/references/.gitkeep +0 -0
  91. package/templates/skills/id3-design-ui/references/step1-structure-derivation.md +177 -0
  92. package/templates/skills/id3-design-ui/references/step2-visual-contract.md +257 -0
  93. package/templates/skills/id3-design-ui/references/step3-gate-and-mockup.md +177 -0
  94. package/templates/skills/id3-design-ui/references/step4-implementation.md +244 -0
  95. package/templates/skills/id3-identify-entities/SKILL.md +239 -0
  96. package/templates/skills/id3-identify-entities/references/.gitkeep +0 -0
  97. package/templates/skills/id3-identify-entities/references/phase0-brownfield.md +377 -0
  98. package/templates/skills/id3-identify-entities/references/phase1-greenfield.md +319 -0
  99. package/templates/skills/id3-info-audit/.gitkeep +0 -0
  100. package/templates/skills/id3-info-audit/SKILL.md +191 -0
  101. package/templates/skills/id3-preview/.gitkeep +0 -0
  102. package/templates/skills/id3-preview/SKILL.md +168 -0
  103. package/templates/skills/id3-spawn-team/.gitkeep +0 -0
  104. package/templates/skills/id3-spawn-team/SKILL.md +213 -0
  105. package/templates/specs/.gitkeep +0 -0
  106. package/templates/specs/data-model.md +26 -0
  107. package/templates/specs/entity-catalog.md +22 -0
  108. package/templates/specs/ui-design-contract.md +54 -0
  109. package/templates/specs/ui-inventory.md +24 -0
  110. package/templates/specs/ui-structure.md +32 -0
  111. package/templates/src/.gitkeep +0 -0
  112. package/templates/steering/.gitkeep +0 -0
  113. package/templates/steering/data-conventions.md +42 -0
  114. package/templates/steering/product.md +38 -0
@@ -0,0 +1,241 @@
1
+ # Phase 2: Detailed Step-by-Step Procedure
2
+
3
+ This document provides the full procedural detail for Phase 2 (Information Design). The parent `SKILL.md` contains the overview; refer here for implementation-level instructions.
4
+
5
+ ---
6
+
7
+ ## Step 1: Attribute Refinement (Detailed)
8
+
9
+ ### 1.1 Read Current State
10
+
11
+ 1. Read `specs/entity-catalog.md` to load all entities and their current attribute definitions.
12
+ 2. Read `steering/data-conventions.md` to load project-specific naming and typing conventions.
13
+ 3. Note which attributes already have concrete types (from Phase 0 brownfield extraction) vs. those that are still abstract.
14
+
15
+ ### 1.2 Assign Data Types
16
+
17
+ For each entity, for each attribute:
18
+
19
+ | Abstract Type | Concrete Type (default) | Notes |
20
+ |---|---|---|
21
+ | identifier / ID | UUID (v7) | Time-sortable; override with BIGINT if convention says auto-increment |
22
+ | short text | VARCHAR(N) | Determine max length from domain context |
23
+ | long text | TEXT | No length limit |
24
+ | number (integer) | INTEGER or BIGINT | Use BIGINT for counters that may exceed 2^31 |
25
+ | number (decimal) | DECIMAL(p,s) | Use for money, measurements; never FLOAT for money |
26
+ | boolean | BOOLEAN | |
27
+ | date | DATE | Date only, no time |
28
+ | datetime | TIMESTAMP WITH TIME ZONE | Always store in UTC |
29
+ | enumeration | ENUM or reference table | 3 or fewer fixed values -> ENUM; otherwise reference table |
30
+ | JSON / flexible | JSONB | Only for frequently changing metadata; normalize if searchable |
31
+ | binary / file | TEXT (URL/key) | Store reference, not binary data |
32
+
33
+ ### 1.3 Add Constraints
34
+
35
+ For each attribute, determine:
36
+
37
+ - **NOT NULL**: Is this field required? If yes, add NOT NULL.
38
+ - **DEFAULT**: Does this field have a sensible default? (e.g., `status` defaults to `'draft'`, `created_at` defaults to `NOW()`)
39
+ - **UNIQUE**: Must values be unique? (e.g., email, slug, code)
40
+ - **CHECK**: Are there value range or format constraints? (e.g., `price >= 0`, `rating BETWEEN 1 AND 5`)
41
+
42
+ ### 1.4 Evaluate Index Needs
43
+
44
+ Apply these rules:
45
+
46
+ 1. **Primary key**: Automatically indexed (no action needed).
47
+ 2. **Foreign keys**: Add index on every FK column.
48
+ 3. **UNIQUE constraints**: Automatically create unique index.
49
+ 4. **Search targets**: If the attribute is used for search (e.g., `name`, `title`), add a regular index; consider GIN index for full-text search on TEXT columns.
50
+ 5. **Frequently filtered**: If the attribute appears in WHERE clauses regularly (e.g., `status`, `type`, `tenant_id`), add an index.
51
+ 6. **Composite indexes**: If queries frequently filter on multiple columns together, consider composite indexes.
52
+
53
+ Document index decisions in `specs/data-model.md` under "Index Strategy".
54
+
55
+ ### 1.5 Apply Timestamp Conventions
56
+
57
+ Ensure every entity has:
58
+
59
+ - `created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()`
60
+ - `updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()`
61
+
62
+ If soft delete applies to this entity (determined in Step 4):
63
+ - `deleted_at TIMESTAMP WITH TIME ZONE` (nullable)
64
+
65
+ ---
66
+
67
+ ## Step 2: Relationship Concretization (Detailed)
68
+
69
+ ### 2.1 FK Placement Rules
70
+
71
+ | Relationship | FK Location | Rationale |
72
+ |---|---|---|
73
+ | 1:1 mandatory | Either side (prefer the dependent entity) | The entity that cannot exist without the other holds the FK |
74
+ | 1:1 optional | The optional side | Avoids NULL FK on the mandatory side |
75
+ | 1:N | The "many" side | Standard normalization |
76
+ | N:M | Junction table | Both FKs in the junction table |
77
+
78
+ ### 2.2 Delete and Update Rules
79
+
80
+ For each FK, specify:
81
+
82
+ | Rule | When to Use |
83
+ |---|---|
84
+ | CASCADE | Child has no meaning without parent (e.g., OrderLineItem when Order is deleted) |
85
+ | SET NULL | Child can exist independently but loses its association (e.g., Task.assignee when User is deleted) |
86
+ | RESTRICT | Deletion should be prevented if children exist (e.g., Category with Products) |
87
+ | SET DEFAULT | Rare; child reverts to a default parent |
88
+
89
+ ### 2.3 Junction Table Design
90
+
91
+ For each N:M relationship:
92
+
93
+ 1. Name the junction table: `{entity_a}_{entity_b}` (alphabetical order) or a domain-specific name if one exists (e.g., `enrollment` for Student-Course).
94
+ 2. Columns:
95
+ - `{entity_a}_id` FK NOT NULL
96
+ - `{entity_b}_id` FK NOT NULL
97
+ - Composite unique index on both FK columns
98
+ - `created_at` timestamp
99
+ - Any additional attributes specific to the relationship (e.g., `role`, `quantity`, `start_date`)
100
+ 3. Delete rule: Usually CASCADE on both FKs (removing either entity removes the association).
101
+
102
+ ### 2.4 Update the ERD
103
+
104
+ After all FK decisions are made, update the Mermaid ERD in `specs/data-model.md` to reflect:
105
+
106
+ - FK columns shown on the correct side
107
+ - Junction tables included
108
+ - Cardinality notation (||--o{, }o--o{, etc.)
109
+
110
+ ---
111
+
112
+ ## Step 3: Business Rule Auto-Derivation (Detailed)
113
+
114
+ ### 3.1 Systematic Scan Process
115
+
116
+ Process entities in alphabetical order. For each entity:
117
+
118
+ 1. **Scan constraints**: NOT NULL -> required rule, UNIQUE -> uniqueness rule, CHECK -> range/format rule
119
+ 2. **Scan FKs**: For each FK, derive a referential integrity rule based on the delete/update rule
120
+ 3. **Scan ENUMs**: For each ENUM attribute, derive a validity domain rule
121
+ 4. **Scan state transitions**: If the entity has a `status` or `state` attribute with ENUM values, derive allowed transition paths. Ask the user to confirm the state machine if not already defined.
122
+ 5. **Scan derived attributes**: If any attribute is computed from others (e.g., `total`, `full_name`, `age`), derive a computation rule.
123
+
124
+ ### 3.2 Rule Numbering
125
+
126
+ - Use sequential numbering: BR-001, BR-002, BR-003, ...
127
+ - If Phase 0/1 already defined some rules, continue from the last number.
128
+ - Do not renumber existing rules.
129
+
130
+ ### 3.3 Rule Documentation Format
131
+
132
+ For each rule, write to `docs/business-rules.md`:
133
+
134
+ ```markdown
135
+ ### BR-NNN: [Rule Name]
136
+ - **Entity**: [Related entity or entities]
137
+ - **Type**: constraint | derivation | transition | validity
138
+ - **Description**: [Clear, unambiguous rule statement]
139
+ - **Enforcement**: DB constraint | application logic | both
140
+ - **Implementation**: [Specific implementation approach, e.g., "NOT NULL on users.email column" or "Zod schema validation in create-user handler"]
141
+ ```
142
+
143
+ ### 3.4 Cross-Entity Rules
144
+
145
+ Some rules span multiple entities:
146
+
147
+ - **Cascading constraints**: "Deleting a Project cascades to all its Tasks and Comments"
148
+ - **Aggregate rules**: "Order.total must equal the sum of all LineItem.subtotal values"
149
+ - **Cross-reference rules**: "A User cannot be both the author and reviewer of the same Document"
150
+
151
+ These require explicit documentation since they cannot be enforced by a single column constraint.
152
+
153
+ ### 3.5 Conflict Resolution
154
+
155
+ If an auto-derived rule conflicts with an existing rule from Phase 0/1:
156
+
157
+ 1. Flag the conflict to the user.
158
+ 2. Present both versions.
159
+ 3. Let the user decide which to keep.
160
+ 4. Update `docs/info-debt.md` if the conflict reveals a design issue.
161
+
162
+ ---
163
+
164
+ ## Step 4: Design Decision Questions (Detailed)
165
+
166
+ ### 4.1 Question Categories
167
+
168
+ Present these categories to the user. Skip categories that are clearly not applicable.
169
+
170
+ **Category A -- Storage Strategy:**
171
+ - Are there attributes that store large binary data (images, files, PDFs)?
172
+ - Should these be stored inline (JSONB/BYTEA) or in external storage (S3, GCS)?
173
+ - What is the expected size range?
174
+
175
+ **Category B -- Soft Delete:**
176
+ - Which entities should support soft delete (`deleted_at` pattern)?
177
+ - General rule: entities with audit requirements or user-facing data should use soft delete; internal/transient entities can use hard delete.
178
+ - Soft delete implications: all queries must filter `WHERE deleted_at IS NULL`.
179
+
180
+ **Category C -- Multi-Tenancy:**
181
+ - Does the application serve multiple tenants?
182
+ - If yes: row-level isolation (`tenant_id` column on every table) or schema-level isolation?
183
+ - Which entities are tenant-scoped vs. global?
184
+
185
+ **Category D -- Audit Trail:**
186
+ - Which entities need change history (who changed what field, when)?
187
+ - Implementation options: audit log table, event sourcing, temporal tables.
188
+ - Minimum: `updated_by` column. Maximum: full audit log with before/after snapshots.
189
+
190
+ **Category E -- Project-Specific:**
191
+ - Any domain-specific architectural choices not covered above?
192
+ - Examples: versioning strategy, approval workflows, notification triggers.
193
+
194
+ ### 4.2 Recording Decisions
195
+
196
+ For each decision, add to `specs/data-model.md`:
197
+
198
+ ```markdown
199
+ | D-NN | [Topic] | [Choice] | [Rationale] | YYYY-MM-DD |
200
+ ```
201
+
202
+ Apply decisions immediately: add `deleted_at` columns, `tenant_id` columns, audit columns, etc., to the entity catalog and ERD.
203
+
204
+ ---
205
+
206
+ ## Step 5: Artifact Updates (Detailed)
207
+
208
+ ### 5.1 Update Order
209
+
210
+ Update artifacts in this specific order to maintain consistency:
211
+
212
+ 1. `specs/entity-catalog.md` -- Add all refined attributes, types, constraints
213
+ 2. `specs/data-model.md` -- Update ERD, add junction tables, index strategy, design decisions
214
+ 3. `docs/business-rules.md` -- Add all derived rules
215
+
216
+ ### 5.2 Entity Catalog Update Checklist
217
+
218
+ For each entity, verify:
219
+
220
+ - [ ] All attributes have concrete data types
221
+ - [ ] NOT NULL / DEFAULT / UNIQUE constraints are specified
222
+ - [ ] Index needs are documented
223
+ - [ ] `created_at` and `updated_at` are present
224
+ - [ ] Soft delete column added (if applicable per D-xx decision)
225
+ - [ ] Tenant column added (if applicable per D-xx decision)
226
+ - [ ] Audit columns added (if applicable per D-xx decision)
227
+ - [ ] All relationships list FK column, cardinality, and delete rule
228
+
229
+ ### 5.3 Data Model Update Checklist
230
+
231
+ - [ ] Mermaid ERD reflects all entities, attributes, and relationships
232
+ - [ ] Junction tables are included in ERD
233
+ - [ ] Index strategy section is populated
234
+ - [ ] Design decisions table is populated
235
+
236
+ ### 5.4 Business Rules Update Checklist
237
+
238
+ - [ ] All auto-derived rules are numbered sequentially
239
+ - [ ] Each rule has entity, type, description, enforcement, and implementation fields
240
+ - [ ] Cross-entity rules are documented
241
+ - [ ] No duplicate or conflicting rules exist
File without changes
@@ -0,0 +1,200 @@
1
+ ---
2
+ name: id3-design-ui
3
+ description: >
4
+ Design and implement UI from the information model. Derives screen structure
5
+ from entities, establishes visual design contracts, generates HTML mockups
6
+ for review, and implements screens via Agent Teams.
7
+ Trigger: design ui, ui design, screen design, frontend design, implement ui,
8
+ Phase 2.5, information representation
9
+ allowed-tools: Read, Glob, Grep, Bash, Write, Edit
10
+ user-invocable: true
11
+ ---
12
+
13
+ # Phase 2.5: UI Design and Implementation
14
+
15
+ You are the lead agent performing IDDD Phase 2.5 -- Information Representation. This phase derives UI structure from the information model, establishes a visual design contract, validates through a 7-Pillar quality gate with mockup preview, and implements screens via Agent Teams.
16
+
17
+ **Core principle:** Every UI element traces back to an Entity, Attribute, or Business Rule. There is no guessing -- screens and widgets are derived from the information model.
18
+
19
+ ## Prerequisites
20
+
21
+ Before starting, verify all of the following:
22
+
23
+ 1. `specs/entity-catalog.md` exists with version >= `"1.0"` (Phase 2 complete).
24
+ 2. `specs/data-model.md` exists with a finalized Mermaid ERD.
25
+ 3. `docs/business-rules.md` exists with confirmed BR-xxx rules.
26
+ 4. `steering/data-conventions.md` exists with naming/typing conventions.
27
+
28
+ If prerequisites are **not** met, respond:
29
+
30
+ > "Please complete Phase 2 (information design) first. Use 'design information' to start."
31
+
32
+ Do **not** proceed until all prerequisites are confirmed.
33
+
34
+ ---
35
+
36
+ ## 4-Step Pipeline
37
+
38
+ ```
39
+ Step 1: UI Structure Derivation [Lead, conversational]
40
+ Step 2: Visual Design Contract [Lead, conversational]
41
+ Step 3: Pre-Implementation Gate [Automated + user approval]
42
+ Step 4: Implementation + Post-Audit [Agent Teams]
43
+ ```
44
+
45
+ Execute each step sequentially. Steps 1-3 are performed by the lead agent with user interaction. Step 4 spawns Agent Teams for parallel implementation.
46
+
47
+ ---
48
+
49
+ ## Step 1: UI Structure Derivation
50
+
51
+ Automatically derive screen structure from the information model, then refine with the user.
52
+
53
+ ### Procedure
54
+
55
+ 1. **Read inputs:** Load `specs/entity-catalog.md`, `specs/data-model.md`, `docs/business-rules.md`, and `specs/ui-inventory.md` (if brownfield).
56
+ 2. **Apply 9 Entity-to-Screen derivation rules** to generate the screen inventory. Every entity produces at least a List View. Additional screens (Detail, Create, Edit, Dashboard, Child Tab, Association Manager) are derived from entity characteristics.
57
+ 3. **Apply 12 Attribute-to-Widget mapping rules** to determine the widget type for each attribute based on its data type, constraints, and metadata.
58
+ 4. **Apply "Output First" principle:** Arrange dashboards and reports before input forms. Design navigation from dashboard to list to detail to form.
59
+ 5. **Brownfield change analysis** (if `ui-inventory.md` exists): Compare current UI inventory against derived screens. Classify differences as New, Modified, Deleted, or Restructured.
60
+ 6. **Present derivation results to user:** Show the derived screen inventory and ask the user to confirm, remove, or add screens.
61
+ 7. **Write `specs/ui-structure.md`** with the finalized screen inventory, entity-screen traceability matrix, navigation structure (Mermaid graph), and brownfield change summary.
62
+
63
+ **For detailed derivation rules and output format, see:** `references/step1-structure-derivation.md`
64
+
65
+ ---
66
+
67
+ ## Step 2: Visual Design Contract
68
+
69
+ Detect the existing frontend stack and establish design tokens with the user.
70
+
71
+ ### Procedure
72
+
73
+ 1. **Scan the project** for frontend framework indicators (package.json, config files, file extensions). Detect React, Vue, Svelte, Next.js, Nuxt, Tailwind, shadcn/ui, Radix, MUI, or greenfield.
74
+ 2. **Confirm with user:** Present the detected stack and ask for confirmation. If greenfield, present options.
75
+ 3. **Establish 5 design token areas:**
76
+ - Spacing Scale (8-point grid default)
77
+ - Typography Scale (4 levels: Display, Heading, Body, Caption)
78
+ - Color System (60/30/10 ratio: Surface, Secondary, Accent + Semantic)
79
+ - Copywriting Standards (CTA patterns, empty states, error messages, danger actions)
80
+ - Component Registry (map widgets to actual framework components)
81
+ 4. **Connect Entity Attributes to design tokens:** For each attribute, trace the full path from Entity -> Widget -> Component -> Design Tokens -> Validation Message.
82
+ 5. **Write `specs/ui-design-contract.md`** with tech stack, all design tokens, component mapping, and per-screen design specifications.
83
+
84
+ **For detailed token definitions and output format, see:** `references/step2-visual-contract.md`
85
+
86
+ ---
87
+
88
+ ## Step 3: Pre-Implementation Gate + Visual Mockup Review
89
+
90
+ Validate the design artifacts and generate HTML mockups for user approval before implementation.
91
+
92
+ ### Procedure
93
+
94
+ 1. **Run 7-Pillar verification** against `specs/ui-structure.md` and `specs/ui-design-contract.md`:
95
+
96
+ | # | Pillar | PASS condition |
97
+ |---|--------|----------------|
98
+ | 1 | Structure Completeness | Every entity has at least 1 screen mapped |
99
+ | 2 | Spacing | All values are multiples of the spacing scale |
100
+ | 3 | Typography | 4 or fewer sizes, 2 or fewer weights |
101
+ | 4 | Color | Accent defined with usage, semantic 4 colors present |
102
+ | 5 | Copywriting | CTA/empty/error/danger patterns defined, no generic text |
103
+ | 6 | Component Registry | Every widget mapped to a component with import path |
104
+ | 7 | Traceability | Every screen has entity source, every widget has attribute source |
105
+
106
+ If any pillar is BLOCKED, fix the issue before proceeding.
107
+
108
+ 2. **Generate mockup HTML files** at 3 fidelity levels (Wireframe, Styled, Interactive) with auto-generated sample data. Write to `.iddd/preview/mockup-index.html` and `.iddd/preview/mockup-{entity}.html`.
109
+ 3. **Start preview server** and display the URL for the user to review.
110
+ 4. **Wait for user approval:**
111
+ - `approve` -> proceed to Step 4
112
+ - `reject` + feedback -> incorporate changes, regenerate mockups, request approval again
113
+
114
+ **For detailed gate rules and mockup generation, see:** `references/step3-gate-and-mockup.md`
115
+
116
+ ---
117
+
118
+ ## Step 4: Implementation + Post-Audit
119
+
120
+ Spawn Agent Teams for parallel screen implementation, then perform a visual audit.
121
+
122
+ ### Procedure
123
+
124
+ 1. **Divide tasks by entity:** Each team member implements 1-3 entity screen groups. Common layout (header, sidebar, navigation) is assigned to the first team member.
125
+ 2. **Spawn Agent Teams:**
126
+ - `ui-implementer-N` (1 per entity group): Implements screens following ui-structure.md and ui-design-contract.md
127
+ - `ui-reviewer` (1): Verifies design token consistency and traceability across all screens
128
+ 3. **Implementation principles:**
129
+ - Follow component mapping from ui-design-contract.md exactly
130
+ - Apply design tokens via Tailwind classes or CSS variables
131
+ - Add traceability comments linking each UI element to Entity/Attribute/BR-xxx
132
+ - Reflect BR-xxx rules in validation code
133
+ - Atomic commits: one commit per entity screen group
134
+ 4. **Post-implementation visual audit:** After all screens are implemented, start the dev server and compare actual rendering against mockup HTML. Score each pillar 1-4 and identify the top 3 fixes.
135
+ - Average >= 3.0 -> "UI implementation complete"
136
+ - Average < 3.0 -> Apply top 3 fixes, then re-audit
137
+
138
+ **For detailed team composition and audit criteria, see:** `references/step4-implementation.md`
139
+
140
+ ---
141
+
142
+ ## Artifacts Produced
143
+
144
+ | File | Status | Content |
145
+ |------|--------|---------|
146
+ | `specs/ui-structure.md` | Created | Screen inventory, traceability matrix, navigation graph |
147
+ | `specs/ui-design-contract.md` | Created | Tech stack, design tokens, component mapping |
148
+ | `.iddd/ui-gate-result.md` | Created | 7-Pillar verification results |
149
+ | `.iddd/preview/mockup-index.html` | Created | Mockup index page with navigation |
150
+ | `.iddd/preview/mockup-{entity}.html` | Created | Per-entity mockups (3 fidelity levels) |
151
+ | `.iddd/preview/ui-audit.html` | Created | Post-implementation visual audit dashboard |
152
+
153
+ ---
154
+
155
+ ## Preview Integration
156
+
157
+ After completing Steps 1-3 and generating mockup HTML files:
158
+
159
+ 1. **Start preview server** with mockup files in `.iddd/preview/`. The server serves all files from the `.iddd/preview/` directory.
160
+ 2. **Display the URL** so the user can review mockups in their browser. The mockup index page provides navigation across all entity mockups with fidelity level tabs.
161
+ 3. **Traceability panel** at the bottom of each mockup shows Entity/Attribute/BR-xxx source and design token values applied. This is the IDDD differentiator -- every visual element has a traceable origin.
162
+
163
+ Use `/id3-preview` to manually start or restart the preview server at any time.
164
+
165
+ ---
166
+
167
+ ## Version Header Update
168
+
169
+ Upon completion of all 4 steps, update YAML frontmatter in `specs/ui-structure.md`:
170
+
171
+ ```yaml
172
+ ---
173
+ version: "1.0"
174
+ derived_from: "entity-catalog.md v1.0"
175
+ screen_count: N
176
+ entity_coverage: "X/X (100%)"
177
+ audit_status: "clean"
178
+ ---
179
+ ```
180
+
181
+ Add an entry to `docs/model-changelog.md`:
182
+
183
+ ```markdown
184
+ ## [1.1] -- YYYY-MM-DD
185
+ ### Phase 2.5 Complete
186
+ - N screens derived from M entities
187
+ - Visual design contract established
188
+ - 7-Pillar gate passed
189
+ - K screens implemented
190
+ ```
191
+
192
+ ---
193
+
194
+ ## Completion Message
195
+
196
+ When all four steps are finished, display:
197
+
198
+ > "UI design and implementation complete. N screens derived from M entities, 7-Pillar gate passed, K screens implemented with audit score X.X. Proceed to Phase 3-5 (/id3-spawn-team) for backend implementation."
199
+
200
+ Replace N, M, K, X.X with actual values from the session.
@@ -0,0 +1,177 @@
1
+ # Step 1: UI Structure Derivation
2
+
3
+ This reference details how to derive screen structure from the information model. The lead agent executes this step conversationally with the user.
4
+
5
+ ---
6
+
7
+ ## Inputs
8
+
9
+ | File | Purpose |
10
+ |------|---------|
11
+ | `specs/entity-catalog.md` | Entity definitions, attributes, relationships, state transitions |
12
+ | `specs/data-model.md` | ERD with FK relationships and cardinalities |
13
+ | `docs/business-rules.md` | BR-xxx rules for validation and behavior |
14
+ | `specs/ui-inventory.md` | Current UI structure (brownfield only) |
15
+
16
+ ---
17
+
18
+ ## Entity-to-Screen Derivation Rules (9 Rules)
19
+
20
+ Apply these rules to every entity in entity-catalog.md. Each rule produces a screen when its condition is met.
21
+
22
+ | # | Entity Characteristic | Derived Screen | URL Pattern | Derivation Rationale |
23
+ |---|----------------------|----------------|-------------|---------------------|
24
+ | 1 | Entity exists | List View | `/{plural}` | Every entity needs a listing |
25
+ | 2 | PK exists | Detail View | `/{plural}/:id` | PK enables individual retrieval |
26
+ | 3 | NOT NULL attributes (non-PK, non-timestamp) | Create Form | `/{plural}/new` | Required fields imply a creation form |
27
+ | 4 | Mutable attributes (non-PK, non-timestamp) | Edit Form | `/{plural}/:id/edit` | Editable fields imply an update form |
28
+ | 5 | State Transitions defined | Status Dashboard | `/{plural}/dashboard` | Status flow needs a status-oriented view |
29
+ | 6 | 1:N FK (parent side) | Child Tab in Detail | `/{plural}/:id/{child-plural}` | Parent detail shows child listing as tab |
30
+ | 7 | N:M relationship | Association Manager | `/{plural}/:id/{related-plural}/manage` | Many-to-many needs a linking UI |
31
+ | 8 | Derived/computed attribute | Dashboard Widget | _(embedded in dashboard)_ | Aggregated values are visualization candidates |
32
+ | 9 | File/Blob attribute | Upload Widget | _(embedded in create/edit form)_ | File-type attributes need upload UI |
33
+
34
+ ### Pluralization
35
+
36
+ Convert entity name to URL-safe plural form:
37
+ - `User` -> `users`
38
+ - `Category` -> `categories`
39
+ - `Address` -> `addresses`
40
+
41
+ ### Priority Assignment
42
+
43
+ | Priority | Criteria |
44
+ |----------|----------|
45
+ | P1 | List + Detail + Create (core CRUD) |
46
+ | P2 | Edit + Dashboard + Child Tab |
47
+ | P3 | Association Manager + specialized widgets |
48
+
49
+ ---
50
+
51
+ ## Attribute-to-Widget Mapping (12 Rules)
52
+
53
+ For each entity attribute, determine the appropriate UI widget based on data type, constraints, and metadata.
54
+
55
+ | # | Data Type | Widget | Additional Condition |
56
+ |---|-----------|--------|---------------------|
57
+ | 1 | VARCHAR/TEXT (short) | Text Input | max_length <= 200 |
58
+ | 2 | TEXT (long) | Textarea | max_length > 200 or unlimited |
59
+ | 3 | ENUM | Select Dropdown | Options generated from enum values |
60
+ | 4 | BOOLEAN | Toggle/Checkbox | -- |
61
+ | 5 | INTEGER | Number Input | min/max constraints derive validation |
62
+ | 6 | DECIMAL | Number Input | min/max + step from precision |
63
+ | 7 | DATE | Date Picker | -- |
64
+ | 8 | TIMESTAMP | DateTime Picker | -- |
65
+ | 9 | FK (reference) | Autocomplete/Select | Search against referenced entity |
66
+ | 10 | UUID (PK) | Hidden/Read-only | Never shown as editable input |
67
+ | 11 | File Reference | File Upload | -- |
68
+ | 12 | Email/URL/Phone | Specialized Input | Type-specific validation + format mask |
69
+
70
+ ### Constraint-to-Validation Mapping
71
+
72
+ | Constraint | Validation Rule |
73
+ |------------|----------------|
74
+ | NOT NULL | Required field |
75
+ | UNIQUE | Uniqueness check (async) |
76
+ | CHECK (min/max) | Range validation |
77
+ | DEFAULT | Pre-filled value |
78
+ | FK | Referential integrity (select from valid options) |
79
+
80
+ ---
81
+
82
+ ## "Output First" Principle
83
+
84
+ Phase 1 captures the "output image" -- what users ultimately want to see. Use this to drive screen ordering:
85
+
86
+ 1. **Dashboards and reports first.** Place summary views, aggregate displays, and status overviews at the top of the navigation hierarchy.
87
+ 2. **Reverse-trace inputs.** For each dashboard element, identify which entities and attributes feed it. Ensure the input forms that populate those attributes are accessible.
88
+ 3. **Navigation order:** Dashboard -> List -> Detail -> Create/Edit Form. This reflects the user's mental model: overview first, then drill down, then act.
89
+
90
+ ---
91
+
92
+ ## Brownfield Change Analysis
93
+
94
+ When `specs/ui-inventory.md` exists (brownfield project), compare the derived screen inventory against the current UI:
95
+
96
+ | Classification | Condition | Action |
97
+ |---------------|-----------|--------|
98
+ | **New** | Entity has screens derived but no matching current UI | Propose new screens |
99
+ | **Modified** | Entity attributes changed since last UI build | Propose screen modifications (added/removed fields, changed widgets) |
100
+ | **Deleted** | Entity removed from entity-catalog.md | Propose screen removal with redirect |
101
+ | **Restructured** | Relationships changed (FK added/removed) | Propose navigation structure changes |
102
+
103
+ Present the change analysis to the user as a table before finalizing.
104
+
105
+ ---
106
+
107
+ ## User Conversation Procedure
108
+
109
+ After completing automatic derivation:
110
+
111
+ 1. **Show summary:** "Derived N screens from M entities. Here is the screen inventory:"
112
+ 2. **Present the screen inventory table** (Screen, URL, Entity, Pattern, Priority, Source).
113
+ 3. **Ask for confirmation:** "Please review and confirm. Should any screens be added, removed, or re-prioritized?"
114
+ 4. **Collect additions:** Users may request screens not derivable from entities (e.g., Settings, About, Help pages). Record these with Source = "User-requested".
115
+ 5. **Prioritize:** Confirm the final priority ordering with the user.
116
+ 6. **Generate preview** of the navigation structure (Mermaid graph) and display via preview server.
117
+
118
+ ---
119
+
120
+ ## Output: `specs/ui-structure.md`
121
+
122
+ Write the finalized screen inventory to `specs/ui-structure.md` using this format:
123
+
124
+ ```markdown
125
+ ---
126
+ version: "1.0"
127
+ derived_from: "entity-catalog.md v1.0"
128
+ screen_count: N
129
+ entity_coverage: "X/X (100%)"
130
+ ---
131
+
132
+ # UI Structure
133
+
134
+ ## Screen Inventory
135
+
136
+ | Screen | URL | Primary Entity | Pattern | Priority | Source |
137
+ |--------|-----|----------------|---------|----------|--------|
138
+ | User List | /users | User | List | P1 | Auto-derived |
139
+ | User Detail | /users/:id | User | Detail | P1 | Auto-derived |
140
+ | Create User | /users/new | User | Create | P1 | Auto-derived |
141
+ | ...
142
+
143
+ ## Entity-Screen Traceability Matrix
144
+
145
+ | Entity | List | Detail | Create | Edit | Dashboard | Notes |
146
+ |--------|------|--------|--------|------|-----------|-------|
147
+ | User | /users | /users/:id | /users/new | /users/:id/edit | - | |
148
+ | ...
149
+
150
+ ## Navigation Structure
151
+
152
+ ​```mermaid
153
+ graph TD
154
+ Dashboard --> UserList["/users"]
155
+ UserList --> UserDetail["/users/:id"]
156
+ UserDetail --> UserEdit["/users/:id/edit"]
157
+ UserDetail --> UserPosts["/users/:id/posts"]
158
+ Dashboard --> PostList["/posts"]
159
+ ​```
160
+
161
+ ## Change Summary (Brownfield)
162
+
163
+ | Type | Entity | Current | Proposed | Reason |
164
+ |------|--------|---------|----------|--------|
165
+ | New | Payment | - | /payments, /payments/:id | New entity added in Phase 2 |
166
+ | Modified | User | /users (3 cols) | /users (5 cols) | 2 attributes added |
167
+ | ...
168
+ ```
169
+
170
+ ### Completeness Check
171
+
172
+ Before writing the file, verify:
173
+ - [ ] Every entity in entity-catalog.md has at least one screen
174
+ - [ ] Entity coverage is 100%
175
+ - [ ] All relationships are reflected in navigation (child tabs, association managers)
176
+ - [ ] Traceability matrix has no empty rows
177
+ - [ ] Brownfield changes are classified (if applicable)