Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 32 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 38 additions & 2 deletions scripts/generate-prd.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ function parseArgs() {
context: {},
model: 'claude',
interactive: false,
help: false
help: false,
projectType: 'web-app'
};

for (let i = 0; i < args.length; i++) {
Expand Down Expand Up @@ -99,6 +100,11 @@ function parseArgs() {
options.model = next;
i++;
break;
case '--project-type':
case '-t':
options.projectType = next;
i++;
break;
Comment on lines +103 to +107
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing input validation for project type. The code accepts any string value for --project-type but only handles 'web-app', 'api', and 'cli'. Invalid values (e.g., 'webapp', 'backend', or typos) will silently default to showing the web-app checklist, which could be confusing.

Add validation to check if the provided value is one of the accepted values ('web-app', 'api', 'cli') and show an error message with valid options if not.

Copilot uses AI. Check for mistakes.
case '--interactive':
case '-I':
options.interactive = true;
Expand Down Expand Up @@ -132,6 +138,7 @@ ${colors.bright}Options:${colors.reset}
--output, -o Output file path (default: PRD-{timestamp}.md)
--context, -c Additional context (JSON string or file)
--model, -m AI model to use (claude|gpt4|gemini, default: claude)
--project-type, -t Project type: web-app|api|cli (default: web-app)
--help, -h Show this help message

${colors.bright}Context JSON Format:${colors.reset}
Expand Down Expand Up @@ -176,6 +183,7 @@ async function interactiveMode() {

console.log(`\n${colors.dim}Optional context (press Enter to skip):${colors.reset}`);

const projectTypeInput = await question(`${colors.yellow}Project type (web-app/api/cli, default: web-app):${colors.reset} `);
const targetAudience = await question(`${colors.yellow}Target Audience:${colors.reset} `);
const businessGoals = await question(`${colors.yellow}Business Goals:${colors.reset} `);
const technicalConstraints = await question(`${colors.yellow}Technical Constraints:${colors.reset} `);
Expand All @@ -187,6 +195,7 @@ async function interactiveMode() {
rl.close();

const context = {};
context.projectType = projectTypeInput || 'web-app';
Comment on lines 186 to 198
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing input validation in interactive mode. The user can enter any string for project type, but only 'web-app', 'api', and 'cli' are valid. Invalid values will silently default to web-app behavior without warning the user.

Consider validating the input and re-prompting if an invalid value is entered, or at least show a warning that the input will be treated as 'web-app'.

Copilot uses AI. Check for mistakes.
if (targetAudience) context.targetAudience = targetAudience;
if (businessGoals) context.businessGoals = businessGoals;
if (technicalConstraints) context.technicalConstraints = technicalConstraints;
Expand All @@ -200,10 +209,30 @@ async function interactiveMode() {
};
}

// Generate Vercel production-readiness section based on project type
function generateVercelSection(projectType) {
const isNonWebApp = projectType === 'api' || projectType === 'cli';
if (isNonWebApp) {
const kind = projectType === 'api' ? 'backend API' : 'CLI';
return `> **N/A** \u2014 This is a ${kind} project and is not applicable for Vercel web deployment. Vercel hosts web apps (e.g., Next.js, Vite); ${projectType === 'api' ? 'API' : 'CLI'} projects should be deployed to their own appropriate runtime (e.g., Base44 serverless functions, Docker, cloud run).`;
Comment on lines +214 to +217
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function is case-sensitive and doesn't handle common variations. For example, 'API' (uppercase), 'Web-App' (capitalized), or 'CLI' (uppercase) would all be treated as web-app. This could be confusing for users.

Consider normalizing the input by converting to lowercase before comparison, or accept common case variations explicitly.

Suggested change
const isNonWebApp = projectType === 'api' || projectType === 'cli';
if (isNonWebApp) {
const kind = projectType === 'api' ? 'backend API' : 'CLI';
return `> **N/A** \u2014 This is a ${kind} project and is not applicable for Vercel web deployment. Vercel hosts web apps (e.g., Next.js, Vite); ${projectType === 'api' ? 'API' : 'CLI'} projects should be deployed to their own appropriate runtime (e.g., Base44 serverless functions, Docker, cloud run).`;
const normalizedType = (projectType || '').toString().trim().toLowerCase();
const isNonWebApp = normalizedType === 'api' || normalizedType === 'cli';
if (isNonWebApp) {
const kind = normalizedType === 'api' ? 'backend API' : 'CLI';
const label = normalizedType === 'api' ? 'API' : 'CLI';
return `> **N/A** \u2014 This is a ${kind} project and is not applicable for Vercel web deployment. Vercel hosts web apps (e.g., Next.js, Vite); ${label} projects should be deployed to their own appropriate runtime (e.g., Base44 serverless functions, Docker, cloud run).`;

Copilot uses AI. Check for mistakes.
}
return [
'- [ ] `vercel.json` present and configured (framework, buildCommand, outputDirectory)',
'- [ ] Environment variables defined in Vercel dashboard (not hard-coded)',
'- [ ] Preview deployments enabled for pull requests',
'- [ ] Production domain configured with valid SSL certificate',
'- [ ] Security headers set (X-Content-Type-Options, X-Frame-Options, Referrer-Policy)',
'- [ ] `rewrites` / `redirects` configured for SPA routing (e.g., `/api/:path*`)',
'- [ ] Edge network region(s) selected appropriate for target audience',
'- [ ] Build passes locally with `npm run build` (output to `dist/` or configured `outputDirectory`)',
'- [ ] No secrets committed to source; all sensitive values use Vercel environment variable references',
].join('\n');
}

// Generate PRD using local AI template (fallback without API)
function generatePRDTemplate(featureIdea, context = {}) {
const timestamp = new Date().toISOString().split('T')[0];

const vercelSection = generateVercelSection(context.projectType || 'web-app');
return `# Product Requirements Document (PRD)

**Feature:** ${featureIdea}
Expand Down Expand Up @@ -576,6 +605,10 @@ ${context.existingIntegrations ? `- ${context.existingIntegrations.split(',').jo
5. Investigate root cause
6. Fix and redeploy

### 12.5 Vercel Production-Readiness

${vercelSection}

---

## 13. Assumptions, Risks & Open Questions
Expand Down Expand Up @@ -670,6 +703,9 @@ async function main() {
}

context = options.context;
if (!context.projectType) {
context.projectType = options.projectType;
}
outputFile = options.output;
}

Expand Down
Loading