From e488e7063100e2debda683515e406da5480e7d8f Mon Sep 17 00:00:00 2001 From: Rohit Ghumare Date: Fri, 23 Oct 2026 22:19:21 +0530 Subject: [PATCH 1/6] feat(pi): package the native extension for distribution Signed-off-by: Rohit Ghumare --- README.md | 2 +- integrations/pi/LICENSE | 190 +++++++++++++++++++++++++++++++++++ integrations/pi/README.md | 54 +++++----- integrations/pi/package.json | 5 +- package.json | 1 + test/connect-pi.test.ts | 35 ++++++- 6 files changed, 254 insertions(+), 33 deletions(-) create mode 100644 integrations/pi/LICENSE diff --git a/README.md b/README.md index 20884ba57e..3075655ea3 100644 --- a/README.md +++ b/README.md @@ -789,7 +789,7 @@ The agentmemory entry is the **same MCP server block** across every host that us | **Codex CLI (full plugin)** | Codex plugin marketplace | `codex plugin marketplace add rohitg00/agentmemory` then `codex plugin add agentmemory@agentmemory`. Registers MCP + 6 lifecycle hooks + 17 skills. Trust hooks and verify capture in your host; see [Codex setup and validation](docs/plugins/codex-local.md). | | **OpenCode (MCP only)** | `opencode.json` | Different shape: top-level `mcp` key, command as array: `{"mcp": {"agentmemory": {"type": "local", "command": ["npx", "-y", "@agentmemory/mcp"], "enabled": true}}}`. | | **OpenCode (full plugin)** | `plugin/opencode/` | 22 auto-capture hooks covering session lifecycle, messages, tools, errors. Project attribution is per-session, so one OpenCode process spanning several repositories files each session under its own project. Two slash commands (`/recall`, `/remember`). Copy `plugin/opencode/` into your OpenCode workspace and add the plugin entry to `opencode.json`. See [`plugin/opencode/README.md`](plugin/opencode/README.md) for the full hook table + gap analysis. | -| **pi** | `~/.pi/agent/extensions/agentmemory` | `agentmemory connect pi` installs the bundled extension into pi's auto-discovery directory (recall on agent start, capture on agent end, `memory_search` / `memory_save` / `memory_health` tools, `/agentmemory-status`). `/reload` in a running pi picks it up. [`integrations/pi`](integrations/pi/) is also a pi package (`pi install ./integrations/pi` from a checkout). | +| **pi** | pi package settings | `pi install ./integrations/pi` from a checkout installs native recall/capture, memory tools, and `/agentmemory-status`. After the first npm publication, use `pi install npm:agentmemory-pi-extension`. Alternatively, `agentmemory connect pi` copies the bundled extension into pi's auto-discovery directory. Use one method, then `/reload`; see [setup and migration](integrations/pi/). | | **Hermes Agent** | `$HERMES_HOME/config.yaml`, default `~/.hermes/config.yaml` | `agentmemory connect hermes` installs the native provider and skills. Configure its scoped credentials with `hermes memory setup`. Add `--with-mcp` for the wider tool surface. See [setup and scope](integrations/hermes/). | | **Qwen Code** | `~/.qwen/settings.json` | `agentmemory connect qwen` writes the standard `mcpServers` block. Hook payload is field-compatible with Claude Code, so the existing 12-hook scripts work without modification; wire them via the `hooks` section in the same `settings.json`. | | **Antigravity IDE / 2.0** | `~/.gemini/config/mcp_config.json` | `agentmemory connect antigravity --with-hooks` installs MCP and capture hooks in the shared customization directory. See [Antigravity setup and limits](docs/plugins/antigravity.md). | diff --git a/integrations/pi/LICENSE b/integrations/pi/LICENSE new file mode 100644 index 0000000000..cb13c72881 --- /dev/null +++ b/integrations/pi/LICENSE @@ -0,0 +1,190 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to the Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by the Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding any notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + Copyright 2026 Rohit Ghumare + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/integrations/pi/README.md b/integrations/pi/README.md index 85a2758e9f..0501d99a9d 100644 --- a/integrations/pi/README.md +++ b/integrations/pi/README.md @@ -1,42 +1,30 @@ -

