@opensaas/stack-cli 0.5.0 → 0.6.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 (61) hide show
  1. package/README.md +76 -0
  2. package/dist/commands/migrate.d.ts.map +1 -1
  3. package/dist/commands/migrate.js +91 -265
  4. package/dist/commands/migrate.js.map +1 -1
  5. package/package.json +7 -2
  6. package/plugin/.claude-plugin/plugin.json +15 -0
  7. package/plugin/README.md +112 -0
  8. package/plugin/agents/migration-assistant.md +150 -0
  9. package/plugin/commands/analyze-schema.md +34 -0
  10. package/plugin/commands/generate-config.md +33 -0
  11. package/plugin/commands/validate-migration.md +34 -0
  12. package/plugin/skills/opensaas-migration/SKILL.md +192 -0
  13. package/.turbo/turbo-build.log +0 -4
  14. package/CHANGELOG.md +0 -462
  15. package/CLAUDE.md +0 -298
  16. package/src/commands/__snapshots__/generate.test.ts.snap +0 -413
  17. package/src/commands/dev.test.ts +0 -215
  18. package/src/commands/dev.ts +0 -48
  19. package/src/commands/generate.test.ts +0 -282
  20. package/src/commands/generate.ts +0 -182
  21. package/src/commands/init.ts +0 -34
  22. package/src/commands/mcp.ts +0 -135
  23. package/src/commands/migrate.ts +0 -534
  24. package/src/generator/__snapshots__/context.test.ts.snap +0 -361
  25. package/src/generator/__snapshots__/prisma.test.ts.snap +0 -174
  26. package/src/generator/__snapshots__/types.test.ts.snap +0 -1702
  27. package/src/generator/context.test.ts +0 -139
  28. package/src/generator/context.ts +0 -227
  29. package/src/generator/index.ts +0 -7
  30. package/src/generator/lists.test.ts +0 -335
  31. package/src/generator/lists.ts +0 -140
  32. package/src/generator/plugin-types.ts +0 -147
  33. package/src/generator/prisma-config.ts +0 -46
  34. package/src/generator/prisma-extensions.ts +0 -159
  35. package/src/generator/prisma.test.ts +0 -211
  36. package/src/generator/prisma.ts +0 -161
  37. package/src/generator/types.test.ts +0 -268
  38. package/src/generator/types.ts +0 -537
  39. package/src/index.ts +0 -46
  40. package/src/mcp/lib/documentation-provider.ts +0 -710
  41. package/src/mcp/lib/features/catalog.ts +0 -301
  42. package/src/mcp/lib/generators/feature-generator.ts +0 -598
  43. package/src/mcp/lib/types.ts +0 -89
  44. package/src/mcp/lib/wizards/migration-wizard.ts +0 -584
  45. package/src/mcp/lib/wizards/wizard-engine.ts +0 -427
  46. package/src/mcp/server/index.ts +0 -361
  47. package/src/mcp/server/stack-mcp-server.ts +0 -544
  48. package/src/migration/generators/migration-generator.ts +0 -675
  49. package/src/migration/introspectors/index.ts +0 -12
  50. package/src/migration/introspectors/keystone-introspector.ts +0 -296
  51. package/src/migration/introspectors/nextjs-introspector.ts +0 -209
  52. package/src/migration/introspectors/prisma-introspector.ts +0 -233
  53. package/src/migration/types.ts +0 -92
  54. package/tests/introspectors/keystone-introspector.test.ts +0 -255
  55. package/tests/introspectors/nextjs-introspector.test.ts +0 -302
  56. package/tests/introspectors/prisma-introspector.test.ts +0 -268
  57. package/tests/migration-generator.test.ts +0 -592
  58. package/tests/migration-wizard.test.ts +0 -442
  59. package/tsconfig.json +0 -13
  60. package/tsconfig.tsbuildinfo +0 -1
  61. package/vitest.config.ts +0 -26
