@aeondave/pi-persona-mind 0.9.0 → 0.9.1
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 +4 -0
- package/CHANGELOG.md +21 -0
- package/README.md +59 -55
- package/docs/DESIGN.md +25 -3
- package/package.json +3 -3
- package/src/core/auto-optimize.ts +4 -4
- package/src/core/capture.ts +10 -2
- package/src/core/memory-inspector.ts +149 -149
- package/src/core/memory-read.ts +3 -3
- package/src/core/memory.ts +6 -0
- package/src/core/optimize-history.ts +3 -3
- package/src/core/optimize-service.ts +4 -4
- package/src/core/optimize.ts +3 -9
- package/src/core/service.ts +8 -6
- package/src/core/store.ts +3 -1
- package/src/extension/inspector-data.ts +69 -69
- package/src/index.ts +11 -4
- package/src/ui/inspector-frame.ts +44 -0
- package/src/ui/memory-inspector.ts +457 -431
package/AGENTS.md
CHANGED
|
@@ -93,6 +93,10 @@ coupled through a versioned local companion handshake to
|
|
|
93
93
|
Reuse maintenance admission/accounting; interrupted reviews never earn automatic retries.
|
|
94
94
|
- For `pi-persona:card-frame:v1`, custom-entry renderers pass their original entry object as optional
|
|
95
95
|
`expansionKey`; Persona owns click/keyboard synchronization. Mind must not duplicate interaction state.
|
|
96
|
+
- F10 queries `pi-persona:inspector-frame:v1` on opening and uses Persona's geometry/painter;
|
|
97
|
+
do not duplicate its frame or fall back to another styling implementation. Missing service affects
|
|
98
|
+
only opening the inspector. Page keys use actual rendered content capacity; native search Input
|
|
99
|
+
receives focus only while searching. Keep owner revocation and close-before-action safeguards.
|
|
96
100
|
- Rotate completed automatic review over older records/pages; account for actual byte admission,
|
|
97
101
|
preserve newest-fact inclusion, and never mark stopped/interrupted work as completed. No unbounded
|
|
98
102
|
sweeper. Optimizer receipts precede replacement and persist at most 32/2MiB per target; unresolved
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.9.1](https://github.com/AeonDave/pi-persona-mind/releases/tag/v0.9.1) - 2026-11-18
|
|
6
|
+
|
|
7
|
+
- Require pi-persona 1.18.1 or later for the shared F9/F10 inspector frame.
|
|
8
|
+
|
|
9
|
+
- Recheck the live memory file under the recovery lock before restoring a backup, preserving facts
|
|
10
|
+
committed by another writer while recovery was waiting.
|
|
11
|
+
- Preserve negated capture requests: “Never remember that …” no longer creates a positive session
|
|
12
|
+
note; negated decision premises are retained instead of discarded before `:`. Affirmative requests
|
|
13
|
+
whose fact contains negative wording, such as “Remember that I never …”, remain valid.
|
|
14
|
+
- Acknowledge backlog reminders by both ID and the displayed deadline, preserving concurrent
|
|
15
|
+
rescheduling instead of silently consuming the new reminder.
|
|
16
|
+
- Recheck persisted memory content before promotion through the shared content guard. Unsafe
|
|
17
|
+
out-of-band records cannot move into durable/shared memory, and refusal preserves both stores.
|
|
18
|
+
- Suppress late status counts and storage warnings after persona changes or shutdown, using the
|
|
19
|
+
same accepting-owner guard as other asynchronous memory operations.
|
|
20
|
+
- Simplify the README around memory lifetimes, retrieval, F10 and deliberate maintenance, with
|
|
21
|
+
technical details linked to the design contract.
|
|
22
|
+
- Share Persona's F9 window frame in F10, including responsive dimensions, gutters and theme
|
|
23
|
+
border. Page navigation follows the visible content without gaps; narrow windows preserve the
|
|
24
|
+
selected record and search focus belongs only to the active native input.
|
|
25
|
+
|
|
5
26
|
## [0.9.0](https://github.com/AeonDave/pi-persona-mind/releases/tag/v0.9.0) - 2026-11-13
|
|
6
27
|
|
|
7
28
|
- Require pi-persona 1.18.0 or later for this release. Mind custom entries use the shared
|
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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.9.
|
|
4
|
+
<img src="https://raw.githubusercontent.com/AeonDave/pi-persona-mind/v0.9.1/assets/banner.png" alt="pi-persona-mind — durable memory for Pi">
|
|
5
5
|
</p>
|
|
6
6
|
|
|
7
7
|
[](https://github.com/AeonDave/pi-persona-mind/actions/workflows/test.yml)
|
|
@@ -12,10 +12,21 @@
|
|
|
12
12
|
and deferred work without turning every conversation into permanent memory.
|
|
13
13
|
Mind complements Pi's native conversation history and compaction; it does not replace them.
|
|
14
14
|
|
|
15
|
+
| What you need | What Mind provides |
|
|
16
|
+
|---|---|
|
|
17
|
+
| Continue a long project | Durable repository decisions, scoped preferences and session notes that survive compaction |
|
|
18
|
+
| Keep context focused | Bounded retrieval by words, tags and paths, with explicit full-record reads |
|
|
19
|
+
| See what the agent remembers | **F10**: saved facts, prepared context and an active-branch timeline |
|
|
20
|
+
| Maintain a growing archive | Bounded consolidation, evidence-grounded review, change history and guarded undo |
|
|
21
|
+
|
|
22
|
+
Memory is stored in local files and Pi's native session history. Recall and browsing need no model
|
|
23
|
+
call. [Automatic consolidation](#quiet-automatic-maintenance) is on by default; it and explicit
|
|
24
|
+
knowledge reviews use the current session model and incur model usage.
|
|
25
|
+
|
|
15
26
|
## Quick start
|
|
16
27
|
|
|
17
|
-
Mind 0.9.
|
|
18
|
-
[**pi-persona 1.18.
|
|
28
|
+
Mind 0.9.1 requires **Pi 1.5.2**, **Node.js 22.19.0+**, and
|
|
29
|
+
[**pi-persona 1.18.1+**](https://github.com/AeonDave/pi-persona) loaded in the same instance.
|
|
19
30
|
|
|
20
31
|
```bash
|
|
21
32
|
pi install npm:@aeondave/pi-persona
|
|
@@ -46,33 +57,30 @@ Press **F10** to inspect what Mind has saved and prepared. Use **`/mind`** for a
|
|
|
46
57
|
|
|
47
58
|
Choose the lifetime and scope that match your intent:
|
|
48
59
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
or `shared` for a durable save. Strong direct-user cues may also be captured automatically, but
|
|
60
|
+
| Memory | Where it belongs | Lifetime |
|
|
61
|
+
|---|---|---|
|
|
62
|
+
| Session notes | The active native session branch | Survive compaction and persisted resume; stay out of new sessions and workers |
|
|
63
|
+
| Project working memory | Temporary repository context | 48 hours by default |
|
|
64
|
+
| Durable project memory | Repository decisions | Until changed or forgotten |
|
|
65
|
+
| Persona memory | One persona across projects | Until changed or forgotten |
|
|
66
|
+
| Shared memory | Deliberately shared across personas | Until changed or forgotten |
|
|
67
|
+
| Backlog | Deferred project work and reminders | 48 hours by default; later reminders extend expiry |
|
|
68
|
+
|
|
69
|
+
The agent chooses scope from your intent; durable saves require an explicit `project`, `persona`
|
|
70
|
+
or `shared` destination. Strong direct-user cues may be captured automatically, but
|
|
61
71
|
**automatic capture creates provisional session notes only**, even for “remember” or “from now on”.
|
|
62
72
|
Broader retention requires a separate deliberate `memory` call with an explicit durable scope.
|
|
63
|
-
Project injection and reminders are suppressed in the home directory.
|
|
64
73
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
74
|
+
Reminders notify you while Pi is open; they do not wake the model. Delegated workers receive a lean
|
|
75
|
+
memory selection, without session notes or memory/backlog write tools. Home-directory sessions skip
|
|
76
|
+
project injection and reminders. See [lifetimes and scope](docs/DESIGN.md#four-lifetimes) and
|
|
77
|
+
[session notes](docs/DESIGN.md#session-notes) for persistence, branch-local forgetting and expiry.
|
|
69
78
|
|
|
70
79
|
## Retrieval and inspection
|
|
71
80
|
|
|
72
|
-
Mind selects
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
The shared context budget is a planning estimate, not a provider billing counter.
|
|
81
|
+
Mind selects relevant excerpts each turn within one shared context budget. Words, tags and paths
|
|
82
|
+
drive retrieval; lexical matching can miss paraphrases or conflicting facts. Use `memory recall`
|
|
83
|
+
to search and `memory read` to inspect a complete record. The budget is an estimate, not a billing counter.
|
|
76
84
|
|
|
77
85
|
**F10** toggles the read-only inspector in the interactive TUI:
|
|
78
86
|
|
|
@@ -80,32 +88,29 @@ The shared context budget is a planning estimate, not a provider billing counter
|
|
|
80
88
|
- **Context** shows the last block prepared by Mind, including omissions—not the final provider payload.
|
|
81
89
|
- **Timeline** shows bounded user/assistant text and session-note events on the active branch.
|
|
82
90
|
|
|
83
|
-
Open a record for detail
|
|
84
|
-
shows
|
|
85
|
-
|
|
86
|
-
branch, not a searchable archive of every past session.
|
|
91
|
+
Open a record for detail and press **s** for its recording source, when available. Recording provenance
|
|
92
|
+
shows how a fact was saved; it does not verify the assertion. Timeline and source lookup cover a
|
|
93
|
+
bounded active-branch window.
|
|
87
94
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
Navigation hints appear in the inspector. See the [inspector design](docs/DESIGN.md#read-only-memory-inspector)
|
|
91
|
-
for keys, coverage and limits.
|
|
95
|
+
In Memories, **a** opens maintenance actions; `/mind browse`, `/mind browse context` and `/mind timeline`
|
|
96
|
+
are command alternatives. Browsing alone is read-only and makes no model calls.
|
|
92
97
|
|
|
93
|
-
|
|
98
|
+
F10 shares Persona's F9 window frame and theme. **PageUp/PageDown** follow visible rows, narrow
|
|
99
|
+
windows keep the selection visible, and **?** opens help. See the
|
|
100
|
+
[inspector design](docs/DESIGN.md#read-only-memory-inspector) for navigation, sources and coverage.
|
|
94
101
|
|
|
95
|
-
|
|
96
|
-
validates proposed replacements and retains history for guarded undo; it does not check repository
|
|
97
|
-
truth. Run `/mind optimize` for one bounded window per eligible nonshared tier, or select a tier.
|
|
98
|
-
Inspect previous changes with `/mind optimize history` and use `/mind optimize undo` with a receipt ID.
|
|
99
|
-
Shared memory is excluded from model-driven optimization.
|
|
102
|
+
## Maintain knowledge deliberately
|
|
100
103
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
+
**Consolidation** merges compatible saved facts and applies validated changes. `/mind optimize`
|
|
105
|
+
reviews one bounded window per allowed project/persona tier; `/mind optimize project-long` selects
|
|
106
|
+
durable project memory alone. Inspect changes with `/mind optimize history`; `/mind optimize undo`
|
|
107
|
+
restores affected facts only when its conflict checks pass. This reorganizes saved knowledge; it does
|
|
108
|
+
not verify it against your repository. [Consolidation and undo details →](docs/DESIGN.md#explicit-consolidation)
|
|
104
109
|
|
|
105
|
-
**Knowledge review**
|
|
106
|
-
files
|
|
107
|
-
|
|
108
|
-
|
|
110
|
+
**Knowledge review** runs in the interactive terminal and checks selected facts against repository
|
|
111
|
+
files you choose and bounded active-branch user-role text. Repository evidence requires project trust.
|
|
112
|
+
The worker proposes corrections, conflicts, insufficient-evidence findings or retirement
|
|
113
|
+
recommendations for your review.
|
|
109
114
|
|
|
110
115
|
1. Choose **F10 → Memories → a**, or run `/mind review project-long` (also `project` or `persona`).
|
|
111
116
|
2. Select evidence and confirm the model call. Inspect the proposal with `/mind review show`.
|
|
@@ -113,20 +118,18 @@ or retirement recommendations; it cannot establish truth or automatically apply
|
|
|
113
118
|
Application rechecks evidence and memory freshness. Retirement is a recommendation; forgetting a
|
|
114
119
|
fact is a separate deliberate action.
|
|
115
120
|
|
|
116
|
-
Both workflows use a **visible Persona-hosted Mind worker on the current session model
|
|
117
|
-
model
|
|
118
|
-
|
|
119
|
-
model
|
|
120
|
-
|
|
121
|
+
Both workflows use a **visible Persona-hosted Mind worker on the current session model** and incur
|
|
122
|
+
model usage. Choose a model with `/model` before starting. New input or model, branch, session and
|
|
123
|
+
owner changes invalidate pending review work. Shared memory and session notes are excluded from
|
|
124
|
+
these model-driven mutations. Reviews and undo history are bounded; a reviewed window is not a
|
|
125
|
+
whole-archive audit or a guarantee of truth.
|
|
121
126
|
|
|
122
127
|
### Quiet automatic maintenance
|
|
123
128
|
|
|
124
129
|
Automatic consolidation is on by default. After eligible saves, it waits for the foreground to become
|
|
125
|
-
idle and respects usage, cooldown and ownership
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
stay quiet. Failures and important warnings remain visible. Model output and validation are not a
|
|
129
|
-
semantic-correctness guarantee.
|
|
130
|
+
idle and respects usage, cooldown and ownership limits. A real worker is visible in Persona;
|
|
131
|
+
successful changes produce one small **mind** notification, while routine no-ops stay quiet.
|
|
132
|
+
Failures and important warnings remain visible, and applied changes retain history for guarded undo.
|
|
130
133
|
|
|
131
134
|
Use `/mind optimize auto status`, `/mind optimize auto off` or `/mind optimize auto on` for the current
|
|
132
135
|
session. `PI_PERSONA_MIND_OPTIMIZE=off` disables automatic optimization at startup. Capture can be set
|
|
@@ -137,5 +140,6 @@ See [automatic review](docs/DESIGN.md#automatic-semantic-review) for admission a
|
|
|
137
140
|
|
|
138
141
|
- [Design: lifetimes, storage, limits, commands and safeguards](docs/DESIGN.md)
|
|
139
142
|
- [Evidence-grounded review and approval](docs/DESIGN.md#evidence-grounded-knowledge-review)
|
|
143
|
+
- [Storage recovery and concurrent writes](docs/DESIGN.md#durable-files-and-recovery)
|
|
140
144
|
- [Architecture decisions and evaluation boundaries](docs/MEMORY-RESEARCH.md)
|
|
141
145
|
- [Release history](CHANGELOG.md) · [MIT license](LICENSE)
|
package/docs/DESIGN.md
CHANGED
|
@@ -17,7 +17,7 @@ patch an installed host.
|
|
|
17
17
|
Mind requires a loaded compatible pi-persona through its versioned local companion handshake.
|
|
18
18
|
Missing/incompatible presence leaves tools inactive and suppresses capture, storage/import,
|
|
19
19
|
injection and reminders. A settings file or installed npm package is not proof of an active
|
|
20
|
-
companion. Mind 0.
|
|
20
|
+
companion. Mind 0.9.1 requires Persona 1.18.1 or later for these paired contracts. Its optional npm
|
|
21
21
|
peer declares that requirement without auto-installing or activating another extension.
|
|
22
22
|
|
|
23
23
|
The node-only core has no Pi imports. The factory wires native Pi hooks, tools, scope, scheduling
|
|
@@ -28,7 +28,7 @@ Command parsing/presentation lives outside the factory. Important seams:
|
|
|
28
28
|
|---|---|
|
|
29
29
|
| core/service.ts | Scope-bound memory/backlog operations, mutation ordering |
|
|
30
30
|
| core/store.ts | Atomic writes, exclusive ownership, recovery, strict snapshots and CAS |
|
|
31
|
-
| core/memory.ts, backlog.ts | Validated facts and deferred-work state |
|
|
31
|
+
| core/memory.ts, backlog.ts | Validated facts, shared persisted-content guard and deferred-work state |
|
|
32
32
|
| core/scope.ts, mind-settings.ts | Project identity, safe paths and canonical Mind preferences |
|
|
33
33
|
| extension/persona-dependency.ts | Loaded capability and actual memory-owner contracts |
|
|
34
34
|
| core/migrate.ts | Bounded, non-destructive import of previous memory layouts |
|
|
@@ -251,6 +251,9 @@ Stores carry version, sequence, updatedAt and entries. Mutations use same-direct
|
|
|
251
251
|
fsync, atomic rename, exclusive lockfiles and ownership checks. Directory fsync is best-effort on
|
|
252
252
|
Windows. A live/foreign/malformed lock holder is never stolen merely for being old. Corruption is
|
|
253
253
|
recovered or quarantined with diagnostics, never silently treated as an empty valid store.
|
|
254
|
+
Backup recovery re-reads the live file after acquiring its exclusive lock: a writer that committed
|
|
255
|
+
while recovery waited takes precedence over the previously observed backup. Recovery never overwrites
|
|
256
|
+
that new live state or replaces a healthy backup with the damaged/missing state it is repairing.
|
|
254
257
|
Windows sharing conflicts during recovery-gate acquisition return to the existing bounded lock
|
|
255
258
|
wait; they never authorize entering the protected callback or deleting another recovery gate.
|
|
256
259
|
Ordinary memory stores default to 10,000 entries and 4 MiB; writes over capacity fail without truncating
|
|
@@ -277,6 +280,9 @@ disk cleanup. Progress is informational, shown once per import and cleared when
|
|
|
277
280
|
Expiry cleanup operates on the current entries under the mutation lock. Never compute a retained
|
|
278
281
|
backlog snapshot before acquiring the write lock: a concurrent add would otherwise be erased.
|
|
279
282
|
Promotion writes LTM before removing STM, so interruption leaves a duplicate rather than data loss.
|
|
283
|
+
Promotion rechecks persisted source text, tags, origin and persona through the same content guard
|
|
284
|
+
used by full reads, consolidation and undo. An unsafe out-of-band record stays in its original tier;
|
|
285
|
+
it is not copied to durable/shared memory or removed from working memory.
|
|
280
286
|
Backlog cleanup retains active items and bounded terminal history.
|
|
281
287
|
|
|
282
288
|
## Capture, injection and UI
|
|
@@ -301,8 +307,13 @@ no durable store was written, and invites a separate deliberate scoped memory ca
|
|
|
301
307
|
matches actual user intent; it does not forbid deliberate durable curation. A session append failure
|
|
302
308
|
has no durable fallback. Prompt mode remains nudge-only and off disables detection/capture. Quoted,
|
|
303
309
|
fenced, peer, worker, extension-follow-up and unattributed content are not direct-user capture input.
|
|
310
|
+
Leading negation such as “Never remember that …” is not stripped into a positive capture request.
|
|
311
|
+
Decision extraction also rejects negation in a premise it would discard before `:`. Negative wording
|
|
312
|
+
inside an affirmative fact (“Remember that I never …” or “We decided …: never …”) remains valid.
|
|
304
313
|
No-cue input skips migration waits. Lifecycle/current-input/owner generations prevent stale capture
|
|
305
314
|
notices; accepted notes stay with the original native owner and are never copied to a replacement session.
|
|
315
|
+
Asynchronous status reads use that same owner guard: results and failures from a previous owner
|
|
316
|
+
cannot replace the current owner's counts or display a stale storage warning after shutdown.
|
|
306
317
|
|
|
307
318
|
Normal injection uses entry caps (8 persona/shared LTM, 4 project LTM, 5 STM, 6 backlog), plus a
|
|
308
319
|
combined 2,400-token planning estimate across all memory blocks, including session notes (up to 600),
|
|
@@ -319,7 +330,9 @@ Bound and clear relay state at settlement.
|
|
|
319
330
|
|
|
320
331
|
Wakes are display-only appendEntry plus a short toast, never sendUserMessage/triggerTurn. Acknowledged
|
|
321
332
|
due reminders are not replayed. Newly due reminders are armed immediately and cancel on closure.
|
|
322
|
-
Keep pending/delivered deadline identity across maintenance re-arms.
|
|
333
|
+
Keep pending/delivered deadline identity across maintenance re-arms. Persistence acknowledges only
|
|
334
|
+
the exact `(id, dueAtEpochMs)` shown to the user, compared under the backlog write lock; an old
|
|
335
|
+
acknowledgement cannot consume a concurrent renewal. It clears that deadline, not the backlog item.
|
|
323
336
|
|
|
324
337
|
Standalone cards use Persona's single `createCardFrame` implementation through the synchronous local
|
|
325
338
|
`pi-persona:card-frame:v1` presentation query. Mind mirrors the small structural contract and queries
|
|
@@ -349,6 +362,15 @@ selects its timeline tab. Existing bare `/mind` and `/mind session` reports rema
|
|
|
349
362
|
print and JSON modes do not open custom TUI. Delegated legs do not receive the shortcut or browse
|
|
350
363
|
access. Entry points require compatible Persona and the actual current native session owner.
|
|
351
364
|
|
|
365
|
+
F10 obtains Persona's stateless frame through the synchronous local
|
|
366
|
+
`pi-persona:inspector-frame:v1` query when opening. Both inspectors use the same width, row
|
|
367
|
+
allocation, gutters and theme `border` role. Mind mirrors only the structural service contract,
|
|
368
|
+
not a second painter; if the service is unavailable, opening reports a compatible-Persona/reload
|
|
369
|
+
diagnostic while memory operations remain unchanged. Selection, tabs, sources, data admission and
|
|
370
|
+
lifecycle remain Mind-owned. Page movement uses the actual rendered list/detail/source/help
|
|
371
|
+
capacity, and narrow layouts shorten controls before hiding the selected record. The native search
|
|
372
|
+
Input receives focus only during search.
|
|
373
|
+
|
|
352
374
|
The inspector is a query/view layer, not a new memory engine. Its explicit `a` action launcher closes
|
|
353
375
|
the overlay before opening native action/approval dialogs. Consolidation calls the existing bounded
|
|
354
376
|
explicit optimizer for the chosen nonshared scope; the launcher does not create a second merge path.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aeondave/pi-persona-mind",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Local memory for Pi with pi-persona — durable project and persona facts, session notes, bounded retrieval, and supervised automatic consolidation.",
|
|
@@ -52,13 +52,13 @@
|
|
|
52
52
|
"verify": "npm run typecheck && npm test"
|
|
53
53
|
},
|
|
54
54
|
"pi": {
|
|
55
|
-
"image": "https://raw.githubusercontent.com/AeonDave/pi-persona-mind/v0.9.
|
|
55
|
+
"image": "https://raw.githubusercontent.com/AeonDave/pi-persona-mind/v0.9.1/assets/banner.png",
|
|
56
56
|
"extensions": [
|
|
57
57
|
"./src/index.ts"
|
|
58
58
|
]
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
|
-
"@aeondave/pi-persona": ">=1.18.
|
|
61
|
+
"@aeondave/pi-persona": ">=1.18.1",
|
|
62
62
|
"@earendil-works/pi-coding-agent": "*",
|
|
63
63
|
"@earendil-works/pi-tui": "*",
|
|
64
64
|
"typebox": "*"
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/** Pure selection and strict proposal contracts for Mind's bounded background reviewer. */
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
3
|
import {
|
|
4
|
-
isMemoryId, MEMORY_KINDS, MAX_MEMORY_TEXT_CHARS, validateLongMemory, validateShortMemory,
|
|
4
|
+
isMemoryId, isSafeMemoryContent, MEMORY_KINDS, MAX_MEMORY_TEXT_CHARS, validateLongMemory, validateShortMemory,
|
|
5
5
|
type MemoryEntry, type MemoryKind,
|
|
6
6
|
} from "./memory.ts";
|
|
7
|
-
import {
|
|
7
|
+
import type { OptimizeInspection, OptimizeOperation } from "./optimize.ts";
|
|
8
8
|
|
|
9
9
|
export type AutoOptimizeTarget = "project" | "project-long" | "persona";
|
|
10
10
|
|
|
@@ -185,7 +185,7 @@ function validateInput(input: AutoOptimizeInput): MemoryEntry[] | undefined {
|
|
|
185
185
|
let personaOwner: string | undefined;
|
|
186
186
|
for (const raw of input.entries) {
|
|
187
187
|
const entry = input.target === "project" ? validateShortMemory(raw) : validateLongMemory(raw);
|
|
188
|
-
if (!entry || !
|
|
188
|
+
if (!entry || !isSafeMemoryContent(entry) || !isMemoryId(entry.id) || ids.has(entry.id)) return undefined;
|
|
189
189
|
if (input.target === "project" || input.target === "project-long") {
|
|
190
190
|
if (typeof entry.persona !== "string" || entry.persona.length === 0) return undefined;
|
|
191
191
|
if (projectOwner !== undefined && projectOwner !== entry.persona) return undefined;
|
|
@@ -208,7 +208,7 @@ function eligibleEntries(inspection: OptimizeInspection, persona: string): Memor
|
|
|
208
208
|
const occurrences = new Map<string, MemoryEntry[]>();
|
|
209
209
|
for (const raw of inspection.entries) {
|
|
210
210
|
const entry = inspection.target === "project" ? validateShortMemory(raw) : validateLongMemory(raw);
|
|
211
|
-
if (!entry || !
|
|
211
|
+
if (!entry || !isSafeMemoryContent(entry)) continue;
|
|
212
212
|
if (inspection.target === "project" && entry.persona !== persona) continue;
|
|
213
213
|
if (inspection.target === "project-long" && entry.persona !== persona) continue;
|
|
214
214
|
// Persona LTM is scoped by the store path; reject a contradictory embedded owner marker while
|
package/src/core/capture.ts
CHANGED
|
@@ -58,7 +58,14 @@ const DECISION_ACTION = /\b(?:decided|chosen|chose|adopted|established|made|set|
|
|
|
58
58
|
const REPORTED_DECISION = /^\s*(?:i\s+(?:saw|noticed|read|heard|observed|found|learned)\b|ho\s+(?:visto|notato|letto|sentito|osservato|scoperto|appreso)\b|mi\s+sono\s+accort[oa]\b)/i;
|
|
59
59
|
|
|
60
60
|
function isDirectDurableDecision(sentence: string): boolean {
|
|
61
|
-
|
|
61
|
+
if (REPORTED_DECISION.test(sentence) || !DIRECT_DECISION_OWNER.test(sentence) || !DURABLE_WORD.test(sentence) || !DECISION_WORD.test(sentence)) return false;
|
|
62
|
+
const action = DECISION_ACTION.exec(sentence);
|
|
63
|
+
if (action === null) return false;
|
|
64
|
+
const colon = sentence.indexOf(":");
|
|
65
|
+
// Reject negation anywhere in a premise that extraction would discard. Otherwise inspect
|
|
66
|
+
// only before the adoption verb: a negative fact remains eligible and keeps its wording.
|
|
67
|
+
const premiseEnd = colon >= 0 && sentence.slice(colon + 1).trim() ? colon : action.index;
|
|
68
|
+
return !/\b(?:never|not|non|mai)\b|n['’]t\b/i.test(sentence.slice(0, premiseEnd));
|
|
62
69
|
}
|
|
63
70
|
|
|
64
71
|
/** Split into sentences on ., !, ?, newline — coarse but enough to isolate the cued clause. */
|
|
@@ -110,7 +117,8 @@ function candidateFor(sentence: string): { text: string; explicit: boolean } {
|
|
|
110
117
|
const text = afterColon || direct;
|
|
111
118
|
return { text, explicit: /[\p{L}\p{N}]/u.test(text) };
|
|
112
119
|
}
|
|
113
|
-
|
|
120
|
+
// "Always remember" reinforces consent; stripping "never" would reverse a refusal.
|
|
121
|
+
const withoutAlways = direct.replace(/^\s*always\s+/i, "");
|
|
114
122
|
for (const prefix of CUE_PREFIXES) {
|
|
115
123
|
const match = prefix.re.exec(direct) ?? (withoutAlways !== direct ? prefix.re.exec(withoutAlways) : null);
|
|
116
124
|
const candidate = match?.[1]?.trim();
|