mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-13 15:47:28 +00:00
* Add Codex prompt snapshots * Fix prompt snapshot scenario catalogs * Harden prompt snapshot drift check * Fix CLI compat build export * fix: keep codex snapshots out of core plugin surface * fix: harden prompt snapshot ci checks * fix: accept readonly web search onboarding scopes * fix: repair plugin sdk package boundary types * fix: clear prompt snapshot ci regressions * fix: clear latest main ci checks * fix: resolve latest main discord helper overlap * fix: refresh codex dynamic tool snapshots * fix: align prompt snapshot branch with latest ci * fix: isolate plugin auto enable tests * test: refresh prompt dynamic tool snapshots * fix: stabilize bundled channel auto enable * fix: clean stale prompt snapshots
44 lines
1.8 KiB
TypeScript
44 lines
1.8 KiB
TypeScript
import fs from "node:fs";
|
|
import os from "node:os";
|
|
import path from "node:path";
|
|
import { describe, expect, it } from "vitest";
|
|
import {
|
|
createFormattedPromptSnapshotFiles,
|
|
deleteStalePromptSnapshotFiles,
|
|
} from "../../scripts/generate-prompt-snapshots.js";
|
|
import { HAPPY_PATH_PROMPT_SNAPSHOT_DIR } from "../helpers/agents/happy-path-prompt-snapshots.js";
|
|
|
|
describe("happy path prompt snapshots", () => {
|
|
it("matches the committed Codex prompt snapshot artifacts", async () => {
|
|
const generated = await createFormattedPromptSnapshotFiles();
|
|
const expectedPaths = new Set(generated.map((file) => file.path));
|
|
for (const file of generated) {
|
|
expect(fs.readFileSync(file.path, "utf8"), file.path).toBe(file.content);
|
|
}
|
|
const committed = fs
|
|
.readdirSync(HAPPY_PATH_PROMPT_SNAPSHOT_DIR)
|
|
.filter((entry) => entry.endsWith(".md") || entry.endsWith(".json"))
|
|
.map((entry) => path.join(HAPPY_PATH_PROMPT_SNAPSHOT_DIR, entry));
|
|
expect(committed.toSorted()).toEqual([...expectedPaths].toSorted());
|
|
});
|
|
|
|
it("deletes stale generated snapshot artifacts", async () => {
|
|
const root = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-prompt-snapshot-stale-"));
|
|
try {
|
|
const snapshotDir = path.join(root, HAPPY_PATH_PROMPT_SNAPSHOT_DIR);
|
|
fs.mkdirSync(snapshotDir, { recursive: true });
|
|
const stalePath = path.join(HAPPY_PATH_PROMPT_SNAPSHOT_DIR, "stale-snapshot.md");
|
|
fs.writeFileSync(path.join(root, stalePath), "stale\n");
|
|
|
|
const deleted = await deleteStalePromptSnapshotFiles(root, [
|
|
{ path: path.join(HAPPY_PATH_PROMPT_SNAPSHOT_DIR, "current.md") },
|
|
]);
|
|
|
|
expect(deleted).toEqual([stalePath]);
|
|
expect(fs.existsSync(path.join(root, stalePath))).toBe(false);
|
|
} finally {
|
|
fs.rmSync(root, { recursive: true, force: true });
|
|
}
|
|
});
|
|
});
|