mirror of
https://github.com/nightly-labs/openbot.git
synced 2026-11-26 10:41:50 +08:00
* Remove code comments and add the no-comments rule Remove the comments from first-party code and configuration files: TS/JS, JSX, CSS, SQL migrations, Swift, Kotlin, Gradle, shell, Docker, systemd, Nix, YAML, TOML, JSONC and GritQL. Keep only what a tool reads: license headers, shebangs, compiler and lint directives, JSDoc types in plain .js files, generated file headers, GritQL scope lines, the install-server.sh help text and the openbot-boat-pre-stop marker. Vendored code, fixtures and released schemas keep their comments. Add the rule to AGENTS.md, and change the docs that asked for comments. Add two i18n keys that only comments named to RELEASED_SOURCE_KEYS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Keep comments that are data in strings The benchmark task files in opencode-free-models-bench.ts tell the model what each function must do. The sample file and HTML page in the two stories are display content. Put their comments back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Keep released migrations and mobile native inputs unchanged check:migrations compares each released migration with v0.73.0 byte for byte, so restore src/backend/migrations. A change to a native build input of apps/mobile makes a new runtime version, so restore those files and the extra fingerprint sources. List these files and the comment markers that a tool reads in AGENTS.md. Remove the last requests for comments in src/renderer/AGENTS.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
143 lines
4.5 KiB
TypeScript
143 lines
4.5 KiB
TypeScript
import { spawn } from "node:child_process";
|
|
import { randomUUID } from "node:crypto";
|
|
import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
import { tmpdir } from "node:os";
|
|
import { dirname, join } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import { z } from "zod";
|
|
import { withoutElectronRuntimeFlags } from "./electron-spawn-env";
|
|
|
|
class FixtureProcessTimeout extends Error {}
|
|
|
|
const projectRoot = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
const buildRoot = await mkdtemp(join(tmpdir(), "openbot-fill-fields-"));
|
|
const reportPath = join(projectRoot, ".openbot-build/browser-fill-fields-e2e/report.json");
|
|
const runId = randomUUID();
|
|
let sourceSha: string | undefined;
|
|
try {
|
|
await mkdir(dirname(reportPath), { recursive: true });
|
|
const entry = join(buildRoot, "browser-fill-fields.mjs");
|
|
await run(process.execPath, [
|
|
"build",
|
|
join(projectRoot, "scripts/browser-fill-fields-electron.ts"),
|
|
"--target=node",
|
|
"--format=esm",
|
|
"--external=electron",
|
|
`--outfile=${entry}`,
|
|
]);
|
|
sourceSha = (await output("git", ["rev-parse", "HEAD"])).trim();
|
|
const bunVersion = await output(process.execPath, ["--version"]);
|
|
await run(
|
|
join(projectRoot, "node_modules/.bin/electron"),
|
|
[
|
|
...(process.platform === "linux" ? ["--no-sandbox"] : []),
|
|
entry,
|
|
`--fixture-root=${buildRoot}`,
|
|
`--report-path=${reportPath}`,
|
|
`--source-sha=${sourceSha}`,
|
|
`--run-id=${runId}`,
|
|
`--harness-runtime=${process.version}`,
|
|
`--bun-version=${bunVersion.trim()}`,
|
|
],
|
|
true,
|
|
);
|
|
const report = z
|
|
.object({
|
|
status: z.literal("passed"),
|
|
cases: z.array(z.string()).min(20),
|
|
runId: z.literal(runId),
|
|
sourceSha: z.literal(sourceSha),
|
|
})
|
|
.parse(JSON.parse(await readFile(reportPath, "utf8")));
|
|
process.stdout.write(
|
|
`${JSON.stringify({ status: report.status, cases: report.cases.length, report: reportPath })}\n`,
|
|
);
|
|
} catch (error) {
|
|
let completedCases: string[] = [];
|
|
let nativeFailure = false;
|
|
try {
|
|
const current = z
|
|
.object({ runId: z.literal(runId), status: z.string(), cases: z.array(z.string()).optional() })
|
|
.parse(JSON.parse(await readFile(reportPath, "utf8")));
|
|
completedCases = current.cases ?? [];
|
|
nativeFailure = current.status === "failed";
|
|
} catch {}
|
|
if (error instanceof FixtureProcessTimeout) {
|
|
await writeFile(
|
|
reportPath,
|
|
`${JSON.stringify(
|
|
{
|
|
status: "timed_out",
|
|
runId,
|
|
sourceSha,
|
|
cases: completedCases,
|
|
reason: "Owned fixture exceeded its 180-second process guard.",
|
|
},
|
|
null,
|
|
2,
|
|
)}\n`,
|
|
);
|
|
} else if (!nativeFailure) {
|
|
await writeFile(
|
|
reportPath,
|
|
`${JSON.stringify(
|
|
{
|
|
status: "failed",
|
|
runId,
|
|
sourceSha,
|
|
cases: completedCases,
|
|
reason: "Fixture process completion or report verification failed.",
|
|
},
|
|
null,
|
|
2,
|
|
)}\n`,
|
|
);
|
|
}
|
|
throw error;
|
|
} finally {
|
|
await rm(buildRoot, { recursive: true, force: true });
|
|
}
|
|
|
|
async function run(command: string, args: string[], electron = false): Promise<void> {
|
|
await new Promise<void>((resolve, reject) => {
|
|
const child = spawn(command, args, {
|
|
cwd: projectRoot,
|
|
stdio: "inherit",
|
|
env: electron ? withoutElectronRuntimeFlags(process.env) : process.env,
|
|
});
|
|
let force: NodeJS.Timeout | undefined;
|
|
let timedOut = false;
|
|
const timeout = setTimeout(() => {
|
|
timedOut = true;
|
|
child.kill("SIGTERM");
|
|
force = setTimeout(() => child.kill("SIGKILL"), 3_000);
|
|
}, 180_000);
|
|
child.once("error", (error) => {
|
|
clearTimeout(timeout);
|
|
clearTimeout(force);
|
|
reject(error);
|
|
});
|
|
child.once("exit", (code, signal) => {
|
|
clearTimeout(timeout);
|
|
clearTimeout(force);
|
|
if (timedOut) reject(new FixtureProcessTimeout("Browser fill fixture timed out."));
|
|
else if (code === 0 && signal === null) resolve();
|
|
else reject(new Error(`Browser fill fixture process failed (${code}).`));
|
|
});
|
|
});
|
|
}
|
|
|
|
async function output(command: string, args: string[]): Promise<string> {
|
|
return new Promise((resolve, reject) => {
|
|
const child = spawn(command, args, { cwd: projectRoot, stdio: ["ignore", "pipe", "inherit"] });
|
|
let text = "";
|
|
child.stdout.on("data", (chunk: Buffer) => {
|
|
text += chunk.toString("utf8");
|
|
});
|
|
child.once("error", reject);
|
|
child.once("exit", (code) =>
|
|
code === 0 ? resolve(text) : reject(new Error("Unable to read fixture source SHA.")),
|
|
);
|
|
});
|
|
}
|