@athrio/loom 0.0.10 → 0.0.11

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.
package/dist/main.js CHANGED
@@ -1,11 +1,17 @@
1
1
  #!/usr/bin/env node
2
2
  import { t as __commonJSMin } from "./rolldown-runtime-YU9U6SYh.js";
3
- import { $ as orDie$1, $p as map$4, $t as Literal, Af as Prototype, Ah as identity, Al as taggedEnum, Bf as filter, Bs as gen, Bt as Defect, Cc as result, Dh as dual, Es as fail, Ff as dedupe, Fn as Union, Gp as fromNullishOr, H as groupedWithin, Hl as provide, Hs as interrupt, I as fromEffect, Il as effect, Kp as fromUndefinedOr, Ku as pretty, Lc as scoped, Lp as match$3, Mm as format, Mp as fail$1, Ms as forEach, N as filter$1, Nh as pipeArguments, O as concat, Os as flatMap, Qp as isSome, Qs as map$2, Ra as take, Rp as succeed$1, Uc as suspend, Vc as succeed, Vp as contains, Wc as sync, Wn as decodeUnknownEffect, Ws as isEffect, Wt as ErrorClass, Xc as tryPromise, Xp as getOrUndefined, Zc as try_, Zp as isNone, Zt as Int, _c as provideService, _f as Service, ah as hasProperty, al as void_, bc as raceFirst, cm as String$2, dc as option, dt as unwrap, ec as mapError, em as match$2, er as is, fc as orDie, fp as sort, fs as catchCause, gc as provideContext, gf as Reference, gs as catchTags, h as Path, hc as provide$1, hs as catchTag, ii as tag, ip as map$3, is as andThen, it as runForEach, jh as pipe, js as fnUntraced, kt as ArraySchema, l as FalseValues, lp as reduce, mc as promise, ms as catchFilter, oi as toCodecStringTree, op as match, ou as MinimumLogLevel, pc as orElseSucceed, q as mapEffect$1, qp as getOrElse, rm as some, s as Boolean, ss as as, tc as match$1, ti as optional$3, tm as none, u as TrueValues, uh as isNotUndefined, vn as String$1, wf as make$1, ws as ensuring, y as FileSystem, yf as empty, yn as Struct, zl as launch } from "./SqlClient-BHo_uVyk.js";
4
- import { N as error, P as log, _ as orElse, c as errorExitCode, i as isQuitError, l as errorReported, n as QuitError, o as Stdio, r as Terminal, u as makeRunMain, v as tag$1, y as value } from "./dist-CKhPOkpR.js";
5
- import { a as storeDir, c as LoomCompiler, f as PackageConfig, i as servicePackage, l as ignoredDirs, n as installedServices, o as workspaceRoot, p as LoomConfig, r as removeService, s as DocumentSource, t as addService } from "./LoomStore-BGlpRj6W.js";
6
- import { t as layer } from "./NodeServices-CtEw3D6F.js";
3
+ import { $ as mkString, $n as UnknownError, $t as effectify, A as log, Ar as map$4, At as fromTransform, B as WatchBackend, Bn as mergeAll, Br as isNullish, Bt as nominal, C as errorExitCode, Cn as result, Cr as flatMap$1, Ct as decodeUnknownEffect, D as Crypto$1, Dn as succeed, Dr as getOrUndefined, Dt as toCodecStringTree, En as serviceOption, Er as getOrElse, Et as tag, F as TypeId$5, Fn as void_, Fr as BaseProto, Ft as offer, G as empty$1, Gn as MinimumLogLevel, Gr as pipeArguments, Gt as asVoid, H as callback$1, Hn as provideMerge, Hr as dual, Ht as addFinalizer$1, I as FileDescriptor, In as catchDone, Ir as format, It as offerUnsafe, J as fromEffect, Jn as isDone, Jt as catchFilter, K as filter$1, Kn as _await, Kt as callback, L as FileSystem, Ln as TaggedError, Lr as hasProperty, Lt as take, M as FalseValues, Mn as tryPromise, Mr as none, Mt as endUnsafe, N as TrueValues, Nn as try_, Nr as some, Nt as failCauseUnsafe, O as make$9, On as suspend, Or as isNone, P as Path$1, Pn as uninterruptible, Pr as String$2, Pt as make$12, Q as merge, Qn as Done, R as FileTypeId, Rn as taggedEnum, Rr as isNotNull, Rt as make$7, S as make$10, Sn as raceFirst, Sr as contains, St as Union, T as makeRunMain, Tn as scoped, Tr as fromUndefinedOr, Tt as optional$3, U as concat, Un as succeed$3, Ur as identity, Ut as andThen, V as make$8, Vn as provide, Vr as isUndefined, Vt as acquireRelease, W as decodeText, Wn as addFinalizer, Wr as pipe, Wt as as, X as isStream, Xn as fail$2, Xt as catchTags, Y as groupedWithin, Yn as makeUnsafe$1, Yt as catchTag, Z as mapEffect$1, Zn as succeed$2, Zt as catch_, _ as QuitError, _n as orDie, _r as reduce, _t as ErrorClass, a as storeDir, an as forever, ar as empty, at as transduce, b as make$13, bn as provideContext, br as match$3, bt as String$1, c as LoomCompiler, cn as ignore, cr as Prototype, ct as make$11, dt as isSink, en as ensuring, er as done, et as orDie$1, f as PackageConfig, fn as map$2, ft as BadArgument, gn as option, gr as of, gt as Defect, hn as matchEffect, hr as match, ht as ArraySchema, i as servicePackage, in as forEach, ir as Service, it as splitLines, j as Boolean, jn as timeoutOrElse, jr as match$2, jt as mapDone, k as error, kn as sync, kr as isSome, l as ignoredDirs, ln as interrupt, lr as dedupe, lt as drain, mn as match$1, mr as map$3, mt as systemError, n as installedServices, nn as flatMap, nr as pretty, nt as runCollect, o as workspaceRoot, on as forkScoped, or as getUnsafe, ot as unwrap, p as LoomConfig, pn as mapError, pt as badArgument, q as fromChannel$1, qn as doneUnsafe, qt as catchCause, r as removeService, rn as fnUntraced, rr as Reference, rt as runForEach, s as DocumentSource, sn as gen, sr as make$6, st as get, t as addService, tn as fail, tr as fail$3, tt as run$2, un as isEffect, ur as filter, ut as fromChannel, v as Terminal, vn as orElseSucceed, vr as sort, vt as Int, w as errorReported, wn as runFork, wr as fromNullishOr, wt as is, x as Stdio, xn as provideService, xr as succeed$1, xt as Struct, y as isQuitError, yn as provide$1, yr as fail$1, yt as Literal, z as Size, zn as effect, zr as isNotUndefined, zt as makeUnsafe } from "./LoomStore-DTpgIJ9l.js";
4
+ import * as NodeChildProcess from "node:child_process";
5
+ import { PassThrough } from "node:stream";
6
+ import * as Crypto from "node:crypto";
7
+ import * as NFS from "node:fs";
7
8
  import { existsSync, readFileSync, writeFileSync } from "node:fs";
9
+ import * as OS from "node:os";
10
+ import * as Path from "node:path";
8
11
  import { dirname, relative, resolve } from "node:path";
12
+ import * as NodeUrl from "node:url";
13
+ import * as readline from "node:readline";
14
+ import { createRequire } from "node:module";
9
15
  //#region ../../node_modules/effect/dist/unstable/cli/CliError.js
10
16
  /**
11
17
  * Defines structured errors for the unstable CLI parser and runner.
@@ -23,7 +29,7 @@ import { dirname, relative, resolve } from "node:path";
23
29
  * @category type IDs
24
30
  * @since 4.0.0
25
31
  */
26
- var TypeId$3 = "~effect/cli/CliError";
32
+ var TypeId$4 = "~effect/cli/CliError";
27
33
  /**
28
34
  * Type guard to check if a value is a CLI error.
29
35
  *
@@ -54,7 +60,7 @@ var TypeId$3 = "~effect/cli/CliError";
54
60
  * @category guards
55
61
  * @since 4.0.0
56
62
  */
57
- var isCliError = (u) => hasProperty(u, TypeId$3);
63
+ var isCliError = (u) => hasProperty(u, TypeId$4);
58
64
  /**
59
65
  * Error thrown when an unrecognized option is encountered.
60
66
  *
@@ -88,7 +94,7 @@ var isCliError = (u) => hasProperty(u, TypeId$3);
88
94
  * @category models
89
95
  * @since 4.0.0
90
96
  */
