From 379ba4300ec263ee26d28d35a8a3d7701968e5a4 Mon Sep 17 00:00:00 2001 From: Ryan Lewis Date: Sat, 13 Jun 2026 18:07:46 +0100 Subject: [PATCH] fix(when): stop rejecting weekday names like "monday" `--when monday` was rejected with "did you mean today?" because levenshtein("monday","today") == 2, inside the typo-detection threshold. Weekday names are valid natural-language values that Things accepts verbatim (and SKILL.md already documents them). Allowlist weekday names and their abbreviations so they bypass the keyword typo detector before nearKeyword runs. --- internal/things/dates.go | 16 ++++++++++++++++ internal/things/dates_test.go | 5 +++++ 2 files changed, 21 insertions(+) diff --git a/internal/things/dates.go b/internal/things/dates.go index 62b8de8..cc21746 100644 --- a/internal/things/dates.go +++ b/internal/things/dates.go @@ -9,10 +9,23 @@ import ( var whenKeywords = []string{"today", "tomorrow", "evening", "anytime", "someday"} +// weekdayWords are natural-language day names Things accepts verbatim. They are +// allowlisted so the typo detector never mistakes them for a keyword — e.g. +// "monday" is Levenshtein distance 2 from "today" and would otherwise be +// rejected as a typo. Abbreviations are included for the same reason. +var weekdayWords = []string{ + "monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday", + "mon", "tue", "tues", "wed", "thu", "thur", "thurs", "fri", "sat", "sun", +} + func isWhenKeyword(s string) bool { return slices.Contains(whenKeywords, s) } +func isWeekdayWord(s string) bool { + return slices.Contains(weekdayWords, s) +} + // NormalizeWhen validates and canonicalises a --when value. // // Accepted forms: @@ -37,6 +50,9 @@ func NormalizeWhen(s string) (string, error) { if t, ok := parseISO8601(v); ok { return t.Format("2006-01-02") + "@" + t.Format("15:04"), nil } + if isWeekdayWord(strings.ToLower(v)) { + return v, nil + } if k, ok := nearKeyword(v); ok { return "", fmt.Errorf("unrecognised --when value %q (did you mean %q? valid keywords: %s)", v, k, strings.Join(whenKeywords, ", ")) } diff --git a/internal/things/dates_test.go b/internal/things/dates_test.go index 0364823..a71d594 100644 --- a/internal/things/dates_test.go +++ b/internal/things/dates_test.go @@ -25,6 +25,11 @@ func TestNormalizeWhen(t *testing.T) { {"21:30", "21:30"}, {"next friday", "next friday"}, {"friday", "friday"}, + {"monday", "monday"}, // dist 2 from "today" — must not be flagged as a typo + {"Monday", "Monday"}, // case preserved for NL pass-through + {"tuesday", "tuesday"}, + {"sunday", "sunday"}, + {"mon", "mon"}, {"tonight", "tonight"}, {"noon", "noon"}, {"2026-03-10T14:30:00Z", "2026-03-10@14:30"},