gencow 0.1.299 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/bin/gencow.mjs +0 -6
  2. package/core/package.json +1 -1
  3. package/docs/packaging.md +14 -4
  4. package/lib/cli-artifact-guard.mjs +53 -3
  5. package/lib/cli-dev-runtime.mjs +1 -0
  6. package/lib/cli-project-runtime.mjs +26 -14
  7. package/lib/codegen-command.mjs +16 -0
  8. package/lib/coding-guardrails.mjs +2 -0
  9. package/lib/dashboard-artifact.mjs +65 -0
  10. package/lib/dashboard-assets.mjs +20 -0
  11. package/lib/db-command.mjs +121 -80
  12. package/lib/db-migration-command-steps.mjs +19 -16
  13. package/lib/db-push-command.mjs +1 -1
  14. package/lib/deploy-codegen-preflight.mjs +1 -0
  15. package/lib/dev-cloud-command.mjs +1 -1
  16. package/lib/dev-local-command.mjs +19 -56
  17. package/lib/document-local-converter.mjs +11 -0
  18. package/lib/local-dashboard-plan.mjs +60 -0
  19. package/lib/local-database-commands.mjs +127 -0
  20. package/lib/local-development-migrations.mjs +157 -0
  21. package/lib/local-drizzle-database.config.mjs +10 -0
  22. package/lib/local-runtime-features.mjs +12 -0
  23. package/lib/rag-selection.mjs +7 -0
  24. package/lib/runtime-local-worker.mjs +116 -0
  25. package/lib/runtime-mode.mjs +3 -0
  26. package/lib/standalone-codegen-adapter.mjs +91 -0
  27. package/lib/ts-codegen-import-extension.mjs +228 -19
  28. package/package.json +15 -8
  29. package/runtime/config.mjs +218 -2
  30. package/runtime/engine/chunk-2HA4CUMS.mjs +90 -0
  31. package/runtime/engine/chunk-2JLO3KMM.mjs +305 -0
  32. package/runtime/engine/chunk-2SR2M7SR.mjs +1045 -0
  33. package/runtime/engine/chunk-3D7MHEUC.mjs +253 -0
  34. package/runtime/engine/chunk-3R7COBWG.mjs +309 -0
  35. package/runtime/engine/chunk-3ZKA54UW.mjs +1560 -0
  36. package/runtime/engine/chunk-45I4YR2J.mjs +9 -0
  37. package/runtime/engine/chunk-4MLRXO7F.mjs +74 -0
  38. package/runtime/engine/chunk-5575APCJ.mjs +215 -0
  39. package/runtime/engine/chunk-5GUJZQF3.mjs +114 -0
  40. package/runtime/engine/chunk-5MXY3T75.mjs +428 -0
  41. package/runtime/engine/chunk-5TACQ2US.mjs +44 -0
  42. package/runtime/engine/chunk-66G4YEDT.mjs +3104 -0
  43. package/runtime/engine/chunk-67YO53WW.mjs +1426 -0
  44. package/runtime/engine/chunk-6GQRM7XY.mjs +87 -0
  45. package/runtime/engine/chunk-6JO72SPP.mjs +68 -0
  46. package/runtime/engine/chunk-6W653LXI.mjs +13 -0
  47. package/runtime/engine/chunk-7ITSMI3S.mjs +69 -0
  48. package/runtime/engine/chunk-7KUJ2H2S.mjs +128 -0
  49. package/runtime/engine/chunk-A5BMQ5IC.mjs +45 -0
  50. package/runtime/engine/chunk-ADF3UR6L.mjs +428 -0
  51. package/runtime/engine/chunk-AEBW7XZJ.mjs +4510 -0
  52. package/runtime/engine/chunk-AGPQ5XIV.mjs +156 -0
  53. package/runtime/engine/chunk-CPU4OZSX.mjs +753 -0
  54. package/runtime/engine/chunk-CSWPPWBL.mjs +50 -0
  55. package/runtime/engine/chunk-DPWXSMWO.mjs +53 -0
  56. package/runtime/engine/chunk-EAIELFKU.mjs +151 -0
  57. package/runtime/engine/chunk-EDU5CBKT.mjs +10 -0
  58. package/runtime/engine/chunk-EQCTAET7.mjs +173 -0
  59. package/runtime/engine/chunk-EQCXDF2Z.mjs +70 -0
  60. package/runtime/engine/chunk-F3G4UGV4.mjs +330 -0
  61. package/runtime/engine/chunk-F62NUNOO.mjs +26 -0
  62. package/runtime/engine/chunk-FKPNIFRP.mjs +2492 -0
  63. package/runtime/engine/chunk-FM23RGVI.mjs +81 -0
  64. package/runtime/engine/chunk-FW5AK4YP.mjs +1041 -0
  65. package/runtime/engine/chunk-GDWYAGWV.mjs +23 -0
  66. package/runtime/engine/chunk-GO5PZUYW.mjs +53 -0
  67. package/runtime/engine/chunk-GOLP7OSG.mjs +340 -0
  68. package/runtime/engine/chunk-GSLM44EF.mjs +242 -0
  69. package/runtime/engine/chunk-GYAJ7OX2.mjs +125 -0
  70. package/runtime/engine/chunk-I3GWR43K.mjs +14 -0
  71. package/runtime/engine/chunk-IFMOTJNU.mjs +106 -0
  72. package/runtime/engine/chunk-IKQKBE2G.mjs +128 -0
  73. package/runtime/engine/chunk-ITH2NEKM.mjs +282 -0
  74. package/runtime/engine/chunk-J6SDRCG4.mjs +96 -0
  75. package/runtime/engine/chunk-JODRNM3S.mjs +29596 -0
  76. package/runtime/engine/chunk-JUDKX53X.mjs +137 -0
  77. package/runtime/engine/chunk-K2YZVPJ4.mjs +827 -0
  78. package/runtime/engine/chunk-KEZJUXEE.mjs +151 -0
  79. package/runtime/engine/chunk-KVLTJFCH.mjs +234 -0
  80. package/runtime/engine/chunk-KX2PRQPS.mjs +126 -0
  81. package/runtime/engine/chunk-LEW5ZMLR.mjs +76 -0
  82. package/runtime/engine/chunk-LINVSJEM.mjs +175 -0
  83. package/runtime/engine/chunk-M7K2ICSM.mjs +11 -0
  84. package/runtime/engine/chunk-MZXDXSDC.mjs +292 -0
  85. package/runtime/engine/chunk-N2TA2IK2.mjs +678 -0
  86. package/runtime/engine/chunk-N4LTCKJP.mjs +695 -0
  87. package/runtime/engine/chunk-N6GCLOUX.mjs +13 -0
  88. package/runtime/engine/chunk-NAG2OXS5.mjs +37 -0
  89. package/runtime/engine/chunk-NNZ2QJUG.mjs +381 -0
  90. package/runtime/engine/chunk-NZPPLDNW.mjs +15 -0
  91. package/runtime/engine/chunk-ODWM57W6.mjs +138 -0
  92. package/runtime/engine/chunk-P5IIXAIE.mjs +23 -0
  93. package/runtime/engine/chunk-PBOXB2BV.mjs +6 -0
  94. package/runtime/engine/chunk-PMOJLN2P.mjs +8 -0
  95. package/runtime/engine/chunk-PZFMKFHO.mjs +180 -0
  96. package/runtime/engine/chunk-QL2TQX2N.mjs +114 -0
  97. package/runtime/engine/chunk-RITT2RSJ.mjs +258 -0
  98. package/runtime/engine/chunk-RODBVJ5M.mjs +135 -0
  99. package/runtime/engine/chunk-RW65MPVY.mjs +261 -0
  100. package/runtime/engine/chunk-S67UYPB6.mjs +25 -0
  101. package/runtime/engine/chunk-SVJCOUI3.mjs +47 -0
  102. package/runtime/engine/chunk-TCN3ZASV.mjs +957 -0
  103. package/runtime/engine/chunk-U2NRG6KC.mjs +32 -0
  104. package/runtime/engine/chunk-UM3F7HUV.mjs +432 -0
  105. package/runtime/engine/chunk-VWU7JJ3P.mjs +146 -0
  106. package/runtime/engine/chunk-WDTKPPMU.mjs +310 -0
  107. package/runtime/engine/chunk-WJOO4XTB.mjs +31 -0
  108. package/runtime/engine/chunk-XNFVL2OY.mjs +63 -0
  109. package/runtime/engine/chunk-XPWJXP2J.mjs +58 -0
  110. package/runtime/engine/chunk-Y3HSBJ3I.mjs +1132 -0
  111. package/runtime/engine/chunk-YMH4RYSX.mjs +317 -0
  112. package/runtime/engine/chunk-YNOMPSGS.mjs +8 -0
  113. package/runtime/engine/chunk-YRBAYTEZ.mjs +251 -0
  114. package/runtime/engine/chunk-YRHM272W.mjs +528 -0
  115. package/runtime/engine/chunk-ZQUZAGIQ.mjs +149 -0
  116. package/runtime/engine/chunk-ZXMM7QFP.mjs +176 -0
  117. package/runtime/engine/chunk-ZZJSIPV2.mjs +262 -0
  118. package/runtime/engine/composition.mjs +325 -0
  119. package/runtime/engine/document-local.mjs +504 -0
  120. package/runtime/engine/graph.json +4134 -0
  121. package/runtime/engine/index.mjs +265 -0
  122. package/runtime/engine/local-postgres-support.mjs +69 -0
  123. package/runtime/engine/local.mjs +3275 -0
  124. package/runtime/engine/pglite-directory-lock.mjs +8 -0
  125. package/runtime/engine/rag.mjs +11 -0
  126. package/runtime/engine/search.mjs +18 -0
  127. package/runtime/framework-migrations/foundation-bootstrap/rag.sql +115 -0
  128. package/runtime/framework-migrations/foundation-bootstrap/workflow.sql +194 -0
  129. package/runtime/framework-migrations/journal-bootstrap/migration.sql +26 -0
  130. package/runtime/framework-migrations/manifest.json +56 -0
  131. package/runtime/framework-migrations/rag/20261006111509_mushy_warhawk/migration.sql +121 -0
  132. package/runtime/framework-migrations/rag/20261013234621_rag_v2_lifecycle_markers/migration.sql +6 -0
  133. package/runtime/framework-migrations/workflow/20261006111508_perpetual_star_brand/migration.sql +31 -0
  134. package/runtime/runtime-metadata.json +27 -0
  135. package/runtime/tooling.mjs +10399 -8951
  136. package/scripts/bundle-runtime-config.mjs +23 -0
  137. package/scripts/bundle-runtime.mjs +100 -0
  138. package/scripts/bundle-runtime.test.mjs +33 -0
  139. package/scripts/bundle-shared.mjs +3 -0
  140. package/scripts/copy-dashboard.mjs +16 -0
  141. package/scripts/pre-publish-check.mjs +23 -11
  142. package/templateFeature/ai/ai-facade.ts +38 -15
  143. package/templateFeature/ai/manifest.json +1 -0
  144. package/templateFeature/sso/sso-auth-callback.tsx +37 -5
  145. package/templateFeature/tools/manifest.json +5 -2
  146. package/templateFeature/tools/tools.ts +3 -3
  147. package/runtime/server.mjs +0 -14389
  148. package/scripts/bundle-server.mjs +0 -223
  149. package/server/config.js +0 -1
  150. package/server/index.js +0 -1
  151. package/server/package.json +0 -6
