openclacky 1.3.3 → 1.3.4

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 (58) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +26 -0
  3. data/docs/rich_ui_guide.md +277 -0
  4. data/docs/rich_ui_refactor_plan.md +396 -0
  5. data/lib/clacky/agent/llm_caller.rb +10 -4
  6. data/lib/clacky/agent/session_serializer.rb +3 -2
  7. data/lib/clacky/agent.rb +3 -2
  8. data/lib/clacky/agent_config.rb +2 -14
  9. data/lib/clacky/api_extension.rb +262 -0
  10. data/lib/clacky/api_extension_loader.rb +156 -0
  11. data/lib/clacky/cli.rb +93 -3
  12. data/lib/clacky/client.rb +38 -13
  13. data/lib/clacky/default_agents/_panels/git/panel.js +1 -1
  14. data/lib/clacky/default_agents/_panels/time_machine/panel.js +1 -1
  15. data/lib/clacky/default_skills/media-gen/SKILL.md +9 -6
  16. data/lib/clacky/idle_compression_timer.rb +3 -1
  17. data/lib/clacky/locales/en.rb +26 -0
  18. data/lib/clacky/locales/i18n.rb +26 -0
  19. data/lib/clacky/locales/zh.rb +26 -0
  20. data/lib/clacky/rich_ui/components/base_component.rb +50 -0
  21. data/lib/clacky/rich_ui/components/dialogs/approval_dialog.rb +142 -0
  22. data/lib/clacky/rich_ui/components/dialogs/config_menu_dialog.rb +106 -0
  23. data/lib/clacky/rich_ui/components/dialogs/form_dialog.rb +128 -0
  24. data/lib/clacky/rich_ui/components/sidebar.rb +119 -0
  25. data/lib/clacky/rich_ui/components/sidebar_panels.rb +134 -0
  26. data/lib/clacky/rich_ui/components/status_view.rb +58 -0
  27. data/lib/clacky/rich_ui/components/thinking_live_view.rb +79 -0
  28. data/lib/clacky/rich_ui/entry_tracker.rb +56 -0
  29. data/lib/clacky/rich_ui/layout_adapter.rb +16 -0
  30. data/lib/clacky/rich_ui/progress_handle_adapter.rb +24 -0
  31. data/lib/clacky/rich_ui/rich_ui_controller.rb +868 -0
  32. data/lib/clacky/rich_ui/shell/rich_agent_shell.rb +184 -0
  33. data/lib/clacky/rich_ui/view_renderer.rb +291 -0
  34. data/lib/clacky/rich_ui.rb +57 -0
  35. data/lib/clacky/rich_ui_controller.rb +3 -1549
  36. data/lib/clacky/server/api_extension_dispatcher.rb +120 -0
  37. data/lib/clacky/server/http_server.rb +150 -103
  38. data/lib/clacky/server/session_registry.rb +1 -1
  39. data/lib/clacky/shell_hook_loader.rb +1 -1
  40. data/lib/clacky/tools/edit.rb +14 -2
  41. data/lib/clacky/ui2/ui_controller.rb +7 -0
  42. data/lib/clacky/version.rb +1 -1
  43. data/lib/clacky/web/app.css +56 -59
  44. data/lib/clacky/web/app.js +65 -7
  45. data/lib/clacky/web/components/onboard.js +18 -2
  46. data/lib/clacky/web/core/aside.js +8 -3
  47. data/lib/clacky/web/core/ext.js +1 -1
  48. data/lib/clacky/web/features/skills/store.js +30 -2
  49. data/lib/clacky/web/features/skills/view.js +32 -1
  50. data/lib/clacky/web/features/workspace/view.js +1 -1
  51. data/lib/clacky/web/i18n.js +32 -20
  52. data/lib/clacky/web/index.html +9 -17
  53. data/lib/clacky/web/sessions.js +286 -28
  54. data/lib/clacky/web/settings.js +109 -111
  55. data/lib/clacky/web/ws-dispatcher.js +7 -3
  56. data/lib/clacky.rb +17 -2
  57. metadata +38 -2
  58. data/lib/clacky/media/output_dir.rb +0 -43
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6b9b4de98a5b98c110e4ee71bc8039c1b6445fda13f4479c42d466d80bb307bd
4
- data.tar.gz: b47e189d857b86955eb95253e0b873d1cad16f9dfcb5040e29e638134151b9a8
3
+ metadata.gz: 8d5879a7f2c6eb0a1846dd3049fa79abd3ca53119750bd0a43b337339f146dad
4
+ data.tar.gz: 12a39e3d860e9e9e691424289543b73813bcb4652e11fe0719e72aa9e6c72760
5
5
  SHA512:
