diff --git a/AGENTS.md b/AGENTS.md index 3897c7910e..81b4eed6fa 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,700+ 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,800+ 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,700+ tests +- 4,800+ tests diff --git a/README.md b/README.md index cd40701a05..7590f939b8 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ 54 MCP tools 12 auto hooks 0 external DBs - 4,700+ tests passing + 4,800+ tests passing

@@ -1313,7 +1313,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,700+ tests +npm test # 4,800+ 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 19dfdad2f8..40b6c0699d 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,700+ tests passing + 4,800+ tests passing

@@ -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,700+ tests +npm test # 4,800+ 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 a0881d0c27..b16b1f7bd4 100644 --- a/READMEs/README.bn-BD.md +++ b/READMEs/README.bn-BD.md @@ -69,7 +69,7 @@ 54 MCP টুল 12 অটো হুক 0 এক্সটার্নাল ডিবি - 4,700+ টেস্ট পাস + 4,800+ টেস্ট পাস

@@ -1257,7 +1257,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,700+ tests +npm test # 4,800+ 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 3837c5eb6e..41c98ab4df 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,700+ testů úspěšně proběhlo + 4,800+ testů úspěšně proběhlo

@@ -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,700+ tests +npm test # 4,800+ 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 209257de1f..6e96f1ad65 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,700+ beståede tests + 4,800+ beståede tests

@@ -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,700+ tests +npm test # 4,800+ 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 a0b4b683b8..f09b2211b6 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,700+ bestandene Tests + 4,800+ bestandene 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,700+ tests +npm test # 4,800+ 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 49f0fb50b2..20190d727a 100644 --- a/READMEs/README.el-GR.md +++ b/READMEs/README.el-GR.md @@ -69,7 +69,7 @@ 54 εργαλεία MCP 12 αυτόματα hooks 0 εξωτερικές βάσεις δεδομένων - 4,700+ επιτυχημένες δοκιμές + 4,800+ επιτυχημένες δοκιμές

@@ -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,700+ tests +npm test # 4,800+ 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 0cf25dab97..6ca88703a2 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,700+ tests superados + 4,800+ tests superados

@@ -1245,7 +1245,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,700+ tests +npm test # 4,800+ 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 c580718e9f..c82e700071 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,700+ testiä läpäisty + 4,800+ testiä läpäisty

@@ -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,700+ tests +npm test # 4,800+ 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 3f508c8454..981e72e4f9 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,700+ tests passing + 4,800+ tests passing

@@ -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,700+ tests +npm test # 4,800+ 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 73f6e4a233..313f456302 100644 --- a/READMEs/README.he-IL.md +++ b/READMEs/README.he-IL.md @@ -71,7 +71,7 @@ 54 כלי MCP 12 hooks אוטומטיים 0 מסדי נתונים חיצוניים - 4,700+ בדיקות עוברות + 4,800+ בדיקות עוברות

@@ -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,700+ tests +npm test # 4,800+ 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 4c3a8d31e2..9bed3ca5eb 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,700+ tests passing + 4,800+ tests passing

@@ -1258,7 +1258,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,700+ tests +npm test # 4,800+ 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 20d0e86604..819b196d68 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,700+ sikeres teszt + 4,800+ sikeres teszt

@@ -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,700+ tests +npm test # 4,800+ 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 855cd4dd52..a5813dcfc8 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,700+ pengujian lolos + 4,800+ pengujian lolos

@@ -1258,7 +1258,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,700+ tests +npm test # 4,800+ 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 cd396e06e9..a2e6f3aa8e 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,700+ tests passing + 4,800+ 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,700+ tests +npm test # 4,800+ 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 9dfe1e726c..412d9f4224 100644 --- a/READMEs/README.ja-JP.md +++ b/READMEs/README.ja-JP.md @@ -69,7 +69,7 @@ 54 MCP ツール 12 自動 hooks 外部 DB 0 個 - 4,700+ 件のテストが成功 + 4,800+ 件のテストが成功

@@ -1257,7 +1257,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,700+ tests +npm test # 4,800+ 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 4c77e312b0..db1bee6bd2 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,700+ tests passing + 4,800+ 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,700+ tests +npm test # 4,800+ 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 e617bec5e1..def9fa24d0 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,700+ tests passing + 4,800+ 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,700+ tests +npm test # 4,800+ 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 ab0aa4972b..a41ab0bf2e 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,700+ tests passing + 4,800+ tests passing

@@ -1245,7 +1245,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,700+ tests +npm test # 4,800+ 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 c24834e624..be1064ea75 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,700+ zaliczonych testów + 4,800+ zaliczonych testów

@@ -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,700+ tests +npm test # 4,800+ 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 8cba9a4b83..14023e43ce 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,700+ tests passing + 4,800+ 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,700+ tests +npm test # 4,800+ 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 c237b780d8..3f2e79bb91 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,700+ testes aprovados + 4,800+ testes aprovados

@@ -1245,7 +1245,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,700+ tests +npm test # 4,800+ 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 620d55913d..91d70e2ffe 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,700+ teste trecute + 4,800+ teste trecute

@@ -1237,7 +1237,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,700+ tests +npm test # 4,800+ 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 3086998cdd..aed56590dc 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,700+ tests passing + 4,800+ 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,700+ tests +npm test # 4,800+ 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 c29d00dbee..fc2f4d5b80 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,700+ godkända tester + 4,800+ godkända tester

@@ -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,700+ tests +npm test # 4,800+ 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 49a0e9ce46..fa1bd6d710 100644 --- a/READMEs/README.th-TH.md +++ b/READMEs/README.th-TH.md @@ -69,7 +69,7 @@ 54 เครื่องมือ MCP 12 hook อัตโนมัติ ไม่ต้องพึ่ง external DB เลย - ผ่านการทดสอบ 4,700+ รายการ + ผ่านการทดสอบ 4,800+ รายการ

@@ -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,700+ tests +npm test # 4,800+ 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 9eacba7baf..27cec827c0 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,700+ pumapasang test + 4,800+ pumapasang test

@@ -1253,7 +1253,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,700+ tests +npm test # 4,800+ 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 f1aa62a40a..d26df964c2 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,700+ tests passing + 4,800+ 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,700+ tests +npm test # 4,800+ 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 11019c61fe..08832163f6 100644 --- a/READMEs/README.uk-UA.md +++ b/READMEs/README.uk-UA.md @@ -69,7 +69,7 @@ 54 інструменти MCP 12 автоматичних хуків 0 зовнішніх БД - 4,700+ тестів пройдено + 4,800+ тестів пройдено

@@ -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,700+ tests +npm test # 4,800+ 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 a4a9b37b3c..c61fdbc3ef 100644 --- a/READMEs/README.ur-PK.md +++ b/READMEs/README.ur-PK.md @@ -71,7 +71,7 @@ 54 MCP ٹولز 12 خودکار ہکس 0 خارجی ڈیٹابیسز - 4,700+ ٹیسٹس پاس ہو رہے ہیں + 4,800+ ٹیسٹس پاس ہو رہے ہیں

