Skip to content

dx: changelog, matching precedence fix, baseUrl normalization, README gaps, llms.txt#23

Merged
sethlivingston merged 2 commits into
mainfrom
agents/usability-assessment-devx-library
May 19, 2026
Merged

dx: changelog, matching precedence fix, baseUrl normalization, README gaps, llms.txt#23
sethlivingston merged 2 commits into
mainfrom
agents/usability-assessment-devx-library

Conversation

@sethlivingston
Copy link
Copy Markdown
Owner

Summary

DX improvements from a full usability assessment of the library for both human developers and AI agents.

Behavioral fixes

  • Response matching precedence — changed from layer-first to specificity-first: 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.
  • baseUrl trailing-slash normalizationbuildEffectiveUrl now automatically appends a trailing / to baseUrl if absent. Removes a silent footgun where "https://api.example.com/v1" would drop /v1 from all constructed URLs.

Documentation

  • README.md — added "Reusable handler fragments" section showing Partial<Matcher> spread + satisfies pattern (already designed in SPEC; just undocumented). Also documented Decode.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 to package.json files so it ships with the npm package.

Tests

All 184 tests pass across Node, Chromium, Firefox, and WebKit.

…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>
Copilot AI review requested due to automatic review settings May 19, 2026 13:02
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 baseUrl to 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.

Comment thread src/send.ts Outdated
Comment thread README.md
…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>
@sethlivingston sethlivingston merged commit bf69f6c into main May 19, 2026
5 checks passed
@sethlivingston sethlivingston deleted the agents/usability-assessment-devx-library branch May 19, 2026 13:16
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.

2 participants