UNPKG

@jjdenhertog/ai-driven-development

Version:

AI-driven development workflow with learning capabilities for Claude

53 lines 2.8 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.saveStorageChanges = saveStorageChanges; const config_1 = require("../../config"); const createCommit_1 = require("../git/createCommit"); const getBranchState_1 = require("../git/getBranchState"); const pushBranch_1 = require("../git/pushBranch"); const logger_1 = require("../logger"); function saveStorageChanges(message) { return __awaiter(this, void 0, void 0, function* () { try { // Check if there are any changes to commit const gitState = yield (0, getBranchState_1.getBranchState)(config_1.STORAGE_PATH); if (!gitState.hasChanges) { (0, logger_1.log)('No changes to save in worktree', 'info'); return; } // Generate commit message if not provided const commitMessage = message || `Auto-save worktree changes: ${new Date().toISOString()}`; const commitResult = yield (0, createCommit_1.createCommit)(commitMessage, { all: true, cwd: config_1.STORAGE_PATH }); if (!commitResult.success) { (0, logger_1.log)(`Failed to commit worktree changes: ${commitResult.error}`, 'error'); throw new Error(commitResult.error || 'Failed to commit changes'); } (0, logger_1.log)('Committed worktree changes', 'success'); const pushResult = yield (0, pushBranch_1.pushBranch)(config_1.STORAGE_BRANCH, config_1.STORAGE_PATH); if (pushResult.success) { (0, logger_1.log)('Pushed worktree changes to remote', 'success'); } else { (0, logger_1.log)(`Failed to push worktree changes: ${pushResult.error}`, 'error'); throw new Error(pushResult.error || 'Failed to push changes'); } } catch (error) { (0, logger_1.log)(`Failed to save worktree changes: ${String(error)}`, 'error'); throw error; } }); } //# sourceMappingURL=saveStorageChanges.js.map