mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-17 02:37:33 +00:00
fix: detect legacy dreaming corpus directories
This commit is contained in:
@@ -757,4 +757,49 @@ describe("maybeRepairLegacyRuntimeStateFiles", () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("imports legacy memory-core session corpus when it is the only dreaming file", async () => {
|
||||
await withTempDir("openclaw-doctor-memory-core-corpus-", async (rootDir) => {
|
||||
const stateDir = path.join(rootDir, "state");
|
||||
const workspaceDir = path.join(rootDir, "workspace");
|
||||
const sessionCorpusDir = path.join(workspaceDir, "memory", ".dreams", "session-corpus");
|
||||
const env = { ...process.env, OPENCLAW_STATE_DIR: stateDir, OPENCLAW_TEST_FAST: "1" };
|
||||
const cfg = {
|
||||
agents: {
|
||||
defaults: {
|
||||
workspace: workspaceDir,
|
||||
},
|
||||
},
|
||||
};
|
||||
await withEnvAsync(env, async () => {
|
||||
await fs.mkdir(sessionCorpusDir, { recursive: true });
|
||||
await fs.writeFile(
|
||||
path.join(sessionCorpusDir, "2026-04-06.txt"),
|
||||
"User: Store the legacy corpus in SQLite.\n",
|
||||
"utf8",
|
||||
);
|
||||
|
||||
await maybeRepairLegacyRuntimeStateFiles({
|
||||
prompter: { shouldRepair: true },
|
||||
env,
|
||||
cfg,
|
||||
});
|
||||
|
||||
expect(noteMock).toHaveBeenCalledWith(
|
||||
expect.stringContaining("memory-core dreaming checkpoint row"),
|
||||
"Doctor changes",
|
||||
);
|
||||
await expect(fs.stat(path.join(sessionCorpusDir, "2026-04-06.txt"))).rejects.toMatchObject({
|
||||
code: "ENOENT",
|
||||
});
|
||||
await expect(
|
||||
readDreamingSessionCorpusText({
|
||||
workspaceDir,
|
||||
relativePath: "memory/.dreams/session-corpus/2026-04-06.txt",
|
||||
env,
|
||||
}),
|
||||
).resolves.toBe("User: Store the legacy corpus in SQLite.\n");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -151,7 +151,12 @@ export async function legacyMemoryCoreDreamingStateFilesExist(params: {
|
||||
}): Promise<boolean> {
|
||||
for (const workspaceDir of configuredDreamingWorkspaces(params.cfg)) {
|
||||
for (const relativePath of Object.values(DREAMING_STATE_RELATIVE_PATHS)) {
|
||||
if (await fileExists(path.join(workspaceDir, relativePath))) {
|
||||
const absolutePath = path.join(workspaceDir, relativePath);
|
||||
const exists =
|
||||
relativePath === DREAMING_STATE_RELATIVE_PATHS.sessionCorpusDir
|
||||
? await dirExists(absolutePath)
|
||||
: await fileExists(absolutePath);
|
||||
if (exists) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user