ggen 1.2.0

ggen is a deterministic, language-agnostic code generation framework that treats software artifacts as projections of knowledge graphs.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of Contents**

- [GitHub Pages API Scripts Reference]#github-pages-api-scripts-reference
  - [Quick Start]#quick-start
  - [Available Scripts]#available-scripts
    - [1. `gh-pages-setup-check` - Comprehensive Validation]#1-gh-pages-setup-check---comprehensive-validation
    - [2. `gh-pages-status` - API Status Check]#2-gh-pages-status---api-status-check
    - [3. `gh-workflow-status` - Workflow Run History]#3-gh-workflow-status---workflow-run-history
    - [4. `gh-pages-trigger` - Manual Workflow Trigger]#4-gh-pages-trigger---manual-workflow-trigger
    - [5. `gh-pages-logs` - View Deployment Logs]#5-gh-pages-logs---view-deployment-logs
    - [6. `gh-pages-compare` - Local vs Remote Comparison]#6-gh-pages-compare---local-vs-remote-comparison
  - [Common Workflows]#common-workflows
    - [Initial Setup and Deployment]#initial-setup-and-deployment
    - [Debugging Failed Deployment]#debugging-failed-deployment
    - [Verifying Deployment Matches Local Build]#verifying-deployment-matches-local-build
  - [GitHub API Endpoints Used]#github-api-endpoints-used
  - [Authentication]#authentication
  - [Environment Variables]#environment-variables
  - [Troubleshooting]#troubleshooting
    - ["GitHub Pages not configured or not accessible"]#github-pages-not-configured-or-not-accessible
    - ["No workflow runs found"]#no-workflow-runs-found
    - ["gh CLI not available"]#gh-cli-not-available
    - ["Site returns 404"]#site-returns-404
  - [See Also]#see-also

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

# GitHub Pages API Scripts Reference

This document describes the cargo-make scripts for diagnosing and managing GitHub Pages deployment via GitHub's API.

## Quick Start

**Check everything at once:**
```bash
cargo make gh-pages-setup-check
```

This validates:
- ✅ Local documentation build
- ✅ Workflow file configuration
- ✅ mdbook installation
- ✅ GitHub CLI authentication
- ✅ Remote site accessibility

## Available Scripts

### 1. `gh-pages-setup-check` - Comprehensive Validation

**Purpose:** Validates the entire GitHub Pages setup from local build to remote deployment.

```bash
cargo make gh-pages-setup-check
```

**Checks:**
- Local docs build exists (`docs/book/index.html`)
- Workflow configured for correct branch (master)
- mdbook installed locally
- GitHub CLI installed and authenticated
- Remote site returns 200 (not 404)

**Output Example:**
```
🔍 GitHub Pages Setup Validation
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

1️⃣  Checking local build...
   ✅ Local docs built successfully
2️⃣  Checking workflow file...
   ✅ Workflow configured for master branch
3️⃣  Checking mdbook installation...
   ✅ mdbook v0.4.52
4️⃣  Checking GitHub CLI...
   ✅ GitHub CLI authenticated
5️⃣  Checking remote site...
   ❌ Site returns 404 - GitHub Pages may not be configured
      Visit: https://github.com/seanchatmangpt/ggen/settings/pages

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📊 Summary:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Errors:   1
Warnings: 0
```

**Exit Codes:**
- `0` - All checks passed
- `1` - Errors found (see output for details)

---

### 2. `gh-pages-status` - API Status Check

**Purpose:** Query GitHub's API for Pages configuration and deployment status.

```bash
cargo make gh-pages-status
```

**Features:**
- Works with or without GitHub CLI (limited info without)
- Shows Pages configuration (build source, custom domain, etc.)
- Lists recent deployments
- Shows workflow run history
- Tests site accessibility with HTTP request

**Output Sections:**
1. 📄 GitHub Pages Configuration (via API)
2. 🚀 Latest Pages Deployment
3. ⚙️ Recent Workflow Runs
4. 🌐 Site Accessibility Test
5. 📋 Quick Setup Checklist

**Example Output:**
```
🔍 Checking GitHub Pages status for seanchatmangpt/ggen...

📊 Using GitHub CLI for authenticated requests
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📄 GitHub Pages Configuration:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
{
  "url": "https://seanchatmangpt.github.io/ggen/",
  "status": "built",
  "source": {
    "branch": "gh-pages",
    "path": "/"
  }
}

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🌐 Testing Site Accessibility:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
❌ Site returns 404: https://seanchatmangpt.github.io/ggen/
   HTTP Status: 404

💡 Possible issues:
   1. GitHub Pages not enabled in repository settings
   2. No successful deployment yet
   3. Source not set to 'GitHub Actions'
```

---

### 3. `gh-workflow-status` - Workflow Run History

**Purpose:** View GitHub Actions workflow runs for Pages deployment.

**Requirements:** GitHub CLI (`gh`) must be installed and authenticated.

```bash
cargo make gh-workflow-status
```

**Shows:**
- Recent workflow runs (last 10)
- Latest run details (status, timing, conclusion)
- Helpful commands for viewing logs and rerunning

**Example Output:**
```
⚙️  Checking workflow status for seanchatmangpt/ggen...

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📊 Recent Workflow Runs:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
STATUS      TITLE                              BRANCH  EVENT  ID
✓ completed Deploy Documentation to GitHub P... master  push   12345678
✗ failed    Deploy Documentation to GitHub P... master  push   12345677

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔍 Latest Run Details:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✓ master Deploy Documentation to GitHub Pages · 12345678
Triggered via push about 1 hour ago

💡 To view logs: gh run view 12345678 --log
💡 To rerun: gh run rerun 12345678
```

---

### 4. `gh-pages-trigger` - Manual Workflow Trigger

