@earendil-works/pi-coding-agent 0.87.0 → 0.87.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 (75) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +25 -711
  3. package/dist/bundle/chunks/{anthropic-messages-MYU5ZMRF.js → anthropic-messages-J5WXPPPC.js} +1 -1
  4. package/dist/bundle/chunks/{chunk-GV2E3GBU.js → chunk-65HAU2C5.js} +1 -1
  5. package/dist/bundle/chunks/{chunk-4DKZACXI.js → chunk-OJP47DM6.js} +13 -13
  6. package/dist/bundle/chunks/github-copilot.js +1 -1
  7. package/dist/bundle/chunks/{openai-completions-XHML6MTL.js → openai-completions-OBX42CLD.js} +1 -1
  8. package/dist/bundle/chunks/{virtual-modules-BNWPZYDH.js → virtual-modules-VHMJYYWQ.js} +1 -1
  9. package/dist/bundle/cli-runtime.js +1 -1
  10. package/dist/bundle/index.js +1 -1
  11. package/dist/bundle/rpc-entry.js +1 -1
  12. package/dist/cli/args.d.ts.map +1 -1
  13. package/dist/cli/args.js +14 -4
  14. package/dist/cli/args.js.map +1 -1
  15. package/dist/core/compaction/compaction.d.ts.map +1 -1
  16. package/dist/core/compaction/compaction.js +9 -9
  17. package/dist/core/compaction/compaction.js.map +1 -1
  18. package/dist/core/model-resolver.d.ts.map +1 -1
  19. package/dist/core/model-resolver.js +1 -1
  20. package/dist/core/model-resolver.js.map +1 -1
  21. package/docs/cli-integration.md +106 -0
  22. package/docs/cli.md +268 -0
  23. package/docs/compaction.md +22 -22
  24. package/docs/configuration.md +45 -0
  25. package/docs/containerization.md +109 -82
  26. package/docs/custom-provider.md +132 -784
  27. package/docs/docs.json +139 -99
  28. package/docs/environment-variables.md +3 -5
  29. package/docs/extensions.md +134 -3020
  30. package/docs/how-pi-works.md +49 -0
  31. package/docs/images/interactive-mode.png +0 -0
  32. package/docs/index.md +24 -69
  33. package/docs/json.md +193 -65
  34. package/docs/keybindings.md +57 -102
  35. package/docs/llama-cpp.md +3 -3
  36. package/docs/message-types.md +261 -0
  37. package/docs/models.md +55 -565
  38. package/docs/packages.md +66 -167
  39. package/docs/prompt-templates.md +31 -68
  40. package/docs/providers.md +102 -240
  41. package/docs/quickstart.md +61 -106
  42. package/docs/rpc-commands.md +854 -0
  43. package/docs/rpc-extension-ui.md +200 -0
  44. package/docs/rpc.md +129 -1556
  45. package/docs/sdk.md +76 -1171
  46. package/docs/security.md +70 -32
  47. package/docs/session-format.md +10 -214
  48. package/docs/sessions.md +35 -141
  49. package/docs/settings.md +109 -387
  50. package/docs/shell-aliases.md +85 -5
  51. package/docs/skills.md +51 -190
  52. package/docs/slash-commands.md +60 -0
  53. package/docs/terminal-setup.md +105 -78
  54. package/docs/termux.md +74 -83
  55. package/docs/themes.md +68 -280
  56. package/docs/tmux.md +31 -39
  57. package/docs/tui.md +69 -923
  58. package/docs/usage.md +54 -272
  59. package/docs/windows.md +43 -17
  60. package/examples/README.md +13 -2
  61. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  62. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  63. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  64. package/examples/extensions/gondolin/package-lock.json +2 -2
  65. package/examples/extensions/gondolin/package.json +1 -1
  66. package/examples/extensions/sandbox/package-lock.json +2 -2
  67. package/examples/extensions/sandbox/package.json +1 -1
  68. package/examples/extensions/with-deps/package-lock.json +2 -2
  69. package/examples/extensions/with-deps/package.json +1 -1
  70. package/examples/rpc-client.ts +35 -0
  71. package/examples/rpc-extension-ui.ts +25 -5
  72. package/examples/sdk/README.md +1 -1
  73. package/npm-shrinkwrap.json +20 -20
  74. package/package.json +8 -8
  75. package/docs/development.md +0 -90
