connect DEV to live MCP configuration and verify tool conformance

This commit is contained in:
2026-09-29 10:36:50 +01:00
parent 20bbbd26bd
commit 9592c9b274
16 changed files with 417 additions and 18 deletions
@@ -6,6 +6,7 @@ public enum I18n {
WORKSPACE_DEV("workspace.dev"),
DEV_GRANT("dev.grant"), DEV_RECLAIM("dev.reclaim"), DEV_COPY_CONFIG("dev.copyConfig"),
DEV_MCP_UNAVAILABLE("dev.mcpUnavailable"), DEV_EXTERNAL_WARNING("dev.externalWarning"),
DEV_MCP_INSTRUCTIONS("dev.mcpInstructions"), DEV_CONFIG_COPIED("dev.configCopied"), DEV_CONFIG_FAILED("dev.configFailed"),
DEV_MANUAL("dev.manual"), DEV_WAITING("dev.waiting"), DEV_WORKING("dev.working"), DEV_RETURNING("dev.returning"),
DEV_SAVE_GRANT("dev.saveGrant"), DEV_UNSAVED("dev.unsaved"),
DEV_DIAGNOSTICS("dev.diagnostics"), DEV_HISTORY("dev.history"),
@@ -66,7 +66,7 @@ public final class MainView extends BorderPane {
final AssetColorSchemaFactory assetColorSchemaFactory,
final TiledAssetService tiledAssetService,
final SceneBankWorkflow sceneBankWorkflow,
final ProjectActivityHistoryStore activityHistoryStore) {
final ProjectActivityHistoryStore activityHistoryStore, final p.studio.api.automation.AgentConnectionGuide connectionGuide) {
initializing = true;
this.eventBus = eventBus;
this.projectSession = projectSession;
@@ -98,7 +98,7 @@ public final class MainView extends BorderPane {
host.register(new DebugWorkspace(projectReference, projectSession.executionSession(), i18n, eventBus));
final var shipperWorkspace = new ShipperWorkspace(projectReference, shipper, i18n, eventBus);
host.register(shipperWorkspace);
host.register(new p.studio.ui.javafx.workspaces.dev.DevWorkspace(projectReference, projectSession.automation(), i18n, eventBus));
host.register(new p.studio.ui.javafx.workspaces.dev.DevWorkspace(projectReference, projectSession.automation(), i18n, eventBus, connectionGuide));
documentRegistration = projectSession.automation().registerDocuments(assetWorkspace.documentHandoff());
p.studio.ui.javafx.workspaces.dev.ManualProjectUiGuard.install(assetWorkspace.rootNode(),
() -> projectSession.automation().snapshot().manualAllowed());
@@ -70,6 +70,7 @@ public final class StudioWindowCoordinator implements AutoCloseable {
private final TiledAssetService tiledAssetService;
private final SceneBankWorkflow sceneBankWorkflow;
private final ProjectActivityHistoryStore activityHistoryStore;
private final p.studio.api.automation.AgentConnectionGuide connectionGuide;
private final Object lifecycleMonitor = new Object();
private volatile boolean closed;
private volatile ProjectSession pendingProjectSession;
@@ -104,7 +105,8 @@ public final class StudioWindowCoordinator implements AutoCloseable {
TiledAssetService tiledAssetService,
SceneBankWorkflow sceneBankWorkflow,
WindowStateStore windowStateStore,
ProjectActivityHistoryStore activityHistoryStore) {
ProjectActivityHistoryStore activityHistoryStore, p.studio.api.automation.AgentConnectionGuide connectionGuide) {
this.connectionGuide = Objects.requireNonNull(connectionGuide);
this.launcherStage = Objects.requireNonNull(launcherStage, "launcherStage");
this.projectCatalogService = Objects.requireNonNull(projectCatalogService, "projectCatalogService");
this.knownProjectsService = Objects.requireNonNull(knownProjectsService, "knownProjectsService");
@@ -263,7 +265,7 @@ public final class StudioWindowCoordinator implements AutoCloseable {
executor, theme, assetCatalog, assetCommands, assetPacking, assetDetails, assetCreationCatalog,
assetMetadataService, assetWorkspaceStorage, assetCapacityPolicy, bankCompositionSessionFactory,
assetColorSchemaFactory, tiledAssetService, sceneBankWorkflow,
activityHistoryStore);
activityHistoryStore, connectionGuide);
this.projectSession = projectSession;
final Scene scene = new Scene(mainView, PROJECT_WIDTH, PROJECT_HEIGHT);
scene.getStylesheets().add(theme.getDefaultTheme());
@@ -25,13 +25,23 @@ public final class DevWorkspace extends Workspace {
private final TextArea diagnostics = new TextArea(), history = new TextArea();
private final ImageView canvas = new ImageView();
private final Button grant = new Button(), reclaim = new Button();
private final Button configuration = new Button();
private final Label availability = new Label(), copyStatus = new Label();
private final AgentConnectionGuide connectionGuide;
private final java.nio.file.Path projectRoot;
private OperationSubscription connectionSubscription;
private OperationSubscription subscription;
private long generation;
private CanonicalCapture rendered;
private final javafx.beans.value.ChangeListener<java.util.Locale> localeListener;
public DevWorkspace(ProjectReference project, AutomationSession automation, I18nService i18n, StudioEventBus events) {
this(project, automation, i18n, events, AgentConnectionGuide.unavailable());
}
public DevWorkspace(ProjectReference project, AutomationSession automation, I18nService i18n, StudioEventBus events,
AgentConnectionGuide connectionGuide) {
super(project, events); this.automation = automation; this.i18n = i18n;
this.connectionGuide = java.util.Objects.requireNonNull(connectionGuide); projectRoot = project.rootPath();
localeListener = (o, before, after) -> apply(this.automation.snapshot());
scroll.setFitToWidth(true);
root.setPadding(new Insets(16)); root.getStyleClass().add("dev-workspace");
@@ -40,9 +50,13 @@ public final class DevWorkspace extends Workspace {
reclaim.textProperty().bind(i18n.bind(I18n.DEV_RECLAIM));
grant.setOnAction(e -> grant(false));
reclaim.setOnAction(e -> automation.reclaim());
Button configuration = new Button(); configuration.setId("dev-mcp-config");
configuration.textProperty().bind(i18n.bind(I18n.DEV_COPY_CONFIG)); configuration.setDisable(true);
Label availability = new Label(); availability.textProperty().bind(i18n.bind(I18n.DEV_MCP_UNAVAILABLE));
configuration.setId("dev-mcp-config");
configuration.textProperty().bind(i18n.bind(I18n.DEV_COPY_CONFIG));
configuration.setOnAction(e -> copyConfiguration());
availability.setId("dev-mcp-endpoint"); availability.setWrapText(true);
copyStatus.setId("dev-mcp-copy-status");
Label instructions = new Label(); instructions.setWrapText(true);
instructions.textProperty().bind(i18n.bind(I18n.DEV_MCP_INSTRUCTIONS));
Label warning = new Label(); warning.setWrapText(true);
warning.textProperty().bind(i18n.bind(I18n.DEV_EXTERNAL_WARNING));
canvas.setPreserveRatio(true); canvas.setSmooth(false); canvas.setFitWidth(640); canvas.setFitHeight(360);
@@ -50,7 +64,7 @@ public final class DevWorkspace extends Workspace {
diagnostics.setEditable(false); diagnostics.setPrefRowCount(3);
history.setEditable(false); history.setPrefRowCount(5);
root.getChildren().addAll(new Label(project.name() + " — " + project.rootPath()),
state, new HBox(10, grant, reclaim, configuration), availability, warning,
state, new HBox(10, grant, reclaim, configuration), availability, copyStatus, instructions, warning,
operation, imageStatus, imagePane, identity,
pane(I18n.DEV_DIAGNOSTICS, diagnostics), pane(I18n.DEV_HISTORY, history));
apply(automation.snapshot());
@@ -71,11 +85,16 @@ public final class DevWorkspace extends Workspace {
Runnable update = () -> { if (generation == subscribed) apply(snapshot); };
if (Platform.isFxApplicationThread()) update.run(); else Platform.runLater(update);
});
connectionSubscription = connectionGuide.subscribe(() -> {
Runnable update = () -> { if (generation == subscribed) { copyStatus.setText(""); updateConnection(); } };
if (Platform.isFxApplicationThread()) update.run(); else Platform.runLater(update);
});
}
@Override public void unLoad() {
generation++;
i18n.localeProperty().removeListener(localeListener);
if (subscription != null) { subscription.unsubscribe(); subscription = null; }
if (connectionSubscription != null) { connectionSubscription.unsubscribe(); connectionSubscription = null; }
}
private void grant(boolean save) {
automation.grant(save).whenComplete((result, failure) -> Platform.runLater(() -> {
@@ -89,6 +108,7 @@ public final class DevWorkspace extends Workspace {
}));
}
private void apply(AutomationSnapshot snapshot) {
updateConnection();
var view = DevWorkspaceProjection.from(snapshot);
state.setText(i18n.text(switch (view.state()) {
case MANUAL -> I18n.DEV_MANUAL;
@@ -105,4 +125,21 @@ public final class DevWorkspace extends Workspace {
canvas.setImage(rendered == null ? null : new Image(new ByteArrayInputStream(rendered.png())));
}
}
private void updateConnection() {
var endpoint = connectionGuide.endpoint();
configuration.setDisable(automation.snapshot().closed() || endpoint.isEmpty());
availability.setText(endpoint.orElseGet(() -> i18n.text(I18n.DEV_MCP_UNAVAILABLE)));
}
private void copyConfiguration() {
try {
if (automation.snapshot().closed()) throw new IllegalStateException("Project closed");
var content = new javafx.scene.input.ClipboardContent();
content.putString(connectionGuide.configuration(projectRoot));
boolean copied = javafx.scene.input.Clipboard.getSystemClipboard().setContent(content);
copyStatus.setText(i18n.text(copied ? I18n.DEV_CONFIG_COPIED : I18n.DEV_CONFIG_FAILED));
} catch (RuntimeException unavailable) {
// Never render exception payloads or credential-bearing configuration in diagnostics.
copyStatus.setText(i18n.text(I18n.DEV_CONFIG_FAILED)); updateConnection();
}
}
}
@@ -361,7 +361,10 @@ workspace.dev=DEV
dev.grant=Grant control to AI
dev.reclaim=Interrupt and reclaim control
dev.copyConfig=Copy MCP configuration
dev.mcpUnavailable=MCP connection is not available yet. This stage provides project control and observation.
dev.mcpUnavailable=MCP connection is unavailable.
dev.mcpInstructions=Copy the connection descriptor into your external client's MCP setup (adapt its format if needed). Connect → read project/language references → acquire after a human grant → edit saved files and validate with LSP/build → release. Copying does not grant control. Keep the token private and out of versioned files; recopy after restarting Studio. Only listed tools are available.
dev.configCopied=Connection descriptor and project instructions copied. Contains a private token.
dev.configFailed=Could not copy the current connection configuration.
dev.externalWarning=Reclaiming control stops Studio-managed work, not direct writes by your external agent. Stop that client separately. Existing edits are preserved.
dev.manual=Manual control
dev.waiting=Waiting for agent — project control granted
@@ -32,7 +32,10 @@ workspace.dev=DEV
dev.grant=Ceder controle à IA
dev.reclaim=Interromper e retomar controle
dev.copyConfig=Copiar configuração MCP
dev.mcpUnavailable=A conexão MCP ainda não está disponível. Esta etapa oferece controle do projeto e acompanhamento.
dev.mcpUnavailable=A conexão MCP está indisponível.
dev.mcpInstructions=Copie o descritor de conexão para a configuração MCP do cliente externo (adapte o formato se necessário). Conecte → consulte projeto/linguagens/referências → adquira após cessão humana → edite arquivos salvos e valide com LSP/build → devolva. Copiar não cede controle. Mantenha o token privado e fora de arquivos versionados; copie novamente após reiniciar o Studio. Somente as ferramentas listadas estão disponíveis.
dev.configCopied=Descritor de conexão e instruções do projeto copiados. Contém um token privado.
dev.configFailed=Não foi possível copiar a configuração atual de conexão.
dev.externalWarning=Retomar controle encerra o trabalho gerenciado pelo Studio, não as escritas diretas do agente externo. Pare esse cliente separadamente. As alterações existentes são preservadas.
dev.manual=Controle manual
dev.waiting=Aguardando agente — controle do projeto cedido