riteshjs 0.1.0 → 0.2.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.
@@ -1,4 +1,4 @@
1
- ritesh bundles the following third-party software in dist/.
1
+ ritesh bundles the following third-party software in dist/. The net and jq add-ons (dist/net.js, dist/jq-worker.js, dist/jq.wasm) carry ipaddr.js, jq-wasm, and jq.
2
2
 
3
3
  ================================================================
4
4
  @xterm/xterm 6.0.0
@@ -102,3 +102,236 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
102
102
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
103
103
  THE SOFTWARE.
104
104
 
105
+
106
+ ================================================================
107
+ ipaddr.js 2.5.0
108
+ https://github.com/whitequark/ipaddr.js
109
+ ================================================================
110
+
111
+
112
+ Copyright (C) 2011-2017 whitequark <whitequark@whitequark.org>
113
+
114
+ Permission is hereby granted, free of charge, to any person obtaining a copy
115
+ of this software and associated documentation files (the "Software"), to deal
116
+ in the Software without restriction, including without limitation the rights
117
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
118
+ copies of the Software, and to permit persons to whom the Software is
119
+ furnished to do so, subject to the following conditions:
120
+
121
+ The above copyright notice and this permission notice shall be included in
122
+ all copies or substantial portions of the Software.
123
+
124
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
125
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
126
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
127
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
128
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
129
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
130
+ THE SOFTWARE.
131
+
132
+ ================================================================
133
+ jq-wasm 3.0.0-jq-1.8.2 (in dist/jq-worker.js)
134
+ https://github.com/owenthereal/jq-wasm
135
+ ================================================================
136
+
137
+ Copyright (c) 2024 Owen Ou
138
+
139
+ Permission is hereby granted, free of charge, to any person obtaining a copy
140
+ of this software and associated documentation files (the "Software"), to deal
141
+ in the Software without restriction, including without limitation the rights
142
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
143
+ copies of the Software, and to permit persons to whom the Software is
144
+ furnished to do so, subject to the following conditions:
145
+
146
+ The above copyright notice and this permission notice shall be included in all
147
+ copies or substantial portions of the Software.
148
+
149
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
150
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
151
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
152
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
153
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
154
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
155
+ SOFTWARE.
156
+
157
+ ================================================================
158
+ jq 1.8.2 (dist/jq.wasm), with the libraries compiled into it
159
+ https://github.com/jqlang/jq (COPYING)
160
+ ================================================================
161
+
162
+ jq is copyright (C) 2012 Stephen Dolan
163
+
164
+ Permission is hereby granted, free of charge, to any person obtaining
165
+ a copy of this software and associated documentation files (the
166
+ "Software"), to deal in the Software without restriction, including
167
+ without limitation the rights to use, copy, modify, merge, publish,
168
+ distribute, sublicense, and/or sell copies of the Software, and to
169
+ permit persons to whom the Software is furnished to do so, subject to
170
+ the following conditions:
171
+
172
+ The above copyright notice and this permission notice shall be
173
+ included in all copies or substantial portions of the Software.
174
+
175
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
176
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
177
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
178
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
179
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
180
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
181
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
182
+
183
+
184
+
185
+ jq's documentation (everything found under the docs/ subdirectory in
186
+ the source tree) is licensed under the Creative Commons CC BY 3.0
187
+ license, which can be found at:
188
+
189
+ https://creativecommons.org/licenses/by/3.0/
190
+
191
+ The documentation website includes a copy of Twitter's Bootstrap and
192
+ relies on Bonsai, Liquid templates and various other projects, look
193
+ them up for detailed licensing conditions.
194
+
195
+
196
+
197
+ jq incorporates David M. Gay's dtoa.c and g_fmt.c, which bear the
198
+ following notices:
199
+
200
+ dtoa.c:
201
+ The author of this software is David M. Gay.
202
+
203
+ Copyright (c) 1991, 2000, 2001 by Lucent Technologies.
204
+
205
+ Permission to use, copy, modify, and distribute this software for any
206
+ purpose without fee is hereby granted, provided that this entire notice
207
+ is included in all copies of any software which is or includes a copy
208
+ or modification of this software and in all copies of the supporting
209
+ documentation for such software.
210
+
211
+ THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
212
+ WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR LUCENT MAKES ANY
213
+ REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
214
+ OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
215
+
216
+ g_fmt.c:
217
+ The author of this software is David M. Gay.
218
+
219
+ Copyright (c) 1991, 1996 by Lucent Technologies.
220
+
221
+ Permission to use, copy, modify, and distribute this software for any
222
+ purpose without fee is hereby granted, provided that this entire notice
223
+ is included in all copies of any software which is or includes a copy
224
+ or modification of this software and in all copies of the supporting
225
+ documentation for such software.
226
+
227
+ THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
228
+ WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR LUCENT MAKES ANY
229
+ REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
230
+ OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
231
+
232
+
233
+
234
+ jq uses parts of the open source C library "decNumber", which is distributed
235
+ under the following license:
236
+
237
+
238
+ ICU License - ICU 1.8.1 and later
239
+
240
+ COPYRIGHT AND PERMISSION NOTICE
241
+
242
+ Copyright (c) 1995-2005 International Business Machines Corporation and others
243
+ All rights reserved.
244
+
245
+ Permission is hereby granted, free of charge, to any person obtaining a
246
+ copy of this software and associated documentation files (the
247
+ "Software"), to deal in the Software without restriction, including
248
+ without limitation the rights to use, copy, modify, merge, publish,
249
+ distribute, and/or sell copies of the Software, and to permit persons
250
+ to whom the Software is furnished to do so, provided that the above
251
+ copyright notice(s) and this permission notice appear in all copies of
252
+ the Software and that both the above copyright notice(s) and this
253
+ permission notice appear in supporting documentation.
254
+
255
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
256
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
257
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
258
+ OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
259
+ HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
260
+ INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
261
+ FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
262
+ NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
263
+ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
264
+
265
+ Except as contained in this notice, the name of a copyright holder
266
+ shall not be used in advertising or otherwise to promote the sale, use
267
+ or other dealings in this Software without prior written authorization
268
+ of the copyright holder.
269
+
270
+ --------------------------------------------------------------------------------
271
+ All trademarks and registered trademarks mentioned herein are the property of their respective owners.
272
+
273
+
274
+
275
+ jv_thread.h is copied from Heimdal's lib/base/heimbase.h and some code
276
+ in jv.c is copied from Heimdal's lib/base/dll.c:
277
+
278
+
279
+ Portions Copyright (c) 2016 Kungliga Tekniska Högskolan
280
+ (Royal Institute of Technology, Stockholm, Sweden).
281
+ All rights reserved.
282
+
283
+ Redistribution and use in source and binary forms, with or without
284
+ modification, are permitted provided that the following conditions
285
+ are met:
286
+
287
+ 1. Redistributions of source code must retain the above copyright
288
+ notice, this list of conditions and the following disclaimer.
289
+
290
+ 2. Redistributions in binary form must reproduce the above copyright
291
+ notice, this list of conditions and the following disclaimer in the
292
+ documentation and/or other materials provided with the distribution.
293
+
294
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
295
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
296
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
297
+ FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
298
+ COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
299
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
300
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
301
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
302
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
303
+ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
304
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
305
+ OF THE POSSIBILITY OF SUCH DAMAGE.
306
+
307
+
308
+
309
+ jq uses a modified version of NetBSD implementation strptime(),
310
+ which is distributed under the following license:
311
+
312
+ Copyright (c) 1997, 1998, 2005, 2008 The NetBSD Foundation, Inc.
313
+ All rights reserved.
314
+
315
+ This code was contributed to The NetBSD Foundation by Klaus Klein.
316
+ Heavily optimised by David Laight
317
+
318
+ Redistribution and use in source and binary forms, with or without
319
+ modification, are permitted provided that the following conditions
320
+ are met:
321
+ 1. Redistributions of source code must retain the above copyright
322
+ notice, this list of conditions and the following disclaimer.
323
+ 2. Redistributions in binary form must reproduce the above copyright
324
+ notice, this list of conditions and the following disclaimer in the
325
+ documentation and/or other materials provided with the distribution.
326
+
327
+ THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
328
+ ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
329
+ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
330
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
331
+ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
332
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
333
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
334
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
335
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
336
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
337
+ POSSIBILITY OF SUCH DAMAGE.
@@ -1,4 +1,4 @@
1
- /*! ritesh | MIT | Copyright (c) 2026 Jarrod Baumann | bundles xterm.js (MIT, see THIRD_PARTY_NOTICES) */
1
+ /*! ritesh | MIT | Copyright (c) 2026 Jarrod Baumann | bundles xterm.js and ipaddr.js (MIT, see THIRD_PARTY_NOTICES) */
2
2
  // src/contracts.ts
