kward 0.70.0 → 0.71.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 (73) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/pages.yml +1 -1
  3. data/CHANGELOG.md +48 -2
  4. data/Gemfile +2 -0
  5. data/Gemfile.lock +90 -2
  6. data/README.md +30 -6
  7. data/Rakefile +96 -0
  8. data/doc/agent-tools.md +43 -0
  9. data/doc/api.md +92 -0
  10. data/doc/authentication.md +39 -25
  11. data/doc/configuration.md +1 -15
  12. data/doc/context-tools.md +70 -0
  13. data/doc/plugins.md +2 -2
  14. data/doc/releasing.md +14 -5
  15. data/doc/rpc.md +3 -11
  16. data/doc/session-management.md +220 -0
  17. data/doc/usage.md +7 -8
  18. data/doc/workspace-tools.md +105 -0
  19. data/lib/kward/cli/commands.rb +8 -0
  20. data/lib/kward/cli/openrouter_commands.rb +55 -0
  21. data/lib/kward/cli/prompt_interface.rb +80 -6
  22. data/lib/kward/cli/rendering.rb +11 -6
  23. data/lib/kward/cli/sessions.rb +260 -11
  24. data/lib/kward/cli/settings.rb +0 -30
  25. data/lib/kward/cli/slash_commands.rb +24 -6
  26. data/lib/kward/cli.rb +13 -0
  27. data/lib/kward/compactor.rb +4 -1
  28. data/lib/kward/config_files.rb +4 -6
  29. data/lib/kward/conversation.rb +49 -20
  30. data/lib/kward/model/client.rb +37 -50
  31. data/lib/kward/model/context_usage.rb +13 -6
  32. data/lib/kward/model/model_info.rb +92 -16
  33. data/lib/kward/model/payloads.rb +2 -0
  34. data/lib/kward/openrouter_model_cache.rb +120 -0
  35. data/lib/kward/plugin_registry.rb +47 -1
  36. data/lib/kward/prompt_interface/banner.rb +16 -51
  37. data/lib/kward/prompt_interface/composer_controller.rb +60 -87
  38. data/lib/kward/prompt_interface/composer_renderer.rb +7 -1
  39. data/lib/kward/prompt_interface/key_handler.rb +31 -10
  40. data/lib/kward/prompt_interface/layout.rb +2 -2
  41. data/lib/kward/prompt_interface/prompt_renderer.rb +32 -13
  42. data/lib/kward/prompt_interface/question_prompt.rb +34 -42
  43. data/lib/kward/prompt_interface/runtime_state.rb +6 -1
  44. data/lib/kward/prompt_interface/screen.rb +1 -0
  45. data/lib/kward/prompt_interface/selection_prompt.rb +513 -54
  46. data/lib/kward/prompt_interface/transcript_buffer.rb +7 -16
  47. data/lib/kward/prompt_interface/transcript_renderer.rb +3 -3
  48. data/lib/kward/prompt_interface.rb +22 -28
  49. data/lib/kward/prompts/commands.rb +2 -1
  50. data/lib/kward/prompts.rb +2 -2
  51. data/lib/kward/rpc/server.rb +3 -8
  52. data/lib/kward/rpc/session_manager.rb +17 -6
  53. data/lib/kward/session_store.rb +23 -4
  54. data/lib/kward/telemetry/logger.rb +5 -3
  55. data/lib/kward/tool_output_compactor.rb +127 -0
  56. data/lib/kward/tools/base.rb +8 -2
  57. data/lib/kward/tools/registry.rb +37 -6
  58. data/lib/kward/tools/retrieve_tool_output.rb +71 -0
  59. data/lib/kward/tools/search/web.rb +2 -2
  60. data/lib/kward/tools/summarize_file_structure.rb +29 -0
  61. data/lib/kward/tools/tool_call.rb +2 -0
  62. data/lib/kward/version.rb +1 -1
  63. data/lib/kward/workspace.rb +58 -2
  64. data/templates/default/fulldoc/html/css/kward.css +256 -7
  65. data/templates/default/fulldoc/html/full_list.erb +107 -0
  66. data/templates/default/fulldoc/html/js/kward.js +161 -2
  67. data/templates/default/fulldoc/html/setup.rb +8 -0
  68. data/templates/default/kward_navigation.rb +91 -0
  69. data/templates/default/layout/html/layout.erb +39 -8
  70. data/templates/default/layout/html/setup.rb +33 -38
  71. metadata +13 -3
  72. data/lib/kward/resources/avatar_kward_logo.rb +0 -50
  73. data/lib/kward/resources/pixel_logo.rb +0 -232
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 12e9e888bceffd64f87f36ea3aa79e4108901e92a193db7c86e588abef789f04
4
- data.tar.gz: 4b69dcc0fca28d026931ec809bba3f2b64ad12b37930df51454ad80003104ac0
3
+ metadata.gz: 2c53686afdfbf5de822759d70cb696e911cae8c5ffc7b5ce63e07306dc4ffaac
4
+ data.tar.gz: '086c43642ad0149e3986277b7424b55f2dc50689a0e876c72e6bb9fd48e4272b'
5
5
  SHA512:
