From 83e4755b55e8864e48348f3eb2364ee3e5f0fb54 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Thu, 1 Oct 2026 01:23:59 -0700 Subject: [PATCH] fix(build): complete source-only Kysely preparation Keep the packed prepare hook independent of the unshipped source generator: invoke its CLI only when source schemas exist and preserve failure exits. Prepare declarations through their existing owner before direct tsgo profiling. This completes the source preparation gaps from 6337d159e391 (#162288). Update behavior: published npm installs have no source schemas and skip source preparation. No database, rollback, or runtime update behavior changes. No published version contains the regressing commit; 2026.9.7 predates it. Validation: real pnpm-pack tarball fails the missing-import guard before and passes after; cold profiler fails before and passes after. Focused owner and package tests, changed checks, boundary lint, architecture, and P2 review pass. --- scripts/prepare-git-hooks.mjs | 12 ++++++++++-- scripts/profile-tsgo.mts | 2 ++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/scripts/prepare-git-hooks.mjs b/scripts/prepare-git-hooks.mjs index d00bd6b14646..84ba741384f9 100644 --- a/scripts/prepare-git-hooks.mjs +++ b/scripts/prepare-git-hooks.mjs @@ -55,8 +55,16 @@ export function configurePrepareGitHooks(params = {}) { if (import.meta.url === pathToFileURL(process.argv[1] ?? "").href) { if (existsSync(join(DEFAULT_PACKAGE_ROOT, "src/state/openclaw-state-schema.sql"))) { - const { ensureKyselyTypes } = await import("./generate-kysely-types.mts"); - await ensureKyselyTypes(DEFAULT_PACKAGE_ROOT); + // Source preparation uses the generator CLI; packaged installs have no schemas. + const generated = spawnSync(process.execPath, [join(scriptDir, "generate-kysely-types.mts")], { + stdio: "inherit", + }); + if (generated.error) { + throw generated.error; + } + if (generated.status !== 0) { + process.exit(generated.status ?? 1); + } } configurePrepareGitHooks(); } diff --git a/scripts/profile-tsgo.mts b/scripts/profile-tsgo.mts index 91d393efff0c..8c90a5c4ae35 100644 --- a/scripts/profile-tsgo.mts +++ b/scripts/profile-tsgo.mts @@ -6,6 +6,7 @@ import { spawnSync } from "node:child_process"; import fs from "node:fs"; import os from "node:os"; import path from "node:path"; +import { ensureKyselyTypes } from "./generate-kysely-types.mts"; import { applyLocalTsgoPolicy, resolveRepoToolBinPath } from "./lib/local-check-runtime.mts"; import { createManagedCommandInvocation } from "./lib/managed-child-process.mts"; import { resolveRepoRoot } from "./lib/repo-root.mjs"; @@ -419,6 +420,7 @@ function profileGraph(name: GraphName, options: ProfileOptions) { async function main(argv: string[]): Promise { const { options, selectedGraphs } = parseArgs(argv); + await ensureKyselyTypes(repoRoot); ensureDirs(options.outDir); const report: ProfileReport = { generatedAt: new Date().toISOString(),