Files
openbot/scripts/agent-pending-runtime-e2e.ts
Aleksander DygońandClaude Opus 5.5 03c2ff34c2 Remove code comments and add the no-comments rule (#12604)
* 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>
2026-11-19 12:19:28 +01:00

102 lines
3.5 KiB
TypeScript

import assert from "node:assert/strict";
import { mkdirSync, writeFileSync } from "node:fs";
import { mkdtemp, rm } from "node:fs/promises";
import { tmpdir } from "node:os";
import { join, resolve } from "node:path";
import type { AgentProviderId } from "@openbot/contracts/ipc";
import { AgentStore } from "../src/backend/agent-store";
import { runCauseEffect } from "../src/backend/effect-boundary";
import { OpenBotDatabase } from "../src/backend/openbot-database";
const ROOT = resolve(import.meta.dirname, "..");
const OUT = join(ROOT, ".openbot-build", "agent-pending-runtime-e2e");
interface Step {
name: string;
passed: boolean;
detail?: unknown;
error?: string;
}
const report: { passed: boolean; steps: Step[] } = { passed: false, steps: [] };
async function step<T>(name: string, run: () => Promise<T>): Promise<T> {
process.stdout.write(`- ${name}\n`);
try {
const value = await run();
report.steps.push({ name, passed: true, detail: value });
return value;
} catch (error) {
report.steps.push({ name, passed: false, error: error instanceof Error ? error.message : String(error) });
throw error;
}
}
const root = await mkdtemp(join(tmpdir(), "openbot-pending-runtime-"));
const statePath = join(root, "state");
const homePath = join(root, "home");
const database = new OpenBotDatabase(statePath);
const store = new AgentStore(statePath, homePath, database);
try {
await runCauseEffect(store.initialize());
const agent = await runCauseEffect(
store.createAgent({ name: "Writer", description: "", avatarSeed: "pending-a", avatarHue: null }),
);
const pendingProvider: AgentProviderId = agent.provider === "codex" ? "claude" : "codex";
const pending = {
provider: pendingProvider,
model: "pending-model",
reasoningEffort: "high" as const,
};
await step("A queued runtime is stored on the agent", async () => {
const updated = await runCauseEffect(store.updateAgent({ agentId: agent.id, pendingRuntime: pending }));
assert.equal(updated.provider, agent.provider);
assert.equal(updated.model, agent.model);
assert.deepEqual(updated.pendingRuntime, pending);
return updated.pendingRuntime;
});
await step("The queued runtime survives a reload", async () => {
const reopened = new AgentStore(statePath, homePath, new OpenBotDatabase(statePath));
await runCauseEffect(reopened.initialize());
const loaded = reopened.list().find((candidate) => candidate.id === agent.id);
assert.ok(loaded);
assert.deepEqual(loaded.pendingRuntime, pending);
return loaded.pendingRuntime;
});
await step("A provider handover that lands clears the queued runtime", async () => {
const moved = await runCauseEffect(
store.updateAgent({
agentId: agent.id,
provider: pendingProvider,
model: "pending-model",
reasoningEffort: "high",
}),
);
assert.equal(moved.provider, pendingProvider);
assert.equal(moved.pendingRuntime, undefined);
return { provider: moved.provider, pendingRuntime: moved.pendingRuntime ?? null };
});
report.passed = true;
} catch (error) {
if (report.steps.every((entry) => entry.passed)) {
report.steps.push({
name: "run",
passed: false,
error: error instanceof Error ? error.message : String(error),
});
}
} finally {
await rm(root, { recursive: true, force: true }).catch(() => undefined);
mkdirSync(OUT, { recursive: true });
writeFileSync(join(OUT, "report.json"), `${JSON.stringify(report, null, 2)}\n`);
}
if (!report.passed) {
process.exitCode = 1;
}