mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 17:03:32 +00:00
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:
committed by
Gustavo Madeira Santana
parent
5b23999404
commit
27e45ccd6c
@@ -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-");
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user