baro-ai 0.58.1 → 0.59.0

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/runner.mjs CHANGED
@@ -3713,7 +3713,7 @@ var require_websocket_server = __commonJS({
3713
3713
  });
3714
3714
 
3715
3715
  // ../baro-orchestrator/scripts/runner.ts
3716
- import { spawn } from "child_process";
3716
+ import { execFileSync, spawn } from "child_process";
3717
3717
  import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "fs";
3718
3718
  import { hostname, homedir, tmpdir } from "os";
3719
3719
  import { join } from "path";
@@ -3734,7 +3734,7 @@ var url = process.env.CONTROL_URL ?? "wss://api.baro.jigjoy.ai";
3734
3734
  var token = process.env.RUNNER_TOKEN;
3735
3735
  var httpBase = url.replace(/^ws/, "http").replace(/\/+$/, "");
3736
3736
  var credsPath = join(homedir(), ".baro", "credentials.json");
3737
- var VERSION = "0.58.1";
3737
+ var VERSION = "0.59.0";
3738
3738
  var updateCachePath = join(homedir(), ".baro", "update-check.json");
3739
3739
  function semverLt(a, b) {
3740
3740
  const pa = a.split(".").map(Number);
@@ -3821,26 +3821,44 @@ var runOnce = process.env.BARO_RUN_ONCE === "1";
3821
3821
  function cloneRepo(fullName, token2, emit) {
3822
3822
  return new Promise((resolve, reject) => {
3823
3823
  const dir = mkdtempSync(join(tmpdir(), "baro-clone-"));
3824
- const url2 = `https://x-access-token:${token2}@github.com/${fullName}.git`;
3824
+ const url2 = token2 ? `https://x-access-token:${token2}@github.com/${fullName}.git` : `https://github.com/${fullName}.git`;
3825
3825
  emit({ type: "story_log", agentId: "_git", data: { type: "story_log", id: "_git", line: `cloning ${fullName}\u2026` } });
3826
3826
  const ch = spawn("git", ["clone", "--quiet", url2, dir], { stdio: "ignore" });
3827
3827
  ch.on("close", (code) => code === 0 ? resolve(dir) : reject(new Error(`git clone exit ${code}`)));
3828
3828
  ch.on("error", reject);
3829
3829
  });
3830
3830
  }
3831
+ function captureDiff(cwd, base) {
3832
+ try {
3833
+ execFileSync("git", ["add", "-A"], { cwd });
3834
+ const out = execFileSync("git", ["diff", "--cached", base], { cwd, maxBuffer: 8 * 1024 * 1024 }).toString();
3835
+ return out.length > 2e5 ? out.slice(0, 2e5) + "\n\u2026 (diff truncated)" : out;
3836
+ } catch {
3837
+ return "";
3838
+ }
3839
+ }
3831
3840
  async function runGoal(d, emit, signal) {
3832
3841
  const env = { ...process.env };
3833
3842
  delete env.ANTHROPIC_API_KEY;
3834
3843
  let cwd = workspaceDir;
3835
3844
  let cleanup;
3836
- if (d.repo && d.githubToken) {
3845
+ let diffBase;
3846
+ if (d.repo && (d.githubToken || d.diffOnly)) {
3837
3847
  try {
3838
3848
  cwd = await cloneRepo(d.repo.fullName, d.githubToken, emit);
3839
3849
  } catch (e) {
3840
3850
  return { success: false, durationSecs: 1, error: `clone failed: ${e.message}` };
3841
3851
  }
3842
- env.GH_TOKEN = d.githubToken;
3843
- env.GITHUB_TOKEN = d.githubToken;
3852
+ if (d.diffOnly) {
3853
+ try {
3854
+ diffBase = execFileSync("git", ["rev-parse", "HEAD"], { cwd }).toString().trim();
3855
+ } catch {
3856
+ diffBase = void 0;
3857
+ }
3858
+ } else {
3859
+ env.GH_TOKEN = d.githubToken;
3860
+ env.GITHUB_TOKEN = d.githubToken;
3861
+ }
3844
3862
  cleanup = () => {
3845
3863
  try {
3846
3864
  rmSync(cwd, { recursive: true, force: true });
@@ -3900,6 +3918,9 @@ async function runGoal(d, emit, signal) {
3900
3918
  });
3901
3919
  child.on("error", (e) => resolve({ success: false, durationSecs: secs(), error: e.message }));
3902
3920
  });
3921
+ if (d.diffOnly && diffBase) {
3922
+ outcome.diff = captureDiff(cwd, diffBase);
3923
+ }
3903
3924
  cleanup?.();
3904
3925
  return outcome;
3905
3926
  }