Skip to content

feat(cli): fetch issue by number directly from GitHub (#17)#45

Open
mahsumaktas wants to merge 5 commits intosimiligh:mainfrom
mahsumaktas:feat/cli-fetch-issue-17
Open

feat(cli): fetch issue by number directly from GitHub (#17)#45
mahsumaktas wants to merge 5 commits intosimiligh:mainfrom
mahsumaktas:feat/cli-fetch-issue-17

Conversation

@mahsumaktas
Copy link
Contributor

@mahsumaktas mahsumaktas commented Feb 13, 2026

Summary

Implements #17 — adds support for fetching issues directly from GitHub by number, eliminating the need for a local JSON file.

Usage

# Fetch and process issue #17 from similigh/simili-bot
simili process --repo similigh/simili-bot --number 17

# Using separate --org and --repo flags
simili process --org similigh --repo simili-bot --number 17

# Using GITHUB_REPOSITORY env var (CI-friendly)
export GITHUB_REPOSITORY=similigh/simili-bot
simili process --number 17

The existing --issue <file> path continues to work as before.

Changes

cmd/simili/commands/process.go

  • New flow: When --issue is not provided but --number is, fetches the issue via github.Client.GetIssue()
  • resolveIssueRepo() — resolves org/repo from:
    1. --repo owner/name (preferred)
    2. --org + --repo separately
    3. GITHUB_REPOSITORY env var fallback
  • githubIssueToPipelineIssue() — converts *github.Issue to pipeline.Issue with proper field mapping
    • Sets EventType: "issues", EventAction: "opened" for directly fetched issues
    • Safely handles nil fields via GitHub API getter methods
  • Updated Long description documenting the new usage patterns
  • Cleaned up the old manual byte-scanning for GITHUB_REPOSITORY parsing (replaced with strings.SplitN)

cmd/simili/commands/process_test.go

  • TestGithubIssueToPipelineIssue — full conversion with all fields
  • TestGithubIssueToPipelineIssue_NilIssue — nil safety

Validation

go build ./...   #
go test ./...    # ✅ all passed

Notes

  • Uses GITHUB_TOKEN (or TRANSFER_TOKEN) for authentication — same as existing GitHub client usage
  • No new dependencies — uses the already-imported go-github/v60 package
  • No breaking changes for existing --issue <file> users

Summary by CodeRabbit

  • New Features

    • Fetch GitHub issues by number (--number), deriving org/repo from flags or environment; inject fetched issue into the processing flow and allow overriding via --issue, --repo, --org. Requires TRANSFER_TOKEN or GITHUB_TOKEN for authenticated fetches.
  • Bug Fixes

    • Improved validation and clearer error messages for missing inputs or missing authentication when fetching by number.
  • Documentation

    • Updated CLI help/usage to document fetching, overrides, and token requirements.
  • Tests

    • Added tests for converting GitHub issues into the pipeline format, including nil-input defaults.

@coderabbitai
Copy link

coderabbitai bot commented Feb 13, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds GitHub issue fetching to the process command when --number is provided: resolves org/repo from flags or GITHUB_REPOSITORY, requires TRANSFER_TOKEN/GITHUB_TOKEN, fetches the issue via GitHub API, converts it to pipeline.Issue, and integrates it into existing processing. (50 words)

Changes

Cohort / File(s) Summary
Process command (GitHub integration)
cmd/simili/commands/process.go
Implements real GitHub fetch when --number is used; adds resolveIssueRepo and githubIssueToPipelineIssue helpers; token handling (TRANSFER_TOKEN/GITHUB_TOKEN); maps GH issue fields to pipeline.Issue; updates help text and error paths.
Tests for conversion
cmd/simili/commands/process_test.go
Adds TestGithubIssueToPipelineIssue and TestGithubIssueToPipelineIssue_NilIssue to validate mapping and defaults; imports GH API types for fixtures.
Build / manifest
go.mod, manifest_file
Dependency and manifest updates to include GitHub API client and any required module changes referenced by new code.

Sequence Diagram

sequenceDiagram
    participant User as CLI User
    participant Cmd as Process Command
    participant Resolver as resolveIssueRepo
    participant Auth as Token Resolver
    participant GitHub as GitHub API
    participant Converter as githubIssueToPipelineIssue
    participant Pipeline as Pipeline

    User->>Cmd: run `process` with --number
    Cmd->>Resolver: derive org/repo from flags or env
    Resolver-->>Cmd: org, repo (or error)
    Cmd->>Auth: read TRANSFER_TOKEN / GITHUB_TOKEN
    Auth-->>Cmd: token (or error)
    Cmd->>GitHub: GET /repos/{org}/{repo}/issues/{number} (auth)
    GitHub-->>Cmd: GitHub Issue payload
    Cmd->>Converter: map GitHub issue -> pipeline.Issue
    Converter-->>Cmd: pipeline.Issue
    Cmd->>Pipeline: submit pipeline.Issue for processing
    Pipeline-->>User: result / error
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Poem

🐇 I sniff the repo, hop to the thread,
Pull out the title and breadcrumbs of thread,
Labels and author, I bundle with care,
Toss it to the pipeline — off through the air,
Hooray for tokens, fetch, and a rabbit's small dare.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(cli): fetch issue by number directly from GitHub (#17)' clearly and concisely describes the main change: adding CLI support to fetch GitHub issues by number.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@cmd/simili/commands/process.go`:
- Around line 139-148: The override logic in the function updating issue
(variables issue, orgName, repoName, issueNum) ignores a slash-formatted --repo
(owner/name); update the block that applies overrides so that when repoName
contains a "/" you parse it (e.g., split on "/" into owner and repo) and set
issue.Org and issue.Repo accordingly, while still letting explicit --org
override the owner; alternatively, if you prefer not to auto-parse, emit a clear
warning via the same logger when --issue is used together with a slash-formatted
--repo to avoid silent ignoring.

Comment on lines 139 to 148
// Apply optional overrides when --issue is used
if orgName != "" {
issue.Org = orgName
}
if repoName != "" && !strings.Contains(repoName, "/") {
issue.Repo = repoName
}
if issueNum != 0 {
issue.Number = issueNum
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

--repo owner/name is silently ignored when combined with --issue.

When --issue is provided along with --repo owner/name (containing a slash), neither the org nor repo from the slash-formatted value are applied because:

  • Line 140-142 only sets issue.Org from --org, not from --repo owner/name
  • Line 143-145 explicitly skips setting issue.Repo when repoName contains "/"

This may cause user confusion. Consider either parsing --repo owner/name here as well, or logging a warning when this combination is detected.

Suggested fix to parse `--repo owner/name` consistently
 		// Apply optional overrides when --issue is used
-		if orgName != "" {
-			issue.Org = orgName
-		}
-		if repoName != "" && !strings.Contains(repoName, "/") {
-			issue.Repo = repoName
-		}
+		if repoName != "" && strings.Contains(repoName, "/") {
+			parts := strings.SplitN(repoName, "/", 2)
+			if len(parts) == 2 {
+				issue.Org = strings.TrimSpace(parts[0])
+				issue.Repo = strings.TrimSpace(parts[1])
+			}
+		} else {
+			if orgName != "" {
+				issue.Org = orgName
+			}
+			if repoName != "" {
+				issue.Repo = repoName
+			}
+		}
🤖 Prompt for AI Agents
In `@cmd/simili/commands/process.go` around lines 139 - 148, The override logic in
the function updating issue (variables issue, orgName, repoName, issueNum)
ignores a slash-formatted --repo (owner/name); update the block that applies
overrides so that when repoName contains a "/" you parse it (e.g., split on "/"
into owner and repo) and set issue.Org and issue.Repo accordingly, while still
letting explicit --org override the owner; alternatively, if you prefer not to
auto-parse, emit a clear warning via the same logger when --issue is used
together with a slash-formatted --repo to avoid silent ignoring.

Signed-off-by: Mahsum Aktas <mahsum@mahsumaktas.com>
@mahsumaktas mahsumaktas force-pushed the feat/cli-fetch-issue-17 branch from 0835c1e to eead182 Compare February 14, 2026 19:09
@mahsumaktas
Copy link
Contributor Author

Friendly ping! 👋 This has been ready for review. Let me know if any changes are needed.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@cmd/simili/commands/process.go`:
- Around line 139-148: When --issue is used together with --repo owner/name the
current check (!strings.Contains(repoName, "/")) silently ignores owner/name;
fix this by detecting and parsing the owner/name form: if repoName contains "/"
split it into owner and repo (e.g., parts := strings.SplitN(repoName, "/", 2))
and set issue.Org and issue.Repo accordingly (overriding orgName only if owner
present), otherwise keep the existing behavior for simple repo names; update the
block that assigns issue.Org and issue.Repo (the variables issue, orgName,
repoName, issueNum in process.go) to perform this parsing and assignment.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@cmd/simili/commands/process.go`:
- Around line 139-148: The current logic silently ignores a slash-formatted
--repo when --issue is used; change the block that handles
repoName/orgName/issue to detect if repoName contains a "/" and split it into
owner and repo (e.g., parts := strings.SplitN(repoName, "/", 2)) then set
issue.Org = parts[0] and issue.Repo = parts[1]; keep the existing behavior where
an explicit orgName flag overrides the owner part (i.e., if orgName != "" use
that instead of parts[0]); optionally emit a warning via the existing logger if
both orgName and a slash-formatted repo are provided to clarify which value
wins.

@mahsumaktas
Copy link
Contributor Author

Closing — this has been open for a while and the codebase may have moved on. Happy to reopen or submit a fresh PR if still needed!

@Kavirubc
Copy link
Member

Hey @mahsumaktas ,

Thanks for contributing. I'm reopning the PR for merge in few hours. I have a PR that need to be merged before this.

You can work on any issues from our milestone 0.2.0v https://github.com/similigh/simili-bot/milestone/3 here.

And also #53 is something I need help with as well.

Thank you.

@Kavirubc Kavirubc reopened this Feb 18, 2026
@Kavirubc Kavirubc added e2e and removed e2e labels Feb 18, 2026
@gh-simili-bot
Copy link

🧪 E2E Test

Bot responded: yes

Test repo → gh-simili-bot/simili-e2e-22148588473
Run → logs

Auto-generated by E2E pipeline

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments