great-cto 2.5.0 → 2.5.1

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.
@@ -54,21 +54,46 @@ function* walk(root, exclude) {
54
54
  function fileMatchesGlobs(file, globs) {
55
55
  if (!globs || globs.length === 0)
56
56
  return true;
57
- // Tiny glob regex. Convert globs in two passes:
58
- // 1. Replace ** and * with sentinel placeholders.
59
- // 2. Escape remaining regex metachars.
60
- // 3. Replace placeholders with their regex equivalents.
57
+ // Normalize path separators for cross-platform matching
58
+ const normalized = file.replace(/\\/g, '/');
61
59
  return globs.some((g) => {
62
- const pattern = g
63
- .replace(/\*\*/g, '') // ** SOH
64
- .replace(/\*/g, '') // * → STX
65
- .replace(/\?/g, '') // ? → ETX
66
- .replace(/[.+^${}()|[\]\\]/g, '\\$&')
67
- .replace(//g, '.*')
68
- .replace(//g, '[^/]*')
69
- .replace(//g, '.');
60
+ // Token-based glob → regex conversion. Walks character-by-character to
61
+ // avoid the substitution-order pitfalls of multiple replace passes.
62
+ // Treats `**/` as "zero or more path segments" — so `**/*.ts` matches
63
+ // both `foo.ts` (root) and `src/lib/foo.ts` (nested).
64
+ let re = '';
65
+ for (let i = 0; i < g.length; i++) {
66
+ const c = g[i];
67
+ if (c === '*' && g[i + 1] === '*') {
68
+ // ** consumes the trailing /, so `**/x` becomes `(?:.*\/)?x` not `.*\/x`
69
+ if (g[i + 2] === '/') {
70
+ re += '(?:.*\\/)?';
71
+ i += 2;
72
+ }
73
+ else {
74
+ re += '.*';
75
+ i++;
76
+ }
77
+ }
78
+ else if (c === '*') {
79
+ re += '[^/]*';
80
+ }
81
+ else if (c === '?') {
82
+ re += '.';
83
+ }
84
+ else if ('.+^${}()|[]\\'.includes(c)) {
85
+ re += '\\' + c;
86
+ }
87
+ else if (c === '/') {
88
+ re += '/';
89
+ }
90
+ else {
91
+ re += c;
92
+ }
93
+ }
70
94
  try {
71
- return new RegExp(pattern).test(file);
95
+ // Match suffix — `src/foo.ts` matches `**/*.ts` regardless of cwd
96
+ return new RegExp('(?:^|/)' + re + '$').test(normalized);
72
97
  }
73
98
  catch {
74
99
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "great-cto",
3
- "version": "2.5.0",
3
+ "version": "2.5.1",
4
4
  "description": "One command install for the great_cto Claude Code plugin. Auto-detects your stack, picks the right archetype, bootstraps PROJECT.md.",
5
5
  "keywords": [
6
6
  "claude-code",