baro-ai 0.23.3 → 0.23.5

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/cli.mjs CHANGED
@@ -9342,7 +9342,14 @@ var Finalizer = class extends Participant {
9342
9342
  startedAtMs = null;
9343
9343
  baseSha;
9344
9344
  branchName = null;
9345
- levels = [];
9345
+ /**
9346
+ * DAG levels keyed by their ordinal as emitted in
9347
+ * LevelStartedItem. We use a Map rather than an array because
9348
+ * Conductor's ordinals are 1-based and would otherwise leave a
9349
+ * `levels[0] = undefined` hole that crashes any `for...of`
9350
+ * iteration (it walks holes too).
9351
+ */
9352
+ levels = /* @__PURE__ */ new Map();
9346
9353
  stories = /* @__PURE__ */ new Map();
9347
9354
  /**
9348
9355
  * Resolves once finalize() has completed (or been short-circuited).
@@ -9374,7 +9381,7 @@ var Finalizer = class extends Participant {
9374
9381
  return;
9375
9382
  }
9376
9383
  if (item instanceof LevelStartedItem) {
9377
- this.levels[item.ordinal] = [...item.storyIds];
9384
+ this.levels.set(item.ordinal, [...item.storyIds]);
9378
9385
  for (const id of item.storyIds) {
9379
9386
  if (!this.stories.has(id)) {
9380
9387
  this.stories.set(id, {
@@ -9408,11 +9415,22 @@ var Finalizer = class extends Participant {
9408
9415
  return;
9409
9416
  }
9410
9417
  if (item instanceof RunCompletedItem) {
9411
- this.finalizePromise = this.finalize(item);
9418
+ this.finalizePromise = this.safeFinalize(item);
9412
9419
  await this.finalizePromise;
9413
9420
  return;
9414
9421
  }
9415
9422
  }
9423
+ async safeFinalize(item) {
9424
+ try {
9425
+ await this.finalize(item);
9426
+ } catch (e) {
9427
+ const msg = e?.stack ?? String(e);
9428
+ this.log(`[finalizer] internal error, skipping PR: ${msg.split("\n")[0]}`);
9429
+ process.stderr.write(`[finalizer] crash: ${msg}
9430
+ `);
9431
+ this.emit(new PrCreatedItem(null, this.branchName ?? "", ""));
9432
+ }
9433
+ }
9416
9434
  /**
9417
9435
  * Resolves once Finalizer has finished handling RunCompletedItem
9418
9436
  * (PR opened, skipped, or failed). Resolves immediately if no run
@@ -9502,14 +9520,17 @@ var Finalizer = class extends Participant {
9502
9520
  // ─── Story ordering & partitioning ──────────────────────────────
9503
9521
  /**
9504
9522
  * Stories returned in DAG order so the table reads top-down the same
9505
- * way the run executed: level 0 first, then level 1, etc. Within a
9506
- * level we sort by id (stable) to keep the table deterministic.
9523
+ * way the run executed: lowest-ordinal level first. Within a level
9524
+ * we sort by id (stable) to keep the table deterministic.
9507
9525
  */
9508
9526
  orderStories() {
9509
9527
  const seen = /* @__PURE__ */ new Set();
9510
9528
  const ordered = [];
9511
- for (const lvl of this.levels) {
9512
- const sorted = [...lvl].sort();
9529
+ const ordinals = [...this.levels.keys()].sort((a, b) => a - b);
9530
+ for (const ord of ordinals) {
9531
+ const ids = this.levels.get(ord);
9532
+ if (!ids) continue;
9533
+ const sorted = [...ids].sort();
9513
9534
  for (const id of sorted) {
9514
9535
  const rec = this.stories.get(id);
9515
9536
  if (rec && !seen.has(id)) {
@@ -9632,13 +9653,14 @@ var Finalizer = class extends Participant {
9632
9653
  lines.push(prd.description.trim());
9633
9654
  lines.push("");
9634
9655
  }
9635
- if (this.levels.length > 0) {
9656
+ if (this.levels.size > 0) {
9636
9657
  lines.push("## Plan");
9637
9658
  lines.push("");
9638
9659
  lines.push("```");
9639
- for (let i = 0; i < this.levels.length; i++) {
9640
- const ids = this.levels[i];
9641
- lines.push(`Level ${i} \u2500\u2500\u2500 ${ids.join(", ")}`);
9660
+ const ordinals = [...this.levels.keys()].sort((a, b) => a - b);
9661
+ for (const ord of ordinals) {
9662
+ const ids = this.levels.get(ord) ?? [];
9663
+ lines.push(`Level ${ord} \u2500\u2500\u2500 ${ids.join(", ")}`);
9642
9664
  }
9643
9665
  lines.push("```");
9644
9666
  lines.push("");