@bakers-build/core 0.7.1-next.7 → 0.8.1-next.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 (35) hide show
  1. package/dist/src/cli/bakers-dir.d.ts +8 -8
  2. package/dist/src/cli/bakers-dir.js +30 -33
  3. package/dist/src/cli/config-inventory.d.ts +2 -0
  4. package/dist/src/cli/config-inventory.js +45 -72
  5. package/dist/src/cli/config-report.d.ts +2 -2
  6. package/dist/src/cli/config-source.js +1 -1
  7. package/dist/src/cli/config-validate.d.ts +49 -0
  8. package/dist/src/cli/config-validate.js +400 -0
  9. package/dist/src/cli/import-config.d.ts +2 -2
  10. package/dist/src/cli/import-config.js +5 -5
  11. package/dist/src/cli/load-bakers-config.d.ts +2 -2
  12. package/dist/src/cli/load-bakers-config.js +20 -49
  13. package/dist/src/cli/machine-context.d.ts +8 -12
  14. package/dist/src/cli/machine-context.js +12 -18
  15. package/dist/src/cli/version-check.d.ts +1 -1
  16. package/dist/src/cli/version-check.js +1 -1
  17. package/dist/src/config-types.generated.d.ts +173 -0
  18. package/dist/src/config-types.generated.js +3 -0
  19. package/dist/src/core/logger.d.ts +3 -3
  20. package/dist/src/core/logger.js +5 -5
  21. package/dist/src/core/proc.d.ts +1 -1
  22. package/dist/src/core/proc.js +8 -5
  23. package/dist/src/index.d.ts +3 -1
  24. package/dist/src/index.js +2 -3
  25. package/dist/src/plugins/discover-addons.d.ts +2 -2
  26. package/dist/src/plugins/discover-addons.js +9 -9
  27. package/dist/src/plugins/preset.d.ts +9 -20
  28. package/dist/src/plugins/preset.js +6 -6
  29. package/dist/src/plugins/scoped-addons.d.ts +5 -14
  30. package/dist/src/plugins/scoped-addons.js +11 -36
  31. package/package.json +5 -3
  32. package/schema/connection.schema.json +57 -0
  33. package/schema/harness-options.schema.json +46 -0
  34. package/schema/machine.schema.json +77 -0
  35. package/schema/project.schema.json +262 -0
@@ -16,7 +16,7 @@ export declare function stemForConfigFile(fileName: string): string | undefined;
16
16
  * so a consumer that must recognise the home dir (e.g. to exclude it from a
17
17
  * project walk-up, BB-219 AC-9) asks for it rather than joining it itself.
18
18
  *
19
- * This is the ONE place that decides where `.bakers` lives. `BB_HOME` names
19
+ * This is the ONE place that decides where `.bakers` lives. `BAKERS_HOME` names
20
20
  * that directory itself — not a home containing one — so an isolated test, a
21
21
  * second identity on one machine, or a container can relocate it without
22
22
  * redirecting HOME. A relative value is resolved against the cwd, because the
@@ -33,14 +33,14 @@ export declare function homeBbDir(home?: string): string;
33
33
  */
34
34
  export declare function findBbDir(cwd: string): string | undefined;
