@duyquangnvx/agent-cli 0.5.0 → 0.6.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 (117) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/agent-cli.js +1 -1
  3. package/dist/agent-cli.js.map +1 -1
  4. package/dist/{built-ins.d.ts → built-ins/commands.d.ts} +1 -1
  5. package/dist/{built-ins.js → built-ins/commands.js} +1 -1
  6. package/dist/built-ins/commands.js.map +1 -0
  7. package/dist/{doctor-rows.d.ts → built-ins/doctor-rows.d.ts} +2 -2
  8. package/dist/{doctor-rows.js → built-ins/doctor-rows.js} +10 -23
  9. package/dist/built-ins/doctor-rows.js.map +1 -0
  10. package/dist/{doctor.d.ts → built-ins/doctor.d.ts} +2 -2
  11. package/dist/{doctor.js → built-ins/doctor.js} +3 -3
  12. package/dist/built-ins/doctor.js.map +1 -0
  13. package/dist/{global-install.js → built-ins/global-install.js} +1 -1
  14. package/dist/built-ins/global-install.js.map +1 -0
  15. package/dist/{npm.d.ts → built-ins/npm.d.ts} +2 -2
  16. package/dist/{npm.js → built-ins/npm.js} +3 -3
  17. package/dist/built-ins/npm.js.map +1 -0
  18. package/dist/built-ins/semver.js.map +1 -0
  19. package/dist/built-ins/skills.d.ts +18 -0
  20. package/dist/built-ins/skills.js +97 -0
  21. package/dist/built-ins/skills.js.map +1 -0
  22. package/dist/{update.d.ts → built-ins/update.d.ts} +2 -2
  23. package/dist/{update.js → built-ins/update.js} +25 -15
  24. package/dist/built-ins/update.js.map +1 -0
  25. package/dist/{upgrade-notes.js → built-ins/upgrade-notes.js} +1 -1
  26. package/dist/built-ins/upgrade-notes.js.map +1 -0
  27. package/dist/clock.d.ts +1 -0
  28. package/dist/clock.js.map +1 -1
  29. package/dist/command-spec.d.ts +12 -2
  30. package/dist/command-spec.js +23 -9
  31. package/dist/command-spec.js.map +1 -1
  32. package/dist/context.d.ts +56 -19
  33. package/dist/define.d.ts +67 -9
  34. package/dist/define.js.map +1 -1
  35. package/dist/error-table.d.ts +6 -1
  36. package/dist/error-table.js +5 -1
  37. package/dist/error-table.js.map +1 -1
  38. package/dist/errors.d.ts +9 -1
  39. package/dist/errors.js +17 -8
  40. package/dist/errors.js.map +1 -1
  41. package/dist/exit-classes.js +36 -39
  42. package/dist/exit-classes.js.map +1 -1
  43. package/dist/files.d.ts +8 -3
  44. package/dist/files.js +4 -3
  45. package/dist/files.js.map +1 -1
  46. package/dist/help-json.d.ts +1 -1
  47. package/dist/help-json.js +2 -1
  48. package/dist/help-json.js.map +1 -1
  49. package/dist/help.js +3 -2
  50. package/dist/help.js.map +1 -1
  51. package/dist/index.d.ts +5 -3
  52. package/dist/index.js +3 -2
  53. package/dist/index.js.map +1 -1
  54. package/dist/interrupts.d.ts +4 -1
  55. package/dist/interrupts.js +25 -12
  56. package/dist/interrupts.js.map +1 -1
  57. package/dist/list.d.ts +12 -3
  58. package/dist/list.js +34 -5
  59. package/dist/list.js.map +1 -1
  60. package/dist/manifest.d.ts +17 -0
  61. package/dist/manifest.js +24 -0
  62. package/dist/manifest.js.map +1 -0
  63. package/dist/output.d.ts +2 -3
  64. package/dist/output.js +1 -6
  65. package/dist/output.js.map +1 -1
  66. package/dist/parse-input.js +10 -1
  67. package/dist/parse-input.js.map +1 -1
  68. package/dist/project.d.ts +2 -1
  69. package/dist/project.js +11 -10
  70. package/dist/project.js.map +1 -1
  71. package/dist/run-cli.d.ts +7 -46
  72. package/dist/run-cli.js +32 -194
  73. package/dist/run-cli.js.map +1 -1
  74. package/dist/run-command.d.ts +11 -0
  75. package/dist/run-command.js +234 -0
  76. package/dist/run-command.js.map +1 -0
  77. package/dist/run-options.d.ts +48 -0
  78. package/dist/run-options.js +2 -0
  79. package/dist/run-options.js.map +1 -0
  80. package/dist/run-process.js +4 -2
  81. package/dist/run-process.js.map +1 -1
  82. package/dist/secrets.d.ts +6 -3
  83. package/dist/secrets.js +6 -6
  84. package/dist/secrets.js.map +1 -1
  85. package/dist/side-task.d.ts +27 -0
  86. package/dist/side-task.js +31 -0
  87. package/dist/side-task.js.map +1 -0
  88. package/dist/spawn.d.ts +8 -2
  89. package/dist/spawn.js.map +1 -1
  90. package/dist/stdin.d.ts +23 -3
  91. package/dist/stdin.js +40 -3
  92. package/dist/stdin.js.map +1 -1
  93. package/dist/usage.d.ts +2 -0
  94. package/dist/usage.js +12 -1
  95. package/dist/usage.js.map +1 -1
  96. package/dist/version.d.ts +3 -0
  97. package/dist/version.js +7 -0
  98. package/dist/version.js.map +1 -0
  99. package/package.json +1 -1
  100. package/dist/built-ins.js.map +0 -1
  101. package/dist/doctor-rows.js.map +0 -1
  102. package/dist/doctor.js.map +0 -1
  103. package/dist/global-install.js.map +0 -1
  104. package/dist/npm.js.map +0 -1
  105. package/dist/semver.js.map +0 -1
  106. package/dist/skill-source.d.ts +0 -4
  107. package/dist/skill-source.js +0 -42
  108. package/dist/skill-source.js.map +0 -1
  109. package/dist/skills.d.ts +0 -12
  110. package/dist/skills.js +0 -62
  111. package/dist/skills.js.map +0 -1
  112. package/dist/update.js.map +0 -1
  113. package/dist/upgrade-notes.js.map +0 -1
  114. /package/dist/{global-install.d.ts → built-ins/global-install.d.ts} +0 -0
  115. /package/dist/{semver.d.ts → built-ins/semver.d.ts} +0 -0
  116. /package/dist/{semver.js → built-ins/semver.js} +0 -0
  117. /package/dist/{upgrade-notes.d.ts → built-ins/upgrade-notes.d.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"command-spec.js","sourceRoot":"","sources":["../src/command-spec.ts"],"names":[],"mappings":"AACA,OAAO,EAA6C,SAAS,EAAE,MAAM,aAAa,CAAC;AACnF,OAAO,EAAoC,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAChF,OAAO,EAAE,SAAS,EAAmB,YAAY,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,EAAiB,QAAQ,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,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AAwB,EAAE,KAAgB;IAC7E,OAAO,SAAS,CAAC,IAAI,CAAC;QACpB,CAAC,CAAC,WAAW,CAAC,WAAW,EAAE,IAAI,EAAE,KAAK,CAAC;QACvC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;AAC5D,CAAC"}
