Skip to content

feat(parser): widen note dialects (DD/MM dates, weekday headers, space/slash sets, @ bw) - #44

Merged
benasbarciauskas merged 4 commits into
mainfrom
feat/parser-dialects
Jun 23, 2026
Merged

feat(parser): widen note dialects (DD/MM dates, weekday headers, space/slash sets, @ bw)#44
benasbarciauskas merged 4 commits into
mainfrom
feat/parser-dialects

Conversation

@benasbarciauskas

Copy link
Copy Markdown
Owner

Widens the deterministic notes parser to handle four more freeform dialects a live smoke test proved it dropped — no LLM, web-only, no regression to the existing dialect.

Adds

  • DD/MM (UK) numeric dates w/ optional weekday: mon 14/10, 14/10/24, Wed 5/4 (day>12 unambiguous; explicit DD/MM path ahead of chrono).
  • Weekday-led session headers so multi-session notes split: wed legs, Monday push.
  • Set tokenizer: space-separated 100x5 102.5x5 105x4, slash rep-lists 60kg 5/5/4 + bodyweight 12/10 / 12/10/8, WEIGHT NxM scheme 140 x5x5. Carried-weight preserved.
  • @-bodyweight: @ 88kg, @88.

Determinism

Parser stays pure — current-year threaded in from the call boundary (pipeline.ts), no Date.now() in src/parser/*.

Review-driven fixes (caught before merge)

  • 🔴 silent data loss on two-value bodyweight slash (pullups 12/10) → fixed.
  • 🟡 false "Unparsed" warning flood on parsed lines → fixed (shared token recognizer).
  • integration date-theft: mid-line 12/10 no longer stolen as the workout date.

Verification

371 tests pass (+19). Smoke on the messy note: 2 workouts, all exercises + weights, correct DD/MM date, bodyweight, 0 false warnings.

Spec: docs/superpowers/specs/2026-06-23-parser-dialects-design.md

…der warnings

Two-value bodyweight slash rep-lists like "pullups 12/10" (and 10/8) were
dropped entirely — no sets, no warning — when both values were <=12, because
the bare-slash branch rejected them via a looksLikeNumericDate guard that
mis-read "12/10" as a DD/MM date. Inside parseSets the text is always set-text
on a line that already has an exercise name, so the date guard was wrong here:
drop it (and the now-unused helper). Date headers are still matched at
line-start in segment.ts / fields.ts.

collectInlineRemainders split set-text on commas and flagged any token with
letters as an unparsed inline entry, falsely flooding the Review UI with one
warning per exercise for the new space/scheme/slash set formats (the exercise
name stays in the first comma-segment). It now reuses the set tokenizer's own
recognizers (new isFullySetTokens) to strip recognized set tokens before
deciding a segment is an unparsed alpha remainder. Genuine inline secondary
exercises (e.g. "then archers x 10") are still flagged.

Also tidy parseToken's weight-only carrier branch contract comment.

Tests: add pullups 12/10 and 10/8 (2-set bodyweight, no data loss), a
dips 20/15 case, and a no-false-warning assertion on the messy-dialect note
while keeping the archers x 10 warning assertion.
…out date

In a full note, a bodyweight exercise line like "pullups 12/10" was mis-read as
the workout DATE (2026-12-10) and the exercise was dropped: date extraction ran
on the exercise line and chrono greedily interpreted the mid-line "12/10" as a
date. This violates the dialect spec §3 (dates are matched only at
header/line-start, never mid-line on an exercise line).

Three reinforcing fixes:
- parseNotes: parse each line as an exercise up front and skip date extraction
  when the line yields an exercise (parsed.length > 0). This is more precise than
  a !looksLikeSetLine guard, which would wrongly skip the date on the
  "19:10, Saturday, 20 Jun 2026" time-prefixed header (that line trips the colon
  branch of looksLikeSetLine yet is a real date header, not an exercise).
- looksLikeSetLine: recognise a two-value bodyweight slash rep-list after an
  exercise name ("pullups 12/10"), excluding weekday-led numeric date headers
  ("mon 14/10") so those still date correctly.
- fields.ts extractDate: strip bare numeric slash/dash date tokens before the
  chrono fallback so a mid-line "12/10" can never be read as 10 Dec even if
  chrono is reached. Named-month dates ("26 Aug 2024") are unaffected; the
  line-start numeric form is still handled by parseNumericDDMM.

Integration test: a 3-line note (wed legs / pullups 12/10 / squat 140 x5x5)
asserts the legs session is undated (not 2026-12-10) and keeps BOTH pullups
(2 bodyweight sets, reps 12/10) and squat — locking the regression the unit
test missed. mon 14/10 push @ 88kg still dates to 14 Oct.
@benasbarciauskas
benasbarciauskas merged commit cbee835 into main Jun 23, 2026
1 check passed
@benasbarciauskas
benasbarciauskas deleted the feat/parser-dialects branch June 23, 2026 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant