Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

mor

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mor - npm Package Compare versions

Comparing version
0.18.4
to
0.18.5
+1
-1
.claude-plugin/plugin.json
{
"name": "mor",
"version": "0.18.4",
"version": "0.18.5",
"description": "AI-accessible knowledge you actually own — plain markdown on your disk",

@@ -5,0 +5,0 @@ "author": {

{
"name": "mor",
"version": "0.18.4",
"version": "0.18.5",
"description": "AI-accessible knowledge you actually own — plain markdown on your disk",

@@ -5,0 +5,0 @@ "type": "module",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

import type { Config, Memory, MemoryType } from './operations.js';
export declare function detectRepository(): string | undefined;
export declare function generateFilename(title: string, id: string): string;
export declare function createMemory(config: Config, opts: {
title: string;
description?: string;
content: string;
tags?: string[];
type?: MemoryType;
repository?: string;
}): {
mem: Memory;
raw: string;
};
export declare function readMemory(filePath: string): Memory;
export declare function tryReadMemory(filePath: string): {
mem: Memory;
raw: string;
} | undefined;
export declare function serializeMemory(mem: Memory): string;
export declare function updateMemory(filePath: string, updates: {
title?: string;
description?: string;
content?: string;
tags?: string[];
type?: MemoryType;
}): {
mem: Memory;
raw: string;
};
export declare function deleteMemory(filePath: string): void;
export declare function listMemoryFiles(config: Config): string[];
import matter from 'gray-matter';
import { execSync } from 'node:child_process';
import crypto from 'node:crypto';
import fs from 'node:fs';
import path from 'node:path';
import { normalizeGitUrl } from './utils/git.js';
let _cachedRepo;
export function detectRepository() {
if (_cachedRepo !== undefined)
return _cachedRepo ?? undefined;
try {
const url = execSync('git remote get-url origin', {
encoding: 'utf-8',
stdio: ['pipe', 'pipe', 'pipe'],
}).trim();
_cachedRepo = normalizeGitUrl(url) ?? null;
}
catch {
_cachedRepo = null;
}
return _cachedRepo ?? undefined;
}
export function generateFilename(title, id) {
const slug = title
.normalize('NFD')
.replace(/[\u0300-\u036f]/g, '')
.replace(/([a-z])([A-Z])/g, '$1-$2')
.replace(/([A-Z]+)([A-Z][a-z])/g, '$1-$2')
.toLowerCase()
.replace(/[^a-z0-9]+/g, '-')
.replace(/^-|-$/g, '') || 'memory';
const hash = id.slice(0, 4);
return `${slug}-${hash}.md`;
}
function buildFrontmatter(fm) {
const out = {
id: fm.id,
title: fm.title,
tags: fm.tags,
type: fm.type,
created: fm.created,
updated: fm.updated,
};
if (fm.description)
out.description = fm.description;
if (fm.repository)
out.repository = fm.repository;
return out;
}
export function createMemory(config, opts) {
const id = crypto.randomUUID();
const now = new Date().toISOString();
const repo = opts.repository ?? detectRepository();
const frontmatter = buildFrontmatter({
id,
title: opts.title,
description: opts.description,
tags: opts.tags ?? [],
type: opts.type ?? 'knowledge',
repository: repo,
created: now,
updated: now,
});
const filename = generateFilename(opts.title, id);
const filePath = path.join(config.memoryDir, filename);
const raw = matter.stringify({ content: opts.content }, frontmatter);
fs.writeFileSync(filePath, raw);
return {
mem: { ...frontmatter, content: opts.content, filePath },
raw,
};
}
function readAndParse(filePath) {
const raw = fs.readFileSync(filePath, 'utf-8');
return { mem: parseMemory(raw, filePath), raw };
}
export function readMemory(filePath) {
return readAndParse(filePath).mem;
}
export function tryReadMemory(filePath) {
try {
return readAndParse(filePath);
}
catch (e) {
process.stderr.write(`Warning: skipping unreadable memory ${filePath}: ${e instanceof Error ? e.message : e}\n`);
return undefined;
}
}
function parseMemory(raw, filePath) {
const { data, content } = matter(raw);
const fm = data;
return {
id: fm.id,
title: fm.title,
description: fm.description,
tags: fm.tags ?? [],
type: fm.type ?? 'knowledge',
repository: fm.repository,
created: fm.created,
updated: fm.updated,
content: content.trim(),
filePath,
};
}
export function serializeMemory(mem) {
const frontmatter = buildFrontmatter(mem);
return matter.stringify({ content: mem.content }, frontmatter);
}
export function updateMemory(filePath, updates) {
const existing = readMemory(filePath);
const now = new Date().toISOString();
const description = updates.description !== undefined
? updates.description
: existing.description;
const frontmatter = buildFrontmatter({
id: existing.id,
title: updates.title ?? existing.title,
description,
tags: updates.tags ?? existing.tags,
type: updates.type ?? existing.type,
repository: existing.repository,
created: existing.created,
updated: now,
});
const content = updates.content ?? existing.content;
const raw = matter.stringify({ content }, frontmatter);
let newPath = filePath;
if (updates.title && updates.title !== existing.title) {
const newFilename = generateFilename(updates.title, existing.id);
newPath = path.join(path.dirname(filePath), newFilename);
}
fs.writeFileSync(newPath, raw);
if (newPath !== filePath)
fs.unlinkSync(filePath);
return {
mem: { ...frontmatter, content, filePath: newPath },
raw,
};
}
export function deleteMemory(filePath) {
fs.unlinkSync(filePath);
}
export function listMemoryFiles(config) {
try {
return fs
.readdirSync(config.memoryDir)
.filter((f) => f.endsWith('.md'))
.map((f) => path.join(config.memoryDir, f));
}
catch {
return [];
}
}
//# sourceMappingURL=memory.js.map
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,IAAI,WAAsC,CAAC;AAE3C,MAAM,UAAU,gBAAgB;IAC9B,IAAI,WAAW,KAAK,SAAS;QAAE,OAAO,WAAW,IAAI,SAAS,CAAC;IAC/D,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,QAAQ,CAAC,2BAA2B,EAAE;YAChD,QAAQ,EAAE,OAAO;YACjB,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;SAChC,CAAC,CAAC,IAAI,EAAE,CAAC;QACV,WAAW,GAAG,eAAe,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC;IAC7C,CAAC;IAAC,MAAM,CAAC;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