@crossdelta/platform-sdk 0.2.31 → 0.3.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.
Files changed (24) hide show
  1. package/README.md +205 -88
  2. package/bin/cli.js +249 -154
  3. package/bin/integration.collection.json +1 -1
  4. package/bin/templates/workspace/.github/README.md +70 -0
  5. package/bin/templates/workspace/.github/actions/check-image-tag-exists/action.yml +27 -0
  6. package/bin/templates/workspace/.github/actions/check-image-tag-exists/index.js +179 -0
  7. package/bin/templates/workspace/.github/actions/check-path-changes/action.yml +21 -0
  8. package/bin/templates/workspace/.github/actions/check-path-changes/index.js +192 -0
  9. package/bin/templates/workspace/.github/actions/detect-skipped-services/action.yml +38 -0
  10. package/bin/templates/workspace/.github/actions/generate-scope-matrix/action.yml +17 -0
  11. package/bin/templates/workspace/.github/actions/generate-scope-matrix/index.js +355 -0
  12. package/bin/templates/workspace/.github/actions/prepare-build-context/action.yml +49 -0
  13. package/bin/templates/workspace/.github/actions/resolve-scope-tags/action.yml +31 -0
  14. package/bin/templates/workspace/.github/actions/resolve-scope-tags/index.js +400 -0
  15. package/bin/templates/workspace/.github/actions/setup-bun-install/action.yml.hbs +57 -0
  16. package/bin/templates/workspace/.github/copilot-chat-configuration.json +49 -0
  17. package/bin/templates/workspace/.github/copilot-instructions.md.hbs +202 -0
  18. package/bin/templates/workspace/.github/dependabot.yml +18 -0
  19. package/bin/templates/workspace/.github/workflows/build-and-deploy.yml.hbs +236 -0
  20. package/bin/templates/workspace/.github/workflows/lint-and-tests.yml.hbs +33 -0
  21. package/bin/templates/workspace/.github/workflows/publish-packages.yml +161 -0
  22. package/bin/templates/workspace/biome.json.hbs +2 -1
  23. package/bin/templates/workspace/turbo.json +40 -0
  24. package/package.json +15 -3
package/README.md CHANGED
@@ -1,24 +1,54 @@
1
+ <p align="center">
2
+ <img src="logo.svg" alt="pf" width="120" />
3
+ </p>
1
4
 
2
- # @crossdelta/platform-sdk
3
- **Bun-first CLI toolkit for building event-driven microservice platforms.**
5
+ <h1 align="center">Platform SDK</h1>
4
6
 
