UNPKG

@jjdenhertog/ai-driven-development

Version:

AI-driven development workflow with learning capabilities for Claude

83 lines 4.41 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.learningCommand = learningCommand; const fs_extra_1 = require("fs-extra"); const checkCommitExists_1 = require("../utils/git/checkCommitExists"); /* eslint-disable max-depth */ const checkGitAuth_1 = require("../utils/git/checkGitAuth"); const processCompletedTask_1 = require("../utils/learning/processCompletedTask"); const logger_1 = require("../utils/logger"); const sleep_1 = require("../utils/sleep"); const getTasks_1 = require("../utils/tasks/getTasks"); function learningCommand(options) { return __awaiter(this, void 0, void 0, function* () { const { dangerouslySkipPermission } = options; // Ensure git auth if (!(0, checkGitAuth_1.checkGitAuth)()) { (0, logger_1.log)('Git authentication required. Run: gh auth login', 'error'); throw new Error('Git authentication required'); } // Switch to main branch (0, logger_1.log)('Learning command started. Monitoring for completed tasks...', 'success'); if (dangerouslySkipPermission) (0, logger_1.log)('Dangerously skipping permission checks of Claude Code', 'warn'); const allTasks = yield (0, getTasks_1.getTasks)(); let tasks = allTasks.filter(task => task.status != 'archived'); const iterationAfterFullReload = 30; let iteration = 0; const mainBranch = 'main'; try { // eslint-disable-next-line no-constant-condition while (true) { // Reload the tasks if (iteration && iteration == iterationAfterFullReload) { iteration = 0; const refreshedTasks = yield (0, getTasks_1.getTasks)(); tasks = refreshedTasks.filter(task => task.status != 'archived'); } // Check for completed tasks const taskDatas = []; // Reload the JSON for (const task of tasks) { const taskData = JSON.parse((0, fs_extra_1.readFileSync)(task.path, 'utf8')); taskDatas.push(taskData); } const completedTasks = taskDatas.filter(task => task.status === 'completed'); if (completedTasks.length > 0) { (0, logger_1.log)(`Found ${completedTasks.length} completed tasks to process`, 'info'); // Process each completed task sequentially for (const task of completedTasks) { try { // Check if this task has already been processed and committed to main branch if (yield (0, checkCommitExists_1.checkCommitExists)(task.id, mainBranch)) { (0, logger_1.log)(`Task ${task.id} already has a commit on main branch. Skipping...`, 'warn'); continue; } yield (0, processCompletedTask_1.processCompletedTask)(task, dangerouslySkipPermission); } catch (error) { (0, logger_1.log)(`Error processing task ${task.id}: ${String(error)}`, 'error'); } } } // Sleep for 30 seconds before next check iteration++; yield (0, sleep_1.sleep)(300000); } } catch (error) { (0, logger_1.log)(`Learning command error: ${String(error)}`, 'error'); throw error; } }); } //# sourceMappingURL=learningCommand.js.map