Skip to content

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.

feat(tools): show what the daemon is doing in its log

Zhuowei Wangfba7ba00343a
diff --git a/tools/linear-autofix/README.md b/tools/linear-autofix/README.md
index 6a8b878..6724165 100644
--- a/tools/linear-autofix/README.md
+++ b/tools/linear-autofix/README.md
@@ -158,6 +158,25 @@ or reset in that checkout would move the branch it is about to push.
Updating the bot: `git pull` on `dev`; the next tick picks up the new code.
State in `~/.local/state/linear-autofix` survives updates.
+## Local log
+
+`tick` and `daemon` print one timestamped line per step to stdout. The launchd
+agent and the `screen` command above send it to `/tmp/linear-autofix.log`:
+
+```
+2026-11-02 12:03:45 3 assigned issue(s) in Backlog/Todo/In Progress/Pending Review
+2026-11-02 12:03:45 stages: in_review 1, triaged 1, skipped 1
+2026-11-02 12:03:58 [CITRO-2908 implement] claude started, budget $25, limit 90 min
+2026-11-02 12:04:10 [CITRO-2908 implement] Bash: npm --prefix package/ego-browser test
+2026-11-02 12:21:02 E2E started: 83 case(s), in /Users/bot/.local/state/linear-autofix/worktrees/CITRO-2908
+2026-11-02 12:26:04 E2E finished in 302 s, exit 0
+2026-11-02 12:26:05 git push zhuoweiwang/citro-2908
+2026-11-02 12:26:30 tick finished in 1365 s
+```
+
+Claude runs show each tool call and the first line of each text block, as they
+happen. A long gap means one step is still running: usually a test or E2E run.
+
## Execution log on Linear
Every tick that did something (a triage, a PR, a review round, an escalation,
diff --git a/tools/linear-autofix/src/claude.mjs b/tools/linear-autofix/src/claude.mjs
index 7f47555..b16c8af 100644
--- a/tools/linear-autofix/src/claude.mjs
+++ b/tools/linear-autofix/src/claude.mjs
@@ -2,7 +2,7 @@ import fs from "node:fs";
import path from "node:path";
import { config } from "./config.mjs";
import { run, tail } from "./proc.mjs";
-import { setUsagePause, usagePausedUntil } from "./state.mjs";
+import { setUsagePause, truncate, usagePausedUntil } from "./state.mjs";
// How long to wait when a usage limit did not come with a reset time.
const USAGE_RETRY_MS = 30 * 60_000;
@@ -90,6 +90,31 @@ function pauseIfUsageLimit(stdout, stderr) {
});
}
+/**
+ * What one stream-json line says Claude is doing, for the log: each tool call
+ * and the first line of each text block. Pure. Returns a list of short strings.
+ */
+export function describeClaudeLine(line) {
+ let message;
+ try {
+ message = JSON.parse(line);
+ } catch {
+ return [];
+ }
+ if (message.type !== "assistant") return [];
+ const steps = [];
+ for (const block of message.message?.content ?? []) {
+ if (block.type === "tool_use") {
+ const input = block.input ?? {};
+ const target = input.command ?? input.file_path ?? input.pattern ?? "";
+ steps.push(truncate(`${block.name}${target ? `: ${target}` : ""}`, 200));
+ } else if (block.type === "text" && block.text?.trim()) {
+ steps.push(truncate(block.text.trim().split("\n")[0], 200));
+ }
+ }
+ return steps;
+}
+
/**
* Run `claude -p` headless. The prompt goes in on stdin. Returns
* { text, structured, costUsd, turns, raw }. Throws on timeout or a non-zero
@@ -111,6 +136,7 @@ export async function runClaude({
cwd,
runDir,
label,
+ identifier,
allowedTools = [],
restricted = false,
budgetUsd,
@@ -139,6 +165,10 @@ export async function runClaude({
if (runDir) fs.writeFileSync(path.join(runDir, `${label}.prompt.md`), prompt);
const started = Date.now();
+ const tag = `[${identifier ? `${identifier} ` : ""}${label}]`;
+ console.log(
+ `${tag} claude started${budgetUsd ? `, budget $${budgetUsd}` : ""}${timeoutMs ? `, limit ${Math.round(timeoutMs / 60_000)} min` : ""}`,
+ );
let result;
try {
result = await run(config.claudeBin, args, {
@@ -146,6 +176,10 @@ export async function runClaude({
input: prompt,
timeoutMs,
env: { CLAUDE_CODE_DISABLE_AUTO_MEMORY: "1" },
+ onLine: (line) => {
+ for (const step of describeClaudeLine(line))
+ console.log(`${tag} ${step}`);
+ },
});
} catch (err) {
if (runDir && err.stdout !== undefined) {
diff --git a/tools/linear-autofix/src/claude.test.mjs b/tools/linear-autofix/src/claude.test.mjs
index aeed43c..5b13068 100644
--- a/tools/linear-autofix/src/claude.test.mjs
+++ b/tools/linear-autofix/src/claude.test.mjs
@@ -11,8 +11,13 @@ const fake = path.join(tmp, "fake-claude.mjs");
process.env.AUTOFIX_STATE_DIR = path.join(tmp, "state");
process.env.AUTOFIX_CLAUDE_BIN = fake;
-const { detectUsageLimit, parseClaudeStream, runClaude, UsageLimitError } =
- await import("./claude.mjs");
+const {
+ describeClaudeLine,
+ detectUsageLimit,
+ parseClaudeStream,
+ runClaude,
+ UsageLimitError,
+} = await import("./claude.mjs");
const { clearUsagePause, setUsagePause, usagePausedUntil } =
await import("./state.mjs");
const { runCodeClaude } = await import("./implement.mjs");
@@ -230,3 +235,26 @@ test("an expired pause no longer counts", () => {
assert.equal(usagePausedUntil(), null);
clearUsagePause();
});
+
+test("describeClaudeLine shows tool calls and the first line of text", () => {
+ const line = JSON.stringify({
+ type: "assistant",
+ message: {
+ content: [
+ { type: "text", text: "Fixing it.\nMore detail." },
+ { type: "tool_use", name: "Bash", input: { command: "npm test" } },
+ { type: "tool_use", name: "Read", input: { file_path: "/a.txt" } },
+ { type: "tool_use", name: "TodoWrite", input: { todos: [] } },
+ { type: "thinking", thinking: "hidden" },
+ ],
+ },
+ });
+ assert.deepEqual(describeClaudeLine(line), [
+ "Fixing it.",
+ "Bash: npm test",
+ "Read: /a.txt",
+ "TodoWrite",
+ ]);
+ assert.deepEqual(describeClaudeLine('{"type":"system"}'), []);
+ assert.deepEqual(describeClaudeLine("not json"), []);
+});
diff --git a/tools/linear-autofix/src/cli.mjs b/tools/linear-autofix/src/cli.mjs
index de93cf8..3be3310 100755
--- a/tools/linear-autofix/src/cli.mjs
+++ b/tools/linear-autofix/src/cli.mjs
@@ -16,7 +16,7 @@ import {
} from "./state.mjs";
import * as git from "./git.mjs";
import * as github from "./github.mjs";
-import { daemon, reconcile, tick } from "./tick.mjs";
+import { daemon, reconcile, tick, timestampLogs } from "./tick.mjs";
import { triage } from "./triage.mjs";
import { implement, publish } from "./implement.mjs";
import { review } from "./review.mjs";
@@ -155,8 +155,10 @@ function status() {
async function main([command, arg]) {
switch (command) {
case "tick":
+ timestampLogs();
return tick();
case "daemon":
+ timestampLogs();
return daemon();
case "triage": {
const { issue, record } = await one(arg);
diff --git a/tools/linear-autofix/src/e2e.mjs b/tools/linear-autofix/src/e2e.mjs
index 1a9a233..be6b19d 100644
--- a/tools/linear-autofix/src/e2e.mjs
+++ b/tools/linear-autofix/src/e2e.mjs
@@ -63,11 +63,18 @@ export function failedCases(results) {
async function runSuite(dir, excluded, only) {
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "autofix-e2e-"));
const resultsFile = path.join(tmp, "results.json");
+ const started = Date.now();
+ console.log(
+ `E2E started: ${only.length} case(s)${excluded.length ? `, ${excluded.length} excluded` : ""}, in ${dir}`,
+ );
try {
const result = await run("npm", ["run", "e2e"], {
cwd: path.join(dir, config.packageDir),
timeoutMs: config.pushTimeoutMs,
allowFailure: true,
+ onLine: (line) => {
+ if (line.startsWith("[FAIL]")) console.log(`E2E ${line.slice(0, 300)}`);
+ },
env: {
EGO_BROWSER_REAL_E2E_RESULTS: resultsFile,
// Without exclusions it stays a full run, which can skip an unchanged
@@ -77,6 +84,9 @@ async function runSuite(dir, excluded, only) {
: {}),
},
});
+ console.log(
+ `E2E finished in ${Math.round((Date.now() - started) / 1000)} s, exit ${result.code}`,
+ );
if (result.code === 0) return [];
const failures = fs.existsSync(resultsFile)
? failedCases(JSON.parse(fs.readFileSync(resultsFile, "utf8")))
diff --git a/tools/linear-autofix/src/git.mjs b/tools/linear-autofix/src/git.mjs
index d86e45f..c035a14 100644
--- a/tools/linear-autofix/src/git.mjs
+++ b/tools/linear-autofix/src/git.mjs
@@ -180,6 +180,7 @@ export async function push(dir, branch, { skipHookE2e = false } = {}) {
);
return;
}
+ console.log(`git push ${branch}`);
await gitIn(dir, ["push", "--set-upstream", config.remote, branch], {
timeoutMs: config.pushTimeoutMs,
env: skipHookE2e ? { LEFTHOOK_EXCLUDE: "e2e-test" } : {},
@@ -204,6 +205,7 @@ export async function remoteSha(dir, branch) {
export async function installDeps(dir) {
const pkg = `${dir}/${config.packageDir}`;
if (fs.existsSync(`${pkg}/node_modules/.bin/prettier`)) return;
+ console.log(`npm ci in ${pkg}`);
await run("npm", ["ci", "--no-audit", "--no-fund"], {
cwd: pkg,
timeoutMs: 15 * 60_000,
diff --git a/tools/linear-autofix/src/implement.mjs b/tools/linear-autofix/src/implement.mjs
index 68ba64e..43e35a0 100644
--- a/tools/linear-autofix/src/implement.mjs
+++ b/tools/linear-autofix/src/implement.mjs
@@ -129,6 +129,7 @@ export async function implement(issue, record) {
prompt,
runDir: out,
label: "implement",
+ identifier: record.identifier,
budgetUsd: config.implementBudgetUsd,
timeoutMs: config.implementTimeoutMs,
});
diff --git a/tools/linear-autofix/src/proc.mjs b/tools/linear-autofix/src/proc.mjs
index 66434c2..aaf9f49 100644
--- a/tools/linear-autofix/src/proc.mjs
+++ b/tools/linear-autofix/src/proc.mjs
@@ -10,7 +10,8 @@ export class ProcessError extends Error {
/**
* Run a child process to completion. Rejects on a non-zero exit or on timeout.
- * `input` is written to stdin.
+ * `input` is written to stdin. `onLine` sees each complete output line as it
+ * arrives, from either stream, for long runs that should show progress.
*
* The child is started in its own process group (`detached`), so a timeout
* terminates the whole tree: Claude's npm, node and shell descendants go with
@@ -21,7 +22,7 @@ export class ProcessError extends Error {
export function run(
cmd,
args,
- { cwd, input, timeoutMs = 120_000, env, allowFailure = false } = {},
+ { cwd, input, timeoutMs = 120_000, env, allowFailure = false, onLine } = {},
) {
return new Promise((resolve, reject) => {
const child = spawn(cmd, args, {
@@ -33,8 +34,18 @@ export function run(
let stdout = "";
let stderr = "";
let timedOut = false;
- child.stdout.on("data", (d) => (stdout += d));
- child.stderr.on("data", (d) => (stderr += d));
+ const lines = onLine ? lineSplitter(onLine) : () => {};
+ const linesErr = onLine ? lineSplitter(onLine) : () => {};
+ child.stdout.setEncoding("utf8");
+ child.stderr.setEncoding("utf8");
+ child.stdout.on("data", (d) => {
+ stdout += d;
+ lines(d);
+ });
+ child.stderr.on("data", (d) => {
+ stderr += d;
+ linesErr(d);
+ });
const timer = setTimeout(() => {
timedOut = true;
killTree(child, "SIGTERM");
@@ -76,6 +87,23 @@ export function run(
});
}
+/** Turn chunks into complete lines. A progress callback never breaks the run. */
+export function lineSplitter(onLine) {
+ let buffer = "";
+ return (chunk) => {
+ buffer += chunk;
+ const parts = buffer.split("\n");
+ buffer = parts.pop();
+ for (const line of parts) {
+ try {
+ onLine(line);
+ } catch (err) {
+ console.error(`progress callback failed: ${err.message}`);
+ }
+ }
+ };
+}
+
/** Signal the child's whole process group; fall back to the child alone. */
export function killTree(child, signal) {
if (!child.pid) return;
diff --git a/tools/linear-autofix/src/proc.test.mjs b/tools/linear-autofix/src/proc.test.mjs
index 7903ef9..8236a51 100644
--- a/tools/linear-autofix/src/proc.test.mjs
+++ b/tools/linear-autofix/src/proc.test.mjs
@@ -3,7 +3,7 @@ import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import { test } from "node:test";
-import { run, ProcessError } from "./proc.mjs";
+import { lineSplitter, run, ProcessError } from "./proc.mjs";
const alive = (pid) => {
try {
@@ -53,3 +53,29 @@ test("a timeout kills the child's descendants too", async () => {
"background sleep should have been killed with the group",
);
});
+
+test("run shows complete output lines from both streams as they arrive", async () => {
+ const lines = [];
+ await run(
+ "sh",
+ ["-c", "printf 'a\\nb'; printf 'err\\n' >&2; sleep 0.1; printf 'c\\n'"],
+ { onLine: (line) => lines.push(line) },
+ );
+ assert.deepEqual(lines.sort(), ["a", "bc", "err"]);
+});
+
+test("lineSplitter survives a callback that throws", () => {
+ const seen = [];
+ const original = console.error;
+ console.error = () => {};
+ try {
+ const feed = lineSplitter((line) => {
+ seen.push(line);
+ throw new Error("boom");
+ });
+ feed("x\ny\n");
+ } finally {
+ console.error = original;
+ }
+ assert.deepEqual(seen, ["x", "y"]);
+});
diff --git a/tools/linear-autofix/src/review.mjs b/tools/linear-autofix/src/review.mjs
index d8527e0..f7fbcec 100644
--- a/tools/linear-autofix/src/review.mjs
+++ b/tools/linear-autofix/src/review.mjs
@@ -239,6 +239,7 @@ export async function review(issue, record) {
prompt,
runDir: out,
label: "review-fix",
+ identifier: record.identifier,
budgetUsd: config.reviewBudgetUsd,
timeoutMs: config.reviewTimeoutMs,
});
diff --git a/tools/linear-autofix/src/tick.mjs b/tools/linear-autofix/src/tick.mjs
index d87558f..be3d2dc 100644
--- a/tools/linear-autofix/src/tick.mjs
+++ b/tools/linear-autofix/src/tick.mjs
@@ -56,6 +56,22 @@ export function reconcile(record, issue) {
return record;
}
+/** "in_review 2, new 1" for the log. Pure. */
+export function stageCounts(records) {
+ const counts = new Map();
+ for (const r of records) counts.set(r.stage, (counts.get(r.stage) ?? 0) + 1);
+ return [...counts].map(([stage, n]) => `${stage} ${n}`).join(", ") || "none";
+}
+
+/** Prefix console output with the local time, so a quiet stretch is visible as one. */
+export function timestampLogs() {
+ for (const method of ["log", "warn", "error"]) {
+ const original = console[method].bind(console);
+ console[method] = (...args) =>
+ original(new Date().toLocaleString("sv"), ...args);
+ }
+}
+
async function guarded(record, fn) {
try {
await fn();
@@ -100,6 +116,7 @@ export async function tick() {
issue,
record: reconcile(upsertFromIssue(issue), issue),
}));
+ console.log(`stages: ${stageCounts(work.map((w) => w.record))}`);
// 1. Review loops first: cheap checks that may finish a PR.
for (const { issue, record } of work.filter(
@@ -170,6 +187,9 @@ export async function tick() {
error: failure,
});
releaseLock();
+ console.log(
+ `tick finished in ${Math.round((Date.now() - startedAt) / 1000)} s`,
+ );
}
}
diff --git a/tools/linear-autofix/src/tick.test.mjs b/tools/linear-autofix/src/tick.test.mjs
index d0d175e..8a5bb34 100644
--- a/tools/linear-autofix/src/tick.test.mjs
+++ b/tools/linear-autofix/src/tick.test.mjs
@@ -7,7 +7,7 @@ import { test } from "node:test";
process.env.AUTOFIX_STATE_DIR = fs.mkdtempSync(
path.join(os.tmpdir(), "linear-autofix-test-"),
);
-const { byPriority, reconcile } = await import("./tick.mjs");
+const { byPriority, reconcile, stageCounts } = await import("./tick.mjs");
const state = await import("./state.mjs");
const issue = (identifier, extra = {}) => ({
@@ -125,3 +125,11 @@ test("identifiers are validated before they become paths", () => {
assert.equal(state.assertIdentifier("CL-556"), "CL-556");
assert.equal(state.assertIdentifier("CITRO-2908"), "CITRO-2908");
});
+
+test("stageCounts summarizes the stages for the log", () => {
+ assert.equal(
+ stageCounts([{ stage: "new" }, { stage: "in_review" }, { stage: "new" }]),
+ "new 2, in_review 1",
+ );
+ assert.equal(stageCounts([]), "none");
+});
diff --git a/tools/linear-autofix/src/triage.mjs b/tools/linear-autofix/src/triage.mjs
index 6db9b10..124de11 100644
--- a/tools/linear-autofix/src/triage.mjs
+++ b/tools/linear-autofix/src/triage.mjs
@@ -95,6 +95,7 @@ export async function triage(issue, record) {
cwd: config.repoRoot,
runDir: dir,
label: "triage",
+ identifier: record.identifier,
allowedTools: [
"Read",
"Grep",