6
- metadata.gz: d372a52d9eb15695e33f6723d060ea051a8cda166e3692c5b3f634a1d7ca5cd7b533dc8afc41f88f39228af095af049c8b767c3d9696e846fb99b58218fdae5f
7
- data.tar.gz: 7ff32c27130676339ab62bccbbc2777c5a382c8adf66f4d1fec525d4c12ecea0aa8d563814c331f409f8c030f0236cc3dd727405955c4bedcb96705c94d42aec
6
+ metadata.gz: 97ebbbf26feedc4dd46d53d7af8b900670edf861cb40f6103eff5ea8579d605517cab49751ea5fe46c4023fa7ba8ced367d31290b34af463fd0cc8f1a9a1087e
7
+ data.tar.gz: 424ac657d7efc70f2b87924914112c0910937deee7e4ec6521448ff4fe51967a58203de9693fb8989adea63fb23adef93668333c8bb5eb22963bff49e7420875
@@ -25,7 +25,7 @@ jobs:
25
25
  - name: Set up Ruby
26
26
  uses: ruby/setup-ruby@v1
27
27
  with:
28
- ruby-version: '3.2'
28
+ ruby-version: '3.3'
29
29
  bundler-cache: true
30
30
 
31
31
  - name: Build documentation
data/CHANGELOG.md CHANGED
@@ -4,15 +4,61 @@ All notable changes to Kward will be documented in this file.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
- ## [0.70.0] - 2026-06-18
7
+ ## [0.71.0] - 2026-06-21
8
+
9
+ ### Fixed
10
+
11
+ - Fixed generated YARD guide links so doc-to-doc Markdown links point at the generated `file.*.html` pages.
12
+ - Fixed web-tool results with BINARY/ASCII-8BIT response bodies so RPC tool events and TUI rendering receive UTF-8-safe content.
13
+
14
+ ### Changed
15
+
16
+ - Changed transcript rendering so assistant, reasoning, and tool output starts on the same line as its label.
17
+ - Changed the interactive startup screen to an info block.”
18
+ - Changed shell command output capture to allow larger raw output for Kward's own compactor, preserving stdout/stderr structure and test failure summaries before model-context trimming.
19
+ - Tightened the built-in system prompt wording to reduce repeated instruction tokens.
20
+ - Changed generated runtime system prompts to use a stable timestamp anchor so time-based persona modifiers do not churn provider cache prefixes each turn.
21
+ - Changed tool schema properties to be emitted in deterministic key order for more stable provider request payloads.
22
+ - Changed large source-file reads to return an outline plus a short preview before requiring offset/limit continuation.
23
+ - Changed large search and fetched-content tool results to preserve file, line, URL, and heading anchors during model-context compaction.
24
+ - Changed large tool results to be compacted before they enter model context while preserving full originals in session tool-execution records, reusing existing artifact ids for repeated outputs, avoiding storage for verbatim outputs, preserving short errors exactly, reverting automatically when compaction would not reduce context, and teaching conversation compaction to preserve tool artifact ids.
25
+ - Changed model context-window resolution to prefer cached OpenRouter metadata, infer matching provider models from that metadata when possible, and use conservative fallbacks for unknown selected models.
26
+ - Updated the authentication guide to describe model picker selection and OpenRouter model cache refresh/list commands.
27
+
28
+ ### Removed
29
+
30
+ - Removed the `banner.enabled` config setting and `/settings` toggle for hiding the interactive startup screen.
31
+ - Removed the generated table of contents and source-checkout launch snippet from the RPC protocol guide.
32
+
33
+ ### Added
34
+
35
+ - Added a Sessions guide covering saved sessions, cloning, forking, rewinding, tree navigation, compaction, and exports.
36
+ - Added Agent Tools documentation pages covering workspace tools, context tools, and token-saving tool-output behavior.
37
+ - Added an API reference overview page and API docs navigation dropdown for generated Ruby indexes and key namespaces.
38
+ - Added Turbolinks-style navigation to the generated documentation site for same-origin HTML links.
39
+ - Added a `docs:check` Rake task and HTMLProofer development dependency for checking generated documentation links, images, and scripts.
40
+ - Added a `docs:serve` Rake task and WEBrick development dependency for previewing the built YARD documentation site locally with automatic rebuilds.
41
+ - Added optional `compaction` telemetry logging for tool-output context savings.
42
+ - Added a `summarize_file_structure` tool for compact source-file outlines before reading full files.
43
+ - Added a `retrieve_tool_output` tool for inspecting original outputs that were compacted out of model context.
44
+ - Added `kward openrouter refresh` and `kward openrouter list` for caching key-scoped text-capable OpenRouter models in the Kward cache directory.
45
+ - Added `/fork` for creating a new session from an earlier prompt and pre-filling that prompt for editing.
46
+ - Added `f` in the `/sessions` picker to open the fork prompt selector for the selected session.
47
+ - Added `/rename <name>` for renaming the current interactive session.
48
+ - Added `r` in the `/sessions` picker to rename the selected session without closing the picker.
49
+ - Added `c` in the `/sessions` picker to clone the selected session and open the new clone, with a cloning spinner while it runs.
50
+ - Added `d d` in the `/sessions` picker to delete the selected session after an inline confirmation.
51
+
52
+ ## [0.70.0] - 2026-06-19
8
53
 
