@bakers-build/addon-herdr 0.10.1-next.1 → 0.10.1-next.11
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/index.js +9 -7
- package/dist/src/workspace.d.ts +2 -2
- package/dist/src/workspace.js +3 -3
- package/dist/src/worktrees.d.ts +10 -5
- package/dist/src/worktrees.js +28 -14
- package/package.json +5 -5
package/dist/src/index.js
CHANGED
|
@@ -6,7 +6,8 @@ import { applyOpenLayout, DEFAULT_OPEN_LAYOUT, isEmptyLayout, parseFirstPane, pa
|
|
|
6
6
|
import { applyPaneLayout, isRecord, parseJson, } from './pane-layout.js';
|
|
7
7
|
import { AGENT_SHELL_ENV, envArgs } from './panes.js';
|
|
8
8
|
import { deriveHerdrRoot } from './root-anchor.js';
|
|
9
|
-
import {
|
|
9
|
+
import { parseWorkspaceList } from './workspace-list.js';
|
|
10
|
+
import { listWorktrees, openCloneWorkspace, resolveWorktreeEntry, } from './worktrees.js';
|
|
10
11
|
export { DEFAULT_OPEN_LAYOUT } from './open-layout.js';
|
|
11
12
|
export { envArgs } from './panes.js';
|
|
12
13
|
// BB-139: the herdr workspace lives in the same package now (the separate
|
|
@@ -149,10 +150,10 @@ export class HerdrExecutor {
|
|
|
149
150
|
let root = null;
|
|
150
151
|
try {
|
|
151
152
|
const entry = resolveWorktreeEntry(await this.listWorktrees(), ctx.branch, path);
|
|
152
|
-
// A run clone is
|
|
153
|
+
// A run clone is a worktree only the host registered: open it by path.
|
|
153
154
|
const open = entry?.open_workspace_id ??
|
|
154
155
|
(loadRunClone(path)
|
|
155
|
-
? await openCloneWorkspace(this.execHerdr, ctx.branch, path)
|
|
156
|
+
? await openCloneWorkspace(this.execHerdr, this.options.root, ctx.branch, path)
|
|
156
157
|
: undefined);
|
|
157
158
|
if (open) {
|
|
158
159
|
root = parseFirstPane(await this.execHerdr(['pane', 'list', '--workspace', open]));
|
|
@@ -188,9 +189,9 @@ export class HerdrExecutor {
|
|
|
188
189
|
// branch is mutable (a coding agent may switch/rename it) and herdr
|
|
189
190
|
// reports `null` for a detached HEAD, so a branch match is unreliable.
|
|
190
191
|
let workspaceId = await this.findOpenWorkspace(branchName, workspacePath);
|
|
191
|
-
// A run clone is
|
|
192
|
+
// A run clone is a worktree only the host registered: open it by path.
|
|
192
193
|
if (!workspaceId && loadRunClone(workspacePath))
|
|
193
|
-
workspaceId = await openCloneWorkspace(this.execHerdr, branchName, workspacePath);
|
|
194
|
+
workspaceId = await openCloneWorkspace(this.execHerdr, this.options.root, branchName, workspacePath);
|
|
194
195
|
// 2. Open workspace if not already open. Reattach from the PARENT repo
|
|
195
196
|
// root, never the linked worktree path: herdr rejects an open whose
|
|
196
197
|
// --cwd is a linked worktree with `linked_worktree_source` ("New and
|
|
@@ -316,11 +317,12 @@ export class HerdrExecutor {
|
|
|
316
317
|
* The branch worktree is untouched (that is `HerdrWorkspace.remove`).
|
|
317
318
|
*/
|
|
318
319
|
async cleanupRun(branch, runId) {
|
|
319
|
-
// A branch without a herdr worktree may be
|
|
320
|
+
// A branch without a herdr worktree may be an older run clone's plain
|
|
321
|
+
// workspace, found by its label.
|
|
320
322
|
const entry = await this.findWorktreeByBranch(branch);
|
|
321
323
|
const workspaceId = entry
|
|
322
324
|
? (entry.open_workspace_id ?? null)
|
|
323
|
-
: await
|
|
325
|
+
: (parseWorkspaceList(await this.execHerdr(['workspace', 'list'])).find((workspace) => workspace.label === branch)?.workspaceId ?? null);
|
|
324
326
|
if (!workspaceId) {
|
|
325
327
|
return;
|
|
326
328
|
}
|
package/dist/src/workspace.d.ts
CHANGED
|
@@ -56,8 +56,8 @@ export declare class HerdrWorkspace implements BbWorkspace {
|
|
|
56
56
|
ensure(_identifier: string, branch?: string, baseRefOverride?: string): Promise<EnsuredWorkspace>;
|
|
57
57
|
/**
|
|
58
58
|
* The isolating-runtime variant: a fresh run clone at the worktree's stable
|
|
59
|
-
* path,
|
|
60
|
-
* branch;
|
|
59
|
+
* path, opened in herdr as a worktree of the parent. The parent keeps the
|
|
60
|
+
* ticket branch; the host's `.git` there is only the stub that links to it.
|
|
61
61
|
*/
|
|
62
62
|
private ensureClone;
|
|
63
63
|
/**
|
package/dist/src/workspace.js
CHANGED
|
@@ -160,8 +160,8 @@ export class HerdrWorkspace {
|
|
|
160
160
|
}
|
|
161
161
|
/**
|
|
162
162
|
* The isolating-runtime variant: a fresh run clone at the worktree's stable
|
|
163
|
-
* path,
|
|
164
|
-
* branch;
|
|
163
|
+
* path, opened in herdr as a worktree of the parent. The parent keeps the
|
|
164
|
+
* ticket branch; the host's `.git` there is only the stub that links to it.
|
|
165
165
|
*/
|
|
166
166
|
async ensureClone(branch, baseRefOverride) {
|
|
167
167
|
const path = resolve(this.root, this.worktreeDir, branch);
|
|
@@ -201,7 +201,7 @@ export class HerdrWorkspace {
|
|
|
201
201
|
...(target ? { target } : {}),
|
|
202
202
|
shared: this.options.shared ?? false,
|
|
203
203
|
});
|
|
204
|
-
await openCloneWorkspace(this.execHerdr, branch, path);
|
|
204
|
+
await openCloneWorkspace(this.execHerdr, this.root, branch, path);
|
|
205
205
|
return { path, instructions: loadInstructions(path), created, clone };
|
|
206
206
|
}
|
|
207
207
|
/**
|
package/dist/src/worktrees.d.ts
CHANGED
|
@@ -39,12 +39,17 @@ export declare function resolveWorktreeEntry(entries: WorktreeEntry[], branch: s
|
|
|
39
39
|
*/
|
|
40
40
|
export declare function listWorktrees(execHerdr: HerdrExec, root: string | undefined): Promise<WorktreeEntry[]>;
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
43
|
-
* plain workspace
|
|
42
|
+
* The run clone's open herdr workspace: the worktree herdr opened at `path`,
|
|
43
|
+
* or a plain workspace labelled with the branch that a run opened before the
|
|
44
|
+
* host registered its clone as a worktree.
|
|
44
45
|
*/
|
|
45
|
-
export declare function cloneWorkspaceId(execHerdr: HerdrExec, branch: string): Promise<string | null>;
|
|
46
|
-
/**
|
|
47
|
-
|
|
46
|
+
export declare function cloneWorkspaceId(execHerdr: HerdrExec, root: string | undefined, branch: string, path: string): Promise<string | null>;
|
|
47
|
+
/**
|
|
48
|
+
* The run clone's herdr workspace, opened as a worktree of `root` when none is
|
|
49
|
+
* open, so herdr groups it under the repository. Registers the clone as a
|
|
50
|
+
* worktree first, whichever addon made it: every refresh empties its stub.
|
|
51
|
+
*/
|
|
52
|
+
export declare function openCloneWorkspace(execHerdr: HerdrExec, root: string | undefined, branch: string, path: string): Promise<string>;
|
|
48
53
|
/** What the herdr worktree teardown needs. */
|
|
49
54
|
export interface HerdrTeardownDeps {
|
|
50
55
|
/** The parent repo root; absent only for rootless test callers. */
|
package/dist/src/worktrees.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs';
|
|
2
2
|
import { removeGitWorktree, removeRunCloneWorkspace, restoreWritable, } from '@bakers-build/addon-workspace-git';
|
|
3
|
-
import { loadRunClone } from '@bakers-build/core';
|
|
3
|
+
import { loadRunClone, registerRunCloneWorktree, } from '@bakers-build/core';
|
|
4
4
|
import { isRecord, parseJson } from './pane-layout.js';
|
|
5
5
|
import { parseWorkspaceList } from './workspace-list.js';
|
|
6
6
|
export function parseWorktreeList(output) {
|
|
@@ -77,29 +77,43 @@ export async function listWorktrees(execHerdr, root) {
|
|
|
77
77
|
return parseWorktreeList(output);
|
|
78
78
|
}
|
|
79
79
|
/**
|
|
80
|
-
*
|
|
81
|
-
* plain workspace
|
|
80
|
+
* The run clone's open herdr workspace: the worktree herdr opened at `path`,
|
|
81
|
+
* or a plain workspace labelled with the branch that a run opened before the
|
|
82
|
+
* host registered its clone as a worktree.
|
|
82
83
|
*/
|
|
83
|
-
export async function cloneWorkspaceId(execHerdr, branch) {
|
|
84
|
-
|
|
84
|
+
export async function cloneWorkspaceId(execHerdr, root, branch, path) {
|
|
85
|
+
const entry = (await listWorktrees(execHerdr, root)).find((worktree) => normPath(worktree.path) === normPath(path));
|
|
86
|
+
return (entry?.open_workspace_id ??
|
|
87
|
+
parseWorkspaceList(await execHerdr(['workspace', 'list'])).find((workspace) => workspace.label === branch)?.workspaceId ??
|
|
88
|
+
null);
|
|
85
89
|
}
|
|
86
|
-
/**
|
|
87
|
-
|
|
88
|
-
|
|
90
|
+
/**
|
|
91
|
+
* The run clone's herdr workspace, opened as a worktree of `root` when none is
|
|
92
|
+
* open, so herdr groups it under the repository. Registers the clone as a
|
|
93
|
+
* worktree first, whichever addon made it: every refresh empties its stub.
|
|
94
|
+
*/
|
|
95
|
+
export async function openCloneWorkspace(execHerdr, root, branch, path) {
|
|
96
|
+
const clone = loadRunClone(path);
|
|
97
|
+
if (clone)
|
|
98
|
+
registerRunCloneWorktree(clone);
|
|
99
|
+
const open = await cloneWorkspaceId(execHerdr, root, branch, path);
|
|
89
100
|
if (open)
|
|
90
101
|
return open;
|
|
91
102
|
const output = await execHerdr([
|
|
92
|
-
'
|
|
93
|
-
'
|
|
103
|
+
'worktree',
|
|
104
|
+
'open',
|
|
94
105
|
'--cwd',
|
|
106
|
+
root ?? path,
|
|
107
|
+
'--path',
|
|
95
108
|
path,
|
|
96
109
|
'--label',
|
|
97
110
|
branch,
|
|
98
111
|
'--no-focus',
|
|
112
|
+
'--json',
|
|
99
113
|
]);
|
|
100
114
|
let created;
|
|
101
115
|
try {
|
|
102
|
-
const parsed = parseJson(output, '
|
|
116
|
+
const parsed = parseJson(output, 'worktree open');
|
|
103
117
|
created = isRecord(parsed)
|
|
104
118
|
? parsed.result?.workspace
|
|
105
119
|
?.workspace_id
|
|
@@ -110,9 +124,9 @@ export async function openCloneWorkspace(execHerdr, branch, path) {
|
|
|
110
124
|
}
|
|
111
125
|
const id = typeof created === 'string' && created
|
|
112
126
|
? created
|
|
113
|
-
: await cloneWorkspaceId(execHerdr, branch);
|
|
127
|
+
: await cloneWorkspaceId(execHerdr, root, branch, path);
|
|
114
128
|
if (!id)
|
|
115
|
-
throw new Error(`herdr
|
|
129
|
+
throw new Error(`herdr worktree open did not yield a workspace for ${path} (branch ${branch}): ${output.trim()}`);
|
|
116
130
|
return id;
|
|
117
131
|
}
|
|
118
132
|
/**
|
|
@@ -191,7 +205,7 @@ export async function removeHerdrWorktree(deps, branch, worktreePath) {
|
|
|
191
205
|
return 'unverified';
|
|
192
206
|
}
|
|
193
207
|
if (worktreePath && loadRunClone(worktreePath)) {
|
|
194
|
-
const open = await cloneWorkspaceId(execHerdr, branch);
|
|
208
|
+
const open = await cloneWorkspaceId(execHerdr, root, branch, worktreePath);
|
|
195
209
|
if (open) {
|
|
196
210
|
if (!(await ensureFocusSafeToRemove(deps, open)))
|
|
197
211
|
return 'unverified';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bakers-build/addon-herdr",
|
|
3
|
-
"version": "0.10.1-next.
|
|
3
|
+
"version": "0.10.1-next.11",
|
|
4
4
|
"description": "bakers.build herdr integration: spawn executor + per-ticket worktree workspace.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,14 +23,14 @@
|
|
|
23
23
|
"directory": "bakers-cli/addons/herdr"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@bakers-build/addon-workspace-git": "^0.10.1-next.
|
|
26
|
+
"@bakers-build/addon-workspace-git": "^0.10.1-next.11"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@bakers-build/conductor": "^0.10.1-next.
|
|
30
|
-
"@bakers-build/core": "^0.10.1-next.
|
|
29
|
+
"@bakers-build/conductor": "^0.10.1-next.11",
|
|
30
|
+
"@bakers-build/core": "^0.10.1-next.11"
|
|
31
31
|
},
|
|
32
32
|
"bakersBuild": {
|
|
33
|
-
"commit": "
|
|
33
|
+
"commit": "a17110983f32ae027848c103b31ddb07fbf21a8e",
|
|
34
34
|
"channel": "next"
|
|
35
35
|
}
|
|
36
36
|
}
|