specpilot 2.10.0 → 2.12.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 (52) hide show
  1. package/README.md +11 -8
  2. package/dist/__tests__/fixtures/allFields.d.ts +3 -0
  3. package/dist/__tests__/fixtures/allFields.d.ts.map +1 -0
  4. package/dist/__tests__/fixtures/allFields.js +31 -0
  5. package/dist/__tests__/fixtures/allFields.js.map +1 -0
  6. package/dist/commands/serve.js +2 -2
  7. package/dist/commands/serve.js.map +1 -1
  8. package/dist/core/chatFlow.d.ts +420 -0
  9. package/dist/core/chatFlow.d.ts.map +1 -0
  10. package/dist/core/chatFlow.js +1107 -0
  11. package/dist/core/chatFlow.js.map +1 -0
  12. package/dist/core/specFiles.js +21 -21
  13. package/dist/core/templateEngine.d.ts.map +1 -1
  14. package/dist/core/templateEngine.js +15 -4
  15. package/dist/core/templateEngine.js.map +1 -1
  16. package/dist/utils/addSpecsQuestions.d.ts +2 -1
  17. package/dist/utils/addSpecsQuestions.d.ts.map +1 -1
  18. package/dist/utils/addSpecsQuestions.js +2 -1
  19. package/dist/utils/addSpecsQuestions.js.map +1 -1
  20. package/dist/utils/initQuestions.d.ts +2 -1
  21. package/dist/utils/initQuestions.d.ts.map +1 -1
  22. package/dist/utils/initQuestions.js +2 -1
  23. package/dist/utils/initQuestions.js.map +1 -1
  24. package/dist/utils/slashCommandGenerator.d.ts +7 -1
  25. package/dist/utils/slashCommandGenerator.d.ts.map +1 -1
  26. package/dist/utils/slashCommandGenerator.js +95 -28
  27. package/dist/utils/slashCommandGenerator.js.map +1 -1
  28. package/dist/utils/specBackfiller.d.ts +1 -1
  29. package/dist/utils/specBackfiller.d.ts.map +1 -1
  30. package/dist/utils/specBackfiller.js.map +1 -1
  31. package/dist/utils/specReader.d.ts +4 -0
  32. package/dist/utils/specReader.d.ts.map +1 -1
  33. package/dist/utils/specReader.js +4 -4
  34. package/dist/utils/specReader.js.map +1 -1
  35. package/dist/utils/specServer.d.ts +31 -4
  36. package/dist/utils/specServer.d.ts.map +1 -1
  37. package/dist/utils/specServer.js +148 -16
  38. package/dist/utils/specServer.js.map +1 -1
  39. package/dist/utils/specSetup.d.ts +21 -4
  40. package/dist/utils/specSetup.d.ts.map +1 -1
  41. package/dist/utils/specSetup.js +113 -20
  42. package/dist/utils/specSetup.js.map +1 -1
  43. package/dist/utils/taskMover.d.ts +42 -0
  44. package/dist/utils/taskMover.d.ts.map +1 -1
  45. package/dist/utils/taskMover.js +177 -25
  46. package/dist/utils/taskMover.js.map +1 -1
  47. package/package.json +1 -1
  48. package/ui/OFL-Sixtyfour.txt +93 -0
  49. package/ui/app.css +59 -3
  50. package/ui/app.js +280 -59
  51. package/ui/index.html +33 -6
  52. package/ui/route.js +71 -8
