Skip to content

Commit 888c40d

Browse files
authored
Merge pull request #5 from pascalorg/feat/calendar-notation-grid-demos
Calendar ranges, plus three demos: adaptive date field, LaTeX notation, normalizing grid
2 parents a60be5e + 194358d commit 888c40d

51 files changed

Lines changed: 3787 additions & 198 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/release.yml‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,23 @@ jobs:
7070
git config user.name "github-actions[bot]"
7171
git config user.email "github-actions[bot]@users.noreply.github.com"
7272
git add packages/lingo/package.json packages/lingo/CHANGELOG.md
73-
git commit -m "chore(release): v${{ steps.bump.outputs.version }}"
74-
git tag "v${{ steps.bump.outputs.version }}"
73+
git commit -m "chore(release): v$VERSION"
74+
git tag "v$VERSION"
7575
git push origin HEAD --tags
76-
gh release create "v${{ steps.bump.outputs.version }}" --generate-notes
76+
# Release body = the curated changelog section, never an auto commit
77+
# list. The notes file lives in RUNNER_TEMP so it can't be committed,
78+
# and reaches gh via --notes-file: the changelog is full of backticks
79+
# and quotes that would execute or break quoting if interpolated.
80+
# npm has already published by this point, so a missing or empty
81+
# section falls back to --generate-notes rather than failing the run.
82+
NOTES="$RUNNER_TEMP/release-notes.md"
83+
if node packages/lingo/scripts/changelog-section.mjs "$VERSION" \
84+
--changelog packages/lingo/CHANGELOG.md --out "$NOTES"; then
85+
gh release create "v$VERSION" --title "v$VERSION" --notes-file "$NOTES"
86+
else
87+
echo "::warning::no changelog section for $VERSION; using generated notes"
88+
gh release create "v$VERSION" --title "v$VERSION" --generate-notes
89+
fi
7790
env:
7891
GH_TOKEN: ${{ github.token }}
92+
VERSION: ${{ steps.bump.outputs.version }}

‎CONTEXT.md‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ kilograms, kelvin, seconds…). *Avoid: amount, measurement, normalized value.*
3232
**Range:** a `QuantityRange` — min/max quantities, `plusMinus`, open bounds,
3333
approximate/fuzzy flags. Never use "range" for text offsets — that's a **span**.
3434

35+
**Date range:** a `DateRange` from `parseDateRange()` — start/end endpoints,
36+
either end optionally open. Unqualified "range" means the quantity kind; say
37+
"date range" when you mean this one. It comes in three shapes, and these are
38+
the names to use: a **time slot** from clock grammar (`2pm to 4pm`, `9-5`), a
39+
**dated span** between two dates (`Aug 3 - Aug 9`; "date-to-date span" is the
40+
long form), and a **calendar period** widened to its real first and last day
41+
(`next week`, `August`, `2027`). The runtime-only `dated` flag is `true` on the
42+
latter two and absent on a slot — test it truthy, never `=== false`.
43+
3544
**Span:** `{ start, end }` character offsets into the ORIGINAL input string
3645
(the normalizer keeps an offset map, hard rule 3). *Avoid: range, position,
3746
location.*
@@ -129,8 +138,9 @@ docs generate Zod/Valibot/TypeBox/ArkType/Effect adapters + a dictionary from it
129138
`createLingo()` returns an isolated **instance** with its own registry,
130139
messages, and fuzzy vocab.
131140

