You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Automatically generates and maintains GitHub wiki pages from your source code**
6
6
7
-
The [Agentic Wiki Writer workflow](../workflows/agentic-wiki-writer.md?plain=1) keeps your project's GitHub wiki synchronized with the codebase. After each merged pull request (or on demand), it reads a `PAGES.md` template to understand what to document, then writes wiki pages directly from the source code.
7
+
The [Agentic Wiki Writer workflow](../workflows/agentic-wiki-writer.md?plain=1) keeps your project's GitHub wiki synchronized with the codebase. Once a day (if any pull requests were merged to the default branch), it reads a `PAGES.md` template to understand what to document, then writes wiki pages directly from the source code. You can also trigger it manually on demand.
8
+
9
+
> [!WARNING]
10
+
> **The repository wiki must be initialized before running this workflow.** GitHub does not create the wiki git repository until at least one page exists. Go to your repository's **Wiki** tab and create a blank page (e.g. "Home") to initialize it. The workflow will fail with a git clone error if this step is skipped.
8
11
9
12
## Installation
10
13
@@ -22,18 +25,20 @@ This walks you through adding the workflow to your repository.
F --> H[Identify changed files from recent merges]
35
+
H --> I[Read relevant source files]
36
+
I --> J[Write wiki pages]
37
+
J --> K[Push wiki pages]
38
+
K --> L[Create PR if source changes needed]
34
39
```
35
40
36
-
On the first run (or when `regenerate-template` is enabled), the workflow generates a `PAGES.md` template describing the wiki structure it will maintain. On subsequent runs it follows the template — reading only the source files relevant to the merged PR, then writing updated wiki content.
41
+
On the first run (or when `regenerate-template` is enabled), the workflow generates a `PAGES.md` template describing the wiki structure it will maintain. On subsequent runs it follows the template — reading only the source files relevant to the recently merged PRs, then writing updated wiki content.
37
42
38
43
### Key Features
39
44
@@ -49,12 +54,201 @@ Trigger the workflow manually with `regenerate-template: true` to create the ini
49
54
50
55
### Configuration
51
56
52
-
The workflow triggers automatically on every merged PR to the default branch. You can also trigger it manually from the Actions tab:
57
+
The workflow runs once a day (around 4:22am UTC) and checks whether any pull requests were merged to the default branch in the last 24 hours. If no merges happened, it exits early with no work done. You can also trigger it manually from the Actions tab.
53
58
54
-
-**`regenerate-template`** (`boolean`, default `false`) — Set to `true` to rebuild the `PAGES.md` template from scratch.
59
+
You can adjust the cadence or event structure to suit your team's workflow. For example, to run immediately on every merge to the default branch (instead of waiting for the daily schedule), replace the `schedule: daily around 4:22` trigger with a `push` trigger:
60
+
61
+
```yaml
62
+
on:
63
+
push:
64
+
branches: [main]
65
+
workflow_dispatch:
66
+
...
67
+
```
68
+
69
+
When using a `push` trigger, the agent will always run on every merge — there is no need for the "any merges today?" check.
70
+
71
+
Or to run at a different time or cadence, change the schedule. For example, to run at 9am UTC every weekday:
72
+
73
+
```yaml
74
+
on:
75
+
schedule:
76
+
- cron: "0 9 * * 1-5"
77
+
workflow_dispatch:
78
+
...
79
+
```
55
80
56
81
After editing the workflow file, run `gh aw compile` to update the compiled workflow and commit all changes to the default branch.
57
82
83
+
Available inputs for manual dispatch:
84
+
85
+
- **`regenerate-template`** (`boolean`, default `false`) — Set to `true` to rebuild the `PAGES.md` template from scratch.
86
+
87
+
## PAGES.md Format
88
+
89
+
The `PAGES.md` file at `.github/agentic-wiki/PAGES.md` is the single source of truth for your wiki structure. It is generated automatically on the first run and saved as a PR for you to review. After that, you can edit it freely to customize your documentation structure. You can also supply a `PAGES.md` yourself before the first run to pre-define the structure.
Save these diff URLs — you will need them for the PR/issue body in Step 7.
128
+
113
129
### 0b. Check for feedback loops
114
130
115
131
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
132
148
133
149
Do NOT attempt to clone the wiki yourself — `GITHUB_TOKEN` is not available in the sandbox.
134
150
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
136
168
137
169
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).
138
170
139
171
**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.
140
172
141
-
### 1c. Read surrounding pages for context
173
+
### 1d. Read surrounding pages for context
142
174
143
175
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.
144
176
@@ -259,13 +291,24 @@ Keep it under 70 characters. Examples:
259
291
260
292
### PR body
261
293
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.
263
295
264
296
```markdown
265
-
## Wiki Changes
297
+
## Wiki Change
298
+
299
+
**[Page Name](html_url)** — [view diff](diff_url)
266
300
267
-
This PR implements code changes based on edits to the following wiki pages:
<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.>
269
312
270
313
## Implementation Summary
271
314
@@ -286,6 +329,12 @@ This PR implements code changes based on edits to the following wiki pages:
286
329
-[ ]`bunx tsc --noEmit` passes
287
330
```
288
331
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
+
289
338
## Step 8: Update memory
290
339
291
340
After creating the PR (or after deciding on noop), update memory files in MEMORY_DIR.
0 commit comments