@stackmemoryai/stackmemory
Version:
Lossless, project-scoped memory for AI coding tools. Durable context across sessions with 56 MCP tools, FTS5 search, conductor orchestrator, loop/watch monitoring, snapshot capture, pre-flight overlap checks, Claude/Codex/OpenCode wrappers, Linear sync, a
52 lines (51 loc) • 1.33 kB
JavaScript
import { fileURLToPath as __fileURLToPath } from 'url';
import { dirname as __pathDirname } from 'path';
const __filename = __fileURLToPath(import.meta.url);
const __dirname = __pathDirname(__filename);
import { join } from "path";
import { existsSync, mkdirSync, readFileSync, writeFileSync, rmSync } from "fs";
import { homedir } from "os";
function workersDir() {
return join(homedir(), ".stackmemory", "workers");
}
function registryFile() {
return join(workersDir(), "registry.json");
}
function ensureWorkerStateDir(workerId) {
const dir = join(workersDir(), workerId);
if (!existsSync(dir)) {
mkdirSync(dir, { recursive: true });
}
return dir;
}
function saveRegistry(session) {
const dir = workersDir();
if (!existsSync(dir)) {
mkdirSync(dir, { recursive: true });
}
writeFileSync(registryFile(), JSON.stringify(session, null, 2));
}
function loadRegistry() {
if (!existsSync(registryFile())) return null;
try {
return JSON.parse(readFileSync(registryFile(), "utf-8"));
} catch {
return null;
}
}
function clearRegistry() {
const file = registryFile();
if (existsSync(file)) {
rmSync(file, { force: true });
}
}
function getWorkersDir() {
return workersDir();
}
export {
clearRegistry,
ensureWorkerStateDir,
getWorkersDir,
loadRegistry,
saveRegistry
};