package/bin/gencow.mjs CHANGED
@@ -53,7 +53,6 @@ import {
53
53
  isMonorepo,
54
54
  loadConfig,
55
55
  runInServer,
56
- spawnInServer,
57
56
  updateEnvLocalUrl,
58
57
  } from "../lib/cli-project-runtime.mjs";
59
58
  import { createCodegenCommand } from "../lib/codegen-command.mjs";
@@ -108,7 +107,6 @@ import {
108
107
  } from "../lib/output.mjs";
109
108
  import { platformFetch, requireCreds, rpcMutation, rpcQuery } from "../lib/platform-client.mjs";
110
109
  import { failReleaseAttempt, finalizeReleaseAttempt, prepareReleaseAttempt } from "../lib/release-client.mjs";
111
-
112
110
  const __dirname = dirname(fileURLToPath(import.meta.url));
113
111
  const CLI_PACKAGE_JSON = JSON.parse(readFileSync(resolve(__dirname, "..", "package.json"), "utf8"));
114
112
  const CLI_VERSION = CLI_PACKAGE_JSON.version || "0.0.0";
@@ -250,9 +248,7 @@ const { dev: runDevCommand, devLocal: runDevLocalCommand } = createDevLocalComma
250
248
  drizzleKitCmdImpl: _drizzleKitCmd,
