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/extensibility.md CHANGED
@@ -1,181 +1,125 @@
1
1
  # Extensibility
2
2
 
3
- Kward can be customized at several levels:
3
+ Kward can be customized without changing its source code. Use extensibility when you want Kward to follow your conventions, repeat common prompts, or add local behavior.
4
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.
5
+ Start simple. Most users only need `PRINCIPLES.md`, workspace `AGENTS.md`, and maybe a prompt template.
10
6
 
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.
7
+ ## Choose the right extension point
12
8
 
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).
9
+ | Need | Use |
10
+ | --- | --- |
11
+ | Global coding preferences | `~/.kward/PRINCIPLES.md` |
12
+ | Repository-specific rules | `<workspace>/AGENTS.md` |
13
+ | Reusable slash prompts | prompt templates |
14
+ | Task-specific reusable instructions | skills |
15
+ | Different tone or role | [personas](personas.md) |
16
+ | Local Ruby behavior or integrations | plugins |
14
17
 
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:
18
+ Install the starter pack for a useful starting point:
24
19
 
25
20
  ```bash
26
21
  kward init
27
22
  ```
28
23
 
29
- ## Agent instructions
24
+ ## Global instructions: `PRINCIPLES.md`
30
25
 
31
- Kward separates repository guidance from workspace-specific agent personality.
26
+ Use this for preferences you want in most projects:
32
27
 
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.
28
+ ```markdown
29
+ Prefer small, focused changes.
30
+ Add tests for new behavior.
31
+ Do not refactor unrelated code.
32
+ Explain risky assumptions before editing.
33
+ ```
35
34
 
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.
35
+ Default location:
37
36
 
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.
37
+ ```text
38
+ ~/.kward/PRINCIPLES.md
39
+ ```
39
40
 
40
- ## Prompt templates
41
+ If `KWARD_CONFIG_PATH` is set, `PRINCIPLES.md` lives beside that config file.
41
42
 
42
- Prompt templates create user-invocable slash commands for reusable prompts.
43
+ ## Project instructions: `AGENTS.md`
43
44
 
44
- Create a template at:
45
+ Put repository-specific rules in the workspace root:
45
46
 
46
47
  ```text
47
- <config-dir>/prompts/<command>.md
48
+ my-project/AGENTS.md
48
49
  ```
49
50
 
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:
51
+ Good examples:
55
52
 
56
53
  ```markdown
57
- ---
58
- description: Create an implementation plan.
59
- argument-hint: <task>
60
- ---
54
+ Run tests with `bundle exec rake test`.
55
+ Use Minitest, not RSpec.
56
+ Do not change generated files under `schema/`.
57
+ Update CHANGELOG.md for user-visible changes.
58
+ ```
61
59
 
62
- Plan this implementation request:
60
+ Use `AGENTS.md` for project facts and engineering rules. Do not put personality or roleplay instructions there; use [personas](personas.md) for tone.
63
61
 
64
- $ARGUMENTS
65
- ```
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.
66
63
 
67
- ## Skills
64
+ ## Prompt templates
68
65
 
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.
66
+ Use prompt templates when you repeatedly type the same kind of request.
70
67
 
71
- Create a skill at:
68
+ Create:
72
69
 
73
70
  ```text
74
- <config-dir>/skills/<skill-name>/SKILL.md
71
+ ~/.kward/prompts/review.md
75
72
  ```
76
73
 
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:
74
+ Example:
80
75
 
81
76
  ```markdown
82
77
  ---
83
- name: planner
84
- description: Helps plan implementation work.
78
+ description: Review a change for correctness.
79
+ argument-hint: <focus>
85
80
  ---
86
81
 
87
- # Planner
88
-
89
- Use this when planning a code change.
82
+ Review the current diff for correctness, tests, and maintainability.
83
+ Focus on: $ARGUMENTS
90
84
  ```
91
85
 
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
- ```
86
+ Then run inside Kward:
112
87
 
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
- }
88
+ ```text
89
+ /review auth edge cases
145
90
  ```
146
91
 
147
- Persona evaluation order is:
92
+ Prompt templates are best for reusable text. They do not run local code.
148
93
 
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`
94
+ ## Skills
156
95
 
157
- Prompt assembly order is:
96
+ Use skills for reusable instructions that should only be loaded for certain tasks.
158
97
 
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`
98
+ Create:
165
99
 
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.
100
+ ```text
101
+ ~/.kward/skills/testing/SKILL.md
102
+ ```
167
103
 
168
- ## Plugins
104
+ Example:
105
+
106
+ ```markdown
107
+ ---
108
+ name: testing
109
+ or description: Use when adding or changing tests.
110
+ ---
169
111
 
170
- Plugins are Kward's trusted Ruby extension layer. Use them when you need behavior rather than just instructions or reusable prompts.
112
+ Prefer focused tests near the changed behavior.
113
+ Do not weaken assertions to make tests pass.
114
+ ```
171
115
 
172
- Plugins can add:
116
+ Skills are listed to the model by name and description. Kward can load the full skill only when it is relevant.
173
117
 
174
- - slash commands,
175
- - one custom terminal footer,
176
- - prompt context,
177
- - live transcript-event observers,
178
- - command behavior exposed to RPC clients.
118
+ ## Plugins
119
+
120
+ Use plugins when text instructions are not enough and you need Ruby code to run locally.
121
+
122
+ Plugins can add slash commands, prompt context, footer UI, transcript observers, and RPC-visible commands.
179
123
 
180
124
  Plugin files live in:
181
125
 
