From 2a206920edffe299a48a5bfb4c02f7bd6243edb1 Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Wed, 18 Mar 2026 23:42:15 -0500 Subject: [PATCH] fix: /retro midnight-aligned dates + local timezone (v0.7.2) (#199) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: use midnight-aligned dates and local timezone in /retro /retro was using --since="7 days ago" which is relative to current time, so running at 9pm gives a misleading "Mar 11 to Mar 18" title when data actually starts at 9pm Mar 11. Now computes absolute midnight-aligned start dates (--since="2026-03-11") for full calendar days. Also removes hardcoded Pacific time (TZ=America/Los_Angeles) throughout the template — all timestamps now use the user's local timezone, which is correct for a global user base. * chore: bump version and changelog (v0.7.2) Co-Authored-By: Claude Opus 4.6 --------- Co-authored-by: Claude Opus 4.6 --- CHANGELOG.md | 7 +++++++ VERSION | 2 +- retro/SKILL.md | 23 ++++++++++++----------- retro/SKILL.md.tmpl | 23 ++++++++++++----------- 4 files changed, 32 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1790addeffe716af4d89a783f70051f28b2dd8d..cc88928b37cc4a8d94c9e10565aa730c5b4d7305 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [0.7.2] - 2026-03-18 + +### Fixed + +- `/retro` date ranges now align to midnight instead of the current time. Running `/retro` at 9pm no longer silently drops the morning of the start date — you get full calendar days. +- `/retro` timestamps now use your local timezone instead of hardcoded Pacific time. Users outside the US-West coast get correct local hours in histograms, session detection, and streak tracking. + ## [0.7.1] - 2026-03-19 ### Added diff --git a/VERSION b/VERSION index 39e898a4f952d339c155a7939d571a5fdd6c8cfc..7486fdbc50b3f93d9d04db440483984df5d1dcce 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.7.1 +0.7.2 diff --git a/retro/SKILL.md b/retro/SKILL.md index 90fb547e57c12b083d3cc7bcc303ce58aa7f8f6c..a4458c22dc3d19f7007d14ff23c31354e4dd2183 100644 --- a/retro/SKILL.md +++ b/retro/SKILL.md @@ -178,7 +178,9 @@ When the user types `/retro`, run this skill. ## Instructions -Parse the argument to determine the time window. Default to 7 days if no argument given. Use `--since="N days ago"`, `--since="N hours ago"`, or `--since="N weeks ago"` (for `w` units) for git log queries. All times should be reported in **Pacific time** (use `TZ=America/Los_Angeles` when converting timestamps). +Parse the argument to determine the time window. Default to 7 days if no argument given. All times should be reported in the user's **local timezone** (use the system default — do NOT set `TZ`). + +**Midnight-aligned windows:** For day (`d`) and week (`w`) units, compute an absolute start date at local midnight, not a relative string. For example, if today is 2026-03-18 and the window is 7 days: the start date is 2026-03-11. Use `--since="2026-03-11"` for git log queries — git interprets a bare date as midnight in the local timezone, so this captures full calendar days regardless of what time the retro runs. For week units, multiply by 7 to get days (e.g., `2w` = 14 days back). For hour (`h`) units, use `--since="N hours ago"` since midnight alignment does not apply to sub-day windows. **Argument validation:** If the argument doesn't match a number followed by `d`, `h`, or `w`, the word `compare`, or `compare` followed by a number and `d`/`h`/`w`, show this usage and stop: ``` @@ -215,8 +217,7 @@ git log origin/ --since="" --format="%H|%aN|%ae|%ai|%s" --short git log origin/ --since="" --format="COMMIT:%H|%aN" --numstat # 3. Commit timestamps for session detection and hourly distribution (with author) -# Use TZ=America/Los_Angeles for Pacific time conversion -TZ=America/Los_Angeles git log origin/ --since="" --format="%at|%aN|%ai|%s" | sort -n +git log origin/ --since="" --format="%at|%aN|%ai|%s" | sort -n # 4. Files most frequently changed (hotspot analysis) git log origin/ --since="" --format="" --name-only | grep -v '^$' | sort | uniq -c | sort -rn @@ -296,7 +297,7 @@ If TODOS.md doesn't exist, skip the Backlog Health row. ### Step 3: Commit Time Distribution -Show hourly histogram in Pacific time using bar chart: +Show hourly histogram in local time using bar chart: ``` Hour Commits ████████████████ @@ -400,11 +401,11 @@ If the time window is 14 days or more, split into weekly buckets and show trends Count consecutive days with at least 1 commit to origin/, going back from today. Track both team streak and personal streak: ```bash -# Team streak: all unique commit dates (Pacific time) — no hard cutoff -TZ=America/Los_Angeles git log origin/ --format="%ad" --date=format:"%Y-%m-%d" | sort -u +# Team streak: all unique commit dates (local time) — no hard cutoff +git log origin/ --format="%ad" --date=format:"%Y-%m-%d" | sort -u # Personal streak: only the current user's commits -TZ=America/Los_Angeles git log origin/ --author="" --format="%ad" --date=format:"%Y-%m-%d" | sort -u +git log origin/ --author="" --format="%ad" --date=format:"%Y-%m-%d" | sort -u ``` Count backward from today — how many consecutive days have at least one commit? This queries the full history so streaks of any length are reported accurately. Display both: @@ -443,7 +444,7 @@ mkdir -p .context/retros Determine the next sequence number for today (substitute the actual date for `$(date +%Y-%m-%d)`): ```bash # Count existing retros for today to get next sequence number -today=$(TZ=America/Los_Angeles date +%Y-%m-%d) +today=$(date +%Y-%m-%d) existing=$(ls .context/retros/${today}-*.json 2>/dev/null | wc -l | tr -d ' ') next=$((existing + 1)) # Save as .context/retros/${today}-${next}.json @@ -617,8 +618,8 @@ Small, practical, realistic. Each must be something that takes <5 minutes to ado When the user runs `/retro compare` (or `/retro compare 14d`): -1. Compute metrics for the current window (default 7d) using `--since="7 days ago"` -2. Compute metrics for the immediately prior same-length window using both `--since` and `--until` to avoid overlap (e.g., `--since="14 days ago" --until="7 days ago"` for a 7d window) +1. Compute metrics for the current window (default 7d) using the midnight-aligned start date (same logic as the main retro — e.g., if today is 2026-03-18 and window is 7d, use `--since="2026-03-11"`) +2. Compute metrics for the immediately prior same-length window using both `--since` and `--until` with midnight-aligned dates to avoid overlap (e.g., for a 7d window starting 2026-03-11: prior window is `--since="2026-03-04" --until="2026-03-11"`) 3. Show a side-by-side comparison table with deltas and arrows 4. Write a brief narrative highlighting the biggest improvements and regressions 5. Save only the current-window snapshot to `.context/retros/` (same as a normal retro run); do **not** persist the prior-window metrics. @@ -640,7 +641,7 @@ When the user runs `/retro compare` (or `/retro compare 14d`): - ALL narrative output goes directly to the user in the conversation. The ONLY file written is the `.context/retros/` JSON snapshot. - Use `origin/` for all git queries (not local main which may be stale) -- Convert all timestamps to Pacific time for display (use `TZ=America/Los_Angeles`) +- Display all timestamps in the user's local timezone (do not override `TZ`) - If the window has zero commits, say so and suggest a different window - Round LOC/hour to nearest 50 - Treat merge commits as PR boundaries diff --git a/retro/SKILL.md.tmpl b/retro/SKILL.md.tmpl index 41a48e7fd4162041cbfa6ba38b8fa6b81a083305..95ee706e08b3ddd8a2abfc613639a6a999540036 100644 --- a/retro/SKILL.md.tmpl +++ b/retro/SKILL.md.tmpl @@ -44,7 +44,9 @@ When the user types `/retro`, run this skill. ## Instructions -Parse the argument to determine the time window. Default to 7 days if no argument given. Use `--since="N days ago"`, `--since="N hours ago"`, or `--since="N weeks ago"` (for `w` units) for git log queries. All times should be reported in **Pacific time** (use `TZ=America/Los_Angeles` when converting timestamps). +Parse the argument to determine the time window. Default to 7 days if no argument given. All times should be reported in the user's **local timezone** (use the system default — do NOT set `TZ`). + +**Midnight-aligned windows:** For day (`d`) and week (`w`) units, compute an absolute start date at local midnight, not a relative string. For example, if today is 2026-03-18 and the window is 7 days: the start date is 2026-03-11. Use `--since="2026-03-11"` for git log queries — git interprets a bare date as midnight in the local timezone, so this captures full calendar days regardless of what time the retro runs. For week units, multiply by 7 to get days (e.g., `2w` = 14 days back). For hour (`h`) units, use `--since="N hours ago"` since midnight alignment does not apply to sub-day windows. **Argument validation:** If the argument doesn't match a number followed by `d`, `h`, or `w`, the word `compare`, or `compare` followed by a number and `d`/`h`/`w`, show this usage and stop: ``` @@ -81,8 +83,7 @@ git log origin/ --since="" --format="%H|%aN|%ae|%ai|%s" --short git log origin/ --since="" --format="COMMIT:%H|%aN" --numstat # 3. Commit timestamps for session detection and hourly distribution (with author) -# Use TZ=America/Los_Angeles for Pacific time conversion -TZ=America/Los_Angeles git log origin/ --since="" --format="%at|%aN|%ai|%s" | sort -n +git log origin/ --since="" --format="%at|%aN|%ai|%s" | sort -n # 4. Files most frequently changed (hotspot analysis) git log origin/ --since="" --format="" --name-only | grep -v '^$' | sort | uniq -c | sort -rn @@ -162,7 +163,7 @@ If TODOS.md doesn't exist, skip the Backlog Health row. ### Step 3: Commit Time Distribution -Show hourly histogram in Pacific time using bar chart: +Show hourly histogram in local time using bar chart: ``` Hour Commits ████████████████ @@ -266,11 +267,11 @@ If the time window is 14 days or more, split into weekly buckets and show trends Count consecutive days with at least 1 commit to origin/, going back from today. Track both team streak and personal streak: ```bash -# Team streak: all unique commit dates (Pacific time) — no hard cutoff -TZ=America/Los_Angeles git log origin/ --format="%ad" --date=format:"%Y-%m-%d" | sort -u +# Team streak: all unique commit dates (local time) — no hard cutoff +git log origin/ --format="%ad" --date=format:"%Y-%m-%d" | sort -u # Personal streak: only the current user's commits -TZ=America/Los_Angeles git log origin/ --author="" --format="%ad" --date=format:"%Y-%m-%d" | sort -u +git log origin/ --author="" --format="%ad" --date=format:"%Y-%m-%d" | sort -u ``` Count backward from today — how many consecutive days have at least one commit? This queries the full history so streaks of any length are reported accurately. Display both: @@ -309,7 +310,7 @@ mkdir -p .context/retros Determine the next sequence number for today (substitute the actual date for `$(date +%Y-%m-%d)`): ```bash # Count existing retros for today to get next sequence number -today=$(TZ=America/Los_Angeles date +%Y-%m-%d) +today=$(date +%Y-%m-%d) existing=$(ls .context/retros/${today}-*.json 2>/dev/null | wc -l | tr -d ' ') next=$((existing + 1)) # Save as .context/retros/${today}-${next}.json @@ -483,8 +484,8 @@ Small, practical, realistic. Each must be something that takes <5 minutes to ado When the user runs `/retro compare` (or `/retro compare 14d`): -1. Compute metrics for the current window (default 7d) using `--since="7 days ago"` -2. Compute metrics for the immediately prior same-length window using both `--since` and `--until` to avoid overlap (e.g., `--since="14 days ago" --until="7 days ago"` for a 7d window) +1. Compute metrics for the current window (default 7d) using the midnight-aligned start date (same logic as the main retro — e.g., if today is 2026-03-18 and window is 7d, use `--since="2026-03-11"`) +2. Compute metrics for the immediately prior same-length window using both `--since` and `--until` with midnight-aligned dates to avoid overlap (e.g., for a 7d window starting 2026-03-11: prior window is `--since="2026-03-04" --until="2026-03-11"`) 3. Show a side-by-side comparison table with deltas and arrows 4. Write a brief narrative highlighting the biggest improvements and regressions 5. Save only the current-window snapshot to `.context/retros/` (same as a normal retro run); do **not** persist the prior-window metrics. @@ -506,7 +507,7 @@ When the user runs `/retro compare` (or `/retro compare 14d`): - ALL narrative output goes directly to the user in the conversation. The ONLY file written is the `.context/retros/` JSON snapshot. - Use `origin/` for all git queries (not local main which may be stale) -- Convert all timestamps to Pacific time for display (use `TZ=America/Los_Angeles`) +- Display all timestamps in the user's local timezone (do not override `TZ`) - If the window has zero commits, say so and suggest a different window - Round LOC/hour to nearest 50 - Treat merge commits as PR boundaries