251
249
  errorImpl: error,
252
250
  exitImpl: (code) => process.exit(code),
253
- findServerRoot,
254
251
  generateApiTsImpl: generateApiTs,
255
- isMonorepo,
256
252
  loadConfig,
257
253
  logImpl: log,
258
254
  infoImpl: info,
@@ -261,7 +257,6 @@ const { dev: runDevCommand, devLocal: runDevLocalCommand } = createDevLocalComma
261
257
  processEnv: process.env,
262
258
  processRef: process,
263
259
  runDevCloudImpl: runDevCloudCommand,
264
- spawnInServer,
265
260
  });
266
261
  const runConfigCommand = createConfigCommand();
267
262
  const runCorsCommand = createCorsCommand();
@@ -351,7 +346,6 @@ const runStaticCommand = createStaticCommand({
351
346
  const runTemplatesCommand = createTemplateMarketplaceCommand();
352
347
 
353
348
  // ─── Commands ─────────────────────────────────────────────
354
-
355
349
  const commands = {
356
350
  init: runInitCommand,
357
351
  "db:reset": runDbResetCommand,
package/core/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gencow/core",
3
- "version": "0.1.48",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "main": "index.js"
6
6
  }
package/docs/packaging.md CHANGED
@@ -43,12 +43,22 @@ Build from a complete repository checkout; workspace dependencies are required:
43
43
  pnpm --dir packages/cli run build:with-deps
44
44
  ```
45
45
 
46
- `build:with-deps` builds the CLI's workspace dependencies (`@gencow/server`,
47
- `@gencow/internal`, `@gencow/core`, and the rest of the CLI closure) once each in
48
- topological order, then produces the package runtime artifacts. It selects packages
46
+ `build:with-deps` builds the CLI's workspace dependencies in topological order,
47
+ then builds the local dashboard application and produces the package runtime
48
+ artifacts. It selects packages
49
49
  with the path selector `{.}...` rather than the name `gencow...`, because the root
50
50
  package is also named `gencow` and a name selector would build the whole workspace. The plain `build`
51
- script does not build dependencies; it expects their `dist/` output to exist. After the build,
51
+ script expects the runtime dependencies' `dist/` output to exist, but always builds
52
+ the dashboard (including its own UI and client prerequisites). Both complete
53
+ builds validate and copy the dashboard's complete built tree; a dashboard build
54
+ failure or missing/invalid artifact fails the CLI build instead of silently
55
+ accepting an old packaged copy. No separate dashboard build is needed.
56
+
57
+ `build:runtime-bundles` is the narrower runtime-only rebuild for already prepared
58
+ runtime dependencies. It does not build the dashboard and retains its optional
59
+ copy behavior; it is not a complete CLI package build.
60
+
61
+ After a complete build,
52
62
  from `packages/cli`, create a local tarball without running package lifecycle
53
63
  hooks, inspect its file list, and run the package integrity check:
54
64
 
@@ -1,3 +1,5 @@
1
+ import { createHash } from "node:crypto";
2
+
1
3
  export const REQUIRED_CLI_TARBALL_FILES = Object.freeze([
2
4
  "bin/gencow.mjs",
3
5
  "bin/gencow-mcp.mjs",
@@ -8,13 +10,14 @@ export const REQUIRED_CLI_TARBALL_FILES = Object.freeze([
8
10
  "lib/canonical-drizzle-generator.config.mjs",
9
11
  "lib/canonical-drizzle-generator-paths.mjs",
10
12
  "runtime/tooling.mjs",
11
- "runtime/server.mjs",
13
+ "runtime/runtime-metadata.json",
14
+ "runtime/engine/graph.json",
15
+ ...["index", "local", "composition", "search", "rag", "local-postgres-support", "pglite-directory-lock", "document-local"].map(name => `runtime/engine/${name}.mjs`),
16
+ "runtime/framework-migrations/manifest.json",
12
17
  "runtime/dependency-lock.mjs",
13
18
  "runtime/dependency-version-report.mjs",
14
19
  "templateFeature/ai/manifest.json",
15
20
  "templateFeature/ai/ai.ts",
16
- "server/index.js",
17
- "server/config.js",
18
21
  "core/index.js",
19
22
  "runtime/config.mjs",
20
23
  "dashboard/index.html",
@@ -68,6 +71,9 @@ export function validateCliTarballFiles(files, requiredFiles = REQUIRED_CLI_TARB
68
71
  errors.push({ ...forbidden });
69
72
  }
70
73
  }
74
+ for (const path of files.filter(path => path === "runtime/server.mjs" || path.startsWith("server/"))) {
75
+ errors.push({ code: "forbidden-server-artifact", path, message: "Server runtime artifacts must not be published in the CLI." });
76
+ }
71
77
 
72
78
  for (const path of requiredFiles) {
73
79
  if (!fileSet.has(path)) {
@@ -85,6 +91,50 @@ export function validateCliTarballFiles(files, requiredFiles = REQUIRED_CLI_TARB
85
91
  };
86
92
  }
87
93
 
94
+ /** Validate the emitted bundle graph against the actual pack list and bytes. */
95
+ export function validateRuntimeGraph({ files, graph, readFile }) {
96
+ const included = new Set(files), errors = [];
97
+ const fail = (code, path, message) => errors.push({ code, path, message });
98
+ const outputs = graph?.version === 1 && graph.outputs && typeof graph.outputs === "object" && !Array.isArray(graph.outputs) ? graph.outputs : null;
99
+ if (!outputs || Object.keys(outputs).length === 0) {
100
+ fail("runtime-graph-invalid", "runtime/engine/graph.json", "Runtime bundle graph metadata is missing or invalid.");
101
+ return { ok: false, errors };
102
+ }
103
+ for (const path of included) {
104
+ if (
105
+ path.startsWith("runtime/engine/") &&
106
+ path !== "runtime/engine/graph.json" &&
107
+ !Object.hasOwn(outputs, path)
108
+ )
109
+ fail("runtime-graph-unlisted-output", path, "Runtime bundle contains an output absent from its build graph.");
110
+ }
111
+ for (const [path, details] of Object.entries(outputs)) {
112
+ if (!/^runtime\/engine\/[A-Za-z0-9_.-]+\.mjs$/u.test(path) || !details || !/^[0-9a-f]{64}$/u.test(details.sha256 ?? "") || !Array.isArray(details.imports)) {
113
+ fail("runtime-graph-invalid", "runtime/engine/graph.json", "Runtime graph contains an invalid entry."); continue;
114
+ }
115
+ if (!included.has(path)) { fail("runtime-graph-missing", path, "Runtime graph output is absent from the tarball."); continue; }
116
+ try {
117
+ if (createHash("sha256").update(readFile(path)).digest("hex") !== details.sha256)
118
+ fail("runtime-graph-digest", path, "Runtime graph output does not match its build metadata.");
119
+ } catch { fail("runtime-graph-unreadable", path, "Runtime graph output is unreadable."); }
120
+ for (const entry of details.imports) {
121
+ if (!entry || typeof entry.path !== "string" || typeof entry.external !== "boolean") {
122
+ fail("runtime-graph-invalid", path, "Runtime graph contains an invalid import."); continue;
123
+ }
124
+ if (entry.external) {
125
+ if (/^@gencow\/(?:server|runtime(?:-hosted)?|internal|platform)(?:\/|$)/u.test(entry.path))
126
+ fail("runtime-graph-private-import", path, "Runtime bundle depends on an excluded Runtime or private package.");
127
+ } else if (!Object.hasOwn(outputs, entry.path) || !included.has(entry.path)) {
128
+ fail("runtime-graph-missing-import", path, "A Runtime bundle chunk is missing from the tarball.");
129
+ }
130
+ }
131
+ }
132
+ for (const path of REQUIRED_CLI_TARBALL_FILES.filter(path => /^runtime\/engine\/.*\.mjs$/u.test(path))) {
133
+ if (!Object.hasOwn(outputs, path)) fail("runtime-graph-missing-entry", path, "Required Runtime entry is not in the bundle graph.");
134
+ }
135
+ return { ok: errors.length === 0, errors };
136
+ }
137
+
88
138
  export function validateGeneratedCodegenBundle(source, options = {}) {
89
139
  const artifactPath = options.artifactPath ?? TOOLING_RUNTIME_BUNDLE_PATH;
90
140
  const errors = [];
@@ -167,6 +167,7 @@ export function createApiCodegenRuntime(options = {}) {
167
167
  const { bundled } = await runCodegenWithReporting({
168
168
  config,
169
169
  cwd,
170
+ includeStandalone: runtimeOptions.includeStandalone,
170
171
  diagnosticsColors: { CYAN, YELLOW, RED, RESET, DIM },
171
172
  emitAuthSchemaArtifactImpl,
172
173
  loadCodegenBundleImpl,
@@ -20,7 +20,7 @@ import { detectProjectConfigFile, warnProjectConfigSelectionOnce } from "./proje
20
20
  import { hasWorkspaceConfigSourceRuntime } from "./runtime-mode.mjs";
21
21
  import { SUPPORTED_DRIZZLE_KIT_GENERATOR_VERSION } from "./drizzle-generate.mjs";
22
22
  import { buildDrizzleGeneratorInvocation } from "./drizzle-generator-invocation.mjs";
23
- import { readTsCodegenImportExtension } from "./ts-codegen-import-extension.mjs";
23
+ import { readTsCodegenImportExtension, readTsProjectFeatures } from "./ts-codegen-import-extension.mjs";
24
24
 
25
25
  const __dirname = dirname(fileURLToPath(import.meta.url));
26
26
 
@@ -192,7 +192,7 @@ function parseTsConfigViaRegex(src) {
192
192
  return match ? match[1] === "true" : null;
193
193
  };
194
194
 
195
- const result = {};
195
+ const result = readTsProjectFeatures(originalSource);
196
196
  const rootDir = extract("rootDir");
197
197
  if (rootDir !== null) result.rootDir = rootDir;
198
198
  const functionsDir = extract("functionsDir");
@@ -339,8 +339,9 @@ export async function loadConfig(options = {}) {
339
339
  parseTsImpl = parseTsConfigViaRegex,
340
340
  cache = loadConfigCache,
341
341
  throwOnInvalid = true,
342
+ validateLoadedConfig,
342
343
  } = options;
343
- const { gencowConfigSchema, getDefaultConfig } = await loadConfigModule();
344
+ const { gencowConfigSchema, getDefaultConfig, validateProjectFeatures } = await loadConfigModule();
344
345
 
345
346
  let path = null;
346
347
  try {
@@ -387,13 +388,17 @@ export async function loadConfig(options = {}) {
387
388
  // Per-process cache keyed by (path, mtimeMs). Same CLI invocation can call
388
389
  // loadConfig multiple times across commands; no need to re-import.
389
390
  let mtimeMs = 0;
391
+ let cached;
390
392
  try {
391
393
  mtimeMs = statSyncImpl(path).mtimeMs;
392
- const cached = cache.get(path);
393
- if (cached && cached.mtimeMs === mtimeMs) return cached.parsed;
394
+ cached = cache.get(path);
394
395
  } catch {
395
396
  /* fall through to load path */
396
397
  }
398
+ if (cached && cached.mtimeMs === mtimeMs) {
399
+ validateLoadedConfig?.(cached.raw ?? cached.parsed);
400
+ return cached.parsed;
401
+ }
397
402
 
398
403
  const isTs = path.endsWith(".ts");
399
404
  let raw;
@@ -404,6 +409,7 @@ export async function loadConfig(options = {}) {
404
409
  raw = await importJsConfigImpl(path, mtimeMs);
405
410
  }
406
411
  } catch (caught) {
412
+ if (["CONFIG_EXPERIMENTAL_NOT_LITERAL", "CONFIG_LOCAL_RAG_NOT_LITERAL", "CONFIG_LOCAL_FEATURES_NOT_LITERAL"].includes(caught?.code)) throw caught;
407
413
  const label = isTs ? "Could not parse gencow.config.ts" : "Could not load gencow.config.js";
408
414
  const message = `${label}: ${caught.message}`;
409
415
  if (throwOnInvalid) {
@@ -413,7 +419,9 @@ export async function loadConfig(options = {}) {
413
419
  warnImpl(`${message} — using defaults`);
414
420
  return markConfigSource(getDefaultConfig(), { schemaDeclared: false });
415
421
  }
416
-
422
+ validateLoadedConfig?.(raw ?? {});
423
+ // Unsupported feature declarations must not become defaults.
424
+ validateProjectFeatures(raw ?? {});
417
425
  let parsed;
418
426
  try {
419
427
  const trimPath = (value) => (typeof value === "string" && value.trim().length > 0 ? value.trim() : null);
@@ -445,7 +453,7 @@ export async function loadConfig(options = {}) {
445
453
  }
446
454
 
447
455
  markConfigSource(parsed, { schemaDeclared: Object.hasOwn(raw ?? {}, "schema") });
448
- cache.set(path, { mtimeMs, parsed });
456
+ cache.set(path, { mtimeMs, parsed, raw });
449
457
  return parsed;
450
458
  }
451
459
 
@@ -633,6 +641,7 @@ export function findServerRoot(options = {}) {
633
641
  errorImpl = error,
634
642
  existsSyncImpl = existsSync,
635
643
  exitImpl = (code) => process.exit(code),
644
+ optional = false,
636
645
  resolvePathImpl = resolve,
637
646
  } = options;
638
647
 
@@ -654,6 +663,7 @@ export function findServerRoot(options = {}) {
654
663
  const siblingServer = resolvePathImpl(dirnameValue, "../../server");
655
664
  if (existsSyncImpl(siblingServer)) return siblingServer;
656
665
 
666
+ if (optional) return null;
657
667
  errorImpl("Server runtime not found. Run 'pnpm install'.");
658
668
  exitImpl(1);
659
669
  return null;
@@ -661,7 +671,7 @@ export function findServerRoot(options = {}) {
661
671
 
662
672
  export function isMonorepo(options = {}) {
663
673
  const { existsSyncImpl = existsSync, resolvePathImpl = resolve } = options;
664
- const serverRoot = findServerRoot(options);
674
+ const serverRoot = findServerRoot({ ...options, optional: true });
665
675
  return !!serverRoot && existsSyncImpl(resolvePathImpl(serverRoot, "src/index.ts"));
666
676
  }
667
677
 
@@ -695,12 +705,14 @@ export function buildEnv(config, options = {}) {
695
705
  appEnv = {};
696
706
  }
697
707
 
708
+ options.onAppEnvironmentKeys?.(Object.freeze(Object.keys(appEnv)));
709
+
698
710
  const cwdNodeModules = resolvePathImpl(cwd, "node_modules");
699
711
  const cliNodeModules = resolvePathImpl(dirnameValue, "..", "node_modules");
700
- const serverRoot = findServerRootImpl({ ...options, cwd, dirnameValue });
701
- const serverNodeModules = resolvePathImpl(serverRoot, "node_modules");
702
- const monoRoot = resolvePathImpl(serverRoot, "../..");
703
- const monoNodeModules = resolvePathImpl(monoRoot, "node_modules");
712
+ const serverRoot = options.runtimeOnly ? undefined : findServerRootImpl({ ...options, cwd, dirnameValue, optional: true });
713
+ const serverNodeModules = serverRoot ? resolvePathImpl(serverRoot, "node_modules") : undefined;
714
+ const monoRoot = serverRoot ? resolvePathImpl(serverRoot, "../..") : undefined;
715
+ const monoNodeModules = monoRoot ? resolvePathImpl(monoRoot, "node_modules") : undefined;
704
716
  const existingNodePath = processEnv.NODE_PATH || "";
705
717
  const nodePath = [cwdNodeModules, cliNodeModules, serverNodeModules, monoNodeModules, existingNodePath]
706
718
  .filter(Boolean)
@@ -719,9 +731,9 @@ export function buildEnv(config, options = {}) {
719
731
  NODE_PATH: nodePath,
720
732
  PORT: String(processEnv.PORT || config.port),
721
733
  GENCOW_FUNCTIONS: resolvePathImpl(cwd, config.rootDir),
722
- GENCOW_APP_NAME: processEnv.GENCOW_APP_NAME || config.name || config.deploy?.app || "",
734
+ GENCOW_APP_NAME: processEnv.GENCOW_APP_NAME || config.name || config.deploy?.app || (options.runtimeOnly ? undefined : ""),
723
735
  GENCOW_DB_URL: resolvePathImpl(cwd, config.db.url),
724
- GENCOW_STORAGE: resolvePathImpl(cwd, config.storage),
736
+ GENCOW_STORAGE: options.localStorage?.adapter === "azure-blob" ? undefined : resolvePathImpl(cwd, options.localStorage?.path ?? config.storage),
725
737
  GENCOW_MIGRATIONS: resolvePathImpl(cwd, config.rootDir, "migrations"),
726
738
  GENCOW_SERVER_CODEGEN_DIR: resolveCodegenServerPublishDir(cwd, config),
727
739
  GENCOW_SCHEMA_PATHS: drizzleSchemaPaths.join(GENCOW_SCHEMA_PATHS_SEP),
@@ -11,6 +11,7 @@ import {
11
11
  resolveProjectSelection,
12
12
  selectCodegenClient,
13
13
  } from "./project-context.mjs";
14
+ import { createStandaloneCodegenOptions } from "./standalone-codegen-adapter.mjs";
14
15
  import { writeCodegenProvenance } from "./deployment-artifact-provenance.mjs";
15
16
 
16
17
  export { formatAuthSchemaConflictMessage } from "./auth-schema-provenance-guard.mjs";
@@ -201,8 +202,14 @@ export async function runCodegenWithReporting({
201
202
  successImpl,
202
203
  cliVersion,
203
204
  sourceRevision,
205
+ includeStandalone = true,
206
+ createStandaloneOptionsImpl = createStandaloneCodegenOptions,
204
207
  }) {
205
208
  const bundled = await (loadCodegenBundleImpl ?? loadCodegenBundleDefault)();
209
+ const experimental = includeStandalone ? config.experimental : undefined;
210
+ const standalone = experimental?.output === "standalone"
211
+ ? await createStandaloneOptionsImpl({ config, cwd, bundled })
212
+ : undefined;
206
213
 
207
214
  const codegenResolved = resolveCodegenConfig(config);
208
215
  const effectiveServerPublishDir = serverPublishDir ?? resolveCodegenServerPublishDir(cwd, config);
@@ -216,6 +223,8 @@ export async function runCodegenWithReporting({
216
223
  serverPublishDir,
217
224
  ...(serverImportDir ? { serverImportDir } : {}),
218
225
  cloudFeatures: config.cloudFeatures,
226
+ ...(experimental !== undefined ? { experimental } : {}),
227
+ ...(standalone ? { standalone } : {}),
219
228
  importExtension: codegenResolved.importExtension,
220
229
  authSchema: codegenResolved.authSchema
221
230
  ? { emitRelations: codegenResolved.authSchemaEmitRelations }
@@ -233,6 +242,13 @@ export async function runCodegenWithReporting({
233
242
  successImpl,
234
243
  });
235
244
  logCodegenDiagnostics(logImpl, result.diagnostics, diagnosticsColors);
245
+ for (const notice of result.standalone?.notices ?? []) logImpl(`${notice.code}: ${notice.message}`);
246
+ if (result.standalone?.emitted) {
247
+ for (const artifact of result.standalone.artifacts) successImpl(`Generated .gencow/generated/${artifact.path}`);
248
+ }
249
+ if (!result.ok && result.standalone) {
250
+ logImpl(`Standalone dependency files: ${result.standalone.dependencyEffect}. Other generated files may have changed; inspect them before retrying.`);
251
+ }
236
252
  assertCodegenSucceeded(result);
237
253
  if (cliVersion && sourceRevision) {
238
254
  writeCodegenProvenance({
@@ -43,6 +43,8 @@ export function classifyGuardrailPath(relPath, config) {
43
43
  export function shouldIgnoreGuardrailPath(relPath, config) {
44
44
  if (!relPath) return true;
45
45
  if (config.ignoredFiles.includes(relPath)) return true;
46
+ const normalizedPath = relPath.replace(/\\/g, "/");
47
+ if ((config.ignoredGeneratedDirs ?? []).some((dir) => normalizedPath === dir || normalizedPath.startsWith(`${dir}/`))) return true;
46
48
 
47
49
  const parts = getPathSegments(relPath);
48
50
  if (parts.length === 0) return true;
@@ -0,0 +1,65 @@
1
+ import { accessSync, constants, readFileSync, readdirSync, realpathSync, statSync } from "node:fs";
2
+ import { isAbsolute, relative, resolve } from "node:path";
3
+
4
+ function containedFile(root, path) {
5
+ const physical = realpathSync(path);
6
+ const child = relative(root, physical);
7
+ if (child === ".." || child.startsWith("../") || child.startsWith("..\\") || isAbsolute(child)) {
8
+ throw Error("Dashboard entry asset escapes its artifact root.");
9
+ }
10
+ if (!statSync(physical).isFile()) throw Error("Dashboard entry asset is not a file.");
11
+ accessSync(physical, constants.R_OK);
12
+ return physical;
13
+ }
14
+
15
+ /** Validates the actual Vite entry closure; no workspace or remote resource fallback. */
16
+ export function validateDashboardArtifact(directory, { onAsset = () => {} } = {}) {
17
+ const root = realpathSync(directory);
18
+ const index = containedFile(root, resolve(root, "index.html"));
19
+ const html = readFileSync(index, "utf8");
20
+ onAsset(index);
21
+ let scriptCount = 0;
22
+ for (const tag of html.matchAll(/<(script|link)\b[^>]*>/giu)) {
23
+ const reference = tag[0].match(/\b(?:src|href)\s*=\s*["']([^"']+)["']/iu)?.[1];
24
+ if (!reference) continue;
25
+ if (tag[1].toLowerCase() === "script") scriptCount++;
26
+ const local = reference.startsWith("/_dashboard/") ? reference.slice("/_dashboard/".length) : reference;
27
+ const path = decodeURIComponent(local.split(/[?#]/u)[0]);
28
+ if (!path || /[\\\u0000:]/u.test(path) || path.startsWith("/") || path.split("/").includes("..")) {
29
+ throw Error("Dashboard entry requires a contained local asset.");
30
+ }
31
+ onAsset(containedFile(root, resolve(root, path)));
32
+ }
33
+ if (scriptCount === 0) throw Error("Dashboard entry has no readable application script.");
34
+ return root;
35
+ }
36
+
37
+ /** Release checks compare the complete freshly built tree, including lazy assets. */
38
+ export function validateDashboardReleaseArtifact(source, destination, { onAsset = () => {} } = {}) {
39
+ const sourceRoot = validateDashboardArtifact(source);
40
+ const destinationRoot = validateDashboardArtifact(destination);
41
+ const entries = (root) => {
42
+ const result = new Map();
43
+ const visit = (dir, prefix = "") => {
44
+ for (const entry of readdirSync(dir, { withFileTypes: true })) {
45
+ const name = prefix ? `${prefix}/${entry.name}` : entry.name;
46
+ const path = resolve(dir, entry.name);
47
+ if (entry.isSymbolicLink()) throw Error("Dashboard release artifacts cannot contain symbolic links.");
48
+ if (entry.isDirectory()) visit(path, name);
49
+ else if (entry.isFile()) result.set(name, path);
50
+ else throw Error("Dashboard release artifact contains an unsupported entry.");
51
+ }
52
+ };
53
+ visit(root);
54
+ return result;
55
+ };
56
+ const built = entries(sourceRoot),
57
+ packaged = entries(destinationRoot);
58
+ if (built.size !== packaged.size) throw Error("Packaged dashboard does not match the fresh build.");
59
+ for (const [name, path] of built) {
60
+ const target = packaged.get(name);
61
+ if (!target || !readFileSync(path).equals(readFileSync(target)))
62
+ throw Error("Packaged dashboard does not match the fresh build.");
63
+ onAsset(target);
64
+ }
65
+ }
@@ -1,5 +1,25 @@
1
1
  import { cpSync, existsSync, rmSync, statSync } from "node:fs";
2
2
  import { resolve } from "node:path";
3
+ import { randomUUID } from "node:crypto";
4
+ import { validateDashboardArtifact, validateDashboardReleaseArtifact } from "./dashboard-artifact.mjs";
5
+
6
+ /** Complete CLI builds must include a valid dashboard, never a stale fallback. */
7
+ export function copyRequiredDashboardAssets(source, destination, options) {
8
+ try {
9
+ validateDashboardArtifact(source);
10
+ copyOptionalDashboardAssets(source, destination, options);
11
+ validateDashboardReleaseArtifact(source, destination);
12
+ } catch {
13
+ throw new Error([
14
+ "Code: CLI_DASHBOARD_ASSETS_INVALID",
15
+ "Stage: build; Capability: dashboard",
16
+ "Application data/current serving state changed: no",
17
+ "Retryable: no; Retry precondition: Correct the dashboard build so it emits a complete local artifact.",
18
+ "Next action: From the repository root, run pnpm --dir packages/cli run build:with-deps and resolve any dashboard build errors.",
19
+ `Correlation ID: ${randomUUID()}`,
20
+ ].join("\n"));
21
+ }
22
+ }
3
23
 
4
24
  export function copyOptionalDashboardAssets(
5
25
  source,