Module: AIGit

Defined in:
lib/ai_git/options.rb,
lib/ai_git.rb,
lib/ai_git/ui.rb,
lib/ai_git/git.rb,
lib/ai_git/config.rb,
lib/ai_git/prompt.rb,
lib/ai_git/secrets.rb,
lib/ai_git/version.rb,
lib/ai_git/ai_client.rb,
lib/ai_git/commands/config.rb,
lib/ai_git/commands/default.rb

Overview

lib/ai_git/version.rb

Defined Under Namespace

Modules: AIClient, Commands, Config, Git, Prompt, Secrets, UI Classes: Options

Constant Summary collapse

SUBCOMMANDS =
{
  "config" => AIGit::Commands::Config,
  "default" => AIGit::Commands::Default
}.freeze
HELP_FLAGS =
%w[-h --help help].freeze
VERSION_FLAGS =
%w[-v --version].freeze
USAGE =
<<~USAGE
  Usage: ai_git [subcommand] [options]

  Subcommands:
    (none)    Generate a commit message, commit, and push staged files
    config    Show the resolved provider configuration

  Options:
    -n, --dry-run  Print the generated message and change nothing
        --no-push  Commit locally without pushing
    -y, --yes      Skip the confirmation prompt (unattended)
    -f, --force    Proceed despite secret or remote-server warnings
    -h, --help     Show this message
    -v, --version  Print version

  On a terminal ai_git asks before committing: accept, edit, regenerate or
  quit. Piped or scripted runs commit and push unattended.

  Configuration (~/.ai_git/config.yml, or config.yaml):
    model_name: ggml-org/gemma-4-E4B-it-GGUF:Q8_0   Model to prompt
    base_url: http://127.0.0.1:8080                 llama.cpp server
    no_color: true                                  Disable colored output

  Run `ai_git config` to see the resolved settings and the file they
  come from.
USAGE
VERSION =
"1.0.1"

Class Method Summary collapse

Class Method Details

.start(args) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/ai_git.rb', line 62

def start(args)
  args = args.dup
  first = args.first

  return puts(USAGE) if first && HELP_FLAGS.include?(first)
  return puts(VERSION) if first && VERSION_FLAGS.include?(first)

  command = "default"
  if first && !first.start_with?("-")
    unless SUBCOMMANDS.key?(first)
      warn "Unknown subcommand: #{first}"
      warn USAGE
      exit 1
    end
    command = args.shift
  end

  SUBCOMMANDS[command].call(args)
end