kward 0.68.0 → 0.69.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 (70) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/pages.yml +48 -0
  3. data/.yardopts +1 -0
  4. data/CHANGELOG.md +34 -0
  5. data/Gemfile.lock +8 -2
  6. data/README.md +32 -25
  7. data/Rakefile +14 -1
  8. data/doc/authentication.md +74 -56
  9. data/doc/code-search.md +55 -28
  10. data/doc/configuration.md +18 -0
  11. data/doc/extensibility.md +89 -128
  12. data/doc/getting-started.md +52 -54
  13. data/doc/memory.md +51 -118
  14. data/doc/personas.md +417 -0
  15. data/doc/plugins.md +55 -97
  16. data/doc/releasing.md +3 -1
  17. data/doc/rpc.md +1 -1
  18. data/doc/usage.md +125 -144
  19. data/doc/web-search.md +80 -14
  20. data/exe/kward +2 -0
  21. data/lib/kward/agent.rb +1 -1
  22. data/lib/kward/cli/commands.rb +10 -3
  23. data/lib/kward/cli/compaction.rb +3 -3
  24. data/lib/kward/cli/interactive_turn.rb +3 -1
  25. data/lib/kward/cli/memory_commands.rb +16 -16
  26. data/lib/kward/cli/plugins.rb +3 -3
  27. data/lib/kward/cli/prompt_interface.rb +15 -13
  28. data/lib/kward/cli/rendering.rb +35 -46
  29. data/lib/kward/cli/runtime_helpers.rb +13 -2
  30. data/lib/kward/cli/sessions.rb +21 -21
  31. data/lib/kward/cli/settings.rb +49 -43
  32. data/lib/kward/cli/slash_commands.rb +6 -4
  33. data/lib/kward/cli/stats.rb +2 -2
  34. data/lib/kward/cli/sysprompt.rb +57 -0
  35. data/lib/kward/cli/tool_summaries.rb +5 -1
  36. data/lib/kward/cli.rb +14 -2
  37. data/lib/kward/cli_transcript_formatter.rb +36 -5
  38. data/lib/kward/compactor.rb +2 -2
  39. data/lib/kward/config_files.rb +45 -10
  40. data/lib/kward/conversation.rb +41 -9
  41. data/lib/kward/memory/manager.rb +131 -14
  42. data/lib/kward/message_access.rb +6 -0
  43. data/lib/kward/model/context_usage.rb +11 -10
  44. data/lib/kward/model/model_info.rb +18 -1
  45. data/lib/kward/model/payloads.rb +89 -10
  46. data/lib/kward/model/stream_parser.rb +258 -25
  47. data/lib/kward/prompt_interface/question_prompt.rb +1 -1
  48. data/lib/kward/prompt_interface/transcript_renderer.rb +20 -11
  49. data/lib/kward/prompts.rb +61 -7
  50. data/lib/kward/rpc/server.rb +7 -2
  51. data/lib/kward/rpc/session_manager.rb +18 -2
  52. data/lib/kward/rpc/session_metrics.rb +2 -2
  53. data/lib/kward/rpc/transcript_normalizer.rb +47 -0
  54. data/lib/kward/session_store.rb +40 -1
  55. data/lib/kward/starter_pack_installer.rb +2 -2
  56. data/lib/kward/tools/fetch_content.rb +41 -0
  57. data/lib/kward/tools/fetch_raw.rb +40 -0
  58. data/lib/kward/tools/registry.rb +9 -2
  59. data/lib/kward/tools/search/web.rb +3 -3
  60. data/lib/kward/tools/search/web_fetch.rb +202 -0
  61. data/lib/kward/tools/tool_call.rb +2 -0
  62. data/lib/kward/version.rb +1 -1
  63. data/templates/default/fulldoc/html/css/kward.css +1501 -0
  64. data/templates/default/fulldoc/html/images/kward_logo.png +0 -0
  65. data/templates/default/fulldoc/html/js/kward.js +296 -0
  66. data/templates/default/fulldoc/html/setup.rb +8 -0
  67. data/templates/default/layout/html/breadcrumb.erb +11 -0
  68. data/templates/default/layout/html/layout.erb +141 -0
  69. data/templates/default/layout/html/setup.rb +139 -0
  70. metadata +14 -1
