| 234 | } |
| 235 | |
| 236 | async function loadExisting(filePath: string): Promise<ExistingModel | null> { |
| 237 | const file = Bun.file(filePath); |
| 238 | if (!(await file.exists())) return null; |
| 239 | try { |
| 240 | const mod = await import(filePath, { with: { type: "toml" } }); |
| 241 | return mod.default as ExistingModel; |
| 242 | } catch (e) { |
| 243 | console.warn(`Warning: failed to parse ${filePath}:`, e); |
| 244 | return null; |
| 245 | } |
| 246 | } |
| 247 | |
| 248 | // --------------------------------------------------------------------------- |
| 249 | // Merged model shape (what we write) |