Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.
Python agent-contextagent-memoryagent-pluginsagentic-ragcontext-databasedsh-pluginknowledge-basememorymemory-managementself-evolvingvector-database
import { existsSync, readFileSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
import { describe, expect, it } from "vitest";
const rootDir = join(dirname(fileURLToPath(import.meta.url)), "../..");
const repoRoot = join(rootDir, "../..");
function readJson(path: string): any {
return JSON.parse(readFileSync(join(rootDir, path), "utf8"));
}
describe("OpenClaw plugin package and install contract", () => {
it("uses compiled OpenClaw runtime entries", () => {
const packageJson = readJson("package.json");
expect(packageJson.openclaw.extensions).toEqual(["./dist/index.js"]);
expect(packageJson.openclaw.setupEntry).toBe("./dist/commands/setup.js");
expect(packageJson.scripts.build).toContain("rmSync('dist'");
expect(packageJson.scripts.build).toContain("tsc -p tsconfig.build.json");
});
it("keeps source install manifest aligned with required source files", () => {
const installManifest = readJson("install-manifest.json");
expect(installManifest.plugin).toMatchObject({
id: "openviking",
kind: "context-engine",
slot: "contextEngine",
});
expect(installManifest.files.required).toEqual(expect.arrayContaining([
"index.ts",
"config.ts",
"context-engine.ts",
"auto-recall.ts",
"client.ts",
"process-manager.ts",
"memory-ranking.ts",
"token-estimator.ts",
"text-utils.ts",
"tool-call-id.ts",
"session-transcript-repair.ts",
"runtime-utils.ts",
"recall-trace.ts",
"query-config.ts",
"adapters/",
"registries/",
"routing/",
"shared/",
"plugin/",
"services/",
"commands/setup.ts",
"config/feature-gates.json",
"tsconfig.json",
"tsconfig.build.json",
"package.json",
"openclaw.plugin.json",
]));
for (const file of installManifest.files.required) {
expect(existsSync(join(rootDir, file)), `${file} should exist`).toBe(true);
}
});
it("ships npm package files needed by source and compiled installs", () => {
const packageJson = readJson("package.json");
expect(packageJson.files).toEqual(expect.arrayContaining([
"dist/",
"*.ts",
"adapters/",
"commands/setup.ts",
"config/feature-gates.json",
"registries/",
"routing/",
"shared/",
"plugin/",
"services/",
"install-manifest.json",
"openclaw.plugin.json",
"package.json",
"README.md",
"INSTALL.md",
"INSTALL-ZH.md",
"INSTALL-AGENT.md",
"images/",
"skills/",
]));
});
it("strips dev dependencies before packing npm and ClawHub release artifacts", () => {
const workflow = readFileSync(
join(repoRoot, ".github/workflows/clawhub-dev-release.yml"),
"utf8",
);
for (const stepName of [
"Pack OpenViking plugin",
"Prepare ClawHub legacy package folder",
]) {
const stepStart = workflow.indexOf(` - name: ${stepName}`);
expect(stepStart, `${stepName} should exist`).toBeGreaterThanOrEqual(0);
const nextStep = workflow.indexOf("\n - name:", stepStart + 1);
const step = workflow.slice(stepStart, nextStep < 0 ? undefined : nextStep);
const buildIndex = step.indexOf("npm run prepack");
const stripIndex = step.indexOf("npm pkg delete devDependencies");
const packIndex = step.indexOf("npm pack --ignore-scripts --pack-destination");
expect(buildIndex, `${stepName} should build before sanitizing`).toBeGreaterThanOrEqual(0);
expect(stripIndex, `${stepName} should strip devDependencies`).toBeGreaterThan(buildIndex);
expect(packIndex, `${stepName} should pack without rerunning scripts`).toBeGreaterThan(
stripIndex,
);
}
});
it("ships and registers the canonical Experience skill", () => {
const pluginManifest = readJson("openclaw.plugin.json");
const installManifest = readJson("install-manifest.json");
const packagedSkillPath = join(rootDir, "skills/ov-experience-memory/SKILL.md");
const canonicalSkillPath = join(repoRoot, "examples/skills/ov-experience-memory/SKILL.md");
expect(pluginManifest.skills).toContain("./skills/ov-experience-memory");
expect(installManifest.files.optional).toContain("skills/ov-experience-memory/SKILL.md");
expect(existsSync(packagedSkillPath)).toBe(true);
expect(readFileSync(packagedSkillPath, "utf8")).toBe(
readFileSync(canonicalSkillPath, "utf8"),
);
});
it("keeps runtime dependencies and overrides available for installed plugin loading", () => {
const packageJson = readJson("package.json");
expect(packageJson.dependencies["@sinclair/typebox"]).toBeDefined();
expect(packageJson.dependencies.fflate).toBeDefined();
expect(packageJson.overrides?.axios).toMatch(/^\^1\./);
expect(packageJson.devDependencies.typescript).toBeDefined();
expect(packageJson.devDependencies.vitest).toBeDefined();
});
it("keeps setup helper fallback metadata compatible with the current plugin manifest", () => {
const installHelper = readFileSync(join(rootDir, "setup-helper/install.js"), "utf8");
const installManifest = readJson("install-manifest.json");
expect(installHelper).toContain("FALLBACK_CURRENT");
expect(installHelper).toContain(`id: "${installManifest.plugin.id}"`);
expect(installHelper).toContain(`kind: "${installManifest.plugin.kind}"`);
expect(installHelper).toContain(`slot: "${installManifest.plugin.slot}"`);
expect(installHelper).toContain("OPENVIKING_PEER_ROLE");
expect(installHelper).toContain("OPENVIKING_PEER_PREFIX");
expect(installHelper).toContain('if (role === "person") return "sender"');
expect(installHelper).toContain('return role === "person" ? null : normalizePeerRole(role);');
expect(installHelper).not.toContain("OPENVIKING_AGENT_PREFIX");
});
});