Skip to content

feat(visual-plan): native builder.io visual-plan replica — Phase 1 (all 3 providers)#30

Merged
Ecko95 merged 10 commits into
gitsfrom
feat/visual-plan-gits
Jun 20, 2026
Merged

feat(visual-plan): native builder.io visual-plan replica — Phase 1 (all 3 providers)#30
Ecko95 merged 10 commits into
gitsfrom
feat/visual-plan-gits

Conversation

@Ecko95

@Ecko95 Ecko95 commented Jun 20, 2026

Copy link
Copy Markdown
Owner

Native Visual Plan for GITS (builder.io visual-plan parity) — Phase 1

Replicates Builder.io's visual-plan skill natively inside GITS with zero dependency on @agent-native/core, their hosted app, the local bridge, or their MCP. The agent authors a typed, structured plan that renders live in a new interactive side panel; all three providers (Claude / Codex / Cursor) are wired.

How it works

provider session (Claude / Codex / Cursor)
  └─ loads .claude/skills/visual-plan/SKILL.md → calls GITS's own MCP endpoint
       /api/gits/visual-plan/mcp  (Bearer = per-session token → threadId)
         tools: get-plan-blocks, create/update/get-visual-plan,
                get-plan-feedback, export-visual-plan
  → orchestrationEngine.dispatch(thread.visual-plan.upsert)
  → decider → event → projector → SQL projection (migration 031) → WS
  → client-runtime reducer → store → VisualPlanPanel.tsx (renders live)

The MCP handler runs in-process, resolves the calling thread from a per-session bearer token (a process-global registry singleton), and dispatches a thread.visual-plan-upserted event carrying a typed PlanContent block document.

Included (Phase 1 — all three providers)

  • Contracts (packages/contracts/src/visualPlan.ts): typed block registry (rich-text, callout, checklist, table, code, annotated-code, file-tree, implementation-map, api-endpoint, data-model, question-form, tabs, columns), PlanContentPatch, flat PlanCommentAnchor.
  • Orchestration data plane: thread.visual-plan-upserted through decider → projector → SQL projection (migration 031) → snapshot hydration → WS → web store / client-runtime.
  • Native MCP endpoint: minimal Streamable-HTTP JSON-RPC server (6 tools) + per-session token gate.
  • Provider wiring: Claude (mcpServers http), Cursor (ACP McpServer http via AcpSessionRuntime), Codex (per-thread thread/start config.mcp_servers override — no config.toml mutation).
  • Skill: .claude/skills/visual-plan/SKILL.md.
  • Web: VisualPlanPanel block renderer + ChatView mount (inline + sheet, lazy-loaded) + composer toggle + --wf-* wireframe theme tokens.

Verification

  • All packages typecheck clean against this gits base (contracts / server / web / client-runtime).
  • Unit tests: patch/export/catalog helpers.
  • Headless boot (on the original base): server comes up with the full layer graph, migration 031 applied, MCP route mounted (401 on missing/invalid token, 404 control).
  • HTTP integration test: drives the served MCP route end-to-end with a minted token (initialize → tools/list → tools/call get-plan-blocks) + token-rejection path.

Live agent round-trips weren't run end-to-end: codex/cursor-agent binaries aren't installed in the dev box, and a live Claude turn needs auth + nondeterministic tool-calling. Per-provider transport injection is typecheck-verified; the shared MCP path is exercised by the integration test.

Note on history

These commits were authored on a local base and replayed (cherry-picked) onto origin/gits; conflicts in server.ts, ChatView.tsx, ChatComposer.tsx, and server.test.ts were resolved to preserve both gits's recent work (Delamain sidebar, MCP inventory, lazy panels, review pipeline) and the visual-plan additions.

Deferred (follow-up phases)

  • Skill distribution to managed provider homes (currently repo-local).
  • P2: diagram render (inert HTML/CSS), anchored comments, in-panel edit→patch, send-back-to-session.
  • P3: wireframe canvas + sandboxed-iframe Alpine.js prototype.

🤖 Generated with Claude Code

Ecko95 and others added 10 commits June 20, 2026 18:46
… plans

