@opensaas/stack-cli 0.4.0 → 0.5.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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +52 -0
- package/dist/commands/migrate.d.ts +9 -0
- package/dist/commands/migrate.d.ts.map +1 -0
- package/dist/commands/migrate.js +473 -0
- package/dist/commands/migrate.js.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp/lib/documentation-provider.d.ts +23 -0
- package/dist/mcp/lib/documentation-provider.d.ts.map +1 -1
- package/dist/mcp/lib/documentation-provider.js +471 -0
- package/dist/mcp/lib/documentation-provider.js.map +1 -1
- package/dist/mcp/lib/wizards/migration-wizard.d.ts +80 -0
- package/dist/mcp/lib/wizards/migration-wizard.d.ts.map +1 -0
- package/dist/mcp/lib/wizards/migration-wizard.js +499 -0
- package/dist/mcp/lib/wizards/migration-wizard.js.map +1 -0
- package/dist/mcp/server/index.d.ts.map +1 -1
- package/dist/mcp/server/index.js +103 -0
- package/dist/mcp/server/index.js.map +1 -1
- package/dist/mcp/server/stack-mcp-server.d.ts +85 -0
- package/dist/mcp/server/stack-mcp-server.d.ts.map +1 -1
- package/dist/mcp/server/stack-mcp-server.js +219 -0
- package/dist/mcp/server/stack-mcp-server.js.map +1 -1
- package/dist/migration/generators/migration-generator.d.ts +60 -0
- package/dist/migration/generators/migration-generator.d.ts.map +1 -0
- package/dist/migration/generators/migration-generator.js +510 -0
- package/dist/migration/generators/migration-generator.js.map +1 -0
- package/dist/migration/introspectors/index.d.ts +12 -0
- package/dist/migration/introspectors/index.d.ts.map +1 -0
- package/dist/migration/introspectors/index.js +10 -0
- package/dist/migration/introspectors/index.js.map +1 -0
- package/dist/migration/introspectors/keystone-introspector.d.ts +59 -0
- package/dist/migration/introspectors/keystone-introspector.d.ts.map +1 -0
- package/dist/migration/introspectors/keystone-introspector.js +229 -0
- package/dist/migration/introspectors/keystone-introspector.js.map +1 -0
- package/dist/migration/introspectors/nextjs-introspector.d.ts +59 -0
- package/dist/migration/introspectors/nextjs-introspector.d.ts.map +1 -0
- package/dist/migration/introspectors/nextjs-introspector.js +159 -0
- package/dist/migration/introspectors/nextjs-introspector.js.map +1 -0
- package/dist/migration/introspectors/prisma-introspector.d.ts +45 -0
- package/dist/migration/introspectors/prisma-introspector.d.ts.map +1 -0
- package/dist/migration/introspectors/prisma-introspector.js +190 -0
- package/dist/migration/introspectors/prisma-introspector.js.map +1 -0
- package/dist/migration/types.d.ts +86 -0
- package/dist/migration/types.d.ts.map +1 -0
- package/dist/migration/types.js +5 -0
- package/dist/migration/types.js.map +1 -0
- package/package.json +5 -2
- package/src/commands/migrate.ts +534 -0
- package/src/index.ts +4 -0
- package/src/mcp/lib/documentation-provider.ts +507 -0
- package/src/mcp/lib/wizards/migration-wizard.ts +584 -0
- package/src/mcp/server/index.ts +121 -0
- package/src/mcp/server/stack-mcp-server.ts +243 -0
- package/src/migration/generators/migration-generator.ts +675 -0
- package/src/migration/introspectors/index.ts +12 -0
- package/src/migration/introspectors/keystone-introspector.ts +296 -0
- package/src/migration/introspectors/nextjs-introspector.ts +209 -0
- package/src/migration/introspectors/prisma-introspector.ts +233 -0
- package/src/migration/types.ts +92 -0
- package/tests/introspectors/keystone-introspector.test.ts +255 -0
- package/tests/introspectors/nextjs-introspector.test.ts +302 -0
- package/tests/introspectors/prisma-introspector.test.ts +268 -0
- package/tests/migration-generator.test.ts +592 -0
- package/tests/migration-wizard.test.ts +442 -0
- package/tsconfig.tsbuildinfo +1 -1
package/.turbo/turbo-build.log
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,57 @@
|
|
|
1
1
|
# @opensaas/stack-cli
|
|
2
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
|
+
|
|
3
55
|
## 0.4.0
|
|
4
56
|
|
|
5
57
|
### Minor Changes
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migration command - Helps migrate existing projects to OpenSaaS Stack
|
|
3
|
+
*/
|
|
4
|
+
import { Command } from 'commander';
|
|
5
|
+
/**
|
|
6
|
+
* Create the migrate command for Commander
|
|
7
|
+
*/
|
|
8
|
+
export declare function createMigrateCommand(): Command;
|
|
9
|
+
//# sourceMappingURL=migrate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../src/commands/migrate.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AA4fnC;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAkB9C"}
|
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migration command - Helps migrate existing projects to OpenSaaS Stack
|
|
3
|
+
*/
|
|
4
|
+
import { Command } from 'commander';
|
|
5
|
+
import * as fs from 'fs';
|
|
6
|
+
import * as path from 'path';
|
|
7
|
+
import chalk from 'chalk';
|
|
8
|
+
import ora from 'ora';
|
|
9
|
+
/**
|
|
10
|
+
* Detect what type of project this is
|
|
11
|
+
*/
|
|
12
|
+
async function detectProjectType(cwd) {
|
|
13
|
+
const types = [];
|
|
14
|
+
// Check for Prisma
|
|
15
|
+
const prismaSchemaPath = path.join(cwd, 'prisma', 'schema.prisma');
|
|
16
|
+
if (fs.existsSync(prismaSchemaPath)) {
|
|
17
|
+
types.push('prisma');
|
|
18
|
+
}
|
|
19
|
+
// Check for KeystoneJS
|
|
20
|
+
const keystoneConfigPath = path.join(cwd, 'keystone.config.ts');
|
|
21
|
+
const keystoneAltPath = path.join(cwd, 'keystone.ts');
|
|
22
|
+
if (fs.existsSync(keystoneConfigPath) || fs.existsSync(keystoneAltPath)) {
|
|
23
|
+
types.push('keystone');
|
|
24
|
+
}
|
|
25
|
+
// Check for Next.js
|
|
26
|
+
const packageJsonPath = path.join(cwd, 'package.json');
|
|
27
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
28
|
+
const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
29
|
+
if (pkg.dependencies?.next || pkg.devDependencies?.next) {
|
|
30
|
+
types.push('nextjs');
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return types;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Analyze a Prisma schema
|
|
37
|
+
*/
|
|
38
|
+
async function analyzePrismaSchema(cwd) {
|
|
39
|
+
const schemaPath = path.join(cwd, 'prisma', 'schema.prisma');
|
|
40
|
+
const schema = fs.readFileSync(schemaPath, 'utf-8');
|
|
41
|
+
// Extract models
|
|
42
|
+
const modelRegex = /model\s+(\w+)\s*\{([^}]+)\}/g;
|
|
43
|
+
const models = [];
|
|
44
|
+
let match;
|
|
45
|
+
while ((match = modelRegex.exec(schema)) !== null) {
|
|
46
|
+
const name = match[1];
|
|
47
|
+
const body = match[2];
|
|
48
|
+
const fieldCount = body
|
|
49
|
+
.split('\n')
|
|
50
|
+
.filter((line) => line.trim() && !line.trim().startsWith('@@') && !line.trim().startsWith('//')).length;
|
|
51
|
+
models.push({ name, fieldCount });
|
|
52
|
+
}
|
|
53
|
+
// Extract provider
|
|
54
|
+
const providerMatch = schema.match(/provider\s*=\s*"(\w+)"/);
|
|
55
|
+
const provider = providerMatch ? providerMatch[1] : 'unknown';
|
|
56
|
+
return { models, provider };
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Ensure directory exists
|
|
60
|
+
*/
|
|
61
|
+
function ensureDir(dirPath) {
|
|
62
|
+
if (!fs.existsSync(dirPath)) {
|
|
63
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Generate template content with placeholders replaced
|
|
68
|
+
*/
|
|
69
|
+
function generateTemplateContent(template, data) {
|
|
70
|
+
const projectType = data.projectTypes[0] || 'unknown';
|
|
71
|
+
const projectTypeLower = projectType.toLowerCase();
|
|
72
|
+
const modelCount = data.models?.length || 0;
|
|
73
|
+
const modelList = data.models?.map((m) => `- ${m.name} (${m.fieldCount} fields)`).join('\n') || '';
|
|
74
|
+
const modelDetails = data.models?.map((m) => `- **${m.name}**: ${m.fieldCount} fields`).join('\n') || '';
|
|
75
|
+
return template
|
|
76
|
+
.replace(/\{\{PROJECT_TYPES\}\}/g, data.projectTypes.join(', '))
|
|
77
|
+
.replace(/\{\{PROJECT_TYPE\}\}/g, projectType)
|
|
78
|
+
.replace(/\{\{PROJECT_TYPE_LOWER\}\}/g, projectTypeLower)
|
|
79
|
+
.replace(/\{\{PROVIDER\}\}/g, data.provider || 'sqlite')
|
|
80
|
+
.replace(/\{\{MODEL_COUNT\}\}/g, String(modelCount))
|
|
81
|
+
.replace(/\{\{HAS_AUTH\}\}/g, String(data.hasAuth || false))
|
|
82
|
+
.replace(/\{\{MODEL_LIST\}\}/g, modelList)
|
|
83
|
+
.replace(/\{\{MODEL_DETAILS\}\}/g, modelDetails);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Setup Claude Code integration
|
|
87
|
+
*/
|
|
88
|
+
async function setupClaudeCode(cwd, analysis) {
|
|
89
|
+
const claudeDir = path.join(cwd, '.claude');
|
|
90
|
+
const agentsDir = path.join(claudeDir, 'agents');
|
|
91
|
+
const commandsDir = path.join(claudeDir, 'commands');
|
|
92
|
+
// Create directories
|
|
93
|
+
ensureDir(agentsDir);
|
|
94
|
+
ensureDir(commandsDir);
|
|
95
|
+
// Create settings.json
|
|
96
|
+
const settings = {
|
|
97
|
+
mcpServers: {
|
|
98
|
+
'opensaas-migration': {
|
|
99
|
+
command: 'npx',
|
|
100
|
+
args: ['@opensaas/stack-cli', 'mcp', 'start'],
|
|
101
|
+
disabled: false,
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
fs.writeFileSync(path.join(claudeDir, 'settings.json'), JSON.stringify(settings, null, 2));
|
|
106
|
+
// Create README template
|
|
107
|
+
const readmeTemplate = `# OpenSaaS Stack Migration
|
|
108
|
+
|
|
109
|
+
This project is being migrated to OpenSaaS Stack.
|
|
110
|
+
|
|
111
|
+
## Project Summary
|
|
112
|
+
|
|
113
|
+
- **Project Type:** {{PROJECT_TYPES}}
|
|
114
|
+
- **Database Provider:** {{PROVIDER}}
|
|
115
|
+
- **Models Detected:** {{MODEL_COUNT}}
|
|
116
|
+
|
|
117
|
+
### Models
|
|
118
|
+
|
|
119
|
+
{{MODEL_LIST}}
|
|
120
|
+
|
|
121
|
+
## Quick Start
|
|
122
|
+
|
|
123
|
+
Ask Claude: **"Help me migrate to OpenSaaS Stack"**
|
|
124
|
+
|
|
125
|
+
Claude will guide you through:
|
|
126
|
+
1. Reviewing your current schema
|
|
127
|
+
2. Configuring access control
|
|
128
|
+
3. Setting up authentication (optional)
|
|
129
|
+
4. Generating \`opensaas.config.ts\`
|
|
130
|
+
|
|
131
|
+
## Available Commands
|
|
132
|
+
|
|
133
|
+
| Command | Description |
|
|
134
|
+
|---------|-------------|
|
|
135
|
+
| \`/analyze-schema\` | View detailed schema analysis |
|
|
136
|
+
| \`/generate-config\` | Generate the config file |
|
|
137
|
+
| \`/validate-migration\` | Validate generated config |
|
|
138
|
+
|
|
139
|
+
## Resources
|
|
140
|
+
|
|
141
|
+
- [OpenSaaS Stack Documentation](https://stack.opensaas.au/)
|
|
142
|
+
- [Migration Guide](https://stack.opensaas.au/guides/migration)
|
|
143
|
+
- [GitHub Repository](https://github.com/OpenSaasAU/stack)
|
|
144
|
+
|
|
145
|
+
## Generated By
|
|
146
|
+
|
|
147
|
+
This migration was set up using:
|
|
148
|
+
\`\`\`bash
|
|
149
|
+
npx @opensaas/stack-cli migrate --with-ai
|
|
150
|
+
\`\`\`
|
|
151
|
+
`;
|
|
152
|
+
fs.writeFileSync(path.join(claudeDir, 'README.md'), generateTemplateContent(readmeTemplate, analysis));
|
|
153
|
+
// Create migration assistant agent template
|
|
154
|
+
const agentTemplate = `You are the OpenSaaS Stack Migration Assistant, helping users migrate their existing projects to OpenSaaS Stack.
|
|
155
|
+
|
|
156
|
+
## Project Context
|
|
157
|
+
|
|
158
|
+
**Project Type:** {{PROJECT_TYPES}}
|
|
159
|
+
**Database Provider:** {{PROVIDER}}
|
|
160
|
+
**Total Models:** {{MODEL_COUNT}}
|
|
161
|
+
|
|
162
|
+
### Detected Models
|
|
163
|
+
|
|
164
|
+
{{MODEL_DETAILS}}
|
|
165
|
+
|
|
166
|
+
## Your Role
|
|
167
|
+
|
|
168
|
+
Guide the user through a complete migration to OpenSaaS Stack:
|
|
169
|
+
|
|
170
|
+
1. **Analyze** their current project structure
|
|
171
|
+
2. **Explain** what OpenSaaS Stack offers (access control, admin UI, type safety)
|
|
172
|
+
3. **Guide** them through the migration wizard
|
|
173
|
+
4. **Generate** a working \`opensaas.config.ts\`
|
|
174
|
+
5. **Validate** the generated configuration
|
|
175
|
+
6. **Provide** clear next steps
|
|
176
|
+
|
|
177
|
+
## Available MCP Tools
|
|
178
|
+
|
|
179
|
+
### Schema Analysis
|
|
180
|
+
- \`opensaas_introspect_prisma\` - Analyze Prisma schema in detail
|
|
181
|
+
- \`opensaas_introspect_keystone\` - Analyze KeystoneJS config
|
|
182
|
+
|
|
183
|
+
### Migration Wizard
|
|
184
|
+
- \`opensaas_start_migration\` - Start the interactive wizard
|
|
185
|
+
- \`opensaas_answer_migration\` - Answer wizard questions
|
|
186
|
+
|
|
187
|
+
### Documentation
|
|
188
|
+
- \`opensaas_search_migration_docs\` - Search migration documentation
|
|
189
|
+
- \`opensaas_get_example\` - Get example code patterns
|
|
190
|
+
|
|
191
|
+
### Validation
|
|
192
|
+
- \`opensaas_validate_feature\` - Validate implementation
|
|
193
|
+
|
|
194
|
+
## Conversation Guidelines
|
|
195
|
+
|
|
196
|
+
### When the user says "help me migrate" or similar:
|
|
197
|
+
|
|
198
|
+
1. **Acknowledge** their project:
|
|
199
|
+
> "I can see you have a {{PROJECT_TYPE}} project with {{MODEL_COUNT}} models. Let me help you migrate to OpenSaaS Stack!"
|
|
200
|
+
|
|
201
|
+
2. **Start the wizard** by calling:
|
|
202
|
+
\`\`\`
|
|
203
|
+
opensaas_start_migration({ projectType: "{{PROJECT_TYPE_LOWER}}" })
|
|
204
|
+
\`\`\`
|
|
205
|
+
|
|
206
|
+
3. **Present questions naturally** - don't mention session IDs or technical details to the user
|
|
207
|
+
|
|
208
|
+
4. **Explain choices** - help them understand what each option means:
|
|
209
|
+
- Access control patterns
|
|
210
|
+
- Authentication options
|
|
211
|
+
- Database configuration
|
|
212
|
+
|
|
213
|
+
5. **Show progress** - let them know how far along they are
|
|
214
|
+
|
|
215
|
+
6. **Generate the config** when complete and explain what was created
|
|
216
|
+
|
|
217
|
+
### When explaining OpenSaaS Stack:
|
|
218
|
+
|
|
219
|
+
Highlight these benefits:
|
|
220
|
+
- **Built-in access control** - Secure by default
|
|
221
|
+
- **Admin UI** - Auto-generated from your schema
|
|
222
|
+
- **Type safety** - Full TypeScript support
|
|
223
|
+
- **Prisma integration** - Uses familiar ORM
|
|
224
|
+
- **Plugin system** - Easy to extend
|
|
225
|
+
|
|
226
|
+
### When answering questions:
|
|
227
|
+
|
|
228
|
+
- Use \`opensaas_search_migration_docs\` to find accurate information
|
|
229
|
+
- Use \`opensaas_get_example\` to show code patterns
|
|
230
|
+
- Be honest if something isn't supported
|
|
231
|
+
|
|
232
|
+
### Tone
|
|
233
|
+
|
|
234
|
+
- Be encouraging and helpful
|
|
235
|
+
- Explain technical concepts simply
|
|
236
|
+
- Celebrate progress ("Great choice!", "Almost there!")
|
|
237
|
+
- Don't overwhelm with information
|
|
238
|
+
|
|
239
|
+
## Example Conversation
|
|
240
|
+
|
|
241
|
+
**User:** Help me migrate to OpenSaaS Stack
|
|
242
|
+
|
|
243
|
+
**You:** I can see you have a {{PROJECT_TYPE}} project with {{MODEL_COUNT}} models. OpenSaaS Stack will give you:
|
|
244
|
+
|
|
245
|
+
- Automatic admin UI for managing your data
|
|
246
|
+
- Built-in access control to secure your API
|
|
247
|
+
- Type-safe database operations
|
|
248
|
+
|
|
249
|
+
Let me start the migration wizard to configure your project...
|
|
250
|
+
|
|
251
|
+
[Call opensaas_start_migration]
|
|
252
|
+
|
|
253
|
+
**User:** [answers questions]
|
|
254
|
+
|
|
255
|
+
**You:** [Continue through wizard, explain each choice, generate final config]
|
|
256
|
+
|
|
257
|
+
## Error Handling
|
|
258
|
+
|
|
259
|
+
If something goes wrong:
|
|
260
|
+
1. Explain what happened in simple terms
|
|
261
|
+
2. Suggest alternatives or manual steps
|
|
262
|
+
3. Link to documentation for more help
|
|
263
|
+
|
|
264
|
+
## After Migration
|
|
265
|
+
|
|
266
|
+
Once the config is generated, guide them through:
|
|
267
|
+
1. Installing dependencies
|
|
268
|
+
2. Running \`opensaas generate\`
|
|
269
|
+
3. Running \`prisma db push\`
|
|
270
|
+
4. Starting their dev server
|
|
271
|
+
5. Visiting the admin UI
|
|
272
|
+
`;
|
|
273
|
+
fs.writeFileSync(path.join(agentsDir, 'migration-assistant.md'), generateTemplateContent(agentTemplate, analysis));
|
|
274
|
+
// Create analyze-schema command
|
|
275
|
+
const analyzeSchemaTemplate = `Analyze the current project schema and provide a detailed breakdown.
|
|
276
|
+
|
|
277
|
+
## Instructions
|
|
278
|
+
|
|
279
|
+
1. Use \`opensaas_introspect_prisma\` or \`opensaas_introspect_keystone\` based on project type
|
|
280
|
+
2. Present the results in a clear, organized format
|
|
281
|
+
3. Highlight:
|
|
282
|
+
- All models and their fields
|
|
283
|
+
- Relationships between models
|
|
284
|
+
- Potential access control patterns
|
|
285
|
+
- Any issues or warnings
|
|
286
|
+
|
|
287
|
+
## Output Format
|
|
288
|
+
|
|
289
|
+
Present like this:
|
|
290
|
+
|
|
291
|
+
### Models Summary
|
|
292
|
+
|
|
293
|
+
| Model | Fields | Has Relations | Suggested Access |
|
|
294
|
+
|-------|--------|---------------|------------------|
|
|
295
|
+
| ... | ... | ... | ... |
|
|
296
|
+
|
|
297
|
+
### Detailed Analysis
|
|
298
|
+
|
|
299
|
+
[For each model, show fields and relationships]
|
|
300
|
+
|
|
301
|
+
### Recommendations
|
|
302
|
+
|
|
303
|
+
[Based on the schema, suggest access control patterns]
|
|
304
|
+
`;
|
|
305
|
+
fs.writeFileSync(path.join(commandsDir, 'analyze-schema.md'), analyzeSchemaTemplate);
|
|
306
|
+
// Create generate-config command
|
|
307
|
+
const generateConfigTemplate = `Generate the opensaas.config.ts file for this project.
|
|
308
|
+
|
|
309
|
+
## Instructions
|
|
310
|
+
|
|
311
|
+
1. If migration wizard hasn't been started, start it:
|
|
312
|
+
\`\`\`
|
|
313
|
+
opensaas_start_migration({ projectType: "{{PROJECT_TYPE_LOWER}}" })
|
|
314
|
+
\`\`\`
|
|
315
|
+
|
|
316
|
+
2. Guide the user through any remaining questions
|
|
317
|
+
|
|
318
|
+
3. When complete, display:
|
|
319
|
+
- The generated config file
|
|
320
|
+
- Dependencies to install
|
|
321
|
+
- Next steps to run
|
|
322
|
+
|
|
323
|
+
4. Offer to explain any part of the generated config
|
|
324
|
+
|
|
325
|
+
## Quick Mode
|
|
326
|
+
|
|
327
|
+
If the user wants defaults, use these answers:
|
|
328
|
+
- preserve_database: true
|
|
329
|
+
- db_provider: {{PROVIDER}}
|
|
330
|
+
- enable_auth: {{HAS_AUTH}}
|
|
331
|
+
- default_access: "public-read-auth-write"
|
|
332
|
+
- admin_base_path: "/admin"
|
|
333
|
+
`;
|
|
334
|
+
fs.writeFileSync(path.join(commandsDir, 'generate-config.md'), generateTemplateContent(generateConfigTemplate, analysis));
|
|
335
|
+
// Create validate-migration command
|
|
336
|
+
const validateMigrationTemplate = `Validate the generated opensaas.config.ts file.
|
|
337
|
+
|
|
338
|
+
## Instructions
|
|
339
|
+
|
|
340
|
+
1. Check if opensaas.config.ts exists in the project root
|
|
341
|
+
|
|
342
|
+
2. If it exists, verify:
|
|
343
|
+
- Syntax is valid TypeScript
|
|
344
|
+
- All imports are correct
|
|
345
|
+
- Database config is complete
|
|
346
|
+
- Lists match original schema
|
|
347
|
+
|
|
348
|
+
3. Try running:
|
|
349
|
+
\`\`\`bash
|
|
350
|
+
npx @opensaas/stack-cli generate
|
|
351
|
+
\`\`\`
|
|
352
|
+
|
|
353
|
+
4. Report any errors and suggest fixes
|
|
354
|
+
|
|
355
|
+
5. If validation passes, confirm next steps:
|
|
356
|
+
- \`npx prisma generate\`
|
|
357
|
+
- \`npx prisma db push\`
|
|
358
|
+
- \`pnpm dev\`
|
|
359
|
+
|
|
360
|
+
## Common Issues
|
|
361
|
+
|
|
362
|
+
- Missing dependencies → suggest \`pnpm add ...\`
|
|
363
|
+
- Database URL not set → remind about .env file
|
|
364
|
+
- Type errors → suggest specific fixes
|
|
365
|
+
`;
|
|
366
|
+
fs.writeFileSync(path.join(commandsDir, 'validate-migration.md'), validateMigrationTemplate);
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Main migrate command
|
|
370
|
+
*/
|
|
371
|
+
async function migrateCommand(options) {
|
|
372
|
+
const cwd = process.cwd();
|
|
373
|
+
console.log(chalk.bold.cyan('\n🚀 OpenSaaS Stack Migration\n'));
|
|
374
|
+
// Step 1: Detect project type
|
|
375
|
+
const spinner = ora('Detecting project type...').start();
|
|
376
|
+
let projectTypes;
|
|
377
|
+
if (options.type) {
|
|
378
|
+
projectTypes = [options.type];
|
|
379
|
+
}
|
|
380
|
+
else {
|
|
381
|
+
projectTypes = await detectProjectType(cwd);
|
|
382
|
+
}
|
|
383
|
+
if (projectTypes.length === 0) {
|
|
384
|
+
spinner.fail(chalk.red('No recognizable project found'));
|
|
385
|
+
console.log(chalk.dim('\nThis command works with:'));
|
|
386
|
+
console.log(chalk.dim(' - Prisma projects (prisma/schema.prisma)'));
|
|
387
|
+
console.log(chalk.dim(' - KeystoneJS projects (keystone.config.ts)'));
|
|
388
|
+
console.log(chalk.dim(' - Next.js projects (package.json with next)'));
|
|
389
|
+
console.log(chalk.dim('\nUse --type to force a project type.'));
|
|
390
|
+
process.exit(1);
|
|
391
|
+
}
|
|
392
|
+
spinner.succeed(chalk.green(`Detected: ${projectTypes.join(', ')}`));
|
|
393
|
+
// Step 2: Analyze schema
|
|
394
|
+
const analysisSpinner = ora('Analyzing schema...').start();
|
|
395
|
+
const analysis = {
|
|
396
|
+
projectTypes,
|
|
397
|
+
cwd,
|
|
398
|
+
};
|
|
399
|
+
if (projectTypes.includes('prisma')) {
|
|
400
|
+
try {
|
|
401
|
+
const prismaAnalysis = await analyzePrismaSchema(cwd);
|
|
402
|
+
analysis.models = prismaAnalysis.models;
|
|
403
|
+
analysis.provider = prismaAnalysis.provider;
|
|
404
|
+
}
|
|
405
|
+
catch (_error) {
|
|
406
|
+
// Prisma analysis failed, continue without it
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
if (analysis.models && analysis.models.length > 0) {
|
|
410
|
+
analysisSpinner.succeed(chalk.green(`Found ${analysis.models.length} models`));
|
|
411
|
+
// Display model tree
|
|
412
|
+
const lastIndex = analysis.models.length - 1;
|
|
413
|
+
analysis.models.forEach((model, index) => {
|
|
414
|
+
const prefix = index === lastIndex ? '└─' : '├─';
|
|
415
|
+
console.log(chalk.dim(` ${prefix} ${model.name} (${model.fieldCount} fields)`));
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
else {
|
|
419
|
+
analysisSpinner.succeed(chalk.yellow('No models found (will create from scratch)'));
|
|
420
|
+
}
|
|
421
|
+
// Step 3: Setup Claude Code (if --with-ai)
|
|
422
|
+
if (options.withAi) {
|
|
423
|
+
const claudeSpinner = ora('Setting up Claude Code...').start();
|
|
424
|
+
try {
|
|
425
|
+
await setupClaudeCode(cwd, analysis);
|
|
426
|
+
claudeSpinner.succeed(chalk.green('Claude Code ready'));
|
|
427
|
+
console.log(chalk.dim(' ├─ Created .claude directory'));
|
|
428
|
+
console.log(chalk.dim(' ├─ Generated migration assistant'));
|
|
429
|
+
console.log(chalk.dim(' └─ Registered MCP server'));
|
|
430
|
+
}
|
|
431
|
+
catch (error) {
|
|
432
|
+
claudeSpinner.fail(chalk.red('Failed to setup Claude Code'));
|
|
433
|
+
console.error(error);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
// Step 4: Display next steps
|
|
437
|
+
console.log(chalk.green('\n✅ Analysis complete!\n'));
|
|
438
|
+
if (options.withAi) {
|
|
439
|
+
console.log(chalk.bold('🤖 Next Steps:\n'));
|
|
440
|
+
console.log(chalk.cyan(' 1. Open this project in Claude Code'));
|
|
441
|
+
console.log(chalk.cyan(' 2. Ask: "Help me migrate to OpenSaaS Stack"'));
|
|
442
|
+
console.log(chalk.cyan(' 3. Follow the interactive wizard'));
|
|
443
|
+
}
|
|
444
|
+
else {
|
|
445
|
+
console.log(chalk.bold('📝 Next Steps:\n'));
|
|
446
|
+
console.log(chalk.cyan(' 1. Run with --with-ai for AI-guided migration'));
|
|
447
|
+
console.log(chalk.cyan(' 2. Or manually create opensaas.config.ts'));
|
|
448
|
+
console.log(chalk.dim('\n See: https://stack.opensaas.au/guides/migration'));
|
|
449
|
+
}
|
|
450
|
+
console.log(chalk.dim(`\n📚 Documentation: https://stack.opensaas.au/guides/migration\n`));
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Create the migrate command for Commander
|
|
454
|
+
*/
|
|
455
|
+
export function createMigrateCommand() {
|
|
456
|
+
const migrate = new Command('migrate');
|
|
457
|
+
migrate.description('Migrate an existing project to OpenSaaS Stack');
|
|
458
|
+
migrate
|
|
459
|
+
.option('--with-ai', 'Enable AI-guided migration with Claude Code')
|
|
460
|
+
.option('--type <type>', 'Force project type (prisma, nextjs, keystone)')
|
|
461
|
+
.action(async (options) => {
|
|
462
|
+
try {
|
|
463
|
+
await migrateCommand(options);
|
|
464
|
+
process.exit(0);
|
|
465
|
+
}
|
|
466
|
+
catch (error) {
|
|
467
|
+
console.error(chalk.red('\n❌ Migration failed:'), error);
|
|
468
|
+
process.exit(1);
|
|
469
|
+
}
|
|
470
|
+
});
|
|
471
|
+
return migrate;
|
|
472
|
+
}
|
|
473
|
+
//# sourceMappingURL=migrate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate.js","sourceRoot":"","sources":["../../src/commands/migrate.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,GAAG,MAAM,KAAK,CAAA;AAQrB;;GAEG;AACH,KAAK,UAAU,iBAAiB,CAAC,GAAW;IAC1C,MAAM,KAAK,GAAkB,EAAE,CAAA;IAE/B,mBAAmB;IACnB,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,eAAe,CAAC,CAAA;IAClE,IAAI,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE,CAAC;QACpC,KAAK,CAAC,IAAI,CAAC,QAAQ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A;QACjB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,uBAAuB,CAAC,EAAE,KAAK,CAAC,CAAA;YACxD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACjB,CAAC;IACH,CAAC,CAAC,CAAA;IAEJ,OAAO,OAAO,CAAA;AAChB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { generateCommand } from './commands/generate.js';
|
|
|
4
4
|
import { initCommand } from './commands/init.js';
|
|
5
5
|
import { devCommand } from './commands/dev.js';
|
|
6
6
|
import { createMCPCommand } from './commands/mcp.js';
|
|
7
|
+
import { createMigrateCommand } from './commands/migrate.js';
|
|
7
8
|
const program = new Command();
|
|
8
9
|
program.name('opensaas').description('OpenSaas Stack CLI').version('0.1.0');
|
|
9
10
|
program
|
|
@@ -33,5 +34,7 @@ program
|
|
|
33
34
|
});
|
|
34
35
|
// Add MCP command group
|
|
35
36
|
program.addCommand(createMCPCommand());
|
|
37
|
+
// Add migrate command
|
|
38
|
+
program.addCommand(createMigrateCommand());
|
|
36
39
|
program.parse();
|
|
37
40
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,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;AAEJ,wBAAwB;AACxB,OAAO,CAAC,UAAU,CAAC,gBAAgB,EAAE,CAAC,CAAA;AAEtC,sBAAsB;AACtB,OAAO,CAAC,UAAU,CAAC,oBAAoB,EAAE,CAAC,CAAA;AAE1C,OAAO,CAAC,KAAK,EAAE,CAAA"}
|
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
* Documentation provider - Fetches documentation from the hosted docs site
|
|
3
3
|
*/
|
|
4
4
|
import type { DocumentationLookup } from './types.js';
|
|
5
|
+
interface LocalDocResult {
|
|
6
|
+
content: string;
|
|
7
|
+
files: string[];
|
|
8
|
+
}
|
|
9
|
+
interface ExampleConfig {
|
|
10
|
+
description: string;
|
|
11
|
+
code: string;
|
|
12
|
+
notes?: string;
|
|
13
|
+
sourcePath: string;
|
|
14
|
+
}
|
|
5
15
|
export declare class OpenSaasDocumentationProvider {
|
|
6
16
|
private readonly DOCS_API;
|
|
7
17
|
private cache;
|
|
@@ -31,6 +41,18 @@ export declare class OpenSaasDocumentationProvider {
|
|
|
31
41
|
* Fallback documentation when API is unavailable
|
|
32
42
|
*/
|
|
33
43
|
private getFallbackDocs;
|
|
44
|
+
/**
|
|
45
|
+
* Search local CLAUDE.md files in the monorepo
|
|
46
|
+
*/
|
|
47
|
+
searchLocalDocs(query: string): Promise<LocalDocResult>;
|
|
48
|
+
/**
|
|
49
|
+
* Get example config code for a feature
|
|
50
|
+
*/
|
|
51
|
+
getExampleConfig(feature: string): Promise<ExampleConfig | null>;
|
|
52
|
+
/**
|
|
53
|
+
* Get migration-specific documentation for a project type
|
|
54
|
+
*/
|
|
55
|
+
findMigrationGuide(projectType: string): Promise<string>;
|
|
34
56
|
/**
|
|
35
57
|
* Clear expired cache entries
|
|
36
58
|
*/
|
|
@@ -40,4 +62,5 @@ export declare class OpenSaasDocumentationProvider {
|
|
|
40
62
|
*/
|
|
41
63
|
clearCache(): void;
|
|
42
64
|
}
|
|
65
|
+
export {};
|
|
43
66
|
//# sourceMappingURL=documentation-provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documentation-provider.d.ts","sourceRoot":"","sources":["../../../src/mcp/lib/documentation-provider.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"documentation-provider.d.ts","sourceRoot":"","sources":["../../../src/mcp/lib/documentation-provider.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAkBrD,UAAU,cAAc;IACtB,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,EAAE,CAAA;CAChB;AAED,UAAU,aAAa;IACrB,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,qBAAa,6BAA6B;IACxC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAyC;IAClE,OAAO,CAAC,KAAK,CAAsE;IACnF,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAiB;IAG3C,OAAO,CAAC,aAAa,CA4BpB;IAED;;OAEG;IACG,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,SAAI,EAAE,QAAQ,SAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IA0CxF;;OAEG;IACG,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAO/D;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAgB3B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAc3B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAY5B;;OAEG;IACH,OAAO,CAAC,eAAe;IAiBvB;;OAEG;IACG,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAsF7D;;OAEG;IACG,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa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