@introspection-ai/recipes 0.38.0 → 0.39.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 (58) hide show
  1. package/README.md +5 -2
  2. package/dist/child/session.d.ts +2 -0
  3. package/dist/child/session.d.ts.map +1 -1
  4. package/dist/child/session.js +3 -0
  5. package/dist/child/session.js.map +1 -1
  6. package/dist/connector-tools.d.ts +4 -0
  7. package/dist/connector-tools.d.ts.map +1 -1
  8. package/dist/connector-tools.js.map +1 -1
  9. package/dist/documents/index.d.ts +3 -1
  10. package/dist/documents/index.d.ts.map +1 -1
  11. package/dist/documents/index.js +1 -0
  12. package/dist/documents/index.js.map +1 -1
  13. package/dist/documents/module.d.ts +17 -8
  14. package/dist/documents/module.d.ts.map +1 -1
  15. package/dist/documents/module.js +2 -1
  16. package/dist/documents/module.js.map +1 -1
  17. package/dist/documents/python.d.ts +30 -0
  18. package/dist/documents/python.d.ts.map +1 -0
  19. package/dist/documents/python.js +64 -0
  20. package/dist/documents/python.js.map +1 -0
  21. package/dist/extensions.d.ts +16 -0
  22. package/dist/extensions.d.ts.map +1 -1
  23. package/dist/extensions.js +12 -0
  24. package/dist/extensions.js.map +1 -1
  25. package/dist/mcp-chunks/{chunk-EQCSXVQ7.js → chunk-ZK2E4S7E.js} +2035 -165
  26. package/dist/mcp-daemon.js +1 -1
  27. package/dist/mcp-run-worker.js +1 -1
  28. package/dist/pi-extension.d.ts.map +1 -1
  29. package/dist/pi-extension.js +89 -14
  30. package/dist/pi-extension.js.map +1 -1
  31. package/dist/python.d.ts +56 -0
  32. package/dist/python.d.ts.map +1 -0
  33. package/dist/python.js +100 -0
  34. package/dist/python.js.map +1 -0
  35. package/dist/recipe/package.d.ts +14 -0
  36. package/dist/recipe/package.d.ts.map +1 -1
  37. package/dist/recipe/package.js +87 -0
  38. package/dist/recipe/package.js.map +1 -1
  39. package/dist/recipe/python.d.ts +141 -0
  40. package/dist/recipe/python.d.ts.map +1 -0
  41. package/dist/recipe/python.js +698 -0
  42. package/dist/recipe/python.js.map +1 -0
  43. package/dist/recipe/resolve.d.ts +3 -0
  44. package/dist/recipe/resolve.d.ts.map +1 -1
  45. package/dist/recipe/resolve.js +2 -0
  46. package/dist/recipe/resolve.js.map +1 -1
  47. package/dist/run-controller.d.ts +2 -0
  48. package/dist/run-controller.d.ts.map +1 -1
  49. package/dist/run-controller.js +3 -0
  50. package/dist/run-controller.js.map +1 -1
  51. package/dist/session.d.ts +8 -0
  52. package/dist/session.d.ts.map +1 -1
  53. package/dist/session.js +37 -15
  54. package/dist/session.js.map +1 -1
  55. package/docs/documents.md +39 -17
  56. package/docs/pi-extension.md +4 -1
  57. package/docs/recipe-format.md +99 -4
  58. package/package.json +10 -5
