@effected/cli 0.19.0 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/Cancelled.js +1 -2
  2. package/CliAudience.js +1 -2
  3. package/CliColor.js +1 -2
  4. package/CliEnv.js +1 -2
  5. package/CliExit.js +1 -2
  6. package/CliFailure.js +1 -2
  7. package/CliInteractive.js +1 -2
  8. package/CliLinks.js +1 -2
  9. package/CliLog.js +1 -2
  10. package/CliLogger.js +1 -2
  11. package/CliMessage.js +1 -2
  12. package/CliPrompt.js +1 -2
  13. package/CliRuntime.js +1 -2
  14. package/CliTest.js +1 -2
  15. package/CliTheme.js +1 -2
  16. package/ConfigIssueRenderer.js +1 -2
  17. package/Doc.js +1 -2
  18. package/Fmt.js +15 -6
  19. package/GithubAnnotation.js +1 -2
  20. package/Glyphs.js +1 -2
  21. package/NotInteractive.js +1 -2
  22. package/Render.js +1 -2
  23. package/SchemaIssueRenderer.js +1 -2
  24. package/Status.js +1 -2
  25. package/TestTerminal.js +1 -2
  26. package/Token.js +1 -2
  27. package/index.d.ts +10 -53
  28. package/internal/ExitRequested.js +1 -2
  29. package/internal/HelpRouting.js +1 -2
  30. package/internal/ansi.js +1 -2
  31. package/internal/autoFormat.js +1 -2
  32. package/internal/canPrompt.js +1 -2
  33. package/internal/counts.js +1 -2
  34. package/internal/diagnostics.js +1 -2
  35. package/internal/displayWidth.js +1 -2
  36. package/internal/failureTarget.js +1 -2
  37. package/internal/fallbackAnswer.js +1 -2
  38. package/internal/fileSink.js +1 -2
  39. package/internal/format.js +1 -2
  40. package/internal/isExitCode.js +1 -2
  41. package/internal/layout.js +1 -2
  42. package/internal/linkScheme.js +1 -2
  43. package/internal/linkTarget.js +1 -2
  44. package/internal/logSafety.js +1 -2
  45. package/internal/renderAnsi.js +1 -2
  46. package/internal/renderDoc.js +1 -2
  47. package/internal/renderGithubLog.js +1 -2
  48. package/internal/renderMarkdown.js +1 -2
  49. package/internal/renderPlain.js +1 -2
  50. package/internal/scanAudience.js +1 -2
  51. package/internal/splitFrame.js +1 -2
  52. package/internal/wizardGate.js +1 -2
  53. package/package.json +6 -6
  54. package/testing.d.ts +0 -4
  55. package/ui/CliUi.js +3 -4
  56. package/ui/CliUiLive.js +1 -2
  57. package/ui/Confirm.js +1 -2
  58. package/ui/DocView.js +1 -2
  59. package/ui/KeyHelp.js +1 -2
  60. package/ui/KeyTable.js +1 -2
  61. package/ui/MultiSelect.js +1 -2
  62. package/ui/Select.js +1 -2
  63. package/ui/Tabs.js +1 -2
  64. package/ui/TextInput.js +1 -2
  65. package/ui/Toggle.js +1 -2
  66. package/ui/UiKey.js +2 -3
  67. package/ui/UiProvider.js +1 -2
  68. package/ui/UiStreams.js +1 -2
  69. package/ui/UiTheme.js +1 -2
  70. package/ui/Viewport.js +1 -2
  71. package/ui/internal/ErrorBoundary.js +1 -2
  72. package/ui/internal/Holder.js +1 -2
  73. package/ui/internal/ScreenContext.js +1 -2
  74. package/ui/internal/UiProviders.js +1 -2
  75. package/ui/internal/ink.js +1 -2
  76. package/ui/internal/inkChalk.js +1 -2
  77. package/ui/internal/inkConsole.js +1 -2
  78. package/ui/internal/lazyView.js +1 -2
  79. package/ui/internal/lineText.js +1 -2
  80. package/ui/internal/mountPermit.js +1 -2
  81. package/ui/internal/processStreams.js +1 -2
  82. package/ui/internal/renderOptions.js +1 -2
  83. package/ui/testing/CliUiTest.js +1 -2
  84. package/ui/testing/fakeStreams.js +1 -2
  85. package/ui/testing/terminalModel.js +1 -2
  86. package/ui-testing-serializer.d.ts +0 -2
  87. package/ui-testing-serializer.js +1 -2
  88. package/ui-testing.d.ts +0 -2
  89. package/ui.d.ts +5 -37
