fix(workspace): create BOOTSTRAP.md regardless of workspace state

writeFileIfMissing already guards against overwriting, so the
isBrandNewWorkspace gate was an unnecessary restriction that
prevented BOOTSTRAP.md creation in existing workspaces.

Fixes #16457
This commit is contained in:
Robby (AI-assisted)
2026-02-14 20:13:24 +00:00
committed by Gustavo Madeira Santana
parent 5b23999404
commit 27e45ccd6c
2 changed files with 15 additions and 3 deletions

View File

@@ -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-");

View File

@@ -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 {