openclacky 0.7.2 → 0.7.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 (34) hide show
  1. checksums.yaml +4 -4
  2. data/.clacky/skills/commit/SKILL.md +252 -74
  3. data/CHANGELOG.md +38 -0
  4. data/bin/openclacky +2 -0
  5. data/lib/clacky/agent/message_compressor_helper.rb +1 -1
  6. data/lib/clacky/agent/system_prompt_builder.rb +9 -8
  7. data/lib/clacky/agent/tool_executor.rb +4 -13
  8. data/lib/clacky/agent.rb +28 -7
  9. data/lib/clacky/cli.rb +22 -5
  10. data/lib/clacky/default_skills/new/SKILL.md +61 -30
  11. data/lib/clacky/default_skills/new/scripts/create_rails_project.sh +176 -0
  12. data/lib/clacky/default_skills/new/scripts/rails_env_checker.sh +389 -0
  13. data/lib/clacky/default_skills/skill-add/SKILL.md +251 -34
  14. data/lib/clacky/default_skills/skill-add/scripts/install_from_github.rb +189 -0
  15. data/lib/clacky/providers.rb +13 -11
  16. data/lib/clacky/tools/invoke_skill.rb +5 -1
  17. data/lib/clacky/tools/safe_shell.rb +2 -2
  18. data/lib/clacky/tools/shell.rb +48 -20
  19. data/lib/clacky/ui2/components/input_area.rb +27 -9
  20. data/lib/clacky/ui2/components/modal_component.rb +22 -2
  21. data/lib/clacky/ui2/components/welcome_banner.rb +33 -10
  22. data/lib/clacky/ui2/layout_manager.rb +107 -26
  23. data/lib/clacky/ui2/line_editor.rb +6 -5
  24. data/lib/clacky/ui2/screen_buffer.rb +0 -15
  25. data/lib/clacky/ui2/terminal_detector.rb +119 -0
  26. data/lib/clacky/ui2/theme_manager.rb +18 -0
  27. data/lib/clacky/ui2/themes/base_theme.rb +22 -1
  28. data/lib/clacky/ui2/themes/hacker_theme.rb +22 -18
  29. data/lib/clacky/ui2/themes/minimal_theme.rb +19 -15
  30. data/lib/clacky/ui2/ui_controller.rb +66 -15
  31. data/lib/clacky/ui2.rb +1 -0
  32. data/lib/clacky/utils/limit_stack.rb +5 -0
  33. data/lib/clacky/version.rb +1 -1
  34. metadata +5 -1
data/lib/clacky/cli.rb CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "thor"
4
4
  require "tty-prompt"
5
+ require "fileutils"
5
6
  require_relative "ui2"
6
7
  require_relative "json_ui_controller"
7
8
 
@@ -224,7 +225,17 @@ module Clacky
224
225
  def validate_working_directory(path)
225
226
  working_dir = path || Dir.pwd
226
227
 
227
- # Expand path to absolute path
228
+ # If no path specified and currently in home directory, use ~/clacky_workspace
229
+ if path.nil? && File.expand_path(working_dir) == File.expand_path(Dir.home)
230
+ working_dir = File.expand_path("~/clacky_workspace")
231
+
232
+ # Create directory if it doesn't exist
233
+ unless Dir.exist?(working_dir)
234
+ FileUtils.mkdir_p(working_dir)
235
+ end
236
+ end
237
+
238
+ # Always expand to absolute path
228
239
  working_dir = File.expand_path(working_dir)
229
240
 
230
241
  # Validate directory exists
@@ -424,6 +435,12 @@ module Clacky
424
435
 
425
436
  # Run agent with UI2 split-screen interface
426
437
  def run_agent_with_ui2(agent, working_dir, agent_config, session_manager = nil, client = nil, is_session_load: false)
438
+ # Detect terminal background BEFORE starting UI2 to avoid output interference
439
+ is_dark_bg = UI2::TerminalDetector.detect_dark_background
440
+
441
+ # Pass detected background mode to theme manager (singleton)
442
+ UI2::ThemeManager.instance.set_background_mode(is_dark_bg)
443
+
427
444
  # Validate theme
428
445
  theme_name = options[:theme] || "hacker"