5
- Spin up a complete Turborepo workspace with [Pulumi](https://www.pulumi.com/) infrastructure, ready-to-run [Hono](https://hono.dev/) / [NestJS](https://nestjs.com/) microservices, automatic env generation, and a unified development workflow — all from a single CLI.
7
+ <p align="center">
8
+ <code>@crossdelta/platform-sdk</code>
9
+ </p>
6
10
 
7
- > Stop wiring Turborepo, Pulumi, ports, env files & service scripts by hand.
8
- > Build a production-ready microservice platform in under a minute.
11
+ <p align="center">
12
+ <strong>Agentic CLI for event-driven microservice platforms</strong>
13
+ </p>
14
+
15
+ <p align="center">
16
+ <a href="https://www.npmjs.com/package/@crossdelta/platform-sdk"><img src="https://img.shields.io/npm/v/@crossdelta/platform-sdk.svg?style=flat-square" alt="npm version" /></a>
17
+ <img src="https://img.shields.io/badge/bun-%E2%9A%A1-f9f1e1?style=flat-square" alt="Bun" />
18
+ <img src="https://img.shields.io/badge/pulumi-ready-blueviolet?style=flat-square" alt="Pulumi" />
19
+ <img src="https://img.shields.io/badge/DigitalOcean-App_Platform_|_DOKS-0080FF?style=flat-square" alt="DigitalOcean" />
20
+ </p>
21
+
22
+ <p align="center">
23
+ Your AI-powered platform engineer. Scaffold complete Turborepo workspaces,<br />
24
+ generate production-ready microservices with natural language,<br />
25
+ and deploy to DigitalOcean — all from one CLI.
26
+ </p>
27
+
28
+ ---
29
+
30
+ > ⚠️ **Cloud Provider Support:** Currently only **DigitalOcean** is supported:
31
+ > - **App Platform** — Managed PaaS for simple deployments
32
+ > - **DOKS (Kubernetes)** — Full Kubernetes control for production workloads
33
+ >
34
+ > AWS and GCP support is planned for future releases.
9
35
 
10
36
  ---
11
37
 
12
38
  ## ✨ Features
13
39
 
14
- - **Instant Scaffolding** – Create fully wired platform workspaces with best practices baked in
15
- - 🥟 **Bun-first DX** – Ultra-fast dev workflow with fallback to npm/yarn/pnpm
16
- - 🏗️ **Turborepo Monorepo** Parallel builds, caching, and unified dev scripts
17
- - 🔧 **Service Generators** [Hono](https://hono.dev/) (lightweight) and [NestJS](https://nestjs.com/) (enterprise-grade) templates
18
- - 📦 **Pulumi-Ready Infra** Infrastructure-as-Code via [Pulumi](https://www.pulumi.com/)
19
- - 🌍 **Automatic `.env.local` Generation** Derived from `infra/services/*.ts`
20
- - 🔌 **Auto Port Assignment** Unique ports per service, zero manual config
21
- - 🔁 **Smart Watch Mode** Watches infra & services, regenerates env, reinstalls deps when needed
40
+ | Feature | Description |
41
+ |---------|-------------|
42
+ | **Instant Scaffolding** | Create fully wired platform workspaces with best practices baked in |
43
+ | **AI-Powered Generation** | Generate services with AI using `--ai` flag (OpenAI/Anthropic) |
44
+ | �🥟 **Bun-first DX** | Ultra-fast dev workflow with fallback to npm/yarn/pnpm |
45
+ | 🏗️ **Turborepo Monorepo** | Parallel builds, caching, and unified dev scripts |
46
+ | 🔧 **Service Generators** | [Hono](https://hono.dev/) (lightweight) and [NestJS](https://nestjs.com/) (enterprise-grade) templates |
47
+ | 📦 **Pulumi-Ready Infra** | Infrastructure-as-Code for DigitalOcean (App Platform or DOKS) |
48
+ | 🚀 **GitHub Actions CI/CD** | Pre-configured workflows for build, test, deploy, and npm publish |
49
+ | 🌍 **Auto `.env.local`** | Environment variables derived from `infra/services/*.ts` |
50
+ | 🔌 **Auto Port Assignment** | Unique ports per service, zero manual config |
51
+ | 🔁 **Smart Watch Mode** | Watches infra & services, regenerates env, reinstalls deps |
22
52
 
23
53
  ---
24
54
 
@@ -28,9 +58,25 @@ Spin up a complete Turborepo workspace with [Pulumi](https://www.pulumi.com/) in
28
58
 
29
59
  ```bash
30
60
  npx @crossdelta/platform-sdk new workspace my-platform
31
- cd my-platform
32
61
  ```
33
62
 
63
+ Or with options:
64
+
65
+ ```bash
66
+ pf new workspace my-platform -y # Skip prompts
67
+ pf new workspace my-platform -o my-github-org # Set GitHub owner
68
+ pf new workspace my-platform --no-github # Without CI/CD
69
+ ```
70
+
71
+ **Options:**
72
+
73
+ | Flag | Description |
74
+ |------|-------------|
75
+ | `-y, --yes` | Skip prompts, use defaults |
76
+ | `-o, --github-owner <owner>` | GitHub org/user for GHCR registry |
77
+ | `-s, --pulumi-stack <name>` | Pulumi stack base name (org/project) |
78
+ | `--no-github` | Skip GitHub Actions workflows |
79
+
34
80
  > 💡 `pf` is the CLI binary shipped with this package.
35
81
  > It automatically works through `npx` — no global install required.
36
82
 
@@ -39,13 +85,36 @@ cd my-platform
39
85
  ### 2. Generate microservices
40
86
 
41
87
  ```bash
42
- # Hono microservice
43
- pf new hono-micro services/orders
88
+ pf new hono-micro services/orders # Lightweight Hono service
89
+ pf new nest-micro services/api-gateway # Enterprise NestJS service
90
+ ```
91
+
92
+ Both generators:
93
+ - Auto-assign unique ports
94
+ - Create Pulumi service config in `infra/services/`
95
+ - Add Dockerfile for containerized deployment
96
+ - Wire up health checks
97
+
98
+ #### 🤖 AI-Powered Generation
99
+
100
+ Generate services with AI assistance:
101
+
102
+ ```bash
103
+ # One-liner with description
104
+ pf new hono-micro services/payments --ai -d "Handle payment webhooks and process transactions"
105
+
106
+ # Interactive mode (prompts for description)
107
+ pf new hono-micro services/notifications --ai
108
+ ```
44
109
 
45
- # NestJS microservice
46
- pf new nest-micro services/api-gateway
110
+ First-time setup:
111
+
112
+ ```bash
113
+ pf setup --ai # Configure OpenAI or Anthropic API key
47
114
  ```
48
115
 
116
+ The AI reads your project's `copilot-instructions.md` and generates code following your conventions.
117
+
49
118
  ---
50
119
 
51
120
  ### 3. Start local development
@@ -56,94 +125,125 @@ pf dev
56
125
 
57
126
  What happens:
58
127
 
59
- - `.env.local` is generated from all `infra/services/*.ts` configs
60
- - Services are started in parallel via Turborepo
61
- - Watching:
62
- - `infra/services/` → regenerate env + restart
63
- - `services/` and `apps/` → detect new/deleted packages and reinstall deps
128
+ 1. `.env.local` is generated from all `infra/services/*.ts` configs
129
+ 2. Services are started in parallel via Turborepo
130
+ 3. **Watching:**
131
+ - `infra/services/` → regenerate env + restart
132
+ - `services/` and `apps/` → detect new/deleted packages and reinstall deps
64
133
 
65
134
  ---
66
135
 
67
- ## 🧠 Example: Automatic env generation
136
+ ## 📁 Generated Workspace Structure
137
+
138
+ ```
139
+ my-platform/
140
+ ├── .github/
141
+ │ ├── workflows/
142
+ │ │ ├── lint-and-tests.yml # PR checks
143
+ │ │ ├── build-and-deploy.yml # Build & deploy on push to main
144
+ │ │ └── publish-packages.yml # Publish npm packages
145
+ │ └── actions/
146
+ │ ├── setup-bun-install/ # Cached Bun setup
147
+ │ ├── generate-scope-matrix/ # Dynamic service detection
148
+ │ ├── check-image-tag-exists/ # Skip unchanged builds
149
+ │ └── ... # More reusable actions
150
+ ├── infra/
151
+ │ ├── index.ts # Pulumi entry point
152
+ │ ├── services/ # Service configs (auto-discovered)
153
+ │ ├── Pulumi.yaml # Project config
154
+ │ └── Pulumi.dev.yaml # Dev stack config
155
+ ├── services/ # Microservices
156
+ ├── apps/ # Frontend apps
157
+ ├── packages/ # Shared packages
158
+ ├── package.json # Root workspace config
159
+ ├── turbo.json # Turborepo config
160
+ └── biome.json # Linting config
161
+ ```
162
+
163
+ ---
164
+
165
+ ## 🛠 CLI Commands
166
+
167
+ | Command | Description |
168
+ |---------|-------------|
169
+ | `pf new workspace <name>` | Scaffold a complete platform workspace |
170
+ | `pf new hono-micro <path>` | Generate a lightweight Hono microservice |
171
+ | `pf new nest-micro <path>` | Generate a NestJS microservice |
172
+ | `pf new hono-micro <path> --ai` | Generate with AI assistance |
173
+ | `pf setup --ai` | Configure AI provider (OpenAI/Anthropic) |
174
+ | `pf dev` | Start dev environment with watch mode |
175
+ | `pf dev --no-watch` | Start without file watching |
176
+ | `pf generate <schematic> <name>` | Generate code using schematics |
177
+
178
+ ---
179
+
180
+ ## 🔧 Configuration
181
+
182
+ ### Service Config Example
68
183
 
69
184
  ```ts
70
185
  // infra/services/orders.ts
71
- import type { ServiceConfig } from '@crossdelta/infrastructure'
186
+ import type { K8sServiceConfig } from '@crossdelta/infrastructure'
72
187
 
73
- export const orders: ServiceConfig = {
188
+ export const config: K8sServiceConfig = {
74
189
  name: 'orders',
75
- httpPort: 4001,
190
+ containerPort: 4001,
191
+ replicas: 1,
192
+ healthCheck: { port: 4001 },
193
+ resources: {
194
+ requests: { cpu: '50m', memory: '64Mi' },
195
+ limits: { cpu: '150m', memory: '128Mi' },
196
+ },
76
197
  env: {
77
- ORDERS_DB_URL: 'postgres://...',
78
- NATS_URL: 'nats://localhost:4222',
198
+ DATABASE_URL: databaseUrl,
199
+ NATS_URL: natsUrl,
79
200
  },
80
201
  }
81
202
  ```
82
203
 
83
- Running:
84
-
85
- ```bash
86
- pf dev
87
- ```
204
+ Running `pf dev` generates:
88
205
 
89
- Creates:
90
-
91
- ```
92
- .env.local
93
- ORDERS_DB_URL=postgres://...
206
+ ```env
207
+ # .env.local
208
+ DATABASE_URL=postgres://...
94
209
  NATS_URL=nats://localhost:4222
95
210
  ORDERS_PORT=4001
96
211
  ```
97
212
 
98
- And automatically reloads services on change.
99
-
100
213
  ---
101
214
 
102
- ## 🛠 Commands
215
+ ## 🚢 Deployment (DigitalOcean)
103
216
 
104
- ### `pf dev`
105
- Start the development environment with optional watch mode.
217
+ ### Prerequisites
106
218
 
107
- ```bash
108
- pf dev # Start with watch mode
109
- pf dev --no-watch # Disable watching
110
- ```
219
+ 1. **Pulumi Account** – [Sign up free](https://app.pulumi.com/signup)
220
+ 2. **DigitalOcean Account** [Create account](https://cloud.digitalocean.com/registrations/new)
221
+ 3. **GitHub Repository** For CI/CD workflows
111
222
 
112
- ---
223
+ ### GitHub Secrets
113
224
 
114
- ### `pf new workspace <name>`
115
- Scaffold a complete platform workspace with Pulumi infrastructure.
225
+ | Secret | Description |
226
+ |--------|-------------|
227
+ | `PULUMI_ACCESS_TOKEN` | Pulumi Cloud access token |
228
+ | `DIGITALOCEAN_TOKEN` | DigitalOcean API token |
229
+ | `NPM_TOKEN` | (optional) For private npm packages |
116
230
 
117
- ```bash
118
- pf new workspace my-platform
119
- pf new workspace my-platform -y # Skip prompts
120
- ```
121
-
122
- ---
123
-
124
- ### `pf new hono-micro <path>`
125
- Generate a lightweight Hono microservice.
231
+ ### Deploy
126
232
 
127
233
  ```bash
128
- pf new hono-micro services/orders
234
+ pulumi login
235
+ pulumi up --stack dev
129
236
  ```
130
237
 
131
238
  ---
132
239
 
133
- ### `pf new nest-micro <path>`
134
- Generate a NestJS microservice with enterprise-ready setup.
240
+ ## 📦 Installation
135
241
 
136
242
  ```bash
137
- pf new nest-micro services/api-gateway
138
- ```
139
-
140
- ---
141
-
142
- ## 📦 Installation (optional)
243
+ # Via npx (recommended)
244
+ npx @crossdelta/platform-sdk new workspace my-platform
143
245
 
144
- ```bash
145
- npm install -g @crossdelta/platform-sdk
146
- # or
246
+ # Global install
147
247
  bun add -g @crossdelta/platform-sdk
148
248
  ```
149
249
 
@@ -151,38 +251,55 @@ bun add -g @crossdelta/platform-sdk
151
251
 
152
252
  ## 👍 When to use this
153
253
 
154
- - You want a **Bun-first microservice platform** with minimal boilerplate
155
- - You prefer **Turborepo + Pulumi** as your architectural baseline
156
- - You want fast **Hono/NestJS service scaffolding**
157
- - You need a **unified dev workflow** for multiple services
158
- - You plan to deploy to **DigitalOcean, GCP, AWS**
254
+ - **Bun-first microservice platform** with minimal boilerplate
255
+ - **Turborepo + Pulumi** as architectural baseline
256
+ - Fast **Hono/NestJS service scaffolding**
257
+ - **Unified dev workflow** for multiple services
258
+ - Deploy to **DigitalOcean App Platform**
259
+ - ✅ **GitHub Actions** for CI/CD
159
260
 
160
261
  ---
161
262
 
162
263
  ## ❌ When NOT to use this
163
264
 
164
- - You need a hosted PaaS (Render, Fly.io, Netlify, etc.)
165
- - You are not using a monorepo
166
- - You don’t use Infrastructure-as-Code
167
- - You prefer fully unopinionated setups
265
+ - You need AWS, GCP, or other cloud providers (coming soon)
266
+ - You need a hosted PaaS (Render, Fly.io, Netlify)
267
+ - You are not using a monorepo
268
+ - You don't use Infrastructure-as-Code
168
269
 
169
270
  ---
170
271
 
171
272
  ## 📚 Requirements
172
273
 
173
- - Node.js 21
174
- - Bun (recommended) or npm/yarn/pnpm
175
- - Pulumi CLI (optional, required for infra)
274
+ | Requirement | Version |
275
+ |-------------|---------|
276
+ | Node.js | 21 |
277
+ | Bun | Latest (recommended) |
278
+ | Pulumi CLI | Latest |
279
+ | Docker | For local Supabase/NATS |
280
+
281
+ ---
282
+
283
+ ## 🔗 Related Packages
284
+
285
+ | Package | Description |
286
+ |---------|-------------|
287
+ | [@crossdelta/infrastructure](https://www.npmjs.com/package/@crossdelta/infrastructure) | Pulumi helpers for DigitalOcean |
288
+ | [@crossdelta/cloudevents](https://www.npmjs.com/package/@crossdelta/cloudevents) | CloudEvents + NATS toolkit |
289
+ | [@crossdelta/telemetry](https://www.npmjs.com/package/@crossdelta/telemetry) | Zero-config OpenTelemetry |
176
290
 
177
291
  ---
178
292
 
179
- ## 🔗 Related
293
+ ## 🗺️ Roadmap
180
294
 
181
- - **[@crossdelta/infrastructure](https://www.npmjs.com/package/@crossdelta/infrastructure)** Shared helpers & types for Pulumi + DigitalOcean
182
- - **[@crossdelta/cloudevents](https://www.npmjs.com/package/@crossdelta/cloudevents)** CloudEvents + NATS toolkit for event-driven microservices
295
+ - [x] AI-powered service generation (OpenAI/Anthropic)
296
+ - [ ] AWS ECS/Fargate provider
297
+ - [ ] GCP Cloud Run provider
298
+ - [ ] Kubernetes (generic) provider
299
+ - [ ] `pf migrate` command for database migrations
183
300
 
184
301
  ---
185
302
 
186
303
  ## 📄 License
187
304
 
188
- MIT © Crossdelta
305
+ MIT © [Crossdelta](https://github.com/crossdelta)