From b41a517e99afa4d9cd0e2e6f84bb7c40d4bde04f Mon Sep 17 00:00:00 2001 From: reevesc88 Date: Sun, 1 Nov 2026 07:00:20 +0800 Subject: [PATCH 1/3] fix: preserve original memory types in search responses Signed-off-by: reevesc88 --- AGENTS.md | 4 +- README.md | 4 +- READMEs/README.ar-SA.md | 4 +- READMEs/README.bn-BD.md | 4 +- READMEs/README.cs-CZ.md | 4 +- READMEs/README.da-DK.md | 4 +- READMEs/README.de-DE.md | 4 +- READMEs/README.el-GR.md | 4 +- READMEs/README.es-ES.md | 4 +- READMEs/README.fi-FI.md | 4 +- READMEs/README.fr-FR.md | 4 +- READMEs/README.he-IL.md | 4 +- READMEs/README.hi-IN.md | 4 +- READMEs/README.hu-HU.md | 4 +- READMEs/README.id-ID.md | 4 +- READMEs/README.it-IT.md | 4 +- READMEs/README.ja-JP.md | 4 +- READMEs/README.ko-KR.md | 4 +- READMEs/README.nb-NO.md | 4 +- READMEs/README.nl-NL.md | 4 +- READMEs/README.pl-PL.md | 4 +- READMEs/README.pt-BR.md | 4 +- READMEs/README.pt-PT.md | 4 +- READMEs/README.ro-RO.md | 4 +- READMEs/README.ru-RU.md | 4 +- READMEs/README.sv-SE.md | 4 +- READMEs/README.th-TH.md | 4 +- READMEs/README.tl-PH.md | 4 +- READMEs/README.tr-TR.md | 4 +- READMEs/README.uk-UA.md | 4 +- READMEs/README.ur-PK.md | 4 +- READMEs/README.vi-VN.md | 4 +- READMEs/README.zh-CN.md | 4 +- READMEs/README.zh-TW.md | 4 +- assets/tags/light/stat-tests.svg | 4 +- assets/tags/stat-tests.svg | 4 +- docs/recall.md | 24 +++++++ scripts/docs-sync.state.json | 2 +- src/functions/recall-response.ts | 4 ++ src/functions/smart-search.ts | 24 ++++--- src/mcp/standalone.ts | 2 +- src/state/memory-utils.ts | 6 +- src/types.ts | 4 ++ test/mcp-standalone.test.ts | 11 ++++ test/memory-type-metadata.test.ts | 102 ++++++++++++++++++++++++++++++ 45 files changed, 238 insertions(+), 85 deletions(-) create mode 100644 test/memory-type-metadata.test.ts diff --git a/AGENTS.md b/AGENTS.md index 6c88f558e2..c53122c1e1 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -101,7 +101,7 @@ Hook scripts in `src/hooks/` are standalone Node.js scripts (no iii-sdk import). ## Testing -- Before every commit run, in order: `npm run build`, `npm run skills:gen`, `npm run docs:sync`, `npm run skills:check`, `npm test` (4,000+ tests). Commit anything the generators changed. CI runs the same build, skills check and tests. +- Before every commit run, in order: `npm run build`, `npm run skills:gen`, `npm run docs:sync`, `npm run skills:check`, `npm test` (4,100+ tests). Commit anything the generators changed. CI runs the same build, skills check and tests. - Before any npm publish: `npm run release:gate` must pass. It installs the packed tarballs into a clean home and runs capture, recovery, restart, export/import, MCP and status checks against the installed CLI (see CONTRIBUTING.md, Release process) - Mock pattern: `vi.mock("iii-sdk")` with mock `sdk.trigger`, `kv.get/set/list` - Test files go in `test/` with `.test.ts` extension @@ -114,4 +114,4 @@ Hook scripts in `src/hooks/` are standalone Node.js scripts (no iii-sdk import). - 6 MCP resources, 3 MCP prompts - 12 hooks, 17 skills - 322+ iii functions -- 4,000+ tests +- 4,100+ tests diff --git a/README.md b/README.md index 0cc41b258a..b371b080e4 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ 54 MCP tools 12 auto hooks 0 external DBs - 4,000+ tests passing + 4,100+ tests passing

@@ -1307,7 +1307,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,000+ tests +npm test # 4,100+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.ar-SA.md b/READMEs/README.ar-SA.md index 3199b8a8d7..432c2446ec 100644 --- a/READMEs/README.ar-SA.md +++ b/READMEs/README.ar-SA.md @@ -71,7 +71,7 @@ 54 MCP tools 12 auto hooks 0 external DBs - 4,000+ tests passing + 4,100+ tests passing

@@ -1242,7 +1242,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,000+ tests +npm test # 4,100+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.bn-BD.md b/READMEs/README.bn-BD.md index 8fe8425a88..8a85ba1375 100644 --- a/READMEs/README.bn-BD.md +++ b/READMEs/README.bn-BD.md @@ -69,7 +69,7 @@ 54 MCP টুল 12 অটো হুক 0 এক্সটার্নাল ডিবি - 4,000+ টেস্ট পাস + 4,100+ টেস্ট পাস

