UNPKG

faf-cli

Version:

😽 TURBO-CAT: The Rapid Catalytic Converter • Project DNA ✨ for ANY AI • Fully Integrated with React, Next.js, Svelte, TypeScript, Vite & n8n • FREE FOREVER • 10,000+ developers • Championship Edition

192 lines 9.11 kB
"use strict"; /** * ⚡ FAF Quick - Lightning-fast .faf creation * One-liner format for instant context generation */ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.quickCommand = quickCommand; const colors_1 = require("../fix-once/colors"); const fs_1 = require("fs"); const path = __importStar(require("path")); const faf_generator_championship_1 = require("../generators/faf-generator-championship"); const championship_style_1 = require("../utils/championship-style"); const file_utils_1 = require("../utils/file-utils"); const universal_fuzzy_detector_1 = require("../utils/universal-fuzzy-detector"); /** * Quick format parser - accepts simple comma-separated values * Format: "project name, what it does, main language, framework, where deployed" * Example: "my-app, e-commerce platform, typescript, react, vercel" */ function parseQuickInput(input) { const parts = input.split(',').map(s => s.trim()); // Minimum 2 parts required (name and description) if (parts.length < 2) { throw new Error('Need at least: project-name, description'); } // Use fuzzy detection on each part const projectGoal = parts[1] || 'Build amazing software'; const languageInput = parts[2] || 'TypeScript'; const frameworkInput = parts[3] || 'none'; // Detect project type from goal with fuzzy matching const projectTypeDetection = universal_fuzzy_detector_1.UniversalFuzzyDetector.detectProjectType(projectGoal); const languageDetection = universal_fuzzy_detector_1.UniversalFuzzyDetector.detectLanguage(languageInput); // Log if fuzzy matching helped if (projectTypeDetection.corrected) { console.log(colors_1.chalk.yellow(` 📝 Auto-corrected: "${parts[1]}" → "${projectTypeDetection.corrected}"`)); } if (languageDetection.corrected) { console.log(colors_1.chalk.yellow(` 📝 Auto-corrected: "${languageInput}" → "${languageDetection.type}"`)); } return { projectName: parts[0] || 'my-project', projectGoal: projectGoal, // Keep original goal text projectType: projectTypeDetection.type || 'general', mainLanguage: languageDetection.type || languageInput, framework: frameworkInput, hosting: parts[4] || 'cloud', // Auto-detect additional context slotBasedPercentage: 60, fafScore: 60, // Include detection info for logging _detections: { projectType: projectTypeDetection, language: languageDetection } }; } async function quickCommand(input, options = {}) { const startTime = Date.now(); try { console.log(); console.log(championship_style_1.FAF_COLORS.fafCyan(`${championship_style_1.FAF_ICONS.lightning} FAF Quick Mode`)); // If no input provided, show usage if (!input) { console.log(); console.log(championship_style_1.FAF_COLORS.fafWhite('Usage:')); console.log(championship_style_1.FAF_COLORS.fafCyan(' faf quick "project-name, description, language, framework, hosting"')); console.log(); console.log(championship_style_1.FAF_COLORS.fafWhite('Examples:')); console.log(colors_1.chalk.gray(' faf quick "my-app, e-commerce platform, typescript, react, vercel"')); console.log(colors_1.chalk.gray(' faf quick "api-service, REST API for mobile app, python, fastapi, aws"')); console.log(colors_1.chalk.gray(' faf quick "cli-tool, developer productivity tool, go"')); console.log(); console.log(championship_style_1.FAF_COLORS.fafOrange('💡 Minimum: name and description. Rest is auto-detected!')); return; } const projectRoot = process.cwd(); const outputPath = path.join(projectRoot, '.faf'); // Check if .faf exists if (await (0, file_utils_1.fileExists)(outputPath) && !options.force) { console.log(championship_style_1.FAF_COLORS.fafOrange(`⚠️ .faf file already exists`)); console.log(colors_1.chalk.yellow(' Use --force to overwrite or "faf edit" to modify')); return; } // Parse the quick input const projectData = parseQuickInput(input); console.log(colors_1.chalk.gray(` Creating .faf for: ${projectData.projectName}`)); // Generate .faf content const detectedType = detectProjectTypeFromQuick(projectData); console.log(colors_1.chalk.gray(` Detected project type: ${detectedType}`)); const fafContent = await (0, faf_generator_championship_1.generateFafFromProject)({ projectType: detectedType, outputPath, projectRoot, ...projectData }); // Write the file await fs_1.promises.writeFile(outputPath, fafContent, 'utf-8'); const elapsedTime = Date.now() - startTime; console.log(); console.log(championship_style_1.FAF_COLORS.fafGreen(`☑️ Created .faf in ${elapsedTime}ms!`)); console.log(); console.log(championship_style_1.FAF_COLORS.fafWhite('Quick Summary:')); console.log(colors_1.chalk.gray(` 📦 Project: ${projectData.projectName}`)); console.log(colors_1.chalk.gray(` 🎯 Purpose: ${projectData.projectGoal}`)); console.log(colors_1.chalk.gray(` 💻 Stack: ${projectData.mainLanguage}${projectData.framework !== 'none' ? ' + ' + projectData.framework : ''}`)); console.log(); console.log(championship_style_1.FAF_COLORS.fafCyan('Next steps:')); console.log(colors_1.chalk.gray(' • Run "faf score" to check AI-readiness')); console.log(colors_1.chalk.gray(' • Run "faf enhance" to improve context')); console.log(colors_1.chalk.gray(' • Run "faf chat" for interactive improvements')); } catch (error) { console.log(colors_1.chalk.red('💥 Quick creation failed:')); console.log(colors_1.chalk.red(error instanceof Error ? error.message : String(error))); console.log(); console.log(colors_1.chalk.yellow('💡 Try "faf chat" for interactive mode')); process.exit(1); } } function detectProjectTypeFromQuick(data) { const framework = data.framework?.toLowerCase() || ''; const language = data.mainLanguage?.toLowerCase() || ''; const goal = data.projectGoal?.toLowerCase() || ''; // Framework-based detection if (framework.includes('react') || framework.includes('next')) return 'react'; if (framework.includes('vue') || framework.includes('nuxt')) return 'vue'; if (framework.includes('svelte') || framework.includes('kit')) return 'svelte'; if (framework.includes('angular')) return 'angular'; if (framework.includes('fastapi')) return 'python-fastapi'; if (framework.includes('django')) return 'python-django'; if (framework.includes('flask')) return 'python-flask'; if (framework.includes('express')) return 'node-api'; // Goal-based detection if (goal.includes('chrome extension') || goal.includes('browser extension')) return 'chrome-extension'; if (goal.includes('api') || goal.includes('backend')) return 'node-api'; if (goal.includes('cli') || goal.includes('command')) return 'cli-tool'; if (goal.includes('library') || goal.includes('package')) return 'library'; // Language-based fallback if (language.includes('python')) return 'python'; if (language.includes('go')) return 'golang'; if (language.includes('rust')) return 'rust'; return 'latest-idea'; } //# sourceMappingURL=quick.js.map