baro-ai 0.22.0 → 0.22.2

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
@@ -7525,6 +7525,55 @@ function extractStderr(e) {
7525
7525
  return e instanceof Error ? e.message : String(e);
7526
7526
  }
7527
7527
 
7528
+ // ../baro-orchestrator/src/dag.ts
7529
+ function buildDag(stories, options = {}) {
7530
+ const onlyIncomplete = options.onlyIncomplete ?? false;
7531
+ const completedIds = new Set(
7532
+ stories.filter((s) => s.passes === true).map((s) => s.id)
7533
+ );
7534
+ const active = onlyIncomplete ? stories.filter((s) => s.passes !== true) : stories.slice();
7535
+ const storyMap = new Map(active.map((s) => [s.id, s]));
7536
+ const inDegree = /* @__PURE__ */ new Map();
7537
+ const dependents = /* @__PURE__ */ new Map();
7538
+ for (const s of active) {
7539
+ const activeDeps = (s.dependsOn ?? []).filter(
7540
+ (d) => storyMap.has(d) && (!onlyIncomplete || !completedIds.has(d))
7541
+ );
7542
+ inDegree.set(s.id, activeDeps.length);
7543
+ for (const dep of activeDeps) {
7544
+ const list = dependents.get(dep) ?? [];
7545
+ list.push(s.id);
7546
+ dependents.set(dep, list);
7547
+ }
7548
+ }
7549
+ const levels = [];
7550
+ let queue = active.filter((s) => (inDegree.get(s.id) ?? 0) === 0);
7551
+ while (queue.length > 0) {
7552
+ queue.sort((a, b) => (a.priority ?? 0) - (b.priority ?? 0));
7553
+ levels.push({ storyIds: queue.map((s) => s.id) });
7554
+ const next = [];
7555
+ for (const s of queue) {
7556
+ const deps = dependents.get(s.id);
7557
+ if (!deps) continue;
7558
+ for (const dependentId of deps) {
7559
+ const remaining = (inDegree.get(dependentId) ?? 0) - 1;
7560
+ inDegree.set(dependentId, remaining);
7561
+ if (remaining === 0) {
7562
+ const story = storyMap.get(dependentId);
7563
+ if (story) next.push(story);
7564
+ }
7565
+ }
7566
+ }
7567
+ queue = next;
7568
+ }
7569
+ const placed = new Set(levels.flatMap((l) => l.storyIds));
7570
+ if (placed.size !== active.length) {
7571
+ const cycled = active.filter((s) => !placed.has(s.id)).map((s) => s.id);
7572
+ throw new Error(`Dependency cycle detected: ${cycled.join(", ")}`);
7573
+ }
7574
+ return levels;
7575
+ }
7576
+
7528
7577
  // ../baro-orchestrator/src/participants/auditor.ts
7529
7578
  import { appendFileSync, mkdirSync } from "fs";
7530
7579
  import { dirname } from "path";