9
54
  ### Added
10
55
 
11
- - Added `z-ai/glm-5.2` to the static OpenRouter model choices.
12
56
  - Added `/rewind` for revisiting earlier user prompts and continuing from there as a branch, while `/tree` remains the advanced full session tree navigator.
13
57
 
14
58
  ### Changed
15
59
 
60
+ - Changed TUI selection search to start only after pressing `/`, hiding the composer cursor until search mode is active and supporting shell-style editing keys while searching.
61
+ - Changed the `/sessions` picker to show right-aligned relative timestamps like `/rewind`.
16
62
  - Changed TUI list navigation to keep long `/sessions` and `/tree` pickers centered while scrolling, and removed wrap-around at list edges.
17
63
  - Changed the saved session picker slash command to `/sessions`, with `/resume` kept as an alias.
18
64
 
data/Gemfile CHANGED
@@ -2,7 +2,9 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
+ gem "html-proofer"
5
6
  gem "minitest"
6
7
  gem "rake"
7
8
  gem "rdoc"
9
+ gem "webrick"
8
10
  gem "yard"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kward (0.69.1)
4
+ kward (0.71.0)
5
5
  base64
6
6
  nokogiri
7
7
  tiktoken_ruby
@@ -13,10 +13,50 @@ PATH
13
13
  GEM
14
14
  remote: https://rubygems.org/
15
15
  specs:
16
+ Ascii85 (2.0.1)
17
+ addressable (2.9.0)
18
+ public_suffix (>= 2.0.2, < 8.0)
19
+ afm (1.0.0)
20
+ async (2.39.0)
21
+ console (~> 1.29)
22
+ fiber-annotation
23
+ io-event (~> 1.11)
24
+ metrics (~> 0.12)
25
+ traces (~> 0.18)
16
26
  base64 (0.3.0)
27
+ benchmark (0.5.0)
28
+ bigdecimal (3.3.1)
29
+ console (1.36.0)
30
+ fiber-annotation
31
+ fiber-local (~> 1.1)
32
+ json
17
33
  date (3.5.1)
18
34
  drb (2.2.3)
19
35
  erb (6.0.4)
36
+ ethon (0.18.0)
37
+ ffi (>= 1.15.0)
38
+ logger
39
+ ffi (1.17.4-arm64-darwin)
40
+ ffi (1.17.4-x86_64-linux-gnu)
41
+ fiber-annotation (0.2.0)
42
+ fiber-local (1.1.0)
43
+ fiber-storage
44
+ fiber-storage (1.0.1)
45
+ hashery (2.1.2)
46
+ html-proofer (5.2.1)
47
+ addressable (~> 2.3)
48
+ async (~> 2.1)
49
+ benchmark (~> 0.5)
50
+ nokogiri (~> 1.13)
51
+ pdf-reader (~> 2.11)
52
+ rainbow (~> 3.0)
53
+ typhoeus (~> 1.3)
54
+ yell (~> 2.0)
55
+ zeitwerk (~> 2.5)
56
+ io-event (1.16.2)
57
+ json (2.19.9)
58
+ logger (1.7.0)
59
+ metrics (0.15.0)
20
60
  minitest (6.0.6)
21
61
  drb (~> 2.0)
22
62
  prism (~> 1.5)
@@ -26,20 +66,32 @@ GEM
26
66
  racc (~> 1.4)
27
67
  pastel (0.8.0)
28
68
  tty-color (~> 0.5)
69
+ pdf-reader (2.15.1)
70
+ Ascii85 (>= 1.0, < 3.0, != 2.0.0)
71
+ afm (>= 0.2.1, < 2)
72
+ hashery (~> 2.0)
73
+ ruby-rc4
74
+ ttfunk
29
75
  prism (1.9.0)
30
76
  psych (5.4.0)
31
77
  date
32
78
  stringio
79
+ public_suffix (7.0.5)
33
80
  racc (1.8.1)
81
+ rainbow (3.1.1)
34
82
  rake (13.3.1)
35
83
  rdoc (7.2.0)
36
84
  erb
37
85
  psych (>= 4.0.0)
38
86
  tsort
87
+ ruby-rc4 (0.1.5)
39
88
  stringio (3.2.0)
40
89
  tiktoken_ruby (0.0.16-arm64-darwin)
41
90
  tiktoken_ruby (0.0.16-x86_64-linux)
