UNPKG

claude-gemini

Version:

Global CLI tool for Claude-Gemini integration across projects

64 lines 2.59 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.watch = watch; const chalk_1 = __importDefault(require("chalk")); const chokidar_1 = __importDefault(require("chokidar")); const debounce_1 = require("../utils/debounce"); const sync_1 = require("./sync"); const config_1 = require("../config"); async function watch(options) { const config = await (0, config_1.loadConfig)(); const patterns = options.pattern?.split(',') || config.watchPatterns || ['*.ts', '*.tsx', '*.js', '*.jsx']; const debounceTime = parseInt(options.debounce || '2000'); console.log(chalk_1.default.blue('Starting file watcher...')); console.log(chalk_1.default.gray(`Watching patterns: ${patterns.join(', ')}`)); console.log(chalk_1.default.gray(`Debounce: ${debounceTime}ms`)); console.log(chalk_1.default.yellow('\nPress Ctrl+C to stop\n')); const watcher = chokidar_1.default.watch(patterns, { ignored: [ '**/node_modules/**', '**/.git/**', '**/dist/**', '**/build/**', '**/.claude-gemini/**' ], persistent: true, ignoreInitial: true }); const runAnalysis = (0, debounce_1.debounce)(async (path) => { console.log(chalk_1.default.blue(`\nFile changed: ${path}`)); console.log(chalk_1.default.yellow('Running analysis...\n')); // You can customize this query based on the changed file const query = `@${path} Analyze the recent changes and their impact`; try { await (0, sync_1.sync)(query, { ripgrep: config.ripgrep, timeout: config.timeout.toString(), model: config.model, format: config.format }); } catch (error) { console.error(chalk_1.default.red(`Analysis failed: ${error}`)); } }, debounceTime); watcher .on('change', runAnalysis) .on('add', runAnalysis) .on('unlink', (path) => { console.log(chalk_1.default.red(`File deleted: ${path}`)); }) .on('error', (error) => { console.error(chalk_1.default.red(`Watcher error: ${error}`)); }); // Handle graceful shutdown process.on('SIGINT', () => { console.log(chalk_1.default.yellow('\n\nStopping file watcher...')); watcher.close(); process.exit(0); }); } //# sourceMappingURL=watch.js.map