@nklisch/pi-enhanced 0.4.3 → 0.5.0

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.
Files changed (47) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +1 -1
  3. package/node_modules/@nklisch/pi-astral-pocket/README.md +127 -93
  4. package/node_modules/@nklisch/pi-astral-pocket/package.json +2 -2
  5. package/node_modules/@nklisch/pi-astral-pocket/src/distiller.ts +196 -183
  6. package/node_modules/@nklisch/pi-astral-pocket/src/guidance.ts +26 -62
  7. package/node_modules/@nklisch/pi-astral-pocket/src/index.ts +8 -5
  8. package/node_modules/@nklisch/pi-astral-pocket/src/sessions.ts +10 -3
  9. package/node_modules/@nklisch/pi-astral-pocket/src/store.ts +439 -321
  10. package/node_modules/@nklisch/pi-astral-pocket/src/tools.ts +172 -66
  11. package/node_modules/@nklisch/pi-clearance/docs/CONFIGURATION.md +3 -3
  12. package/node_modules/@nklisch/pi-clearance/docs/DEVELOPER_GUIDE.md +11 -12
  13. package/node_modules/@nklisch/pi-clearance/docs/PACK_AUTHORING.md +5 -5
  14. package/node_modules/@nklisch/pi-clearance/docs/PRINCIPLES.md +1 -2
  15. package/node_modules/@nklisch/pi-clearance/docs/REFERENCE_PATTERNS.md +13 -19
  16. package/node_modules/@nklisch/pi-clearance/docs/SPEC.md +4 -4
  17. package/node_modules/@nklisch/pi-clearance/docs/USER_GUIDE.md +2 -3
  18. package/node_modules/@nklisch/pi-clearance/docs/VISION.md +1 -1
  19. package/node_modules/@nklisch/pi-clearance/native/clearance-core.win32-x64-msvc.node +0 -0
  20. package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/README.md +2 -2
  21. package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/docs/VISION.md +2 -3
  22. package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/docs/architecture/architecture.md +105 -886
  23. package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/docs/decisions/0002-extensions-on-a-minimal-core.md +44 -78
  24. package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/docs/decisions/0003-publish-bundled-type-declarations.md +28 -57
  25. package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/docs/decisions/0004-reconsider-ui-direction.md +49 -261
  26. package/node_modules/@nklisch/pi-plugins/package.json +2 -2
  27. package/package.json +2 -2
  28. package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/docs/architecture/client-server-opportunities.md +0 -127
  29. package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/docs/architecture/history/phase-1-api-boundary.md +0 -8
  30. package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/docs/architecture/history/phase-10-structural-decomposition.md +0 -141
  31. package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/docs/architecture/history/phase-11-closure-to-class.md +0 -100
  32. package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/docs/architecture/history/phase-12-complexity-test-fixtures.md +0 -55
  33. package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/docs/architecture/history/phase-13-remaining-smells.md +0 -88
  34. package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/docs/architecture/history/phase-14-strip-policy.md +0 -49
  35. package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/docs/architecture/history/phase-15-domain-model-evolution.md +0 -73
  36. package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/docs/architecture/history/phase-16-invert-dependencies.md +0 -144
  37. package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/docs/architecture/history/phase-17-core-consolidation.md +0 -214
  38. package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/docs/architecture/history/phase-18-reconsider-ui.md +0 -166
  39. package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/docs/architecture/history/phase-19-implement-ui-decisions.md +0 -282
  40. package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/docs/architecture/history/phase-2-remove-scheduling.md +0 -9
  41. package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/docs/architecture/history/phase-3-remove-rpc-groupjoin.md +0 -11
  42. package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/docs/architecture/history/phase-4-implement-service.md +0 -8
  43. package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/docs/architecture/history/phase-5-decompose-index.md +0 -42
  44. package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/docs/architecture/history/phase-7-encapsulation.md +0 -173
  45. package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/docs/architecture/history/phase-8-testability.md +0 -103
  46. package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/docs/architecture/history/phase-9-observation-ctx.md +0 -122
  47. package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/docs/decisions/0001-deferred-patches.md +0 -80
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.5.0 — 2026-09-07
4
+
5
+ ### Changed
6
+
7
+ - Bundle Astral Pocket 0.3.0: repository-scoped navigation clues and hard-won technical pitfalls replace broad startup digests. User preferences and delivery history no longer belong in memory.
8
+ - Keep legacy notes and raw session history behind explicit historical recall. Add note retirement and complete-card startup budgets; exclude the active session from past-session search.
9
+
10
+ ### Migration
11
+
12
+ - Old notes are not automatically promoted to startup learning. Existing Markdown remains available through explicit historical recall; no user data is deleted automatically. User preferences belong in user-maintained `AGENTS.md`, not Pocket.
13
+
14
+ ## v0.4.4 — 2026-09-06
15
+
16
+ ### Fixed
17
+
18
+ - Bundle Plugin Host `0.8.4` and select MCP adapter `2.21.0-nklisch.4` for reliable MCP discovery, schemas, subscriptions, and OAuth recovery.
19
+
3
20
  ## v0.4.3 — Prepared
