@bakers-build/addon-herdr 0.6.1-next.6 → 0.6.1-next.7
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 +5 -11
- package/dist/src/fs.d.ts +2 -15
- package/dist/src/fs.js +5 -48
- package/dist/src/index.d.ts +13 -162
- package/dist/src/index.js +55 -483
- package/dist/src/open-layout.d.ts +96 -0
- package/dist/src/open-layout.js +162 -0
- package/dist/src/preset.d.ts +0 -1
- package/dist/src/preset.js +3 -6
- package/dist/src/shared.d.ts +2 -1
- package/dist/src/shared.js +2 -1
- package/dist/src/workspace.d.ts +13 -110
- package/dist/src/workspace.js +23 -181
- package/dist/src/worktrees.d.ts +67 -0
- package/dist/src/worktrees.js +223 -0
- package/package.json +5 -5
- package/dist/src/process-host.d.ts +0 -6
- package/dist/src/process-host.js +0 -46
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { OpenWorkspaceContext } from '@bakers-build/conductor/contract';
|
|
2
|
+
import type { ConductorLogger } from '@bakers-build/core';
|
|
3
|
+
import { type PaneSpec } from './config.js';
|
|
4
|
+
import { type HerdrExec } from './pane-layout.js';
|
|
5
|
+
/**
|
|
6
|
+
* Layout applied to a fresh worktree's initial (root) pane (BB-139): `command`
|
|
7
|
+
* launches a tool in the main pane (e.g. `spiceedit`) so the human lands in an
|
|
8
|
+
* editor instead of a bare shell; `panes[]` are optional splits off it. Same
|
|
9
|
+
* shape as the executor's per-state layout minus `tabLabel` — there is only ONE
|
|
10
|
+
* open layout, not a per-ticket-state map.
|
|
11
|
+
*
|
|
12
|
+
* BB-234: `{identifier}`, `{branch}`, `{title}` and `{worktreePath}` expand in
|
|
13
|
+
* `command` **and** in every `panes[].command`. The root command is rendered
|
|
14
|
+
* here before the finished layout reaches `applyPaneLayout` — that shared
|
|
15
|
+
* helper types its root command VERBATIM on purpose, because its other caller
|
|
16
|
+
* (the run tab) pre-assembles `KEY='value' <agent>` env prefixes whose values
|
|
17
|
+
* may legitimately contain braces (spec D2).
|
|
18
|
+
*
|
|
19
|
+
* BB-374: `tabLabel` / `panelLabel` are chrome strings applied after the
|
|
20
|
+
* layout via `herdr tab rename` / `herdr pane rename` ("panel label" = pane
|
|
21
|
+
* label). Defaults ship when keys are absent on an active layout; `open: {}`
|
|
22
|
+
* remains the full opt-out (no command, no splits, no labels). The overview
|
|
23
|
+
* **tab** default is `{identifier} · {title}` with `{title}` capped at
|
|
24
|
+
* {@link OPEN_TAB_TITLE_MAX} so the always-visible tab bar stays readable;
|
|
25
|
+
* the pane/panel label still gets the full title.
|
|
26
|
+
*
|
|
27
|
+
* Unset → {@link DEFAULT_OPEN_LAYOUT}, the ticket deep link. `{}` → the bare
|
|
28
|
+
* empty tab (`applyPaneLayout` issues no calls for an empty layout).
|
|
29
|
+
*/
|
|
30
|
+
export interface OpenLayout {
|
|
31
|
+
command?: string;
|
|
32
|
+
panes?: PaneSpec[];
|
|
33
|
+
/**
|
|
34
|
+
* Overview tab label template. Default: `{identifier} · {title}` (title
|
|
35
|
+
* truncated to {@link OPEN_TAB_TITLE_MAX} when rendering).
|
|
36
|
+
*/
|
|
37
|
+
tabLabel?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Overview root-pane label template (`herdr pane rename`). Default:
|
|
40
|
+
* `{identifier} · {title}` (full title).
|
|
41
|
+
*/
|
|
42
|
+
panelLabel?: string;
|
|
43
|
+
}
|
|
44
|
+
/** Max `{title}` length substituted into the overview **tab** label (BB-374). */
|
|
45
|
+
export declare const OPEN_TAB_TITLE_MAX = 30;
|
|
46
|
+
/** Cap overview-tab `{title}` and append `...` when truncated. */
|
|
47
|
+
export declare function truncateOpenTabTitle(title: string): string;
|
|
48
|
+
/** Default overview tab chrome (BB-374) — always-visible tab bar identity. */
|
|
49
|
+
export declare const DEFAULT_OPEN_TAB_LABEL = "{identifier} \u00B7 {title}";
|
|
50
|
+
/** Default overview pane/panel label template (BB-374). */
|
|
51
|
+
export declare const DEFAULT_OPEN_PANEL_LABEL = "{identifier} \u00B7 {title}";
|
|
52
|
+
/**
|
|
53
|
+
* The shipped default open layout (BB-234): a fresh worktree's initial pane
|
|
54
|
+
* renders the ticket it belongs to instead of an anonymous shell prompt.
|
|
55
|
+
*
|
|
56
|
+
* It lives in **code, not config**, because a default each repo has to opt into
|
|
57
|
+
* would leave the defect in place for every other consumer of this addon; the
|
|
58
|
+
* addon already ships opinionated defaults of this kind (`BUILTIN_DEFAULTS` in
|
|
59
|
+
* `./config.js`), and `bakers ui` is a command of the very host that ships it.
|
|
60
|
+
*
|
|
61
|
+
* `open: {}` is the documented opt-out back to the pre-BB-234 bare tab, so
|
|
62
|
+
* the default is not a one-way door.
|
|
63
|
+
*/
|
|
64
|
+
export declare const DEFAULT_OPEN_LAYOUT: OpenLayout;
|
|
65
|
+
/** `open: {}` — the opt-out back to the bare tab: no command, splits or labels. */
|
|
66
|
+
export declare function isEmptyLayout(open: OpenLayout): boolean;
|
|
67
|
+
/** A workspace's initial pane, and its tab when herdr reported one. */
|
|
68
|
+
export interface RootPane {
|
|
69
|
+
paneId: string;
|
|
70
|
+
tabId?: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The root pane of a `worktree create`/`worktree open` response
|
|
74
|
+
* (`result.root_pane`, tab id from it or `result.tab`), or null when the
|
|
75
|
+
* response carries none.
|
|
76
|
+
*/
|
|
77
|
+
export declare function parseRootPane(output: string, command: string): RootPane | null;
|
|
78
|
+
/**
|
|
79
|
+
* The first pane of `herdr pane list --workspace <id>` — the initial pane of a
|
|
80
|
+
* workspace that was just created and has no other pane yet.
|
|
81
|
+
*
|
|
82
|
+
* shortcut: assumes `result.panes[]` with `pane_id`/`tab_id`, like `tab list`'s
|
|
83
|
+
* `result.tabs[]`; not yet confirmed against a live herdr, upgrade when the
|
|
84
|
+
* live check shows another shape.
|
|
85
|
+
*/
|
|
86
|
+
export declare function parseFirstPane(output: string): RootPane | null;
|
|
87
|
+
/**
|
|
88
|
+
* Apply `open` to a fresh worktree's root pane — by default (BB-234) the
|
|
89
|
+
* ticket's `bakers ui` deep link, so the tab shows the ticket instead of a
|
|
90
|
+
* bare shell. The splits get the worktree checkout as their cwd. BB-374 then
|
|
91
|
+
* renames the overview tab and root pane.
|
|
92
|
+
*
|
|
93
|
+
* Best-effort: a broken layout is logged and swallowed so a startup-command
|
|
94
|
+
* failure can NEVER wedge dispatch.
|
|
95
|
+
*/
|
|
96
|
+
export declare function applyOpenLayout(execHerdr: HerdrExec, logger: ConductorLogger, open: OpenLayout, root: RootPane, path: string, ctx: OpenWorkspaceContext): Promise<void>;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { renderTemplate } from './config.js';
|
|
2
|
+
import { applyPaneLayout, isRecord, parseJson, } from './pane-layout.js';
|
|
3
|
+
/** Max `{title}` length substituted into the overview **tab** label (BB-374). */
|
|
4
|
+
export const OPEN_TAB_TITLE_MAX = 30;
|
|
5
|
+
/** Cap overview-tab `{title}` and append `...` when truncated. */
|
|
6
|
+
export function truncateOpenTabTitle(title) {
|
|
7
|
+
if (title.length <= OPEN_TAB_TITLE_MAX) {
|
|
8
|
+
return title;
|
|
9
|
+
}
|
|
10
|
+
return `${title.slice(0, OPEN_TAB_TITLE_MAX)}...`;
|
|
11
|
+
}
|
|
12
|
+
/** Default overview tab chrome (BB-374) — always-visible tab bar identity. */
|
|
13
|
+
export const DEFAULT_OPEN_TAB_LABEL = '{identifier} · {title}';
|
|
14
|
+
/** Default overview pane/panel label template (BB-374). */
|
|
15
|
+
export const DEFAULT_OPEN_PANEL_LABEL = '{identifier} · {title}';
|
|
16
|
+
/**
|
|
17
|
+
* The shipped default open layout (BB-234): a fresh worktree's initial pane
|
|
18
|
+
* renders the ticket it belongs to instead of an anonymous shell prompt.
|
|
19
|
+
*
|
|
20
|
+
* It lives in **code, not config**, because a default each repo has to opt into
|
|
21
|
+
* would leave the defect in place for every other consumer of this addon; the
|
|
22
|
+
* addon already ships opinionated defaults of this kind (`BUILTIN_DEFAULTS` in
|
|
23
|
+
* `./config.js`), and `bakers ui` is a command of the very host that ships it.
|
|
24
|
+
*
|
|
25
|
+
* `open: {}` is the documented opt-out back to the pre-BB-234 bare tab, so
|
|
26
|
+
* the default is not a one-way door.
|
|
27
|
+
*/
|
|
28
|
+
export const DEFAULT_OPEN_LAYOUT = {
|
|
29
|
+
command: 'bakers ui --ticket {identifier}',
|
|
30
|
+
tabLabel: DEFAULT_OPEN_TAB_LABEL,
|
|
31
|
+
panelLabel: DEFAULT_OPEN_PANEL_LABEL,
|
|
32
|
+
};
|
|
33
|
+
/** `open: {}` — the opt-out back to the bare tab: no command, splits or labels. */
|
|
34
|
+
export function isEmptyLayout(open) {
|
|
35
|
+
return (open.command === undefined &&
|
|
36
|
+
!open.panes?.length &&
|
|
37
|
+
open.tabLabel === undefined &&
|
|
38
|
+
open.panelLabel === undefined);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The root pane of a `worktree create`/`worktree open` response
|
|
42
|
+
* (`result.root_pane`, tab id from it or `result.tab`), or null when the
|
|
43
|
+
* response carries none.
|
|
44
|
+
*/
|
|
45
|
+
export function parseRootPane(output, command) {
|
|
46
|
+
const parsed = parseJson(output, command);
|
|
47
|
+
if (!isRecord(parsed) || !isRecord(parsed.result))
|
|
48
|
+
return null;
|
|
49
|
+
const result = parsed.result;
|
|
50
|
+
const paneId = result.root_pane?.pane_id;
|
|
51
|
+
if (typeof paneId !== 'string' || !paneId)
|
|
52
|
+
return null;
|
|
53
|
+
const tabIdRaw = result.root_pane?.tab_id ?? result.tab?.tab_id;
|
|
54
|
+
const tabId = typeof tabIdRaw === 'string' && tabIdRaw ? tabIdRaw : undefined;
|
|
55
|
+
return tabId !== undefined ? { paneId, tabId } : { paneId };
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The first pane of `herdr pane list --workspace <id>` — the initial pane of a
|
|
59
|
+
* workspace that was just created and has no other pane yet.
|
|
60
|
+
*
|
|
61
|
+
* shortcut: assumes `result.panes[]` with `pane_id`/`tab_id`, like `tab list`'s
|
|
62
|
+
* `result.tabs[]`; not yet confirmed against a live herdr, upgrade when the
|
|
63
|
+
* live check shows another shape.
|
|
64
|
+
*/
|
|
65
|
+
export function parseFirstPane(output) {
|
|
66
|
+
const parsed = parseJson(output, 'pane list');
|
|
67
|
+
const panes = isRecord(parsed)
|
|
68
|
+
? parsed.result?.panes
|
|
69
|
+
: undefined;
|
|
70
|
+
if (!Array.isArray(panes))
|
|
71
|
+
return null;
|
|
72
|
+
const first = panes.find((p) => isRecord(p) && typeof p.pane_id === 'string' && p.pane_id);
|
|
73
|
+
if (!first)
|
|
74
|
+
return null;
|
|
75
|
+
return typeof first.tab_id === 'string' && first.tab_id
|
|
76
|
+
? { paneId: first.pane_id, tabId: first.tab_id }
|
|
77
|
+
: { paneId: first.pane_id };
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Apply `open` to a fresh worktree's root pane — by default (BB-234) the
|
|
81
|
+
* ticket's `bakers ui` deep link, so the tab shows the ticket instead of a
|
|
82
|
+
* bare shell. The splits get the worktree checkout as their cwd. BB-374 then
|
|
83
|
+
* renames the overview tab and root pane.
|
|
84
|
+
*
|
|
85
|
+
* Best-effort: a broken layout is logged and swallowed so a startup-command
|
|
86
|
+
* failure can NEVER wedge dispatch.
|
|
87
|
+
*/
|
|
88
|
+
export async function applyOpenLayout(execHerdr, logger, open, root, path, ctx) {
|
|
89
|
+
try {
|
|
90
|
+
// Render the ROOT command here (spec D2). `applyPaneLayout` types its
|
|
91
|
+
// root command verbatim for the run tab's brace-bearing env-prefixed
|
|
92
|
+
// agent command, so templating it there would corrupt that; the split
|
|
93
|
+
// commands it already renders from the same `vars`.
|
|
94
|
+
const vars = {
|
|
95
|
+
identifier: ctx.identifier,
|
|
96
|
+
branch: ctx.branch,
|
|
97
|
+
title: ctx.title,
|
|
98
|
+
worktreePath: path,
|
|
99
|
+
};
|
|
100
|
+
const layout = {
|
|
101
|
+
...open,
|
|
102
|
+
...(open.command !== undefined
|
|
103
|
+
? { command: renderTemplate(open.command, vars) }
|
|
104
|
+
: {}),
|
|
105
|
+
};
|
|
106
|
+
await applyPaneLayout(execHerdr, root.paneId, layout, path, vars);
|
|
107
|
+
await applyOverviewLabels(execHerdr, logger, open, root, vars);
|
|
108
|
+
}
|
|
109
|
+
catch (err) {
|
|
110
|
+
logger.warn({ branch: ctx.branch, worktree: path, err: String(err) }, 'herdr open-layout failed (best-effort, ignored)');
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Best-effort overview tab + pane renames (BB-374). Skipped for the
|
|
115
|
+
* `open: {}` opt-out. A missing tab id falls back to `pane get`.
|
|
116
|
+
*/
|
|
117
|
+
async function applyOverviewLabels(execHerdr, logger, open, root, vars) {
|
|
118
|
+
if (isEmptyLayout(open)) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
// Tab bar is always visible; cap title length and mark truncation with
|
|
122
|
+
// `...`. Pane/panel label keeps the full title for pane borders.
|
|
123
|
+
const tabVars = {
|
|
124
|
+
...vars,
|
|
125
|
+
title: truncateOpenTabTitle(vars.title ?? ''),
|
|
126
|
+
};
|
|
127
|
+
const tabLabel = renderTemplate(open.tabLabel ?? DEFAULT_OPEN_TAB_LABEL, tabVars);
|
|
128
|
+
const panelLabel = renderTemplate(open.panelLabel ?? DEFAULT_OPEN_PANEL_LABEL, vars);
|
|
129
|
+
let tabId = root.tabId;
|
|
130
|
+
if (!tabId) {
|
|
131
|
+
try {
|
|
132
|
+
tabId = (await resolveTabIdForPane(execHerdr, root.paneId)) ?? undefined;
|
|
133
|
+
}
|
|
134
|
+
catch (err) {
|
|
135
|
+
logger.warn({ paneId: root.paneId, err: String(err) }, 'herdr overview tab id lookup failed (best-effort, ignored)');
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (tabId) {
|
|
139
|
+
try {
|
|
140
|
+
await execHerdr(['tab', 'rename', tabId, tabLabel]);
|
|
141
|
+
}
|
|
142
|
+
catch (err) {
|
|
143
|
+
logger.warn({ tabId, err: String(err) }, 'herdr overview tab rename failed (best-effort, ignored)');
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
try {
|
|
147
|
+
await execHerdr(['pane', 'rename', root.paneId, panelLabel]);
|
|
148
|
+
}
|
|
149
|
+
catch (err) {
|
|
150
|
+
logger.warn({ paneId: root.paneId, err: String(err) }, 'herdr overview pane rename failed (best-effort, ignored)');
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/** `pane get <id>` → `result.pane.tab_id` when present. */
|
|
154
|
+
async function resolveTabIdForPane(execHerdr, paneId) {
|
|
155
|
+
const output = await execHerdr(['pane', 'get', paneId, '--json']);
|
|
156
|
+
const parsed = parseJson(output, 'pane get');
|
|
157
|
+
const tabId = isRecord(parsed)
|
|
158
|
+
? parsed.result?.pane
|
|
159
|
+
?.tab_id
|
|
160
|
+
: undefined;
|
|
161
|
+
return typeof tabId === 'string' && tabId ? tabId : null;
|
|
162
|
+
}
|
package/dist/src/preset.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Preset } from '@bakers-build/conductor/contract';
|
|
2
2
|
export declare const executors: Preset['executors'];
|
|
3
3
|
export declare const workspaces: Preset['workspaces'];
|
|
4
|
-
export declare const processHosts: Preset['processHosts'];
|
|
5
4
|
export declare const hooks: Preset['hooks'];
|
|
6
5
|
export declare const scopes: Preset['scopes'];
|
package/dist/src/preset.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { herdrFrozenMarker } from './frozen-marker.js';
|
|
2
2
|
import { herdrExecutor, herdrWorkspace } from './index.js';
|
|
3
|
-
import { herdrProcessHost } from './process-host.js';
|
|
4
3
|
export const executors = (acc, opts) => [
|
|
5
4
|
...acc,
|
|
6
5
|
herdrExecutor(opts),
|
|
@@ -9,10 +8,8 @@ export const workspaces = (acc, opts) => [
|
|
|
9
8
|
...acc,
|
|
10
9
|
herdrWorkspace(opts),
|
|
11
10
|
];
|
|
12
|
-
export const processHosts = (acc) => [
|
|
13
|
-
...acc,
|
|
14
|
-
herdrProcessHost,
|
|
15
|
-
];
|
|
16
11
|
export const hooks = (acc) => [...acc, herdrFrozenMarker];
|
|
17
|
-
// Hook listeners
|
|
12
|
+
// Hook listeners belong to one project (no machine hook listeners, BB-599). A
|
|
13
|
+
// machine picks herdr as its executor through the machine.config.js `executor`
|
|
14
|
+
// slot instead.
|
|
18
15
|
export const scopes = ['project'];
|
package/dist/src/shared.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
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
|
-
export { truncateOpenTabTitle
|
|
4
|
+
export { truncateOpenTabTitle } from './open-layout.js';
|
|
5
|
+
export { validateBranch } from './workspace.js';
|
|
5
6
|
/** Runs `git <args>`; resolves with stdout, rejects on non-zero exit. */
|
|
6
7
|
export type BaseRefGitExec = (args: string[]) => Promise<string>;
|
|
7
8
|
/**
|
package/dist/src/shared.js
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
export { renderTemplate } from './config.js';
|
|
5
5
|
export { restoreWritable } from './fs.js';
|
|
6
6
|
export { watchLaunch, writeLaunchScript, } from './launch-script.js';
|
|
7
|
-
export { truncateOpenTabTitle
|
|
7
|
+
export { truncateOpenTabTitle } from './open-layout.js';
|
|
8
|
+
export { validateBranch } from './workspace.js';
|
|
8
9
|
/**
|
|
9
10
|
* Resolve (and fetch) the base ref a NEW worktree branch is created from, so a
|
|
10
11
|
* run starts from the pushed remote state, not the host's local branch.
|
package/dist/src/workspace.d.ts
CHANGED
|
@@ -1,69 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type WorktreeGitExec } from '@bakers-build/addon-workspace-git';
|
|
2
|
+
import type { BbWorkspace, EnsuredWorkspace, WorkspacePlugin, WorktreeTeardown } from '@bakers-build/conductor/contract';
|
|
2
3
|
import type { ConductorLogger } from '@bakers-build/core';
|
|
3
|
-
import { type PaneSpec } from './config.js';
|
|
4
4
|
import { type RootGitExec } from './root-anchor.js';
|
|
5
5
|
export type HerdrExec = (args: string[]) => Promise<string>;
|
|
6
6
|
export type GitExec = (args: string[]) => Promise<string>;
|
|
7
|
-
/**
|
|
8
|
-
* Layout applied to the workspace's initial (root) pane on a FRESH worktree open
|
|
9
|
-
* (BB-139): `command` launches a tool in the main pane (e.g. `spiceedit`) so
|
|
10
|
-
* the human lands in an editor instead of a bare shell; `panes[]` are optional
|
|
11
|
-
* splits off it. Same shape as the executor's per-state layout minus `tabLabel`
|
|
12
|
-
* — there is only ONE open layout, not a per-ticket-state map.
|
|
13
|
-
*
|
|
14
|
-
* BB-234: `{identifier}`, `{branch}` and `{worktreePath}` expand in `command`
|
|
15
|
-
* **and** in every `panes[].command`. The root command is rendered here, by
|
|
16
|
-
* `ensure`, before the finished layout reaches `applyPaneLayout` — that shared
|
|
17
|
-
* helper types its root command VERBATIM on purpose, because its other caller
|
|
18
|
-
* (the executor) pre-assembles `KEY='value' <agent>` env prefixes whose values
|
|
19
|
-
* may legitimately contain braces (spec D2).
|
|
20
|
-
*
|
|
21
|
-
* BB-374: `tabLabel` / `panelLabel` are chrome strings applied after the
|
|
22
|
-
* layout via `herdr tab rename` / `herdr pane rename` ("panel label" = pane
|
|
23
|
-
* label). Defaults ship when keys are absent on an active layout; `open: {}`
|
|
24
|
-
* remains the full opt-out (no command, no splits, no labels). The overview
|
|
25
|
-
* **tab** default is `{identifier} · {title}` with `{title}` capped at
|
|
26
|
-
* {@link OPEN_TAB_TITLE_MAX} so the always-visible tab bar stays readable;
|
|
27
|
-
* the pane/panel label still gets the full title.
|
|
28
|
-
*
|
|
29
|
-
* Unset → {@link DEFAULT_OPEN_LAYOUT}, the ticket deep link. `{}` → the bare
|
|
30
|
-
* empty tab (`applyPaneLayout` issues no calls for an empty layout).
|
|
31
|
-
*/
|
|
32
|
-
export interface OpenLayout {
|
|
33
|
-
command?: string;
|
|
34
|
-
panes?: PaneSpec[];
|
|
35
|
-
/**
|
|
36
|
-
* Overview tab label template. Default: `{identifier} · {title}` (title
|
|
37
|
-
* truncated to {@link OPEN_TAB_TITLE_MAX} when rendering).
|
|
38
|
-
*/
|
|
39
|
-
tabLabel?: string;
|
|
40
|
-
/**
|
|
41
|
-
* Overview root-pane label template (`herdr pane rename`). Default:
|
|
42
|
-
* `{identifier} · {title}` (full title).
|
|
43
|
-
*/
|
|
44
|
-
panelLabel?: string;
|
|
45
|
-
}
|
|
46
|
-
/** Max `{title}` length substituted into the overview **tab** label (BB-374). */
|
|
47
|
-
export declare const OPEN_TAB_TITLE_MAX = 30;
|
|
48
|
-
/** Cap overview-tab `{title}` and append `...` when truncated. */
|
|
49
|
-
export declare function truncateOpenTabTitle(title: string): string;
|
|
50
|
-
/** Default overview tab chrome (BB-374) — always-visible tab bar identity. */
|
|
51
|
-
export declare const DEFAULT_OPEN_TAB_LABEL = "{identifier} \u00B7 {title}";
|
|
52
|
-
/** Default overview pane/panel label template (BB-374). */
|
|
53
|
-
export declare const DEFAULT_OPEN_PANEL_LABEL = "{identifier} \u00B7 {title}";
|
|
54
|
-
/**
|
|
55
|
-
* The shipped default open layout (BB-234): a fresh worktree's initial pane
|
|
56
|
-
* renders the ticket it belongs to instead of an anonymous shell prompt.
|
|
57
|
-
*
|
|
58
|
-
* It lives in **code, not config**, because a default each repo has to opt into
|
|
59
|
-
* would leave the defect in place for every other consumer of this addon; the
|
|
60
|
-
* addon already ships opinionated defaults of this kind (`BUILTIN_DEFAULTS` in
|
|
61
|
-
* `./config.js`), and `bakers ui` is a command of the very host that ships it.
|
|
62
|
-
*
|
|
63
|
-
* `open: {}` is the documented opt-out back to the pre-BB-234 bare tab, so
|
|
64
|
-
* the default is not a one-way door.
|
|
65
|
-
*/
|
|
66
|
-
export declare const DEFAULT_OPEN_LAYOUT: OpenLayout;
|
|
67
7
|
export interface HerdrWorkspaceOptions {
|
|
68
8
|
/** Main clone (a git repo): herdr `--cwd` target + worktree base. */
|
|
69
9
|
root: string;
|
|
@@ -75,17 +15,13 @@ export interface HerdrWorkspaceOptions {
|
|
|
75
15
|
* so runs start from the pushed remote state, not the host's local branch.
|
|
76
16
|
*/
|
|
77
17
|
baseBranch?: string;
|
|
78
|
-
/**
|
|
79
|
-
* Startup layout for the initial pane, applied on a FRESH worktree open only
|
|
80
|
-
* (BB-139). Unset → {@link DEFAULT_OPEN_LAYOUT} (`bakers ui --ticket <ID>`,
|
|
81
|
-
* BB-234); `{}` → the bare empty tab is left unchanged.
|
|
82
|
-
*/
|
|
83
|
-
open?: OpenLayout;
|
|
84
18
|
/** Overrideable herdr exec fn — defaults to the real `herdr` binary. */
|
|
85
19
|
execHerdr?: HerdrExec;
|
|
86
20
|
/** Overrideable git exec fn — defaults to the real `git` binary. */
|
|
87
21
|
execGit?: GitExec;
|
|
88
|
-
/**
|
|
22
|
+
/** Overrideable git runner in a cwd, for the teardown fallback. */
|
|
23
|
+
runGit?: WorktreeGitExec;
|
|
24
|
+
/** Optional logger for the teardown (defaults to noop). */
|
|
89
25
|
logger?: ConductorLogger;
|
|
90
26
|
/**
|
|
91
27
|
* Default `false`: before creating a worktree, set `branch.autoSetupMerge=false`
|
|
@@ -101,21 +37,15 @@ export declare class HerdrWorkspace implements BbWorkspace {
|
|
|
101
37
|
private readonly execGit;
|
|
102
38
|
private readonly root;
|
|
103
39
|
private readonly worktreeDir;
|
|
104
|
-
private readonly open;
|
|
105
40
|
private readonly logger;
|
|
106
|
-
|
|
107
|
-
* Root panes captured by a FRESH `ensure` create, keyed by worktree path,
|
|
108
|
-
* awaiting {@link applyOpenLayout} (BB-237). One-shot: consumed on apply.
|
|
109
|
-
* Optional `tabId` powers the BB-374 overview tab rename.
|
|
110
|
-
*/
|
|
111
|
-
private readonly pendingRootPanes;
|
|
41
|
+
private readonly runGit;
|
|
112
42
|
constructor(options: HerdrWorkspaceOptions);
|
|
113
43
|
/**
|
|
114
44
|
* Ensure the branch's worktree + herdr workspace exist.
|
|
115
45
|
*
|
|
116
|
-
* `_identifier` is unused HERE: the worktree is located by branch, and
|
|
117
|
-
*
|
|
118
|
-
*
|
|
46
|
+
* `_identifier` is unused HERE: the worktree is located by branch, and the
|
|
47
|
+
* open layout — the one thing that consumed the identifier, to render
|
|
48
|
+
* `{identifier}` (BB-234) — is applied by `HerdrExecutor.openWorkspace`,
|
|
119
49
|
* which takes it on its own `ctx`. The parameter stays because it is the
|
|
120
50
|
* `BbWorkspace.ensure` contract position (the git workspace does use it).
|
|
121
51
|
* It is still taken as-passed rather than parsed back out of `branch`, which
|
|
@@ -123,37 +53,11 @@ export declare class HerdrWorkspace implements BbWorkspace {
|
|
|
123
53
|
*/
|
|
124
54
|
ensure(_identifier: string, branch?: string, baseRefOverride?: string): Promise<EnsuredWorkspace>;
|
|
125
55
|
/**
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
* The pane's cwd is the worktree checkout, passed explicitly on the splits
|
|
130
|
-
* (the root pane's cwd is already the checkout).
|
|
131
|
-
*
|
|
132
|
-
* BB-374 then renames the overview tab (`{identifier} · {title}` with title
|
|
133
|
-
* capped at {@link OPEN_TAB_TITLE_MAX}) and root pane (full
|
|
134
|
-
* `{identifier} · {title}`) — fresh-create only, same gate as the layout.
|
|
135
|
-
*
|
|
136
|
-
* NO stored pane ⇒ silent no-op. That is the reused-worktree case: `ensure`
|
|
137
|
-
* took the reuse branch, there is no fresh root pane, and re-applying would
|
|
138
|
-
* start a duplicate editor process on reattach (BB-139). The capture is
|
|
139
|
-
* one-shot — consumed here — so a repeat call cannot double-apply and the map
|
|
140
|
-
* cannot grow without bound.
|
|
141
|
-
*
|
|
142
|
-
* Best-effort — mirrors the `fetchBaseRef` pattern: a broken layout is logged
|
|
143
|
-
* and swallowed so a startup-command failure can NEVER wedge dispatch.
|
|
144
|
-
*/
|
|
145
|
-
applyOpenLayout(path: string, ctx: {
|
|
146
|
-
identifier: string;
|
|
147
|
-
branch: string;
|
|
148
|
-
title: string;
|
|
149
|
-
}): Promise<void>;
|
|
150
|
-
/**
|
|
151
|
-
* Best-effort overview tab + pane renames (BB-374). Skipped for the
|
|
152
|
-
* `open: {}` opt-out. A missing create-time tab id falls back to `pane get`.
|
|
56
|
+
* Tear down the branch's worktree and its herdr workspace
|
|
57
|
+
* (`herdr worktree remove --force`); a worktree herdr no longer tracks is
|
|
58
|
+
* torn down with git alone. See {@link removeHerdrWorktree}.
|
|
153
59
|
*/
|
|
154
|
-
|
|
155
|
-
/** `pane get <id>` → `result.pane.tab_id` when present. */
|
|
156
|
-
private resolveTabIdForPane;
|
|
60
|
+
remove(branch: string, worktreePath?: string): Promise<WorktreeTeardown>;
|
|
157
61
|
}
|
|
158
62
|
export declare function herdrWorkspace(opts?: {
|
|
159
63
|
/**
|
|
@@ -163,7 +67,6 @@ export declare function herdrWorkspace(opts?: {
|
|
|
163
67
|
root?: string;
|
|
164
68
|
worktreeDir?: string;
|
|
165
69
|
baseBranch?: string;
|
|
166
|
-
open?: OpenLayout;
|
|
167
70
|
autoSetupMerge?: boolean;
|
|
168
71
|
/** Overrideable git exec for root derivation (tests). */
|
|
169
72
|
execGit?: RootGitExec;
|