Skip to content

Commit 06bf149

Browse files
authored
prompt to show wiki diffs in resulting PRs (#258)
1 parent 3462045 commit 06bf149

1 file changed

Lines changed: 55 additions & 6 deletions

File tree

workflows/agentic-wiki-coder.md

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,22 @@ Parse the `pages` array from the JSON. Each entry contains:
110110

111111
Also extract `sender.login` from the event payload for the feedback loop check in Step 0b.
112112

113+
### 0a-ii. Construct wiki diff URLs
114+
115+
For each page in the event, construct the diff URL using this pattern:
116+
117+
```
118+
{html_url}/_compare/{sha}
119+
```
120+
121+
For example, if `html_url` is `https://github.com/owner/repo/wiki/My-Page` and `sha` is `abc123`, the diff URL is:
122+
123+
```
124+
https://github.com/owner/repo/wiki/My-Page/_compare/abc123
125+
```
126+
127+
Save these diff URLs — you will need them for the PR/issue body in Step 7.
128+
113129
### 0b. Check for feedback loops
114130

115131
Check the `sender.login` field from the event payload (extracted in Step 0a). If the sender login is `github-actions[bot]`, this edit was made by the `agentic-wiki-writer` workflow (which commits as `github-actions[bot]`). Call the `noop` safe-output with "Wiki edit was made by github-actions[bot] — skipping to prevent feedback loop with agentic-wiki-writer" and **stop**.
@@ -132,13 +148,29 @@ If this directory does not exist or is empty, run `echo "FATAL: wiki not pre-clo
132148

133149
Do NOT attempt to clone the wiki yourself — `GITHUB_TOKEN` is not available in the sandbox.
134150

135-
### 1b. Read changed pages
151+
### 1b. Get wiki diffs
152+
153+
For each changed page, get the actual diff content from the wiki clone. Run `git log` and `git diff` in `/tmp/gh-aw/wiki/` to extract what changed:
154+
155+
```bash
156+
cd /tmp/gh-aw/wiki && git show --format="%H %s" --stat {sha}
157+
```
158+
159+
```bash
160+
cd /tmp/gh-aw/wiki && git diff {sha}~1 {sha} -- "*.md"
161+
```
162+
163+
If the page was newly created (`action` is `"created"`), the parent commit may not contain the file, so use `git show {sha} -- {Page-Name}.md` instead.
164+
165+
Save the diff output for each page — you will include it (or a summary of it) in the PR/issue body in Step 7.
166+
167+
### 1c. Read changed pages
136168

137169
Read **each changed wiki page** identified in the event payload (Step 0a) from `/tmp/gh-aw/wiki/`. The files are named `Page-Name.md` (title with spaces replaced by hyphens).
138170

139171
**Focus on the specific pages from the event.** These are the pages that triggered this run. Read each one carefully — these are your primary input.
140172

141-
### 1c. Read surrounding pages for context
173+
### 1d. Read surrounding pages for context
142174

143175
Read other wiki pages that might provide context — especially the Home page and any pages that link to or from the changed pages. This helps you understand the broader documentation context.
144176

@@ -259,13 +291,24 @@ Keep it under 70 characters. Examples:
259291

260292
### PR body
261293

262-
Structure the body as follows:
294+
Structure the body as follows. The wiki change that triggered the work MUST be the most prominent part — a reviewer should immediately see what wiki edit inspired this code change.
263295

264296
```markdown
265-
## Wiki Changes
297+
## Wiki Change
298+
299+
**[Page Name](html_url)**[view diff](diff_url)
266300

267-
This PR implements code changes based on edits to the following wiki pages:
268-
- [Page Name](html_url) — <brief description of what changed>
301+
<Include the wiki diff here. If the diff is small (under ~40 lines), show it in full inside a diff code block. If it is large, write a concise summary of the key changes (what was added, removed, or modified) and link to the full diff.>
302+
303+
<details><summary>Wiki diff</summary>
304+
305+
```diff
306+
<the actual diff output from git diff>
307+
```
308+
309+
</details>
310+
311+
<For multiple pages, repeat the above block for each page.>
269312

270313
## Implementation Summary
271314

@@ -286,6 +329,12 @@ This PR implements code changes based on edits to the following wiki pages:
286329
- [ ] `bunx tsc --noEmit` passes
287330
```
288331

332+
**Small vs large diffs:**
333+
- **Small diffs (under ~40 lines):** Show the full diff directly in the body (not inside a `<details>` block) so reviewers see it immediately.
334+
- **Large diffs (40+ lines):** Write a 2-4 sentence summary of the functional changes above the fold, then put the full diff inside a `<details>` block.
335+
336+
This same structure applies if the safe-output falls back to creating an issue instead of a PR (e.g., due to protected files). The issue body should use the identical format so the wiki diff is always front and center.
337+
289338
## Step 8: Update memory
290339

291340
After creating the PR (or after deciding on noop), update memory files in MEMORY_DIR.

0 commit comments

Comments
 (0)