@knightcodeai/cli-linux-x64 0.9.0 → 0.9.2
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/bin/CHANGELOG.md +88 -0
- package/bin/README.md +52 -19
- package/bin/docs/cli-integration.md +106 -0
- package/bin/docs/cli.md +270 -0
- package/bin/docs/compaction.md +56 -37
- package/bin/docs/configuration.md +46 -0
- package/bin/docs/containerization.md +86 -54
- package/bin/docs/custom-provider.md +132 -782
- package/bin/docs/docs.json +143 -103
- package/bin/docs/environment-variables.md +5 -3
- package/bin/docs/extensions.md +134 -2937
- package/bin/docs/how-knightcode-works.md +49 -0
- package/bin/docs/index.md +24 -69
- package/bin/docs/json.md +193 -65
- package/bin/docs/keybindings.md +56 -101
- package/bin/docs/llama-cpp.md +3 -3
- package/bin/docs/message-types.md +261 -0
- package/bin/docs/models.md +65 -517
- package/bin/docs/packages.md +66 -167
- package/bin/docs/prompt-templates.md +31 -68
- package/bin/docs/providers.md +103 -233
- package/bin/docs/quickstart.md +61 -106
- package/bin/docs/rpc-commands.md +854 -0
- package/bin/docs/rpc-extension-ui.md +200 -0
- package/bin/docs/rpc.md +129 -1556
- package/bin/docs/sdk.md +76 -1160
- package/bin/docs/security.md +70 -32
- package/bin/docs/session-format.md +39 -216
- package/bin/docs/sessions.md +43 -121
- package/bin/docs/settings.md +112 -367
- package/bin/docs/shell-aliases.md +85 -5
- package/bin/docs/skills.md +51 -189
- package/bin/docs/slash-commands.md +63 -0
- package/bin/docs/terminal-setup.md +107 -79
- package/bin/docs/termux.md +74 -83
- package/bin/docs/themes.md +68 -280
- package/bin/docs/tmux.md +31 -39
- package/bin/docs/tui.md +69 -923
- package/bin/docs/usage.md +79 -285
- package/bin/docs/windows.md +43 -17
- package/bin/export-html/template.js +6 -1
- package/bin/knightcode +2 -2
- package/bin/package.json +6 -6
- package/package.json +1 -1
- package/bin/docs/development.md +0 -71
|
@@ -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 KnightCode
|
|
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": "knightcode - 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 KnightCode
|
|
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/KnightCodeAI/knightcode/blob/main/packages/cli/src/modes/rpc/rpc-types.ts). See [Extensions](extensions.md#ui-and-modes) for mode-independent extension guidance.
|