So I'm working on annotation processing for ank and I think I've got it but there is one caveat. Object itself and operations on it cannot be in the same script. Basically code block with object must be compiled with standard compiler (not the script one).
So for example for optics there would be two code blocks
import arrow.optics.optics
@optics
data class MyClass(val name: String)
val myClass = MyClass("qwerty")
myClassName().modify(myClass, {"NEW TEXT"})