6
- metadata.gz: 1ab60195873b54c48d72a4d6ebe5f79c9e5daeaa826f867c50cb79e5f6d367dd809b53ebe50aecd42af397cdd03962c0f0a5517ac2e94112b7399778d52c22ec
7
- data.tar.gz: c11638e5355fde8fc2ade76d7868f8b68f47722dada241abafd34adf5a61fc88d5b734292ded5cb97cbdb4bc6360c9fd7b84a77ebd9fe95ec156a8eb02828556
6
+ metadata.gz: cdb47cb9da7cccae4329aa0d4b98f03d9e5cadf763c12b9cd255060e2f230154eed3e7404e494f9a0b7e7b54cdb569f2dc25a1ea69c0b8af386a4a1122942d65
7
+ data.tar.gz: 196c48e418e2119201664b920871aa489ff3531128a8aa8b981f73d6ddc95a7d3ef23ecb79da0611810b8af02735f83340ce0712ddb18ad30de0f94421dbd0a4
data/CHANGELOG.md CHANGED
@@ -5,6 +5,32 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.3.4] - 2026-06-25
9
+
10
+ ### Added
11
+ - Skill edit UI with brand skill theme colors
12
+ - WebUI language preference propagated to backend for localized error messages
13
+ - Edit message resend with confirmation modal and localStorage key normalization
14
+ - Duplicate model card action
15
+ - i18n support for aside tab labels (files/git/time-machine)
16
+ - File picker defaults to workspace with mkdir/rename support and hardened validation
17
+ - API extensions and EPIPE rebuild client handling
18
+ - Ruby Rich enhancement and refactoring (runtime dependency added)
19
+
20
+ ### Improved
21
+ - Default aside panel to collapsed; sidebar widths aligned to 16rem
22
+ - Onboarding manual config UX and spacing improvements
23
+ - Fixed positioning for modal model/baseurl dropdowns to avoid overflow clipping
24
+ - Disable transition during aside resize drag
25
+ - Rename resetAfterUnbind to resetBrandState to avoid view/store collision
26
+
27
+ ### Fixed
28
+ - Edit tool performs literal replacement (C-5682)
29
+ - Shield code spans before math extraction to prevent LaTeX rendering (C-5635)
30
+ - Preserve updated_at on idle compression and session eviction; fix Today/Yesterday display bug
31
+ - Remove media output dir UI setting — always use session workspace
32
+ - Test: stub req.path and req.request_method in check_access_key loopback bypass spec
33
+
8
34
  ## [1.3.3] - 2026-06-23
9
35
 
10
36
  ### Added
