kward 0.79.0 → 0.80.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 (117) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +6 -0
  3. data/CHANGELOG.md +58 -1
  4. data/Gemfile.lock +2 -2
  5. data/README.md +31 -38
  6. data/doc/agent-tools.md +9 -10
  7. data/doc/api.md +3 -3
  8. data/doc/authentication.md +79 -110
  9. data/doc/code-search.md +1 -1
  10. data/doc/composer.md +1 -1
  11. data/doc/configuration.md +69 -26
  12. data/doc/context-budgeting.md +6 -6
  13. data/doc/context-tools.md +2 -2
  14. data/doc/editor.md +7 -7
  15. data/doc/extensibility.md +7 -29
  16. data/doc/files.md +6 -6
  17. data/doc/getting-started.md +2 -2
  18. data/doc/git.md +8 -2
  19. data/doc/lifecycle-hooks.md +5 -4
  20. data/doc/local-models.md +2 -2
  21. data/doc/mcp.md +5 -5
  22. data/doc/permissions.md +13 -4
  23. data/doc/plugins.md +39 -4
  24. data/doc/prompt-templates.md +105 -0
  25. data/doc/providers.md +140 -0
  26. data/doc/releasing.md +10 -2
  27. data/doc/rpc.md +54 -31
  28. data/doc/sandboxing.md +22 -0
  29. data/doc/security.md +22 -7
  30. data/doc/session-management.md +2 -4
  31. data/doc/tabs.md +37 -0
  32. data/doc/telegram.md +138 -0
  33. data/doc/transports.md +209 -0
  34. data/doc/usage.md +11 -3
  35. data/doc/web-search.md +3 -3
  36. data/doc/workspace-tools.md +2 -2
  37. data/examples/plugins/stardate_footer.rb +10 -0
  38. data/examples/plugins/telegram/plugin.rb +39 -0
  39. data/examples/plugins/telegram/telegram_api.rb +136 -0
  40. data/examples/plugins/telegram/telegram_transport.rb +304 -0
  41. data/lib/kward/ansi.rb +1 -0
  42. data/lib/kward/auth/api_key_store.rb +99 -0
  43. data/lib/kward/cli/auth_commands.rb +72 -13
  44. data/lib/kward/cli/commands.rb +7 -0
  45. data/lib/kward/cli/git.rb +31 -8
  46. data/lib/kward/cli/plugins.rb +1 -0
  47. data/lib/kward/cli/prompt_interface.rb +7 -0
  48. data/lib/kward/cli/rendering.rb +6 -2
  49. data/lib/kward/cli/runtime_helpers.rb +4 -2
  50. data/lib/kward/cli/sessions.rb +1 -1
  51. data/lib/kward/cli/settings.rb +97 -33
  52. data/lib/kward/cli/tabs.rb +102 -37
  53. data/lib/kward/cli/transports.rb +67 -0
  54. data/lib/kward/cli/worktrees.rb +360 -0
  55. data/lib/kward/cli.rb +20 -0
  56. data/lib/kward/config_files.rb +26 -3
  57. data/lib/kward/conversation.rb +13 -7
  58. data/lib/kward/git_worktree_manager.rb +291 -0
  59. data/lib/kward/model/azure_openai_config.rb +54 -0
  60. data/lib/kward/model/catalog.rb +113 -0
  61. data/lib/kward/model/client.rb +225 -20
  62. data/lib/kward/model/model_info.rb +49 -0
  63. data/lib/kward/model/payloads.rb +63 -4
  64. data/lib/kward/model/provider_catalog.rb +114 -0
  65. data/lib/kward/model/sources.rb +70 -0
  66. data/lib/kward/model/stream_parser.rb +83 -13
  67. data/lib/kward/permissions/policy.rb +18 -4
  68. data/lib/kward/plugin_chat_runtime.rb +374 -0
  69. data/lib/kward/plugin_registry.rb +80 -7
  70. data/lib/kward/private_file.rb +9 -3
  71. data/lib/kward/prompt_interface/approval_prompt.rb +2 -0
  72. data/lib/kward/prompt_interface/composer_renderer.rb +1 -5
  73. data/lib/kward/prompt_interface/editor/auto_indent.rb +46 -0
  74. data/lib/kward/prompt_interface/editor/buffer.rb +18 -4
  75. data/lib/kward/prompt_interface/editor/controller.rb +7 -7
  76. data/lib/kward/prompt_interface/editor/modes/vibe.rb +2 -2
  77. data/lib/kward/prompt_interface/editor/renderer.rb +8 -8
  78. data/lib/kward/prompt_interface/editor/state.rb +3 -9
  79. data/lib/kward/prompt_interface/editor/syntax_highlighter.rb +184 -9
  80. data/lib/kward/prompt_interface/file_overlay.rb +2 -2
  81. data/lib/kward/prompt_interface/git_prompt.rb +7 -3
  82. data/lib/kward/prompt_interface/interactive/controller.rb +4 -4
  83. data/lib/kward/prompt_interface/interactive/renderer.rb +4 -1
  84. data/lib/kward/prompt_interface/interactive/state.rb +2 -2
  85. data/lib/kward/prompt_interface/project_browser.rb +25 -6
  86. data/lib/kward/prompt_interface/runtime_state.rb +22 -6
  87. data/lib/kward/prompt_interface/screen.rb +3 -0
  88. data/lib/kward/prompt_interface/selection_prompt.rb +7 -1
  89. data/lib/kward/prompt_interface/transcript_buffer.rb +24 -2
  90. data/lib/kward/prompt_interface.rb +53 -12
  91. data/lib/kward/prompts/commands.rb +1 -1
  92. data/lib/kward/prompts.rb +6 -5
  93. data/lib/kward/rpc/auth_manager.rb +112 -152
  94. data/lib/kward/rpc/config_manager.rb +46 -6
  95. data/lib/kward/rpc/plugin_chat_manager.rb +55 -196
  96. data/lib/kward/rpc/prompt_bridge.rb +8 -4
  97. data/lib/kward/rpc/redactor.rb +1 -1
  98. data/lib/kward/rpc/server.rb +60 -10
  99. data/lib/kward/rpc/session_manager.rb +109 -30
  100. data/lib/kward/session_store.rb +84 -24
  101. data/lib/kward/tab_driver.rb +6 -3
  102. data/lib/kward/tools/git_commit.rb +39 -0
  103. data/lib/kward/tools/registry.rb +7 -2
  104. data/lib/kward/tools/tool_call.rb +1 -0
  105. data/lib/kward/transport/gateway.rb +253 -0
  106. data/lib/kward/transport/host.rb +343 -0
  107. data/lib/kward/transport/manager.rb +179 -0
  108. data/lib/kward/transport/plugin_chat_gateway.rb +186 -0
  109. data/lib/kward/transport/runtime.rb +41 -0
  110. data/lib/kward/transport/store.rb +101 -0
  111. data/lib/kward/transport.rb +204 -0
  112. data/lib/kward/version.rb +1 -1
  113. data/lib/kward/workspace_factory.rb +19 -2
  114. data/templates/default/fulldoc/html/js/kward.js +2 -0
  115. data/templates/default/kward_navigation.rb +7 -2
  116. data/templates/default/layout/html/setup.rb +4 -0
  117. metadata +26 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 79174a2cb7441a44857a53568078c50b2c7735d7a8f7507ce6e8d1199f8b37fa