35
35
  /**
36
- * Resolve the ENGINE (`conductor.config.js`) config path from `cwd`.
36
+ * Resolve the project config (`project.config.js`) path from `cwd`.
37
37
  *
38
- * 1. An explicit `--config` / `$BB_CONDUCTOR_CONFIG` wins verbatim (no walk).
38
+ * 1. An explicit `--config` / `$BAKERS_CONDUCTOR_CONFIG` wins verbatim (no walk).
39
39
  * 2. Otherwise walk root-ward to the nearest `.bakers/` dir holding a conductor
40
40
  * config — so any subdirectory of a project/worktree resolves the same dir.
41
- * - A `--conductor <name>` / `$BB_CONDUCTOR` selector resolves the stem's
42
- * file (`conductor` → `conductor.config.js`, else `<name>.conductor.config.js`).
43
- * - No selector: `conductor.config.js` present → the default; else exactly
41
+ * - A `--conductor <name>` / `$BAKERS_CONDUCTOR` selector resolves the stem's
42
+ * file (`conductor` → `project.config.js`, else `project.<name>.config.js`).
43
+ * - No selector: `project.config.js` present → the default; else exactly
44
44
  * one config → use it (back-compat); else → error naming the stems.
45
45
  * 3. No `.bakers/` config anywhere up the tree → an `ENOENT` error naming
46
46
  * `bakers config init --scope project`.
@@ -70,8 +70,8 @@ export declare function findBbConfig(cwd: string): {
70
70
  } | undefined;
71
71
  /**
72
72
  * Walk root-ward for the nearest `.bakers/` dir that marks a **project** — one
73
- * holding any bakers config at all, a `bakers.config.js` or at least one conductor
74
- * config. Returns that `.bakers/` dir, or `undefined` up to the filesystem root.
73
+ * holding any bakers config at all, a `connection.config.js` or at least one
74
+ * project config. Returns that `.bakers/` dir, or `undefined` up to the filesystem root.
75
75
  *
76
76
  * Deliberately a different question from `findBbConfig` (BB-219 AC-9):
77
77
  * "which project am I standing in" is not "where does my connection come from".
@@ -3,18 +3,18 @@ import { homedir } from 'node:os';
3
3
  import { dirname, join, resolve } from 'node:path';
4
4
  /** A repo's config files live in this dir, one conductor config per conductor. */
5
5
  const BB_DIR = '.bakers';
6
- /** The default conductor's file name; its stem is `conductor`. */
7
- const DEFAULT_CONFIG = 'conductor.config.js';
8
- /** Variant files are `<stem>.conductor.config.js`. */
9
- const VARIANT_SUFFIX = '.conductor.config.js';
10
- /** The connection config file name (project + home). */
11
- const BB_CONFIG = 'bakers.config.js';
6
+ /** The project file; its conductor variant is `conductor`, the conductor id's default. */
7
+ const DEFAULT_CONFIG = 'project.config.js';
8
+ /** Variant files are `project.<variant>.config.js`. */
9
+ const VARIANT = /^project\.(.+)\.config\.js$/;
10
+ /** A project's own connection file. */
11
+ const PROJECT_CONNECTION = 'connection.config.js';
12
+ /** The home default connection, beside the named ones. */
13
+ const DEFAULT_CONNECTION = join('connections', 'default.js');
12
14
  /**
13
- * List the conductor-config stems in a `.bakers/` dir. A file is a conductor
14
- * config iff it is exactly `conductor.config.js` (stem `conductor`, the
15
- * default) or ends with `.conductor.config.js` (stem = the leading part).
16
- * Every other file (`vite.config.js`, the near-miss `myconductor.config.js`,
17
- * and `bakers.config.js` itself) is ignored.
15
+ * List the conductor variants in a `.bakers/` dir: `project.config.js` is the
16
+ * default variant `conductor`, `project.<name>.config.js` is variant `<name>`.
17
+ * Every other file (`vite.config.js`, `connection.config.js`) is ignored.
18
18
  */