package/CHANGELOG.md DELETED
@@ -1,462 +0,0 @@
1
- # @opensaas/stack-cli
2
-
3
- ## 0.5.0
4
-
5
- ### Minor Changes
6
-
7
- - [#198](https://github.com/OpenSaasAU/stack/pull/198) [`c84405e`](https://github.com/OpenSaasAU/stack/commit/c84405e669e03dbc38fb094e813a105abbb448b8) Thanks [@borisno2](https://github.com/borisno2)! - Add Phase 2 MCP migration tools and enhanced documentation provider
8
-
9
- This update adds 6 new MCP server tools to assist with project migration:
10
-
11
- **New MCP Tools:**
12
- - `opensaas_start_migration`: Start migration wizard for Prisma/Keystone/Next.js projects
13
- - `opensaas_answer_migration`: Answer migration wizard questions
14
- - `opensaas_introspect_prisma`: Analyze Prisma schema files
15
- - `opensaas_introspect_keystone`: Analyze KeystoneJS config files
16
- - `opensaas_search_migration_docs`: Search local and online documentation
17
- - `opensaas_get_example`: Retrieve curated code examples
18
-
19
- **Enhanced Documentation Provider:**
20
- - Local CLAUDE.md file search with relevance scoring
21
- - Curated code examples for common patterns (blog-with-auth, access-control, relationships, hooks, custom-fields)
22
- - Project-specific migration guides for Prisma, KeystoneJS, and Next.js
23
-
24
- **Dependencies:**
25
- - Added `fs-extra` and `glob` for local file search capabilities
26
- - Added `@types/fs-extra` for TypeScript support
27
-
28
- Note: Migration wizard and introspectors are currently stubs and will be fully implemented in future phases.
29
-
30
- - [#196](https://github.com/OpenSaasAU/stack/pull/196) [`2f364b6`](https://github.com/OpenSaasAU/stack/commit/2f364b6b8295dfd205dfb3d0a11eb0bdb5ea2621) Thanks [@borisno2](https://github.com/borisno2)! - Add `opensaas migrate` CLI command for project migration
31
-
32
- Implements a new CLI command that helps users migrate existing Prisma, KeystoneJS, and Next.js projects to OpenSaaS Stack. The command provides both automatic project analysis and AI-guided migration through Claude Code integration.
33
-
34
- Features:
35
- - Auto-detects project type (Prisma, KeystoneJS, Next.js)
36
- - Analyzes existing schema (models, fields, database provider)
37
- - Optional AI-guided migration with `--with-ai` flag
38
- - Creates `.claude/` directory with migration assistant agent
39
- - Generates command files for schema analysis and config generation
40
- - Provides clear next steps and documentation links
41
-
42
- Usage:
43
-
44
- ```bash
45
- opensaas migrate # Analyze current project
46
- opensaas migrate --with-ai # Enable AI-guided migration
47
- opensaas migrate --type prisma # Force project type
48
- ```
49
-
50
- ### Patch Changes
51
-
52
- - Updated dependencies []:
53
- - @opensaas/stack-core@0.5.0
54
-
55
- ## 0.4.0
56
-
57
- ### Minor Changes
58
-
59
- - [#170](https://github.com/OpenSaasAU/stack/pull/170) [`3c4db9d`](https://github.com/OpenSaasAU/stack/commit/3c4db9d8318fc73d291991d8bdfa4f607c3a50ea) Thanks [@list({](https://github.com/list({)! - Add support for virtual fields with proper TypeScript type generation
60
-
61
- Virtual fields are computed fields that don't exist in the database but are added to query results at runtime. This feature enables derived or computed values to be included in your API responses with full type safety.
62
-
63
- **New Features:**
64
- - Added `virtual()` field type for defining computed fields in your schema
65
- - Virtual fields are automatically excluded from database schema and input types
66
- - Virtual fields appear in output types with full TypeScript autocomplete
67
- - Virtual fields support `resolveOutput` hooks for custom computation logic
68
-
69
- **Type System Improvements:**
70
- - Generated Context type now properly extends AccessContext from core
71
- - Separate Input and Output types (e.g., `UserOutput` includes virtual fields, `UserCreateInput` does not)
72
- - UI components now accept `AccessContext<any>` for better compatibility with custom context types
73
- - Type aliases provide convenience (e.g., `User = UserOutput`)
74
-
75
- **Example Usage:**
76
-
77
- ```typescript
78
- import { list, text, virtual } from '@opensaas/stack-core'
79
-
80
- export default config({
81
- lists: {
82
-
83
- fields: {
84
- name: text(),
85
- email: text(),
86
- displayName: virtual({
87
- type: 'string',
88
- hooks: {
89
- resolveOutput: async ({ item }) => {
90
- return `${item.name} (${item.email})`
91
- },
92
- },
93
- }),
94
- },
95
- }),
96
- },
97
- })
98
- ```
99
-
100
- The `displayName` field will automatically appear in query results with full TypeScript support, but won't be part of create/update operations or the database schema.
101
-
102
- ### Patch Changes
103
-
104
- - [#154](https://github.com/OpenSaasAU/stack/pull/154) [`edf1e5f`](https://github.com/OpenSaasAU/stack/commit/edf1e5fa4cfefcb7bc09bf45d4702260e6d0d3aa) Thanks [@renovate](https://github.com/apps/renovate)! - Update dependency chokidar to v5
105
-
106
- - [#172](https://github.com/OpenSaasAU/stack/pull/172) [`929a2a9`](https://github.com/OpenSaasAU/stack/commit/929a2a9a2dfa80b1d973d259dd87828d644ea58d) Thanks [@list<Lists.User.TypeInfo>({](https://github.com/list<Lists.User.TypeInfo>({), [@list<Lists.User.TypeInfo>({](https://github.com/list<Lists.User.TypeInfo>({)! - Improve TypeScript type inference for field configs and list-level hooks by automatically passing TypeInfo from list level down
107
-
108
- This change eliminates the need to manually specify type parameters on field builders when using features like virtual fields, and fixes a critical bug where list-level hooks weren't receiving properly typed parameters.
109
-
110
- ## Field Type Inference Improvements
111
-
112
- Previously, users had to write `virtual<Lists.User.TypeInfo>({...})` to get proper type inference. Now TypeScript automatically infers the correct types from the list-level type parameter.
113
-
114
- **Example:**
115
-
116
- ```typescript
117
- // Before
118
-
119
- fields: {
120
- displayName: virtual<Lists.User.TypeInfo>({
121
- type: 'string',
122
- hooks: {
123
- resolveOutput: ({ item }) => `${item.name} (${item.email})`,
124
- },
125
- }),
126
- },
127
- })
128
-
129
- // After
130
-
131
- fields: {
132
- displayName: virtual({
133
- type: 'string',
134
- hooks: {
135
- resolveOutput: ({ item }) => `${item.name} (${item.email})`,
136
- },
137
- }),
138
- },
139
- })
140
- ```
141
-
142
- ## List-Level Hooks Type Inference Fix
143
-
144
- Fixed a critical type parameter mismatch where `Hooks<TTypeInfo>` was passing the entire TypeInfo object as the first parameter instead of properly destructuring it into three required parameters:
145
- 1. `TOutput` - The item type (what's stored in DB)
146
- 2. `TCreateInput` - Prisma create input type
147
- 3. `TUpdateInput` - Prisma update input type
148
-
149
- **Impact:**
150
- - `resolveInput` now receives proper Prisma input types (e.g., `PostCreateInput`, `PostUpdateInput`)
151
- - `validateInput` has access to properly typed input data
152
- - `beforeOperation` and `afterOperation` have correct item types
153
- - All list-level hook callbacks now get full IntelliSense and type checking
154
-
155
- **Example:**
156
-
157
- ```typescript
158
- Post: list<Lists.Post.TypeInfo>({
159
- fields: { title: text(), content: text() },
160
- hooks: {
161
- resolveInput: async ({ operation, resolvedData }) => {
162
- // ✅ resolvedData is now properly typed as PostCreateInput or PostUpdateInput
163
- // ✅ Full autocomplete for title, content, etc.
164
- if (operation === 'create') {
165
- console.log(resolvedData.title) // TypeScript knows this is string | undefined
166
- }
167
- return resolvedData
168
- },
169
- beforeOperation: async ({ operation, item }) => {
170
- // ✅ item is now properly typed as Post with all fields
171
- if (operation === 'update' && item) {
172
- console.log(item.title) // TypeScript knows this is string
173
- console.log(item.createdAt) // TypeScript knows this is Date
174
- }
175
- },
176
- },
177
- })
178
- ```
179
-
180
- ## Breaking Changes
181
- - Field types now accept full `TTypeInfo extends TypeInfo` instead of just `TItem`
182
- - `FieldsWithItemType` utility replaced with `FieldsWithTypeInfo`
183
- - All field builders updated to use new type signature
184
- - List-level hooks now receive properly typed parameters (may reveal existing type errors)
185
-
186
- ## Benefits
187
- - ✨ Cleaner code without manual type parameter repetition
188
- - 🎯 Better type inference in both field-level and list-level hooks
189
- - 🔄 Consistent type flow from list configuration down to individual fields
190
- - 🛡️ Maintained full type safety with improved DX
191
- - 💡 Full IntelliSense support in all hook callbacks
192
-
193
- - Updated dependencies [[`527b677`](https://github.com/OpenSaasAU/stack/commit/527b677ab598070185e23d163a9e99bc20f03c49), [`929a2a9`](https://github.com/OpenSaasAU/stack/commit/929a2a9a2dfa80b1d973d259dd87828d644ea58d), [`3c4db9d`](https://github.com/OpenSaasAU/stack/commit/3c4db9d8318fc73d291991d8bdfa4f607c3a50ea)]:
194
- - @opensaas/stack-core@0.4.0
195
-
196
- ## 0.3.0
197
-
198
- ### Patch Changes
199
-
200
- - Updated dependencies []:
201
- - @opensaas/stack-core@0.3.0
202
-
203
- ## 0.2.0
204
-
205
- ### Minor Changes
206
-
207
- - [#107](https://github.com/OpenSaasAU/stack/pull/107) [`f4f3966`](https://github.com/OpenSaasAU/stack/commit/f4f3966faedba07d2cf412fab826d81e30c63a6c) Thanks [@borisno2](https://github.com/borisno2)! - # Add MCP Server for AI-Assisted Development
208
-
209
- ## New Features
210
-
211
- ### CLI Package (@opensaas/stack-cli)
212
- - **New `opensaas mcp` command group** for AI-assisted development:
213
- - `opensaas mcp install` - Install MCP server in Claude Code
214
- - `opensaas mcp uninstall` - Remove MCP server from Claude Code
215
- - `opensaas mcp start` - Start MCP server directly (for debugging)
216
- - **Feature-driven development tools**:
217
- - Interactive feature implementation wizards (authentication, blog, comments, file-upload, semantic-search)
218
- - Live documentation search from stack.opensaas.au
219
- - Code generation following OpenSaaS best practices
220
- - Smart feature suggestions based on your current app
221
- - Config validation
222
- - **MCP tools available in Claude Code**:
223
- - `opensaas_implement_feature` - Start feature wizard
224
- - `opensaas_feature_docs` - Search documentation
225
- - `opensaas_list_features` - Browse available features
226
- - `opensaas_suggest_features` - Get personalized recommendations
227
- - `opensaas_validate_feature` - Validate implementations
228
-
229
- ### create-opensaas-app
230
- - **Interactive MCP setup prompt** during project creation
231
- - Option to enable AI development tools automatically
232
- - Automatic installation of MCP server if user opts in
233
- - Helpful instructions if MCP installation is declined or fails
234
-
235
- ## Installation
236
-
237
- Enable AI development tools for an existing project:
238
-
239
- ```bash
240
- npx @opensaas/stack-cli mcp install
241
- ```
242
-
243
- Or during project creation:
244
-
245
- ```bash
246
- npm create opensaas-app@latest my-app
247
- # When prompted: Enable AI development tools? → yes
248
- ```
249
-
250
- ## Benefits
251
- - **Build apps faster**: Describe what you want to build, get complete implementations
252
- - **Feature-driven development**: Work with high-level features instead of low-level config
253
- - **Best practices baked in**: Generated code follows OpenSaaS Stack patterns
254
- - **Live documentation**: Always up-to-date docs from the official site
255
- - **Single toolkit**: All developer commands in one CLI
256
-
257
- ## Example Usage
258
-
259
- With Claude Code installed and the MCP server enabled, you can:
260
-
261
- ```
262
- You: "I want to build a food tracking app"
263
-
264
- Claude Code uses MCP tools to:
265
- 1. Ask clarifying questions about requirements
266
- 2. Implement authentication feature (wizard)
267
- 3. Create custom Food and FoodLog lists
268
- 4. Generate complete code with UI and access control
269
- 5. Provide testing and deployment guidance
270
- ```
271
-
272
- - [#132](https://github.com/OpenSaasAU/stack/pull/132) [`fcf5cb8`](https://github.com/OpenSaasAU/stack/commit/fcf5cb8bbd55d802350b8d97e342dd7f6368163b) Thanks [@borisno2](https://github.com/borisno2)! - Upgrade to Prisma 7 with database adapter support
273
-
274
- ## Breaking Changes
275
-
276
- ### Required `prismaClientConstructor`
277
-
278
- Prisma 7 requires database adapters. All configs must now include `prismaClientConstructor`:
279
-
280
- ```typescript
281
- import { PrismaBetterSQLite3 } from '@prisma/adapter-better-sqlite3'
282
- import Database from 'better-sqlite3'
283
-
284
- export default config({
285
- db: {
286
- provider: 'sqlite',
287
- prismaClientConstructor: (PrismaClient) => {
288
- const db = new Database(process.env.DATABASE_URL || './dev.db')
289
- const adapter = new PrismaBetterSQLite3(db)
290
- return new PrismaClient({ adapter })
291
- },
292
- },
293
- })
294
- ```
295
-
296
- ### Removed `url` from `DatabaseConfig`
297
-
298
- The `url` field has been removed from the `DatabaseConfig` type. Database connection URLs are now passed directly to adapters in `prismaClientConstructor`:
299
-
300
- ```typescript
301
- // ❌ Before (Prisma 6)
302
- db: {
303
- provider: 'sqlite',
304
- url: 'file:./dev.db', // url in config
305
- }
306
-
307
- // ✅ After (Prisma 7)
308
- db: {
309
- provider: 'sqlite',
310
- prismaClientConstructor: (PrismaClient) => {
311
- const adapter = new PrismaBetterSQLite3({ url: './dev.db' }) // url in adapter
312
- return new PrismaClient({ adapter })
313
- },
314
- }
315
- ```
316
-
317
- ### Generated Schema Changes
318
- - Generator provider changed from `prisma-client-js` to `prisma-client`
319
- - Removed `url` field from datasource block
320
- - Database URL now passed via adapter in `prismaClientConstructor`
321
-
322
- ### Required Dependencies
323
-
324
- Install the appropriate adapter for your database:
325
- - **SQLite**: `@prisma/adapter-better-sqlite3` + `better-sqlite3`
326
- - **PostgreSQL**: `@prisma/adapter-pg` + `pg`
327
- - **MySQL**: `@prisma/adapter-mysql` + `mysql2`
328
-
329
- ## Migration Steps
330
- 1. Install Prisma 7 and adapter:
331
-
332
- ```bash
333
- pnpm add @prisma/client@7 @prisma/adapter-better-sqlite3 better-sqlite3
334
- pnpm add -D prisma@7
335
- ```
336
-
337
- 2. Update your `opensaas.config.ts` to include `prismaClientConstructor` (see example above)
338
- 3. Regenerate schema and client:
339
-
340
- ```bash
341
- pnpm generate
342
- npx prisma generate
343
- ```
344
-
345
- 4. Push schema to database:
346
- ```bash
347
- pnpm db:push
348
- ```
349
-
350
- See the updated documentation in CLAUDE.md for more examples including PostgreSQL and custom adapters.
351
-
352
- ### Patch Changes
353
-
354
- - [#107](https://github.com/OpenSaasAU/stack/pull/107) [`f4f3966`](https://github.com/OpenSaasAU/stack/commit/f4f3966faedba07d2cf412fab826d81e30c63a6c) Thanks [@borisno2](https://github.com/borisno2)! - Add strict typing for plugin runtime services
355
-
356
- This change implements fully typed plugin runtime services, providing autocomplete and type safety for `context.plugins` throughout the codebase.
357
-
358
- **Core Changes:**
359
- - Extended `Plugin` type with optional `runtimeServiceTypes` metadata for type-safe code generation
360
- - Converted `OpenSaasConfig` and `AccessContext` from `type` to `interface` to enable module augmentation
361
- - Plugins can now declare their runtime service type information
362
-
363
- **Auth Plugin:**
364
- - Added `AuthRuntimeServices` interface defining runtime service types
365
- - Exported runtime types from package
366
- - Users now get full autocomplete for `context.plugins.auth.getUser()` and `context.plugins.auth.getCurrentUser()`
367
-
368
- **RAG Plugin:**
369
- - Added `RAGRuntimeServices` interface defining runtime service types
370
- - Exported runtime types from package
371
- - Users now get full autocomplete for `context.plugins.rag.generateEmbedding()` and `context.plugins.rag.generateEmbeddings()`
372
-
373
- **CLI Generator:**
374
- - Enhanced plugin types generator to import and use plugin runtime service types
375
- - Generated `.opensaas/plugin-types.ts` now includes proper type imports
376
- - `PluginServices` interface extends `Record<string, Record<string, any> | undefined>` for type compatibility
377
- - Maintains backwards compatibility with plugins that don't provide type metadata
378
-
379
- **UI Package:**
380
- - Updated `AdminUI` props to accept contexts with typed plugin services
381
- - Ensures compatibility between generated context types and UI components
382
-
383
- **Benefits:**
384
- - Full TypeScript autocomplete for all plugin runtime methods
385
- - Compile-time type checking catches errors early
386
- - Better IDE experience with hover documentation and jump-to-definition
387
- - Backwards compatible - third-party plugins without type metadata continue to work
388
- - Zero type errors in examples
389
-
390
- **Example:**
391
-
392
- ```typescript
393
- const context = await getContext()
394
-
395
- // Fully typed with autocomplete
396
- context.plugins.auth.getUser('123') // (userId: string) => Promise<unknown>
397
- context.plugins.rag.generateEmbedding('text') // (text: string, providerName?: string) => Promise<number[]>
398
- ```
399
-
400
- - Updated dependencies [[`fcf5cb8`](https://github.com/OpenSaasAU/stack/commit/fcf5cb8bbd55d802350b8d97e342dd7f6368163b), [`3851a3c`](https://github.com/OpenSaasAU/stack/commit/3851a3cf72e78dc6f01a73c6fff97deca6fad043), [`f4f3966`](https://github.com/OpenSaasAU/stack/commit/f4f3966faedba07d2cf412fab826d81e30c63a6c)]:
401
- - @opensaas/stack-core@0.2.0
402
-
403
- ## 0.1.7
404
-
405
- ### Patch Changes
406
-
407
- - 372d467: Add sudo to context to bypass access control
408
- - Updated dependencies [372d467]
409
- - @opensaas/stack-core@0.1.7
410
-
411
- ## 0.1.6
412
-
413
- ### Patch Changes
414
-
415
- - 39996ca: Fix missing StoredEmbedding type import in generated types. Fields can now declare TypeScript imports needed for their types via the new `getTypeScriptImports()` method. This resolves the type error where `StoredEmbedding` was referenced but not imported in the generated `.opensaas/types.ts` file.
416
- - 39996ca: Add plugin mechanism
417
- - Updated dependencies [39996ca]
418
- - Updated dependencies [39996ca]
419
- - @opensaas/stack-core@0.1.6
420
-
421
- ## 0.1.5
422
-
423
- ### Patch Changes
424
-
425
- - 17eaafb: Update package urls
426
- - Updated dependencies [17eaafb]
427
- - @opensaas/stack-core@0.1.5
428
-
429
- ## 0.1.4
430
-
431
- ### Patch Changes
432
-
433
- - d2d1720: clean up dependency
434
- - Updated dependencies [d013859]
435
- - @opensaas/stack-core@0.1.4
436
-
437
- ## 0.1.3
438
-
439
- ### Patch Changes
440
-
441
- - @opensaas/stack-core@0.1.3
442
- - @opensaas/stack-mcp@0.1.3
443
-
444
- ## 0.1.2
445
-
446
- ### Patch Changes
447
-
448
- - 7bb96e6: Fix up init command to work
449
- - @opensaas/stack-core@0.1.2
450
- - @opensaas/stack-mcp@0.1.2
451
-
452
- ## 0.1.1
453
-
454
- ### Patch Changes
455
-
456
- - f8ebc0e: Add base mcp server
457
- - 045c071: Add field and image upload
458
- - Updated dependencies [9a3fda5]
459
- - Updated dependencies [f8ebc0e]
460
- - Updated dependencies [045c071]
461
- - @opensaas/stack-core@0.1.1
462
- - @opensaas/stack-mcp@0.1.1