t3code-cli 0.14.0 → 0.14.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 (163) hide show
  1. package/README.md +1 -0
  2. package/dist/application.d.ts +2 -2
  3. package/dist/application.js +1 -1
  4. package/dist/auth.d.ts +1 -1
  5. package/dist/auth.js +1 -1
  6. package/dist/bin.js +551 -265
  7. package/dist/cli.d.ts +1 -1
  8. package/dist/cli.js +1 -1
  9. package/dist/client-runtime/authorization.d.ts +1 -1
  10. package/dist/client-runtime/authorization.js +1 -1
  11. package/dist/client-runtime/connection.d.ts +1 -1
  12. package/dist/client-runtime/connection.js +1 -1
  13. package/dist/client-runtime/environment.d.ts +5 -1
  14. package/dist/client-runtime/environment.js +1 -1
  15. package/dist/client-runtime/errors.js +1 -1
  16. package/dist/client-runtime/operations/projects.d.ts +2 -2
  17. package/dist/client-runtime/operations/projects.js +2 -2
  18. package/dist/client-runtime/operations.d.ts +2 -2
  19. package/dist/client-runtime/operations.js +2 -2
  20. package/dist/client-runtime/platform.d.ts +1 -1
  21. package/dist/client-runtime/platform.js +1 -1
  22. package/dist/client-runtime/relay.d.ts +5 -1
  23. package/dist/client-runtime/relay.js +1 -1
  24. package/dist/client-runtime/rpc.d.ts +2 -2
  25. package/dist/client-runtime/rpc.js +2 -2
  26. package/dist/client-runtime/state/assets.d.ts +17 -11
  27. package/dist/client-runtime/state/assets.js +1 -1
  28. package/dist/client-runtime/state/auth.d.ts +1 -1
  29. package/dist/client-runtime/state/auth.js +1 -1
  30. package/dist/client-runtime/state/connections.js +1 -1
  31. package/dist/client-runtime/state/entities.d.ts +1 -1
  32. package/dist/client-runtime/state/entities.js +1 -1
  33. package/dist/client-runtime/state/filesystem.d.ts +1 -1
  34. package/dist/client-runtime/state/filesystem.js +1 -1
  35. package/dist/client-runtime/state/git.d.ts +5 -5
  36. package/dist/client-runtime/state/git.js +1 -1
  37. package/dist/client-runtime/state/models.d.ts +1 -1
  38. package/dist/client-runtime/state/models.js +1 -1
  39. package/dist/client-runtime/state/orchestration.d.ts +42 -2
  40. package/dist/client-runtime/state/orchestration.js +13 -1
  41. package/dist/client-runtime/state/presentation.d.ts +9 -3
  42. package/dist/client-runtime/state/presentation.js +1 -1
  43. package/dist/client-runtime/state/preview.d.ts +55 -48
  44. package/dist/client-runtime/state/preview.js +1 -1
  45. package/dist/client-runtime/state/project-grouping.d.ts +26 -2
  46. package/dist/client-runtime/state/project-grouping.js +83 -3
  47. package/dist/client-runtime/state/projects.d.ts +24 -18
  48. package/dist/client-runtime/state/projects.js +1 -1
  49. package/dist/client-runtime/state/relay.d.ts +1 -1
  50. package/dist/client-runtime/state/relay.js +1 -1
  51. package/dist/client-runtime/state/review.d.ts +16 -1
  52. package/dist/client-runtime/state/review.js +27 -6
  53. package/dist/client-runtime/state/runtime.d.ts +2 -2
  54. package/dist/client-runtime/state/runtime.js +2 -2
  55. package/dist/client-runtime/state/server.d.ts +299 -172
  56. package/dist/client-runtime/state/server.js +192 -16
  57. package/dist/client-runtime/state/session.d.ts +65 -7
  58. package/dist/client-runtime/state/session.js +32 -3
  59. package/dist/client-runtime/state/shell.d.ts +41 -7
  60. package/dist/client-runtime/state/shell.js +1 -1
  61. package/dist/client-runtime/state/source-control.d.ts +2 -2
  62. package/dist/client-runtime/state/source-control.js +1 -1
  63. package/dist/client-runtime/state/subagentRuntime.d.ts +145 -0
  64. package/dist/client-runtime/state/subagentRuntime.js +521 -0
  65. package/dist/client-runtime/state/terminal.d.ts +17 -17
  66. package/dist/client-runtime/state/terminal.js +1 -1
  67. package/dist/client-runtime/state/thread-search.d.ts +23 -0
  68. package/dist/client-runtime/state/thread-search.js +38 -0
  69. package/dist/client-runtime/state/thread-settled.d.ts +28 -3
  70. package/dist/client-runtime/state/thread-settled.js +74 -2
  71. package/dist/client-runtime/state/thread-sort.d.ts +59 -2
  72. package/dist/client-runtime/state/thread-sort.js +128 -2
  73. package/dist/client-runtime/state/threads.d.ts +115 -3
  74. package/dist/client-runtime/state/threads.js +309 -28
  75. package/dist/client-runtime/state/vcs.d.ts +14 -14
  76. package/dist/client-runtime/state/vcs.js +1 -1
  77. package/dist/config.d.ts +1 -1
  78. package/dist/config.js +1 -1
  79. package/dist/connection.d.ts +1 -1
  80. package/dist/connection.js +1 -1
  81. package/dist/contracts.d.ts +1 -1
  82. package/dist/contracts.js +1 -1
  83. package/dist/index.d.ts +1 -1
  84. package/dist/index.js +1 -1
  85. package/dist/node.d.ts +1 -1
  86. package/dist/node.js +1 -1
  87. package/dist/orchestration.d.ts +144 -1
  88. package/dist/orchestration.js +1 -1
  89. package/dist/preview.d.ts +1 -1
  90. package/dist/preview.js +1 -1
  91. package/dist/rpc.d.ts +883 -351
  92. package/dist/rpc.js +1 -1
  93. package/dist/runtime.d.ts +1 -1
  94. package/dist/runtime.js +1 -1
  95. package/dist/shared/DrainableWorker.js +1 -1
  96. package/dist/shared/KeyedCoalescingWorker.js +1 -1
  97. package/dist/shared/Net.js +1 -1
  98. package/dist/shared/advertisedEndpoint.d.ts +1 -1
  99. package/dist/shared/advertisedEndpoint.js +1 -1
  100. package/dist/shared/agentAwareness.d.ts +1 -1
  101. package/dist/shared/backgroundActivitySettings.d.ts +1 -1
  102. package/dist/shared/composerInlineTokens.js +1 -1
  103. package/dist/shared/connectAuth.js +1 -1
  104. package/dist/shared/devHome.js +1 -1
  105. package/dist/shared/dpop.js +1 -1
  106. package/dist/shared/git.d.ts +1 -1
  107. package/dist/shared/httpObservability.js +1 -1
  108. package/dist/shared/httpReadiness.js +1 -1
  109. package/dist/shared/keybindings.d.ts +2 -2
  110. package/dist/shared/keybindings.js +15 -1
  111. package/dist/shared/model.d.ts +1 -1
  112. package/dist/shared/oauthScope.js +1 -1
  113. package/dist/shared/observability.d.ts +8 -1
  114. package/dist/shared/observability.js +49 -5
  115. package/dist/shared/path.js +1 -1
  116. package/dist/shared/preview.js +1 -1
  117. package/dist/shared/previewViewport.d.ts +1 -1
  118. package/dist/shared/previewViewport.js +1 -1
  119. package/dist/shared/projectFavicon.d.ts +2 -1
  120. package/dist/shared/projectFavicon.js +13 -1
  121. package/dist/shared/projectScripts.d.ts +1 -1
  122. package/dist/shared/relayAuth.js +1 -1
  123. package/dist/shared/relayClient.d.ts +1 -1
  124. package/dist/shared/relayClient.js +1 -1
  125. package/dist/shared/relayJwt.js +1 -1
  126. package/dist/shared/relayTracing.js +1 -1
  127. package/dist/shared/relayUrl.js +1 -1
  128. package/dist/shared/remote.js +1 -1
  129. package/dist/shared/schemaYaml.js +3 -3
  130. package/dist/shared/semver.js +1 -1
  131. package/dist/shared/serverSettings.d.ts +1 -1
  132. package/dist/shared/serverSettings.js +1 -1
  133. package/dist/shared/shell.d.ts +6 -1
  134. package/dist/shared/shell.js +42 -4
  135. package/dist/shared/sourceControl.d.ts +1 -1
  136. package/dist/shared/t3ProjectFile.d.ts +9 -1
  137. package/dist/shared/t3ProjectFile.js +12 -2
  138. package/dist/shared/terminalLabels.d.ts +1 -1
  139. package/dist/shared/threadEnvMode.d.ts +29 -0
  140. package/dist/shared/threadEnvMode.js +24 -0
  141. package/dist/shared/toolActivity.d.ts +1 -1
  142. package/dist/shared/usageFormat.d.ts +21 -0
  143. package/dist/shared/usageFormat.js +90 -0
  144. package/dist/shared/usageMerge.d.ts +67 -0
  145. package/dist/shared/usageMerge.js +218 -0
  146. package/dist/shared.d.ts +4472 -668
  147. package/dist/shared.js +16867 -16273
  148. package/dist/t3tools.d.ts +2 -2
  149. package/dist/t3tools.js +2 -2
  150. package/package.json +5 -5
  151. package/src/application/index.ts +1 -0
  152. package/src/application/service.ts +5 -1
  153. package/src/application/threads.ts +43 -1
  154. package/src/bin.ts +10 -7
  155. package/src/cli/app.ts +2 -0
  156. package/src/cli/format/thread.ts +23 -1
  157. package/src/cli/search.ts +48 -0
  158. package/src/config/persist/schema.ts +1 -1
  159. package/src/orchestration/layer.ts +6 -0
  160. package/src/orchestration/service.ts +5 -0
  161. package/src/rpc/error.ts +2 -0
  162. package/src/rpc/operation.ts +2 -0
  163. package/src/rpc/ws-group.ts +2 -0
