jj-octo 0.9.0 → 0.9.2

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 (3) hide show
  1. package/README.md +4 -2
  2. package/dist/jj-octo.js +1064 -707
  3. package/package.json +6 -6
package/dist/jj-octo.js CHANGED
@@ -790,6 +790,10 @@ function assignProperty(self, key, value) {
790
790
  }
791
791
  }
792
792
  function assignProperties(self, source) {
793
+ if (!Object.hasOwn(source, "__proto__")) {
794
+ Object.assign(self, source);
795
+ return;
796
+ }
793
797
  for (const key of Reflect.ownKeys(source)) {
794
798
  if (Object.prototype.propertyIsEnumerable.call(source, key)) {
795
799
  assignProperty(self, key, source[key]);
@@ -880,7 +884,7 @@ class CauseImpl {
880
884
  toJSON() {
881
885
  return {
882
886
  _id: "Cause",
883
- failures: this.reasons.map((f) => f.toJSON())
887
+ reasons: this.reasons.map((f) => f.toJSON())
884
888
  };
885
889
  }
886
890
  toString() {
@@ -1670,6 +1674,27 @@ var match2 = /* @__PURE__ */ dual(2, (self, {
1670
1674
  onFailure,
1671
1675
  onSuccess
1672
1676
  }) => isFailure2(self) ? onFailure(self.failure) : onSuccess(self.success));
1677
+ var all = (input) => {
1678
+ if (Symbol.iterator in input) {
1679
+ const out = [];
1680
+ for (const e of input) {
1681
+ if (isFailure2(e)) {
1682
+ return e;
1683
+ }
1684
+ out.push(e.success);
1685
+ }
1686
+ return succeed2(out);
1687
+ }
1688
+ const out = {};
1689
+ for (const key of Object.keys(input)) {
1690
+ const e = input[key];
1691
+ if (isFailure2(e)) {
1692
+ return e;
1693
+ }
1694
+ assignProperty(out, key, e.success);
1695
+ }
1696
+ return succeed2(out);
1697
+ };
1673
1698
 
1674
1699
  // node_modules/effect/dist/Tuple.js
1675
1700
  var makeEquivalence = Tuple;
@@ -1800,9 +1825,21 @@ var bigint2 = /* @__PURE__ */ BigInt(2);
1800
1825
  var bigint10 = /* @__PURE__ */ BigInt(10);
1801
1826
  var bigint1e3 = /* @__PURE__ */ BigInt(1000);
1802
1827
  var bigint1e6 = /* @__PURE__ */ BigInt(1e6);
1828
+ var bigint1e9 = /* @__PURE__ */ BigInt(1e9);
1829
+ var bigintNanosPerMinute = /* @__PURE__ */ BigInt(60000000000);
1830
+ var bigintNanosPerHour = /* @__PURE__ */ BigInt(3600000000000);
1831
+ var bigintNanosPerDay = /* @__PURE__ */ BigInt(86400000000000);
1832
+ var bigintNanosPerWeek = /* @__PURE__ */ BigInt(604800000000000);
1803
1833
  var roundTiesAwayFromZero = (input) => BigInt(Math.sign(input) * Math.round(Math.abs(input)));
1804
1834
  var roundMillisToNanos = (millis) => Number.isInteger(millis) ? BigInt(millis) * bigint1e6 : roundTiesAwayFromZero(millis * 1e6);
1805
1835
  var fromNanosNumber = (nanos) => make4(Number.isFinite(nanos) ? roundTiesAwayFromZero(nanos) : nanos);
1836
+ var nanosToUnit = (nanos, divisor) => {
1837
+ const value = Number(nanos);
1838
+ if (Number.isFinite(value))
1839
+ return value / divisor;
1840
+ const scale = BigInt(divisor);
1841
+ return Number(nanos / scale) + Number(nanos % scale) / divisor;
1842
+ };
1806
1843
  var parseNanos = (input, scale) => {
1807
1844
  const decimalIndex = input.indexOf(".");
1808
1845
  if (decimalIndex === -1)
@@ -1818,6 +1855,13 @@ var divideTiesAwayFromZero = (numerator, denominator) => {
1818
1855
  const rounded = absolute / denominator + (absolute % denominator * bigint2 >= denominator ? bigint1 : bigint0);
1819
1856
  return numerator < bigint0 ? -rounded : rounded;
1820
1857
  };
1858
+ var fromMillisString = (input, scale) => {
1859
+ const millis = Number(input) * scale;
1860
+ if (!Number.isFinite(millis))
1861
+ return make4(millis);
1862
+ const nanos = parseNanos(input, BigInt(scale) * bigint1e6);
1863
+ return make4(Number.isInteger(millis) && BigInt(millis) * bigint1e6 === nanos ? millis : nanos);
1864
+ };
1821
1865
  var DURATION_REGEXP = /^(-?\d+(?:\.\d+)?)\s+(nanos?|micros?|millis?|seconds?|minutes?|hours?|days?|weeks?)$/;
1822
1866
  var fromInputUnsafe = (input) => {
1823
1867
  switch (typeof input) {
@@ -1842,26 +1886,25 @@ var fromInputUnsafe = (input) => {
1842
1886
  if (unit === "micro" || unit === "micros") {
1843
1887
  return nanos(parseNanos(valueStr, bigint1e3));
1844
1888
  }
1845
- const value = Number(valueStr);
1846
1889
  switch (unit) {
1847
1890
  case "milli":
1848
1891
  case "millis":
1849
- return millis(value);
1892
+ return fromMillisString(valueStr, 1);
1850
1893
  case "second":
1851
1894
  case "seconds":
1852
- return seconds(value);
1895
+ return fromMillisString(valueStr, 1000);
1853
1896
  case "minute":
1854
1897
  case "minutes":
1855
- return minutes(value);
1898
+ return fromMillisString(valueStr, 60000);
1856
1899
  case "hour":
1857
1900
  case "hours":
1858
- return hours(value);
1901
+ return fromMillisString(valueStr, 3600000);
1859
1902
  case "day":
1860
1903
  case "days":
1861
- return days(value);
1904
+ return fromMillisString(valueStr, 86400000);
1862
1905
  case "week":
1863
1906
  case "weeks":
1864
- return weeks(value);
1907
+ return fromMillisString(valueStr, 604800000);
1865
1908
  }
1866
1909
  break;
1867
1910
  }
@@ -1883,7 +1926,8 @@ var fromInputUnsafe = (input) => {
1883
1926
  if (input[0] === Infinity || input[1] === Infinity) {
1884
1927
  return infinity;
1885
1928
  }
1886
- return fromNanosNumber(input[0] * 1e9 + input[1]);
1929
+ const nanos = input[0] * 1e9 + input[1];
1930
+ return Number.isFinite(nanos) && Number.isInteger(input[0]) && Number.isInteger(input[1]) ? make4(BigInt(input[0]) * bigint1e9 + BigInt(input[1])) : fromNanosNumber(nanos);
1887
1931
  }
1888
1932
  const obj = input;
1889
1933
  let millis = 0;
@@ -1899,13 +1943,42 @@ var fromInputUnsafe = (input) => {
1899
1943
  millis += obj.seconds * 1000;
1900
1944
  if (obj.milliseconds)
1901
1945
  millis += obj.milliseconds;
1902
- if (!obj.microseconds && !obj.nanoseconds)
1903
- return make4(millis);
1904
- return fromNanosNumber(millis * 1e6 + (obj.microseconds ?? 0) * 1000 + (obj.nanoseconds ?? 0));
1946
+ if (!obj.microseconds && !obj.nanoseconds) {
1947
+ if (!Number.isFinite(millis))
1948
+ return make4(millis);
1949
+ const exact = sumObjectNanos(obj);
1950
+ return exact === undefined || BigInt(millis) * bigint1e6 === exact ? make4(millis) : make4(exact);
1951
+ }
1952
+ const nanos = millis * 1e6 + (obj.microseconds ?? 0) * 1000 + (obj.nanoseconds ?? 0);
1953
+ const exact = Number.isFinite(nanos) ? sumObjectNanos(obj) : undefined;
1954
+ return exact === undefined ? fromNanosNumber(nanos) : make4(exact);
1905
1955
  }
1906
1956
  }
1907
1957
  return invalid(input);
1908
1958
  };
1959
+ var isIntegerOrUnset = (n) => !n || Number.isInteger(n);
1960
+ var sumObjectNanos = (obj) => {
1961
+ if (!isIntegerOrUnset(obj.weeks) || !isIntegerOrUnset(obj.days) || !isIntegerOrUnset(obj.hours) || !isIntegerOrUnset(obj.minutes) || !isIntegerOrUnset(obj.seconds) || !isIntegerOrUnset(obj.milliseconds) || !isIntegerOrUnset(obj.microseconds) || !isIntegerOrUnset(obj.nanoseconds))
1962
+ return;
1963
+ let nanos = bigint0;
1964
+ if (obj.weeks)
1965
+ nanos += BigInt(obj.weeks) * bigintNanosPerWeek;
1966
+ if (obj.days)
1967
+ nanos += BigInt(obj.days) * bigintNanosPerDay;
1968
+ if (obj.hours)
1969
+ nanos += BigInt(obj.hours) * bigintNanosPerHour;
1970
+ if (obj.minutes)
1971
+ nanos += BigInt(obj.minutes) * bigintNanosPerMinute;
1972
+ if (obj.seconds)
1973
+ nanos += BigInt(obj.seconds) * bigint1e9;
1974
+ if (obj.milliseconds)
1975
+ nanos += BigInt(obj.milliseconds) * bigint1e6;
1976
+ if (obj.microseconds)
1977
+ nanos += BigInt(obj.microseconds) * bigint1e3;
1978
+ if (obj.nanoseconds)
1979
+ nanos += BigInt(obj.nanoseconds);
1980
+ return nanos;
1981
+ };
1909
1982
  var invalid = (input) => {
1910
1983
  throw new Error(`Invalid Input: ${input}`);
1911
1984
  };
@@ -2015,13 +2088,9 @@ var negativeInfinity = /* @__PURE__ */ make4(-Infinity);
2015
2088
  var nanos = (nanos) => make4(nanos);
2016
2089
  var millis = (millis) => make4(millis);
2017
2090
  var seconds = (seconds) => make4(seconds * 1000);
2018
- var minutes = (minutes) => make4(minutes * 60000);
2019
- var hours = (hours) => make4(hours * 3600000);
2020
- var days = (days) => make4(days * 86400000);
2021
- var weeks = (weeks) => make4(weeks * 604800000);
2022
2091
  var toMillis = (self) => match4(fromInputUnsafe(self), {
2023
2092
  onMillis: identity,
2024
- onNanos: (nanos) => Number(nanos) / 1e6,
2093
+ onNanos: (nanos) => nanosToUnit(nanos, 1e6),
2025
2094
  onInfinity: () => Infinity,
2026
2095
  onNegativeInfinity: () => -Infinity
2027
2096
  });
@@ -2093,7 +2162,7 @@ var setTimer = "setImmediate" in globalThis ? (f) => {
2093
2162
  const timer = setTimeout(f, 0);
2094
2163
  return () => clearTimeout(timer);
2095
2164
  };
2096
- var setImmediate = (f) => {
2165
+ var setImmediate2 = (f) => {
2097
2166
  try {
2098
2167
  return setTimer(f);
2099
2168
  } catch {
@@ -2133,7 +2202,7 @@ class MixedScheduler {
2133
2202
  setImmediate;
2134
2203
  constructor(executionMode = "async", setImmediateFn) {
2135
2204
  this.executionMode = executionMode;
2136
- this.setImmediate = setImmediateFn ?? (executionMode === "sync" ? setMicrotask : setImmediate);
2205
+ this.setImmediate = setImmediateFn ?? (executionMode === "sync" ? setMicrotask : setImmediate2);
2137
2206
  }
2138
2207
  shouldYield(fiber) {
2139
2208
  return fiber.currentOpCount >= fiber.cache.maxOpsBeforeYield;
@@ -2147,7 +2216,7 @@ class MixedSchedulerDispatcher {
2147
2216
  tasks = /* @__PURE__ */ new PriorityBuckets;
2148
2217
  running = undefined;
2149
2218
  setImmediate;
2150
- constructor(setImmediateFn = setImmediate) {
2219
+ constructor(setImmediateFn = setImmediate2) {
2151
2220
  this.setImmediate = setImmediateFn;
2152
2221
  }
2153
2222
  scheduleTask(task, priority) {
@@ -2437,10 +2506,7 @@ class Interrupt extends ReasonBase {
2437
2506
  }
2438
2507
  }
2439
2508
  var causeInterrupt = (fiberId) => new CauseImpl([new Interrupt(fiberId)]);
2440
- var findFail = (self) => {
2441
- const reason = self.reasons.find(isFailReason);
2442
- return reason ? succeed2(reason) : fail2(self);
2443
- };
2509
+ var hasFails = (self) => self.reasons.some(isFailReason);
2444
2510
  var findError = (self) => {
2445
2511
  for (let i = 0;i < self.reasons.length; i++) {
2446
2512
  const reason = self.reasons[i];
@@ -2451,6 +2517,9 @@ var findError = (self) => {
2451
2517
  return fail2(self);
2452
2518
  };
2453
2519
  var findErrorOption = /* @__PURE__ */ toOption(findError);
2520
+ var hasDies = (self) => self.reasons.some(isDieReason);
2521
+ var causeElectDefects = (self) => hasDies(self) && hasFails(self) ? causeFromReasons(self.reasons.map((reason) => reason._tag === "Fail" && !isDone(reason.error) ? new Die(reason.error, reason.annotations) : reason)) : self;
2522
+ var findRecoverableError = (self) => hasDies(self) ? fail2(causeElectDefects(self)) : findError(self);
2454
2523
  var hasInterrupts = (self) => self.reasons.some(isInterruptReason);
2455
2524
  var causeFilterInterruptors = (self) => {
2456
2525
  let interruptors;
@@ -2525,12 +2594,14 @@ var causePrettyErrors = (self, options) => {
2525
2594
  }
2526
2595
  return errors;
2527
2596
  };
2528
- var causePrettyError = (original, annotations, options) => {
2597
+ var causePrettyError = (original, annotations, options, seen = new Set) => {
2529
2598
  const kind = typeof original;
2530
2599
  let error;
2531
2600
  if (original && kind === "object") {
2601
+ seen.add(original);
2602
+ const cause = original.cause;
2532
2603
  error = new globalThis.Error(causePrettyMessage(original), {
2533
- cause: original.cause ? causePrettyError(original.cause) : undefined
2604
+ cause: cause !== undefined && !seen.has(cause) ? causePrettyError(cause, undefined, undefined, seen) : undefined
2534
2605
  });
2535
2606
  if (typeof original.name === "string") {
2536
2607
  error.name = original.name;
@@ -2741,7 +2812,11 @@ class FiberImpl {
2741
2812
  } else if (this._asyncContext !== undefined) {
2742
2813
  const asyncContext = this._asyncContext;
2743
2814
  this._asyncContext = undefined;
2744
- return asyncContext.runInAsyncScope(this.evaluate, this, effect);
2815
+ try {
2816
+ return asyncContext.runInAsyncScope(this.evaluate, this, effect);
2817
+ } finally {
2818
+ asyncContext.emitDestroy();
2819
+ }
2745
2820
  } else if (this._yielded !== undefined) {
2746
2821
  const yielded = this._yielded;
2747
2822
  this._yielded = undefined;
@@ -3042,7 +3117,6 @@ var tryPromise = (options) => {
3042
3117
  }
3043
3118
  }, f.length !== 0);
3044
3119
  };
3045
- var withFiberId = (f) => withFiber((fiber) => f(fiber.id));
3046
3120
  var callbackOptions = /* @__PURE__ */ function() {
3047
3121
  const Proto = /* @__PURE__ */ makePrimitiveProto({
3048
3122
  op: "Async",
@@ -3063,9 +3137,9 @@ var callbackOptions = /* @__PURE__ */ function() {
3063
3137
  if (yielded !== false)
3064
3138
  return yielded;
3065
3139
  yielded = true;
3066
- fiber._yielded = () => {
3140
+ fiber.yieldWith(() => {
3067
3141
  resumed = true;
3068
- };
3142
+ });
3069
3143
  if (controller === undefined && onCancel === undefined) {
3070
3144
  return Yield;
3071
3145
  }
@@ -3294,9 +3368,9 @@ var catchEager = /* @__PURE__ */ dual(2, (self, f) => {
3294
3368
  if (effectIsExit(self)) {
3295
3369
  if (self._tag === "Success")
3296
3370
  return self;
3297
- const error = findError(self.cause);
3371
+ const error = findRecoverableError(self.cause);
3298
3372
  if (isFailure2(error))
3299
- return self;
3373
+ return exitFailCause(error.failure);
3300
3374
  return f(error.success);
3301
3375
  }
3302
3376
  return catch_(self, f);
@@ -3311,18 +3385,12 @@ var exitMap = /* @__PURE__ */ dual(2, (self, f) => self._tag === "Success" ? exi
3311
3385
  var exitMapError = /* @__PURE__ */ dual(2, (self, f) => {
3312
3386
  if (self._tag === "Success")
3313
3387
  return self;
3314
- const error = findError(self.cause);
3315
- if (isFailure2(error))
3316
- return self;
3317
- return exitFail(f(error.success));
3388
+ return exitFailCause(causeMap(self.cause, f));
3318
3389
  });
3319
3390
  var exitMapBoth = /* @__PURE__ */ dual(2, (self, options) => {
3320
3391
  if (self._tag === "Success")
3321
3392
  return exitSucceed(options.onSuccess(self.value));
3322
- const error = findError(self.cause);
3323
- if (isFailure2(error))
3324
- return self;
3325
- return exitFail(options.onFailure(error.success));
3393
+ return exitFailCause(causeMap(self.cause, options.onFailure));
3326
3394
  });
3327
3395
  var exitZipRight = /* @__PURE__ */ dual(2, (self, that) => exitIsSuccess(self) ? that : self);
3328
3396
  var exitAsVoidAll = (exits) => {
@@ -3389,7 +3457,7 @@ var catchCauseFilter = /* @__PURE__ */ dual(3, (self, filter, f) => catchCause(s
3389
3457
  const eb = filter(cause);
3390
3458
  return isFailure2(eb) ? failCause(eb.failure) : f(eb.success, cause);
3391
3459
  }));
3392
- var catch_ = /* @__PURE__ */ dual(2, (self, f) => catchCauseFilter(self, findError, (e) => f(e)));
3460
+ var catch_ = /* @__PURE__ */ dual(2, (self, f) => catchCauseFilter(self, findRecoverableError, (e) => f(e)));
3393
3461
  var tapCause = /* @__PURE__ */ dual(2, (self, f) => catchCause(self, (cause) => andThen(f(cause), failCause(cause))));
3394
3462
  var tapCauseFilter = /* @__PURE__ */ dual(3, (self, filter, f) => catchCause(self, (cause) => {
3395
3463
  const result = filter(cause);
@@ -3400,7 +3468,7 @@ var tapCauseFilter = /* @__PURE__ */ dual(3, (self, filter, f) => catchCause(sel
3400
3468
  }));
3401
3469
  var tapError = /* @__PURE__ */ dual(2, (self, f) => tapCauseFilter(self, findError, (e) => f(e)));
3402
3470
  var catchIf = /* @__PURE__ */ dual((args) => isEffect(args[0]), (self, predicate, f, orElse) => catchCause(self, (cause) => {
3403
- const error = findError(cause);
3471
+ const error = findRecoverableError(cause);
3404
3472
  if (isFailure2(error))
3405
3473
  return failCause(error.failure);
3406
3474
  if (!predicate(error.success)) {
@@ -3409,7 +3477,7 @@ var catchIf = /* @__PURE__ */ dual((args) => isEffect(args[0]), (self, predicate
3409
3477
  return f(error.success);
3410
3478
  }));
3411
3479
  var catchFilter = /* @__PURE__ */ dual((args) => isEffect(args[0]), (self, filter, f, orElse) => catchCause(self, (cause) => {
3412
- const error = findError(cause);
3480
+ const error = findRecoverableError(cause);
3413
3481
  if (isFailure2(error))
3414
3482
  return failCause(error.failure);
3415
3483
  const result = filter(error.success);
@@ -3429,9 +3497,9 @@ var catchTags = /* @__PURE__ */ dual((args) => isEffect(args[0]), (self, cases,
3429
3497
  return hasProperty(e, "_tag") && isString(e["_tag"]) && keys.includes(e["_tag"]) ? succeed2(e) : fail2(e);
3430
3498
  }, (e) => cases[e["_tag"]](e), orElse);
3431
3499
  });
3432
- var mapError2 = /* @__PURE__ */ dual(2, (self, f) => catch_(self, (error) => failSync(() => f(error))));
3433
- var mapBoth = /* @__PURE__ */ dual(2, (self, options) => matchEffect(self, {
3434
- onFailure: (e) => failSync(() => options.onFailure(e)),
3500
+ var mapError2 = /* @__PURE__ */ dual(2, (self, f) => catchCause(self, (cause) => failCause(causeMap(cause, f))));
3501
+ var mapBoth = /* @__PURE__ */ dual(2, (self, options) => matchCauseEffect(self, {
3502
+ onFailure: (cause) => failCause(causeMap(cause, options.onFailure)),
3435
3503
  onSuccess: (a) => sync(() => options.onSuccess(a))
3436
3504
  }));
3437
3505
  var orDie = (self) => catch_(self, die);
@@ -3446,8 +3514,8 @@ var ignore = /* @__PURE__ */ dual((args) => isEffect(args[0]), (self, options) =
3446
3514
  const logEffect = logWithLevel(options.log === true ? undefined : options.log);
3447
3515
  return matchCauseEffect(self, {
3448
3516
  onFailure(cause) {
3449
- const failure = findFail(cause);
3450
- return isFailure2(failure) ? failCause(failure.failure) : options.message === undefined ? logEffect(cause) : logEffect(options.message, cause);
3517
+ const error = findRecoverableError(cause);
3518
+ return isFailure2(error) ? failCause(error.failure) : options.message === undefined ? logEffect(cause) : logEffect(options.message, cause);
3451
3519
  },
3452
3520
  onSuccess: (_) => void_
3453
3521
  });
@@ -3486,16 +3554,16 @@ var makeMatch = (op, onFailure) => {
3486
3554
  return MatchImpl;
3487
3555
  };
3488
3556
  var MatchImpl = /* @__PURE__ */ makeMatch("Match", function(cause, fiber) {
3489
- const fail = cause.reasons.find(isFailReason);
3490
- if (fail === undefined)
3491
- return failCause(cause);
3557
+ const error = findRecoverableError(cause);
3558
+ if (isFailure2(error))
3559
+ return failCause(error.failure);
3492
3560
  const handlers = this.payload;
3493
- return fiber.succeedWith(continuationMarksStack ? handlers.onFailure(fail.error) : internalCall(() => handlers.onFailure(fail.error)));
3561
+ return fiber.succeedWith(continuationMarksStack ? handlers.onFailure(error.success) : internalCall(() => handlers.onFailure(error.success)));
3494
3562
  });
3495
3563
  var matchEffect = /* @__PURE__ */ dual(2, (self, options) => matchCauseEffect(self, {
3496
3564
  onFailure: (cause) => {
3497
- const fail = cause.reasons.find(isFailReason);
3498
- return fail ? options.onFailure(fail.error) : failCause(cause);
3565
+ const error = findRecoverableError(cause);
3566
+ return isFailure2(error) ? failCause(error.failure) : options.onFailure(error.success);
3499
3567
  },
3500
3568
  onSuccess: options.onSuccess
3501
3569
  }));
@@ -3504,9 +3572,9 @@ var matchEager = /* @__PURE__ */ dual(2, (self, options) => {
3504
3572
  if (effectIsExit(self)) {
3505
3573
  if (self._tag === "Success")
3506
3574
  return exitSucceed(options.onSuccess(self.value));
3507
- const error = findError(self.cause);
3575
+ const error = findRecoverableError(self.cause);
3508
3576
  if (isFailure2(error))
3509
- return self;
3577
+ return exitFailCause(error.failure);
3510
3578
  return exitSucceed(options.onFailure(error.success));
3511
3579
  }
3512
3580
  return match5(self, options);
@@ -3561,17 +3629,17 @@ var runFinalizer = (finalizer, exit_) => {
3561
3629
  return exitDie(defect);
3562
3630
  }
3563
3631
  };
3564
- var combineFinalizerCause = (exit_, finalizer) => exitIsSuccess(exit_) ? finalizer : catchCause(finalizer, (cause) => failCause(causeCombine(exit_.cause, cause)));
3632
+ var combineFinalizerCause = (exit_, finalizer) => exitIsSuccess(exit_) ? finalizer : catchCause(finalizer, (cause) => failCause(causeElectDefects(causeCombine(exit_.cause, cause))));
3565
3633
  var scopeCloseFinalizers = /* @__PURE__ */ fnUntraced(function* (self, finalizers, exit_) {
3566
3634
  let exits = [];
3567
3635
  const fibers = [];
3568
- const arr = Array.from(finalizers.values());
3636
+ const arr = Array.from(finalizers);
3569
3637
  const parent = getCurrentFiber();
3570
3638
  for (let i = arr.length - 1;i >= 0; i--) {
3571
- const finalizer = arr[i];
3639
+ const [key, finalizer] = arr[i];
3572
3640
  if (self.strategy === "sequential") {
3573
3641
  exits.push(yield* exit(runFinalizer(finalizer, exit_)));
3574
- } else {
3642
+ } else if (key !== parent) {
3575
3643
  fibers.push(forkUnsafe(parent, runFinalizer(finalizer, exit_), true, true, "inherit"));
3576
3644
  }
3577
3645
  }
@@ -3730,9 +3798,10 @@ var makeCachedUnsafe = (self, ttlMillis) => {
3730
3798
  const join = (fiber, run) => {
3731
3799
  run.awaiters++;
3732
3800
  onExitUnsafe(fiber, () => {
3733
- if (--run.awaiters > 0 || current !== run)
3801
+ if (--run.awaiters > 0 || run.done)
3734
3802
  return;
3735
- current = undefined;
3803
+ if (current === run)
3804
+ current = undefined;
3736
3805
  return fiberInterrupt(run.fiber);
3737
3806
  });
3738
3807
  return fiberJoin(run.fiber);
@@ -3748,11 +3817,13 @@ var makeCachedUnsafe = (self, ttlMillis) => {
3748
3817
  const clock = fiber.getRef(ClockRef);
3749
3818
  const run = {
3750
3819
  fiber: new FiberImpl(fiber.context),
3751
- awaiters: 0
3820
+ awaiters: 0,
3821
+ done: false
3752
3822
  };
3753
3823
  current = run;
3754
3824
  const joined = join(fiber, run);
3755
3825
  run.fiber.evaluate(onExitPrimitive(self, (exit_) => {
3826
+ run.done = true;
3756
3827
  if (current !== run)
3757
3828
  return;
3758
3829
  current = undefined;
@@ -3764,6 +3835,7 @@ var makeCachedUnsafe = (self, ttlMillis) => {
3764
3835
  }));
3765
3836
  return run.fiber._exit ?? joined;
3766
3837
  }), sync(() => {
3838
+ current = undefined;
3767
3839
  exit = undefined;
3768
3840
  })];
3769
3841
  };
@@ -3812,21 +3884,15 @@ var uninterruptibleMask = (f) => withFiber((fiber) => {
3812
3884
  fiber._stack.push(setInterruptibleTrue);
3813
3885
  return f(interruptible);
3814
3886
  });
3815
- var all = (arg, options) => {
3887
+ var all2 = (arg, options) => {
3816
3888
  if (isIterable(arg)) {
3817
3889
  return options?.mode === "result" ? forEach(arg, result, options) : forEach(arg, identity, options);
3818
3890
  } else if (options?.discard) {
3819
3891
  return options.mode === "result" ? forEach(Object.values(arg), result, options) : forEach(Object.values(arg), identity, options);
3820
3892
  }
3821
- return suspend(() => {
3822
- const out = {};
3823
- return as(forEach(Object.entries(arg), ([key, effect]) => map5(options?.mode === "result" ? result(effect) : effect, (value) => {
3824
- assignProperty(out, key, value);
3825
- }), {
3826
- discard: true,
3827
- concurrency: options?.concurrency
3828
- }), out);
3829
- });
3893
+ return suspend(() => map5(forEach(Object.entries(arg), ([key, effect]) => map5(options?.mode === "result" ? result(effect) : effect, (value) => [key, value]), {
3894
+ concurrency: options?.concurrency
3895
+ }), Object.fromEntries));
3830
3896
  };
3831
3897
  var whileLoop = /* @__PURE__ */ makePrimitive({
3832
3898
  op: "While",
@@ -3965,7 +4031,7 @@ var iterateConcurrentImpl = (options) => {
3965
4031
  const reasons = exit.cause.reasons.filter((reason) => reason._tag !== "Interrupt");
3966
4032
  if (reasons.length > 0) {
3967
4033
  const cause = causeFromReasons(reasons);
3968
- terminal = exitFailCause(terminal._tag === "Failure" ? causeCombine(terminal.cause, cause) : cause);
4034
+ terminal = exitFailCause(terminal._tag === "Failure" ? causeElectDefects(causeCombine(terminal.cause, cause)) : cause);
3969
4035
  }
3970
4036
  }
3971
4037
  } else {
@@ -4044,14 +4110,13 @@ var forkUnsafe = (parent, effect, immediate = false, daemon = false, uninterrupt
4044
4110
  }
4045
4111
  return child;
4046
4112
  };
4113
+ var fiberScopeFinalizer = (fiber) => () => withFiber((current) => current === fiber ? void_ : fiberInterrupt(fiber));
4047
4114
  var forkIn = /* @__PURE__ */ dual((args) => isEffect(args[0]), (self, scope, options) => withFiber((parent) => {
4048
- const fiber = forkUnsafe(parent, self, options?.startImmediately, true, options?.uninterruptible);
4115
+ const fiber = scope.state._tag === "Closed" ? new FiberImpl(parent.context) : forkUnsafe(parent, self, options?.startImmediately, true, options?.uninterruptible);
4049
4116
  if (!fiber._exit) {
4050
4117
  if (scope.state._tag !== "Closed") {
4051
- const key = {};
4052
- const finalizer = () => withFiberId((interruptor) => interruptor === fiber.id ? void_ : fiberInterrupt(fiber));
4053
- scopeAddFinalizerUnsafe(scope, key, finalizer);
4054
- fiber.addObserver(() => scopeRemoveFinalizerUnsafe(scope, key));
4118
+ scopeAddFinalizerUnsafe(scope, fiber, fiberScopeFinalizer(fiber));
4119
+ fiber.addObserver(() => scopeRemoveFinalizerUnsafe(scope, fiber));
4055
4120
  } else {
4056
4121
  fiber.interruptUnsafe(parent.id, fiberStackAnnotations(parent));
4057
4122
  }
@@ -4088,7 +4153,7 @@ var fiberRunIn = /* @__PURE__ */ dual(2, (self, scope) => {
4088
4153
  return self;
4089
4154
  }
4090
4155
  scopeRemoveFinalizerUnsafe(scope, self);
4091
- scopeAddFinalizerUnsafe(scope, self, () => fiberInterrupt(self));
4156
+ scopeAddFinalizerUnsafe(scope, self, fiberScopeFinalizer(self));
4092
4157
  self.addObserver(() => scopeRemoveFinalizerUnsafe(scope, self));
4093
4158
  return self;
4094
4159
  });
@@ -4783,8 +4848,8 @@ var mergeAllEffect = (layers, memoMap, scope) => {
4783
4848
  concurrency: layers.length
4784
4849
  }).pipe(map5((context) => mergeAll(...context)));
4785
4850
  };
4786
- var mergeAll2 = (...layers) => fromBuild((memoMap, scope) => mergeAllEffect(layers, memoMap, scope));
4787
- var provideWith = (self, that, f) => fromBuild((memoMap, scope) => flatMap2(Array.isArray(that) ? mergeAllEffect(that, memoMap, scope) : that.build(memoMap, scope), (context) => self.build(memoMap, scope).pipe(provideContext(context), map5((merged) => f(merged, context)))));
4851
+ var mergeAll2 = (...layers) => fromBuildMemo((memoMap, scope) => mergeAllEffect(layers, memoMap, scope));
4852
+ var provideWith = (self, that, f) => fromBuildMemo((memoMap, scope) => flatMap2(Array.isArray(that) ? mergeAllEffect(that, memoMap, scope) : that.build(memoMap, scope), (context) => self.build(memoMap, scope).pipe(provideContext(context), map5((merged) => f(merged, context)))));
4788
4853
  var provideMerge = /* @__PURE__ */ dual(2, (self, that) => provideWith(self, that, (self, that) => merge(that, self)));
4789
4854
  var flatMap3 = /* @__PURE__ */ dual(2, (self, f) => fromBuild((memoMap, scope) => flatMap2(self.build(memoMap, scope), (context) => f(context).build(memoMap, scope))));
4790
4855
 
@@ -4943,14 +5008,17 @@ var provideLayer = (self, layer, options) => scopedWith((scope) => flatMap2(opti
4943
5008
  var provide2 = /* @__PURE__ */ dual((args) => isEffect(args[0]), (self, source, options) => isContext(source) ? provideContext(self, source) : provideLayer(self, Array.isArray(source) ? mergeAll2(...source) : source, options));
4944
5009
 
4945
5010
  // node_modules/effect/dist/internal/schedule.js
4946
- var findErrorOnly = (cause) => cause.reasons.every(isFailReason) ? findError(cause) : fail2(cause);
4947
5011
  var repeatOrElse = /* @__PURE__ */ dual(3, (self, schedule, orElse) => flatMap2(toStepWithMetadata(schedule), (step) => {
4948
5012
  let meta = CurrentMetadata.defaultValue();
4949
- return catchCauseFilter(catchDone(forever(tap(flatMap2(suspend(() => provideService(self, CurrentMetadata, meta)), step), (meta_) => sync(() => {
4950
- meta = meta_;
4951
- })), {
4952
- disableYield: true
4953
- }), (out) => succeed3(out)), findErrorOnly, (error) => orElse(error, meta.attempt === 0 ? none2() : some2(meta)));
5013
+ const loop = (input) => matchEffect2(step(input), {
5014
+ onSuccess(meta_) {
5015
+ meta = meta_;
5016
+ return flatMap2(provideService(self, CurrentMetadata, meta), loop);
5017
+ },
5018
+ onFailure: failCause,
5019
+ onDone: succeed3
5020
+ });
5021
+ return catchCauseFilter(flatMap2(provideService(self, CurrentMetadata, meta), loop), findRecoverableError, (error) => orElse(error, meta.attempt === 0 ? none2() : some2(meta)));
4954
5022
  }));
4955
5023
  var repeat = /* @__PURE__ */ dual(2, (self, options) => {
4956
5024
  const schedule = typeof options === "function" ? options(identity) : isSchedule(options) ? options : buildFromOptions(options);
@@ -4985,7 +5053,7 @@ var buildFromOptions = (options) => {
4985
5053
 
4986
5054
  // node_modules/effect/dist/Effect.js
4987
5055
  var isEffect2 = isEffect;
4988
- var all2 = all;
5056
+ var all3 = all2;
4989
5057
  var forEach2 = forEach;
4990
5058
  var whileLoop2 = whileLoop;
4991
5059
  var promise2 = promise;
@@ -4997,6 +5065,7 @@ var void_3 = void_;
4997
5065
  var callback2 = callback;
4998
5066
  var gen2 = gen;
4999
5067
  var fail6 = fail3;
5068
+ var failSync2 = failSync;
5000
5069
  var failCause3 = failCause;
5001
5070
  var failCauseSync2 = failCauseSync;
5002
5071
  var die3 = die;
@@ -5064,16 +5133,23 @@ var fnUntraced2 = fnUntraced;
5064
5133
  var clockWith2 = clockWith;
5065
5134
  var logError = /* @__PURE__ */ logWithLevel("Error");
5066
5135
  var effectify = (fn, onError, onSyncError) => (...args) => callback2((resume) => {
5136
+ let synchronous = true;
5137
+ let pending;
5067
5138
  try {
5068
5139
  fn(...args, (err, result) => {
5069
- if (err) {
5070
- resume(onError ? suspend2(() => fail6(onError(err, args))) : fail6(err));
5140
+ const effect = err ? onError ? suspend2(() => fail6(onError(err, args))) : fail6(err) : succeed6(result);
5141
+ if (synchronous) {
5142
+ pending ??= effect;
5071
5143
  } else {
5072
- resume(succeed6(result));
5144
+ resume(effect);
5073
5145
  }
5074
5146
  });
5075
5147
  } catch (err) {
5076
- resume(onSyncError ? fail6(onSyncError(err, args)) : die3(err));
5148
+ pending = onSyncError ? fail6(onSyncError(err, args)) : die3(err);
5149
+ }
5150
+ synchronous = false;
5151
+ if (pending) {
5152
+ resume(pending);
5077
5153
  }
5078
5154
  });
5079
5155
  var mapEager2 = mapEager;
@@ -5092,23 +5168,26 @@ var defaultTeardown = (exit, onExit) => {
5092
5168
  return onExit(getErrorExitCode(squash(exit.cause)));
5093
5169
  };
5094
5170
  var makeRunMain = (f) => dual((args) => isEffect2(args[0]), (effect, options) => {
5095
- const fiber = options?.disableErrorReporting === true ? runFork2(effect) : runFork2(tapCause2(effect, (cause) => {
5171
+ const main = options?.disableErrorReporting === true ? effect : tapCause2(effect, (cause) => {
5096
5172
  if (hasInterruptsOnly2(cause))
5097
5173
  return void_3;
5098
5174
  const isReported = getErrorReported(squash(cause));
5099
5175
  return isReported ? logError(cause) : void_3;
5100
- }));
5101
- try {
5102
- const keepAlive = globalThis.setInterval(constVoid, 2147483647);
5103
- fiber.addObserver(() => {
5104
- clearInterval(keepAlive);
5105
- });
5106
- } catch {}
5107
- const teardown = options?.teardown ?? defaultTeardown;
5108
- return f({
5109
- fiber,
5110
- teardown
5111
5176
  });
5177
+ const teardown = options?.teardown ?? defaultTeardown;
5178
+ runFork2(withFiber2((fiber) => {
5179
+ try {
5180
+ const keepAlive = globalThis.setInterval(constVoid, 2147483647);
5181
+ fiber.addObserver(() => {
5182
+ clearInterval(keepAlive);
5183
+ });
5184
+ } catch {}
5185
+ f({
5186
+ fiber,
5187
+ teardown
5188
+ });
5189
+ return main;
5190
+ }));
5112
5191
  });
5113
5192
  var errorExitCode = "~effect/Runtime/errorExitCode";
5114
5193
  var getErrorExitCode = (u) => {
@@ -5753,7 +5832,9 @@ var toTransform = (channel) => channel.transform;
5753
5832
  var asyncQueue = (scope, f, options) => make9({
5754
5833
  capacity: options?.bufferSize,
5755
5834
  strategy: options?.strategy
5756
- }).pipe(tap2((queue) => addFinalizer2(scope, shutdown(queue))), tap2((queue) => provide(f(queue), scope).pipe(catchCause2((cause) => failCause4(queue, cause)), forkIn2(scope))));
5835
+ }).pipe(tap2((queue) => addFinalizer2(scope, shutdown(queue))), tap2((queue) => provide(f(queue), scope).pipe(catchCause2((cause) => failCause4(queue, cause)), forkIn2(scope, {
5836
+ startImmediately: true
5837
+ }))));
5757
5838
  var callbackArray = (f, options) => fromTransform((_, scope) => map7(asyncQueue(scope, f, options), takeAll2));
5758
5839
  var suspend3 = (evaluate) => fromTransform((upstream, scope) => suspend2(() => toTransform(evaluate())(upstream, scope)));
5759
5840
  var succeed7 = (value) => fromEffect(succeed6(value));
@@ -5795,7 +5876,7 @@ var readableStreamToPullUnsafe = (options) => {
5795
5876
  }
5796
5877
  });
5797
5878
  });
5798
- return as2(addFinalizer2(options.scope, options.releaseLockOnEnd ? sync2(() => reader.releaseLock()) : promise2(() => reader.cancel().catch(constVoid))), pull);
5879
+ return as2(addFinalizer2(options.scope, options.releaseLockOnEnd ? sync2(() => reader.releaseLock()) : promise2(() => reader.cancel().catch((error) => reader.closed.then(() => Promise.reject(error), constVoid))).pipe(ensuring2(sync2(() => reader.releaseLock())))), pull);
5799
5880
  };
5800
5881
  var map8 = /* @__PURE__ */ dual(2, (self, f) => transformPull(self, (pull) => sync2(() => {
5801
5882
  let i = 0;
@@ -5913,6 +5994,18 @@ var splitLines = () => fromTransform((upstream, _scope) => sync2(() => {
5913
5994
  }
5914
5995
  return pullOrFlush;
5915
5996
  }));
5997
+ var decodeText = (encoding, options) => fromTransform((upstream, _scope) => sync2(() => {
5998
+ const decoder = new TextDecoder(encoding, options);
5999
+ const streamOptions = {
6000
+ stream: true
6001
+ };
6002
+ let pull = upstream.pipe(map7(map4((bytes) => decoder.decode(bytes, streamOptions))), catchDone((leftover) => {
6003
+ pull = done2(leftover);
6004
+ const last = decoder.decode();
6005
+ return last.length > 0 ? succeed6(of(last)) : pull;
6006
+ }));
6007
+ return suspend2(() => pull);
6008
+ }));
5916
6009
  var pipeTo = /* @__PURE__ */ dual(2, (self, that) => fromTransform((upstream, scope) => flatMap4(toTransform(self)(upstream, scope), (upstream) => toTransform(that)(upstream, scope))));
5917
6010
  var unwrap2 = (channel) => fromTransform((upstream, scope) => {
5918
6011
  let pull;
@@ -5922,6 +6015,9 @@ var unwrap2 = (channel) => fromTransform((upstream, scope) => {
5922
6015
  return channel.pipe(provide(scope), flatMap4((channel) => toTransform(channel)(upstream, scope)), flatMap4((pull_) => pull = pull_));
5923
6016
  }));
5924
6017
  });
6018
+ var interruptWhen = /* @__PURE__ */ dual(2, (self, effect) => merge2(self, fromPull(succeed6(flatMap4(effect, done2))), {
6019
+ haltStrategy: "either"
6020
+ }));
5925
6021
  var onExit3 = /* @__PURE__ */ dual(2, (self, finalizer) => fromTransformBracket((upstream, scope, forkedScope) => addFinalizerExit(forkedScope, finalizer).pipe(andThen2(toTransform(self)(upstream, scope)))));
5926
6022
  var ensuring3 = /* @__PURE__ */ dual(2, (self, finalizer) => onExit3(self, (_) => finalizer));
5927
6023
  var runWith = (self, f, onHalt) => suspend2(() => {
@@ -6148,7 +6244,12 @@ var toChannel2 = (stream) => stream.channel;
6148
6244
  var callback3 = (f, options) => fromChannel3(callbackArray(f, options));
6149
6245
  var empty4 = /* @__PURE__ */ fromChannel3(empty3);
6150
6246
  var make12 = (...values) => fromArray2(values);
6151
- var suspend4 = (stream) => fromChannel3(suspend3(() => stream().channel));
6247
+ var suspend4 = (stream) => {
6248
+ const suspended = fromChannel3(suspend3(() => stream().channel));
6249
+ suspendedStreams.set(suspended, stream);
6250
+ return suspended;
6251
+ };
6252
+ var suspendedStreams = /* @__PURE__ */ new WeakMap;
6152
6253
  var fail8 = (error) => fromChannel3(fail7(error));
6153
6254
  var fromArray2 = (array) => isReadonlyArrayNonEmpty(array) ? fromChannel3(succeed7(array)) : empty4;
6154
6255
  var fromReadableStream2 = (options) => fromChannel3(fromReadableStream(options));
@@ -6178,17 +6279,13 @@ var transduce = /* @__PURE__ */ dual(2, (self, sink) => transformPull2(self, (up
6178
6279
  });
6179
6280
  return suspend2(() => done ? done : pull);
6180
6281
  })));
6181
- var decodeText = /* @__PURE__ */ dual((args) => isStream(args[0]), (self, options) => suspend4(() => {
6182
- const decoder = new TextDecoder(options?.encoding);
6183
- return map9(self, (chunk) => decoder.decode(chunk, {
6184
- stream: true
6185
- }));
6186
- }));
6282
+ var decodeText2 = /* @__PURE__ */ dual((args) => isStream(args[0]), (self, options) => self.channel.pipe(pipeTo(decodeText(options?.encoding)), fromChannel3));
6187
6283
  var encodeText = (self) => suspend4(() => {
6188
6284
  const encoder = new TextEncoder;
6189
6285
  return map9(self, (chunk) => encoder.encode(chunk));
6190
6286
  });
6191
6287
  var splitLines2 = (self) => self.channel.pipe(pipeTo(splitLines()), fromChannel3);
6288
+ var interruptWhen2 = /* @__PURE__ */ dual(2, (self, effect) => fromChannel3(interruptWhen(self.channel, effect)));
6192
6289
  var ensuring4 = /* @__PURE__ */ dual(2, (self, finalizer) => fromChannel3(ensuring3(self.channel, finalizer)));
6193
6290
  var run = /* @__PURE__ */ dual(2, (self, sink) => scopedWith2((scope) => toPullScoped(self.channel, scope).pipe(flatMap4((upstream) => sink.transform(upstream, scope)), map7(([a]) => a))));
6194
6291
  var runCollect = (self) => runFold(self.channel, () => [], (acc, chunk) => {
@@ -6197,7 +6294,6 @@ var runCollect = (self) => runFold(self.channel, () => [], (acc, chunk) => {
6197
6294
  }
6198
6295
  return acc;
6199
6296
  });
6200
- var runForEachArray = /* @__PURE__ */ dual(2, (self, f) => runForEach(self.channel, f));
6201
6297
  var mkString = (self) => runFold(self.channel, () => "", (acc, chunk) => acc + chunk.join(""));
6202
6298
  var toReadableStreamWith = /* @__PURE__ */ dual((args) => isStream(args[0]), (self, context, options) => {
6203
6299
  let currentResolve = undefined;
@@ -6208,14 +6304,14 @@ var toReadableStreamWith = /* @__PURE__ */ dual((args) => isStream(args[0]), (se
6208
6304
  const onAbort = () => fiber.interruptUnsafe();
6209
6305
  return new ReadableStream({
6210
6306
  start(controller) {
6211
- fiber = runFork2(provideContext2(runForEachArray(self, (chunk) => latch.whenOpen(sync2(() => {
6307
+ fiber = runFork2(provideContext2(runForEach(transformPull(self.channel, (pull) => succeed6(latch.whenOpen(pull))), (chunk) => sync2(() => {
6212
6308
  latch.closeUnsafe();
6213
6309
  for (let i = 0;i < chunk.length; i++) {
6214
6310
  controller.enqueue(chunk[i]);
6215
6311
  }
6216
6312
  currentResolve();
6217
6313
  currentResolve = undefined;
6218
- }))), context));
6314
+ })), context));
6219
6315
  fiber.addObserver((exit) => {
6220
6316
  signal?.removeEventListener("abort", onAbort);
6221
6317
  if (cancelled)
@@ -6525,7 +6621,7 @@ var defaultLeafHook = (issue) => {
6525
6621
  }
6526
6622
  }
6527
6623
  };
6528
- var defaultCheckHook = (issue) => findMessage(issue.issue) ?? findMessage(issue);
6624
+ var defaultCheckHook = (issue) => findMessage(issue) ?? findMessage(issue.issue);
6529
6625
  function formatInput(issue) {
6530
6626
  return hasInput(issue) ? format(issue.input) : undefined;
6531
6627
  }
@@ -6537,6 +6633,13 @@ function getExpectedMessage(expected, issue) {
6537
6633
  const input = formatInput(issue);
6538
6634
  return input === undefined ? `Expected ${expected}` : `Expected ${expected}, got ${input}`;
6539
6635
  }
6636
+ function getFilterMessage(issue, checkHook) {
6637
+ const message = checkHook(issue);
6638
+ if (message !== undefined || issue.issue._tag !== "InvalidValue")
6639
+ return message;
6640
+ const expected = findExpected(issue.issue);
6641
+ return expected === undefined ? getExpectedMessage(formatCheck(issue.filter), issue) : getExpectedMessage(expected, issue.issue);
6642
+ }
6540
6643
  function formatCheck(check) {
6541
6644
  const expected = check.annotations?.expected;
6542
6645
  if (typeof expected === "string")
@@ -6552,44 +6655,33 @@ function makeFormatterDefault() {
6552
6655
  return (issue) => formatIssue(issue, "");
6553
6656
  }
6554
6657
  var defaultFormatter = /* @__PURE__ */ makeFormatterDefault();
6555
- function formatIssue(issue, path) {
6658
+ function formatIssue(issue, path, messageOverride) {
6556
6659
  let message;
6557
6660
  switch (issue._tag) {
6558
- case "Filter": {
6559
- const annotated = defaultCheckHook(issue);
6560
- if (annotated !== undefined) {
6561
- message = annotated;
6562
- } else {
6563
- if (issue.issue._tag !== "InvalidValue") {
6564
- return formatIssue(issue.issue, path);
6565
- }
6566
- const expected = findExpected(issue.issue);
6567
- message = expected === undefined ? getExpectedMessage(formatCheck(issue.filter), issue) : getExpectedMessage(expected, issue.issue);
6568
- }
6569
- break;
6570
- }
6661
+ case "Filter":
6662
+ return formatIssue(issue.issue, path, messageOverride ?? getFilterMessage(issue, defaultCheckHook));
6571
6663
  case "Encoding":
6572
- return formatIssue(issue.issue, path);
6664
+ return formatIssue(issue.issue, path, messageOverride);
6573
6665
  case "Pointer":
6574
- return formatIssue(issue.issue, path + formatPath(issue.path));
6666
+ return formatIssue(issue.issue, path + formatPath(issue.path), messageOverride);
6575
6667
  case "Composite":
6576
6668
  case "AnyOf": {
6577
6669
  if (issue._tag === "Composite" || issue.issues.length > 0) {
6578
- return issue.issues.map((issue) => formatIssue(issue, path)).join(`
6670
+ return issue.issues.map((issue) => formatIssue(issue, path, messageOverride)).join(`
6579
6671
  `);
6580
6672
  }
6581
- message = findMessage(issue) ?? getExpectedMessage(getExpected(issue.ast), issue);
6673
+ message = messageOverride ?? findMessage(issue) ?? getExpectedMessage(getExpected(issue.ast), issue);
6582
6674
  break;
6583
6675
  }
6584
6676
  default:
6585
- message = defaultLeafHook(issue);
6677
+ message = messageOverride ?? defaultLeafHook(issue);
6586
6678
  break;
6587
6679
  }
6588
6680
  return path ? `${message}
6589
6681
  at ${path}` : message;
6590
6682
  }
6591
6683
  function findMessage(issue) {
6592
- if (issue._tag === "Pointer")
6684
+ if (issue._tag === "Pointer" || issue._tag === "Composite")
6593
6685
  return;
6594
6686
  if (issue._tag === "Encoding")
6595
6687
  return findMessage(issue.issue);
@@ -6941,7 +7033,12 @@ var Declaration = class extends ASTNodeImpl {
6941
7033
  return (input, options) => {
6942
7034
  if (input === missing)
6943
7035
  return missingExit;
6944
- return (run ??= this.run(this.typeParameters))(input, this, options);
7036
+ run ??= this.run(this.typeParameters);
7037
+ try {
7038
+ return run(input, this, options);
7039
+ } catch (error) {
7040
+ return die3(error);
7041
+ }
6945
7042
  };
6946
7043
  }
6947
7044
  _rebuild(recur, checks, encodingChecks, run, encodingRun) {
@@ -7166,7 +7263,7 @@ var Arrays = class extends ASTNodeImpl {
7166
7263
  input,
7167
7264
  len,
7168
7265
  tailThreshold: Math.max(elementLen, len - tailLen),
7169
- output: new globalThis.Array(len),
7266
+ output: [],
7170
7267
  issues: undefined,
7171
7268
  options
7172
7269
  };
@@ -7275,7 +7372,7 @@ var wrapPropertyKeyIssue = (s, ast, key, exit) => {
7275
7372
  return fail5(new Composite(ast, [pointer], s.input, s.options));
7276
7373
  }
7277
7374
  };
7278
- var FINITE_PATTERN = "[+-]?\\d*\\.?\\d+(?:[Ee][+-]?\\d+)?";
7375
+ var FINITE_PATTERN = "[+-]?(?:\\d+(?:\\.\\d+)?|\\.\\d+)(?:[Ee][+-]?\\d+)?";
7279
7376
  function getIndexSignatureKeys(input, parameter, options = defaultParseOptions) {
7280
7377
  let stringKeys;
7281
7378
  let symbolKeys;
@@ -7514,9 +7611,15 @@ var Objects = class extends ASTNodeImpl {
7514
7611
  if (indexCount)
7515
7612
  return makeFallback();
7516
7613
  let fallback;
7517
- const resume = (state, index, pending) => {
7614
+ const resume = (snapshot, index, pending) => {
7518
7615
  const property = properties[index];
7519
7616
  return flatMap4(exit2(pending), (exit) => {
7617
+ const state = {
7618
+ ...snapshot,
7619
+ out: {
7620
+ ...snapshot.out
7621
+ }
7622
+ };
7520
7623
  const terminal = stepProperty(state, property, exit);
7521
7624
  if (terminal)
7522
7625
  return terminal;
@@ -7646,9 +7749,6 @@ function struct(fields, checks, annotations) {
7646
7749
  function getAST(self) {
7647
7750
  return self.ast;
7648
7751
  }
7649
- function tuple(elements, checks = undefined) {
7650
- return new Arrays(false, elements.map((e) => e.ast), [], undefined, checks);
7651
- }
7652
7752
  function union(members, options, checks) {
7653
7753
  return new Union(members.map(getAST), options, undefined, checks);
7654
7754
  }
@@ -8567,7 +8667,7 @@ var makeHandle = (params) => Object.setPrototypeOf({
8567
8667
  ...params
8568
8668
  }, HandleProto);
8569
8669
  var make15 = (spawn) => {
8570
- const streamString = (command, options) => spawn(command).pipe(map7((handle) => decodeText(options?.includeStderr === true ? handle.all : handle.stdout)), unwrap4);
8670
+ const streamString = (command, options) => spawn(command).pipe(map7((handle) => decodeText2(options?.includeStderr === true ? handle.all : handle.stdout)), unwrap4);
8571
8671
  const streamLines = (command, options) => splitLines2(streamString(command, options));
8572
8672
  return ChildProcessSpawner.of({
8573
8673
  spawn,
@@ -8736,6 +8836,7 @@ var handleErrnoException = (module, method) => (err, [path]) => {
8736
8836
  reason = "NotFound";
8737
8837
  break;
8738
8838
  case "EACCES":
8839
+ case "EPERM":
8739
8840
  reason = "PermissionDenied";
8740
8841
  break;
8741
8842
  case "EEXIST":
@@ -8764,66 +8865,149 @@ var handleErrnoException = (module, method) => (err, [path]) => {
8764
8865
  });
8765
8866
  };
8766
8867
 
8868
+ // node_modules/@effect/platform-node-shared/dist/NodeSink.js
8869
+ import { finished } from "stream";
8870
+
8871
+ // node_modules/@effect/platform-node-shared/dist/internal/stream.js
8872
+ var destroyStream = (stream, cleanup, onDestroyed) => {
8873
+ if (!("closed" in stream)) {
8874
+ cleanup();
8875
+ onDestroyed?.();
8876
+ return;
8877
+ }
8878
+ const onDone = () => {
8879
+ clearImmediate(immediate);
8880
+ stream.off("error", onDone);
8881
+ stream.off("close", onDone);
8882
+ onDestroyed?.();
8883
+ };
8884
+ const onClosed = () => {
8885
+ if (stream.closed) {
8886
+ onDone();
8887
+ } else {
8888
+ immediate = setImmediate(onClosed);
8889
+ if (!onDestroyed)
8890
+ immediate.unref();
8891
+ }
8892
+ };
8893
+ let immediate = setImmediate(onClosed);
8894
+ if (!onDestroyed)
8895
+ immediate.unref();
8896
+ stream.once("error", onDone);
8897
+ stream.once("close", onDone);
8898
+ cleanup();
8899
+ if (!stream.closed) {
8900
+ stream.destroy();
8901
+ }
8902
+ };
8903
+
8767
8904
  // node_modules/@effect/platform-node-shared/dist/NodeSink.js
8768
8905
  var fromWritable = (options) => fromChannel2(mapDone(fromWritableChannel(options), (_) => [_]));
8769
8906
  var fromWritableChannel = (options) => fromTransform((pull) => {
8770
8907
  const writable = options.evaluate();
8771
- return succeed6(pullIntoWritable({
8908
+ const write = pullIntoWritable({
8772
8909
  ...options,
8773
8910
  writable,
8774
8911
  pull
8775
- }));
8776
- });
8777
- var pullIntoWritable = (options) => options.pull.pipe(flatMap4((chunk) => {
8778
- let i = 0;
8779
- return callback2((resume) => {
8780
- let cancelled = false;
8781
- const loop = () => {
8782
- for (;i < chunk.length; ) {
8783
- if (cancelled) {
8784
- return;
8785
- }
8786
- const success = options.writable.write(chunk[i++], options.encoding);
8787
- if (!success) {
8788
- if (!cancelled) {
8789
- options.writable.once("drain", loop);
8912
+ });
8913
+ return succeed6(options.endOnDone === false ? write : onError2(write, (cause) => isDoneCause(cause) ? void_3 : releaseWritable(writable)));
8914
+ });
8915
+ var releaseWritable = (writable) => callback2((resume) => {
8916
+ const onDestroyed = () => resume(void_3);
8917
+ if (writable.closed) {
8918
+ const cleanup = finished(writable, {
8919
+ readable: false
8920
+ }, () => {
8921
+ cleanup();
8922
+ onDestroyed();
8923
+ });
8924
+ } else {
8925
+ destroyStream(writable, constVoid, onDestroyed);
8926
+ }
8927
+ });
8928
+ var pullIntoWritable = (options) => withFiber2((fiber) => {
8929
+ const dispatcher = fiber.currentDispatcher;
8930
+ const completion = makeUnsafe2();
8931
+ const failure = makeUnsafe2();
8932
+ const onError = (error) => doneUnsafe(failure, failSync2(() => options.onError(error)));
8933
+ let errorEmitted = false;
8934
+ const onStreamError = (error) => {
8935
+ errorEmitted = true;
8936
+ onError(error);
8937
+ };
8938
+ options.writable.on("error", onStreamError);
8939
+ const cleanup = finished(options.writable, {
8940
+ readable: false
8941
+ }, (error) => {
8942
+ if (error) {
8943
+ onError(error);
8944
+ } else {
8945
+ doneUnsafe(completion, void_3);
8946
+ }
8947
+ });
8948
+ return options.pull.pipe(flatMap4((chunk) => {
8949
+ let i = 0;
8950
+ return callback2((resume) => {
8951
+ let cancelled = false;
8952
+ const onFinish = () => dispatcher.scheduleTask(loop, 0);
8953
+ const loop = () => {
8954
+ options.writable.off("drain", loop);
8955
+ options.writable.off("finish", onFinish);
8956
+ for (;i < chunk.length; ) {
8957
+ if (cancelled) {
8958
+ return;
8959
+ }
8960
+ const success = options.writable.write(chunk[i++], options.encoding, (error) => {
8961
+ if (!error)
8962
+ return;
8963
+ if (options.writable.closed) {
8964
+ onError(error);
8965
+ } else {
8966
+ dispatcher.scheduleTask(() => onError(error), 0);
8967
+ }
8968
+ });
8969
+ if (!success) {
8970
+ if (!cancelled) {
8971
+ options.writable.once("drain", loop);
8972
+ options.writable.once("finish", onFinish);
8973
+ }
8974
+ return;
8790
8975
  }
8791
- return;
8792
8976
  }
8793
- }
8794
- if (!cancelled) {
8795
- resume(void_3);
8796
- }
8797
- };
8798
- loop();
8799
- return sync2(() => {
8800
- cancelled = true;
8801
- options.writable.off("drain", loop);
8977
+ if (!cancelled) {
8978
+ resume(void_3);
8979
+ }
8980
+ };
8981
+ loop();
8982
+ return sync2(() => {
8983
+ cancelled = true;
8984
+ options.writable.off("drain", loop);
8985
+ options.writable.off("finish", onFinish);
8986
+ });
8802
8987
  });
8803
- });
8804
- }), forever3({
8805
- disableYield: true
8806
- }), options.endOnDone !== false ? catchDone((_) => {
8807
- if ("closed" in options.writable && options.writable.closed) {
8808
- return done2(_);
8809
- }
8810
- return callback2((resume) => {
8811
- const onFinish = () => resume(done2(_));
8812
- options.writable.once("finish", onFinish);
8988
+ }), forever3({
8989
+ disableYield: true
8990
+ }), options.endOnDone !== false ? catchDone((_) => {
8813
8991
  options.writable.end();
8814
- return sync2(() => {
8815
- options.writable.off("finish", onFinish);
8816
- });
8817
- });
8818
- }) : identity, raceFirst2(callback2((resume) => {
8819
- const onError = (error) => resume(fail6(options.onError(error)));
8820
- options.writable.once("error", onError);
8821
- return sync2(() => {
8822
- options.writable.off("error", onError);
8823
- });
8824
- })));
8992
+ return andThen2(_await(completion), done2(_));
8993
+ }) : identity, raceFirst2(_await(failure)), ensuring2(sync2(() => {
8994
+ cleanup();
8995
+ const removeErrorListener = () => {
8996
+ options.writable.off("error", onStreamError);
8997
+ options.writable.off("error", removeErrorListener);
8998
+ options.writable.off("close", removeErrorListener);
8999
+ };
9000
+ if (options.writable.errored && !options.writable.closed && !errorEmitted) {
9001
+ options.writable.once("error", removeErrorListener);
9002
+ options.writable.once("close", removeErrorListener);
9003
+ } else {
9004
+ removeErrorListener();
9005
+ }
9006
+ })));
9007
+ });
8825
9008
 
8826
9009
  // node_modules/@effect/platform-node-shared/dist/NodeStream.js
9010
+ import { finished as finished2, Readable } from "stream";
8827
9011
  var fromReadable = (options) => fromChannel3(fromReadableChannel(options));
8828
9012
  var fromReadableChannel = (options) => fromTransform((_, scope) => readableToPullUnsafe({
8829
9013
  scope,
@@ -8840,17 +9024,14 @@ var readableToPullUnsafe = (options) => {
8840
9024
  function onReadable() {
8841
9025
  latch.openUnsafe();
8842
9026
  }
8843
- function onError(error) {
8844
- exit.current = fail5(options.onError(error));
8845
- latch.openUnsafe();
8846
- }
8847
- function onEnd() {
8848
- exit.current = fail5(Done2());
8849
- latch.openUnsafe();
8850
- }
8851
9027
  readable.on("readable", onReadable);
8852
- readable.once("error", onError);
8853
- readable.once("end", onEnd);
9028
+ const cleanup = finished2(readable, {
9029
+ readable: true,
9030
+ writable: false
9031
+ }, (error) => {
9032
+ exit.current ??= fail5(error ? options.onError(error) : Done2());
9033
+ latch.openUnsafe();
9034
+ });
8854
9035
  const pull = suspend2(function loop() {
8855
9036
  let item = options.readable.read(options.chunkSize);
8856
9037
  if (item === null) {
@@ -8874,10 +9055,10 @@ var readableToPullUnsafe = (options) => {
8874
9055
  });
8875
9056
  return as2(addFinalizer2(options.scope, sync2(() => {
8876
9057
  readable.off("readable", onReadable);
8877
- readable.off("error", onError);
8878
- readable.off("end", onEnd);
8879
- if (closeOnDone && "closed" in options.readable && !options.readable.closed) {
8880
- options.readable.destroy();
9058
+ if (closeOnDone) {
9059
+ destroyStream(readable, cleanup);
9060
+ } else {
9061
+ cleanup();
8881
9062
  }
8882
9063
  })), pull);
8883
9064
  };
@@ -9202,6 +9383,7 @@ var make17 = /* @__PURE__ */ gen2(function* () {
9202
9383
  const signalGroup = (signal) => killProcessGroup(command, childProcess, signal).pipe(catch_2(() => killProcess(command, childProcess, signal)));
9203
9384
  yield* signalGroup(options?.killSignal ?? "SIGTERM");
9204
9385
  if (isUndefined(options?.forceKillAfter)) {
9386
+ yield* _await(exitSignal);
9205
9387
  yield* awaitProcessExit(childProcess, exitSignal, processGroupGraceMillis);
9206
9388
  } else {
9207
9389
  yield* awaitProcessExit(childProcess, exitSignal, toMillis(options.forceKillAfter));
@@ -9448,10 +9630,14 @@ var ulidString = (timestampMillis, bytes) => {
9448
9630
  };
9449
9631
 
9450
9632
  // node_modules/effect/dist/internal/uuid.js
9451
- var hex = (byte) => byte.toString(16).padStart(2, "0");
9633
+ var hex = /* @__PURE__ */ Array.from({
9634
+ length: 256
9635
+ }, (_, byte) => byte.toString(16).padStart(2, "0"));
9452
9636
  var stringify = (bytes) => {
9453
- const segments = [bytes.subarray(0, 4), bytes.subarray(4, 6), bytes.subarray(6, 8), bytes.subarray(8, 10), bytes.subarray(10, 16)];
9454
- return segments.map((segment) => Array.from(segment, hex).join("")).join("-");
9637
+ if (bytes.length < 16) {
9638
+ return [bytes.subarray(0, 4), bytes.subarray(4, 6), bytes.subarray(6, 8), bytes.subarray(8, 10), bytes.subarray(10, 16)].map((segment) => Array.from(segment, (byte) => hex[byte]).join("")).join("-");
9639
+ }
9640
+ return hex[bytes[0]] + hex[bytes[1]] + hex[bytes[2]] + hex[bytes[3]] + "-" + hex[bytes[4]] + hex[bytes[5]] + "-" + hex[bytes[6]] + hex[bytes[7]] + "-" + hex[bytes[8]] + hex[bytes[9]] + "-" + hex[bytes[10]] + hex[bytes[11]] + hex[bytes[12]] + hex[bytes[13]] + hex[bytes[14]] + hex[bytes[15]];
9455
9641
  };
9456
9642
  var randomBytes = () => globalThis.crypto.getRandomValues(new Uint8Array(16));
9457
9643
  function v4Bytes(bytes = randomBytes()) {
@@ -9912,14 +10098,14 @@ var readLink = /* @__PURE__ */ (() => {
9912
10098
  return (path) => nodeReadLink(path);
9913
10099
  })();
9914
10100
  var realPath = /* @__PURE__ */ (() => {
9915
- const nodeRealPath = /* @__PURE__ */ effectify(NFS.realpath, /* @__PURE__ */ handleErrnoException("FileSystem", "realPath"), /* @__PURE__ */ handleBadArgument("realPath"));
10101
+ const nodeRealPath = /* @__PURE__ */ effectify(process.platform === "win32" ? NFS.realpath.native : NFS.realpath, /* @__PURE__ */ handleErrnoException("FileSystem", "realPath"), /* @__PURE__ */ handleBadArgument("realPath"));
9916
10102
  return (path) => nodeRealPath(path);
9917
10103
  })();
9918
10104
  var rename2 = /* @__PURE__ */ (() => {
9919
10105
  const nodeRename = /* @__PURE__ */ effectify(NFS.rename, /* @__PURE__ */ handleErrnoException("FileSystem", "rename"), /* @__PURE__ */ handleBadArgument("rename"));
9920
10106
  return (oldPath, newPath) => nodeRename(oldPath, newPath);
9921
10107
  })();
9922
- var makeFileInfo = (stat) => try_3({
10108
+ var makeFileInfo = (stat, method = "stat") => try_3({
9923
10109
  try: () => ({
9924
10110
  type: stat.isFile() ? "File" : stat.isDirectory() ? "Directory" : stat.isSymbolicLink() ? "SymbolicLink" : stat.isBlockDevice() ? "BlockDevice" : stat.isCharacterDevice() ? "CharacterDevice" : stat.isFIFO() ? "FIFO" : stat.isSocket() ? "Socket" : "Unknown",
9925
10111
  mtime: fromNullishOr(stat.mtime),
@@ -9936,14 +10122,16 @@ var makeFileInfo = (stat) => try_3({
9936
10122
  blksize: stat.blksize !== undefined ? some2(bytes(stat.blksize)) : none2(),
9937
10123
  blocks: fromNullishOr(stat.blocks)
9938
10124
  }),
9939
- catch: handleBadArgument("stat")
10125
+ catch: handleBadArgument(method)
9940
10126
  });
9941
- var stat2 = /* @__PURE__ */ (() => {
9942
- const nodeStat = /* @__PURE__ */ effectify(NFS.stat, /* @__PURE__ */ handleErrnoException("FileSystem", "stat"), /* @__PURE__ */ handleBadArgument("stat"));
10127
+ var statFactory = (method, nodeStatFn) => {
10128
+ const nodeStat = effectify(nodeStatFn, handleErrnoException("FileSystem", method), handleBadArgument(method));
9943
10129
  return (path) => flatMap4(nodeStat(path, {
9944
10130
  bigint: true
9945
- }), makeFileInfo);
9946
- })();
10131
+ }), (stat) => makeFileInfo(stat, method));
10132
+ };
10133
+ var stat2 = /* @__PURE__ */ statFactory("stat", NFS.stat);
10134
+ var lstat2 = /* @__PURE__ */ statFactory("lstat", NFS.lstat);
9947
10135
  var symlink2 = /* @__PURE__ */ (() => {
9948
10136
  const nodeSymlink = /* @__PURE__ */ effectify(NFS.symlink, /* @__PURE__ */ handleErrnoException("FileSystem", "symlink"), /* @__PURE__ */ handleBadArgument("symlink"));
9949
10137
  return (target, path) => nodeSymlink(target, path);
@@ -10000,7 +10188,7 @@ var watchNode = (path, info, options) => callback3((queue) => acquireRelease2(sy
10000
10188
  });
10001
10189
  return watcher;
10002
10190
  }), (watcher) => sync2(() => watcher.close())).pipe(tap2(() => sync2(() => options?.onReady?.()))));
10003
- var watch2 = (backend, path, options) => all2([stat2(path), serviceOption2(WatchBackend)]).pipe(map7(([stat, callerBackend]) => orElse(callerBackend, () => backend).pipe(flatMap((_) => _.register(path, stat, options)), getOrElse(() => watchNode(path, stat, options)))), unwrap4);
10191
+ var watch2 = (backend, path, options) => all3([stat2(path), serviceOption2(WatchBackend)]).pipe(map7(([stat, callerBackend]) => orElse(callerBackend, () => backend).pipe(flatMap((_) => _.register(path, stat, options)), getOrElse(() => watchNode(path, stat, options)))), unwrap4);
10004
10192
  var writeFile2 = (path, data, options) => callback2((resume, signal) => {
10005
10193
  try {
10006
10194
  NFS.writeFile(path, data, {
@@ -10026,6 +10214,7 @@ var makeFileSystem = /* @__PURE__ */ map7(/* @__PURE__ */ serviceOption2(WatchBa
10026
10214
  copyFile: copyFile2,
10027
10215
  glob: glob2,
10028
10216
  link: link2,
10217
+ lstat: lstat2,
10029
10218
  makeDirectory,
10030
10219
  makeTempDirectory,
10031
10220
  makeTempDirectoryScoped,
@@ -10641,6 +10830,16 @@ var CurrentRedactedNames2 = /* @__PURE__ */ Reference("effect/http/UrlParams/Cur
10641
10830
  // node_modules/effect/dist/internal/schema/interpreter.js
10642
10831
  var flatMapTransformation = (result, current, f) => result === sameExit ? f(current) : flatMapEager2(result, f);
10643
10832
  function compileTransformation(transformation) {
10833
+ const apply = compileTransformationUnsafe(transformation);
10834
+ return (result, current, options) => {
10835
+ try {
10836
+ return apply(result, current, options);
10837
+ } catch (error) {
10838
+ return die3(error);
10839
+ }
10840
+ };
10841
+ }
10842
+ function compileTransformationUnsafe(transformation) {
10644
10843
  if (transformation._tag === "Middleware") {
10645
10844
  return (result, current, options) => {
10646
10845
  const transformed = result === sameExit ? transformation.decode(succeed8(toOption2(current)), options) : transformation.decode(mapEager2(result, toOption2), options);
@@ -10716,53 +10915,57 @@ function compile(ast, compile, compileField, base, specialize) {
10716
10915
  let encodingParsers;
10717
10916
  const parseChecks = (input, options) => {
10718
10917
  let result = parser(input, options);
10719
- if (encodingChecks && !options.disableChecks) {
10720
- if (effectIsExit(result)) {
10721
- if (result._tag === "Success") {
10722
- const output = result === sameExit ? input : result[args];
10723
- if (input !== missing && output !== missing) {
10724
- const issues = collectIssues(encodingChecks, input, undefined, ast, options);
10725
- if (issues) {
10726
- result = fail6(new Composite(ast, issues, input, options));
10918
+ try {
10919
+ if (encodingChecks && !options.disableChecks) {
10920
+ if (effectIsExit(result)) {
10921
+ if (result._tag === "Success") {
10922
+ const output = result === sameExit ? input : result[args];
10923
+ if (input !== missing && output !== missing) {
10924
+ const issues = collectIssues(encodingChecks, input, undefined, ast, options);
10925
+ if (issues) {
10926
+ result = fail6(new Composite(ast, issues, input, options));
10927
+ }
10727
10928
  }
10728
10929
  }
10729
- }
10730
- } else {
10731
- result = flatMap4(result, (value) => {
10732
- if (input !== missing && value !== missing) {
10733
- const issues = collectIssues(encodingChecks, input, undefined, ast, options);
10734
- if (issues) {
10735
- return fail6(new Composite(ast, issues, input, options));
10930
+ } else {
10931
+ result = flatMap4(result, (value) => {
10932
+ if (input !== missing && value !== missing) {
10933
+ const issues = collectIssues(encodingChecks, input, undefined, ast, options);
10934
+ if (issues) {
10935
+ return fail6(new Composite(ast, issues, input, options));
10936
+ }
10736
10937
  }
10737
- }
10738
- return succeed6(value);
10739
- });
10740
- }
10741
- }
10742
- if (checks && !options.disableChecks) {
10743
- if (effectIsExit(result)) {
10744
- if (result._tag === "Success") {
10745
- const value = result === sameExit ? input : result[args];
10746
- if (value === missing)
10747
- return result;
10748
- const issues = collectIssues(checks, value, undefined, ast, options);
10749
- if (issues) {
10750
- result = fail6(new Composite(ast, issues, value, options));
10751
- }
10938
+ return succeed6(value);
10939
+ });
10752
10940
  }
10753
- } else {
10754
- result = flatMap4(result, (value) => {
10755
- if (value !== missing) {
10941
+ }
10942
+ if (checks && !options.disableChecks) {
10943
+ if (effectIsExit(result)) {
10944
+ if (result._tag === "Success") {
10945
+ const value = result === sameExit ? input : result[args];
10946
+ if (value === missing)
10947
+ return result;
10756
10948
  const issues = collectIssues(checks, value, undefined, ast, options);
10757
10949
  if (issues) {
10758
- return fail6(new Composite(ast, issues, value, options));
10950
+ result = fail6(new Composite(ast, issues, value, options));
10759
10951
  }
10760
10952
  }
10761
- return succeed6(value);
10762
- });
10953
+ } else {
10954
+ result = flatMap4(result, (value) => {
10955
+ if (value !== missing) {
10956
+ const issues = collectIssues(checks, value, undefined, ast, options);
10957
+ if (issues) {
10958
+ return fail6(new Composite(ast, issues, value, options));
10959
+ }
10960
+ }
10961
+ return succeed6(value);
10962
+ });
10963
+ }
10763
10964
  }
10965
+ return result;
10966
+ } catch (error) {
10967
+ return die3(error);
10764
10968
  }
10765
- return result;
10766
10969
  };
10767
10970
  const parseLocal = specialize === undefined ? parseChecks : specialize(parseChecks);
10768
10971
  if (!links) {
@@ -11134,6 +11337,14 @@ function toCodecJson(schema) {
11134
11337
  });
11135
11338
  }
11136
11339
  var toCodecJsonAST = /* @__PURE__ */ applyToSelfOrLastLinkEncodingIdempotent((ast) => {
11340
+ const owner = getContextOwner(ast);
11341
+ if (owner !== ast) {
11342
+ const fromOwner = toCodecJsonAST(owner);
11343
+ if (fromOwner === owner)
11344
+ return ast;
11345
+ if (fromOwner.encoding === undefined)
11346
+ return replaceContext(fromOwner, ast.context);
11347
+ }
11137
11348
  const out = toCodecJsonASTStep(ast, toCodecJsonAST);
11138
11349
  const context = ast.context;
11139
11350
  if (out === ast || context === undefined)
@@ -11400,18 +11611,6 @@ function makeStruct(ast, fields) {
11400
11611
  function Struct(fields) {
11401
11612
  return makeStruct(struct(fields, undefined), fields);
11402
11613
  }
11403
- function makeTuple(ast, elements) {
11404
- return make26(ast, {
11405
- elements,
11406
- mapElements(f, options) {
11407
- const elements = f(this.elements);
11408
- return makeTuple(tuple(elements, options?.unsafePreserveChecks ? this.ast.checks : undefined), elements);
11409
- }
11410
- });
11411
- }
11412
- function Tuple2(elements) {
11413
- return makeTuple(tuple(elements), elements);
11414
- }
11415
11614
  var ArraySchema = /* @__PURE__ */ lambda((schema) => make26(new Arrays(false, [], [schema.ast]), {
11416
11615
  value: schema
11417
11616
  }));
@@ -11488,32 +11687,24 @@ function link3() {
11488
11687
  };
11489
11688
  }
11490
11689
  var makeFilter2 = makeFilter;
11491
- function isPattern2(regExp, annotations) {
11492
- const source = regExp.source;
11493
- const flags = regExp.flags;
11494
- const canExport = /^[dg]*uy?$/.test(flags);
11495
- const runtimeRegExp = flags === "" ? `new RegExp(${format(source)})` : `new RegExp(${format(source)}, ${format(flags)})`;
11496
- return isPattern(regExp, {
11497
- toJsonSchema: () => canExport ? {
11498
- pattern: flags.endsWith("y") ? `^(?:${source})` : source
11499
- } : [{}, true],
11500
- toCode: () => ({
11501
- runtime: `Schema.isPattern(${runtimeRegExp})`
11502
- }),
11503
- ...annotations
11504
- });
11505
- }
11506
11690
  function isBase64(annotations) {
11507
- const regExp = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
11508
- return isPattern2(regExp, {
11691
+ const pattern = "^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$";
11692
+ const regExp = /^[0-9a-zA-Z+/]*={0,2}$/;
11693
+ return makeFilter2((s) => s.length % 4 === 0 && regExp.test(s), {
11509
11694
  expected: "a base64 encoded string",
11510
11695
  representation: {
11511
11696
  id: "effect/schema/isBase64",
11512
11697
  payload: null
11513
11698
  },
11514
11699
  toJsonSchema: () => ({
11515
- pattern: regExp.source
11700
+ pattern
11516
11701
  }),
11702
+ arbitraryConstraint: {
11703
+ patterns: [{
11704
+ source: pattern,
11705
+ flags: ""
11706
+ }]
11707
+ },
11517
11708
  toCode: () => ({
11518
11709
  runtime: "Schema.isBase64()"
11519
11710
  }),
@@ -11665,47 +11856,6 @@ var File = /* @__PURE__ */ instanceOf(globalThis.File, {
11665
11856
  })
11666
11857
  }))
11667
11858
  });
11668
- var FormData2 = /* @__PURE__ */ instanceOf(globalThis.FormData, {
11669
- representation: {
11670
- id: "effect/schema/FormData",
11671
- payload: null
11672
- },
11673
- toCode: () => ({
11674
- runtime: `Schema.FormData`,
11675
- Type: `globalThis.FormData`
11676
- }),
11677
- expected: "FormData",
11678
- toCodecJson: () => link3()(ArraySchema(Tuple2([String4, Union2([Struct({
11679
- _tag: tag("String"),
11680
- value: String4
11681
- }), Struct({
11682
- _tag: tag("File"),
11683
- value: File
11684
- })])])), transformEffect2({
11685
- decode: (e) => {
11686
- const out = new globalThis.FormData;
11687
- for (const [key, entry] of e) {
11688
- out.append(key, entry.value);
11689
- }
11690
- return succeed6(out);
11691
- },
11692
- encode: (formData) => {
11693
- return succeed6(globalThis.Array.from(formData.entries()).map(([key, value]) => {
11694
- if (typeof value === "string") {
11695
- return [key, {
11696
- _tag: "String",
11697
- value
11698
- }];
11699
- } else {
11700
- return [key, {
11701
- _tag: "File",
11702
- value
11703
- }];
11704
- }
11705
- }));
11706
- }
11707
- }))
11708
- });
11709
11859
  var URLSearchParams2 = /* @__PURE__ */ instanceOf(globalThis.URLSearchParams, {
11710
11860
  representation: {
11711
11861
  id: "effect/schema/URLSearchParams",
@@ -11871,13 +12021,16 @@ function makeClass(Inherited, identifier, struct2, annotations, proto) {
11871
12021
  }
11872
12022
  return out;
11873
12023
  }
11874
- function getClassTransformation(self) {
11875
- return new Transformation(transform((input) => new self(input, {
12024
+ function makeClassTrusted(self, fields) {
12025
+ return new self(fields, {
11876
12026
  "~payload": {
11877
12027
  token: payloadToken,
11878
- value: input
12028
+ value: fields
11879
12029
  }
11880
- })), passthrough2());
12030
+ });
12031
+ }
12032
+ function getClassTransformation(self) {
12033
+ return new Transformation(transform((input) => makeClassTrusted(self, input)), passthrough2());
11881
12034
  }
11882
12035
  function getClassTypeId(identifier) {
11883
12036
  return `~effect/Schema/Class/${identifier}`;
@@ -11985,9 +12138,6 @@ var make28 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQu
11985
12138
  readline.emitKeypressEvents(stdin, rl);
11986
12139
  rl.on("line", onLine);
11987
12140
  rl.once("close", onClose);
11988
- if (stdin.isTTY) {
11989
- stdin.setRawMode(true);
11990
- }
11991
12141
  return {
11992
12142
  rl,
11993
12143
  onClose,
@@ -12001,9 +12151,6 @@ var make28 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQu
12001
12151
  readlineActive = false;
12002
12152
  rl.off("line", onLine);
12003
12153
  rl.off("close", onClose);
12004
- if (stdin.isTTY) {
12005
- stdin.setRawMode(false);
12006
- }
12007
12154
  rl.close();
12008
12155
  if (inputEnded) {
12009
12156
  endUnsafe(lines);
@@ -12011,6 +12158,14 @@ var make28 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQu
12011
12158
  })),
12012
12159
  idleTimeToLive: "10 millis"
12013
12160
  });
12161
+ const setRawMode = (enabled) => sync2(() => {
12162
+ if (stdin.isTTY)
12163
+ stdin.setRawMode(enabled);
12164
+ });
12165
+ const rawModeRef = yield* make11({
12166
+ acquire: acquireRelease2(setRawMode(true), () => setRawMode(false)),
12167
+ idleTimeToLive: "10 millis"
12168
+ });
12014
12169
  const columns = sync2(() => stdout.columns ?? 0);
12015
12170
  const rows = sync2(() => stdout.rows ?? 0);
12016
12171
  const readInput = gen2(function* () {
@@ -12045,6 +12200,7 @@ var make28 = /* @__PURE__ */ fnUntraced2(function* (shouldQuit = defaultShouldQu
12045
12200
  handleEnd();
12046
12201
  } else {
12047
12202
  yield* get3(rlRef);
12203
+ yield* get3(rawModeRef);
12048
12204
  stdin.once("end", handleEnd);
12049
12205
  }
12050
12206
  return queue;
@@ -12232,6 +12388,10 @@ var orElse2 = /* @__PURE__ */ dual(2, (self, that) => {
12232
12388
  onSuccess: (resolution) => isFailure2(resolution) ? evaluateAt(that(resolution.failure), provider, pathPrefix) : succeed6(resolution)
12233
12389
  }));
12234
12390
  });
12391
+ function all4(arg) {
12392
+ const configs = globalThis.Array.isArray(arg) ? arg : (Symbol.iterator in arg) ? [...arg] : arg;
12393
+ return make30((provider, pathPrefix) => globalThis.Array.isArray(configs) ? mapEager2(all3(configs.map((config) => evaluateAt(config, provider, pathPrefix))), all) : mapEager2(all3(map3(configs, (config) => evaluateAt(config, provider, pathPrefix))), all));
12394
+ }
12235
12395
  var withDefault3 = /* @__PURE__ */ dual(2, (self, defaultValue) => {
12236
12396
  return make30((provider, pathPrefix) => mapEager2(evaluateAt(self, provider, pathPrefix), (resolution) => isFailure2(resolution) ? succeed2(defaultValue) : resolution));
12237
12397
  });
@@ -12279,7 +12439,6 @@ var toConfigCursorAST = /* @__PURE__ */ memoize((root) => {
12279
12439
  seen.add(ast);
12280
12440
  switch (ast._tag) {
12281
12441
  case "Objects": {
12282
- const matchesIndex = ast.indexSignatures.map((is) => _is(is.parameter));
12283
12442
  const materialize = fnUntraced2(function* (cursor) {
12284
12443
  if (cursor.node?._tag !== "Record") {
12285
12444
  return;
@@ -12290,10 +12449,16 @@ var toConfigCursorAST = /* @__PURE__ */ memoize((root) => {
12290
12449
  if (typeof property.name === "string")
12291
12450
  keys.add(property.name);
12292
12451
  }
12293
- if (matchesIndex.length > 0) {
12452
+ if (ast.indexSignatures.length > 0) {
12453
+ const input = {};
12294
12454
  for (const key of node.keys) {
12295
- if (matchesIndex.some((matches) => matches(key)))
12296
- keys.add(key);
12455
+ assignProperty(input, key, undefined);
12456
+ }
12457
+ for (const is of ast.indexSignatures) {
12458
+ for (const key of getIndexSignatureKeys(input, is.parameter)) {
12459
+ if (typeof key === "string")
12460
+ keys.add(key);
12461
+ }
12297
12462
  }
12298
12463
  }
12299
12464
  const out = {};
@@ -12355,6 +12520,9 @@ function schema(codec, path) {
12355
12520
  }))), mapReasons((reason) => isDieReason2(reason) && isSourceError(reason.defect) ? makeFailReason(new ConfigError(reason.defect)).annotate(reasonAnnotations2(reason)) : reason));
12356
12521
  });
12357
12522
  }
12523
+ function String5(name) {
12524
+ return schema(String4, name);
12525
+ }
12358
12526
  function Redacted2(name) {
12359
12527
  return schema(Redacted(String4), name);
12360
12528
  }
@@ -12582,6 +12750,12 @@ class UnknownSubcommand extends (/* @__PURE__ */ TaggedError3(`${TypeId33}/Unkno
12582
12750
  }
12583
12751
  }
12584
12752
 
12753
+ class ValidationError extends (/* @__PURE__ */ TaggedError3(`${TypeId33}/ValidationError`)("ValidationError", {
12754
+ message: String4
12755
+ })) {
12756
+ [TypeId33] = TypeId33;
12757
+ }
12758
+
12585
12759
  class UserError extends (/* @__PURE__ */ TaggedError3(`${TypeId33}/UserError`)("UserError", {
12586
12760
  cause: /* @__PURE__ */ Defect(),
12587
12761
  userMessage: /* @__PURE__ */ optionalKey2(String4)
@@ -12598,7 +12772,7 @@ class UserError extends (/* @__PURE__ */ TaggedError3(`${TypeId33}/UserError`)("
12598
12772
  return "An error occurred";
12599
12773
  }
12600
12774
  }
12601
- var NonShowHelpErrors = /* @__PURE__ */ Union2([UnrecognizedOption, DuplicateOption, MissingOption, MissingArgument, UnexpectedArgument, InvalidValue2, UnknownSubcommand, UserError]);
12775
+ var NonShowHelpErrors = /* @__PURE__ */ Union2([UnrecognizedOption, DuplicateOption, MissingOption, MissingArgument, UnexpectedArgument, InvalidValue2, UnknownSubcommand, ValidationError, UserError]);
12602
12776
 
12603
12777
  class ShowHelp extends (/* @__PURE__ */ TaggedError3(`${TypeId33}/ShowHelp`)("ShowHelp", {
12604
12778
  commandPath: /* @__PURE__ */ ArraySchema(String4),
@@ -12632,7 +12806,7 @@ var makeSchemaPrimitive = (tag, schema) => {
12632
12806
  return makePrimitive2(tag, (value) => mapError3(decode(value), (error) => error.message));
12633
12807
  };
12634
12808
  var Boolean4 = /* @__PURE__ */ makeSchemaPrimitive("Boolean", BooleanLiterals);
12635
- var String5 = /* @__PURE__ */ makePrimitive2("String", (value) => succeed6(value));
12809
+ var String6 = /* @__PURE__ */ makePrimitive2("String", (value) => succeed6(value));
12636
12810
  var Choice = (choices) => {
12637
12811
  const choiceMap = new Map(choices);
12638
12812
  const validChoices = choices.map(([key]) => format(key)).join(" | ");
@@ -12975,7 +13149,7 @@ var succeed9 = (value) => {
12975
13149
  op.value = value;
12976
13150
  return op;
12977
13151
  };
12978
- var String6 = (options) => basePrompt(options, "text");
13152
+ var String7 = (options) => basePrompt(options, "text");
12979
13153
  var Toggle = (options) => {
12980
13154
  const opts = {
12981
13155
  initial: false,
@@ -14431,9 +14605,9 @@ var makeSingle2 = (params) => {
14431
14605
  parse
14432
14606
  }, Proto10);
14433
14607
  };
14434
- var String7 = (kind, name) => makeSingle2({
14608
+ var String8 = (kind, name) => makeSingle2({
14435
14609
  name,
14436
- primitiveType: String5,
14610
+ primitiveType: String6,
14437
14611
  kind
14438
14612
  });
14439
14613
  var Boolean5 = (kind, name) => makeSingle2({
@@ -14684,229 +14858,6 @@ var getParamMetadata = (param) => {
14684
14858
  })
14685
14859
  });
14686
14860
  };
14687
- // node_modules/effect/dist/cli/CliOutput.js
14688
- var Formatter = /* @__PURE__ */ Reference("effect/cli/CliOutput", {
14689
- defaultValue: () => defaultFormatter2()
14690
- });
14691
- var escapeControlCharacters = (text) => text.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/g, (character) => `\\x${character.charCodeAt(0).toString(16).padStart(2, "0")}`);
14692
- var defaultFormatter2 = (options) => {
14693
- const useColor = options?.colors ?? detectColors();
14694
- const colors = useColor ? {
14695
- bold: (text) => `\x1B[1m${text}\x1B[0m`,
14696
- dim: (text) => `\x1B[2m${text}\x1B[0m`,
14697
- cyan: (text) => `\x1B[36m${text}\x1B[0m`,
14698
- green: (text) => `\x1B[32m${text}\x1B[0m`,
14699
- blue: (text) => `\x1B[34m${text}\x1B[0m`,
14700
- yellow: (text) => `\x1B[33m${text}\x1B[0m`,
14701
- magenta: (text) => `\x1B[35m${text}\x1B[0m`
14702
- } : {
14703
- bold: (text) => text,
14704
- dim: (text) => text,
14705
- cyan: (text) => text,
14706
- green: (text) => text,
14707
- blue: (text) => text,
14708
- yellow: (text) => text,
14709
- magenta: (text) => text
14710
- };
14711
- const reset = useColor ? "\x1B[0m" : "";
14712
- const red = useColor ? "\x1B[31m" : "";
14713
- const bold = useColor ? "\x1B[1m" : "";
14714
- return {
14715
- formatHelpDoc: (doc) => formatHelpDocImpl(doc, colors),
14716
- formatCliError: (error) => escapeControlCharacters(error.message),
14717
- formatError: (error) => {
14718
- return `
14719
- ${bold}${red}ERROR${reset}
14720
- ${escapeControlCharacters(error.message)}${reset}`;
14721
- },
14722
- formatErrors: (errors) => {
14723
- if (errors.length === 0)
14724
- return "";
14725
- if (errors.length === 1) {
14726
- return `
14727
- ${bold}${red}ERROR${reset}
14728
- ${escapeControlCharacters(errors[0].message)}${reset}`;
14729
- }
14730
- const grouped = new Map;
14731
- for (const error of errors) {
14732
- const tag = error._tag ?? "Error";
14733
- const group = grouped.get(tag) ?? [];
14734
- group.push(error);
14735
- grouped.set(tag, group);
14736
- }
14737
- const sections = [];
14738
- sections.push(`
14739
- ${bold}${red}ERRORS${reset}`);
14740
- for (const [, group] of grouped) {
14741
- for (const error of group) {
14742
- sections.push(` ${escapeControlCharacters(error.message)}${reset}`);
14743
- }
14744
- }
14745
- return sections.join(`
14746
- `);
14747
- },
14748
- formatVersion: (name, version) => `${colors.bold(name)} ${colors.dim("v")}${colors.bold(version)}`
14749
- };
14750
- };
14751
- var stripAnsi = (text) => {
14752
- return text.replace(/\u001B\[[0-9;]*m/g, "");
14753
- };
14754
- var graphemeSegmenter = /* @__PURE__ */ new Intl.Segmenter(undefined, {
14755
- granularity: "grapheme"
14756
- });
14757
- var zeroWidthCodePoints = /[\p{Mark}\p{Control}\p{Default_Ignorable_Code_Point}]/gu;
14758
- var emojiPresentation = /\p{Emoji_Presentation}/u;
14759
- var isFullWidthCodePoint = (codePoint) => {
14760
- if (codePoint < 4352)
14761
- return false;
14762
- return codePoint <= 4447 || codePoint === 9001 || codePoint === 9002 || codePoint >= 11904 && codePoint <= 12350 || codePoint >= 12352 && codePoint <= 42191 || codePoint >= 44032 && codePoint <= 55203 || codePoint >= 63744 && codePoint <= 64255 || codePoint >= 65040 && codePoint <= 65049 || codePoint >= 65072 && codePoint <= 65135 || codePoint >= 65280 && codePoint <= 65376 || codePoint >= 65504 && codePoint <= 65510 || codePoint >= 110592 && codePoint <= 111359 || codePoint >= 127488 && codePoint <= 127569 || codePoint >= 131072 && codePoint <= 262141;
14763
- };
14764
- var graphemeWidth = (grapheme) => {
14765
- const visible = grapheme.replace(zeroWidthCodePoints, "");
14766
- if (visible.length === 0)
14767
- return 0;
14768
- if (emojiPresentation.test(grapheme) || grapheme.includes("\uFE0F"))
14769
- return 2;
14770
- return isFullWidthCodePoint(visible.codePointAt(0)) ? 2 : 1;
14771
- };
14772
- var displayWidth = (text) => {
14773
- let length = 0;
14774
- for (const {
14775
- segment
14776
- } of graphemeSegmenter.segment(stripAnsi(text))) {
14777
- length += graphemeWidth(segment);
14778
- }
14779
- return length;
14780
- };
14781
- var pad = (s, width) => {
14782
- const actualLength = displayWidth(s);
14783
- const padding = Math.max(0, width - actualLength);
14784
- return s + " ".repeat(padding);
14785
- };
14786
- var renderTable = (rows, widthCap) => {
14787
- const maxColumn = Math.max(...rows.map((r) => displayWidth(r.left))) + 4;
14788
- const col = widthCap === undefined ? maxColumn : Math.min(maxColumn, widthCap);
14789
- return rows.map(({
14790
- left,
14791
- right
14792
- }) => ` ${pad(left, Math.max(col, displayWidth(left) + 1))}${right}`).join(`
14793
- `);
14794
- };
14795
- var formatSubcommandName = (name, alias) => alias ? `${name}, ${alias}` : name;
14796
- var formatHelpDocImpl = (doc, colors) => {
14797
- const sections = [];
14798
- if (doc.description) {
14799
- sections.push(colors.bold("DESCRIPTION"));
14800
- sections.push(` ${doc.description}`);
14801
- sections.push("");
14802
- }
14803
- sections.push(colors.bold("USAGE"));
14804
- sections.push(` ${colors.cyan(doc.usage)}`);
14805
- sections.push("");
14806
- if (doc.args && doc.args.length > 0) {
14807
- sections.push(colors.bold("ARGUMENTS"));
14808
- const argRows = doc.args.map((arg) => {
14809
- let name = arg.name;
14810
- if (arg.variadic) {
14811
- name += "...";
14812
- }
14813
- const coloredName = colors.green(name);
14814
- const coloredType = colors.dim(arg.type);
14815
- const nameType = `${coloredName} ${coloredType}`;
14816
- const optionalSuffix = arg.required ? "" : colors.dim(" (optional)");
14817
- const description = getOrElse(arg.description, () => "") + optionalSuffix;
14818
- return {
14819
- left: nameType,
14820
- right: description
14821
- };
14822
- });
14823
- sections.push(renderTable(argRows, 25));
14824
- sections.push("");
14825
- }
14826
- if (doc.flags.length > 0) {
14827
- sections.push(colors.bold("FLAGS"));
14828
- const flagRows = doc.flags.map((flag) => {
14829
- const names = [];
14830
- names.push(colors.green(`--${flag.name}`));
14831
- for (const alias of flag.aliases) {
14832
- names.push(colors.green(alias));
14833
- }
14834
- const namesPart = names.join(", ");
14835
- const typePart = flag.type !== "boolean" ? ` ${colors.dim(flag.type)}` : "";
14836
- return {
14837
- left: namesPart + typePart,
14838
- right: getOrElse(flag.description, () => "")
14839
- };
14840
- });
14841
- sections.push(renderTable(flagRows));
14842
- sections.push("");
14843
- }
14844
- if (doc.globalFlags && doc.globalFlags.length > 0) {
14845
- sections.push(colors.bold("GLOBAL FLAGS"));
14846
- const globalFlagRows = doc.globalFlags.map((flag) => {
14847
- const names = [];
14848
- names.push(colors.green(`--${flag.name}`));
14849
- for (const alias of flag.aliases) {
14850
- names.push(colors.green(alias));
14851
- }
14852
- const namesPart = names.join(", ");
14853
- const typePart = flag.type !== "boolean" ? ` ${colors.dim(flag.type)}` : "";
14854
- return {
14855
- left: namesPart + typePart,
14856
- right: getOrElse(flag.description, () => "")
14857
- };
14858
- });
14859
- sections.push(renderTable(globalFlagRows));
14860
- sections.push("");
14861
- }
14862
- if (doc.subcommands && doc.subcommands.length > 0) {
14863
- const ungrouped = doc.subcommands.find((group) => group.group === undefined);
14864
- if (ungrouped) {
14865
- sections.push(colors.bold("SUBCOMMANDS"));
14866
- sections.push(renderTable(ungrouped.commands.map((sub) => ({
14867
- left: colors.cyan(formatSubcommandName(sub.name, sub.alias)),
14868
- right: sub.shortDescription ?? sub.description
14869
- })), 20));
14870
- if (doc.subcommands.length > 1) {
14871
- sections.push("");
14872
- }
14873
- }
14874
- for (const group of doc.subcommands) {
14875
- if (group.group === undefined)
14876
- continue;
14877
- sections.push(colors.bold(`${group.group}:`));
14878
- sections.push(renderTable(group.commands.map((sub) => ({
14879
- left: colors.cyan(formatSubcommandName(sub.name, sub.alias)),
14880
- right: sub.shortDescription ?? sub.description
14881
- })), 20));
14882
- sections.push("");
14883
- }
14884
- }
14885
- if (doc.examples && doc.examples.length > 0) {
14886
- sections.push(colors.bold("EXAMPLES"));
14887
- let first = true;
14888
- let previousHadDescription = false;
14889
- for (const example of doc.examples) {
14890
- if (example.description) {
14891
- if (!first)
14892
- sections.push("");
14893
- sections.push(` ${colors.dim(`# ${example.description}`)}`);
14894
- } else if (previousHadDescription) {
14895
- sections.push("");
14896
- }
14897
- sections.push(` ${colors.cyan(example.command)}`);
14898
- first = false;
14899
- previousHadDescription = !!example.description;
14900
- }
14901
- sections.push("");
14902
- }
14903
- if (sections[sections.length - 1] === "") {
14904
- sections.pop();
14905
- }
14906
- return sections.join(`
14907
- `);
14908
- };
14909
-
14910
14861
  // node_modules/effect/dist/cli/internal/config.js
14911
14862
  var ConfigInternalTypeId = "~effect/cli/Command/Config/Internal";
14912
14863
  var parseConfig = (config) => {
@@ -14990,6 +14941,7 @@ var makeCommand = (options) => {
14990
14941
  const annotations = options.annotations ?? empty();
14991
14942
  const globalFlags = options.globalFlags ?? [];
14992
14943
  const subcommands = options.subcommands ?? [];
14944
+ const resolveExamples = options.resolveExamples ?? noExamples;
14993
14945
  const handle = (input, commandPath) => isNotUndefined(options.handle) ? options.handle(input, commandPath) : fail6(new ShowHelp({
14994
14946
  commandPath,
14995
14947
  errors: []
@@ -15047,7 +14999,7 @@ var makeCommand = (options) => {
15047
14999
  }))
15048
15000
  });
15049
15001
  }
15050
- const examples = options.examples ?? [];
15002
+ const examples = resolveExamples(commandPath);
15051
15003
  return {
15052
15004
  description: options.description ?? "",
15053
15005
  usage,
@@ -15067,7 +15019,8 @@ var makeCommand = (options) => {
15067
15019
  return Object.assign(Object.create(Proto11), {
15068
15020
  [TypeId37]: TypeId37,
15069
15021
  name: options.name,
15070
- examples: options.examples ?? [],
15022
+ examples: resolveExamples([options.name]),
15023
+ resolveExamples,
15071
15024
  annotations,
15072
15025
  globalFlags,
15073
15026
  subcommands,
@@ -15090,6 +15043,7 @@ var makeCommand = (options) => {
15090
15043
  } : {}
15091
15044
  });
15092
15045
  };
15046
+ var noExamples = () => [];
15093
15047
  var toFlagDoc = (single, metadata) => {
15094
15048
  const formattedAliases = single.aliases.map((alias) => alias.length === 1 ? `-${alias}` : `--${alias}`);
15095
15049
  const type = single.typeName ?? getTypeName(single.primitiveType);
@@ -15271,7 +15225,8 @@ var fromCommand = (cmd, inheritedFlags = []) => {
15271
15225
  aliases: single.aliases,
15272
15226
  description: getOrUndefined(single.description),
15273
15227
  type: toFlagType(single),
15274
- optionalValue: single.optionalValue !== undefined
15228
+ optionalValue: single.optionalValue !== undefined,
15229
+ negation: single.negation
15275
15230
  });
15276
15231
  }
15277
15232
  }
@@ -15316,6 +15271,7 @@ var fromCommand = (cmd, inheritedFlags = []) => {
15316
15271
  };
15317
15272
  };
15318
15273
  var takesSeparateValue = (flag) => flag.type._tag !== "Boolean" && flag.optionalValue !== true;
15274
+ var negatedName = (flag) => flag.type._tag !== "Boolean" || flag.negation === false ? undefined : flag.negation ?? `no-${flag.name}`;
15319
15275
 
15320
15276
  // node_modules/effect/dist/cli/internal/completions/bash.js
15321
15277
  var escapeForBash = (s) => s.replace(/'/g, "'\\''");
@@ -15325,8 +15281,9 @@ var flagNamesForWordlist = (flag) => {
15325
15281
  for (const alias of flag.aliases) {
15326
15282
  names.push(alias.length === 1 ? `-${alias}` : `--${alias}`);
15327
15283
  }
15328
- if (flag.type._tag === "Boolean") {
15329
- names.push(`--no-${flag.name}`);
15284
+ const negation = negatedName(flag);
15285
+ if (negation !== undefined) {
15286
+ names.push(`--${negation}`);
15330
15287
  }
15331
15288
  return names;
15332
15289
  };
@@ -15635,8 +15592,9 @@ var flagContainsOptCondition = (flag) => {
15635
15592
  optArgs.push(alias);
15636
15593
  }
15637
15594
  }
15638
- if (flag.type._tag === "Boolean") {
15639
- optArgs.push(`no-${flag.name}`);
15595
+ const negation = negatedName(flag);
15596
+ if (negation !== undefined) {
15597
+ optArgs.push(negation);
15640
15598
  }
15641
15599
  return `not __fish_contains_opt ${optArgs.join(" ")}`;
15642
15600
  };
@@ -15720,11 +15678,12 @@ var generateCompletions = (executableName, descriptor, parentPath, lines) => {
15720
15678
  parts.push(flagCondArg);
15721
15679
  parts.push(...flagCompletionArgs(flag));
15722
15680
  lines.push(parts.join(" "));
15723
- if (flag.type._tag === "Boolean") {
15681
+ const negation = negatedName(flag);
15682
+ if (negation !== undefined) {
15724
15683
  const negParts = [`complete -c ${executableName}`];
15725
15684
  if (flagCondArg)
15726
15685
  negParts.push(flagCondArg);
15727
- negParts.push(`-l no-${flag.name}`);
15686
+ negParts.push(`-l ${negation}`);
15728
15687
  if (flag.description) {
15729
15688
  negParts.push(`-d '${escapeFishString(`Disable ${flag.name}`)}'`);
15730
15689
  }
@@ -15736,7 +15695,7 @@ var generateCompletions = (executableName, descriptor, parentPath, lines) => {
15736
15695
  const bareBase = condition ? `${condition}; and ${notDash}` : notDash;
15737
15696
  for (const flag of descriptor.flags) {
15738
15697
  const bareCondition = `${bareBase}; and ${flagContainsOptCondition(flag)}`;
15739
- const isBoolean = flag.type._tag === "Boolean";
15698
+ const negation = negatedName(flag);
15740
15699
  const parts = [`complete -c ${executableName}`];
15741
15700
  parts.push(`-n '${bareCondition}'`);
15742
15701
  parts.push(`-f -a '--${flag.name}'`);
@@ -15744,10 +15703,10 @@ var generateCompletions = (executableName, descriptor, parentPath, lines) => {
15744
15703
  parts.push(`-d '${escapeFishString(flag.description)}'`);
15745
15704
  }
15746
15705
  lines.push(parts.join(" "));
15747
- if (isBoolean) {
15706
+ if (negation !== undefined) {
15748
15707
  const negParts = [`complete -c ${executableName}`];
15749
15708
  negParts.push(`-n '${bareCondition}'`);
15750
- negParts.push(`-f -a '--no-${flag.name}'`);
15709
+ negParts.push(`-f -a '--${negation}'`);
15751
15710
  if (flag.description) {
15752
15711
  negParts.push(`-d '${escapeFishString(`Disable ${flag.name}`)}'`);
15753
15712
  }
@@ -15813,7 +15772,10 @@ var psOptional = (s) => s ? quotePs(s) : "$null";
15813
15772
  var sanitize = (s) => s.replace(/[^a-zA-Z0-9_]/g, "_");
15814
15773
  var flagForms = (flag) => [`--${flag.name}`, ...flag.aliases.map((alias) => alias.length === 1 ? `-${alias}` : `--${alias}`)];
15815
15774
  var valueFields = (type) => `values = ${psArray(type._tag === "Choice" ? type.values : [])}; ` + `pathType = ${type._tag === "Path" ? quotePs(type.pathType) : "$null"}`;
15816
- var flagEntry = (flag) => `@{ name = ${quotePs(flag.name)}; forms = ${psArray(flagForms(flag))}; ` + `takesValue = $${flag.type._tag !== "Boolean"}; ` + (flag.optionalValue === true ? `optionalValue = $true; ` : "") + `${valueFields(flag.type)}; ` + `description = ${psOptional(flag.description)} }`;
15775
+ var flagEntry = (flag) => {
15776
+ const negation = negatedName(flag);
15777
+ return `@{ name = ${quotePs(flag.name)}; forms = ${psArray(flagForms(flag))}; ` + `takesValue = $${flag.type._tag !== "Boolean"}; ` + (negation === undefined ? "" : `negation = ${quotePs(`--${negation}`)}; `) + (flag.optionalValue === true ? `optionalValue = $true; ` : "") + `${valueFields(flag.type)}; ` + `description = ${psOptional(flag.description)} }`;
15778
+ };
15817
15779
  var argumentEntry = (argument) => `@{ name = ${quotePs(argument.name)}; variadic = $${argument.variadic}; ${valueFields(argument.type)}; ` + `description = ${psOptional(argument.description)} }`;
15818
15780
  var pushList = (lines, field, entries) => {
15819
15781
  if (entries.length === 0) {
@@ -15888,10 +15850,10 @@ var completer = (dataName) => String.raw` param($wordToComplete, $commandAst, $
15888
15850
  foreach ($form in $flag.forms) {
15889
15851
  & $add $form 'ParameterName' $flag.description $typed ''
15890
15852
  }
15891
- if (-not $flag.takesValue) {
15853
+ if ($flag.negation) {
15892
15854
  $tooltip = $null
15893
15855
  if ($flag.description) { $tooltip = 'Disable ' + $flag.name }
15894
- & $add ('--no-' + $flag.name) 'ParameterName' $tooltip $typed ''
15856
+ & $add $flag.negation 'ParameterName' $tooltip $typed ''
15895
15857
  }
15896
15858
  }
15897
15859
  }
@@ -15962,14 +15924,19 @@ var completer = (dataName) => String.raw` param($wordToComplete, $commandAst, $
15962
15924
  foreach ($form in $forms) {
15963
15925
  $pending = $null
15964
15926
  $flag = $lookup[$form]
15965
- if ($null -eq $flag) {
15966
- if ($form.StartsWith('--no-')) {
15967
- $name = $form.Substring(5)
15968
- $flag = $lookup['--' + $name]
15969
- if ($null -ne $flag -and -not $flag.takesValue -and $flag.name -ceq $name) { $used[$name] = $true }
15927
+ # As in the CLI parser, a negation wins over an alias but not over a
15928
+ # canonical name.
15929
+ if ($null -eq $flag -or $form -cne ('--' + $flag.name)) {
15930
+ $negated = $null
15931
+ foreach ($candidate in $context.flags) {
15932
+ if ($candidate.negation -ceq $form) { $negated = $candidate }
15933
+ }
15934
+ if ($null -ne $negated) {
15935
+ $used[$negated.name] = $true
15936
+ continue
15970
15937
  }
15971
- continue
15972
15938
  }
15939
+ if ($null -eq $flag) { continue }
15973
15940
  $used[$flag.name] = $true
15974
15941
  # A flag with an optional value only takes a value attached with '='.
15975
15942
  if (-not $hasValue -and -not $flag.optionalValue) { $pending = $flag }
@@ -16060,8 +16027,9 @@ var allForms = (flag) => {
16060
16027
  for (const alias of flag.aliases) {
16061
16028
  forms.push(alias.length === 1 ? `-${alias}` : `--${alias}`);
16062
16029
  }
16063
- if (flag.type._tag === "Boolean") {
16064
- forms.push(`--no-${flag.name}`);
16030
+ const negation = negatedName(flag);
16031
+ if (negation !== undefined) {
16032
+ forms.push(`--${negation}`);
16065
16033
  }
16066
16034
  return forms;
16067
16035
  };
@@ -16105,9 +16073,10 @@ var flagSpecs = (flag) => {
16105
16073
  const prefix = alias.length === 1 ? "-" : "--";
16106
16074
  specs.push(`'${excl}${prefix}${alias}${valueSuffix}${desc}${action}'`);
16107
16075
  }
16108
- if (flag.type._tag === "Boolean") {
16076
+ const negation = negatedName(flag);
16077
+ if (negation !== undefined) {
16109
16078
  const negDesc = flag.description ? `[${escapeZshExplanation(`Disable ${flag.name}`)}]` : "";
16110
- specs.push(`'${excl}--no-${flag.name}${negDesc}'`);
16079
+ specs.push(`'${excl}--${negation}${negDesc}'`);
16111
16080
  }
16112
16081
  return specs;
16113
16082
  };
@@ -16234,7 +16203,7 @@ var generate5 = (executableName, shell, descriptor) => {
16234
16203
  };
16235
16204
 
16236
16205
  // node_modules/effect/dist/cli/Flag.js
16237
- var String8 = (name) => String7(flagKind, name);
16206
+ var String9 = (name) => String8(flagKind, name);
16238
16207
  var Boolean6 = (name) => Boolean5(flagKind, name);
16239
16208
  var ChoiceWithValue2 = (name, choices) => ChoiceWithValue(flagKind, name, choices);
16240
16209
  var withAlias2 = /* @__PURE__ */ dual(2, (self, alias) => withAlias(self, alias));
@@ -16243,6 +16212,265 @@ var withMetavar2 = /* @__PURE__ */ dual(2, (self, metavar) => withMetavar(self,
16243
16212
  var optional4 = (param) => optional3(param);
16244
16213
  var withDefault5 = withDefault4;
16245
16214
 
16215
+ // node_modules/effect/dist/cli/CliOutput.js
16216
+ var Formatter = /* @__PURE__ */ Reference("effect/cli/CliOutput", {
16217
+ defaultValue: () => defaultFormatter2()
16218
+ });
16219
+ var escapeControlCharacters = (text) => text.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F]/g, (character) => `\\x${character.charCodeAt(0).toString(16).padStart(2, "0")}`);
16220
+ var defaultFormatter2 = (options) => {
16221
+ const useColor = options?.colors ?? detectColors();
16222
+ const colors = useColor ? {
16223
+ bold: (text) => `\x1B[1m${text}\x1B[0m`,
16224
+ dim: (text) => `\x1B[2m${text}\x1B[0m`,
16225
+ cyan: (text) => `\x1B[36m${text}\x1B[0m`,
16226
+ green: (text) => `\x1B[32m${text}\x1B[0m`,
16227
+ blue: (text) => `\x1B[34m${text}\x1B[0m`,
16228
+ yellow: (text) => `\x1B[33m${text}\x1B[0m`,
16229
+ magenta: (text) => `\x1B[35m${text}\x1B[0m`
16230
+ } : {
16231
+ bold: (text) => text,
16232
+ dim: (text) => text,
16233
+ cyan: (text) => text,
16234
+ green: (text) => text,
16235
+ blue: (text) => text,
16236
+ yellow: (text) => text,
16237
+ magenta: (text) => text
16238
+ };
16239
+ const reset = useColor ? "\x1B[0m" : "";
16240
+ const red = useColor ? "\x1B[31m" : "";
16241
+ const bold = useColor ? "\x1B[1m" : "";
16242
+ return {
16243
+ formatHelpDoc: (doc) => formatHelpDocImpl(doc, colors),
16244
+ formatCliError: (error) => escapeControlCharacters(error.message),
16245
+ formatError: (error) => {
16246
+ return `
16247
+ ${bold}${red}ERROR${reset}
16248
+ ${escapeControlCharacters(error.message)}${reset}`;
16249
+ },
16250
+ formatErrors: (errors) => {
16251
+ if (errors.length === 0)
16252
+ return "";
16253
+ if (errors.length === 1) {
16254
+ return `
16255
+ ${bold}${red}ERROR${reset}
16256
+ ${escapeControlCharacters(errors[0].message)}${reset}`;
16257
+ }
16258
+ const grouped = new Map;
16259
+ for (const error of errors) {
16260
+ const tag = error._tag ?? "Error";
16261
+ const group = grouped.get(tag) ?? [];
16262
+ group.push(error);
16263
+ grouped.set(tag, group);
16264
+ }
16265
+ const sections = [];
16266
+ sections.push(`
16267
+ ${bold}${red}ERRORS${reset}`);
16268
+ for (const [, group] of grouped) {
16269
+ for (const error of group) {
16270
+ sections.push(` ${escapeControlCharacters(error.message)}${reset}`);
16271
+ }
16272
+ }
16273
+ return sections.join(`
16274
+ `);
16275
+ },
16276
+ formatVersion: (name, version) => `${colors.bold(name)} ${colors.dim("v")}${colors.bold(version)}`
16277
+ };
16278
+ };
16279
+ var stripAnsi = (text) => {
16280
+ return text.replace(/\u001B\[[0-9;]*m/g, "");
16281
+ };
16282
+ var graphemeSegmenter = /* @__PURE__ */ new Intl.Segmenter(undefined, {
16283
+ granularity: "grapheme"
16284
+ });
16285
+ var zeroWidthCodePoints = /[\p{Mark}\p{Control}\p{Default_Ignorable_Code_Point}]/gu;
16286
+ var emojiPresentation = /\p{Emoji_Presentation}/u;
16287
+ var isFullWidthCodePoint = (codePoint) => {
16288
+ if (codePoint < 4352)
16289
+ return false;
16290
+ return codePoint <= 4447 || codePoint === 9001 || codePoint === 9002 || codePoint >= 11904 && codePoint <= 12350 || codePoint >= 12352 && codePoint <= 42191 || codePoint >= 44032 && codePoint <= 55203 || codePoint >= 63744 && codePoint <= 64255 || codePoint >= 65040 && codePoint <= 65049 || codePoint >= 65072 && codePoint <= 65135 || codePoint >= 65280 && codePoint <= 65376 || codePoint >= 65504 && codePoint <= 65510 || codePoint >= 110592 && codePoint <= 111359 || codePoint >= 127488 && codePoint <= 127569 || codePoint >= 131072 && codePoint <= 262141;
16291
+ };
16292
+ var graphemeWidth = (grapheme) => {
16293
+ const visible = grapheme.replace(zeroWidthCodePoints, "");
16294
+ if (visible.length === 0)
16295
+ return 0;
16296
+ if (emojiPresentation.test(grapheme) || grapheme.includes("\uFE0F"))
16297
+ return 2;
16298
+ return isFullWidthCodePoint(visible.codePointAt(0)) ? 2 : 1;
16299
+ };
16300
+ var displayWidth = (text) => {
16301
+ let length = 0;
16302
+ for (const {
16303
+ segment
16304
+ } of graphemeSegmenter.segment(stripAnsi(text))) {
16305
+ length += graphemeWidth(segment);
16306
+ }
16307
+ return length;
16308
+ };
16309
+ var pad = (s, width) => {
16310
+ const actualLength = displayWidth(s);
16311
+ const padding = Math.max(0, width - actualLength);
16312
+ return s + " ".repeat(padding);
16313
+ };
16314
+ var renderTable = (rows, widthCap) => {
16315
+ const maxColumn = Math.max(...rows.map((r) => displayWidth(r.left))) + 4;
16316
+ const col = widthCap === undefined ? maxColumn : Math.min(maxColumn, widthCap);
16317
+ return rows.map(({
16318
+ left,
16319
+ right
16320
+ }) => ` ${pad(left, Math.max(col, displayWidth(left) + 1))}${right}`).join(`
16321
+ `);
16322
+ };
16323
+ var formatSubcommandName = (name, alias) => alias ? `${name}, ${alias}` : name;
16324
+ var formatHelpDocImpl = (doc, colors) => {
16325
+ const sections = [];
16326
+ if (doc.description) {
16327
+ sections.push(colors.bold("DESCRIPTION"));
16328
+ sections.push(` ${doc.description}`);
16329
+ sections.push("");
16330
+ }
16331
+ sections.push(colors.bold("USAGE"));
16332
+ sections.push(` ${colors.cyan(doc.usage)}`);
16333
+ sections.push("");
16334
+ if (doc.args && doc.args.length > 0) {
16335
+ sections.push(colors.bold("ARGUMENTS"));
16336
+ const argRows = doc.args.map((arg) => {
16337
+ let name = arg.name;
16338
+ if (arg.variadic) {
16339
+ name += "...";
16340
+ }
16341
+ const coloredName = colors.green(name);
16342
+ const coloredType = colors.dim(arg.type);
16343
+ const nameType = `${coloredName} ${coloredType}`;
16344
+ const optionalSuffix = arg.required ? "" : colors.dim(" (optional)");
16345
+ const description = getOrElse(arg.description, () => "") + optionalSuffix;
16346
+ return {
16347
+ left: nameType,
16348
+ right: description
16349
+ };
16350
+ });
16351
+ sections.push(renderTable(argRows, 25));
16352
+ sections.push("");
16353
+ }
16354
+ if (doc.flags.length > 0) {
16355
+ sections.push(colors.bold("FLAGS"));
16356
+ const flagRows = doc.flags.map((flag) => {
16357
+ const names = [];
16358
+ names.push(colors.green(`--${flag.name}`));
16359
+ for (const alias of flag.aliases) {
16360
+ names.push(colors.green(alias));
16361
+ }
16362
+ const namesPart = names.join(", ");
16363
+ const typePart = flag.type !== "boolean" ? ` ${colors.dim(flag.type)}` : "";
16364
+ return {
16365
+ left: namesPart + typePart,
16366
+ right: getOrElse(flag.description, () => "")
16367
+ };
16368
+ });
16369
+ sections.push(renderTable(flagRows));
16370
+ sections.push("");
16371
+ }
16372
+ if (doc.globalFlags && doc.globalFlags.length > 0) {
16373
+ sections.push(colors.bold("GLOBAL FLAGS"));
16374
+ const globalFlagRows = doc.globalFlags.map((flag) => {
16375
+ const names = [];
16376
+ names.push(colors.green(`--${flag.name}`));
16377
+ for (const alias of flag.aliases) {
16378
+ names.push(colors.green(alias));
16379
+ }
16380
+ const namesPart = names.join(", ");
16381
+ const typePart = flag.type !== "boolean" ? ` ${colors.dim(flag.type)}` : "";
16382
+ return {
16383
+ left: namesPart + typePart,
16384
+ right: getOrElse(flag.description, () => "")
16385
+ };
16386
+ });
16387
+ sections.push(renderTable(globalFlagRows));
16388
+ sections.push("");
16389
+ }
16390
+ if (doc.subcommands && doc.subcommands.length > 0) {
16391
+ const ungrouped = doc.subcommands.find((group) => group.group === undefined);
16392
+ if (ungrouped) {
16393
+ sections.push(colors.bold("SUBCOMMANDS"));
16394
+ sections.push(renderTable(ungrouped.commands.map((sub) => ({
16395
+ left: colors.cyan(formatSubcommandName(sub.name, sub.alias)),
16396
+ right: sub.shortDescription ?? sub.description
16397
+ })), 20));
16398
+ if (doc.subcommands.length > 1) {
16399
+ sections.push("");
16400
+ }
16401
+ }
16402
+ for (const group of doc.subcommands) {
16403
+ if (group.group === undefined)
16404
+ continue;
16405
+ sections.push(colors.bold(`${group.group}:`));
16406
+ sections.push(renderTable(group.commands.map((sub) => ({
16407
+ left: colors.cyan(formatSubcommandName(sub.name, sub.alias)),
16408
+ right: sub.shortDescription ?? sub.description
16409
+ })), 20));
16410
+ sections.push("");
16411
+ }
16412
+ }
16413
+ if (doc.examples && doc.examples.length > 0) {
16414
+ sections.push(colors.bold("EXAMPLES"));
16415
+ let first = true;
16416
+ let previousHadDescription = false;
16417
+ for (const example of doc.examples) {
16418
+ if (example.description) {
16419
+ if (!first)
16420
+ sections.push("");
16421
+ sections.push(` ${colors.dim(`# ${example.description}`)}`);
16422
+ } else if (previousHadDescription) {
16423
+ sections.push("");
16424
+ }
16425
+ sections.push(` ${colors.cyan(example.command)}`);
16426
+ first = false;
16427
+ previousHadDescription = !!example.description;
16428
+ }
16429
+ sections.push("");
16430
+ }
16431
+ if (sections[sections.length - 1] === "") {
16432
+ sections.pop();
16433
+ }
16434
+ return sections.join(`
16435
+ `);
16436
+ };
16437
+
16438
+ // node_modules/effect/dist/cli/TerminalCapabilities.js
16439
+ var TerminalCapabilities = /* @__PURE__ */ Reference("effect/cli/TerminalCapabilities", {
16440
+ defaultValue: () => fromProcess()
16441
+ });
16442
+ var isPresent = (value) => value !== undefined && value.length > 0;
16443
+ var isForcingColor = (value) => isPresent(value) && value !== "0" && value.toLowerCase() !== "false";
16444
+ var detect = (input) => {
16445
+ if (input.term === "dumb") {
16446
+ return {
16447
+ canColor: false,
16448
+ canAnimate: false,
16449
+ canPrompt: false
16450
+ };
16451
+ }
16452
+ return {
16453
+ canColor: !isPresent(input.noColor) && (isForcingColor(input.forceColor) || input.stdoutIsTerminal),
16454
+ canAnimate: input.stdoutIsTerminal,
16455
+ canPrompt: input.stdinIsTerminal && input.stdoutIsTerminal
16456
+ };
16457
+ };
16458
+ var fromProcess = () => {
16459
+ const process2 = globalThis.process;
16460
+ return detect({
16461
+ noColor: process2?.env?.NO_COLOR,
16462
+ forceColor: process2?.env?.FORCE_COLOR,
16463
+ term: process2?.env?.TERM,
16464
+ stdinIsTerminal: process2?.stdin?.isTTY === true,
16465
+ stdoutIsTerminal: process2?.stdout?.isTTY === true
16466
+ });
16467
+ };
16468
+
16469
+ // node_modules/effect/dist/cli/internal/formatter.js
16470
+ var resolveFormatter = /* @__PURE__ */ contextWith2((context) => succeed6(getOrUndefined2(context, Formatter) ?? defaultFormatter2({
16471
+ colors: get(context, TerminalCapabilities).canColor
16472
+ })));
16473
+
16246
16474
  // node_modules/effect/dist/cli/internal/help.js
16247
16475
  var dedupeGlobalFlags = (flags) => {
16248
16476
  const seen = new Set;
@@ -16372,7 +16600,7 @@ var Help = /* @__PURE__ */ Action2({
16372
16600
  command,
16373
16601
  commandPath
16374
16602
  }) {
16375
- const formatter = yield* Formatter;
16603
+ const formatter = yield* resolveFormatter;
16376
16604
  const helpDoc = yield* getHelpForCommandPath(command, commandPath, builtIns);
16377
16605
  yield* log(formatter.formatHelpDoc(helpDoc));
16378
16606
  })
@@ -16383,7 +16611,7 @@ var Version = /* @__PURE__ */ Action2({
16383
16611
  command,
16384
16612
  version
16385
16613
  }) {
16386
- const formatter = yield* Formatter;
16614
+ const formatter = yield* resolveFormatter;
16387
16615
  yield* log(formatter.formatVersion(command.name, version));
16388
16616
  })
16389
16617
  });
@@ -16447,13 +16675,20 @@ var lexTokens = (args) => {
16447
16675
  const equalIndex = arg.indexOf("=");
16448
16676
  if (equalIndex !== -1) {
16449
16677
  const name = arg.slice(2, equalIndex);
16450
- const value = arg.slice(equalIndex + 1);
16451
- tokens.push({
16452
- _tag: "LongOption",
16453
- name,
16454
- raw: arg,
16455
- value
16456
- });
16678
+ if (name === "") {
16679
+ tokens.push({
16680
+ _tag: "Value",
16681
+ value: arg
16682
+ });
16683
+ } else {
16684
+ const value = arg.slice(equalIndex + 1);
16685
+ tokens.push({
16686
+ _tag: "LongOption",
16687
+ name,
16688
+ raw: arg,
16689
+ value
16690
+ });
16691
+ }
16457
16692
  } else {
16458
16693
  tokens.push({
16459
16694
  _tag: "LongOption",
@@ -16465,13 +16700,20 @@ var lexTokens = (args) => {
16465
16700
  const flags = arg.slice(1);
16466
16701
  const equalIndex = flags.indexOf("=");
16467
16702
  if (equalIndex !== -1) {
16468
- const flag = flags.slice(0, equalIndex);
16469
- const value = flags.slice(equalIndex + 1);
16703
+ const chars = Array.from(flags.slice(0, equalIndex));
16704
+ const flag = chars.pop() ?? "";
16705
+ for (const ch of chars) {
16706
+ tokens.push({
16707
+ _tag: "ShortOption",
16708
+ flag: ch,
16709
+ raw: `-${ch}`
16710
+ });
16711
+ }
16470
16712
  tokens.push({
16471
16713
  _tag: "ShortOption",
16472
16714
  flag,
16473
16715
  raw: `-${flag}`,
16474
- value
16716
+ value: flags.slice(equalIndex + 1)
16475
16717
  });
16476
16718
  } else {
16477
16719
  for (const ch of flags) {
@@ -16582,8 +16824,10 @@ var makeCursor = (tokens) => {
16582
16824
  rest: () => tokens.slice(i)
16583
16825
  };
16584
16826
  };
16827
+ var negatedName2 = (param) => !isBoolean2(param.primitiveType) || param.negation === false ? undefined : param.negation ?? `no-${param.name}`;
16585
16828
  var createFlagRegistry = (params) => {
16586
16829
  const index = new Map;
16830
+ const negations = new Map;
16587
16831
  for (const param of params) {
16588
16832
  if (index.has(param.name)) {
16589
16833
  throw new Error(`Duplicate flag name "${param.name}" in command definition`);
@@ -16595,10 +16839,18 @@ var createFlagRegistry = (params) => {
16595
16839
  }
16596
16840
  index.set(alias, param);
16597
16841
  }
16842
+ const negation = negatedName2(param);
16843
+ if (negation !== undefined) {
16844
+ if (negations.has(negation)) {
16845
+ throw new Error(`Duplicate negation "${negation}" in command definition (conflicts with "${negations.get(negation).name}")`);
16846
+ }
16847
+ negations.set(negation, param);
16848
+ }
16598
16849
  }
16599
16850
  return {
16600
16851
  params,
16601
- index
16852
+ index,
16853
+ negations
16602
16854
  };
16603
16855
  };
16604
16856
  var buildSubcommandIndex = (subcommands) => {
@@ -16652,15 +16904,12 @@ var resolveFlag = (token, registry) => {
16652
16904
  negated: false
16653
16905
  };
16654
16906
  }
16655
- if (token._tag === "LongOption" && token.name.startsWith("no-")) {
16656
- const canonicalName = token.name.slice(3);
16657
- const param = registry.index.get(canonicalName);
16658
- if (param && param.name === canonicalName && isBoolean2(param.primitiveType)) {
16659
- return {
16660
- param,
16661
- negated: true
16662
- };
16663
- }
16907
+ const negated = token._tag === "LongOption" ? registry.negations.get(token.name) : undefined;
16908
+ if (negated) {
16909
+ return {
16910
+ param: negated,
16911
+ negated: true
16912
+ };
16664
16913
  }
16665
16914
  if (direct) {
16666
16915
  return {
@@ -16904,8 +17153,9 @@ var createUnrecognizedFlagError = (token, params, commandPath) => {
16904
17153
  if (p.hidden)
16905
17154
  continue;
16906
17155
  validNames.push(p.name);
16907
- if (isBoolean2(p.primitiveType)) {
16908
- validNames.push(`no-${p.name}`);
17156
+ const negation = negatedName2(p);
17157
+ if (negation !== undefined) {
17158
+ validNames.push(negation);
16909
17159
  }
16910
17160
  for (const alias of p.aliases) {
16911
17161
  validNames.push(alias);
@@ -17190,7 +17440,7 @@ var promptSingle = (single) => {
17190
17440
  message
17191
17441
  })), (value) => commandLineArg(value2(value), "<redacted>"));
17192
17442
  default:
17193
- return map7(run3(String6({
17443
+ return map7(run3(String7({
17194
17444
  message
17195
17445
  })), commandLineArg);
17196
17446
  }
@@ -17354,7 +17604,7 @@ var withSubcommands = /* @__PURE__ */ dual(2, (self, subcommands) => {
17354
17604
  unlisted: impl.unlisted,
17355
17605
  annotations: impl.annotations,
17356
17606
  globalFlags: impl.globalFlags,
17357
- examples: impl.examples,
17607
+ resolveExamples: impl.resolveExamples,
17358
17608
  service: impl.service,
17359
17609
  subcommands: normalized.groups,
17360
17610
  parse,
@@ -17402,7 +17652,7 @@ var showHelp = (command, error2, renderErrors) => gen2(function* () {
17402
17652
  const {
17403
17653
  builtIns
17404
17654
  } = yield* CliConfig;
17405
- const formatter = yield* Formatter;
17655
+ const formatter = yield* resolveFormatter;
17406
17656
  const helpDoc = yield* getHelpForCommandPath(command, error2.commandPath, builtIns);
17407
17657
  yield* log(formatter.formatHelpDoc(helpDoc));
17408
17658
  if (renderErrors && error2.errors.length > 0) {
@@ -17410,7 +17660,7 @@ var showHelp = (command, error2, renderErrors) => gen2(function* () {
17410
17660
  }
17411
17661
  });
17412
17662
  var showUserError = (error2) => gen2(function* () {
17413
- const formatter = yield* Formatter;
17663
+ const formatter = yield* resolveFormatter;
17414
17664
  yield* error(formatter.formatError(error2));
17415
17665
  error2[errorReported] = false;
17416
17666
  });
@@ -17708,7 +17958,12 @@ var make33 = (url, params, hash) => try_({
17708
17958
  });
17709
17959
  var baseUrl = () => {
17710
17960
  if ("location" in globalThis && globalThis.location !== undefined && globalThis.location.origin !== undefined && globalThis.location.pathname !== undefined) {
17711
- return location.origin + location.pathname;
17961
+ const base = location.origin + location.pathname;
17962
+ try {
17963
+ return new URL(base).href;
17964
+ } catch {
17965
+ return;
17966
+ }
17712
17967
  }
17713
17968
  return;
17714
17969
  };
@@ -17832,28 +18087,17 @@ var schemaBodyJson = (schema, options) => {
17832
18087
  return (self) => decodeJson === undefined ? flatMap4(self.json, (u) => decode(u, options)) : flatMap4(self.text, (body) => body === "" ? flatMap4(self.json, (u) => decode(u, options)) : decodeJson(body, options));
17833
18088
  };
17834
18089
  var inspect = (self, that) => {
17835
- const contentType = self.headers["content-type"] ?? "";
17836
- let body;
17837
- if (contentType.includes("application/json")) {
17838
- try {
17839
- body = runSync2(self.json);
17840
- } catch (_) {}
17841
- } else if (contentType.includes("text/") || contentType.includes("urlencoded")) {
17842
- try {
17843
- body = runSync2(self.text);
17844
- } catch (_) {}
17845
- }
17846
- const obj = {
18090
+ return {
17847
18091
  ...that,
17848
18092
  headers: redact(self.headers),
17849
18093
  remoteAddress: self.remoteAddress
17850
18094
  };
17851
- if (body !== undefined) {
17852
- obj.body = body;
17853
- }
17854
- return obj;
17855
18095
  };
17856
18096
 
18097
+ // node_modules/effect/dist/http/internal/webResponse.js
18098
+ var WebSourceSymbol = "~effect/http/HttpClientResponse/WebSource";
18099
+ var getWebSource = (self) => self[WebSourceSymbol]?.();
18100
+
17857
18101
  // node_modules/effect/dist/http/HttpClientResponse.js
17858
18102
  var TypeId42 = "~effect/http/HttpClientResponse";
17859
18103
  var fromWeb = (request, source) => new WebHttpClientResponse(request, source);
@@ -17901,6 +18145,9 @@ class WebHttpClientResponse extends Class2 {
17901
18145
  get remoteAddress() {
17902
18146
  return none2();
17903
18147
  }
18148
+ [WebSourceSymbol]() {
18149
+ return this.source;
18150
+ }
17904
18151
  get stream() {
17905
18152
  return this.source.body ? fromReadableStream2({
17906
18153
  evaluate: () => this.source.body,
@@ -17977,6 +18224,15 @@ class WebHttpClientResponse extends Class2 {
17977
18224
  }).pipe(cached2, runSync2);
17978
18225
  return this.arrayBufferBody;
17979
18226
  }
18227
+ get upgrade() {
18228
+ return fail6(new HttpClientError({
18229
+ reason: new StatusCodeError({
18230
+ request: this.request,
18231
+ response: this,
18232
+ description: "fetch cannot hand over the connection of an HTTP upgrade"
18233
+ })
18234
+ }));
18235
+ }
17980
18236
  pipe() {
17981
18237
  return pipeArguments(this, arguments);
17982
18238
  }
@@ -18151,7 +18407,9 @@ var layerMergedContext = (effect2) => effect(HttpClient)(contextWith2((context)
18151
18407
  var responseRegistry = /* @__PURE__ */ (() => {
18152
18408
  if ("FinalizationRegistry" in globalThis && globalThis.FinalizationRegistry) {
18153
18409
  const registry = /* @__PURE__ */ new FinalizationRegistry((controller) => {
18154
- controller.abort();
18410
+ try {
18411
+ controller.abort();
18412
+ } catch {}
18155
18413
  });
18156
18414
  return {
18157
18415
  register(response, controller) {
@@ -18228,6 +18486,15 @@ class InterruptibleResponse {
18228
18486
  get arrayBuffer() {
18229
18487
  return this.applyInterrupt(this.original.arrayBuffer);
18230
18488
  }
18489
+ get upgrade() {
18490
+ return this.applyInterrupt(this.original.upgrade);
18491
+ }
18492
+ [WebSourceSymbol]() {
18493
+ const source = getWebSource(this.original);
18494
+ if (source !== undefined)
18495
+ responseRegistry.unregister(this.original);
18496
+ return source;
18497
+ }
18231
18498
  get stream() {
18232
18499
  return suspend4(() => {
18233
18500
  responseRegistry.unregister(this.original);
@@ -18255,12 +18522,22 @@ var Fetch = /* @__PURE__ */ Reference("effect/http/FetchHttpClient/Fetch", {
18255
18522
  class RequestInit extends (/* @__PURE__ */ Service()("effect/http/FetchHttpClient/RequestInit")) {
18256
18523
  }
18257
18524
  var fetch = /* @__PURE__ */ make35((request, url, signal, fiber) => {
18525
+ if (request.headers.upgrade !== undefined) {
18526
+ return fail6(new HttpClientError({
18527
+ reason: new TransportError({
18528
+ request,
18529
+ description: "fetch cannot send an HTTP upgrade request"
18530
+ })
18531
+ }));
18532
+ }
18258
18533
  const fetch = fiber.getRef(Fetch);
18259
18534
  const options = getOrUndefined2(fiber.context, RequestInit) ?? {};
18260
18535
  let headers = options.headers ? merge4(fromInput(options.headers), request.headers) : request.headers;
18261
18536
  if (headers["content-length"]) {
18262
18537
  headers = remove3(headers, "content-length");
18263
18538
  }
18539
+ let uploadController;
18540
+ const stopUpload = sync2(() => uploadController?.abort());
18264
18541
  const send = (body) => map7(tryPromise2({
18265
18542
  try: () => fetch(url, {
18266
18543
  ...options,
@@ -18268,7 +18545,7 @@ var fetch = /* @__PURE__ */ make35((request, url, signal, fiber) => {
18268
18545
  headers,
18269
18546
  body,
18270
18547
  duplex: typeof ReadableStream !== "undefined" && body instanceof ReadableStream ? "half" : undefined,
18271
- signal
18548
+ signal: uploadController ? AbortSignal.any([signal, uploadController.signal]) : signal
18272
18549
  }),
18273
18550
  catch: (cause) => new HttpClientError({
18274
18551
  reason: new TransportError({
@@ -18276,15 +18553,43 @@ var fetch = /* @__PURE__ */ make35((request, url, signal, fiber) => {
18276
18553
  cause
18277
18554
  })
18278
18555
  })
18279
- }), (response) => fromWeb(request, response));
18556
+ }), (response) => {
18557
+ const original = fromWeb(request, response);
18558
+ if (!uploadController)
18559
+ return original;
18560
+ if (response.body === null)
18561
+ uploadController.abort();
18562
+ return Object.create(original, {
18563
+ ...Object.fromEntries(["arrayBuffer", "text", "json", "formData", "urlParamsBody"].map((key) => [key, {
18564
+ get: () => ensuring2(original[key], stopUpload)
18565
+ }])),
18566
+ stream: {
18567
+ get: () => ensuring4(original.stream, stopUpload)
18568
+ }
18569
+ });
18570
+ }).pipe(onError2(() => stopUpload));
18280
18571
  switch (request.body._tag) {
18281
18572
  case "Raw":
18282
18573
  case "Uint8Array":
18283
18574
  return send(request.body.body);
18284
18575
  case "FormData":
18285
18576
  return send(request.body.formData);
18286
- case "Stream":
18287
- return flatMap4(toReadableStreamEffect(request.body.stream), send);
18577
+ case "Stream": {
18578
+ uploadController = new AbortController;
18579
+ const uploadSignal = AbortSignal.any([signal, uploadController.signal]);
18580
+ const stopped = callback2((resume) => {
18581
+ const onAbort = () => resume(interrupt2);
18582
+ if (uploadSignal.aborted) {
18583
+ onAbort();
18584
+ return;
18585
+ }
18586
+ uploadSignal.addEventListener("abort", onAbort, {
18587
+ once: true
18588
+ });
18589
+ return sync2(() => uploadSignal.removeEventListener("abort", onAbort));
18590
+ });
18591
+ return flatMap4(toReadableStreamEffect(interruptWhen2(request.body.stream, stopped)), send);
18592
+ }
18288
18593
  }
18289
18594
  return send(undefined);
18290
18595
  });
@@ -18292,7 +18597,7 @@ var layer14 = /* @__PURE__ */ layerMergedContext(/* @__PURE__ */ succeed6(fetch)
18292
18597
  // package.json
18293
18598
  var package_default = {
18294
18599
  name: "jj-octo",
18295
- version: "0.9.0",
18600
+ version: "0.9.2",
18296
18601
  description: "A jj subcommand for GitHub that supports stacked pull requests and works in Claude Code cloud sessions",
18297
18602
  license: "MIT",
18298
18603
  repository: {
@@ -18324,20 +18629,20 @@ var package_default = {
18324
18629
  test: "bun run build && bun run compile && bun test ./src"
18325
18630
  },
18326
18631
  devDependencies: {
18327
- "@effect/platform-bun": "4.0.5",
18632
+ "@effect/platform-bun": "4.0.6",
18328
18633
  "@octokit/openapi-types": "29.0.1",
18329
18634
  "@tsconfig/strictest": "2.0.8",
18330
- "@types/bun": "1.4.3",
18331
- effect: "4.0.5",
18635
+ "@types/bun": "1.4.4",
18636
+ effect: "4.0.6",
18332
18637
  oxfmt: "0.74.0",
18333
18638
  oxlint: "1.89.0",
18334
- "oxlint-tsgolint": "7.0.2004",
18639
+ "oxlint-tsgolint": "7.0.2005",
18335
18640
  typescript: "7.0.2"
18336
18641
  },
18337
18642
  engines: {
18338
18643
  bun: ">=1.4.0"
18339
18644
  },
18340
- packageManager: "bun@1.4.3"
18645
+ packageManager: "bun@1.4.4"
18341
18646
  };
18342
18647
 
18343
18648
  // src/cli/command.ts
@@ -18346,7 +18651,7 @@ var asUserError = (program) => program.pipe(mapError3(({ message }) => userError
18346
18651
  var withHelp = (summary, ...paragraphs) => (command) => command.pipe(withShortDescription(summary), withDescription3([summary, ...paragraphs].join(`
18347
18652
 
18348
18653
  `)));
18349
- var revisionFlag = (description) => String8("revision").pipe(withAlias2("r"), withDefault5("@"), withDescription2(`${description}, the working copy by default`));
18654
+ var revisionFlag = (description) => String9("revision").pipe(withAlias2("r"), withDefault5("@"), withDescription2(`${description}, the working copy by default`));
18350
18655
  // src/clients/git.ts
18351
18656
  class GitFailed extends TaggedError2("GitFailed") {
18352
18657
  }
@@ -18364,7 +18669,7 @@ var gitLayer = ({ cwd, env } = {}) => effect(Git, gen2(function* () {
18364
18669
  `, github: `${remote}
18365
18670
  `, local: `${local}
18366
18671
  ` };
18367
- yield* all2(Object.entries(written).map(([name, text]) => fs.writeFileString(path.join(directory, name), text)));
18672
+ yield* all3(Object.entries(written).map(([name, text]) => fs.writeFileString(path.join(directory, name), text)));
18368
18673
  const handle = yield* spawner.spawn(make16("git", [
18369
18674
  "merge-file",
18370
18675
  "-p",
@@ -18378,9 +18683,9 @@ var gitLayer = ({ cwd, env } = {}) => effect(Git, gen2(function* () {
18378
18683
  "base",
18379
18684
  "github"
18380
18685
  ], { cwd: directory }));
18381
- const [text, stderr, code] = yield* all2([
18382
- mkString(decodeText(handle.stdout)),
18383
- mkString(decodeText(handle.stderr)),
18686
+ const [text, stderr, code] = yield* all3([
18687
+ mkString(decodeText2(handle.stdout)),
18688
+ mkString(decodeText2(handle.stderr)),
18384
18689
  handle.exitCode
18385
18690
  ], { concurrency: "unbounded" });
18386
18691
  if (code > 127) {
@@ -18390,9 +18695,9 @@ var gitLayer = ({ cwd, env } = {}) => effect(Git, gen2(function* () {
18390
18695
  })).pipe(catchTag2("PlatformError", (error) => fail6(new GitFailed({ message: `git merge-file failed: ${error.message}` })))),
18391
18696
  read: (args) => scoped2(gen2(function* () {
18392
18697
  const handle = yield* spawner.spawn(make16("git", args, { cwd, env, extendEnv: true }));
18393
- const [stdout, stderr, code] = yield* all2([
18394
- mkString(decodeText(handle.stdout)),
18395
- mkString(decodeText(handle.stderr)),
18698
+ const [stdout, stderr, code] = yield* all3([
18699
+ mkString(decodeText2(handle.stdout)),
18700
+ mkString(decodeText2(handle.stderr)),
18396
18701
  handle.exitCode
18397
18702
  ], { concurrency: "unbounded" });
18398
18703
  return code === 0 ? stdout : yield* new GitFailed({
@@ -18435,9 +18740,9 @@ var jjLayer = ({ cwd, env, printed } = {}) => effect(Jj, gen2(function* () {
18435
18740
  const location2 = { cwd, env, extendEnv: true };
18436
18741
  const captured = (args) => scoped2(gen2(function* () {
18437
18742
  const handle = yield* spawner.spawn(make16("jj", args, location2));
18438
- return yield* all2([
18439
- mkString(decodeText(handle.stdout)),
18440
- mkString(decodeText(handle.stderr)),
18743
+ return yield* all3([
18744
+ mkString(decodeText2(handle.stdout)),
18745
+ mkString(decodeText2(handle.stderr)),
18441
18746
  handle.exitCode
18442
18747
  ], { concurrency: "unbounded" });
18443
18748
  })).pipe(catchTag2("PlatformError", (error) => fail6(failed(args, error.message))));
@@ -18476,10 +18781,13 @@ var jjConfig = (key) => gen2(function* () {
18476
18781
  message: `${key} is ${JSON.stringify(value)}; set it to a string`
18477
18782
  });
18478
18783
  });
18479
- var jjFlag = (key) => gen2(function* () {
18784
+ var jjFlag = (key, fallback = false) => gen2(function* () {
18480
18785
  const value = yield* readJjConfig(key);
18481
- if (value === undefined || typeof value === "boolean") {
18482
- return value === true;
18786
+ if (value === undefined) {
18787
+ return fallback;
18788
+ }
18789
+ if (typeof value === "boolean") {
18790
+ return value;
18483
18791
  }
18484
18792
  return yield* new JjFailed({
18485
18793
  message: `${key} is ${JSON.stringify(value)}; set it to true or false`
@@ -18506,14 +18814,27 @@ var parseDescription = (json) => {
18506
18814
  const parsed = JSON.parse(json);
18507
18815
  return typeof parsed === "string" ? parsed : "";
18508
18816
  };
18509
- var readLog = (revset, template) => gen2(function* () {
18817
+ var readLog = (revset, template, { ignoreWorkingCopy = false } = {}) => gen2(function* () {
18510
18818
  const jj = yield* Jj;
18511
- return yield* jj.read(["log", "--no-graph", "--reversed", "-r", revset, "-T", template]);
18819
+ return yield* jj.read([
18820
+ "log",
18821
+ ...ignoreWorkingCopy ? ["--ignore-working-copy"] : [],
18822
+ "--no-graph",
18823
+ "--reversed",
18824
+ "-r",
18825
+ revset,
18826
+ "-T",
18827
+ template
18828
+ ]);
18512
18829
  });
18513
- var logLines = (revset, template) => readLog(revset, template).pipe(map7(lines2));
18830
+ var logLines = (revset, template, options) => readLog(revset, template, options).pipe(map7(lines2));
18514
18831
  var changesIn = (revset) => logLines(revset, String.raw`change_id.shortest(8) ++ " " ++ description.first_line() ++ "\n"`);
18515
18832
  var commitsAt = (revset) => logLines(revset, String.raw`commit_id ++ "\n"`);
18516
18833
  var changeIdsAt = (revset) => logLines(revset, String.raw`change_id ++ "\n"`);
18834
+ var lineCountsAt = (commitIds) => logLines(anyOf(commitIds), String.raw`commit_id ++ "\t" ++ diff.stat().total_added() ++ "\t" ++ diff.stat().total_removed() ++ "\n"`, { ignoreWorkingCopy: true }).pipe(map7((logged) => new Map(logged.flatMap((line) => {
18835
+ const [commitId = "", added = "", removed = ""] = line.split("\t");
18836
+ return /^\d+$/u.test(added) && /^\d+$/u.test(removed) ? [[commitId, { added: Number(added), removed: Number(removed) }]] : [];
18837
+ }))));
18517
18838
  var bookmarksAt = (revset) => gen2(function* () {
18518
18839
  const jj = yield* Jj;
18519
18840
  const template = String.raw`if(!remote, name ++ "\n")`;
@@ -18891,6 +19212,9 @@ var init = gen2(function* () {
18891
19212
  });
18892
19213
  var initCommand = make32("init", {}, () => asUserError(init)).pipe(withHelp("Set up a git checkout for the other commands", "Makes it a jj repository colocated with git, unless it already is one, and copies git's name and email into the repository's jj config where jj has none. Where neither has them, set them with `jj config set --user`.", "Reads the default branch from `origin`, fetches and tracks it, and sets `trunk()` to it in the repository's config. jj's own `trunk()` guesses from branch names, so without this a default branch it doesn't guess would be the base of pull requests but not of local rebases. `submit`, `merge` and `sync` check that the two agree.", "Sets the `jj gh` alias to run `jj-octo` from `PATH`, in the repository's config, unless the repository has one, such as one that runs another build.", "Needs no GitHub token. Running it again changes nothing that is already set up. Run it again after the default branch changes on GitHub. Fails with what it couldn't set up, after setting up the rest. Where it can't make a colocated jj repository, such as in a git worktree, it sets up nothing else."));
18893
19214
 
19215
+ // src/clients/claude-code.ts
19216
+ var claudeCodeCloudSession = orDie2(String5("CLAUDE_CODE_REMOTE").pipe(withDefault3(""), map10((value) => value === "true")));
19217
+
18894
19218
  // src/clients/clipboard.ts
18895
19219
  class ClipboardFailed extends TaggedError2("ClipboardFailed") {
18896
19220
  }
@@ -18909,50 +19233,62 @@ function run([html, text]) {
18909
19233
  throw new Error("the pasteboard didn't take the links");
18910
19234
  }
18911
19235
  }`;
18912
- var commandsFor = ({ html, text }, platform, env) => {
18913
- const make = (name, args, input) => ({
18914
- command: make16(name, args, {
18915
- detached: false,
18916
- env,
18917
- extendEnv: true,
18918
- stdout: "ignore",
18919
- ...input === "stdin" ? { stderr: "ignore", stdin: make12(html).pipe(encodeText) } : { stderr: "inherit", stdin: "ignore" }
18920
- }),
18921
- name
18922
- });
19236
+ var environment = all4({
19237
+ path: String5("PATH").pipe(withDefault3("")),
19238
+ wayland: String5("WAYLAND_DISPLAY").pipe(withDefault3(""))
19239
+ });
19240
+ var commandsFor = ({ html, text }, platform, wayland) => {
18923
19241
  if (platform === "darwin") {
18924
- return [make("osascript", ["-l", "JavaScript", "-e", MACOS_SCRIPT, html, text], "arguments")];
19242
+ return [
19243
+ {
19244
+ args: ["-l", "JavaScript", "-e", MACOS_SCRIPT, html, text],
19245
+ input: "arguments",
19246
+ name: "osascript"
19247
+ }
19248
+ ];
18925
19249
  }
18926
19250
  if (platform !== "linux") {
18927
19251
  return [];
18928
19252
  }
18929
- const xclip = make("xclip", ["-selection", "clipboard", "-t", "text/html"], "stdin");
18930
- const wayland = env["WAYLAND_DISPLAY"] ?? process.env["WAYLAND_DISPLAY"] ?? "";
18931
- return wayland === "" ? [xclip] : [make("wl-copy", ["--type", "text/html"], "stdin"), xclip];
19253
+ const xclip = {
19254
+ args: ["-selection", "clipboard", "-t", "text/html"],
19255
+ input: "stdin",
19256
+ name: "xclip"
19257
+ };
19258
+ return wayland === "" ? [xclip] : [{ args: ["--type", "text/html"], input: "stdin", name: "wl-copy" }, xclip];
18932
19259
  };
18933
- var clipboardLayer = ({
18934
- env = {},
18935
- platform = process.platform
18936
- } = {}) => effect(Clipboard, gen2(function* () {
19260
+ var childProcess = ({ args, input }, executable, html) => make16(executable, args, {
19261
+ detached: false,
19262
+ stdout: "ignore",
19263
+ ...input === "stdin" ? { stderr: "ignore", stdin: make12(html).pipe(encodeText) } : { stderr: "inherit", stdin: "ignore" }
19264
+ });
19265
+ var clipboardLayer = ({ platform = process.platform } = {}) => effect(Clipboard, gen2(function* () {
19266
+ const { path, wayland } = yield* orDie2(environment);
19267
+ if (yield* claudeCodeCloudSession) {
19268
+ return Clipboard.of({ write: () => succeed6("unreachable") });
19269
+ }
18937
19270
  const spawner = yield* ChildProcessSpawner;
18938
- return {
19271
+ return Clipboard.of({
18939
19272
  write: (content) => {
18940
- const commands = commandsFor(content, platform, env);
19273
+ const commands = commandsFor(content, platform, wayland);
18941
19274
  if (commands.length === 0) {
18942
19275
  return fail6(new ClipboardFailed({
18943
19276
  message: `copying to the clipboard needs macOS, or Linux with wl-copy or xclip, not ${platform}`
18944
19277
  }));
18945
19278
  }
18946
- const PATH = env["PATH"] ?? process.env["PATH"] ?? "";
18947
- const installed = commands.find(({ name }) => Bun.which(name, { PATH }) !== null);
19279
+ const [installed] = commands.flatMap((command) => {
19280
+ const executable = Bun.which(command.name, { PATH: path });
19281
+ return executable === null ? [] : [{ command, executable }];
19282
+ });
18948
19283
  if (installed === undefined) {
18949
19284
  const names = commands.map(({ name }) => name).join(" or ");
18950
19285
  return fail6(new ClipboardFailed({ message: `couldn't find ${names}` }));
18951
19286
  }
18952
- const { command, name } = installed;
18953
- return spawner.exitCode(command).pipe(catchTag2("PlatformError", (error) => fail6(new ClipboardFailed({ message: `${name} failed: ${error.message}` }))), flatMap4((code) => code === 0 ? void_3 : fail6(new ClipboardFailed({ message: `${name} exited with ${code}` }))));
19287
+ const { command, executable } = installed;
19288
+ const { name } = command;
19289
+ return spawner.exitCode(childProcess(command, executable, content.html)).pipe(catchTag2("PlatformError", (error) => fail6(new ClipboardFailed({ message: `${name} failed: ${error.message}` }))), flatMap4((code) => code === 0 ? succeed6("copied") : fail6(new ClipboardFailed({ message: `${name} exited with ${code}` }))));
18954
19290
  }
18955
- };
19291
+ });
18956
19292
  }));
18957
19293
  var ClipboardLive = clipboardLayer();
18958
19294
 
@@ -19036,7 +19372,7 @@ class NoPullRequests extends TaggedError2("NoPullRequests") {
19036
19372
  var EMOJI = {
19037
19373
  closed: "\uD83D\uDEAB",
19038
19374
  draft: "\uD83D\uDCDD",
19039
- merged: "\u2705",
19375
+ merged: "\uD83C\uDFC1",
19040
19376
  ready: "\uD83D\uDC40"
19041
19377
  };
19042
19378
  var OPEN = {
@@ -19045,20 +19381,41 @@ var OPEN = {
19045
19381
  merged: false,
19046
19382
  ready: true
19047
19383
  };
19048
- var markdownLinks = (pullRequests) => pullRequests.map(({ number, state, title, url }) => `${EMOJI[state]} [#${number} ${title}](${url})`).join(`
19384
+ var COPY_REPORT = {
19385
+ copied: "copied the links to the clipboard",
19386
+ unreachable: [
19387
+ "This Claude Code cloud session can't reach the user's clipboard.",
19388
+ "To give the user the links, put the Markdown links this command printed in your reply, outside a code block.",
19389
+ "The Claude app shows them as links, which paste into Slack as links."
19390
+ ].join(" ")
19391
+ };
19392
+ var lineCounts = ({ added, removed }) => `+${added}/-${removed}`;
19393
+ var markdownLinks = (pullRequests) => pullRequests.map((pullRequest) => `${EMOJI[pullRequest.state]} [#${pullRequest.number} ${pullRequest.title}](${pullRequest.url}) ${lineCounts(pullRequest)}`).join(`
19049
19394
  `);
19050
- var htmlLinks = (pullRequests) => `<meta charset="utf-8">${pullRequests.map(({ number, state, title, url }) => `${EMOJI[state]} <a href="${Bun.escapeHTML(url)}">#${number} ${Bun.escapeHTML(title)}</a>`).join("<br>")}`;
19395
+ var htmlLinks = (pullRequests) => `<meta charset="utf-8">${pullRequests.map((pullRequest) => `${EMOJI[pullRequest.state]} <a href="${Bun.escapeHTML(pullRequest.url)}">#${pullRequest.number} ${Bun.escapeHTML(pullRequest.title)}</a> ${lineCounts(pullRequest)}`).join("<br>")}`;
19051
19396
  var pullRequestOf = (pullRequests, commitId, pushed) => fromNullishOr(pullRequests.find(({ state }) => OPEN[state]) ?? pullRequests.find(({ head }) => head === commitId || head === pushed));
19052
19397
  var stackPullRequests = (revision) => gen2(function* () {
19053
19398
  const github = yield* GitHub;
19054
19399
  const stack = yield* stackChanges(revision);
19055
- const [targets, found] = yield* all2([
19400
+ const [targets, counts, found] = yield* all3([
19056
19401
  bookmarkTargets,
19402
+ lineCountsAt(stack.map(({ commitId }) => commitId)),
19057
19403
  forEach2(stack, ({ bookmark }) => github.pullRequestsFrom(bookmark), {
19058
19404
  concurrency: "unbounded"
19059
19405
  })
19060
19406
  ], { concurrency: "unbounded" });
19061
- return stack.flatMap(({ bookmark, commitId }, index) => toArray(pullRequestOf(found[index] ?? [], commitId, targets.get(bookmark)?.origin))).toReversed();
19407
+ const linked = [];
19408
+ for (const [index, { bookmark, commitId }] of stack.entries()) {
19409
+ const pullRequest = pullRequestOf(found[index] ?? [], commitId, targets.get(bookmark)?.origin);
19410
+ const changed = counts.get(commitId);
19411
+ if (isSome2(pullRequest)) {
19412
+ if (changed === undefined) {
19413
+ return yield* new JjFailed({ message: `jj printed no line counts for ${commitId}` });
19414
+ }
19415
+ linked.push({ ...pullRequest.value, ...changed });
19416
+ }
19417
+ }
19418
+ return linked.toReversed();
19062
19419
  });
19063
19420
  var links = ({
19064
19421
  copy,
@@ -19069,14 +19426,14 @@ var links = ({
19069
19426
  yield* log(text);
19070
19427
  if (copy) {
19071
19428
  const clipboard = yield* Clipboard;
19072
- yield* clipboard.write({ html: htmlLinks(pullRequests), text });
19073
- yield* error("copied the links to the clipboard");
19429
+ const written = yield* clipboard.write({ html: htmlLinks(pullRequests), text });
19430
+ yield* error(COPY_REPORT[written]);
19074
19431
  }
19075
19432
  });
19076
19433
  var linksCommand = make32("links", {
19077
- copy: Boolean6("copy").pipe(withDefault5(false), withDescription2("Also copy the links to the clipboard, as links that Slack pastes")),
19434
+ copy: Boolean6("copy").pipe(withDefault5(false), withDescription2("Also copy the links to the clipboard, as links that Slack pastes, or in a Claude Code cloud session say how to give them to the user")),
19078
19435
  revision: revisionFlag("A change of the stack to list")
19079
- }, (options) => asUserError(links(options).pipe(provide3([GitHubFromOrigin, ClipboardLive])))).pipe(withHelp("Print the stack's pull requests as Markdown links", "Prints one line per pull request, top first: \uD83D\uDCDD for a draft, \uD83D\uDC40 for one ready for review, \u2705 for a merged one and \uD83D\uDEAB for one closed unmerged, then a Markdown link showing its number and title.", "A change's pull request is the open one from its branch, or else the newest closed one whose head is the change or the commit pushed for it. A change with no pull request is left out, as is one that `sync` abandoned because its pull request merged. Fails where no change has one.", "With `--copy`, also puts the links on the clipboard as HTML, which Slack and other apps paste as links. That runs `osascript` on macOS, which also copies the Markdown as plain text, and `wl-copy` or `xclip` on Linux, which copy the HTML alone.", "Fails if the changes aren't a chain, if one has conflicts, or if one doesn't have exactly one bookmark, as `log` does. Changes nothing, locally or on GitHub."));
19436
+ }, (options) => asUserError(links(options).pipe(provide3([GitHubFromOrigin, ClipboardLive])))).pipe(withHelp("Print the stack's pull requests as Markdown links", "Prints one line per pull request, top first: \uD83D\uDCDD for a draft, \uD83D\uDC40 for one ready for review, \uD83C\uDFC1 for a merged one and \uD83D\uDEAB for one closed unmerged, then a Markdown link showing its number and title, then the lines its change adds and removes, as `+123/-45`.", "A change's pull request is the open one from its branch, or else the newest closed one whose head is the change or the commit pushed for it. A change with no pull request is left out, as is one that `sync` abandoned because its pull request merged. Fails where no change has one.", "With `--copy`, also puts the links on the clipboard as HTML, which Slack and other apps paste as links. That runs `osascript` on macOS, which also copies the Markdown as plain text, and `wl-copy` or `xclip` on Linux, which copy the HTML alone.", "In a Claude Code cloud session, where `CLAUDE_CODE_REMOTE` is `true`, `--copy` copies nothing. It tells the agent to put the Markdown in its reply, which the Claude app shows as links that paste into Slack.", "Fails if the changes aren't a chain, if one has conflicts, or if one doesn't have exactly one bookmark, as `log` does. Changes nothing, locally or on GitHub."));
19080
19437
 
19081
19438
  // src/cli/gh/log.ts
19082
19439
  var logLines2 = (entries) => {
@@ -19095,7 +19452,7 @@ var log2 = (revision) => gen2(function* () {
19095
19452
  const github = yield* GitHub;
19096
19453
  const stack = yield* stackChanges(revision);
19097
19454
  const targets = yield* bookmarkTargets;
19098
- const pullRequests = yield* all2(stack.map(({ bookmark }) => github.openPullRequest(bookmark)), { concurrency: "unbounded" });
19455
+ const pullRequests = yield* all3(stack.map(({ bookmark }) => github.openPullRequest(bookmark)), { concurrency: "unbounded" });
19099
19456
  return logLines2(stack.map((change, index) => ({
19100
19457
  bookmark: change.bookmark,
19101
19458
  pullRequest: pullRequests[index] ?? none2(),
@@ -19233,7 +19590,7 @@ class DescriptionConflict extends TaggedError2("DescriptionConflict") {
19233
19590
  var kept = (text) => ({ send: false, text });
19234
19591
  var sent = (text) => ({ send: true, text });
19235
19592
  var ignoreClaudeCodeFooterKey = "jj-octo.ignore-claude-code-footer";
19236
- var ignoresClaudeCodeFooter = jjFlag(ignoreClaudeCodeFooterKey);
19593
+ var ignoresClaudeCodeFooter = flatMap4(claudeCodeCloudSession, (cloudSession) => jjFlag(ignoreClaudeCodeFooterKey, cloudSession));
19237
19594
  var descriptionsOf = (commits) => commits.length === 0 ? succeed6(new Map) : readLog(commits.join(" | "), String.raw`commit_id ++ "\t" ++ description.escape_json() ++ "\n"`).pipe(map7((output) => new Map(lines2(output).map((line) => {
19238
19595
  const [commit = "", json = '""'] = line.split("\t");
19239
19596
  return [commit, parseDescription(json)];
@@ -19542,7 +19899,7 @@ var changedOnGitHub = (bookmarks) => gen2(function* () {
19542
19899
  var syncStack = (revision, trunk) => gen2(function* () {
19543
19900
  const downstack = downstackRevset(revision);
19544
19901
  const before = yield* bookmarksBeforeFetch(downstack);
19545
- const [heads, onGitHub] = yield* all2([mergedHeadsOf(before), changedOnGitHub(before)], {
19902
+ const [heads, onGitHub] = yield* all3([mergedHeadsOf(before), changedOnGitHub(before)], {
19546
19903
  concurrency: "unbounded"
19547
19904
  });
19548
19905
  const merged = yield* mergedIn(before, heads);
@@ -19584,7 +19941,7 @@ class SeveralStacks extends TaggedError2("SeveralStacks") {
19584
19941
  }
19585
19942
  var stackContaining = (pullRequests) => gen2(function* () {
19586
19943
  const github = yield* GitHub;
19587
- const found = yield* all2(pullRequests.map((pullRequest) => github.stackOf(pullRequest)), { concurrency: "unbounded" });
19944
+ const found = yield* all3(pullRequests.map((pullRequest) => github.stackOf(pullRequest)), { concurrency: "unbounded" });
19588
19945
  const stacks = dedupeWith(found.flatMap((stack) => toArray(stack)), (a, b) => a.number === b.number);
19589
19946
  if (stacks.length > 1) {
19590
19947
  return yield* new SeveralStacks({
@@ -19603,7 +19960,7 @@ var publish = (stack, { draft, overwriteDescriptions, trunk }) => gen2(function*
19603
19960
  const records = yield* PrDescriptions;
19604
19961
  const bookmarks = stack.map(({ bookmark }) => bookmark);
19605
19962
  const bases = basesFor(bookmarks, trunk);
19606
- const found = yield* all2(stack.map((change, index) => github.openPullRequest(change.bookmark).pipe(map7((pullRequest) => ({ base: bases[index] ?? trunk, change, pullRequest })))), { concurrency: "unbounded" });
19963
+ const found = yield* all3(stack.map((change, index) => github.openPullRequest(change.bookmark).pipe(map7((pullRequest) => ({ base: bases[index] ?? trunk, change, pullRequest })))), { concurrency: "unbounded" });
19607
19964
  const targets = yield* bookmarkTargets;
19608
19965
  const pushedDescriptions = yield* descriptionsOf(bookmarks.flatMap((bookmark) => targets.get(bookmark)?.origin ?? []));
19609
19966
  const ignoreClaudeCodeFooter = yield* ignoresClaudeCodeFooter;