4
- data.tar.gz: c83fda7c64aea1ad5f8af38c5ee0bb1d0c56a3c05efa3457c02fcd5b3049cb99
3
+ metadata.gz: e9128f608c2a864ad996598d285d4042758ea1bc1b3a76a1224984ef23129544
4
+ data.tar.gz: c9d718290398f95e1420e5e12225e43aaba6bf6c64c868fb6d175d5725aaf19d
5
5
  SHA512:
6
- metadata.gz: 9088afe9fb4976a8a40ec08a0297ee99d075f9df756465f68e04482c55f5fbb1d5b0b8d5e20b880d258253d8e015ce91b745a1db57c3ce03374b912d4fc109fe
7
- data.tar.gz: 7452c7d1674338e52b3216f648b798f9181cf421db840bc54a74270acebd40c1aa67aa1c2dbbfaea322908cd50344e34500a79cb68033bdfc1fa62642cefbf20
6
+ metadata.gz: 6b0e53fddfa2de055b11b6bbe0965496e2abc860162ed0888642bb353ae64e0e0fdbfbe14ed7412198c8c60583c1d55fd6d9cd7fec7a43eb37db456a494f5a1a
7
+ data.tar.gz: 2396aceedf67453422924616d92031160d3eee67ae448347d2f367a05d48a97d9ae39789b2100c3c47bdbc5925c85e4922146a50c72ee662d863f8ad597dacbd
@@ -30,6 +30,12 @@ jobs:
30
30
  - name: Install sandbox test dependency
31
31
  run: sudo apt-get update && sudo apt-get install --yes bubblewrap
32
32
 
33
+ - name: Enable Bubblewrap namespaces
34
+ run: |
35
+ sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0
36
+ sudo sysctl -w kernel.unprivileged_userns_clone=1
37
+ bwrap --ro-bind / / --unshare-net true
38
+
33
39
  - name: Check syntax
34
40
  run: find lib test -name '*.rb' -print0 | xargs -0 ruby -c
35
41
 
data/CHANGELOG.md CHANGED
@@ -2,7 +2,64 @@
2
2
 
3
3
  All notable changes to Kward will be documented in this file.
4
4
 
