shipdeck
Version:
Ship MVPs in 48 hours. Fix bugs in 30 seconds. The command deck for developers who ship.
1,039 lines (908 loc) • 31.5 kB
JavaScript
/**
* Rapid Prototyper Agent for Shipdeck Ultimate
* Specializes in quickly creating MVPs, proof-of-concepts, and demo applications within 6-day sprints
*/
const { BaseAgent } = require('./base-agent');
class RapidPrototyper extends BaseAgent {
constructor(options = {}) {
super({
name: 'RapidPrototyper',
description: 'Specialized agent for rapid MVP development, proof-of-concepts, and demo applications with 6-day sprint cycles',
version: '1.0.0',
...options
});
// Rapid prototyping configuration
this.prototypingConfig = {
framework: 'next-js',
database: 'sqlite', // Fast setup for prototypes
styling: 'tailwindcss',
deployment: 'vercel', // Quick deployment
authentication: 'clerk', // Rapid auth setup
stateManagement: 'zustand', // Lightweight state management
sprintDays: 6,
prioritizeSpeed: true,
includeBasicTests: true,
includeDocumentation: true,
...options.prototypingConfig
};
// Template collections for rapid development
this.templates = this.initializeTemplates();
// Common prototype patterns
this.prototypePatterns = this.initializePrototypePatterns();
}
/**
* Get rapid prototyper capabilities
* @returns {Array<string>} Array of prototyping capabilities
*/
getCapabilities() {
return ['prototype', 'mvp', 'scaffold', 'demo', 'poc'];
}
/**
* Initialize rapid development templates
* @returns {Object} Templates organized by prototype type
*/
initializeTemplates() {
return {
mvp: {
landingPage: this.getMVPLandingPageTemplate(),
dashboard: this.getMVPDashboardTemplate(),
authFlow: this.getMVPAuthTemplate(),
crudOperations: this.getMVPCrudTemplate(),
apiEndpoints: this.getMVPAPITemplate()
},
demo: {
interactiveDemo: this.getInteractiveDemoTemplate(),
productShowcase: this.getProductShowcaseTemplate(),
featureDemo: this.getFeatureDemoTemplate()
},
scaffold: {
projectStructure: this.getProjectScaffoldTemplate(),
configFiles: this.getConfigFilesTemplate(),
packageSetup: this.getPackageSetupTemplate()
},
poc: {
conceptValidation: this.getConceptValidationTemplate(),
integrationTest: this.getIntegrationTestTemplate(),
performanceTest: this.getPerformanceTestTemplate()
}
};
}
/**
* Initialize common prototype patterns for different industries/use cases
* @returns {Object} Prototype patterns organized by category
*/
initializePrototypePatterns() {
return {
saas: {
name: 'SaaS Application',
components: ['landing', 'auth', 'dashboard', 'billing', 'settings'],
estimatedDays: 5,
techStack: ['Next.js', 'Prisma', 'Stripe', 'Clerk']
},
ecommerce: {
name: 'E-commerce Store',
components: ['storefront', 'cart', 'checkout', 'admin', 'inventory'],
estimatedDays: 6,
techStack: ['Next.js', 'Stripe', 'Tailwind', 'Zustand']
},
social: {
name: 'Social Platform',
components: ['feed', 'profiles', 'messaging', 'posts', 'notifications'],
estimatedDays: 6,
techStack: ['Next.js', 'Socket.io', 'Prisma', 'Clerk']
},
portfolio: {
name: 'Portfolio/Agency Site',
components: ['hero', 'projects', 'about', 'contact', 'blog'],
estimatedDays: 3,
techStack: ['Next.js', 'Tailwind', 'MDX', 'Framer Motion']
},
productivity: {
name: 'Productivity Tool',
components: ['workspace', 'tasks', 'calendar', 'collaboration', 'reports'],
estimatedDays: 5,
techStack: ['Next.js', 'Prisma', 'Real-time sync', 'Charts']
}
};
}
/**
* Execute rapid prototyping task
* @param {Object} task - Task configuration
* @param {Object} context - Execution context
* @returns {Promise<Object>} Generated prototype structure and code
*/
async execute(task, context = {}) {
this.log('info', `Executing rapid prototype task: ${task.type}`, { task: task.type });
try {
switch (task.type) {
case 'prototype':
return await this.createPrototype(task, context);
case 'mvp':
return await this.createMVP(task, context);
case 'scaffold':
return await this.scaffoldProject(task, context);
case 'demo':
return await this.createDemo(task, context);
case 'poc':
return await this.createProofOfConcept(task, context);
default:
return await this.createCustomPrototype(task, context);
}
} catch (error) {
this.log('error', `Rapid prototyping task failed: ${error.message}`, { error: error.stack });
throw error;
}
}
/**
* Create a rapid prototype based on specifications
* @param {Object} task - Task configuration
* @param {Object} context - Execution context
* @returns {Promise<Object>} Generated prototype
*/
async createPrototype(task, context) {
const prompt = this.createPrototypePrompt(task, context);
const response = await this.sendMessage(prompt, {
maxTokens: 12288,
temperature: 0.4
});
if (!response.success) {
throw new Error(`Prototype creation failed: ${response.error}`);
}
return this.parsePrototypeResponse(response.content, 'prototype');
}
/**
* Create a Minimum Viable Product (MVP)
* @param {Object} task - Task configuration
* @param {Object} context - Execution context
* @returns {Promise<Object>} Generated MVP structure
*/
async createMVP(task, context) {
const prompt = this.createMVPPrompt(task, context);
const response = await this.sendMessage(prompt, {
maxTokens: 16384,
temperature: 0.3
});
if (!response.success) {
throw new Error(`MVP creation failed: ${response.error}`);
}
return this.parsePrototypeResponse(response.content, 'mvp');
}
/**
* Scaffold a new project structure
* @param {Object} task - Task configuration
* @param {Object} context - Execution context
* @returns {Promise<Object>} Generated project scaffold
*/
async scaffoldProject(task, context) {
const prompt = this.createScaffoldPrompt(task, context);
const response = await this.sendMessage(prompt, {
maxTokens: 10240,
temperature: 0.2
});
if (!response.success) {
throw new Error(`Project scaffolding failed: ${response.error}`);
}
return this.parsePrototypeResponse(response.content, 'scaffold');
}
/**
* Create a demo application
* @param {Object} task - Task configuration
* @param {Object} context - Execution context
* @returns {Promise<Object>} Generated demo application
*/
async createDemo(task, context) {
const prompt = this.createDemoPrompt(task, context);
const response = await this.sendMessage(prompt, {
maxTokens: 10240,
temperature: 0.5
});
if (!response.success) {
throw new Error(`Demo creation failed: ${response.error}`);
}
return this.parsePrototypeResponse(response.content, 'demo');
}
/**
* Create a proof of concept
* @param {Object} task - Task configuration
* @param {Object} context - Execution context
* @returns {Promise<Object>} Generated proof of concept
*/
async createProofOfConcept(task, context) {
const prompt = this.createPocPrompt(task, context);
const response = await this.sendMessage(prompt, {
maxTokens: 8192,
temperature: 0.3
});
if (!response.success) {
throw new Error(`Proof of concept creation failed: ${response.error}`);
}
return this.parsePrototypeResponse(response.content, 'poc');
}
/**
* Create custom prototype based on specific requirements
* @param {Object} task - Task configuration
* @param {Object} context - Execution context
* @returns {Promise<Object>} Generated custom prototype
*/
async createCustomPrototype(task, context) {
const prompt = this.createCustomPrototypePrompt(task, context);
const response = await this.sendMessage(prompt, {
maxTokens: 12288,
temperature: 0.4
});
if (!response.success) {
throw new Error(`Custom prototype creation failed: ${response.error}`);
}
return this.parsePrototypeResponse(response.content, 'custom');
}
/**
* Get system prompt for rapid prototyper
* @returns {string} System prompt
*/
getSystemPrompt() {
return `You are RapidPrototyper, a specialized AI agent for creating MVPs, prototypes, and demo applications.
CORE MISSION:
Build working prototypes and MVPs that can be shipped within 6-day sprint cycles.
Prioritize speed and functionality over perfection. Focus on core features that validate the concept.
EXPERTISE:
- Next.js 14+ with App Router for rapid full-stack development
- TypeScript for type safety without complexity
- Tailwind CSS for rapid styling
- SQLite/Prisma for quick database setup
- Clerk for instant authentication
- Vercel for one-click deployment
- Zustand for lightweight state management
- React Hook Form for fast form handling
- Shadcn/ui for pre-built components
RAPID DEVELOPMENT PRINCIPLES:
1. **MVP First**: Build only essential features for initial validation
2. **Speed Over Perfection**: Working prototype beats perfect architecture
3. **Proven Stack**: Use battle-tested, quick-setup technologies
4. **Copy & Adapt**: Leverage templates and patterns for common use cases
5. **Minimal Config**: Reduce setup time with sensible defaults
6. **Deploy Early**: Get prototypes online ASAP for feedback
7. **Iterate Fast**: Plan for rapid changes based on user feedback
8. **Document Decisions**: Record key choices for future development
6-DAY SPRINT STRUCTURE:
- Day 1: Project setup, core architecture, auth
- Day 2-3: Main features development
- Day 4: UI polish, basic error handling
- Day 5: Testing, deployment, documentation
- Day 6: Buffer for fixes, final polish
PROTOTYPE CATEGORIES:
1. **MVP**: Full functional application with core features
2. **Demo**: Interactive showcase of key functionality
3. **POC**: Technical validation of concepts/integrations
4. **Scaffold**: Project structure with basic setup
5. **Prototype**: Working model with essential features
TECH STACK DEFAULTS:
- Framework: Next.js 14 (App Router)
- Database: SQLite + Prisma (for prototypes)
- Auth: Clerk (quickest setup)
- Styling: Tailwind CSS + Shadcn/ui
- State: Zustand (lightweight)
- Forms: React Hook Form
- Deployment: Vercel
- Testing: Vitest + Testing Library
OUTPUT REQUIREMENTS:
Generate complete, working code that includes:
1. Project structure with proper folder organization
2. Configuration files (package.json, tsconfig, etc.)
3. Environment setup instructions
4. Core components with TypeScript interfaces
5. Basic error handling and loading states
6. Responsive design (mobile-first)
7. Essential tests for critical paths
8. Deployment configuration
9. README with setup and usage instructions
10. Next steps for further development
Always provide working, deployable code that can be set up and running within 1 hour.`;
}
/**
* Create prototype generation prompt
* @param {Object} task - Task configuration
* @param {Object} context - Execution context
* @returns {string} Formatted prompt
*/
createPrototypePrompt(task, context) {
const pattern = this.selectPrototypePattern(task);
return `${this.getSystemPrompt()}
TASK: Create Rapid Prototype
PROTOTYPE SPECIFICATION:
- Name: ${task.name || 'Prototype App'}
- Type: ${task.prototypeType || 'web-app'}
- Target Users: ${task.targetUsers || 'General users'}
- Core Purpose: ${task.purpose || 'Validate concept and gather feedback'}
- Timeline: ${task.timeline || '6 days'}
${pattern ? `SUGGESTED PATTERN: ${pattern.name}
Estimated Development: ${pattern.estimatedDays} days
Components: ${pattern.components.join(', ')}
Tech Stack: ${pattern.techStack.join(', ')}` : ''}
CORE FEATURES (Priority Order):
${task.features ? task.features.map((f, i) => `${i + 1}. ${f}`).join('\n') : '1. Basic user interface\n2. Core functionality\n3. User feedback collection'}
TECHNICAL REQUIREMENTS:
${task.requirements ? task.requirements.map(r => `- ${r}`).join('\n') : '- Responsive design\n- Fast loading times\n- Simple deployment'}
${task.description ? `DESCRIPTION: ${task.description}` : ''}
CONTEXT:
${this.formatContextPrompt(context)}
Generate a complete rapid prototype with:
1. Project structure optimized for speed
2. Essential features implementation
3. Basic UI with responsive design
4. Quick deployment configuration
5. Setup and usage documentation
6. Testing strategy for core features
7. Performance optimizations
8. Error handling and user feedback
9. Analytics integration for user insights
10. Iteration plan for improvements
Focus on getting a working prototype deployed and testable within the first 3 days of development.`;
}
/**
* Create MVP generation prompt
* @param {Object} task - Task configuration
* @param {Object} context - Execution context
* @returns {string} Formatted prompt
*/
createMVPPrompt(task, context) {
const pattern = this.selectPrototypePattern(task);
return `${this.getSystemPrompt()}
TASK: Create Minimum Viable Product (MVP)
MVP SPECIFICATION:
- Product Name: ${task.productName || 'MVP Application'}
- Market: ${task.market || 'General market'}
- Value Proposition: ${task.valueProposition || 'Solve user problems efficiently'}
- Target Launch: ${task.launchDate || '6 days from start'}
- Business Model: ${task.businessModel || 'Freemium'}
${pattern ? `PATTERN MATCH: ${pattern.name}
Components Required: ${pattern.components.join(', ')}
Recommended Stack: ${pattern.techStack.join(', ')}` : ''}
MUST-HAVE FEATURES (MVP Core):
${task.mustHaveFeatures ? task.mustHaveFeatures.map((f, i) => `${i + 1}. ${f}`).join('\n') : '1. User registration/login\n2. Core workflow\n3. Basic dashboard\n4. Payment processing (if applicable)'}
NICE-TO-HAVE FEATURES (Post-MVP):
${task.niceToHaveFeatures ? task.niceToHaveFeatures.map((f, i) => `${i + 1}. ${f}`).join('\n') : '1. Advanced analytics\n2. Social features\n3. Mobile app\n4. Integrations'}
BUSINESS REQUIREMENTS:
- User Analytics: ${task.needsAnalytics !== false ? 'Required' : 'Optional'}
- Payment Processing: ${task.needsPayments ? 'Required' : 'Optional'}
- User Management: ${task.needsUserManagement !== false ? 'Required' : 'Optional'}
- Email Notifications: ${task.needsEmails !== false ? 'Required' : 'Optional'}
${task.description ? `PRODUCT DESCRIPTION: ${task.description}` : ''}
CONTEXT:
${this.formatContextPrompt(context)}
Generate a production-ready MVP with:
1. Complete application architecture
2. User authentication and management
3. Core business logic implementation
4. Payment integration (if needed)
5. Admin panel for management
6. Email notifications system
7. Analytics and tracking
8. SEO optimization
9. Performance monitoring
10. Deployment and scaling configuration
11. User onboarding flow
12. Feedback collection system
13. Documentation for users and developers
14. Legal pages (privacy, terms)
15. Launch checklist and marketing assets
Ensure the MVP can handle real users and generate revenue from day one.`;
}
/**
* Create project scaffolding prompt
* @param {Object} task - Task configuration
* @param {Object} context - Execution context
* @returns {string} Formatted prompt
*/
createScaffoldPrompt(task, context) {
return `${this.getSystemPrompt()}
TASK: Scaffold Project Structure
PROJECT SPECIFICATION:
- Project Name: ${task.projectName || 'new-project'}
- Type: ${task.projectType || 'web-app'}
- Framework: ${task.framework || this.prototypingConfig.framework}
- Database: ${task.database || this.prototypingConfig.database}
- Authentication: ${task.auth || this.prototypingConfig.authentication}
FEATURES TO SCAFFOLD:
${task.features ? task.features.map(f => `- ${f}`).join('\n') : '- Basic routing\n- Database setup\n- Authentication\n- UI components'}
${task.description ? `DESCRIPTION: ${task.description}` : ''}
CONTEXT:
${this.formatContextPrompt(context)}
Generate a complete project scaffold with:
1. Proper folder structure
2. Configuration files (package.json, tsconfig, tailwind.config, etc.)
3. Environment setup (.env.example, .env.local)
4. Database schema and migrations
5. Basic routing structure
6. Authentication setup
7. UI component library setup
8. Testing configuration
9. Build and deployment scripts
10. Documentation (README, CONTRIBUTING, etc.)
11. Git configuration (.gitignore, etc.)
12. ESLint and Prettier configuration
13. Basic error handling setup
14. Development workflow scripts
${this.templates.scaffold.projectStructure}`;
}
/**
* Create demo application prompt
* @param {Object} task - Task configuration
* @param {Object} context - Execution context
* @returns {string} Formatted prompt
*/
createDemoPrompt(task, context) {
return `${this.getSystemPrompt()}
TASK: Create Demo Application
DEMO SPECIFICATION:
- Demo Name: ${task.demoName || 'Feature Demo'}
- Purpose: ${task.purpose || 'Showcase key features'}
- Audience: ${task.audience || 'Potential users and stakeholders'}
- Demo Type: ${task.demoType || 'interactive'}
- Duration: ${task.duration || '5 minutes'}
FEATURES TO DEMONSTRATE:
${task.features ? task.features.map((f, i) => `${i + 1}. ${f}`).join('\n') : '1. Core functionality\n2. User interface\n3. Key workflows'}
DEMO REQUIREMENTS:
- Interactive Elements: ${task.interactive !== false ? 'Yes' : 'No'}
- Sample Data: ${task.needsSampleData !== false ? 'Include realistic data' : 'Use minimal data'}
- Mobile Responsive: ${task.responsive !== false ? 'Yes' : 'No'}
- Offline Capable: ${task.offline || false ? 'Yes' : 'No'}
${task.description ? `DESCRIPTION: ${task.description}` : ''}
CONTEXT:
${this.formatContextPrompt(context)}
Generate an engaging demo application with:
1. Landing page explaining the demo
2. Interactive feature walkthrough
3. Sample data that shows real-world usage
4. Guided tour or onboarding flow
5. Responsive design for all devices
6. Fast loading and smooth interactions
7. Clear call-to-actions
8. Analytics to track demo engagement
9. Feedback collection mechanism
10. Social sharing capabilities
11. Mobile-optimized experience
12. Accessibility features
${this.templates.demo.interactiveDemo}`;
}
/**
* Create proof of concept prompt
* @param {Object} task - Task configuration
* @param {Object} context - Execution context
* @returns {string} Formatted prompt
*/
createPocPrompt(task, context) {
return `${this.getSystemPrompt()}
TASK: Create Proof of Concept
POC SPECIFICATION:
- Concept: ${task.concept || 'Technical validation'}
- Hypothesis: ${task.hypothesis || 'Concept is technically feasible'}
- Success Criteria: ${task.successCriteria || 'Working implementation'}
- Technical Challenge: ${task.challenge || 'Integration complexity'}
VALIDATION REQUIREMENTS:
${task.validationPoints ? task.validationPoints.map((p, i) => `${i + 1}. ${p}`).join('\n') : '1. Technical feasibility\n2. Performance benchmarks\n3. Integration possibilities'}
TECHNICAL CONSTRAINTS:
${task.constraints ? task.constraints.map(c => `- ${c}`).join('\n') : '- Limited development time\n- Quick validation needed\n- Minimal viable implementation'}
${task.description ? `DESCRIPTION: ${task.description}` : ''}
CONTEXT:
${this.formatContextPrompt(context)}
Generate a focused proof of concept with:
1. Minimal viable implementation
2. Clear success/failure criteria
3. Performance benchmarking
4. Integration test points
5. Documentation of findings
6. Recommendations for full development
7. Risk assessment and mitigation
8. Technical architecture decisions
9. Next steps roadmap
10. Lessons learned summary
${this.templates.poc.conceptValidation}`;
}
/**
* Create custom prototype prompt
* @param {Object} task - Task configuration
* @param {Object} context - Execution context
* @returns {string} Formatted prompt
*/
createCustomPrototypePrompt(task, context) {
return `${this.getSystemPrompt()}
TASK: ${task.type}
CUSTOM REQUIREMENTS:
${task.description ? task.description : 'Create custom prototype based on specifications'}
SPECIFICATIONS:
${task.specifications ? task.specifications.map(s => `- ${s}`).join('\n') : '- Follow rapid prototyping principles'}
${task.features ? `FEATURES:\n${task.features.map(f => `- ${f}`).join('\n')}` : ''}
CONTEXT:
${this.formatContextPrompt(context)}
Generate a custom prototype following rapid development best practices.`;
}
/**
* Select appropriate prototype pattern based on task
* @param {Object} task - Task configuration
* @returns {Object|null} Selected pattern or null
*/
selectPrototypePattern(task) {
const keywords = (task.description || '').toLowerCase();
if (keywords.includes('saas') || keywords.includes('software as a service')) {
return this.prototypePatterns.saas;
}
if (keywords.includes('ecommerce') || keywords.includes('e-commerce') || keywords.includes('store')) {
return this.prototypePatterns.ecommerce;
}
if (keywords.includes('social') || keywords.includes('community') || keywords.includes('network')) {
return this.prototypePatterns.social;
}
if (keywords.includes('portfolio') || keywords.includes('agency') || keywords.includes('showcase')) {
return this.prototypePatterns.portfolio;
}
if (keywords.includes('productivity') || keywords.includes('task') || keywords.includes('management')) {
return this.prototypePatterns.productivity;
}
return null;
}
/**
* Parse rapid prototyping response and structure it
* @param {string} response - AI response
* @param {string} type - Response type
* @returns {Object} Structured prototype result
*/
parsePrototypeResponse(response, type) {
try {
const parsed = JSON.parse(response);
return {
type: 'structured',
category: type,
prototype: parsed,
files: this.extractFileList(parsed),
sprintPlan: this.generateSprintPlan(parsed, type),
deploymentPlan: this.generateDeploymentPlan(parsed),
timestamp: new Date().toISOString(),
estimatedDevelopmentTime: this.estimateTimeRequired(parsed, type)
};
} catch {
const codeBlocks = this.extractCodeBlocks(response);
return {
type: 'text',
category: type,
content: response,
codeBlocks,
sprintPlan: this.generateBasicSprintPlan(type),
timestamp: new Date().toISOString()
};
}
}
/**
* Extract file list from structured response
* @param {Object} parsed - Parsed response
* @returns {Array} List of files
*/
extractFileList(parsed) {
const files = [];
const traverse = (obj, prefix = '') => {
for (const [key, value] of Object.entries(obj)) {
if (typeof value === 'string' && key.includes('.')) {
files.push(prefix + key);
} else if (typeof value === 'object' && value !== null) {
traverse(value, prefix + key + '/');
}
}
};
traverse(parsed);
return files;
}
/**
* Generate sprint plan based on prototype type
* @param {Object} prototype - Prototype structure
* @param {string} type - Prototype type
* @returns {Object} Sprint plan
*/
generateSprintPlan(prototype, type) {
const basePlan = {
totalDays: this.prototypingConfig.sprintDays,
dailyTasks: {},
milestones: [],
deliverables: []
};
switch (type) {
case 'mvp':
return {
...basePlan,
dailyTasks: {
1: ['Project setup', 'Authentication', 'Database schema'],
2: ['Core features development', 'API endpoints'],
3: ['UI development', 'State management'],
4: ['Integration testing', 'Error handling'],
5: ['Deployment setup', 'Performance optimization'],
6: ['Final testing', 'Documentation', 'Launch preparation']
},
milestones: ['Day 1: Foundation', 'Day 3: Core Features', 'Day 5: Production Ready', 'Day 6: Launch'],
deliverables: ['Working MVP', 'Documentation', 'Deployment Pipeline', 'Launch Plan']
};
case 'demo':
return {
...basePlan,
totalDays: 3,
dailyTasks: {
1: ['Demo structure', 'Sample data', 'Core interactions'],
2: ['UI polish', 'Guided tour', 'Mobile optimization'],
3: ['Testing', 'Deployment', 'Analytics setup']
},
milestones: ['Day 1: Basic Demo', 'Day 2: Polished Experience', 'Day 3: Production Demo'],
deliverables: ['Interactive Demo', 'Demo Documentation', 'Analytics Dashboard']
};
default:
return basePlan;
}
}
/**
* Generate deployment plan
* @param {Object} prototype - Prototype structure
* @returns {Object} Deployment plan
*/
generateDeploymentPlan(prototype) {
return {
platform: 'vercel',
steps: [
'Connect GitHub repository',
'Configure environment variables',
'Set up domain (optional)',
'Configure database connection',
'Deploy to production',
'Set up monitoring and analytics'
],
environmentVariables: [
'DATABASE_URL',
'NEXTAUTH_SECRET',
'NEXTAUTH_URL',
'CLERK_SECRET_KEY (if using Clerk)'
],
estimatedDeploymentTime: '15 minutes'
};
}
/**
* Estimate time required for development
* @param {Object} prototype - Prototype structure
* @param {string} type - Prototype type
* @returns {string} Time estimate
*/
estimateTimeRequired(prototype, type) {
const baseTime = {
'mvp': '5-6 days',
'demo': '2-3 days',
'scaffold': '0.5-1 day',
'poc': '1-2 days',
'prototype': '3-4 days'
};
return baseTime[type] || '3-4 days';
}
/**
* Generate basic sprint plan for text responses
* @param {string} type - Response type
* @returns {Object} Basic sprint plan
*/
generateBasicSprintPlan(type) {
return {
totalDays: this.prototypingConfig.sprintDays,
focus: `Rapid ${type} development`,
approach: 'Iterative development with daily deployments'
};
}
/**
* Extract code blocks from text response
* @param {string} text - Response text
* @returns {Array} Array of code blocks
*/
extractCodeBlocks(text) {
const codeBlockRegex = /```(\w+)?\n([\s\S]*?)```/g;
const blocks = [];
let match;
while ((match = codeBlockRegex.exec(text)) !== null) {
blocks.push({
language: match[1] || 'typescript',
code: match[2].trim(),
filename: this.guessFilename(match[2], match[1])
});
}
return blocks;
}
/**
* Guess filename from code content and language
* @param {string} code - Code content
* @param {string} language - Programming language
* @returns {string} Guessed filename
*/
guessFilename(code, language) {
// Simple heuristics to guess filename
if (code.includes('export default') && language === 'typescript') {
const componentMatch = code.match(/const\s+(\w+):/);
if (componentMatch) {
return `${componentMatch[1]}.tsx`;
}
}
if (code.includes('package.json')) return 'package.json';
if (code.includes('tailwind.config')) return 'tailwind.config.js';
if (code.includes('next.config')) return 'next.config.js';
const extensions = {
javascript: '.js',
typescript: '.ts',
tsx: '.tsx',
jsx: '.jsx',
json: '.json',
css: '.css',
html: '.html'
};
return `file${extensions[language] || '.txt'}`;
}
// Template methods
getMVPLandingPageTemplate() {
return `
MVP Landing Page Template:
- Hero section with value proposition
- Feature highlights
- Social proof/testimonials
- CTA for signup/demo
- Responsive design
- SEO optimization
`;
}
getMVPDashboardTemplate() {
return `
MVP Dashboard Template:
- User authentication required
- Key metrics overview
- Primary action buttons
- Recent activity feed
- Navigation sidebar
- Settings access
`;
}
getMVPAuthTemplate() {
return `
MVP Authentication Template:
- Sign up/sign in forms
- Social login options
- Password reset flow
- Email verification
- User profile management
- Session handling
`;
}
getMVPCrudTemplate() {
return `
MVP CRUD Operations Template:
- Create new items
- Read/view items list
- Update item details
- Delete items
- Search and filter
- Pagination
`;
}
getMVPAPITemplate() {
return `
MVP API Template:
- RESTful endpoints
- Authentication middleware
- Input validation
- Error handling
- Rate limiting
- API documentation
`;
}
getInteractiveDemoTemplate() {
return `
Interactive Demo Template:
- Welcome screen with overview
- Guided walkthrough
- Interactive elements
- Progress indicators
- Sample data
- Call-to-action at end
`;
}
getProductShowcaseTemplate() {
return `
Product Showcase Template:
- Product hero section
- Feature demonstrations
- Use case examples
- Comparison tables
- Pricing information
- Contact forms
`;
}
getFeatureDemoTemplate() {
return `
Feature Demo Template:
- Feature introduction
- Step-by-step demonstration
- Benefits highlighting
- Interactive elements
- Usage examples
- Next steps guidance
`;
}
getProjectScaffoldTemplate() {
return `
Project Scaffold Structure:
/
├── src/
│ ├── app/
│ ├── components/
│ ├── lib/
│ └── types/
├── public/
├── package.json
├── tsconfig.json
├── tailwind.config.js
├── next.config.js
└── README.md
`;
}
getConfigFilesTemplate() {
return `
Configuration Files Template:
- package.json with dependencies
- tsconfig.json for TypeScript
- tailwind.config.js for styling
- next.config.js for Next.js
- .env.example for environment variables
- .gitignore for Git
`;
}
getPackageSetupTemplate() {
return `
Package Setup Template:
- Next.js framework
- TypeScript configuration
- Tailwind CSS for styling
- Prisma for database
- Auth provider (Clerk/NextAuth)
- UI component library
- Testing framework
`;
}
getConceptValidationTemplate() {
return `
Concept Validation Template:
- Hypothesis statement
- Success criteria definition
- Test implementation
- Results measurement
- Performance benchmarks
- Conclusion and recommendations
`;
}
getIntegrationTestTemplate() {
return `
Integration Test Template:
- External API connections
- Database operations
- Authentication flows
- Error handling
- Performance under load
- Edge case scenarios
`;
}
getPerformanceTestTemplate() {
return `
Performance Test Template:
- Load time measurements
- Response time benchmarks
- Memory usage analysis
- Database query optimization
- CDN effectiveness
- Mobile performance
`;
}
/**
* Cleanup resources and log completion
*/
cleanup() {
this.log('info', 'Rapid Prototyper cleanup completed', {
prototypesCreated: this.prototypesCreated || 0,
averageTime: this.averageTime || 'N/A'
});
}
}
module.exports = RapidPrototyper;