package/Cancelled.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Runtime, Schema } from "effect";
2
2
 
3
- //#region src/Cancelled.ts
3
+ // src/Cancelled.ts
4
4
  /**
5
5
  * A person backed out of an interactive prompt: they pressed escape, or the
6
6
  * prompt was interrupted.
@@ -40,5 +40,4 @@ var Cancelled = class extends Schema.TaggedError()("Cancelled", { reason: Schema
40
40
  }
41
41
  };
42
42
 
43
- //#endregion
44
43
  export { Cancelled };
package/CliAudience.js CHANGED
@@ -7,7 +7,7 @@ import { Effect, Option, Stdio } from "effect";
7
7
  import { Audience, TerminalEnv } from "@effected/env";
8
8
  import { CliConfig, CliError, Command, Flag, GlobalFlag } from "effect/cli";
9
9
 
10
- //#region src/CliAudience.ts
10
+ // src/CliAudience.ts
11
11
  const KINDS = [
12
12
  "human",
13
13
  "agent",
@@ -174,5 +174,4 @@ var CliAudience = class CliAudience {
174
174
  static run = (command, config) => Stdio.Stdio.use(({ args }) => Effect.flatMap(args, (argv) => CliAudience.runWith(command, config)(argv)));
175
175
  };
176
176
 
177
- //#endregion
178
177
  export { CliAudience };
package/CliColor.js CHANGED
@@ -2,7 +2,7 @@ import { Effect, Layer } from "effect";
2
2
  import { TerminalEnv } from "@effected/env";
3
3
  import { CliOutput } from "effect/cli";
4
4
 
5
- //#region src/CliColor.ts
5
+ // src/CliColor.ts
6
6
  /**
7
7
  * Whether a CLI's output should carry ANSI colour, decided once and shared by
8
8
  * everything that renders — help text, error output, and any rendered result.
@@ -56,5 +56,4 @@ var CliColor = class CliColor {
56
56
  })));
57
57
  };
58
58
 
59
- //#endregion
60
59
  export { CliColor };
package/CliEnv.js CHANGED
@@ -5,7 +5,7 @@ import { CliPrompt } from "./CliPrompt.js";
5
5
  import { ConfigProvider, Layer, Option } from "effect";
6
6
  import { Audience, CurrentRuntimeEnv, TerminalEnv } from "@effected/env";
7
7
 
8
- //#region src/CliEnv.ts
8
+ // src/CliEnv.ts
9
9
  /**
10
10
  * The environment services a CLI reads, built once and in the right order.
11
11
  *
@@ -85,5 +85,4 @@ var CliEnv = class {
85
85
  };
86
86
  };
87
87
 
88
- //#endregion
89
88
  export { CliEnv };
package/CliExit.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { isExitCode } from "./internal/isExitCode.js";
2
2
  import { Context, Effect, Layer, MutableRef } from "effect";
3
3
 
4
- //#region src/CliExit.ts
4
+ // src/CliExit.ts
5
5
  /**
6
6
  * The exit code a successful run wants, for commands whose findings are a
7
7
  * result rather than a failure (a linter that found problems, say).
@@ -61,5 +61,4 @@ var CliExit = class CliExit extends Context.Service()("@effected/cli/CliExit") {
61
61
  });
62
62
  };
63
63
 
64
- //#endregion
65
64
  export { CliExit };
package/CliFailure.js CHANGED
@@ -7,7 +7,7 @@ import { NotInteractive } from "./NotInteractive.js";
7
7
  import { Status } from "./Status.js";
8
8
  import { Cause, Context, SchemaIssue } from "effect";
9
9
 
10
- //#region src/CliFailure.ts
10
+ // src/CliFailure.ts
11
11
  /**
12
12
  * The protocol an error class implements to say how a failure is shown: a method under this key that returns the
13
13
  * document.
@@ -298,5 +298,4 @@ var CliFailure = class {
298
298
  };
299
299
  };
300
300
 
301
- //#endregion
302
301
  export { CliDoc, CliFailure };
package/CliInteractive.js CHANGED
@@ -2,7 +2,7 @@ import { canPrompt } from "./internal/canPrompt.js";
2
2
  import { Context, Effect, Layer } from "effect";
3
3
  import { Audience, TerminalEnv } from "@effected/env";
4
4
 
5
- //#region src/CliInteractive.ts
5
+ // src/CliInteractive.ts
6
6
  /**
7
7
  * Whether this run may prompt a person: a human audience, with a terminal on
8
8
  * both standard input and standard output, and a `TERM` that is not `dumb`.
@@ -67,5 +67,4 @@ var CliInteractive = class CliInteractive extends Context.Reference("@effected/c
67
67
  });
68
68
  };
69
69
 
70
- //#endregion
71
70
  export { CliInteractive };
package/CliLinks.js CHANGED
@@ -5,7 +5,7 @@ import { Config, Context, Effect, FileSystem, Layer, Option, Path } from "effect
5
5
  import { CurrentRuntimeEnv } from "@effected/env";
6
6
  import { Walker } from "@effected/walker";
7
7
 
8
- //#region src/CliLinks.ts
8
+ // src/CliLinks.ts
9
9
  const MODES = [
10
10
  "auto",
11
11
  "vscode",
@@ -150,5 +150,4 @@ const ambientLinksLayer = (options = {}) => Layer.effect(CliLinks, Effect.gen(fu
150
150
  });
151
151
  }));
152
152
 
153
- //#endregion
154
153
  export { CliLinks, ambientLinksLayer };
package/CliLog.js CHANGED
@@ -10,7 +10,7 @@ import { Cause, Config, Console, Context, Effect, Layer, LogLevel, Logger, Optio
10
10
  import { Audience, CurrentRuntimeEnv, TerminalEnv } from "@effected/env";
11
11
  import { CommandNeutralizer } from "@effected/github-commands";
12
12
 
13
- //#region src/CliLog.ts
13
+ // src/CliLog.ts
14
14
  /** The most spaces a numeric `indent` writes. */
