@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
@@ -1,5 +1,5 @@
1
1
  // The effective addon list: `~/.bakers/machine.config.js` and the project's
2
- // `.bakers/conductor.config.js` each carry one `addons[]`, read the same way.
2
+ // `.bakers/project.config.js` each carry one `addons[]`, read the same way.
3
3
  // The addon decides where it may be listed (its preset's `scopes`, default
4
4
  // both); an entry in a scope it does not declare is reported and not loaded.
5
5
  // The same addon (resolved module + alias) in both scopes becomes one entry
@@ -11,34 +11,18 @@ import { dirname, join } from 'node:path';
11
11
  import { pathToFileURL } from 'node:url';
12
12
  import { findConfigProjectBbDir, homeBbDir } from '../cli/bakers-dir.js';
13
13
  import { AddonUnresolvedError, discoverAddons, isRetiredAddon, loadAddonPreset, normalizeEntry, } from './discover-addons.js';
14
- /** The addon's own findings for one entry's `with`; a throwing check is one. */
15
- function checkEntryWith(preset, entry) {
16
- if (!preset.checkWith)
17
- return [];
18
- try {
19
- return preset.checkWith(entryWith(entry));
20
- }
21
- catch (error) {
22
- return [
23
- {
24
- key: '',
25
- message: `checkWith failed: ${error instanceof Error ? error.message : String(error)}`,
26
- },
27
- ];
28
- }
29
- }
30
14
  const ALL_SCOPES = ['machine', 'project'];
31
15
  const SCOPE_FILE = {
32
16
  machine: '~/.bakers/machine.config.js',
33
- project: '.bakers/conductor.config.js',
17
+ project: '.bakers/project.config.js',
34
18
  };
35
- /** The `with` an entry carries (`options` is its alias). */
19
+ /** The `with` an entry carries. */
36
20
  function entryWith(entry) {
37
21
  return normalizeEntry(entry).opts;
38
22
  }
39
23
  /** `entry` as a descriptor carrying `with` (or none when undefined). */
40
24
  function withReplaced(entry, value) {
41
- const { with: _with, options: _options, ...rest } = typeof entry === 'string' ? { use: entry } : entry;
25
+ const { with: _with, ...rest } = typeof entry === 'string' ? { use: entry } : entry;
42
26
  return value === undefined ? rest : { ...rest, with: value };
43
27
  }
44
28
  /**
@@ -62,7 +46,7 @@ export async function scopeAddons(inputs, opts = {}) {
62
46
  ...inputs.filter((i) => i.scope !== 'machine'),
63
47
  ];
64
48
  for (const input of ordered) {
65
- for (const [index, entry] of input.entries.entries()) {
49
+ for (const entry of input.entries) {
66
50
  const { spec, alias } = normalizeEntry(entry);
67
51
  if (isRetiredAddon(spec)) {
68
52
  // discoverAddons warns once and skips it.
@@ -101,15 +85,6 @@ export async function scopeAddons(inputs, opts = {}) {
101
85
  `be configured only in ${allowed.map((s) => SCOPE_FILE[s]).join(' or ')}.`);
102
86
  continue;
103
87
  }
104
- for (const problem of checkEntryWith(loaded.preset, entry))
105
- findings.push({
106
- code: 'addon_with_invalid',
107
- spec,
108
- path: input.path,
109
- scope: input.scope,
110
- index,
111
- ...problem,
112
- });
113
88
  const match = `${loaded.key}\0${alias ?? ''}`;
114
89
  const at = input.scope === 'project' ? machineAt.get(match) : undefined;
115
90
  if (at !== undefined) {
@@ -142,20 +117,20 @@ export function discoverScoped(addons, surface, opts = {}) {
142
117
  return discoverAddons(addons.map((a) => a.entry), surface, addons[0]?.bases ?? [], { ...opts, entryBases: addons.map((a) => a.bases) });
143
118
  }
144
119
  /**
145
- * `<BB_HOME or ~/.bakers>/machine.config.js`. `home` stays optional and, when
120
+ * `<BAKERS_HOME or ~/.bakers>/machine.config.js`. `home` stays optional and, when
146
121
  * given, still wins (a fixture that pins an explicit home) — but an absent one
147
122
  * must reach `homeBbDir()`'s resolver rather than collapsing to the OS home
148
- * first, or `BB_HOME` never relocates this file.
123
+ * first, or `BAKERS_HOME` never relocates this file.
149
124
  */
