From bdd3d91ff7c1e421c7828b96fe8f77ef1e625d0d Mon Sep 17 00:00:00 2001 From: JJ Date: Fri, 9 Oct 2026 13:41:45 -0500 Subject: [PATCH 1/2] refactor: use public Pi SDK text helpers (0.2.2) Record the source that was published to npm as 0.2.2 but never committed: read message text with contentText from @earendil-works/pi-ai, resolve the agent directory with getAgentDir, require pi-ai >=1.0.4 and pi-secrets ^0.2.6. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 2 + package-lock.json | 130 +++++++++++++++++++++++++++++++++---- package.json | 6 +- src/curation/analyzer.ts | 7 +- src/curation/curator.ts | 7 +- src/curation/translator.ts | 7 +- src/eval/answer.ts | 7 +- src/extension/hooks.ts | 3 +- src/sources/discovery.ts | 4 +- 9 files changed, 136 insertions(+), 37 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a1a806..4e29638 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +## 0.2.2 (2026-10-07) + ## 0.2.0 (2026-10-06) - Remove semantic reranking, classifier curation, turn judging and credential setup. diff --git a/package-lock.json b/package-lock.json index 27002af..f629c6e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,16 +1,16 @@ { "name": "@prjct.app/pi-memory", - "version": "0.2.1", + "version": "0.2.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@prjct.app/pi-memory", - "version": "0.2.1", + "version": "0.2.2", "license": "MIT", "dependencies": { "@huggingface/transformers": "4.3.0", - "@prjct.app/pi-secrets": "^0.2.1", + "@prjct.app/pi-secrets": "^0.2.6", "@prjct.app/pi-tui-kit": "^0.3.4", "sqlite-vec": "0.1.9", "tsx": "^4.20.0" @@ -28,7 +28,7 @@ "node": ">=22.19.0" }, "peerDependencies": { - "@earendil-works/pi-ai": "*", + "@earendil-works/pi-ai": ">=1.0.4", "@earendil-works/pi-coding-agent": "*", "@earendil-works/pi-tui": "*", "typebox": "*" @@ -38,6 +38,7 @@ "version": "0.129.0", "resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-0.129.0.tgz", "integrity": "sha512-MH7LB20kNpGLUpPTe2OG5XvL/KhX8HUO9XyBaFjgFk6TLS4Xjt0VPIuMKywe7POKKPslX+QxSlVok9e+8kG5Nw==", + "dev": true, "license": "MIT", "dependencies": { "json-schema-to-ts": "^3.1.1", @@ -59,6 +60,7 @@ "version": "3.1127.0", "resolved": "https://registry.npmjs.org/@aws-sdk/client-bedrock-runtime/-/client-bedrock-runtime-3.1127.0.tgz", "integrity": "sha512-IDl/lrPb90aH+pZFHGNDmgH9nAUQj5PlZH1sJ3w7RikctyjHSnY3oNjZhrLoaBoQn/rNK0zsP6OHEqEhj2tdLA==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@aws-sdk/core": "^3.977.9", @@ -82,6 +84,7 @@ "version": "3.978.1", "resolved": "https://registry.npmjs.org/@aws-sdk/core/-/core-3.978.1.tgz", "integrity": "sha512-LbY9aGsEiznDWmUc30Nwv3aIX/+dbwTx8KfS0yOC3NPYMO+O91e6jkT1azf34FwjOndq8/Q+RcVVZz5xnerwdg==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@aws-sdk/types": "^3.974.6", @@ -101,6 +104,7 @@ "version": "3.972.72", "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-env/-/credential-provider-env-3.972.72.tgz", "integrity": "sha512-xTKO/FWJPozTIXbozVnVGoNBhaGba8TBcx+KyUjRVeOlXE+dUc7GTR1cLvu0uTdIdmemzaFbqqCshXeZA1fZew==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@aws-sdk/core": "^3.978.1", @@ -117,6 +121,7 @@ "version": "3.972.74", "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-http/-/credential-provider-http-3.972.74.tgz", "integrity": "sha512-u91E/hT8f4d1xy0Jl7VG4nVKJ3lxbrZkoBTeSVoJdWBiSEUMwMS/9+e0H/aJVQV//Lt5wuzP+E69v4aRSsNTmw==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@aws-sdk/core": "^3.978.1", @@ -135,6 +140,7 @@ "version": "3.973.17", "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-ini/-/credential-provider-ini-3.973.17.tgz", "integrity": "sha512-ged4KXdBkvIC81bLvNHHuQKdKak/VXhQTR1NWYTTqW0474nlmsxy9O/vlgTIohDDWH3xpBdtVMZRyjb+DnocDA==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@aws-sdk/core": "^3.978.1", @@ -159,6 +165,7 @@ "version": "3.972.79", "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-login/-/credential-provider-login-3.972.79.tgz", "integrity": "sha512-L+Z85anONJd8MaiuraO4wRxATCdEejBZ3K3eymzWI5JPXa9sOS9CkIm72PBKqXKX+Z9p9NGMX5AIMXm0LEflgw==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@aws-sdk/core": "^3.978.1", @@ -176,6 +183,7 @@ "version": "3.972.84", "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-node/-/credential-provider-node-3.972.84.tgz", "integrity": "sha512-oHt854odINVwzwsh+c5x69j0ajm4DbqqqVJ+O1ECsCIZeMDAbzFpXItaqP7UZstJj/ATdTk/KFSH0LaNAgV+kA==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@aws-sdk/credential-provider-env": "^3.972.72", @@ -198,6 +206,7 @@ "version": "3.972.72", "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-process/-/credential-provider-process-3.972.72.tgz", "integrity": "sha512-rLIp2xbMjX/k9/od7APpqq1ZgXXnV0pOL1Th3ZsL8Wu0TRtBsDTVS8iPqcfRFcHakFxPvR04OSTv2ka2qOb/2A==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@aws-sdk/core": "^3.978.1", @@ -214,6 +223,7 @@ "version": "3.973.16", "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-sso/-/credential-provider-sso-3.973.16.tgz", "integrity": "sha512-IGihaJfFZYacJJr/odqILCoK7W/mvrZ7cuK7ECn3sAu4vLC6u0V8bS7mCGbdugJ8Aum2tnvqmx0F2MRFp2rn9g==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@aws-sdk/core": "^3.978.1", @@ -232,6 +242,7 @@ "version": "3.1138.0", "resolved": "https://registry.npmjs.org/@aws-sdk/token-providers/-/token-providers-3.1138.0.tgz", "integrity": "sha512-GpyAr0DD63YOEmYFM6Df+gJuIgC92MMTiBK4FTKfxii5MJ9ge20epR7LyroulscYlG89J+ZB2ivFDPjvfQhzdw==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@aws-sdk/core": "^3.978.1", @@ -249,6 +260,7 @@ "version": "3.972.78", "resolved": "https://registry.npmjs.org/@aws-sdk/credential-provider-web-identity/-/credential-provider-web-identity-3.972.78.tgz", "integrity": "sha512-/y9WvNtlcPBGLR0qc1a+9J/xtYZfVczvLUOuXaVWylzttH7ewsxwHtjmiJSolNrVSDorIxHGHMU61CbonRkmwA==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@aws-sdk/core": "^3.978.1", @@ -266,6 +278,7 @@ "version": "3.972.35", "resolved": "https://registry.npmjs.org/@aws-sdk/eventstream-handler-node/-/eventstream-handler-node-3.972.35.tgz", "integrity": "sha512-a8xilRoRaalvSPZdfrs0VY3/BPc0uYhXW56Z/k6nmZ5Vk430LHeowf9APIPq8utM3tMJSNGSSuJMlB9YrPsN+A==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@aws-sdk/types": "^3.974.6", @@ -281,6 +294,7 @@ "version": "3.972.30", "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-eventstream/-/middleware-eventstream-3.972.30.tgz", "integrity": "sha512-B6gvZlcnRBNWraKgyEjKsbhv+VjtbyHmpU7hmtTHzXpDSxHPpCJnYLpglEOOsF+SFne20DbZC5IVC1aNr2Pb4A==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@aws-sdk/types": "^3.974.6", @@ -296,6 +310,7 @@ "version": "3.972.54", "resolved": "https://registry.npmjs.org/@aws-sdk/middleware-websocket/-/middleware-websocket-3.972.54.tgz", "integrity": "sha512-bhESdru8u8KosziH8jcVta/NM/dNreeRz2+2aU86si5bfBYOiJ6IiqD+9U4URUcU5WJO3Yw+jO3GLDIHlscXMQ==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@aws-sdk/core": "^3.978.1", @@ -314,6 +329,7 @@ "version": "3.997.46", "resolved": "https://registry.npmjs.org/@aws-sdk/nested-clients/-/nested-clients-3.997.46.tgz", "integrity": "sha512-oRxtBcka/JGHGs9l9p9IVajGoTP8vTPmoAzdHGy4Qcy9P5vPnDf6nhIeM/COQNY9k/OahImTRaLkHftoXvfcmQ==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@aws-sdk/core": "^3.978.1", @@ -333,6 +349,7 @@ "version": "3.996.47", "resolved": "https://registry.npmjs.org/@aws-sdk/signature-v4-multi-region/-/signature-v4-multi-region-3.996.47.tgz", "integrity": "sha512-Zk08macMvQTHzQJCLJVkOlviVoqwYMrpXv4lmLN7b7sAbiMoOK7Go0NYdR5UeF+MW8LIbRmwrNy9u/5VvX1U5g==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@aws-sdk/types": "^3.974.6", @@ -348,6 +365,7 @@ "version": "3.1127.0", "resolved": "https://registry.npmjs.org/@aws-sdk/token-providers/-/token-providers-3.1127.0.tgz", "integrity": "sha512-Dv2TMWBshJ+tF6ahs2Sy5bh4Iabsd4GAQqVvE9XZmYmnoaVbpS2QKIKE/HRacc7bTtbjEEvP+laGzHvHlf1CiQ==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@aws-sdk/core": "^3.977.9", @@ -365,6 +383,7 @@ "version": "3.974.6", "resolved": "https://registry.npmjs.org/@aws-sdk/types/-/types-3.974.6.tgz", "integrity": "sha512-v/clNZzZnDxGyvpHMOGpJKVXFAExJzUNAAjaWGdcx8QAcXLGwTaOkw33p5SHAi0YAioK32xB3hWwOekRVfmfKg==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@smithy/types": "^4.19.0", @@ -378,6 +397,7 @@ "version": "3.972.41", "resolved": "https://registry.npmjs.org/@aws-sdk/xml-builder/-/xml-builder-3.972.41.tgz", "integrity": "sha512-ctjVSyCMegrWfXlx6VqzSBFI6UqmQ5ZlnfMhdLIiWmhoH8UAQxSCP5N3OpG7X3k4LnS7ou74C4mt20+bfTW2aQ==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@smithy/types": "^4.19.0", @@ -391,6 +411,7 @@ "version": "0.3.0", "resolved": "https://registry.npmjs.org/@aws/lambda-invoke-store/-/lambda-invoke-store-0.3.0.tgz", "integrity": "sha512-sl4Bm6yiMNYrZKkqqDFWN0UfnWhlS8ivKxrYl+6t0gCLrqr8y3B2IqZZbFRkfaVVp7C/baApyh71P+LeE1A2sQ==", + "dev": true, "license": "Apache-2.0", "engines": { "node": ">=18.0.0" @@ -400,6 +421,7 @@ "version": "7.29.7", "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.29.7.tgz", "integrity": "sha512-Nq8OhGWiZIZGV6hLHoyAKLLcJihP/xFeBMGJoUrxTX2psI8dCifzLhZISFb+VWS3wFMRDmCGw5R+dOySCqPLhw==", + "dev": true, "license": "MIT", "engines": { "node": ">=6.9.0" @@ -409,6 +431,7 @@ "version": "1.0.4", "resolved": "https://registry.npmjs.org/@earendil-works/chord/-/chord-1.0.4.tgz", "integrity": "sha512-d2JZw2utoa/reoSmL07O71wsXiMDhIlnnxTb4LCNV+Oq8Evj2rGLvjVuYrlXZGbXUr0IDNfvd1RT/utCY1UhkQ==", + "dev": true, "license": "MIT", "dependencies": { "esbuild": "0.28.2" @@ -421,6 +444,7 @@ "version": "1.0.4", "resolved": "https://registry.npmjs.org/@earendil-works/pi-agent-core/-/pi-agent-core-1.0.4.tgz", "integrity": "sha512-/xGICE+N/+G9N7KfYFSxlE8G8fQcBlLHKiY+j1Ehz9vvb1zhvGneWosFK56d2qmA5oteafeG7yKr2nqU4ed9ig==", + "dev": true, "license": "MIT", "dependencies": { "@earendil-works/pi-ai": "^1.0.4", @@ -434,12 +458,14 @@ "version": "1.3.27", "resolved": "https://registry.npmjs.org/typebox/-/typebox-1.3.27.tgz", "integrity": "sha512-zu+jc1pcy4UiNThxikUr36f0Rybk9PEeCg/NE6adeWr/SKsdNO4EzZHYRDlv2YCVAfj3Odq3dESSo/jNyoBXzA==", + "dev": true, "license": "MIT" }, "node_modules/@earendil-works/pi-ai": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/@earendil-works/pi-ai/-/pi-ai-1.0.4.tgz", "integrity": "sha512-/Eu5R0gfor6wcmRcVyOmulUiZmsHJ0bKu5wXXnpCoSHF3y4FnW4fgnjRlLjNza8NJWXdvW5Uew90Zukx7Sh2rw==", + "dev": true, "license": "MIT", "dependencies": { "@anthropic-ai/sdk": "0.129.0", @@ -464,12 +490,14 @@ "version": "1.3.27", "resolved": "https://registry.npmjs.org/typebox/-/typebox-1.3.27.tgz", "integrity": "sha512-zu+jc1pcy4UiNThxikUr36f0Rybk9PEeCg/NE6adeWr/SKsdNO4EzZHYRDlv2YCVAfj3Odq3dESSo/jNyoBXzA==", + "dev": true, "license": "MIT" }, "node_modules/@earendil-works/pi-codemode": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/@earendil-works/pi-codemode/-/pi-codemode-1.0.4.tgz", "integrity": "sha512-e198pjBsdEQJ/RCjJ9ZeYIjRaQYWUgtoZbPCmJ57auuOsiRsBXeSZ1aiWtTah0/7gx97WIOD1XqHvgRU0gOXtg==", + "dev": true, "license": "MIT", "dependencies": { "quickjs-wasi": "3.6.2" @@ -482,6 +510,7 @@ "version": "1.0.4", "resolved": "https://registry.npmjs.org/@earendil-works/pi-coding-agent/-/pi-coding-agent-1.0.4.tgz", "integrity": "sha512-+956nfMFHr5lDUVY/2Q4k+YzojzBuCaBXFgj0eSlXVGr7QVliVddKdc1Pz6yVg1dOlJQmb67doOVrlMsIcIdaw==", + "dev": true, "license": "MIT", "dependencies": { "@earendil-works/chord": "^1.0.4", @@ -519,18 +548,21 @@ "version": "0.3.4", "resolved": "https://registry.npmjs.org/@silvia-odwyer/photon-node/-/photon-node-0.3.4.tgz", "integrity": "sha512-bnly4BKB3KDTFxrUIcgCLbaeVVS8lrAkri1pEzskpmxu9MdfGQTy8b8EgcD83ywD3RPMsIulY8xJH5Awa+t9fA==", + "dev": true, "license": "Apache-2.0" }, "node_modules/@earendil-works/pi-coding-agent/node_modules/graceful-fs": { "version": "4.2.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", + "dev": true, "license": "ISC" }, "node_modules/@earendil-works/pi-coding-agent/node_modules/highlight.js": { "version": "10.7.3", "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-10.7.3.tgz", "integrity": "sha512-tzcUFauisWKNHaRkN4Wjl/ZA07gENAjFl3J/c480dprkGTg5EQstgaNFqBfUqCq54kZRIEcreTsAgF/m2quD7A==", + "dev": true, "license": "BSD-3-Clause", "engines": { "node": "*" @@ -540,6 +572,7 @@ "version": "9.0.3", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-9.0.3.tgz", "integrity": "sha512-Hc+ghLoSt6QaYZUv0WBiIvmMDZuZZ7oaDvdH8MbfOO4lOsxdXLEvuC6ePoGs9H1X9oCLyq6+NVN0MKqD+ydxyg==", + "dev": true, "license": "ISC", "dependencies": { "lru-cache": "^11.1.0" @@ -552,6 +585,7 @@ "version": "2.7.0", "resolved": "https://registry.npmjs.org/jiti/-/jiti-2.7.0.tgz", "integrity": "sha512-AC/7JofJvZGrrneWNaEnJeOLUx+JlGt7tNa0wZiRPT4MY1wmfKjt2+6O2p2uz2+skll8OZZmJMNqeke7kKbNgQ==", + "dev": true, "license": "MIT", "bin": { "jiti": "lib/jiti-cli.mjs" @@ -561,6 +595,7 @@ "version": "11.4.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.4.0.tgz", "integrity": "sha512-W+R+kFL4HgVxONq2bhXPi3bGpzGe/yEhVOp233qw9wCRtgncJ15P3bC+e4zZMu4Cq7d+WAJjXGW0uUkifhcatA==", + "dev": true, "license": "BlueOak-1.0.0", "engines": { "node": "20 || >=22" @@ -570,6 +605,7 @@ "version": "4.1.2", "resolved": "https://registry.npmjs.org/proper-lockfile/-/proper-lockfile-4.1.2.tgz", "integrity": "sha512-TjNPblN4BwAWMXU8s9AEz4JmQxnD1NNL7bNOY/AKUzyamc379FWASUhc/K1pL2noVb+XmZKLL68cjzLsiOAMaA==", + "dev": true, "license": "MIT", "dependencies": { "graceful-fs": "^4.2.4", @@ -581,6 +617,7 @@ "version": "0.12.0", "resolved": "https://registry.npmjs.org/retry/-/retry-0.12.0.tgz", "integrity": "sha512-9LkiTwjUh6rT555DtE9rTX+BKByPfrMzEAtnlEtdEwr3Nkffwiihqe2bWADg+OQRjt9gl6ICdmB/ZFDCGAtSow==", + "dev": true, "license": "MIT", "engines": { "node": ">= 4" @@ -590,18 +627,21 @@ "version": "3.0.7", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "dev": true, "license": "ISC" }, "node_modules/@earendil-works/pi-coding-agent/node_modules/typebox": { "version": "1.3.27", "resolved": "https://registry.npmjs.org/typebox/-/typebox-1.3.27.tgz", "integrity": "sha512-zu+jc1pcy4UiNThxikUr36f0Rybk9PEeCg/NE6adeWr/SKsdNO4EzZHYRDlv2YCVAfj3Odq3dESSo/jNyoBXzA==", + "dev": true, "license": "MIT" }, "node_modules/@earendil-works/pi-mcp": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/@earendil-works/pi-mcp/-/pi-mcp-1.0.4.tgz", "integrity": "sha512-I6SqOqrKED+XrjkkFIXY7Ze38QtXtjojPJlQsJ2v5soCPV4QI1bNxXDwQaqzZ2a+6pNN8meWrRw1qkSMbPy9QQ==", + "dev": true, "license": "MIT", "dependencies": { "cross-spawn": "7.0.6" @@ -614,6 +654,7 @@ "version": "1.0.4", "resolved": "https://registry.npmjs.org/@earendil-works/pi-telemetry/-/pi-telemetry-1.0.4.tgz", "integrity": "sha512-DL2eXXtnL5/VQkuQd97fL57GXTG1/zKHtMmDsrv8tGeJ5EgYYTWvzy44dqbYL0lD0Z22v/NOwqU3PHO75HVrqA==", + "dev": true, "license": "MIT", "engines": { "node": ">=22.19.0" @@ -623,6 +664,7 @@ "version": "1.0.4", "resolved": "https://registry.npmjs.org/@earendil-works/pi-tui/-/pi-tui-1.0.4.tgz", "integrity": "sha512-TgvDJohtxvG3XWQID5w6bwEyBocywdG0F9yHZtP+Ywvtiq9RgeSMbeB8quUobk7/4ko6IvFOQo45AqIqNVr8Rg==", + "dev": true, "license": "MIT", "dependencies": { "get-east-asian-width": "1.6.0", @@ -1062,6 +1104,7 @@ "version": "2.21.0", "resolved": "https://registry.npmjs.org/@google/genai/-/genai-2.21.0.tgz", "integrity": "sha512-+PDtco2/Z0ONdzCGekCoCT+O1VJS9xJQNN4XzQpXG/t3El/SWWMkCWlFRO1KmivOHPa4Q0VjUYu1HBKCZ/v33Q==", + "dev": true, "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { @@ -1878,13 +1921,13 @@ } }, "node_modules/@prjct.app/pi-secrets": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/@prjct.app/pi-secrets/-/pi-secrets-0.2.1.tgz", - "integrity": "sha512-9WWp+slUCLmF7i9bepGFalHP0SoSPgwz22M8EHSaf+UtgbJPpRiE0AivfXvo5iRXdwBCeUjO4xHWzraEhimPnQ==", + "version": "0.2.6", + "resolved": "https://registry.npmjs.org/@prjct.app/pi-secrets/-/pi-secrets-0.2.6.tgz", + "integrity": "sha512-CgP02Qdt54NSUf6MvL1Ed8R4HWMbfOWJLaDid6TWhb5HPB4nuI+/nMxrq4R8+Ybm9zTdGWa3A9NtzUvyLXACIg==", "license": "MIT", "dependencies": { "@napi-rs/keyring": "1.3.0", - "@prjct.app/pi-tui-kit": "^0.3.1" + "@prjct.app/pi-tui-kit": "^0.3.5" }, "engines": { "node": ">=22.19.0" @@ -1897,9 +1940,9 @@ } }, "node_modules/@prjct.app/pi-tui-kit": { - "version": "0.3.4", - "resolved": "https://registry.npmjs.org/@prjct.app/pi-tui-kit/-/pi-tui-kit-0.3.4.tgz", - "integrity": "sha512-+pbMGGyefTimnTSmRZsf2AZahf8U3Pz/SCP6qr3490OAYLPzt/Axjts1mW8EhsRoNUJGp4kQMWYhul29XOo/Ig==", + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/@prjct.app/pi-tui-kit/-/pi-tui-kit-0.3.5.tgz", + "integrity": "sha512-E0vQ5xV8d+m7hD+NvyiSZexFEsmrNmTHvgQBvemXioY/5juBOqnvHYwcFQzc+of3sNUOGvvyC30f+yS6bqcZgw==", "license": "MIT", "engines": { "node": ">=22.19.0" @@ -1972,6 +2015,7 @@ "version": "3.35.1", "resolved": "https://registry.npmjs.org/@smithy/core/-/core-3.35.1.tgz", "integrity": "sha512-i4YPS4B6ts7bjn7UwLnGjiZdprOvHvgGobFZsYK3GIY3E5hIqtj0rReU69BcTpGp+fvtraSNXeG1l+jtJvF55w==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@smithy/types": "^4.19.0", @@ -1985,6 +2029,7 @@ "version": "4.5.2", "resolved": "https://registry.npmjs.org/@smithy/credential-provider-imds/-/credential-provider-imds-4.5.2.tgz", "integrity": "sha512-A9uSdn72ozbRUSit0eib0TW7nXuNPlaeM0zcGkJ+nE6tFcSDbnmtwoxbTCFBukVQcszDAyvsd7+rTduPTXpygg==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@smithy/core": "^3.33.2", @@ -1999,6 +2044,7 @@ "version": "5.8.0", "resolved": "https://registry.npmjs.org/@smithy/fetch-http-handler/-/fetch-http-handler-5.8.0.tgz", "integrity": "sha512-ycSJu3tFAQ4v04CBB0agqFMVsSQ1iG3yw+SpgxRqKfaURpQD4CZ8Wn0zPMmSnOuTpTh65Vz+EA0rMrw089wvkA==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@smithy/core": "^3.33.3", @@ -2013,6 +2059,7 @@ "version": "4.12.1", "resolved": "https://registry.npmjs.org/@smithy/node-http-handler/-/node-http-handler-4.12.1.tgz", "integrity": "sha512-ThMkboGeONWXAelq9FvGsuJC4rOi+qyC4/zhUF58xYpxUg5sQKx2VXZYJmtNjr4dSuBJ1HeJXETQILCz3wOHvw==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@smithy/core": "^3.33.3", @@ -2027,6 +2074,7 @@ "version": "5.7.4", "resolved": "https://registry.npmjs.org/@smithy/signature-v4/-/signature-v4-5.7.4.tgz", "integrity": "sha512-tHy0K0VtqNd5Y7Y41h0a0Lhh0L1GzC08dTWg0F7vRJWFtTENg7IZikf3wQkanYIRdb7ngoIPMTmqgUi401fEeQ==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@smithy/core": "^3.35.0", @@ -2041,6 +2089,7 @@ "version": "4.19.0", "resolved": "https://registry.npmjs.org/@smithy/types/-/types-4.19.0.tgz", "integrity": "sha512-r7jh49VJxGerfAcTQA6gXcKc+98zOp/tqRwzYjgOE+iSQsP6cEU1hq2QzbuipmP68QtYdY9wKEhiCQZIzHgZ4Q==", + "dev": true, "license": "Apache-2.0", "dependencies": { "tslib": "^2.6.2" @@ -2053,6 +2102,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/@stablelib/base64/-/base64-1.0.1.tgz", "integrity": "sha512-1bnPQqSxSuc3Ii6MhBysoWCg58j97aUjuCSZrGSmDxNqtytIi0k8utUenAwTZN4V5mXXYGsVUI9zeBqy+jBOSQ==", + "dev": true, "license": "MIT" }, "node_modules/@types/node": { @@ -2068,6 +2118,7 @@ "version": "0.12.0", "resolved": "https://registry.npmjs.org/@types/retry/-/retry-0.12.0.tgz", "integrity": "sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA==", + "dev": true, "license": "MIT" }, "node_modules/adm-zip": { @@ -2083,6 +2134,7 @@ "version": "9.0.0", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-9.0.0.tgz", "integrity": "sha512-TQf59BsZnytt8GdJKLPfUZ54g/iaUL2OWDSFCCvMOhsHduDQxO8xC4PNeyIkVcA5KwL2phPSv0douC0fgWzmnA==", + "dev": true, "license": "MIT", "engines": { "node": ">= 20" @@ -2092,6 +2144,7 @@ "version": "4.0.4", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", + "dev": true, "license": "MIT", "engines": { "node": "18 || 20 || >=22" @@ -2101,6 +2154,7 @@ "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "dev": true, "funding": [ { "type": "github", @@ -2121,6 +2175,7 @@ "version": "9.3.1", "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.3.1.tgz", "integrity": "sha512-Ko0uX15oIUS7wJ3Rb30Fs6SkVbLmPBAKdlm7q9+ak9bbIeFf0MwuBsQV6z7+X768/cHsfg+WlysDWJcmthjsjQ==", + "dev": true, "license": "MIT", "engines": { "node": "*" @@ -2130,12 +2185,14 @@ "version": "2.14.1", "resolved": "https://registry.npmjs.org/bowser/-/bowser-2.14.1.tgz", "integrity": "sha512-tzPjzCxygAKWFOJP011oxFHs57HzIhOEracIgAePE4pqB3LikALKnSzUyU4MGs9/iCEUuHlAJTjTc5M+u7YEGg==", + "dev": true, "license": "MIT" }, "node_modules/brace-expansion": { "version": "5.0.12", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz", "integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==", + "dev": true, "license": "MIT", "dependencies": { "balanced-match": "^4.0.2" @@ -2148,12 +2205,14 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==", + "dev": true, "license": "BSD-3-Clause" }, "node_modules/chalk": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/chalk/-/chalk-6.0.0.tgz", "integrity": "sha512-2uNTXIuTTxk7ciZgAU1BQcgnchcG0xXnrs6jzkQfj9SsRa9M2s5zE8WT96hS6KmG4MzWHSrvH43DF1m4XRkrFg==", + "dev": true, "license": "MIT", "engines": { "node": ">=22" @@ -2166,6 +2225,7 @@ "version": "7.0.6", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "dev": true, "license": "MIT", "dependencies": { "path-key": "^3.1.0", @@ -2180,6 +2240,7 @@ "version": "4.0.1", "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", "integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==", + "dev": true, "license": "MIT", "engines": { "node": ">= 12" @@ -2189,6 +2250,7 @@ "version": "4.4.3", "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "dev": true, "license": "MIT", "dependencies": { "ms": "^2.1.3" @@ -2249,6 +2311,7 @@ "version": "8.0.4", "resolved": "https://registry.npmjs.org/diff/-/diff-8.0.4.tgz", "integrity": "sha512-DPi0FmjiSU5EvQV0++GFDOJ9ASQUVFh5kD+OzOnYdi7n3Wpm9hWWGfB/O2blfHcMVTL5WkQXSnRiK9makhrcnw==", + "dev": true, "license": "BSD-3-Clause", "engines": { "node": ">=0.3.1" @@ -2258,6 +2321,7 @@ "version": "1.0.11", "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", + "dev": true, "license": "Apache-2.0", "dependencies": { "safe-buffer": "^5.0.1" @@ -2338,18 +2402,21 @@ "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", + "dev": true, "license": "MIT" }, "node_modules/fast-sha256": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/fast-sha256/-/fast-sha256-1.3.0.tgz", "integrity": "sha512-n11RGP/lrWEFI/bWdygLxhI+pVeo1ZYIVwvvPkW7azl/rOy+F3HYRZ2K5zeE9mmkhQppyv9sQFx0JM9UabnpPQ==", + "dev": true, "license": "Unlicense" }, "node_modules/fetch-blob": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==", + "dev": true, "funding": [ { "type": "github", @@ -2379,6 +2446,7 @@ "version": "4.0.10", "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", + "dev": true, "license": "MIT", "dependencies": { "fetch-blob": "^3.1.2" @@ -2405,6 +2473,7 @@ "version": "7.3.1", "resolved": "https://registry.npmjs.org/gaxios/-/gaxios-7.3.1.tgz", "integrity": "sha512-kB3rzJV7d9juLZh8/56QTXCwQfxyhdOMdyYk1HdQKFtF8TJTDTZQJtixWIwXdE9Jji91mC41DUNpjleo4L4eAQ==", + "dev": true, "license": "Apache-2.0", "dependencies": { "extend": "^3.0.2", @@ -2419,6 +2488,7 @@ "version": "7.1.4", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.4.tgz", "integrity": "sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==", + "dev": true, "license": "MIT", "engines": { "node": ">= 14" @@ -2428,6 +2498,7 @@ "version": "7.0.6", "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz", "integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==", + "dev": true, "license": "MIT", "dependencies": { "agent-base": "^7.1.2", @@ -2441,6 +2512,7 @@ "version": "8.1.2", "resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-8.1.2.tgz", "integrity": "sha512-zV/5HKTfCeKWnxG0Dmrw51hEWFGfcF2xiXqcA3+J90WDuP0SvoiSO5ORvcBsifmx/FoIjgQN3oNOGaQ5PhLFkg==", + "dev": true, "license": "Apache-2.0", "dependencies": { "gaxios": "^7.0.0", @@ -2455,6 +2527,7 @@ "version": "1.6.0", "resolved": "https://registry.npmjs.org/get-east-asian-width/-/get-east-asian-width-1.6.0.tgz", "integrity": "sha512-QRbvDIbx6YklUe6RxeTeleMR0yv3cYH6PsPZHcnVn7xv7zO1BHN8r0XETu8n6Ye3Q+ahtSarc3WgtNWmehIBfA==", + "dev": true, "license": "MIT", "engines": { "node": ">=18" @@ -2498,6 +2571,7 @@ "version": "10.9.1", "resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-10.9.1.tgz", "integrity": "sha512-i1ydyHrqcIxXkWh/uBmVkzCvIuq5yiK2ATndIe5XxKholrG/MTYP9xGYka4sQhrbIAgGjL2B6NOE7rFaiF3fXw==", + "dev": true, "license": "Apache-2.0", "dependencies": { "base64-js": "^1.3.0", @@ -2515,6 +2589,7 @@ "version": "1.1.3", "resolved": "https://registry.npmjs.org/google-logging-utils/-/google-logging-utils-1.1.3.tgz", "integrity": "sha512-eAmLkjDjAFCVXg7A1unxHsLf961m6y17QFqXqAXGj/gVkKFrEICfStRfwUlGNfeCEjNRa32JEWOUTlYXPyyKvA==", + "dev": true, "license": "Apache-2.0", "engines": { "node": ">=14" @@ -2536,6 +2611,7 @@ "version": "0.2.3", "resolved": "https://registry.npmjs.org/grok-mermaid/-/grok-mermaid-0.2.3.tgz", "integrity": "sha512-/4KopAbsjvuRP9MdPtlDjOHUmUVEohOX73JNcsWpzAtFxh+bq5+Dhb6gzvRieLDwIPQIR3/vy8V1NNTuz4Zsmg==", + "dev": true, "license": "Apache-2.0", "engines": { "node": ">=18" @@ -2563,6 +2639,7 @@ "version": "9.1.0", "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-9.1.0.tgz", "integrity": "sha512-2NxoveTT58mjYT4n3RPTEfCZGLMbidoO8XEieXfpSYxu+PQJ1qpx4ypwH6N+uF9twBPIvRRgvkvW5HUTYWENig==", + "dev": true, "license": "MIT", "dependencies": { "agent-base": "9.0.0", @@ -2577,6 +2654,7 @@ "version": "9.1.0", "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-9.1.0.tgz", "integrity": "sha512-ag87y7cJJ9/3+GxFr8Oy4O5faDsGRGnBGsJj/YjOSsSx/5eadKLYTMPlzuR6obgoCDDm0abAAZitXXQkMOPSpA==", + "dev": true, "license": "MIT", "dependencies": { "agent-base": "9.0.0", @@ -2591,6 +2669,7 @@ "version": "7.0.8", "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.8.tgz", "integrity": "sha512-YYNsSlXBjMk92SKnkwvB5LOVSa6OznlFUGcsvrFgNJbJCd0M1XKeFVRc8ZByeCqz32FivYNHJVooLmdqrmvp/Q==", + "dev": true, "license": "MIT", "engines": { "node": ">= 4" @@ -2600,12 +2679,14 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true, "license": "ISC" }, "node_modules/json-bigint": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/json-bigint/-/json-bigint-1.0.0.tgz", "integrity": "sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ==", + "dev": true, "license": "MIT", "dependencies": { "bignumber.js": "^9.0.0" @@ -2615,6 +2696,7 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/json-schema-to-ts/-/json-schema-to-ts-3.1.1.tgz", "integrity": "sha512-+DWg8jCJG2TEnpy7kOm/7/AxaYoaRbjVB4LFZLySZlWn8exGs3A4OLJR966cVvU26N7X9TWxl+Jsw7dzAqKT6g==", + "dev": true, "license": "MIT", "dependencies": { "@babel/runtime": "^7.18.3", @@ -2628,6 +2710,7 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/jwa/-/jwa-2.0.1.tgz", "integrity": "sha512-hRF04fqJIP8Abbkq5NKGN0Bbr3JxlQ+qhZufXVr0DvujKy93ZCbXZMHDL4EOtodSbCWxOqR8MS1tXA5hwqCXDg==", + "dev": true, "license": "MIT", "dependencies": { "buffer-equal-constant-time": "^1.0.1", @@ -2639,6 +2722,7 @@ "version": "4.0.1", "resolved": "https://registry.npmjs.org/jws/-/jws-4.0.1.tgz", "integrity": "sha512-EKI/M/yqPncGUUh44xz0PxSidXFr/+r0pA70+gIYhjv+et7yxM+s29Y+VGDkovRofQem0fs7Uvf4+YmAdyRduA==", + "dev": true, "license": "MIT", "dependencies": { "jwa": "^2.0.1", @@ -2655,6 +2739,7 @@ "version": "18.0.11", "resolved": "https://registry.npmjs.org/marked/-/marked-18.0.11.tgz", "integrity": "sha512-HnslJfsZkRPBDJRHvVtAaWlZHEpSu7u8LgQuJCELjRKuWR+hpq4A7sLq3p8HaI9ypVoXDXxV34CsQJEe1+J5Aw==", + "dev": true, "license": "MIT", "bin": { "marked": "bin/marked.js" @@ -2682,6 +2767,7 @@ "version": "10.2.6", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz", "integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==", + "dev": true, "license": "BlueOak-1.0.0", "dependencies": { "brace-expansion": "^5.0.8" @@ -2697,6 +2783,7 @@ "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, "license": "MIT" }, "node_modules/node-domexception": { @@ -2704,6 +2791,7 @@ "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==", "deprecated": "Use your platform's native DOMException instead", + "dev": true, "funding": [ { "type": "github", @@ -2723,6 +2811,7 @@ "version": "3.3.2", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", + "dev": true, "license": "MIT", "dependencies": { "data-uri-to-buffer": "^4.0.0", @@ -2793,6 +2882,7 @@ "version": "7.19.0", "resolved": "https://registry.npmjs.org/openai/-/openai-7.19.0.tgz", "integrity": "sha512-MX2s3u2L5racTO0CC/SWpCOasJQBCJrqLKXK+l82cAhdeF8mPMBEe/gxMm0ZFa2xpKpOFLRjxv5afYEZbBXmbQ==", + "dev": true, "license": "Apache-2.0", "engines": { "node": ">=22.0.0" @@ -2830,6 +2920,7 @@ "version": "4.6.2", "resolved": "https://registry.npmjs.org/p-retry/-/p-retry-4.6.2.tgz", "integrity": "sha512-312Id396EbJdvRONlngUx0NydfrIQ5lsYu0znKVUzVvArzEIt08V1qhtyESbGVd1FGX7UKtiFp5uwKZdM8wIuQ==", + "dev": true, "license": "MIT", "dependencies": { "@types/retry": "0.12.0", @@ -2843,12 +2934,14 @@ "version": "0.1.7", "resolved": "https://registry.npmjs.org/partial-json/-/partial-json-0.1.7.tgz", "integrity": "sha512-Njv/59hHaokb/hRUjce3Hdv12wd60MtM9Z5Olmn+nehe0QDAsRtRbJPvJ0Z91TusF0SuZRIvnM+S4l6EIP8leA==", + "dev": true, "license": "MIT" }, "node_modules/path-key": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, "license": "MIT", "engines": { "node": ">=8" @@ -2887,6 +2980,7 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/proxy-agent-negotiate/-/proxy-agent-negotiate-1.1.0.tgz", "integrity": "sha512-N8IBcM3UgCVzz2L2Lqv8DVntDnnC8/hiV4nEDUPkqq72TPUgYWjQc+bdZlBPZK9LzPAvOY//gAt0S0DApoOXWQ==", + "dev": true, "license": "MIT", "engines": { "node": ">= 20" @@ -2904,12 +2998,14 @@ "version": "3.6.2", "resolved": "https://registry.npmjs.org/quickjs-wasi/-/quickjs-wasi-3.6.2.tgz", "integrity": "sha512-FCqGtGOrMgzUiIrMNMA2YnsOxCNwo31dzqXvclXUC6xeT35NJLKXQJsvbeCTjvoFAwZgEAPg8U6+KAPDGXn8Mg==", + "dev": true, "license": "MIT" }, "node_modules/retry": { "version": "0.13.1", "resolved": "https://registry.npmjs.org/retry/-/retry-0.13.1.tgz", "integrity": "sha512-XQBQ3I8W1Cge0Seh+6gjj03LbmRFWuoszgK9ooCpwYIrhhoO80pfq4cUkU5DkknwfOfFteRwlZ56PYOGYyFWdg==", + "dev": true, "license": "MIT", "engines": { "node": ">= 4" @@ -2919,6 +3015,7 @@ "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true, "funding": [ { "type": "github", @@ -3015,6 +3112,7 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, "license": "MIT", "dependencies": { "shebang-regex": "^3.0.0" @@ -3027,6 +3125,7 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, "license": "MIT", "engines": { "node": ">=8" @@ -3114,6 +3213,7 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/standardwebhooks/-/standardwebhooks-1.1.1.tgz", "integrity": "sha512-bCbX9ZEyFkWPsRz7Bl3NuQUJohmwGSev/yhr7vhaGPlc4AfIrspIRa6cPTBuI1ItmrTDJ4d/S2hCsfe4+vQGnQ==", + "dev": true, "license": "MIT", "dependencies": { "@stablelib/base64": "^1.0.0", @@ -3124,12 +3224,14 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/ts-algebra/-/ts-algebra-2.0.0.tgz", "integrity": "sha512-FPAhNPFMrkwz76P7cdjdmiShwMynZYN6SgOujD1urY4oNm80Ou9oMdmbR45LotcKOXoy7wSmHkRFE6Mxbrhefw==", + "dev": true, "license": "MIT" }, "node_modules/tslib": { "version": "2.8.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "devOptional": true, "license": "0BSD" }, "node_modules/tsx": { @@ -3166,6 +3268,7 @@ "version": "1.3.7", "resolved": "https://registry.npmjs.org/typebox/-/typebox-1.3.7.tgz", "integrity": "sha512-meKuifc33Pccx0O6PdIzYMq3Og8zvP4TIi/a+Bw3AEMZMxOD0+RHGQvpglEe6Zdy3wZ8nqn/j95h8LUZLk/6Hg==", + "dev": true, "license": "MIT" }, "node_modules/typescript": { @@ -3186,6 +3289,7 @@ "version": "8.10.2", "resolved": "https://registry.npmjs.org/undici/-/undici-8.10.2.tgz", "integrity": "sha512-/y4/bH9YNU5hi9NIrpOuvGXFcxrj3CMrV+/AYpowAYTpHn8gX/XPFjNy766FPoYY0miQhdW977JFWKGNhBdwyQ==", + "dev": true, "license": "MIT", "engines": { "node": ">=22.19.0" @@ -3201,6 +3305,7 @@ "version": "3.3.3", "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz", "integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==", + "dev": true, "license": "MIT", "engines": { "node": ">= 8" @@ -3210,6 +3315,7 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, "license": "ISC", "dependencies": { "isexe": "^2.0.0" @@ -3225,6 +3331,7 @@ "version": "8.22.0", "resolved": "https://registry.npmjs.org/ws/-/ws-8.22.0.tgz", "integrity": "sha512-Ydggc987+RO0AnWtZ/7Wq9FtNvcrL1b/RO0ud9mWjUPgDrsAAwQSF51sm2hm1XofbU/4jkpGEsLFsZZxU+1DOg==", + "dev": true, "license": "MIT", "engines": { "node": ">=10.0.0" @@ -3246,6 +3353,7 @@ "version": "2.9.0", "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.9.0.tgz", "integrity": "sha512-2AvhNX3mb8zd6Zy7INTtSpl1F15HW6Wnqj0srWlkKLcpYl/gMIMJiyuGq2KeI2YFxUPjdlB+3Lc10seMLtL4cA==", + "dev": true, "license": "ISC", "bin": { "yaml": "bin.mjs" diff --git a/package.json b/package.json index 34f3b69..f421f8b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@prjct.app/pi-memory", - "version": "0.2.1", + "version": "0.2.2", "description": "Pi-native temporal memory and hybrid retrieval for agents.", "type": "module", "keywords": [ @@ -45,13 +45,13 @@ }, "dependencies": { "@huggingface/transformers": "4.3.0", - "@prjct.app/pi-secrets": "^0.2.1", + "@prjct.app/pi-secrets": "^0.2.6", "@prjct.app/pi-tui-kit": "^0.3.4", "sqlite-vec": "0.1.9", "tsx": "^4.20.0" }, "peerDependencies": { - "@earendil-works/pi-ai": "*", + "@earendil-works/pi-ai": ">=1.0.4", "@earendil-works/pi-coding-agent": "*", "@earendil-works/pi-tui": "*", "typebox": "*" diff --git a/src/curation/analyzer.ts b/src/curation/analyzer.ts index ae58e94..e7dfc4f 100644 --- a/src/curation/analyzer.ts +++ b/src/curation/analyzer.ts @@ -1,5 +1,5 @@ import { protectOutboundData } from '@prjct.app/pi-secrets/privacy'; -import type { Api, AssistantMessage, Model } from '@earendil-works/pi-ai'; +import { contentText, type Api, type Model } from '@earendil-works/pi-ai'; import { ModelRuntime } from '@earendil-works/pi-coding-agent'; import { CurationBlockError, type AnalysisResult, type Analyzer, type EvidenceBundle } from './types.ts'; import { extractJsonObject, parseProposal } from './validate.ts'; @@ -37,9 +37,6 @@ Rules: - Never assign provenance. The publisher derives it from the source boundary; you are not a host observer. - Preserve the source language, meaning, qualifications and force. Quote the source verbatim in excerpt; excerpts are evidence and are never translated.`; -const textOf = (message: AssistantMessage): string => - message.content.flatMap(block => 'type' in block && block.type === 'text' && 'text' in block ? [String(block.text)] : []).join('\n'); - const bundlePrompt = (bundle: EvidenceBundle): string => JSON.stringify({ identity: bundle.identity, currentTopic: bundle.currentTopic ?? null, @@ -66,7 +63,7 @@ export const createSdkAnalyzer = async (options: Readonly<{ if (message.stopReason === 'error' || message.stopReason === 'aborted') { throw new Error(message.errorMessage || `Analysis ${message.stopReason}.`); } - const output = textOf(message); + const output = contentText(message.content); if (Buffer.byteLength(output, 'utf8') > maxOutputChars) throw new Error('Analysis output exceeded the size limit.'); const proposal = parseProposal(extractJsonObject(output), bundle); return { diff --git a/src/curation/curator.ts b/src/curation/curator.ts index ea7cf86..ad57f17 100644 --- a/src/curation/curator.ts +++ b/src/curation/curator.ts @@ -1,5 +1,5 @@ import { protectOutboundData } from '@prjct.app/pi-secrets/privacy'; -import type { Api, AssistantMessage, Model } from '@earendil-works/pi-ai'; +import { contentText, type Api, type Model } from '@earendil-works/pi-ai'; import { ModelRuntime } from '@earendil-works/pi-coding-agent'; import { createHash } from 'node:crypto'; import { mkdir, readFile, readdir, stat, writeFile } from 'node:fs/promises'; @@ -45,9 +45,6 @@ Return ONLY a JSON object: {"actions":[...]}. Each action is one of: If an added rule refines an existing one, supersede the existing rule by the new one's position instead of keeping both: add it, then supersede the old id with "by":"new". Leave every other rule alone. Never invent a rule. Prefer fewer actions when unsure.`; -const textOf = (message: AssistantMessage): string => - message.content.flatMap(block => 'type' in block && block.type === 'text' && 'text' in block ? [String(block.text)] : []).join('\n'); - /** Only actions about rules that were shown, with the fields each op needs. */ export const parseCuration = (value: unknown, rules: readonly Rule[], userMessages: readonly string[] = []): CurationAction[] => { const ids = new Set(rules.map(rule => rule.id)); @@ -95,7 +92,7 @@ export const createSdkCurator = async (options: Readonly<{ provider: string; mod messages: [{ role: 'user', content: JSON.stringify(await protectOutboundData({ rules, userMessages })), timestamp: Date.now() }], }, { maxTokens: Math.min(model.maxTokens, 32768), reasoning: 'high', ...(signal === undefined ? {} : { signal }) }); if (message.stopReason === 'error' || message.stopReason === 'aborted') throw new Error(message.errorMessage || `Curation ${message.stopReason}.`); - return parseCuration(extractJsonObject(textOf(message)), rules, userMessages); + return parseCuration(extractJsonObject(contentText(message.content)), rules, userMessages); }, }; }; diff --git a/src/curation/translator.ts b/src/curation/translator.ts index 3c57238..3d5e0a1 100644 --- a/src/curation/translator.ts +++ b/src/curation/translator.ts @@ -1,5 +1,5 @@ import { protectOutboundData } from '@prjct.app/pi-secrets/privacy'; -import type { Api, AssistantMessage, Model } from '@earendil-works/pi-ai'; +import { contentText, type Api, type Model } from '@earendil-works/pi-ai'; import { ModelRuntime } from '@earendil-works/pi-coding-agent'; /** @@ -24,9 +24,6 @@ Rules: prohibition, a preference stays a preference. - If the input is already English, return it unchanged.`; -const textOf = (message: AssistantMessage): string => - message.content.flatMap(block => 'type' in block && block.type === 'text' && 'text' in block ? [String(block.text)] : []).join('\n'); - export class TranslationUnavailableError extends Error { constructor(message: string) { super(message); @@ -44,7 +41,7 @@ const complete = async ( if (message.stopReason === 'error' || message.stopReason === 'aborted') { throw new TranslationUnavailableError(message.errorMessage || `Translation ${message.stopReason}.`); } - const output = textOf(message).trim(); + const output = contentText(message.content).trim(); // A translation that comes back empty, or wildly longer than its input, is // the model having answered the sentence instead of translating it. if (!output || output.length > Math.max(400, text.length * 3)) { diff --git a/src/eval/answer.ts b/src/eval/answer.ts index 547af5d..c2defd5 100644 --- a/src/eval/answer.ts +++ b/src/eval/answer.ts @@ -1,14 +1,11 @@ import { protectOutboundData } from '@prjct.app/pi-secrets/privacy'; -import type { Api, AssistantMessage, Model } from '@earendil-works/pi-ai'; +import { contentText, type Api, type Model } from '@earendil-works/pi-ai'; import { ModelRuntime } from '@earendil-works/pi-coding-agent'; import { CurationBlockError } from '../curation/types.ts'; import type { AnswerProvider, AnswerRequest, AnswerResult } from './comparison.ts'; const SYSTEM = 'Answer only from the provided evidence and prior facts. Quote supporting excerpts. Do not invent claims.'; -const textOf = (message: AssistantMessage): string => - message.content.flatMap(block => 'type' in block && block.type === 'text' && 'text' in block ? [String(block.text)] : []).join('\n'); - export const createSdkAnswerProvider = async (options: Readonly<{ provider: string; model: string; maxOutputChars?: number; }>): Promise => { @@ -32,7 +29,7 @@ export const createSdkAnswerProvider = async (options: Readonly<{ if (message.stopReason === 'error' || message.stopReason === 'aborted') { return { text: '', inputTokens: message.usage?.input ?? 0, outputTokens: message.usage?.output ?? 0, failed: true }; } - const text = textOf(message).slice(0, maxOutputChars); + const text = contentText(message.content).slice(0, maxOutputChars); return { text, inputTokens: message.usage?.input ?? Math.ceil(request.evidence.length / 4), diff --git a/src/extension/hooks.ts b/src/extension/hooks.ts index c85112d..7e877b5 100644 --- a/src/extension/hooks.ts +++ b/src/extension/hooks.ts @@ -3,6 +3,7 @@ import { mkdir, realpath, writeFile } from 'node:fs/promises'; import { homedir, tmpdir } from 'node:os'; import { dirname, join, resolve } from 'node:path'; import type { ExtensionAPI, ExtensionContext } from '@earendil-works/pi-coding-agent'; +import { contentText } from '@earendil-works/pi-ai'; import type { EvidenceRef } from '../contracts/evidence.ts'; import { factIsValidAt, type MemoryKind } from '../contracts/memory.ts'; import { renderMemoryEnvelope, type MemoryEnvelope } from '../handoff/memory-envelope.ts'; @@ -588,7 +589,7 @@ export const installMemoryHooks = (pi: ExtensionAPI, options: { return branch.flatMap(entry => { if (entry.type !== 'message' || entry.message.role !== 'user') return []; const content = entry.message.content; - return [typeof content === 'string' ? content : content.filter(part => part.type === 'text').map(part => part.text).join('\n')]; + return [contentText(content)]; }); }, }; diff --git a/src/sources/discovery.ts b/src/sources/discovery.ts index 6e1451e..08a925f 100644 --- a/src/sources/discovery.ts +++ b/src/sources/discovery.ts @@ -1,6 +1,6 @@ import { readdir, readFile } from 'node:fs/promises'; -import { homedir } from 'node:os'; import { join } from 'node:path'; +import { getAgentDir } from '@earendil-works/pi-coding-agent'; /** * Scopes are discovered from the marker files prjct publishes, not from @@ -19,7 +19,7 @@ const TEAM_NAME = /^[a-z][a-z0-9-]{0,47}$/; * the mailbox is agent-local runtime state. */ export const teamMailboxRoot = (override?: string): string => - override ?? join(process.env.PI_CODING_AGENT_DIR ?? join(homedir(), '.pi', 'agent'), 'teams'); + override ?? join(getAgentDir(), 'teams'); const readTeamMarker = async (home: string, id: string): Promise => { const raw = await readFile(join(home, 'teams', id, 'settings.json'), 'utf8').catch(() => undefined); From a4d6e68c620a6a9b86dca171c4529bc9e0a5ccac Mon Sep 17 00:00:00 2001 From: JJ Date: Fri, 9 Oct 2026 13:42:43 -0500 Subject: [PATCH 2/2] fix: send memory snapshots once and never force the system prompt (0.2.3) before_agent_start re-sent an identical every user turn, including "No eligible facts" for empty memory. It now sends only what the retained context (buildSessionProjection) lacks, reusing the uniqueMemory delivery rules: an unchanged snapshot is skipped, a new recall rides alone, A-B-A is a new delivery, an evicted snapshot is sent again, and an empty memory with no earlier snapshot to revoke sends nothing. The hook also returned systemPrompt: event.systemPrompt as a no-op. Pi 1.1 treats any returned systemPrompt as a forced prompt for prompted turns only, so it is no longer returned. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 5 ++++ package-lock.json | 4 +-- package.json | 2 +- src/extension/hooks.ts | 55 +++++++++++++++++++++------------- src/handoff/memory-envelope.ts | 39 +++++++++++++++++++----- tests/cache-strategy.test.ts | 15 +++++++++- tests/extension.test.ts | 4 +-- tests/memory-works.test.ts | 20 ++++++++++++- tests/relevance.test.ts | 5 ++-- tests/session-learning.test.ts | 2 +- 10 files changed, 111 insertions(+), 40 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e29638..4ed7fc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.2.3 (2026-10-09) + +- Send the memory snapshot only when the retained context lacks it: an unchanged snapshot is no longer repeated every turn, a new recall rides alone, and an empty memory with nothing to revoke sends nothing. +- Never return `systemPrompt` from `before_agent_start`. Pi treats any returned prompt, even an unchanged one, as a forced prompt for that turn only. + ## 0.2.2 (2026-10-07) ## 0.2.0 (2026-10-06) diff --git a/package-lock.json b/package-lock.json index f629c6e..4ae73a0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@prjct.app/pi-memory", - "version": "0.2.2", + "version": "0.2.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@prjct.app/pi-memory", - "version": "0.2.2", + "version": "0.2.3", "license": "MIT", "dependencies": { "@huggingface/transformers": "4.3.0", diff --git a/package.json b/package.json index f421f8b..6e0d63c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@prjct.app/pi-memory", - "version": "0.2.2", + "version": "0.2.3", "description": "Pi-native temporal memory and hybrid retrieval for agents.", "type": "module", "keywords": [ diff --git a/src/extension/hooks.ts b/src/extension/hooks.ts index 7e877b5..30a961f 100644 --- a/src/extension/hooks.ts +++ b/src/extension/hooks.ts @@ -6,7 +6,8 @@ import type { ExtensionAPI, ExtensionContext } from '@earendil-works/pi-coding-a import { contentText } from '@earendil-works/pi-ai'; import type { EvidenceRef } from '../contracts/evidence.ts'; import { factIsValidAt, type MemoryKind } from '../contracts/memory.ts'; -import { renderMemoryEnvelope, type MemoryEnvelope } from '../handoff/memory-envelope.ts'; +import { unseenMemory, type MemoryEnvelope } from '../handoff/memory-envelope.ts'; +import type { HandoffMessage } from '../handoff/turns.ts'; import { hostEvidence, MemoryEngine } from '../engine.ts'; import type { EmbeddingProvider } from '../vector/providers.ts'; import { CORE_DIGEST_BYTES, CORE_KINDS, memoryDigest, memoryStatusLine } from './digest.ts'; @@ -96,6 +97,8 @@ export const recallQueries = (prompt: string): string[] => { const NOT_INITIALIZED = /not initialized/iu; /** Facts considered for the digest; far more than fit its byte budget. */ const DIGEST_SCAN_LIMIT = 500; +/** The revision of an empty snapshot; a context without any snapshot holds the same. */ +const EMPTY_REVISION = sha256(''); export const isNotInitialized = (error: unknown): boolean => error instanceof Error && NOT_INITIALIZED.test(error.message); const retainedJson = (value: unknown): string => JSON.stringify(value) @@ -411,11 +414,21 @@ export const installMemoryHooks = (pi: ExtensionAPI, options: { const digest = memoryDigest(facts, Date.now(), CORE_DIGEST_BYTES, CORE_KINDS); return { facts, digest, small: memoryDigest(facts).complete, revision: sha256(digest.block ?? '') }; }; - const memoryMessage = (revision: string, block: string | undefined, recall?: string, items = 0, omitted = 0) => { + /** What the next request carries, compaction-aware. Fixtures without a session carry nothing. */ + const retainedMessages = (ctx: ExtensionContext): readonly HandoffMessage[] => { + try { return ctx.sessionManager.buildSessionProjection?.().messages ?? []; } catch { return []; } + }; + /** + * Only the part of the envelope the retained context lacks: an unchanged + * snapshot is not resent every turn, and an empty memory with no earlier + * snapshot to revoke sends nothing. Undefined when nothing is new. + */ + const memoryMessage = (ctx: ExtensionContext, revision: string, block: string | undefined, recall?: string, items = 0, omitted = 0) => { const memory: MemoryEnvelope = { version: 1, revision, snapshot: block ?? 'No eligible facts in this snapshot.', ...(recall ? { recall } : {}) }; - return { customType: 'pi-memory-recall', content: renderMemoryEnvelope(memory), display: false, - details: { memory, items, omitted } }; + const content = unseenMemory(retainedMessages(ctx), memory, EMPTY_REVISION); + if (content === undefined) return undefined; + return { customType: 'pi-memory-recall', content, display: false, details: { memory, items, omitted } }; }; /** @@ -423,16 +436,16 @@ export const installMemoryHooks = (pi: ExtensionAPI, options: { * result) never reach before_agent_start. After the window is rebuilt the core * goes back in right away, so those turns do not run without the rules. */ - const restoreCore = async (): Promise => { + const restoreCore = async (ctx: ExtensionContext): Promise => { const current = get(); const project = await engine().catch(() => undefined); if (!project || get().generation !== current.generation) return; const { digest, revision } = coreSnapshot(project); - if (!digest.block) return; - pi.sendMessage(memoryMessage(revision, digest.block), { triggerTurn: false }); + const message = memoryMessage(ctx, revision, digest.block); + if (message) pi.sendMessage(message, { triggerTurn: false }); }; - pi.on('session_compact', async () => { await restoreCore().catch(() => undefined); }); - pi.on('session_tree', async () => { await restoreCore().catch(() => undefined); }); + pi.on('session_compact', async (_event, ctx) => { await restoreCore(ctx).catch(() => undefined); }); + pi.on('session_tree', async (_event, ctx) => { await restoreCore(ctx).catch(() => undefined); }); pi.on('before_agent_start', async (event, ctx) => { const current = get(); @@ -440,7 +453,7 @@ export const installMemoryHooks = (pi: ExtensionAPI, options: { void flushInBackground(); set({ ctx, prompt: event.prompt }); await countTurn(ctx).catch(() => undefined); - if (stale()) return { systemPrompt: event.systemPrompt }; + if (stale()) return undefined; const prompt = clipSessionSummary(event.prompt); const observedAt = new Date().toISOString(); const correction = declaredCorrectionQuote(event.prompt); @@ -463,20 +476,20 @@ export const installMemoryHooks = (pi: ExtensionAPI, options: { } } const project = await engine().catch(() => undefined); - if (stale()) return { systemPrompt: event.systemPrompt }; - // No system prompt edits: a per-turn system prompt is dropped on automated - // turns (subagent results, self-compact handoffs), which flipped the cached - // prefix and re-billed the whole context. The snapshot itself says it is - // reference data, not instructions. - const base = event.systemPrompt; + if (stale()) return undefined; + // Never return systemPrompt, not even unchanged: Pi takes any returned + // prompt as a forced prompt and rewrites the request head for this turn. + // Automated turns (subagent results, self-compact handoffs) skip this hook, + // so the cached prefix flipped and the whole context was re-billed. The + // snapshot itself says it is reference data, not instructions. if (!project) return undefined; const { facts, digest, small, revision } = coreSnapshot(project); - // L0 is policy only. Changing facts belong at the append-only message tail, - // not in the early system prefix. Include empty snapshots to revoke memory. - const systemPrompt = base; + // Changing facts belong at the append-only message tail, not in the early + // system prefix. An empty snapshot still revokes an earlier one in context. const deliver = (recall?: string, items = 0, omitted = 0) => { try { setMode(ctx, 'memory', memoryStatusLine(digest, facts.length, items)); } catch { /* the status line must not cost the prompt */ } - return { systemPrompt, message: memoryMessage(revision, digest.block, recall, items, omitted) }; + const message = memoryMessage(ctx, revision, digest.block, recall, items, omitted); + return message ? { message } : undefined; }; // The snapshot already carries all of memory: nothing to search, no encoder. if (facts.every(fact => digest.covered.has(fact.id))) return deliver(); @@ -485,7 +498,7 @@ export const installMemoryHooks = (pi: ExtensionAPI, options: { const dense = small ? false : encoderReady(project); const recalled = await search({ queries: recallQueries(event.prompt), limit: 8, maxBytes: 1500, dense, scoreThreshold: recallThreshold, namespaces: ['memory', 'memory.topic'] }) .catch(() => undefined); - if (stale()) return { systemPrompt: event.systemPrompt }; + if (stale()) return undefined; const highConfidence = (recalled?.items ?? []) .filter(item => (item.standing === 'supported' || item.standing === 'needs_review') && !digest.covered.has(item.id)).slice(0, 4); const memoryBlock = highConfidence.length diff --git a/src/handoff/memory-envelope.ts b/src/handoff/memory-envelope.ts index 08fe281..b55df49 100644 --- a/src/handoff/memory-envelope.ts +++ b/src/handoff/memory-envelope.ts @@ -8,6 +8,20 @@ export const renderMemoryEnvelope = (memory: MemoryEnvelope, snapshot = true, re ...(recall && memory.recall ? [memory.recall] : []), ].join('\n\n'); +type DeliveryState = { revision: string | undefined; recalls: Set }; + +/** Which parts of `memory` are new after the deliveries folded into `state`; folds this one in. */ +const nextDelivery = (state: DeliveryState, memory: MemoryEnvelope): { snapshot: boolean; recall: boolean } => { + const snapshot = state.revision !== memory.revision; + if (snapshot) { + state.revision = memory.revision; + state.recalls.clear(); + } + const recall = Boolean(memory.recall && !state.recalls.has(memory.recall)); + if (memory.recall) state.recalls.add(memory.recall); + return { snapshot, recall }; +}; + /** Recompute from retained context, never from a process-lifetime delivery ledger. * Keep first-copy bytes and compare only the latest snapshot: A → B → A is a * new delivery, not a repeat of the obsolete A. Proposed messages count only @@ -15,7 +29,7 @@ export const renderMemoryEnvelope = (memory: MemoryEnvelope, snapshot = true, re */ export const uniqueMemory = (messages: readonly HandoffMessage[], onReplacement?: (replacement: HandoffMessage, source: HandoffMessage) => void): readonly HandoffMessage[] => { - const state = { revision: undefined as string | undefined, recalls: new Set() }; + const state: DeliveryState = { revision: undefined, recalls: new Set() }; return messages.flatMap(message => { const custom = message as EnvelopeMessage; if (custom.customType !== 'pi-memory-recall') return [message]; @@ -26,13 +40,7 @@ export const uniqueMemory = (messages: readonly HandoffMessage[], state.recalls.add(key); return [message]; } - const snapshot = state.revision !== memory.revision; - if (snapshot) { - state.revision = memory.revision; - state.recalls.clear(); - } - const recall = Boolean(memory.recall && !state.recalls.has(memory.recall)); - if (memory.recall) state.recalls.add(memory.recall); + const { snapshot, recall } = nextDelivery(state, memory); if (!snapshot && !recall) return []; const content = renderMemoryEnvelope(memory, snapshot, recall); if (content === message.content) return [message]; @@ -41,3 +49,18 @@ export const uniqueMemory = (messages: readonly HandoffMessage[], return [replacement]; }); }; + +/** The envelope text the model does not already have in `retained`, or + * undefined when it would repeat what is there. A context with no snapshot + * counts as holding `baseline`, so an empty memory has nothing to revoke. + */ +export const unseenMemory = (retained: readonly HandoffMessage[], memory: MemoryEnvelope, baseline?: string): string | undefined => { + const state: DeliveryState = { revision: baseline, recalls: new Set() }; + for (const message of retained) { + const custom = message as EnvelopeMessage; + const earlier = custom.customType === 'pi-memory-recall' ? custom.details?.memory : undefined; + if (earlier?.version === 1) nextDelivery(state, earlier); + } + const { snapshot, recall } = nextDelivery(state, memory); + return snapshot || recall ? renderMemoryEnvelope(memory, snapshot, recall) : undefined; +}; diff --git a/tests/cache-strategy.test.ts b/tests/cache-strategy.test.ts index 82d393d..4deb80a 100644 --- a/tests/cache-strategy.test.ts +++ b/tests/cache-strategy.test.ts @@ -2,7 +2,7 @@ import assert from 'node:assert/strict'; import { test } from 'node:test'; import { createContextWindow } from '../src/handoff/window.ts'; import { budgetForModel, estimateHandoffTokens } from '../src/handoff/select.ts'; -import { renderMemoryEnvelope, uniqueMemory } from '../src/handoff/memory-envelope.ts'; +import { renderMemoryEnvelope, uniqueMemory, unseenMemory } from '../src/handoff/memory-envelope.ts'; import { retainHistory } from '../src/handoff/history.ts'; import { maskObservations } from '../src/handoff/observations.ts'; import { turnIsComplete, type HandoffMessage } from '../src/handoff/turns.ts'; @@ -78,6 +78,19 @@ test('retained envelopes append recall without repeating digest; snapshots revok assert.deepEqual(uniqueMemory([input[1]!]), [input[1]], 'evicted digest must be delivered again'); }); +test('the next delivery sends only what retained context lacks', () => { + const memory = (revision: string, recall?: string) => ({ version: 1 as const, revision, snapshot: `DIGEST_${revision}`, ...(recall ? { recall } : {}) }); + const retained = [user('first'), envelope('A', 'recall 1'), user('second')]; + assert.equal(unseenMemory(retained, memory('A')), undefined, 'an unchanged snapshot is not resent'); + assert.equal(unseenMemory(retained, memory('A', 'recall 1')), undefined, 'a recall already in context is not resent'); + assert.equal(unseenMemory(retained, memory('A', 'recall 2')), 'recall 2', 'a new recall rides without the snapshot'); + assert.match(String(unseenMemory(retained, memory('B'))), /DIGEST_B/, 'a changed snapshot is sent'); + assert.match(String(unseenMemory([...retained, envelope('B')], memory('A'))), /DIGEST_A/, 'A-B-A is a new delivery'); + assert.match(String(unseenMemory([user('after compaction')], memory('A'))), /DIGEST_A/, 'an evicted snapshot is sent again'); + assert.equal(unseenMemory([user('first')], memory('empty'), 'empty'), undefined, 'no snapshot in context equals the empty baseline'); + assert.match(String(unseenMemory(retained, memory('empty'), 'empty')), /DIGEST_empty/, 'an empty snapshot still revokes an earlier one'); +}); + test('envelope survives the same selection that evicts its first copy', () => { const window = createContextWindow(noMask); const initial = [user('first'), envelope('A', 'recall')]; diff --git a/tests/extension.test.ts b/tests/extension.test.ts index b7c4ab9..263a175 100644 --- a/tests/extension.test.ts +++ b/tests/extension.test.ts @@ -285,7 +285,7 @@ test('automatic recall preserves evidence already bounded by retrieval instead o await engine.recordFact({ kind: 'procedure', statement: text.slice(0, 8000), standing: 'supported', entities: [], evidence: [], episodeIds: [], confidence: 0.9, tags: { area: 'backup' } }); const response = await handlers.get('before_agent_start')!({ prompt: 'SQLite backup', systemPrompt: 'Base rules.' }, ctx); - assert.doesNotMatch(response.systemPrompt, /Decision: preserve the WAL/, 'a long memory is only previewed in the digest'); + assert.equal(response.systemPrompt, undefined, 'memory never returns a system prompt: Pi would force it for this turn only'); assert.equal(response.message.content.match(/<\/project_memory>/g)?.length, 1, 'stored text cannot close the digest'); assert.equal(response.message.customType, 'pi-memory-recall'); assert.match(response.message.content, /Decision: preserve the WAL/); @@ -403,7 +403,7 @@ test('a stale prompt/activity open cannot overwrite a replacement session', asyn await starting; const response = await prompt; assert.equal(runtime.currentPrompt(), ''); - assert.equal(response.message, undefined); + assert.equal(response?.message, undefined); assert.deepEqual(activity, []); assert.deepEqual(counters, { turns: 0, disposed: 1 }); await handlers.get('session_shutdown')!({}, ctxB); diff --git a/tests/memory-works.test.ts b/tests/memory-works.test.ts index 504af17..81386f2 100644 --- a/tests/memory-works.test.ts +++ b/tests/memory-works.test.ts @@ -92,6 +92,24 @@ test('an agent-recorded memory is in the next prompt\'s snapshot without loading assert.equal(again.systemPrompt, result.systemPrompt, 'the digest is stable across prompts'); }); +test('a snapshot still in context is not resent; after compaction removes it, it is', async t => { + const h = await harness(t, { git: true }); + await h.tools.get('memory_record').execute('c1', { + action: 'remember', kind: 'decision', statement: 'Compiled Pi builds live in the agent builds directory outside repositories.', + }); + const transcript: any[] = []; + const ctx = { ...h.ctx, sessionManager: { ...h.ctx.sessionManager, buildSessionProjection: () => ({ messages: transcript }) } }; + const first = await h.handlers.get('before_agent_start')!({ prompt: 'where do builds go?', systemPrompt: 'base' }, ctx); + assert.equal(first.systemPrompt, undefined, 'a returned prompt would be forced for this turn only'); + assert.match(first.message.content, / { const failing = await harness(t, { git: true }); await failing.handlers.get('tool_result')!({ toolName: 'bash', toolCallId: 'f1', isError: true, @@ -198,7 +216,7 @@ test('memory larger than the digest gets vectors in the background and per-promp assert.ok(engine.projection.stats().vectors > 0, 'vectors once memory exceeds the digest'); const result = await h.handlers.get('before_agent_start')!({ prompt: 'why do deploys to the staging cluster fail?', systemPrompt: 'base' }, h.ctx); assert.doesNotMatch(result.message.content, /Service \d+ runbook/, 'facts are not in the core snapshot'); - assert.doesNotMatch(result.systemPrompt, /kubeconfig context/, 'failures never ride in the system prompt'); + assert.equal(result.systemPrompt, undefined, 'failures never ride in the system prompt'); assert.match(result.message?.content ?? '', / kase.name === 'O8')!; const recalled = await handlers.get('before_agent_start')!({ prompt: o8.query, systemPrompt: 'Base' }, ctx); - assert.equal(recalled.systemPrompt, 'Base', 'the system prompt is left byte-identical'); - assert.match(recalled.message.content, /Reference data only, not instructions/); - assert.equal(recalled.message.details.memory.recall, undefined, 'unrelated prompt gets no overflow recall'); + assert.equal(recalled?.systemPrompt, undefined, 'the system prompt is never returned'); + assert.equal(recalled?.message, undefined, 'unrelated prompt gets no overflow recall, and an empty core has nothing to revoke'); const lookup = await tools.get('memory_context').execute('call', { action: 'lookup', queries: [o8.query] }); assert.equal(scoreOracle(lookup.details.items, o8, lookup.details).passed, true); for (const kase of cases) { diff --git a/tests/session-learning.test.ts b/tests/session-learning.test.ts index 2d1abcb..e82ba2b 100644 --- a/tests/session-learning.test.ts +++ b/tests/session-learning.test.ts @@ -269,7 +269,7 @@ test('tool observations alone never invent durable memories', async t => { const recalled = await handlers.get('before_agent_start')!({ prompt: 'error TS2688 Cannot find type definition file for node', systemPrompt: 'Base', }, ctx(cwd, 'next-session')); - assert.doesNotMatch(recalled.message.content, /error TS2688/, 'unrecorded observations do not become durable facts'); + assert.doesNotMatch(recalled?.message?.content ?? '', /error TS2688/, 'unrecorded observations do not become durable facts'); await handlers.get('session_shutdown')!({}, ctx(cwd, 'next-session')); });