@xprnvd/pi-context-view 0.0.0-stage → 0.7.2

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 (58) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +112 -2
  3. package/package.json +55 -5
  4. package/src/capture/adjustments.ts +649 -0
  5. package/src/capture/attribution.ts +25 -0
  6. package/src/capture/builder.ts +128 -0
  7. package/src/capture/diff.ts +455 -0
  8. package/src/capture/dispatch.ts +36 -0
  9. package/src/capture/guard.ts +287 -0
  10. package/src/capture/messages.ts +246 -0
  11. package/src/capture/payload.ts +584 -0
  12. package/src/capture/redact.ts +58 -0
  13. package/src/capture/register.ts +129 -0
  14. package/src/capture/request.ts +218 -0
  15. package/src/capture/tools.ts +69 -0
  16. package/src/capture/tracker.ts +71 -0
  17. package/src/command.ts +164 -0
  18. package/src/compaction.ts +57 -0
  19. package/src/config.ts +408 -0
  20. package/src/index.ts +191 -0
  21. package/src/injections.ts +670 -0
  22. package/src/measure.ts +887 -0
  23. package/src/message-preview.ts +72 -0
  24. package/src/model-identity.ts +48 -0
  25. package/src/model.ts +548 -0
  26. package/src/pi-version.ts +29 -0
  27. package/src/probe/failure.ts +34 -0
  28. package/src/probe/filter.ts +126 -0
  29. package/src/probe/silent-probe.ts +349 -0
  30. package/src/probe/token.ts +28 -0
  31. package/src/probe/trigger.ts +178 -0
  32. package/src/probe/view.ts +26 -0
  33. package/src/projection.ts +122 -0
  34. package/src/prompt-additions.ts +226 -0
  35. package/src/prompt-blocks.ts +80 -0
  36. package/src/replay.ts +234 -0
  37. package/src/settings.ts +62 -0
  38. package/src/snapshot.ts +188 -0
  39. package/src/system-prompt-rows.ts +311 -0
  40. package/src/text.ts +46 -0
  41. package/src/token-diff.ts +211 -0
  42. package/src/transcript.ts +19 -0
  43. package/src/ui/color.ts +52 -0
  44. package/src/ui/diff-preview.ts +181 -0
  45. package/src/ui/injections-model.ts +378 -0
  46. package/src/ui/injections-view.ts +729 -0
  47. package/src/ui/json-preview.ts +41 -0
  48. package/src/ui/layout.ts +148 -0
  49. package/src/ui/markers.ts +253 -0
  50. package/src/ui/notes.ts +117 -0
  51. package/src/ui/section-preview.ts +267 -0
  52. package/src/ui/skill-preview.ts +83 -0
  53. package/src/ui/status-bar.ts +94 -0
  54. package/src/ui/usage-map.ts +157 -0
  55. package/src/ui/usage-preview.ts +194 -0
  56. package/src/ui/usage-view.ts +1255 -0
  57. package/src/ui/wheel.ts +65 -0
  58. 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,113 @@
1
- # Temporary Holding Version
1
+ # pi-context-view
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
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&amp;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
39
+
40
+
41
+ ### `/context`
42
+
43
+ See what fills your context, for example, what survives compaction:
44
+
45
+ ![Context usage view showing estimated context composition](https://media.githubusercontent.com/media/dimk90/pi-context-view/e9f75e538ada31af0c1ba3517bad0a13f06050e6/doc/images/context-usage.gif)
46
+
47
+
48
+ ### `/context injections`
49
+
50
+ Inspect hidden parts of the context, such as tool definitions:
51
+
52
+ ![Context injections view and item preview](https://media.githubusercontent.com/media/dimk90/pi-context-view/e9f75e538ada31af0c1ba3517bad0a13f06050e6/doc/images/context-injections.gif)
53
+
54
+ ### Zoom
55
+
56
+ Zoom in for a more detailed breakdown of large context windows, such as
57
+ 1M-token windows:
58
+
59
+ ![Zoom feature](https://media.githubusercontent.com/media/dimk90/pi-context-view/e9f75e538ada31af0c1ba3517bad0a13f06050e6/doc/images/zoom.gif)
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
+ ![Terrain and rainbow palettes](https://media.githubusercontent.com/media/dimk90/pi-context-view/e9f75e538ada31af0c1ba3517bad0a13f06050e6/doc/images/palettes.png)
89
+
90
+ See the [theme color reference](https://github.com/dimk90/pi-context-view/blob/develop/doc/PI-THEME-COLORS.md)
91
+ for color names that follow the current theme.
92
+
93
+ ### Map Size
94
+
95
+ You can configure the number of rows and columns in the `Context Usage` map:
96
+
97
+ ![Map size demo](https://media.githubusercontent.com/media/dimk90/pi-context-view/2bc280f758d88fc0ac6396e921c7e697c9016086/doc/images/map-sizes.png)
98
+
99
+
100
+ ## Context Footprint
101
+
102
+ `pi-context-view` adds nothing to the model context. Opening a view before the
103
+ first turn may run one [silent probe](doc/architecture/probe.md)
104
+ that sends no request and leaves only blank entries, omitted from future context.
105
+ Set `"autoProbing": false` in the [config](https://github.com/dimk90/pi-context-view/blob/master/doc/CONFIG.md#silent-probe) to disable it.
106
+
107
+ ## My Other Stuff
108
+
109
+ 📌 [S-VHS](https://github.com/dimk90/s-vhs) - terminal recorder used to create the demo GIFs.
110
+
111
+ ## License
112
+
113
+ [MIT](https://github.com/dimk90/pi-context-view/blob/master/LICENSE)
package/package.json CHANGED
@@ -1,6 +1,56 @@
1
1
  {
2
- "name": "@xprnvd/pi-context-view",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
2
+ "name": "@xprnvd/pi-context-view",
3
+ "version": "0.7.2",
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/dimk90/pi-context-view#readme",
13
+ "bugs": {
14
+ "url": "https://github.com/dimk90/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
+ }