| 225 | if (warnings.length > 0) { |
| 226 | hookOutput('post-edit', 'warned', |
| 227 | `[structural] ${relativePath}:\n` + warnings.map(w => ` - ${w}`).join('\n') + '\n', |
| 228 | { file: relativePath, warnings, lens: 'structural' }); |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | function detectLayer(relativePath) { |
| 233 | if (/^src\/kernel\//.test(relativePath)) return 'kernel'; |
| 234 | if (/^src\/os\//.test(relativePath)) return 'os'; |
| 235 | if (/^src\/domains\//.test(relativePath)) return 'domains'; |
| 236 | if (/^src\/canvas\//.test(relativePath)) return 'canvas'; |
| 237 | return null; |
| 238 | } |
| 239 | |
| 240 | function checkLayerViolation(layer, importAlias) { |
| 241 | const importLayer = importAlias.split('/')[0].replace('@', ''); |
| 242 | |
| 243 | const rules = { |
| 244 | kernel: [], // kernel cannot import app layers |
| 245 | os: ['kernel'], // os can import kernel only |
| 246 | domains: ['kernel', 'os'], // domains can import kernel + os |
| 247 | canvas: ['kernel', 'os', 'ui'], // canvas can import kernel + os + design system |
| 248 | }; |
| 249 | |
| 250 | const allowed = rules[layer]; |