150
125
  export function machineUiConfigPath(home) {
151
126
  return join(homeBbDir(home), 'machine.config.js');
152
127
  }
153
- /** The nearest project `.bakers/conductor.config.js` above `cwd`, or undefined. */
128
+ /** The nearest project `.bakers/project.config.js` above `cwd`, or undefined. */
154
129
  export function projectConductorConfigPath(cwd, home) {
155
130
  const bakersDir = findConfigProjectBbDir(cwd, home);
156
131
  if (bakersDir === undefined)
157
132
  return undefined;
158
- const path = join(dirname(bakersDir), '.bakers', 'conductor.config.js');
133
+ const path = join(dirname(bakersDir), '.bakers', 'project.config.js');
159
134
  return existsSync(path) ? path : undefined;
160
135
  }
161
136
  /** A config file's `addons[]`, or `[]` when the file is absent or broken. */
@@ -174,7 +149,7 @@ export async function readConfigAddons(path) {
174
149
  }
175
150
  /**
176
151
  * The effective entry for one addon package from `machine.config.js` and the
177
- * nearest project `.bakers/conductor.config.js` above `cwd` (or `projectPath`).
152
+ * nearest project `.bakers/project.config.js` above `cwd` (or `projectPath`).
178
153
  * `bases` are appended to each scope's own (e.g. the caller's install).
179
154
  */
180
155
  export async function readEffectiveAddon(spec, opts) {
@@ -202,7 +177,7 @@ export async function readEffectiveAddon(spec, opts) {
202
177
  });
203
178
  // Only this addon's entries: an unrelated broken entry must not block it.
204
179
  for (const input of inputs)
205
- input.entries = input.entries.filter((e) => (typeof e === 'string' ? e : (e?.use ?? e?.name)) === spec);
180
+ input.entries = input.entries.filter((e) => (typeof e === 'string' ? e : e?.use) === spec);
206
181
  const { addons } = await scopeAddons(inputs, { unresolved: 'skip' });
207
182
  return addons[0];
208
183
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bakers-build/core",
3
- "version": "0.7.1-next.7",
3
+ "version": "0.8.1-next.1",
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",
@@ -10,10 +10,12 @@
10
10
  "exports": {
11
11
  ".": "./dist/src/index.js",
12
12
  "./conductor-registry": "./dist/src/conductor-registry/index.js",
13
- "./package.json": "./package.json"
13
+ "./package.json": "./package.json",
14
+ "./schema/*": "./schema/*"
14
15
  },
15
16
  "files": [
16
17
  "dist/src",
18
+ "schema",
17
19
  "README.md",
18
20
  "LICENSE"
19
21
  ],
@@ -38,7 +40,7 @@
38
40
  "yaml": "^2.7.0"
39
41
  },
40
42
  "bakersBuild": {
41
- "commit": "082d8c57436f78e751f5a9a26a4446cec42209ce",
43
+ "commit": "c4a887bee37bb2fed14bb9ba15ad0aacf0e26f7e",
42
44
  "channel": "next"
43
45
  }
44
46
  }
