kward 0.71.0 → 0.72.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.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +41 -1
  3. data/Gemfile.lock +2 -2
  4. data/README.md +4 -0
  5. data/doc/agent-tools.md +15 -6
  6. data/doc/authentication.md +22 -1
  7. data/doc/code-search.md +42 -2
  8. data/doc/configuration.md +106 -3
  9. data/doc/context-budgeting.md +136 -0
  10. data/doc/context-tools.md +16 -3
  11. data/doc/editor.md +394 -0
  12. data/doc/extensibility.md +16 -7
  13. data/doc/files.md +100 -0
  14. data/doc/getting-started.md +25 -18
  15. data/doc/git.md +122 -0
  16. data/doc/memory.md +24 -4
  17. data/doc/personas.md +34 -5
  18. data/doc/plugins.md +72 -1
  19. data/doc/releasing.md +37 -9
  20. data/doc/rpc.md +74 -4
  21. data/doc/session-management.md +35 -1
  22. data/doc/shell.md +286 -0
  23. data/doc/tabs.md +122 -0
  24. data/doc/troubleshooting.md +77 -1
  25. data/doc/usage.md +53 -7
  26. data/doc/web-search.md +12 -4
  27. data/doc/workspace-tools.md +51 -12
  28. data/examples/plugins/space_invaders.rb +377 -0
  29. data/lib/kward/agent.rb +1 -1
  30. data/lib/kward/cli/commands.rb +33 -2
  31. data/lib/kward/cli/git.rb +150 -0
  32. data/lib/kward/cli/interactive_turn.rb +73 -9
  33. data/lib/kward/cli/plugins.rb +54 -4
  34. data/lib/kward/cli/prompt_interface.rb +32 -1
  35. data/lib/kward/cli/runtime_helpers.rb +133 -3
  36. data/lib/kward/cli/sessions.rb +2 -2
  37. data/lib/kward/cli/settings.rb +218 -9
  38. data/lib/kward/cli/slash_commands.rb +415 -2
  39. data/lib/kward/cli/tabs.rb +695 -0
  40. data/lib/kward/cli.rb +158 -26
  41. data/lib/kward/config_files.rb +123 -1
  42. data/lib/kward/context_budget_meter.rb +44 -0
  43. data/lib/kward/conversation.rb +12 -4
  44. data/lib/kward/editor_mode.rb +25 -0
  45. data/lib/kward/ekwsh.rb +362 -0
  46. data/lib/kward/plugin_registry.rb +61 -0
  47. data/lib/kward/project_files.rb +52 -0
  48. data/lib/kward/prompt_history.rb +82 -0
  49. data/lib/kward/prompt_interface/composer_controller.rb +69 -1
  50. data/lib/kward/prompt_interface/composer_renderer.rb +109 -13
  51. data/lib/kward/prompt_interface/composer_state.rb +96 -27
  52. data/lib/kward/prompt_interface/editor/auto_close_pairs.rb +123 -0
  53. data/lib/kward/prompt_interface/editor/auto_indent.rb +509 -0
  54. data/lib/kward/prompt_interface/editor/buffer.rb +109 -0
  55. data/lib/kward/prompt_interface/editor/controller.rb +1018 -0
  56. data/lib/kward/prompt_interface/editor/endwise.rb +321 -0
  57. data/lib/kward/prompt_interface/editor/file_marker.rb +40 -0
  58. data/lib/kward/prompt_interface/editor/indent_navigation.rb +61 -0
  59. data/lib/kward/prompt_interface/editor/kill_ring.rb +78 -0
  60. data/lib/kward/prompt_interface/editor/modes/emacs.rb +259 -0
  61. data/lib/kward/prompt_interface/editor/modes/modern.rb +353 -0
  62. data/lib/kward/prompt_interface/editor/modes/vibe.rb +1962 -0
  63. data/lib/kward/prompt_interface/editor/renderer.rb +243 -0
  64. data/lib/kward/prompt_interface/editor/search.rb +76 -0
  65. data/lib/kward/prompt_interface/editor/selections.rb +120 -0
  66. data/lib/kward/prompt_interface/editor/state.rb +1249 -0
  67. data/lib/kward/prompt_interface/editor/status_text.rb +23 -0
  68. data/lib/kward/prompt_interface/editor/syntax_highlighter.rb +420 -0
  69. data/lib/kward/prompt_interface/editor/undo_history.rb +46 -0
  70. data/lib/kward/prompt_interface/editor/vibe_state.rb +44 -0
  71. data/lib/kward/prompt_interface/file_overlay.rb +211 -0
  72. data/lib/kward/prompt_interface/git_prompt.rb +299 -0
  73. data/lib/kward/prompt_interface/interactive/controller.rb +186 -0
  74. data/lib/kward/prompt_interface/interactive/renderer.rb +71 -0
  75. data/lib/kward/prompt_interface/interactive/state.rb +62 -0
  76. data/lib/kward/prompt_interface/key_handler.rb +387 -35
  77. data/lib/kward/prompt_interface/overlay_renderer.rb +21 -2
  78. data/lib/kward/prompt_interface/project_browser.rb +524 -0
  79. data/lib/kward/prompt_interface/question_prompt.rb +98 -50
  80. data/lib/kward/prompt_interface/runtime_state.rb +43 -0
  81. data/lib/kward/prompt_interface/screen.rb +16 -0
  82. data/lib/kward/prompt_interface/selection_prompt.rb +7 -13
  83. data/lib/kward/prompt_interface/stream_state.rb +7 -0
  84. data/lib/kward/prompt_interface/transcript_buffer.rb +6 -0
  85. data/lib/kward/prompt_interface.rb +286 -8
  86. data/lib/kward/prompts/commands.rb +5 -0
  87. data/lib/kward/prompts.rb +2 -0
  88. data/lib/kward/rpc/server.rb +42 -3
  89. data/lib/kward/rpc/session_manager.rb +35 -47
  90. data/lib/kward/rpc/session_tree_rows.rb +9 -115
  91. data/lib/kward/rpc/tool_event_normalizer.rb +1 -1
  92. data/lib/kward/session_store.rb +44 -0
  93. data/lib/kward/session_tree_nodes.rb +136 -0
  94. data/lib/kward/session_tree_renderer.rb +9 -131
  95. data/lib/kward/tab_store.rb +47 -0
  96. data/lib/kward/text_boundary.rb +25 -0
  97. data/lib/kward/tools/context_budget_stats.rb +54 -0
  98. data/lib/kward/tools/context_for_task.rb +202 -0
  99. data/lib/kward/tools/read_file.rb +8 -4
  100. data/lib/kward/tools/registry.rb +62 -16
  101. data/lib/kward/tools/tool_call.rb +10 -0
  102. data/lib/kward/version.rb +1 -1
  103. data/lib/kward/workers/git_guard.rb +68 -0
  104. data/lib/kward/workers/live_view.rb +49 -0
  105. data/lib/kward/workers/manager.rb +288 -0
  106. data/lib/kward/workers/store.rb +72 -0
  107. data/lib/kward/workers/tool_policy.rb +23 -0
  108. data/lib/kward/workers/worker.rb +82 -0
  109. data/lib/kward/workers/write_lock.rb +38 -0
  110. data/lib/kward/workers.rb +7 -0
  111. data/lib/kward/workspace.rb +110 -24
  112. data/templates/default/fulldoc/html/css/kward.css +107 -36
  113. data/templates/default/kward_navigation.rb +12 -1
  114. data/templates/default/layout/html/layout.erb +4 -2
  115. data/templates/default/layout/html/setup.rb +6 -0
  116. metadata +53 -1
