import { z } from 'zod'; import { FileManager } from '../utils/file-manager.js'; const archiveSchema = z.object({ projectPath: z.string().min(1, 'projectPath is required and must be absolute'), archiveName: z.string().min(1, 'archiveName is required') }); export async function handleSpecArchive(args: any) { try { const { projectPath, archiveName } = archiveSchema.parse(args); const fileManager = new FileManager(projectPath); // Create archive directory const archiveDir = await fileManager.createArchiveDir(archiveName); // Get list of spec files const specFiles = await fileManager.listFiles(); if (specFiles.length === 0) { return { content: [{ type: "text", text: "❌ No spec files found to archive. Create some specs first using spec-project, spec-requirements, spec-design, or spec-tasks." }] }; } // Copy all spec files to archive const archivedFiles = []; for (const file of specFiles) { await fileManager.copyToArchive(file, archiveDir); archivedFiles.push(file); } return { content: [{ type: "text", text: `✅ Archive created successfully!\n\nArchive: ${archiveName}\nLocation: ${archiveDir}\nFiles archived: ${archivedFiles.join(', ')}` }] }; } catch (error: any) { return { content: [{ type: "text", text: `❌ Error in spec-archive: ${error.message}` }] }; } } // Export the tool function export const specArchiveTool = { name: "spec-archive", description: "Archive current spec files", inputSchema: { type: "object", properties: { projectPath: { type: "string", description: "Absolute path to the project directory (must be full path, not relative)" }, archiveName: { type: "string", description: "Name for the archived spec file" } }, required: ["projectPath", "archiveName"] }, handler: handleSpecArchive };