@hir4ta/mneme 0.22.0 → 0.22.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/README.ja.md +7 -1
- package/README.md +1 -1
- package/dist/lib/incremental-save.js +2 -2
- package/dist/lib/prompt-search.js +1 -64
- package/dist/lib/search-core.js +1 -64
- package/dist/lib/session-finalize.js +21 -10
- package/dist/public/assets/index-DZyzcWMg.js +351 -0
- package/dist/public/assets/index-g8Lvi94K.css +1 -0
- package/dist/public/assets/{react-force-graph-2d-Dlcfvz01.js → react-force-graph-2d-CAP2m3Y0.js} +1 -1
- package/dist/public/index.html +2 -2
- package/dist/server.js +190 -243
- package/dist/servers/db-server.js +140 -436
- package/dist/servers/search-server.js +3 -95
- package/package.json +1 -1
- package/scripts/export-weekly-knowledge-html.ts +15 -14
- package/servers/db-server.ts +180 -515
- package/servers/search-server.ts +3 -46
- package/skills/save/SKILL.md +20 -21
- package/dist/public/assets/index-Bvl_IrPy.css +0 -1
- package/dist/public/assets/index-k5JYSPV6.js +0 -351
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mneme",
|
|
3
3
|
"description": "A plugin that provides long-term memory for Claude Code. It automatically saves context lost during auto-compact, offering features for session restoration, recording technical decisions, and learning developer patterns.",
|
|
4
|
-
"version": "0.22.
|
|
4
|
+
"version": "0.22.3",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "hir4ta"
|
|
7
7
|
},
|
package/README.ja.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# mneme
|
|
2
2
|
|
|
3
|
+

|
|
4
|
+

