diff --git a/src/agents/workspace.e2e.test.ts b/src/agents/workspace.e2e.test.ts index d4f842e6ea0..92e2f425c28 100644 --- a/src/agents/workspace.e2e.test.ts +++ b/src/agents/workspace.e2e.test.ts @@ -1,9 +1,12 @@ +import fs from "node:fs/promises"; import path from "node:path"; import { describe, expect, it } from "vitest"; import { makeTempWorkspace, writeWorkspaceFile } from "../test-helpers/workspace.js"; import { + DEFAULT_BOOTSTRAP_FILENAME, DEFAULT_MEMORY_ALT_FILENAME, DEFAULT_MEMORY_FILENAME, + ensureAgentWorkspace, loadWorkspaceBootstrapFiles, resolveDefaultAgentWorkspaceDir, } from "./workspace.js"; @@ -19,6 +22,17 @@ describe("resolveDefaultAgentWorkspaceDir", () => { }); }); +describe("ensureAgentWorkspace", () => { + it("creates BOOTSTRAP.md even when workspace already has other bootstrap files", async () => { + const tempDir = await makeTempWorkspace("openclaw-workspace-"); + await writeWorkspaceFile({ dir: tempDir, name: "AGENTS.md", content: "existing" }); + + await ensureAgentWorkspace({ dir: tempDir, ensureBootstrapFiles: true }); + + await expect(fs.access(path.join(tempDir, DEFAULT_BOOTSTRAP_FILENAME))).resolves.toBeUndefined(); + }); +}); + describe("loadWorkspaceBootstrapFiles", () => { it("includes MEMORY.md when present", async () => { const tempDir = await makeTempWorkspace("openclaw-workspace-"); diff --git a/src/agents/workspace.ts b/src/agents/workspace.ts index c13fe29f72a..cb6849e6c8a 100644 --- a/src/agents/workspace.ts +++ b/src/agents/workspace.ts @@ -221,9 +221,7 @@ export async function ensureAgentWorkspace(params?: { await writeFileIfMissing(identityPath, identityTemplate); await writeFileIfMissing(userPath, userTemplate); await writeFileIfMissing(heartbeatPath, heartbeatTemplate); - if (isBrandNewWorkspace) { - await writeFileIfMissing(bootstrapPath, bootstrapTemplate); - } + await writeFileIfMissing(bootstrapPath, bootstrapTemplate); await ensureGitRepo(dir, isBrandNewWorkspace); return {