kward 0.66.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 (93) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +9 -0
  3. data/CHANGELOG.md +12 -0
  4. data/Gemfile +8 -0
  5. data/Gemfile.lock +90 -0
  6. data/LICENSE +21 -0
  7. data/README.md +101 -0
  8. data/Rakefile +20 -0
  9. data/doc/authentication.md +105 -0
  10. data/doc/code-search.md +56 -0
  11. data/doc/configuration.md +310 -0
  12. data/doc/extensibility.md +186 -0
  13. data/doc/getting-started.md +127 -0
  14. data/doc/memory.md +192 -0
  15. data/doc/plugins.md +223 -0
  16. data/doc/releasing.md +36 -0
  17. data/doc/rpc.md +635 -0
  18. data/doc/usage.md +179 -0
  19. data/doc/web-search.md +28 -0
  20. data/exe/kward +5 -0
  21. data/kward.gemspec +33 -0
  22. data/lib/kward/agent.rb +234 -0
  23. data/lib/kward/ansi.rb +276 -0
  24. data/lib/kward/auth/file.rb +11 -0
  25. data/lib/kward/auth/github_oauth.rb +222 -0
  26. data/lib/kward/auth/openai_oauth.rb +323 -0
  27. data/lib/kward/auth/openrouter_api_key.rb +40 -0
  28. data/lib/kward/cancellation.rb +54 -0
  29. data/lib/kward/cli.rb +2122 -0
  30. data/lib/kward/clipboard.rb +84 -0
  31. data/lib/kward/compactor.rb +998 -0
  32. data/lib/kward/config_files.rb +564 -0
  33. data/lib/kward/conversation.rb +148 -0
  34. data/lib/kward/events.rb +13 -0
  35. data/lib/kward/export_path.rb +28 -0
  36. data/lib/kward/image_attachments.rb +331 -0
  37. data/lib/kward/markdown_transcript.rb +72 -0
  38. data/lib/kward/memory/manager.rb +652 -0
  39. data/lib/kward/message_access.rb +42 -0
  40. data/lib/kward/model/chat_invocation.rb +23 -0
  41. data/lib/kward/model/client.rb +875 -0
  42. data/lib/kward/model/context_overflow.rb +55 -0
  43. data/lib/kward/model/context_usage.rb +104 -0
  44. data/lib/kward/model/model_info.rb +188 -0
  45. data/lib/kward/model/retry_message.rb +11 -0
  46. data/lib/kward/model/stream_parser.rb +205 -0
  47. data/lib/kward/pan/index.html.erb +143 -0
  48. data/lib/kward/pan/server.rb +397 -0
  49. data/lib/kward/plugin_registry.rb +327 -0
  50. data/lib/kward/private_file.rb +18 -0
  51. data/lib/kward/prompt_interface.rb +2437 -0
  52. data/lib/kward/prompts/commands.rb +50 -0
  53. data/lib/kward/prompts/templates.rb +60 -0
  54. data/lib/kward/prompts.rb +58 -0
  55. data/lib/kward/resources/avatar_kward_logo.rb +48 -0
  56. data/lib/kward/resources/pixel_logo.rb +230 -0
  57. data/lib/kward/rpc/auth_manager.rb +265 -0
  58. data/lib/kward/rpc/config_manager.rb +58 -0
  59. data/lib/kward/rpc/prompt_bridge.rb +104 -0
  60. data/lib/kward/rpc/redactor.rb +47 -0
  61. data/lib/kward/rpc/server.rb +639 -0
  62. data/lib/kward/rpc/session_manager.rb +1122 -0
  63. data/lib/kward/rpc/tool_event_normalizer.rb +68 -0
  64. data/lib/kward/rpc/tool_metadata.rb +80 -0
  65. data/lib/kward/rpc/transcript_normalizer.rb +307 -0
  66. data/lib/kward/rpc/transport.rb +58 -0
  67. data/lib/kward/session_diff.rb +125 -0
  68. data/lib/kward/session_store.rb +493 -0
  69. data/lib/kward/skills/registry.rb +76 -0
  70. data/lib/kward/starter_pack_installer.rb +110 -0
  71. data/lib/kward/steering.rb +56 -0
  72. data/lib/kward/telemetry/logger.rb +195 -0
  73. data/lib/kward/telemetry/stats.rb +466 -0
  74. data/lib/kward/tools/ask_user_question.rb +107 -0
  75. data/lib/kward/tools/base.rb +45 -0
  76. data/lib/kward/tools/code_search.rb +65 -0
  77. data/lib/kward/tools/edit_file.rb +41 -0
  78. data/lib/kward/tools/list_directory.rb +21 -0
  79. data/lib/kward/tools/read_file.rb +30 -0
  80. data/lib/kward/tools/read_skill.rb +27 -0
  81. data/lib/kward/tools/registry.rb +117 -0
  82. data/lib/kward/tools/run_shell_command.rb +28 -0
  83. data/lib/kward/tools/search/code.rb +445 -0
  84. data/lib/kward/tools/search/web.rb +747 -0
  85. data/lib/kward/tools/tool_call.rb +87 -0
  86. data/lib/kward/tools/web_search.rb +48 -0
  87. data/lib/kward/tools/write_file.rb +29 -0
  88. data/lib/kward/transcript_export.rb +40 -0
  89. data/lib/kward/version.rb +4 -0
  90. data/lib/kward/workspace.rb +377 -0
  91. data/lib/kward.rb +6 -0
  92. data/lib/main.rb +3 -0
  93. metadata +232 -0
