feat(studio): integrate project MCP setup and lifecycle
This commit is contained in:
@@ -4,10 +4,15 @@ import p.studio.api.operation.OperationSubscription;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Optional;
|
||||
|
||||
/** Connection assistance only. Copying credentials never grants project authority. */
|
||||
/** Connection assistance only. Preparation never grants project authority. */
|
||||
public interface AgentConnectionGuide {
|
||||
enum State { UNAVAILABLE, WAITING_FOR_ACCESS, CONNECTED, RECONNECTING }
|
||||
default boolean supportsPreparation() { return false; }
|
||||
default State state(Path root) { return endpoint().isPresent() ? State.WAITING_FOR_ACCESS : State.UNAVAILABLE; }
|
||||
default AgentIntegrationPreparation.Result prepare(Path root) { return new AgentIntegrationPreparation.Result(false, "Preparation unavailable"); }
|
||||
default AgentIntegrationPreparation.Result preparationStatus(Path root) { return new AgentIntegrationPreparation.Result(false, ""); }
|
||||
Optional<String> endpoint();
|
||||
/** Explicit secret-bearing export for the clipboard; never persist or log this string. */
|
||||
/** Permanent registration guidance only; never returns credentials. */
|
||||
String configuration(Path openProjectRoot);
|
||||
OperationSubscription subscribe(Runnable changed);
|
||||
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package p.studio.api.automation;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
/** Machine-local client setup, independent of granting project authority. */
|
||||
public interface AgentIntegrationPreparation {
|
||||
Result prepare(Path projectRoot);
|
||||
default Result status(Path projectRoot) { return new Result(false, "Prepare the assistant for this project."); }
|
||||
record Result(boolean ready, String message) { }
|
||||
static AgentIntegrationPreparation unavailable() {
|
||||
return root -> new Result(false, "Prepare the assistant from an installed Studio.");
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package p.studio.api.automation;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
/** Required grant participant. Preparation/publication may do IO; activation/invalidation must not. */
|
||||
public interface AutomationConnectionLifecycle {
|
||||
Publication prepare(Path projectRoot) throws Exception;
|
||||
|
||||
final class OwnershipConflict extends Exception {
|
||||
public OwnershipConflict() { super("Another Studio instance owns this project's connection. Reclaim or close it before granting here."); }
|
||||
}
|
||||
|
||||
interface Publication extends AutoCloseable {
|
||||
void publish() throws Exception;
|
||||
void activate();
|
||||
void invalidate();
|
||||
@Override void close() throws Exception;
|
||||
}
|
||||
|
||||
static AutomationConnectionLifecycle none() {
|
||||
return root -> new Publication() {
|
||||
public void publish() { }
|
||||
public void activate() { }
|
||||
public void invalidate() { }
|
||||
public void close() { }
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package p.studio.api.automation;
|
||||
public record ControlResult(Status status, TaskIdentity task, String diagnostic) {
|
||||
public enum Status { GRANTED, ACQUIRED, RETURNED, BUSY, DIRTY_DOCUMENTS, SAVE_FAILED, NOT_GRANTED, INVALID_TASK, CLOSED, CLEANUP_FAILED }
|
||||
public enum Status { GRANTED, ACQUIRED, RETURNED, BUSY, DIRTY_DOCUMENTS, SAVE_FAILED, CONNECTION_FAILED, CONNECTION_CONFLICT, NOT_GRANTED, INVALID_TASK, CLOSED, CLEANUP_FAILED }
|
||||
public boolean success() { return status == Status.GRANTED || status == Status.ACQUIRED || status == Status.RETURNED; }
|
||||
public static ControlResult of(Status status, String message) { return new ControlResult(status, null, message); }
|
||||
}
|
||||
|
||||
+10
-1
@@ -2,14 +2,23 @@ package p.studio.api.project;
|
||||
|
||||
public record ProjectLocalStudioSetup(
|
||||
String prometeuRuntimePath,
|
||||
EditorIndentationSetup editorIndentation) {
|
||||
EditorIndentationSetup editorIndentation,
|
||||
AgentIntegrationSetup agentIntegration) {
|
||||
public ProjectLocalStudioSetup(String runtimePath, EditorIndentationSetup indentation) {
|
||||
this(runtimePath, indentation, AgentIntegrationSetup.defaults());
|
||||
}
|
||||
public ProjectLocalStudioSetup {
|
||||
agentIntegration = agentIntegration == null ? AgentIntegrationSetup.defaults() : agentIntegration;
|
||||
prometeuRuntimePath = normalizeText(prometeuRuntimePath);
|
||||
editorIndentation = editorIndentation == null
|
||||
? EditorIndentationSetup.defaults()
|
||||
: editorIndentation.normalize();
|
||||
}
|
||||
|
||||
public record AgentIntegrationSetup(int schemaVersion, boolean enabled, String clientProfile) {
|
||||
public static AgentIntegrationSetup defaults() { return new AgentIntegrationSetup(1, true, "codex"); }
|
||||
}
|
||||
|
||||
public static ProjectLocalStudioSetup defaults() {
|
||||
return new ProjectLocalStudioSetup(null, EditorIndentationSetup.defaults());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user