Configure lefthook formatter checks (#231)

* Add lefthook formatter checks

* Fix SDK mode hydration

* Stabilize SDK mode integration test
This commit is contained in:
Nathan Flurry 2026-03-10 23:03:11 -07:00 committed by GitHub
parent 0471214d65
commit d2346bafb3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
282 changed files with 5840 additions and 8399 deletions

View file

@ -37,9 +37,7 @@
},
"error": {}
},
"required": [
"type"
]
"required": ["type"]
},
"RpcMessage": {
"type": "object",
@ -96,9 +94,7 @@
"data": {},
"error": {}
},
"required": [
"type"
]
"required": ["type"]
},
"RpcCommand": {
"type": "object",
@ -115,10 +111,7 @@
},
"params": {}
},
"required": [
"type",
"command"
]
"required": ["type", "command"]
}
}
}
}

View file

@ -66,18 +66,11 @@ function findRepoRoot(root: string): string {
}
function resolveTsconfig(root: string): string | undefined {
const candidates = [
join(root, "tsconfig.json"),
join(root, "tsconfig.base.json"),
join(root, "packages", "coding-agent", "tsconfig.json"),
];
const candidates = [join(root, "tsconfig.json"), join(root, "tsconfig.base.json"), join(root, "packages", "coding-agent", "tsconfig.json")];
return candidates.find((path) => existsSync(path));
}
function generateDefinitions(
rpcTypesPath: string,
tsconfigPath?: string
): Record<string, JSONSchema7> {
function generateDefinitions(rpcTypesPath: string, tsconfigPath?: string): Record<string, JSONSchema7> {
const definitions: Record<string, JSONSchema7> = {};
for (const typeName of TARGET_TYPES) {
@ -96,11 +89,7 @@ function generateDefinitions(
return definitions;
}
function mergeDefinitions(
target: Record<string, JSONSchema7>,
schema: JSONSchema7,
typeName: string
): void {
function mergeDefinitions(target: Record<string, JSONSchema7>, schema: JSONSchema7, typeName: string): void {
if (schema.definitions) {
for (const [name, def] of Object.entries(schema.definitions)) {
target[name] = def as JSONSchema7;

View file

@ -11,11 +11,7 @@
},
"role": {
"type": "string",
"enum": [
"system",
"user",
"assistant"
],
"enum": ["system", "user", "assistant"],
"description": "The role of the message."
},
"metadata": {
@ -38,10 +34,7 @@
},
"state": {
"type": "string",
"enum": [
"streaming",
"done"
],
"enum": ["streaming", "done"],
"description": "The state of the text part."
},
"providerMetadata": {
@ -85,10 +78,7 @@
"description": "The provider metadata."
}
},
"required": [
"type",
"text"
],
"required": ["type", "text"],
"additionalProperties": false,
"description": "A text part of a message."
},
@ -105,10 +95,7 @@
},
"state": {
"type": "string",
"enum": [
"streaming",
"done"
],
"enum": ["streaming", "done"],
"description": "The state of the reasoning part."
},
"providerMetadata": {
@ -152,10 +139,7 @@
"description": "The provider metadata."
}
},
"required": [
"type",
"text"
],
"required": ["type", "text"],
"additionalProperties": false,
"description": "A reasoning part of a message."
},
@ -232,12 +216,7 @@
"description": "Whether the tool call was executed by the provider."
}
},
"required": [
"state",
"toolCallId",
"toolName",
"type"
]
"required": ["state", "toolCallId", "toolName", "type"]
},
{
"type": "object",
@ -308,13 +287,7 @@
"description": "Whether the tool call was executed by the provider."
}
},
"required": [
"input",
"state",
"toolCallId",
"toolName",
"type"
]
"required": ["input", "state", "toolCallId", "toolName", "type"]
},
{
"type": "object",
@ -372,9 +345,7 @@
"type": "string"
}
},
"required": [
"id"
],
"required": ["id"],
"additionalProperties": false
},
"type": {
@ -397,14 +368,7 @@
"description": "Whether the tool call was executed by the provider."
}
},
"required": [
"approval",
"input",
"state",
"toolCallId",
"toolName",
"type"
]
"required": ["approval", "input", "state", "toolCallId", "toolName", "type"]
},
{
"type": "object",
@ -468,10 +432,7 @@
"type": "string"
}
},
"required": [
"id",
"approved"
],
"required": ["id", "approved"],
"additionalProperties": false
},
"type": {
@ -494,14 +455,7 @@
"description": "Whether the tool call was executed by the provider."
}
},
"required": [
"approval",
"input",
"state",
"toolCallId",
"toolName",
"type"
]
"required": ["approval", "input", "state", "toolCallId", "toolName", "type"]
},
{
"type": "object",
@ -570,10 +524,7 @@
"type": "string"
}
},
"required": [
"id",
"approved"
],
"required": ["id", "approved"],
"additionalProperties": false
},
"type": {
@ -596,14 +547,7 @@
"description": "Whether the tool call was executed by the provider."
}
},
"required": [
"input",
"output",
"state",
"toolCallId",
"toolName",
"type"
]
"required": ["input", "output", "state", "toolCallId", "toolName", "type"]
},
{
"type": "object",
@ -671,10 +615,7 @@
"type": "string"
}
},
"required": [
"id",
"approved"
],
"required": ["id", "approved"],
"additionalProperties": false
},
"type": {
@ -697,14 +638,7 @@
"description": "Whether the tool call was executed by the provider."
}
},
"required": [
"errorText",
"input",
"state",
"toolCallId",
"toolName",
"type"
]
"required": ["errorText", "input", "state", "toolCallId", "toolName", "type"]
},
{
"type": "object",
@ -769,10 +703,7 @@
"type": "string"
}
},
"required": [
"id",
"approved"
],
"required": ["id", "approved"],
"additionalProperties": false
},
"type": {
@ -795,14 +726,7 @@
"description": "Whether the tool call was executed by the provider."
}
},
"required": [
"approval",
"input",
"state",
"toolCallId",
"toolName",
"type"
]
"required": ["approval", "input", "state", "toolCallId", "toolName", "type"]
},
{
"type": "object",
@ -861,11 +785,7 @@
"description": "Additional provider-specific metadata that is returned from the provider.\n\nThis is needed to enable provider-specific functionality that can be fully encapsulated in the provider."
}
},
"required": [
"type",
"sourceId",
"url"
],
"required": ["type", "sourceId", "url"],
"additionalProperties": false,
"description": "A source part of a message."
},
@ -929,12 +849,7 @@
"description": "Additional provider-specific metadata that is returned from the provider.\n\nThis is needed to enable provider-specific functionality that can be fully encapsulated in the provider."
}
},
"required": [
"type",
"sourceId",
"mediaType",
"title"
],
"required": ["type", "sourceId", "mediaType", "title"],
"additionalProperties": false,
"description": "A document source part of a message."
},
@ -998,11 +913,7 @@
"description": "The provider metadata."
}
},
"required": [
"type",
"mediaType",
"url"
],
"required": ["type", "mediaType", "url"],
"additionalProperties": false,
"description": "A file part of a message."
},
@ -1018,9 +929,7 @@
"const": "step-start"
}
},
"required": [
"type"
],
"required": ["type"],
"additionalProperties": false,
"description": "A step boundary part of a message."
}
@ -1029,11 +938,7 @@
"description": "The parts of the message. Use this for rendering the message in the UI.\n\nSystem messages should be avoided (set the system prompt on the server instead). They can have text parts.\n\nUser messages can have text parts and file parts.\n\nAssistant messages can have text, reasoning, tool invocation, and file parts."
}
},
"required": [
"id",
"role",
"parts"
],
"required": ["id", "role", "parts"],
"additionalProperties": false,
"description": "AI SDK UI Messages. They are used in the client and to communicate between the frontend and the API routes."
},
@ -1103,4 +1008,4 @@
"$id": "https://sandbox-agent/schemas/vercel-ai-sdk/ui-message.json",
"title": "UIMessage",
"description": "Vercel AI SDK v6.0.50 UIMessage"
}
}

