claude-memory-layer 1.0.0

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.
Files changed (127) hide show
  1. package/.claude-plugin/commands/memory-forget.md +42 -0
  2. package/.claude-plugin/commands/memory-history.md +34 -0
  3. package/.claude-plugin/commands/memory-import.md +56 -0
  4. package/.claude-plugin/commands/memory-list.md +37 -0
  5. package/.claude-plugin/commands/memory-search.md +36 -0
  6. package/.claude-plugin/commands/memory-stats.md +34 -0
  7. package/.claude-plugin/hooks.json +59 -0
  8. package/.claude-plugin/plugin.json +24 -0
  9. package/.history/package_20260201112328.json +45 -0
  10. package/.history/package_20260201113602.json +45 -0
  11. package/.history/package_20260201113713.json +45 -0
  12. package/.history/package_20260201114110.json +45 -0
  13. package/Memo.txt +558 -0
  14. package/README.md +520 -0
  15. package/context.md +636 -0
  16. package/dist/.claude-plugin/commands/memory-forget.md +42 -0
  17. package/dist/.claude-plugin/commands/memory-history.md +34 -0
  18. package/dist/.claude-plugin/commands/memory-import.md +56 -0
  19. package/dist/.claude-plugin/commands/memory-list.md +37 -0
  20. package/dist/.claude-plugin/commands/memory-search.md +36 -0
  21. package/dist/.claude-plugin/commands/memory-stats.md +34 -0
  22. package/dist/.claude-plugin/hooks.json +59 -0
  23. package/dist/.claude-plugin/plugin.json +24 -0
  24. package/dist/cli/index.js +3539 -0
  25. package/dist/cli/index.js.map +7 -0
  26. package/dist/core/index.js +4408 -0
  27. package/dist/core/index.js.map +7 -0
  28. package/dist/hooks/session-end.js +2971 -0
  29. package/dist/hooks/session-end.js.map +7 -0
  30. package/dist/hooks/session-start.js +2969 -0
  31. package/dist/hooks/session-start.js.map +7 -0
  32. package/dist/hooks/stop.js +3123 -0
  33. package/dist/hooks/stop.js.map +7 -0
  34. package/dist/hooks/user-prompt-submit.js +2960 -0
  35. package/dist/hooks/user-prompt-submit.js.map +7 -0
  36. package/dist/services/memory-service.js +2931 -0
  37. package/dist/services/memory-service.js.map +7 -0
  38. package/package.json +45 -0
  39. package/plan.md +1642 -0
  40. package/scripts/build.ts +102 -0
  41. package/spec.md +624 -0
  42. package/specs/citations-system/context.md +243 -0
  43. package/specs/citations-system/plan.md +495 -0
  44. package/specs/citations-system/spec.md +371 -0
  45. package/specs/endless-mode/context.md +305 -0
  46. package/specs/endless-mode/plan.md +620 -0
  47. package/specs/endless-mode/spec.md +455 -0
  48. package/specs/entity-edge-model/context.md +401 -0
  49. package/specs/entity-edge-model/plan.md +459 -0
  50. package/specs/entity-edge-model/spec.md +391 -0
  51. package/specs/evidence-aligner-v2/context.md +401 -0
  52. package/specs/evidence-aligner-v2/plan.md +303 -0
  53. package/specs/evidence-aligner-v2/spec.md +312 -0
  54. package/specs/mcp-desktop-integration/context.md +278 -0
  55. package/specs/mcp-desktop-integration/plan.md +550 -0
  56. package/specs/mcp-desktop-integration/spec.md +494 -0
  57. package/specs/post-tool-use-hook/context.md +319 -0
  58. package/specs/post-tool-use-hook/plan.md +469 -0
  59. package/specs/post-tool-use-hook/spec.md +364 -0
  60. package/specs/private-tags/context.md +288 -0
  61. package/specs/private-tags/plan.md +412 -0
  62. package/specs/private-tags/spec.md +345 -0
  63. package/specs/progressive-disclosure/context.md +346 -0
  64. package/specs/progressive-disclosure/plan.md +663 -0
  65. package/specs/progressive-disclosure/spec.md +415 -0
  66. package/specs/task-entity-system/context.md +297 -0
  67. package/specs/task-entity-system/plan.md +301 -0
  68. package/specs/task-entity-system/spec.md +314 -0
  69. package/specs/vector-outbox-v2/context.md +470 -0
  70. package/specs/vector-outbox-v2/plan.md +562 -0
  71. package/specs/vector-outbox-v2/spec.md +466 -0
  72. package/specs/web-viewer-ui/context.md +384 -0
  73. package/specs/web-viewer-ui/plan.md +797 -0
  74. package/specs/web-viewer-ui/spec.md +516 -0
  75. package/src/cli/index.ts +570 -0
  76. package/src/core/canonical-key.ts +186 -0
  77. package/src/core/citation-generator.ts +63 -0
  78. package/src/core/consolidated-store.ts +279 -0
  79. package/src/core/consolidation-worker.ts +384 -0
  80. package/src/core/context-formatter.ts +276 -0
  81. package/src/core/continuity-manager.ts +336 -0
  82. package/src/core/edge-repo.ts +324 -0
  83. package/src/core/embedder.ts +124 -0
  84. package/src/core/entity-repo.ts +342 -0
  85. package/src/core/event-store.ts +672 -0
  86. package/src/core/evidence-aligner.ts +635 -0
  87. package/src/core/graduation.ts +365 -0
  88. package/src/core/index.ts +32 -0
  89. package/src/core/matcher.ts +210 -0
  90. package/src/core/metadata-extractor.ts +203 -0
  91. package/src/core/privacy/filter.ts +179 -0
  92. package/src/core/privacy/index.ts +20 -0
  93. package/src/core/privacy/tag-parser.ts +145 -0
  94. package/src/core/progressive-retriever.ts +415 -0
  95. package/src/core/retriever.ts +235 -0
  96. package/src/core/task/blocker-resolver.ts +325 -0
  97. package/src/core/task/index.ts +9 -0
  98. package/src/core/task/task-matcher.ts +238 -0
  99. package/src/core/task/task-projector.ts +345 -0
  100. package/src/core/task/task-resolver.ts +414 -0
  101. package/src/core/types.ts +841 -0
  102. package/src/core/vector-outbox.ts +295 -0
  103. package/src/core/vector-store.ts +182 -0
  104. package/src/core/vector-worker.ts +488 -0
  105. package/src/core/working-set-store.ts +244 -0
  106. package/src/hooks/post-tool-use.ts +127 -0
  107. package/src/hooks/session-end.ts +78 -0
  108. package/src/hooks/session-start.ts +57 -0
  109. package/src/hooks/stop.ts +78 -0
  110. package/src/hooks/user-prompt-submit.ts +54 -0
  111. package/src/mcp/handlers.ts +212 -0
  112. package/src/mcp/index.ts +47 -0
  113. package/src/mcp/tools.ts +78 -0
  114. package/src/server/api/citations.ts +101 -0
  115. package/src/server/api/events.ts +101 -0
  116. package/src/server/api/index.ts +18 -0
  117. package/src/server/api/search.ts +98 -0
  118. package/src/server/api/sessions.ts +111 -0
  119. package/src/server/api/stats.ts +97 -0
  120. package/src/server/index.ts +91 -0
  121. package/src/services/memory-service.ts +626 -0
  122. package/src/services/session-history-importer.ts +367 -0
  123. package/tests/canonical-key.test.ts +101 -0
  124. package/tests/evidence-aligner.test.ts +152 -0
  125. package/tests/matcher.test.ts +112 -0
  126. package/tsconfig.json +24 -0
  127. package/vitest.config.ts +15 -0
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Tests for AXIOMMIND Matcher
3
+ */
4
+
5
+ import { describe, it, expect } from 'vitest';
6
+ import { Matcher } from '../src/core/matcher.js';
7
+
8
+ describe('Matcher', () => {
9
+ const matcher = new Matcher();
10
+
11
+ describe('calculateCombinedScore', () => {
12
+ it('should calculate weighted score', () => {
13
+ const score = matcher.calculateCombinedScore(0.9, 0.8, 0, true);
14
+ // 0.4*0.9 + 0.25*0.8 + 0.2*1.0 + 0.15*1.0 = 0.36 + 0.2 + 0.2 + 0.15 = 0.91
15
+ expect(score).toBeCloseTo(0.91, 2);
16
+ });
17
+
18
+ it('should apply recency decay', () => {
19
+ const recentScore = matcher.calculateCombinedScore(0.9, 0.8, 0, true);
20
+ const oldScore = matcher.calculateCombinedScore(0.9, 0.8, 30, true);
21
+
22
+ expect(recentScore).toBeGreaterThan(oldScore);
23
+ });
24
+
25
+ it('should penalize inactive events', () => {
26
+ const activeScore = matcher.calculateCombinedScore(0.9, 0.8, 0, true);
27
+ const inactiveScore = matcher.calculateCombinedScore(0.9, 0.8, 0, false);
28
+
29
+ expect(activeScore).toBeGreaterThan(inactiveScore);
30
+ });
31
+
32
+ it('should cap score at 1.0', () => {
33
+ const score = matcher.calculateCombinedScore(1.0, 1.0, 0, true);
34
+ expect(score).toBeLessThanOrEqual(1.0);
35
+ });
36
+ });
37
+
38
+ describe('classifyConfidence', () => {
39
+ it('should return "high" for score >= 0.92 and gap >= 0.03', () => {
40
+ expect(matcher.classifyConfidence(0.95, 0.90)).toBe('high');
41
+ expect(matcher.classifyConfidence(0.92, 0.85)).toBe('high');
42
+ });
43
+
44
+ it('should return "suggested" for score >= 0.75 but not high', () => {
45
+ expect(matcher.classifyConfidence(0.85, 0.83)).toBe('suggested'); // gap too small
46
+ expect(matcher.classifyConfidence(0.75, null)).toBe('suggested');
47
+ });
48
+
49
+ it('should return "none" for score < 0.75', () => {
50
+ expect(matcher.classifyConfidence(0.70, null)).toBe('none');
51
+ expect(matcher.classifyConfidence(0.50, 0.30)).toBe('none');
52
+ });
53
+
54
+ it('should handle null second score', () => {
55
+ expect(matcher.classifyConfidence(0.95, null)).toBe('high');
56
+ });
57
+ });
58
+
59
+ describe('matchSearchResults', () => {
60
+ it('should return "none" confidence for empty results', () => {
61
+ const result = matcher.matchSearchResults([], () => 0);
62
+ expect(result.confidence).toBe('none');
63
+ expect(result.match).toBeNull();
64
+ });
65
+
66
+ it('should return match with calculated score', () => {
67
+ const results = [
68
+ {
69
+ id: 'vec1',
70
+ eventId: 'event1',
71
+ content: 'test content',
72
+ score: 0.95,
73
+ sessionId: 'session1',
74
+ eventType: 'user_prompt',
75
+ timestamp: new Date().toISOString()
76
+ }
77
+ ];
78
+
79
+ const result = matcher.matchSearchResults(results, () => 0);
80
+ expect(result.match).not.toBeNull();
81
+ expect(result.match?.event.id).toBe('event1');
82
+ });
83
+ });
84
+
85
+ describe('custom config', () => {
86
+ it('should use custom thresholds', () => {
87
+ const customMatcher = new Matcher({
88
+ minCombinedScore: 0.8,
89
+ minGap: 0.05,
90
+ suggestionThreshold: 0.6
91
+ });
92
+
93
+ // With custom thresholds, 0.85 should be high confidence
94
+ expect(customMatcher.classifyConfidence(0.85, 0.75)).toBe('high');
95
+ });
96
+
97
+ it('should use custom weights', () => {
98
+ const customMatcher = new Matcher({
99
+ weights: {
100
+ semanticSimilarity: 0.6,
101
+ ftsScore: 0.2,
102
+ recencyBonus: 0.1,
103
+ statusWeight: 0.1
104
+ }
105
+ });
106
+
107
+ const score = customMatcher.calculateCombinedScore(0.9, 0.5, 0, true);
108
+ // 0.6*0.9 + 0.2*0.5 + 0.1*1.0 + 0.1*1.0 = 0.54 + 0.1 + 0.1 + 0.1 = 0.84
109
+ expect(score).toBeCloseTo(0.84, 2);
110
+ });
111
+ });
112
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "strict": true,
7
+ "esModuleInterop": true,
8
+ "skipLibCheck": true,
9
+ "forceConsistentCasingInFileNames": true,
10
+ "outDir": "dist",
11
+ "rootDir": "src",
12
+ "declaration": true,
13
+ "declarationMap": true,
14
+ "sourceMap": true,
15
+ "resolveJsonModule": true,
16
+ "isolatedModules": true,
17
+ "noUnusedLocals": true,
18
+ "noUnusedParameters": true,
19
+ "noImplicitReturns": true,
20
+ "noFallthroughCasesInSwitch": true
21
+ },
22
+ "include": ["src/**/*"],
23
+ "exclude": ["node_modules", "dist", "tests"]
24
+ }
@@ -0,0 +1,15 @@
1
+ import { defineConfig } from 'vitest/config';
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ globals: true,
6
+ environment: 'node',
7
+ include: ['tests/**/*.test.ts'],
8
+ coverage: {
9
+ provider: 'v8',
10
+ reporter: ['text', 'json', 'html'],
11
+ include: ['src/**/*.ts'],
12
+ exclude: ['src/**/*.d.ts']
13
+ }
14
+ }
15
+ });