91
+ traces (0.18.2)
42
92
  tsort (0.2.0)
93
+ ttfunk (1.8.0)
94
+ bigdecimal (~> 3.1)
43
95
  tty-color (0.6.0)
44
96
  tty-cursor (0.7.1)
45
97
  tty-prompt (0.23.1)
@@ -50,8 +102,13 @@ GEM
50
102
  tty-screen (~> 0.8)
51
103
  wisper (~> 2.0)
52
104
  tty-screen (0.8.2)
105
+ typhoeus (1.6.0)
106
+ ethon (>= 0.18.0)
107
+ webrick (1.9.2)
53
108
  wisper (2.0.1)
54
109
  yard (0.9.44)
110
+ yell (2.2.2)
111
+ zeitwerk (2.8.2)
55
112
 
56
113
  PLATFORMS
57
114
  arm64-darwin
@@ -59,38 +116,69 @@ PLATFORMS
59
116
  x86_64-linux
60
117
 
61
118
  DEPENDENCIES
119
+ html-proofer
62
120
  kward!
63
121
  minitest
64
122
  rake
65
123
  rdoc
124
+ webrick
66
125
  yard
67
126
 
68
127
  CHECKSUMS
128
+ Ascii85 (2.0.1) sha256=15cb5d941808543cbb9e7e6aea3c8ec3877f154c3461e8b3673e97f7ecedbe5a
129
+ addressable (2.9.0) sha256=7fdf6ac3660f7f4e867a0838be3f6cf722ace541dd97767fa42bc6cfa980c7af
130
+ afm (1.0.0) sha256=5bd4d6f6241e7014ef090985ec6f4c3e9745f6de0828ddd58bc1efdd138f4545
131
+ async (2.39.0) sha256=df18730073f2bbb45788077dfa20cb365ecc1b9453969f44de6796b5191a00aa
69
132
  base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
133
+ benchmark (0.5.0) sha256=465df122341aedcb81a2a24b4d3bd19b6c67c1530713fd533f3ff034e419236c
134
+ bigdecimal (3.3.1) sha256=eaa01e228be54c4f9f53bf3cc34fe3d5e845c31963e7fcc5bedb05a4e7d52218
135
+ console (1.36.0) sha256=45599ea906cf80a73d8941f03abf873fe66a6a954e0bac5bc1c01e2cdc406f07
70
136
  date (3.5.1) sha256=750d06384d7b9c15d562c76291407d89e368dda4d4fff957eb94962d325a0dc0
71
137
  drb (2.2.3) sha256=0b00d6fdb50995fe4a45dea13663493c841112e4068656854646f418fda13373
72
138
  erb (6.0.4) sha256=38e3803694be357fe2bfe312487c74beaf9fb4e5beb3e22498952fe1645b95d9
73
- kward (0.69.1)
139
+ ethon (0.18.0) sha256=b598afc9f30448cb068b850714b7d6948e941476095d04f90a4ac65b8d6efcb2
140
+ ffi (1.17.4-arm64-darwin) sha256=19071aaf1419251b0a46852abf960e77330a3b334d13a4ab51d58b31a937001b
141
+ ffi (1.17.4-x86_64-linux-gnu) sha256=9d3db14c2eae074b382fa9c083fe95aec6e0a1451da249eab096c34002bc752d
142
+ fiber-annotation (0.2.0) sha256=7abfadf1d119f508867d4103bf231c0354d019cc39a5738945dec2edadaf6c03
143
+ fiber-local (1.1.0) sha256=c885f94f210fb9b05737de65d511136ea602e00c5105953748aa0f8793489f06
144
+ fiber-storage (1.0.1) sha256=f48e5b6d8b0be96dac486332b55cee82240057065dc761c1ea692b2e719240e1
145
+ hashery (2.1.2) sha256=d239cc2310401903f6b79d458c2bbef5bf74c46f3f974ae9c1061fb74a404862
146
+ html-proofer (5.2.1) sha256=fdd958a7cbf9c3255fb96fe7cfc4e611f64e2706e469488a3326309ad007d2fd
147
+ io-event (1.16.2) sha256=9f9cb0a96ea5c3850a672606c65f27bc96d7621399ef6196acbfe2be0cd1279c
148
+ json (2.19.9) sha256=9b9025b7cdddafa38d316eca0b2358488e42d417045c1b90d216a9fefe46b79a
149
+ kward (0.71.0)
150
+ logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
151
+ metrics (0.15.0) sha256=61ded5bac95118e995b1bc9ed4a5f19bc9814928a312a85b200abbdac9039072
74
152
  minitest (6.0.6) sha256=153ea36d1d987a62942382b61075745042a2b3123b1cd48f4c3675af9cc7d6f1
75
153
  nokogiri (1.19.3-arm64-darwin) sha256=71b9bd424b1b7abc18b05052a1a3cfd3627abdca62be280854cc411791357e42
76
154
  nokogiri (1.19.3-x86_64-linux-gnu) sha256=2f5078620fe12e83669b5b17311b32532a8153d02eee7ad06948b926d6080976