data/doc/plugins.md CHANGED
@@ -1,18 +1,25 @@
1
1
  # Plugins
2
2
 
3
- Plugins are Kward's trusted local extension system. They let you add project or personal workflow features without changing Kward itself.
3
+ Plugins are trusted local Ruby extensions for Kward. Use them when you need behavior that prompts, skills, or instructions cannot provide.
4
4
 
5
- A plugin can:
5
+ Good plugin use cases:
6
6
 
7
- - add interactive slash commands,
8
- - expose commands through the RPC backend,
9
- - render a custom terminal footer,
10
- - inject concise prompt context into future model requests,
11
- - observe live transcript events such as assistant output, tool calls, and retries.
7
+ - add a slash command for a personal workflow,
8
+ - show project/session status in the terminal footer,
9
+ - add concise local context to prompts,
10
+ - log or observe transcript events,
11
+ - expose local commands to an RPC client.
12
12
 
13
- Plugins are plain Ruby files. They run inside the Kward process with your local user permissions, so install only plugins you trust.
13
+ Plugins run inside the Kward process with your user permissions. Install only plugins you trust.
14
14
 
15
- Use a prompt template when reusable text is enough. Use a skill when you need reusable instructions. Use a plugin when you need local Ruby behavior, file or network integration, custom commands, or transcript observers.
15
+ ## When to use a plugin
16
+
17
+ | Need | Better choice |
18
+ | --- | --- |
19
+ | Reusable prompt text | prompt template |
20
+ | Reusable model instructions | skill |
21
+ | Repository rules | `AGENTS.md` |
22
+ | Local Ruby code or integration | plugin |
16
23
 
17
24
  ## Where plugins live
18
25
 
