@opensaas/stack-cli 0.4.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 (90) hide show
  1. package/README.md +76 -0
  2. package/dist/commands/migrate.d.ts +9 -0
  3. package/dist/commands/migrate.d.ts.map +1 -0
  4. package/dist/commands/migrate.js +299 -0
  5. package/dist/commands/migrate.js.map +1 -0
  6. package/dist/index.js +3 -0
  7. package/dist/index.js.map +1 -1
  8. package/dist/mcp/lib/documentation-provider.d.ts +23 -0
  9. package/dist/mcp/lib/documentation-provider.d.ts.map +1 -1
  10. package/dist/mcp/lib/documentation-provider.js +471 -0
  11. package/dist/mcp/lib/documentation-provider.js.map +1 -1
  12. package/dist/mcp/lib/wizards/migration-wizard.d.ts +80 -0
  13. package/dist/mcp/lib/wizards/migration-wizard.d.ts.map +1 -0
  14. package/dist/mcp/lib/wizards/migration-wizard.js +499 -0
  15. package/dist/mcp/lib/wizards/migration-wizard.js.map +1 -0
  16. package/dist/mcp/server/index.d.ts.map +1 -1
  17. package/dist/mcp/server/index.js +103 -0
  18. package/dist/mcp/server/index.js.map +1 -1
  19. package/dist/mcp/server/stack-mcp-server.d.ts +85 -0
  20. package/dist/mcp/server/stack-mcp-server.d.ts.map +1 -1
  21. package/dist/mcp/server/stack-mcp-server.js +219 -0
  22. package/dist/mcp/server/stack-mcp-server.js.map +1 -1
  23. package/dist/migration/generators/migration-generator.d.ts +60 -0
  24. package/dist/migration/generators/migration-generator.d.ts.map +1 -0
  25. package/dist/migration/generators/migration-generator.js +510 -0
  26. package/dist/migration/generators/migration-generator.js.map +1 -0
  27. package/dist/migration/introspectors/index.d.ts +12 -0
  28. package/dist/migration/introspectors/index.d.ts.map +1 -0
  29. package/dist/migration/introspectors/index.js +10 -0
  30. package/dist/migration/introspectors/index.js.map +1 -0
  31. package/dist/migration/introspectors/keystone-introspector.d.ts +59 -0
  32. package/dist/migration/introspectors/keystone-introspector.d.ts.map +1 -0
  33. package/dist/migration/introspectors/keystone-introspector.js +229 -0
  34. package/dist/migration/introspectors/keystone-introspector.js.map +1 -0
  35. package/dist/migration/introspectors/nextjs-introspector.d.ts +59 -0
  36. package/dist/migration/introspectors/nextjs-introspector.d.ts.map +1 -0
  37. package/dist/migration/introspectors/nextjs-introspector.js +159 -0
  38. package/dist/migration/introspectors/nextjs-introspector.js.map +1 -0
  39. package/dist/migration/introspectors/prisma-introspector.d.ts +45 -0
  40. package/dist/migration/introspectors/prisma-introspector.d.ts.map +1 -0
  41. package/dist/migration/introspectors/prisma-introspector.js +190 -0
  42. package/dist/migration/introspectors/prisma-introspector.js.map +1 -0
  43. package/dist/migration/types.d.ts +86 -0
  44. package/dist/migration/types.d.ts.map +1 -0
  45. package/dist/migration/types.js +5 -0
  46. package/dist/migration/types.js.map +1 -0
  47. package/package.json +10 -2
  48. package/plugin/.claude-plugin/plugin.json +15 -0
  49. package/plugin/README.md +112 -0
  50. package/plugin/agents/migration-assistant.md +150 -0
  51. package/plugin/commands/analyze-schema.md +34 -0
  52. package/plugin/commands/generate-config.md +33 -0
  53. package/plugin/commands/validate-migration.md +34 -0
  54. package/plugin/skills/opensaas-migration/SKILL.md +192 -0
  55. package/.turbo/turbo-build.log +0 -4
  56. package/CHANGELOG.md +0 -410
  57. package/CLAUDE.md +0 -298
  58. package/src/commands/__snapshots__/generate.test.ts.snap +0 -413
  59. package/src/commands/dev.test.ts +0 -215
  60. package/src/commands/dev.ts +0 -48
  61. package/src/commands/generate.test.ts +0 -282
  62. package/src/commands/generate.ts +0 -182
  63. package/src/commands/init.ts +0 -34
  64. package/src/commands/mcp.ts +0 -135
  65. package/src/generator/__snapshots__/context.test.ts.snap +0 -361
  66. package/src/generator/__snapshots__/prisma.test.ts.snap +0 -174
  67. package/src/generator/__snapshots__/types.test.ts.snap +0 -1702
  68. package/src/generator/context.test.ts +0 -139
  69. package/src/generator/context.ts +0 -227
  70. package/src/generator/index.ts +0 -7
  71. package/src/generator/lists.test.ts +0 -335
  72. package/src/generator/lists.ts +0 -140
  73. package/src/generator/plugin-types.ts +0 -147
  74. package/src/generator/prisma-config.ts +0 -46
  75. package/src/generator/prisma-extensions.ts +0 -159
  76. package/src/generator/prisma.test.ts +0 -211
  77. package/src/generator/prisma.ts +0 -161
  78. package/src/generator/types.test.ts +0 -268
  79. package/src/generator/types.ts +0 -537
  80. package/src/index.ts +0 -42
  81. package/src/mcp/lib/documentation-provider.ts +0 -203
  82. package/src/mcp/lib/features/catalog.ts +0 -301
  83. package/src/mcp/lib/generators/feature-generator.ts +0 -598
  84. package/src/mcp/lib/types.ts +0 -89
  85. package/src/mcp/lib/wizards/wizard-engine.ts +0 -427
  86. package/src/mcp/server/index.ts +0 -240
  87. package/src/mcp/server/stack-mcp-server.ts +0 -301
  88. package/tsconfig.json +0 -13
  89. package/tsconfig.tsbuildinfo +0 -1
  90. package/vitest.config.ts +0 -26
