/** * Create the .implementation scaffold */ import { mkdirSync, existsSync } from 'fs'; import { join } from 'path'; interface CreateOptions { output?: string; force?: boolean; } export async function createImplementation(options: CreateOptions): Promise { const outputDir = options.output || process.cwd(); const implDir = join(outputDir, '.implementation'); // Check if directory exists if (existsSync(implDir) && !options.force) { console.error(`Directory already exists: ${implDir}`); console.error('Use --force to overwrite'); process.exit(1); } console.log(`Creating .implementation scaffold...`); console.log(` Location: ${implDir}`); console.log(''); // Create directory structure const dirs = [ implDir, join(implDir, 'data'), join(implDir, 'data', 'indexes'), join(implDir, 'data', 'plans'), join(implDir, 'data', 'todos'), join(implDir, 'data', 'audits'), join(implDir, 'data', 'architecture'), join(implDir, 'docs'), join(implDir, 'logs'), ]; for (const dir of dirs) { mkdirSync(dir, { recursive: true }); } // Create index files in data/indexes const indexFiles = [ { name: 'TODOS.md', content: generateTodosIndex() }, { name: 'MEMENTOS.md', content: generateMementosIndex() }, { name: 'PLANS.md', content: generatePlansIndex() }, { name: 'AUDITS.md', content: generateAuditsIndex() }, ]; for (const file of indexFiles) { await Bun.write(join(implDir, 'data', 'indexes', file.name), file.content); } // Create README.md in .implementation await Bun.write(join(implDir, 'README.md'), generateReadme()); console.log('Created structure:'); console.log(' .implementation/'); console.log(' ├── data/'); console.log(' │ ├── indexes/'); console.log(' │ │ ├── TODOS.md'); console.log(' │ │ ├── MEMENTOS.md'); console.log(' │ │ ├── PLANS.md'); console.log(' │ │ └── AUDITS.md'); console.log(' │ ├── plans/'); console.log(' │ ├── todos/'); console.log(' │ ├── audits/'); console.log(' │ └── architecture/'); console.log(' ├── docs/'); console.log(' ├── logs/'); console.log(' └── README.md'); console.log(''); console.log('Implementation scaffold created successfully!'); } function generateReadme(): string { return `# Implementation This directory contains project implementation tracking data. ## Structure - **data/** - Structured data for project tracking - **indexes/** - Index files for quick reference - TODOS.md - Task index - MEMENTOS.md - Important notes and decisions - PLANS.md - Implementation plans index - AUDITS.md - Audit records index - **plans/** - Detailed implementation plans - **todos/** - Task lists and checklists - **audits/** - Code audits, reviews, security checks - **architecture/** - Architecture decisions and diagrams - **docs/** - Project documentation - **logs/** - Development logs and session notes ## Usage This scaffold is designed to help track project development: 1. Add plans to \`data/plans/\` and index them in \`data/indexes/PLANS.md\` 2. Track tasks in \`data/todos/\` and index in \`data/indexes/TODOS.md\` 3. Record important decisions in \`data/indexes/MEMENTOS.md\` 4. Store audit results in \`data/audits/\` and index in \`data/indexes/AUDITS.md\` 5. Keep architecture docs in \`data/architecture/\` Generated by implementation. `; } function generateTodosIndex(): string { return `# Todos Index Track all project tasks here. ## Active ## Completed ## Backlog `; } function generateMementosIndex(): string { return `# Mementos Important notes, decisions, and things to remember. ## Decisions ## Notes ## Reminders `; } function generatePlansIndex(): string { return `# Plans Index Index of all implementation plans. ## Current ## Completed ## Archived `; } function generateAuditsIndex(): string { return `# Audits Index Index of all audits and reviews. ## Recent ## Security ## Code Reviews `; }