429
446
  available_themes = UI2::ThemeManager.available_themes.map(&:to_s)
@@ -535,7 +552,7 @@ module Clacky
535
552
 
536
553
  # Cancel idle timer if running (new input means user is active)
537
554
  if idle_timer_thread&.alive?
538
- ui_controller.log("Idle timer killed, start new 1", level: :debug)
555
+ # ui_controller.log("Idle timer killed, start new 1", level: :debug)
539
556
  idle_timer_thread.kill
540
557
  idle_timer_thread = nil
541
558
  end
@@ -544,17 +561,17 @@ module Clacky
544
561
  start_idle_timer = lambda do
545
562
  # Cancel any existing idle timer first
546
563
  if idle_timer_thread&.alive?
547
- ui_controller.log("Idle timer killed, start new 2", level: :debug)
564
+ # ui_controller.log("Idle timer killed, start new 2", level: :debug)
548
565
  idle_timer_thread.kill
549
566
  idle_timer_thread = nil
550
567
  end
551
568
 
552
569
  # Start idle timer - trigger compression after 180 seconds of inactivity
553
570
  idle_timer_thread = Thread.new do
554
- ui_controller.log("Idle timer started, will trigger compression in 180 seconds", level: :debug)
571
+ # ui_controller.log("Idle timer started, will trigger compression in 180 seconds", level: :debug)
555
572
  # Sleep outside of rescue block - if interrupted here, let it propagate and exit
556
573
  sleep 180
557
- ui_controller.log("Idle timer sleep completed, starting compression", level: :debug)
574
+ # ui_controller.log("Idle timer sleep completed, starting compression", level: :debug)
558
575
 
559
576
  # After sleep completes, switch to current_task_thread for compression
560
577
  # (so it can be interrupted by Ctrl+C)
@@ -8,48 +8,79 @@ user-invocable: true
8
8
  # Create New Project
9
9
 
10
10
  ## Usage
11
- When user wants to create a new project:
12
- - "help me create a new project"
13
- - "I want to start a new project called blog"
14
- - "/new my-app"
11
+ When user wants to create a new Rails project:
12
+ - "help me create a new Rails project"
13
+ - "I want to start a new Rails project"
14
+ - "/new"
15
15
 
16
16
  ## Process Steps
17
17
 
18
- ### 1. Get Project Name
19
- - Extract project name from user input
20
- - Validate: letters, numbers, underscores, hyphens only
21
- - Must start with a letter
18
+ ### 1. Check Directory Before Starting
19
+ Before running the setup script, check if current directory is empty:
20
+ - Use glob tool to check if directory has files: `glob("*", base_path: ".")`
21
+ - If directory is NOT empty, ask user for confirmation: "Current directory is not empty. Continue anyway? (y/n)"
22
+ - If user declines, abort and suggest creating project in an empty directory
22
23
 
23
- ### 2. Check Directory
24
- If directory already exists, ask user to choose a different name
25
-
26
- ### 3. Clone Template
24
+ ### 2. Run Setup Script
25
+ Execute the create_rails_project.sh script in current directory:
27
26
  ```bash
28
- git clone git@github.com:clacky-ai/rails-template-7x-starter.git <project_name>
27
+ <clacky_skills_path>/new/scripts/create_rails_project.sh
29
28
  ```
30
29
 
