{"record":{"id":"620178eb66e7074c","repo":"JuliusBrussee/caveman","slug":"caveman-build-config-must-export-definebuild","errorCode":null,"errorMessage":"caveman build: config must export defineBuild()","messagePattern":"caveman build: config must export defineBuild\\(\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/agent/src/cli.ts","lineNumber":676,"sourceCode":"  loaded: Awaited<ReturnType<typeof loadDevModule>>,\n): Promise<boolean> {\n  const lockPath = \".caveman/agent.lock.json\";\n  try {\n    await readFile(resolve(root, lockPath));\n  } catch (error) {\n    if ((error as NodeJS.ErrnoException).code === \"ENOENT\") return false;\n    throw error;\n  }\n  const configPath = \"caveman.config.ts\";\n  await loaded.includeFiles([lockPath]);\n  await loaded.includeSourceGraph([configPath]);\n  const imported = await importFresh(resolve(loaded.rootDir, configPath)) as {\n    default?: BuildConfig;\n    config?: BuildConfig;\n  };\n  const config = imported.default ?? imported.config;\n  if (!config || typeof config.evals !== \"string\") {\n    throw new Error(\"caveman build: config must export defineBuild()\");\n  }\n  const evalFiles: string[] = [];\n  for await (const path of glob(config.evals, { cwd: root })) {\n    evalFiles.push(resolve(root, path));\n  }\n  await loaded.includeSourceGraph(evalFiles);\n  const sourceFiles: string[] = [];\n  for (const pattern of SOURCE_PATTERNS) {\n    for await (const path of glob(pattern, { cwd: root })) sourceFiles.push(resolve(root, path));\n  }\n  await loaded.includeFiles(sourceFiles);\n  await loaded.includeOptionalFiles(PACKAGE_STATE_FILES);\n  return true;\n}\n\nfunction firstUsefulError(error: unknown): string {\n  const stack = error instanceof Error ? error.stack ?? error.message : String(error);\n  return stack.split(\"\\n\").slice(0, 4).join(\"\\n\");","sourceCodeStart":658,"sourceCodeEnd":694,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/agent/src/cli.ts#L658-L694","documentation":"stageDevLockInputs imports the caveman config file freshly (bypassing the module cache) and expects it to export a BuildConfig either as the default export or as a named `config` export. The check requires a config object whose `evals` field is a string (a glob). If the module exports neither default nor `config`, or the exported value lacks a string `evals`, this error is thrown.","triggerScenarios":"caveman.config.ts uses a different export style (e.g. `export const build = defineBuild(...)`), omits `defineBuild()` entirely, exports only primitives, or sets `evals` to undefined/non-string; also a config file that throws or exports a promise-shaped value.","commonSituations":"Copy-pasting a config snippet with `export const cfg = ...` instead of `export default defineBuild({...})`; hand-written config without the defineBuild helper; a refactor renaming the export.","solutions":["Export the result of defineBuild() as the default export: `export default defineBuild({...})`.","Alternatively export it as `export const config = defineBuild({...})`.","Ensure the `evals` field is a string glob (e.g. \"evals/**/*.eval.ts\").","Rebuild/restart so the fresh import picks up the corrected file."],"exampleFix":"// before\nexport const build = { lock: \"strict\", sandbox: \"required\", evals: \"evals/*.ts\" };\n// after\nimport { defineBuild } from \"@caveman/agent\";\nexport default defineBuild({ lock: \"strict\", sandbox: \"required\", evals: \"evals/*.eval.ts\" });","handlingStrategy":"validation","validationCode":"const cfg = await import(\"./caveman.config.ts\");\nconst c = cfg.default ?? cfg.config;\nif (!c || typeof c.evals !== \"string\") throw new Error(\"config must default-export defineBuild() with a string evals glob\");","typeGuard":"function isBuildConfig(v: unknown): v is BuildConfig & { evals: string } {\n  return typeof v === \"object\" && v !== null && \"evals\" in v && typeof (v as { evals: unknown }).evals === \"string\";\n}","tryCatchPattern":"try {\n  await stageDevLockInputs();\n} catch (err) {\n  if (String(err?.message).includes(\"config must export defineBuild()\")) {\n    console.error(\"Fix caveman.config.ts: export default defineBuild({ ... evals: 'glob' })\");\n  }\n  throw err;\n}","preventionTips":["Always author configs as `export default defineBuild({...})`.","Keep `evals` as a string glob; never undefined or an array.","Run a build in CI on PRs to catch config regressions early.","Type the config with the exported BuildConfig type for editor-time checking."],"tags":["config","validation","build"],"backgroundTag":"missing-required-config-field","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}