feat: release design system engine, studio and component contracts
This commit is contained in:
1 parent
ff1065fb27
commit
3943b946d6
693 files changed
+175546
-3894
No files matched your search
@@ -0,0 +1,138 @@
|
||||
import type { McpTool } from "./index.ts";
|
||||
const string = { type: "string" };
|
||||
const fields: Record<string, Record<string, unknown>> = {
|
||||
package: { notes: string },
|
||||
upgrade_plan: { source: string },
|
||||
upgrade: { source: string },
|
||||
inspect: {},
|
||||
capabilities: {},
|
||||
context: { components: { type: "array", items: string, maxItems: 12 } },
|
||||
create: { source: string },
|
||||
propose: {
|
||||
source: string,
|
||||
patches: {
|
||||
type: "array",
|
||||
maxItems: 48,
|
||||
items: {
|
||||
type: "object",
|
||||
properties: { path: string, value: {} },
|
||||
required: ["path", "value"],
|
||||
additionalProperties: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
locks: { locks: { type: "array", items: string, maxItems: 128 } },
|
||||
page: {
|
||||
page: {
|
||||
type: "object",
|
||||
properties: {
|
||||
id: string,
|
||||
title: string,
|
||||
components: {
|
||||
type: "array",
|
||||
minItems: 1,
|
||||
maxItems: 12,
|
||||
items: {
|
||||
type: "object",
|
||||
properties: { component: string, props: { type: "object" } },
|
||||
required: ["component"],
|
||||
additionalProperties: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
required: ["id", "title", "components"],
|
||||
additionalProperties: false,
|
||||
},
|
||||
},
|
||||
validate: {},
|
||||
preview: { pageId: string },
|
||||
diff: {},
|
||||
apply: { baseApplicationRevision: string },
|
||||
revert: {
|
||||
target: { type: "string", enum: ["draft", "checkpoint", "application"] },
|
||||
baseApplicationRevision: string,
|
||||
},
|
||||
export: {},
|
||||
conformance: {
|
||||
source: string,
|
||||
exceptions: {
|
||||
type: "array",
|
||||
maxItems: 64,
|
||||
items: {
|
||||
type: "object",
|
||||
properties: { code: string, path: string, reason: string },
|
||||
required: ["code", "path", "reason"],
|
||||
additionalProperties: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
const descriptions: Record<string, string> = {
|
||||
package:
|
||||
"Export a verified self-contained design package with a content digest. No filesystem or draft mutation.",
|
||||
upgrade_plan:
|
||||
"Review a shared package upgrade, including integrity, identity, locks and migration diagnostics, without changing the draft.",
|
||||
upgrade:
|
||||
"Adopt a verified shared design package as a recoverable history entry; draft revision and decision locks are rechecked.",
|
||||
inspect: "Inspect recoverable source, valid preview, locks, pages and revisions.",
|
||||
capabilities: "List contracted components, operations and explicit integration limits.",
|
||||
context: "Get resolved tokens, selected component APIs, parts, constraints and generation rules.",
|
||||
create:
|
||||
"Create a recoverable design draft from optional canonical source; invalid source remains recoverable.",
|
||||
propose:
|
||||
"Propose canonical source or token/recipe JSON-pointer patches respecting decision locks.",
|
||||
locks: "Set explicit decision locks for future edits.",
|
||||
page: "Save a bounded literal page specification composed of contracted components; returns generated .wrn source.",
|
||||
validate: "Validate draft and saved page specifications.",
|
||||
preview:
|
||||
"Render a saved page through trusted shipped components. Returns CSP-protected static HTML.",
|
||||
diff: "Review design changes against the applied baseline and affected page ids.",
|
||||
apply:
|
||||
"Save an application design bundle after checking draft and application revisions. Explicit app integration still required.",
|
||||
revert:
|
||||
"Undo a draft edit, swap the previous draft checkpoint, or revert the application bundle pointer.",
|
||||
export:
|
||||
"Export raw draft recovery data, valid design artifacts and generated page sources without writing routes.",
|
||||
conformance:
|
||||
"Statically check .wrn source for unknown APIs, invented variants and token bypasses. Warnings need exact reviewed exceptions.",
|
||||
};
|
||||
export const DESIGN_WRITES = new Set([
|
||||
"create",
|
||||
"propose",
|
||||
"locks",
|
||||
"page",
|
||||
"apply",
|
||||
"revert",
|
||||
"upgrade",
|
||||
]);
|
||||
export function designTools(writable: boolean): McpTool[] {
|
||||
return Object.entries(fields)
|
||||
.filter(([name]) => writable || !DESIGN_WRITES.has(name))
|
||||
.map(([name, properties]) => ({
|
||||
name: "wrnexus_design_" + name,
|
||||
description: descriptions[name]!,
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
...properties,
|
||||
...(["context", "preview", "export", "apply"].includes(name)
|
||||
? { mode: string, density: string }
|
||||
: {}),
|
||||
...(DESIGN_WRITES.has(name) ? { baseRevision: string } : {}),
|
||||
},
|
||||
required: [
|
||||
...(DESIGN_WRITES.has(name) ? ["baseRevision"] : []),
|
||||
...({
|
||||
upgrade_plan: ["source"],
|
||||
upgrade: ["source"],
|
||||
page: ["page"],
|
||||
preview: ["pageId"],
|
||||
locks: ["locks"],
|
||||
apply: ["baseApplicationRevision"],
|
||||
conformance: ["source"],
|
||||
}[name] ?? []),
|
||||
],
|
||||
additionalProperties: false,
|
||||
},
|
||||
}));
|
||||
}
|
||||
Reference in new issue
Block a user