The fastest browser for AI agents to run browser automation, built for sharing your logged-in browser state with your AI agents, like Codex or Claude Code, without disturbing you. Zero cost, zero config.
JavaScript agent-skillsai-agentautomationbrowserbrowser-automationclaude-codecodexhermes-agentskillsskills-sh
fix(tools): keep hook output when a push fails and add `publish` to redo only push + PR
Zhuowei Wang1867262585b7
diff --git a/tools/linear-autofix/README.md b/tools/linear-autofix/README.mdindex 65d6796..4f4b5df 100644--- a/tools/linear-autofix/README.md+++ b/tools/linear-autofix/README.md@@ -126,7 +126,8 @@ Operations:node src/cli.mjs statusnode src/cli.mjs stop # STOP file: running tick finishes its step, later ticks exitnode src/cli.mjs resume-node src/cli.mjs retry CITRO-2908+node src/cli.mjs publish CITRO-2908 # push failed (E2E)? fix the host, then redo only push + PR+node src/cli.mjs retry CITRO-2908 # start over: re-triage and re-implementlaunchctl bootout gui/$(id -u)/com.citrolabs.linear-autofix # uninstall the schedule```@@ -175,6 +176,23 @@ escalates instead of pushing again. A round whose outcome is `disputed`produces a PR comment and no commit; the next tick sees the same findings andescalates, which is intended: a dispute needs a human.+## When a push fails++`git push` runs the pre-push hook, which runs the real-browser E2E suite on+this host whenever `package/ego-browser/` or `skills/ego-browser/` changed.+A failed push escalates the ticket with the last lines of the hook output; the+full output is in `runs/<ID>/<timestamp>-implement/push.log`. The commits stay+in `worktrees/<ID>`. To see the failure directly:++```sh+cd ~/.local/state/linear-autofix/worktrees/CITRO-2908+git push -u origin zhuoweiwang/citro-2908 # or: (cd package/ego-browser && npm run e2e)+```++Once the host is fixed (ego lite running and in the foreground, nobody+controlling it), `node src/cli.mjs publish CITRO-2908` redoes only the push+and the PR; the review loop takes over from there.+## Limitations- Branch freshness: the bot merges `origin/dev` into its branch (merge commit)diff --git a/tools/linear-autofix/src/cli.mjs b/tools/linear-autofix/src/cli.mjsindex e0d215c..d0caffb 100755--- a/tools/linear-autofix/src/cli.mjs+++ b/tools/linear-autofix/src/cli.mjs@@ -11,7 +11,7 @@ import {} from "./state.mjs";import { reconcile, tick } from "./tick.mjs";import { triage } from "./triage.mjs";-import { implement } from "./implement.mjs";+import { implement, publish } from "./implement.mjs";import { review } from "./review.mjs";import { flushTickLog } from "./journal.mjs";@@ -22,7 +22,8 @@ Usage:linear-autofix triage <CITRO-123> triage one ticket nowlinear-autofix implement <ID> implement a ticket that was triaged as fixlinear-autofix review <ID> run one review-loop check for a ticket's PR- linear-autofix retry <ID> reset a skipped/escalated ticket to "new"+ linear-autofix publish <ID> push the worktree and open the PR again (after a failed push)+ linear-autofix retry <ID> reset a skipped/escalated ticket to "new" (re-triage, re-implement)linear-autofix status list tracked tickets and their stagelinear-autofix stop | resume create / remove the STOP file (kill switch)@@ -94,6 +95,14 @@ async function main([command, arg]) {);return review(issue, record);}+ case "publish": {+ const { record } = await one(arg);+ if (!["escalated", "triaged", "implementing"].includes(record.stage))+ throw new Error(+ `${arg} is in stage ${record.stage}; publish is for a ticket whose push or PR failed`,+ );+ return logged(`publish ${arg}`, () => publish(record));+ }case "retry": {const record = load(arg);if (!record) throw new Error(`no record for ${arg}`);diff --git a/tools/linear-autofix/src/implement.mjs b/tools/linear-autofix/src/implement.mjsindex 5bf3829..f70bb42 100644--- a/tools/linear-autofix/src/implement.mjs+++ b/tools/linear-autofix/src/implement.mjs@@ -7,6 +7,7 @@ import * as github from "./github.mjs";import * as linear from "./linear.mjs";import { note, runDir, transition, worktreePath } from "./state.mjs";import { escalate, FOOTER } from "./actions.mjs";+import { bothTails } from "./proc.mjs";/*** Tools the implementer and the review fixer may use. The list keeps Claude on@@ -132,13 +133,50 @@ export async function implement(issue, record) {`实现阶段产生了 ${ahead} 个提交但没有写出 pr.json,无法开 PR。worktree: \`${dir}\``,);}+ record.implement.pr = { title: pr.title.trim(), body: pr.body };+ return publish(record);+}++/**+ * Push the worktree branch and open (or adopt) the PR, then hand the ticket to+ * the review loop. Also reachable from `linear-autofix publish <ID>` after a+ * human fixed whatever made the push fail (usually the pre-push E2E).+ */+export async function publish(record) {+ const dir = worktreePath(record.identifier);+ const base = `${config.remote}/${config.baseBranch}`;+ const pr = record.implement?.pr;+ if (!pr?.title || !pr?.body) {+ return escalate(record, `没有保存下来的 PR 标题和描述,无法 publish。`);+ }+ if (!fs.existsSync(dir)) {+ return escalate(record, `worktree 不存在:\`${dir}\``);+ }+ if (await git.isDirty(dir)) {+ return escalate(+ record,+ `工作树有未提交的改动,先处理再 publish。worktree: \`${dir}\``,+ );+ }+ const ahead = await git.commitsAhead(dir, base);+ if (ahead === 0) {+ return escalate(record, `分支上没有领先 ${base} 的提交,无法 publish。`);+ }try {await git.push(dir, record.branch);} catch (err) {+ const logDir =+ record.implement?.runDir ?? runDir(record.identifier, "publish");+ const log = path.join(logDir, "push.log");+ fs.writeFileSync(+ log,+ `${err.stdout ?? ""}\n${err.stderr ?? ""}\n${err.message}`,+ );+ const excerpt = bothTails(err.stdout, err.stderr, 60).slice(-2200);return escalate(record,- `push 失败(pre-push 会跑真浏览器 E2E,通常是 E2E 未通过):\n\n\`\`\`\n${String(err.message).slice(0, 2500)}\n\`\`\`\n\nworktree: \`${dir}\``,+ `push 失败(pre-push 会跑真浏览器 E2E,通常是 E2E 未通过):\n\n\`\`\`\n${excerpt}\n\`\`\`\n\n完整输出:\`${log}\`\nworktree: \`${dir}\`\n\n修好环境后运行 \`linear-autofix publish ${record.identifier}\` 只重跑 push 和开 PR,不会重新实现。`,);}note(record, "pushed", await git.recentLog(dir, base));@@ -150,7 +188,7 @@ export async function implement(issue, record) {} else {prInfo = await github.createPr({branch: record.branch,- title: pr.title.trim(),+ title: pr.title,body: composePrBody({body: pr.body,identifier: record.identifier,@@ -168,10 +206,14 @@ export async function implement(issue, record) {draft: prInfo.isDraft ?? draft,};record.review = { rounds: 0 };+ record.consecutiveErrors = 0;if (["Backlog", "Todo"].includes(record.linearState)) {await linear.setState(record, config.linearStateInProgress);}+ if (record.stage === "escalated") {+ await linear.removeLabel(record, config.labels.escalated);+ }await linear.comment(record,`**已开 PR** ${prInfo.url}${draft ? "(draft,待在 Windows 上验证后转正)" : ""}\n\n机器人会跟进 Codex review 和人工评论,直到没有新意见为止。合并由人工完成。\n\n${FOOTER}`,diff --git a/tools/linear-autofix/src/proc.mjs b/tools/linear-autofix/src/proc.mjsindex 8d66b13..66434c2 100644--- a/tools/linear-autofix/src/proc.mjs+++ b/tools/linear-autofix/src/proc.mjs@@ -63,7 +63,7 @@ export function run(} else if (code !== 0 && !allowFailure) {reject(new ProcessError(- `${cmd} ${args.join(" ").slice(0, 200)} exited ${code}${signal ? ` (${signal})` : ""}\n${tail(stderr || stdout)}`,+ `${cmd} ${args.join(" ").slice(0, 200)} exited ${code}${signal ? ` (${signal})` : ""}\n${bothTails(stdout, stderr)}`,result,),);@@ -90,6 +90,11 @@ export function killTree(child, signal) {}}+/** Both streams, each trimmed to its last lines. Hook output (lefthook, E2E) arrives on stdout while git reports on stderr. */+export function bothTails(stdout, stderr, lines = 40) {+ return [tail(stdout, lines), tail(stderr, lines)].filter(Boolean).join("\n");+}+export function tail(text, lines = 40) {return String(text ?? "").trimEnd()diff --git a/tools/linear-autofix/src/proc.test.mjs b/tools/linear-autofix/src/proc.test.mjsindex dc9090a..7903ef9 100644--- a/tools/linear-autofix/src/proc.test.mjs+++ b/tools/linear-autofix/src/proc.test.mjs@@ -27,6 +27,13 @@ test("run resolves with stdout and rejects on a non-zero exit", async () => {assert.equal(tolerated.code, 2);});+test("a failure message carries both stdout and stderr", async () => {+ await assert.rejects(+ run("sh", ["-c", "echo hook-output; echo git-error >&2; exit 1"]),+ (err) => /hook-output[\s\S]*git-error/.test(err.message),+ );+});+test("a timeout kills the child's descendants too", async () => {const pidFile = path.join(fs.mkdtempSync(path.join(os.tmpdir(), "autofix-proc-")),