pi-blackhole 0.5.5 → 0.5.7
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/CHANGELOG.md +41 -0
- package/README.md +17 -19
- package/dist/index.js +155 -136
- package/index.ts +4 -0
- package/package.json +15 -15
- package/src/commands/memory.ts +7 -4
- package/src/commands/pi-vcc.ts +1 -1
- package/src/core/brief.ts +4 -47
- package/src/core/build-sections.ts +152 -28
- package/src/core/config-env.ts +2 -0
- package/src/core/content.ts +25 -2
- package/src/core/sanitize.ts +4 -0
- package/src/core/search-entries.ts +44 -9
- package/src/core/segment.ts +109 -0
- package/src/core/summarize.ts +249 -35
- package/src/core/unified-config.ts +11 -0
- package/src/extract/commits.ts +298 -27
- package/src/extract/file-touch.ts +1367 -0
- package/src/extract/files.ts +203 -38
- package/src/extract/git-status.ts +102 -0
- package/src/extract/goals.ts +3 -3
- package/src/extract/preferences.ts +42 -3
- package/src/hooks/before-compact.ts +35 -1
- package/src/hooks/cosmetic-output.ts +239 -0
- package/src/om/agents/agent-context.ts +67 -0
- package/src/om/agents/dropper/agent.ts +3 -11
- package/src/om/agents/observer/agent.ts +3 -11
- package/src/om/agents/reflector/agent.ts +3 -11
- package/src/om/compaction-trigger.ts +50 -12
- package/src/om/consolidation.ts +60 -53
- package/src/om/inline-compaction.ts +47 -1
- package/src/om/model-budget.ts +2 -2
- package/src/om/runtime.ts +13 -0
- package/src/om/status-bar.ts +352 -0
- package/src/om/tokens.ts +6 -2
- package/src/pi-base/blackhole-settings.ts +21 -0
- package/src/project-recall/corpus.ts +4 -4
- package/src/project-recall/dedup.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,47 @@
|
|
|
2
2
|
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
+
## [0.5.7] - 2026-09-21
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- **Footer status bar.** pi-blackhole now shows live state in the pi footer (config key `statusBar`, default on; env `PI_BLACKHOLE_STATUSBAR`): three token gauges — O (transcript since the last observer run), P (observation pool fill), X (context since the last compaction) — plus worker spinners, `✓ +N` completion events, and compaction notes with their trigger reason. Gauges color by fill: dim under 80%, theme warning color from 80%, theme error color at 100%. The bar reads in-process state (`runtime.config`, `model-budget.ts`, `ledger/progress.ts`, `runtime.consolidationPhase`), so its numbers match `/blackhole-memory` status; it adds no file polling and no threshold guessing, only a 1-second in-process poll of the runtime state. If you ran the standalone `blackhole-status.ts` footer extension before, remove it: two writers on the same `setStatus` key race.
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- **Pi 0.87 is supported.** The `@earendil-works/*` devDependencies move to `0.87.0` in lockstep and the dependabot `>=0.87.0` hold is removed ([#118](https://github.com/k0valik/pi-blackhole/issues/118)). `peerDependencies` (`>=0.85.1 <1.0.0`) is unchanged: the observational-memory system-prompt carrier is probed at runtime, so consolidation keeps its prompt on 0.85/0.86 (legacy `AgentContext.systemPrompt`) and 0.87+ (leading transcript system message) — see Fixed.
|
|
14
|
+
- **CI runs on pull requests targeting `dev` too.** `ci.yml` previously triggered only for `pull_request → main`, so PRs merged into the working branch were gated by bot reviews alone. The full gate (build → typecheck → lint → test → format:check) now covers both branches.
|
|
15
|
+
- **Installs work under pnpm's built-in minimum-release-age policy.** pnpm 11 enforces a 24-hour minimum release age by default, which rejected the brand-new `@earendil-works/*@0.87.0` set. The toolchain pin moves to `pnpm@11.27.1` and those versions are listed in `minimumReleaseAgeExclude` (the previous pin, `11.2.2`, ignored that list), so `pnpm install --frozen-lockfile`, CI, and git-based extension installs no longer wait out the window.
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- **The compact-shape guard follows Pi 0.87's `_refreshFinalizedContext()` indirection.** 0.87 moved the `agent.state.messages` repoint out of `AgentSession.compact()` into a helper, so the guard that requires the write _inside_ `compact()` rejected the class and mid-run inline compaction failed closed on 0.87 ([#117](https://github.com/k0valik/pi-blackhole/issues/117)). The guard now accepts an assignment found one call level deep in one of the class's own prototype methods, and still rejects inherited helpers, deeper indirection, and a helper that only reads the property.
|
|
20
|
+
- **Observational-memory consolidation keeps its system prompt on Pi 0.87.** 0.87 removed `AgentContext.systemPrompt` and now carries the prompt as a leading transcript `system` message, so the observer, reflector, and dropper would have silently run without their prompts. They now build whichever carrier the loaded host reads — probed by the presence of Pi 0.87's `createInitialSystemMessage` helper, not a version allowlist — so 0.85/0.86 keep the legacy field and 0.87+ gets the transcript message ([#118](https://github.com/k0valik/pi-blackhole/issues/118)).
|
|
21
|
+
- **Discover Pi 0.86's bundled host behind its `createRequire` launcher.** Follow the same-package bootstrap file without executing it before locating the runtime chunk, so inline compaction captures the active `AgentSession` instead of patching the unused modular class and falling back to settled compaction. A bootstrap target that is missing, unreadable, or outside the Pi package now leaves the launcher's own source in place, so the direct-import scan still runs instead of being skipped.
|
|
22
|
+
- **Observer preamble cap now applies in auto/off compaction modes.** `observerPreambleMaxTokens` was previously only enforced in manual mode, so auto-mode observer prompts could grow without bound even though the main session prompt stayed capped by `observationsPoolMaxTokens`; the observer now applies the same relevance-ranked selection budget in all modes, defaulting to 30% of `observerChunkMaxTokens` when unset.
|
|
23
|
+
- **Observer preamble cap now covers reflections, and the context guard prices the full prompt.** Reflections were never trimmed (no drop entry type exists for them), leaving a permanently growing floor on the observer preamble; each preamble section is now capped at `observerPreambleMaxTokens` (reflections newest-first). The pre-flight `observer.context_window_exceeded` guard previously measured only `chunkTokens + 8000`, so oversized prompts sailed through and failed every attempt with a provider 400; it now accounts for the rendered preamble and the observer system prompt, skipping the model cleanly instead.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## [0.5.6] - 2026-09-19
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
|
|
31
|
+
- **Pre-compaction output stays visible after compaction** ([#103](https://github.com/k0valik/pi-blackhole/pull/103), thanks @sonSunnoi). After a successful Blackhole compaction, the newest assistant text removed from view is re-rendered as a display-only **Previous output — display only** block, so recent work stays readable without opening `/tree`. Bounded and opt-out: 16 KiB UTF-8 cap with a truncation marker, text only (no tool output, thinking, or images), idempotent per compaction, skipped when the newest dropped text is retained; disabled via `showPreCompactionMessage` (default `true`, env `PI_BLACKHOLE_SHOW_PRE_COMPACTION_MESSAGE`).
|
|
32
|
+
|
|
33
|
+
### Changed
|
|
34
|
+
|
|
35
|
+
- **Minimum supported Pi raised to 0.85.1; compat-floor CI retired.** The `compat-min-supported` job re-pinned the `@earendil-works/*` peers to the `peerDependencies` floor and typechecked against them, going red every time. The extension now builds against the pinned devDependencies (0.85.1) and the peer floor is set to match; `peerDependencies` remains the single source of truth for the declared minimum.
|
|
36
|
+
|
|
37
|
+
### Fixed
|
|
38
|
+
|
|
39
|
+
- **Observer chunk cap now counts every entry type** ([#110](https://github.com/k0valik/pi-blackhole/issues/110)). `capSourceEntriesToTokens` used a hand-rolled type table that had drifted from the trigger's estimator, so `custom_message` entries (text lives in `.content`, not `.summary`) counted as zero tokens and an oversized chunk could exceed `maxTokens`; it now reuses the same `estimateEntryTokens` the trigger uses (CJK-aware), and debug logging exposes the post-cap chunk size and cooldown-skipped models on the normal path.
|
|
40
|
+
- **CJK-aware token accounting, text primitives, and extractor language handling** ([#106](https://github.com/k0valik/pi-blackhole/issues/106), [#105](https://github.com/k0valik/pi-blackhole/issues/105)). Script detection is automatic — no new config keys. `estimateStringTokens` counts CJK scripts as ~1 token/char instead of `ceil(chars/4)`, so every budget built on it (OM `tokenCount`, pool caps, `retainedToolOutputMaxTokens`, worker context pre-check) no longer admits ~3× the configured tokens. Clipping recognizes CJK terminators (`。!?;`, fullwidth included) and pause punctuation instead of hard-cutting space-free text. `recall` word-segments CJK queries via `Intl.Segmenter`, restoring per-term BM25 ranking with script-aware document-length normalization. `[User Preferences]` accepts CJK correction anchors (`不要`/`回退`/`错了`…) and `[Outstanding Context]` CJK failure stems (`失败`/`报错`/`错误`…) with benign-compound guards, scanning the whole fresh window instead of the last 20 blocks.
|
|
41
|
+
- **`[Files And Changes]` and `[Commits]` now extract what actually happened** ([#105](https://github.com/k0valik/pi-blackhole/issues/105)). File attribution correlates tool calls with results (native path args, anchor-based edits, a bash parser for redirects/`sed -i`/`tee`/`cp`/`mv`/`rm`/`curl -o`), sanitizes arg strings so `src/a.ts:10-40` no longer phantoms next to `/repo/src/a.ts`, and adds git grounding tags (`staged`, `new`, `deleted`, …); the collector runs only at compaction time. `[Commits]` uses a quote-aware token parser with a message-recovery chain (segment-scoped `-m`, `-F -` heredocs, the git success line) and precision guards (`--dry-run`, failed commits, non-`git` commands produce nothing).
|
|
42
|
+
- **`[Files And Changes]` display and cross-compaction merge overhauled**. cwd-relative paths, capped counted lists that never shrink after merge, and single-token paths hard-broken by `wrapLongLines` are reassembled; `(#N)` refs on `[Scope change]` and `[Commits]` for `recall` drill-down; session-goal and outstanding-context clips raised to 200.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
5
46
|
## [0.5.5] - 2026-09-15
|
|
6
47
|
|
|
7
48
|
### Changed
|
package/README.md
CHANGED
|
@@ -31,13 +31,12 @@ Then `/reload` or restart Pi. The config file at `~/.pi/agent/pi-blackhole/pi-bl
|
|
|
31
31
|
|
|
32
32
|
## ✨ What's new
|
|
33
33
|
|
|
34
|
-
> **Latest release: [0.5.
|
|
34
|
+
> **Latest release: [0.5.7](CHANGELOG.md)**
|
|
35
35
|
>
|
|
36
|
-
> - **
|
|
37
|
-
> - **
|
|
38
|
-
> - **
|
|
39
|
-
> - **
|
|
40
|
-
> - **Minimum supported Pi is 0.84.3**, and the compat CI job now tracks the `peerDependencies` floor instead of a hardcoded version.
|
|
36
|
+
> - **Pi 0.87 is supported** — inline compaction, the observer/reflector/dropper system prompts, and auto-compaction all work on `0.87.0`. The compact-shape guard follows 0.87's `_refreshFinalizedContext()` helper, the memory workers build whichever prompt carrier the loaded host reads, and `@earendil-works/*` moves to `0.87.0` with the dependabot hold removed. ([#117](https://github.com/k0valik/pi-blackhole/issues/117), [#118](https://github.com/k0valik/pi-blackhole/issues/118))
|
|
37
|
+
> - **Live footer status bar** — `O` (transcript since the last observer run), `P` (observation pool fill) and `X` (context since the last compaction) gauges with color thresholds, plus worker spinners and compaction notes carrying their trigger reason. Config `statusBar`, default on. Remove the standalone `blackhole-status.ts` extension if you ran it: two writers race on the same status key. ([#113](https://github.com/k0valik/pi-blackhole/pull/113))
|
|
38
|
+
> - **Inline compaction finds Pi's bundled host behind the 0.86 `createRequire` launcher** — the adapter follows the same-package bootstrap file without executing it, so it patches the `AgentSession` the host actually runs instead of the unused modular class, which fell back to settled compaction. ([#116](https://github.com/k0valik/pi-blackhole/pull/116))
|
|
39
|
+
> - **Observer prompts are capped in every compaction mode** — `observerPreambleMaxTokens` now applies in `auto`/`off` too and covers reflections (newest first), and the pre-flight context guard prices the rendered preamble plus system prompt, so an oversized prompt skips the model cleanly instead of failing every attempt with a provider 400.
|
|
41
40
|
|
|
42
41
|
See [`CHANGELOG.md`](CHANGELOG.md) for the full history.
|
|
43
42
|
|
|
@@ -74,7 +73,8 @@ Both halves share a single hook and a single output. Together they keep the agen
|
|
|
74
73
|
|
|
75
74
|
All commands work regardless of `compaction` mode — only _when_ auto-compaction fires changes. See [Compaction modes](#compaction-modes) below.
|
|
76
75
|
|
|
77
|
-
|
|
76
|
+
<details>
|
|
77
|
+
<summary>The `recall` tool (agent-facing)</summary>
|
|
78
78
|
|
|
79
79
|
The agent gets one unified `recall` tool that handles every form of historical lookup. Searches read the raw session file directly, bypassing compaction.
|
|
80
80
|
|
|
@@ -96,6 +96,8 @@ Every recall response is capped at `recallResponseMaxChars` (default 48,000 ≈
|
|
|
96
96
|
|
|
97
97
|
The `/blackhole-recall` command exposes the same engine to the user. Results are shown as a collapsible message and auto-fed to the agent as context.
|
|
98
98
|
|
|
99
|
+
</details>
|
|
100
|
+
|
|
99
101
|
---
|
|
100
102
|
|
|
101
103
|
## Compaction modes
|
|
@@ -196,7 +198,8 @@ If any stage fails (model error, rate limit, timeout), remaining stages are skip
|
|
|
196
198
|
|
|
197
199
|
---
|
|
198
200
|
|
|
199
|
-
|
|
201
|
+
<details>
|
|
202
|
+
<summary>What the agent sees after compaction</summary>
|
|
200
203
|
|
|
201
204
|
After compaction, the agent sees something like this (sections appear only when relevant — a session with no git commits won't show `[Commits]`):
|
|
202
205
|
|
|
@@ -249,9 +252,12 @@ Use `recall` with an id to retrieve original context.
|
|
|
249
252
|
|
|
250
253
|
> **Note:** The OM injection format uses `## Reflections` and `## Observations` Markdown headers followed by a brief footer. Each observation and reflection has a 12-char hex identifier the agent (and you, via `/blackhole-recall`) can use to recover source evidence. When no observations or reflections exist, only the short recall-guidance footer is appended.
|
|
251
254
|
|
|
255
|
+
</details>
|
|
256
|
+
|
|
252
257
|
---
|
|
253
258
|
|
|
254
|
-
|
|
259
|
+
<details>
|
|
260
|
+
<summary>Feature comparison</summary>
|
|
255
261
|
|
|
256
262
|
| | pi-blackhole | pi-vcc | pi-obs-memory | Pi default |
|
|
257
263
|
| ------------------------------------------- | ------------ | ------ | ------------- | ---------- |
|
|
@@ -269,6 +275,8 @@ Use `recall` with an id to retrieve original context.
|
|
|
269
275
|
| Unified single-file config | ✓ | — | — | — |
|
|
270
276
|
| Per-session pending state | ✓ | — | — | — |
|
|
271
277
|
|
|
278
|
+
</details>
|
|
279
|
+
|
|
272
280
|
---
|
|
273
281
|
|
|
274
282
|
## Uninstall
|
|
@@ -297,16 +305,6 @@ rm -rf ~/.pi/agent/pi-blackhole
|
|
|
297
305
|
|
|
298
306
|
---
|
|
299
307
|
|
|
300
|
-
## Migration from an older version
|
|
301
|
-
|
|
302
|
-
If you're upgrading from a pre-0.4.0 config (the old `pi-vcc` / `pi-observational-memory` keys, or an early `pi-blackhole` config with `overrideDefaultCompaction` / `noAutoCompact` / `passive`): see **[`docs/MIGRATION-GUIDE.md`](docs/MIGRATION-GUIDE.md)** for the key mapping, semantic changes, and notes on automatic migration.
|
|
303
|
-
|
|
304
|
-
The short version: old keys are auto-migrated in memory at load time and the on-disk file is never mutated. Set the new keys explicitly via `/blackhole settings` (alias `/blackhole configure`) to silence the migration notification.
|
|
305
|
-
|
|
306
|
-
The legacy config surface is documented at **[`docs/OLD_CONFIG.md`](docs/OLD_CONFIG.md)** for reference only — no new keys are added there.
|
|
307
|
-
|
|
308
|
-
---
|
|
309
|
-
|
|
310
308
|
## Credits
|
|
311
309
|
|
|
312
310
|
`pi-blackhole` started as a merge of two upstream projects but has since diverged significantly. The codebase still carries DNA from both:
|