dx: changelog, matching precedence fix, baseUrl normalization, README gaps, llms.txt#23
Merged
Merged
Conversation
…s, llms.txt - Add CHANGELOG.md (Keep-a-Changelog format; 0.9.0 = feature complete) - Fix response matching to specificity-first order: req-exact → cli-exact → req-class → cli-class - Fix baseUrl trailing-slash footgun: normalize in buildEffectiveUrl instead of requiring callers to do it - README: add Partial<Matcher> reusable handler fragments section - README: document Decode.optional() in Decode Factories quickstart - Add llms.txt for AI agent consumers; include in npm files array - Update SPEC.md: document new matching precedence and baseUrl normalization Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
DX-focused update that aligns runtime behavior and documentation with the library’s usability goals and docs/SPEC.md, specifically fixing response-matching precedence and removing a common baseUrl URL-resolution footgun.
Changes:
- Changed response matching to specificity-first (exact status beats class match regardless of layer), with updated unit tests + spec text.
- Normalized
baseUrlto always end with/during URL construction to preserve versioned path prefixes (e.g./v1), with new unit tests. - Expanded documentation (README + SPEC) and added distributable project metadata files (
CHANGELOG.md,llms.txt).
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/send.test.ts | Adds unit coverage for baseUrl trailing-slash normalization behavior. |
| tests/unit/response-matching.test.ts | Updates/expands tests to assert specificity-first matching precedence. |
| src/send.ts | Normalizes baseUrl by appending a trailing / before new URL(path, baseUrl). |
| src/response-matching.ts | Reorders lookup logic to exact-tier first, then class-tier (request wins ties within each tier). |
| README.md | Documents reusable Send.match handler fragments and Decode.optional() usage. |
| package.json | Ships llms.txt in the published package via files. |
| llms.txt | Adds an AI-assistant-oriented API/patterns reference document. |
| docs/SPEC.md | Updates matching precedence rules and documents baseUrl normalization semantics. |
| CHANGELOG.md | Introduces Keep-a-Changelog formatted changelog capturing these fixes/additions. |
…ard ref - src/send.ts: parse rawBase via new URL() before appending '/' to pathname, preventing corruption when baseUrl contains a query string or hash - README.md: declare result1 before sharedErrors so typeof result1 is in scope for the Partial<Matcher<>> type annotation Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DX improvements from a full usability assessment of the library for both human developers and AI agents.
Behavioral fixes
req-exact → cli-exact → req-class → cli-class. Previously a client-level exact match (e.g.200) could be beaten by a request-level class match (e.g.2xx), which was counterintuitive.baseUrltrailing-slash normalization —buildEffectiveUrlnow automatically appends a trailing/tobaseUrlif absent. Removes a silent footgun where"https://api.example.com/v1"would drop/v1from all constructed URLs.Documentation
README.md— added "Reusable handler fragments" section showingPartial<Matcher>spread +satisfiespattern (already designed in SPEC; just undocumented). Also documentedDecode.optional()in the Decode Factories quickstart.docs/SPEC.md— updated matching precedence section and added baseUrl normalization note.New files
CHANGELOG.md— Keep-a-Changelog format.[0.9.0]= feature complete.[Unreleased]= this PR's changes.llms.txt— structured AI agent context file (API reference, common patterns, common mistakes). Added topackage.jsonfilesso it ships with the npm package.Tests
All 184 tests pass across Node, Chromium, Firefox, and WebKit.