@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.
- package/README.md +196 -28
- package/dist/cli.js +894 -0
- package/package.json +65 -8
- package/rules/app-compose/backend/auth.md +78 -0
- package/rules/app-compose/frontend/auth.md +55 -0
- package/rules/app-compose/frontend/component.md +55 -0
- package/rules/app-compose/frontend/page.md +86 -0
- package/rules/app-compose/frontend/screen-detailview.md +112 -0
- package/rules/app-compose/frontend/screen-form.md +145 -0
- package/rules/app-compose/frontend/screen-listview.md +159 -0
- package/rules/app-compose/structure.md +32 -0
- package/rules/module-development/commands.md +54 -0
- package/rules/module-development/cross-module-type-injection.md +28 -0
- package/rules/module-development/dependency-modules.md +24 -0
- package/rules/module-development/errors.md +12 -0
- package/rules/module-development/executors.md +67 -0
- package/rules/module-development/exports.md +13 -0
- package/rules/module-development/models.md +34 -0
- package/rules/module-development/structure.md +27 -0
- package/rules/module-development/sync-vs-async-operations.md +83 -0
- package/rules/module-development/testing.md +43 -0
- package/rules/sdk-best-practices/db-relations.md +74 -0
- package/rules/sdk-best-practices/sdk-docs.md +14 -0
- package/schemas/app-compose/actors.yml +34 -0
- package/schemas/app-compose/business-flow.yml +50 -0
- package/schemas/app-compose/requirements.yml +33 -0
- package/schemas/app-compose/resolver.yml +47 -0
- package/schemas/app-compose/screen.yml +81 -0
- package/schemas/app-compose/story.yml +67 -0
- package/schemas/module/command.yml +52 -0
- package/schemas/module/feature.yml +58 -0
- package/schemas/module/model.yml +70 -0
- package/schemas/module/module.yml +50 -0
- package/skills/1-module-docs/SKILL.md +107 -0
- package/skills/2-module-feature-breakdown/SKILL.md +66 -0
- package/skills/3-module-doc-review/SKILL.md +230 -0
- package/skills/4-module-tdd-implementation/SKILL.md +56 -0
- package/skills/5-module-implementation-review/SKILL.md +400 -0
- package/skills/app-compose-1-requirement-analysis/SKILL.md +85 -0
- package/skills/app-compose-2-requirements-breakdown/SKILL.md +88 -0
- package/skills/app-compose-3-doc-review/SKILL.md +112 -0
- package/skills/app-compose-4-design-mock/SKILL.md +248 -0
- package/skills/app-compose-5-design-mock-review/SKILL.md +283 -0
- package/skills/app-compose-6-implementation-spec/SKILL.md +122 -0
- package/skills/mock-scenario/SKILL.md +118 -0
- package/src/app.ts +1 -0
- package/src/cli.ts +120 -0
- package/src/commands/check.test.ts +30 -0
- package/src/commands/check.ts +66 -0
- package/src/commands/init.test.ts +77 -0
- package/src/commands/init.ts +87 -0
- package/src/commands/mock/index.ts +53 -0
- package/src/commands/mock/start.ts +179 -0
- package/src/commands/mock/validate.test.ts +185 -0
- package/src/commands/mock/validate.ts +198 -0
- package/src/commands/scaffold.test.ts +76 -0
- package/src/commands/scaffold.ts +119 -0
- package/src/commands/sync-check.test.ts +125 -0
- package/src/commands/sync-check.ts +182 -0
- package/src/integration.test.ts +63 -0
- package/src/mdschema.ts +48 -0
- package/src/mockServer.ts +55 -0
- package/src/module.ts +86 -0
- package/src/modules/accounting/.gitkeep +0 -0
- package/src/modules/coa-management/.gitkeep +0 -0
- package/src/modules/inventory/.gitkeep +0 -0
- package/src/modules/manufacturing/.gitkeep +0 -0
- package/src/modules/primitives/README.md +39 -0
- package/src/modules/primitives/command/activateCategory.test.ts +75 -0
- package/src/modules/primitives/command/activateCategory.ts +50 -0
- package/src/modules/primitives/command/activateCurrency.test.ts +70 -0
- package/src/modules/primitives/command/activateCurrency.ts +50 -0
- package/src/modules/primitives/command/activateUnit.test.ts +53 -0
- package/src/modules/primitives/command/activateUnit.ts +50 -0
- package/src/modules/primitives/command/convertAmount.test.ts +275 -0
- package/src/modules/primitives/command/convertAmount.ts +126 -0
- package/src/modules/primitives/command/convertQuantity.test.ts +219 -0
- package/src/modules/primitives/command/convertQuantity.ts +73 -0
- package/src/modules/primitives/command/createCategory.test.ts +126 -0
- package/src/modules/primitives/command/createCategory.ts +89 -0
- package/src/modules/primitives/command/createCurrency.test.ts +191 -0
- package/src/modules/primitives/command/createCurrency.ts +77 -0
- package/src/modules/primitives/command/createExchangeRate.test.ts +216 -0
- package/src/modules/primitives/command/createExchangeRate.ts +91 -0
- package/src/modules/primitives/command/createUnit.test.ts +214 -0
- package/src/modules/primitives/command/createUnit.ts +88 -0
- package/src/modules/primitives/command/deactivateCategory.test.ts +97 -0
- package/src/modules/primitives/command/deactivateCategory.ts +62 -0
- package/src/modules/primitives/command/deactivateCurrency.test.ts +85 -0
- package/src/modules/primitives/command/deactivateCurrency.ts +55 -0
- package/src/modules/primitives/command/deactivateUnit.test.ts +78 -0
- package/src/modules/primitives/command/deactivateUnit.ts +62 -0
- package/src/modules/primitives/command/setBaseCurrency.test.ts +98 -0
- package/src/modules/primitives/command/setBaseCurrency.ts +74 -0
- package/src/modules/primitives/command/setReferenceUnit.test.ts +108 -0
- package/src/modules/primitives/command/setReferenceUnit.ts +84 -0
- package/src/modules/primitives/db/currency.ts +30 -0
- package/src/modules/primitives/db/exchangeRate.ts +28 -0
- package/src/modules/primitives/db/unit.ts +32 -0
- package/src/modules/primitives/db/uomCategory.ts +32 -0
- package/src/modules/primitives/docs/commands/ActivateCategory.md +34 -0
- package/src/modules/primitives/docs/commands/ActivateCurrency.md +33 -0
- package/src/modules/primitives/docs/commands/ActivateUnit.md +34 -0
- package/src/modules/primitives/docs/commands/ConvertAmount.md +50 -0
- package/src/modules/primitives/docs/commands/ConvertQuantity.md +43 -0
- package/src/modules/primitives/docs/commands/CreateCategory.md +44 -0
- package/src/modules/primitives/docs/commands/CreateCurrency.md +47 -0
- package/src/modules/primitives/docs/commands/CreateExchangeRate.md +48 -0
- package/src/modules/primitives/docs/commands/CreateUnit.md +48 -0
- package/src/modules/primitives/docs/commands/DeactivateCategory.md +38 -0
- package/src/modules/primitives/docs/commands/DeactivateCurrency.md +38 -0
- package/src/modules/primitives/docs/commands/DeactivateUnit.md +38 -0
- package/src/modules/primitives/docs/commands/SetBaseCurrency.md +39 -0
- package/src/modules/primitives/docs/commands/SetReferenceUnit.md +43 -0
- package/src/modules/primitives/docs/features/currency-definitions.md +55 -0
- package/src/modules/primitives/docs/features/exchange-rates.md +61 -0
- package/src/modules/primitives/docs/features/unit-conversion.md +66 -0
- package/src/modules/primitives/docs/features/uom-categories.md +52 -0
- package/src/modules/primitives/docs/models/Currency.md +45 -0
- package/src/modules/primitives/docs/models/ExchangeRate.md +33 -0
- package/src/modules/primitives/docs/models/Unit.md +46 -0
- package/src/modules/primitives/docs/models/UoMCategory.md +44 -0
- package/src/modules/primitives/generated/kysely-tailordb.ts +95 -0
- package/src/modules/primitives/index.ts +40 -0
- package/src/modules/primitives/lib/errors.ts +138 -0
- package/src/modules/primitives/lib/types.ts +20 -0
- package/src/modules/primitives/module.ts +66 -0
- package/src/modules/primitives/permissions.ts +18 -0
- package/src/modules/primitives/tailor.config.ts +11 -0
- package/src/modules/primitives/testing/fixtures.ts +161 -0
- package/src/modules/product-management/.gitkeep +0 -0
- package/src/modules/purchase/.gitkeep +0 -0
- package/src/modules/sales/.gitkeep +0 -0
- package/src/modules/shared/createContext.test.ts +39 -0
- package/src/modules/shared/createContext.ts +15 -0
- package/src/modules/shared/defineCommand.test.ts +42 -0
- package/src/modules/shared/defineCommand.ts +19 -0
- package/src/modules/shared/definePermissions.test.ts +146 -0
- package/src/modules/shared/definePermissions.ts +94 -0
- package/src/modules/shared/entityTypes.ts +15 -0
- package/src/modules/shared/errors.ts +22 -0
- package/src/modules/shared/index.ts +1 -0
- package/src/modules/shared/internal.ts +13 -0
- package/src/modules/shared/requirePermission.test.ts +47 -0
- package/src/modules/shared/requirePermission.ts +8 -0
- package/src/modules/shared/types.ts +4 -0
- package/src/modules/supplier-management/.gitkeep +0 -0
- package/src/modules/supplier-portal/.gitkeep +0 -0
- package/src/modules/testing/index.ts +120 -0
- package/src/modules/user-management/README.md +38 -0
- package/src/modules/user-management/command/activateUser.test.ts +112 -0
- package/src/modules/user-management/command/activateUser.ts +67 -0
- package/src/modules/user-management/command/assignPermissionToRole.test.ts +119 -0
- package/src/modules/user-management/command/assignPermissionToRole.ts +87 -0
- package/src/modules/user-management/command/assignRoleToUser.test.ts +162 -0
- package/src/modules/user-management/command/assignRoleToUser.ts +93 -0
- package/src/modules/user-management/command/createPermission.test.ts +143 -0
- package/src/modules/user-management/command/createPermission.ts +66 -0
- package/src/modules/user-management/command/createRole.test.ts +115 -0
- package/src/modules/user-management/command/createRole.ts +52 -0
- package/src/modules/user-management/command/createUser.test.ts +198 -0
- package/src/modules/user-management/command/createUser.ts +85 -0
- package/src/modules/user-management/command/deactivateUser.test.ts +112 -0
- package/src/modules/user-management/command/deactivateUser.ts +67 -0
- package/src/modules/user-management/command/logAuditEvent.test.ts +179 -0
- package/src/modules/user-management/command/logAuditEvent.ts +59 -0
- package/src/modules/user-management/command/reactivateUser.test.ts +115 -0
- package/src/modules/user-management/command/reactivateUser.ts +67 -0
- package/src/modules/user-management/command/revokePermissionFromRole.test.ts +112 -0
- package/src/modules/user-management/command/revokePermissionFromRole.ts +81 -0
- package/src/modules/user-management/command/revokeRoleFromUser.test.ts +112 -0
- package/src/modules/user-management/command/revokeRoleFromUser.ts +81 -0
- package/src/modules/user-management/db/auditEvent.ts +47 -0
- package/src/modules/user-management/db/permission.ts +31 -0
- package/src/modules/user-management/db/role.ts +28 -0
- package/src/modules/user-management/db/rolePermission.ts +44 -0
- package/src/modules/user-management/db/user.ts +38 -0
- package/src/modules/user-management/db/userRole.ts +44 -0
- package/src/modules/user-management/docs/commands/ActivateUser.md +36 -0
- package/src/modules/user-management/docs/commands/AssignPermissionToRole.md +39 -0
- package/src/modules/user-management/docs/commands/AssignRoleToUser.md +43 -0
- package/src/modules/user-management/docs/commands/CreatePermission.md +35 -0
- package/src/modules/user-management/docs/commands/CreateRole.md +35 -0
- package/src/modules/user-management/docs/commands/CreateUser.md +41 -0
- package/src/modules/user-management/docs/commands/DeactivateUser.md +38 -0
- package/src/modules/user-management/docs/commands/LogAuditEvent.md +37 -0
- package/src/modules/user-management/docs/commands/ReactivateUser.md +37 -0
- package/src/modules/user-management/docs/commands/RevokePermissionFromRole.md +40 -0
- package/src/modules/user-management/docs/commands/RevokeRoleFromUser.md +40 -0
- package/src/modules/user-management/docs/features/audit-trail.md +80 -0
- package/src/modules/user-management/docs/features/role-based-access-control.md +76 -0
- package/src/modules/user-management/docs/features/user-account-management.md +64 -0
- package/src/modules/user-management/docs/models/AuditEvent.md +34 -0
- package/src/modules/user-management/docs/models/Permission.md +31 -0
- package/src/modules/user-management/docs/models/Role.md +31 -0
- package/src/modules/user-management/docs/models/RolePermission.md +33 -0
- package/src/modules/user-management/docs/models/User.md +47 -0
- package/src/modules/user-management/docs/models/UserRole.md +34 -0
- package/src/modules/user-management/docs/plans/2026-01-30-flattened-permissions-design.md +52 -0
- package/src/modules/user-management/executor/recomputeOnRolePermissionChange.ts +61 -0
- package/src/modules/user-management/generated/enums.ts +24 -0
- package/src/modules/user-management/generated/kysely-tailordb.ts +112 -0
- package/src/modules/user-management/index.ts +32 -0
- package/src/modules/user-management/lib/errors.ts +81 -0
- package/src/modules/user-management/lib/recomputeUserPermissions.ts +53 -0
- package/src/modules/user-management/lib/types.ts +31 -0
- package/src/modules/user-management/module.ts +77 -0
- package/src/modules/user-management/permissions.ts +15 -0
- package/src/modules/user-management/tailor.config.ts +11 -0
- package/src/modules/user-management/testing/fixtures.ts +98 -0
- package/src/schemas.ts +25 -0
- package/src/testing.ts +10 -0
- package/src/util.ts +3 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: 2-module-feature-breakdown
|
|
3
|
+
description: Use when breaking down a feature spec into model and command documentation. Triggers on feature implementation planning, creating model docs, creating command docs, or when user references model.yml/command.yml schemas.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Feature Breakdown to Model/Command Docs
|
|
7
|
+
|
|
8
|
+
Convert feature specifications into structured model and command documentation following framework schemas.
|
|
9
|
+
|
|
10
|
+
## When to Use
|
|
11
|
+
|
|
12
|
+
- User has a feature spec (e.g., `docs/features/*.md`) and wants implementation docs
|
|
13
|
+
- User asks to create model or command documentation
|
|
14
|
+
- User references `model.yml` or `command.yml` schemas
|
|
15
|
+
|
|
16
|
+
## Workflow
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
ANALYZE → SCAFFOLD → POPULATE → VALIDATE
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### 1. Analyze
|
|
23
|
+
|
|
24
|
+
Read the feature spec and identify:
|
|
25
|
+
|
|
26
|
+
- **Models**: Entities with state, fields, relationships
|
|
27
|
+
- **Commands**: Operations that change state (look for verbs in state diagrams)
|
|
28
|
+
|
|
29
|
+
### 2. Scaffold
|
|
30
|
+
|
|
31
|
+
For each model and command, scaffold the documentation files using `erp-kit` CLI:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
erp-kit scaffold --modules-root modules model <module-name> <model-name>
|
|
35
|
+
erp-kit scaffold --modules-root modules command <module-name> <command-name>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### 3. Populate
|
|
39
|
+
|
|
40
|
+
Fill in the scaffolded docs with details analyzed from Step 1.
|
|
41
|
+
|
|
42
|
+
### 4. Validate
|
|
43
|
+
|
|
44
|
+
Run `pnpm run module:doc:check` and fix any violations.
|
|
45
|
+
|
|
46
|
+
## Schema Quick Reference
|
|
47
|
+
|
|
48
|
+
Schemas are bundled in `@tailor-platform/erp-kit` (model.yml, command.yml).
|
|
49
|
+
|
|
50
|
+
## Common Patterns
|
|
51
|
+
|
|
52
|
+
| Feature Element | Documentation Type |
|
|
53
|
+
| --------------------- | -------------------------------- |
|
|
54
|
+
| Entity with fields | Model doc |
|
|
55
|
+
| State machine | Model doc with State Transitions |
|
|
56
|
+
| Verb in state diagram | Command doc |
|
|
57
|
+
| CRUD operation | Command doc |
|
|
58
|
+
| Validation logic | Command doc Business Rules |
|
|
59
|
+
|
|
60
|
+
## Validation
|
|
61
|
+
|
|
62
|
+
Always run before completing:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
pnpm run module:doc:check
|
|
66
|
+
```
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: 3-module-review
|
|
3
|
+
description: Review feature parity between feature documentation and command/model documentation. Use when validating that all feature scenarios are covered by command docs, and that all required models exist.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Feature Parity Review Workflow
|
|
7
|
+
|
|
8
|
+
Review **documentation consistency** between feature specs and command/model docs.
|
|
9
|
+
|
|
10
|
+
## Purpose
|
|
11
|
+
|
|
12
|
+
Verify that feature documentation (high-level business requirements) is properly covered by command documentation (command specifications) and model documentation (data structures).
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
Feature Docs (What) → Command Docs (How) → Model Docs (With What)
|
|
16
|
+
↓ ↓ ↓
|
|
17
|
+
Scenarios Business Rules Data Structures
|
|
18
|
+
Process Flows Error Scenarios Relationships
|
|
19
|
+
Test Cases Process Flows Constraints
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## When to Use
|
|
23
|
+
|
|
24
|
+
- After writing feature documentation, check for gaps in command/model documentation
|
|
25
|
+
- After writing command/model documentation, verify consistency with features
|
|
26
|
+
- Quality check during documentation review
|
|
27
|
+
|
|
28
|
+
## Workflow
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
FEATURE DOCS → COMMAND DOCS → MODEL DOCS → COMPARE → REPORT
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Step-by-Step
|
|
35
|
+
|
|
36
|
+
### 1. Read Feature Documentation
|
|
37
|
+
|
|
38
|
+
Read ALL feature docs:
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
modules/<module-name>/docs/features/*.md
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### 2. Read Command Documentation
|
|
45
|
+
|
|
46
|
+
Read ALL command docs:
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
modules/<module-name>/docs/commands/*.md
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### 3. Read Model Documentation
|
|
53
|
+
|
|
54
|
+
Read ALL model docs:
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
modules/<module-name>/docs/models/*.md
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### 4. Feature → Command Parity Check
|
|
61
|
+
|
|
62
|
+
For each feature's scenarios and test cases:
|
|
63
|
+
|
|
64
|
+
| Check Item | Question |
|
|
65
|
+
| ---------------------- | -------------------------------------------------------------------------- |
|
|
66
|
+
| Command existence | Does a command doc exist to implement the scenario? |
|
|
67
|
+
| Business rule coverage | Are feature test cases covered by command business rules? |
|
|
68
|
+
| Error handling | Are expected error cases from feature included in command error scenarios? |
|
|
69
|
+
| Process flow alignment | Does feature process flow match command process flow? |
|
|
70
|
+
|
|
71
|
+
#### How to Check
|
|
72
|
+
|
|
73
|
+
1. List all scenario patterns from feature
|
|
74
|
+
2. Identify required operations (verbs) for each scenario: "Add", "Update", "Delete", "Set default", etc.
|
|
75
|
+
3. Verify corresponding command doc exists
|
|
76
|
+
4. Map feature test cases to command business rules / error scenarios
|
|
77
|
+
|
|
78
|
+
### 5. Feature → Model Parity Check
|
|
79
|
+
|
|
80
|
+
For each entity mentioned in feature:
|
|
81
|
+
|
|
82
|
+
| Check Item | Question |
|
|
83
|
+
| ---------------- | ------------------------------------------------------------------ |
|
|
84
|
+
| Model existence | Does a model doc exist for entities mentioned in feature? |
|
|
85
|
+
| State management | Do feature state transitions match model state transitions? |
|
|
86
|
+
| Relationships | Are relationships shown in feature defined in model relationships? |
|
|
87
|
+
|
|
88
|
+
### 6. Command → Model Consistency Check
|
|
89
|
+
|
|
90
|
+
For each command doc:
|
|
91
|
+
|
|
92
|
+
| Check Item | Question |
|
|
93
|
+
| -------------------------- | -------------------------------------------------------------- |
|
|
94
|
+
| Target model | Does a model doc exist for the model that command operates on? |
|
|
95
|
+
| State transition alignment | Do state changes by command match model state transitions? |
|
|
96
|
+
|
|
97
|
+
### 7. Report Findings
|
|
98
|
+
|
|
99
|
+
```markdown
|
|
100
|
+
## Feature Parity Review Report
|
|
101
|
+
|
|
102
|
+
**Module:** <module-name>
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
### 1. Feature → Command Coverage
|
|
107
|
+
|
|
108
|
+
| Feature | Scenarios | Required Commands | Documented Commands | Gap |
|
|
109
|
+
| ----------- | ----------- | ---------------------------------- | ------------------------- | ------------------ |
|
|
110
|
+
| <feature-1> | N scenarios | <cmd-a>, <cmd-b>, <cmd-c>, <cmd-d> | <cmd-a>, <cmd-b>, <cmd-c> | ❌ <cmd-d> missing |
|
|
111
|
+
| <feature-2> | N scenarios | <cmd-e>, <cmd-f>, <cmd-g> | - | ❌ No command docs |
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
### 2. Feature → Model Coverage
|
|
116
|
+
|
|
117
|
+
| Feature | Required Models | Documented Models | Gap |
|
|
118
|
+
| ----------- | -------------------- | -------------------- | --- |
|
|
119
|
+
| <feature-1> | <Model-A> | <Model-A> | ✅ |
|
|
120
|
+
| <feature-2> | <Model-B>, <Model-A> | <Model-B>, <Model-A> | ✅ |
|
|
121
|
+
| <feature-3> | <Model-C>, <Model-A> | <Model-C>, <Model-A> | ✅ |
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
### 3. Test Case → Business Rule Mapping
|
|
126
|
+
|
|
127
|
+
| Feature | Test Case | Covered by Command | Status |
|
|
128
|
+
| ----------- | ------------------------------------------ | ----------------------- | ----------------- |
|
|
129
|
+
| <feature-1> | "<test case description from feature doc>" | <cmd-a> (business rule) | ✅ |
|
|
130
|
+
| <feature-1> | "<test case description from feature doc>" | <cmd-c> (business rule) | ✅ |
|
|
131
|
+
| <feature-2> | "<test case description from feature doc>" | - | ❌ No command doc |
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
### 4. Missing Documentation
|
|
136
|
+
|
|
137
|
+
#### Missing Command Docs
|
|
138
|
+
|
|
139
|
+
| Feature | Expected Command | Purpose |
|
|
140
|
+
| ----------- | ---------------- | --------------------- |
|
|
141
|
+
| <feature-2> | <cmd-e> | <purpose description> |
|
|
142
|
+
| <feature-2> | <cmd-f> | <purpose description> |
|
|
143
|
+
| <feature-2> | <cmd-g> | <purpose description> |
|
|
144
|
+
|
|
145
|
+
#### Missing Model Docs
|
|
146
|
+
|
|
147
|
+
(none found)
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
### 5. Inconsistencies
|
|
152
|
+
|
|
153
|
+
| Type | Location | Issue |
|
|
154
|
+
| ------------------------- | -------------------------------------- | ----------------------------------------------------------------- |
|
|
155
|
+
| State transition mismatch | <feature-1> feature vs <Model-A> model | Feature shows "<cmd-x>" but no command doc exists |
|
|
156
|
+
| Missing error scenario | <feature-2> feature | "<error case from test cases>" has no corresponding command error |
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
### 6. Summary
|
|
161
|
+
|
|
162
|
+
| Aspect | Status | Details |
|
|
163
|
+
| -------------------------- | ------ | ------------------------------------------- |
|
|
164
|
+
| Feature → Command Coverage | ⚠️ | X/Y features have complete command coverage |
|
|
165
|
+
| Feature → Model Coverage | ✅ | All required models documented |
|
|
166
|
+
| Test Case Coverage | ⚠️ | X/Y test cases mapped to business rules |
|
|
167
|
+
| Documentation Consistency | ⚠️ | N inconsistencies found |
|
|
168
|
+
|
|
169
|
+
### 7. Recommendations
|
|
170
|
+
|
|
171
|
+
1. **Create missing command docs:**
|
|
172
|
+
- List all missing commands grouped by feature
|
|
173
|
+
|
|
174
|
+
2. **Add missing business rules to existing command docs:**
|
|
175
|
+
- Feature test cases not yet mapped to command business rules
|
|
176
|
+
3. **Resolve inconsistencies:**
|
|
177
|
+
- Align state transitions between feature and model docs
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## Common Gaps
|
|
181
|
+
|
|
182
|
+
### Feature → Command
|
|
183
|
+
|
|
184
|
+
- **Orphaned scenarios**: Feature describes operation but no command doc exists
|
|
185
|
+
- **Missing CRUD**: Feature implies create/update/delete but only some are documented
|
|
186
|
+
- **Implicit commands**: Feature scenario requires helper command not documented
|
|
187
|
+
- **Default handling**: Feature mentions "default" selection but no setDefault command
|
|
188
|
+
|
|
189
|
+
### Feature → Model
|
|
190
|
+
|
|
191
|
+
- **Missing models**: Feature references entity with no model doc
|
|
192
|
+
- **State mismatch**: Feature shows states not in model's state diagram
|
|
193
|
+
- **Relationship gaps**: Feature implies relationship not in model doc
|
|
194
|
+
|
|
195
|
+
### Test Case → Business Rule
|
|
196
|
+
|
|
197
|
+
- **Uncovered test cases**: Feature test case has no corresponding business rule
|
|
198
|
+
- **Missing error scenarios**: Feature error case not in command's error scenarios
|
|
199
|
+
- **Validation gaps**: Feature constraint not enforced by any command
|
|
200
|
+
|
|
201
|
+
## Quick Reference: Extraction Patterns
|
|
202
|
+
|
|
203
|
+
### From Feature Docs
|
|
204
|
+
|
|
205
|
+
```markdown
|
|
206
|
+
## Scenario Patterns
|
|
207
|
+
|
|
208
|
+
- **Add <entity>**: ... → Command: add<Entity> / create<Entity>
|
|
209
|
+
- **Change default <entity>**: ... → Command: setDefault<Entity>
|
|
210
|
+
|
|
211
|
+
## Test Cases
|
|
212
|
+
|
|
213
|
+
- Adding a <entity> with valid data creates it in active status
|
|
214
|
+
→ Business rule in add<Entity>
|
|
215
|
+
- Only one <entity> can be default per <parent> at a time
|
|
216
|
+
→ Business rule in setDefault<Entity>
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Expected Command Docs for Feature
|
|
220
|
+
|
|
221
|
+
| Feature Operation | Expected Command Doc |
|
|
222
|
+
| ----------------- | -------------------- |
|
|
223
|
+
| "Add X" | addX / createX |
|
|
224
|
+
| "Update X" | updateX |
|
|
225
|
+
| "Delete X" | deleteX |
|
|
226
|
+
| "Set default X" | setDefaultX |
|
|
227
|
+
| "Activate X" | activateX |
|
|
228
|
+
| "Deactivate X" | deactivateX |
|
|
229
|
+
| "Assign X to Y" | assignXToY |
|
|
230
|
+
| "Remove X from Y" | removeXFromY |
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: 4-module-tdd-implementation
|
|
3
|
+
description: Use when implementing features in any module under modules/. Triggers on TDD workflow, domain command implementation, adding new database models, creating test fixtures, or implementing business logic commands.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# TDD Implementation for Module Development
|
|
7
|
+
|
|
8
|
+
Guide for implementing features in modules using Test-Driven Development.
|
|
9
|
+
|
|
10
|
+
## When to Use
|
|
11
|
+
|
|
12
|
+
- Implementing new domain commands in any module
|
|
13
|
+
- Adding database models with `@tailor-platform/sdk`
|
|
14
|
+
- Creating tests with `@tailor-platform/erp-kit` testing utilities
|
|
15
|
+
- Implementing business logic (CRUD, state transitions, relationships)
|
|
16
|
+
|
|
17
|
+
## Workflow
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
MODELS → ERRORS → FIXTURES → TESTS → IMPLEMENT → EXPORT → VERIFY
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Step-by-Step
|
|
24
|
+
|
|
25
|
+
### 1. Database Models (`src/db/`)
|
|
26
|
+
|
|
27
|
+
See: `.agents/rules/module-development/models.md`
|
|
28
|
+
|
|
29
|
+
### 2. Error Classes (`src/lib/errors.ts`)
|
|
30
|
+
|
|
31
|
+
See: `.agents/rules/module-development/errors.md`
|
|
32
|
+
|
|
33
|
+
### 3. Test Fixtures (`src/testing/fixtures.ts`)
|
|
34
|
+
|
|
35
|
+
See: `.agents/rules/module-development/testing.md`
|
|
36
|
+
|
|
37
|
+
### 4. Write Tests First (`src/command/*.test.ts`)
|
|
38
|
+
|
|
39
|
+
See: `.agents/rules/module-development/testing.md`
|
|
40
|
+
|
|
41
|
+
### 5. Implement Commands (`src/command/*.ts`)
|
|
42
|
+
|
|
43
|
+
See: `.agents/rules/module-development/commands.md`
|
|
44
|
+
|
|
45
|
+
### 6. Export (`src/index.ts`)
|
|
46
|
+
|
|
47
|
+
See: `.agents/rules/module-development/exports.md`
|
|
48
|
+
|
|
49
|
+
### 7. Verify
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
pnpm generate # Regenerate types if models changed
|
|
53
|
+
pnpm lint # Check code style
|
|
54
|
+
pnpm typecheck # Verify TypeScript types
|
|
55
|
+
pnpm test # Run all tests
|
|
56
|
+
```
|