|
| 1 | +--- |
| 2 | +name: hugo-chores |
| 3 | +description: "Maintenance tasks for the memmachine.github.io Hugo site: upgrade Hugo version in CI/CD, verify the build, update npm dependencies. Use when the user wants to perform site maintenance." |
| 4 | +trigger: /hugo-chores |
| 5 | +--- |
| 6 | + |
| 7 | +# /hugo-chores |
| 8 | + |
| 9 | +Perform maintenance tasks on the MemMachine website repository. Subcommands handle Hugo version upgrades, build verification, and npm dependency updates. |
| 10 | + |
| 11 | +## Usage |
| 12 | + |
| 13 | +``` |
| 14 | +/hugo-chores # show available subcommands |
| 15 | +/hugo-chores upgrade-hugo # update Hugo version in CI/CD and docs |
| 16 | +/hugo-chores verify-build # run a production build and report results |
| 17 | +/hugo-chores update-npm # audit and update npm dependencies |
| 18 | +``` |
| 19 | + |
| 20 | +## What You Must Do When Invoked |
| 21 | + |
| 22 | +If no subcommand is given, print the usage above and list the available subcommands with one-line descriptions. Do not run any commands. |
| 23 | + |
| 24 | +If a subcommand is given, follow the steps for that subcommand below. |
| 25 | + |
| 26 | +--- |
| 27 | + |
| 28 | +## Subcommand: upgrade-hugo |
| 29 | + |
| 30 | +Upgrades the Hugo version used in CI/CD and updates all version references in documentation. |
| 31 | + |
| 32 | +### Step 1 — Find the current version |
| 33 | + |
| 34 | +```bash |
| 35 | +grep -n "HUGO_VERSION\|hugo-version\|hugo Extended" .github/workflows/hugo.yaml | head -10 |
| 36 | +``` |
| 37 | + |
| 38 | +Parse the current version from the workflow file (look for the version string in the Hugo setup step, typically `extended_0.149.0` or similar format). |
| 39 | + |
| 40 | +### Step 2 — Find the latest Hugo release |
| 41 | + |
| 42 | +```bash |
| 43 | +# Check the latest release tag from the Hugo GitHub releases page |
| 44 | +curl -s https://api.github.com/repos/gohugoio/hugo/releases/latest | grep '"tag_name"' |
| 45 | +``` |
| 46 | + |
| 47 | +If network access is unavailable, ask the user to provide the latest version number. |
| 48 | + |
| 49 | +### Step 3 — Compare versions |
| 50 | + |
| 51 | +If the current version equals the latest, tell the user: "Hugo is already at the latest version (vX.X.X). No update needed." and stop. |
| 52 | + |
| 53 | +If the latest is newer, proceed. |
| 54 | + |
| 55 | +### Step 4 — Update the workflow file |
| 56 | + |
| 57 | +In `.github/workflows/hugo.yaml`, find the Hugo installation step. Update the version string from the old version to the new version. Use the Edit tool for a targeted replacement. |
| 58 | + |
| 59 | +Common patterns to update: |
| 60 | +- `extended_0.149.0` → `extended_{new_version}` (without the leading `v`) |
| 61 | +- `HUGO_VERSION: '0.149.0'` → `HUGO_VERSION: '{new_version}'` |
| 62 | + |
| 63 | +### Step 5 — Update documentation |
| 64 | + |
| 65 | +Update version references in these files (use grep first to find exact strings): |
| 66 | + |
| 67 | +```bash |
| 68 | +grep -n "0\.14[0-9]\|hugo.*version\|Hugo.*version" README.md AGENTS.md 2>/dev/null |
| 69 | +``` |
| 70 | + |
| 71 | +Use the Edit tool to update each occurrence found. |
| 72 | + |
| 73 | +### Step 6 — Verify |
| 74 | + |
| 75 | +```bash |
| 76 | +hugo version |
| 77 | +``` |
| 78 | + |
| 79 | +Report the installed Hugo version. Note if it differs from the new CI version (that's expected if the user hasn't installed the new version locally yet). |
| 80 | + |
| 81 | +### Step 7 — Report |
| 82 | + |
| 83 | +Tell the user: |
| 84 | +- What was updated (workflow file + which docs) |
| 85 | +- Old version → new version |
| 86 | +- Reminder to commit the changes: `git commit -sS -m "chore: upgrade Hugo to v{new_version}"` |
| 87 | +- Note that CI will use the new version on next push to main |
| 88 | + |
| 89 | +--- |
| 90 | + |
| 91 | +## Subcommand: verify-build |
| 92 | + |
| 93 | +Runs a full production build and reports success or failure with useful diagnostics. |
| 94 | + |
| 95 | +### Step 1 — Run the build |
| 96 | + |
| 97 | +```bash |
| 98 | +hugo --gc --minify 2>&1 |
| 99 | +``` |
| 100 | + |
| 101 | +### Step 2 — Report results |
| 102 | + |
| 103 | +**On success:** Report: |
| 104 | +- "Build successful" |
| 105 | +- Total pages built (look for "pages" in hugo output) |
| 106 | +- Build time |
| 107 | +- Output directory: `public/` |
| 108 | + |
| 109 | +**On failure:** Report: |
| 110 | +- The full error message from Hugo |
| 111 | +- Which file caused the error (if identifiable from the output) |
| 112 | +- Suggested fix based on the error type |
| 113 | + |
| 114 | +Common error types and fixes: |
| 115 | +- `template: ... execute of template failed` — template syntax error in `themes/memmachine/layouts/` |
| 116 | +- `YAML parse error` — malformed frontmatter in a content file or data file |
| 117 | +- `Error: module ... not found` — run `hugo mod tidy` or check `hugo.toml` |
| 118 | +- `Sass compilation error` — CSS syntax error in `themes/memmachine/assets/css/` |
| 119 | + |
| 120 | +### Step 3 — Clean up |
| 121 | + |
| 122 | +If build succeeded, the `public/` directory now contains the built site. Remind the user that `public/` is gitignored and should not be committed. |
| 123 | + |
| 124 | +--- |
| 125 | + |
| 126 | +## Subcommand: update-npm |
| 127 | + |
| 128 | +Audits and updates Node.js dependencies (PostCSS, Autoprefixer). |
| 129 | + |
| 130 | +### Step 1 — Check for vulnerabilities |
| 131 | + |
| 132 | +```bash |
| 133 | +npm audit |
| 134 | +``` |
| 135 | + |
| 136 | +Report the number of vulnerabilities found by severity. If none, say so. |
| 137 | + |
| 138 | +### Step 2 — Update dependencies |
| 139 | + |
| 140 | +```bash |
| 141 | +npm update |
| 142 | +``` |
| 143 | + |
| 144 | +### Step 3 — Verify the build still passes |
| 145 | + |
| 146 | +```bash |
| 147 | +hugo --gc --minify 2>&1 |
| 148 | +``` |
| 149 | + |
| 150 | +If the build fails after the npm update, report the error. The user may need to investigate the breaking change in the updated package. |
| 151 | + |
| 152 | +### Step 4 — Report |
| 153 | + |
| 154 | +Tell the user: |
| 155 | +- Which packages were updated and to what versions (compare `package.json` before and after) |
| 156 | +- Whether the build passed |
| 157 | +- Reminder to commit: `git commit -sS -m "chore: update npm dependencies"` |
| 158 | + |
| 159 | +--- |
| 160 | + |
| 161 | +## Evaluations |
| 162 | + |
| 163 | +### Evaluation 1: upgrade-hugo with newer version available |
| 164 | + |
| 165 | +**Setup:** Current workflow has `extended_0.149.0`. Latest GitHub release is `v0.151.0`. |
| 166 | + |
| 167 | +**Expected behavior:** |
| 168 | +- Detects current version as `0.149.0` |
| 169 | +- Detects latest as `0.151.0` |
| 170 | +- Updates `.github/workflows/hugo.yaml` to `extended_0.151.0` |
| 171 | +- Updates version references in `README.md` and `AGENTS.md` |
| 172 | +- Reports: "Updated Hugo from 0.149.0 to 0.151.0 in 3 files" |
| 173 | + |
| 174 | +**Pass criteria:** All files updated with correct version string; no other files modified. |
| 175 | + |
| 176 | +--- |
| 177 | + |
| 178 | +### Evaluation 2: verify-build on clean repository |
| 179 | + |
| 180 | +**Setup:** Repository has no uncommitted changes; all content and templates are valid. |
| 181 | + |
| 182 | +**Expected behavior:** |
| 183 | +- Runs `hugo --gc --minify` |
| 184 | +- Build succeeds |
| 185 | +- Reports page count and build time |
| 186 | +- Does not commit or push anything |
| 187 | + |
| 188 | +**Pass criteria:** Build passes; only read-only operations and the hugo command are run; `public/` is not staged for commit. |
0 commit comments