Class: RailsAiBridge::Tools::ExplainSymbol::CliExplorer
- Inherits:
-
Object
- Object
- RailsAiBridge::Tools::ExplainSymbol::CliExplorer
- Defined in:
- lib/rails_ai_bridge/tools/explain_symbol/cli_explorer.rb
Overview
Runs local codegraph explore against an on-disk .codegraph/ index.
Uses argv arrays (no shell) and a wall-clock timeout. Never opens a network
connection — failures surface as ExploreError.
Constant Summary collapse
- DEFAULT_TIMEOUT_SECONDS =
15
Instance Method Summary collapse
-
#explore(query) ⇒ String
Markdown from
codegraph explore. -
#initialize(root:, timeout: DEFAULT_TIMEOUT_SECONDS) ⇒ CliExplorer
constructor
A new instance of CliExplorer.
Constructor Details
#initialize(root:, timeout: DEFAULT_TIMEOUT_SECONDS) ⇒ CliExplorer
Returns a new instance of CliExplorer.
17 18 19 20 |
# File 'lib/rails_ai_bridge/tools/explain_symbol/cli_explorer.rb', line 17 def initialize(root:, timeout: DEFAULT_TIMEOUT_SECONDS) @root = root @timeout = timeout end |
Instance Method Details
#explore(query) ⇒ String
Returns markdown from codegraph explore.
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rails_ai_bridge/tools/explain_symbol/cli_explorer.rb', line 25 def explore(query) stdout, stderr, status = run_explore(query) return stdout.to_s if status.success? raise ExploreError, failure_detail(stderr, status) rescue Errno::ENOENT raise ExploreError, 'codegraph CLI not found on PATH' rescue Timeout::Error raise ExploreError, "codegraph explore timed out after #{@timeout} seconds" end |