openclacky 0.7.1 → 0.7.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d00dc4e2243d55c56a3f5df9838517d7588a96137b18348c750e42374d15f7d8
4
- data.tar.gz: 0e0fb9b1fce48ac1fb5542e3fb4e5b3744aecb4cd9a51bd15ffa6ada3f892212
3
+ metadata.gz: 05ce65a24427505768d5edd395ace486c9f7ede88a7abcb42770dce4138a319e
4
+ data.tar.gz: 400a1efafd35cddf6993ba3298830f13eaa1e3cb4502540191e638cb17b22b66
5
5
  SHA512:
6
- metadata.gz: ab6df815f041afa4fa586547299a61562e544de3ae2425b2e9c7a7c9256c05e7b0f79dc824553ccd810939bf3cf3d6e1376b32f4d8a92acedb03efedcfa1e552
7
- data.tar.gz: a6409dd1ab5456f70ae2f6f576f209d47bb4140956caa14ee18815d91c3c901415219212cc73138e959b43531be9f450938fd8e767e63c1075444c520147fa7e
6
+ metadata.gz: 8bef68ebcadc6a178a697592e2e92b09d8307d6bd789171a21eedb2b3296b23071fe761caf762dfe6e2e399ed76dcc028d232190ae8ce5652c9387337a9c6a39
7
+ data.tar.gz: f43e0362780a85166435f572ad42a38654d62f9acc66401e5c229bfd6f27605d75844ee232d3f334fbb8414a0b2d6686b2164a10eb4ebe4ef90b54a021bbf163
data/CHANGELOG.md CHANGED
@@ -7,6 +7,63 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.7.1] - 2026-02-24
11
+
12
+ This release brings significant user experience improvements, new interaction modes, and enhanced agent capabilities.
13
+
14
+ ### 🎯 Major Features
15
+
16
+ **Subagent System**
17
+ - Deploy subagent for parallel task execution
18
+ - Subagent mode with invoke_skill tool and code-explorer skill integration
19
+ - Environment variable support and model type system
20
+
21
+ **Command Experience**
22
+ - Tab completion for slash commands
23
+ - Ctrl+O toggle expand in diff view
24
+ - JSON mode for structured output
25
+ - Streamlined command selection workflow with improved filtering
26
+
27
+ **Agent Improvements**
28
+ - Idle compression with auto-trigger (180s timer)
29
+ - Improved interrupt handling for tool execution
30
+ - Preview display for edit and write tools in auto-approve mode
31
+ - Enable preview display in auto-approve mode
32
+
33
+ **Configuration UI**
34
+ - Auto-save to config modal
35
+ - Improved model management UI
36
+ - Better error handling and validation
37
+
38
+ ### Added
39
+ - Quick start guides in English and Chinese
40
+ - Config example and tests for AgentConfig
41
+
42
+ ### Improved
43
+ - Refactored agent architecture (split agent.rb, moved file locations)
44
+ - Simplified thread management in chat command
45
+ - Dynamic width ratio instead of fixed MAX_CONTENT_WIDTH
46
+ - API error messages with HTML detection and truncation
47
+ - Help command handling
48
+
49
+ ### Changed
50
+ - Removed deprecated Config class (replaced by AgentConfig)
51
+ - Removed confirm_edits permission mode
52
+ - Removed keep_recent_messages configuration
53
+ - Removed default model value
54
+
55
+ ### Fixed
56
+ - Use ToolCallError instead of generic Error in tool registry
57
+ - Handle AgentInterrupted exception during idle compression
58
+ - Handle XML tag contamination in JSON tool parameters
59
+ - Prevent modal flickering on validation failure
60
+ - Update agent client when switching models to prevent stale config
61
+ - Update is_safe_operation to not use removed editing_tool? method
62
+
63
+ ### More
64
+ - Optimize markdown horizontal rule rendering
65
+ - Add debug logging throughout codebase
66
+
10
67
  ## [0.7.0] - 2026-02-06
11
68
 
12
69
  This is a major release with significant improvements to skill system, conversation memory management, and user experience.
