UNPKG

@jjdenhertog/ai-driven-development

Version:

AI-driven development workflow with learning capabilities for Claude

74 lines 2.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.saveUserChanges = saveUserChanges; const fs_extra_1 = require("fs-extra"); const node_path_1 = require("node:path"); const config_1 = require("../../config"); const logger_1 = require("../logger"); /** * Determines if a file path represents an important file for learning purposes */ function isImportantFile(filePath) { // Skip files that start with a dot (configuration files, hidden files) if (filePath.startsWith('.')) return false; const unimportantFileExtensions = [ '.md', '.txt', '.lock', '.lockb', '.lock.json', '.lock.yaml', '.lock.yml', '.lock.json', '.bundleinfo', '.tsbuildinfo' ]; if (unimportantFileExtensions.some(ext => filePath.endsWith(ext))) return false; // Skip common unimportant files const unimportantPatterns = [ 'package-lock.json', 'yarn.lock', 'pnpm-lock.yaml', 'bun.lockb', 'CLAUDE.md', // AI instructions file 'README.md', // Often just documentation updates 'CHANGELOG.md', 'LICENSE', 'LICENSE.txt', 'LICENSE.md' ]; // Get just the filename for exact matches const fileName = filePath.split('/').pop() || ''; if (unimportantPatterns.includes(fileName)) return false; // Skip certain directories that are rarely important for learning const unimportantDirectories = [ 'node_modules/', 'dist/', 'build/', 'out/', 'coverage/', 'docs/', 'documentation/' ]; if (unimportantDirectories.some(dir => filePath.startsWith(dir))) return false; return true; } function saveUserChanges(taskId, changes) { // Filter commits to only include those with important file changes const filteredChanges = changes .map(commit => (Object.assign(Object.assign({}, commit), { fileChanges: commit.fileChanges.filter(fileChange => isImportantFile(fileChange.file)) }))) .filter(commit => commit.fileChanges.length > 0); // Create directory for task logs if it doesn't exist // Always use absolute path to worktree output directory const logDir = (0, node_path_1.join)(config_1.TASKS_OUTPUT_DIR, taskId); (0, fs_extra_1.ensureDirSync)(logDir); // Save filtered user changes to JSON file const filePath = (0, node_path_1.join)(logDir, 'user_changes.json'); (0, fs_extra_1.writeJsonSync)(filePath, filteredChanges, { spaces: 2 }); (0, logger_1.log)(`Saved user changes to ${filePath}`, 'success'); } //# sourceMappingURL=saveUserChanges.js.map