@aeondave/pi-theme-1337 0.0.0-stage → 0.5.1

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 (55) hide show
  1. package/CHANGELOG.md +253 -0
  2. package/LICENSE +21 -0
  3. package/README.md +159 -2
  4. package/assets/banner.png +0 -0
  5. package/assets/palettes.gif +0 -0
  6. package/docs/architecture.md +167 -0
  7. package/docs/configuration.md +87 -0
  8. package/docs/palette-design.md +51 -0
  9. package/docs/theme-motion.md +88 -0
  10. package/package.json +68 -4
  11. package/src/avatar.ts +174 -0
  12. package/src/background.ts +82 -0
  13. package/src/config.ts +357 -0
  14. package/src/diff-spans.ts +77 -0
  15. package/src/editor.ts +443 -0
  16. package/src/format.ts +464 -0
  17. package/src/frame.ts +380 -0
  18. package/src/index.ts +1195 -0
  19. package/src/quota.ts +581 -0
  20. package/src/redraw-guard.ts +79 -0
  21. package/src/run-summary.ts +623 -0
  22. package/src/spinner.ts +72 -0
  23. package/src/terminal-title.ts +67 -0
  24. package/src/tool-activity.ts +216 -0
  25. package/src/tool-adapter.ts +491 -0
  26. package/src/tool-groups.ts +192 -0
  27. package/src/tool-lexicon.ts +200 -0
  28. package/src/tool-view.ts +788 -0
  29. package/src/width.ts +246 -0
  30. package/themes/1337-amber.json +94 -0
  31. package/themes/1337-amber.pi1337 +3 -0
  32. package/themes/1337-cosmos.json +94 -0
  33. package/themes/1337-cosmos.pi1337 +3 -0
  34. package/themes/1337-cyber.json +94 -0
  35. package/themes/1337-cyber.pi1337 +3 -0
  36. package/themes/1337-cyberpunk-2077-edgerunner.json +94 -0
  37. package/themes/1337-cyberpunk-2077-edgerunner.pi1337 +7 -0
  38. package/themes/1337-cyberpunk-2077.json +94 -0
  39. package/themes/1337-cyberpunk-2077.pi1337 +7 -0
  40. package/themes/1337-fallout.json +94 -0
  41. package/themes/1337-fallout.pi1337 +4 -0
  42. package/themes/1337-ice.json +94 -0
  43. package/themes/1337-ice.pi1337 +3 -0
  44. package/themes/1337-magma.json +94 -0
  45. package/themes/1337-magma.pi1337 +1 -0
  46. package/themes/1337-neon.json +94 -0
  47. package/themes/1337-neon.pi1337 +3 -0
  48. package/themes/1337-poison.json +94 -0
  49. package/themes/1337-poison.pi1337 +3 -0
  50. package/themes/1337-skynet-dark.json +94 -0
  51. package/themes/1337-skynet-dark.pi1337 +4 -0
  52. package/themes/1337-skynet.json +94 -0
  53. package/themes/1337-skynet.pi1337 +4 -0
  54. package/themes/1337.json +95 -0
  55. package/themes/1337.pi1337 +3 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,253 @@
