That's a very good point. Adding a factory type to the context as you suggest would make sense and allow the global to be removed while still allowing those methods to be instance methods. I'll refine the pitch proposal.
The intent with the proposed Diagnostics change in particular was to simplify the verbiage a bit. But your point about the static methods points out a limitation I hadn't considered.
That's a good point, and that was an oversight. In my view your suggestion of a context property is probably better, though.
This is something I considered, but since we know that we want to allow plugin configuration in the future, it seemed to me to make sense to reserve those properties for declared parameters of the plugin.
In short it seemed clearer to say that the function parameters are the inputs from SwiftPM, the return values are the outputs to SwiftPM, and then (in a future version) the instance's properties are the parameters of the plugin (with values provided by the invocation). Perhaps we could then also use attributes to let the plugin declare its configurable properties, in the manner of SwiftArgumentParser.
The intent was to have a separate plugin invocation for each target, i.e. the same as described SE-0303, to prevent leaking of state from one invocation to the other in the same process. It might certainly be more effficient to invoke it repeatedly, but that seemed like a larger change than the API refinements proposed here.
For example, SE-0303 says that if a target uses multiple build tool plugins, they are applied in the order in which they are listed. If two targets list the same two plugins but in opposite order, that would mean that at least in some cases there would need to be multiple plugin invocations with one target each. That might be a good future optimization but it seems as if it can get a bit subtle.
That makes sense, though in this particular case I don't think that it's necessarily desirable to separate out the build commands from prebuild commands (ideally we wouldn't even need prebuild commands, if regular commands in the build system could generate new work that wasn't known until the command ran, but that isn't something that will be addressed soon).
But I see your broader point. It's worth considering whether more varied names would be better here, especially since it would allow multiple capabilities in a single plugin.
Meanwhile, I had actually revised the proposal to get away from the CommandConstructor approach to instead return different kinds of commands via an enum, which seems a little cleaner.
Allowing any plugin to provide any capability has a conceptual appeal (essentially getting rid of the predeclared capabilities). The reason the capability declaration was added to the manifest was so that SwiftPM will know when to invoke the plugin, without having to invoke it just to find out. But allowing multiple capabilities in the same declaration would work, without having a lot of plugin invocations to happen "just in case".
And if the plugin can be statically analyzed to determine what protocols it implements, then that might be a way to avoid having to declare specific capabilities in the first place.
Thanks for pointing out that error!
Good point. Some of the earlier feedback was to focus on only the differences, but seeing the end result would be important here. I'll add that back in.
Thanks a lot for your feedback! A lot of things to consider there...