package/dist/bin.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { a as __toESM, i as __require, t as __commonJSMin } from "./rolldown-runtime.js";
3
- import { $D as flatMap, $E as runDrain, $O as mergeAll, $T as Struct, $k as hasProperty, $w as extractSingleParams, AE as Size, AO as tapError, AT as isTrueValue, Ak as empty$1, BD as andThen, BE as filter, Bk as isSome, Bw as toImpl, CC as T3Config, CD as BadArgument, CE as make$6, CO as scoped, CT as magenta, Ck as isSuccess, DE as FileDescriptor, DO as suspend, DT as getTypeName, EE as TypeId$2, EO as succeed, ET as getChoiceKeys, Es as layerNode$1, Ew as T3Application, FD as value$2, FT as UnrecognizedOption, Fk as getOrElse, Fn as BaseAppLayer, Fw as getGlobalFlagsForCommandTree, GE as isStream, Gw as optional$2, HD as as, HT as isQuitError, Hk as match, Hw as boolean, ID as makeRunMain, IT as isCliError, Iw as getHelpForCommandPath, JD as catchTags, Jw as withDescription$1, KD as catchFilter, KE as map$1, Kw as string$2, LD as acquireRelease, LE as decodeText, LO as uninterruptible, Lw as TypeId$3, ME as make$8, MO as timeoutOrElse, MT as InvalidValue, Mk as flatMap$1, Mw as LogLevel, NE as callback$1, NO as tryPromise, NT as ShowHelp, Nb as ProviderUserInputAnswers, Nk as fromNullishOr, Ns as latestAssistantMessage, Nw as Wizard, OE as FileSystem, OO as sync, OT as isBoolean, Ok as Reference, PO as try_, PT as UnknownSubcommand, Pk as fromUndefinedOr, Ps as threadStatus, Pw as getGlobalFlagsForCommandPath, QD as fail, QE as run$2, QO as effect, QT as String$1, Qw as argumentKind, RD as addFinalizer, RO as void_, Rk as getOrUndefined, Rw as checkForDuplicateFlags, SC as layer$12, SD as unbounded, SE as ProcessId, SO as runFork, ST as green, Sk as isResult, Sw as resolveOutputFormat, TD as systemError, TE as Path$1, TT as white, UD as asVoid, UE as fromIterable, UT as make$11, Uk as none, Uw as choice, VT as Terminal, Vw as parseConfig, WD as callback, WE as fromQueue, Wk as some, Ww as integer$1, XD as effectify, Xw as error, YD as catch_, YE as merge, Yw as Formatter, Zw as log, _C as resolveThreadId, _D as make$10, _E as fdName, _T as toggle, aA as isUndefined, aD as succeed$5, aO as gen, aT as mapEffect$1, ak as _await, aw as formatFlag, bC as ThreadSessionError, bD as shutdown, bE as ChildProcessSpawner, bO as provideService, bT as bold, bw as isAgentEnvironment, cA as pipe, cD as transduce, cT as variadic$1, ck as make$13, cw as projectPathFlag, dD as make$9, dE as optionalKey, dO as mapError, dT as float, dw as threadFlag, eA as isNotNull, eD as runFold, eE as TaggedErrorClass, eO as fn, ek as provide, fC as CliPath, fD as drain, fO as match$1, fT as integer, fk as succeed$1, fw as threadFormatFlag, gD as failCauseUnsafe, gE as fromWritable, gO as orDie, gT as text, gw as canRenderLiveTerminal, hC as resolveCommandProjectRef, hD as endUnsafe, hE as fromReadable, hT as select, hw as yesFlag, iE as decodeUnknownEffect, iO as forkScoped, iT as isParam, ik as MinimumLogLevel, iw as forceFlag, jE as WatchBackend, jk as make$12, js as layer$13, jw as BuiltIns, kE as FileTypeId, kT as isFalseValue, kk as Service, ks as layerNode, lA as pipeArguments, lD as unwrap, lT as confirm, lk as makeUnsafe, lw as replaceFlag, mC as T3Auth, mE as make$7, mT as run$3, mw as worktreeFlag, nA as isNullish, nD as runHead, nO as forEach, nT as getUnderlyingSingleOrThrow, nk as succeed$2, oA as dual, oE as decodeUnknownSync, oO as ignore, oT as optional$1, ok as doneUnsafe, ow as modelFlags, pC as cliEnvironmentSetting, pD as isSink, pE as Crypto, pO as matchEffect, pT as password, pw as waitFormatFlag, qD as catchTag, qO as fail$1, qT as Literal, qw as withDefault, rD as runLast, rT as isFlagParam, rk as sync$1, rw as envNameFlag, sA as identity$1, sD as tap, sE as fromJsonString, sO as interrupt, sT as string$1, sk as isDone, sw as projectFlag, tA as isNotUndefined, tD as runForEach, tO as fnUntraced, tT as getParamMetadata, tk as provideMerge, uD as get$1, uO as map, uT as date, uk as succeed$4, uw as selfActionForceFlag, vC as resolveWorktreePath, vD as offer, vE as make$5, vO as provide$1, vT as annotate, wD as badArgument, wE as makeHandle, wO as serviceOption, wT as red, wk as succeed$3, ww as loadT3CliEnv, xC as CliRuntime, xE as ExitCode, xO as result$1, xT as cyanBright, xw as isInteractiveHumanTerminal, yC as ProjectLookupError, yD as offerUnsafe, yE as parseFdName, yO as provideContext, yT as blackBright, yk as fail$2, zE as empty, zk as isNone, zw as makeCommand } from "./shared.js";
3
+ import { $D as ExitCode, $E as red, $O as isSink, $T as loadT3CliEnv, AA as fail$1, AD as TaggedErrorClass, AE as getParamMetadata, AO as fromQueue, Aj as none, BA as succeed$2, BE as float, BO as runFold, BT as threadFlag, Bj as hasProperty, Bk as gen, Bs as CliPath, CD as Literal, CE as withDescription$1, CO as decodeText, DE as argumentKind, Dj as isSome, Dk as catch_, EE as log, EO as filter, Ej as isNone, Ek as catchTags, FD as decodeUnknownEffect, FE as optional$1, FO as merge, FT as modelFlags, Fk as fnUntraced, GA as isDone, GD as Crypto, GE as text, GO as succeed$5, GT as canRenderLiveTerminal, Gk as map, HA as MinimumLogLevel, HD as optionalKey, HE as password, HO as runHead, HT as waitFormatFlag, Hj as isNotUndefined, Hk as interrupt, Hs as threadStatus, Hw as cliEnvironmentSetting, IA as effect, IE as string$1, IT as projectFlag, Ik as forEach, Is as layerNode, JA as succeed$4, JD as fromWritable, JE as blackBright, JO as transduce, Jj as identity$1, Jk as matchEffect, Jw as ProjectLookupError, KA as make$13, KD as make$7, KE as toggle, Kj as isUndefined, Kk as mapError, Kw as resolveThreadId, LA as mergeAll, LD as decodeUnknownSync, LE as variadic$1, LT as projectPathFlag, ME as isFlagParam, MO as map$1, MT as envNameFlag, NE as isParam, NT as forceFlag, Nk as flatMap, Ns as layerNode$1, OD as String$1, OE as extractSingleParams, Ok as effectify, PE as mapEffect$1, PT as formatFlag, Pk as fn, QD as ChildProcessSpawner, QE as magenta, QO as drain, Qk as orDie, Qw as T3Config, RA as provide, RD as fromJsonString, RE as confirm, RO as run$2, RT as replaceFlag, Rs as layer$13, SE as withDefault, Sj as getOrElse, Sk as callback, TE as error, TO as empty, Tj as getOrUndefined, Tk as catchTag, UA as _await, UE as run$3, UO as runLast, UT as worktreeFlag, Uj as isNullish, Uw as T3Auth, VA as sync$1, VE as integer, VO as runForEach, VT as threadFormatFlag, Vj as isNotNull, Vk as ignore, Vs as latestAssistantMessage, WA as doneUnsafe, WD as value$2, WE as select, WT as yesFlag, Ww as resolveCommandProjectRef, XD as make$5, XE as cyanBright, XO as get$1, XT as isInteractiveHumanTerminal, Xj as pipeArguments, Xw as CliRuntime, YD as fdName, YE as bold, YO as unwrap, YT as isAgentEnvironment, Yj as pipe, Yw as ThreadSessionError, ZA as succeed$1, ZD as parseFdName, ZE as green, ZO as make$10, ZT as resolveOutputFormat, Zw as layer$12, _D as Terminal, _E as boolean, _O as WatchBackend, _j as make$12, aA as scoped, aD as isTrueValue, ak as offerUnsafe, bA as void_, bE as optional$2, bj as fromNullishOr, bk as as, cA as succeed, cD as ShowHelp, cE as Wizard, cj as isSuccess, dD as isCliError, dE as getHelpForCommandPath, dk as BadArgument, eA as provide$1, eD as white, eO as ProcessId, fE as TypeId$3, fO as Path$1, fk as badArgument, gA as try_, gD as QuitError, gE as parseConfig, gO as Size, gj as empty$1, gk as addFinalizer, hA as tryPromise, hE as toImpl, hO as FileTypeId, hj as Service, hk as acquireRelease, iA as runFork, iD as isFalseValue, ij as fail$2, ik as offer, jE as getUnderlyingSingleOrThrow, jO as isStream, jj as some, jk as fail, kD as Struct, kO as fromIterable, kj as match, lA as suspend, lD as UnknownSubcommand, lE as getGlobalFlagsForCommandPath, lj as succeed$3, lk as take, mA as timeoutOrElse, mE as makeCommand, mO as FileSystem, mj as Reference, mk as makeRunMain, nA as provideService, nD as getTypeName, nO as makeHandle, nS as ProviderUserInputAnswers, nk as failCauseUnsafe, oA as serviceOption, oE as BuiltIns, ok as poll, pE as checkForDuplicateFlags, pO as TypeId$2, pk as systemError, qA as makeUnsafe, qD as fromReadable, qE as annotate, qO as tap, qj as dual, qk as match$1, qw as resolveWorktreePath, rA as result$1, rD as isBoolean, rk as make$9, sD as InvalidValue, sE as LogLevel, sj as isResult, sk as shutdown, tA as provideContext, tD as getChoiceKeys, tE as T3Application, tO as make$6, tk as endUnsafe, uA as sync, uD as UnrecognizedOption, uE as getGlobalFlagsForCommandTree, uk as unbounded, vD as isQuitError, vE as choice, vO as make$8, vj as flatMap$1, vk as andThen, wE as Formatter, wk as catchFilter, xE as string$2, xj as fromUndefinedOr, xk as asVoid, yA as uninterruptible, yD as make$11, yE as integer$1, yO as callback$1, zA as provideMerge, zE as date, zO as runDrain, zT as selfActionForceFlag, zk as forkScoped, zn as BaseAppLayer } from "./shared.js";
4
4
  import * as OS from "node:os";
5
5
  import os, { homedir } from "node:os";
6
6
  import * as NodeChildProcess from "node:child_process";
@@ -14,7 +14,7 @@ import * as readline from "node:readline";
14
14
  import process$1 from "node:process";
15
15
  import tty from "node:tty";
16
16
  //#endregion
17
- //#region node_modules/.pnpm/@effect+platform-node@4.0.0-beta.102_patch_hash=cae7efcda6fd29f4db2efd357cb7dc6c41cb6ad_5ec7f92fdb36a12db81428ea9ead6984/node_modules/@effect/platform-node/dist/NodeRuntime.js
17
+ //#region node_modules/.pnpm/@effect+platform-node@4.0.0-beta.103_effect@4.0.0-beta.103_patch_hash=af36b7948b6f9c566_933a6d6775be5e2696c624c811da82a4/node_modules/@effect/platform-node/dist/NodeRuntime.js
18
18
  /**
19
19
  * Node.js process runner for Effect programs.
20
20
  *
@@ -66,7 +66,18 @@ const runMain = /* @__PURE__ */ makeRunMain(({ fiber, teardown }) => {
66
66
  process.on("SIGTERM", onSigint);
67
67
  });
68
68
  //#endregion
69
- //#region node_modules/.pnpm/@effect+platform-node-shared@4.0.0-beta.102_effect@4.0.0-beta.102_patch_hash=71215759e1_3273714b76c575f5c82a5a72c5bb5418/node_modules/@effect/platform-node-shared/dist/internal/utils.js
69
+ //#region node_modules/.pnpm/@effect+platform-node-shared@4.0.0-beta.107_effect@4.0.0-beta.103_patch_hash=af36b7948b_4e5b8af3fb2887013aca0b70cb08d812/node_modules/@effect/platform-node-shared/dist/internal/nodeChildProcessSpawner.js
70
+ const buildSpawnOptions = (options, base, platform) => {
71
+ const detached = options.detached ?? platform !== "win32";
72
+ return {
73
+ ...base,
74
+ detached,
75
+ shell: options.shell,
76
+ windowsHide: options.windowsHide ?? !detached
77
+ };
78
+ };
79
+ //#endregion
80
+ //#region node_modules/.pnpm/@effect+platform-node-shared@4.0.0-beta.107_effect@4.0.0-beta.103_patch_hash=af36b7948b_4e5b8af3fb2887013aca0b70cb08d812/node_modules/@effect/platform-node-shared/dist/internal/utils.js
70
81
  /** @internal */
71
82
  const handleErrnoException = (module, method) => (err, [path]) => {
72
83
  let reason = "Unknown";
@@ -103,7 +114,7 @@ const handleErrnoException = (module, method) => (err, [path]) => {
103
114
  });
104
115
  };
105
116
  //#endregion
106
- //#region node_modules/.pnpm/@effect+platform-node-shared@4.0.0-beta.102_effect@4.0.0-beta.102_patch_hash=71215759e1_3273714b76c575f5c82a5a72c5bb5418/node_modules/@effect/platform-node-shared/dist/NodeChildProcessSpawner.js
117
+ //#region node_modules/.pnpm/@effect+platform-node-shared@4.0.0-beta.107_effect@4.0.0-beta.103_patch_hash=af36b7948b_4e5b8af3fb2887013aca0b70cb08d812/node_modules/@effect/platform-node-shared/dist/NodeChildProcessSpawner.js
107
118
  const toError = (error) => error instanceof globalThis.Error ? error : new globalThis.Error(String(error));