@@ -1,203 +0,0 @@
1
- /**
2
- * Documentation provider - Fetches documentation from the hosted docs site
3
- */
4
-
5
- import type { DocumentationLookup } from './types.js'
6
-
7
- interface SearchResult {
8
- content: string
9
- metadata: {
10
- title?: string
11
- slug?: string
12
- section?: string
13
- }
14
- score: number
15
- }
16
-
17
- interface SearchResponse {
18
- results: SearchResult[]
19
- query: string
20
- count: number
21
- }
22
-
23
- export class OpenSaasDocumentationProvider {
24
- private readonly DOCS_API = 'https://stack.opensaas.au/api/search'
25
- private cache = new Map<string, { data: DocumentationLookup; timestamp: number }>()
26
- private readonly CACHE_TTL = 1000 * 60 * 30 // 30 minutes
27
-
28
- // Topic mappings for user-friendly queries
29
- private topicMappings: Record<string, string> = {
30
- fields: 'field-types',
31
- 'field types': 'field-types',
32
- 'field type': 'field-types',
33
- access: 'access-control',
34
- 'access control': 'access-control',
35
- permissions: 'access-control',
36
- auth: 'authentication',
37
- authentication: 'authentication',
38
- login: 'authentication',
39
- 'sign in': 'authentication',
40
- hooks: 'hooks',
41
- hook: 'hooks',
42
- lifecycle: 'hooks',
43
- plugins: 'plugin-system',
44
- plugin: 'plugin-system',
45
- rag: 'rag',
46
- search: 'semantic-search',
47
- 'semantic search': 'semantic-search',
48
- storage: 'file-storage',
49
- files: 'file-storage',
50
- upload: 'file-storage',
51
- config: 'configuration',
52
- configuration: 'configuration',
53
- prisma: 'prisma-integration',
54
- database: 'database-setup',
55
- deployment: 'deployment',
56
- deploy: 'deployment',
57
- }
58
-
59
- /**
60
- * Search documentation by query
61
- */
62
- async searchDocs(query: string, limit = 5, minScore = 0.7): Promise<DocumentationLookup> {
63
- const cacheKey = `search:${query}:${limit}:${minScore}`
64
-
65
- // Check cache
66
- const cached = this.cache.get(cacheKey)
67
- if (cached && Date.now() - cached.timestamp < this.CACHE_TTL) {
68
- return cached.data
69
- }
70
-
71
- try {
72
- const response = await fetch(this.DOCS_API, {
73
- method: 'POST',
74
- headers: {
75
- 'Content-Type': 'application/json',
76
- },
77
- body: JSON.stringify({ query, limit, minScore }),
78
- })
79
-
80
- if (!response.ok) {
81
- throw new Error(`Docs API error: ${response.statusText}`)
82
- }
83
-
84
- const data = (await response.json()) as SearchResponse
85
-
86
- const docLookup: DocumentationLookup = {
87
- topic: query,
88
- content: this.formatSearchResults(data.results),
89
- url: 'https://stack.opensaas.au/',
90
- codeExamples: this.extractCodeExamples(data.results),
91
- relatedTopics: this.extractRelatedTopics(data.results),
92
- }
93
-
94
- // Cache the result
95
- this.cache.set(cacheKey, { data: docLookup, timestamp: Date.now() })
96
-
97
- return docLookup
98
- } catch (error) {
99
- console.error('Error fetching documentation:', error)
100
- return this.getFallbackDocs(query)
101
- }
102
- }
103
-
104
- /**
105
- * Get documentation for a specific topic
106
- */
107
- async getTopicDocs(topic: string): Promise<DocumentationLookup> {
108
- // Normalize topic using mappings
109
- const normalizedTopic = this.topicMappings[topic.toLowerCase()] || topic
110
-
111
- return this.searchDocs(normalizedTopic, 3, 0.8)
112
- }
113
-
114
- /**
115
- * Format search results into readable content
116
- */
117
- private formatSearchResults(results: SearchResult[]): string {
118
- if (results.length === 0) {
119
- return 'No documentation found for this query.'
120
- }
121
-
122
- return results
123
- .map((result, index) => {
124
- const title = result.metadata.title || `Section ${index + 1}`
125
- const section = result.metadata.section || ''
126
- const score = (result.score * 100).toFixed(0)
127
-
128
- return `### ${title}${section ? ` (${section})` : ''} [Relevance: ${score}%]\n\n${result.content}\n`
129
- })
130
- .join('\n---\n\n')
131
- }
132
-
133
- /**
134
- * Extract code examples from search results
135
- */
136
- private extractCodeExamples(results: SearchResult[]): string[] {
137
- const codeExamples: string[] = []
138
- const codeBlockRegex = /```[\s\S]*?```/g
139
-
140
- for (const result of results) {
141
- const matches = result.content.match(codeBlockRegex)
142
- if (matches) {
143
- codeExamples.push(...matches)
144
- }
145
- }
146
-
147
- return codeExamples
148
- }
149
-
150
- /**
151
- * Extract related topics from search results
152
- */
153
- private extractRelatedTopics(results: SearchResult[]): string[] {
154
- const topics = new Set<string>()
155
-
156
- for (const result of results) {
157
- if (result.metadata.section) {
158
- topics.add(result.metadata.section)
159
- }
160
- }
161
-
162
- return Array.from(topics)
163
- }
164
-
165
- /**
166
- * Fallback documentation when API is unavailable
167
- */
168
- private getFallbackDocs(query: string): DocumentationLookup {
169
- return {
170
- topic: query,
171
- content: `Unable to fetch documentation from the docs site at this time.
172
-
173
- Please visit the OpenSaaS Stack documentation directly:
174
- https://stack.opensaas.au/
175
-
176
- For ${query}, you can also check:
177
- - GitHub repository: https://github.com/OpenSaasAU/stack
178
- - Example projects in the examples/ directory`,
179
- url: 'https://stack.opensaas.au/',
180
- codeExamples: [],
181
- relatedTopics: [],
182
- }
183
- }
184
-
185
- /**
186
- * Clear expired cache entries
187
- */
188
- clearExpiredCache(): void {
189
- const now = Date.now()
190
- for (const [key, value] of this.cache.entries()) {
191
- if (now - value.timestamp >= this.CACHE_TTL) {
192
- this.cache.delete(key)
193
- }
194
- }
195
- }
196
-
197
- /**
198
- * Clear all cache
199
- */
200
- clearCache(): void {
201
- this.cache.clear()
202
- }
203
- }
@@ -1,301 +0,0 @@
1
- /**
2
- * Feature catalog - Defines all available features with their configuration wizards
3
- */
4
-
5
- import type { Feature } from '../types.js'
6
-
7
- export const AUTHENTICATION_FEATURE: Feature = {
8
- id: 'authentication',
9
- name: 'User Authentication',
10
- description: 'Complete authentication system with sessions, sign-up/sign-in, and access control',
11
- category: 'authentication',
12
- includes: [
13
- 'User list with email, password, name, and optional fields',
14
- 'Better-auth integration with session management',
15
- 'Sign-up and sign-in pages with form validation',
16
- 'Access control helpers (isAuthenticated, isAdmin, isOwner)',
17
- 'OAuth providers (optional)',
18
- 'Email verification (optional)',
19
- ],
20
- questions: [
21
- {
22
- id: 'auth-methods',
23
- text: 'Which authentication methods do you want to support?',
24
- type: 'multiselect',
25
- required: true,
26
- options: ['Email & Password', 'Google OAuth', 'GitHub OAuth', 'Magic Links'],
27
- defaultValue: ['Email & Password'],
28
- },
29
- {
30
- id: 'user-roles',
31
- text: 'Do you need user roles for access control?',
32
- type: 'boolean',
33
- required: true,
34
- defaultValue: true,
35
- followUp: {
36
- if: true,
37
- ask: 'What roles do you need? (Enter comma-separated, e.g., admin,editor,user)',
38
- type: 'text',
39
- },
40
- },
41
- {
42
- id: 'user-fields',
43
- text: 'Select additional user profile fields',
44
- type: 'multiselect',
45
- required: false,
46
- options: ['Avatar', 'Bio', 'Phone', 'Location', 'Website'],
47
- defaultValue: [],
48
- },
49
- {
50
- id: 'email-verification',
51
- text: 'Require email verification for new accounts?',
52
- type: 'boolean',
53
- required: true,
54
- defaultValue: false,
55
- },
56
- ],
57
- }
58
-
59
- export const BLOG_FEATURE: Feature = {
60
- id: 'blog',
61
- name: 'Blog System',
62
- description: 'Complete blog with posts, authors, and rich content editing',
63
- category: 'content',
64
- includes: [
65
- 'Post list with title, content, and metadata',
66
- 'Author relationship to User',
67
- 'Draft/publish workflow with status field',
68
- 'Access control (authors can edit own posts)',
69
- 'Rich text editor or markdown support',
70
- 'SEO-friendly slugs',
71
- ],
72
- dependsOn: ['authentication'],
73
- questions: [
74
- {
75
- id: 'content-editor',
76
- text: 'How should users write posts?',
77
- type: 'select',
78
- required: true,
79
- options: ['Rich text editor (Tiptap)', 'Markdown', 'Plain text'],
80
- defaultValue: 'Rich text editor (Tiptap)',
81
- },
82
- {
83
- id: 'post-status',
84
- text: 'Enable draft/publish workflow?',
85
- type: 'boolean',
86
- required: true,
87
- defaultValue: true,
88
- },
89
- {
90
- id: 'taxonomy',
91
- text: 'Add categories or tags for organizing posts?',
92
- type: 'multiselect',
93
- required: false,
94
- options: ['Categories', 'Tags'],
95
- defaultValue: [],
96
- },
97
- {
98
- id: 'post-fields',
99
- text: 'Select additional post fields',
100
- type: 'multiselect',
101
- required: false,
102
- options: [
103
- 'Featured image',
104
- 'Excerpt/summary',
105
- 'SEO metadata (title, description)',
106
- 'Published date',
107
- 'Reading time estimate',
108
- ],
109
- defaultValue: ['Featured image', 'Excerpt/summary'],
110
- },
111
- {
112
- id: 'comments-enabled',
113
- text: 'Enable comments on blog posts?',
114
- type: 'boolean',
115
- required: false,
116
- defaultValue: false,
117
- },
118
- ],
119
- }
120
-
121
- export const COMMENTS_FEATURE: Feature = {
122
- id: 'comments',
123
- name: 'Comments System',
124
- description: 'Add threaded comments to your content with moderation',
125
- category: 'content',
126
- includes: [
127
- 'Comment list with content and author',
128
- 'Relationship to commentable content',
129
- 'Nested replies support (optional)',
130
- 'Moderation workflow',
131
- 'Access control for comment management',
132
- ],
133
- dependsOn: ['authentication'],
134
- questions: [
135
- {
136
- id: 'comment-targets',
137
- text: 'What content types can users comment on?',
138
- type: 'multiselect',
139
- required: true,
140
- options: ['Posts', 'Products', 'Other'],
141
- defaultValue: ['Posts'],
142
- },
143
- {
144
- id: 'nested-replies',
145
- text: 'Allow nested/threaded replies?',
146
- type: 'boolean',
147
- required: true,
148
- defaultValue: true,
149
- },
150
- {
151
- id: 'moderation',
152
- text: 'Comment moderation approach?',
153
- type: 'select',
154
- required: true,
155
- options: [
156
- 'Auto-approve all comments',
157
- 'Require admin approval',
158
- 'Auto-approve for verified users only',
159
- ],
160
- defaultValue: 'Auto-approve all comments',
161
- },
162
- {
163
- id: 'comment-features',
164
- text: 'Additional comment features?',
165
- type: 'multiselect',
166
- required: false,
167
- options: ['Upvotes/downvotes', 'Report/flag comments', 'Markdown support'],
168
- defaultValue: [],
169
- },
170
- ],
171
- }
172
-
173
- export const FILE_UPLOAD_FEATURE: Feature = {
174
- id: 'file-upload',
175
- name: 'File Uploads',
176
- description: 'Upload and manage files with cloud storage integration',
177
- category: 'storage',
178
- includes: [
179
- 'File list with name, URL, size, and type',
180
- 'Storage plugin integration',
181
- 'Upload UI components',
182
- 'Access control for files',
183
- 'Image optimization (optional)',
184
- ],
185
- questions: [
186
- {
187
- id: 'storage-provider',
188
- text: 'Which storage provider do you want to use?',
189
- type: 'select',
190
- required: true,
191
- options: ['AWS S3', 'Cloudflare R2', 'Vercel Blob', 'Local filesystem (development only)'],
192
- defaultValue: 'Vercel Blob',
193
- },
194
- {
195
- id: 'file-associations',
196
- text: 'Where will files be used?',
197
- type: 'multiselect',
198
- required: true,
199
- options: ['User avatars', 'Post featured images', 'General attachments', 'Product images'],
200
- defaultValue: ['User avatars'],
201
- },
202
- {
203
- id: 'file-types',
204
- text: 'What file types should be allowed?',
205
- type: 'multiselect',
206
- required: true,
207
- options: ['Images (jpg, png, webp)', 'PDFs', 'Videos', 'Any file type'],
208
- defaultValue: ['Images (jpg, png, webp)'],
209
- },
210
- {
211
- id: 'image-processing',
212
- text: 'Enable automatic image optimization and resizing?',
213
- type: 'boolean',
214
- required: false,
215
- defaultValue: true,
216
- dependsOn: {
217
- questionId: 'file-types',
218
- value: 'Images (jpg, png, webp)',
219
- },
220
- },
221
- ],
222
- }
223
-
224
- export const SEMANTIC_SEARCH_FEATURE: Feature = {
225
- id: 'semantic-search',
226
- name: 'Semantic Search',
227
- description: 'AI-powered search using RAG (Retrieval Augmented Generation)',
228
- category: 'search',
229
- includes: [
230
- 'RAG plugin integration',
231
- 'Automatic embeddings generation',
232
- 'Search API endpoint',
233
- 'Search UI component',
234
- 'Relevance scoring',
235
- ],
236
- questions: [
237
- {
238
- id: 'searchable-content',
239
- text: 'What content should be searchable?',
240
- type: 'multiselect',
241
- required: true,
242
- options: ['Posts', 'Products', 'Documentation', 'User profiles'],
243
- defaultValue: ['Posts'],
244
- },
245
- {
246
- id: 'embedding-provider',
247
- text: 'Which embedding provider?',
248
- type: 'select',
249
- required: true,
250
- options: ['OpenAI (text-embedding-3-small)', 'Cohere', 'Anthropic'],
251
- defaultValue: 'OpenAI (text-embedding-3-small)',
252
- },
253
- {
254
- id: 'search-fields',
255
- text: 'Which fields should be indexed for search?',
256
- type: 'multiselect',
257
- required: true,
258
- options: ['Title', 'Content/body', 'Excerpt', 'Tags/categories'],
259
- defaultValue: ['Title', 'Content/body'],
260
- },
261
- {
262
- id: 'real-time-indexing',
263
- text: 'Update search index in real-time when content changes?',
264
- type: 'boolean',
265
- required: true,
266
- defaultValue: true,
267
- },
268
- ],
269
- }
270
-
271
- /**
272
- * Feature catalog - maps feature IDs to feature definitions
273
- */
274
- export const FeatureCatalog = new Map<string, Feature>([
275
- ['authentication', AUTHENTICATION_FEATURE],
276
- ['blog', BLOG_FEATURE],
277
- ['comments', COMMENTS_FEATURE],
278
- ['file-upload', FILE_UPLOAD_FEATURE],
279
- ['semantic-search', SEMANTIC_SEARCH_FEATURE],
280
- ])
281
-
282
- /**
283
- * Get feature by ID
284
- */
285
- export function getFeature(featureId: string): Feature | undefined {
286
- return FeatureCatalog.get(featureId)
287
- }
288
-
289
- /**
290
- * Get all available features
291
- */
292
- export function getAllFeatures(): Feature[] {
293
- return Array.from(FeatureCatalog.values())
294
- }
295
-
296
- /**
297
- * Get features by category
298
- */
299
- export function getFeaturesByCategory(category: Feature['category']): Feature[] {
300
- return getAllFeatures().filter((f) => f.category === category)
301
- }