Class: RubynCode::CLI::App

Inherits:
Object
  • Object
show all
Defined in:
lib/rubyn_code/cli/app.rb

Constant Summary collapse

HELP_TEXT =
<<~HELP
  rubyn-code - Ruby & Rails Agentic Coding Assistant

  Usage:
    rubyn-code                    Start interactive REPL
    rubyn-code -p "prompt"        Run a single prompt and exit
    rubyn-code --resume [ID]      Resume a previous session
    rubyn-code --setup            Pin rubyn-code to bypass rbenv/rvm
    rubyn-code --auth             Authenticate with Claude
    rubyn-code --ide              Start IDE server (VS Code extension)
    rubyn-code --permission-mode MODE  Set permission mode (default, accept_edits, plan_only, auto, dont_ask, bypass)
    rubyn-code --version          Show version
    rubyn-code --help             Show this help

  Daemon Mode:
    rubyn-code daemon             Start autonomous daemon (GOLEM)
    rubyn-code daemon --name NAME Agent name (default: golem-<random>)
    rubyn-code daemon --role ROLE Agent role description
    rubyn-code daemon --max-runs N     Max tasks before shutdown (default: 100)
    rubyn-code daemon --max-cost N     Max USD spend before shutdown (default: 10.0)
    rubyn-code daemon --idle-timeout N Seconds idle before shutdown (default: 60)
    rubyn-code daemon --poll-interval N Seconds between polls (default: 5)

  Interactive Commands:
    /help          Show available commands
    /quit          Exit
    /compact       Compress context
    /cost          Show usage costs
    /tasks         List tasks
    /skill [name]  Load or list skills

  Environment:
    Config:  ~/.rubyn-code/config.yml
    Data:    ~/.rubyn-code/rubyn_code.db
    Tokens:  ~/.rubyn-code/tokens.yml
HELP
SIMPLE_FLAGS =
{
  '--version' => :version, '-v' => :version,
  '--help' => :help, '-h' => :help,
  '--auth' => :auth, '--setup' => :setup
}.freeze
BOOLEAN_FLAGS =
{ '--yolo' => :yolo, '--debug' => :debug, '--skip-setup' => :skip_setup, '--ide' => :ide }.freeze
VALUE_FLAGS =
{ '--permission-mode' => :permission_mode }.freeze
DAEMON_INT_FLAGS =
{ '--max-runs' => :max_runs, '--idle-timeout' => :idle_timeout,
'--poll-interval' => :poll_interval }.freeze
DAEMON_STR_FLAGS =
{ '--name' => :agent_name, '--role' => :role }.freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ App

Returns a new instance of App.



10
11
12
13
# File 'lib/rubyn_code/cli/app.rb', line 10

def initialize(argv)
  @argv = argv
  @options = parse_options(argv)
end

Class Method Details

.start(argv) ⇒ Object



6
7
8
# File 'lib/rubyn_code/cli/app.rb', line 6

def self.start(argv)
  new(argv).run
end

Instance Method Details

#runObject



15
16
17
18
# File 'lib/rubyn_code/cli/app.rb', line 15

def run
  RubynCode::Debug.enable! if @options[:debug]
  dispatch_command(@options[:command])
end