language js

private pattern js_module_reference() {
  or {
    JsImport(),
    JsImportCallExpression()
  }
}

private pattern chat_shell_read_model_source() {
  r"^[\"'](?:(?:\.\./)+(?:panel/)?shell-read-model|(?:\./)?shell-read-model|src/features/chat/panel/shell-read-model)(?:\.ts)?[\"']$"
}

js_module_reference() as $stmt where {
  $stmt <: contains `$source` where { $source <: chat_shell_read_model_source() },
  register_diagnostic(span=$stmt, message="Import chat panel signal read models only from the shell and panel surface rendering adapters.", severity="error")
}