|
|
3
5
|
[](https://www.npmjs.com/package/@hir4ta/mneme)
|
|
4
6
|
[](https://github.com/hir4ta/mneme/blob/main/LICENSE)
|
|
5
7
|
|
|
@@ -24,7 +26,11 @@ Claude Codeの長期記憶を実現するプラグイン
|
|
|
24
26
|
|
|
25
27
|
Claude Codeのセッションは終了やAuto-Compactで文脈が失われ、過去の判断が追えず、知見の再利用が困難です。
|
|
26
28
|
|
|
27
|
-
|
|
29
|
+
**よくある問題**: セッション間での文脈喪失、同じミスの繰り返し、不透明な設計判断
|
|
30
|
+
|
|
31
|
+
**mnemeでの解決**: 自動保存と再開、毎プロンプトでの自動記憶検索、判断・パターン履歴の検索
|
|
32
|
+
|
|
33
|
+
**チームでの利点**: `.mneme/` のJSONファイルはGit管理され、判断やセッション履歴をチームで共有できます。
|
|
28
34
|
|
|
29
35
|
## インストール
|
|
30
36
|
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# mneme
|
|
2
2
|
|
|
3
|
-

|
|
4
4
|

|
|
5
5
|
[](https://www.npmjs.com/package/@hir4ta/mneme)
|
|
6
6
|
[](https://github.com/hir4ta/mneme/blob/main/LICENSE)
|
|
@@ -327,7 +327,7 @@ async function parseTranscriptIncremental(transcriptPath, lastSavedLine) {
|
|
|
327
327
|
name: c.name ?? "",
|
|
328
328
|
detail: c.name === "Bash" ? c.input?.command : c.name === "Read" || c.name === "Edit" || c.name === "Write" ? c.input?.file_path : c.name === "Glob" || c.name === "Grep" ? c.input?.pattern : null
|
|
329
329
|
}));
|
|
330
|
-
if (!thinking && !text) return null;
|
|
330
|
+
if (!thinking && !text && toolDetails.length === 0) return null;
|
|
331
331
|
return {
|
|
332
332
|
timestamp: e.timestamp,
|
|
333
333
|
thinking,
|
|
@@ -340,7 +340,7 @@ async function parseTranscriptIncremental(transcriptPath, lastSavedLine) {
|
|
|
340
340
|
const user = userMessages[i];
|
|
341
341
|
const nextUserTs = i + 1 < userMessages.length ? userMessages[i + 1].timestamp : "9999-12-31T23:59:59Z";
|
|
342
342
|
const turnResponses = assistantMessages.filter(
|
|
343
|
-
(a) => a.timestamp
|
|
343
|
+
(a) => a.timestamp >= user.timestamp && a.timestamp < nextUserTs
|
|
344
344
|
);
|
|
345
345
|
if (turnResponses.length > 0) {
|
|
346
346
|
const allToolDetails = turnResponses.flatMap((r) => r.toolDetails);
|
|
@@ -406,66 +406,6 @@ function searchSessions(mnemeDir, keywords, limit = 5) {
|
|
|
406
406
|
});
|
|
407
407
|
return results.sort((a, b) => b.score - a.score).slice(0, limit);
|
|
408
408
|
}
|
|
409
|
-
function searchUnits(mnemeDir, keywords, limit = 5) {
|
|
410
|
-
const unitsPath = path3.join(mnemeDir, "units", "units.json");
|
|
411
|
-
const results = [];
|
|
412
|
-
const pattern = new RegExp(keywords.map(escapeRegex).join("|"), "i");
|
|
413
|
-
if (!fs3.existsSync(unitsPath)) return results;
|
|
414
|
-
try {
|
|
415
|
-
const cards = JSON.parse(fs3.readFileSync(unitsPath, "utf-8"));
|
|
416
|
-
const items = (cards.items || []).filter(
|
|
417
|
-
(item) => item.status === "approved"
|
|
418
|
-
);
|
|
419
|
-
for (const item of items) {
|
|
420
|
-
let score = 0;
|
|
421
|
-
const matchedFields = [];
|
|
422
|
-
const titleScore = fieldScore(item.title, pattern, 3);
|
|
423
|
-
if (titleScore > 0) {
|
|
424
|
-
score += titleScore;
|
|
425
|
-
matchedFields.push("title");
|
|
426
|
-
}
|
|
427
|
-
const summaryScore = fieldScore(item.summary, pattern, 2);
|
|
428
|
-
if (summaryScore > 0) {
|
|
429
|
-
score += summaryScore;
|
|
430
|
-
matchedFields.push("summary");
|
|
431
|
-
}
|
|
432
|
-
if (item.tags?.some((tag) => pattern.test(tag))) {
|
|
433
|
-
score += 1;
|
|
434
|
-
matchedFields.push("tags");
|
|
435
|
-
}
|
|
436
|
-
if (item.sourceType && pattern.test(item.sourceType)) {
|
|
437
|
-
score += 1;
|
|
438
|
-
matchedFields.push("sourceType");
|
|
439
|
-
}
|
|
440
|
-
if (score === 0 && keywords.length <= 2) {
|
|
441
|
-
const titleWords = (item.title || "").toLowerCase().split(/\s+/);
|
|
442
|
-
const tagWords = item.tags || [];
|
|
443
|
-
for (const keyword of keywords) {
|
|
444
|
-
if (titleWords.some((w) => isFuzzyMatch(keyword, w))) {
|
|
445
|
-
score += 1;
|
|
446
|
-
matchedFields.push("title~fuzzy");
|
|
447
|
-
}
|
|
448
|
-
if (tagWords.some((t) => isFuzzyMatch(keyword, t))) {
|
|
449
|
-
score += 0.5;
|
|
450
|
-
matchedFields.push("tags~fuzzy");
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
if (score > 0) {
|
|
455
|
-
results.push({
|
|
456
|
-
type: "unit",
|
|
457
|
-
id: item.id,
|
|
458
|
-
title: item.title || item.id,
|
|
459
|
-
snippet: item.summary || "",
|
|
460
|
-
score,
|
|
461
|
-
matchedFields
|
|
462
|
-
});
|
|
463
|
-
}
|
|
464
|
-
}
|
|
465
|
-
} catch {
|
|
466
|
-
}
|
|
467
|
-
return results.sort((a, b) => b.score - a.score).slice(0, limit);
|
|
468
|
-
}
|
|
469
409
|
function normalizeRequestedTypes(types) {
|
|
470
410
|
const normalized = /* @__PURE__ */ new Set();
|
|
471
411
|
for (const type of types) {
|
|
@@ -479,7 +419,7 @@ function searchKnowledge(options) {
|
|
|
479
419
|
mnemeDir,
|
|
480
420
|
projectPath,
|
|
481
421
|
database = null,
|
|
482
|
-
types = ["session", "
|
|
422
|
+
types = ["session", "interaction"],
|
|
483
423
|
limit = 10,
|
|
484
424
|
offset = 0
|
|
485
425
|
} = options;
|
|
@@ -496,9 +436,6 @@ function searchKnowledge(options) {
|
|
|
496
436
|
if (normalizedTypes.has("session")) {
|
|
497
437
|
results.push(...searchSessions(mnemeDir, expandedKeywords, fetchLimit));
|
|
498
438
|
}
|
|
499
|
-
if (normalizedTypes.has("unit")) {
|
|
500
|
-
results.push(...searchUnits(mnemeDir, expandedKeywords, fetchLimit));
|
|
501
|
-
}
|
|
502
439
|
if (normalizedTypes.has("interaction")) {
|
|
503
440
|
results.push(
|
|
504
441
|
...searchInteractions(
|
package/dist/lib/search-core.js
CHANGED
|
@@ -400,66 +400,6 @@ function searchSessions(mnemeDir, keywords, limit = 5) {
|
|
|
400
400
|
});
|
|
401
401
|
return results.sort((a, b) => b.score - a.score).slice(0, limit);
|
|
402
402
|
}
|
|
403
|
-
function searchUnits(mnemeDir, keywords, limit = 5) {
|
|
404
|
-
const unitsPath = path3.join(mnemeDir, "units", "units.json");
|
|
405
|
-
const results = [];
|
|
406
|
-
const pattern = new RegExp(keywords.map(escapeRegex).join("|"), "i");
|
|
407
|
-
if (!fs3.existsSync(unitsPath)) return results;
|
|
408
|
-
try {
|
|
409
|
-
const cards = JSON.parse(fs3.readFileSync(unitsPath, "utf-8"));
|
|
410
|
-
const items = (cards.items || []).filter(
|
|
411
|
-
(item) => item.status === "approved"
|
|
412
|
-
);
|
|
413
|
-
for (const item of items) {
|
|
414
|
-
let score = 0;
|
|
415
|
-
const matchedFields = [];
|
|
416
|
-
const titleScore = fieldScore(item.title, pattern, 3);
|
|
417
|
-
if (titleScore > 0) {
|
|
418
|
-
score += titleScore;
|
|
419
|
-
matchedFields.push("title");
|
|
420
|
-
}
|
|
421
|
-
const summaryScore = fieldScore(item.summary, pattern, 2);
|
|
422
|
-
if (summaryScore > 0) {
|
|
423
|
-
score += summaryScore;
|
|
424
|
-
matchedFields.push("summary");
|
|
425
|
-
}
|
|
426
|
-
if (item.tags?.some((tag) => pattern.test(tag))) {
|
|
427
|
-
score += 1;
|
|
428
|
-
matchedFields.push("tags");
|
|
429
|
-
}
|
|
430
|
-
if (item.sourceType && pattern.test(item.sourceType)) {
|
|
431
|
-
score += 1;
|
|
432
|
-
matchedFields.push("sourceType");
|
|
433
|
-
}
|
|
434
|
-
if (score === 0 && keywords.length <= 2) {
|
|
435
|
-
const titleWords = (item.title || "").toLowerCase().split(/\s+/);
|
|
436
|
-
const tagWords = item.tags || [];
|
|
437
|
-
for (const keyword of keywords) {
|
|
438
|
-
if (titleWords.some((w) => isFuzzyMatch(keyword, w))) {
|
|
439
|
-
score += 1;
|
|
440
|
-
matchedFields.push("title~fuzzy");
|
|
441
|
-
}
|
|
442
|
-
if (tagWords.some((t) => isFuzzyMatch(keyword, t))) {
|
|
443
|
-
score += 0.5;
|
|
444
|
-
matchedFields.push("tags~fuzzy");
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
if (score > 0) {
|
|
449
|
-
results.push({
|
|
450
|
-
type: "unit",
|
|
451
|
-
id: item.id,
|
|
452
|
-
title: item.title || item.id,
|
|
453
|
-
snippet: item.summary || "",
|
|
454
|
-
score,
|
|
455
|
-
matchedFields
|
|
456
|
-
});
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
} catch {
|
|
460
|
-
}
|
|
461
|
-
return results.sort((a, b) => b.score - a.score).slice(0, limit);
|
|
462
|
-
}
|
|
463
403
|
function normalizeRequestedTypes(types) {
|
|
464
404
|
const normalized = /* @__PURE__ */ new Set();
|
|
465
405
|
for (const type of types) {
|
|
@@ -473,7 +413,7 @@ function searchKnowledge(options) {
|
|
|
473
413
|
mnemeDir,
|
|
474
414
|
projectPath,
|
|
475
415
|
database = null,
|
|
476
|
-
types = ["session", "
|
|
416
|
+
types = ["session", "interaction"],
|
|
477
417
|
limit = 10,
|
|
478
418
|
offset = 0
|
|
479
419
|
} = options;
|
|
@@ -490,9 +430,6 @@ function searchKnowledge(options) {
|
|
|
490
430
|
if (normalizedTypes.has("session")) {
|
|
491
431
|
results.push(...searchSessions(mnemeDir, expandedKeywords, fetchLimit));
|
|
492
432
|
}
|
|
493
|
-
if (normalizedTypes.has("unit")) {
|
|
494
|
-
results.push(...searchUnits(mnemeDir, expandedKeywords, fetchLimit));
|
|
495
|
-
}
|
|
496
433
|
if (normalizedTypes.has("interaction")) {
|
|
497
434
|
results.push(
|
|
498
435
|
...searchInteractions(
|
|
@@ -331,7 +331,7 @@ async function parseTranscriptIncremental(transcriptPath, lastSavedLine) {
|
|
|
331
331
|
name: c.name ?? "",
|
|
332
332
|
detail: c.name === "Bash" ? c.input?.command : c.name === "Read" || c.name === "Edit" || c.name === "Write" ? c.input?.file_path : c.name === "Glob" || c.name === "Grep" ? c.input?.pattern : null
|
|
333
333
|
}));
|
|
334
|
-
if (!thinking && !text) return null;
|
|
334
|
+
if (!thinking && !text && toolDetails.length === 0) return null;
|
|
335
335
|
return {
|
|
336
336
|
timestamp: e.timestamp,
|
|
337
337
|
thinking,
|
|
@@ -344,7 +344,7 @@ async function parseTranscriptIncremental(transcriptPath, lastSavedLine) {
|
|
|
344
344
|
const user = userMessages[i];
|
|
345
345
|
const nextUserTs = i + 1 < userMessages.length ? userMessages[i + 1].timestamp : "9999-12-31T23:59:59Z";
|
|
346
346
|
const turnResponses = assistantMessages.filter(
|
|
347
|
-
(a) => a.timestamp
|
|
347
|
+
(a) => a.timestamp >= user.timestamp && a.timestamp < nextUserTs
|
|
348
348
|
);
|
|
349
349
|
if (turnResponses.length > 0) {
|
|
350
350
|
const allToolDetails = turnResponses.flatMap((r) => r.toolDetails);
|
|
@@ -875,15 +875,26 @@ async function sessionFinalize(sessionId, cwd, transcriptPath, cleanupPolicy, gr
|
|
|
875
875
|
console.error(
|
|
876
876
|
`[mneme] Session ended without /mneme:save - cleaned up ${cleanupResult.count} interactions`
|
|
877
877
|
);
|
|
878
|
+
fs3.unlinkSync(sessionFile);
|
|
879
|
+
const linkFile = path3.join(sessionLinksDir, `${sessionShortId}.json`);
|
|
880
|
+
if (fs3.existsSync(linkFile)) {
|
|
881
|
+
fs3.unlinkSync(linkFile);
|
|
882
|
+
}
|
|
883
|
+
console.error(
|
|
884
|
+
"[mneme] Session completed (not saved, cleaned up immediately)"
|
|
885
|
+
);
|
|
886
|
+
} else {
|
|
887
|
+
data.status = "complete";
|
|
888
|
+
data.endedAt = now;
|
|
889
|
+
data.updatedAt = now;
|
|
890
|
+
delete data.uncommitted;
|
|
891
|
+
delete data.interactions;
|
|
892
|
+
delete data.preCompactBackups;
|
|
893
|
+
safeWriteJson(sessionFile, data);
|
|
894
|
+
console.error(
|
|
895
|
+
"[mneme] Session completed (committed in SQLite, kept despite missing summary)"
|
|
896
|
+
);
|
|
878
897
|
}
|
|
879
|
-
fs3.unlinkSync(sessionFile);
|
|
880
|
-
const linkFile = path3.join(sessionLinksDir, `${sessionShortId}.json`);
|
|
881
|
-
if (fs3.existsSync(linkFile)) {
|
|
882
|
-
fs3.unlinkSync(linkFile);
|
|
883
|
-
}
|
|
884
|
-
console.error(
|
|
885
|
-
"[mneme] Session completed (not saved, cleaned up immediately)"
|
|
886
|
-
);
|
|
887
898
|
} else if (cleanupPolicy === "never") {
|
|
888
899
|
console.error(
|
|
889
900
|
"[mneme] Session completed (not saved, kept as uncommitted)"
|