@jjdenhertog/ai-driven-development
Version:
AI-driven development workflow with learning capabilities for Claude
47 lines • 2.32 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.getTasks = getTasks;
const fs_extra_1 = require("fs-extra");
const node_path_1 = require("node:path");
const config_1 = require("../../config");
const loadTaskFromFile_1 = require("./loadTaskFromFile");
const logger_1 = require("../logger");
function getTasks() {
return __awaiter(this, arguments, void 0, function* (options = {}) {
const { status } = options;
// Always use absolute path to worktree tasks directory
const foundTasks = [];
try {
// Check if directory exists before reading
if (!(0, fs_extra_1.existsSync)(config_1.TASKS_DIR))
return [];
const files = (0, fs_extra_1.readdirSync)(config_1.TASKS_DIR);
for (const file of files) {
if (!file.endsWith('.json'))
continue;
const filePath = (0, node_path_1.join)(config_1.TASKS_DIR, file);
let task = (0, loadTaskFromFile_1.loadTaskFromFile)(filePath);
if (task) {
task = Object.assign(Object.assign({}, task), { status: task.status || 'pending' });
if ((!status || task.status === status))
foundTasks.push(task);
}
}
}
catch (error) {
// Log error for debugging but don't fail
(0, logger_1.log)(`Failed to read tasks directory: ${error instanceof Error ? error.message : String(error)}`, 'warn');
}
return foundTasks;
});
}
//# sourceMappingURL=getTasks.js.map