UNPKG

context-forge

Version:

AI orchestration platform with autonomous teams, enhancement planning, migration tools, 25+ slash commands, checkpoints & hooks. Multi-IDE: Claude, Cursor, Windsurf, Cline, Copilot

204 lines (196 loc) • 7.63 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.prdInput = prdInput; const inquirer_1 = __importDefault(require("inquirer")); const chalk_1 = __importDefault(require("chalk")); const fs_extra_1 = __importDefault(require("fs-extra")); const path_1 = __importDefault(require("path")); const validator_1 = require("../../utils/validator"); async function prdInput() { console.log(chalk_1.default.blue('\nšŸ“ Step 3 of 7: Product Requirements')); console.log(chalk_1.default.gray("Define what you're building and why.\n")); const { hasPRD } = await inquirer_1.default.prompt([ { type: 'confirm', name: 'hasPRD', message: 'Do you have an existing Product Requirements Document (PRD)?', default: false, }, ]); if (hasPRD) { const { inputMethod } = await inquirer_1.default.prompt([ { type: 'list', name: 'inputMethod', message: 'How would you like to provide the PRD?', choices: [ { name: 'āœļø Type/paste it here', value: 'type' }, { name: 'šŸ“ Load from file (prd.md)', value: 'file' }, { name: 'šŸ§žā€ā™‚ļø Create one through guided questions', value: 'guided' }, ], }, ]); switch (inputMethod) { case 'type': return await typePRD(); case 'file': return await loadPRDFromFile(); case 'guided': return await guidedPRD(); } } // If no PRD, use guided questions return await guidedPRD(); } async function typePRD() { console.log(chalk_1.default.yellow('\nšŸ“ Paste your PRD content')); console.log(chalk_1.default.gray('This will open your default editor. Save and close when done.\n')); const { prdContent } = await inquirer_1.default.prompt([ { type: 'editor', name: 'prdContent', message: 'PRD content:', validate: validator_1.validatePRD, }, ]); console.log(chalk_1.default.green('āœ“ PRD content loaded\n')); return { content: prdContent, }; } async function loadPRDFromFile() { console.log(chalk_1.default.yellow('\nšŸ“ Load PRD from file')); const { filePath } = await inquirer_1.default.prompt([ { type: 'input', name: 'filePath', message: 'Path to PRD file:', default: 'prd.md', validate: async (input) => { const resolvedPath = path_1.default.resolve(input); const exists = await fs_extra_1.default.pathExists(resolvedPath); if (!exists) { return `File not found: ${resolvedPath}`; } const stats = await fs_extra_1.default.stat(resolvedPath); if (!stats.isFile()) { return 'Path must be a file, not a directory'; } return true; }, }, ]); try { const content = await fs_extra_1.default.readFile(path_1.default.resolve(filePath), 'utf-8'); console.log(chalk_1.default.green(`āœ“ PRD loaded from ${filePath}\n`)); return { content, }; } catch (error) { throw new Error(`Failed to read PRD file: ${error instanceof Error ? error.message : String(error)}`); } } async function guidedPRD() { console.log(chalk_1.default.yellow('\nšŸŽÆ Create PRD through guided questions')); console.log(chalk_1.default.gray('Answer a few questions to generate a comprehensive PRD.\n')); const answers = await inquirer_1.default.prompt([ { type: 'input', name: 'problemStatement', message: 'What problem does this solve?', validate: (input) => input.length > 10 || 'Please provide a detailed problem statement (min 10 characters)', transformer: (input) => { if (input.length > 20) return chalk_1.default.green(input); if (input.length > 10) return chalk_1.default.yellow(input); return input; }, }, { type: 'input', name: 'targetUsers', message: 'Who are the target users?', validate: (input) => input.length > 5 || 'Please describe your target users (min 5 characters)', transformer: (input) => { if (input.length > 15) return chalk_1.default.green(input); if (input.length > 5) return chalk_1.default.yellow(input); return input; }, }, { type: 'editor', name: 'userStories', message: 'What are the main user stories? (one per line)', validate: (input) => input.trim().length > 0 || 'Please provide at least one user story', }, { type: 'editor', name: 'coreFeatures', message: 'List the core features (one per line):', validate: (input) => input.trim().length > 0 || 'Please list at least one core feature', }, { type: 'input', name: 'successMetrics', message: 'How will you measure success?', default: 'User engagement, task completion rate, user satisfaction', }, { type: 'list', name: 'scope', message: 'Project scope:', choices: [ { name: 'šŸŽÆ MVP - Essential features only', value: 'mvp' }, { name: 'šŸš€ Standard - Core features + nice-to-haves', value: 'standard' }, { name: 'šŸŽ† Full Product - All features', value: 'full' }, ], }, ]); // Parse user stories const userStories = answers.userStories .split('\n') .map((story) => story.trim()) .filter((story) => story.length > 0); // Parse core features const coreFeatures = answers.coreFeatures .split('\n') .map((feature) => feature.trim()) .filter((feature) => feature.length > 0); // Generate PRD content const content = `# Product Requirements Document ## Problem Statement ${answers.problemStatement} ## Target Users ${answers.targetUsers} ## User Stories ${userStories.map((story) => `- ${story}`).join('\n')} ## Core Features ${coreFeatures.map((feature) => `- ${feature}`).join('\n')} ## Success Metrics ${answers.successMetrics} ## Project Scope ${answers.scope === 'mvp' ? 'MVP - Essential features only' : answers.scope === 'standard' ? 'Standard - Core features + nice-to-haves' : 'Full Product - All features'} ## Technical Requirements - Must be scalable and maintainable - Should follow best practices for the chosen tech stack - Must include proper error handling and logging - Should have comprehensive testing coverage ## Timeline Based on the ${answers.scope} scope, estimated timeline will be determined during implementation planning. `; console.log(chalk_1.default.green('\nāœ“ PRD generated successfully\n')); return { content, problemStatement: answers.problemStatement, targetUsers: answers.targetUsers, userStories, }; } //# sourceMappingURL=prdInput.js.map