From c3097ba5d7b17754fa18941d46f57bd6b6ec4966 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Mon, 30 Mar 2026 22:31:33 -0700 Subject: [PATCH] Move schema descriptions into contracts - Inline settings and keybinding schema descriptions in shared contracts - Simplify schema generation scripts to emit the updated docs --- apps/marketing/public/schemas/settings.json | 12 ++-- packages/contracts/src/keybindings.ts | 2 + packages/contracts/src/orchestration.ts | 4 ++ scripts/lib/keybindings-schema.ts | 30 +-------- scripts/lib/server-settings-schema.ts | 73 +-------------------- 5 files changed, 15 insertions(+), 106 deletions(-) diff --git a/apps/marketing/public/schemas/settings.json b/apps/marketing/public/schemas/settings.json index f75aaaf878..463c66bac5 100644 --- a/apps/marketing/public/schemas/settings.json +++ b/apps/marketing/public/schemas/settings.json @@ -12,7 +12,7 @@ "anyOf": [ { "type": "boolean", - "description": "Whether server-driven assistant responses should stream incrementally to clients when the active provider supports it." + "description": "Show token-by-token output while a response is in progress." }, { "type": "null" @@ -25,7 +25,7 @@ { "type": "string", "enum": ["local", "worktree"], - "description": "Default execution environment to use when creating new threads." + "description": "Pick the default workspace mode for newly created draft threads." }, { "type": "null" @@ -154,7 +154,7 @@ "description": "Text generation model selection for the Claude provider." } ], - "description": "Default provider and model to use for server-side text generation features." + "description": "Configure the model used for generated commit messages, PR titles, and similar Git text." }, { "type": "null" @@ -188,7 +188,7 @@ "anyOf": [ { "type": "string", - "description": "Path to the Codex executable. Leave blank to resolve the `codex` executable from PATH." + "description": "Path to the Codex binary" }, { "type": "null" @@ -200,7 +200,7 @@ "anyOf": [ { "type": "string", - "description": "Optional Codex home directory. Leave blank to use the default provider-managed location." + "description": "Optional custom Codex home and config directory." }, { "type": "null" @@ -254,7 +254,7 @@ "anyOf": [ { "type": "string", - "description": "Path to the Claude executable. Leave blank to resolve the `claude` executable from PATH." + "description": "Path to the Claude binary" }, { "type": "null" diff --git a/packages/contracts/src/keybindings.ts b/packages/contracts/src/keybindings.ts index ddf1139547..6006a608b1 100644 --- a/packages/contracts/src/keybindings.ts +++ b/packages/contracts/src/keybindings.ts @@ -69,9 +69,11 @@ const KeybindingWhen = TrimmedString.annotate({ }).check(Schema.isMinLength(1), Schema.isMaxLength(MAX_KEYBINDING_WHEN_LENGTH)); export const KeybindingRule = Schema.Struct({ key: KeybindingValue.pipe( + Schema.flip, Schema.annotate({ description: "Keyboard shortcut to listen for.", }), + Schema.flip, ), command: KeybindingCommand.pipe( Schema.annotate({ diff --git a/packages/contracts/src/orchestration.ts b/packages/contracts/src/orchestration.ts index 2ae65e30d3..6a57d76079 100644 --- a/packages/contracts/src/orchestration.ts +++ b/packages/contracts/src/orchestration.ts @@ -52,9 +52,11 @@ export const CodexModelSelection = Schema.Struct({ }), ), model: TrimmedNonEmptyString.pipe( + Schema.flip, Schema.annotate({ description: "The Codex model slug to use for text generation.", }), + Schema.flip, ), options: Schema.optionalKey(CodexModelOptions).pipe( Schema.annotate({ @@ -73,9 +75,11 @@ export const ClaudeModelSelection = Schema.Struct({ }), ), model: TrimmedNonEmptyString.pipe( + Schema.flip, Schema.annotate({ description: "The Claude model slug to use for text generation.", }), + Schema.flip, ), options: Schema.optionalKey(ClaudeModelOptions).pipe( Schema.annotate({ diff --git a/scripts/lib/keybindings-schema.ts b/scripts/lib/keybindings-schema.ts index 0995506d06..deba37d4fe 100644 --- a/scripts/lib/keybindings-schema.ts +++ b/scripts/lib/keybindings-schema.ts @@ -1,10 +1,5 @@ import { KeybindingsConfig } from "@t3tools/contracts"; -import { - buildJsonSchemaDocument, - getJsonSchemaProperty, - setJsonSchemaDescription, - writeJsonSchemaArtifacts, -} from "./json-schema"; +import { buildJsonSchemaDocument, writeJsonSchemaArtifacts } from "./json-schema"; export const KEYBINDINGS_SCHEMA_RELATIVE_PATH = "apps/marketing/public/schemas/keybindings.json"; export const KEYBINDINGS_VERSIONED_SCHEMA_DIRECTORY_RELATIVE_PATH = @@ -14,31 +9,10 @@ export const getVersionedKeybindingsSchemaRelativePath = (version: string) => `${KEYBINDINGS_VERSIONED_SCHEMA_DIRECTORY_RELATIVE_PATH}/${version}.json`; export function buildKeybindingsJsonSchema(): Record { - const schema = buildJsonSchemaDocument(KeybindingsConfig, { + return buildJsonSchemaDocument(KeybindingsConfig, { title: "T3 Code Keybindings", description: "JSON Schema for the keybindings.json file consumed by T3 Code.", }); - - const items = - schema.items && typeof schema.items === "object" && !Array.isArray(schema.items) - ? (schema.items as Record) - : null; - - setJsonSchemaDescription(items, "Single keybinding rule entry in `keybindings.json`."); - setJsonSchemaDescription( - getJsonSchemaProperty(items ?? {}, "key"), - "Keyboard shortcut to listen for.", - ); - setJsonSchemaDescription( - getJsonSchemaProperty(items ?? {}, "command"), - "Command to execute when the shortcut matches.", - ); - setJsonSchemaDescription( - getJsonSchemaProperty(items ?? {}, "when"), - "Optional expression limiting when the shortcut is active.", - ); - - return schema; } export function writeKeybindingsJsonSchemas(options?: { diff --git a/scripts/lib/server-settings-schema.ts b/scripts/lib/server-settings-schema.ts index b1407ee8f8..3804ec0d25 100644 --- a/scripts/lib/server-settings-schema.ts +++ b/scripts/lib/server-settings-schema.ts @@ -1,12 +1,5 @@ import { ServerSettings } from "@t3tools/contracts/settings"; -import { - buildJsonSchemaDocument, - getJsonSchemaAnyOfBranches, - getJsonSchemaProperty, - getNullableJsonSchemaBranch, - setJsonSchemaDescription, - writeJsonSchemaArtifacts, -} from "./json-schema"; +import { buildJsonSchemaDocument, writeJsonSchemaArtifacts } from "./json-schema"; export const SERVER_SETTINGS_SCHEMA_RELATIVE_PATH = "apps/marketing/public/schemas/settings.json"; export const SERVER_SETTINGS_VERSIONED_SCHEMA_DIRECTORY_RELATIVE_PATH = @@ -33,70 +26,6 @@ export function buildServerSettingsJsonSchema(): Record { throw new Error("ServerSettings JSON schema must expose object properties."); } - setJsonSchemaDescription( - getNullableJsonSchemaBranch(getJsonSchemaProperty(schema, "enableAssistantStreaming")), - "Whether server-driven assistant responses should stream incrementally to clients when the active provider supports it.", - ); - setJsonSchemaDescription( - getNullableJsonSchemaBranch(getJsonSchemaProperty(schema, "defaultThreadEnvMode")), - "Default execution environment to use when creating new threads.", - ); - setJsonSchemaDescription( - getNullableJsonSchemaBranch(getJsonSchemaProperty(schema, "textGenerationModelSelection")), - "Default provider and model to use for server-side text generation features.", - ); - setJsonSchemaDescription( - getNullableJsonSchemaBranch(getJsonSchemaProperty(schema, "providers")), - "Provider-specific server configuration.", - ); - - const providersBranch = getNullableJsonSchemaBranch(getJsonSchemaProperty(schema, "providers")); - const codexBranch = getNullableJsonSchemaBranch( - getJsonSchemaProperty(providersBranch ?? {}, "codex"), - ); - const claudeBranch = getNullableJsonSchemaBranch( - getJsonSchemaProperty(providersBranch ?? {}, "claudeAgent"), - ); - - setJsonSchemaDescription(codexBranch, "Configuration for the Codex provider."); - setJsonSchemaDescription( - getNullableJsonSchemaBranch(getJsonSchemaProperty(codexBranch ?? {}, "binaryPath")), - "Path to the Codex executable. Leave blank to resolve the `codex` executable from PATH.", - ); - setJsonSchemaDescription( - getNullableJsonSchemaBranch(getJsonSchemaProperty(codexBranch ?? {}, "homePath")), - "Optional Codex home directory. Leave blank to use the default provider-managed location.", - ); - - setJsonSchemaDescription(claudeBranch, "Configuration for the Claude provider."); - setJsonSchemaDescription( - getNullableJsonSchemaBranch(getJsonSchemaProperty(claudeBranch ?? {}, "binaryPath")), - "Path to the Claude executable. Leave blank to resolve the `claude` executable from PATH.", - ); - - for (const selectionBranch of getJsonSchemaAnyOfBranches( - getNullableJsonSchemaBranch(getJsonSchemaProperty(schema, "textGenerationModelSelection")), - )) { - const providerProperty = getJsonSchemaProperty(selectionBranch, "provider"); - const providerBranch = getNullableJsonSchemaBranch(providerProperty); - const providerName = - Array.isArray(providerBranch?.enum) && typeof providerBranch.enum[0] === "string" - ? providerBranch.enum[0] - : null; - - if (providerName === "codex") { - setJsonSchemaDescription( - getJsonSchemaProperty(selectionBranch, "model"), - "The Codex model slug to use for text generation.", - ); - } else if (providerName === "claudeAgent") { - setJsonSchemaDescription( - getJsonSchemaProperty(selectionBranch, "model"), - "The Claude model slug to use for text generation.", - ); - } - } - return { ...schema, properties: {