5
- ## [Unreleased]
5
+ ## [0.80.0] - 2026-07-27
6
+
7
+ ### Added
8
+
9
+ - Added HTML/Ruby syntax highlighting and common-block auto-indentation for `.erb` files in the integrated editor.
10
+ - Added catalog-based API-key login and model selection for OpenAI, Anthropic, Azure OpenAI, Gemini, Cerebras, DeepSeek, Fireworks AI, Groq, Mistral, NVIDIA NIM, OpenRouter, Together AI, and xAI, with private credential storage and live/cached/curated model catalogs.
11
+ - Added native streaming runtimes for the OpenAI Responses API, Google Gemini, and Azure OpenAI, including tool calls, usage metadata, retries, cancellation, and secret redaction.
12
+ - Added RPC parity for provider/auth-method discovery, sanitized credential status, API-key login/logout, model refresh, and provider/model selection.
13
+ - Added a dedicated model-provider guide with the canonical provider list, runtime IDs, authentication, model configuration, discovery behavior, and limitations.
14
+ - Added a prompt-template guide, including template creation, slash-command expansion, and the starter templates installed by `kward init`.
15
+ - Added a Stardate footer plugin example for the interactive CLI.
16
+ - Added a general transport plugin API with normalized messages and events, persistent transport state, policy checks, managed lifecycle, foreground CLI commands, and RPC capability/status reporting.
17
+ - Added a first-party Telegram long-polling transport example with fixed-workspace routing, numeric allowlists, idempotent updates, message chunking, and interactive approval/question buttons.
18
+ - Added packaged plugin entrypoints under `~/.kward/plugins/*/plugin.rb` for multi-file trusted plugins.
19
+ - Added generic transport execution profiles and an isolated Telegram chat transport with no tools, plugin commands, memory, attachments, or interactions.
20
+ - Added a shared scoped plugin-chat runtime and `Transport::Host#plugin_chats` for explicitly transport-capable plugin chats, including actor context, event replay, cancellation, and separate transport/RPC access.
21
+ - Added transport-only plugin chats with `local: false`, keeping externally targeted plugin chats out of local tab opening and restoration.
22
+ - Added Git worktree bindings for normal interactive session tabs. `/tab worktree` can move a tab into a strict linked-worktree workspace after research, preserve its transcript, warn about dirty origin changes, and keep the branch available when explicitly detached.
23
+ - Added the active worktree `git_commit` model tool, allowing explicitly requested agent commits through the trusted host-side Git workflow without widening the shell sandbox.
24
+ - Added `/tab worktree merge` for explicitly merging a clean worktree branch into the branch checked out in its original workspace, plus `/tab worktree merge abort` for conflicted merges.
25
+ - Added `j`/`k` keyboard navigation to the `/files` project browser.
26
+ - Added `h`/`l` keyboard navigation for collapsing and expanding `/files` directories.
27
+ - Added `j`/`k` keyboard navigation to the `/git` changed-file overlay.
28
+
29
+ ### Changed
30
+
31
+ - Avoided copying bounded transcript buffers into idle tab snapshots while preserving intentional full-conversation scrollback replay when those tabs are revisited.
32
+ - Kept the TUI transcript buffer under its existing limit while trimming to a safe low watermark instead of copying the full buffer after every appended character.
33
+ - Reduced integrated-editor layout work by caching line starts and calculating the cursor line once per rendered frame.
34
+ - Limited interactive plugin footer evaluation to its authoritative one-second refresh interval and reused the cached value between refreshes.
35
+ - Made interactive plugin canvases publish only complete frames submitted with `ui.render`, skip unpublished ticks, and follow terminal width changes.
36
+ - Avoided rebuilding and flushing the TUI composer when tab labels and selection have not changed.
37
+ - Reduced interactive streaming overhead by writing each labeled TUI delta in one synchronized prompt transaction.
38
+ - Highlighted the current editor line number in white while keeping the rest of the line-number gutter green.
39
+ - Made `/model` provider-aware with refresh, manual model IDs, capability-filtered defaults, Show all, and provider switching while preserving Codex, Copilot, OpenRouter, and local models.
40
+ - Kept direct OpenAI API credentials (`openai_api`) separate from ChatGPT/Codex OAuth so both can be configured at once.
41
+ - Azure OpenAI setup now validates HTTPS endpoints, deployment names, and API versions, and treats the configured deployment as the selectable model.
42
+ - Updated current documentation to describe Copilot and the JSON-RPC backend as supported features rather than experimental ones.
43
+ - Clarified the distinct roles of workspace guardrails, tool permissions, and command sandboxing.
44
+ - Reorganized the README documentation index and clarified generated Ruby API support boundaries.
45
+ - Added task-oriented navigation to the RPC and configuration references.
46
+ - Standardized MCP support and limitation wording across the user and RPC guides.
47
+ - Reframed the README introduction around Kward as an Agentic Development Environment (ADE) with opt-in safety controls.
48
+ - Moved the local-model setup guide to the generated documentation Integrate navigation.
49
+ - Added the Telegram transport deployment guide to the generated documentation navigation.
50
+ - Replaced implicit `/tab worktree` detachment with explicit `/tab worktree detach`; running `/tab worktree` again now leaves an active worktree enabled.
51
+ - Added workspace overrides for foreground transports via `kward transport run NAME WORKSPACE` and the global `--working-directory` option.
52
+ - The `/files` project-browser now uses full terminal height if there are enough files to fill that space
53
+
54
+ ### Fixed
55
+
56
+ - Prevented a stopped tab live-view thread from resuming against a newly active tab after a slow render.
57
+ - Kept `@`/`$` completion, `/files`, prompt history, and the integrated editor rooted in the active worktree tab instead of the original checkout.
58
+ - Fixed HTML and ERB editor highlighting so tag names, attributes, values, and tag fragments retain consistent colors across embedded Ruby expressions.
59
+ - Refreshed composer diff and context usage status immediately when switching session tabs.
60
+ - Prevented `/reload` from retaining stale prompt templates, so new and edited prompt files refresh slash-command completion and expansion.
61
+ - Prevented session-picker rename input from filtering the visible session list.
62
+ - Fixed session listing timestamps and ordering to ignore system-prompt and other metadata writes during session restoration.
6
63
 
7
64
  ## [0.79.0] - 2026-07-19
8
65
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kward (0.79.0)
4
+ kward (0.80.0)
5
5
  base64
6
6
  nokogiri
7
7
  tiktoken_ruby
@@ -146,7 +146,7 @@ CHECKSUMS
146
146
  html-proofer (5.2.1) sha256=fdd958a7cbf9c3255fb96fe7cfc4e611f64e2706e469488a3326309ad007d2fd
147
147
  io-event (1.16.2) sha256=9f9cb0a96ea5c3850a672606c65f27bc96d7621399ef6196acbfe2be0cd1279c
148
148
  json (2.19.9) sha256=9b9025b7cdddafa38d316eca0b2358488e42d417045c1b90d216a9fefe46b79a