package/dist/context.d.ts CHANGED
@@ -26,20 +26,39 @@ export interface Context<Ports = unknown, Settings = unknown> {
26
26
  readonly build: BuildStamp | undefined;
27
27
  /**
28
28
  * The command line that reruns this CLI, to spawn one of its hidden Commands: Node, its flags and
29
- * the bin, or the CLI's name, found on PATH, when run without a bin.
29
+ * the bin, or the CLI's name, found on PATH, when run without a bin. Spawn it as
30
+ * `ctx.spawn(self[0], [...self.slice(1), "daemon"])`.
30
31
  */
31
32
  readonly self: readonly string[];
32
- /** The folder holding this CLI's `package.json`, for reading files shipped in the package. */
33
+ /**
34
+ * The folder holding this CLI's `package.json`, found from the running bin, for reading files the
35
+ * package ships; run through `runCli` without `bin`, it is found from `cwd`.
36
+ */
33
37
  readonly packageRoot: string;
34
- /** Writes a plain line to stderr, for long work; it never reaches stdout. */
38
+ /**
39
+ * Writes a line to stderr, for long work; it never reaches stdout. Under `--json` the line is
40
+ * `{"progress":"..."}`.
41
+ */
35
42
  progress(message: string): void;
36
43
  /**
37
- * Aborts when the run is interrupted (Ctrl-C) or hits the Command's run deadline; pass it to
38
- * `fetch` and child processes.
44
+ * Aborts when the run is interrupted (Ctrl-C, SIGTERM, or `runCli`'s `signal`) or hits the
45
+ * Command's run deadline; pass it to `fetch` and the ports. An interrupt fails the run with
46
+ * `INTERRUPTED`, exit 130 for SIGINT or 143 for SIGTERM; a second Ctrl-C ends the process at once.
39
47
  */
40
48
  readonly signal: AbortSignal;
41
- /** Returns a signal that also aborts, with `DEADLINE_EXCEEDED`, once `ms` have passed. */
49
+ /**
50
+ * Returns a signal that aborts with `ctx.signal`, and with `DEADLINE_EXCEEDED` (exit 75) once
51
+ * `ms` have passed. The run reports that deadline for each error, or leaf of an `AggregateError`,
52
+ * that is not a `CliError` and whose `cause` chain holds its abort; any other error is reported
53
+ * as it is, so a `CliError` keeping the abort as `cause` keeps its own code.
54
+ */
42
55
  deadline(ms: number): AbortSignal;
56
+ /**
57
+ * Returns a signal that aborts with `DEADLINE_EXCEEDED` (exit 75) once `ms` have passed, and
58
+ * follows neither `ctx.signal` nor the run deadline: it bounds a call inside `runToEnd` that
59
+ * Ctrl-C must not cut short. Its abort is reported as `ctx.deadline`'s is.
60
+ */
61
+ timeout(ms: number): AbortSignal;
43
62
  /**
44
63
  * Runs a step that must not stop halfway: the run waits for it even when stopped, and then
45
64
  * prints `finishing <name>` on stderr.
@@ -47,33 +66,47 @@ export interface Context<Ports = unknown, Settings = unknown> {
47
66
  runToEnd<T>(name: string, work: () => Promise<T>): Promise<T>;
48
67
  /**
49
68
  * Records the data done so far, in the shape `render` takes; the last call wins. A run that then
50
- * fails, hits a deadline or is interrupted prints it; a returned value replaces it.
69
+ * fails, hits a deadline or is interrupted prints it on stdout beside its errors on stderr; a
70
+ * returned value replaces it. Delivered data spills like returned data.
51
71
  */
52
72
  deliver(data: unknown): void;
53
73
  /** The outside systems the CLI declared with `agentCli<Ports>()`. */
54
74
  readonly ports: Ports;
55
75
  /**
56
- * Reads, lists, removes and atomically writes files and folders, paths resolved against `cwd`; a
57
- * failure fails the run with `PERMISSION_DENIED`, `DISK_FULL`, `NOT_FOUND`, `NOT_A_FILE` or
58
- * `ALREADY_EXISTS`.
76
+ * Reads, lists, removes and atomically writes files and folders, paths resolved against `cwd`. A
77
+ * failure fails the run naming the path: `PERMISSION_DENIED` (exit 2, with a hint on allowing the
78
+ * path in a Coding agent's sandbox), `DISK_FULL` (exit 2), `NOT_FOUND`, `NOT_A_FILE` or
79
+ * `ALREADY_EXISTS` (exit 1); the codes are exported.
59
80
  */
60
81
  readonly files: Files;
61
82
  /**
62
- * Runs a child process, killed when the run is interrupted; `check: true` fails the run with
63
- * `TOOL_FAILED` and the tail of its stderr when it exits non-zero.
83
+ * Runs a child process in `cwd` with `env`, killed when the run is interrupted; on Windows every
84
+ * process it started is killed too. A program not found fails the run with `TOOL_MISSING` (exit 2).
64
85
  */
65
86
  readonly spawn: ContextSpawn;
66
87
  /** Deadlines, `poll` and the grace period after an interrupt run on it. */
67
88
  readonly clock: Clock;
68
89
  /**
69
90
  * Calls `check` until it returns a value other than `undefined`, sleeping `intervalMs` between
70
- * calls; it stops when `ctx.signal` or the given `signal` aborts.
91
+ * calls; it ends with the abort reason of `ctx.signal` or of the given `signal`.
71
92
  */
72
93
  poll<T>(check: () => T | undefined | Promise<T | undefined>, options: PollOptions): Promise<T>;
73
- /** The Project file found by walking up from `cwd`, parsed by the CLI's schema. */
94
+ /**
95
+ * The Project file found by walking up from `cwd`, parsed by the CLI's schema, or `undefined`
96
+ * when there is none. A file the schema rejects fails the run with `PROJECT_INVALID` (exit 2)
97
+ * before the Command runs; the built-in Commands never read it.
98
+ */
74
99
  readonly project: Project<Settings> | undefined;
75
- /** Reads `name` from the env, then from `$XDG_CONFIG_HOME/<cli>/.env`, with where it came from. */
100
+ /**
101
+ * Reads `name` from the env, then from `$XDG_CONFIG_HOME/<cli>/.env` (default `~/.config`), with
102
+ * where it came from; a `.env` it cannot read fails the run with `PERMISSION_DENIED`.
103
+ */
76
104
  secret(name: string): Secret | undefined;
105
+ /**
106
+ * The `.env` that `secret` reads: `$XDG_CONFIG_HOME/<cli>/.env`, or `~/.config/<cli>/.env`
107
+ * without it. Name it in a hint that asks for a missing key.
108
+ */
109
+ readonly envFile: string;
77
110
  /**
78
111
  * Classifies an errno failure of the CLI's own file access, such as a store it opens itself, as
79
112
  * `ctx.files` does; any other error comes back unchanged.
@@ -83,13 +116,17 @@ export interface Context<Ports = unknown, Settings = unknown> {
83
116
  readonly force: boolean;
84
117
  /**
85
118
  * The command line as the caller typed it, starting with the CLI's name and shell-quoted, with
86
- * each flag in `remove` dropped along with its value and the words in `add` placed before any
87
- * `--`; for the hint that names the command to run next.
119
+ * each flag in `remove` dropped along with its value (`--from 3` and `--from=3`, every time it was
120
+ * given) and the words in `add` placed before any `--`. Build every hint that names a command to
121
+ * run with it.
88
122
  */
89
123
  commandLine(change?: CommandLineChange): string;
90
124
  }