@@ -1255,7 +1255,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,000+ tests +npm test # 4,100+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.cs-CZ.md b/READMEs/README.cs-CZ.md index d0960e654a..6733e9778b 100644 --- a/READMEs/README.cs-CZ.md +++ b/READMEs/README.cs-CZ.md @@ -69,7 +69,7 @@ 54 MCP nástrojů 12 automatických hooks 0 externích databází - 4,000+ testů úspěšně proběhlo + 4,100+ testů úspěšně proběhlo

@@ -1241,7 +1241,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,000+ tests +npm test # 4,100+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.da-DK.md b/READMEs/README.da-DK.md index 0c124bb1b3..986f11e1c0 100644 --- a/READMEs/README.da-DK.md +++ b/READMEs/README.da-DK.md @@ -69,7 +69,7 @@ 54 MCP-værktøjer 12 automatiske hooks 0 eksterne databaser - 4,000+ beståede tests + 4,100+ beståede tests

@@ -1249,7 +1249,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,000+ tests +npm test # 4,100+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.de-DE.md b/READMEs/README.de-DE.md index 25d246df90..7a7aee598b 100644 --- a/READMEs/README.de-DE.md +++ b/READMEs/README.de-DE.md @@ -69,7 +69,7 @@ 54 MCP-Tools 12 Auto-Hooks 0 externe DBs - 4,000+ bestandene Tests + 4,100+ bestandene Tests

@@ -1247,7 +1247,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,000+ tests +npm test # 4,100+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.el-GR.md b/READMEs/README.el-GR.md index 9fdaf0a8ed..da436a98c1 100644 --- a/READMEs/README.el-GR.md +++ b/READMEs/README.el-GR.md @@ -69,7 +69,7 @@ 54 εργαλεία MCP 12 αυτόματα hooks 0 εξωτερικές βάσεις δεδομένων - 4,000+ επιτυχημένες δοκιμές + 4,100+ επιτυχημένες δοκιμές

@@ -1241,7 +1241,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,000+ tests +npm test # 4,100+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.es-ES.md b/READMEs/README.es-ES.md index 9e646f18ae..9a2add4427 100644 --- a/READMEs/README.es-ES.md +++ b/READMEs/README.es-ES.md @@ -69,7 +69,7 @@ 54 tools MCP 12 hooks automáticos 0 bases de datos externas - 4,000+ tests superados + 4,100+ tests superados

@@ -1243,7 +1243,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,000+ tests +npm test # 4,100+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.fi-FI.md b/READMEs/README.fi-FI.md index 0af45964b9..f0d7093a4f 100644 --- a/READMEs/README.fi-FI.md +++ b/READMEs/README.fi-FI.md @@ -69,7 +69,7 @@ 54 MCP-työkalua 12 automaattista hookia 0 ulkoista tietokantaa - 4,000+ testiä läpäisty + 4,100+ testiä läpäisty

@@ -1241,7 +1241,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,000+ tests +npm test # 4,100+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.fr-FR.md b/READMEs/README.fr-FR.md index 6e8a3510ae..60ed0f017a 100644 --- a/READMEs/README.fr-FR.md +++ b/READMEs/README.fr-FR.md @@ -69,7 +69,7 @@ 54 MCP tools 12 auto hooks 0 external DBs - 4,000+ tests passing + 4,100+ tests passing

@@ -1250,7 +1250,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,000+ tests +npm test # 4,100+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.he-IL.md b/READMEs/README.he-IL.md index 6cd626a723..580e9069b0 100644 --- a/READMEs/README.he-IL.md +++ b/READMEs/README.he-IL.md @@ -71,7 +71,7 @@ 54 כלי MCP 12 hooks אוטומטיים 0 מסדי נתונים חיצוניים - 4,000+ בדיקות עוברות + 4,100+ בדיקות עוברות

@@ -1242,7 +1242,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,000+ tests +npm test # 4,100+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.hi-IN.md b/READMEs/README.hi-IN.md index c8fbebef85..04eb563111 100644 --- a/READMEs/README.hi-IN.md +++ b/READMEs/README.hi-IN.md @@ -69,7 +69,7 @@ 54 MCP tools 12 auto hooks 0 external DBs - 4,000+ tests passing + 4,100+ tests passing

@@ -1256,7 +1256,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,000+ tests +npm test # 4,100+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.hu-HU.md b/READMEs/README.hu-HU.md index 864dbdb03c..2951739da5 100644 --- a/READMEs/README.hu-HU.md +++ b/READMEs/README.hu-HU.md @@ -69,7 +69,7 @@ 54 MCP eszköz 12 automatikus hook 0 külső adatbázis - 4,000+ sikeres teszt + 4,100+ sikeres teszt

@@ -1239,7 +1239,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,000+ tests +npm test # 4,100+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.id-ID.md b/READMEs/README.id-ID.md index 37ee206858..b9b300ebfc 100644 --- a/READMEs/README.id-ID.md +++ b/READMEs/README.id-ID.md @@ -69,7 +69,7 @@ 54 tool MCP 12 hook otomatis 0 DB eksternal - 4,000+ pengujian lolos + 4,100+ pengujian lolos

@@ -1256,7 +1256,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,000+ tests +npm test # 4,100+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.it-IT.md b/READMEs/README.it-IT.md index 8bf8a07fc9..76c4267bd3 100644 --- a/READMEs/README.it-IT.md +++ b/READMEs/README.it-IT.md @@ -69,7 +69,7 @@ 54 MCP tools 12 auto hooks 0 external DBs - 4,000+ tests passing + 4,100+ tests passing

