claude-gemini
Version:
Global CLI tool for Claude-Gemini integration across projects
100 lines (88 loc) • 3.67 kB
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.inject = inject;
const chalk_1 = __importDefault(require("chalk"));
const fs_extra_1 = __importDefault(require("fs-extra"));
const path_1 = __importDefault(require("path"));
const CLAUDE_INSTRUCTIONS = `
This project uses the claude-gemini CLI for analyzing large codebases. As Claude, I must use this tool when:
1. Analyzing entire directories or multiple large files
2. The requested analysis would exceed my context window
3. You explicitly ask for comprehensive codebase analysis
**IMPORTANT**: I MUST use the \`claude-gemini\` or \`cg\` command (NOT direct gemini):
\`\`\`bash
claude-gemini "@src/ @lib/ Find all API endpoints"
cg "@src/ @lib/ Find all API endpoints"
gemini -p "@src/ @lib/ Find all API endpoints"
\`\`\`
\`\`\`bash
cg "@src/auth.ts @src/middleware.ts Analyze authentication flow"
cg "@src/ @lib/ Find all WebSocket implementations"
cg -r "@src/ Find all useState hooks"
cg -t 600 "@./ Comprehensive security audit"
\`\`\`
1. Detect when large analysis is needed
2. Use \`cg\` command (NOT direct gemini)
3. Wait for "✅ Analysis complete!" message
4. Use the comprehensive results
5. Do NOT proceed with limited analysis while waiting
`;
async function inject(options) {
const filePath = path_1.default.resolve(options.file || './CLAUDE.md');
try {
if (!await fs_extra_1.default.pathExists(filePath)) {
console.error(chalk_1.default.red(`File not found: ${filePath}`));
console.log(chalk_1.default.yellow('Tip: Run "cg init" to create CLAUDE.md'));
process.exit(1);
}
const content = await fs_extra_1.default.readFile(filePath, 'utf-8');
// Check if already injected
if (content.includes('claude-gemini') || content.includes('Claude-Gemini')) {
if (!options.force) {
console.log(chalk_1.default.yellow('Claude-Gemini instructions already present in file.'));
console.log(chalk_1.default.gray('Use --force to overwrite'));
return;
}
}
// Find injection point or append
const lines = content.split('\n');
let injected = false;
// Try to find a good section
for (let i = 0; i < lines.length; i++) {
if (lines[i].match(/^
// Insert after this section
let j = i + 1;
while (j < lines.length && lines[j].trim() !== '' && !lines[j].match(/^
j++;
}
lines.splice(j, 0, CLAUDE_INSTRUCTIONS);
injected = true;
break;
}
}
if (!injected) {
// Append at the end
lines.push('', CLAUDE_INSTRUCTIONS);
}
await fs_extra_1.default.writeFile(filePath, lines.join('\n'));
console.log(chalk_1.default.green(`✅ Injected Claude-Gemini instructions into ${filePath}`));
}
catch (error) {
console.error(chalk_1.default.red(`Failed to inject: ${error}`));
process.exit(1);
}
}
//# sourceMappingURL=inject.js.map