@mrquake/quakecode-cli 0.64.0 → 0.64.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 (150) hide show
  1. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  2. package/dist/modes/interactive/components/session-selector.js +82 -105
  3. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  4. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  5. package/dist/modes/interactive/interactive-mode.js +7 -2
  6. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  7. package/package.json +11 -4
  8. package/docs/compaction.md +0 -394
  9. package/docs/custom-provider.md +0 -596
  10. package/docs/development.md +0 -71
  11. package/docs/extensions.md +0 -2286
  12. package/docs/images/doom-extension.png +0 -0
  13. package/docs/images/exy.png +0 -0
  14. package/docs/images/interactive-mode.png +0 -0
  15. package/docs/images/tree-view.png +0 -0
  16. package/docs/json.md +0 -82
  17. package/docs/keybindings.md +0 -175
  18. package/docs/models.md +0 -341
  19. package/docs/packages.md +0 -218
  20. package/docs/prompt-templates.md +0 -67
  21. package/docs/providers.md +0 -195
  22. package/docs/rpc.md +0 -1377
  23. package/docs/sdk.md +0 -1064
  24. package/docs/session.md +0 -412
  25. package/docs/settings.md +0 -246
  26. package/docs/shell-aliases.md +0 -13
  27. package/docs/skills.md +0 -232
  28. package/docs/terminal-setup.md +0 -106
  29. package/docs/termux.md +0 -127
  30. package/docs/themes.md +0 -295
  31. package/docs/tmux.md +0 -61
  32. package/docs/tree.md +0 -231
  33. package/docs/tui.md +0 -887
  34. package/docs/windows.md +0 -17
  35. package/examples/README.md +0 -25
  36. package/examples/extensions/README.md +0 -206
  37. package/examples/extensions/antigravity-image-gen.ts +0 -418
  38. package/examples/extensions/auto-commit-on-exit.ts +0 -49
  39. package/examples/extensions/bash-spawn-hook.ts +0 -30
  40. package/examples/extensions/bookmark.ts +0 -50
  41. package/examples/extensions/built-in-tool-renderer.ts +0 -246
  42. package/examples/extensions/claude-rules.ts +0 -86
  43. package/examples/extensions/commands.ts +0 -72
  44. package/examples/extensions/confirm-destructive.ts +0 -59
  45. package/examples/extensions/custom-compaction.ts +0 -127
  46. package/examples/extensions/custom-footer.ts +0 -64
  47. package/examples/extensions/custom-header.ts +0 -73
  48. package/examples/extensions/custom-provider-anthropic/index.ts +0 -604
  49. package/examples/extensions/custom-provider-anthropic/package-lock.json +0 -24
  50. package/examples/extensions/custom-provider-anthropic/package.json +0 -19
  51. package/examples/extensions/custom-provider-gitlab-duo/index.ts +0 -349
  52. package/examples/extensions/custom-provider-gitlab-duo/package.json +0 -16
  53. package/examples/extensions/custom-provider-gitlab-duo/test.ts +0 -82
  54. package/examples/extensions/custom-provider-qwen-cli/index.ts +0 -345
  55. package/examples/extensions/custom-provider-qwen-cli/package.json +0 -16
  56. package/examples/extensions/dirty-repo-guard.ts +0 -56
  57. package/examples/extensions/doom-overlay/README.md +0 -46
  58. package/examples/extensions/doom-overlay/doom/build/doom.js +0 -21
  59. package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
  60. package/examples/extensions/doom-overlay/doom/build.sh +0 -152
  61. package/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +0 -72
  62. package/examples/extensions/doom-overlay/doom-component.ts +0 -132
  63. package/examples/extensions/doom-overlay/doom-engine.ts +0 -173
  64. package/examples/extensions/doom-overlay/doom-keys.ts +0 -104
  65. package/examples/extensions/doom-overlay/index.ts +0 -74
  66. package/examples/extensions/doom-overlay/wad-finder.ts +0 -51
  67. package/examples/extensions/dynamic-resources/SKILL.md +0 -8
  68. package/examples/extensions/dynamic-resources/dynamic.json +0 -79
  69. package/examples/extensions/dynamic-resources/dynamic.md +0 -5
  70. package/examples/extensions/dynamic-resources/index.ts +0 -15
  71. package/examples/extensions/dynamic-tools.ts +0 -74
  72. package/examples/extensions/event-bus.ts +0 -43
  73. package/examples/extensions/file-trigger.ts +0 -41
  74. package/examples/extensions/git-checkpoint.ts +0 -53
  75. package/examples/extensions/handoff.ts +0 -153
  76. package/examples/extensions/hello.ts +0 -26
  77. package/examples/extensions/hidden-thinking-label.ts +0 -53
  78. package/examples/extensions/inline-bash.ts +0 -94
  79. package/examples/extensions/input-transform.ts +0 -43
  80. package/examples/extensions/interactive-shell.ts +0 -196
  81. package/examples/extensions/mac-system-theme.ts +0 -47
  82. package/examples/extensions/message-renderer.ts +0 -59
  83. package/examples/extensions/minimal-mode.ts +0 -426
  84. package/examples/extensions/modal-editor.ts +0 -85
  85. package/examples/extensions/model-status.ts +0 -31
  86. package/examples/extensions/notify.ts +0 -55
  87. package/examples/extensions/overlay-qa-tests.ts +0 -1348
  88. package/examples/extensions/overlay-test.ts +0 -150
  89. package/examples/extensions/permission-gate.ts +0 -34
  90. package/examples/extensions/pirate.ts +0 -47
  91. package/examples/extensions/plan-mode/README.md +0 -65
  92. package/examples/extensions/plan-mode/index.ts +0 -340
  93. package/examples/extensions/plan-mode/utils.ts +0 -168
  94. package/examples/extensions/preset.ts +0 -397
  95. package/examples/extensions/protected-paths.ts +0 -30
  96. package/examples/extensions/provider-payload.ts +0 -14
  97. package/examples/extensions/qna.ts +0 -122
  98. package/examples/extensions/question.ts +0 -264
  99. package/examples/extensions/questionnaire.ts +0 -427
  100. package/examples/extensions/rainbow-editor.ts +0 -88
  101. package/examples/extensions/reload-runtime.ts +0 -37
  102. package/examples/extensions/rpc-demo.ts +0 -118
  103. package/examples/extensions/sandbox/index.ts +0 -321
  104. package/examples/extensions/sandbox/package-lock.json +0 -92
  105. package/examples/extensions/sandbox/package.json +0 -19
  106. package/examples/extensions/send-user-message.ts +0 -97
  107. package/examples/extensions/session-name.ts +0 -27
  108. package/examples/extensions/shutdown-command.ts +0 -63
  109. package/examples/extensions/snake.ts +0 -343
  110. package/examples/extensions/space-invaders.ts +0 -560
  111. package/examples/extensions/ssh.ts +0 -220
  112. package/examples/extensions/status-line.ts +0 -32
  113. package/examples/extensions/subagent/README.md +0 -172
  114. package/examples/extensions/subagent/agents/planner.md +0 -37
  115. package/examples/extensions/subagent/agents/reviewer.md +0 -35
  116. package/examples/extensions/subagent/agents/scout.md +0 -50
  117. package/examples/extensions/subagent/agents/worker.md +0 -24
  118. package/examples/extensions/subagent/agents.ts +0 -126
  119. package/examples/extensions/subagent/index.ts +0 -986
  120. package/examples/extensions/subagent/prompts/implement-and-review.md +0 -10
  121. package/examples/extensions/subagent/prompts/implement.md +0 -10
  122. package/examples/extensions/subagent/prompts/scout-and-plan.md +0 -9
  123. package/examples/extensions/summarize.ts +0 -206
  124. package/examples/extensions/system-prompt-header.ts +0 -17
  125. package/examples/extensions/timed-confirm.ts +0 -70
  126. package/examples/extensions/titlebar-spinner.ts +0 -58
  127. package/examples/extensions/todo.ts +0 -297
  128. package/examples/extensions/tool-override.ts +0 -144
  129. package/examples/extensions/tools.ts +0 -141
  130. package/examples/extensions/trigger-compact.ts +0 -50
  131. package/examples/extensions/truncated-tool.ts +0 -195
  132. package/examples/extensions/widget-placement.ts +0 -9
  133. package/examples/extensions/with-deps/index.ts +0 -32
  134. package/examples/extensions/with-deps/package-lock.json +0 -31
  135. package/examples/extensions/with-deps/package.json +0 -22
  136. package/examples/rpc-extension-ui.ts +0 -632
  137. package/examples/sdk/01-minimal.ts +0 -22
  138. package/examples/sdk/02-custom-model.ts +0 -49
  139. package/examples/sdk/03-custom-prompt.ts +0 -55
  140. package/examples/sdk/04-skills.ts +0 -52
  141. package/examples/sdk/05-tools.ts +0 -56
  142. package/examples/sdk/06-extensions.ts +0 -88
  143. package/examples/sdk/07-context-files.ts +0 -40
  144. package/examples/sdk/08-prompt-templates.ts +0 -48
  145. package/examples/sdk/09-api-keys-and-oauth.ts +0 -48
  146. package/examples/sdk/10-settings.ts +0 -51
  147. package/examples/sdk/11-sessions.ts +0 -48
  148. package/examples/sdk/12-full-control.ts +0 -81
  149. package/examples/sdk/13-session-runtime.ts +0 -49
  150. package/examples/sdk/README.md +0 -145
