baro-ai 0.74.5 → 0.74.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/cli.mjs CHANGED
@@ -22243,8 +22243,8 @@ var require_websocket_server = __commonJS({
22243
22243
 
22244
22244
  // ../baro-memory/dist/vectra-store.js
22245
22245
  import { LocalIndex } from "vectra";
22246
- import { readFileSync as readFileSync3, writeFileSync as writeFileSync3, mkdirSync as mkdirSync4, existsSync as existsSync3, renameSync, rmSync as rmSync2, readdirSync as readdirSync2, statSync as statSync2, lstatSync } from "fs";
22247
- import { join as join4 } from "path";
22246
+ import { readFileSync as readFileSync4, writeFileSync as writeFileSync3, mkdirSync as mkdirSync4, existsSync as existsSync4, renameSync, rmSync as rmSync2, readdirSync as readdirSync2, statSync as statSync2, lstatSync } from "fs";
22247
+ import { join as join5 } from "path";
22248
22248
  import { tmpdir as tmpdir2, homedir } from "os";
22249
22249
  async function createMemoryStore(config) {
22250
22250
  const cfg = { ...DEFAULTS, ...config };
@@ -22257,23 +22257,23 @@ async function createMemoryStore(config) {
22257
22257
  if (cfg.disabled) {
22258
22258
  return new NoOpMemoryStore();
22259
22259
  }
22260
- const sessionPath = cfg.sessionPath || join4(tmpdir2(), `baro-memory-${process.pid}-${Date.now()}`);
22260
+ const sessionPath = cfg.sessionPath || join5(tmpdir2(), `baro-memory-${process.pid}-${Date.now()}`);
22261
22261
  validateSessionPath(sessionPath);
22262
22262
  mkdirSync4(sessionPath, { recursive: true });
22263
- const indexPath = join4(sessionPath, "index");
22263
+ const indexPath = join5(sessionPath, "index");
22264
22264
  mkdirSync4(indexPath, { recursive: true });
22265
22265
  const index = new LocalIndex(indexPath);
22266
22266
  if (!await index.isIndexCreated()) {
22267
22267
  await index.createIndex({ version: 1 });
22268
22268
  }
22269
22269
  const transformers = await import("@xenova/transformers");
22270
- transformers.env.cacheDir = process.env.TRANSFORMERS_CACHE || join4(homedir(), ".baro", "models");
22270
+ transformers.env.cacheDir = process.env.TRANSFORMERS_CACHE || join5(homedir(), ".baro", "models");
22271
22271
  const { pipeline: pipeline2 } = transformers;
22272
22272
  const extractor = await pipeline2("feature-extraction", cfg.embeddingModel);
22273
22273
  return new VectraMemoryStore(index, extractor, sessionPath, cfg);
22274
22274
  }
22275
22275
  function validateSessionPath(sessionPath) {
22276
- const resolved = join4(sessionPath);
22276
+ const resolved = join5(sessionPath);
22277
22277
  if (resolved.includes("..")) {
22278
22278
  throw new Error(`Invalid session path (contains ..): ${resolved}`);
22279
22279
  }
@@ -22291,13 +22291,13 @@ function validateSessionPath(sessionPath) {
22291
22291
  }
22292
22292
  function pruneOldSessions(sessionsDir) {
22293
22293
  try {
22294
- if (!existsSync3(sessionsDir))
22294
+ if (!existsSync4(sessionsDir))
22295
22295
  return;
22296
22296
  const now = Date.now();
22297
22297
  for (const entry of readdirSync2(sessionsDir)) {
22298
22298
  if (!entry.startsWith("run-"))
22299
22299
  continue;
22300
- const entryPath = join4(sessionsDir, entry);
22300
+ const entryPath = join5(sessionsDir, entry);
22301
22301
  try {
22302
22302
  const stat2 = lstatSync(entryPath);
22303
22303
  if (stat2.isSymbolicLink())
@@ -22354,10 +22354,10 @@ var init_vectra_store = __esm({
22354
22354
  this.index = index;
22355
22355
  this.extractor = extractor;
22356
22356
  this.sessionPath = sessionPath;
22357
- this.indexPath = join4(sessionPath, "index");
22358
- this.indexFilePath = join4(this.indexPath, "index.json");
22359
- this.cachePath = join4(sessionPath, "cache.json");
22360
- this.lockPath = join4(sessionPath, "cache.lock");
22357
+ this.indexPath = join5(sessionPath, "index");
22358
+ this.indexFilePath = join5(this.indexPath, "index.json");
22359
+ this.cachePath = join5(sessionPath, "cache.json");
22360
+ this.lockPath = join5(sessionPath, "cache.lock");
22361
22361
  this.config = config;
22362
22362
  }
22363
22363
  /**
@@ -22369,7 +22369,7 @@ var init_vectra_store = __esm({
22369
22369
  */
22370
22370
  refreshIndexIfChanged() {
22371
22371
  try {
22372
- if (!existsSync3(this.indexFilePath))
22372
+ if (!existsSync4(this.indexFilePath))
22373
22373
  return;
22374
22374
  const mtimeMs = statSync2(this.indexFilePath).mtimeMs;
22375
22375
  if (mtimeMs === this.lastIndexMtimeMs)
@@ -22583,8 +22583,8 @@ ${result.content}
22583
22583
  */
22584
22584
  loadCache() {
22585
22585
  try {
22586
- if (existsSync3(this.cachePath)) {
22587
- const raw = readFileSync3(this.cachePath, "utf-8");
22586
+ if (existsSync4(this.cachePath)) {
22587
+ const raw = readFileSync4(this.cachePath, "utf-8");
22588
22588
  if (raw.trim()) {
22589
22589
  return JSON.parse(raw);
22590
22590
  }
@@ -22610,7 +22610,7 @@ ${result.content}
22610
22610
  }
22611
22611
  } finally {
22612
22612
  try {
22613
- if (existsSync3(this.lockPath))
22613
+ if (existsSync4(this.lockPath))
22614
22614
  rmSync2(this.lockPath);
22615
22615
  } catch {
22616
22616
  }
@@ -22669,13 +22669,13 @@ var init_dist2 = __esm({
22669
22669
  });
22670
22670
 
22671
22671
  // ../baro-orchestrator/scripts/cli.ts
22672
- import { existsSync as existsSync6 } from "fs";
22672
+ import { existsSync as existsSync7 } from "fs";
22673
22673
  import { resolve as resolve3 } from "path";
22674
22674
 
22675
22675
  // ../baro-orchestrator/src/orchestrate.ts
22676
22676
  import { mkdirSync as mkdirSync7 } from "fs";
22677
22677
  import { hostname } from "os";
22678
- import { dirname as dirname3, join as join7 } from "path";
22678
+ import { dirname as dirname3, join as join8 } from "path";
22679
22679
 
22680
22680
  // ../../node_modules/openai/internal/tslib.mjs
22681
22681
  function __classPrivateFieldSet(receiver, state, value, kind, f3) {
@@ -42759,11 +42759,73 @@ ${userPrompt}`;
42759
42759
  };
42760
42760
 
42761
42761
  // ../baro-orchestrator/src/participants/finalizer.ts
42762
- import { execFile as execFile4 } from "child_process";
42762
+ import { execFile as execFile5 } from "child_process";
42763
42763
  import { mkdirSync as mkdirSync3, writeFileSync as writeFileSync2 } from "fs";
42764
+ import { join as join4 } from "path";
42765
+ import { promisify as promisify6 } from "util";
42766
+
42767
+ // ../baro-orchestrator/src/verify.ts
42768
+ import { execFile as execFile4 } from "child_process";
42769
+ import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
42764
42770
  import { join as join3 } from "path";
42765
42771
  import { promisify as promisify5 } from "util";
42766
42772
  var execFileAsync2 = promisify5(execFile4);
42773
+ var TIMEOUT_MS = 5 * 6e4;
42774
+ var TAIL_BYTES = 1500;
42775
+ function detectCommands(cwd) {
42776
+ const cmds = [];
42777
+ const pkgPath = join3(cwd, "package.json");
42778
+ if (existsSync3(pkgPath)) {
42779
+ let scripts = {};
42780
+ try {
42781
+ scripts = JSON.parse(readFileSync3(pkgPath, "utf8"))?.scripts ?? {};
42782
+ } catch {
42783
+ scripts = {};
42784
+ }
42785
+ const pm = existsSync3(join3(cwd, "pnpm-lock.yaml")) ? "pnpm" : existsSync3(join3(cwd, "yarn.lock")) ? "yarn" : "npm";
42786
+ if (typeof scripts.build === "string") cmds.push({ label: `${pm} run build`, tool: pm, args: ["run", "build"] });
42787
+ if (typeof scripts.test === "string") cmds.push({ label: `${pm} run test`, tool: pm, args: ["run", "test"] });
42788
+ }
42789
+ if (existsSync3(join3(cwd, "Cargo.toml"))) {
42790
+ cmds.push({ label: "cargo build", tool: "cargo", args: ["build"] });
42791
+ cmds.push({ label: "cargo test", tool: "cargo", args: ["test"] });
42792
+ }
42793
+ if (existsSync3(join3(cwd, "go.mod"))) {
42794
+ cmds.push({ label: "go build ./...", tool: "go", args: ["build", "./..."] });
42795
+ cmds.push({ label: "go test ./...", tool: "go", args: ["test", "./..."] });
42796
+ }
42797
+ return cmds;
42798
+ }
42799
+ async function runCmd(cwd, c) {
42800
+ try {
42801
+ await execFileAsync2(c.tool, c.args, {
42802
+ cwd,
42803
+ timeout: TIMEOUT_MS,
42804
+ maxBuffer: 8 * 1024 * 1024,
42805
+ shell: process.platform === "win32"
42806
+ });
42807
+ return { status: "pass" };
42808
+ } catch (e2) {
42809
+ if (e2.code === "ENOENT") return { status: "skipped" };
42810
+ const err = e2;
42811
+ const combined = `${err.stdout ?? ""}${err.stderr ?? ""}`.trim() || err.message || "";
42812
+ return { status: "fail", tail: combined.slice(-TAIL_BYTES) };
42813
+ }
42814
+ }
42815
+ async function verifyBuild(cwd) {
42816
+ const failures = [];
42817
+ let ran = false;
42818
+ for (const c of detectCommands(cwd)) {
42819
+ const outcome = await runCmd(cwd, c);
42820
+ if (outcome.status === "skipped") continue;
42821
+ ran = true;
42822
+ if (outcome.status === "fail") failures.push({ cmd: c.label, tail: outcome.tail });
42823
+ }
42824
+ return { ran, ok: failures.length === 0, failures };
42825
+ }
42826
+
42827
+ // ../baro-orchestrator/src/participants/finalizer.ts
42828
+ var execFileAsync3 = promisify6(execFile5);
42767
42829
  var Finalizer = class extends BaseObserver {
42768
42830
  opts;
42769
42831
  envRef = null;
@@ -42936,12 +42998,22 @@ var Finalizer = class extends BaseObserver {
42936
42998
  const { passed, failed } = this.partition(orderedStories);
42937
42999
  const filesStats = await this.collectFileStats();
42938
43000
  const totalSecs = run.totalDurationSecs;
42939
- const checkpoint = !run.success;
43001
+ this.log("[finalizer] verifying build\u2026");
43002
+ const verify = await verifyBuild(this.opts.cwd);
43003
+ if (!verify.ran) {
43004
+ this.log("[finalizer] nothing to verify (no build/test)");
43005
+ } else if (verify.ok) {
43006
+ this.log("[finalizer] \u2713 build-verified");
43007
+ } else {
43008
+ this.log(`[finalizer] \u26A0 verification failed: ${verify.failures[0]?.cmd ?? "build/test"}`);
43009
+ }
43010
+ const checkpoint = !run.success || verify.ran && !verify.ok;
42940
43011
  const title = this.buildPrTitle(prd, passed.length, orderedStories.length, checkpoint);
42941
43012
  const body = this.buildPrBody({
42942
43013
  prd,
42943
43014
  run,
42944
43015
  checkpoint,
43016
+ verify,
42945
43017
  orderedStories,
42946
43018
  passed,
42947
43019
  failed,
@@ -42987,18 +43059,18 @@ var Finalizer = class extends BaseObserver {
42987
43059
  const adrs = parseAdrs(doc);
42988
43060
  if (adrs.length === 0) return;
42989
43061
  try {
42990
- const dir = join3(this.opts.cwd, "adr");
43062
+ const dir = join4(this.opts.cwd, "adr");
42991
43063
  mkdirSync3(dir, { recursive: true });
42992
43064
  for (const a of adrs) {
42993
43065
  const num = a.num.padStart(4, "0");
42994
- writeFileSync2(join3(dir, `${num}-${slugify(a.title)}.md`), `# ADR-${num}: ${a.title}
43066
+ writeFileSync2(join4(dir, `${num}-${slugify(a.title)}.md`), `# ADR-${num}: ${a.title}
42995
43067
 
42996
43068
  ${a.body}
42997
43069
  `);
42998
43070
  }
42999
- await execFileAsync2("git", ["add", "adr"], { cwd: this.opts.cwd });
43071
+ await execFileAsync3("git", ["add", "adr"], { cwd: this.opts.cwd });
43000
43072
  try {
43001
- await execFileAsync2(
43073
+ await execFileAsync3(
43002
43074
  "git",
43003
43075
  ["commit", "-m", `docs: architecture decision records (${adrs.length})
43004
43076
 
@@ -43059,7 +43131,7 @@ ${BARO_COAUTHOR_TRAILER}`],
43059
43131
  async collectCommitsSinceBase() {
43060
43132
  if (!this.baseSha) return [];
43061
43133
  try {
43062
- const { stdout } = await execFileAsync2(
43134
+ const { stdout } = await execFileAsync3(
43063
43135
  "git",
43064
43136
  ["log", `${this.baseSha}..HEAD`, "--pretty=format:%H%x09%s"],
43065
43137
  { cwd: this.opts.cwd }
@@ -43075,7 +43147,7 @@ ${BARO_COAUTHOR_TRAILER}`],
43075
43147
  async collectFileStats() {
43076
43148
  if (!this.baseSha) return { created: 0, modified: 0 };
43077
43149
  try {
43078
- const { stdout } = await execFileAsync2(
43150
+ const { stdout } = await execFileAsync3(
43079
43151
  "git",
43080
43152
  ["diff", "--name-status", this.baseSha, "HEAD"],
43081
43153
  { cwd: this.opts.cwd }
@@ -43094,7 +43166,7 @@ ${BARO_COAUTHOR_TRAILER}`],
43094
43166
  }
43095
43167
  async detectBranch() {
43096
43168
  try {
43097
- const { stdout } = await execFileAsync2(
43169
+ const { stdout } = await execFileAsync3(
43098
43170
  "git",
43099
43171
  ["branch", "--show-current"],
43100
43172
  { cwd: this.opts.cwd }
@@ -43106,7 +43178,7 @@ ${BARO_COAUTHOR_TRAILER}`],
43106
43178
  }
43107
43179
  async detectDefaultBaseBranch() {
43108
43180
  try {
43109
- const { stdout } = await execFileAsync2(
43181
+ const { stdout } = await execFileAsync3(
43110
43182
  "gh",
43111
43183
  ["repo", "view", "--json", "defaultBranchRef", "--jq", ".defaultBranchRef.name"],
43112
43184
  { cwd: this.opts.cwd }
@@ -43116,7 +43188,7 @@ ${BARO_COAUTHOR_TRAILER}`],
43116
43188
  } catch {
43117
43189
  }
43118
43190
  try {
43119
- const { stdout } = await execFileAsync2(
43191
+ const { stdout } = await execFileAsync3(
43120
43192
  "git",
43121
43193
  ["symbolic-ref", "--short", "refs/remotes/origin/HEAD"],
43122
43194
  { cwd: this.opts.cwd }
@@ -43147,6 +43219,20 @@ ${BARO_COAUTHOR_TRAILER}`],
43147
43219
  lines.push("> **Checkpoint PR:** baro produced branch changes, but the run failed during verification/retry/replan. Review this as a candidate fix, not a fully verified completion.");
43148
43220
  lines.push("");
43149
43221
  }
43222
+ if (args.verify.ran && !args.verify.ok) {
43223
+ lines.push("## \u26A0 Build/test verification failed");
43224
+ lines.push("");
43225
+ lines.push("The fully-merged branch did not pass an objective build/test check:");
43226
+ lines.push("");
43227
+ for (const f3 of args.verify.failures) {
43228
+ lines.push(`**\`${f3.cmd}\`**`);
43229
+ lines.push("");
43230
+ lines.push("```");
43231
+ lines.push(f3.tail.trim() || "(no output captured)");
43232
+ lines.push("```");
43233
+ lines.push("");
43234
+ }
43235
+ }
43150
43236
  if (prd?.description) {
43151
43237
  lines.push("## Goal");
43152
43238
  lines.push("");
@@ -43209,7 +43295,7 @@ ${BARO_COAUTHOR_TRAILER}`],
43209
43295
  }
43210
43296
  async hasGhBinary() {
43211
43297
  try {
43212
- await execFileAsync2("gh", ["--version"], { cwd: this.opts.cwd });
43298
+ await execFileAsync3("gh", ["--version"], { cwd: this.opts.cwd });
43213
43299
  return true;
43214
43300
  } catch {
43215
43301
  return false;
@@ -43221,7 +43307,7 @@ ${BARO_COAUTHOR_TRAILER}`],
43221
43307
  // surfaces the real outcome.
43222
43308
  async pushBranch(branch) {
43223
43309
  try {
43224
- await execFileAsync2("git", ["push", "origin", branch], { cwd: this.opts.cwd });
43310
+ await execFileAsync3("git", ["push", "origin", branch], { cwd: this.opts.cwd });
43225
43311
  } catch (e2) {
43226
43312
  const detail = (e2.stderr ?? e2.message).split("\n")[0]?.trim();
43227
43313
  this.log(`[finalizer] pre-PR push: ${detail}`);
@@ -43229,7 +43315,7 @@ ${BARO_COAUTHOR_TRAILER}`],
43229
43315
  }
43230
43316
  async openPr(args) {
43231
43317
  try {
43232
- const { stdout } = await execFileAsync2(
43318
+ const { stdout } = await execFileAsync3(
43233
43319
  "gh",
43234
43320
  [
43235
43321
  "pr",
@@ -44226,10 +44312,10 @@ function tokenizeHints(prompt) {
44226
44312
 
44227
44313
  // ../baro-orchestrator/src/participants/memory-librarian.ts
44228
44314
  import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync5 } from "fs";
44229
- import { join as join5 } from "path";
44315
+ import { join as join6 } from "path";
44230
44316
  var DEBUG = process.env.BARO_DEBUG?.includes("memory") ?? false;
44231
- var LOG_DIR = join5(process.env.HOME || "/tmp", ".baro", "runs");
44232
- var LOG_FILE = join5(LOG_DIR, `memory-${Date.now()}.log`);
44317
+ var LOG_DIR = join6(process.env.HOME || "/tmp", ".baro", "runs");
44318
+ var LOG_FILE = join6(LOG_DIR, `memory-${Date.now()}.log`);
44233
44319
  try {
44234
44320
  mkdirSync5(LOG_DIR, { recursive: true });
44235
44321
  } catch {
@@ -48014,8 +48100,8 @@ var StoryFactory = class extends BaseObserver {
48014
48100
  };
48015
48101
 
48016
48102
  // ../baro-orchestrator/src/participants/surgeon.ts
48017
- import { execFile as execFile5 } from "child_process";
48018
- import { promisify as promisify6 } from "util";
48103
+ import { execFile as execFile6 } from "child_process";
48104
+ import { promisify as promisify7 } from "util";
48019
48105
  var CritiqueLog = class {
48020
48106
  constructor(keep = 3) {
48021
48107
  this.keep = keep;
@@ -48032,7 +48118,7 @@ var CritiqueLog = class {
48032
48118
  return this.byStory.get(storyId) ?? [];
48033
48119
  }
48034
48120
  };
48035
- var execFileAsync3 = promisify6(execFile5);
48121
+ var execFileAsync4 = promisify7(execFile6);
48036
48122
  var SURGEON_SYSTEM_PROMPT = `You are the Surgeon \u2014 an autonomous planner that adapts a software-project
48037
48123
  DAG when stories fail. Given:
48038
48124
  1. A snapshot of the current PRD (project, story list with dependencies +
@@ -48164,7 +48250,7 @@ var Surgeon = class extends BaseObserver {
48164
48250
  this.critiques.forStory(failure.storyId)
48165
48251
  );
48166
48252
  try {
48167
- const { stdout } = await execFileAsync3(
48253
+ const { stdout } = await execFileAsync4(
48168
48254
  this.opts.claudeBin,
48169
48255
  [
48170
48256
  "--print",
@@ -48895,8 +48981,8 @@ async function orchestrate(config) {
48895
48981
  const useLibrarian = config.withLibrarian ?? true;
48896
48982
  const useSentry = config.withSentry ?? true;
48897
48983
  const useMemory = config.withMemory ?? true;
48898
- const sessionsDir = join7(process.env.HOME || "/tmp", ".baro", "sessions");
48899
- const memorySessionPath = useMemory ? join7(sessionsDir, runId, "memory") : void 0;
48984
+ const sessionsDir = join8(process.env.HOME || "/tmp", ".baro", "sessions");
48985
+ const memorySessionPath = useMemory ? join8(sessionsDir, runId, "memory") : void 0;
48900
48986
  if (useMemory) {
48901
48987
  try {
48902
48988
  const { pruneOldSessions: pruneOldSessions2 } = await Promise.resolve().then(() => (init_dist2(), dist_exports));
@@ -49439,7 +49525,7 @@ async function main() {
49439
49525
  }
49440
49526
  const cwd = resolve3(args.cwd);
49441
49527
  const prdPath = resolve3(cwd, args.prd);
49442
- if (!existsSync6(prdPath)) {
49528
+ if (!existsSync7(prdPath)) {
49443
49529
  process.stderr.write(`[cli] PRD not found: ${prdPath}
49444
49530
  `);
49445
49531
  process.exit(2);