@mariozechner/pi-coding-agent 0.49.2 → 0.50.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.
Files changed (237) hide show
  1. package/CHANGELOG.md +126 -1
  2. package/README.md +310 -1229
  3. package/dist/cli/args.d.ts +5 -0
  4. package/dist/cli/args.d.ts.map +1 -1
  5. package/dist/cli/args.js +57 -22
  6. package/dist/cli/args.js.map +1 -1
  7. package/dist/cli/config-selector.d.ts +14 -0
  8. package/dist/cli/config-selector.d.ts.map +1 -0
  9. package/dist/cli/config-selector.js +31 -0
  10. package/dist/cli/config-selector.js.map +1 -0
  11. package/dist/cli/session-picker.d.ts.map +1 -1
  12. package/dist/cli/session-picker.js +1 -1
  13. package/dist/cli/session-picker.js.map +1 -1
  14. package/dist/config.d.ts +2 -0
  15. package/dist/config.d.ts.map +1 -1
  16. package/dist/config.js +6 -0
  17. package/dist/config.js.map +1 -1
  18. package/dist/core/agent-session.d.ts +53 -34
  19. package/dist/core/agent-session.d.ts.map +1 -1
  20. package/dist/core/agent-session.js +262 -67
  21. package/dist/core/agent-session.js.map +1 -1
  22. package/dist/core/auth-storage.d.ts +8 -18
  23. package/dist/core/auth-storage.d.ts.map +1 -1
  24. package/dist/core/auth-storage.js +39 -55
  25. package/dist/core/auth-storage.js.map +1 -1
  26. package/dist/core/bash-executor.d.ts.map +1 -1
  27. package/dist/core/bash-executor.js +2 -1
  28. package/dist/core/bash-executor.js.map +1 -1
  29. package/dist/core/diagnostics.d.ts +15 -0
  30. package/dist/core/diagnostics.d.ts.map +1 -0
  31. package/dist/core/diagnostics.js +2 -0
  32. package/dist/core/diagnostics.js.map +1 -0
  33. package/dist/core/export-html/template.css +9 -0
  34. package/dist/core/export-html/template.js +6 -4
  35. package/dist/core/extensions/index.d.ts +1 -1
  36. package/dist/core/extensions/index.d.ts.map +1 -1
  37. package/dist/core/extensions/index.js.map +1 -1
  38. package/dist/core/extensions/loader.d.ts +1 -1
  39. package/dist/core/extensions/loader.d.ts.map +1 -1
  40. package/dist/core/extensions/loader.js +10 -1
  41. package/dist/core/extensions/loader.js.map +1 -1
  42. package/dist/core/extensions/runner.d.ts +9 -3
  43. package/dist/core/extensions/runner.d.ts.map +1 -1
  44. package/dist/core/extensions/runner.js +39 -12
  45. package/dist/core/extensions/runner.js.map +1 -1
  46. package/dist/core/extensions/types.d.ts +112 -1
  47. package/dist/core/extensions/types.d.ts.map +1 -1
  48. package/dist/core/extensions/types.js.map +1 -1
  49. package/dist/core/footer-data-provider.d.ts +9 -2
  50. package/dist/core/footer-data-provider.d.ts.map +1 -1
  51. package/dist/core/footer-data-provider.js +13 -0
  52. package/dist/core/footer-data-provider.js.map +1 -1
  53. package/dist/core/model-registry.d.ts +42 -2
  54. package/dist/core/model-registry.d.ts.map +1 -1
  55. package/dist/core/model-registry.js +154 -44
  56. package/dist/core/model-registry.js.map +1 -1
  57. package/dist/core/model-resolver.d.ts.map +1 -1
  58. package/dist/core/model-resolver.js +3 -2
  59. package/dist/core/model-resolver.js.map +1 -1
  60. package/dist/core/package-manager.d.ts +129 -0
  61. package/dist/core/package-manager.d.ts.map +1 -0
  62. package/dist/core/package-manager.js +1148 -0
  63. package/dist/core/package-manager.js.map +1 -0
  64. package/dist/core/prompt-templates.d.ts +6 -0
  65. package/dist/core/prompt-templates.d.ts.map +1 -1
  66. package/dist/core/prompt-templates.js +114 -54
  67. package/dist/core/prompt-templates.js.map +1 -1
  68. package/dist/core/resource-loader.d.ts +160 -0
  69. package/dist/core/resource-loader.d.ts.map +1 -0
  70. package/dist/core/resource-loader.js +604 -0
  71. package/dist/core/resource-loader.js.map +1 -0
  72. package/dist/core/sdk.d.ts +14 -105
  73. package/dist/core/sdk.d.ts.map +1 -1
  74. package/dist/core/sdk.js +52 -304
  75. package/dist/core/sdk.js.map +1 -1
  76. package/dist/core/session-manager.d.ts.map +1 -1
  77. package/dist/core/session-manager.js +45 -1
  78. package/dist/core/session-manager.js.map +1 -1
  79. package/dist/core/settings-manager.d.ts +39 -16
  80. package/dist/core/settings-manager.d.ts.map +1 -1
  81. package/dist/core/settings-manager.js +107 -25
  82. package/dist/core/settings-manager.js.map +1 -1
  83. package/dist/core/skills.d.ts +18 -10
  84. package/dist/core/skills.d.ts.map +1 -1
  85. package/dist/core/skills.js +126 -93
  86. package/dist/core/skills.js.map +1 -1
  87. package/dist/core/system-prompt.d.ts +3 -27
  88. package/dist/core/system-prompt.d.ts.map +1 -1
  89. package/dist/core/system-prompt.js +16 -103
  90. package/dist/core/system-prompt.js.map +1 -1
  91. package/dist/core/tools/bash.d.ts.map +1 -1
  92. package/dist/core/tools/bash.js +2 -1
  93. package/dist/core/tools/bash.js.map +1 -1
  94. package/dist/core/tools/read.d.ts.map +1 -1
  95. package/dist/core/tools/read.js +4 -4
  96. package/dist/core/tools/read.js.map +1 -1
  97. package/dist/index.d.ts +12 -7
  98. package/dist/index.d.ts.map +1 -1
  99. package/dist/index.js +8 -6
  100. package/dist/index.js.map +1 -1
  101. package/dist/main.d.ts.map +1 -1
  102. package/dist/main.js +209 -97
  103. package/dist/main.js.map +1 -1
  104. package/dist/modes/interactive/components/assistant-message.d.ts +3 -2
  105. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  106. package/dist/modes/interactive/components/assistant-message.js +5 -3
  107. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  108. package/dist/modes/interactive/components/bordered-loader.d.ts +5 -1
  109. package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
  110. package/dist/modes/interactive/components/bordered-loader.js +29 -9
  111. package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
  112. package/dist/modes/interactive/components/branch-summary-message.d.ts +3 -2
  113. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
  114. package/dist/modes/interactive/components/branch-summary-message.js +4 -2
  115. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
  116. package/dist/modes/interactive/components/compaction-summary-message.d.ts +3 -2
  117. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
  118. package/dist/modes/interactive/components/compaction-summary-message.js +4 -2
  119. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
  120. package/dist/modes/interactive/components/config-selector.d.ts +71 -0
  121. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -0
  122. package/dist/modes/interactive/components/config-selector.js +468 -0
  123. package/dist/modes/interactive/components/config-selector.js.map +1 -0
  124. package/dist/modes/interactive/components/custom-message.d.ts +3 -2
  125. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  126. package/dist/modes/interactive/components/custom-message.js +4 -2
  127. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  128. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  129. package/dist/modes/interactive/components/footer.js +9 -0
  130. package/dist/modes/interactive/components/footer.js.map +1 -1
  131. package/dist/modes/interactive/components/index.d.ts +1 -0
  132. package/dist/modes/interactive/components/index.d.ts.map +1 -1
  133. package/dist/modes/interactive/components/index.js +1 -0
  134. package/dist/modes/interactive/components/index.js.map +1 -1
  135. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  136. package/dist/modes/interactive/components/oauth-selector.js +3 -4
  137. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  138. package/dist/modes/interactive/components/session-selector.d.ts +18 -1
  139. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  140. package/dist/modes/interactive/components/session-selector.js +195 -87
  141. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  142. package/dist/modes/interactive/components/skill-invocation-message.d.ts +17 -0
  143. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -0
  144. package/dist/modes/interactive/components/skill-invocation-message.js +47 -0
  145. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -0
  146. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  147. package/dist/modes/interactive/components/tool-execution.js +12 -5
  148. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  149. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  150. package/dist/modes/interactive/components/tree-selector.js +2 -2
  151. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  152. package/dist/modes/interactive/components/user-message.d.ts +2 -2
  153. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  154. package/dist/modes/interactive/components/user-message.js +2 -2
  155. package/dist/modes/interactive/components/user-message.js.map +1 -1
  156. package/dist/modes/interactive/interactive-mode.d.ts +47 -2
  157. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  158. package/dist/modes/interactive/interactive-mode.js +566 -211
  159. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  160. package/dist/modes/interactive/theme/dark.json +1 -1
  161. package/dist/modes/interactive/theme/light.json +1 -1
  162. package/dist/modes/interactive/theme/theme-schema.json +8 -1
  163. package/dist/modes/interactive/theme/theme.d.ts +8 -1
  164. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  165. package/dist/modes/interactive/theme/theme.js +79 -28
  166. package/dist/modes/interactive/theme/theme.js.map +1 -1
  167. package/dist/modes/print-mode.d.ts.map +1 -1
  168. package/dist/modes/print-mode.js +25 -89
  169. package/dist/modes/print-mode.js.map +1 -1
  170. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  171. package/dist/modes/rpc/rpc-mode.js +32 -92
  172. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  173. package/dist/utils/git.d.ts +2 -0
  174. package/dist/utils/git.d.ts.map +1 -0
  175. package/dist/utils/git.js +6 -0
  176. package/dist/utils/git.js.map +1 -0
  177. package/dist/utils/shell.d.ts +1 -0
  178. package/dist/utils/shell.d.ts.map +1 -1
  179. package/dist/utils/shell.js +16 -2
  180. package/dist/utils/shell.js.map +1 -1
  181. package/dist/utils/sleep.d.ts +5 -0
  182. package/dist/utils/sleep.d.ts.map +1 -0
  183. package/dist/utils/sleep.js +17 -0
  184. package/dist/utils/sleep.js.map +1 -0
  185. package/docs/compaction.md +23 -21
  186. package/docs/custom-provider.md +538 -0
  187. package/docs/development.md +69 -0
  188. package/docs/extensions.md +180 -118
  189. package/docs/images/doom-extension.png +0 -0
  190. package/docs/images/interactive-mode.png +0 -0
  191. package/docs/images/tree-view.png +0 -0
  192. package/docs/json.md +79 -0
  193. package/docs/keybindings.md +162 -0
  194. package/docs/models.md +193 -0
  195. package/docs/packages.md +163 -0
  196. package/docs/prompt-templates.md +67 -0
  197. package/docs/providers.md +147 -0
  198. package/docs/sdk.md +111 -178
  199. package/docs/session.md +167 -16
  200. package/docs/settings.md +216 -0
  201. package/docs/shell-aliases.md +13 -0
  202. package/docs/skills.md +111 -202
  203. package/docs/terminal-setup.md +65 -0
  204. package/docs/themes.md +295 -0
  205. package/docs/tui.md +36 -5
  206. package/docs/windows.md +17 -0
  207. package/examples/README.md +1 -0
  208. package/examples/extensions/README.md +24 -2
  209. package/examples/extensions/antigravity-image-gen.ts +413 -0
  210. package/examples/extensions/bookmark.ts +50 -0
  211. package/examples/extensions/custom-provider-anthropic/index.ts +604 -0
  212. package/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
  213. package/examples/extensions/custom-provider-anthropic/package.json +19 -0
  214. package/examples/extensions/custom-provider-gitlab-duo/index.ts +349 -0
  215. package/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
  216. package/examples/extensions/custom-provider-gitlab-duo/test.ts +82 -0
  217. package/examples/extensions/doom-overlay/doom/build.sh +1 -1
  218. package/examples/extensions/event-bus.ts +43 -0
  219. package/examples/extensions/inline-bash.ts +94 -0
  220. package/examples/extensions/message-renderer.ts +59 -0
  221. package/examples/extensions/session-name.ts +27 -0
  222. package/examples/extensions/space-invaders.ts +560 -0
  223. package/examples/extensions/with-deps/package-lock.json +2 -2
  224. package/examples/extensions/with-deps/package.json +1 -1
  225. package/examples/sdk/02-custom-model.ts +3 -3
  226. package/examples/sdk/03-custom-prompt.ts +20 -9
  227. package/examples/sdk/04-skills.ts +26 -27
  228. package/examples/sdk/06-extensions.ts +15 -6
  229. package/examples/sdk/07-context-files.ts +22 -18
  230. package/examples/sdk/08-prompt-templates.ts +19 -14
  231. package/examples/sdk/09-api-keys-and-oauth.ts +5 -12
  232. package/examples/sdk/10-settings.ts +3 -3
  233. package/examples/sdk/12-full-control.ts +16 -7
  234. package/examples/sdk/README.md +24 -30
  235. package/package.json +4 -4
  236. package/docs/theme.md +0 -617
  237. package/examples/extensions/chalk-logger.ts +0 -26