149
- kward (0.79.0)
149
+ kward (0.80.0)
150
150
  logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
151
151
  metrics (0.15.0) sha256=61ded5bac95118e995b1bc9ed4a5f19bc9814928a312a85b200abbdac9039072
152
152
  minitest (6.0.6) sha256=153ea36d1d987a62942382b61075745042a2b3123b1cd48f4c3675af9cc7d6f1
data/README.md CHANGED
@@ -1,29 +1,16 @@
1
1
  # Kward
2
2
 
3
- Kward is an extendable Ruby CLI coding agent. It can chat with you about a project, inspect and edit files, run local shell commands, search the web, look up public source code, save local sessions, and load trusted Ruby plugins for custom workflows.
3
+ Kward is a coding agent for your terminal. It can inspect and edit a project, run commands, research problems, and save your work in sessions you can resume later.
4
4
 
5
- It supports the OpenAI/ChatGPT Codex backend, Anthropic Claude Pro/Max subscription, OpenRouter, experimental Copilot provider support, and OpenAI-compatible local servers such as Ollama, LM Studio, and llama.cpp.
5
+ Use Kward from the terminal, its local browser interface, or a trusted JSON-RPC client. It works with ChatGPT/Codex and Claude subscriptions, hosted model APIs, GitHub Copilot, OpenRouter, and local servers such as Ollama, LM Studio, and llama.cpp.
6
6
 
7
- ## Why use Kward?
7
+ ## Why Kward?
8
8
 
9
- Kward is designed for working with real projects, not isolated prompts.
9
+ Software work rarely fits into one chat. A project can span days of research, implementation, debugging, review, and decisions worth keeping.
10
10
 
11
- Typical workflows include:
11
+ Kward treats that work as an ongoing workspace rather than a disposable conversation. You can resume earlier sessions, split work across tabs and Git worktrees, and keep project guidance close to the code. Optional permissions, command sandboxing, and workspace boundaries give you more control when a task needs it.
12
12
 
13
- - Understanding an unfamiliar codebase
14
- - Investigating bugs
15
- - Reviewing changes
16
- - Refactoring code
17
- - Automating repetitive development tasks
18
- - Building custom agent workflows through plugins
19
-
20
- Examples:
21
-
22
- ```bash
23
- kward "Explain this project"
24
- kward "Review this diff"
25
- kward "Find performance problems in this codebase"
26
- ```
13
+ Start with a normal coding conversation. If your workflow grows, you can add memory, reusable prompts and skills, local plugins, lifecycle hooks, MCP servers, transports, or a custom RPC client.
27
14
 
28
15
  ## Install
29
16
 
@@ -52,57 +39,63 @@ kward "Explain this project" # run one prompt and exit
52
39
  kward --working-directory ~/code/project "Explain this project"
