fleet-agents 0.1.0
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.
- package/LICENSE +21 -0
- package/README.md +144 -0
- package/bin/fleet.js +1018 -0
- package/commands/fleet.md +78 -0
- package/package.json +40 -0
- package/prompts/fix.md +46 -0
- package/prompts/research.md +38 -0
- package/prompts/review.md +51 -0
- package/review/README.md +60 -0
- package/review/cli.sh +63 -0
- package/review/coverage.sh +90 -0
- package/review/fix.sh +91 -0
- package/review/lib.sh +258 -0
- package/review/merge.sh +374 -0
- package/review/prompts/fix.md +190 -0
- package/review/prompts/review.md +170 -0
- package/review/review.sh +72 -0
- package/review/sync.sh +15 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
You are finishing PR #__PR__ on `__REPO__`.
|
|
2
|
+
|
|
3
|
+
The branch `pr/__PR__` is already checked out locally with the base branch merged in and
|
|
4
|
+
upstream tracking set — skip any fetch / checkout / merge phases.
|
|
5
|
+
|
|
6
|
+
`pushRemote` is already wired to the contributor's fork — `git push` from this branch lands
|
|
7
|
+
directly on the PR's head branch (`__HEAD_REPO__:__HEAD_BRANCH__`), updating the actual PR. Do
|
|
8
|
+
not push to `origin` explicitly; plain `git push` is correct.
|
|
9
|
+
|
|
10
|
+
__CONFLICT_BLOCK__
|
|
11
|
+
|
|
12
|
+
# Your job
|
|
13
|
+
|
|
14
|
+
Two phases, both required:
|
|
15
|
+
|
|
16
|
+
1. **Review and apply fixes**: do a CodeRabbit-style review of the diff, identify real issues
|
|
17
|
+
(blockers, major, suggestions), and apply the fixes directly to the working tree. Also
|
|
18
|
+
address every existing reviewer/bot comment on the PR (CodeRabbit, maintainers, inline
|
|
19
|
+
threads) — apply each actionable item rather than describing it.
|
|
20
|
+
2. **Quality suite, commit, push**: run the repo's formatters / typecheck / lint / tests,
|
|
21
|
+
commit everything in focused commits, and push back to the PR branch.
|
|
22
|
+
|
|
23
|
+
**Your job is to finish the PR, not to report on it.** A response that only lists what *should*
|
|
24
|
+
be done is a failure mode.
|
|
25
|
+
|
|
26
|
+
# Workflow
|
|
27
|
+
|
|
28
|
+
## 0. Sanity check the working state
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
git status --short # should be empty or only your own staged work
|
|
32
|
+
git branch --show-current # should be pr/__PR__
|
|
33
|
+
git rev-parse --abbrev-ref @{u} # upstream must be set
|
|
34
|
+
git log --oneline -5
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
If the working tree is dirty in a way you didn't expect, stop and ask — never stash/discard.
|
|
38
|
+
|
|
39
|
+
## 1. Fetch PR metadata and existing review comments
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
gh pr view __PR__ -R __REPO__ --json number,title,headRefName,headRepositoryOwner,headRepository,baseRefName,isCrossRepository,state,author,url,body,mergeable,statusCheckRollup
|
|
43
|
+
gh pr diff __PR__ -R __REPO__
|
|
44
|
+
gh pr view __PR__ -R __REPO__ --json reviews --jq '.reviews[] | {author: .author.login, state: .state, body: .body, submittedAt: .submittedAt}'
|
|
45
|
+
gh api repos/__REPO__/pulls/__PR__/comments --paginate
|
|
46
|
+
gh api repos/__REPO__/issues/__PR__/comments --paginate
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Confirm the PR is **open**. Abort on closed/merged unless the user says otherwise.
|
|
50
|
+
|
|
51
|
+
For cross-repo forks where local `pr/__PR__` was pushed to your own `origin` (not the
|
|
52
|
+
contributor's fork), pushes update your origin copy — **not the actual PR**. Flag this clearly.
|
|
53
|
+
|
|
54
|
+
## 2. Read every changed file in full
|
|
55
|
+
|
|
56
|
+
Read the **whole file** (not just the hunk). Read siblings for new files; check both paths for
|
|
57
|
+
moves/renames. Skipping this produces shallow fixes.
|
|
58
|
+
|
|
59
|
+
## 3. Analyze + classify each existing comment and your own findings
|
|
60
|
+
|
|
61
|
+
Run a CodeRabbit-style review against these axes:
|
|
62
|
+
|
|
63
|
+
**Correctness** — logic bugs, off-by-one, null/undefined, async/await misuse, race conditions,
|
|
64
|
+
error propagation and handling.
|
|
65
|
+
|
|
66
|
+
**Project standards** — read the repo's own `CLAUDE.md` / `AGENTS.md` / `CONTRIBUTING` and
|
|
67
|
+
linter/formatter config, and hold the change to *those* conventions (module layout, error
|
|
68
|
+
handling, logging style, file-size limits). Don't impose rules the project doesn't follow.
|
|
69
|
+
|
|
70
|
+
**Testing** — new behavior ships with tests using the repo's framework; cover branches and
|
|
71
|
+
error paths.
|
|
72
|
+
|
|
73
|
+
**Security** — credentials, command injection, SQL injection, path traversal, XSS.
|
|
74
|
+
|
|
75
|
+
Classify each existing comment and new finding:
|
|
76
|
+
- `actionable-trivial` — typo, rename, formatting, missing import: fix directly.
|
|
77
|
+
- `actionable-non-trivial` — logic/architecture/test gap: fix if direction is unambiguous;
|
|
78
|
+
otherwise defer.
|
|
79
|
+
- `already-addressed` — current code satisfies it.
|
|
80
|
+
- `stale-outdated` — no longer applies.
|
|
81
|
+
- `disagree` / `defer-human` / `question` — surface in the final report and post back as a PR
|
|
82
|
+
comment via `gh api`; never silently dismiss.
|
|
83
|
+
|
|
84
|
+
## 4. Apply fixes (REQUIRED)
|
|
85
|
+
|
|
86
|
+
Apply every `actionable-trivial` and clearly-directed `actionable-non-trivial` fix. Re-read
|
|
87
|
+
surrounding code before each edit (state may have drifted since the comment was written).
|
|
88
|
+
|
|
89
|
+
One logical concern per commit:
|
|
90
|
+
|
|
91
|
+
```text
|
|
92
|
+
fix(<area>): <what changed> (addresses @<reviewer> on <file>:<line>)
|
|
93
|
+
refactor(<area>): <what changed>
|
|
94
|
+
test(<area>): <what added>
|
|
95
|
+
docs(<area>): <what changed>
|
|
96
|
+
chore(pr-fix): apply formatting
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Skip anything you choose not to apply (capture the reason for the final report). Don't expand
|
|
100
|
+
scope.
|
|
101
|
+
|
|
102
|
+
## 5. Run the quality suite
|
|
103
|
+
|
|
104
|
+
Detect the repo's checks from its manifests (`package.json` / `Cargo.toml` / `Makefile` /
|
|
105
|
+
`pyproject.toml` / etc.) and run them — formatters, typecheck/lint, and tests. Run independent
|
|
106
|
+
suites in parallel; always run the formatter + typecheck when code changed.
|
|
107
|
+
|
|
108
|
+
If a test fails on apparent flake, rerun once. If it still fails, stop and report.
|
|
109
|
+
|
|
110
|
+
## 6. Commit any auto-fixes
|
|
111
|
+
|
|
112
|
+
- Formatter changes → `chore(pr-fix): apply formatting`.
|
|
113
|
+
- Non-trivial lint autofixes → `chore(pr-fix): lint autofix`.
|
|
114
|
+
- `git status --short` must be empty before push.
|
|
115
|
+
- Never `--no-verify` unless a pre-push hook fails on pre-existing breakage unrelated to your
|
|
116
|
+
changes — in that case, push with `--no-verify` and note it in the report.
|
|
117
|
+
- Never amend published commits. Never force-push without explicit user approval.
|
|
118
|
+
|
|
119
|
+
## 7. Push (REQUIRED)
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
git status --short # must be empty
|
|
123
|
+
git push # pushes to the contributor's fork (__HEAD_REPO__:__HEAD_BRANCH__) — updates the PR
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
If rejected (non-fast-forward — the contributor pushed while you worked): `git pull --rebase`
|
|
127
|
+
then push. **Never** force-push without explicit user approval.
|
|
128
|
+
|
|
129
|
+
If the push fails with a permissions error (no write access to the contributor's fork): stop,
|
|
130
|
+
do NOT fall back to `origin`, and report — the user needs access or the contributor must pull
|
|
131
|
+
the changes themselves.
|
|
132
|
+
|
|
133
|
+
## 8. Post deferred / disagree / question items back to the PR
|
|
134
|
+
|
|
135
|
+
For every item classified `disagree`, `defer-human`, or `question`, post it as an inline review
|
|
136
|
+
comment via `gh api` so nothing is lost in chat:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
gh api -X POST repos/__REPO__/pulls/__PR__/comments \
|
|
140
|
+
-f body="<your reply>" \
|
|
141
|
+
-f commit_id="$(gh pr view __PR__ -R __REPO__ --json headRefOid --jq .headRefOid)" \
|
|
142
|
+
-f path="<file path>" \
|
|
143
|
+
-F line=<line number> \
|
|
144
|
+
-f side=RIGHT
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## 9. Final report (to the user)
|
|
148
|
+
|
|
149
|
+
```text
|
|
150
|
+
## PR #__PR__ - <title>
|
|
151
|
+
Branch: pr/__PR__ PR head: <headRefName> Base: <baseRefName> Author: <login>
|
|
152
|
+
|
|
153
|
+
### Preconditions
|
|
154
|
+
- Working tree clean at start: yes/no
|
|
155
|
+
- Branch / upstream verified: yes/no
|
|
156
|
+
- Cross-repo fork: yes/no — push target: <origin/<branch> | contributor-fork>
|
|
157
|
+
|
|
158
|
+
### Review comments processed (<count>)
|
|
159
|
+
- @<reviewer> on <file>:<line> - <one-line> -> fixed / already addressed / deferred / disagree
|
|
160
|
+
|
|
161
|
+
### New findings raised (<count>)
|
|
162
|
+
- <severity> <file>:<line> - <one-line> -> fixed / deferred
|
|
163
|
+
|
|
164
|
+
### Checks
|
|
165
|
+
| Check | Result |
|
|
166
|
+
|---|---|
|
|
167
|
+
| typecheck | pass/fail |
|
|
168
|
+
| lint | pass/fail (N autofixes) |
|
|
169
|
+
| format | pass |
|
|
170
|
+
| tests | <passed>/<total> |
|
|
171
|
+
|
|
172
|
+
### Commits pushed
|
|
173
|
+
- <sha> <subject>
|
|
174
|
+
|
|
175
|
+
### Outstanding human items
|
|
176
|
+
- <list, or none>
|
|
177
|
+
|
|
178
|
+
### PR
|
|
179
|
+
<url>
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
# Guardrails
|
|
183
|
+
|
|
184
|
+
- **Never** push to `main`, force-push, skip hooks (except the documented pre-existing-breakage
|
|
185
|
+
case), amend published commits, or run destructive git commands without explicit user approval.
|
|
186
|
+
- **Never** commit secrets (`.env`, `*.key`, credentials).
|
|
187
|
+
- If the working tree is dirty at start in unexpected ways, **stop** — don't stash.
|
|
188
|
+
- If tests flake, rerun once; if still failing, report rather than loop.
|
|
189
|
+
- Stay on the PR branch; never accidentally commit to the base branch.
|
|
190
|
+
- Keep findings honest. If the PR is clean, say so. Don't pad with invented issues.
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
You are doing a CodeRabbit-style review of PR #__PR__ on `__REPO__`.
|
|
2
|
+
|
|
3
|
+
The branch `pr/__PR__` is already checked out locally with the base branch merged in and
|
|
4
|
+
upstream tracking set — skip any fetch / checkout / merge phases.
|
|
5
|
+
|
|
6
|
+
__CONFLICT_BLOCK__
|
|
7
|
+
|
|
8
|
+
# Your job
|
|
9
|
+
|
|
10
|
+
Produce a thorough CodeRabbit-style review: walkthrough, change summary table, per-file
|
|
11
|
+
analysis, actionable inline comments with concrete code suggestions, and a nitpick section.
|
|
12
|
+
Then **post the review and any inline comments via `gh`**. If the changes look acceptable
|
|
13
|
+
overall, approve with `gh pr review __PR__ -R __REPO__ --approve`. If blocking issues remain,
|
|
14
|
+
request changes instead.
|
|
15
|
+
|
|
16
|
+
Do NOT apply code changes — this is a review-only task.
|
|
17
|
+
|
|
18
|
+
# Workflow
|
|
19
|
+
|
|
20
|
+
## 1. Fetch PR metadata and diff
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
gh pr view __PR__ -R __REPO__ --json number,title,headRefName,baseRefName,isCrossRepository,state,author,url,body,mergeable,additions,deletions,changedFiles
|
|
24
|
+
gh pr diff __PR__ -R __REPO__
|
|
25
|
+
gh pr view __PR__ -R __REPO__ --json files --jq '.files[] | {path, additions, deletions}'
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Abort on closed/merged PRs unless the user insists. Note cross-repo/fork status.
|
|
29
|
+
|
|
30
|
+
## 2. Read every changed file in full
|
|
31
|
+
|
|
32
|
+
For every file in the diff:
|
|
33
|
+
- Read the **whole file**, not just the hunk. Context matters.
|
|
34
|
+
- For new files, read siblings in the same directory to learn local conventions.
|
|
35
|
+
- For moved/renamed files, check both old and new paths.
|
|
36
|
+
|
|
37
|
+
Skipping this produces shallow reviews that miss architectural issues.
|
|
38
|
+
|
|
39
|
+
## 3. Analyze against these axes
|
|
40
|
+
|
|
41
|
+
**Correctness** — logic bugs, off-by-one, null/undefined, async/await misuse, race
|
|
42
|
+
conditions, resource leaks, error propagation and handling.
|
|
43
|
+
|
|
44
|
+
**Project standards** — read the repo's own `CLAUDE.md` / `AGENTS.md` / `CONTRIBUTING` and
|
|
45
|
+
its linter/formatter/editorconfig, and hold the change to *those* conventions (module layout,
|
|
46
|
+
error-handling patterns, logging style, file-size limits, naming). Don't impose rules the
|
|
47
|
+
project doesn't follow.
|
|
48
|
+
|
|
49
|
+
**Testing** — new behavior ships with tests using the repo's framework; cover branches and
|
|
50
|
+
error paths; test behavior over implementation; no real network, no time-based flakes.
|
|
51
|
+
|
|
52
|
+
**Debug logging** — meaningful logs on new flows (entry/exit, branches, retries, state
|
|
53
|
+
transitions) with grep-friendly prefixes; never log secrets or PII.
|
|
54
|
+
|
|
55
|
+
**Security** — credentials, command injection, SQL injection, path traversal, XSS, secret
|
|
56
|
+
files (`.env`, `*.key`), validation at trust boundaries.
|
|
57
|
+
|
|
58
|
+
**Design / code quality** — dead code, commented-out blocks, unexplained TODOs,
|
|
59
|
+
over-abstraction, duplication, backwards-compat cruft, "what" comments instead of "why".
|
|
60
|
+
|
|
61
|
+
**UX / UI** (frontend changes) — accessibility, keyboard nav, loading/error/empty states,
|
|
62
|
+
responsiveness.
|
|
63
|
+
|
|
64
|
+
**Documentation** — comments/API docs match new behavior; architecture/usage docs updated for
|
|
65
|
+
behavior or rule changes.
|
|
66
|
+
|
|
67
|
+
## 4. Classify findings
|
|
68
|
+
|
|
69
|
+
For each finding, tag:
|
|
70
|
+
- **Severity**: `blocker` (must fix before merge), `major` (should fix), `minor` / `nitpick`
|
|
71
|
+
(optional polish), `question` (needs discussion).
|
|
72
|
+
- **Confidence**: `high` / `medium` / `low`.
|
|
73
|
+
|
|
74
|
+
Drop `low`-confidence `minor` items — they're noise. Keep real issues; don't pad the review.
|
|
75
|
+
|
|
76
|
+
## 5. Emit and post the review
|
|
77
|
+
|
|
78
|
+
Format the review using the structure below, then post it as a single review on the PR using
|
|
79
|
+
`gh pr review __PR__ -R __REPO__ --body-file -` (or `--body "..."`). For each per-file
|
|
80
|
+
actionable item, also post an inline review comment via `gh api repos/__REPO__/pulls/__PR__/comments`
|
|
81
|
+
so it lands on the right line in the diff:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
gh api -X POST repos/__REPO__/pulls/__PR__/comments \
|
|
85
|
+
-f body="<comment body>" \
|
|
86
|
+
-f commit_id="$(gh pr view __PR__ -R __REPO__ --json headRefOid --jq .headRefOid)" \
|
|
87
|
+
-f path="<file path>" \
|
|
88
|
+
-F line=<line number> \
|
|
89
|
+
-f side=RIGHT
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Review body structure:
|
|
93
|
+
|
|
94
|
+
````markdown
|
|
95
|
+
# PR #__PR__ — <title>
|
|
96
|
+
|
|
97
|
+
## Walkthrough
|
|
98
|
+
<2–4 sentence prose summary of what the PR does, the approach taken, and overall assessment.>
|
|
99
|
+
|
|
100
|
+
## Changes
|
|
101
|
+
|
|
102
|
+
| File | Summary |
|
|
103
|
+
| --- | --- |
|
|
104
|
+
| `path/to/file1` | <1-line summary> |
|
|
105
|
+
| `path/to/file2` | <…> |
|
|
106
|
+
|
|
107
|
+
## Actionable comments (<count>)
|
|
108
|
+
|
|
109
|
+
### 🛑 Blockers
|
|
110
|
+
|
|
111
|
+
#### 1. `path/to/file:42-56` — <short title>
|
|
112
|
+
<2–5 line explanation of the issue, why it's wrong, and the downstream effect.>
|
|
113
|
+
|
|
114
|
+
**Suggested change:**
|
|
115
|
+
```
|
|
116
|
+
// before
|
|
117
|
+
<snippet>
|
|
118
|
+
|
|
119
|
+
// after
|
|
120
|
+
<snippet>
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### ⚠️ Major
|
|
124
|
+
#### 2. `path/to/other:110-128` — <short title>
|
|
125
|
+
<…same structure…>
|
|
126
|
+
|
|
127
|
+
### 💡 Refactor / suggestion
|
|
128
|
+
#### 3. `path/to/thing:200-240` — <short title>
|
|
129
|
+
<…>
|
|
130
|
+
|
|
131
|
+
## Nitpicks (<count>)
|
|
132
|
+
- `path/to/file:15` — prefer `const` over `let`; not reassigned.
|
|
133
|
+
|
|
134
|
+
## Questions for the author (<count>)
|
|
135
|
+
- `path/to/file:88` — <question>
|
|
136
|
+
|
|
137
|
+
## Verified / looks good
|
|
138
|
+
- <what you checked that's correct>
|
|
139
|
+
````
|
|
140
|
+
|
|
141
|
+
Rules:
|
|
142
|
+
- Use **file:line** or **file:line-range** for every actionable item.
|
|
143
|
+
- Every actionable comment must include a **concrete proposed fix** — a code block where
|
|
144
|
+
plausible. "Consider refactoring" is not a suggestion.
|
|
145
|
+
- Before/after code blocks should be minimal.
|
|
146
|
+
- Do not invent issues. If the PR is clean, say so and keep it short.
|
|
147
|
+
- Do not repeat what the linter/compiler would catch unless CI hasn't caught it.
|
|
148
|
+
|
|
149
|
+
## 6. Approve or request changes
|
|
150
|
+
|
|
151
|
+
After posting the review:
|
|
152
|
+
- No blockers, no major issues: `gh pr review __PR__ -R __REPO__ --approve`.
|
|
153
|
+
- Blockers exist: `gh pr review __PR__ -R __REPO__ --request-changes --body "See review above."`.
|
|
154
|
+
- Otherwise: leave it as a plain `--comment`.
|
|
155
|
+
|
|
156
|
+
## 7. Final report (to the user)
|
|
157
|
+
|
|
158
|
+
```text
|
|
159
|
+
## PR #__PR__ — Review posted
|
|
160
|
+
### Findings raised: <total> (blockers <n>, major <n>, suggestions <n>, nitpicks <n>, questions <n>)
|
|
161
|
+
### Action: posted review <yes/no>, inline comments <n>, final state APPROVED / CHANGES_REQUESTED / COMMENTED
|
|
162
|
+
### PR URL: <url>
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
# Guardrails
|
|
166
|
+
|
|
167
|
+
- This is review-only. Do NOT edit code, commit, or push.
|
|
168
|
+
- Never approve a PR with unresolved blockers.
|
|
169
|
+
- Keep the review honest. If the PR is good, say so.
|
|
170
|
+
- Never log secrets or full PII in comments.
|
package/review/review.sh
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# review.sh <pr-number> [--agent <tool>] [extra-prompt]
|
|
3
|
+
# Sync the PR locally, then hand a fully-inlined CodeRabbit-style review prompt
|
|
4
|
+
# to the chosen agent. The prompt is loaded from scripts/shortcuts/review/prompts/review.md
|
|
5
|
+
# so the workflow is agent-agnostic (no reliance on Claude Code's named
|
|
6
|
+
# subagent registry).
|
|
7
|
+
#
|
|
8
|
+
# --agent picks the CLI that drives the work. Default: claude.
|
|
9
|
+
# A trailing positional <extra-prompt> (any free-form text) is appended to the
|
|
10
|
+
# agent's prompt verbatim.
|
|
11
|
+
|
|
12
|
+
set -euo pipefail
|
|
13
|
+
here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
14
|
+
# shellcheck source=lib.sh
|
|
15
|
+
source "$here/lib.sh"
|
|
16
|
+
|
|
17
|
+
require git gh jq
|
|
18
|
+
require_pr_number "${1:-}"
|
|
19
|
+
|
|
20
|
+
pr="$1"
|
|
21
|
+
agent="claude"
|
|
22
|
+
extra_prompt=""
|
|
23
|
+
shift
|
|
24
|
+
while [ $# -gt 0 ]; do
|
|
25
|
+
case "$1" in
|
|
26
|
+
--agent) agent="${2:?--agent requires a value}"; shift 2 ;;
|
|
27
|
+
--agent=*) agent="${1#*=}"; shift ;;
|
|
28
|
+
*)
|
|
29
|
+
if [ -n "$extra_prompt" ]; then
|
|
30
|
+
echo "[review] unexpected extra arg: $1 (extra-prompt already set)" >&2
|
|
31
|
+
exit 1
|
|
32
|
+
fi
|
|
33
|
+
extra_prompt="$1"; shift
|
|
34
|
+
;;
|
|
35
|
+
esac
|
|
36
|
+
done
|
|
37
|
+
|
|
38
|
+
require "$agent"
|
|
39
|
+
sync_pr "$pr"
|
|
40
|
+
|
|
41
|
+
template="$here/prompts/review.md"
|
|
42
|
+
if [ ! -f "$template" ]; then
|
|
43
|
+
echo "[review] missing prompt template: $template" >&2
|
|
44
|
+
exit 1
|
|
45
|
+
fi
|
|
46
|
+
|
|
47
|
+
if [ "${REVIEW_HAS_CONFLICTS:-0}" = "1" ]; then
|
|
48
|
+
conflict_block="# ⚠️ Merge conflicts detected
|
|
49
|
+
|
|
50
|
+
When the PR branch was merged with current \`main\`, the following files were left with unresolved conflict markers:
|
|
51
|
+
|
|
52
|
+
$(printf '%s\n' "$REVIEW_CONFLICT_FILES" | sed 's/^/- /')
|
|
53
|
+
|
|
54
|
+
Since this is a **review-only** run, do NOT resolve them — but you MUST call them out prominently in the review walkthrough as a blocker (with severity 🛑) and request changes on the PR. Tell the author exactly which files need attention before this PR can merge."
|
|
55
|
+
else
|
|
56
|
+
conflict_block=""
|
|
57
|
+
fi
|
|
58
|
+
|
|
59
|
+
prompt=$(REVIEW_CONFLICT_BLOCK="$conflict_block" \
|
|
60
|
+
awk -v pr="$REVIEW_PR" -v repo="$REVIEW_REPO_RESOLVED" '
|
|
61
|
+
BEGIN { conflict = ENVIRON["REVIEW_CONFLICT_BLOCK"] }
|
|
62
|
+
{ gsub(/__PR__/, pr); gsub(/__REPO__/, repo); gsub(/__CONFLICT_BLOCK__/, conflict); print }
|
|
63
|
+
' "$template")
|
|
64
|
+
|
|
65
|
+
if [ -n "$extra_prompt" ]; then
|
|
66
|
+
prompt="${prompt}
|
|
67
|
+
|
|
68
|
+
# Additional instructions from the user
|
|
69
|
+
${extra_prompt}"
|
|
70
|
+
fi
|
|
71
|
+
|
|
72
|
+
agent_exec "$agent" "$prompt"
|
package/review/sync.sh
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# sync.sh <pr-number>
|
|
3
|
+
# Check out the PR as local branch pr/<num>, merge main in, wire upstream
|
|
4
|
+
# tracking + pushRemote to the contributor's fork. No agent invocation.
|
|
5
|
+
|
|
6
|
+
set -euo pipefail
|
|
7
|
+
here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
8
|
+
# shellcheck source=lib.sh
|
|
9
|
+
source "$here/lib.sh"
|
|
10
|
+
|
|
11
|
+
require git gh jq
|
|
12
|
+
require_pr_number "${1:-}"
|
|
13
|
+
sync_pr "$1"
|
|
14
|
+
|
|
15
|
+
echo "[review] done. current branch: $(git branch --show-current)"
|