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
38 changes: 30 additions & 8 deletions .fullsend/custom/agents/grillme.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,31 @@ files. A deterministic post-script posts your output as a PR review.

| Source | How to read it |
|--------|----------------|
| PR / issue number | `PR_NUMBER` or `ISSUE_NUMBER` |
| Triggering PR | `GITHUB_ISSUE_URL` (always set). Number is the last path segment. |
| PR / issue number | `PR_NUMBER` or `ISSUE_NUMBER` if set; otherwise parse `GITHUB_ISSUE_URL` |
| Repo | `REPO_FULL_NAME` |
| Answer text after `/fs-grillme` | `HUMAN_INSTRUCTION` (may be empty on the first turn) |
| Prior grill turns | Review threads whose first comment contains `<!-- grillme -->` |
| Change under review | PR diff, title/body, and relevant files in the workspace |
| Prior grill turns | Review threads on **that same PR** whose first comment contains `<!-- grillme -->` |
| Change under review | `gh pr diff <number>` / `gh pr view <number>` of **that PR**, plus files in the workspace |
| Run URL | `RUN_URL` (include in footer context only if useful) |

**Resolve the target PR first, before any other `gh` call:**

```bash
# .env.d may not be sourced into Bash tool shells — derive every time.
PR="${PR_NUMBER:-${ISSUE_NUMBER:-}}"
if [[ ! "${PR}" =~ ^[0-9]+$ ]]; then
PR="$(basename "${GITHUB_ISSUE_URL:-}")"
fi
echo "Grilling PR ${PR} (${GITHUB_ISSUE_URL:-unset})"
```

That number is the PR that triggered this run. **Do not** `gh pr list` to pick a target. **Do not** grill a different open PR, even if it looks more recently updated.

If `HUMAN_INSTRUCTION` is `none`, empty, or unset, treat this as a **new or
continuing turn without a new answer** — usually the opening questions, or the
next turn after reviewing replies on existing threads.
next turn after reviewing replies on existing threads. An empty instruction is
**not** a reason to switch PRs.

## Session lifecycle

Expand All @@ -58,10 +73,11 @@ diff lines. Engineers reply directly to each inline comment, then trigger

## Procedure

1. **Orient.** Identify the PR, read its title/body, and understand what
changed (`gh pr diff`, `gh pr view`, key files in the workspace). If
`openspec/` is in the diff, treat those artifacts as first-class decision
surfaces alongside the code.
1. **Orient.** Resolve the triggering PR number as above. Then
`gh pr diff "$PR"` / `gh pr view "$PR"` and read the relevant files.
If `openspec/` is in **this** PR's diff, treat those artifacts as
first-class decision surfaces. Count existing grillme threads on this
PR: if any exist, this is **not** turn 1.

2. **Load review threads.** Query the PR's review threads to find your prior
grillme comments. Split `REPO_FULL_NAME` into owner/repo, then run:
Expand Down Expand Up @@ -123,6 +139,10 @@ Your final assistant message has two parts:
The text before the JSON block becomes the PR review body. The post-script
adds the `<!-- fullsend:grillme -->` marker and footer.

**Your final message must start with the heading below.** Do not include
chain-of-thought, tool narration, or "let me analyze" preamble. The
post-script posts this text; anything before the heading is dropped.

**First turn:**

```markdown
Expand Down Expand Up @@ -235,6 +255,8 @@ All three fields are optional. Omit any that have no entries.
findings. Stay on decisions, intent, and architectural alignment.
- Do not call `gh pr review`, `gh pr comment`, or `gh issue comment` — the
post-script owns GitHub writes.
- **Do not grill a different PR** than the one in `GITHUB_ISSUE_URL`.
`gh pr list` is not how you choose a target.
- Do not ask about facts you can verify from the PR or filesystem.
- If the PR is empty or the change is unclear, ask one clarifying question about
intent/scope.
14 changes: 13 additions & 1 deletion .fullsend/custom/scripts/post-grillme.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ if [[ -z "${_TOKEN}" ]]; then
fi
echo "::add-mask::${_TOKEN}"
export GH_TOKEN="${_TOKEN}"
RUN_URL="${RUN_URL:-${STATUS_RUN_URL:-}}"

# ---------- Derive ISSUE_NUMBER ----------
# The pre-script writes to GITHUB_ENV, but the harness runner executes
Expand Down Expand Up @@ -115,6 +116,14 @@ if printf '%s' "${SUMMARY}" | grep -qE '```json:grillme'; then
MARKDOWN_BODY=$(printf '%s' "${MARKDOWN_BODY}" | sed -e 's/[[:space:]]*$//')
fi

# Drop chain-of-thought preamble. The review body starts at the Grillme heading.
if printf '%s' "${MARKDOWN_BODY}" | grep -qE '^#{1,3}[[:space:]]+.*Grillme'; then
MARKDOWN_BODY=$(printf '%s' "${MARKDOWN_BODY}" | awk '
/^#{1,3}[[:space:]]+.*Grillme/ { keep=1 }
keep { print }
')
fi

# ---------- Determine footer ----------

is_session_complete=false
Expand Down Expand Up @@ -161,7 +170,10 @@ if [[ "${has_new_comments}" == "true" ]]; then
echo "PR review posted with ${comment_count} inline comment(s)"
else
echo "WARNING: Failed to post PR review with inline comments — falling back to issue comment"
printf '%s' "${REVIEW_BODY}" | gh issue comment "${ISSUE_NUMBER}" --repo "${REPO_FULL_NAME}" --body-file -
FALLBACK="${REVIEW_BODY}

⚠️ Inline comments were not pinned — GitHub rejected the paths/lines (they may not be in this PR's diff)."
printf '%s' "${FALLBACK}" | gh issue comment "${ISSUE_NUMBER}" --repo "${REPO_FULL_NAME}" --body-file -
fi
else
printf '%s' "${REVIEW_BODY}" | gh issue comment "${ISSUE_NUMBER}" --repo "${REPO_FULL_NAME}" --body-file -
Expand Down
Loading