@@ -1249,7 +1249,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,000+ tests +npm test # 4,100+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.ja-JP.md b/READMEs/README.ja-JP.md index ce2d9dee07..5f3bd8dd2d 100644 --- a/READMEs/README.ja-JP.md +++ b/READMEs/README.ja-JP.md @@ -69,7 +69,7 @@ 54 MCP ツール 12 自動 hooks 外部 DB 0 個 - 4,000+ 件のテストが成功 + 4,100+ 件のテストが成功

@@ -1255,7 +1255,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,000+ tests +npm test # 4,100+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.ko-KR.md b/READMEs/README.ko-KR.md index 9958760be9..75ea0ac701 100644 --- a/READMEs/README.ko-KR.md +++ b/READMEs/README.ko-KR.md @@ -69,7 +69,7 @@ 54 MCP tools 12 auto hooks 0 external DBs - 4,000+ tests passing + 4,100+ tests passing

@@ -1254,7 +1254,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,000+ tests +npm test # 4,100+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.nb-NO.md b/READMEs/README.nb-NO.md index 56ebebc6ba..59f55f0809 100644 --- a/READMEs/README.nb-NO.md +++ b/READMEs/README.nb-NO.md @@ -69,7 +69,7 @@ 54 MCP tools 12 auto hooks 0 external DBs - 4,000+ tests passing + 4,100+ tests passing

@@ -1247,7 +1247,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,000+ tests +npm test # 4,100+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.nl-NL.md b/READMEs/README.nl-NL.md index 569d1fb29c..d5f8c62a3d 100644 --- a/READMEs/README.nl-NL.md +++ b/READMEs/README.nl-NL.md @@ -69,7 +69,7 @@ 54 MCP tools 12 auto hooks 0 external DBs - 4,000+ tests passing + 4,100+ tests passing

@@ -1243,7 +1243,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,000+ tests +npm test # 4,100+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.pl-PL.md b/READMEs/README.pl-PL.md index bdbe4eea32..d20aa558c1 100644 --- a/READMEs/README.pl-PL.md +++ b/READMEs/README.pl-PL.md @@ -69,7 +69,7 @@ 54 narzędzia MCP 12 automatycznych hooków 0 zewnętrznych baz danych - 4,000+ zaliczonych testów + 4,100+ zaliczonych testów

@@ -1239,7 +1239,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,000+ tests +npm test # 4,100+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.pt-BR.md b/READMEs/README.pt-BR.md index b076d8d82e..c6c37e69f3 100644 --- a/READMEs/README.pt-BR.md +++ b/READMEs/README.pt-BR.md @@ -69,7 +69,7 @@ 54 MCP tools 12 auto hooks 0 external DBs - 4,000+ tests passing + 4,100+ tests passing

@@ -1247,7 +1247,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,000+ tests +npm test # 4,100+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.pt-PT.md b/READMEs/README.pt-PT.md index 36ff810e19..0b57b1b8db 100644 --- a/READMEs/README.pt-PT.md +++ b/READMEs/README.pt-PT.md @@ -69,7 +69,7 @@ 54 ferramentas MCP 12 hooks automáticos 0 bases de dados externas - 4,000+ testes aprovados + 4,100+ testes aprovados

@@ -1243,7 +1243,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,000+ tests +npm test # 4,100+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.ro-RO.md b/READMEs/README.ro-RO.md index 890afccaef..3e1f4c5870 100644 --- a/READMEs/README.ro-RO.md +++ b/READMEs/README.ro-RO.md @@ -69,7 +69,7 @@ 54 de instrumente MCP 12 hook-uri automate 0 baze de date externe - 4,000+ teste trecute + 4,100+ teste trecute

@@ -1235,7 +1235,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,000+ tests +npm test # 4,100+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.ru-RU.md b/READMEs/README.ru-RU.md index af94d55bbb..3ea4e5de29 100644 --- a/READMEs/README.ru-RU.md +++ b/READMEs/README.ru-RU.md @@ -69,7 +69,7 @@ 54 MCP tools 12 auto hooks 0 external DBs - 4,000+ tests passing + 4,100+ tests passing

@@ -1241,7 +1241,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,000+ tests +npm test # 4,100+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.sv-SE.md b/READMEs/README.sv-SE.md index a130b39bd2..3c3e72e866 100644 --- a/READMEs/README.sv-SE.md +++ b/READMEs/README.sv-SE.md @@ -69,7 +69,7 @@ 54 MCP-verktyg 12 automatiska hooks 0 externa databaser - 4,000+ godkända tester + 4,100+ godkända tester

@@ -1249,7 +1249,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,000+ tests +npm test # 4,100+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.th-TH.md b/READMEs/README.th-TH.md index b549a34e6a..76671822b6 100644 --- a/READMEs/README.th-TH.md +++ b/READMEs/README.th-TH.md @@ -69,7 +69,7 @@ 54 เครื่องมือ MCP 12 hook อัตโนมัติ ไม่ต้องพึ่ง external DB เลย - ผ่านการทดสอบ 4,000+ รายการ + ผ่านการทดสอบ 4,100+ รายการ

