@mariozechner/pi-coding-agent 0.49.3 → 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.
- package/CHANGELOG.md +99 -1
- package/README.md +310 -1230
- package/dist/cli/args.d.ts +5 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +57 -23
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/config-selector.d.ts +14 -0
- package/dist/cli/config-selector.d.ts.map +1 -0
- package/dist/cli/config-selector.js +31 -0
- package/dist/cli/config-selector.js.map +1 -0
- package/dist/cli/session-picker.d.ts.map +1 -1
- package/dist/cli/session-picker.js +1 -1
- package/dist/cli/session-picker.js.map +1 -1
- package/dist/core/agent-session.d.ts +53 -34
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +262 -67
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts +8 -18
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +39 -55
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +2 -1
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/diagnostics.d.ts +15 -0
- package/dist/core/diagnostics.d.ts.map +1 -0
- package/dist/core/diagnostics.js +2 -0
- package/dist/core/diagnostics.js.map +1 -0
- package/dist/core/export-html/template.css +9 -0
- package/dist/core/export-html/template.js +6 -4
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader.d.ts +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +10 -1
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +9 -3
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +39 -12
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +112 -1
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts +9 -2
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +13 -0
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/model-registry.d.ts +42 -2
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +154 -44
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +3 -2
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/package-manager.d.ts +129 -0
- package/dist/core/package-manager.d.ts.map +1 -0
- package/dist/core/package-manager.js +1148 -0
- package/dist/core/package-manager.js.map +1 -0
- package/dist/core/prompt-templates.d.ts +6 -0
- package/dist/core/prompt-templates.d.ts.map +1 -1
- package/dist/core/prompt-templates.js +114 -54
- package/dist/core/prompt-templates.js.map +1 -1
- package/dist/core/resource-loader.d.ts +160 -0
- package/dist/core/resource-loader.d.ts.map +1 -0
- package/dist/core/resource-loader.js +604 -0
- package/dist/core/resource-loader.js.map +1 -0
- package/dist/core/sdk.d.ts +14 -105
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +52 -304
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +45 -1
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +34 -16
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +104 -25
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skills.d.ts +18 -10
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +126 -93
- package/dist/core/skills.js.map +1 -1
- package/dist/core/system-prompt.d.ts +3 -27
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +16 -103
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +2 -1
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +4 -4
- package/dist/core/tools/read.js.map +1 -1
- package/dist/index.d.ts +12 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -6
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +209 -97
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.d.ts +5 -1
- package/dist/modes/interactive/components/bordered-loader.d.ts.map +1 -1
- package/dist/modes/interactive/components/bordered-loader.js +29 -9
- package/dist/modes/interactive/components/bordered-loader.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts +71 -0
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/config-selector.js +468 -0
- package/dist/modes/interactive/components/config-selector.js.map +1 -0
- package/dist/modes/interactive/components/footer.d.ts.map +1 -1
- package/dist/modes/interactive/components/footer.js +4 -0
- package/dist/modes/interactive/components/footer.js.map +1 -1
- package/dist/modes/interactive/components/index.d.ts +1 -0
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js +1 -0
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/oauth-selector.js +3 -4
- package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +18 -1
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +195 -87
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +17 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/skill-invocation-message.js +47 -0
- package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -0
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +5 -5
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +42 -2
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +535 -200
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/dark.json +1 -1
- package/dist/modes/interactive/theme/light.json +1 -1
- package/dist/modes/interactive/theme/theme-schema.json +8 -1
- package/dist/modes/interactive/theme/theme.d.ts +8 -1
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +72 -25
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +25 -89
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +32 -92
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/utils/git.d.ts +2 -0
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/utils/git.js +6 -0
- package/dist/utils/git.js.map +1 -0
- package/dist/utils/shell.d.ts +1 -0
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +14 -1
- package/dist/utils/shell.js.map +1 -1
- package/dist/utils/sleep.d.ts +5 -0
- package/dist/utils/sleep.d.ts.map +1 -0
- package/dist/utils/sleep.js +17 -0
- package/dist/utils/sleep.js.map +1 -0
- package/docs/compaction.md +23 -21
- package/docs/custom-provider.md +538 -0
- package/docs/development.md +69 -0
- package/docs/extensions.md +180 -118
- package/docs/images/doom-extension.png +0 -0
- package/docs/images/interactive-mode.png +0 -0
- package/docs/images/tree-view.png +0 -0
- package/docs/json.md +79 -0
- package/docs/keybindings.md +162 -0
- package/docs/models.md +193 -0
- package/docs/packages.md +163 -0
- package/docs/prompt-templates.md +67 -0
- package/docs/providers.md +147 -0
- package/docs/sdk.md +111 -178
- package/docs/session.md +167 -16
- package/docs/settings.md +216 -0
- package/docs/shell-aliases.md +13 -0
- package/docs/skills.md +111 -202
- package/docs/terminal-setup.md +65 -0
- package/docs/themes.md +295 -0
- package/docs/tui.md +36 -5
- package/docs/windows.md +17 -0
- package/examples/README.md +1 -0
- package/examples/extensions/README.md +22 -2
- package/examples/extensions/bookmark.ts +50 -0
- package/examples/extensions/custom-provider-anthropic/index.ts +604 -0
- package/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
- package/examples/extensions/custom-provider-anthropic/package.json +19 -0
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +349 -0
- package/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
- package/examples/extensions/custom-provider-gitlab-duo/test.ts +82 -0
- package/examples/extensions/doom-overlay/doom/build.sh +1 -1
- package/examples/extensions/event-bus.ts +43 -0
- package/examples/extensions/message-renderer.ts +59 -0
- package/examples/extensions/session-name.ts +27 -0
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/examples/sdk/02-custom-model.ts +3 -3
- package/examples/sdk/03-custom-prompt.ts +20 -9
- package/examples/sdk/04-skills.ts +26 -27
- package/examples/sdk/06-extensions.ts +15 -6
- package/examples/sdk/07-context-files.ts +22 -18
- package/examples/sdk/08-prompt-templates.ts +19 -14
- package/examples/sdk/09-api-keys-and-oauth.ts +5 -12
- package/examples/sdk/10-settings.ts +3 -3
- package/examples/sdk/12-full-control.ts +16 -7
- package/examples/sdk/README.md +24 -30
- package/package.json +4 -4
- package/docs/theme.md +0 -617
- 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
|
-
|
|
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
|
-
|
|
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
|
-
| `
|
|
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
|
|
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
|
|
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:
|
package/docs/windows.md
ADDED
|
@@ -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
|
+
```
|
package/examples/README.md
CHANGED
|
@@ -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
|
|
|
@@ -88,12 +88,32 @@ cp permission-gate.ts ~/.pi/agent/extensions/
|
|
|
88
88
|
|-----------|-------------|
|
|
89
89
|
| `mac-system-theme.ts` | Syncs pi theme with macOS dark/light mode |
|
|
90
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
|
+
|
|
91
112
|
### External Dependencies
|
|
92
113
|
|
|
93
114
|
| Extension | Description |
|
|
94
115
|
|-----------|-------------|
|
|
95
|
-
| `
|
|
96
|
-
| `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) |
|
|
97
117
|
| `file-trigger.ts` | Watches a trigger file and injects contents into conversation |
|
|
98
118
|
|
|
99
119
|
## Writing Extensions
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Entry bookmarking example.
|
|
3
|
+
*
|
|
4
|
+
* Shows setLabel to mark entries with labels for easy navigation in /tree.
|
|
5
|
+
* Labels appear in the tree view and help you find important points.
|
|
6
|
+
*
|
|
7
|
+
* Usage: /bookmark [label] - bookmark the last assistant message
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
11
|
+
|
|
12
|
+
export default function (pi: ExtensionAPI) {
|
|
13
|
+
pi.registerCommand("bookmark", {
|
|
14
|
+
description: "Bookmark last message (usage: /bookmark [label])",
|
|
15
|
+
handler: async (args, ctx) => {
|
|
16
|
+
const label = args.trim() || `bookmark-${Date.now()}`;
|
|
17
|
+
|
|
18
|
+
// Find the last assistant message entry
|
|
19
|
+
const entries = ctx.sessionManager.getEntries();
|
|
20
|
+
for (let i = entries.length - 1; i >= 0; i--) {
|
|
21
|
+
const entry = entries[i];
|
|
22
|
+
if (entry.type === "message" && entry.message.role === "assistant") {
|
|
23
|
+
pi.setLabel(entry.id, label);
|
|
24
|
+
ctx.ui.notify(`Bookmarked as: ${label}`, "info");
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
ctx.ui.notify("No assistant message to bookmark", "warning");
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// Remove bookmark
|
|
34
|
+
pi.registerCommand("unbookmark", {
|
|
35
|
+
description: "Remove bookmark from last labeled entry",
|
|
36
|
+
handler: async (_args, ctx) => {
|
|
37
|
+
const entries = ctx.sessionManager.getEntries();
|
|
38
|
+
for (let i = entries.length - 1; i >= 0; i--) {
|
|
39
|
+
const entry = entries[i];
|
|
40
|
+
const label = ctx.sessionManager.getLabel(entry.id);
|
|
41
|
+
if (label) {
|
|
42
|
+
pi.setLabel(entry.id, undefined);
|
|
43
|
+
ctx.ui.notify(`Removed bookmark: ${label}`, "info");
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
ctx.ui.notify("No bookmarked entry found", "warning");
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
}
|