4
21
 
5
22
  ### Fixed
package/README.md CHANGED
@@ -25,7 +25,7 @@ install commands, or versions to coordinate.
25
25
  | pi-background-tasks | Background jobs with polling, status, cancellation, and wakeups. |
26
26
  | pi-model-modes | System-prompt adaptation per model and mode. |
27
27
  | pi-conveniences | `/exit`, `.agents/AGENTS.md` context loading, context-window footer, subagent model listing. |
28
- | pi-astral-pocket | Persistent note pocket and past-session recall, active only for gpt-6-astra. |
28
+ | pi-astral-pocket | Repository navigation clues and technical pitfalls, with explicit historical recall; active only for gpt-6-astra. |
29
29
  | pi-fff-compat | FFF-indexed file search through Pi-native find/grep semantics (no fuzzy fallback). |
30
30
 
31
31
  (`@nklisch/pi-zai-research` remains published separately if you prefer its
@@ -1,37 +1,104 @@
1
1
  # @nklisch/pi-astral-pocket
2
2
 
3
- Astral Pocket keeps durable Markdown notes across Pi sessions. It activates only
4
- when the current model is `openai-codex/gpt-6-astra`.
5
-
6
- Notes normally belong to the current Git repository. Subdirectories and linked
7
- worktrees share the same local repository identity. Explicit global notes can
8
- carry a general preference or a conditional lesson between repositories.
9
- Foreign repository memories are not injected into the current session.
10
-
11
- ## Notes and digest
12
-
13
- The extension adds two tools while Astra is active:
14
-
15
- - `pocket_note` saves a durable note. Its default scope is `project`. The caller
16
- may set `scope: "global"` only for an intentionally portable preference or
17
- observation.
18
- - `pocket_recall` searches current-project and global notes, plus past Astra
19
- sessions from the current repository. `full: true` returns larger excerpts.
20
- `scope: "all"` deliberately includes other repositories and labels their
21
- results as cross-repository precedent. Recall returns at most 20 matches from
22
- each selected source.
23
-
24
- Distillation means extracting durable decisions, constraints, preferences, and
25
- pitfalls from an idle session into a source-linked note. Automatic extraction
26
- always stays project-scoped. A digest is then rebuilt from the actual notes for
27
- the current repository. Explicit global notes have a separate, smaller digest.
28
- The extension never builds a new digest by recursively summarizing an old one.
29
-
30
- Memory is historical evidence, not an instruction source. The current user
31
- request and current repository guidance take priority. Verify remembered facts
32
- when their relevance or freshness is uncertain.
33
-
34
- ## Commands
3
+ Astral Pocket helps an agent find its way around a repository and avoid repeating
4
+ expensive technical mistakes. It stores short Markdown learnings across Pi
5
+ sessions and activates only for `openai-codex/gpt-6-astra`.
6
+
7
+ ## What belongs in memory
8
+
9
+ A learning is either:
10
+
11
+ - **Navigation:** a non-obvious place to start investigating a problem, with the
12
+ relevant file, symbol, or evidence pointer.
13
+ - **Pitfall:** a concrete failure, its cause or diagnostic clue, and what avoids
14
+ repeating the investigation.
15
+
16
+ For example, knowing that a nested model call needs explicitly resolved
17
+ credentials can save debugging an otherwise unexplained authentication failure.
18
+ A general description of the repository's architecture does not belong here.
19
+
20
+ User preferences, permissions, model choices, review instructions, and other
21
+ user decisions are not Pocket learnings. Those belong in user-maintained
22
+ `AGENTS.md` only when the user explicitly chooses to record them. Pocket does not
23
+ write that file. Delivery history and facts already explained by current
24
+ repository documentation also stay out of startup memory.
25
+
26
+ ## What enters the prompt
27
+
28
+ Before an agent run, Pocket adds complete, source-linked learning cards from the
29
+ current repository. Each card identifies its kind, last note-update date, and
30
+ note file. That date does not mean the underlying fact was reverified.
31
+
32
+ Selection considers every eligible note, prioritizes deliberate agent-authored
33
+ notes over automatic extraction, and alternates navigation clues with pitfalls
34
+ within those groups. Newer notes come first within each kind. Selection is not
35
+ tailored to the current question.
36
+
37
+ The default card budget is 6,000 characters; cards that do not fit are omitted
38
+ rather than cut mid-sentence. The summary reports omitted material so the agent
39
+ can search when needed.
40
+
41
+ Subdirectories and linked Git worktrees share one repository identity. Foreign
42
+ repository notes and global notes are not injected. Older, unclassified notes
43
+ are not automatically promoted into learnings. Old aggregate digest files are
44
+ not read or recursively summarized.
45
+
46
+ Cards are investigation clues, not current engineering authority. Read current
47
+ code and foundations before relying on a remembered claim. A useful discovery
48
+ can become obsolete; replace or retire it rather than keeping two competing
49
+ current-looking descriptions.
50
+
51
+ ## Saving and recalling
52
+
53
+ `pocket_note` saves a repository-scoped navigation or pitfall learning with a
54
+ short title and actionable body. Saving requires `kind`, `title`, and `body`;
55
+ `kind` is `navigation` or `pitfall`. An optional `evidence` pointer can name the
56
+ relevant file, symbol, test, or source. Keep one technical lesson per note.
57
+
58
+ To update an agent-authored note, supply its filename as `replace`. To retire a
59
+ note, call `pocket_note` with `action: "retire"` and `noteFile`. Saving a new note
60
+ with `supersedes: ["old-note.md"]` retires the old note after saving its
61
+ replacement. Retired notes leave startup and default recall immediately.
62
+
63
+ Retiring a generated note also excludes its source session from further
64
+ automatic extraction, including rebuilds. This prevents a model from reviving
65
+ the same obsolete claim under a different title. Other active learnings from
66
+ that session remain available; later useful discoveries can be saved manually.
67
+
68
+ `pocket_recall` searches active repository learnings by default. Search terms
69
+ are case-insensitive and must all match; there is no semantic search service.
70
+ Start with one focused lookup and expand only when the result helps.
71
+
72
+ Use `includeHistory: true` to include legacy, retired, or global notes. Use
73
+ `source: "sessions"` or `source: "both"` to search raw session transcripts.
74
+ `scope: "all"` adds other repositories. Historical results are labeled as
75
+ precedent, not current truth. The active
76
+ session is excluded from past-session searches. Cross-repository scope does not
77
+ implicitly opt into legacy or retired notes.
78
+
79
+ Returned text is an excerpt, not a model-generated summary. `full: true` requests
80
+ a larger excerpt, not the complete file. Recall returns at most 20 matches per
81
+ selected source.
82
+
83
+ ## Automatic extraction
84
+
85
+ Distillation extracts a few narrowly useful technical learnings from an idle
86
+ session. It does not produce a general session summary or a repository digest.
87
+ The model is instructed to omit preferences, user decisions, delivery history,
88
+ documented facts, and unsupported conclusions. Structured output validates the
89
+ learning shape; it cannot guarantee perfect judgment about arbitrary prose.
90
+
91
+ By default, an activation-time pass considers changed Astra sessions from the
92
+ current repository that have been idle for at least six hours and were modified
93
+ within the last 30 days. It processes at most 16 sessions, oldest eligible first.
94
+ The active session is excluded. Changed sessions replace their generated notes;
95
+ an extraction with no useful learnings removes obsolete generated notes.
96
+
97
+ There is no daemon. Work runs on Astra activation or an explicit command.
98
+ Switching away from Astra, disabling Pocket, reloading, or shutting down cancels
99
+ the session-owned pass.
100
+
101
+ ## Controls
35
102
 
36
103
  ```text
37
104
  /pocket status
@@ -48,24 +115,13 @@ when their relevance or freshness is uncertain.
48
115
  /pocket rebuild
49
116
  ```
50
117
 
51
- `/pocket status` shows the requested and resolved model, requested and effective
52
- reasoning, whether distillation is enabled, and the last pass outcome. Pi may
53
- map a requested reasoning level to a model-supported effort; status reports that
54
- mapping.
55
-
56
- `/pocket distill` retries changed or previously failed session work and stale
57
- digests. `/pocket rebuild` also forces the current project and global digest
58
- caches to be regenerated. Both commands require an active Astra session and an
59
- enabled distiller.
60
-
61
- Changing the model or reasoning setting cancels the current pass before starting
62
- a replacement. Switching away from Astra, disabling the pocket, reloading, or
63
- shutting down cancels the session-owned pass.
118
+ `/pocket status` reports activation, model availability, requested/effective
119
+ reasoning, and the last pass outcome. `/pocket distill` processes eligible new or
120
+ changed sources. `/pocket rebuild` forces a bounded re-extraction pass, preserving
121
+ manual notes and retirements; it no longer rebuilds an aggregate digest. Both
122
+ require an active Astra session and an enabled distiller.
64
123
 
65
- ## Configuration
66
-
67
- Configuration lives in `config.json`. All fields are optional. These are the
68
- defaults:
124
+ Configuration lives in `config.json`. All fields are optional:
69
125
 
70
126
  ```json
71
127
  {
@@ -81,52 +137,29 @@ defaults:
81
137
  }
82
138
  ```
83
139
 
84
- The model must use the exact `provider/modelId` form. Astral Pocket asks Pi's
85
- model registry for current authentication and headers on every request. It does
86
- not silently select another provider when that model is unavailable. A malformed
87
- configuration falls back to defaults without blocking note access.
140
+ The model uses the exact `provider/modelId` form. Authentication and headers are
141
+ resolved through Pi's model registry on every request. There is no silent
142
+ provider fallback. Malformed configuration falls back to defaults without
143
+ blocking note access.
88
144
 
89
- ## Storage and recovery
145
+ ## Storage and privacy
90
146
 
91
- Files are stored under `~/.pi/agent/astral-pocket/`, or under
92
- `$PI_CODING_AGENT_DIR/astral-pocket/` when that variable is set:
147
+ Storage lives under `~/.pi/agent/astral-pocket/`, or under
148
+ `$PI_CODING_AGENT_DIR/astral-pocket/` when set. `notes/` holds canonical Markdown;
149
+ `POCKET.md` is a rebuildable registry and `distilled.json` records extraction
150
+ progress. Legacy summary and digest files are unused. Upgrading does not delete
151
+ existing notes automatically.
93
152
 
94
- ```text
95
- config.json settings
96
- notes/ canonical Markdown notes
97
- digests/ rebuildable per-project and global digest caches
98
- POCKET.md rebuildable note registry
99
- SUMMARY.md legacy-compatible derived summary surface
100
- distilled.json processed source revisions and digest fingerprints
101
- ```
153
+ Files are atomically replaced, and Pi's file mutation queue serializes writes
154
+ inside one process. Concurrent Pi processes can still duplicate extraction work
155
+ or publish competing derived registries; this is not cross-process locking.
156
+ Canonical notes remain accessible when a model request fails.
102
157
 
103
- Canonical note files remain readable if a model call fails or a derived registry
104
- or digest lags. Changed sessions replace their one stable generated note. If a
105
- fresh extraction returns `NONE`, that generated note is removed rather than
106
- leaving superseded knowledge behind. Legacy notes are not rewritten: notes with
107
- project metadata remain project-scoped, while notes with unknown scope appear
108
- only in an explicit all-project recall.
109
-
110
- There is no daemon or global worker. Work runs only on Astra activation or an
111
- explicit command. Pi's file mutation queue serializes writes inside one process,
112
- and files are atomically replaced to avoid torn output. Two simultaneous Pi
113
- processes can still duplicate model calls or publish competing derived snapshots;
114
- the extension does not claim cross-process locking. A later rebuild recovers the
115
- registry and digest from canonical notes.
116
-
117
- ## Privacy
118
-
119
- Session files can contain prompts, tool arguments, and tool results. Distillation
120
- uses a bounded transcript that omits most tool output and instructs the model to
121
- exclude credentials, personal data, quoted instructions, rejected proposals,
122
- and facts already documented in the repository. A prompt cannot guarantee that
123
- every sensitive value is removed.
124
-
125
- Choosing a distiller model sends the bounded source material to that model's
126
- configured provider. Astral Pocket never falls back to a different provider.
127
- Use `pocket_recall` without `full` first; larger session excerpts can re-surface
128
- sensitive text from past work. Use all-project recall only when you intentionally
129
- want foreign repository precedent.
158
+ Session transcripts can contain prompts, tool arguments, and results. Extraction
159
+ sends a bounded transcript to the configured model provider and asks it to omit
160
+ secrets and personal data. Prompt instructions cannot guarantee redaction.
161
+ Explicit raw-session recall can also surface old preferences or sensitive text;
162
+ those transcripts are evidence, not automatically accepted learnings.
130
163
 
131
164
  ## Install
132
165
 
@@ -134,5 +167,6 @@ want foreign repository precedent.
134
167
  pi install npm:@nklisch/pi-enhanced
135
168
  ```
136
169
 
137
- Astral Pocket is currently distributed as part of Pi Enhanced rather than as a
138
- standalone npm package.
170
+ Astral Pocket is distributed inside Pi Enhanced rather than as a standalone npm
171
+ package. Update Pi Enhanced to receive Pocket changes, then reload Pi or start a
172
+ new session to activate the new extension code.
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@nklisch/pi-astral-pocket",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "private": false,
5
- "description": "Model-gated note pocket and session recall for gpt-6-astra",
5
+ "description": "Repository navigation clues and hard-won technical learnings for gpt-6-astra",
6
6
  "type": "module",
7
7
  "author": {
8
8
  "name": "Nathan Klisch"