baro-ai 0.63.0 → 0.64.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 +49 -1
- package/dist/runner.mjs.map +1 -1
- package/package.json +1 -1
package/dist/runner.mjs
CHANGED
|
@@ -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.
|
|
3737
|
+
var VERSION = "0.64.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);
|
|
@@ -3844,6 +3844,7 @@ async function runGoal(d, emit, signal) {
|
|
|
3844
3844
|
let cleanup;
|
|
3845
3845
|
let diffBase;
|
|
3846
3846
|
let scratch = false;
|
|
3847
|
+
let prUrl = null;
|
|
3847
3848
|
if (d.repo && (d.githubToken || d.diffOnly)) {
|
|
3848
3849
|
try {
|
|
3849
3850
|
cwd = await cloneRepo(d.repo.fullName, d.githubToken, emit);
|
|
@@ -3922,6 +3923,7 @@ async function runGoal(d, emit, signal) {
|
|
|
3922
3923
|
if (ev.type === "story_complete") passed++;
|
|
3923
3924
|
else if (ev.type === "story_error") failed++;
|
|
3924
3925
|
else if (ev.type === "done") doneSuccess = !!ev.success;
|
|
3926
|
+
else if (ev.type === "finalize_complete") prUrl = ev.data?.pr_url ?? ev.pr_url ?? prUrl;
|
|
3925
3927
|
const d2 = ev.data ?? {};
|
|
3926
3928
|
const msg = d2.error ?? d2.message ?? ev.error;
|
|
3927
3929
|
if (typeof msg === "string" && msg.trim() && (String(ev.type).includes("error") || String(ev.type).includes("fail") || ev.type === "done" && ev.success === false)) {
|
|
@@ -3951,9 +3953,55 @@ async function runGoal(d, emit, signal) {
|
|
|
3951
3953
|
if ((d.diffOnly || scratch) && diffBase) {
|
|
3952
3954
|
outcome.diff = captureDiff(cwd, diffBase);
|
|
3953
3955
|
}
|
|
3956
|
+
if (process.env.BARO_PR_DOCTOR === "1" && d.repo && !d.diffOnly && !scratch && outcome.success && prUrl) {
|
|
3957
|
+
try {
|
|
3958
|
+
await watchCi(cwd, emit, signal);
|
|
3959
|
+
} catch (e) {
|
|
3960
|
+
emit({ type: "story_log", agentId: "_ci", data: { type: "story_log", id: "_ci", line: `[pr-doctor] CI watch error: ${e.message}` } });
|
|
3961
|
+
}
|
|
3962
|
+
}
|
|
3954
3963
|
cleanup?.();
|
|
3955
3964
|
return outcome;
|
|
3956
3965
|
}
|
|
3966
|
+
function gh(args, cwd) {
|
|
3967
|
+
try {
|
|
3968
|
+
const out = execFileSync("gh", args, { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] });
|
|
3969
|
+
return { code: 0, out };
|
|
3970
|
+
} catch (e) {
|
|
3971
|
+
const err = e;
|
|
3972
|
+
return {
|
|
3973
|
+
code: typeof err.status === "number" ? err.status : 1,
|
|
3974
|
+
out: `${err.stdout?.toString() ?? ""}${err.stderr?.toString() ?? ""}`
|
|
3975
|
+
};
|
|
3976
|
+
}
|
|
3977
|
+
}
|
|
3978
|
+
async function watchCi(cwd, emit, signal) {
|
|
3979
|
+
const log = (line) => emit({ type: "story_log", agentId: "_ci", data: { type: "story_log", id: "_ci", line } });
|
|
3980
|
+
const timeoutMs = Number(process.env.BARO_PR_DOCTOR_CI_TIMEOUT ?? 900) * 1e3;
|
|
3981
|
+
const deadline = Date.now() + timeoutMs;
|
|
3982
|
+
log("watching the pull request's CI\u2026");
|
|
3983
|
+
while (Date.now() < deadline && !signal.aborted) {
|
|
3984
|
+
const r = gh(["pr", "checks"], cwd);
|
|
3985
|
+
const out = r.out.toLowerCase();
|
|
3986
|
+
if (out.includes("no checks") || out.includes("no commit statuses")) {
|
|
3987
|
+
log("no CI configured on this repo \u2014 nothing to watch.");
|
|
3988
|
+
return;
|
|
3989
|
+
}
|
|
3990
|
+
if (r.code === 0) {
|
|
3991
|
+
log("\u2713 CI is green \u2014 all checks passed.");
|
|
3992
|
+
return;
|
|
3993
|
+
}
|
|
3994
|
+
if (r.code === 8 || out.includes("pending") || out.includes("in progress") || out.includes("queued")) {
|
|
3995
|
+
await new Promise((res) => setTimeout(res, 2e4));
|
|
3996
|
+
continue;
|
|
3997
|
+
}
|
|
3998
|
+
const fails = r.out.split("\n").filter((l) => /fail|error|✗|×/i.test(l)).slice(0, 8).join("\n");
|
|
3999
|
+
log(`\u2717 CI is failing:
|
|
4000
|
+
${fails || r.out.slice(-500)}`);
|
|
4001
|
+
return;
|
|
4002
|
+
}
|
|
4003
|
+
log("CI watch timed out while checks were still pending.");
|
|
4004
|
+
}
|
|
3957
4005
|
var rejected;
|
|
3958
4006
|
var currentWs = null;
|
|
3959
4007
|
var inflight = /* @__PURE__ */ new Map();
|