ask-github 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 61e0c09960d2b923d6209cc171870ccc4517b594fb4764ae7c5ffb611fe09e78
4
- data.tar.gz: 456ca8833ac0e354809e09d2cf1b84ea7b1354a26589aa74533981ebe63b5c4b
3
+ metadata.gz: f64d61d784bb31f0281d5aabedd9abe2937b335b25a85dee0d8246dbe7e6745b
4
+ data.tar.gz: d81bfb900b6d5c3f9cdfd7b5b6f6553ab9b5a93ecacbef219d5fda968dd3eb29
5
5
  SHA512:
6
- metadata.gz: db1fd215ba903feca7ba4c09fded2c10d7c306b54906224ee3a373f3ef3f0f85708535845d0a7abd46ed09aef82f9c4dfb1943f2b116682a1c085b056ef3dc49
7
- data.tar.gz: 591f2708a9538d55114a9c6add830b7409f030ab8313dd1a36c68b1cae38900e50c4dd7285a3e84725ccf8c33a38c348f90ed0ec73400bd470f3cc71c607c76f
6
+ metadata.gz: 9a8b8fe7c51f63e6a78e92f302010e10d3e7da2ad990b2f6b967d0624be0ab224c448a042dd8925459777710c370bbe787a7cd1596153623998907427c2a032a
7
+ data.tar.gz: 29b96dd81509ba2323990ebfd8742e580058840ac29e41e089cdcc918611932ae6338b3ef954b96b14f8dd6ad795d4f0faebc6d4d6cf2bcdfad42616a6f37c06
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ask
4
4
  module GitHub
5
- VERSION = "0.1.1"
5
+ VERSION = "0.1.2"
6
6
  end
7
7
  end
@@ -0,0 +1,86 @@
1
+ ---
2
+ name: github.use_github
3
+ description: How to navigate the GitHub API with Octokit — discover endpoints, handle auth, pagination, and errors
4
+ ---
5
+
6
+ Use this skill when you need to interact with GitHub — reading issues, pull
7
+ requests, repository contents, search, or managing projects using code tools.
8
+
9
+ ## Step 1: Get the Client
10
+
11
+ ```ruby
12
+ client = Ask::GitHub.client
13
+ ```
14
+
15
+ This returns an authenticated Octokit client. It expects a valid GitHub personal
16
+ access token resolved via `Ask::Auth.resolve(:github_token)`.
17
+
18
+ If you get an auth error, read `Ask::GitHub::Context::AUTH_HOW` for token setup.
19
+
20
+ ## Step 2: Explore the Context
21
+
22
+ The gem ships with structured context you should reference:
23
+
24
+ ```ruby
25
+ Ask::GitHub::Context::DOCS_URL # GitHub REST API docs
26
+ Ask::GitHub::Context::GEM_DOCS # Octokit Ruby docs
27
+ Ask::GitHub::Context::QUICK_START # Copy-paste examples
28
+ Ask::GitHub::Context::GEM_NAME # "octokit"
29
+ ```
30
+
31
+ The `QUICK_START` constant has basic usage examples for common operations
32
+ (issues, pull requests, contents, search).
33
+
34
+ ## Step 3: Discover Available Methods
35
+
36
+ Rather than assuming which methods exist, use code tools to explore the client:
37
+
38
+ ```ruby
39
+ # List all public methods (filter out Object basics)
40
+ Code.new.call(code: "
41
+ client = Ask::GitHub.client
42
+ puts (client.methods - Object.methods).sort.join(\"\\n\")
43
+ ")
44
+ ```
45
+
46
+ Octokit methods follow REST API patterns:
47
+ - `client.issues("owner/repo")` — list issues
48
+ - `client.pull_requests("owner/repo")` — list PRs
49
+ - `client.contents("owner/repo", path: "README.md")` — read file
50
+ - `client.search_issues("query")` — search across repos
51
+ - `client.create_issue("owner/repo", "Title", "body")` — create issue
52
+
53
+ For method specifics, read the Octokit source:
54
+ ```ruby
55
+ Grep.new.call(pattern: "def issues", path: "$GEM_PATH/octokit-*/lib")
56
+ ```
57
+
58
+ ## Step 4: Authentication Errors
59
+
60
+ Auth failures are converted to `Ask::Auth::InvalidCredential`. For detailed
61
+ error guidance, use:
62
+
63
+ ```ruby
64
+ Ask::GitHub::Errors.for("Octokit::NotFound")
65
+ Ask::GitHub::Errors.status_code_description(404)
66
+ Ask::GitHub::Errors::RATE_LIMIT
67
+ ```
68
+
69
+ Common scenarios:
70
+ - **401/403**: Token invalid or missing scopes → check token at GitHub settings
71
+ - **404**: Resource doesn't exist or is private → verify owner/repo and access
72
+ - **429**: Rate limited → wait and retry (5,000 req/hr with token)
73
+
74
+ ## Step 5: Pagination
75
+
76
+ Octokit auto-paginates by default (`auto_paginate: true`, `per_page: 100`).
77
+ For very large result sets, you can iterate manually using the response's
78
+ `rels` (relations) links.
79
+
80
+ ## Step 6: Fallback Strategy
81
+
82
+ If Octokit doesn't have a convenience method for what you need:
83
+ 1. Check `Ask::GitHub::Context::DOCS_URL` for the REST API endpoint
84
+ 2. Use `client.get("/endpoint")` for custom REST requests
85
+ 3. Use the GraphQL API via `client.post("/graphql", { query: "..." })` for complex queries
86
+ 4. For search, use `client.search_issues("...")` which supports GitHub's query syntax
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ask-github
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kaka Ruto
@@ -137,8 +137,7 @@ files:
137
137
  - lib/ask/github/context.rb