77
155
  pastel (0.8.0) sha256=481da9fb7d2f6e6b1a08faf11fa10363172dc40fd47848f096ae21209f805a75
156
+ pdf-reader (2.15.1) sha256=18c6a986a84a3117fa49f4279fc2de51f5d2399b71833df5d2bccd595c7068ce
78
157
  prism (1.9.0) sha256=7b530c6a9f92c24300014919c9dcbc055bf4cdf51ec30aed099b06cd6674ef85
79
158
  psych (5.4.0) sha256=14f72d69a611af663d7d70e4a7b67d9eb1f3ae9f8d916b478961d5a0075ba5b7
159
+ public_suffix (7.0.5) sha256=1a8bb08f1bbea19228d3bed6e5ed908d1cb4f7c2726d18bd9cadf60bc676f623
80
160
  racc (1.8.1) sha256=4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f
161
+ rainbow (3.1.1) sha256=039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a
81
162
  rake (13.3.1) sha256=8c9e89d09f66a26a01264e7e3480ec0607f0c497a861ef16063604b1b08eb19c
82
163
  rdoc (7.2.0) sha256=8650f76cd4009c3b54955eb5d7e3a075c60a57276766ebf36f9085e8c9f23192
164
+ ruby-rc4 (0.1.5) sha256=00cc40a39d20b53f5459e7ea006a92cf584e9bc275e2a6f7aa1515510e896c03
83
165
  stringio (3.2.0) sha256=c37cb2e58b4ffbd33fe5cd948c05934af997b36e0b6ca6fdf43afa234cf222e1
84
166
  tiktoken_ruby (0.0.16-arm64-darwin) sha256=3da6fe850bf920d08c7eb736673f50bc9d08e8f2e17d34904ad3185a73fc9da7
85
167
  tiktoken_ruby (0.0.16-x86_64-linux) sha256=4d970b8e68a86972ec81799306116480b33a558c06bb4fe0092852280a4b76b2
168
+ traces (0.18.2) sha256=80f1649cb4daace1d7174b81f3b3b7427af0b93047759ba349960cb8f315e214
86
169
  tsort (0.2.0) sha256=9650a793f6859a43b6641671278f79cfead60ac714148aabe4e3f0060480089f
170
+ ttfunk (1.8.0) sha256=a7cbc7e489cc46e979dde04d34b5b9e4f5c8f1ee5fc6b1a7be39b829919d20ca
87
171
  tty-color (0.6.0) sha256=6f9c37ca3a4e2367fb2e6d09722762647d6f455c111f05b59f35730eeb24332a
88
172
  tty-cursor (0.7.1) sha256=79534185e6a777888d88628b14b6a1fdf5154a603f285f80b1753e1908e0bf48
89
173
  tty-prompt (0.23.1) sha256=fcdbce905238993f27eecfdf67597a636bc839d92192f6a0eef22b8166449ec8
90
174
  tty-reader (0.9.0) sha256=c62972c985c0b1566f0e56743b6a7882f979d3dc32ff491ed490a076f899c2b1
91
175
  tty-screen (0.8.2) sha256=c090652115beae764336c28802d633f204fb84da93c6a968aa5d8e319e819b50
176
+ typhoeus (1.6.0) sha256=bacc41c23e379547e29801dc235cd1699b70b955a1ba3d32b2b877aa844c331d
177
+ webrick (1.9.2) sha256=beb4a15fc474defed24a3bda4ffd88a490d517c9e4e6118c3edce59e45864131
92
178
  wisper (2.0.1) sha256=ce17bc5c3a166f241a2e6613848b025c8146fce2defba505920c1d1f3f88fae6
93
179
  yard (0.9.44) sha256=eb087e9b631ccd887b049f303d489963945452d5e2a7eb49a5a74a7cf6887f28
180
+ yell (2.2.2) sha256=1d166f3cc3b6dc49a59778ea7156ed6d8de794c15106d48ffd6cbb061b9b26bc
181
+ zeitwerk (2.8.2) sha256=7212a61311083c604184b1ea2574b9aa05cd14f855a0841c06985cabe9181d12
94
182
 
95
183
  BUNDLED WITH
96
184
  4.0.6
data/README.md CHANGED
@@ -77,17 +77,25 @@ Start here:
77
77
 
78
78
  Feature guides:
79
79
 
80
+ - [Sessions](doc/session-management.md): resume, clone, fork, rewind, compact, and navigate saved work.
80
81
  - [Memory](doc/memory.md): opt-in core, soft, and session memory.
81
82
  - [Personas](doc/personas.md): configure Kward's tone and role by default, workspace, model, reasoning effort, time, and weekday.
