@bakers-build/addon-herdr 0.8.0 → 0.8.1-next.2
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/config.d.ts +11 -15
- package/dist/src/config.js +7 -7
- package/dist/src/index.d.ts +13 -1
- package/dist/src/index.js +63 -18
- package/dist/src/launch-script.d.ts +5 -5
- package/dist/src/launch-script.js +5 -5
- package/dist/src/open-layout.d.ts +5 -5
- package/dist/src/open-layout.js +7 -7
- package/dist/src/pane-layout.d.ts +2 -2
- package/dist/src/pane-layout.js +1 -1
- package/dist/src/panes.d.ts +2 -2
- package/dist/src/panes.js +4 -4
- package/dist/src/preset.d.ts +1 -1
- package/dist/src/preset.js +1 -1
- package/dist/src/shared.d.ts +1 -1
- package/dist/src/shared.js +1 -1
- package/dist/src/workspace.d.ts +3 -3
- package/dist/src/workspace.js +4 -4
- package/options.schema.json +119 -0
- package/package.json +10 -8
package/dist/src/config.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { LaunchWatchOptions } from './launch-script.js';
|
|
1
2
|
import type { OpenLayout } from './open-layout.js';
|
|
2
3
|
import type { RootGitExec } from './root-anchor.js';
|
|
3
4
|
export interface PaneSpec {
|
|
@@ -9,17 +10,17 @@ export interface StateConfig {
|
|
|
9
10
|
/**
|
|
10
11
|
* Tab label template. Must contain {identifier} — the conductor matches a
|
|
11
12
|
* run's tab by its ticket identifier (stop/state), so the identifier is the
|
|
12
|
-
* stable anchor in the visible name. Other vars: {title}, {
|
|
13
|
-
* {
|
|
13
|
+
* stable anchor in the visible name. Other vars: {title}, {title_slug},
|
|
14
|
+
* {run_uuid}, {workspace_path}.
|
|
14
15
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
tab_label?: string;
|
|
17
|
+
workspace_label?: string;
|
|
17
18
|
/**
|
|
18
19
|
* Root-pane (panel) label template applied via `herdr pane rename` after the
|
|
19
20
|
* state tab is created (BB-374). Default `{title}`. Distinct from
|
|
20
|
-
* {@link
|
|
21
|
+
* {@link tab_label}: stop/state matching still anchors on the tab label.
|
|
21
22
|
*/
|
|
22
|
-
|
|
23
|
+
panel_label?: string;
|
|
23
24
|
/** Extra layout panes (diff/logs); NOT the agent command. */
|
|
24
25
|
panes?: PaneSpec[];
|
|
25
26
|
}
|
|
@@ -46,18 +47,13 @@ export interface HerdrExecutorOptions {
|
|
|
46
47
|
default?: StateConfig;
|
|
47
48
|
states?: Record<string, StateConfig>;
|
|
48
49
|
/**
|
|
49
|
-
* Launch-watch windows. `
|
|
50
|
+
* Launch-watch windows. `start_timeout_ms` is how long startRun waits for the
|
|
50
51
|
* wrapper to write `started` (default 60s, so a slow interactive shell can
|
|
51
|
-
* finish rc). `
|
|
52
|
+
* finish rc). `timeout_ms` is the short window after `started` in which an
|
|
52
53
|
* immediate agent exit fails the launch (default 4000 ms). Tests inject
|
|
53
|
-
* shorter windows, including `
|
|
54
|
+
* shorter windows, including `timeout_ms: 0` to skip the exit wait.
|
|
54
55
|
*/
|
|
55
|
-
|
|
56
|
-
timeoutMs?: number;
|
|
57
|
-
startTimeoutMs?: number;
|
|
58
|
-
pollMs?: number;
|
|
59
|
-
sleep?: (ms: number) => Promise<void>;
|
|
60
|
-
};
|
|
56
|
+
launch_watch?: Omit<LaunchWatchOptions, 'readPane'>;
|
|
61
57
|
}
|
|
62
58
|
export interface ResolvedConfig {
|
|
63
59
|
tabLabel: string;
|
package/dist/src/config.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const BUILTIN_DEFAULTS = {
|
|
2
|
-
tabLabel: '{identifier} · {
|
|
3
|
-
workspaceLabel: '{
|
|
2
|
+
tabLabel: '{identifier} · {title_slug}',
|
|
3
|
+
workspaceLabel: '{repo_name}',
|
|
4
4
|
panelLabel: '{title}',
|
|
5
5
|
panes: [],
|
|
6
6
|
};
|
|
@@ -8,11 +8,11 @@ export function resolveStateConfig(options, state) {
|
|
|
8
8
|
const base = options.default ?? {};
|
|
9
9
|
const stateCfg = options.states?.[state] ?? {};
|
|
10
10
|
return {
|
|
11
|
-
tabLabel: stateCfg.
|
|
12
|
-
workspaceLabel: stateCfg.
|
|
13
|
-
base.
|
|
11
|
+
tabLabel: stateCfg.tab_label ?? base.tab_label ?? BUILTIN_DEFAULTS.tabLabel,
|
|
12
|
+
workspaceLabel: stateCfg.workspace_label ??
|
|
13
|
+
base.workspace_label ??
|
|
14
14
|
BUILTIN_DEFAULTS.workspaceLabel,
|
|
15
|
-
panelLabel: stateCfg.
|
|
15
|
+
panelLabel: stateCfg.panel_label ?? base.panel_label ?? BUILTIN_DEFAULTS.panelLabel,
|
|
16
16
|
panes: stateCfg.panes ?? base.panes ?? BUILTIN_DEFAULTS.panes,
|
|
17
17
|
};
|
|
18
18
|
}
|
|
@@ -24,6 +24,6 @@ export function renderTemplate(tpl, vars) {
|
|
|
24
24
|
}
|
|
25
25
|
export function assertTabLabelTemplate(tabLabel) {
|
|
26
26
|
if (!tabLabel.includes('{identifier}')) {
|
|
27
|
-
throw new Error(`herdr
|
|
27
|
+
throw new Error(`herdr tab_label must contain {identifier} for stop/state matching: ${tabLabel}`);
|
|
28
28
|
}
|
|
29
29
|
}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export { DEFAULT_OPEN_LAYOUT, type OpenLayout } from './open-layout.js';
|
|
|
6
6
|
export type { HerdrExec } from './pane-layout.js';
|
|
7
7
|
export { envArgs } from './panes.js';
|
|
8
8
|
export { HerdrWorkspace, type HerdrWorkspaceOptions, herdrWorkspace, } from './workspace.js';
|
|
9
|
-
export { parseWorkspaceList, type WorkspaceEntry
|
|
9
|
+
export { parseWorkspaceList, type WorkspaceEntry } from './workspace-list.js';
|
|
10
10
|
export declare class HerdrExecutor implements BbExecutor {
|
|
11
11
|
private readonly options;
|
|
12
12
|
private readonly execHerdr;
|
|
@@ -62,6 +62,18 @@ export declare class HerdrExecutor implements BbExecutor {
|
|
|
62
62
|
* The branch worktree is untouched (that is `HerdrWorkspace.remove`).
|
|
63
63
|
*/
|
|
64
64
|
cleanupRun(branch: string, runId: number): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Whether a pane of the run's tab still runs the run's launch wrapper; a
|
|
67
|
+
* failing `herdr` call throws. After a server restart herdr restores tabs as
|
|
68
|
+
* bare shells, or resumes the agent itself without the run's flags and
|
|
69
|
+
* tools, so an open tab alone does not mean the run lives.
|
|
70
|
+
*/
|
|
71
|
+
runAlive(branch: string, runId: number): Promise<boolean>;
|
|
72
|
+
/**
|
|
73
|
+
* The branch workspace's tabs labelled `#<runId>`: after a restart herdr can
|
|
74
|
+
* restore an old run tab beside the relaunched one.
|
|
75
|
+
*/
|
|
76
|
+
private runTabs;
|
|
65
77
|
private commandFor;
|
|
66
78
|
}
|
|
67
79
|
export declare function herdrExecutor(options?: HerdrExecutorOptions): ExecutorPlugin;
|
package/dist/src/index.js
CHANGED
|
@@ -13,7 +13,7 @@ export { envArgs } from './panes.js';
|
|
|
13
13
|
// @bakers-build/addon-herdr-workspace was merged in). The package DEFAULT export
|
|
14
14
|
// stays the executor (below); herdrWorkspace + HerdrWorkspace are named exports.
|
|
15
15
|
export { HerdrWorkspace, herdrWorkspace, } from './workspace.js';
|
|
16
|
-
export { parseWorkspaceList
|
|
16
|
+
export { parseWorkspaceList } from './workspace-list.js';
|
|
17
17
|
async function defaultExec(args, opts) {
|
|
18
18
|
return exec('herdr', args, opts);
|
|
19
19
|
}
|
|
@@ -227,9 +227,9 @@ export class HerdrExecutor {
|
|
|
227
227
|
const vars = {
|
|
228
228
|
identifier: input.ticket.identifier,
|
|
229
229
|
title: input.ticket.title,
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
230
|
+
title_slug: slugify(input.ticket.title),
|
|
231
|
+
run_uuid: input.run.uuid,
|
|
232
|
+
workspace_path: input.workspacePath,
|
|
233
233
|
};
|
|
234
234
|
// 3. Create tab — NO --json flag; label includes the run-id token. The tab's
|
|
235
235
|
// root pane IS the agent pane, so it is created carrying the agent-shell
|
|
@@ -249,7 +249,7 @@ export class HerdrExecutor {
|
|
|
249
249
|
]));
|
|
250
250
|
// BB-374: panel label on the state root pane (best-effort). Tab --label
|
|
251
251
|
// above stays the stop/state matching string and is intentionally not the
|
|
252
|
-
// resolved StateConfig.
|
|
252
|
+
// resolved StateConfig.tab_label path.
|
|
253
253
|
await this.execHerdr([
|
|
254
254
|
'pane',
|
|
255
255
|
'rename',
|
|
@@ -273,7 +273,7 @@ export class HerdrExecutor {
|
|
|
273
273
|
launch = writeLaunchScript(this.commandFor(input));
|
|
274
274
|
await applyPaneLayout(this.execHerdr, rootPaneId, { command: launch.typedCommand, panes: cfg.panes }, input.workspacePath, vars, { env: AGENT_SHELL_ENV });
|
|
275
275
|
await watchLaunch(launch, {
|
|
276
|
-
...(this.options.
|
|
276
|
+
...(this.options.launch_watch ?? {}),
|
|
277
277
|
readPane: () => this.execHerdr(['pane', 'read', rootPaneId, '--lines', '40']),
|
|
278
278
|
});
|
|
279
279
|
// 6. Return branch as sessionRef (for logging)
|
|
@@ -313,21 +313,64 @@ export class HerdrExecutor {
|
|
|
313
313
|
* The branch worktree is untouched (that is `HerdrWorkspace.remove`).
|
|
314
314
|
*/
|
|
315
315
|
async cleanupRun(branch, runId) {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
316
|
+
// No tab for this run is a quiet best-effort no-op (AC-4).
|
|
317
|
+
for (const tabId of (await this.runTabs(branch, runId)).tabIds) {
|
|
318
|
+
try {
|
|
319
|
+
await this.execHerdr(['tab', 'close', tabId]);
|
|
320
|
+
}
|
|
321
|
+
catch {
|
|
322
|
+
// ignore — best-effort: a failing tab-close must not abort finalisation
|
|
323
|
+
}
|
|
319
324
|
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Whether a pane of the run's tab still runs the run's launch wrapper; a
|
|
328
|
+
* failing `herdr` call throws. After a server restart herdr restores tabs as
|
|
329
|
+
* bare shells, or resumes the agent itself without the run's flags and
|
|
330
|
+
* tools, so an open tab alone does not mean the run lives.
|
|
331
|
+
*/
|
|
332
|
+
async runAlive(branch, runId) {
|
|
333
|
+
const { workspaceId, tabIds } = await this.runTabs(branch, runId);
|
|
334
|
+
if (tabIds.size === 0) {
|
|
335
|
+
return false;
|
|
324
336
|
}
|
|
325
|
-
|
|
326
|
-
|
|
337
|
+
const listed = parseJson(await this.execHerdr(['pane', 'list', '--workspace', workspaceId]), 'pane list');
|
|
338
|
+
const panes = isRecord(listed)
|
|
339
|
+
? listed.result?.panes
|
|
340
|
+
: undefined;
|
|
341
|
+
for (const pane of Array.isArray(panes) ? panes.filter(isRecord) : []) {
|
|
342
|
+
if (!tabIds.has(pane.tab_id) ||
|
|
343
|
+
typeof pane.pane_id !== 'string') {
|
|
344
|
+
continue;
|
|
345
|
+
}
|
|
346
|
+
const info = parseJson(await this.execHerdr(['pane', 'process-info', '--pane', pane.pane_id]), 'pane process-info');
|
|
347
|
+
const procs = isRecord(info)
|
|
348
|
+
? info.result?.process_info?.foreground_processes
|
|
349
|
+
: undefined;
|
|
350
|
+
const wrapper = /\/bakers-run-[^/]+\/run\.sh$/;
|
|
351
|
+
if (Array.isArray(procs) &&
|
|
352
|
+
procs.some((p) => isRecord(p) &&
|
|
353
|
+
Array.isArray(p.argv) &&
|
|
354
|
+
p.argv.some((a) => typeof a === 'string' && wrapper.test(a)))) {
|
|
355
|
+
return true;
|
|
356
|
+
}
|
|
327
357
|
}
|
|
328
|
-
|
|
329
|
-
|
|
358
|
+
return false;
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* The branch workspace's tabs labelled `#<runId>`: after a restart herdr can
|
|
362
|
+
* restore an old run tab beside the relaunched one.
|
|
363
|
+
*/
|
|
364
|
+
async runTabs(branch, runId) {
|
|
365
|
+
const workspaceId = await this.findWorkspaceByBranch(branch);
|
|
366
|
+
if (!workspaceId) {
|
|
367
|
+
return { workspaceId: '', tabIds: new Set() };
|
|
330
368
|
}
|
|
369
|
+
const tabs = parseTabList(await this.execHerdr(['tab', 'list', '--workspace', workspaceId]));
|
|
370
|
+
return {
|
|
371
|
+
workspaceId,
|
|
372
|
+
tabIds: new Set(tabs.filter((t) => labelMatchesRun(t.label, runId)).map((t) => t.tabId)),
|
|
373
|
+
};
|
|
331
374
|
}
|
|
332
375
|
commandFor(input) {
|
|
333
376
|
const env = Object.entries(input.env ?? {}).map(([key, value]) => {
|
|
@@ -368,7 +411,9 @@ export function herdrExecutor(options = {}) {
|
|
|
368
411
|
...(options.open ? { open: options.open } : {}),
|
|
369
412
|
...(options.default ? { default: options.default } : {}),
|
|
370
413
|
...(options.states ? { states: options.states } : {}),
|
|
371
|
-
...(options.
|
|
414
|
+
...(options.launch_watch
|
|
415
|
+
? { launch_watch: options.launch_watch }
|
|
416
|
+
: {}),
|
|
372
417
|
}, defaultExec, deps.logger);
|
|
373
418
|
},
|
|
374
419
|
};
|
|
@@ -18,16 +18,16 @@ export interface LaunchScript {
|
|
|
18
18
|
export declare function writeLaunchScript(command: string): LaunchScript;
|
|
19
19
|
export interface LaunchWatchOptions {
|
|
20
20
|
/** Window after `started` in which an immediate agent exit fails the launch. */
|
|
21
|
-
|
|
21
|
+
timeout_ms?: number;
|
|
22
22
|
/** How long to wait for the wrapper to write `started`. Default 60s. */
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
start_timeout_ms?: number;
|
|
24
|
+
poll_ms?: number;
|
|
25
25
|
sleep?: (ms: number) => Promise<void>;
|
|
26
26
|
readPane?: () => Promise<string>;
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
|
-
* Poll the launch markers in two phases. Wait up to `
|
|
30
|
-
* `started` (shell start-up), then apply a short `
|
|
29
|
+
* Poll the launch markers in two phases. Wait up to `start_timeout_ms` for
|
|
30
|
+
* `started` (shell start-up), then apply a short `timeout_ms` exit window from
|
|
31
31
|
* that moment. An immediate exit or a script that never starts fails the
|
|
32
32
|
* launch; an agent still running at the exit deadline is treated as started.
|
|
33
33
|
*/
|
|
@@ -52,15 +52,15 @@ const DEFAULT_TIMEOUT_MS = 4000;
|
|
|
52
52
|
const DEFAULT_START_TIMEOUT_MS = 60_000;
|
|
53
53
|
const DEFAULT_POLL_MS = 50;
|
|
54
54
|
/**
|
|
55
|
-
* Poll the launch markers in two phases. Wait up to `
|
|
56
|
-
* `started` (shell start-up), then apply a short `
|
|
55
|
+
* Poll the launch markers in two phases. Wait up to `start_timeout_ms` for
|
|
56
|
+
* `started` (shell start-up), then apply a short `timeout_ms` exit window from
|
|
57
57
|
* that moment. An immediate exit or a script that never starts fails the
|
|
58
58
|
* launch; an agent still running at the exit deadline is treated as started.
|
|
59
59
|
*/
|
|
60
60
|
export async function watchLaunch(script, opts = {}) {
|
|
61
|
-
const timeoutMs = opts.
|
|
62
|
-
const startTimeoutMs = opts.
|
|
63
|
-
const pollMs = opts.
|
|
61
|
+
const timeoutMs = opts.timeout_ms ?? DEFAULT_TIMEOUT_MS;
|
|
62
|
+
const startTimeoutMs = opts.start_timeout_ms ?? DEFAULT_START_TIMEOUT_MS;
|
|
63
|
+
const pollMs = opts.poll_ms ?? DEFAULT_POLL_MS;
|
|
64
64
|
const sleep = opts.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
|
|
65
65
|
const startDeadline = Date.now() + startTimeoutMs;
|
|
66
66
|
let exitDeadline = 0;
|
|
@@ -6,17 +6,17 @@ import { type HerdrExec } from './pane-layout.js';
|
|
|
6
6
|
* Layout applied to a fresh worktree's initial (root) pane (BB-139): `command`
|
|
7
7
|
* launches a tool in the main pane (e.g. `spiceedit`) so the human lands in an
|
|
8
8
|
* editor instead of a bare shell; `panes[]` are optional splits off it. Same
|
|
9
|
-
* shape as the executor's per-state layout minus `
|
|
9
|
+
* shape as the executor's per-state layout minus `tab_label` — there is only ONE
|
|
10
10
|
* open layout, not a per-ticket-state map.
|
|
11
11
|
*
|
|
12
|
-
* BB-234: `{identifier}`, `{branch}`, `{title}` and `{
|
|
12
|
+
* BB-234: `{identifier}`, `{branch}`, `{title}` and `{worktree_path}` expand in
|
|
13
13
|
* `command` **and** in every `panes[].command`. The root command is rendered
|
|
14
14
|
* here before the finished layout reaches `applyPaneLayout` — that shared
|
|
15
15
|
* helper types its root command VERBATIM on purpose, because its other caller
|
|
16
16
|
* (the run tab) pre-assembles `KEY='value' <agent>` env prefixes whose values
|
|
17
17
|
* may legitimately contain braces (spec D2).
|
|
18
18
|
*
|
|
19
|
-
* BB-374: `
|
|
19
|
+
* BB-374: `tab_label` / `panel_label` are chrome strings applied after the
|
|
20
20
|
* layout via `herdr tab rename` / `herdr pane rename` ("panel label" = pane
|
|
21
21
|
* label). Defaults ship when keys are absent on an active layout; `open: {}`
|
|
22
22
|
* remains the full opt-out (no command, no splits, no labels). The overview
|
|
@@ -34,12 +34,12 @@ export interface OpenLayout {
|
|
|
34
34
|
* Overview tab label template. Default: `{identifier} · {title}` (title
|
|
35
35
|
* truncated to {@link OPEN_TAB_TITLE_MAX} when rendering).
|
|
36
36
|
*/
|
|
37
|
-
|
|
37
|
+
tab_label?: string;
|
|
38
38
|
/**
|
|
39
39
|
* Overview root-pane label template (`herdr pane rename`). Default:
|
|
40
40
|
* `{identifier} · {title}` (full title).
|
|
41
41
|
*/
|
|
42
|
-
|
|
42
|
+
panel_label?: string;
|
|
43
43
|
}
|
|
44
44
|
/** Max `{title}` length substituted into the overview **tab** label (BB-374). */
|
|
45
45
|
export declare const OPEN_TAB_TITLE_MAX = 30;
|
package/dist/src/open-layout.js
CHANGED
|
@@ -27,15 +27,15 @@ export const DEFAULT_OPEN_PANEL_LABEL = '{identifier} · {title}';
|
|
|
27
27
|
*/
|
|
28
28
|
export const DEFAULT_OPEN_LAYOUT = {
|
|
29
29
|
command: 'bakers ui --ticket {identifier}',
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
tab_label: DEFAULT_OPEN_TAB_LABEL,
|
|
31
|
+
panel_label: DEFAULT_OPEN_PANEL_LABEL,
|
|
32
32
|
};
|
|
33
33
|
/** `open: {}` — the opt-out back to the bare tab: no command, splits or labels. */
|
|
34
34
|
export function isEmptyLayout(open) {
|
|
35
35
|
return (open.command === undefined &&
|
|
36
36
|
!open.panes?.length &&
|
|
37
|
-
open.
|
|
38
|
-
open.
|
|
37
|
+
open.tab_label === undefined &&
|
|
38
|
+
open.panel_label === undefined);
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
41
|
* The root pane of a `worktree create`/`worktree open` response
|
|
@@ -95,7 +95,7 @@ export async function applyOpenLayout(execHerdr, logger, open, root, path, ctx)
|
|
|
95
95
|
identifier: ctx.identifier,
|
|
96
96
|
branch: ctx.branch,
|
|
97
97
|
title: ctx.title,
|
|
98
|
-
|
|
98
|
+
worktree_path: path,
|
|
99
99
|
};
|
|
100
100
|
const layout = {
|
|
101
101
|
...open,
|
|
@@ -124,8 +124,8 @@ async function applyOverviewLabels(execHerdr, logger, open, root, vars) {
|
|
|
124
124
|
...vars,
|
|
125
125
|
title: truncateOpenTabTitle(vars.title ?? ''),
|
|
126
126
|
};
|
|
127
|
-
const tabLabel = renderTemplate(open.
|
|
128
|
-
const panelLabel = renderTemplate(open.
|
|
127
|
+
const tabLabel = renderTemplate(open.tab_label ?? DEFAULT_OPEN_TAB_LABEL, tabVars);
|
|
128
|
+
const panelLabel = renderTemplate(open.panel_label ?? DEFAULT_OPEN_PANEL_LABEL, vars);
|
|
129
129
|
let tabId = root.tabId;
|
|
130
130
|
if (!tabId) {
|
|
131
131
|
try {
|
|
@@ -10,7 +10,7 @@ export declare function parsePaneSplit(output: string): string;
|
|
|
10
10
|
* split panes. Shared by the executor's per-run tab (`startRun`) and the
|
|
11
11
|
* workspace's initial open pane (`herdrWorkspace` `open`) — one code path, no
|
|
12
12
|
* duplication. The per-state `StateConfig` (executor) and the workspace `open`
|
|
13
|
-
* option both narrow to this shape (the executor adds `
|
|
13
|
+
* option both narrow to this shape (the executor adds `tab_label`; there is only
|
|
14
14
|
* one open layout, not a per-state map).
|
|
15
15
|
*/
|
|
16
16
|
export interface PaneLayout {
|
|
@@ -32,7 +32,7 @@ export interface PaneLayout {
|
|
|
32
32
|
* secret, while the command herdr actually runs stays real. An empty layout
|
|
33
33
|
* (`{}`) issues no calls at all — the caller's unconfigured default is preserved.
|
|
34
34
|
*
|
|
35
|
-
* `opts.env` is forwarded to each split pane as `--env` args (
|
|
35
|
+
* `opts.env` is forwarded to each split pane as `--env` args (BAKERS_* only, see
|
|
36
36
|
* {@link envArgs}). It is deliberately per-CALLER rather than baked in: this
|
|
37
37
|
* primitive serves both the executor's agent tab and the workspace's own open
|
|
38
38
|
* pane, and only the former's panes are agent-owned (BB-64). The ROOT pane is
|
package/dist/src/pane-layout.js
CHANGED
|
@@ -35,7 +35,7 @@ export function parsePaneSplit(output) {
|
|
|
35
35
|
* secret, while the command herdr actually runs stays real. An empty layout
|
|
36
36
|
* (`{}`) issues no calls at all — the caller's unconfigured default is preserved.
|
|
37
37
|
*
|
|
38
|
-
* `opts.env` is forwarded to each split pane as `--env` args (
|
|
38
|
+
* `opts.env` is forwarded to each split pane as `--env` args (BAKERS_* only, see
|
|
39
39
|
* {@link envArgs}). It is deliberately per-CALLER rather than baked in: this
|
|
40
40
|
* primitive serves both the executor's agent tab and the workspace's own open
|
|
41
41
|
* pane, and only the former's panes are agent-owned (BB-64). The ROOT pane is
|
package/dist/src/panes.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Marker exported into an AGENT pane's interactive shell, so a user's opt-in
|
|
3
3
|
* shell init can recognise an agent-run pane at startup and isolate its history
|
|
4
|
-
* (BB-64). It is a plain `
|
|
4
|
+
* (BB-64). It is a plain `BAKERS_*` env entry on purpose: it rides {@link envArgs}
|
|
5
5
|
* like every other pane var instead of adding a second mechanism.
|
|
6
6
|
*
|
|
7
7
|
* AGENT panes only — the executor's per-run tab and its layout panes. NOT the
|
|
@@ -9,5 +9,5 @@
|
|
|
9
9
|
* `docs/conductor/node.md` § Agent-pane shell marker.
|
|
10
10
|
*/
|
|
11
11
|
export declare const AGENT_SHELL_ENV: Record<string, string>;
|
|
12
|
-
/** BB_* env vars as `--env KEY=VALUE` args (never dump the full environment). */
|
|
12
|
+
/** BAKERS_* (and the internal BB_* hand-offs) env vars as `--env KEY=VALUE` args (never dump the full environment). */
|
|
13
13
|
export declare function envArgs(env: Record<string, string | undefined>): string[];
|
package/dist/src/panes.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* Marker exported into an AGENT pane's interactive shell, so a user's opt-in
|
|
5
5
|
* shell init can recognise an agent-run pane at startup and isolate its history
|
|
6
|
-
* (BB-64). It is a plain `
|
|
6
|
+
* (BB-64). It is a plain `BAKERS_*` env entry on purpose: it rides {@link envArgs}
|
|
7
7
|
* like every other pane var instead of adding a second mechanism.
|
|
8
8
|
*
|
|
9
9
|
* AGENT panes only — the executor's per-run tab and its layout panes. NOT the
|
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
* `docs/conductor/node.md` § Agent-pane shell marker.
|
|
12
12
|
*/
|
|
13
13
|
export const AGENT_SHELL_ENV = {
|
|
14
|
-
|
|
14
|
+
BAKERS_AGENT_SHELL: '1',
|
|
15
15
|
};
|
|
16
|
-
/** BB_* env vars as `--env KEY=VALUE` args (never dump the full environment). */
|
|
16
|
+
/** BAKERS_* (and the internal BB_* hand-offs) env vars as `--env KEY=VALUE` args (never dump the full environment). */
|
|
17
17
|
export function envArgs(env) {
|
|
18
18
|
const out = [];
|
|
19
19
|
for (const [key, value] of Object.entries(env)) {
|
|
20
|
-
if (
|
|
20
|
+
if (/^(BAKERS|BB)_/.test(key) && value != null) {
|
|
21
21
|
out.push('--env', `${key}=${value}`);
|
|
22
22
|
}
|
|
23
23
|
}
|
package/dist/src/preset.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Preset } from '@bakers-build/conductor/contract';
|
|
2
2
|
export declare const executors: Preset['executors'];
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const worktrees: Preset['worktrees'];
|
|
4
4
|
export declare const hooks: Preset['hooks'];
|
|
5
5
|
export declare const scopes: Preset['scopes'];
|
package/dist/src/preset.js
CHANGED
package/dist/src/shared.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export type BaseRefGitExec = (args: string[]) => Promise<string>;
|
|
|
10
10
|
* run starts from the pushed remote state, not the host's local branch.
|
|
11
11
|
*
|
|
12
12
|
* A ticket's `override` (its `origin/<base_branch>`) wins only when it resolves
|
|
13
|
-
* on the remote after a fetch; otherwise the configured `
|
|
13
|
+
* on the remote after a fetch; otherwise the configured `base_branch`, else the
|
|
14
14
|
* upstream of the repo's HEAD (e.g. `origin/develop`). A repo with no upstream
|
|
15
15
|
* yields `undefined`. Fetch failures are non-fatal (offline / unknown remote).
|
|
16
16
|
*/
|
package/dist/src/shared.js
CHANGED
|
@@ -11,7 +11,7 @@ export { validateBranch } from './workspace.js';
|
|
|
11
11
|
* run starts from the pushed remote state, not the host's local branch.
|
|
12
12
|
*
|
|
13
13
|
* A ticket's `override` (its `origin/<base_branch>`) wins only when it resolves
|
|
14
|
-
* on the remote after a fetch; otherwise the configured `
|
|
14
|
+
* on the remote after a fetch; otherwise the configured `base_branch`, else the
|
|
15
15
|
* upstream of the repo's HEAD (e.g. `origin/develop`). A repo with no upstream
|
|
16
16
|
* yields `undefined`. Fetch failures are non-fatal (offline / unknown remote).
|
|
17
17
|
*/
|
package/dist/src/workspace.d.ts
CHANGED
|
@@ -65,9 +65,9 @@ export declare function herdrWorkspace(opts?: {
|
|
|
65
65
|
* the main clone is derived from the git common dir (BB-177).
|
|
66
66
|
*/
|
|
67
67
|
root?: string;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
worktree_dir?: string;
|
|
69
|
+
base_branch?: string;
|
|
70
|
+
auto_setup_merge?: boolean;
|
|
71
71
|
/** Overrideable git exec for root derivation (tests). */
|
|
72
72
|
execGit?: RootGitExec;
|
|
73
73
|
/** Overrideable herdr exec (tests) — sibling of `execGit`. */
|
package/dist/src/workspace.js
CHANGED
|
@@ -176,7 +176,7 @@ export class HerdrWorkspace {
|
|
|
176
176
|
}
|
|
177
177
|
export function herdrWorkspace(opts = {}) {
|
|
178
178
|
return {
|
|
179
|
-
kind: '
|
|
179
|
+
kind: 'worktree',
|
|
180
180
|
id: 'herdr',
|
|
181
181
|
requiredModules: [],
|
|
182
182
|
// `deps` carries the conductor logger, so teardown warnings are actually
|
|
@@ -188,10 +188,10 @@ export function herdrWorkspace(opts = {}) {
|
|
|
188
188
|
});
|
|
189
189
|
return new HerdrWorkspace({
|
|
190
190
|
root,
|
|
191
|
-
...(opts.
|
|
192
|
-
...(opts.
|
|
191
|
+
...(opts.worktree_dir ? { worktreeDir: opts.worktree_dir } : {}),
|
|
192
|
+
...(opts.base_branch ? { baseBranch: opts.base_branch } : {}),
|
|
193
193
|
...(opts.execHerdr ? { execHerdr: opts.execHerdr } : {}),
|
|
194
|
-
...(opts.
|
|
194
|
+
...(opts.auto_setup_merge ? { autoSetupMerge: true } : {}),
|
|
195
195
|
...(deps?.logger ? { logger: deps.logger } : {}),
|
|
196
196
|
});
|
|
197
197
|
},
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://bakers.build/schema/addon-herdr/options.schema.json",
|
|
4
|
+
"title": "herdr executor + worktree options",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"command": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "Fallback agent command when the conductor supplies none. Default `claude`."
|
|
10
|
+
},
|
|
11
|
+
"open": {
|
|
12
|
+
"type": "object",
|
|
13
|
+
"description": "Startup layout of a fresh worktree; `{}` opts out. Templates expand {identifier}, {branch}, {title}, {worktree_path}.",
|
|
14
|
+
"properties": {
|
|
15
|
+
"command": {
|
|
16
|
+
"type": "string"
|
|
17
|
+
},
|
|
18
|
+
"panes": {
|
|
19
|
+
"type": "array",
|
|
20
|
+
"items": {
|
|
21
|
+
"$ref": "#/$defs/pane"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"tab_label": {
|
|
25
|
+
"type": "string"
|
|
26
|
+
},
|
|
27
|
+
"panel_label": {
|
|
28
|
+
"type": "string"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"additionalProperties": false
|
|
32
|
+
},
|
|
33
|
+
"root": {
|
|
34
|
+
"type": "string",
|
|
35
|
+
"description": "Main clone; otherwise derived from the git common dir."
|
|
36
|
+
},
|
|
37
|
+
"default": {
|
|
38
|
+
"$ref": "#/$defs/state"
|
|
39
|
+
},
|
|
40
|
+
"states": {
|
|
41
|
+
"type": "object",
|
|
42
|
+
"additionalProperties": {
|
|
43
|
+
"$ref": "#/$defs/state"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"launch_watch": {
|
|
47
|
+
"type": "object",
|
|
48
|
+
"description": "Launch-watch windows: wait start_timeout_ms (default 60000) for the wrapper to start, then timeout_ms (default 4000) in which an immediate agent exit fails the launch.",
|
|
49
|
+
"properties": {
|
|
50
|
+
"timeout_ms": {
|
|
51
|
+
"type": "integer",
|
|
52
|
+
"minimum": 0
|
|
53
|
+
},
|
|
54
|
+
"start_timeout_ms": {
|
|
55
|
+
"type": "integer",
|
|
56
|
+
"minimum": 0
|
|
57
|
+
},
|
|
58
|
+
"poll_ms": {
|
|
59
|
+
"type": "integer",
|
|
60
|
+
"minimum": 0
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"additionalProperties": false
|
|
64
|
+
},
|
|
65
|
+
"worktree_dir": {
|
|
66
|
+
"type": "string",
|
|
67
|
+
"description": "Directory (relative to root, or absolute) for new worktrees. Default `.bakers-worktrees`."
|
|
68
|
+
},
|
|
69
|
+
"base_branch": {
|
|
70
|
+
"type": "string",
|
|
71
|
+
"description": "Base ref for new branches. Default: the upstream of the root's HEAD."
|
|
72
|
+
},
|
|
73
|
+
"auto_setup_merge": {
|
|
74
|
+
"type": "boolean",
|
|
75
|
+
"description": "`true` leaves Git's branch.autoSetupMerge alone. Default `false`."
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
"additionalProperties": false,
|
|
79
|
+
"$defs": {
|
|
80
|
+
"pane": {
|
|
81
|
+
"type": "object",
|
|
82
|
+
"properties": {
|
|
83
|
+
"direction": {
|
|
84
|
+
"enum": ["right", "down"]
|
|
85
|
+
},
|
|
86
|
+
"command": {
|
|
87
|
+
"type": "string"
|
|
88
|
+
},
|
|
89
|
+
"focus": {
|
|
90
|
+
"type": "boolean"
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"required": ["direction", "command"],
|
|
94
|
+
"additionalProperties": false
|
|
95
|
+
},
|
|
96
|
+
"state": {
|
|
97
|
+
"type": "object",
|
|
98
|
+
"description": "Per-state layout. Templates expand {identifier}, {title}, {title_slug}, {run_uuid}, {workspace_path}.",
|
|
99
|
+
"properties": {
|
|
100
|
+
"tab_label": {
|
|
101
|
+
"type": "string"
|
|
102
|
+
},
|
|
103
|
+
"workspace_label": {
|
|
104
|
+
"type": "string"
|
|
105
|
+
},
|
|
106
|
+
"panel_label": {
|
|
107
|
+
"type": "string"
|
|
108
|
+
},
|
|
109
|
+
"panes": {
|
|
110
|
+
"type": "array",
|
|
111
|
+
"items": {
|
|
112
|
+
"$ref": "#/$defs/pane"
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
"additionalProperties": false
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
package/package.json
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bakers-build/addon-herdr",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1-next.2",
|
|
4
4
|
"description": "bakers.build herdr integration: spawn executor + per-ticket worktree workspace.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": "./dist/src/index.js",
|
|
9
9
|
"./preset": "./dist/src/preset.js",
|
|
10
|
-
"./shared": "./dist/src/shared.js"
|
|
10
|
+
"./shared": "./dist/src/shared.js",
|
|
11
|
+
"./options.schema.json": "./options.schema.json"
|
|
11
12
|
},
|
|
12
13
|
"files": [
|
|
13
|
-
"dist/src"
|
|
14
|
+
"dist/src",
|
|
15
|
+
"options.schema.json"
|
|
14
16
|
],
|
|
15
17
|
"publishConfig": {
|
|
16
18
|
"access": "public"
|
|
@@ -21,14 +23,14 @@
|
|
|
21
23
|
"directory": "bakers-cli/addons/herdr"
|
|
22
24
|
},
|
|
23
25
|
"dependencies": {
|
|
24
|
-
"@bakers-build/addon-workspace-git": "^0.8.
|
|
26
|
+
"@bakers-build/addon-workspace-git": "^0.8.1-next.2"
|
|
25
27
|
},
|
|
26
28
|
"peerDependencies": {
|
|
27
|
-
"@bakers-build/conductor": "^0.8.
|
|
28
|
-
"@bakers-build/core": "^0.8.
|
|
29
|
+
"@bakers-build/conductor": "^0.8.1-next.2",
|
|
30
|
+
"@bakers-build/core": "^0.8.1-next.2"
|
|
29
31
|
},
|
|
30
32
|
"bakersBuild": {
|
|
31
|
-
"commit": "
|
|
32
|
-
"channel": "
|
|
33
|
+
"commit": "0177880667693d1c36c65ffced82d2f3a17cbf2a",
|
|
34
|
+
"channel": "next"
|
|
33
35
|
}
|
|
34
36
|
}
|