diff --git a/FAQ.md b/FAQ.md index b6fae57..0b6345d 100644 --- a/FAQ.md +++ b/FAQ.md @@ -57,6 +57,19 @@ Claude reads layer 0 first, then routes down as needed. Yes. Edit any `CONTEXT.md`, add `` at the top, and Klonode will preserve your edits on future runs. +## How do I ignore generated files in Git? + +If you want to treat Klonode's output as ephemeral artifacts rather than committing them to your repo, add this to your `.gitignore`: + +```gitignore +# Klonode auto-generated routing +CLAUDE.md +CONTEXT.md +.klonode/ +``` + +You can automatically append this by running `klonode init --gitignore-only`. + ## Is it production-ready? No. This is v0.1.0 alpha. Interfaces may change. But the core pipeline works end-to-end — we use it daily. diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts index cb24ced..371fb92 100644 --- a/packages/cli/src/cli.ts +++ b/packages/cli/src/cli.ts @@ -22,6 +22,7 @@ program .argument('[path]', 'Path to the git repository', '.') .option('-m, --mode ', 'Output mode: inline or shadow', 'inline') .option('--dry-run', 'Show what would be generated without writing files') + .option('--gitignore-only', 'Append Klonode presets to .gitignore without scanning') .action(initCommand); program diff --git a/packages/cli/src/commands/init.ts b/packages/cli/src/commands/init.ts index 258169b..1c2ac4e 100644 --- a/packages/cli/src/commands/init.ts +++ b/packages/cli/src/commands/init.ts @@ -7,8 +7,29 @@ import chalk from 'chalk'; export async function initCommand( repoPath: string, - options: { mode?: string; dryRun?: boolean }, + options: { mode?: string; dryRun?: boolean; gitignoreOnly?: boolean }, ): Promise { + const resolved = path.resolve(repoPath); + + if (options.gitignoreOnly) { + const fs = await import('fs'); + const gitignorePath = path.join(resolved, '.gitignore'); + const snippet = '\n# Klonode auto-generated routing\nCLAUDE.md\nCONTEXT.md\n.klonode/\n'; + + if (fs.existsSync(gitignorePath)) { + const content = fs.readFileSync(gitignorePath, 'utf8'); + if (!content.includes('# Klonode auto-generated routing')) { + fs.appendFileSync(gitignorePath, snippet); + console.log(chalk.green('✓ Appended Klonode preset to .gitignore')); + } else { + console.log(chalk.yellow('⚠ .gitignore already contains the Klonode preset')); + } + } else { + fs.writeFileSync(gitignorePath, snippet.trimStart()); + console.log(chalk.green('✓ Created .gitignore and added Klonode preset')); + } + return; + } const { generateRouting, writeGeneratedFiles, @@ -19,7 +40,7 @@ export async function initCommand( formatInjectionReport, } = await import('@klonode/core'); - const resolved = path.resolve(repoPath); + const mode = (options.mode === 'shadow' ? 'shadow' : 'inline') as 'inline' | 'shadow'; console.log(chalk.blue.bold('\n⟐ Klonode — AI Context Routing Generator\n'));