



























@@ -8,6 +8,7 @@ import {
88type AgentBootstrapHookContext,
99} from "../hooks/internal-hooks.js";
1010import { makeTempWorkspace } from "../test-helpers/workspace.js";
11+import { withEnvAsync } from "../test-utils/env.js";
1112import {
1213resetBootstrapWarningCacheForTest,
1314FULL_BOOTSTRAP_COMPLETED_CUSTOM_TYPE,
@@ -255,20 +256,12 @@ describe("resolveBootstrapFilesForRun", () => {
255256await fs.writeFile(path.join(workspaceDir, "AGENTS.md"), "rules", "utf8");
256257await fs.writeFile(path.join(workspaceDir, "BOOTSTRAP.md"), "stale ritual", "utf8");
257258258-const previousOpenClawHome = process.env.OPENCLAW_HOME;
259-process.env.OPENCLAW_HOME = parentDir;
260-try {
261-const files = await resolveBootstrapFilesForRun({ workspaceDir: "~/workspace" });
262-263-expect(files.map((file) => file.name)).toContain("AGENTS.md");
264-expect(files.map((file) => file.name)).not.toContain("BOOTSTRAP.md");
265-} finally {
266-if (previousOpenClawHome === undefined) {
267-delete process.env.OPENCLAW_HOME;
268-} else {
269-process.env.OPENCLAW_HOME = previousOpenClawHome;
270-}
271-}
259+const files = await withEnvAsync({ OPENCLAW_HOME: parentDir }, async () =>
260+resolveBootstrapFilesForRun({ workspaceDir: "~/workspace" }),
261+);
262+263+expect(files.map((file) => file.name)).toContain("AGENTS.md");
264+expect(files.map((file) => file.name)).not.toContain("BOOTSTRAP.md");
272265});
273266274267it("keeps hook-added nested BOOTSTRAP.md after setup is completed", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。