package/docs/themes.md DELETED
@@ -1,295 +0,0 @@
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/tmux.md DELETED
@@ -1,61 +0,0 @@
1
- # tmux Setup
2
-
3
- Pi works inside tmux, but tmux strips modifier information from certain keys by default. Without configuration, `Shift+Enter` and `Ctrl+Enter` are usually indistinguishable from plain `Enter`.
4
-
5
- ## Recommended Configuration
6
-
7
- Add to `~/.tmux.conf`:
8
-
9
- ```tmux
10
- set -g extended-keys on
11
- set -g extended-keys-format csi-u
12
- ```
13
-
14
- Then restart tmux fully:
15
-
16
- ```bash
17
- tmux kill-server
18
- tmux
19
- ```
20
-
21
- Pi requests extended key reporting automatically when Kitty keyboard protocol is not available. With `extended-keys-format csi-u`, tmux forwards modified keys in CSI-u format, which is the most reliable configuration.
22
-
23
- ## Why `csi-u` Is Recommended
24
-
25
- With only:
26
-
27
- ```tmux
28
- set -g extended-keys on
29
- ```
30
-
31
- tmux defaults to `extended-keys-format xterm`. When an application requests extended key reporting, modified keys are forwarded in xterm `modifyOtherKeys` format such as:
32
-
33
- - `Ctrl+C` → `\x1b[27;5;99~`
34
- - `Ctrl+D` → `\x1b[27;5;100~`
35
- - `Ctrl+Enter` → `\x1b[27;5;13~`
36
-
37
- With `extended-keys-format csi-u`, the same keys are forwarded as:
38
-
39
- - `Ctrl+C` → `\x1b[99;5u`
40
- - `Ctrl+D` → `\x1b[100;5u`
41
- - `Ctrl+Enter` → `\x1b[13;5u`
42
-
43
- Pi supports both formats, but `csi-u` is the recommended tmux setup.
44
-
45
- ## What This Fixes
46
-
47
- Without tmux extended keys, modified Enter keys collapse to legacy sequences:
48
-
49
- | Key | Without extkeys | With `csi-u` |
50
- |-----|-----------------|--------------|
51
- | Enter | `\r` | `\r` |
52
- | Shift+Enter | `\r` | `\x1b[13;2u` |
53
- | Ctrl+Enter | `\r` | `\x1b[13;5u` |
54
- | Alt/Option+Enter | `\x1b\r` | `\x1b[13;3u` |
55
-
56
- This affects the default keybindings (`Enter` to submit, `Shift+Enter` for newline) and any custom keybindings using modified Enter.
57
-
58
- ## Requirements
59
-
60
- - tmux 3.2 or later (run `tmux -V` to check)
61
- - A terminal emulator that supports extended keys (Ghostty, Kitty, iTerm2, WezTerm, Windows Terminal)
package/docs/tree.md DELETED
@@ -1,231 +0,0 @@
1
- # Session Tree Navigation
2
-
3
- The `/tree` command provides tree-based navigation of the session history.
4
-
5
- ## Overview
6
-
7
- Sessions are stored as trees where each entry has an `id` and `parentId`. The "leaf" pointer tracks the current position. `/tree` lets you navigate to any point and optionally summarize the branch you're leaving.
8
-
9
- ### Comparison with `/fork`
10
-
11
- | Feature | `/fork` | `/tree` |
12
- |---------|---------|---------|
13
- | View | Flat list of user messages | Full tree structure |
14
- | Action | Extracts path to **new session file** | Changes leaf in **same session** |
15
- | Summary | Never | Optional (user prompted) |
16
- | Events | `session_before_fork` / `session_start` (`reason: "fork"`) | `session_before_tree` / `session_tree` |
17
-
18
- ## Tree UI
19
-
20
- ```
21
- ├─ user: "Hello, can you help..."
22
- │ └─ assistant: "Of course! I can..."
23
- │ ├─ user: "Let's try approach A..."
24
- │ │ └─ assistant: "For approach A..."
25
- │ │ └─ [compaction: 12k tokens]
26
- │ │ └─ user: "That worked..." ← active
27
- │ └─ user: "Actually, approach B..."
28
- │ └─ assistant: "For approach B..."
29
- ```
30
-
31
- ### Controls
32
-
33
- | Key | Action |
34
- |-----|--------|
35
- | ↑/↓ | Navigate (depth-first order) |
36
- | ←/→ | Page up/down |
37
- | Ctrl+←/Ctrl+→ or Alt+←/Alt+→ | Fold/unfold and jump between branch segments |
38
- | Shift+L | Set or clear a label on the selected node |
39
- | Shift+T | Toggle label timestamps |
40
- | Enter | Select node |
41
- | Escape/Ctrl+C | Cancel |
42
- | Ctrl+U | Toggle: user messages only |
43
- | Ctrl+O | Toggle: show all (including custom/label entries) |
44
-
45
- `Ctrl+←` or `Alt+←` folds the current node if it is foldable. Foldable nodes are roots and branch segment starts that have visible children. If the current node is not foldable, or is already folded, the selection jumps up to the previous visible branch segment start.
46
-
47
- `Ctrl+→` or `Alt+→` unfolds the current node if it is folded. Otherwise, the selection jumps down to the next visible branch segment start, or to the branch end when there is no further branch point.
48
-
49
- ### Display
50
-
51
- - Height: half terminal height
52
- - Current leaf marked with `← active`
53
- - Labels shown inline: `[label-name]`
54
- - `Shift+T` shows the latest label-change timestamp next to labeled nodes
55
- - Foldable branch starts show `⊟` in the connector. Folded branches show `⊞`
56
- - Active path marker `•` appears after the fold indicator when applicable
57
- - Search and filter changes reset all folds
58
- - Default filter hides `label` and `custom` entries (shown in Ctrl+O mode)
59
- - At each branch point, the active subtree is shown first; other sibling branches are sorted by timestamp (oldest first)
60
-
61
- ## Selection Behavior
62
-
63
- ### User Message or Custom Message
64
- 1. Leaf set to **parent** of selected node (or `null` if root)
65
- 2. Message text placed in **editor** for re-submission
66
- 3. User edits and submits, creating a new branch
67
-
68
- ### Non-User Message (assistant, compaction, etc.)
69
- 1. Leaf set to **selected node**
70
- 2. Editor stays empty
71
- 3. User continues from that point
72
-
73
- ### Selecting Root User Message
74
- If user selects the very first message (has no parent):
75
- 1. Leaf reset to `null` (empty conversation)
76
- 2. Message text placed in editor
77
- 3. User effectively restarts from scratch
78
-
79
- ## Branch Summarization
80
-
81
- When switching branches, user is presented with three options:
82
-
83
- 1. **No summary** - Switch immediately without summarizing
84
- 2. **Summarize** - Generate a summary using the default prompt
85
- 3. **Summarize with custom prompt** - Opens an editor to enter additional focus instructions that are appended to the default summarization prompt
86
-
87
- ### What Gets Summarized
88
-
89
- Path from old leaf back to common ancestor with target:
90
-
91
- ```
92
- A → B → C → D → E → F ← old leaf
93
- ↘ G → H ← target
94
- ```
95
-
96
- Abandoned path: D → E → F (summarized)
97
-
98
- Summarization stops at:
99
- 1. Common ancestor (always)
100
- 2. Compaction node (if encountered first)
101
-
102
- ### Summary Storage
103
-
104
- Stored as `BranchSummaryEntry`:
105
-
106
- ```typescript
107
- interface BranchSummaryEntry {
108
- type: "branch_summary";
109
- id: string;
110
- parentId: string; // New leaf position
111
- timestamp: string;
112
- fromId: string; // Old leaf we abandoned
113
- summary: string; // LLM-generated summary
114
- details?: unknown; // Optional hook data
115
- }
116
- ```
117
-
118
- ## Implementation
119
-
120
- ### AgentSession.navigateTree()
121
-
122
- ```typescript
123
- async navigateTree(
124
- targetId: string,
125
- options?: {
126
- summarize?: boolean;
127
- customInstructions?: string;
128
- replaceInstructions?: boolean;
129
- label?: string;
130
- }
131
- ): Promise<{ editorText?: string; cancelled: boolean }>
132
- ```
133
-
134
- Options:
135
- - `summarize`: Whether to generate a summary of the abandoned branch
136
- - `customInstructions`: Custom instructions for the summarizer
137
- - `replaceInstructions`: If true, `customInstructions` replaces the default prompt instead of being appended
138
- - `label`: Label to attach to the branch summary entry (or target entry if not summarizing)
139
-
140
- Flow:
141
- 1. Validate target, check no-op (target === current leaf)
142
- 2. Find common ancestor between old leaf and target
143
- 3. Collect entries to summarize (if requested)
144
- 4. Fire `session_before_tree` event (hook can cancel or provide summary)
145
- 5. Run default summarizer if needed
146
- 6. Switch leaf via `branch()` or `branchWithSummary()`
147
- 7. Update agent: `agent.state.messages = sessionManager.buildSessionContext().messages`
148
- 8. Fire `session_tree` event
149
- 9. Notify custom tools via session event
150
- 10. Return result with `editorText` if user message was selected
151
-
152
- ### SessionManager
153
-
154
- - `getLeafUuid(): string | null` - Current leaf (null if empty)
155
- - `resetLeaf(): void` - Set leaf to null (for root user message navigation)
156
- - `getTree(): SessionTreeNode[]` - Full tree with children sorted by timestamp
157
- - `branch(id)` - Change leaf pointer
158
- - `branchWithSummary(id, summary)` - Change leaf and create summary entry
159
-
160
- ### InteractiveMode
161
-
162
- `/tree` command shows `TreeSelectorComponent`, then:
163
- 1. Prompt for summarization
164
- 2. Call `session.navigateTree()`
165
- 3. Clear and re-render chat
166
- 4. Set editor text if applicable
167
-
168
- ## Hook Events
169
-
170
- ### `session_before_tree`
171
-
172
- ```typescript
173
- interface TreePreparation {
174
- targetId: string;
175
- oldLeafId: string | null;
176
- commonAncestorId: string | null;
177
- entriesToSummarize: SessionEntry[];
178
- userWantsSummary: boolean;
179
- customInstructions?: string;
180
- replaceInstructions?: boolean;
181
- label?: string;
182
- }
183
-
184
- interface SessionBeforeTreeEvent {
185
- type: "session_before_tree";
186
- preparation: TreePreparation;
187
- signal: AbortSignal;
188
- }
189
-
190
- interface SessionBeforeTreeResult {
191
- cancel?: boolean;
192
- summary?: { summary: string; details?: unknown };
193
- customInstructions?: string; // Override custom instructions
194
- replaceInstructions?: boolean; // Override replace mode
195
- label?: string; // Override label
196
- }
197
- ```
198
-
199
- Extensions can override `customInstructions`, `replaceInstructions`, and `label` by returning them from the `session_before_tree` handler.
200
-
201
- ### `session_tree`
202
-
203
- ```typescript
204
- interface SessionTreeEvent {
205
- type: "session_tree";
206
- newLeafId: string | null;
207
- oldLeafId: string | null;
208
- summaryEntry?: BranchSummaryEntry;
209
- fromHook?: boolean;
210
- }
211
- ```
212
-
213
- ### Example: Custom Summarizer
214
-
215
- ```typescript
216
- export default function(pi: HookAPI) {
217
- pi.on("session_before_tree", async (event, ctx) => {
218
- if (!event.preparation.userWantsSummary) return;
219
- if (event.preparation.entriesToSummarize.length === 0) return;
220
-
221
- const summary = await myCustomSummarizer(event.preparation.entriesToSummarize);
222
- return { summary: { summary, details: { custom: true } } };
223
- });
224
- }
225
- ```
226
-
227
- ## Error Handling
228
-
229
- - Summarization failure: cancels navigation, shows error
230
- - User abort (Escape): cancels navigation
231
- - Hook returns `cancel: true`: cancels navigation silently