@pattern-algebra/core 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/README.md +571 -0
  2. package/dist/automaton/complement.d.ts +20 -0
  3. package/dist/automaton/complement.d.ts.map +1 -0
  4. package/dist/automaton/complement.js +36 -0
  5. package/dist/automaton/complement.js.map +1 -0
  6. package/dist/automaton/complement.test.d.ts +2 -0
  7. package/dist/automaton/complement.test.d.ts.map +1 -0
  8. package/dist/automaton/complement.test.js +114 -0
  9. package/dist/automaton/complement.test.js.map +1 -0
  10. package/dist/automaton/determinize.d.ts +41 -0
  11. package/dist/automaton/determinize.d.ts.map +1 -0
  12. package/dist/automaton/determinize.js +310 -0
  13. package/dist/automaton/determinize.js.map +1 -0
  14. package/dist/automaton/determinize.test.d.ts +2 -0
  15. package/dist/automaton/determinize.test.d.ts.map +1 -0
  16. package/dist/automaton/determinize.test.js +134 -0
  17. package/dist/automaton/determinize.test.js.map +1 -0
  18. package/dist/automaton/emptiness.d.ts +41 -0
  19. package/dist/automaton/emptiness.d.ts.map +1 -0
  20. package/dist/automaton/emptiness.js +262 -0
  21. package/dist/automaton/emptiness.js.map +1 -0
  22. package/dist/automaton/emptiness.test.d.ts +2 -0
  23. package/dist/automaton/emptiness.test.d.ts.map +1 -0
  24. package/dist/automaton/emptiness.test.js +154 -0
  25. package/dist/automaton/emptiness.test.js.map +1 -0
  26. package/dist/automaton/index.d.ts +10 -0
  27. package/dist/automaton/index.d.ts.map +1 -0
  28. package/dist/automaton/index.js +11 -0
  29. package/dist/automaton/index.js.map +1 -0
  30. package/dist/automaton/intersect.d.ts +35 -0
  31. package/dist/automaton/intersect.d.ts.map +1 -0
  32. package/dist/automaton/intersect.js +302 -0
  33. package/dist/automaton/intersect.js.map +1 -0
  34. package/dist/automaton/pattern-algebra.d.ts +62 -0
  35. package/dist/automaton/pattern-algebra.d.ts.map +1 -0
  36. package/dist/automaton/pattern-algebra.js +309 -0
  37. package/dist/automaton/pattern-algebra.js.map +1 -0
  38. package/dist/automaton/pattern-algebra.test.d.ts +2 -0
  39. package/dist/automaton/pattern-algebra.test.d.ts.map +1 -0
  40. package/dist/automaton/pattern-algebra.test.js +223 -0
  41. package/dist/automaton/pattern-algebra.test.js.map +1 -0
  42. package/dist/compile/automaton-builder.d.ts +47 -0
  43. package/dist/compile/automaton-builder.d.ts.map +1 -0
  44. package/dist/compile/automaton-builder.js +211 -0
  45. package/dist/compile/automaton-builder.js.map +1 -0
  46. package/dist/compile/compiler.d.ts +32 -0
  47. package/dist/compile/compiler.d.ts.map +1 -0
  48. package/dist/compile/compiler.js +47 -0
  49. package/dist/compile/compiler.js.map +1 -0
  50. package/dist/compile/index.d.ts +8 -0
  51. package/dist/compile/index.d.ts.map +1 -0
  52. package/dist/compile/index.js +8 -0
  53. package/dist/compile/index.js.map +1 -0
  54. package/dist/compile/quick-reject.d.ts +28 -0
  55. package/dist/compile/quick-reject.d.ts.map +1 -0
  56. package/dist/compile/quick-reject.js +147 -0
  57. package/dist/compile/quick-reject.js.map +1 -0
  58. package/dist/containment/analysis.d.ts +60 -0
  59. package/dist/containment/analysis.d.ts.map +1 -0
  60. package/dist/containment/analysis.js +378 -0
  61. package/dist/containment/analysis.js.map +1 -0
  62. package/dist/containment/containment.d.ts +23 -0
  63. package/dist/containment/containment.d.ts.map +1 -0
  64. package/dist/containment/containment.js +681 -0
  65. package/dist/containment/containment.js.map +1 -0
  66. package/dist/containment/containment.test.d.ts +2 -0
  67. package/dist/containment/containment.test.d.ts.map +1 -0
  68. package/dist/containment/containment.test.js +209 -0
  69. package/dist/containment/containment.test.js.map +1 -0
  70. package/dist/containment/index.d.ts +7 -0
  71. package/dist/containment/index.d.ts.map +1 -0
  72. package/dist/containment/index.js +7 -0
  73. package/dist/containment/index.js.map +1 -0
  74. package/dist/core-alpha.d.ts +1253 -0
  75. package/dist/core-beta.d.ts +1253 -0
  76. package/dist/core-public.d.ts +1253 -0
  77. package/dist/core-unstripped.d.ts +1253 -0
  78. package/dist/index.d.ts +32 -0
  79. package/dist/index.d.ts.map +1 -0
  80. package/dist/index.js +49 -0
  81. package/dist/index.js.map +1 -0
  82. package/dist/match/index.d.ts +8 -0
  83. package/dist/match/index.d.ts.map +1 -0
  84. package/dist/match/index.js +8 -0
  85. package/dist/match/index.js.map +1 -0
  86. package/dist/match/matcher.d.ts +40 -0
  87. package/dist/match/matcher.d.ts.map +1 -0
  88. package/dist/match/matcher.js +256 -0
  89. package/dist/match/matcher.js.map +1 -0
  90. package/dist/match/matcher.test.d.ts +2 -0
  91. package/dist/match/matcher.test.d.ts.map +1 -0
  92. package/dist/match/matcher.test.js +185 -0
  93. package/dist/match/matcher.test.js.map +1 -0
  94. package/dist/match/path-utils.d.ts +132 -0
  95. package/dist/match/path-utils.d.ts.map +1 -0
  96. package/dist/match/path-utils.js +223 -0
  97. package/dist/match/path-utils.js.map +1 -0
  98. package/dist/match/path-utils.test.d.ts +2 -0
  99. package/dist/match/path-utils.test.d.ts.map +1 -0
  100. package/dist/match/path-utils.test.js +193 -0
  101. package/dist/match/path-utils.test.js.map +1 -0
  102. package/dist/match/segment-matcher.d.ts +25 -0
  103. package/dist/match/segment-matcher.d.ts.map +1 -0
  104. package/dist/match/segment-matcher.js +267 -0
  105. package/dist/match/segment-matcher.js.map +1 -0
  106. package/dist/parse/brace-expansion.d.ts +34 -0
  107. package/dist/parse/brace-expansion.d.ts.map +1 -0
  108. package/dist/parse/brace-expansion.js +294 -0
  109. package/dist/parse/brace-expansion.js.map +1 -0
  110. package/dist/parse/brace-expansion.test.d.ts +2 -0
  111. package/dist/parse/brace-expansion.test.d.ts.map +1 -0
  112. package/dist/parse/brace-expansion.test.js +105 -0
  113. package/dist/parse/brace-expansion.test.js.map +1 -0
  114. package/dist/parse/index.d.ts +8 -0
  115. package/dist/parse/index.d.ts.map +1 -0
  116. package/dist/parse/index.js +8 -0
  117. package/dist/parse/index.js.map +1 -0
  118. package/dist/parse/parser.d.ts +15 -0
  119. package/dist/parse/parser.d.ts.map +1 -0
  120. package/dist/parse/parser.js +526 -0
  121. package/dist/parse/parser.js.map +1 -0
  122. package/dist/parse/parser.test.d.ts +2 -0
  123. package/dist/parse/parser.test.d.ts.map +1 -0
  124. package/dist/parse/parser.test.js +266 -0
  125. package/dist/parse/parser.test.js.map +1 -0
  126. package/dist/parse/validator.d.ts +30 -0
  127. package/dist/parse/validator.d.ts.map +1 -0
  128. package/dist/parse/validator.js +115 -0
  129. package/dist/parse/validator.js.map +1 -0
  130. package/dist/parse/validator.test.d.ts +2 -0
  131. package/dist/parse/validator.test.d.ts.map +1 -0
  132. package/dist/parse/validator.test.js +45 -0
  133. package/dist/parse/validator.test.js.map +1 -0
  134. package/dist/types/ast.d.ts +158 -0
  135. package/dist/types/ast.d.ts.map +1 -0
  136. package/dist/types/ast.js +2 -0
  137. package/dist/types/ast.js.map +1 -0
  138. package/dist/types/automaton.d.ts +150 -0
  139. package/dist/types/automaton.d.ts.map +1 -0
  140. package/dist/types/automaton.js +2 -0
  141. package/dist/types/automaton.js.map +1 -0
  142. package/dist/types/containment.d.ts +257 -0
  143. package/dist/types/containment.d.ts.map +1 -0
  144. package/dist/types/containment.js +5 -0
  145. package/dist/types/containment.js.map +1 -0
  146. package/dist/types/errors.d.ts +37 -0
  147. package/dist/types/errors.d.ts.map +1 -0
  148. package/dist/types/errors.js +24 -0
  149. package/dist/types/errors.js.map +1 -0
  150. package/dist/types/index.d.ts +10 -0
  151. package/dist/types/index.d.ts.map +1 -0
  152. package/dist/types/index.js +6 -0
  153. package/dist/types/index.js.map +1 -0
  154. package/package.json +48 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/compile/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjG,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Quick-reject filter construction.