data/doc/editor.md ADDED
@@ -0,0 +1,394 @@
1
+ # Integrated Editor
2
+
3
+ <quote>
4
+ Three Modes for the Elven-kings under the sky,<br>
5
+ Seven Keymaps for the Dwarf-lords in their halls of stone,<br>
6
+ Nine Editors for Mortal Men doomed to compile,<br>
7
+ One Kward to rule them all,<br>
8
+ One Kward to find them,<br>
9
+ One Kward to bring them all and in the transcript bind them<br>
10
+ In the Land of Ruby where the agents lie.<br>
11
+ </quote>
12
+
13
+ Kward includes a terminal editor with 3 editing modes to choose from: Modern, Emacs and Vibe. It opens inside the chat composer, so you can jump into a file, make a change, save it, and return to the conversation without switching tools.
14
+
15
+ The editor is scoped to the current workspace. It only opens files inside that directory, which helps keep edits tied to the project you started Kward in.
16
+
17
+ ## Quick start
18
+
19
+ Open the file picker by typing `$` as the first character in the composer:
20
+
21
+ ```text
22
+ $lib/kward/agent.rb
23
+ ```
24
+
25
+ As you type, Kward shows matching files. Use the arrow keys to choose one and press `Enter` to open it.
26
+
27
+ For a nested project tree, run:
28
+
29
+ ```text
30
+ /files
31
+ ```
32
+
33
+ In the tree browser, use `↑`/`↓` to move, `←`/`→` to collapse or expand directories, `Enter` to toggle a directory or open a file, `Tab` or `/` to search, `@` to insert the selected file as an `@path` mention, and `Esc` to close. When you open a file from `/files`, quitting the editor returns to the browser at the same position.
34
+
35
+ You can also type a relative path yourself and press `Enter`. If the file does not exist, Kward asks whether to create it.
36
+
37
+ A few things to know:
38
+
39
+ - `$` only opens the editor when it is the first character in the composer.
40
+ - Once a file opens, the composer becomes the editor.
41
+ - Save or quit to return to normal chat.
42
+ - If the file changed on disk while you were editing, Kward asks before overwriting it.
43
+ - If you quit with unsaved changes, Kward asks before discarding them.
44
+
45
+ ## Example workflow
46
+
47
+ ```text
48
+ $doc/editor.md
49
+ ```
50
+
51
+ 1. Type `$doc/editor.md` in the composer.
52
+ 2. Pick the file from the matching results, or press `Enter` if the path is already complete.
53
+ 3. Edit the file.
54
+ 4. Save with `Ctrl+S` in Modern mode, `C-x C-s` in Emacs mode, or `:w` in Vibe mode.
55
+ 5. Quit with `Ctrl+Q`, `C-x C-c`, or `:q`.
56
+ 6. Continue chatting with Kward.
57
+
58
+ ## What the editor supports
59
+
60
+ The editor is intentionally compact, but it covers the basics you need for quick changes:
61
+
62
+ - Syntax highlighting for common languages, including Ruby, Crystal, Elixir, Julia, JavaScript, TypeScript, JSON, Markdown, YAML, Shell, Makefile, HTML, CSS, SCSS, Python, Go, Rust, Java, C#, C, C++, Swift, Kotlin, Lua, and SQL. Unknown file types render as plain text.
63
+ - Auto-indent, enabled by default. New lines inherit indentation, Tab jumps to the expected indentation or the next indentation stop, Shift+Tab moves indentation back, obvious closing tokens are re-indented, and Backspace in leading whitespace removes one indentation unit when possible. For Ruby, Crystal, Elixir, Julia, Lua, Makefiles, and shell scripts, Enter after a block opener inserts the matching closing keyword; Ctrl+Enter also works from the middle of the line in terminals that report modified Enter keys.
64
+ - Undo and redo, with up to 100 history entries per buffer.
65
+ - Incremental search forward and backward.
66
+ - Selection, copy, cut, and paste. Copy and cut also write to the terminal clipboard through OSC 52 when the terminal supports it.
67
+ - A line-number gutter and a status line that shows the current mode and prompts.
68
+ - Soft-wrap, enabled by default so long lines wrap within the editor width instead of scrolling sideways. Disable it with `editor.soft_wrap: false`.
69
+
70
+ ## Choosing an editor mode
71
+
72
+ The editor has three keybinding modes:
73
+
74
+ - **Modern**: default mode, with familiar shortcuts like `Ctrl+S`, `Ctrl+Q`, `/` search, and `?` reverse search.
75
+ - **Emacs**: non-modal Emacs-style chords, including `C-x C-s`, `C-x C-c`, and a per-buffer kill ring.
76
+ - **Vibe**: modal editing inspired by classic vi/vim workflows, with normal, insert, replace, visual, and command modes.
77
+
78
+ Change the mode from:
79
+
80
+ ```text
81
+ /settings > Interface > Editor mode
82
+ ```
83
+
84
+ New editor buffers use the updated setting immediately. You do not need to restart Kward.
85
+
86
+ You can also configure it in `config.json`:
87
+
88
+ ```json
89
+ {
90
+ "editor": {
91
+ "mode": "modern"
92
+ }
93
+ }
94
+ ```
95
+
96
+ `mode` can be `modern`, `emacs`, or `vibe`. The old `default` value is still accepted as an alias for `modern`.
97
+
98
+ To disable auto-indent or auto-close pairs:
99
+
100
+ ```json
101
+ {
102
+ "editor": {
103
+ "auto_indent": false,
104
+ "auto_close_pairs": false
105
+ }
106
+ }
107
+ ```
108
+
109
+ Auto-close pairs inserts matching `()`, `[]`, `{}`, quotes, and backticks while editing.
110
+
111
+ Line numbers are absolute by default. Set `editor.line_numbers` to `relative` to show distances from the cursor line in editable buffers while keeping the current line absolute.
112
+
113
+ Editable editor buffers request a vertical bar cursor by default. Set `editor.bar_cursor` to `false` if you want Kward to leave the terminal cursor shape alone.
114
+
115
+ See [Configuration](configuration.md) for the full editor settings reference.
116
+
117
+ ## Modern mode
118
+
119
+ Modern mode is the default and is the easiest place to start. It uses common terminal-editor shortcuts and supports Shift+Arrow selection.
120
+
121
+ | Key | Action |
122
+ | --------------------- | ------------------------------------------------- |
123
+ | `Ctrl+S` | Save |
124
+ | `Ctrl+Q` | Quit; press again to discard unsaved changes |
125
+ | `/` | Search forward |
126
+ | `?` | Search backward |
127
+ | `Ctrl+C` | Copy selection, or cancel search |
128
+ | `Ctrl+X` | Cut selection |
129
+ | `Ctrl+V` | Paste kill buffer |
130
+ | `Ctrl+Y` | Copy selection, or paste if there is no selection |
131
+ | `Ctrl+Z` | Undo |
132
+ | `Ctrl+Shift+Z` | Redo |
133
+ | `Ctrl+Space` | Begin selection |
134
+ | `Shift+Arrow` | Extend selection |
135
+ | `Alt+Up` on macOS, `Ctrl+Up` elsewhere | Move up by indentation level |
136
+ | `Alt+Down` on macOS, `Ctrl+Down` elsewhere | Move down by indentation level |
137
+ | `Alt+Right` on macOS, `Ctrl+Right` elsewhere | Move to indentation, then word end |
138
+ | `Alt+Shift+Up` on macOS, `Ctrl+Shift+Up` elsewhere | Select up by indentation level |
139
+ | `Alt+Shift+Down` on macOS, `Ctrl+Shift+Down` elsewhere | Select down by indentation level |
140
+ | `Alt+Shift+Right` on macOS, `Ctrl+Shift+Right` elsewhere | Select to indentation, then word end |
141
+ | `Ctrl+Left` | Move to start of line |
142
+ | `Alt+Shift+Left` | Extend selection to previous word boundary |
143
+ | `Ctrl+A` | Move to start of line |
144
+ | `Ctrl+E` | Move to end of line |
145
+ | `Ctrl+B` | Move left |
146
+ | `Ctrl+F` | Move right |
147
+ | `Ctrl+N` | Move down |
148
+ | `Ctrl+P` | Move up |
149
+ | `Ctrl+K` | Kill to end of line |
150
+ | `Ctrl+U` | Kill to start of line |
151
+ | `Ctrl+W` | Delete word before cursor |
152
+ | `Ctrl+D` | Delete character at cursor |
153
+ | `Alt+B` | Move to previous word |
154
+ | `Alt+F` | Move to next word |
155
+ | `Alt+D` | Delete word after cursor |
156
+ | `Alt+Backspace` | Delete word before cursor |
157
+ | `Arrow keys` | Move cursor |
158
+ | `Home` / `End` | Move to start / end of line |
159
+ | `PageUp` / `PageDown` | Scroll |
160
+ | `Enter` | Insert newline, or confirm search |
161
+ | `Tab` | Smart-indent to the expected indentation or next stop |
162
+ | `Shift+Tab` | Move indentation back by one stop |
163
+ | `Backspace` | Delete before cursor |
164
+ | `Delete` | Delete character at cursor |
165
+ | `Esc` | Cancel search or clear selection |
166
+
167
+ ## Emacs mode
168
+
169
+ Emacs mode is for users who prefer classic Emacs-style non-modal editing. Save and quit use two-key `C-x` commands, and kills are stored in a per-buffer kill ring so you can yank and cycle recent kills.
170
+
171
+ | Key | Action |
172
+ | --------------------- | -------------------------------------------- |
173
+ | `C-x C-s` | Save |
174
+ | `C-x C-c` | Quit; press again to discard unsaved changes |
175
+ | `C-s` | Search forward |
176
+ | `C-r` | Search backward |
177
+ | `C-g` | Cancel search, pending command, or selection |
178
+ | `Esc` | Clear selection, or cancel search |
179
+ | `C-Space` | Set the mark and begin a region |
180
+ | `C-w` | Kill region, or delete word before cursor |
181
+ | `M-w` | Copy region |
182
+ | `C-y` | Yank from kill ring |
183
+ | `M-y` | Cycle kill ring after a yank |
184
+ | `C-a` | Move to start of line |
185
+ | `C-e` | Move to end of line |
186
+ | `C-b` | Move left |
187
+ | `C-f` | Move right |
188
+ | `C-n` | Move down |
189
+ | `C-p` | Move up |
190
+ | `C-k` | Kill to end of line |
191
+ | `C-u` | Kill to start of line |
192
+ | `M-d` | Delete word after cursor |
193
+ | `M-Backspace` | Delete word before cursor |
194
+ | `M-b` | Move to previous word |
195
+ | `M-f` | Move to next word |
196
+ | `C-v` | Page down |
197
+ | `M-v` | Page up |
198
+ | `Arrow keys` | Move cursor |
199
+ | `Home` / `End` | Move to start / end of line |
200
+ | `PageUp` / `PageDown` | Scroll |
201
+ | `Enter` | Insert newline, or confirm search |
202
+ | `Tab` | Smart-indent to the expected indentation or next stop |
203
+ | `Shift+Tab` | Move indentation back by one stop |
204
+ | `Backspace` | Delete before cursor |
205
+ | `Delete` / `C-d` | Delete character at cursor |
206
+
207
+ ## Vibe mode
208
+
209
+ Vibe mode is a modal editor built for Kward, inspired by classic Vi and Vim. If you already know Vim, you will feel at home here. Files open in normal mode, where keys run commands. Press `i`, `a`, `o`, or another insert command to type text, then press `Esc` to return to normal mode.
210
+
211
+ It supports a compact but practical modal-editing set: counts, operators with motions, visual selections, visual block edits, marks, registers, macros, search, repeat (`.`), Ruby-aware navigation, and `:` commands. It is not a full Vim clone — there are no splits or ex-mode scripting — but it covers everyday keyboard editing inside the conversation.
212
+
213
+ The status line always shows the current mode (`NORMAL`, `INSERT`, `VISUAL`, `REPLACE`, or `:`) so you never lose track of where you are.
214
+
215
+ ### Normal mode
216
+
217
+ Use normal mode for movement, operators, marks, registers, macros, search, and command mode. Visual-mode-specific commands are listed in their own section below.
218
+
219
+ | Key | Action |
220
+ | ----------------------- | ----------------------------------------------- |
221
+ | `h` / `←` / `Backspace` | Move left |
222
+ | `j` / `↓` / `Ctrl+N` | Move down |
223
+ | `k` / `↑` / `Ctrl+P` | Move up |
224
+ | `l` / `Space` | Move right |
225
+ | `0` / `Home` | Move to start of line |
226
+ | `^` | Move to first non-blank character |
227
+ | `$` / `End` | Move to end of line |
228
+ | `w` | Move to next word |
229
+ | `e` | Move to end of word |
230
+ | `b` | Move to previous word |
231
+ | `gg` | Move to start of file |
232
+ | `G` | Move to end of file |
233
+ | `N G` | Move to line `N` |
234
+ | `H` | Move to top of screen |
235
+ | `M` | Move to middle of screen |
236
+ | `L` | Move to bottom of screen |
237
+ | `zz` | Center cursor line in viewport |
238
+ | `zt` | Scroll cursor line to top of viewport |
239
+ | `zb` | Scroll cursor line to bottom of viewport |
240
+ | `+` / `Enter` | Move to first non-blank of next line |
241
+ | `-` | Move to first non-blank of previous line |
242
+ | `_` | Move to first non-blank of current line |
243
+ | `Ctrl+J` | Move down by indentation level |
244
+ | `Ctrl+K` | Move up by indentation level |
245
+ | `Ctrl+F` | Page down |
246
+ | `Ctrl+B` | Page up |
247
+ | `Ctrl+D` | Half page down |
248
+ | `Ctrl+U` | Half page up |
249
+ | `Ctrl+E` | Scroll down one line |
250
+ | `Ctrl+Y` | Scroll up one line |
251
+ | `i` | Insert before cursor |
252
+ | `I` | Insert at first non-blank of line |
253
+ | `a` | Insert after cursor |
254
+ | `A` | Insert at end of line |
255
+ | `o` | Open line below and insert |
256
+ | `O` | Open line above and insert |
257
+ | `x` | Delete character at cursor |
258
+ | `X` | Delete character before cursor |
259
+ | `dd` | Delete line |
260
+ | `D` | Delete to end of line |
261
+ | `C` | Change to end of line |
262
+ | `cc` | Change line |
263
+ | `s` | Substitute character |
264
+ | `S` | Change line |
265
+ | `J` | Join lines |
266
+ | `r` then char | Replace character |
267
+ | `R` | Replace mode |
268
+ | `dw` / `yw` / `cw` | Delete / yank / change with motion |
269
+ | `diw` / `yiw` / `ciw` | Delete / yank / change inner word |
270
+ | `daw` / `yaw` / `caw` | Delete / yank / change a word plus spacing |
271
+ | `di(`/`ci(`/`yi(` | Delete / change / yank inside a pair |
272
+ | `da(`/`ca(`/`ya(` | Delete / change / yank around a pair |
273
+ | `dib` / `ciB` | Pair aliases for parentheses/braces |
274
+ | `dip` / `cip` / `yip` | Delete / change / yank inside a paragraph |
275
+ | `dap` / `cap` / `yap` | Delete / change / yank around a paragraph |
276
+ | `dir` / `cir` / `yir` | Delete / change / yank inside a Ruby block |
277
+ | `dar` / `car` / `yar` | Delete / change / yank around a Ruby block |
278
+ | `yy` | Yank line |
279
+ | `"ayy` / `"ap` | Yank / paste with named registers |
280
+ | `p` | Paste after cursor |
281
+ | `P` | Paste before cursor |
282
+ | `u` | Undo |
283
+ | `Ctrl+R` | Redo |
284
+ | `%` | Jump to matching pair |
285
+ | `f`/`F`/`t`/`T` | Find character on current line |
286
+ | `{` / `}` | Move by paragraph |
287
+ | `]m` / `[m` | Jump to next / previous Ruby method |
288
+ | `df)` / `ct,` / `d%` | Use character and pair motions with operators |
289
+ | `;` / `,` | Repeat character find forward/backward |
290
+ | `U` | Restore current line |
291
+ | `.` | Repeat last change |
292
+ | `v` | Visual character mode |
293
+ | `V` | Visual line mode |
294
+ | `Ctrl+V` | Visual block mode |
295
+ | `gv` | Restore previous visual selection |
296
+ | `ma` / `` `a `` / `'a` | Set and jump to marks |
297
+ | `qa` / `@a` / `@@` | Record and replay macros |
298
+ | `/` | Search forward |
299
+ | `?` | Search backward |
300
+ | `n` | Repeat search |
301
+ | `N` | Repeat search in opposite direction |
302
+ | `*` | Search word under cursor forward |
303
+ | `#` | Search word under cursor backward |
304
+ | `:` | Enter command mode |
305
+ | `:%s/a/b/g` | Substitute text across command ranges |
306
+ | `Esc` / `Ctrl+C` | Cancel pending command |
307
+ | `N`command | Repeat command `N` times, such as `3dd` or `2w` |
308
+
309
+ ### Visual mode
310
+
311
+ Visual mode uses the same motion language as normal mode where practical. Start characterwise visual mode with `v`, linewise mode with `V`, or visual block mode with `Ctrl+V`.
312
+
313
+ | Key | Action |
314
+ | ----------------------- | ----------------------------------------------- |
315
+ | `o` | Switch active end of visual selection |
316
+ | `G` / `gg` / `N`motion | Extend visual selection with counts/motions |
317
+ | `%`, `f`/`F`/`t`/`T` | Extend visual selection with advanced motions |
318
+ | `iw` / `a(` / `ip` | Select visual text objects |
319
+ | `>` / `<` | Indent / outdent selected lines |
320
+ | `I` / `A` | Insert / append text across visual block lines |
321
+ | `J` | Join selected lines |
322
+ | `~` / `u` / `U` | Swapcase / lowercase / uppercase selection |
323
+ | `/` / `?` / `n` / `N` | Extend visual selection with search |
324
+ | `y` / `d` / `c` / `p` | Yank / delete / change / paste selection |
325
+
326
+ ### Insert mode
327
+
328
+ In insert mode, typed characters are inserted at the cursor. Press `Esc` or `Ctrl+C` to return to normal mode. Arrow keys move the cursor without leaving insert mode.
329
+
330
+ Vibe insert mode also supports readline-style shortcuts for efficient editing without dropping back to normal mode:
331
+
332
+ | Key | Action |
333
+ | ---------------- | ---------------------------------------- |
334
+ | type text | Insert characters |
335
+ | `Enter` | Insert newline |
336
+ | `Tab` | Smart-indent to the expected indentation or next stop |
337
+ | `Shift+Tab` | Move indentation back by one stop |
338
+ | `Backspace` | Delete before cursor |
339
+ | `Delete` | Delete character at cursor |
340
+ | `Ctrl+A` | Move to start of line |
341
+ | `Ctrl+E` | Move to end of line |
342
+ | `Ctrl+B` | Move left |
343
+ | `Ctrl+F` | Move right |
344
+ | `Ctrl+D` | Delete character at cursor |
345
+ | `Ctrl+K` | Kill to end of line |
346
+ | `Ctrl+U` | Kill to start of line |
347
+ | `Ctrl+W` | Delete word before cursor |
348
+ | `Ctrl+Y` | Paste kill buffer |
349
+ | `Alt+B` | Move to previous word |
350
+ | `Alt+F` | Move to next word |
351
+ | `Alt+D` | Delete word after cursor |
352
+ | `Alt+Backspace` | Delete word before cursor |
353
+ | `Arrow keys` | Move cursor |
354
+ | `Home` / `End` | Move to start / end of line |
355
+ | `Esc` / `Ctrl+C` | Return to normal mode |
356
+
357
+ ### Replace mode
358
+
359
+ Replace mode overwrites characters at the cursor instead of inserting. Each typed character replaces the character under the cursor and advances. Press `Esc` or `Ctrl+C` to return to normal mode.
360
+
361
+ | Key | Action |
362
+ | ---------------- | --------------------------- |
363
+ | type text | Replace character at cursor |
364
+ | `Enter` | Insert newline |
365
+ | `Backspace` | Delete before cursor |
366
+ | `Esc` / `Ctrl+C` | Return to normal mode |
367
+
368
+ Typing an opening bracket (`(`, `[`, `{`) or quote (`"`, `'`, `` ` ``) in visual mode wraps the selection in the matching pair, then returns to normal mode.
369
+
370
+ ### Command mode
371
+
372
+ Enter command mode with `:` from normal mode. Type a command and press `Enter`. Press `Esc` or `Ctrl+C` to cancel.
373
+
374
+ | Command | Action |
375
+ | ------- | ------------------------------------------ |
376
+ | `:w` | Save |
377
+ | `:q` | Quit; refuses if there are unsaved changes |
378
+ | `:q!` | Quit and discard changes |
379
+ | `:wq` | Save and quit |
380
+ | `:x` | Save if changed, then quit |
381
+ | `:N` | Go to line `N` |
382
+
383
+ ### Vibe design notes
384
+
385
+ Vibe mode is not trying to be Vim. It is a focused subset designed for quick edits inside a chat-based coding agent. Here is what to expect:
386
+
387
+ - **Counts work with commands and motions**: `3dd` deletes three lines, `2w` moves two words, `5x` deletes five characters.
388
+ - **`.` repeats the last change**: after `cw word Esc`, pressing `.` changes the next word the same way. Insert-mode keystrokes are recorded as part of the change.
389
+ - **`/` and `?` search forward and backward**: `n` and `N` repeat the last search. `*` and `#` search for the word under the cursor.
390
+ - **Operators with motions**: `d`, `y`, and `c` work with `w` (word), `e` (end of word), `b` (back word), `$` (end of line), `0` (start of line), and `^` (first non-blank).
391
+ - **Yanks copy to the terminal clipboard**: when OSC 52 is supported, yanked text is also sent to the system clipboard, so you can paste into other applications.
392
+ - **Registers and macros are supported**: named registers work with yank/delete/paste flows, and `q`/`@` record and replay simple macros for repeated edits.
393
+ - **Viewport commands**: `zz`, `zt`, and `zb` reposition the cursor line to the center, top, or bottom of the viewport without moving the cursor itself — the same as Vim.
394
+ - **Indentation navigation**: `Ctrl+J` and `Ctrl+K` jump to the next or previous indentation level, which is useful for navigating nested code blocks in Ruby and other indented languages.
data/doc/extensibility.md CHANGED
@@ -40,6 +40,8 @@ Default location:
40
40
 
41
41
  If `KWARD_CONFIG_PATH` is set, `PRINCIPLES.md` lives beside that config file.
42
42
 
43
+ If `PRINCIPLES.md` is absent, Kward also reads `~/.kward/AGENTS.md` (or the equivalent beside a custom config path) as a legacy alias. New setups should use `PRINCIPLES.md`. See [Configuration](configuration.md) for details.
44
+
43
45
  ## Project instructions: `AGENTS.md`
44
46
 
45
47
  Put repository-specific rules in the workspace root:
@@ -59,7 +61,7 @@ Update CHANGELOG.md for user-visible changes.
59
61
 
60
62
  Use `AGENTS.md` for project facts and engineering rules. Do not put personality or roleplay instructions there; use [personas](personas.md) for tone.
61
63
 
62
- By default, Kward adds a compact instruction telling the model that `AGENTS.md` exists and should be read when relevant. Set `enforce_workspace_agents_file: true` only if you want the full file injected every time.
64
+ By default, Kward adds a compact instruction telling the model that `AGENTS.md` exists and should be read when relevant. Set `enforce_workspace_agents_file: true` only if you want the full file injected every time. See [Configuration](configuration.md) for details.
63
65
 
64
66
  ## Prompt templates
65
67
 
@@ -89,6 +91,8 @@ Then run inside Kward:
89
91
  /review auth edge cases
90
92
  ```
91
93
 
94
+ The `description` frontmatter field appears in the slash command list and completion overlay so you can find the template by purpose. `argument-hint` is shown as a usage hint. The `$ARGUMENTS` placeholder in the body is replaced with whatever you type after the command.
95
+
92
96
  Prompt templates are best for reusable text. They do not run local code.
93
97
 
94
98
  ## Skills
@@ -106,14 +110,16 @@ Example:
106
110
  ```markdown
107
111
  ---
108
112
  name: testing
109
- or description: Use when adding or changing tests.
113
+ description: Use when adding or changing tests.
110
114
  ---
111
115
 
112
116
  Prefer focused tests near the changed behavior.
113
117
  Do not weaken assertions to make tests pass.
114
118
  ```
115
119
 
116
- Skills are listed to the model by name and description. Kward can load the full skill only when it is relevant.
120
+ Skills are listed to the model by name and description. When a task matches a skill, the model calls the `read_skill` tool to load the full `SKILL.md` instructions before proceeding.
121
+
122
+ Skills can also contain additional files alongside `SKILL.md`. The model can read them through `read_skill` with a relative `path` argument (for example, `path: examples.md`). Files must stay inside the skill folder; paths outside are rejected.
117
123
 
118
124
  ## Plugins
119
125
 
@@ -135,13 +141,16 @@ When Kward builds instructions for a turn, it combines roughly:
135
141
 
136
142
  1. Kward's built-in operating instructions.
137
143
  2. `PRINCIPLES.md`.
138
- 3. selected persona.
139
- 4. plugin prompt context.
140
- 5. available skills list.
141
- 6. workspace `AGENTS.md` hint or full content.
144
+ 3. memory context (when memory is enabled and relevant).
145
+ 4. selected persona.
146
+ 5. plugin prompt context.
147
+ 6. available skills list.
148
+ 7. workspace `AGENTS.md` hint or full content.
142
149
 
143
150
  If behavior seems surprising, inspect the assembled instructions:
144
151
 
145
152
  ```bash
146
153
  kward sysprompt
147
154
  ```
155
+
156
+ Add `--raw` to print the raw system prompt content without section formatting, useful for piping to another tool:
data/doc/files.md ADDED
@@ -0,0 +1,100 @@
1
+ # Project files
2
+
3
+ Use `/files` when you want to browse the current workspace as a tree, open a file in Kward's integrated editor, or insert a file mention into the chat composer without typing the path by hand.
4
+
5
+ It is built for the moment when you know the file is somewhere in the project, but you do not want to leave the TUI to run `find`, `ls`, or your external editor. The browser opens as an overlay inside the composer and keeps you in the same conversation.
6
+
7
+ ## Quick start
8
+
9
+ From an interactive Kward session, run:
10
+
11
+ ```text
12
+ /files
13
+ ```
14
+
15
+ Kward opens the project file browser. Use the arrow keys to move through the tree, then press `Enter` on a file to open it in the integrated editor.
16
+
17
+ When you quit the editor, Kward returns to the file browser at the same position so you can keep browsing nearby files.
18
+
19
+ ## What appears in the browser
20
+
21
+ Inside a Git repository, `/files` uses Git's project view:
22
+
23
+ ```bash
24
+ git ls-files --cached --others --exclude-standard
25
+ ```
26
+
27
+ That means tracked files and normal untracked files appear, while ignored files stay out of the list.
28
+
29
+ Outside Git, Kward scans the workspace directory and skips common noisy directories such as `.git`, `.yardoc`, `_yardoc`, `node_modules`, `rdoc`, `tmp`, and `vendor/bundle`.
30
+
31
+ ## Navigation
32
+
33
+ | Key | Action |
34
+ | --- | ------ |
35
+ | `↑` / `↓` | Move the selection |
36
+ | `Enter` | Open a file, or toggle a directory |
37
+ | `←` | Collapse the selected directory, or jump to its parent |
38
+ | `→` | Expand the selected directory |
39
+ | `Tab` | Start or stop search |
40
+ | `/` | Start search |
41
+ | `Backspace` | Delete the last search character |
42
+ | `Esc` | Leave search; press again to close the browser |
43
+ | `@` | Insert the selected file as an `@path` mention |
44
+
45
+ Directories use `▸` and `▾` markers to show collapsed and expanded state. Files are shown under their containing directory with indentation.
46
+
47
+ ## Search files
48
+
49
+ Press `Tab` or `/` to search. While search is active, type part of a path and Kward filters the browser to matching files.
50
+
51
+ For example:
52
+
53
+ ```text
54
+ /files
55
+ /agent
56
+ ```
57
+
58
+ Use `↑` and `↓` to choose a result, then press `Enter` to open it. Press `Esc` to return to the tree view.
59
+
60
+ ## Mention a file in chat
61
+
62
+ Press `@` on a selected file to insert it into the composer as an `@path` mention:
63
+
64
+ ```text
65
+ @lib/kward/agent.rb
66
+ ```
67
+
68
+ This is useful when you want Kward to talk about a specific file instead of opening it yourself. After inserting the mention, finish your prompt normally:
69
+
70
+ ```text
71
+ @lib/kward/agent.rb Explain how tool execution works here.
72
+ ```
73
+
74
+ ## Open and edit files
75
+
76
+ Press `Enter` on a file to open it in the integrated editor. The editor uses your configured editor mode: Modern, Emacs, or Vibe.
77
+
78
+ A typical workflow:
79
+
80
+ 1. Run `/files`.
81
+ 2. Search for `README`, `agent`, or another path fragment.
82
+ 3. Press `Enter` on the file you want.
83
+ 4. Make the edit in the integrated editor.
84
+ 5. Save and quit.
85
+ 6. Continue browsing files, or press `Esc` to return to chat.
86
+
87
+ See [Integrated Editor](editor.md) for editor modes, save/quit keys, search, selection, and configuration.
88
+
89
+ ## Remembered state
90
+
91
+ Kward remembers the expanded folders and selected path for each workspace. The next time you open `/files` in the same project, it restores the browser close to where you left it.
92
+
93
+ Search itself is temporary. Closing search returns to the normal tree, and closing the browser leaves your chat session intact.
94
+
95
+ ## Notes and limitations
96
+
97
+ - `/files` is only available in the interactive prompt.
98
+ - It opens files inside the current workspace.
99
+ - It is a focused project browser, not a full file manager: it does not rename, move, copy, or delete files.
100
+ - Ignored Git files are intentionally hidden when Git can provide the file list.
@@ -18,13 +18,21 @@ Install the gem:
18
18
  gem install kward
19
19
  ```
20
20
 
21
- Install the starter pack:
21
+ Optionally install the starter pack:
22
22
 
23
23
  ```bash
24
24
  kward init
25
25
  ```
26
26
 
27
- The starter pack adds default prompts and a base `PRINCIPLES.md` under `~/.kward`. It does not overwrite existing files.
27
+ The starter pack adds default prompts and a base `PRINCIPLES.md` under `~/.kward`. It does not overwrite existing files. It is safe to skip if you prefer to create your own instructions. It requires network access because it fetches the pack from GitHub.
28
+
29
+ Verify your setup:
30
+
31
+ ```bash
32
+ kward doctor
33
+ ```
34
+
35
+ This checks your config, auth, writable directories, and workspace. Run `kward help` to see all available commands and examples.
28
36
 
29
37
  If you are working from a checkout instead:
30
38
 
@@ -49,6 +57,14 @@ Or from inside an interactive session:
49
57
 
50
58
  Kward supports OpenAI/ChatGPT, Anthropic Claude Pro/Max, OpenRouter, and experimental Copilot credentials. See [Authentication](authentication.md) when you need a specific provider.
51
59
 
60
+ Confirm your credentials are saved:
61
+
62
+ ```bash
63
+ kward auth status
64
+ ```
65
+
66
+ If your provider offers multiple models, choose one inside Kward with `/model`.
67
+
52
68
  ## Start an interactive chat
53
69
 
54
70
  Run Kward from the project you want it to work on:
@@ -58,6 +74,12 @@ cd ~/code/my-project
58
74
  kward
59
75
  ```
60
76
 
77
+ Or point Kward at a project without leaving your shell:
78
+
79
+ ```bash
80
+ kward --working-directory ~/code/my-project
81
+ ```
82
+
61
83
  Ask something concrete:
62
84
 
63
85
  ```text
@@ -88,7 +110,7 @@ git diff | kward "Review this diff for bugs"
88
110
 
89
111
  One-shot prompts do not use Kward memory.
90
112
 
91
- ## Useful first commands
113
+ ## Useful interactive commands
92
114
 
93
115
  Inside interactive Kward:
94
116
 
@@ -97,27 +119,12 @@ Inside interactive Kward:
97
119
  /model choose a model
98
120
  /status show session and context status
99
121
  /sessions open the saved sessions picker
100
- /resume alias for /sessions
101
122
  /rewind revisit an earlier prompt
102
123
  /export notes.md export the transcript
103
124
  /compact summarize older context when a chat gets long
104
125
  /exit leave Kward
105
126
  ```
106
127
 
107
- ## Run from source
108
-
109
- ```bash
110
- ruby lib/main.rb login
111
- ruby lib/main.rb
112
- ruby lib/main.rb "Explain this project"
113
- ```
114
-
115
- You can also run:
116
-
117
- ```bash
118
- exe/kward
119
- ```
120
-
121
128
  ## Next steps
122
129
 
123
130
  - Read [Usage](usage.md) for day-to-day workflows.