import fs from 'fs'; import path from 'path'; const dir = path.join(process.cwd(), 'src/components/assistant/DoormileAI'); const files = fs.readdirSync(dir).filter(f => f.endsWith('.jsx') && f !== 'shim.jsx'); for (const file of files) { const filepath = path.join(dir, file); let content = fs.readFileSync(filepath, 'utf8'); // Replace @astryxdesign/core imports with shim content = content.replace(/import\s+{\s*([^}]+)\s*}\s+from\s+'@astryxdesign\/core[^']*';/g, "import { $1 } from './shim';"); // Fix intents, flows, etc imports to point to src/lib/assistant/ // The original were: import { something } from '../intents'; // Now it should be: import { something } from '@/lib/assistant/intents'; content = content.replace(/from\s+'\.\.\/(intents|actions|assignActions|bulkOrderActions|customerFlow|orderFlow|bulkFlow|assignFlow|repeatFlow|repeatRuns)'/g, "from '@/lib/assistant/$1'"); // Replace OpenToast with toast content = content.replace(/import\s+{\s*OpenToast\s*}\s*from\s*'components\/third-party\/OpenToast';/, "import { toast } from '@/components/ui/use-toast';\nconst OpenToast = ({message, tone}) => toast({description: message, variant: tone === 'error' ? 'destructive' : 'default'});"); // STATUS is from themes/dt/tokens content = content.replace(/import\s+{\s*STATUS\s*}\s*from\s*'themes\/dt\/tokens';/, "const STATUS = { error: 'error', success: 'success', warning: 'warning', info: 'info', muted: 'muted' };"); // A few icons from @ant-design/icons to lucide-react content = content.replace(/import\s+{\s*CloseOutlined,\s*MoreOutlined\s*}\s*from\s*'@ant-design\/icons';/, "import { X as CloseOutlined, MoreHorizontal as MoreOutlined } from 'lucide-react';"); content = content.replace(/import\s+{\s*([A-Za-z]+Outlined)\s*}\s*from\s*'@ant-design\/icons';/g, "import { $1 } from 'lucide-react';"); // close enough for now fs.writeFileSync(filepath, content, 'utf8'); } console.log('Patch complete');