15
15
  const MAX_INDENT = 64;
16
16
  /** An indent as written before the glyph: spaces for a number, a string with nothing in it that is not text. */
@@ -342,5 +342,4 @@ const envBuildLogLayer = (options, audienceEnvVar) => Layer.unwrap(Effect.gen(fu
342
342
  })]);
343
343
  }));
344
344
 
345
- //#endregion
346
345
  export { CliLog, envBuildLogLayer, platformLogLayer };
package/CliLogger.js CHANGED
@@ -3,7 +3,7 @@ import { TrustedLine, sanitizeParts, underActionsIn } from "./internal/logSafety
3
3
  import { Console, LogLevel, Logger, References } from "effect";
4
4
  import { CommandNeutralizer } from "@effected/github-commands";
5
5
 
6
- //#region src/CliLogger.ts
6
+ // src/CliLogger.ts
7
7
  const defaultRender = (message) => Array.isArray(message) ? message.map(String).join(" ") : String(message);
8
8
  /**
9
9
  * A `Logger` that renders CLI output rather than service logs: no timestamp, level or fiber id, with every level
@@ -88,5 +88,4 @@ const makeCliLogger = (options = {}, underActions = underActionsIn) => {
88
88
  });
89
89
  };
90
90
 
91
- //#endregion
92
91
  export { CliLogger, makeCliLogger };
package/CliMessage.js CHANGED
@@ -6,7 +6,7 @@ import { Console, Effect } from "effect";
6
6
  import { Audience } from "@effected/env";
7
7
  import { CommandNeutralizer } from "@effected/github-commands";
8
8
 
9
- //#region src/CliMessage.ts
9
+ // src/CliMessage.ts
10
10
  /**
11
11
  * One-line status messages: a glyph and some text, themed for a person and plain for an agent.
12
12
  *
@@ -76,5 +76,4 @@ var CliMessage = class CliMessage {
76
76
  static failure = (text) => CliMessage.status(Status.core, "failure", text);
77
77
  };
78
78
 
79
- //#endregion
80
79
  export { CliMessage };
package/CliPrompt.js CHANGED
@@ -5,7 +5,7 @@ import { answerWithoutPerson } from "./internal/fallbackAnswer.js";
5
5
  import { Context, Effect, Layer, Queue, Terminal } from "effect";
6
6
  import { CliConfig, GlobalFlag, Prompt } from "effect/cli";
7
7
 
8
- //#region src/CliPrompt.ts
8
+ // src/CliPrompt.ts
9
9
  /**
10
10
  * Prompts that know whether there is a person to ask.
11
11
  *
@@ -99,5 +99,4 @@ var CliPrompt = class {
99
99
  }));
100
100
  };
101
101
 
102
- //#endregion
103
102
  export { CliPrompt };
package/CliRuntime.js CHANGED
@@ -15,7 +15,7 @@ import { Cause, Effect, Layer, Logger, MutableRef, Runtime } from "effect";
15
15
  import { CliError } from "effect/cli";
16
16
  import { CommandNeutralizer } from "@effected/github-commands";
17
17
 
18
- //#region src/CliRuntime.ts
18
+ // src/CliRuntime.ts
19
19
  const isShowHelp = (u) => CliError.isCliError(u) && u._tag === "ShowHelp";
20
20
  /** A `UserError` `Command.runWith` already printed: it sets the mark to `false` after rendering. */