53
40
  ```
54
41
 
55
- From inside Kward, `/login` opens the same provider picker.
42
+ From inside Kward, `/login` lets you choose API-key or subscription authentication across supported providers. `/model` then switches providers, refreshes model catalogs, or accepts a manual model/deployment ID. Direct OpenAI API credentials and ChatGPT/Codex OAuth can coexist.
56
43
 
57
- See [Authentication](doc/authentication.md) for more details about sign-in options and provider credentials.
44
+ See [Model providers](doc/providers.md) to choose a backend and [Authentication](doc/authentication.md) for credential storage and login flows.
58
45
 
59
- ## What Kward can do
46
+ ## Common ways to use Kward
60
47
 
61
- - Keep a multi-turn coding conversation in your terminal.
62
- - Read, write, and edit workspace files with read-before-write guardrails.
63
- - Run local shell commands from the workspace.
64
- - Search the live web and inspect cached public GitHub repositories.
65
- - Save, resume, clone, compact, and export sessions.
66
- - Extend the Agent with trusted Ruby plugins for custom commands, footer UI, prompt context, and transcript-event observers.
67
- - Use optional memory, personas, prompt templates, and skills.
68
- - Serve a JSON-RPC backend for trusted local UI clients.
48
+ - Explore an unfamiliar codebase and keep useful discoveries for later sessions.
49
+ - Investigate a bug, make a focused change, and run the related tests.
50
+ - Review a diff, inspect the surrounding code, and commit from the terminal UI.
51
+ - Work on several tasks at once with tabs, branches, and linked Git worktrees.
52
+ - Teach Kward your project conventions with `AGENTS.md`, skills, prompt templates, and optional memory.
53
+ - Add trusted local behavior through plugins, lifecycle hooks, MCP servers, transports, or JSON-RPC integrations.
69
54
 
70
55
  ## Documentation
71
56
 
72
- Start here:
57
+ New to Kward:
73
58
 
74
59
  - [Getting started](doc/getting-started.md): first run, authentication choices, and basic commands.
75
60
  - [Usage](doc/usage.md): interactive chat, slash commands, sessions, tools, images, and Pan mode.
76
61
  - [Configuration](doc/configuration.md): config files, providers, models, web search, logging, and color output.
77
- - [Authentication](doc/authentication.md): OpenAI OAuth, Anthropic OAuth, OpenRouter API keys, and Copilot/GitHub setup.
62
+ - [Authentication](doc/authentication.md): multi-provider API keys, OpenAI/Anthropic subscription OAuth, Azure setup, and credential safety.
63
+ - [Model providers](doc/providers.md): compare providers and find their runtime IDs, model keys, environment variables, discovery behavior, and limitations.
64
+
65
+ Work safely:
66
+
78
67
  - [Security and trust](doc/security.md): local permissions, external data flow, trusted extensions, and safe work in unfamiliar repositories.
79
68
  - [Permissions](doc/permissions.md): opt-in tool approval, write scopes, policy rules, and current limits.
80
69
  - [Command sandboxing](doc/sandboxing.md): opt-in OS-enforced boundaries for model-requested shell commands.
81
70
  - [Troubleshooting](doc/troubleshooting.md): environment-specific install and runtime issues.
82
71
 
83
- Feature guides:
72
+ Everyday workflows:
84
73
 
85
74
  - [Sessions](doc/session-management.md): resume, clone, fork, rewind, compact, and navigate saved work.
86
75
  - [Interactive composer](doc/composer.md): use multiline input, completion, history, files, reasoning shortcuts, busy input, and images.
87
76
  - [Tabs](doc/tabs.md): keep several conversations open and run work in another tab.
88
77
  - [Project files](doc/files.md): browse, search, mention, open, and edit workspace files.
89
- - [Integrated Editor](doc/editor.md): open files from the shell or composer, edit in-place, and choose editor keybindings.
78
+ - [Integrated editor](doc/editor.md): open files from the shell or composer, edit in-place, and choose editor keybindings.
90
79
  - [Git](doc/git.md): review changes, use the diff viewer, stage files, and commit from the interactive TUI.
91
80
  - [Shell](doc/shell.md): use `/shell`, the embedded Kward shell with aliases, completion, and per-tab state.
92
81
  - [Memory](doc/memory.md): opt-in core, soft, and session memory.
93
82
  - [Personas](doc/personas.md): configure Kward's tone and role by default, workspace, model, reasoning effort, time, and weekday.
94
83
  - [Skills](doc/skills.md): add reusable instructions that load only for matching tasks.
84
+ - [Prompt templates](doc/prompt-templates.md): create reusable slash prompts and use the starter templates installed by `kward init`.
95
85
  - [MCP servers](doc/mcp.md): connect trusted local Model Context Protocol tool servers.
96
86
  - [Pan mode](doc/pan.md): use the mobile-friendly browser interface on a trusted local network.
97
87
  - [Local models](doc/local-models.md): connect Ollama, LM Studio, or llama.cpp and use a minimal replacement prompt.
98
88
 
99
- Advanced:
89
+ Extend and integrate:
100
90
 
101
- - [Extensibility](doc/extensibility.md): `PRINCIPLES.md`, workspace `AGENTS.md`, skills, prompt templates, and extension choices.
91
+ - [Extensibility](doc/extensibility.md): choose between `PRINCIPLES.md`, workspace `AGENTS.md`, skills, prompt templates, and other extension points.
102
92
  - [Plugins](doc/plugins.md): trusted Ruby plugins for commands, footer UI, prompt context, transcript events, and RPC clients.
103
93
  - [Lifecycle hooks](doc/lifecycle-hooks.md): deterministic runtime hooks for policy, approvals, automation, and command-hook integrations.
104
94
  - [RPC protocol](doc/rpc.md): JSON-RPC backend mode for trusted local UI clients.
105
95
  - [Releasing](doc/releasing.md): release checklist for RubyGems publishing.
96
+
97
+ Reference guides:
98
+
106
99
  - [Agent tools](doc/agent-tools.md): overview of model-callable tools, token-saving behavior, and tool categories.
107
100
  - [Workspace tools](doc/workspace-tools.md): local file, edit, and shell command tools.
108
101
  - [Context budgeting](doc/context-budgeting.md): focused context gathering, budgeted reads, output compaction, and token-saving history.
@@ -110,9 +103,9 @@ Advanced:
110
103
  - [Code search](doc/code-search.md): package lookup, GitHub repository cache, and external source reading for the code search agent tool.
111
104
  - [Context tools](doc/context-tools.md): skills, compacted output retrieval, and structured clarification questions.
112
105
 
113
- API reference:
106
+ Generated Ruby API:
114
107
 
115
- - [API reference](doc/api.md): generated Ruby API entry points, indexes, and public API expectations.
108
+ - [API reference](doc/api.md): generated Ruby API entry points, indexes, and supported API expectations.
116
109
 
117
110
  ## Development
118
111
 
data/doc/agent-tools.md CHANGED
@@ -2,14 +2,13 @@
2
2
 
3
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
4
 
5
- Tools are part of Kward's safety and context-management boundary:
5
+ Tools also enforce important boundaries:
6
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 (see [Configuration](configuration.md) for the guardrail setting),
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.
7
+ - Kward validates every tool call before running it.
8
+ - Workspace tools stay inside the active workspace by default (see [Configuration](configuration.md) for the guardrail setting).
9
+ - File-changing tools require the file to be read first.
10
+ - Large outputs are bounded or compacted before they enter model context.
11
+ - Full tool outputs remain available in the session record for later inspection.
13
12
 
14
13
  ## Tool categories
15
14
 
@@ -22,7 +21,7 @@ Tools are part of Kward's safety and context-management boundary:
22
21
 
23
22
  ## How tools save tokens
24
23
 
25
- Kward tries to keep tool context useful without flooding the model. The built-in prompt tells Kward to start with focused context tools and escalate from outlines/previews to exact ranges before full-file reads:
24
+ Kward tries to gather enough evidence without flooding the conversation. It usually starts with focused context tools, then moves from outlines and previews to exact ranges or full files only when needed:
26
25
 
27
26
  - `read_file` reads bounded line ranges, supports continuation with `offset` and `limit`, and accepts explicit `preview`, `outline`, `range`, and `full` modes with optional per-call byte budgets.
28
27
  - `context_for_task` builds a task-shaped bundle from ranked files, outlines, and matching excerpts within a caller-supplied byte budget.
@@ -32,9 +31,9 @@ Kward tries to keep tool context useful without flooding the model. The built-in
32
31
  - Repeated identical tool output is replaced with a short reference instead of being sent again.
33
32
  - Compacted outputs are stored as artifacts that can be reopened with `retrieve_tool_output`, including after resuming a saved session that contains the original tool execution record.
34
33
 
35
- When a tool output exceeds 12 KB, Kward compacts it before sending it to the model. The compactor preserves the first 40 and last 40 lines, keeps lines matching error, test, or search-result patterns with 2 lines of surrounding context, and replaces omitted sections with `[... omitted lines ...]` markers. Shell command output is section-aware: STDOUT and STDERR sections are compacted separately. Compacted outputs include a header with the original and compacted byte counts and the artifact ID for retrieval. Error outputs under 8 KB are left intact so failure details stay visible.
34
+ When output exceeds 12 KB, Kward keeps the most useful sections in context and stores the original output for later retrieval. The compacted result includes an artifact ID, so Kward can reopen an exact section without repeating the tool call. Error output under 8 KB stays intact so useful failure details are not lost.
36
35
 
37
- This lets the assistant reason from focused evidence while preserving access to original outputs when needed. For a fuller overview of Kward's context budgeting and token-saving work, see [Context budgeting](context-budgeting.md).
36
+ See [Context budgeting](context-budgeting.md) for the full compaction strategy, limits, and token-saving workflow.
38
37
 
39
38
  ## How tools are exposed
40
39
 
data/doc/api.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # API reference
2
2
 
3
- Kward's generated Ruby API documentation is mainly for contributors, plugin authors, tool authors, and people building RPC or editor integrations.
3
+ Kward's generated Ruby API documentation is for contributors, plugin authors, tool authors, and people building RPC or editor integrations.
4
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.
5
+ If you use Kward from the terminal, start with the [user guides](file.README.html#Documentation). This reference also includes internal classes and methods that may change. Treat the behavior described in the guides, the Plugin DSL, and the methods in the [RPC protocol](rpc.md) as Kward's supported public interfaces.
6
6
 
7
7
  ## Start here
8
8
 
@@ -84,7 +84,7 @@ The generated comments focus on these supported extension boundaries rather than
84
84
 
85
85
  ## Public API expectations
86
86
 
87
- 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.
87
+ The generated reference is useful for understanding the codebase, but it does not make every class, method, or constructor a supported public API.
88
88
 
89
89
  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.
90
90
 
@@ -1,181 +1,150 @@
1
1
  # Authentication
2
2
 
3
- Kward needs access to a model provider before it can answer prompts. The fastest path is:
3
+ Kward can keep credentials for several model providers at once. First connect an account or API key, then use `/model` to choose the provider and model for your work. See [Model providers](providers.md) to compare providers and find their configuration names and environment variables.
4
4
 
5
- ```bash
6
- kward login
7
- ```
8
-
9
- Or inside interactive Kward:
5
+ The easiest setup is inside interactive Kward:
10
6
 
11
7
  ```text
