@tailor-platform/erp-kit 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (213) hide show
  1. package/README.md +196 -28
  2. package/dist/cli.js +894 -0
  3. package/package.json +65 -8
  4. package/rules/app-compose/backend/auth.md +78 -0
  5. package/rules/app-compose/frontend/auth.md +55 -0
  6. package/rules/app-compose/frontend/component.md +55 -0
  7. package/rules/app-compose/frontend/page.md +86 -0
  8. package/rules/app-compose/frontend/screen-detailview.md +112 -0
  9. package/rules/app-compose/frontend/screen-form.md +145 -0
  10. package/rules/app-compose/frontend/screen-listview.md +159 -0
  11. package/rules/app-compose/structure.md +32 -0
  12. package/rules/module-development/commands.md +54 -0
  13. package/rules/module-development/cross-module-type-injection.md +28 -0
  14. package/rules/module-development/dependency-modules.md +24 -0
  15. package/rules/module-development/errors.md +12 -0
  16. package/rules/module-development/executors.md +67 -0
  17. package/rules/module-development/exports.md +13 -0
  18. package/rules/module-development/models.md +34 -0
  19. package/rules/module-development/structure.md +27 -0
  20. package/rules/module-development/sync-vs-async-operations.md +83 -0
  21. package/rules/module-development/testing.md +43 -0
  22. package/rules/sdk-best-practices/db-relations.md +74 -0
  23. package/rules/sdk-best-practices/sdk-docs.md +14 -0
  24. package/schemas/app-compose/actors.yml +34 -0
  25. package/schemas/app-compose/business-flow.yml +50 -0
  26. package/schemas/app-compose/requirements.yml +33 -0
  27. package/schemas/app-compose/resolver.yml +47 -0
  28. package/schemas/app-compose/screen.yml +81 -0
  29. package/schemas/app-compose/story.yml +67 -0
  30. package/schemas/module/command.yml +52 -0
  31. package/schemas/module/feature.yml +58 -0
  32. package/schemas/module/model.yml +70 -0
  33. package/schemas/module/module.yml +50 -0
  34. package/skills/1-module-docs/SKILL.md +107 -0
  35. package/skills/2-module-feature-breakdown/SKILL.md +66 -0
  36. package/skills/3-module-doc-review/SKILL.md +230 -0
  37. package/skills/4-module-tdd-implementation/SKILL.md +56 -0
  38. package/skills/5-module-implementation-review/SKILL.md +400 -0
  39. package/skills/app-compose-1-requirement-analysis/SKILL.md +85 -0
  40. package/skills/app-compose-2-requirements-breakdown/SKILL.md +88 -0
  41. package/skills/app-compose-3-doc-review/SKILL.md +112 -0
  42. package/skills/app-compose-4-design-mock/SKILL.md +248 -0
  43. package/skills/app-compose-5-design-mock-review/SKILL.md +283 -0
  44. package/skills/app-compose-6-implementation-spec/SKILL.md +122 -0
  45. package/skills/mock-scenario/SKILL.md +118 -0
  46. package/src/app.ts +1 -0
  47. package/src/cli.ts +120 -0
  48. package/src/commands/check.test.ts +30 -0
  49. package/src/commands/check.ts +66 -0
  50. package/src/commands/init.test.ts +77 -0
  51. package/src/commands/init.ts +87 -0
  52. package/src/commands/mock/index.ts +53 -0
  53. package/src/commands/mock/start.ts +179 -0
  54. package/src/commands/mock/validate.test.ts +185 -0
  55. package/src/commands/mock/validate.ts +198 -0
  56. package/src/commands/scaffold.test.ts +76 -0
  57. package/src/commands/scaffold.ts +119 -0
  58. package/src/commands/sync-check.test.ts +125 -0
  59. package/src/commands/sync-check.ts +182 -0
  60. package/src/integration.test.ts +63 -0
  61. package/src/mdschema.ts +48 -0
  62. package/src/mockServer.ts +55 -0
  63. package/src/module.ts +86 -0
  64. package/src/modules/accounting/.gitkeep +0 -0
  65. package/src/modules/coa-management/.gitkeep +0 -0
  66. package/src/modules/inventory/.gitkeep +0 -0
  67. package/src/modules/manufacturing/.gitkeep +0 -0
  68. package/src/modules/primitives/README.md +39 -0
  69. package/src/modules/primitives/command/activateCategory.test.ts +75 -0
  70. package/src/modules/primitives/command/activateCategory.ts +50 -0
  71. package/src/modules/primitives/command/activateCurrency.test.ts +70 -0
  72. package/src/modules/primitives/command/activateCurrency.ts +50 -0
  73. package/src/modules/primitives/command/activateUnit.test.ts +53 -0
  74. package/src/modules/primitives/command/activateUnit.ts +50 -0
  75. package/src/modules/primitives/command/convertAmount.test.ts +275 -0
  76. package/src/modules/primitives/command/convertAmount.ts +126 -0
  77. package/src/modules/primitives/command/convertQuantity.test.ts +219 -0
  78. package/src/modules/primitives/command/convertQuantity.ts +73 -0
  79. package/src/modules/primitives/command/createCategory.test.ts +126 -0
  80. package/src/modules/primitives/command/createCategory.ts +89 -0
  81. package/src/modules/primitives/command/createCurrency.test.ts +191 -0
  82. package/src/modules/primitives/command/createCurrency.ts +77 -0
  83. package/src/modules/primitives/command/createExchangeRate.test.ts +216 -0
  84. package/src/modules/primitives/command/createExchangeRate.ts +91 -0
  85. package/src/modules/primitives/command/createUnit.test.ts +214 -0
  86. package/src/modules/primitives/command/createUnit.ts +88 -0
  87. package/src/modules/primitives/command/deactivateCategory.test.ts +97 -0
  88. package/src/modules/primitives/command/deactivateCategory.ts +62 -0
  89. package/src/modules/primitives/command/deactivateCurrency.test.ts +85 -0
  90. package/src/modules/primitives/command/deactivateCurrency.ts +55 -0
  91. package/src/modules/primitives/command/deactivateUnit.test.ts +78 -0
  92. package/src/modules/primitives/command/deactivateUnit.ts +62 -0
  93. package/src/modules/primitives/command/setBaseCurrency.test.ts +98 -0
  94. package/src/modules/primitives/command/setBaseCurrency.ts +74 -0
  95. package/src/modules/primitives/command/setReferenceUnit.test.ts +108 -0
  96. package/src/modules/primitives/command/setReferenceUnit.ts +84 -0
  97. package/src/modules/primitives/db/currency.ts +30 -0
  98. package/src/modules/primitives/db/exchangeRate.ts +28 -0
  99. package/src/modules/primitives/db/unit.ts +32 -0
  100. package/src/modules/primitives/db/uomCategory.ts +32 -0
  101. package/src/modules/primitives/docs/commands/ActivateCategory.md +34 -0
  102. package/src/modules/primitives/docs/commands/ActivateCurrency.md +33 -0
  103. package/src/modules/primitives/docs/commands/ActivateUnit.md +34 -0
  104. package/src/modules/primitives/docs/commands/ConvertAmount.md +50 -0
  105. package/src/modules/primitives/docs/commands/ConvertQuantity.md +43 -0
  106. package/src/modules/primitives/docs/commands/CreateCategory.md +44 -0
  107. package/src/modules/primitives/docs/commands/CreateCurrency.md +47 -0
  108. package/src/modules/primitives/docs/commands/CreateExchangeRate.md +48 -0
  109. package/src/modules/primitives/docs/commands/CreateUnit.md +48 -0
  110. package/src/modules/primitives/docs/commands/DeactivateCategory.md +38 -0
  111. package/src/modules/primitives/docs/commands/DeactivateCurrency.md +38 -0
  112. package/src/modules/primitives/docs/commands/DeactivateUnit.md +38 -0
  113. package/src/modules/primitives/docs/commands/SetBaseCurrency.md +39 -0
  114. package/src/modules/primitives/docs/commands/SetReferenceUnit.md +43 -0
  115. package/src/modules/primitives/docs/features/currency-definitions.md +55 -0
  116. package/src/modules/primitives/docs/features/exchange-rates.md +61 -0
  117. package/src/modules/primitives/docs/features/unit-conversion.md +66 -0
  118. package/src/modules/primitives/docs/features/uom-categories.md +52 -0
  119. package/src/modules/primitives/docs/models/Currency.md +45 -0
  120. package/src/modules/primitives/docs/models/ExchangeRate.md +33 -0
  121. package/src/modules/primitives/docs/models/Unit.md +46 -0
  122. package/src/modules/primitives/docs/models/UoMCategory.md +44 -0
  123. package/src/modules/primitives/generated/kysely-tailordb.ts +95 -0
  124. package/src/modules/primitives/index.ts +40 -0
  125. package/src/modules/primitives/lib/errors.ts +138 -0
  126. package/src/modules/primitives/lib/types.ts +20 -0
  127. package/src/modules/primitives/module.ts +66 -0
  128. package/src/modules/primitives/permissions.ts +18 -0
  129. package/src/modules/primitives/tailor.config.ts +11 -0
  130. package/src/modules/primitives/testing/fixtures.ts +161 -0
  131. package/src/modules/product-management/.gitkeep +0 -0
  132. package/src/modules/purchase/.gitkeep +0 -0
  133. package/src/modules/sales/.gitkeep +0 -0
  134. package/src/modules/shared/createContext.test.ts +39 -0
  135. package/src/modules/shared/createContext.ts +15 -0
  136. package/src/modules/shared/defineCommand.test.ts +42 -0
  137. package/src/modules/shared/defineCommand.ts +19 -0
  138. package/src/modules/shared/definePermissions.test.ts +146 -0
  139. package/src/modules/shared/definePermissions.ts +94 -0
  140. package/src/modules/shared/entityTypes.ts +15 -0
  141. package/src/modules/shared/errors.ts +22 -0
  142. package/src/modules/shared/index.ts +1 -0
  143. package/src/modules/shared/internal.ts +13 -0
  144. package/src/modules/shared/requirePermission.test.ts +47 -0
  145. package/src/modules/shared/requirePermission.ts +8 -0
  146. package/src/modules/shared/types.ts +4 -0
  147. package/src/modules/supplier-management/.gitkeep +0 -0
  148. package/src/modules/supplier-portal/.gitkeep +0 -0
  149. package/src/modules/testing/index.ts +120 -0
  150. package/src/modules/user-management/README.md +38 -0
  151. package/src/modules/user-management/command/activateUser.test.ts +112 -0
  152. package/src/modules/user-management/command/activateUser.ts +67 -0
  153. package/src/modules/user-management/command/assignPermissionToRole.test.ts +119 -0
  154. package/src/modules/user-management/command/assignPermissionToRole.ts +87 -0
  155. package/src/modules/user-management/command/assignRoleToUser.test.ts +162 -0
  156. package/src/modules/user-management/command/assignRoleToUser.ts +93 -0
  157. package/src/modules/user-management/command/createPermission.test.ts +143 -0
  158. package/src/modules/user-management/command/createPermission.ts +66 -0
  159. package/src/modules/user-management/command/createRole.test.ts +115 -0
  160. package/src/modules/user-management/command/createRole.ts +52 -0
  161. package/src/modules/user-management/command/createUser.test.ts +198 -0
  162. package/src/modules/user-management/command/createUser.ts +85 -0
  163. package/src/modules/user-management/command/deactivateUser.test.ts +112 -0
  164. package/src/modules/user-management/command/deactivateUser.ts +67 -0
  165. package/src/modules/user-management/command/logAuditEvent.test.ts +179 -0
  166. package/src/modules/user-management/command/logAuditEvent.ts +59 -0
  167. package/src/modules/user-management/command/reactivateUser.test.ts +115 -0
  168. package/src/modules/user-management/command/reactivateUser.ts +67 -0
  169. package/src/modules/user-management/command/revokePermissionFromRole.test.ts +112 -0
  170. package/src/modules/user-management/command/revokePermissionFromRole.ts +81 -0
  171. package/src/modules/user-management/command/revokeRoleFromUser.test.ts +112 -0
  172. package/src/modules/user-management/command/revokeRoleFromUser.ts +81 -0
  173. package/src/modules/user-management/db/auditEvent.ts +47 -0
  174. package/src/modules/user-management/db/permission.ts +31 -0
  175. package/src/modules/user-management/db/role.ts +28 -0
  176. package/src/modules/user-management/db/rolePermission.ts +44 -0
  177. package/src/modules/user-management/db/user.ts +38 -0
  178. package/src/modules/user-management/db/userRole.ts +44 -0
  179. package/src/modules/user-management/docs/commands/ActivateUser.md +36 -0
  180. package/src/modules/user-management/docs/commands/AssignPermissionToRole.md +39 -0
  181. package/src/modules/user-management/docs/commands/AssignRoleToUser.md +43 -0
  182. package/src/modules/user-management/docs/commands/CreatePermission.md +35 -0
  183. package/src/modules/user-management/docs/commands/CreateRole.md +35 -0
  184. package/src/modules/user-management/docs/commands/CreateUser.md +41 -0
  185. package/src/modules/user-management/docs/commands/DeactivateUser.md +38 -0
  186. package/src/modules/user-management/docs/commands/LogAuditEvent.md +37 -0
  187. package/src/modules/user-management/docs/commands/ReactivateUser.md +37 -0
  188. package/src/modules/user-management/docs/commands/RevokePermissionFromRole.md +40 -0
  189. package/src/modules/user-management/docs/commands/RevokeRoleFromUser.md +40 -0
  190. package/src/modules/user-management/docs/features/audit-trail.md +80 -0
  191. package/src/modules/user-management/docs/features/role-based-access-control.md +76 -0
  192. package/src/modules/user-management/docs/features/user-account-management.md +64 -0
  193. package/src/modules/user-management/docs/models/AuditEvent.md +34 -0
  194. package/src/modules/user-management/docs/models/Permission.md +31 -0
  195. package/src/modules/user-management/docs/models/Role.md +31 -0
  196. package/src/modules/user-management/docs/models/RolePermission.md +33 -0
  197. package/src/modules/user-management/docs/models/User.md +47 -0
  198. package/src/modules/user-management/docs/models/UserRole.md +34 -0
  199. package/src/modules/user-management/docs/plans/2026-01-30-flattened-permissions-design.md +52 -0
  200. package/src/modules/user-management/executor/recomputeOnRolePermissionChange.ts +61 -0
  201. package/src/modules/user-management/generated/enums.ts +24 -0
  202. package/src/modules/user-management/generated/kysely-tailordb.ts +112 -0
  203. package/src/modules/user-management/index.ts +32 -0
  204. package/src/modules/user-management/lib/errors.ts +81 -0
  205. package/src/modules/user-management/lib/recomputeUserPermissions.ts +53 -0
  206. package/src/modules/user-management/lib/types.ts +31 -0
  207. package/src/modules/user-management/module.ts +77 -0
  208. package/src/modules/user-management/permissions.ts +15 -0
  209. package/src/modules/user-management/tailor.config.ts +11 -0
  210. package/src/modules/user-management/testing/fixtures.ts +98 -0
  211. package/src/schemas.ts +25 -0
  212. package/src/testing.ts +10 -0
  213. package/src/util.ts +3 -0
