@martinffx/atelier 1.2.2 → 1.4.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/.codex-plugin/plugin.json +27 -0
- package/CHANGELOG.md +33 -0
- package/README.md +51 -59
- package/agents/architect.md +1 -1
- package/agents/oracle.md +1 -1
- package/dist/atelier.js +14171 -12949
- package/package.json +6 -1
- package/skills/code-commit/SKILL.md +77 -77
- package/skills/code-handoff/SKILL.md +1 -1
- package/skills/code-pull-request/SKILL.md +36 -0
- package/skills/code-pull-request/references/common.md +76 -0
- package/skills/code-pull-request/references/create-pr.md +122 -0
- package/skills/code-pull-request/references/default-template.md +25 -0
- package/skills/code-pull-request/references/leave-comment.md +53 -0
- package/skills/code-pull-request/references/merge-pr.md +94 -0
- package/skills/code-pull-request/references/read-comments.md +61 -0
- package/skills/code-pull-request/references/respond-to-comment.md +66 -0
- package/skills/code-review/SKILL.md +21 -12
- package/skills/code-review/references/reviewers.md +142 -41
- package/skills/code-review/references/rq.md +48 -32
- package/skills/oracle-debug/SKILL.md +218 -0
- package/skills/{code-debug → oracle-debug}/references/bug-patterns.md +3 -3
- package/skills/oracle-domain-modelling/SKILL.md +84 -0
- package/skills/oracle-grill-me/SKILL.md +20 -0
- package/skills/spec-brainstorm/SKILL.md +91 -71
- package/skills/spec-finish/SKILL.md +20 -14
- package/skills/spec-implement/SKILL.md +3 -2
- package/skills/spec-orchestrator/SKILL.md +4 -15
- package/skills/spec-plan/SKILL.md +1 -1
- package/agents/scout.md +0 -40
- package/skills/code-commit/references/pr-workflow.md +0 -145
- package/skills/code-debug/SKILL.md +0 -199
- package/skills/code-docs/SKILL.md +0 -171
- package/skills/code-docs/references/api-docs.md +0 -116
- package/skills/code-docs/references/changelog.md +0 -64
- package/skills/code-docs/references/readme-structure.md +0 -94
- package/skills/oracle-architect/SKILL.md +0 -327
- package/skills/oracle-architect/references/api-design.md +0 -345
- package/skills/oracle-architect/references/data-modeling.md +0 -318
- package/skills/oracle-architect/references/ddd-patterns.md +0 -348
- package/skills/oracle-architect/references/interface-design.md +0 -203
- package/skills/oracle-challenge/SKILL.md +0 -126
- package/skills/oracle-doubt/SKILL.md +0 -252
- package/skills/oracle-doubt/references/adversarial-prompt.md +0 -47
- package/skills/oracle-grillme/SKILL.md +0 -160
- package/skills/oracle-security/SKILL.md +0 -225
- package/skills/oracle-security/references/security-patterns.md +0 -236
- package/skills/oracle-security/references/threat-modeling-guide.md +0 -137
- package/skills/oracle-testing/SKILL.md +0 -237
- package/skills/oracle-testing/references/anti-patterns.md +0 -618
- package/skills/oracle-testing/references/boundaries.md +0 -579
- package/skills/oracle-testing/references/core-testing.md +0 -691
- package/skills/oracle-testing/references/edge-testing.md +0 -794
- package/skills/oracle-testing/references/stub-driven-tdd.md +0 -322
- package/skills/oracle-thinkdeep/SKILL.md +0 -164
- /package/skills/{code-debug → oracle-debug}/references/language-tools.md +0 -0
- /package/skills/{code-debug → oracle-debug}/references/techniques.md +0 -0
- /package/skills/{oracle-grillme → oracle-domain-modelling}/references/ADR-FORMAT.md +0 -0
- /package/skills/{oracle-grillme → oracle-domain-modelling}/references/CONTEXT-FORMAT.md +0 -0
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
# API Documentation Tools
|
|
2
|
-
|
|
3
|
-
## TypeScript/JavaScript
|
|
4
|
-
|
|
5
|
-
### TypeDoc
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install --save-dev typedoc
|
|
9
|
-
|
|
10
|
-
# Generate
|
|
11
|
-
npx typedoc --out docs src/index.ts
|
|
12
|
-
|
|
13
|
-
# Options
|
|
14
|
-
--entryPoints src/
|
|
15
|
-
--out docs/
|
|
16
|
-
--name "My Project"
|
|
17
|
-
--theme default
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
### JSDoc
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
npm install --save-dev jsdoc
|
|
24
|
-
|
|
25
|
-
# Generate
|
|
26
|
-
npx jsdoc src/ -d docs/
|
|
27
|
-
|
|
28
|
-
# Config (jsdoc.json)
|
|
29
|
-
{
|
|
30
|
-
"source": {
|
|
31
|
-
"includePattern": ".+\\.js(doc)?$"
|
|
32
|
-
},
|
|
33
|
-
"opts": {
|
|
34
|
-
"destination": "./docs/"
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
---
|
|
40
|
-
|
|
41
|
-
## Python
|
|
42
|
-
|
|
43
|
-
### Sphinx
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
pip install sphinx
|
|
47
|
-
|
|
48
|
-
# Initialize
|
|
49
|
-
sphinx-quickstart
|
|
50
|
-
|
|
51
|
-
# Build
|
|
52
|
-
make html
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
### pdoc
|
|
56
|
-
|
|
57
|
-
```bash
|
|
58
|
-
pip install pdoc
|
|
59
|
-
|
|
60
|
-
# Generate
|
|
61
|
-
pdoc --output-dir docs src/
|
|
62
|
-
pdoc --logo logo.png src/ # With logo
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
---
|
|
66
|
-
|
|
67
|
-
## Go
|
|
68
|
-
|
|
69
|
-
### godoc
|
|
70
|
-
|
|
71
|
-
```bash
|
|
72
|
-
# Install
|
|
73
|
-
go install golang.org/x/tools/cmd/godoc@latest
|
|
74
|
-
|
|
75
|
-
# Run locally
|
|
76
|
-
godoc -http=:6060
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
### swag (OpenAPI)
|
|
80
|
-
|
|
81
|
-
```bash
|
|
82
|
-
go install github.com/swaggo/swag/cmd/swag@latest
|
|
83
|
-
|
|
84
|
-
# Generate from annotations
|
|
85
|
-
swag init -g cmd/server/main.go
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
---
|
|
89
|
-
|
|
90
|
-
## OpenAPI/Swagger
|
|
91
|
-
|
|
92
|
-
### tools
|
|
93
|
-
|
|
94
|
-
- swagger-cli validate
|
|
95
|
-
- @apidevtools/swagger-cli
|
|
96
|
-
- redoc CLI
|
|
97
|
-
|
|
98
|
-
### Annotations Example
|
|
99
|
-
|
|
100
|
-
```javascript
|
|
101
|
-
/**
|
|
102
|
-
* @openapi
|
|
103
|
-
* /users:
|
|
104
|
-
* get:
|
|
105
|
-
* summary: List users
|
|
106
|
-
* responses:
|
|
107
|
-
* 200:
|
|
108
|
-
* description: User list
|
|
109
|
-
* content:
|
|
110
|
-
* application/json:
|
|
111
|
-
* schema:
|
|
112
|
-
* type: array
|
|
113
|
-
* items:
|
|
114
|
-
* $ref: '#/components/schemas/User'
|
|
115
|
-
*/
|
|
116
|
-
```
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
# Changelog Format
|
|
2
|
-
|
|
3
|
-
## Keep a Changelog
|
|
4
|
-
|
|
5
|
-
Follow: https://keepachangelog.com
|
|
6
|
-
|
|
7
|
-
## Format
|
|
8
|
-
|
|
9
|
-
```markdown
|
|
10
|
-
# Changelog
|
|
11
|
-
|
|
12
|
-
All notable changes to this project will be documented in this file.
|
|
13
|
-
|
|
14
|
-
## [Unreleased]
|
|
15
|
-
|
|
16
|
-
### Added
|
|
17
|
-
- New feature
|
|
18
|
-
|
|
19
|
-
### Changed
|
|
20
|
-
- Changed behavior
|
|
21
|
-
|
|
22
|
-
### Deprecated
|
|
23
|
-
- Soon-to-be removed feature
|
|
24
|
-
|
|
25
|
-
### Removed
|
|
26
|
-
- Now removed feature
|
|
27
|
-
|
|
28
|
-
### Fixed
|
|
29
|
-
- Bug fix
|
|
30
|
-
|
|
31
|
-
### Security
|
|
32
|
-
- Security improvement
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
## Version Template
|
|
36
|
-
|
|
37
|
-
```markdown
|
|
38
|
-
## [1.0.0] - 2024-01-15
|
|
39
|
-
|
|
40
|
-
### Added
|
|
41
|
-
- Users can now authenticate via OAuth
|
|
42
|
-
- New /api/users/:id endpoint
|
|
43
|
-
|
|
44
|
-
### Changed
|
|
45
|
-
- Authentication now uses JWT tokens
|
|
46
|
-
|
|
47
|
-
### Fixed
|
|
48
|
-
- Fixed race condition in user creation
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
## Rules
|
|
52
|
-
|
|
53
|
-
1. One version per section
|
|
54
|
-
2. Chronological order (newest first)
|
|
55
|
-
3. Link to issues/pr
|
|
56
|
-
4. Mention breaking changes
|
|
57
|
-
5. Use imperative mood
|
|
58
|
-
|
|
59
|
-
## Example Entry
|
|
60
|
-
|
|
61
|
-
```markdown
|
|
62
|
-
### Added
|
|
63
|
-
- Add user profile endpoint (#123, @username)
|
|
64
|
-
```
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
# README Structure
|
|
2
|
-
|
|
3
|
-
## Quick Template
|
|
4
|
-
|
|
5
|
-
```markdown
|
|
6
|
-
# Project Name
|
|
7
|
-
|
|
8
|
-
One-sentence description.
|
|
9
|
-
|
|
10
|
-
[](link)
|
|
11
|
-
[](link)
|
|
12
|
-
[](link)
|
|
13
|
-
|
|
14
|
-
## Features
|
|
15
|
-
|
|
16
|
-
- Feature 1
|
|
17
|
-
- Feature 2
|
|
18
|
-
- Feature 3
|
|
19
|
-
|
|
20
|
-
## Quick Start
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
npm install package-name
|
|
24
|
-
npm start
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## Installation
|
|
28
|
-
|
|
29
|
-
### Prerequisites
|
|
30
|
-
|
|
31
|
-
- Node.js 18+
|
|
32
|
-
- npm 9+
|
|
33
|
-
|
|
34
|
-
### Steps
|
|
35
|
-
|
|
36
|
-
1. Clone repo
|
|
37
|
-
2. Install deps: npm install
|
|
38
|
-
3. Configure: cp .env.example .env
|
|
39
|
-
4. Run: npm run dev
|
|
40
|
-
|
|
41
|
-
## Usage
|
|
42
|
-
|
|
43
|
-
```javascript
|
|
44
|
-
const pkg = require('package-name');
|
|
45
|
-
|
|
46
|
-
pkg.doSomething();
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
## API
|
|
50
|
-
|
|
51
|
-
See [API Documentation](docs/api.md).
|
|
52
|
-
|
|
53
|
-
## Configuration
|
|
54
|
-
|
|
55
|
-
| Env | Description | Default |
|
|
56
|
-
|-----|-------------|---------|
|
|
57
|
-
| PORT | Server port | 3000 |
|
|
58
|
-
| DB_URL | Database connection | localhost |
|
|
59
|
-
|
|
60
|
-
## Development
|
|
61
|
-
|
|
62
|
-
```bash
|
|
63
|
-
npm run dev # Start dev server
|
|
64
|
-
npm test # Run tests
|
|
65
|
-
npm run lint # Lint
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## Contributing
|
|
69
|
-
|
|
70
|
-
1. Fork
|
|
71
|
-
2. Branch: feature/my-feature
|
|
72
|
-
3. Commit
|
|
73
|
-
4. PR
|
|
74
|
-
|
|
75
|
-
## License
|
|
76
|
-
|
|
77
|
-
MIT
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
## Sections to Include
|
|
81
|
-
|
|
82
|
-
| Section | Required | Description |
|
|
83
|
-
|---------|----------|-------------|
|
|
84
|
-
| Title + Badges | Yes | Project name, version, status |
|
|
85
|
-
| Description | Yes | What it does |
|
|
86
|
-
| Features | Yes | Key capabilities |
|
|
87
|
-
| Quick Start | Yes | 3-5 commands |
|
|
88
|
-
| Installation | No | Detailed setup |
|
|
89
|
-
| Usage | No | Code examples |
|
|
90
|
-
| API | No | For libraries |
|
|
91
|
-
| Configuration | No | Env vars, settings |
|
|
92
|
-
| Development | No | Dev commands |
|
|
93
|
-
| Contributing | No | How to contribute |
|
|
94
|
-
| License | Yes | Open source license |
|
|
@@ -1,327 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: oracle-architect
|
|
3
|
-
description: DDD and hexagonal architecture with functional core pattern. Use when designing features, modeling domains, breaking down tasks, or understanding component responsibilities.
|
|
4
|
-
user-invocable: false
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Architect Skill
|
|
8
|
-
|
|
9
|
-
## Glossary
|
|
10
|
-
|
|
11
|
-
Precise vocabulary for every architectural decision. Use these terms exactly — consistency is the point.
|
|
12
|
-
|
|
13
|
-
- **Module** — anything with an interface and an implementation (function, class, package, layer). Router, Service, Entity, and Repository are all modules.
|
|
14
|
-
- **Interface** — everything a caller must know to use the module: types, invariants, error modes, ordering, config. Not just the type signature.
|
|
15
|
-
- **Seam** — where a module's interface lives; a place behaviour can be altered without editing in place. The functional core / effectful edge boundary is the primary seam.
|
|
16
|
-
- **Depth** — leverage at the interface. A module is **deep** when a lot of behaviour sits behind a small interface. A module is **shallow** when the interface is nearly as complex as the implementation.
|
|
17
|
-
- **Adapter** — a concrete thing satisfying an interface at a seam. A Postgres repository is an adapter; an in-memory fake for testing is another adapter at the same seam.
|
|
18
|
-
- **Leverage** — what callers get from depth: more capability per unit of interface they learn.
|
|
19
|
-
- **Locality** — what maintainers get from depth: change, bugs, and knowledge concentrate in one place.
|
|
20
|
-
|
|
21
|
-
Key principles (apply to every decision):
|
|
22
|
-
|
|
23
|
-
- **The deletion test.** Imagine deleting the module. If complexity vanishes, it was a pass-through. If complexity reappears across N callers, it was earning its keep.
|
|
24
|
-
- **The interface is the test surface.** Callers and tests cross the same seam. If you want to test past the interface, the module is probably the wrong shape.
|
|
25
|
-
- **One adapter = hypothetical seam. Two adapters = real seam.** Don't introduce a seam unless something actually varies across it.
|
|
26
|
-
|
|
27
|
-
Domain-Driven Design and hexagonal architecture with functional core pattern for feature design.
|
|
28
|
-
|
|
29
|
-
## Architecture Model
|
|
30
|
-
|
|
31
|
-
Unified view of functional core and effectful edge:
|
|
32
|
-
|
|
33
|
-
```
|
|
34
|
-
Effectful Edge (IO) Functional Core (Pure)
|
|
35
|
-
┌─────────────────────────────────┐ ┌──────────────────────────┐
|
|
36
|
-
│ Router → request parsing │ │ Service → orchestration│
|
|
37
|
-
│ Consumer → event handling │───▶│ Entity → domain rules │
|
|
38
|
-
│ Client → external APIs │ │ → validation │
|
|
39
|
-
│ Producer → event publishing │◀───│ → transforms │
|
|
40
|
-
│ Repository→ data persistence │ │ │
|
|
41
|
-
└─────────────────────────────────┘ └──────────────────────────┘
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
**Key Principle:** Business logic lives in the functional core (Service + Entity). IO operations live in the effectful edge. Core defines interfaces; edge implements them (dependency inversion).
|
|
45
|
-
|
|
46
|
-
## Evaluating Architecture Decisions
|
|
47
|
-
|
|
48
|
-
Before creating a new module, run these checks:
|
|
49
|
-
|
|
50
|
-
### Deletion Test
|
|
51
|
-
|
|
52
|
-
> *Imagine deleting the module. If complexity vanishes, it was a pass-through. If complexity reappears across N callers, it was earning its keep.*
|
|
53
|
-
|
|
54
|
-
**When to apply:** Before extracting a new Service, Repository, or utility class.
|
|
55
|
-
|
|
56
|
-
**Example:**
|
|
57
|
-
```
|
|
58
|
-
❌ Shallow: OrderFormatterService with 1 method per field
|
|
59
|
-
→ Deleting it just moves 6 lines into the Router
|
|
60
|
-
→ Interface is as complex as implementation
|
|
61
|
-
|
|
62
|
-
✅ Deep: OrderService with validate → reserve → save → publish
|
|
63
|
-
→ Deleting it replicates orchestration across N handlers
|
|
64
|
-
→ Small interface (createOrder), large implementation
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
### Interface as Test Surface
|
|
68
|
-
|
|
69
|
-
> *Callers and tests cross the same seam. If you want to test past the interface, the module is probably the wrong shape.*
|
|
70
|
-
|
|
71
|
-
**Implication:**
|
|
72
|
-
- Unit tests for Entities test the public interface (validate, transform)
|
|
73
|
-
- Unit tests for Services test through the seam with stub repositories
|
|
74
|
-
- Integration tests for Repositories test the actual adapter
|
|
75
|
-
- If you find yourself testing "internal" methods, the module needs redrawing
|
|
76
|
-
|
|
77
|
-
### Adapter Rule
|
|
78
|
-
|
|
79
|
-
> *One adapter = hypothetical seam. Two adapters = real seam.*
|
|
80
|
-
|
|
81
|
-
**When to apply:** Deciding whether to extract an interface.
|
|
82
|
-
|
|
83
|
-
**Examples:**
|
|
84
|
-
```typescript
|
|
85
|
-
// ❌ Hypothetical seam — only one adapter exists
|
|
86
|
-
interface IEmailClient { send(email: Email): Promise<void>; }
|
|
87
|
-
class SendgridClient implements IEmailClient { ... }
|
|
88
|
-
// No second adapter. The interface adds indirection without value.
|
|
89
|
-
|
|
90
|
-
// ✅ Real seam — two adapters exist
|
|
91
|
-
interface IOrderRepository { save(order: Order): Promise<Order>; }
|
|
92
|
-
class PostgresOrderRepository implements IOrderRepository { ... }
|
|
93
|
-
class InMemoryOrderRepository implements IOrderRepository { ... } // for tests
|
|
94
|
-
// The seam earns its keep because callers vary (production vs test).
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
### Depth Check
|
|
98
|
-
|
|
99
|
-
Prefer deep modules over shallow ones:
|
|
100
|
-
|
|
101
|
-
| Module | Interface Size | Implementation | Depth |
|
|
102
|
-
|--------|--------------|----------------|-------|
|
|
103
|
-
| `OrderValidator` | 3 methods (validate, validateItems, validateAddress) | 30 lines each | Shallow |
|
|
104
|
-
| `Order` (entity) | 4 methods (fromRequest, toRecord, toResponse, validate) | 200 lines of rules, transforms, invariants | **Deep** |
|
|
105
|
-
|
|
106
|
-
**Rule of thumb:** A module's interface should hide at least 3x the complexity it exposes.
|
|
107
|
-
|
|
108
|
-
## Functional Core
|
|
109
|
-
|
|
110
|
-
Pure, deterministic components containing all business logic.
|
|
111
|
-
|
|
112
|
-
### Service Layer
|
|
113
|
-
|
|
114
|
-
**Responsibility:** Orchestrate business operations, coordinate between entities and repositories.
|
|
115
|
-
|
|
116
|
-
**Characteristics:**
|
|
117
|
-
- Pure functions that take data and return results
|
|
118
|
-
- No IO operations (database, HTTP, file system)
|
|
119
|
-
- Calls repositories through interfaces (dependency injection)
|
|
120
|
-
- Composes entity operations into workflows
|
|
121
|
-
- Returns success/error results
|
|
122
|
-
|
|
123
|
-
**Example:**
|
|
124
|
-
```typescript
|
|
125
|
-
class OrderService {
|
|
126
|
-
async createOrder(request: CreateOrderRequest): Promise<Result<Order>> {
|
|
127
|
-
// Validate with entity
|
|
128
|
-
const order = Order.fromRequest(request);
|
|
129
|
-
const validation = order.validate();
|
|
130
|
-
if (!validation.ok) return validation;
|
|
131
|
-
|
|
132
|
-
// Check business rules
|
|
133
|
-
const inventory = await this.inventoryRepo.checkAvailability(order.items);
|
|
134
|
-
if (!inventory.available) return Err('Items not available');
|
|
135
|
-
|
|
136
|
-
// Coordinate persistence
|
|
137
|
-
await this.inventoryRepo.reserve(order.items);
|
|
138
|
-
const saved = await this.orderRepo.save(order.toRecord());
|
|
139
|
-
|
|
140
|
-
return Ok(Order.fromRecord(saved));
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
### Entity Layer
|
|
146
|
-
|
|
147
|
-
**Responsibility:** Domain models, validation, business rules, data transformations.
|
|
148
|
-
|
|
149
|
-
**Characteristics:**
|
|
150
|
-
- Pure data structures with behavior
|
|
151
|
-
- All validation logic
|
|
152
|
-
- Data transformations (fromRequest, toRecord, toResponse)
|
|
153
|
-
- Business rules and invariants
|
|
154
|
-
- No IO, no framework dependencies
|
|
155
|
-
|
|
156
|
-
**Example:**
|
|
157
|
-
```typescript
|
|
158
|
-
class Order {
|
|
159
|
-
constructor(
|
|
160
|
-
public readonly id: string,
|
|
161
|
-
public readonly customerId: string,
|
|
162
|
-
public readonly items: OrderItem[],
|
|
163
|
-
public readonly status: OrderStatus,
|
|
164
|
-
public readonly total: number
|
|
165
|
-
) {}
|
|
166
|
-
|
|
167
|
-
static fromRequest(req: CreateOrderRequest): Order {
|
|
168
|
-
return new Order(
|
|
169
|
-
generateId(),
|
|
170
|
-
req.customerId,
|
|
171
|
-
req.items.map(i => new OrderItem(i)),
|
|
172
|
-
'pending',
|
|
173
|
-
req.items.reduce((sum, i) => sum + i.price * i.quantity, 0)
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
toRecord(): OrderRecord {
|
|
178
|
-
return {
|
|
179
|
-
id: this.id,
|
|
180
|
-
customer_id: this.customerId,
|
|
181
|
-
items: JSON.stringify(this.items),
|
|
182
|
-
status: this.status,
|
|
183
|
-
total: this.total
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
validate(): Result<Order> {
|
|
188
|
-
if (this.items.length === 0) {
|
|
189
|
-
return Err('Order must have at least one item');
|
|
190
|
-
}
|
|
191
|
-
if (this.total < 0) {
|
|
192
|
-
return Err('Order total cannot be negative');
|
|
193
|
-
}
|
|
194
|
-
return Ok(this);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
canCancel(): boolean {
|
|
198
|
-
return ['pending', 'confirmed'].includes(this.status);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
## Effectful Edge
|
|
204
|
-
|
|
205
|
-
IO-performing components that interact with the outside world.
|
|
206
|
-
|
|
207
|
-
### Router
|
|
208
|
-
|
|
209
|
-
**Responsibility:** HTTP request handling, parsing, response formatting.
|
|
210
|
-
|
|
211
|
-
**Characteristics:**
|
|
212
|
-
- Parses HTTP requests into domain types
|
|
213
|
-
- Calls service layer with parsed data
|
|
214
|
-
- Formats service results into HTTP responses
|
|
215
|
-
- Handles HTTP-specific concerns (status codes, headers)
|
|
216
|
-
- No business logic
|
|
217
|
-
|
|
218
|
-
**Example:**
|
|
219
|
-
```typescript
|
|
220
|
-
router.post('/orders', async (req, res) => {
|
|
221
|
-
const result = await orderService.createOrder(req.body);
|
|
222
|
-
|
|
223
|
-
if (result.ok) {
|
|
224
|
-
res.status(201).json(result.value.toResponse());
|
|
225
|
-
} else {
|
|
226
|
-
res.status(400).json({ error: result.error });
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
### Repository
|
|
232
|
-
|
|
233
|
-
**Responsibility:** Data persistence and retrieval.
|
|
234
|
-
|
|
235
|
-
**Characteristics:**
|
|
236
|
-
- Implements data access interface used by services
|
|
237
|
-
- Converts between domain entities and database records
|
|
238
|
-
- Handles database queries and transactions
|
|
239
|
-
- No business logic or validation
|
|
240
|
-
|
|
241
|
-
**Example:**
|
|
242
|
-
```typescript
|
|
243
|
-
class OrderRepository {
|
|
244
|
-
async save(record: OrderRecord): Promise<OrderRecord> {
|
|
245
|
-
return await db.orders.create(record);
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
async findById(id: string): Promise<OrderRecord | null> {
|
|
249
|
-
return await db.orders.findOne({ id });
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
## Component Matrix
|
|
255
|
-
|
|
256
|
-
Quick reference for where things belong:
|
|
257
|
-
|
|
258
|
-
| Concern | Component | Layer | Testability |
|
|
259
|
-
|---------|-----------|-------|-------------|
|
|
260
|
-
| Domain model | Entity | Core | Unit test (pure) |
|
|
261
|
-
| Validation | Entity | Core | Unit test (pure) |
|
|
262
|
-
| Business rules | Entity | Core | Unit test (pure) |
|
|
263
|
-
| Orchestration | Service | Core | Unit test (stub repos) |
|
|
264
|
-
| Data transforms | Entity | Core | Unit test (pure) |
|
|
265
|
-
| HTTP parsing | Router | Edge | Integration test |
|
|
266
|
-
| Data access | Repository | Edge | Integration test |
|
|
267
|
-
| External APIs | Client | Edge | Integration test |
|
|
268
|
-
| Event handling | Consumer | Edge | Integration test |
|
|
269
|
-
| Event publishing | Producer | Edge | Integration test |
|
|
270
|
-
|
|
271
|
-
## Task Breakdown
|
|
272
|
-
|
|
273
|
-
### Bottom-Up Dependency Ordering
|
|
274
|
-
|
|
275
|
-
Implementation order follows dependency chain:
|
|
276
|
-
|
|
277
|
-
```
|
|
278
|
-
1. Entity → Domain models, validation, transforms
|
|
279
|
-
2. Repository → Data access interfaces and implementations
|
|
280
|
-
3. Service → Business logic orchestration
|
|
281
|
-
4. Router → HTTP endpoints
|
|
282
|
-
```
|
|
283
|
-
|
|
284
|
-
**Rationale:** Each layer depends on layers below. Can't implement service without entity, can't implement router without service.
|
|
285
|
-
|
|
286
|
-
### Task Granularity
|
|
287
|
-
|
|
288
|
-
**One task per layer:**
|
|
289
|
-
- Implement Order entity with validation
|
|
290
|
-
- Implement OrderRepository with data access
|
|
291
|
-
- Implement OrderService with business logic
|
|
292
|
-
- Implement order API endpoints
|
|
293
|
-
|
|
294
|
-
**For complex features, break down further:**
|
|
295
|
-
- Entity: Order, OrderItem, OrderStatus
|
|
296
|
-
- Repository: OrderRepository, InventoryRepository
|
|
297
|
-
- Service: OrderService, PaymentService
|
|
298
|
-
- Router: Order routes, Payment routes
|
|
299
|
-
|
|
300
|
-
## Architect → Testing Flow
|
|
301
|
-
|
|
302
|
-
Architectural decisions inform testing strategy:
|
|
303
|
-
|
|
304
|
-
```
|
|
305
|
-
Architect Outputs → Testing Inputs
|
|
306
|
-
────────────────────────────────────────────────
|
|
307
|
-
Component responsibilities → What to test
|
|
308
|
-
Layer boundaries → Where to test
|
|
309
|
-
Pure vs effectful → Unit vs integration
|
|
310
|
-
Entity transformations → Property-based tests
|
|
311
|
-
Service orchestration → Stub-driven tests
|
|
312
|
-
```
|
|
313
|
-
|
|
314
|
-
The testing skill uses architectural structure to determine:
|
|
315
|
-
- What gets unit tested (core) vs integration tested (edge)
|
|
316
|
-
- Where to place test boundaries
|
|
317
|
-
- What to stub and what to test for real
|
|
318
|
-
- What test cases validate business rules
|
|
319
|
-
|
|
320
|
-
## Reference Materials
|
|
321
|
-
|
|
322
|
-
For detailed patterns and examples:
|
|
323
|
-
|
|
324
|
-
- **See [references/ddd-patterns.md](references/ddd-patterns.md)** - Aggregates, Value Objects, Domain Events, Bounded Contexts, composition patterns, seam placement
|
|
325
|
-
- **See [references/data-modeling.md](references/data-modeling.md)** - Entity design principles, schema patterns, access pattern optimization, data transformation
|
|
326
|
-
- **See [references/api-design.md](references/api-design.md)** - REST conventions, request/response contracts, error handling, versioning patterns
|
|
327
|
-
- **See [references/interface-design.md](references/interface-design.md)** - Designing module interfaces, "Design It Twice" pattern, depth heuristics, dependency categories, anti-patterns
|