openclacky 0.7.1 → 0.7.3

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: 7412866b05ae167fe6425d335db66e045a5e46ee02f20c25df41ff025c34d504
4
+ data.tar.gz: af3fb00041f896a6b9a8e98d7cb94be58ad49333e111cd6929233cedce684a80
5
5
  SHA512:
6
- metadata.gz: ab6df815f041afa4fa586547299a61562e544de3ae2425b2e9c7a7c9256c05e7b0f79dc824553ccd810939bf3cf3d6e1376b32f4d8a92acedb03efedcfa1e552
7
- data.tar.gz: a6409dd1ab5456f70ae2f6f576f209d47bb4140956caa14ee18815d91c3c901415219212cc73138e959b43531be9f450938fd8e767e63c1075444c520147fa7e
6
+ metadata.gz: 97b3549db52c0f6f8f2b1b5f54f703b45e1aa8619a26909db5bd394bb8dd371972ddce81f61ed2a6047a7105a31be5eeb5e34a7fd1619e57107b363ce805de54
7
+ data.tar.gz: 231fe7e3e095fde2e295dc10d151f231532f44f541c3b623bc9e0efcee054f7a5e32ea58b6734ee6cc0f7e4b137b88d269c1a8a31ac3d6ebcd5c72ee21cd2438
data/CHANGELOG.md CHANGED
@@ -7,6 +7,89 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.7.2] - 2026-02-26
11
+
12
+ ### Added
13
+ - Cross-platform auto-install script with mise and WSL support
14
+ - Built-in provider presets for quick model configuration
15
+ - Terminal restart reminder after installation
16
+ - More bin commands for improved CLI experience
17
+ - Shields.io badges to README
18
+
19
+ ### Improved
20
+ - Install script robustness and user experience
21
+ - Code-explorer workflow with forked subagent mode explanation
22
+ - README with features, usage scenarios, and comparison table
23
+ - Installation section with clearer instructions
24
+
25
+ ### Fixed
26
+ - Binary file detection using magic bytes only (prevents false positives on multibyte text)
27
+ - Display user input before executing callback in handle_submit
28
+ - Install script now uses gem-only approach (removed homebrew dependency)
29
+
30
+ ### More
31
+ - Minor formatting fixes in install script and README
32
+ - Removed skill emoji for cleaner UI
33
+ - Removed test-skill
34
+ - Updated install script configuration
35
+
36
+ ## [0.7.1] - 2026-02-24
37
+
38
+ This release brings significant user experience improvements, new interaction modes, and enhanced agent capabilities.
39
+
40
+ ### 🎯 Major Features
41
+
42
+ **Subagent System**
43
+ - Deploy subagent for parallel task execution
44
+ - Subagent mode with invoke_skill tool and code-explorer skill integration
45
+ - Environment variable support and model type system
46
+
47
+ **Command Experience**
48
+ - Tab completion for slash commands
49
+ - Ctrl+O toggle expand in diff view
50
+ - JSON mode for structured output
51
+ - Streamlined command selection workflow with improved filtering
52
+
53
+ **Agent Improvements**
54
+ - Idle compression with auto-trigger (180s timer)
55
+ - Improved interrupt handling for tool execution
56
+ - Preview display for edit and write tools in auto-approve mode
57
+ - Enable preview display in auto-approve mode
58
+
59
+ **Configuration UI**
60
+ - Auto-save to config modal
61
+ - Improved model management UI
62
+ - Better error handling and validation
63
+
64
+ ### Added
65
+ - Quick start guides in English and Chinese
66
+ - Config example and tests for AgentConfig
67
+
68
+ ### Improved
69
+ - Refactored agent architecture (split agent.rb, moved file locations)
70
+ - Simplified thread management in chat command
71
+ - Dynamic width ratio instead of fixed MAX_CONTENT_WIDTH
72
+ - API error messages with HTML detection and truncation
73
+ - Help command handling
74
+
75
+ ### Changed
76
+ - Removed deprecated Config class (replaced by AgentConfig)
77
+ - Removed confirm_edits permission mode
78
+ - Removed keep_recent_messages configuration
79
+ - Removed default model value
80
+
81
+ ### Fixed
82
+ - Use ToolCallError instead of generic Error in tool registry
83
+ - Handle AgentInterrupted exception during idle compression
84
+ - Handle XML tag contamination in JSON tool parameters
85
+ - Prevent modal flickering on validation failure
86
+ - Update agent client when switching models to prevent stale config
87
+ - Update is_safe_operation to not use removed editing_tool? method
88
+
89
+ ### More
90
+ - Optimize markdown horizontal rule rendering
91
+ - Add debug logging throughout codebase
92
+
10
93
  ## [0.7.0] - 2026-02-06
11
94
 