@@ -0,0 +1,277 @@
1
+ # OpenClacky Rich UI Mode — Operations and Interface Display
2
+
3
+ > Source directory: `lib/clacky/rich_ui/`
4
+ > Terminal TUI interface built on the RubyRich library
5
+
6
+ ---
7
+
8
+ ## I. Overall Architecture
9
+
10
+ `lib/clacky/rich_ui` is OpenClacky's terminal TUI interface module, built on the `RubyRich` library, implementing a complete terminal user interaction interface. The core entry point is `RichUIController` (`rich_ui_controller.rb`), which manages layout, components, events, and lifecycle through `RichAgentShell`.
11
+
12
+ ---
13
+
14
+ ## II. Interface Layout (7-layer Zoning)
15
+
16
+ The interface is defined by the zoning layout in `RichAgentShell#build_layout`:
17
+
18
+ | Zone | Name | Description |
19
+ |------|------|-------------|
20
+ | Row 1 | **Header** | Top title bar, displays `OpenClacky` title/subtitle |
21
+ | Main body left | **Transcript** | Conversation viewport, displays user messages, assistant replies, tool calls, etc. |
22
+ | Main body right | **Sidebar** | Sidebar (36 columns wide), contains Work / Tasks / Context three panels |
23
+ | Main body bottom | **ThinkingLive** | Real-time thinking display area (dynamically appears/disappears, height 0 or 6 rows) |
24
+ | From row 6 | **Composer** | Input editor, with Framed border titled "Composer" |
25
+ | Last row | **Status** | Bottom status bar, displays current mode, model, task count, cost, etc. |
26
+
27
+ ---
28
+
29
+ ## III. Sidebar — Three Information Panels
30
+
31
+ The sidebar (`RichSidebar`, `components/sidebar.rb`) supports multiple display modes, switched via F1-F4 shortcuts:
32
+
33
+ - **F1 → Work panel**: Displays plan description, up to 8 recent tool activities (with status markers), task count and cost statistics
34
+ - **F2 → Tasks panel**: Displays the current task list (from `update_todos`), with completion progress (e.g. `3/5 done`), status markers:
35
+ - `✓` (green) = Completed
36
+ - `●` (blue) = In progress
37
+ - `!` (red) = Failed
38
+ - `○` (gray) = Pending
39
+ - **F3 → Auto mode**: Automatically displays all panels that have content
40
+ - **F4 → Context panel**: Displays Token usage details (prompt / output / total / cost)
41
+
42
+ Sidebar panels are implemented by `components/sidebar_panels.rb`:
43
+ - `RichWorkPanel`: Work progress panel
44
+ - `RichTasksPanel`: Task list panel
45
+ - `RichContextPanel`: Context / Token info panel
46
+
47
+ ---
48
+
49
+ ## IV. Bottom Status Bar
50
+
51
+ `RichStatusView` (`components/status_view.rb`) renders a single row of status information at the very bottom of the terminal:
52
+
53
+ - **Idle state**: Shows mode name + "idle" + model name + task count + cost + "Ctrl+C quit"
54
+ - **Working**: Shows rotating spinner animation + current tool name (e.g. "web_search…") + model/latency + task count + cost
55
+ - **Ctrl+C warning**: Red prompt "Press Ctrl+C again to exit"
56
+ - Latency info is appended after the model name (format: `model_name (1.2s)`)
57
+
58
+ ---
59
+
60
+ ## V. Transcript — Operations and Display
61
+
62
+ ### 5.1 Message Display
63
+
64
+ - **User messages**: Displayed directly in the conversation area
65
+ - **Assistant replies**: Rendered in Markdown format (supports code blocks, tables, lists, etc.)
66
+ - Long text (≥240 characters) triggers **streaming rendering**: 6 characters per chunk, 0.03s interval, appearing progressively
67
+ - File summaries are automatically appended at the end of replies (e.g. `Files - path/to/file.rb`)
68
+ - **System messages**: Regular info / warning / error displayed in different colors
69
+ - **Welcome banner**: On first launch, displays `WelcomeBanner` containing working directory, mode, etc.; if there is session history, shows a "recent session" separator and the last user message
70
+
71
+ ### 5.2 Thinking Process Display (Two Phases)
72
+
73
+ 1. **Live phase**: `ThinkingLiveView` (`components/thinking_live_view.rb`) dynamically appears (occupying 6 rows), renders thinking content character by character in real time, with a rotating spinner and elapsed time counter, stays for about 0.6s after completion
74
+ 2. **Collapsed phase**: Thinking content is retained in the conversation area as a collapsed block (marked "Xs"), press Ctrl+O to expand and view
75
+
76
+ ### 5.3 Tool Call Display
77
+
78
+ Each tool call process is visualized in three steps:
79
+
80
+ - **Start**: Insert a `running` status entry in the conversation area, displaying tool name and parameters (truncated as needed, e.g. `web_search("query...")`, `web_fetch(hostname)`)
81
+ - **Complete**: Update entry status to `done` (green `[OK]`), with output content appended
82
+ - **Error**: Update entry status to `error` (red `[Error]`), with error message appended
83
+
84
+ Tool activities are simultaneously synced to the sidebar Work panel (up to 12 entries recorded).
85
+
86
+ ### 5.4 Diff Display
87
+
88
+ Through the `show_diff` method, using the `Diffy` library to generate unified format diffs, truncated to 50 visible lines (excess lines indicate hidden count), with stats appended (e.g. `+5, -3, 2 hunks`).
89
+
90
+ ### 5.5 Token Usage Display
91
+
92
+ `show_token_usage` displays prompt/output/total token counts and cost estimates in the conversation area, while syncing to the sidebar Context panel.
93
+
94
+ ### 5.6 Text Selection and Copy
95
+
96
+ `ViewportSelection` (`extensions/viewport_selection.rb`) extends `RubyRich::Viewport`, supporting:
97
+
98
+ - **Mouse selection**: Left-click drag to select text, highlighted with reverse color
99
+ - **Right-click copy**: Copy selected text to system clipboard
100
+ - **Multi-platform clipboard support**: Linux (wl-copy / xclip / xsel), macOS (pbcopy), Windows, with OSC 52 terminal protocol fallback
101
+
102
+ ### 5.7 Table Rendering Optimization
103
+
104
+ `MarkdownTableAdapter` (`extensions/markdown_table_adapter.rb`) extends RubyRich's Markdown converter, enabling tables to adapt to terminal width: calculating natural column widths, proportionally compressing columns when exceeding terminal width, and auto-wrapping long text.
105
+
106
+ ---
107
+
108
+ ## VI. Composer (Input Area) — Operations
109
+
110
+ ### 6.1 Basic Operations
111
+
112
+ - **Text input**: Single-line editor, `Shift+Enter` for newline
113
+ - **History navigation**: Up/down arrows to browse message history
114
+ - **Vim scrolling**: Type `/vim` to toggle, enabling `j`/`k` to scroll the conversation area in single-line mode
115
+ - **Clear**: `Ctrl+C` first press interrupts current task, second press exits; `Esc` multi-layer cancel (see below)
116
+
117
+ ### 6.2 Slash Commands
118
+
119
+ Built-in commands trigger a dropdown menu via `/`:
120
+
121
+ | Command | Description |
122
+ |---------|-------------|
123
+ | `/clear` | Clear output and restart session |
124
+ | `/config` | Open model configuration dialog |
125
+ | `/undo` | Restore previous task state |
126
+ | `/help` | Show help information |
127
+ | `/exit` | Exit application |
128
+ | `/model` | Switch LLM model |
129
+
130
+ Skill slash commands are also dynamically registered in the Composer menu, with descriptions truncated to 50 characters.
131
+
132
+ ### 6.3 Esc Multi-Layer Cancel Stack
133
+
134
+ Pressing `Esc` processes in priority order:
135
+
136
+ 1. Close any open dialog (if present)
137
+ 2. Close slash menu (if open)
138
+ 3. Interrupt running task
139
+ 4. Clear input field text (Composer native behavior)
140
+
141
+ ---
142
+
143
+ ## VII. Dialog System
144
+
145
+ RichUI provides three dialog types, all running in blocking mode (calling `show_blocking_dialog`):
146
+
147
+ ### 7.1 Approval Dialog (ApprovalDialog)
148
+
149
+ File: `components/dialogs/approval_dialog.rb`
150
+
151
+ Security confirmation before tool execution, displaying:
152
+ - **Tool name** + category badge (File/Shell/Network/Paid, different colors)
153
+ - **Risk level**: Low (green), Medium (yellow), High (yellow), Critical (red), with `●○○○` style progress bar
154
+ - **Tool info** and parameter details
155
+ - Three action buttons: `Approve`, `Deny`, `Always allow` (fingerprint whitelist)
156
+
157
+ Navigation: `←`/`→` or `h`/`l` to switch options, `Enter` to confirm, `Esc` to deny.
158
+
159
+ ### 7.2 Configuration Menu Dialog (ConfigMenuDialog)
160
+
161
+ File: `components/dialogs/config_menu_dialog.rb`
162
+
163
+ Opened by `/config` command, for model management:
164
+ - Lists all configured models (showing API Key mask, type labels)
165
+ - Actions: Switch model / Add new model / Edit current model / Delete model / Close
166
+ - When adding a model, first select Provider (pre-configured vs custom), then fill in API Key, Model name, Base URL form
167
+ - Connection test verification available after adding/editing
168
+
169
+ Navigation: `↑`/`↓` or `j`/`k` to move, `Enter` to select, `q`/`Esc` to cancel.
170
+
171
+ ### 7.3 Form Dialog (FormDialog)
172
+
173
+ File: `components/dialogs/form_dialog.rb`
174
+
175
+ General-purpose form input, used for model editing and similar scenarios:
176
+ - Supports multiple fields (with labels, default values, placeholders, password masking)
177
+ - Focused field shows `➜` marker
178
+ - Navigation: `↑`/`↓`/`Tab`/`Shift+Tab` to switch fields, `Enter` to submit, `Esc` to cancel
179
+
180
+ ### 7.4 Model Switch Dialog
181
+
182
+ Triggered by `/model` command, two-step operation:
183
+ 1. Select target model from the available model list
184
+ 2. Choose scope: current session only / save permanently
185
+
186
+ ---
187
+
188
+ ## VIII. Keyboard Shortcut Overview
189
+
190
+ | Shortcut | Scope | Function |
191
+ |----------|-------|----------|
192
+ | `Ctrl+C` | Global (within 1s) | Interrupt current task |
193
+ | `Ctrl+C` | Global (after 1s) | Exit program |
194
+ | `Ctrl+M` | Global (within 2s) | Toggle permission mode (confirm_safes ↔ confirm_all) |
195
+ | `Tab` | Global | Toggle permission mode + refocus Composer |
196
+ | `F1` | Global | Sidebar → Work panel |
197
+ | `F2` | Global | Sidebar → Tasks panel |
198
+ | `F3` | Global | Sidebar → Auto mode |
199
+ | `F4` | Global | Sidebar → Context panel |
200
+ | `Esc` | Global | Multi-layer cancel (dialog→menu→interrupt→clear input) |
201
+ | `Shift+Enter` | Composer | Newline |
202
+ | `↑`/`↓` | Composer | History message navigation |
203
+ | `j`/`k` | Composer (single-line mode) | Scroll conversation area |
204
+ | `Ctrl+O` | Transcript | Expand/collapse thinking block |
205
+ | Left-click drag | Transcript | Select text |
206
+ | Right-click | Transcript | Copy selected text |
207
+
208
+ ---
209
+
210
+ ## IX. Auxiliary Modules
211
+
212
+ | Module | File | Function |
213
+ |--------|------|----------|
214
+ | **ViewRenderer** | `view_renderer.rb` | Tool output formatting (`[OK]`/`[Error]`), parameter truncation, tool activity label generation, Diff stat parsing, thinking text extraction, API Key masking, config menu option building, model form validation |
215
+ | **EntryTracker** | `entry_tracker.rb` | Lightweight ID tracker, maintains tool call stack (push/pop), ensures correct pairing of tool calls and results |
216
+ | **LayoutAdapter** | `layout_adapter.rb` | Layout adapter, provides `clear_output` to clear conversation area |
217
+ | **ProgressHandleAdapter** | `progress_handle_adapter.rb` | Wraps RubyRich progress handler, provides `update` / `finish` / `cancel` interface |
218
+ | **BaseComponent** | `components/base_component.rb` | Component base class, provides shared rendering methods: `muted`/`colored`/`status_marker`/`truncate`/`theme` |
219
+ | **TranscriptPlain** | `extensions/transcript_plain.rb` | Extends Transcript, supports `plain: true` marked plain text entries (for welcome banner, etc.) |
220
+ | **MarkdownTableAdapter** | `extensions/markdown_table_adapter.rb` | Monkey patch extending Kramdown-to-RubyRich table conversion, implementing terminal-width-adaptive table wrapping |
221
+ | **ViewportSelection** | `extensions/viewport_selection.rb` | Extends viewport, supports text selection and multi-platform clipboard copy |
222
+
223
+ ---
224
+
225
+ ## X. Key Rendering Constants
226
+
227
+ | Constant | Value | Description |
228
+ |----------|-------|-------------|
229
+ | `STREAMING_MARKDOWN_THRESHOLD` | 240 chars | Triggers streaming rendering when exceeded |
230
+ | `STREAMING_MARKDOWN_CHUNK_SIZE` | 6 chars/chunk | Streaming rendering chunk size |
231
+ | `STREAMING_MARKDOWN_DELAY` | 0.03s | Streaming rendering interval |
232
+ | Thinking streaming chunk size | 3 chars/chunk | Thinking content streaming display chunk size |
233
+ | Thinking streaming delay | 0.008s | Thinking content streaming display interval |
234
+ | `SKILL_DESC_MAX` | 50 chars | Skill description truncation length in menu |
235
+ | Tool activity record limit | 12 entries | Max entries in sidebar Work panel |
236
+ | Diff visible lines | 50 lines | Default max display lines for `show_diff` |
237
+ | Tool label truncation | 40 chars | Truncation length for tool call parameter labels |
238
+
239
+ ---
240
+
241
+ ## XI. Source File Listing
242
+
243
+ ```
244
+ lib/clacky/rich_ui/
245
+ ├── rich_ui_controller.rb # Core controller (824 lines)
246
+ ├── view_renderer.rb # View rendering helper module (291 lines)
247
+ ├── entry_tracker.rb # Entry ID tracker
248
+ ├── layout_adapter.rb # Layout adapter
249
+ ├── progress_handle_adapter.rb # Progress handler adapter
250
+ ├── shell/
251
+ │ └── rich_agent_shell.rb # AgentShell in Rich mode
252
+ ├── components/
253
+ │ ├── base_component.rb # Base component module
254
+ │ ├── sidebar.rb # Sidebar
255
+ │ ├── sidebar_panels.rb # Sidebar panels (Work/Tasks/Context)
256
+ │ ├── status_view.rb # Status view (bottom status bar)
257
+ │ ├── thinking_live_view.rb # Real-time thinking view
258
+ │ └── dialogs/
259
+ │ ├── approval_dialog.rb # Approval dialog
260
+ │ ├── form_dialog.rb # Form dialog
261
+ │ └── config_menu_dialog.rb # Configuration menu dialog
262
+ └── extensions/
263
+ ├── markdown_table_adapter.rb # Markdown table adapter
264
+ ├── transcript_plain.rb # Plain text transcript extension
265
+ └── viewport_selection.rb # Viewport text selection extension
266
+ ```
267
+
268
+ ## XII. Lifecycle
269
+
270
+ 1. `RichUIController#initialize` — Initializes configuration, creates `RichAgentShell`, `LayoutAdapter`, `EntryTracker`, binds callbacks
271
+ 2. `initialize_and_show_banner` — Sets `running=true`, displays welcome banner or session history
272
+ 3. `start` → `start_input_loop` → `@shell.start` — Enters terminal event loop
273
+ 4. User submits input → `on_submit` callback → `@input_callback` → CLI → Agent
274
+ 5. Agent response → `show_assistant_message` (thinking streaming + Markdown rendering)
275
+ 6. Tool calls → `show_tool_call` / `show_tool_result` / `show_tool_error`
276
+ 7. Task complete → `show_complete`, updates status bar and sidebar
277
+ 8. `stop` — Exits event loop, optional screen clear