91
- var UnrecognizedOption = class extends ErrorClass(`${TypeId$3}/UnrecognizedOption`)({
97
+ var UnrecognizedOption = class extends ErrorClass(`${TypeId$4}/UnrecognizedOption`)({
92
98
  _tag: /*#__PURE__*/ tag("UnrecognizedOption"),
93
99
  option: String$1,
94
100
  command: /*#__PURE__*/ optional$3(/*#__PURE__*/ ArraySchema(String$1)),
@@ -99,7 +105,7 @@ var UnrecognizedOption = class extends ErrorClass(`${TypeId$3}/UnrecognizedOptio
99
105
  *
100
106
  * @since 4.0.0
101
107
  */
102
- [TypeId$3] = TypeId$3;
108
+ [TypeId$4] = TypeId$4;
103
109
  /**
104
110
  * Formats the unrecognized option with command context and suggestions.
105
111
  *
@@ -132,7 +138,7 @@ var UnrecognizedOption = class extends ErrorClass(`${TypeId$3}/UnrecognizedOptio
132
138
  * @category models
133
139
  * @since 4.0.0
134
140
  */
135
- var DuplicateOption = class extends ErrorClass(`${TypeId$3}/DuplicateOption`)({
141
+ var DuplicateOption = class extends ErrorClass(`${TypeId$4}/DuplicateOption`)({
136
142
  _tag: /*#__PURE__*/ tag("DuplicateOption"),
137
143
  option: String$1,
138
144
  parentCommand: String$1,
@@ -143,7 +149,7 @@ var DuplicateOption = class extends ErrorClass(`${TypeId$3}/DuplicateOption`)({
143
149
  *
144
150
  * @since 4.0.0
145
151
  */
146
- [TypeId$3] = TypeId$3;
152
+ [TypeId$4] = TypeId$4;
147
153
  /**
148
154
  * Explains which parent and child commands define the duplicate option.
149
155
  *
@@ -183,7 +189,7 @@ var DuplicateOption = class extends ErrorClass(`${TypeId$3}/DuplicateOption`)({
183
189
  * @category models
184
190
  * @since 4.0.0
185
191
  */
186
- var MissingOption = class extends ErrorClass(`${TypeId$3}/MissingOption`)({
192
+ var MissingOption = class extends ErrorClass(`${TypeId$4}/MissingOption`)({
187
193
  _tag: /*#__PURE__*/ tag("MissingOption"),
188
194
  option: String$1
189
195
  }) {
@@ -192,7 +198,7 @@ var MissingOption = class extends ErrorClass(`${TypeId$3}/MissingOption`)({
192
198
  *
193
199
  * @since 4.0.0
194
200
  */
195
- [TypeId$3] = TypeId$3;
201
+ [TypeId$4] = TypeId$4;
196
202
  /**
197
203
  * Formats the missing required flag for display.
198
204
  *
@@ -231,7 +237,7 @@ var MissingOption = class extends ErrorClass(`${TypeId$3}/MissingOption`)({
231
237
  * @category models
232
238
  * @since 4.0.0
233
239
  */
234
- var MissingArgument = class extends ErrorClass(`${TypeId$3}/MissingArgument`)({
240
+ var MissingArgument = class extends ErrorClass(`${TypeId$4}/MissingArgument`)({
235
241
  _tag: /*#__PURE__*/ tag("MissingArgument"),
236
242
  argument: String$1
237
243
  }) {
@@ -240,7 +246,7 @@ var MissingArgument = class extends ErrorClass(`${TypeId$3}/MissingArgument`)({
240
246
  *
241
247
  * @since 4.0.0
242
248
  */
243
- [TypeId$3] = TypeId$3;
249
+ [TypeId$4] = TypeId$4;
244
250
  /**
245
251
  * Formats the missing required positional argument for display.
246
252
  *
@@ -284,7 +290,7 @@ var MissingArgument = class extends ErrorClass(`${TypeId$3}/MissingArgument`)({
284
290
  * @category models
285
291
  * @since 4.0.0
286
292
  */
287
- var InvalidValue = class extends ErrorClass(`${TypeId$3}/InvalidValue`)({
293
+ var InvalidValue = class extends ErrorClass(`${TypeId$4}/InvalidValue`)({
288
294
  _tag: /*#__PURE__*/ tag("InvalidValue"),
289
295
  option: String$1,
290
296
  value: String$1,
@@ -296,7 +302,7 @@ var InvalidValue = class extends ErrorClass(`${TypeId$3}/InvalidValue`)({
296
302
  *
297
303
  * @since 4.0.0
298
304
  */
299
- [TypeId$3] = TypeId$3;
305
+ [TypeId$4] = TypeId$4;
300
306
  /**
301
307
  * Formats the invalid flag or argument value with the expected input.
302
308
  *
@@ -343,7 +349,7 @@ var InvalidValue = class extends ErrorClass(`${TypeId$3}/InvalidValue`)({
343
349
  * @category models
344
350
  * @since 4.0.0
345
351
  */
346
- var UnknownSubcommand = class extends ErrorClass(`${TypeId$3}/UnknownSubcommand`)({
352
+ var UnknownSubcommand = class extends ErrorClass(`${TypeId$4}/UnknownSubcommand`)({
347
353
  _tag: /*#__PURE__*/ tag("UnknownSubcommand"),
348
354
  subcommand: String$1,
349
355
  parent: /*#__PURE__*/ optional$3(/*#__PURE__*/ ArraySchema(String$1)),
@@ -354,7 +360,7 @@ var UnknownSubcommand = class extends ErrorClass(`${TypeId$3}/UnknownSubcommand`
354
360
  *
355
361
  * @since 4.0.0
356
362
  */
357
- [TypeId$3] = TypeId$3;
363
+ [TypeId$4] = TypeId$4;
358
364
  /**
359
365
  * Formats the unknown subcommand with parent command context and suggestions.
360
366
  *
@@ -401,7 +407,7 @@ var UnknownSubcommand = class extends ErrorClass(`${TypeId$3}/UnknownSubcommand`
401
407
  * @category models
402
408
  * @since 4.0.0
403
409
  */
404
- var UserError = class extends ErrorClass(`${TypeId$3}/UserError`)({
410
+ var UserError = class extends ErrorClass(`${TypeId$4}/UserError`)({
405
411
  _tag: /*#__PURE__*/ tag("UserError"),
406
412
  cause: /*#__PURE__*/ Defect()
407
413
  }) {
@@ -410,7 +416,7 @@ var UserError = class extends ErrorClass(`${TypeId$3}/UserError`)({
410
416
  *
411
417
  * @since 4.0.0
412
418
  */
413
- [TypeId$3] = TypeId$3;
419
+ [TypeId$4] = TypeId$4;
414
420
  };
415
421
  /**
416
422
  * Schema for concrete CLI errors that can be reported together with help output.
@@ -444,12 +450,12 @@ var NonShowHelpErrors = /*#__PURE__*/ Union([
444
450
  * @category models
445
451
  * @since 4.0.0
446
452
  */
447
- var ShowHelp = class extends ErrorClass(`${TypeId$3}/ShowHelp`)({
453
+ var ShowHelp = class extends ErrorClass(`${TypeId$4}/ShowHelp`)({
448
454
  _tag: /*#__PURE__*/ tag("ShowHelp"),
449
455
  commandPath: /*#__PURE__*/ ArraySchema(String$1),
450
456
  errors: /*#__PURE__*/ ArraySchema(NonShowHelpErrors)
451
457
  }) {
452
- [TypeId$3] = TypeId$3;
458
+ [TypeId$4] = TypeId$4;
453
459
  [errorExitCode] = this.errors.length ? 1 : 0;
454
460
  [errorReported] = false;
455
461
  get message() {
@@ -4818,14 +4824,14 @@ var require_toml = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4818
4824
  }));
4819
4825
  require_ini();
4820
4826
  require_toml();
4821
- var Proto$2 = { ["~effect/cli/Primitive"]: { _A: identity } };
4827
+ var Proto$3 = { ["~effect/cli/Primitive"]: { _A: identity } };
4822
4828
  /** @internal */
4823
4829
  var isTrueValue = /*#__PURE__*/ is(TrueValues);
4824
4830
  /** @internal */
4825
4831
  var isFalseValue = /*#__PURE__*/ is(FalseValues);
4826
4832
  /** @internal */
4827
4833
  var isBoolean = (p) => p._tag === "Boolean";
4828
- var makePrimitive = (tag, parse) => Object.assign(Object.create(Proto$2), {
4834
+ var makePrimitive = (tag, parse) => Object.assign(Object.create(Proto$3), {
4829
4835
  _tag: tag,
4830
4836
  parse
4831
4837
  });
@@ -4988,7 +4994,7 @@ var choice$2 = (choices) => {
4988
4994
  */
4989
4995
  var path$1 = (pathType, mustExist) => makePrimitive("Path", fnUntraced(function* (value) {
4990
4996
  const fs = yield* FileSystem;
4991
- const path = yield* Path;
4997
+ const path = yield* Path$1;
4992
4998
  const absolutePath = path.isAbsolute(value) ? value : path.resolve(value);
4993
4999
  const exists = yield* mapError(fs.exists(absolutePath), (error) => `Failed to check path existence: ${error.message}`);
4994
5000
  if (mustExist === true && !exists) return yield* fail(`Path does not exist: ${absolutePath}`);
@@ -5138,7 +5144,7 @@ var eraseLines = (rows) => {
5138
5144
  *
5139
5145
  * @since 4.0.0
5140
5146
  */
5141
- var TypeId$2 = "~effect/cli/Prompt";
5147
+ var TypeId$3 = "~effect/cli/Prompt";
5142
5148
  var defaultFigures = {
5143
5149
  arrowUp: "↑",
5144
5150
  arrowDown: "↓",
@@ -5239,7 +5245,7 @@ var proto = {
5239
5245
  return run$1(this);
5240
5246
  }
5241
5247
  }),
5242
- [TypeId$2]: { _Output: (_) => _ }
5248
+ [TypeId$3]: { _Output: (_) => _ }
5243
5249
  };
5244
5250
  var runWithInput = (prompt, terminal, input) => suspend(() => {
5245
5251
  const op = prompt;
@@ -5493,7 +5499,7 @@ var basePrompt = (options, type) => {
5493
5499
  };
5494
5500
  //#endregion
5495
5501
  //#region ../../node_modules/effect/dist/unstable/cli/Param.js
5496
- var TypeId$1 = "~effect/cli/Param";
5502
+ var TypeId$2 = "~effect/cli/Param";
5497
5503
  /**
5498
5504
  * Defines the kind discriminator for positional argument parameters.
5499
5505
  *
@@ -5523,8 +5529,8 @@ var argumentKind = "argument";
5523
5529
  * @since 4.0.0
5524
5530
  */
5525
5531
  var flagKind = "flag";
5526
- var Proto$1 = {
5527
- [TypeId$1]: { _A: identity },
5532
+ var Proto$2 = {
5533
+ [TypeId$2]: { _A: identity },
5528
5534
  pipe() {
5529
5535
  return pipeArguments(this, arguments);
5530
5536
  }
@@ -5547,7 +5553,7 @@ var Proto$1 = {
5547
5553
  * @category refinements
5548
5554
  * @since 4.0.0
5549
5555
  */
5550
- var isParam = (u) => hasProperty(u, TypeId$1);
5556
+ var isParam = (u) => hasProperty(u, TypeId$2);
5551
5557
  /**
5552
5558
  * Type guard to check if a Single param is a flag (not an argument).
5553
5559
  *
@@ -5568,7 +5574,7 @@ var isFlagParam = (single) => single.kind === "flag";
5568
5574
  */
5569
5575
  var makeSingle = (params) => {
5570
5576
  const parse = (args) => params.kind === "argument" ? parsePositional(params.name, params.primitiveType, args) : parseFlag(params.name, params.primitiveType, args);
5571
- return Object.assign(Object.create(Proto$1), {
5577
+ return Object.assign(Object.create(Proto$2), {
5572
5578
  _tag: "Single",
5573
5579
  ...params,
5574
5580
  description: params.description ?? none(),
@@ -5856,7 +5862,7 @@ var withDescription$1 = /*#__PURE__*/ dual(2, (self, description) => {
5856
5862
  */
5857
5863
  var map$1 = /*#__PURE__*/ dual(2, (self, f) => {
5858
5864
  const parse = (args) => map$2(self.parse(args), ([operands, value]) => [operands, f(value)]);
5859
- return Object.assign(Object.create(Proto$1), {
5865
+ return Object.assign(Object.create(Proto$2), {
5860
5866
  _tag: "Map",
5861
5867
  kind: self.kind,
5862
5868
  param: self,
@@ -5864,7 +5870,7 @@ var map$1 = /*#__PURE__*/ dual(2, (self, f) => {
5864
5870
  parse
5865
5871
  });
5866
5872
  });
5867
- var transform = (self, f) => Object.assign(Object.create(Proto$1), {
5873
+ var transform = (self, f) => Object.assign(Object.create(Proto$2), {
5868
5874
  _tag: "Transform",
5869
5875
  kind: self.kind,
5870
5876
  param: self,
@@ -5932,7 +5938,7 @@ var optional$2 = (param) => {
5932
5938
  MissingArgument: () => succeed([args.arguments, none()])
5933
5939
  }));
5934
5940
  });
5935
- return Object.assign(Object.create(Proto$1), {
5941
+ return Object.assign(Object.create(Proto$2), {
5936
5942
  _tag: "Optional",
5937
5943
  kind: param.kind,
5938
5944
  param,
@@ -6014,7 +6020,7 @@ var variadic = (self, options) => {
6014
6020
  if (single.kind === "argument") return parsePositionalVariadic(self, single, args, options);
6015
6021
  else return parseOptionVariadic(self, single, args, options);
6016
6022
  };
6017
- return Object.assign(Object.create(Proto$1), {
6023
+ return Object.assign(Object.create(Proto$2), {
6018
6024
  _tag: "Variadic",
6019
6025
  kind: self.kind,
6020
6026
  param: self,
@@ -7323,13 +7329,13 @@ var reconstructTree = (tree, results) => {
7323
7329
  * Internal implementation details for CLI commands.
7324
7330
  * Public API is in ../Command.ts
7325
7331
  */
7326
- var TypeId = "~effect/cli/Command";
7332
+ var TypeId$1 = "~effect/cli/Command";
7327
7333
  /**
7328
7334
  * Casts a Command to its internal implementation.
7329
7335
  * For use by internal modules that need access to config, parse, handle, etc.
7330
7336
  */
7331
7337
  var toImpl = (self) => self;
7332
- var Proto = { .../*#__PURE__*/ Prototype({
7338
+ var Proto$1 = { .../*#__PURE__*/ Prototype({
7333
7339
  label: "Command",
7334
7340
  evaluate() {
7335
7341
  return toImpl(this).service;
@@ -7404,8 +7410,8 @@ var makeCommand = (options) => {
7404
7410
  ...examples.length > 0 && { examples }
7405
7411
  };
7406
7412
  };
7407
- return Object.assign(Object.create(Proto), {
7408
- [TypeId]: TypeId,
7413
+ return Object.assign(Object.create(Proto$1), {
7414
+ [TypeId$1]: TypeId$1,
7409
7415
  name: options.name,
7410
7416
  examples: options.examples ?? [],
7411
7417
  annotations,
@@ -8466,7 +8472,7 @@ var scanCommandLevel = (tokens, context) => {
8466
8472
  * @category guards
8467
8473
  * @since 4.0.0
8468
8474
  */
8469
- var isCommand = (u) => hasProperty(u, TypeId);
8475
+ var isCommand = (u) => hasProperty(u, TypeId$1);
8470
8476
  /**
8471
8477
  * Creates a `Command` from a name, an optional configuration, and an optional
8472
8478
  * handler.
@@ -8524,7 +8530,7 @@ var isCommand = (u) => hasProperty(u, TypeId);
8524
8530
  * @category constructors
8525
8531
  * @since 4.0.0
8526
8532
  */
8527
- var make = (name, config, handler) => {
8533
+ var make$5 = (name, config, handler) => {
8528
8534
  return makeCommand({
8529
8535
  name,
8530
8536
  config: parseConfig(config ?? {}),
@@ -8817,12 +8823,1483 @@ var runWith = (command, config) => {
8817
8823
  program = provideService(program, LogLevel, logLevel);
8818
8824
  const services = match$2(logLevel, {
8819
8825
  onNone: () => empty(),
8820
- onSome: (level) => make$1(MinimumLogLevel, level)
8826
+ onSome: (level) => make$6(MinimumLogLevel, level)
8821
8827
  });
8822
8828
  yield* provideContext(program, services);
8823
8829
  }, catchFilter((error) => isCliError(error) && error._tag === "ShowHelp" ? succeed$1(error) : fail$1(error), (error) => andThen(showHelp(command, error), fail(error))), catchFilter((e) => isQuitError(e) ? succeed$1(e) : fail$1(e), (_) => interrupt));
8824
8830
  };
8825
8831
  //#endregion
8832
+ //#region ../../node_modules/effect/dist/unstable/process/ChildProcessSpawner.js
8833
+ /**
8834
+ * Service boundary for starting and controlling child processes.
8835
+ *
8836
+ * `ChildProcessSpawner` is the service used by `ChildProcess` commands to start
8837
+ * operating-system processes. A spawner turns a command description into a
8838
+ * handle that can write to stdin, read stdout and stderr, wait for exit, kill
8839
+ * the process, and manage whether the process keeps its parent alive. Platform
8840
+ * backends implement this service, while most application code uses the higher
8841
+ * level `ChildProcess` module.
8842
+ *
8843
+ * @since 4.0.0
8844
+ */
8845
+ /**
8846
+ * Constructs branded child process `ExitCode` values.
8847
+ *
8848
+ * @category constructors
8849
+ * @since 4.0.0
8850
+ */
8851
+ var ExitCode = /*#__PURE__*/ nominal();
8852
+ /**
8853
+ * Constructs branded child process `ProcessId` values.
8854
+ *
8855
+ * @category constructors
8856
+ * @since 4.0.0
8857
+ */
8858
+ var ProcessId = /*#__PURE__*/ nominal();
8859
+ var HandleTypeId = "~effect/ChildProcessSpawner/ChildProcessHandle";
8860
+ var HandleProto = {
8861
+ [HandleTypeId]: HandleTypeId,
8862
+ ...BaseProto,
8863
+ toJSON() {
8864
+ return {
8865
+ _id: "ChildProcessHandle",
8866
+ pid: this.pid
8867
+ };
8868
+ }
8869
+ };
8870
+ /**
8871
+ * Constructs a new `ChildProcessHandle`.
8872
+ *
8873
+ * @category constructors
8874
+ * @since 4.0.0
8875
+ */
8876
+ var makeHandle = (params) => Object.assign(Object.create(HandleProto), params);
8877
+ /**
8878
+ * Creates a `ChildProcessSpawner` service from a `spawn` function, deriving
8879
+ * helpers for exit codes and output collection from that implementation.
8880
+ *
8881
+ * @category models
8882
+ * @since 4.0.0
8883
+ */
8884
+ var make$4 = (spawn) => {
8885
+ const streamString = (command, options) => spawn(command).pipe(map$2((handle) => decodeText(options?.includeStderr === true ? handle.all : handle.stdout)), unwrap);
8886
+ const streamLines = (command, options) => splitLines(streamString(command, options));
8887
+ return ChildProcessSpawner.of({
8888
+ spawn,
8889
+ exitCode: (command) => scoped(flatMap(spawn(command), (handle) => handle.exitCode)),
8890
+ streamString,
8891
+ streamLines,
8892
+ lines: (command, options) => runCollect(streamLines(command, options)),
8893
+ string: (command, options) => mkString(streamString(command, options))
8894
+ });
8895
+ };
8896
+ /**
8897
+ * Service tag for child process spawning.
8898
+ *
8899
+ * @category services
8900
+ * @since 4.0.0
8901
+ */
8902
+ var ChildProcessSpawner = class extends Service()("effect/process/ChildProcessSpawner") {};
8903
+ //#endregion
8904
+ //#region ../../node_modules/effect/dist/unstable/process/ChildProcess.js
8905
+ /**
8906
+ * Describes child processes before they are started.
8907
+ *
8908
+ * A `Command` stores the executable, arguments, environment, standard streams,
8909
+ * working directory, and other process options. Commands can also be piped
8910
+ * together. A command is an `Effect`; running it asks the
8911
+ * `ChildProcessSpawner` service to start the process and returns a
8912
+ * `ChildProcessHandle`.
8913
+ *
8914
+ * @since 4.0.0
8915
+ */
8916
+ var TypeId = "~effect/unstable/process/ChildProcess";
8917
+ var Proto = {
8918
+ .../*#__PURE__*/ Prototype({
8919
+ label: "Command",
8920
+ evaluate(fiber) {
8921
+ return getUnsafe(fiber.context, ChildProcessSpawner).spawn(this);
8922
+ }
8923
+ }),
8924
+ [TypeId]: TypeId
8925
+ };
8926
+ var makeStandardCommand = (command, args, options) => Object.assign(Object.create(Proto), {
8927
+ _tag: "StandardCommand",
8928
+ command,
8929
+ args,
8930
+ options
8931
+ });
8932
+ /**
8933
+ * Create a command from a template literal, options + template, or array form.
8934
+ *
8935
+ * **Details**
8936
+ *
8937
+ * This function supports three calling conventions:
8938
+ * 1. Template literal: `make\`npm run build\``
8939
+ * 2. Options + template literal: `make({ cwd: "/app" })\`npm run build\``
8940
+ * 3. Array form: `make("npm", ["run", "build"], options?)`
8941
+ *
8942
+ * Template literals are not parsed until execution time, allowing parsing
8943
+ * errors to flow through Effect's error channel.
8944
+ *
8945
+ * **Example** (Creating commands)
8946
+ *
8947
+ * ```ts
8948
+ * import { ChildProcess } from "effect/unstable/process"
8949
+ *
8950
+ * // Template literal form
8951
+ * const cmd1 = ChildProcess.make`echo "hello"`
8952
+ *
8953
+ * // With options
8954
+ * const cmd2 = ChildProcess.make({ cwd: "/tmp" })`ls -la`
8955
+ *
8956
+ * // Array form
8957
+ * const cmd3 = ChildProcess.make("git", ["status"])
8958
+ * ```
8959
+ *
8960
+ * @category constructors
8961
+ * @since 4.0.0
8962
+ */
8963
+ var make$3 = function make(...args) {
8964
+ if (isTemplateString(args[0])) {
8965
+ const [templates, ...expressions] = args;
8966
+ const tokens = parseTemplates(templates, expressions);
8967
+ return makeStandardCommand(tokens[0] ?? "", tokens.slice(1), {});
8968
+ }
8969
+ if (typeof args[0] === "object" && !Array.isArray(args[0]) && !isTemplateString(args[0])) {
8970
+ const options = args[0];
8971
+ return function(templates, ...expressions) {
8972
+ const tokens = parseTemplates(templates, expressions);
8973
+ return makeStandardCommand(tokens[0] ?? "", tokens.slice(1), options);
8974
+ };
8975
+ }
8976
+ if (typeof args[0] === "string" && !Array.isArray(args[1])) {
8977
+ const [command, options = {}] = args;
8978
+ return makeStandardCommand(command, [], options);
8979
+ }
8980
+ const [command, cmdArgs = [], options = {}] = args;
8981
+ return makeStandardCommand(command, cmdArgs, options);
8982
+ };
8983
+ var isTemplateString = (u) => Array.isArray(u) && "raw" in u && Array.isArray(u.raw);
8984
+ /**
8985
+ * Parses an fd name like "fd3" to its numeric index.
8986
+ * Returns undefined if the name is invalid.
8987
+ *
8988
+ * @category converting
8989
+ * @since 4.0.0
8990
+ */
8991
+ var parseFdName = (name) => {
8992
+ const match = /^fd(\d+)$/.exec(name);
8993
+ if (match === null) return void 0;
8994
+ const fd = parseInt(match[1], 10);
8995
+ return fd >= 3 ? fd : void 0;
8996
+ };
8997
+ /**
8998
+ * Create an fd name from its numeric index.
8999
+ *
9000
+ * @category converting
9001
+ * @since 4.0.0
9002
+ */
9003
+ var fdName = (fd) => `fd${fd}`;
9004
+ var parseTemplates = (templates, expressions) => {
9005
+ let tokens = [];
9006
+ for (const [index, template] of templates.entries()) tokens = parseTemplate(templates, expressions, tokens, template, index);
9007
+ return tokens;
9008
+ };
9009
+ var parseTemplate = (templates, expressions, prevTokens, template, index) => {
9010
+ const rawTemplate = templates.raw[index];
9011
+ if (rawTemplate === void 0) throw new Error(`Invalid backslash sequence: ${templates.raw[index]}`);
9012
+ const { hasLeadingWhitespace, hasTrailingWhitespace, tokens } = splitByWhitespaces(template, rawTemplate);
9013
+ const nextTokens = concatTokens(prevTokens, tokens, hasLeadingWhitespace);
9014
+ if (index === expressions.length) return nextTokens;
9015
+ const expression = expressions[index];
9016
+ return concatTokens(nextTokens, Array.isArray(expression) ? expression.map((expression) => parseExpression(expression)) : [parseExpression(expression)], hasTrailingWhitespace);
9017
+ };
9018
+ /**
9019
+ * Convert valid expressions defined in a template string command (i.e. using
9020
+ * `${expression}` into strings.
9021
+ */
9022
+ var parseExpression = (expression) => {
9023
+ if (typeof expression === "string") return expression;
9024
+ return String(expression);
9025
+ };
9026
+ var DELIMITERS = /*#__PURE__*/ new Set([
9027
+ " ",
9028
+ " ",
9029
+ "\r",
9030
+ "\n"
9031
+ ]);
9032
+ /**
9033
+ * Number of characters in backslash escape sequences: \0 \xXX or \uXXXX
9034
+ * \cX is allowed in RegExps but not in strings
9035
+ * Octal sequences are not allowed in strict mode
9036
+ */
9037
+ var ESCAPE_LENGTH = {
9038
+ x: 3,
9039
+ u: 5
9040
+ };
9041
+ /**
9042
+ * Splits a template string by whitespace while also properly handling escape
9043
+ * sequences.
9044
+ *
9045
+ * As an example, let's review the following valid commands:
9046
+ *
9047
+ * ```ts
9048
+ * ChildProcess.exec`echo foo\n bar`
9049
+ * // We should run `["echo", "foo\n", "bar"]`
9050
+ *
9051
+ * ChildProcess.exec`echo foo
9052
+ * bar`
9053
+ * // We should run `["echo", "foo", "bar]`
9054
+ * ```
9055
+ *
9056
+ * The problem is that when we evaluate the template string for both of the above
9057
+ * commands, we will end up with the same string "echo foo\n bar".
9058
+ *
9059
+ * What we really want is to include the escaped character in the arguments for
9060
+ * the first command, since it was written explicitly by the user.
9061
+ *
9062
+ * This is why also having access to the raw template string is useful - in a
9063
+ * template string, there are two representations of the same string:
9064
+ * 1. `template` - The processed string (escape sequences are evaluated).
9065
+ * 2. `template.raw` - The raw string (escape sequences are literal).
9066
+ */
9067
+ var splitByWhitespaces = (template, rawTemplate) => {
9068
+ if (rawTemplate.length === 0) return {
9069
+ tokens: [],
9070
+ hasLeadingWhitespace: false,
9071
+ hasTrailingWhitespace: false
9072
+ };
9073
+ const hasLeadingWhitespace = DELIMITERS.has(rawTemplate[0]);
9074
+ const tokens = [];
9075
+ let templateCursor = 0;
9076
+ for (let templateIndex = 0, rawIndex = 0; templateIndex < template.length; templateIndex += 1, rawIndex += 1) {
9077
+ const rawCharacter = rawTemplate[rawIndex];
9078
+ if (DELIMITERS.has(rawCharacter)) {
9079
+ if (templateCursor !== templateIndex) tokens.push(template.slice(templateCursor, templateIndex));
9080
+ templateCursor = templateIndex + 1;
9081
+ } else if (rawCharacter === "\\") {
9082
+ const nextRawCharacter = rawTemplate[rawIndex + 1];
9083
+ if (nextRawCharacter === "\n") {
9084
+ templateIndex -= 1;
9085
+ rawIndex += 1;
9086
+ } else if (nextRawCharacter === "u" && rawTemplate[rawIndex + 2] === "{") rawIndex = rawTemplate.indexOf("}", rawIndex + 3);
9087
+ else rawIndex += ESCAPE_LENGTH[nextRawCharacter] ?? 1;
9088
+ }
9089
+ }
9090
+ const hasTrailingWhitespace = templateCursor === template.length;
9091
+ if (!hasTrailingWhitespace) tokens.push(template.slice(templateCursor));
9092
+ return {
9093
+ tokens,
9094
+ hasLeadingWhitespace,
9095
+ hasTrailingWhitespace
9096
+ };
9097
+ };
9098
+ /**
9099
+ * Concatenates two separate sets of string tokens together.
9100
+ *
9101
+ * If either set is empty or `isSeparated=false`, the last element of `prevTokens`
9102
+ * and the first element of `nextTokens` will be joined into a single token.
9103
+ */
9104
+ var concatTokens = (prevTokens, nextTokens, isSeparated) => isSeparated || prevTokens.length === 0 || nextTokens.length === 0 ? [...prevTokens, ...nextTokens] : [
9105
+ ...prevTokens.slice(0, -1),
9106
+ `${prevTokens.at(-1)}${nextTokens.at(0)}`,
9107
+ ...nextTokens.slice(1)
9108
+ ];
9109
+ //#endregion
9110
+ //#region ../../node_modules/@effect/platform-node-shared/dist/internal/utils.js
9111
+ /** @internal */
9112
+ var handleErrnoException = (module, method) => (err, [path]) => {
9113
+ let reason = "Unknown";
9114
+ switch (err.code) {
9115
+ case "ENOENT":
9116
+ reason = "NotFound";
9117
+ break;
9118
+ case "EACCES":
9119
+ reason = "PermissionDenied";
9120
+ break;
9121
+ case "EEXIST":
9122
+ reason = "AlreadyExists";
9123
+ break;
9124
+ case "EISDIR":
9125
+ reason = "BadResource";
9126
+ break;
9127
+ case "ENOTDIR":
9128
+ reason = "BadResource";
9129
+ break;
9130
+ case "EBUSY":
9131
+ reason = "Busy";
9132
+ break;
9133
+ case "ELOOP":
9134
+ reason = "BadResource";
9135
+ break;
9136
+ }
9137
+ return systemError({
9138
+ _tag: reason,
9139
+ module,
9140
+ method,
9141
+ pathOrDescriptor: path,
9142
+ syscall: err.syscall,
9143
+ cause: err
9144
+ });
9145
+ };
9146
+ //#endregion
9147
+ //#region ../../node_modules/@effect/platform-node-shared/dist/NodeSink.js
9148
+ /**
9149
+ * Creates a `Sink` that writes chunks to a Node writable stream, respecting
9150
+ * backpressure, mapping writable errors with `onError`, and ending the stream
9151
+ * on completion unless `endOnDone` is `false`.
9152
+ *
9153
+ * @category constructors
9154
+ * @since 4.0.0
9155
+ */
9156
+ var fromWritable = (options) => fromChannel(mapDone(fromWritableChannel(options), (_) => [_]));
9157
+ /**
9158
+ * Creates a `Channel` that pulls chunks from upstream and writes them to a
9159
+ * Node writable stream, respecting backpressure and optionally ending the
9160
+ * writable when upstream is done.
9161
+ *
9162
+ * @category constructors
9163
+ * @since 4.0.0
9164
+ */
9165
+ var fromWritableChannel = (options) => fromTransform((pull) => {
9166
+ const writable = options.evaluate();
9167
+ return succeed(pullIntoWritable({
9168
+ ...options,
9169
+ writable,
9170
+ pull
9171
+ }));
9172
+ });
9173
+ /**
9174
+ * Writes Effect chunks into a Node writable stream.
9175
+ *
9176
+ * **When to use**
9177
+ *
9178
+ * Use to implement custom Node stream adapters that already have an upstream
9179
+ * pull and need direct control over a writable stream.
9180
+ *
9181
+ * **Details**
9182
+ *
9183
+ * The loop waits for `drain` when needed, fails on writable errors, and ends
9184
+ * the writable on upstream completion unless `endOnDone` is `false`.
9185
+ *
9186
+ * @category converting
9187
+ * @since 4.0.0
9188
+ */
9189
+ var pullIntoWritable = (options) => options.pull.pipe(flatMap((chunk) => {
9190
+ let i = 0;
9191
+ return callback(function loop(resume) {
9192
+ for (; i < chunk.length;) if (!options.writable.write(chunk[i++], options.encoding)) {
9193
+ options.writable.once("drain", () => loop(resume));
9194
+ return;
9195
+ }
9196
+ resume(void_);
9197
+ });
9198
+ }), forever({ disableYield: true }), raceFirst(callback((resume) => {
9199
+ const onError = (error) => resume(fail(options.onError(error)));
9200
+ options.writable.once("error", onError);
9201
+ return sync(() => {
9202
+ options.writable.off("error", onError);
9203
+ });
9204
+ })), options.endOnDone !== false ? catchDone((_) => {
9205
+ if ("closed" in options.writable && options.writable.closed) return done(_);
9206
+ return callback((resume) => {
9207
+ options.writable.once("finish", () => resume(done(_)));
9208
+ options.writable.end();
9209
+ });
9210
+ }) : identity);
9211
+ //#endregion
9212
+ //#region ../../node_modules/@effect/platform-node-shared/dist/NodeStream.js
9213
+ /**
9214
+ * Adapters between Node streams and Effect streams, channels, and readables.
9215
+ *
9216
+ * This module is the stream boundary for Node APIs. It wraps `Readable` and
9217
+ * `Duplex` values as Effect `Stream`s and `Channel`s, pipes Effect streams
9218
+ * through Node duplex streams, exposes an Effect `Stream` back to Node as a
9219
+ * `Readable`, and collects readable payloads into strings, array buffers, or
9220
+ * `Uint8Array`s with optional byte limits.
9221
+ *
9222
+ * @since 4.0.0
9223
+ */
9224
+ /**
9225
+ * Converts a Node readable stream into an Effect `Stream`, reading chunks with
9226
+ * an optional chunk size, mapping stream errors with `onError`, and destroying
9227
+ * the readable on completion unless `closeOnDone` is `false`.
9228
+ *
9229
+ * @category constructors
9230
+ * @since 4.0.0
9231
+ */
9232
+ var fromReadable = (options) => fromChannel$1(fromReadableChannel(options));
9233
+ /**
9234
+ * Creates a `Channel` that pulls chunks from a Node readable stream, mapping
9235
+ * errors with `onError` and destroying the readable on completion unless
9236
+ * `closeOnDone` is `false`.
9237
+ *
9238
+ * @category constructors
9239
+ * @since 4.0.0
9240
+ */
9241
+ var fromReadableChannel = (options) => fromTransform((_, scope) => readableToPullUnsafe({
9242
+ scope,
9243
+ readable: options.evaluate(),
9244
+ onError: options.onError ?? defaultOnError,
9245
+ chunkSize: options.chunkSize,
9246
+ closeOnDone: options.closeOnDone
9247
+ }));
9248
+ var readableToPullUnsafe = (options) => {
9249
+ const readable = options.readable;
9250
+ const closeOnDone = options.closeOnDone ?? true;
9251
+ const exit = options.exit ?? make$7(void 0);
9252
+ const latch = makeUnsafe(false);
9253
+ function onReadable() {
9254
+ latch.openUnsafe();
9255
+ }
9256
+ function onError(error) {
9257
+ exit.current = fail$2(options.onError(error));
9258
+ latch.openUnsafe();
9259
+ }
9260
+ function onEnd() {
9261
+ exit.current = fail$2(Done());
9262
+ latch.openUnsafe();
9263
+ }
9264
+ readable.on("readable", onReadable);
9265
+ readable.once("error", onError);
9266
+ readable.once("end", onEnd);
9267
+ const pull = suspend(function loop() {
9268
+ let item = options.readable.read(options.chunkSize);
9269
+ if (item === null) {
9270
+ if (exit.current) return exit.current;
9271
+ if (readable.readableEnded) return fail(Done());
9272
+ latch.closeUnsafe();
9273
+ return flatMap(latch.await, loop);
9274
+ }
9275
+ const chunk = of(item);
9276
+ while (true) {
9277
+ item = options.readable.read(options.chunkSize);
9278
+ if (item === null) break;
9279
+ chunk.push(item);
9280
+ }
9281
+ return succeed(chunk);
9282
+ });
9283
+ return as(addFinalizer(options.scope, sync(() => {
9284
+ readable.off("readable", onReadable);
9285
+ readable.off("error", onError);
9286
+ readable.off("end", onEnd);
9287
+ if (closeOnDone && "closed" in options.readable && !options.readable.closed) options.readable.destroy();
9288
+ })), pull);
9289
+ };
9290
+ var defaultOnError = (error) => new UnknownError(error);
9291
+ //#endregion
9292
+ //#region ../../node_modules/@effect/platform-node-shared/dist/NodeChildProcessSpawner.js
9293
+ var toError = (error) => error instanceof globalThis.Error ? error : new globalThis.Error(String(error));
9294
+ var toPlatformError = (method, error, command) => {
9295
+ const { commands } = flattenCommand(command);
9296
+ const commandStr = commands.reduce((acc, curr) => {
9297
+ const cmd = `${curr.command} ${curr.args.join(" ")}`;
9298
+ return acc.length === 0 ? cmd : `${acc} | ${cmd}`;
9299
+ }, "");
9300
+ return handleErrnoException("ChildProcess", method)(error, [commandStr]);
9301
+ };
9302
+ /**
9303
+ * Layer that provides the `NodeChildProcessSpawner` implementation.
9304
+ *
9305
+ * @category layers
9306
+ * @since 4.0.0
9307
+ */
9308
+ var layer$11 = /*#__PURE__*/ effect(ChildProcessSpawner, /* @__PURE__ */ gen(function* () {
9309
+ const fs = yield* FileSystem;
9310
+ const path = yield* Path$1;
9311
+ const resolveWorkingDirectory = fnUntraced(function* (options) {
9312
+ if (isUndefined(options.cwd)) return void 0;
9313
+ yield* fs.access(options.cwd);
9314
+ return path.resolve(options.cwd);
9315
+ });
9316
+ const resolveEnvironment = (options) => {
9317
+ return options.extendEnv ? {
9318
+ ...globalThis.process.env,
9319
+ ...options.env
9320
+ } : options.env;
9321
+ };
9322
+ const inputToStdioOption = (input) => isStream(input) ? "pipe" : input;
9323
+ const outputToStdioOption = (input) => isSink(input) ? "pipe" : input;
9324
+ const resolveStdinOption = (options) => {
9325
+ const defaultConfig = {
9326
+ stream: "pipe",
9327
+ encoding: "utf-8",
9328
+ endOnDone: true
9329
+ };
9330
+ if (isUndefined(options.stdin)) return defaultConfig;
9331
+ if (typeof options.stdin === "string") return {
9332
+ ...defaultConfig,
9333
+ stream: options.stdin
9334
+ };
9335
+ if (isStream(options.stdin)) return {
9336
+ ...defaultConfig,
9337
+ stream: options.stdin
9338
+ };
9339
+ return {
9340
+ stream: options.stdin.stream,
9341
+ encoding: options.stdin.encoding ?? defaultConfig.encoding,
9342
+ endOnDone: options.stdin.endOnDone ?? defaultConfig.endOnDone
9343
+ };
9344
+ };
9345
+ const resolveOutputOption = (options, streamName) => {
9346
+ const option = options[streamName];
9347
+ if (isUndefined(option)) return { stream: "pipe" };
9348
+ if (typeof option === "string") return { stream: option };
9349
+ if (isSink(option)) return { stream: option };
9350
+ return { stream: option.stream };
9351
+ };
9352
+ const resolveAdditionalFds = (options) => {
9353
+ if (isUndefined(options.additionalFds)) return [];
9354
+ const result = [];
9355
+ for (const [name, config] of Object.entries(options.additionalFds)) {
9356
+ const fd = parseFdName(name);
9357
+ if (isNotUndefined(fd)) result.push({
9358
+ fd,
9359
+ config
9360
+ });
9361
+ }
9362
+ return result.sort((a, b) => a.fd - b.fd);
9363
+ };
9364
+ const buildStdioArray = (stdinConfig, stdoutConfig, stderrConfig, additionalFds) => {
9365
+ const stdio = [
9366
+ inputToStdioOption(stdinConfig.stream),
9367
+ outputToStdioOption(stdoutConfig.stream),
9368
+ outputToStdioOption(stderrConfig.stream)
9369
+ ];
9370
+ if (additionalFds.length === 0) return stdio;
9371
+ const maxFd = additionalFds.reduce((max, { fd }) => Math.max(max, fd), 2);
9372
+ for (let i = 3; i <= maxFd; i++) stdio[i] = "ignore";
9373
+ for (const { fd } of additionalFds) stdio[fd] = "pipe";
9374
+ return stdio;
9375
+ };
9376
+ const setupAdditionalFds = fnUntraced(function* (command, childProcess, additionalFds) {
9377
+ if (additionalFds.length === 0) return {
9378
+ getInputFd: () => drain,
9379
+ getOutputFd: () => empty$1
9380
+ };
9381
+ const inputSinks = /* @__PURE__ */ new Map();
9382
+ const outputStreams = /* @__PURE__ */ new Map();
9383
+ for (const { config, fd } of additionalFds) {
9384
+ const nodeStream = childProcess.stdio[fd];
9385
+ switch (config.type) {
9386
+ case "input": {
9387
+ let sink = drain;
9388
+ if (nodeStream && "write" in nodeStream) sink = fromWritable({
9389
+ evaluate: () => nodeStream,
9390
+ onError: (error) => toPlatformError(`fromWritable(fd${fd})`, toError(error), command)
9391
+ });
9392
+ if (config.stream) yield* forkScoped(run$2(config.stream, sink));
9393
+ inputSinks.set(fd, sink);
9394
+ break;
9395
+ }
9396
+ case "output": {
9397
+ let stream = empty$1;
9398
+ if (nodeStream && "read" in nodeStream) {
9399
+ const passThrough = new PassThrough();
9400
+ nodeStream.on("error", (error) => passThrough.destroy(error));
9401
+ nodeStream.pipe(passThrough);
9402
+ stream = fromReadable({
9403
+ evaluate: () => passThrough,
9404
+ onError: (error) => toPlatformError(`fromReadable(fd${fd})`, toError(error), command)
9405
+ });
9406
+ }
9407
+ if (config.sink) stream = transduce(stream, config.sink);
9408
+ outputStreams.set(fd, stream);
9409
+ break;
9410
+ }
9411
+ }
9412
+ }
9413
+ return {
9414
+ getInputFd: (fd) => inputSinks.get(fd) ?? drain,
9415
+ getOutputFd: (fd) => outputStreams.get(fd) ?? empty$1
9416
+ };
9417
+ });
9418
+ const setupChildStdin = (command, childProcess, config) => suspend(() => {
9419
+ let sink = drain;
9420
+ if (isNotNull(childProcess.stdin)) sink = fromWritable({
9421
+ evaluate: () => childProcess.stdin,
9422
+ onError: (error) => toPlatformError("fromWritable(stdin)", toError(error), command),
9423
+ endOnDone: config.endOnDone,
9424
+ encoding: config.encoding
9425
+ });
9426
+ if (isStream(config.stream)) return as(forkScoped(run$2(config.stream, sink)), sink);
9427
+ return succeed(sink);
9428
+ });
9429
+ const setupChildOutputStreams = (command, childProcess, stdoutConfig, stderrConfig) => {
9430
+ let stdout = childProcess.stdout ? (() => {
9431
+ const passThrough = new PassThrough();
9432
+ childProcess.stdout.on("error", (error) => passThrough.destroy(error));
9433
+ childProcess.stdout.pipe(passThrough);
9434
+ return fromReadable({
9435
+ evaluate: () => passThrough,
9436
+ onError: (error) => toPlatformError("fromReadable(stdout)", toError(error), command)
9437
+ });
9438
+ })() : empty$1;
9439
+ let stderr = childProcess.stderr ? (() => {
9440
+ const passThrough = new PassThrough();
9441
+ childProcess.stderr.on("error", (error) => passThrough.destroy(error));
9442
+ childProcess.stderr.pipe(passThrough);
9443
+ return fromReadable({
9444
+ evaluate: () => passThrough,
9445
+ onError: (error) => toPlatformError("fromReadable(stderr)", toError(error), command)
9446
+ });
9447
+ })() : empty$1;
9448
+ if (isSink(stdoutConfig.stream)) stdout = transduce(stdout, stdoutConfig.stream);
9449
+ if (isSink(stderrConfig.stream)) stderr = transduce(stderr, stderrConfig.stream);
9450
+ const all = merge(stdout, stderr);
9451
+ return {
9452
+ stdout,
9453
+ stderr,
9454
+ all
9455
+ };
9456
+ };
9457
+ const spawn = (command, spawnOptions) => callback((resume) => {
9458
+ const deferred = makeUnsafe$1();
9459
+ const handle = NodeChildProcess.spawn(command.command, command.args, spawnOptions);
9460
+ handle.on("error", (error) => {
9461
+ resume(fail(toPlatformError("spawn", error, command)));
9462
+ });
9463
+ handle.on("exit", (...args) => {
9464
+ doneUnsafe(deferred, succeed$2(args));
9465
+ });
9466
+ handle.on("spawn", () => {
9467
+ resume(succeed([handle, deferred]));
9468
+ });
9469
+ return sync(() => {
9470
+ handle.kill("SIGTERM");
9471
+ });
9472
+ });
9473
+ const killProcessGroup = (command, childProcess, signal) => {
9474
+ if (globalThis.process.platform === "win32") return callback((resume) => {
9475
+ NodeChildProcess.exec(`taskkill /pid ${childProcess.pid} /T /F`, (error) => {
9476
+ if (error) resume(fail(toPlatformError("kill", toError(error), command)));
9477
+ else resume(void_);
9478
+ });
9479
+ });
9480
+ return try_({
9481
+ try: () => {
9482
+ globalThis.process.kill(-childProcess.pid, signal);
9483
+ },
9484
+ catch: (error) => toPlatformError("kill", toError(error), command)
9485
+ });
9486
+ };
9487
+ const killProcessGroupOnExit = (childProcess, signal) => {
9488
+ if (globalThis.process.platform === "win32") {
9489
+ NodeChildProcess.exec(`taskkill /pid ${childProcess.pid} /T /F`, () => {});
9490
+ return;
9491
+ }
9492
+ try {
9493
+ globalThis.process.kill(-childProcess.pid, signal);
9494
+ } catch {}
9495
+ };
9496
+ const killProcess = (command, childProcess, signal) => suspend(() => {
9497
+ if (!childProcess.kill(signal)) return fail(toPlatformError("kill", new globalThis.Error("Failed to kill child process"), command));
9498
+ return void_;
9499
+ });
9500
+ const withTimeout = (childProcess, command, options) => (kill) => {
9501
+ const killSignal = options?.killSignal ?? "SIGTERM";
9502
+ return isUndefined(options?.forceKillAfter) ? kill(command, childProcess, killSignal) : timeoutOrElse(kill(command, childProcess, killSignal), {
9503
+ duration: options.forceKillAfter,
9504
+ orElse: () => kill(command, childProcess, "SIGKILL")
9505
+ });
9506
+ };
9507
+ /**
9508
+ * Get the appropriate source stream from a process handle based on the
9509
+ * `from` pipe option.
9510
+ */
9511
+ const getSourceStream = (handle, from) => {
9512
+ const fromOption = from ?? "stdout";
9513
+ switch (fromOption) {
9514
+ case "stdout": return handle.stdout;
9515
+ case "stderr": return handle.stderr;
9516
+ case "all": return handle.all;
9517
+ default: {
9518
+ const fd = parseFdName(fromOption);
9519
+ if (isNotUndefined(fd)) return handle.getOutputFd(fd);
9520
+ return handle.stdout;
9521
+ }
9522
+ }
9523
+ };
9524
+ const spawnCommand = fnUntraced(function* (cmd) {
9525
+ switch (cmd._tag) {
9526
+ case "StandardCommand": {
9527
+ const stdinConfig = resolveStdinOption(cmd.options);
9528
+ const stdoutConfig = resolveOutputOption(cmd.options, "stdout");
9529
+ const stderrConfig = resolveOutputOption(cmd.options, "stderr");
9530
+ const resolvedAdditionalFds = resolveAdditionalFds(cmd.options);
9531
+ let isReferenced = true;
9532
+ const cwd = yield* resolveWorkingDirectory(cmd.options);
9533
+ const env = resolveEnvironment(cmd.options);
9534
+ const stdio = buildStdioArray(stdinConfig, stdoutConfig, stderrConfig, resolvedAdditionalFds);
9535
+ const [childProcess, exitSignal] = yield* acquireRelease(spawn(cmd, {
9536
+ cwd,
9537
+ env,
9538
+ stdio,
9539
+ detached: cmd.options.detached ?? process.platform !== "win32",
9540
+ shell: cmd.options.shell
9541
+ }), fnUntraced(function* ([childProcess, exitSignal]) {
9542
+ const exited = yield* isDone(exitSignal);
9543
+ const killWithTimeout = withTimeout(childProcess, cmd, cmd.options);
9544
+ if (exited) {
9545
+ const [code] = yield* _await(exitSignal);
9546
+ if (code !== 0 && isNotNull(code)) return yield* ignore(killWithTimeout(killProcessGroup));
9547
+ return yield* void_;
9548
+ }
9549
+ if (!isReferenced) return yield* void_;
9550
+ return yield* killWithTimeout((command, childProcess, signal) => catch_(killProcessGroup(command, childProcess, signal), () => killProcess(command, childProcess, signal))).pipe(andThen(_await(exitSignal)), ignore);
9551
+ }));
9552
+ const pid = ProcessId(childProcess.pid);
9553
+ childProcess.on("exit", (code) => {
9554
+ if (code !== 0 && isNotNull(code)) killProcessGroupOnExit(childProcess, cmd.options.killSignal ?? "SIGTERM");
9555
+ });
9556
+ const reref = sync(() => {
9557
+ if (!isReferenced) {
9558
+ childProcess.ref();
9559
+ isReferenced = true;
9560
+ }
9561
+ });
9562
+ const unref = sync(() => {
9563
+ if (isReferenced) {
9564
+ childProcess.unref();
9565
+ isReferenced = false;
9566
+ }
9567
+ return reref;
9568
+ });
9569
+ const stdin = yield* setupChildStdin(cmd, childProcess, stdinConfig);
9570
+ const { all, stderr, stdout } = setupChildOutputStreams(cmd, childProcess, stdoutConfig, stderrConfig);
9571
+ const { getInputFd, getOutputFd } = yield* setupAdditionalFds(cmd, childProcess, resolvedAdditionalFds);
9572
+ const isRunning = map$2(isDone(exitSignal), (done) => !done);
9573
+ const exitCode = flatMap(_await(exitSignal), ([code, signal]) => {
9574
+ if (isNotNull(code)) return succeed(ExitCode(code));
9575
+ return fail(toPlatformError("exitCode", new globalThis.Error(`Process interrupted due to receipt of signal: '${signal}'`), cmd));
9576
+ });
9577
+ const kill = (options) => {
9578
+ return withTimeout(childProcess, cmd, options)((command, childProcess, signal) => catch_(killProcessGroup(command, childProcess, signal), () => killProcess(command, childProcess, signal))).pipe(andThen(_await(exitSignal)), asVoid);
9579
+ };
9580
+ return makeHandle({
9581
+ pid,
9582
+ exitCode,
9583
+ isRunning,
9584
+ kill,
9585
+ stdin,
9586
+ stdout,
9587
+ stderr,
9588
+ all,
9589
+ getInputFd,
9590
+ getOutputFd,
9591
+ unref
9592
+ });
9593
+ }
9594
+ case "PipedCommand": {
9595
+ const { commands, pipeOptions } = flattenCommand(cmd);
9596
+ const [root, ...pipeline] = commands;
9597
+ const handles = [yield* spawnCommand(root)];
9598
+ for (let i = 0; i < pipeline.length; i++) {
9599
+ const command = pipeline[i];
9600
+ const options = pipeOptions[i] ?? {};
9601
+ const stdinConfig = resolveStdinOption(command.options);
9602
+ const sourceStream = unwrap(succeed(getSourceStream(handles[handles.length - 1], options.from)));
9603
+ const toOption = options.to ?? "stdin";
9604
+ if (toOption === "stdin") handles.push(yield* spawnCommand(make$3(command.command, command.args, {
9605
+ ...command.options,
9606
+ stdin: {
9607
+ ...stdinConfig,
9608
+ stream: sourceStream
9609
+ }
9610
+ })));
9611
+ else {
9612
+ const fd = parseFdName(toOption);
9613
+ if (isNotUndefined(fd)) {
9614
+ const fdName$1 = fdName(fd);
9615
+ const existingFds = command.options.additionalFds ?? {};
9616
+ handles.push(yield* spawnCommand(make$3(command.command, command.args, {
9617
+ ...command.options,
9618
+ additionalFds: {
9619
+ ...existingFds,
9620
+ [fdName$1]: {
9621
+ type: "input",
9622
+ stream: sourceStream
9623
+ }
9624
+ }
9625
+ })));
9626
+ } else handles.push(yield* spawnCommand(make$3(command.command, command.args, {
9627
+ ...command.options,
9628
+ stdin: {
9629
+ ...stdinConfig,
9630
+ stream: sourceStream
9631
+ }
9632
+ })));
9633
+ }
9634
+ }
9635
+ const handle = handles[handles.length - 1];
9636
+ const unref = gen(function* () {
9637
+ const rerefs = [];
9638
+ for (const handle of handles) rerefs.push(yield* handle.unref);
9639
+ return forEach([...rerefs].reverse(), (reref) => reref, { discard: true });
9640
+ });
9641
+ return makeHandle({
9642
+ pid: handle.pid,
9643
+ exitCode: handle.exitCode,
9644
+ isRunning: handle.isRunning,
9645
+ kill: handle.kill,
9646
+ stdin: handle.stdin,
9647
+ stdout: handle.stdout,
9648
+ stderr: handle.stderr,
9649
+ all: handle.all,
9650
+ getInputFd: handle.getInputFd,
9651
+ getOutputFd: handle.getOutputFd,
9652
+ unref
9653
+ });
9654
+ }
9655
+ }
9656
+ });
9657
+ return make$4(spawnCommand);
9658
+ }));
9659
+ /**
9660
+ * Flattens a `Command` into an array of `StandardCommand`s along with pipe
9661
+ * options for each connection.
9662
+ *
9663
+ * @category transforming
9664
+ * @since 4.0.0
9665
+ */
9666
+ var flattenCommand = (command) => {
9667
+ const commands = [];
9668
+ const pipeOptions = [];
9669
+ const flatten = (cmd) => {
9670
+ switch (cmd._tag) {
9671
+ case "StandardCommand":
9672
+ commands.push(cmd);
9673
+ break;
9674
+ case "PipedCommand":
9675
+ flatten(cmd.left);
9676
+ pipeOptions.push(cmd.options);
9677
+ flatten(cmd.right);
9678
+ break;
9679
+ }
9680
+ };
9681
+ flatten(command);
9682
+ if (commands.length === 0) throw new Error("flattenCommand produced empty commands array");
9683
+ const [first, ...rest] = commands;
9684
+ return {
9685
+ commands: [first, ...rest],
9686
+ pipeOptions
9687
+ };
9688
+ };
9689
+ //#endregion
9690
+ //#region ../../node_modules/@effect/platform-node-shared/dist/NodeFileSystem.js
9691
+ /**
9692
+ * Shared Node-compatible implementation of Effect's `FileSystem` service.
9693
+ *
9694
+ * This module adapts Node's `node:fs`, `node:os`, and `node:path` APIs into a
9695
+ * `FileSystem` layer for Effect programs running on Node-compatible runtimes.
9696
+ * Platform packages use it to provide file and directory I/O, permissions,
9697
+ * links, metadata, temporary files and directories, and file watching through
9698
+ * the shared `FileSystem` service.
9699
+ *
9700
+ * @since 4.0.0
9701
+ */
9702
+ var handleBadArgument = (method) => (err) => badArgument({
9703
+ module: "FileSystem",
9704
+ method,
9705
+ description: err.message ?? String(err)
9706
+ });
9707
+ var access = /*#__PURE__*/ (() => {
9708
+ const nodeAccess = /*#__PURE__*/ effectify(NFS.access, /*#__PURE__*/ handleErrnoException("FileSystem", "access"), /*#__PURE__*/ handleBadArgument("access"));
9709
+ return (path, options) => {
9710
+ let mode = NFS.constants.F_OK;
9711
+ if (options?.readable) mode |= NFS.constants.R_OK;
9712
+ if (options?.writable) mode |= NFS.constants.W_OK;
9713
+ return nodeAccess(path, mode);
9714
+ };
9715
+ })();
9716
+ var copy = /*#__PURE__*/ (() => {
9717
+ const nodeCp = /*#__PURE__*/ effectify(NFS.cp, /*#__PURE__*/ handleErrnoException("FileSystem", "copy"), /*#__PURE__*/ handleBadArgument("copy"));
9718
+ return (fromPath, toPath, options) => nodeCp(fromPath, toPath, {
9719
+ force: options?.overwrite ?? false,
9720
+ preserveTimestamps: options?.preserveTimestamps ?? false,
9721
+ recursive: true
9722
+ });
9723
+ })();
9724
+ var copyFile = /*#__PURE__*/ (() => {
9725
+ const nodeCopyFile = /*#__PURE__*/ effectify(NFS.copyFile, /*#__PURE__*/ handleErrnoException("FileSystem", "copyFile"), /*#__PURE__*/ handleBadArgument("copyFile"));
9726
+ return (fromPath, toPath) => nodeCopyFile(fromPath, toPath);
9727
+ })();
9728
+ var chmod = /*#__PURE__*/ (() => {
9729
+ const nodeChmod = /*#__PURE__*/ effectify(NFS.chmod, /*#__PURE__*/ handleErrnoException("FileSystem", "chmod"), /*#__PURE__*/ handleBadArgument("chmod"));
9730
+ return (path, mode) => nodeChmod(path, mode);
9731
+ })();
9732
+ var chown = /*#__PURE__*/ (() => {
9733
+ const nodeChown = /*#__PURE__*/ effectify(NFS.chown, /*#__PURE__*/ handleErrnoException("FileSystem", "chown"), /*#__PURE__*/ handleBadArgument("chown"));
9734
+ return (path, uid, gid) => nodeChown(path, uid, gid);
9735
+ })();
9736
+ var glob = /*#__PURE__*/ (() => {
9737
+ const nodeGlob = /*#__PURE__*/ effectify(NFS.glob, /*#__PURE__*/ handleErrnoException("FileSystem", "glob"), /*#__PURE__*/ handleBadArgument("glob"));
9738
+ return (pattern, options) => nodeGlob(pattern, {
9739
+ cwd: options?.root,
9740
+ exclude: options?.exclude
9741
+ });
9742
+ })();
9743
+ var link = /*#__PURE__*/ (() => {
9744
+ const nodeLink = /*#__PURE__*/ effectify(NFS.link, /*#__PURE__*/ handleErrnoException("FileSystem", "link"), /*#__PURE__*/ handleBadArgument("link"));
9745
+ return (existingPath, newPath) => nodeLink(existingPath, newPath);
9746
+ })();
9747
+ var makeDirectory = /*#__PURE__*/ (() => {
9748
+ const nodeMkdir = /*#__PURE__*/ effectify(NFS.mkdir, /*#__PURE__*/ handleErrnoException("FileSystem", "makeDirectory"), /*#__PURE__*/ handleBadArgument("makeDirectory"));
9749
+ return (path, options) => nodeMkdir(path, {
9750
+ recursive: options?.recursive ?? false,
9751
+ mode: options?.mode
9752
+ });
9753
+ })();
9754
+ var makeTempDirectoryFactory = (method) => {
9755
+ const nodeMkdtemp = effectify(NFS.mkdtemp, handleErrnoException("FileSystem", method), handleBadArgument(method));
9756
+ return (options) => suspend(() => {
9757
+ const prefix = options?.prefix ?? "";
9758
+ const directory = typeof options?.directory === "string" ? Path.join(options.directory, ".") : OS.tmpdir();
9759
+ return nodeMkdtemp(prefix ? Path.join(directory, prefix) : directory + "/");
9760
+ });
9761
+ };
9762
+ var makeTempDirectory = /*#__PURE__*/ makeTempDirectoryFactory("makeTempDirectory");
9763
+ var removeFactory = (method) => {
9764
+ const nodeRm = effectify(NFS.rm, handleErrnoException("FileSystem", method), handleBadArgument(method));
9765
+ return (path, options) => nodeRm(path, {
9766
+ recursive: options?.recursive ?? false,
9767
+ force: options?.force ?? false
9768
+ });
9769
+ };
9770
+ var remove$1 = /*#__PURE__*/ removeFactory("remove");
9771
+ var makeTempDirectoryScoped = /*#__PURE__*/ (() => {
9772
+ const makeDirectory = /*#__PURE__*/ makeTempDirectoryFactory("makeTempDirectoryScoped");
9773
+ const removeDirectory = /*#__PURE__*/ removeFactory("makeTempDirectoryScoped");
9774
+ return (options) => acquireRelease(makeDirectory(options), (directory) => orDie(removeDirectory(directory, { recursive: true })));
9775
+ })();
9776
+ var openFactory = (method) => {
9777
+ const nodeOpen = effectify(NFS.open, handleErrnoException("FileSystem", method), handleBadArgument(method));
9778
+ const nodeClose = effectify(NFS.close, handleErrnoException("FileSystem", method), handleBadArgument(method));
9779
+ return (path, options) => pipe(acquireRelease(nodeOpen(path, options?.flag ?? "r", options?.mode), (fd) => orDie(nodeClose(fd))), map$2((fd) => makeFile(FileDescriptor(fd), options?.flag?.startsWith("a") ?? false)));
9780
+ };
9781
+ var open = /*#__PURE__*/ openFactory("open");
9782
+ var makeFile = /*#__PURE__*/ (() => {
9783
+ const nodeReadFactory = (method) => effectify(NFS.read, handleErrnoException("FileSystem", method), handleBadArgument(method));
9784
+ const nodeRead = /*#__PURE__*/ nodeReadFactory("read");
9785
+ const nodeReadAlloc = /*#__PURE__*/ nodeReadFactory("readAlloc");
9786
+ const nodeStat = /*#__PURE__*/ effectify(NFS.fstat, /*#__PURE__*/ handleErrnoException("FileSystem", "stat"), /*#__PURE__*/ handleBadArgument("stat"));
9787
+ const nodeTruncate = /*#__PURE__*/ effectify(NFS.ftruncate, /*#__PURE__*/ handleErrnoException("FileSystem", "truncate"), /*#__PURE__*/ handleBadArgument("truncate"));
9788
+ const nodeSync = /*#__PURE__*/ effectify(NFS.fsync, /*#__PURE__*/ handleErrnoException("FileSystem", "sync"), /*#__PURE__*/ handleBadArgument("sync"));
9789
+ const nodeWriteFactory = (method) => effectify(NFS.write, handleErrnoException("FileSystem", method), handleBadArgument(method));
9790
+ const nodeWrite = /*#__PURE__*/ nodeWriteFactory("write");
9791
+ const nodeWriteAll = /*#__PURE__*/ nodeWriteFactory("writeAll");
9792
+ class FileImpl {
9793
+ [FileTypeId];
9794
+ fd;
9795
+ append;
9796
+ position = /*#__PURE__*/ BigInt(0);
9797
+ constructor(fd, append) {
9798
+ this[FileTypeId] = FileTypeId;
9799
+ this.fd = fd;
9800
+ this.append = append;
9801
+ }
9802
+ get stat() {
9803
+ return map$2(nodeStat(this.fd), makeFileInfo);
9804
+ }
9805
+ get sync() {
9806
+ return nodeSync(this.fd);
9807
+ }
9808
+ seek(offset, from) {
9809
+ const offsetSize = Size(offset);
9810
+ return sync(() => {
9811
+ if (from === "start") this.position = offsetSize;
9812
+ else if (from === "current") this.position = this.position + offsetSize;
9813
+ return this.position;
9814
+ });
9815
+ }
9816
+ read(buffer) {
9817
+ return suspend(() => {
9818
+ const position = this.position;
9819
+ return map$2(nodeRead(this.fd, {
9820
+ buffer,
9821
+ position
9822
+ }), (bytesRead) => {
9823
+ const sizeRead = Size(bytesRead);
9824
+ this.position = position + sizeRead;
9825
+ return sizeRead;
9826
+ });
9827
+ });
9828
+ }
9829
+ readAlloc(size) {
9830
+ const sizeNumber = Number(size);
9831
+ return suspend(() => {
9832
+ const buffer = Buffer.allocUnsafeSlow(sizeNumber);
9833
+ const position = this.position;
9834
+ return map$2(nodeReadAlloc(this.fd, {
9835
+ buffer,
9836
+ position
9837
+ }), (bytesRead) => {
9838
+ if (bytesRead === 0) return none();
9839
+ this.position = position + BigInt(bytesRead);
9840
+ if (bytesRead === sizeNumber) return some(buffer);
9841
+ const dst = Buffer.allocUnsafeSlow(bytesRead);
9842
+ buffer.copy(dst, 0, 0, bytesRead);
9843
+ return some(dst);
9844
+ });
9845
+ });
9846
+ }
9847
+ truncate(length) {
9848
+ return map$2(nodeTruncate(this.fd, length ? Number(length) : void 0), () => {
9849
+ if (!this.append) {
9850
+ const len = BigInt(length ?? 0);
9851
+ if (this.position > len) this.position = len;
9852
+ }
9853
+ });
9854
+ }
9855
+ write(buffer) {
9856
+ return suspend(() => {
9857
+ const position = this.position;
9858
+ return map$2(nodeWrite(this.fd, buffer, void 0, void 0, this.append ? void 0 : Number(position)), (bytesWritten) => {
9859
+ const sizeWritten = Size(bytesWritten);
9860
+ if (!this.append) this.position = position + sizeWritten;
9861
+ return sizeWritten;
9862
+ });
9863
+ });
9864
+ }
9865
+ writeAllChunk(buffer) {
9866
+ return suspend(() => {
9867
+ const position = this.position;
9868
+ return flatMap(nodeWriteAll(this.fd, buffer, void 0, void 0, this.append ? void 0 : Number(position)), (bytesWritten) => {
9869
+ if (bytesWritten === 0) return fail(systemError({
9870
+ module: "FileSystem",
9871
+ method: "writeAll",
9872
+ _tag: "WriteZero",
9873
+ pathOrDescriptor: this.fd,
9874
+ description: "write returned 0 bytes written"
9875
+ }));
9876
+ if (!this.append) this.position = position + BigInt(bytesWritten);
9877
+ return bytesWritten < buffer.length ? this.writeAllChunk(buffer.subarray(bytesWritten)) : void_;
9878
+ });
9879
+ });
9880
+ }
9881
+ writeAll(buffer) {
9882
+ return this.writeAllChunk(buffer);
9883
+ }
9884
+ }
9885
+ return (fd, append) => new FileImpl(fd, append);
9886
+ })();
9887
+ var makeTempFileFactory = (method) => {
9888
+ const makeDirectory = makeTempDirectoryFactory(method);
9889
+ return fnUntraced(function* (options) {
9890
+ const directory = yield* makeDirectory(options);
9891
+ const random = Crypto.randomBytes(6).toString("hex");
9892
+ const name = Path.join(directory, options?.suffix ? `${random}${options.suffix}` : random);
9893
+ yield* writeFile(name, /* @__PURE__ */ new Uint8Array(0));
9894
+ return name;
9895
+ });
9896
+ };
9897
+ var makeTempFile = /*#__PURE__*/ makeTempFileFactory("makeTempFile");
9898
+ var makeTempFileScoped = /*#__PURE__*/ (() => {
9899
+ const makeFile = /*#__PURE__*/ makeTempFileFactory("makeTempFileScoped");
9900
+ const removeDirectory = /*#__PURE__*/ removeFactory("makeTempFileScoped");
9901
+ return (options) => acquireRelease(makeFile(options), (file) => orDie(removeDirectory(Path.dirname(file), { recursive: true })));
9902
+ })();
9903
+ var readDirectory = (path, options) => tryPromise({
9904
+ try: () => NFS.promises.readdir(path, options),
9905
+ catch: (err) => handleErrnoException("FileSystem", "readDirectory")(err, [path])
9906
+ });
9907
+ var readFile = (path) => callback((resume, signal) => {
9908
+ try {
9909
+ NFS.readFile(path, { signal }, (err, data) => {
9910
+ if (err) resume(fail(handleErrnoException("FileSystem", "readFile")(err, [path])));
9911
+ else resume(succeed(data));
9912
+ });
9913
+ } catch (err) {
9914
+ resume(fail(handleBadArgument("readFile")(err)));
9915
+ }
9916
+ });
9917
+ var readLink = /*#__PURE__*/ (() => {
9918
+ const nodeReadLink = /*#__PURE__*/ effectify(NFS.readlink, /*#__PURE__*/ handleErrnoException("FileSystem", "readLink"), /*#__PURE__*/ handleBadArgument("readLink"));
9919
+ return (path) => nodeReadLink(path);
9920
+ })();
9921
+ var realPath = /*#__PURE__*/ (() => {
9922
+ const nodeRealPath = /*#__PURE__*/ effectify(NFS.realpath, /*#__PURE__*/ handleErrnoException("FileSystem", "realPath"), /*#__PURE__*/ handleBadArgument("realPath"));
9923
+ return (path) => nodeRealPath(path);
9924
+ })();
9925
+ var rename = /*#__PURE__*/ (() => {
9926
+ const nodeRename = /*#__PURE__*/ effectify(NFS.rename, /*#__PURE__*/ handleErrnoException("FileSystem", "rename"), /*#__PURE__*/ handleBadArgument("rename"));
9927
+ return (oldPath, newPath) => nodeRename(oldPath, newPath);
9928
+ })();
9929
+ var makeFileInfo = (stat) => ({
9930
+ type: stat.isFile() ? "File" : stat.isDirectory() ? "Directory" : stat.isSymbolicLink() ? "SymbolicLink" : stat.isBlockDevice() ? "BlockDevice" : stat.isCharacterDevice() ? "CharacterDevice" : stat.isFIFO() ? "FIFO" : stat.isSocket() ? "Socket" : "Unknown",
9931
+ mtime: fromNullishOr(stat.mtime),
9932
+ atime: fromNullishOr(stat.atime),
9933
+ birthtime: fromNullishOr(stat.birthtime),
9934
+ dev: stat.dev,
9935
+ rdev: fromNullishOr(stat.rdev),
9936
+ ino: fromNullishOr(stat.ino),
9937
+ mode: stat.mode,
9938
+ nlink: fromNullishOr(stat.nlink),
9939
+ uid: fromNullishOr(stat.uid),
9940
+ gid: fromNullishOr(stat.gid),
9941
+ size: Size(stat.size),
9942
+ blksize: stat.blksize !== void 0 ? some(Size(stat.blksize)) : none(),
9943
+ blocks: fromNullishOr(stat.blocks)
9944
+ });
9945
+ var stat = /*#__PURE__*/ (() => {
9946
+ const nodeStat = /*#__PURE__*/ effectify(NFS.stat, /*#__PURE__*/ handleErrnoException("FileSystem", "stat"), /*#__PURE__*/ handleBadArgument("stat"));
9947
+ return (path) => map$2(nodeStat(path), makeFileInfo);
9948
+ })();
9949
+ var symlink = /*#__PURE__*/ (() => {
9950
+ const nodeSymlink = /*#__PURE__*/ effectify(NFS.symlink, /*#__PURE__*/ handleErrnoException("FileSystem", "symlink"), /*#__PURE__*/ handleBadArgument("symlink"));
9951
+ return (target, path) => nodeSymlink(target, path);
9952
+ })();
9953
+ var truncate = /*#__PURE__*/ (() => {
9954
+ const nodeTruncate = /*#__PURE__*/ effectify(NFS.truncate, /*#__PURE__*/ handleErrnoException("FileSystem", "truncate"), /*#__PURE__*/ handleBadArgument("truncate"));
9955
+ return (path, length) => nodeTruncate(path, length !== void 0 ? Number(length) : void 0);
9956
+ })();
9957
+ var utimes = /*#__PURE__*/ (() => {
9958
+ const nodeUtimes = /*#__PURE__*/ effectify(NFS.utimes, /*#__PURE__*/ handleErrnoException("FileSystem", "utime"), /*#__PURE__*/ handleBadArgument("utime"));
9959
+ return (path, atime, mtime) => nodeUtimes(path, atime, mtime);
9960
+ })();
9961
+ var watchNode = (path) => callback$1((queue) => acquireRelease(sync(() => {
9962
+ const watcher = NFS.watch(path, { recursive: true }, (event, path) => {
9963
+ if (!path) return;
9964
+ switch (event) {
9965
+ case "rename":
9966
+ runFork(matchEffect(stat(path), {
9967
+ onSuccess: (_) => offer(queue, {
9968
+ _tag: "Create",
9969
+ path
9970
+ }),
9971
+ onFailure: (_) => offer(queue, {
9972
+ _tag: "Remove",
9973
+ path
9974
+ })
9975
+ }));
9976
+ return;
9977
+ case "change":
9978
+ offerUnsafe(queue, {
9979
+ _tag: "Update",
9980
+ path
9981
+ });
9982
+ return;
9983
+ }
9984
+ });
9985
+ watcher.on("error", (error) => {
9986
+ failCauseUnsafe(queue, fail$3(systemError({
9987
+ module: "FileSystem",
9988
+ _tag: "Unknown",
9989
+ method: "watch",
9990
+ pathOrDescriptor: path,
9991
+ cause: error
9992
+ })));
9993
+ });
9994
+ watcher.on("close", () => {
9995
+ endUnsafe(queue);
9996
+ });
9997
+ return watcher;
9998
+ }), (watcher) => sync(() => watcher.close())));
9999
+ var watch = (backend, path) => stat(path).pipe(map$2((stat) => backend.pipe(flatMap$1((_) => _.register(path, stat)), getOrElse(() => watchNode(path)))), unwrap);
10000
+ var writeFile = (path, data, options) => callback((resume, signal) => {
10001
+ try {
10002
+ NFS.writeFile(path, data, {
10003
+ signal,
10004
+ flag: options?.flag,
10005
+ mode: options?.mode
10006
+ }, (err) => {
10007
+ if (err) resume(fail(handleErrnoException("FileSystem", "writeFile")(err, [path])));
10008
+ else resume(void_);
10009
+ });
10010
+ } catch (err) {
10011
+ resume(fail(handleBadArgument("writeFile")(err)));
10012
+ }
10013
+ });
10014
+ var makeFileSystem = /*#__PURE__*/ map$2(/*#__PURE__*/ serviceOption(WatchBackend), (backend) => make$8({
10015
+ access,
10016
+ chmod,
10017
+ chown,
10018
+ copy,
10019
+ copyFile,
10020
+ glob,
10021
+ link,
10022
+ makeDirectory,
10023
+ makeTempDirectory,
10024
+ makeTempDirectoryScoped,
10025
+ makeTempFile,
10026
+ makeTempFileScoped,
10027
+ open,
10028
+ readDirectory,
10029
+ readFile,
10030
+ readLink,
10031
+ realPath,
10032
+ remove: remove$1,
10033
+ rename,
10034
+ stat,
10035
+ symlink,
10036
+ truncate,
10037
+ utimes,
10038
+ watch(path) {
10039
+ return watch(backend, path);
10040
+ },
10041
+ writeFile
10042
+ }));
10043
+ //#endregion
10044
+ //#region ../../node_modules/@effect/platform-node/dist/NodeFileSystem.js
10045
+ /**
10046
+ * Node.js `FileSystem` layer for programs that perform real filesystem I/O.
10047
+ *
10048
+ * The exported layer satisfies the platform-independent `FileSystem` service
10049
+ * with Node-backed operations for files, directories, metadata, permissions,
10050
+ * links, temporary paths, and path watching. Effects still call the service from
10051
+ * `effect/FileSystem`; this module only chooses the Node implementation.
10052
+ *
10053
+ * @since 4.0.0
10054
+ */
10055
+ /**
10056
+ * Provides the `FileSystem` service backed by Node filesystem APIs.
10057
+ *
10058
+ * @category layers
10059
+ * @since 4.0.0
10060
+ */
10061
+ var layer$9 = /* @__PURE__ */ effect(FileSystem)(makeFileSystem);
10062
+ //#endregion
10063
+ //#region ../../node_modules/@effect/platform-node-shared/dist/NodeCrypto.js
10064
+ /**
10065
+ * Node-compatible implementation of Effect's `Crypto` service.
10066
+ *
10067
+ * This module builds the service from `node:crypto`, using `randomBytes` for
10068
+ * random data and `createHash` for supported digest algorithms. It exports
10069
+ * `make` as the concrete service value and `layer` for providing it through
10070
+ * Effect context.
10071
+ *
10072
+ * @since 1.0.0
10073
+ */
10074
+ var toHashAlgorithm = (algorithm) => {
10075
+ switch (algorithm) {
10076
+ case "SHA-1": return "sha1";
10077
+ case "SHA-256": return "sha256";
10078
+ case "SHA-384": return "sha384";
10079
+ case "SHA-512": return "sha512";
10080
+ }
10081
+ };
10082
+ var digest = (algorithm, data) => try_({
10083
+ try: () => Uint8Array.from(Crypto.createHash(toHashAlgorithm(algorithm)).update(data).digest()),
10084
+ catch: (cause) => systemError({
10085
+ module: "Crypto",
10086
+ method: "digest",
10087
+ _tag: "Unknown",
10088
+ description: "Could not compute digest",
10089
+ cause
10090
+ })
10091
+ });
10092
+ //#endregion
10093
+ //#region ../../node_modules/@effect/platform-node/dist/NodeCrypto.js
10094
+ /**
10095
+ * The `NodeCrypto` module provides the Node.js `Crypto` service layer for
10096
+ * Effect programs. Provide {@link layer} at the edge of a Node application,
10097
+ * CLI, script, or test to satisfy `effect/Crypto` with Node's `node:crypto`
10098
+ * implementation for secure random bytes, UUID generation, random values, and
10099
+ * SHA digest operations.
10100
+ *
10101
+ * This module is the public Node adapter around the shared Node-compatible
10102
+ * implementation. Digest failures are reported as platform errors, and SHA-1
10103
+ * remains available only for interoperability with existing protocols.
10104
+ *
10105
+ * @since 1.0.0
10106
+ */
10107
+ /**
10108
+ * Layer that provides the Node.js Crypto service implementation.
10109
+ *
10110
+ * @category layers
10111
+ * @since 1.0.0
10112
+ */
10113
+ var layer$7 = /* @__PURE__ */ succeed$3(Crypto$1, /* @__PURE__ */ make$9({
10114
+ randomBytes: Crypto.randomBytes,
10115
+ digest
10116
+ }));
10117
+ //#endregion
10118
+ //#region ../../node_modules/@effect/platform-node-shared/dist/NodePath.js
10119
+ /**
10120
+ * Node-backed provider for Effect's `Path` service.
10121
+ *
10122
+ * This module turns Node's `node:path` and `node:url` APIs into `Path` layers.
10123
+ * `layer` uses the host platform path implementation, while `layerPosix` and
10124
+ * `layerWin32` provide fixed POSIX and Windows variants. All three layers also
10125
+ * include helpers for converting between file paths and file URLs.
10126
+ *
10127
+ * @since 4.0.0
10128
+ */
10129
+ var fromFileUrl = (url) => try_({
10130
+ try: () => NodeUrl.fileURLToPath(url),
10131
+ catch: (cause) => new BadArgument({
10132
+ module: "Path",
10133
+ method: "fromFileUrl",
10134
+ cause
10135
+ })
10136
+ });
10137
+ var toFileUrl = (path) => try_({
10138
+ try: () => NodeUrl.pathToFileURL(path),
10139
+ catch: (cause) => new BadArgument({
10140
+ module: "Path",
10141
+ method: "toFileUrl",
10142
+ cause
10143
+ })
10144
+ });
10145
+ ({ ...Path.posix });
10146
+ ({ ...Path.win32 });
10147
+ //#endregion
10148
+ //#region ../../node_modules/@effect/platform-node/dist/NodePath.js
10149
+ /**
10150
+ * Node.js layers for Effect's `Path` service.
10151
+ *
10152
+ * This module provides the default, POSIX, and Windows variants of the
10153
+ * platform-independent `Path` service by reusing the shared Node path
10154
+ * implementation. The provided path services include Node file URL conversion
10155
+ * behavior.
10156
+ *
10157
+ * @since 4.0.0
10158
+ */
10159
+ /**
10160
+ * Provides the default Node `Path` service using the platform's `node:path`
10161
+ * implementation.
10162
+ *
10163
+ * @category layers
10164
+ * @since 4.0.0
10165
+ */
10166
+ var layer$5 = /* @__PURE__ */ succeed$3(Path$1)({
10167
+ [TypeId$5]: TypeId$5,
10168
+ ...Path,
10169
+ fromFileUrl,
10170
+ toFileUrl
10171
+ });
10172
+ //#endregion
10173
+ //#region ../../node_modules/@effect/platform-node/dist/NodeStdio.js
10174
+ /**
10175
+ * Node.js `Stdio` layer for the current process.
10176
+ *
10177
+ * The exported layer reuses the shared Node stdio implementation. It satisfies
10178
+ * the platform-independent `Stdio` service by reading command-line arguments
10179
+ * from `process.argv`, consuming input from `process.stdin`, and writing output
10180
+ * streams to `process.stdout` and `process.stderr`.
10181
+ *
10182
+ * @since 4.0.0
10183
+ */
10184
+ /**
10185
+ * Provides the `Stdio` service backed by the current process arguments,
10186
+ * stdin, stdout, and stderr streams.
10187
+ *
10188
+ * @category layers
10189
+ * @since 4.0.0
10190
+ */
10191
+ var layer$3 = /* @__PURE__ */ succeed$3(Stdio, /*#__PURE__*/ make$10({
10192
+ args: /*#__PURE__*/ sync(() => process.argv.slice(2)),
10193
+ stdout: (options) => fromWritable({
10194
+ evaluate: () => process.stdout,
10195
+ onError: (cause) => systemError({
10196
+ module: "Stdio",
10197
+ method: "stdout",
10198
+ _tag: "Unknown",
10199
+ cause
10200
+ }),
10201
+ endOnDone: options?.endOnDone ?? false
10202
+ }),
10203
+ stderr: (options) => fromWritable({
10204
+ evaluate: () => process.stderr,
10205
+ onError: (cause) => systemError({
10206
+ module: "Stdio",
10207
+ method: "stderr",
10208
+ _tag: "Unknown",
10209
+ cause
10210
+ }),
10211
+ endOnDone: options?.endOnDone ?? false
10212
+ }),
10213
+ stdin: /*#__PURE__*/ fromReadable({
10214
+ evaluate: () => process.stdin,
10215
+ onError: (cause) => systemError({
10216
+ module: "Stdio",
10217
+ method: "stdin",
10218
+ _tag: "Unknown",
10219
+ cause
10220
+ }),
10221
+ closeOnDone: false
10222
+ })
10223
+ }));
10224
+ /**
10225
+ * Provides the default process-backed `Terminal` service, ending key input on
10226
+ * Ctrl+C or Ctrl+D.
10227
+ *
10228
+ * @category layers
10229
+ * @since 4.0.0
10230
+ */
10231
+ var layer$2 = /*#__PURE__*/ effect(Terminal, /*#__PURE__*/ (/* @__PURE__ */ fnUntraced(function* (shouldQuit = defaultShouldQuit) {
10232
+ const stdin = process.stdin;
10233
+ const stdout = process.stdout;
10234
+ const rlRef = yield* make$11({ acquire: acquireRelease(sync(() => {
10235
+ const rl = readline.createInterface({
10236
+ input: stdin,
10237
+ escapeCodeTimeout: 50
10238
+ });
10239
+ readline.emitKeypressEvents(stdin, rl);
10240
+ if (stdin.isTTY) stdin.setRawMode(true);
10241
+ return rl;
10242
+ }), (rl) => sync(() => {
10243
+ if (stdin.isTTY) stdin.setRawMode(false);
10244
+ rl.close();
10245
+ })) });
10246
+ const columns = sync(() => stdout.columns ?? 0);
10247
+ const rows = sync(() => stdout.rows ?? 0);
10248
+ const readInput = gen(function* () {
10249
+ yield* get(rlRef);
10250
+ const queue = yield* make$12();
10251
+ const handleKeypress = (s, k) => {
10252
+ const userInput = {
10253
+ input: fromUndefinedOr(s),
10254
+ key: {
10255
+ name: k.name ?? "",
10256
+ ctrl: !!k.ctrl,
10257
+ meta: !!k.meta,
10258
+ shift: !!k.shift
10259
+ }
10260
+ };
10261
+ offerUnsafe(queue, userInput);
10262
+ if (shouldQuit(userInput)) endUnsafe(queue);
10263
+ };
10264
+ yield* addFinalizer$1(() => sync(() => stdin.off("keypress", handleKeypress)));
10265
+ stdin.on("keypress", handleKeypress);
10266
+ return queue;
10267
+ });
10268
+ const readLine = scoped(flatMap(get(rlRef), (readlineInterface) => callback((resume) => {
10269
+ const onLine = (line) => resume(succeed(line));
10270
+ readlineInterface.once("line", onLine);
10271
+ return sync(() => readlineInterface.off("line", onLine));
10272
+ })));
10273
+ const display = (prompt) => uninterruptible(callback((resume) => {
10274
+ stdout.write(prompt, (err) => isNullish(err) ? resume(void_) : resume(fail(badArgument({
10275
+ module: "Terminal",
10276
+ method: "display",
10277
+ description: "Failed to write prompt to stdout",
10278
+ cause: err
10279
+ }))));
10280
+ }));
10281
+ return make$13({
10282
+ columns,
10283
+ rows,
10284
+ readInput,
10285
+ readLine,
10286
+ display
10287
+ });
10288
+ }))(defaultShouldQuit));
10289
+ function defaultShouldQuit(input) {
10290
+ return input.key.ctrl && (input.key.name === "c" || input.key.name === "d");
10291
+ }
10292
+ //#endregion
10293
+ //#region ../../node_modules/@effect/platform-node/dist/NodeServices.js
10294
+ /**
10295
+ * Provides the default Node implementations for child process spawning,
10296
+ * filesystem, path, stdio, and terminal services.
10297
+ *
10298
+ * @category layers
10299
+ * @since 4.0.0
10300
+ */
10301
+ var layer = /*#__PURE__*/ provideMerge(layer$11, /*#__PURE__*/ mergeAll(layer$9, layer$7, layer$5, layer$3, layer$2));
10302
+ //#endregion
8826
10303
  //#region ../../node_modules/@effect/platform-node/dist/NodeRuntime.js
8827
10304
  /**
8828
10305
  * Node.js process runner for Effect programs.
@@ -8995,7 +10472,7 @@ var tangleWatch = (file) => gen(function* () {
8995
10472
  yield* log(`loom: watching ${file} — re-tangling on change`);
8996
10473
  yield* runForEach(tangler.watch(resolve(process.cwd(), file)), match$3({
8997
10474
  onSuccess: reportWritten,
8998
- onFailure: (error$2) => error(error$2.message)
10475
+ onFailure: (error$1) => error(error$1.message)
8999
10476
  }));
9000
10477
  });
9001
10478
  var tangle = (file, watch) => watch ? tangleWatch(file) : tangleOnce(file);
@@ -9070,7 +10547,7 @@ var add = (language) => gen(function* () {
9070
10547
  yield* addService(language, dir);
9071
10548
  yield* updateLanguages(config, dir, (ids) => [.../* @__PURE__ */ new Set([...ids, language])]);
9072
10549
  yield* log(`\n ${teal("✓")} activated ${language}\n ${dim(`store: ${storeDir(dir)}`)}\n`);
9073
- }).pipe(catchTag("StoreError", (error$1) => error(`loom: could not install ${servicePackage(error$1.id)} — ${String(error$1.cause)}`).pipe(andThen(sync(() => void (process.exitCode = 1))))));
10550
+ }).pipe(catchTag("StoreError", (error$2) => error(`loom: could not install ${servicePackage(error$2.id)} — ${String(error$2.cause)}`).pipe(andThen(sync(() => void (process.exitCode = 1))))));
9074
10551
  var remove = (language) => gen(function* () {
9075
10552
  const config = yield* LoomConfig;
9076
10553
  const dir = process.cwd();
@@ -9115,71 +10592,49 @@ var set = (name, value) => gen(function* () {
9115
10592
  const corpus = resolve(workspace, current?.corpus ?? "corpus");
9116
10593
  yield* log(`loom: set ${name} = ${value} (re-tangled ${(yield* tangler.tangle(corpus)).length} files)`);
9117
10594
  }).pipe(catchTag("TangleError", (e) => error(e.message).pipe(andThen(sync(() => void (process.exitCode = 1))))));
9118
- var PORT_ONLY = /^[0-9]+$/;
9119
- var HAS_SCHEME = /^[a-z][a-z0-9+.-]*:\/\//i;
9120
- var addressOf = (given) => HAS_SCHEME.test(given) ? given : PORT_ONLY.test(given) ? `http://localhost:${given}` : `http://${given}`;
9121
- var within = (one, other) => one === other || one.startsWith(`${other}/`) || other.startsWith(`${one}/`);
9122
- var refusalOf = (standing, project, directory) => value(standing).pipe(tag$1("Taken", () => some(`loom: \`${project}\` is registered to another project, and its notes point elsewhere.\n This directory is ${directory}.\n Run Design here under a different name, or run it in the directory that owns \`${project}\`.`)), tag$1("Misplaced", () => some(`loom: \`${project}\` is registered, but ${directory} carries no identity for it.\n This is almost always the wrong directory. Run Design from the project it names.`)), orElse(() => none()));
9123
- var design = (project, given, port) => {
9124
- const application = addressOf(given);
9125
- return gen(function* () {
9126
- const directory = process.cwd();
9127
- yield* promise(async () => {
9128
- const { createRequire } = await import("node:module");
9129
- const scope = globalThis;
9130
- scope.require = scope.require ?? createRequire(import.meta.url);
9131
- });
9132
- const proxy = yield* tryPromise(() => import("./design-S_129JVC.js"));
9133
- const kept = yield* tryPromise(() => import("./store-CtvrwAS8.js"));
9134
- const projects = yield* tryPromise(() => import("./identity-DvFsrt2d.js"));
9135
- const store = kept.localStore();
9136
- yield* match$2(refusalOf(yield* projects.settle({
9137
- project,
9138
- directory,
9139
- address: application,
9140
- store
9141
- }), project, directory), {
9142
- onSome: (message) => error(message).pipe(andThen(sync(() => void (process.exitCode = 1)))),
9143
- onNone: () => gen(function* () {
9144
- yield* match$2(yield* projects.servedFrom(application), {
9145
- onNone: () => void_,
9146
- onSome: (from) => within(from, directory) ? void_ : error(`loom: warning — the server on ${application} is running in ${from}, not in ${directory}`)
9147
- });
9148
- yield* log(`loom: Design on http://localhost:${port}, in front of ${application}, noting ${project} in ${directory}`);
9149
- yield* launch(proxy.designServer({
9150
- port,
9151
- application,
9152
- project,
9153
- store
9154
- }));
9155
- })
9156
- });
9157
- }).pipe(catchCause((cause) => error(`loom: Design could not run in front of ${application}\n${pretty(cause)}`).pipe(andThen(sync(() => void (process.exitCode = 1))))));
9158
- };
9159
- var tangleCommand = make("tangle", {
10595
+ var DesignMissing = class extends TaggedError("DesignMissing") {};
10596
+ var manifestOf = (base) => try_(() => createRequire(base).resolve("@athrio/loom-design/package.json"));
10597
+ var designBinary = gen(function* () {
10598
+ const directory = process.cwd();
10599
+ return resolve(dirname(yield* manifestOf(resolve(directory, "index.js")).pipe(catch_(() => manifestOf(import.meta.url)), mapError(() => new DesignMissing({ directory })))), "dist", "loom-design.js");
10600
+ });
10601
+ var design = (project, application, port) => gen(function* () {
10602
+ const code = yield* scoped(flatMap(make$3(yield* designBinary, [
10603
+ project,
10604
+ application,
10605
+ "--port",
10606
+ String(port)
10607
+ ], {
10608
+ stdin: "inherit",
10609
+ stdout: "inherit",
10610
+ stderr: "inherit"
10611
+ }), (running) => running.exitCode));
10612
+ yield* sync(() => void (process.exitCode = code));
10613
+ }).pipe(catchTag("DesignMissing", () => error("loom: Loom Design is not installed.\n Add it with `bun add -d @athrio/loom-design`, then run this again.").pipe(andThen(sync(() => void (process.exitCode = 1))))), catchCause((cause) => error(`loom: Loom Design could not start\n${pretty(cause)}`).pipe(andThen(sync(() => void (process.exitCode = 1))))));
10614
+ var tangleCommand = make$5("tangle", {
9160
10615
  path: string("path"),
9161
10616
  watch: boolean("watch")
9162
10617
  }, ({ path, watch }) => tangle(path, watch));
9163
- var orphansCommand = make("orphans", { prune: boolean("prune") }, ({ prune }) => orphans(prune));
9164
- var weaveCommand = make("weave", {
10618
+ var orphansCommand = make$5("orphans", { prune: boolean("prune") }, ({ prune }) => orphans(prune));
10619
+ var weaveCommand = make$5("weave", {
9165
10620
  path: string("path"),
9166
10621
  out: string("out")
9167
10622
  }, ({ path, out }) => weave(path, out));
9168
- var tocCommand = make("toc", { path: string("path") }, ({ path }) => toc(path));
9169
- var initCommand = make("init", { dir: optional$1(directory("dir")) }, ({ dir }) => init(dir));
9170
- var addCommand = make("add", { language: string("language") }, ({ language }) => add(language));
9171
- var removeCommand = make("remove", { language: string("language") }, ({ language }) => remove(language));
9172
- var statusCommand = make("status", {}, () => status);
9173
- var setCommand = make("set", {
10623
+ var tocCommand = make$5("toc", { path: string("path") }, ({ path }) => toc(path));
10624
+ var initCommand = make$5("init", { dir: optional$1(directory("dir")) }, ({ dir }) => init(dir));
10625
+ var addCommand = make$5("add", { language: string("language") }, ({ language }) => add(language));
10626
+ var removeCommand = make$5("remove", { language: string("language") }, ({ language }) => remove(language));
10627
+ var statusCommand = make$5("status", {}, () => status);
10628
+ var setCommand = make$5("set", {
9174
10629
  name: string("name"),
9175
10630
  value: string("value")
9176
10631
  }, ({ name, value }) => set(name, value));
9177
- var designCommand = make("design", {
10632
+ var designCommand = make$5("design", {
9178
10633
  project: string("name"),
9179
10634
  application: string("address"),
9180
10635
  port: integer("port").pipe(withDefault(5710))
9181
10636
  }, ({ project, application, port }) => design(project, application, port));
9182
- var program = run(make("loom").pipe(withSubcommands([
10637
+ var program = run(make$5("loom").pipe(withSubcommands([
9183
10638
  tangleCommand,
9184
10639
  orphansCommand,
9185
10640
  weaveCommand,
@@ -9190,11 +10645,10 @@ var program = run(make("loom").pipe(withSubcommands([
9190
10645
  statusCommand,
9191
10646
  setCommand,
9192
10647
  designCommand
9193
- ])), { version: "0.0.10" }).pipe(provide$1(LoomTangler.layer), provide$1(LoomWeaver.layer), provide$1(LoomContents.layer), provide$1(DocumentSource.layer), provide$1(PackageConfig.layer), provide$1(LoomConfig.layer), provide$1(layer));
10648
+ ])), { version: "0.0.11" }).pipe(provide$1(LoomTangler.layer), provide$1(LoomWeaver.layer), provide$1(LoomContents.layer), provide$1(DocumentSource.layer), provide$1(PackageConfig.layer), provide$1(LoomConfig.layer), provide$1(layer));
9194
10649
  if (process.argv[2] === "lsp") {
9195
- const { createRequire } = await import("node:module");
9196
10650
  globalThis.require = createRequire(import.meta.url);
9197
- const { startLanguageServer } = await import("./LoomServer-JbCtLtxV.js");
10651
+ const { startLanguageServer } = await import("./LoomServer-mL8VcuCS.js");
9198
10652
  startLanguageServer();
9199
10653
  } else runMain(program);
9200
10654
  //#endregion