

























@@ -2,20 +2,22 @@ import fs from "node:fs";
22import os from "node:os";
33import path from "node:path";
44import { describe, expect, it } from "vitest";
5-import {
6-createFormattedPromptSnapshotFiles,
7-deleteStalePromptSnapshotFiles,
8-} from "../../scripts/generate-prompt-snapshots.js";
95import {
106defaultCatalogPathCandidates,
117findDefaultCatalogPath,
128renderCodexModelInstructions,
139runCodexModelPromptFixtureSync,
1410} from "../../scripts/sync-codex-model-prompt-fixture.js";
15-import {
16-CODEX_MODEL_PROMPT_FIXTURE_DIR,
17-CODEX_RUNTIME_HAPPY_PATH_PROMPT_SNAPSHOT_DIR,
18-} from "../helpers/agents/happy-path-prompt-snapshots.js";
11+12+const promptSnapshotsEnabled = process.env.OPENCLAW_RUN_PROMPT_SNAPSHOTS !== "false";
13+const promptSnapshotIt = promptSnapshotsEnabled ? it : it.skip;
14+const CODEX_RUNTIME_HAPPY_PATH_PROMPT_SNAPSHOT_DIR =
15+"test/fixtures/agents/prompt-snapshots/codex-runtime-happy-path";
16+const CODEX_MODEL_PROMPT_FIXTURE_DIR = "test/fixtures/agents/prompt-snapshots/codex-model-catalog";
17+18+async function loadPromptSnapshotGenerator() {
19+return await import("../../scripts/generate-prompt-snapshots.js");
20+}
19212022function requireGeneratedSnapshot(
2123generated: Array<{ path: string; content: string }>,
@@ -38,7 +40,8 @@ function renderedPromptSection(content: string, heading: string, nextHeading: st
3840}
39414042describe("happy path prompt snapshots", () => {
41-it("matches the committed Codex prompt snapshot artifacts", async () => {
43+promptSnapshotIt("matches the committed Codex prompt snapshot artifacts", async () => {
44+const { createFormattedPromptSnapshotFiles } = await loadPromptSnapshotGenerator();
4245const generated = await createFormattedPromptSnapshotFiles();
4346const expectedPaths = new Set(generated.map((file) => file.path));
4447for (const file of generated) {
@@ -51,7 +54,8 @@ describe("happy path prompt snapshots", () => {
5154expect(committed.toSorted()).toEqual([...expectedPaths].toSorted());
5255});
535654-it("deletes stale generated snapshot artifacts", async () => {
57+promptSnapshotIt("deletes stale generated snapshot artifacts", async () => {
58+const { deleteStalePromptSnapshotFiles } = await loadPromptSnapshotGenerator();
5559const root = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-prompt-snapshot-stale-"));
5660try {
5761const snapshotDir = path.join(root, CODEX_RUNTIME_HAPPY_PATH_PROMPT_SNAPSHOT_DIR);
@@ -73,7 +77,8 @@ describe("happy path prompt snapshots", () => {
7377}
7478});
757976-it("renders the Codex model-bound prompt layers", async () => {
80+promptSnapshotIt("renders the Codex model-bound prompt layers", async () => {
81+const { createFormattedPromptSnapshotFiles } = await loadPromptSnapshotGenerator();
7782const generated = await createFormattedPromptSnapshotFiles();
7883const telegram = requireGeneratedSnapshot(generated, "telegram-direct-codex-message-tool.md");
7984@@ -94,7 +99,8 @@ describe("happy path prompt snapshots", () => {
9499expect(telegram).toContain("### Tools: Dynamic Tool Catalog");
95100});
9610197-it("keeps heartbeat guidance in heartbeat collaboration mode only", async () => {
102+promptSnapshotIt("keeps heartbeat guidance in heartbeat collaboration mode only", async () => {
103+const { createFormattedPromptSnapshotFiles } = await loadPromptSnapshotGenerator();
98104const generated = await createFormattedPromptSnapshotFiles();
99105const direct = requireGeneratedSnapshot(generated, "telegram-direct-codex-message-tool.md");
100106const group = requireGeneratedSnapshot(generated, "discord-group-codex-message-tool.md");
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。