@@ -1248,7 +1248,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,700+ tests +npm test # 4,800+ 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 47177b4c47..6b3d54b63f 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,700+ tests passing + 4,800+ tests passing

@@ -1253,7 +1253,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,700+ tests +npm test # 4,800+ 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 0a5f9c2d05..e7a3f90896 100644 --- a/READMEs/README.zh-CN.md +++ b/READMEs/README.zh-CN.md @@ -69,7 +69,7 @@ 54 个 MCP 工具 12 个自动 hooks 0 个外部数据库 - 4,700+ 项测试通过 + 4,800+ 项测试通过

@@ -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,700+ tests +npm test # 4,800+ 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 c2e315c886..74e1eca426 100644 --- a/READMEs/README.zh-TW.md +++ b/READMEs/README.zh-TW.md @@ -69,7 +69,7 @@ 54 個 MCP 工具 12 個自動 hooks 0 個外部資料庫 - 4,700+ 測試通過 + 4,800+ 測試通過

@@ -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,700+ tests +npm test # 4,800+ 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 1b4179cfc2..743b0d095d 100644 --- a/assets/tags/light/stat-tests.svg +++ b/assets/tags/light/stat-tests.svg @@ -1,5 +1,5 @@ - + - 4700+ + 4800+ TESTS PASSING diff --git a/assets/tags/stat-tests.svg b/assets/tags/stat-tests.svg index 2b679ac742..7b4a1c20eb 100644 --- a/assets/tags/stat-tests.svg +++ b/assets/tags/stat-tests.svg @@ -1,5 +1,5 @@ - + - 4700+ + 4800+ TESTS PASSING diff --git a/scripts/docs-sync.state.json b/scripts/docs-sync.state.json index ef3f2b4c6b..3829d237a6 100644 --- a/scripts/docs-sync.state.json +++ b/scripts/docs-sync.state.json @@ -20,13 +20,13 @@ "12" ], "tests": [ - "4700+" + "4800+" ], "functions": [ "323" ], "sourceFiles": [ - "259" + "260" ], "loc": [ "60000" diff --git a/src/capture/spool.ts b/src/capture/spool.ts index e1e0f6c26a..ab7e571421 100644 --- a/src/capture/spool.ts +++ b/src/capture/spool.ts @@ -85,6 +85,7 @@ export interface SpoolSummary { maxBytes: number; maxAgeHours: number; stats: SpoolStats; + unreadable?: boolean; } export type SendOutcome = "delivered" | "duplicate" | "rejected" | "retry"; @@ -648,12 +649,18 @@ export function spoolSummary(url: string, options: { policy?: SpoolPolicy; dir?: let bytes = 0; let oldestAt: string | null = null; const files: string[] = []; - if (existsSync(paths.file)) files.push(paths.file); + let unreadable = false; + const noteError = (err: unknown) => { + if ((err as NodeJS.ErrnoException)?.code !== "ENOENT") unreadable = true; + }; + files.push(paths.file); try { for (const entry of readdirSync(paths.dir)) { if (entry.startsWith(`${paths.name}.draining-`) && entry.endsWith(".jsonl")) files.push(join(paths.dir, entry)); } - } catch {} + } catch (err) { + noteError(err); + } for (const file of files) { try { const text = readFileSync(file, "utf-8"); @@ -662,7 +669,9 @@ export function spoolSummary(url: string, options: { policy?: SpoolPolicy; dir?: records++; if (!oldestAt || rec.spooledAt < oldestAt) oldestAt = rec.spooledAt; } - } catch {} + } catch (err) { + noteError(err); + } } let retained = 0; let retainedBytes = 0; @@ -684,5 +693,6 @@ export function spoolSummary(url: string, options: { policy?: SpoolPolicy; dir?: maxBytes: policy.maxBytes, maxAgeHours: Math.round(policy.maxAgeMs / 3600_000), stats: readSpoolStats(paths), + ...(unreadable ? { unreadable: true } : {}), }; } diff --git a/src/cli.ts b/src/cli.ts index b2b89ab08d..da9f14f0ed 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -104,6 +104,8 @@ import { bearerHeaders, resolveClientSecret } from "./secret-store.js"; import { assertComposePortsFree, composeCall, composeRegistryFailureMessage, composeStateRegistryFailure, composeWorkerFailureSummary, ownedComposeProject, readComposeLogFromOffset, startComposeDaemon, writeComposeState, type ComposeStatus } from "./cli/compose-control.js"; import { COMPOSE_WORKER_VERSIONS, composeDownTimeoutMs, composeNamespace } from "./cli/compose-project.js"; import { legacyDockerStateMessage, type LegacyDockerEngineState } from "./cli/legacy-docker-state.js"; +import { NO_HOOK_CAPTURE, hookCaptureMissing } from "./functions/status.js"; +import type { CaptureStatus } from "./functions/capture.js"; const __dirname = dirname(fileURLToPath(import.meta.url)); const args = process.argv.slice(2); @@ -1973,6 +1975,18 @@ async function runStatus() { } } p.note(lines.join("\n"), "agentmemory"); + if (Array.isArray(sessionsRes?.sessions) && sessions === 0) { + const [allSessions, captureRes] = await Promise.all([ + apiFetch<{ sessions?: unknown }>(base, "sessions?agentId=*&limit=1"), + apiFetch<{ capture?: CaptureStatus | null }>(base, "capture?limit=1"), + ]); + const noSessions = Array.isArray(allSessions?.sessions) && allSessions.sessions.length === 0; + const capture = captureRes?.capture; + const known = !!capture && typeof capture === "object" && !!capture.sinceStart && Array.isArray(capture.spool); + if (noSessions && known && hookCaptureMissing(0, capture)) { + p.log.warn(`${NO_HOOK_CAPTURE.message}\n${NO_HOOK_CAPTURE.fix}`); + } + } } catch (err) { p.log.error(err instanceof Error ? err.message : String(err)); process.exit(1); diff --git a/src/cli/connect/capture-notice.ts b/src/cli/connect/capture-notice.ts new file mode 100644 index 0000000000..1bab0af935 --- /dev/null +++ b/src/cli/connect/capture-notice.ts @@ -0,0 +1,32 @@ +import type { ConnectAdapter, ConnectOptions, ConnectResult, HookState } from "./types.js"; + +export function hookState(result: ConnectResult): HookState { + return result.kind === "installed" || result.kind === "already-wired" ? "installed" : "skipped"; +} + +export function mcpOnlyCaptureNotice( + adapter: Pick, + opts: Pick, + result: ConnectResult, +): string | null { + if (result.kind !== "installed" && result.kind !== "already-wired") return null; + const mode = adapter.autoCapture; + if (mode === "built-in" || result.hooks === "installed") return null; + const lead = `${adapter.displayName}: MCP only. Nothing is captured automatically`; + if (opts.withHooks && mode === "with-hooks") { + return `${lead} because the hooks were not installed. Fix the problem reported above, then rerun with --with-hooks.`; + } + if (opts.withHooks && mode === "plugin-or-with-hooks") { + return `${adapter.displayName}: MCP only. The hooks were not installed, so nothing is captured automatically unless the agentmemory plugin is installed. Fix the problem reported above and rerun with --with-hooks, or install the plugin.`; + } + switch (mode) { + case "with-hooks": + return `${lead}. Rerun with --with-hooks to capture sessions automatically.`; + case "plugin": + return `${lead} unless the agentmemory plugin for ${adapter.displayName} is installed. Without it, the agent must call memory_save to store anything.`; + case "plugin-or-with-hooks": + return `${lead} unless the agentmemory plugin is installed. Install the plugin, or rerun with --with-hooks.`; + default: + return `${lead}. The agent must call memory_save to store anything.`; + } +} diff --git a/src/cli/connect/claude-code.ts b/src/cli/connect/claude-code.ts index 271468bf2e..66bab360cf 100644 --- a/src/cli/connect/claude-code.ts +++ b/src/cli/connect/claude-code.ts @@ -3,7 +3,8 @@ import { homedir } from "node:os"; import { isAbsolute, join, normalize, resolve } from "node:path"; import * as p from "@clack/prompts"; import { isEnvFileValue } from "../../config.js"; -import type { ConnectAdapter, ConnectOptions, ConnectResult } from "./types.js"; +import type { ConnectAdapter, ConnectOptions, ConnectResult, HookState } from "./types.js"; +import { hookState } from "./capture-notice.js"; import { AGENTMEMORY_MCP_BLOCK, backupFile, @@ -50,6 +51,7 @@ export const adapter: ConnectAdapter = { name: "claude-code", displayName: "Claude Code", category: "native", + autoCapture: "plugin-or-with-hooks", docs: "https://github.com/rohitg00/agentmemory#claude-code-one-block-paste-it", protocolNote: "→ Using MCP. Hooks are also available — see https://github.com/rohitg00/agentmemory#claude-code-one-block-paste-it.", @@ -106,22 +108,16 @@ export const adapter: ConnectAdapter = { const alreadyHas = entryMatches(servers["agentmemory"]); if (alreadyHas && !opts.force) { logAlreadyWired("Claude Code", CLAUDE_JSON); - if (opts.withHooks) { - const hookResult = installClaudeHooks(opts); - if (hookResult.kind === "skipped") { - p.log.warn( - `Claude Code hooks fallback skipped: ${hookResult.reason}.`, - ); - } - } - return { kind: "already-wired", mutatedPath: CLAUDE_JSON }; + const hooks = runClaudeHooks(opts, ""); + return { kind: "already-wired", mutatedPath: CLAUDE_JSON, ...(hooks && { hooks }) }; } if (opts.dryRun) { p.log.info( `[dry-run] Would ${alreadyHas ? "overwrite" : "add"} mcpServers.agentmemory in ${CLAUDE_JSON}`, ); - return { kind: "installed", mutatedPath: CLAUDE_JSON }; + const hooks = runClaudeHooks(opts, ""); + return { kind: "installed", mutatedPath: CLAUDE_JSON, ...(hooks && { hooks }) }; } let backupPath: string | undefined; @@ -150,19 +146,21 @@ export const adapter: ConnectAdapter = { "Restart Claude Code (or run `/mcp` inside a session) to pick up the new server.", ); - if (opts.withHooks) { - const hookResult = installClaudeHooks(opts); - if (hookResult.kind === "skipped") { - p.log.warn( - `Claude Code hooks fallback skipped: ${hookResult.reason}. MCP wiring still applied.`, - ); - } - } + const hooks = runClaudeHooks(opts, " MCP wiring still applied."); - return { kind: "installed", mutatedPath: CLAUDE_JSON, backupPath }; + return { kind: "installed", mutatedPath: CLAUDE_JSON, backupPath, ...(hooks && { hooks }) }; }, }; +function runClaudeHooks(opts: ConnectOptions, suffix: string): HookState | undefined { + if (!opts.withHooks) return undefined; + const hookResult = installClaudeHooks(opts); + if (hookResult.kind === "skipped") { + p.log.warn(`Claude Code hooks fallback skipped: ${hookResult.reason}.${suffix}`); + } + return hookState(hookResult); +} + function installClaudeHooks(opts: ConnectOptions): ConnectResult { const { dir: CLAUDE_DIR, settings: CLAUDE_SETTINGS } = claudeConfigPaths(); let pluginRoot: string; diff --git a/src/cli/connect/codex.ts b/src/cli/connect/codex.ts index b31b35d119..0a247b8e08 100644 --- a/src/cli/connect/codex.ts +++ b/src/cli/connect/codex.ts @@ -2,7 +2,8 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs"; import { homedir } from "node:os"; import { join, dirname } from "node:path"; import * as p from "@clack/prompts"; -import type { ConnectAdapter, ConnectOptions, ConnectResult } from "./types.js"; +import type { ConnectAdapter, ConnectOptions, ConnectResult, HookState } from "./types.js"; +import { hookState } from "./capture-notice.js"; import { backupFile, logAlreadyWired, @@ -64,6 +65,7 @@ export const adapter: ConnectAdapter = { name: "codex", displayName: "Codex CLI", category: "native", + autoCapture: "plugin-or-with-hooks", docs: "https://github.com/rohitg00/agentmemory#codex-cli-codex-plugin-platform", protocolNote: "→ Using MCP. Hooks ship via the Codex plugin; on Codex Desktop, also pass --with-hooks to install the global hooks.json workaround.", @@ -79,15 +81,16 @@ export const adapter: ConnectAdapter = { if (wired && !opts.force) { logAlreadyWired("Codex CLI", CODEX_TOML); - return { kind: "already-wired", mutatedPath: CODEX_TOML }; + const hooks = runCodexHooks(opts, ""); + return { kind: "already-wired", mutatedPath: CODEX_TOML, ...(hooks && { hooks }) }; } if (opts.dryRun) { p.log.info( `[dry-run] Would ${wired ? "rewrite" : "append"} [mcp_servers.agentmemory] in ${CODEX_TOML}`, ); - if (opts.withHooks) installCodexHooks(opts); - return { kind: "installed", mutatedPath: CODEX_TOML }; + const hooks = runCodexHooks(opts, ""); + return { kind: "installed", mutatedPath: CODEX_TOML, ...(hooks && { hooks }) }; } let backupPath: string | undefined; @@ -116,23 +119,26 @@ export const adapter: ConnectAdapter = { "Codex picks up MCP servers on next launch. For the deeper plugin install, run: codex plugin marketplace add rohitg00/agentmemory && codex plugin add agentmemory@agentmemory", ); - if (opts.withHooks) { - const hookResult = installCodexHooks(opts); - if (hookResult.kind === "skipped") { - p.log.warn( - `Codex hooks fallback skipped: ${hookResult.reason}. MCP wiring still applied.`, - ); - } - } + const hooks = runCodexHooks(opts, " MCP wiring still applied."); return { kind: "installed", mutatedPath: CODEX_TOML, ...(backupPath !== undefined && { backupPath }), + ...(hooks && { hooks }), }; }, }; +function runCodexHooks(opts: ConnectOptions, suffix: string): HookState | undefined { + if (!opts.withHooks) return undefined; + const hookResult = installCodexHooks(opts); + if (hookResult.kind === "skipped") { + p.log.warn(`Codex hooks fallback skipped: ${hookResult.reason}.${suffix}`); + } + return hookState(hookResult); +} + function installCodexHooks(opts: ConnectOptions): ConnectResult { let pluginRoot: string; try { diff --git a/src/cli/connect/copilot-cli.ts b/src/cli/connect/copilot-cli.ts index 1f7b43dd87..7f50e37f5b 100644 --- a/src/cli/connect/copilot-cli.ts +++ b/src/cli/connect/copilot-cli.ts @@ -31,6 +31,7 @@ export const adapter: ConnectAdapter = { name: "copilot-cli", displayName: "GitHub Copilot CLI", category: "native", + autoCapture: "plugin", docs: "https://github.com/rohitg00/agentmemory#github-copilot-cli", protocolNote: "→ Using MCP. Install the plugin too for full hooks/skills coverage.", diff --git a/src/cli/connect/cursor.ts b/src/cli/connect/cursor.ts index 642add4efb..63d41a4025 100644 --- a/src/cli/connect/cursor.ts +++ b/src/cli/connect/cursor.ts @@ -8,6 +8,7 @@ export const adapter = createJsonMcpAdapter({ // Cursor speaks lifecycle hooks as well as MCP, so it groups with the // native hosts rather than the MCP-only ones. category: "native", + autoCapture: "plugin", detectDir: join(homedir(), ".cursor"), configPath: join(homedir(), ".cursor", "mcp.json"), docs: "https://github.com/rohitg00/agentmemory#cursor", diff --git a/src/cli/connect/dsh.ts b/src/cli/connect/dsh.ts index f18c93b7e9..91fcb02da4 100644 --- a/src/cli/connect/dsh.ts +++ b/src/cli/connect/dsh.ts @@ -100,6 +100,7 @@ export const adapter: ConnectAdapter = { protocolNote: "→ Using MCP via $DSH_HOME/cordis.patch.yml (the home-level patch layer every profile loads). Tools appear as mcp__agentmemory__*. Pass --with-hooks to also wire auto-capture with the bundled native DSH plugin.", category: "native", + autoCapture: "with-hooks", detect(): boolean { return existsSync(resolveDshHome()); }, @@ -115,6 +116,11 @@ export const adapter: ConnectAdapter = { const hooks = managedEntries(existing, HOOKS_MARKER); const pluginPath = wantHooks ? join(dirname(findPluginRoot()), "dist", "integrations", "dsh.mjs") : ""; const hooksReady = hooks.length === 1 && hooks[0].get("name") === pluginPath && existsSync(pluginPath); + const hooksUsable = hooks.some((entry) => { + const name = String(entry.get("name")); + return name !== "@deepseek-ai/dsh-hooks-claude-code" && existsSync(name); + }); + const hookState = wantHooks || hooksUsable ? { hooks: "installed" as const } : {}; if (wantHooks && !opts.force && hooks.some(entry => entry.get("name") === "@deepseek-ai/dsh-hooks-claude-code")) { throw new Error("Legacy DSH hooks bridge found. Run agentmemory connect dsh --with-hooks --force to replace it with the bundled native plugin. Existing manifest files will be preserved."); @@ -122,14 +128,14 @@ export const adapter: ConnectAdapter = { if (hasMcp && (!wantHooks || hooksReady) && !opts.force) { logAlreadyWired(this.displayName, configPath); - return { kind: "already-wired", mutatedPath: configPath }; + return { kind: "already-wired", mutatedPath: configPath, ...hookState }; } if (opts.dryRun) { p.log.info( `[dry-run] Would update the agentmemory mcp-client row${wantHooks ? " and the bundled capture plugin" : ""} in ${configPath}`, ); - return { kind: "installed", mutatedPath: configPath }; + return { kind: "installed", mutatedPath: configPath, ...hookState }; } if (wantHooks && !existsSync(pluginPath)) { @@ -161,6 +167,6 @@ export const adapter: ConnectAdapter = { } logInstalled(this.displayName, configPath); - return { kind: "installed", mutatedPath: configPath, backupPath }; + return { kind: "installed", mutatedPath: configPath, backupPath, ...hookState }; }, }; diff --git a/src/cli/connect/hermes.ts b/src/cli/connect/hermes.ts index d7bc5e6b6f..09a7f577b1 100644 --- a/src/cli/connect/hermes.ts +++ b/src/cli/connect/hermes.ts @@ -18,6 +18,7 @@ export const adapter: ConnectAdapter = { name: "hermes", displayName: "Hermes Agent", category: "native", + autoCapture: "built-in", docs: DOCS, protocolNote: "→ Installs the native memory provider and bundled skills into the active Hermes profile. Credentials stay managed by Hermes.", detect: () => existsSync(hermesHome()), diff --git a/src/cli/connect/index.ts b/src/cli/connect/index.ts index 055cb547d3..2de3da9551 100644 --- a/src/cli/connect/index.ts +++ b/src/cli/connect/index.ts @@ -3,6 +3,7 @@ import * as p from "@clack/prompts"; import pc from "picocolors"; import type { ConnectAdapter, ConnectOptions, ConnectResult } from "./types.js"; import { writeGuideline } from "./guidelines.js"; +import { mcpOnlyCaptureNotice } from "./capture-notice.js"; import { adapter as antigravity } from "./antigravity.js"; import { adapter as antigravityCli } from "./antigravity-cli.js"; import { adapter as claudeCode } from "./claude-code.js"; @@ -129,6 +130,8 @@ export async function runAdapter( ); } } + const captureNotice = mcpOnlyCaptureNotice(adapter, opts, result); + if (captureNotice) p.log.warn(captureNotice); return result; } catch (err) { p.log.error( diff --git a/src/cli/connect/json-mcp-adapter.ts b/src/cli/connect/json-mcp-adapter.ts index 0b76aa754f..5709fc0ac2 100644 --- a/src/cli/connect/json-mcp-adapter.ts +++ b/src/cli/connect/json-mcp-adapter.ts @@ -1,7 +1,8 @@ import { existsSync, mkdirSync } from "node:fs"; import { dirname } from "node:path"; import * as p from "@clack/prompts"; -import type { ConnectAdapter, ConnectOptions, ConnectResult } from "./types.js"; +import type { AutoCapture, ConnectAdapter, ConnectOptions, ConnectResult, HookState } from "./types.js"; +import { hookState } from "./capture-notice.js"; import { AGENTMEMORY_MCP_BLOCK, backupFile, @@ -23,6 +24,7 @@ export type JsonMcpAdapterConfig = { // JSON MCP config writer is MCP-only by construction; hosts that also // ship hooks (e.g. OpenClaw) pass "native". category?: "native" | "mcp"; + autoCapture?: AutoCapture; // Wrapper key under which servers live. Default "mcpServers". // Zed uses "context_servers"; otherwise same shape. wrapperKey?: string; @@ -47,10 +49,21 @@ export function createJsonMcpAdapter( config: JsonMcpAdapterConfig, ): ConnectAdapter { const wrapperKey = config.wrapperKey ?? "mcpServers"; + const runHooks = (opts: ConnectOptions, suffix: string): HookState | undefined => { + if (!opts.withHooks || !config.installHooks) return undefined; + const hookResult = config.installHooks(opts); + if (hookResult.kind === "skipped") { + p.log.warn(`${config.displayName} hooks skipped: ${hookResult.reason}.${suffix}`); + } + return hookState(hookResult); + }; + const autoCapture: AutoCapture | undefined = + config.autoCapture ?? (config.installHooks ? "with-hooks" : undefined); return { name: config.name, displayName: config.displayName, category: config.category ?? "mcp", + ...(autoCapture !== undefined && { autoCapture }), ...(config.docs !== undefined && { docs: config.docs }), ...(config.protocolNote !== undefined && { protocolNote: config.protocolNote, @@ -70,30 +83,16 @@ export function createJsonMcpAdapter( const alreadyHas = entryMatches(servers["agentmemory"]); if (alreadyHas && !opts.force) { logAlreadyWired(config.displayName, config.configPath); - if (opts.withHooks && config.installHooks) { - const hookResult = config.installHooks(opts); - if (hookResult.kind === "skipped") { - p.log.warn( - `${config.displayName} hooks skipped: ${hookResult.reason}.`, - ); - } - } - return { kind: "already-wired", mutatedPath: config.configPath }; + const hooks = runHooks(opts, ""); + return { kind: "already-wired", mutatedPath: config.configPath, ...(hooks && { hooks }) }; } if (opts.dryRun) { p.log.info( `[dry-run] Would ${alreadyHas ? "overwrite" : "add"} ${wrapperKey}.agentmemory in ${config.configPath}`, ); - if (opts.withHooks && config.installHooks) { - const hookResult = config.installHooks(opts); - if (hookResult.kind === "skipped") { - p.log.warn( - `${config.displayName} hooks skipped: ${hookResult.reason}.`, - ); - } - } - return { kind: "installed", mutatedPath: config.configPath }; + const hooks = runHooks(opts, ""); + return { kind: "installed", mutatedPath: config.configPath, ...(hooks && { hooks }) }; } let backupPath: string | undefined; @@ -124,19 +123,13 @@ export function createJsonMcpAdapter( logInstalled(config.displayName, config.configPath); - if (opts.withHooks && config.installHooks) { - const hookResult = config.installHooks(opts); - if (hookResult.kind === "skipped") { - p.log.warn( - `${config.displayName} hooks skipped: ${hookResult.reason}. MCP wiring still applied.`, - ); - } - } + const hooks = runHooks(opts, " MCP wiring still applied."); return { kind: "installed", mutatedPath: config.configPath, ...(backupPath !== undefined && { backupPath }), + ...(hooks && { hooks }), }; }, }; diff --git a/src/cli/connect/omp.ts b/src/cli/connect/omp.ts index 90a4d59000..d0de985939 100644 --- a/src/cli/connect/omp.ts +++ b/src/cli/connect/omp.ts @@ -22,6 +22,7 @@ export const adapter: ConnectAdapter = { name: "omp", displayName: "Oh My Pi", category: "native", + autoCapture: "built-in", docs: "https://github.com/rohitg00/agentmemory/tree/main/integrations/omp", protocolNote: "Installs native recall, capture and skills. Add --with-mcp for the full memory toolset.", detect: () => { try { const paths = ompPaths(); return existsSync(paths.agent) || existsSync(paths.root); } catch { return false; } }, diff --git a/src/cli/connect/openclaw.ts b/src/cli/connect/openclaw.ts index 6b992a61d7..60ef6b6382 100644 --- a/src/cli/connect/openclaw.ts +++ b/src/cli/connect/openclaw.ts @@ -25,6 +25,7 @@ export const adapter: ConnectAdapter = { name: "openclaw", displayName: "OpenClaw", category: "native", + autoCapture: "built-in", docs: "https://github.com/rohitg00/agentmemory/tree/main/integrations/openclaw", protocolNote: "→ Installs native recall/capture and bundled skills into the active OpenClaw state directory. MCP tools are opt-in with --with-mcp.", detect: () => existsSync(paths().config) || existsSync(paths().state), diff --git a/src/cli/connect/opencode.ts b/src/cli/connect/opencode.ts index 76ddbf63d1..9016ecc1c4 100644 --- a/src/cli/connect/opencode.ts +++ b/src/cli/connect/opencode.ts @@ -45,6 +45,7 @@ export const adapter: ConnectAdapter = { name: "opencode", displayName: "OpenCode", category: "mcp", + autoCapture: "plugin", docs: "https://github.com/rohitg00/agentmemory#other-agents", protocolNote: "Using MCP via ~/.config/opencode/opencode.json (top-level `mcp` key). For full auto-capture, also install the bundled plugin in plugin/opencode/.", diff --git a/src/cli/connect/pi.ts b/src/cli/connect/pi.ts index 8d954fa21d..8489cc9e44 100644 --- a/src/cli/connect/pi.ts +++ b/src/cli/connect/pi.ts @@ -34,7 +34,7 @@ function hasPackage(config: Record, configDir: string, target: } export const adapter: ConnectAdapter = { - name: "pi", displayName: "Pi", category: "native", + name: "pi", displayName: "Pi", category: "native", autoCapture: "built-in", docs: "https://github.com/rohitg00/agentmemory/tree/main/integrations/pi", protocolNote: "Installs native recall, capture and skills. Add --with-mcp for the full memory toolset.", detect: () => existsSync(agentDir()) || existsSync(join(homedir(), ".pi")), diff --git a/src/cli/connect/types.ts b/src/cli/connect/types.ts index 4d71df33cc..6862367a66 100644 --- a/src/cli/connect/types.ts +++ b/src/cli/connect/types.ts @@ -12,6 +12,12 @@ export type ConnectOptions = { guidelines?: boolean; }; +export type AutoCapture = + | "built-in" + | "with-hooks" + | "plugin" + | "plugin-or-with-hooks"; + export type ConnectAdapter = { name: string; displayName: string; @@ -24,12 +30,15 @@ export type ConnectAdapter = { */ protocolNote?: string; category?: "native" | "mcp"; + autoCapture?: AutoCapture; detect(): boolean; install(opts: ConnectOptions): Promise; }; +export type HookState = "installed" | "skipped"; + export type ConnectResult = - | { kind: "installed"; mutatedPath?: string; backupPath?: string } - | { kind: "already-wired"; mutatedPath?: string } + | { kind: "installed"; mutatedPath?: string; backupPath?: string; hooks?: HookState } + | { kind: "already-wired"; mutatedPath?: string; hooks?: HookState } | { kind: "stub"; reason: string } | { kind: "skipped"; reason: string }; diff --git a/src/functions/status.ts b/src/functions/status.ts index 6967f7249b..09b15bdfa1 100644 --- a/src/functions/status.ts +++ b/src/functions/status.ts @@ -478,15 +478,22 @@ export function evaluateStatus(input: StatusInputs): StatusReport { }); } - if (input.capture === null) { + const unreadableSpools = (input.capture?.spool ?? []).filter((s) => s.unreadable).map((s) => s.path); + if (input.capture === null || input.capture?.inbox === null || unreadableSpools.length > 0) { + const spoolFix = unreadableSpools.length > 0 + ? ` Check that the agentmemory process can read ${unreadableSpools.join(", ")} and its folder.` + : ""; problems.push({ level: "info", code: "capture-check-unavailable", - message: "The capture inbox did not answer in time, so capture was not checked.", - fix: "The check runs again on the next status request. If it keeps timing out, the state store is overloaded: check the server log.", + message: "The capture inbox or spool could not be read, so capture was not checked.", + fix: `The check runs again on the next status request. If it keeps timing out, the state store is overloaded: check the server log.${spoolFix}`, }); } problems.push(...captureProblems(input.capture ?? null, input.now, input.ports.rest)); + if (hookCaptureMissing(input.index.sessions, input.capture)) { + problems.push({ level: "warn", code: "no-hook-capture", ...NO_HOOK_CAPTURE }); + } if (input.stateStore && !input.stateStore.ok) { problems.push({ @@ -555,6 +562,23 @@ export function captureRestBase(restPort: number | null): string { return `http://localhost:${restPort ?? 3111}/agentmemory`; } +export const NO_HOOK_CAPTURE = { + message: + "No capture has been observed yet: there are no sessions and no hook events. An agent connected with MCP only records no session observations; it saves long-term memories only when it calls memory_save.", + fix: "Run one agent session, then check again. If there are still no sessions and the agent supports hooks or an agentmemory plugin, rerun npx @agentmemory/agentmemory connect --with-hooks or install the plugin. Agents without either stay MCP only and keep memories only through memory_save.", +}; + +export function hookCaptureMissing(sessions: number | null, capture: CaptureStatus | null | undefined): boolean { + return sessions === 0 && !!capture?.inbox && !capture.spool.some((s) => s.unreadable) && !captureActivity(capture); +} + +function captureActivity(capture: CaptureStatus): boolean { + const inbox = capture.inbox; + const queued = inbox ? inbox.pending + inbox.retrying + inbox.dead : 0; + const spooled = capture.spool.reduce((n, s) => n + s.records, 0); + return capture.sinceStart.accepted > 0 || queued > 0 || spooled > 0; +} + function captureProblems(capture: CaptureStatus | null, now: Date, restPort: number | null): StatusProblem[] { if (!capture) return []; const problems: StatusProblem[] = []; diff --git a/test/capture-spool.test.ts b/test/capture-spool.test.ts index 7deed3393a..238bdf8554 100644 --- a/test/capture-spool.test.ts +++ b/test/capture-spool.test.ts @@ -1,5 +1,5 @@ import { describe, it, expect, beforeEach } from "vitest"; -import { mkdtempSync, readFileSync, readdirSync, statSync, writeFileSync, existsSync } from "node:fs"; +import { mkdirSync, mkdtempSync, readFileSync, readdirSync, statSync, writeFileSync, existsSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; import { @@ -96,6 +96,14 @@ describe("capture spool", () => { expect(summary.stats.lastDropReason).toBe("full"); }); + it("flags a spool it cannot read instead of reporting it empty", () => { + expect(spoolSummary(URL, { dir: join(dir, "missing"), policy }).unreadable).toBeUndefined(); + mkdirSync(spoolPaths(URL, dir).file, { recursive: true }); + const summary = spoolSummary(URL, { dir, policy }); + expect(summary.records).toBe(0); + expect(summary.unreadable).toBe(true); + }); + it("does nothing when the spool is disabled", () => { const r = appendSpool(URL, "evc_eeeeeeeeeeee", body("off"), "unreachable", { dir, policy: { ...policy, enabled: false } }); expect(r).toEqual({ spooled: false, dropped: "disabled" }); diff --git a/test/codex-connect-hooks.test.ts b/test/codex-connect-hooks.test.ts index 6871ff5ed1..e3fc0c81df 100644 --- a/test/codex-connect-hooks.test.ts +++ b/test/codex-connect-hooks.test.ts @@ -1,4 +1,4 @@ -import { describe, it, expect } from "vitest"; +import { afterEach, beforeEach, describe, it, expect, vi } from "vitest"; import { copyFileSync, writeFileSync, @@ -6,6 +6,7 @@ import { mkdirSync, mkdtempSync, rmSync, + existsSync, } from "node:fs"; import { join, resolve } from "node:path"; import { tmpdir } from "node:os"; @@ -165,3 +166,32 @@ describe("buildMergedHooks file round-trip", () => { } }); }); + +describe("connect codex --with-hooks on an already-wired config", () => { + let home: string; + + beforeEach(() => { + home = mkdtempSync(join(tmpdir(), "am-codex-wired-")); + vi.stubEnv("HOME", home); + vi.stubEnv("USERPROFILE", home); + vi.resetModules(); + }); + + afterEach(() => { + vi.unstubAllEnvs(); + vi.resetModules(); + rmSync(home, { recursive: true, force: true }); + }); + + it("installs the requested hooks and reports them before returning already-wired", async () => { + const { adapter } = await import("../src/cli/connect/codex.js"); + expect(await adapter.install({ dryRun: false, force: false })).toMatchObject({ kind: "installed" }); + const hooksPath = join(home, ".codex", "hooks.json"); + expect(existsSync(hooksPath)).toBe(false); + + const result = await adapter.install({ dryRun: false, force: false, withHooks: true }); + expect(result).toMatchObject({ kind: "already-wired", hooks: "installed" }); + const hooks = JSON.parse(readFileSync(hooksPath, "utf-8")) as HookManifest; + expect(Object.keys(hooks.hooks)).toContain("SessionStart"); + }); +}); diff --git a/test/connect-capture-notice.test.ts b/test/connect-capture-notice.test.ts new file mode 100644 index 0000000000..a2da9c6d58 --- /dev/null +++ b/test/connect-capture-notice.test.ts @@ -0,0 +1,127 @@ +import { beforeEach, describe, expect, it, vi } from "vitest"; +import type { ConnectAdapter } from "../src/cli/connect/types.js"; + +const log = vi.hoisted(() => ({ + info: vi.fn(), + warn: vi.fn(), + step: vi.fn(), + message: vi.fn(), + error: vi.fn(), + success: vi.fn(), +})); +vi.mock("@clack/prompts", () => ({ log })); + +import { mcpOnlyCaptureNotice } from "../src/cli/connect/capture-notice.js"; +import { ADAPTERS, runAdapter } from "../src/cli/connect/index.js"; + +const installed = { kind: "installed" } as const; + +describe("mcpOnlyCaptureNotice", () => { + it("tells MCP-only agents without hook support that the agent must call memory_save", () => { + const notice = mcpOnlyCaptureNotice({ displayName: "Gemini CLI" }, { withHooks: false }, installed); + expect(notice).toBe("Gemini CLI: MCP only. Nothing is captured automatically. The agent must call memory_save to store anything."); + expect(notice).not.toContain("--with-hooks"); + }); + + it("does not suggest --with-hooks when the adapter cannot install hooks, even if the flag was passed", () => { + const notice = mcpOnlyCaptureNotice({ displayName: "Kiro" }, { withHooks: true }, installed); + expect(notice).toContain("memory_save"); + expect(notice).not.toContain("--with-hooks"); + }); + + it("suggests --with-hooks only for adapters that support it", () => { + const notice = mcpOnlyCaptureNotice({ displayName: "Antigravity", autoCapture: "with-hooks" }, { withHooks: false }, installed); + expect(notice).toBe("Antigravity: MCP only. Nothing is captured automatically. Rerun with --with-hooks to capture sessions automatically."); + }); + + it("stays quiet once the adapter reports its hooks as installed", () => { + const withHooks = { kind: "installed", hooks: "installed" } as const; + expect(mcpOnlyCaptureNotice({ displayName: "Droid", autoCapture: "with-hooks" }, { withHooks: true }, withHooks)).toBeNull(); + expect(mcpOnlyCaptureNotice({ displayName: "Codex CLI", autoCapture: "plugin-or-with-hooks" }, { withHooks: true }, { kind: "already-wired", hooks: "installed" })).toBeNull(); + expect(mcpOnlyCaptureNotice({ displayName: "DSH", autoCapture: "with-hooks" }, { withHooks: false }, withHooks)).toBeNull(); + }); + + it("still warns when --with-hooks was passed but the hooks were not installed", () => { + for (const result of [installed, { kind: "installed", hooks: "skipped" } as const, { kind: "already-wired", hooks: "skipped" } as const]) { + expect(mcpOnlyCaptureNotice({ displayName: "Droid", autoCapture: "with-hooks" }, { withHooks: true }, result)).toBe( + "Droid: MCP only. Nothing is captured automatically because the hooks were not installed. Fix the problem reported above, then rerun with --with-hooks.", + ); + expect(mcpOnlyCaptureNotice({ displayName: "Codex CLI", autoCapture: "plugin-or-with-hooks" }, { withHooks: true }, result)).toBe( + "Codex CLI: MCP only. The hooks were not installed, so nothing is captured automatically unless the agentmemory plugin is installed. Fix the problem reported above and rerun with --with-hooks, or install the plugin.", + ); + } + }); + + it("points plugin-based agents at their plugin", () => { + const plugin = mcpOnlyCaptureNotice({ displayName: "Cursor", autoCapture: "plugin" }, { withHooks: false }, installed); + expect(plugin).toContain("unless the agentmemory plugin for Cursor is installed"); + expect(plugin).toContain("memory_save"); + expect(plugin).not.toContain("--with-hooks"); + const both = mcpOnlyCaptureNotice({ displayName: "Claude Code", autoCapture: "plugin-or-with-hooks" }, { withHooks: false }, installed); + expect(both).toContain("Install the plugin, or rerun with --with-hooks."); + }); + + it("stays quiet for built-in capture and for results that did not wire anything", () => { + expect(mcpOnlyCaptureNotice({ displayName: "Hermes Agent", autoCapture: "built-in" }, { withHooks: false }, installed)).toBeNull(); + expect(mcpOnlyCaptureNotice({ displayName: "Gemini CLI" }, { withHooks: false }, { kind: "skipped", reason: "exception" })).toBeNull(); + expect(mcpOnlyCaptureNotice({ displayName: "OpenHuman" }, { withHooks: false }, { kind: "stub", reason: "manual" })).toBeNull(); + expect(mcpOnlyCaptureNotice({ displayName: "Gemini CLI" }, { withHooks: false }, { kind: "already-wired" })).not.toBeNull(); + }); +}); + +describe("adapter capture modes", () => { + it("declares how each adapter captures automatically", () => { + const modes = Object.fromEntries(ADAPTERS.map((a) => [a.name, a.autoCapture ?? "none"])); + expect(modes).toMatchObject({ + "claude-code": "plugin-or-with-hooks", + codex: "plugin-or-with-hooks", + cursor: "plugin", + "copilot-cli": "plugin", + opencode: "plugin", + antigravity: "with-hooks", + "antigravity-cli": "with-hooks", + droid: "with-hooks", + devin: "with-hooks", + dsh: "with-hooks", + hermes: "built-in", + openclaw: "built-in", + pi: "built-in", + omp: "built-in", + "gemini-cli": "none", + kiro: "none", + qwen: "none", + zed: "none", + }); + }); +}); + +describe("runAdapter capture notice", () => { + beforeEach(() => { + vi.clearAllMocks(); + }); + + const fake = (overrides: Partial = {}): ConnectAdapter => ({ + name: "fake", + displayName: "Fake Agent", + detect: () => true, + install: async () => ({ kind: "installed" }), + ...overrides, + }); + + it("prints the MCP-only line after a hook-less install", async () => { + await runAdapter(fake(), { dryRun: true, force: false, guidelines: false }); + expect(log.warn).toHaveBeenCalledWith( + "Fake Agent: MCP only. Nothing is captured automatically. The agent must call memory_save to store anything.", + ); + }); + + it("does not print it when --with-hooks installed the hooks", async () => { + await runAdapter(fake({ autoCapture: "with-hooks", install: async () => ({ kind: "installed", hooks: "installed" }) }), { dryRun: true, force: false, withHooks: true, guidelines: false }); + expect(log.warn).not.toHaveBeenCalled(); + }); + + it("prints it when --with-hooks was passed but the adapter skipped the hooks", async () => { + await runAdapter(fake({ autoCapture: "with-hooks", install: async () => ({ kind: "already-wired", hooks: "skipped" }) }), { dryRun: true, force: false, withHooks: true, guidelines: false }); + expect(log.warn).toHaveBeenCalledWith(expect.stringContaining("because the hooks were not installed")); + }); +}); diff --git a/test/connect-dsh.test.ts b/test/connect-dsh.test.ts index e222b64d6c..7d33e53f3d 100644 --- a/test/connect-dsh.test.ts +++ b/test/connect-dsh.test.ts @@ -354,12 +354,39 @@ describe("connect: DeepSeek Harness", () => { expect(readFileSync(configPath, "utf-8")).toBe(existing); }); + it("does not report a hooks row whose plugin file is gone as installed", async () => { + const hooks = await import("../src/cli/connect/codex-hooks.js"); + vi.spyOn(hooks, "findPluginRoot").mockReturnValue(join(home, "install", "plugin")); + const { adapter } = await import("../src/cli/connect/dsh.js"); + await adapter.install({ dryRun: false, force: false }); + const configPath = join(home, ".dsh", "cordis.patch.yml"); + const rows = parseDocument(readFileSync(configPath, "utf-8")).toJS(); + rows.push({ insert: [{ id: "agentmemory-hooks", name: join(home, "install", "dist", "integrations", "dsh.mjs") }] }); + writeFileSync(configPath, JSON.stringify(rows)); + const result = await adapter.install({ dryRun: false, force: false }); + expect(result.kind).toBe("already-wired"); + expect(result.hooks).toBeUndefined(); + }); + + it("does not count a legacy bridge row as installed hooks", async () => { + const { adapter } = await import("../src/cli/connect/dsh.js"); + await adapter.install({ dryRun: false, force: false }); + const dir = join(home, ".dsh"); + const configPath = join(dir, "cordis.patch.yml"); + const rows = parseDocument(readFileSync(configPath, "utf-8")).toJS(); + rows.push({ insert: [{ id: "agentmemory-hooks", name: "@deepseek-ai/dsh-hooks-claude-code", config: { configPath: "agentmemory.hooks.json" } }] }); + writeFileSync(configPath, JSON.stringify(rows)); + writeFileSync(join(dir, "agentmemory.hooks.json"), "{}"); + expect((await adapter.install({ dryRun: false, force: false })).hooks).toBeUndefined(); + }); + it("MCP-only install after --with-hooks keeps the hooks row intact", async () => { mkdirSync(join(home, ".dsh"), { recursive: true }); const { adapter } = await import("../src/cli/connect/dsh.js"); await adapter.install({ dryRun: false, force: false, withHooks: true }); const result = await adapter.install({ dryRun: false, force: false }); expect(result.kind).toBe("already-wired"); + expect(result.hooks).toBe("installed"); const patch = readFileSync(join(home, ".dsh", "cordis.patch.yml"), "utf-8"); expect(patch).toContain("id: agentmemory-hooks"); expect(patch).toContain("serverName: agentmemory"); diff --git a/test/status.test.ts b/test/status.test.ts index 375f846cc6..6f815b3eec 100644 --- a/test/status.test.ts +++ b/test/status.test.ts @@ -117,6 +117,62 @@ describe("evaluateStatus", () => { expect(problem?.fix).toMatch(/Restart agentmemory/); }); + const idleCapture = { + policy: { maxAttempts: 5, retryIntervalMs: 10_000, dedupRetentionHours: 168, inboxMax: 10_000, deadMax: 1000, eventsMax: 100_000 }, + inbox: { pending: 0, retrying: 0, dead: 0, oldestAcceptedAt: null, nextAttemptAt: null, lastError: null }, + sinceStart: { accepted: 0, completed: 0, duplicates: 0, retried: 0, recovered: 0, deadLettered: 0, rejected: 0, pruned: 0 }, + lastSweepAt: null, + lastPruneAt: null, + lastBootDrain: null, + spool: [], + } as unknown as NonNullable; + + it("warns when no hook has ever reached the server", () => { + const report = evaluateStatus(inputs({ index: { ...inputs().index, sessions: 0 }, capture: idleCapture })); + expect(codes(report)).toEqual(["no-hook-capture"]); + expect(report.status).toBe("warn"); + const problem = report.problems[0]; + expect(problem.message).toMatch(/No capture has been observed yet/); + expect(problem.fix).toMatch(/^Run one agent session/); + expect(problem.message).toMatch(/long-term memories only when it calls memory_save/); + expect(problem.fix).toMatch(/supports hooks or an agentmemory plugin/); + expect(problem.fix).toMatch(/--with-hooks/); + }); + + it("skips the no-hook warning while hook captures are in flight or the session count is unknown", () => { + const capture = idleCapture; + const empty = { ...inputs().index, sessions: 0 }; + expect(codes(evaluateStatus(inputs({ index: empty, capture })))).toContain("no-hook-capture"); + const accepted = { ...capture, sinceStart: { ...capture.sinceStart, accepted: 2 } }; + expect(codes(evaluateStatus(inputs({ index: empty, capture: accepted })))).not.toContain("no-hook-capture"); + const pending = { ...capture, inbox: { ...capture.inbox!, pending: 1 } }; + expect(codes(evaluateStatus(inputs({ index: empty, capture: pending })))).not.toContain("no-hook-capture"); + expect(codes(evaluateStatus(inputs({ index: { ...empty, sessions: null }, capture })))).not.toContain("no-hook-capture"); + }); + + it("does not diagnose missing hooks when the capture check is unavailable", () => { + const report = evaluateStatus(inputs({ index: { ...inputs().index, sessions: 0 }, capture: null })); + expect(codes(report)).toContain("capture-check-unavailable"); + expect(codes(report)).not.toContain("no-hook-capture"); + }); + + it("does not diagnose missing hooks when the capture inbox could not be read", () => { + const capture = { ...idleCapture, inbox: null }; + const report = evaluateStatus(inputs({ index: { ...inputs().index, sessions: 0 }, capture })); + expect(codes(report)).toContain("capture-check-unavailable"); + expect(codes(report)).not.toContain("no-hook-capture"); + expect(report.status).not.toBe("ok"); + }); + + it("does not diagnose missing hooks when the capture spool could not be read", () => { + const spool = [{ path: "/tmp/spool/x.jsonl", records: 0, unreadable: true, stats: { dropped: 0, lastDropAt: null } }] as unknown as NonNullable["spool"]; + const report = evaluateStatus(inputs({ index: { ...inputs().index, sessions: 0 }, capture: { ...idleCapture, spool } })); + expect(codes(report)).toContain("capture-check-unavailable"); + expect(codes(report)).not.toContain("no-hook-capture"); + expect(report.status).not.toBe("ok"); + expect(report.problems.find((p) => p.code === "capture-check-unavailable")?.fix).toContain("can read /tmp/spool/x.jsonl"); + }); + it("notes when the index check timed out instead of claiming the index is fine", () => { const report = evaluateStatus(inputs({ index: { ...inputs().index, missingObservations: null, sessions: null } })); expect(codes(report)).toEqual(["index-check-unavailable"]);