feat(studio): add AI workspace with Codex ACP integration
Test / Tests and coverage
Intrepid/Prometeu/Studio/pipeline/head This commit looks good

This commit is contained in:
2026-11-23 03:11:33 +00:00
parent a2b6a81a27
commit ae7d01aa99
36 changed files with 2550 additions and 28 deletions
@@ -0,0 +1,17 @@
package p.studio.api.ai;
import java.util.List;
/** Non-secret machine-local Studio launch settings. Arguments are a vector, never shell text. */
public record AcpSettings(String executable, List<String> arguments) {
public AcpSettings {
executable = executable == null || executable.isBlank() ? defaultExecutable() : executable.strip();
arguments = arguments == null ? List.of() : List.copyOf(arguments);
if (executable.indexOf('\0') >= 0 || arguments.stream().anyMatch(a -> a.indexOf('\0') >= 0))
throw new IllegalArgumentException("Invalid ACP launch settings");
}
private static String defaultExecutable() {
return java.nio.file.Path.of(System.getProperty("user.home"),".prometeu-studio","bin","codex-acp").toString();
}
public static AcpSettings defaults() { return new AcpSettings(defaultExecutable(),List.of()); }
}
@@ -0,0 +1,45 @@
package p.studio.api.ai;
import java.util.List;
import java.util.concurrent.*;
import java.util.function.*;
/** Asynchronous project-owned agent port. Callbacks may arrive on worker threads. */
public interface AgentConnection {
enum State { DISCONNECTED, CONNECTING, CONNECTED, AUTHENTICATING, READY, FAILED, CLOSING, CLOSED }
enum Kind { TEXT, ACTIVITY }
record Status(State state, String detail) { }
record Event(String sessionId, Kind kind, String text) { }
record Choice(String id, String name, String kind) { }
record Permission(String sessionId, String title, String details, List<Choice> choices) {
public Permission(String sessionId,String title,List<Choice> choices){this(sessionId,title,"",choices);}
}
record Turn(CompletionStage<Void> accepted, CompletionStage<String> completion) { }
boolean available();
Status status();
AutoCloseable observe(Consumer<Status> listener);
void events(Consumer<Event> listener);
void permissions(Function<Permission, CompletionStage<String>> handler);
CompletionStage<Void> connect(AcpSettings settings);
CompletionStage<Void> login();
CompletionStage<String> newSession();
Turn prompt(String sessionId, String text);
CompletionStage<Void> cancel(String sessionId);
CompletionStage<Void> closeAsync();
static AgentConnection unavailable() {
return new AgentConnection() {
private final Status status = new Status(State.DISCONNECTED, "");
private <T> CompletionStage<T> missing() { return CompletableFuture.failedFuture(new IllegalStateException("Agent integration unavailable")); }
public boolean available(){return false;} public Status status(){return status;}
public AutoCloseable observe(Consumer<Status> l){l.accept(status);return ()->{};}
public void events(Consumer<Event> l){} public void permissions(Function<Permission,CompletionStage<String>> h){}
public CompletionStage<Void> connect(AcpSettings s){return missing();} public CompletionStage<Void> login(){return missing();}
public CompletionStage<String> newSession(){return missing();}
public Turn prompt(String s,String t){return new Turn(missing(),missing());}
public CompletionStage<Void> cancel(String s){return CompletableFuture.completedFuture(null);}
public CompletionStage<Void> closeAsync(){return CompletableFuture.completedFuture(null);}
};
}
}
@@ -0,0 +1,8 @@
package p.studio.api.ai;
import java.nio.file.Path;
@FunctionalInterface
public interface AgentConnectionFactory {
AgentConnection create(Path projectRoot);
}
@@ -0,0 +1,9 @@
package p.studio.api.preferences;
import p.studio.api.ai.AcpSettings;
/** Machine-local Studio agent configuration, shared by every project. IO belongs off FX. */
public interface AgentSettingsStore {
AcpSettings load();
void save(AcpSettings settings);
}