pi-rtk 0.1.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/README.md ADDED
@@ -0,0 +1,116 @@
1
+ # RTK Plugin for Pi-Coding-Agent
2
+
3
+ A token reduction plugin for pi-coding-agent that intelligently filters tool output to reduce token consumption by 60-90% while preserving essential information.
4
+
5
+ Based on the RTK (Rust Token Killer) specification from [RTK.md](RTK.md).
6
+
7
+ ## Features
8
+
9
+ - **Source Code Filtering**: Remove comments and normalize whitespace (minimal) or keep only signatures (aggressive)
10
+ - **Build Output Filtering**: Remove compilation noise, keep only errors and warnings
11
+ - **Test Output Aggregation**: Summarize test results, show failures only
12
+ - **Git Compaction**: Compact diffs, status, and log output
13
+ - **Search Result Grouping**: Group grep results by file with counts
14
+ - **Linter Aggregation**: Summarize lint errors by rule and file
15
+ - **ANSI Stripping**: Remove color codes and formatting
16
+ - **Smart Truncation**: Intelligently truncate large outputs
17
+
18
+ ## Installation
19
+
20
+ ### Via npm (recommended)
21
+
22
+ ```bash
23
+ # Install into your pi extensions directory
24
+ cd ~/.pi/agent/extensions
25
+ npm install pi-rtk
26
+ ```
27
+
28
+ Then add to your pi config (`~/.pi/agent/settings.json`):
29
+ ```json
30
+ {
31
+ "extensions": ["pi-rtk"]
32
+ }
33
+ ```
34
+
35
+ ### Manual install
36
+
37
+ ```bash
38
+ # Clone and point pi at the directory
39
+ git clone https://github.com/mcowger/pi-rtk ~/.pi/agent/extensions/pi-rtk
40
+
41
+ # Or load directly via flag
42
+ pi --extension ~/.pi/agent/extensions/pi-rtk
43
+ ```
44
+
45
+ ### Load for a single session
46
+
47
+ ```bash
48
+ pi --extension /path/to/pi-rtk
49
+ ```
50
+
51
+ ## Configuration
52
+
53
+ Create `~/.pi/agent/rtk-config.json`:
54
+
55
+ ```json
56
+ {
57
+ "enabled": true,
58
+ "logSavings": true,
59
+ "showUpdateEvery": 10,
60
+ "techniques": {
61
+ "ansiStripping": true,
62
+ "truncation": { "enabled": true, "maxChars": 10000 },
63
+ "sourceCodeFiltering": "minimal",
64
+ "smartTruncation": { "enabled": true, "maxLines": 200 },
65
+ "testOutputAggregation": true,
66
+ "buildOutputFiltering": true,
67
+ "gitCompaction": true,
68
+ "searchResultGrouping": true,
69
+ "linterAggregation": true
70
+ }
71
+ }
72
+ ```
73
+
74
+ ### Filter Levels
75
+
76
+ - `none`: No filtering applied
77
+ - `minimal`: Remove comments, normalize whitespace
78
+ - `aggressive`: Keep only signatures and structure
79
+
80
+ ## Commands
81
+
82
+ - `/rtk-stats` - Show token savings statistics
83
+ - `/rtk-toggle` - Enable/disable token reduction
84
+ - `/rtk-clear` - Clear metrics history
85
+
86
+ ## Supported Languages
87
+
88
+ - TypeScript/JavaScript
89
+ - Python
90
+ - Rust
91
+ - Go
92
+ - Java
93
+ - C/C++
94
+
95
+ ## Token Savings
96
+
97
+ | Output Type | Expected Savings |
98
+ |-------------|------------------|
99
+ | Source code | 60-90% (aggressive mode) |
100
+ | Build output | 70-90% |
101
+ | Test results | 50-80% |
102
+ | Git output | 60-80% |
103
+ | Search results | 40-60% |
104
+
105
+ ## Architecture
106
+
107
+ The plugin intercepts `tool_result` events and applies appropriate filtering based on:
108
+ - Tool type (bash, read, grep)
109
+ - Command context (build, test, git, etc.)
110
+ - File extension for source code
111
+
112
+ Metrics are tracked in-memory and can be viewed with `/rtk-stats`.
113
+
114
+ ## License
115
+
116
+ MIT - Based on the RTK specification