@@ -0,0 +1,200 @@
1
+ # RPC Extension UI
2
+
3
+ Extensions can request user interaction through `ctx.ui`. In RPC mode, supported calls become a request/response subprotocol alongside normal [RPC commands](rpc-commands.md) and [session events](json.md).
4
+
5
+ There are two categories of extension UI methods:
6
+
7
+ - **Dialog methods** (`select`, `confirm`, `input`, `editor`): emit an `extension_ui_request` on stdout and block until the client sends back an `extension_ui_response` on stdin with the matching `id`.
8
+ - **Fire-and-forget methods** (`notify`, `setStatus`, `setWidget`, `setTitle`, `set_editor_text`): emit an `extension_ui_request` on stdout but do not expect a response. The client can display the information or ignore it.
9
+
10
+ If a dialog method includes a `timeout` field, the agent-side will auto-resolve with a default value when the timeout expires. The client does not need to track timeouts.
11
+
12
+ ## Limitations
13
+
14
+ Some `ExtensionUIContext` methods are not supported or degraded in RPC mode because they require direct terminal UI access:
15
+
16
+ - `custom()` returns `undefined`.
17
+ - `onTerminalInput()` returns a no-op unsubscribe function.
18
+ - `setWorkingMessage()`, `setWorkingVisible()`, `setWorkingIndicator()`, `setHiddenThinkingLabel()`, `setFooter()`, `setHeader()`, `addAutocompleteProvider()`, `setEditorComponent()`, and `setToolsExpanded()` are no-ops.
19
+ - `getEditorText()` returns `""` and `getEditorComponent()` returns `undefined`.
20
+ - `getToolsExpanded()` returns `false`.
21
+ - `pasteToEditor()` delegates to `setEditorText()` without terminal paste handling.
22
+ - `getAllThemes()` returns `[]`, and `getTheme()` returns `undefined`.
23
+ - `setTheme()` returns `{ success: false, error: "Theme switching not supported in RPC mode" }`.
24
+
25
+ Note: `ctx.mode` is `"rpc"` and `ctx.hasUI` is `true` in RPC mode because the dialog and fire-and-forget methods are functional via the extension UI sub-protocol. Use `ctx.mode === "tui"` to guard TUI-specific features like `custom()` that require a real terminal.
26
+
27
+ ## Requests from Pi
28
+
29
+ All requests have `type: "extension_ui_request"`, a unique `id`, and a `method` field.
30
+
31
+ ### select
32
+
33
+ Prompt the user to choose from a list. Dialog methods with a `timeout` field include the timeout in milliseconds; the agent auto-resolves with `undefined` if the client doesn't respond in time.
34
+
35
+ ```json
36
+ {
37
+ "type": "extension_ui_request",
38
+ "id": "uuid-1",
39
+ "method": "select",
40
+ "title": "Allow dangerous command?",
41
+ "options": ["Allow", "Block"],
42
+ "timeout": 10000
43
+ }
44
+ ```
45
+
46
+ Expected response: `extension_ui_response` with `value` (the selected option string) or `cancelled: true`.
47
+
48
+ ### confirm
49
+
50
+ Prompt the user for yes/no confirmation.
51
+
52
+ ```json
53
+ {
54
+ "type": "extension_ui_request",
55
+ "id": "uuid-2",
56
+ "method": "confirm",
57
+ "title": "Clear session?",
58
+ "message": "All messages will be lost.",
59
+ "timeout": 5000
60
+ }
61
+ ```
62
+
63
+ Expected response: `extension_ui_response` with `confirmed: true/false` or `cancelled: true`.
64
+
65
+ ### input
66
+
67
+ Prompt the user for free-form text.
68
+
69
+ ```json
70
+ {
71
+ "type": "extension_ui_request",
72
+ "id": "uuid-3",
73
+ "method": "input",
74
+ "title": "Enter a value",
75
+ "placeholder": "type something..."
76
+ }
77
+ ```
78
+
79
+ Expected response: `extension_ui_response` with `value` (the entered text) or `cancelled: true`.
80
+
81
+ ### editor
82
+
83
+ Open a multi-line text editor with optional prefilled content.
84
+
85
+ ```json
86
+ {
87
+ "type": "extension_ui_request",
88
+ "id": "uuid-4",
89
+ "method": "editor",
90
+ "title": "Edit some text",
91
+ "prefill": "Line 1\nLine 2\nLine 3"
92
+ }
93
+ ```
94
+
95
+ Expected response: `extension_ui_response` with `value` (the edited text) or `cancelled: true`.
96
+
97
+ ### notify
98
+
99
+ Display a notification. Fire-and-forget, no response expected.
100
+
101
+ ```json
102
+ {
103
+ "type": "extension_ui_request",
104
+ "id": "uuid-5",
105
+ "method": "notify",
106
+ "message": "Command blocked by user",
107
+ "notifyType": "warning"
108
+ }
109
+ ```
110
+
111
+ The `notifyType` field is `"info"`, `"warning"`, or `"error"`. Defaults to `"info"` if omitted.
112
+
113
+ ### setStatus
114
+
115
+ Set or clear a status entry in the footer/status bar. Fire-and-forget.
116
+
117
+ ```json
118
+ {
119
+ "type": "extension_ui_request",
120
+ "id": "uuid-6",
121
+ "method": "setStatus",
122
+ "statusKey": "my-ext",
123
+ "statusText": "Turn 3 running..."
124
+ }
125
+ ```
126
+
127
+ Send `statusText: undefined` (or omit it) to clear the status entry for that key.
128
+
129
+ ### setWidget
130
+
131
+ Set or clear a widget (block of text lines) displayed above or below the editor. Fire-and-forget.
132
+
133
+ ```json
134
+ {
135
+ "type": "extension_ui_request",
136
+ "id": "uuid-7",
137
+ "method": "setWidget",
138
+ "widgetKey": "my-ext",
139
+ "widgetLines": ["--- My Widget ---", "Line 1", "Line 2"],
140
+ "widgetPlacement": "aboveEditor"
141
+ }
142
+ ```
143
+
144
+ Send `widgetLines: undefined` (or omit it) to clear the widget. The `widgetPlacement` field is `"aboveEditor"` (default) or `"belowEditor"`. Only string arrays are supported in RPC mode; component factories are ignored.
145
+
146
+ ### setTitle
147
+
148
+ Set the terminal window/tab title. Fire-and-forget.
149
+
150
+ ```json
151
+ {
152
+ "type": "extension_ui_request",
153
+ "id": "uuid-8",
154
+ "method": "setTitle",
155
+ "title": "pi - my project"
156
+ }
157
+ ```
158
+
159
+ ### set_editor_text
160
+
161
+ Set the text in the input editor. Fire-and-forget.
162
+
163
+ ```json
164
+ {
165
+ "type": "extension_ui_request",
166
+ "id": "uuid-9",
167
+ "method": "set_editor_text",
168
+ "text": "prefilled text for the user"
169
+ }
170
+ ```
171
+
172
+ ## Responses to Pi
173
+
174
+ Responses are sent for dialog methods only (`select`, `confirm`, `input`, `editor`). The `id` must match the request.
175
+
176
+ ### Value response (select, input, editor)
177
+
178
+ ```json
179
+ {"type": "extension_ui_response", "id": "uuid-1", "value": "Allow"}
180
+ ```
181
+
182
+ ### Confirmation response (confirm)
183
+
184
+ ```json
185
+ {"type": "extension_ui_response", "id": "uuid-2", "confirmed": true}
186
+ ```
187
+
188
+ ### Cancellation response (any dialog)
189
+
190
+ Dismiss any dialog method. The extension receives `undefined` (for select/input/editor) or `false` (for confirm).
191
+
192
+ ```json
193
+ {"type": "extension_ui_response", "id": "uuid-3", "cancelled": true}
194
+ ```
195
+
196
+ ## Example
197
+
198
+ See the checked [RPC extension UI client](../examples/rpc-extension-ui.ts) and its [demo extension](../examples/extensions/rpc-demo.ts).
199
+
200
+ The exported request and response unions are defined in [`rpc-types.ts`](https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/modes/rpc/rpc-types.ts). See [Extensions](extensions.md#ui-and-modes) for mode-independent extension guidance.