12
8
  /login
13
9
  ```
14
10
 
15
- `/login` opens a provider picker; `kward login` accepts the provider as an argument.
11
+ Choose **API key** or **Subscription / OAuth**, then choose a provider. After login, open:
16
12
 
17
- Use the provider you already have access to. You can change the active model later with `/model`.
18
-
19
- ## Choose a provider
20
-
21
- | Provider | Use it when... |
22
- | --- | --- |
23
- | OpenAI/ChatGPT | You want the default Codex backend with a ChatGPT account. |
24
- | Anthropic | You have Claude Pro/Max and want to use Claude through Kward. |
25
- | OpenRouter | You want to use an OpenRouter API key and choose from its model catalog. |
26
- | Copilot | You want to try experimental Copilot provider support. |
13
+ ```text
14
+ /model
15
+ ```
27
16
 
28
- If you are unsure, start with `kward login` and choose OpenAI.
17
+ ## Supported authentication
29
18
 
30
- ## Login commands
19
+ | Provider | API key | Subscription / OAuth |
20
+ | --- | --- | --- |
21
+ | OpenAI | Yes, direct OpenAI API | Yes, ChatGPT/Codex |
22
+ | Anthropic | Yes, direct Anthropic API | Yes, Claude Pro/Max |
23
+ | Azure OpenAI | Yes; endpoint, deployment, and API version are also required | No |
24
+ | Google Gemini | Yes | No |
25
+ | Cerebras, DeepSeek, Fireworks AI, Groq, Mistral, NVIDIA NIM, Together AI | Yes | No |
26
+ | OpenRouter | Yes | Not yet in Kward |
27
+ | xAI | Yes | No supported third-party flow |
28
+ | GitHub Copilot | No API-key mode | Yes |
31
29
 
32
- ```bash
33
- kward login # OpenAI/ChatGPT OAuth
34
- kward login anthropic # Anthropic Claude Pro/Max OAuth
35
- kward login openrouter # OpenRouter API key
36
- kward login github # GitHub OAuth for experimental Copilot support
37
- ```
30
+ Direct OpenAI API credentials and ChatGPT/Codex OAuth are independent. You can keep both and switch between **OpenAI** and **Codex** in `/model`.
38
31
 
39
- ## OpenAI / ChatGPT
32
+ ## API-key workflow
40
33
 
41
- ```bash
42
- kward login
43
- ```
44
-
45
- This opens a browser login and saves credentials to:
34
+ From `/login`, choose **API key** and the provider. Kward validates providers with live model discovery before saving the key, then stores it in:
46
35
 
47
36
  ```text
