Class: SkillBench::Commands::Init

Inherits:
Object
  • Object
show all
Defined in:
lib/skill_bench/commands/init.rb

Overview

Handles the ‘skill-bench init` command. Generates a skill-bench.json config file with single-provider settings.

Class Method Summary collapse

Class Method Details

.config_for_provider(provider) ⇒ Hash

Generates configuration hash for a specific provider.

Parameters:

  • provider (Symbol)

    LLM provider name

Returns:

  • (Hash)

    Single-provider configuration

Raises:

  • (ArgumentError)

    if provider is not registered



30
31
32
33
34
35
36
# File 'lib/skill_bench/commands/init.rb', line 30

def self.config_for_provider(provider)
  {
    provider: provider,
    max_execution_time: 30,
    config: SkillBench::Clients::ProviderSchemas.for(provider)
  }
end

.run(provider:, force: false) ⇒ void

This method returns an undefined value.

Run the init command to generate config.

Parameters:

  • provider (Symbol)

    LLM provider name (e.g., :openai, :gemini)

  • force (Boolean) (defaults to: false)

    Whether to overwrite an existing config file.

Raises:

  • (RuntimeError)

    if config file exists and force is false

  • (ArgumentError)

    if provider is not registered



18
19
20
21
22
23
# File 'lib/skill_bench/commands/init.rb', line 18

def self.run(provider:, force: false)
  raise "Config file '#{SkillBench::Config::CONFIG_FILENAME}' already exists. Use --force to overwrite." if File.exist?(SkillBench::Config::CONFIG_FILENAME) && !force

  config = config_for_provider(provider)
  File.write(SkillBench::Config::CONFIG_FILENAME, JSON.pretty_generate(config))
end