132-
**Corpus:** `packages/lingo/tests/corpus/contract-v1.json` — the behavior
133-
contract. Drift is classified **ADDITIVE** (new inputs now parse) or
141+
**Corpus:** the behavior contracts under `packages/lingo/tests/corpus/` —
142+
`contract-v1.json` for English plus one `locale-<id>-contract-v1.json` per
143+
locale pack. Drift is classified **ADDITIVE** (new inputs now parse) or
134144
**BREAKING** (existing interpretations changed) by `scripts/corpus-diff.mjs`;
135145
BREAKING requires a decision entry and a major version.
136146

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ with the package: [`packages/lingo`](packages/lingo/README.md).**
7777
|------|------------|
7878
| [`packages/lingo`](packages/lingo) | `@pascal-app/lingo`, the published library (src, tests, bench, size/corpus/zero-deps gates) |
7979
| [`apps/site`](apps/site) | Docs site with live parser demos (Next.js, port 3000 or next free) |
80+
| [`skills/`](skills/README.md) | Agent skills shipped for coding agents (`skills/lingo` — the on-ramp to using the library) |
8081
| [`plans/`](plans/README.md) | Forward-looking specs, one numbered living markdown file per topic |
8182
| [`wiki/`](wiki/README.md) | As-built docs: architecture, decisions, conventions, credits, research |
8283
| [`AGENTS.md`](AGENTS.md) | Canonical agent guide (hard rules, workflow, module map) |