82
- - [Extensibility](doc/extensibility.md): `PRINCIPLES.md`, workspace `AGENTS.md`, skills, prompt templates, and extension choices.
83
- - [Plugins](doc/plugins.md): trusted Ruby plugins for commands, footer UI, prompt context, transcript events, and RPC clients.
84
- - [Web search](doc/web-search.md): live search providers and network behavior.
85
- - [Code search](doc/code-search.md): package lookup, GitHub repository cache, and external source reading.
86
83
 
87
- Advanced/reference:
84
+ Advanced:
88
85
 
86
+ - [Extensibility](doc/extensibility.md): `PRINCIPLES.md`, workspace `AGENTS.md`, skills, prompt templates, and extension choices.
87
+ - [Plugins](doc/plugins.md): trusted Ruby plugins for commands, footer UI, prompt context, transcript events, and RPC clients.
89
88
  - [RPC protocol](doc/rpc.md): experimental JSON-RPC backend mode for UI clients.
90
89
  - [Releasing](doc/releasing.md): release checklist for RubyGems publishing.
90
+ - [Agent tools](doc/agent-tools.md): overview of model-callable tools, token-saving behavior, and tool categories.
91
+ - [Workspace tools](doc/workspace-tools.md): local file, edit, and shell command tools.
92
+ - [Web search](doc/web-search.md): live search providers and network behavior for the web search agent tool.
93
+ - [Code search](doc/code-search.md): package lookup, GitHub repository cache, and external source reading for the code search agent tool.
94
+ - [Context tools](doc/context-tools.md): skills, compacted output retrieval, and structured clarification questions.
95
+
96
+ API reference:
97
+
98
+ - [API reference](doc/api.md): generated Ruby API entry points, indexes, and public API expectations.
91
99
 
92
100
  ## Development
93
101
 
@@ -97,7 +105,15 @@ Run tests:
97
105
  bundle exec rake test
98
106
  ```
99
107
 
100
- Build the YARD documentation site:
108
+ Preview the built YARD documentation site locally with automatic rebuilds:
109
+
110
+ ```bash
111
+ bundle exec rake docs:serve
112
+ ```
113
+
114
+ The preview builds `_yardoc/`, serves it with WEBrick using `Cache-Control: no-store`, and rebuilds in a fresh process when documentation sources, library code, or templates change. Generated HTML, images, CSS, and JavaScript match the published site. Open <http://localhost:8808/> and refresh your browser after rebuilds. Use `PORT=4000 bundle exec rake docs:serve` to choose another port.
115
+
116
+ Build the static YARD documentation site for publishing:
101
117
 
102
118
  ```bash
103
119
  bundle exec rake docs:build
@@ -105,6 +121,14 @@ bundle exec rake docs:build
105
121
 
106
122
  The generated site is written to `_yardoc/`. Pushes to `main` deploy that directory to GitHub Pages.
107
123
 
124
+ Check generated documentation links, images, and scripts:
125
+
126
+ ```bash
127
+ bundle exec rake docs:check
128
+ ```
129
+
130
+ External link checks are disabled by default for stable local runs. Enable them with `DOCS_CHECK_EXTERNAL=1 bundle exec rake docs:check`.
131
+
108
132
  Generate the RDoc API documentation:
109
133
 
