openclacky 0.5.6 → 0.6.1

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 (48) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +71 -0
  3. data/docs/ui2-architecture.md +124 -0
  4. data/lib/clacky/agent.rb +376 -346
  5. data/lib/clacky/agent_config.rb +1 -7
  6. data/lib/clacky/cli.rb +167 -398
  7. data/lib/clacky/client.rb +68 -36
  8. data/lib/clacky/gitignore_parser.rb +26 -12
  9. data/lib/clacky/model_pricing.rb +6 -2
  10. data/lib/clacky/session_manager.rb +6 -2
  11. data/lib/clacky/tools/glob.rb +66 -10
  12. data/lib/clacky/tools/grep.rb +6 -122
  13. data/lib/clacky/tools/run_project.rb +10 -5
  14. data/lib/clacky/tools/safe_shell.rb +149 -20
  15. data/lib/clacky/tools/shell.rb +3 -51
  16. data/lib/clacky/tools/todo_manager.rb +50 -3
  17. data/lib/clacky/tools/trash_manager.rb +1 -1
  18. data/lib/clacky/tools/web_fetch.rb +4 -4
  19. data/lib/clacky/tools/web_search.rb +40 -28
  20. data/lib/clacky/ui2/README.md +214 -0
  21. data/lib/clacky/ui2/components/base_component.rb +163 -0
  22. data/lib/clacky/ui2/components/common_component.rb +98 -0
  23. data/lib/clacky/ui2/components/inline_input.rb +187 -0
  24. data/lib/clacky/ui2/components/input_area.rb +1124 -0
  25. data/lib/clacky/ui2/components/message_component.rb +80 -0
  26. data/lib/clacky/ui2/components/output_area.rb +112 -0
  27. data/lib/clacky/ui2/components/todo_area.rb +130 -0
  28. data/lib/clacky/ui2/components/tool_component.rb +106 -0
  29. data/lib/clacky/ui2/components/welcome_banner.rb +103 -0
  30. data/lib/clacky/ui2/layout_manager.rb +437 -0
  31. data/lib/clacky/ui2/line_editor.rb +201 -0
  32. data/lib/clacky/ui2/markdown_renderer.rb +80 -0
  33. data/lib/clacky/ui2/screen_buffer.rb +257 -0
  34. data/lib/clacky/ui2/theme_manager.rb +68 -0
  35. data/lib/clacky/ui2/themes/base_theme.rb +85 -0
  36. data/lib/clacky/ui2/themes/hacker_theme.rb +58 -0
  37. data/lib/clacky/ui2/themes/minimal_theme.rb +52 -0
  38. data/lib/clacky/ui2/ui_controller.rb +778 -0
  39. data/lib/clacky/ui2/view_renderer.rb +177 -0
  40. data/lib/clacky/ui2.rb +37 -0
  41. data/lib/clacky/utils/file_ignore_helper.rb +126 -0
  42. data/lib/clacky/version.rb +1 -1
  43. data/lib/clacky.rb +1 -6
  44. metadata +53 -6
  45. data/lib/clacky/ui/banner.rb +0 -155
  46. data/lib/clacky/ui/enhanced_prompt.rb +0 -786
  47. data/lib/clacky/ui/formatter.rb +0 -209
  48. data/lib/clacky/ui/statusbar.rb +0 -96
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 34f843ea474327ea95f88685111f1a86149730503625c5e971de239e63764969
4
- data.tar.gz: 85f2e93d791d3f774aa4f0d29177d4999fd91306f3c441f21d89c11ab37f15d0
3
+ metadata.gz: 9c052d03a1c67251ddb1310bd82b4d1bbee0129716f4e0f2ec664dfdf3b52ced
4
+ data.tar.gz: 1d04af0f03f0e03e5ef41a312b2074a8b53a57d2fc9b38f95e73fe3baed3ffd4
5
5
  SHA512:
