@bakers-build/addon-herdr 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/config.d.ts +11 -15
- package/dist/src/config.js +7 -7
- package/dist/src/index.js +8 -6
- 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 -2
- package/dist/src/shared.js +2 -2
- package/dist/src/workspace.d.ts +3 -5
- package/dist/src/workspace.js +4 -13
- package/options.schema.json +157 -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.js
CHANGED
|
@@ -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)
|
|
@@ -368,7 +368,9 @@ export function herdrExecutor(options = {}) {
|
|
|
368
368
|
...(options.open ? { open: options.open } : {}),
|
|
369
369
|
...(options.default ? { default: options.default } : {}),
|
|
370
370
|
...(options.states ? { states: options.states } : {}),
|
|
371
|
-
...(options.
|
|
371
|
+
...(options.launch_watch
|
|
372
|
+
? { launch_watch: options.launch_watch }
|
|
373
|
+
: {}),
|
|
372
374
|
}, defaultExec, deps.logger);
|
|
373
375
|
},
|
|
374
376
|
};
|
|
@@ -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
|
@@ -2,7 +2,6 @@ export { renderTemplate } from './config.js';
|
|
|
2
2
|
export { restoreWritable } from './fs.js';
|
|
3
3
|
export { type LaunchScript, type LaunchWatchOptions, watchLaunch, writeLaunchScript, } from './launch-script.js';
|
|
4
4
|
export { truncateOpenTabTitle } from './open-layout.js';
|
|
5
|
-
export { validateBranch } from './workspace.js';
|
|
6
5
|
/** Runs `git <args>`; resolves with stdout, rejects on non-zero exit. */
|
|
7
6
|
export type BaseRefGitExec = (args: string[]) => Promise<string>;
|
|
8
7
|
/**
|
|
@@ -10,7 +9,7 @@ export type BaseRefGitExec = (args: string[]) => Promise<string>;
|
|
|
10
9
|
* run starts from the pushed remote state, not the host's local branch.
|
|
11
10
|
*
|
|
12
11
|
* A ticket's `override` (its `origin/<base_branch>`) wins only when it resolves
|
|
13
|
-
* on the remote after a fetch; otherwise the configured `
|
|
12
|
+
* on the remote after a fetch; otherwise the configured `base_branch`, else the
|
|
14
13
|
* upstream of the repo's HEAD (e.g. `origin/develop`). A repo with no upstream
|
|
15
14
|
* yields `undefined`. Fetch failures are non-fatal (offline / unknown remote).
|
|
16
15
|
*/
|
package/dist/src/shared.js
CHANGED
|
@@ -5,13 +5,12 @@ export { renderTemplate } from './config.js';
|
|
|
5
5
|
export { restoreWritable } from './fs.js';
|
|
6
6
|
export { watchLaunch, writeLaunchScript, } from './launch-script.js';
|
|
7
7
|
export { truncateOpenTabTitle } from './open-layout.js';
|
|
8
|
-
export { validateBranch } from './workspace.js';
|
|
9
8
|
/**
|
|
10
9
|
* Resolve (and fetch) the base ref a NEW worktree branch is created from, so a
|
|
11
10
|
* run starts from the pushed remote state, not the host's local branch.
|
|
12
11
|
*
|
|
13
12
|
* A ticket's `override` (its `origin/<base_branch>`) wins only when it resolves
|
|
14
|
-
* on the remote after a fetch; otherwise the configured `
|
|
13
|
+
* on the remote after a fetch; otherwise the configured `base_branch`, else the
|
|
15
14
|
* upstream of the repo's HEAD (e.g. `origin/develop`). A repo with no upstream
|
|
16
15
|
* yields `undefined`. Fetch failures are non-fatal (offline / unknown remote).
|
|
17
16
|
*/
|
|
@@ -26,6 +25,7 @@ export async function resolveBaseRef(root, execGit, opts) {
|
|
|
26
25
|
root,
|
|
27
26
|
'fetch',
|
|
28
27
|
ref.slice(0, slash),
|
|
28
|
+
'--',
|
|
29
29
|
ref.slice(slash + 1),
|
|
30
30
|
]);
|
|
31
31
|
}
|
package/dist/src/workspace.d.ts
CHANGED
|
@@ -29,8 +29,6 @@ export interface HerdrWorkspaceOptions {
|
|
|
29
29
|
*/
|
|
30
30
|
autoSetupMerge?: boolean;
|
|
31
31
|
}
|
|
32
|
-
/** Git-safe branch validation: safe ref chars only, no leading dot, no `..`. */
|
|
33
|
-
export declare function validateBranch(branch: string): void;
|
|
34
32
|
export declare class HerdrWorkspace implements BbWorkspace {
|
|
35
33
|
private readonly options;
|
|
36
34
|
private readonly execHerdr;
|
|
@@ -65,9 +63,9 @@ export declare function herdrWorkspace(opts?: {
|
|
|
65
63
|
* the main clone is derived from the git common dir (BB-177).
|
|
66
64
|
*/
|
|
67
65
|
root?: string;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
worktree_dir?: string;
|
|
67
|
+
base_branch?: string;
|
|
68
|
+
auto_setup_merge?: boolean;
|
|
71
69
|
/** Overrideable git exec for root derivation (tests). */
|
|
72
70
|
execGit?: RootGitExec;
|
|
73
71
|
/** Overrideable herdr exec (tests) — sibling of `execGit`. */
|
package/dist/src/workspace.js
CHANGED
|
@@ -46,14 +46,6 @@ function parseWorktreePath(output, command) {
|
|
|
46
46
|
}
|
|
47
47
|
return path;
|
|
48
48
|
}
|
|
49
|
-
/** Git-safe branch validation: safe ref chars only, no leading dot, no `..`. */
|
|
50
|
-
export function validateBranch(branch) {
|
|
51
|
-
if (!/^[A-Za-z0-9._/-]+$/.test(branch) ||
|
|
52
|
-
branch.startsWith('.') ||
|
|
53
|
-
branch.includes('..')) {
|
|
54
|
-
throw new Error(`invalid workspace branch: ${branch}`);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
49
|
export class HerdrWorkspace {
|
|
58
50
|
options;
|
|
59
51
|
execHerdr;
|
|
@@ -86,7 +78,6 @@ export class HerdrWorkspace {
|
|
|
86
78
|
if (branch === undefined) {
|
|
87
79
|
throw new Error('herdr workspace requires a branch name');
|
|
88
80
|
}
|
|
89
|
-
validateBranch(branch);
|
|
90
81
|
const extra = this.options.autoSetupMerge
|
|
91
82
|
? {}
|
|
92
83
|
: { env: await runBranchGit(this.root, this.logger) };
|
|
@@ -176,7 +167,7 @@ export class HerdrWorkspace {
|
|
|
176
167
|
}
|
|
177
168
|
export function herdrWorkspace(opts = {}) {
|
|
178
169
|
return {
|
|
179
|
-
kind: '
|
|
170
|
+
kind: 'worktree',
|
|
180
171
|
id: 'herdr',
|
|
181
172
|
requiredModules: [],
|
|
182
173
|
// `deps` carries the conductor logger, so teardown warnings are actually
|
|
@@ -188,10 +179,10 @@ export function herdrWorkspace(opts = {}) {
|
|
|
188
179
|
});
|
|
189
180
|
return new HerdrWorkspace({
|
|
190
181
|
root,
|
|
191
|
-
...(opts.
|
|
192
|
-
...(opts.
|
|
182
|
+
...(opts.worktree_dir ? { worktreeDir: opts.worktree_dir } : {}),
|
|
183
|
+
...(opts.base_branch ? { baseBranch: opts.base_branch } : {}),
|
|
193
184
|
...(opts.execHerdr ? { execHerdr: opts.execHerdr } : {}),
|
|
194
|
-
...(opts.
|
|
185
|
+
...(opts.auto_setup_merge ? { autoSetupMerge: true } : {}),
|
|
195
186
|
...(deps?.logger ? { logger: deps.logger } : {}),
|
|
196
187
|
});
|
|
197
188
|
},
|
|
@@ -0,0 +1,157 @@
|
|
|
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 agent addons supply none.",
|
|
10
|
+
"default": "claude"
|
|
11
|
+
},
|
|
12
|
+
"open": {
|
|
13
|
+
"type": "object",
|
|
14
|
+
"description": "Overview layout of a fresh worktree; when omitted it runs `bakers ui --ticket {identifier}`, `{}` leaves a bare tab. Templates also expand {branch} and {worktree_path}.",
|
|
15
|
+
"properties": {
|
|
16
|
+
"command": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"description": "Command of the overview pane.",
|
|
19
|
+
"default": "bakers ui --ticket {identifier}"
|
|
20
|
+
},
|
|
21
|
+
"panes": {
|
|
22
|
+
"type": "array",
|
|
23
|
+
"items": {
|
|
24
|
+
"$ref": "#/$defs/pane"
|
|
25
|
+
},
|
|
26
|
+
"description": "Extra splits beside the overview pane."
|
|
27
|
+
},
|
|
28
|
+
"tab_label": {
|
|
29
|
+
"type": "string",
|
|
30
|
+
"description": "Tab label template.",
|
|
31
|
+
"default": "{identifier} · {title}"
|
|
32
|
+
},
|
|
33
|
+
"panel_label": {
|
|
34
|
+
"type": "string",
|
|
35
|
+
"description": "Panel label template.",
|
|
36
|
+
"default": "{identifier} · {title}"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"additionalProperties": false
|
|
40
|
+
},
|
|
41
|
+
"root": {
|
|
42
|
+
"type": "string",
|
|
43
|
+
"description": "Main clone path; derived from Git's common directory when omitted."
|
|
44
|
+
},
|
|
45
|
+
"default": {
|
|
46
|
+
"$ref": "#/$defs/state",
|
|
47
|
+
"description": "Layout for every run; a `states` entry beats it, and it beats the built-ins."
|
|
48
|
+
},
|
|
49
|
+
"states": {
|
|
50
|
+
"type": "object",
|
|
51
|
+
"additionalProperties": {
|
|
52
|
+
"$ref": "#/$defs/state"
|
|
53
|
+
},
|
|
54
|
+
"description": "Layout per workflow state; it only lays out panes and does not choose which states are served.",
|
|
55
|
+
"propertyNames": {
|
|
56
|
+
"title": "state"
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"launch_watch": {
|
|
60
|
+
"type": "object",
|
|
61
|
+
"description": "Launch-watch windows: how long a start may take and how soon an agent exit counts as a failed launch.",
|
|
62
|
+
"properties": {
|
|
63
|
+
"timeout_ms": {
|
|
64
|
+
"type": "integer",
|
|
65
|
+
"minimum": 0,
|
|
66
|
+
"description": "Window after start in which an immediate agent exit fails the launch; 0 skips it.",
|
|
67
|
+
"default": 4000
|
|
68
|
+
},
|
|
69
|
+
"start_timeout_ms": {
|
|
70
|
+
"type": "integer",
|
|
71
|
+
"minimum": 0,
|
|
72
|
+
"description": "How long the launch waits for the wrapper to report the start.",
|
|
73
|
+
"default": 60000
|
|
74
|
+
},
|
|
75
|
+
"poll_ms": {
|
|
76
|
+
"type": "integer",
|
|
77
|
+
"minimum": 0,
|
|
78
|
+
"description": "Polling interval of both windows.",
|
|
79
|
+
"default": 50
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
"additionalProperties": false
|
|
83
|
+
},
|
|
84
|
+
"worktree_dir": {
|
|
85
|
+
"type": "string",
|
|
86
|
+
"description": "Directory for new worktrees, relative to `root` or absolute.",
|
|
87
|
+
"default": ".bakers-worktrees"
|
|
88
|
+
},
|
|
89
|
+
"base_branch": {
|
|
90
|
+
"type": "string",
|
|
91
|
+
"description": "Base ref for new branches; when omitted, the remote-tracking branch of the checked-out branch."
|
|
92
|
+
},
|
|
93
|
+
"auto_setup_merge": {
|
|
94
|
+
"type": "boolean",
|
|
95
|
+
"description": "`false` sets Git's `branch.autoSetupMerge=false` in the root repository, so run branches have no upstream and push with `push.default=current` (see workspace-git); `true` leaves Git alone.",
|
|
96
|
+
"default": false
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
"additionalProperties": false,
|
|
100
|
+
"$defs": {
|
|
101
|
+
"pane": {
|
|
102
|
+
"type": "object",
|
|
103
|
+
"properties": {
|
|
104
|
+
"direction": {
|
|
105
|
+
"enum": [
|
|
106
|
+
"right",
|
|
107
|
+
"down"
|
|
108
|
+
],
|
|
109
|
+
"description": "Where the split opens."
|
|
110
|
+
},
|
|
111
|
+
"command": {
|
|
112
|
+
"type": "string",
|
|
113
|
+
"description": "Command the split runs."
|
|
114
|
+
},
|
|
115
|
+
"focus": {
|
|
116
|
+
"type": "boolean",
|
|
117
|
+
"description": "Focus this split after opening."
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
"required": [
|
|
121
|
+
"direction",
|
|
122
|
+
"command"
|
|
123
|
+
],
|
|
124
|
+
"additionalProperties": false,
|
|
125
|
+
"description": "One extra split; not the agent command."
|
|
126
|
+
},
|
|
127
|
+
"state": {
|
|
128
|
+
"type": "object",
|
|
129
|
+
"description": "Per-run layout. Labels expand {identifier}, {title}, {title_slug}, {run_uuid}, {repo_name}, {workspace_path}.",
|
|
130
|
+
"properties": {
|
|
131
|
+
"tab_label": {
|
|
132
|
+
"type": "string",
|
|
133
|
+
"description": "Tab label; must contain {identifier}.",
|
|
134
|
+
"default": "{identifier} · {title_slug}"
|
|
135
|
+
},
|
|
136
|
+
"workspace_label": {
|
|
137
|
+
"type": "string",
|
|
138
|
+
"description": "Workspace label.",
|
|
139
|
+
"default": "{repo_name}"
|
|
140
|
+
},
|
|
141
|
+
"panel_label": {
|
|
142
|
+
"type": "string",
|
|
143
|
+
"description": "Label of the agent panel.",
|
|
144
|
+
"default": "{title}"
|
|
145
|
+
},
|
|
146
|
+
"panes": {
|
|
147
|
+
"type": "array",
|
|
148
|
+
"items": {
|
|
149
|
+
"$ref": "#/$defs/pane"
|
|
150
|
+
},
|
|
151
|
+
"description": "Extra splits; an array replaces the previous one."
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
"additionalProperties": false
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
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.10",
|
|
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.10"
|
|
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.10",
|
|
30
|
+
"@bakers-build/core": "^0.8.1-next.10"
|
|
29
31
|
},
|
|
30
32
|
"bakersBuild": {
|
|
31
|
-
"commit": "
|
|
32
|
-
"channel": "
|
|
33
|
+
"commit": "ceb44a12624feaa85cb2b0c9f84345399b38bf50",
|
|
34
|
+
"channel": "next"
|
|
33
35
|
}
|
|
34
36
|
}
|