widenPass
Widen a single class file so the REPL can reach non-public members. Two coordinated edits, one pass:
JVM ACC flags: anything not public → public (no final removal — REPL needs access, not inheritance). This is what the K2 frontend reads for JAVA classes (Minecraft), and it's what the runtime link would need too (though runtime actually goes through the indy AccessBridge, which ignores access).
@kotlin.Metadatavisibility: for KOTLIN classes the frontend reads member visibility from the metadata proto (DeserializedClassDescriptor / MemberDeserializer:Flags.VISIBILITY.get(...)), NOT from ACC flags — so an ACC-only widen leaves Kotlinprivate/protectedstill closed. flipping the proto (private/protected/private-to-this → public;internalis handled by PlainEngine's friend weave,publicuntouched) is the only lever. See rewriteMetadata.
A non-null rename adds intermediary -> mojmap class names as a third edit, in bytecode and metadata alike. It costs the copy path (rebuilt constant pool), and with no raw-byte transfer what is not parsed is not written — so CODE (Kotlin's inliner reads inline bodies from the class file) and FRAMES (they name types) must be read.
Returns widened bytes if anything changed, null if the class was already fully open (skip writing). ClassWriter(cr, 0) copy path when not renaming. Accepts a shared read buffer to avoid per-class allocation.