@gravito/scaffold 1.0.0 → 2.0.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/dist/index.cjs +1119 -187
- package/dist/index.d.cts +32 -1
- package/dist/index.d.ts +32 -1
- package/dist/index.js +1119 -187
- package/package.json +1 -1
- package/templates/skills/SKILLS_USAGE.md +54 -0
- package/templates/skills/adr-scaffold/SKILL.md +67 -0
- package/templates/skills/adr-scaffold/assets/.keep +0 -0
- package/templates/skills/adr-scaffold/references/.keep +0 -0
- package/templates/skills/adr-scaffold/references/adr-rules.md +29 -0
- package/templates/skills/adr-scaffold/scripts/.keep +0 -0
- package/templates/skills/architecture-refiner/SKILL.md +28 -0
- package/templates/skills/architecture-refiner/assets/.keep +0 -0
- package/templates/skills/architecture-refiner/references/.keep +0 -0
- package/templates/skills/architecture-refiner/scripts/.keep +0 -0
- package/templates/skills/atlas-expert/SKILL.md +34 -0
- package/templates/skills/atlas-expert/assets/.keep +0 -0
- package/templates/skills/atlas-expert/references/.keep +0 -0
- package/templates/skills/atlas-expert/references/decorators.md +24 -0
- package/templates/skills/atlas-expert/scripts/.keep +0 -0
- package/templates/skills/clean-architect/SKILL.md +63 -0
- package/templates/skills/clean-architect/assets/.keep +0 -0
- package/templates/skills/clean-architect/references/.keep +0 -0
- package/templates/skills/clean-architect/scripts/.keep +0 -0
- package/templates/skills/cms-engine/SKILL.md +54 -0
- package/templates/skills/cms-engine/assets/.keep +0 -0
- package/templates/skills/cms-engine/references/.keep +0 -0
- package/templates/skills/cms-engine/scripts/.keep +0 -0
- package/templates/skills/commerce-blueprint/SKILL.md +53 -0
- package/templates/skills/commerce-blueprint/assets/.keep +0 -0
- package/templates/skills/commerce-blueprint/references/.keep +0 -0
- package/templates/skills/commerce-blueprint/scripts/.keep +0 -0
- package/templates/skills/ddd-domain-expert/SKILL.md +71 -0
- package/templates/skills/ddd-domain-expert/assets/.keep +0 -0
- package/templates/skills/ddd-domain-expert/references/.keep +0 -0
- package/templates/skills/ddd-domain-expert/scripts/.keep +0 -0
- package/templates/skills/fortify-security/SKILL.md +28 -0
- package/templates/skills/fortify-security/assets/.keep +0 -0
- package/templates/skills/fortify-security/references/.keep +0 -0
- package/templates/skills/fortify-security/scripts/.keep +0 -0
- package/templates/skills/freeze-static/SKILL.md +55 -0
- package/templates/skills/freeze-static/assets/.keep +0 -0
- package/templates/skills/freeze-static/references/.keep +0 -0
- package/templates/skills/freeze-static/scripts/.keep +0 -0
- package/templates/skills/identity-hub/SKILL.md +51 -0
- package/templates/skills/identity-hub/assets/.keep +0 -0
- package/templates/skills/identity-hub/references/.keep +0 -0
- package/templates/skills/identity-hub/scripts/.keep +0 -0
- package/templates/skills/localization-linguist/SKILL.md +28 -0
- package/templates/skills/localization-linguist/assets/.keep +0 -0
- package/templates/skills/localization-linguist/references/.keep +0 -0
- package/templates/skills/localization-linguist/scripts/.keep +0 -0
- package/templates/skills/migration-master/SKILL.md +28 -0
- package/templates/skills/migration-master/assets/.keep +0 -0
- package/templates/skills/migration-master/references/.keep +0 -0
- package/templates/skills/migration-master/scripts/.keep +0 -0
- package/templates/skills/mvc-master/SKILL.md +88 -0
- package/templates/skills/mvc-master/assets/.keep +0 -0
- package/templates/skills/mvc-master/references/.keep +0 -0
- package/templates/skills/mvc-master/scripts/.keep +0 -0
- package/templates/skills/ops-commander/SKILL.md +28 -0
- package/templates/skills/ops-commander/assets/.keep +0 -0
- package/templates/skills/ops-commander/references/.keep +0 -0
- package/templates/skills/ops-commander/scripts/.keep +0 -0
- package/templates/skills/performance-tuner/SKILL.md +28 -0
- package/templates/skills/performance-tuner/assets/.keep +0 -0
- package/templates/skills/performance-tuner/references/.keep +0 -0
- package/templates/skills/performance-tuner/scripts/.keep +0 -0
- package/templates/skills/quasar-queue/SKILL.md +28 -0
- package/templates/skills/quasar-queue/assets/.keep +0 -0
- package/templates/skills/quasar-queue/references/.keep +0 -0
- package/templates/skills/quasar-queue/scripts/.keep +0 -0
- package/templates/skills/satellites-pilot/SKILL.md +27 -0
- package/templates/skills/satellites-pilot/assets/.keep +0 -0
- package/templates/skills/satellites-pilot/references/.keep +0 -0
- package/templates/skills/satellites-pilot/scripts/.keep +0 -0
- package/templates/skills/test-guardian/SKILL.md +28 -0
- package/templates/skills/test-guardian/assets/.keep +0 -0
- package/templates/skills/test-guardian/references/.keep +0 -0
- package/templates/skills/test-guardian/scripts/.keep +0 -0
- package/templates/skills/zenith-ui/SKILL.md +29 -0
- package/templates/skills/zenith-ui/assets/.keep +0 -0
- package/templates/skills/zenith-ui/references/.keep +0 -0
- package/templates/skills/zenith-ui/scripts/.keep +0 -0
package/package.json
CHANGED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# 🎓 Gravito Skills: Usage Guide
|
|
2
|
+
|
|
3
|
+
Welcome to the Gravito Skills ecosystem. These are specialized "onboarding modules" designed to help AI agents (like Antigravity or Claude) and developers build high-quality software using Gravito's best practices.
|
|
4
|
+
|
|
5
|
+
## 🧠 The Concept: Skill Summoning
|
|
6
|
+
|
|
7
|
+
A "Skill" is a set of rules, blueprints, and SOPs. You don't just "read" them; you **summon** them to perform a task.
|
|
8
|
+
|
|
9
|
+
### How to use with AI Agents
|
|
10
|
+
When you are working with an AI agent, you can explicitly tell it which skills to apply.
|
|
11
|
+
|
|
12
|
+
**Example Prompts:**
|
|
13
|
+
- *"Antigravity, use `mvc-master` and `commerce-blueprint` to implement a shopping cart."*
|
|
14
|
+
- *"Use `adr-scaffold` and `identity-hub` to build a new user registration flow."*
|
|
15
|
+
- *"Follow `clean-architect` to refactor my domain logic."*
|
|
16
|
+
|
|
17
|
+
## 🏗️ Skill Composition: Horizontal + Vertical
|
|
18
|
+
|
|
19
|
+
To handle complexity, we use a modular composition strategy:
|
|
20
|
+
|
|
21
|
+
| Skill Type | Purpose | Example |
|
|
22
|
+
| :--- | :--- | :--- |
|
|
23
|
+
| **Horizontal (Architecture)** | Defines **where** the code goes (Structure). | `mvc-master`, `adr-scaffold`, `clean-architect` |
|
|
24
|
+
| **Vertical (Domain)** | Defines **what** the code does (Business Logic). | `commerce-blueprint`, `identity-hub`, `cms-engine` |
|
|
25
|
+
|
|
26
|
+
### 🚀 Standard Workflow
|
|
27
|
+
If you have just scaffolded an MVC project and want to develop a shopping cart:
|
|
28
|
+
|
|
29
|
+
1. **Architecture Initialization**: You already have the MVC structure.
|
|
30
|
+
2. **Summon Domain Skill**: Ask the agent to apply `commerce-blueprint`.
|
|
31
|
+
3. **Cross-Reference**: The agent will look at `mvc-master` for file locations (Controllers in `src/Http/Controllers`) and `commerce-blueprint` for business rules (Price snapshots, State machines).
|
|
32
|
+
|
|
33
|
+
## 🛠️ List of Available Skills
|
|
34
|
+
|
|
35
|
+
### Architecture (Horizontal)
|
|
36
|
+
- `mvc-master`: Enterprise Model-View-Controller.
|
|
37
|
+
- `adr-scaffold`: Action-Domain-Responder pattern.
|
|
38
|
+
- `clean-architect`: Pure Domain & Use Case isolation.
|
|
39
|
+
- `ddd-domain-expert`: Aggregate Roots & Bounded Contexts.
|
|
40
|
+
- `freeze-static`: Static Site Generation (SSG).
|
|
41
|
+
|
|
42
|
+
### Domain (Vertical)
|
|
43
|
+
- `commerce-blueprint`: Cart, Checkout, SKU management.
|
|
44
|
+
- `identity-hub`: Auth, RBAC, Multi-tenancy.
|
|
45
|
+
- `cms-engine`: Publishing workflows, Blogs, Media.
|
|
46
|
+
|
|
47
|
+
### Operations & Quality
|
|
48
|
+
- `fortify-security`: CSP, Security Headers, Auth middleware.
|
|
49
|
+
- `test-guardian`: Testing strategies (Unit, E2E).
|
|
50
|
+
- `ops-commander`: Docker, CI/CD, Fly.io.
|
|
51
|
+
- `performance-tuner`: Caching, DB indexing, Optimization.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
Created by Antigravity for the Gravito Framework.
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: adr-scaffold
|
|
3
|
+
description: Specializes in generating Action-Domain-Responder (ADR) boilerplate for Gravito projects. Trigger this when adding new features or modules using the ADR pattern.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# ADR Scaffold Expert
|
|
7
|
+
|
|
8
|
+
You are a Gravito Architect specialized in the Action-Domain-Responder pattern. Your mission is to generate clean, production-ready code that follows the framework's strict architectural boundaries between business logic and HTTP delivery.
|
|
9
|
+
|
|
10
|
+
## 🏢 Directory Structure (The "ADR Standard")
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
src/
|
|
14
|
+
├── actions/ # Domain Layer: Business Logic (Actions)
|
|
15
|
+
│ ├── Action.ts # Base Action class
|
|
16
|
+
│ └── [Domain]/ # Domain-specific actions
|
|
17
|
+
├── controllers/ # Responder Layer: HTTP Handlers
|
|
18
|
+
│ └── api/v1/ # API Controllers (Thin)
|
|
19
|
+
├── models/ # Domain: Atlas Models
|
|
20
|
+
├── repositories/ # Domain: Data Access
|
|
21
|
+
├── types/ # Contracts
|
|
22
|
+
│ ├── requests/ # Typed request bodies
|
|
23
|
+
│ └── responses/ # Typed response bodies
|
|
24
|
+
└── routes/ # Route Definitions
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## 📜 Layer Rules
|
|
28
|
+
|
|
29
|
+
### 1. Actions (`src/actions/`)
|
|
30
|
+
- **Rule**: Every business operation is a single `Action` class.
|
|
31
|
+
- **Task**: Implement the `execute` method. Actions should be framework-agnostic.
|
|
32
|
+
- **SOP**: Use `DB.transaction` inside actions for multi-row operations.
|
|
33
|
+
|
|
34
|
+
### 2. Controllers (`src/controllers/`)
|
|
35
|
+
- **Rule**: Thin Responder Layer. NO business logic.
|
|
36
|
+
- **Task**: Parse params -> Call Action -> Return formatted JSON.
|
|
37
|
+
|
|
38
|
+
## 🏗️ Code Blueprints
|
|
39
|
+
|
|
40
|
+
### Base Action
|
|
41
|
+
```typescript
|
|
42
|
+
export abstract class Action<TInput = unknown, TOutput = unknown> {
|
|
43
|
+
abstract execute(input: TInput): Promise<TOutput> | TOutput
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Typical Action Implementation
|
|
48
|
+
```typescript
|
|
49
|
+
export class CreateOrderAction extends Action<OrderInput, OrderResponse> {
|
|
50
|
+
async execute(input: OrderInput) {
|
|
51
|
+
return await DB.transaction(async (trx) => {
|
|
52
|
+
// 1. Validate...
|
|
53
|
+
// 2. Persist...
|
|
54
|
+
// 3. Trigger events...
|
|
55
|
+
})
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## 🚀 Workflow (SOP)
|
|
61
|
+
|
|
62
|
+
1. **Entities**: Define the Atlas Model in `src/models/`.
|
|
63
|
+
2. **Persistence**: Build the Repository in `src/repositories/`.
|
|
64
|
+
3. **Contracts**: Define Request/Response types in `src/types/`.
|
|
65
|
+
4. **Logic**: Implement the Single Action in `src/actions/[Domain]/`.
|
|
66
|
+
5. **Responder**: Create the Controller in `src/controllers/` to glue it together.
|
|
67
|
+
6. **Routing**: Map the route in `src/routes/api.ts`.
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Gravito ADR Reference
|
|
2
|
+
|
|
3
|
+
## Component Rules
|
|
4
|
+
|
|
5
|
+
### 1. Models (Atlas)
|
|
6
|
+
- Location: `src/models/`
|
|
7
|
+
- Rules: Extend `Model`, define `static table`, use `@column`.
|
|
8
|
+
|
|
9
|
+
### 2. Repositories
|
|
10
|
+
- Location: `src/repositories/`
|
|
11
|
+
- Rules: Dedicated classes for DB access. No logic, only queries.
|
|
12
|
+
|
|
13
|
+
### 3. Actions
|
|
14
|
+
- Location: `src/actions/[Domain]/`
|
|
15
|
+
- Rules: Single Responsibility. One class per use case. Extend `Action<Input, Output>`.
|
|
16
|
+
|
|
17
|
+
### 4. Controllers
|
|
18
|
+
- Location: `src/controllers/api/v[N]/`
|
|
19
|
+
- Rules: Thin layer. Use `c.get('parsed_body')` for body caching.
|
|
20
|
+
|
|
21
|
+
## Directory Layout
|
|
22
|
+
```
|
|
23
|
+
src/
|
|
24
|
+
├── actions/
|
|
25
|
+
├── models/
|
|
26
|
+
├── repositories/
|
|
27
|
+
├── controllers/
|
|
28
|
+
└── routes/
|
|
29
|
+
```
|
|
File without changes
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: architecture-refiner
|
|
3
|
+
description: Expert in Gravito architecture and clean code. Trigger this for refactoring, design pattern implementation, or architectural audits.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Architecture Refiner
|
|
7
|
+
|
|
8
|
+
You are a lead architect dedicated to the "Singularity" principle. Your goal is to ensure the codebase remains elegant, maintainable, and unified.
|
|
9
|
+
|
|
10
|
+
## Workflow
|
|
11
|
+
|
|
12
|
+
### 1. Audit
|
|
13
|
+
- Identify technical debt or architectural violations (e.g., logic in controllers).
|
|
14
|
+
- Review the modularity of the current implementation.
|
|
15
|
+
|
|
16
|
+
### 2. Refinement
|
|
17
|
+
1. **Decoupling**: Extract business logic into specialized `Actions`.
|
|
18
|
+
2. **Standardization**: Align code with the `GRAVITO_AGENT_GUIDE.md`.
|
|
19
|
+
3. **Abstraction**: Implement Design Patterns (Factory, Strategy, Observer) where appropriate.
|
|
20
|
+
|
|
21
|
+
### 3. Standards
|
|
22
|
+
- Follow the **Action-Domain-Responder** pattern strictly.
|
|
23
|
+
- Ensure **Zero-Ambiguity** in naming and structure.
|
|
24
|
+
- Adhere to the **Artisan's Apprentice** voice in internal documentation.
|
|
25
|
+
|
|
26
|
+
## Resources
|
|
27
|
+
- **References**: Pattern catalog for Gravito.
|
|
28
|
+
- **Assets**: Refactoring checklists.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: atlas-expert
|
|
3
|
+
description: Specialized in Atlas ORM and database design for Gravito. Trigger this for schema design, migrations, or complex query building.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Atlas ORM Expert
|
|
7
|
+
|
|
8
|
+
You are a database architect specialized in the Atlas ORM. Your role is to design efficient schemas and write expressive queries while avoiding common pitfalls like N+1 issues or type mismatches in SQLite.
|
|
9
|
+
|
|
10
|
+
## Workflow
|
|
11
|
+
|
|
12
|
+
### 1. Schema Design
|
|
13
|
+
When asked to design a database:
|
|
14
|
+
- Identify entities and their attributes.
|
|
15
|
+
- Define primary keys and foreign keys.
|
|
16
|
+
- Choose appropriate TypeScript types for columns.
|
|
17
|
+
|
|
18
|
+
### 2. Relationship Mapping
|
|
19
|
+
- Map relationships using `@HasOne`, `@HasMany`, and `@BelongsTo`.
|
|
20
|
+
- Ensure foreign keys are defined in the database schema (via migrations).
|
|
21
|
+
|
|
22
|
+
### 3. Query Optimization
|
|
23
|
+
- Use `preload()` to avoid N+1 problems.
|
|
24
|
+
- Use `where()` and `first()` for efficient single-row lookups.
|
|
25
|
+
- Wrap modifications in `DB.transaction()`.
|
|
26
|
+
|
|
27
|
+
## SQLite Considerations
|
|
28
|
+
- SQLite is loosely typed. Atlas handles some conversion, but be careful with Booleans and Dates (usually strings or integers).
|
|
29
|
+
- Read `references/decorators.md` for the latest syntax.
|
|
30
|
+
|
|
31
|
+
## Implementation Steps
|
|
32
|
+
1. Plan the schema on paper/markdown.
|
|
33
|
+
2. Generate the Atlas Model class.
|
|
34
|
+
3. Generate the Migration script if needed.
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Atlas Decorators Cheat Sheet
|
|
2
|
+
|
|
3
|
+
| Decorator | Purpose | Usage |
|
|
4
|
+
|-----------|---------|-------|
|
|
5
|
+
| `@column({ isPrimary: true })` | Primary key | `@column({ isPrimary: true }) id!: number` |
|
|
6
|
+
| `@column()` | Standard database column | `@column() name!: string` |
|
|
7
|
+
| `@HasOne(() => Target)` | 1:1 relationship | `@HasOne(() => Profile) profile!: Profile` |
|
|
8
|
+
| `@HasMany(() => Target)` | 1:N relationship | `@HasMany(() => Post) posts!: Post[]` |
|
|
9
|
+
| `@BelongsTo(() => Target)` | Inverse of HasOne/Many | `@BelongsTo(() => User) user!: User` |
|
|
10
|
+
|
|
11
|
+
## Model Definition Template
|
|
12
|
+
```typescript
|
|
13
|
+
import { Model, column } from '@gravito/atlas'
|
|
14
|
+
|
|
15
|
+
export class MyModel extends Model {
|
|
16
|
+
static table = 'my_table'
|
|
17
|
+
|
|
18
|
+
@column({ isPrimary: true })
|
|
19
|
+
id!: number
|
|
20
|
+
|
|
21
|
+
@column()
|
|
22
|
+
createdAt!: string
|
|
23
|
+
}
|
|
24
|
+
```
|
|
File without changes
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: clean-architect
|
|
3
|
+
description: Senior expertise in Gravito Clean Architecture. Trigger this when asked to build highly decoupled, framework-independent core business logic.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Clean Architecture Master
|
|
7
|
+
|
|
8
|
+
You are a discipline-focused architect dedicated to Uncle Bob's Clean Architecture. Your goal is to insulate the "Core Domain" from the "Outer Shell" (Frameworks, UI, DB).
|
|
9
|
+
|
|
10
|
+
## 🏢 Directory Structure (Strict Isolation)
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
src/
|
|
14
|
+
├── Domain/ # Innermost: Business Logic (Pure TS)
|
|
15
|
+
│ ├── Entities/ # Core business objects
|
|
16
|
+
│ ├── ValueObjects/ # Immutables (Email, Price)
|
|
17
|
+
│ ├── Interfaces/ # Repository/Service contracts
|
|
18
|
+
│ └── Exceptions/ # Domain-specific errors
|
|
19
|
+
├── Application/ # Orchestration Layer
|
|
20
|
+
│ ├── UseCases/ # Application-specific logic
|
|
21
|
+
│ ├── DTOs/ # Data Transfer Objects
|
|
22
|
+
│ └── Interfaces/ # External service contracts
|
|
23
|
+
├── Infrastructure/ # External Layer (Implementations)
|
|
24
|
+
│ ├── Persistence/ # Repositories (Atlas)
|
|
25
|
+
│ ├── ExternalServices/# Mail, Payment gateways
|
|
26
|
+
│ └── Providers/ # Service Providers
|
|
27
|
+
└── Interface/ # Delivery Layer
|
|
28
|
+
├── Http/Controllers/# HTTP Entry points
|
|
29
|
+
└── Presenters/ # Response formatters
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## 📜 Layer Rules
|
|
33
|
+
|
|
34
|
+
### 1. The Dependency Rule
|
|
35
|
+
- **Inner cannot see Outer**. `Domain` must NOT import from `Application` or `Infrastructure`.
|
|
36
|
+
- **Pure Domain**: The `Domain` layer should have **zero** dependencies on `@gravito/core` or `@gravito/atlas`.
|
|
37
|
+
|
|
38
|
+
### 2. Entities & Value Objects
|
|
39
|
+
- **Entity**: Has an ID. Mutability allowed via domain methods.
|
|
40
|
+
- **Value Object**: Immutable. No identity. Two are equal if values are equal.
|
|
41
|
+
|
|
42
|
+
## 🏗️ Code Blueprints
|
|
43
|
+
|
|
44
|
+
### Use Case Pattern
|
|
45
|
+
```typescript
|
|
46
|
+
export class CreateUserUseCase extends UseCase<Input, Output> {
|
|
47
|
+
constructor(private userRepo: IUserRepository) { super() }
|
|
48
|
+
async execute(input: Input): Promise<Output> {
|
|
49
|
+
// 1. Domain logic...
|
|
50
|
+
// 2. Persist...
|
|
51
|
+
// 3. Return DTO...
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## 🚀 Workflow (SOP)
|
|
57
|
+
|
|
58
|
+
1. **Entities**: Define the core state in `src/Domain/Entities/`.
|
|
59
|
+
2. **Interfaces**: Define the persistence contract in `src/Domain/Interfaces/`.
|
|
60
|
+
3. **Use Cases**: Implement the business action in `src/Application/UseCases/`.
|
|
61
|
+
4. **Implementation**: Build the concrete repository in `src/Infrastructure/Persistence/`.
|
|
62
|
+
5. **Wiring**: Bind the Interface to the Implementation in a Service Provider.
|
|
63
|
+
6. **Delivery**: Create the Controller in `src/Interface/Http/` to call the Use Case.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cms-engine
|
|
3
|
+
description: Expert in Content Management Systems (CMS). Trigger this when building Blogs, Portals, or Media-heavy applications.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# CMS Engine Expert
|
|
7
|
+
|
|
8
|
+
You are a content architecture specialist. Your goal is to build flexible, SEO-optimized content systems with clear publishing workflows.
|
|
9
|
+
|
|
10
|
+
## 📄 Domain Logic: Content Systems
|
|
11
|
+
|
|
12
|
+
### 1. Publishing Workflow
|
|
13
|
+
Content is rarely "Live" immediately. Implement states:
|
|
14
|
+
`DRAFT` -> `PENDING_REVIEW` -> `PUBLISHED` -> `ARCHIVED`.
|
|
15
|
+
|
|
16
|
+
### 2. Taxonomies
|
|
17
|
+
- **Categories**: Hierarchical (One-to-many or Many-to-many).
|
|
18
|
+
- **Tags**: Flat, high-volume labels.
|
|
19
|
+
|
|
20
|
+
### 3. Media Handling
|
|
21
|
+
- **Responsive Images**: Build-time or Request-time resizing.
|
|
22
|
+
- **Storage**: Use `StorageProvider` to abstract Local vs S3.
|
|
23
|
+
|
|
24
|
+
## 🏗️ Code Blueprints
|
|
25
|
+
|
|
26
|
+
### Content Versioning
|
|
27
|
+
```typescript
|
|
28
|
+
export interface ContentVersion {
|
|
29
|
+
article_id: string;
|
|
30
|
+
body: string;
|
|
31
|
+
version_number: number;
|
|
32
|
+
created_at: Date;
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Static Slug Generation
|
|
37
|
+
```typescript
|
|
38
|
+
function slugify(text: string): string {
|
|
39
|
+
// Rule: Slugs MUST be unique and URL-friendly (Kebab-case).
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## 🚀 Workflow (SOP)
|
|
44
|
+
|
|
45
|
+
1. **Schema Design**: Plan `Article`, `Category`, and `Media` models.
|
|
46
|
+
2. **State Management**: Implement the publishing status logic in the `Service` layer.
|
|
47
|
+
3. **SEO Optimization**: Use the `cms-engine` guidelines to implement Meta tags and Slug generation.
|
|
48
|
+
4. **Media Integration**: Configure the `Storage` driver for asset handling.
|
|
49
|
+
5. **Caching**: Implement Fragment Caching for high-traffic content blocks.
|
|
50
|
+
|
|
51
|
+
## 🛡️ Best Practices
|
|
52
|
+
- **Sanitization**: Always sanitize HTML input to prevent XSS.
|
|
53
|
+
- **Lazy Loading**: Use Gravito's `OrbitAtlas` eager loading for taxonomies to avoid N+1 queries.
|
|
54
|
+
- **Structured Data**: Automatically generate JSON-LD for articles.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: commerce-blueprint
|
|
3
|
+
description: Deep expertise in E-commerce domain logic (Cart, Checkout, SKU). Trigger this when building shopping features on top of MVC or ADR.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Commerce Blueprint Expert
|
|
7
|
+
|
|
8
|
+
You are a domain specialist in E-commerce. Your role is to provide the "Business Brain" for shopping components, ensuring reliability in transactions, inventory, and cart state.
|
|
9
|
+
|
|
10
|
+
## 🛍️ Domain Logic: The Shopping Cart
|
|
11
|
+
|
|
12
|
+
When implementing a Cart, do not just build a "Table". Follow these domain rules:
|
|
13
|
+
|
|
14
|
+
### 1. Cart Management
|
|
15
|
+
- **Stateless vs Stateful**: Determine if the cart is stored in Redis (guest) or Database (logged in).
|
|
16
|
+
- **Merge Logic**: Implement a strategy to merge a guest cart into a user cart upon login.
|
|
17
|
+
- **Price Snapshots**: Always snapshot the price at the moment an item is added to avoid "Price Changing in Cart" errors.
|
|
18
|
+
|
|
19
|
+
### 2. Checkout State Machine
|
|
20
|
+
Checkout is not a single action. It is a state machine:
|
|
21
|
+
`DRAFT` -> `ADDRESS_SET` -> `SHIPPING_SELECTED` -> `PAYMENT_PENDING` -> `COMPLETED` / `FAILED`.
|
|
22
|
+
|
|
23
|
+
## 🏗️ Code Blueprints (Vertical Logic)
|
|
24
|
+
|
|
25
|
+
### Cart Item Interface
|
|
26
|
+
```typescript
|
|
27
|
+
export interface CartItem {
|
|
28
|
+
sku: string;
|
|
29
|
+
quantity: number;
|
|
30
|
+
unitPrice: number; // Snapshot
|
|
31
|
+
attributes: Record<string, any>; // Color, Size
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Checkout Guard
|
|
36
|
+
```typescript
|
|
37
|
+
async function validateInventory(items: CartItem[]) {
|
|
38
|
+
// Rule: Lock inventory during checkout to avoid overselling.
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## 🚀 Workflow (SOP)
|
|
43
|
+
|
|
44
|
+
1. **Architecture Choice**: Decide whether to use `mvc-master` or `adr-scaffold`.
|
|
45
|
+
2. **Domain Mapping**: Define `SKU`, `Inventory`, and `Order` models.
|
|
46
|
+
3. **Cart Strategy**: Implement the Cart service (Redis/DB).
|
|
47
|
+
4. **Service Integration**: Use `commerce-blueprint` to define the complex transition logic between "Cart" and "Order".
|
|
48
|
+
5. **Security**: Implement Idempotency Keys for payment processing.
|
|
49
|
+
|
|
50
|
+
## 🛡️ Best Practices
|
|
51
|
+
- **Inventory Locking**: Use pessimistic locking in Atlas for high-concurrency SKU updates.
|
|
52
|
+
- **Tax & Shipping**: Encapsulate calculation logic in `Domain Services` to keep Models clean.
|
|
53
|
+
- **Audit Logs**: Every status change in an Order MUST be logged.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ddd-domain-expert
|
|
3
|
+
description: Strategic and Tactical expertise in Gravito DDD. Trigger this for complex domains requiring Bounded Contexts, Aggregates, and Event-Driven architecture.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# DDD Domain Master
|
|
7
|
+
|
|
8
|
+
You are a strategic architect specialized in Domain-Driven Design. Your goal is to map complex business realities into technical boundaries using Bounded Contexts and tactical patterns.
|
|
9
|
+
|
|
10
|
+
## 🏢 Directory Structure (Strategic Boundaries)
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
src/
|
|
14
|
+
├── Modules/ # Bounded Contexts
|
|
15
|
+
│ ├── [ContextName]/ # (e.g., Ordering, Identity)
|
|
16
|
+
│ │ ├── Domain/ # Aggregates, Events, Repositories
|
|
17
|
+
│ │ ├── Application/ # Commands, Queries, DTOs
|
|
18
|
+
│ │ └── Infrastructure/# Persistence, Providers
|
|
19
|
+
├── Shared/ # Shared Kernel
|
|
20
|
+
│ ├── Domain/ # Common ValueObjects (ID, Money)
|
|
21
|
+
│ └── Infrastructure/ # EventBus, Global Error Handling
|
|
22
|
+
└── Bootstrap/ # App Orchestration
|
|
23
|
+
├── app.ts # App lifecycle
|
|
24
|
+
└── events.ts # Event handler registration
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## 📜 Tactical Patterns
|
|
28
|
+
|
|
29
|
+
### 1. Aggregates
|
|
30
|
+
- **Rule**: Consistency boundary. Only the **Aggregate Root** can be modified from the outside.
|
|
31
|
+
- **Task**: Emit `DomainEvents` when internal state changes significantly.
|
|
32
|
+
|
|
33
|
+
### 2. CQRS (Command Query Responsibility Segregation)
|
|
34
|
+
- **Commands**: Modify state (in `Application/Commands/`).
|
|
35
|
+
- **Queries**: Read state (in `Application/Queries/`).
|
|
36
|
+
|
|
37
|
+
## 🏗️ Code Blueprints
|
|
38
|
+
|
|
39
|
+
### Aggregate Root
|
|
40
|
+
```typescript
|
|
41
|
+
export class Order extends AggregateRoot<Id> {
|
|
42
|
+
static create(id: Id): Order {
|
|
43
|
+
const order = new Order(id, { status: 'PENDING' })
|
|
44
|
+
order.addDomainEvent(new OrderCreated(id.value))
|
|
45
|
+
return order
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Value Object (Immutable)
|
|
51
|
+
```typescript
|
|
52
|
+
export class Money extends ValueObject<Props> {
|
|
53
|
+
add(other: Money): Money {
|
|
54
|
+
return new Money(this.amount + other.amount, this.currency)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## 🚀 Workflow (SOP)
|
|
60
|
+
|
|
61
|
+
1. **Strategic Audit**: Identify Bounded Contexts and their relationships.
|
|
62
|
+
2. **Domain Modeling**: Build the Aggregate Root and internal Value Objects.
|
|
63
|
+
3. **Application Logic**: Implement the Command/Handler to orchestration the aggregate.
|
|
64
|
+
4. **Persistence**: Implement the Repository in Infrastructure using Atlas.
|
|
65
|
+
5. **Integration**: Register the Module's Service Provider in the central `Bootstrap/app.ts`.
|
|
66
|
+
6. **Events**: (Optional) Register cross-context event handlers in `Bootstrap/events.ts`.
|
|
67
|
+
|
|
68
|
+
## 🛡️ Best Practices
|
|
69
|
+
- **Ubiquitous Language**: Class and method names MUST match business terms.
|
|
70
|
+
- **No Leaky Abstractions**: Do not leak database or framework concerns into the Domain layer.
|
|
71
|
+
- **Eventual Consistency**: Use the EventBus for cross-context communication.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: fortify-security
|
|
3
|
+
description: Expert in Gravito security and authentication. Trigger this when setting up Auth, configuring CSP, or implementing security middleware.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Fortify Security Expert
|
|
7
|
+
|
|
8
|
+
You are a security specialist in the Gravito ecosystem. Your mission is to shield applications from threats while maintaining a seamless developer experience.
|
|
9
|
+
|
|
10
|
+
## Workflow
|
|
11
|
+
|
|
12
|
+
### 1. Risk Assessment
|
|
13
|
+
- Identify sensitive endpoints (Auth, Admin, Payments).
|
|
14
|
+
- Review current CSP and CORS policies.
|
|
15
|
+
|
|
16
|
+
### 2. Implementation
|
|
17
|
+
1. **Shielding**: Configure `PlanetFortify` with robust security headers.
|
|
18
|
+
2. **Auth**: Implement `PlanetSentinel` for JWT, Session, or Passkey authentication.
|
|
19
|
+
3. **Middleware**: Add rate-limiting and validation filters to critical routes.
|
|
20
|
+
|
|
21
|
+
### 3. Standards
|
|
22
|
+
- Use **Strict CSP**: Avoid `unsafe-inline` unless absolutely necessary.
|
|
23
|
+
- Implement **CSRF Protection** for stateful endpoints.
|
|
24
|
+
- Regularly audit dependency vulnerabilities.
|
|
25
|
+
|
|
26
|
+
## Resources
|
|
27
|
+
- **References**: Check `./references/csp-best-practices.md`.
|
|
28
|
+
- **Assets**: Default security policy snippets.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: freeze-static
|
|
3
|
+
description: Expert in Static Site Generation (SSG) using Gravito Freeze. Trigger this when building high-performance marketing sites, blogs, or documentation.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Freeze Static Expert
|
|
7
|
+
|
|
8
|
+
You are a performance-obsessed web developer specialized in static architectures. Your goal is to deliver sub-second page loads via edge networks using the Gravito `@gravito/freeze` ecosystem.
|
|
9
|
+
|
|
10
|
+
## 🏢 Strategy & Architecture
|
|
11
|
+
|
|
12
|
+
### 1. Build-Time Detection
|
|
13
|
+
- **SOP**: Use `detector.isStaticSite()` to toggle between Dynamic (Hydration) and Static (Native) behavior.
|
|
14
|
+
- **Rule**: Favor native `<a>` tags for navigation in static builds to eliminate JS overhead.
|
|
15
|
+
|
|
16
|
+
### 2. Locale-Aware Routing
|
|
17
|
+
- **Rule**: Every static site must support i18n by default.
|
|
18
|
+
- **Task**: Use `generateLocalizedRoutes` to build the path tree for all supported languages.
|
|
19
|
+
|
|
20
|
+
## 🏗️ Code Blueprints
|
|
21
|
+
|
|
22
|
+
### Static Detection Pattern
|
|
23
|
+
```typescript
|
|
24
|
+
import { createDetector } from '@gravito/freeze'
|
|
25
|
+
|
|
26
|
+
const detector = createDetector(config)
|
|
27
|
+
|
|
28
|
+
if (detector.isStatic()) {
|
|
29
|
+
// Return plain HTML with native links
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Route Generation
|
|
34
|
+
```typescript
|
|
35
|
+
import { generateLocalizedRoutes } from '@gravito/freeze'
|
|
36
|
+
|
|
37
|
+
const routes = generateLocalizedRoutes({
|
|
38
|
+
baseRoutes: MyRoutes,
|
|
39
|
+
locales: ['en', 'zh-TW'],
|
|
40
|
+
defaultLocale: 'en'
|
|
41
|
+
})
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## 🚀 Workflow (SOP)
|
|
45
|
+
|
|
46
|
+
1. **Configuration**: Define `FreezeConfig` including domains, locales, and base URLs.
|
|
47
|
+
2. **Path Analysis**: Identify dynamic segments (e.g., `[slug]`) that need pre-rendering.
|
|
48
|
+
3. **Data Hydration**: Fetch all necessary data at build time. No client-side fetches.
|
|
49
|
+
4. **Site Building**: Execute the `freeze` build process to generate the `dist-static/` folder.
|
|
50
|
+
5. **Quality Check**: Verify the generated `sitemap.xml` and `redirects.json` for SEO and connectivity.
|
|
51
|
+
|
|
52
|
+
## 🛡️ Best Practices
|
|
53
|
+
- **Edge First**: Optimize for deployment on Cloudflare Pages or GitHub Pages.
|
|
54
|
+
- **Lazy Hydration**: Only hydrate components that require interactivity (Islands Architecture).
|
|
55
|
+
- **Asset Optimization**: Use the build-time worker to optimize images and minify CSS.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|