Class: Rubino::Commands::Handlers::Help

Inherits:
Object
  • Object
show all
Defined in:
lib/rubino/commands/handlers/help.rb

Overview

The ‘/help` and `/commands` listings (and the unknown-command “Available:” roster), extracted from Commands::Executor (batch B). A plain collaborator given the command `loader` and the `ui` — it owns the built-in/keys/input reference text and the custom-command discovery copy.

Instance Method Summary collapse

Constructor Details

#initialize(ui:, loader:) ⇒ Help

Returns a new instance of Help.



11
12
13
14
# File 'lib/rubino/commands/handlers/help.rb', line 11

def initialize(ui:, loader:)
  @ui = ui
  @loader = loader
end

Instance Method Details

#available_commandsObject

All known slash commands (built-ins + discovered custom), used for the “Available:” hint on an unknown command (L6 — previously listed only custom commands, which is usually empty).



19
20
21
22
23
24
25
26
# File 'lib/rubino/commands/handlers/help.rb', line 19

def available_commands
  custom = begin
    @loader.names
  rescue StandardError
    []
  end
  (BuiltIns::NAMES + custom).uniq
end

#show_commandsObject



77
78
79
80
81
82
83
84
85
# File 'lib/rubino/commands/handlers/help.rb', line 77

def show_commands
  commands = @loader.all
  return explain_empty_commands if commands.empty?

  @ui.info("Custom commands  (run with /<name>; add --preview to see the prompt first):")
  commands.each do |cmd|
    @ui.info("  /#{cmd.name}#{custom_desc(cmd)}")
  end
end

#show_helpObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/rubino/commands/handlers/help.rb', line 28

def show_help
  @ui.info("Slash commands run actions or reusable prompts. Type /<name>; /help is this list.")
  @ui.blank_line
  @ui.info("Built-in:")
  rows  = help_builtin_rows
  width = rows.map { |name, _| name.length }.max
  rows.each do |name, desc|
    @ui.info("  #{name.ljust(width)}  - #{desc}")
  end
  @ui.blank_line

  # The `@` file-picker is a discoverable composer feature (type `@` to
  # autocomplete a workspace file) but was undocumented in /help (F14).
  # /paste and /clear-images already appear once under "Built-in" above,
  # so they're NOT repeated here — this section is image/file INPUT only,
  # no command rows (#87 de-dup).
  @ui.info("Input:")
  @ui.info("  ! <command>   - run a shell command yourself, no approval; output joins the context")
  @ui.info("  @<path>       - autocomplete a workspace file into the prompt")
  @ui.info("  @<image>      - attach an image (png/jpg/jpeg/gif/webp/bmp) to the turn")
  @ui.info("  <image path>  - drop or paste an image file path to attach it")
  @ui.blank_line

  # The keystroke vocabulary was invisible in /help (#87): a newcomer
  # couldn't learn how to cancel a turn, drive the approval menu, or that
  # Tab completes. One compact reference line covers it.
  @ui.info("Keys:")
  @ui.info("  ↑/↓ + Enter   - choose in the approval menu")
  @ui.info("  Enter         - send; during a turn, interrupt it and run this next")
  @ui.info("  Alt-Enter     - queue this to run after the current turn (or /queued <msg>)")
  @ui.info("  Shift-Tab     - cycle mode (default → plan → yolo)")
  @ui.info("  Ctrl-O        - reveal the last reasoning (collapsed or hidden)")
  @ui.info("  Ctrl-C        - cancel the turn (twice to exit)")
  @ui.info("  Esc Esc       - rewind to an earlier message (fork + edit & resend)")
  @ui.info("  Tab           - complete the highlighted /command or @file")
  @ui.info("  /             - start a command;  @  attach a file/image")
  @ui.blank_line

  custom = @loader.all
  if custom.any?
    @ui.info("Custom commands  (run with /<name>; add --preview to see the prompt first):")
    custom.each do |cmd|
      @ui.info("  /#{cmd.name}#{custom_desc(cmd)}")
    end
  else
    @ui.info("Custom commands  (none yet — run /commands to learn how to add one)")
  end
end