@@ -1242,7 +1242,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,000+ tests +npm test # 4,100+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.tl-PH.md b/READMEs/README.tl-PH.md index 2d4dcfe47d..ff68ebdba6 100644 --- a/READMEs/README.tl-PH.md +++ b/READMEs/README.tl-PH.md @@ -69,7 +69,7 @@ 54 MCP tool 12 awtomatikong hook 0 panlabas na DB - 4,000+ pumapasang test + 4,100+ pumapasang test

@@ -1251,7 +1251,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,000+ tests +npm test # 4,100+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.tr-TR.md b/READMEs/README.tr-TR.md index 0b08152ae9..a5d36b5299 100644 --- a/READMEs/README.tr-TR.md +++ b/READMEs/README.tr-TR.md @@ -69,7 +69,7 @@ 54 MCP tools 12 auto hooks 0 external DBs - 4,000+ tests passing + 4,100+ tests passing

@@ -1241,7 +1241,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,000+ tests +npm test # 4,100+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.uk-UA.md b/READMEs/README.uk-UA.md index ad26bff5c1..4033a79f17 100644 --- a/READMEs/README.uk-UA.md +++ b/READMEs/README.uk-UA.md @@ -69,7 +69,7 @@ 54 інструменти MCP 12 автоматичних хуків 0 зовнішніх БД - 4,000+ тестів пройдено + 4,100+ тестів пройдено

@@ -1242,7 +1242,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,000+ tests +npm test # 4,100+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.ur-PK.md b/READMEs/README.ur-PK.md index 62602b9130..53f941522e 100644 --- a/READMEs/README.ur-PK.md +++ b/READMEs/README.ur-PK.md @@ -71,7 +71,7 @@ 54 MCP ٹولز 12 خودکار ہکس 0 خارجی ڈیٹابیسز - 4,000+ ٹیسٹس پاس ہو رہے ہیں + 4,100+ ٹیسٹس پاس ہو رہے ہیں

@@ -1246,7 +1246,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,000+ tests +npm test # 4,100+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.vi-VN.md b/READMEs/README.vi-VN.md index 3a7879a3f5..2be083144f 100644 --- a/READMEs/README.vi-VN.md +++ b/READMEs/README.vi-VN.md @@ -69,7 +69,7 @@ 54 MCP tools 12 auto hooks 0 external DBs - 4,000+ tests passing + 4,100+ tests passing

@@ -1251,7 +1251,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,000+ tests +npm test # 4,100+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.zh-CN.md b/READMEs/README.zh-CN.md index b12e7fe2fd..a96226f914 100644 --- a/READMEs/README.zh-CN.md +++ b/READMEs/README.zh-CN.md @@ -69,7 +69,7 @@ 54 个 MCP 工具 12 个自动 hooks 0 个外部数据库 - 4,000+ 项测试通过 + 4,100+ 项测试通过

@@ -1252,7 +1252,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,000+ tests +npm test # 4,100+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/READMEs/README.zh-TW.md b/READMEs/README.zh-TW.md index bfd866fee0..5ed8dc3dce 100644 --- a/READMEs/README.zh-TW.md +++ b/READMEs/README.zh-TW.md @@ -69,7 +69,7 @@ 54 個 MCP 工具 12 個自動 hooks 0 個外部資料庫 - 4,000+ 測試通過 + 4,100+ 測試通過