@@ -0,0 +1,57 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://bakers.build/schema/connection.schema.json",
4
+ "title": "ConnectionConfig",
5
+ "description": "A connection to a bakers.build server: ~/.bakers/connections/<id>.js, or a project's .bakers/connection.config.js. dropsh reads the same file.",
6
+ "type": "object",
7
+ "properties": {
8
+ "schema_version": {
9
+ "const": 1,
10
+ "description": "Configuration schema version."
11
+ },
12
+ "site": {
13
+ "type": "object",
14
+ "properties": {
15
+ "base_url": {
16
+ "type": "string",
17
+ "pattern": "^https?://[^\\s/]+",
18
+ "description": "The server's absolute HTTP(S) URL."
19
+ },
20
+ "jsonapi_prefix": {
21
+ "type": "string",
22
+ "description": "JSON:API path prefix. Default /jsonapi."
23
+ }
24
+ },
25
+ "required": ["base_url"],
26
+ "additionalProperties": false
27
+ },
28
+ "workspace_id": {
29
+ "type": "string",
30
+ "description": "Workspace bakers ui starts focused on."
31
+ },
32
+ "plugins": {
33
+ "type": "array",
34
+ "description": "dropsh plugins: { plugin, export?, with?, options? }, or constructed plugins.",
35
+ "items": {
36
+ "if": { "type": "object", "required": ["plugin"] },
37
+ "then": {
38
+ "properties": {
39
+ "plugin": { "$ref": "project.schema.json#/$defs/nonempty" },
40
+ "export": { "$ref": "project.schema.json#/$defs/nonempty" },
41
+ "with": {},
42
+ "options": {}
43
+ },
44
+ "additionalProperties": false
45
+ },
46
+ "else": { "type": "object" }
47
+ }
48
+ },
49
+ "addons": {
50
+ "type": "array",
51
+ "description": "Connection addons, such as auth providers.",
52
+ "items": { "$ref": "project.schema.json#/$defs/addon" }
53
+ }
54
+ },
55
+ "required": ["site"],
56
+ "additionalProperties": false
57
+ }
@@ -0,0 +1,46 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://bakers.build/schema/harness-options.schema.json",
4
+ "title": "Options every agent harness takes",
5
+ "description": "Composed by each harness addon's options.schema.json, which adds its own keys and rejects unknown ones with unevaluatedProperties: false.",
6
+ "type": "object",
7
+ "properties": {
8
+ "args": {
9
+ "type": "array",
10
+ "items": { "type": "string" },
11
+ "description": "Extra command-line arguments appended to the agent launch."
12
+ },
13
+ "model": { "type": "string", "description": "Model the agent runs." },
14
+ "effort": {
15
+ "type": "string",
16
+ "description": "Reasoning effort the agent runs at."
17
+ },
18
+ "permissions": {
19
+ "enum": ["sandbox", "system", "yolo", "custom"],
20
+ "description": "Permission mode. Default: system."
21
+ },
22
+ "sandbox": {
23
+ "type": "object",
24
+ "description": "Sandbox lists; only valid with permissions: 'sandbox'.",
25
+ "properties": {
26
+ "trusted_commands": { "$ref": "#/$defs/string_list" },
27
+ "deny_read": { "$ref": "#/$defs/string_list" },
28
+ "allow_write": { "$ref": "#/$defs/string_list" },
29
+ "network": { "$ref": "#/$defs/string_list" },
30
+ "mcp_servers": { "type": "object" }
31
+ },
32
+ "additionalProperties": false
33
+ },
34
+ "config": {
35
+ "type": "object",
36
+ "description": "The agent's own permission configuration; only valid with permissions: 'custom'."
37
+ },
38
+ "env_deny": {
39
+ "$ref": "#/$defs/string_list",
40
+ "description": "Environment variables removed from the run environment."
41
+ }
42
+ },
43
+ "$defs": {
44
+ "string_list": { "type": "array", "items": { "type": "string" } }
45
+ }
46
+ }
@@ -0,0 +1,77 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://bakers.build/schema/machine.schema.json",
4
+ "title": "MachineConfig",
5
+ "description": "This machine's private configuration: ~/.bakers/machine.config.js.",
6
+ "type": "object",
7
+ "properties": {
8
+ "schema_version": {
9
+ "const": 1,
10
+ "description": "Configuration schema version."
11
+ },
12
+ "machine_id": {
13
+ "$ref": "project.schema.json#/$defs/nonempty",
14
+ "description": "Host key; bakers init writes a UUID."
15
+ },
16
+ "label": {
17
+ "$ref": "project.schema.json#/$defs/nonempty",
18
+ "description": "Display name for people."
19
+ },
20
+ "agents": {
21
+ "type": "object",
22
+ "description": "Selection policy for the agents the addons contribute.",
23
+ "properties": {
24
+ "catalog": {
25
+ "type": "array",
26
+ "description": "Extra agent variants built from installed harnesses.",
27
+ "items": {
28
+ "type": "object",
29
+ "properties": {
30
+ "harness": { "$ref": "project.schema.json#/$defs/nonempty" },
31
+ "alias": { "$ref": "project.schema.json#/$defs/nonempty" },
32
+ "with": { "description": "The harness options." }
33
+ },
34
+ "required": ["harness"],
35
+ "additionalProperties": false
36
+ }
37
+ },
38
+ "enabled": { "$ref": "#/$defs/alias_list" },
39
+ "disabled": { "$ref": "#/$defs/alias_list" },
40
+ "routes": {
41
+ "type": "object",
42
+ "description": "Named routes from states (or *) to aliases; routes.default is the automatic one.",
43
+ "additionalProperties": {
44
+ "type": "object",
45
+ "minProperties": 1,
46
+ "additionalProperties": {
47
+ "$ref": "project.schema.json#/$defs/nonempty"
48
+ }
49
+ }
50
+ }
51
+ },
52
+ "additionalProperties": false
53
+ },
54
+ "addons": {
55
+ "type": "array",
56
+ "description": "Addons this machine uses.",
57
+ "items": { "$ref": "project.schema.json#/$defs/addon" }
58
+ },
59
+ "tunnel": {
60
+ "type": "boolean",
61
+ "description": "Share local preview links through bakers ports. Default false."
62
+ },
63
+ "permissions": { "$ref": "project.schema.json#/$defs/permissions" },
64
+ "executor": {
65
+ "$ref": "project.schema.json#/$defs/slot",
66
+ "description": "This machine's executor; overrides every project's."
67
+ }
68
+ },
69
+ "required": ["machine_id", "label"],
70
+ "additionalProperties": false,
71
+ "$defs": {
72
+ "alias_list": {
73
+ "type": "array",
74
+ "items": { "$ref": "project.schema.json#/$defs/nonempty" }
75
+ }
76
+ }
77
+ }
@@ -0,0 +1,262 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://bakers.build/schema/project.schema.json",
4
+ "title": "ProjectConfig",
5
+ "description": "A project's committed conductor configuration: .bakers/project.config.js and its variants .bakers/project.<name>.config.js.",
6
+ "type": "object",
7
+ "properties": {
8
+ "schema_version": {
9
+ "const": 1,
10
+ "description": "Configuration schema version."
11
+ },
12
+ "project": {
13
+ "type": "object",
14
+ "description": "The bakers.build project this repository belongs to.",
15
+ "properties": {
16
+ "name": {
17
+ "$ref": "#/$defs/nonempty",
18
+ "description": "Project name on the server; BAKERS_PROJECT overrides it."
19
+ },
20
+ "workspace": {
21
+ "$ref": "#/$defs/nonempty",
22
+ "description": "Team workspace the project belongs to."
23
+ }
24
+ },
25
+ "required": [
26
+ "name"
27
+ ],
28
+ "additionalProperties": false
29
+ },
30
+ "permissions": {
31
+ "$ref": "#/$defs/permissions"
32
+ },
33
+ "addons": {
34
+ "type": "array",
35
+ "description": "Addons this project uses.",
36
+ "items": {
37
+ "$ref": "#/$defs/addon"
38
+ }
39
+ },
40
+ "server": {
41
+ "$ref": "#/$defs/slot",
42
+ "description": "Explicit server slot; wins over an addon's."
43
+ },
44
+ "executor": {
45
+ "$ref": "#/$defs/slot",
46
+ "description": "Explicit executor slot; the machine's wins over it."
47
+ },
48
+ "worktree": {
49
+ "$ref": "#/$defs/slot",
50
+ "description": "Explicit worktree slot; wins over an addon's."
51
+ },
52
+ "states": {
53
+ "type": "array",
54
+ "description": "States this conductor serves; empty or absent serves all.",
55
+ "items": {
56
+ "$ref": "#/$defs/nonempty"
57
+ }
58
+ },
59
+ "prompt": {
60
+ "type": "string",
61
+ "description": "Agent prompt; placeholders {identifier}, {state}, {run_uuid}, {ticket_uuid}."
62
+ },
63
+ "poll_interval_ms": {
64
+ "type": "integer",
65
+ "minimum": 1,
66
+ "description": "Poll interval in milliseconds. Default 5000."
67
+ },
68
+ "lease_seconds": {
69
+ "type": "integer",
70
+ "minimum": 1,
71
+ "description": "Run lease in seconds. Default 300."
72
+ },
73
+ "restart_on_change": {
74
+ "type": "boolean",
75
+ "description": "Restart the foreground conductor when a config file changes. Default true."
76
+ },
77
+ "capture_logs": {
78
+ "type": "boolean",
79
+ "description": "Upload transcripts where the server allows it. Default true."
80
+ },
81
+ "hooks": {
82
+ "type": "object",
83
+ "description": "Shell commands the conductor runs in a ticket's worktree.",
84
+ "properties": {
85
+ "after_create": {
86
+ "type": "string"
87
+ },
88
+ "before_run": {
89
+ "type": "string"
90
+ },
91
+ "after_run": {
92
+ "type": "string"
93
+ },
94
+ "after_done": {
95
+ "type": "string"
96
+ },
97
+ "on_freeze": {
98
+ "type": "string"
99
+ },
100
+ "on_resume": {
101
+ "type": "string"
102
+ },
103
+ "provision_up": {
104
+ "description": "Command, or commands by profile, offered to runs as provision_up(profile?).",
105
+ "anyOf": [
106
+ {
107
+ "type": "string"
108
+ },
109
+ {
110
+ "type": "object",
111
+ "additionalProperties": {
112
+ "type": "string"
113
+ }
114
+ }
115
+ ]
116
+ }
117
+ },
118
+ "additionalProperties": false
119
+ },
120
+ "marketplaces": {
121
+ "type": "array",
122
+ "description": "Agent plugin marketplaces every run of this project installs.",
123
+ "items": {
124
+ "type": "object",
125
+ "properties": {
126
+ "url": {
127
+ "type": "string",
128
+ "pattern": "^(https?://|ssh://|git@[^:\\s]+:)\\S+$",
129
+ "description": "a remote Git URL (https, ssh or git@)"
130
+ },
131
+ "ref": {
132
+ "$ref": "#/$defs/nonempty",
133
+ "description": "Branch or tag."
134
+ },
135
+ "plugins": {
136
+ "type": "array",
137
+ "minItems": 1,
138
+ "items": {
139
+ "$ref": "#/$defs/nonempty"
140
+ }
141
+ }
142
+ },
143
+ "required": [
144
+ "url",
145
+ "ref",
146
+ "plugins"
147
+ ],
148
+ "additionalProperties": false
149
+ }
150
+ },
151
+ "select_agent": {
152
+ "function": true,
153
+ "description": "Function choosing the agent for a ticket; replaces the shipped selection."
154
+ }
155
+ },
156
+ "required": [
157
+ "project"
158
+ ],
159
+ "additionalProperties": false,
160
+ "$defs": {
161
+ "nonempty": {
162
+ "type": "string",
163
+ "minLength": 1,
164
+ "pattern": "\\S"
165
+ },
166
+ "permissions": {
167
+ "type": "object",
168
+ "description": "Shared run permissions for every agent.",
169
+ "properties": {
170
+ "mode": {
171
+ "enum": [
172
+ "sandbox",
173
+ "system",
174
+ "yolo"
175
+ ]
176
+ },
177
+ "sandbox": {
178
+ "type": "object",
179
+ "properties": {
180
+ "deny_read": {
181
+ "$ref": "#/$defs/string_list"
182
+ },
183
+ "allow_write": {
184
+ "$ref": "#/$defs/string_list"
185
+ },
186
+ "trusted_commands": {
187
+ "$ref": "#/$defs/string_list"
188
+ }
189
+ },
190
+ "additionalProperties": false
191
+ }
192
+ },
193
+ "additionalProperties": false
194
+ },
195
+ "string_list": {
196
+ "type": "array",
197
+ "items": {
198
+ "type": "string"
199
+ }
200
+ },
201
+ "addon": {
202
+ "description": "A package name, or { use, alias?, with? }.",
203
+ "if": {
204
+ "type": "string"
205
+ },
206
+ "then": {
207
+ "$ref": "#/$defs/nonempty"
208
+ },
209
+ "else": {
210
+ "type": "object",
211
+ "properties": {
212
+ "use": {
213
+ "$ref": "#/$defs/nonempty"
214
+ },
215
+ "alias": {
216
+ "$ref": "#/$defs/nonempty"
217
+ },
218
+ "with": {
219
+ "description": "The addon's options."
220
+ },
221
+ "priority": {
222
+ "function": true
223
+ }
224
+ },
225
+ "required": [
226
+ "use"
227
+ ],
228
+ "additionalProperties": false
229
+ }
230
+ },
231
+ "slot": {
232
+ "description": "{ use, export?, with? }, or a constructed plugin carrying its kind.",
233
+ "if": {
234
+ "type": "object",
235
+ "required": [
236
+ "kind"
237
+ ]
238
+ },
239
+ "then": {
240
+ "type": "object"
241
+ },
242
+ "else": {
243
+ "type": "object",
244
+ "properties": {
245
+ "use": {
246
+ "$ref": "#/$defs/nonempty"
247
+ },
248
+ "export": {
249
+ "$ref": "#/$defs/nonempty"
250
+ },
251
+ "with": {
252
+ "description": "Options passed to the factory."
253
+ }
254
+ },
255
+ "required": [
256
+ "use"
257
+ ],
258
+ "additionalProperties": false
259
+ }
260
+ }
261
+ }
262
+ }