@bakers-build/core 0.5.1-next.746 → 0.5.1-next.776

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.
@@ -1,6 +1,5 @@
1
1
  import { createHash } from 'node:crypto';
2
- import { readdirSync, readFileSync } from 'node:fs';
3
- import { homedir } from 'node:os';
2
+ import { existsSync, readdirSync, readFileSync } from 'node:fs';
4
3
  import { dirname, join, resolve } from 'node:path';
5
4
  import { shellQuote } from '../core/shell.js';
6
5
  import { findConfigProjectBbDir, homeBbDir, stemForConfigFile, } from './bakers-dir.js';
@@ -25,11 +24,8 @@ function observed(property, key) {
25
24
  /** Collect selected files and prerequisite sources without importing any module. */
26
25
  export function inventoryConfig(options = {}) {
27
26
  const operation = options.operation ?? 'check';
28
- const home = resolve(options.home ?? homedir());
29
27
  // The `.bakers` root is core's decision (BB_HOME), not this function's; an
30
- // explicit options.home still pins it, which is what fixtures rely on. `home`
31
- // above stays the operating-system home because the legacy machine input
32
- // below lives at ~/.config/conductor, outside `.bakers` entirely.
28
+ // explicit options.home still pins it, which is what fixtures rely on.
33
29
  const bakersRoot = homeBbDir(options.home);
34
30
  const cwd = resolve(options.cwd ?? process.cwd());
35
31
  const machinePath = resolve(options.machinePath ?? join(bakersRoot, 'machine.config.js'));
@@ -283,7 +279,7 @@ export function inventoryConfig(options = {}) {
283
279
  requireValue('schema_version', 'A positive integer schema version.', (property) => typeof property.value === 'number' &&
284
280
  Number.isInteger(property.value) &&
285
281
  property.value > 0);
286
- if (kind === 'machine' || kind === 'legacy-machine') {
282
+ if (kind === 'machine') {
287
283
  for (const key of ['machine_id', 'user_id'])
288
284
  requireValue(key, 'A nonempty identifier using letters, numbers, dots, underscores or hyphens.', (property) => typeof property.value === 'string' &&
289
285
  IDENTIFIER.test(property.value));
@@ -389,7 +385,7 @@ export function inventoryConfig(options = {}) {
389
385
  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);
390
386
  }
391
387
  }
392
- if (kind !== 'machine' && kind !== 'legacy-machine') {
388
+ if (kind !== 'machine') {
393
389
  for (const key of ['max_parallel', 'conductor.max_parallel', 'tunnel']) {
394
390
  const property = source.properties.get(key);
395
391
  if (property)
@@ -406,21 +402,25 @@ export function inventoryConfig(options = {}) {
406
402
  };
407
403
  inspectFile(machinePath, 'machine', 'machine', true);
408
404
  inspectFile(connectionPath, 'connection', 'connection', true);
409
- inspectFile(join(dirname(connectionPath), 'conductor.config.local.js'), 'home-local', 'connection', false, 'supplementary');
410
- const legacy = join(home, '.config/conductor/conductor.config.machine.js');
411
- // An explicit machine target does not authorize migration of another home's legacy input.
412
- if (!options.machinePath ||
413
- machinePath === join(bakersRoot, 'machine.config.js')) {
414
- // Keep an absent legacy file out of the report; it is never required.
415
- try {
416
- readFileSync(legacy);
417
- inspectFile(legacy, 'legacy-machine', 'machine', false, 'supplementary');
418
- }
419
- catch (error) {
420
- if (error.code !== 'ENOENT')
421
- inspectFile(legacy, 'legacy-machine', 'machine', false, 'supplementary');
422
- }
423
- }
405
+ // Conductor configs live in the project only. Historical global connections
406
+ // imported this retired sibling, so migrating one past it unseen would
407
+ // silently switch server or account: refuse until it is gone.
408
+ const retiredLocal = join(dirname(connectionPath), 'conductor.config.local.js');
409
+ if (existsSync(retiredLocal))
410
+ report.findings.push({
411
+ code: 'superseded_file',
412
+ severity: 'error',
413
+ stage: 'inventory',
414
+ path: retiredLocal,
415
+ key: null,
416
+ expected: 'No conductor config beside the global connection; conductor overrides live in the project .bakers/conductor.config.local.js.',
417
+ observed: null,
418
+ owner: 'connection',
419
+ related: [],
420
+ statically_determined: true,
421
+ remediation: `Move any values from ${shellQuote(retiredLocal)} into the machine, connection or project local config, then delete it.`,
422
+ recheck,
423
+ });
424
424
  if (projectRoot) {
425
425
  const bakersDir = join(projectRoot, '.bakers');
426
426
  let names = [];
@@ -14,7 +14,7 @@ export function withBakersClientHeader(http) {
14
14
  }
15
15
  /** Shared normal dropsh authentication, context and request-hook composition. */
16
16
  export async function createBbConnectionContext(connection, options = {}) {
17
- const [{ resolveAuth }, { createHttpClient, createJsonApiClient, PluginError },] = await Promise.all([import('dropsh'), import('dropsh/plugin')]);
17
+ const [{ resolveAuth }, { createHttpClient, createJsonApiClient, PluginError, AuthError },] = await Promise.all([import('dropsh'), import('dropsh/plugin')]);
18
18
  // BB-607: a write whose response is lost may already have applied, and
19
19
  // dropsh's client retries every request after a network failure; a
20
20
  // re-sent POST created the same entity up to four times. Reads keep the
@@ -33,6 +33,11 @@ export async function createBbConnectionContext(connection, options = {}) {
33
33
  now: Date.now,
34
34
  ...(options.stateDir ? { stateDir: options.stateDir } : {}),
35
35
  ...(options.profile ? { profile: options.profile } : {}),
36
+ }).catch((error) => {
37
+ if (error instanceof AuthError) {
38
+ error.message = error.message.replace("Run 'dropsh auth login", "Run 'bakers auth login");
39
+ }
40
+ throw error;
36
41
  }));
37
42
  const context = {
38
43
  http,
@@ -204,7 +209,7 @@ export async function verifyConfigConnections(report, options) {
204
209
  related: [],
205
210
  statically_determined: false,
206
211
  remediation: authFailure
207
- ? `Check credentials in ${shellQuote(file.path)}; run bakers dropsh --config ${shellQuote(file.path)} auth login, then ${recheck}.`
212
+ ? `Check credentials in ${shellQuote(file.path)}; run bakers auth login --config ${shellQuote(file.path)}, then ${recheck}.`
208
213
  : `Inspect ${shellQuote(file.path)}; run ${recheck}.`,
209
214
  recheck,
210
215
  });
@@ -1,7 +1,7 @@
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' | 'home-local' | 'legacy-machine' | 'connection' | 'project-connection' | 'conductor' | 'local';
4
+ export type ConfigFileKind = 'machine' | 'connection' | 'project-connection' | 'conductor' | 'local';
5
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' | 'future_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';
6
6
  export interface ConfigLocation {
7
7
  path: string;
@@ -40,8 +40,6 @@ export interface MachineContext {
40
40
  }
41
41
  /** Canonical machine-context path: `<BB_HOME or ~/.bakers>/machine.config.js`. */
42
42
  export declare function machineContextPath(): string;
43
- /** Legacy machine-context path (pre-BB-201), historical migration input only. */
44
- export declare function legacyMachineContextPath(): string;
45
43
  /** Resolve explicit or canonical current host context. */
46
44
  export declare function resolveMachineContextPath(path?: string): string;
47
45
  /** Import an existing context module's default export, or `{}` if absent/broken. */
@@ -1,5 +1,4 @@
1
1
  import { existsSync } from 'node:fs';
2
- import { homedir } from 'node:os';
3
2
  import { join } from 'node:path';
4
3
  import { pathToFileURL } from 'node:url';
5
4
  import { homeBbDir } from './bakers-dir.js';
@@ -7,10 +6,6 @@ import { homeBbDir } from './bakers-dir.js';
7
6
  export function machineContextPath() {
8
7
  return join(homeBbDir(), 'machine.config.js');
9
8
  }
10
- /** Legacy machine-context path (pre-BB-201), historical migration input only. */
11
- export function legacyMachineContextPath() {
12
- return join(homedir(), '.config', 'conductor', 'conductor.config.machine.js');
13
- }
14
9
  /** Resolve explicit or canonical current host context. */
15
10
  export function resolveMachineContextPath(path) {
16
11
  if (path !== undefined && path !== '')
@@ -2,7 +2,7 @@ import { shellQuote } from '../core/shell.js';
2
2
  import { createBbConnectionClient } from './config-online.js';
3
3
  import { loadBbConnectionBootstrap, } from './load-bakers-config.js';
4
4
  export function workspaceSearchCommand(path) {
5
- return `bakers dropsh --config ${shellQuote(path)} --format md search bb_workspace`;
5
+ return `bakers tools --config ${shellQuote(path)} tool_api__bakers_workspace_list`;
6
6
  }
7
7
  /** A UUID looks like `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`. */
8
8
  const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
@@ -9,7 +9,7 @@ export { type ConfigSourceInspection, type ConfigSourceProperty, declaresTopLeve
9
9
  export { HOME_IMPORT_EXPRESSION_PATTERN, importConfig, } from './cli/import-config.js';
10
10
  export { type LayeredUiEntryLayer, machineUiConfigPath, projectConductorConfigPath, readUiEntryLayers, } from './cli/layered-ui-entries.js';
11
11
  export { type BbConnectionConfig, BbConnectionConfigError, type BbConnectionGlobals, type BbConnectionLoadOptions, type BbConnectionSelection, type EffectiveConnectionField, loadBbConfig, loadBbConnectionBootstrap, reportLoadedBbConfigFields, resolveBbConnectionSelection, } from './cli/load-bakers-config.js';
12
- export { type AgentRoutes, legacyMachineContextPath, type MachineContext, machineContextPath, readMachineContext, resolveMachineContextPath, } from './cli/machine-context.js';
12
+ export { type AgentRoutes, type MachineContext, machineContextPath, readMachineContext, resolveMachineContextPath, } from './cli/machine-context.js';
13
13
  export { corePackageRoot } from './cli/paths.js';
14
14
  export { resolveModuleEslintStyle } from './cli/resolve-module.js';
15
15
  export { BB_PACKAGE, checkForUpdate, declineUpdate, defaultUpdateCachePath, fetchLatestVersion, fetchUpdateNotice, printVersionLine, REGISTRY_LATEST_URL, resolveCliVersion, UNKNOWN_VERSION, UPDATE_CHECK_TTL_MS, type UpdateCheckOptions, type UpdateCheckResult, updateNotice, } from './cli/version-check.js';
package/dist/src/index.js CHANGED
@@ -11,7 +11,7 @@ export { declaresTopLevelKey, findDefaultExportObject, inspectConfigSource, matc
11
11
  export { HOME_IMPORT_EXPRESSION_PATTERN, importConfig, } from './cli/import-config.js';
12
12
  export { machineUiConfigPath, projectConductorConfigPath, readUiEntryLayers, } from './cli/layered-ui-entries.js';
13
13
  export { BbConnectionConfigError, loadBbConfig, loadBbConnectionBootstrap, reportLoadedBbConfigFields, resolveBbConnectionSelection, } from './cli/load-bakers-config.js';
14
- export { legacyMachineContextPath, machineContextPath, readMachineContext, resolveMachineContextPath, } from './cli/machine-context.js';
14
+ export { machineContextPath, readMachineContext, resolveMachineContextPath, } from './cli/machine-context.js';
15
15
  export { corePackageRoot } from './cli/paths.js';
16
16
  export { resolveModuleEslintStyle } from './cli/resolve-module.js';
17
17
  export { BB_PACKAGE, checkForUpdate, declineUpdate, defaultUpdateCachePath, fetchLatestVersion, fetchUpdateNotice, printVersionLine, REGISTRY_LATEST_URL, resolveCliVersion, UNKNOWN_VERSION, UPDATE_CHECK_TTL_MS, updateNotice, } from './cli/version-check.js';
@@ -18,6 +18,10 @@ export interface CommandDescriptor {
18
18
  describe: string;
19
19
  /** Named export to pick instead of the module default. */
20
20
  export?: string;
21
+ /** Keep dispatch available while omitting the command from help. */
22
+ hidden?: boolean;
23
+ /** `bakers help <name>` runs `bakers <name> --help`, for plugins that render their own help. */
24
+ forwardHelp?: boolean;
21
25
  }
22
26
  /** The three surfaces, each named for its config home (surface = file = plugins). */
23
27
  export type BbSurface = 'command' | 'conductor' | 'connection';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bakers-build/core",
3
- "version": "0.5.1-next.746",
3
+ "version": "0.5.1-next.776",
4
4
  "description": "bakers.build surface-agnostic kernel: host contract, split-config helpers, addon preset/discovery machinery, shared primitives.",
5
5
  "type": "module",
6
6
  "license": "MIT",