package/docs/themes.md ADDED
@@ -0,0 +1,295 @@
1
+ > pi can create themes. Ask it to build one for your setup.
2
+
3
+ # Themes
4
+
5
+ Themes are JSON files that define colors for the TUI.
6
+
7
+ ## Table of Contents
8
+
9
+ - [Locations](#locations)
10
+ - [Selecting a Theme](#selecting-a-theme)
11
+ - [Creating a Custom Theme](#creating-a-custom-theme)
12
+ - [Theme Format](#theme-format)
13
+ - [Color Tokens](#color-tokens)
14
+ - [Color Values](#color-values)
15
+ - [Tips](#tips)
16
+
17
+ ## Locations
18
+
19
+ Pi loads themes from:
20
+
21
+ - Built-in: `dark`, `light`
22
+ - Global: `~/.pi/agent/themes/*.json`
23
+ - Project: `.pi/themes/*.json`
24
+ - Packages: `themes/` directories or `pi.themes` entries in `package.json`
25
+ - Settings: `themes` array with files or directories
26
+ - CLI: `--theme <path>` (repeatable)
27
+
28
+ Disable discovery with `--no-themes`.
29
+
30
+ ## Selecting a Theme
31
+
32
+ Select a theme via `/settings` or in `settings.json`:
33
+
34
+ ```json
35
+ {
36
+ "theme": "my-theme"
37
+ }
38
+ ```
39
+
40
+ On first run, pi detects your terminal background and defaults to `dark` or `light`.
41
+
42
+ ## Creating a Custom Theme
43
+
44
+ 1. Create a theme file:
45
+
46
+ ```bash
47
+ mkdir -p ~/.pi/agent/themes
48
+ vim ~/.pi/agent/themes/my-theme.json
49
+ ```
50
+
51
+ 2. Define the theme with all required colors (see [Color Tokens](#color-tokens)):
52
+
53
+ ```json
54
+ {
55
+ "$schema": "https://raw.githubusercontent.com/badlogic/pi-mono/main/packages/coding-agent/src/modes/interactive/theme/theme-schema.json",
56
+ "name": "my-theme",
57
+ "vars": {
58
+ "primary": "#00aaff",
59
+ "secondary": 242
60
+ },
61
+ "colors": {
62
+ "accent": "primary",
63
+ "border": "primary",
64
+ "borderAccent": "#00ffff",
65
+ "borderMuted": "secondary",
66
+ "success": "#00ff00",
67
+ "error": "#ff0000",
68
+ "warning": "#ffff00",
69
+ "muted": "secondary",
70
+ "dim": 240,
71
+ "text": "",
72
+ "thinkingText": "secondary",
73
+ "selectedBg": "#2d2d30",
74
+ "userMessageBg": "#2d2d30",
75
+ "userMessageText": "",
76
+ "customMessageBg": "#2d2d30",
77
+ "customMessageText": "",
78
+ "customMessageLabel": "primary",
79
+ "toolPendingBg": "#1e1e2e",
80
+ "toolSuccessBg": "#1e2e1e",
81
+ "toolErrorBg": "#2e1e1e",
82
+ "toolTitle": "primary",
83
+ "toolOutput": "",
84
+ "mdHeading": "#ffaa00",
85
+ "mdLink": "primary",
86
+ "mdLinkUrl": "secondary",
87
+ "mdCode": "#00ffff",
88
+ "mdCodeBlock": "",
89
+ "mdCodeBlockBorder": "secondary",
90
+ "mdQuote": "secondary",
91
+ "mdQuoteBorder": "secondary",
92
+ "mdHr": "secondary",
93
+ "mdListBullet": "#00ffff",
94
+ "toolDiffAdded": "#00ff00",
95
+ "toolDiffRemoved": "#ff0000",
96
+ "toolDiffContext": "secondary",
97
+ "syntaxComment": "secondary",
98
+ "syntaxKeyword": "primary",
99
+ "syntaxFunction": "#00aaff",
100
+ "syntaxVariable": "#ffaa00",
101
+ "syntaxString": "#00ff00",
102
+ "syntaxNumber": "#ff00ff",
103
+ "syntaxType": "#00aaff",
104
+ "syntaxOperator": "primary",
105
+ "syntaxPunctuation": "secondary",
106
+ "thinkingOff": "secondary",
107
+ "thinkingMinimal": "primary",
108
+ "thinkingLow": "#00aaff",
109
+ "thinkingMedium": "#00ffff",
110
+ "thinkingHigh": "#ff00ff",
111
+ "thinkingXhigh": "#ff0000",
112
+ "bashMode": "#ffaa00"
113
+ }
114
+ }
115
+ ```
116
+
117
+ 3. Select the theme via `/settings`.
118
+
119
+ **Hot reload:** When you edit the currently active custom theme file, pi reloads it automatically for immediate visual feedback.
120
+
121
+ ## Theme Format
122
+
123
+ ```json
124
+ {
125
+ "$schema": "https://raw.githubusercontent.com/badlogic/pi-mono/main/packages/coding-agent/src/modes/interactive/theme/theme-schema.json",
126
+ "name": "my-theme",
127
+ "vars": {
128
+ "blue": "#0066cc",
129
+ "gray": 242
130
+ },
131
+ "colors": {
132
+ "accent": "blue",
133
+ "muted": "gray",
134
+ "text": "",
135
+ ...
136
+ }
137
+ }
138
+ ```
139
+
140
+ - `name` is required and must be unique.
141
+ - `vars` is optional. Define reusable colors here, then reference them in `colors`.
142
+ - `colors` must define all 51 required tokens.
143
+
144
+ The `$schema` field enables editor auto-completion and validation.
145
+
146
+ ## Color Tokens
147
+
148
+ Every theme must define all 51 color tokens. There are no optional colors.
149
+
150
+ ### Core UI (11 colors)
151
+
152
+ | Token | Purpose |
153
+ |-------|---------|
154
+ | `accent` | Primary accent (logo, selected items, cursor) |
155
+ | `border` | Normal borders |
156
+ | `borderAccent` | Highlighted borders |
157
+ | `borderMuted` | Subtle borders (editor) |
158
+ | `success` | Success states |
159
+ | `error` | Error states |
160
+ | `warning` | Warning states |
161
+ | `muted` | Secondary text |
162
+ | `dim` | Tertiary text |
163
+ | `text` | Default text (usually `""`) |
164
+ | `thinkingText` | Thinking block text |
165
+
166
+ ### Backgrounds & Content (11 colors)
167
+
168
+ | Token | Purpose |
169
+ |-------|---------|
170
+ | `selectedBg` | Selected line background |
171
+ | `userMessageBg` | User message background |
172
+ | `userMessageText` | User message text |
173
+ | `customMessageBg` | Extension message background |
174
+ | `customMessageText` | Extension message text |
175
+ | `customMessageLabel` | Extension message label |
176
+ | `toolPendingBg` | Tool box (pending) |
177
+ | `toolSuccessBg` | Tool box (success) |
178
+ | `toolErrorBg` | Tool box (error) |
179
+ | `toolTitle` | Tool title |
180
+ | `toolOutput` | Tool output text |
181
+
182
+ ### Markdown (10 colors)
183
+
184
+ | Token | Purpose |
185
+ |-------|---------|
186
+ | `mdHeading` | Headings |
187
+ | `mdLink` | Link text |
188
+ | `mdLinkUrl` | Link URL |
189
+ | `mdCode` | Inline code |
190
+ | `mdCodeBlock` | Code block content |
191
+ | `mdCodeBlockBorder` | Code block fences |
192
+ | `mdQuote` | Blockquote text |
193
+ | `mdQuoteBorder` | Blockquote border |
194
+ | `mdHr` | Horizontal rule |
195
+ | `mdListBullet` | List bullets |
196
+
197
+ ### Tool Diffs (3 colors)
198
+
199
+ | Token | Purpose |
200
+ |-------|---------|
201
+ | `toolDiffAdded` | Added lines |
202
+ | `toolDiffRemoved` | Removed lines |
203
+ | `toolDiffContext` | Context lines |
204
+
205
+ ### Syntax Highlighting (9 colors)
206
+
207
+ | Token | Purpose |
208
+ |-------|---------|
209
+ | `syntaxComment` | Comments |
210
+ | `syntaxKeyword` | Keywords |
211
+ | `syntaxFunction` | Function names |
212
+ | `syntaxVariable` | Variables |
213
+ | `syntaxString` | Strings |
214
+ | `syntaxNumber` | Numbers |
215
+ | `syntaxType` | Types |
216
+ | `syntaxOperator` | Operators |
217
+ | `syntaxPunctuation` | Punctuation |
218
+
219
+ ### Thinking Level Borders (6 colors)
220
+
221
+ Editor border colors indicating thinking level (visual hierarchy from subtle to prominent):
222
+
223
+ | Token | Purpose |
224
+ |-------|---------|
225
+ | `thinkingOff` | Thinking off |
226
+ | `thinkingMinimal` | Minimal thinking |
227
+ | `thinkingLow` | Low thinking |
228
+ | `thinkingMedium` | Medium thinking |
229
+ | `thinkingHigh` | High thinking |
230
+ | `thinkingXhigh` | Extra high thinking |
231
+
232
+ ### Bash Mode (1 color)
233
+
234
+ | Token | Purpose |
235
+ |-------|---------|
236
+ | `bashMode` | Editor border in bash mode (`!` prefix) |
237
+
238
+ ### HTML Export (optional)
239
+
240
+ The `export` section controls colors for `/export` HTML output. If omitted, colors are derived from `userMessageBg`.
241
+
242
+ ```json
243
+ {
244
+ "export": {
245
+ "pageBg": "#18181e",
246
+ "cardBg": "#1e1e24",
247
+ "infoBg": "#3c3728"
248
+ }
249
+ }
250
+ ```
251
+
252
+ ## Color Values
253
+
254
+ Four formats are supported:
255
+
256
+ | Format | Example | Description |
257
+ |--------|---------|-------------|
258
+ | Hex | `"#ff0000"` | 6-digit hex RGB |
259
+ | 256-color | `39` | xterm 256-color palette index (0-255) |
260
+ | Variable | `"primary"` | Reference to a `vars` entry |
261
+ | Default | `""` | Terminal's default color |
262
+
263
+ ### 256-Color Palette
264
+
265
+ - `0-15`: Basic ANSI colors (terminal-dependent)
266
+ - `16-231`: 6×6×6 RGB cube (`16 + 36×R + 6×G + B` where R,G,B are 0-5)
267
+ - `232-255`: Grayscale ramp
268
+
269
+ ### Terminal Compatibility
270
+
271
+ Pi uses 24-bit RGB colors. Most modern terminals support this (iTerm2, Kitty, WezTerm, Windows Terminal, VS Code). For older terminals with only 256-color support, pi falls back to the nearest approximation.
272
+
273
+ Check truecolor support:
274
+
275
+ ```bash
276
+ echo $COLORTERM # Should output "truecolor" or "24bit"
277
+ ```
278
+
279
+ ## Tips
280
+
281
+ **Dark terminals:** Use bright, saturated colors with higher contrast.
282
+
283
+ **Light terminals:** Use darker, muted colors with lower contrast.
284
+
285
+ **Color harmony:** Start with a base palette (Nord, Gruvbox, Tokyo Night), define it in `vars`, and reference consistently.
286
+
287
+ **Testing:** Check your theme with different message types, tool states, markdown content, and long wrapped text.
288
+
289
+ **VS Code:** Set `terminal.integrated.minimumContrastRatio` to `1` for accurate colors.
290
+
291
+ ## Examples
292
+
293
+ See the built-in themes:
294
+ - [dark.json](../src/modes/interactive/theme/dark.json)
295
+ - [light.json](../src/modes/interactive/theme/light.json)
package/docs/tui.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # TUI Components
4
4
 
5
- Hooks and custom tools can render custom TUI components for interactive user interfaces. This page covers the component system and available building blocks.
5
+ Extensions and custom tools can render custom TUI components for interactive user interfaces. This page covers the component system and available building blocks.
6
6
 
7
7
  **Source:** [`@mariozechner/pi-tui`](https://github.com/badlogic/pi-mono/tree/main/packages/tui)
8
8
 
@@ -14,7 +14,8 @@ All components implement:
14
14
  interface Component {
15
15
  render(width: number): string[];
16
16
  handleInput?(data: string): void;
17
- invalidate?(): void;
17
+ wantsKeyRelease?: boolean;
18
+ invalidate(): void;
18
19
  }
19
20
  ```
20
21
 
@@ -22,7 +23,8 @@ interface Component {
22
23
  |--------|-------------|
23
24
  | `render(width)` | Return array of strings (one per line). Each line **must not exceed `width`**. |
24
25
  | `handleInput?(data)` | Receive keyboard input when component has focus. |
25
- | `invalidate?()` | Clear cached render state. |
26
+ | `wantsKeyRelease?` | If true, component receives key release events (Kitty protocol). Default: false. |
27
+ | `invalidate()` | Clear cached render state. Called on theme changes. |
26
28
 
27
29
  The TUI appends a full SGR reset and OSC 8 reset at the end of each rendered line. Styles do not carry across lines. If you emit multi-line text with styling, reapply styles per line or use `wrapTextWithAnsi()` so styles are preserved for each wrapped line.
28
30
 
@@ -84,7 +86,7 @@ Without this propagation, typing with an IME (Chinese, Japanese, Korean, etc.) w
84
86
 
85
87
  ## Using Components
86
88
 
87
- **In hooks** via `ctx.ui.custom()`:
89
+ **In extensions** via `ctx.ui.custom()`:
88
90
 
89
91
  ```typescript
90
92
  pi.on("session_start", async (_event, ctx) => {
@@ -152,6 +154,27 @@ const result = await ctx.ui.custom<string | null>(
152
154
  );
153
155
  ```
154
156
 
157
+ ### Overlay Lifecycle
158
+
159
+ Overlay components are disposed when closed. Don't reuse references - create fresh instances:
160
+
161
+ ```typescript
162
+ // Wrong - stale reference
163
+ let menu: MenuComponent;
164
+ await ctx.ui.custom((_, __, ___, done) => {
165
+ menu = new MenuComponent(done);
166
+ return menu;
167
+ }, { overlay: true });
168
+ setActiveComponent(menu); // Disposed
169
+
170
+ // Correct - re-call to re-show
171
+ const showMenu = () => ctx.ui.custom((_, __, ___, done) =>
172
+ new MenuComponent(done), { overlay: true });
173
+
174
+ await showMenu(); // First show
175
+ await showMenu(); // "Back" = just call again
176
+ ```
177
+
155
178
  See [overlay-qa-tests.ts](../examples/extensions/overlay-qa-tests.ts) for comprehensive examples covering anchors, margins, stacking, responsive visibility, and animation.
156
179
 
157
180
  ## Built-in Components
@@ -337,7 +360,7 @@ class MySelector {
337
360
  }
338
361
  ```
339
362
 
340
- Usage in a hook:
363
+ Usage in an extension:
341
364
 
342
365
  ```typescript
343
366
  pi.registerCommand("pick", {
@@ -420,6 +443,14 @@ interface MyTheme {
420
443
  }
421
444
  ```
422
445
 
446
+ ## Debug logging
447
+
448
+ Set `PI_TUI_WRITE_LOG` to capture the raw ANSI stream written to stdout.
449
+
450
+ ```bash
451
+ PI_TUI_WRITE_LOG=/tmp/tui-ansi.log npx tsx packages/tui/test/chat-simple.ts
452
+ ```
453
+
423
454
  ## Performance
424
455
 
425
456
  Cache rendered output when possible:
@@ -0,0 +1,17 @@
1
+ # Windows Setup
2
+
3
+ Pi requires a bash shell on Windows. Checked locations (in order):
4
+
5
+ 1. Custom path from `~/.pi/agent/settings.json`
6
+ 2. Git Bash (`C:\Program Files\Git\bin\bash.exe`)
7
+ 3. `bash.exe` on PATH (Cygwin, MSYS2, WSL)
8
+
9
+ For most users, [Git for Windows](https://git-scm.com/download/win) is sufficient.
10
+
11
+ ## Custom Shell Path
12
+
13
+ ```json
14
+ {
15
+ "shellPath": "C:\\cygwin64\\bin\\bash.exe"
16
+ }
17
+ ```
@@ -16,6 +16,7 @@ Example extensions demonstrating:
16
16
  - Git integration (checkpoints, auto-commit)
17
17
  - System prompt modifications and custom compaction
18
18
  - External integrations (SSH, file watchers, system theme sync)
19
+ - Custom providers (Anthropic with custom streaming, GitLab Duo)
19
20
 
20
21
  ## Documentation
21
22
 
@@ -34,6 +34,7 @@ cp permission-gate.ts ~/.pi/agent/extensions/
34
34
  | `questionnaire.ts` | Multi-question input with tab bar navigation between questions |
35
35
  | `tool-override.ts` | Override built-in tools (e.g., add logging/access control to `read`) |
36
36
  | `truncated-tool.ts` | Wraps ripgrep with proper output truncation (50KB/2000 lines) |
37
+ | `antigravity-image-gen.ts` | Generate images via Google Antigravity with optional save-to-disk modes |
37
38
  | `ssh.ts` | Delegate all tools to a remote machine via SSH using pluggable operations |
38
39
  | `subagent/` | Delegate tasks to specialized subagents with isolated context windows |
39
40
 
@@ -63,6 +64,7 @@ cp permission-gate.ts ~/.pi/agent/extensions/
63
64
  | `doom-overlay/` | DOOM game running as an overlay at 35 FPS (demonstrates real-time game rendering) |
64
65
  | `shutdown-command.ts` | Adds `/quit` command demonstrating `ctx.shutdown()` |
65
66
  | `interactive-shell.ts` | Run interactive commands (vim, htop) with full terminal via `user_bash` hook |
67
+ | `inline-bash.ts` | Expands `!{command}` patterns in prompts via `input` event transformation |
66
68
 
67
69
  ### Git Integration
68
70
 
@@ -86,12 +88,32 @@ cp permission-gate.ts ~/.pi/agent/extensions/
86
88
  |-----------|-------------|
87
89
  | `mac-system-theme.ts` | Syncs pi theme with macOS dark/light mode |
88
90
 
91
+ ### Messages & Communication
92
+
93
+ | Extension | Description |
94
+ |-----------|-------------|
95
+ | `message-renderer.ts` | Custom message rendering with colors and expandable details via `registerMessageRenderer` |
96
+ | `event-bus.ts` | Inter-extension communication via `pi.events` |
97
+
98
+ ### Session Metadata
99
+
100
+ | Extension | Description |
101
+ |-----------|-------------|
102
+ | `session-name.ts` | Name sessions for the session selector via `setSessionName` |
103
+ | `bookmark.ts` | Bookmark entries with labels for `/tree` navigation via `setLabel` |
104
+
105
+ ### Custom Providers
106
+
107
+ | Extension | Description |
108
+ |-----------|-------------|
109
+ | `custom-provider-anthropic/` | Custom Anthropic provider with OAuth support and custom streaming implementation |
110
+ | `custom-provider-gitlab-duo/` | GitLab Duo provider using pi-ai's built-in Anthropic/OpenAI streaming via proxy |
111
+
89
112
  ### External Dependencies
90
113
 
91
114
  | Extension | Description |
92
115
  |-----------|-------------|
93
- | `chalk-logger.ts` | Uses chalk from parent node_modules (demonstrates jiti module resolution) |
94
- | `with-deps/` | Extension with its own package.json and dependencies |
116
+ | `with-deps/` | Extension with its own package.json and dependencies (demonstrates jiti module resolution) |
95
117
  | `file-trigger.ts` | Watches a trigger file and injects contents into conversation |
96
118
 
97
119
  ## Writing Extensions