From 4497800bc85deda647841d41ef9c10d5f341bb45 Mon Sep 17 00:00:00 2001 From: Martin Trapp <94928215+martrapp@users.noreply.github.com> Date: Wed, 20 May 2026 13:38:50 +0200 Subject: [PATCH] Refactor RSS update automation and enhance documentation for clarity --- .github/skills/update-rss/SKILL.md | 82 +++++++------ .github/skills/update-rss/check-rss-sort.ts | 29 ----- .../diff-file-from-last-build-date.ts | 115 ++++++++++++++++++ src/content/docs/recent-updates.md | 10 +- 4 files changed, 163 insertions(+), 73 deletions(-) delete mode 100644 .github/skills/update-rss/check-rss-sort.ts create mode 100644 .github/skills/update-rss/diff-file-from-last-build-date.ts diff --git a/.github/skills/update-rss/SKILL.md b/.github/skills/update-rss/SKILL.md index c02823f..ac12cb2 100644 --- a/.github/skills/update-rss/SKILL.md +++ b/.github/skills/update-rss/SKILL.md @@ -13,47 +13,51 @@ disable-model-invocation: false ## Input - Confirm that git is up to date before starting. This workflow relies on commit history for `pubDate` decisions. -## High-value automation in this skill -- Use scripts for the repetitive, easy-to-get-wrong parts: mapping RSS entries to source files, restoring selected `pubDate` values, and re-sorting entries. -- Keep human review focused on classification only: decide minor vs. substantive, then let scripts apply updates. -- Run steps sequentially: `node bin/rss-update.ts` depends on finished `npm run build` output. -- **Classification is the critical human task.** The difference between minor and substantive directly affects how readers discover content. A new technique or capability warrants a new `pubDate`. +## Automation & Workflow +This workflow is **fully scripted except for one critical decision**: classifying changes as minor or substantive. All other steps—identifying changed entries, extracting source paths, diffing files, restoring dates, and re-sorting—are automated. + +- All manual git work is replaced by scripts: `diff-rss.ts`, `diff-file-from-last-build-date.ts`, and `apply-rss-date-overrides.ts`. +- The **only human/LLM task** is deciding whether a changed entry is minor (keep old pubDate) or substantive (keep new pubDate). +- This classification directly affects reader discovery: new techniques or capabilities warrant a new `pubDate`; style/grammar fixes do not. ## Procedure -0. Ask the user whether git is up to date. Stop immediately if the user says no. This is important because the process relies on commit dates for time stamps. - -1. Run `npm run build` to update `public/rss.xml`. Stop immediately if the build fails. - -2. Run `node .github/skills/update-rss/diff-rss.ts` to identify which existing entries have changed `pubDate` values versus `HEAD`, and which are brand new. The output now includes the source content path for each entry, so do not derive the path manually from the URL unless the script reports an unresolved fallback path. - -3. For each entry listed as CHANGED, use the source file path reported by `node .github/skills/update-rss/diff-rss.ts`. Check whether the change since the old `pubDate` is minor: - - Find the commit that was current as of the committed `pubDate`, following renames: `git log --follow --before="" -1 --format="%H" -- ` - - If that command returns no commit, stop treating it as a routine minor-change candidate and keep the new `pubDate`. - - If you need the historical path at that commit, get it with: `git log --follow --before="" -1 --name-only --format="" -- ` - - Get the diff to the current file: - - If the path is unchanged, use: `git --no-pager diff -- ` - - If the file was renamed, compare the historical blob to the current file: `git --no-pager diff : -- ` - - **⚠️ CRITICAL: Review the FULL diff, not a sample.** If the diff is large (>150 lines), scan the entire output before classifying. Look for red flags: - - New section headings (`##`, `###`) indicate substantive additions - - Lines showing "moved" or "new" sections in git output - - Large blocks of new prose or code examples (not just fixes) - - A diff is **minor** if the page keeps the primary functionality described and the key technical concepts remain unchanged, even when wording is expanded or reorganized for clarity. - - Treat as **minor**: grammar/style fixes, formatting, link updates, readability rewrites, sentence/paragraph reshuffling, and examples or clarifications that do not change recommendations or factual claims. - - A diff is **substantive** only if it changes what the reader should do or believe: new/removed features, changed compatibility/support statements, changed API semantics, changed recommended patterns, added/removed constraints/caveats, **or teaches new techniques/capabilities the reader didn't know before**. - - If uncertain, apply this test: if a developer familiar with the technology and its typical use cases would keep the same implementation decisions after reading both versions, classify as **minor**. If they would learn a *new technique* or *new capability*, classify as **substantive**. - - Keep a list of CHANGED entry `guid` values that you classify as **minor**. - - If the change is substantive, keep the new `pubDate` as is. - -4. ADDED entries (new `guid` not in `HEAD`) always keep their new `pubDate` without review. - -5. After classifying all CHANGED entries, restore the old dates for the minor ones with the script instead of editing XML by hand: - - Inline GUIDs: `node .github/skills/update-rss/apply-rss-date-overrides.ts ...` - - Or use a file with one GUID per line: `node .github/skills/update-rss/apply-rss-date-overrides.ts --guid-file /tmp/minor-rss-guids.txt` - - The script restores `pubDate` values from `HEAD` only for the selected GUIDs and automatically re-sorts all `` entries in `public/rss.xml` by descending `pubDate`. - -6. Validate the final result: - - Run `node .github/skills/update-rss/diff-rss.ts` again and confirm that only the intended substantive entries still appear under CHANGED. - - Run `node .github/skills/update-rss/check-rss-sort.ts` and confirm it prints `RSS_SORT_OK`. + +### Pre-flight check +0. Ask the user whether git is up to date. Stop the whole process immediately if the user says no. This is critical because the workflow relies on commit history for timestamps. + +### Step 1: Build (automated) +1. Run `npm run build` to update `public/rss.xml`. Stop if the build fails. + +### Step 2: Identify changes (automated) +2. Run `node .github/skills/update-rss/diff-rss.ts` to detect: + - ADDED entries (new GUIDs) → keep new `pubDate`, no review needed + - CHANGED entries (existing GUIDs with different `pubDate`) → these need your classification + +### Step 3: Classify changes (manual — this is the only decision you make) +For each CHANGED entry, **you decide: minor or substantive?** + +**To make this decision:** +- Use `node .github/skills/update-rss/diff-file-from-last-build-date.ts ` to see what changed since the last build date. +- **MANDATORY:** Classify only after reviewing the complete diff output for the file. +- Base the decision on the full file diff, not on a shortened or summarized representation. +- Ask: *Would a developer familiar with this topic learn a new technique or capability, or keep the same implementation decisions?* + +**Classification rules:** +- **Minor** (keep old `pubDate`): grammar/style fixes, formatting, link updates, readability rewrites, paragraph reshuffling, or clarifications that don't change recommendations or facts. +- **Substantive** (keep new `pubDate`): new/removed features, changed API semantics, changed compatibility statements, changed recommended patterns, new constraints, **or teaches new techniques/capabilities**. + + +Once you classify all CHANGED entries, record the GUIDs you marked as **minor**. + +### Step 4: Apply classifications (automated) +4. Run the script to restore old dates for minor entries: + - Inline: `node .github/skills/update-rss/apply-rss-date-overrides.ts ...` + - Or from file: `node .github/skills/update-rss/apply-rss-date-overrides.ts --guid-file /tmp/minor-guids.txt` (one GUID per line) + - The script automatically re-sorts all entries by `pubDate`. + +### Step 5: Validate (automated) +5. Run these validation scripts: + - `node .github/skills/update-rss/diff-rss.ts` → confirm only substantive entries appear under CHANGED ## URL to source file mapping - Normally, do not use this mapping because `diff-rss.ts` already reports the source file path. diff --git a/.github/skills/update-rss/check-rss-sort.ts b/.github/skills/update-rss/check-rss-sort.ts deleted file mode 100644 index a7673a8..0000000 --- a/.github/skills/update-rss/check-rss-sort.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { parseRss, readRssFile } from './rss-utils.ts'; - -const items = parseRss(readRssFile()).items; -let previousTimestamp = Number.POSITIVE_INFINITY; -let isSorted = true; - -for (const item of items) { - const { guid, pubDate } = item; - const timestamp = Date.parse(pubDate ?? ''); - - if (Number.isNaN(timestamp)) { - console.log(`INVALID_DATE ${guid} | ${pubDate}`); - process.exitCode = 1; - isSorted = false; - continue; - } - - if (timestamp > previousTimestamp) { - console.log(`OUT_OF_ORDER ${guid} | ${pubDate}`); - process.exitCode = 1; - isSorted = false; - } - - previousTimestamp = timestamp; -} - -if (isSorted) { - console.log('RSS_SORT_OK'); -} \ No newline at end of file diff --git a/.github/skills/update-rss/diff-file-from-last-build-date.ts b/.github/skills/update-rss/diff-file-from-last-build-date.ts new file mode 100644 index 0000000..f6fb7b7 --- /dev/null +++ b/.github/skills/update-rss/diff-file-from-last-build-date.ts @@ -0,0 +1,115 @@ +import fs from 'node:fs'; +import { execSync } from 'node:child_process'; +import { extractTagValue, readHeadRssFile } from './rss-utils.ts'; + +function usage(): void { + console.log('Usage: node .github/skills/update-rss/diff-file-from-last-build-date.ts '); +} + +function runGit(command: string): string { + return execSync(command, { encoding: 'utf8' }).trim(); +} + +function shellQuote(value: string): string { + return `'${value.replace(/'/g, `'\\''`)}'`; +} + +function parseArgs(argv: string[]): { filePath?: string } { + let filePath: string | undefined; + + for (const arg of argv) { + if (arg === '--help' || arg === '-h') { + usage(); + process.exit(0); + } + + if (!filePath) { + filePath = arg; + continue; + } + + console.error(`Unexpected argument: ${arg}`); + usage(); + process.exit(1); + } + + return { filePath }; +} + +function getHeadLastBuildDate(): string { + const headRss = readHeadRssFile(); + const lastBuildDate = extractTagValue(headRss, 'lastBuildDate'); + + if (!lastBuildDate) { + throw new Error('Unable to read from HEAD public/rss.xml'); + } + console.log(`HEAD RSS lastBuildDate: ${lastBuildDate}`); + return lastBuildDate; +} + +function resolveHistoricalCommit(filePath: string, beforeDate: string): string { + const commit = runGit( + `git log --follow --before=${shellQuote(beforeDate)} -1 --format=%H -- ${shellQuote(filePath)}`, + ); + + if (!commit) { + throw new Error(`No commit found for ${filePath} at or before ${beforeDate}`); + } + + return commit; +} + +function resolveHistoricalPath(filePath: string, commit: string): string { + const lines = runGit( + `git log --follow --name-only --format=%H -- ${shellQuote(filePath)}`, + ) + .split('\n') + .map(line => line.trim()) + .filter(Boolean); + + let currentCommit = ''; + for (const line of lines) { + if (/^[0-9a-f]{40}$/.test(line)) { + currentCommit = line; + continue; + } + + if (currentCommit === commit) { + return line; + } + } + + throw new Error(`Unable to resolve historical path for ${filePath} at ${commit}`); +} + +const { filePath } = parseArgs(process.argv.slice(2)); + +if (!filePath) { + usage(); + process.exit(1); +} + +if (!fs.existsSync(filePath)) { + console.error(`File does not exist: ${filePath}`); + process.exit(1); +} + +const lastBuildDate = getHeadLastBuildDate(); +const historicalCommit = resolveHistoricalCommit(filePath, lastBuildDate); +const historicalPath = resolveHistoricalPath(filePath, historicalCommit); + +console.log(`HEAD_RSS_LAST_BUILD_DATE ${lastBuildDate}`); +console.log(`FILE ${filePath}`); +console.log(`BASE_COMMIT ${historicalCommit}`); +console.log(`BASE_PATH ${historicalPath}`); + +const diffCommand = historicalPath === filePath + ? `git --no-pager diff ${historicalCommit} -- ${shellQuote(filePath)}` + : `git --no-pager diff ${shellQuote(`${historicalCommit}:${historicalPath}`)} -- ${shellQuote(filePath)}`; + +const diffOutput = execSync(diffCommand, { encoding: 'utf8' }); +if (diffOutput.trim()) { + process.stdout.write(diffOutput); +} else { + console.log('NO_DIFF'); +} \ No newline at end of file diff --git a/src/content/docs/recent-updates.md b/src/content/docs/recent-updates.md index e6dd137..7542198 100644 --- a/src/content/docs/recent-updates.md +++ b/src/content/docs/recent-updates.md @@ -6,6 +6,11 @@ description: Last update dates of all articles on vtbag.dev This list shows last update dates for all articles on vtbag.dev. The list also reflects minor updates, such as fixing typos or improving formatting. If you are interested in major updates only, check the [RSS feed](https://vtbag.dev/rss.xml). +- [Recent updates](https://vtbag.dev/recent-updates/)\ +Last update dates of all articles on vtbag.dev\ +First published Tue, 28 Apr 2026 15:06:01 GMT\ +Last updated Wed, 20 May 2026 08:15:10 GMT + - [Styling View Transitions](https://vtbag.dev/basics/styling/)\ Styling view transitions including :active-view-transition-type and view-transition-class\ First published Wed, 23 Oct 2024 12:29:56 GMT\ @@ -26,11 +31,6 @@ How to override the defaults animations for the ::view-transition-old and ::view First published Sat, 25 Jan 2025 12:31:50 GMT\ Last updated Tue, 19 May 2026 06:22:16 GMT -- [Recent updates](https://vtbag.dev/recent-updates/)\ -Last update dates of all articles on vtbag.dev\ -First published Tue, 28 Apr 2026 15:06:01 GMT\ -Last updated Mon, 11 May 2026 21:42:57 GMT - - [Automatically Assigned View Transition Names](https://vtbag.dev/tips/auto-names/)\ Explore current methods for automatically generating view transition names.\ First published Sat, 08 Feb 2025 09:55:50 GMT\ -- knotmirror 0.0.1