Skip to content

Bounded redirect quick path for agents (refs #383) - #386

Merged
jimhoyd merged 1 commit into
mainfrom
docs/redirect-quick-path-383
Sep 21, 2026
Merged

jimhoyd merged 1 commit into
mainfrom
docs/redirect-quick-path-383

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 21, 2026

Copy link
Copy Markdown
Collaborator

Refs #383. Not merging this PR — leaving it open for review.

Support matrix established by running validate/test/audit (not assumed)

Shape Supported? Exact YAML / error
Fixed redirect (status 301/302/303/307/308, 302 default) Yes redirect: {url, status}
Parameterized path (/users/:id -> /profiles/:id) Yes {id} placeholder in redirect.url, naming a declared path parameter
Fixed-depth suffix (/legacy/a/b -> /modern/a/b) Yes, one route per depth one {param} per segment
Query-string preservation Yes, opt-in only redirect.query.pass (explicit allowlist) / query.map
Method-preserving redirect Yes methods + status: 307/308
404 for unmatched paths Yes site.notFound (shipped in 0.4.7, not 0.4.6) or the runtime default
Wildcard/suffix (/legacy/* -> /modern/*, any depth) No redirect: {url: "https://.../*"} -> "Only static or extension routes support a terminal /* wildcard"; {rest...} -> "Invalid route parameter"
Host/scheme/relative destination No /relative, //host/x -> "Redirect URL must be absolute HTTP(S)"; {host} placeholder -> "Redirect placeholders are allowed only in path segments"

@jimhoyd/urlcode published versions: 0.4.1, 0.4.2, 0.4.6, 0.4.7. site.notFound shipped in 0.4.7 (commit f01baec, issue #316) — not present in 0.4.6, the version the benchmark agent used, so its declarative-404 gap report for 0.4.6 was accurate for that revision.

What shipped

  1. urlcode context --project DIR --task redirects (MCP get_context {"task":"redirects"}): one bounded call returning every shape above with exact YAML or exact error, the tested workaround for the two gaps, this project's own redirects, and the usual validate/test/audit commands. Same budget-dropping mechanics as the existing buildContext/--budget.
  2. llms.txt: new early "Building only redirects? Start here" section pointing at the task context and the matrix.
  3. docs/AI-AUTHORING.md: redirect rows added at the opening of the "Built-in features by task" table, each mapping a need to exact YAML, with the two gaps marked and linked to docs/OPEN-DECISIONS.md.
  4. recipes/redirect: extended (not duplicated) to a runnable project covering fixed, parameterized-path, query-preserving and default-404 shapes in one urlcode.yaml, with fixtures for every shape plus HEAD/405 coverage. urlcode recipes search redirect still finds it first.
  5. docs/OPEN-DECISIONS.md: concrete proposed YAML for a wildcard-suffix redirect (/** + {**} capture) with ordering/security notes (open-redirect risk stays closed because the destination host is still a literal), and an explanation of why host/scheme redirects are a deliberate refusal rather than a gap to close casually.

Token comparison (context --task redirects vs whole-project context)

Measured via urlcode context --project recipes/redirect --stats (characters/4 estimate, same estimator as the existing --stats):

  • Whole-project urlcode context: ~1094 tokens for this 2-route project.
  • urlcode context --task redirects (guidance + this project's redirects + commands): ~1249 tokens — the extra cost is the fixed shape catalog (9 shapes with exact YAML), which is what replaces reading docs/RECIPES catalogs/package inspection; a --budget still bounds it (e.g. --budget 400 drops to guidance-only in ~25 tokens).
  • Whole documentation bundle (llms-full.txt) for comparison: ~57,809 tokens.

Package entry count

npm run audit:packages: core package (@jimhoyd/urlcode) is 430 files against the unchanged 440-entry cap. Cap not raised.

Open decisions (not implemented here, need a maintainer decision)

Verification

npm run verify (lint, typecheck, check:code, check:docs, build, full test suite including the new test/context-task.test.ts, workspace verify, audit:packages) passes end to end. npm run docs:llms regenerated llms-full.txt.

🤖 Generated with Claude Code

Establishes and proves the current redirect support matrix by running
`urlcode validate`/`test`/`audit` against fixed, parameterized-path,
fixed-depth-suffix, query-preserving, method-preserving and 404 shapes
(all supported), and against wildcard-suffix/`{rest...}` and
host/scheme/relative destinations (both refused, with their exact
validation errors).

- `urlcode context --task redirects` / MCP `get_context {"task":"redirects"}`:
  one bounded call returning every shape's support, exact YAML or exact
  error, the tested workaround for gaps, and this project's own redirects.
  Same budget-dropping mechanics as the existing `buildContext`.
- Early "Building only redirects? Start here" section in llms.txt, and a
  redirect-first block at the top of docs/AI-AUTHORING.md's built-in
  features table, both pointing at the new task-scoped context.
- Extended the existing `redirect` recipe (not duplicated) to cover fixed,
  parameterized-path, query-preserving and default-404 shapes in one
  runnable project, with fixtures for every one plus HEAD/405 coverage.
- docs/OPEN-DECISIONS.md: concrete proposals for wildcard-suffix redirects
  (with security/ordering notes) and why host/scheme redirects are a
  deliberate refusal, not a gap to close casually.

Verified: `npm run verify` (lint, typecheck, check:code, check:docs,
build, full test suite, workspace verify, audit:packages) passes.
Core package: 430 files against the 440-entry cap (unchanged cap).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@jimhoyd
jimhoyd force-pushed the docs/redirect-quick-path-383 branch from 5d25d79 to 2052289 Compare September 21, 2026 15:22
@jimhoyd
jimhoyd merged commit fcbc9c5 into main Sep 21, 2026
20 checks passed
@jimhoyd
jimhoyd deleted the docs/redirect-quick-path-383 branch September 21, 2026 15:30
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