Add a GITS-native visual plan model (block registry, content patches,
anchored comments) and wire a thread.visual-plan-upserted event through
the orchestration engine end-to-end: decider, projector, SQL projection
(migration 031), and the snapshot read-model hydration paths. This is the
data plane for the builder.io visual-plan parity feature (Phase 1).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add a minimal Streamable-HTTP MCP server (JSON-RPC over POST) at
/api/gits/visual-plan/mcp exposing get-plan-blocks, create/update/
get-visual-plan, get-plan-feedback and export-visual-plan. Calls are
authenticated by a per-session bearer token resolved to a thread via an
in-memory registry, then dispatched into the orchestration engine so the
plan renders live. Includes patch application + markdown export helpers.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… registry

Mint a per-session bearer token (process-global registry singleton) and
pass it to the Claude Agent SDK via an http mcpServers entry pointing at
the loopback visual-plan MCP endpoint, so Claude can author/update the
plan that renders live in GITS. Registry is a module singleton shared by
the route and adapter (no layer requirement to thread through providers).
Cursor/Codex wiring tracked as follow-up.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ime state

Thread.visualPlans flows: orchestration event -> client-runtime reducer ->
EnvironmentState.visualPlanByThreadId -> threadDerivation -> store thread.
Adds the reducer case, the normalized state slice, and the selector so the
panel can read the live plan document.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… wiring

Add VisualPlanPanel (typed block-registry renderer: rich-text, callout,
checklist, table, code, annotated-code, file-tree, implementation-map,
api-endpoint, data-model, question-form, tabs, columns) and mount it as a
right-hand panel (inline + sheet) mutually exclusive with the plan sidebar.
A 'Visual Plan' composer toggle appears once a plan exists. Adds --wf-*
wireframe token aliases for the Phase 3 canvas.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ed files

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…adapters

Cursor: pass an ACP http McpServer descriptor (per-session token) through
AcpSessionRuntime mcpServers into session/new + session/load.
Codex: register the visual-plan MCP via the per-thread thread/start config
override (config.mcp_servers, streamable HTTP + bearer_token) — no shared
config.toml mutation needed. All three providers now author the same plan.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Drive the served /api/gits/visual-plan/mcp route end-to-end with a minted
session token: initialize -> tools/list -> tools/call get-plan-blocks (the
sequence every provider MCP client runs on connect), plus invalid-token
rejection.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:XXL labels Jun 20, 2026
@Ecko95
Ecko95 marked this pull request as ready for review June 20, 2026 19:21
@Ecko95
Ecko95 merged commit 44c365c into gits Jun 20, 2026
7 of 10 checks passed
Ecko95 added a commit that referenced this pull request Jun 20, 2026
…it, send-back

Builds on Phase 1 (PR #30). Adds the web→server write path that comments and
edits both need, plus diagram rendering and send-to-agent.

Contracts
- Move pure plan model (applyPlanPatches/exportPlanToMarkdown) + new comment
  helpers (upsertPlanComment/resolvePlanComment) into @t3tools/contracts so the
  server write paths and the web panel's optimistic updates/export share one impl.
- Add gits.visualPlan.mutate RPC: VisualPlanMutateInput/Result + error.

Server
- visualPlanWrite.ts: shared loadVisualPlanState/upsertVisualPlanState +
  mutateVisualPlan (patches → comment → resolve → round-trip thread.visual-plan.
  upsert). Keeps the MCP registry cache coherent so the agent's get-plan-feedback
  sees web comments. http.ts (MCP) refactored to reuse it; ws.ts wires the RPC.

Web
- diagram/custom-html render inert agent HTML in a fully sandboxed iframe
  (sandbox="", opaque origin) with size caps, script/handler/URL stripping, and
  --wf-* theme injection (lib/visualPlanHtml.ts).
- VisualPlanPanel: text-selection + per-block anchored comments with a composer
  and routing (agent/human); resolve; in-panel editing of rich-text/checklist
  (@dnd-kit reorder)/callout/table emitting PlanContentPatches; optimistic local
  apply + persist via the mutate RPC; "send to agent" exporting markdown and
  dispatching a turn (ChatView wiring, reuses buildPlanImplementationPrompt).

Tests: contracts model + sanitizer + comment-anchor unit tests; server HTTP/WS
integration (web mutate → plan + get-plan-feedback + export coherence); panel
render test asserting the sandboxed iframe strips scripts. All 4 packages
typecheck clean; web build green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant