kward 0.70.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.
- checksums.yaml +4 -4
- data/.github/workflows/pages.yml +1 -1
- data/CHANGELOG.md +89 -3
- data/Gemfile +2 -0
- data/Gemfile.lock +90 -2
- data/README.md +34 -6
- data/Rakefile +96 -0
- data/doc/agent-tools.md +52 -0
- data/doc/api.md +92 -0
- data/doc/authentication.md +58 -23
- data/doc/code-search.md +42 -2
- data/doc/configuration.md +102 -13
- data/doc/context-budgeting.md +136 -0
- data/doc/context-tools.md +83 -0
- data/doc/editor.md +394 -0
- data/doc/extensibility.md +16 -7
- data/doc/files.md +100 -0
- data/doc/getting-started.md +25 -18
- data/doc/git.md +122 -0
- data/doc/memory.md +24 -4
- data/doc/personas.md +34 -5
- data/doc/plugins.md +74 -3
- data/doc/releasing.md +45 -8
- data/doc/rpc.md +77 -15
- data/doc/session-management.md +254 -0
- data/doc/shell.md +286 -0
- data/doc/tabs.md +122 -0
- data/doc/troubleshooting.md +77 -1
- data/doc/usage.md +60 -15
- data/doc/web-search.md +12 -4
- data/doc/workspace-tools.md +144 -0
- data/examples/plugins/space_invaders.rb +377 -0
- data/lib/kward/agent.rb +1 -1
- data/lib/kward/cli/commands.rb +41 -2
- data/lib/kward/cli/git.rb +150 -0
- data/lib/kward/cli/interactive_turn.rb +73 -9
- data/lib/kward/cli/openrouter_commands.rb +55 -0
- data/lib/kward/cli/plugins.rb +54 -4
- data/lib/kward/cli/prompt_interface.rb +111 -6
- data/lib/kward/cli/rendering.rb +11 -6
- data/lib/kward/cli/runtime_helpers.rb +133 -3
- data/lib/kward/cli/sessions.rb +262 -13
- data/lib/kward/cli/settings.rb +216 -37
- data/lib/kward/cli/slash_commands.rb +439 -8
- data/lib/kward/cli/tabs.rb +695 -0
- data/lib/kward/cli.rb +171 -26
- data/lib/kward/compactor.rb +4 -1
- data/lib/kward/config_files.rb +125 -5
- data/lib/kward/context_budget_meter.rb +44 -0
- data/lib/kward/conversation.rb +59 -22
- data/lib/kward/editor_mode.rb +25 -0
- data/lib/kward/ekwsh.rb +362 -0
- data/lib/kward/model/client.rb +37 -50
- data/lib/kward/model/context_usage.rb +13 -6
- data/lib/kward/model/model_info.rb +92 -16
- data/lib/kward/model/payloads.rb +2 -0
- data/lib/kward/openrouter_model_cache.rb +120 -0
- data/lib/kward/plugin_registry.rb +108 -1
- data/lib/kward/project_files.rb +52 -0
- data/lib/kward/prompt_history.rb +82 -0
- data/lib/kward/prompt_interface/banner.rb +16 -51
- data/lib/kward/prompt_interface/composer_controller.rb +124 -83
- data/lib/kward/prompt_interface/composer_renderer.rb +116 -14
- 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 +509 -0
- data/lib/kward/prompt_interface/editor/buffer.rb +109 -0
- data/lib/kward/prompt_interface/editor/controller.rb +1018 -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 +353 -0
- data/lib/kward/prompt_interface/editor/modes/vibe.rb +1962 -0
- data/lib/kward/prompt_interface/editor/renderer.rb +243 -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 +1249 -0
- data/lib/kward/prompt_interface/editor/status_text.rb +23 -0
- data/lib/kward/prompt_interface/editor/syntax_highlighter.rb +420 -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 +299 -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 +416 -43
- data/lib/kward/prompt_interface/layout.rb +2 -2
- 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/prompt_renderer.rb +32 -13
- data/lib/kward/prompt_interface/question_prompt.rb +122 -82
- data/lib/kward/prompt_interface/runtime_state.rb +49 -1
- data/lib/kward/prompt_interface/screen.rb +17 -0
- data/lib/kward/prompt_interface/selection_prompt.rb +511 -58
- data/lib/kward/prompt_interface/stream_state.rb +7 -0
- data/lib/kward/prompt_interface/transcript_buffer.rb +13 -16
- data/lib/kward/prompt_interface/transcript_renderer.rb +3 -3
- data/lib/kward/prompt_interface.rb +307 -35
- data/lib/kward/prompts/commands.rb +7 -1
- data/lib/kward/prompts.rb +4 -2
- data/lib/kward/rpc/server.rb +45 -11
- data/lib/kward/rpc/session_manager.rb +52 -53
- data/lib/kward/rpc/session_tree_rows.rb +9 -115
- data/lib/kward/rpc/tool_event_normalizer.rb +1 -1
- data/lib/kward/session_store.rb +67 -4
- 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/telemetry/logger.rb +5 -3
- data/lib/kward/text_boundary.rb +25 -0
- data/lib/kward/tool_output_compactor.rb +127 -0
- data/lib/kward/tools/base.rb +8 -2
- data/lib/kward/tools/context_budget_stats.rb +54 -0
- data/lib/kward/tools/context_for_task.rb +202 -0
- data/lib/kward/tools/read_file.rb +8 -4
- data/lib/kward/tools/registry.rb +92 -15
- data/lib/kward/tools/retrieve_tool_output.rb +71 -0
- data/lib/kward/tools/search/web.rb +2 -2
- data/lib/kward/tools/summarize_file_structure.rb +29 -0
- data/lib/kward/tools/tool_call.rb +12 -0
- data/lib/kward/version.rb +1 -1
- data/lib/kward/workers/git_guard.rb +68 -0
- data/lib/kward/workers/live_view.rb +49 -0
- data/lib/kward/workers/manager.rb +288 -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 +7 -0
- data/lib/kward/workspace.rb +154 -12
- data/templates/default/fulldoc/html/css/kward.css +362 -42
- data/templates/default/fulldoc/html/full_list.erb +107 -0
- data/templates/default/fulldoc/html/js/kward.js +161 -2
- data/templates/default/fulldoc/html/setup.rb +8 -0
- data/templates/default/kward_navigation.rb +102 -0
- data/templates/default/layout/html/layout.erb +43 -10
- data/templates/default/layout/html/setup.rb +39 -38
- metadata +65 -3
- data/lib/kward/resources/avatar_kward_logo.rb +0 -50
- data/lib/kward/resources/pixel_logo.rb +0 -232
data/doc/troubleshooting.md
CHANGED
|
@@ -1,6 +1,74 @@
|
|
|
1
1
|
# Troubleshooting
|
|
2
2
|
|
|
3
|
-
This page
|
|
3
|
+
This page covers common issues and how to diagnose them. When something is not working, start with `kward doctor` — it checks your config, directories, workspace, model, and auth status in one pass.
|
|
4
|
+
|
|
5
|
+
## Run `kward doctor` first
|
|
6
|
+
|
|
7
|
+
`kward doctor` reports the state of your local setup without printing secrets:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
kward doctor
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
It checks that your config file is readable and valid JSON, that the config and session directories are writable, that the workspace exists, which provider and model are active, and which credentials are configured. Use it as the first diagnostic step for any unexpected behavior.
|
|
14
|
+
|
|
15
|
+
`kward auth status` gives a focused view of credentials only, also without printing secrets:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
kward auth status
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Authentication errors and token expiration
|
|
22
|
+
|
|
23
|
+
OAuth tokens expire. Kward refreshes access tokens automatically when a refresh token is available, but if the refresh token is missing or expired, requests fail with a provider-specific error:
|
|
24
|
+
|
|
25
|
+
- OpenAI: `No OpenAI OAuth login found.`
|
|
26
|
+
- Anthropic: `No Anthropic OAuth login found.`
|
|
27
|
+
- Copilot: `No GitHub Copilot OAuth login found.`
|
|
28
|
+
- OpenRouter: `No OpenRouter API key found.`
|
|
29
|
+
|
|
30
|
+
Re-run login for the affected provider:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
kward login # OpenAI
|
|
34
|
+
kward login anthropic # Anthropic
|
|
35
|
+
kward login openrouter # OpenRouter
|
|
36
|
+
kward login github # Copilot
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Or use `/login` inside Kward. See [Authentication](authentication.md) for the full provider flow.
|
|
40
|
+
|
|
41
|
+
## Provider usage limits and billing errors
|
|
42
|
+
|
|
43
|
+
Kward detects non-retryable quota and billing errors from providers, including messages such as `quota exceeded`, `insufficient_quota`, `out of credits`, and `monthly usage limit reached`. These are not retried — the request fails immediately.
|
|
44
|
+
|
|
45
|
+
If you see one of these errors:
|
|
46
|
+
|
|
47
|
+
- Check your provider dashboard for usage or billing limits.
|
|
48
|
+
- For OpenRouter, verify your account balance at [openrouter.ai](https://openrouter.ai).
|
|
49
|
+
- For OpenAI, check your organization's usage and billing settings.
|
|
50
|
+
- Switch to a different provider or model with `/model` if you have alternative credentials.
|
|
51
|
+
|
|
52
|
+
## Rate limiting and transient server errors
|
|
53
|
+
|
|
54
|
+
Kward automatically retries transient failures: HTTP 429 (rate limit) and 5xx server errors. It makes up to 3 attempts total with short backoff delays. Network errors such as timeouts and connection resets are also retried.
|
|
55
|
+
|
|
56
|
+
If requests fail after retries, you will see a message like `request failed after 3 attempts`. Common causes:
|
|
57
|
+
|
|
58
|
+
- You are hitting the provider's rate limit. Wait a moment and retry, or reduce request frequency.
|
|
59
|
+
- The provider is experiencing an outage. Check the provider's status page.
|
|
60
|
+
- Your session context is very large, making each request slower and more likely to time out. Use `/compact` to reduce context.
|
|
61
|
+
|
|
62
|
+
## Context overflow errors
|
|
63
|
+
|
|
64
|
+
When a conversation exceeds the model's context window, the provider returns an error such as `prompt is too long` or `exceeds the context window`. Kward detects these and does not retry them.
|
|
65
|
+
|
|
66
|
+
To resolve context overflow:
|
|
67
|
+
|
|
68
|
+
- Run `/compact` to summarize and reduce the conversation context.
|
|
69
|
+
- Start a new session with `/new` if the current one is no longer needed.
|
|
70
|
+
- Enable auto-compaction if it is off — see [Configuration](configuration.md).
|
|
71
|
+
- Switch to a model with a larger context window via `/model`.
|
|
4
72
|
|
|
5
73
|
## `gem install kward` succeeds, but `kward` is not found with rbenv
|
|
6
74
|
|
|
@@ -53,3 +121,11 @@ kward --help
|
|
|
53
121
|
```
|
|
54
122
|
|
|
55
123
|
This stale `.rbenv-shim` file can be left behind by an interrupted `rbenv rehash` or gem installation. It is local rbenv state, not a Kward packaging issue.
|
|
124
|
+
|
|
125
|
+
## Still stuck?
|
|
126
|
+
|
|
127
|
+
If none of the above resolves your issue:
|
|
128
|
+
|
|
129
|
+
1. Run `kward doctor` and `kward auth status` to gather diagnostics.
|
|
130
|
+
2. Check the [Authentication](authentication.md) and [Configuration](configuration.md) docs.
|
|
131
|
+
3. Search or report issues at the [Kward issue tracker](https://github.com/kaiwood/kward/issues).
|
data/doc/usage.md
CHANGED
|
@@ -12,7 +12,7 @@ cd ~/code/project
|
|
|
12
12
|
kward
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
When running from source, replace `kward` with `ruby lib/main.rb`.
|
|
15
|
+
When running from source, replace `kward` with `ruby lib/main.rb`. See [Getting started](getting-started.md) for install and sign-in.
|
|
16
16
|
|
|
17
17
|
## Common workflows
|
|
18
18
|
|
|
@@ -42,6 +42,14 @@ For larger reviews, use interactive mode so Kward can inspect related files:
|
|
|
42
42
|
Review the current git diff. If something looks risky, inspect the relevant files before recommending changes.
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
+
To review and commit changes interactively, use `/git`:
|
|
46
|
+
|
|
47
|
+
```text
|
|
48
|
+
/git
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
It opens a staging overlay where you can stage or unstage files, preview diffs, and write a commit message without leaving Kward.
|
|
52
|
+
|
|
45
53
|
### Make a small code change
|
|
46
54
|
|
|
47
55
|
```text
|
|
@@ -64,6 +72,14 @@ Or run a shell command yourself from the composer by prefixing it with `!`:
|
|
|
64
72
|
!git status --short
|
|
65
73
|
```
|
|
66
74
|
|
|
75
|
+
For several commands, enter the embedded Kward shell:
|
|
76
|
+
|
|
77
|
+
```text
|
|
78
|
+
/shell
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
`/shell` opens `ekwsh`, a Kward-native command mode. Kward keeps the tab bar, composer editing, and transcript rendering while each command runs through your configured shell. Built-ins such as `cd`, `pwd`, `export`, `unset`, `alias`, `clear`, and `exit` maintain shell-mode state between commands. Plain Tab completes built-in command names, configured aliases, executables from `$PATH`, and file paths from the shell's current directory; `cd` completion suggests directories only. `ekwsh` preserves safe ANSI SGR color/style output while stripping terminal-control sequences that could corrupt the TUI, and sets conservative color-friendly environment defaults such as `CLICOLOR=1`, `COLORTERM=truecolor`, and `TERM=xterm-256color` when needed. It does not force color by default; set `FORCE_COLOR`, `CLICOLOR_FORCE`, or command-specific flags such as `--color=always` if you want more aggressive color output. You can set global shell env vars and aliases in `~/.kward/ekwsh.yml`; see [Configuration](configuration.md). It is intended for command output, not full-screen interactive programs such as editors or pagers.
|
|
82
|
+
|
|
67
83
|
## Shell commands
|
|
68
84
|
|
|
69
85
|
Useful shell commands:
|
|
@@ -72,10 +88,12 @@ Useful shell commands:
|
|
|
72
88
|
kward # start interactive chat
|
|
73
89
|
kward "Explain this project" # ask one question and exit
|
|
74
90
|
kward help # show commands and examples
|
|
91
|
+
kward version # show the installed version
|
|
75
92
|
kward doctor # check local setup
|
|
76
93
|
kward login # sign in or save credentials
|
|
77
94
|
kward auth status # show credential status without secrets
|
|
78
95
|
kward sysprompt # inspect assembled instructions
|
|
96
|
+
kward stats tokens # export local token telemetry as CSV
|
|
79
97
|
kward rpc # start the experimental RPC backend
|
|
80
98
|
```
|
|
81
99
|
|
|
@@ -88,45 +106,67 @@ kward --working-directory ~/code/project "Summarize this repository"
|
|
|
88
106
|
|
|
89
107
|
## Interactive slash commands
|
|
90
108
|
|
|
91
|
-
|
|
109
|
+
Slash commands run local actions in the current session. Most do not send a prompt to the model; exceptions like `/git` and `/workers` orchestrate local flows that may then trigger model work.
|
|
92
110
|
|
|
93
111
|
| Command | Use it when you want to... |
|
|
94
112
|
| --- | --- |
|
|
95
113
|
| `/login` | sign in or save provider credentials. |
|
|
96
114
|
| `/model` | choose the active model. |
|
|
97
115
|
| `/reasoning` | choose reasoning effort. |
|
|
116
|
+
| `/git` | review uncommitted changes, stage files, and commit. |
|
|
117
|
+
| `/files` | browse project files in a nested tree and open them in the editor. |
|
|
118
|
+
| `/shell` | run workspace commands in the embedded Kward shell. |
|
|
119
|
+
| `/settings` | configure prompt overlays. |
|
|
98
120
|
| `/status` | see session, model, and context status. |
|
|
99
|
-
| `/new` | start a fresh session. |
|
|
121
|
+
| `/new` | start a fresh session in the current tab. |
|
|
122
|
+
| `/tab 2` | switch to tab 2. |
|
|
123
|
+
| `/tab move 1` | move the active tab to position 1. |
|
|
124
|
+
| `/tab move left` | move the active tab one position left. |
|
|
125
|
+
| `/tab move right` | move the active tab one position right. |
|
|
126
|
+
| `/tab close` | close the active tab. |
|
|
127
|
+
| `/tab new` | open a new tab. |
|
|
128
|
+
| `/tab name <label>` | rename the active tab label. |
|
|
100
129
|
| `/sessions` | open the saved sessions picker or continue a previous session by path. |
|
|
101
130
|
| `/resume` | alias for `/sessions`. |
|
|
102
|
-
| `/name <name>` | name the current session. |
|
|
131
|
+
| `/name <name>` | name or clear the current session. |
|
|
132
|
+
| `/rename <name>` | rename the current session. |
|
|
103
133
|
| `/clone` | copy the current session into a new branch. |
|
|
104
134
|
| `/rewind` | revisit an earlier prompt and try a different direction. |
|
|
105
135
|
| `/tree` | inspect and navigate the full technical session tree. |
|
|
106
136
|
| `/copy last` | copy the latest assistant answer. |
|
|
107
137
|
| `/copy transcript` | copy the transcript as Markdown. |
|
|
108
138
|
| `/export notes.md` | write the transcript to a Markdown file. |
|
|
109
|
-
| `/compact [
|
|
139
|
+
| `/compact [instructions]` | summarize older context so a long chat can continue. |
|
|
110
140
|
| `/memory ...` | manage opt-in memory. |
|
|
111
141
|
| `/redraw` | fix terminal drawing after resize or glitches. |
|
|
142
|
+
| `/reload` | reload installed plugins. |
|
|
143
|
+
| `/workers` | open the experimental worker pipeline (`new`, `do <task>`, or `list`). |
|
|
112
144
|
| `/exit` | leave Kward. |
|
|
113
145
|
|
|
114
146
|
Prompt templates and plugins can add more slash commands.
|
|
115
147
|
|
|
148
|
+
## Prompt history
|
|
149
|
+
|
|
150
|
+
In interactive mode, Kward keeps prompt history per workspace under `~/.kward/history/`. Press Up/Down to recall previous prompts across restarts.
|
|
151
|
+
|
|
152
|
+
Press `Ctrl-R` to search history. Type a fuzzy query in the composer, use Up/Down to choose a result from the overlay, then press Enter to place it back in the composer for editing or resubmission. Press Esc or Ctrl-C to cancel the search and restore the draft.
|
|
153
|
+
|
|
154
|
+
`$path` editor-open commands are also saved after a file opens successfully, using the resolved workspace-relative path.
|
|
155
|
+
|
|
116
156
|
## Sessions
|
|
117
157
|
|
|
118
|
-
Interactive chats are saved under:
|
|
158
|
+
Interactive chats are saved as workspace-scoped sessions under:
|
|
119
159
|
|
|
120
160
|
```text
|
|
121
161
|
~/.kward/sessions/
|
|
122
162
|
```
|
|
123
163
|
|
|
124
|
-
|
|
164
|
+
Use sessions when work spans more than one terminal sitting, or when you want to branch a conversation and try another direction.
|
|
125
165
|
|
|
126
166
|
Typical flow:
|
|
127
167
|
|
|
128
168
|
```text
|
|
129
|
-
/
|
|
169
|
+
/rename oauth cleanup
|
|
130
170
|
# work with Kward
|
|
131
171
|
/export oauth-notes.md
|
|
132
172
|
/exit
|
|
@@ -138,11 +178,9 @@ Later:
|
|
|
138
178
|
/sessions
|
|
139
179
|
```
|
|
140
180
|
|
|
141
|
-
`/resume` remains available as an alias
|
|
142
|
-
|
|
143
|
-
Use `/rewind` when you want to go back to an earlier prompt and try a different direction. Kward shows user prompts from the current session, lets you edit a prior prompt, and continues from that point as a branch. Use `/tree` when you need the full technical session tree, including branches, assistant entries, tool calls, and tool results.
|
|
181
|
+
In the sessions picker, press `r` to rename the highlighted session, `c` to clone it, `f` to fork from an earlier prompt, or `d` twice to delete it. `/resume` remains available as an alias for `/sessions`.
|
|
144
182
|
|
|
145
|
-
|
|
183
|
+
For the full guide to context management, cloning, forking, rewinding, `/tree`, compaction, and exports, read [Sessions](session-management.md).
|
|
146
184
|
|
|
147
185
|
## One-shot prompts
|
|
148
186
|
|
|
@@ -150,11 +188,18 @@ One-shot prompts are best for short tasks that do not need session history:
|
|
|
150
188
|
|
|
151
189
|
```bash
|
|
152
190
|
kward "What does this repository do?"
|
|
191
|
+
cat error.log | kward
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
When stdin and a prompt are both present, Kward runs in filter mode: stdin is the input, the prompt is the instruction, and stdout contains only the transformed result. You can also force this with `--filter` or `--mode filter`.
|
|
195
|
+
|
|
196
|
+
```bash
|
|
153
197
|
git diff | kward "Review this diff"
|
|
154
|
-
|
|
198
|
+
echo "Hello" | kward --filter "Translate to German"
|
|
199
|
+
kward --mode filter "Indent this JSON" < unindented.json
|
|
155
200
|
```
|
|
156
201
|
|
|
157
|
-
Use `--` when your prompt starts with something that could be parsed as a command or option:
|
|
202
|
+
Use `--mode chat`, `--mode oneshot`, or `--mode filter` to override automatic mode detection. Use `--` when your prompt starts with something that could be parsed as a command or option:
|
|
158
203
|
|
|
159
204
|
```bash
|
|
160
205
|
kward -- explain --working-directory
|
|
@@ -182,7 +227,7 @@ Important guardrails:
|
|
|
182
227
|
|
|
183
228
|
## Images
|
|
184
229
|
|
|
185
|
-
If the active model supports images, Kward can attach image paths, Markdown image links, `file://` URLs, or image data URLs pasted into the composer.
|
|
230
|
+
If the active model supports images, Kward can attach image paths, Markdown image links, `file://` URLs, or image data URLs pasted into the composer. Supported formats are GIF, JPEG, PNG, and WebP, up to 20 MB per image.
|
|
186
231
|
|
|
187
232
|
Use this for tasks such as:
|
|
188
233
|
|
data/doc/web-search.md
CHANGED
|
@@ -36,16 +36,18 @@ Kward should search first, then fetch important pages before relying on them.
|
|
|
36
36
|
|
|
37
37
|
## Network behavior
|
|
38
38
|
|
|
39
|
-
Web tools are advertised to the model by default. Queries and fetched URLs are sent over the network to the selected provider or target host.
|
|
39
|
+
Web tools are advertised to the model by default. Queries and fetched URLs are sent over the network to the selected provider or target host. See [Configuration](configuration.md) for the full `web_search` config reference including API key storage and the `provider` config setting.
|
|
40
40
|
|
|
41
41
|
In automatic mode, provider fallback is:
|
|
42
42
|
|
|
43
43
|
1. Exa API when `EXA_API_KEY` is configured, otherwise keyless Exa MCP.
|
|
44
|
-
2. Perplexity API when configured and model-provider fallback is allowed.
|
|
45
|
-
3. Gemini API with Google Search grounding when configured and model-provider fallback is allowed.
|
|
44
|
+
2. Perplexity API when `PERPLEXITY_API_KEY` is configured and model-provider fallback is allowed.
|
|
45
|
+
3. Gemini API with Google Search grounding when `GEMINI_API_KEY` is configured and model-provider fallback is allowed.
|
|
46
46
|
4. DuckDuckGo HTML search, then bundled public SearXNG instances.
|
|
47
47
|
|
|
48
|
-
You do not need an API key for basic web search, but keys can improve limits or provider choice.
|
|
48
|
+
You do not need an API key for basic web search, but keys can improve limits or provider choice. The default provider can also be set in config as `web_search.provider`; the tool argument overrides it for a single call.
|
|
49
|
+
|
|
50
|
+
Search output is capped at 8 KB total, with excerpts up to 300 characters and answer text up to 2,000 characters. HTTP requests use a 10-second timeout.
|
|
49
51
|
|
|
50
52
|
## Disable web tools
|
|
51
53
|
|
|
@@ -83,6 +85,10 @@ Arguments:
|
|
|
83
85
|
- `max_bytes`: default 16384, capped at 131072.
|
|
84
86
|
- `extract`: optional `auto`, `text`, or `markdown`.
|
|
85
87
|
|
|
88
|
+
In `auto` mode (default), Kward detects HTML content and extracts readable text by stripping scripts, styles, navigation, and forms, preserving headings, paragraphs, lists, code blocks, and blockquotes. Non-HTML content is returned as cleaned text. Use `markdown` to format extracted headings and code blocks as Markdown, or `text` for plain text without formatting.
|
|
89
|
+
|
|
90
|
+
Fetches follow up to 5 redirects and use a 10-second HTTP timeout.
|
|
91
|
+
|
|
86
92
|
### `fetch_raw`
|
|
87
93
|
|
|
88
94
|
Reads a specific HTTP or HTTPS resource without readability extraction. Use it for JSON, YAML, XML, RSS, OpenAPI specs, and plain text.
|
|
@@ -92,3 +98,5 @@ Arguments:
|
|
|
92
98
|
- `url`
|
|
93
99
|
- `max_bytes`: default 16384, capped at 131072.
|
|
94
100
|
- `accept`: optional HTTP `Accept` header.
|
|
101
|
+
|
|
102
|
+
Fetches follow up to 5 redirects and use a 10-second HTTP timeout.
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# Workspace tools
|
|
2
|
+
|
|
3
|
+
Workspace tools let Kward inspect and change the local project. They are the tools behind prompts such as:
|
|
4
|
+
|
|
5
|
+
```text
|
|
6
|
+
Find where configuration is loaded.
|
|
7
|
+
Add a focused test for this behavior.
|
|
8
|
+
Run the related test file.
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Kward normally chooses these tools itself. You do not need to know their exact names to use them, but understanding the boundaries helps explain why Kward sometimes reads before editing or asks before running broad checks.
|
|
12
|
+
|
|
13
|
+
## Guardrails
|
|
14
|
+
|
|
15
|
+
Workspace tools use the active workspace as their boundary. File paths are workspace-relative by default, and file tools are guarded so Kward does not edit arbitrary unread files. Guardrails can be disabled with the `tools.workspace_guardrails` setting — see [Configuration](configuration.md). When disabled, file tools can access paths outside the workspace, but shell commands are unaffected since they already run as your OS user.
|
|
16
|
+
|
|
17
|
+
Important behavior:
|
|
18
|
+
|
|
19
|
+
- Existing files must be read in the current conversation before `write_file` or `edit_file` can change them.
|
|
20
|
+
- Reads are bounded to avoid pulling very large files into context by accident. Files larger than 256 KB cannot be read or edited. Read output is capped at 50 KB or 2,000 lines, whichever comes first.
|
|
21
|
+
- Edits use exact text replacement, so accidental partial or fuzzy changes fail instead of guessing.
|
|
22
|
+
- Shell commands run as your operating-system user from the workspace. They are powerful and should be treated like commands you run yourself. Command output is capped at 128 KB.
|
|
23
|
+
|
|
24
|
+
## Reading the workspace
|
|
25
|
+
|
|
26
|
+
### `list_directory`
|
|
27
|
+
|
|
28
|
+
Lists entries in a workspace-relative directory. Kward uses it to discover project structure before reading specific files.
|
|
29
|
+
|
|
30
|
+
Arguments:
|
|
31
|
+
|
|
32
|
+
- `path`: workspace-relative directory.
|
|
33
|
+
|
|
34
|
+
### `read_file`
|
|
35
|
+
|
|
36
|
+
Reads a workspace text file. Output is capped, and Kward can continue with line offsets when it needs more detail. The tool also supports explicit context modes so Kward can start cheap and widen only when needed.
|
|
37
|
+
|
|
38
|
+
Arguments:
|
|
39
|
+
|
|
40
|
+
- `path`: workspace-relative file path.
|
|
41
|
+
- `offset`: optional 1-indexed start line.
|
|
42
|
+
- `limit`: optional maximum number of lines.
|
|
43
|
+
- `mode`: optional context mode:
|
|
44
|
+
- `preview`: read a short preview slice, defaulting to 120 lines when `limit` is omitted.
|
|
45
|
+
- `outline`: return only the source declaration outline.
|
|
46
|
+
- `range`: read the requested `offset`/`limit` slice.
|
|
47
|
+
- `full`: read from `offset` until Kward's read caps stop the response.
|
|
48
|
+
- `max_bytes`: optional per-call byte budget, capped by Kward's workspace read limit.
|
|
49
|
+
|
|
50
|
+
A successful read marks the resolved file path as read for the conversation, allowing later edits to that file.
|
|
51
|
+
|
|
52
|
+
When called without `offset`, `limit`, or `mode` on a file that exceeds 2,000 lines or 50 KB, Kward returns a structure outline (classes, modules, methods) plus the first 120 lines instead of truncating blindly. This helps identify relevant entry points before requesting specific line ranges.
|
|
53
|
+
|
|
54
|
+
Binary files (detected by null bytes) return an error instead of content.
|
|
55
|
+
|
|
56
|
+
### `context_budget_stats`
|
|
57
|
+
|
|
58
|
+
Returns approximate context-budget savings for the current active conversation since it was opened in this process. The report compares each raw tool result size with the model-facing result after compaction or duplicate replacement, includes per-tool totals, and estimates saved tokens using roughly four bytes per token.
|
|
59
|
+
|
|
60
|
+
Arguments: none.
|
|
61
|
+
|
|
62
|
+
These numbers are intentionally approximate runtime stats. They are useful for seeing whether Kward's budgeting is helping the current conversation, not for billing, and they are not reconstructed when a saved session is resumed.
|
|
63
|
+
|
|
64
|
+
### `context_for_task`
|
|
65
|
+
|
|
66
|
+
Builds a compact, task-shaped context bundle from likely workspace files. It ranks files by task terms, includes source outlines, and adds short matching excerpts while respecting an approximate byte budget. This is intentionally lightweight: it does not maintain a persistent index or semantic graph.
|
|
67
|
+
|
|
68
|
+
Arguments:
|
|
69
|
+
|
|
70
|
+
- `task`: required task or question to gather context for.
|
|
71
|
+
- `paths`: optional files or directories to focus. Defaults to the workspace root.
|
|
72
|
+
- `budget`: optional approximate byte budget, default 4,000 and capped at 20,000.
|
|
73
|
+
|
|
74
|
+
Use this when Kward needs orientation for a bug, review, implementation, or explanation before deciding which exact file ranges to read.
|
|
75
|
+
|
|
76
|
+
### `summarize_file_structure`
|
|
77
|
+
|
|
78
|
+
Returns a compact outline of recognizable declarations in a source file, including line ranges and declaration kind where Kward can infer them. Kward uses it when a file may be too large to read fully at first.
|
|
79
|
+
|
|
80
|
+
Arguments:
|
|
81
|
+
|
|
82
|
+
- `path`: workspace-relative source file path.
|
|
83
|
+
|
|
84
|
+
This tool saves tokens by letting Kward identify relevant entry points before requesting exact line ranges with `read_file`. The outline is capped at 80 entries and recognizes common Ruby, JavaScript/TypeScript, Go, Rust, Java, and C#-style declarations with lightweight pattern matching rather than a full parser. Binary files (detected by null bytes) return an error instead of content.
|
|
85
|
+
|
|
86
|
+
## Changing files
|
|
87
|
+
|
|
88
|
+
### `write_file`
|
|
89
|
+
|
|
90
|
+
Writes complete file content. Existing files must be read first. New files can be created when the path is inside the workspace.
|
|
91
|
+
|
|
92
|
+
Arguments:
|
|
93
|
+
|
|
94
|
+
- `path`: workspace-relative file path.
|
|
95
|
+
- `content`: complete file content.
|
|
96
|
+
|
|
97
|
+
Use full writes when replacing generated content or creating a new file. For small edits to existing files, Kward should usually prefer `edit_file`.
|
|
98
|
+
|
|
99
|
+
The result includes a unified diff of the changes, capped at 8 KB with a summary of additions and deletions when truncated.
|
|
100
|
+
|
|
101
|
+
### `edit_file`
|
|
102
|
+
|
|
103
|
+
Applies one or more exact replacements to a file that has already been read.
|
|
104
|
+
|
|
105
|
+
Arguments:
|
|
106
|
+
|
|
107
|
+
- `path`: workspace-relative file path.
|
|
108
|
+
- `edits`: array of replacements:
|
|
109
|
+
- `old_text`: unique exact text to replace.
|
|
110
|
+
- `new_text`: replacement text.
|
|
111
|
+
|
|
112
|
+
Each `old_text` must match exactly once, and replacements must not overlap. This keeps edits deterministic and avoids broad fuzzy rewriting. Empty `old_text`, multiple matches, and no-op edits (where the result is identical) are all rejected with an error.
|
|
113
|
+
|
|
114
|
+
The result includes a unified diff of the changes, capped at 8 KB with a summary of additions and deletions when truncated.
|
|
115
|
+
|
|
116
|
+
## Running commands
|
|
117
|
+
|
|
118
|
+
### `run_shell_command`
|
|
119
|
+
|
|
120
|
+
Runs a shell command from the workspace root.
|
|
121
|
+
|
|
122
|
+
Arguments:
|
|
123
|
+
|
|
124
|
+
- `command`: command to run.
|
|
125
|
+
- `timeout_seconds`: optional timeout, default 30 seconds.
|
|
126
|
+
|
|
127
|
+
Kward uses shell commands for tests, linters, build checks, and simple repository inspection. Command output is bounded at 128 KB and may be compacted before it is sent back into model context, while the original output remains available in the session record.
|
|
128
|
+
|
|
129
|
+
The output format is `Exit status: N` followed by `STDOUT:` and `STDERR:` sections. On timeout, Kward sends SIGTERM then SIGKILL after 0.2 seconds and returns a timeout error. Commands support cooperative cancellation when the session is cancelled.
|
|
130
|
+
|
|
131
|
+
## Token behavior
|
|
132
|
+
|
|
133
|
+
Workspace tools are intentionally incremental:
|
|
134
|
+
|
|
135
|
+
1. list directories to find likely files,
|
|
136
|
+
2. use `read_file` with `mode: "outline"` or `summarize_file_structure` before reading everything,
|
|
137
|
+
3. read focused line ranges with `mode: "range"`, `offset`, `limit`, and optional `max_bytes`,
|
|
138
|
+
4. widen to `mode: "full"` only when focused context is insufficient,
|
|
139
|
+
5. make exact edits,
|
|
140
|
+
6. run focused verification commands.
|
|
141
|
+
|
|
142
|
+
This keeps the model's context window focused on relevant evidence instead of flooding it with entire repositories or long command output.
|
|
143
|
+
|
|
144
|
+
For details on how tool outputs are compacted, deduplicated, and retrieved, see [Agent tools](agent-tools.md).
|