@aeondave/pi-persona-mind 0.0.0-stage → 0.8.5
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 +79 -0
- package/CHANGELOG.md +84 -0
- package/LICENSE +24 -0
- package/README.md +240 -2
- package/assets/banner.png +0 -0
- package/docs/DESIGN.md +284 -0
- package/docs/MEMORY-RESEARCH.md +112 -0
- package/package.json +93 -4
- package/src/core/auto-optimize.ts +239 -0
- package/src/core/backlog.ts +228 -0
- package/src/core/blocked.ts +38 -0
- package/src/core/capture.ts +146 -0
- package/src/core/context-budget.ts +74 -0
- package/src/core/host-compat.ts +13 -0
- package/src/core/ids.ts +59 -0
- package/src/core/inject.ts +247 -0
- package/src/core/memory-read.ts +34 -0
- package/src/core/memory.ts +308 -0
- package/src/core/migrate.ts +713 -0
- package/src/core/mind-settings.ts +54 -0
- package/src/core/optimize-history.ts +101 -0
- package/src/core/optimize-service.ts +182 -0
- package/src/core/optimize.ts +133 -0
- package/src/core/retrieval.ts +108 -0
- package/src/core/scanner.ts +146 -0
- package/src/core/scope.ts +205 -0
- package/src/core/service.ts +644 -0
- package/src/core/session-memory.ts +71 -0
- package/src/core/store.ts +948 -0
- package/src/extension/activity.ts +79 -0
- package/src/extension/auto-optimize-session.ts +120 -0
- package/src/extension/auto-optimize.ts +298 -0
- package/src/extension/mind-command.ts +357 -0
- package/src/extension/mind-worker.ts +32 -0
- package/src/extension/persona-dependency.ts +76 -0
- package/src/index.ts +1231 -0
- package/src/session-memory.ts +118 -0
- package/src/tools/backlog.ts +126 -0
- package/src/tools/memory-optimize.ts +133 -0
- package/src/tools/memory.ts +400 -0
- package/src/ui/mind-result-card.ts +15 -0
- package/src/ui/presentation.ts +97 -0
- package/src/ui/session-note-card.ts +50 -0
package/AGENTS.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# AGENTS.md — pi-persona-mind
|
|
2
|
+
|
|
3
|
+
An extension requiring a compatible loaded pi-persona: durable persona-aware memory + backlog,
|
|
4
|
+
coupled through a versioned local companion handshake to
|
|
5
|
+
[`pi-persona`](https://github.com/AeonDave/pi-persona). Binding design: [`docs/DESIGN.md`](docs/DESIGN.md).
|
|
6
|
+
|
|
7
|
+
## Commands
|
|
8
|
+
|
|
9
|
+
- Typecheck: `npm run typecheck` (`tsc --noEmit`, strict + `exactOptionalPropertyTypes`)
|
|
10
|
+
- Tests: `npm test` · both: `npm run verify`
|
|
11
|
+
- Hermetic choke point: `node --import tsx --import ./test/setup/hermetic-env.ts --test test/*.test.ts`
|
|
12
|
+
- Installed Pi 1.4 qualification: `node --import tsx scripts/qualify-host.mjs <absolute-pi-package-root> <absolute-pi-persona-extension-path> [<absolute-packed-mind-extension-path>]`
|
|
13
|
+
(isolated profile, offline synthetic provider; no cloud authentication/model-quality claim).
|
|
14
|
+
|
|
15
|
+
## Conventions
|
|
16
|
+
|
|
17
|
+
- Erasable-syntax-only TS. `src/core/*` is pure (no Pi imports) and unit-tested.
|
|
18
|
+
- Target the latest stable Pi only (currently 1.4.0), Node 22.19.0+. Keep host packages and
|
|
19
|
+
typebox as optional peers on `*`, with all four Pi development packages pinned together.
|
|
20
|
+
No historical-host branches; never bundle a second host runtime. Scope development security
|
|
21
|
+
overrides to their affected parent/version and remove them when that graph no longer needs them.
|
|
22
|
+
- Tests clear `PI_PERSONA_*` case-insensitively and pin `PI_AGENT_DIR` to a throwaway directory.
|
|
23
|
+
Keep the hermetic import on every direct test invocation. Real SDK tests use an offline provider.
|
|
24
|
+
- Require the loaded companion protocol at session activation and tool call time; missing or
|
|
25
|
+
incompatible Persona means no capture, storage/migration, injection or scheduler activity.
|
|
26
|
+
Settings files alone do not prove presence. Resolve the actual active persona through the
|
|
27
|
+
session-bound `pi-persona:memory-owner:v1` runtime contract; never reconstruct it from CLI or saved
|
|
28
|
+
selection. Before that owner is ready, do no memory IO. Delegated engines freeze the parent's
|
|
29
|
+
persona for their lifetime. Canonical `<agentDir>/persona/settings.json` supplies only Mind's
|
|
30
|
+
`mindCapture`/`mindNudge` session preference snapshots. Do not interpret retired state markers.
|
|
31
|
+
Contribute effective Mind settings
|
|
32
|
+
only from a supervisor via the shared settings event bus. Mirror `PI_PERSONA_LEG` /
|
|
33
|
+
`PI_PERSONA_CHILD`, and `pi-persona-deferred-input` by env/customType only.
|
|
34
|
+
- Model configuration changes are not persona switches;
|
|
35
|
+
`/persona models` must leave Mind's scope unchanged. Do not duplicate persona discovery here.
|
|
36
|
+
- Wakes are display-only (`appendEntry` + toast). Never `sendUserMessage` / `triggerTurn`.
|
|
37
|
+
- Lifecycle generations bound capture/injection UI state to the accepting session. An accepted
|
|
38
|
+
explicit capture may finish in its original store; its acknowledgement must not leak to a new turn.
|
|
39
|
+
- Nested tool results reach only their caller. Nudge on a blocked report only when the top-level
|
|
40
|
+
result actually relays it; bound provenance by `parentToolCallId` and clear it on lifecycle change.
|
|
41
|
+
- Persona/shared and repository LTM are durable across sessions. `scope: project` with long term
|
|
42
|
+
stays in the repository; promotion defaults there and requires an owned source. `project-long`
|
|
43
|
+
is the optimizer target; `project` still means working STM. Shared writes use `scope: shared`,
|
|
44
|
+
not a boolean. Existing persona facts are not automatically reassigned. STM/backlog auto-delete after ~48h. Explicit session notes live
|
|
45
|
+
in Pi's native active branch, survive compaction/resume, and stay absent from delegated workers.
|
|
46
|
+
A non-persistent host session reports in-memory storage; forget is a branch-local tombstone.
|
|
47
|
+
- `/mind optimize [project|project-long|persona]` starts one bounded real Persona-hosted LLM review NOW, bypassing automatic dirty/token/cooldown and auto-off gates but not owner, busy, validation or CAS safeguards. It uses the existing worker/prompt/strict JSON/provenance/preview/apply/receipt pipeline, exact current model only, no fallback/tools, and reports bounded coverage/no-op honestly. Shared is refused with a pointer to `/mind optimize inspect shared`; it is excluded from all LLM automatic and explicit writes. `/mind optimize inspect [target]` stays read-only. Do not publish a separate persistent activity row for full optimization; let Persona's normal worker row terminate. Interrupted/stale explicit runs never apply, report across owner change, or arm an automatic retry.
|
|
48
|
+
- Optimization inspect/stage exact replacements/apply a short-lived plan ID remains available through explicit inspect/show/apply commands and the memory tool. Similarity
|
|
49
|
+
is advisory. Compare the original raw store fingerprint under its lock; reject stale/expired
|
|
50
|
+
plans, invalid stores, ownership mixing, provenance overflow and extended STM expiry.
|
|
51
|
+
Lifecycle changes invalidate plans. Automatic semantic review is user-authorized and on by default
|
|
52
|
+
unless `PI_PERSONA_MIND_OPTIMIZE=off`; session commands may switch it immediately. Queue after a
|
|
53
|
+
successful remember/promotion. First eligible burst has no token floor; later attempts need dirty
|
|
54
|
+
memories AND 1M main-session input tokens since the prior launch (exclude output/cache/worker usage).
|
|
55
|
+
Usage alone never marks memories dirty. Coalesce 2s after `agent_settled` while idle with no queued
|
|
56
|
+
work; cool down 5min between actual attempts. Only the interrupted attempt can retry without the
|
|
57
|
+
token floor, after a later settled event and cooldown. One worker per instance; unchanged semantic
|
|
58
|
+
digests skip review. New input, agent start,
|
|
59
|
+
off or owner changes cancel and invalidate plans. Use a real visible
|
|
60
|
+
Persona-hosted Mind worker on exactly the session model, no fallback or arbitrary tools. Give it
|
|
61
|
+
at most 12 full source records/24k JSON characters, a 180s deadline and at most 4 strict JSON
|
|
62
|
+
replacement operations/12 source IDs each, then validate/apply through parent-owned
|
|
63
|
+
provenance/freshness/CAS checks. Shared memories and age-based deletion remain excluded. Preserve
|
|
64
|
+
durable before/after operator cards; worker completion is not proof of semantic truth.
|
|
65
|
+
- Rotate completed automatic review over older records/pages; account for actual byte admission,
|
|
66
|
+
preserve newest-fact inclusion, and never mark stopped/interrupted work as completed. No unbounded
|
|
67
|
+
sweeper. Optimizer receipts precede replacement and persist at most 32/2MiB per target; unresolved
|
|
68
|
+
prepared receipts are protected. Undo compares affected facts and owner generation under lock,
|
|
69
|
+
never restores expired STM or clobbers unrelated writes. Propagate uncertain-finalization warnings.
|
|
70
|
+
- Retrieval uses one lexical/tag/path ranker; do not introduce a second recall policy. All injected
|
|
71
|
+
tiers share a 2400-token planning estimate (UTF-8 bytes/3); session notes use up to 600. Include
|
|
72
|
+
wrappers, separators and omission counts, keep whole excerpts, and never exempt pinned facts from
|
|
73
|
+
the bound. The estimate and synthetic evaluation are not billing or semantic-quality guarantees.
|
|
74
|
+
- `exactOptionalPropertyTypes`: omit optional props; do not assign `undefined`.
|
|
75
|
+
|
|
76
|
+
## Done
|
|
77
|
+
|
|
78
|
+
`npm run typecheck` clean, `npm test` green, full `npm audit --audit-level=low`, and package dry-run
|
|
79
|
+
inspection. Re-run after final edits. Keep published files explicit; no tests, drafts or local artifacts.
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.8.5](https://github.com/AeonDave/pi-persona-mind/releases/tag/v0.8.5) - 2026-10-26
|
|
4
|
+
|
|
5
|
+
- Add `/mind optimize [project|project-long|persona]` for an immediate, bounded review by a visible Persona-hosted worker using the current session model. Changes pass Mind's validation, provenance and compare-and-swap checks; successful writes retain receipts and support guarded undo.
|
|
6
|
+
- Remove the worker row on completion while retaining results in the conversation. Keep reviews bounded, rotate completed windows, and handle busy sessions, cancellation, stale owners and errors safely.
|
|
7
|
+
- **Usage change:** use `/mind optimize inspect [target]` to inspect; `/mind optimize [target]` now starts a review instead.
|
|
8
|
+
|
|
9
|
+
## [0.8.4](https://github.com/AeonDave/pi-persona-mind/releases/tag/v0.8.4) - 2026-10-25
|
|
10
|
+
|
|
11
|
+
- Add durable project memory and scope-preserving promotion; expose project/persona/shared scope
|
|
12
|
+
consistently in tools, snapshots and diagnostics. Replace the shared-write boolean with scope.
|
|
13
|
+
- Rank injected context and recall by task words, tags and repository paths; apply a combined
|
|
14
|
+
token estimate across archive and session context, retaining explicit omissions and full reads.
|
|
15
|
+
- Rotate bounded automatic reviews over older records and retain durable consolidation receipts.
|
|
16
|
+
Add history and guarded undo that preserves unrelated writes and refuses stale affected facts.
|
|
17
|
+
- Add deterministic retrieval evaluation with an explicit baseline and no semantic-quality claim.
|
|
18
|
+
|
|
19
|
+
- Add automatic semantic consolidation through a visible asynchronous Mind worker on the current
|
|
20
|
+
session model. The first new-memory burst queues an idle review; subsequent attempts require new
|
|
21
|
+
memories and 1M main-session input tokens, excluding output/cache/worker usage. Rapid saves coalesce;
|
|
22
|
+
new input cancels the worker. Parent validation and fingerprint checks protect application; shared
|
|
23
|
+
memory is excluded.
|
|
24
|
+
`/mind optimize auto [status|on|off]` controls this session, doctor reports its state, and
|
|
25
|
+
`PI_PERSONA_MIND_OPTIMIZE=off` changes the initial default.
|
|
26
|
+
- Require the loaded pi-persona companion protocol; without it Mind remains inactive, including
|
|
27
|
+
direct programmatic calls. Local optimization appears as a Mind activity row in Persona's tree/F9.
|
|
28
|
+
- Use the actual live persona for memory ownership even with selection persistence disabled;
|
|
29
|
+
delegated workers keep their launching persona on both engines. Remove the obsolete selection mirror.
|
|
30
|
+
- Target Pi 1.4.0 exclusively; align development packages and native event contracts, and remove
|
|
31
|
+
the retired companion state-marker fallback. Existing memory-data imports remain available.
|
|
32
|
+
- Add active-branch session notes, honest persistent/in-memory receipts, and full ID-based memory
|
|
33
|
+
reads. Session notes preserve their origin across forks and never enter delegated worker context.
|
|
34
|
+
- Add explicit, bounded memory consolidation: inspect candidates, stage exact replacements, then
|
|
35
|
+
apply a fingerprint-checked plan. Preserve source lineage and STM expiry; refuse stale plans.
|
|
36
|
+
- Paginate inspection to reach older facts, and distinguish slow background imports from persistent
|
|
37
|
+
failures instead of leaving a successful import marked with a warning.
|
|
38
|
+
- Add `/persona-mind` with `/mind` as the same-handler alias, strict command parsing, session and
|
|
39
|
+
optimization commands, and consistent expandable command cards.
|
|
40
|
+
- Include inline flow reports in the blocked-work hint and preserve concurrent backlog additions
|
|
41
|
+
during expiry cleanup. Qualify package and companion integration on the current host.
|
|
42
|
+
|
|
43
|
+
## [0.8.3](https://github.com/AeonDave/pi-persona-mind/releases/tag/v0.8.3) - 2026-10-20
|
|
44
|
+
|
|
45
|
+
- Read persona selection and startup `defaultPersona`/`persist` preferences from pi-persona's
|
|
46
|
+
canonical settings store, preserving legacy marker fallback only when canonical settings are absent.
|
|
47
|
+
- Contribute Mind's capture/nudge settings to pi-persona's unified settings panel, while retaining
|
|
48
|
+
environment overrides and session-start snapshot behavior.
|
|
49
|
+
- Scope marker latches and Mind-specific preference snapshots to Pi session IDs so child sessions
|
|
50
|
+
cannot reset their supervisor's active scope or companion controls.
|
|
51
|
+
- Match pi-persona's extension-factory snapshot for the scalar persona selectors, keeping Mind's
|
|
52
|
+
memory scope aligned across `/new` sessions until Pi reloads/restarts extensions.
|
|
53
|
+
- Reject malformed UTF-8 in canonical and legacy persona markers rather than deriving a replacement-character memory scope.
|
|
54
|
+
|
|
55
|
+
## [0.8.2](https://github.com/AeonDave/pi-persona-mind/releases/tag/v0.8.2) - 2026-10-19
|
|
56
|
+
|
|
57
|
+
- Respect Pi's `--` CLI separator when resolving persona memory scope; prompt text resembling
|
|
58
|
+
`--persona` no longer selects a different memory store.
|
|
59
|
+
- Add isolated installed-Pi 1.3 qualification alongside the minimum-Pi 1.0 SDK suite, including
|
|
60
|
+
optional pi-persona integration for model refresh and delegated read-only memory.
|
|
61
|
+
|
|
62
|
+
## [0.8.1](https://github.com/AeonDave/pi-persona-mind/releases/tag/v0.8.1) - 2026-10-13
|
|
63
|
+
|
|
64
|
+
- Handle Pi 1.2 custom-triggered completion reports from their attributed `before_agent_start`
|
|
65
|
+
message event, deduplicate follow-up nudges, and keep custom report text out of direct-user capture.
|
|
66
|
+
|
|
67
|
+
## [0.8.0](https://github.com/AeonDave/pi-persona-mind/releases/tag/v0.8.0) - 2026-10-03
|
|
68
|
+
|
|
69
|
+
- Require Pi 1.0.0+ and Node.js 22.19.0+; keep host libraries and typebox as host-provided peers.
|
|
70
|
+
- Reset capture hints and empty-store announcements when a session changes; prevent late capture
|
|
71
|
+
notices and memory injection from leaking into the next session.
|
|
72
|
+
- Skip migration/storage waits for ordinary input with no capture cue.
|
|
73
|
+
- Preserve undelivered backlog alarms across slow storage reads and concurrent re-arm calls; a
|
|
74
|
+
newly queued reminder that is already due is shown immediately, without restarting Pi.
|
|
75
|
+
- Deduplicate a reminder's displayed deadline while acknowledgement persists, including re-arms
|
|
76
|
+
triggered by background migration; a later deadline remains eligible.
|
|
77
|
+
- Suggest backlog capture only for blocked nested output actually relayed by its outer tool.
|
|
78
|
+
- Enforce erasable-only TypeScript, including store/service constructors.
|
|
79
|
+
- Isolate test profiles; exercise capture, persistence, tool execution, display-only reminders and
|
|
80
|
+
read-only workers in real Pi 1.0 SDK sessions with an offline provider.
|
|
81
|
+
- Align package/lock metadata, upgrade development dependencies and pin three-platform CI actions.
|
|
82
|
+
|
|
83
|
+
Older storage roots remain readable through non-destructive migration. No existing store is deleted
|
|
84
|
+
or moved by the host compatibility update.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AeonDave
|
|
4
|
+
|
|
5
|
+
Portions of src/core/store.ts adapt the durable atomic-store pattern from
|
|
6
|
+
OpenLore (clay-good/openlore), also MIT-licensed.
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
10
|
+
in the Software without restriction, including without limitation the rights
|
|
11
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
12
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
13
|
+
furnished to do so, subject to the following conditions:
|
|
14
|
+
|
|
15
|
+
The above copyright notice and this permission notice shall be included in all
|
|
16
|
+
copies or substantial portions of the Software.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,241 @@
|
|
|
1
|
-
|
|
1
|
+
<h1 align="center">pi-persona-mind</h1>
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="https://raw.githubusercontent.com/AeonDave/pi-persona-mind/v0.8.5/assets/banner.png" alt="pi-persona-mind — durable memory for Pi">
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
[](https://github.com/AeonDave/pi-persona-mind/actions/workflows/test.yml) [](https://www.npmjs.com/package/@aeondave/pi-persona-mind) [](LICENSE)
|
|
8
|
+
|
|
9
|
+
Local memory for [Pi](https://github.com/earendil-works/pi): durable facts, session notes and
|
|
10
|
+
unfinished work. Bounded excerpts enter each turn; the agent can retrieve full entries when needed.
|
|
11
|
+
|
|
12
|
+
Requires a compatible loaded [pi-persona](https://github.com/AeonDave/pi-persona). The current
|
|
13
|
+
release pair is Mind 0.8.5 with Persona 1.17.5 or later.
|
|
14
|
+
Stores use local files and Pi's session history, without embeddings, a database or a separate service.
|
|
15
|
+
Automatic consolidation uses a visible Mind worker on your current session model. Memory injection and
|
|
16
|
+
worker review consume normal model tokens. A saved claim is not automatically a verified fact.
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
|
|
20
|
+
Requires the **latest stable Pi (currently 1.4.0)** and **Node.js 22.19.0+**. Historical Pi releases
|
|
21
|
+
are not maintained. Windows, Linux and macOS are supported.
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pi install npm:@aeondave/pi-persona
|
|
25
|
+
pi install npm:@aeondave/pi-persona-mind
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Keep both extensions on a compatible release pair. Restart Pi or run `/reload` after installing or
|
|
29
|
+
updating them. Mind stays inactive when the compatible Persona companion is missing or incompatible,
|
|
30
|
+
with no memory capture, writes, injection or reminders.
|
|
31
|
+
|
|
32
|
+
| Install option | Command |
|
|
33
|
+
|---|---|
|
|
34
|
+
| This project only | `pi install -l npm:@aeondave/pi-persona-mind` |
|
|
35
|
+
| Pin Mind 0.8.5 | `pi install npm:@aeondave/pi-persona-mind@0.8.5` |
|
|
36
|
+
| Update the unpinned pair | `pi update npm:@aeondave/pi-persona`<br>`pi update npm:@aeondave/pi-persona-mind` |
|
|
37
|
+
|
|
38
|
+
When switching either extension from a Git install to npm, remove its exact Git source first (use
|
|
39
|
+
your pinned source if applicable):
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pi remove git:github.com/AeonDave/pi-persona
|
|
43
|
+
pi remove git:github.com/AeonDave/pi-persona-mind
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Keep only one source configured for each extension to avoid loading it twice.
|
|
47
|
+
|
|
48
|
+
## Choose the right memory
|
|
49
|
+
|
|
50
|
+
| Kind | Scope | Lifetime |
|
|
51
|
+
|---|---|---|
|
|
52
|
+
| Long-term facts | Active persona, plus an explicit shared tier | Until explicitly changed or forgotten |
|
|
53
|
+
| Durable project facts | Current repository, with author persona recorded | Until explicitly changed or forgotten |
|
|
54
|
+
| Short-term facts | Current project, with author persona recorded | 48 hours by default |
|
|
55
|
+
| Session notes | Active Pi session branch | Follows that session's history |
|
|
56
|
+
| Backlog | Current project's deferred work | 48 hours by default; later reminders extend it |
|
|
57
|
+
|
|
58
|
+
Session notes survive compaction and resume of a persisted session. A new session starts without
|
|
59
|
+
them; a fork inherits its selected history and keeps each note's original session ID. With
|
|
60
|
+
`--no-session` or an in-memory SDK session, notes last only as long as that session. Forgetting a
|
|
61
|
+
note hides it on the current branch; it does not erase old transcript bytes.
|
|
62
|
+
|
|
63
|
+
Promote project knowledge that must outlive its expiry: promotion defaults to durable project memory,
|
|
64
|
+
keeping repository decisions out of other projects. Explicit `scope: persona|shared` broadens the
|
|
65
|
+
destination. Existing persona facts are not automatically moved or guessed to belong to a project.
|
|
66
|
+
Mind never imports private worker archives:
|
|
67
|
+
the supervisor reads a result through Intercom, checks it, then saves the useful fact and optional
|
|
68
|
+
source reference. A result reference is provenance, not permission to read another session.
|
|
69
|
+
|
|
70
|
+
## Commands
|
|
71
|
+
|
|
72
|
+
`/mind` is an alias of `/persona-mind`; both execute the same handler.
|
|
73
|
+
|
|
74
|
+
| Command | Effect |
|
|
75
|
+
|---|---|
|
|
76
|
+
| `/persona-mind` | Project/persona memory snapshot |
|
|
77
|
+
| `/persona-mind help` | Command reference |
|
|
78
|
+
| `/persona-mind doctor` | Scope, capture policy, paths and recovery warnings |
|
|
79
|
+
| `/persona-mind session` | Bounded list of active-branch session notes |
|
|
80
|
+
| `/persona-mind reset` | Clear this project's short-term facts and backlog |
|
|
81
|
+
| `/persona-mind reset workspace` | Same explicit workspace reset |
|
|
82
|
+
| `/persona-mind migrate-persona` | Recover an ambiguous historical persona-data alias |
|
|
83
|
+
| `/persona-mind optimize [project\|project-long\|persona]` | Request one visible Persona-hosted LLM review; defaults to `project` |
|
|
84
|
+
| `/persona-mind optimize inspect [project\|project-long\|persona\|shared]` | Read-only bounded inspection |
|
|
85
|
+
| `/persona-mind optimize show <planId>` | Display an already staged plan |
|
|
86
|
+
| `/persona-mind optimize apply <planId>` | Apply that exact plan if still current |
|
|
87
|
+
| `/persona-mind optimize history [target]` | Review retained before/after receipts; default `project` |
|
|
88
|
+
| `/persona-mind optimize undo <receiptId> [target]` | Restore unchanged affected facts; default `project` |
|
|
89
|
+
| `/persona-mind optimize auto [status\|on\|off]` | Inspect or switch automatic review for this session |
|
|
90
|
+
|
|
91
|
+
Reset preserves long-term facts and session notes. `reset all` and unexpected extra arguments are
|
|
92
|
+
refused. Reports use expandable cards and short status notifications. Tool results have compact
|
|
93
|
+
previews with Pi's expand key, usually `ctrl+o`.
|
|
94
|
+
|
|
95
|
+
## Agent tools
|
|
96
|
+
|
|
97
|
+
- `memory remember`: `term: long|short|session`, `kind`, `text`. Long/short facts also support tags,
|
|
98
|
+
source, lineage and supersession. For long facts choose `scope: project|persona|shared`; default
|
|
99
|
+
is persona. The old `shared` boolean is removed: use `scope: shared`.
|
|
100
|
+
- `memory recall`: lexical/path/tag discovery with `query`, `max`, and
|
|
101
|
+
`scope: long|short|both|project|persona|shared|session`. Project includes its durable and working
|
|
102
|
+
facts; long includes all durable tiers; both includes all active archives. Session is separate.
|
|
103
|
+
- `memory read`: full text and provenance by ID, including `session:<UUID>` notes.
|
|
104
|
+
- `memory forget`: remove a fact by ID, optionally restricted by scope, or tombstone a session note.
|
|
105
|
+
- `memory promote`: make an owned short-term fact durable in this project, unless another scope is explicit.
|
|
106
|
+
- `memory optimize`: inspect, stage, apply, history and undo; undo requires `receiptId` and explicit `target`.
|
|
107
|
+
- `backlog add|list|take|done|drop`: defer, inspect, claim or close work; reminders are optional.
|
|
108
|
+
|
|
109
|
+
Prefer declarative facts such as “The project uses Node 22.” An `objective` is prioritized in
|
|
110
|
+
durable injection; a session objective stays in its session.
|
|
111
|
+
|
|
112
|
+
Injection ranks current-task words, explicit tags and repository paths, with a small priority core
|
|
113
|
+
for objectives/invariants. Persona/shared, project, working context, backlog and session notes share
|
|
114
|
+
a **2,400-token planning estimate** (UTF-8 bytes / 3), including wrappers and omission notices.
|
|
115
|
+
Session notes use up to 600 of that estimate. This is not a provider tokenizer or a billing guarantee.
|
|
116
|
+
Whole excerpts are admitted under the budget, omitted facts are counted, and full reads remain available.
|
|
117
|
+
The retrieval is deterministic; it does not infer arbitrary synonyms or establish factual truth.
|
|
118
|
+
|
|
119
|
+
## Review and consolidate
|
|
120
|
+
|
|
121
|
+
`/mind optimize [project|project-long|persona]` requests one bounded review in the real visible Persona worker; the command returns before inspection and worker admission. It bypasses automatic preference/token/cooldown gates, but refuses busy sessions, overlap and stale owners. It uses the session model and the validated preview/CAS/apply/undo pipeline. Use `/mind optimize inspect [target]` for explicitly read-only inspection. `shared` is excluded from LLM optimization and must be inspected and handled through a manually reviewed workflow.
|
|
122
|
+
|
|
123
|
+
1. `memory {action:"optimize", mode:"inspect", target:"project"}` returns IDs and a fingerprint.
|
|
124
|
+
2. Read full facts, then stage explicit replacements with that fingerprint and
|
|
125
|
+
`operations: [{sourceIds, kind, text, tags?, source?}]`.
|
|
126
|
+
3. Review the before/after plan and apply its `planId` through the tool or slash command.
|
|
127
|
+
|
|
128
|
+
One source rewrites a fact; several sources merge them. Each transaction affects one tier.
|
|
129
|
+
`project` changes only the active persona's short-term rows; `project-long` changes that persona's
|
|
130
|
+
durable repository facts; `persona` targets that persona's
|
|
131
|
+
durable store across projects; `shared` targets shared durable facts. Inspect further pages through
|
|
132
|
+
`offset`/`nextOffset`; restart if the fingerprint changes. Similarity compares the current page,
|
|
133
|
+
so absence from its candidate list does not prove the store is duplicate-free.
|
|
134
|
+
|
|
135
|
+
Plans last ten minutes, at most four per active owner. Session/persona/workspace changes invalidate
|
|
136
|
+
them. Concurrent writes refuse application. Consolidation preserves origins and lineage, never
|
|
137
|
+
extends short-term expiry, and never trims unrelated records to fit storage limits. Lineage IDs
|
|
138
|
+
alone are not a full archive of removed text. Each applied consolidation now has a durable before/after
|
|
139
|
+
receipt written before replacement. History retains at most 32 receipts / 2 MiB per target, plus the
|
|
140
|
+
store's recovery backup. Undo preserves unrelated later writes and refuses altered replacements,
|
|
141
|
+
collisions, foreign ownership or expired source facts. A `prepared` receipt means an interrupted
|
|
142
|
+
intent whose commit may or may not have happened; it is kept rather than guessing. Ambiguous IO
|
|
143
|
+
failures can therefore require manual recovery if unresolved receipts fill the history budget.
|
|
144
|
+
|
|
145
|
+
Exact deduplication and expiry cleanup already run automatically. Lexical similarity only suggests
|
|
146
|
+
comparisons; it cannot distinguish agreement from contradiction. Age never deletes a durable fact.
|
|
147
|
+
See [research and decisions](docs/MEMORY-RESEARCH.md).
|
|
148
|
+
|
|
149
|
+
Local inspect/stage/apply activity uses Mind activity rows. Full `/mind optimize` runs appear as ordinary Persona worker rows; the host removes those rows on terminal completion. The full review does not create a separate sticky activity row.
|
|
150
|
+
|
|
151
|
+
Automatic review is on by default. Successful saves/promotions mark project or persona memories
|
|
152
|
+
for review; shared memories are excluded. The first eligible burst can run after the main agent
|
|
153
|
+
settles. Every later attempt requires both new pending memories and **1,000,000 main-session input
|
|
154
|
+
tokens since the preceding attempt**. Output, cache and worker tokens do not count. Token usage
|
|
155
|
+
alone never schedules a review, and rapid additions stay queued together instead of launching a
|
|
156
|
+
worker for every save. This is a cost-control policy, not a research-derived optimum.
|
|
157
|
+
Requests coalesce for two seconds after the main agent settles, with no queued work, and actual
|
|
158
|
+
attempts have a five-minute cooldown. Only one review can run at a time; unchanged completed reviews
|
|
159
|
+
are skipped. New input cancels it; that interrupted attempt may retry after a later settled turn and
|
|
160
|
+
the cooldown without waiting for another million tokens. `/mind optimize auto off` cancels and clears
|
|
161
|
+
pending review; saves while off do not queue automatic work. Turning it on waits for the next save.
|
|
162
|
+
`on` and `off` apply immediately to this session. Set `PI_PERSONA_MIND_OPTIMIZE=off` for the initial
|
|
163
|
+
session default, and use `/mind doctor` to inspect the current state.
|
|
164
|
+
|
|
165
|
+
This is a real asynchronous Mind subagent with its own Persona view. It uses exactly the session's
|
|
166
|
+
model, without a substitute or fallback, and has no arbitrary tools. It receives at most 12 full memory
|
|
167
|
+
records within 24,000 JSON characters. Repeated admitted reviews rotate within inspection pages and
|
|
168
|
+
through older pages, reserving room for the newest eligible fact. Rotation resets with its owner;
|
|
169
|
+
it does not launch an unbounded cleanup loop or claim the whole store has been reviewed. It has a
|
|
170
|
+
three-minute deadline and proposes at most four strict
|
|
171
|
+
JSON replacements. The parent validates provenance, owner, freshness and the store fingerprint before
|
|
172
|
+
applying anything. A durable operator card records the before/after proposal before application;
|
|
173
|
+
rejected or stale proposals do not alter their target store. Automatic review does not authorize age-based
|
|
174
|
+
deletion, shared-memory editing or inference that an old fact is false.
|
|
175
|
+
|
|
176
|
+
## Capture, reminders and collaboration
|
|
177
|
+
|
|
178
|
+
Explicit direct-user requests such as “remember that I prefer small changes” are saved before
|
|
179
|
+
the model starts, with a visible receipt. Casual cues suggest capture instead.
|
|
180
|
+
|
|
181
|
+
| Setting | Effect |
|
|
182
|
+
|---|---|
|
|
183
|
+
| `PI_PERSONA_MIND_CAPTURE=auto` | Capture explicit direct-user cues; default |
|
|
184
|
+
| `PI_PERSONA_MIND_CAPTURE=prompt` | Suggest a tool call without automatic writes |
|
|
185
|
+
| `PI_PERSONA_MIND_CAPTURE=off` | Disable cue detection and capture |
|
|
186
|
+
| `PI_PERSONA_MIND_NUDGE=off` | Disable suggestions, not explicit automatic capture |
|
|
187
|
+
|
|
188
|
+
The same preferences appear in pi-persona's settings panel. Environment overrides win; Mind refreshes
|
|
189
|
+
its capture/nudge preferences on session start. The loaded Persona runtime supplies the actual active
|
|
190
|
+
persona, including with selection persistence disabled. Changing council models does not switch memory
|
|
191
|
+
scope. Mind does not infer the active persona from old files or saved selection.
|
|
192
|
+
|
|
193
|
+
Quoted text, worker reports and Intercom/Exocom messages are not direct user input.
|
|
194
|
+
The reserved `pi-persona-deferred-input` replay preserves queued direct-user requests. This is
|
|
195
|
+
a convention between trusted extensions, not protection from arbitrary code in the same process.
|
|
196
|
+
|
|
197
|
+
Workers marked `PI_PERSONA_LEG` or `PI_PERSONA_CHILD` receive only durable identity/objectives:
|
|
198
|
+
their memory scope stays on the persona that launched them, even if the parent switches later.
|
|
199
|
+
They receive no project notes, session notes, backlog, memory tools or wakes. Blocked delegate/council/flow
|
|
200
|
+
reports can suggest backlog capture; they never write it automatically. Discarded nested reports
|
|
201
|
+
do not create invisible reminders.
|
|
202
|
+
|
|
203
|
+
A due backlog item creates one display-only card and a short toast, never an agent turn.
|
|
204
|
+
Opening Pi from the home directory suppresses project injection and wakes.
|
|
205
|
+
|
|
206
|
+
## Storage and development
|
|
207
|
+
|
|
208
|
+
Under `<agentDir>/persona-mind/`: persona/shared facts in `memory/ltm/`, durable repository facts
|
|
209
|
+
in `memory/project/`, working facts in `memory/stm/`,
|
|
210
|
+
deferred work in `backlog/`. Session notes live in Pi's session file. Writes use exclusive locks,
|
|
211
|
+
ownership checks, atomic rename and a last-known-good backup. Imports of old memory data remain
|
|
212
|
+
non-destructive. Scanning and escaped injection reduce unsafe-content exposure; they do not
|
|
213
|
+
prove saved facts true or arbitrary text harmless.
|
|
214
|
+
|
|
215
|
+
An import exceeding the turn's wait budget continues in the background with a temporary information
|
|
216
|
+
notice. That alone does not mean data loss; older entries may become available later. Use
|
|
217
|
+
`/persona-mind doctor` for its state and actual warnings. After fixing a reported import problem,
|
|
218
|
+
`/reload` rechecks the retained original files.
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
npm ci
|
|
222
|
+
npm run typecheck
|
|
223
|
+
npm test
|
|
224
|
+
npm run eval:memory
|
|
225
|
+
npm audit --audit-level=low
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
Tests isolate profile/environment and exercise the real Pi 1.4 SDK with an offline provider.
|
|
229
|
+
Qualify an installed host with current pi-persona and optionally an extracted Mind tarball:
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
node --import tsx scripts/qualify-host.mjs <pi-package-root> <pi-persona-extension> [<packed-mind-extension>]
|
|
233
|
+
node --import tsx scripts/qualify-package.ts <extracted-package>/src/index.ts <pi-persona-extension>
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
The evaluation reports deterministic retrieval on a small synthetic corpus, including a prior
|
|
237
|
+
substring baseline and context estimates. It does not measure model merge quality or cloud cost.
|
|
238
|
+
These checks verify host integration, not provider authentication or semantic memory quality. Pi supplies
|
|
239
|
+
runtime peers. Development security overrides do not patch a separately installed Pi.
|
|
240
|
+
|
|
241
|
+
[Design and limits](docs/DESIGN.md) · [Changes](CHANGELOG.md) · [MIT license](LICENSE)
|
|
Binary file
|