48
- ~/.kward/auth.json
37
+ ~/.kward/api_keys.json
49
38
  ```
50
39
 
51
- Kward uses the ChatGPT/Codex backend, not the OpenAI Platform API key flow.
40
+ The file is private (`0600` when supported). It is separate from `config.json`, so normal config reads and RPC responses do not return keys.
52
41
 
53
- If Kward asks for an OAuth client ID, add it to `~/.kward/config.json`:
42
+ For providers that do not also offer subscription login, the shell command is convenient:
54
43
 
55
- ```json
56
- {
57
- "openai_oauth_client_id": "your-client-id"
58
- }
44
+ ```bash
45
+ kward login groq
46
+ kward login gemini
47
+ kward login openrouter
48
+ kward login azure_openai
59
49
  ```
60
50
 
61
- Kward ships with a built-in client ID, so this is only needed if login fails or you want to use your own.
51
+ Use the interactive `/login` method picker for direct OpenAI or Anthropic API keys because `kward login openai` and `kward login anthropic` retain their subscription-login behavior.
62
52
 
63
- For a single shell session without OAuth, you can set an access token directly:
53
+ Environment variables override a stored key for that provider:
64
54
 
65
55
  ```bash
66
- OPENAI_ACCESS_TOKEN=... kward
56
+ OPENAI_API_KEY=... kward
57
+ GEMINI_API_KEY=... kward
58
+ GROQ_API_KEY=... kward
67
59
  ```
68
60
 