21
21
  const isRenderedUserError = (u) => CliError.isCliError(u) && u._tag === "UserError" && Runtime.getErrorReported(u) === false;
@@ -220,5 +220,4 @@ var CliRuntime = class CliRuntime {
220
220
  }
221
221
  };
222
222
 
223
- //#endregion
224
223
  export { CliRuntime };
package/CliTest.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Effect, FileSystem, Path, Stream } from "effect";
2
2
  import { ChildProcess, ChildProcessSpawner } from "effect/process";
3
3
 
4
- //#region src/CliTest.ts
4
+ // src/CliTest.ts
5
5
  const text = (stream) => Stream.mkString(Stream.decodeText(stream));
6
6
  /**
7
7
  * Spawn a built CLI bin hermetically and read its exit code and streams as data.
@@ -91,5 +91,4 @@ var CliTest = class {
91
91
  }));
92
92
  };
93
93
 
94
- //#endregion
95
94
  export { CliTest };
package/CliTheme.js CHANGED
@@ -5,7 +5,7 @@ import { Config, Context, Effect, Layer, Option } from "effect";
5
5
  import { TerminalEnv } from "@effected/env";
6
6
  import { Prompt } from "effect/cli";
7
7
 
8
- //#region src/CliTheme.ts
8
+ // src/CliTheme.ts
9
9
  /**
10
10
  * A stream theme at `color`, over a style resolution and a glyph set: the one way a {@link StreamTheme} is built.
11
11
  *
@@ -139,5 +139,4 @@ var CliTheme = class CliTheme extends Context.Service()("@effected/cli/CliTheme"
139
139
  }));
140
140
  };
141
141
 
142
- //#endregion
143
142
  export { CliTheme, streamThemeAt };
@@ -1,6 +1,6 @@
1
1
  import { formatIssue } from "./internal/format.js";
2
2
 
3
- //#region src/ConfigIssueRenderer.ts
3
+ // src/ConfigIssueRenderer.ts
4
4
  /**
5
5
  * Turns a `@effected/config-file` `ConfigValidationError` into one line per rejected value.
6
6
  *
@@ -54,5 +54,4 @@ var ConfigIssueRenderer = class {
54
54
  static render = (error) => formatIssue(error?.issue);
55
55
  };
56
56
 
57
- //#endregion
58
57
  export { ConfigIssueRenderer };
package/Doc.js CHANGED
@@ -3,7 +3,7 @@ import { totalOf, visibleCountersOf } from "./internal/counts.js";
3
3
  import { Render } from "./Render.js";
4
4
  import { Console, Effect } from "effect";
5
5
 
6
- //#region src/Doc.ts
6
+ // src/Doc.ts
7
7
  const isList = (input) => Array.isArray(input);
8
8
  const freeze = (value) => Object.freeze(value);
9
9
  const frozenArray = (items) => Object.freeze([...items]);
@@ -540,5 +540,4 @@ var Doc = class {
540
540
  });
541
541
  };
542
542
 
543
- //#endregion
544
543
  export { Doc };
package/Fmt.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { displayWidth, graphemes, stripAnsi } from "./internal/displayWidth.js";
2
+ import { Duration, Option } from "effect";
2
3
 
3
- //#region src/Fmt.ts
4
+ // src/Fmt.ts
4
5
  const CONTROL = /[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u009F]/g;
5
6
  /**
6
7
  * Text made safe to lay out and print: complete ANSI and OSC sequences removed, every remaining control character
@@ -76,18 +77,27 @@ var Fmt = class {
76
77
  return useEllipsis ? `${out}${ellipsis}` : out;
77
78
  };
78
79
  /**
79
- * A duration in milliseconds as short human text: `250ms`, `1.2s`, `2s`, `1m 3s`, `2m`, `1h 2m`, `2h`.
80
+ * A duration as short human text: `250ms`, `1.2s`, `2s`, `1m 3s`, `2m`, `1h 2m`, `2h`.
80
81
  *
81
82
  * @remarks
82
83
  * Under a second it is whole milliseconds; under a minute, seconds to one decimal with a trailing `.0`
83
84
  * dropped; under an hour, minutes and whole seconds, with the seconds dropped when zero; from an hour, hours and
84
85
  * whole minutes, the seconds dropped. A value that rounds up to the next unit (`999.6` to a second, `59999` to a
85
86
  * minute, `3599999` to an hour) is written in that unit, so `1000ms`, `60s` and `60m` never appear. There is no
86
- * days unit. A negative or non-finite input is `0ms`.
87
+ * days unit. The format is bespoke: core's `Duration.format` renders differently.
87
88
  *
88
- * @param ms - the duration in milliseconds
89
+ * The input is anything `Duration.Input` admits. A plain number is milliseconds and is used as given, never
90
+ * converted through a `Duration`, which rounds a fractional millisecond to whole nanoseconds and would move a value
91
+ * such as `999.4999999` across the rounding boundary. A `bigint` is nanoseconds, as in core. A negative, infinite
92
+ * or invalid input (a string `Duration.Input` cannot parse) is `0ms`: a formatter in a render path never throws.
93
+ *
94
+ * @param input - the duration; a number is milliseconds
89
95
  */
