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
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d6d8b5577dbec359eb683a0ce26cb87276b334b2d6346670df0338c9f10b123f
4
+ data.tar.gz: abbd42bade9aed052e52b0e5c9ef6f9e560b56c35558346736d3963bdb34fc76
5
+ SHA512:
6
+ metadata.gz: 81c6bf970a1dd702e30ee6481feaa57fa11457fca292d17dd0f609c2e37981f9cf72d1e610d2f354a77f7093a3e21fd16b67fea03a54ad30e69c560f72081343
7
+ data.tar.gz: daa54b6f0db9025b84ad14393654dbce127083f307ca67f0612100e0b015a499ab9f06a5cf413b80ea7e4d5f9f8386b11ae175a4d610f4e2fc90ab3817bd5390
data/.yardopts ADDED
@@ -0,0 +1,9 @@
1
+ --readme README.md
2
+ --output-dir _yardoc
3
+ --markup markdown
4
+ lib/**/*.rb
5
+ -
6
+ README.md
7
+ CHANGELOG.md
8
+ LICENSE
9
+ doc/**/*.md
data/CHANGELOG.md ADDED
@@ -0,0 +1,12 @@
1
+ # Changelog
2
+
3
+ All notable changes to Kward will be documented in this file.
4
+
5
+ ## Unreleased
6
+
7
+ - No changes yet.
8
+
9
+ ## 0.66.0 - 2026-06-12 - Codename: Order
10
+
11
+ - Initial public release.
12
+ - Prepare RubyGems packaging for the initial public release.
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem "minitest"
6
+ gem "rake"
7
+ gem "rdoc"
8
+ gem "yard"
data/Gemfile.lock ADDED
@@ -0,0 +1,90 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ kward (0.66.0)
5
+ base64
6
+ nokogiri
7
+ tiktoken_ruby
8
+ tty-cursor
9
+ tty-prompt
10
+ tty-reader
11
+ tty-screen
12
+
13
+ GEM
14
+ remote: https://rubygems.org/
15
+ specs:
16
+ base64 (0.3.0)
17
+ date (3.5.1)
18
+ drb (2.2.3)
19
+ erb (6.0.4)
20
+ minitest (6.0.6)
21
+ drb (~> 2.0)
22
+ prism (~> 1.5)
23
+ nokogiri (1.19.3-arm64-darwin)
24
+ racc (~> 1.4)
25
+ pastel (0.8.0)
26
+ tty-color (~> 0.5)
27
+ prism (1.9.0)
28
+ psych (5.4.0)
29
+ date
30
+ stringio
31
+ racc (1.8.1)
32
+ rake (13.3.1)
33
+ rdoc (7.2.0)
34
+ erb
35
+ psych (>= 4.0.0)
36
+ tsort
37
+ stringio (3.2.0)
38
+ tiktoken_ruby (0.0.16-arm64-darwin)
39
+ tsort (0.2.0)
40
+ tty-color (0.6.0)
41
+ tty-cursor (0.7.1)
42
+ tty-prompt (0.23.1)
43
+ pastel (~> 0.8)
44
+ tty-reader (~> 0.8)
45
+ tty-reader (0.9.0)
46
+ tty-cursor (~> 0.7)
47
+ tty-screen (~> 0.8)
48
+ wisper (~> 2.0)
49
+ tty-screen (0.8.2)
50
+ wisper (2.0.1)
51
+ yard (0.9.44)
52
+
53
+ PLATFORMS
54
+ arm64-darwin
55
+ arm64-darwin-25
56
+
57
+ DEPENDENCIES
58
+ kward!
59
+ minitest
60
+ rake
61
+ rdoc
62
+ yard
63
+
64
+ CHECKSUMS
65
+ base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
66
+ date (3.5.1) sha256=750d06384d7b9c15d562c76291407d89e368dda4d4fff957eb94962d325a0dc0
67
+ drb (2.2.3) sha256=0b00d6fdb50995fe4a45dea13663493c841112e4068656854646f418fda13373
68
+ erb (6.0.4) sha256=38e3803694be357fe2bfe312487c74beaf9fb4e5beb3e22498952fe1645b95d9
69
+ kward (0.66.0)
70
+ minitest (6.0.6) sha256=153ea36d1d987a62942382b61075745042a2b3123b1cd48f4c3675af9cc7d6f1
71
+ nokogiri (1.19.3-arm64-darwin) sha256=71b9bd424b1b7abc18b05052a1a3cfd3627abdca62be280854cc411791357e42
72
+ pastel (0.8.0) sha256=481da9fb7d2f6e6b1a08faf11fa10363172dc40fd47848f096ae21209f805a75
73
+ prism (1.9.0) sha256=7b530c6a9f92c24300014919c9dcbc055bf4cdf51ec30aed099b06cd6674ef85
74
+ psych (5.4.0) sha256=14f72d69a611af663d7d70e4a7b67d9eb1f3ae9f8d916b478961d5a0075ba5b7
75
+ racc (1.8.1) sha256=4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f
76
+ rake (13.3.1) sha256=8c9e89d09f66a26a01264e7e3480ec0607f0c497a861ef16063604b1b08eb19c
77
+ rdoc (7.2.0) sha256=8650f76cd4009c3b54955eb5d7e3a075c60a57276766ebf36f9085e8c9f23192
78
+ stringio (3.2.0) sha256=c37cb2e58b4ffbd33fe5cd948c05934af997b36e0b6ca6fdf43afa234cf222e1
79
+ tiktoken_ruby (0.0.16-arm64-darwin) sha256=3da6fe850bf920d08c7eb736673f50bc9d08e8f2e17d34904ad3185a73fc9da7
80
+ tsort (0.2.0) sha256=9650a793f6859a43b6641671278f79cfead60ac714148aabe4e3f0060480089f
81
+ tty-color (0.6.0) sha256=6f9c37ca3a4e2367fb2e6d09722762647d6f455c111f05b59f35730eeb24332a
82
+ tty-cursor (0.7.1) sha256=79534185e6a777888d88628b14b6a1fdf5154a603f285f80b1753e1908e0bf48
83
+ tty-prompt (0.23.1) sha256=fcdbce905238993f27eecfdf67597a636bc839d92192f6a0eef22b8166449ec8
84
+ tty-reader (0.9.0) sha256=c62972c985c0b1566f0e56743b6a7882f979d3dc32ff491ed490a076f899c2b1
85
+ tty-screen (0.8.2) sha256=c090652115beae764336c28802d633f204fb84da93c6a968aa5d8e319e819b50
86
+ wisper (2.0.1) sha256=ce17bc5c3a166f241a2e6613848b025c8146fce2defba505920c1d1f3f88fae6
87
+ yard (0.9.44) sha256=eb087e9b631ccd887b049f303d489963945452d5e2a7eb49a5a74a7cf6887f28
88
+
89
+ BUNDLED WITH
90
+ 4.0.6
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kai Wood
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,101 @@
1
+ # Kward
2
+
3
+ Kward is an extendable Ruby CLI coding agent. It can chat with you about a project, inspect and edit files, run confirmed shell commands, search the web, look up public source code, save local sessions, and load trusted Ruby plugins for custom workflows.
4
+
5
+ It currently supports the OpenAI/ChatGPT Codex backend, OpenRouter, and experimental Copilot provider support.
6
+
7
+ ## Install
8
+
9
+ Kward is being prepared for a RubyGems release. Once published, install it with:
10
+
11
+ ```bash
12
+ gem install kward
13
+ ```
14
+
15
+ Optionally install the starter pack after installation:
16
+
17
+ ```bash
18
+ kward --install-starter-pack
19
+ ```
20
+
21
+ This downloads Kward's default prompts and base `AGENTS.md` into your config directory. It is useful for a first setup, but safe to skip if you prefer to create your own instructions. Existing files are left untouched.
22
+
23
+ Then start Kward and sign in when needed:
24
+
25
+ ```bash
26
+ kward # start an interactive chat
27
+ /login # from inside Kward: sign in or save provider credentials
28
+ kward login # from your shell: sign in or save provider credentials
29
+ kward "Explain this project" # run one prompt and exit
30
+ ```
31
+
32
+ See [Authentication](doc/authentication.md) for more details about sign-in options and provider credentials.
33
+
34
+ ## Run from source
35
+
36
+ If you are working from a checkout:
37
+
38
+ ```bash
39
+ bundle install
40
+ ruby lib/main.rb login # sign in or save provider credentials
41
+ ruby lib/main.rb # start an interactive chat
42
+ ruby lib/main.rb "Explain this project" # run one prompt and exit
43
+ ```
44
+
45
+ You can also use the executable directly after installing dependencies:
46
+
47
+ ```bash
48
+ exe/kward
49
+ ```
50
+
51
+ ## What Kward can do
52
+
53
+ - Keep a multi-turn coding conversation in your terminal.
54
+ - Read, write, and edit workspace files with confirmation before changes.
55
+ - Run shell commands after confirmation.
56
+ - Search the live web and inspect cached public GitHub repositories.
57
+ - Save, resume, clone, compact, and export sessions.
58
+ - Extend the Agent with trusted Ruby plugins for custom commands, footer UI, prompt context, and transcript-event observers.
59
+ - Use optional memory, personas, prompt templates, and skills.
60
+ - Serve an experimental JSON-RPC backend for UI clients.
61
+
62
+ ## Documentation
63
+
64
+ Start here:
65
+
66
+ - [Getting started](doc/getting-started.md): first run, authentication choices, and basic commands.
67
+ - [Usage](doc/usage.md): interactive chat, slash commands, sessions, tools, images, and Pan mode.
68
+ - [Configuration](doc/configuration.md): config files, providers, models, web search, logging, and color output.
69
+ - [Authentication](doc/authentication.md): OpenAI OAuth, OpenRouter API keys, and Copilot/GitHub setup.
70
+
71
+ Feature guides:
72
+
73
+ - [Memory](doc/memory.md): opt-in core, soft, and session memory.
74
+ - [Extensibility](doc/extensibility.md): `AGENTS.md`, personas, skills, and prompt templates.
75
+ - [Plugins](doc/plugins.md): trusted Ruby plugins for commands, footer UI, prompt context, transcript events, and RPC clients.
76
+ - [Web search](doc/web-search.md): live search providers and network behavior.
77
+ - [Code search](doc/code-search.md): package lookup, GitHub repository cache, and external source reading.
78
+
79
+ Advanced/reference:
80
+
81
+ - [RPC protocol](doc/rpc.md): experimental JSON-RPC backend mode for UI clients.
82
+ - [Releasing](doc/releasing.md): release checklist for RubyGems publishing.
83
+
84
+ ## Run tests
85
+
86
+ ```bash
87
+ bundle exec rake test
88
+ ```
89
+
90
+ Equivalent direct command:
91
+
92
+ ```bash
93
+ ruby -Itest -e 'Dir["test/**/test_*.rb"].sort.each { |file| require_relative file }'
94
+ ```
95
+
96
+ ## Generate API documentation
97
+
98
+ ```bash
99
+ bundle exec rake rdoc
100
+ bundle exec yard doc
101
+ ```
data/Rakefile ADDED
@@ -0,0 +1,20 @@
1
+ require "rdoc/task"
2
+ require "yard"
3
+ require "yard/rake/yardoc_task"
4
+
5
+ task default: :test
6
+
7
+ task :test do
8
+ ruby "-Itest", "-e", 'Dir["test/**/test_*.rb"].sort.each { |file| require_relative file }'
9
+ end
10
+
11
+ RDoc::Task.new do |rdoc|
12
+ rdoc.main = "README.md"
13
+ rdoc.rdoc_dir = "rdoc"
14
+ rdoc.rdoc_files.include("README.md", "CHANGELOG.md", "LICENSE", "doc/**/*.md", "lib/**/*.rb")
15
+ end
16
+
17
+ YARD::Rake::YardocTask.new do |yard|
18
+ yard.files = ["lib/**/*.rb", "-", "README.md", "CHANGELOG.md", "LICENSE", "doc/**/*.md"]
19
+ yard.options = ["--readme", "README.md", "--output-dir", "_yardoc", "--markup", "markdown"]
20
+ end
@@ -0,0 +1,105 @@
1
+ # Authentication
2
+
3
+ Kward needs credentials for a model provider before it can answer prompts. The easiest path is to start Kward and run `/login`.
4
+
5
+ Kward supports:
6
+
7
+ - OpenAI/ChatGPT OAuth for the Codex backend.
8
+ - OpenRouter API keys.
9
+ - GitHub OAuth or `COPILOT_GITHUB_TOKEN` for experimental Copilot provider support.
10
+
11
+ If you installed the gem, use `kward` in the examples below. When running from source, use `ruby lib/main.rb` instead.
12
+
13
+ ## Quick login
14
+
15
+ Inside an interactive session:
16
+
17
+ ```text
18
+ /login
19
+ ```
20
+
21
+ Kward opens a provider picker and saves the selected credentials.
22
+
23
+ From your shell, you can also run:
24
+
25
+ ```bash
26
+ kward login # OpenAI/ChatGPT OAuth
27
+ kward login openrouter # save an OpenRouter API key
28
+ kward login github # GitHub OAuth for experimental Copilot support
29
+ ```
30
+
31
+ ## OpenAI OAuth
32
+
33
+ OpenAI OAuth is the default provider path when credentials are available. It uses your ChatGPT account and sends requests to the ChatGPT/Codex backend (`chatgpt.com/backend-api/codex/responses`), not the OpenAI Platform API.
34
+
35
+ To start the browser login from your shell:
36
+
37
+ ```bash
38
+ kward login
39
+ ```
40
+
41
+ In an interactive session, run `/login` and choose OpenAI.
42
+
43
+ Complete the browser redirect flow. Tokens are saved to:
44
+
45
+ ```text
46
+ ~/.kward/auth.json
47
+ ```
48
+
49
+ The auth file is written with file mode `0600`.
50
+
51
+ OpenAI OAuth requires an OAuth client ID in `~/.kward/config.json`:
52
+
53
+ ```json
54
+ {
55
+ "openai_oauth_client_id": "your-client-id"
56
+ }
57
+ ```
58
+
59
+ If it is missing, Kward tells you which config file to update.
60
+
61
+ ## OpenRouter API key
62
+
63
+ OpenRouter uses an API key rather than OAuth. To save it from your shell:
64
+
65
+ ```bash
66
+ kward login openrouter
67
+ ```
68
+
69
+ In an interactive session, run `/login` and choose OpenRouter.
70
+
71
+ Kward saves the key as `openrouter_api_key` in `~/.kward/config.json`. You can also set `OPENROUTER_API_KEY` for a single run without saving it.
72
+
73
+ ## GitHub OAuth for Copilot provider support
74
+
75
+ Kward can use a GitHub token for experimental Copilot provider support.
76
+
77
+ The GitHub device flow uses a built-in default client ID unless you set `GITHUB_OAUTH_CLIENT_ID` or add `github_oauth_client_id` to `~/.kward/config.json`. To log in:
78
+
79
+ ```bash
80
+ kward login github
81
+ ```
82
+
83
+ Tokens are saved to:
84
+
85
+ ```text
86
+ ~/.kward/github_auth.json
87
+ ```
88
+
89
+ The auth file is written with file mode `0600`.
90
+
91
+ You can also run `/login` in an interactive session and choose GitHub, or provide `COPILOT_GITHUB_TOKEN` for a single run.
92
+
93
+ Important: Kward's Copilot provider follows Pi Agent's direct HTTPS approach. It exchanges the GitHub OAuth token for a Copilot internal token and sends chat requests to the Copilot proxy API. It does not use the official Copilot CLI or SDK runtime.
94
+
95
+ ## Fallback and provider selection
96
+
97
+ Credential priority is provider-aware:
98
+
99
+ - OpenAI OAuth is used by default after login, even when `OPENROUTER_API_KEY` or `openrouter_api_key` is also present.
100
+ - `OPENAI_ACCESS_TOKEN` can be used as an OpenAI environment fallback.
101
+ - `OPENROUTER_API_KEY` is a fallback only when no OpenAI OAuth/access token exists.
102
+ - `COPILOT_GITHUB_TOKEN` can be used as a Copilot environment fallback.
103
+ - If `provider` in config or `KWARD_PROVIDER` in the environment is set to `codex`, `openrouter`, or `copilot`, Kward uses that provider and does not fall through to another provider.
104
+
105
+ See [Configuration](configuration.md) for model and provider settings.
@@ -0,0 +1,56 @@
1
+ # Code search
2
+
3
+ Kward exposes a `code_search` tool so the agent can inspect public open-source code for implementation guidance.
4
+
5
+ Use code search when you want Kward to learn from real packages before changing your project. It is useful for checking library APIs, finding examples, comparing implementation patterns, or understanding how another project solved a similar problem.
6
+
7
+ Example prompts:
8
+
9
+ ```text
10
+ Look up how tty-prompt handles key bindings before changing our composer.
11
+ Find examples of Faraday retry middleware usage.
12
+ Inspect how Rails structures this kind of generator test.
13
+ ```
14
+
15
+ The tool can:
16
+
17
+ - look up packages from RubyGems, npm, PyPI, crates.io, and Go package documentation
18
+ - find public GitHub source repositories from package metadata
19
+ - fall back to GitHub repository search when registry metadata has no source URL
20
+ - clone public GitHub repositories into Kward's cache
21
+ - search cached repository files and return bounded snippets with paths and line numbers
22
+ - read bounded line ranges from cached repository files
23
+ - list, refresh, and clear cached repositories
24
+
25
+ ## Cache
26
+
27
+ Repositories are cloned under:
28
+
29
+ ```text
30
+ ~/.kward/cache/code_search
31
+ ```
32
+
33
+ If `KWARD_CONFIG_PATH` points at another config location, the cache is stored next to that config directory under `cache/code_search`.
34
+
35
+ The tool keeps cloned repositories outside the current workspace. It uses safe cache keys derived from GitHub `owner/name` identifiers and rejects absolute paths or path traversal when reading files.
36
+
37
+ ## GitHub access
38
+
39
+ `code_search` uses live network access and the local `git` executable. GitHub authentication is optional. If either `GITHUB_TOKEN` or `GH_TOKEN` is set, the token is sent to GitHub API requests. Without a token, GitHub requests are unauthenticated and may hit lower rate limits.
40
+
41
+ Tokens are not included in tool output.
42
+
43
+ ## Actions
44
+
45
+ The tool has one schema with an `action` parameter:
46
+
47
+ - `package_search` - find package metadata and likely source repository
48
+ - `github_search` - search public GitHub repositories
49
+ - `repo_clone` - clone a GitHub repository into cache if needed
50
+ - `repo_search` - search cached repository files for text
51
+ - `repo_read` - read a bounded line range from a cached repository file
52
+ - `list_cache` - list cached repositories
53
+ - `refresh_cache` - fetch updates for a cached repository
54
+ - `clear_cache` - remove one cached repository
55
+
56
+ Search and read output is bounded to avoid loading excessive external source into context. Oversized and binary files are skipped.