6
- metadata.gz: 8bcb13d8cb5ee790ff698fc9bd0be4d2b366e1d16216db6a2f24e56c0dc1954c3b82349473b49cdee7c66ae732e3b684ee1d249d54dabe0f7d9cb0cf1f59873b
7
- data.tar.gz: 866e043424ca831364baba5a842b5554cc1da2309e2935a0458edbead75c5e89f9cdf146506df12fc04c87d78c5613e3b2e812b13a816864af5861b1f815c788
6
+ metadata.gz: 6a78384406082c30a41e3546b145230276532567664e2fcf2d6de579a7765966d9ce837629c24b1e35e27f5b9a60b7e1337d6f95981665f74cc99cdee52773ef
7
+ data.tar.gz: 6da58385006861fcb511c56febf1a0c81d5f30825354e3610201ea2b4c53a29f0d65fd41cf89447c9347c396de4dadb77f7139e4a69d19d0f5debcc986e5536f
data/CHANGELOG.md CHANGED
@@ -7,6 +7,77 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.6.1] - 2026-01-29
11
+
12
+ ### Added
13
+ - User tips for better guidance and feedback
14
+ - Batch TODO operations for improved task management
15
+ - Markdown output support for better formatted responses
16
+ - Text style customization options
17
+
18
+ ### Improved
19
+ - Tool execution with slow progress indicators for long-running operations
20
+ - Progress UI refinements for better visual feedback
21
+ - Session restore now shows recent messages for context
22
+ - TODO area UI enhancements with auto-hide when all tasks completed
23
+ - Work status bar styling improvements
24
+ - Text wrapping when moving input to output area
25
+ - Safe shell output improvements for better readability
26
+ - Task info display optimization (only show essential information)
27
+ - TODO list cleanup and organization
28
+
29
+ ### Fixed
30
+ - Double paste bug causing duplicate input
31
+ - Double error message display issue
32
+ - TODO clear functionality
33
+ - RSpec test hanging issues
34
+
35
+ ### Removed
36
+ - Tool emoji from output for cleaner display
37
+
38
+ ## [0.6.0] - 2026-01-28
39
+
40
+ ### Added
41
+ - **New UI System (UI2)**: Complete component-based UI rewrite with modular architecture (InputArea, OutputArea, TodoArea, ToolComponent, ScreenBuffer, LayoutManager)
42
+ - **Slash Commands**: `/help`, `/clear`, `/exit` for quick actions
43
+ - **Prompt Caching**: Significantly improved performance and reduced API costs
44
+ - **Theme System**: Support for multiple UI themes (base, hacker, minimal)
45
+ - **Session Management**: Auto-keep last 10 sessions with datetime naming
46
+
47
+ ### Improved
48
+ - Advanced inline input with Unicode support, multi-line handling, smooth scrolling, and rapid paste detection
49
+ - Better terminal resize handling and flicker-free rendering
50
+ - Work/idle status indicators with token cost display
51
+ - Enhanced tool execution feedback and multiple tool rejection handling
52
+ - Tool improvements: glob limits, grep performance, safe shell security, UTF-8 encoding fixes
53
+
54
+ ### Fixed
55
+ - Input flickering, output scrolling, Ctrl+C behavior, image copying, base64 warnings, prompt cache issues
56
+
57
+ ### Removed
58
+ - Legacy UI components (Banner, EnhancedPrompt, Formatter, StatusBar)
59
+ - Max cost/iteration limits for better flexibility
60
+
61
+ ## [0.5.6] - 2026-01-18
62
+
63
+ ### Added
64
+ - **Image Support**: Added support for image handling with cost tracking and display
65
+ - **Enhanced Input Controls**: Added Emacs-like Ctrl+A/E navigation for input fields
66
+ - **Session Management**: Added `/clear` command to clear session history
67
+ - **Edit Mode Switching**: New feature to switch between different edit modes
68
+ - **File Operations**: Support for reading from home directory (`~/`) and current directory (`.`)
69
+ - **Image Management**: Ctrl+D hotkey to delete images functionality
70
+
71
+ ### Improved
72
+ - **Cost Tracking**: Display detailed cost information at every turn for better transparency
73
+ - **Performance**: Test suite speed optimizations and performance improvements
74
+ - **Token Efficiency**: Reduced token usage in grep operations for cost savings
75
+
76
+ ### Fixed
77
+ - Fixed system Cmd+V copy functionality for multi-line text
78
+ - Fixed input flickering issues during text editing
79
+ - Removed unnecessary blank lines from image handling
80
+
10
81
  ## [0.5.4] - 2026-01-16
11
82
 
12
83
  ### Added