108
119
  const toPlatformError = (method, error, command) => {
109
120
  const { commands } = flattenCommand(command);
@@ -113,6 +124,12 @@ const toPlatformError = (method, error, command) => {
113
124
  }, "");
114
125
  return handleErrnoException("ChildProcess", method)(error, [commandStr]);
115
126
  };
127
+ const taskkill = (childProcess, onExit = () => {}) => NodeChildProcess.execFile("taskkill", [
128
+ "/pid",
129
+ String(childProcess.pid),
130
+ "/T",
131
+ "/F"
132
+ ], { windowsHide: true }, onExit);
116
133
  /**
117
134
  * Layer that provides the `NodeChildProcessSpawner` implementation.
118
135
  *
@@ -286,7 +303,7 @@ const layer$11 = /*#__PURE__*/ effect(ChildProcessSpawner, /* @__PURE__ */ gen(f
286
303
  });
287
304
  const killProcessGroup = (command, childProcess, signal) => {
288
305
  if (globalThis.process.platform === "win32") return callback((resume) => {
289
- NodeChildProcess.exec(`taskkill /pid ${childProcess.pid} /T /F`, (error) => {
306
+ taskkill(childProcess, (error) => {
290
307
  if (error) resume(fail(toPlatformError("kill", toError(error), command)));
291
308
  else resume(void_);
292
309
  });
@@ -300,7 +317,7 @@ const layer$11 = /*#__PURE__*/ effect(ChildProcessSpawner, /* @__PURE__ */ gen(f
300
317
  };
301
318
  const killProcessGroupOnExit = (childProcess, signal) => {
302
319
  if (globalThis.process.platform === "win32") {
303
- NodeChildProcess.exec(`taskkill /pid ${childProcess.pid} /T /F`, () => {});
320
+ taskkill(childProcess);
304
321
  return;
305
322
  }
306
323
  try {
@@ -349,13 +366,11 @@ const layer$11 = /*#__PURE__*/ effect(ChildProcessSpawner, /* @__PURE__ */ gen(f
349
366
  const cwd = yield* resolveWorkingDirectory(cmd.options);
350
367
  const env = resolveEnvironment(cmd.options);
351
368
  const stdio = buildStdioArray(stdinConfig, stdoutConfig, stderrConfig, resolvedAdditionalFds);
352
- const [childProcess, exitSignal] = yield* acquireRelease(spawn(cmd, {
369
+ const [childProcess, exitSignal] = yield* acquireRelease(spawn(cmd, buildSpawnOptions(cmd.options, {
353
370
  cwd,
354
371
  env,
355
- stdio,
356
- detached: cmd.options.detached ?? process.platform !== "win32",
357
- shell: cmd.options.shell
358
- }), fnUntraced(function* ([childProcess, exitSignal]) {
372
+ stdio
373
+ }, process.platform)), fnUntraced(function* ([childProcess, exitSignal]) {
359
374
  const exited = yield* isDone(exitSignal);
360
375
  const killWithTimeout = withTimeout(childProcess, cmd, cmd.options);
361
376
  if (exited) {
@@ -451,6 +466,7 @@ const layer$11 = /*#__PURE__*/ effect(ChildProcessSpawner, /* @__PURE__ */ gen(f
451
466
  }
452
467
  }
453
468
  const handle = handles[handles.length - 1];
469
+ const kill = (options) => forEach([...handles].reverse(), (handle) => ignore(handle.kill(options)), { discard: true });
454
470
  const unref = gen(function* () {
455
471
  const rerefs = [];
456
472
  for (const handle of handles) rerefs.push(yield* handle.unref);
@@ -460,7 +476,7 @@ const layer$11 = /*#__PURE__*/ effect(ChildProcessSpawner, /* @__PURE__ */ gen(f
460
476
  pid: handle.pid,
461
477
  exitCode: handle.exitCode,
462
478
  isRunning: handle.isRunning,
463
- kill: handle.kill,
479
+ kill,
464
480
  stdin: handle.stdin,
465
481
  stdout: handle.stdout,
466
482
  stderr: handle.stderr,
@@ -505,7 +521,7 @@ const flattenCommand = (command) => {
505
521
  };
506
522
  };
507
523
  //#endregion
508
- //#region node_modules/.pnpm/@effect+platform-node-shared@4.0.0-beta.102_effect@4.0.0-beta.102_patch_hash=71215759e1_3273714b76c575f5c82a5a72c5bb5418/node_modules/@effect/platform-node-shared/dist/NodeCrypto.js
524
+ //#region node_modules/.pnpm/@effect+platform-node-shared@4.0.0-beta.107_effect@4.0.0-beta.103_patch_hash=af36b7948b_4e5b8af3fb2887013aca0b70cb08d812/node_modules/@effect/platform-node-shared/dist/NodeCrypto.js
509
525
  /**
510
526
  * Node-compatible implementation of Effect's `Crypto` service.
511
527
  *
@@ -535,7 +551,7 @@ const digest = (algorithm, data) => try_({
535
551
  })
536
552
  });
537
553
  //#endregion
538
- //#region node_modules/.pnpm/@effect+platform-node@4.0.0-beta.102_patch_hash=cae7efcda6fd29f4db2efd357cb7dc6c41cb6ad_5ec7f92fdb36a12db81428ea9ead6984/node_modules/@effect/platform-node/dist/NodeCrypto.js
554
+ //#region node_modules/.pnpm/@effect+platform-node@4.0.0-beta.103_effect@4.0.0-beta.103_patch_hash=af36b7948b6f9c566_933a6d6775be5e2696c624c811da82a4/node_modules/@effect/platform-node/dist/NodeCrypto.js
539
555
  /**
540
556
  * The `NodeCrypto` module provides the Node.js `Crypto` service layer for
541
557
  * Effect programs. Provide {@link layer} at the edge of a Node application,
@@ -560,7 +576,7 @@ const layer$9 = /* @__PURE__ */ succeed$2(Crypto, /* @__PURE__ */ make$7({
560
576
  digest
561
577
  }));
562
578
  //#endregion
563
- //#region node_modules/.pnpm/@effect+platform-node-shared@4.0.0-beta.102_effect@4.0.0-beta.102_patch_hash=71215759e1_3273714b76c575f5c82a5a72c5bb5418/node_modules/@effect/platform-node-shared/dist/NodeFileSystem.js
579
+ //#region node_modules/.pnpm/@effect+platform-node-shared@4.0.0-beta.107_effect@4.0.0-beta.103_patch_hash=af36b7948b_4e5b8af3fb2887013aca0b70cb08d812/node_modules/@effect/platform-node-shared/dist/NodeFileSystem.js
564
580
  /**
565
581
  * Shared Node-compatible implementation of Effect's `FileSystem` service.
566
582
  *
@@ -649,7 +665,7 @@ const makeTempDirectoryScoped = /*#__PURE__*/ (() => {
649
665
  const openFactory = (method) => {
650
666
  const nodeOpen = effectify(NFS.open, handleErrnoException("FileSystem", method), handleBadArgument(method));
651
667
  const nodeClose = effectify(NFS.close, handleErrnoException("FileSystem", method), handleBadArgument(method));
652
- return (path, options) => pipe(acquireRelease(nodeOpen(path, options?.flag ?? "r", options?.mode), (fd) => orDie(nodeClose(fd))), map((fd) => makeFile(FileDescriptor(fd), options?.flag?.startsWith("a") ?? false)));
668
+ return (path, options) => pipe(acquireRelease(nodeOpen(path, options?.flag ?? "r", options?.mode), (fd) => orDie(nodeClose(fd))), map((fd) => makeFile(fd, options?.flag?.startsWith("a") ?? false)));
653
669
  };
654
670
  const open = /*#__PURE__*/ openFactory("open");
655
671
  const makeFile = /*#__PURE__*/ (() => {
@@ -683,7 +699,7 @@ const makeFile = /*#__PURE__*/ (() => {
683
699
  return sync(() => {
684
700
  if (from === "start") this.position = offsetSize;
685
701
  else if (from === "current") this.position = this.position + offsetSize;
686
- return this.position;
702
+ return Size(this.position);
687
703
  });
688
704
  }
689
705
  read(buffer) {
@@ -831,8 +847,8 @@ const utimes = /*#__PURE__*/ (() => {
831
847
  const nodeUtimes = /*#__PURE__*/ effectify(NFS.utimes, /*#__PURE__*/ handleErrnoException("FileSystem", "utime"), /*#__PURE__*/ handleBadArgument("utime"));
832
848
  return (path, atime, mtime) => nodeUtimes(path, atime, mtime);
833
849
  })();
834
- const watchNode = (path) => callback$1((queue) => acquireRelease(sync(() => {
835
- const watcher = NFS.watch(path, { recursive: true }, (event, path) => {
850
+ const watchNode = (path, options) => callback$1((queue) => acquireRelease(sync(() => {
851
+ const watcher = NFS.watch(path, { recursive: options?.recursive ?? false }, (event, path) => {
836
852
  if (!path) return;
837
853
  switch (event) {
838
854
  case "rename":
@@ -869,7 +885,7 @@ const watchNode = (path) => callback$1((queue) => acquireRelease(sync(() => {
869
885
  });
870
886
  return watcher;
871
887
  }), (watcher) => sync(() => watcher.close())));
872
- const watch = (backend, path) => stat(path).pipe(map((stat) => backend.pipe(flatMap$1((_) => _.register(path, stat)), getOrElse(() => watchNode(path)))), unwrap);
888
+ const watch = (backend, path, options) => stat(path).pipe(map((stat) => backend.pipe(flatMap$1((_) => _.register(path, stat, options)), getOrElse(() => watchNode(path, options)))), unwrap);
873
889
  const writeFile = (path, data, options) => callback((resume, signal) => {
874
890
  try {
875
891
  NFS.writeFile(path, data, {
@@ -908,13 +924,13 @@ const makeFileSystem = /*#__PURE__*/ map(/*#__PURE__*/ serviceOption(WatchBacken
908
924
  symlink,
909
925
  truncate,
910
926
  utimes,
911
- watch(path) {
912
- return watch(backend, path);
927
+ watch(path, options) {
928
+ return watch(backend, path, options);
913
929
  },
914
930
  writeFile
915
931
  }));
916
932
  //#endregion
917
- //#region node_modules/.pnpm/@effect+platform-node@4.0.0-beta.102_patch_hash=cae7efcda6fd29f4db2efd357cb7dc6c41cb6ad_5ec7f92fdb36a12db81428ea9ead6984/node_modules/@effect/platform-node/dist/NodeFileSystem.js
933
+ //#region node_modules/.pnpm/@effect+platform-node@4.0.0-beta.103_effect@4.0.0-beta.103_patch_hash=af36b7948b6f9c566_933a6d6775be5e2696c624c811da82a4/node_modules/@effect/platform-node/dist/NodeFileSystem.js
918
934
  /**
919
935
  * Node.js `FileSystem` layer for programs that perform real filesystem I/O.
920
936
  *
@@ -933,7 +949,7 @@ const makeFileSystem = /*#__PURE__*/ map(/*#__PURE__*/ serviceOption(WatchBacken
933
949
  */
934
950
  const layer$7 = /* @__PURE__ */ effect(FileSystem)(makeFileSystem);
935
951
  //#endregion
936
- //#region node_modules/.pnpm/@effect+platform-node-shared@4.0.0-beta.102_effect@4.0.0-beta.102_patch_hash=71215759e1_3273714b76c575f5c82a5a72c5bb5418/node_modules/@effect/platform-node-shared/dist/NodePath.js
952
+ //#region node_modules/.pnpm/@effect+platform-node-shared@4.0.0-beta.107_effect@4.0.0-beta.103_patch_hash=af36b7948b_4e5b8af3fb2887013aca0b70cb08d812/node_modules/@effect/platform-node-shared/dist/NodePath.js
937
953
  /**
938
954
  * Node-backed provider for Effect's `Path` service.
939
955
  *
@@ -944,26 +960,34 @@ const layer$7 = /* @__PURE__ */ effect(FileSystem)(makeFileSystem);
944
960
  *
945
961
  * @since 4.0.0
946
962
  */
947
- const fromFileUrl = (url) => try_({
948
- try: () => NodeUrl.fileURLToPath(url),
949
- catch: (cause) => new BadArgument({
950
- module: "Path",
951
- method: "fromFileUrl",
952
- cause
963
+ const fileUrlOps = (windows) => ({
964
+ fromFileUrl: (url) => try_({
965
+ try: () => NodeUrl.fileURLToPath(url, { windows }),
966
+ catch: (cause) => new BadArgument({
967
+ module: "Path",
968
+ method: "fromFileUrl",
969
+ cause
970
+ })
971
+ }),
972
+ toFileUrl: (path) => try_({
973
+ try: () => NodeUrl.pathToFileURL(path, { windows }),
974
+ catch: (cause) => new BadArgument({
975
+ module: "Path",
976
+ method: "toFileUrl",
977
+ cause
978
+ })
953
979
  })
954
980
  });
955
- const toFileUrl = (path) => try_({
956
- try: () => NodeUrl.pathToFileURL(path),
957
- catch: (cause) => new BadArgument({
958
- module: "Path",
959
- method: "toFileUrl",
960
- cause
961
- })
981
+ ({
982
+ ...Path.posix,
983
+ .../*#__PURE__*/ fileUrlOps(false)
984
+ });
985
+ ({
986
+ ...Path.win32,
987
+ .../*#__PURE__*/ fileUrlOps(true)
962
988
  });
963
- ({ ...Path.posix });
964
- ({ ...Path.win32 });
965
989
  //#endregion
966
- //#region node_modules/.pnpm/@effect+platform-node@4.0.0-beta.102_patch_hash=cae7efcda6fd29f4db2efd357cb7dc6c41cb6ad_5ec7f92fdb36a12db81428ea9ead6984/node_modules/@effect/platform-node/dist/NodePath.js
990
+ //#region node_modules/.pnpm/@effect+platform-node@4.0.0-beta.103_effect@4.0.0-beta.103_patch_hash=af36b7948b6f9c566_933a6d6775be5e2696c624c811da82a4/node_modules/@effect/platform-node/dist/NodePath.js
967
991
  /**
968
992
  * Node.js layers for Effect's `Path` service.
969
993
  *
@@ -984,11 +1008,10 @@ const toFileUrl = (path) => try_({
984
1008
  const layer$5 = /* @__PURE__ */ succeed$2(Path$1)({
985
1009
  [TypeId$2]: TypeId$2,
986
1010
  ...Path,
987
- fromFileUrl,
988
- toFileUrl
1011
+ .../*#__PURE__*/ fileUrlOps(void 0)
989
1012
  });
990
1013
  //#endregion
991
- //#region node_modules/.pnpm/effect@4.0.0-beta.102_patch_hash=71215759e1ac0a7f65d7b75d816986687ae6c3a6cba02d928d184ca71790d488/node_modules/effect/dist/Stdio.js
1014
+ //#region node_modules/.pnpm/effect@4.0.0-beta.103_patch_hash=af36b7948b6f9c56623074662b51dade5699880c1a7c71245de73e13c3185fb6/node_modules/effect/dist/Stdio.js
992
1015
  /**
993
1016
  * Service contract for command-line arguments and standard input, output, and
994
1017
  * error output. It lets programs depend on standard I/O through the Effect
@@ -1053,7 +1076,7 @@ const make$2 = (options) => ({
1053
1076
  ...options
1054
1077
  });
1055
1078
  //#endregion
1056
- //#region node_modules/.pnpm/@effect+platform-node@4.0.0-beta.102_patch_hash=cae7efcda6fd29f4db2efd357cb7dc6c41cb6ad_5ec7f92fdb36a12db81428ea9ead6984/node_modules/@effect/platform-node/dist/NodeStdio.js
1079
+ //#region node_modules/.pnpm/@effect+platform-node@4.0.0-beta.103_effect@4.0.0-beta.103_patch_hash=af36b7948b6f9c566_933a6d6775be5e2696c624c811da82a4/node_modules/@effect/platform-node/dist/NodeStdio.js
1057
1080
  /**
1058
1081
  * Node.js `Stdio` layer for the current process.
1059
1082
  *
@@ -1073,6 +1096,8 @@ const make$2 = (options) => ({
1073
1096
  */
1074
1097
  const layer$3 = /* @__PURE__ */ succeed$2(Stdio, /*#__PURE__*/ make$2({
1075
1098
  args: /*#__PURE__*/ sync(() => process.argv.slice(2)),
1099
+ stdinIsTerminal: /*#__PURE__*/ sync(() => process.stdin.isTTY === true),
1100
+ stdoutIsTerminal: /*#__PURE__*/ sync(() => process.stdout.isTTY === true),
1076
1101
  stdout: (options) => fromWritable({
1077
1102
  evaluate: () => process.stdout,
1078
1103
  onError: (cause) => systemError({
@@ -1114,23 +1139,50 @@ const layer$3 = /* @__PURE__ */ succeed$2(Stdio, /*#__PURE__*/ make$2({
1114
1139
  const layer$2 = /*#__PURE__*/ effect(Terminal, /*#__PURE__*/ (/* @__PURE__ */ fnUntraced(function* (shouldQuit = defaultShouldQuit) {
1115
1140
  const stdin = process.stdin;
1116
1141
  const stdout = process.stdout;
1117
- const rlRef = yield* make$9({ acquire: acquireRelease(sync(() => {
1118
- const rl = readline.createInterface({
1119
- input: stdin,
1120
- escapeCodeTimeout: 50
1121
- });
1122
- readline.emitKeypressEvents(stdin, rl);
1123
- if (stdin.isTTY) stdin.setRawMode(true);
1124
- return rl;
1125
- }), (rl) => sync(() => {
1126
- if (stdin.isTTY) stdin.setRawMode(false);
1127
- rl.close();
1128
- })) });
1142
+ const lines = yield* make$9();
1143
+ let inputEnded = stdin.readableEnded;
1144
+ let readlineActive = false;
1145
+ const onStdinEnd = () => {
1146
+ inputEnded = true;
1147
+ if (!readlineActive) endUnsafe(lines);
1148
+ };
1149
+ stdin.once("end", onStdinEnd);
1150
+ yield* addFinalizer(() => sync(() => stdin.off("end", onStdinEnd)));
1151
+ const rlRef = yield* make$10({
1152
+ acquire: acquireRelease(sync(() => {
1153
+ const rl = readline.createInterface({
1154
+ input: stdin,
1155
+ escapeCodeTimeout: 50
1156
+ });
1157
+ const onLine = (line) => offerUnsafe(lines, line);
1158
+ const onClose = () => {
1159
+ readlineActive = false;
1160
+ endUnsafe(lines);
1161
+ };
1162
+ readlineActive = true;
1163
+ readline.emitKeypressEvents(stdin, rl);
1164
+ rl.on("line", onLine);
1165
+ rl.once("close", onClose);
1166
+ if (stdin.isTTY) stdin.setRawMode(true);
1167
+ return {
1168
+ rl,
1169
+ onClose,
1170
+ onLine
1171
+ };
1172
+ }), ({ rl, onClose, onLine }) => sync(() => {
1173
+ readlineActive = false;
1174
+ rl.off("line", onLine);
1175
+ rl.off("close", onClose);
1176
+ if (stdin.isTTY) stdin.setRawMode(false);
1177
+ rl.close();
1178
+ if (inputEnded) endUnsafe(lines);
1179
+ })),
1180
+ idleTimeToLive: "10 millis"
1181
+ });
1129
1182
  const columns = sync(() => stdout.columns ?? 0);
1130
1183
  const rows = sync(() => stdout.rows ?? 0);
1131
1184
  const readInput = gen(function* () {
1132
- yield* get$1(rlRef);
1133
- const queue = yield* make$10();
1185
+ const queue = yield* make$9();
1134
1186
  const handleKeypress = (s, k) => {
1135
1187
  const userInput = {
1136
1188
  input: fromUndefinedOr(s),
@@ -1144,15 +1196,28 @@ const layer$2 = /*#__PURE__*/ effect(Terminal, /*#__PURE__*/ (/* @__PURE__ */ fn
1144
1196
  offerUnsafe(queue, userInput);
1145
1197
  if (shouldQuit(userInput)) endUnsafe(queue);
1146
1198
  };
1147
- yield* addFinalizer(() => sync(() => stdin.off("keypress", handleKeypress)));
1199
+ const keepAlive = setInterval(() => {}, 2147483647);
1200
+ const handleEnd = () => {
1201
+ clearInterval(keepAlive);
1202
+ endUnsafe(queue);
1203
+ };
1204
+ yield* addFinalizer(() => sync(() => {
1205
+ clearInterval(keepAlive);
1206
+ stdin.off("keypress", handleKeypress);
1207
+ stdin.off("end", handleEnd);
1208
+ }));
1148
1209
  stdin.on("keypress", handleKeypress);
1210
+ if (inputEnded) handleEnd();
1211
+ else {
1212
+ yield* get$1(rlRef);
1213
+ stdin.once("end", handleEnd);
1214
+ }
1149
1215
  return queue;
1150
1216
  });
1151
- const readLine = scoped(flatMap(get$1(rlRef), (readlineInterface) => callback((resume) => {
1152
- const onLine = (line) => resume(succeed(line));
1153
- readlineInterface.once("line", onLine);
1154
- return sync(() => readlineInterface.off("line", onLine));
1155
- })));
1217
+ const readLine = suspend(() => poll(lines).pipe(flatMap(match({
1218
+ onNone: () => scoped(andThen(get$1(rlRef), take(lines))),
1219
+ onSome: succeed
1220
+ })), mapError(() => new QuitError({}))));
1156
1221
  const display = (prompt) => uninterruptible(callback((resume) => {
1157
1222
  stdout.write(prompt, (err) => isNullish(err) ? resume(void_) : resume(fail(badArgument({
1158
1223
  module: "Terminal",
@@ -1173,7 +1238,7 @@ function defaultShouldQuit(input) {
1173
1238
  return input.key.ctrl && (input.key.name === "c" || input.key.name === "d");
1174
1239
  }
1175
1240
  //#endregion
1176
- //#region node_modules/.pnpm/@effect+platform-node@4.0.0-beta.102_patch_hash=cae7efcda6fd29f4db2efd357cb7dc6c41cb6ad_5ec7f92fdb36a12db81428ea9ead6984/node_modules/@effect/platform-node/dist/NodeServices.js
1241
+ //#region node_modules/.pnpm/@effect+platform-node@4.0.0-beta.103_effect@4.0.0-beta.103_patch_hash=af36b7948b6f9c566_933a6d6775be5e2696c624c811da82a4/node_modules/@effect/platform-node/dist/NodeServices.js
1177
1242
  /**
1178
1243
  * Provides the default Node implementations for child process spawning,
1179
1244
  * filesystem, path, stdio, and terminal services.
@@ -1183,16 +1248,17 @@ function defaultShouldQuit(input) {
1183
1248
  */
1184
1249
  const layer = /*#__PURE__*/ provideMerge(layer$11, /*#__PURE__*/ mergeAll(layer$7, layer$9, layer$5, layer$3, layer$2));
1185
1250
  //#endregion
1186
- //#region node_modules/.pnpm/effect@4.0.0-beta.102_patch_hash=71215759e1ac0a7f65d7b75d816986687ae6c3a6cba02d928d184ca71790d488/node_modules/effect/dist/unstable/cli/Argument.js
1251
+ //#region node_modules/.pnpm/effect@4.0.0-beta.103_patch_hash=af36b7948b6f9c56623074662b51dade5699880c1a7c71245de73e13c3185fb6/node_modules/effect/dist/unstable/cli/Argument.js
1187
1252
  /**
1188
1253
  * Creates a positional string argument.
1189
1254
  *
1190
1255
  * **Example** (Creating a string argument)
1191
1256
  *
1192
- * ```ts
1257
+ * ```ts import.meta.vitest
1193
1258
  * import { Argument } from "effect/unstable/cli"
1194
1259
  *
1195
1260
  * const filename = Argument.string("filename")
1261
+ * filename.kind // => "argument"
1196
1262
  * ```
1197
1263
  *
1198
1264
  * @category constructors
@@ -1204,10 +1270,11 @@ const string = (name) => string$1(argumentKind, name);
1204
1270
  *
1205
1271
  * **Example** (Making an argument optional)
1206
1272
  *
1207
- * ```ts
1273
+ * ```ts import.meta.vitest
1208
1274
  * import { Argument } from "effect/unstable/cli"
1209
1275
  *
1210
1276
  * const optionalVersion = Argument.string("version").pipe(Argument.optional)
1277
+ * optionalVersion.kind // => "argument"
1211
1278
  * ```
1212
1279
  *
1213
1280
  * @category combinators
@@ -1219,7 +1286,7 @@ const optional = (arg) => optional$1(arg);
1219
1286
  *
1220
1287
  * **Example** (Accepting multiple values)
1221
1288
  *
1222
- * ```ts
1289
+ * ```ts import.meta.vitest
1223
1290
  * import { Argument } from "effect/unstable/cli"
1224
1291
  *
1225
1292
  * // Accept any number of files
@@ -1234,6 +1301,8 @@ const optional = (arg) => optional$1(arg);
1234
1301
  * const limitedFiles = Argument.string("files").pipe(
1235
1302
  * Argument.variadic({ min: 1, max: 5 })
1236
1303
  * )
1304
+ *
1305
+ * const kinds = [anyFiles.kind, atLeastOneFile.kind, limitedFiles.kind] // => ["argument", "argument", "argument"]
1237
1306
  * ```
1238
1307
  *
1239
1308
  * @category combinators
@@ -1245,9 +1314,27 @@ const variadic = /*#__PURE__*/ dual((args) => isParam(args[0]), (self, options)
1245
1314
  *
1246
1315
  * **Example** (Validating values effectfully)
1247
1316
  *
1248
- * ```ts
1249
- * import { Effect } from "effect"
1317
+ * ```ts import.meta.vitest
1318
+ * import { Effect, FileSystem, Layer, Path, Stdio, Terminal } from "effect"
1250
1319
  * import { Argument, CliError } from "effect/unstable/cli"
1320
+ * import { ChildProcessSpawner } from "effect/unstable/process"
1321
+ *
1322
+ * const CliTestLayer = Layer.mergeAll(
1323
+ * FileSystem.layerNoop({}),
1324
+ * Path.layer,
1325
+ * Stdio.layerTest({}),
1326
+ * Layer.succeed(Terminal.Terminal, Terminal.make({
1327
+ * columns: Effect.succeed(80),
1328
+ * rows: Effect.succeed(24),
1329
+ * readInput: Effect.die("unused"),
1330
+ * readLine: Effect.die("unused"),
1331
+ * display: () => Effect.void
1332
+ * })),
1333
+ * Layer.succeed(
1334
+ * ChildProcessSpawner.ChildProcessSpawner,
1335
+ * ChildProcessSpawner.make(() => Effect.die("unused"))
1336
+ * )
1337
+ * )
1251
1338
  *
1252
1339
  * const files = Argument.string("files").pipe(
1253
1340
  * Argument.mapEffect((file) =>
@@ -1260,6 +1347,11 @@ const variadic = /*#__PURE__*/ dual((args) => isParam(args[0]), (self, options)
1260
1347
  * )
1261
1348
  * )
1262
1349
  * )
1350
+ *
1351
+ * const [, value] = await Effect.runPromise(
1352
+ * files.parse({ arguments: ["notes.txt"], flags: {} }).pipe(Effect.provide(CliTestLayer))
1353
+ * )
1354
+ * value // => "notes.txt"
1263
1355
  * ```
1264
1356
  *
1265
1357
  * @category combinators
@@ -1267,7 +1359,7 @@ const variadic = /*#__PURE__*/ dual((args) => isParam(args[0]), (self, options)
1267
1359
  */
1268
1360
  const mapEffect = /*#__PURE__*/ dual(2, (self, f) => mapEffect$1(self, f));
1269
1361
  //#endregion
1270
- //#region node_modules/.pnpm/effect@4.0.0-beta.102_patch_hash=71215759e1ac0a7f65d7b75d816986687ae6c3a6cba02d928d184ca71790d488/node_modules/effect/dist/unstable/cli/CliConfig.js
1362
+ //#region node_modules/.pnpm/effect@4.0.0-beta.103_patch_hash=af36b7948b6f9c56623074662b51dade5699880c1a7c71245de73e13c3185fb6/node_modules/effect/dist/unstable/cli/CliConfig.js
1271
1363
  /**
1272
1364
  * Configuration for Effect CLI command execution.
1273
1365
  *
@@ -1294,7 +1386,7 @@ var CliConfig = class extends Reference("effect/unstable/cli/CliConfig", { defau
1294
1386
  */
1295
1387
  const defaults = { builtIns: BuiltIns };
1296
1388
  //#endregion
1297
- //#region node_modules/.pnpm/effect@4.0.0-beta.102_patch_hash=71215759e1ac0a7f65d7b75d816986687ae6c3a6cba02d928d184ca71790d488/node_modules/effect/dist/unstable/cli/internal/lexer.js
1389
+ //#region node_modules/.pnpm/effect@4.0.0-beta.103_patch_hash=af36b7948b6f9c56623074662b51dade5699880c1a7c71245de73e13c3185fb6/node_modules/effect/dist/unstable/cli/internal/lexer.js
1298
1390
  /** @internal */
1299
1391
  function lex(argv) {
1300
1392
  const endIndex = argv.indexOf("--");
@@ -1314,12 +1406,20 @@ const lexTokens = (args) => {
1314
1406
  value: arg
1315
1407
  });
1316
1408
  else if (arg.startsWith("--")) {
1317
- const [name, value] = arg.slice(2).split("=", 2);
1318
- tokens.push({
1409
+ const equalIndex = arg.indexOf("=");
1410
+ if (equalIndex !== -1) {
1411
+ const name = arg.slice(2, equalIndex);
1412
+ const value = arg.slice(equalIndex + 1);
1413
+ tokens.push({
1414
+ _tag: "LongOption",
1415
+ name,
1416
+ raw: arg,
1417
+ value
1418
+ });
1419
+ } else tokens.push({
1319
1420
  _tag: "LongOption",
1320
- name,
1321
- raw: arg,
1322
- value
1421
+ name: arg.slice(2),
1422
+ raw: arg
1323
1423
  });
1324
1424
  } else if (arg.length > 1) {
1325
1425
  const flags = arg.slice(1);
@@ -1345,7 +1445,7 @@ const lexTokens = (args) => {
1345
1445
  return tokens;
1346
1446
  };
1347
1447
  //#endregion
1348
- //#region node_modules/.pnpm/effect@4.0.0-beta.102_patch_hash=71215759e1ac0a7f65d7b75d816986687ae6c3a6cba02d928d184ca71790d488/node_modules/effect/dist/unstable/cli/internal/auto-suggest.js
1448
+ //#region node_modules/.pnpm/effect@4.0.0-beta.103_patch_hash=af36b7948b6f9c56623074662b51dade5699880c1a7c71245de73e13c3185fb6/node_modules/effect/dist/unstable/cli/internal/auto-suggest.js
1349
1449
  /**
1350
1450
  * Simple Levenshtein distance implementation (small N, no perf worries)
1351
1451
  */
@@ -1373,7 +1473,7 @@ const suggest = (input, candidates) => {
1373
1473
  return distances.filter(([d]) => d === minDistance).map(([, c]) => c);
1374
1474
  };
1375
1475
  //#endregion
1376
- //#region node_modules/.pnpm/effect@4.0.0-beta.102_patch_hash=71215759e1ac0a7f65d7b75d816986687ae6c3a6cba02d928d184ca71790d488/node_modules/effect/dist/unstable/cli/internal/parser.js
1476
+ //#region node_modules/.pnpm/effect@4.0.0-beta.103_patch_hash=af36b7948b6f9c56623074662b51dade5699880c1a7c71245de73e13c3185fb6/node_modules/effect/dist/unstable/cli/internal/parser.js
1377
1477
  /**
1378
1478
  * Parsing Pipeline for CLI Commands
1379
1479
  * ==================================
@@ -1431,13 +1531,13 @@ const parseArgs = (lexResult, command, commandPath = []) => gen(function* () {
1431
1531
  };
1432
1532
  const subLex = {
1433
1533
  tokens: result.childTokens,
1434
- trailingOperands: []
1534
+ trailingOperands: afterEndOfOptions
1435
1535
  };
1436
1536
  const subParsed = yield* parseArgs(subLex, result.sub, newCommandPath);
1437
1537
  const allErrors = [...result.errors, ...subParsed.errors ?? []];
1438
1538
  return {
1439
1539
  flags: result.flags,
1440
- arguments: afterEndOfOptions,
1540
+ arguments: [],
1441
1541
  subcommand: some({
1442
1542
  name: result.sub.name,
1443
1543
  parsedInput: subParsed
@@ -1901,7 +2001,7 @@ const scanCommandLevel = (tokens, context) => {
1901
2001
  return toLeafResult(state);
1902
2002
  };
1903
2003
  //#endregion
1904
- //#region node_modules/.pnpm/effect@4.0.0-beta.102_patch_hash=71215759e1ac0a7f65d7b75d816986687ae6c3a6cba02d928d184ca71790d488/node_modules/effect/dist/unstable/cli/internal/wizard.js
2004
+ //#region node_modules/.pnpm/effect@4.0.0-beta.103_patch_hash=af36b7948b6f9c56623074662b51dade5699880c1a7c71245de73e13c3185fb6/node_modules/effect/dist/unstable/cli/internal/wizard.js
1905
2005
  const run$1 = /*#__PURE__*/ fnUntraced(function* (command, options) {
1906
2006
  const commandPath = options?.commandPath ?? [command.name];
1907
2007
  const selected = getCommandAtPath(command, commandPath);
@@ -2061,7 +2161,7 @@ const wrapCommand = (commandLine) => {
2061
2161
  };
2062
2162
  const formatShellArg = (arg) => /^[A-Za-z0-9_./:@%+=,-]+$/.test(arg) ? arg : `'${arg.replaceAll("'", `'"'"'`)}'`;
2063
2163
  //#endregion
2064
- //#region node_modules/.pnpm/effect@4.0.0-beta.102_patch_hash=71215759e1ac0a7f65d7b75d816986687ae6c3a6cba02d928d184ca71790d488/node_modules/effect/dist/unstable/cli/Command.js
2164
+ //#region node_modules/.pnpm/effect@4.0.0-beta.103_patch_hash=af36b7948b6f9c56623074662b51dade5699880c1a7c71245de73e13c3185fb6/node_modules/effect/dist/unstable/cli/Command.js
2065
2165
  /**
2066
2166
  * Returns `true` if the provided value is a `Command`.
2067
2167
  *
@@ -2086,9 +2186,27 @@ const isCommand = (u) => hasProperty(u, TypeId$3);
2086
2186
  *
2087
2187
  * **Example** (Creating commands)
2088
2188
  *
2089
- * ```ts
2090
- * import { Console, Effect } from "effect"
2189
+ * ```ts import.meta.vitest
2190
+ * import { Effect, FileSystem, Layer, Path, Stdio, Terminal } from "effect"
2091
2191
  * import { Argument, Command, Flag } from "effect/unstable/cli"
2192
+ * import { ChildProcessSpawner } from "effect/unstable/process"
2193
+ *
2194
+ * const CliTestLayer = Layer.mergeAll(
2195
+ * FileSystem.layerNoop({}),
2196
+ * Path.layer,
2197
+ * Stdio.layerTest({}),
2198
+ * Layer.succeed(Terminal.Terminal, Terminal.make({
2199
+ * columns: Effect.succeed(80),
2200
+ * rows: Effect.succeed(24),
2201
+ * readInput: Effect.die("unused"),
2202
+ * readLine: Effect.die("unused"),
2203
+ * display: () => Effect.void
2204
+ * })),
2205
+ * Layer.succeed(
2206
+ * ChildProcessSpawner.ChildProcessSpawner,
2207
+ * ChildProcessSpawner.make(() => Effect.die("unused"))
2208
+ * )
2209
+ * )
2092
2210
  *
2093
2211
  * // Simple command with no configuration
2094
2212
  * const version = Command.make("version")
@@ -2113,19 +2231,29 @@ const isCommand = (u) => hasProperty(u, TypeId$3);
2113
2231
  * })
2114
2232
  *
2115
2233
  * // Command with handler
2234
+ * const output: Array<string> = []
2116
2235
  * const deployWithHandler = Command.make("deploy", {
2117
2236
  * environment: Flag.string("env"),
2118
2237
  * force: Flag.boolean("force")
2119
2238
  * }, (config) =>
2120
2239
  * Effect.gen(function*() {
2121
- * yield* Console.log(`Starting deployment to ${config.environment}`)
2240
+ * yield* Effect.sync(() => output.push(`Starting deployment to ${config.environment}`))
2122
2241
  *
2123
2242
  * if (!config.force && config.environment === "production") {
2124
2243
  * return yield* Effect.fail("Production deployments require --force flag")
2125
2244
  * }
2126
2245
  *
2127
- * yield* Console.log("Deployment completed successfully")
2246
+ * yield* Effect.sync(() => output.push("Deployment completed successfully"))
2128
2247
  * }))
2248
+ *
2249
+ * await Effect.runPromise(
2250
+ * Command.runWith(deployWithHandler, { version: "1.0.0" })([
2251
+ * "--env",
2252
+ * "staging",
2253
+ * "--force"
2254
+ * ]).pipe(Effect.provide(CliTestLayer))
2255
+ * )
2256
+ * output // => ["Starting deployment to staging", "Deployment completed successfully"]
2129
2257
  * ```
2130
2258
  *
2131
2259
  * @category constructors
@@ -2183,9 +2311,27 @@ const normalizeSubcommandEntries = (entries) => {
2183
2311
  *
2184
2312
  * **Example** (Adding subcommands)
2185
2313
  *
2186
- * ```ts
2187
- * import { Console, Effect } from "effect"
2314
+ * ```ts import.meta.vitest
2315
+ * import { Effect, FileSystem, Layer, Path, Stdio, Terminal } from "effect"
2188
2316
  * import { Command, Flag } from "effect/unstable/cli"
2317
+ * import { ChildProcessSpawner } from "effect/unstable/process"
2318
+ *
2319
+ * const CliTestLayer = Layer.mergeAll(
2320
+ * FileSystem.layerNoop({}),
2321
+ * Path.layer,
2322
+ * Stdio.layerTest({}),
2323
+ * Layer.succeed(Terminal.Terminal, Terminal.make({
2324
+ * columns: Effect.succeed(80),
2325
+ * rows: Effect.succeed(24),
2326
+ * readInput: Effect.die("unused"),
2327
+ * readLine: Effect.die("unused"),
2328
+ * display: () => Effect.void
2329
+ * })),
2330
+ * Layer.succeed(
2331
+ * ChildProcessSpawner.ChildProcessSpawner,
2332
+ * ChildProcessSpawner.make(() => Effect.die("unused"))
2333
+ * )
2334
+ * )
2189
2335
  *
2190
2336
  * // Parent command with shared flags
2191
2337
  * const git = Command.make("git").pipe(
@@ -2195,19 +2341,29 @@ const normalizeSubcommandEntries = (entries) => {
2195
2341
  * )
2196
2342
  *
2197
2343
  * // Subcommand that accesses parent config
2344
+ * const output: Array<string> = []
2198
2345
  * const clone = Command.make("clone", {
2199
2346
  * repository: Flag.string("repo")
2200
2347
  * }, (config) =>
2201
2348
  * Effect.gen(function*() {
2202
2349
  * const parent = yield* git // Access parent's parsed config
2203
2350
  * if (parent.verbose) {
2204
- * yield* Console.log("Verbose mode enabled")
2351
+ * yield* Effect.sync(() => output.push("Verbose mode enabled"))
2205
2352
  * }
2206
- * yield* Console.log(`Cloning ${config.repository}`)
2353
+ * yield* Effect.sync(() => output.push(`Cloning ${config.repository}`))
2207
2354
  * }))
2208
2355
  *
2209
2356
  * const app = git.pipe(Command.withSubcommands([clone]))
2210
- * // Usage: git --verbose clone --repo github.com/foo/bar
2357
+ *
2358
+ * await Effect.runPromise(
2359
+ * Command.runWith(app, { version: "1.0.0" })([
2360
+ * "--verbose",
2361
+ * "clone",
2362
+ * "--repo",
2363
+ * "github.com/foo/bar"
2364
+ * ]).pipe(Effect.provide(CliTestLayer))
2365
+ * )
2366
+ * output // => ["Verbose mode enabled", "Cloning github.com/foo/bar"]
2211
2367
  * ```
2212
2368
  *
2213
2369
  * @category combinators
@@ -2290,18 +2446,42 @@ const withGlobalFlags = /*#__PURE__*/ dual(2, (self, globalFlags) => {
2290
2446
  *
2291
2447
  * **Example** (Setting descriptions)
2292
2448
  *
2293
- * ```ts
2294
- * import { Console, Effect } from "effect"
2449
+ * ```ts import.meta.vitest
2450
+ * import { Effect, FileSystem, Layer, Path, Stdio, Terminal } from "effect"
2295
2451
  * import { Command, Flag } from "effect/unstable/cli"
2452
+ * import { ChildProcessSpawner } from "effect/unstable/process"
2453
+ *
2454
+ * const CliTestLayer = Layer.mergeAll(
2455
+ * FileSystem.layerNoop({}),
2456
+ * Path.layer,
2457
+ * Stdio.layerTest({}),
2458
+ * Layer.succeed(Terminal.Terminal, Terminal.make({
2459
+ * columns: Effect.succeed(80),
2460
+ * rows: Effect.succeed(24),
2461
+ * readInput: Effect.die("unused"),
2462
+ * readLine: Effect.die("unused"),
2463
+ * display: () => Effect.void
2464
+ * })),
2465
+ * Layer.succeed(
2466
+ * ChildProcessSpawner.ChildProcessSpawner,
2467
+ * ChildProcessSpawner.make(() => Effect.die("unused"))
2468
+ * )
2469
+ * )
2296
2470
  *
2471
+ * const output: Array<string> = []
2297
2472
  * const deploy = Command.make("deploy", {
2298
2473
  * environment: Flag.string("env")
2299
2474
  * }, (config) =>
2300
2475
  * Effect.gen(function*() {
2301
- * yield* Console.log(`Deploying to ${config.environment}`)
2476
+ * yield* Effect.sync(() => output.push(`Deploying to ${config.environment}`))
2302
2477
  * })).pipe(
2303
2478
  * Command.withDescription("Deploy the application to a specified environment")
2304
2479
  * )
2480
+ *
2481
+ * await Effect.runPromise(
2482
+ * Command.runWith(deploy, { version: "1.0.0" })(["--env", "staging"]).pipe(Effect.provide(CliTestLayer))
2483
+ * )
2484
+ * output // => ["Deploying to staging"]
2305
2485
  * ```
2306
2486
  *
2307
2487
  * @category combinators
@@ -2350,26 +2530,50 @@ const showHelp = (command, error$1) => gen(function* () {
2350
2530
  *
2351
2531
  * **Example** (Running commands with standard input)
2352
2532
  *
2353
- * ```ts
2354
- * import { Console, Effect } from "effect"
2533
+ * ```ts import.meta.vitest
2534
+ * import { Effect, FileSystem, Layer, Path, Stdio, Terminal } from "effect"
2355
2535
  * import { Command, Flag } from "effect/unstable/cli"
2536
+ * import { ChildProcessSpawner } from "effect/unstable/process"
2537
+ *
2538
+ * const CliTestLayer = Layer.mergeAll(
2539
+ * FileSystem.layerNoop({}),
2540
+ * Path.layer,
2541
+ * Stdio.layerTest({
2542
+ * args: Effect.succeed(["--name", "Alice"])
2543
+ * }),
2544
+ * Layer.succeed(Terminal.Terminal, Terminal.make({
2545
+ * columns: Effect.succeed(80),
2546
+ * rows: Effect.succeed(24),
2547
+ * readInput: Effect.die("unused"),
2548
+ * readLine: Effect.die("unused"),
2549
+ * display: () => Effect.void
2550
+ * })),
2551
+ * Layer.succeed(
2552
+ * ChildProcessSpawner.ChildProcessSpawner,
2553
+ * ChildProcessSpawner.make(() => Effect.die("unused"))
2554
+ * )
2555
+ * )
2356
2556
  *
2557
+ * const output: Array<string> = []
2357
2558
  * const greetCommand = Command.make("greet", {
2358
2559
  * name: Flag.string("name")
2359
2560
  * }, (config) =>
2360
2561
  * Effect.gen(function*() {
2361
- * yield* Console.log(`Hello, ${config.name}!`)
2562
+ * yield* Effect.sync(() => output.push(`Hello, ${config.name}!`))
2362
2563
  * }))
2363
2564
  *
2364
2565
  * // Automatically gets args from the Stdio service
2365
2566
  * const program = Command.run(greetCommand, {
2366
2567
  * version: "1.0.0"
2367
2568
  * })
2569
+ *
2570
+ * await Effect.runPromise(program.pipe(Effect.provide(CliTestLayer)))
2571
+ * output // => ["Hello, Alice!"]
2368
2572
  * ```
2369
2573
  *
2370
2574
  * @see {@link runWith} for running a command with an explicit argument array
2371
2575
  *
2372
- * @category command execution
2576
+ * @category running
2373
2577
  * @since 4.0.0
2374
2578
  */
2375
2579
  const run = /*#__PURE__*/ dual(2, (command, config) => Stdio.use(({ args }) => flatMap(args, (args) => runWith(command, config)(args))));
@@ -2383,17 +2587,36 @@ const run = /*#__PURE__*/ dual(2, (command, config) => Stdio.use(({ args }) => f
2383
2587
  *
2384
2588
  * **Example** (Running commands with explicit arguments)
2385
2589
  *
2386
- * ```ts
2387
- * import { Console, Effect } from "effect"
2590
+ * ```ts import.meta.vitest
2591
+ * import { Effect, FileSystem, Layer, Path, Stdio, Terminal } from "effect"
2388
2592
  * import { Command, Flag } from "effect/unstable/cli"
2593
+ * import { ChildProcessSpawner } from "effect/unstable/process"
2594
+ *
2595
+ * const CliTestLayer = Layer.mergeAll(
2596
+ * FileSystem.layerNoop({}),
2597
+ * Path.layer,
2598
+ * Stdio.layerTest({}),
2599
+ * Layer.succeed(Terminal.Terminal, Terminal.make({
2600
+ * columns: Effect.succeed(80),
2601
+ * rows: Effect.succeed(24),
2602
+ * readInput: Effect.die("unused"),
2603
+ * readLine: Effect.die("unused"),
2604
+ * display: () => Effect.void
2605
+ * })),
2606
+ * Layer.succeed(
2607
+ * ChildProcessSpawner.ChildProcessSpawner,
2608
+ * ChildProcessSpawner.make(() => Effect.die("unused"))
2609
+ * )
2610
+ * )
2389
2611
  *
2612
+ * const output: Array<string> = []
2390
2613
  * const greet = Command.make("greet", {
2391
2614
  * name: Flag.string("name"),
2392
2615
  * count: Flag.integer("count").pipe(Flag.withDefault(1))
2393
2616
  * }, (config) =>
2394
2617
  * Effect.gen(function*() {
2395
2618
  * for (let i = 0; i < config.count; i++) {
2396
- * yield* Console.log(`Hello, ${config.name}!`)
2619
+ * yield* Effect.sync(() => output.push(`Hello, ${config.name}!`))
2397
2620
  * }
2398
2621
  * }))
2399
2622
  *
@@ -2401,18 +2624,14 @@ const run = /*#__PURE__*/ dual(2, (command, config) => Stdio.use(({ args }) => f
2401
2624
  * const testProgram = Effect.gen(function*() {
2402
2625
  * const runCommand = Command.runWith(greet, { version: "1.0.0" })
2403
2626
  *
2404
- * // Test normal execution
2405
2627
  * yield* runCommand(["--name", "Alice", "--count", "2"])
2406
- *
2407
- * // Test help display
2408
- * yield* runCommand(["--help"])
2409
- *
2410
- * // Test version display
2411
- * yield* runCommand(["--version"])
2412
2628
  * })
2629
+ *
2630
+ * await Effect.runPromise(testProgram.pipe(Effect.provide(CliTestLayer)))
2631
+ * output // => ["Hello, Alice!", "Hello, Alice!"]
2413
2632
  * ```
2414
2633
  *
2415
- * @category command execution
2634
+ * @category running
2416
2635
  * @since 4.0.0
2417
2636
  */
2418
2637
  const runWith = (command, config) => {
@@ -86320,7 +86539,7 @@ const result = (self) => {
86320
86539
  };
86321
86540
  };
86322
86541
  //#endregion
86323
- //#region node_modules/.pnpm/effect@4.0.0-beta.102_patch_hash=71215759e1ac0a7f65d7b75d816986687ae6c3a6cba02d928d184ca71790d488/node_modules/effect/dist/Match.js
86542
+ //#region node_modules/.pnpm/effect@4.0.0-beta.103_patch_hash=af36b7948b6f9c56623074662b51dade5699880c1a7c71245de73e13c3185fb6/node_modules/effect/dist/Match.js
86324
86543
  /**
86325
86544
  * Builds pattern matchers for TypeScript values.
86326
86545
  *
@@ -86352,7 +86571,7 @@ const result = (self) => {
86352
86571
  *
86353
86572
  * **Example** (Matching an Object by Property)
86354
86573
  *
86355
- * ```ts
86574
+ * ```ts import.meta.vitest
86356
86575
  * import { Match } from "effect"
86357
86576
  *
86358
86577
  * const input = { name: "John", age: 30 }
@@ -86368,8 +86587,7 @@ const result = (self) => {
86368
86587
  * Match.orElse(() => "Oh, not John")
86369
86588
  * )
86370
86589
  *
86371
- * console.log(result)
86372
- * // Output: "John is 30 years old"
86590
+ * result // => "John is 30 years old"
86373
86591
  * ```
86374
86592
  *
86375
86593
  * @see {@link type} for creating a matcher from a specific type.
@@ -86395,7 +86613,7 @@ const value = value$1;
86395
86613
  *
86396
86614
  * **Example** (Matching with values and predicates)
86397
86615
  *
86398
- * ```ts
86616
+ * ```ts import.meta.vitest
86399
86617
  * import { Match } from "effect"
86400
86618
  *
86401
86619
  * // Create a matcher for objects with an "age" property
@@ -86411,14 +86629,11 @@ const value = value$1;
86411
86629
  * Match.orElse((user: { age: number }) => `${user.age} is too young`)
86412
86630
  * )
86413
86631
  *
86414
- * console.log(match({ age: 20 }))
86415
- * // Output: "Age: 20"
86632
+ * match({ age: 20 }) // => "Age: 20"
86416
86633
  *
86417
- * console.log(match({ age: 18 }))
86418
- * // Output: "You can vote"
86634
+ * match({ age: 18 }) // => "You can vote"
86419
86635
  *
86420
- * console.log(match({ age: 4 }))
86421
- * // Output: "4 is too young"
86636
+ * match({ age: 4 }) // => "4 is too young"
86422
86637
  * ```
86423
86638
  *
86424
86639
  * @see {@link whenOr} for handling any one of several patterns with the same handler
@@ -86426,7 +86641,7 @@ const value = value$1;
86426
86641
  * @see {@link not} for handling inputs that do not match a pattern
86427
86642
  * @see {@link orElse} for providing a fallback when no pattern case matches
86428
86643
  *
86429
- * @category Defining patterns
86644
+ * @category defining patterns
86430
86645
  * @since 4.0.0
86431
86646
  */
86432
86647
  const when = when$1;
@@ -86445,7 +86660,7 @@ const when = when$1;
86445
86660
  *
86446
86661
  * **Example** (Matching a discriminated union by tag)
86447
86662
  *
86448
- * ```ts
86663
+ * ```ts import.meta.vitest
86449
86664
  * import { Match } from "effect"
86450
86665
  *
86451
86666
  * type Event =
@@ -86464,14 +86679,12 @@ const when = when$1;
86464
86679
  * Match.exhaustive
86465
86680
  * )
86466
86681
  *
86467
- * console.log(match({ _tag: "success", data: "Hello" }))
86468
- * // Output: "Ok!"
86682
+ * match({ _tag: "success", data: "Hello" }) // => "Ok!"
86469
86683
  *
86470
- * console.log(match({ _tag: "error", error: new Error("Oops!") }))
86471
- * // Output: "Error: Oops!"
86684
+ * match({ _tag: "error", error: new Error("Oops!") }) // => "Error: Oops!"
86472
86685
  * ```
86473
86686
  *
86474
- * @category Defining patterns
86687
+ * @category defining patterns
86475
86688
  * @since 4.0.0
86476
86689
  */
86477
86690
  const tag = tag$1;
@@ -86491,7 +86704,7 @@ const tag = tag$1;
86491
86704
  *
86492
86705
  * **Example** (Providing a default value when no patterns match)
86493
86706
  *
86494
- * ```ts
86707
+ * ```ts import.meta.vitest
86495
86708
  * import { Match } from "effect"
86496
86709
  *
86497
86710
  * // Create a matcher for string or number values
@@ -86502,11 +86715,9 @@ const tag = tag$1;
86502
86715
  * Match.orElse(() => "fallback")
86503
86716
  * )
86504
86717
  *
86505
- * console.log(match("a"))
86506
- * // Output: "ok"
86718
+ * match("a") // => "ok"
86507
86719
  *
86508
- * console.log(match("b"))
86509
- * // Output: "fallback"
86720
+ * match("b") // => "fallback"
86510
86721
  * ```
86511
86722
  *
86512
86723
  * @see {@link option} for finalizing unmatched input as `Option.none`
@@ -87827,133 +88038,6 @@ const addCommand = make("add", {
87827
88038
  else yield* output.printInfo(formatProjectAddedHuman(result.project));
87828
88039
  })).pipe(withDescription("add project"));
87829
88040
  //#endregion
87830
- //#region src/cli/threads/approve.ts
87831
- const approvalDecisionFlag = choice("decision", [
87832
- "accept",
87833
- "decline",
87834
- "cancel"
87835
- ]).pipe(withDescription$1("Approval decision"));
87836
- const approveThreadCommand = make("approve", {
87837
- thread: threadFlag,
87838
- request: string$2("request").pipe(withDescription$1("Pending approval request id"), optional$2),
87839
- decision: approvalDecisionFlag,
87840
- format: formatFlag,
87841
- ...extraArgsConfig
87842
- }, ({ thread, request, decision, format }) => gen(function* () {
87843
- const application = yield* T3Application;
87844
- const cliRuntime = yield* CliRuntime;
87845
- const t3CliEnv = yield* loadT3CliEnv;
87846
- const output = yield* T3Output;
87847
- const threadId = resolveThreadId({
87848
- value: getOrUndefined(thread),
87849
- scope: t3CliEnv.scope
87850
- });
87851
- if (threadId === void 0) return yield* fail(new MissingThreadError({ message: "thread id is required: pass --thread or set T3CODE_THREAD_ID" }));
87852
- const requestId = getOrUndefined(request);
87853
- if (requestId === void 0 || requestId.length === 0) return yield* fail(new MissingRequestError({ message: "request id is required: pass --request" }));
87854
- const resolvedFormat = resolveOutputFormat(format, cliRuntime, t3CliEnv, "json");
87855
- const result = yield* application.approveThread({
87856
- threadId,
87857
- requestId,
87858
- decision
87859
- });
87860
- if (resolvedFormat === "json") return yield* output.printJson(result);
87861
- return yield* output.printInfo(`approval submitted: ${result.requestId} (sequence ${result.dispatch.sequence})`);
87862
- })).pipe(withDescription("respond to a pending approval request"));
87863
- //#endregion
87864
- //#region src/cli/interaction/self-action.ts
87865
- const requireSelfActionConfirmation = fn("requireSelfActionConfirmation")(function* (input) {
87866
- if (input.force) return;
87867
- if (!isAgentEnvironment(input.t3CliEnv)) return;
87868
- const callerThreadId = input.t3CliEnv.scope.t3codeThreadId;
87869
- if (callerThreadId === void 0 || callerThreadId.length === 0) return;
87870
- if (input.threadId !== callerThreadId) return;
87871
- yield* fail(new SelfActionError({
87872
- threadId: input.threadId,
87873
- message: `cannot ${input.action} thread ${input.threadId}: command targets the calling thread. Pass --force to confirm.`
87874
- }));
87875
- });
87876
- //#endregion
87877
- //#region src/cli/threads/archive.ts
87878
- const archiveThreadCommand = make("archive", {
87879
- thread: threadFlag,
87880
- force: selfActionForceFlag,
87881
- format: formatFlag,
87882
- ...extraArgsConfig
87883
- }, ({ thread, force, format }) => gen(function* () {
87884
- const application = yield* T3Application;
87885
- const cliRuntime = yield* CliRuntime;
87886
- const t3CliEnv = yield* loadT3CliEnv;
87887
- const output = yield* T3Output;
87888
- const threadId = resolveThreadId({
87889
- value: getOrUndefined(thread),
87890
- scope: t3CliEnv.scope
87891
- });
87892
- if (threadId === void 0) return yield* fail(new MissingThreadError({ message: "thread id is required: pass --thread or set T3CODE_THREAD_ID" }));
87893
- yield* requireSelfActionConfirmation({
87894
- threadId,
87895
- force,
87896
- cliRuntime,
87897
- t3CliEnv,
87898
- action: "archive"
87899
- });
87900
- const resolvedFormat = resolveOutputFormat(format, cliRuntime, t3CliEnv, "json");
87901
- const dispatch = yield* application.archiveThread(threadId);
87902
- if (resolvedFormat === "json") return yield* output.printJson(dispatch);
87903
- return yield* output.printInfo(`thread archived: ${threadId} (sequence ${dispatch.sequence})`);
87904
- })).pipe(withDescription("archive thread"));
87905
- //#endregion
87906
- //#region src/cli/threads/callback.ts
87907
- const callbackThreadCommand = make("callback", {
87908
- from: string$2("from").pipe(withDescription$1("Thread ID to watch for completion")),
87909
- thread: threadFlag,
87910
- prompt: string$2("prompt").pipe(withDescription$1("Message to send to target thread")),
87911
- background: boolean("background").pipe(withDescription$1("Fork and detach as background process"), optional$2),
87912
- ...extraArgsConfig
87913
- }, ({ from, thread, prompt, background }) => gen(function* () {
87914
- const application = yield* T3Application;
87915
- const t3CliEnv = yield* loadT3CliEnv;
87916
- const output = yield* T3Output;
87917
- const cliPath = yield* CliPath;
87918
- const spawner = yield* ChildProcessSpawner;
87919
- const fromThreadId = from;
87920
- const targetThreadId = resolveThreadId({
87921
- value: getOrUndefined(thread),
87922
- scope: t3CliEnv.scope
87923
- });
87924
- if (targetThreadId === void 0) return yield* fail(new MissingThreadError({ message: "target thread id is required: pass --thread or set T3CODE_THREAD_ID" }));
87925
- if (getOrElse(background, () => false)) {
87926
- const args = [
87927
- cliPath.path,
87928
- "thread",
87929
- "callback",
87930
- "--from",
87931
- fromThreadId,
87932
- "--thread",
87933
- targetThreadId,
87934
- "--prompt",
87935
- prompt
87936
- ];
87937
- const proc = make$5(process.execPath, args, {
87938
- detached: true,
87939
- stdin: "ignore",
87940
- stdout: "ignore",
87941
- stderr: "ignore"
87942
- });
87943
- const handle = yield* spawner.spawn(proc);
87944
- yield* handle.unref.pipe(ignore);
87945
- yield* output.printInfo(`background callback scheduled: ${fromThreadId} -> ${targetThreadId} (pid: ${handle.pid})`);
87946
- return;
87947
- }
87948
- yield* output.printInfo(`watching thread ${fromThreadId} for completion...`);
87949
- const result = yield* application.callbackThread({
87950
- fromThreadId,
87951
- targetThreadId,
87952
- prompt
87953
- });
87954
- yield* output.printInfo(`callback sent to ${result.targetThreadId} (dispatch: ${result.dispatch.sequence})`);
87955
- })).pipe(withDescription("watch a thread and send a message when it completes"));
87956
- //#endregion
87957
88041
  //#region src/cli/format/thread.ts
87958
88042
  function formatThreadShowJson(thread) {
87959
88043
  return {
@@ -88106,6 +88190,51 @@ function formatThreadsHuman(threads) {
88106
88190
  }
88107
88191
  ], threads)}\n`;
88108
88192
  }
88193
+ function formatThreadSearchHuman(matches) {
88194
+ if (matches.length === 0) return "no matches\n";
88195
+ return `${matches.map((match) => formatRecord([
88196
+ {
88197
+ field: "thread",
88198
+ value: match.threadTitle ?? "-"
88199
+ },
88200
+ {
88201
+ field: "thread id",
88202
+ value: match.threadId
88203
+ },
88204
+ {
88205
+ field: "project",
88206
+ value: match.projectTitle ?? "-"
88207
+ },
88208
+ {
88209
+ field: "project id",
88210
+ value: match.projectId
88211
+ },
88212
+ {
88213
+ field: "workspace",
88214
+ value: match.workspaceRoot ?? "-"
88215
+ },
88216
+ {
88217
+ field: "branch",
88218
+ value: match.branch ?? "-"
88219
+ },
88220
+ {
88221
+ field: "worktree",
88222
+ value: match.worktreePath ?? "-"
88223
+ },
88224
+ {
88225
+ field: "source",
88226
+ value: match.source
88227
+ },
88228
+ {
88229
+ field: "created",
88230
+ value: match.messageCreatedAt ?? "-"
88231
+ },
88232
+ {
88233
+ field: "snippet",
88234
+ value: match.snippet
88235
+ }
88236
+ ])).join("\n\n")}\n`;
88237
+ }
88109
88238
  function formatThreadDeletedHuman(input) {
88110
88239
  return `thread deleted: ${input.threadId} (sequence ${input.dispatch.sequence})`;
88111
88240
  }
@@ -88173,6 +88302,158 @@ function stripThreadHeavy(thread) {
88173
88302
  return rest;
88174
88303
  }
88175
88304
  //#endregion
88305
+ //#region src/cli/search.ts
88306
+ const searchThreadsCommand = make("search", {
88307
+ query: string("query"),
88308
+ limit: integer$1("limit").pipe(withDescription$1("Maximum matches (1-50, default: 50)"), optional$2),
88309
+ format: formatFlag,
88310
+ ...extraArgsConfig
88311
+ }, ({ query, limit, format }) => gen(function* () {
88312
+ const value = getOrUndefined(limit);
88313
+ if (value !== void 0 && (value < 1 || value > 50)) return yield* fail(new InvalidLimitError({
88314
+ message: `invalid limit: ${value}`,
88315
+ value: String(value)
88316
+ }));
88317
+ const application = yield* T3Application;
88318
+ const cliRuntime = yield* CliRuntime;
88319
+ const t3CliEnv = yield* loadT3CliEnv;
88320
+ const output = yield* T3Output;
88321
+ const resolvedFormat = resolveOutputFormat(format, cliRuntime, t3CliEnv, "json");
88322
+ const matches = yield* application.searchThreads({
88323
+ query,
88324
+ ...value !== void 0 ? { limit: value } : {}
88325
+ });
88326
+ if (resolvedFormat === "json") return yield* output.printJson(matches);
88327
+ return yield* output.writeStdout(formatThreadSearchHuman(matches));
88328
+ })).pipe(withDescription("search threads by conversation content"));
88329
+ //#endregion
88330
+ //#region src/cli/threads/approve.ts
88331
+ const approvalDecisionFlag = choice("decision", [
88332
+ "accept",
88333
+ "decline",
88334
+ "cancel"
88335
+ ]).pipe(withDescription$1("Approval decision"));
88336
+ const approveThreadCommand = make("approve", {
88337
+ thread: threadFlag,
88338
+ request: string$2("request").pipe(withDescription$1("Pending approval request id"), optional$2),
88339
+ decision: approvalDecisionFlag,
88340
+ format: formatFlag,
88341
+ ...extraArgsConfig
88342
+ }, ({ thread, request, decision, format }) => gen(function* () {
88343
+ const application = yield* T3Application;
88344
+ const cliRuntime = yield* CliRuntime;
88345
+ const t3CliEnv = yield* loadT3CliEnv;
88346
+ const output = yield* T3Output;
88347
+ const threadId = resolveThreadId({
88348
+ value: getOrUndefined(thread),
88349
+ scope: t3CliEnv.scope
88350
+ });
88351
+ if (threadId === void 0) return yield* fail(new MissingThreadError({ message: "thread id is required: pass --thread or set T3CODE_THREAD_ID" }));
88352
+ const requestId = getOrUndefined(request);
88353
+ if (requestId === void 0 || requestId.length === 0) return yield* fail(new MissingRequestError({ message: "request id is required: pass --request" }));
88354
+ const resolvedFormat = resolveOutputFormat(format, cliRuntime, t3CliEnv, "json");
88355
+ const result = yield* application.approveThread({
88356
+ threadId,
88357
+ requestId,
88358
+ decision
88359
+ });
88360
+ if (resolvedFormat === "json") return yield* output.printJson(result);
88361
+ return yield* output.printInfo(`approval submitted: ${result.requestId} (sequence ${result.dispatch.sequence})`);
88362
+ })).pipe(withDescription("respond to a pending approval request"));
88363
+ //#endregion
88364
+ //#region src/cli/interaction/self-action.ts
88365
+ const requireSelfActionConfirmation = fn("requireSelfActionConfirmation")(function* (input) {
88366
+ if (input.force) return;
88367
+ if (!isAgentEnvironment(input.t3CliEnv)) return;
88368
+ const callerThreadId = input.t3CliEnv.scope.t3codeThreadId;
88369
+ if (callerThreadId === void 0 || callerThreadId.length === 0) return;
88370
+ if (input.threadId !== callerThreadId) return;
88371
+ yield* fail(new SelfActionError({
88372
+ threadId: input.threadId,
88373
+ message: `cannot ${input.action} thread ${input.threadId}: command targets the calling thread. Pass --force to confirm.`
88374
+ }));
88375
+ });
88376
+ //#endregion
88377
+ //#region src/cli/threads/archive.ts
88378
+ const archiveThreadCommand = make("archive", {
88379
+ thread: threadFlag,
88380
+ force: selfActionForceFlag,
88381
+ format: formatFlag,
88382
+ ...extraArgsConfig
88383
+ }, ({ thread, force, format }) => gen(function* () {
88384
+ const application = yield* T3Application;
88385
+ const cliRuntime = yield* CliRuntime;
88386
+ const t3CliEnv = yield* loadT3CliEnv;
88387
+ const output = yield* T3Output;
88388
+ const threadId = resolveThreadId({
88389
+ value: getOrUndefined(thread),
88390
+ scope: t3CliEnv.scope
88391
+ });
88392
+ if (threadId === void 0) return yield* fail(new MissingThreadError({ message: "thread id is required: pass --thread or set T3CODE_THREAD_ID" }));
88393
+ yield* requireSelfActionConfirmation({
88394
+ threadId,
88395
+ force,
88396
+ cliRuntime,
88397
+ t3CliEnv,
88398
+ action: "archive"
88399
+ });
88400
+ const resolvedFormat = resolveOutputFormat(format, cliRuntime, t3CliEnv, "json");
88401
+ const dispatch = yield* application.archiveThread(threadId);
88402
+ if (resolvedFormat === "json") return yield* output.printJson(dispatch);
88403
+ return yield* output.printInfo(`thread archived: ${threadId} (sequence ${dispatch.sequence})`);
88404
+ })).pipe(withDescription("archive thread"));
88405
+ //#endregion
88406
+ //#region src/cli/threads/callback.ts
88407
+ const callbackThreadCommand = make("callback", {
88408
+ from: string$2("from").pipe(withDescription$1("Thread ID to watch for completion")),
88409
+ thread: threadFlag,
88410
+ prompt: string$2("prompt").pipe(withDescription$1("Message to send to target thread")),
88411
+ background: boolean("background").pipe(withDescription$1("Fork and detach as background process"), optional$2),
88412
+ ...extraArgsConfig
88413
+ }, ({ from, thread, prompt, background }) => gen(function* () {
88414
+ const application = yield* T3Application;
88415
+ const t3CliEnv = yield* loadT3CliEnv;
88416
+ const output = yield* T3Output;
88417
+ const cliPath = yield* CliPath;
88418
+ const spawner = yield* ChildProcessSpawner;
88419
+ const fromThreadId = from;
88420
+ const targetThreadId = resolveThreadId({
88421
+ value: getOrUndefined(thread),
88422
+ scope: t3CliEnv.scope
88423
+ });
88424
+ if (targetThreadId === void 0) return yield* fail(new MissingThreadError({ message: "target thread id is required: pass --thread or set T3CODE_THREAD_ID" }));
88425
+ if (getOrElse(background, () => false)) {
88426
+ const args = [
88427
+ cliPath.path,
88428
+ "thread",
88429
+ "callback",
88430
+ "--from",
88431
+ fromThreadId,
88432
+ "--thread",
88433
+ targetThreadId,
88434
+ "--prompt",
88435
+ prompt
88436
+ ];
88437
+ const proc = make$5(process.execPath, args, {
88438
+ detached: true,
88439
+ stdin: "ignore",
88440
+ stdout: "ignore",
88441
+ stderr: "ignore"
88442
+ });
88443
+ const handle = yield* spawner.spawn(proc);
88444
+ yield* handle.unref.pipe(ignore);
88445
+ yield* output.printInfo(`background callback scheduled: ${fromThreadId} -> ${targetThreadId} (pid: ${handle.pid})`);
88446
+ return;
88447
+ }
88448
+ yield* output.printInfo(`watching thread ${fromThreadId} for completion...`);
88449
+ const result = yield* application.callbackThread({
88450
+ fromThreadId,
88451
+ targetThreadId,
88452
+ prompt
88453
+ });
88454
+ yield* output.printInfo(`callback sent to ${result.targetThreadId} (dispatch: ${result.dispatch.sequence})`);
88455
+ })).pipe(withDescription("watch a thread and send a message when it completes"));
88456
+ //#endregion
88176
88457
  //#region src/cli/threads/delete.ts
88177
88458
  const deleteThreadCommand = make("delete", {
88178
88459
  thread: threadFlag,
@@ -88752,6 +89033,7 @@ function createCliCommand() {
88752
89033
  listThreadsCommand,
88753
89034
  createModelCommand(),
88754
89035
  createProjectCommand(),
89036
+ searchThreadsCommand,
88755
89037
  createTerminalCommandGroup(),
88756
89038
  startThreadCommand,
88757
89039
  sendThreadCommand,
@@ -88893,7 +89175,7 @@ var T3Version = class extends Service()("t3cli/T3Version") {};
88893
89175
  //#endregion
88894
89176
  //#region src/version/layer.ts
88895
89177
  const PackageJsonSchema = fromJsonString(Struct({ version: String$1 }));
88896
- const T3VersionBundledLive = sync$1(T3Version, () => ({ version: "0.14.0" }));
89178
+ const T3VersionBundledLive = sync$1(T3Version, () => ({ version: "0.14.2" }));
88897
89179
  effect(T3Version, gen(function* () {
88898
89180
  const packageJson = yield* (yield* FileSystem).readFileString(fileURLToPath(new URL("../../package.json", import.meta.url)));
88899
89181
  return { version: (yield* decodeUnknownEffect(PackageJsonSchema)(packageJson)).version };
@@ -88909,8 +89191,12 @@ runMain(gen(function* () {
88909
89191
  return yield* run(createCliCommand(), { version: version.version });
88910
89192
  }).pipe(catchTag("ShowHelp", (error) => sync(() => {
88911
89193
  process.exitCode = error.errors.length > 0 ? 1 : 0;
88912
- })), tapError((error) => gen(function* () {
88913
- yield* (yield* T3Output).writeStderr(`${error instanceof Error ? error.message : String(error)}\n`);
88914
- })), scoped, provide$1(CliLayer)), { disableErrorReporting: true });
89194
+ })), matchEffect({
89195
+ onFailure: (error) => gen(function* () {
89196
+ yield* (yield* T3Output).writeStderr(`${error instanceof Error ? error.message : String(error)}\n`);
89197
+ process.exitCode = 1;
89198
+ }),
89199
+ onSuccess: (value) => succeed(value)
89200
+ }), scoped, provide$1(CliLayer)));
88915
89201
  //#endregion
88916
89202
  export {};