chore: initialize EverOS 1.0.0
md-first memory extraction framework for AI agents. Markdown is the single source of truth; SQLite holds state and LanceDB provides the rebuildable vector + BM25 + scalar index. The codebase follows a single-direction DDD layering (entrypoints -> service -> memory -> infra, with component / core / config cross-cutting) enforced by import-linter. Engineering surface: - Coding conventions in .claude/rules/ (path-scoped) and workflows in .claude/skills/ (/commit, /new-branch, /pr). - GitHub Actions CI runs make lint + test + integration; pre-commit mirrors the gates locally (ruff, hygiene hooks, gitlint commit-msg). - Commit messages follow Conventional Commits, enforced by gitlint. - make lint also enforces datetime two-zone discipline and OpenAPI drift.
This commit is contained in:
@ -0,0 +1,71 @@
|
||||
import { readFileSync } from 'fs';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { dirname, join } from 'path';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
||||
const DATA_PATH = join(__dirname, '..', '..', '..', 'data', 'mock-memories.json');
|
||||
|
||||
let memoriesCache = null;
|
||||
|
||||
/**
|
||||
* @typedef {Object} Memory
|
||||
* @property {string} text - The memory content
|
||||
* @property {string} timestamp - ISO timestamp when memory was created
|
||||
*/
|
||||
|
||||
/**
|
||||
* Load mock memories from JSON file
|
||||
* @returns {Memory[]} Array of memory objects with text and timestamp
|
||||
*/
|
||||
export function loadMemories() {
|
||||
if (memoriesCache !== null) {
|
||||
return memoriesCache;
|
||||
}
|
||||
|
||||
try {
|
||||
const data = readFileSync(DATA_PATH, 'utf-8');
|
||||
const parsed = JSON.parse(data);
|
||||
memoriesCache = parsed.memories || [];
|
||||
return memoriesCache;
|
||||
} catch (error) {
|
||||
console.error(`[Memory Plugin] Failed to load memories: ${error.message}`);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a timestamp as relative time (e.g., "2h ago", "3 days ago")
|
||||
* @param {string} isoTimestamp - ISO timestamp string
|
||||
* @returns {string} Relative time string
|
||||
*/
|
||||
export function formatRelativeTime(isoTimestamp) {
|
||||
const now = new Date();
|
||||
const then = new Date(isoTimestamp);
|
||||
const diffMs = now - then;
|
||||
|
||||
const seconds = Math.floor(diffMs / 1000);
|
||||
const minutes = Math.floor(seconds / 60);
|
||||
const hours = Math.floor(minutes / 60);
|
||||
const days = Math.floor(hours / 24);
|
||||
const weeks = Math.floor(days / 7);
|
||||
const months = Math.floor(days / 30);
|
||||
|
||||
if (months > 0) {
|
||||
return months === 1 ? '1 month ago' : `${months} months ago`;
|
||||
}
|
||||
if (weeks > 0) {
|
||||
return weeks === 1 ? '1 week ago' : `${weeks} weeks ago`;
|
||||
}
|
||||
if (days > 0) {
|
||||
return days === 1 ? '1 day ago' : `${days} days ago`;
|
||||
}
|
||||
if (hours > 0) {
|
||||
return hours === 1 ? '1 hour ago' : `${hours}h ago`;
|
||||
}
|
||||
if (minutes > 0) {
|
||||
return minutes === 1 ? '1 min ago' : `${minutes}m ago`;
|
||||
}
|
||||
return 'just now';
|
||||
}
|
||||
Reference in New Issue
Block a user