pi-context-map 0.1.0 → 0.1.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 (3) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +55 -23
  3. package/package.json +6 -1
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Vendex
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,41 +1,73 @@
1
1
  # pi-context-map
2
2
 
3
- A Pi extension that transforms your session's context window into a visual, actionable dashboard.
3
+ A visual context window mapping extension for [Pi](https://pi.dev/) that transforms your abstract token window into a concrete, actionable dashboard.
4
4
 
5
- ## 🚀 Features
5
+ [![Pi Package](https://img.shields.io/badge/Pi-Package-blue)](https://pi.dev/packages)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+ [![npm version](https://img.shields.io/npm/v/pi-context-map.svg)](https://www.npmjs.com/package/pi-context-map)
6
8
 
7
- - **Visual Context Budget**: See exactly how your tokens are distributed between system prompts, history, files, and tool results.
8
- - **Working Set Analysis**: Identify which files are "Active", "Stale", or "Legacy".
9
- - **Token Weighting**: Discover which files are consuming the most context window space.
10
- - **Operation History**: Track how files entered the context (Read 👁️, Write 📝, Edit ✍️).
11
- - **Temporal Mapping**: See a timeline of file access to identify candidates for compaction.
9
+ ## Features
12
10
 
13
- ## 🛠️ Installation
11
+ - **Visual Context Budget**: Real-time breakdown of tokens used by System, History, Files, and Tool Results.
12
+ - **Working Set Analysis**: Categorizes files as `Active`, `Stale`, or `Legacy` based on access recency.
13
+ - **Token Weighting**: Identifies "token hogs" by calculating the approximate size of each file in the window.
14
+ - **Operation Tracking**: Marks files with their last operation (Read 👁️, Write 📝, Edit ✍️).
15
+ - **Temporal Mapping**: Visually maps when files entered the context to identify compaction candidates.
16
+
17
+ ## Installation
14
18
 
15
19
  ```bash
16
20
  pi install npm:pi-context-map
17
21
  ```
18
22
 
19
- ## 📖 Usage
23
+ ## Quick Start
20
24
 
21
- Run the following command in any Pi session:
25
+ Run the mapping command to generate your session dashboard:
22
26
 
23
- `/context-map`
27
+ ```bash
28
+ /context-map
29
+ ```
24
30
 
25
- The extension will analyze your session and generate a standalone HTML report at:
31
+ The extension will analyze the session and create an interactive HTML report at:
26
32
  `~/.pi/context-map/report.html`
27
33
 
28
- ## 📊 How it Works
34
+ ## Context Statuses
35
+
36
+ The extension categorizes files to help you manage context bloat:
37
+
38
+ | Status | Criteria | Action |
39
+ |--------|----------|--------|
40
+ | **Active** | Accessed in last 3 turns | Keep in context |
41
+ | **Stale** | Accessed 4-10 turns ago | Monitor for removal |
42
+ | **Legacy** | Accessed > 10 turns ago | Prime candidate for compaction |
43
+
44
+ ## How It Works
45
+
46
+ 1. **Scanning**: The analyzer iterates through the session history, identifying all `tool_use` calls involving file operations.
47
+ 2. **Weighting**: It extracts the content length of tool results and applies a token heuristic (approx. 4 chars/token).
48
+ 3. **Categorization**: It calculates the temporal distance between the current turn and the last file access.
49
+ 4. **Visualization**: It generates a standalone HTML dashboard featuring a token budget bar and a file-weight grid.
50
+
51
+ ## Compatibility
52
+
53
+ - ✅ Works with any Pi session regardless of model.
54
+ - ✅ Compatible with `pi-ultra-compact` (use together for a "Scan $\to$ Compress" workflow).
55
+ - ✅ Compatible with `gentle-engram` and `gentle-pi`.
56
+
57
+ ## Contributing
58
+
59
+ Contributions are welcome! Please feel free to submit a Pull Request.
60
+
61
+ 1. Fork the repository
62
+ 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
63
+ 3. Commit your changes (`git commit -m 'feat: add amazing feature'`)
64
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
65
+ 5. Open a Pull Request
66
+
67
+ ## License
29
68
 
30
- The extension scans the session's message history to build a map of the "Working Set":
31
- 1. **Scanning**: Every `tool_use` call for `read`, `write`, or `edit` is tracked.
32
- 2. **Weighting**: Content length is converted to estimated tokens.
33
- 3. **Categorization**:
34
- - **Active**: Accessed in the last 3 turns.
35
- - **Stale**: Accessed in the last 10 turns.
36
- - **Legacy**: Accessed > 10 turns ago.
37
- 4. **Visualization**: Data is injected into a high-performance HTML dashboard.
69
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
38
70
 
39
- ## ⚖️ License
71
+ ## Acknowledgments
40
72
 
41
- MIT
73
+ - [Pi](https://pi.dev/) - The AI coding agent
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-context-map",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "A Pi extension that visualizes the current session context window and token distribution.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -10,6 +10,7 @@
10
10
  },
11
11
  "keywords": [
12
12
  "pi",
13
+ "pi-package",
13
14
  "extension",
14
15
  "context",
15
16
  "visualization",
@@ -27,6 +28,10 @@
27
28
  ]
28
29
  },
29
30
  "dependencies": {},
31
+ "peerDependencies": {
32
+ "@earendil-works/pi-ai": "*",
33
+ "@earendil-works/pi-coding-agent": "*"
34
+ },
30
35
  "devDependencies": {
31
36
  "typescript": "^5.0.0",
32
37
  "@types/node": "^20.0.0"