@hir4ta/mneme 0.22.2 → 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.
@@ -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.2",
4
+ "version": "0.22.3",
5
5
  "author": {
6
6
  "name": "hir4ta"
7
7
  },
package/README.ja.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # mneme
2
2
 
3
- ![Version](https://img.shields.io/badge/version-0.22.2-blue)
3
+ ![Version](https://img.shields.io/badge/version-0.22.3-blue)
4
4
  ![Node.js](https://img.shields.io/badge/node-%3E%3D22.5.0-brightgreen)
5
5
  [![NPM Version](https://img.shields.io/npm/v/%40hir4ta%2Fmneme)](https://www.npmjs.com/package/@hir4ta/mneme)
6
6
  [![MIT License](https://img.shields.io/npm/l/%40hir4ta%2Fmneme)](https://github.com/hir4ta/mneme/blob/main/LICENSE)
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # mneme
2
2
 
3
- ![Version](https://img.shields.io/badge/version-0.22.2-blue)
3
+ ![Version](https://img.shields.io/badge/version-0.22.3-blue)
4
4
  ![Node.js](https://img.shields.io/badge/node-%3E%3D22.5.0-brightgreen)
5
5
  [![NPM Version](https://img.shields.io/npm/v/%40hir4ta%2Fmneme)](https://www.npmjs.com/package/@hir4ta/mneme)
6
6
  [![MIT License](https://img.shields.io/npm/l/%40hir4ta%2Fmneme)](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 > user.timestamp && a.timestamp < nextUserTs
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", "unit", "interaction"],
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(
@@ -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", "unit", "interaction"],
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 > user.timestamp && a.timestamp < nextUserTs
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);