@@ -0,0 +1,400 @@
1
+ ---
2
+ name: 5-module-implementation-review
3
+ description: Review implementation parity between documentation and code. Use when validating that TDD implementation (step 4) matches model docs, command docs, and test coverage requirements.
4
+ ---
5
+
6
+ # Implementation Parity Review Workflow
7
+
8
+ Review **implementation consistency** between documentation and actual code.
9
+
10
+ ## Purpose
11
+
12
+ Verify that TDD implementation (models, commands, tests) properly implements what's documented in model docs and command docs.
13
+
14
+ ```
15
+ Model Docs (Schema) → src/db/*.ts (Implementation)
16
+ ↓ ↓
17
+ Fields createEntityType()
18
+ Relationships Foreign keys
19
+ State Transitions Status enums
20
+
21
+ Command Docs (Spec) → src/command/*.ts (Implementation)
22
+ ↓ ↓
23
+ Business Rules Validation logic
24
+ Error Scenarios Error classes
25
+ Process Flows Branching logic
26
+
27
+ Command Docs (Spec) → src/command/*.test.ts (Tests)
28
+ ↓ ↓
29
+ Process Flow branches Test cases
30
+ Error scenarios Error assertions
31
+ Idempotent paths Return existing tests
32
+ ```
33
+
34
+ ## When to Use
35
+
36
+ - After TDD implementation (step 4), verify it matches documentation
37
+ - Before merging feature branches
38
+ - Quality check during code review
39
+
40
+ ## Workflow
41
+
42
+ ```
43
+ MODEL DOCS → MODEL CODE → COMMAND DOCS → COMMAND CODE → TESTS → COMPARE → REPORT
44
+ ```
45
+
46
+ ## Step-by-Step
47
+
48
+ ### 1. Read Model Documentation
49
+
50
+ Read ALL model docs:
51
+
52
+ ```
53
+ modules/<module-name>/docs/models/*.md
54
+ ```
55
+
56
+ Extract for each model:
57
+
58
+ - Field names and types
59
+ - Required vs optional fields
60
+ - Relationships (foreign keys)
61
+ - State transitions (if stateful)
62
+ - Constraints
63
+
64
+ ### 2. Read Model Implementation
65
+
66
+ Read ALL model files:
67
+
68
+ ```
69
+ modules/<module-name>/src/db/*.ts
70
+ ```
71
+
72
+ Extract for each model:
73
+
74
+ - Fields in `createEntityType()`
75
+ - Status enums (base + additional)
76
+ - Foreign key references
77
+ - Field descriptions
78
+
79
+ ### 3. Read Command Documentation
80
+
81
+ Read ALL command docs:
82
+
83
+ ```
84
+ modules/<module-name>/docs/commands/*.md
85
+ ```
86
+
87
+ Extract for each command:
88
+
89
+ - Business rules
90
+ - Error scenarios (with codes)
91
+ - Process flow branches
92
+ - Input/output types
93
+
94
+ ### 4. Read Command Implementation
95
+
96
+ Read ALL command files:
97
+
98
+ ```
99
+ modules/<module-name>/src/command/*.ts
100
+ ```
101
+
102
+ Extract for each command:
103
+
104
+ - Validation logic implemented
105
+ - Error classes thrown
106
+ - Branching paths (if/else, early returns)
107
+ - Input interface fields
108
+ - Return type structure
109
+
110
+ ### 5. Read Error Implementation
111
+
112
+ Read error definitions:
113
+
114
+ ```
115
+ modules/<module-name>/src/lib/errors.ts
116
+ ```
117
+
118
+ Extract:
119
+
120
+ - Error class names
121
+ - Error codes
122
+ - Error message patterns
123
+
124
+ ### 6. Read Test Implementation
125
+
126
+ Read ALL test files:
127
+
128
+ ```
129
+ modules/<module-name>/src/command/*.test.ts
130
+ ```
131
+
132
+ Extract for each command:
133
+
134
+ - Test case descriptions
135
+ - Error assertions
136
+ - Happy path coverage
137
+ - Edge case coverage
138
+
139
+ ### 7. Model Doc → Model Code Parity Check
140
+
141
+ | Check Item | Question |
142
+ | ------------------ | ---------------------------------------------------------------- |
143
+ | Field coverage | Does code include all fields from model doc? |
144
+ | Type accuracy | Do field types match doc specification? |
145
+ | Required fields | Are required fields enforced (no default, not nullable)? |
146
+ | Relationship impl | Are foreign key fields implemented for documented relationships? |
147
+ | State transitions | Does status enum include all documented states? |
148
+ | Field descriptions | Do `.description()` calls match doc field descriptions? |
149
+
150
+ ### 8. Command Doc → Command Code Parity Check
151
+
152
+ | Check Item | Question |
153
+ | ----------------------- | ---------------------------------------------------------- |
154
+ | Business rule impl | Is each documented business rule implemented in code? |
155
+ | Error scenario coverage | Does code throw errors for all documented error scenarios? |
156
+ | Error code accuracy | Do error codes in code match documented codes? |
157
+ | Process flow alignment | Do code branches match documented process flow? |
158
+ | Input type coverage | Does input interface include all documented inputs? |
159
+ | Return type accuracy | Does return type match documented output? |
160
+ | Dual function pattern | Does command follow `_fn` internal / `fn` public pattern? |
161
+
162
+ ### 9. Command Doc → Test Coverage Check
163
+
164
+ | Check Item | Question |
165
+ | --------------------- | ---------------------------------------------------------- |
166
+ | Process flow coverage | Does each branch in process flow have a test case? |
167
+ | Error scenario tests | Does each documented error scenario have a test assertion? |
168
+ | Happy path tests | Are success paths tested? |
169
+ | Idempotent path tests | If doc shows "already exists → return", is this tested? |
170
+
171
+ ### 10. Report Findings
172
+
173
+ ```markdown
174
+ ## Implementation Parity Review Report
175
+
176
+ **Module:** <module-name>
177
+
178
+ ---
179
+
180
+ ### 1. Model Doc → Model Code Coverage
181
+
182
+ | Model Doc | Fields Documented | Fields Implemented | Gap |
183
+ | --------- | ----------------- | ------------------ | ------------------- |
184
+ | <Model-A> | N fields | N fields | ✅ |
185
+ | <Model-B> | N fields | N-1 fields | ❌ `fieldX` missing |
186
+
187
+ ---
188
+
189
+ ### 2. Model State Transitions
190
+
191
+ | Model | Documented States | Implemented States | Gap |
192
+ | --------- | ------------------------ | ------------------ | ------------------ |
193
+ | <Model-A> | PENDING, ACTIVE, REMOVED | PENDING, ACTIVE | ❌ REMOVED missing |
194
+ | <Model-B> | ACTIVE, INACTIVE | ACTIVE, INACTIVE | ✅ |
195
+
196
+ ---
197
+
198
+ ### 3. Command Doc → Command Code Coverage
199
+
200
+ | Command Doc | Business Rules | Implemented | Gap |
201
+ | ----------- | -------------- | ----------- | -------------------------------- |
202
+ | <cmd-a> | 3 rules | 3 rules | ✅ |
203
+ | <cmd-b> | 4 rules | 3 rules | ❌ "rule X validation" not found |
204
+
205
+ ---
206
+
207
+ ### 4. Error Scenario Implementation
208
+
209
+ | Command Doc | Error Code | Implemented in errors.ts | Thrown in command | Test assertion |
210
+ | ----------- | ---------------- | ------------------------ | ----------------- | -------------- |
211
+ | <cmd-a> | ENTITY_NOT_FOUND | ✅ EntityNotFoundError | ✅ | ✅ |
212
+ | <cmd-a> | INVALID_STATE | ❌ Not defined | ❌ | ❌ |
213
+ | <cmd-b> | DUPLICATE_ENTRY | ✅ DuplicateEntryError | ✅ | ❌ No test |
214
+
215
+ ---
216
+
217
+ ### 5. Process Flow → Test Coverage
218
+
219
+ | Command Doc | Process Flow Branches | Test Cases | Gap |
220
+ | ----------- | --------------------- | ---------- | -------------------------------- |
221
+ | <cmd-a> | 3 branches | 3 tests | ✅ |
222
+ | <cmd-b> | 4 branches | 2 tests | ❌ Missing "already exists" test |
223
+
224
+ ---
225
+
226
+ ### 6. Implementation Pattern Compliance
227
+
228
+ | Command | Dual Function Pattern | Input Interface Exported | JSDoc Present |
229
+ | ------- | --------------------- | ------------------------ | ------------- |
230
+ | <cmd-a> | ✅ `_cmdA` + `cmdA` | ✅ | ✅ |
231
+ | <cmd-b> | ❌ Only `cmdB` | ✅ | ❌ |
232
+
233
+ ---
234
+
235
+ ### 7. Missing Implementation
236
+
237
+ #### Missing in Model Code
238
+
239
+ | Model Doc | Missing Item | Type | Doc Reference |
240
+ | --------- | ------------ | ------ | --------------------------- |
241
+ | <Model-A> | `fieldX` | Field | "fieldX: uuid, required" |
242
+ | <Model-A> | `REMOVED` | Status | State diagram shows REMOVED |
243
+
244
+ #### Missing in Command Code
245
+
246
+ | Command Doc | Missing Item | Type | Doc Reference |
247
+ | ----------- | ---------------- | ------------- | ------------------------ |
248
+ | <cmd-b> | validation for X | Business rule | "Rule: X must be unique" |
249
+
250
+ #### Missing Error Classes
251
+
252
+ | Command Doc | Error Code | Expected Class |
253
+ | ----------- | ------------- | ----------------- |
254
+ | <cmd-a> | INVALID_STATE | InvalidStateError |
255
+
256
+ #### Missing Tests
257
+
258
+ | Command Doc | Missing Test Case | Doc Reference |
259
+ | ----------- | -------------------------------- | --------------------- |
260
+ | <cmd-b> | "entity already exists → return" | Process flow branch 2 |
261
+ | <cmd-b> | "throws DUPLICATE_ENTRY" | Error scenario 3 |
262
+
263
+ ---
264
+
265
+ ### 8. Inconsistencies
266
+
267
+ | Type | Location | Issue |
268
+ | ------------------- | -------------- | ------------------------------------------- |
269
+ | Type mismatch | Model-A.fieldX | Doc: string, Code: number |
270
+ | Error code mismatch | cmd-a | Doc: USER_NOT_FOUND, Code: ENTITY_NOT_FOUND |
271
+ | Missing description | Model-B.fieldY | No `.description()` but doc has description |
272
+
273
+ ---
274
+
275
+ ### 9. Summary
276
+
277
+ | Aspect | Status | Details |
278
+ | ----------------------------- | ------ | --------------------------------- |
279
+ | Model Doc → Code Coverage | ⚠️ | X/Y models fully implemented |
280
+ | Command Doc → Code Coverage | ⚠️ | X/Y commands fully implemented |
281
+ | Error Scenario Implementation | ❌ | X/Y errors defined and thrown |
282
+ | Test Coverage | ⚠️ | X/Y process branches have tests |
283
+ | Pattern Compliance | ✅ | All commands follow dual function |
284
+
285
+ ### 10. Recommendations
286
+
287
+ 1. **Add missing model fields:**
288
+ - Model-A: add `fieldX` field
289
+
290
+ 2. **Add missing status values:**
291
+ - Model-A: add `REMOVED` to status enum
292
+
293
+ 3. **Implement missing business rules:**
294
+ - cmd-b: add validation for "X must be unique"
295
+
296
+ 4. **Define missing error classes:**
297
+ - Add `InvalidStateError` in errors.ts
298
+
299
+ 5. **Add missing test cases:**
300
+ - cmd-b: test "entity already exists → return existing"
301
+ - cmd-b: test "throws DUPLICATE_ENTRY on duplicate"
302
+
303
+ 6. **Fix inconsistencies:**
304
+ - Model-A.fieldX: change type to string per doc
305
+ ```
306
+
307
+ ## Common Gaps
308
+
309
+ ### Model Doc → Model Code
310
+
311
+ - **Missing fields**: Doc specifies field but not in code
312
+ - **Type mismatches**: Doc says string, code uses number
313
+ - **Missing status values**: State diagram shows state not in enum
314
+ - **Missing relationships**: Doc shows FK but not implemented
315
+ - **Missing descriptions**: Doc has field description but no `.description()`
316
+
317
+ ### Command Doc → Command Code
318
+
319
+ - **Unimplemented business rules**: Rule in doc but no validation code
320
+ - **Missing error throws**: Error scenario documented but not thrown
321
+ - **Wrong error codes**: Code and doc use different error codes
322
+ - **Missing process branches**: Flowchart branch not in code logic
323
+ - **Missing dual function**: Only public function, no internal `_fn`
324
+
325
+ ### Command Doc → Tests
326
+
327
+ - **Uncovered process branches**: Flowchart branch has no test
328
+ - **Missing error tests**: Error scenario has no assertion
329
+ - **Missing idempotent tests**: "Return existing" path untested
330
+ - **Missing edge cases**: Boundary conditions not tested
331
+
332
+ ## Quick Reference: Extraction Patterns
333
+
334
+ ### From Model Docs
335
+
336
+ ```markdown
337
+ ## Fields
338
+
339
+ | Field | Type | Required |
340
+ | -------- | ------ | -------- | ---------------------------------------- |
341
+ | id | uuid | yes | → Check: field exists, type matches |
342
+ | name | string | yes | → Check: not nullable |
343
+ | status | enum | yes | → Check: enum values match state diagram |
344
+ | parentId | uuid | yes | → Check: foreign key implemented |
345
+
346
+ ## State Diagram
347
+
348
+ PENDING → ACTIVE → REMOVED
349
+ → Check: all states in enum
350
+ ```
351
+
352
+ ### From Command Docs
353
+
354
+ ```markdown
355
+ ## Business Rules
356
+
357
+ 1. Entity must exist → Check: validation in code
358
+ 2. Status must be ACTIVE → Check: status check in code
359
+
360
+ ## Error Scenarios
361
+
362
+ | Code | Condition |
363
+ | -------------- | -------------- | ----------------------------------- |
364
+ | NOT_FOUND | Entity missing | → Check: error class + throw + test |
365
+ | INVALID_STATUS | Wrong status | → Check: error class + throw + test |
366
+
367
+ ## Process Flow (mermaid)
368
+
369
+ graph TD
370
+ A[Start] --> B{Exists?}
371
+ B -->|Yes| C[Return] → Check: test for "already exists"
372
+ B -->|No| D[Create] → Check: test for "create new"
373
+ ```
374
+
375
+ ### From Implementation
376
+
377
+ ```typescript
378
+ // Model: check fields match doc
379
+ export function createEntityType(params) {
380
+ return {
381
+ fields: {
382
+ /* verify each field */
383
+ },
384
+ };
385
+ }
386
+
387
+ // Command: check business rules
388
+ export async function _myCommand(db, input) {
389
+ // Check: validation for each business rule
390
+ if (!entity) throw new EntityNotFoundError(); // Check: matches doc error
391
+ // Check: each branch matches process flow
392
+ }
393
+
394
+ // Test: check coverage
395
+ describe("myCommand", () => {
396
+ it("creates entity when valid"); // Check: happy path
397
+ it("returns existing if found"); // Check: idempotent path
398
+ it("throws NOT_FOUND when missing"); // Check: error scenario
399
+ });
400
+ ```
@@ -0,0 +1,85 @@
1
+ ---
2
+ name: app-compose-1-requirement-analysis
3
+ description: Create Tier 1-2 documentation (requirements, actors, business-flow) for examples/. Use when starting a new application or documenting high-level requirements and workflows.
4
+ ---
5
+
6
+ # Application Requirement Analysis Workflow
7
+
8
+ Create Tier 1-2 documentation: Requirements, Actors, and Business Flows.
9
+
10
+ ## Workflow Phases
11
+
12
+ ```
13
+ GATHER → CLARIFY → CREATE → VALIDATE
14
+ ```
15
+
16
+ ### Phase 1: Gather
17
+
18
+ Understand the application's purpose and scope:
19
+
20
+ 1. **Identify** what the application does (business purpose)
21
+ 2. **List** target users (actors) and their roles
22
+ 3. **Understand** business goals and success criteria
23
+ 4. **Capture** key workflows the application must support
24
+
25
+ Focus on "what" the application should do, not "how" it will be implemented.
26
+
27
+ ### Phase 2: Clarify
28
+
29
+ Use AskUserQuestion to clarify undefined requirements:
30
+
31
+ | Category | Example Questions |
32
+ | ----------------- | ---------------------------------------------- |
33
+ | Authentication | External IdP / Password / Out of scope? |
34
+ | User Operations | Direct creation / Email invitation / Both? |
35
+ | Roles | Fixed roles (Admin/User) / Custom roles? |
36
+ | User Self-Service | View only / Profile edit / Password change? |
37
+ | Lifecycle | Create only / Full lifecycle (activate/deact)? |
38
+
39
+ Ask 3-4 questions at a time using multiSelect where appropriate.
40
+
41
+ ### Phase 3: Create
42
+
43
+ Generate documentation using `erp-kit` CLI:
44
+
45
+ ```bash
46
+ # Tier 1: Requirements
47
+ erp-kit scaffold --app-root examples requirements <app-name>
48
+
49
+ # Tier 2: Actors
50
+ erp-kit scaffold --app-root examples actors <app-name> <actor-name>
51
+
52
+ # Tier 2: Business Flows
53
+ erp-kit scaffold --app-root examples business-flow <app-name> <flow-name>
54
+ ```
55
+
56
+ **Naming conventions:**
57
+
58
+ - Files: kebab-case (e.g., `sales-representative.md`)
59
+ - H1 heading slug must match filename slug
60
+
61
+ **Authorized Business Flows format (in actor docs):**
62
+
63
+ ```markdown
64
+ - [Flow Name](../business-flow/<flow>/README.md) — role
65
+ ```
66
+
67
+ Roles: `initiator`, `approver`, `viewer`
68
+
69
+ ### Phase 4: Validate
70
+
71
+ ```bash
72
+ pnpm run app:doc:check
73
+ ```
74
+
75
+ ## Schema Reference
76
+
77
+ | Schema | Tier | Output Path |
78
+ | ------------------- | ---- | ------------------------------------- |
79
+ | `requirements.yml` | 1 | `README.md` |
80
+ | `actors.yml` | 2 | `docs/actors/<name>.md` |
81
+ | `business-flow.yml` | 2 | `docs/business-flow/<flow>/README.md` |
82
+
83
+ ## Next Step
84
+
85
+ After completing Tier 1-2, use `/app-compose-2-requirements-breakdown` to create Tier 3 documentation.
@@ -0,0 +1,88 @@
1
+ ---
2
+ name: app-compose-2-requirements-breakdown
3
+ description: Create Tier 3 documentation (stories, screens) by breaking down business flows. Use after completing Tier 1-2 documentation with app-compose-1-requirement-analysis.
4
+ ---
5
+
6
+ # Requirements Breakdown Workflow
7
+
8
+ Break down Tier 2 business flows into Tier 3 documentation: User Stories and Screens.
9
+
10
+ ## Prerequisites
11
+
12
+ Tier 1-2 documentation must exist:
13
+
14
+ - `README.md` (requirements)
15
+ - `docs/actors/*.md` (actor definitions)
16
+ - `docs/business-flow/*/README.md` (business workflows)
17
+
18
+ ## Workflow Phases
19
+
20
+ ```
21
+ ANALYZE → BREAKDOWN → CREATE → VALIDATE
22
+ ```
23
+
24
+ ### Phase 1: Analyze
25
+
26
+ Review existing Tier 2 documentation:
27
+
28
+ 1. **Read** all business flow files in `docs/business-flow/`
29
+ 2. **Identify** flow steps that represent user actions
30
+ 3. **Map** each step to the responsible actor
31
+ 4. **Note** data inputs/outputs for each step
32
+
33
+ ### Phase 2: Breakdown
34
+
35
+ For each business flow, decompose into stories and screens:
36
+
37
+ | Flow Element | Maps To |
38
+ | ---------------- | ----------- |
39
+ | User action step | Story |
40
+ | UI requirement | Screen |
41
+ | Actor in flow | Story actor |
42
+
43
+ ### Phase 3: Create
44
+
45
+ Generate documentation using `erp-kit` CLI:
46
+
47
+ ```bash
48
+ # Tier 3: Stories
49
+ erp-kit scaffold --app-root examples story <app> <flow>/<actor>--<story>
50
+
51
+ # Tier 3: Screens
52
+ erp-kit scaffold --app-root examples screen <app> <screen-name>
53
+ ```
54
+
55
+ **Naming conventions:**
56
+
57
+ - Story filename: `<actor>--<story-name>.md` (double-dash separator)
58
+ - Story heading: Title Case of story name (after `--`)
59
+ - Screen filename: kebab-case, noun-focused (e.g., `supplier-list.md`)
60
+
61
+ **After creating stories**, update `## Stories` section in business flow README:
62
+
63
+ ```markdown
64
+ - [Story Title](./story/<actor>--<story-name>.md)
65
+ ```
66
+
67
+ ### Phase 4: Validate
68
+
69
+ ```bash
70
+ pnpm run app:doc:check
71
+ ```
72
+
73
+ ## Schema Reference
74
+
75
+ | Schema | Tier | Output Path |
76
+ | ------------ | ---- | ---------------------------------------------------- |
77
+ | `story.yml` | 3 | `docs/business-flow/<flow>/story/<actor>--<name>.md` |
78
+ | `screen.yml` | 3 | `docs/screen/<name>.md` |
79
+
80
+ ## Tips
81
+
82
+ - One business flow typically produces 3-8 stories
83
+ - Stories should be completable in a single user session
84
+ - Screens can be shared across multiple stories
85
+
86
+ ## Next Step
87
+
88
+ After completing Tier 3, use `/app-compose-3-doc-review` to validate documentation parity.
@@ -0,0 +1,112 @@
1
+ ---
2
+ name: app-compose-3-doc-review
3
+ description: Review documentation parity between Tier 2 (business flows, actors) and Tier 3 (stories, screens). Use when validating that all business flow steps have corresponding stories, and that screens are properly linked.
4
+ ---
5
+
6
+ # Documentation Parity Review Workflow
7
+
8
+ Review **documentation consistency** between Tier 2 and Tier 3 documentation.
9
+
10
+ ## Purpose
11
+
12
+ ```
13
+ Business Flow (Tier 2) → Stories (Tier 3) → Screens (Tier 3)
14
+ ↓ ↓ ↓
15
+ Flow Steps User Actions UI Components
16
+ Actors Involved Scenario Patterns Screen Types
17
+ ```
18
+
19
+ ## When to Use
20
+
21
+ - After writing Tier 3 documentation, check for gaps
22
+ - Before proceeding to Tier 4 (implementation spec)
23
+ - Quality check during documentation review
24
+
25
+ ## Workflow
26
+
27
+ ```
28
+ READ DOCS → PARITY CHECKS → REPORT
29
+ ```
30
+
31
+ ### Step 1: Read All Documentation
32
+
33
+ ```
34
+ examples/<app-name>/docs/business-flow/*/README.md # Flows
35
+ examples/<app-name>/docs/business-flow/*/story/*.md # Stories
36
+ examples/<app-name>/docs/screen/*.md # Screens
37
+ examples/<app-name>/docs/actors/*.md # Actors
38
+ ```
39
+
40
+ ### Step 2: Parity Checks
41
+
42
+ #### Business Flow → Story
43
+
44
+ | Check | Question |
45
+ | --------------- | ----------------------------------------------- |
46
+ | Story existence | Does each flow step have a corresponding story? |
47
+ | Actor coverage | Are all actors in flow represented in stories? |
48
+ | Link validity | Do story links in flow README resolve? |
49
+
50
+ #### Actor → Business Flow
51
+
52
+ | Check | Question |
53
+ | -------------- | ----------------------------------------- |
54
+ | Flow existence | Do all flows in "Authorized Flows" exist? |
55
+ | Link validity | Do flow links resolve correctly? |
56
+
57
+ #### Story → Screen
58
+
59
+ | Check | Question |
60
+ | ---------------- | ---------------------------------- |
61
+ | Screen existence | Do all screens in story exist? |
62
+ | Link validity | Do screen links resolve correctly? |
63
+
64
+ #### Orphan Detection
65
+
66
+ | Check | Question |
67
+ | -------------- | ------------------------------------------ |
68
+ | Orphan stories | Stories not linked from any business flow? |
69
+ | Orphan screens | Screens not referenced by any story? |
70
+ | Orphan actors | Actors not participating in any flow? |
71
+
72
+ ### Step 3: Report
73
+
74
+ ```markdown
75
+ ## Documentation Parity Review Report
76
+
77
+ **Application:** <app-name>
78
+
79
+ ### Summary
80
+
81
+ | Aspect | Status | Details |
82
+ | --------------------- | -------- | ----------------- |
83
+ | Business Flow → Story | ✅/⚠️/❌ | X/Y flows covered |
84
+ | Actor → Flow | ✅/⚠️/❌ | All links valid |
85
+ | Story → Screen | ✅/⚠️/❌ | X missing screens |
86
+ | Orphan Detection | ✅/⚠️/❌ | N orphans found |
87
+
88
+ ### Gaps Found
89
+
90
+ - [ ] Missing: <item>
91
+ - [ ] Broken link: <source> → <target>
92
+ - [ ] Orphan: <file>
93
+
94
+ ### Recommendations
95
+
96
+ 1. Create missing: ...
97
+ 2. Fix broken links: ...
98
+ 3. Remove or link orphans: ...
99
+ ```
100
+
101
+ ## Link Format Reference
102
+
103
+ | From | To | Format |
104
+ | ------------- | ------------- | ----------------------------------- |
105
+ | Business Flow | Story | `./story/<actor>--<name>.md` |
106
+ | Business Flow | Actor | `../../actors/<actor>.md` |
107
+ | Actor | Business Flow | `../business-flow/<flow>/README.md` |
108
+ | Story | Screen | `../../../screen/<screen>.md` |
109
+
110
+ ## Next Step
111
+
112
+ After fixing all issues, use `/app-compose-4-design-mock` to create visual UI mockups from screen specifications.