138
138
  - lib/ask/github/error_guide.rb
139
139
  - lib/ask/github/version.rb
140
- - lib/ask/skills/github.issue_triage/SKILL.md
141
- - lib/ask/skills/github.pr_review/SKILL.md
140
+ - lib/ask/skills/github.use_github/SKILL.md
142
141
  homepage: https://github.com/ask-rb/ask-github
143
142
  licenses:
144
143
  - MIT
@@ -1,144 +0,0 @@
1
- ---
2
- name: github.issue_triage
3
- description: Systematic approach for triaging GitHub issues — reproduce, classify, check duplicates, label, prioritize
4
- ---
5
-
6
- Use this skill when asked to handle a new GitHub issue, classify bug reports,
7
- or organize a queue of unprocessed issues.
8
-
9
- ## Step 1: Reproduce the Issue
10
-
11
- If the issue describes a bug, the first step is reproduction:
12
-
13
- ```ruby
14
- client = Ask::GitHub.client
15
- issue = client.issue("owner/repo", ISSUE_NUMBER)
16
- puts issue.title
17
- puts issue.body
18
- ```
19
-
20
- Extract from the issue body:
21
- 1. **Steps to reproduce** — are they complete and accurate?
22
- 2. **Expected behavior** — what should happen
23
- 3. **Actual behavior** — what happens instead
24
- 4. **Environment** — OS, version, browser, dependencies
25
- 5. **Error messages** — exact text, stack traces, screenshots
26
-
27
- If steps are missing, ask for them. Never triage a bug that can't be reproduced.
28
-
29
- ## Step 2: Classify the Issue
30
-
31
- Determine what type of issue it is:
32
-
33
- **Bug** — Unexpected behavior, crash, error
34
- - Severity: Critical (production outage) / Major (broken feature) / Minor (cosmetic)
35
-
36
- **Feature Request** — New capability or enhancement
37
- - Scope: Small (add param) / Medium (new endpoint) / Large (new subsystem)
38
-
39
- **Question** — How-to, clarification,usage help
40
- - Answerable from docs? Redirect to docs first.
41
-
42
- **Task** — Chore, tech debt, CI fix, dependency update
43
- - Effort: Small / Medium / Large
44
-
45
- ## Step 3: Check for Duplicates
46
-
47
- Search for similar existing issues:
48
-
49
- ```ruby
50
- # Search for keywords from the issue title
51
- similar = client.search_issues("keyword repo:owner/repo is:issue")
52
- similar.items.each { |i| puts "##{i.number}: #{i.title} (#{i.state})" }
53
- ```
54
-
55
- Check both open AND closed issues — a previously closed issue might have been
56
- reopened in a new form.
57
-
58
- Mark as duplicate if:
59
- - Same root cause (different symptom? still a duplicate)
60
- - Same feature request (even different proposed API shape)
61
- - References the same error message or stack trace
62
-
63
- If duplicate found, add a comment:
64
- ```ruby
65
- client.add_comment("owner/repo", ISSUE_NUMBER, "Duplicate of #123. Closing.")
66
- client.update_issue("owner/repo", ISSUE_NUMBER, state: "closed")
67
- ```
68
-
69
- ## Step 4: Add Labels
70
-
71
- Apply appropriate labels based on classification:
72
-
73
- ```ruby
74
- labels = []
75
- labels << "bug" if bug
76
- labels << "enhancement" if feature
77
- labels << "question" if question
78
- labels << priority_label(severity) # "critical", "high", "medium", "low"
79
- labels << "needs-reproduction" if steps_to_repro_missing
80
- labels << "good-first-issue" if simple and well-scoped
81
-
82
- client.add_labels_to_an_issue("owner/repo", ISSUE_NUMBER, labels)
83
- ```
84
-
85
- If the issue needs more information to be actionable:
86
- ```ruby
87
- labels << "needs-info"
88
- client.update_issue("owner/repo", ISSUE_NUMBER, labels: labels)
89
- ```
90
-
91
- ## Step 5: Prioritize
92
-
93
- Priority matrix based on:
94
-
95
- ```
96
- | Critical | Major | Minor
97
- User Impact | High | High | Low
98
- Workaround | None | Some | Has
99
- Frequency | Always | Often | Rare
100
- Scope | All | Some | Edge
101
- ```
102
-
103
- **Critical** — Fix immediately, patch release: P0
104
- - Production outage, data loss, security vulnerability
105
-
106
- **High** — Fix this sprint: P1
107
- - Feature broken for most users, no workaround
108
-
109
- **Medium** — Schedule next sprint: P2
110
- - Feature broken for some users, has workaround
111
-
112
- **Low** — Backlog, community PR welcome: P3
113
- - Enhancement, nice-to-have, rare edge case
114
-
115
- ## Step 6: Add Context
116
-
117
- If the issue references code, trace through the codebase to add helpful context:
118
-
119
- ```ruby
120
- # Search for related code
121
- search_paths = ["app/", "lib/"] # adjust for repo structure
122
- Glob.new.call(pattern: "app/**/*.rb") # check the repo structure
123
- ```
124
-
125
- Add a triage comment summarizing:
126
- 1. Brief reproduction status
127
- 2. Classification
128
- 3. Priority with reasoning
129
- 4. Suggested approach (if bug: fix direction; if feature: implementation sketch)
130
- 5. @mention relevant maintainer if needed
131
-
132
- ```ruby
133
- client.add_comment("owner/repo", ISSUE_NUMBER, "Triage summary: ...")
134
- ```
135
-
136
- ## Failure Mode Guide
137
-
138
- | Situation | Action |
139
- |-----------|--------|
140
- | Can't reproduce | Label `needs-info`, ask for more details |
141
- | Incomplete report | Request specific missing information |
142
- | Security issue | Do NOT file publicly — create private advisory |
143
- | Controversial feature request | Label `needs-discussion`, ping maintainers |
144
- | Issue spam | Label `invalid`, close immediately |
@@ -1,143 +0,0 @@
1
- ---
2
- name: github.pr_review
3
- description: Systematic methodology for reviewing GitHub pull requests
4
- ---
5
-
6
- Use this skill when asked to review a GitHub pull request. Follow the steps
7
- in order — each provides context needed for the next.
8
-
9
- ## Step 1: Understand the Change
10
-
11
- First, get the big picture:
12
-
13
- ```ruby
14
- client = Ask::GitHub.client
15
- files = client.pull_request_files("owner/repo", PR_NUMBER)
16
- ```
17
-
18
- Review the file list:
19
- - **Total files changed** — is this a reasonable scope?
20
- - **File types** — config, app code, tests, migrations, docs?
21
- - **Lines added vs deleted** — is it mostly new code or refactoring?
22
-
23
- Then get the full diff for each file:
24
-
25
- ```ruby
26
- files.each do |f|
27
- puts "#{f.filename}: +#{f.additions}/-#{f.deletions}"
28
- end
29
- ```
30
-
31
- For large PRs, focus on the core logic files and skip generated/config changes
32
- unless they're the purpose of the PR.
33
-
34
- ## Step 2: Read the PR Description and Related Issues
35
-
36
- ```ruby
37
- pr = client.pull_request("owner/repo", PR_NUMBER)
38
- puts pr.title
39
- puts pr.body
40
- ```
41
-
42
- Check for:
43
- - **Motivation** — is the WHY clear?
44
- - **Related issues** — does `pr.body` reference #123 or "Closes #123"?
45
- - **Testing strategy** — does it mention how it was tested?
46
- - **Deployment considerations** — migrations, config changes, feature flags?
47
-
48
- If issues are referenced, review them for context:
49
-
50
- ```ruby
51
- client.issue("owner/repo", ISSUE_NUMBER)
52
- ```
53
-
54
- ## Step 3: Review Tests First
55
-
56
- Look at the test files changed:
57
-
58
- ```ruby
59
- test_files = files.select { |f| f.filename.match?(/_test\.rb|_spec\.rb$/) }
60
- test_files.each do |f|
61
- # Read the test content
62
- client.contents("owner/repo", path: f.filename)
63
- end
64
- ```
65
-
66
- Check:
67
- - **Coverage** — does every new method/logic path have a test?
68
- - **Edge cases** — empty state, error handling, boundary conditions?
69
- - **Test quality** — are they testing the behavior or the implementation?
70
- - **Setup/teardown** — are shared states properly isolated?
71
-
72
- ## Step 4: Review Core Logic
73
-
74
- Review the main implementation files:
75
-
76
- ```ruby
77
- app_files = files.reject { |f| f.filename.match?(/_test\.rb|_spec\.rb$/) }
78
- app_files.each do |f|
79
- content = client.contents("owner/repo", path: f.filename)
80
- # Review the content
81
- end
82
- ```
83
-
84
- What to look for:
85
- - **Security**: SQL injection (raw SQL, string interpolation), mass assignment,
86
- authentication bypass, exposed credentials
87
- - **Correctness**: Off-by-one errors, nil checks, edge case handling
88
- - **Performance**: N+1 queries, missing eager loading, unnecessary allocations
89
- - **Pattern consistency**: Follows existing code conventions?
90
- - **Error handling**: What happens when external services fail?
91
-
92
- ## Step 5: Check for Common Anti-Patterns
93
-
94
- Scan for these common issues:
95
-
96
- 1. **Hard-coded values** — should be config or environment variables
97
- 2. **TODO/FIXME/HACK comments** — left-behind development artifacts
98
- 3. **Commented-out code** — should be removed before merge
99
- 4. **Overly complex methods** — more than 10-15 lines suggests refactoring needed
100
- 5. **Duplicate logic** — extract to shared method or concern
101
- 6. **Missing validations** — user input not validated before database insert
102
-
103
- ## Step 6: Assess Test Results and CI
104
-
105
- If available, check CI status:
106
-
107
- ```ruby
108
- # Check commit status
109
- client.commit_status("owner/repo", pr.head.sha)
110
- ```
111
-
112
- If tests are failing or CI is red, DO NOT approve the PR until that's addressed.
113
-
114
- ## Step 7: Write the Review
115
-
116
- Structure your review feedback:
117
-
118
- 1. **Summary** — 2-3 sentences about what the PR does
119
- 2. **Positive feedback** — what's done well (specific examples)
120
- 3. **Required changes** — bugs, security issues, breaking tests
121
- 4. **Suggestions** — improvements that are optional (performance, style)
122
- 5. **Questions** — anything unclear that the author should clarify
123
-
124
- Use GitHub's review API:
125
-
126
- ```ruby
127
- client.create_pull_request_review(
128
- "owner/repo",
129
- PR_NUMBER,
130
- body: "Summary...",
131
- event: "COMMENT" # or "APPROVE" or "REQUEST_CHANGES"
132
- )
133
- ```
134
-
135
- ## Failure Mode Guide
136
-
137
- | Situation | Action |
138
- |-----------|--------|
139
- | No test coverage | Request tests before approval |
140
- | Security vulnerability | Block with clear explanation, suggest fix |
141
- | PR has merge conflicts | Note that it needs rebase before review |
142
- | Large PR (>500 lines) | Focus on core logic, note scoping concerns |
143
- | Missing description | Ask for context before detailed review |