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
@@ -60,7 +60,8 @@ The foundation MUST have display-free tests of its own locale/preferences/resour
Initial qualification is on available macOS. Windows/Linux, assistive-technology walkthroughs and native IME composition require their own evidence. Logical scene snapshots MUST NOT be presented as proof of physical pixel alignment at every HiDPI scale.
Project navigation and integrated Play are specified separately by specification
14. Document host, free docking, ACP, asset workflows, code/LSP editor, scene/entity
14; the AI workspace presentation is specified separately by specification 15.
Document host, free docking, ACP transport, asset workflows, code/LSP editor, scene/entity
authoring, pixels/audio editing and shipping remain outside this foundation
contract. Backend integrations MUST use existing application services; domain logic
MUST NOT be duplicated here.
@@ -64,10 +64,15 @@ standalone foundation shell/gallery retains its decorative panel.
Tabs MUST retain native selection, focus and keyboard behavior and the inherited
Studio typeface. Tabs MUST use stepped upper corners and a flat base without the
lower bevel or bottom outline of a button. The selected tab MUST join the content
lower bevel or bottom outline of a button. Tab headers MUST have equal width,
sized to the longest current title
with its padding and controls, and recomputed when language, font, scale or the tab
set changes. Native overflow navigation MUST remain available in narrow windows.
The selected tab MUST join the content
surface, with a gold accent on its top and sides. Semantic theme colors MUST retain
distinct selected, hovered, disabled and focused states. This slice MUST NOT add
placeholder editors or extra tabs.
placeholder editors. The separate AI presentation is governed by
[specification 15](15.%20AI%20Workspace%20Presentation%20Specification.md).
The gold outline MUST continue from the active tab header around its entire content
area, joining the header's sides without drawing a line across the opening below
@@ -89,7 +94,7 @@ Play. Existing headless, MCP, evidence, tests and agent contracts remain availab
through their existing entry points and services. Their preservation takes
precedence over interactive convenience.
Editors, workspaces, AI prompts, tuning during Play,
Editors, functional agent integration, tuning during Play,
breakpoints, hot reload, PMC builds and distribution/export are outside this
slice. Future packaging belongs in Studio as a separate action; Play MUST NOT
implicitly package a PMC or a distributable runtime.
@@ -0,0 +1,93 @@
# AI Workspace Presentation Specification
Status: Implemented presentation, local chats and initial ACP integration. Owner: `studio`.
## Scope
The JavaFX 2 project shell MUST expose an AI tab alongside Gameplay, an AI prompt
entry in the footer and an AI / ACP section in Studio preferences. This contract
extends specifications 13–14 without changing execution ownership, runtime input
contracts or existing execution services. Opening a project connects the installed agent using the shared Studio configuration.
## Workspace and prompt
The AI tab MUST place the chat manager on the left and the conversation area and
prompt on the right. Empty conversations MUST use brief localized text, without
invented responses or agent activity. Chat creation, selection, renaming and
deletion MUST operate on local state. Loading persisted history and asset attachment
MUST remain visibly disabled. Sending follows the ACP contract in specification 16.
The compact manager MUST expose a chat selector, New chat and an actions menu.
The footer MUST retain the selected tab's information and reserve a fixed slot at
the right for an AI icon. The icon MUST have a localized tooltip, accessible name
and visible keyboard focus. It MUST expose a selected state and an accent
background while the prompt is visible, including its inline AI-tab form.
In other tabs, activating it MUST open or collapse a
prompt panel above the footer. The panel MUST reduce the available content height
rather than overlap it. A native divider MUST adjust its height, with minimum
sizes for the upper content and panel; constrained content MUST remain scrollable.
The footer control MUST be the sole open/collapse control; the prompt panel MUST
NOT contain a separate collapse button.
In the AI tab, activating the footer icon MUST focus the existing prompt. The
same compositor MUST move between the AI tab and the compact panel: two prompts
MUST NOT appear simultaneously. Opening/collapsing, tab selection and changes to
theme, language or text scale MUST retain the entered text. Collapsing MUST return
focus to a usable control. Focusing the prompt MUST release Gameplay keyboard input.
Starting Play MUST collapse the external drawer before selecting Gameplay and
focusing the game. This MUST preserve the draft, including when Play starts from
the AI tab, so returning to Gameplay does not reopen the drawer automatically.
## Local chats and drafts
Each project view MUST own one in-memory chat collection and active selection.
Opening a project MUST start without chats. New chat MUST work in either manager,
create a stable local identity and numbered initial title, select the new chat and
allow writing its initially empty draft. It MUST keep the current workspace tab.
Without a chat, writing MUST be disabled and the UI MUST direct the user to create
one. The footer entry MUST focus New chat when no editable prompt is available.
The full list and compact selector MUST share the same collection and active
chat. The prompt MUST identify its destination. Selecting in either manager MUST
restore exactly that chat's text while retaining all other drafts. A title MUST
NOT serve as chat identity. Presentation changes, opening/collapsing the panel,
Settings and starting/stopping Play MUST preserve the collection and drafts.
Rename MUST be available from both managers, trim external whitespace and reject
empty titles. Cancelling or invalid input MUST leave identity, title, selection
and draft unchanged. Delete MUST identify the target and require confirmation.
Cancelling MUST not alter state. Confirming MUST remove only that chat and draft;
if active, select the next chat in creation order, otherwise the previous one.
Deleting the last chat MUST return to no selection and disable writing/rename/delete.
Chats, titles, selection and drafts MUST remain transient project-view state.
The UI MUST briefly explain that they are discarded on project close. Closing
MUST cancel owned chat dialogs and discard this state; reopening the same project
or opening another MUST start empty. No chat data MAY be saved by Studio in project files, setup, preferences or a
database. Local creation/selection/rename MUST NOT start an ACP session; the first
send creates it lazily. The agent MAY retain its own independent history.
## Studio preferences
Studio preferences MUST contain an AI / ACP section identifying Codex as the initial
agent and ChatGPT login as the only authentication choice. It MUST expose the
shared launch configuration, Connect, login and current connection state.
The section MUST NOT offer API keys, future authentication choices or billing
explanations. Login MUST be enabled only after connection and disabled when the
existing ChatGPT login is recognized. Configuration and execution follow
[the ACP integration contract](16.%20Codex%20ACP%20Integration%20Specification.md).
## Verification and later capabilities
Presentation MUST use the existing Studio components, semantic theme colors and
English/Portuguese bundles. Desktop qualification MUST exercise prompt ownership,
focus, resizing, independent drafts, synchronized selection, rename validation,
deletion/cancellation, project lifetime, unavailable operations and settings, in
both themes and languages, including constrained windows and large text scale.
Display-free state tests MUST cover independent drafts, stable identity on rename,
invalid operations, deletion selection and project isolation/disposal.
Codex connection, sending, streaming, explicit permissions and cancellation follow
[specification 16](16.%20Codex%20ACP%20Integration%20Specification.md). Asset attachment
and persisted chat resumption remain future capabilities. Integration MUST preserve
shared-composer ownership, independent drafts and the project lifetime boundary.
@@ -0,0 +1,120 @@
# Codex ACP Integration Specification
Status: Implemented initial conversation slice. Owner: `studio`.
## Scope and ownership
The Studio JavaFX 2 project shell MUST consume an asynchronous, JavaFX-free
`AgentConnection` port in Studio API. The application MUST own the process adapter
and composition. UI MUST NOT launch processes or parse ACP; Core MUST NOT depend
on JavaFX. This extends specifications 8 and 15 and does not change runtime or MCP
authority. Assets, model selection, persistent chat indexing and history resumption
are outside this slice.
## Project connection and authentication
Studio preferences MUST offer Codex, ChatGPT login, executable, an ordered argument
vector, Connect and connection state. Launch settings MUST be machine-local and
shared by every project in `~/.prometeu-studio/ai-settings.json`. Project setup MUST
NOT override them. Legacy project `acp` values MUST be ignored without losing runtime,
save, indentation or MCP intent; new setup writes MUST omit the legacy field. A
project MUST NOT silently supply the global default. Apply MUST save without
restarting a connected agent; changed settings apply at the next connection.
Connect MUST save the configuration before launching it. With no project open,
preferences MUST remain editable, while connection/login indicate that a project
must first be opened.
The default executable MUST be `~/.prometeu-studio/bin/codex-acp`, with no arguments.
The explicit installer MUST stage adapter 2.9.0 under
`~/.prometeu-studio/agents/codex-acp/2.9.0`, use a working Node 22+ absolute executable
and set its PATH in the stable launcher. Runtime MUST NOT depend on npx or temporary
files. The launcher SHOULD reuse an installed compatible Codex 0.171.x through
CODEX_PATH; otherwise it MUST use the package dependency. Installation MUST be
idempotent, refuse replacing an unmanaged launcher and preserve an existing explicit
global preference. It MUST NOT modify system Node/npm or authentication. Installation
is explicit; opening a project MUST NOT download or update the adapter.
After a project is successfully presented, Studio MUST connect using global launch
settings and that project's root as cwd. Process, ACP sessions, transcript and drafts
MUST remain project-owned. Connection failure MUST remain visible and direct the
user to Studio preferences. The executable MUST be invoked directly, without shell
text evaluation. No browser login MAY start automatically; existing ChatGPT login is
reused, or explicit login remains available in preferences for the opened project.
The adapter MUST negotiate ACP v1 over stdio JSON-RPC, require the `chat-gpt`
authentication method and recognize existing active ChatGPT authentication through
`auth/status` and status updates. Explicit login MUST request only `chat-gpt`;
the adapter owns browser login and credential storage. Studio MUST NOT offer API
keys or billing indications, forward inherited OPENAI_API_KEY/CODEX_API_KEY, save
credentials in setup/AIE, or expose raw environment/stderr in UI or evidence.
Connection/authentication failures MUST remain visible and MUST NOT imply readiness.
## Sessions, sending and drafts
Each local chat MUST lazily obtain its own ACP session on first send. Sessions MUST
use the project cwd and select the offered `workspace-write` mode before prompting,
which uses Codex's on-request permission policy. No unattended approval mode is
introduced. Only one request MAY run per project; selecting chats and editing their
independent drafts MUST remain possible while it runs.
Send MUST snapshot only the selected draft, select its chat and open AI, collapsing
the external prompt. Responses MUST route by session rather than current selection.
ACP has no separate prompt-accepted response: first relevant agent progress or a
successful prompt response MUST acknowledge delivery. The corresponding draft MUST
clear only if still identical to the snapshot. Pre-delivery failure MUST preserve
it; edits made while sending MUST survive. The submitted text and failures MUST
remain in the conversation. Recover last request MUST copy that text only into an
empty draft. Failed work MUST NOT be automatically resubmitted.
The log MUST show user text, streamed agent text, tool activity and terminal
result/error/cancellation. Thought content MUST NOT be stored or shown; generic
working activity MAY be shown. Current activity and connection state MUST remain
visible, including the running chat identity when another chat is selected. The
Studio log is a bounded plain-text view (last 200,000 characters per chat), not an
authoritative persisted agent history.
Connection loss MUST invalidate bound session IDs. Retained transcripts MUST remain
readable, with explicit guidance to create a new chat after reconnecting. Studio MUST
NOT silently create a replacement session pretending to retain conversation context.
## Permission and cancellation
Each `session/request_permission` MUST require an explicit choice from its offered
options. The owned, nonblocking dialog MUST identify the chat and requested action,
with a bounded scrollable action preview when supplied. Closing/cancelling MUST
return cancelled; unknown options MUST NOT authorize. Cancellation, turn completion
and project close MUST dismiss stale permission dialogs. UI callbacks MUST run on FX;
protocol IO and process waits MUST run off FX.
Cancel MUST send `session/cancel` and await the active prompt's terminal response.
If unresponsive for ten seconds, the connection MUST terminate its owned process
tree and invalidate sessions before cancellation finishes. Deleting a running chat
MUST confirm, cancel and await termination before removing local state. Failure MUST
retain the chat and report an error. Deletion MUST NOT undo project changes or claim
to delete the agent's own persisted history.
Project close MUST cancel and await the agent alongside runtime shutdown, then
terminate the owned process tree before discarding chats/drafts and closing the
project session. Cancellation has a ten-second grace; process termination MUST
escalate from graceful destruction to force with bounded waits (two plus three
seconds). A termination failure MUST keep closure visibly incomplete and allow
cleanup retry. Cleanup MUST target only the launched process and tracked descendants,
never unrelated Codex processes.
## Transport and verification
Requests MUST correlate IDs, support asynchronous notifications and incoming
permission requests, bound frame size to 4 MiB and use finite RPC timeouts. Missing
or incompatible agents, rejection, malformed frames, process death and timeout MUST
fail visibly. Unsupported incoming methods MUST receive method-not-found. Reconnect
MUST dispose the previous transport before launch and fence old process output.
Display-free tests MUST exercise real stdio peers, handshake/authentication,
independent sessions, explicit permission choices, cancellation, unresponsive peers,
malformed/disconnected transport and process-tree cleanup. Chat-state tests MUST
cover independent drafts, delivery failure, edits during delivery, session creation
cancellation, delete waiting and invalidated sessions. Desktop tests MUST exercise
the actual settings, prompt, chat routing, permissions and project lifetime with a
controlled backend. The opt-in live smoke MUST use a disposable project and an
existing ChatGPT login, request no tools or file changes, and await full shutdown.
Live smoke MUST NOT run as part of ordinary unit tests.
@@ -308,3 +308,15 @@ External PNGs require an opaque project-bound grant issued by explicit human
source selection. Validate canonical scope, expected bytes and PNG bounds before
staging, then revalidate relevant source bytes at commit. A path, hash or
caller-supplied claim alone is not an external-source grant.
## ACP configuration belongs to Studio
ACP launch settings MUST be machine-local Studio preferences in
`~/.prometeu-studio/ai-settings.json`, with an executable and ordered literal arguments.
They MUST NOT be persisted in project setup or restored as project state. Readers
MUST ignore legacy project `acp` fields while preserving runtime/save paths,
indentation and MCP `agentIntegration` intent. New setup writes MUST omit that field.
A legacy project MUST NOT override or automatically seed the global preference.
Credentials, session IDs, chats and drafts MUST NOT be stored in either setup or
launch preferences. Connection state is transient and cwd/sessions remain per project.
See [the ACP contract](16.%20Codex%20ACP%20Integration%20Specification.md).
+6
View File
@@ -16,6 +16,12 @@ remain shared. The normal/installed app uses the new chooser and Play frontend;
[`14. Integrated Play Specification.md`](14.%20Integrated%20Play%20Specification.md)
owns project flow, execution authority, transport/presentation, input, saves and
qualification boundaries.
[`15. AI Workspace Presentation Specification.md`](15.%20AI%20Workspace%20Presentation%20Specification.md)
defines the AI tab, shared footer prompt, transient local chats/drafts and
global Studio ACP preferences with project-owned sessions.
[`16. Codex ACP Integration Specification.md`](16.%20Codex%20ACP%20Integration%20Specification.md)
defines initial ChatGPT authentication, real conversation, permissions, cancellation
and process lifetime. Asset attachment and persisted chat resumption remain unavailable.
## Purpose