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): let publish read pr.json from the implement run when the record predates the saved PR fields
Zhuowei Wangbccad8238ef6
diff --git a/tools/linear-autofix/src/implement.mjs b/tools/linear-autofix/src/implement.mjsindex 098b07b..aba9669 100644--- a/tools/linear-autofix/src/implement.mjs+++ b/tools/linear-autofix/src/implement.mjs@@ -146,10 +146,14 @@ export async function implement(issue, record) {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。`);+ const pr = prMetadata(record);+ if (!pr) {+ return escalate(+ record,+ `没有保存下来的 PR 标题和描述(record.implement.pr 或 run 目录里的 pr.json),无法 publish。`,+ );}+ record.implement = { ...record.implement, pr };if (!fs.existsSync(dir)) {return escalate(record, `worktree 不存在:\`${dir}\``);}@@ -222,6 +226,21 @@ export async function publish(record) {transition(record, "in_review", prInfo.url);}+/**+ * PR title/body for a ticket: saved on the record, or read from the implement+ * run's pr.json (records written before the field existed). Pure apart from+ * the file read.+ */+export function prMetadata(record) {+ const saved = record.implement?.pr;+ if (saved?.title && saved?.body) return saved;+ const runDirectory = record.implement?.runDir;+ if (!runDirectory) return null;+ const fromFile = readJson(path.join(runDirectory, "pr.json"));+ if (!fromFile?.title || !fromFile?.body) return null;+ return { title: String(fromFile.title).trim(), body: String(fromFile.body) };+}+function renderTriageForPrompt(t) {if (!t) return "(none)";return [diff --git a/tools/linear-autofix/src/triage.test.mjs b/tools/linear-autofix/src/triage.test.mjsindex 93d2ac4..6862e84 100644--- a/tools/linear-autofix/src/triage.test.mjs+++ b/tools/linear-autofix/src/triage.test.mjs@@ -1,7 +1,10 @@import assert from "node:assert/strict";import { test } from "node:test";import { renderTriageComment, validateTriage } from "./triage.mjs";-import { composePrBody, PR_FOOTER } from "./implement.mjs";+import { composePrBody, PR_FOOTER, prMetadata } from "./implement.mjs";+import fs from "node:fs";+import os from "node:os";+import path from "node:path";import { parseJsonBlock, renderPrompt } from "./claude.mjs";import { ciStatus } from "./github.mjs";@@ -113,3 +116,21 @@ test("ciStatus folds the rollup into one of four states", () => {"failure",);});++test("prMetadata prefers the saved PR fields and falls back to the run's pr.json", () => {+ const runDir = fs.mkdtempSync(path.join(os.tmpdir(), "autofix-pr-"));+ assert.equal(prMetadata({ implement: { runDir } }), null);+ fs.writeFileSync(+ path.join(runDir, "pr.json"),+ JSON.stringify({ title: " t ", body: "b" }),+ );+ assert.deepEqual(prMetadata({ implement: { runDir } }), {+ title: "t",+ body: "b",+ });+ assert.deepEqual(+ prMetadata({ implement: { runDir, pr: { title: "saved", body: "s" } } }),+ { title: "saved", body: "s" },+ );+ assert.equal(prMetadata({}), null);+});