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.
| Location | Role today |
|---|---|
plugin/lib/intersect/index.ts | L1 public surface — throwing stubs. |
plugin/lib/intersect/segments/index.ts | The implemented L0 core this wraps. |
plugin/lib/intersect/fixtures/path.cases.json | Path-API spec, all pending. |
Proposed
Section titled “Proposed”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.
Approach
Section titled “Approach”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.- Coerce
Patterns(string | readonly string[]) toSegmentPattern[]viaparse. intersects(a, b, opts): true iff any parsed pattern ofacore-intersects any ofb.matches(path, patterns): parsepathand each pattern; true iff the core matches for any.whichMatch(path, patterns): the subset ofpatternsmatchingpath, in input order.overlapping(query, candidates): the subset ofcandidatesthat core-intersect any parsedquerypattern, in candidate order.witness(a, b): stringify the core witness back to a path (join segments with the separator);nullwhen none.compile(patterns, opts): parse once; return aMatcherwhose methods reuse the parsed set.- Flip
path.cases.json(and the string-level cases inoptions.cases.json) to active.
Files to touch
Section titled “Files to touch”| Location | Kind | Change |
|---|---|---|
plugin/lib/intersect/parse.ts | new | parse: path-like string → SegmentPattern. |
plugin/lib/intersect/index.ts | modify | Implement the path-API primitives + compile/Matcher. |
plugin/lib/intersect/fixtures/path.cases.json | modify | Activate. |
Acceptance criteria
Section titled “Acceptance criteria”- AC-1: All
path.cases.jsoncases pass;bun test plugin/lib/intersectis green. - AC-2:
intersects("src/siteA/components", "src/siteA/components")istrue;intersects("src/siteA/components", "src/siteA/components/x.vue")isfalse;intersects("src/siteA/components/**", "src/siteA/components/x.vue")istrue. - AC-3:
overlappingandwhichMatchpreserve the input order ofcandidates/patterns. - AC-4:
compile(p).matches(x) === matches(x, p)for every fixture input;bunx tsc --noEmitpasses.
Out of scope
Section titled “Out of scope”- The registry —
T-C4Q0; the filesystem layer —T-ZAZO. - Pattern-level negation and
intersection(a,b)— deferred perD-4FRD-intersect-api.
Dependencies
Section titled “Dependencies”- Requires the implemented segment core from
T-UY5H.
Discovery context
Section titled “Discovery context”- The
D-4FRD-intersect-apilayered-api.mdL1 section; minimalist path semantics (exact match unless**).
Depends on
Section titled “Depends on”T-UY5H