@bakers-build/conductor 0.8.0 → 0.8.1-next.10
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.
- package/dist/src/cli/config-plan.js +14 -29
- package/dist/src/cli/config-schema.d.ts +4 -4
- package/dist/src/cli/config-schema.js +5 -5
- package/dist/src/cli/config-templates.js +18 -24
- package/dist/src/cli/config-validation.d.ts +1 -1
- package/dist/src/cli/config-validation.js +27 -131
- package/dist/src/cli/project-context.d.ts +5 -8
- package/dist/src/cli/project-context.js +25 -68
- package/dist/src/commands/conductor.d.ts +2 -2
- package/dist/src/commands/conductor.js +24 -24
- package/dist/src/commands/oven-tools.js +1 -1
- package/dist/src/config.d.ts +16 -17
- package/dist/src/config.js +70 -136
- package/dist/src/contract.d.ts +2 -2
- package/dist/src/contract.js +1 -1
- package/dist/src/core/conductor.d.ts +3 -3
- package/dist/src/core/conductor.js +67 -35
- package/dist/src/core/mr-changes.js +3 -1
- package/dist/src/core/start-hooks.d.ts +3 -0
- package/dist/src/core/start-hooks.js +58 -0
- package/dist/src/core/tool-server.d.ts +1 -1
- package/dist/src/plugins/agent.d.ts +10 -3
- package/dist/src/plugins/agent.js +11 -3
- package/dist/src/plugins/executor.d.ts +12 -1
- package/dist/src/plugins/plugins.d.ts +2 -2
- package/dist/src/plugins/preset.d.ts +5 -5
- package/dist/src/plugins/remote.d.ts +9 -6
- package/dist/src/plugins/tools.d.ts +1 -0
- package/dist/src/plugins/tools.js +3 -3
- package/dist/src/plugins/workspace.d.ts +1 -1
- package/dist/src/preset.js +3 -2
- package/dist/src/types.d.ts +5 -4
- package/package.json +5 -5
- package/dist/src/core/required-skills.d.ts +0 -7
- package/dist/src/core/required-skills.js +0 -157
|
@@ -8,10 +8,10 @@ import { applyMigrations, BB_CONFIG_SCHEMA_VERSION } from './config-schema.js';
|
|
|
8
8
|
import { ConfigSourceEditor, redactConfigSource, } from './config-source-edit.js';
|
|
9
9
|
import { renderCommittedConfig, renderGlobalConnection, renderHostMachine, } from './config-templates.js';
|
|
10
10
|
import { validateConfigSources } from './config-validation.js';
|
|
11
|
-
// Every config file
|
|
11
|
+
// Every config file is at schema v1; no migration step exists yet.
|
|
12
12
|
const CURRENT = {
|
|
13
13
|
machine: 1,
|
|
14
|
-
|
|
14
|
+
project: 1,
|
|
15
15
|
connection: 1,
|
|
16
16
|
'project-connection': 1,
|
|
17
17
|
};
|
|
@@ -274,11 +274,6 @@ export function planConfig(options = {}) {
|
|
|
274
274
|
}
|
|
275
275
|
if (currentRoute === undefined)
|
|
276
276
|
machineEditor.set('agents.routes.default', expression);
|
|
277
|
-
const catchAll = source.property('default_agent.*');
|
|
278
|
-
if (catchAll?.staticallyDetermined &&
|
|
279
|
-
typeof catchAll.value === 'string' &&
|
|
280
|
-
!machineEditor.property('agents.default_agent'))
|
|
281
|
-
machineEditor.set('agents.default_agent', JSON.stringify(catchAll.value));
|
|
282
277
|
source.remove('default_agent');
|
|
283
278
|
};
|
|
284
279
|
const migrateCatalog = (sourceFile, source) => {
|
|
@@ -395,13 +390,6 @@ export function planConfig(options = {}) {
|
|
|
395
390
|
}
|
|
396
391
|
source.remove('agent');
|
|
397
392
|
};
|
|
398
|
-
const deriveMachineDefault = () => {
|
|
399
|
-
if (machineEditor.property('agents.default_agent'))
|
|
400
|
-
return;
|
|
401
|
-
const catchAll = machineEditor.property('agents.routes.default.*');
|
|
402
|
-
if (catchAll?.staticallyDetermined && typeof catchAll.value === 'string')
|
|
403
|
-
machineEditor.set('agents.default_agent', JSON.stringify(catchAll.value));
|
|
404
|
-
};
|
|
405
393
|
if (machine.selected && !protectedFile(machine)) {
|
|
406
394
|
const oldAgents = machineEditor.property('agents');
|
|
407
395
|
if (oldAgents?.nodeType === 'ArrayExpression') {
|
|
@@ -427,9 +415,8 @@ export function planConfig(options = {}) {
|
|
|
427
415
|
if (routes !== undefined)
|
|
428
416
|
setMachineAgentValue(machine, machineEditor, 'agent_routes', 'agents.routes', routes);
|
|
429
417
|
migrateStateDefaults(machine, machineEditor);
|
|
430
|
-
deriveMachineDefault();
|
|
431
418
|
}
|
|
432
|
-
for (const file of files.filter((candidate) => candidate.selected &&
|
|
419
|
+
for (const file of files.filter((candidate) => candidate.selected && candidate.kind === 'project')) {
|
|
433
420
|
const source = editors.get(file.path);
|
|
434
421
|
if (!source || protectedFile(file))
|
|
435
422
|
continue;
|
|
@@ -443,9 +430,7 @@ export function planConfig(options = {}) {
|
|
|
443
430
|
if (routes !== undefined)
|
|
444
431
|
setMachineAgentValue(file, source, 'agent_routes', 'agents.routes', routes);
|
|
445
432
|
migrateStateDefaults(file, source);
|
|
446
|
-
|
|
447
|
-
migrateCatalog(file, source);
|
|
448
|
-
deriveMachineDefault();
|
|
433
|
+
migrateCatalog(file, source);
|
|
449
434
|
}
|
|
450
435
|
for (const file of files) {
|
|
451
436
|
if (protectedFile(file) || !file.selected)
|
|
@@ -462,7 +447,7 @@ export function planConfig(options = {}) {
|
|
|
462
447
|
fill(file, 'label', options.inputs?.label);
|
|
463
448
|
editor(file).stamp(1);
|
|
464
449
|
}
|
|
465
|
-
if (file.kind === '
|
|
450
|
+
if (file.kind === 'project') {
|
|
466
451
|
if ((!e || e.text.trim() === 'export default {};') &&
|
|
467
452
|
file.required &&
|
|
468
453
|
options.project) {
|
|
@@ -477,9 +462,9 @@ export function planConfig(options = {}) {
|
|
|
477
462
|
}
|
|
478
463
|
if (!e)
|
|
479
464
|
continue;
|
|
480
|
-
|
|
465
|
+
{
|
|
481
466
|
e = editor(file);
|
|
482
|
-
fill(file, '
|
|
467
|
+
fill(file, 'project.name', options.project);
|
|
483
468
|
const canonical = new ConfigSourceEditor(renderCommittedConfig({
|
|
484
469
|
project: options.project ?? 'project',
|
|
485
470
|
}));
|
|
@@ -488,18 +473,18 @@ export function planConfig(options = {}) {
|
|
|
488
473
|
.map(([, property]) => property.value)
|
|
489
474
|
.filter((value) => typeof value === 'string'));
|
|
490
475
|
const providers = {
|
|
491
|
-
|
|
476
|
+
server: [
|
|
492
477
|
'@bakers-build/addon-remote-drupal',
|
|
493
478
|
'@bakers-build/addon-fake',
|
|
494
479
|
],
|
|
495
480
|
executor: ['@bakers-build/addon-herdr', '@bakers-build/addon-fake'],
|
|
496
|
-
|
|
481
|
+
worktree: [
|
|
497
482
|
'@bakers-build/addon-herdr',
|
|
498
483
|
'@bakers-build/addon-fake',
|
|
499
484
|
'@bakers-build/addon-workspace-git',
|
|
500
485
|
],
|
|
501
486
|
};
|
|
502
|
-
for (const slot of ['
|
|
487
|
+
for (const slot of ['server', 'executor', 'worktree']) {
|
|
503
488
|
if (e.property(slot) ||
|
|
504
489
|
providers[slot]?.some((provider) => addonPackages.has(provider)))
|
|
505
490
|
continue;
|
|
@@ -507,8 +492,8 @@ export function planConfig(options = {}) {
|
|
|
507
492
|
}
|
|
508
493
|
if (options.operation === 'init' &&
|
|
509
494
|
options.inputs?.workspace &&
|
|
510
|
-
!e.property('
|
|
511
|
-
e.set('
|
|
495
|
+
!e.property('project.workspace'))
|
|
496
|
+
e.set('project.workspace', JSON.stringify(options.inputs.workspace));
|
|
512
497
|
e.stamp(1);
|
|
513
498
|
}
|
|
514
499
|
}
|
|
@@ -585,7 +570,7 @@ export function planConfig(options = {}) {
|
|
|
585
570
|
after,
|
|
586
571
|
mode: before !== null
|
|
587
572
|
? statSync(file.path).mode & 0o777
|
|
588
|
-
: file.kind === 'project
|
|
573
|
+
: file.kind === 'project'
|
|
589
574
|
? 0o644
|
|
590
575
|
: 0o600,
|
|
591
576
|
});
|
|
@@ -593,7 +578,7 @@ export function planConfig(options = {}) {
|
|
|
593
578
|
path: file.path,
|
|
594
579
|
layer: file.layer,
|
|
595
580
|
before_version: file.version.effective,
|
|
596
|
-
after_version: after === null
|
|
581
|
+
after_version: after === null ? null : CURRENT[file.kind],
|
|
597
582
|
diff: `--- ${file.path}\n+++ ${file.path}\n${before === null
|
|
598
583
|
? ''
|
|
599
584
|
: redactConfigSource(before)
|
|
@@ -18,10 +18,10 @@ export interface ConnectionConfigMigration {
|
|
|
18
18
|
apply(currentText: string): string;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
|
-
* The ordered, contiguous migration chain.
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
21
|
+
* The ordered, contiguous migration chain. Every config file is at schema v1,
|
|
22
|
+
* so the chain is empty; a later shape change adds its `v1 → v2` step here.
|
|
23
|
+
* `BB_CONFIG_SCHEMA_VERSION` derives from the chain's last `to` — never
|
|
24
|
+
* hardcode it.
|
|
25
25
|
*/
|
|
26
26
|
export declare const CONNECTION_MIGRATIONS: ConnectionConfigMigration[];
|
|
27
27
|
/** The current connection-config schema version — single source of truth. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
2
|
// BB-216: schema versioning for the generated CONNECTION config
|
|
3
|
-
// (
|
|
3
|
+
// (connection file, project + home). Decoupled from the npm package semver —
|
|
4
4
|
// the schema version bumps only when the config SHAPE changes, not every
|
|
5
5
|
// release. Every generated connection config carries a machine-readable header
|
|
6
6
|
// comment `// @bakers-schema-version <N>` (the source of truth for the upgrade
|
|
@@ -11,10 +11,10 @@ import { readFileSync } from 'node:fs';
|
|
|
11
11
|
const MARKER_RE = /@bakers-schema-version\s+(\d+)/;
|
|
12
12
|
const HEADER_LINE_RE = /^\/\/ @bakers-schema-version \d+\n/;
|
|
13
13
|
/**
|
|
14
|
-
* The ordered, contiguous migration chain.
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
14
|
+
* The ordered, contiguous migration chain. Every config file is at schema v1,
|
|
15
|
+
* so the chain is empty; a later shape change adds its `v1 → v2` step here.
|
|
16
|
+
* `BB_CONFIG_SCHEMA_VERSION` derives from the chain's last `to` — never
|
|
17
|
+
* hardcode it.
|
|
18
18
|
*/
|
|
19
19
|
export const CONNECTION_MIGRATIONS = [];
|
|
20
20
|
/** The current connection-config schema version — single source of truth. */
|
|
@@ -15,7 +15,8 @@ export function renderGlobalConnection(inputs) {
|
|
|
15
15
|
device_authorization_url: ${JSON.stringify(`${baseUrl}/oauth/device_authorization`)},`
|
|
16
16
|
: `client_id: ${JSON.stringify(inputs.clientId)}, client_secret: ${JSON.stringify(inputs.secret ?? '')},`;
|
|
17
17
|
return `// @bakers-schema-version 1
|
|
18
|
-
//
|
|
18
|
+
// A bakers.build connection: credentials and optional workspace. Keep this file private.
|
|
19
|
+
/** @type {import('@bakers-build/core').ConnectionConfig} */
|
|
19
20
|
export default {
|
|
20
21
|
schema_version: 1,
|
|
21
22
|
site: { base_url: ${JSON.stringify(inputs.baseUrl)}, jsonapi_prefix: '/jsonapi' },
|
|
@@ -34,9 +35,10 @@ ${inputs.workspaceId ? ` workspace_id: ${JSON.stringify(inputs.workspaceId)},\n
|
|
|
34
35
|
export function renderHostMachine(inputs) {
|
|
35
36
|
return `// @bakers-schema-version 1
|
|
36
37
|
// Local host identity. The run budget is set on the machine in the backend;
|
|
37
|
-
// server credentials belong to
|
|
38
|
-
// (e.g. \`{
|
|
39
|
-
// project's executor on this machine.
|
|
38
|
+
// server credentials belong to the connection (connections/default.js). An
|
|
39
|
+
// \`executor\` slot here (e.g. \`{ use: '@bakers-build/addon-herdr-core' }\`)
|
|
40
|
+
// overrides every project's executor on this machine.
|
|
41
|
+
/** @type {import('@bakers-build/core').MachineConfig} */
|
|
40
42
|
export default {
|
|
41
43
|
schema_version: 1,
|
|
42
44
|
machine_id: ${JSON.stringify(inputs.machineId)},
|
|
@@ -44,21 +46,18 @@ ${inputs.label ? ` label: ${JSON.stringify(inputs.label)},\n` : ''}};
|
|
|
44
46
|
`;
|
|
45
47
|
}
|
|
46
48
|
export function renderCommittedConfig(inputs) {
|
|
47
|
-
return `//
|
|
48
|
-
//
|
|
49
|
-
// (
|
|
50
|
-
// Connections belong to bakers.config.js.
|
|
49
|
+
return `// The project's bakers.build configuration — committed and identical for
|
|
50
|
+
// everyone. A conductor is this machine (machine.config.js) + this project +
|
|
51
|
+
// the variant (project.<name>.config.js). Connections are private files.
|
|
51
52
|
//
|
|
52
|
-
//
|
|
53
|
-
//
|
|
54
|
-
//
|
|
55
|
-
//
|
|
56
|
-
// no slot needs an \`export:\` — EXCEPT the merged herdr workspace
|
|
57
|
-
// (\`@bakers-build/addon-herdr\` default-exports the executor, so the workspace names
|
|
58
|
-
// \`export: 'herdrWorkspace'\` — BB-139).
|
|
53
|
+
// The slots are \`{ use, export?, with? }\` descriptors naming the published
|
|
54
|
+
// package; the loader resolves each name (config dir → cwd → CLI install).
|
|
55
|
+
// \`@bakers-build/addon-herdr\` default-exports the executor, so the worktree
|
|
56
|
+
// slot names \`export: 'herdrWorkspace'\`.
|
|
59
57
|
|
|
58
|
+
/** @type {import('@bakers-build/core').ProjectConfig} */
|
|
60
59
|
export default {
|
|
61
|
-
|
|
60
|
+
project: { name: ${JSON.stringify(inputs.project)}${inputs.bakersWorkspace ? `, workspace: ${JSON.stringify(inputs.bakersWorkspace)}` : ''} },
|
|
62
61
|
// The run budget (max_parallel) is set on the machine in the backend.
|
|
63
62
|
// Transcripts upload only where the server's run-log storage allows it.
|
|
64
63
|
// Set to false to keep this conductor's transcripts local even then.
|
|
@@ -77,15 +76,10 @@ ${inputs.hooks?.after_create || inputs.hooks?.after_done
|
|
|
77
76
|
]
|
|
78
77
|
.filter(Boolean)
|
|
79
78
|
.join(', ')} },\n`
|
|
80
|
-
: ''}
|
|
81
|
-
executor: {
|
|
79
|
+
: ''} server: { use: '@bakers-build/addon-remote-drupal' },
|
|
80
|
+
executor: { use: '@bakers-build/addon-herdr' },
|
|
82
81
|
addons: ${DEFAULT_CONDUCTOR_AGENT_ADDONS},
|
|
83
|
-
|
|
84
|
-
// default-exports the EXECUTOR — so the workspace slot names export: 'herdrWorkspace'.
|
|
85
|
-
workspace: {
|
|
86
|
-
plugin: '@bakers-build/addon-herdr',
|
|
87
|
-
export: 'herdrWorkspace',
|
|
88
|
-
},
|
|
82
|
+
worktree: { use: '@bakers-build/addon-herdr', export: 'herdrWorkspace' },
|
|
89
83
|
};
|
|
90
84
|
`;
|
|
91
85
|
}
|
|
@@ -4,7 +4,7 @@ import { type ConfigFileReport, type ConfigInventoryOptions, type ConfigReport }
|
|
|
4
4
|
* addon, fills no conductor slot" — a UI-only addon (BB-562) belongs in a
|
|
5
5
|
* conductor `addons[]` but contributes a cockpit tab, not a slot. Listing it is
|
|
6
6
|
* not cosmetic: an UNKNOWN specifier sets `addonsAreOpaque` below, which
|
|
7
|
-
* downgrades a genuinely missing
|
|
7
|
+
* downgrades a genuinely missing server/executor/worktree from
|
|
8
8
|
* `missing_required_key` to `unknown_value`.
|
|
9
9
|
*/
|
|
10
10
|
export declare const CONDUCTOR_ADDON_SLOTS: Record<string, string[]>;
|
|
@@ -5,16 +5,16 @@ import { ConfigSourceEditor } from './config-source-edit.js';
|
|
|
5
5
|
* addon, fills no conductor slot" — a UI-only addon (BB-562) belongs in a
|
|
6
6
|
* conductor `addons[]` but contributes a cockpit tab, not a slot. Listing it is
|
|
7
7
|
* not cosmetic: an UNKNOWN specifier sets `addonsAreOpaque` below, which
|
|
8
|
-
* downgrades a genuinely missing
|
|
8
|
+
* downgrades a genuinely missing server/executor/worktree from
|
|
9
9
|
* `missing_required_key` to `unknown_value`.
|
|
10
10
|
*/
|
|
11
11
|
export const CONDUCTOR_ADDON_SLOTS = {
|
|
12
|
-
'@bakers-build/addon-remote-drupal': ['
|
|
13
|
-
'@bakers-build/addon-herdr': ['executor', '
|
|
14
|
-
'@bakers-build/addon-orca': ['executor', '
|
|
12
|
+
'@bakers-build/addon-remote-drupal': ['server'],
|
|
13
|
+
'@bakers-build/addon-herdr': ['executor', 'worktree'],
|
|
14
|
+
'@bakers-build/addon-orca': ['executor', 'worktree'],
|
|
15
15
|
'@bakers-build/addon-herdr-core': ['executor'],
|
|
16
|
-
'@bakers-build/addon-fake': ['
|
|
17
|
-
'@bakers-build/addon-workspace-git': ['
|
|
16
|
+
'@bakers-build/addon-fake': ['server', 'executor', 'worktree'],
|
|
17
|
+
'@bakers-build/addon-workspace-git': ['worktree'],
|
|
18
18
|
'@bakers-build/addon-claude': ['agent'],
|
|
19
19
|
'@bakers-build/addon-codex': ['agent'],
|
|
20
20
|
'@bakers-build/addon-grok': ['agent'],
|
|
@@ -25,6 +25,9 @@ export const CONDUCTOR_ADDON_SLOTS = {
|
|
|
25
25
|
'@bakers-build/addon-ports-cloudflare': [],
|
|
26
26
|
'@bakers-build/addon-ports-cloudflare-quick': [],
|
|
27
27
|
'@bakers-build/addon-ports-frp': [],
|
|
28
|
+
'@bakers-build/addon-forge': [],
|
|
29
|
+
'@bakers-build/addon-forge-github': [],
|
|
30
|
+
'@bakers-build/addon-forge-gitlab': [],
|
|
28
31
|
'@bakers-build/addon-bakers-ui': [],
|
|
29
32
|
'@bakers-build/addon-bakers-ui-artifacts': [],
|
|
30
33
|
'@bakers-build/addon-agents': [],
|
|
@@ -41,83 +44,31 @@ export const CONDUCTOR_ADDON_SLOTS = {
|
|
|
41
44
|
};
|
|
42
45
|
function validateConductorSources(options, editors, report) {
|
|
43
46
|
const recheck = configRecheckCommand((options.scope ?? 'all'), report.roots.project);
|
|
44
|
-
const
|
|
45
|
-
const localEditor = localFile ? editors.get(localFile.path) : undefined;
|
|
46
|
-
for (const file of report.files.filter((candidate) => candidate.selected && candidate.kind === 'conductor')) {
|
|
47
|
+
for (const file of report.files.filter((candidate) => candidate.selected && candidate.kind === 'project')) {
|
|
47
48
|
const editor = editors.get(file.path);
|
|
48
49
|
if (editor?.source.shape !== 'object')
|
|
49
50
|
continue;
|
|
50
51
|
const start = report.findings.length;
|
|
51
|
-
|
|
52
|
+
// Field shapes are the schema's; only what a schema cannot know is here:
|
|
53
|
+
// which slots the listed addons fill.
|
|
54
|
+
const add = (code, key, expected, property = editor.property(key)) => {
|
|
52
55
|
const unknown = code === 'unknown_value';
|
|
53
56
|
report.findings.push({
|
|
54
57
|
code,
|
|
55
58
|
severity: unknown ? 'warning' : 'error',
|
|
56
59
|
stage: 'schema',
|
|
57
|
-
path:
|
|
60
|
+
path: file.path,
|
|
58
61
|
key,
|
|
59
62
|
expected,
|
|
60
63
|
observed: unknown ? '[COMPUTED]' : (property?.value ?? null),
|
|
61
64
|
owner: 'project',
|
|
62
65
|
related: [],
|
|
63
66
|
statically_determined: property?.staticallyDetermined ?? false,
|
|
64
|
-
remediation: `${unknown ? 'Determine' : 'Set'} ${key} in ${shellQuote(
|
|
67
|
+
remediation: `${unknown ? 'Determine' : 'Set'} ${key} in ${shellQuote(file.path)}, then run ${recheck}.`,
|
|
65
68
|
recheck,
|
|
66
69
|
...(property ? { line: property.line, column: property.column } : {}),
|
|
67
70
|
});
|
|
68
71
|
};
|
|
69
|
-
for (const legacy of ['project', 'bb_workspace']) {
|
|
70
|
-
if (!editor.property(legacy))
|
|
71
|
-
continue;
|
|
72
|
-
add('misplaced_key', legacy, `Committed bakers.build identity belongs under bakers.${legacy === 'project' ? 'project' : 'workspace'}.`);
|
|
73
|
-
const finding = report.findings.at(-1);
|
|
74
|
-
if (finding)
|
|
75
|
-
finding.remediation = `Move ${legacy} to bakers.${legacy === 'project' ? 'project' : 'workspace'} in ${shellQuote(file.path)}, then run ${recheck}.`;
|
|
76
|
-
}
|
|
77
|
-
// A conductor is machine + project + variant: no project file names an id.
|
|
78
|
-
for (const [source, path] of [
|
|
79
|
-
[editor, file.path],
|
|
80
|
-
[localEditor, localFile?.path],
|
|
81
|
-
]) {
|
|
82
|
-
if (!source || !path)
|
|
83
|
-
continue;
|
|
84
|
-
for (const key of ['conductor_id', 'machine_id', 'label']) {
|
|
85
|
-
const property = source.property(key);
|
|
86
|
-
if (!property)
|
|
87
|
-
continue;
|
|
88
|
-
add('retired_key', key, 'No identity in a project config: a conductor is machine + project + variant.', property, path);
|
|
89
|
-
const finding = report.findings.at(-1);
|
|
90
|
-
if (finding)
|
|
91
|
-
finding.remediation = `Remove ${key} from ${shellQuote(path)}; the machine identity comes from bakers init.`;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
const bakers = editor.property('bakers');
|
|
95
|
-
const bakersExpression = editor.expression('bakers');
|
|
96
|
-
if (bakers &&
|
|
97
|
-
(bakers.nodeType !== 'ObjectExpression' ||
|
|
98
|
-
(bakersExpression &&
|
|
99
|
-
new ConfigSourceEditor(`export default ${bakersExpression};`).source
|
|
100
|
-
.unknownKeys))) {
|
|
101
|
-
add('unsupported_source_shape', 'bakers', 'A statically inspectable bakers object without spreads is required.');
|
|
102
|
-
const finding = report.findings.at(-1);
|
|
103
|
-
if (finding)
|
|
104
|
-
finding.remediation = `Write bakers as a literal object without spreads in ${shellQuote(file.path)}, then run ${recheck}.`;
|
|
105
|
-
}
|
|
106
|
-
const validateIdentity = (key) => {
|
|
107
|
-
const property = editor.property(key);
|
|
108
|
-
if (!property) {
|
|
109
|
-
add(editor.source.unknownKeys ? 'unknown_value' : 'missing_required_key', key, 'A nonempty conductor project.');
|
|
110
|
-
}
|
|
111
|
-
else if (property.staticallyDetermined &&
|
|
112
|
-
typeof property.value === 'string' &&
|
|
113
|
-
property.value.trim() !== '') {
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
add(property.staticallyDetermined ? 'invalid_value' : 'unknown_value', key, 'A nonempty conductor project.', property);
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
validateIdentity('bakers.project');
|
|
121
72
|
const addon = editor.property('addons');
|
|
122
73
|
const addonSlots = new Set();
|
|
123
74
|
let addonsAreOpaque = false;
|
|
@@ -141,57 +92,10 @@ function validateConductorSources(options, editors, report) {
|
|
|
141
92
|
}
|
|
142
93
|
}
|
|
143
94
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
// no agent slot or no agent-contributing addons is valid — machine.config.js
|
|
147
|
-
// provides the candidates at runtime. Existing pre-migration configs that
|
|
148
|
-
// still carry agent addons continue to validate until the conductor 0→1
|
|
149
|
-
// migration removes them.
|
|
150
|
-
for (const slot of ['remote', 'executor', 'workspace']) {
|
|
151
|
-
const property = editor.property(slot);
|
|
152
|
-
if (slot === 'workspace' &&
|
|
153
|
-
property?.staticallyDetermined &&
|
|
154
|
-
typeof property.value === 'string' &&
|
|
155
|
-
property.value.trim() !== '' &&
|
|
156
|
-
addonSlots.has('workspace'))
|
|
95
|
+
for (const slot of ['server', 'executor', 'worktree']) {
|
|
96
|
+
if (editor.property(slot) || addonSlots.has(slot))
|
|
157
97
|
continue;
|
|
158
|
-
|
|
159
|
-
if (addonSlots.has(slot))
|
|
160
|
-
continue;
|
|
161
|
-
add(addon && addonsAreOpaque ? 'unknown_value' : 'missing_required_key', slot, `A conductor ${slot} plugin supplied by an explicit slot or known addon.`);
|
|
162
|
-
continue;
|
|
163
|
-
}
|
|
164
|
-
if (!property.staticallyDetermined) {
|
|
165
|
-
add('unknown_value', slot, `A conductor ${slot} plugin supplied by an explicit slot or known addon.`, property);
|
|
166
|
-
continue;
|
|
167
|
-
}
|
|
168
|
-
const descriptor = (prefix, kind) => {
|
|
169
|
-
const plugin = editor.property(`${prefix}.plugin`)?.value;
|
|
170
|
-
return ((typeof plugin === 'string' && plugin.trim() !== '') ||
|
|
171
|
-
editor.property(`${prefix}.kind`)?.value === kind);
|
|
172
|
-
};
|
|
173
|
-
if (slot === 'agent' && property.nodeType === 'ArrayExpression') {
|
|
174
|
-
let unknownCandidate = false;
|
|
175
|
-
let invalidCandidate = (property.arrayLength ?? 0) === 0;
|
|
176
|
-
for (let index = 0; index < (property.arrayLength ?? 0); index++) {
|
|
177
|
-
const prefix = `agent[${index}]`;
|
|
178
|
-
const candidate = editor.property(prefix);
|
|
179
|
-
const wrapped = editor.property(`${prefix}.agent`);
|
|
180
|
-
if (!candidate?.staticallyDetermined ||
|
|
181
|
-
wrapped?.staticallyDetermined === false)
|
|
182
|
-
unknownCandidate = true;
|
|
183
|
-
else if (!descriptor(prefix, 'agent') &&
|
|
184
|
-
!descriptor(`${prefix}.agent`, 'agent'))
|
|
185
|
-
invalidCandidate = true;
|
|
186
|
-
}
|
|
187
|
-
if (unknownCandidate)
|
|
188
|
-
add('unknown_value', slot, `A conductor ${slot} plugin supplied by an explicit slot or known addon.`, property);
|
|
189
|
-
else if (invalidCandidate)
|
|
190
|
-
add('invalid_value', slot, `A conductor ${slot} plugin supplied by an explicit slot or known addon.`, property);
|
|
191
|
-
continue;
|
|
192
|
-
}
|
|
193
|
-
if (property.nodeType !== 'ObjectExpression' || !descriptor(slot, slot))
|
|
194
|
-
add('invalid_value', slot, `A conductor ${slot} plugin supplied by an explicit slot or known addon.`, property);
|
|
98
|
+
add(addon && addonsAreOpaque ? 'unknown_value' : 'missing_required_key', slot, `A ${slot} supplied by an explicit slot or a listed addon.`);
|
|
195
99
|
}
|
|
196
100
|
const findings = report.findings.slice(start);
|
|
197
101
|
if (findings.some((finding) => finding.severity === 'error'))
|
|
@@ -207,21 +111,13 @@ export function validateConfigSources(options, texts, files) {
|
|
|
207
111
|
.map(([path, text]) => [path, new ConfigSourceEditor(text)]));
|
|
208
112
|
const resolved = new Set();
|
|
209
113
|
const global = files.find((f) => f.kind === 'connection');
|
|
210
|
-
const local = files.find((f) => f.kind === 'local');
|
|
211
114
|
const globalEditor = global ? editors.get(global.path) : undefined;
|
|
212
|
-
const localEditor = local ? editors.get(local.path) : undefined;
|
|
213
115
|
const primitive = (e, key) => {
|
|
214
116
|
const p = e?.property(key);
|
|
215
117
|
return p?.staticallyDetermined && p.value !== undefined
|
|
216
118
|
? JSON.stringify(p.value)
|
|
217
119
|
: undefined;
|
|
218
120
|
};
|
|
219
|
-
const fallback = (localKey, defaultExpression) => {
|
|
220
|
-
const p = localEditor?.property(localKey);
|
|
221
|
-
if (!p || (p.staticallyDetermined && p.value === null))
|
|
222
|
-
return defaultExpression;
|
|
223
|
-
return primitive(localEditor, localKey);
|
|
224
|
-
};
|
|
225
121
|
let inherits = false;
|
|
226
122
|
for (const file of files) {
|
|
227
123
|
const e = editors.get(file.path);
|
|
@@ -247,12 +143,14 @@ export function validateConfigSources(options, texts, files) {
|
|
|
247
143
|
p.value === '@dropsh/plugin-oauth2')?.[0]
|
|
248
144
|
.replace(/\.plugin$/, '');
|
|
249
145
|
const values = {
|
|
250
|
-
baseUrl:
|
|
251
|
-
workspaceId:
|
|
252
|
-
clientId:
|
|
253
|
-
|
|
146
|
+
baseUrl: primitive(globalEditor, 'site.base_url'),
|
|
147
|
+
workspaceId: primitive(globalEditor, 'workspace_id'),
|
|
148
|
+
clientId: auth
|
|
149
|
+
? primitive(globalEditor, `${auth}.with.client_id`)
|
|
150
|
+
: undefined,
|
|
151
|
+
clientSecret: auth
|
|
254
152
|
? primitive(globalEditor, `${auth}.with.client_secret`)
|
|
255
|
-
: undefined
|
|
153
|
+
: undefined,
|
|
256
154
|
};
|
|
257
155
|
for (const [name, value] of Object.entries(values))
|
|
258
156
|
if (value !== undefined)
|
|
@@ -289,9 +187,7 @@ export function validateConfigSources(options, texts, files) {
|
|
|
289
187
|
}
|
|
290
188
|
for (const key of [...e.source.properties.keys()]) {
|
|
291
189
|
const expression = e.expression(key);
|
|
292
|
-
|
|
293
|
-
if (expression === 'local.oauth?.client_secret')
|
|
294
|
-
value = primitive(localEditor, 'oauth.client_secret');
|
|
190
|
+
const value = expression ? declarations.get(expression) : undefined;
|
|
295
191
|
if (value !== undefined) {
|
|
296
192
|
e.set(key, value);
|
|
297
193
|
resolved.add(`${file.path}:${key}`);
|
|
@@ -303,7 +199,7 @@ export function validateConfigSources(options, texts, files) {
|
|
|
303
199
|
overlay.set(path, e.text);
|
|
304
200
|
const report = inventoryConfig({ ...options, sourceTexts: overlay }).report;
|
|
305
201
|
validateConductorSources(options, editors, report);
|
|
306
|
-
// Literal values resolved from
|
|
202
|
+
// Literal values resolved from generated wiring are not secrets stored in the committed file.
|
|
307
203
|
report.findings = report.findings.filter((f) => !(f.code === 'misplaced_key' &&
|
|
308
204
|
f.key?.endsWith('client_secret') &&
|
|
309
205
|
resolved.has(`${f.path}:${f.key}`)));
|
|
@@ -7,15 +7,12 @@ export interface BbProjectSelection {
|
|
|
7
7
|
workspace?: string;
|
|
8
8
|
}
|
|
9
9
|
export type BbProjectOwner = BbWorkspaceOwner;
|
|
10
|
-
/**
|
|
11
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Read the committed `project: { name, workspace }` without executing the
|
|
12
|
+
* file. `BAKERS_PROJECT` overrides the name for this process.
|
|
13
|
+
*/
|
|
14
|
+
export declare function readBbProjectSelection(path: string, env?: NodeJS.ProcessEnv): BbProjectSelection;
|
|
12
15
|
/** Establish the exact file that can receive a nested workspace choice. */
|
|
13
16
|
export declare function bakersProjectOwner(path: string): BbProjectOwner;
|
|
14
|
-
/** Read the committed project name without executing engine config. */
|
|
15
|
-
export declare function readProjectSelection(path: string): string | undefined;
|
|
16
|
-
/** Read the committed product-workspace name without executing engine config. */
|
|
17
|
-
export declare function readBbWorkspaceSelection(path: string): string | undefined;
|
|
18
|
-
/** Establish the conductor-owned source that the cockpit may update. */
|
|
19
|
-
export declare function bakersWorkspaceOwner(path: string): BbWorkspaceOwner;
|
|
20
17
|
/** Atomically update only the product-workspace field, preserving plugin slots. */
|
|
21
18
|
export declare function writeBbWorkspaceSelection(owner: BbWorkspaceOwner, selected: string, hint: string): Promise<void>;
|
|
@@ -1,91 +1,48 @@
|
|
|
1
1
|
import { existsSync, readFileSync, renameSync, statSync, unlinkSync, writeFileSync, } from 'node:fs';
|
|
2
2
|
import { basename } from 'node:path';
|
|
3
|
+
import { stemForConfigFile } from '@bakers-build/core';
|
|
3
4
|
import { ConfigSourceEditor } from './config-source-edit.js';
|
|
4
|
-
/**
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Read the committed `project: { name, workspace }` without executing the
|
|
7
|
+
* file. `BAKERS_PROJECT` overrides the name for this process.
|
|
8
|
+
*/
|
|
9
|
+
export function readBbProjectSelection(path, env = process.env) {
|
|
6
10
|
const editor = new ConfigSourceEditor(readFileSync(path, 'utf8'));
|
|
7
|
-
const invalid = () => new Error(`Cannot read committed
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
? new ConfigSourceEditor(`export default ${
|
|
11
|
+
const invalid = () => new Error(`Cannot read the committed project in ${path}; set project: { name: '<name>' } as a literal object without spreads.`);
|
|
12
|
+
const block = editor.property('project');
|
|
13
|
+
const blockExpression = editor.expression('project');
|
|
14
|
+
const hasSpread = blockExpression
|
|
15
|
+
? new ConfigSourceEditor(`export default ${blockExpression};`).source
|
|
12
16
|
.unknownKeys
|
|
13
17
|
: false;
|
|
14
|
-
const
|
|
15
|
-
const
|
|
18
|
+
const override = env.BAKERS_PROJECT?.trim();
|
|
19
|
+
const name = editor.property('project.name');
|
|
20
|
+
const workspace = editor.property('project.workspace');
|
|
21
|
+
const literal = (p) => p?.staticallyDetermined &&
|
|
22
|
+
typeof p.value === 'string' &&
|
|
23
|
+
p.value.trim() !== '';
|
|
16
24
|
if (editor.source.shape !== 'object' ||
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
!project?.staticallyDetermined ||
|
|
22
|
-
typeof project.value !== 'string' ||
|
|
23
|
-
!project.value.trim() ||
|
|
24
|
-
(workspace !== undefined &&
|
|
25
|
-
(!workspace.staticallyDetermined ||
|
|
26
|
-
typeof workspace.value !== 'string' ||
|
|
27
|
-
!workspace.value.trim())))
|
|
25
|
+
hasSpread ||
|
|
26
|
+
block?.nodeType !== 'ObjectExpression' ||
|
|
27
|
+
(!override && !literal(name)) ||
|
|
28
|
+
(workspace !== undefined && !literal(workspace)))
|
|
28
29
|
throw invalid();
|
|
29
30
|
return {
|
|
30
|
-
project:
|
|
31
|
+
project: override || String(name?.value).trim(),
|
|
31
32
|
...(workspace ? { workspace: workspace.value.trim() } : {}),
|
|
32
33
|
};
|
|
33
34
|
}
|
|
34
35
|
/** Establish the exact file that can receive a nested workspace choice. */
|
|
35
36
|
export function bakersProjectOwner(path) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
throw new Error(`Cannot write bakers.build workspace selection to ${path}.`);
|
|
37
|
+
if (stemForConfigFile(basename(path)) === undefined)
|
|
38
|
+
throw new Error(`Cannot write bakers.build workspace selection to ${path}; expected project.config.js or a project.<name>.config.js variant. No configuration was written.`);
|
|
39
39
|
readBbProjectSelection(path);
|
|
40
40
|
return { path, before: readFileSync(path, 'utf8') };
|
|
41
41
|
}
|
|
42
|
-
/** Read the committed project name without executing engine config. */
|
|
43
|
-
export function readProjectSelection(path) {
|
|
44
|
-
try {
|
|
45
|
-
const property = new ConfigSourceEditor(readFileSync(path, 'utf8')).property('project');
|
|
46
|
-
return property?.staticallyDetermined &&
|
|
47
|
-
typeof property.value === 'string' &&
|
|
48
|
-
property.value.trim() !== ''
|
|
49
|
-
? property.value.trim()
|
|
50
|
-
: undefined;
|
|
51
|
-
}
|
|
52
|
-
catch {
|
|
53
|
-
return undefined;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
/** Read the committed product-workspace name without executing engine config. */
|
|
57
|
-
export function readBbWorkspaceSelection(path) {
|
|
58
|
-
try {
|
|
59
|
-
const property = new ConfigSourceEditor(readFileSync(path, 'utf8')).property('bb_workspace');
|
|
60
|
-
return property?.staticallyDetermined &&
|
|
61
|
-
typeof property.value === 'string' &&
|
|
62
|
-
property.value.trim() !== ''
|
|
63
|
-
? property.value.trim()
|
|
64
|
-
: undefined;
|
|
65
|
-
}
|
|
66
|
-
catch {
|
|
67
|
-
return undefined;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
/** Establish the conductor-owned source that the cockpit may update. */
|
|
71
|
-
export function bakersWorkspaceOwner(path) {
|
|
72
|
-
const file = basename(path);
|
|
73
|
-
if (file !== 'conductor.config.js' && !file.endsWith('.conductor.config.js'))
|
|
74
|
-
throw new Error(`Cannot write bakers.build workspace selection to ${path}; expected conductor.config.js or a named conductor variant. No configuration was written.`);
|
|
75
|
-
const before = readFileSync(path, 'utf8');
|
|
76
|
-
const editor = new ConfigSourceEditor(before);
|
|
77
|
-
const property = editor.property('bb_workspace');
|
|
78
|
-
if (editor.source.shape === 'object' &&
|
|
79
|
-
!editor.source.unknownKeys &&
|
|
80
|
-
(!property ||
|
|
81
|
-
(property.staticallyDetermined && typeof property.value === 'string')))
|
|
82
|
-
return { path, before };
|
|
83
|
-
throw new Error(`Cannot establish a literal writable bb_workspace in ${path}. No configuration was written.`);
|
|
84
|
-
}
|
|
85
42
|
/** Atomically update only the product-workspace field, preserving plugin slots. */
|
|
86
43
|
export async function writeBbWorkspaceSelection(owner, selected, hint) {
|
|
87
44
|
const editor = new ConfigSourceEditor(owner.before);
|
|
88
|
-
editor.set(
|
|
45
|
+
editor.set('project.workspace', JSON.stringify(selected));
|
|
89
46
|
if ((existsSync(owner.path) ? readFileSync(owner.path, 'utf8') : null) !==
|
|
90
47
|
owner.before)
|
|
91
48
|
throw new Error(`Configuration changed while choosing; recheck ${owner.path} before retrying. No configuration was written.`);
|