Skip to content

T-IRYT-intersect-path-api

Status: closed/done · Impact: high · Complexity: medium

Implement the friendly path API — parse (split path-like strings on the separator into SegmentPattern, verbatim) plus the string | string[]-aware intersects/matches/whichMatch/overlapping/witness/compile over the segment core — so the path-layer fixtures pass.

The path surface and its fixtures exist as stubs from T-FGMJ; the segment core it wraps is implemented by T-UY5H.

LocationRole today
plugin/lib/intersect/index.tsL1 public surface — throwing stubs.
plugin/lib/intersect/segments/index.tsThe implemented L0 core this wraps.
plugin/lib/intersect/fixtures/path.cases.jsonPath-API spec, all pending.

The path API is implemented. parse does no inference — a bare path is an exact match, a subtree is written explicitly as dir/**; every primitive accepts string | string[], normalizes to SegmentPattern[], and defers to the core; compile returns a reusable Matcher. Path fixtures are active and green.

  1. parse(pathLike, { separator = "/" }): split on the separator into segments; each segment is a verbatim glob token. No directory/file/ambiguity classification. A trailing separator (empty final segment) is normalized off.
  2. Coerce Patterns (string | readonly string[]) to SegmentPattern[] via parse.
  3. intersects(a, b, opts): true iff any parsed pattern of a core-intersects any of b.
  4. matches(path, patterns): parse path and each pattern; true iff the core matches for any.
  5. whichMatch(path, patterns): the subset of patterns matching path, in input order.
  6. overlapping(query, candidates): the subset of candidates that core-intersect any parsed query pattern, in candidate order.
  7. witness(a, b): stringify the core witness back to a path (join segments with the separator); null when none.
  8. compile(patterns, opts): parse once; return a Matcher whose methods reuse the parsed set.
  9. Flip path.cases.json (and the string-level cases in options.cases.json) to active.
LocationKindChange
plugin/lib/intersect/parse.tsnewparse: path-like string → SegmentPattern.
plugin/lib/intersect/index.tsmodifyImplement the path-API primitives + compile/Matcher.
plugin/lib/intersect/fixtures/path.cases.jsonmodifyActivate.
  • AC-1: All path.cases.json cases pass; bun test plugin/lib/intersect is green.
  • AC-2: intersects("src/siteA/components", "src/siteA/components") is true; intersects("src/siteA/components", "src/siteA/components/x.vue") is false; intersects("src/siteA/components/**", "src/siteA/components/x.vue") is true.
  • AC-3: overlapping and whichMatch preserve the input order of candidates/patterns.
  • AC-4: compile(p).matches(x) === matches(x, p) for every fixture input; bunx tsc --noEmit passes.
  • The registry — T-C4Q0; the filesystem layer — T-ZAZO.
  • Pattern-level negation and intersection(a,b) — deferred per D-4FRD-intersect-api.
  • Requires the implemented segment core from T-UY5H.
  • The D-4FRD-intersect-api layered-api.md L1 section; minimalist path semantics (exact match unless **).

T-UY5H


← Back to Tasks