@gobing-ai/ts-rule-engine 0.3.16 → 0.3.17

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.
@@ -64,7 +64,20 @@ export declare function scanFiles(options: ScanFilesOptions): Promise<ScannedFil
64
64
  export declare function relativeToWorkdir(workdir: string, path: string): string;
65
65
  /** Return parent directory for a workdir-relative path. */
66
66
  export declare function relativeParent(path: string): string;
67
- /** Return true when a path matches any supplied fragment or suffix. */
67
+ /**
68
+ * Return true when a path matches any supplied pattern.
69
+ *
70
+ * Each pattern is matched in two passes, most-specific first:
71
+ * 1. If it contains a glob metachar (`*`), try anchored {@link matchesGlob} —
72
+ * so `packages/**\/*.ts` resolves segment-by-segment instead of collapsing
73
+ * to a bare fragment (the latter silently matched nothing, leaving every
74
+ * glob-scoped loose-mode rule scanning zero files).
75
+ * 2. Otherwise (or if the glob did not match), fall back to the legacy
76
+ * fragment/suffix substring test, where stars are stripped — preserving
77
+ * bare fragments like `.ts`, `src/`, `/tests/` that loose-mode evaluators
78
+ * have always accepted, and keeping unanchored patterns like `*.ts`
79
+ * (→ suffix `.ts`) matching nested paths.
80
+ */
68
81
  export declare function matchesAny(path: string, patterns: string[] | undefined): boolean;
69
82
  /**
70
83
  * Segment-aware glob matching with `**` (any depth) and `*` (single segment).
@@ -1 +1 @@
1
- {"version":3,"file":"file-utils.d.ts","sourceRoot":"","sources":["../../src/evaluators/file-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,KAAK,gBAAgB,IAAI,UAAU,EACnC,cAAc,EAIjB,MAAM,uBAAuB,CAAC;AAE/B,yCAAyC;AACzC,MAAM,WAAW,sBAAsB;IACnC,yBAAyB;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,0CAA0C;IAC1C,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,8BAA8B;IAC9B,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,0BAA0B;IAC1B,EAAE,CA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MAAM,CAGnG;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAKhF"}
@@ -55,13 +55,30 @@ export function relativeParent(path) {
55
55
  const parent = dirnamePath(path);
56
56
  return parent === '.' ? '' : parent;
57
57
  }
58
- /** Return true when a path matches any supplied fragment or suffix. */
58
+ /**
59
+ * Return true when a path matches any supplied pattern.
60
+ *
61
+ * Each pattern is matched in two passes, most-specific first:
62
+ * 1. If it contains a glob metachar (`*`), try anchored {@link matchesGlob} —
63
+ * so `packages/**\/*.ts` resolves segment-by-segment instead of collapsing
64
+ * to a bare fragment (the latter silently matched nothing, leaving every
65
+ * glob-scoped loose-mode rule scanning zero files).
66
+ * 2. Otherwise (or if the glob did not match), fall back to the legacy
67
+ * fragment/suffix substring test, where stars are stripped — preserving
68
+ * bare fragments like `.ts`, `src/`, `/tests/` that loose-mode evaluators
69
+ * have always accepted, and keeping unanchored patterns like `*.ts`
70
+ * (→ suffix `.ts`) matching nested paths.
71
+ */
59
72
  export function matchesAny(path, patterns) {
60
73
  if (patterns === undefined || patterns.length === 0)
61
74
  return true;
75
+ const normalizedPath = path.replaceAll('\\', '/');
62
76
  return patterns.some((pattern) => {
63
- const clean = pattern.replaceAll('\\', '/').replaceAll('**/', '').replaceAll('*', '');
64
- return clean.length === 0 || path.includes(clean) || path.endsWith(clean);
77
+ const normalized = pattern.replaceAll('\\', '/');
78
+ if (normalized.includes('*') && matchesGlob(normalizedPath, normalized))
79
+ return true;
80
+ const clean = normalized.replaceAll('**/', '').replaceAll('*', '');
81
+ return clean.length === 0 || normalizedPath.includes(clean) || normalizedPath.endsWith(clean);
65
82
  });
66
83
  }
67
84
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gobing-ai/ts-rule-engine",
3
- "version": "0.3.16",
3
+ "version": "0.3.17",
4
4
  "description": "@gobing-ai/ts-rule-engine — Constraint rule schemas, loading, evaluation, and result formatting.",
5
5
  "keywords": [
6
6
  "typescript",
@@ -49,10 +49,10 @@
49
49
  "release": "echo 'Manual publish is disabled. Releases go through GitHub Actions via Trusted Publishing — push a tag: git tag @gobing-ai/ts-rule-engine-v<version> && git push --tags' && exit 1"
50
50
  },
51
51
  "dependencies": {
52
- "@gobing-ai/ts-ai-runner": "^0.3.16",
53
- "@gobing-ai/ts-infra": "^0.3.16",
54
- "@gobing-ai/ts-runtime": "^0.3.16",
55
- "@gobing-ai/ts-db": "^0.3.16",
52
+ "@gobing-ai/ts-ai-runner": "^0.3.17",
53
+ "@gobing-ai/ts-infra": "^0.3.17",
54
+ "@gobing-ai/ts-runtime": "^0.3.17",
55
+ "@gobing-ai/ts-db": "^0.3.17",
56
56
  "yaml": "^2.7.0",
57
57
  "zod": "^4.1.0"
58
58
  },
@@ -124,12 +124,28 @@ export function relativeParent(path: string): string {
124
124
  return parent === '.' ? '' : parent;
125
125
  }
126
126
 
127
- /** Return true when a path matches any supplied fragment or suffix. */
127
+ /**
128
+ * Return true when a path matches any supplied pattern.
129
+ *
130
+ * Each pattern is matched in two passes, most-specific first:
131
+ * 1. If it contains a glob metachar (`*`), try anchored {@link matchesGlob} —
132
+ * so `packages/**\/*.ts` resolves segment-by-segment instead of collapsing
133
+ * to a bare fragment (the latter silently matched nothing, leaving every
134
+ * glob-scoped loose-mode rule scanning zero files).
135
+ * 2. Otherwise (or if the glob did not match), fall back to the legacy
136
+ * fragment/suffix substring test, where stars are stripped — preserving
137
+ * bare fragments like `.ts`, `src/`, `/tests/` that loose-mode evaluators
138
+ * have always accepted, and keeping unanchored patterns like `*.ts`
139
+ * (→ suffix `.ts`) matching nested paths.
140
+ */
128
141
  export function matchesAny(path: string, patterns: string[] | undefined): boolean {
129
142
  if (patterns === undefined || patterns.length === 0) return true;
143
+ const normalizedPath = path.replaceAll('\\', '/');
130
144
  return patterns.some((pattern) => {
131
- const clean = pattern.replaceAll('\\', '/').replaceAll('**/', '').replaceAll('*', '');
132
- return clean.length === 0 || path.includes(clean) || path.endsWith(clean);
145
+ const normalized = pattern.replaceAll('\\', '/');
146
+ if (normalized.includes('*') && matchesGlob(normalizedPath, normalized)) return true;
147
+ const clean = normalized.replaceAll('**/', '').replaceAll('*', '');
148
+ return clean.length === 0 || normalizedPath.includes(clean) || normalizedPath.endsWith(clean);
133
149
  });
134
150
  }
135
151