kward 0.71.0 → 0.73.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.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +30 -0
- data/CHANGELOG.md +93 -0
- data/Gemfile.lock +2 -2
- data/README.md +4 -0
- data/doc/agent-tools.md +15 -6
- data/doc/authentication.md +22 -1
- data/doc/code-search.md +42 -2
- data/doc/configuration.md +106 -3
- data/doc/context-budgeting.md +136 -0
- data/doc/context-tools.md +16 -3
- data/doc/editor.md +415 -0
- data/doc/extensibility.md +16 -7
- data/doc/files.md +100 -0
- data/doc/getting-started.md +25 -18
- data/doc/git.md +123 -0
- data/doc/memory.md +24 -4
- data/doc/personas.md +34 -5
- data/doc/plugins.md +72 -1
- data/doc/releasing.md +37 -9
- data/doc/rpc.md +75 -5
- data/doc/session-management.md +35 -1
- data/doc/shell.md +332 -0
- data/doc/tabs.md +122 -0
- data/doc/troubleshooting.md +77 -1
- data/doc/usage.md +79 -7
- data/doc/web-search.md +12 -4
- data/doc/workspace-tools.md +51 -12
- data/examples/plugins/space_invaders.rb +377 -0
- data/lib/kward/agent.rb +1 -1
- data/lib/kward/ansi.rb +62 -23
- data/lib/kward/cli/commands.rb +33 -2
- data/lib/kward/cli/git.rb +150 -0
- data/lib/kward/cli/interactive_turn.rb +73 -9
- data/lib/kward/cli/plugins.rb +54 -4
- data/lib/kward/cli/prompt_interface.rb +32 -1
- data/lib/kward/cli/rendering.rb +4 -1
- data/lib/kward/cli/runtime_helpers.rb +268 -4
- data/lib/kward/cli/sessions.rb +2 -2
- data/lib/kward/cli/settings.rb +217 -9
- data/lib/kward/cli/slash_commands.rb +628 -2
- data/lib/kward/cli/tabs.rb +725 -0
- data/lib/kward/cli/tool_summaries.rb +6 -0
- data/lib/kward/cli.rb +150 -26
- data/lib/kward/clipboard.rb +2 -3
- data/lib/kward/compactor.rb +7 -19
- data/lib/kward/config_files.rb +145 -1
- data/lib/kward/context_budget_meter.rb +44 -0
- data/lib/kward/conversation.rb +12 -4
- data/lib/kward/editor_mode.rb +25 -0
- data/lib/kward/ekwsh.rb +559 -0
- data/lib/kward/image_attachments.rb +3 -1
- data/lib/kward/interactive_pty_runner.rb +151 -0
- data/lib/kward/local_command_runner.rb +155 -0
- data/lib/kward/local_pty_command_runner.rb +171 -0
- data/lib/kward/model/context_usage.rb +2 -2
- data/lib/kward/model/payloads.rb +2 -5
- data/lib/kward/plugin_registry.rb +61 -0
- data/lib/kward/project_files.rb +52 -0
- data/lib/kward/prompt_history.rb +84 -0
- data/lib/kward/prompt_interface/composer_controller.rb +69 -1
- data/lib/kward/prompt_interface/composer_renderer.rb +109 -13
- data/lib/kward/prompt_interface/composer_state.rb +96 -27
- data/lib/kward/prompt_interface/editor/auto_close_pairs.rb +123 -0
- data/lib/kward/prompt_interface/editor/auto_indent.rb +510 -0
- data/lib/kward/prompt_interface/editor/buffer.rb +109 -0
- data/lib/kward/prompt_interface/editor/controller.rb +1218 -0
- data/lib/kward/prompt_interface/editor/endwise.rb +321 -0
- data/lib/kward/prompt_interface/editor/file_marker.rb +40 -0
- data/lib/kward/prompt_interface/editor/indent_navigation.rb +61 -0
- data/lib/kward/prompt_interface/editor/kill_ring.rb +78 -0
- data/lib/kward/prompt_interface/editor/modes/emacs.rb +259 -0
- data/lib/kward/prompt_interface/editor/modes/modern.rb +354 -0
- data/lib/kward/prompt_interface/editor/modes/vibe.rb +1812 -0
- data/lib/kward/prompt_interface/editor/modes/vibe_insert_readline.rb +166 -0
- data/lib/kward/prompt_interface/editor/renderer.rb +244 -0
- data/lib/kward/prompt_interface/editor/search.rb +76 -0
- data/lib/kward/prompt_interface/editor/selections.rb +120 -0
- data/lib/kward/prompt_interface/editor/state.rb +1271 -0
- data/lib/kward/prompt_interface/editor/status_text.rb +23 -0
- data/lib/kward/prompt_interface/editor/syntax_highlighter.rb +422 -0
- data/lib/kward/prompt_interface/editor/undo_history.rb +46 -0
- data/lib/kward/prompt_interface/editor/vibe_state.rb +44 -0
- data/lib/kward/prompt_interface/file_overlay.rb +211 -0
- data/lib/kward/prompt_interface/git_prompt.rb +288 -0
- data/lib/kward/prompt_interface/interactive/controller.rb +186 -0
- data/lib/kward/prompt_interface/interactive/renderer.rb +71 -0
- data/lib/kward/prompt_interface/interactive/state.rb +62 -0
- data/lib/kward/prompt_interface/key_handler.rb +451 -57
- data/lib/kward/prompt_interface/overlay_renderer.rb +21 -2
- data/lib/kward/prompt_interface/project_browser.rb +524 -0
- data/lib/kward/prompt_interface/question_prompt.rb +99 -56
- data/lib/kward/prompt_interface/runtime_state.rb +43 -0
- data/lib/kward/prompt_interface/screen.rb +19 -3
- data/lib/kward/prompt_interface/selection_prompt.rb +10 -19
- data/lib/kward/prompt_interface/slash_overlay.rb +2 -0
- data/lib/kward/prompt_interface/stream_state.rb +7 -0
- data/lib/kward/prompt_interface/transcript_buffer.rb +6 -0
- data/lib/kward/prompt_interface.rb +366 -222
- data/lib/kward/prompts/commands.rb +9 -0
- data/lib/kward/prompts.rb +2 -0
- data/lib/kward/rpc/memory_methods.rb +83 -0
- data/lib/kward/rpc/server.rb +169 -83
- data/lib/kward/rpc/session_manager.rb +45 -121
- data/lib/kward/rpc/session_tree_rows.rb +9 -115
- data/lib/kward/rpc/tool_event_normalizer.rb +1 -1
- data/lib/kward/rpc/tool_metadata.rb +11 -0
- data/lib/kward/rpc/transcript_normalizer.rb +4 -39
- data/lib/kward/scratchpad_runner.rb +56 -0
- data/lib/kward/session_diff.rb +20 -3
- data/lib/kward/session_naming.rb +11 -0
- data/lib/kward/session_store.rb +44 -0
- data/lib/kward/session_tree_nodes.rb +136 -0
- data/lib/kward/session_tree_renderer.rb +9 -131
- data/lib/kward/tab_store.rb +47 -0
- data/lib/kward/terminal_keys.rb +84 -0
- data/lib/kward/terminal_sequences.rb +42 -0
- data/lib/kward/text_boundary.rb +25 -0
- data/lib/kward/tools/context_budget_stats.rb +54 -0
- data/lib/kward/tools/context_for_task.rb +204 -0
- data/lib/kward/tools/read_file.rb +8 -4
- data/lib/kward/tools/registry.rb +62 -16
- data/lib/kward/tools/tool_call.rb +10 -0
- data/lib/kward/version.rb +1 -1
- data/lib/kward/workers/git_guard.rb +93 -0
- data/lib/kward/workers/job.rb +99 -0
- data/lib/kward/workers/live_view.rb +49 -0
- data/lib/kward/workers/manager.rb +288 -0
- data/lib/kward/workers/queue_runner.rb +166 -0
- data/lib/kward/workers/queue_store.rb +112 -0
- data/lib/kward/workers/store.rb +72 -0
- data/lib/kward/workers/tool_policy.rb +23 -0
- data/lib/kward/workers/worker.rb +82 -0
- data/lib/kward/workers/write_lock.rb +38 -0
- data/lib/kward/workers.rb +10 -0
- data/lib/kward/workspace.rb +125 -87
- data/templates/default/fulldoc/html/css/kward.css +140 -36
- data/templates/default/fulldoc/html/images/kward_screen_1.png +0 -0
- data/templates/default/fulldoc/html/setup.rb +1 -0
- data/templates/default/kward_navigation.rb +12 -1
- data/templates/default/layout/html/layout.erb +23 -34
- data/templates/default/layout/html/setup.rb +6 -0
- metadata +67 -1
data/doc/rpc.md
CHANGED
|
@@ -6,6 +6,8 @@ Kward RPC is an experimental backend protocol for UI clients. It is versioned as
|
|
|
6
6
|
|
|
7
7
|
This page is for people building UI clients or integrations. If you use Kward from the terminal, you can skip it.
|
|
8
8
|
|
|
9
|
+
Prompt history search is a CLI terminal feature only. RPC clients own their composer/input UX and Kward does not currently expose prompt-history read, append, or search methods over RPC.
|
|
10
|
+
|
|
9
11
|
## Launch
|
|
10
12
|
|
|
11
13
|
```bash
|
|
@@ -48,14 +50,14 @@ Result fields:
|
|
|
48
50
|
Detailed capability fields include:
|
|
49
51
|
|
|
50
52
|
- `transcript`: Tauren transcript format support, including normalized messages, image/tool support, compaction summaries, and restored assistant reasoning as Pi-compatible `thinking` content blocks.
|
|
51
|
-
- `sessions`: explicit RPC session mode, JSONL persistence, supported session methods, startup auto-resume capability/default, immediate transcript support for auto-resume, RPC list support, supported linear-session fork methods, supported compaction, and explicit unsupported import/
|
|
53
|
+
- `sessions`: explicit RPC session mode, JSONL persistence, supported session methods, startup auto-resume capability/default, immediate transcript support for auto-resume, RPC list support, supported linear-session fork methods, supported compaction, supported tree navigation with labels and branch summarization, explicit unsupported import support, and unsupported live session updates reported with `notification: "session/updated"`.
|
|
52
54
|
- `turns`: async turn mode, per-session concurrency, provider-gated native busy-input steering, queued follow-up input, best-effort cancellation, and recent in-memory event replay behavior.
|
|
53
|
-
- `events`: `turn/event` notification details, assistant/reasoning event names, normalized tool metadata, diff result support, configured workspace guardrail status, and explicit unsupported shell changed-file detection/session update flags.
|
|
55
|
+
- `events`: `turn/event` notification details, assistant/reasoning event names, normalized tool metadata, diff result support, configured workspace guardrail status, focused context and context-budget stats tool support, and explicit unsupported shell changed-file detection/session update flags.
|
|
54
56
|
- `attachments`: supported input attachment contract for `turns/start`, with accepted base64 image MIME types and a stable max byte value.
|
|
55
57
|
- `models`: model/reasoning RPC methods, explicit OpenRouter catalog listing, exposed model fields, and no scoped model support.
|
|
56
58
|
- `runtime`: supported state/stats methods with message-count stats and OpenAI/Codex context usage. Cumulative token and cost stats are not computed.
|
|
57
59
|
- `runtimeSettings`: live `runtime/updateSetting` support for `defaultModel` and `defaultThinkingLevel`, plus `runtime/reload`.
|
|
58
|
-
- `auth`: Tauren auth provider format, OpenAI and Anthropic OAuth, OpenRouter API-key login, and provider logout for stored credentials.
|
|
60
|
+
- `auth`: Tauren auth provider format, OpenAI and Anthropic OAuth, OpenRouter API-key login, GitHub/Copilot status reporting, and provider logout for stored credentials. GitHub OAuth login is CLI-only; RPC reports `supported: false` for the GitHub provider with a reason string.
|
|
59
61
|
- `memory`: opt-in structured memory support, interactive prompt injection only, JSON/JSONL local storage, and dedicated `memory/*` methods.
|
|
60
62
|
- `commands`: supported `commands/list` capability for prompt, skill, and plugin command sources, plus plugin execution through `commands/run` or plugin slash turns.
|
|
61
63
|
- `startupResources`: supported startup resource listing for context, skills, prompts, and plugins.
|
|
@@ -63,6 +65,10 @@ Detailed capability fields include:
|
|
|
63
65
|
- `composer`: composer-only UI features. Interactive session diff totals are explicitly unsupported over RPC (`composer.sessionDiff.supported: false`) because RPC clients already receive per-tool diff results and no live composer status payload is exposed. Clipboard copy is also unsupported over RPC (`composer.copy.supported: false`) because UI clients own clipboard access.
|
|
64
66
|
- `security`: trusted-local behavior; no workspace mutation guard or tool approval, shell/file mutation can run. File-tool workspace guardrails are reported under `capabilities.events.tools.workspaceGuardrails` and `runtime/state.workspaceGuardrailsEnabled`.
|
|
65
67
|
- `export`: supported transcript export formats. Currently `markdown` and `html`; default is `markdown`.
|
|
68
|
+
- `workers`: experimental agent worker pipeline. Reports `supported: false` by default; set to `supported: true` with `methods: ["workers/list", "workers/show"]` when Kward is launched with `--experimental-workers`.
|
|
69
|
+
- `starterPack`: explicitly unsupported (`supported: false`, reason `cliOnlyInstallCommand`). Use `kward init` from the shell.
|
|
70
|
+
- `shell`: explicitly unsupported (`supported: false`, reason `interactiveTuiOnly`) because `/shell` is the local embedded TUI shell.
|
|
71
|
+
- `logging`: local redacted telemetry logging support, the log directory, enabled categories, `methods: ["logging/stats", "logging/tokenCsv"]`, `usageCsv` sub-capability with bucket support, JSONL format, rotation (10 MB, manual retention), config key `logging`, env prefix `KWARD_LOGGING`, and redacted-metadata-only content.
|
|
66
72
|
|
|
67
73
|
### `shutdown`
|
|
68
74
|
|
|
@@ -217,6 +223,37 @@ Closes the RPC session. Empty unnamed session files may be cleaned up.
|
|
|
217
223
|
|
|
218
224
|
Returns session metadata and full conversation messages. Assistant `reasoning_summary` values and existing `thinking`/`reasoning` content parts are restored as normalized `{ "type": "thinking", "thinking": "..." }` blocks before assistant text; reasoning is not merged into normal text blocks.
|
|
219
225
|
|
|
226
|
+
### `sessions/tree`
|
|
227
|
+
|
|
228
|
+
Params:
|
|
229
|
+
|
|
230
|
+
- `sessionId`
|
|
231
|
+
|
|
232
|
+
Returns the full branching session tree as flattened Tauren-compatible rows (`tauren-tree-items-v1`). Each row includes `entryId`, `parentId`, `role`, `text` (compact display text), `current` (whether it is the active leaf), `depth`, `isLast`, `ancestorContinues`, `activePath`, `selectable`, `label`, `labelTimestamp`, and `prefix` (tree-drawing connector string). User-message entries are selectable; assistant/tool entries are not.
|
|
233
|
+
|
|
234
|
+
### `sessions/tree/setLabel`
|
|
235
|
+
|
|
236
|
+
Params:
|
|
237
|
+
|
|
238
|
+
- `sessionId`
|
|
239
|
+
- `entryId`
|
|
240
|
+
- `label`: optional display label override for the entry.
|
|
241
|
+
|
|
242
|
+
Persists a label override for one tree entry and returns `{ "ok": true }`.
|
|
243
|
+
|
|
244
|
+
### `sessions/tree/navigate`
|
|
245
|
+
|
|
246
|
+
Params:
|
|
247
|
+
|
|
248
|
+
- `sessionId`
|
|
249
|
+
- `entryId`: a selectable entry ID from `sessions/tree`.
|
|
250
|
+
- `summarize`: optional boolean; when true, Kward summarizes the abandoned branch before moving.
|
|
251
|
+
- `customInstructions`: optional additional guidance for the summarizer.
|
|
252
|
+
|
|
253
|
+
Moves the active branch to the selected tree entry. If the entry is a user message, its parent becomes the new active leaf and the user message text is returned as `editorText` so clients can place it into the composer for editing/resubmission. When `summarize` is true, a branch summary is generated and appended to the session before moving.
|
|
254
|
+
|
|
255
|
+
Returns `{ "session": {}, "editorText": "...", "cancelled": false, "aborted": false }`. Fields with no value are omitted.
|
|
256
|
+
|
|
220
257
|
## Turn methods
|
|
221
258
|
|
|
222
259
|
Turns are asynchronous. A session queues turns sequentially; only one turn runs per session at a time.
|
|
@@ -276,6 +313,7 @@ Known event types:
|
|
|
276
313
|
|
|
277
314
|
- `turnQueued`
|
|
278
315
|
- `turnSteered`
|
|
316
|
+
- `steeringApplied`
|
|
279
317
|
- `turnStarted`
|
|
280
318
|
- `reasoningDelta`
|
|
281
319
|
- `assistantDelta`
|
|
@@ -292,6 +330,8 @@ Lifecycle payloads include `status` for `turnQueued`, `turnStarted`, and `turnFi
|
|
|
292
330
|
|
|
293
331
|
`modelRetry` is emitted before Kward retries a transient model request failure. Its payload includes `provider`, `model`, `attempt`, `maxAttempts`, `delaySeconds`, and `error`.
|
|
294
332
|
|
|
333
|
+
`steeringApplied` is emitted after queued steering input has been appended to conversation context. Its payload includes `count`, the number of steering messages applied.
|
|
334
|
+
|
|
295
335
|
`toolCall` and `toolResult` payloads include canonical Tauren-normalized fields:
|
|
296
336
|
|
|
297
337
|
- `toolCallId`: tool call ID.
|
|
@@ -365,7 +405,7 @@ Params:
|
|
|
365
405
|
|
|
366
406
|
- `sessionId`: active RPC session ID.
|
|
367
407
|
- `settingId`: currently `defaultModel` or `defaultThinkingLevel`.
|
|
368
|
-
- `value`: setting value. `defaultModel` accepts `Provider/model-id` and preserves slashes after the provider separator.
|
|
408
|
+
- `value`: setting value. `defaultModel` accepts a structured object such as `{ "provider": "OpenRouter", "model": "anthropic/claude-sonnet-4.5" }`. For compatibility, it also accepts `Provider/model-id` strings and preserves slashes after the provider separator.
|
|
369
409
|
|
|
370
410
|
Applies the setting live by updating config and refreshing client config. Unsupported setting IDs are rejected.
|
|
371
411
|
|
|
@@ -379,7 +419,7 @@ Refreshes config-backed runtime state and returns `{ "ok": true, "message": "Res
|
|
|
379
419
|
|
|
380
420
|
## Logging methods
|
|
381
421
|
|
|
382
|
-
The `logging` capability reports local redacted telemetry logging support, the log directory, enabled categories,
|
|
422
|
+
The `logging` capability reports local redacted telemetry logging support, the log directory, enabled categories, `methods: ["logging/stats", "logging/tokenCsv"]`, `usageCsv` sub-capability with bucket support, JSONL format with 10 MB rotation and manual retention, config key `logging`, env prefix `KWARD_LOGGING`, and redacted-metadata-only content. Logging methods require logging to be enabled by config or environment for at least one category.
|
|
383
423
|
|
|
384
424
|
### `logging/stats`
|
|
385
425
|
|
|
@@ -391,6 +431,15 @@ Accepted units are minutes, hours, days, weeks, months, and years. Ranges use UT
|
|
|
391
431
|
|
|
392
432
|
Returns structured stats for enabled categories only, including the requested range, log directory, record counts by category/event, `usageStats` token totals, performance duration summaries, tool call summaries, and error counts by event/class/provider/code. Error messages are not included in the stats response.
|
|
393
433
|
|
|
434
|
+
### `logging/tokenCsv`
|
|
435
|
+
|
|
436
|
+
Params:
|
|
437
|
+
|
|
438
|
+
- `range`: optional duration string; defaults to `1 week`.
|
|
439
|
+
- `bucket`: optional aggregation bucket: `second`, `minute`, `hour`, `day`, `week`, `month`, or `year`.
|
|
440
|
+
|
|
441
|
+
Returns `{ "csv": "..." }` with token usage data as CSV. Accepted range units and calendar-period behavior match `logging/stats`. This is the RPC equivalent of `kward stats tokens`.
|
|
442
|
+
|
|
394
443
|
## Memory methods
|
|
395
444
|
|
|
396
445
|
Memory is disabled by default. Auto-summary is also disabled by default. RPC memory methods operate on the same local storage as the CLI: `<config-dir>/memory/core.json`, `<config-dir>/memory/soft.jsonl`, and `<config-dir>/memory/events.jsonl`. Retrieved memory is injected only for normal session turns when memory is enabled.
|
|
@@ -639,6 +688,27 @@ Completes the login using the submitted code.
|
|
|
639
688
|
|
|
640
689
|
Returns login status for a login ID.
|
|
641
690
|
|
|
691
|
+
## Worker methods (experimental)
|
|
692
|
+
|
|
693
|
+
Worker methods are available only when Kward is launched with `--experimental-workers`. The `workers` capability reports `supported: false` by default and `supported: true` with `methods: ["workers/list", "workers/show"]` when the flag is active.
|
|
694
|
+
|
|
695
|
+
### `workers/list`
|
|
696
|
+
|
|
697
|
+
Params:
|
|
698
|
+
|
|
699
|
+
- `sessionId`: active RPC session ID.
|
|
700
|
+
|
|
701
|
+
Returns the list of agent workers for the session.
|
|
702
|
+
|
|
703
|
+
### `workers/show`
|
|
704
|
+
|
|
705
|
+
Params:
|
|
706
|
+
|
|
707
|
+
- `sessionId`: active RPC session ID.
|
|
708
|
+
- `workerId`: worker ID.
|
|
709
|
+
|
|
710
|
+
Returns details for a specific worker.
|
|
711
|
+
|
|
642
712
|
## Security and privacy notes
|
|
643
713
|
|
|
644
714
|
- RPC is intended for a trusted local UI and can read/write files, run shell commands, update secrets, and use OAuth.
|
data/doc/session-management.md
CHANGED
|
@@ -23,6 +23,8 @@ cd ~/code/project
|
|
|
23
23
|
kward
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
+
To automatically resume the last active session for the current workspace on startup, enable `sessions.auto_resume` in your config — see [Configuration](configuration.md). When auto-resume is off (the default), Kward starts fresh each time and you can resume earlier work with `/sessions`.
|
|
27
|
+
|
|
26
28
|
## A normal session workflow
|
|
27
29
|
|
|
28
30
|
Start a chat and give it a useful name:
|
|
@@ -31,6 +33,8 @@ Start a chat and give it a useful name:
|
|
|
31
33
|
/rename oauth cleanup
|
|
32
34
|
```
|
|
33
35
|
|
|
36
|
+
`/rename` requires a name. Use `/name` without an argument to clear the current session name.
|
|
37
|
+
|
|
34
38
|
Work normally:
|
|
35
39
|
|
|
36
40
|
```text
|
|
@@ -71,10 +75,12 @@ Inside the picker you can:
|
|
|
71
75
|
| `r` | rename the highlighted session. |
|
|
72
76
|
| `c` | clone the highlighted session. |
|
|
73
77
|
| `f` | fork the highlighted session from an earlier prompt. |
|
|
74
|
-
| `d
|
|
78
|
+
| `d` | start deleting the highlighted session. Press `d` again to confirm, or `Esc` to cancel. |
|
|
75
79
|
|
|
76
80
|
Use names generously. A session named `oauth cleanup` or `release checklist` is much easier to find later than a timestamp.
|
|
77
81
|
|
|
82
|
+
Deleted sessions are moved to your OS trash or recycle bin when a supported platform tool is available (Finder on macOS, `gio trash` or `trash-put` on Linux, Recycle Bin on Windows). If no trash tool is found, the session file is permanently deleted. You can recover accidentally deleted sessions from your trash.
|
|
83
|
+
|
|
78
84
|
## Clone a session
|
|
79
85
|
|
|
80
86
|
Clone when you want an exact copy of the current conversation and then continue in a separate branch.
|
|
@@ -185,6 +191,17 @@ After compaction, Kward may need to re-read files before editing them again. Tha
|
|
|
185
191
|
|
|
186
192
|
Compaction is also context management. It trades detailed old conversation for a concise working summary so Kward can spend tokens on the next task.
|
|
187
193
|
|
|
194
|
+
## Copy session text to the clipboard
|
|
195
|
+
|
|
196
|
+
Use `/copy` to copy conversation text without writing a file:
|
|
197
|
+
|
|
198
|
+
```text
|
|
199
|
+
/copy last # copy the latest assistant response
|
|
200
|
+
/copy transcript # copy the full transcript as Markdown
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
With no argument, `/copy` defaults to `last`. Copying uses the terminal clipboard (OSC 52) when supported.
|
|
204
|
+
|
|
188
205
|
## Export a session
|
|
189
206
|
|
|
190
207
|
Export when you want notes outside Kward:
|
|
@@ -193,20 +210,35 @@ Export when you want notes outside Kward:
|
|
|
193
210
|
/export notes.md
|
|
194
211
|
```
|
|
195
212
|
|
|
213
|
+
With no argument, `/export` writes a Markdown file beside the session file, derived from the session name with a `.md` extension.
|
|
214
|
+
|
|
196
215
|
Exports are useful for handoff notes, review summaries, release records, or saving a human-readable transcript before deleting old sessions.
|
|
197
216
|
|
|
217
|
+
## Check session status
|
|
218
|
+
|
|
219
|
+
Use `/status` to see the active session name, file path, and auto-compaction reserve at a glance:
|
|
220
|
+
|
|
221
|
+
```text
|
|
222
|
+
/status
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
This is useful when you want to confirm which session you are in or check whether auto-compaction is active.
|
|
226
|
+
|
|
198
227
|
## Which command should I use?
|
|
199
228
|
|
|
200
229
|
| Need | Use |
|
|
201
230
|
| --- | --- |
|
|
202
231
|
| Continue earlier work | `/sessions` or `/resume` |
|
|
203
232
|
| Give the current session a better name | `/rename <name>` |
|
|
233
|
+
| Clear the current session name | `/name` |
|
|
204
234
|
| Keep the current state but try another future | `/clone` |
|
|
205
235
|
| Start a separate session from before an earlier prompt | `/fork` |
|
|
206
236
|
| Quickly retry an earlier prompt in this session | `/rewind` |
|
|
207
237
|
| Inspect or navigate the full branch structure | `/tree` |
|
|
208
238
|
| Reduce old context so a long session can continue | `/compact` |
|
|
239
|
+
| Copy the last response or full transcript to clipboard | `/copy [last\|transcript]` |
|
|
209
240
|
| Save a readable transcript | `/export <path>` |
|
|
241
|
+
| Check the active session and compaction status | `/status` |
|
|
210
242
|
|
|
211
243
|
## Practical habits
|
|
212
244
|
|
|
@@ -218,3 +250,5 @@ Exports are useful for handoff notes, review summaries, release records, or savi
|
|
|
218
250
|
- Compact when the conversation gets long, but keep the focus instruction specific.
|
|
219
251
|
|
|
220
252
|
Sessions make Kward less like a single chat box and more like a workspace timeline. You can preserve context, branch it, compress it, and return to it when the work needs another pass.
|
|
253
|
+
|
|
254
|
+
RPC clients have their own session API with equivalent create, resume, list, clone, fork, rename, and compaction methods. See the [RPC documentation](rpc.md) for details.
|
data/doc/shell.md
ADDED
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
# Embedded shell
|
|
2
|
+
|
|
3
|
+
Use `/shell` when you want to run a sequence of local commands without leaving Kward's interactive TUI.
|
|
4
|
+
|
|
5
|
+
`/shell` opens **ekwsh**, the embedded Kward shell. It is not a full terminal emulator. Kward keeps ownership of the composer, transcript, tab bar, and keybindings while each command runs through your normal shell one command at a time.
|
|
6
|
+
|
|
7
|
+
This makes it good for:
|
|
8
|
+
|
|
9
|
+
- checking Git state,
|
|
10
|
+
- running focused tests,
|
|
11
|
+
- inspecting files with command-line tools,
|
|
12
|
+
- using project aliases,
|
|
13
|
+
- keeping command output visible beside the current Kward session.
|
|
14
|
+
|
|
15
|
+
Use `/pty <command>` when you intentionally want to hand the terminal to a full-screen interactive command such as `less`.
|
|
16
|
+
|
|
17
|
+
## Start shell mode
|
|
18
|
+
|
|
19
|
+
Inside interactive Kward:
|
|
20
|
+
|
|
21
|
+
```text
|
|
22
|
+
/shell
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The composer prompt changes to show the shell's current directory:
|
|
26
|
+
|
|
27
|
+
```text
|
|
28
|
+
Shell ~/code/project $
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Type commands as you would in a normal shell:
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
git status --short
|
|
35
|
+
bundle exec ruby -Itest test/test_ekwsh.rb
|
|
36
|
+
cd lib/kward
|
|
37
|
+
pwd
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Leave shell mode with:
|
|
41
|
+
|
|
42
|
+
```sh
|
|
43
|
+
exit
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
or press Ctrl+D on an empty shell prompt.
|
|
47
|
+
|
|
48
|
+
## How commands run
|
|
49
|
+
|
|
50
|
+
`ekwsh` is POSIX-oriented and runs each command through `/bin/sh` using the shell's `-c` mode by default. You can configure another POSIX-compatible shell in `ekwsh.yml`. The shell is intentionally not started as a login shell so Kward-managed environment values, such as configured PATH entries, are not overwritten by login startup files.
|
|
51
|
+
|
|
52
|
+
The current directory and exported environment are tracked by Kward between commands, so this works as expected:
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
cd test
|
|
56
|
+
pwd
|
|
57
|
+
export FOO=bar
|
|
58
|
+
printf '%s\n' "$FOO"
|
|
59
|
+
unset FOO
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
`cd` changes only the embedded shell's current directory. It does not change Kward's workspace root or the process directory used by the rest of Kward.
|
|
63
|
+
|
|
64
|
+
Shell output streams into the transcript area as commands run, but it is not added to the AI conversation history. Simple assignment-only commands such as `FOO=bar` persist into the embedded shell environment for later commands.
|
|
65
|
+
|
|
66
|
+
Shell commands are persisted in a separate workspace-scoped shell history. They do not share the normal Kward prompt history used for chat prompts. The shell history limit is controlled by `history_limit` in `ekwsh.yml`.
|
|
67
|
+
|
|
68
|
+
## Built-ins
|
|
69
|
+
|
|
70
|
+
`ekwsh` handles a small set of built-ins itself:
|
|
71
|
+
|
|
72
|
+
| Built-in | What it does |
|
|
73
|
+
| --- | --- |
|
|
74
|
+
| `cd [dir]` | Change the embedded shell directory. Supports `cd`, `cd -`, and normal relative paths. |
|
|
75
|
+
| `pwd` | Print the embedded shell directory. |
|
|
76
|
+
| `export KEY[=value]` | Set or mark an environment variable for later commands. `export` and `export -p` list variables. |
|
|
77
|
+
| `unset KEY` | Remove an environment variable from later commands. |
|
|
78
|
+
| `alias [name]` | List configured aliases, show specific configured aliases, or set `alias name=value`. |
|
|
79
|
+
| `unalias name` / `unalias -a` | Remove configured aliases. |
|
|
80
|
+
| `clear` | Clear Kward's visible transcript. |
|
|
81
|
+
| `exit` / `logout` | Leave shell mode. |
|
|
82
|
+
|
|
83
|
+
Built-ins take precedence over aliases and executables.
|
|
84
|
+
|
|
85
|
+
## Tabs
|
|
86
|
+
|
|
87
|
+
Shell mode is tracked per Kward tab.
|
|
88
|
+
|
|
89
|
+
If you enter `/shell` in one tab, switch to another tab, and later switch back, that tab is still in shell mode. Its shell state and transcript snapshot are restored until you leave shell mode in that tab.
|
|
90
|
+
|
|
91
|
+
This means each tab can have its own:
|
|
92
|
+
|
|
93
|
+
- shell current directory,
|
|
94
|
+
- exported environment,
|
|
95
|
+
- visible shell transcript,
|
|
96
|
+
- command prompt state.
|
|
97
|
+
|
|
98
|
+
Kward's normal tab-switching shortcuts continue to work in shell mode. If you switch tabs while a shell command is running, Kward cancels that foreground command and requeues the tab action so the TUI can switch cleanly.
|
|
99
|
+
|
|
100
|
+
## Tab completion
|
|
101
|
+
|
|
102
|
+
Plain Tab completes shell input while in `ekwsh`.
|
|
103
|
+
|
|
104
|
+
Completion includes:
|
|
105
|
+
|
|
106
|
+
- built-in command names,
|
|
107
|
+
- configured aliases,
|
|
108
|
+
- executable names from `$PATH`,
|
|
109
|
+
- file paths from the shell's current directory.
|
|
110
|
+
|
|
111
|
+
Examples:
|
|
112
|
+
|
|
113
|
+
```sh
|
|
114
|
+
pw<Tab> # pwd
|
|
115
|
+
ll<Tab> # configured alias, if present
|
|
116
|
+
cat lib/kw<Tab> # path completion
|
|
117
|
+
cd doc<Tab> # directory-only completion for cd
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Directory completions get a trailing slash. File and command completions get a trailing space when there is a single match.
|
|
121
|
+
|
|
122
|
+
Paths with spaces are shell-escaped:
|
|
123
|
+
|
|
124
|
+
```sh
|
|
125
|
+
cat my<Tab>
|
|
126
|
+
# => cat my\ file.txt
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Quoted path tokens are completed in the same quoting style:
|
|
130
|
+
|
|
131
|
+
```sh
|
|
132
|
+
cat "my<Tab>
|
|
133
|
+
# => cat "my file.txt
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
If there are multiple candidates, Kward applies any common prefix. When there is no longer common prefix, it prints a compact candidate list in the transcript. Command-name completion caches `$PATH` executables and refreshes when `PATH` changes through shell assignment, `export`, or `unset`.
|
|
137
|
+
|
|
138
|
+
## Colors and ANSI output
|
|
139
|
+
|
|
140
|
+
`ekwsh` preserves safe ANSI SGR color/style sequences in command output, such as:
|
|
141
|
+
|
|
142
|
+
- colors,
|
|
143
|
+
- bold,
|
|
144
|
+
- dim,
|
|
145
|
+
- italic,
|
|
146
|
+
- underline,
|
|
147
|
+
- 256-color and truecolor SGR sequences.
|
|
148
|
+
|
|
149
|
+
It strips terminal-control sequences that could corrupt Kward's TUI, such as cursor movement, clear-screen controls, OSC title changes, and alternate-screen controls.
|
|
150
|
+
|
|
151
|
+
When rbenv is available, `ekwsh` also prepends the rbenv shims and bin directories to PATH and sets `RBENV_ROOT` when it was missing. This lets commands such as `ruby`, `bundle`, and `./exe/kward` use the same Ruby selected by rbenv without requiring `rbenv init` support in `ekwsh`.
|
|
152
|
+
|
|
153
|
+
By default, `ekwsh` sets conservative color-friendly environment values:
|
|
154
|
+
|
|
155
|
+
```sh
|
|
156
|
+
CLICOLOR=1
|
|
157
|
+
COLORTERM=truecolor
|
|
158
|
+
TERM=xterm-256color # only when TERM is missing or dumb
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
It does **not** force color by default. If a tool does not emit color because stdout is not a TTY, use a command-specific flag or configure forced color yourself:
|
|
162
|
+
|
|
163
|
+
```sh
|
|
164
|
+
git diff --color=always
|
|
165
|
+
grep --color=always TODO lib/**/*.rb
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Global ekwsh config
|
|
169
|
+
|
|
170
|
+
You can configure environment variables and aliases in:
|
|
171
|
+
|
|
172
|
+
```text
|
|
173
|
+
~/.kward/ekwsh.yml
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
If `KWARD_CONFIG_PATH` points to another config file, `ekwsh.yml` is read from that file's directory instead.
|
|
177
|
+
|
|
178
|
+
Example:
|
|
179
|
+
|
|
180
|
+
```yaml
|
|
181
|
+
shell: /bin/sh
|
|
182
|
+
# timeout_seconds: 300
|
|
183
|
+
# max_output_bytes: 1048576
|
|
184
|
+
# history_limit: 1000
|
|
185
|
+
|
|
186
|
+
env:
|
|
187
|
+
FORCE_COLOR: "1"
|
|
188
|
+
CLICOLOR_FORCE: "1"
|
|
189
|
+
RAILS_ENV: "test"
|
|
190
|
+
|
|
191
|
+
aliases:
|
|
192
|
+
ll: "ls -la"
|
|
193
|
+
gs: "git status --short"
|
|
194
|
+
gd: "git diff --color=always"
|
|
195
|
+
be: "bundle exec"
|
|
196
|
+
t: "bundle exec ruby -Itest"
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### Runtime settings
|
|
200
|
+
|
|
201
|
+
`ekwsh` accepts these top-level runtime settings:
|
|
202
|
+
|
|
203
|
+
| Setting | Default | What it does |
|
|
204
|
+
| --- | --- | --- |
|
|
205
|
+
| `shell` | `/bin/sh` | Absolute path to the POSIX-compatible shell used with `-c`. Invalid or relative paths fall back to `/bin/sh`. |
|
|
206
|
+
| `timeout_seconds` | `300` | Maximum runtime for one command. |
|
|
207
|
+
| `max_output_bytes` | `1048576` | Maximum captured output for one command. |
|
|
208
|
+
| `history_limit` | `1000` | Maximum persisted shell history entries per workspace. |
|
|
209
|
+
|
|
210
|
+
When a command exceeds `timeout_seconds`, `ekwsh` terminates it and reports the timeout. When command output exceeds `max_output_bytes`, `ekwsh` terminates the command, keeps bounded output, and reports the output limit. Press Ctrl+C while a command is running to terminate that command and return to the shell prompt without exiting Kward.
|
|
211
|
+
|
|
212
|
+
### Environment variables
|
|
213
|
+
|
|
214
|
+
`env` values are applied when shell mode starts, after Kward's conservative color defaults.
|
|
215
|
+
|
|
216
|
+
Keys must look like environment variable names:
|
|
217
|
+
|
|
218
|
+
```text
|
|
219
|
+
A_Z, digits after the first character, and underscores
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Invalid keys are ignored. Values are converted to strings. Nil values are ignored.
|
|
223
|
+
|
|
224
|
+
Configured env is useful for local preferences such as:
|
|
225
|
+
|
|
226
|
+
```yaml
|
|
227
|
+
env:
|
|
228
|
+
FORCE_COLOR: "1"
|
|
229
|
+
BUNDLE_WITHOUT: "production"
|
|
230
|
+
RAILS_ENV: "test"
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
For one shell session, you can also use the built-in `export` command:
|
|
234
|
+
|
|
235
|
+
```sh
|
|
236
|
+
export FORCE_COLOR=1
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### Aliases
|
|
240
|
+
|
|
241
|
+
Aliases expand the first word of a command once.
|
|
242
|
+
|
|
243
|
+
With this config:
|
|
244
|
+
|
|
245
|
+
```yaml
|
|
246
|
+
aliases:
|
|
247
|
+
ll: "ls -la"
|
|
248
|
+
t: "bundle exec ruby -Itest"
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
these commands run as:
|
|
252
|
+
|
|
253
|
+
```sh
|
|
254
|
+
ll lib
|
|
255
|
+
# runs: ls -la lib
|
|
256
|
+
|
|
257
|
+
t test/test_ekwsh.rb
|
|
258
|
+
# runs: bundle exec ruby -Itest test/test_ekwsh.rb
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
Aliases are intentionally simple:
|
|
262
|
+
|
|
263
|
+
- only the first word is expanded,
|
|
264
|
+
- aliases do not recursively expand,
|
|
265
|
+
- built-ins win over alias names,
|
|
266
|
+
- aliases are not shell functions,
|
|
267
|
+
- aliases are global for now.
|
|
268
|
+
|
|
269
|
+
List configured aliases inside `ekwsh`:
|
|
270
|
+
|
|
271
|
+
```sh
|
|
272
|
+
alias
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
Show specific aliases:
|
|
276
|
+
|
|
277
|
+
```sh
|
|
278
|
+
alias ll gs
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
Aliases also appear in command-name Tab completion.
|
|
282
|
+
|
|
283
|
+
## Interactive PTY passthrough
|
|
284
|
+
|
|
285
|
+
Use `/pty <command>` for commands that need to own the terminal temporarily, such as pagers:
|
|
286
|
+
|
|
287
|
+
```text
|
|
288
|
+
/pty git log
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
Inside `/shell`, use the `pty` built-in so the command inherits the embedded shell's current directory and environment:
|
|
292
|
+
|
|
293
|
+
```sh
|
|
294
|
+
pty git log
|
|
295
|
+
pty vim README.md
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
Kward runs the command in a PTY, forwards your keyboard input to the process, and streams the process output directly to the terminal. This lets tools such as `less` receive keys like Space, `/`, `n`, and `q` normally. When the command exits, Kward restores its prompt and records only a short session summary in the transcript instead of raw full-screen terminal control output.
|
|
299
|
+
|
|
300
|
+
`/pty` and shell `pty` are explicit on purpose. Normal `/shell` commands remain captured and transcript-friendly; `pty` is for commands where the child process should temporarily own the terminal.
|
|
301
|
+
|
|
302
|
+
## `/shell` versus `!command`
|
|
303
|
+
|
|
304
|
+
Kward has two ways to run local commands yourself:
|
|
305
|
+
|
|
306
|
+
```text
|
|
307
|
+
!git status --short
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
runs one command directly from the normal composer.
|
|
311
|
+
|
|
312
|
+
```text
|
|
313
|
+
/shell
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
starts an embedded command mode for several commands with persistent shell state, aliases, completion, and per-tab shell context.
|
|
317
|
+
|
|
318
|
+
Use `!command` for one-offs. Use `/shell` when you expect to run several commands in a row.
|
|
319
|
+
|
|
320
|
+
## Limitations
|
|
321
|
+
|
|
322
|
+
`ekwsh` is deliberately not a full interactive terminal.
|
|
323
|
+
|
|
324
|
+
Current limitations:
|
|
325
|
+
|
|
326
|
+
- no job control,
|
|
327
|
+
- no persistent shell functions,
|
|
328
|
+
- no shell startup file sourcing,
|
|
329
|
+
- no native readline from your login shell,
|
|
330
|
+
- normal `/shell` command output is transcript-sanitized rather than treated as a full terminal UI.
|
|
331
|
+
|
|
332
|
+
External `/shell` commands run under a minimal PTY so terminal-aware tools can detect TTY output and terminal width. Full-screen interactive programs should still use explicit `/pty <command>` passthrough.
|