Skip to content

Commit 8ea6141

Browse files
authored
feat(v0.6.0): write ops + diff/comments view flags + repo file reader (#6)
Make the plugin genuinely useful for agents driving real GitHub work, not just read-only summaries. Closes the gap where Merlin agents kept falling back to authenticated-failing `web-fetch` calls because the plugin couldn't surface diffs, comments, or file contents at a ref. prs: - `view` gets --diff and --comments append flags. - `comment <num> -b BODY` posts a PR comment. - `review <num> --approve | --request-changes | --comment-review` submits a review (--body required for the latter two). - `merge <num>` with --squash (default) | --merge | --rebase. - `close <num>` and `reopen <num>`. issues: - `view` gets a --comments flag. - `comment <num> -b BODY`, `close <num>`, `reopen <num>`. repo (new subcommand): - `view [-R OWNER/NAME] [--json]` — repo metadata. - `file <path> [-R OWNER/NAME] [-r REF] [--json]` — read a file's contents at any ref. Wraps `gh api repos/.../contents/...` and decodes the base64, so it works for private repos and arbitrary refs without needing a clone or a raw-URL token. Router and plugin.toml description updated; README + CHANGELOG follow. Bash strict-mode safe (empty-array expansion uses scalars), shellcheck clean at --severity=warning.
1 parent 001854c commit 8ea6141

7 files changed

Lines changed: 392 additions & 62 deletions

File tree

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
# Changelog
22

3+
## [v0.6.0] - 2026-05-21
4+
5+
### Features
6+
7+
- `prs view`: add `--diff` and `--comments` flags to append the unified diff and conversation comments + reviews to the view output.
8+
- `prs comment <NUMBER> -b BODY`: post a comment on a pull request.
9+
- `prs review <NUMBER>`: submit a review — one of `--approve`, `--request-changes`, or `--comment-review`, plus `--body`.
10+
- `prs merge <NUMBER>`: merge a PR with `--squash` (default), `--merge`, or `--rebase`.
11+
- `prs close <NUMBER>` / `prs reopen <NUMBER>`: close without merging or reopen.
12+
- `issues view`: add `--comments` flag to append the issue conversation.
13+
- `issues comment <NUMBER> -b BODY`: post a comment on an issue.
14+
- `issues close <NUMBER>` / `issues reopen <NUMBER>`.
15+
- New `repo` subcommand:
16+
- `repo view [-R OWNER/NAME] [--json]` — repo metadata.
17+
- `repo file <PATH> [-R OWNER/NAME] [-r REF] [--json]` — read a file's contents at any ref via `gh api repos/.../contents/...`. Closes the gap where agents fell back to authenticated-failing `web-fetch` against `raw.githubusercontent.com`.
18+
319
## [v0.5.0] - 2026-05-13
420

521
### Features

README.md

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,38 +37,61 @@ $ fledge github checks
3737

3838
JSON output is the raw GitHub API response from `repos/{owner}/{repo}/commits/{branch}/check-runs`.
3939

40-
### `fledge github issues [list | view <num> | create] [OPTIONS]`
40+
### `fledge github issues [list | view <num> | create | comment <num> | close <num> | reopen <num>] [OPTIONS]`
4141

42-
Browse and create issues. Lists by default; `view <number>` shows a specific one; `create` opens a new issue.
42+
Browse, create, and write to issues. Lists by default.
4343

4444
```
4545
$ fledge github issues --state all --limit 5
46-
$ fledge github issues view 42 --json
46+
$ fledge github issues view 42 --comments
4747
$ fledge github issues create --title "Bug: something broke"
48-
$ fledge github issues create --title "Feature request" --label enhancement --assignee octocat --json
48+
$ fledge github issues comment 42 -b "Reproduced on 0.3.1."
49+
$ fledge github issues close 42
50+
$ fledge github issues reopen 42
4951
```
5052

51-
List/view options: `--state {open,closed,all}`, `--limit <N>`, `--label <label>`, `--json`.
52-
Create options: `--title <title>`, `--body <body>`, `--label <label>`, `--assignee <login>`, `--json`.
53+
List/view options: `--state {open,closed,all}`, `--limit <N>`, `--label <label>`, `--json`, `--comments` (view).
54+
Create options: `--title <title>`, `--body <body>`, `--label <label>`, `--assignee <login>`, `--json`.
55+
Comment options: `--body <body>` (required), `--json`.
5356

54-
### `fledge github prs [list | view <num> | create] [OPTIONS]`
57+
### `fledge github prs [list | view <num> | create | comment <num> | review <num> | merge <num> | close <num> | reopen <num>] [OPTIONS]`
5558

56-
Browse and create pull requests. Lists by default; `view <number>` shows a specific one; `create` opens a new PR.
59+
The full PR surface. Lists by default; everything else takes a PR number.
5760

5861
```
5962
$ fledge github prs --state merged --limit 5
60-
$ fledge github prs view 256 --json
63+
$ fledge github prs view 256 --diff --comments
6164
$ fledge github prs create --fill
62-
$ fledge github prs create --ai
6365
$ fledge github prs create --ai --draft
64-
$ fledge github prs create --title "My feature" --draft --json
66+
$ fledge github prs comment 256 -b "Looks good — one nit inline."
67+
$ fledge github prs review 256 --approve
68+
$ fledge github prs review 256 --request-changes -b "See comments."
69+
$ fledge github prs merge 256 --squash
70+
$ fledge github prs close 256
6571
```
6672

67-
List/view options: `--state {open,closed,merged,all}`, `--limit <N>`, `--json`.
68-
Create options: `--title <title>`, `--body <body>`, `--base <branch>`, `--draft`, `--fill`, `--ai`, `--json`.
73+
List/view options: `--state {open,closed,merged,all}`, `--limit <N>`, `--json`, `--diff` (view, append unified diff), `--comments` (view, append conversation).
74+
Create options: `--title <title>`, `--body <body>`, `--base <branch>`, `--draft`, `--fill`, `--ai`, `--json`.
75+
Comment options: `--body <body>` (required), `--json`.
76+
Review options: one of `--approve` / `--request-changes` / `--comment-review`, plus `--body <body>` (required for the latter two).
77+
Merge options: `--squash` (default) | `--merge` | `--rebase`.
6978

7079
`--ai` generates a PR title and body by sending your commits and diff to `fledge ask`. It shows a preview and lets you confirm, edit, or abort before creating the PR.
7180

81+
### `fledge github repo [view | file <path>] [OPTIONS]`
82+
83+
Read repo metadata or fetch a file's contents at a ref. `file` wraps `gh api repos/.../contents/...` and decodes the base64, so it works for any branch/tag/SHA without needing a clone or a raw-URL token.
84+
85+
```
86+
$ fledge github repo view
87+
$ fledge github repo view -R CorvidLabs/merlin --json
88+
$ fledge github repo file CHANGELOG.md
89+
$ fledge github repo file Cargo.toml -r v0.3.0
90+
$ fledge github repo file README.md -R CorvidLabs/fledge-plugin-github
91+
```
92+
93+
Options: `-R, --repo <owner/name>` (default: current repo), `-r, --ref <ref>` (file only), `--json`.
94+
7295
### `fledge github poll [OPTIONS]`
7396

7497
Poll for new issues and PRs as structured event objects. Designed for [Merlin](https://github.com/CorvidLabs/merlin) daemon mode — the output matches the daemon `Event` schema.
@@ -89,7 +112,7 @@ A flat `checks`/`issues`/`prs` surface bakes "all dev happens on GitHub" into fl
89112

90113
## Hacking
91114

92-
`bin/fledge-github` is a thin dispatcher; each subcommand is a self-contained POSIX-ish shell script (`bin/fledge-github-checks`, `…-issues`, `…-prs`, `…-poll`). The scripts use `gh api` (or `gh issue`/`gh pr`) to talk to GitHub, then format the response — no extra runtime dependencies beyond `gh`, `git`, `python3`, and `awk`.
115+
`bin/fledge-github` is a thin dispatcher; each subcommand is a self-contained POSIX-ish shell script (`bin/fledge-github-checks`, `…-issues`, `…-prs`, `…-poll`, `…-repo`). The scripts use `gh api` (or `gh issue`/`gh pr`/`gh repo`) to talk to GitHub, then format the response — no extra runtime dependencies beyond `gh`, `git`, `python3`, `awk`, and `base64`.
93116

94117
## License
95118

bin/fledge-github

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ USAGE:
2424
2525
SUBCOMMANDS:
2626
checks View CI/CD check status for a branch
27-
issues List and view GitHub issues
28-
prs List and view GitHub pull requests
27+
issues List, view, create, comment on, close, and reopen GitHub issues
28+
prs List, view, create, comment on, review, merge, close, and reopen pull requests
29+
repo View repo metadata and read file contents at a ref
2930
poll Poll for new issues/PRs as daemon events (JSON)
3031
3132
Run `fledge github <SUBCOMMAND> --help` for subcommand-specific options.
@@ -41,7 +42,7 @@ SUB="$1"
4142
shift
4243

4344
case "$SUB" in
44-
checks|issues|prs|poll)
45+
checks|issues|prs|poll|repo)
4546
exec "${DIR}/fledge-github-${SUB}" "$@"
4647
;;
4748
-h|--help|help)