‎apps/site/package.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@
1818
"dependencies": {
1919
"@base-ui/react": "^1.6.0",
2020
"@pascal-app/lingo": "workspace:*",
21+
"@tanstack/react-table": "^8.21.3",
2122
"@vercel/analytics": "^2.0.1",
2223
"class-variance-authority": "^0.7.1",
2324
"clsx": "^2.1.1",
2425
"geist": "^1.7.2",
26+
"katex": "^0.18.1",
2527
"lucide-react": "^1.23.0",
2628
"marked": "^18.0.7",
2729
"motion": "^12.42.2",
@@ -33,6 +35,7 @@
3335
},
3436
"devDependencies": {
3537
"@tailwindcss/postcss": "^4",
38+
"@types/katex": "^0.16.8",
3639
"@types/node": "^20",
3740
"@types/react": "^19",
3841
"@types/react-dom": "^19",

‎apps/site/public/llms-small.txt‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ import { parseDate, parseDateRange, humanizeDate, parseDuration } from "@pascal-
9797
const now = new Date("2026-07-08T12:00:00Z")
9898
parseDate("three days ago", { now }) // grain "day"; reference-dependent inputs need explicit now
9999
parseDateRange("2pm to 4pm", { now }) // { start, end } civil endpoints
100+
parseDateRange("Aug 3 - Aug 9", { now }) // dated span, day grain, dated: true
101+
parseDateRange("August", { now }) // whole period: Aug 1 → Aug 31
100102
parseDuration("1h30").duration.base // 5400 seconds
101103
humanizeDate(d, { now }) // "3 days ago" — always re-parses within one grain
102104
```
@@ -105,6 +107,10 @@ humanizeDate(d, { now }) // "3 days ago" — always re-parses within one grain
105107
- Trailing timezones detected on `.zone`; pass `applyZone: true` to resolve the real UTC instant.
106108
- `parseDateRange`, `humanizeDateRange`, `humanizeDuration`.
107109

110+
`parseDateRange` reads three shapes, in this order: a **time slot** (`2pm to 4pm`, `between 9am and 5pm`, `9-5`, `from 3pm`), a **date-to-date span** (`July 1 to July 5`, `Aug 3 - Aug 9`, `from tomorrow to friday`, `Mon-Fri`, `2026-08-01 to 2026-08-05`), and a **whole calendar period** expanded to its real first and last day (`next week` → Mon–Sun, `next month` → 1st–last, `2027` → Jan 1–Dec 31, `August`, `this weekend` → Sat–Sun). A coarse endpoint widens on the CLOSING side too: `July to August` ends Aug 31 and `until August` ends Aug 31, while `from August` opens on the 1st. `this weekend` on a Saturday or Sunday means the weekend in progress. Two absolute dates given backwards (`2026-08-09 to 2026-08-03`) are swapped with a `RANGE_REVERSED` warning; overnight clock slots (`9pm to 5am`) pass through untouched. A runtime-only `dated` flag says which grammar matched, so one field can drive a day picker, a range picker, or a slot picker; `humanizeDateRange` renders dated ranges as dates (`2026-08-01 to 2026-08-31`) and slots as clock phrases, both re-parseable.
111+
112+
Not supported: quarters (`Q3`, `next quarter`), elliptical right sides (`Aug 3-9`), and dash-joined ISO dates with no spaces (`2026-08-01-2026-08-05`) — all return `UNSUPPORTED_DATE`. Use a spaced dash or `to` between ISO dates.
113+
108114
## DOM (`@pascal-app/lingo/dom`)
109115

110116
```ts
@@ -249,7 +255,7 @@ Fields implement Standard Schema (validate + jsonSchema). Input JSON Schema is `
249255
- `toJSONSchema(field, { io?, target? })`, `repairTextWith(spec)`, `repairToolCallWith(specsByTool)`.
250256
- `canonicalizeValues(value, spec)`, `quantityMatch`, `dateMatch`.
251257

252-
Tool-boundary defaults: `AMBIGUOUS_NUMBER` → error + candidate; `dateField` escalates `TZ_IGNORED` and requires explicit `now` for reference-dependent dates; `lingoObject` is closed (`additionalProperties: false`; `{passthrough:true}` opts out).
258+
Tool-boundary defaults: `AMBIGUOUS_NUMBER` → error + candidate; `dateField` escalates `TZ_IGNORED` and requires explicit `now` for reference-dependent dates; `lingoObject` is closed (`additionalProperties: false`; `{passthrough:true}` opts out). `dateRangeField` shares those guards and accepts every `parseDateRange` shape — slots, dated spans, and calendar periods — returning `{ start?, end?: ISO }`.
253259

254260
## MCP (`@pascal-app/lingo/mcp`)
255261

@@ -325,13 +331,15 @@ The `/docs#forms-ux` section and `/docs/forms-ux.md` markdown mirror show the sa
325331
| TZ_IGNORED | Timezone detected but not applied | Pass `applyZone:true` or remove zone from input |
326332
| TYPO_CORRECTED | Typo auto-fixed | Use `strictness:'confirm'` to fail with candidate |
327333
| RANGE_MIN / RANGE_MAX | Value outside bounds | Re-emit within min/max advertised in field description |
334+
| RANGE_REVERSED | Bounds given high-to-low; parser swapped them | Emit low-to-high, or accept the swap |
335+
| UNSUPPORTED_DATE | Date/range shape not in the grammar (`Q3`, `Aug 3-9`) | Re-emit a supported shape or an explicit `start to end` pair |
328336
| RATE_REQUIRED | Cross-currency without rates | Call `convertCurrency` with injected rates |
329337

330338
Full list: EMPTY, NO_VALUE, UNKNOWN_UNIT, KIND_MISMATCH, RANGE_KIND_MISMATCH, CONVERSION_KIND_MISMATCH, RATE_REQUIRED, TRAILING_INPUT, SINGLE_VALUE_EXPECTED, APPROX_NOT_ALLOWED, UNIT_REQUIRED, CONVERSION_NOT_ALLOWED, NUMBER_FORMAT, NONFINITE, LOCALE_NOT_LOADED, RANGE_MIN, RANGE_MAX, RANGE_OPEN_BOUND_NOT_ALLOWED, REQUIRED, UNSUPPORTED_DATE, NOW_REQUIRED, TYPO_CORRECTED, AMBIGUOUS_NUMBER, AMBIGUOUS_UNIT, AMBIGUOUS_DATE, RANGE_REVERSED, COMPOUND_OVERFLOW, CIVIL_AVERAGE, UNIT_ASSUMED, WEEKDAY_ASSUMED_NEXT, SLANG_UNIT, TZ_IGNORED, AMBIGUOUS_TIMEZONE. Override copy via `messages` option map.
331339

332340
## Canonical examples (input → essence)
333341

334-
"2 ft" → quantity length base 0.6096 m · "5'11\"" → 1.8034 m (parts ft+in) · "72 in to cm" → conversion, converted 182.88 cm · "60 miles an hour" → speed in m/s · "5 cubic feet" → volume in m³ · "approx. 5 kg" → approximate mass · "1m80" → 1.8 m · "1h30" → 5400 s · "2 lb 3 oz" → 0.9922 kg · "$5" → currency USD value/base 5 baseUnit USD + AMBIGUOUS_UNIT; pass `{currency:'CAD'}` to read bare "$" as CAD · "50 cents" → 0.5 USD + AMBIGUOUS_UNIT; pass `{currency:'EUR'}` to read as EUR · "five dollars and fifty cents" → 5.5 USD · "50p" → 0.5 GBP · "3 quid 50" → 3.5 GBP · "€5-€10" → currency range baseUnit EUR · "5 EUR to USD" → ok:false RATE_REQUIRED (use convertCurrency with injected rates) · "between 5 and 10 kg" → range 5..10 kg · "under 10 minutes" → range max 600 s exclusive · "no greater than 5 kg" → range max 5 kg inclusive · "10 ± 0.5 mm" → plusMinus center 10 mm/base 0.01 and delta 0.5 mm/base 0.0005 · "a few minutes" → range 120..240 s approximate · "it's hot" (kind temperature) → range 300.15..308.15 K fuzzy 'hot' · "1,5 kg" → 1.5 kg · "1,234" → 1234 + AMBIGUOUS_NUMBER (alt 1.234) · "5 meterz" (kind length) → 5 m + TYPO_CORRECTED; with strictness confirm → ok:false + candidate 5 m · "72" (kind length, unit cm, accept.bareNumbers false) → UNIT_REQUIRED + candidate 72 cm · "72 in to cm" with accept.conversions false → CONVERSION_NOT_ALLOWED + candidate conversion · "5m" (kind duration) → 300 s + SLANG_UNIT · "in 2d" → date two days from now · "3min from tmrw" → tomorrow, same time-of-day +3 min · "17h30" → 17:30 · "quarter past 5" → 05:15 · "3pm EST" → 15:00 civil + zone {abbrev, -300, ambiguous} + TZ_IGNORED/AMBIGUOUS_TIMEZONE; `{applyZone:true}` → the 20:00Z instant · "2pm to 4pm" → date-range 14:00..16:00 · "9-5" → date-range 09:00..17:00 (workday shift) · "500 KB" → 500000 B · "5 Mb" → 625000 B (megabits) · "5 Mbps" → data_rate 5000000 bit/s; use "bit/s" for bits per second because bare "bps" stays basis points · "5 gpm" → flow_rate 0.000315451 m³/s · "250 mL/min" → flow_rate 0.000004167 m³/s · "10 inH₂O" → pressure 2490.8891 Pa · "1 kgf/cm²" → pressure 98.0665 kPa · "1 kg/cm²" → ok:false TRAILING_INPUT (kilogram-mass over area deferred; use kgf/cm²) · "5 psig" (kind pressure) → ok:false UNKNOWN_UNIT (gauge semantics deferred) · "9.8 m/s²" → acceleration 9.8 m/s² · "10 Nm" → torque 10 N⋅m (exact-case; lowercase "nm" remains nanometers) · "500 lux" → illuminance 500 lx · "100 nits" → luminance 100 cd/m² · "20 mSv" → radiation equivalent dose 0.02 Sv · "5 MBq" → radioactivity 5000000 Bq · "5 uM" → concentration 0.005 mol/m³ · "1 mol/L" and "1 mol per L" → concentration 1000 mol/m³; untyped glued "1M" fails, use "1 M" or `kind:'concentration'` · "-40°F" → 233.15 K · "3×10⁵ m" → 300000 m · "½ cup" → 118.29 mL · "15%" → percent 15 · "25 bps" → 0.25% (basis points; bare bps stays percent) · "500 mAh" → charge 1800 C · "4.7 kohm" → resistance 4700 Ω · "250 mmol" → substance 0.25 mol.
342+
"2 ft" → quantity length base 0.6096 m · "5'11\"" → 1.8034 m (parts ft+in) · "72 in to cm" → conversion, converted 182.88 cm · "60 miles an hour" → speed in m/s · "5 cubic feet" → volume in m³ · "approx. 5 kg" → approximate mass · "1m80" → 1.8 m · "1h30" → 5400 s · "2 lb 3 oz" → 0.9922 kg · "$5" → currency USD value/base 5 baseUnit USD + AMBIGUOUS_UNIT; pass `{currency:'CAD'}` to read bare "$" as CAD · "50 cents" → 0.5 USD + AMBIGUOUS_UNIT; pass `{currency:'EUR'}` to read as EUR · "five dollars and fifty cents" → 5.5 USD · "50p" → 0.5 GBP · "3 quid 50" → 3.5 GBP · "€5-€10" → currency range baseUnit EUR · "5 EUR to USD" → ok:false RATE_REQUIRED (use convertCurrency with injected rates) · "between 5 and 10 kg" → range 5..10 kg · "under 10 minutes" → range max 600 s exclusive · "no greater than 5 kg" → range max 5 kg inclusive · "10 ± 0.5 mm" → plusMinus center 10 mm/base 0.01 and delta 0.5 mm/base 0.0005 · "a few minutes" → range 120..240 s approximate · "it's hot" (kind temperature) → range 300.15..308.15 K fuzzy 'hot' · "1,5 kg" → 1.5 kg · "1,234" → 1234 + AMBIGUOUS_NUMBER (alt 1.234) · "5 meterz" (kind length) → 5 m + TYPO_CORRECTED; with strictness confirm → ok:false + candidate 5 m · "72" (kind length, unit cm, accept.bareNumbers false) → UNIT_REQUIRED + candidate 72 cm · "72 in to cm" with accept.conversions false → CONVERSION_NOT_ALLOWED + candidate conversion · "5m" (kind duration) → 300 s + SLANG_UNIT · "in 2d" → date two days from now · "3min from tmrw" → tomorrow, same time-of-day +3 min · "17h30" → 17:30 · "quarter past 5" → 05:15 · "3pm EST" → 15:00 civil + zone {abbrev, -300, ambiguous} + TZ_IGNORED/AMBIGUOUS_TIMEZONE; `{applyZone:true}` → the 20:00Z instant · "2pm to 4pm" → date-range 14:00..16:00 · "9-5" → date-range 09:00..17:00 (workday shift) · "Aug 3 - Aug 9" → dated date-range 2026-08-03..2026-08-09 · "August" → dated date-range 2026-08-01..2026-08-31 (whole month) · "next week" → Mon..Sun · "this weekend" → Sat..Sun (the one in progress on Sat/Sun) · "2026-08-09 to 2026-08-03" → swapped 08-03..08-09 + RANGE_REVERSED · "Q3" → ok:false UNSUPPORTED_DATE (quarters need a fiscal-year anchor; not supported) · "500 KB" → 500000 B · "5 Mb" → 625000 B (megabits) · "5 Mbps" → data_rate 5000000 bit/s; use "bit/s" for bits per second because bare "bps" stays basis points · "5 gpm" → flow_rate 0.000315451 m³/s · "250 mL/min" → flow_rate 0.000004167 m³/s · "10 inH₂O" → pressure 2490.8891 Pa · "1 kgf/cm²" → pressure 98.0665 kPa · "1 kg/cm²" → ok:false TRAILING_INPUT (kilogram-mass over area deferred; use kgf/cm²) · "5 psig" (kind pressure) → ok:false UNKNOWN_UNIT (gauge semantics deferred) · "9.8 m/s²" → acceleration 9.8 m/s² · "10 Nm" → torque 10 N⋅m (exact-case; lowercase "nm" remains nanometers) · "500 lux" → illuminance 500 lx · "100 nits" → luminance 100 cd/m² · "20 mSv" → radiation equivalent dose 0.02 Sv · "5 MBq" → radioactivity 5000000 Bq · "5 uM" → concentration 0.005 mol/m³ · "1 mol/L" and "1 mol per L" → concentration 1000 mol/m³; untyped glued "1M" fails, use "1 M" or `kind:'concentration'` · "-40°F" → 233.15 K · "3×10⁵ m" → 300000 m · "½ cup" → 118.29 mL · "15%" → percent 15 · "25 bps" → 0.25% (basis points; bare bps stays percent) · "500 mAh" → charge 1800 C · "4.7 kohm" → resistance 4700 Ω · "250 mmol" → substance 0.25 mol.
335343

336344
## Docs (online)
337345

0 commit comments

Comments
 (0)