UNPKG

@jjdenhertog/ai-driven-development

Version:

AI-driven development workflow with learning capabilities for Claude

207 lines 8.3 kB
#!/usr/bin/env node "use strict"; /* eslint-disable unicorn/prefer-module */ 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 }); const commander_1 = require("commander"); const node_console_1 = require("node:console"); const node_fs_1 = require("node:fs"); const node_path_1 = require("node:path"); const clearCommand_1 = require("./commands/clearCommand"); const executeNextTaskCommand_1 = require("./commands/executeNextTaskCommand"); const executeTaskCommand_1 = require("./commands/executeTaskCommand"); const initCommand_1 = require("./commands/initCommand"); const learningCommand_1 = require("./commands/learningCommand"); const log_1 = require("./commands/log"); const logger_1 = require("./utils/logger"); const sleep_1 = require("./utils/sleep"); // Read version from package.json const packageJsonPath = (0, node_path_1.join)(__dirname, '..', '..', 'package.json'); const { version } = JSON.parse((0, node_fs_1.readFileSync)(packageJsonPath, 'utf8')); const program = new commander_1.Command(); // Program configuration program .name('aidev') .description('AI-Driven Development CLI - Automated workflow management for Claude') .version(version); // Init command program .command('init') .description('Initialize AI-driven development in current project') .option('--force', 'Force initialization even if .aidev directory already exists', false) .action((cmdObject) => __awaiter(void 0, void 0, void 0, function* () { try { yield (0, initCommand_1.initCommand)({ force: !!cmdObject.force }); } catch (error) { if (error instanceof Error) { (0, logger_1.logError)(error.message); } else { (0, logger_1.logError)(String(error)); } } })); // Execute task command program .command('execute <taskId>') .description('Execute a specific task by ID') .option('--dry-run', 'Show what would be executed without making changes') .option('--force', 'Force execution even if task is already in progress') .option('--dangerously-skip-permissions, --dsp', 'Skip permission checks of Claude Code') .action((taskId, cmdObject) => __awaiter(void 0, void 0, void 0, function* () { try { yield (0, executeTaskCommand_1.executeTaskCommand)({ taskId, dryRun: !!cmdObject.dryRun, force: !!cmdObject.force, dangerouslySkipPermission: !!cmdObject.dsp }); } catch (error) { if (error instanceof Error) { (0, logger_1.logError)(error.message); } else { (0, logger_1.logError)(String(error)); } } })); // Execute next task command program .command('execute-next') .description('Find and execute the next available pending task') .option('--dry-run', 'Show what would be executed without making changes') .option('--force', 'Force execution even if task is already in progress') .option('--dangerously-skip-permissions, --dsp', 'Skip permission checks of Claude Code') .action((cmdObject) => __awaiter(void 0, void 0, void 0, function* () { try { yield (0, executeNextTaskCommand_1.executeNextTaskCommand)({ dryRun: !!cmdObject.dryRun, force: !!cmdObject.force, dangerouslySkipPermission: !!cmdObject.dsp }); } catch (error) { if (error instanceof Error) { (0, logger_1.logError)(error.message); } else { (0, logger_1.logError)(String(error)); } } })); // Loop tasks command program .command('loop-tasks') .description('Continuously find and execute pending tasks') .option('--dry-run', 'Show what would be executed without making changes') .option('--force', 'Force execution even if task is already in progress') .option('--dangerously-skip-permissions, --dsp', 'Skip permission checks of Claude Code') .action((cmdObject) => __awaiter(void 0, void 0, void 0, function* () { const TASK_EXECUTION_DELAY = 60 * 1000; // 60 seconds const NO_TASKS_DELAY = 5 * 60 * 1000; // 5 minutes (0, node_console_1.log)('Starting continuous task execution loop...', 'info'); (0, node_console_1.log)('Press Ctrl+C to stop', 'info'); // eslint-disable-next-line no-constant-condition while (true) { try { (0, node_console_1.log)('Looking for next task...', 'info'); const result = yield (0, executeNextTaskCommand_1.executeNextTaskCommand)({ dryRun: !!cmdObject.dryRun, force: !!cmdObject.force, dangerouslySkipPermission: !!cmdObject.dsp }); if (result.noTasksFound) { (0, node_console_1.log)(`No tasks found. Waiting ${NO_TASKS_DELAY / 1000} seconds before checking again...`, 'info'); yield (0, sleep_1.sleep)(NO_TASKS_DELAY); } else if (result.taskExecuted) { (0, node_console_1.log)(`Task execution completed. Waiting ${TASK_EXECUTION_DELAY / 1000} seconds before next task...`, 'info'); yield (0, sleep_1.sleep)(TASK_EXECUTION_DELAY); } else { // No executable tasks (all have dependencies or are in progress) (0, node_console_1.log)(`No executable tasks available. Waiting ${TASK_EXECUTION_DELAY / 1000} seconds before checking again...`, 'info'); yield (0, sleep_1.sleep)(TASK_EXECUTION_DELAY); } } catch (error) { if (error instanceof Error) { (0, logger_1.logError)(`Error during task execution: ${error.message}`); } else { (0, logger_1.logError)(`Error during task execution: ${String(error)}`); } (0, node_console_1.log)(`Waiting ${TASK_EXECUTION_DELAY / 1000} seconds before retrying...`, 'info'); yield (0, sleep_1.sleep)(TASK_EXECUTION_DELAY); } } })); // Learning command program .command('learn') .description('Monitor completed tasks and learn from user changes') .option('--dangerously-skip-permissions, --dsp', 'Skip permission checks of Claude Code') .action((cmdObject) => __awaiter(void 0, void 0, void 0, function* () { try { yield (0, learningCommand_1.learningCommand)({ dangerouslySkipPermission: !!cmdObject.dsp }); } catch (error) { if (error instanceof Error) { (0, logger_1.logError)(error.message); } else { (0, logger_1.logError)(String(error)); } } })); // Log command - for capturing output from Claude Code hooks program .command('log') .description('Capture and log output from Claude Code hooks') .action(() => { try { (0, log_1.logCommand)(); } catch (error) { if (error instanceof Error) { (0, logger_1.logError)(error.message); } else { (0, logger_1.logError)(String(error)); } process.exit(1); } }); // Clear command program .command('clear') .description('Clear invalid worktrees') .action(() => __awaiter(void 0, void 0, void 0, function* () { try { yield (0, clearCommand_1.clearCommand)(); } catch (error) { if (error instanceof Error) { (0, logger_1.logError)(error.message); } else { (0, logger_1.logError)(String(error)); } } })); program.parse(process.argv); //# sourceMappingURL=index.js.map