@bakers-build/core 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/bakers-dir.d.ts +8 -8
- package/dist/src/cli/bakers-dir.js +30 -33
- package/dist/src/cli/config-inventory.d.ts +2 -0
- package/dist/src/cli/config-inventory.js +45 -72
- package/dist/src/cli/config-report.d.ts +2 -2
- package/dist/src/cli/config-source.js +1 -1
- package/dist/src/cli/config-validate.d.ts +49 -0
- package/dist/src/cli/config-validate.js +400 -0
- package/dist/src/cli/import-config.d.ts +2 -2
- package/dist/src/cli/import-config.js +5 -5
- package/dist/src/cli/load-bakers-config.d.ts +2 -2
- package/dist/src/cli/load-bakers-config.js +20 -49
- package/dist/src/cli/machine-connection.d.ts +2 -0
- package/dist/src/cli/machine-connection.js +47 -0
- package/dist/src/cli/machine-context.d.ts +9 -12
- package/dist/src/cli/machine-context.js +12 -18
- package/dist/src/cli/version-check.d.ts +1 -1
- package/dist/src/cli/version-check.js +1 -1
- package/dist/src/config-types.generated.d.ts +175 -0
- package/dist/src/config-types.generated.js +3 -0
- package/dist/src/core/logger.d.ts +3 -3
- package/dist/src/core/logger.js +5 -5
- package/dist/src/core/proc.d.ts +1 -1
- package/dist/src/core/proc.js +8 -5
- package/dist/src/index.d.ts +4 -1
- package/dist/src/index.js +3 -3
- package/dist/src/plugins/discover-addons.d.ts +2 -2
- package/dist/src/plugins/discover-addons.js +9 -9
- package/dist/src/plugins/preset.d.ts +9 -20
- package/dist/src/plugins/preset.js +6 -6
- package/dist/src/plugins/scoped-addons.d.ts +5 -14
- package/dist/src/plugins/scoped-addons.js +11 -36
- package/package.json +6 -4
- package/schema/connection.schema.json +57 -0
- package/schema/harness-options.schema.json +78 -0
- package/schema/machine.schema.json +81 -0
- package/schema/project.schema.json +262 -0
|
@@ -4,14 +4,13 @@ export interface MachineAgentEntry {
|
|
|
4
4
|
alias?: string;
|
|
5
5
|
with?: unknown;
|
|
6
6
|
}
|
|
7
|
-
/**
|
|
7
|
+
/** Named state-to-agent routes. `default` is the automatic route; `'*'` matches any state. */
|
|
8
8
|
export type AgentRoutes = Record<string, Record<string, string>>;
|
|
9
9
|
/** Optional host-local overlays and selection policy for addon-derived agents. */
|
|
10
10
|
export interface MachineAgentPolicy {
|
|
11
11
|
catalog?: MachineAgentEntry[];
|
|
12
12
|
enabled?: string[];
|
|
13
13
|
disabled?: string[];
|
|
14
|
-
default_agent?: string;
|
|
15
14
|
routes?: AgentRoutes;
|
|
16
15
|
}
|
|
17
16
|
/** Local host identity, display label and shared capacity. */
|
|
@@ -20,6 +19,7 @@ export interface MachineContext {
|
|
|
20
19
|
machine_id: string;
|
|
21
20
|
/** Display name for people; never a key. */
|
|
22
21
|
label: string;
|
|
22
|
+
connection_url?: string | null;
|
|
23
23
|
/** Optional selection policy for the agents the machine `addons[]` contribute. */
|
|
24
24
|
agents?: MachineAgentPolicy;
|
|
25
25
|
/**
|
|
@@ -45,25 +45,22 @@ export interface MachineContext {
|
|
|
45
45
|
*/
|
|
46
46
|
executor?: unknown;
|
|
47
47
|
}
|
|
48
|
-
/**
|
|
49
|
-
* Warn once that a leftover `max_parallel` in a config file is ignored: the
|
|
50
|
-
* run budget is set on the machine in the backend.
|
|
51
|
-
*/
|
|
52
|
-
export declare function warnIgnoredMaxParallel(path: string, raw: object): void;
|
|
53
|
-
/** Canonical machine-context path: `<BB_HOME or ~/.bakers>/machine.config.js`. */
|
|
48
|
+
/** Canonical machine-context path: `<BAKERS_HOME or ~/.bakers>/machine.config.js`. */
|
|
54
49
|
export declare function machineContextPath(): string;
|
|
55
50
|
/** Resolve explicit or canonical current host context. */
|
|
56
51
|
export declare function resolveMachineContextPath(path?: string): string;
|
|
52
|
+
/** The configuration schema version every file kind is at. */
|
|
53
|
+
export declare const CONFIG_SCHEMA_VERSION = 1;
|
|
57
54
|
/**
|
|
58
55
|
* Every config file (machine, connection, project) is at schema version 1.
|
|
59
56
|
* Any other version, in the `schema_version` field or the
|
|
60
|
-
* `@bakers-schema-version` header,
|
|
57
|
+
* `@bakers-schema-version` header, is refused.
|
|
61
58
|
*/
|
|
62
|
-
export declare function
|
|
59
|
+
export declare function assertSchemaVersion(path: string, raw: Record<string, unknown>): void;
|
|
63
60
|
/**
|
|
64
61
|
* Import an existing context module's default export, or `{}` if absent/broken.
|
|
65
|
-
*
|
|
66
|
-
*
|
|
62
|
+
* A file at another schema version, or one the machine schema rejects,
|
|
63
|
+
* throws naming the file and every problem. An existing machine keeps its
|
|
67
64
|
* `machine_id` as it is; only a UUID is normalised to lowercase.
|
|
68
65
|
*/
|
|
69
66
|
export declare function readMachineContext(path?: string): Promise<Partial<MachineContext>>;
|
|
@@ -2,15 +2,8 @@ import { existsSync, readFileSync } from 'node:fs';
|
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { pathToFileURL } from 'node:url';
|
|
4
4
|
import { homeBbDir } from './bakers-dir.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* run budget is set on the machine in the backend.
|
|
8
|
-
*/
|
|
9
|
-
export function warnIgnoredMaxParallel(path, raw) {
|
|
10
|
-
if ('max_parallel' in raw)
|
|
11
|
-
console.warn(`warning: max_parallel in ${path} is ignored; the run budget is set on the machine in the backend.`);
|
|
12
|
-
}
|
|
13
|
-
/** Canonical machine-context path: `<BB_HOME or ~/.bakers>/machine.config.js`. */
|
|
5
|
+
import { assertValidConfig } from './config-validate.js';
|
|
6
|
+
/** Canonical machine-context path: `<BAKERS_HOME or ~/.bakers>/machine.config.js`. */
|
|
14
7
|
export function machineContextPath() {
|
|
15
8
|
return join(homeBbDir(), 'machine.config.js');
|
|
16
9
|
}
|
|
@@ -25,12 +18,14 @@ const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
|
25
18
|
function isUuid(value) {
|
|
26
19
|
return typeof value === 'string' && UUID.test(value);
|
|
27
20
|
}
|
|
21
|
+
/** The configuration schema version every file kind is at. */
|
|
22
|
+
export const CONFIG_SCHEMA_VERSION = 1;
|
|
28
23
|
/**
|
|
29
24
|
* Every config file (machine, connection, project) is at schema version 1.
|
|
30
25
|
* Any other version, in the `schema_version` field or the
|
|
31
|
-
* `@bakers-schema-version` header,
|
|
26
|
+
* `@bakers-schema-version` header, is refused.
|
|
32
27
|
*/
|
|
33
|
-
export function
|
|
28
|
+
export function assertSchemaVersion(path, raw) {
|
|
34
29
|
let text = '';
|
|
35
30
|
try {
|
|
36
31
|
text = readFileSync(path, 'utf8');
|
|
@@ -40,14 +35,14 @@ export function assertSchemaVersion1(path, raw, remedy = 'remove the file and ru
|
|
|
40
35
|
...(raw.schema_version !== undefined ? [raw.schema_version] : []),
|
|
41
36
|
...[...text.matchAll(/@bakers-schema-version\s+(\d+)/g)].map((m) => Number(m[1])),
|
|
42
37
|
];
|
|
43
|
-
const other = versions.find((version) => version !==
|
|
38
|
+
const other = versions.find((version) => version !== CONFIG_SCHEMA_VERSION);
|
|
44
39
|
if (other !== undefined)
|
|
45
|
-
throw new Error(`${path}: schema version ${String(other)} is not supported;
|
|
40
|
+
throw new Error(`${path}: schema version ${String(other)} is not supported; remove the file and run bakers init`);
|
|
46
41
|
}
|
|
47
42
|
/**
|
|
48
43
|
* Import an existing context module's default export, or `{}` if absent/broken.
|
|
49
|
-
*
|
|
50
|
-
*
|
|
44
|
+
* A file at another schema version, or one the machine schema rejects,
|
|
45
|
+
* throws naming the file and every problem. An existing machine keeps its
|
|
51
46
|
* `machine_id` as it is; only a UUID is normalised to lowercase.
|
|
52
47
|
*/
|
|
53
48
|
export async function readMachineContext(path) {
|
|
@@ -66,9 +61,8 @@ export async function readMachineContext(path) {
|
|
|
66
61
|
if (!raw || typeof raw !== 'object')
|
|
67
62
|
return {};
|
|
68
63
|
const ctx = raw;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
throw new Error(`${resolved}: user_id is retired (the server takes the owner from sign-in); run bakers init to rewrite the file`);
|
|
64
|
+
assertSchemaVersion(resolved, ctx);
|
|
65
|
+
assertValidConfig('machine', ctx, resolved);
|
|
72
66
|
return {
|
|
73
67
|
...ctx,
|
|
74
68
|
...(isUuid(ctx.machine_id)
|
|
@@ -5,7 +5,7 @@ export declare const UNKNOWN_VERSION = "0.0.0";
|
|
|
5
5
|
export declare const UPDATE_CHECK_TTL_MS: number;
|
|
6
6
|
/**
|
|
7
7
|
* A module-level const would freeze the answer at import time, before a test
|
|
8
|
-
* (or a container) sets
|
|
8
|
+
* (or a container) sets BAKERS_HOME — so this is a function, resolved through
|
|
9
9
|
* the one place that decides where `.bakers` lives.
|
|
10
10
|
*/
|
|
11
11
|
export declare function defaultUpdateCachePath(): string;
|
|
@@ -10,7 +10,7 @@ export const UNKNOWN_VERSION = '0.0.0';
|
|
|
10
10
|
export const UPDATE_CHECK_TTL_MS = 24 * 60 * 60 * 1000;
|
|
11
11
|
/**
|
|
12
12
|
* A module-level const would freeze the answer at import time, before a test
|
|
13
|
-
* (or a container) sets
|
|
13
|
+
* (or a container) sets BAKERS_HOME — so this is a function, resolved through
|
|
14
14
|
* the one place that decides where `.bakers` lives.
|
|
15
15
|
*/
|
|
16
16
|
export function defaultUpdateCachePath() {
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/** A project's committed conductor configuration: .bakers/project.config.js and its variants .bakers/project.<name>.config.js. */
|
|
2
|
+
export interface ProjectConfig {
|
|
3
|
+
/** Configuration schema version. */
|
|
4
|
+
schema_version?: 1;
|
|
5
|
+
/** The bakers.build project this repository belongs to. */
|
|
6
|
+
project: {
|
|
7
|
+
/** Project name on the server; BAKERS_PROJECT overrides it. */
|
|
8
|
+
name: string;
|
|
9
|
+
/** Team workspace the project belongs to. */
|
|
10
|
+
workspace?: string;
|
|
11
|
+
};
|
|
12
|
+
permissions?: {
|
|
13
|
+
mode?: "sandbox" | "system" | "yolo";
|
|
14
|
+
sandbox?: {
|
|
15
|
+
deny_read?: Array<string>;
|
|
16
|
+
allow_write?: Array<string>;
|
|
17
|
+
trusted_commands?: Array<string>;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
/** Addons this project uses. */
|
|
21
|
+
addons?: Array<string | {
|
|
22
|
+
use: string;
|
|
23
|
+
alias?: string;
|
|
24
|
+
/** The addon's options. */
|
|
25
|
+
with?: unknown;
|
|
26
|
+
priority?: (...args: never[]) => unknown;
|
|
27
|
+
}>;
|
|
28
|
+
/** Explicit server slot; wins over an addon's. */
|
|
29
|
+
server?: {
|
|
30
|
+
kind: string;
|
|
31
|
+
[key: string]: unknown;
|
|
32
|
+
} | {
|
|
33
|
+
use: string;
|
|
34
|
+
export?: string;
|
|
35
|
+
/** Options passed to the factory. */
|
|
36
|
+
with?: unknown;
|
|
37
|
+
};
|
|
38
|
+
/** Explicit executor slot; the machine's wins over it. */
|
|
39
|
+
executor?: {
|
|
40
|
+
kind: string;
|
|
41
|
+
[key: string]: unknown;
|
|
42
|
+
} | {
|
|
43
|
+
use: string;
|
|
44
|
+
export?: string;
|
|
45
|
+
/** Options passed to the factory. */
|
|
46
|
+
with?: unknown;
|
|
47
|
+
};
|
|
48
|
+
/** Explicit worktree slot; wins over an addon's. */
|
|
49
|
+
worktree?: {
|
|
50
|
+
kind: string;
|
|
51
|
+
[key: string]: unknown;
|
|
52
|
+
} | {
|
|
53
|
+
use: string;
|
|
54
|
+
export?: string;
|
|
55
|
+
/** Options passed to the factory. */
|
|
56
|
+
with?: unknown;
|
|
57
|
+
};
|
|
58
|
+
/** States this conductor serves; empty or absent serves all. */
|
|
59
|
+
states?: Array<string>;
|
|
60
|
+
/** Agent prompt; placeholders {identifier}, {state}, {run_uuid}, {ticket_uuid}. */
|
|
61
|
+
prompt?: string;
|
|
62
|
+
/** Poll interval in milliseconds. Default 5000. */
|
|
63
|
+
poll_interval_ms?: number;
|
|
64
|
+
/** Run lease in seconds. Default 300. */
|
|
65
|
+
lease_seconds?: number;
|
|
66
|
+
/** Restart the foreground conductor when a config file changes. Default true. */
|
|
67
|
+
restart_on_change?: boolean;
|
|
68
|
+
/** Upload transcripts where the server allows it. Default true. */
|
|
69
|
+
capture_logs?: boolean;
|
|
70
|
+
/** Shell commands the conductor runs in a ticket's worktree. */
|
|
71
|
+
hooks?: {
|
|
72
|
+
after_create?: string;
|
|
73
|
+
before_run?: string;
|
|
74
|
+
after_run?: string;
|
|
75
|
+
after_done?: string;
|
|
76
|
+
on_freeze?: string;
|
|
77
|
+
on_resume?: string;
|
|
78
|
+
/** Command, or commands by profile, offered to runs as provision_up(profile?). */
|
|
79
|
+
provision_up?: string | {
|
|
80
|
+
[key: string]: string;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
/** Agent plugin marketplaces every run of this project installs. */
|
|
84
|
+
marketplaces?: Array<{
|
|
85
|
+
/** a remote Git URL (https, ssh or git@) */
|
|
86
|
+
url: string;
|
|
87
|
+
/** Branch or tag. */
|
|
88
|
+
ref: string;
|
|
89
|
+
plugins: Array<string>;
|
|
90
|
+
}>;
|
|
91
|
+
/** Function choosing the agent for a ticket; replaces the shipped selection. */
|
|
92
|
+
select_agent?: (...args: never[]) => unknown;
|
|
93
|
+
}
|
|
94
|
+
/** This machine's private configuration: ~/.bakers/machine.config.js. */
|
|
95
|
+
export interface MachineConfig {
|
|
96
|
+
/** Configuration schema version. */
|
|
97
|
+
schema_version?: 1;
|
|
98
|
+
/** Host key; bakers init writes a UUID. */
|
|
99
|
+
machine_id: string;
|
|
100
|
+
/** Display name for people. */
|
|
101
|
+
label: string;
|
|
102
|
+
/** Public SSH or HTTPS connection address; null clears it at the next conductor start. */
|
|
103
|
+
connection_url?: string | null;
|
|
104
|
+
/** Selection policy for the agents the addons contribute. */
|
|
105
|
+
agents?: {
|
|
106
|
+
/** Extra agent variants built from installed harnesses. */
|
|
107
|
+
catalog?: Array<{
|
|
108
|
+
harness: string;
|
|
109
|
+
alias?: string;
|
|
110
|
+
/** The harness options. */
|
|
111
|
+
with?: unknown;
|
|
112
|
+
}>;
|
|
113
|
+
enabled?: Array<string>;
|
|
114
|
+
disabled?: Array<string>;
|
|
115
|
+
/** Named routes from states (or *) to aliases; routes.default is the automatic one. */
|
|
116
|
+
routes?: {
|
|
117
|
+
[key: string]: {
|
|
118
|
+
[key: string]: string;
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
/** Addons this machine uses. */
|
|
123
|
+
addons?: Array<string | {
|
|
124
|
+
use: string;
|
|
125
|
+
alias?: string;
|
|
126
|
+
/** The addon's options. */
|
|
127
|
+
with?: unknown;
|
|
128
|
+
priority?: (...args: never[]) => unknown;
|
|
129
|
+
}>;
|
|
130
|
+
/** Share local preview links through bakers ports. Default false. */
|
|
131
|
+
tunnel?: boolean;
|
|
132
|
+
permissions?: {
|
|
133
|
+
mode?: "sandbox" | "system" | "yolo";
|
|
134
|
+
sandbox?: {
|
|
135
|
+
deny_read?: Array<string>;
|
|
136
|
+
allow_write?: Array<string>;
|
|
137
|
+
trusted_commands?: Array<string>;
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
/** This machine's executor; overrides every project's. */
|
|
141
|
+
executor?: {
|
|
142
|
+
kind: string;
|
|
143
|
+
[key: string]: unknown;
|
|
144
|
+
} | {
|
|
145
|
+
use: string;
|
|
146
|
+
export?: string;
|
|
147
|
+
/** Options passed to the factory. */
|
|
148
|
+
with?: unknown;
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
/** A connection to a bakers.build server: ~/.bakers/connections/<id>.js, or a project's .bakers/connection.config.js. dropsh reads the same file. */
|
|
152
|
+
export interface ConnectionConfig {
|
|
153
|
+
/** Configuration schema version. */
|
|
154
|
+
schema_version?: 1;
|
|
155
|
+
site: {
|
|
156
|
+
/** The server's absolute HTTP(S) URL. */
|
|
157
|
+
base_url: string;
|
|
158
|
+
/** JSON:API path prefix. Default /jsonapi. */
|
|
159
|
+
jsonapi_prefix?: string;
|
|
160
|
+
};
|
|
161
|
+
/** Workspace bakers ui starts focused on. */
|
|
162
|
+
workspace_id?: string;
|
|
163
|
+
/** dropsh plugins: { plugin, export?, with?, options? }, or constructed plugins. */
|
|
164
|
+
plugins?: Array<unknown | {
|
|
165
|
+
[key: string]: unknown;
|
|
166
|
+
}>;
|
|
167
|
+
/** Connection addons, such as auth providers. */
|
|
168
|
+
addons?: Array<string | {
|
|
169
|
+
use: string;
|
|
170
|
+
alias?: string;
|
|
171
|
+
/** The addon's options. */
|
|
172
|
+
with?: unknown;
|
|
173
|
+
priority?: (...args: never[]) => unknown;
|
|
174
|
+
}>;
|
|
175
|
+
}
|
|
@@ -20,7 +20,7 @@ export interface ConductorLogger {
|
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
22
|
* Pick the log sink. Precedence: explicit CLI override (`sink`) > the
|
|
23
|
-
*
|
|
23
|
+
* BAKERS_CONDUCTOR_LOG env var > default (`both` on a TTY, `file` otherwise).
|
|
24
24
|
*
|
|
25
25
|
* BB-237: the TTY default used to be stdout-ONLY, which made the conductor's
|
|
26
26
|
* own diagnostics non-durable exactly where it normally runs — inside a herdr
|
|
@@ -28,7 +28,7 @@ export interface ConductorLogger {
|
|
|
28
28
|
* worktree + ticket + err) was therefore written nowhere and died with the pane,
|
|
29
29
|
* so an aborting worktree bootstrap left no trace to find. The default now tees:
|
|
30
30
|
* the operator keeps pretty stdout AND the record lands in `log.txt`. An
|
|
31
|
-
* EXPLICIT `stdout` / `file` (CLI flag or
|
|
31
|
+
* EXPLICIT `stdout` / `file` (CLI flag or BAKERS_CONDUCTOR_LOG) keeps its exact
|
|
32
32
|
* previous meaning — one stream, chosen deliberately.
|
|
33
33
|
*
|
|
34
34
|
* BB-450 D4: `checkoutRoot` is now genuinely the checkout root (its `.bakers`
|
|
@@ -40,7 +40,7 @@ export interface ConductorLogger {
|
|
|
40
40
|
export declare function resolveSink(env: NodeJS.ProcessEnv, isTTY: boolean, checkoutRoot: string, override?: string): LogSink;
|
|
41
41
|
/**
|
|
42
42
|
* Pick the log level. Precedence: explicit CLI override (`level`) >
|
|
43
|
-
* the
|
|
43
|
+
* the BAKERS_LOG_LEVEL env var > info.
|
|
44
44
|
*/
|
|
45
45
|
export declare function resolveLevel(env: NodeJS.ProcessEnv, override?: string): string;
|
|
46
46
|
export declare function createLogger(opts: {
|
package/dist/src/core/logger.js
CHANGED
|
@@ -5,7 +5,7 @@ import { resolveCliVersion } from '../cli/version-check.js';
|
|
|
5
5
|
import { configHomeOf } from './checkout-root.js';
|
|
6
6
|
/**
|
|
7
7
|
* Pick the log sink. Precedence: explicit CLI override (`sink`) > the
|
|
8
|
-
*
|
|
8
|
+
* BAKERS_CONDUCTOR_LOG env var > default (`both` on a TTY, `file` otherwise).
|
|
9
9
|
*
|
|
10
10
|
* BB-237: the TTY default used to be stdout-ONLY, which made the conductor's
|
|
11
11
|
* own diagnostics non-durable exactly where it normally runs — inside a herdr
|
|
@@ -13,7 +13,7 @@ import { configHomeOf } from './checkout-root.js';
|
|
|
13
13
|
* worktree + ticket + err) was therefore written nowhere and died with the pane,
|
|
14
14
|
* so an aborting worktree bootstrap left no trace to find. The default now tees:
|
|
15
15
|
* the operator keeps pretty stdout AND the record lands in `log.txt`. An
|
|
16
|
-
* EXPLICIT `stdout` / `file` (CLI flag or
|
|
16
|
+
* EXPLICIT `stdout` / `file` (CLI flag or BAKERS_CONDUCTOR_LOG) keeps its exact
|
|
17
17
|
* previous meaning — one stream, chosen deliberately.
|
|
18
18
|
*
|
|
19
19
|
* BB-450 D4: `checkoutRoot` is now genuinely the checkout root (its `.bakers`
|
|
@@ -24,7 +24,7 @@ import { configHomeOf } from './checkout-root.js';
|
|
|
24
24
|
*/
|
|
25
25
|
export function resolveSink(env, isTTY, checkoutRoot, override) {
|
|
26
26
|
const path = join(configHomeOf(checkoutRoot), 'log.txt');
|
|
27
|
-
const choice = override ?? env.
|
|
27
|
+
const choice = override ?? env.BAKERS_CONDUCTOR_LOG;
|
|
28
28
|
if (choice === 'stdout')
|
|
29
29
|
return { kind: 'stdout' };
|
|
30
30
|
if (choice === 'file')
|
|
@@ -35,10 +35,10 @@ export function resolveSink(env, isTTY, checkoutRoot, override) {
|
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
37
|
* Pick the log level. Precedence: explicit CLI override (`level`) >
|
|
38
|
-
* the
|
|
38
|
+
* the BAKERS_LOG_LEVEL env var > info.
|
|
39
39
|
*/
|
|
40
40
|
export function resolveLevel(env, override) {
|
|
41
|
-
return override ?? env.
|
|
41
|
+
return override ?? env.BAKERS_LOG_LEVEL ?? 'info';
|
|
42
42
|
}
|
|
43
43
|
export function createLogger(opts) {
|
|
44
44
|
const env = opts.env ?? process.env;
|
package/dist/src/core/proc.d.ts
CHANGED
|
@@ -87,7 +87,7 @@ export interface RunProcessProbe {
|
|
|
87
87
|
}
|
|
88
88
|
export declare function defaultRunProcessProbe(): RunProcessProbe;
|
|
89
89
|
/**
|
|
90
|
-
* Ends every process of this OS user that carries `
|
|
90
|
+
* Ends every process of this OS user that carries `BAKERS_RUN_UUID=<runUuid>`:
|
|
91
91
|
* the run's agent, its sandbox and background commands that outlive the
|
|
92
92
|
* PTY. SIGTERM first, SIGKILL for survivors after `graceMs`. Best-effort.
|
|
93
93
|
* shortcut: a process that clears its environment is not found; track
|
package/dist/src/core/proc.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { readdirSync, readFileSync, statSync } from 'node:fs';
|
|
2
2
|
/**
|
|
3
3
|
* Substrings a live bakers-conductor foreground process's command line must all
|
|
4
|
-
* contain (see `cmdStartBody`'s `fgCmd`: `bakers
|
|
4
|
+
* contain (see `cmdStartBody`'s `fgCmd`: `bakers conductor … start --foreground
|
|
5
5
|
* --no-update-check`). Deliberately loose — the proof this function performs
|
|
6
6
|
* is "is a bakers conductor foreground loop", not an exact argv match.
|
|
7
7
|
*/
|
|
8
|
-
const CONDUCTOR_CMDLINE_MARKERS = ['
|
|
8
|
+
const CONDUCTOR_CMDLINE_MARKERS = ['start', '--foreground'];
|
|
9
|
+
/** `conductor`, or `oven` for a conductor an older CLI started. */
|
|
10
|
+
const CONDUCTOR_COMMAND = /(^|[\s\0])(conductor|oven)([\s\0]|$)/;
|
|
9
11
|
function looksLikeBbConductor(cmdline) {
|
|
10
|
-
return
|
|
12
|
+
return (CONDUCTOR_COMMAND.test(cmdline) &&
|
|
13
|
+
CONDUCTOR_CMDLINE_MARKERS.every((marker) => cmdline.includes(marker)));
|
|
11
14
|
}
|
|
12
15
|
/**
|
|
13
16
|
* Signals a process only after proving it is a bakers conductor owned by the
|
|
@@ -178,7 +181,7 @@ export function defaultRunProcessProbe() {
|
|
|
178
181
|
};
|
|
179
182
|
}
|
|
180
183
|
/**
|
|
181
|
-
* Ends every process of this OS user that carries `
|
|
184
|
+
* Ends every process of this OS user that carries `BAKERS_RUN_UUID=<runUuid>`:
|
|
182
185
|
* the run's agent, its sandbox and background commands that outlive the
|
|
183
186
|
* PTY. SIGTERM first, SIGKILL for survivors after `graceMs`. Best-effort.
|
|
184
187
|
* shortcut: a process that clears its environment is not found; track
|
|
@@ -188,7 +191,7 @@ export async function killRunProcesses(runUuid, probe = defaultRunProcessProbe()
|
|
|
188
191
|
if (!probe.supported || runUuid === '') {
|
|
189
192
|
return { supported: probe.supported, pids: [] };
|
|
190
193
|
}
|
|
191
|
-
const marker = `
|
|
194
|
+
const marker = `BAKERS_RUN_UUID=${runUuid}`;
|
|
192
195
|
const uid = process.getuid?.();
|
|
193
196
|
const ofRun = (pid) => probe.environOf(pid)?.includes(marker) === true;
|
|
194
197
|
const pids = probe
|
package/dist/src/index.d.ts
CHANGED
|
@@ -6,14 +6,17 @@ export { type ConfigOnlineOptions, createBbConnectionClient, createBbConnectionC
|
|
|
6
6
|
export type { ConfigChange, ConfigFileKind, ConfigFileReport, ConfigFinding, ConfigFindingCode, ConfigLayer, ConfigLocation, ConfigOperation, ConfigReport, ConfigScope, } from './cli/config-report.js';
|
|
7
7
|
export { configRecheckCommand, finalizeConfigReport, } from './cli/config-report.js';
|
|
8
8
|
export { type ConfigSourceInspection, type ConfigSourceProperty, declaresTopLevelKey, findDefaultExportObject, inspectConfigSource, matchDelimiter, type PropEntry, readKey, scanTopLevelProperties, scanToTopLevelComma, skipBlockComment, skipLineComment, skipString, skipTrivia, } from './cli/config-source.js';
|
|
9
|
+
export { addonOptionProblems, assertValidConfig, type ConfigKind, checkConfigText, configAjv, coreSchemaPath, type SchemaProblem, type StaticConfig, staticConfig, validateConfig, } from './cli/config-validate.js';
|
|
9
10
|
export { HOME_IMPORT_EXPRESSION_PATTERN, importConfig, } from './cli/import-config.js';
|
|
10
11
|
export { type LayeredUiEntryLayer, machineUiConfigPath, projectConductorConfigPath, readUiEntryLayers, } from './cli/layered-ui-entries.js';
|
|
11
12
|
export { type BbConnectionConfig, BbConnectionConfigError, type BbConnectionGlobals, type BbConnectionLoadOptions, type BbConnectionSelection, type EffectiveConnectionField, loadBbConfig, loadBbConnectionBootstrap, reportLoadedBbConfigFields, resolveBbConnectionSelection, } from './cli/load-bakers-config.js';
|
|
12
|
-
export {
|
|
13
|
+
export { isValidMachineConnectionUrl } from './cli/machine-connection.js';
|
|
14
|
+
export { type AgentRoutes, assertSchemaVersion, CONFIG_SCHEMA_VERSION, type MachineContext, machineContextPath, readMachineContext, resolveMachineContextPath, } from './cli/machine-context.js';
|
|
13
15
|
export { corePackageRoot } from './cli/paths.js';
|
|
14
16
|
export { resolveModuleEslintStyle } from './cli/resolve-module.js';
|
|
15
17
|
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';
|
|
16
18
|
export { discoverBbWorkspaces, loadReadyBbConnection, resolveWorkspaceSelector, type WorkspaceChoice, type WorkspaceRecoveryOptions, workspaceSearchCommand, } from './cli/workspace-recovery.js';
|
|
19
|
+
export type { ConnectionConfig, MachineConfig, ProjectConfig, } from './config-types.generated.js';
|
|
17
20
|
export { configHomeOf, defaultRootGitExec, deriveCheckoutRoot, type RootGitExec, } from './core/checkout-root.js';
|
|
18
21
|
export { CommandRunner, ExecError, exec, setDefaultCommandRunner, } from './core/exec.js';
|
|
19
22
|
export { type GitSandboxPaths, gitSandboxPaths, withoutGitDirs, } from './core/git-sandbox.js';
|
package/dist/src/index.js
CHANGED
|
@@ -8,10 +8,12 @@ export { configRecheckCommand, finalizeConfigReport, } from './cli/config-report
|
|
|
8
8
|
// BB-218 strip pass share one answer to "which top-level properties does this
|
|
9
9
|
// config source declare?" — core is layer 0 and cannot import the conductor's copy.
|
|
10
10
|
export { declaresTopLevelKey, findDefaultExportObject, inspectConfigSource, matchDelimiter, readKey, scanTopLevelProperties, scanToTopLevelComma, skipBlockComment, skipLineComment, skipString, skipTrivia, } from './cli/config-source.js';
|
|
11
|
+
export { addonOptionProblems, assertValidConfig, checkConfigText, configAjv, coreSchemaPath, staticConfig, validateConfig, } from './cli/config-validate.js';
|
|
11
12
|
export { HOME_IMPORT_EXPRESSION_PATTERN, importConfig, } from './cli/import-config.js';
|
|
12
13
|
export { machineUiConfigPath, projectConductorConfigPath, readUiEntryLayers, } from './cli/layered-ui-entries.js';
|
|
13
14
|
export { BbConnectionConfigError, loadBbConfig, loadBbConnectionBootstrap, reportLoadedBbConfigFields, resolveBbConnectionSelection, } from './cli/load-bakers-config.js';
|
|
14
|
-
export {
|
|
15
|
+
export { isValidMachineConnectionUrl } from './cli/machine-connection.js';
|
|
16
|
+
export { assertSchemaVersion, CONFIG_SCHEMA_VERSION, machineContextPath, readMachineContext, resolveMachineContextPath, } from './cli/machine-context.js';
|
|
15
17
|
export { corePackageRoot } from './cli/paths.js';
|
|
16
18
|
export { resolveModuleEslintStyle } from './cli/resolve-module.js';
|
|
17
19
|
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';
|
|
@@ -40,5 +42,3 @@ export { bumpUiRefresh, UI_REFRESH_FILE } from './core/ui-refresh.js';
|
|
|
40
42
|
export { AddonUnresolvedError, discoverAddons, loadAddonPreset, resolveConductorSlots, } from './plugins/discover-addons.js';
|
|
41
43
|
export { emptyContributions, PRESET_FUNCTION_KEYS, SURFACE_KEYS, } from './plugins/preset.js';
|
|
42
44
|
export { discoverScoped, readConfigAddons, readEffectiveAddon, scopeAddons, } from './plugins/scoped-addons.js';
|
|
43
|
-
// BB-194 AC-2: there is no agent-host contract here; `bakers ui` no longer
|
|
44
|
-
// hosts agents.
|
|
@@ -64,9 +64,9 @@ export interface ResolvedConductorSlots<R = unknown, E = unknown, W = unknown, A
|
|
|
64
64
|
}
|
|
65
65
|
/** Resolve discovered conductor contributions into the four engine slots. */
|
|
66
66
|
export declare function resolveConductorSlots<R, E, W, A>(contributions: {
|
|
67
|
-
|
|
67
|
+
servers: R[];
|
|
68
68
|
executors: E[];
|
|
69
|
-
|
|
69
|
+
worktrees: W[];
|
|
70
70
|
agents: A[];
|
|
71
71
|
}, logger?: ConductorLogger): ResolvedConductorSlots<R, E, W, A>;
|
|
72
72
|
export {};
|
|
@@ -42,13 +42,13 @@ function warnFrom(logger) {
|
|
|
42
42
|
export function normalizeEntry(entry) {
|
|
43
43
|
if (typeof entry === 'string')
|
|
44
44
|
return { spec: entry, opts: undefined };
|
|
45
|
-
const spec = entry.use
|
|
45
|
+
const spec = entry.use;
|
|
46
46
|
if (typeof spec !== 'string' || spec.trim() === '') {
|
|
47
|
-
throw new Error(`addons[] entry must name a package via a string or { use }
|
|
47
|
+
throw new Error(`addons[] entry must name a package via a string or { use }; got ${JSON.stringify(entry)}`);
|
|
48
48
|
}
|
|
49
49
|
return {
|
|
50
50
|
spec,
|
|
51
|
-
opts: entry.with
|
|
51
|
+
opts: entry.with,
|
|
52
52
|
...(entry.alias !== undefined ? { alias: entry.alias } : {}),
|
|
53
53
|
...(entry.priority ? { priority: entry.priority } : {}),
|
|
54
54
|
};
|
|
@@ -99,9 +99,9 @@ function adaptDefaultExport(mod, spec, warn) {
|
|
|
99
99
|
...conn,
|
|
100
100
|
];
|
|
101
101
|
},
|
|
102
|
-
|
|
102
|
+
servers: (acc, opts) => routeByKind(factory, opts, 'server', acc),
|
|
103
103
|
executors: (acc, opts) => routeByKind(factory, opts, 'executor', acc),
|
|
104
|
-
|
|
104
|
+
worktrees: (acc, opts) => routeByKind(factory, opts, 'worktree', acc),
|
|
105
105
|
agents: (acc, opts) => {
|
|
106
106
|
const built = factory(opts);
|
|
107
107
|
const list = Array.isArray(built) ? built : [built];
|
|
@@ -111,9 +111,9 @@ function adaptDefaultExport(mod, spec, warn) {
|
|
|
111
111
|
};
|
|
112
112
|
}
|
|
113
113
|
function isEngineKind(kind) {
|
|
114
|
-
return (kind === '
|
|
114
|
+
return (kind === 'server' ||
|
|
115
115
|
kind === 'executor' ||
|
|
116
|
-
kind === '
|
|
116
|
+
kind === 'worktree' ||
|
|
117
117
|
kind === 'agent');
|
|
118
118
|
}
|
|
119
119
|
function routeByKind(factory, opts, kind, acc) {
|
|
@@ -359,9 +359,9 @@ function resolveSingleton(list, kind, logger) {
|
|
|
359
359
|
}
|
|
360
360
|
/** Resolve discovered conductor contributions into the four engine slots. */
|
|
361
361
|
export function resolveConductorSlots(contributions, logger) {
|
|
362
|
-
const remote = resolveSingleton(contributions.
|
|
362
|
+
const remote = resolveSingleton(contributions.servers, 'server', logger);
|
|
363
363
|
const executor = resolveSingleton(contributions.executors, 'executor', logger);
|
|
364
|
-
const workspace = resolveSingleton(contributions.
|
|
364
|
+
const workspace = resolveSingleton(contributions.worktrees, 'worktree', logger);
|
|
365
365
|
return {
|
|
366
366
|
...(remote ? { remote } : {}),
|
|
367
367
|
...(executor ? { executor } : {}),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DropSHPlugin } from 'dropsh/plugin';
|
|
2
2
|
import type { ConfigScope } from '../cli/config-report.js';
|
|
3
3
|
/** The config files an addon may be listed in: `~/.bakers/machine.config.js`
|
|
4
|
-
* (`machine`) and the project's `.bakers/
|
|
4
|
+
* (`machine`) and the project's `.bakers/project.config.js` (`project`). */
|
|
5
5
|
export type AddonScope = Extract<ConfigScope, 'machine' | 'project'>;
|
|
6
6
|
/**
|
|
7
7
|
* A lazy command pointer (moved here from the host, BB-201, + `describe`). The
|
|
@@ -20,6 +20,8 @@ export interface CommandDescriptor {
|
|
|
20
20
|
export?: string;
|
|
21
21
|
/** Keep dispatch available while omitting the command from help. */
|
|
22
22
|
hidden?: boolean;
|
|
23
|
+
/** Hidden alternative names that run this command (`oven` → `conductor`). */
|
|
24
|
+
aliases?: string[];
|
|
23
25
|
/** `bakers help <name>` runs `bakers <name> --help`, for plugins that render their own help. */
|
|
24
26
|
forwardHelp?: boolean;
|
|
25
27
|
}
|
|
@@ -33,16 +35,12 @@ export type BbSurface = 'command' | 'conductor' | 'connection';
|
|
|
33
35
|
* contribution's own `.kind`.
|
|
34
36
|
*/
|
|
35
37
|
export type AddonEntry = string | {
|
|
36
|
-
/** The addon package
|
|
37
|
-
use
|
|
38
|
-
/** Storybook's term for the same field; accepted as an alias. */
|
|
39
|
-
name?: string;
|
|
38
|
+
/** The addon package. */
|
|
39
|
+
use: string;
|
|
40
40
|
/** Options handed to the addon's accumulators as `opts`. */
|
|
41
41
|
with?: unknown;
|
|
42
42
|
/** Select a named agent variant, or name a single custom contribution. */
|
|
43
43
|
alias?: string;
|
|
44
|
-
/** Alias for `with`. */
|
|
45
|
-
options?: unknown;
|
|
46
44
|
/**
|
|
47
45
|
* Agent-surface only: the static per-ticket priority (see the conductor
|
|
48
46
|
* surface's `selectAgent`). The ticket type belongs to the conductor
|
|
@@ -62,11 +60,11 @@ export type AddonEntry = string | {
|
|
|
62
60
|
export interface DiscoveredContributions {
|
|
63
61
|
commands: CommandDescriptor[];
|
|
64
62
|
/** Opaque: `RemotePlugin[]` on the conductor surface. */
|
|
65
|
-
|
|
63
|
+
servers: unknown[];
|
|
66
64
|
/** Opaque: `ExecutorPlugin[]` on the conductor surface. */
|
|
67
65
|
executors: unknown[];
|
|
68
66
|
/** Opaque: `WorkspacePlugin[]` on the conductor surface. */
|
|
69
|
-
|
|
67
|
+
worktrees: unknown[];
|
|
70
68
|
/** Opaque: `AgentCandidate[]` on the conductor surface. */
|
|
71
69
|
agents: unknown[];
|
|
72
70
|
/** Opaque: `HookListener[]` on the conductor surface (BB-599). */
|
|
@@ -136,19 +134,10 @@ export interface BbPreset<O = unknown> {
|
|
|
136
134
|
* `with`, when given, replaces the project `with` whole.
|
|
137
135
|
*/
|
|
138
136
|
mergeWith?: (project: unknown, machine: unknown) => unknown;
|
|
139
|
-
/**
|
|
140
|
-
* Check one entry's own `with` (`undefined` when it has none); each problem
|
|
141
|
-
* names its key relative to `with`. `bakers config check --online` reports
|
|
142
|
-
* them as `addon_with_invalid`.
|
|
143
|
-
*/
|
|
144
|
-
checkWith?: (value: unknown) => {
|
|
145
|
-
key: string;
|
|
146
|
-
message: string;
|
|
147
|
-
}[];
|
|
148
137
|
commands?: (acc: CommandDescriptor[], opts: O) => CommandDescriptor[] | Promise<CommandDescriptor[]>;
|
|
149
|
-
|
|
138
|
+
servers?: OpaqueAccumulator<O>;
|
|
150
139
|
executors?: OpaqueAccumulator<O>;
|
|
151
|
-
|
|
140
|
+
worktrees?: OpaqueAccumulator<O>;
|
|
152
141
|
agents?: OpaqueAccumulator<O>;
|
|
153
142
|
hooks?: OpaqueAccumulator<O>;
|
|
154
143
|
connectionPlugins?: (acc: DropSHPlugin[], opts: O) => DropSHPlugin[] | Promise<DropSHPlugin[]>;
|