31
- ### 4. Install Dependencies
32
- ```bash
33
- cd <project_name>
34
- ./bin/setup
30
+ The script will automatically:
31
+
32
+ **Step 1: Clone Template**
33
+ - Clone rails-template-7x-starter to a temporary directory
34
+ - Move all files to current directory
35
+ - Delete template's .git directory
36
+ - Initialize new git repository with initial commit
37
+
38
+ **Step 2: Check Environment**
39
+ - Run rails_env_checker.sh to verify dependencies:
40
+ - Ruby >= 3.0.0 (must be pre-installed)
41
+ - Node.js >= 22.0.0 (will install automatically if missing on macOS/Ubuntu)
42
+ - PostgreSQL (will install automatically if missing on macOS/Ubuntu)
43
+ - Script automatically installs missing dependencies without prompting
44
+
45
+ **Step 3: Install Project Dependencies**
46
+ - Run ./bin/setup to:
47
+ - Install Ruby gems (bundle install)
48
+ - Install npm packages (npm install)
49
+ - Copy configuration files
50
+ - Setup database (db:prepare)
51
+
52
+ **Step 4: Project Setup Complete**
53
+ - Script completes successfully
54
+ - Project is ready to run
55
+
56
+ ### 3. Start Development Server
57
+ After the script completes, use the run_project tool to start the server:
58
+ ```
59
+ run_project(action: "start")
35
60
  ```
36
61
 
37
- ### 5. Success Message
38
- Tell user:
39
- - Project created successfully!
40
- - Next step: enter project directory to start development
41
- - Command: `cd <project_name>`
62
+ This will start the Rails development server in the background. Inform user:
63
+ - Application: http://localhost:3000
64
+ - Admin: http://localhost:3000/admin (admin/admin)
42
65
 
43
66
  ## Error Handling
44
- - Directory exists → Ask for different name
45
- - Git clone fails → Check network connection
46
- - Setup failsSuggest manual run: ./bin/setup
67
+ - Directory not empty → Ask user confirmation, abort if declined
68
+ - Git clone fails → Check network connection, verify repository URL
69
+ - Ruby not installed Error message, user must install Ruby 3.x manually
70
+ - Node.js < 22 → Script installs automatically (macOS/Ubuntu)
71
+ - PostgreSQL missing → Script installs automatically (macOS/Ubuntu)
72
+ - bin/setup fails → Show error, suggest running `./bin/setup` manually
73
+ - run_project fails → Check logs with `run_project(action: "output")` and verify database status
47
74
 
48
75
  ## Example Interaction
49
- User: "help me create a blog project"
76
+ User: "/new"
50
77
 
51
78
  Response:
52
- 1. Creating a new project named "blog"
53
- 2. Cloning template...
54
- 3. Installing dependencies...
55
- 4. Done! You can now: `cd blog` to start development
79
+ 1. Checking if current directory is empty...
80
+ 2. Running create_rails_project.sh in current directory
81
+ 3. Cloning Rails template from GitHub...
82
+ 4. Checking environment dependencies...
83
+ 5. Installing project dependencies...
84
+ 6. Project setup complete!
85
+ 7. Starting development server with run_project...
86
+ 8. ✨ Server running! Visit http://localhost:3000
@@ -0,0 +1,176 @@
1
+ #!/bin/bash
2
+ # Create Rails Project Script
3
+ # This script creates a new Rails 7.x project from the rails-template-7x-starter template
4
+ # Run this script in an empty directory
5
+
6
+ set -e
7
+
8
+ # Colors for output
9
+ RED='\033[0;31m'
10
+ GREEN='\033[0;32m'
11
+ YELLOW='\033[1;33m'
12
+ BLUE='\033[0;34m'
13
+ NC='\033[0m' # No Color
14
+
15
+ # Print colored messages
16
+ print_info() {
17
+ echo -e "${BLUE}ℹ${NC} $1"
18
+ }
19
+
20
+ print_success() {
21
+ echo -e "${GREEN}✓${NC} $1"
22
+ }
23
+
24
+ print_warning() {
25
+ echo -e "${YELLOW}⚠${NC} $1"
26
+ }
27
+
28
+ print_error() {
29
+ echo -e "${RED}✗${NC} $1"
30
+ }
31
+
32
+ print_step() {
33
+ echo -e "\n${BLUE}==>${NC} $1"
34
+ }
35
+
36
+ # Get script directory
37
+ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
38
+
39
+ # Check if current directory is empty
40
+ check_current_directory() {
41
+ print_step "Checking current directory..."
42
+
43
+ local current_dir=$(pwd)
44
+ print_info "Working in: $current_dir"
45
+
46
+ # Check if directory is empty (silently continue if not)
47
+ if [ "$(ls -A .)" ]; then
48
+ print_warning "Current directory is not empty - continuing anyway"
49
+ else
50
+ print_success "Current directory is empty"
51
+ fi
52
+ }
53
+
54
+ # Clone template to current directory
55
+ clone_template() {
56
+ print_step "Cloning Rails template..."
57
+
58
+ # Create temporary directory
59
+ local temp_dir=$(mktemp -d)
60
+ print_info "Using temporary directory: $temp_dir"
61
+
62
+ # Clone template to temp directory
63
+ print_info "Downloading template from GitHub..."
64
+ if git clone https://github.com/clacky-ai/rails-template-7x-starter.git "$temp_dir" >/dev/null 2>&1; then
65
+ print_success "Template cloned successfully"
66
+ else
67
+ print_error "Failed to clone template"
68
+ rm -rf "$temp_dir"
69
+ exit 1
70
+ fi
71
+
72
+ # Move all files to current directory
73
+ print_info "Moving files to current directory..."
74
+ mv "$temp_dir"/* "$temp_dir"/.* . 2>/dev/null || true
75
+
76
+ # Delete .git directory
77
+ rm -rf .git
78
+
79
+ # Clean up temp directory
80
+ rm -rf "$temp_dir"
81
+ print_success "Template files copied to current directory"
82
+
83
+ # Initialize new git repository
84
+ print_info "Initializing git repository..."
85
+ git init > /dev/null 2>&1
86
+ git add . > /dev/null 2>&1
87
+ git commit -m "Initial commit from rails-template-7x-starter" > /dev/null 2>&1
88
+ print_success "Git repository initialized"
89
+ }
90
+
91
+ # Check environment dependencies
92
+ check_environment() {
93
+ print_step "Checking environment dependencies..."
94
+
95
+ # Run rails_env_checker.sh
96
+ if [ -f "$SCRIPT_DIR/rails_env_checker.sh" ]; then
97
+ if bash "$SCRIPT_DIR/rails_env_checker.sh"; then
98
+ print_success "Environment check passed"
99
+ return 0
100
+ else
101
+ print_error "Environment check failed"
102
+ return 1
103
+ fi
104
+ else
105
+ print_warning "rails_env_checker.sh not found, skipping environment check"
106
+ print_info "Please ensure you have Ruby 3.x, Node.js 22+, and PostgreSQL installed"
107
+ return 0
108
+ fi
109
+ }
110
+
111
+ # Run project setup
112
+ run_project_setup() {
113
+ print_step "Running project setup..."
114
+
115
+ if [ ! -f "./bin/setup" ]; then
116
+ print_error "bin/setup not found"
117
+ return 1
118
+ fi
119
+
120
+ chmod +x ./bin/setup
121
+
122
+ if ./bin/setup; then
123
+ print_success "Project setup completed"
124
+ return 0
125
+ else
126
+ print_error "Project setup failed"
127
+ return 1
128
+ fi
129
+ }
130
+
131
+ # Main function
132
+ main() {
133
+ echo ""
134
+ echo "╔═══════════════════════════════════════════════════════════╗"
135
+ echo "║ ║"
136
+ echo "║ 🚀 Rails 7.x Project Creator ║"
137
+ echo "║ ║"
138
+ echo "║ Creating your new Rails project... ║"
139
+ echo "║ ║"
140
+ echo "╚═══════════════════════════════════════════════════════════╝"
141
+ echo ""
142
+
143
+ # Check current directory
144
+ check_current_directory
145
+
146
+ # Clone template
147
+ if ! clone_template; then
148
+ exit 1
149
+ fi
150
+
151
+ # Check environment
152
+ if ! check_environment; then
153
+ print_error "Please fix environment issues and run ./bin/setup manually"
154
+ exit 1
155
+ fi
156
+
157
+ # Run project setup
158
+ if ! run_project_setup; then
159
+ print_error "Setup failed. You can try running './bin/setup' manually"
160
+ exit 1
161
+ fi
162
+
163
+ # Project is ready
164
+ echo ""
165
+ echo "╔═══════════════════════════════════════════════════════════╗"
166
+ echo "║ ║"
167
+ echo "║ ✨ Project Setup Complete! ║"
168
+ echo "║ ║"
169
+ echo "╚═══════════════════════════════════════════════════════════╝"
170
+ echo ""
171
+ print_success "Rails project created and configured successfully"
172
+ echo ""
173
+ }
174
+
175
+ # Run main
176
+ main