12
95
  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,109 @@
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
+
15
+ "openrouter" => {
16
+ "name" => "OpenRouter",
17
+ "base_url" => "https://openrouter.ai/api/v1",
18
+ "api" => "openai-responses",
19
+ "default_model" => "anthropic/claude-sonnet-4-6",
20
+ "models" => [] # Dynamic - fetched from API
21
+ }.freeze,
22
+
23
+ "minimax" => {
24
+ "name" => "Minimax",
25
+ "base_url" => "https://api.minimaxi.com/v1",
26
+ "api" => "openai-completions",
27
+ "default_model" => "MiniMax-M2.5",
28
+ "models" => ["MiniMax-M2.1", "MiniMax-M2.5"]
29
+ }.freeze,
30
+
31
+ "kimi" => {
32
+ "name" => "Kimi (Moonshot)",
33
+ "base_url" => "https://api.moonshot.cn/v1",
34
+ "api" => "openai-completions",
35
+ "default_model" => "kimi-k2.5",
36
+ "models" => ["kimi-k2.5"]
37
+ }.freeze,
38
+
39
+ "anthropic" => {
40
+ "name" => "Anthropic (Claude)",
41
+ "base_url" => "https://api.anthropic.com",
42
+ "api" => "anthropic-messages",
43
+ "default_model" => "claude-sonnet-4.6",
44
+ "models" => ["claude-opus-4-6", "claude-sonnet-4.6", "claude-haiku-4.5"]
45
+ }.freeze
46
+
47
+ }.freeze
48
+
49
+ class << self
50
+ # Check if a provider preset exists
51
+ # @param provider_id [String] The provider identifier (e.g., "anthropic", "openrouter")
52
+ # @return [Boolean] True if the preset exists
53
+ def exists?(provider_id)
54
+ PRESETS.key?(provider_id)
55
+ end
56
+
57
+ # Get a provider preset by ID
58
+ # @param provider_id [String] The provider identifier
59
+ # @return [Hash, nil] The preset configuration or nil if not found
60
+ def get(provider_id)
61
+ PRESETS[provider_id]
62
+ end
63
+
64
+ # Get the default model for a provider
65
+ # @param provider_id [String] The provider identifier
66
+ # @return [String, nil] The default model name or nil if provider not found
67
+ def default_model(provider_id)
68
+ preset = PRESETS[provider_id]
69
+ preset&.dig("default_model")
70
+ end
71
+
72
+ # Get the base URL for a provider
73
+ # @param provider_id [String] The provider identifier
74
+ # @return [String, nil] The base URL or nil if provider not found
75
+ def base_url(provider_id)
76
+ preset = PRESETS[provider_id]
77
+ preset&.dig("base_url")
78
+ end
79
+
80
+ # Get the API type for a provider
81
+ # @param provider_id [String] The provider identifier
82
+ # @return [String, nil] The API type or nil if provider not found
83
+ def api_type(provider_id)
84
+ preset = PRESETS[provider_id]
85
+ preset&.dig("api")
86
+ end
87
+
88
+ # List all available provider IDs
89
+ # @return [Array<String>] List of provider identifiers
90
+ def provider_ids
91
+ PRESETS.keys
92
+ end
93
+
94
+ # List all available providers with their names
95
+ # @return [Array<Array(String, String)>] Array of [id, name] pairs
96
+ def list
97
+ PRESETS.map { |id, config| [id, config["name"]] }
98
+ end
99
+
100
+ # Get available models for a provider
101
+ # @param provider_id [String] The provider identifier
102
+ # @return [Array<String>] List of model names (empty if dynamic)
103
+ def models(provider_id)
104
+ preset = PRESETS[provider_id]
105
+ preset&.dig("models") || []
106
+ end
107
+ end
108
+ end
109
+ end
@@ -45,10 +45,16 @@ module Clacky
45
45
  @selected_index = @choices.index { |c| !c[:disabled] } || 0
46
46
  end
47
47
 
48
- # Adjust height for menu mode
48
+ # Adjust height based on mode
49
49
  if @mode == :menu
50
50
  visible_items = [@choices.length, 15].min
51
51
  @height = visible_items + 4 # +4 for title, borders, and instructions
52
+ else
53
+ # Form mode - adjust height based on number of fields
54
+ # Each field takes 2 rows (label + input)
55
+ # +3 for title and top border
56
+ # +5 for error message area, buttons, and bottom border
57
+ @height = (@fields.length * 2) + 3 + 5
52
58
  end
53
59
 
54
60
  # Get terminal size
@@ -154,14 +160,10 @@ module Clacky
154
160
 
155
161
  # All fields collected - validate if validator provided
156
162
  if validator
157
- # Show "Testing..." message with debug info
163
+ # Show "Testing..." message
158
164
  testing_row = start_row + @height - 5
159
165
  testing_col = start_col + 3
160
166
  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
167
  print "\e[#{testing_row + 1};#{testing_col}H\e[K"
166
168
  print @pastel.cyan("⏳ Testing connection...")
167
169
  STDOUT.flush