91
- /** The slice of `Context` the ports factory receives, which exists before the ports do. */
92
- export type PortsBase = Pick<Context, "env" | "cwd" | "packageRoot" | "secret" | "spawn" | "files" | "clock" | "signal" | "progress" | "version" | "build" | "self" | "fileError">;
125
+ /**
126
+ * The slice of `Context` the ports factory receives, which exists before the ports do; a test that
127
+ * keeps the real factory gives it the test's env and fakes.
128
+ */
129
+ export type PortsBase = Pick<Context, "env" | "cwd" | "packageRoot" | "secret" | "envFile" | "spawn" | "files" | "clock" | "signal" | "progress" | "version" | "build" | "self" | "fileError">;
93
130
  export interface Project<Settings = unknown> {
94
131
  /** The folder holding the Project file. */
95
132
  readonly root: string;
package/dist/define.d.ts CHANGED
@@ -3,8 +3,11 @@ import type { BuildStamp, Context, PortsBase, ProjectFile } from "./context.js";
3
3
  import type { ErrorTable } from "./error-table.js";
4
4
  import { type StandardFlagName } from "./flags.js";
5
5
  import type { Page, PageInput, RowSchema } from "./list.js";
6
+ import type { SideTaskRun } from "./side-task.js";
6
7
  import type { Style } from "./style.js";
8
+ /** Shown in help and help JSON. */
7
9
  export interface Example {
10
+ /** A realistic full command line, starting with the CLI's name. */
8
11
  readonly command: string;
9
12
  readonly note: string;
10
13
  }
@@ -27,12 +30,15 @@ export interface RunDeadline<In> {
27
30
  readonly ms: number;
28
31
  /**
29
32
  * The command line that continues the work, given as the hint of the run's `DEADLINE_EXCEEDED`;
30
- * `commandLine` is `ctx.commandLine`.
33
+ * `commandLine` is `ctx.commandLine`. Once the deadline passes, every error of the run becomes
34
+ * `DEADLINE_EXCEEDED`.
31
35
  */
32
36
  resume(input: In, commandLine: Context["commandLine"]): string;
33
37
  }
34
38
  interface CommandBase<Args extends InputSchema, Options extends InputSchema> {
39
+ /** The word the Command is listed under in `commands`; it labels the Command in errors and spill files. */
35
40
  readonly name: string;
41
+ /** One line, shown in help and help JSON. */
36
42
  readonly description: string;
37
43
  /** A paragraph printed after the options in text help, and carried as `help` in help JSON. */
38
44
  readonly help?: string;
@@ -41,48 +47,84 @@ interface CommandBase<Args extends InputSchema, Options extends InputSchema> {
41
47
  readonly hidden?: boolean;
42
48
  /**
43
49
  * Only a person at a terminal runs it: under a Coding agent the run fails with `NEEDS_OPERATOR`
44
- * before `plan`, `run` or `start`, naming the line the operator types.
50
+ * (exit 2) before its input is read, stdin included, and the hint asks the operator to type the
51
+ * command line after `!`. `--json` alone does not make it refuse.
45
52
  */
46
53
  readonly operator?: true;
47
- /** Missing ones fail the run with `TOOL_MISSING` before `plan`, `run` or `start`. */
54
+ /**
55
+ * Looked up before `plan`, `run` or `start`, `--dry-run` included: missing ones fail the run with
56
+ * `TOOL_MISSING` (exit 2), naming each with its `install`, and `doctor` checks each.
57
+ */
48
58
  readonly tools?: readonly Tool[];
59
+ /**
60
+ * Positional operands, in the schema's order; each field's `.describe()` is its help. The last
61
+ * field may be a `z.array(...)`, which takes every remaining operand, and one string field may be
62
+ * wrapped in `orStdin`. Input the schema rejects is a usage error (exit 1) before the Command runs.
63
+ */
49
64
  readonly args?: Args;
65
+ /**
66
+ * Flags, a camelCase key typed in kebab-case; each field's `.describe()` is its help. A
67
+ * `z.array(...)` option collects every occurrence of its flag in order, and a repeated scalar flag
68
+ * keeps its last value. Input the schema rejects is a usage error (exit 1) before the Command runs.
69
+ */
50
70
  readonly options?: Options;
51
71
  /** At `ms`, `ctx.signal` aborts and the run ends with `DEADLINE_EXCEEDED` (exit 75). */
52
72
  readonly deadline?: RunDeadline<Input<Args, Options>>;
53
73
  }
54
74
  interface UnpagedCommand<Args extends InputSchema, Options extends InputSchema> extends CommandBase<Args, Options> {
75
+ /** The schema of the data the Command prints, published as JSON Schema in help JSON. */
55
76
  readonly output?: z.ZodType;
56
77
  readonly rows?: never;
57
78
  }
58
79
  export interface ReadCommand<Args extends InputSchema, Options extends InputSchema, Data, Ports = unknown, Settings = unknown> extends UnpagedCommand<Args, Options> {
59
80
  readonly effect: "read";
60
81
  run(input: Input<Args, Options>, ctx: Context<Ports, Settings>): Data | Promise<Data>;
82
+ /**
83
+ * Turns the data into short text; `--json` prints the data itself. `style` colours only when a
84
+ * person watches a terminal or `FORCE_COLOR` is set.
85
+ */
61
86
  render(data: Data, style: Style): string;
62
87
  }
63
- /** A read Command whose data is a page of rows; the Runtime adds `--limit`, `--cursor` and `--fields`. */
88
+ /**
89
+ * A read Command whose data is a page of rows, from `paginate` or `page`; the Runtime adds `--limit`
90
+ * (default 20), `--cursor` and `--fields`, and prints the page as `{ items, next? }`, `next` being
91
+ * the command line for the following page, and as text ends it with a line saying how many rows were
92
+ * shown and either that command line or that no pages remain. A page never spills, and `--fields` keeps only the named fields.
93
+ */
64
94
  export interface ListCommand<Args extends InputSchema, Options extends InputSchema, Row extends RowSchema, Ports = unknown, Settings = unknown> extends CommandBase<Args, Options> {
65
95
  readonly effect: "read";
66
96
  /** The schema of one row; the page's output schema is derived from it. */
67
97
  readonly rows: Row;
68
98
  readonly output?: never;
69
99
  run(input: Flatten<OutputOf<Args> & OutputOf<Options> & PageInput>, ctx: Context<Ports, Settings>): Page<z.output<Row>> | Promise<Page<z.output<Row>>>;
100
+ /** Receives the page; render `page.items`. */
70
101
  render(page: Page<z.output<Row>>, style: Style): string;
71
102
  }
72
- /** A Command that changes something: `plan` has no side effects, `apply` performs the Plan. */
103
+ /**
104
+ * A Command that changes something: `plan` has no side effects, `apply` performs the Plan. The
105
+ * Runtime adds `--dry-run`, which prints the Plan and stops; between `plan` and `apply` it checks
106
+ * `outputs`, then `cost`, then `confirm`, each refusal's hint holding the command line plus its flag.
107
+ */
73
108
  interface PlannedCommand<Args extends InputSchema, Options extends InputSchema, Plan, Data, Ports, Settings> extends UnpagedCommand<Args, Options> {
74
109
  plan(input: Input<Args, Options>, ctx: Context<Ports, Settings>): Plan | Promise<Plan>;
75
110
  apply(plan: Plan, ctx: Context<Ports, Settings>): Data | Promise<Data>;
76
111
  render(data: Data, style: Style): string;
112
+ /**
113
+ * `--dry-run --json` prints the Plan itself, or `{ plan, outputs?, cost }` when the Command
114
+ * declares `outputs` or `cost`; a byte array in it prints as an index-keyed object.
115
+ */
77
116
  renderPlan(plan: Plan, style: Style): string;
78
117
  /**
79
118
  * A sentence stating what the Plan costs, or undefined when it is cheap. Declaring it adds
80
- * `--yes`, which a run must pass whenever it returns a sentence.
119
+ * `--yes`; a run whose cost is a sentence and lacks it refuses with `NOT_CONFIRMED` (exit 2), and
120
+ * `--dry-run` prints `cost: <sentence>`.
81
121
  */
82
122
  cost?(plan: Plan): string | undefined;
83
123
  /**
84
124
  * The files the Plan writes, relative to `ctx.cwd`. Declaring it adds `--force`, without which
85
- * a run refuses with `OUTPUT_EXISTS` when any of them exists.
125
+ * a run refuses with `OUTPUT_EXISTS` (exit 1) when any of them exists, and `--dry-run` lists them.
126
+ * Before `apply` the Runtime creates each one's folder and a temp file in it, so a sandbox denial
127
+ * fails with `PERMISSION_DENIED` first; without `--force` the first write to each is exclusive.
86
128
  */
87
129
  outputs?(plan: Plan): readonly string[];
88
130
  /**
@@ -96,10 +138,16 @@ export interface WriteCommand<Args extends InputSchema, Options extends InputSch
96
138
  }
97
139
  export interface DestructiveCommand<Args extends InputSchema, Options extends InputSchema, Plan, Data, Ports = unknown, Settings = unknown> extends PlannedCommand<Args, Options, Plan, Data, Ports, Settings> {
98
140
  readonly effect: "destructive";
99
- /** The value the caller must repeat as `--confirm`, naming the target the Plan changes. */
141
+ /**
142
+ * The value the caller must repeat as `--confirm`, naming the target the Plan changes; without it
143
+ * the run refuses with exit 1.
144
+ */
100
145
  confirm(plan: Plan): string;
101
146
  }
102
- /** A Command that keeps running, such as a preview server, until Ctrl-C or SIGTERM stops it. */
147
+ /**
148
+ * A Command that keeps running, such as a preview server, until Ctrl-C or SIGTERM stops it with
149
+ * exit 0. Of the Standard flags it gets only `--json`.
150
+ */
103
151
  export interface ServeCommand<Args extends InputSchema, Options extends InputSchema, Data, Ports = unknown, Settings = unknown> extends UnpagedCommand<Args, Options> {
104
152
  readonly effect: "serve";
105
153
  /** Starts the work and returns its data, which prints at once; stop the work on `ctx.signal`. */
@@ -113,6 +161,8 @@ export interface Commands<Ports = unknown, Settings = unknown> {
113
161
  interface CliBase<Ports, Settings> {
114
162
  readonly name: string;
115
163
  readonly version: string;
164
+ /** One line saying what the CLI does, shown under the first line of its help and in help JSON. */
165
+ readonly description: string;
116
166
  /** The commit the build was made from and when, stamped by the bundler; `--version` prints it. */
117
167
  readonly build?: BuildStamp;
118
168
  /** Every code the CLI throws; a code missing here exits 70, as a bug. */
@@ -124,6 +174,14 @@ interface CliBase<Ports, Settings> {
124
174
  readonly skill?: {
125
175
  readonly source: string;
126
176
  };
177
+ /**
178
+ * Work that runs beside every Command run, such as a usage count; return `undefined` to decline.
179
+ * It starts once the input is parsed, before `plan`, `run` or `start`, so it also runs for a run a
180
+ * guard refuses, and once the output is written the run waits for it at most `SIDE_TASK_WAIT_MS`.
181
+ * Nothing it throws changes stdout, stderr or the exit code; `<NAME>_DEBUG=1` prints it on stderr.
182
+ * It never runs for help, `--version`, a usage error or a built-in Command.
183
+ */
184
+ sideTask?(run: SideTaskRun<Ports>): Promise<void> | undefined;
127
185
  }
128
186
  /** Where an Agent CLI is published and how it is installed; `doctor` and `update` read it. */
129
187
  export interface GlobalInstall {
@@ -1 +1 @@
1
- {"version":3,"file":"define.js","sourceRoot":"","sources":["../src/define.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAyB,MAAM,YAAY,CAAC;AACrF,OAAO,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAwS5F,SAAS,cAAc,CAA2B,OAAiB;IACjE,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAC9B,UAA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AC,MAAM,aAAa,GAA2B,gBAAgB,EAAE,CAAC;AAExE,0FAA0F;AAC1F,MAAM,UAAU,SAAS,CAAC,IAAwB;IAChD,OAAO,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,CAAC;AACzC,CAAC"}
@@ -4,6 +4,7 @@ import type { ExitClass } from "./exit-classes.js";
4
4
  /** The Exit classes a CLI's own code can have; a bug or an interrupt is the Runtime's to tell. */
5
5
  export type DeclaredExitClass = Exclude<ExitClass, "bug" | "interrupted">;
6
6
  export interface ErrorDeclaration {
7
+ /** Who must act, which sets the exit code: `caller` 1, `operator` 2, `source` 3, `wait` 75. */
7
8
  readonly class: DeclaredExitClass;
8
9
  readonly details?: z.ZodType;
9
10
  }
@@ -29,6 +30,10 @@ export type CliErrorInit<Declaration extends ErrorDeclaration> = {
29
30
  readonly message: string;
30
31
  readonly hint: string;
31
32
  } & DetailsInit<Declaration> & RetryInit<Declaration>;
32
- /** A `CliError` for a code of `table`, whose `details` must match the code's schema. */
33
+ /**
34
+ * A `CliError` for a code of `table`, whose `details` must match the code's schema. The `hint`
35
+ * names the next command to run and says whether running it again can help; `retryAt` (ISO 8601)
36
+ * is allowed only on a wait-class code.
37
+ */
33
38
  export declare function cliError<Table extends ErrorTable, Code extends keyof Table & string>(_table: Table, code: Code, init: CliErrorInit<Table[Code]>, options?: ErrorOptions): CliError;
34
39
  export {};
@@ -3,7 +3,11 @@ import { CliError } from "./errors.js";
3
3
  export function defineErrors(table) {
4
4
  return table;
5
5
  }
6
- /** A `CliError` for a code of `table`, whose `details` must match the code's schema. */
6
+ /**
7
+ * A `CliError` for a code of `table`, whose `details` must match the code's schema. The `hint`
8
+ * names the next command to run and says whether running it again can help; `retryAt` (ISO 8601)
9
+ * is allowed only on a wait-class code.
10
+ */
7
11
  export function cliError(_table, code, init, options) {
8
12
  return new CliError({ ...init, code }, options);
9
13
  }
@@ -1 +1 @@
1
- {"version":3,"file":"error-table.js","sourceRoot":"","sources":["../src/error-table.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAcvC,oGAAoG;AACpG,MAAM,UAAU,YAAY,CAAiC,KAAY;IACvE,OAAO,KAAK,CAAC;AACf,CAAC;AAmBD,wFAAwF;AACxF,MAAM,UAAU,QAAQ,CACtB,MAAa,EACb,IAAU,EACV,IAA+B,EAC/B,OAAsB;IAEtB,OAAO,IAAI,QAAQ,CAAC,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC;AAClD,CAAC"}
1
+ {"version":3,"file":"error-table.js","sourceRoot":"","sources":["../src/error-table.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAevC,oGAAoG;AACpG,MAAM,UAAU,YAAY,CAAiC,KAAY;IACvE,OAAO,KAAK,CAAC;AACf,CAAC;AAmBD;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CACtB,MAAa,EACb,IAAU,EACV,IAA+B,EAC/B,OAAsB;IAEtB,OAAO,IAAI,QAAQ,CAAC,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC;AAClD,CAAC"}
package/dist/errors.d.ts CHANGED
@@ -27,6 +27,8 @@ export interface ErrorFormat {
27
27
  readonly json: boolean;
28
28
  readonly env: Env;
29
29
  readonly style: Style;
30
+ /** Where the CLI takes bug reports, read from package.json `bugs` only when a hint names it. */
31
+ readonly bugs?: () => string | undefined;
30
32
  /** Whether `error` is a bug: not a `CliError`, or one whose code nobody declared. */
31
33
  readonly isBug: (error: unknown) => boolean;
32
34
  }
@@ -35,6 +37,12 @@ export declare function isMissingFile(error: unknown): boolean;
35
37
  export declare function isNothingThere(error: unknown): boolean;
36
38
  export declare function debugVariable(cliName: string): string;
37
39
  export declare function messageOf(error: unknown): string;
38
- /** The errors a run failed with: each one an `AggregateError` holds, or the one it threw. */
40
+ export declare function isDebug({ env, cliName }: Pick<ErrorFormat, "env" | "cliName">): boolean;
41
+ export declare function causesOf(error: unknown): unknown[];
42
+ export declare function traceOf(error: unknown): string;
43
+ /**
44
+ * The errors a run failed with: the leaves of nested `AggregateError`s, or the one it threw. An
45
+ * empty `AggregateError` is a leaf.
46
+ */
39
47
  export declare function errorsOf(error: unknown): readonly unknown[];
40
48
  export declare function formatRuntimeError(error: unknown, format: ErrorFormat): string;
package/dist/errors.js CHANGED
@@ -38,13 +38,17 @@ export function debugVariable(cliName) {
38
38
  export function messageOf(error) {
39
39
  return error instanceof Error ? error.message : String(error);
40
40
  }
41
- function isDebug({ env, cliName }) {
41
+ export function isDebug({ env, cliName }) {
42
42
  return Boolean(env[debugVariable(cliName)]);
43
43
  }
44
44
  function bugHint(format) {
45
- return isDebug(format)
46
- ? "the stack trace shows where it failed"
47
- : `rerun with ${debugVariable(format.cliName)}=1 to see the stack trace`;
45
+ const bugs = format.bugs?.();
46
+ if (isDebug(format)) {
47
+ const where = "the stack trace shows where it failed";
48
+ return bugs === undefined ? where : `${where}; report it at ${bugs}`;
49
+ }
50
+ const rerun = `rerun with ${debugVariable(format.cliName)}=1 to see the stack trace`;
51
+ return bugs === undefined ? rerun : `${rerun}, then report it at ${bugs}`;
48
52
  }
49
53
  function fieldsOf(error, format) {
50
54
  if (error instanceof CliError) {
@@ -53,12 +57,12 @@ function fieldsOf(error, format) {
53
57
  }
54
58
  return { code: INTERNAL_CODE, message: messageOf(error), hint: bugHint(format) };
55
59
  }
56
- function causesOf(error) {
60
+ export function causesOf(error) {
57
61
  return error instanceof Error && error.cause !== undefined
58
62
  ? [error.cause, ...causesOf(error.cause)]
59
63
  : [];
60
64
  }
61
- function traceOf(error) {
65
+ export function traceOf(error) {
62
66
  return error instanceof Error ? (error.stack ?? error.message) : String(error);
63
67
  }
64
68
  /** Under debug: a bug's stack trace, then every error's cause chain. */
@@ -71,9 +75,14 @@ function debugTrace(error, format) {
71
75
  ];
72
76
  return lines.length === 0 ? undefined : lines.join("\n");
73
77
  }
74
- /** The errors a run failed with: each one an `AggregateError` holds, or the one it threw. */
78
+ /**
79
+ * The errors a run failed with: the leaves of nested `AggregateError`s, or the one it threw. An
80
+ * empty `AggregateError` is a leaf.
81
+ */
75
82
  export function errorsOf(error) {
76
- return error instanceof AggregateError && error.errors.length > 0 ? error.errors : [error];
83
+ return error instanceof AggregateError && error.errors.length > 0
84
+ ? error.errors.flatMap(errorsOf)
85
+ : [error];
77
86
  }
78
87
  function errorLines(error, format) {
79
88
  const fields = fieldsOf(error, format);
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAaA,MAAM,OAAO,QAAS,SAAQ,KAAK;IACxB,IAAI,CAAS;IACb,IAAI,CAAS;IACb,OAAO,CAAU;IACjB,OAAO,CAAqB;IAErC,YAAY,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAkB,EAAE,OAAsB;QAC3F,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AAID,0EAA0E;AAC1E,MAAM,OAAO,UAAW,SAAQ,QAAQ;IACtC,YAAY,MAAwB;QAClC,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IAC3B,CAAC;CACF;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,UAAU,CAAC;AAWxC,MAAM,UAAU,OAAO,CAAC,KAAc;IACpC,OAAO,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ;QAChF,CAAC,CAAC,KAA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AAK,CAAC,CAAC;IAC/B,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;QAChB,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YACpC,GAAG,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;YACzB,KAAK,EAAE,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC;SAChC,CAAC,CAAC,CAAC;QACJ,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,IAAI,CAAC;IACpD,CAAC;IACD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACjE,CAAC"}
@@ -1,16 +1,17 @@
1
+ import { DOCTOR_PROBLEMS } from "./built-ins/doctor.js";
2
+ import { NOT_GLOBAL_INSTALL } from "./built-ins/global-install.js";
3
+ import { INSTALL_FAILED, NO_LATEST, NPM_FAILED, REGISTRY_AUTH, REGISTRY_UNREACHABLE, } from "./built-ins/npm.js";
1
4
  import { CONFIRMATION_MISMATCH, CONFIRMATION_REQUIRED } from "./confirm.js";
2
5
  import { NOT_CONFIRMED } from "./cost.js";
3
- import { DOCTOR_PROBLEMS } from "./doctor.js";
4
6
  import { ALREADY_EXISTS, DISK_FULL, NOT_A_FILE, NOT_FOUND, PERMISSION_DENIED } from "./errno.js";
5
7
  import { CliError, errorsOf, INTERNAL_CODE, UsageError } from "./errors.js";
6
- import { NOT_GLOBAL_INSTALL } from "./global-install.js";
7
8
  import { DEADLINE_EXCEEDED, INTERRUPTED } from "./interrupts.js";
8
9
  import { UNKNOWN_FIELD } from "./list.js";
9
- import { INSTALL_FAILED, NO_LATEST, NPM_FAILED, REGISTRY_AUTH, REGISTRY_UNREACHABLE, } from "./npm.js";
10
10
  import { NEEDS_OPERATOR } from "./operator.js";
11
11
  import { OUTPUT_EXISTS } from "./outputs.js";
12
12
  import { PROJECT_INVALID } from "./project.js";
13
13
  import { TOOL_FAILED } from "./spawn.js";
14
+ import { STDIN_STALLED } from "./stdin.js";
14
15
  import { TOOL_MISSING } from "./tools.js";
15
16
  import { INVALID_INPUT, UNKNOWN_COMMAND, UNKNOWN_OPTION } from "./usage.js";
16
17
  export const SIGNAL_EXIT_CODES = { SIGINT: 130, SIGTERM: 143 };
@@ -21,43 +22,39 @@ export const EXIT_CODES = {
21
22
  wait: 75,
22
23
  bug: 70,
23
24
  };
24
- // Built on call: the modules that throw these codes import this one back (through output.ts), so
25
- // their constants are not initialised yet while this module loads.
26
- /** The codes the Runtime and its built-in Commands raise, each with the class that must act on it. */
27
- function runtimeCodes() {
28
- return {
29
- [INVALID_INPUT]: "caller",
30
- [UNKNOWN_OPTION]: "caller",
31
- [UNKNOWN_COMMAND]: "caller",
32
- [UNKNOWN_FIELD]: "caller",
33
- [CONFIRMATION_REQUIRED]: "caller",
34
- [CONFIRMATION_MISMATCH]: "caller",
35
- [NOT_CONFIRMED]: "operator",
36
- [NEEDS_OPERATOR]: "operator",
37
- [OUTPUT_EXISTS]: "caller",
38
- [INTERRUPTED]: "interrupted",
39
- [DEADLINE_EXCEEDED]: "wait",
40
- [INTERNAL_CODE]: "bug",
41
- [PERMISSION_DENIED]: "operator",
42
- [DISK_FULL]: "operator",
43
- [NOT_FOUND]: "caller",
44
- [ALREADY_EXISTS]: "caller",
45
- [NOT_A_FILE]: "caller",
46
- [TOOL_FAILED]: "operator",
47
- [TOOL_MISSING]: "operator",
48
- [PROJECT_INVALID]: "operator",
49
- [DOCTOR_PROBLEMS]: "operator",
50
- [NOT_GLOBAL_INSTALL]: "operator",
51
- [REGISTRY_UNREACHABLE]: "operator",
52
- [REGISTRY_AUTH]: "operator",
53
- [INSTALL_FAILED]: "operator",
54
- [NPM_FAILED]: "operator",
55
- [NO_LATEST]: "source",
56
- };
57
- }
25
+ const RUNTIME_EXIT_CLASSES = {
26
+ [INVALID_INPUT]: "caller",
27
+ [UNKNOWN_OPTION]: "caller",
28
+ [UNKNOWN_COMMAND]: "caller",
29
+ [UNKNOWN_FIELD]: "caller",
30
+ [CONFIRMATION_REQUIRED]: "caller",
31
+ [CONFIRMATION_MISMATCH]: "caller",
32
+ [NOT_CONFIRMED]: "operator",
33
+ [NEEDS_OPERATOR]: "operator",
34
+ [OUTPUT_EXISTS]: "caller",
35
+ [STDIN_STALLED]: "caller",
36
+ [INTERRUPTED]: "interrupted",
37
+ [DEADLINE_EXCEEDED]: "wait",
38
+ [INTERNAL_CODE]: "bug",
39
+ [PERMISSION_DENIED]: "operator",
40
+ [DISK_FULL]: "operator",
41
+ [NOT_FOUND]: "caller",
42
+ [ALREADY_EXISTS]: "caller",
43
+ [NOT_A_FILE]: "caller",
44
+ [TOOL_FAILED]: "operator",
45
+ [TOOL_MISSING]: "operator",
46
+ [PROJECT_INVALID]: "operator",
47
+ [DOCTOR_PROBLEMS]: "operator",
48
+ [NOT_GLOBAL_INSTALL]: "operator",
49
+ [REGISTRY_UNREACHABLE]: "operator",
50
+ [REGISTRY_AUTH]: "operator",
51
+ [INSTALL_FAILED]: "operator",
52
+ [NPM_FAILED]: "operator",
53
+ [NO_LATEST]: "source",
54
+ };
58
55
  /** The codes of `errors` that the Runtime already declares, which a CLI cannot redeclare. */
59
56
  export function runtimeCodesIn(errors) {
60
- return Object.keys(errors).filter((code) => Object.hasOwn(runtimeCodes(), code));
57
+ return Object.keys(errors).filter((code) => Object.hasOwn(RUNTIME_EXIT_CLASSES, code));
61
58
  }
62
59
  // A code that neither the Runtime nor the CLI declares was thrown by mistake: a bug.
63
60
  function exitClassOfOne(error, errors) {
@@ -65,7 +62,7 @@ function exitClassOfOne(error, errors) {
65
62
  return "bug";
66
63
  if (error instanceof UsageError)
67
64
  return "caller";
68
- return runtimeCodes()[error.code] ?? errors[error.code]?.class ?? "bug";
65
+ return RUNTIME_EXIT_CLASSES[error.code] ?? errors[error.code]?.class ?? "bug";
69
66
  }
70
67
  export function isBug(error, errors) {
71
68
  return exitClassOfOne(error, errors) === "bug";
@@ -1 +1 @@
1
- {"version":3,"file":"exit-classes.js","sourceRoot":"","sources":["../src/exit-classes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEjG,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EACL,cAAc,EACd,SAAS,EACT,UAAU,EACV,aAAa,EACb,oBAAoB,GACrB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAK5E,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAW,CAAC;AAIxE,MAAM,CAAC,MAAM,UAAU,GAAG;I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AAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACpF,OAAO,IAAI,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC;AACvC,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,YAAY,CAAC,MAAe;IAC1C,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC;AACrD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CACxB,KAAc,EACd,MAAkB,EAClB,IAA6B;IAE7B,MAAM,SAAS,GAAG,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC7C,OAAO,SAAS,KAAK,aAAa;QAChC,CAAC,CAAC,iBAAiB,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAC/C,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;AAC5B,CAAC"}
package/dist/files.d.ts CHANGED
@@ -2,6 +2,8 @@ import type { FileError } from "./errno.js";
2
2
  export interface MkdirOptions {
3
3
  /** Fail with `ALREADY_EXISTS` when the folder itself exists. */
4
4
  readonly exclusive?: boolean;
5
+ /** The permission bits of each folder it creates, less the umask; an existing folder keeps its mode. */
6
+ readonly mode?: number;
5
7
  }
6
8
  export interface WriteOptions {
7
9
  /** Fail with `ALREADY_EXISTS` when anything exists at the path. */
@@ -21,16 +23,19 @@ export interface Files {
21
23
  * replacing write through a symlink replaces its target.
22
24
  */
23
25
  write(path: string, data: string | Uint8Array, options?: WriteOptions): Promise<void>;
24
- /** Whether anything exists at the absolute `path`. */
26
+ /** Whether anything exists at the absolute `path`; false also for a path under a file. */
25
27
  exists(path: string): Promise<boolean>;
26
28
  read(path: string): Promise<Uint8Array>;
27
- /** The names in the absolute `folder`. */
29
+ /** The names in the absolute `folder`, sorted. */
28
30
  list(folder: string): Promise<string[]>;
29
31
  /** Removes a file, or a folder and everything in it; a missing `path` is a success. */
30
32
  remove(path: string): Promise<void>;
31
33
  /** Creates the folder and its missing parents; an existing folder is a success unless `exclusive`. */
32
34
  mkdir(path: string, options?: MkdirOptions): Promise<void>;
33
- /** The file at the absolute `path`, or `undefined` when nothing is there or a part of it is a file. */
35
+ /**
36
+ * The file at the absolute `path`, or `undefined` when nothing is there or a part of it is a file.
37
+ * Two paths are one file when their `id`s match, which a link or a case-insensitive disk hides.
38
+ */
34
39
  stat(path: string): Promise<FileStat | undefined>;
35
40
  }
36
41
  /** Where the Runtime writes `path` before moving it into place; a dead writer's is swept. */