pi-memoria 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AGENTS.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Working on pi-memoria
2
2
 
3
3
  This is a TypeScript Pi extension with five tools and **one global memory store**.
4
- README.md documents the product; this file documents how to change and release the repository.
4
+ README.md documents the product; this file documents how to change this package. Read the [monorepo instructions](https://github.com/rcsaquino/pi-extensions/blob/main/AGENTS.md) and [release process](https://github.com/rcsaquino/pi-extensions/blob/main/RELEASING.md) for shared tooling and authorized publication.
5
5
 
6
6
  ## North star
7
7
 
@@ -13,7 +13,9 @@ README.md documents the product; this file documents how to change and release t
13
13
 
14
14
  ## Commands
15
15
 
16
- - `npm ci --ignore-scripts`: install the locked development dependencies.
16
+ From this package directory; from the monorepo root, use `npm --prefix packages/pi-memoria` before the same operation.
17
+
18
+ - `npm install --ignore-scripts --legacy-peer-deps --workspaces=false`: install package-local development dependencies. No lockfile is currently committed; use `npm ci` only after a usable lock is deliberately supplied.
17
19
  - `npm run check`: strict TypeScript checking.
18
20
  - `npm test`: storage, concurrency, retrieval, and Pi integration tests; uses temporary directories.
19
21
  - `npm run verify`: typecheck and tests.
@@ -51,59 +53,22 @@ README.md documents the product; this file documents how to change and release t
51
53
 
52
54
  ## Development conventions
53
55
 
54
- Use explicit `.ts` imports, strict types, Node built-ins, and small modules. Pi loads TypeScript directly; there is no build step. Keep the peer dependency ranges required by Pi packaging; pin the tested Pi version in devDependencies. Update package-lock.json through npm when dependencies change.
56
+ Use explicit `.ts` imports, strict types, Node built-ins, and small modules. Pi loads TypeScript directly; there is no build step. Keep the peer dependency ranges required by Pi packaging; pin the tested Pi version in devDependencies. If maintaining a lockfile, update it through npm when dependencies change; never edit it manually or introduce root dependency hoisting as an unrelated fix.
55
57
 
56
- Read the installed Pi documentation and relevant examples before changing integration code. The reference installation for this workspace is `/home/rcsaquino/.npm-global/lib/node_modules/@earendil-works/pi-coding-agent/`; resolve `docs/...` and `examples/...` there, not here. Read referenced Markdown files completely. Check exported declarations for exact API signatures.
58
+ Read the installed Pi documentation and relevant examples before changing integration code. Locate the host with `npm root -g`, then its `@earendil-works/pi-coding-agent` package (or the configured `PI_HOST_PACKAGE_DIR` for development tooling); resolve `docs/...` and `examples/...` there, not here. Read referenced Markdown files completely. Check exported declarations for exact API signatures.
57
59
 
58
60
  Add meaningful regression tests for cap boundaries, races, durable retrieval, pagination, and error paths when changing them. Run `npm run verify` before delivery. Benchmark claims must state corpus size and distinguish indexed SQLite lookups from linear session scans.
59
61
 
60
62
  ## Releasing
61
63
 
62
- Start a release only when the user decides to bump the version. Tags, GitHub releases, and npm versions are public and are not cleanly removable.
63
-
64
- 1. Bump `version` in `package.json`, then run `npm run verify`. A version-only bump does not change dependencies, so `package-lock.json` needs no update.
65
- 2. Commit as `Release X.Y.Z` and push `main`.
66
- 3. Create an annotated tag `vX.Y.Z` with the message `pi-memoria X.Y.Z` (the convention for `v0.2.0` and later) and push it with the commit:
67
-
68
- ```sh
69
- git tag -a vX.Y.Z -m "pi-memoria X.Y.Z"
70
- git push origin main vX.Y.Z
71
- ```
72
-
73
- 4. Create the GitHub release after the tag exists. Publishing the release triggers
74
- `.github/workflows/npm-publish.yml`, which checks the tag against `package.json`, runs
75
- `npm run verify`, and publishes to npm. `gh` is installed and authenticated as
76
- `rcsaquino`:
77
-
78
- ```sh
79
- gh release create vX.Y.Z --title "pi-memoria X.Y.Z" --notes-file - <<'EOF'
80
- ...
81
- EOF
82
- ```
83
-
84
- Keep notes factual: what changed, requirements, and limits. Do not restate the README.
85
-
86
- 5. Watch the workflow and confirm the registry:
87
-
88
- ```sh
89
- gh run list --workflow npm-publish.yml --limit 4
90
- npm view pi-memoria version dist-tags
91
- ```
92
-
93
- - The workflow authenticates with npm trusted publishing (OIDC). The trusted publisher
94
- on npmjs.com must name the repository `rcsaquino/pi-memoria` and the workflow file
95
- `npm-publish.yml`. The package's publishing access disallows traditional tokens,
96
- so OIDC is the only automated publish path.
97
- - The `files` field in `package.json` controls the tarball; inspect it with
98
- `npm pack --dry-run` first.
99
- - The registry can accept the tarball (`HTTP 202`, "being processed") and take a few
100
- minutes to expose it. Confirm with `npm view` before reporting success.
101
- - Fallback only if the workflow is unavailable: `npm publish` locally. Writes require
102
- 2FA, so it starts the npmjs web-auth flow and needs a real terminal or pseudo-TTY to
103
- open the browser; without one it fails with `EOTP`. An automation token with 2FA
104
- bypass also works.
105
-
106
- Only push tags, create releases, or publish to npm for a user-requested version bump.
64
+ Follow the [monorepo release process](https://github.com/rcsaquino/pi-extensions/blob/main/RELEASING.md) only after explicit approval. Version 0.3.2 is the patch after the public 0.3.1 release; it is not published by editing this file.
65
+
66
+ - Verify this package and the root suite, inspect `npm pack --dry-run --ignore-scripts --workspaces=false`, and check the chosen version is not already on npm.
67
+ - Use package-specific tags such as `pi-memoria-v0.3.2`, not a shared root `v0.3.2` tag. Commit, push, tag, release creation, and npm publication remain separately authorized actions; pushing a `pi-memoria-v<version>` tag is the publication authorization for the workflow.
68
+ - `.github/workflows/publish-pi-memoria.yml` publishes this package on a `pi-memoria-v<version>` tag after the full suite verifies, using npm trusted publishing (OIDC) with automatic provenance. Creating a GitHub release does not itself publish npm packages.
69
+ - The old trusted-publisher configuration targeting the standalone `rcsaquino/pi-memoria` repository does not apply. The npm trusted publisher must target `rcsaquino/pi-extensions` with workflow filename `publish-pi-memoria.yml` and allow `npm publish`; verify it on npm before the first tagged release and never claim it is configured until then.
70
+ - Manual publication needs the account's current npm authorization and any required interactive 2FA. A dry run cannot verify those permissions. Never include credentials in commands, documentation, logs, or model context.
71
+ - Confirm the exact published version and dist-tag from the public registry before reporting success. Keep release notes factual and specific to this package.
107
72
 
108
73
  ## Files and data to protect
109
74
 
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2026 Rey Christian
3
+ Copyright (c) 2026 rcsaquino
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -5,7 +5,6 @@
5
5
 
6
6
  **Global memory for [Pi](https://github.com/earendil-works/pi): startup rules in `MEMORY.md`, durable facts in SQLite FTS5, and cited search across every past conversation.**
7
7
 
8
- [![GitHub release](https://img.shields.io/github/v/release/rcsaquino/pi-memoria?style=flat-square)](https://github.com/rcsaquino/pi-memoria/releases)
9
8
  [![Node.js >= 22.19](https://img.shields.io/badge/Node.js-%3E%3D22.19-3c873a?style=flat-square&logo=nodedotjs&logoColor=white)](https://nodejs.org)
10
9
  [![TypeScript](https://img.shields.io/badge/TypeScript-3178c6?style=flat-square&logo=typescript&logoColor=white)](https://www.typescriptlang.org)
11
10
  [![MIT license](https://img.shields.io/badge/license-MIT-yellow?style=flat-square)](LICENSE)
@@ -18,8 +17,8 @@ pi-memoria gives Pi one memory shared across every project: instructions that mu
18
17
 
19
18
  ## Requirements
20
19
 
21
- - **Node.js 22.19+** (uses `node:sqlite`; tested on 22.19 and 24.20).
22
- - **Pi** with the current extension API (tested with 0.87.1), Node-based. Standalone/Bun builds are not validated with `node:sqlite`.
20
+ - **Node.js 22.19+** (uses `node:sqlite`; earlier baselines 22.19/24.20, maintained suite 26.10.0).
21
+ - A Node-based **Pi** host. The pinned development baseline is 1.0.0, the maintained Pi host. Standalone/Bun builds are not validated with `node:sqlite`.
23
22
  - **ripgrep (`rg`) on PATH** for session search.
24
23
 
25
24
  ## Installation
@@ -28,20 +27,24 @@ pi-memoria gives Pi one memory shared across every project: instructions that mu
28
27
  pi install npm:pi-memoria
29
28
  ```
30
29
 
31
- Restart Pi or run `/reload`. To uninstall, run `pi remove npm:pi-memoria`; stored memory remains until you delete its directory.
30
+ This installs the current public npm release. This checkout contains version **0.3.2**, the patch after the public 0.3.1 release.
31
+
32
+ Activate with `/reload` in an idle session when intended, or a separately approved restart. To uninstall, run `pi remove npm:pi-memoria`; stored memory remains until you delete its directory.
32
33
 
33
34
  <details>
34
35
  <summary><strong>Install from a local checkout</strong></summary>
35
36
 
37
+ From the monorepo root:
38
+
36
39
  ```sh
37
- npm ci --ignore-scripts
38
- pi install /absolute/path/to/pi-memoria
40
+ npm --prefix packages/pi-memoria install --ignore-scripts --legacy-peer-deps --workspaces=false
41
+ pi install /absolute/path/to/pi-extensions/packages/pi-memoria
39
42
  ```
40
43
 
41
44
  Keep the checkout in place: a local install references it directly. To try it without installing:
42
45
 
43
46
  ```sh
44
- pi -e /absolute/path/to/pi-memoria/index.ts
47
+ pi -e /absolute/path/to/pi-extensions/packages/pi-memoria/index.ts
45
48
  ```
46
49
 
47
50
  </details>
@@ -168,12 +171,17 @@ The default session root is `<agent-dir>/sessions`; roots Pi uses are remembered
168
171
 
169
172
  ## Development
170
173
 
174
+ From the monorepo root:
175
+
171
176
  ```sh
172
- npm ci --ignore-scripts
173
- npm run verify
174
- npm run bench
177
+ npm --prefix packages/pi-memoria install --ignore-scripts --legacy-peer-deps --workspaces=false
178
+ npm run link-host
179
+ npm --prefix packages/pi-memoria run verify
180
+ npm --prefix packages/pi-memoria run bench
175
181
  ```
176
182
 
183
+ No package lockfile is currently committed, so `npm ci` is not a fresh-checkout setup command. The shared host-link helper preserves working dependencies and only repairs missing/broken links.
184
+
177
185
  There is no build step: Pi loads `index.ts` directly. `src/database.ts`, `src/hot-memory.ts`, and `src/sessions.ts` own the storage layers; `index.ts` wires them to lifecycle events and the tool schemas. Tests use temporary directories, real SQLite FTS5, real `rg`, concurrent writers, and Pi's extension loader. See [AGENTS.md](AGENTS.md) for architecture and contribution rules.
178
186
 
179
187
  ## Support and contact
package/index.ts CHANGED
@@ -15,7 +15,7 @@ import { chunk, HOT_LIMIT, MEMORY_LIMIT } from "./src/text.ts";
15
15
  const SAVE_GUIDANCE = "Before saving a durable fact, search SQLite with memoria_search using topic keywords and aliases, and inspect relevant matches. If the same fact is already stored, do not add it again; use memoria_edit with its ID only when information changes or useful detail is missing. Different wording can express the same fact. For hot memory, check the injected MEMORY.md before adding a bullet.";
16
16
 
17
17
  export const MEMORY_GUIDANCE = `You have global, persistent memory shared across all projects.
18
- - MEMORY.md below is working memory, available before every user prompt. Store only requirements needed without a retrieval cue, e.g. "Start every sentence with beep_boop." Topic-triggered facts such as liking apples belong in SQLite, tagged with useful retrieval cues such as fruit and preferences.
18
+ - The hot_memory block contains standing instructions from MEMORY.md, available before every user prompt, not merely quoted reference material. Follow them subject to higher-priority instructions and the conflict guidance below. Store only requirements needed without a retrieval cue, e.g. "Start every sentence with beep_boop." Topic-triggered facts such as liking apples belong in SQLite, tagged with useful retrieval cues such as fruit and preferences.
19
19
  - Proactively save durable user instructions, preferences, and decisions with memoria_add; update corrections with memoria_edit and remove obsolete facts with memoria_delete. Do not save guesses as facts or secrets unless explicitly requested. Use the memory tools for writes, not direct file/database edits.
20
20
  - ${SAVE_GUIDANCE}
21
21
  - For hot writes use store="hot", content, and optional priority. Hot content must be one line and internal spacing is preserved. Tags and source are SQLite metadata; omit them for hot memory.
@@ -116,21 +116,23 @@ export default function memoria(pi: ExtensionAPI) {
116
116
  });
117
117
 
118
118
  pi.on("before_agent_start", async (event, ctx) => {
119
- let text = MEMORY_GUIDANCE;
119
+ let text = `<instructions>\n${MEMORY_GUIDANCE}\n</instructions>`;
120
+ const status: string[] = [];
120
121
  const current = stores(ctx);
121
122
  try {
122
123
  const snapshot = await current.hot.load();
123
- text += `\n\nGlobal MEMORY.md (${snapshot.characters}/${HOT_LIMIT} characters; ${current.config.hotPath}):\n${snapshot.text || "(empty)"}`;
124
+ text += `\n\n<hot_memory>\nGlobal MEMORY.md (${snapshot.characters}/${HOT_LIMIT} characters; ${current.config.hotPath}):\n${snapshot.text || "(empty)"}\n</hot_memory>`;
124
125
  for (const repaired of [startupRepair, snapshot]) {
125
- if (repaired?.archived.length) text += `\nRepaired an oversized manual edit: ${repaired.archived.length} bullets archived to SQLite; original backup: ${repaired.backup}.`;
126
+ if (repaired?.archived.length) status.push(`Repaired an oversized manual edit: ${repaired.archived.length} bullets archived to SQLite; original backup: ${repaired.backup}.`);
126
127
  }
127
128
  startupRepair = undefined;
128
129
  } catch (error) {
129
- text += `\n\nMEMORY UNAVAILABLE: ${(error as Error).message}. Hot instructions were not loaded; tell the user and do not assume that memory is empty.`;
130
+ status.push(`MEMORY UNAVAILABLE: ${(error as Error).message}. Hot instructions were not loaded; tell the user and do not assume that memory is empty.`);
130
131
  }
131
132
  if (!current.database && current.databaseError !== undefined) {
132
- text += `\n\nSQLITE LONG-TERM MEMORY UNAVAILABLE: ${(current.databaseError as Error).message}. Hot memory above remains valid; SQLite add/edit/delete/search and archive operations fail until the store is fixed. Session search uses default, configured, and current roots only, so remembered custom roots may be missing.`;
133
+ status.push(`SQLITE LONG-TERM MEMORY UNAVAILABLE: ${(current.databaseError as Error).message}. Any successfully loaded hot memory remains valid; SQLite add/edit/delete/search and archive operations fail until the store is fixed. Session search uses default, configured, and current roots only, so remembered custom roots may be missing.`);
133
134
  }
135
+ if (status.length) text += `\n\n<status>\n${status.join("\n")}\n</status>`;
134
136
  event.systemPromptOptions.sections.pi_memoria = text;
135
137
  // Respect earlier extensions that supply an opaque, complete system prompt.
136
138
  if (event.systemPromptOptions.forceSystemPrompt !== undefined) {
package/package.json CHANGED
@@ -1,10 +1,13 @@
1
1
  {
2
2
  "name": "pi-memoria",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Global working memory, SQLite FTS5 recall, and complete Pi session search",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
- "repository": { "type": "git", "url": "git+https://github.com/rcsaquino/pi-memoria.git" },
7
+ "repository": { "type": "git", "url": "git+https://github.com/rcsaquino/pi-extensions.git", "directory": "packages/pi-memoria" },
8
+ "homepage": "https://github.com/rcsaquino/pi-extensions/tree/main/packages/pi-memoria#readme",
9
+ "bugs": { "url": "https://github.com/rcsaquino/pi-extensions/issues" },
10
+ "publishConfig": { "access": "public" },
8
11
  "keywords": ["pi-package", "pi-extension", "memory", "sqlite", "fts5"],
9
12
  "files": ["index.ts", "src", "README.md", "AGENTS.md", "LICENSE"],
10
13
  "pi": { "extensions": ["./index.ts"] },
@@ -21,7 +24,7 @@
21
24
  "typebox": "*"
22
25
  },
23
26
  "devDependencies": {
24
- "@earendil-works/pi-coding-agent": "0.87.1",
27
+ "@earendil-works/pi-coding-agent": "1.0.0",
25
28
  "@types/node": "^22.19.0",
26
29
  "@types/proper-lockfile": "^4.1.4",
27
30
  "tsx": "^4.20.0",