@jjdenhertog/ai-driven-development
Version:
AI-driven development workflow with learning capabilities for Claude
74 lines • 3.95 kB
JavaScript
;
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.processCompletedTask = processCompletedTask;
const node_child_process_1 = require("node:child_process");
const createCommit_1 = require("../git/createCommit");
const getCommits_1 = require("../git/getCommits");
const logger_1 = require("../logger");
const saveUserChanges_1 = require("../storage/saveUserChanges");
const updateTaskFile_1 = require("../tasks/updateTaskFile");
function processCompletedTask(task, dangerouslySkipPermission) {
return __awaiter(this, void 0, void 0, function* () {
(0, logger_1.log)(`Processing completed task: ${task.id} - ${task.name}`, 'success');
// Check if task has a branch (even if deleted, we can try to analyze)
if (!task.branch) {
(0, logger_1.log)(`Task ${task.id} has no branch information`, 'error');
return;
}
try {
// Analyze user changes using available information
(0, logger_1.log)(`Analyzing user changes for task ${task.id}...`, 'info');
const userChanges = yield (0, getCommits_1.getCommits)(task.branch);
if (!userChanges || userChanges.length === 0) {
(0, logger_1.log)(`No user changes detected for task ${task.id}. Task was merged as-is.`, 'info');
// Update task status to archived
yield setToArchiveAndPushAsync(task, `archive task ${task.id} - no user changes needed (AI-generated)`);
return;
}
// Save user changes to JSON
(0, logger_1.log)(`Found ${userChanges.length} file changes to learn from`, 'info');
(0, saveUserChanges_1.saveUserChanges)(task.id, userChanges);
const args = [];
if (dangerouslySkipPermission)
args.push('--dangerously-skip-permissions');
// await executeClaudeCommand({
// command: `/aidev-learn ${task.id}-${task.name}`,
// args,
// taskId: task.id
// });
yield setToArchiveAndPushAsync(task, `archive task ${task.id} - user changes learned`);
}
catch (error) {
(0, logger_1.log)(`Failed to process task ${task.id}: ${error instanceof Error ? error.message : String(error)}`, 'error');
(0, logger_1.log)(`Task ${task.id} will remain in 'completed' status for retry`, 'warn');
}
});
}
function setToArchiveAndPushAsync(task, message) {
return __awaiter(this, void 0, void 0, function* () {
// Update task status to archived
(0, updateTaskFile_1.updateTaskFile)(task.path, {
status: 'archived',
archived_at: new Date().toISOString()
});
(0, logger_1.log)(`Committing archive status for task ${task.id}...`, 'info');
const commitResult = yield (0, createCommit_1.createCommit)(message, {
all: true // Stage all changes
});
if (!commitResult.success) {
throw new Error(`Failed to commit: ${commitResult.error}`);
}
const mainBranch = 'main';
(0, node_child_process_1.execSync)(`git push origin ${mainBranch}`);
});
}
//# sourceMappingURL=processCompletedTask.js.map