bin/fledge-github-issues

Lines changed: 62 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/env bash
2-
# fledge-github-issues — list, view, and create GitHub issues via the gh CLI.
3-
# Invoked via: fledge github issues [create | view <num> | list] [OPTIONS]
2+
# fledge-github-issues — list, view, create, comment on, close, and reopen
3+
# GitHub issues via the gh CLI.
4+
# Invoked via: fledge github issues [list | view <num> | create | comment <num> |
5+
# close <num> | reopen <num>] [OPTIONS]
46
set -euo pipefail
57

68
ACTION="list"
@@ -12,12 +14,13 @@ TITLE=""
1214
BODY=""
1315
ASSIGNEE=""
1416
JSON=false
17+
INCLUDE_COMMENTS=false
1518

16-
# First positional arg can be a subcommand: create, view, or list
19+
# First positional arg can be a subcommand.
1720
if [ $# -gt 0 ] && [ "${1:0:1}" != "-" ]; then
1821
case "$1" in
19-
view)
20-
ACTION="view"
22+
view|comment|close|reopen)
23+
ACTION="$1"
2124
shift
2225
if [ $# -gt 0 ] && [ "${1:0:1}" != "-" ]; then
2326
NUMBER="$1"
@@ -44,34 +47,44 @@ while [ $# -gt 0 ]; do
4447
-b|--body) BODY="${2:-}"; shift 2;;
4548
-a|--assignee) ASSIGNEE="${2:-}"; shift 2;;
4649
--json) JSON=true; shift;;
50+
--comments) INCLUDE_COMMENTS=true; shift;;
4751
-h|--help)
4852
cat <<'EOF'
49-
fledge github issues — list, view, and create GitHub issues
53+
fledge github issues — manage GitHub issues via the gh CLI
5054
5155
USAGE:
52-
fledge github issues [list] List open issues (default)
53-
fledge github issues view <NUMBER> View a specific issue
54-
fledge github issues create Create a new issue
56+
fledge github issues [list] List open issues (default)
57+
fledge github issues view <NUMBER> View a specific issue
58+
fledge github issues create Create a new issue
59+
fledge github issues comment <NUMBER> -b BODY Post a comment
60+
fledge github issues close <NUMBER> Close an issue
61+
fledge github issues reopen <NUMBER> Reopen a closed issue
5562
5663
LIST / VIEW OPTIONS:
5764
-s, --state <STATE> open | closed | all (default: open)
5865
-l, --limit <N> Maximum results (default: 20)
5966
--label <LABEL> Filter by label
6067
--json Output JSON
68+
--comments (view) Append the issue's conversation comments
6169
6270
CREATE OPTIONS:
6371
-t, --title <TITLE> Issue title
6472
-b, --body <BODY> Issue body
65-
--label <LABEL> Attach label (repeatable)
73+
--label <LABEL> Attach label (repeatable on the gh side)
6674
-a, --assignee <LOGIN> Assign to user
6775
--json Output JSON (number, url, title)
6876
77+
COMMENT OPTIONS:
78+
-b, --body <BODY> Comment body (required)
79+
--json Output JSON (url)
80+
6981
EXAMPLES:
7082
fledge github issues
7183
fledge github issues --state all --limit 50
72-
fledge github issues view 42 --json
84+
fledge github issues view 42 --comments
7385
fledge github issues create --title "Bug: something broke"
74-
fledge github issues create --title "Feature request" --label enhancement --assignee octocat
86+
fledge github issues comment 42 -b "Reproduced on 0.3.1 too."
87+
fledge github issues close 42
7588
EOF
7689
exit 0
7790
;;
@@ -87,16 +100,49 @@ if ! command -v gh >/dev/null 2>&1; then
87100
exit 127
88101
fi
89102