@@ -7901,55 +7950,6 @@ var Auditor = class extends Participant {
7901
7950
  import { existsSync, readFileSync as readFileSync2 } from "fs";
7902
7951
  import { join } from "path";
7903
7952
 
7904
- // ../baro-orchestrator/src/dag.ts
7905
- function buildDag(stories, options = {}) {
7906
- const onlyIncomplete = options.onlyIncomplete ?? false;
7907
- const completedIds = new Set(
7908
- stories.filter((s) => s.passes === true).map((s) => s.id)
7909
- );
7910
- const active = onlyIncomplete ? stories.filter((s) => s.passes !== true) : stories.slice();
7911
- const storyMap = new Map(active.map((s) => [s.id, s]));
7912
- const inDegree = /* @__PURE__ */ new Map();
7913
- const dependents = /* @__PURE__ */ new Map();
7914
- for (const s of active) {
7915
- const activeDeps = (s.dependsOn ?? []).filter(
7916
- (d) => storyMap.has(d) && (!onlyIncomplete || !completedIds.has(d))
7917
- );
7918
- inDegree.set(s.id, activeDeps.length);
7919
- for (const dep of activeDeps) {
7920
- const list = dependents.get(dep) ?? [];
7921
- list.push(s.id);
7922
- dependents.set(dep, list);
7923
- }
7924
- }
7925
- const levels = [];
7926
- let queue = active.filter((s) => (inDegree.get(s.id) ?? 0) === 0);
7927
- while (queue.length > 0) {
7928
- queue.sort((a, b) => (a.priority ?? 0) - (b.priority ?? 0));
7929
- levels.push({ storyIds: queue.map((s) => s.id) });
7930
- const next = [];
7931
- for (const s of queue) {
7932
- const deps = dependents.get(s.id);
7933
- if (!deps) continue;
7934
- for (const dependentId of deps) {
7935
- const remaining = (inDegree.get(dependentId) ?? 0) - 1;
7936
- inDegree.set(dependentId, remaining);
7937
- if (remaining === 0) {
7938
- const story = storyMap.get(dependentId);
7939
- if (story) next.push(story);
7940
- }
7941
- }
7942
- }
7943
- queue = next;
7944
- }
7945
- const placed = new Set(levels.flatMap((l) => l.storyIds));
7946
- if (placed.size !== active.length) {
7947
- const cycled = active.filter((s) => !placed.has(s.id)).map((s) => s.id);
7948
- throw new Error(`Dependency cycle detected: ${cycled.join(", ")}`);
7949
- }
7950
- return levels;
7951
- }
7952
-
7953
7953
  // ../baro-orchestrator/src/prd.ts
7954
7954
  import { readFileSync, writeFileSync } from "fs";
7955
7955
  var STORY_DEFAULTS = { retries: 2 };
@@ -8955,6 +8955,8 @@ ${prompt}`;
8955
8955
  )
8956
8956
  );
8957
8957
  const summary = {
8958
+ success,
8959
+ abortReason,
8958
8960
  completedStories: [...this.globalCompleted],
8959
8961
  failedStories: [...this.globalFailed],
8960
8962
  droppedStories: [...this.globalDropped],
@@ -9917,6 +9919,10 @@ async function orchestrate(config) {
9917
9919
  depends_on: s.dependsOn
9918
9920
  }))
9919
9921
  });
9922
+ const dagLevels = buildDag(prd.userStories).map(
9923
+ (lvl) => lvl.storyIds.map((id) => ({ id }))
9924
+ );
9925
+ emit({ type: "dag", levels: dagLevels });
9920
9926
  }
9921
9927
  env.deliverContextItem(operator, new RunStartRequestItem("orchestrate"));
9922
9928
  const summary = await conductor.done;
@@ -9933,9 +9939,11 @@ async function orchestrate(config) {
9933
9939
  emit({
9934
9940
  type: "done",
9935
9941
  total_time_secs: summary.totalDurationSecs,
9942
+ success: summary.success,
9943
+ abort_reason: summary.abortReason ?? void 0,
9936
9944
  stats: {
9937
9945
  stories_completed: summary.completedStories.length,
9938
- stories_skipped: 0,
9946
+ stories_skipped: summary.failedStories.length + summary.droppedStories.length,
9939
9947
  total_commits: 0,
9940
9948
  files_created: filesCreated,
9941
9949
  files_modified: filesModified
@@ -10282,6 +10290,18 @@ async function main() {
10282
10290
  process.exit(1);
10283
10291
  }
10284
10292
  }
10293
+ process.on("unhandledRejection", (reason) => {
10294
+ const stack = reason?.stack ?? String(reason);
10295
+ process.stderr.write(`[cli] unhandledRejection: ${stack}
10296
+ `);
10297
+ process.exit(1);
10298
+ });
10299
+ process.on("uncaughtException", (err) => {
10300
+ const stack = err?.stack ?? String(err);
10301
+ process.stderr.write(`[cli] uncaughtException: ${stack}
10302
+ `);
10303
+ process.exit(1);
10304
+ });
10285
10305
  main().catch((e) => {
10286
10306
  process.stderr.write(`[cli] unhandled: ${e?.stack ?? String(e)}
10287
10307
  `);