@aeondave/pi-persona-mind 0.9.3 → 0.9.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 CHANGED
@@ -1,131 +1,135 @@
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.6.0 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
- - User-requested commits use **AeonDave** as both author and committer, retaining the user's configured
18
- email. Never add `Co-authored-by` or assistant/bot attribution; do not push unless explicitly requested.
19
- - Erasable-syntax-only TS. `src/core/*` is pure (no Pi imports) and unit-tested.
20
- - Target the latest stable Pi only (currently 1.6.0), Node 22.19.0+. Keep host packages and
21
- typebox as optional peers on `*`, with all four Pi development packages pinned together.
22
- No historical-host branches; never bundle a second host runtime. Scope development security
23
- overrides to their affected parent/version and remove them when that graph no longer needs them.
24
- - Tests clear `PI_PERSONA_*` case-insensitively and pin `PI_AGENT_DIR` plus the SDK's
25
- `PI_CODING_AGENT_DIR` to the same throwaway directory.
26
- Keep the hermetic import on every direct test invocation. Real SDK tests use an offline provider.
27
- - Require the loaded companion protocol at session activation and tool call time; missing or
28
- incompatible Persona means no capture, storage/migration, injection or scheduler activity.
29
- Settings files alone do not prove presence. Resolve the actual active persona through the
30
- session-bound `pi-persona:memory-owner:v1` runtime contract; never reconstruct it from CLI or saved
31
- selection. Before that owner is ready, do no memory IO. Delegated engines freeze the parent's
32
- persona for their lifetime. Canonical `<agentDir>/persona/settings.json` supplies only Mind's
33
- `mindCapture`/`mindNudge` session preference snapshots. Do not interpret retired state markers.
34
- Contribute effective Mind settings
35
- only from a supervisor via the shared settings event bus. Mirror `PI_PERSONA_LEG` /
36
- `PI_PERSONA_CHILD`, and `pi-persona-deferred-input` by env/customType only.
37
- - Model configuration changes are not persona switches;
38
- `/persona models` must leave Mind's scope unchanged. Do not duplicate persona discovery here.
39
- - Wakes are display-only (`appendEntry` + toast). Never `sendUserMessage` / `triggerTurn`.
40
- - Lifecycle generations bind capture/injection UI state to the accepting session. An accepted
41
- session-only capture may remain on its original native branch; its acknowledgement must not leak to a new turn.
42
- - Nested tool results reach only their caller. Nudge on a blocked report only when the top-level
43
- result actually relays it; bound provenance by `parentToolCallId` and clear it on lifecycle change.
44
- - Persona/shared and repository LTM are durable across sessions. Every long-term `remember` must
45
- explicitly choose `scope: project|persona|shared`; there is no implicit persona destination.
46
- `project` with long term stays in the repository; promotion defaults to project and requires an
47
- owned source. `project-long` is the optimizer target; `project` still means working STM. Shared
48
- writes use `scope: shared`, not a boolean. Scope expresses API routing intent, not authenticated
49
- user consent. Use session for task-specific/uncertain choices (models, strategies, task constraints),
50
- project for stable repository facts, persona for intent across all projects of the same persona,
51
- and shared only for intent across personas. Existing persona facts are not automatically reassigned.
52
- STM/backlog auto-delete after ~48h. `kind: objective` never changes the requested lifetime. Explicit
53
- session notes live in Pi's native active branch, survive compaction/resume when session history is
54
- persistent, are not copied to a new session, and stay absent from delegated workers. A non-persistent
55
- host session reports in-memory storage; forget is a branch-local tombstone.
56
- - AUTO strong direct-user cue capture writes only native session notes; even explicit “remember”,
57
- “from now on”, or durable wording does not write project/persona/shared stores or dirty optimizer
58
- targets. Capture feedback states session-only lifetime and does not claim durable storage. Prompt
59
- mode remains nudge-only; off disables capture; foreign/quoted/worker content remains non-direct.
60
- Broader persistence requires a deliberate memory call with an explicit scope chosen from actual intent.
61
- Never fall back to durable storage if a native session append fails.
62
- - Bare `/mind optimize` (also `/mind optimize all`) reviews one bounded window for each currently allowed nonshared target, sequentially, at most three workers; home allows persona only. Named `/mind optimize project|project-long|persona` stays single-target. All explicit work bypasses automatic dirty/token/cooldown and auto-off gates but not owner, busy, validation or CAS safeguards; retain the real Persona worker, strict JSON/provenance/preview/apply/receipt path, exact session model, no fallback/tools, per-tier outcomes, and honest bounded no-op/skip diagnostics. A skipped page is not proof the whole target is empty. Stop a batch on cancellation, owner change or failed/refused/uncertain work. Shared is refused with a pointer to `/mind optimize inspect shared`; it is excluded from all LLM automatic and explicit writes. Inspect/history defaults stay unchanged. 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.
63
- - Optimization inspect/stage exact replacements/apply a short-lived plan ID remains available through explicit inspect/show/apply commands and the memory tool. Similarity
64
- is advisory. Compare the original raw store fingerprint under its lock; reject stale/expired
65
- plans, invalid stores, ownership mixing, provenance overflow and extended STM expiry.
66
- Lifecycle changes invalidate plans. Automatic semantic review is user-authorized and on by default
67
- unless `PI_PERSONA_MIND_OPTIMIZE=off`; session commands may switch it immediately. Queue after a
68
- successful remember/promotion. First eligible burst has no token floor; later attempts need dirty
69
- memories AND 1M main-session input tokens since the prior launch (exclude output/cache/worker usage).
70
- Actual explicit worker launches also reset the automatic token/cooldown baseline and persist their
71
- completed digests, but interrupted explicit work never grants automatic retry. Usage alone never
72
- marks memories dirty. Coalesce 2s after `agent_settled` while idle with no queued
73
- work; cool down 5min between actual attempts. Only the interrupted attempt can retry without the
74
- token floor, after a later settled event and cooldown. One worker per instance; unchanged semantic
75
- digests skip review. New input, agent start,
76
- off or owner changes cancel and invalidate plans. Use a real visible
77
- Persona-hosted Mind worker on exactly the session model, no fallback or arbitrary tools. Give it
78
- at most 12 full source records/24k JSON characters, a 180s deadline and at most 4 strict JSON
79
- replacement operations/12 source IDs each, then validate/apply through parent-owned
80
- provenance/freshness/CAS checks. Automatic operations must consolidate at least two compatible
81
- supplied sources; single-record rewrites remain explicit-only. A window without a same-kind pair
82
- cannot start an automatic model call or consume its first-attempt allowance. Shared memories and
83
- age-based deletion remain excluded. Persist the full proposal audit before apply, but keep it out
84
- of the automatic transcript; show one informative `mind` toast on successful change, no routine
85
- result card, and no no-op card or toast. Keep durable history and guarded undo available.
86
- Manual detail and important warnings remain visible. Worker completion is not proof of semantic truth.
87
- - Evidence-grounded knowledge review is explicit and separate from consolidation. F10 actions close
88
- the overlay before native prompts. Parent-selected, bounded trusted-repository files and active-branch
89
- user-role text are evidence, never instructions or authenticated truth. Use the real exact-session-model
90
- Persona worker with no tools; validate closed findings/citations. Corrections remain staged in a separate
91
- optimizer until user approval and source/owner freshness checks, including the guarded store callback.
92
- Shared/session are not review write targets. Retirement is recommendation-only, not an implicit delete.
93
- Reuse maintenance admission/accounting; interrupted reviews never earn automatic retries.
94
- - For `pi-persona:card-frame:v1`, custom-entry renderers pass their original entry object as optional
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.
100
- - Rotate completed automatic review over older records/pages; account for actual byte admission,
101
- preserve newest-fact inclusion, and never mark stopped/interrupted work as completed. No unbounded
102
- sweeper. Optimizer receipts precede replacement and persist at most 32/2MiB per target; unresolved
103
- prepared receipts are protected. Undo compares affected facts and owner generation under lock,
104
- never restores expired STM or clobbers unrelated writes. Propagate uncertain-finalization warnings.
105
- - Retrieval uses one lexical/tag/path ranker; do not introduce a second recall policy. Matches preserve Unicode and exact-term priority; identifier/vowel-accent bridges have lower weight.
106
- Keep numeric versions exact and retain negation/exception terms. Test false positives as well as hits.
107
- Ordinary `remember supersedes` receipts share the optimizer's history/CAS protocol and retain
108
- before/after provenance. Historical facts never join active recall or injection; ordinary receipt
109
- undo is refused. History lists metadata and explicit receipt details are paged, not full-store dumps.
110
- Explicit handoffs use one bounded project sidecar (32 entries / 128 KiB) with persona ownership,
111
- native session/branch origin and revision checks. No automatic expiry/eviction, injection or worker
112
- access. Complete requires a resolution; pending text remains historical. Recheck accepting owners
113
- under the store lock and reject malformed/unsafe persisted fields.
114
- All injected tiers share a 2400-token planning estimate (UTF-8 bytes/3); session notes use up to 600. Include
115
- wrappers, separators and omission counts, keep whole excerpts, and never exempt pinned facts from
116
- the bound. The estimate and synthetic evaluation are not billing or semantic-quality guarantees.
117
- - `exactOptionalPropertyTypes`: omit optional props; do not assign `undefined`.
118
-
119
- ## Done
120
-
121
- `npm run typecheck` clean, `npm test` green, full `npm audit --audit-level=low`, and package dry-run
122
- inspection. Re-run after final edits. Keep published files explicit; no tests, drafts or local artifacts.
123
-
124
- ### Accepted platform diagnostics
125
-
126
- - Windows runs have zero expected skips. On other platforms, only the two Windows recovery-gate
127
- sharing-violation cases in `test/store.test.ts` are intentionally skipped: they exercise the
128
- Windows-specific `EPERM` handling, not the POSIX path. Report them as untested, never passed.
129
- - Evidence symlink-boundary tests are required on every platform. Windows test accounts need
130
- Developer Mode or `SeCreateSymbolicLinkPrivilege`; missing support fails rather than silently
131
- dropping those security checks. No other conditional skips are accepted.
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.6.0 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
+ - User-requested commits use **AeonDave** as both author and committer, retaining the user's configured
18
+ email. Never add `Co-authored-by` or assistant/bot attribution; do not push unless explicitly requested.
19
+ - Erasable-syntax-only TS. `src/core/*` is pure (no Pi imports) and unit-tested.
20
+ - Target the latest stable Pi only (currently 1.6.0), Node 22.19.0+. Keep host packages and
21
+ typebox as optional peers on `*`, with all four Pi development packages pinned together.
22
+ No historical-host branches; never bundle a second host runtime. Scope development security
23
+ overrides to their affected parent/version and remove them when that graph no longer needs them.
24
+ - Tests clear `PI_PERSONA_*` case-insensitively and pin `PI_AGENT_DIR` plus the SDK's
25
+ `PI_CODING_AGENT_DIR` to the same throwaway directory.
26
+ Keep the hermetic import on every direct test invocation. Real SDK tests use an offline provider.
27
+ - Require the loaded companion protocol at session activation and tool call time; missing or
28
+ incompatible Persona means no capture, storage/migration, injection or scheduler activity.
29
+ Settings files alone do not prove presence. Resolve the actual active persona through the
30
+ session-bound `pi-persona:memory-owner:v1` runtime contract; never reconstruct it from CLI or saved
31
+ selection. Before that owner is ready, do no memory IO. Delegated engines freeze the parent's
32
+ persona for their lifetime. Canonical `<agentDir>/persona/settings.json` supplies only Mind's
33
+ `mindCapture`/`mindNudge` session preference snapshots. Do not interpret retired state markers.
34
+ Contribute effective Mind settings
35
+ only from a supervisor via the shared settings event bus. Mirror `PI_PERSONA_LEG` /
36
+ `PI_PERSONA_CHILD`, and `pi-persona-deferred-input` by env/customType only.
37
+ - Model configuration changes are not persona switches;
38
+ `/persona models` must leave Mind's scope unchanged. Do not duplicate persona discovery here.
39
+ - Wakes are display-only (`appendEntry` + toast). Never `sendUserMessage` / `triggerTurn`.
40
+ - Lifecycle generations bind capture/injection UI state to the accepting session. An accepted
41
+ session-only capture may remain on its original native branch; its acknowledgement must not leak to a new turn.
42
+ - Nested tool results reach only their caller. Nudge on a blocked report only when the top-level
43
+ result actually relays it; bound provenance by `parentToolCallId` and clear it on lifecycle change.
44
+ - Persona/shared and repository LTM are durable across sessions. Every long-term `remember` must
45
+ explicitly choose `scope: project|persona|shared`; there is no implicit persona destination.
46
+ `project` with long term stays in the repository; promotion defaults to project and requires an
47
+ owned source. `project-long` is the optimizer target; `project` still means working STM. Shared
48
+ writes use `scope: shared`, not a boolean. Scope expresses API routing intent, not authenticated
49
+ user consent. Use session for task-specific/uncertain choices (models, strategies, task constraints),
50
+ project for stable repository facts, persona for intent across all projects of the same persona,
51
+ and shared only for intent across personas. Existing persona facts are not automatically reassigned.
52
+ STM/backlog auto-delete after ~48h. `kind: objective` never changes the requested lifetime. Explicit
53
+ session notes live in Pi's native active branch, survive compaction/resume when session history is
54
+ persistent, are not copied to a new session, and stay absent from delegated workers. A non-persistent
55
+ host session reports in-memory storage; forget is a branch-local tombstone.
56
+ - AUTO strong direct-user cue capture writes only native session notes; even explicit “remember”,
57
+ “from now on”, or durable wording does not write project/persona/shared stores or dirty optimizer
58
+ targets. Capture feedback states session-only lifetime and does not claim durable storage. Prompt
59
+ mode remains nudge-only; off disables capture; foreign/quoted/worker content remains non-direct.
60
+ Broader persistence requires a deliberate memory call with an explicit scope chosen from actual intent.
61
+ Never fall back to durable storage if a native session append fails.
62
+ - Bare `/mind optimize` (also `/mind optimize all`) reviews one bounded window for each currently allowed nonshared target, sequentially, at most three workers; home allows persona only. Named `/mind optimize project|project-long|persona` stays single-target. All explicit work bypasses automatic dirty/token/cooldown and auto-off gates but not owner, busy, validation or CAS safeguards; retain the real Persona worker, strict JSON/provenance/preview/apply/receipt path, exact session model, no fallback/tools, per-tier outcomes, and honest bounded no-op/skip diagnostics. A skipped page is not proof the whole target is empty. Stop a batch on cancellation, owner change or failed/refused/uncertain work. Shared is refused with a pointer to `/mind optimize inspect shared`; it is excluded from all LLM automatic and explicit writes. Inspect/history defaults stay unchanged. 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.
63
+ - Optimization inspect/stage exact replacements/apply a short-lived plan ID remains available through explicit inspect/show/apply commands and the memory tool. Similarity
64
+ is advisory. Compare the original raw store fingerprint under its lock; reject stale/expired
65
+ plans, invalid stores, ownership mixing, provenance overflow and extended STM expiry.
66
+ Lifecycle changes invalidate plans. Automatic semantic review is user-authorized and on by default
67
+ unless `PI_PERSONA_MIND_OPTIMIZE=off`; session commands may switch it immediately. Queue after a
68
+ successful remember/promotion. First eligible burst has no token floor; later attempts need dirty
69
+ memories AND 1M main-session input tokens since the prior launch (exclude output/cache/worker usage).
70
+ Actual explicit worker launches also reset the automatic token/cooldown baseline and persist their
71
+ completed digests, but interrupted explicit work never grants automatic retry. Usage alone never
72
+ marks memories dirty. Coalesce 2s after `agent_settled` while idle with no queued
73
+ work; cool down 5min between actual attempts. Only the interrupted attempt can retry without the
74
+ token floor, after a later settled event and cooldown, once per unchanged input digest; a second
75
+ interruption parks that window (bypassed by rotation, never settled) until its records change, and a
76
+ `failed` worker result is terminal for its input. A skipped window never settles another window's
77
+ pending retry: that retry is dropped without a receipt when its own input is gone, else stays owed. One worker per instance; unchanged semantic
78
+ digests skip review. New input, agent start,
79
+ off or owner changes cancel and invalidate plans. Use a real visible
80
+ Persona-hosted Mind worker on exactly the session model, no fallback or arbitrary tools. Give it
81
+ at most 12 full source records/24k JSON characters, a 180s deadline and at most 4 strict JSON
82
+ replacement operations/12 source IDs each, then validate/apply through parent-owned
83
+ provenance/freshness/CAS checks. Automatic operations must consolidate at least two compatible
84
+ supplied sources; single-record rewrites remain explicit-only. A window without a same-kind pair
85
+ cannot start an automatic model call or consume its first-attempt allowance. Shared memories and
86
+ age-based deletion remain excluded. Persist the full proposal audit before apply, but keep it out
87
+ of the automatic transcript; show one informative `mind` toast on successful change, no routine
88
+ result card, and no no-op card or toast. Keep durable history and guarded undo available.
89
+ Manual detail and important warnings remain visible. Worker completion is not proof of semantic truth.
90
+ - Evidence-grounded knowledge review is explicit and separate from consolidation. F10 actions close
91
+ the overlay before native prompts. Parent-selected, bounded trusted-repository files and active-branch
92
+ user-role text are evidence, never instructions or authenticated truth. Use the real exact-session-model
93
+ Persona worker with no tools; validate closed findings/citations. Corrections remain staged in a separate
94
+ optimizer until user approval and source/owner freshness checks, including the guarded store callback.
95
+ Shared/session are not review write targets. Retirement is recommendation-only, not an implicit delete.
96
+ Reuse maintenance admission/accounting; interrupted reviews never earn automatic retries.
97
+ - For `pi-persona:card-frame:v1`, custom-entry renderers pass their original entry object as optional
98
+ `expansionKey`; Persona owns click/keyboard synchronization. Mind must not duplicate interaction state.
99
+ - F10 queries `pi-persona:inspector-frame:v1` on opening and uses Persona's geometry/painter;
100
+ do not duplicate its frame or fall back to another styling implementation. Missing service affects
101
+ only opening the inspector. Page keys use actual rendered content capacity; native search Input
102
+ receives focus only while searching. Keep owner revocation and close-before-action safeguards.
103
+ - Rotate completed automatic review over older records/pages; account for actual byte admission,
104
+ preserve newest-fact inclusion, and never mark stopped/interrupted work as completed. No unbounded
105
+ sweeper. Optimizer receipts precede replacement and persist at most 32/2MiB per target; unresolved
106
+ prepared receipts are protected unless the store still holds the bytes they were prepared against
107
+ (then the replacement is not in effect and they settle rejected; same store, owner and target only). Undo compares affected facts and owner generation under lock,
108
+ never restores expired STM or clobbers unrelated writes. Propagate uncertain-finalization warnings.
109
+ - Retrieval uses one lexical/tag/path ranker; do not introduce a second recall policy. Matches preserve Unicode and exact-term priority; identifier/vowel-accent bridges have lower weight.
110
+ Keep numeric versions exact and retain negation/exception terms. Test false positives as well as hits.
111
+ Ordinary `remember supersedes` receipts share the optimizer's history/CAS protocol and retain
112
+ before/after provenance. Historical facts never join active recall or injection; ordinary receipt
113
+ undo is refused. History lists metadata and explicit receipt details are paged, not full-store dumps.
114
+ Explicit handoffs use one bounded project sidecar (32 entries per persona, 128 KiB for the file) with persona ownership,
115
+ native session/branch origin and revision checks. No automatic expiry/eviction, injection or worker
116
+ access. Complete requires a resolution; pending text remains historical. Recheck accepting owners
117
+ under the store lock and reject malformed/unsafe persisted fields.
118
+ All injected tiers share a 2400-token planning estimate (UTF-8 bytes/3); session notes use up to 600. Include
119
+ wrappers, separators and omission counts, keep whole excerpts, and never exempt pinned facts from
120
+ the bound. The estimate and synthetic evaluation are not billing or semantic-quality guarantees.
121
+ - `exactOptionalPropertyTypes`: omit optional props; do not assign `undefined`.
122
+
123
+ ## Done
124
+
125
+ `npm run typecheck` clean, `npm test` green, full `npm audit --audit-level=low`, and package dry-run
126
+ inspection. Re-run after final edits. Keep published files explicit; no tests, drafts or local artifacts.
127
+
128
+ ### Accepted platform diagnostics
129
+
130
+ - Windows runs have zero expected skips. On other platforms, only the two Windows recovery-gate
131
+ sharing-violation cases in `test/store.test.ts` are intentionally skipped: they exercise the
132
+ Windows-specific `EPERM` handling, not the POSIX path. Report them as untested, never passed.
133
+ - Evidence symlink-boundary tests are required on every platform. Windows test accounts need
134
+ Developer Mode or `SeCreateSymbolicLinkPrivilege`; missing support fails rather than silently
135
+ dropping those security checks. No other conditional skips are accepted.