Skip to content

Implement AI Workspace MCP server and multi-workspace cross-worktree file view #157

Closed

Description

@Juliusolsson05

Summary

Add a new built-in MCP server/domain called AI Workspace that lets agents create and manage curated file workspaces for the user. Each AI Workspace is a named/scoped collection of file references that can span multiple branches and worktrees, then be opened in Agent Code as a Global Editor-style review surface.

This must be separate from the Orchestration Agents MCP server. Orchestration Agents will likely use AI Workspace heavily, but AI Workspace should remain a standalone capability that any agent can call.

Why

Multi-agent workflows often produce useful planning or review artifacts in separate worktrees. For example, an orchestration agent may spawn five linked agents, each working on a different GitHub issue in its own branch/worktree. Each worker writes a markdown plan in its own worktree.

Without a curated cross-worktree surface, the user has to manually find and open those files. The existing Global Editor correctly shows one project tree for normal editing, but it is not the right surface for reviewing agent-produced artifacts scattered across separate worktrees.

AI Workspace solves this by letting agents attach specific files to one or more curated review/edit workspaces.

Important Design Constraint: Multiple AI Workspaces

AI Workspace must not be a single global bucket.

Agent Code can have multiple active tasks, linked-agent groups, dispatch contexts, or visible workspace surfaces at the same time. The MCP API and UI should support multiple AI Workspaces concurrently, for example:

Each MCP operation should target a workspace by stable workspaceId or create one by name/scope. A default workspace may exist for convenience, but the underlying model must support many workspaces.

Example Workflow

  1. User asks an orchestration agent to plan five issues.
  2. Orchestration agent creates five worker agents, each in its own worktree/branch.
  3. Each worker writes a planning markdown file in its own worktree.
  4. Orchestration agent collects the five file paths.
  5. Orchestration agent creates an AI Workspace named Issue planning review.
  6. Orchestration agent attaches the five files to that workspace through AI Workspace MCP tools.
  7. User runs Open AI Workspace and selects the relevant workspace.
  8. Agent Code opens a Global Editor-style view whose file tree contains only the attached files.
  9. User can read and compare the plans without manually navigating every worktree.

Proposed MCP Tools

ai_workspace_create

Create or return an AI Workspace.

Inputs:

  • name: display name
  • description: optional description
  • scope: optional structured scope, such as parent session id, task id, issue id, or project cwd

Behavior:

  • Create a new workspace or return an existing matching workspace depending on the chosen idempotency policy.
  • Return workspaceId and metadata.

ai_workspace_attach_file

Attach a file to an AI Workspace.

Inputs:

  • workspaceId: target AI Workspace
  • path: absolute file path
  • title: optional display title
  • description: optional note explaining why this file matters
  • sourceSessionId: optional Agent Code session id
  • sourceAgentLabel: optional agent label/name
  • taskId: optional task or issue id
  • metadata: optional structured metadata

Behavior:

  • Validate that the path exists.
  • Validate that the path points to a file, not a directory.
  • Normalize and store the absolute path.
  • Preserve source metadata.
  • De-duplicate by normalized path within the target workspace.
  • Return the attached file entry.

ai_workspace_detach_file

Detach a file from an AI Workspace.

Inputs:

  • workspaceId
  • path or entryId

Behavior:

  • Remove the matching entry if present.
  • Return success and remaining count.

ai_workspace_list_files

List files in an AI Workspace.

Inputs:

  • workspaceId

Behavior:

  • Return all attached entries with metadata.
  • Include existence/readability status so stale paths are visible.

ai_workspace_list_workspaces

List available AI Workspaces.

Behavior:

  • Return workspace ids, names, scopes, counts, and last-updated timestamps.

ai_workspace_clear

Clear an AI Workspace.

Inputs:

  • workspaceId

Behavior:

  • Remove every file entry from that workspace.
  • Return number of removed files.

ai_workspace_delete

Delete an AI Workspace entirely.

Inputs:

  • workspaceId

Behavior:

  • Remove the workspace and its file references.
  • Do not delete real files from disk.

Main Process State

Add an AI Workspace registry owned by the main process.

Each workspace should include:

  • stable workspaceId
  • display name
  • optional description
  • optional structured scope
  • createdAt
  • updatedAt
  • list of attached entries

Each file entry should include:

  • stable entryId
  • normalized absolute path
  • display title
  • optional description
  • optional sourceSessionId
  • optional sourceAgentLabel
  • optional taskId
  • detected worktree/project root if available
  • detected git branch if available
  • attachedAt
  • current existence/readability status

Renderer UI

Add command palette commands:

  • Open AI Workspace
  • Create AI Workspace
  • Clear AI Workspace
  • optionally Remove Current File from AI Workspace

Behavior:

  • Opening AI Workspace lets the user choose among existing AI Workspaces when more than one exists.
  • The editor surface should reuse Global Editor primitives where possible.
  • The file tree/sidebar shows only files attached to the selected AI Workspace.
  • Files may live across different worktrees.
  • Selecting a file opens its real path.
  • The UI should distinguish files with the same basename using branch/worktree/task labels.

Initial editing policy:

  • Prefer reusing Global Editor's existing read/write file handling if safe.
  • If cross-worktree writes introduce risk, start read-only and add editing in a follow-up.

Persistence

Persist AI Workspaces with workspace state so curated review sets survive app reloads.

On load:

  • Rehydrate workspaces and entries.
  • Mark missing/unreadable files as stale rather than dropping them silently.

Relationship To Orchestration Agents

AI Workspace is not part of the Orchestration Agents MCP server.

Orchestration Agents can use AI Workspace tools to present outputs from worker agents, but AI Workspace should remain a general-purpose built-in MCP domain for curated file review.

This separation keeps responsibilities clean:

  • Orchestration Agents: create/control/read linked agents.
  • AI Workspace: curate files into user-facing cross-worktree review/edit surfaces.

Acceptance Criteria

  • A new AI Workspace MCP domain/server exists under the project MCP structure.
  • The model supports multiple AI Workspaces concurrently.
  • Agents can create/list/delete AI Workspaces through MCP tools.
  • Agents can attach, detach, list, and clear files within a specific AI Workspace.
  • Attached files are tracked by main-process state with metadata.
  • User can open an AI Workspace UI from the command palette.
  • When multiple AI Workspaces exist, the user can choose which one to open.
  • AI Workspace UI shows only files attached to the selected workspace, including files from different worktrees.
  • Opening an attached file reads from the real path.
  • Duplicate paths are handled cleanly per workspace.
  • Missing or unreadable files are shown as stale instead of crashing.
  • AI Workspaces persist across app reloads.
  • The implementation remains separate from Orchestration Agents.
  • Tests or focused validation cover workspace create/list/delete and attach/list/detach/clear flows.

Notes

This should build on the MCP groundwork from issue #155. It should not block on full Orchestration Agents implementation, but it should be designed so issue #156 can use it naturally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions