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
275 lines (258 loc) โข 11.7 kB
JavaScript
;
/**
* ๐ faf ai-enhance - Claude-First, Big-3 Compatible Enhancement
* Universal AI-context enhancement with Claude intelligence and Big-3 compatibility
*
* Architecture: Claude-first โ Big-3 Compatible โ Bullet-proof Universal
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.enhanceFafWithAI = enhanceFafWithAI;
const colors_1 = require("../fix-once/colors");
const fs_1 = require("fs");
const yaml_1 = require("../fix-once/yaml");
/**
* Claude-First, Big-3 Compatible AI Enhancement
*/
async function enhanceFafWithAI(file, options = {}) {
// MAINTENANCE MODE - Temporarily disabled for improvements
console.log();
console.log(colors_1.chalk.yellow('โ ๏ธ FAF Enhance is temporarily under maintenance'));
console.log(colors_1.chalk.gray(' We discovered the AI enhancement was showing incorrect scores.'));
console.log(colors_1.chalk.gray(' We\'re improving this feature to provide real, accurate enhancements.'));
console.log();
console.log(colors_1.chalk.cyan('๐ง Alternative options:'));
console.log(colors_1.chalk.white(' โข Use "faf chat" for guided improvements'));
console.log(colors_1.chalk.white(' โข Use "faf edit" to manually improve your .faf'));
console.log(colors_1.chalk.white(' โข Use "faf score --details" to see what needs improvement'));
console.log();
return;
/* Original code temporarily disabled
try {
const fafPath = file || (await findFafFile());
if (!fafPath) {
console.log(chalk.red("โ No .faf file found"));
console.log(chalk.yellow('๐ก Run "faf init" to create one'));
process.exit(1);
}
const model = options.model || 'claude'; // Claude-first default
console.log(chalk.cyan(`โก AI-enhancing with ${getModelDisplay(model)}: ${fafPath}`));
// Read current .faf file
const content = await fs.readFile(fafPath, "utf-8");
const fafData = parseYAML(content);
// Calculate real score, don't trust embedded score
const { FafCompiler } = require('../compiler/faf-compiler');
const compiler = new FafCompiler(path.dirname(fafPath));
const realScore = await compiler.compile(fafPath);
console.log(chalk.cyan("๐ Current .faf score:"), chalk.bold(`${realScore.score}%`));
// WARNING: This is a mock implementation
console.log(chalk.yellow("โ ๏ธ Enhancement is currently in beta and may not improve scores"));
// Determine enhancement focus
const focus = options.focus || detectEnhancementFocus(fafData);
console.log(chalk.blue(`๐ Enhancement focus: ${focus}`));
if (options.dryRun) {
const prompt = generateEnhancementPrompt(fafData, focus, model);
console.log(chalk.yellow("\n๐ Dry run - Enhancement prompt:"));
console.log(chalk.dim(prompt));
return;
}
// Execute Claude-first, Big-3 compatible enhancement
const enhanced = await executeBig3Enhancement(fafPath, fafData, focus, model, options);
if (enhanced) {
console.log(chalk.green(`โ๏ธ .faf file enhanced with ${getModelDisplay(model)} intelligence`));
console.log(chalk.cyan("๐ Run 'faf score' to see improvement"));
console.log(chalk.dim("๐ค Run 'faf verify' to test AI understanding"));
}
} catch (error) {
console.log(chalk.red("๐ฅ AI enhancement failed:"));
console.log(
chalk.red(error instanceof Error ? error.message : String(error)),
);
process.exit(1);
}
*/
}
/**
* Get display name for AI model
*/
function getModelDisplay(model) {
const displays = {
'claude': '๐ค Claude (Championship)',
'chatgpt': '๐ค ChatGPT',
'gemini': '๐ Gemini',
'big3': '๐ Big-3 Consensus',
'universal': '๐ Universal AI'
};
return displays[model] || model;
}
/**
* Detect enhancement focus based on .faf analysis
*/
function detectEnhancementFocus(fafData) {
const score = parseInt(fafData.ai_score?.replace('%', '')) || fafData.scores?.faf_score || 0;
// Claude-first analysis priorities
if (!fafData.human_context?.who || !fafData.human_context?.what) {
return "human-context";
}
if (!fafData.ai_instructions?.priority_order || !fafData.ai_instructions?.working_style) {
return "ai-instructions";
}
if (score < 70) {
return "completeness";
}
if (!fafData.project?.goal || fafData.project.goal.includes('!CI')) {
return "claude-exclusive"; // Claude's specialty: championship content
}
return "optimization";
}
/**
* Generate Claude-first, model-specific enhancement prompt
*/
function generateEnhancementPrompt(fafData, focus, model) {
const modelInstructions = {
'claude': 'You are Claude, the championship AI. Focus on F1-inspired engineering excellence and revolutionary content.',
'chatgpt': 'You are ChatGPT. Focus on clear communication and practical improvements.',
'gemini': 'You are Gemini. Focus on technical precision and comprehensive analysis.',
'big3': 'Analyze from all three AI perspectives: Claude (championship), ChatGPT (clarity), Gemini (precision).',
'universal': 'Create universal improvements that work across all AI models.'
};
const focusInstructions = {
'human-context': 'Improve WHO/WHAT/WHY clarity for human handoffs',
'ai-instructions': 'Enhance AI onboarding and working style guidance',
'completeness': 'Fill missing context slots and improve scoring',
'optimization': 'Streamline for better AI consumption and performance',
'claude-exclusive': 'Apply Claude\'s championship content expertise - eliminate placeholders, add F1-inspired messaging'
};
return `${modelInstructions[model] || modelInstructions.claude}
Analyze and enhance this .faf (Universal AI-context Format) file.
Current .faf content:
\`\`\`yaml
${(0, yaml_1.stringify)(fafData)}
\`\`\`
Enhancement focus: ${focus}
Specific instructions: ${focusInstructions[focus]}
Requirements:
1. Analyze current .faf completeness and AI-readiness
2. Apply ${model === 'claude' ? 'championship F1-inspired' : model} intelligence
3. Focus specifically on "${focus}" improvements
4. Maintain .faf v2.4.0+ schema compatibility
5. Preserve existing working elements
6. Output enhanced .faf as valid YAML
${focus === 'claude-exclusive' ? 'CLAUDE SPECIAL: Replace any !CI placeholders with revolutionary F1-inspired content. Make it championship-grade!' : ''}
Provide the enhanced .faf file as clean YAML (no markdown backticks needed).`;
}
/**
* Execute Big-3 Compatible AI Enhancement (Claude-first architecture)
*/
async function executeBig3Enhancement(fafPath, fafData, focus, model, options) {
try {
console.log(colors_1.chalk.cyan(`๐ค ${getModelDisplay(model)} analysis starting...`));
// Use our existing Big-3 verification system for enhancement analysis
const models = model === 'big3' ? ['claude', 'chatgpt', 'gemini'] : [model === 'universal' ? 'claude' : model];
// Mock AI enhancement using our verification engine architecture
const enhancementResults = await generateMockEnhancement(fafData, focus);
if (options.consensus && models.length > 1) {
console.log(colors_1.chalk.yellow('๐ Building consensus from all models...'));
// Simulate consensus building
await new Promise(resolve => setTimeout(resolve, 500));
}
// Apply enhancements based on focus area
const enhanced = applyEnhancements(fafData, enhancementResults, focus);
if (enhanced) {
// Backup original
await fs_1.promises.copyFile(fafPath, `${fafPath}.backup-${Date.now()}`);
// Write enhanced version
const enhancedYaml = (0, yaml_1.stringify)(enhanced);
await fs_1.promises.writeFile(fafPath, enhancedYaml);
console.log(colors_1.chalk.green(`โ๏ธ Enhanced .faf with ${getModelDisplay(model)} intelligence`));
console.log(colors_1.chalk.dim(`๐ Backup created`));
// Show specific improvements
displayEnhancementResults(enhancementResults, focus);
return true;
}
return false;
}
catch (error) {
console.log(colors_1.chalk.red("โ Big-3 enhancement failed:"));
console.log(colors_1.chalk.red(error instanceof Error ? error.message : String(error)));
return false;
}
}
/**
* Generate mock enhancement using our Big-3 architecture
*/
async function generateMockEnhancement(fafData, focus) {
// Simulate AI analysis delay
await new Promise(resolve => setTimeout(resolve, 200));
const improvements = {
'human-context': {
// Don't add generic placeholders - they provide no value
// Only keep existing values or leave empty for user to fill
who: fafData.human_context?.who,
what: fafData.human_context?.what,
why: fafData.human_context?.why
},
'ai-instructions': {
priority_order: [
'1. Read THIS .faf file first for complete context',
'2. Check CLAUDE.md for session-specific context',
'3. Review package.json and key files for technical stack'
],
working_style: {
code_first: true,
explanations: 'minimal',
quality_bar: 'zero_errors',
testing: 'required'
}
},
'claude-exclusive': {
mission: '๐ Make Your AI Happy! ๐งก Trust-Driven ๐ค',
revolution: '30 seconds replaces 20 minutes of questions',
brand: 'F1-Inspired Software Engineering - Championship AI Context'
}
};
return improvements[focus] || {};
}
/**
* Apply AI enhancements to .faf data
*/
function applyEnhancements(fafData, enhancements, focus) {
const enhanced = { ...fafData };
switch (focus) {
case 'human-context':
enhanced.human_context = { ...(enhanced.human_context || {}), ...enhancements };
break;
case 'ai-instructions':
enhanced.ai_instructions = { ...(enhanced.ai_instructions || {}), ...enhancements };
break;
case 'claude-exclusive':
enhanced.project = { ...(enhanced.project || {}), ...enhancements };
break;
case 'completeness':
// Fill missing slots with intelligent defaults
if (!enhanced.instant_context) {
enhanced.instant_context = {};
}
if (!enhanced.instant_context.what_building && enhanced.project?.goal) {
enhanced.instant_context.what_building = enhanced.project.goal;
}
break;
}
// Update metadata
enhanced.project = enhanced.project || {};
enhanced.project.enhanced_date = new Date().toISOString();
enhanced.project.enhanced_by = 'faf-ai-enhance';
return enhanced;
}
/**
* Display enhancement results
*/
function displayEnhancementResults(results, focus) {
console.log(colors_1.chalk.cyan('\n๐ Enhancement Summary:'));
console.log(colors_1.chalk.dim(`Focus: ${focus}`));
const improvements = Object.keys(results).length;
if (improvements > 0) {
console.log(colors_1.chalk.green(`โ๏ธ ${improvements} improvements applied`));
console.log(colors_1.chalk.dim('๐ Run \'faf score\' to see impact'));
}
}
//# sourceMappingURL=ai-enhance.js.map