Skip to content

Commit 5c285d1

Browse files
authored
Merge branch 'main' into autoloop-workflow
2 parents 984d818 + cbb46ab commit 5c285d1

5 files changed

Lines changed: 298 additions & 37 deletions

File tree

.github/aw/actions-lock.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@
4545
"version": "v0.56.2",
4646
"sha": "f1073c5498ee46fec1530555a7c953445417c69b"
4747
},
48+
"github/gh-aw/actions/setup@v0.58.3": {
49+
"repo": "github/gh-aw/actions/setup",
50+
"version": "v0.58.3",
51+
"sha": "08a903b1fb2e493a84a57577778fe5dd711f9468"
52+
},
4853
"super-linter/super-linter@v8.5.0": {
4954
"repo": "super-linter/super-linter",
5055
"version": "v8.5.0",

docs/agentic-wiki-writer.md

Lines changed: 207 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
55
**Automatically generates and maintains GitHub wiki pages from your source code**
66

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.
811
912
## Installation
1013

@@ -22,18 +25,20 @@ This walks you through adding the workflow to your repository.
2225

2326
```mermaid
2427
graph LR
25-
A[PR merged / manual trigger] --> B{PAGES.md exists?}
26-
B -->|No| C[Generate PAGES.md template]
27-
B -->|Yes| D[Read PAGES.md template]
28-
C --> E[Save template to .github/agentic-wiki/]
29-
D --> F[Identify changed files from PR]
30-
F --> G[Read relevant source files]
31-
G --> H[Write wiki pages]
32-
H --> I[Push wiki pages]
33-
I --> J[Create PR if source changes needed]
28+
A[Daily schedule / manual trigger] --> B{Any merges today?}
29+
B -->|No| C[Skip - no wiki update needed]
30+
B -->|Yes| D{PAGES.md exists?}
31+
D -->|No| E[Generate PAGES.md template]
32+
D -->|Yes| F[Read PAGES.md template]
33+
E --> G[Save template to .github/agentic-wiki/]
34+
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]
3439
```
3540

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.
3742

3843
### Key Features
3944

@@ -49,12 +54,201 @@ Trigger the workflow manually with `regenerate-template: true` to create the ini
4954

5055
### Configuration
5156

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.
5358

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+
```
5580

5681
After editing the workflow file, run `gh aw compile` to update the compiled workflow and commit all changes to the default branch.
5782

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.
90+
91+
### Header Hierarchy
92+
93+
| Level | Purpose | Output |
94+
|-------|---------|--------|
95+
| H1 (`#`) | Top-level page | Separate `.md` file, top-level sidebar entry |
96+
| H2 (`##`) | Nested page | Separate `.md` file, indented under parent in sidebar |
97+
| H3 (`###`) | Deeply nested page | Separate `.md` file, further indented in sidebar |
98+
| H4+ (`####`) | Section within page | H2+ header in rendered page, not in sidebar nav |
99+
| H4+ with `+` (`####+`) | Sidebar section | H2+ header in page, included in sidebar nav |
100+
101+
### Query Templates
102+
103+
Use `*{ query }*` syntax to mark content that should be AI-generated:
104+
105+
```markdown
106+
# Home
107+
108+
*{ Provide an overview of this project }*
109+
110+
## Architecture
111+
112+
*{ Describe the system architecture and key design decisions }*
113+
```
114+
115+
Static text is preserved as-is:
116+
117+
```markdown
118+
# Getting Started
119+
120+
This guide will help you set up the project.
121+
122+
*{ List the installation steps }*
123+
124+
For more help, see the troubleshooting section.
125+
```
126+
127+
### Sidebar Sections
128+
129+
By default, H4+ headers become sections within a page but don't appear in the sidebar. Add `+` after the hashes to include them in sidebar navigation:
130+
131+
```markdown
132+
# API Reference
133+
134+
*{ Overview of the API }*
135+
136+
####+ Authentication
137+
*{ Describe auth flow }*
138+
139+
####+ Rate Limits
140+
*{ Describe rate limiting }*
141+
142+
#### Internal Details
143+
*{ Implementation details - not shown in sidebar }*
144+
```
145+
146+
This generates:
147+
- Sidebar: `API Reference` with nested links to `#Authentication` and `#Rate Limits`
148+
- Page: All three sections rendered as H2 headers
149+
150+
### Header Normalization
151+
152+
Sections (H4–H6) are normalized when rendered to individual pages:
153+
154+
| In PAGES.md | In rendered page |
155+
|-------------|-----------------|
156+
| `####` / `####+` | `##` |
157+
| `#####` | `###` |
158+
| `######` | `####` |
159+
160+
Every page starts with an implicit H1 (the page title, rendered by GitHub from the filename). Sections start at H2.
161+
162+
### Slug Generation
163+
164+
Page and section slugs are generated from titles:
165+
- Spaces → hyphens
166+
- Special characters removed (apostrophes, parentheses, question marks, etc.)
167+
- Multiple hyphens collapsed
168+
169+
| Title | Slug |
170+
|-------|------|
171+
| `Getting Started` | `Getting-Started` |
172+
| `What's New?` | `Whats-New` |
173+
| `API Reference (v2)` | `API-Reference-v2` |
174+
175+
### Complete Example
176+
177+
```markdown
178+
# Home
179+
180+
Welcome to the project documentation.
181+
182+
*{ Provide a brief overview of the project }*
183+
184+
# Architecture
185+
186+
*{ Describe the high-level architecture }*
187+
188+
## Frontend
189+
190+
*{ Describe the frontend stack }*
191+
192+
### Components
193+
194+
*{ List major React components }*
195+
196+
####+ State Management
197+
*{ Explain how state is managed }*
198+
199+
####+ Routing
200+
*{ Describe the routing setup }*
201+
202+
## Backend
203+
204+
*{ Describe the backend architecture }*
205+
206+
### API
207+
208+
*{ Document the REST API }*
209+
210+
####+ Endpoints
211+
*{ List all endpoints }*
212+
213+
# Getting Started
214+
215+
*{ Write a getting started guide }*
216+
217+
#### Prerequisites
218+
*{ List prerequisites }*
219+
220+
#### Installation
221+
*{ Installation steps }*
222+
```
223+
224+
**Output files:**
225+
226+
| File | Content |
227+
|------|---------|
228+
| `Home.md` | H1 title + overview content |
229+
| `Architecture.md` | H1 title + architecture content |
230+
| `Frontend.md` | H1 title + frontend content + State Management (H2) + Routing (H2) sections |
231+
| `Components.md` | H1 title + components content |
232+
| `Backend.md` | H1 title + backend content |
233+
| `API.md` | H1 title + API content + Endpoints (H2) section |
234+
| `Getting-Started.md` | H1 title + guide content + Prerequisites (H2) + Installation (H2) sections |
235+
| `_Sidebar.md` | Auto-generated navigation |
236+
237+
**Generated sidebar:**
238+
239+
```markdown
240+
- [[Home|Home]]
241+
- [[Architecture|Architecture]]
242+
- [[Frontend|Frontend]]
243+
- [[State Management|Frontend#State-Management]]
244+
- [[Routing|Frontend#Routing]]
245+
- [[Components|Components]]
246+
- [[Backend|Backend]]
247+
- [[API|API]]
248+
- [[Endpoints|API#Endpoints]]
249+
- [[Getting Started|Getting-Started]]
250+
```
251+
58252
## Learn More
59253

60254
- [Agentic Wiki Writer source workflow](https://github.com/githubnext/agentics/blob/main/workflows/agentic-wiki-writer.md)

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)