@bakers-build/addon-herdr 0.8.1-next.3 → 0.8.1-next.4

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.
@@ -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 } from './workspace-list.js';
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,18 +62,6 @@ 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;
77
65
  private commandFor;
78
66
  }
79
67
  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 } from './workspace-list.js';
16
+ export { parseWorkspaceList, } from './workspace-list.js';
17
17
  async function defaultExec(args, opts) {
18
18
  return exec('herdr', args, opts);
19
19
  }
@@ -313,64 +313,21 @@ export class HerdrExecutor {
313
313
  * The branch worktree is untouched (that is `HerdrWorkspace.remove`).
314
314
  */
315
315
  async cleanupRun(branch, runId) {
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
- }
324
- }
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;
336
- }
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
- }
357
- }
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
316
  const workspaceId = await this.findWorkspaceByBranch(branch);
366
317
  if (!workspaceId) {
367
- return { workspaceId: '', tabIds: new Set() };
318
+ return;
368
319
  }
369
320
  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
- };
321
+ const match = tabs.find((tab) => labelMatchesRun(tab.label, runId));
322
+ if (!match) {
323
+ return; // no tab for this run — quiet best-effort no-op (AC-4)
324
+ }
325
+ try {
326
+ await this.execHerdr(['tab', 'close', match.tabId]);
327
+ }
328
+ catch {
329
+ // ignore — best-effort: a failing tab-close must not abort finalisation
330
+ }
374
331
  }
375
332
  commandFor(input) {
376
333
  const env = Object.entries(input.env ?? {}).map(([key, value]) => {
@@ -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
  /**
@@ -5,7 +5,6 @@ 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.
@@ -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
  }
@@ -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;
@@ -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) };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bakers-build/addon-herdr",
3
- "version": "0.8.1-next.3",
3
+ "version": "0.8.1-next.4",
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.8.1-next.3"
26
+ "@bakers-build/addon-workspace-git": "^0.8.1-next.4"
27
27
  },
28
28
  "peerDependencies": {
29
- "@bakers-build/conductor": "^0.8.1-next.3",
30
- "@bakers-build/core": "^0.8.1-next.3"
29
+ "@bakers-build/conductor": "^0.8.1-next.4",
30
+ "@bakers-build/core": "^0.8.1-next.4"
31
31
  },
32
32
  "bakersBuild": {
33
- "commit": "808f07a3ab9eb6ca6005894ba725623817e79c30",
33
+ "commit": "ba56bec9e0a2d128491f52088a07061938e77832",
34
34
  "channel": "next"
35
35
  }
36
36
  }