Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ dist
.tmp
judgmentkit-product-spec-package.zip
output/playwright
artifacts/
public/resources
public/schemas
public/docs
Expand Down
34 changes: 8 additions & 26 deletions app/mcp/route.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,20 @@
import { WebStandardStreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js";
import { NextResponse } from "next/server";

import { createJudgmentKitMcpServer, getMcpMetadata } from "@/lib/mcp-server";
import { handleMcpHttpRequest } from "@/lib/mcp-http";

export const runtime = "nodejs";
export const dynamic = "force-dynamic";

function wantsSse(request: Request) {
return request.headers.get("accept")?.includes("text/event-stream") ?? false;
}

async function handleStreamableHttpRequest(request: Request) {
const server = createJudgmentKitMcpServer();
const transport = new WebStandardStreamableHTTPServerTransport({
sessionIdGenerator: undefined,
enableJsonResponse: true,
});

await server.connect(transport);
return transport.handleRequest(request);
}

export async function GET(request: Request) {
if (!wantsSse(request)) {
return NextResponse.json(getMcpMetadata("streamable-http"));
}

return handleStreamableHttpRequest(request);
return handleMcpHttpRequest(request);
}

export async function POST(request: Request) {
return handleStreamableHttpRequest(request);
return handleMcpHttpRequest(request);
}

export async function DELETE(request: Request) {
return handleStreamableHttpRequest(request);
return handleMcpHttpRequest(request);
}

export async function OPTIONS(request: Request) {
return handleMcpHttpRequest(request, { allowOptions: true, cors: true });
}
12 changes: 11 additions & 1 deletion components/inspect-surface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ type InspectDocumentState =

const HASH_PREFIX = "#resource-";
const INSPECT_RESOURCE_RAIL_ID = "inspect-resource-rail";
const INSPECT_CATEGORY_ORDER = ["Examples", "Workflows", "Guardrails"] as const;
const INSPECT_CATEGORY_ORDER = [
"Examples",
"Workflows",
"Constraint packs",
"Guideline profiles",
"Guardrails",
] as const;

const VIEWER_MODE_LABELS: Record<ProductSurfaceInspectViewerMode, string> = {
prompt: "Prompt",
Expand Down Expand Up @@ -115,6 +121,10 @@ function getItemEyebrow(item: ProductSurfaceInspectItem) {
return "Workflow";
case "guardrail":
return "Guardrail";
case "constraint_pack":
return "Constraint pack";
case "guideline_profile":
return "Guideline profile";
case "example":
return "Example";
default:
Expand Down
65 changes: 65 additions & 0 deletions content/docs/examples/mode-structure-drift.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
title: Mode structure drift
slug: /docs/examples/mode-structure-drift
page_type: example
summary: A product-surface request defaults to a marketing hero, then gets rewritten to lead with the working surface.
agent_summary: >
This example calibrates visually led UI generation against the surface mode
contract, especially product surfaces that drift into marketing-page
structure.
audiences:
- design-leaders
- product-managers
- platform-engineering
- ai-application-developers
workflows:
- workflow.ai-ui-generation
guardrails:
- guardrail.surface-mode-structure
owners:
primary: Design Systems
risk: Product
operational: Frontend Platform
status: active
last_reviewed: 2026-04-23
related_pages:
- /docs/workflows/ai-ui-generation
- /docs/guardrails/surface-mode-structure
related_resources:
- /resources/examples/mode-structure-drift.v1.json
related_schemas:
- /schemas/example.schema.json
- /schemas/verdict.schema.json
toc: true
---

## Scenario

A team asks for a calmer review workspace where operators triage generated UI candidates and compare evidence.

## Raw decision or output

`Start with a premium hero explaining the AI review platform, add three benefit cards, a stat strip, and a floating dashboard preview below the fold.`

## What JudgmentKit detected

- the task was operational but the first viewport used marketing structure
- product proof was delayed behind generic hero, card, and stat patterns
- no single surface mode was named before layout decisions were made

## What action was taken

JudgmentKit selected product-surface mode and moved the working review surface into the first viewport.

## Corrected result

`Mode: product surface. First viewport: a triage workspace with candidate list, active preview, evidence inspector, and local decision actions. Follow with orientation copy that explains scope and freshness, then secondary context for guideline coverage and unresolved review questions.`

## Why the correction matters

Visually led product surfaces still need to satisfy the operator's first job before they sell the product.

## JSON artifact links

- Example resource: `/resources/examples/mode-structure-drift.v1.json`
- Schema: `/schemas/example.schema.json`
64 changes: 64 additions & 0 deletions content/docs/examples/motion-media-drift.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
title: Motion media drift
slug: /docs/examples/motion-media-drift
page_type: example
summary: Decorative media and motion are rewritten into product proof, restrained transitions, and reduced-motion handling.
agent_summary: >
This example calibrates visual UI generation so motion and media serve
hierarchy, affordance, or product proof rather than decoration.
audiences:
- design-leaders
- product-managers
- platform-engineering
- ai-application-developers
workflows:
- workflow.ai-ui-generation
guardrails:
- guardrail.motion-media-purpose
owners:
primary: Design Systems
risk: Accessibility
operational: Frontend Platform
status: active
last_reviewed: 2026-04-23
related_pages:
- /docs/workflows/ai-ui-generation
- /docs/guardrails/motion-media-purpose
related_resources:
- /resources/examples/motion-media-drift.v1.json
related_schemas:
- /schemas/example.schema.json
- /schemas/verdict.schema.json
toc: true
---

## Scenario

A model is asked to make a launch page feel cinematic for a developer tool without supplied product imagery.

## Raw decision or output

`Use abstract animated blobs, parallax glow layers, a rotating carousel of screenshots, and continuous floating motion behind the headline.`

## What JudgmentKit detected

- media was atmospheric rather than evidence of the product, state, or workflow
- motion was continuous decoration rather than hierarchy or affordance
- reduced-motion and readability constraints were missing

## What action was taken

JudgmentKit pivoted to product UI as the visual anchor and downgraded motion to purposeful, reduced-motion-safe transitions.

## Corrected result

`Use the product UI state as the primary visual anchor. Motion plan: stagger the headline and install action once on entry, reveal the proof plane with opacity and translate, and use a small hover transition on the primary action. Honor prefers-reduced-motion by removing translate and keeping instant opacity changes.`

## Why the correction matters

Motion and media should carry meaning. If they do not clarify hierarchy, proof, or affordance, they add review cost and accessibility risk.

## JSON artifact links

- Example resource: `/resources/examples/motion-media-drift.v1.json`
- Schema: `/schemas/example.schema.json`
65 changes: 65 additions & 0 deletions content/docs/examples/output-contract-gap.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
title: Output contract gap
slug: /docs/examples/output-contract-gap
page_type: example
summary: A visual implementation summary omits mode, visual thesis, and motion plan, then gets completed with contract evidence.
agent_summary: >
This example shows how JudgmentKit completes visually led implementation
responses so reviewers can audit the mode, thesis, motion plan, and any
downgrade.
audiences:
- design-leaders
- product-managers
- platform-engineering
- ai-application-developers
workflows:
- workflow.ai-ui-generation
guardrails:
- guardrail.frontend-output-contract
owners:
primary: Design Systems
risk: Product
operational: AI Application Developers
status: active
last_reviewed: 2026-04-23
related_pages:
- /docs/workflows/ai-ui-generation
- /docs/guardrails/frontend-output-contract
related_resources:
- /resources/examples/output-contract-gap.v1.json
related_schemas:
- /schemas/example.schema.json
- /schemas/verdict.schema.json
toc: true
---

## Scenario

An agent updates a product UI to feel calmer and more deliberate, but the final response omits the visual contract evidence.

## Raw decision or output

`Updated the page styling, improved spacing, and made the interface feel more polished. Tests passed.`

## What JudgmentKit detected

- the final response did not state the selected mode
- the final response omitted the visual thesis and motion plan
- the implementation could not be audited from the response

## What action was taken

JudgmentKit completed the response with the required visual output contract and disclosed the motion downgrade.

## Corrected result

`Updated the actual product surface to lead with the workspace, reduce card chrome, and tighten copy. Visual Thesis: calm operational clarity with strong typography and low-chrome structure. Mode: product surface. Motion Plan: hover affordance on primary actions and reduced-motion-safe opacity transitions; richer scroll motion was intentionally skipped to preserve runtime budget.`

## Why the correction matters

Visual implementation needs review evidence. The final answer should make the mode, thesis, motion choices, and downgrades explicit without forcing the user to reconstruct intent.

## JSON artifact links

- Example resource: `/resources/examples/output-contract-gap.v1.json`
- Schema: `/schemas/example.schema.json`
66 changes: 66 additions & 0 deletions content/docs/examples/primitive-sprawl-drift.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
title: Primitive sprawl drift
slug: /docs/examples/primitive-sprawl-drift
page_type: example
summary: A no-design-system workspace draft invents bespoke modules, then gets rewritten into the portable JudgmentKit primitive inventory.
agent_summary: >
This example shows how JudgmentKit rewrites bespoke visual modules into the
published primitive vocabulary when no external design system exists.
audiences:
- design-leaders
- product-managers
- platform-engineering
- ai-application-developers
workflows:
- workflow.ai-ui-generation
guardrails:
- guardrail.design-system-integrity
- guardrail.spec-completeness
owners:
primary: Design Systems
risk: Accessibility
operational: Frontend Platform
status: active
last_reviewed: 2026-04-14
related_pages:
- /docs/workflows/ai-ui-generation
- /docs/reference/portable-no-design-system-pack
- /docs/guardrails/design-system-integrity
- /docs/guardrails/spec-completeness
related_resources:
- /resources/examples/primitive-sprawl-drift.v1.json
related_schemas:
- /schemas/example.schema.json
- /schemas/verdict.schema.json
toc: true
---

## Scenario

A model tries to make a review workspace feel premium in one pass without a real design system.

## Raw decision or output

`Build a floating insight ribbon, a holographic evidence capsule, a decision dock, and a metadata halo around the selected artifact.`

## What JudgmentKit detected

- bespoke primitives without authority
- visual modules that cannot be compared against a stable component vocabulary

## What action was taken

JudgmentKit rewrote the surface using the published layout shell, artifact panel, inspector, card, and button primitives.

## Corrected result

`Use a layout shell with a queue list on the left, a header plus artifact panel in the workspace center, and a persistent inspector on the right. Represent decision actions with buttons inside the artifact panel header instead of inventing a new decision dock primitive.`

## Why the correction matters

Portable governance depends on a closed primitive vocabulary. Recomposition is allowed. Primitive invention is not.

## JSON artifact links

- Example resource: `/resources/examples/primitive-sprawl-drift.v1.json`
- Schema: `/schemas/example.schema.json`
Loading