import { logger } from '../utils/logger.js'; import fs from 'fs-extra'; import path from 'path'; const TASKS_FILE = 'data/tasks.json'; export class TaskCreateTool { constructor() { this.name = 'task_create'; this.description = 'Create a new task with description'; } async execute(args) { const { description } = args; try { const tasks = await this._loadTasks(); const id = String(Date.now()).slice(-8); tasks.push({ id, description, status: 'pending', created: new Date().toISOString() }); await this._saveTasks(tasks); return `✅ Task created: #${id} — ${description}`; } catch (e) { return `❌ ${e.message}`; } } async _loadTasks() { try { return await fs.readJson(TASKS_FILE); } catch { return []; } } async _saveTasks(tasks) { await fs.ensureDir(path.dirname(TASKS_FILE)); await fs.writeJson(TASKS_FILE, tasks, { spaces: 2 }); } }