1
+ # Changelog
2
+
3
+ ## [0.5.1] - 2026-11-18
4
+
5
+ - Publish to npm as `@aeondave/pi-theme-1337`: install with
6
+ `pi install npm:@aeondave/pi-theme-1337`. The Git source keeps working.
7
+ - Replace the banner with real Pi sessions in three palettes above a strip of all thirteen, and add
8
+ an animation that shows one session in every palette. The README opens with install and a short
9
+ summary; the full feature list is one click away.
10
+ - `npm run test:parity` measures against the installed development `pi-tui` by default instead of
11
+ needing a `../pi` checkout, which failed outright when that checkout had no dependencies.
12
+ - Run typecheck, tests, the parity sweep and the dependency audit in CI on Linux, macOS and
13
+ Windows, with Dependabot keeping the two Pi development packages aligned.
14
+
15
+ ## [0.5.0] - 2026-11-17
16
+
17
+ - Add Cosmos (`1337-cosmos`, alias `cosmos`): starlit mauve text and pastel
18
+ syntax on indigo-black with a star-gold accent and a twinkling-star spinner,
19
+ bringing the collection to thirteen palettes. Its colors come from
20
+ pi-starline's Catppuccin Mocha swatches.
21
+ - Name a long-running tool in the status row: once a call has run for half a
22
+ second, `Running npm test…` takes the workspace segment's place (` +2` when
23
+ other calls run beside it) and leaves when the call ends. After three seconds
24
+ it also carries the elapsed time (`Running npm test… 14s`). The right group
25
+ never moves for it, and fast calls never flash.
26
+ `PI_1337_ACTIVITY=off` (config `activity:false`) hides it.
27
+ - Fold settled exploration: three or more consecutive `read`/`grep`/`find`/`ls`
28
+ rows become one tally row (`● Read 3 files, searched 2 patterns (ctrl+o to
29
+ expand)`) as soon as the third one settles; the tally stays in place and counts
30
+ up while the run goes on. It counts distinct files and patterns, not calls.
31
+ Click the tally to bring
32
+ that run back, or press the expand key to show every row. Failed calls,
33
+ results with images, `bash`, `edit`, `write` and custom tools always keep
34
+ their own rows, and a thinking row ends a run, so only rows that were truly
35
+ adjacent fold. `PI_1337_GROUPS=off` (config `groups:false`) keeps one row per
36
+ call.
37
+ - Quieter tool rows: the title leads while the duration and expand hint recede;
38
+ durations read `4.2s` and are omitted under one second; running output drops
39
+ its `Running:` prefix; short errors lose the lone hint line; write previews
40
+ read `Wrote N lines` with the same number gutter as edits.
41
+ - Running and failed commands preview their newest lines instead of their
42
+ first ones, so a long test run visibly progresses and a failure shows the
43
+ error and exit status; earlier output is announced above them. `npm run`
44
+ output no longer spends a preview row on its leading blank line.
45
+ - Tool rows cost what Pi's own rows cost: the row shell and its clipped lines
46
+ are reused across frames. A 500-row session rendered a frame in 17 ms with the
47
+ theme on and 89 ms with it toggled off; both are now about 1 ms.
48
+ - Keep Pi's theme when it is light: every bundled palette is dark, so the
49
+ package now applies only the framed editor, status row and tool rows there.
50
+ `PI_1337_THEME=<palette>` (or `on`) still forces a palette.
51
+ - Replace unpaired UTF-16 surrogates in labels and tool output with `U+FFFD`
52
+ before measuring: they measured zero columns but painted one, so a row could
53
+ run past the terminal edge.
54
+ - Qualify development dependencies and test fixtures against Pi 1.5.2, and drop
55
+ the root `undici` override: 1.5.2 already depends on 8.12.3, which the
56
+ override would have downgraded.
57
+ - Quiet tool rows say what they found: `· 6 matches`, `· no matches`,
58
+ `· 12 entries`, `· 40 lines`. Read rows show their line range, multi-line
59
+ bash commands show their first line, and a folded run names its files when
60
+ they fit (`Read width.ts, frame.ts · searched 2 patterns`).
61
+ - Move the model identity into the top border, top-right: `provider/model ·
62
+ level`, with a reasoning model's thinking level in the palette's thinking
63
+ color, narrowing to `model · level` and then `model`. The bottom border stays
64
+ plain.
65
+ - Rebuild the status row as two groups: where you are on the left, the
66
+ session's state on the right (`[▰▱▱▱▱] 136.9k/1M · 13% · ~$48.89 +$1.24 ·
67
+ persona`). Decorations go first (the run's spend, then the window, then the
68
+ gauge, which no longer needs a 90-column row), then path detail, then cost
69
+ and tokens; the
70
+ context percentage stays to the end. It reads the same without pi-persona.
71
+ - Show the context window as a denominator (`/200k`, `/1M`) and the current
72
+ run's spend (`+$1.24`), kept after the run settles until the next one.
73
+ - Cost fixes: `0.9996` reads `~$1.00`, a tiny positive total reads `~<$0.001`,
74
+ and a background agent's spend that lands while Pi is idle now updates the
75
+ row. The total itself was verified against Pi's own footer sum.
76
+ - Remove the agent count from the status row: it counted agents only, also
77
+ queued ones, and repeated pi-persona's own widget.
78
+ - Add an end-of-run summary row: duration, files edited with exact +/− lines,
79
+ files written, commands and failures, and the run's estimated cost. Expanded,
80
+ it lists each file. It is stored once as a custom session entry that never
81
+ reaches the model. `PI_1337_SUMMARY=off` (config `summary:false`) turns it off.
82
+ - Show what Pi is doing in the terminal title (a named call, working, waiting
83
+ for you, done, failed) and return to Pi's own title at rest, on toggle-off
84
+ and on exit. `PI_1337_TITLE=off` (config `title:false`) leaves it alone.
85
+ - Draw other extensions' tool rows in the flat frame: a tool with its own
86
+ `renderCall` and `renderResult` now shows one status dot before its call
87
+ lines and its result under `└`, with no background box. The lines are the
88
+ renderer's own — never rewritten, wrapped or sanitized; one too wide is
89
+ clipped — and its hooks still run once per update with Pi's own row state.
90
+ `/theme-1337` off returns existing rows to Pi's box. Renderers that declare
91
+ `renderShell: "self"` or define only one of the two hooks, results with
92
+ images and image-protocol output stay in Pi's box, and these rows never
93
+ fold. So does a row whose renderer returned a line that is not a string
94
+ (`[undefined, "x"]`): Pi's box paints it as Pi always did.
95
+ - Show a running command's timeout as stock Pi does: `● $ npm test (timeout
96
+ 30s)` while the command is pending or running, as one dim rung that is the
97
+ first to go on a narrow row and leaves with the final result. Only a
98
+ finite, positive number of seconds Pi's shell would accept is printed.
99
+ - An empty third-party row (no line in either slot) takes no line, with the
100
+ redesign on or off. Off, that is one blank row less than stock Pi, which
101
+ prints a separator above its empty box; rows with blank lines or one empty
102
+ slot match Pi exactly.
103
+ - Show a run clock in the status row: when no tool is named and the run has
104
+ lasted three seconds, `Working… 45s` takes the workspace segment's place. It
105
+ counts from the run's start across retries and follow-ups, hides during
106
+ prompts and compaction, moves nothing on the right and adds no timer.
107
+ `PI_1337_ACTIVITY=off` hides it with the tool label.
108
+ - Say when background work is still running: if pi-persona reports agents,
109
+ monitors, timers or scripts when a run settles, the summary row reads
110
+ `● Turn ended in 9.0s · 7 tool calls · ~$0.08 · waiting on 3 agents, 1
111
+ monitor` with a muted dot instead of `Done`, narrowing to `waiting on 4
112
+ background tasks`, and the terminal title reads `◌ Waiting on 3 agents — …`
113
+ until the work ends, then `✓ Done`. Nothing about it enters the status row.
114
+ - Show where a run's time went on the expanded summary row: `model 1m 32s ·
115
+ tools 42s · 48 tok/s`. `tools` is the run's time not spent waiting on the
116
+ model, so it includes retry back-off, compaction and prompts. The line is
117
+ shown whole or not at all: on a row too narrow for `model 1m 32s` it takes
118
+ no line. Summary rows written earlier are unchanged.
119
+ - Show thinking time on the same line, as part of the model time: `model 1m
120
+ 32s (40s thinking) · tools 42s · 48 tok/s`. It is measured from the stream's
121
+ own thinking events, shown from one second up, and goes after the rate and
122
+ before the tools time when the row narrows.
123
+ - Fix the status row clipping the branch to a stub (`…/proj · m…`,
124
+ `/…/src/pi-1337 · fe…`). The left group now gives up whole details: the
125
+ session name, then the branch, then the path down to its last folder. A
126
+ branch is shown whole or not at all; a long session name may shorten, to no
127
+ fewer than nine characters and `…`. The activity label likewise shortens to
128
+ no fewer than seven characters and `…`, and below that the workspace stays.
129
+ - Keep context and cost current inside a turn: when a tool call starts, the
130
+ row shows the tokens and spend of the response that launched it instead of
131
+ the figures from before it.
132
+ - Follow `!!` in the editor: the prompt marker stays `$` and turns dim, as Pi
133
+ paints a command whose output is kept out of the model's context.
134
+ - Share the editor slot with other extensions: `/theme-1337` off restores an
135
+ editor another extension had installed before this one, and leaves in place
136
+ one installed after it. It used to reset the slot to Pi's own editor either
137
+ way. When another extension installs its editor over the frame while the
138
+ redesign is on, Pi's footer and working row come back, so the workspace,
139
+ model, context, cost and spinner stay visible; the frame returns at the next
140
+ `/theme-1337` or session start.
141
+ - Show subscription quota in the status row, between the cost and the
142
+ persona: `5h 43% · wk 12%` (percent used of the five-hour and weekly
143
+ windows), `wk 85%` when one window is known, `limit` once the usage limit is
144
+ reached. The percentage warns above 70% and turns to the error color above
145
+ 90%; above 70% it stays while the row narrows, and a calm one is a
146
+ decoration that goes after the gauge. It is read only from what the
147
+ provider sends with a response — no request is made for it — so it appears
148
+ after the first response and shows nothing for providers that report
149
+ nothing. Seen on live accounts: Anthropic's subscription headers (weekly
150
+ window) and OpenAI's usage-limit error on a ChatGPT login. Implemented from
151
+ the published Codex client format, not yet seen live: the Codex headers and
152
+ stream event, and Anthropic's five-hour window. `PI_1337_QUOTA=off` (config
153
+ `quota:false`) turns it off.
154
+ - Fix a crash when expanding a built-in tool row whose arguments cannot be
155
+ serialized (a BigInt or a circular value): the row now shows `[unavailable
156
+ arguments]`.
157
+ - A summary row's failure count names what failed once the total is dropped
158
+ (`1 command failed`, `2 calls failed`); a row with no commands reads
159
+ `wrote 2 files · 1 call failed`.
160
+ - Add `PI_1337_MAX_WIDTH` (config `maxWidth`): the framed box's width cap,
161
+ default 100, `0` or `full` for none.
162
+ - Fix workspace labels directly under home (`~/src/project`, not
163
+ `~/…/src/project`) and reword the toggle notice to `pi-theme-1337 on/off`.
164
+ - Ship `CHANGELOG.md` in the package so Pi can show update notes.
165
+ - Add `npm run preview`, which renders a sample session and the framed editor in
166
+ any bundled palette without launching Pi.
167
+
168
+ ## [0.4.2] - 2026-11-12
169
+
170
+ - Rename the package to `pi-theme-1337` and the command to `/theme-1337`;
171
+ remove the old `/pi-1337` command.
172
+
173
+ ## [0.4.1] - 2026-11-12
174
+
175
+ - Qualify development dependencies and test fixtures against Pi 1.5.1.
176
+ - Describe the full variety of palettes in the README.
177
+ - Emphasize separate changed spans in recorded edit diffs while preserving common
178
+ text between edits, Unicode graphemes, semantic colors and narrow-width layout.
179
+ - Pair replacements within contiguous change groups after line-number shifts;
180
+ keep uneven, clipped or over-budget groups as full-line colored previews.
181
+
182
+ ## [0.4.0] - 2026-10-25
183
+
184
+ ### Themes
185
+
186
+ - Add Cyberpunk 2077: dominant neon yellow on black with azure accents.
187
+ - Add Cyberpunk 2077 Edgerunner: burgundy-black surfaces, reddish text,
188
+ yellow titles, and cyan accents.
189
+ - Add Magma and Skynet Dark, bringing the collection to twelve palettes.
190
+ - Rename Split to Poison. Update an explicit `split` / `1337-split` setting to
191
+ `poison` / `1337-poison`.
192
+ - Refine the default palette toward 1985 green phosphor with amber accents;
193
+ distinguish Poison's emerald and orchid, and strengthen Cyber and Neon.
194
+ - Rework Skynet around Terminator 2's warm-white diagnostic HUD and crimson
195
+ accents; Skynet Dark keeps the red-on-near-black direction.
196
+
197
+ ### Fixes
198
+
199
+ - Preserve a bundled palette chosen through `/settings` across `/reload`, even
200
+ when `config.json` contains an older startup theme. An explicit
201
+ `PI_1337_THEME` palette still takes precedence.
202
+
203
+ ### Documentation
204
+
205
+ - Refresh the README with a palette banner, faster setup, and a concise theme
206
+ catalog; move configuration and architecture details into dedicated docs.
207
+ - Document palette references, contrast measurements, and motion profiles.
208
+
209
+ ### Development
210
+
211
+ - Override Pi 1.4.0's Undici dependency to patched 8.12.2 in the repository's
212
+ development install. Pi package pins stay matched at 1.4.0; this does not
213
+ update the user's installed Pi host.
214
+
215
+ ## [0.3.0] - 2026-10-23
216
+
217
+ - Target Pi 1.4.0 with compact tool views, expandable output, and theme-aware
218
+ diff previews that preserve execution and custom renderers.
219
+ - Add distinct status-row color roles, a space-aware context gauge, and
220
+ API-equivalent cost estimates.
221
+ - Refresh eight palettes and add validated per-theme text spinner profiles,
222
+ including Skynet's two-row crimson pyramid.
223
+ - Remove bundled PNG avatars while retaining optional user-configured avatars.
224
+ - Improve renderer caching, toggle restoration, and HTML-export state handling.
225
+
226
+ ## [0.2.0] - 2026-10-20
227
+
228
+ - Update to Pi 1.3 and improve narrow status rows, activity settlement,
229
+ compaction recovery, usage accounting, and mouse-cache behavior.
230
+ - Correct avatar fallback geometry and raise unchanged diff-text contrast.
231
+ - Keep RPC, JSON, and print modes free of presentation side effects.
232
+
233
+ ## [0.1.2] - 2026-10-02
234
+
235
+ - Update to Pi 1.0, correct autocomplete and mouse positioning, and improve
236
+ Kitty avatar centering.
237
+ - Move theme options into `.pi1337` sidecars and add optional config-file
238
+ settings with environment overrides.
239
+
240
+ ## [0.1.1] - 2026-09-16
241
+
242
+ ### Performance
243
+
244
+ - Cache unchanged editor layout during spinner-only redraws while preserving
245
+ invalidation for input, text, padding, resize, autocomplete, and mouse input.
246
+ - Coalesce out-of-band stderr repair redraws into a bounded 16 ms frame window,
247
+ including asynchronous write bursts.
248
+
249
+ ### Documentation and tests
250
+
251
+ - Document the editor cache and redraw guard behavior.
252
+ - Add regression coverage for editor layout reuse, coordinate translation, and
253
+ asynchronous redraw coalescing.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 pi-1337 contributors
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,160 @@
1
- # Temporary Holding Version
1
+ <p align="center">
2
+ <img src="assets/banner.png" alt="pi-theme-1337: the same Pi session in the phosphor, neon and cyberpunk palettes, above a strip of all thirteen palettes">
3
+ </p>
2
4
 
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.
5
+ <h3 align="center">Thirteen dark palettes and a framed terminal editor for Pi.</h3>
6
+
7
+ <p align="center">
8
+ CRT, cyberpunk, synthwave and HUD-inspired palettes, with an extension that moves the editor<br>
9
+ and the session status you actually read into one centered frame.
10
+ </p>
11
+
12
+ <p align="center">
13
+ <a href="#install">Install</a> ·
14
+ <a href="#what-it-adds">What it adds</a> ·
15
+ <a href="#palettes">Palettes</a> ·
16
+ <a href="#use">Use</a>
17
+ </p>
18
+
19
+ ![One Pi session shown in each of the thirteen palettes in turn: phosphor, amber, ice, cyber, cyberpunk, edgerunner, neon, cosmos, poison, magma, fallout, skynet and skynet-dark.](assets/palettes.gif)
20
+
21
+ <sub>Banner and animation are real Pi sessions running this package, each on its palette's own
22
+ background (`PI_1337_BG=on`); the model's replies are scripted.</sub>
23
+
24
+ ## Install
25
+
26
+ ```bash
27
+ pi install npm:@aeondave/pi-theme-1337
28
+ ```
29
+
30
+ Then pick a palette in `/settings`. To install from Git instead, use
31
+ `pi install git:github.com/AeonDave/pi-theme-1337`; from a local clone, `pi install .` in the
32
+ repository directory.
33
+
34
+ Requires Pi and Node.js 22.19 or later.
35
+
36
+ ## What it adds
37
+
38
+ - **A framed editor.** A centered, rounded box with the model and thinking level in its top border
39
+ and one status row: workspace, branch, context use, cost and subscription quota.
40
+ - **A status row that tells you what is running.** A long tool call is named in place
41
+ (`Running npm test… 14s`) without moving the rest of the row.
42
+ - **A compact transcript.** One row per tool call, exploration runs folded into a tally, edit
43
+ previews with the changed spans emphasised, and errors visible while collapsed.
44
+ - **An end-of-run summary** (`● Done in 2m 14s · edited 3 files +42 −7 · 6 commands, 1 failed`) and
45
+ a terminal title that shows the run state.
46
+ - **Thirteen palettes**, selectable in `/settings` and kept across restarts.
47
+ - **Reversible.** `/theme-1337` turns the redesign off and gives Pi's own chrome back.
48
+
49
+ The extension changes presentation only: Pi's editor behavior, tool execution and prompts stay as
50
+ they are, and other extensions' tool renderers keep their content.
51
+
52
+ <details>
53
+ <summary>Every detail</summary>
54
+
55
+ - A centered, rounded editor with a prompt marker and activity spinner, the model and thinking level in its top border (`openai/gpt-6.1-sol · xhigh`), and a status row: workspace, branch and session on the left; context usage against its window, estimated cost, the current run's spend and the persona on the right (`[▰▱▱▱▱] 136.9k/1M · 13% · ~$48.89 +$1.24 · 💻 Dev`).
56
+ - A status row that names a long-running tool (`Running npm test…`) in the workspace segment's place, without reflowing the rest of the row. When no tool is named, a run that has lasted three seconds shows its clock there instead: `Working… 45s`.
57
+ - A row that narrows by meaning: decorations go first, then path detail, and the context percentage stays visible to the end. The left group gives up whole details — the session name, then the branch, then the path down to its last folder — so a branch is shown whole or not at all, never as `fe…`.
58
+ - Subscription quota in the status row, between the cost and the persona, when the provider reports it: `5h 43% · wk 12%` (percent used of the five-hour and weekly windows), `wk 85%` for one window, or `limit` once the usage limit is reached. It turns to the warning color above 70% and the error color above 90%, and a figure above 70% stays visible while the rest of the row narrows. It comes only from what the provider already sends with each response — the package makes no request of its own — so it appears after the first response and shows nothing for providers that report nothing. Seen on live accounts: Anthropic's subscription headers (the weekly window) and OpenAI's usage-limit error on a ChatGPT login. Read from the published Codex client format but not yet seen live: the Codex headers and stream event, and Anthropic's five-hour window. `PI_1337_QUOTA=off` turns it off.
59
+ - A prompt marker that follows Pi's bash mode: `$` for `!command`, and a dim `$` for `!!command`, whose output stays out of the model's context.
60
+ - An end-of-run summary row in the transcript: `● Done in 2m 14s · edited 3 files +42 −7 · wrote 1 file · 6 commands, 1 failed · ~$1.24`. Expand tools (ctrl+o) to list each file and see where the time went (`model 1m 32s (40s thinking) · tools 42s · 48 tok/s`; thinking is part of the model time, and `tools` is everything that was not waiting on the model). A run that is retried or continued counts as one run. When pi-persona still has background work running, the row reads `● Turn ended in 9.0s · 7 tool calls · ~$0.08 · waiting on 3 agents, 1 timer` instead of `Done`. It is stored as a custom session entry that never reaches the model; changes made by shell commands are not counted.
61
+ - A terminal title that shows the run state (`● Running npm test… — repo`, `? Waiting for you`, `✓ Done`) and Pi's own title at rest. After a clean run it reads `◌ Waiting on 3 agents` until pi-persona's background work ends.
62
+ - Thirteen Pi themes that you can choose in `/settings`; Pi keeps the selected bundled theme across restarts. All thirteen are dark: when Pi is on a light theme the package keeps it and applies only the framed editor, status row and tool rows. Set `PI_1337_THEME=<palette>` (or `on` for the default green) to force a palette anyway.
63
+ - Compact tool transcript rows and theme-aware edit previews, with errors visible while collapsed. Quiet rows end with what they found (`· 6 matches`, `· no matches`, `· 40 lines`) and running or failed commands show their newest lines. A running command also names the timeout it was given (`● $ npm test (timeout 30s)`). Runs of settled reads and searches fold into one tally row — `● Read width.ts, frame.ts · searched 2 patterns`, or `● Read 12 files` when the names do not fit — until you click it or press the expand key.
64
+ - Rows from other extensions' tool renderers in the same flat frame: one status dot before the call, the result under `└`, no background box. Their lines are the renderer's own, unchanged; `/theme-1337` off returns them to Pi's box.
65
+ - A reversible `/theme-1337` toggle and a clean-buffer copy shortcut (`alt+c` by default). Toggling off gives the editor back to an extension that had installed its own before, and leaves alone one installed since. If another extension installs its editor over the frame while the redesign is on, Pi's own footer and working row come back until the next `/theme-1337` or session start, so the workspace, model, context, cost and spinner never go missing.
66
+
67
+ </details>
68
+
69
+ The extension changes presentation only. It leaves Pi's editor behavior, tool execution and prompts in place, and third-party custom tool renderers keep their content: only the frame around their lines changes.
70
+ When pi-persona is installed, the frame shows its persona and includes its child agents' spend in the cost, and the summary row and terminal title say when its background work is still running; the two packages work independently, and the frame is complete without it.
71
+
72
+ Edit previews use Pi's recorded diff, with separate changed spans emphasized inside
73
+ paired replacement lines. Collapsed previews show up to 16 rows; expand for the full
74
+ diff. Uneven change groups and large lines keep line colors without span emphasis.
75
+ Write previews show submitted file content.
76
+
77
+ Folding covers three or more consecutive `read`, `grep`, `find`, and `ls` rows
78
+ with nothing painted between them. Failed calls, results with image attachments,
79
+ `bash`, `edit`, `write`, and custom tools always keep their own rows. Both the
80
+ fold and the status label are fed by Pi's tool and message events alone — no
81
+ execution, schema, or prompt changes — and `PI_1337_GROUPS` / `PI_1337_ACTIVITY`
82
+ turn them off.
83
+
84
+ ## Palettes
85
+
86
+ | Theme | Character |
87
+ | --- | --- |
88
+ | `1337` | Yellow-green phosphor with amber UI accents. |
89
+ | `1337-amber` | Bright amber CRT with cream-gold accents. |
90
+ | `1337-ice` | Cool cyan-blue phosphor. |
91
+ | `1337-cyber` | Indigo surfaces, periwinkle text, and electric cyan. |
92
+ | `1337-cyberpunk-2077` | Neon yellow and cyan-blue on black. |
93
+ | `1337-cyberpunk-2077-edgerunner` | Muted red, yellow titles, and cyan on burgundy-black. |
94
+ | `1337-neon` | Synthwave violet, hot pink, and cyan. |
95
+ | `1337-cosmos` | Starlit mauve and pastel syntax on indigo-black, with a star-gold accent. |
96
+ | `1337-poison` | Emerald green with orchid and cyan accents. |
97
+ | `1337-magma` | Molten coral-orange with crisp cyan accents. |
98
+ | `1337-fallout` | Yellow-lime Pip-Boy phosphor. |
99
+ | `1337-skynet` | Warm-white HUD with red accents on tinted black. |
100
+ | `1337-skynet-dark` | Red-on-near-black Skynet palette. |
101
+
102
+ All palettes share Pi's 51-token theme contract. See [palette design](docs/palette-design.md) for color references and contrast rules.
103
+
104
+ ## Use
105
+
106
+ - Choose `1337` or any `1337-*` palette in `/settings`. The choice persists across restarts and `/reload`.
107
+ - Run `/theme-1337` to turn the editor redesign off or on.
108
+ - Press `alt+c` to copy the editor's logical text without frame characters or added row breaks.
109
+
110
+ `PI_1337_THEME` can explicitly pin a palette, for example `PI_1337_THEME=cyber`. Use `PI_1337_THEME=off` to keep Pi's current theme while using the framed editor.
111
+
112
+ ## Essential settings
113
+
114
+ Settings can go in `~/.pi/agent/1337-theme/config.json`; `PI_CODING_AGENT_DIR` changes Pi's agent directory. Environment variables override matching file settings.
115
+
116
+ ```json
117
+ {
118
+ "copyKey": "alt+c",
119
+ "polish": true
120
+ }
121
+ ```
122
+
123
+ | Variable | Purpose |
124
+ | --- | --- |
125
+ | `PI_1337_THEME` | Select or pin a palette; `off` keeps the current Pi theme. |
126
+ | `PI_1337_COPY_KEY` | Change the clean-copy key; set it empty to disable the shortcut. |
127
+ | `PI_1337_MAX_WIDTH` | Widest framed editor box in columns (default 100); `0` or `full` removes the cap. |
128
+ | `PI_1337_SUMMARY=off` | Write no end-of-run summary rows and hide existing ones. |
129
+ | `PI_1337_TITLE=off` | Leave the terminal title alone. |
130
+ | `PI_1337_QUOTA=off` | Show no subscription quota in the status row and read no response headers for it. |
131
+ | `PI_1337_POLISH=off` | Keep Pi's standard tool transcript renderers. |
132
+ | `PI_1337_ACTIVITY=off` | Stop naming long-running tools in the status row. |
133
+ | `PI_1337_GROUPS=off` | Keep one transcript row per tool call (no folding). |
134
+ | `PI_1337_BG` | Control optional terminal background tint (`on`, `off`, or a hex color). |
135
+ | `PI_1337_DISABLE` | Disable the extension. |
136
+
137
+ See [configuration](docs/configuration.md) for precedence, all options, theme sidecars, and optional avatars.
138
+
139
+ ## Related docs
140
+
141
+ - [Theme motion profiles](docs/theme-motion.md)
142
+ - [Architecture and rendering](docs/architecture.md)
143
+
144
+ ## Development
145
+
146
+ ```bash
147
+ npm install --ignore-scripts
148
+ npm run typecheck
149
+ npm test
150
+ npm run test:parity
151
+ npm run preview
152
+ ```
153
+
154
+ `npm run preview` renders a sample session (tool rows, a folded run, a failure, a diff and the framed editor) in a bundled palette, using the package's real renderers in truecolor. Name palettes as arguments or pass `--all`; `--width N` sets the width and `--plain` strips color for diffing. It never changes your terminal. Bold spans need a real terminal: when piping, run it as `FORCE_COLOR=3 npm run preview`.
155
+
156
+ Development packages are pinned to Pi 1.5.2; wildcard peer dependencies do not promise compatibility with older hosts. The parity sweep measures against the installed development `pi-tui`; set `PI_TUI` to another `pi-tui/dist/index.js` to check the bundle you run.
157
+
158
+ ## License
159
+
160
+ MIT
Binary file
Binary file
@@ -0,0 +1,167 @@
1
+ # Architecture
2
+
3
+ pi-1337 is a Pi package with two parts: thirteen color-only theme files and an extension that presents Pi's editor and tool transcript in a phosphor-style interface. The theme files remain valid Pi palettes; extension-only settings live in adjacent `.pi1337` sidecars.
4
+
5
+ ## Boundaries
6
+
7
+ ```text
8
+ Pi theme JSON ───────────────> Pi theme system
9
+ Pi extension API ─> index.ts ─> editor.ts ─> frame.ts
10
+ └──> tool renderers
11
+ ```
12
+
13
+ `index.ts` owns Pi events, UI changes, and configuration reads. `editor.ts` and the tool adapters connect host components to the presentation code. Pure modules format or lay out data without owning Pi UI state.
14
+
15
+ | Area | Responsibility |
16
+ | --- | --- |
17
+ | `themes/*.json` | Color tokens for each palette. |
18
+ | `src/index.ts` | Extension lifecycle, commands, theme switching, config, and spinner lifecycle. |
19
+ | `src/editor.ts` | Custom editor wrapper that preserves Pi's editing and input behavior. |
20
+ | `src/frame.ts` | Pure frame construction, status layout, and narrow-width degradation. |
21
+ | `src/format.ts` | Pure sanitizers and label, context, cost and run-delta formatting. |
22
+ | `src/tool-activity.ts` | Pure status-row label naming a long-running tool call, and the run clock. |
23
+ | `src/run-summary.ts` | Pure per-run collector and the end-of-run transcript row. |
24
+ | `src/terminal-title.ts` | Pure terminal-title text for each run state. |
25
+ | `src/width.ts` | Shared width measurement seam used by render modules. |
26
+ | `src/tool-view.ts`, `src/tool-adapter.ts` | Compact presentation for tool calls, results, and diffs. |
27
+ | `src/tool-lexicon.ts` | The one vocabulary for built-in tools: row title, status verb, tally clause. |
28
+ | `src/tool-groups.ts` | Pure registry folding runs of settled exploration rows into one tally row. |
29
+ | `src/diff-spans.ts` | Bounded comparison of sanitized replacement bodies. |
30
+ | `src/avatar.ts`, `src/background.ts`, `src/spinner.ts` | Pure parsing/layout and value helpers for optional presentation settings. |
31
+ | `src/redraw-guard.ts` | Pass-through stderr observation and coalesced redraw repair while active. |
32
+
33
+ ## Editor rendering
34
+
35
+ The editor wrapper asks Pi's base editor to render at the space available inside the frame. A pure formatter removes the host's top and bottom rules, adds the rounded outline and side gutters, then centers the result. The prompt marker and spinner occupy reserved gutters; a status row appears inside the bottom edge when autocomplete is closed.
36
+
37
+ The wrapper leaves editing, cursor handling, autocomplete, history, and keybindings to Pi. It uses Pi TUI's exported width functions so the measured frame matches the renderer that paints it. A dependency-free width fallback supports pure module tests.
38
+
39
+ Status values are captured from Pi and extension status sources outside the render path, then formatted into the editor frame. The model identity sits in the top border's right end (`provider/model · level`, narrowing to `model · level` and then `model`). The status row has two groups — where you are on the left, the session's state on the right — and gives up space by meaning: the run's spend, the window denominator, the second quota window, the gauge and a calm quota first, then path detail and the session name, then cost, token count, persona and a quota above 70% (or `limit`), with the context percentage last. The left group gives up whole details, in the order session name, branch, path down to `…/basename`: a branch is an identifier and is shown whole or not at all, while a session name, being free text, may shorten to no fewer than ten columns (nine characters and `…`) before it goes. The activity label that borrows these cells shortens to no fewer than eight columns; with fewer, the workspace keeps its place. Context usage and cost are refreshed on agent, turn and session events, and once more when the first top-level tool call of a response starts: Pi has appended that response to the session by then, so a long call shows current figures. The prompt marker reads the buffer as Pi does: `!` makes it a `bashMode`-colored `$`, `!!` a `dim` one, because that command's output is kept out of the model's context.
40
+
41
+ ## Subscription quota
42
+
43
+ Between the cost and the persona the status row shows the current provider's subscription quota, as percent used: `5h 43% · wk 12%`, `wk 85%` when one window is known, or `limit` once the usage limit is reached. The pure module `src/quota.ts` builds it from three things Pi already hands extensions; the extension makes no request, reads no credential and starts no timer for it.
44
+
45
+ | Source (Pi event) | What is read | Status |
46
+ | --- | --- | --- |
47
+ | Response headers (`after_provider_response`), `anthropic-messages` | `anthropic-ratelimit-unified-{5h,7d}-utilization` (a fraction) and `-reset` (epoch seconds) | Observed on a live subscription; those responses carried the weekly window only. |
48
+ | Assistant message that ended in an error (`message_end`) | `errorMessage` containing the phrase `usage limit` | Observed on OpenAI's ChatGPT login, where it is the only signal: the response is a 200 with no quota headers. |
49
+ | Response headers, `openai-responses` and `openai-codex-responses` | `x-codex-{primary,secondary}-used-percent` (a percent), `-window-minutes`, `-reset-at`, `-reset-after-seconds` | Implemented from the official client's format; not yet seen live. |
50
+ | Raw stream event (`provider_stream_event`), `openai-codex-responses` | `codex.rate_limits` → `rate_limits.primary` / `.secondary` (`used_percent`, `window_minutes`, `reset_at`, `reset_after_seconds`) | Implemented from the shape Pi's own Codex stream test replays; not yet seen live. |
51
+
52
+ Other apis are not read, so providers that report nothing (z.ai, OpenRouter and other `openai-completions` routes) show nothing. The family is chosen by the model's api and only that family's exact header names count. Values must be strict numbers; nothing from a header, an event or an error message is printed — labels come from a canonical duration, and a declared length such as 299 or 10079 minutes snaps to the whole hour or day it lies within 5% of.
53
+
54
+ State is kept per provider, so switching model away and back keeps the figures. A response usually carries a subset of the windows, so each window is kept on its own with the time it was last seen: it leaves when its reset passes or, without a believable reset, thirty minutes after it was last seen. A figure older than thirty minutes is drawn dim while it is calm. Two successful responses in a row with no quota header drop everything known about that provider (the account or its auth changed). `limit` stays until that provider's next assistant message that is an answer; another error or an interrupted attempt leaves it. A response is credited to the model its turn started with, so switching model while a request is in flight does not move one account's figures onto another.
55
+
56
+ The view is rebuilt on events — a response, a message's end, a model or session change, a run or turn boundary — and cached; rendering only reads the cache, so an expired window disappears at the next event rather than on a timer. A quota above 70% (or `limit`) is content and stays while the row narrows, yielding only to the context percentage; a calm one is a decoration that goes after the gauge. Nothing about quota enters the summary row or the terminal title. Not known from any of these sources: the plan, the absolute limit, model-scoped or overage windows, and when a `limit` will lift. `PI_1337_QUOTA=off` turns the feature off.
57
+
58
+ ## Tool views
59
+
60
+ The extension registers renderers for compact tool headers, output previews, and edit diffs. This changes transcript presentation only; it does not alter tool schemas, arguments, prompts, execution, or results. Original host renderers return when the redesign is disabled. `PI_1337_POLISH=off` keeps the host's tool views while retaining the framed editor.
61
+
62
+ Third-party renderers keep their content. A non-built-in tool that defines both `renderCall` and `renderResult` and does not declare `renderShell: "self"` is drawn in a flat shell while the redesign is active: one status dot, then the renderer's call lines; its result lines under `└`; no background fill and no box pad rows. The renderer gets the row width minus the side padding and the two-column lead. Its lines are never rewritten, wrapped or sanitized; a line that is too wide is clipped, and only the blank rows a slot opens or closes with are dropped. The row has one lane, so the hooks run once per host update with the host's own `context.state` and their own `lastComponent`, and a toggle never forks or resets that state. Toggled off, the same components sit in the host's box. A row whose slots render no line at all takes none in either state (active, that includes slots of nothing but blank lines); toggled off this is one blank row short of the host, whose default shell still prints its separator above an empty box — a self-framed row is given that separator only together with a line of its own, so the single row cannot be reproduced. A descriptor with `renderShell: "self"` or with only one of the two hooks is returned unchanged; a result with image content keeps the host box while it is current, and a row that emitted an image-protocol line keeps it for good. So does a row whose renderer returned a line that is not a string: the host's box paints it as the text it coerces to, and the adapter never throws where the host does not. These rows never fold. The flat shell memoizes the composed row per slot, so a repeat frame measures nothing; the child components still render every frame.
63
+
64
+ A `bash` row that is still running shows the timeout the model chose, as stock Pi does: ` (timeout 30s)` after the title, one dim rung that is the first to yield and is gone with the final result. Only a finite, positive number of seconds within the host shell's ceiling is shown, spelled by the renderer; any other value prints nothing.
65
+
66
+ Edit previews use only recorded result diffs; write previews show submitted content.
67
+ `diff-spans.ts` compares words and punctuation with a longest common subsequence,
68
+ then refines each changed span's edges at grapheme boundaries. Common text between
69
+ separate edits keeps its normal weight. Equal-sized, contiguous removed/added groups
70
+ pair by position, since old/new line numbers diverge after insertions. Context and
71
+ omitted-hunk markers end a group; uneven and incomplete preview groups/bodies keep
72
+ full-line semantic colors without intra-line emphasis.
73
+
74
+ Comparison is capped at 8,192 UTF-16 units per body, 256 tokens per side and 65,536
75
+ matrix cells (~128 KiB). Over-budget pairs retain line colors. Unified rows preserve
76
+ space for code at narrow widths; bold spans survive wrapping and clipping without
77
+ styling the renderer's truncation marker. Rendering uses the current host's ruler,
78
+ the active theme's semantic colors, and the existing expansion and toggle contracts.
79
+
80
+ ## Activity label and folding
81
+
82
+ Both features are fed only by Pi's documented events — no host prototypes are
83
+ touched — and both take their words from `tool-lexicon.ts`, so a tool reads the
84
+ same way on its row (`Read src/width.ts`), in the status row (`Reading
85
+ width.ts…`) and in a tally (`Read 3 files`).
86
+
87
+ `tool-activity.ts` tracks top-level `tool_execution_start`/`end` calls (nested
88
+ `parentToolCallId` calls never render as rows). Once the oldest running call has
89
+ lasted half a second, the editor names it in the workspace segment's place, with
90
+ ` +N` for calls running beside it. The frame lays the row out from its normal
91
+ two groups first and repaints only the left group's cells; the right group never
92
+ moves. No timer is added: the spinner's repaint
93
+ reveals the label, and fast calls end before it would appear.
94
+
95
+ The same module holds the run clock. When no call is named and the run has
96
+ lasted three seconds, the slot reads `Working… 45s`, counted from the run's
97
+ first `agent_start` after a settle; retries, mid-run compaction and drained
98
+ follow-ups do not restart it. It is shown whole, without its time, or not at
99
+ all, and it is hidden during a blocking prompt, during compaction, after
100
+ `agent_settled` and for a run that began while the redesign was toggled off.
101
+ It uses the label's overlay and the spinner's repaint, so the right group does
102
+ not move and no timer is added.
103
+
104
+ ## Run summary and terminal title
105
+
106
+ `run-summary.ts` collects one run from live events and `index.ts` appends the
107
+ result once, at `agent_settled`, as a custom session entry. Four fields are
108
+ optional, so earlier entries render unchanged and a malformed one is ignored
109
+ on its own. `waiting` is a snapshot of pi-persona's `persona-background`
110
+ status as counts; with it a clean run reads `● Turn ended in 9.0s · … ·
111
+ waiting on 3 agents, 1 monitor` with a muted dot, and the clause narrows to one
112
+ count (`waiting on 4 background tasks`) and outlasts the cost and the work
113
+ detail. `modelMs` sums `turn_start` → the turn's assistant `message_end`, and
114
+ `outputTokens` sums `usage.output`, absent if any assistant message lacked it.
115
+ `thinkingMs` sums `thinking_start` → `thinking_end` from the assistant stream
116
+ (`message_update`), closing a block the stream left open at that message's
117
+ `message_end`; it is stored only from one second up and never above `modelMs`.
118
+ The expanded row shows them as `model 1m 32s (40s thinking) · tools 42s · 48
119
+ tok/s`; thinking is part of the model time, so it stands in parentheses, and
120
+ `tools` is the run's duration minus model time, so it also holds retry
121
+ back-off, compaction and prompt waits. The line narrows by dropping the rate,
122
+ then the parenthesis, then the tools time, and on a row too narrow for
123
+ `model 1m 32s` it is left empty rather than cut.
124
+
125
+ The status is parsed strictly (`parseBackgroundStatus` in `format.ts`:
126
+ `kind=count` pairs in the order `agents monitors timers scripts`, counts
127
+ 1–9999); anything else means no background work, and only the parsed numbers
128
+ are displayed. After a clean run the terminal title reads `◌ Waiting on 3
129
+ agents — …` while the status parses and `✓ Done — …` once it clears. The
130
+ footer render compares the raw status string and the title is written from a
131
+ microtask. Background work never enters the status row.
132
+
133
+ `tool-groups.ts` keeps runs of consecutive `read`/`grep`/`find`/`ls` calls. A run
134
+ closes when anything else paints a row: another tool, a user or custom message,
135
+ assistant text, an error line, or a thinking row. A run with at least three
136
+ settled, successful, image-free calls folds, open or closed: the last one renders
137
+ a tally row and the others render nothing, so the tally stays in place and counts
138
+ up as later calls settle into it. A call still running keeps its own row.
139
+ Failed calls and calls with images keep their rows, and the tally counts distinct
140
+ files and patterns. Rows painted without any extension event (`notify()`, host
141
+ notices) cannot end a run. A click on the tally, or on any row of a run, expands
142
+ that run; the host's expand key renders everything. Folding is presentation of
143
+ the transcript itself — `notify()`, status indicators, widgets, and every other
144
+ Pi channel stay untouched, and HTML export still shows every call.
145
+
146
+ ## Lifecycle and host behavior
147
+
148
+ `/theme-1337` and shutdown restore the presentation changes made by the extension, including the editor, footer, spinner visibility, theme when still owned by the extension, optional widget, and any terminal tint. The editor slot is shared with other extensions, so it is touched only while `getEditorComponent()` still returns this extension's factory: toggling off then reinstalls the factory that held the slot before (falling back to Pi's own editor if that factory throws), while shutdown only empties it and never builds another extension's editor. An editor installed after this one is left in place. A host without `getEditorComponent` gets the earlier behaviour, an unconditional reset.
149
+
150
+ While the redesign is on, an editor installed over this extension's frame would leave the user with nothing: the frame is the only place the workspace, model, context, cost and spinner are shown, and the footer is empty and Pi's working row hidden. No event announces it, so the empty footer's render compares `getEditorComponent()` with this extension's factory on each UI pass and, from a microtask after that render, hands the chrome back: Pi's footer returns, its working row shows again and this extension's spinner timer stops. Tool rows, the theme, the terminal title and summary rows carry on. The frame is not taken back by itself; the next `/theme-1337` or session start installs it again. The extension only applies UI changes in Pi's interactive TUI mode; RPC, JSON, and print modes do not acquire the redesign or animation timer.
151
+
152
+ Pi owns notices, dialogs, widgets, retry indicators, compaction indicators, and other status channels. The extension keeps these host channels intact and does not replace them with a footer status row.
153
+
154
+ ## Development dependencies
155
+
156
+ The two Pi development packages are pinned to 1.5.2, the latest published
157
+ release. That release already depends on `undici` 8.12.3, which includes the
158
+ fixes for the reported
159
+ [Undici advisories](https://github.com/nodejs/undici/releases/tag/v8.12.2), so
160
+ the root override that earlier pins needed is gone. Check the host's own pin
161
+ again when updating the matched Pi development packages.
162
+
163
+ ## Inspirations
164
+
165
+ The compact transcript's visual direction was informed by [pi-polish](https://github.com/Pringled/pi-extensions/tree/main/packages/pi-polish) and [pi-context-bar](https://github.com/Pringled/pi-extensions/tree/main/packages/pi-context-bar). pi-1337 is an independent implementation adapted to its palettes and framed editor.
166
+
167
+ The `1337-cosmos` palette takes its colors from [pi-starline](https://github.com/Andy8647/pi-starline) (MIT), whose cover art and pill bar use the [Catppuccin](https://github.com/catppuccin/palette) Mocha swatches (MIT). The role mapping, the derived steps and the spinner are original, and no pi-starline or Catppuccin code is bundled.