data/README.md CHANGED
@@ -1,75 +1,66 @@
1
1
  # OpenClacky
2
2
 
3
- OpenClacky = Lovable + Supabase
4
-
5
- ## Features
3
+ [![Build](https://img.shields.io/github/actions/workflow/status/clacky-ai/open-clacky/main.yml?label=build&style=flat-square)](https://github.com/clacky-ai/open-clacky/actions)
4
+ [![Release](https://img.shields.io/gem/v/openclacky?label=release&style=flat-square&color=blue)](https://rubygems.org/gems/openclacky)
5
+ [![Ruby](https://img.shields.io/badge/ruby-%3E%3D%203.1.0-red?style=flat-square)](https://www.ruby-lang.org)
6
+ [![Downloads](https://img.shields.io/gem/dt/openclacky?label=downloads&style=flat-square&color=brightgreen)](https://rubygems.org/gems/openclacky)
7
+ [![License](https://img.shields.io/badge/license-MIT-lightgrey?style=flat-square)](LICENSE.txt)
6
8
 
7
- - 💬 Interactive chat sessions with AI models
8
- - 🤖 Autonomous AI agent with tool use capabilities
9
- - 📝 Enhanced input with multi-line support and Unicode (Chinese, etc.)
10
- - 🖼️ Paste images from clipboard (macOS/Linux)
11
- - 🚀 Single-message mode for quick queries
12
- - 🔐 Secure API key management
13
- - 📝 Multi-turn conversation support
14
- - 🎨 Colorful terminal output
15
- - 🌐 OpenAI-compatible API support (OpenAI, Gitee AI, DeepSeek, etc.)
16
- - 🛠️ Rich built-in tools: file operations, web search, code execution, and more
17
- - ⚡ Prompt caching support for Claude models (reduces costs up to 90%)
9
+ OpenClacky = Lovable + Supabase
18
10
 
19
- ## Installation
11
+ **OpenClacky** is a CLI tool for building full-stack web applications — no technical background required. We spent months crafting a **Rails for AI** full-stack architecture that is fully production-ready, with one-click deployment, isolated dev/production environments, and automatic backups.
20
12
 
21
- ### Quick Install (Recommended)
13
+ OpenClacky's goal is to deliver the best balance of **AI quality, AI cost, and AI speed**.
22
14
 
23
- **One-line installation** (auto-detects your system):
15
+ ## Quick start
24
16
 
25
17
  ```bash
26
- curl -sSL https://raw.githubusercontent.com/clacky-ai/open-clacky/main/scripts/install.sh | bash
18
+ $ openclacky
27
19
  ```
28
20
 
29
- This script will:
30
- - Check your Ruby version
31
- - Install via Homebrew (macOS) if available
32
- - Install via RubyGems if Ruby >= 3.1.0 is installed
33
- - Guide you to install Ruby if needed
21
+ - `/config` — Set your API key, model, and base URL
22
+ - `/new <project-name>` Create a new project
23
+ - Type your requirements and start building
24
+
25
+ ## Why OpenClacky?
26
+
27
+ | | **Claude Code** | **Lovable + Supabase** | **OpenClacky** |
28
+ |---|---|---|---|
29
+ | **Target Users** | Professional developers | Non-technical users | Non-technical users |
30
+ | **Tech Stack** | Any | React + Supabase | Rails (full-stack) |
31
+ | **Full-Stack Integration** | ❌ DIY | ⚠️ Frontend/backend split | ✅ Unified full-stack |
32
+ | **Production-Ready** | ❌ Manual setup | ⚠️ Relies on third-party | ✅ Built-in |
33
+ | **One-Click Deploy** | ❌ | ⚠️ Platform lock-in | ✅ Deploy anywhere |
34
+ | **Dev/Prod Isolation** | ❌ | ❌ | ✅ Automatic |
35
+ | **Automatic Backups** | ❌ | ⚠️ Paid feature | ✅ Built-in |
36
+ | **AI Cost Control** | ❌ Pay per token | ❌ Subscription | ✅ Optimally balanced |
37
+ | **Data Ownership** | ✅ | ❌ Platform-owned | ✅ Fully yours |
38
+ | **Interface** | Terminal | Web UI | Terminal |
34
39
 
35
- ### Method 1: Homebrew (macOS/Linux)
40
+ ## Features
36
41
 
37
- **Best for macOS users** - Automatically handles Ruby dependencies:
42
+ - [x] `/new <project-name>` — Scaffold a full-stack Rails web app in seconds
43
+ - [x] **Skills system** — Specialized AI workflows for deploy, frontend design, PDF, PPTX, and more
44
+ - [x] **Cost monitoring & compression** — Real-time cost tracking, automatic message compression (up to 90% savings)
45
+ - [x] **One-click deployment** — Ship to production with a single command (with Clacky CDE)
46
+ - [x] **Autonomous AI agent** — Multi-step task execution with undo/redo
47
+ - [x] **Multi-provider support** — OpenAI, Anthropic, DeepSeek, and any OpenAI-compatible API
48
+ - [ ] **Time Machine** — Visual history to rewind and branch any point in your project *(coming soon)*
38
49
 
39
- ```bash
40
- brew tap clacky-ai/openclacky
41
- brew install openclacky
42
- ```
50
+ ## Installation
43
51
 
44
- ### Method 2: RubyGems (If you already have Ruby >= 3.1.0)
52
+ ### Method 1: One-line Install (Recommended)
45
53
 
46
54
  ```bash
47
- gem install openclacky
55
+ /bin/bash -c "$(curl -sSL https://raw.githubusercontent.com/clacky-ai/open-clacky/main/scripts/install.sh)"
48
56
  ```
49
57
 
50
- ### Method 3: From Source (For Development)
58
+ ### Method 2: RubyGems
51
59
 
52
- ```bash
53
- git clone https://github.com/clacky-ai/open-clacky.git
54
- cd open-clacky
55
- bundle install
56
- bin/clacky
57
- ```
58
-
59
- ### System Requirements
60
-
61
- - **Ruby**: >= 3.1.0 (automatically handled by Homebrew)
62
- - **OS**: macOS, Linux, or Windows (WSL)
63
-
64
- ### Uninstallation
60
+ **Requirements:** Ruby >= 3.1.0
65
61
 
66
62
  ```bash
67
- # Quick uninstall
68
- curl -sSL https://raw.githubusercontent.com/clacky-ai/open-clacky/main/scripts/uninstall.sh | bash
69
-
70
- # Or manually
71
- brew uninstall openclacky # If installed via Homebrew
72
- gem uninstall openclacky # If installed via gem
63
+ gem install openclacky
73
64
  ```
74
65
 
75
66
  ## Configuration
@@ -77,141 +68,59 @@ gem uninstall openclacky # If installed via gem
77
68
  Before using Clacky, you need to configure your settings:
78
69
 
79
70
  ```bash
80
- clacky config set
71
+ $ openclacky
72
+
73
+ - /config
81
74
  ```
82
75
 
83
76
  You'll be prompted to enter:
84
77
  - **API Key**: Your API key from any OpenAI-compatible provider
85
- - **Model**: Model name (e.g., `gpt-4`, `deepseek-chat`)
86
- - **Base URL**: OpenAI-compatible API endpoint (e.g., `https://api.openai.com/v1`)
87
-
88
- To view your current configuration:
89
-
90
- ```bash
91
- clacky config show
92
- ```
78
+ - **Model**: Model name
79
+ - **Base URL**: OpenAI-compatible API endpoint
93
80
 
94
81
  ## Usage
95
82
 
96
- ### AI Agent Mode (Interactive)
97
-
98
- Run an autonomous AI agent in interactive mode. The agent can use tools to complete tasks and runs in a continuous loop, allowing you to have multi-turn conversations with tool use capabilities.
99
-
100
- ```bash
101
- # Start interactive agent (will prompt for tasks)
102
- clacky agent
103
-
104
- # Start with an initial task, then continue interactively
105
- clacky agent "Create a README.md file for my project"
106
-
107
- # Auto-approve all tool executions
108
- clacky agent --mode=auto_approve
109
-
110
- # Work in a specific project directory
111
- clacky agent --path /path/to/project
112
-
113
- #### Permission Modes
114
-
115
- - `auto_approve` - Automatically execute all tools (use with caution)
116
- - `confirm_safes` - Auto-approve read-only tools, confirm edits
117
- - `plan_only` - Generate plan without executing
118
-
119
- #### Agent Options
83
+ ### Scenario 1: Create a new web app
120
84
 
121
85
  ```bash
122
- --path PATH # Project directory (defaults to current directory)
123
- --mode MODE # Permission mode
124
- --verbose # Show detailed output
86
+ $ openclacky
87
+ > /new my-blog
88
+ # OpenClacky scaffolds a full-stack Rails app in seconds
89
+ # > Add a posts page with title, content, and author fields
90
+ # > Deploy to production
91
+ # > exit
125
92
  ```
126
93
 
127
- #### Cost Control & Memory Management
128
-
129
- The agent includes intelligent cost control features:
130
-
131
- - **Automatic Message Compression**: When conversation history grows beyond 100 messages, the agent automatically compresses older messages into a summary, keeping only the system prompt and the most recent 20 messages. This dramatically reduces token costs for long-running tasks (achieves ~60% compression ratio).
132
-
133
- - **Compression Settings**:
134
- - `enable_compression`: Enable/disable automatic compression (default: true)
135
- - `keep_recent_messages`: Number of recent messages to preserve (default: 20)
136
- - Compression triggers at: ~100 messages (keep_recent_messages + 80)
137
-
138
- ### List Available Tools
139
-
140
- View all built-in tools:
94
+ ### Scenario 2: Build a feature in an existing project
141
95
 
142
96
  ```bash
143
- clacky tools
97
+ $ cd ~/my-project && openclacky
98
+ # > Add user authentication with email and password
99
+ # > Write tests for the auth flow
100
+ # > exit
144
101
  ```
145
102
 
146
- #### Built-in Tools
147
-
148
- - **todo_manager** - Manage TODO items for task planning and tracking
149
- - **file_reader** - Read file contents
150
- - **write** - Create or overwrite files
151
- - **edit** - Make precise edits to existing files
152
- - **glob** - Find files by pattern matching
153
- - **grep** - Search file contents with regex
154
- - **shell** - Execute shell commands
155
- - **web_search** - Search the web for information
156
- - **web_fetch** - Fetch and parse web page content
157
-
158
- ### Available Commands
103
+ ### Scenario 3: Ask questions about your codebase
159
104
 
160
105
  ```bash
161
- clacky agent [MESSAGE] # Run autonomous agent with tool use
162
- clacky tools # List available tools
163
- clacky config set # Set your API key
164
- clacky config show # Show current configuration
165
- clacky version # Show clacky version
166
- clacky help # Show help information
106
+ $ openclacky
107
+ # > How does the payment module work?
108
+ # > Where is the user session managed?
109
+ # > exit
167
110
  ```
168
111
 
169
- ## Examples
170
-
171
- ### Agent Examples
112
+ ## Install from Source
172
113
 
173
114
  ```bash
174
- # Start interactive agent session
175
- clacky agent
176
- # Then type tasks interactively:
177
- # > Create a TODO.md file with 3 example tasks
178
- # > Now add more items to the TODO list
179
- # > exit
180
-
181
- # Auto-approve mode for trusted operations
182
- clacky agent --mode=auto_approve --path ~/my-project
183
- # > Count all lines of code
184
- # > Create a summary report
185
- # > exit
186
-
187
- # Using TODO manager for complex tasks
188
- clacky agent "Implement a new feature with user authentication"
189
- # Agent will:
190
- # 1. Use todo_manager to create a task plan
191
- # 2. Add todos: "Research current auth patterns", "Design auth flow", etc.
192
- # 3. Complete each todo step by step
193
- # 4. Mark todos as completed as work progresses
194
- # > exit
115
+ git clone https://github.com/clacky-ai/open-clacky.git
116
+ cd open-clacky
117
+ bundle install
118
+ bin/clacky
195
119
  ```
196
120
 
197
121
  ## Development
198
122
 
199
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
200
-
201
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
202
-
203
- ### Testing Agent Features
204
-
205
- After making changes to agent-related functionality (tools, system prompts, agent logic, etc.), test with this command:
206
-
207
- ```bash
208
- # Test agent with a complex multi-step task using auto-approve mode
209
- echo "Create a simple calculator project with index.html, style.css, and script.js files" | \
210
- bin/clacky agent --mode=auto_approve --path=tmp --max-iterations=20
211
-
212
- # Expected: Agent should plan tasks (add TODOs), execute them (create files),
213
- # and track progress (mark TODOs as completed)
214
- ```
123
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/clacky` for an interactive prompt that will allow you to experiment.
215
124
 
216
125
  ## Contributing
217
126
 
data/bin/clarky ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Display typo correction message
4
+ warn "\nNote: 'clarky' appears to be a typo!"
5
+ warn "The correct command is 'clacky'"
6
+
7
+ warn "\nRedirecting to the correct command...\n\n"
8
+
9
+ # Redirect to clacky
10
+ clacky_path = File.expand_path("clacky", __dir__)
11
+ exec(clacky_path, *ARGV)
data/lib/clacky/agent.rb CHANGED
@@ -655,9 +655,18 @@ module Clacky
655
655
  # Append system prompt suffix as user message (for cache reuse)
656
656
  if system_prompt_suffix
657
657
  messages = subagent.instance_variable_get(:@messages)
658
+
659
+ # Build forbidden tools notice if any tools are forbidden
660
+ forbidden_notice = if forbidden_tools.any?
661
+ tool_list = forbidden_tools.map { |t| "`#{t}`" }.join(", ")
662
+ "\n\n[System Notice] The following tools are disabled in this subagent and will be rejected if called: #{tool_list}"
663
+ else
664
+ ""
665
+ end
666
+
658
667
  messages << {
659
668
  role: "user",
660
- content: "CRITICAL: TASK CONTEXT SWITCH - FORKED SUBAGENT MODE\n\n#{system_prompt_suffix}",
669
+ content: "CRITICAL: TASK CONTEXT SWITCH - FORKED SUBAGENT MODE\n\nYou are now running as a forked subagent — a temporary, isolated agent spawned by the parent agent to handle a specific task. You run independently and cannot communicate back to the parent mid-task. When you finish (i.e., you stop calling tools and return a final response), your output will be automatically summarized and returned to the parent agent as a result so it can continue.\n\n#{system_prompt_suffix}#{forbidden_notice}",
661
670
  system_injected: true,
662
671
  subagent_instructions: true
663
672
  }
data/lib/clacky/cli.rb CHANGED
@@ -506,8 +506,6 @@ module Clacky
506
506
  handle_time_machine_command(ui_controller, agent, session_manager)
507
507
  next
508
508
  when "/clear"
509
- # Show user input first
510
- ui_controller.append_output(display) if display
511
509
  sleep 0.1
512
510
  # Clear output area
513
511
  ui_controller.layout.clear_output
@@ -523,8 +521,6 @@ module Clacky
523
521
  ui_controller.stop
524
522
  exit(0)
525
523
  when "/help"
526
- # Show user input first
527
- ui_controller.append_output(display) if display
528
524
  sleep 0.1
529
525
  ui_controller.show_help
530
526
  next
@@ -15,27 +15,20 @@ You are now running in a **forked subagent** mode optimized for fast code explor
15
15
  ## Your Mission
16
16
  Quickly explore and analyze the codebase to answer questions or gather information.
17
17
 
18
- ## Your Capabilities
19
- - Read files: Use `file_reader` to examine source code
20
- - Search patterns: Use `grep` to find code patterns and text
21
- - List files: Use `glob` to discover project structure
22
- - Web research: Use `web_search` and `web_fetch` if needed
23
-
24
18
  ## Your Restrictions
25
19
  - NO modifications: You CANNOT use `write` or `edit` tools
26
- - NO commands: You CANNOT use `safe_shell` to run commands
27
20
  - Read-only: Your role is to ANALYZE, not to change
28
21
 
29
- ## Workflow
30
- 1. Understand the request: What information is needed?
31
- 2. Explore efficiently: Use glob to map structure, grep to find patterns, file_reader for details
32
- 3. Analyze findings: Draw insights from the code you read
33
- 4. Report clearly: Provide a concise, actionable summary
22
+ ## Workflow — follow this order strictly
34
23
 
35
- ## Tips for Efficiency
36
- - Start with `glob` to understand project structure
37
- - Use `grep` for targeted searches (faster than reading all files)
38
- - Only use `file_reader` when you need full file content
39
- - Focus on answering the specific question asked
24
+ 1. **List the file tree** — run `glob` with `**/*` to get an overview of the project structure
25
+ 2. **Read README.md** if it exists, read it to understand the project purpose and layout
26
+ 3. **Find relevant files** — based on the task, use `grep` to locate key patterns or specific files
27
+ 4. **Read only what's needed** — use `file_reader` only on the files directly relevant to the question
28
+ 5. **Report clearly** provide a concise, actionable summary
40
29
 
41
- Remember: You're running on a cheaper model for speed and cost efficiency. Be thorough but concise!
30
+ ## Rules
31
+ - Do NOT read files blindly — always have a reason before opening a file
32
+ - Do NOT read every file in a directory — be selective
33
+ - Prefer `grep` over `file_reader` for finding specific patterns
34
+ - Stop as soon as you have enough information to answer the question
@@ -36,7 +36,7 @@ cd <project_name>
36
36
 
37
37
  ### 5. Success Message
38
38
  Tell user:
39
- - Project created successfully!
39
+ - Project created successfully!
40
40
  - Next step: enter project directory to start development
41
41
  - Command: `cd <project_name>`
42
42
 
@@ -52,4 +52,4 @@ Response:
52
52
  1. Creating a new project named "blog"
53
53
  2. Cloning template...
54
54
  3. Installing dependencies...
55
- 4. Done! You can now: `cd blog` to start development
55
+ 4. Done! You can now: `cd blog` to start development
@@ -0,0 +1,107 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Clacky
4
+ # Built-in model provider presets
5
+ # Provides default configurations for supported AI model providers
6
+ module Providers
7
+ # Provider preset definitions
8
+ # Each preset includes:
9
+ # - name: Human-readable provider name
10
+ # - base_url: Default API endpoint
11
+ # - api: API type (anthropic-messages, openai-responses, openai-completions)
12
+ # - default_model: Recommended default model
13
+ PRESETS = {
14
+ "anthropic" => {
15
+ "name" => "Anthropic (Claude)",
16
+ "base_url" => "https://api.anthropic.com",
17
+ "api" => "anthropic-messages",
18
+ "default_model" => "claude-sonnet-4-6",
19
+ "models" => ["claude-opus-4-6", "claude-sonnet-4-6", "claude-haiku-4"]
20
+ }.freeze,
21
+
22
+ "openrouter" => {
23
+ "name" => "OpenRouter",
24
+ "base_url" => "https://openrouter.ai/api/v1",
25
+ "api" => "openai-responses",
26
+ "default_model" => "anthropic/claude-sonnet-4-5",
27
+ "models" => [] # Dynamic - fetched from API
28
+ }.freeze,
29
+
30
+ "minimax" => {
31
+ "name" => "Minimax",
32
+ "base_url" => "https://api.minimax.chat/v1",
33
+ "api" => "openai-completions",
34
+ "default_model" => "MiniMax-Text-01",
35
+ "models" => ["MiniMax-Text-01", "MiniMax-M2"]
36
+ }.freeze,
37
+
38
+ "kimi" => {
39
+ "name" => "Kimi (Moonshot)",
40
+ "base_url" => "https://api.moonshot.cn/v1",
41
+ "api" => "openai-completions",
42
+ "default_model" => "kimi-k2.5",
43
+ "models" => ["kimi-k2.5"]
44
+ }.freeze
45
+ }.freeze
46
+
47
+ class << self
48
+ # Check if a provider preset exists
49
+ # @param provider_id [String] The provider identifier (e.g., "anthropic", "openrouter")
50
+ # @return [Boolean] True if the preset exists
51
+ def exists?(provider_id)
52
+ PRESETS.key?(provider_id)
53
+ end
54
+
55
+ # Get a provider preset by ID
56
+ # @param provider_id [String] The provider identifier
57
+ # @return [Hash, nil] The preset configuration or nil if not found
58
+ def get(provider_id)
59
+ PRESETS[provider_id]
60
+ end
61
+
62
+ # Get the default model for a provider
63
+ # @param provider_id [String] The provider identifier
64
+ # @return [String, nil] The default model name or nil if provider not found
65
+ def default_model(provider_id)
66
+ preset = PRESETS[provider_id]
67
+ preset&.dig("default_model")
68
+ end
69
+
70
+ # Get the base URL for a provider
71
+ # @param provider_id [String] The provider identifier
72
+ # @return [String, nil] The base URL or nil if provider not found
73
+ def base_url(provider_id)
74
+ preset = PRESETS[provider_id]
75
+ preset&.dig("base_url")
76
+ end
77
+
78
+ # Get the API type for a provider
79
+ # @param provider_id [String] The provider identifier
80
+ # @return [String, nil] The API type or nil if provider not found
81
+ def api_type(provider_id)
82
+ preset = PRESETS[provider_id]
83
+ preset&.dig("api")
84
+ end
85
+
86
+ # List all available provider IDs
87
+ # @return [Array<String>] List of provider identifiers
88
+ def provider_ids
89
+ PRESETS.keys
90
+ end
91
+
92
+ # List all available providers with their names
93
+ # @return [Array<Array(String, String)>] Array of [id, name] pairs
94
+ def list
95
+ PRESETS.map { |id, config| [id, config["name"]] }
96
+ end
97
+
98
+ # Get available models for a provider
99
+ # @param provider_id [String] The provider identifier
100
+ # @return [Array<String>] List of model names (empty if dynamic)
101
+ def models(provider_id)
102
+ preset = PRESETS[provider_id]
103
+ preset&.dig("models") || []
104
+ end
105
+ end
106
+ end
107
+ end
@@ -154,14 +154,10 @@ module Clacky
154
154
 
155
155
  # All fields collected - validate if validator provided
156
156
  if validator
157
- # Show "Testing..." message with debug info
157
+ # Show "Testing..." message
158
158
  testing_row = start_row + @height - 5
159
159
  testing_col = start_col + 3
160
160
  print "\e[#{testing_row};#{testing_col}H\e[K"
161
-
162
- # Show debug info about what we're testing
163
- debug_info = "Testing: API=#{@values[:api_key]&.[](0..10)}... URL=#{@values[:base_url]} Model=#{@values[:model]}"
164
- print @pastel.dim(debug_info)
165
161
  print "\e[#{testing_row + 1};#{testing_col}H\e[K"
166
162
  print @pastel.cyan("⏳ Testing connection...")
167
163
  STDOUT.flush
@@ -171,17 +167,6 @@ module Clacky
171
167
  # Clear testing messages
172
168
  print "\e[#{testing_row};#{testing_col}H\e[K"
173
169
  print "\e[#{testing_row + 1};#{testing_col}H\e[K"
174
-
175
- if validation_result[:success]
176
- # Validation passed - hide cursor and return values
177
- print "\e[?25l"
178
- return @values
179
- else
180
- # Validation failed - show error and loop again to let user correct input
181
- @error_message = validation_result[:error] || "Validation failed"
182
- # Don't clear modal - just loop again to redraw with error message
183
- # This prevents the modal from flickering
184
- end
185
170
  else
186
171
  # No validator - return immediately
187
172
  print "\e[?25l"