@@ -22,7 +29,7 @@ Kward loads top-level Ruby files from:
22
29
  ~/.kward/plugins/*.rb
23
30
  ```
24
31
 
25
- Plugins are intentionally **not** loaded from the current workspace, from a project repository, or from a custom `KWARD_CONFIG_PATH` directory. This keeps plugin loading tied to the local user account rather than to whatever project Kward is currently inspecting.
32
+ Plugins are not loaded from the current workspace or a custom `KWARD_CONFIG_PATH` directory. This prevents a project checkout from silently adding executable Ruby code to Kward.
26
33
 
27
34
  ## A first plugin
28
35
 
@@ -32,12 +39,12 @@ Create the plugin directory:
32
39
  mkdir -p ~/.kward/plugins
33
40
  ```
34
41
 
35
- Then create `~/.kward/plugins/hello.rb`:
42
+ Create `~/.kward/plugins/hello.rb`:
36
43
 
37
44
  ```ruby
38
45
  Kward.plugin do |plugin|
39
46
  plugin.command "hello", description: "Say hello", argument_hint: "[name]" do |args, ctx|
40
- name = args.strip.empty? ? "captain" : args.strip
47
+ name = args.strip.empty? ? "there" : args.strip
41
48
  ctx.say("Hello, #{name}.")
42
49
  end
43
50
  end
@@ -49,41 +56,28 @@ Start Kward and run:
49
56
  /hello Kai
50
57
  ```
51
58
 
52
- Plugin commands appear in interactive slash completion and in RPC command listings.
53
-
54
- ## Slash commands
59
+ ## Add a slash command
55
60
 
56
- Register a command with `plugin.command`:
61
+ Use plugin commands for local actions that should not call the model.
57
62
 
58
63
  ```ruby
59
64
  Kward.plugin do |plugin|
60
65
  plugin.command "session-info", description: "Show session details" do |_args, ctx|
61
66
  ctx.say("Session: #{ctx.session_name || ctx.session_id || 'unnamed'}")
62
- ctx.say("Path: #{ctx.session_path || 'not saved'}")
63
67
  ctx.say("Workspace: #{ctx.workspace_root}")
64
68
  end
65
69
  end
66
70
  ```
67
71
 
68
- Command names:
69
-
70
- - do not include the leading `/`,
71
- - must start with a letter or number,
72
- - may contain letters, numbers, `_`, and `-`,
73
- - cannot replace built-in commands or prompt-template commands.
74
-
75
- If a plugin command conflicts with a reserved or duplicate command, Kward skips it and prints a warning.
76
-
77
- Command handlers receive:
72
+ Command names do not include `/`. They must start with a letter or number and may contain letters, numbers, `_`, and `-`.
78
73
 
79
- - `args`: the raw text after the command name,
80
- - `ctx`: a plugin context object.
74
+ A plugin command cannot replace a built-in command or prompt-template command.
81
75
 
82
- Use `ctx.say(message)` for user-visible output.
76
+ ## Add prompt context
83
77
 
84
- ## Prompt context
78
+ Prompt context is short text injected into future model requests.
85
79
 
86
- Plugins can add concise context to future system prompts:
80
+ Use it for stable facts the model should know, not for large files or secrets.
87
81
 
88
82
  ```ruby
89
83
  Kward.plugin do |plugin|
@@ -95,37 +89,29 @@ Kward.plugin do |plugin|
95
89
  end
96
90
  ```
97
91
 
98
- Prompt context is injected after personas and before skills/workspace instructions. Keep it short and stable. Long or noisy prompt context will be sent repeatedly to the model and can reduce useful context space.
99
-
100
- If plugin state changes and the active conversation should rebuild its system message, call:
92
+ If plugin state changes and Kward should rebuild the active system message, call:
101
93
 
102
94
  ```ruby
103
95
  ctx.refresh_system_message!
104
96
  ```
105
97
 
106
- from a command or event handler.
107
-
108
- ## Custom footer
98
+ ## Add a footer
109
99
 
110
- A plugin can render one custom footer for the terminal UI:
100
+ A footer can show compact local status in the terminal UI:
111
101
 
112
102
  ```ruby
113
103
  Kward.plugin do |plugin|
114
104
  plugin.footer do |ctx|
115
- name = ctx.session_name || "unnamed"
116
- messages = ctx.transcript.messages.length
117
- "#{name} • #{messages} messages"
105
+ "#{ctx.session_name || 'unnamed'} • #{ctx.transcript.messages.length} messages"
118
106
  end
119
107
  end
120
108
  ```
121
109
 
122
- Only one footer renderer is active. If multiple plugins register footers, the later one replaces the earlier one and Kward prints a warning.
123
-
124
- Footer errors are caught and printed as warnings so they do not break the session.
110
+ Only one footer is active. If multiple plugins register footers, the later one replaces the earlier one and Kward prints a warning.
125
111
 
126
- ## Transcript events
112
+ ## Observe transcript events
127
113
 
128
- Plugins can observe live transcript stream events:
114
+ Use transcript events when you need to log or react to live activity:
129
115
 
130
116
  ```ruby
131
117
  Kward.plugin do |plugin|
@@ -139,7 +125,9 @@ Kward.plugin do |plugin|
139
125
  end
140
126
  ```
141
127
 
142
- Supported event types include:
128
+ Event payloads are read-only copies. Handler errors are caught and printed as warnings.
129
+
130
+ Common event types include:
143
131
 
144
132
  - `reasoning_delta`
145
133
  - `assistant_delta`
@@ -150,28 +138,24 @@ Supported event types include:
150
138
  - `tool_result`
151
139
  - `answer`
152
140
 
153
- Event payloads are deep-frozen copies. Treat them as read-only.
154
-
155
- Transcript-event handler errors are caught and printed as warnings.
141
+ ## Plugin context
156
142
 
157
- ## Plugin context API
143
+ Handlers receive a `ctx` object. Common methods:
158
144
 
159
- Plugin handlers receive a `ctx` object with:
145
+ - `ctx.workspace_root`
146
+ - `ctx.args`
147
+ - `ctx.say(message)`
148
+ - `ctx.transcript.messages`
149
+ - `ctx.session_id`
150
+ - `ctx.session_name`
151
+ - `ctx.session_path`
152
+ - `ctx.refresh_system_message!`
160
153
 
161
- - `ctx.args` - raw command arguments for contexts that have them.
162
- - `ctx.workspace_root` - active workspace path.
163
- - `ctx.transcript.messages` - deep-frozen copy of active conversation messages.
164
- - `ctx.say(message)` - emit output to the active frontend when available.
165
- - `ctx.session_id` - current persisted session ID when available.
166
- - `ctx.session_name` - current session name when available.
167
- - `ctx.session_path` - current session file path when available.
168
- - `ctx.refresh_system_message!` - rebuild the active conversation system message.
169
-
170
- The transcript is read-only by design. Plugins should use Kward APIs exposed through the context rather than mutating conversation internals.
154
+ The transcript is read-only. Use context methods instead of mutating Kward internals.
171
155
 
172
156
  ## RPC support
173
157
 
174
- Plugins are available to both the CLI and the experimental RPC backend.
158
+ Plugins are available in the CLI and experimental RPC backend.
175
159
 
176
160
  RPC clients can:
177
161
 
@@ -179,43 +163,17 @@ RPC clients can:
179
163
  - run plugin commands through `commands/run`,
180
164
  - run plugin slash commands through `turns/start` input such as `/hello Kai`.
181
165
 
182
- When a plugin command is run as a turn, Kward emits command output through normal turn events without calling the model.
166
+ Plugin command output is emitted through normal turn events without calling the model.
183
167
 
184
- ## Security model
168
+ ## Security
185
169
 
186
- Plugins are trusted local Ruby code. A plugin can read and write files, run commands, make network requests, and access process environment variables just like any Ruby code running as your user.
170
+ Plugins are local Ruby code. They can read files, write files, run commands, make network requests, and read environment variables as your user.
187
171
 
188
172
  Recommended practices:
189
173
 
190
174
  - Install plugins only from sources you trust.
191
175
  - Keep plugins in your personal `~/.kward/plugins` directory.
192
- - Do not place secrets directly in plugin files if they will be shared.
193
- - Prefer user-specific config or environment variables for credentials.
194
- - Keep prompt context concise and avoid injecting secrets into model prompts.
195
- - Be careful when writing transcript observers that persist conversation content.
196
-
197
- ## Complete example
198
-
199
- ```ruby
200
- Kward.plugin do |plugin|
201
- plugin.command "last-message", description: "Show transcript size" do |_args, ctx|
202
- ctx.say("Messages: #{ctx.transcript.messages.length}")
203
- end
204
-
205
- plugin.footer do |ctx|
206
- "#{ctx.session_name || 'unnamed'} • #{ctx.transcript.messages.length} messages"
207
- end
208
-
209
- plugin.prompt_context do |_ctx|
210
- "Project background: prefer small, focused changes."
211
- end
212
-
213
- plugin.on_transcript_event do |event, ctx|
214
- next unless event.type == "assistant_delta"
215
-
216
- File.open(File.join(ctx.workspace_root, ".assistant-stream.log"), "a") do |file|
217
- file.write(event.payload[:delta])
218
- end
219
- end
220
- end
221
- ```
176
+ - Do not put secrets in shared plugin files.
177
+ - Prefer environment variables or private config for credentials.
178
+ - Keep prompt context short and never inject secrets into model prompts.
179
+ - Be careful with transcript observers that persist conversation content.
data/doc/releasing.md CHANGED
@@ -14,9 +14,11 @@ Release steps before publishing:
14
14
 
15
15
  ```bash
16
16
  bundle exec rake rdoc
17
- bundle exec yard doc
17
+ bundle exec rake docs:build
18
18
  ```
19
19
 
20
+ Pushes to `main` deploy the generated YARD site to GitHub Pages.
21
+
20
22
  5. Build the gem locally:
21
23
 
22
24
  ```bash
data/doc/rpc.md CHANGED
@@ -554,7 +554,7 @@ Params:
554
554
 
555
555
  - `sessionId`: active RPC session ID.
556
556
 
557
- Returns stable startup sections for configured context (`AGENTS.md`), skills, prompt templates, and plugin slash commands.
557
+ Returns stable startup sections for configured context (`PRINCIPLES.md`, or legacy `AGENTS.md`), skills, prompt templates, and plugin slash commands.
558
558
 
559
559
  ### `prompts/list`
560
560
 
data/doc/usage.md CHANGED
@@ -1,217 +1,198 @@
1
1
  # Usage
2
2
 
3
- Kward's most common commands are:
3
+ Kward has two main modes:
4
+
5
+ - **Interactive chat** for ongoing work in a project.
6
+ - **One-shot prompts** for quick questions, reviews, and summaries.
7
+
8
+ Run Kward from the workspace you want it to inspect:
4
9
 
5
10
  ```bash
6
- kward # interactive chat
7
- kward help # command overview and examples
8
- kward "Explain this project" # one-shot prompt
9
- kward init # optional first-time setup
10
- kward doctor # check local setup
11
- kward auth status # show saved credential status
12
- kward pan # Pan mode web UI
13
- kward rpc # experimental JSON-RPC backend
11
+ cd ~/code/project
12
+ kward
14
13
  ```
15
14
 
16
15
  When running from source, replace `kward` with `ruby lib/main.rb`.
17
16
 
18
- ## Starter pack
17
+ ## Common workflows
19
18
 
20
- Install Kward's starter prompts and base `AGENTS.md` into your config directory, usually `~/.kward`:
19
+ ### Understand a new project
21
20
 
22
- ```bash
23
- kward init
21
+ ```text
22
+ Explain the project structure and point out the main entry points.
24
23
  ```
25
24
 
26
- The installer downloads the pinned `kaiwood/kward-starter-pack` `v1.0.0` release, creates the config directory and base `config.json` if needed, and copies only starter-pack instruction/prompt files. It preserves the starter-pack layout in your config directory and skips files that already exist.
25
+ Useful follow-ups:
27
26
 
28
- ## Interactive chat
27
+ ```text
28
+ Where is configuration loaded?
29
+ Which files would I read first to understand authentication?
30
+ Summarize the test strategy.
31
+ ```
29
32
 
30
- Interactive mode opens a terminal composer and saves the conversation as a per-workspace session. Use it when you want Kward to inspect files, make changes, run commands, or continue a conversation over time.
33
+ ### Review changes before committing
31
34
 
32
- The composer stays available while assistant and tool output streams. If you press Enter while a response is still running, Kward queues your next prompt and sends it after the current turn finishes. Press Ctrl+C while a response is running to stop the current turn and return to the composer.
35
+ ```bash
36
+ git diff | kward "Review this diff for bugs, missing tests, and confusing naming"
37
+ ```
33
38
 
34
- Prefix input with `!` to run a local shell command from the workspace root without sending it to the model:
39
+ For larger reviews, use interactive mode so Kward can inspect related files:
35
40
 
36
41
  ```text
37
- !git status --short
42
+ Review the current git diff. If something looks risky, inspect the relevant files before recommending changes.
38
43
  ```
39
44
 
40
- ## Shell commands
45
+ ### Make a small code change
41
46
 
42
- Use `kward help` or `kward --help` to print a colored overview of available commands and examples. Use `kward help <command>` or `<command> --help` for command-specific help. Use `kward version` or `kward --version` to print the installed version.
47
+ ```text
48
+ Add a --json option to the status command. Keep the text output unchanged and add focused tests.
49
+ ```
43
50
 
44
- Use `kward doctor` to check local config, workspace, auth hints, Pan credentials, and writable directories. Use `kward auth status` to show saved credential status without printing secrets, or `kward auth logout` to remove saved OpenAI, GitHub, and OpenRouter credentials.
51
+ Kward must read an existing file in the current conversation before editing it. This guardrail helps prevent accidental overwrites.
45
52
 
46
- Use `--working-directory PATH` with any mode to run Kward from a different workspace:
53
+ ### Run local checks
47
54
 
48
- ```bash
49
- kward --working-directory ~/code/project
50
- kward --working-directory ~/code/project "Summarize this project"
51
- kward --working-directory ~/code/project pan
52
- kward --working-directory ~/code/project rpc
53
- ```
55
+ Inside interactive mode, ask Kward to run a command:
54
56
 
55
- ## One-shot prompts
57
+ ```text
58
+ Run the focused test for the CLI status command.
59
+ ```
56
60
 
57
- Command names take precedence. Invalid arguments for known commands show usage instead of becoming prompts. Anything else passed as command-line text is sent as a one-shot prompt:
61
+ Or run a shell command yourself from the composer by prefixing it with `!`:
58
62
 
59
- ```bash
60
- kward "Summarize the changes in this repository"
61
- kward Summarize the changes in this repository
63
+ ```text
64
+ !git status --short
62
65
  ```
63
66
 
64
- Use `--` before the prompt when the prompt itself starts with a command name or contains option-like text:
67
+ ## Shell commands
68
+
69
+ Useful shell commands:
65
70
 
66
71
  ```bash
67
- kward -- pan extra
68
- kward -- explain --working-directory option
72
+ kward # start interactive chat
73
+ kward "Explain this project" # ask one question and exit
74
+ kward help # show commands and examples
75
+ kward doctor # check local setup
76
+ kward login # sign in or save credentials
77
+ kward auth status # show credential status without secrets
78
+ kward sysprompt # inspect assembled instructions
79
+ kward rpc # start the experimental RPC backend
69
80
  ```
70
81
 
71
- Kward also accepts piped input:
82
+ Use another workspace without changing directories:
72
83
 
73
84
  ```bash
74
- git diff | kward "Review this diff"
85
+ kward --working-directory ~/code/project
86
+ kward --working-directory ~/code/project "Summarize this repository"
75
87
  ```
76
88
 
77
- One-shot prompts do not use Kward memory.
89
+ ## Interactive slash commands
78
90
 
79
- ## Workspace tools
91
+ Use slash commands for local actions that should not go to the model:
80
92
 
81
- Kward can use these tools during a turn:
82
-
83
- - `list_directory` and `read_file` to inspect the workspace.
84
- - `write_file` and `edit_file` to create or change files.
85
- - `run_shell_command` to run local commands from the workspace.
86
- - `web_search` to search the live web.
87
- - `code_search` to find packages, clone public GitHub repositories into cache, and read bounded source snippets.
88
- - `ask_user_question` to ask structured clarification questions.
89
-
90
- Safety rules:
91
-
92
- - Existing files must be read in the current conversation before Kward can write or edit them.
93
- - Text file reads and edits are capped at 256 KiB per file.
94
- - Tool schemas are the official contract for generated tool calls and returned tool payloads.
95
- - At runtime, Kward accepts tolerant incoming tool-call input for compatibility: extra fields are ignored, and existing legacy-compatible input shapes remain supported.
96
- - Required fields and invalid required values still return explicit tool errors.
97
- - Tool output payloads are kept schema-clean so future model calls and restored transcripts do not depend on accidental extra fields.
98
- - When successful tool results include unified diffs, the composer status shows live session totals such as `+700|-572`.
99
-
100
- ## Slash commands
101
-
102
- Use slash commands in interactive mode for local Kward actions:
103
-
104
- | Command | Purpose |
93
+ | Command | Use it when you want to... |
105
94
  | --- | --- |
106
- | `/exit`, `/quit` | Leave the session. |
107
- | `/new` | Start a fresh session. |
108
- | `/resume [path]` | Resume a saved session, or pick one when no path is given. |
109
- | `/name [name]` | Name or clear the current session name. |
110
- | `/clone` | Duplicate the current session. |
111
- | `/copy [last\|transcript]` | Copy clean assistant text or the Markdown transcript to the clipboard. |
112
- | `/export [path]` | Export the transcript as Markdown. |
113
- | `/compact [instructions]` | Summarize older conversation into a checkpoint and keep recent context. |
114
- | `/model` | Choose or type the default model. |
115
- | `/openrouter/catalog` | List the full OpenRouter model catalog. |
116
- | `/reasoning` | Choose reasoning effort. |
117
- | `/settings` | Configure overlay alignment and width. |
118
- | `/login` | Log in from inside the session. |
119
- | `/status` | Show status and auto-compaction information. |
120
- | `/stats [range]` | Show local telemetry stats when logging is enabled. |
121
- | `/memory ...` | Manage opt-in memory. |
122
- | `/redraw` | Refresh the terminal after resize or drawing glitches. |
123
-
124
- Prompt templates can add more slash commands. Plugin commands can also appear when trusted local plugins are installed.
95
+ | `/login` | sign in or save provider credentials. |
96
+ | `/model` | choose the active model. |
97
+ | `/reasoning` | choose reasoning effort. |
98
+ | `/status` | see session, model, and context status. |
99
+ | `/new` | start a fresh session. |
100
+ | `/resume` | continue a previous session. |
101
+ | `/name <name>` | name the current session. |
102
+ | `/clone` | copy the current session into a new branch. |
103
+ | `/copy last` | copy the latest assistant answer. |
104
+ | `/copy transcript` | copy the transcript as Markdown. |
105
+ | `/export notes.md` | write the transcript to a Markdown file. |
106
+ | `/compact [focus]` | summarize older context so a long chat can continue. |
107
+ | `/memory ...` | manage opt-in memory. |
108
+ | `/redraw` | fix terminal drawing after resize or glitches. |
109
+ | `/exit` | leave Kward. |
110
+
111
+ Prompt templates and plugins can add more slash commands.
125
112
 
126
113
  ## Sessions
127
114
 
128
- Interactive chats are stored as JSONL files under `~/.kward/sessions/`. Sessions are per workspace.
115
+ Interactive chats are saved under:
129
116
 
130
- Useful session commands:
131
-
132
- - `/resume` opens a picker for recent sessions.
133
- - `/name <name>` gives the current session a human-readable name.
134
- - `/clone` creates a new independent copy. Cloned sessions remember their parent and appear in the recent session picker by modification time.
135
- - `/copy` and `/copy last` copy the latest assistant response without terminal borders or ANSI styling. `/copy transcript` copies the clean Markdown transcript. Mouse selection may still include terminal UI chrome.
136
- - `/export [path]` writes a Markdown transcript. Explicit paths are resolved relative to the current workspace and must stay inside the workspace or Kward session directory.
137
- - `/compact [instructions]` summarizes older conversation into a structured Ruby-aware checkpoint. Text after `/compact ` is freeform focus text, not parsed as flags.
117
+ ```text
118
+ ~/.kward/sessions/
119
+ ```
138
120
 
139
- After compaction, Kward may need to re-read files before future edits because compacting clears remembered read-file state.
121
+ Sessions are scoped to the workspace. Use them when work spans more than one terminal sitting.
140
122
 
141
- ## Auto-compaction
123
+ Typical flow:
142
124
 
143
- Auto-compaction is enabled by default when Kward can determine the active context window. It reserves part of the model context so conversations can continue longer without suddenly exceeding the limit.
125
+ ```text
126
+ /name oauth cleanup
127
+ # work with Kward
128
+ /export oauth-notes.md
129
+ /exit
130
+ ```
144
131
 
145
- Configure it in `config.json`:
132
+ Later:
146
133
 
147
- ```json
148
- {
149
- "compaction": {
150
- "enabled": true,
151
- "reserve_tokens": 16384,
152
- "keep_recent_tokens": 20000
153
- }
154
- }
134
+ ```text
135
+ /resume
155
136
  ```
156
137
 
157
- Manual `/compact` still works when auto-compaction is disabled.
138
+ Use `/compact` when a conversation gets long. Kward summarizes older context and keeps recent context active. After compaction, it may need to re-read files before editing them again.
158
139
 
159
- ## Memory
160
-
161
- Memory is disabled by default and only applies to interactive sessions.
140
+ ## One-shot prompts
162
141
 
163
- Common commands:
142
+ One-shot prompts are best for short tasks that do not need session history:
164
143
 
165
- ```text
166
- /memory enable
167
- /memory core <text>
168
- /memory add <text>
169
- /memory list
170
- /memory why
171
- /memory promote <id>
172
- /memory relax <id>
173
- /memory forget <id>
174
- /memory disable
144
+ ```bash
145
+ kward "What does this repository do?"
146
+ git diff | kward "Review this diff"
147
+ cat error.log | kward "Explain the likely cause"
175
148
  ```
176
149
 
177
- See [Memory](memory.md) for storage locations, safety rules, auto-summary, and RPC methods.
150
+ Use `--` when your prompt starts with something that could be parsed as a command or option:
178
151
 
179
- ## Composer keys
152
+ ```bash
153
+ kward -- explain --working-directory
154
+ ```
180
155
 
181
- - Enter sends.
182
- - Shift+Enter inserts a newline.
183
- - Up/Down browse prompt history.
184
- - Ctrl+D exits from an empty prompt.
185
- - Ctrl+C stops the current response while assistant or tool output is running.
186
- - Backspace at the beginning of the prompt removes the most recent image attachment.
156
+ One-shot prompts do not use Kward memory.
187
157
 
188
- Multiline input grows the composer up to a capped height.
158
+ ## Workspace tools
189
159
 
190
- ## Image attachments
160
+ During a turn, Kward can inspect and change the workspace with tools for:
191
161
 
192
- Kward can attach images when the active model supports images. It detects:
162
+ - listing and reading files,
163
+ - creating and editing files,
164
+ - running shell commands,
165
+ - searching the web,
166
+ - fetching specific URLs,
167
+ - inspecting public source repositories,
168
+ - asking structured clarification questions.
193
169
 
194
- - pasted image file paths,
195
- - Markdown image links,
196
- - `file://` image URLs,
197
- - image data URLs.
170
+ Important guardrails:
198
171
 
199
- In the interactive composer, pasted image references appear as attachment badges instead of editable filename or base64 text. Transcripts show attachment badges and render the image inline when the terminal advertises a supported inline image protocol, such as iTerm2 or Kitty/WezTerm.
172
+ - Existing files must be read before Kward can edit or overwrite them.
173
+ - File reads and edits are bounded to avoid loading very large files by accident.
174
+ - Shell commands run from the workspace and should be treated like commands you run yourself.
200
175
 
201
- ## Pan mode
176
+ ## Images
202
177
 
203
- Pan mode starts a minimal LAN web UI with a prompt textarea and transcript:
178
+ If the active model supports images, Kward can attach image paths, Markdown image links, `file://` URLs, or image data URLs pasted into the composer.
204
179
 
205
- ```bash
206
- kward --working-directory="/path/to/workspace" pan
180
+ Use this for tasks such as:
181
+
182
+ ```text
183
+ This screenshot shows the broken layout. Find the likely CSS issue.
207
184
  ```
208
185
 
209
- From source:
186
+ ## Pan mode
187
+
188
+ Pan mode starts a simple LAN web UI:
210
189
 
211
190
  ```bash
212
- ruby lib/main.rb --working-directory="/path/to/workspace" pan
191
+ kward --working-directory ~/code/project pan
213
192
  ```
214
193
 
215
- Pan mode streams assistant output and tool calls, queues prompts submitted while a turn is running, and saves the conversation as a normal per-workspace session.
194
+ Use it only on trusted networks. It exposes the same file, shell, and web tools through a browser UI and requires credentials configured in `config.json`. See [Configuration](configuration.md).
195
+
196
+ ## RPC backend
216
197
 
217
- Configure `pan_mode.username` and `pan_mode.password` before starting it; see [Configuration](configuration.md). Pan mode is reachable on the LAN, so use it only on trusted networks.
198
+ `kward rpc` starts the experimental JSON-RPC backend for UI clients and editor integrations. Terminal users can ignore it. Integration authors should read [RPC protocol](rpc.md).