90
- static duration = (ms) => {
96
+ static duration = (input) => {
97
+ const ms = typeof input === "number" ? input : Option.match(Duration.fromInput(input), {
98
+ onNone: () => 0,
99
+ onSome: Duration.toMillis
100
+ });
91
101
  const value = Number.isFinite(ms) ? Math.max(0, ms) : 0;
92
102
  const whole = Math.round(value);
93
103
  if (whole < 1e3) return `${whole}ms`;
@@ -129,5 +139,4 @@ var Fmt = class {
129
139
  static plural = (n, singular, plural) => `${n} ${n === 1 ? singular : plural ?? `${singular}s`}`;
130
140
  };
131
141
 
132
- //#endregion
133
142
  export { Fmt, sanitize };
@@ -1,6 +1,6 @@
1
1
  import { WorkflowCommand } from "@effected/github-commands";
2
2
 
3
- //#region src/GithubAnnotation.ts
3
+ // src/GithubAnnotation.ts
4
4
  /**
5
5
  * GitHub Actions annotations, as workflow commands.
6
6
  *
@@ -36,5 +36,4 @@ var GithubAnnotation = class {
36
36
  };
37
37
  };
38
38
 
39
- //#endregion
40
39
  export { GithubAnnotation };
package/Glyphs.js CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/Glyphs.ts
1
+ // src/Glyphs.ts
2
2
  /**
3
3
  * The two glyph sets: Unicode, and a plain-ASCII fallback for terminals that cannot draw it.
4
4
  *
@@ -79,5 +79,4 @@ var Glyphs = class Glyphs {
79
79
  });
80
80
  };
81
81
 
82
- //#endregion
83
82
  export { Glyphs };
package/NotInteractive.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Runtime, Schema } from "effect";
2
2
 
3
- //#region src/NotInteractive.ts
3
+ // src/NotInteractive.ts
4
4
  /**
5
5
  * A command needed to prompt, but there is no terminal to prompt on.
6
6
  *
@@ -38,5 +38,4 @@ var NotInteractive = class extends Schema.TaggedError()("NotInteractive", {}) {
38
38
  }
39
39
  };
40
40
 
41
- //#endregion
42
41
  export { NotInteractive };
package/Render.js CHANGED
@@ -12,7 +12,7 @@ import { Effect } from "effect";
12
12
  import { Audience, TerminalEnv } from "@effected/env";
13
13
  import { CommandNeutralizer } from "@effected/github-commands";
14
14
 
15
- //#region src/Render.ts
15
+ // src/Render.ts
16
16
  /** A renderer's text, with workflow commands neutralized when the context says the runner is reading it. */
17
17
  const guarded = (text, ctx) => ctx.neutralizeWorkflowCommands === true ? CommandNeutralizer.text(text) : text;
18
18
  /**
@@ -252,5 +252,4 @@ var Render = class {
252
252
  static githubLog = (doc, ctx) => renderGithubLog(doc, ctx);
253
253
  };
254
254
 
255
- //#endregion
256
255
  export { Render };
@@ -1,6 +1,6 @@
1
1
  import { formatIssue } from "./internal/format.js";
2
2
 
3
- //#region src/SchemaIssueRenderer.ts
3
+ // src/SchemaIssueRenderer.ts
4
4
  /**
5
5
  * Turns a `SchemaIssue` tree into lines a user can act on.
6
6
  *
@@ -44,5 +44,4 @@ var SchemaIssueRenderer = class {
44
44
  static render = (issue) => formatIssue(issue);
45
45
  };
46
46
 
47
- //#endregion
48
47
  export { SchemaIssueRenderer };
package/Status.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { sanitize } from "./Fmt.js";
2
2
  import { Array, Option } from "effect";
3
3
 
4
- //#region src/Status.ts
4
+ // src/Status.ts
5
5
  /**
6
6
  * An open vocabulary of statuses.
7
7
  *
@@ -162,5 +162,4 @@ var Status = class Status {
162
162
  }
163
163
  };
164
164
 
165
- //#endregion
166
165
  export { Status };
package/TestTerminal.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Effect, Layer, Option, Queue, Terminal } from "effect";
2
2
 
3
- //#region src/TestTerminal.ts
3
+ // src/TestTerminal.ts
4
4
  /**
5
5
  * A scripted `Terminal` for testing prompts and anything that reads the terminal.
6
6
  *
@@ -76,5 +76,4 @@ var TestTerminal = class {
76
76
  });
77
77
  };
78
78
 
79
- //#endregion
80
79
  export { TestTerminal };
package/Token.js CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/Token.ts
1
+ // src/Token.ts
2
2
  /** The default style of every token. Deeply frozen: the record is shared. */
3
3
  const DEFAULTS = Object.freeze({
4
4
  success: Object.freeze({ fg: "green" }),
@@ -65,5 +65,4 @@ var Token = class {
65
65
  static style = (style) => style;
66
66
  };
67
67
 
68
- //#endregion
69
68
  export { Token };