Module: Ask::GitHub
- Defined in:
- lib/ask/github/client.rb,
lib/ask/github/context.rb,
lib/ask/github/version.rb,
lib/ask/github/error_guide.rb
Defined Under Namespace
Modules: Errors Classes: ClientProxy
Constant Summary collapse
- DESCRIPTION =
Human-readable description of the GitHub service context.
"GitHub — code hosting, issues, pull requests, actions, packages"- DOCS_URL =
Base URL for GitHub REST API documentation.
"https://docs.github.com/en/rest"- OPENAPI_URL =
URL for the GitHub OpenAPI specification.
"https://api.github.com/openapi.json"- AUTH_NAME =
Credential name used with Ask::Auth.resolve.
:github_token- AUTH_HOW =
Instructions for obtaining a GitHub personal access token.
"https://github.com/settings/tokens — scopes: repo, read:org"- GEM_NAME =
Gem name for the GitHub API client.
"octokit"- GEM_VERSION =
Required gem version constraint.
"~> 9.0"- GEM_DOCS =
URL for Octokit Ruby library documentation.
"https://octokit.github.io/octokit.rb"- QUICK_START =
Quick-start Ruby code snippet for agents to copy-paste.
<<~RUBY client = Ask::GitHub.client client.issues("owner/repo") client.create_issue("owner/repo", "Title", "Body") client.pull_requests("owner/repo") client.contents("owner/repo", path: "Gemfile") client.search_issues("query") RUBY
- VERSION =
"0.1.2"
Class Method Summary collapse
-
.client ⇒ Octokit::Client
Returns an authenticated Octokit client configured for an AI agent.
Class Method Details
.client ⇒ Octokit::Client
Returns an authenticated Octokit client configured for an AI agent.
Resolves the GitHub token via Ask::Auth.resolve(:github_token) and configures the client with sensible defaults:
-
auto_paginate:true(collects all pages automatically) -
per_page:100(maximum items per page) -
middleware: Faraday retry middleware (3 retries, exponential backoff)
The client is wrapped in a ClientProxy that converts Octokit::Unauthorized into Ask::Auth::InvalidCredential.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/ask/github/client.rb', line 27 def self.client token = Ask::Auth.resolve(:github_token) client = Octokit::Client.new(access_token: token, auto_paginate: true, per_page: 100) # Configure Faraday retry middleware for transient failures client.middleware = Faraday::RackBuilder.new do |builder| builder.request :retry, max: 3, interval: 1, backoff_factor: 2, retry_statuses: [429, 500, 502, 503] builder.adapter Faraday.default_adapter end ClientProxy.new(client) end |