@@ -0,0 +1,310 @@
1
+ # Configuration
2
+
3
+ Kward reads user configuration from `~/.kward/config.json` by default. Most users do not need to edit this file by hand at first: use `/login`, `/model`, `/reasoning`, and `/settings` from inside Kward when possible.
4
+
5
+ On first start, if the file does not exist, Kward creates a starter config with an active Kward persona, explicit disabled memory settings, and the default composer busy-help setting so you can inspect and edit them. Provider-specific model defaults are added only when you choose a provider/model. If `KWARD_CONFIG_PATH` is set, Kward uses that file instead and treats that file's directory as the config directory for prompts, skills, memory, logs, and caches.
6
+
7
+ Small examples:
8
+
9
+ ```json
10
+ {
11
+ "provider": "openrouter",
12
+ "openrouter_model": "openai/gpt-5.5"
13
+ }
14
+ ```
15
+
16
+ ```json
17
+ {
18
+ "memory": {
19
+ "enabled": true
20
+ }
21
+ }
22
+ ```
23
+
24
+ ## Config directory
25
+
26
+ By default, Kward stores user data under `~/.kward`:
27
+
28
+ ```text
29
+ ~/.kward/config.json
30
+ ~/.kward/auth.json
31
+ ~/.kward/github_auth.json
32
+ ~/.kward/sessions/
33
+ ~/.kward/memory/
34
+ ~/.kward/logs/
35
+ ~/.kward/cache/
36
+ ```
37
+
38
+ When `KWARD_CONFIG_PATH=/path/to/config.json` is set, most config-related files live beside that file instead. User plugins are the exception: they are loaded only from `~/.kward/plugins`.
39
+
40
+ ## Provider and model settings
41
+
42
+ Set `provider` to choose the active backend:
43
+
44
+ ```json
45
+ {
46
+ "provider": "codex"
47
+ }
48
+ ```
49
+
50
+ Supported values are:
51
+
52
+ - `codex` for the OpenAI/ChatGPT Codex backend.
53
+ - `openrouter` for OpenRouter.
54
+ - `copilot` for experimental Copilot provider support.
55
+
56
+ Model settings:
57
+
58
+ ```json
59
+ {
60
+ "model": "gpt-5.5",
61
+ "openai_model": "gpt-5.5",
62
+ "openrouter_model": "openai/gpt-5.5",
63
+ "copilot_model": "gpt-5-mini",
64
+ "reasoning_effort": "medium",
65
+ "openai_reasoning_effort": "medium",
66
+ "openrouter_reasoning_effort": "medium",
67
+ "copilot_reasoning_effort": "medium",
68
+ "thinking_level": "medium"
69
+ }
70
+ ```
71
+
72
+ `model` is a generic setting for the active provider. Provider-specific values such as `openai_model`, `openrouter_model`, and `copilot_model` take precedence for their provider. `reasoning_effort` and `thinking_level` are generic reasoning settings. `openai_reasoning_effort`, `openrouter_reasoning_effort`, and `copilot_reasoning_effort` are provider-specific forms.
73
+
74
+ Defaults:
75
+
76
+ - OpenAI/Codex: `gpt-5.5`
77
+ - OpenRouter: `openai/gpt-5.5`
78
+ - Copilot: `gpt-5-mini`
79
+ - Reasoning effort: `medium`
80
+
81
+ The interactive `/model` picker prefers OpenRouter models available to the configured API key when Kward can fetch them. `/openrouter/catalog` and RPC `openrouter/catalog` list the full OpenRouter catalog separately.
82
+
83
+ ## Environment overrides
84
+
85
+ Use environment variables for one-off runs or local secrets that you do not want in config.
86
+
87
+ Provider and model:
88
+
89
+ - `KWARD_PROVIDER`
90
+ - `OPENAI_MODEL`
91
+ - `OPENAI_REASONING_EFFORT`
92
+ - `OPENROUTER_MODEL`
93
+ - `OPENROUTER_REASONING_EFFORT`
94
+ - `COPILOT_MODEL`
95
+ - `COPILOT_REASONING_EFFORT`
96
+
97
+ Credentials:
98
+
99
+ - `OPENAI_ACCESS_TOKEN`
100
+ - `OPENROUTER_API_KEY`
101
+ - `COPILOT_GITHUB_TOKEN`
102
+ - `GITHUB_TOKEN` or `GH_TOKEN` for authenticated GitHub API requests in `code_search`
103
+
104
+ Web search:
105
+
106
+ - `EXA_API_KEY`
107
+ - `PERPLEXITY_API_KEY`
108
+ - `GEMINI_API_KEY`
109
+
110
+ Color and logging environment variables are covered below.
111
+
112
+ ## Authentication settings
113
+
114
+ The friendliest way to configure credentials is `/login` inside Kward, or `kward login` from your shell. See [Authentication](authentication.md) for the full provider flow.
115
+
116
+ Credential settings can also live in config:
117
+
118
+ ```json
119
+ {
120
+ "openai_oauth_client_id": "your-client-id",
121
+ "openrouter_api_key": "sk-or-v1-..."
122
+ }
123
+ ```
124
+
125
+ Use environment variables for temporary or local-only secrets when possible. If both OpenAI and OpenRouter credentials are available, OpenAI OAuth is used by default unless `provider` or `KWARD_PROVIDER` selects another backend.
126
+
127
+ ## Overlay settings
128
+
129
+ Overlay settings control terminal picker/card layout:
130
+
131
+ ```json
132
+ {
133
+ "overlay": {
134
+ "alignment": "center",
135
+ "width": "maximum"
136
+ }
137
+ }
138
+ ```
139
+
140
+ `alignment` can be `left`, `center`, or `right`. `width` can be `maximum` to match the composer width or `capped` for a compact card.
141
+
142
+ You can change these interactively with `/settings`.
143
+
144
+ ## Composer settings
145
+
146
+ The busy composer shows a short Ctrl+C cancellation hint by default. To hide it:
147
+
148
+ ```json
149
+ {
150
+ "composer": {
151
+ "busy_help": false
152
+ }
153
+ }
154
+ ```
155
+
156
+ This only hides the hint text; Ctrl+C still stops the current running response.
157
+
158
+ ## Memory
159
+
160
+ Memory is off by default. Enabling it writes:
161
+
162
+ ```json
163
+ {
164
+ "memory": {
165
+ "enabled": true
166
+ }
167
+ }
168
+ ```
169
+
170
+ Memory auto-summary can also be enabled:
171
+
172
+ ```json
173
+ {
174
+ "memory": {
175
+ "enabled": true,
176
+ "auto_summary": true
177
+ }
178
+ }
179
+ ```
180
+
181
+ Memory files live under `<config-dir>/memory`, usually `~/.kward/memory`. See [Memory](memory.md).
182
+
183
+ ## Compaction
184
+
185
+ Auto-compaction is enabled by default when Kward can determine the active context window. You can tune or disable it:
186
+
187
+ ```json
188
+ {
189
+ "compaction": {
190
+ "enabled": true,
191
+ "reserve_tokens": 16384,
192
+ "keep_recent_tokens": 20000
193
+ }
194
+ }
195
+ ```
196
+
197
+ Manual `/compact [instructions]` works even when auto-compaction is disabled.
198
+
199
+ ## Pan mode
200
+
201
+ `--pan-mode` starts a LAN-reachable web UI and requires HTTP Basic Auth. Configure credentials before starting it:
202
+
203
+ ```json
204
+ {
205
+ "pan_mode": {
206
+ "host": "0.0.0.0",
207
+ "port": 8765,
208
+ "username": "kward",
209
+ "password": "choose-a-private-password"
210
+ }
211
+ }
212
+ ```
213
+
214
+ `host` defaults to `0.0.0.0` and `port` defaults to `8765`. Kward fails to start pan mode unless `username` and `password` are configured.
215
+
216
+ These credentials are stored in plaintext config. Use a private, user-specific password and do not share the config file. Pan mode exposes the agent's file, shell, and web tools to anyone on the LAN who has the credentials, so use it only on trusted networks.
217
+
218
+ ## Web search
219
+
220
+ Web search works without an API key through Exa's public MCP endpoint and is advertised to the model by default. To hide the tool:
221
+
222
+ ```json
223
+ {
224
+ "web_search": {
225
+ "enabled": false
226
+ }
227
+ }
228
+ ```
229
+
230
+ For higher limits or alternate providers, add user-specific keys. Model-backed auto fallback to Perplexity/Gemini stays off unless `allow_model_providers` is true; direct provider requests still work when the matching key is configured.
231
+
232
+ ```json
233
+ {
234
+ "web_search": {
235
+ "enabled": true,
236
+ "provider": "auto",
237
+ "allow_model_providers": false,
238
+ "exa_api_key": "exa-...",
239
+ "perplexity_api_key": "pplx-...",
240
+ "gemini_api_key": "AIza...",
241
+ "gemini_model": "gemini-2.5-flash",
242
+ "perplexity_model": "sonar"
243
+ }
244
+ }
245
+ ```
246
+
247
+ Do not put shared or published API keys in this file.
248
+
249
+ ## Logging and stats
250
+
251
+ Local telemetry logs are off by default. Enable logging with the master flag and each category you want:
252
+
253
+ ```json
254
+ {
255
+ "logging": {
256
+ "enabled": true,
257
+ "tokens": true,
258
+ "performance": true,
259
+ "tools": true,
260
+ "errors": true
261
+ }
262
+ }
263
+ ```
264
+
265
+ Environment variables override config for a single run:
266
+
267
+ - `KWARD_LOGGING`
268
+ - `KWARD_LOGGING_TOKENS`
269
+ - `KWARD_LOGGING_PERFORMANCE`
270
+ - `KWARD_LOGGING_TOOLS`
271
+ - `KWARD_LOGGING_ERRORS`
272
+
273
+ Values `1`, `true`, `yes`, and `on` enable a flag. Values `0`, `false`, `no`, and `off` disable it.
274
+
275
+ Logs are JSON Lines files in `<config-dir>/logs`, usually `~/.kward/logs`. Files rotate after 10 MB using numbered suffixes, and Kward does not delete old rotated logs.
276
+
277
+ Logged data is redacted metadata only. Kward does not intentionally log prompts, assistant text, tool arguments, tool outputs, file contents, shell command text, API keys, or OAuth tokens. Logged fields can include provider/model names, token counts, byte counts, durations, retry attempts, tool names, statuses, and redacted error messages.
278
+
279
+ Use `/stats [range]` in interactive mode to summarize enabled telemetry categories. The range defaults to `1 week` and accepts values such as `5 hours`, `10 minutes`, `2 days`, or `1 year`.
280
+
281
+ Export token usage as CSV with:
282
+
283
+ ```bash
284
+ kward stats tokens [range] [--bucket second|minute|hour|day|week|month|year] [--output path]
285
+ ```
286
+
287
+ Example:
288
+
289
+ ```bash
290
+ kward stats tokens 5 hours --bucket hour --output token-usage.csv
291
+ ```
292
+
293
+ ## Color output
294
+
295
+ ANSI colors are enabled automatically on TTY output.
296
+
297
+ Disable colors:
298
+
299
+ ```bash
300
+ NO_COLOR=1 kward
301
+ CLICOLOR=0 kward
302
+ KWARD_COLOR=never kward
303
+ ```
304
+
305
+ Force colors:
306
+
307
+ ```bash
308
+ KWARD_COLOR=always kward
309
+ FORCE_COLOR=1 kward
310
+ ```
@@ -0,0 +1,186 @@
1
+ # Extensibility
2
+
3
+ Kward can be customized at several levels:
4
+
5
+ - `AGENTS.md` for coding guidance and repository rules.
6
+ - Prompt templates for reusable slash-command prompts.
7
+ - Skills for reusable agent instructions the model can load on demand.
8
+ - Personas for assistant personality and communication style.
9
+ - Plugins for trusted Ruby extensions that add commands, footer UI, prompt context, transcript-event observers, and RPC-visible behavior.
10
+
11
+ Prompts, skills, personas, and config-directory `AGENTS.md` live beside the config file. By default this is `~/.kward`; if `KWARD_CONFIG_PATH` is set, Kward uses that file's directory instead.
12
+
13
+ Plugins are different: user plugins are loaded only from `~/.kward/plugins`, regardless of `KWARD_CONFIG_PATH` or the current project directory. See the dedicated [Plugins guide](plugins.md).
14
+
15
+ ## Which extension point should I use?
16
+
17
+ - Use `AGENTS.md` when you want Kward to follow coding rules, project conventions, or review expectations.
18
+ - Use prompt templates when you want reusable slash commands such as `/plan <task>` or `/review <diff>`.
19
+ - Use skills when you want reusable instructions that Kward can load only when a task needs them.
20
+ - Use personas when you want to change tone, role, or communication style.
21
+ - Use plugins when you need Ruby code to run locally, add commands, observe transcript events, or integrate with another tool.
22
+
23
+ The optional starter pack installs a useful base `AGENTS.md` and prompt templates. You can install it with:
24
+
25
+ ```bash
26
+ kward --install-starter-pack
27
+ ```
28
+
29
+ ## Agent instructions
30
+
31
+ Kward separates repository guidance from workspace-specific agent personality.
32
+
33
+ - Config-directory `AGENTS.md`: global coding guidance appended to Kward's built-in system instructions when present.
34
+ - Workspace `AGENTS.md`: repository guidance loaded from the active workspace root when present.
35
+
36
+ Use `AGENTS.md` for engineering instructions such as coding rules, project conventions, testing requirements, review expectations, and workflow guidance. Avoid putting personality, roleplay, or communication style there; configure those as personas instead.
37
+
38
+ Workspace `AGENTS.md` is injected once when a conversation starts. Kward refreshes it only when the file changes or when the agent edits the workspace `AGENTS.md`. Config-directory and workspace `AGENTS.md` files are skipped with a warning if they exceed 32 KiB, because they are injected into every model request.
39
+
40
+ ## Prompt templates
41
+
42
+ Prompt templates create user-invocable slash commands for reusable prompts.
43
+
44
+ Create a template at:
45
+
46
+ ```text
47
+ <config-dir>/prompts/<command>.md
48
+ ```
49
+
50
+ For example, `prompts/plan.md` becomes `/plan` in interactive mode. Templates support `$ARGUMENTS`, replaced by the text after the command.
51
+
52
+ Built-in commands such as `/exit`, `/new`, `/resume`, `/name`, `/clone`, `/export`, `/redraw`, and `/status` are reserved.
53
+
54
+ Example prompt template:
55
+
56
+ ```markdown
57
+ ---
58
+ description: Create an implementation plan.
59
+ argument-hint: <task>
60
+ ---
61
+
62
+ Plan this implementation request:
63
+
64
+ $ARGUMENTS
65
+ ```
66
+
67
+ ## Skills
68
+
69
+ Skills are reusable instruction packs the assistant can load when a task matches their description. They are useful when an instruction is too specific to include in every conversation, but important enough to keep around.
70
+
71
+ Create a skill at:
72
+
73
+ ```text
74
+ <config-dir>/skills/<skill-name>/SKILL.md
75
+ ```
76
+
77
+ A skill is listed in the system instructions by its frontmatter `name` and `description`. The assistant can then call `read_skill` to load `SKILL.md` or related files inside that skill folder.
78
+
79
+ Example skill:
80
+
81
+ ```markdown
82
+ ---
83
+ name: planner
84
+ description: Helps plan implementation work.
85
+ ---
86
+
87
+ # Planner
88
+
89
+ Use this when planning a code change.
90
+ ```
91
+
92
+ ## Personas
93
+
94
+ Personas configure personality, role, and communication style without modifying repository files. New configs include a single active `kward` character by default; edit or remove `personas.default` to change the first-run experience. `personas.crew` is still accepted as an alias for `personas.characters`.
95
+
96
+ A small persona config looks like this:
97
+
98
+ ```json
99
+ {
100
+ "personas": {
101
+ "characters": [
102
+ {
103
+ "key": "kward",
104
+ "label": "Kward",
105
+ "instruction": "Be concise, practical, and friendly. Prefer small, safe changes."
106
+ }
107
+ ],
108
+ "default": "kward"
109
+ }
110
+ }
111
+ ```
112
+
113
+ You can also target personas by workspace, model, reasoning effort, time of day, or weekday:
114
+
115
+ ```json
116
+ {
117
+ "personas": {
118
+ "characters": [
119
+ {
120
+ "key": "reviewer",
121
+ "label": "Reviewer",
122
+ "instruction": "Be skeptical and focus on correctness, tests, and maintainability."
123
+ },
124
+ {
125
+ "key": "coach",
126
+ "label": "Coach",
127
+ "instruction": "Explain tradeoffs and teach as you go."
128
+ }
129
+ ],
130
+ "default": "reviewer",
131
+ "workspaces": {
132
+ "/Users/kwood/Repositories/github.com/kaiwood/tauren": "coach"
133
+ },
134
+ "models": {
135
+ "gpt-5.5": "reviewer"
136
+ },
137
+ "persona_modifiers": {
138
+ "reasoning": {
139
+ "high": "Think strategically before answering."
140
+ },
141
+ "suffix": "Act like it."
142
+ }
143
+ }
144
+ }
145
+ ```
146
+
147
+ Persona evaluation order is:
148
+
149
+ 1. `personas.default`
150
+ 2. Matching `personas.workspaces` entry, using normalized workspace paths
151
+ 3. Matching `personas.models` entry for the current model
152
+ 4. Matching `persona_modifiers.reasoning` entry for the current reasoning effort
153
+ 5. Matching `persona_modifiers.time_of_day` entry for local time: `morning` 05:00-10:59, `before_lunch` 11:00-11:59, `late_evening` 21:00-04:59
154
+ 6. Matching `persona_modifiers.weekday` entry for the local weekday
155
+ 7. `persona_modifiers.suffix`
156
+
157
+ Prompt assembly order is:
158
+
159
+ 1. Kward built-in base prompt
160
+ 2. Config-directory `AGENTS.md`
161
+ 3. Evaluated persona text
162
+ 4. Plugin prompt context
163
+ 5. Skills listing
164
+ 6. Workspace `AGENTS.md`
165
+
166
+ If no persona entries match, Kward simply omits that part. Conversation compaction uses a neutral prompt without workspace personality, so summaries stay continuation-focused and machine-oriented.
167
+
168
+ ## Plugins
169
+
170
+ Plugins are Kward's trusted Ruby extension layer. Use them when you need behavior rather than just instructions or reusable prompts.
171
+
172
+ Plugins can add:
173
+
174
+ - slash commands,
175
+ - one custom terminal footer,
176
+ - prompt context,
177
+ - live transcript-event observers,
178
+ - command behavior exposed to RPC clients.
179
+
180
+ Plugin files live in:
181
+
182
+ ```text
183
+ ~/.kward/plugins/*.rb
184
+ ```
185
+
186
+ See [Plugins](plugins.md) for the full plugin API, examples, and security model.
@@ -0,0 +1,127 @@
1
+ # Getting started
2
+
3
+ Kward is a Ruby CLI coding agent for local projects. It can answer questions, inspect files, propose and apply edits, run confirmed commands, search the web, and keep session history.
4
+
5
+ This page gets you to a first working chat. For day-to-day features after that, see [Usage](usage.md).
6
+
7
+ ## Requirements
8
+
9
+ - Ruby 3.2 or newer.
10
+ - Bundler when running from source.
11
+ - Credentials for at least one model provider. You can add them with `/login` inside Kward or with `kward login` from your shell.
12
+
13
+ ## Install
14
+
15
+ Kward is being prepared for a RubyGems release. Once published:
16
+
17
+ ```bash
18
+ gem install kward
19
+ ```
20
+
21
+ Optionally install the starter pack:
22
+
23
+ ```bash
24
+ kward --install-starter-pack
25
+ ```
26
+
27
+ The starter pack adds useful default prompts and a base `AGENTS.md` to your config directory. It is helpful for a first setup, but safe to skip if you want to write your own instructions. Existing files are not overwritten.
28
+
29
+ Until the gem is published, run Kward from a repository checkout:
30
+
31
+ ```bash
32
+ bundle install
33
+ ruby lib/main.rb --install-starter-pack # optional
34
+ ```
35
+
36
+ ## Start Kward and sign in
37
+
38
+ Start an interactive session:
39
+
40
+ ```bash
41
+ kward
42
+ ```
43
+
44
+ From source:
45
+
46
+ ```bash
47
+ ruby lib/main.rb
48
+ ```
49
+
50
+ When Kward needs credentials, sign in from inside the session:
51
+
52
+ ```text
53
+ /login
54
+ ```
55
+
56
+ You can also sign in from your shell before starting a chat:
57
+
58
+ ```bash
59
+ kward login
60
+ ```
61
+
62
+ From source:
63
+
64
+ ```bash
65
+ ruby lib/main.rb login
66
+ ```
67
+
68
+ For provider-specific login options, such as OpenRouter API keys or experimental Copilot support, see [Authentication](authentication.md).
69
+
70
+ ## Ask one question and exit
71
+
72
+ Pass a prompt as command-line text:
73
+
74
+ ```bash
75
+ kward "Explain this project"
76
+ ```
77
+
78
+ From source:
79
+
80
+ ```bash
81
+ ruby lib/main.rb "Explain this project"
82
+ ```
83
+
84
+ You can also pipe input:
85
+
86
+ ```bash
87
+ git diff | kward "Review this diff"
88
+ ```
89
+
90
+ One-shot prompts do not use Kward memory.
91
+
92
+ ## Useful first commands
93
+
94
+ Inside an interactive session:
95
+
96
+ ```text
97
+ /login sign in or save provider credentials
98
+ /status show current session and compaction status
99
+ /model choose the default model
100
+ /reasoning choose reasoning effort
101
+ /resume resume a saved session
102
+ /export notes.md export the current session as Markdown
103
+ /exit leave the session
104
+ ```
105
+
106
+ Kward saves interactive sessions under `~/.kward/sessions/`.
107
+
108
+ ## Safety basics
109
+
110
+ - Kward must read an existing file in the current conversation before it can edit or overwrite it.
111
+ - File writes and edits ask for confirmation first.
112
+ - Shell commands ask for confirmation before running.
113
+ - Tool reads are bounded so large files are not accidentally loaded into context.
114
+
115
+ ## Run tests
116
+
117
+ If you are developing Kward itself:
118
+
119
+ ```bash
120
+ bundle exec rake test
121
+ ```
122
+
123
+ Equivalent direct command:
124
+
125
+ ```bash
126
+ ruby -Itest -e 'Dir["test/**/test_*.rb"].sort.each { |file| require_relative file }'
127
+ ```