3
3
  const ERRNOS = [
4
4
  "ENOENT",
@@ -62,4 +62,4 @@ const EXIT = {
62
62
  const PASS = Symbol("rite.pass");
63
63
  export { RiteError as a, PASS as i, ERRNO_MESSAGES as n, EXIT as r, ERRNOS as t };
64
64
 
65
- //# sourceMappingURL=contracts-CFeF8xY8.js.map
65
+ //# sourceMappingURL=contracts-0hnYHcIF.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"contracts-CFeF8xY8.js","names":[],"sources":["../src/contracts.ts"],"sourcesContent":["// Cross-module contracts. Every module talks to every other through these\n// types. They are frozen for each implementation wave: a unit that finds a\n// gap reports it instead of editing this file.\n\n// ---------------------------------------------------------------- errors\n\nexport const ERRNOS = [\n \"ENOENT\", \"ENOTDIR\", \"EISDIR\", \"EACCES\", \"EPERM\", \"EEXIST\", \"ENOTEMPTY\",\n \"EROFS\", \"ELOOP\", \"EINVAL\", \"ENOTSUP\", \"ENOSPC\", \"EIO\", \"EPIPE\",\n \"ECANCELED\", \"ETIMEDOUT\", \"ENOTCONN\",\n] as const\nexport type Errno = (typeof ERRNOS)[number]\n\nexport const ERRNO_MESSAGES: Record<Errno, string> = {\n ENOENT: \"no such file or directory\",\n ENOTDIR: \"not a directory\",\n EISDIR: \"is a directory\",\n EACCES: \"permission denied\",\n EPERM: \"operation not permitted\",\n EEXIST: \"file exists\",\n ENOTEMPTY: \"directory not empty\",\n EROFS: \"read-only file system\",\n ELOOP: \"too many levels of symbolic links\",\n EINVAL: \"invalid argument\",\n ENOTSUP: \"operation not supported\",\n ENOSPC: \"no space left on device\",\n EIO: \"input/output error\",\n EPIPE: \"broken pipe\",\n ECANCELED: \"operation canceled\",\n ETIMEDOUT: \"operation timed out\",\n ENOTCONN: \"transport endpoint is not connected\",\n}\n\n/** The one error type that crosses module boundaries. */\nexport class RiteError extends Error {\n readonly errno: Errno\n readonly path: string | undefined\n constructor(errno: Errno, path?: string, message?: string) {\n super(message ?? ERRNO_MESSAGES[errno])\n this.name = \"RiteError\"\n this.errno = errno\n this.path = path\n }\n}\n\n/** Exit codes with fixed meanings (docs/language.md). Others are 0-255. */\nexport const EXIT = {\n OK: 0,\n FAILURE: 1,\n USAGE: 2,\n NOT_EXECUTABLE: 126,\n NOT_FOUND: 127,\n INTERRUPTED: 130,\n CONNECTION_LOST: 255,\n} as const\n\n// ---------------------------------------------------------------- parser\n\nexport type TokenKind =\n | \"word\" | \"operator\" | \"redirect\" | \"comment\" | \"whitespace\" | \"reserved\"\n\n/** [start, end) offsets into the source line, in UTF-16 code units. */\nexport type Span = readonly [start: number, end: number]\n\nexport interface Token {\n kind: TokenKind\n text: string\n span: Span\n}\n\n/** One piece of a word, before expansion. */\nexport type WordPart =\n | { kind: \"literal\"; text: string; quoted: boolean }\n | { kind: \"param\"; name: string; quoted: boolean }\n | { kind: \"tilde\"; text: string }\n | { kind: \"glob\"; text: string }\n\nexport interface Word {\n parts: WordPart[]\n span: Span\n}\n\nexport type RedirectOp = \">\" | \">>\" | \"<\" | \"2>\" | \"2>>\" | \"2>&1\" | \">&2\"\n\nexport interface Redirect {\n op: RedirectOp\n /** Absent for the duplication forms 2>&1 and >&2. */\n target?: Word\n span: Span\n}\n\nexport interface Assignment {\n name: string\n value: Word\n span: Span\n}\n\nexport interface SimpleCommand {\n type: \"command\"\n assignments: Assignment[]\n words: Word[]\n redirects: Redirect[]\n span: Span\n}\n\nexport interface Pipeline {\n type: \"pipeline\"\n commands: SimpleCommand[]\n span: Span\n}\n\nexport interface List {\n type: \"list\"\n /** First pipeline, then (operator, pipeline) pairs, left-associative. */\n first: Pipeline\n rest: Array<{ op: \";\" | \"&&\" | \"||\"; pipeline: Pipeline }>\n span: Span\n}\n\nexport type ParseResult =\n | { ok: true; ast: List | null; tokens: Token[] }\n | { ok: false; incomplete: true; tokens: Token[] }\n | { ok: false; incomplete: false; error: SyntaxErrorInfo; tokens: Token[] }\n\nexport interface SyntaxErrorInfo {\n message: string\n span: Span\n}\n\nexport interface ParseOptions {\n /** Returns an alias body for a name in command position, if defined. */\n alias?: (name: string) => string | undefined\n}\n\nexport interface Parser {\n parse(line: string, options?: ParseOptions): ParseResult\n /** Tokens only, for highlighting. Never throws. */\n tokenize(line: string): Token[]\n /** Quote a value so it parses back as one literal word. */\n quoteWord(value: string, context: \"bare\" | \"double\" | \"single\"): string\n /** The version string printed in \"not supported in rite <version>\". */\n readonly version: string\n}\n\n// ---------------------------------------------------------------- vfs\n\nexport type InodeType = \"dir\" | \"file\" | \"cmd\" | \"link\" | \"action\" | \"dev\"\n\nexport interface Stat {\n type: InodeType\n /** Permission bits, e.g. 0o755. */\n mode: number\n uid: number\n gid: number\n size: number\n /** Milliseconds since the epoch. */\n mtime: number\n /** Set when the path is inside a mount. */\n mount?: string\n}\n\nexport interface Entry {\n name: string\n type: InodeType\n}\n\nexport type ActionDef =\n | { navigate: string }\n | { open: string }\n | { event: string; detail?: unknown }\n | { print: string }\n\nexport type ActionVia = \"cd\" | \"open\" | \"cat\"\n\nexport interface ActionEvent {\n kind: \"navigate\" | \"open\" | \"event\" | \"print\"\n path: string\n via: ActionVia\n href?: string\n url?: string\n name?: string\n detail?: unknown\n /** The host calls this to stop rite's default handling. */\n preventDefault(): void\n readonly defaultPrevented: boolean\n}\n\nexport interface ActionResult {\n event: ActionEvent\n /** Text the command prints (print actions, or the URL when a popup is blocked). */\n output?: string\n}\n\nexport type FileContent = string | (() => string | Promise<string>)\n\nexport type InodeSpec =\n | { type: \"dir\"; mode?: number; uid?: number }\n | { type: \"file\"; content: FileContent; mode?: number; uid?: number }\n | { type: \"cmd\"; command: CommandDef; mode?: number }\n | { type: \"link\"; target: string }\n | { type: \"action\"; action: ActionDef; mode?: number }\n | { type: \"dev\"; read?: () => string; write?: (data: string) => void; mode?: number }\n\n/** What the editor may read synchronously from the vfs cache. */\nexport interface Inode {\n type: InodeType\n mode: number\n uid: number\n /** Present for cmd inodes. */\n command?: CommandInfo\n}\n\nexport interface CallOptions {\n signal?: AbortSignal\n}\n\nexport interface WriteOptions extends CallOptions {\n mode: \"truncate\" | \"append\"\n}\n\n/**\n * Paths given to the vfs are absolute or relative to `cwd`. Tilde is a\n * kernel expansion and never reaches the vfs. `..` resolves lexically.\n */\nexport interface Vfs {\n stat(path: string, cwd: string, o?: CallOptions): Promise<Stat>\n list(path: string, cwd: string, o?: CallOptions): Promise<Entry[]>\n read(path: string, cwd: string, o?: CallOptions): Promise<string>\n write(path: string, cwd: string, data: string, o: WriteOptions): Promise<void>\n mkdir(path: string, cwd: string, o?: CallOptions & { parents?: boolean }): Promise<void>\n remove(path: string, cwd: string, o?: CallOptions & { recursive?: boolean }): Promise<void>\n /** Only cd, open, and cat call this. stat and list never trigger actions. */\n activate(path: string, cwd: string, via: ActionVia): Promise<ActionResult | null>\n /** Absolute, normalized path. Does not check existence. */\n resolve(path: string, cwd: string): string\n /** Cache only, synchronous, never does I/O. The editor uses only this. */\n peek(path: string, cwd: string): Inode | undefined\n /** Create or replace an inode (host setup and kernel use). */\n put(path: string, spec: InodeSpec): void\n mount(path: string, provider: MountProvider): void\n unmount(path: string): void\n /** Permission check for the given uid: r, w, or x. Root bypasses. */\n access(path: string, cwd: string, uid: number, want: \"r\" | \"w\" | \"x\"): Promise<boolean>\n}\n\n/** A subtree served by a host object or a remote server. Paths are relative to the mount root, \"\" is the root. */\nexport interface MountProvider {\n readonly readonly: boolean\n stat(rel: string, o: CallOptions): Promise<Stat>\n list(rel: string, o: CallOptions): Promise<Entry[]>\n read(rel: string, o: CallOptions): Promise<string>\n write?(rel: string, data: string, o: WriteOptions): Promise<void>\n mkdir?(rel: string, o: CallOptions): Promise<void>\n remove?(rel: string, o: CallOptions): Promise<void>\n /** Called with a relative path when something under the mount changes. Returns an unsubscribe. */\n watch?(onChange: (rel: string) => void): () => void\n}\n\n// ---------------------------------------------------------------- processes\n\nexport type Env = Record<string, string>\n\nexport interface Tty {\n readonly cols: number\n readonly rows: number\n /** Read one line from the terminal. echo:false for passwords. Never recorded in history. */\n read(options?: { echo?: boolean; prompt?: string; signal?: AbortSignal }): Promise<string | null>\n /** Unfiltered output. Local commands only (clear, egg animations). */\n raw(data: string): Promise<void>\n}\n\nexport type StdioKind = \"tty\" | \"pipe\" | \"file\" | \"null\"\n\nexport interface Stdio {\n stdin: StdioKind\n stdout: StdioKind\n stderr: StdioKind\n}\n\nexport type FlagValue = boolean | string | number | Array<string | number>\nexport type Flags = Record<string, FlagValue | undefined>\n\nexport interface Proc {\n /** argv[0] is the name the command was invoked by. */\n readonly argv: readonly string[]\n /** Parsed flags, keyed by the long name when one exists, else the short name. */\n readonly flags: Flags\n /** Operands after flag parsing; argv.slice(1) when the command declares no flags. */\n readonly args: readonly string[]\n /** The resolved subcommand path, e.g. [\"devices\", \"ls\"]. Empty when none. */\n readonly subcommand: readonly string[]\n readonly stdin: ReadableStream<string>\n readonly stdout: WritableStream<string>\n readonly stderr: WritableStream<string>\n /** Write to stdout or stderr; resolves when the sink accepted the chunk. Commands write \"\\n\". */\n out(text: string): Promise<void>\n err(text: string): Promise<void>\n /** stdin split into lines, without terminators. */\n lines(): AsyncIterable<string>\n readonly env: Readonly<Env>\n readonly cwd: string\n readonly uid: number\n readonly fs: Vfs\n /** Aborted on ^C (reason \"INT\") or when a downstream reader exits (reason \"EPIPE\"). */\n readonly signal: AbortSignal\n /** Null when stdout is not the terminal. */\n readonly tty: Tty | null\n readonly stdio: Stdio\n readonly sys: Sys\n}\n\n/** A command's body. void means exit 0. A throw is exit 1 with one stderr line. */\nexport type Run = (p: Proc) => Promise<number | void>\n\nexport type Resolution =\n | { kind: \"alias\"; name: string; body: string }\n | { kind: \"builtin\"; name: string; info: CommandInfo }\n | { kind: \"command\"; name: string; path: string; info: CommandInfo }\n | { kind: \"egg\"; name: string; id: string }\n | { kind: \"not-found\"; name: string }\n\nexport interface SessionView {\n readonly user: string\n readonly uid: number\n readonly cwd: string\n readonly hostname: string\n readonly home: string\n readonly lastStatus: number\n}\n\n/** The kernel facade a command may use. */\nexport interface Sys {\n resolve(name: string): Resolution\n commands(): CommandInfo[]\n /** Run argv as a child. stdio defaults to the caller's. */\n spawn(argv: readonly string[], options?: { uid?: number; env?: Env; stdio?: Partial<StdioStreams> }): Promise<number>\n /** Run a full line (rite -c, source). */\n run(line: string, options?: { env?: Env }): Promise<number>\n readonly session: SessionView\n /** Host configuration for sudo. */\n readonly sudo: SudoPolicy\n history(): readonly string[]\n}\n\nexport interface StdioStreams {\n stdin: ReadableStream<string>\n stdout: WritableStream<string>\n stderr: WritableStream<string>\n}\n\nexport type SudoPolicy = boolean | ((password: string) => boolean | Promise<boolean>)\n\n/** Builtins also receive the mutable session. In a pipeline the changes do not persist. */\nexport interface Session {\n user: string\n uid: number\n cwd: string\n oldCwd: string\n hostname: string\n home: string\n env: Env\n /** Names exported to child processes. */\n exported: Set<string>\n aliases: Map<string, string>\n lastStatus: number\n /** Set by the exit builtin. */\n exitRequested: number | null\n}\n\nexport type BuiltinRun = (p: Proc, session: Session) => Promise<number | void>\n\n// ---------------------------------------------------------------- commands\n\nexport interface FlagDef {\n long?: string\n short?: string\n type: \"boolean\" | \"string\" | \"number\"\n /** Repeatable flags collect into an array. */\n repeat?: boolean\n default?: FlagValue\n description?: string\n}\n\nexport interface Candidate {\n value: string\n display?: string\n description?: string\n /** Appended after insertion: \" \" by default, \"/\" for directories, \"\" to keep typing. */\n suffix?: string\n}\n\nexport interface CompleteContext {\n argv: readonly string[]\n /** Index into argv of the word being completed. */\n index: number\n prefix: string\n env: Readonly<Env>\n cwd: string\n fs: Vfs\n signal: AbortSignal\n}\n\nexport type Completer = (ctx: CompleteContext) => Promise<Candidate[]>\n\nexport interface CommandDef {\n name: string\n summary: string\n usage: string\n /** Keyed by the canonical name (long when present). Omit to receive raw argv. */\n flags?: Record<string, FlagDef>\n subcommands?: Record<string, Omit<CommandDef, \"name\">>\n complete?: Completer\n run?: Run\n /** Longer text for man. */\n manual?: string\n}\n\nexport interface CommandInfo {\n name: string\n summary: string\n usage: string\n /** Longer text for man, when the definition has one. */\n manual?: string\n flags?: Record<string, FlagDef>\n subcommands?: Record<string, { summary: string; usage: string }>\n builtin: boolean\n remote: boolean\n}\n\n/** Supplies commands from outside the vfs tree (the remote client). */\nexport interface CommandSource {\n /** Names known before connecting, so completion and which work early. */\n names(): string[]\n info(name: string): CommandInfo | undefined\n run(name: string, p: Proc): Promise<number>\n complete?(argv: readonly string[], index: number, signal: AbortSignal): Promise<Candidate[]>\n}\n\n// ---------------------------------------------------------------- eggs\n\nexport const PASS: unique symbol = Symbol(\"rite.pass\")\nexport type EggResult = number | void | typeof PASS\n\nexport type EggTrigger =\n | { command: string; when?: (argv: readonly string[], session: SessionView) => boolean }\n | { input: RegExp }\n | { keys: string }\n\nexport interface EggDef {\n id: string\n trigger: EggTrigger\n run: (p: Proc) => Promise<EggResult>\n}\n\n// ---------------------------------------------------------------- completion\n\nexport interface Completion {\n /** The span of the line the candidates replace. */\n span: Span\n candidates: Candidate[]\n}\n\n// ---------------------------------------------------------------- terminal\n\nexport type OutputPolicy = \"plain\" | \"sgr\" | \"raw\"\n\nexport interface TermSize {\n cols: number\n rows: number\n}\n\n/** The only boundary to xterm. The editor renders through it; tests back it with @xterm/headless. */\nexport interface Term {\n /**\n * Write complete text with a policy; resolves once xterm has parsed it.\n * \"\\n\" becomes \"\\r\\n\". Each call is filtered on its own: an escape\n * sequence cut off at the end of the data is dropped.\n */\n write(data: string, policy: OutputPolicy): Promise<void>\n /**\n * A writer for one stream (a process's stdout): its filter keeps an escape\n * sequence split across chunks until it completes, apart from every other\n * writer.\n */\n writer(policy: OutputPolicy): (chunk: string) => Promise<void>\n /** Key input, already decoded into strings, terminal replies discarded. Returns an unsubscribe. */\n onInput(listener: (data: string) => void): () => void\n onResize(listener: (size: TermSize) => void): () => void\n readonly size: TermSize\n /** Replace the terminal's colors (xterm ITheme keys). */\n setTheme(theme: Theme): void\n /** Display width of one code point: 0, 1, or 2. */\n width(codePoint: number): 0 | 1 | 2\n focus(): void\n fit(): void\n dispose(): void\n}\n\n// ---------------------------------------------------------------- kernel\n\nexport interface Kernel {\n readonly session: SessionView\n /** Run one line as if typed. Queued behind any running job. */\n exec(line: string, stdio?: Partial<StdioStreams>): Promise<number>\n /** Run one egg directly (a key trigger), queued like a line. */\n runEgg(egg: EggDef): Promise<number>\n complete(line: string, cursor: number, o: { signal: AbortSignal }): Promise<Completion>\n /** Abort the foreground job (^C). */\n interrupt(): void\n readonly running: boolean\n register(def: CommandDef, at?: string): void\n registerEgg(def: EggDef): void\n /** Eggs with key triggers, for the editor. */\n keyEggs(): readonly EggDef[]\n addCommandSource(at: string, source: CommandSource): void\n readonly vfs: Vfs\n readonly parser: Parser\n}\n\n// ---------------------------------------------------------------- host\n\nexport type HistoryMode = \"local\" | \"memory\" | false\n\n/** Terminal colors: xterm's ITheme keys (strings, and extendedAnsi as a list). */\nexport interface Theme {\n [key: string]: string | readonly string[] | undefined\n extendedAnsi?: readonly string[]\n}\n\nexport interface HostOptions {\n element: HTMLElement\n hostname?: string\n user?: string\n /** Printed before the first prompt; SGR colors are kept, every other escape sequence is dropped. */\n motd?: string\n files?: Record<string, FileContent>\n inodes?: Record<string, InodeSpec>\n mounts?: Array<{ path: string; provider: MountProvider }>\n commands?: CommandDef[]\n eggs?: EggDef[] | false\n remote?: RemoteHandle\n sudo?: SudoPolicy\n history?: HistoryMode\n /** xterm ITheme keys; `themes` has brass, tide, dusk (dark) and paper (light) ready-made. */\n theme?: Theme\n /** The terminal's font. Load web fonts before createRite so the cell size is measured right. */\n font?: { family?: string; size?: number }\n screenReaderMode?: boolean\n onAction?: (e: ActionEvent) => void\n}\n\n/** What rite/remote hands to createRite. Core never imports the remote module. */\nexport interface RemoteHandle {\n readonly at: string\n readonly bin: string\n readonly provider: MountProvider\n readonly commands: CommandSource\n connect(): Promise<void>\n /** The terminal's size changed: tell the server (tty.resize) if connected. */\n resize(cols: number, rows: number): void\n dispose(): void\n onNotify(listener: (text: string, level: \"info\" | \"warn\" | \"error\") => void): () => void\n}\n\nexport interface Rite {\n readonly ready: Promise<void>\n exec(line: string): Promise<{ code: number }>\n print(text: string): void\n focus(): void\n fit(): void\n /** The terminal's size in cells. */\n readonly size: TermSize\n /** Called after the terminal changes size (a fit, a resize). Returns an unsubscribe. */\n onResize(listener: (size: TermSize) => void): () => void\n /** Replace the terminal's colors, such as `themes.paper`. */\n setTheme(theme: Theme): void\n dispose(): void\n}\n"],"mappings":";;AAMA,MAAa,SAAS;CACpB;CAAU;CAAW;CAAU;CAAU;CAAS;CAAU;CAC5D;CAAS;CAAS;CAAU;CAAW;CAAU;CAAO;CACxD;CAAa;CAAa;AAC5B;AAGA,MAAa,iBAAwC;CACnD,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,QAAQ;CACR,OAAO;CACP,QAAQ;CACR,WAAW;CACX,OAAO;CACP,OAAO;CACP,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,KAAK;CACL,OAAO;CACP,WAAW;CACX,WAAW;CACX,UAAU;AACZ;;AAGA,IAAa,YAAb,cAA+B,MAAM;CAC1B;CACA;CACT,YAAY,OAAc,MAAe,SAAkB;EACzD,MAAM,WAAW,eAAe,MAAM;EACtC,KAAK,OAAO;EACZ,KAAK,QAAQ;EACb,KAAK,OAAO;CACd;AACF;;AAGA,MAAa,OAAO;CAClB,IAAI;CACJ,SAAS;CACT,OAAO;CACP,gBAAgB;CAChB,WAAW;CACX,aAAa;CACb,iBAAiB;AACnB;AAkYA,MAAa,OAAsB,OAAO,WAAW"}
1
+ {"version":3,"file":"contracts-0hnYHcIF.js","names":[],"sources":["../src/contracts.ts"],"sourcesContent":["// Cross-module contracts. Every module talks to every other through these\n// types. They are frozen for each implementation wave: a unit that finds a\n// gap reports it instead of editing this file.\n\n// ---------------------------------------------------------------- errors\n\nexport const ERRNOS = [\n \"ENOENT\", \"ENOTDIR\", \"EISDIR\", \"EACCES\", \"EPERM\", \"EEXIST\", \"ENOTEMPTY\",\n \"EROFS\", \"ELOOP\", \"EINVAL\", \"ENOTSUP\", \"ENOSPC\", \"EIO\", \"EPIPE\",\n \"ECANCELED\", \"ETIMEDOUT\", \"ENOTCONN\",\n] as const\nexport type Errno = (typeof ERRNOS)[number]\n\nexport const ERRNO_MESSAGES: Record<Errno, string> = {\n ENOENT: \"no such file or directory\",\n ENOTDIR: \"not a directory\",\n EISDIR: \"is a directory\",\n EACCES: \"permission denied\",\n EPERM: \"operation not permitted\",\n EEXIST: \"file exists\",\n ENOTEMPTY: \"directory not empty\",\n EROFS: \"read-only file system\",\n ELOOP: \"too many levels of symbolic links\",\n EINVAL: \"invalid argument\",\n ENOTSUP: \"operation not supported\",\n ENOSPC: \"no space left on device\",\n EIO: \"input/output error\",\n EPIPE: \"broken pipe\",\n ECANCELED: \"operation canceled\",\n ETIMEDOUT: \"operation timed out\",\n ENOTCONN: \"transport endpoint is not connected\",\n}\n\n/** The one error type that crosses module boundaries. */\nexport class RiteError extends Error {\n readonly errno: Errno\n readonly path: string | undefined\n constructor(errno: Errno, path?: string, message?: string) {\n super(message ?? ERRNO_MESSAGES[errno])\n this.name = \"RiteError\"\n this.errno = errno\n this.path = path\n }\n}\n\n/** Exit codes with fixed meanings (docs/language.md). Others are 0-255. */\nexport const EXIT = {\n OK: 0,\n FAILURE: 1,\n USAGE: 2,\n NOT_EXECUTABLE: 126,\n NOT_FOUND: 127,\n INTERRUPTED: 130,\n CONNECTION_LOST: 255,\n} as const\n\n// ---------------------------------------------------------------- parser\n\nexport type TokenKind =\n | \"word\" | \"operator\" | \"redirect\" | \"comment\" | \"whitespace\" | \"reserved\"\n\n/** [start, end) offsets into the source line, in UTF-16 code units. */\nexport type Span = readonly [start: number, end: number]\n\nexport interface Token {\n kind: TokenKind\n text: string\n span: Span\n}\n\n/** One piece of a word, before expansion. */\nexport type WordPart =\n | { kind: \"literal\"; text: string; quoted: boolean }\n | { kind: \"param\"; name: string; quoted: boolean }\n | { kind: \"tilde\"; text: string }\n | { kind: \"glob\"; text: string }\n\nexport interface Word {\n parts: WordPart[]\n span: Span\n}\n\nexport type RedirectOp = \">\" | \">>\" | \"<\" | \"2>\" | \"2>>\" | \"2>&1\" | \">&2\"\n\nexport interface Redirect {\n op: RedirectOp\n /** Absent for the duplication forms 2>&1 and >&2. */\n target?: Word\n span: Span\n}\n\nexport interface Assignment {\n name: string\n value: Word\n span: Span\n}\n\nexport interface SimpleCommand {\n type: \"command\"\n assignments: Assignment[]\n words: Word[]\n redirects: Redirect[]\n span: Span\n}\n\nexport interface Pipeline {\n type: \"pipeline\"\n commands: SimpleCommand[]\n span: Span\n}\n\nexport interface List {\n type: \"list\"\n /** First pipeline, then (operator, pipeline) pairs, left-associative. */\n first: Pipeline\n rest: Array<{ op: \";\" | \"&&\" | \"||\"; pipeline: Pipeline }>\n span: Span\n}\n\nexport type ParseResult =\n | { ok: true; ast: List | null; tokens: Token[] }\n | { ok: false; incomplete: true; tokens: Token[] }\n | { ok: false; incomplete: false; error: SyntaxErrorInfo; tokens: Token[] }\n\nexport interface SyntaxErrorInfo {\n message: string\n span: Span\n}\n\nexport interface ParseOptions {\n /** Returns an alias body for a name in command position, if defined. */\n alias?: (name: string) => string | undefined\n}\n\nexport interface Parser {\n parse(line: string, options?: ParseOptions): ParseResult\n /** Tokens only, for highlighting. Never throws. */\n tokenize(line: string): Token[]\n /** Quote a value so it parses back as one literal word. */\n quoteWord(value: string, context: \"bare\" | \"double\" | \"single\"): string\n /** The version string printed in \"not supported in rite <version>\". */\n readonly version: string\n}\n\n// ---------------------------------------------------------------- vfs\n\nexport type InodeType = \"dir\" | \"file\" | \"cmd\" | \"link\" | \"action\" | \"dev\"\n\nexport interface Stat {\n type: InodeType\n /** Permission bits, e.g. 0o755. */\n mode: number\n uid: number\n gid: number\n size: number\n /** Milliseconds since the epoch. */\n mtime: number\n /** Set when the path is inside a mount. */\n mount?: string\n}\n\nexport interface Entry {\n name: string\n type: InodeType\n}\n\nexport type ActionDef =\n | { navigate: string }\n | { open: string }\n | { event: string; detail?: unknown }\n | { print: string }\n\nexport type ActionVia = \"cd\" | \"open\" | \"cat\"\n\nexport interface ActionEvent {\n kind: \"navigate\" | \"open\" | \"event\" | \"print\"\n path: string\n via: ActionVia\n href?: string\n url?: string\n name?: string\n detail?: unknown\n /** The host calls this to stop rite's default handling. */\n preventDefault(): void\n readonly defaultPrevented: boolean\n}\n\nexport interface ActionResult {\n event: ActionEvent\n /** Text the command prints (print actions, or the URL when a popup is blocked). */\n output?: string\n}\n\nexport type FileContent = string | (() => string | Promise<string>)\n\nexport type InodeSpec =\n | { type: \"dir\"; mode?: number; uid?: number }\n | { type: \"file\"; content: FileContent; mode?: number; uid?: number }\n | { type: \"cmd\"; command: CommandDef; mode?: number }\n | { type: \"link\"; target: string }\n | { type: \"action\"; action: ActionDef; mode?: number }\n | { type: \"dev\"; read?: () => string; write?: (data: string) => void; mode?: number }\n\n/** What the editor may read synchronously from the vfs cache. */\nexport interface Inode {\n type: InodeType\n mode: number\n uid: number\n /** Present for cmd inodes. */\n command?: CommandInfo\n}\n\nexport interface CallOptions {\n signal?: AbortSignal\n}\n\nexport interface WriteOptions extends CallOptions {\n mode: \"truncate\" | \"append\"\n}\n\n/**\n * Paths given to the vfs are absolute or relative to `cwd`. Tilde is a\n * kernel expansion and never reaches the vfs. `..` resolves lexically.\n */\nexport interface Vfs {\n stat(path: string, cwd: string, o?: CallOptions): Promise<Stat>\n list(path: string, cwd: string, o?: CallOptions): Promise<Entry[]>\n read(path: string, cwd: string, o?: CallOptions): Promise<string>\n write(path: string, cwd: string, data: string, o: WriteOptions): Promise<void>\n mkdir(path: string, cwd: string, o?: CallOptions & { parents?: boolean }): Promise<void>\n remove(path: string, cwd: string, o?: CallOptions & { recursive?: boolean }): Promise<void>\n /** Only cd, open, and cat call this. stat and list never trigger actions. */\n activate(path: string, cwd: string, via: ActionVia): Promise<ActionResult | null>\n /** Absolute, normalized path. Does not check existence. */\n resolve(path: string, cwd: string): string\n /** Cache only, synchronous, never does I/O. The editor uses only this. */\n peek(path: string, cwd: string): Inode | undefined\n /** Create or replace an inode (host setup and kernel use). */\n put(path: string, spec: InodeSpec): void\n mount(path: string, provider: MountProvider): void\n unmount(path: string): void\n /** Permission check for the given uid: r, w, or x. Root bypasses. */\n access(path: string, cwd: string, uid: number, want: \"r\" | \"w\" | \"x\"): Promise<boolean>\n}\n\n/** A subtree served by a host object or a remote server. Paths are relative to the mount root, \"\" is the root. */\nexport interface MountProvider {\n readonly readonly: boolean\n stat(rel: string, o: CallOptions): Promise<Stat>\n list(rel: string, o: CallOptions): Promise<Entry[]>\n read(rel: string, o: CallOptions): Promise<string>\n write?(rel: string, data: string, o: WriteOptions): Promise<void>\n mkdir?(rel: string, o: CallOptions): Promise<void>\n remove?(rel: string, o: CallOptions): Promise<void>\n /** Called with a relative path when something under the mount changes. Returns an unsubscribe. */\n watch?(onChange: (rel: string) => void): () => void\n}\n\n// ---------------------------------------------------------------- processes\n\nexport type Env = Record<string, string>\n\nexport interface Tty {\n readonly cols: number\n readonly rows: number\n /** Read one line from the terminal. echo:false for passwords. Never recorded in history. */\n read(options?: { echo?: boolean; prompt?: string; signal?: AbortSignal }): Promise<string | null>\n /** Unfiltered output. Local commands only (clear, egg animations). */\n raw(data: string): Promise<void>\n}\n\nexport type StdioKind = \"tty\" | \"pipe\" | \"file\" | \"null\"\n\nexport interface Stdio {\n stdin: StdioKind\n stdout: StdioKind\n stderr: StdioKind\n}\n\nexport type FlagValue = boolean | string | number | Array<string | number>\nexport type Flags = Record<string, FlagValue | undefined>\n\nexport interface Proc {\n /** argv[0] is the name the command was invoked by. */\n readonly argv: readonly string[]\n /** Parsed flags, keyed by the long name when one exists, else the short name. */\n readonly flags: Flags\n /** Operands after flag parsing; argv.slice(1) when the command declares no flags. */\n readonly args: readonly string[]\n /** The resolved subcommand path, e.g. [\"devices\", \"ls\"]. Empty when none. */\n readonly subcommand: readonly string[]\n readonly stdin: ReadableStream<string>\n readonly stdout: WritableStream<string>\n readonly stderr: WritableStream<string>\n /** Write to stdout or stderr; resolves when the sink accepted the chunk. Commands write \"\\n\". */\n out(text: string): Promise<void>\n err(text: string): Promise<void>\n /** stdin split into lines, without terminators. */\n lines(): AsyncIterable<string>\n readonly env: Readonly<Env>\n readonly cwd: string\n readonly uid: number\n readonly fs: Vfs\n /** Aborted on ^C (reason \"INT\") or when a downstream reader exits (reason \"EPIPE\"). */\n readonly signal: AbortSignal\n /** Null when stdout is not the terminal. */\n readonly tty: Tty | null\n readonly stdio: Stdio\n readonly sys: Sys\n}\n\n/** A command's body. void means exit 0. A throw is exit 1 with one stderr line. */\nexport type Run = (p: Proc) => Promise<number | void>\n\nexport type Resolution =\n | { kind: \"alias\"; name: string; body: string }\n | { kind: \"builtin\"; name: string; info: CommandInfo }\n | { kind: \"command\"; name: string; path: string; info: CommandInfo }\n | { kind: \"egg\"; name: string; id: string }\n | { kind: \"not-found\"; name: string }\n\nexport interface SessionView {\n readonly user: string\n readonly uid: number\n readonly cwd: string\n readonly hostname: string\n readonly home: string\n readonly lastStatus: number\n}\n\n/** The kernel facade a command may use. */\nexport interface Sys {\n resolve(name: string): Resolution\n commands(): CommandInfo[]\n /** Run argv as a child. stdio defaults to the caller's. */\n spawn(argv: readonly string[], options?: { uid?: number; env?: Env; stdio?: Partial<StdioStreams> }): Promise<number>\n /** Run a full line (rite -c, source). */\n run(line: string, options?: { env?: Env }): Promise<number>\n readonly session: SessionView\n /** Host configuration for sudo. */\n readonly sudo: SudoPolicy\n history(): readonly string[]\n}\n\nexport interface StdioStreams {\n stdin: ReadableStream<string>\n stdout: WritableStream<string>\n stderr: WritableStream<string>\n}\n\nexport type SudoPolicy = boolean | ((password: string) => boolean | Promise<boolean>)\n\n/** Builtins also receive the mutable session. In a pipeline the changes do not persist. */\nexport interface Session {\n user: string\n uid: number\n cwd: string\n oldCwd: string\n hostname: string\n home: string\n env: Env\n /** Names exported to child processes. */\n exported: Set<string>\n aliases: Map<string, string>\n lastStatus: number\n /** Set by the exit builtin. */\n exitRequested: number | null\n}\n\nexport type BuiltinRun = (p: Proc, session: Session) => Promise<number | void>\n\n// ---------------------------------------------------------------- commands\n\nexport interface FlagDef {\n long?: string\n short?: string\n type: \"boolean\" | \"string\" | \"number\"\n /** Repeatable flags collect into an array. */\n repeat?: boolean\n default?: FlagValue\n description?: string\n}\n\nexport interface Candidate {\n value: string\n display?: string\n description?: string\n /** Appended after insertion: \" \" by default, \"/\" for directories, \"\" to keep typing. */\n suffix?: string\n}\n\nexport interface CompleteContext {\n argv: readonly string[]\n /** Index into argv of the word being completed. */\n index: number\n prefix: string\n env: Readonly<Env>\n cwd: string\n fs: Vfs\n signal: AbortSignal\n}\n\nexport type Completer = (ctx: CompleteContext) => Promise<Candidate[]>\n\nexport interface CommandDef {\n name: string\n summary: string\n usage: string\n /** Keyed by the canonical name (long when present). Omit to receive raw argv. */\n flags?: Record<string, FlagDef>\n subcommands?: Record<string, Omit<CommandDef, \"name\">>\n complete?: Completer\n run?: Run\n /** Longer text for man. */\n manual?: string\n}\n\nexport interface CommandInfo {\n name: string\n summary: string\n usage: string\n /** Longer text for man, when the definition has one. */\n manual?: string\n flags?: Record<string, FlagDef>\n subcommands?: Record<string, { summary: string; usage: string }>\n builtin: boolean\n remote: boolean\n}\n\n/** Supplies commands from outside the vfs tree (the remote client). */\nexport interface CommandSource {\n /** Names known before connecting, so completion and which work early. */\n names(): string[]\n info(name: string): CommandInfo | undefined\n run(name: string, p: Proc): Promise<number>\n complete?(argv: readonly string[], index: number, signal: AbortSignal): Promise<Candidate[]>\n}\n\n// ---------------------------------------------------------------- eggs\n\nexport const PASS: unique symbol = Symbol(\"rite.pass\")\nexport type EggResult = number | void | typeof PASS\n\nexport type EggTrigger =\n | { command: string; when?: (argv: readonly string[], session: SessionView) => boolean }\n | { input: RegExp }\n | { keys: string }\n\nexport interface EggDef {\n id: string\n trigger: EggTrigger\n run: (p: Proc) => Promise<EggResult>\n}\n\n// ---------------------------------------------------------------- completion\n\nexport interface Completion {\n /** The span of the line the candidates replace. */\n span: Span\n candidates: Candidate[]\n}\n\n// ---------------------------------------------------------------- terminal\n\nexport type OutputPolicy = \"plain\" | \"sgr\" | \"raw\"\n\nexport interface TermSize {\n cols: number\n rows: number\n}\n\n/** The only boundary to xterm. The editor renders through it; tests back it with @xterm/headless. */\nexport interface Term {\n /**\n * Write complete text with a policy; resolves once xterm has parsed it.\n * \"\\n\" becomes \"\\r\\n\". Each call is filtered on its own: an escape\n * sequence cut off at the end of the data is dropped.\n */\n write(data: string, policy: OutputPolicy): Promise<void>\n /**\n * A writer for one stream (a process's stdout): its filter keeps an escape\n * sequence split across chunks until it completes, apart from every other\n * writer.\n */\n writer(policy: OutputPolicy): (chunk: string) => Promise<void>\n /** Key input, already decoded into strings, terminal replies discarded. Returns an unsubscribe. */\n onInput(listener: (data: string) => void): () => void\n onResize(listener: (size: TermSize) => void): () => void\n readonly size: TermSize\n /** Replace the terminal's colors (xterm ITheme keys). */\n setTheme(theme: Theme): void\n /** Display width of one code point: 0, 1, or 2. */\n width(codePoint: number): 0 | 1 | 2\n focus(): void\n fit(): void\n dispose(): void\n}\n\n// ---------------------------------------------------------------- kernel\n\nexport interface Kernel {\n readonly session: SessionView\n /** Run one line as if typed. Queued behind any running job. */\n exec(line: string, stdio?: Partial<StdioStreams>): Promise<number>\n /** Run one egg directly (a key trigger), queued like a line. */\n runEgg(egg: EggDef): Promise<number>\n complete(line: string, cursor: number, o: { signal: AbortSignal }): Promise<Completion>\n /** Abort the foreground job (^C). */\n interrupt(): void\n readonly running: boolean\n register(def: CommandDef, at?: string): void\n registerEgg(def: EggDef): void\n /** Eggs with key triggers, for the editor. */\n keyEggs(): readonly EggDef[]\n addCommandSource(at: string, source: CommandSource): void\n readonly vfs: Vfs\n readonly parser: Parser\n}\n\n// ---------------------------------------------------------------- host\n\nexport type HistoryMode = \"local\" | \"memory\" | false\n\n/** Terminal colors: xterm's ITheme keys (strings, and extendedAnsi as a list). */\nexport interface Theme {\n [key: string]: string | readonly string[] | undefined\n extendedAnsi?: readonly string[]\n}\n\nexport interface HostOptions {\n element: HTMLElement\n hostname?: string\n user?: string\n /** Printed before the first prompt; SGR colors are kept, every other escape sequence is dropped. */\n motd?: string\n files?: Record<string, FileContent>\n inodes?: Record<string, InodeSpec>\n mounts?: Array<{ path: string; provider: MountProvider }>\n commands?: CommandDef[]\n eggs?: EggDef[] | false\n remote?: RemoteHandle\n sudo?: SudoPolicy\n history?: HistoryMode\n /** xterm ITheme keys; `themes` has brass, tide, dusk (dark) and paper (light) ready-made. */\n theme?: Theme\n /** The terminal's font. Load web fonts before createRite so the cell size is measured right. */\n font?: { family?: string; size?: number }\n screenReaderMode?: boolean\n onAction?: (e: ActionEvent) => void\n}\n\n/** What rite/remote hands to createRite. Core never imports the remote module. */\nexport interface RemoteHandle {\n readonly at: string\n readonly bin: string\n readonly provider: MountProvider\n readonly commands: CommandSource\n connect(): Promise<void>\n /** The terminal's size changed: tell the server (tty.resize) if connected. */\n resize(cols: number, rows: number): void\n dispose(): void\n onNotify(listener: (text: string, level: \"info\" | \"warn\" | \"error\") => void): () => void\n}\n\nexport interface Rite {\n readonly ready: Promise<void>\n exec(line: string): Promise<{ code: number }>\n print(text: string): void\n focus(): void\n fit(): void\n /** The terminal's size in cells. */\n readonly size: TermSize\n /** Called after the terminal changes size (a fit, a resize). Returns an unsubscribe. */\n onResize(listener: (size: TermSize) => void): () => void\n /** Replace the terminal's colors, such as `themes.paper`. */\n setTheme(theme: Theme): void\n dispose(): void\n}\n"],"mappings":";;AAMA,MAAa,SAAS;CACpB;CAAU;CAAW;CAAU;CAAU;CAAS;CAAU;CAC5D;CAAS;CAAS;CAAU;CAAW;CAAU;CAAO;CACxD;CAAa;CAAa;AAC5B;AAGA,MAAa,iBAAwC;CACnD,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,QAAQ;CACR,OAAO;CACP,QAAQ;CACR,WAAW;CACX,OAAO;CACP,OAAO;CACP,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,KAAK;CACL,OAAO;CACP,WAAW;CACX,WAAW;CACX,UAAU;AACZ;;AAGA,IAAa,YAAb,cAA+B,MAAM;CAC1B;CACA;CACT,YAAY,OAAc,MAAe,SAAkB;EACzD,MAAM,WAAW,eAAe,MAAM;EACtC,KAAK,OAAO;EACZ,KAAK,QAAQ;EACb,KAAK,OAAO;CACd;AACF;;AAGA,MAAa,OAAO;CAClB,IAAI;CACJ,SAAS;CACT,OAAO;CACP,gBAAgB;CAChB,WAAW;CACX,aAAa;CACb,iBAAiB;AACnB;AAkYA,MAAa,OAAsB,OAAO,WAAW"}
@@ -1,4 +1,4 @@
1
- /*! ritesh | MIT | Copyright (c) 2026 Jarrod Baumann | bundles xterm.js (MIT, see THIRD_PARTY_NOTICES) */
1
+ /*! ritesh | MIT | Copyright (c) 2026 Jarrod Baumann | bundles xterm.js and ipaddr.js (MIT, see THIRD_PARTY_NOTICES) */
2
2
  declare const ERRNOS: readonly ["ENOENT", "ENOTDIR", "EISDIR", "EACCES", "EPERM", "EEXIST", "ENOTEMPTY", "EROFS", "ELOOP", "EINVAL", "ENOTSUP", "ENOSPC", "EIO", "EPIPE", "ECANCELED", "ETIMEDOUT", "ENOTCONN"];
3
3
  type Errno = (typeof ERRNOS)[number];
4
4
  declare const ERRNO_MESSAGES: Record<Errno, string>;
@@ -1,5 +1,5 @@
1
- /*! ritesh | MIT | Copyright (c) 2026 Jarrod Baumann | bundles xterm.js (MIT, see THIRD_PARTY_NOTICES) */
2
- import { l as CommandDef, v as EggDef } from "./contracts-C55jYvFz.js";
1
+ /*! ritesh | MIT | Copyright (c) 2026 Jarrod Baumann | bundles xterm.js and ipaddr.js (MIT, see THIRD_PARTY_NOTICES) */
2
+ import { l as CommandDef, v as EggDef } from "./contracts-DwXN7Pv9.js";
3
3
  /** Identity helpers that give a command or egg definition its type. */
4
4
  declare function defineCommand(def: CommandDef): CommandDef;
5
5
  declare function defineEgg(def: EggDef): EggDef;
@@ -1,5 +1,5 @@
1
- /*! ritesh | MIT | Copyright (c) 2026 Jarrod Baumann | bundles xterm.js (MIT, see THIRD_PARTY_NOTICES) */
2
- import { i as PASS, r as EXIT } from "./contracts-CFeF8xY8.js";
1
+ /*! ritesh | MIT | Copyright (c) 2026 Jarrod Baumann | bundles xterm.js and ipaddr.js (MIT, see THIRD_PARTY_NOTICES) */
2
+ import { i as PASS, r as EXIT } from "./contracts-0hnYHcIF.js";
3
3
  // src/define.ts
4
4
  /** Identity helpers that give a command or egg definition its type. */
5
5
  function defineCommand(def) {
@@ -85,4 +85,4 @@ const sudoers = defineEgg({
85
85
  const eggs = [sudoers, rmrf];
86
86
  export { defineEgg as a, defineCommand as i, sudoers as n, rmrf as r, eggs as t };
87
87
 
88
- //# sourceMappingURL=eggs-Dtm-FrKN.js.map
88
+ //# sourceMappingURL=eggs-xvNKRzfj.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"eggs-Dtm-FrKN.js","names":[],"sources":["../src/define.ts","../src/eggs/rmrf.ts","../src/eggs/sudoers.ts","../src/eggs/index.ts"],"sourcesContent":["import type { CommandDef, EggDef } from \"./contracts.js\"\n\n/** Identity helpers that give a command or egg definition its type. */\nexport function defineCommand(def: CommandDef): CommandDef {\n return def\n}\n\nexport function defineEgg(def: EggDef): EggDef {\n return def\n}\n","import { type Entry, EXIT } from \"../contracts.js\"\nimport { defineEgg } from \"../define.js\"\n\n/** Entries shown from each top-level directory. */\nconst PER_DIR = 6\n\n/** Lexical: \".\" and empty components drop, \"..\" pops and stops at the root. */\nfunction normalize(path: string, cwd: string): string {\n const parts: string[] = []\n for (const part of (path.startsWith(\"/\") ? path : `${cwd}/${path}`).split(\"/\")) {\n if (part === \"\" || part === \".\") continue\n if (part === \"..\") parts.pop()\n else parts.push(part)\n }\n return \"/\" + parts.join(\"/\")\n}\n\n/**\n * True for `rm` with the recursive and the force flag, in any spelling, and\n * an operand that normalizes to \"/\". Other options are ignored, as rm would\n * read them, and nothing after `--` is an option.\n */\nexport function wipesRoot(argv: readonly string[], cwd: string): boolean {\n let recursive = false\n let force = false\n let root = false\n let options = true\n for (const word of argv.slice(1)) {\n if (options && word === \"--\") options = false\n else if (options && word.startsWith(\"--\")) {\n if (word === \"--recursive\") recursive = true\n else if (word === \"--force\") force = true\n } else if (options && word.length > 1 && word.startsWith(\"-\")) {\n for (const letter of word.slice(1)) {\n if (letter === \"r\" || letter === \"R\") recursive = true\n else if (letter === \"f\") force = true\n }\n } else if (word !== \"\" && normalize(word, cwd) === \"/\") root = true\n }\n return recursive && force && root\n}\n\n/** `rm -rf /`: a deletion that is not happening, then the admission. */\nexport const rmrf = defineEgg({\n id: \"rmrf\",\n trigger: { command: \"rm\", when: (argv, session) => wipesRoot(argv, session.cwd) },\n run: async (p) => {\n const list = (path: string): Promise<Entry[]> =>\n p.fs.list(path, \"/\", { signal: p.signal }).catch((): Entry[] => [])\n try {\n // Plain lines through stdout: the names may come from a mount, so they are never raw.\n for (const entry of await list(\"/\")) {\n if (p.signal.aborted) return EXIT.INTERRUPTED\n const path = `/${entry.name}`\n if (entry.type !== \"dir\") {\n await p.out(`removed ${path}\\n`)\n continue\n }\n for (const child of (await list(path)).slice(0, PER_DIR)) await p.out(`removed ${path}/${child.name}\\n`)\n await p.out(`removed directory ${path}\\n`)\n }\n await p.out(\"just kidding. nothing here is yours to delete.\\n\")\n return EXIT.OK\n } catch (e) {\n if (p.signal.aborted) return EXIT.INTERRUPTED\n throw e\n }\n },\n})\n","import { EXIT, PASS } from \"../contracts.js\"\nimport { defineEgg } from \"../define.js\"\n\n/** Answers `sudo <command>` when the host lets nobody use sudo, which is the default. */\nexport const sudoers = defineEgg({\n id: \"sudoers\",\n trigger: { command: \"sudo\" },\n run: async (p) => {\n // The policy is not part of what a trigger's predicate sees, so it is checked here.\n if (p.sys.sudo !== false || p.argv.length < 2) return PASS\n await p.err(`${p.sys.session.user} is not in the sudoers file. This incident will be reported.\\n`)\n return EXIT.FAILURE\n },\n})\n","import type { EggDef } from \"../contracts.js\"\nimport { rmrf } from \"./rmrf.js\"\nimport { sudoers } from \"./sudoers.js\"\n\nexport { rmrf } from \"./rmrf.js\"\nexport { sudoers } from \"./sudoers.js\"\n\n/** The eggs shipped with ritesh, for `createRite({ eggs })`. */\nexport const eggs: EggDef[] = [sudoers, rmrf]\n"],"mappings":";;;;AAGA,SAAgB,cAAc,KAA6B;CACzD,OAAO;AACT;AAEA,SAAgB,UAAU,KAAqB;CAC7C,OAAO;AACT;;;ACLA,MAAM,UAAU;;AAGhB,SAAS,UAAU,MAAc,KAAqB;CACpD,MAAM,QAAkB,CAAC;CACzB,KAAK,MAAM,SAAS,KAAK,WAAW,GAAG,IAAI,OAAO,GAAG,IAAI,GAAG,OAAA,CAAQ,MAAM,GAAG,GAAG;EAC9E,IAAI,SAAS,MAAM,SAAS,KAAK;EACjC,IAAI,SAAS,MAAM,MAAM,IAAI;OACxB,MAAM,KAAK,IAAI;CACtB;CACA,OAAO,MAAM,MAAM,KAAK,GAAG;AAC7B;;;;;;AAOA,SAAgB,UAAU,MAAyB,KAAsB;CACvE,IAAI,YAAY;CAChB,IAAI,QAAQ;CACZ,IAAI,OAAO;CACX,IAAI,UAAU;CACd,KAAK,MAAM,QAAQ,KAAK,MAAM,CAAC,GAC7B,IAAI,WAAW,SAAS,MAAM,UAAU;MACnC,IAAI,WAAW,KAAK,WAAW,IAAI,GAAG;EACzC,IAAI,SAAS,eAAe,YAAY;OACnC,IAAI,SAAS,WAAW,QAAQ;CACvC,OAAO,IAAI,WAAW,KAAK,SAAS,KAAK,KAAK,WAAW,GAAG,GACrD;OAAA,MAAM,UAAU,KAAK,MAAM,CAAC,GAC/B,IAAI,WAAW,OAAO,WAAW,KAAK,YAAY;OAC7C,IAAI,WAAW,KAAK,QAAQ;CAAA,OAE9B,IAAI,SAAS,MAAM,UAAU,MAAM,GAAG,MAAM,KAAK,OAAO;CAEjE,OAAO,aAAa,SAAS;AAC/B;;AAGA,MAAa,OAAO,UAAU;CAC5B,IAAI;CACJ,SAAS;EAAE,SAAS;EAAM,OAAO,MAAM,YAAY,UAAU,MAAM,QAAQ,GAAG;CAAE;CAChF,KAAK,OAAO,MAAM;EAChB,MAAM,QAAQ,SACZ,EAAE,GAAG,KAAK,MAAM,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,YAAqB,CAAC,CAAC;EACpE,IAAI;GAEF,KAAK,MAAM,SAAS,MAAM,KAAK,GAAG,GAAG;IACnC,IAAI,EAAE,OAAO,SAAS,OAAO,KAAK;IAClC,MAAM,OAAO,IAAI,MAAM;IACvB,IAAI,MAAM,SAAS,OAAO;KACxB,MAAM,EAAE,IAAI,WAAW,KAAK,GAAG;KAC/B;IACF;IACA,KAAK,MAAM,UAAU,MAAM,KAAK,IAAI,EAAA,CAAG,MAAM,GAAG,OAAO,GAAG,MAAM,EAAE,IAAI,WAAW,KAAK,GAAG,MAAM,KAAK,GAAG;IACvG,MAAM,EAAE,IAAI,qBAAqB,KAAK,GAAG;GAC3C;GACA,MAAM,EAAE,IAAI,kDAAkD;GAC9D,OAAO,KAAK;EACd,SAAS,GAAG;GACV,IAAI,EAAE,OAAO,SAAS,OAAO,KAAK;GAClC,MAAM;EACR;CACF;AACF,CAAC;;;AChED,MAAa,UAAU,UAAU;CAC/B,IAAI;CACJ,SAAS,EAAE,SAAS,OAAO;CAC3B,KAAK,OAAO,MAAM;EAEhB,IAAI,EAAE,IAAI,SAAS,SAAS,EAAE,KAAK,SAAS,GAAG,OAAO;EACtD,MAAM,EAAE,IAAI,GAAG,EAAE,IAAI,QAAQ,KAAK,+DAA+D;EACjG,OAAO,KAAK;CACd;AACF,CAAC;;;ACLD,MAAa,OAAiB,CAAC,SAAS,IAAI"}
1
+ {"version":3,"file":"eggs-xvNKRzfj.js","names":[],"sources":["../src/define.ts","../src/eggs/rmrf.ts","../src/eggs/sudoers.ts","../src/eggs/index.ts"],"sourcesContent":["import type { CommandDef, EggDef } from \"./contracts.js\"\n\n/** Identity helpers that give a command or egg definition its type. */\nexport function defineCommand(def: CommandDef): CommandDef {\n return def\n}\n\nexport function defineEgg(def: EggDef): EggDef {\n return def\n}\n","import { type Entry, EXIT } from \"../contracts.js\"\nimport { defineEgg } from \"../define.js\"\n\n/** Entries shown from each top-level directory. */\nconst PER_DIR = 6\n\n/** Lexical: \".\" and empty components drop, \"..\" pops and stops at the root. */\nfunction normalize(path: string, cwd: string): string {\n const parts: string[] = []\n for (const part of (path.startsWith(\"/\") ? path : `${cwd}/${path}`).split(\"/\")) {\n if (part === \"\" || part === \".\") continue\n if (part === \"..\") parts.pop()\n else parts.push(part)\n }\n return \"/\" + parts.join(\"/\")\n}\n\n/**\n * True for `rm` with the recursive and the force flag, in any spelling, and\n * an operand that normalizes to \"/\". Other options are ignored, as rm would\n * read them, and nothing after `--` is an option.\n */\nexport function wipesRoot(argv: readonly string[], cwd: string): boolean {\n let recursive = false\n let force = false\n let root = false\n let options = true\n for (const word of argv.slice(1)) {\n if (options && word === \"--\") options = false\n else if (options && word.startsWith(\"--\")) {\n if (word === \"--recursive\") recursive = true\n else if (word === \"--force\") force = true\n } else if (options && word.length > 1 && word.startsWith(\"-\")) {\n for (const letter of word.slice(1)) {\n if (letter === \"r\" || letter === \"R\") recursive = true\n else if (letter === \"f\") force = true\n }\n } else if (word !== \"\" && normalize(word, cwd) === \"/\") root = true\n }\n return recursive && force && root\n}\n\n/** `rm -rf /`: a deletion that is not happening, then the admission. */\nexport const rmrf = defineEgg({\n id: \"rmrf\",\n trigger: { command: \"rm\", when: (argv, session) => wipesRoot(argv, session.cwd) },\n run: async (p) => {\n const list = (path: string): Promise<Entry[]> =>\n p.fs.list(path, \"/\", { signal: p.signal }).catch((): Entry[] => [])\n try {\n // Plain lines through stdout: the names may come from a mount, so they are never raw.\n for (const entry of await list(\"/\")) {\n if (p.signal.aborted) return EXIT.INTERRUPTED\n const path = `/${entry.name}`\n if (entry.type !== \"dir\") {\n await p.out(`removed ${path}\\n`)\n continue\n }\n for (const child of (await list(path)).slice(0, PER_DIR)) await p.out(`removed ${path}/${child.name}\\n`)\n await p.out(`removed directory ${path}\\n`)\n }\n await p.out(\"just kidding. nothing here is yours to delete.\\n\")\n return EXIT.OK\n } catch (e) {\n if (p.signal.aborted) return EXIT.INTERRUPTED\n throw e\n }\n },\n})\n","import { EXIT, PASS } from \"../contracts.js\"\nimport { defineEgg } from \"../define.js\"\n\n/** Answers `sudo <command>` when the host lets nobody use sudo, which is the default. */\nexport const sudoers = defineEgg({\n id: \"sudoers\",\n trigger: { command: \"sudo\" },\n run: async (p) => {\n // The policy is not part of what a trigger's predicate sees, so it is checked here.\n if (p.sys.sudo !== false || p.argv.length < 2) return PASS\n await p.err(`${p.sys.session.user} is not in the sudoers file. This incident will be reported.\\n`)\n return EXIT.FAILURE\n },\n})\n","import type { EggDef } from \"../contracts.js\"\nimport { rmrf } from \"./rmrf.js\"\nimport { sudoers } from \"./sudoers.js\"\n\nexport { rmrf } from \"./rmrf.js\"\nexport { sudoers } from \"./sudoers.js\"\n\n/** The eggs shipped with ritesh, for `createRite({ eggs })`. */\nexport const eggs: EggDef[] = [sudoers, rmrf]\n"],"mappings":";;;;AAGA,SAAgB,cAAc,KAA6B;CACzD,OAAO;AACT;AAEA,SAAgB,UAAU,KAAqB;CAC7C,OAAO;AACT;;;ACLA,MAAM,UAAU;;AAGhB,SAAS,UAAU,MAAc,KAAqB;CACpD,MAAM,QAAkB,CAAC;CACzB,KAAK,MAAM,SAAS,KAAK,WAAW,GAAG,IAAI,OAAO,GAAG,IAAI,GAAG,OAAA,CAAQ,MAAM,GAAG,GAAG;EAC9E,IAAI,SAAS,MAAM,SAAS,KAAK;EACjC,IAAI,SAAS,MAAM,MAAM,IAAI;OACxB,MAAM,KAAK,IAAI;CACtB;CACA,OAAO,MAAM,MAAM,KAAK,GAAG;AAC7B;;;;;;AAOA,SAAgB,UAAU,MAAyB,KAAsB;CACvE,IAAI,YAAY;CAChB,IAAI,QAAQ;CACZ,IAAI,OAAO;CACX,IAAI,UAAU;CACd,KAAK,MAAM,QAAQ,KAAK,MAAM,CAAC,GAC7B,IAAI,WAAW,SAAS,MAAM,UAAU;MACnC,IAAI,WAAW,KAAK,WAAW,IAAI,GAAG;EACzC,IAAI,SAAS,eAAe,YAAY;OACnC,IAAI,SAAS,WAAW,QAAQ;CACvC,OAAO,IAAI,WAAW,KAAK,SAAS,KAAK,KAAK,WAAW,GAAG,GACrD;OAAA,MAAM,UAAU,KAAK,MAAM,CAAC,GAC/B,IAAI,WAAW,OAAO,WAAW,KAAK,YAAY;OAC7C,IAAI,WAAW,KAAK,QAAQ;CAAA,OAE9B,IAAI,SAAS,MAAM,UAAU,MAAM,GAAG,MAAM,KAAK,OAAO;CAEjE,OAAO,aAAa,SAAS;AAC/B;;AAGA,MAAa,OAAO,UAAU;CAC5B,IAAI;CACJ,SAAS;EAAE,SAAS;EAAM,OAAO,MAAM,YAAY,UAAU,MAAM,QAAQ,GAAG;CAAE;CAChF,KAAK,OAAO,MAAM;EAChB,MAAM,QAAQ,SACZ,EAAE,GAAG,KAAK,MAAM,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,YAAqB,CAAC,CAAC;EACpE,IAAI;GAEF,KAAK,MAAM,SAAS,MAAM,KAAK,GAAG,GAAG;IACnC,IAAI,EAAE,OAAO,SAAS,OAAO,KAAK;IAClC,MAAM,OAAO,IAAI,MAAM;IACvB,IAAI,MAAM,SAAS,OAAO;KACxB,MAAM,EAAE,IAAI,WAAW,KAAK,GAAG;KAC/B;IACF;IACA,KAAK,MAAM,UAAU,MAAM,KAAK,IAAI,EAAA,CAAG,MAAM,GAAG,OAAO,GAAG,MAAM,EAAE,IAAI,WAAW,KAAK,GAAG,MAAM,KAAK,GAAG;IACvG,MAAM,EAAE,IAAI,qBAAqB,KAAK,GAAG;GAC3C;GACA,MAAM,EAAE,IAAI,kDAAkD;GAC9D,OAAO,KAAK;EACd,SAAS,GAAG;GACV,IAAI,EAAE,OAAO,SAAS,OAAO,KAAK;GAClC,MAAM;EACR;CACF;AACF,CAAC;;;AChED,MAAa,UAAU,UAAU;CAC/B,IAAI;CACJ,SAAS,EAAE,SAAS,OAAO;CAC3B,KAAK,OAAO,MAAM;EAEhB,IAAI,EAAE,IAAI,SAAS,SAAS,EAAE,KAAK,SAAS,GAAG,OAAO;EACtD,MAAM,EAAE,IAAI,GAAG,EAAE,IAAI,QAAQ,KAAK,+DAA+D;EACjG,OAAO,KAAK;CACd;AACF,CAAC;;;ACLD,MAAa,OAAiB,CAAC,SAAS,IAAI"}
package/dist/eggs.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- /*! ritesh | MIT | Copyright (c) 2026 Jarrod Baumann | bundles xterm.js (MIT, see THIRD_PARTY_NOTICES) */
2
- import { L as PASS, b as EggTrigger, v as EggDef, y as EggResult } from "./contracts-C55jYvFz.js";
3
- import { n as defineEgg } from "./define-9nO3xQor.js";
1
+ /*! ritesh | MIT | Copyright (c) 2026 Jarrod Baumann | bundles xterm.js and ipaddr.js (MIT, see THIRD_PARTY_NOTICES) */
2
+ import { L as PASS, b as EggTrigger, v as EggDef, y as EggResult } from "./contracts-DwXN7Pv9.js";
3
+ import { n as defineEgg } from "./define-C14xvFmq.js";
4
4
  /** `rm -rf /`: a deletion that is not happening, then the admission. */
5
5
  export declare const rmrf: EggDef;
6
6
  /** Answers `sudo <command>` when the host lets nobody use sudo, which is the default. */
package/dist/eggs.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! ritesh | MIT | Copyright (c) 2026 Jarrod Baumann | bundles xterm.js (MIT, see THIRD_PARTY_NOTICES) */
2
- import { i as PASS } from "./contracts-CFeF8xY8.js";
3
- import { a as defineEgg, n as sudoers, r as rmrf, t as eggs } from "./eggs-Dtm-FrKN.js";
1
+ /*! ritesh | MIT | Copyright (c) 2026 Jarrod Baumann | bundles xterm.js and ipaddr.js (MIT, see THIRD_PARTY_NOTICES) */
2
+ import { i as PASS } from "./contracts-0hnYHcIF.js";
3
+ import { a as defineEgg, n as sudoers, r as rmrf, t as eggs } from "./eggs-xvNKRzfj.js";
4
4
  export { PASS, defineEgg, eggs, rmrf, sudoers };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- /*! ritesh | MIT | Copyright (c) 2026 Jarrod Baumann | bundles xterm.js (MIT, see THIRD_PARTY_NOTICES) */
2
- import { $ as Span, A as Inode, B as Parser, C as Errno, D as Flags, E as FlagValue, F as MountProvider, G as RemoteHandle, H as Proc, I as OutputPolicy, J as RiteError, K as Resolution, L as PASS, M as InodeType, N as Kernel, O as HistoryMode, P as List, Q as SimpleCommand, R as ParseOptions, S as Env, T as FlagDef, U as Redirect, V as Pipeline, W as RedirectOp, X as Session, Y as Run, Z as SessionView, _ as EXIT, a as Assignment, at as SyntaxErrorInfo, b as EggTrigger, c as Candidate, ct as TermSize, d as CommandSource, dt as TokenKind, et as Stat, f as CompleteContext, ft as Tty, g as ERRNO_MESSAGES, gt as WriteOptions, h as ERRNOS, ht as WordPart, i as ActionVia, it as SudoPolicy, j as InodeSpec, k as HostOptions, l as CommandDef, lt as Theme, m as Completion, mt as Word, n as ActionEvent, nt as StdioKind, o as BuiltinRun, ot as Sys, p as Completer, pt as Vfs, q as Rite, r as ActionResult, rt as StdioStreams, s as CallOptions, st as Term, t as ActionDef, tt as Stdio, u as CommandInfo, ut as Token, v as EggDef, w as FileContent, x as Entry, y as EggResult, z as ParseResult } from "./contracts-C55jYvFz.js";
3
- import { n as defineEgg, t as defineCommand } from "./define-9nO3xQor.js";
1
+ /*! ritesh | MIT | Copyright (c) 2026 Jarrod Baumann | bundles xterm.js and ipaddr.js (MIT, see THIRD_PARTY_NOTICES) */
2
+ import { $ as Span, A as Inode, B as Parser, C as Errno, D as Flags, E as FlagValue, F as MountProvider, G as RemoteHandle, H as Proc, I as OutputPolicy, J as RiteError, K as Resolution, L as PASS, M as InodeType, N as Kernel, O as HistoryMode, P as List, Q as SimpleCommand, R as ParseOptions, S as Env, T as FlagDef, U as Redirect, V as Pipeline, W as RedirectOp, X as Session, Y as Run, Z as SessionView, _ as EXIT, a as Assignment, at as SyntaxErrorInfo, b as EggTrigger, c as Candidate, ct as TermSize, d as CommandSource, dt as TokenKind, et as Stat, f as CompleteContext, ft as Tty, g as ERRNO_MESSAGES, gt as WriteOptions, h as ERRNOS, ht as WordPart, i as ActionVia, it as SudoPolicy, j as InodeSpec, k as HostOptions, l as CommandDef, lt as Theme, m as Completion, mt as Word, n as ActionEvent, nt as StdioKind, o as BuiltinRun, ot as Sys, p as Completer, pt as Vfs, q as Rite, r as ActionResult, rt as StdioStreams, s as CallOptions, st as Term, t as ActionDef, tt as Stdio, u as CommandInfo, ut as Token, v as EggDef, w as FileContent, x as Entry, y as EggResult, z as ParseResult } from "./contracts-DwXN7Pv9.js";
3
+ import { n as defineEgg, t as defineCommand } from "./define-C14xvFmq.js";
4
4
  /** The rite version: RITE_VERSION, `rite --version`, and the parser's messages. */
5
- export declare const VERSION = "0.1.0";
5
+ export declare const VERSION = "0.2.0";
6
6
  /** PROMPT escapes: %n user, %m host, %~ cwd, %# (# for root, else %), %? last status, %F{color}...%f, %% a percent. */
7
7
  export declare function renderPrompt(prompt: string, s: {
8
8
  user: string;
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
- /*! ritesh | MIT | Copyright (c) 2026 Jarrod Baumann | bundles xterm.js (MIT, see THIRD_PARTY_NOTICES) */
2
- import { t as __exportAll } from "./rolldown-runtime-dOZj-Y2f.js";
3
- import { a as defineEgg, i as defineCommand, t as eggs } from "./eggs-Dtm-FrKN.js";
4
- import { a as RiteError, i as PASS, n as ERRNO_MESSAGES, r as EXIT, t as ERRNOS } from "./contracts-CFeF8xY8.js";
5
- import { i as o, n as L, r as Ke, t as Dl } from "./vendor/xterm-Bn51SPNn.js";
1
+ /*! ritesh | MIT | Copyright (c) 2026 Jarrod Baumann | bundles xterm.js and ipaddr.js (MIT, see THIRD_PARTY_NOTICES) */
2
+ import { n as __exportAll } from "./rolldown-runtime-Sht-Y2pv.js";
3
+ import { a as defineEgg, i as defineCommand, t as eggs } from "./eggs-xvNKRzfj.js";
4
+ import { a as RiteError, i as PASS, n as ERRNO_MESSAGES, r as EXIT, t as ERRNOS } from "./contracts-0hnYHcIF.js";
5
+ import { i as o, n as L, r as Ke, t as Dl } from "./vendor/xterm-CqUeQQJm.js";
6
6
  /** Lines per stdout write when the output is already in memory. */
7
7
  const BATCH = 256;
8
8
  function flag(p, name) {
@@ -117,6 +117,21 @@ function countFlag(p, name) {
117
117
  const value = p.flags[name];
118
118
  return typeof value === "number" && Number.isInteger(value) && value >= 0 ? value : void 0;
119
119
  }
120
+ /**
121
+ * head and tail's line count and files: -n N, or the older first operand -N
122
+ * (`head -5`), which other shells still take.
123
+ */
124
+ function lineCount(p) {
125
+ const short = /^-(\d+)$/.exec(p.args[0] ?? "");
126
+ if (short) return {
127
+ count: Number(short[1]),
128
+ operands: inputs(p, p.args.slice(1))
129
+ };
130
+ return {
131
+ count: countFlag(p, "lines"),
132
+ operands: inputs(p)
133
+ };
134
+ }
120
135
  /** Order by code point, the order the language uses for glob results. */
121
136
  function byCodePoint(a, b) {
122
137
  const n = Math.min(a.length, b.length);
@@ -378,9 +393,8 @@ const head = defineCommand({
378
393
  } },
379
394
  manual: ["Prints the first lines of each file, or of stdin. With several files each", "is headed by `==> name <==`. Reading stdin stops once the lines are printed."].join("\n"),
380
395
  run: body("head", async (p) => {
381
- const count = countFlag(p, "lines");
396
+ const { count, operands } = lineCount(p);
382
397
  if (count === void 0) return usageError(p, "head", USAGE$10, "invalid number of lines");
383
- const operands = inputs(p);
384
398
  let first = true;
385
399
  return each(p, "head", operands, async (operand) => {
386
400
  const lines = operand === "-" ? void 0 : splitLines(await p.fs.read(operand, p.cwd, { signal: p.signal }));
@@ -891,9 +905,8 @@ const tail = defineCommand({
891
905
  } },
892
906
  manual: ["Prints the last lines of each file, or of stdin. With several files each", "is headed by `==> name <==`. There is no -f: nothing is followed."].join("\n"),
893
907
  run: body("tail", async (p) => {
894
- const count = countFlag(p, "lines");
908
+ const { count, operands } = lineCount(p);
895
909
  if (count === void 0) return usageError(p, "tail", USAGE$4, "invalid number of lines");
896
- const operands = inputs(p);
897
910
  let first = true;
898
911
  return each(p, "tail", operands, async (operand) => {
899
912
  let lines;
@@ -5948,7 +5961,7 @@ async function produce(content, path) {
5948
5961
  }
5949
5962
  // src/rite.ts
5950
5963
  /** The rite version: RITE_VERSION, `rite --version`, and the parser's messages. */
5951
- const VERSION = "0.1.0";
5964
+ const VERSION = "0.2.0";
5952
5965
  const DEFAULT_PROMPT = "%F{green}%n@%m%f %F{blue}%~%f %# ";
5953
5966
  /**
5954
5967
  * Wires a shell over a Term. createRite is this with the browser's xterm;