feat(core): add 8 AGENTS.md files (package, layer, domain levels)
This commit is contained in:
28
packages/core/src/application/AGENTS.md
Normal file
28
packages/core/src/application/AGENTS.md
Normal file
@@ -0,0 +1,28 @@
|
||||
# Application Layer — Use Cases + Interfaces
|
||||
|
||||
## Rules
|
||||
|
||||
- Imports from entities/ ONLY
|
||||
- NEVER imports from infrastructure/ or interface-adapters/
|
||||
- Repository interfaces define data access contracts
|
||||
- Service interfaces define external service contracts
|
||||
- Use cases get dependencies via `getInjection()` — never direct import of implementations
|
||||
|
||||
## Adding a New Use Case
|
||||
|
||||
1. Create `src/application/use-cases/{domain}/{verb}-{noun}.use-case.ts`
|
||||
2. Get dependencies via DI: `const repo = getInjection("IMyRepository")`
|
||||
3. Implement business logic using entities and interfaces only
|
||||
4. Write test in `tests/unit/use-cases/{domain}/` using `initializeContainer()`/`destroyContainer()` pattern
|
||||
|
||||
## Adding a New Repository Interface
|
||||
|
||||
1. Create `src/application/repositories/{name}.repository.interface.ts`
|
||||
2. Define interface methods returning entity types
|
||||
3. Export from `src/application/repositories/index.ts`
|
||||
4. Create mock implementation in infrastructure/
|
||||
5. Register in DI container (add symbol, module binding)
|
||||
|
||||
## Adding a New Service Interface
|
||||
|
||||
Same as repository, but in `src/application/services/`
|
||||
30
packages/core/src/application/use-cases/auth/AGENTS.md
Normal file
30
packages/core/src/application/use-cases/auth/AGENTS.md
Normal file
@@ -0,0 +1,30 @@
|
||||
# Auth Domain — Business Rules
|
||||
|
||||
## Responsibility
|
||||
|
||||
Authentication and authorization: sign-in, sign-up, sign-out, session management.
|
||||
|
||||
## Business Rules
|
||||
|
||||
- Passwords are hashed via IAuthenticationService (never stored plain)
|
||||
- Sessions expire after 7 days (configured in mock, real impl may differ)
|
||||
- Sign-up requires unique username
|
||||
- Sign-in verifies password via IAuthenticationService.verifyPassword()
|
||||
- Sign-out invalidates session and returns blank cookie
|
||||
|
||||
## Error Cases
|
||||
|
||||
- `AuthenticationError` — wrong credentials (sign-in) or username taken (sign-up)
|
||||
- `UnauthenticatedError` — invalid/expired session
|
||||
|
||||
## Dependencies
|
||||
|
||||
- `IUsersRepository` — user lookup and creation
|
||||
- `IAuthenticationService` — password hashing, session management
|
||||
|
||||
## Adding a New Auth Use Case
|
||||
|
||||
1. Create `{verb}-{noun}.use-case.ts` in this folder
|
||||
2. Get deps via `getInjection("IUsersRepository")`, `getInjection("IAuthenticationService")`
|
||||
3. Write test first in `tests/unit/use-cases/auth/`
|
||||
4. Use `initializeContainer()`/`destroyContainer()` pattern in tests
|
||||
29
packages/core/src/application/use-cases/content/AGENTS.md
Normal file
29
packages/core/src/application/use-cases/content/AGENTS.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# Content Domain — Business Rules
|
||||
|
||||
## Responsibility
|
||||
|
||||
Article management: creation, retrieval, publishing workflow.
|
||||
|
||||
## Business Rules
|
||||
|
||||
- Articles must have a title and content
|
||||
- Slugs auto-generated from title if not provided
|
||||
- New articles default to "draft" status
|
||||
- Filtering by status, authorId supported
|
||||
- Pagination via limit/offset
|
||||
|
||||
## Error Cases
|
||||
|
||||
- `NotFoundError` — article doesn't exist (future: update/delete)
|
||||
- `UnauthorizedError` — user can't edit article (future)
|
||||
- `InputParseError` — missing required fields (handled by controller)
|
||||
|
||||
## Dependencies
|
||||
|
||||
- `IArticlesRepository` — article CRUD operations
|
||||
|
||||
## Adding a New Content Use Case
|
||||
|
||||
1. Create `{verb}-{noun}.use-case.ts` in this folder
|
||||
2. Get deps via `getInjection("IArticlesRepository")`
|
||||
3. Write test first in `tests/unit/use-cases/content/`
|
||||
Reference in New Issue
Block a user