@crossdelta/platform-sdk 0.8.21 → 0.8.32
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.
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Generator Documentation
|
|
2
|
+
|
|
3
|
+
This directory contains AI instructions for code generators.
|
|
4
|
+
|
|
5
|
+
## Structure
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
generators/
|
|
9
|
+
├── README.md # This file
|
|
10
|
+
└── service.md # Service generator instructions
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## How Instructions Are Loaded
|
|
14
|
+
|
|
15
|
+
The AI service generator loads instructions in priority order (most specific first):
|
|
16
|
+
|
|
17
|
+
1. **Generator-specific** (`packages/platform-sdk/docs/generators/service.md`)
|
|
18
|
+
- Detailed rules for the service generator output format
|
|
19
|
+
- Event consumer/publisher workflows
|
|
20
|
+
- File structure requirements
|
|
21
|
+
|
|
22
|
+
2. **Copilot instructions** (`.github/copilot-instructions.md`)
|
|
23
|
+
- Project-wide coding standards
|
|
24
|
+
- Code style rules
|
|
25
|
+
- Package-specific guidelines
|
|
26
|
+
|
|
27
|
+
3. **Project AI guidelines** (`docs/ai-guidelines.md`)
|
|
28
|
+
- General architectural principles
|
|
29
|
+
- Validation patterns
|
|
30
|
+
- Testing guidelines
|
|
31
|
+
|
|
32
|
+
## Adding New Generators
|
|
33
|
+
|
|
34
|
+
To add instructions for a new generator:
|
|
35
|
+
|
|
36
|
+
1. Create `<generator-name>.md` in this directory
|
|
37
|
+
2. Update `INSTRUCTION_FILES` in `ai-service-generator.ts` if needed
|
|
38
|
+
3. Follow the existing format from `service.md`
|
|
39
|
+
|
|
40
|
+
## Template Variables
|
|
41
|
+
|
|
42
|
+
The following variables are replaced at runtime:
|
|
43
|
+
|
|
44
|
+
| Variable | Description |
|
|
45
|
+
|----------|-------------|
|
|
46
|
+
| `{{scope}}` | Package scope (e.g., `@orderboss`) |
|
|
47
|
+
| `{{AVAILABLE_CONTRACTS}}` | Auto-generated list of existing contracts |
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Service Generator Instructions
|
|
2
2
|
|
|
3
3
|
These rules define how AI-generated scaffolded services must be structured.
|
|
4
4
|
|
|
@@ -88,7 +88,7 @@ consumeJetStreamEvents({
|
|
|
88
88
|
|
|
89
89
|
---
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
## Commands Block (REQUIRED - MUST BE FIRST)
|
|
92
92
|
|
|
93
93
|
```commands
|
|
94
94
|
pf new hono-micro services/my-service -y
|
|
@@ -99,7 +99,7 @@ pf new hono-micro services/my-service -y
|
|
|
99
99
|
|
|
100
100
|
---
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
## Post-Generation Commands
|
|
103
103
|
|
|
104
104
|
For Event Consumer services:
|
|
105
105
|
|
|
@@ -111,7 +111,7 @@ pf event add <event.type> --service services/my-service
|
|
|
111
111
|
|
|
112
112
|
---
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
## Dependencies Block
|
|
115
115
|
|
|
116
116
|
Only include packages not in the scaffold:
|
|
117
117
|
|
|
@@ -124,7 +124,7 @@ zod
|
|
|
124
124
|
|
|
125
125
|
---
|
|
126
126
|
|
|
127
|
-
|
|
127
|
+
## Required Files
|
|
128
128
|
|
|
129
129
|
**Event Consumer:**
|
|
130
130
|
```
|
|
@@ -159,16 +159,9 @@ services/my-service/
|
|
|
159
159
|
|
|
160
160
|
---
|
|
161
161
|
|
|
162
|
-
|
|
162
|
+
## Service Types
|
|
163
163
|
|
|
164
|
-
|
|
165
|
-
- No semicolons, minimal comments, alphabetized imports
|
|
166
|
-
|
|
167
|
-
---
|
|
168
|
-
|
|
169
|
-
# 6. Service Types
|
|
170
|
-
|
|
171
|
-
## 📤 Event Publisher (REST API)
|
|
164
|
+
### 📤 Event Publisher (REST API)
|
|
172
165
|
|
|
173
166
|
**Keywords:** "publishes", "creates", "manages", "REST API"
|
|
174
167
|
|
|
@@ -189,19 +182,19 @@ app.post('/orders', async (c) => {
|
|
|
189
182
|
Bun.serve({ port: 4001, fetch: app.fetch })
|
|
190
183
|
```
|
|
191
184
|
|
|
192
|
-
|
|
185
|
+
### 📥 Event Consumer (NATS)
|
|
193
186
|
|
|
194
187
|
**Keywords:** "consumes", "listens to", "reacts to", "handles events"
|
|
195
188
|
|
|
196
|
-
See
|
|
189
|
+
See 3-Step Workflow above.
|
|
197
190
|
|
|
198
|
-
|
|
191
|
+
### 🔄 Hybrid (Both)
|
|
199
192
|
|
|
200
193
|
Combines REST endpoints + NATS consumer.
|
|
201
194
|
|
|
202
195
|
---
|
|
203
196
|
|
|
204
|
-
|
|
197
|
+
## Use-Case Rules
|
|
205
198
|
|
|
206
199
|
- Live in `src/use-cases/*.use-case.ts`
|
|
207
200
|
- Pure functions, no framework imports
|
|
@@ -226,7 +219,7 @@ export const processOrder = async (
|
|
|
226
219
|
|
|
227
220
|
---
|
|
228
221
|
|
|
229
|
-
|
|
222
|
+
## Testing Rules
|
|
230
223
|
|
|
231
224
|
- Test ONLY use-cases
|
|
232
225
|
- Use `import { describe, expect, it } from 'bun:test'`
|
|
@@ -248,7 +241,7 @@ describe('Process Order', () => {
|
|
|
248
241
|
|
|
249
242
|
---
|
|
250
243
|
|
|
251
|
-
|
|
244
|
+
## Absolute Rules
|
|
252
245
|
|
|
253
246
|
**DO NOT:**
|
|
254
247
|
- Generate full rewrites
|
|
@@ -10,6 +10,7 @@ Always generate **minimal diffs**, never full rewrites.
|
|
|
10
10
|
- Analyze only the opened file unless explicitly asked.
|
|
11
11
|
- Follow existing architecture and naming conventions.
|
|
12
12
|
- Prefer strict typing; avoid `any`.
|
|
13
|
+
- **Reuse existing code**: Before implementing new functionality, search the codebase for existing functions, utilities, or services that can be reused. Avoid duplicating logic.
|
|
13
14
|
|
|
14
15
|
## Code Style
|
|
15
16
|
- Single quotes, no semicolons, 2-space indent, trailing commas.
|
|
@@ -60,8 +61,7 @@ Always generate **minimal diffs**, never full rewrites.
|
|
|
60
61
|
When working with specific service types or packages, refer to these detailed guidelines:
|
|
61
62
|
|
|
62
63
|
### Service Generation & Architecture
|
|
63
|
-
- [Service
|
|
64
|
-
- [Hono Microservice Guidelines](../docs/generators/services/hono-micro-guidelines.md) - Event-driven Hono patterns
|
|
64
|
+
- [CLI Service Generator](../packages/platform-sdk/docs/generators/service.md) - AI code generation rules
|
|
65
65
|
|
|
66
66
|
### Key Packages
|
|
67
67
|
- [@crossdelta/cloudevents](../packages/cloudevents/README.md) - Event handling with NATS and CloudEvents
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crossdelta/platform-sdk",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.32",
|
|
4
4
|
"description": "Platform toolkit for event-driven microservices — keeping code and infrastructure in lockstep.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"files": [
|
|
30
30
|
"bin/**/*.js",
|
|
31
31
|
"bin/**/templates/**",
|
|
32
|
-
"bin
|
|
32
|
+
"bin/docs/generators/**",
|
|
33
33
|
"bin/**/*.json",
|
|
34
34
|
"!bin/**/*.map",
|
|
35
35
|
"dist/",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"scripts": {
|
|
52
52
|
"start:dev": "node esbuild.config.mjs --watch",
|
|
53
53
|
"build:cli": "node esbuild.config.mjs",
|
|
54
|
-
"build:cli:copy": "cp cli/integration.collection.json bin/integration.collection.json && rm -rf bin/templates && mkdir -p bin/templates && cp -r cli/src/commands/create/workspace/templates bin/templates/workspace && cp -r cli/src/commands/create/hono-microservice/templates bin/templates/hono-microservice && cp -r cli/src/commands/create/nest-microservice/templates bin/templates/nest-microservice && mkdir -p bin/
|
|
54
|
+
"build:cli:copy": "cp cli/integration.collection.json bin/integration.collection.json && rm -rf bin/templates && mkdir -p bin/templates && cp -r cli/src/commands/create/workspace/templates bin/templates/workspace && cp -r cli/src/commands/create/hono-microservice/templates bin/templates/hono-microservice && cp -r cli/src/commands/create/nest-microservice/templates bin/templates/nest-microservice && mkdir -p bin/docs/generators && cp -r docs/generators/* bin/docs/generators/",
|
|
55
55
|
"build:schematics:transpile": "tsc --project tsconfig.schematics.json",
|
|
56
56
|
"build:schematics:copy": "cp -R schematics/* dist/schematics && find dist/schematics -name '*.ts' -delete",
|
|
57
57
|
"build:schematics": "npm run build:schematics:transpile && npm run build:schematics:copy",
|