19
19
  function configStems(bakersDir) {
20
20
  return readdirSync(bakersDir)
@@ -37,22 +37,19 @@ function configStems(bakersDir) {
37
37
  export function stemForConfigFile(fileName) {
38
38
  if (fileName === DEFAULT_CONFIG)
39
39
  return 'conductor';
40
- if (fileName.endsWith(VARIANT_SUFFIX)) {
41
- const stem = fileName.slice(0, -VARIANT_SUFFIX.length);
42
- return stem === '' ? undefined : stem;
43
- }
44
- return undefined;
40
+ const variant = VARIANT.exec(fileName)?.[1];
41
+ return variant === 'conductor' ? undefined : variant;
45
42
  }
46
43
  /** Map a conductor stem back to its file name. */
47
44
  function fileForStem(stem) {
48
- return stem === 'conductor' ? DEFAULT_CONFIG : `${stem}${VARIANT_SUFFIX}`;
45
+ return stem === 'conductor' ? DEFAULT_CONFIG : `project.${stem}.config.js`;
49
46
  }
50
47
  /**
51
48
  * The user-global `.bakers` dir. Core owns where the split-config files live,
52
49
  * so a consumer that must recognise the home dir (e.g. to exclude it from a
53
50
  * project walk-up, BB-219 AC-9) asks for it rather than joining it itself.
54
51
  *
55
- * This is the ONE place that decides where `.bakers` lives. `BB_HOME` names
52
+ * This is the ONE place that decides where `.bakers` lives. `BAKERS_HOME` names
56
53
  * that directory itself — not a home containing one — so an isolated test, a
57
54
  * second identity on one machine, or a container can relocate it without
58
55
  * redirecting HOME. A relative value is resolved against the cwd, because the
@@ -64,7 +61,7 @@ function fileForStem(stem) {
64
61
  export function homeBbDir(home) {
65
62
  if (home !== undefined)
66
63
  return join(home, BB_DIR);
67
- const override = process.env.BB_HOME;
64
+ const override = process.env.BAKERS_HOME;
68
65
  return override ? resolve(override) : join(homedir(), BB_DIR);
69
66
  }
70
67
  /**
@@ -87,20 +84,20 @@ export function findBbDir(cwd) {
87
84
  }
88
85
  }
89
86
  /**
90
- * Resolve the ENGINE (`conductor.config.js`) config path from `cwd`.
87
+ * Resolve the project config (`project.config.js`) path from `cwd`.
91
88
  *
92
- * 1. An explicit `--config` / `$BB_CONDUCTOR_CONFIG` wins verbatim (no walk).
89
+ * 1. An explicit `--config` / `$BAKERS_CONDUCTOR_CONFIG` wins verbatim (no walk).
93
90
  * 2. Otherwise walk root-ward to the nearest `.bakers/` dir holding a conductor
94
91
  * config — so any subdirectory of a project/worktree resolves the same dir.
95
- * - A `--conductor <name>` / `$BB_CONDUCTOR` selector resolves the stem's
96
- * file (`conductor` → `conductor.config.js`, else `<name>.conductor.config.js`).
97
- * - No selector: `conductor.config.js` present → the default; else exactly
92
+ * - A `--conductor <name>` / `$BAKERS_CONDUCTOR` selector resolves the stem's
93
+ * file (`conductor` → `project.config.js`, else `project.<name>.config.js`).
94
+ * - No selector: `project.config.js` present → the default; else exactly
98
95
  * one config → use it (back-compat); else → error naming the stems.
99
96
  * 3. No `.bakers/` config anywhere up the tree → an `ENOENT` error naming
100
97
  * `bakers config init --scope project`.
101
98
  */
102
99
  export function resolveConfigPath(override, cwd = process.cwd(), conductorName) {
103
- const explicit = override ?? process.env.BB_CONDUCTOR_CONFIG;
100
+ const explicit = override ?? process.env.BAKERS_CONDUCTOR_CONFIG;
104
101
  if (explicit) {
105
102
  return explicit;
106
103
  }
@@ -115,11 +112,11 @@ export function resolveConfigPath(override, cwd = process.cwd(), conductorName)
115
112
  // latter writes machine and connection and deliberately leaves the project
116
113
  // layer alone, so recommending it sends the reader back to the command
117
114
  // they have already run.
118
- throw Object.assign(new Error(`no .bakers/conductor.config.js found from ${cwd} upward; ` +
115
+ throw Object.assign(new Error(`no .bakers/project.config.js found from ${cwd} upward; ` +
119
116
  'run `bakers config init --scope project` in a project checkout'), { code: 'ENOENT' });
120
117
  }
121
118
  const stems = configStems(bakersDir);
122
- const name = conductorName ?? process.env.BB_CONDUCTOR;
119
+ const name = conductorName ?? process.env.BAKERS_CONDUCTOR;
123
120
  if (name !== undefined && name !== '') {
124
121
  const candidate = join(bakersDir, fileForStem(name));
125
122
  if (!existsSync(candidate)) {
@@ -134,7 +131,7 @@ export function resolveConfigPath(override, cwd = process.cwd(), conductorName)
134
131
  return join(bakersDir, fileForStem(stems[0]));
135
132
  }
136
133
  throw new Error(`${stems.length} conductors in ${bakersDir} (${stems.join(', ')}); ` +
137
- 'select one with --conductor <name> or $BB_CONDUCTOR');
134
+ 'select one with --conductor <name> or $BAKERS_CONDUCTOR');
138
135
  }
139
136
  /** Walk upward for current project connection files only. Legacy engine files
140
137
  * are migration input, never runtime connection sources. */
@@ -143,7 +140,7 @@ export function findBbConfig(cwd) {
143
140
  for (;;) {
144
141
  const bakersDir = join(dir, BB_DIR);
145
142
  if (existsSync(bakersDir)) {
146
- const bakersCfg = join(bakersDir, BB_CONFIG);
143
+ const bakersCfg = join(bakersDir, PROJECT_CONNECTION);
147
144
  if (existsSync(bakersCfg))
148
145
  return { path: bakersCfg, legacy: false };
149
146
  }
@@ -155,8 +152,8 @@ export function findBbConfig(cwd) {
155
152
  }
156
153
  /**
157
154
  * Walk root-ward for the nearest `.bakers/` dir that marks a **project** — one
158
- * holding any bakers config at all, a `bakers.config.js` or at least one conductor
159
- * config. Returns that `.bakers/` dir, or `undefined` up to the filesystem root.
155
+ * holding any bakers config at all, a `connection.config.js` or at least one
156
+ * project config. Returns that `.bakers/` dir, or `undefined` up to the filesystem root.
160
157
  *
161
158
  * Deliberately a different question from `findBbConfig` (BB-219 AC-9):
162
159
  * "which project am I standing in" is not "where does my connection come from".
@@ -175,7 +172,7 @@ export function findProjectBbDir(cwd) {
175
172
  for (;;) {
176
173
  const bakersDir = join(dir, BB_DIR);
177
174
  if (existsSync(bakersDir) &&
178
- (existsSync(join(bakersDir, BB_CONFIG)) ||
175
+ (existsSync(join(bakersDir, PROJECT_CONNECTION)) ||
179
176
  configStems(bakersDir).length > 0)) {
180
177
  return bakersDir;
181
178
  }
@@ -204,7 +201,7 @@ export function findConfigProjectBbDir(cwd, home) {
204
201
  /** Resolve explicit → project → global connection. An absent global still
205
202
  * names its canonical owner so callers can provide a precise init remedy. */
206
203
  export function resolveBbConfigPath(opts = {}) {
207
- const homeCfg = join(homeBbDir(opts.home), BB_CONFIG);
204
+ const homeCfg = join(homeBbDir(opts.home), DEFAULT_CONNECTION);
208
205
  const explicit = opts.explicit;
209
206
  if (explicit !== undefined && explicit.trim() !== '') {
210
207
  return {
@@ -20,6 +20,8 @@ export interface ConfigInventoryOptions {
20
20
  currentVersions?: Partial<Record<ConfigFileKind, number>>;
21
21
  /** Internal planner overlay: proposed modules are validated without filesystem writes. */
22
22
  sourceTexts?: ReadonlyMap<string, string | null>;
23
+ /** Where addon packages resolve from (the CLI install), after the config's dir and cwd. */
24
+ addonBases?: string[];
23
25
  }
24
26
  export interface ConfigInventory {
25
27
  report: ConfigReport;
@@ -1,10 +1,18 @@
1
1
  import { createHash } from 'node:crypto';
2
- import { existsSync, readdirSync, readFileSync } from 'node:fs';
2
+ import { readdirSync, readFileSync } from 'node:fs';
3
3
  import { dirname, join, resolve } from 'node:path';
4
+ import { pathToFileURL } from 'node:url';
4
5
  import { shellQuote } from '../core/shell.js';
5
6
  import { findConfigProjectBbDir, homeBbDir, stemForConfigFile, } from './bakers-dir.js';
6
7
  import { configRecheckCommand, finalizeConfigReport, } from './config-report.js';
7
8
  import { inspectConfigSource, } from './config-source.js';
9
+ import { checkConfigText } from './config-validate.js';
10
+ const SCHEMA_KIND = {
11
+ machine: 'machine',
12
+ connection: 'connection',
13
+ 'project-connection': 'connection',
14
+ project: 'project',
15
+ };
8
16
  const SCOPES = ['machine', 'connection', 'project', 'all'];
9
17
  const SECRET_KEY = /secret|token|password|credential|client_id|authorization/i;
10
18
  /** Public observed values never include expressions, objects or credentials. */
@@ -23,12 +31,12 @@ function observed(property, key) {
23
31
  /** Collect selected files and prerequisite sources without importing any module. */
24
32
  export function inventoryConfig(options = {}) {
25
33
  const operation = options.operation ?? 'check';
26
- // The `.bakers` root is core's decision (BB_HOME), not this function's; an
34
+ // The `.bakers` root is core's decision (BAKERS_HOME), not this function's; an
27
35
  // explicit options.home still pins it, which is what fixtures rely on.
28
36
  const bakersRoot = homeBbDir(options.home);
29
37
  const cwd = resolve(options.cwd ?? process.cwd());
30
38
  const machinePath = resolve(options.machinePath ?? join(bakersRoot, 'machine.config.js'));
31
- const connectionPath = resolve(options.connectionPath ?? join(bakersRoot, 'bakers.config.js'));
39
+ const connectionPath = resolve(options.connectionPath ?? join(bakersRoot, 'connections', 'default.js'));
32
40
  const discovered = findConfigProjectBbDir(options.path ? resolve(cwd, options.path) : cwd, options.home);
33
41
  const projectRoot = options.path
34
42
  ? resolve(cwd, options.path)
@@ -230,7 +238,7 @@ export function inventoryConfig(options = {}) {
230
238
  if (selected &&
231
239
  source.properties.get('executor') &&
232
240
  (kind === 'machine' ||
233
- (kind === 'conductor' && report.executor_source === undefined)))
241
+ (kind === 'project' && report.executor_source === undefined)))
234
242
  report.executor_source = path;
235
243
  const startFindings = report.findings.length;
236
244
  const field = source.properties.get('schema_version');
@@ -282,21 +290,10 @@ export function inventoryConfig(options = {}) {
282
290
  add('invalid_value', key, expected, `Repair ${key} in ${shellQuote(path)}; expected ${expected}`, 'schema', 'error', property);
283
291
  };
284
292
  const nonempty = (property) => typeof property.value === 'string' && property.value.trim() !== '';
285
- if (field)
286
- requireValue('schema_version', 'A positive integer schema version.', (property) => typeof property.value === 'number' &&
287
- Number.isInteger(property.value) &&
288
- property.value > 0);
289
293
  if (kind === 'machine') {
290
- // New machines get a UUID from bakers init; existing ones keep their id.
291
- requireValue('machine_id', 'A nonempty machine id.', nonempty);
292
- requireValue('label', 'A nonempty display label.', nonempty);
293
- const userId = source.properties.get('user_id');
294
- if (userId)
295
- add('retired_key', 'user_id', 'No user_id: the server takes the owner from sign-in.', 'Run bakers init to rewrite the file without it.', 'schema', 'error', userId);
296
294
  const tunnel = source.properties.get('tunnel');
297
295
  const tunnelExpected = 'A boolean tunnel sharing policy.';
298
296
  if (tunnel) {
299
- requireValue('tunnel', tunnelExpected, (property) => typeof property.value === 'boolean', false);
300
297
  setTunnelPolicy(tunnel.staticallyDetermined && typeof tunnel.value === 'boolean'
301
298
  ? tunnel.value
302
299
  : null);
@@ -336,29 +333,14 @@ export function inventoryConfig(options = {}) {
336
333
  add('misplaced_key', key, `Connection-owned ${key} belongs in ${connectionPath}.`, `Move ${key} from ${shellQuote(path)} into ${shellQuote(connectionPath)}.`, 'ownership', 'error', property, 'connection');
337
334
  }
338
335
  }
339
- if (kind === 'project-connection')
340
- add('superseded_file', null, 'Legacy project connection overrides remain supported but are superseded by named global connections.', `Create a named connection with bakers config init --scope connection --connection <id>, then select it in .bakers/connection.config.local.js.`, 'ownership', 'info');
341
- if (kind === 'connection') {
342
- requireValue('site', 'A site object.', (property) => property.nodeType === 'ObjectExpression');
343
- requireValue('site.base_url', 'An absolute HTTP or HTTPS URL.', (property) => {
344
- if (typeof property.value !== 'string')
345
- return false;
346
- try {
347
- return ['http:', 'https:'].includes(new URL(property.value).protocol);
348
- }
349
- catch {
350
- return false;
351
- }
352
- });
353
- requireValue('plugins', 'An array of plugin descriptors.', (property) => property.nodeType === 'ArrayExpression');
336
+ if (kind === 'connection' || kind === 'project-connection') {
337
+ // The schema checks the shape; an OAuth provider also needs credentials.
354
338
  const plugins = source.properties.get('plugins');
355
339
  if (plugins?.nodeType === 'ArrayExpression') {
356
340
  for (let index = 0; index < (plugins.arrayLength ?? 0); index++) {
357
341
  const entry = `plugins[${index}]`;
358
- requireValue(entry, 'A plugin object or computed plugin instance.', (property) => property.nodeType === 'ObjectExpression');
359
342
  const descriptor = source.properties.get(entry);
360
343
  if (descriptor?.nodeType === 'ObjectExpression') {
361
- requireValue(`${entry}.plugin`, 'A nonempty plugin module specifier.', nonempty);
362
344
  if (source.properties.get(`${entry}.plugin`)?.value ===
363
345
  '@dropsh/plugin-oauth2') {
364
346
  // A public client (device-code grant) declares no
@@ -371,59 +353,51 @@ export function inventoryConfig(options = {}) {
371
353
  ? ['client_id']
372
354
  : ['client_id', 'client_secret'])
373
355
  requireValue(`${entry}.with.${key}`, 'A nonempty OAuth credential.', nonempty);
374
- const secretKey = `${entry}.with.client_secret`;
375
- const secret = source.properties.get(secretKey);
376
- void secret;
377
356
  }
378
357
  }
379
358
  }
380
359
  }
381
360
  }
382
- if (kind === 'local') {
383
- for (const key of [
384
- 'base_url',
385
- 'workspace_id',
386
- 'oauth',
387
- 'oauth.client_id',
388
- 'oauth.client_secret',
389
- ]) {
390
- const property = source.properties.get(key);
391
- if (property)
392
- add('dead_key', key, `${key} is no longer read from conductor.config.local.js.`, `Remove ${key} from ${shellQuote(path)} after confirming the selected global connection contains the intended value.`, 'ownership', 'warning', property);
393
- }
394
- }
395
361
  if (kind !== 'machine') {
396
362
  const property = source.properties.get('tunnel');
397
363
  if (property)
398
364
  add('misplaced_key', 'tunnel', `Machine-owned tunnel belongs in ${machinePath}.`, `Move tunnel from ${shellQuote(path)} into ${shellQuote(machinePath)}.`, 'ownership', 'error', property, 'machine');
399
365
  }
366
+ // Field checks: the same schema the loader applies, on the literal values.
367
+ const reported = new Set(report.findings.slice(startFindings).map((finding) => finding.key));
368
+ for (const problem of checkConfigText(SCHEMA_KIND[kind], text, {
369
+ bases: [
370
+ pathToFileURL(`${dirname(path)}/`).href,
371
+ pathToFileURL(`${cwd}/`).href,
372
+ ...(options.addonBases ?? []),
373
+ import.meta.url,
374
+ ],
375
+ })) {
376
+ // Version markers are judged above against the command's current version.
377
+ if (problem.key === 'schema_version' || reported.has(problem.key))
378
+ continue;
379
+ const key = problem.key || null;
380
+ const at = key ? `${key} in ${shellQuote(path)}` : shellQuote(path);
381
+ add(problem.code, key, key ? `${key}: ${problem.message}` : problem.message, problem.code === 'not_checked' || problem.code === 'options_not_checked'
382
+ ? `Nothing to repair offline; the loader checks ${at} when the conductor starts.`
383
+ : `Repair ${at}: ${problem.message.replace(/\.$/, '')}.`, 'schema', problem.severity, key ? source.properties.get(key) : undefined);
384
+ if (problem.line !== undefined) {
385
+ const finding = report.findings.at(-1);
386
+ if (finding && finding.key === key)
387
+ Object.assign(finding, {
388
+ line: problem.line,
389
+ column: problem.column,
390
+ });
391
+ }
392
+ }
400
393
  const findings = report.findings.slice(startFindings);
401
394
  if (findings.some((finding) => finding.severity === 'error'))
402
395
  file.state = 'partial';
403
- else if (findings.some((finding) => finding.code === 'unknown_value'))
396
+ else if (findings.some((finding) => finding.code === 'unknown_value' || finding.code === 'not_checked'))
404
397
  file.state = 'computed';
405
398
  };
406
399
  inspectFile(machinePath, 'machine', 'machine', true);
407
400
  inspectFile(connectionPath, 'connection', 'connection', true);
408
- // Conductor configs live in the project only. Historical global connections
409
- // imported this retired sibling, so migrating one past it unseen would
410
- // silently switch server or account: refuse until it is gone.
411
- const retiredLocal = join(dirname(connectionPath), 'conductor.config.local.js');
412
- if (existsSync(retiredLocal))
413
- report.findings.push({
414
- code: 'superseded_file',
415
- severity: 'error',
416
- stage: 'inventory',
417
- path: retiredLocal,
418
- key: null,
419
- expected: 'No conductor config beside the global connection; conductor overrides live in the project .bakers/conductor.config.local.js.',
420
- observed: null,
421
- owner: 'connection',
422
- related: [],
423
- statically_determined: true,
424
- remediation: `Move any values from ${shellQuote(retiredLocal)} into the machine, connection or project local config, then delete it.`,
425
- recheck,
426
- });
427
401
  if (projectRoot) {
428
402
  const bakersDir = join(projectRoot, '.bakers');
429
403
  let names = [];
@@ -436,11 +410,10 @@ export function inventoryConfig(options = {}) {
436
410
  /* Missing/partial roots still inventory their required default file. */
437
411
  }
438
412
  if (names.length === 0)
439
- names = ['conductor.config.js'];
413
+ names = ['project.config.js'];
440
414
  for (const name of names)
441
- inspectFile(join(bakersDir, name), 'conductor', 'project', true);
442
- inspectFile(join(bakersDir, 'conductor.config.local.js'), 'local', 'project', false, 'supplementary');
443
- inspectFile(join(bakersDir, 'bakers.config.js'), 'project-connection', 'project', false);
415
+ inspectFile(join(bakersDir, name), 'project', 'project', true);
416
+ inspectFile(join(bakersDir, 'connection.config.js'), 'project-connection', 'project', false);
444
417
  }
445
418
  // Cross-file ownership diagnostics use the same inspected values as callers.
446
419
  // Equal duplicates still need relocation, but are not conflicts.
@@ -1,8 +1,8 @@
1
1
  export type ConfigScope = 'machine' | 'connection' | 'project' | 'all';
2
2
  export type ConfigLayer = Exclude<ConfigScope, 'all'>;
3
3
  export type ConfigOperation = 'init' | 'upgrade' | 'check';
4
- export type ConfigFileKind = 'machine' | 'connection' | 'project-connection' | 'conductor' | 'local';
5
- export type ConfigFindingCode = 'scope_required' | 'invalid_scope' | 'project_required' | 'missing_required_file' | 'missing_required_key' | 'unreadable_file' | 'syntax_error' | 'unsupported_source_shape' | 'unknown_value' | 'invalid_value' | 'version_marker_disagreement' | 'unsupported_schema_version' | 'misplaced_key' | 'conflicting_values' | 'out_of_scope_write_required' | 'changed_since_planning' | 'authentication_failure' | 'no_workspace' | 'cancelled_selection' | 'superseded_file' | 'dead_key' | 'retired_key' | 'addon_scope_not_allowed' | 'addon_scope_skipped' | 'addon_with_invalid' | 'write_failure';
4
+ export type ConfigFileKind = 'machine' | 'connection' | 'project-connection' | 'project';
5
+ export type ConfigFindingCode = 'scope_required' | 'invalid_scope' | 'project_required' | 'missing_required_file' | 'missing_required_key' | 'unreadable_file' | 'syntax_error' | 'unsupported_source_shape' | 'unknown_value' | 'not_checked' | 'options_not_checked' | 'unknown_key' | 'invalid_value' | 'version_marker_disagreement' | 'unsupported_schema_version' | 'misplaced_key' | 'conflicting_values' | 'out_of_scope_write_required' | 'changed_since_planning' | 'authentication_failure' | 'no_workspace' | 'cancelled_selection' | 'dead_key' | 'retired_key' | 'addon_scope_not_allowed' | 'addon_scope_skipped' | 'write_failure';
6
6
  export interface ConfigLocation {
7
7
  path: string;
8
8
  key: string | null;
@@ -4,7 +4,7 @@
4
4
  // introduced it) so both users share one source of truth for "which top-level
5
5
  // properties does this config source declare?":
6
6
  //
7
- // - `@bakers-build/core` — `findBbConfig` gates the LEGACY `conductor.config.js`
7
+ // - `@bakers-build/core` — `findBbConfig` gates the LEGACY `project.config.js`
8
8
  // connection read on CONTENT: a config declaring no `site` is not a
9
9
  // connection source (root cause 2). Core is layer 0 with zero `@bakers-build/*`
10
10
  // edges, so it cannot import the conductor's copy — hence the hoist.
@@ -0,0 +1,49 @@
1
+ import { Ajv2020 } from 'ajv/dist/2020.js';
2
+ /** The three configuration file kinds, one schema each. */
3
+ export type ConfigKind = 'connection' | 'machine' | 'project';
4
+ export interface SchemaProblem {
5
+ /** Key path such as `hooks.after_create` or `addons[0].use`; `''` is the whole file. */
6
+ key: string;
7
+ code: 'unknown_key' | 'invalid_value' | 'missing_required_key' | 'not_checked' | 'options_not_checked';
8
+ severity: 'error' | 'warning';
9
+ message: string;
10
+ line?: number;
11
+ column?: number;
12
+ }
13
+ /** A schema file shipped in `@bakers-build/core/schema/`. */
14
+ export declare function coreSchemaPath(name: string): string;
15
+ /** The shared ajv instance: core and harness schemas registered, `function` keyword added. */
16
+ export declare function configAjv(): Ajv2020;
17
+ interface ValidateOptions {
18
+ /** Key paths whose value is not statically known. */
19
+ computed?: ReadonlySet<string>;
20
+ /** Object key paths with a spread: their key set is not known. */
21
+ partial?: ReadonlySet<string>;
22
+ }
23
+ /** Validate one file's value against its schema. Problems sorted by key. */
24
+ export declare function validateConfig(kind: ConfigKind, value: unknown, opts?: ValidateOptions): SchemaProblem[];
25
+ /** Throw one error naming the file and every error-level problem; warn the rest. */
26
+ export declare function assertValidConfig(kind: ConfigKind, value: unknown, path: string, warn?: (message: string) => void): void;
27
+ /** The literal value of a config source, with computed and partial key paths. */
28
+ export interface StaticConfig {
29
+ value: Record<string, unknown>;
30
+ computed: Set<string>;
31
+ partial: Set<string>;
32
+ locations: Map<string, {
33
+ line: number;
34
+ column: number;
35
+ }>;
36
+ }
37
+ /** Read the default-export object literal without evaluating anything. */
38
+ export declare function staticConfig(text: string): StaticConfig | undefined;
39
+ /**
40
+ * Check each literal `with` of the `addons[]` entries (and, on a machine, the
41
+ * `agents.catalog[]` entries) against the addon's own options schema. Addon
42
+ * code never runs; an addon without a schema leaves its options not checked.
43
+ */
44
+ export declare function addonOptionProblems(kind: ConfigKind, parsed: Pick<StaticConfig, 'value' | 'computed'>, bases: string[]): SchemaProblem[];
45
+ /** `config check`'s offline field check of one file's source text. */
46
+ export declare function checkConfigText(kind: ConfigKind, text: string, opts?: {
47
+ bases?: string[];
48
+ }): SchemaProblem[];
49
+ export {};