View file

@ -1,13 +1,4 @@
import {
mkdtempSync,
mkdirSync,
readFileSync,
rmSync,
writeFileSync,
existsSync,
appendFileSync,
statSync,
} from "fs";
import { mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync, existsSync, appendFileSync, statSync } from "fs";
import { join } from "path";
import { tmpdir } from "os";
import { createGenerator, type Config } from "ts-json-schema-generator";
@ -117,15 +108,8 @@ function packageDirFor(name: string, nodeModulesDir: string): string {
return join(nodeModulesDir, ...parts);
}
async function installPackage(
name: string,
versionRange: string,
nodeModulesDir: string,
installed: Set<string>
): Promise<void> {
const encodedName = name.startsWith("@")
? `@${encodeURIComponent(name.slice(1))}`
: encodeURIComponent(name);
async function installPackage(name: string, versionRange: string, nodeModulesDir: string, installed: Set<string>): Promise<void> {
const encodedName = name.startsWith("@") ? `@${encodeURIComponent(name.slice(1))}` : encodeURIComponent(name);
const registryUrl = `https://registry.npmjs.org/${encodedName}`;
const registry = await fetchRegistry(registryUrl);
const version = resolveVersionFromRange(registry, versionRange);
@ -208,10 +192,7 @@ function patchValueOfAlias(nodeModulesDir: string): void {
log(" [warn] ValueOf alias declaration not found");
}
let patched = contents.replace(
/ObjectType\\s*\\[\\s*ValueType\\s*\\]/,
"ObjectType[string]"
);
let patched = contents.replace(/ObjectType\\s*\\[\\s*ValueType\\s*\\]/, "ObjectType[string]");
if (patched !== contents) {
writeFileSync(aiTypesPath, patched);
@ -220,8 +201,7 @@ function patchValueOfAlias(nodeModulesDir: string): void {
}
const valueOfIndex = contents.indexOf("ValueOf");
const preview =
valueOfIndex === -1 ? contents.slice(0, 200) : contents.slice(valueOfIndex, valueOfIndex + 200);
const preview = valueOfIndex === -1 ? contents.slice(0, 200) : contents.slice(valueOfIndex, valueOfIndex + 200);
log(" [warn] ValueOf alias not found in ai types");
log(` [debug] ai types path: ${aiTypesPath}`);
log(` [debug] preview: ${preview.replace(/\\s+/g, " ").slice(0, 200)}`);
@ -318,7 +298,7 @@ function patchUiMessageTypes(nodeModulesDir: string): void {
const dataReplaced = replaceAlias(
"DataUIPart",
"type DataUIPart<DATA_TYPES extends UIDataTypes> = {\\n type: `data-${string}`;\\n id?: string;\\n data: unknown;\\n};"
"type DataUIPart<DATA_TYPES extends UIDataTypes> = {\\n type: `data-${string}`;\\n id?: string;\\n data: unknown;\\n};",
);
if (dataReplaced) {
log(" [patch] Simplified DataUIPart to avoid indexed access");
@ -326,7 +306,7 @@ function patchUiMessageTypes(nodeModulesDir: string): void {
const toolReplaced = replaceAlias(
"ToolUIPart",
"type ToolUIPart<TOOLS extends UITools = UITools> = {\\n type: `tool-${string}`;\\n} & UIToolInvocation<UITool>;"
"type ToolUIPart<TOOLS extends UITools = UITools> = {\\n type: `tool-${string}`;\\n} & UIToolInvocation<UITool>;",
);
if (toolReplaced) {
log(" [patch] Simplified ToolUIPart to avoid indexed access");