110
134
  ```bash
data/Rakefile CHANGED
@@ -1,8 +1,49 @@
1
1
  require "fileutils"
2
+ require "html-proofer"
2
3
  require "rdoc/task"
4
+ require "webrick"
3
5
  require "yard"
4
6
  require "yard/rake/yardoc_task"
5
7
 
8
+ DOCS_WATCH_GLOBS = [
9
+ ".yardopts",
10
+ "CHANGELOG.md",
11
+ "LICENSE",
12
+ "README.md",
13
+ "doc/**/*.md",
14
+ "lib/**/*.rb",
15
+ "templates/**/*"
16
+ ].freeze
17
+
18
+ def docs_watch_snapshot
19
+ DOCS_WATCH_GLOBS.flat_map { |pattern| Dir.glob(pattern) }
20
+ .select { |path| File.file?(path) }
21
+ .uniq
22
+ .to_h { |path| [path, File.mtime(path)] }
23
+ end
24
+
25
+ def rebuild_docs
26
+ system({ "DOCS_SERVE_REBUILD" => "1" }, "bundle", "exec", "rake", "docs:build") || abort("Documentation rebuild failed")
27
+ end
28
+
29
+ def rewrite_yard_markdown_links
30
+ guide_names = Dir.glob("doc/*.md").map { |path| File.basename(path, ".md") }
31
+
32
+ Dir.glob("_yardoc/**/*.html").each do |path|
33
+ html = File.read(path)
34
+ rewritten = html.gsub(/href=(["'])(?:(?:\.\.\/)?doc\/)?([a-z0-9-]+)\.md(#[^"']*)?\1/) do |match|
35
+ quote = Regexp.last_match(1)
36
+ guide_name = Regexp.last_match(2)
37
+ anchor = Regexp.last_match(3).to_s
38
+ next match unless guide_names.include?(guide_name)
39
+
40
+ "href=#{quote}file.#{guide_name}.html#{anchor}#{quote}"
41
+ end
42
+
43
+ File.write(path, rewritten) unless rewritten == html
44
+ end
45
+ end
46
+
6
47
  task default: :test
7
48
 
8
49
  task :test do
@@ -26,8 +67,63 @@ YARD::Rake::YardocTask.new do |yard|
26
67
  end
27
68
 
28
69
  namespace :docs do
70
+ desc "Serve the built YARD documentation site locally and rebuild on changes"
71
+ task serve: :build do
72
+ port = Integer(ENV.fetch("PORT", "8808"))
73
+ server = WEBrick::HTTPServer.new(
74
+ BindAddress: "127.0.0.1",
75
+ DocumentRoot: File.expand_path("_yardoc", __dir__),
76
+ Port: port
77
+ )
78
+
79
+ server.mount_proc "/" do |request, response|
80
+ WEBrick::HTTPServlet::FileHandler.new(server, File.expand_path("_yardoc", __dir__)).service(request, response)
81
+ response["Cache-Control"] = "no-store"
82
+ end
83
+
84
+ watcher = Thread.new do
85
+ snapshot = docs_watch_snapshot
86
+
87
+ loop do
88
+ sleep 1
89
+ current_snapshot = docs_watch_snapshot
90
+ next if current_snapshot == snapshot
91
+
92
+ snapshot = current_snapshot
93
+ puts "Documentation changed; rebuilding _yardoc/. Refresh your browser when it finishes."
94
+ rebuild_docs
95
+ puts "Documentation rebuilt."
96
+ rescue StandardError => error
97
+ warn "Documentation rebuild failed: #{error.class}: #{error.message}"
98
+ end
99
+ end
100
+
101
+ trap("INT") { server.shutdown }
102
+ trap("TERM") { server.shutdown }
103
+
104
+ puts "Serving documentation at http://localhost:#{port}/"
105
+ puts "Watching documentation sources for changes. Refresh your browser after rebuilds."
106
+ server.start
107
+ ensure
108
+ watcher&.kill
109
+ end
110
+
29
111
  desc "Build the YARD documentation site"
30
112
  task build: :yard do
113
+ rewrite_yard_markdown_links
31
114
  FileUtils.touch("_yardoc/.nojekyll")
32
115
  end
116
+
117
+ desc "Check generated documentation links and images"
118
+ task check: :build do
119
+ options = {
120
+ checks: ["Images", "Links", "Scripts"],
121
+ allow_missing_href: true,
122
+ disable_external: ENV["DOCS_CHECK_EXTERNAL"] != "1",
123
+ enforce_https: false,
124
+ ignore_urls: [/^$/]
125
+ }
126
+
127
+ HTMLProofer.check_directory("_yardoc", options).run
128
+ end
33
129
  end
@@ -0,0 +1,43 @@
1
+ # Agent tools
2
+
3
+ Agent tools are the model-callable operations Kward uses to inspect projects, change files, run commands, search outside sources, and ask for clarification. Most users do not call these tools directly. You ask for an outcome in natural language, and Kward decides which tools are needed.
4
+
5
+ Tools are part of Kward's safety and context-management boundary:
6
+
7
+ - schemas describe what the model is allowed to call,
8
+ - Ruby tool objects validate and execute those calls,
9
+ - workspace tools stay inside the active workspace by default,
10
+ - file-changing tools require the file to be read first,
11
+ - large outputs are bounded or compacted before they enter model context,
12
+ - full tool outputs are kept in the session record for later inspection.
13
+
14
+ ## Tool categories
15
+
16
+ | Category | Tools | Guide |
17
+ | --- | --- | --- |
18
+ | Workspace tools | `list_directory`, `read_file`, `summarize_file_structure`, `write_file`, `edit_file`, `run_shell_command` | [Workspace tools](workspace-tools.md) |
19
+ | Web tools | `web_search`, `fetch_content`, `fetch_raw` | [Web search](web-search.md) |
20
+ | Code search | `code_search` | [Code search](code-search.md) |
21
+ | Context and interaction tools | `read_skill`, `retrieve_tool_output`, `ask_user_question` | [Context tools](context-tools.md) |
22
+
23
+ ## How tools save tokens
24
+
25
+ Kward tries to keep tool context useful without flooding the model:
26
+
27
+ - `read_file` reads bounded line ranges and supports continuation with `offset` and `limit`.
28
+ - `summarize_file_structure` returns a compact outline for large source files before reading all code.
29
+ - Search, fetch, and shell outputs are capped or compacted before model ingestion.
30
+ - Repeated identical tool output is replaced with a short reference instead of being sent again.
31
+ - Compacted outputs are stored as artifacts that can be reopened with `retrieve_tool_output`.
32
+
33
+ This lets the assistant reason from focused evidence while preserving access to original outputs when needed.
34
+
35
+ ## How tools are exposed
36
+
37
+ `Kward::ToolRegistry` builds the available tool objects and the schemas advertised to the model. Some tools are always available in normal CLI/RPC sessions, while others depend on configuration or frontend capability:
38
+
39
+ - web tools can be hidden with web search configuration,
40
+ - `read_skill` is advertised only when skills are available,
41
+ - `ask_user_question` is advertised only when the frontend can display structured questions.
42
+
43
+ Unknown tool calls are recorded as tool results instead of crashing the session, so the model can recover and choose an advertised tool on the next turn.
data/doc/api.md ADDED
@@ -0,0 +1,92 @@
1
+ # API reference
2
+
3
+ Kward's generated Ruby API documentation is mainly for contributors, plugin authors, tool authors, and people building RPC or editor integrations.
4
+
5
+ If you use Kward from the terminal, start with the [user guides](file.README.html#Documentation) instead. The API reference exposes many internal classes because it is generated from the source tree; not every documented class is a stable extension API.
6
+
7
+ ## Start here
8
+
9
+ - [Classes and modules](class_list.html): searchable index of generated Ruby constants.
10
+ - [Methods](method_list.html): searchable index of generated Ruby methods.
11
+ - [Files](file_list.html): generated file index.
12
+ - [Top-level Kward namespace](Kward.html): root namespace for the generated reference.
13
+
14
+ ## Start by role
15
+
16
+ ### Plugin authors
17
+
18
+ Use plugins when you need trusted local Ruby code for slash commands, prompt context, footer UI, transcript events, or RPC-visible commands.
19
+
20
+ Read first:
21
+
22
+ - [Plugins](plugins.md)
23
+ - [Extensibility](extensibility.md)
24
+
25
+ Generated entry points:
26
+
27
+ - [`Kward.plugin`](Kward.html#plugin-class_method)
28
+ - [`Kward::PluginRegistry`](Kward/PluginRegistry.html)
29
+ - [`Kward::PluginRegistry::DSL`](Kward/PluginRegistry/DSL.html)
30
+ - [`Kward::PluginRegistry::Context`](Kward/PluginRegistry/Context.html)
31
+
32
+ ### Tool authors and contributors
33
+
34
+ Built-in tools are Ruby classes registered with Kward's tool registry. They expose schemas to the model and execute bounded local operations.
35
+
36
+ Read first:
37
+
38
+ - [Usage](usage.md#Workspace_tools)
39
+ - [Web search](web-search.md)
40
+ - [Code search](code-search.md)
41
+
42
+ Generated entry points:
43
+
44
+ - [`Kward::Tools`](Kward/Tools.html)
45
+ - [`Kward::Tools::Base`](Kward/Tools/Base.html)
46
+ - [`Kward::ToolRegistry`](Kward/ToolRegistry.html)
47
+
48
+ ### RPC and frontend authors
49
+
50
+ The RPC protocol is the supported integration surface for UI clients. Prefer the protocol guide before reading implementation classes.
51
+
52
+ Read first:
53
+
54
+ - [RPC protocol](rpc.md)
55
+
56
+ Generated entry points:
57
+
58
+ - [`Kward::RPC`](Kward/RPC.html)
59
+ - [`Kward::RPC::Server`](Kward/RPC/Server.html)
60
+ - [`Kward::RPC::SessionManager`](Kward/RPC/SessionManager.html)
61
+ - [`Kward::RPC::ToolEventNormalizer`](Kward/RPC/ToolEventNormalizer.html)
62
+
63
+ ### Prompt, skill, and configuration contributors
64
+
65
+ Prompt templates, skills, personas, and project instructions are user-facing extension points. Prefer the guides for supported behavior, then use the API reference to inspect implementation details.
66
+
67
+ Read first:
68
+
69
+ - [Extensibility](extensibility.md)
70
+ - [Personas](personas.md)
71
+ - [Configuration](configuration.md)
72
+
73
+ Generated entry points:
74
+
75
+ - [`Kward::Prompts`](Kward/Prompts.html)
76
+ - [`Kward::Prompts::Templates`](Kward/Prompts/Templates.html)
77
+ - [`Kward::Skills`](Kward/Skills.html)
78
+ - [`Kward::Skills::Registry`](Kward/Skills/Registry.html)
79
+ - [`Kward::ConfigFiles`](Kward/ConfigFiles.html)
80
+
81
+ ## Public API expectations
82
+
83
+ Kward is still evolving. The generated reference is useful for understanding the codebase, but it should not be read as a promise that every class, method, or constructor is public and stable.
84
+
85
+ Prefer the documented guides for supported extension behavior. Use generated class and method pages when you need implementation detail, are contributing to Kward itself, or are coordinating a frontend integration with the current codebase.
86
+
87
+ As a rule of thumb:
88
+
89
+ - Guide-documented behavior is the supported user-facing surface.
90
+ - Plugin DSL methods are intended extension points.
91
+ - RPC JSON-RPC methods documented in [RPC protocol](rpc.md) are the integration contract for frontend clients.
92
+ - Generated classes without guide coverage may be internal implementation details.