Move schema descriptions into contracts

- Inline settings and keybinding schema descriptions in shared contracts
- Simplify schema generation scripts to emit the updated docs
This commit is contained in:
Julius Marminge committed 2026-03-30 22:31:33 -07:00
1 parent 32f1d4c34f
commit c3097ba5d7
5 files changed
+15 -106

No files matched your search

+6 -6
View File
@@ -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"
+2
View File
@@ -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({
+4
View File
@@ -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({
+2 -28
View File
@@ -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<string, unknown> {
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<string, unknown>)
: 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?: {
+1 -72
View File
@@ -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<string, unknown> {
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: {