@@ -89,17 +89,17 @@ var require_visit = __commonJS({
89
89
  visit.BREAK = BREAK;
90
90
  visit.SKIP = SKIP;
91
91
  visit.REMOVE = REMOVE;
92
- function visit_(key, node, visitor, path) {
93
- const ctrl = callVisitor(key, node, visitor, path);
92
+ function visit_(key, node, visitor, path2) {
93
+ const ctrl = callVisitor(key, node, visitor, path2);
94
94
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
95
- replaceNode(key, path, ctrl);
96
- return visit_(key, ctrl, visitor, path);
95
+ replaceNode(key, path2, ctrl);
96
+ return visit_(key, ctrl, visitor, path2);
97
97
  }
98
98
  if (typeof ctrl !== "symbol") {
99
99
  if (identity.isCollection(node)) {
100
- path = Object.freeze(path.concat(node));
100
+ path2 = Object.freeze(path2.concat(node));
101
101
  for (let i = 0; i < node.items.length; ++i) {
102
- const ci = visit_(i, node.items[i], visitor, path);
102
+ const ci = visit_(i, node.items[i], visitor, path2);
103
103
  if (typeof ci === "number")
104
104
  i = ci - 1;
105
105
  else if (ci === BREAK)
@@ -110,13 +110,13 @@ var require_visit = __commonJS({
110
110
  }
111
111
  }
112
112
  } else if (identity.isPair(node)) {
113
- path = Object.freeze(path.concat(node));
114
- const ck = visit_("key", node.key, visitor, path);
113
+ path2 = Object.freeze(path2.concat(node));
114
+ const ck = visit_("key", node.key, visitor, path2);
115
115
  if (ck === BREAK)
116
116
  return BREAK;
117
117
  else if (ck === REMOVE)
118
118
  node.key = null;
119
- const cv = visit_("value", node.value, visitor, path);
119
+ const cv = visit_("value", node.value, visitor, path2);
120
120
  if (cv === BREAK)
121
121
  return BREAK;
122
122
  else if (cv === REMOVE)
@@ -137,17 +137,17 @@ var require_visit = __commonJS({
137
137
  visitAsync.BREAK = BREAK;
138
138
  visitAsync.SKIP = SKIP;
139
139
  visitAsync.REMOVE = REMOVE;
140
- async function visitAsync_(key, node, visitor, path) {
141
- const ctrl = await callVisitor(key, node, visitor, path);
140
+ async function visitAsync_(key, node, visitor, path2) {
141
+ const ctrl = await callVisitor(key, node, visitor, path2);
142
142
  if (identity.isNode(ctrl) || identity.isPair(ctrl)) {
143
- replaceNode(key, path, ctrl);
144
- return visitAsync_(key, ctrl, visitor, path);
143
+ replaceNode(key, path2, ctrl);
144
+ return visitAsync_(key, ctrl, visitor, path2);
145
145
  }
146
146
  if (typeof ctrl !== "symbol") {
147
147
  if (identity.isCollection(node)) {
148
- path = Object.freeze(path.concat(node));
148
+ path2 = Object.freeze(path2.concat(node));
149
149
  for (let i = 0; i < node.items.length; ++i) {
150
- const ci = await visitAsync_(i, node.items[i], visitor, path);
150
+ const ci = await visitAsync_(i, node.items[i], visitor, path2);
151
151
  if (typeof ci === "number")
152
152
  i = ci - 1;
153
153
  else if (ci === BREAK)
@@ -158,13 +158,13 @@ var require_visit = __commonJS({
158
158
  }
159
159
  }
160
160
  } else if (identity.isPair(node)) {
161
- path = Object.freeze(path.concat(node));
162
- const ck = await visitAsync_("key", node.key, visitor, path);
161
+ path2 = Object.freeze(path2.concat(node));
162
+ const ck = await visitAsync_("key", node.key, visitor, path2);
163
163
  if (ck === BREAK)
164
164
  return BREAK;
165
165
  else if (ck === REMOVE)
166
166
  node.key = null;
167
- const cv = await visitAsync_("value", node.value, visitor, path);
167
+ const cv = await visitAsync_("value", node.value, visitor, path2);
168
168
  if (cv === BREAK)
169
169
  return BREAK;
170
170
  else if (cv === REMOVE)
@@ -191,23 +191,23 @@ var require_visit = __commonJS({
191
191
  }
192
192
  return visitor;
193
193
  }
194
- function callVisitor(key, node, visitor, path) {
194
+ function callVisitor(key, node, visitor, path2) {
195
195
  if (typeof visitor === "function")
196
- return visitor(key, node, path);
196
+ return visitor(key, node, path2);
197
197
  if (identity.isMap(node))
198
- return visitor.Map?.(key, node, path);
198
+ return visitor.Map?.(key, node, path2);
199
199
  if (identity.isSeq(node))
200
- return visitor.Seq?.(key, node, path);
200
+ return visitor.Seq?.(key, node, path2);
201
201
  if (identity.isPair(node))
202
- return visitor.Pair?.(key, node, path);
202
+ return visitor.Pair?.(key, node, path2);
203
203
  if (identity.isScalar(node))
204
- return visitor.Scalar?.(key, node, path);
204
+ return visitor.Scalar?.(key, node, path2);
205
205
  if (identity.isAlias(node))
206
- return visitor.Alias?.(key, node, path);
206
+ return visitor.Alias?.(key, node, path2);
207
207
  return void 0;
208
208
  }
209
- function replaceNode(key, path, node) {
210
- const parent = path[path.length - 1];
209
+ function replaceNode(key, path2, node) {
210
+ const parent = path2[path2.length - 1];
211
211
  if (identity.isCollection(parent)) {
212
212
  parent.items[key] = node;
213
213
  } else if (identity.isPair(parent)) {
@@ -747,8 +747,8 @@ var require_createNode = __commonJS({
747
747
  var defaultTagPrefix = "tag:yaml.org,2002:";
748
748
  function findTagObject(value, tagName, tags) {
749
749
  if (tagName) {
750
- const match = tags.filter((t) => t.tag === tagName);
751
- const tagObj = match.find((t) => !t.format) ?? match[0];
750
+ const match2 = tags.filter((t) => t.tag === tagName);
751
+ const tagObj = match2.find((t) => !t.format) ?? match2[0];
752
752
  if (!tagObj)
753
753
  throw new Error(`Tag ${tagName} not found`);
754
754
  return tagObj;
@@ -819,10 +819,10 @@ var require_Collection = __commonJS({
819
819
  var createNode = require_createNode();
820
820
  var identity = require_identity();
821
821
  var Node = require_Node();
822
- function collectionFromPath(schema, path, value) {
822
+ function collectionFromPath(schema, path2, value) {
823
823
  let v = value;
824
- for (let i = path.length - 1; i >= 0; --i) {
825
- const k = path[i];
824
+ for (let i = path2.length - 1; i >= 0; --i) {
825
+ const k = path2[i];
826
826
  if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
827
827
  const a = [];
828
828
  a[k] = v;
@@ -841,7 +841,7 @@ var require_Collection = __commonJS({
841
841
  sourceObjects: /* @__PURE__ */ new Map()
842
842
  });
843
843
  }
844
- var isEmptyPath = (path) => path == null || typeof path === "object" && !!path[Symbol.iterator]().next().done;
844
+ var isEmptyPath = (path2) => path2 == null || typeof path2 === "object" && !!path2[Symbol.iterator]().next().done;
845
845
  var Collection = class extends Node.NodeBase {
846
846
  constructor(type, schema) {
847
847
  super(type);
@@ -871,11 +871,11 @@ var require_Collection = __commonJS({
871
871
  * be a Pair instance or a `{ key, value }` object, which may not have a key
872
872
  * that already exists in the map.
873
873
  */
874
- addIn(path, value) {
875
- if (isEmptyPath(path))
874
+ addIn(path2, value) {
875
+ if (isEmptyPath(path2))
876
876
  this.add(value);
877
877
  else {
878
- const [key, ...rest] = path;
878
+ const [key, ...rest] = path2;
879
879
  const node = this.get(key, true);
880
880
  if (identity.isCollection(node))
881
881
  node.addIn(rest, value);
@@ -889,8 +889,8 @@ var require_Collection = __commonJS({
889
889
  * Removes a value from the collection.
890
890
  * @returns `true` if the item was found and removed.
891
891
  */
892
- deleteIn(path) {
893
- const [key, ...rest] = path;
892
+ deleteIn(path2) {
893
+ const [key, ...rest] = path2;
894
894
  if (rest.length === 0)
895
895
  return this.delete(key);
896
896
  const node = this.get(key, true);
@@ -904,8 +904,8 @@ var require_Collection = __commonJS({
904
904
  * scalar values from their surrounding node; to disable set `keepScalar` to
905
905
  * `true` (collections are always returned intact).
906
906
  */
907
- getIn(path, keepScalar) {
908
- const [key, ...rest] = path;
907
+ getIn(path2, keepScalar) {
908
+ const [key, ...rest] = path2;
909
909
  const node = this.get(key, true);
910
910
  if (rest.length === 0)
911
911
  return !keepScalar && identity.isScalar(node) ? node.value : node;
@@ -923,8 +923,8 @@ var require_Collection = __commonJS({
923
923
  /**
924
924
  * Checks if the collection includes a value with the key `key`.
925
925
  */
926
- hasIn(path) {
927
- const [key, ...rest] = path;
926
+ hasIn(path2) {
927
+ const [key, ...rest] = path2;
928
928
  if (rest.length === 0)
929
929
  return this.has(key);
930
930
  const node = this.get(key, true);
@@ -934,8 +934,8 @@ var require_Collection = __commonJS({
934
934
  * Sets a value in this collection. For `!!set`, `value` needs to be a
935
935
  * boolean to add/remove the item from the set.
936
936
  */
937
- setIn(path, value) {
938
- const [key, ...rest] = path;
937
+ setIn(path2, value) {
938
+ const [key, ...rest] = path2;
939
939
  if (rest.length === 0) {
940
940
  this.set(key, value);
941
941
  } else {
@@ -1443,21 +1443,21 @@ var require_stringify = __commonJS({
1443
1443
  }
1444
1444
  function getTagObject(tags, item) {
1445
1445
  if (item.tag) {
1446
- const match = tags.filter((t) => t.tag === item.tag);
1447
- if (match.length > 0)
1448
- return match.find((t) => t.format === item.format) ?? match[0];
1446
+ const match2 = tags.filter((t) => t.tag === item.tag);
1447
+ if (match2.length > 0)
1448
+ return match2.find((t) => t.format === item.format) ?? match2[0];
1449
1449
  }
1450
1450
  let tagObj = void 0;
1451
1451
  let obj;
1452
1452
  if (identity.isScalar(item)) {
1453
1453
  obj = item.value;
1454
- let match = tags.filter((t) => t.identify?.(obj));
1455
- if (match.length > 1) {
1456
- const testMatch = match.filter((t) => t.test);
1454
+ let match2 = tags.filter((t) => t.identify?.(obj));
1455
+ if (match2.length > 1) {
1456
+ const testMatch = match2.filter((t) => t.test);
1457
1457
  if (testMatch.length > 0)
1458
- match = testMatch;
1458
+ match2 = testMatch;
1459
1459
  }
1460
- tagObj = match.find((t) => t.format === item.format) ?? match.find((t) => !t.format);
1460
+ tagObj = match2.find((t) => t.format === item.format) ?? match2.find((t) => !t.format);
1461
1461
  } else {
1462
1462
  obj = item;
1463
1463
  tagObj = tags.find((t) => t.nodeClass && obj instanceof t.nodeClass);
@@ -3099,13 +3099,13 @@ var require_timestamp = __commonJS({
3099
3099
  // assumed to be 00:00:00Z (start of day, UTC).
3100
3100
  test: RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),
3101
3101
  resolve(str) {
3102
- const match = str.match(timestamp.test);
3103
- if (!match)
3102
+ const match2 = str.match(timestamp.test);
3103
+ if (!match2)
3104
3104
  throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");
3105
- const [, year, month, day, hour, minute, second] = match.map(Number);
3106
- const millisec = match[7] ? Number((match[7] + "00").substr(1, 3)) : 0;
3105
+ const [, year, month, day, hour, minute, second] = match2.map(Number);
3106
+ const millisec = match2[7] ? Number((match2[7] + "00").substr(1, 3)) : 0;
3107
3107
  let date = Date.UTC(year, month - 1, day, hour || 0, minute || 0, second || 0, millisec);
3108
- const tz = match[8];
3108
+ const tz = match2[8];
3109
3109
  if (tz && tz !== "Z") {
3110
3110
  let d = parseSexagesimal(tz, false);
3111
3111
  if (Math.abs(d) < 30)
@@ -3450,9 +3450,9 @@ var require_Document = __commonJS({
3450
3450
  this.contents.add(value);
3451
3451
  }
3452
3452
  /** Adds a value to the document. */
3453
- addIn(path, value) {
3453
+ addIn(path2, value) {
3454
3454
  if (assertCollection(this.contents))
3455
- this.contents.addIn(path, value);
3455
+ this.contents.addIn(path2, value);
3456
3456
  }
3457
3457
  /**
3458
3458
  * Create a new `Alias` node, ensuring that the target `node` has the required anchor.
@@ -3527,14 +3527,14 @@ var require_Document = __commonJS({
3527
3527
  * Removes a value from the document.
3528
3528
  * @returns `true` if the item was found and removed.
3529
3529
  */
3530
- deleteIn(path) {
3531
- if (Collection.isEmptyPath(path)) {
3530
+ deleteIn(path2) {
3531
+ if (Collection.isEmptyPath(path2)) {
3532
3532
  if (this.contents == null)
3533
3533
  return false;
3534
3534
  this.contents = null;
3535
3535
  return true;
3536
3536
  }
3537
- return assertCollection(this.contents) ? this.contents.deleteIn(path) : false;
3537
+ return assertCollection(this.contents) ? this.contents.deleteIn(path2) : false;
3538
3538
  }
3539
3539
  /**
3540
3540
  * Returns item at `key`, or `undefined` if not found. By default unwraps
@@ -3549,10 +3549,10 @@ var require_Document = __commonJS({
3549
3549
  * scalar values from their surrounding node; to disable set `keepScalar` to
3550
3550
  * `true` (collections are always returned intact).
3551
3551
  */
3552
- getIn(path, keepScalar) {
3553
- if (Collection.isEmptyPath(path))
3552
+ getIn(path2, keepScalar) {
3553
+ if (Collection.isEmptyPath(path2))
3554
3554
  return !keepScalar && identity.isScalar(this.contents) ? this.contents.value : this.contents;
3555
- return identity.isCollection(this.contents) ? this.contents.getIn(path, keepScalar) : void 0;
3555
+ return identity.isCollection(this.contents) ? this.contents.getIn(path2, keepScalar) : void 0;
3556
3556
  }
3557
3557
  /**
3558
3558
  * Checks if the document includes a value with the key `key`.
@@ -3563,10 +3563,10 @@ var require_Document = __commonJS({
3563
3563
  /**
3564
3564
  * Checks if the document includes a value at `path`.
3565
3565
  */
3566
- hasIn(path) {
3567
- if (Collection.isEmptyPath(path))
3566
+ hasIn(path2) {
3567
+ if (Collection.isEmptyPath(path2))
3568
3568
  return this.contents !== void 0;
3569
- return identity.isCollection(this.contents) ? this.contents.hasIn(path) : false;
3569
+ return identity.isCollection(this.contents) ? this.contents.hasIn(path2) : false;
3570
3570
  }
3571
3571
  /**
3572
3572
  * Sets a value in this document. For `!!set`, `value` needs to be a
@@ -3583,13 +3583,13 @@ var require_Document = __commonJS({
3583
3583
  * Sets a value in this document. For `!!set`, `value` needs to be a
3584
3584
  * boolean to add/remove the item from the set.
3585
3585
  */
3586
- setIn(path, value) {
3587
- if (Collection.isEmptyPath(path)) {
3586
+ setIn(path2, value) {
3587
+ if (Collection.isEmptyPath(path2)) {
3588
3588
  this.contents = value;
3589
3589
  } else if (this.contents == null) {
3590
- this.contents = Collection.collectionFromPath(this.schema, Array.from(path), value);
3590
+ this.contents = Collection.collectionFromPath(this.schema, Array.from(path2), value);
3591
3591
  } else if (assertCollection(this.contents)) {
3592
- this.contents.setIn(path, value);
3592
+ this.contents.setIn(path2, value);
3593
3593
  }
3594
3594
  }
3595
3595
  /**
@@ -3975,10 +3975,10 @@ var require_resolve_block_map = __commonJS({
3975
3975
  let offset = bm.offset;
3976
3976
  let commentEnd = null;
3977
3977
  for (const collItem of bm.items) {
3978
- const { start, key, sep, value } = collItem;
3978
+ const { start, key, sep: sep2, value } = collItem;
3979
3979
  const keyProps = resolveProps.resolveProps(start, {
3980
3980
  indicator: "explicit-key-ind",
3981
- next: key ?? sep?.[0],
3981
+ next: key ?? sep2?.[0],
3982
3982
  offset,
3983
3983
  onError,
3984
3984
  parentIndent: bm.indent,
@@ -3992,7 +3992,7 @@ var require_resolve_block_map = __commonJS({
3992
3992
  else if ("indent" in key && key.indent !== bm.indent)
3993
3993
  onError(offset, "BAD_INDENT", startColMsg);
3994
3994
  }
3995
- if (!keyProps.anchor && !keyProps.tag && !sep) {
3995
+ if (!keyProps.anchor && !keyProps.tag && !sep2) {
3996
3996
  commentEnd = keyProps.end;
3997
3997
  if (keyProps.comment) {
3998
3998
  if (map.comment)
@@ -4016,7 +4016,7 @@ var require_resolve_block_map = __commonJS({
4016
4016
  ctx.atKey = false;
4017
4017
  if (utilMapIncludes.mapIncludes(ctx, map.items, keyNode))
4018
4018
  onError(keyStart, "DUPLICATE_KEY", "Map keys must be unique");
4019
- const valueProps = resolveProps.resolveProps(sep ?? [], {
4019
+ const valueProps = resolveProps.resolveProps(sep2 ?? [], {
4020
4020
  indicator: "map-value-ind",
4021
4021
  next: value,
4022
4022
  offset: keyNode.range[2],
@@ -4032,7 +4032,7 @@ var require_resolve_block_map = __commonJS({
4032
4032
  if (ctx.options.strict && keyProps.start < valueProps.found.offset - 1024)
4033
4033
  onError(keyNode.range, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit block mapping key");
4034
4034
  }
4035
- const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep, null, valueProps, onError);
4035
+ const valueNode = value ? composeNode(ctx, value, valueProps, onError) : composeEmptyNode(ctx, offset, sep2, null, valueProps, onError);
4036
4036
  if (ctx.schema.compat)
4037
4037
  utilFlowIndentCheck.flowIndentCheck(bm.indent, value, onError);
4038
4038
  offset = valueNode.range[2];
@@ -4123,7 +4123,7 @@ var require_resolve_end = __commonJS({
4123
4123
  let comment = "";
4124
4124
  if (end) {
4125
4125
  let hasSpace = false;
4126
- let sep = "";
4126
+ let sep2 = "";
4127
4127
  for (const token of end) {
4128
4128
  const { source, type } = token;
4129
4129
  switch (type) {
@@ -4137,13 +4137,13 @@ var require_resolve_end = __commonJS({
4137
4137
  if (!comment)
4138
4138
  comment = cb;
4139
4139
  else
4140
- comment += sep + cb;
4141
- sep = "";
4140
+ comment += sep2 + cb;
4141
+ sep2 = "";
4142
4142
  break;
4143
4143
  }
4144
4144
  case "newline":
4145
4145
  if (comment)
4146
- sep += source;
4146
+ sep2 += source;
4147
4147
  hasSpace = true;
4148
4148
  break;
4149
4149
  default:
@@ -4186,18 +4186,18 @@ var require_resolve_flow_collection = __commonJS({
4186
4186
  let offset = fc.offset + fc.start.source.length;
4187
4187
  for (let i = 0; i < fc.items.length; ++i) {
4188
4188
  const collItem = fc.items[i];
4189
- const { start, key, sep, value } = collItem;
4189
+ const { start, key, sep: sep2, value } = collItem;
4190
4190
  const props = resolveProps.resolveProps(start, {
4191
4191
  flow: fcName,
4192
4192
  indicator: "explicit-key-ind",
4193
- next: key ?? sep?.[0],
4193
+ next: key ?? sep2?.[0],
4194
4194
  offset,
4195
4195
  onError,
4196
4196
  parentIndent: fc.indent,
4197
4197
  startOnNewline: false
4198
4198
  });
4199
4199
  if (!props.found) {
4200
- if (!props.anchor && !props.tag && !sep && !value) {
4200
+ if (!props.anchor && !props.tag && !sep2 && !value) {
4201
4201
  if (i === 0 && props.comma)
4202
4202
  onError(props.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${fcName}`);
4203
4203
  else if (i < fc.items.length - 1)
@@ -4251,8 +4251,8 @@ var require_resolve_flow_collection = __commonJS({
4251
4251
  }
4252
4252
  }
4253
4253
  }
4254
- if (!isMap && !sep && !props.found) {
4255
- const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep, null, props, onError);
4254
+ if (!isMap && !sep2 && !props.found) {
4255
+ const valueNode = value ? composeNode(ctx, value, props, onError) : composeEmptyNode(ctx, props.end, sep2, null, props, onError);
4256
4256
  coll.items.push(valueNode);
4257
4257
  offset = valueNode.range[2];
4258
4258
  if (isBlock(value))
@@ -4264,7 +4264,7 @@ var require_resolve_flow_collection = __commonJS({
4264
4264
  if (isBlock(key))
4265
4265
  onError(keyNode.range, "BLOCK_IN_FLOW", blockMsg);
4266
4266
  ctx.atKey = false;
4267
- const valueProps = resolveProps.resolveProps(sep ?? [], {
4267
+ const valueProps = resolveProps.resolveProps(sep2 ?? [], {
4268
4268
  flow: fcName,
4269
4269
  indicator: "map-value-ind",
4270
4270
  next: value,
@@ -4275,8 +4275,8 @@ var require_resolve_flow_collection = __commonJS({
4275
4275
  });
4276
4276
  if (valueProps.found) {
4277
4277
  if (!isMap && !props.found && ctx.options.strict) {
4278
- if (sep)
4279
- for (const st of sep) {
4278
+ if (sep2)
4279
+ for (const st of sep2) {
4280
4280
  if (st === valueProps.found)
4281
4281
  break;
4282
4282
  if (st.type === "newline") {
@@ -4293,7 +4293,7 @@ var require_resolve_flow_collection = __commonJS({
4293
4293
  else
4294
4294
  onError(valueProps.start, "MISSING_CHAR", `Missing , or : between ${fcName} items`);
4295
4295
  }
4296
- const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep, null, valueProps, onError) : null;
4296
+ const valueNode = value ? composeNode(ctx, value, valueProps, onError) : valueProps.found ? composeEmptyNode(ctx, valueProps.end, sep2, null, valueProps, onError) : null;
4297
4297
  if (valueNode) {
4298
4298
  if (isBlock(value))
4299
4299
  onError(valueNode.range, "BLOCK_IN_FLOW", blockMsg);
@@ -4473,7 +4473,7 @@ var require_resolve_block_scalar = __commonJS({
4473
4473
  chompStart = i + 1;
4474
4474
  }
4475
4475
  let value = "";
4476
- let sep = "";
4476
+ let sep2 = "";
4477
4477
  let prevMoreIndented = false;
4478
4478
  for (let i = 0; i < contentStart; ++i)
4479
4479
  value += lines[i][0].slice(trimIndent) + "\n";
@@ -4490,24 +4490,24 @@ var require_resolve_block_scalar = __commonJS({
4490
4490
  indent = "";
4491
4491
  }
4492
4492
  if (type === Scalar.Scalar.BLOCK_LITERAL) {
4493
- value += sep + indent.slice(trimIndent) + content;
4494
- sep = "\n";
4493
+ value += sep2 + indent.slice(trimIndent) + content;
4494
+ sep2 = "\n";
4495
4495
  } else if (indent.length > trimIndent || content[0] === " ") {
4496
- if (sep === " ")
4497
- sep = "\n";
4498
- else if (!prevMoreIndented && sep === "\n")
4499
- sep = "\n\n";
4500
- value += sep + indent.slice(trimIndent) + content;
4501
- sep = "\n";
4496
+ if (sep2 === " ")
4497
+ sep2 = "\n";
4498
+ else if (!prevMoreIndented && sep2 === "\n")
4499
+ sep2 = "\n\n";
4500
+ value += sep2 + indent.slice(trimIndent) + content;
4501
+ sep2 = "\n";
4502
4502
  prevMoreIndented = true;
4503
4503
  } else if (content === "") {
4504
- if (sep === "\n")
4504
+ if (sep2 === "\n")
4505
4505
  value += "\n";
4506
4506
  else
4507
- sep = "\n";
4507
+ sep2 = "\n";
4508
4508
  } else {
4509
- value += sep + content;
4510
- sep = " ";
4509
+ value += sep2 + content;
4510
+ sep2 = " ";
4511
4511
  prevMoreIndented = false;
4512
4512
  }
4513
4513
  }
@@ -4678,8 +4678,8 @@ var require_resolve_flow_scalar = __commonJS({
4678
4678
  }
4679
4679
  function unfoldLines(source) {
4680
4680
  const line = /(.*?)\r?\n/sy;
4681
- let match = line.exec(source);
4682
- if (!match)
4681
+ let match2 = line.exec(source);
4682
+ if (!match2)
4683
4683
  return source;
4684
4684
  let trimEnd, trimBoth;
4685
4685
  try {
@@ -4689,26 +4689,26 @@ var require_resolve_flow_scalar = __commonJS({
4689
4689
  trimEnd = /[ \t]+$/;
4690
4690
  trimBoth = /^[ \t]+|[ \t]+$/g;
4691
4691
  }
4692
- let res = match[1].replace(trimEnd, "");
4693
- let sep = " ";
4692
+ let res = match2[1].replace(trimEnd, "");
4693
+ let sep2 = " ";
4694
4694
  let pos = line.lastIndex;
4695
- while (match = line.exec(source)) {
4696
- const lm = match[1].replace(trimBoth, "");
4695
+ while (match2 = line.exec(source)) {
4696
+ const lm = match2[1].replace(trimBoth, "");
4697
4697
  if (lm === "") {
4698
- if (sep === "\n")
4699
- res += sep;
4698
+ if (sep2 === "\n")
4699
+ res += sep2;
4700
4700
  else
4701
- sep = "\n";
4701
+ sep2 = "\n";
4702
4702
  } else {
4703
- res += sep + lm;
4704
- sep = " ";
4703
+ res += sep2 + lm;
4704
+ sep2 = " ";
4705
4705
  }
4706
4706
  pos = line.lastIndex;
4707
4707
  }
4708
4708
  const last = /[ \t]*(.*)/sy;
4709
4709
  last.lastIndex = pos;
4710
- match = last.exec(source);
4711
- return res + sep + (match?.[1] ?? "");
4710
+ match2 = last.exec(source);
4711
+ return res + sep2 + (match2?.[1] ?? "");
4712
4712
  }
4713
4713
  function doubleQuotedValue(source, onError) {
4714
4714
  let res = "";
@@ -4830,7 +4830,7 @@ var require_compose_scalar = __commonJS({
4830
4830
  var resolveBlockScalar = require_resolve_block_scalar();
4831
4831
  var resolveFlowScalar = require_resolve_flow_scalar();
4832
4832
  function composeScalar(ctx, token, tagToken, onError) {
4833
- const { value, type, comment, range } = token.type === "block-scalar" ? resolveBlockScalar.resolveBlockScalar(ctx, token, onError) : resolveFlowScalar.resolveFlowScalar(token, ctx.options.strict, onError);
4833
+ const { value, type, comment, range: range2 } = token.type === "block-scalar" ? resolveBlockScalar.resolveBlockScalar(ctx, token, onError) : resolveFlowScalar.resolveFlowScalar(token, ctx.options.strict, onError);
4834
4834
  const tagName = tagToken ? ctx.directives.tagName(tagToken.source, (msg) => onError(tagToken, "TAG_RESOLVE_FAILED", msg)) : null;
4835
4835
  let tag;
4836
4836
  if (ctx.options.stringKeys && ctx.atKey) {
@@ -4850,7 +4850,7 @@ var require_compose_scalar = __commonJS({
4850
4850
  onError(tagToken ?? token, "TAG_RESOLVE_FAILED", msg);
4851
4851
  scalar = new Scalar.Scalar(value);
4852
4852
  }
4853
- scalar.range = range;
4853
+ scalar.range = range2;
4854
4854
  scalar.source = value;
4855
4855
  if (type)
4856
4856
  scalar.type = type;
@@ -5518,14 +5518,14 @@ var require_cst_stringify = __commonJS({
5518
5518
  }
5519
5519
  }
5520
5520
  }
5521
- function stringifyItem({ start, key, sep, value }) {
5521
+ function stringifyItem({ start, key, sep: sep2, value }) {
5522
5522
  let res = "";
5523
5523
  for (const st of start)
5524
5524
  res += st.source;
5525
5525
  if (key)
5526
5526
  res += stringifyToken(key);
5527
- if (sep)
5528
- for (const st of sep)
5527
+ if (sep2)
5528
+ for (const st of sep2)
5529
5529
  res += st.source;
5530
5530
  if (value)
5531
5531
  res += stringifyToken(value);
@@ -5550,9 +5550,9 @@ var require_cst_visit = __commonJS({
5550
5550
  visit.BREAK = BREAK;
5551
5551
  visit.SKIP = SKIP;
5552
5552
  visit.REMOVE = REMOVE;
5553
- visit.itemAtPath = (cst, path) => {
5553
+ visit.itemAtPath = (cst, path2) => {
5554
5554
  let item = cst;
5555
- for (const [field, index] of path) {
5555
+ for (const [field, index] of path2) {
5556
5556
  const tok = item?.[field];
5557
5557
  if (tok && "items" in tok) {
5558
5558
  item = tok.items[index];
@@ -5561,23 +5561,23 @@ var require_cst_visit = __commonJS({
5561
5561
  }
5562
5562
  return item;
5563
5563
  };
5564
- visit.parentCollection = (cst, path) => {
5565
- const parent = visit.itemAtPath(cst, path.slice(0, -1));
5566
- const field = path[path.length - 1][0];
5564
+ visit.parentCollection = (cst, path2) => {
5565
+ const parent = visit.itemAtPath(cst, path2.slice(0, -1));
5566
+ const field = path2[path2.length - 1][0];
5567
5567
  const coll = parent?.[field];
5568
5568
  if (coll && "items" in coll)
5569
5569
  return coll;
5570
5570
  throw new Error("Parent collection not found");
5571
5571
  };
5572
- function _visit(path, item, visitor) {
5573
- let ctrl = visitor(item, path);
5572
+ function _visit(path2, item, visitor) {
5573
+ let ctrl = visitor(item, path2);
5574
5574
  if (typeof ctrl === "symbol")
5575
5575
  return ctrl;
5576
5576
  for (const field of ["key", "value"]) {
5577
5577
  const token = item[field];
5578
5578
  if (token && "items" in token) {
5579
5579
  for (let i = 0; i < token.items.length; ++i) {
5580
- const ci = _visit(Object.freeze(path.concat([[field, i]])), token.items[i], visitor);
5580
+ const ci = _visit(Object.freeze(path2.concat([[field, i]])), token.items[i], visitor);
5581
5581
  if (typeof ci === "number")
5582
5582
  i = ci - 1;
5583
5583
  else if (ci === BREAK)
@@ -5588,10 +5588,10 @@ var require_cst_visit = __commonJS({
5588
5588
  }
5589
5589
  }
5590
5590
  if (typeof ctrl === "function" && field === "key")
5591
- ctrl = ctrl(item, path);
5591
+ ctrl = ctrl(item, path2);
5592
5592
  }
5593
5593
  }
5594
- return typeof ctrl === "function" ? ctrl(item, path) : ctrl;
5594
+ return typeof ctrl === "function" ? ctrl(item, path2) : ctrl;
5595
5595
  }
5596
5596
  exports.visit = visit;
5597
5597
  }
@@ -6692,18 +6692,18 @@ var require_parser = __commonJS({
6692
6692
  if (this.type === "map-value-ind") {
6693
6693
  const prev = getPrevProps(this.peek(2));
6694
6694
  const start = getFirstKeyStartProps(prev);
6695
- let sep;
6695
+ let sep2;
6696
6696
  if (scalar.end) {
6697
- sep = scalar.end;
6698
- sep.push(this.sourceToken);
6697
+ sep2 = scalar.end;
6698
+ sep2.push(this.sourceToken);
6699
6699
  delete scalar.end;
6700
6700
  } else
6701
- sep = [this.sourceToken];
6701
+ sep2 = [this.sourceToken];
6702
6702
  const map = {
6703
6703
  type: "block-map",
6704
6704
  offset: scalar.offset,
6705
6705
  indent: scalar.indent,
6706
- items: [{ start, key: scalar, sep }]
6706
+ items: [{ start, key: scalar, sep: sep2 }]
6707
6707
  };
6708
6708
  this.onKeyLine = true;
6709
6709
  this.stack[this.stack.length - 1] = map;
@@ -6856,15 +6856,15 @@ var require_parser = __commonJS({
6856
6856
  } else if (isFlowToken(it.key) && !includesToken(it.sep, "newline")) {
6857
6857
  const start2 = getFirstKeyStartProps(it.start);
6858
6858
  const key = it.key;
6859
- const sep = it.sep;
6860
- sep.push(this.sourceToken);
6859
+ const sep2 = it.sep;
6860
+ sep2.push(this.sourceToken);
6861
6861
  delete it.key;
6862
6862
  delete it.sep;
6863
6863
  this.stack.push({
6864
6864
  type: "block-map",
6865
6865
  offset: this.offset,
6866
6866
  indent: this.indent,
6867
- items: [{ start: start2, key, sep }]
6867
+ items: [{ start: start2, key, sep: sep2 }]
6868
6868
  });
6869
6869
  } else if (start.length > 0) {
6870
6870
  it.sep = it.sep.concat(start, this.sourceToken);
@@ -7058,13 +7058,13 @@ var require_parser = __commonJS({
7058
7058
  const prev = getPrevProps(parent);
7059
7059
  const start = getFirstKeyStartProps(prev);
7060
7060
  fixFlowSeqItems(fc);
7061
- const sep = fc.end.splice(1, fc.end.length);
7062
- sep.push(this.sourceToken);
7061
+ const sep2 = fc.end.splice(1, fc.end.length);
7062
+ sep2.push(this.sourceToken);
7063
7063
  const map = {
7064
7064
  type: "block-map",
7065
7065
  offset: fc.offset,
7066
7066
  indent: fc.indent,
7067
- items: [{ start, key: fc, sep }]
7067
+ items: [{ start, key: fc, sep: sep2 }]
7068
7068
  };
7069
7069
  this.onKeyLine = true;
7070
7070
  this.stack[this.stack.length - 1] = map;
@@ -8166,9 +8166,9 @@ function serializeMcpDaemonEnvelope(envelope, maxBytes = MCP_DAEMON_MAX_FRAME_BY
8166
8166
  // src/mcp/trace-context.ts
8167
8167
  var TRACEPARENT = /^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})$/i;
8168
8168
  function mcpDaemonRequestContext(carrier, base = ROOT_CONTEXT) {
8169
- const match = carrier?.traceparent.match(TRACEPARENT);
8170
- if (!match) return base;
8171
- const [, version, traceId, spanId, flags] = match;
8169
+ const match2 = carrier?.traceparent.match(TRACEPARENT);
8170
+ if (!match2) return base;
8171
+ const [, version, traceId, spanId, flags] = match2;
8172
8172
  if (version?.toLowerCase() === "ff" || traceId === "0".repeat(32) || spanId === "0".repeat(16)) {
8173
8173
  return base;
8174
8174
  }
@@ -8593,6 +8593,1876 @@ function mcpRunHelpText() {
8593
8593
  // src/mcp/index.ts
8594
8594
  import { delimiter, dirname, join, resolve } from "node:path";
8595
8595
 
8596
+ // node_modules/.pnpm/balanced-match@4.0.4/node_modules/balanced-match/dist/esm/index.js
8597
+ var balanced = (a, b, str) => {
8598
+ const ma = a instanceof RegExp ? maybeMatch(a, str) : a;
8599
+ const mb = b instanceof RegExp ? maybeMatch(b, str) : b;
8600
+ const r = ma !== null && mb != null && range(ma, mb, str);
8601
+ return r && {
8602
+ start: r[0],
8603
+ end: r[1],
8604
+ pre: str.slice(0, r[0]),
8605
+ body: str.slice(r[0] + ma.length, r[1]),
8606
+ post: str.slice(r[1] + mb.length)
8607
+ };
8608
+ };
8609
+ var maybeMatch = (reg, str) => {
8610
+ const m = str.match(reg);
8611
+ return m ? m[0] : null;
8612
+ };
8613
+ var range = (a, b, str) => {
8614
+ let begs, beg, left, right = void 0, result;
8615
+ let ai = str.indexOf(a);
8616
+ let bi = str.indexOf(b, ai + 1);
8617
+ let i = ai;
8618
+ if (ai >= 0 && bi > 0) {
8619
+ if (a === b) {
8620
+ return [ai, bi];
8621
+ }
8622
+ begs = [];
8623
+ left = str.length;
8624
+ while (i >= 0 && !result) {
8625
+ if (i === ai) {
8626
+ begs.push(i);
8627
+ ai = str.indexOf(a, i + 1);
8628
+ } else if (begs.length === 1) {
8629
+ const r = begs.pop();
8630
+ if (r !== void 0)
8631
+ result = [r, bi];
8632
+ } else {
8633
+ beg = begs.pop();
8634
+ if (beg !== void 0 && beg < left) {
8635
+ left = beg;
8636
+ right = bi;
8637
+ }
8638
+ bi = str.indexOf(b, i + 1);
8639
+ }
8640
+ i = ai < bi && ai >= 0 ? ai : bi;
8641
+ }
8642
+ if (begs.length && right !== void 0) {
8643
+ result = [left, right];
8644
+ }
8645
+ }
8646
+ return result;
8647
+ };
8648
+
8649
+ // node_modules/.pnpm/brace-expansion@5.0.12/node_modules/brace-expansion/dist/esm/index.js
8650
+ var escSlash = "\0SLASH" + Math.random() + "\0";
8651
+ var escOpen = "\0OPEN" + Math.random() + "\0";
8652
+ var escClose = "\0CLOSE" + Math.random() + "\0";
8653
+ var escComma = "\0COMMA" + Math.random() + "\0";
8654
+ var escPeriod = "\0PERIOD" + Math.random() + "\0";
8655
+ var escSlashPattern = new RegExp(escSlash, "g");
8656
+ var escOpenPattern = new RegExp(escOpen, "g");
8657
+ var escClosePattern = new RegExp(escClose, "g");
8658
+ var escCommaPattern = new RegExp(escComma, "g");
8659
+ var escPeriodPattern = new RegExp(escPeriod, "g");
8660
+ var slashPattern = /\\\\/g;
8661
+ var openPattern = /\\{/g;
8662
+ var closePattern = /\\}/g;
8663
+ var commaPattern = /\\,/g;
8664
+ var periodPattern = /\\\./g;
8665
+ var EXPANSION_MAX = 1e5;
8666
+ var EXPANSION_MAX_LENGTH = 4e6;
8667
+ var EXPANSION_MAX_DEPTH = 1e3;
8668
+ var EXPANSION_MAX_REWRITES = 1e3;
8669
+ function numeric(str) {
8670
+ return !isNaN(str) ? parseInt(str, 10) : str.charCodeAt(0);
8671
+ }
8672
+ function escapeBraces(str) {
8673
+ return str.replace(slashPattern, escSlash).replace(openPattern, escOpen).replace(closePattern, escClose).replace(commaPattern, escComma).replace(periodPattern, escPeriod);
8674
+ }
8675
+ function unescapeBraces(str) {
8676
+ return str.replace(escSlashPattern, "\\").replace(escOpenPattern, "{").replace(escClosePattern, "}").replace(escCommaPattern, ",").replace(escPeriodPattern, ".");
8677
+ }
8678
+ function pushAll(target, items) {
8679
+ for (let i = 0; i < items.length; i++) {
8680
+ target.push(items[i]);
8681
+ }
8682
+ }
8683
+ function parseCommaParts(str) {
8684
+ const parts = [];
8685
+ let carry = "";
8686
+ for (; ; ) {
8687
+ const m = balanced("{", "}", str);
8688
+ if (!m) {
8689
+ const tail = str.split(",");
8690
+ tail[0] = carry + tail[0];
8691
+ pushAll(parts, tail);
8692
+ return parts;
8693
+ }
8694
+ const { pre, body, post } = m;
8695
+ const p = pre.split(",");
8696
+ p[0] = carry + p[0];
8697
+ p[p.length - 1] += "{" + body + "}";
8698
+ if (!post.length) {
8699
+ pushAll(parts, p);
8700
+ return parts;
8701
+ }
8702
+ carry = p.pop();
8703
+ pushAll(parts, p);
8704
+ str = post;
8705
+ }
8706
+ }
8707
+ function expand(str, options = {}) {
8708
+ if (!str) {
8709
+ return [];
8710
+ }
8711
+ const { max = EXPANSION_MAX, maxLength = EXPANSION_MAX_LENGTH, maxDepth = EXPANSION_MAX_DEPTH, maxRewrites = EXPANSION_MAX_REWRITES } = options;
8712
+ if (str.slice(0, 2) === "{}") {
8713
+ str = "\\{\\}" + str.slice(2);
8714
+ }
8715
+ return expand_(escapeBraces(str), max, maxLength, maxDepth, 0, maxRewrites, true).map(unescapeBraces);
8716
+ }
8717
+ function embrace(str) {
8718
+ return "{" + str + "}";
8719
+ }
8720
+ function isPadded(el) {
8721
+ return /^-?0\d/.test(el);
8722
+ }
8723
+ function lte(i, y) {
8724
+ return i <= y;
8725
+ }
8726
+ function gte(i, y) {
8727
+ return i >= y;
8728
+ }
8729
+ function combine(acc, pre, values, max, maxLength, dropEmpties) {
8730
+ const out = [];
8731
+ let length = 0;
8732
+ for (let a = 0; a < acc.length; a++) {
8733
+ for (let v = 0; v < values.length; v++) {
8734
+ if (out.length >= max)
8735
+ return out;
8736
+ const expansion = acc[a] + pre + values[v];
8737
+ if (dropEmpties && !expansion)
8738
+ continue;
8739
+ if (length + expansion.length > maxLength)
8740
+ return out;
8741
+ out.push(expansion);
8742
+ length += expansion.length;
8743
+ }
8744
+ }
8745
+ return out;
8746
+ }
8747
+ function expandSequence(body, isAlphaSequence, max, maxLength) {
8748
+ const n = body.split(/\.\./);
8749
+ const N = [];
8750
+ if (n[0] === void 0 || n[1] === void 0) {
8751
+ return N;
8752
+ }
8753
+ const x = numeric(n[0]);
8754
+ const y = numeric(n[1]);
8755
+ const width = Math.max(n[0].length, n[1].length);
8756
+ let incr = n.length === 3 && n[2] !== void 0 ? Math.max(Math.abs(numeric(n[2])), 1) : 1;
8757
+ let test = lte;
8758
+ const reverse = y < x;
8759
+ if (reverse) {
8760
+ incr *= -1;
8761
+ test = gte;
8762
+ }
8763
+ const pad = n.some(isPadded);
8764
+ let length = 0;
8765
+ for (let i = x; test(i, y) && N.length < max; i += incr) {
8766
+ let c;
8767
+ if (isAlphaSequence) {
8768
+ c = String.fromCharCode(i);
8769
+ if (c === "\\") {
8770
+ c = "";
8771
+ }
8772
+ } else {
8773
+ c = String(i);
8774
+ if (pad) {
8775
+ const need = width - c.length;
8776
+ if (need > 0) {
8777
+ const z = new Array(need + 1).join("0");
8778
+ if (i < 0) {
8779
+ c = "-" + z + c.slice(1);
8780
+ } else {
8781
+ c = z + c;
8782
+ }
8783
+ }
8784
+ }
8785
+ }
8786
+ if (length + c.length > maxLength)
8787
+ break;
8788
+ N.push(c);
8789
+ length += c.length;
8790
+ }
8791
+ return N;
8792
+ }
8793
+ function expand_(str, max, maxLength, maxDepth, depth, maxRewrites, isTop) {
8794
+ if (depth > maxDepth) {
8795
+ return [str];
8796
+ }
8797
+ let acc = [""];
8798
+ let rewrites = 0;
8799
+ let dropEmpties = false;
8800
+ let firstGroup = true;
8801
+ for (; ; ) {
8802
+ const m = balanced("{", "}", str);
8803
+ if (!m) {
8804
+ return combine(acc, str, [""], max, maxLength, dropEmpties);
8805
+ }
8806
+ const pre = m.pre;
8807
+ if (/\$$/.test(pre)) {
8808
+ acc = combine(acc, pre + "{" + m.body + "}", [""], max, maxLength, dropEmpties && !m.post.length);
8809
+ firstGroup = false;
8810
+ if (!m.post.length)
8811
+ break;
8812
+ str = m.post;
8813
+ continue;
8814
+ }
8815
+ const isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
8816
+ const isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
8817
+ const isSequence = isNumericSequence || isAlphaSequence;
8818
+ const isOptions = m.body.indexOf(",") >= 0;
8819
+ if (!isSequence && !isOptions) {
8820
+ if (rewrites < maxRewrites && m.post.match(/,(?!,).*\}/)) {
8821
+ rewrites++;
8822
+ str = m.pre + "{" + m.body + escClose + m.post;
8823
+ isTop = true;
8824
+ continue;
8825
+ }
8826
+ return combine(acc, pre + "{" + m.body + "}" + m.post, [""], max, maxLength, dropEmpties);
8827
+ }
8828
+ if (firstGroup) {
8829
+ dropEmpties = isTop && !isSequence;
8830
+ firstGroup = false;
8831
+ }
8832
+ let values;
8833
+ if (isSequence) {
8834
+ values = expandSequence(m.body, isAlphaSequence, max, maxLength);
8835
+ } else {
8836
+ let n = parseCommaParts(m.body);
8837
+ if (n.length === 1 && n[0] !== void 0) {
8838
+ n = expand_(n[0], max, maxLength, maxDepth, depth + 1, maxRewrites, false).map(embrace);
8839
+ if (n.length === 1) {
8840
+ acc = combine(acc, pre + n[0], [""], max, maxLength, dropEmpties && !m.post.length);
8841
+ if (!m.post.length)
8842
+ break;
8843
+ str = m.post;
8844
+ continue;
8845
+ }
8846
+ }
8847
+ let dropsEmpties = dropEmpties && !m.post.length && !pre;
8848
+ for (let d = 0; dropsEmpties && d < acc.length; d++) {
8849
+ if (acc[d]) {
8850
+ dropsEmpties = false;
8851
+ }
8852
+ }
8853
+ values = [];
8854
+ let valuesLength = 0;
8855
+ outer: for (let j = 0; j < n.length; j++) {
8856
+ const expanded = expand_(n[j], max, maxLength, maxDepth, depth + 1, maxRewrites, false);
8857
+ for (let k = 0; k < expanded.length; k++) {
8858
+ const v = expanded[k];
8859
+ if (dropsEmpties && !v)
8860
+ continue;
8861
+ if (values.length >= max || valuesLength + v.length > maxLength) {
8862
+ break outer;
8863
+ }
8864
+ values.push(v);
8865
+ valuesLength += v.length;
8866
+ }
8867
+ }
8868
+ }
8869
+ acc = combine(acc, pre, values, max, maxLength, dropEmpties && !m.post.length);
8870
+ if (!m.post.length)
8871
+ break;
8872
+ str = m.post;
8873
+ }
8874
+ return acc;
8875
+ }
8876
+
8877
+ // node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/assert-valid-pattern.js
8878
+ var MAX_PATTERN_LENGTH = 1024 * 64;
8879
+ var assertValidPattern = (pattern) => {
8880
+ if (typeof pattern !== "string") {
8881
+ throw new TypeError("invalid pattern");
8882
+ }
8883
+ if (pattern.length > MAX_PATTERN_LENGTH) {
8884
+ throw new TypeError("pattern is too long");
8885
+ }
8886
+ };
8887
+
8888
+ // node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/brace-expressions.js
8889
+ var posixClasses = {
8890
+ "[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", true],
8891
+ "[:alpha:]": ["\\p{L}\\p{Nl}", true],
8892
+ "[:ascii:]": ["\\x00-\\x7f", false],
8893
+ "[:blank:]": ["\\p{Zs}\\t", true],
8894
+ "[:cntrl:]": ["\\p{Cc}", true],
8895
+ "[:digit:]": ["\\p{Nd}", true],
8896
+ "[:graph:]": ["\\p{Z}\\p{C}", true, true],
8897
+ "[:lower:]": ["\\p{Ll}", true],
8898
+ "[:print:]": ["\\p{C}", true],
8899
+ "[:punct:]": ["\\p{P}", true],
8900
+ "[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f", true],
8901
+ "[:upper:]": ["\\p{Lu}", true],
8902
+ "[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}", true],
8903
+ "[:xdigit:]": ["A-Fa-f0-9", false]
8904
+ };
8905
+ var braceEscape = (s) => s.replace(/[[\]\\-]/g, "\\$&");
8906
+ var regexpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
8907
+ var rangesToString = (ranges) => ranges.join("");
8908
+ var parseClass = (glob, position) => {
8909
+ const pos = position;
8910
+ if (glob.charAt(pos) !== "[") {
8911
+ throw new Error("not in a brace expression");
8912
+ }
8913
+ const ranges = [];
8914
+ const negs = [];
8915
+ let i = pos + 1;
8916
+ let sawStart = false;
8917
+ let uflag = false;
8918
+ let escaping = false;
8919
+ let negate = false;
8920
+ let endPos = pos;
8921
+ let rangeStart = "";
8922
+ WHILE: while (i < glob.length) {
8923
+ const c = glob.charAt(i);
8924
+ if ((c === "!" || c === "^") && i === pos + 1) {
8925
+ negate = true;
8926
+ i++;
8927
+ continue;
8928
+ }
8929
+ if (c === "]" && sawStart && !escaping) {
8930
+ endPos = i + 1;
8931
+ break;
8932
+ }
8933
+ sawStart = true;
8934
+ if (c === "\\") {
8935
+ if (!escaping) {
8936
+ escaping = true;
8937
+ i++;
8938
+ continue;
8939
+ }
8940
+ }
8941
+ if (c === "[" && !escaping) {
8942
+ for (const [cls, [unip, u, neg]] of Object.entries(posixClasses)) {
8943
+ if (glob.startsWith(cls, i)) {
8944
+ if (rangeStart) {
8945
+ return ["$.", false, glob.length - pos, true];
8946
+ }
8947
+ i += cls.length;
8948
+ if (neg)
8949
+ negs.push(unip);
8950
+ else
8951
+ ranges.push(unip);
8952
+ uflag = uflag || u;
8953
+ continue WHILE;
8954
+ }
8955
+ }
8956
+ }
8957
+ escaping = false;
8958
+ if (rangeStart) {
8959
+ if (c > rangeStart) {
8960
+ ranges.push(braceEscape(rangeStart) + "-" + braceEscape(c));
8961
+ } else if (c === rangeStart) {
8962
+ ranges.push(braceEscape(c));
8963
+ }
8964
+ rangeStart = "";
8965
+ i++;
8966
+ continue;
8967
+ }
8968
+ if (glob.startsWith("-]", i + 1)) {
8969
+ ranges.push(braceEscape(c + "-"));
8970
+ i += 2;
8971
+ continue;
8972
+ }
8973
+ if (glob.startsWith("-", i + 1)) {
8974
+ rangeStart = c;
8975
+ i += 2;
8976
+ continue;
8977
+ }
8978
+ ranges.push(braceEscape(c));
8979
+ i++;
8980
+ }
8981
+ if (endPos < i) {
8982
+ return ["", false, 0, false];
8983
+ }
8984
+ if (!ranges.length && !negs.length) {
8985
+ return ["$.", false, glob.length - pos, true];
8986
+ }
8987
+ if (negs.length === 0 && ranges.length === 1 && /^\\?.$/.test(ranges[0]) && !negate) {
8988
+ const r = ranges[0].length === 2 ? ranges[0].slice(-1) : ranges[0];
8989
+ return [regexpEscape(r), false, endPos - pos, false];
8990
+ }
8991
+ const sranges = "[" + (negate ? "^" : "") + rangesToString(ranges) + "]";
8992
+ const snegs = "[" + (negate ? "" : "^") + rangesToString(negs) + "]";
8993
+ const comb = ranges.length && negs.length ? "(" + sranges + "|" + snegs + ")" : ranges.length ? sranges : snegs;
8994
+ return [comb, uflag, endPos - pos, true];
8995
+ };
8996
+
8997
+ // node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/unescape.js
8998
+ var unescape = (s, { windowsPathsNoEscape = false, magicalBraces = true } = {}) => {
8999
+ if (magicalBraces) {
9000
+ return windowsPathsNoEscape ? s.replace(/\[([^/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^/\\])\]/g, "$1$2").replace(/\\([^/])/g, "$1");
9001
+ }
9002
+ return windowsPathsNoEscape ? s.replace(/\[([^/\\{}])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^/\\{}])\]/g, "$1$2").replace(/\\([^/{}])/g, "$1");
9003
+ };
9004
+
9005
+ // node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/ast.js
9006
+ var _a;
9007
+ var types = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]);
9008
+ var isExtglobType = (c) => types.has(c);
9009
+ var isExtglobAST = (c) => isExtglobType(c.type);
9010
+ var adoptionMap = /* @__PURE__ */ new Map([
9011
+ ["!", ["@"]],
9012
+ ["?", ["?", "@"]],
9013
+ ["@", ["@"]],
9014
+ ["*", ["*", "+", "?", "@"]],
9015
+ ["+", ["+", "@"]]
9016
+ ]);
9017
+ var adoptionWithSpaceMap = /* @__PURE__ */ new Map([
9018
+ ["!", ["?"]],
9019
+ ["@", ["?"]],
9020
+ ["+", ["?", "*"]]
9021
+ ]);
9022
+ var adoptionAnyMap = /* @__PURE__ */ new Map([
9023
+ ["!", ["?", "@"]],
9024
+ ["?", ["?", "@"]],
9025
+ ["@", ["?", "@"]],
9026
+ ["*", ["*", "+", "?", "@"]],
9027
+ ["+", ["+", "@", "?", "*"]]
9028
+ ]);
9029
+ var usurpMap = /* @__PURE__ */ new Map([
9030
+ ["!", /* @__PURE__ */ new Map([["!", "@"]])],
9031
+ [
9032
+ "?",
9033
+ /* @__PURE__ */ new Map([
9034
+ ["*", "*"],
9035
+ ["+", "*"]
9036
+ ])
9037
+ ],
9038
+ [
9039
+ "@",
9040
+ /* @__PURE__ */ new Map([
9041
+ ["!", "!"],
9042
+ ["?", "?"],
9043
+ ["@", "@"],
9044
+ ["*", "*"],
9045
+ ["+", "+"]
9046
+ ])
9047
+ ],
9048
+ [
9049
+ "+",
9050
+ /* @__PURE__ */ new Map([
9051
+ ["?", "*"],
9052
+ ["*", "*"]
9053
+ ])
9054
+ ]
9055
+ ]);
9056
+ var startNoTraversal = "(?!(?:^|/)\\.\\.?(?:$|/))";
9057
+ var startNoDot = "(?!\\.)";
9058
+ var addPatternStart = /* @__PURE__ */ new Set(["[", "."]);
9059
+ var justDots = /* @__PURE__ */ new Set(["..", "."]);
9060
+ var reSpecials = new Set("().*{}+?[]^$\\!");
9061
+ var regExpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
9062
+ var qmark = "[^/]";
9063
+ var star = qmark + "*?";
9064
+ var starNoEmpty = qmark + "+?";
9065
+ var ID = 0;
9066
+ var AST = class {
9067
+ type;
9068
+ #root;
9069
+ #hasMagic;
9070
+ #uflag = false;
9071
+ #parts = [];
9072
+ #parent;
9073
+ #parentIndex;
9074
+ #negs;
9075
+ #filledNegs = false;
9076
+ #options;
9077
+ #toString;
9078
+ // set to true if it's an extglob with no children
9079
+ // (which really means one child of '')
9080
+ #emptyExt = false;
9081
+ id = ++ID;
9082
+ get depth() {
9083
+ return (this.#parent?.depth ?? -1) + 1;
9084
+ }
9085
+ [/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")]() {
9086
+ return {
9087
+ "@@type": "AST",
9088
+ id: this.id,
9089
+ type: this.type,
9090
+ root: this.#root.id,
9091
+ parent: this.#parent?.id,
9092
+ depth: this.depth,
9093
+ partsLength: this.#parts.length,
9094
+ parts: this.#parts
9095
+ };
9096
+ }
9097
+ constructor(type, parent, options = {}) {
9098
+ this.type = type;
9099
+ if (type)
9100
+ this.#hasMagic = true;
9101
+ this.#parent = parent;
9102
+ this.#root = this.#parent ? this.#parent.#root : this;
9103
+ this.#options = this.#root === this ? options : this.#root.#options;
9104
+ this.#negs = this.#root === this ? [] : this.#root.#negs;
9105
+ if (type === "!" && !this.#root.#filledNegs)
9106
+ this.#negs.push(this);
9107
+ this.#parentIndex = this.#parent ? this.#parent.#parts.length : 0;
9108
+ }
9109
+ get hasMagic() {
9110
+ if (this.#hasMagic !== void 0)
9111
+ return this.#hasMagic;
9112
+ for (const p of this.#parts) {
9113
+ if (typeof p === "string")
9114
+ continue;
9115
+ if (p.type || p.hasMagic)
9116
+ return this.#hasMagic = true;
9117
+ }
9118
+ return this.#hasMagic;
9119
+ }
9120
+ // reconstructs the pattern
9121
+ toString() {
9122
+ return this.#toString !== void 0 ? this.#toString : !this.type ? this.#toString = this.#parts.map((p) => String(p)).join("") : this.#toString = this.type + "(" + this.#parts.map((p) => String(p)).join("|") + ")";
9123
+ }
9124
+ #fillNegs() {
9125
+ if (this !== this.#root)
9126
+ throw new Error("should only call on root");
9127
+ if (this.#filledNegs)
9128
+ return this;
9129
+ this.toString();
9130
+ this.#filledNegs = true;
9131
+ let n;
9132
+ while (n = this.#negs.pop()) {
9133
+ if (n.type !== "!")
9134
+ continue;
9135
+ let p = n;
9136
+ let pp = p.#parent;
9137
+ while (pp) {
9138
+ for (let i = p.#parentIndex + 1; !pp.type && i < pp.#parts.length; i++) {
9139
+ for (const part of n.#parts) {
9140
+ if (typeof part === "string") {
9141
+ throw new Error("string part in extglob AST??");
9142
+ }
9143
+ part.copyIn(pp.#parts[i]);
9144
+ }
9145
+ }
9146
+ p = pp;
9147
+ pp = p.#parent;
9148
+ }
9149
+ }
9150
+ return this;
9151
+ }
9152
+ push(...parts) {
9153
+ for (const p of parts) {
9154
+ if (p === "")
9155
+ continue;
9156
+ if (typeof p !== "string" && !(p instanceof _a && p.#parent === this)) {
9157
+ throw new Error("invalid part: " + p);
9158
+ }
9159
+ this.#parts.push(p);
9160
+ }
9161
+ }
9162
+ toJSON() {
9163
+ const ret = this.type === null ? this.#parts.slice().map((p) => typeof p === "string" ? p : p.toJSON()) : [this.type, ...this.#parts.map((p) => p.toJSON())];
9164
+ if (this.isStart() && !this.type)
9165
+ ret.unshift([]);
9166
+ if (this.isEnd() && (this === this.#root || this.#root.#filledNegs && this.#parent?.type === "!")) {
9167
+ ret.push({});
9168
+ }
9169
+ return ret;
9170
+ }
9171
+ isStart() {
9172
+ if (this.#root === this)
9173
+ return true;
9174
+ if (!this.#parent?.isStart())
9175
+ return false;
9176
+ if (this.#parentIndex === 0)
9177
+ return true;
9178
+ const p = this.#parent;
9179
+ for (let i = 0; i < this.#parentIndex; i++) {
9180
+ const pp = p.#parts[i];
9181
+ if (!(pp instanceof _a && pp.type === "!")) {
9182
+ return false;
9183
+ }
9184
+ }
9185
+ return true;
9186
+ }
9187
+ isEnd() {
9188
+ if (this.#root === this)
9189
+ return true;
9190
+ if (this.#parent?.type === "!")
9191
+ return true;
9192
+ if (!this.#parent?.isEnd())
9193
+ return false;
9194
+ if (!this.type)
9195
+ return this.#parent?.isEnd();
9196
+ const pl = this.#parent ? this.#parent.#parts.length : 0;
9197
+ return this.#parentIndex === pl - 1;
9198
+ }
9199
+ copyIn(part) {
9200
+ if (typeof part === "string")
9201
+ this.push(part);
9202
+ else
9203
+ this.push(part.clone(this));
9204
+ }
9205
+ clone(parent) {
9206
+ const c = new _a(this.type, parent);
9207
+ for (const p of this.#parts) {
9208
+ c.copyIn(p);
9209
+ }
9210
+ return c;
9211
+ }
9212
+ static #parseAST(str, ast, pos, opt, extDepth) {
9213
+ const maxDepth = opt.maxExtglobRecursion ?? 2;
9214
+ let escaping = false;
9215
+ let inBrace = false;
9216
+ let braceStart = -1;
9217
+ let braceNeg = false;
9218
+ if (ast.type === null) {
9219
+ let i2 = pos;
9220
+ let acc2 = "";
9221
+ while (i2 < str.length) {
9222
+ const c = str.charAt(i2++);
9223
+ if (escaping || c === "\\") {
9224
+ escaping = !escaping;
9225
+ acc2 += c;
9226
+ continue;
9227
+ }
9228
+ if (inBrace) {
9229
+ if (i2 === braceStart + 1) {
9230
+ if (c === "^" || c === "!") {
9231
+ braceNeg = true;
9232
+ }
9233
+ } else if (c === "]" && !(i2 === braceStart + 2 && braceNeg)) {
9234
+ inBrace = false;
9235
+ }
9236
+ acc2 += c;
9237
+ continue;
9238
+ } else if (c === "[") {
9239
+ inBrace = true;
9240
+ braceStart = i2;
9241
+ braceNeg = false;
9242
+ acc2 += c;
9243
+ continue;
9244
+ }
9245
+ const doRecurse = !opt.noext && isExtglobType(c) && str.charAt(i2) === "(" && extDepth <= maxDepth;
9246
+ if (doRecurse) {
9247
+ ast.push(acc2);
9248
+ acc2 = "";
9249
+ const ext2 = new _a(c, ast);
9250
+ i2 = _a.#parseAST(str, ext2, i2, opt, extDepth + 1);
9251
+ ast.push(ext2);
9252
+ continue;
9253
+ }
9254
+ acc2 += c;
9255
+ }
9256
+ ast.push(acc2);
9257
+ return i2;
9258
+ }
9259
+ let i = pos + 1;
9260
+ let part = new _a(null, ast);
9261
+ const parts = [];
9262
+ let acc = "";
9263
+ while (i < str.length) {
9264
+ const c = str.charAt(i++);
9265
+ if (escaping || c === "\\") {
9266
+ escaping = !escaping;
9267
+ acc += c;
9268
+ continue;
9269
+ }
9270
+ if (inBrace) {
9271
+ if (i === braceStart + 1) {
9272
+ if (c === "^" || c === "!") {
9273
+ braceNeg = true;
9274
+ }
9275
+ } else if (c === "]" && !(i === braceStart + 2 && braceNeg)) {
9276
+ inBrace = false;
9277
+ }
9278
+ acc += c;
9279
+ continue;
9280
+ } else if (c === "[") {
9281
+ inBrace = true;
9282
+ braceStart = i;
9283
+ braceNeg = false;
9284
+ acc += c;
9285
+ continue;
9286
+ }
9287
+ const doRecurse = !opt.noext && isExtglobType(c) && str.charAt(i) === "(" && /* c8 ignore start - the maxDepth is sufficient here */
9288
+ (extDepth <= maxDepth || ast && ast.#canAdoptType(c));
9289
+ if (doRecurse) {
9290
+ const depthAdd = ast && ast.#canAdoptType(c) ? 0 : 1;
9291
+ part.push(acc);
9292
+ acc = "";
9293
+ const ext2 = new _a(c, part);
9294
+ part.push(ext2);
9295
+ i = _a.#parseAST(str, ext2, i, opt, extDepth + depthAdd);
9296
+ continue;
9297
+ }
9298
+ if (c === "|") {
9299
+ part.push(acc);
9300
+ acc = "";
9301
+ parts.push(part);
9302
+ part = new _a(null, ast);
9303
+ continue;
9304
+ }
9305
+ if (c === ")") {
9306
+ if (acc === "" && ast.#parts.length === 0) {
9307
+ ast.#emptyExt = true;
9308
+ }
9309
+ part.push(acc);
9310
+ acc = "";
9311
+ ast.push(...parts, part);
9312
+ return i;
9313
+ }
9314
+ acc += c;
9315
+ }
9316
+ ast.type = null;
9317
+ ast.#hasMagic = void 0;
9318
+ ast.#parts = [str.substring(pos - 1)];
9319
+ return i;
9320
+ }
9321
+ #canAdoptWithSpace(child) {
9322
+ return this.#canAdopt(child, adoptionWithSpaceMap);
9323
+ }
9324
+ #canAdopt(child, map = adoptionMap) {
9325
+ if (!child || typeof child !== "object" || child.type !== null || child.#parts.length !== 1 || this.type === null) {
9326
+ return false;
9327
+ }
9328
+ const gc = child.#parts[0];
9329
+ if (!gc || typeof gc !== "object" || gc.type === null) {
9330
+ return false;
9331
+ }
9332
+ return this.#canAdoptType(gc.type, map);
9333
+ }
9334
+ #canAdoptType(c, map = adoptionAnyMap) {
9335
+ return !!map.get(this.type)?.includes(c);
9336
+ }
9337
+ #adoptWithSpace(child, index) {
9338
+ const gc = child.#parts[0];
9339
+ const blank = new _a(null, gc, this.options);
9340
+ blank.#parts.push("");
9341
+ gc.push(blank);
9342
+ this.#adopt(child, index);
9343
+ }
9344
+ #adopt(child, index) {
9345
+ const gc = child.#parts[0];
9346
+ this.#parts.splice(index, 1, ...gc.#parts);
9347
+ for (const p of gc.#parts) {
9348
+ if (typeof p === "object")
9349
+ p.#parent = this;
9350
+ }
9351
+ this.#toString = void 0;
9352
+ }
9353
+ #canUsurpType(c) {
9354
+ const m = usurpMap.get(this.type);
9355
+ return !!m?.has(c);
9356
+ }
9357
+ #canUsurp(child) {
9358
+ if (!child || typeof child !== "object" || child.type !== null || child.#parts.length !== 1 || this.type === null || this.#parts.length !== 1) {
9359
+ return false;
9360
+ }
9361
+ const gc = child.#parts[0];
9362
+ if (!gc || typeof gc !== "object" || gc.type === null) {
9363
+ return false;
9364
+ }
9365
+ return this.#canUsurpType(gc.type);
9366
+ }
9367
+ #usurp(child) {
9368
+ const m = usurpMap.get(this.type);
9369
+ const gc = child.#parts[0];
9370
+ const nt = m?.get(gc.type);
9371
+ if (!nt)
9372
+ return false;
9373
+ this.#parts = gc.#parts;
9374
+ for (const p of this.#parts) {
9375
+ if (typeof p === "object") {
9376
+ p.#parent = this;
9377
+ }
9378
+ }
9379
+ this.type = nt;
9380
+ this.#toString = void 0;
9381
+ this.#emptyExt = false;
9382
+ }
9383
+ static fromGlob(pattern, options = {}) {
9384
+ const ast = new _a(null, void 0, options);
9385
+ _a.#parseAST(pattern, ast, 0, options, 0);
9386
+ return ast;
9387
+ }
9388
+ // returns the regular expression if there's magic, or the unescaped
9389
+ // string if not.
9390
+ toMMPattern() {
9391
+ if (this !== this.#root)
9392
+ return this.#root.toMMPattern();
9393
+ const glob = this.toString();
9394
+ const [re2, body, hasMagic, uflag] = this.toRegExpSource();
9395
+ const anyMagic = hasMagic || this.#hasMagic || this.#options.nocase && !this.#options.nocaseMagicOnly && glob.toUpperCase() !== glob.toLowerCase();
9396
+ if (!anyMagic) {
9397
+ return body;
9398
+ }
9399
+ const flags = (this.#options.nocase ? "i" : "") + (uflag ? "u" : "");
9400
+ return Object.assign(new RegExp(`^${re2}$`, flags), {
9401
+ _src: re2,
9402
+ _glob: glob
9403
+ });
9404
+ }
9405
+ get options() {
9406
+ return this.#options;
9407
+ }
9408
+ // returns the string match, the regexp source, whether there's magic
9409
+ // in the regexp (so a regular expression is required) and whether or
9410
+ // not the uflag is needed for the regular expression (for posix classes)
9411
+ // TODO: instead of injecting the start/end at this point, just return
9412
+ // the BODY of the regexp, along with the start/end portions suitable
9413
+ // for binding the start/end in either a joined full-path makeRe context
9414
+ // (where we bind to (^|/), or a standalone matchPart context (where
9415
+ // we bind to ^, and not /). Otherwise slashes get duped!
9416
+ //
9417
+ // In part-matching mode, the start is:
9418
+ // - if not isStart: nothing
9419
+ // - if traversal possible, but not allowed: ^(?!\.\.?$)
9420
+ // - if dots allowed or not possible: ^
9421
+ // - if dots possible and not allowed: ^(?!\.)
9422
+ // end is:
9423
+ // - if not isEnd(): nothing
9424
+ // - else: $
9425
+ //
9426
+ // In full-path matching mode, we put the slash at the START of the
9427
+ // pattern, so start is:
9428
+ // - if first pattern: same as part-matching mode
9429
+ // - if not isStart(): nothing
9430
+ // - if traversal possible, but not allowed: /(?!\.\.?(?:$|/))
9431
+ // - if dots allowed or not possible: /
9432
+ // - if dots possible and not allowed: /(?!\.)
9433
+ // end is:
9434
+ // - if last pattern, same as part-matching mode
9435
+ // - else nothing
9436
+ //
9437
+ // Always put the (?:$|/) on negated tails, though, because that has to be
9438
+ // there to bind the end of the negated pattern portion, and it's easier to
9439
+ // just stick it in now rather than try to inject it later in the middle of
9440
+ // the pattern.
9441
+ //
9442
+ // We can just always return the same end, and leave it up to the caller
9443
+ // to know whether it's going to be used joined or in parts.
9444
+ // And, if the start is adjusted slightly, can do the same there:
9445
+ // - if not isStart: nothing
9446
+ // - if traversal possible, but not allowed: (?:/|^)(?!\.\.?$)
9447
+ // - if dots allowed or not possible: (?:/|^)
9448
+ // - if dots possible and not allowed: (?:/|^)(?!\.)
9449
+ //
9450
+ // But it's better to have a simpler binding without a conditional, for
9451
+ // performance, so probably better to return both start options.
9452
+ //
9453
+ // Then the caller just ignores the end if it's not the first pattern,
9454
+ // and the start always gets applied.
9455
+ //
9456
+ // But that's always going to be $ if it's the ending pattern, or nothing,
9457
+ // so the caller can just attach $ at the end of the pattern when building.
9458
+ //
9459
+ // So the todo is:
9460
+ // - better detect what kind of start is needed
9461
+ // - return both flavors of starting pattern
9462
+ // - attach $ at the end of the pattern when creating the actual RegExp
9463
+ //
9464
+ // Ah, but wait, no, that all only applies to the root when the first pattern
9465
+ // is not an extglob. If the first pattern IS an extglob, then we need all
9466
+ // that dot prevention biz to live in the extglob portions, because eg
9467
+ // +(*|.x*) can match .xy but not .yx.
9468
+ //
9469
+ // So, return the two flavors if it's #root and the first child is not an
9470
+ // AST, otherwise leave it to the child AST to handle it, and there,
9471
+ // use the (?:^|/) style of start binding.
9472
+ //
9473
+ // Even simplified further:
9474
+ // - Since the start for a join is eg /(?!\.) and the start for a part
9475
+ // is ^(?!\.), we can just prepend (?!\.) to the pattern (either root
9476
+ // or start or whatever) and prepend ^ or / at the Regexp construction.
9477
+ toRegExpSource(allowDot) {
9478
+ const dot = allowDot ?? !!this.#options.dot;
9479
+ if (this.#root === this) {
9480
+ this.#flatten();
9481
+ this.#fillNegs();
9482
+ }
9483
+ if (!isExtglobAST(this)) {
9484
+ const noEmpty = this.isStart() && this.isEnd() && !this.#parts.some((s) => typeof s !== "string");
9485
+ const src = this.#parts.map((p) => {
9486
+ const [re2, _, hasMagic, uflag] = typeof p === "string" ? _a.#parseGlob(p, this.#hasMagic, noEmpty) : p.toRegExpSource(allowDot);
9487
+ this.#hasMagic = this.#hasMagic || hasMagic;
9488
+ this.#uflag = this.#uflag || uflag;
9489
+ return re2;
9490
+ }).join("");
9491
+ let start2 = "";
9492
+ if (this.isStart()) {
9493
+ if (typeof this.#parts[0] === "string") {
9494
+ const dotTravAllowed = this.#parts.length === 1 && justDots.has(this.#parts[0]);
9495
+ if (!dotTravAllowed) {
9496
+ const aps = addPatternStart;
9497
+ const needNoTrav = (
9498
+ // dots are allowed, and the pattern starts with [ or .
9499
+ dot && aps.has(src.charAt(0)) || // the pattern starts with \., and then [ or .
9500
+ src.startsWith("\\.") && aps.has(src.charAt(2)) || // the pattern starts with \.\., and then [ or .
9501
+ src.startsWith("\\.\\.") && aps.has(src.charAt(4))
9502
+ );
9503
+ const needNoDot = !dot && !allowDot && aps.has(src.charAt(0));
9504
+ start2 = needNoTrav ? startNoTraversal : needNoDot ? startNoDot : "";
9505
+ }
9506
+ }
9507
+ }
9508
+ let end = "";
9509
+ if (this.isEnd() && this.#root.#filledNegs && this.#parent?.type === "!") {
9510
+ end = "(?:$|\\/)";
9511
+ }
9512
+ const final2 = start2 + src + end;
9513
+ return [
9514
+ final2,
9515
+ unescape(src),
9516
+ this.#hasMagic = !!this.#hasMagic,
9517
+ this.#uflag
9518
+ ];
9519
+ }
9520
+ const repeated = this.type === "*" || this.type === "+";
9521
+ const start = this.type === "!" ? "(?:(?!(?:" : "(?:";
9522
+ let body = this.#partsToRegExp(dot);
9523
+ if (this.isStart() && this.isEnd() && !body && this.type !== "!") {
9524
+ const s = this.toString();
9525
+ const me = this;
9526
+ me.#parts = [s];
9527
+ me.type = null;
9528
+ me.#hasMagic = void 0;
9529
+ return [s, unescape(this.toString()), false, false];
9530
+ }
9531
+ let bodyDotAllowed = !repeated || allowDot || dot || !startNoDot ? "" : this.#partsToRegExp(true);
9532
+ if (bodyDotAllowed === body) {
9533
+ bodyDotAllowed = "";
9534
+ }
9535
+ if (bodyDotAllowed) {
9536
+ body = `(?:${body})(?:${bodyDotAllowed})*?`;
9537
+ }
9538
+ let final = "";
9539
+ if (this.type === "!" && this.#emptyExt) {
9540
+ final = (this.isStart() && !dot ? startNoDot : "") + starNoEmpty;
9541
+ } else {
9542
+ const close = this.type === "!" ? (
9543
+ // !() must match something,but !(x) can match ''
9544
+ "))" + (this.isStart() && !dot && !allowDot ? startNoDot : "") + star + ")"
9545
+ ) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && bodyDotAllowed ? ")" : this.type === "*" && bodyDotAllowed ? `)?` : `)${this.type}`;
9546
+ final = start + body + close;
9547
+ }
9548
+ return [
9549
+ final,
9550
+ unescape(body),
9551
+ this.#hasMagic = !!this.#hasMagic,
9552
+ this.#uflag
9553
+ ];
9554
+ }
9555
+ #flatten() {
9556
+ if (!isExtglobAST(this)) {
9557
+ for (const p of this.#parts) {
9558
+ if (typeof p === "object") {
9559
+ p.#flatten();
9560
+ }
9561
+ }
9562
+ } else {
9563
+ let iterations = 0;
9564
+ let done = false;
9565
+ do {
9566
+ done = true;
9567
+ for (let i = 0; i < this.#parts.length; i++) {
9568
+ const c = this.#parts[i];
9569
+ if (typeof c === "object") {
9570
+ c.#flatten();
9571
+ if (this.#canAdopt(c)) {
9572
+ done = false;
9573
+ this.#adopt(c, i);
9574
+ } else if (this.#canAdoptWithSpace(c)) {
9575
+ done = false;
9576
+ this.#adoptWithSpace(c, i);
9577
+ } else if (this.#canUsurp(c)) {
9578
+ done = false;
9579
+ this.#usurp(c);
9580
+ }
9581
+ }
9582
+ }
9583
+ } while (!done && ++iterations < 10);
9584
+ }
9585
+ this.#toString = void 0;
9586
+ }
9587
+ #partsToRegExp(dot) {
9588
+ return this.#parts.map((p) => {
9589
+ if (typeof p === "string") {
9590
+ throw new Error("string type in extglob ast??");
9591
+ }
9592
+ const [re2, _, _hasMagic, uflag] = p.toRegExpSource(dot);
9593
+ this.#uflag = this.#uflag || uflag;
9594
+ return re2;
9595
+ }).filter((p) => !(this.isStart() && this.isEnd()) || !!p).join("|");
9596
+ }
9597
+ static #parseGlob(glob, hasMagic, noEmpty = false) {
9598
+ let escaping = false;
9599
+ let re2 = "";
9600
+ let uflag = false;
9601
+ let inStar = false;
9602
+ for (let i = 0; i < glob.length; i++) {
9603
+ const c = glob.charAt(i);
9604
+ if (escaping) {
9605
+ escaping = false;
9606
+ re2 += (reSpecials.has(c) ? "\\" : "") + c;
9607
+ continue;
9608
+ }
9609
+ if (c === "*") {
9610
+ if (inStar)
9611
+ continue;
9612
+ inStar = true;
9613
+ re2 += noEmpty && /^[*]+$/.test(glob) ? starNoEmpty : star;
9614
+ hasMagic = true;
9615
+ continue;
9616
+ } else {
9617
+ inStar = false;
9618
+ }
9619
+ if (c === "\\") {
9620
+ if (i === glob.length - 1) {
9621
+ re2 += "\\\\";
9622
+ } else {
9623
+ escaping = true;
9624
+ }
9625
+ continue;
9626
+ }
9627
+ if (c === "[") {
9628
+ const [src, needUflag, consumed, magic] = parseClass(glob, i);
9629
+ if (consumed) {
9630
+ re2 += src;
9631
+ uflag = uflag || needUflag;
9632
+ i += consumed - 1;
9633
+ hasMagic = hasMagic || magic;
9634
+ continue;
9635
+ }
9636
+ }
9637
+ if (c === "?") {
9638
+ re2 += qmark;
9639
+ hasMagic = true;
9640
+ continue;
9641
+ }
9642
+ re2 += regExpEscape(c);
9643
+ }
9644
+ return [re2, unescape(glob), !!hasMagic, uflag];
9645
+ }
9646
+ };
9647
+ _a = AST;
9648
+
9649
+ // node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/escape.js
9650
+ var escape = (s, { windowsPathsNoEscape = false, magicalBraces = false } = {}) => {
9651
+ if (magicalBraces) {
9652
+ return windowsPathsNoEscape ? s.replace(/[?*()[\]{}]/g, "[$&]") : s.replace(/[?*()[\]\\{}]/g, "\\$&");
9653
+ }
9654
+ return windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
9655
+ };
9656
+
9657
+ // node_modules/.pnpm/minimatch@10.2.6/node_modules/minimatch/dist/esm/index.js
9658
+ var minimatch = (p, pattern, options = {}) => {
9659
+ assertValidPattern(pattern);
9660
+ if (!options.nocomment && pattern.charAt(0) === "#") {
9661
+ return false;
9662
+ }
9663
+ return new Minimatch(pattern, options).match(p);
9664
+ };
9665
+ var starDotExtRE = /^\*+([^+@!?*[(]*)$/;
9666
+ var starDotExtTest = (ext2) => (f) => !f.startsWith(".") && f.endsWith(ext2);
9667
+ var starDotExtTestDot = (ext2) => (f) => f.endsWith(ext2);
9668
+ var starDotExtTestNocase = (ext2) => {
9669
+ ext2 = ext2.toLowerCase();
9670
+ return (f) => !f.startsWith(".") && f.toLowerCase().endsWith(ext2);
9671
+ };
9672
+ var starDotExtTestNocaseDot = (ext2) => {
9673
+ ext2 = ext2.toLowerCase();
9674
+ return (f) => f.toLowerCase().endsWith(ext2);
9675
+ };
9676
+ var starDotStarRE = /^\*+\.\*+$/;
9677
+ var starDotStarTest = (f) => !f.startsWith(".") && f.includes(".");
9678
+ var starDotStarTestDot = (f) => f !== "." && f !== ".." && f.includes(".");
9679
+ var dotStarRE = /^\.\*+$/;
9680
+ var dotStarTest = (f) => f !== "." && f !== ".." && f.startsWith(".");
9681
+ var starRE = /^\*+$/;
9682
+ var starTest = (f) => f.length !== 0 && !f.startsWith(".");
9683
+ var starTestDot = (f) => f.length !== 0 && f !== "." && f !== "..";
9684
+ var qmarksRE = /^\?+([^+@!?*[(]*)?$/;
9685
+ var qmarksTestNocase = ([$0, ext2 = ""]) => {
9686
+ const noext = qmarksTestNoExt([$0]);
9687
+ if (!ext2)
9688
+ return noext;
9689
+ ext2 = ext2.toLowerCase();
9690
+ return (f) => noext(f) && f.toLowerCase().endsWith(ext2);
9691
+ };
9692
+ var qmarksTestNocaseDot = ([$0, ext2 = ""]) => {
9693
+ const noext = qmarksTestNoExtDot([$0]);
9694
+ if (!ext2)
9695
+ return noext;
9696
+ ext2 = ext2.toLowerCase();
9697
+ return (f) => noext(f) && f.toLowerCase().endsWith(ext2);
9698
+ };
9699
+ var qmarksTestDot = ([$0, ext2 = ""]) => {
9700
+ const noext = qmarksTestNoExtDot([$0]);
9701
+ return !ext2 ? noext : (f) => noext(f) && f.endsWith(ext2);
9702
+ };
9703
+ var qmarksTest = ([$0, ext2 = ""]) => {
9704
+ const noext = qmarksTestNoExt([$0]);
9705
+ return !ext2 ? noext : (f) => noext(f) && f.endsWith(ext2);
9706
+ };
9707
+ var qmarksTestNoExt = ([$0]) => {
9708
+ const len = $0.length;
9709
+ return (f) => f.length === len && !f.startsWith(".");
9710
+ };
9711
+ var qmarksTestNoExtDot = ([$0]) => {
9712
+ const len = $0.length;
9713
+ return (f) => f.length === len && f !== "." && f !== "..";
9714
+ };
9715
+ var defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
9716
+ var path = {
9717
+ win32: { sep: "\\" },
9718
+ posix: { sep: "/" }
9719
+ };
9720
+ var sep = defaultPlatform === "win32" ? path.win32.sep : path.posix.sep;
9721
+ minimatch.sep = sep;
9722
+ var GLOBSTAR = /* @__PURE__ */ Symbol("globstar **");
9723
+ minimatch.GLOBSTAR = GLOBSTAR;
9724
+ var qmark2 = "[^/]";
9725
+ var star2 = qmark2 + "*?";
9726
+ var twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";
9727
+ var twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?";
9728
+ var filter = (pattern, options = {}) => (p) => minimatch(p, pattern, options);
9729
+ minimatch.filter = filter;
9730
+ var ext = (a, b = {}) => Object.assign({}, a, b);
9731
+ var defaults = (def) => {
9732
+ if (!def || typeof def !== "object" || !Object.keys(def).length) {
9733
+ return minimatch;
9734
+ }
9735
+ const orig = minimatch;
9736
+ const m = (p, pattern, options = {}) => orig(p, pattern, ext(def, options));
9737
+ return Object.assign(m, {
9738
+ Minimatch: class Minimatch extends orig.Minimatch {
9739
+ constructor(pattern, options = {}) {
9740
+ super(pattern, ext(def, options));
9741
+ }
9742
+ static defaults(options) {
9743
+ return orig.defaults(ext(def, options)).Minimatch;
9744
+ }
9745
+ },
9746
+ AST: class AST extends orig.AST {
9747
+ /* c8 ignore start */
9748
+ constructor(type, parent, options = {}) {
9749
+ super(type, parent, ext(def, options));
9750
+ }
9751
+ /* c8 ignore stop */
9752
+ static fromGlob(pattern, options = {}) {
9753
+ return orig.AST.fromGlob(pattern, ext(def, options));
9754
+ }
9755
+ },
9756
+ unescape: (s, options = {}) => orig.unescape(s, ext(def, options)),
9757
+ escape: (s, options = {}) => orig.escape(s, ext(def, options)),
9758
+ filter: (pattern, options = {}) => orig.filter(pattern, ext(def, options)),
9759
+ defaults: (options) => orig.defaults(ext(def, options)),
9760
+ makeRe: (pattern, options = {}) => orig.makeRe(pattern, ext(def, options)),
9761
+ braceExpand: (pattern, options = {}) => orig.braceExpand(pattern, ext(def, options)),
9762
+ match: (list, pattern, options = {}) => orig.match(list, pattern, ext(def, options)),
9763
+ sep: orig.sep,
9764
+ GLOBSTAR
9765
+ });
9766
+ };
9767
+ minimatch.defaults = defaults;
9768
+ var braceExpand = (pattern, options = {}) => {
9769
+ assertValidPattern(pattern);
9770
+ if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) {
9771
+ return [pattern];
9772
+ }
9773
+ return expand(pattern, { max: options.braceExpandMax });
9774
+ };
9775
+ minimatch.braceExpand = braceExpand;
9776
+ var makeRe = (pattern, options = {}) => new Minimatch(pattern, options).makeRe();
9777
+ minimatch.makeRe = makeRe;
9778
+ var match = (list, pattern, options = {}) => {
9779
+ const mm = new Minimatch(pattern, options);
9780
+ list = list.filter((f) => mm.match(f));
9781
+ if (mm.options.nonull && !list.length) {
9782
+ list.push(pattern);
9783
+ }
9784
+ return list;
9785
+ };
9786
+ minimatch.match = match;
9787
+ var globMagic = /[?*]|[+@!]\(.*?\)|\[|\]/;
9788
+ var regExpEscape2 = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
9789
+ var Minimatch = class {
9790
+ options;
9791
+ set;
9792
+ pattern;
9793
+ windowsPathsNoEscape;
9794
+ nonegate;
9795
+ negate;
9796
+ comment;
9797
+ empty;
9798
+ preserveMultipleSlashes;
9799
+ partial;
9800
+ globSet;
9801
+ globParts;
9802
+ nocase;
9803
+ isWindows;
9804
+ platform;
9805
+ windowsNoMagicRoot;
9806
+ maxGlobstarRecursion;
9807
+ regexp;
9808
+ constructor(pattern, options = {}) {
9809
+ assertValidPattern(pattern);
9810
+ options = options || {};
9811
+ this.options = options;
9812
+ this.maxGlobstarRecursion = options.maxGlobstarRecursion ?? 200;
9813
+ this.pattern = pattern;
9814
+ this.platform = options.platform || defaultPlatform;
9815
+ this.isWindows = this.platform === "win32";
9816
+ const awe = "allowWindowsEscape";
9817
+ this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || options[awe] === false;
9818
+ if (this.windowsPathsNoEscape) {
9819
+ this.pattern = this.pattern.replace(/\\/g, "/");
9820
+ }
9821
+ this.preserveMultipleSlashes = !!options.preserveMultipleSlashes;
9822
+ this.regexp = null;
9823
+ this.negate = false;
9824
+ this.nonegate = !!options.nonegate;
9825
+ this.comment = false;
9826
+ this.empty = false;
9827
+ this.partial = !!options.partial;
9828
+ this.nocase = !!this.options.nocase;
9829
+ this.windowsNoMagicRoot = options.windowsNoMagicRoot !== void 0 ? options.windowsNoMagicRoot : !!(this.isWindows && this.nocase);
9830
+ this.globSet = [];
9831
+ this.globParts = [];
9832
+ this.set = [];
9833
+ this.make();
9834
+ }
9835
+ hasMagic() {
9836
+ if (this.options.magicalBraces && this.set.length > 1) {
9837
+ return true;
9838
+ }
9839
+ for (const pattern of this.set) {
9840
+ for (const part of pattern) {
9841
+ if (typeof part !== "string")
9842
+ return true;
9843
+ }
9844
+ }
9845
+ return false;
9846
+ }
9847
+ debug(..._) {
9848
+ }
9849
+ make() {
9850
+ const pattern = this.pattern;
9851
+ const options = this.options;
9852
+ if (!options.nocomment && pattern.charAt(0) === "#") {
9853
+ this.comment = true;
9854
+ return;
9855
+ }
9856
+ if (!pattern) {
9857
+ this.empty = true;
9858
+ return;
9859
+ }
9860
+ this.parseNegate();
9861
+ this.globSet = [...new Set(this.braceExpand())];
9862
+ if (options.debug) {
9863
+ this.debug = (...args) => console.error(...args);
9864
+ }
9865
+ this.debug(this.pattern, this.globSet);
9866
+ const rawGlobParts = this.globSet.map((s) => this.slashSplit(s));
9867
+ this.globParts = this.preprocess(rawGlobParts);
9868
+ this.debug(this.pattern, this.globParts);
9869
+ let set = this.globParts.map((s, _, __) => {
9870
+ if (this.isWindows && this.windowsNoMagicRoot) {
9871
+ const isUNC = s[0] === "" && s[1] === "" && (s[2] === "?" || !globMagic.test(s[2])) && !globMagic.test(s[3]);
9872
+ const isDrive = /^[a-z]:/i.test(s[0]);
9873
+ if (isUNC) {
9874
+ return [
9875
+ ...s.slice(0, 4),
9876
+ ...s.slice(4).map((ss) => this.parse(ss))
9877
+ ];
9878
+ } else if (isDrive) {
9879
+ return [s[0], ...s.slice(1).map((ss) => this.parse(ss))];
9880
+ }
9881
+ }
9882
+ return s.map((ss) => this.parse(ss));
9883
+ });
9884
+ this.debug(this.pattern, set);
9885
+ this.set = set.filter((s) => s.indexOf(false) === -1);
9886
+ if (this.isWindows) {
9887
+ for (let i = 0; i < this.set.length; i++) {
9888
+ const p = this.set[i];
9889
+ if (p[0] === "" && p[1] === "" && this.globParts[i][2] === "?" && typeof p[3] === "string" && /^[a-z]:$/i.test(p[3])) {
9890
+ p[2] = "?";
9891
+ }
9892
+ }
9893
+ }
9894
+ this.debug(this.pattern, this.set);
9895
+ }
9896
+ // various transforms to equivalent pattern sets that are
9897
+ // faster to process in a filesystem walk. The goal is to
9898
+ // eliminate what we can, and push all ** patterns as far
9899
+ // to the right as possible, even if it increases the number
9900
+ // of patterns that we have to process.
9901
+ preprocess(globParts) {
9902
+ if (this.options.noglobstar) {
9903
+ for (const partset of globParts) {
9904
+ for (let j = 0; j < partset.length; j++) {
9905
+ if (partset[j] === "**") {
9906
+ partset[j] = "*";
9907
+ }
9908
+ }
9909
+ }
9910
+ }
9911
+ const { optimizationLevel = 1 } = this.options;
9912
+ if (optimizationLevel >= 2) {
9913
+ globParts = this.firstPhasePreProcess(globParts);
9914
+ globParts = this.secondPhasePreProcess(globParts);
9915
+ } else if (optimizationLevel >= 1) {
9916
+ globParts = this.levelOneOptimize(globParts);
9917
+ } else {
9918
+ globParts = this.adjascentGlobstarOptimize(globParts);
9919
+ }
9920
+ return globParts;
9921
+ }
9922
+ // just get rid of adjascent ** portions
9923
+ adjascentGlobstarOptimize(globParts) {
9924
+ return globParts.map((parts) => {
9925
+ let gs = -1;
9926
+ while (-1 !== (gs = parts.indexOf("**", gs + 1))) {
9927
+ let i = gs;
9928
+ while (parts[i + 1] === "**") {
9929
+ i++;
9930
+ }
9931
+ if (i !== gs) {
9932
+ parts.splice(gs, i - gs);
9933
+ }
9934
+ }
9935
+ return parts;
9936
+ });
9937
+ }
9938
+ // get rid of adjascent ** and resolve .. portions
9939
+ levelOneOptimize(globParts) {
9940
+ return globParts.map((parts) => {
9941
+ parts = parts.reduce((set, part) => {
9942
+ const prev = set[set.length - 1];
9943
+ if (part === "**" && prev === "**") {
9944
+ return set;
9945
+ }
9946
+ if (part === "..") {
9947
+ if (prev && prev !== ".." && prev !== "." && prev !== "**") {
9948
+ set.pop();
9949
+ return set;
9950
+ }
9951
+ }
9952
+ set.push(part);
9953
+ return set;
9954
+ }, []);
9955
+ return parts.length === 0 ? [""] : parts;
9956
+ });
9957
+ }
9958
+ levelTwoFileOptimize(parts) {
9959
+ if (!Array.isArray(parts)) {
9960
+ parts = this.slashSplit(parts);
9961
+ }
9962
+ let didSomething = false;
9963
+ do {
9964
+ didSomething = false;
9965
+ if (!this.preserveMultipleSlashes) {
9966
+ for (let i = 1; i < parts.length - 1; i++) {
9967
+ const p = parts[i];
9968
+ if (i === 1 && p === "" && parts[0] === "")
9969
+ continue;
9970
+ if (p === "." || p === "") {
9971
+ didSomething = true;
9972
+ parts.splice(i, 1);
9973
+ i--;
9974
+ }
9975
+ }
9976
+ if (parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "")) {
9977
+ didSomething = true;
9978
+ parts.pop();
9979
+ }
9980
+ }
9981
+ let dd = 0;
9982
+ while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
9983
+ const p = parts[dd - 1];
9984
+ if (p && p !== "." && p !== ".." && p !== "**" && !(this.isWindows && /^[a-z]:$/i.test(p))) {
9985
+ didSomething = true;
9986
+ parts.splice(dd - 1, 2);
9987
+ dd -= 2;
9988
+ }
9989
+ }
9990
+ } while (didSomething);
9991
+ return parts.length === 0 ? [""] : parts;
9992
+ }
9993
+ // First phase: single-pattern processing
9994
+ // <pre> is 1 or more portions
9995
+ // <rest> is 1 or more portions
9996
+ // <p> is any portion other than ., .., '', or **
9997
+ // <e> is . or ''
9998
+ //
9999
+ // **/.. is *brutal* for filesystem walking performance, because
10000
+ // it effectively resets the recursive walk each time it occurs,
10001
+ // and ** cannot be reduced out by a .. pattern part like a regexp
10002
+ // or most strings (other than .., ., and '') can be.
10003
+ //
10004
+ // <pre>/**/../<p>/<p>/<rest> -> {<pre>/../<p>/<p>/<rest>,<pre>/**/<p>/<p>/<rest>}
10005
+ // <pre>/<e>/<rest> -> <pre>/<rest>
10006
+ // <pre>/<p>/../<rest> -> <pre>/<rest>
10007
+ // **/**/<rest> -> **/<rest>
10008
+ //
10009
+ // **/*/<rest> -> */**/<rest> <== not valid because ** doesn't follow
10010
+ // this WOULD be allowed if ** did follow symlinks, or * didn't
10011
+ firstPhasePreProcess(globParts) {
10012
+ let didSomething = false;
10013
+ do {
10014
+ didSomething = false;
10015
+ for (let parts of globParts) {
10016
+ let gs = -1;
10017
+ while (-1 !== (gs = parts.indexOf("**", gs + 1))) {
10018
+ let gss = gs;
10019
+ while (parts[gss + 1] === "**") {
10020
+ gss++;
10021
+ }
10022
+ if (gss > gs) {
10023
+ parts.splice(gs + 1, gss - gs);
10024
+ }
10025
+ let next = parts[gs + 1];
10026
+ const p = parts[gs + 2];
10027
+ const p2 = parts[gs + 3];
10028
+ if (next !== "..")
10029
+ continue;
10030
+ if (!p || p === "." || p === ".." || !p2 || p2 === "." || p2 === "..") {
10031
+ continue;
10032
+ }
10033
+ didSomething = true;
10034
+ parts.splice(gs, 1);
10035
+ const other = parts.slice(0);
10036
+ other[gs] = "**";
10037
+ globParts.push(other);
10038
+ gs--;
10039
+ }
10040
+ if (!this.preserveMultipleSlashes) {
10041
+ for (let i = 1; i < parts.length - 1; i++) {
10042
+ const p = parts[i];
10043
+ if (i === 1 && p === "" && parts[0] === "")
10044
+ continue;
10045
+ if (p === "." || p === "") {
10046
+ didSomething = true;
10047
+ parts.splice(i, 1);
10048
+ i--;
10049
+ }
10050
+ }
10051
+ if (parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "")) {
10052
+ didSomething = true;
10053
+ parts.pop();
10054
+ }
10055
+ }
10056
+ let dd = 0;
10057
+ while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
10058
+ const p = parts[dd - 1];
10059
+ if (p && p !== "." && p !== ".." && p !== "**") {
10060
+ didSomething = true;
10061
+ const needDot = dd === 1 && parts[dd + 1] === "**";
10062
+ const splin = needDot ? ["."] : [];
10063
+ parts.splice(dd - 1, 2, ...splin);
10064
+ if (parts.length === 0)
10065
+ parts.push("");
10066
+ dd -= 2;
10067
+ }
10068
+ }
10069
+ }
10070
+ } while (didSomething);
10071
+ return globParts;
10072
+ }
10073
+ // second phase: multi-pattern dedupes
10074
+ // {<pre>/*/<rest>,<pre>/<p>/<rest>} -> <pre>/*/<rest>
10075
+ // {<pre>/<rest>,<pre>/<rest>} -> <pre>/<rest>
10076
+ // {<pre>/**/<rest>,<pre>/<rest>} -> <pre>/**/<rest>
10077
+ //
10078
+ // {<pre>/**/<rest>,<pre>/**/<p>/<rest>} -> <pre>/**/<rest>
10079
+ // ^-- not valid because ** doens't follow symlinks
10080
+ secondPhasePreProcess(globParts) {
10081
+ for (let i = 0; i < globParts.length - 1; i++) {
10082
+ for (let j = i + 1; j < globParts.length; j++) {
10083
+ const matched = this.partsMatch(globParts[i], globParts[j], !this.preserveMultipleSlashes);
10084
+ if (matched) {
10085
+ globParts[i] = [];
10086
+ globParts[j] = matched;
10087
+ break;
10088
+ }
10089
+ }
10090
+ }
10091
+ return globParts.filter((gs) => gs.length);
10092
+ }
10093
+ partsMatch(a, b, emptyGSMatch = false) {
10094
+ let ai = 0;
10095
+ let bi = 0;
10096
+ let result = [];
10097
+ let which = "";
10098
+ while (ai < a.length && bi < b.length) {
10099
+ if (a[ai] === b[bi]) {
10100
+ result.push(which === "b" ? b[bi] : a[ai]);
10101
+ ai++;
10102
+ bi++;
10103
+ } else if (emptyGSMatch && a[ai] === "**" && b[bi] === a[ai + 1]) {
10104
+ result.push(a[ai]);
10105
+ ai++;
10106
+ } else if (emptyGSMatch && b[bi] === "**" && a[ai] === b[bi + 1]) {
10107
+ result.push(b[bi]);
10108
+ bi++;
10109
+ } else if (a[ai] === "*" && b[bi] && (this.options.dot || !b[bi].startsWith(".")) && b[bi] !== "**") {
10110
+ if (which === "b")
10111
+ return false;
10112
+ which = "a";
10113
+ result.push(a[ai]);
10114
+ ai++;
10115
+ bi++;
10116
+ } else if (b[bi] === "*" && a[ai] && (this.options.dot || !a[ai].startsWith(".")) && a[ai] !== "**") {
10117
+ if (which === "a")
10118
+ return false;
10119
+ which = "b";
10120
+ result.push(b[bi]);
10121
+ ai++;
10122
+ bi++;
10123
+ } else {
10124
+ return false;
10125
+ }
10126
+ }
10127
+ return a.length === b.length && result;
10128
+ }
10129
+ parseNegate() {
10130
+ if (this.nonegate)
10131
+ return;
10132
+ const pattern = this.pattern;
10133
+ let negate = false;
10134
+ let negateOffset = 0;
10135
+ for (let i = 0; i < pattern.length && pattern.charAt(i) === "!"; i++) {
10136
+ negate = !negate;
10137
+ negateOffset++;
10138
+ }
10139
+ if (negateOffset)
10140
+ this.pattern = pattern.slice(negateOffset);
10141
+ this.negate = negate;
10142
+ }
10143
+ // set partial to true to test if, for example,
10144
+ // "/a/b" matches the start of "/*/b/*/d"
10145
+ // Partial means, if you run out of file before you run
10146
+ // out of pattern, then that's fine, as long as all
10147
+ // the parts match.
10148
+ matchOne(file, pattern, partial = false) {
10149
+ let fileStartIndex = 0;
10150
+ let patternStartIndex = 0;
10151
+ if (this.isWindows) {
10152
+ const fileDrive = typeof file[0] === "string" && /^[a-z]:$/i.test(file[0]);
10153
+ const fileUNC = !fileDrive && file[0] === "" && file[1] === "" && file[2] === "?" && /^[a-z]:$/i.test(file[3]);
10154
+ const patternDrive = typeof pattern[0] === "string" && /^[a-z]:$/i.test(pattern[0]);
10155
+ const patternUNC = !patternDrive && pattern[0] === "" && pattern[1] === "" && pattern[2] === "?" && typeof pattern[3] === "string" && /^[a-z]:$/i.test(pattern[3]);
10156
+ const fdi = fileUNC ? 3 : fileDrive ? 0 : void 0;
10157
+ const pdi = patternUNC ? 3 : patternDrive ? 0 : void 0;
10158
+ if (typeof fdi === "number" && typeof pdi === "number") {
10159
+ const [fd, pd] = [
10160
+ file[fdi],
10161
+ pattern[pdi]
10162
+ ];
10163
+ if (fd.toLowerCase() === pd.toLowerCase()) {
10164
+ pattern[pdi] = fd;
10165
+ patternStartIndex = pdi;
10166
+ fileStartIndex = fdi;
10167
+ }
10168
+ }
10169
+ }
10170
+ const { optimizationLevel = 1 } = this.options;
10171
+ if (optimizationLevel >= 2) {
10172
+ file = this.levelTwoFileOptimize(file);
10173
+ }
10174
+ if (pattern.includes(GLOBSTAR)) {
10175
+ return this.#matchGlobstar(file, pattern, partial, fileStartIndex, patternStartIndex);
10176
+ }
10177
+ return this.#matchOne(file, pattern, partial, fileStartIndex, patternStartIndex);
10178
+ }
10179
+ #matchGlobstar(file, pattern, partial, fileIndex, patternIndex) {
10180
+ const firstgs = pattern.indexOf(GLOBSTAR, patternIndex);
10181
+ const lastgs = pattern.lastIndexOf(GLOBSTAR);
10182
+ const [head, body, tail] = partial ? [
10183
+ pattern.slice(patternIndex, firstgs),
10184
+ pattern.slice(firstgs + 1),
10185
+ []
10186
+ ] : [
10187
+ pattern.slice(patternIndex, firstgs),
10188
+ pattern.slice(firstgs + 1, lastgs),
10189
+ pattern.slice(lastgs + 1)
10190
+ ];
10191
+ if (head.length) {
10192
+ const fileHead = file.slice(fileIndex, fileIndex + head.length);
10193
+ if (!this.#matchOne(fileHead, head, partial, 0, 0)) {
10194
+ return false;
10195
+ }
10196
+ fileIndex += head.length;
10197
+ patternIndex += head.length;
10198
+ }
10199
+ let fileTailMatch = 0;
10200
+ if (tail.length) {
10201
+ if (tail.length + fileIndex > file.length)
10202
+ return false;
10203
+ let tailStart = file.length - tail.length;
10204
+ if (this.#matchOne(file, tail, partial, tailStart, 0)) {
10205
+ fileTailMatch = tail.length;
10206
+ } else {
10207
+ if (file[file.length - 1] !== "" || fileIndex + tail.length === file.length) {
10208
+ return false;
10209
+ }
10210
+ tailStart--;
10211
+ if (!this.#matchOne(file, tail, partial, tailStart, 0)) {
10212
+ return false;
10213
+ }
10214
+ fileTailMatch = tail.length + 1;
10215
+ }
10216
+ }
10217
+ if (!body.length) {
10218
+ let sawSome = !!fileTailMatch;
10219
+ for (let i2 = fileIndex; i2 < file.length - fileTailMatch; i2++) {
10220
+ const f = String(file[i2]);
10221
+ sawSome = true;
10222
+ if (f === "." || f === ".." || !this.options.dot && f.startsWith(".")) {
10223
+ return false;
10224
+ }
10225
+ }
10226
+ return partial || sawSome;
10227
+ }
10228
+ const bodySegments = [[[], 0]];
10229
+ let currentBody = bodySegments[0];
10230
+ let nonGsParts = 0;
10231
+ const nonGsPartsSums = [0];
10232
+ for (const b of body) {
10233
+ if (b === GLOBSTAR) {
10234
+ nonGsPartsSums.push(nonGsParts);
10235
+ currentBody = [[], 0];
10236
+ bodySegments.push(currentBody);
10237
+ } else {
10238
+ currentBody[0].push(b);
10239
+ nonGsParts++;
10240
+ }
10241
+ }
10242
+ let i = bodySegments.length - 1;
10243
+ const fileLength = file.length - fileTailMatch;
10244
+ for (const b of bodySegments) {
10245
+ b[1] = fileLength - (nonGsPartsSums[i--] + b[0].length);
10246
+ }
10247
+ return !!this.#matchGlobStarBodySections(file, bodySegments, fileIndex, 0, partial, 0, !!fileTailMatch);
10248
+ }
10249
+ // return false for "nope, not matching"
10250
+ // return null for "not matching, cannot keep trying"
10251
+ #matchGlobStarBodySections(file, bodySegments, fileIndex, bodyIndex, partial, globStarDepth, sawTail) {
10252
+ const bs = bodySegments[bodyIndex];
10253
+ if (!bs) {
10254
+ for (let i = fileIndex; i < file.length; i++) {
10255
+ sawTail = true;
10256
+ const f = file[i];
10257
+ if (f === "." || f === ".." || !this.options.dot && f.startsWith(".")) {
10258
+ return false;
10259
+ }
10260
+ }
10261
+ return sawTail;
10262
+ }
10263
+ const [body, after] = bs;
10264
+ while (fileIndex <= after) {
10265
+ const m = this.#matchOne(file.slice(0, fileIndex + body.length), body, partial, fileIndex, 0);
10266
+ if (m && globStarDepth < this.maxGlobstarRecursion) {
10267
+ const sub = this.#matchGlobStarBodySections(file, bodySegments, fileIndex + body.length, bodyIndex + 1, partial, globStarDepth + 1, sawTail);
10268
+ if (sub !== false) {
10269
+ return sub;
10270
+ }
10271
+ }
10272
+ const f = file[fileIndex];
10273
+ if (f === "." || f === ".." || !this.options.dot && f.startsWith(".")) {
10274
+ return false;
10275
+ }
10276
+ fileIndex++;
10277
+ }
10278
+ return partial || null;
10279
+ }
10280
+ #matchOne(file, pattern, partial, fileIndex, patternIndex) {
10281
+ let fi;
10282
+ let pi;
10283
+ let pl;
10284
+ let fl;
10285
+ for (fi = fileIndex, pi = patternIndex, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
10286
+ this.debug("matchOne loop");
10287
+ let p = pattern[pi];
10288
+ let f = file[fi];
10289
+ this.debug(pattern, p, f);
10290
+ if (p === false || p === GLOBSTAR) {
10291
+ return false;
10292
+ }
10293
+ let hit;
10294
+ if (typeof p === "string") {
10295
+ hit = f === p;
10296
+ this.debug("string match", p, f, hit);
10297
+ } else {
10298
+ hit = p.test(f);
10299
+ this.debug("pattern match", p, f, hit);
10300
+ }
10301
+ if (!hit)
10302
+ return false;
10303
+ }
10304
+ if (fi === fl && pi === pl) {
10305
+ return true;
10306
+ } else if (fi === fl) {
10307
+ return partial;
10308
+ } else if (pi === pl) {
10309
+ return fi === fl - 1 && file[fi] === "";
10310
+ } else {
10311
+ throw new Error("wtf?");
10312
+ }
10313
+ }
10314
+ braceExpand() {
10315
+ return braceExpand(this.pattern, this.options);
10316
+ }
10317
+ parse(pattern) {
10318
+ assertValidPattern(pattern);
10319
+ const options = this.options;
10320
+ if (pattern === "**")
10321
+ return GLOBSTAR;
10322
+ if (pattern === "")
10323
+ return "";
10324
+ let m;
10325
+ let fastTest = null;
10326
+ if (m = pattern.match(starRE)) {
10327
+ fastTest = options.dot ? starTestDot : starTest;
10328
+ } else if (m = pattern.match(starDotExtRE)) {
10329
+ fastTest = (options.nocase ? options.dot ? starDotExtTestNocaseDot : starDotExtTestNocase : options.dot ? starDotExtTestDot : starDotExtTest)(m[1]);
10330
+ } else if (m = pattern.match(qmarksRE)) {
10331
+ fastTest = (options.nocase ? options.dot ? qmarksTestNocaseDot : qmarksTestNocase : options.dot ? qmarksTestDot : qmarksTest)(m);
10332
+ } else if (m = pattern.match(starDotStarRE)) {
10333
+ fastTest = options.dot ? starDotStarTestDot : starDotStarTest;
10334
+ } else if (m = pattern.match(dotStarRE)) {
10335
+ fastTest = dotStarTest;
10336
+ }
10337
+ const re2 = AST.fromGlob(pattern, this.options).toMMPattern();
10338
+ if (fastTest && typeof re2 === "object") {
10339
+ Reflect.defineProperty(re2, "test", { value: fastTest });
10340
+ }
10341
+ return re2;
10342
+ }
10343
+ makeRe() {
10344
+ if (this.regexp || this.regexp === false)
10345
+ return this.regexp;
10346
+ const set = this.set;
10347
+ if (!set.length) {
10348
+ this.regexp = false;
10349
+ return this.regexp;
10350
+ }
10351
+ const options = this.options;
10352
+ const twoStar = options.noglobstar ? star2 : options.dot ? twoStarDot : twoStarNoDot;
10353
+ const flags = new Set(options.nocase ? ["i"] : []);
10354
+ let re2 = set.map((pattern) => {
10355
+ const pp = pattern.map((p) => {
10356
+ if (p instanceof RegExp) {
10357
+ for (const f of p.flags.split(""))
10358
+ flags.add(f);
10359
+ }
10360
+ return typeof p === "string" ? regExpEscape2(p) : p === GLOBSTAR ? GLOBSTAR : p._src;
10361
+ });
10362
+ pp.forEach((p, i) => {
10363
+ const next = pp[i + 1];
10364
+ const prev = pp[i - 1];
10365
+ if (p !== GLOBSTAR || prev === GLOBSTAR) {
10366
+ return;
10367
+ }
10368
+ if (prev === void 0) {
10369
+ if (next !== void 0 && next !== GLOBSTAR) {
10370
+ pp[i + 1] = "(?:\\/|" + twoStar + "\\/)?" + next;
10371
+ } else {
10372
+ pp[i] = twoStar;
10373
+ }
10374
+ } else if (next === void 0) {
10375
+ pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + ")?";
10376
+ } else if (next !== GLOBSTAR) {
10377
+ pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + "\\/)" + next;
10378
+ pp[i + 1] = GLOBSTAR;
10379
+ }
10380
+ });
10381
+ const filtered = pp.filter((p) => p !== GLOBSTAR);
10382
+ if (this.partial && filtered.length >= 1) {
10383
+ const prefixes = [];
10384
+ for (let i = 1; i <= filtered.length; i++) {
10385
+ prefixes.push(filtered.slice(0, i).join("/"));
10386
+ }
10387
+ return "(?:" + prefixes.join("|") + ")";
10388
+ }
10389
+ return filtered.join("/");
10390
+ }).join("|");
10391
+ const [open2, close] = set.length > 1 ? ["(?:", ")"] : ["", ""];
10392
+ re2 = "^" + open2 + re2 + close + "$";
10393
+ if (this.partial) {
10394
+ re2 = "^(?:\\/|" + open2 + re2.slice(1, -1) + close + ")$";
10395
+ }
10396
+ if (this.negate)
10397
+ re2 = "^(?!" + re2 + ").+$";
10398
+ try {
10399
+ this.regexp = new RegExp(re2, [...flags].join(""));
10400
+ } catch {
10401
+ this.regexp = false;
10402
+ }
10403
+ return this.regexp;
10404
+ }
10405
+ slashSplit(p) {
10406
+ if (this.preserveMultipleSlashes) {
10407
+ return p.split("/");
10408
+ } else if (this.isWindows && /^\/\/[^/]+/.test(p)) {
10409
+ return ["", ...p.split(/\/+/)];
10410
+ } else {
10411
+ return p.split(/\/+/);
10412
+ }
10413
+ }
10414
+ match(f, partial = this.partial) {
10415
+ this.debug("match", f, this.pattern);
10416
+ if (this.comment) {
10417
+ return false;
10418
+ }
10419
+ if (this.empty) {
10420
+ return f === "";
10421
+ }
10422
+ if (f === "/" && partial) {
10423
+ return true;
10424
+ }
10425
+ const options = this.options;
10426
+ if (this.isWindows) {
10427
+ f = f.split("\\").join("/");
10428
+ }
10429
+ const ff = this.slashSplit(f);
10430
+ this.debug(this.pattern, "split", ff);
10431
+ const set = this.set;
10432
+ this.debug(this.pattern, "set", set);
10433
+ let filename = ff[ff.length - 1];
10434
+ if (!filename) {
10435
+ for (let i = ff.length - 2; !filename && i >= 0; i--) {
10436
+ filename = ff[i];
10437
+ }
10438
+ }
10439
+ for (const pattern of set) {
10440
+ let file = ff;
10441
+ if (options.matchBase && pattern.length === 1) {
10442
+ file = [filename];
10443
+ }
10444
+ const hit = this.matchOne(file, pattern, partial);
10445
+ if (hit) {
10446
+ if (options.flipNegate) {
10447
+ return true;
10448
+ }
10449
+ return !this.negate;
10450
+ }
10451
+ }
10452
+ if (options.flipNegate) {
10453
+ return false;
10454
+ }
10455
+ return this.negate;
10456
+ }
10457
+ static defaults(def) {
10458
+ return minimatch.defaults(def).Minimatch;
10459
+ }
10460
+ };
10461
+ minimatch.AST = AST;
10462
+ minimatch.Minimatch = Minimatch;
10463
+ minimatch.escape = escape;
10464
+ minimatch.unescape = unescape;
10465
+
8596
10466
  // src/documents/profile.ts
8597
10467
  var import_yaml = __toESM(require_dist(), 1);
8598
10468
 
@@ -9152,11 +11022,11 @@ function searchMcpTools(session, query, opts = {}) {
9152
11022
  return matches.sort((a, b) => b.score - a.score || a.ref.localeCompare(b.ref)).slice(0, opts.limit ?? 5);
9153
11023
  }
9154
11024
  async function readSession() {
9155
- const path = sessionPolicyPath();
9156
- const data = await readFile(path, "utf8");
11025
+ const path2 = sessionPolicyPath();
11026
+ const data = await readFile(path2, "utf8");
9157
11027
  const parsed = JSON.parse(data);
9158
11028
  if (parsed.version !== 1 || !Array.isArray(parsed.servers)) {
9159
- throw new Error(`Invalid MCP session policy at ${path}`);
11029
+ throw new Error(`Invalid MCP session policy at ${path2}`);
9160
11030
  }
9161
11031
  return parsed;
9162
11032
  }
@@ -9209,11 +11079,11 @@ async function readCachedCatalog(server) {
9209
11079
  async function writeCachedCatalog(server, tools) {
9210
11080
  const directory = join2(sessionRoot(), ".pi", "mcp-catalogs");
9211
11081
  await mkdir(directory, { recursive: true });
9212
- const path = catalogCachePath(server);
9213
- const temporary = `${path}.${process.pid}.${randomUUID()}.tmp`;
11082
+ const path2 = catalogCachePath(server);
11083
+ const temporary = `${path2}.${process.pid}.${randomUUID()}.tmp`;
9214
11084
  await writeFile(temporary, `${JSON.stringify({ tools })}
9215
11085
  `, { mode: 384 });
9216
- await rename(temporary, path);
11086
+ await rename(temporary, path2);
9217
11087
  }
9218
11088
  function processExists(pid) {
9219
11089
  try {
@@ -9223,9 +11093,9 @@ function processExists(pid) {
9223
11093
  return error.code === "EPERM";
9224
11094
  }
9225
11095
  }
9226
- async function catalogLockIsStale(path, timeoutMs) {
11096
+ async function catalogLockIsStale(path2, timeoutMs) {
9227
11097
  try {
9228
- const owner = JSON.parse(await readFile(path, "utf8"));
11098
+ const owner = JSON.parse(await readFile(path2, "utf8"));
9229
11099
  if (typeof owner.pid === "number" && Number.isInteger(owner.pid) && owner.pid > 0 && typeof owner.createdAt === "number" && Number.isFinite(owner.createdAt)) {
9230
11100
  return !processExists(owner.pid) || Date.now() - owner.createdAt > timeoutMs + CATALOG_LOCK_INCOMPLETE_GRACE_MS;
9231
11101
  }
@@ -9233,16 +11103,16 @@ async function catalogLockIsStale(path, timeoutMs) {
9233
11103
  if (error.code === "ENOENT") return false;
9234
11104
  }
9235
11105
  try {
9236
- const metadata = await stat(path);
11106
+ const metadata = await stat(path2);
9237
11107
  return Date.now() - metadata.mtimeMs > CATALOG_LOCK_INCOMPLETE_GRACE_MS;
9238
11108
  } catch {
9239
11109
  return false;
9240
11110
  }
9241
11111
  }
9242
- async function acquireCatalogLock(path) {
11112
+ async function acquireCatalogLock(path2) {
9243
11113
  let handle;
9244
11114
  try {
9245
- handle = await open(path, "wx", 384);
11115
+ handle = await open(path2, "wx", 384);
9246
11116
  } catch (error) {
9247
11117
  if (error.code === "EEXIST") return false;
9248
11118
  throw error;
@@ -9254,7 +11124,7 @@ async function acquireCatalogLock(path) {
9254
11124
  );
9255
11125
  } catch (error) {
9256
11126
  await handle.close();
9257
- await rm(path, { force: true });
11127
+ await rm(path2, { force: true });
9258
11128
  throw error;
9259
11129
  }
9260
11130
  await handle.close();
@@ -9385,9 +11255,9 @@ function parseSearchArgs(args) {
9385
11255
  function renderSearchResults(matches, catalogs) {
9386
11256
  let budget = MAX_SEARCH_CONTRACT_CHARS;
9387
11257
  let shortened = false;
9388
- const blocks = matches.map((match, index) => {
9389
- const entry = catalogs.get(match.server)?.find((tool2) => tool2.name === match.tool);
9390
- if (!entry) return `${match.ref}${match.description ? ` \u2014 ${match.description}` : ""}
11258
+ const blocks = matches.map((match2, index) => {
11259
+ const entry = catalogs.get(match2.server)?.find((tool2) => tool2.name === match2.tool);
11260
+ if (!entry) return `${match2.ref}${match2.description ? ` \u2014 ${match2.description}` : ""}
9391
11261
  `;
9392
11262
  const tool = {
9393
11263
  name: entry.name,
@@ -9396,13 +11266,13 @@ function renderSearchResults(matches, catalogs) {
9396
11266
  outputSchema: entry.output_schema,
9397
11267
  annotations: entry.annotations
9398
11268
  };
9399
- const contract = renderToolContract(match.server, tool);
11269
+ const contract = renderToolContract(match2.server, tool);
9400
11270
  if (!shortened && (index === 0 || contract.length <= budget)) {
9401
11271
  budget -= contract.length;
9402
11272
  return contract;
9403
11273
  }
9404
11274
  shortened = true;
9405
- return `${renderToolSignature(match.server, tool)}
11275
+ return `${renderToolSignature(match2.server, tool)}
9406
11276
  `;
9407
11277
  });
9408
11278
  return blocks.join("\n") + (shortened ? "\nThe rest are signatures: `mcp list <server.tool> --schema` shows one in full.\n" : "");
@@ -9538,11 +11408,11 @@ function aggregateListExitCode(hadFailure, args) {
9538
11408
  return hadFailure && (args.includes("--quiet") || args.includes("--exit-code")) ? 1 : 0;
9539
11409
  }
9540
11410
  function writeCompactListError(error) {
9541
- const filter = createDelegatedErrorFilter((text) => stderr.write(text));
11411
+ const filter2 = createDelegatedErrorFilter((text) => stderr.write(text));
9542
11412
  const message = error instanceof Error ? error.stack ?? error.message : String(error);
9543
- filter.push(`mcp list: ${message.endsWith("\n") ? message : `${message}
11413
+ filter2.push(`mcp list: ${message.endsWith("\n") ? message : `${message}
9544
11414
  `}`);
9545
- filter.flush();
11415
+ filter2.flush();
9546
11416
  }
9547
11417
  var LIST_OPTIONS = {
9548
11418
  "all-parameters": { type: "boolean" },