**Purpose:** Manually trigger the Pages deployment workflow.

**Requirements:** GitHub CLI (`gh`) must be installed and authenticated.

```bash
cargo make gh-pages-trigger
```

**Use Cases:**
- Retry failed deployment
- Deploy without pushing commits
- Test workflow after configuration changes

**Example Output:**
```
🚀 Triggering GitHub Pages deployment workflow...

✅ Workflow triggered successfully

💡 Check status with: cargo make gh-workflow-status
💡 Or visit: https://github.com/seanchatmangpt/ggen/actions
```

---

### 5. `gh-pages-logs` - View Deployment Logs

**Purpose:** View detailed logs from the latest deployment workflow run.

**Requirements:** GitHub CLI (`gh`) must be installed and authenticated.

```bash
cargo make gh-pages-logs
```

**Shows:**
- Full logs from all workflow steps
- Build output from mdbook
- Deployment status
- Error messages (if any)

---

### 6. `gh-pages-compare` - Local vs Remote Comparison

**Purpose:** Compare local documentation build with deployed version.

**Requirements:**
- `wget` installed
- Remote site must be accessible (200 status)
- Local build must exist

```bash
cargo make gh-pages-compare
```

**Features:**
- Downloads deployed version
- Compares file counts
- Checks key files (index.html, marketplace.html, searchindex.js)
- Reports size differences

**Example Output:**
```
🔄 Comparing local build with deployed version...

📥 Downloading deployed version...

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📊 File Comparison:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Local files:  156
Remote files: 156

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔍 Key File Comparison:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✅ index.html: Same size (16400 bytes)
⚠️  marketplace.html: Different sizes (Local: 14800, Remote: 14614)
✅ searchindex.js: Same size (646228 bytes)

💡 To see detailed diff, check: /var/folders/.../tmp.ABC123
```

---

## Common Workflows

### Initial Setup and Deployment

```bash
# 1. Validate everything is configured correctly
cargo make gh-pages-setup-check

# 2. Fix any errors shown, then build locally
cargo make docs-deploy

# 3. Push changes to trigger deployment
git add .github/workflows/publish-registry.yml Makefile.toml
git commit -m "fix(docs): configure GitHub Pages deployment"
git push origin master

# 4. Check deployment status
cargo make gh-pages-status

# 5. Wait for workflow to complete
cargo make gh-workflow-status

# 6. Verify site is live
curl -I https://seanchatmangpt.github.io/ggen/
```

### Debugging Failed Deployment

```bash
# 1. Check what failed
cargo make gh-workflow-status

# 2. View detailed logs
cargo make gh-pages-logs

# 3. Fix issues locally and test
cargo make docs-deploy

# 4. Retry deployment
git commit --amend --no-edit
git push --force-with-lease origin master

# Or trigger manually without new commit:
cargo make gh-pages-trigger
```

### Verifying Deployment Matches Local Build

```bash
# 1. Build locally
cargo make docs-build

# 2. Compare with deployed version
cargo make gh-pages-compare

# 3. If different, check what changed
cargo make gh-workflow-status
cargo make gh-pages-logs
```

---

## GitHub API Endpoints Used

These scripts query the following GitHub API endpoints:

1. **Pages Configuration:**
   ```
   GET /repos/{owner}/{repo}/pages
   ```
   Returns: build source, custom domain, HTTPS enforcement, etc.

2. **Pages Deployments:**
   ```
   GET /repos/{owner}/{repo}/pages/deployments
   ```
   Returns: deployment history, status URLs, timestamps

3. **Workflow Runs:**
   ```
   GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}/runs
   ```
   Returns: run status, conclusions, timing, artifacts

## Authentication

**Without GitHub CLI:**
- `gh-pages-status` works with public API (limited info)
- Other scripts will fail or show errors

**With GitHub CLI:**
- All scripts work fully
- Authenticated requests have higher rate limits
- Can trigger workflows and view private data

**Setup GitHub CLI:**
```bash
# Install
brew install gh

# Authenticate
gh auth login

# Verify
gh auth status
```

## Environment Variables

The scripts use these environment variables (set in Makefile.toml):

```toml
[env]
GITHUB_REPO = "seanchatmangpt/ggen"
GITHUB_API = "https://api.github.com"
GITHUB_PAGES_URL = "https://seanchatmangpt.github.io/ggen"
```

To override for a different repository:
```bash
GITHUB_REPO=myuser/myrepo cargo make gh-pages-status
```

## Troubleshooting

### "GitHub Pages not configured or not accessible"

**Solution:**
1. Go to https://github.com/seanchatmangpt/ggen/settings/pages
2. Under "Build and deployment", set Source to "GitHub Actions"
3. Save settings
4. Push a commit to trigger deployment

### "No workflow runs found"

**Possible causes:**
- Workflow never ran (push to wrong branch)
- Workflow file has syntax errors
- Workflow name doesn't match

**Solution:**
```bash
# Check workflow file
cat .github/workflows/publish-registry.yml

# Manually trigger
cargo make gh-pages-trigger
```

### "gh CLI not available"

**Solution:**
```bash
brew install gh
gh auth login
```

### "Site returns 404"

**Possible causes:**
1. GitHub Pages not enabled
2. Workflow failed
3. Wrong source configured
4. DNS not propagated yet

**Solution:**
```bash
# Check all possible issues
cargo make gh-pages-setup-check

# View workflow logs
cargo make gh-pages-logs
```

## See Also

- [DEPLOYMENT.md]./DEPLOYMENT.md - Complete deployment guide
- [MAKEFILE.md]../MAKEFILE.md - All cargo-make tasks
- [GitHub Pages Documentation]https://docs.github.com/en/pages
- [GitHub Actions Documentation]https://docs.github.com/en/actions