@abeedoo/radish-schemas 1.7.7
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/README.md +317 -0
- package/index.js +38 -0
- package/package.json +51 -0
- package/prompts/index.js +118 -0
- package/prompts/radish-app-generation.md +259 -0
- package/prompts/radish-components-generation.md +138 -0
- package/prompts/radish-roles-generation.md +133 -0
- package/prompts/radish-schema-generation.md +267 -0
- package/prompts/radish-theme-generation.md +138 -0
- package/prompts/radish-types-generation.md +294 -0
- package/prompts/radish-ui-generation.md +227 -0
- package/schemas/app.schema.json +289 -0
- package/schemas/components.schema.json +199 -0
- package/schemas/index.js +49 -0
- package/schemas/roles.schema.json +64 -0
- package/schemas/theme.schema.json +196 -0
- package/schemas/types.schema.json +761 -0
- package/schemas/ui.schema.json +346 -0
- package/validators/index.js +175 -0
package/README.md
ADDED
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
# @radish/schemas
|
|
2
|
+
|
|
3
|
+
Shared JSON schemas, validators, and AI prompts for the Radish CLI ecosystem.
|
|
4
|
+
|
|
5
|
+
**All blueprints use JSON as the source of truth.** YAML rendering is available as a display utility.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @radish/schemas
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
For GitLab private registry:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm config set @radish:registry https://your-gitlab.com/api/v4/projects/PROJECT_ID/packages/npm/
|
|
17
|
+
npm install @radish/schemas
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
### Validating Blueprints
|
|
23
|
+
|
|
24
|
+
```javascript
|
|
25
|
+
import { validateBlueprint, formatValidationErrors } from '@radish/schemas';
|
|
26
|
+
import { readFileSync } from 'fs';
|
|
27
|
+
|
|
28
|
+
const blueprint = JSON.parse(readFileSync('types.json', 'utf8'));
|
|
29
|
+
|
|
30
|
+
const result = validateBlueprint(blueprint, 'types');
|
|
31
|
+
|
|
32
|
+
if (result.valid) {
|
|
33
|
+
console.log('Blueprint is valid');
|
|
34
|
+
} else {
|
|
35
|
+
console.error(formatValidationErrors(result.errors));
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Validating from Raw JSON Strings
|
|
40
|
+
|
|
41
|
+
```javascript
|
|
42
|
+
import { validateFromJSON } from '@radish/schemas';
|
|
43
|
+
|
|
44
|
+
// Parse and validate in one step - useful for AI-generated output
|
|
45
|
+
const result = validateFromJSON(aiResponseString, 'app');
|
|
46
|
+
|
|
47
|
+
if (result.valid) {
|
|
48
|
+
console.log('Valid!', result.data); // Parsed object available
|
|
49
|
+
} else {
|
|
50
|
+
console.error(result.errors); // Includes JSON parse errors
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### YAML Display
|
|
55
|
+
|
|
56
|
+
```javascript
|
|
57
|
+
import { toYAML } from '@radish/schemas';
|
|
58
|
+
|
|
59
|
+
const blueprint = JSON.parse(readFileSync('app.json', 'utf8'));
|
|
60
|
+
const yamlView = toYAML(blueprint);
|
|
61
|
+
console.log(yamlView);
|
|
62
|
+
// version: 1
|
|
63
|
+
// app:
|
|
64
|
+
// name: MyApp
|
|
65
|
+
// description: My application
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Getting Schemas
|
|
69
|
+
|
|
70
|
+
```javascript
|
|
71
|
+
import { getSchemas, typesSchema, rolesSchema, appSchema } from '@radish/schemas';
|
|
72
|
+
|
|
73
|
+
// Get all schemas
|
|
74
|
+
const schemas = getSchemas();
|
|
75
|
+
|
|
76
|
+
// Or import directly
|
|
77
|
+
console.log(typesSchema);
|
|
78
|
+
console.log(rolesSchema);
|
|
79
|
+
console.log(appSchema);
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### AI Prompts
|
|
83
|
+
|
|
84
|
+
```javascript
|
|
85
|
+
import { buildPrompt } from '@radish/schemas/prompts';
|
|
86
|
+
|
|
87
|
+
// Build a prompt for app blueprint generation
|
|
88
|
+
const appPrompt = buildPrompt('app', 'A blog with posts and comments');
|
|
89
|
+
|
|
90
|
+
// Build a prompt for types/roles generation
|
|
91
|
+
const typesPrompt = buildPrompt('types', 'A blog with posts and comments');
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Package Structure
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
@radish/schemas/
|
|
98
|
+
├── schemas/ # JSON Schema files
|
|
99
|
+
│ ├── types.schema.json # Data layer entities/fields
|
|
100
|
+
│ ├── roles.schema.json # Roles and permissions
|
|
101
|
+
│ └── app.schema.json # Application blueprint
|
|
102
|
+
├── validators/ # Validation utilities
|
|
103
|
+
│ └── index.js
|
|
104
|
+
├── prompts/ # AI prompt templates
|
|
105
|
+
│ ├── radish-schema-generation.md # Types/roles generation
|
|
106
|
+
│ └── radish-app-generation.md # App blueprint generation
|
|
107
|
+
└── index.js # Main exports
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Blueprint Types
|
|
111
|
+
|
|
112
|
+
### types.json
|
|
113
|
+
Data layer entity definitions - fields, relationships, indexes, filters.
|
|
114
|
+
|
|
115
|
+
### roles.json
|
|
116
|
+
Role and permission definitions for access control.
|
|
117
|
+
|
|
118
|
+
### app.json
|
|
119
|
+
Application-level blueprint (master document) including:
|
|
120
|
+
- **app** - Name, description, domain, tags
|
|
121
|
+
- **audience** - User personas (primary, secondary, admin)
|
|
122
|
+
- **workflows** - Core user journeys with actors
|
|
123
|
+
- **categories** - Content taxonomy
|
|
124
|
+
- **style** - Branding and UI hints
|
|
125
|
+
- **features** - Feature flags (auth, roles, api, search, etc.)
|
|
126
|
+
- **entityOverview** - High-level entity descriptions grouped by domain concern
|
|
127
|
+
- **accessPatterns** - Who can do what, by access level
|
|
128
|
+
- **database** - Database configuration
|
|
129
|
+
|
|
130
|
+
## Version Compatibility
|
|
131
|
+
|
|
132
|
+
### Current Version
|
|
133
|
+
|
|
134
|
+
- **Package Version:** `@radish/schemas@1.4.0`
|
|
135
|
+
- **Blueprint Spec Version:** `1`
|
|
136
|
+
- **Minimum CLI Version:** `radish-cli@0.1.0`
|
|
137
|
+
|
|
138
|
+
### Compatibility Policy
|
|
139
|
+
|
|
140
|
+
`@radish/schemas` follows semantic versioning with special consideration for blueprint compatibility:
|
|
141
|
+
|
|
142
|
+
- **Major version bumps** (e.g., 1.x → 2.x) indicate **breaking changes to blueprint format**
|
|
143
|
+
- **Minor version bumps** (e.g., 1.0 → 1.1) add **backward-compatible features**
|
|
144
|
+
- **Patch version bumps** (e.g., 1.0.0 → 1.0.1) include **bug fixes and improvements**
|
|
145
|
+
|
|
146
|
+
For detailed versioning strategy, see [VERSIONING-STRATEGY.md](./VERSIONING-STRATEGY.md).
|
|
147
|
+
|
|
148
|
+
### Using VERSIONING Metadata
|
|
149
|
+
|
|
150
|
+
```javascript
|
|
151
|
+
import { VERSIONING } from '@radish/schemas';
|
|
152
|
+
|
|
153
|
+
console.log(VERSIONING.packageVersion); // "1.4.0"
|
|
154
|
+
console.log(VERSIONING.currentSpecVersion); // 1
|
|
155
|
+
console.log(VERSIONING.supportedSpecVersions); // [1]
|
|
156
|
+
console.log(VERSIONING.minCliVersion); // "0.1.0"
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## API Reference
|
|
160
|
+
|
|
161
|
+
### Validators
|
|
162
|
+
|
|
163
|
+
#### `validateBlueprint(data, type)`
|
|
164
|
+
|
|
165
|
+
Validates a parsed object against a schema.
|
|
166
|
+
|
|
167
|
+
- **Parameters:**
|
|
168
|
+
- `data` (object): Parsed JSON data
|
|
169
|
+
- `type` ('types' | 'roles' | 'app'): Schema type
|
|
170
|
+
- **Returns:** `{ valid: boolean, errors: Array }`
|
|
171
|
+
|
|
172
|
+
#### `validateFromJSON(jsonString, type)`
|
|
173
|
+
|
|
174
|
+
Parses a JSON string and validates against a schema.
|
|
175
|
+
|
|
176
|
+
- **Parameters:**
|
|
177
|
+
- `jsonString` (string): Raw JSON string
|
|
178
|
+
- `type` ('types' | 'roles' | 'app'): Schema type
|
|
179
|
+
- **Returns:** `{ valid: boolean, errors: Array, data: object|null }`
|
|
180
|
+
|
|
181
|
+
#### `toYAML(data)`
|
|
182
|
+
|
|
183
|
+
Converts a blueprint object to YAML string for display purposes.
|
|
184
|
+
|
|
185
|
+
- **Parameters:**
|
|
186
|
+
- `data` (object): Blueprint data
|
|
187
|
+
- **Returns:** `string` - YAML-formatted string
|
|
188
|
+
|
|
189
|
+
#### `formatValidationErrors(errors)`
|
|
190
|
+
|
|
191
|
+
Formats AJV errors for display.
|
|
192
|
+
|
|
193
|
+
- **Parameters:**
|
|
194
|
+
- `errors` (Array): AJV validation errors
|
|
195
|
+
- **Returns:** `string` - Formatted error message
|
|
196
|
+
|
|
197
|
+
#### `getSchemas()`
|
|
198
|
+
|
|
199
|
+
Gets all schemas.
|
|
200
|
+
|
|
201
|
+
- **Returns:** `{ types: object, roles: object, app: object }`
|
|
202
|
+
|
|
203
|
+
### Prompts
|
|
204
|
+
|
|
205
|
+
#### `getSchemaPrompt()`
|
|
206
|
+
|
|
207
|
+
Gets the AI prompt template for types/roles generation.
|
|
208
|
+
|
|
209
|
+
- **Returns:** `string` - Prompt markdown
|
|
210
|
+
|
|
211
|
+
#### `getAppPrompt()`
|
|
212
|
+
|
|
213
|
+
Gets the AI prompt template for app blueprint generation.
|
|
214
|
+
|
|
215
|
+
- **Returns:** `string` - Prompt markdown
|
|
216
|
+
|
|
217
|
+
#### `buildPrompt(promptType, description)`
|
|
218
|
+
|
|
219
|
+
Builds a complete prompt with user description injected.
|
|
220
|
+
|
|
221
|
+
- **Parameters:**
|
|
222
|
+
- `promptType` ('app' | 'types' | 'roles'): Blueprint type to generate
|
|
223
|
+
- `description` (string): User's app description
|
|
224
|
+
- **Returns:** `string` - Complete prompt
|
|
225
|
+
|
|
226
|
+
#### `getSchemaForPrompt(type)`
|
|
227
|
+
|
|
228
|
+
Gets a schema as a JSON string for inclusion in prompts.
|
|
229
|
+
|
|
230
|
+
- **Parameters:**
|
|
231
|
+
- `type` ('types' | 'roles' | 'app'): Schema type
|
|
232
|
+
- **Returns:** `string` - Stringified JSON schema
|
|
233
|
+
|
|
234
|
+
## Validation Service
|
|
235
|
+
|
|
236
|
+
This package includes a standalone Fastify validation service deployed at `https://schemas.radishplatform.com`.
|
|
237
|
+
|
|
238
|
+
All Radish tools (wizard, n8n workflows, CLI) use this service as the single source of truth for validation.
|
|
239
|
+
|
|
240
|
+
### Live URL
|
|
241
|
+
|
|
242
|
+
`https://schemas.radishplatform.com`
|
|
243
|
+
|
|
244
|
+
### Running Locally
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
npm start
|
|
248
|
+
# Server starts on http://localhost:3000
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### Endpoints
|
|
252
|
+
|
|
253
|
+
#### `GET /health`
|
|
254
|
+
Returns service status and version info.
|
|
255
|
+
```bash
|
|
256
|
+
curl https://schemas.radishplatform.com/health
|
|
257
|
+
```
|
|
258
|
+
Returns: `{ "status": "ok", "version": "1.4.0", "specVersion": 1, "supportedSpecVersions": [1] }`
|
|
259
|
+
|
|
260
|
+
#### `POST /validate`
|
|
261
|
+
Validates a parsed JSON object.
|
|
262
|
+
```bash
|
|
263
|
+
curl -X POST https://schemas.radishplatform.com/validate \
|
|
264
|
+
-H "Content-Type: application/json" \
|
|
265
|
+
-d '{"type": "app", "data": {"version": 1, "app": {"name": "Test", "description": "A test"}}}'
|
|
266
|
+
```
|
|
267
|
+
Returns: `{ "valid": true|false, "errors": [...], "data": {...}, "formatted": "..." }`
|
|
268
|
+
|
|
269
|
+
#### `POST /validate/json`
|
|
270
|
+
Parses a raw JSON string and validates (ideal for AI output).
|
|
271
|
+
```bash
|
|
272
|
+
curl -X POST https://schemas.radishplatform.com/validate/json \
|
|
273
|
+
-H "Content-Type: application/json" \
|
|
274
|
+
-d '{"type": "types", "json": "{\"version\":1,\"entities\":{...}}"}'
|
|
275
|
+
```
|
|
276
|
+
Returns: `{ "valid": true|false, "errors": [...], "data": {...}, "formatted": "..." }`
|
|
277
|
+
|
|
278
|
+
#### `GET /schemas/:type`
|
|
279
|
+
Returns the raw JSON schema for `app`, `types`, or `roles`.
|
|
280
|
+
```bash
|
|
281
|
+
curl https://schemas.radishplatform.com/schemas/app
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
#### `POST /prompts/:type`
|
|
285
|
+
Returns an AI prompt with user description injected. Types: `app`, `types`, `roles`.
|
|
286
|
+
```bash
|
|
287
|
+
curl -X POST https://schemas.radishplatform.com/prompts/app \
|
|
288
|
+
-H "Content-Type: application/json" \
|
|
289
|
+
-d '{"description": "A blog with posts and comments"}'
|
|
290
|
+
```
|
|
291
|
+
Returns: `{ "prompt": "..." }`
|
|
292
|
+
|
|
293
|
+
#### `GET /prompts/:type`
|
|
294
|
+
Returns the raw prompt template (with `{{USER_DESCRIPTION}}` placeholder).
|
|
295
|
+
```bash
|
|
296
|
+
curl https://schemas.radishplatform.com/prompts/types
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
#### `POST /to-yaml`
|
|
300
|
+
Converts a JSON object to YAML for display.
|
|
301
|
+
```bash
|
|
302
|
+
curl -X POST https://schemas.radishplatform.com/to-yaml \
|
|
303
|
+
-H "Content-Type: application/json" \
|
|
304
|
+
-d '{"version": 1, "app": {"name": "Blog", "description": "A blog"}}'
|
|
305
|
+
```
|
|
306
|
+
Returns: `{ "yaml": "..." }`
|
|
307
|
+
|
|
308
|
+
### Docker Deployment
|
|
309
|
+
|
|
310
|
+
```bash
|
|
311
|
+
docker build -t radish-schemas .
|
|
312
|
+
docker run -p 3000:3000 radish-schemas
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
## License
|
|
316
|
+
|
|
317
|
+
MIT
|
package/index.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// Main entry point for @radish/schemas
|
|
2
|
+
export { typesSchema, rolesSchema, appSchema, uiSchema, componentsSchema, themeSchema, getSchema } from './schemas/index.js';
|
|
3
|
+
export {
|
|
4
|
+
validateBlueprint,
|
|
5
|
+
validateFromJSON,
|
|
6
|
+
toYAML,
|
|
7
|
+
getSchemas,
|
|
8
|
+
formatValidationErrors,
|
|
9
|
+
validators
|
|
10
|
+
} from './validators/index.js';
|
|
11
|
+
export {
|
|
12
|
+
getTypesPrompt,
|
|
13
|
+
getRolesPrompt,
|
|
14
|
+
getAppPrompt,
|
|
15
|
+
getUiPrompt,
|
|
16
|
+
getComponentsPrompt,
|
|
17
|
+
getThemePrompt,
|
|
18
|
+
getSchemaPrompt, // deprecated: use getTypesPrompt/getRolesPrompt
|
|
19
|
+
buildPrompt,
|
|
20
|
+
getSchemaForPrompt
|
|
21
|
+
} from './prompts/index.js';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Version metadata for @radish/schemas
|
|
25
|
+
*
|
|
26
|
+
* This provides compatibility information for tools and CLIs that depend on this package.
|
|
27
|
+
*
|
|
28
|
+
* @property {string} packageVersion - The npm package version (from package.json)
|
|
29
|
+
* @property {number} currentSpecVersion - The current blueprint format version
|
|
30
|
+
* @property {number[]} supportedSpecVersions - All blueprint format versions supported by this package
|
|
31
|
+
* @property {string} minCliVersion - Minimum radish-cli version compatible with this package
|
|
32
|
+
*/
|
|
33
|
+
export const VERSIONING = {
|
|
34
|
+
packageVersion: '1.7.7',
|
|
35
|
+
currentSpecVersion: 1,
|
|
36
|
+
supportedSpecVersions: [1],
|
|
37
|
+
minCliVersion: '0.1.0'
|
|
38
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@abeedoo/radish-schemas",
|
|
3
|
+
"version": "1.7.7",
|
|
4
|
+
"description": "Shared JSON schemas, validators, and prompts for Radish CLI ecosystem",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./index.js",
|
|
9
|
+
"./schemas": "./schemas/index.js",
|
|
10
|
+
"./validators": "./validators/index.js",
|
|
11
|
+
"./prompts": "./prompts/index.js",
|
|
12
|
+
"./schemas/types.schema.json": "./schemas/types.schema.json",
|
|
13
|
+
"./schemas/roles.schema.json": "./schemas/roles.schema.json",
|
|
14
|
+
"./schemas/app.schema.json": "./schemas/app.schema.json",
|
|
15
|
+
"./schemas/ui.schema.json": "./schemas/ui.schema.json",
|
|
16
|
+
"./schemas/components.schema.json": "./schemas/components.schema.json",
|
|
17
|
+
"./schemas/theme.schema.json": "./schemas/theme.schema.json"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"schemas/",
|
|
21
|
+
"validators/",
|
|
22
|
+
"prompts/",
|
|
23
|
+
"types/",
|
|
24
|
+
"index.js",
|
|
25
|
+
"README.md"
|
|
26
|
+
],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"test": "node test.js",
|
|
29
|
+
"start": "node server/index.js",
|
|
30
|
+
"prepublishOnly": "echo 'Running pre-publish checks...'"
|
|
31
|
+
},
|
|
32
|
+
"keywords": [
|
|
33
|
+
"radish",
|
|
34
|
+
"schema",
|
|
35
|
+
"validation",
|
|
36
|
+
"blueprints"
|
|
37
|
+
],
|
|
38
|
+
"author": "Radish CLI",
|
|
39
|
+
"license": "MIT",
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=18"
|
|
42
|
+
},
|
|
43
|
+
"sideEffects": false,
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"ajv": "^8.12.0",
|
|
46
|
+
"ajv-formats": "^2.1.1"
|
|
47
|
+
},
|
|
48
|
+
"publishConfig": {
|
|
49
|
+
"access": "public"
|
|
50
|
+
}
|
|
51
|
+
}
|
package/prompts/index.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { readFileSync } from 'fs';
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
3
|
+
import { dirname, join } from 'path';
|
|
4
|
+
import { getSchema } from '../schemas/index.js';
|
|
5
|
+
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = dirname(__filename);
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Get the AI types blueprint generation prompt
|
|
11
|
+
* @returns {string} Prompt markdown content
|
|
12
|
+
*/
|
|
13
|
+
export function getTypesPrompt() {
|
|
14
|
+
return readFileSync(
|
|
15
|
+
join(__dirname, 'radish-types-generation.md'),
|
|
16
|
+
'utf-8'
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Get the AI roles blueprint generation prompt
|
|
22
|
+
* @returns {string} Prompt markdown content
|
|
23
|
+
*/
|
|
24
|
+
export function getRolesPrompt() {
|
|
25
|
+
return readFileSync(
|
|
26
|
+
join(__dirname, 'radish-roles-generation.md'),
|
|
27
|
+
'utf-8'
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Get the AI UI blueprint generation prompt
|
|
33
|
+
* @returns {string} Prompt markdown content
|
|
34
|
+
*/
|
|
35
|
+
export function getUiPrompt() {
|
|
36
|
+
return readFileSync(
|
|
37
|
+
join(__dirname, 'radish-ui-generation.md'),
|
|
38
|
+
'utf-8'
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Get the AI components blueprint generation prompt
|
|
44
|
+
* @returns {string} Prompt markdown content
|
|
45
|
+
*/
|
|
46
|
+
export function getComponentsPrompt() {
|
|
47
|
+
return readFileSync(
|
|
48
|
+
join(__dirname, 'radish-components-generation.md'),
|
|
49
|
+
'utf-8'
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Get the AI theme blueprint generation prompt
|
|
55
|
+
* @returns {string} Prompt markdown content
|
|
56
|
+
*/
|
|
57
|
+
export function getThemePrompt() {
|
|
58
|
+
return readFileSync(
|
|
59
|
+
join(__dirname, 'radish-theme-generation.md'),
|
|
60
|
+
'utf-8'
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Get the AI app blueprint generation prompt
|
|
66
|
+
* @returns {string} Prompt markdown content
|
|
67
|
+
*/
|
|
68
|
+
export function getAppPrompt() {
|
|
69
|
+
return readFileSync(
|
|
70
|
+
join(__dirname, 'radish-app-generation.md'),
|
|
71
|
+
'utf-8'
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* @deprecated Use getTypesPrompt() or getRolesPrompt() instead.
|
|
77
|
+
* Returns the combined types+roles prompt for backward compatibility.
|
|
78
|
+
* @returns {string} Prompt markdown content
|
|
79
|
+
*/
|
|
80
|
+
export function getSchemaPrompt() {
|
|
81
|
+
return readFileSync(
|
|
82
|
+
join(__dirname, 'radish-schema-generation.md'),
|
|
83
|
+
'utf-8'
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Build a complete prompt with user description injected
|
|
89
|
+
* @param {'app' | 'types' | 'roles' | 'ui' | 'components' | 'theme'} promptType - Blueprint type to generate
|
|
90
|
+
* @param {string} description - User's app description
|
|
91
|
+
* @returns {string} Complete prompt with description injected
|
|
92
|
+
*/
|
|
93
|
+
export function buildPrompt(promptType, description) {
|
|
94
|
+
const prompts = {
|
|
95
|
+
app: getAppPrompt,
|
|
96
|
+
types: getTypesPrompt,
|
|
97
|
+
roles: getRolesPrompt,
|
|
98
|
+
ui: getUiPrompt,
|
|
99
|
+
components: getComponentsPrompt,
|
|
100
|
+
theme: getThemePrompt
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const getPrompt = prompts[promptType];
|
|
104
|
+
if (!getPrompt) {
|
|
105
|
+
throw new Error(`Unknown prompt type: ${promptType}. Available: ${Object.keys(prompts).join(', ')}`);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return getPrompt().replace('{{USER_DESCRIPTION}}', description);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Get schema JSON for inclusion in prompts
|
|
113
|
+
* @param {'types' | 'roles' | 'app'} type - Schema type
|
|
114
|
+
* @returns {string} Stringified JSON schema
|
|
115
|
+
*/
|
|
116
|
+
export function getSchemaForPrompt(type) {
|
|
117
|
+
return JSON.stringify(getSchema(type), null, 2);
|
|
118
|
+
}
|