Persistent Context Across Sessions for Every Agent – Captures everything your agent does during sessions, compresses it with AI, and injects relevant context back into future sessions. Works with Claude Code, OpenClaw, Codex, Gemini, Hermes, Copilot, OpenCode + More
TypeScript aiai-agentsai-memoryanthropicartificial-intelligencechromadbclaudeclaude-agent-sdkclaude-agentsclaude-codeclaude-code-pluginclaude-skillsembeddingslong-term-memorymem0memory-engineopenmemoryragsqlitesupermemory
import { describe, it, expect } from 'bun:test';
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, statSync, writeFileSync } from 'fs';
import { tmpdir } from 'os';
import path from 'path';
import { fileURLToPath } from 'url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const projectRoot = path.resolve(__dirname, '../..');
const versionManifestFilenames = ['plugin.json', 'openclaw.plugin.json', 'package.json'];
const nonNpmVersionManifests = [
'.grok-plugin/plugin.json',
'claude-mem-cursor/.cursor-plugin/plugin.json',
'claude-mem-grok-bot/.cursor-plugin/plugin.json',
];
const independentVersionManifests = new Set([
'openclaw/package.json',
]);
function readManifest(root: string, relativePath: string) {
return JSON.parse(readFileSync(path.join(root, relativePath), 'utf-8'));
}
function discoverShippedVersionManifests(root: string = projectRoot): string[] {
const packageFiles = readManifest(root, 'package.json').files as string[];
const candidates = new Set<string>();
for (const entry of packageFiles) {
const relativePath = entry.replace(/\\/g, '/');
const absolutePath = path.join(root, relativePath);
if (
versionManifestFilenames.includes(path.posix.basename(relativePath))
&& existsSync(absolutePath)
) {
candidates.add(relativePath);
}
if (!existsSync(absolutePath) || !statSync(absolutePath).isDirectory()) continue;
for (const filename of versionManifestFilenames) {
const candidate = path.posix.join(relativePath, filename);
if (existsSync(path.join(root, candidate))) candidates.add(candidate);
}
}
// No filter on the manifest's contents: a shipped manifest that lost its
// `version` must stay in the list so its version test fails, not vanish.
return [...candidates]
.filter(candidate => candidate !== 'package.json' && !independentVersionManifests.has(candidate))
.sort();
}
describe('Version Consistency', () => {
const rootVersion: string = readManifest(projectRoot, 'package.json').version;
it('should read version from root package.json', () => {
const packageJsonPath = path.join(projectRoot, 'package.json');
expect(existsSync(packageJsonPath)).toBe(true);
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
expect(packageJson.version).toBeDefined();
expect(packageJson.version).toMatch(/^\d+\.\d+\.\d+$/);
});
it('discovers shipped version manifests from package.json#files', () => {
// The exact set, so a required manifest that drops out of discovery fails
// here instead of silently losing its version test.
expect(discoverShippedVersionManifests()).toEqual([
'.claude-plugin/plugin.json',
'.codex-plugin/plugin.json',
'.qoder-plugin/plugin.json',
'dsh/package.json',
'openclaw/openclaw.plugin.json',
'plugin/.claude-plugin/plugin.json',
'plugin/.codex-plugin/plugin.json',
'plugin/.devin-plugin/plugin.json',
'plugin/.qoder-plugin/plugin.json',
'plugin/package.json',
'plugin/server-runtime/package.json',
]);
});
it('still discovers a listed manifest that has no version', () => {
const fixtureRoot = mkdtempSync(path.join(tmpdir(), 'cmem-manifest-discovery-'));
try {
mkdirSync(path.join(fixtureRoot, 'new-host'), { recursive: true });
writeFileSync(
path.join(fixtureRoot, 'package.json'),
JSON.stringify({ files: ['new-host'] }),
);
writeFileSync(
path.join(fixtureRoot, 'new-host', 'plugin.json'),
JSON.stringify({ name: 'new-host' }),
);
expect(discoverShippedVersionManifests(fixtureRoot)).toEqual([
'new-host/plugin.json',
]);
} finally {
rmSync(fixtureRoot, { recursive: true, force: true });
}
});
it('should have matching version in .claude-plugin/marketplace.json', () => {
const marketplaceJsonPath = path.join(projectRoot, '.claude-plugin/marketplace.json');
expect(existsSync(marketplaceJsonPath)).toBe(true);
const marketplaceJson = JSON.parse(readFileSync(marketplaceJsonPath, 'utf-8'));
expect(marketplaceJson.plugins).toBeDefined();
expect(marketplaceJson.plugins.length).toBeGreaterThan(0);
const claudeMemPlugin = marketplaceJson.plugins.find((p: any) => p.name === 'claude-mem');
expect(claudeMemPlugin).toBeDefined();
expect(claudeMemPlugin.version).toBe(rootVersion);
});
for (const manifestPath of [
...discoverShippedVersionManifests(),
...nonNpmVersionManifests,
]) {
it(`should have matching version in ${manifestPath}`, () => {
const filePath = path.join(projectRoot, manifestPath);
expect(existsSync(filePath)).toBe(true);
const manifest = readManifest(projectRoot, manifestPath);
expect(manifest.version).toBe(rootVersion);
});
}
for (const bundle of ['worker-service.cjs', 'mcp-server.cjs', 'server-service.cjs', 'transcript-watcher.cjs']) {
it(`should have the release version injected into built ${bundle}`, () => {
const bundlePath = path.join(projectRoot, 'plugin/scripts', bundle);
expect(existsSync(bundlePath)).toBe(true);
const content = readFileSync(bundlePath, 'utf-8');
expect(content.includes(`"${rootVersion}"`)).toBe(true);
});
}
});