69
- ## Anthropic Claude Pro/Max
61
+ Other supported variables are listed in [Configuration](configuration.md#Environment_overrides).
70
62
 
71
- ```bash
72
- kward login anthropic
73
- ```
63
+ ### Azure OpenAI
74
64
 
75
- This saves credentials to:
65
+ Azure setup asks for three non-secret values after the key:
76
66
 
77
- ```text
78
- ~/.kward/anthropic_auth.json
79
- ```
67
+ - an HTTPS endpoint, such as `https://example.openai.azure.com`;
68
+ - a deployment name;
69
+ - an API version, such as `2025-04-01-preview`.
80
70
 
81
- Use this when you want Kward to use your Claude Pro/Max subscription. Kward refreshes the access token when a refresh token is available.
71
+ Kward rejects endpoint credentials, query strings, fragments, and unsafe deployment/version characters. The deployment is the model shown in `/model`; Kward does not claim to discover Azure deployments from an inference key.
82
72
 
83
- ## OpenRouter
73
+ ## ChatGPT / Codex OAuth
84
74
 
85
75
  ```bash
86
- kward login openrouter
76
+ kward login
87
77
  ```
88
78
 
89
- This stores your API key in `~/.kward/config.json`.
79
+ Credentials are saved to `~/.kward/auth.json`. This uses the ChatGPT/Codex backend, not `OPENAI_API_KEY` or the public OpenAI API endpoint.
90
80
 
91
- For a single shell session, you can avoid saving the key:
81
+ For one shell session, you can provide the Codex access token directly:
92
82
 
93
83
  ```bash
94
- OPENROUTER_API_KEY=sk-or-v1-... kward
84
+ OPENAI_ACCESS_TOKEN=... kward
95
85
  ```
96
86
 
97
- Choose OpenRouter when you want access to its model catalog or want provider/model selection through an API key.
98
-
99
- ### Refresh the OpenRouter model cache
87
+ `OPENAI_ACCESS_TOKEN` continues to mean Codex OAuth. `OPENAI_API_KEY` means direct OpenAI API access; neither replaces the other.
100
88
 
101
- Kward's `/model` picker can show OpenRouter models that are available to your API key. Refresh the local cache after logging in:
89
+ ## Anthropic Claude Pro/Max
102
90
 
103
91
  ```bash
104
- kward openrouter refresh
105
- ```
106
-
107
- This fetches text-capable OpenRouter models for the configured key and writes them to:
108
-
109
- ```text
110
- ~/.kward/cache/openrouter_models.json
92
+ kward login anthropic
111
93
  ```
112
94
 
113
- If `KWARD_CONFIG_PATH` points at a custom config file, the cache is written beside that config file under `cache/openrouter_models.json`.
95
+ OAuth credentials are saved to `~/.kward/anthropic_auth.json`. Kward refreshes the access token when a refresh token is available. Choose **API key** in `/login` instead when you want direct Anthropic API billing.
114
96
 
115
- Inspect the cached model ids with:
97
+ ## GitHub Copilot
116
98
 
117
99
  ```bash
118
- kward openrouter list
100
+ kward login github
119
101
  ```
120
102
 
121
- Use this when:
103
+ Credentials are saved to `~/.kward/github_auth.json`. For one run, use `COPILOT_GITHUB_TOKEN`. General `GH_TOKEN` and `GITHUB_TOKEN` values are not treated as Copilot credentials.
122
104
 
123
- - you added or changed your OpenRouter API key,
124
- - OpenRouter added new models,
125
- - your model picker does not show the model you expect,
126
- - you want Kward to use current context-window metadata from OpenRouter.
127
-
128
- After refreshing, start Kward and choose the model with `/model`.
105
+ ## OpenRouter
129
106
 
130
- ## Experimental Copilot support
107
+ API-key login is supported, including model refresh:
131
108
 
132
109
  ```bash
133
- kward login github
110
+ kward login openrouter
111
+ kward openrouter refresh
112
+ kward openrouter list
134
113
  ```
135
114
 
136
- This saves GitHub OAuth credentials to:
115
+ The cache lives at `<config-dir>/cache/openrouter_models.json`. `/model` can also refresh the active provider directly.
137
116
 
138
- ```text
139
- ~/.kward/github_auth.json
140
- ```
117
+ OpenRouter documents an official [OAuth PKCE flow](https://openrouter.ai/docs/guides/overview/auth/oauth), but Kward does not implement that flow yet. It remains unavailable in CLI and RPC capabilities rather than exposing an unverified partial login.
141
118
 
142
- You can also use a token for one run:
119
+ xAI's public inference documentation currently directs clients to API keys (see the [xAI quickstart](https://docs.x.ai/developers/quickstart)); Kward does not expose an xAI subscription OAuth flow.
143
120
 
144
- ```bash
145
- COPILOT_GITHUB_TOKEN=... kward
146
- ```
121
+ ## Model selection
147
122
 
148
- Copilot support is experimental and uses direct HTTPS calls to the Copilot proxy API. It does not use the official Copilot CLI or SDK runtime.
123
+ The provider-aware `/model` picker offers:
149
124
 
150
- ## Choose the active model
125
+ - **Refresh model list**;
126
+ - **Enter model ID manually**;
127
+ - **Show all models**;
128
+ - **Change provider**.
151
129
 
152
- Authentication makes providers available. The active model is selected separately.
130
+ By default, Kward hides entries when provider metadata proves they are not generation/tool models. It keeps entries whose metadata is incomplete. **Show all models** and manual IDs remain available for previews, private deployments, and incomplete catalogs.
153
131
 
154
- Inside Kward, use:
132
+ ## Status and logout
155
133
 
156
- ```text
157
- /model
134
+ ```bash
135
+ kward auth status
136
+ kward auth logout
158
137
  ```
159
138
 
160
- The model picker is the normal way to switch between configured providers and models. You can keep credentials for multiple providers and choose the model you want for the current work.
161
-
162
- For one-off shell runs, `KWARD_PROVIDER` and provider-specific model environment variables remain available. See [Configuration](configuration.md) for the full list.
163
-
164
- ## Custom auth file locations
165
-
166
- Each auth file has an environment variable override, useful for isolated or multi-account setups. When unset, they default to the paths shown above under `~/.kward/`.
139
+ Status reports only whether credentials exist and where they came from; it never prints credential values. CLI logout removes all saved OAuth and API-key credentials. Environment variables remain active until you unset them.
167
140
 
168
- - `KWARD_AUTH_PATH` OpenAI OAuth credentials (`auth.json`)
169
- - `KWARD_ANTHROPIC_AUTH_PATH` — Anthropic OAuth credentials (`anthropic_auth.json`)
170
- - `KWARD_GITHUB_AUTH_PATH` — GitHub OAuth credentials (`github_auth.json`)
141
+ RPC clients can list catalog providers, inspect sanitized method availability, save/remove individual API keys, and remove a specific provider/auth method. See [RPC](rpc.md#Config_and_auth_methods).
171
142
 
172
- When `KWARD_CONFIG_PATH` points at a custom config file, the OpenRouter API key is stored in that file instead of `~/.kward/config.json`.
143
+ ## Custom locations
173
144
 
174
- ## Security notes
145
+ - `KWARD_CONFIG_PATH` moves `config.json`, `api_keys.json`, caches, and most other Kward state to that file's directory.
146
+ - `KWARD_AUTH_PATH` overrides ChatGPT/Codex OAuth storage.
147
+ - `KWARD_ANTHROPIC_AUTH_PATH` overrides Anthropic OAuth storage.
148
+ - `KWARD_GITHUB_AUTH_PATH` overrides GitHub Copilot OAuth storage.
175
149
 
176
- - Auth files are written with file mode `0600` when possible.
177
- - Do not commit `~/.kward/config.json` or auth files.
178
- - Prefer environment variables for temporary credentials.
179
- - `kward auth status` shows credential status without printing secrets.
180
- - `kward auth logout` removes **all** saved credentials at once: every OAuth file (OpenAI, Anthropic, GitHub) and the stored OpenRouter API key. There is no per-provider logout; to remove a single provider, delete its auth file by hand.
181
- - `kward doctor` reports which credentials are currently configured alongside other local checks.
150
+ Never commit credential files. For temporary credentials, prefer environment variables and unset them when finished.
data/doc/code-search.md CHANGED
@@ -29,7 +29,7 @@ The `code_search` tool can:
29
29
  4. search cached files,
30
30
  5. read bounded line ranges from cached files.
31
31
 
32
- Kward should use this when the best answer depends on how another project actually implemented something.
32
+ Kward uses code search when the best answer depends on how another project actually implemented something.
33
33
 
34
34
  ## Supported ecosystems
35
35
 
data/doc/composer.md CHANGED
@@ -99,7 +99,7 @@ The `$` token must begin at the first character of the composer. Use Up/Down to
99
99
 
100
100
  A successful `$path` open is saved in prompt history using the resolved workspace-relative path. It opens the editor instead of sending a model prompt.
101
101
 
102
- See [Integrated Editor](editor.md) for editing modes, save and quit keys, scratchpads, and conflict handling.
102
+ See [Integrated editor](editor.md) for editing modes, save and quit keys, scratchpads, and conflict handling.
103
103
 
104
104
  ## Reuse prompt history
105
105