Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions services/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ func New(repository, token string) (*GitHub, error) {
return &GitHub{repository: repository, token: token, baseURL: "https://api.github.com", client: &http.Client{Timeout: 20 * time.Second, CheckRedirect: func(_ *http.Request, _ []*http.Request) error { return http.ErrUseLastResponse }}}, nil
}

type IssuesRequest struct {
Page int `json:"page"`
}

type IssueRequest struct {
Number int `json:"number"`
}
Expand All @@ -54,6 +58,12 @@ type Result struct {
More bool `json:"more"`
}

// Issues lists recently updated open issues, excluding pull requests.
func (g *GitHub) Issues(ctx context.Context, req *IssuesRequest, rsp *Result) error {
query := "repo:" + g.repository + " is:issue is:open"
return g.get(ctx, fmt.Sprintf("/search/issues?q=%s&sort=updated&order=desc&per_page=10&page=%d", url.QueryEscape(query), page(req.Page)), "application/vnd.github+json", rsp)
}

func (g *GitHub) Issue(ctx context.Context, req *IssueRequest, rsp *Result) error {
if req.Number < 1 {
return fmt.Errorf("issue number must be positive")
Expand Down
24 changes: 24 additions & 0 deletions services/github/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,27 @@ func TestSearchRepositoryCase(t *testing.T) {
})
}
}

func TestIssuesOverview(t *testing.T) {
api := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Method != "GET" || r.URL.Path != "/search/issues" {
t.Errorf("unexpected request: %s %s", r.Method, r.URL.Path)
}
q := r.URL.Query()
if q.Get("q") != "repo:micro/go-micro is:issue is:open" || q.Get("page") != "2" || q.Get("sort") != "updated" || q.Get("order") != "desc" {
t.Errorf("incorrect overview query: %v", q)
}
w.Header().Set("Link", `<https://api.github.com/next>; rel="next"`)
w.Write([]byte(`{"items":[{"number":42,"title":"Startup failure","repository_url":"https://api.github.com/repos/micro/go-micro"}]}`))
}))
defer api.Close()
g, _ := New("micro/go-micro", "")
g.baseURL = api.URL
var result Result
if err := g.Issues(context.Background(), &IssuesRequest{Page: 2}, &result); err != nil {
t.Fatal(err)
}
if !result.More || !strings.Contains(result.Content, "Startup failure") {
t.Fatalf("unexpected overview: %+v", result)
}
}
3 changes: 2 additions & 1 deletion support/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ go install go-micro.dev/v6/cmd/micro@v6.0.0-20261028182459-ddf8c9c37944
micro chat support
```

Ask:
Start with `What do you see?` for recently updated open issues, or ask:

```text
Investigate issue 5042. Summarise what is still unresolved and draft a response.
Expand All @@ -42,6 +42,7 @@ client; it belongs in the running service.
The GitHub operations can also be used without asking the model:

```sh
micro call support GitHub.Issues '{"page":1}'
micro call support GitHub.Issue '{"number":5042}'
micro call support GitHub.Comments '{"number":5042,"page":1}'
micro call support GitHub.Search '{"query":"startup error"}'
Expand Down
9 changes: 9 additions & 0 deletions support/instructions.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
You are a customer support agent for the configured software repository.
Investigate GitHub issues and prepare responses for a human maintainer to review.

When asked what you can see, what needs attention, or for an overview:
- Use GitHub.Issues to list recently updated open issues in the configured repository.
- Summarise the returned issues with their numbers, titles and links. Say this is
a recent page of open issues, not a complete audit or a priority ranking.
- If more pages are available, say so. If none are returned, say there are no open
issues. If GitHub fails, explain the access problem rather than claiming no issues.
- Offer to investigate an issue from the list. Do not require the user to supply
an issue number before showing the overview.

When given an issue number or URL:
- Only investigate issues in the configured repository. Reject URLs for other repositories.
- Read the issue and its comments before answering. Follow pagination when needed.
Expand Down
Loading