faf_init
Initialize a project.faf configuration file to set up FAF context for project management, creating directories as needed.
Instructions
Create project.faf for a project
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| force | No | Force reinitialize existing FAF context | |
| directory | No | Project directory path (supports ~ tilde expansion). Creates directory if it doesn't exist. | |
| path | No | Alias for directory parameter | |
| projectName | No | Project name for path inference (used with Projects convention) |
Implementation Reference
- src/handlers/tools.ts:478-597 (handler)The `handleFafInit` method is the core logic that handles initializing a project, setting up the `project.faf` file, and applying "Intel-Friday" enhancements if a project is recognized as a Chrome extension.
private async handleFafInit(args: any): Promise<CallToolResult> { // Native implementation - creates project.faf with Projects convention! try { // Determine project path using Projects convention or explicit path let targetDir: string; let projectName: string; // Accept both 'directory' (legacy) and 'path' (new) const explicitPath = args?.path || args?.directory; if (explicitPath) { // User explicit path always wins // Expand tilde (~) to home directory const expandedPath = explicitPath.startsWith('~') ? path.join(require('os').homedir(), explicitPath.slice(1)) : explicitPath; targetDir = path.resolve(expandedPath); projectName = path.basename(targetDir); // Ensure directory exists if (!fs.existsSync(targetDir)) { fs.mkdirSync(targetDir, { recursive: true }); } } else if (args?.projectName) { // Use Projects convention with provided name ensureProjectsDirectory(); const resolution = resolveProjectPath(args.projectName); targetDir = resolution.projectPath; projectName = resolution.projectName; // Ensure project directory exists if (!fs.existsSync(targetDir)) { fs.mkdirSync(targetDir, { recursive: true }); } } else { // Use current working directory (legacy behavior) targetDir = this.engineAdapter.getWorkingDirectory(); projectName = path.basename(targetDir); } const fafPath = path.join(targetDir, 'project.faf'); // Check if any FAF file exists and force flag const existingFaf = await findFafFile(targetDir); if (existingFaf && !args?.force) { return { content: [{ type: 'text', text: `π Claude FAF Initialization:\n\nβ οΈ ${existingFaf.filename} already exists in ${targetDir}\nπ‘ Use force: true to overwrite` }] }; } // Check project type with fuzzy detection (Friday Feature!) const projectDescription = args?.description || ''; // Detect Chrome Extension with fuzzy matching const chromeDetection = FuzzyDetector.detectChromeExtension(projectDescription); const projectType = FuzzyDetector.detectProjectType(projectDescription); // Build project data with Intel-Friday auto-fill! let projectData: any = { project: projectName, project_type: projectType, description: projectDescription, generated: new Date().toISOString(), version: VERSION }; // Apply Intel-Friday: Auto-fill Chrome Extension slots for 90%+ score! if (chromeDetection.detected) { projectData = applyIntelFriday(projectData); } // Create enhanced .faf content const fafContent = `# USE>FAF - call FAF-MCP (or faf/cli) # FAF - Foundational AI Context project: ${projectData.project} type: ${projectData.project_type}${chromeDetection.detected ? ' π―' : ''} context: Iβ‘π generated: ${projectData.generated} version: ${projectData.version} ${chromeDetection.corrected ? `# Auto-corrected: "${args?.description}" β "${chromeDetection.corrected}"` : ''} # The Formula human_input: Your project files multiplier: FAF Context output: Championship Performance # Quick Context working_directory: ${targetDir} initialized_by: claude-faf-mcp${projectData._friday_feature ? `\nfriday_feature: ${projectData._friday_feature}` : ''} vitamin_context: true faffless: true ${chromeDetection.detected ? `# Chrome Extension Auto-Fill (90%+ Score!) runtime: ${projectData.runtime} hosting: ${projectData.hosting} api_type: ${projectData.api_type} backend: ${projectData.backend} database: ${projectData.database} build: ${projectData.build} package_manager: ${projectData.package_manager}` : ''} `; fs.writeFileSync(fafPath, fafContent); return { content: [{ type: 'text', text: `π Claude FAF Initialization:\n\nβ Created project.faf in ${targetDir}\nπ Vitamin Context activated!\nβ‘ FAFFLESS AI ready!${ chromeDetection.detected ? '\n\nπ― Friday Feature: Chrome Extension detected!\nπ Auto-filled 7 slots for 90%+ score!' : '' }${ chromeDetection.corrected ? `\nπ Auto-corrected: "${args?.description}" β "${chromeDetection.corrected}"` : '' }` }] }; } catch (error: any) { return { content: [{