@@ -0,0 +1,124 @@
1
+ # UI2 Architecture
2
+
3
+ ## Core Principle
4
+ **Strict Layering**: UI layer must NOT directly access Agent layer. Use callbacks for communication.
5
+
6
+ ## Component Hierarchy
7
+ ```
8
+ UIController (single external interface)
9
+ ├── LayoutManager (layout coordination)
10
+ │ ├── OutputArea (output display)
11
+ │ ├── InputArea (user input)
12
+ │ ├── TodoArea (task list)
13
+ │ └── InlineInput (confirmation prompt)
14
+ └── Callbacks (external communication)
15
+ ├── on_input -> CLI handles input
16
+ ├── on_interrupt -> CLI handles interruption
17
+ └── on_mode_toggle -> CLI handles mode change
18
+ ```
19
+
20
+ ## Data Flow
21
+
22
+ ### Agent → UI: One-way calls
23
+ ```ruby
24
+ # Agent calls UI to display
25
+ @ui&.show_tool_call(...)
26
+ @ui&.append_output(...)
27
+ @ui&.show_token_usage(...)
28
+ ```
29
+
30
+ ### UI → Agent: Via callbacks
31
+ ```ruby
32
+ # ❌ Wrong: UI directly calls Agent
33
+ agent.run(input)
34
+
35
+ # ✅ Correct: Via callback
36
+ ui_controller.on_input { |input| agent.run(input) }
37
+ ```
38
+
39
+ ## Common Mistakes
40
+
41
+ ### ❌ Directly accessing Agent in UI components
42
+ ```ruby
43
+ # Bad example
44
+ def toggle_mode
45
+ @agent.config.mode = "auto_approve" # ❌ Violates separation
46
+ end
47
+ ```
48
+
49
+ ### ✅ Notify via callback
50
+ ```ruby
51
+ # Good example
52
+ def toggle_mode
53
+ @mode_toggle_callback&.call("auto_approve") # ✅ Proper separation
54
+ end
55
+ ```
56
+
57
+ ### ❌ Using puts for logging
58
+ ```ruby
59
+ puts "Debug info" # ❌ Breaks UI rendering
60
+ ```
61
+
62
+ ### ✅ Use UIController.log
63
+ ```ruby
64
+ ui_controller.log("Debug info") # ✅ Displays in output area
65
+ ui_controller.log("Warning", level: :warning)
66
+ ui_controller.log("Error", level: :error)
67
+ ```
68
+
69
+ ## Logging System
70
+
71
+ Use `ui_controller.log(message, level: :info)` to display debug information in the output area without breaking rendering.
72
+
73
+ **Available log levels:**
74
+ - `:debug` - Gray dimmed text
75
+ - `:info` - Normal text with info symbol
76
+ - `:warning` - Yellow warning text
77
+ - `:error` - Red error text
78
+
79
+ **Example:**
80
+ ```ruby
81
+ # In UIController or components with access to UIController
82
+ @ui_controller.log("Tool execution started", level: :debug)
83
+ @ui_controller.log("Cache hit", level: :info)
84
+ @ui_controller.log("Retry attempt 3/10", level: :warning)
85
+ @ui_controller.log("Network failed", level: :error)
86
+ ```
87
+
88
+ ## Rendering Flow
89
+
90
+ ### Fixed Areas
91
+ - **InputArea**: Fixed at bottom (hidden when InlineInput is active via `paused?`)
92
+ - **TodoArea**: Fixed above InputArea
93
+
94
+ ### Scrolling Area
95
+ - **OutputArea**: Natural scrolling, all content appended here
96
+
97
+ ### Thread Safety
98
+ - All rendering protected by `@render_mutex`
99
+ - Never call render methods outside LayoutManager
100
+
101
+ ## Key Methods
102
+
103
+ ### Display Methods (Agent → UI)
104
+ - `append_output(content)` - Add content to output area
105
+ - `update_sessionbar(tasks:, cost:)` - Update session bar
106
+ - `show_token_usage(token_data)` - Display token statistics
107
+ - `show_tool_call(name, args)` - Display tool execution
108
+ - `request_confirmation(message)` - Blocking user confirmation
109
+
110
+ ### Callback Registration (CLI sets these)
111
+ - `on_input { |text, images| ... }` - Handle user input
112
+ - `on_interrupt { |input_was_empty:| ... }` - Handle Ctrl+C
113
+ - `on_mode_toggle { |new_mode| ... }` - Handle Shift+Tab
114
+
115
+ ### Logging (Use instead of puts)
116
+ - `log(message, level: :info)` - Display debug/info in output
117
+
118
+ ## Best Practices
119
+
120
+ 1. **Never bypass UIController** - All UI updates go through UIController
121
+ 2. **Use callbacks for upward communication** - UI notifies CLI/Agent via callbacks
122
+ 3. **Log via UIController** - Never use `puts` or `print` directly
123
+ 4. **Check paused state** - Don't render InputArea when InlineInput is active
124
+ 5. **Trust the render flow** - Let LayoutManager handle rendering coordination