@@ -1244,7 +1244,7 @@ curl -X POST http://localhost:3111/agentmemory/graph/compact -H "Authorization: ```bash npm run dev # Hot reload npm run build # Production build -npm test # 4,000+ tests +npm test # 4,100+ tests npm run test:integration # API tests (requires running services) ``` diff --git a/assets/tags/light/stat-tests.svg b/assets/tags/light/stat-tests.svg index 915e1bab9d..7248bfad00 100644 --- a/assets/tags/light/stat-tests.svg +++ b/assets/tags/light/stat-tests.svg @@ -1,5 +1,5 @@ - + - 4000+ + 4100+ TESTS PASSING diff --git a/assets/tags/stat-tests.svg b/assets/tags/stat-tests.svg index 99b680533e..e51099c87f 100644 --- a/assets/tags/stat-tests.svg +++ b/assets/tags/stat-tests.svg @@ -1,5 +1,5 @@ - + - 4000+ + 4100+ TESTS PASSING diff --git a/docs/recall.md b/docs/recall.md index 434dc5bfc6..d7fb77b02e 100644 --- a/docs/recall.md +++ b/docs/recall.md @@ -26,6 +26,30 @@ Its optional lesson list accompanies mixed search only. Use `memory_lesson_recal for lessons and `memory_insight_list` for insights. Layer selection is separate from `project` and `agentId`; preserve scope filters when expanding results. +## Original memory types + +Saved memories have their own `type`, such as `fact`, `preference`, or +`architecture`. Search adapts them to the observation format, where `type` +remains `decision`. Read `memoryType` for the original saved-memory type. + +Compact search returns `memoryType` beside `type`. Expanded search and full +recall put it inside `observation`. Compact and narrative recall retain it, +including shortened previews. Ordinary observations and lessons omit it. + +For example, a saved fact appears as: + +```json +{ + "type": "decision", + "memoryType": "fact" +} +``` + +Older persisted indexes need no migration: compact smart search resolves the +type from the authorized saved record. Stored memory types and the observation +type enum do not change. The reduced local MCP fallback adds `memoryType` while +retaining its existing compact response fields. + ## Budgeted recall All three `memory_recall` formats (`full`, `compact`, `narrative`) return structured diff --git a/scripts/docs-sync.state.json b/scripts/docs-sync.state.json index 0538665c6a..a17f6cf914 100644 --- a/scripts/docs-sync.state.json +++ b/scripts/docs-sync.state.json @@ -20,7 +20,7 @@ "12" ], "tests": [ - "4000+" + "4100+" ], "functions": [ "322" diff --git a/src/functions/recall-response.ts b/src/functions/recall-response.ts index dadd6559cd..220b470d00 100644 --- a/src/functions/recall-response.ts +++ b/src/functions/recall-response.ts @@ -54,6 +54,7 @@ function formatResult(result: SearchResult, format: RecallFormat): RecallResult sessionId: result.sessionId, title: observation.title, type: observation.type, + ...(observation.memoryType !== undefined && { memoryType: observation.memoryType }), score: result.score, timestamp: observation.timestamp, ...(result.layer !== undefined && { layer: result.layer }), @@ -76,6 +77,7 @@ function clipResult( sessionId: result.sessionId, title: "", type: observation.type, + ...(observation.memoryType !== undefined && { memoryType: observation.memoryType }), score: result.score, timestamp: observation.timestamp, ...layer, @@ -96,6 +98,7 @@ function clipResult( sessionId: result.sessionId, title, narrative, + ...(observation.memoryType !== undefined && { memoryType: observation.memoryType }), score: result.score, timestamp: observation.timestamp, ...layer, @@ -108,6 +111,7 @@ function clipResult( sessionId: observation.sessionId, timestamp: observation.timestamp, type: observation.type, + ...(observation.memoryType !== undefined && { memoryType: observation.memoryType }), title, facts: [], narrative, diff --git a/src/functions/smart-search.ts b/src/functions/smart-search.ts index 19318b0669..b0610a7d35 100644 --- a/src/functions/smart-search.ts +++ b/src/functions/smart-search.ts @@ -227,14 +227,22 @@ export function registerSmartSearchFunction( .slice(0, limit) : projectResults.slice(0, limit); - const compact: CompactSearchResult[] = filteredHybrid.map((r) => ({ - obsId: r.observation.id, - layer: r.layer ?? getSearchIndex().layerOf(r.observation.id) ?? getSearchResultLayer(r.observation.id, r.sessionId), - sessionId: r.sessionId, - title: r.observation.title, - type: r.observation.type, - score: r.combinedScore, - timestamp: r.observation.timestamp, + const compact: CompactSearchResult[] = await Promise.all(filteredHybrid.map(async (r) => { + const layer = r.layer ?? getSearchIndex().layerOf(r.observation.id) ?? getSearchResultLayer(r.observation.id, r.sessionId); + // Older persisted indexes lack memoryType; use the already-authorized source row. + const memoryType = layer === "memory" + ? (await kv.get(KV.memories, r.observation.id))?.type ?? r.observation.memoryType + : undefined; + return { + obsId: r.observation.id, + layer, + sessionId: r.sessionId, + title: r.observation.title, + type: r.observation.type, + ...(memoryType !== undefined && { memoryType }), + score: r.combinedScore, + timestamp: r.observation.timestamp, + }; })); void recordAccessBatch( diff --git a/src/mcp/standalone.ts b/src/mcp/standalone.ts index 0a5a820649..b310c18bab 100644 --- a/src/mcp/standalone.ts +++ b/src/mcp/standalone.ts @@ -413,7 +413,7 @@ async function handleLocal( return textResponse(buildRecallResponse(matches, v.format ?? "full", v.tokenBudget), true); } return textResponse({ mode: "compact", results: results.map((memory) => ({ - ...memory, obsId: memory.id, sessionId: memory.sessionIds?.[0] ?? "memory", layer: "memory", + ...memory, memoryType: memory.type, obsId: memory.id, sessionId: memory.sessionIds?.[0] ?? "memory", layer: "memory", })) }, true); } diff --git a/src/state/memory-utils.ts b/src/state/memory-utils.ts index 9bc5b16afa..a7d1bbc41e 100644 --- a/src/state/memory-utils.ts +++ b/src/state/memory-utils.ts @@ -3,9 +3,8 @@ import type { CompressedObservation, Lesson, Memory } from "../types.js"; // Wraps a Memory record in the CompressedObservation shape that // SearchIndex / VectorIndex / enrichment paths consume. Memories share // the same searchable fields as observations (title + content + -// concepts + files); type is normalized to "decision" so memories stay -// distinguishable in result metadata without colliding with observation -// enums (file_read, command_run, …). The synthetic sessionId +// concepts + files). Keep the observation enum compatible and preserve the +// original durable-memory type separately in memoryType. The synthetic sessionId // ("memory" or memory.sessionIds[0]) is what enrich-side fallbacks key // off of when looking up the source record in KV.memories. export function memoryToObservation(memory: Memory): CompressedObservation { @@ -14,6 +13,7 @@ export function memoryToObservation(memory: Memory): CompressedObservation { sessionId: memory.sessionIds?.[0] ?? "memory", timestamp: memory.createdAt, type: "decision", + memoryType: memory.type, title: memory.title, facts: [memory.content], narrative: memory.content, diff --git a/src/types.ts b/src/types.ts index c6d6a37026..6b71f61234 100644 --- a/src/types.ts +++ b/src/types.ts @@ -96,6 +96,8 @@ export interface CompressedObservation { sessionId: string; timestamp: string; type: ObservationType; + /** Original durable-memory type; observation type remains schema-compatible. */ + memoryType?: Memory["type"]; title: string; subtitle?: string; facts: string[]; @@ -346,6 +348,8 @@ export interface CompactSearchResult { sessionId: string; title: string; type: ObservationType; + /** Original durable-memory type; observation type remains schema-compatible. */ + memoryType?: Memory["type"]; score: number; timestamp: string; layer?: "memory" | "observation" | "lesson" | "insight"; diff --git a/test/mcp-standalone.test.ts b/test/mcp-standalone.test.ts index 7d3edd5a0f..0903574807 100644 --- a/test/mcp-standalone.test.ts +++ b/test/mcp-standalone.test.ts @@ -282,6 +282,17 @@ describe("handleToolCall", () => { expect(parsed.results[0].content).toBe("Use bcrypt for password hashing"); }); + it.each(["pattern", "preference", "architecture", "bug", "workflow", "fact"])("retains %s metadata in fallback compact and expanded search", async (type) => { + const kv = new InMemoryKV(); + await handleToolCall("memory_save", { content: "Synthetic type probe", type, project: "type-project" }, kv); + const compact = JSON.parse((await handleToolCall("memory_smart_search", { query: "Synthetic", project: "type-project" }, kv)).content[0].text); + expect(compact.results[0]).toHaveProperty("memoryType", type); + const id = compact.results[0].obsId; + const expanded = JSON.parse((await handleToolCall("memory_smart_search", { expandIds: id, project: "type-project" }, kv)).content[0].text); + expect(expanded.results[0].observation).toMatchObject({ id, type: "decision", memoryType: type }); + expect((await kv.get<{ type: string }>("mem:memories", id))?.type).toBe(type); + }); + it("memory_smart_search rejects empty query to prevent match-all in forget flow", async () => { const kv = new InMemoryKV(); await handleToolCall("memory_save", { content: "anything" }, kv); diff --git a/test/memory-type-metadata.test.ts b/test/memory-type-metadata.test.ts new file mode 100644 index 0000000000..1e7c6a5f29 --- /dev/null +++ b/test/memory-type-metadata.test.ts @@ -0,0 +1,102 @@ +import { describe, expect, it, vi } from "vitest"; +import { memoryToObservation, lessonToObservation } from "../src/state/memory-utils.js"; +import { registerSmartSearchFunction } from "../src/functions/smart-search.js"; +import { buildRecallResponse } from "../src/functions/recall-response.js"; +import { CompressOutputSchema } from "../src/eval/schemas.js"; +import type { Memory, Lesson, CompressedObservation, HybridSearchResult } from "../src/types.js"; +import type { IIIClient } from "iii-sdk"; +import type { StateKV } from "../src/state/kv.js"; + +vi.mock("../src/logger.js", () => ({ logger: { info: vi.fn(), warn: vi.fn(), error: vi.fn() } })); + +const types: Memory["type"][] = ["pattern", "preference", "architecture", "bug", "workflow", "fact"]; +function memory(type: Memory["type"]): Memory { + return { + id: `mem_${type}`, type, title: "Synthetic type preservation", content: "Synthetic content. ".repeat(200), + createdAt: "2026-10-31T14:44:33.707Z", updatedAt: "2026-10-31T14:44:33.707Z", + concepts: ["synthetic"], files: [], sessionIds: [], strength: 7, version: 1, isLatest: true, + project: "project-a", agentId: "owner", + }; +} + +function fixture(saved: Memory, legacy = false) { + const store = new Map>([["mem:memories", new Map([[saved.id, saved]])]]); + const kv = { + get: async (scope: string, id: string) => store.get(scope)?.get(id) ?? null, + set: async (scope: string, id: string, value: unknown) => { + if (!store.has(scope)) store.set(scope, new Map()); + store.get(scope)!.set(id, value); + return value; + }, + list: async (scope: string) => [...(store.get(scope)?.values() ?? [])], + }; + let handler: (args: object) => Promise<{ + mode: string; + results: Array<{ obsId: string; observation?: CompressedObservation }>; + truncated?: boolean; + }>; + const sdk = { registerFunction: (_: string, fn: typeof handler) => { handler = fn; } }; + const observation = memoryToObservation(saved); + if (legacy) delete observation.memoryType; + const search = vi.fn(async (): Promise => [{ + observation, sessionId: "memory", layer: "memory", combinedScore: 1, + bm25Score: 1, vectorScore: 0, graphScore: 0, + }]); + // The in-memory doubles implement only the SDK/KV methods this function exercises. + registerSmartSearchFunction(sdk as unknown as IIIClient, kv as unknown as StateKV, search); + return { call: (args: object) => handler(args), saved }; +} + +describe("original memory type metadata", () => { + it.each(types)("preserves %s without changing the observation type or input", (type) => { + const saved = memory(type); + const before = structuredClone(saved); + const result = memoryToObservation(Object.freeze(saved)); + expect(result).toMatchObject({ id: saved.id, type: "decision", memoryType: type, narrative: saved.content, agentId: "owner" }); + expect(saved).toEqual(before); + expect(CompressOutputSchema.safeParse(result).success).toBe(true); + expect(CompressOutputSchema.safeParse({ ...result, type }).success).toBe(false); + }); + + it.each(types)("preserves %s in compact and expanded search, including a legacy index", async (type) => { + const f = fixture(memory(type), true); + const scope = { project: "project-a", agentId: "*", targetLayer: "memory", includeLessons: false }; + const compact = await f.call({ query: "Synthetic", ...scope }); + expect(compact.results[0]).toMatchObject({ obsId: f.saved.id, type: "decision", memoryType: type }); + const expanded = await f.call({ expandIds: [f.saved.id], ...scope }); + expect(expanded.results[0].observation).toMatchObject({ type: "decision", memoryType: type, narrative: f.saved.content }); + expect(expanded.truncated).toBe(false); + expect((await f.call({ query: "Synthetic", ...scope, project: "project-b" })).results).toEqual([]); + expect((await f.call({ expandIds: [f.saved.id], ...scope, project: "project-b" })).results).toEqual([]); + expect((await f.call({ query: "Synthetic", ...scope, agentId: "other" })).results).toEqual([]); + expect((await f.call({ expandIds: [f.saved.id], ...scope, agentId: "other" })).results).toEqual([]); + expect((await f.call({ query: "Synthetic", ...scope, targetLayer: "observation" })).results).toEqual([]); + }); + + it.each(["full", "compact", "narrative"] as const)("retains memoryType in %s recall with and without clipping", (format) => { + const observation = memoryToObservation(memory("fact")); + observation.title = "Synthetic memory title ".repeat(100); + const result = { observation, sessionId: "memory", layer: "memory" as const, score: 1 }; + for (const budget of [undefined, 250]) { + const response = buildRecallResponse([result], format, budget); + const first = response.results[0]; + expect(first).toBeDefined(); + const metadata = "observation" in first ? first.observation : first; + expect(metadata).toHaveProperty("memoryType", "fact"); + if (budget) { + expect(first).toHaveProperty("content_truncated", true); + expect(response.tokens_used).toBeLessThanOrEqual(budget); + } + } + }); + + it("does not assign a memory type to lessons or ordinary observations", () => { + const lesson = { id: "lsn_test", content: "Lesson", context: "", tags: [], confidence: 7, createdAt: "2026-10-31" } as Lesson; + expect(lessonToObservation(lesson)).not.toHaveProperty("memoryType"); + const observation: CompressedObservation = { ...memoryToObservation(memory("fact")), id: "obs_test", type: "file_read" }; + delete observation.memoryType; + const result = buildRecallResponse([{ observation, sessionId: "session", layer: "observation", score: 1 }], "compact"); + expect(result.results[0]).toHaveProperty("type", "file_read"); + expect(result.results[0]).not.toHaveProperty("memoryType"); + }); +}); From 0000efa375d0ecacdf893a1709716a3cccd51508 Mon Sep 17 00:00:00 2001 From: Rohit Ghumare Date: Wed, 4 Nov 2026 12:13:05 +0530 Subject: [PATCH 2/3] fix(search): keep compact search alive on a failed type read and align fallback type - A rejected read of the stored memory while building compact results rejected the whole smart-search call. The read now falls back to the memoryType already on the ranked observation. - Standalone fallback compact results now report type "decision", the same as daemon results, with the saved category in memoryType. --- src/functions/smart-search.ts | 3 +-- src/mcp/standalone.ts | 2 +- test/mcp-standalone.test.ts | 2 +- test/memory-type-metadata.test.ts | 13 +++++++++++-- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/functions/smart-search.ts b/src/functions/smart-search.ts index b0610a7d35..78caa6b3d2 100644 --- a/src/functions/smart-search.ts +++ b/src/functions/smart-search.ts @@ -229,9 +229,8 @@ export function registerSmartSearchFunction( const compact: CompactSearchResult[] = await Promise.all(filteredHybrid.map(async (r) => { const layer = r.layer ?? getSearchIndex().layerOf(r.observation.id) ?? getSearchResultLayer(r.observation.id, r.sessionId); - // Older persisted indexes lack memoryType; use the already-authorized source row. const memoryType = layer === "memory" - ? (await kv.get(KV.memories, r.observation.id))?.type ?? r.observation.memoryType + ? (await kv.get(KV.memories, r.observation.id).catch(() => null))?.type ?? r.observation.memoryType : undefined; return { obsId: r.observation.id, diff --git a/src/mcp/standalone.ts b/src/mcp/standalone.ts index b310c18bab..ac56053300 100644 --- a/src/mcp/standalone.ts +++ b/src/mcp/standalone.ts @@ -413,7 +413,7 @@ async function handleLocal( return textResponse(buildRecallResponse(matches, v.format ?? "full", v.tokenBudget), true); } return textResponse({ mode: "compact", results: results.map((memory) => ({ - ...memory, memoryType: memory.type, obsId: memory.id, sessionId: memory.sessionIds?.[0] ?? "memory", layer: "memory", + ...memory, type: "decision", memoryType: memory.type, obsId: memory.id, sessionId: memory.sessionIds?.[0] ?? "memory", layer: "memory", })) }, true); } diff --git a/test/mcp-standalone.test.ts b/test/mcp-standalone.test.ts index 0903574807..7b34e99f24 100644 --- a/test/mcp-standalone.test.ts +++ b/test/mcp-standalone.test.ts @@ -286,7 +286,7 @@ describe("handleToolCall", () => { const kv = new InMemoryKV(); await handleToolCall("memory_save", { content: "Synthetic type probe", type, project: "type-project" }, kv); const compact = JSON.parse((await handleToolCall("memory_smart_search", { query: "Synthetic", project: "type-project" }, kv)).content[0].text); - expect(compact.results[0]).toHaveProperty("memoryType", type); + expect(compact.results[0]).toMatchObject({ type: "decision", memoryType: type }); const id = compact.results[0].obsId; const expanded = JSON.parse((await handleToolCall("memory_smart_search", { expandIds: id, project: "type-project" }, kv)).content[0].text); expect(expanded.results[0].observation).toMatchObject({ id, type: "decision", memoryType: type }); diff --git a/test/memory-type-metadata.test.ts b/test/memory-type-metadata.test.ts index 1e7c6a5f29..f87348012a 100644 --- a/test/memory-type-metadata.test.ts +++ b/test/memory-type-metadata.test.ts @@ -19,10 +19,13 @@ function memory(type: Memory["type"]): Memory { }; } -function fixture(saved: Memory, legacy = false) { +function fixture(saved: Memory, legacy = false, failMemoryReads = false) { const store = new Map>([["mem:memories", new Map([[saved.id, saved]])]]); const kv = { - get: async (scope: string, id: string) => store.get(scope)?.get(id) ?? null, + get: async (scope: string, id: string) => { + if (failMemoryReads && scope === "mem:memories") throw new Error("state read failed"); + return store.get(scope)?.get(id) ?? null; + }, set: async (scope: string, id: string, value: unknown) => { if (!store.has(scope)) store.set(scope, new Map()); store.get(scope)!.set(id, value); @@ -48,6 +51,12 @@ function fixture(saved: Memory, legacy = false) { } describe("original memory type metadata", () => { + it("keeps compact search working when the stored memory read fails", async () => { + const f = fixture(memory("bug"), false, true); + const compact = await f.call({ query: "Synthetic", agentId: "*", targetLayer: "memory", includeLessons: false }); + expect(compact.results[0]).toMatchObject({ obsId: f.saved.id, type: "decision", memoryType: "bug" }); + }); + it.each(types)("preserves %s without changing the observation type or input", (type) => { const saved = memory(type); const before = structuredClone(saved); From 00a76a1f7350a0025b39a8bfe415f085f56c8d5c Mon Sep 17 00:00:00 2001 From: Rohit Ghumare Date: Wed, 4 Nov 2026 13:30:29 +0530 Subject: [PATCH 3/3] chore: remove code comments and issue references --- src/state/memory-utils.ts | 2 -- src/types.ts | 2 -- test/memory-type-metadata.test.ts | 1 - 3 files changed, 5 deletions(-) diff --git a/src/state/memory-utils.ts b/src/state/memory-utils.ts index a7d1bbc41e..dd6ceaacfd 100644 --- a/src/state/memory-utils.ts +++ b/src/state/memory-utils.ts @@ -3,8 +3,6 @@ import type { CompressedObservation, Lesson, Memory } from "../types.js"; // Wraps a Memory record in the CompressedObservation shape that // SearchIndex / VectorIndex / enrichment paths consume. Memories share // the same searchable fields as observations (title + content + -// concepts + files). Keep the observation enum compatible and preserve the -// original durable-memory type separately in memoryType. The synthetic sessionId // ("memory" or memory.sessionIds[0]) is what enrich-side fallbacks key // off of when looking up the source record in KV.memories. export function memoryToObservation(memory: Memory): CompressedObservation { diff --git a/src/types.ts b/src/types.ts index 6b71f61234..eff9b8ca86 100644 --- a/src/types.ts +++ b/src/types.ts @@ -96,7 +96,6 @@ export interface CompressedObservation { sessionId: string; timestamp: string; type: ObservationType; - /** Original durable-memory type; observation type remains schema-compatible. */ memoryType?: Memory["type"]; title: string; subtitle?: string; @@ -348,7 +347,6 @@ export interface CompactSearchResult { sessionId: string; title: string; type: ObservationType; - /** Original durable-memory type; observation type remains schema-compatible. */ memoryType?: Memory["type"]; score: number; timestamp: string; diff --git a/test/memory-type-metadata.test.ts b/test/memory-type-metadata.test.ts index f87348012a..da93b3646a 100644 --- a/test/memory-type-metadata.test.ts +++ b/test/memory-type-metadata.test.ts @@ -45,7 +45,6 @@ function fixture(saved: Memory, legacy = false, failMemoryReads = false) { observation, sessionId: "memory", layer: "memory", combinedScore: 1, bm25Score: 1, vectorScore: 0, graphScore: 0, }]); - // The in-memory doubles implement only the SDK/KV methods this function exercises. registerSmartSearchFunction(sdk as unknown as IIIClient, kv as unknown as StateKV, search); return { call: (args: object) => handler(args), saved }; }