3
+ * @packageDocumentation
4
+ */
5
+ import type { PathPattern, QuickRejectFilter } from '../types';
6
+ /**
7
+ * Build quick-reject filters for a pattern.
8
+ *
9
+ * Quick-reject filters enable fast elimination of non-matching paths
10
+ * before full automaton simulation.
11
+ *
12
+ * @param pattern - Pattern AST
13
+ * @returns Quick-reject filter configuration
14
+ *
15
+ * @public
16
+ */
17
+ export declare function buildQuickRejectFilter(pattern: PathPattern): QuickRejectFilter;
18
+ /**
19
+ * Apply quick-reject filter to a path.
20
+ *
21
+ * @param path - Normalized path to check
22
+ * @param filter - Quick-reject filter
23
+ * @returns false if path definitely doesn't match, true if it might match
24
+ *
25
+ * @public
26
+ */
27
+ export declare function applyQuickReject(path: string, filter: QuickRejectFilter): boolean;
28
+ //# sourceMappingURL=quick-reject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quick-reject.d.ts","sourceRoot":"","sources":["../../src/compile/quick-reject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAA4B,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAExF;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,WAAW,GAAG,iBAAiB,CAO9E;AAqGD;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,GAAG,OAAO,CA2BjF"}
@@ -0,0 +1,147 @@
1
+ /**
2
+ * Quick-reject filter construction.
3
+ * @packageDocumentation
4
+ */
5
+ /**
6
+ * Build quick-reject filters for a pattern.
7
+ *
8
+ * Quick-reject filters enable fast elimination of non-matching paths
9
+ * before full automaton simulation.
10
+ *
11
+ * @param pattern - Pattern AST
12
+ * @returns Quick-reject filter configuration
13
+ *
14
+ * @public
15
+ */
16
+ export function buildQuickRejectFilter(pattern) {
17
+ // Extract from sequence (alternations are more complex)
18
+ if (pattern.root.type === 'sequence') {
19
+ return extractSequenceFilters(pattern.root);
20
+ }
21
+ return {};
22
+ }
23
+ /**
24
+ * Extract filters from a segment sequence.
25
+ */
26
+ function extractSequenceFilters(sequence) {
27
+ const segments = sequence.segments;
28
+ // Required prefix: leading literal segments before any wildcard
29
+ const prefixParts = [];
30
+ for (const segment of segments) {
31
+ if (segment.type === 'literal') {
32
+ prefixParts.push(segment.value);
33
+ }
34
+ else {
35
+ break;
36
+ }
37
+ }
38
+ const requiredPrefix = prefixParts.length > 0 ? '/' + prefixParts.join('/') : undefined;
39
+ // Required suffix: trailing literal segments after last wildcard
40
+ const suffixParts = [];
41
+ for (let i = segments.length - 1; i >= 0; i--) {
42
+ const segment = segments[i];
43
+ if (segment.type === 'literal') {
44
+ suffixParts.unshift(segment.value);
45
+ }
46
+ else {
47
+ break;
48
+ }
49
+ }
50
+ // Only use suffix if it doesn't overlap with prefix
51
+ const requiredSuffix = suffixParts.length > 0 && suffixParts.length < segments.length ? '/' + suffixParts.join('/') : undefined;
52
+ // Required literals: any literal segment that must appear
53
+ const literals = [];
54
+ for (const segment of segments) {
55
+ if (segment.type === 'literal') {
56
+ literals.push(segment.value);
57
+ }
58
+ }
59
+ const requiredLiterals = literals.length > 0 ? literals : undefined;
60
+ // Minimum length: sum of minimum segment lengths
61
+ let minLengthValue = 0;
62
+ for (const segment of segments) {
63
+ minLengthValue += getSegmentMinLength(segment);
64
+ minLengthValue += 1; // For the separator (/)
65
+ }
66
+ const minLength = minLengthValue > 1 ? minLengthValue : undefined;
67
+ return {
68
+ requiredPrefix,
69
+ requiredSuffix,
70
+ requiredLiterals,
71
+ minLength,
72
+ };
73
+ }
74
+ /**
75
+ * Get minimum character length for a segment.
76
+ */
77
+ function getSegmentMinLength(segment) {
78
+ switch (segment.type) {
79
+ case 'literal':
80
+ return segment.value.length;
81
+ case 'globstar':
82
+ return 0; // Globstar can match zero characters
83
+ case 'wildcard': {
84
+ // Count required characters
85
+ let min = 0;
86
+ for (const part of segment.parts) {
87
+ if (part.type === 'literal') {
88
+ min += part.value.length;
89
+ }
90
+ else if (part.type === 'question') {
91
+ min += 1;
92
+ }
93
+ // star contributes 0
94
+ }
95
+ return min;
96
+ }
97
+ case 'charclass':
98
+ return 1; // Single character
99
+ case 'composite': {
100
+ let min = 0;
101
+ for (const part of segment.parts) {
102
+ if (part.type === 'literal') {
103
+ min += part.value.length;
104
+ }
105
+ else if (part.type === 'question' || part.type === 'charclass') {
106
+ min += 1;
107
+ }
108
+ // star contributes 0
109
+ }
110
+ return min;
111
+ }
112
+ }
113
+ }
114
+ /**
115
+ * Apply quick-reject filter to a path.
116
+ *
117
+ * @param path - Normalized path to check
118
+ * @param filter - Quick-reject filter
119
+ * @returns false if path definitely doesn't match, true if it might match
120
+ *
121
+ * @public
122
+ */
123
+ export function applyQuickReject(path, filter) {
124
+ // Check minimum length
125
+ if (filter.minLength !== undefined && path.length < filter.minLength) {
126
+ return false;
127
+ }
128
+ // Check required prefix
129
+ if (filter.requiredPrefix !== undefined && !path.startsWith(filter.requiredPrefix)) {
130
+ return false;
131
+ }
132
+ // Check required suffix
133
+ if (filter.requiredSuffix !== undefined && !path.endsWith(filter.requiredSuffix)) {
134
+ return false;
135
+ }
136
+ // Check required literals (must appear as segments)
137
+ if (filter.requiredLiterals !== undefined) {
138
+ const segments = path.split('/');
139
+ for (const required of filter.requiredLiterals) {
140
+ if (!segments.includes(required)) {
141
+ return false;
142
+ }
143
+ }
144
+ }
145
+ return true;
146
+ }
147
+ //# sourceMappingURL=quick-reject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quick-reject.js","sourceRoot":"","sources":["../../src/compile/quick-reject.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;;;;;;;;;GAUG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAoB;IACzD,wDAAwD;I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,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC;QACjF,OAAO,KAAK,CAAA;IACd,CAAC;IAED,oDAAoD;IACpD,IAAI,MAAM,CAAC,gBAAgB,KAAK,SAAS,EAAE,CAAC;QAC1C,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAChC,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,gBAAgB,EAAE,CAAC;YAC/C,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACjC,OAAO,KAAK,CAAA;YACd,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Pattern analysis utilities.
3
+ * @packageDocumentation
4
+ */
5
+ import type { CompiledPattern, PatternAnalysis, PatternRelationship } from '../types';
6
+ /**
7
+ * Analyze the relationship between two patterns in detail.
8
+ *
9
+ * Provides comprehensive information about how patterns relate,
10
+ * including the intersection and set differences.
11
+ *
12
+ * @param a - First compiled pattern
13
+ * @param b - Second compiled pattern
14
+ * @returns Full analysis of pattern relationship
15
+ *
16
+ * @public
17
+ */
18
+ export declare function analyzePatterns(a: CompiledPattern, b: CompiledPattern): PatternAnalysis;
19
+ /**
20
+ * Determine if two patterns are equivalent (match the same set of paths).
21
+ *
22
+ * @param a - First pattern
23
+ * @param b - Second pattern
24
+ * @returns true if patterns are equivalent
25
+ *
26
+ * @public
27
+ */
28
+ export declare function areEquivalent(a: CompiledPattern, b: CompiledPattern): boolean;
29
+ /**
30
+ * Determine if two patterns have any overlap.
31
+ *
32
+ * @param a - First pattern
33
+ * @param b - Second pattern
34
+ * @returns true if there exists a path matching both patterns
35
+ *
36
+ * @public
37
+ */
38
+ export declare function hasOverlap(a: CompiledPattern, b: CompiledPattern): boolean;
39
+ /**
40
+ * Determine if two patterns are disjoint (no common paths).
41
+ *
42
+ * @param a - First pattern
43
+ * @param b - Second pattern
44
+ * @returns true if patterns have no paths in common
45
+ *
46
+ * @public
47
+ */
48
+ export declare function areDisjoint(a: CompiledPattern, b: CompiledPattern): boolean;
49
+ /**
50
+ * Get a human-readable summary of the relationship between patterns.
51
+ *
52
+ * @param relationship - The pattern relationship
53
+ * @param patternA - Source of pattern A
54
+ * @param patternB - Source of pattern B
55
+ * @returns Human-readable description
56
+ *
57
+ * @public
58
+ */
59
+ export declare function summarizeRelationship(relationship: PatternRelationship, patternA: string, patternB: string): string;
60
+ //# sourceMappingURL=analysis.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analysis.d.ts","sourceRoot":"","sources":["../../src/containment/analysis.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EAEf,mBAAmB,EAGpB,MAAM,UAAU,CAAA;AAIjB;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,eAAe,EAAE,CAAC,EAAE,eAAe,GAAG,eAAe,CAgBvF;AAuHD;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,eAAe,EAAE,CAAC,EAAE,eAAe,GAAG,OAAO,CAG7E;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,eAAe,EAAE,CAAC,EAAE,eAAe,GAAG,OAAO,CA0B1E;AAmED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,eAAe,EAAE,CAAC,EAAE,eAAe,GAAG,OAAO,CAE3E;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAiBnH"}
@@ -0,0 +1,378 @@
1
+ /**
2
+ * Pattern analysis utilities.
3
+ * @packageDocumentation
4
+ */
5
+ import { checkContainment } from './containment';
6
+ import { matchPath } from '../match/matcher';
7
+ /**
8
+ * Analyze the relationship between two patterns in detail.
9
+ *
10
+ * Provides comprehensive information about how patterns relate,
11
+ * including the intersection and set differences.
12
+ *
13
+ * @param a - First compiled pattern
14
+ * @param b - Second compiled pattern
15
+ * @returns Full analysis of pattern relationship
16
+ *
17
+ * @public
18
+ */
19
+ export function analyzePatterns(a, b) {
20
+ const containment = checkContainment(a, b);
21
+ const intersection = describeIntersection(a, b);
22
+ const aMinusB = describeSetDifference(a, b, 'A-B');
23
+ const bMinusA = describeSetDifference(a, b, 'B-A');
24
+ return {
25
+ patternA: a.source,
26
+ patternB: b.source,
27
+ relationship: containment.relationship,
28
+ containment,
29
+ intersection,
30
+ aMinusB,
31
+ bMinusA,
32
+ };
33
+ }
34
+ /**
35
+ * Describe the intersection of two patterns.
36
+ */
37
+ function describeIntersection(a, b) {
38
+ // Generate test paths from both patterns and find common matches
39
+ const examples = [];
40
+ const aPaths = generateTestPaths(a, 15);
41
+ const bPaths = generateTestPaths(b, 15);
42
+ // Check A paths that also match B
43
+ for (const path of aPaths) {
44
+ if (matchPath(path, b) && !examples.includes(path)) {
45
+ examples.push(path);
46
+ if (examples.length >= 3)
47
+ break;
48
+ }
49
+ }
50
+ // Check B paths that also match A
51
+ for (const path of bPaths) {
52
+ if (matchPath(path, a) && !examples.includes(path)) {
53
+ examples.push(path);
54
+ if (examples.length >= 3)
55
+ break;
56
+ }
57
+ }
58
+ // Try combined paths if no overlap found yet
59
+ if (examples.length === 0) {
60
+ const combinedPaths = generateCombinedPaths(a, b, 15);
61
+ for (const path of combinedPaths) {
62
+ if (matchPath(path, a) && matchPath(path, b) && !examples.includes(path)) {
63
+ examples.push(path);
64
+ if (examples.length >= 3)
65
+ break;
66
+ }
67
+ }
68
+ }
69
+ if (examples.length === 0) {
70
+ return {
71
+ isEmpty: true,
72
+ description: 'The patterns have no paths in common',
73
+ };
74
+ }
75
+ // Try to describe the intersection pattern
76
+ const pattern = describeIntersectionPattern(a, b);
77
+ return {
78
+ isEmpty: false,
79
+ examples,
80
+ pattern,
81
+ description: pattern
82
+ ? `Paths matching both patterns: ${pattern}`
83
+ : `Paths that match both "${a.source}" and "${b.source}"`,
84
+ };
85
+ }
86
+ /**
87
+ * Describe the set difference between patterns.
88
+ */
89
+ function describeSetDifference(a, b, direction) {
90
+ const [first, second] = direction === 'A-B' ? [a, b] : [b, a];
91
+ // Generate paths from the first pattern that don't match the second
92
+ const examples = [];
93
+ const firstPaths = generateTestPaths(first, 20);
94
+ for (const path of firstPaths) {
95
+ if (!matchPath(path, second) && !examples.includes(path)) {
96
+ examples.push(path);
97
+ if (examples.length >= 3)
98
+ break;
99
+ }
100
+ }
101
+ if (examples.length === 0) {
102
+ return {
103
+ isEmpty: true,
104
+ description: direction === 'A-B'
105
+ ? `All paths matching "${a.source}" also match "${b.source}"`
106
+ : `All paths matching "${b.source}" also match "${a.source}"`,
107
+ };
108
+ }
109
+ return {
110
+ isEmpty: false,
111
+ examples,
112
+ description: direction === 'A-B'
113
+ ? `Paths matching "${a.source}" but not "${b.source}"`
114
+ : `Paths matching "${b.source}" but not "${a.source}"`,
115
+ };
116
+ }
117
+ /**
118
+ * Try to describe the intersection as a pattern.
119
+ */
120
+ function describeIntersectionPattern(a, b) {
121
+ // Special cases where we can compute an explicit pattern
122
+ // If one is a subset of the other, the intersection is the smaller one
123
+ const aPrefix = a.quickReject.requiredPrefix;
124
+ const bPrefix = b.quickReject.requiredPrefix;
125
+ if (aPrefix && bPrefix) {
126
+ // Both have prefixes - intersection might be expressible
127
+ if (aPrefix.startsWith(bPrefix)) {
128
+ return a.source; // A is more specific
129
+ }
130
+ if (bPrefix.startsWith(aPrefix)) {
131
+ return b.source; // B is more specific
132
+ }
133
+ }
134
+ // For simple cases, return undefined (too complex to express)
135
+ return undefined;
136
+ }
137
+ /**
138
+ * Determine if two patterns are equivalent (match the same set of paths).
139
+ *
140
+ * @param a - First pattern
141
+ * @param b - Second pattern
142
+ * @returns true if patterns are equivalent
143
+ *
144
+ * @public
145
+ */
146
+ export function areEquivalent(a, b) {
147
+ const result = checkContainment(a, b);
148
+ return result.isEqual;
149
+ }
150
+ /**
151
+ * Determine if two patterns have any overlap.
152
+ *
153
+ * @param a - First pattern
154
+ * @param b - Second pattern
155
+ * @returns true if there exists a path matching both patterns
156
+ *
157
+ * @public
158
+ */
159
+ export function hasOverlap(a, b) {
160
+ // Generate paths from A and check if any match B
161
+ const aPaths = generateTestPaths(a, 15);
162
+ for (const path of aPaths) {
163
+ if (matchPath(path, b)) {
164
+ return true;
165
+ }
166
+ }
167
+ // Generate paths from B and check if any match A
168
+ const bPaths = generateTestPaths(b, 15);
169
+ for (const path of bPaths) {
170
+ if (matchPath(path, a)) {
171
+ return true;
172
+ }
173
+ }
174
+ // Try to generate paths that combine constraints from both patterns
175
+ const combinedPaths = generateCombinedPaths(a, b, 15);
176
+ for (const path of combinedPaths) {
177
+ if (matchPath(path, a) && matchPath(path, b)) {
178
+ return true;
179
+ }
180
+ }
181
+ return false;
182
+ }
183
+ /**
184
+ * Generate paths that might match both patterns by combining their constraints.
185
+ */
186
+ function generateCombinedPaths(a, b, count) {
187
+ const paths = [];
188
+ // Extract constraints from both patterns, removing leading slashes
189
+ const aPrefix = a.quickReject.requiredPrefix?.replace(/^\//, '') ?? '';
190
+ const bPrefix = b.quickReject.requiredPrefix?.replace(/^\//, '') ?? '';
191
+ const aSuffix = a.quickReject.requiredSuffix?.replace(/^\//, '') ?? '';
192
+ const bSuffix = b.quickReject.requiredSuffix?.replace(/^\//, '') ?? '';
193
+ // Extract file extensions and base names from suffixes
194
+ const extractFileInfo = (suffix) => {
195
+ if (!suffix)
196
+ return { basename: '', ext: '' };
197
+ const lastDot = suffix.lastIndexOf('.');
198
+ if (lastDot > 0) {
199
+ return { basename: suffix.slice(0, lastDot), ext: suffix.slice(lastDot) };
200
+ }
201
+ return { basename: suffix, ext: '' };
202
+ };
203
+ // Build candidate paths
204
+ const prefixes = [aPrefix, bPrefix].filter(Boolean);
205
+ if (prefixes.length === 0)
206
+ prefixes.push('');
207
+ // If we have suffixes like "index.ts", extract the components
208
+ const suffixInfoA = extractFileInfo(aSuffix);
209
+ const suffixInfoB = extractFileInfo(bSuffix);
210
+ // File basenames to try
211
+ const basenames = [suffixInfoA.basename || 'index', suffixInfoB.basename || 'index', 'file', 'test'].filter(Boolean);
212
+ // Extensions to try
213
+ const extensions = [suffixInfoA.ext, suffixInfoB.ext, '.ts', '.js'].filter(Boolean);
214
+ for (const prefix of prefixes) {
215
+ for (const basename of basenames) {
216
+ for (const ext of extensions) {
217
+ // Build path: /prefix/basename.ext
218
+ const filename = basename + ext;
219
+ const path = prefix ? `/${prefix}/${filename}` : `/${filename}`;
220
+ if (!paths.includes(path)) {
221
+ paths.push(path);
222
+ }
223
+ // Also try with subdirectory
224
+ if (prefix) {
225
+ const deepPath = `/${prefix}/sub/${filename}`;
226
+ if (!paths.includes(deepPath)) {
227
+ paths.push(deepPath);
228
+ }
229
+ }
230
+ if (paths.length >= count)
231
+ break;
232
+ }
233
+ if (paths.length >= count)
234
+ break;
235
+ }
236
+ if (paths.length >= count)
237
+ break;
238
+ }
239
+ return paths.slice(0, count);
240
+ }
241
+ /**
242
+ * Determine if two patterns are disjoint (no common paths).
243
+ *
244
+ * @param a - First pattern
245
+ * @param b - Second pattern
246
+ * @returns true if patterns have no paths in common
247
+ *
248
+ * @public
249
+ */
250
+ export function areDisjoint(a, b) {
251
+ return !hasOverlap(a, b);
252
+ }
253
+ /**
254
+ * Get a human-readable summary of the relationship between patterns.
255
+ *
256
+ * @param relationship - The pattern relationship
257
+ * @param patternA - Source of pattern A
258
+ * @param patternB - Source of pattern B
259
+ * @returns Human-readable description
260
+ *
261
+ * @public
262
+ */
263
+ export function summarizeRelationship(relationship, patternA, patternB) {
264
+ switch (relationship) {
265
+ case 'equal':
266
+ return `"${patternA}" and "${patternB}" match exactly the same paths`;
267
+ case 'subset':
268
+ return `"${patternA}" is contained within "${patternB}" (every path matching A also matches B)`;
269
+ case 'superset':
270
+ return `"${patternA}" contains "${patternB}" (every path matching B also matches A)`;
271
+ case 'overlapping':
272
+ return `"${patternA}" and "${patternB}" have some paths in common, but neither contains the other`;
273
+ case 'disjoint':
274
+ return `"${patternA}" and "${patternB}" have no paths in common`;
275
+ }
276
+ }
277
+ /**
278
+ * Generate test paths that match a pattern.
279
+ */
280
+ function generateTestPaths(pattern, count) {
281
+ const paths = [];
282
+ const ast = pattern.ast;
283
+ if (ast.root.type === 'alternation') {
284
+ // Generate paths for each branch
285
+ for (const branch of ast.root.branches) {
286
+ paths.push(...generatePathsFromSequence(branch, Math.ceil(count / ast.root.branches.length)));
287
+ }
288
+ }
289
+ else {
290
+ paths.push(...generatePathsFromSequence(ast.root, count));
291
+ }
292
+ return paths.slice(0, count);
293
+ }
294
+ /**
295
+ * Generate paths from a segment sequence.
296
+ */
297
+ function generatePathsFromSequence(sequence, count) {
298
+ const paths = [];
299
+ // Generate base path
300
+ const basePath = generateBasePath(sequence.segments);
301
+ paths.push(basePath);
302
+ // Generate variations
303
+ for (let i = 1; i < count && paths.length < count; i++) {
304
+ const variation = generatePathVariation(sequence.segments, i);
305
+ if (variation && !paths.includes(variation)) {
306
+ paths.push(variation);
307
+ }
308
+ }
309
+ return paths;
310
+ }
311
+ /**
312
+ * Generate a base path from segments.
313
+ */
314
+ function generateBasePath(segments) {
315
+ const parts = [];
316
+ for (const segment of segments) {
317
+ parts.push(generateSegmentValue(segment, 0));
318
+ }
319
+ return '/' + parts.join('/');
320
+ }
321
+ /**
322
+ * Generate a path variation.
323
+ */
324
+ function generatePathVariation(segments, variationIndex) {
325
+ const parts = [];
326
+ let usedVariation = false;
327
+ for (let i = 0; i < segments.length; i++) {
328
+ const segment = segments[i];
329
+ if (segment.type === 'globstar' && !usedVariation) {
330
+ // For globstar, always add at least one segment (globstar requires at least 1)
331
+ // Then optionally add more based on variation
332
+ const extraCount = 1 + (variationIndex % 3);
333
+ for (let j = 0; j < extraCount; j++) {
334
+ parts.push(`dir${j}`);
335
+ }
336
+ usedVariation = true;
337
+ }
338
+ else {
339
+ parts.push(generateSegmentValue(segment, usedVariation ? 0 : variationIndex));
340
+ }
341
+ }
342
+ return '/' + parts.join('/');
343
+ }
344
+ /**
345
+ * Generate a value that matches a segment pattern.
346
+ */
347
+ function generateSegmentValue(segment, variation) {
348
+ switch (segment.type) {
349
+ case 'literal':
350
+ return segment.value;
351
+ case 'globstar':
352
+ return 'subdir';
353
+ case 'wildcard': {
354
+ // Generate based on pattern
355
+ const pattern = segment.pattern;
356
+ if (pattern.endsWith('.ts')) {
357
+ return `file${variation}.ts`;
358
+ }
359
+ if (pattern.endsWith('.js')) {
360
+ return `file${variation}.js`;
361
+ }
362
+ if (pattern.startsWith('test-')) {
363
+ return `test-${variation}`;
364
+ }
365
+ return `match${variation}`;
366
+ }
367
+ case 'charclass':
368
+ // Pick a character from the class
369
+ if (segment.ranges.length > 0) {
370
+ const range = segment.ranges[0];
371
+ return range.start;
372
+ }
373
+ return segment.chars[0] || 'x';
374
+ case 'composite':
375
+ return `composite${variation}`;
376
+ }
377
+ }
378
+ //# sourceMappingURL=analysis.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analysis.js","sourceRoot":"","sources":["../../src/containment/analysis.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAE5C;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,eAAe,CAAC,CAAkB,EAAE,CAAkB;IACpE,MAAM,WAAW,GAAG,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IAE1C,MAAM,YAAY,GAAG,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IAC/C,MAAM,OAAO,GAAG,qBAAqB,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAA;IAClD,MAAM,OAAO,GAAG,qBAAqB,CAAC,CAAC,EAAE,CAAC,EAAE,K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OAAO,CAAA;YAC/B,IAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC5B,OAAO,OAAO,SAAS,KAAK,CAAA;YAC9B,CAAC;YACD,IAAI,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC5B,OAAO,OAAO,SAAS,KAAK,CAAA;YAC9B,CAAC;YACD,IAAI,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;gBAChC,OAAO,QAAQ,SAAS,EAAE,CAAA;YAC5B,CAAC;YACD,OAAO,QAAQ,SAAS,EAAE,CAAA;QAC5B,CAAC;QAED,KAAK,WAAW;YACd,kCAAkC;YAClC,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC9B,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;gBAC/B,OAAO,KAAK,CAAC,KAAK,CAAA;YACpB,CAAC;YACD,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,GAAG,CAAA;QAEhC,KAAK,WAAW;YACd,OAAO,YAAY,SAAS,EAAE,CAAA;IAClC,CAAC;AACH,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Pattern containment checking.
3
+ * @packageDocumentation
4
+ */
5
+ import type { CompiledPattern, ContainmentResult } from '../types';
6
+ /**
7
+ * Check if pattern A is contained within pattern B.
8
+ *
9
+ * A ⊆ B means: every path that matches A also matches B.
10
+ *
11
+ * Uses a hybrid approach:
12
+ * 1. Structural analysis for quick checks
13
+ * 2. Sample-based testing for validation
14
+ * 3. Automaton operations for complex cases (when available)
15
+ *
16
+ * @param a - First compiled pattern
17
+ * @param b - Second compiled pattern
18
+ * @returns Containment result with explanation data
19
+ *
20
+ * @public
21
+ */
22
+ export declare function checkContainment(a: CompiledPattern, b: CompiledPattern): ContainmentResult;
23
+ //# sourceMappingURL=containment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"containment.d.ts","sourceRoot":"","sources":["../../src/containment/containment.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,iBAAiB,EAYlB,MAAM,UAAU,CAAA;AAGjB;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,eAAe,EAAE,CAAC,EAAE,eAAe,GAAG,iBAAiB,CAmC1F"}