103+
case "$ACTION" in
104+
view|comment|close|reopen)
105+
if [ -z "$NUMBER" ]; then
106+
echo "fledge github issues: '$ACTION' requires an issue number. Try: fledge github issues $ACTION 42" >&2
107+
exit 64
108+
fi
109+
;;
110+
esac
111+
90112
if [ "$ACTION" = "view" ]; then
91-
if [ -z "$NUMBER" ]; then
92-
echo "fledge github issues: 'view' requires an issue number. Try: fledge github issues view 42" >&2
93-
exit 64
94-
fi
95113
if [ "$JSON" = "true" ]; then
96114
gh issue view "$NUMBER" --json number,title,state,author,body,labels,createdAt,updatedAt,url,assignees
97115
else
98116
gh issue view "$NUMBER"
99117
fi
118+
if [ "$JSON" != "true" ] && [ "$INCLUDE_COMMENTS" = "true" ]; then
119+
printf '\n--- Comments ---\n'
120+
gh issue view "$NUMBER" --comments
121+
fi
122+
exit 0
123+
fi
124+
125+
if [ "$ACTION" = "comment" ]; then
126+
if [ -z "$BODY" ]; then
127+
echo "fledge github issues: 'comment' requires --body" >&2
128+
exit 64
129+
fi
130+
if [ "$JSON" = "true" ]; then
131+
URL="$(gh issue comment "$NUMBER" -b "$BODY")"
132+
printf '{"url":"%s"}\n' "$URL"
133+
else
134+
gh issue comment "$NUMBER" -b "$BODY"
135+
fi
136+
exit 0
137+
fi
138+
139+
if [ "$ACTION" = "close" ]; then
140+
gh issue close "$NUMBER"
141+
exit 0
142+
fi
143+
144+
if [ "$ACTION" = "reopen" ]; then
145+
gh issue reopen "$NUMBER"
100146
exit 0
101147
fi
102148

0 commit comments

Comments
 (0)