mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-24 14:01:16 +00:00
* refactor(plugins): trim activation and contract exports * test(plugins): restore fixture cleanup * refactor(plugins): trim install and loader exports * test(plugins): fully reset loader caches * refactor(plugins): trim metadata and catalog exports * test(plugins): preserve catalog trust coverage * refactor(plugins): trim provider and plugin exports * refactor(plugins): trim runtime and tool exports * test(plugins): update dead-export consumers * test(plugins): remove empty dead-export suites * refactor(plugins): align exports with split registry * refactor(plugins): trim drifted loader exports * style(plugins): format test fixtures * refactor(scripts): use supported plugin APIs * refactor(plugins): finish dead export cleanup * chore(deadcode): refresh export baseline * test(cli): mock production memory state * chore(deadcode): sync latest export baseline * fix(tests): keep plugin fixtures inside core * chore(deadcode): refresh rebased export baseline * chore(deadcode): sync current ratchets * fix(plugins): retain reserved slot invariant * fix(plugins): preserve dead-export invariants * test(plugins): use neutral catalog query fixture * test(plugins): satisfy catalog lint * test(plugins): preserve integrity drift coverage * fix(ci): register skill experience live proof
147 lines
4.6 KiB
TypeScript
147 lines
4.6 KiB
TypeScript
/**
|
|
* Tests memory host core public artifact discovery and workspace handling.
|
|
*/
|
|
import fs from "node:fs/promises";
|
|
import os from "node:os";
|
|
import path from "node:path";
|
|
import { afterEach, describe, expect, it } from "vitest";
|
|
import {
|
|
clearMemoryPluginState,
|
|
registerMemoryCapability,
|
|
registerMemoryPromptSection,
|
|
} from "../plugins/memory-state.test-fixtures.js";
|
|
import * as memoryCoreAlias from "./memory-core.js";
|
|
import {
|
|
buildActiveMemoryPromptSection,
|
|
listMemoryHostPublicArtifacts,
|
|
listActiveMemoryPublicArtifacts,
|
|
} from "./memory-host-core.js";
|
|
import { appendMemoryHostEvent, resolveMemoryHostEventLogPath } from "./memory-host-events.js";
|
|
|
|
describe("memory-host-core helpers", () => {
|
|
afterEach(() => {
|
|
clearMemoryPluginState();
|
|
});
|
|
|
|
it("exposes the active memory prompt guidance builder for context engines", () => {
|
|
registerMemoryPromptSection(({ citationsMode }) => [
|
|
"## Memory Recall",
|
|
`citations=${citationsMode ?? "default"}`,
|
|
"",
|
|
]);
|
|
|
|
expect(
|
|
buildActiveMemoryPromptSection({
|
|
availableTools: new Set(["memory_search"]),
|
|
citationsMode: "off",
|
|
}),
|
|
).toEqual(["## Memory Recall", "citations=off", ""]);
|
|
});
|
|
|
|
it("exposes active memory public artifacts for companion plugins", async () => {
|
|
registerMemoryCapability("memory-core", {
|
|
publicArtifacts: {
|
|
async listArtifacts() {
|
|
return [
|
|
{
|
|
kind: "memory-root",
|
|
workspaceDir: "/tmp/workspace",
|
|
relativePath: "MEMORY.md",
|
|
absolutePath: "/tmp/workspace/MEMORY.md",
|
|
agentIds: ["main"],
|
|
contentType: "markdown" as const,
|
|
},
|
|
];
|
|
},
|
|
},
|
|
});
|
|
|
|
await expect(listActiveMemoryPublicArtifacts({ cfg: {} as never })).resolves.toEqual([
|
|
{
|
|
kind: "memory-root",
|
|
workspaceDir: "/tmp/workspace",
|
|
relativePath: "MEMORY.md",
|
|
absolutePath: "/tmp/workspace/MEMORY.md",
|
|
agentIds: ["main"],
|
|
contentType: "markdown",
|
|
},
|
|
]);
|
|
});
|
|
|
|
it("lists shared public artifacts from memory workspaces", async () => {
|
|
const fixtureRoot = await fs.mkdtemp(path.join(os.tmpdir(), "memory-host-public-artifacts-"));
|
|
try {
|
|
const workspaceDir = path.join(fixtureRoot, "workspace");
|
|
await fs.mkdir(path.join(workspaceDir, "memory", "dreaming"), { recursive: true });
|
|
await fs.writeFile(path.join(workspaceDir, "MEMORY.md"), "# Durable Memory\n", "utf8");
|
|
await fs.writeFile(
|
|
path.join(workspaceDir, "memory", "2026-05-18.md"),
|
|
"# Daily Note\n",
|
|
"utf8",
|
|
);
|
|
await fs.writeFile(
|
|
path.join(workspaceDir, "memory", "dreaming", "2026-05-18.md"),
|
|
"# Dream Report\n",
|
|
"utf8",
|
|
);
|
|
await appendMemoryHostEvent(workspaceDir, {
|
|
type: "memory.recall.recorded",
|
|
timestamp: "2026-05-18T12:00:00.000Z",
|
|
query: "bridge",
|
|
resultCount: 0,
|
|
results: [],
|
|
});
|
|
|
|
await expect(
|
|
listMemoryHostPublicArtifacts({
|
|
cfg: {
|
|
agents: {
|
|
list: [{ id: "main", default: true, workspace: workspaceDir }],
|
|
},
|
|
},
|
|
}),
|
|
).resolves.toEqual([
|
|
{
|
|
kind: "memory-root",
|
|
workspaceDir,
|
|
relativePath: "MEMORY.md",
|
|
absolutePath: path.join(workspaceDir, "MEMORY.md"),
|
|
agentIds: ["main"],
|
|
contentType: "markdown",
|
|
},
|
|
{
|
|
kind: "daily-note",
|
|
workspaceDir,
|
|
relativePath: "memory/2026-05-18.md",
|
|
absolutePath: path.join(workspaceDir, "memory", "2026-05-18.md"),
|
|
agentIds: ["main"],
|
|
contentType: "markdown",
|
|
},
|
|
{
|
|
kind: "dream-report",
|
|
workspaceDir,
|
|
relativePath: "memory/dreaming/2026-05-18.md",
|
|
absolutePath: path.join(workspaceDir, "memory", "dreaming", "2026-05-18.md"),
|
|
agentIds: ["main"],
|
|
contentType: "markdown",
|
|
},
|
|
{
|
|
kind: "event-log",
|
|
workspaceDir,
|
|
relativePath: "memory/.dreams/events.jsonl",
|
|
absolutePath: resolveMemoryHostEventLogPath(workspaceDir),
|
|
agentIds: ["main"],
|
|
contentType: "json",
|
|
},
|
|
]);
|
|
} finally {
|
|
await fs.rm(fixtureRoot, { recursive: true, force: true });
|
|
}
|
|
});
|
|
|
|
it("keeps the deprecated memory-core alias wired to memory-host-core", () => {
|
|
expect(memoryCoreAlias.buildActiveMemoryPromptSection).toBe(buildActiveMemoryPromptSection);
|
|
expect(memoryCoreAlias.listActiveMemoryPublicArtifacts).toBe(listActiveMemoryPublicArtifacts);
|
|
});
|
|
});
|