superdesign_check_files
Detect file changes by comparing current workspace files against a provided manifest, enabling gallery refresh integration for design workflows.
Instructions
Check for file changes by comparing current files with a manifest (for gallery refresh integration)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| workspace_path | No | Workspace path (defaults to current directory) | |
| manifest | Yes | File manifest to compare against |
Implementation Reference
- src/index.ts:66-73 (schema)Input schema definition for the superdesign_check_files toolconst CheckFilesSchema = z.object({ workspace_path: z.string().optional().describe("Workspace path (defaults to current directory)"), manifest: z.array(z.object({ name: z.string(), size: z.number(), modified: z.number() })).describe("File manifest to compare against") });
- src/index.ts:2048-2069 (registration)Registration of the superdesign_check_files tool in the list of available toolsname: "superdesign_check_files", description: "Check for file changes by comparing current files with a manifest (for gallery refresh integration)", inputSchema: { type: "object", properties: { workspace_path: { type: "string", description: "Workspace path (defaults to current directory)" }, manifest: { type: "array", items: { type: "object", properties: { name: { type: "string" }, size: { type: "number" }, modified: { type: "number" } }, required: ["name", "size", "modified"] }, description: "File manifest to compare against" } }, required: ["manifest"], },
- src/index.ts:2516-2539 (handler)Handler that processes superdesign_check_files tool calls: validates input with CheckFilesSchema, computes changes using checkFileChanges, returns JSON with hasChanges and changes listcase "superdesign_check_files": { const { workspace_path, manifest } = CheckFilesSchema.parse(args); try { const superdesignDir = getSuperdeignDirectory(workspace_path); const designIterationsDir = path.join(superdesignDir, 'design_iterations'); if (!existsSync(designIterationsDir)) { return { content: [{ type: "text", text: JSON.stringify({ hasChanges: false, changes: [], error: "No design iterations directory found" }) }], }; } const result = checkFileChanges(superdesignDir, manifest); return { content: [{ type: "text", text: JSON.stringify(result) }], }; } catch (error: any) { return { content: [{ type: "text", text: JSON.stringify({ hasChanges: false, changes: [], error: error.message }) }], }; } }
- src/index.ts:298-331 (helper)Core logic that scans current design files (*.html, *.svg), compares against manifest by name/size/mtime, detects and categorizes changes as added/modified/deletedfunction checkFileChanges(superdesignDir: string, manifest: Array<{name: string; size: number; modified: number}>): {hasChanges: boolean; changes: Array<{file: string; type: 'added' | 'modified' | 'deleted'}>} { const designIterationsDir = path.join(superdesignDir, 'design_iterations'); const currentFiles = glob.sync('*.{html,svg}', { cwd: designIterationsDir }); const changes: Array<{file: string; type: 'added' | 'modified' | 'deleted'}> = []; // Check for new or modified files currentFiles.forEach(file => { const filePath = path.join(designIterationsDir, file); if (existsSync(filePath)) { const stats = statSync(filePath); const manifestEntry = manifest.find(m => m.name === file); if (!manifestEntry) { // New file changes.push({ file, type: 'added' }); } else if (stats.size !== manifestEntry.size || stats.mtime.getTime() !== manifestEntry.modified) { // Modified file changes.push({ file, type: 'modified' }); } } }); // Check for deleted files manifest.forEach(manifestEntry => { if (!currentFiles.includes(manifestEntry.name)) { changes.push({ file: manifestEntry.name, type: 'deleted' }); } }); return { hasChanges: changes.length > 0, changes }; }