@@ -0,0 +1,1107 @@
1
+ "use strict";
2
+ // The chat core (BL-PM-004b, REQ-002.I.7): what init.specpilot.dev's setup chat decides, ported from
3
+ // SpecPilot.Init/src/components/chat/flow.ts and flowOptions/*.ts (at 2c694db) with the same behaviour,
4
+ // plus what only `specpilot serve` needs. It imports nothing at all: the server also sends tsc's output of
5
+ // this file to the page as /assets/chat-core.js, so the page and the tests run the same functions.
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.FIELD_FILES = exports.MAX_LIST_ITEMS = exports.OPTIONAL_FIELD_LIMITS = exports.TODO = exports.CHAT_KEYS = exports.CHAT_STEPS = exports.CICD_OPTIONS = exports.TESTING_OPTIONS = exports.AI_ONLY_SECURITY_IDS = exports.SECURITY_CARDS = exports.AVAILABILITY_OPTIONS = exports.RESPONSE_TIME_OPTIONS = exports.COMPLIANCE_OPTIONS = exports.CONSTRAINT_OPTIONS = exports.INTEGRATION_CATEGORY_IDS = exports.INTEGRATION_CATEGORIES = exports.DATA_SYNC_STRATEGIES = exports.REALTIME_TYPES = exports.AUTH_OPTIONS = exports.DATABASES = exports.SYSTEM_PATTERNS = exports.getAuthBadge = exports.getDatabaseBadge = exports.TEAM_SIZES = exports.APPSTORE_DEPLOY_TARGETS = exports.REGISTRY_DEPLOY_TARGETS = exports.BAAS_DEPLOY_TARGET = exports.DEPLOY_TARGETS = exports.USER_RANGES = exports.TIMELINES = exports.SCALE_TIERS = exports.SPECIAL_OPTIONS = exports.ACCESS_OPTIONS = exports.USER_TYPE_GROUPS = exports.PLATFORM_LANGUAGE = exports.BAAS_BUNDLES = exports.BUNDLES_INCLUDE_FRONTEND = exports.PLATFORM_GROUPS = exports.STARTER_GROUPS = void 0;
8
+ exports.getCapabilities = getCapabilities;
9
+ exports.inferProjectCategory = inferProjectCategory;
10
+ exports.hasMobilePlatform = hasMobilePlatform;
11
+ exports.hasBaasPlatform = hasBaasPlatform;
12
+ exports.visiblePlatformGroups = visiblePlatformGroups;
13
+ exports.togglePlatform = togglePlatform;
14
+ exports.platformGridGroups = platformGridGroups;
15
+ exports.bundleLine = bundleLine;
16
+ exports.getPlatformNote = getPlatformNote;
17
+ exports.languageHints = languageHints;
18
+ exports.visibleUserTypeGroups = visibleUserTypeGroups;
19
+ exports.deployTargetOptions = deployTargetOptions;
20
+ exports.getArchBadge = getArchBadge;
21
+ exports.getApiBadge = getApiBadge;
22
+ exports.getDatabaseMismatch = getDatabaseMismatch;
23
+ exports.getLocalDatabaseOptions = getLocalDatabaseOptions;
24
+ exports.getDeployTargetMismatch = getDeployTargetMismatch;
25
+ exports.getRealtimeMismatch = getRealtimeMismatch;
26
+ exports.getActiveUsersMismatch = getActiveUsersMismatch;
27
+ exports.getTeamSizeMismatch = getTeamSizeMismatch;
28
+ exports.visibleCategories = visibleCategories;
29
+ exports.toggleIntegration = toggleIntegration;
30
+ exports.noneOfThese = noneOfThese;
31
+ exports.getComplianceBadge = getComplianceBadge;
32
+ exports.getCicdBadge = getCicdBadge;
33
+ exports.captionText = captionText;
34
+ exports.chatQuestions = chatQuestions;
35
+ exports.answerPatch = answerPatch;
36
+ exports.reseed = reseed;
37
+ exports.requestFields = requestFields;
38
+ const str = (a, k) => (typeof a[k] === 'string' ? a[k] : '');
39
+ const list = (a, k) => (Array.isArray(a[k]) ? a[k] : []);
40
+ const map = (a, k) => {
41
+ const v = a[k];
42
+ return v && typeof v === 'object' && !Array.isArray(v) ? v : {};
43
+ };
44
+ const OTHER = { hasServer: true, hasWebUI: true, hasMobileUI: true, hasGraphicalUI: true, distribution: 'hosting', audienceIsDevelopers: false };
45
+ const CAPABILITIES = {
46
+ saas: { hasServer: true, hasWebUI: true, hasMobileUI: true, hasGraphicalUI: true, distribution: 'hosting', audienceIsDevelopers: false },
47
+ api: { hasServer: true, hasWebUI: false, hasMobileUI: false, hasGraphicalUI: false, distribution: 'hosting', audienceIsDevelopers: true },
48
+ mobile: { hasServer: true, hasWebUI: false, hasMobileUI: true, hasGraphicalUI: true, distribution: 'hosting', audienceIsDevelopers: false },
49
+ cli: { hasServer: false, hasWebUI: false, hasMobileUI: false, hasGraphicalUI: false, distribution: 'registry', audienceIsDevelopers: true },
50
+ pipeline: { hasServer: true, hasWebUI: false, hasMobileUI: false, hasGraphicalUI: false, distribution: 'hosting', audienceIsDevelopers: true },
51
+ ml: { hasServer: true, hasWebUI: false, hasMobileUI: false, hasGraphicalUI: false, distribution: 'hosting', audienceIsDevelopers: true },
52
+ static: { hasServer: false, hasWebUI: true, hasMobileUI: false, hasGraphicalUI: true, distribution: 'hosting', audienceIsDevelopers: false },
53
+ docs: { hasServer: false, hasWebUI: true, hasMobileUI: false, hasGraphicalUI: true, distribution: 'hosting', audienceIsDevelopers: true },
54
+ extension: { hasServer: false, hasWebUI: false, hasMobileUI: false, hasGraphicalUI: true, distribution: 'appstore', audienceIsDevelopers: false },
55
+ library: { hasServer: false, hasWebUI: false, hasMobileUI: false, hasGraphicalUI: false, distribution: 'registry', audienceIsDevelopers: true },
56
+ other: OTHER,
57
+ };
58
+ /** No category (free text, or guided setup) falls back to 'other': show and allow everything. */
59
+ function getCapabilities(category) {
60
+ return category ? CAPABILITIES[category] : OTHER;
61
+ }
62
+ // ---------------------------------------------------------------- project description (projectOptions.ts)
63
+ exports.STARTER_GROUPS = [
64
+ {
65
+ group: 'APPS & PRODUCTS',
66
+ items: [
67
+ { emoji: '✅', label: 'Task / Project Manager' }, { emoji: '🛒', label: 'E-commerce Store' }, { emoji: '🤝', label: 'CRM System' },
68
+ { emoji: '🏥', label: 'Healthcare / Clinic App' }, { emoji: '📅', label: 'Booking / Scheduling' }, { emoji: '🎓', label: 'Learning Platform' },
69
+ { emoji: '💬', label: 'Social / Community App' }, { emoji: '📰', label: 'News / Blog / CMS' }, { emoji: '📊', label: 'Admin Dashboard' },
70
+ { emoji: '🤖', label: 'AI Chatbot / Assistant' }, { emoji: '🏬', label: 'Marketplace' }, { emoji: '💳', label: 'Subscription SaaS' },
71
+ ],
72
+ },
73
+ {
74
+ group: 'SIMPLER / COMMON',
75
+ items: [
76
+ { emoji: '🌐', label: 'Static Website' }, { emoji: '⚡', label: 'Single Page App (SPA)' }, { emoji: '🎯', label: 'Landing Page' },
77
+ { emoji: '🖼️', label: 'Portfolio Site' }, { emoji: '📚', label: 'Documentation Site' }, { emoji: '🏢', label: 'Company Intranet' },
78
+ { emoji: '🛠️', label: 'Internal Tool' }, { emoji: '🧩', label: 'Browser Extension' }, { emoji: '🧩', label: 'Chrome Extension' },
79
+ ],
80
+ },
81
+ {
82
+ group: 'DEVELOPER / DATA',
83
+ items: [
84
+ { emoji: '🔌', label: 'REST API / Backend' }, { emoji: '📡', label: 'GraphQL API' }, { emoji: '⌨️', label: 'CLI Tool' },
85
+ { emoji: '🔄', label: 'Data Pipeline' }, { emoji: '🧠', label: 'ML / AI Service' }, { emoji: '🪝', label: 'Webhook Service' },
86
+ { emoji: '🗂️', label: 'Monorepo / Library' }, { emoji: '📦', label: 'SDK / npm Package' },
87
+ ],
88
+ },
89
+ ];
90
+ const CATEGORY_BY_LABEL = {
91
+ 'Task / Project Manager': 'saas', 'E-commerce Store': 'saas', 'CRM System': 'saas', 'Healthcare / Clinic App': 'saas',
92
+ 'Booking / Scheduling': 'saas', 'Learning Platform': 'saas', 'Social / Community App': 'saas', 'News / Blog / CMS': 'saas',
93
+ 'Admin Dashboard': 'saas', 'AI Chatbot / Assistant': 'saas', Marketplace: 'saas', 'Subscription SaaS': 'saas',
94
+ 'Static Website': 'static', 'Single Page App (SPA)': 'saas', 'Landing Page': 'static', 'Portfolio Site': 'static',
95
+ 'Documentation Site': 'docs', 'Company Intranet': 'saas', 'Internal Tool': 'saas', 'Browser Extension': 'extension',
96
+ 'Chrome Extension': 'extension', 'REST API / Backend': 'api', 'GraphQL API': 'api', 'CLI Tool': 'cli', 'Data Pipeline': 'pipeline',
97
+ 'ML / AI Service': 'ml', 'Webhook Service': 'api', 'Monorepo / Library': 'library', 'SDK / npm Package': 'library',
98
+ };
99
+ /** Keyed on the exact starter-chip label; free text stays uncategorized (null). */
100
+ function inferProjectCategory(description) {
101
+ return CATEGORY_BY_LABEL[description] ?? null;
102
+ }
103
+ exports.PLATFORM_GROUPS = [
104
+ { group: 'MOBILE', emoji: '📱', items: [
105
+ { id: 'ios', label: 'iOS Native', lang: 'Swift' }, { id: 'android', label: 'Android Native', lang: 'Kotlin' },
106
+ { id: 'rn', label: 'React Native', lang: 'JS / TS' }, { id: 'flutter', label: 'Flutter', lang: 'Dart' },
107
+ { id: 'kmp', label: 'Kotlin Multiplatform', lang: 'Kotlin' },
108
+ ] },
109
+ { group: 'WEB FRONTEND', emoji: '🌐', items: [
110
+ { id: 'react', label: 'React', lang: 'TS / JS' }, { id: 'nextjs', label: 'Next.js', lang: 'TS / JS' },
111
+ { id: 'angular', label: 'Angular', lang: 'TS' }, { id: 'vue', label: 'Vue / Nuxt', lang: 'TS / JS' },
112
+ { id: 'svelte', label: 'SvelteKit', lang: 'TS / JS' },
113
+ ] },
114
+ { group: 'BACKEND', emoji: '⚙', items: [
115
+ { id: 'node', label: 'Node.js / Express', lang: 'TS / JS' }, { id: 'fastapi', label: 'FastAPI', lang: 'Python' },
116
+ { id: 'django', label: 'Django', lang: 'Python' }, { id: 'spring', label: 'Spring Boot', lang: 'Kotlin / Java' },
117
+ { id: 'dotnet', label: '.NET / ASP.NET', lang: 'C#' }, { id: 'laravel', label: 'Laravel', lang: 'PHP' },
118
+ ] },
119
+ { group: 'FULL STACK BUNDLES', emoji: '🚀', items: [
120
+ { id: 't3', label: 'T3 Stack', lang: 'TS' }, { id: 'mern', label: 'MERN Stack', lang: 'JS / TS', emoji: '🌱' },
121
+ { id: 'supabase', label: 'Supabase Stack', lang: 'TS / JS' }, { id: 'firebase', label: 'Firebase', lang: 'TS / JS' },
122
+ { id: 'amplify', label: 'AWS Amplify', lang: 'TS / JS' }, { id: 'appwrite', label: 'Appwrite', lang: 'TS / JS', emoji: '🔺' },
123
+ ] },
124
+ { group: 'CLI FRAMEWORKS', emoji: '⌨️', items: [
125
+ { id: 'commander', label: 'Node.js (Commander / Ink)', lang: 'TypeScript / JavaScript' }, { id: 'click', label: 'Python (Click / Typer)', lang: 'Python' },
126
+ { id: 'cobra', label: 'Go (Cobra)', lang: 'Go' }, { id: 'clap', label: 'Rust (Clap)', lang: 'Rust' }, { id: 'shell', label: 'Shell script', lang: 'Bash' },
127
+ ] },
128
+ { group: 'EXTENSION FRAMEWORKS', emoji: '🧩', items: [
129
+ { id: 'plasmo', label: 'Plasmo', lang: 'TypeScript / React' }, { id: 'wxt', label: 'WXT', lang: 'TypeScript' },
130
+ { id: 'crxjs', label: 'CRXJS (Vite)', lang: 'TypeScript / JavaScript' }, { id: 'vanilla-mv3', label: 'Vanilla Manifest V3', lang: 'JavaScript / TypeScript', emoji: '📄' },
131
+ ] },
132
+ { group: 'LANGUAGE / PACKAGE', emoji: '📦', items: [
133
+ { id: 'npm-ts', label: 'TypeScript (npm)', lang: 'TypeScript' }, { id: 'py-pypi', label: 'Python (PyPI)', lang: 'Python' },
134
+ { id: 'go-mod', label: 'Go module', lang: 'Go' }, { id: 'rust-crate', label: 'Rust crate', lang: 'Rust' },
135
+ { id: 'java-maven', label: 'Java (Maven / Gradle)', lang: 'Java / Kotlin' },
136
+ ] },
137
+ { group: 'DATA PIPELINE TOOLS', emoji: '🔄', items: [
138
+ { id: 'airflow', label: 'Airflow', lang: 'Python' }, { id: 'dagster', label: 'Dagster', lang: 'Python' },
139
+ { id: 'prefect', label: 'Prefect', lang: 'Python' }, { id: 'dbt', label: 'dbt', lang: 'SQL / Python' },
140
+ { id: 'cron', label: 'Plain Python / cron script', lang: 'Python', emoji: '⏰' },
141
+ ] },
142
+ { group: 'DOCS FRAMEWORKS', emoji: '📚', items: [
143
+ { id: 'docusaurus', label: 'Docusaurus', lang: 'TypeScript / React' }, { id: 'vitepress', label: 'VitePress', lang: 'TypeScript / Vue' },
144
+ { id: 'mkdocs', label: 'MkDocs', lang: 'Python', emoji: '📘' }, { id: 'mintlify', label: 'Mintlify', lang: 'MDX' },
145
+ ] },
146
+ ];
147
+ const groupIds = (group) => exports.PLATFORM_GROUPS.find(g => g.group === group)?.items.map(i => i.id) ?? [];
148
+ const PLATFORM_GROUP = Object.fromEntries(exports.PLATFORM_GROUPS.flatMap(g => g.items.map(i => [i.id, g.group])));
149
+ /** Bundles that include their own frontend (T3 = Next.js, MERN = React). */
150
+ exports.BUNDLES_INCLUDE_FRONTEND = ['t3', 'mern'];
151
+ /** Backend-as-a-service bundles: they bring hosting, a database and auth. */
152
+ exports.BAAS_BUNDLES = ['supabase', 'firebase', 'amplify', 'appwrite'];
153
+ function hasMobilePlatform(platforms) {
154
+ const ids = groupIds('MOBILE');
155
+ return platforms.some(p => ids.includes(p));
156
+ }
157
+ function hasBaasPlatform(platforms) {
158
+ return platforms.some(p => exports.BAAS_BUNDLES.includes(p));
159
+ }
160
+ /** The platform groups a category shows. */
161
+ function visiblePlatformGroups(category) {
162
+ const cap = getCapabilities(category);
163
+ const groups = [];
164
+ if (cap.hasMobileUI)
165
+ groups.push('MOBILE');
166
+ if (cap.hasWebUI)
167
+ groups.push('WEB FRONTEND');
168
+ if (cap.hasServer)
169
+ groups.push('BACKEND');
170
+ if (cap.hasServer && (cap.hasWebUI || cap.hasMobileUI))
171
+ groups.push('FULL STACK BUNDLES');
172
+ if (category === 'cli')
173
+ groups.push('CLI FRAMEWORKS');
174
+ if (category === 'extension')
175
+ groups.push('EXTENSION FRAMEWORKS');
176
+ if (category === 'library')
177
+ groups.push('LANGUAGE / PACKAGE');
178
+ if (category === 'pipeline')
179
+ groups.push('DATA PIPELINE TOOLS');
180
+ if (category === 'docs')
181
+ groups.push('DOCS FRAMEWORKS');
182
+ return groups;
183
+ }
184
+ /** One pick per group; a bundle replaces a backend pick (and a web pick when it bundles a frontend), and back. */
185
+ function togglePlatform(platforms, id) {
186
+ const ids = groupIds(PLATFORM_GROUP[id]);
187
+ const withoutGroup = platforms.filter(p => !ids.includes(p));
188
+ const isDeselecting = platforms.includes(id);
189
+ let next = isDeselecting ? withoutGroup : [...withoutGroup, id];
190
+ const bundleIds = groupIds('FULL STACK BUNDLES');
191
+ const webIds = groupIds('WEB FRONTEND');
192
+ const backendIds = groupIds('BACKEND');
193
+ if (!isDeselecting && bundleIds.includes(id)) {
194
+ next = next.filter(p => !backendIds.includes(p) && !(exports.BUNDLES_INCLUDE_FRONTEND.includes(id) && webIds.includes(p)));
195
+ }
196
+ else if (!isDeselecting && backendIds.includes(id)) {
197
+ next = next.filter(p => !bundleIds.includes(p));
198
+ }
199
+ else if (!isDeselecting && webIds.includes(id)) {
200
+ next = next.filter(p => !(bundleIds.includes(p) && exports.BUNDLES_INCLUDE_FRONTEND.includes(p)));
201
+ }
202
+ return next;
203
+ }
204
+ /** The groups the grid shows now: a bundle hides Backend, a frontend bundle hides Web frontend too. */
205
+ function platformGridGroups(category, platforms) {
206
+ const bundleSelected = platforms.some(p => groupIds('FULL STACK BUNDLES').includes(p));
207
+ const frontendBundle = platforms.some(p => exports.BUNDLES_INCLUDE_FRONTEND.includes(p));
208
+ return visiblePlatformGroups(category).filter(g => !(bundleSelected && g === 'BACKEND') && !(frontendBundle && g === 'WEB FRONTEND'));
209
+ }
210
+ /** The line under the grid when a bundle is picked, or ''. */
211
+ function bundleLine(platforms) {
212
+ if (!platforms.some(p => groupIds('FULL STACK BUNDLES').includes(p)))
213
+ return '';
214
+ return platforms.some(p => exports.BUNDLES_INCLUDE_FRONTEND.includes(p))
215
+ ? 'ℹ Web Frontend and Backend are covered by your bundle.'
216
+ : 'ℹ Backend is covered by your bundle - pick a Web Frontend too if you need one.';
217
+ }
218
+ const ECOSYSTEM = {
219
+ ios: 'swift', android: 'kotlin', rn: 'jsts', flutter: 'dart', kmp: 'kotlin', react: 'jsts', nextjs: 'jsts', angular: 'jsts', vue: 'jsts', svelte: 'jsts',
220
+ node: 'jsts', fastapi: 'python', django: 'python', spring: 'kotlin', dotnet: 'csharp', laravel: 'php', t3: 'jsts', mern: 'jsts', supabase: 'jsts',
221
+ firebase: 'jsts', amplify: 'jsts', appwrite: 'jsts', commander: 'jsts', click: 'python', cobra: 'go', clap: 'rust', shell: 'bash',
222
+ plasmo: 'jsts', wxt: 'jsts', crxjs: 'jsts', 'vanilla-mv3': 'jsts', 'npm-ts': 'jsts', 'py-pypi': 'python', 'go-mod': 'go', 'rust-crate': 'rust', 'java-maven': 'kotlin',
223
+ airflow: 'python', dagster: 'python', prefect: 'python', dbt: 'python', cron: 'python', docusaurus: 'jsts', vitepress: 'jsts', mkdocs: 'python', mintlify: 'jsts',
224
+ };
225
+ const ECOSYSTEM_LABEL = {
226
+ swift: 'Swift', kotlin: 'Kotlin / Java', jsts: 'TypeScript / JavaScript', dart: 'Dart', python: 'Python', csharp: 'C#', php: 'PHP', go: 'Go', rust: 'Rust', bash: 'Bash',
227
+ };
228
+ /** The note after the platforms answer, or null. */
229
+ function getPlatformNote(platforms) {
230
+ const bundleIds = groupIds('FULL STACK BUNDLES');
231
+ const webIds = groupIds('WEB FRONTEND');
232
+ const backendIds = groupIds('BACKEND');
233
+ const bundleSelected = platforms.some(p => bundleIds.includes(p));
234
+ const isMultiGroup = exports.PLATFORM_GROUPS.filter(g => g.items.some(i => platforms.includes(i.id))).length >= 2;
235
+ const ecosystems = [...new Set(platforms.map(p => ECOSYSTEM[p]).filter(Boolean))];
236
+ const backendPlatformSelected = platforms.some(p => backendIds.includes(p));
237
+ const hasWebFrontend = platforms.some(p => webIds.includes(p));
238
+ const rnWithWeb = platforms.includes('rn') && (hasWebFrontend || bundleSelected);
239
+ if (isMultiGroup) {
240
+ if (rnWithWeb)
241
+ return { tone: 'success', text: 'React Native + web is the best monorepo candidate - shared TypeScript, hooks, and types. Expo Router + Next.js in a Turborepo with a packages/ directory is the go-to setup.' };
242
+ if (ecosystems.length === 1)
243
+ return { tone: 'success', text: `Monorepo-friendly - all selected platforms share ${ECOSYSTEM_LABEL[ecosystems[0]]}. Consider Turborepo or Nx to manage shared workspaces.` };
244
+ return { tone: 'warn', text: `Cross-ecosystem: ${ecosystems.map(e => ECOSYSTEM_LABEL[e]).join(' + ')}. These platforms can't share code and will likely live in separate repos - I'll generate separate spec sections for each.` };
245
+ }
246
+ if (hasMobilePlatform(platforms) && !(backendPlatformSelected || bundleSelected)) {
247
+ return { tone: 'warn', text: 'Mobile apps typically need a data layer - consider adding a backend or picking a Full Stack Bundle (Supabase Stack is popular for mobile).' };
248
+ }
249
+ if (platforms.some(p => ['nextjs', 'svelte'].includes(p)) && backendPlatformSelected) {
250
+ return { tone: 'info', text: `${platforms.includes('nextjs') ? 'Next.js' : 'SvelteKit'} has built-in API routes - a separate backend is optional unless you need an independent service.` };
251
+ }
252
+ return null;
253
+ }
254
+ // ---------------------------------------------------------------- platform → CLI language (the App's own, REQ-002.H.28)
255
+ /** Platform id → [CLI language, CLI framework or null]; absent = no CLI language (Dart, C#, PHP, Go, Rust, Bash, MDX). */
256
+ exports.PLATFORM_LANGUAGE = {
257
+ ios: ['swift', 'ios'], android: ['kotlin', 'android'], kmp: ['kotlin', null],
258
+ rn: ['typescript', null], svelte: ['typescript', null], supabase: ['typescript', null], firebase: ['typescript', null], amplify: ['typescript', null],
259
+ appwrite: ['typescript', null], commander: ['typescript', null], wxt: ['typescript', null], crxjs: ['typescript', null], plasmo: ['typescript', null],
260
+ 'vanilla-mv3': ['typescript', null], 'npm-ts': ['typescript', null], docusaurus: ['typescript', null], vitepress: ['typescript', null],
261
+ react: ['typescript', 'react'], nextjs: ['typescript', 'next'], angular: ['typescript', 'angular'], vue: ['typescript', 'vue'],
262
+ node: ['typescript', 'express'], mern: ['typescript', 'express'], t3: ['typescript', 'next'],
263
+ fastapi: ['python', 'fastapi'], django: ['python', 'django'],
264
+ click: ['python', null], 'py-pypi': ['python', null], airflow: ['python', null], dagster: ['python', null], prefect: ['python', null],
265
+ dbt: ['python', null], cron: ['python', null], mkdocs: ['python', null],
266
+ spring: ['kotlin', 'spring'], 'java-maven': ['kotlin', null],
267
+ };
268
+ const UNSUPPORTED_LANGUAGE = {
269
+ flutter: 'Dart', dotnet: 'C#', laravel: 'PHP', cobra: 'Go', 'go-mod': 'Go', clap: 'Rust', 'rust-crate': 'Rust', shell: 'Bash', mintlify: 'MDX',
270
+ };
271
+ const LANGUAGE_NAME = { typescript: 'TypeScript', javascript: 'JavaScript', python: 'Python', kotlin: 'Kotlin', swift: 'Swift' };
272
+ /** Tab priority for the pre-selection when the platforms imply two languages (the developer's answer, 2026-10-07). */
273
+ const GROUP_PRIORITY = ['BACKEND', 'FULL STACK BUNDLES', 'WEB FRONTEND', 'MOBILE'];
274
+ const priority = (id) => {
275
+ const i = GROUP_PRIORITY.indexOf(PLATFORM_GROUP[id]);
276
+ return i < 0 ? GROUP_PRIORITY.length : i;
277
+ };
278
+ /** What the platforms say about the CLI's language and framework questions. */
279
+ function languageHints(platforms, language) {
280
+ const mapped = platforms.filter(p => exports.PLATFORM_LANGUAGE[p]).sort((a, b) => priority(a) - priority(b));
281
+ const languages = [...new Set(mapped.map(p => exports.PLATFORM_LANGUAGE[p][0]))];
282
+ const top = mapped[0];
283
+ const chosen = language ?? (top ? exports.PLATFORM_LANGUAGE[top][0] : undefined);
284
+ const sameLanguage = mapped.filter(p => exports.PLATFORM_LANGUAGE[p][0] === chosen);
285
+ const frameworks = [...new Set(sameLanguage.map(p => exports.PLATFORM_LANGUAGE[p][1]).filter((f) => !!f))];
286
+ const notes = [];
287
+ if (languages.length > 1) {
288
+ const names = languages.map(l => LANGUAGE_NAME[l]);
289
+ notes.push(`Your platforms use ${names.slice(0, -1).join(', ')} and ${names[names.length - 1]}. SpecPilot writes one language into project.yaml: pick the main one. Every platform is still listed under platforms.`);
290
+ }
291
+ const unsupported = [...new Set(platforms.map(p => UNSUPPORTED_LANGUAGE[p]).filter(Boolean))];
292
+ if (unsupported.length)
293
+ notes.push(`SpecPilot has no ${unsupported.join(' or ')} templates yet. Pick the closest language; your platforms are listed as you picked them.`);
294
+ return {
295
+ languages,
296
+ language: top ? exports.PLATFORM_LANGUAGE[top][0] : undefined,
297
+ frameworks,
298
+ framework: sameLanguage.map(p => exports.PLATFORM_LANGUAGE[p][1]).find((f) => !!f),
299
+ note: notes.join(' '),
300
+ };
301
+ }
302
+ // ---------------------------------------------------------------- users (userOptions.ts)
303
+ exports.USER_TYPE_GROUPS = [
304
+ { group: 'CONSUMERS', items: [{ emoji: '👥', label: 'Customers' }, { emoji: '🌍', label: 'General Public' }, { emoji: '👶', label: 'Children' }, { emoji: '🎓', label: 'Students' }, { emoji: '👨‍👩‍👧', label: 'Parents' }] },
305
+ { group: 'ENTERPRISE', items: [{ emoji: '💼', label: 'Employees' }, { emoji: '📊', label: 'Managers' }, { emoji: '🔧', label: 'Admins' }, { emoji: '💻', label: 'Developers' }, { emoji: '🏢', label: 'Enterprise Users' }] },
306
+ { group: 'DOMAIN', items: [{ emoji: '🏥', label: 'Patients' }, { emoji: '👨‍⚕️', label: 'Doctors / Clinicians' }, { emoji: '👩‍🏫', label: 'Teachers' }, { emoji: '⛪', label: 'Church Members' }] },
307
+ ];
308
+ function visibleUserTypeGroups(category) {
309
+ return getCapabilities(category).audienceIsDevelopers ? exports.USER_TYPE_GROUPS.filter(g => g.group === 'ENTERPRISE') : exports.USER_TYPE_GROUPS;
310
+ }
311
+ exports.ACCESS_OPTIONS = [
312
+ { id: 'public', emoji: '🌍', label: 'Public - no login' },
313
+ { id: 'login', emoji: '🔐', label: 'Login required' },
314
+ { id: 'role', emoji: '🎭', label: 'Role-based access' },
315
+ { id: 'multitenant', emoji: '🏢', label: 'Multi-tenant / team-based' },
316
+ { id: 'unsure', emoji: '❓', label: 'Not sure → TODO', isTodo: true },
317
+ ];
318
+ exports.SPECIAL_OPTIONS = [
319
+ { id: 'a11y', emoji: '♿', label: 'Accessibility (WCAG)' },
320
+ { id: 'i18n', emoji: '🌐', label: 'Multi-language / i18n' },
321
+ { id: 'offline', emoji: '📱', label: 'Low-bandwidth / offline' },
322
+ { id: 'child', emoji: '👶', label: 'Child-safe content' },
323
+ { id: 'sensitive', emoji: '🔏', label: 'High data sensitivity' },
324
+ ];
325
+ // ---------------------------------------------------------------- scale (scaleOptions.ts)
326
+ exports.SCALE_TIERS = [
327
+ { id: 'prototype', emoji: '🧪', title: 'Prototype', description: 'Solo dev, fast iteration, minimal infra' },
328
+ { id: 'startup', emoji: '🚀', title: 'Startup', description: '1K–50K users, growth-focused', badge: 'recommended' },
329
+ { id: 'scaleup', emoji: '📈', title: 'Scale-up', description: '50K–500K users, team 5–20 devs' },
330
+ { id: 'enterprise', emoji: '🏛️', title: 'Enterprise', description: '500K+ users, compliance requirements' },
331
+ ];
332
+ exports.TIMELINES = [
333
+ { id: '1-3m', emoji: '⚡', label: '1–3 months' }, { id: '3-6m', emoji: '🏃', label: '3–6 months' },
334
+ { id: '6-12m', emoji: '🚶', label: '6–12 months' }, { id: '12m+', emoji: '🐢', label: '12+ months' },
335
+ { id: 'noidea', emoji: '❓', label: 'No idea → TODO', isTodo: true },
336
+ ];
337
+ exports.USER_RANGES = [
338
+ { id: '< 100', emoji: '🌱', label: '< 100' }, { id: '100–1K', emoji: '🌿', label: '100–1K' }, { id: '1K–50K', emoji: '🌳', label: '1K–50K' },
339
+ { id: '50K–500K', emoji: '🌲', label: '50K–500K' }, { id: '500K+', emoji: '🌍', label: '500K+' }, { id: 'noidea', emoji: '❓', label: 'No idea → TODO', isTodo: true },
340
+ ];
341
+ exports.DEPLOY_TARGETS = [
342
+ { label: 'AWS', description: 'Raw cloud infrastructure - EC2/ECS/Lambda, you assemble and operate the stack', group: 'CLOUD' },
343
+ { label: 'GCP', description: 'Raw cloud infrastructure - Compute/Cloud Run/Functions, you assemble the stack', group: 'CLOUD' },
344
+ { label: 'Azure', description: 'Raw cloud infrastructure - App Service/Functions, common in Microsoft/.NET shops', group: 'CLOUD' },
345
+ { label: 'Self-hosted', emoji: '🏠', description: 'Your own servers or a VPS - full control, you handle uptime, scaling, and patching', group: 'CLOUD' },
346
+ { label: 'Vercel', description: 'Managed platform - git-push deploys, built for Next.js and frontend frameworks', group: 'PLATFORM' },
347
+ { label: 'Netlify', description: 'Managed platform - git-push deploys for static sites and serverless functions', group: 'PLATFORM' },
348
+ { label: 'Railway', description: 'Managed platform - runs long-lived servers and databases with minimal config', group: 'PLATFORM' },
349
+ { label: 'Fly.io', description: 'Managed platform - runs containers close to users, good for always-on servers', group: 'PLATFORM' },
350
+ { label: 'Cloudflare Pages', description: 'Managed platform - static sites and frontend frameworks on Cloudflare\'s edge', group: 'PLATFORM' },
351
+ { label: 'Cloudflare Workers', description: 'Managed platform - serverless functions at the edge, pairs with D1/R2/KV', group: 'PLATFORM' },
352
+ { label: 'Supabase', description: 'Backend-as-a-service - Postgres, auth, storage, and realtime hosted together', group: 'BAAS' },
353
+ { label: 'Firebase Hosting', description: 'Backend-as-a-service - Google-hosted, pairs with Firestore and Firebase Auth', group: 'BAAS' },
354
+ { label: 'AWS Amplify Hosting', description: 'Backend-as-a-service - AWS-hosted, pairs with Amplify DataStore and Amplify Auth', group: 'BAAS' },
355
+ { label: 'Appwrite Cloud', description: 'Backend-as-a-service - hosted Appwrite, bundles database, auth, and storage', group: 'BAAS' },
356
+ { label: 'App Store', description: 'Apple\'s iOS/iPadOS store - review process, yearly developer account fee', group: 'MOBILE STORES' },
357
+ { label: 'Google Play', description: 'Android\'s store - review process, one-time developer account fee', group: 'MOBILE STORES' },
358
+ { label: 'Undecided', emoji: '❓', description: 'Not chosen yet - recorded as a TODO in the generated specs', group: 'CLOUD' },
359
+ ];
360
+ /** BaaS platform → the deploy target it implies (badge and seed). */
361
+ exports.BAAS_DEPLOY_TARGET = { supabase: 'Supabase', firebase: 'Firebase Hosting', amplify: 'AWS Amplify Hosting', appwrite: 'Appwrite Cloud' };
362
+ exports.REGISTRY_DEPLOY_TARGETS = [{ label: 'npm' }, { label: 'PyPI' }, { label: 'Homebrew' }, { label: 'crates.io' }, { label: 'GitHub Releases' }, { label: 'Undecided', emoji: '❓' }];
363
+ exports.APPSTORE_DEPLOY_TARGETS = [{ label: 'Chrome Web Store' }, { label: 'Firefox Add-ons' }, { label: 'Edge Add-ons' }, { label: 'Undecided', emoji: '❓' }];
364
+ exports.TEAM_SIZES = [
365
+ { id: 'solo', emoji: '🧑‍💻', label: 'Solo dev' }, { id: '2-5', emoji: '👥', label: '2–5 devs' },
366
+ { id: '5-15', emoji: '👨‍👩‍👧‍👦', label: '5–15 devs' }, { id: '15+', emoji: '🏢', label: '15+ devs' },
367
+ ];
368
+ /** The deploy targets for a category and its platforms (registry, store, or hosting without the tabs the platforms rule out). */
369
+ function deployTargetOptions(category, platforms) {
370
+ const cap = getCapabilities(category);
371
+ if (cap.distribution === 'registry')
372
+ return exports.REGISTRY_DEPLOY_TARGETS;
373
+ if (cap.distribution === 'appstore')
374
+ return exports.APPSTORE_DEPLOY_TARGETS;
375
+ const answered = platforms.length > 0;
376
+ const showMobileStores = cap.hasMobileUI && (!answered || hasMobilePlatform(platforms));
377
+ const showBaas = !answered || hasBaasPlatform(platforms);
378
+ return exports.DEPLOY_TARGETS.filter(t => (t.group !== 'MOBILE STORES' || showMobileStores) && (t.group !== 'BAAS' || showBaas));
379
+ }
380
+ function getArchBadge(scaleTier, teamSize) {
381
+ const solo = teamSize === 'solo';
382
+ const small = teamSize === '2-5';
383
+ const large = teamSize === '5-15' || teamSize === '15+';
384
+ if (solo || (small && (scaleTier === 'prototype' || scaleTier === 'startup')))
385
+ return { monolith: 'recommended' };
386
+ if (small && scaleTier === 'scaleup')
387
+ return { monolith: 'recommended', modular: 'recommended' };
388
+ if (large && (scaleTier === 'scaleup' || scaleTier === 'enterprise'))
389
+ return { modular: 'recommended', microservices: 'flagged' };
390
+ return { monolith: 'recommended' };
391
+ }
392
+ const API_STYLE_BY_DESCRIPTION = { 'GraphQL API': 'graphql', 'REST API / Backend': 'rest' };
393
+ /** The web's API style badge; its `rest` and `graphql` are the CLI paradigm values of the same name. */
394
+ function getApiBadge(scaleTier, projectDescription = '') {
395
+ const fromDescription = API_STYLE_BY_DESCRIPTION[projectDescription];
396
+ if (fromDescription)
397
+ return { [fromDescription]: 'recommended' };
398
+ if (scaleTier === 'enterprise')
399
+ return { graphql: 'recommended' };
400
+ return { rest: 'recommended' };
401
+ }
402
+ const BAAS_DATABASE = { supabase: 'Supabase', firebase: 'Firestore', amplify: 'Amplify DataStore' };
403
+ const BAAS_AUTH = { supabase: 'Supabase Auth', firebase: 'Firebase Auth', amplify: 'Amplify Auth' };
404
+ const baasBadge = (platforms, m) => {
405
+ const match = platforms.map(p => m[p]).find(Boolean);
406
+ return match ? { [match]: 'recommended' } : {};
407
+ };
408
+ const getDatabaseBadge = (platforms) => baasBadge(platforms, BAAS_DATABASE);
409
+ exports.getDatabaseBadge = getDatabaseBadge;
410
+ const getAuthBadge = (platforms) => baasBadge(platforms, BAAS_AUTH);
411
+ exports.getAuthBadge = getAuthBadge;
412
+ const VENDOR_LOCKED_DATABASES = {
413
+ 'Amazon RDS': 'AWS', DynamoDB: 'AWS', 'Amazon ElastiCache': 'AWS', 'Amplify DataStore': 'AWS', 'Google Cloud SQL': 'GCP', Firestore: 'GCP', 'Azure SQL Database': 'Azure',
414
+ };
415
+ const CLOUDFLARE_DATABASES = ['Cloudflare D1'];
416
+ const VECTOR_DATABASES = ['Pinecone', 'Weaviate', 'Chroma', 'pgvector (Postgres)'];
417
+ const aiSelected = (a) => (map(a, 'integrations').ai ?? []).some(v => v !== 'None');
418
+ function getDatabaseMismatch(a) {
419
+ const result = {};
420
+ const targets = new Set(list(a, 'deploymentTargets'));
421
+ for (const [label, vendor] of Object.entries(VENDOR_LOCKED_DATABASES))
422
+ if (!targets.has(vendor))
423
+ result[label] = `Deploy target is not ${vendor}`;
424
+ if (!targets.has('Cloudflare Pages') && !targets.has('Cloudflare Workers'))
425
+ for (const label of CLOUDFLARE_DATABASES)
426
+ result[label] = 'Deploy target is not Cloudflare';
427
+ if (!aiSelected(a) && a.projectCategory !== 'ml')
428
+ for (const label of VECTOR_DATABASES)
429
+ result[label] = 'No AI/LLM integration selected';
430
+ return result;
431
+ }
432
+ exports.SYSTEM_PATTERNS = [
433
+ { id: 'monolith', emoji: '🧱', title: 'Monolith', description: 'Single deploy, simple ops' },
434
+ { id: 'modular', emoji: '🧩', title: 'Modular Monolith', description: 'Domain modules, deploy as one' },
435
+ { id: 'microservices', emoji: '🕸️', title: 'Microservices', description: 'Independent services, complex ops' },
436
+ ];
437
+ exports.DATABASES = [
438
+ { label: 'PostgreSQL', description: 'SQL - general-purpose relational database, the safe default for structured data', group: 'SQL' },
439
+ { label: 'MySQL', description: 'SQL - relational database, common in traditional hosting/WordPress-adjacent stacks', group: 'SQL' },
440
+ { label: 'SQLite', description: 'SQL - file-based, zero setup, best for local/small-scale or embedded use', group: 'SQL' },
441
+ { label: 'Amazon RDS', emoji: '🟧', description: 'Managed SQL - AWS-hosted Postgres/MySQL/SQL Server/etc., handles backups, patching, and scaling', group: 'MANAGED SQL' },
442
+ { label: 'Google Cloud SQL', emoji: '🔵', description: 'Managed SQL - GCP-hosted Postgres/MySQL/SQL Server, integrates with the rest of GCP', group: 'MANAGED SQL' },
443
+ { label: 'Azure SQL Database', emoji: '🔷', description: 'Managed SQL - Microsoft-hosted SQL Server, integrates with the rest of Azure', group: 'MANAGED SQL' },
444
+ { label: 'Cloudflare D1', description: 'Managed SQL (SQLite-based) - serverless, runs at the edge alongside Cloudflare Workers', group: 'MANAGED SQL' },
445
+ { label: 'Supabase', description: 'Managed SQL (Postgres) - managed, with built-in auth/storage/realtime bundled in', group: 'MANAGED SQL' },
446
+ { label: 'SQL Server', emoji: '🗄️', description: 'SQL - Microsoft-managed relational database, common in enterprise/.NET stacks', group: 'SQL' },
447
+ { label: 'Oracle', emoji: '🗄️', description: 'SQL - enterprise relational database, common where it\'s already the corporate standard', group: 'SQL' },
448
+ { label: 'MongoDB', description: 'NoSQL - flexible document storage, good when your data shape varies or evolves fast', group: 'NoSQL' },
449
+ { label: 'DynamoDB', description: 'NoSQL - AWS-managed key-value/document store, scales automatically', group: 'NoSQL' },
450
+ { label: 'Firestore', description: 'NoSQL - Google-managed document store, pairs with Firebase Auth', group: 'NoSQL' },
451
+ { label: 'Amplify DataStore', description: 'NoSQL - AWS-managed, pairs with Amplify Auth, offline-first sync built in', group: 'NoSQL' },
452
+ { label: 'Redis', emoji: '🟥', description: 'Cache / key-value - in-memory store, common for caching, sessions, and rate limiting', group: 'CACHE / KEY-VALUE' },
453
+ { label: 'Amazon ElastiCache', emoji: '🟧', description: 'Cache / key-value - AWS-managed Redis or Memcached, handles patching and scaling', group: 'CACHE / KEY-VALUE' },
454
+ { label: 'Memcached', emoji: '⚡', description: 'Cache / key-value - simple, high-performance in-memory cache', group: 'CACHE / KEY-VALUE' },
455
+ { label: 'Upstash', emoji: '🔺', description: 'Cache / key-value - serverless Redis, pay-per-request, no server to manage', group: 'CACHE / KEY-VALUE' },
456
+ { label: 'Pinecone', description: 'Vector - fully managed vector database, purpose-built for similarity search at scale', group: 'VECTOR' },
457
+ { label: 'Weaviate', emoji: '🕸️', description: 'Vector - open-source vector database with built-in hybrid search', group: 'VECTOR' },
458
+ { label: 'Chroma', description: 'Vector - lightweight, embeddable vector database, easy to self-host', group: 'VECTOR' },
459
+ { label: 'pgvector (Postgres)', description: 'Vector - adds vector search to Postgres, good if you already run Postgres', group: 'VECTOR' },
460
+ { label: 'Not sure → TODO', emoji: '❓', isTodo: true },
461
+ ];
462
+ exports.AUTH_OPTIONS = [
463
+ { label: 'JWT', description: 'Protocol - you build and manage the tokens/sessions yourself, full control', group: 'PROTOCOL' },
464
+ { label: 'OAuth 2.0', emoji: '🔐', description: 'Protocol - "Sign in with Google/GitHub/etc.", you still host the integration', group: 'PROTOCOL' },
465
+ { label: 'SAML / SSO', description: 'Protocol - enterprise single sign-on, usually required by corporate customers', group: 'PROTOCOL' },
466
+ { label: 'Clerk', description: 'Managed service - drop-in login UI and user management, you don’t build auth', group: 'MANAGED SERVICE' },
467
+ { label: 'Auth0', description: 'Managed service - enterprise-grade hosted auth, you don’t build it yourself', group: 'MANAGED SERVICE' },
468
+ { label: 'Firebase Auth', description: 'Managed service - Google-hosted auth, pairs naturally with Firestore', group: 'MANAGED SERVICE' },
469
+ { label: 'Supabase Auth', description: 'Managed service - bundled with Supabase’s Postgres database', group: 'MANAGED SERVICE' },
470
+ { label: 'AWS Cognito', description: 'Managed service - AWS-hosted user pools and identity federation', group: 'MANAGED SERVICE' },
471
+ { label: 'Amplify Auth', description: 'Managed service - AWS Amplify’s auth layer, pairs with Amplify DataStore', group: 'MANAGED SERVICE' },
472
+ { label: 'Not sure → TODO', emoji: '❓', isTodo: true },
473
+ ];
474
+ exports.REALTIME_TYPES = [
475
+ { label: 'WebSockets', emoji: '🔌', description: 'Full two-way live connection - best for chat, multiplayer, collaborative editing' },
476
+ { label: 'Server-Sent Events', emoji: '📡', description: 'One-way live updates from server to client - good for feeds, notifications' },
477
+ { label: 'Polling', emoji: '🔄', description: 'Client checks for updates on a timer - simplest to build, less instant' },
478
+ ];
479
+ const REALM = { label: 'Realm', emoji: '🗄️', description: 'Cross-platform mobile database, works across iOS and Android' };
480
+ const SQLITE = { label: 'SQLite', description: 'Embedded file-based database, no separate server process' };
481
+ const LOCAL_DATABASES_BY_PLATFORM = {
482
+ ios: [{ label: 'Core Data', emoji: '🍎', description: 'Apple\'s native object graph and persistence framework' }, { label: 'SwiftData', emoji: '🍎', description: 'Swift-native persistence, the modern successor to Core Data' }, REALM, SQLITE],
483
+ android: [{ label: 'Room', emoji: '🤖', description: 'Android Jetpack\'s SQLite abstraction layer' }, { label: 'DataStore', emoji: '🤖', description: 'Jetpack\'s modern key-value/typed preferences store' }, REALM, SQLITE],
484
+ flutter: [{ label: 'Hive', emoji: '🐝', description: 'Lightweight, fast key-value store for Dart/Flutter' }, { label: 'Isar', emoji: '💎', description: 'Fast NoSQL database built for Flutter' }, { label: 'Drift', emoji: '💧', description: 'Reactive persistence library over SQLite for Dart' }, { label: 'sqflite', description: 'Direct SQLite bindings for Flutter' }],
485
+ rn: [{ label: 'WatermelonDB', emoji: '🍉', description: 'Reactive, high-performance database built for React Native' }, { label: 'AsyncStorage', emoji: '📦', description: 'Simple async key-value storage for React Native' }, { label: 'SQLite (Expo)', description: 'Direct SQLite access via expo-sqlite' }, REALM],
486
+ };
487
+ const SERVER_SIDE_LOCAL_DATABASES = [SQLITE, { label: 'IndexedDB', emoji: '🌐', description: 'Browser-native structured storage for offline web clients' }];
488
+ function getLocalDatabaseOptions(platforms) {
489
+ const seen = new Map();
490
+ for (const platform of platforms)
491
+ for (const db of LOCAL_DATABASES_BY_PLATFORM[platform] ?? [])
492
+ seen.set(db.label, db);
493
+ return seen.size > 0 ? Array.from(seen.values()) : SERVER_SIDE_LOCAL_DATABASES;
494
+ }
495
+ exports.DATA_SYNC_STRATEGIES = [
496
+ { id: 'last-write-wins', label: 'Last write wins', emoji: '🏁', description: 'Simplest conflict resolution - the most recent write overwrites earlier ones' },
497
+ { id: 'merge-fields', label: 'Field-level merge', emoji: '🧬', description: 'Merges non-conflicting fields from each side instead of discarding one write entirely' },
498
+ { id: 'crdt-merge', label: 'Automatic merge (CRDT)', emoji: '🔀', description: 'Keeps both sides\' changes and merges them automatically, even on true conflicts - no data lost, no user prompt (e.g. Automerge, Yjs)' },
499
+ { id: 'manual-resolution', label: 'Manual conflict resolution', emoji: '🙋', description: 'Surfaces conflicts to the user to resolve, rather than resolving automatically' },
500
+ { id: 'server-authoritative', label: 'Server is authoritative', emoji: '🖥️', description: 'The server\'s copy always wins - local changes are queued and replayed, not merged' },
501
+ ];
502
+ const SERVERLESS_TARGETS = ['Vercel', 'Netlify', 'Cloudflare Pages', 'Cloudflare Workers'];
503
+ const LONG_LIVED_SERVER_PLATFORMS = { django: 'Django', laravel: 'Laravel', spring: 'Spring Boot', dotnet: '.NET / ASP.NET' };
504
+ function getDeployTargetMismatch(a) {
505
+ const result = {};
506
+ const platform = list(a, 'platforms').map(p => LONG_LIVED_SERVER_PLATFORMS[p]).find(Boolean);
507
+ if (!platform)
508
+ return result;
509
+ for (const target of SERVERLESS_TARGETS)
510
+ result[target] = `${platform} needs a long-running server - this host runs serverless functions`;
511
+ return result;
512
+ }
513
+ const NO_WEBSOCKET_TARGETS = ['Vercel', 'Netlify', 'Cloudflare Pages'];
514
+ function getRealtimeMismatch(a) {
515
+ const blocking = list(a, 'deploymentTargets').filter(t => NO_WEBSOCKET_TARGETS.includes(t));
516
+ if (!blocking.length)
517
+ return {};
518
+ return { WebSockets: `${blocking.join(' / ')} does not hold open WebSocket connections - needs Durable Objects or a separate service` };
519
+ }
520
+ const TIER_LABEL = { prototype: 'Prototype', startup: 'Startup', scaleup: 'Scale-up', enterprise: 'Enterprise' };
521
+ const TIER_USER_RANGES = {
522
+ prototype: ['< 100', '100–1K'], startup: ['100–1K', '1K–50K'], scaleup: ['1K–50K', '50K–500K'], enterprise: ['50K–500K', '500K+'],
523
+ };
524
+ const TIER_TEAM_SIZES = {
525
+ prototype: ['solo', '2-5'], startup: ['solo', '2-5', '5-15'], scaleup: ['2-5', '5-15', '15+'], enterprise: ['5-15', '15+'],
526
+ };
527
+ function getActiveUsersMismatch(a) {
528
+ const tier = str(a, 'scaleTier');
529
+ const expected = TIER_USER_RANGES[tier];
530
+ if (!expected)
531
+ return {};
532
+ const result = {};
533
+ for (const range of Object.values(TIER_USER_RANGES).flat())
534
+ if (!expected.includes(range))
535
+ result[range] = `Unusual for a ${TIER_LABEL[tier]} project`;
536
+ return result;
537
+ }
538
+ function getTeamSizeMismatch(a) {
539
+ const tier = str(a, 'scaleTier');
540
+ const expected = TIER_TEAM_SIZES[tier];
541
+ if (!expected)
542
+ return {};
543
+ const result = {};
544
+ for (const size of ['solo', '2-5', '5-15', '15+'])
545
+ if (!expected.includes(size))
546
+ result[size] = `Unusual for a ${TIER_LABEL[tier]} project`;
547
+ return result;
548
+ }
549
+ exports.INTEGRATION_CATEGORIES = [
550
+ { id: 'payments', emoji: '💳', label: 'Payments', options: ['Stripe', 'LemonSqueezy', 'Paddle', 'None'] },
551
+ { id: 'email', emoji: '📧', label: 'Email / SMS', options: ['Resend', 'SendGrid', 'Twilio', 'Postmark', 'None'] },
552
+ { id: 'storage', emoji: '🗄', label: 'File Storage', options: ['AWS S3', 'Cloudinary', 'Supabase Storage', 'Cloudflare R2', 'None'] },
553
+ { id: 'analytics', emoji: '📊', label: 'Analytics', options: ['PostHog', 'Mixpanel', 'GA4', 'None'] },
554
+ { id: 'errors', emoji: '🐛', label: 'Error Tracking', options: ['Sentry', 'Datadog', 'LogRocket', 'None'] },
555
+ { id: 'push', emoji: '🔔', label: 'Push Notifications', options: ['FCM', 'APNs', 'OneSignal', 'None'], mobileOnly: true },
556
+ { id: 'maps', emoji: '🗺', label: 'Maps', options: ['Google Maps', 'Mapbox', 'None'] },
557
+ { id: 'ai', emoji: '🤖', label: 'AI / LLM', options: ['OpenAI', 'Anthropic', 'Groq', 'HuggingFace', 'None'] },
558
+ ];
559
+ /** The integration map's keys a request may send. */
560
+ exports.INTEGRATION_CATEGORY_IDS = exports.INTEGRATION_CATEGORIES.map(c => c.id);
561
+ const CATEGORY_MAP = {
562
+ saas: ['payments', 'email', 'storage', 'analytics', 'errors', 'maps', 'ai'],
563
+ api: ['email', 'analytics', 'errors', 'ai'],
564
+ mobile: ['push', 'analytics', 'errors', 'maps', 'ai', 'storage'],
565
+ cli: ['errors', 'ai'],
566
+ pipeline: ['storage', 'errors', 'analytics'],
567
+ ml: ['storage', 'errors', 'ai'],
568
+ static: ['analytics', 'email'],
569
+ docs: ['analytics'],
570
+ extension: ['analytics', 'errors', 'ai'],
571
+ library: ['errors', 'ai'],
572
+ other: ['payments', 'email', 'storage', 'analytics', 'errors', 'push', 'maps', 'ai'],
573
+ };
574
+ function visibleCategories(category, mobile = false) {
575
+ const ids = category ? CATEGORY_MAP[category] : exports.INTEGRATION_CATEGORY_IDS;
576
+ return exports.INTEGRATION_CATEGORIES.filter(c => ids.includes(c.id) && (!c.mobileOnly || mobile));
577
+ }
578
+ /** `None` is exclusive within a category. */
579
+ function toggleIntegration(current, categoryId, option) {
580
+ const selected = current[categoryId] ?? [];
581
+ let next;
582
+ if (option === 'None')
583
+ next = selected.includes('None') ? [] : ['None'];
584
+ else {
585
+ const withoutNone = selected.filter(v => v !== 'None');
586
+ next = withoutNone.includes(option) ? withoutNone.filter(v => v !== option) : [...withoutNone, option];
587
+ }
588
+ return { ...current, [categoryId]: next };
589
+ }
590
+ /** "None of these apply": `None` in every visible category that has no pick yet. */
591
+ function noneOfThese(current, visible) {
592
+ const filled = { ...current };
593
+ for (const c of visible)
594
+ if (!filled[c.id] || filled[c.id].length === 0)
595
+ filled[c.id] = ['None'];
596
+ return filled;
597
+ }
598
+ // ---------------------------------------------------------------- constraints (constraintOptions.ts)
599
+ exports.CONSTRAINT_OPTIONS = [
600
+ { emoji: '💰', label: 'Budget cap' }, { emoji: '🏗️', label: 'Must use existing infra' }, { emoji: '📚', label: 'Team skill gaps' },
601
+ { emoji: '🕰️', label: 'Legacy system integration' }, { emoji: '⏰', label: 'Hard deadline' },
602
+ ];
603
+ exports.COMPLIANCE_OPTIONS = [
604
+ { id: 'gdpr', emoji: '🇪🇺', label: 'GDPR', description: 'You have users in the EU, or handle their personal data' },
605
+ { id: 'hipaa', emoji: '🏥', label: 'HIPAA', description: 'You store or process U.S. health/medical data' },
606
+ { id: 'soc2', emoji: '🛡️', label: 'SOC 2', description: 'You sell to businesses that require an independent security audit' },
607
+ { id: 'pci', emoji: '💳', label: 'PCI DSS', description: 'You handle credit card payments directly (not just via Stripe/etc. checkout)' },
608
+ { id: 'ccpa', emoji: '🇺🇸', label: 'CCPA', description: 'You have users in California, or handle their personal data' },
609
+ { id: 'coppa', emoji: '👶', label: 'COPPA', description: 'Your service is directed at children under 13, or you knowingly collect their data' },
610
+ { id: 'none', emoji: '➖', label: 'None' },
611
+ { id: 'unsure', emoji: '❓', label: 'Not sure → TODO', isTodo: true },
612
+ ];
613
+ const HEALTHCARE_USER_TYPES = ['Patients', 'Doctors / Clinicians'];
614
+ function getComplianceBadge(userTypes, specialConsiderations, integrations) {
615
+ const badges = {};
616
+ if (userTypes.some(u => HEALTHCARE_USER_TYPES.includes(u)))
617
+ badges.hipaa = 'recommended';
618
+ if (userTypes.includes('Children'))
619
+ badges.coppa = 'recommended';
620
+ if ((integrations.payments ?? []).some(v => v !== 'None'))
621
+ badges.pci = 'flagged';
622
+ if (specialConsiderations.includes('sensitive')) {
623
+ badges.gdpr ?? (badges.gdpr = 'recommended');
624
+ badges.ccpa ?? (badges.ccpa = 'recommended');
625
+ }
626
+ return badges;
627
+ }
628
+ exports.RESPONSE_TIME_OPTIONS = [
629
+ { id: '100ms', emoji: '⚡', label: '< 100ms' }, { id: '500ms', emoji: '🏃', label: '< 500ms' }, { id: '1s', emoji: '🚶', label: '< 1s' },
630
+ { id: 'best', emoji: '🤷', label: 'Best effort' }, { id: 'unsure', emoji: '❓', label: 'Not sure → TODO', isTodo: true },
631
+ ];
632
+ exports.AVAILABILITY_OPTIONS = [
633
+ { id: '99', emoji: '🥉', label: '99%', description: '≈ 3.65 days of downtime per year' },
634
+ { id: '99.5', emoji: '🥈', label: '99.5%', description: '≈ 1.83 days of downtime per year' },
635
+ { id: '99.9', emoji: '🥇', label: '99.9%', description: '≈ 8.76 hours of downtime per year' },
636
+ { id: '99.99', emoji: '💎', label: '99.99%', description: '≈ 52.6 minutes of downtime per year' },
637
+ { id: 'unsure', emoji: '❓', label: 'Not sure → TODO', isTodo: true },
638
+ ];
639
+ // ---------------------------------------------------------------- security (securityOptions.ts)
640
+ exports.SECURITY_CARDS = [
641
+ { id: 'encryption', emoji: '🔐', label: 'Data Encryption', description: 'Encrypt sensitive data at rest and in transit' },
642
+ { id: 'ratelimit', emoji: '🛡', label: 'Rate Limiting', description: 'Cap how many requests a client can make, to stop abuse/overload' },
643
+ { id: 'audit', emoji: '📋', label: 'Audit Logging', description: 'Record who did what and when, for accountability and incident review' },
644
+ { id: 'secrets', emoji: '🔑', label: 'Secrets Mgmt', description: 'Keep API keys/passwords out of source code, in a dedicated vault/store' },
645
+ { id: 'owasp', emoji: '🌐', label: 'OWASP Top 10 2025', description: 'Guard against the most common web vulnerabilities (SQL injection, XSS, etc.)' },
646
+ { id: 'ddos', emoji: '🚫', label: 'DDoS Protection', description: 'Defend against traffic floods meant to take your service down' },
647
+ { id: 'validation', emoji: '🔍', label: 'Input Validation', description: 'Reject malformed or malicious input before it reaches your logic' },
648
+ { id: 'intrusion', emoji: '👁', label: 'Intrusion Detection', description: 'Monitor for and alert on suspicious activity or break-in attempts' },
649
+ { id: 'promptinjection', emoji: '🧩', label: 'Prompt Injection Defense', description: 'Guard against untrusted text hijacking an LLM\'s instructions or triggering unintended actions' },
650
+ { id: 'outputfiltering', emoji: '🧹', label: 'Output Filtering', description: 'Sanitize/validate LLM output before rendering or acting on it, so it can\'t inject scripts or leak data' },
651
+ ];
652
+ exports.AI_ONLY_SECURITY_IDS = ['promptinjection', 'outputfiltering'];
653
+ exports.TESTING_OPTIONS = [
654
+ { id: 'unit', label: 'Unit tests', description: 'Tests individual functions/components in isolation, fast and focused' },
655
+ { id: 'integration', label: 'Integration tests', description: 'Tests multiple parts working together (e.g. API + database)' },
656
+ { id: 'e2e', label: 'E2E tests', description: 'End-to-end - simulates a real user clicking through the whole app' },
657
+ { id: 'load', label: 'Load / perf tests', description: 'Simulates heavy traffic to find performance limits and bottlenecks' },
658
+ { id: 'security', label: 'Security scans', description: 'Automated checks for known vulnerabilities and misconfigurations' },
659
+ { id: 'none', label: 'None for now' },
660
+ { id: 'unsure', label: 'Not sure → TODO', isTodo: true },
661
+ ];
662
+ exports.CICD_OPTIONS = [
663
+ { id: 'github', label: 'GitHub Actions' }, { id: 'gitlab', label: 'GitLab CI' }, { id: 'circle', label: 'CircleCI' },
664
+ { id: 'cloudflare', label: 'Cloudflare Pages (built-in)' }, { id: 'vercel', label: 'Vercel (built-in)' }, { id: 'netlify', label: 'Netlify (built-in)' },
665
+ { id: 'railway', label: 'Railway (built-in)' }, { id: 'none', label: 'None', emoji: '➖' }, { id: 'unsure', label: 'Not sure → TODO', emoji: '❓', isTodo: true },
666
+ ];
667
+ const CICD_BY_DEPLOY_TARGET = { Vercel: 'vercel', Netlify: 'netlify', Railway: 'railway', 'Cloudflare Pages': 'cloudflare', 'Cloudflare Workers': 'cloudflare' };
668
+ function getCicdBadge(deploymentTargets) {
669
+ const match = deploymentTargets.map(t => CICD_BY_DEPLOY_TARGET[t]).find(Boolean);
670
+ return match ? { [match]: 'recommended' } : {};
671
+ }
672
+ exports.CHAT_STEPS = ['Project identity', 'Platform & IDE', 'Target users', 'Scale & deploy', 'Architecture & data', 'Integrations', 'Constraints & non-goals', 'Security & NFR'];
673
+ /** Every question key in the chat's order, with its step (index into CHAT_STEPS). The parent folder is the page's own. */
674
+ exports.CHAT_KEYS = [
675
+ ['parent', 0], ['projectDescription', 0], ['projectType', 0], ['handle', 0],
676
+ ['platforms', 1], ['language', 1], ['framework', 1], ['ide', 1],
677
+ ['userTypes', 2], ['accessControl', 2], ['specialConsiderations', 2], ['accessibilityNotes', 2],
678
+ ['scaleTier', 3], ['activeUsers', 3], ['deploymentTargets', 3], ['buildTimeline', 3], ['teamSize', 3],
679
+ ['systemPattern', 4], ['apiParadigm', 4], ['databases', 4], ['authStrategy', 4], ['realtimeTypes', 4], ['localDatabases', 4], ['dataSyncStrategy', 4],
680
+ ['integrations', 5], ['otherApis', 5],
681
+ ['nonGoals', 6], ['technicalConstraints', 6], ['constraintDescription', 6], ['compliance', 6], ['apiResponseTime', 6], ['availability', 6],
682
+ ['securityConcerns', 7], ['testingStrategy', 7], ['cicd', 7],
683
+ ];
684
+ /** The TODO answer of the non-goals question. */
685
+ exports.TODO = '__todo__';
686
+ /** Each key the page sends: the 23 optional fields of REQ-002.I.4, their kind and longest text. */
687
+ exports.OPTIONAL_FIELD_LIMITS = {
688
+ platforms: { kind: 'list', max: 100 }, accessControl: { kind: 'text', max: 100 }, specialConsiderations: { kind: 'list', max: 100 },
689
+ accessibilityNotes: { kind: 'text', max: 1000 }, systemPattern: { kind: 'text', max: 100 }, activeUsers: { kind: 'text', max: 100 },
690
+ teamSize: { kind: 'text', max: 100 }, deploymentTargets: { kind: 'list', max: 100 }, localDatabases: { kind: 'list', max: 100 },
691
+ dataSyncStrategy: { kind: 'text', max: 100 }, integrations: { kind: 'map', max: 100 }, otherApis: { kind: 'text', max: 1000 },
692
+ apiResponseTime: { kind: 'text', max: 100 }, availability: { kind: 'text', max: 100 }, databases: { kind: 'list', max: 100 },
693
+ authStrategy: { kind: 'text', max: 100 }, realtimeTypes: { kind: 'list', max: 100 }, compliance: { kind: 'list', max: 100 },
694
+ cicd: { kind: 'list', max: 100 }, securityConcerns: { kind: 'list', max: 100 }, buildTimeline: { kind: 'text', max: 100 },
695
+ constraintDescription: { kind: 'text', max: 1000 }, testingStrategy: { kind: 'list', max: 100 },
696
+ };
697
+ /** Most items in one list (and in one integration category). */
698
+ exports.MAX_LIST_ITEMS = 25;
699
+ /**
700
+ * The files each answer changes, spec-relative inside `.specs/` (checked against `render()` by a test).
701
+ * The context answers fill `development/onboarding.md` for Greenfield only.
702
+ */
703
+ exports.FIELD_FILES = {
704
+ platforms: ['project/project.yaml'],
705
+ accessControl: ['project/requirements.md'], specialConsiderations: ['project/requirements.md'], accessibilityNotes: ['project/requirements.md'],
706
+ systemPattern: ['architecture/architecture.md'], activeUsers: ['architecture/architecture.md'], teamSize: ['architecture/architecture.md'],
707
+ deploymentTargets: ['architecture/architecture.md'], localDatabases: ['architecture/architecture.md'], dataSyncStrategy: ['architecture/architecture.md'],
708
+ integrations: ['architecture/architecture.md', 'security/threat-model.md'], otherApis: ['architecture/architecture.md'],
709
+ apiResponseTime: ['architecture/architecture.md'], availability: ['architecture/architecture.md'],
710
+ databases: ['architecture/api.yaml'], authStrategy: ['architecture/api.yaml', 'security/security-decisions.md'], realtimeTypes: ['architecture/api.yaml'],
711
+ compliance: ['security/security-decisions.md'], cicd: ['security/security-decisions.md'], securityConcerns: ['security/threat-model.md'],
712
+ buildTimeline: ['planning/roadmap.md'], constraintDescription: ['development/context.md'], testingStrategy: ['quality/tests.md'],
713
+ whatItDoes: ['development/onboarding.md'], targetUsers: ['development/onboarding.md'], expectedScale: ['development/onboarding.md'], constraints: ['development/onboarding.md'],
714
+ projectType: ['development/onboarding.md'], apiParadigm: ['architecture/api.yaml'],
715
+ };
716
+ /** Which context answer each folded question is sent in. */
717
+ const FOLDED_INTO = {
718
+ projectDescription: 'whatItDoes', userTypes: 'targetUsers', scaleTier: 'expectedScale', nonGoals: 'constraints', technicalConstraints: 'constraints',
719
+ };
720
+ /** The caption: `For a & b & c`, `For <n> files`, or '' for none. */
721
+ function captionText(files) {
722
+ if (!files.length)
723
+ return '';
724
+ return files.length > 3 ? `For ${files.length} files` : `For ${files.join(' & ')}`;
725
+ }
726
+ const opts = (arr) => arr.map(o => ({ id: o.id ?? o.label, label: o.label, emoji: o.emoji, description: o.description, group: o.group, todo: o.isTodo, badge: o.badge }));
727
+ const cap = (a) => getCapabilities(a.projectCategory);
728
+ const desc = (a) => str(a, 'projectDescription').toLowerCase();
729
+ /** The App's own rule: `api.yaml` is the only home of databases and realtime, written after `rest` and `graphql` only. */
730
+ const apiYamlHolds = (a) => ['rest', 'graphql'].includes(str(a, 'apiParadigm'));
731
+ const CORE = {
732
+ projectDescription: {
733
+ type: 'tabbed-chips', required: true, label: 'Description', cli: 'whatItDoes',
734
+ placeholder: 'A CRM for boutique gyms to manage members, book classes, and handle recurring billing',
735
+ options: () => exports.STARTER_GROUPS.flatMap(g => g.items.map(i => ({ id: i.label, label: i.label, emoji: i.emoji, group: g.group }))),
736
+ chat: "Describe it in plain words. As detailed or as brief as you like — I'll gather the rest.",
737
+ },
738
+ platforms: {
739
+ type: 'platform-grid', label: 'Platforms',
740
+ options: a => platformGridGroups(a.projectCategory, list(a, 'platforms'))
741
+ .flatMap(g => exports.PLATFORM_GROUPS.find(x => x.group === g).items.map(i => ({ id: i.id, label: i.label, emoji: i.emoji, description: `[${i.lang}]`, group: g }))),
742
+ chat: 'Which platforms should this run on? Pick everything that applies.',
743
+ },
744
+ userTypes: {
745
+ type: 'grouped-multi', label: 'User types', cli: 'targetUsers', custom: true,
746
+ options: a => [
747
+ ...visibleUserTypeGroups(a.projectCategory).flatMap(g => g.items.map(i => ({ id: i.label, label: i.label, emoji: i.emoji, group: g.group }))),
748
+ { id: exports.TODO, label: 'Not sure yet → TODO', emoji: '❓', todo: true },
749
+ ],
750
+ chat: "Who's going to use this system? Pick everything that applies.",
751
+ },
752
+ accessControl: {
753
+ type: 'choice', required: true, label: 'Access control', options: () => opts(exports.ACCESS_OPTIONS),
754
+ chat: "What's the access control model? This drives the security spec's auth/authorization section and the app's permission model.",
755
+ },
756
+ specialConsiderations: {
757
+ type: 'multi', label: 'Special considerations',
758
+ options: a => opts(exports.SPECIAL_OPTIONS.filter(o => cap(a).hasGraphicalUI || o.id !== 'a11y')),
759
+ chat: 'Any special considerations - accessibility, i18n, offline support?',
760
+ },
761
+ accessibilityNotes: {
762
+ type: 'text', label: 'Accessibility notes', placeholder: 'e.g. Screen reader support, right-to-left layout…',
763
+ chat: 'Anything else on accessibility or constraints worth noting? Optional.',
764
+ },
765
+ scaleTier: {
766
+ type: 'cards', required: true, label: 'Scale tier', cli: 'expectedScale',
767
+ options: () => exports.SCALE_TIERS.map(t => ({ id: t.id, label: t.title, emoji: t.emoji, description: t.description, badge: t.badge })),
768
+ chat: "What's the expected scale? This drives infrastructure and architecture choices.",
769
+ },
770
+ activeUsers: {
771
+ type: 'choice', required: true, label: 'Active users', options: () => opts(exports.USER_RANGES), warnings: getActiveUsersMismatch,
772
+ chat: 'Roughly how many active users are you expecting?',
773
+ },
774
+ deploymentTargets: {
775
+ type: 'multi', label: 'Deploy targets', custom: true,
776
+ options: a => opts(deployTargetOptions(a.projectCategory, list(a, 'platforms'))),
777
+ badges: a => {
778
+ const target = list(a, 'platforms').map(p => exports.BAAS_DEPLOY_TARGET[p]).find(Boolean);
779
+ return target ? { [target]: 'recommended' } : {};
780
+ },
781
+ warnings: getDeployTargetMismatch,
782
+ seed: a => {
783
+ const target = list(a, 'platforms').map(p => exports.BAAS_DEPLOY_TARGET[p]).find(Boolean);
784
+ return target && cap(a).distribution === 'hosting' ? [target] : undefined;
785
+ },
786
+ chat: a => {
787
+ const dist = cap(a).distribution;
788
+ if (dist === 'registry')
789
+ return 'Where will you publish this - which package registries?';
790
+ if (dist === 'appstore')
791
+ return 'Where will you publish this - which extension stores?';
792
+ return "Where's this going to deploy? Pick everything that applies.";
793
+ },
794
+ },
795
+ buildTimeline: { type: 'choice', required: true, label: 'Timeline', options: () => opts(exports.TIMELINES), chat: "What's the build timeline?" },
796
+ teamSize: { type: 'choice', required: true, label: 'Team size', options: () => opts(exports.TEAM_SIZES), warnings: getTeamSizeMismatch, chat: 'How big is the team building this?' },
797
+ systemPattern: {
798
+ type: 'cards', required: true, label: 'Pattern',
799
+ options: () => exports.SYSTEM_PATTERNS.map(p => ({ id: p.id, label: p.title, emoji: p.emoji, description: p.description })),
800
+ badges: a => getArchBadge(str(a, 'scaleTier'), str(a, 'teamSize')),
801
+ skip: a => !cap(a).hasServer,
802
+ skipNote: a => `Skipping architecture pattern, database, auth, and real-time questions - a ${desc(a)} doesn't typically need a backend. Tap your project description above to change it if that's wrong.`,
803
+ chat: 'One deployable app, or split into services? Pick an architecture pattern - monolith, modular monolith, or microservices.',
804
+ },
805
+ databases: {
806
+ type: 'multi', label: 'Database', custom: true, options: () => opts(exports.DATABASES),
807
+ warnings: getDatabaseMismatch, badges: a => (0, exports.getDatabaseBadge)(list(a, 'platforms')),
808
+ skip: a => !cap(a).hasServer || !apiYamlHolds(a),
809
+ chat: 'Database preference? Pick as many as apply - SQL (structured, related tables), NoSQL (flexible, document-based), a cache/key-value store, or vector - whatever fits your data.',
810
+ },
811
+ authStrategy: {
812
+ type: 'choice', label: 'Auth strategy', custom: true, options: () => opts(exports.AUTH_OPTIONS), badges: a => (0, exports.getAuthBadge)(list(a, 'platforms')),
813
+ skip: a => !cap(a).hasServer,
814
+ chat: 'Auth strategy? Build it yourself with a protocol (JWT/OAuth/SAML), or use a managed service (Clerk/Auth0/Firebase/etc.) - this feeds the security spec\'s auth section.',
815
+ },
816
+ realtimeTypes: {
817
+ type: 'multi', label: 'Realtime', options: () => opts(exports.REALTIME_TYPES), warnings: getRealtimeMismatch,
818
+ skip: a => !cap(a).hasServer || !apiYamlHolds(a),
819
+ chat: 'Does anything need to update live without a refresh - chat, dashboards, notifications? If so, pick how (WebSockets, SSE, polling).',
820
+ },
821
+ localDatabases: {
822
+ type: 'multi', label: 'Offline', custom: true, options: a => opts(getLocalDatabaseOptions(list(a, 'platforms'))),
823
+ skip: a => !cap(a).hasGraphicalUI,
824
+ chat: 'Does this need to work offline? If so, pick what stores data locally on the device.',
825
+ },
826
+ dataSyncStrategy: {
827
+ type: 'choice', label: 'Data sync', options: () => opts(exports.DATA_SYNC_STRATEGIES),
828
+ skip: a => !cap(a).hasGraphicalUI || list(a, 'localDatabases').length === 0,
829
+ chat: 'How should conflicting local and server state get reconciled once the device is back online?',
830
+ },
831
+ integrations: {
832
+ type: 'categorized', label: 'Integrations',
833
+ chat: 'Any third-party integrations I should plan for? Only categories relevant to your project type are shown.',
834
+ },
835
+ otherApis: {
836
+ type: 'text', label: 'Other APIs', placeholder: 'e.g. Twilio for SMS, Mapbox for maps…',
837
+ chat: 'Any other external APIs or services not listed above? Optional.',
838
+ },
839
+ nonGoals: {
840
+ type: 'text', required: true, label: 'Non-goals', todo: exports.TODO, cli: 'constraints',
841
+ placeholder: 'e.g. No mobile app in v1. No offline mode. No multi-language support initially.',
842
+ chat: 'What will this project explicitly NOT do?',
843
+ },
844
+ technicalConstraints: {
845
+ type: 'multi', label: 'Technical constraints', options: () => opts(exports.CONSTRAINT_OPTIONS),
846
+ chat: 'Any technical constraints - budget, existing infra, legacy systems, a hard deadline?',
847
+ },
848
+ constraintDescription: {
849
+ type: 'text', label: 'Constraint detail', placeholder: 'Describe the constraint…',
850
+ skip: a => list(a, 'technicalConstraints').length === 0,
851
+ chat: 'Can you say a bit more about that constraint?',
852
+ },
853
+ compliance: {
854
+ type: 'multi', label: 'Compliance', custom: true, options: () => opts(exports.COMPLIANCE_OPTIONS),
855
+ badges: a => getComplianceBadge(list(a, 'userTypes'), list(a, 'specialConsiderations'), map(a, 'integrations')),
856
+ chat: 'Any compliance requirements - GDPR, HIPAA, SOC 2? Getting this wrong has real legal consequences, so pick by your situation (EU users, health data, payments) below, not the regulation name.',
857
+ },
858
+ apiResponseTime: {
859
+ type: 'choice', label: 'Response time', options: () => opts(exports.RESPONSE_TIME_OPTIONS),
860
+ skip: a => !cap(a).hasServer,
861
+ skipNote: a => `Skipping response-time and availability SLA questions too - not hosted-service concepts for a ${desc(a)}.`,
862
+ chat: 'Any API response-time target?',
863
+ },
864
+ availability: {
865
+ type: 'choice', label: 'Availability', options: () => opts(exports.AVAILABILITY_OPTIONS), skip: a => !cap(a).hasServer,
866
+ chat: 'Availability SLA target - what fraction of the time does this need to be up? Higher percentages mean much less allowed downtime per year.',
867
+ },
868
+ securityConcerns: {
869
+ type: 'multi', label: 'Security concerns',
870
+ options: a => opts(aiSelected(a) ? exports.SECURITY_CARDS : exports.SECURITY_CARDS.filter(c => !exports.AI_ONLY_SECURITY_IDS.includes(c.id))),
871
+ chat: 'Any security concerns to plan for - encryption, rate limiting, audit logging?',
872
+ },
873
+ testingStrategy: { type: 'multi', label: 'Testing strategy', options: () => opts(exports.TESTING_OPTIONS), chat: 'Testing strategy?' },
874
+ cicd: {
875
+ type: 'multi', label: 'CI/CD', options: () => opts(exports.CICD_OPTIONS), badges: a => getCicdBadge(list(a, 'deploymentTargets')),
876
+ chat: 'CI / CD - automatically running tests and deploying on every code change. Pick everything that applies.',
877
+ },
878
+ };
879
+ const greenfield = (a) => (a.projectType ?? 'greenfield') === 'greenfield';
880
+ /** Whether a core question is asked at all in this mode (before the skip rules). */
881
+ function inMode(key, a, mode) {
882
+ if (key === 'projectDescription')
883
+ return mode === 'new';
884
+ if (key === 'userTypes' || key === 'scaleTier' || key === 'nonGoals')
885
+ return mode === 'new' && greenfield(a);
886
+ return true;
887
+ }
888
+ const asArray = (v) => (Array.isArray(v) ? v : []);
889
+ /** A core answer as the bubble shows it. */
890
+ function coreText(key, def, value, options) {
891
+ const label = (id) => {
892
+ const o = options.find(x => x.id === id) ?? (def.type === 'platform-grid' ? exports.PLATFORM_GROUPS.flatMap(g => g.items).find(i => i.id === id) : undefined);
893
+ return o ? (o.emoji ? `${o.emoji} ${o.label}` : o.label) : id;
894
+ };
895
+ if (def.type === 'text' || def.type === 'tabbed-chips') {
896
+ if (def.todo && value === def.todo)
897
+ return 'Not sure - skip for now (TODO)';
898
+ return typeof value === 'string' && value.trim() ? value.trim() : 'Skipped';
899
+ }
900
+ if (def.type === 'choice' || def.type === 'cards')
901
+ return typeof value === 'string' && value ? label(value) : 'Skipped';
902
+ if (def.type === 'categorized') {
903
+ const entries = Object.entries((value ?? {})).filter(([, v]) => v.length && !(v.length === 1 && v[0] === 'None'));
904
+ return entries.length ? entries.map(([k, v]) => `${exports.INTEGRATION_CATEGORIES.find(c => c.id === k)?.label ?? k}: ${v.filter(x => x !== 'None').join(', ')}`).join(' · ') : 'None';
905
+ }
906
+ const arr = asArray(value);
907
+ if (key === 'userTypes' && arr.includes(exports.TODO) && arr.length === 1)
908
+ return 'Not sure yet (TODO)';
909
+ return arr.length ? arr.map(label).join(' · ') : 'None';
910
+ }
911
+ /** Whether a stored core answer still fits its question (an option filtered away since is asked again). */
912
+ function coreAnswered(def, value, options) {
913
+ if (value === undefined)
914
+ return false;
915
+ const ids = options.map(o => o.id);
916
+ if (def.type === 'text' || def.type === 'tabbed-chips')
917
+ return typeof value === 'string' && (!def.required || value.trim() !== '');
918
+ if (def.type === 'choice' || def.type === 'cards') {
919
+ if (typeof value !== 'string')
920
+ return false;
921
+ if (value === '')
922
+ return !def.required;
923
+ return ids.includes(value) || !!def.custom;
924
+ }
925
+ if (def.type === 'categorized')
926
+ return !!value && typeof value === 'object';
927
+ if (!Array.isArray(value))
928
+ return false;
929
+ if (def.type === 'platform-grid')
930
+ return value.every(v => PLATFORM_GROUP[v] !== undefined);
931
+ return value.every(v => ids.includes(v) || !!def.custom);
932
+ }
933
+ const withBadges = (options, badges, warnings) => options.map(o => ({ ...o, badge: badges[o.id] ?? o.badge, warning: warnings[o.id] }));
934
+ /**
935
+ * The questions to ask now, in the chat's order: the core's, and the server's CLI questions (`cli`, as
936
+ * `route.flowQuestions()` leaves them) in their places with their badges, seeds and notes. `all` is every
937
+ * question the server sent (the context questions lend their message to the folded ones and are not asked
938
+ * themselves); `parent` is the page's own first question of a new project.
939
+ */
940
+ function chatQuestions(all, cli, a, mode, outside = {}) {
941
+ const message = (key) => all.find(q => q.key === key)?.message ?? '';
942
+ const out = [];
943
+ let pending = [];
944
+ const hints = languageHints(list(a, 'platforms'), typeof a.language === 'string' ? a.language : undefined);
945
+ for (const [key, stepIndex] of exports.CHAT_KEYS) {
946
+ const step = exports.CHAT_STEPS[stepIndex];
947
+ const def = CORE[key];
948
+ if (!def) {
949
+ const q = cli.find(x => x.key === key);
950
+ if (!q)
951
+ continue;
952
+ const extra = {};
953
+ if (key === 'language') {
954
+ extra.badges = Object.fromEntries(hints.languages.map(l => [l, 'recommended']));
955
+ extra.seed = hints.language;
956
+ extra.note = hints.note || undefined;
957
+ }
958
+ else if (key === 'framework') {
959
+ extra.badges = Object.fromEntries(hints.frameworks.map(f => [f, 'recommended']));
960
+ extra.seed = hints.framework;
961
+ }
962
+ else if (key === 'apiParadigm') {
963
+ extra.badges = getApiBadge(str(a, 'scaleTier'), str(a, 'projectDescription'));
964
+ const c = cap(a);
965
+ if (!c.hasServer)
966
+ extra.seed = a.projectCategory === 'cli' ? 'cli' : 'none';
967
+ extra.type = 'cards';
968
+ }
969
+ else if (key === 'ide')
970
+ extra.type = 'cards';
971
+ const choice = q.choices?.find(c => c.value === a[key]);
972
+ const answered = key in a && (!q.choices || !!choice);
973
+ const files = key === 'ide' ? outside[String(choice?.value ?? q.choices?.[0]?.value)] ?? []
974
+ : key === 'projectType' && mode === 'setup' ? [] : exports.FIELD_FILES[key] ?? [];
975
+ out.push({
976
+ ...q,
977
+ type: q.choices ? 'choice' : 'text',
978
+ ...extra,
979
+ key, step, core: false, chat: q.chat ?? '', message: q.message, label: q.label ?? key, required: q.required ?? false,
980
+ notesBefore: pending, answered,
981
+ text: q.choices ? (choice ? choice.name.split(' — ')[0] : '') : String(a[key] ?? '').trim() || 'Skipped',
982
+ files, caption: captionText(files),
983
+ });
984
+ pending = [];
985
+ continue;
986
+ }
987
+ if (!inMode(key, a, mode))
988
+ continue;
989
+ if (def.skip?.(a)) {
990
+ if (def.skipNote)
991
+ pending.push(def.skipNote(a));
992
+ continue;
993
+ }
994
+ let options = def.options?.(a);
995
+ if (options)
996
+ options = withBadges(options, def.badges?.(a) ?? {}, def.warnings?.(a) ?? {});
997
+ const fold = FOLDED_INTO[key];
998
+ const sentAs = fold ? (mode === 'new' && greenfield(a) ? fold : null) : key;
999
+ const q = {
1000
+ key, step, core: true, type: def.type,
1001
+ chat: typeof def.chat === 'function' ? def.chat(a) : def.chat,
1002
+ message: def.cli ? message(def.cli) : '',
1003
+ label: def.label, required: !!def.required, placeholder: def.placeholder, options, custom: def.custom, todo: def.todo,
1004
+ seed: def.seed?.(a), notesBefore: pending,
1005
+ answered: coreAnswered(def, a[key], options ?? []),
1006
+ text: coreText(key, def, a[key], options ?? []),
1007
+ files: sentAs ? exports.FIELD_FILES[sentAs] ?? [] : [],
1008
+ caption: captionText(sentAs ? exports.FIELD_FILES[sentAs] ?? [] : []),
1009
+ };
1010
+ if (key === 'platforms') {
1011
+ q.tabs = platformGridGroups(a.projectCategory, list(a, 'platforms'));
1012
+ q.note = bundleLine(list(a, 'platforms')) || undefined;
1013
+ q.noteAfter = getPlatformNote(list(a, 'platforms'))?.text;
1014
+ }
1015
+ if (key === 'integrations') {
1016
+ q.categories = visibleCategories(a.projectCategory, hasMobilePlatform(list(a, 'platforms')))
1017
+ .map(c => ({ id: c.id, label: c.label, emoji: c.emoji, options: c.options }));
1018
+ }
1019
+ out.push(q);
1020
+ pending = [];
1021
+ }
1022
+ return out;
1023
+ }
1024
+ /** What storing `value` for a question changes: the value, and for the description the category (the web's toPatch). */
1025
+ function answerPatch(key, value, a) {
1026
+ if (key === 'projectDescription') {
1027
+ const description = String(value);
1028
+ const inferred = inferProjectCategory(description);
1029
+ return { projectDescription: description, projectCategory: description.trim() === '' ? null : (inferred ?? a.projectCategory ?? null) };
1030
+ }
1031
+ return { [key]: value };
1032
+ }
1033
+ const same = (x, y) => JSON.stringify(x) === JSON.stringify(y);
1034
+ /**
1035
+ * Replace stale seeds: an answer that still equals the seed it was given (`seeded`, which the page records
1036
+ * when the user continues with the seed unchanged) is replaced by the question's seed now, when that differs.
1037
+ */
1038
+ function reseed(questions, a, seeded) {
1039
+ const answers = { ...a };
1040
+ const next = { ...seeded };
1041
+ for (const q of questions) {
1042
+ if (!(q.key in next))
1043
+ continue;
1044
+ if (!same(answers[q.key], next[q.key])) {
1045
+ delete next[q.key];
1046
+ continue;
1047
+ }
1048
+ if (q.seed !== undefined && !same(q.seed, answers[q.key])) {
1049
+ answers[q.key] = q.seed;
1050
+ next[q.key] = q.seed;
1051
+ }
1052
+ }
1053
+ return { answers, seeded: next };
1054
+ }
1055
+ /** The labels to send for a stored choice: TODO choices dropped, ids shown as their labels, free entries as typed. */
1056
+ function labelsOf(q, ids) {
1057
+ return ids
1058
+ .filter(id => !q.options?.find(o => o.id === id)?.todo && id !== exports.TODO)
1059
+ .map(id => q.options?.find(o => o.id === id)?.label ?? id)
1060
+ .map(s => s.trim())
1061
+ .filter(Boolean);
1062
+ }
1063
+ /**
1064
+ * The optional fields and the folded context answers to send, from the asked questions (REQ-002.H.28): labels,
1065
+ * no TODO choices, no `None` inside an integration category; the four folds for a Greenfield new project only.
1066
+ */
1067
+ function requestFields(questions, a, mode) {
1068
+ const body = {};
1069
+ const asked = (key) => questions.find(q => q.key === key && q.core);
1070
+ for (const key of Object.keys(exports.OPTIONAL_FIELD_LIMITS)) {
1071
+ const q = asked(key);
1072
+ if (!q)
1073
+ continue;
1074
+ const value = a[key];
1075
+ if (key === 'integrations') {
1076
+ const m = Object.fromEntries(Object.entries(map(a, key)).map(([k, v]) => [k, v.filter(x => x !== 'None')]).filter(([, v]) => v.length));
1077
+ if (Object.keys(m).length)
1078
+ body[key] = m;
1079
+ }
1080
+ else if (q.type === 'text') {
1081
+ if (typeof value === 'string' && value.trim())
1082
+ body[key] = value.trim();
1083
+ }
1084
+ else if (q.type === 'choice' || q.type === 'cards') {
1085
+ const v = typeof value === 'string' ? labelsOf(q, [value]) : [];
1086
+ if (v.length)
1087
+ body[key] = v[0];
1088
+ }
1089
+ else {
1090
+ const v = labelsOf(q, asArray(value));
1091
+ if (v.length)
1092
+ body[key] = v;
1093
+ }
1094
+ }
1095
+ if (mode === 'new' && greenfield(a)) {
1096
+ const userTypes = asked('userTypes');
1097
+ const tier = exports.SCALE_TIERS.find(t => t.id === a.scaleTier);
1098
+ const nonGoals = str(a, 'nonGoals') === exports.TODO ? '' : str(a, 'nonGoals').trim();
1099
+ const tc = asked('technicalConstraints') ? labelsOf(asked('technicalConstraints'), list(a, 'technicalConstraints')) : [];
1100
+ body.whatItDoes = str(a, 'projectDescription').trim();
1101
+ body.targetUsers = userTypes ? labelsOf(userTypes, list(a, 'userTypes')).join(', ') : '';
1102
+ body.expectedScale = tier ? `${tier.title} (${tier.description})` : '';
1103
+ body.constraints = [nonGoals, tc.length ? `Technical constraints: ${tc.join(', ')}.` : ''].filter(Boolean).join(' ');
1104
+ }
1105
+ return body;
1106
+ }
1107
+ //# sourceMappingURL=chatFlow.js.map