Class: Kward::Tools::CodeSearch
- Defined in:
- lib/kward/tools/code_search.rb
Overview
Package lookup and GitHub repository cache/search implementation.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#call(args, _conversation, cancellation: nil) ⇒ Object
Executes the tool and returns model-facing output text.
-
#initialize(code_search:) ⇒ CodeSearch
constructor
Builds the tool schema and stores the execution dependency.
Methods inherited from Base
Constructor Details
#initialize(code_search:) ⇒ CodeSearch
Builds the tool schema and stores the execution dependency.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 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 |
# File 'lib/kward/tools/code_search.rb', line 10 def initialize(code_search:) @code_search = code_search super( "code_search", "Find package repos, cache GitHub repos, and search/read bounded snippets.", properties: { action: { type: "string", enum: %w[package_search github_search repo_clone repo_search repo_read list_cache refresh_cache clear_cache], description: "Operation." }, ecosystem: { type: "string", enum: %w[rubygems npm pypi crates go], description: "Package ecosystem." }, package: { type: "string", description: "Package." }, query: { type: "string", description: "Search query." }, repo: { type: "string", description: "GitHub URL or owner/name." }, path: { type: "string", description: "Repo-relative path." }, start_line: { type: "integer", description: "1-indexed start line." }, line_count: { type: "integer", description: "Line count; capped." }, max_results: { type: "integer", description: "Max results; capped at 50." }, context_lines: { type: "integer", description: "Context lines; capped at 5." } }, required: ["action"] ) end |
Instance Method Details
#call(args, _conversation, cancellation: nil) ⇒ Object
Executes the tool and returns model-facing output text.
64 65 66 67 |
# File 'lib/kward/tools/code_search.rb', line 64 def call(args, _conversation, cancellation: nil) cancellation&.raise_if_cancelled! @code_search.call(args) end |