@@ -183,4 +127,21 @@ Plugin files live in:
183
127
  ~/.kward/plugins/*.rb
184
128
  ```
185
129
 
186
- See [Plugins](plugins.md) for the full plugin API, examples, and security model.
130
+ Plugins are trusted local Ruby code. Install only plugins you trust. See [Plugins](plugins.md).
131
+
132
+ ## Prompt assembly order
133
+
134
+ When Kward builds instructions for a turn, it combines roughly:
135
+
136
+ 1. Kward's built-in operating instructions.
137
+ 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.
142
+
143
+ If behavior seems surprising, inspect the assembled instructions:
144
+
145
+ ```bash
146
+ kward sysprompt
147
+ ```
@@ -1,125 +1,123 @@
1
1
  # Getting started
2
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.
3
+ Use Kward when you want an agent in your terminal that can inspect the current project, explain code, edit files, run local commands, and keep an interactive session history.
4
4
 
5
- This page gets you to a first working chat. For day-to-day features after that, see [Usage](usage.md).
5
+ This page gets you from install to a first useful chat.
6
6
 
7
7
  ## Requirements
8
8
 
9
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.
10
+ - Credentials for one model provider. The easiest setup is `kward login` or `/login` inside Kward.
11
+ - Bundler only if you run Kward from a source checkout.
12
12
 
13
13
  ## Install
14
14
 
15
- Install Kward from RubyGems:
15
+ Install the gem:
16
16
 
17
17
  ```bash
18
18
  gem install kward
19
19
  ```
20
20
 
21
- Optionally install the starter pack:
21
+ Install the starter pack:
22
22
 
23
23
  ```bash
24
24
  kward init
25
25
  ```
26
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.
27
+ The starter pack adds default prompts and a base `PRINCIPLES.md` under `~/.kward`. It does not overwrite existing files.
28
28
 
29
- If you are working from a repository checkout:
29
+ If you are working from a checkout instead:
30
30
 
31
31
  ```bash
32
32
  bundle install
33
- ruby lib/main.rb init # optional
33
+ ruby lib/main.rb init
34
34
  ```
35
35
 
36
- ## Start Kward and sign in
36
+ ## Sign in
37
37
 
38
- Start an interactive session:
38
+ From your shell:
39
39
 
40
40
  ```bash
41
- kward
42
- ```
43
-
44
- From source:
45
-
46
- ```bash
47
- ruby lib/main.rb
41
+ kward login
48
42
  ```
49
43
 
50
- When Kward needs credentials, sign in from inside the session:
44
+ Or from inside an interactive session:
51
45
 
52
46
  ```text
53
47
  /login
54
48
  ```
55
49
 
56
- You can also sign in from your shell before starting a chat:
50
+ Kward supports OpenAI/ChatGPT, Anthropic Claude Pro/Max, OpenRouter, and experimental Copilot credentials. See [Authentication](authentication.md) when you need a specific provider.
57
51
 
58
- ```bash
59
- kward login
60
- ```
52
+ ## Start an interactive chat
61
53
 
62
- From source:
54
+ Run Kward from the project you want it to work on:
63
55
 
64
56
  ```bash
65
- ruby lib/main.rb login
57
+ cd ~/code/my-project
58
+ kward
66
59
  ```
67
60
 
68
- For provider-specific login options, such as OpenRouter API keys or experimental Copilot support, see [Authentication](authentication.md).
61
+ Ask something concrete:
69
62
 
70
- ## Ask one question and exit
63
+ ```text
64
+ Explain the structure of this project.
65
+ ```
71
66
 
72
- Pass a prompt as command-line text:
67
+ Then try a task that uses the workspace:
73
68
 
74
- ```bash
75
- kward "Explain this project"
69
+ ```text
70
+ Find where user authentication is implemented and summarize the flow.
76
71
  ```
77
72
 
78
- From source:
73
+ Kward can read files, suggest edits, apply changes, and run commands from the workspace. Existing files must be read in the current conversation before Kward can edit them.
74
+
75
+ ## Ask one question and exit
76
+
77
+ For quick tasks, pass the prompt directly:
79
78
 
80
79
  ```bash
81
- ruby lib/main.rb "Explain this project"
80
+ kward "Explain this project"
82
81
  ```
83
82
 
84
- You can also pipe input:
83
+ Review a diff:
85
84
 
86
85
  ```bash
87
- git diff | kward "Review this diff"
86
+ git diff | kward "Review this diff for bugs"
88
87
  ```
89
88
 
90
89
  One-shot prompts do not use Kward memory.
91
90
 
92
91
  ## Useful first commands
93
92
 
94
- Inside an interactive session:
93
+ Inside interactive Kward:
95
94
 
96
95
  ```text
97
96
  /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
97
+ /model choose a model
98
+ /status show session and context status
99
+ /resume resume a previous session
100
+ /export notes.md export the transcript
101
+ /compact summarize older context when a chat gets long
102
+ /exit leave Kward
104
103
  ```
105
104
 
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
- - Tool reads are bounded so large files are not accidentally loaded into context.
112
-
113
- ## Run tests
114
-
115
- If you are developing Kward itself:
105
+ ## Run from source
116
106
 
117
107
  ```bash
118
- bundle exec rake test
108
+ ruby lib/main.rb login
109
+ ruby lib/main.rb
110
+ ruby lib/main.rb "Explain this project"
119
111
  ```
120
112
 
121
- Equivalent direct command:
113
+ You can also run:
122
114
 
123
115
  ```bash
124
- ruby -Itest -e 'Dir["test/**/test_*.rb"].sort.each { |file| require_relative file }'
116
+ exe/kward
125
117
  ```
118
+
119
+ ## Next steps
120
+
121
+ - Read [Usage](usage.md) for day-to-day workflows.
122
+ - Read [Configuration](configuration.md) when you want to change providers, models, memory, or web search.
123
+ - Read [Extensibility](extensibility.md) when you want reusable prompts, skills, or project rules.