( filePath: string, )
| 142 | } |
| 143 | |
| 144 | async function loadExistingModel( |
| 145 | filePath: string, |
| 146 | ): Promise<ExistingModel | null> { |
| 147 | try { |
| 148 | const file = Bun.file(filePath); |
| 149 | if (!(await file.exists())) { |
| 150 | return null; |
| 151 | } |
| 152 | const toml = await import(filePath, { with: { type: "toml" } }).then( |
| 153 | (mod) => mod.default, |
| 154 | ); |
| 155 | return toml as ExistingModel; |
| 156 | } catch (e) { |
| 157 | console.warn(`Warning: Failed to parse existing file ${filePath}:`, e); |
| 158 | return null; |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | interface MergedModel { |
| 163 | name: string; |