@xprnvd/pi-context-view 0.0.0-stage → 0.8.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.
- package/LICENSE +21 -0
- package/README.md +114 -2
- package/package.json +55 -5
- package/src/capture/adjustments.ts +649 -0
- package/src/capture/attribution.ts +25 -0
- package/src/capture/builder.ts +128 -0
- package/src/capture/diff.ts +514 -0
- package/src/capture/dispatch.ts +36 -0
- package/src/capture/guard.ts +287 -0
- package/src/capture/messages.ts +246 -0
- package/src/capture/payload.ts +584 -0
- package/src/capture/redact.ts +58 -0
- package/src/capture/register.ts +129 -0
- package/src/capture/request.ts +251 -0
- package/src/capture/tools.ts +69 -0
- package/src/capture/tracker.ts +71 -0
- package/src/command.ts +164 -0
- package/src/compaction.ts +57 -0
- package/src/config.ts +408 -0
- package/src/index.ts +191 -0
- package/src/injections.ts +670 -0
- package/src/measure.ts +887 -0
- package/src/message-preview.ts +72 -0
- package/src/model-identity.ts +48 -0
- package/src/model.ts +548 -0
- package/src/pi-version.ts +29 -0
- package/src/probe/failure.ts +34 -0
- package/src/probe/filter.ts +126 -0
- package/src/probe/silent-probe.ts +349 -0
- package/src/probe/token.ts +28 -0
- package/src/probe/trigger.ts +178 -0
- package/src/probe/view.ts +26 -0
- package/src/projection.ts +122 -0
- package/src/prompt-additions.ts +226 -0
- package/src/prompt-blocks.ts +80 -0
- package/src/replay.ts +234 -0
- package/src/settings.ts +62 -0
- package/src/snapshot.ts +188 -0
- package/src/system-prompt-rows.ts +311 -0
- package/src/text.ts +46 -0
- package/src/token-diff.ts +211 -0
- package/src/transcript.ts +19 -0
- package/src/ui/color.ts +52 -0
- package/src/ui/diff-preview.ts +181 -0
- package/src/ui/injections-model.ts +487 -0
- package/src/ui/injections-view.ts +1023 -0
- package/src/ui/json-preview.ts +41 -0
- package/src/ui/layout.ts +161 -0
- package/src/ui/markers.ts +253 -0
- package/src/ui/notes.ts +117 -0
- package/src/ui/search.ts +427 -0
- package/src/ui/section-preview.ts +267 -0
- package/src/ui/skill-preview.ts +83 -0
- package/src/ui/status-bar.ts +94 -0
- package/src/ui/usage-map.ts +157 -0
- package/src/ui/usage-preview.ts +202 -0
- package/src/ui/usage-view.ts +1428 -0
- package/src/ui/wheel.ts +65 -0
- package/src/usage.ts +461 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Dmitry Makarov
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,115 @@
|
|
|
1
|
-
#
|
|
1
|
+
# pi-context-view
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img width="456" src="https://media.githubusercontent.com/media/dimk90/pi-context-view/9a9f9f4fafaa09c77759485d53c42f8694650755/doc/images/pi-context-view.png">
|
|
5
|
+
<br>
|
|
6
|
+
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square" alt="License: MIT"></a>
|
|
7
|
+
<a href="https://www.npmjs.com/package/pi-context-view"><img src="https://img.shields.io/npm/v/pi-context-view?style=flat-square&logoColor=white" alt="npm version"></a>
|
|
8
|
+
<a href="https://pi.dev/packages/pi-context-view"><img src="https://img.shields.io/badge/Pi-Package-6366F1?style=flat-square" alt="Pi Package"></a>
|
|
9
|
+
<a href="https://www.npmjs.com/package/pi-context-view"><img src="https://img.shields.io/npm/dm/pi-context-view?label=Downloads&style=flat-square" alt="npm downloads"></a>
|
|
10
|
+
<a href="https://discord.com/channels/1456806362351669492/1531004733873979532"><img src="https://img.shields.io/static/v1?label=%20&message=Chat&color=5865F2&labelColor=555&style=flat-square&logo=discord&logoColor=white" alt="Discord"></a>
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
<br>
|
|
14
|
+
|
|
15
|
+
[Pi](https://pi.dev) extension that visualizes context usage and lets you inspect the parts you
|
|
16
|
+
normally can't see: the system prompt, tool definitions, and instructions
|
|
17
|
+
injected by other extensions.
|
|
18
|
+
|
|
19
|
+
## Features
|
|
20
|
+
|
|
21
|
+
- **Context usage map** - visualize used and free context space, grouped by
|
|
22
|
+
category (tools, skills, messages, and more).
|
|
23
|
+
|
|
24
|
+
- **Context injections** - explore the hidden parts of the context: the
|
|
25
|
+
system prompt, tool definitions, and extension injections, including
|
|
26
|
+
changes that extensions make only to the request sent to the model.
|
|
27
|
+
|
|
28
|
+
## Commands
|
|
29
|
+
|
|
30
|
+
- `/context` - shorthand for `/context usage`.
|
|
31
|
+
- `/context usage` - open the context usage visualization.
|
|
32
|
+
- `/context injections` - explore the latest request's injections: its system
|
|
33
|
+
prompt, tool definitions, and extension contributions.
|
|
34
|
+
- `/context config` - create the global configuration file populated with
|
|
35
|
+
defaults, useful for
|
|
36
|
+
[customization](https://github.com/dimk90/pi-context-view#customization).
|
|
37
|
+
|
|
38
|
+
## Demo: `/context`
|
|
39
|
+
|
|
40
|
+
See what fills your context, for example, what survives compaction:
|
|
41
|
+
|
|
42
|
+

|
|
43
|
+
➥ Pi theme in this demo: [`dark-legacy`](https://github.com/dimk90/pi-context-view/blob/master/doc/dark-legacy.json).
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
## Demo: `/context injections`
|
|
47
|
+
|
|
48
|
+
Inspect hidden parts of the context, such as tool definitions:
|
|
49
|
+
|
|
50
|
+

|
|
51
|
+
➥ Pi theme in this demo: [`dark-legacy`](https://github.com/dimk90/pi-context-view/blob/master/doc/dark-legacy.json).
|
|
52
|
+
|
|
53
|
+
## Demo: Zoom
|
|
54
|
+
|
|
55
|
+
Zoom in for a more detailed breakdown of large context windows, such as
|
|
56
|
+
1M-token windows:
|
|
57
|
+
|
|
58
|
+

|
|
59
|
+
➥ Pi theme in this demo: [`dark-legacy`](https://github.com/dimk90/pi-context-view/blob/master/doc/dark-legacy.json).
|
|
60
|
+
|
|
61
|
+
## Install
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
pi install npm:pi-context-view
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Customization
|
|
68
|
+
|
|
69
|
+
Currently, you can customize only the colors and dimensions of the `Context Usage` map.
|
|
70
|
+
|
|
71
|
+
To get started, create a configuration file populated with the current defaults:
|
|
72
|
+
|
|
73
|
+
```text
|
|
74
|
+
/context config
|
|
75
|
+
```
|
|
76
|
+
➥ This creates `~/.pi/agent/extensions/pi-context-view.json`.
|
|
77
|
+
|
|
78
|
+
See the [configuration reference](https://github.com/dimk90/pi-context-view/blob/master/doc/CONFIG.md)
|
|
79
|
+
for each parameter's meaning and default value.
|
|
80
|
+
|
|
81
|
+
### Category Colors
|
|
82
|
+
|
|
83
|
+
You can use theme color names to match your current theme or hex values for
|
|
84
|
+
colors that stay the same across themes. Here are examples of custom
|
|
85
|
+
[terrain](https://github.com/dimk90/pi-context-view/blob/master/doc/palettes/terrain.json) and
|
|
86
|
+
[rainbow](https://github.com/dimk90/pi-context-view/blob/master/doc/palettes/rainbow.json) palettes:
|
|
87
|
+
|
|
88
|
+

|
|
89
|
+
➥ Pi theme in this demo: [`dark-legacy`](https://github.com/dimk90/pi-context-view/blob/master/doc/dark-legacy.json).
|
|
90
|
+
|
|
91
|
+
See the [theme color reference](https://github.com/dimk90/pi-context-view/blob/develop/doc/PI-THEME-COLORS.md)
|
|
92
|
+
for color names that follow the current theme.
|
|
93
|
+
|
|
94
|
+
### Map Size
|
|
95
|
+
|
|
96
|
+
You can configure the number of rows and columns in the `Context Usage` map:
|
|
97
|
+
|
|
98
|
+

|
|
99
|
+
➥ Pi theme in this demo: [`dark-legacy`](https://github.com/dimk90/pi-context-view/blob/master/doc/dark-legacy.json).
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
## Context Footprint
|
|
103
|
+
|
|
104
|
+
`pi-context-view` adds nothing to the model context. Opening a view before the
|
|
105
|
+
first turn may run one [silent probe](doc/architecture/probe.md)
|
|
106
|
+
that sends no request and leaves only blank entries, omitted from future context.
|
|
107
|
+
Set `"autoProbing": false` in the [config](https://github.com/dimk90/pi-context-view/blob/master/doc/CONFIG.md#silent-probe) to disable it.
|
|
108
|
+
|
|
109
|
+
## My Other Stuff
|
|
110
|
+
|
|
111
|
+
📌 [S-VHS](https://github.com/dimk90/s-vhs) - terminal recorder used to create the demo GIFs.
|
|
112
|
+
|
|
113
|
+
## License
|
|
114
|
+
|
|
115
|
+
[MIT](https://github.com/dimk90/pi-context-view/blob/master/LICENSE)
|
package/package.json
CHANGED
|
@@ -1,6 +1,56 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "@xprnvd/pi-context-view",
|
|
3
|
+
"version": "0.8.0",
|
|
4
|
+
"description": "Pi extension to visualize context usage and inspect the hidden parts: base prompt, tools defs, and extension injections",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "Dmitry Makarov",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/xprnvd/pi-context-view.git"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/xprnvd/pi-context-view",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/xprnvd/pi-context-view/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"pi",
|
|
18
|
+
"pi-extension",
|
|
19
|
+
"pi-package",
|
|
20
|
+
"coding-agent",
|
|
21
|
+
"context",
|
|
22
|
+
"tokens",
|
|
23
|
+
"tui"
|
|
24
|
+
],
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=22.19.0"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"src",
|
|
30
|
+
"README.md"
|
|
31
|
+
],
|
|
32
|
+
"scripts": {
|
|
33
|
+
"test": "node test/run.ts",
|
|
34
|
+
"check": "tsc --noEmit && pnpm test"
|
|
35
|
+
},
|
|
36
|
+
"pi": {
|
|
37
|
+
"extensions": [
|
|
38
|
+
"./src/index.ts"
|
|
39
|
+
],
|
|
40
|
+
"image": "https://media.githubusercontent.com/media/dimk90/pi-context-view/9a9f9f4fafaa09c77759485d53c42f8694650755/doc/images/pi-context-view.png"
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"@earendil-works/pi-agent-core": "*",
|
|
44
|
+
"@earendil-works/pi-ai": "*",
|
|
45
|
+
"@earendil-works/pi-coding-agent": "*",
|
|
46
|
+
"@earendil-works/pi-tui": "*"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@earendil-works/pi-agent-core": "1.3.0",
|
|
50
|
+
"@earendil-works/pi-ai": "1.3.0",
|
|
51
|
+
"@earendil-works/pi-coding-agent": "1.3.0",
|
|
52
|
+
"@earendil-works/pi-tui": "1.3.0",
|
|
53
|
+
"@types/node": "^22.20.1",
|
|
54
|
+
"typescript": "^7.0.2"
|
|
55
|
+
}
|
|
56
|
+
}
|