- agentmemory -

+# agentmemory for pi -

-  agentmemory for pi -

- -

- Your pi sessions remember everything. No more re-explaining.
- Persistent cross-session memory via agentmemory — shared with Claude Code, Codex CLI, Gemini CLI, Hermes, OpenClaw, and more. -

- ---- +Persistent cross-session memory via [agentmemory](https://github.com/rohitg00/agentmemory), shared with Claude Code, Codex CLI, Gemini CLI, Hermes, OpenClaw, and more. ## Quick setup Start the agentmemory server in a separate terminal: ```bash -npx @agentmemory/agentmemory +npx -y @agentmemory/agentmemory@latest ``` -Copy this folder into pi's global extensions directory: +Install the package from an agentmemory checkout: ```bash -mkdir -p ~/.pi/agent/extensions/agentmemory -cp integrations/pi/index.ts ~/.pi/agent/extensions/agentmemory/index.ts +pi install ./integrations/pi ``` -Then enable it in `~/.pi/agent/settings.json` if you prefer explicit loading: +After the first npm publication, install without a checkout: -```json -{ - "extensions": ["~/.pi/agent/extensions/agentmemory"] -} +```bash +pi install npm:agentmemory-pi-extension ``` -If you place it under `~/.pi/agent/extensions/agentmemory/`, pi will also auto-discover it and `/reload` can hot-reload it. +Run `/reload` in pi, then `/agentmemory-status`. Keep the agentmemory server running while using the extension. + +Alternatively, `npx -y @agentmemory/agentmemory@latest connect pi` copies the bundled extension into `~/.pi/agent/extensions/agentmemory/`. Use one installation method. Before switching to a pi package, move any existing copied extension outside pi's extensions directory and remove explicit settings entries for that copy to avoid loading it twice. ## What it adds @@ -52,7 +40,7 @@ If you place it under `~/.pi/agent/extensions/agentmemory/`, pi will also auto-d | Variable | Default | Description | |---|---|---| | `AGENTMEMORY_URL` | `http://localhost:3111` | agentmemory server URL | -| `AGENTMEMORY_SECRET` | (none) | Bearer token for protected instances | +| `AGENTMEMORY_SECRET` | Local server credential | Explicit bearer token for protected instances. For loopback URLs, falls back to `~/.agentmemory/.env`, then `~/.agentmemory/secret`. Set it when connecting to a remote server. | | `AGENTMEMORY_REQUIRE_HTTPS` | (off) | When set to `1`, refuse to send a bearer token over plaintext HTTP to a non-loopback host. Sends the token only when `AGENTMEMORY_URL` is `https://...` or points at `localhost`/`127.0.0.1`/`::1`. With this off, the plugin warns once but still sends. | ## Smoke test @@ -63,7 +51,17 @@ Run pi and ask it to use the `memory_health` tool, or call the command directly: /agentmemory-status ``` -You should see `agentmemory healthy` and a footer status like `🧠 agentmemory`. +You should see `agentmemory healthy`. + +## Package archive + +From an agentmemory checkout, build an archive containing the extension and its local helper: + +```bash +npm run plugin:pack:pi +``` + +The archive is written to `dist/plugins/`. No build or repository dependencies are needed to pack this TypeScript extension; pi provides its runtime dependencies. ## Notes @@ -72,6 +70,6 @@ You should see `agentmemory healthy` and a footer status like `🧠 agentmemory` ## See also -- [agentmemory main README](../../README.md) -- [Hermes integration](../hermes/README.md) -- [OpenClaw integration](../openclaw/README.md) +- [agentmemory main README](https://github.com/rohitg00/agentmemory#readme) +- [Hermes integration](https://github.com/rohitg00/agentmemory/tree/main/integrations/hermes) +- [OpenClaw integration](https://github.com/rohitg00/agentmemory/tree/main/integrations/openclaw) diff --git a/integrations/pi/package.json b/integrations/pi/package.json index fdc37b3b7b..3a44d5e0f9 100644 --- a/integrations/pi/package.json +++ b/integrations/pi/package.json @@ -1,10 +1,10 @@ { "name": "agentmemory-pi-extension", "version": "0.1.0", - "private": true, "description": "agentmemory extension for the pi coding agent: memory recall on agent start, capture on agent end, memory_search / memory_save / memory_health tools, /agentmemory-status command", "type": "module", "license": "Apache-2.0", + "homepage": "https://github.com/rohitg00/agentmemory/tree/main/integrations/pi", "keywords": [ "pi-package", "agentmemory", @@ -18,7 +18,8 @@ "files": [ "index.ts", "security.ts", - "README.md" + "README.md", + "LICENSE" ], "pi": { "extensions": [ diff --git a/package.json b/package.json index 77063fdb0e..c764b66c0f 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "docs:sync": "tsx scripts/docs-sync.ts", "docs:check": "tsx scripts/docs-sync.ts --check", "plugin:pack:codex": "npm run build && node scripts/plugins/package-codex.mjs", + "plugin:pack:pi": "mkdir -p dist/plugins && npm pack ./integrations/pi --pack-destination dist/plugins", "plugin:verify:published": "node scripts/plugins/verify-published.mjs", "test:plugin:live": "node scripts/plugins/test-live.mjs", "bench:load": "node --import tsx benchmark/load-100k.ts", diff --git a/test/connect-pi.test.ts b/test/connect-pi.test.ts index d7736199c5..afd3c96abf 100644 --- a/test/connect-pi.test.ts +++ b/test/connect-pi.test.ts @@ -10,6 +10,7 @@ import { } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; +import { execFileSync } from "node:child_process"; // pi adapter: copies the bundled integrations/pi extension into // ~/.pi/agent/extensions/agentmemory/, which pi auto-discovers via its @@ -116,8 +117,38 @@ describe("integrations/pi is a valid pi package", () => { expect(pkg.pi.extensions).toEqual(["./index.ts"]); expect(pkg.peerDependencies["@earendil-works/pi-coding-agent"]).toBe("*"); expect(pkg.peerDependencies["typebox"]).toBe("*"); - // Local pi package only — never published to npm. - expect(pkg.private).toBe(true); + expect(pkg.private).not.toBe(true); + }); + + it("packs a self-contained extension with its helper and license", () => { + const dir = mkdtempSync(join(tmpdir(), "am-pi-pack-")); + try { + const npmCli = process.env.npm_execpath; + const output = execFileSync(npmCli ? process.execPath : "npm", [ + ...(npmCli ? [npmCli] : []), + "pack", "./integrations/pi", "--ignore-scripts", "--offline", + "--json", "--pack-destination", dir, + ], { + encoding: "utf-8", + env: { ...process.env, npm_config_cache: join(dir, "cache") }, + }); + const [packed] = JSON.parse(output); + execFileSync("tar", ["-xzf", join(dir, packed.filename), "-C", dir]); + const packageDir = join(dir, "package"); + expect(readdirSync(packageDir).sort()).toEqual([ + "LICENSE", "README.md", "index.ts", "package.json", "security.ts", + ]); + const pkg = JSON.parse(readFileSync(join(packageDir, "package.json"), "utf-8")); + expect(readFileSync(join(packageDir, pkg.pi.extensions[0]), "utf-8")) + .toBe(readFileSync("integrations/pi/index.ts", "utf-8")); + expect(readFileSync(join(packageDir, "security.ts"), "utf-8")) + .toBe(readFileSync("integrations/pi/security.ts", "utf-8")); + expect(readFileSync(join(packageDir, "LICENSE"), "utf-8")) + .toBe(readFileSync("LICENSE", "utf-8")); + expect(pkg.dependencies).toBeUndefined(); + } finally { + rmSync(dir, { recursive: true, force: true }); + } }); it("the npm package ships integrations/pi", () => { From 11a194d6fafcd3daf51ea720b32786c39a6c00c7 Mon Sep 17 00:00:00 2001 From: Rohit Ghumare Date: Fri, 23 Oct 2026 23:26:53 +0530 Subject: [PATCH 2/6] fix(pi): use the @agentmemory/pi package name Signed-off-by: Rohit Ghumare --- README.md | 2 +- integrations/pi/README.md | 2 +- integrations/pi/package.json | 5 ++++- test/connect-pi.test.ts | 6 ++++++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3075655ea3..a15cd5d9fa 100644 --- a/README.md +++ b/README.md @@ -789,7 +789,7 @@ The agentmemory entry is the **same MCP server block** across every host that us | **Codex CLI (full plugin)** | Codex plugin marketplace | `codex plugin marketplace add rohitg00/agentmemory` then `codex plugin add agentmemory@agentmemory`. Registers MCP + 6 lifecycle hooks + 17 skills. Trust hooks and verify capture in your host; see [Codex setup and validation](docs/plugins/codex-local.md). | | **OpenCode (MCP only)** | `opencode.json` | Different shape: top-level `mcp` key, command as array: `{"mcp": {"agentmemory": {"type": "local", "command": ["npx", "-y", "@agentmemory/mcp"], "enabled": true}}}`. | | **OpenCode (full plugin)** | `plugin/opencode/` | 22 auto-capture hooks covering session lifecycle, messages, tools, errors. Project attribution is per-session, so one OpenCode process spanning several repositories files each session under its own project. Two slash commands (`/recall`, `/remember`). Copy `plugin/opencode/` into your OpenCode workspace and add the plugin entry to `opencode.json`. See [`plugin/opencode/README.md`](plugin/opencode/README.md) for the full hook table + gap analysis. | -| **pi** | pi package settings | `pi install ./integrations/pi` from a checkout installs native recall/capture, memory tools, and `/agentmemory-status`. After the first npm publication, use `pi install npm:agentmemory-pi-extension`. Alternatively, `agentmemory connect pi` copies the bundled extension into pi's auto-discovery directory. Use one method, then `/reload`; see [setup and migration](integrations/pi/). | +| **pi** | pi package settings | `pi install ./integrations/pi` from a checkout installs native recall/capture, memory tools, and `/agentmemory-status`. After the first npm publication, use `pi install npm:@agentmemory/pi`. Alternatively, `agentmemory connect pi` copies the bundled extension into pi's auto-discovery directory. Use one method, then `/reload`; see [setup and migration](integrations/pi/). | | **Hermes Agent** | `$HERMES_HOME/config.yaml`, default `~/.hermes/config.yaml` | `agentmemory connect hermes` installs the native provider and skills. Configure its scoped credentials with `hermes memory setup`. Add `--with-mcp` for the wider tool surface. See [setup and scope](integrations/hermes/). | | **Qwen Code** | `~/.qwen/settings.json` | `agentmemory connect qwen` writes the standard `mcpServers` block. Hook payload is field-compatible with Claude Code, so the existing 12-hook scripts work without modification; wire them via the `hooks` section in the same `settings.json`. | | **Antigravity IDE / 2.0** | `~/.gemini/config/mcp_config.json` | `agentmemory connect antigravity --with-hooks` installs MCP and capture hooks in the shared customization directory. See [Antigravity setup and limits](docs/plugins/antigravity.md). | diff --git a/integrations/pi/README.md b/integrations/pi/README.md index 0501d99a9d..64e5d79ee1 100644 --- a/integrations/pi/README.md +++ b/integrations/pi/README.md @@ -19,7 +19,7 @@ pi install ./integrations/pi After the first npm publication, install without a checkout: ```bash -pi install npm:agentmemory-pi-extension +pi install npm:@agentmemory/pi ``` Run `/reload` in pi, then `/agentmemory-status`. Keep the agentmemory server running while using the extension. diff --git a/integrations/pi/package.json b/integrations/pi/package.json index 3a44d5e0f9..29be40ce3e 100644 --- a/integrations/pi/package.json +++ b/integrations/pi/package.json @@ -1,9 +1,12 @@ { - "name": "agentmemory-pi-extension", + "name": "@agentmemory/pi", "version": "0.1.0", "description": "agentmemory extension for the pi coding agent: memory recall on agent start, capture on agent end, memory_search / memory_save / memory_health tools, /agentmemory-status command", "type": "module", "license": "Apache-2.0", + "publishConfig": { + "access": "public" + }, "homepage": "https://github.com/rohitg00/agentmemory/tree/main/integrations/pi", "keywords": [ "pi-package", diff --git a/test/connect-pi.test.ts b/test/connect-pi.test.ts index afd3c96abf..2ec8af21db 100644 --- a/test/connect-pi.test.ts +++ b/test/connect-pi.test.ts @@ -113,6 +113,8 @@ describe("connect: pi", () => { describe("integrations/pi is a valid pi package", () => { it("package.json declares the pi manifest, keyword, and peer deps", () => { const pkg = JSON.parse(readFileSync("integrations/pi/package.json", "utf-8")); + expect(pkg.name).toBe("@agentmemory/pi"); + expect(pkg.publishConfig.access).toBe("public"); expect(pkg.keywords).toContain("pi-package"); expect(pkg.pi.extensions).toEqual(["./index.ts"]); expect(pkg.peerDependencies["@earendil-works/pi-coding-agent"]).toBe("*"); @@ -139,6 +141,10 @@ describe("integrations/pi is a valid pi package", () => { "LICENSE", "README.md", "index.ts", "package.json", "security.ts", ]); const pkg = JSON.parse(readFileSync(join(packageDir, "package.json"), "utf-8")); + expect(packed.name).toBe("@agentmemory/pi"); + expect(packed.filename).toBe(`agentmemory-pi-${pkg.version}.tgz`); + expect(pkg.name).toBe("@agentmemory/pi"); + expect(pkg.publishConfig.access).toBe("public"); expect(readFileSync(join(packageDir, pkg.pi.extensions[0]), "utf-8")) .toBe(readFileSync("integrations/pi/index.ts", "utf-8")); expect(readFileSync(join(packageDir, "security.ts"), "utf-8")) From 093eaaaf6af1cfb2448ede77ce6ea390779688a1 Mon Sep 17 00:00:00 2001 From: Rohit Ghumare Date: Sun, 25 Oct 2026 10:31:01 +0530 Subject: [PATCH 3/6] fix(pi): make packing portable and clarify local installs Signed-off-by: Rohit Ghumare --- integrations/pi/README.md | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/integrations/pi/README.md b/integrations/pi/README.md index 64e5d79ee1..8ceba76f7b 100644 --- a/integrations/pi/README.md +++ b/integrations/pi/README.md @@ -16,6 +16,8 @@ Install the package from an agentmemory checkout: pi install ./integrations/pi ``` +Pi loads this package directly from the checkout. Keep the checkout in place, or use the npm package or `connect pi` below for an installation independent of it. + After the first npm publication, install without a checkout: ```bash diff --git a/package.json b/package.json index c764b66c0f..135bd0dfe8 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "docs:sync": "tsx scripts/docs-sync.ts", "docs:check": "tsx scripts/docs-sync.ts --check", "plugin:pack:codex": "npm run build && node scripts/plugins/package-codex.mjs", - "plugin:pack:pi": "mkdir -p dist/plugins && npm pack ./integrations/pi --pack-destination dist/plugins", + "plugin:pack:pi": "node -e \"require('node:fs').mkdirSync('dist/plugins', { recursive: true })\" && npm pack ./integrations/pi --pack-destination dist/plugins", "plugin:verify:published": "node scripts/plugins/verify-published.mjs", "test:plugin:live": "node scripts/plugins/test-live.mjs", "bench:load": "node --import tsx benchmark/load-100k.ts", From 68d0040dc79c1e2ad7062fe4b58b9667cbb5c1d2 Mon Sep 17 00:00:00 2001 From: Rohit Ghumare Date: Sun, 25 Oct 2026 13:43:58 +0530 Subject: [PATCH 4/6] fix(pi): preserve MCP configuration permissions --- src/cli/connect/pi.ts | 7 +++---- test/connect-pi.test.ts | 9 ++++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/cli/connect/pi.ts b/src/cli/connect/pi.ts index 90ecb9f3e6..8d954fa21d 100644 --- a/src/cli/connect/pi.ts +++ b/src/cli/connect/pi.ts @@ -5,7 +5,7 @@ import { dirname, join, resolve } from "node:path"; import * as p from "@clack/prompts"; import type { ConnectAdapter } from "./types.js"; import { installNativeBundles, nativeMcpEntry, nativePackageRoot, nativeUserPath, prepareNativeBundle, record } from "./native-install.js"; -import { backupFile, logAlreadyWired, logBackup, logInstalled, writeTextAtomic } from "./util.js"; +import { logAlreadyWired, logBackup, logInstalled } from "./util.js"; const agentDir = () => process.env.PI_CODING_AGENT_DIR ? nativeUserPath(process.env.PI_CODING_AGENT_DIR, homedir()) : join(homedir(), ".pi/agent"); @@ -91,15 +91,14 @@ export const adapter: ConnectAdapter = { const mcpChanged = mcpText !== mcpRaw; let backupPath: string | undefined; if (mcpChanged) { - if (mcpRaw !== undefined) backupPath = backupFile(mcpPath, "pi-mcp"); - writeTextAtomic(mcpPath, mcpText!); + backupPath = installNativeBundles([], mcpPath, mcpText!); } try { if (configChanged) backupPath = installNativeBundles([bundle!], configPath, text) ?? backupPath; } catch (error) { if (mcpChanged) { if (mcpRaw === undefined) rmSync(mcpPath, { force: true }); - else writeTextAtomic(mcpPath, mcpRaw); + else installNativeBundles([], mcpPath, mcpRaw); } throw error; } diff --git a/test/connect-pi.test.ts b/test/connect-pi.test.ts index a221f13326..7908f6b949 100644 --- a/test/connect-pi.test.ts +++ b/test/connect-pi.test.ts @@ -1,6 +1,6 @@ import { createHash } from "node:crypto"; import { describe, it, expect, beforeEach, afterEach, vi } from "vitest"; -import { cpSync, mkdtempSync, mkdirSync, rmSync, readFileSync, readdirSync, writeFileSync, existsSync } from "node:fs"; +import { chmodSync, statSync, cpSync, mkdtempSync, mkdirSync, rmSync, readFileSync, readdirSync, writeFileSync, existsSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; import { execFileSync } from "node:child_process"; @@ -61,6 +61,13 @@ describe("connect: pi", () => { const custom = json(path); custom.mcpServers.agentmemory.env.CUSTOM = "preserve"; writeFileSync(path, JSON.stringify(custom)); await adapter.install({ ...options, withMcp: true, force: true }); expect(json(path)).toEqual(custom); }); + it.skipIf(process.platform === "win32")("preserves private permissions when adding MCP beside other credentials", async () => { + mkdirSync(dir(), { recursive: true }); const path = join(dir(), "mcp.json"); + const other = { url: "https://other.example", headers: { Authorization: "Bearer fixture-only" } }; + writeFileSync(path, JSON.stringify({ mcpServers: { other } })); chmodSync(path, 0o600); + const { adapter } = await import("../src/cli/connect/pi.js"); expect((await adapter.install({ ...options, withMcp: true })).kind).toBe("installed"); + expect(statSync(path).mode & 0o777).toBe(0o600); expect(json(path).mcpServers.other).toEqual(other); + }); it("preserves user-owned MCP settings even with force", async () => { mkdirSync(dir(), { recursive: true }); const mcp = { mcpServers: { other: { command: "other" }, agentmemory: { url: "https://custom.example/mcp" } } }; writeFileSync(join(dir(), "mcp.json"), JSON.stringify(mcp)); From 5b7c8b72302ab51e049283818715fb57fa36ae1d Mon Sep 17 00:00:00 2001 From: Rohit Ghumare Date: Sun, 25 Oct 2026 13:49:42 +0530 Subject: [PATCH 5/6] fix(pi): preserve both configuration backups --- src/cli/connect/native-install.ts | 2 +- test/connect-pi.test.ts | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/cli/connect/native-install.ts b/src/cli/connect/native-install.ts index 082ce2cebc..368752d2c2 100644 --- a/src/cli/connect/native-install.ts +++ b/src/cli/connect/native-install.ts @@ -103,7 +103,7 @@ export function installNativeBundles(bundles: NativeBundle[], configPath: string } } const configChanged = !existsSync(configPath) || readFileSync(configPath, "utf8") !== configText; - if (configChanged && existsSync(configPath)) backupPath = backupFile(configPath, "native-config", "config"); + if (configChanged && existsSync(configPath)) backupPath = backupFile(configPath, `native-config-${transaction}`, "config"); if (configChanged) { mkdirSync(dirname(configPath), { recursive: true }); writeFileSync(configStage, configText, { mode: existsSync(configPath) ? lstatSync(configPath).mode & 0o777 : 0o600 }); diff --git a/test/connect-pi.test.ts b/test/connect-pi.test.ts index 7908f6b949..d38ba7109b 100644 --- a/test/connect-pi.test.ts +++ b/test/connect-pi.test.ts @@ -61,6 +61,17 @@ describe("connect: pi", () => { const custom = json(path); custom.mcpServers.agentmemory.env.CUSTOM = "preserve"; writeFileSync(path, JSON.stringify(custom)); await adapter.install({ ...options, withMcp: true, force: true }); expect(json(path)).toEqual(custom); }); + it("keeps both original configs when backups share the same timestamp", async () => { + mkdirSync(dir(), { recursive: true }); + const settings = JSON.stringify({ theme: "light" }); + const mcp = JSON.stringify({ mcpServers: { other: { command: "other-server" } } }); + writeFileSync(join(dir(), "settings.json"), settings); writeFileSync(join(dir(), "mcp.json"), mcp); + vi.spyOn(Date.prototype, "toISOString").mockReturnValue("2026-10-25T00:00:00.000Z"); + const { adapter } = await import("../src/cli/connect/pi.js"); expect((await adapter.install({ ...options, withMcp: true })).kind).toBe("installed"); + const backups = join(home, ".agentmemory/backups"); + const originals = readdirSync(backups).filter(name => name.endsWith(".config")).map(name => readFileSync(join(backups, name), "utf8")); + expect(originals).toHaveLength(2); expect(originals).toContain(settings); expect(originals).toContain(mcp); + }); it.skipIf(process.platform === "win32")("preserves private permissions when adding MCP beside other credentials", async () => { mkdirSync(dir(), { recursive: true }); const path = join(dir(), "mcp.json"); const other = { url: "https://other.example", headers: { Authorization: "Bearer fixture-only" } }; From 50893a50241691f011bd39456cbace428230f101 Mon Sep 17 00:00:00 2001 From: Rohit Ghumare Date: Sun, 25 Oct 2026 13:54:48 +0530 Subject: [PATCH 6/6] fix(pi): address capture and test review findings --- README.md | 2 +- package.json | 1 + src/capture/client.ts | 2 +- test/omp-capture.test.ts | 5 +++-- test/pi-extension.test.ts | 7 +++++-- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 5267a391bd..e0e4235dbd 100644 --- a/README.md +++ b/README.md @@ -751,7 +751,7 @@ npx skills add rohitg00/agentmemory -y -a '*' # install to every installed age This is **complementary** to `agentmemory connect `: - `agentmemory connect ` normally writes the MCP server config. Hermes, OpenClaw, Pi and Oh My Pi install their native integration and bundled skills by default; MCP is opt-in with `--with-mcp`. -- `npx skills add rohitg00/agentmemory` installs the skills so the agent knows when to call them. +- `npx skills add rohitg00/agentmemory` installs skills for agents without native bundled skills. Skip this step for Hermes, OpenClaw, Pi and Oh My Pi; their native connectors already install the skills. For the few agents the skills CLI doesn't cover yet (Zed v1.3.x and below), drop the 17 SKILL.md files under the agent's native skill directory yourself; the same format works everywhere. diff --git a/package.json b/package.json index aac9efdc15..5766b3ef3b 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "dev": "tsx src/index.ts", "start": "node dist/cli.mjs", "migrate": "node dist/functions/migrate.js", + "pretest": "npm run build", "test": "vitest run --exclude test/integration.test.ts", "test:watch": "vitest --exclude test/integration.test.ts", "test:integration": "vitest run test/integration.test.ts", diff --git a/src/capture/client.ts b/src/capture/client.ts index 706d04ab9a..334a35b537 100644 --- a/src/capture/client.ts +++ b/src/capture/client.ts @@ -7,7 +7,7 @@ export function cleanCapture(value: unknown): unknown { } if (Array.isArray(value)) return value.map(cleanCapture); if (value && typeof value === "object") return scrubRecord(Object.fromEntries(Object.entries(value).map(([key, item]) => [key, - /(?:password|secret|token|credential|authorization|apikey)$/i.test(key.replace(/[_-]/g, "")) ? "[REDACTED_SECRET]" : cleanCapture(item), + /(?:password|passwd|secret|token|credential|authorization|apikey|secretkey|privatekey|accesskey)$/i.test(key.replace(/[_-]/g, "")) ? "[REDACTED_SECRET]" : cleanCapture(item), ])), { scrubKeys: true }); return value; } diff --git a/test/omp-capture.test.ts b/test/omp-capture.test.ts index e6160f81c7..fe1dadf127 100644 --- a/test/omp-capture.test.ts +++ b/test/omp-capture.test.ts @@ -49,9 +49,10 @@ describe("OMP capture recovery", () => { expect(capture.status().records).toBe(0); }); it("redacts private blocks and structured secrets before serialization, including JSON tool output", () => { - const raw = { password: "short", nested: { api_key: "private-key", content: "hello personal" } }; + const keys = ["secret_key", "private_key", "accessKey", "aws_secret_access_key", "passwd", "secret-key"]; + const raw = { password: "short", nested: { api_key: "private-key", content: "hello personal", credentials: [Object.fromEntries(keys.map(key => [key, "opaque-value"]))] } }; const cleaned = JSON.stringify(cleanCapture({ input: raw, output: JSON.stringify(raw) })); - for (const value of ["short", "private-key", "personal"]) expect(cleaned).not.toContain(value); + for (const value of ["short", "private-key", "personal", "opaque-value"]) expect(cleaned).not.toContain(value); expect(cleaned).toContain("hello"); expect(cleaned).toContain("REDACTED"); }); }); diff --git a/test/pi-extension.test.ts b/test/pi-extension.test.ts index da81c59ea9..51b1f99222 100644 --- a/test/pi-extension.test.ts +++ b/test/pi-extension.test.ts @@ -113,11 +113,14 @@ describe("Pi extension", () => { }); it("bounds stalled shutdown and disables redirects on every request", async () => { const { handlers, ctx } = extension(); await handlers.get("session_start")!({}, ctx); + const seen: (RequestInit | undefined)[] = []; vi.mocked(fetch).mockImplementation((_url, options) => new Promise((_resolve, reject) => { - expect(options?.redirect).toBe("error"); expect(options?.signal).toBeDefined(); - options!.signal!.addEventListener("abort", () => reject(options!.signal!.reason)); + seen.push(options); + options?.signal?.addEventListener("abort", () => reject(options.signal!.reason)); })); const start = Date.now(); await handlers.get("session_shutdown")!({ reason: "quit" }); expect(Date.now() - start).toBeLessThan(1900); + expect(seen.length).toBeGreaterThan(0); + for (const options of seen) { expect(options?.redirect).toBe("error"); expect(options?.signal).toBeDefined(); } }); it("uses stored credentials only on loopback unless explicit-only mode is set", () => { mkdirSync(join(home, ".agentmemory")); writeFileSync(join(home, ".agentmemory/secret"), "local-fixture");