1use std::collections::BTreeMap;
5
6use crate::{
7 Dispatch, MethodSig, PackageDeclaration, Param, PropertySig, Span, Type, TypeKind, TypeSymbol,
8 ValueKind, ValueSymbol,
9};
10
11use super::MODULE_NAME;
12
13pub fn package_declaration() -> PackageDeclaration {
14 let mut defs = PackageDeclaration::with_package(MODULE_NAME);
15
16 let path_param = Param::new("path", Type::String);
17 let bytes_or_undefined = Type::union(vec![Type::Uint8Array, Type::Undefined]);
18 let string_or_undefined = Type::union(vec![Type::String, Type::Undefined]);
19
20 insert_stat_interface(&mut defs);
21 insert_peek_interface(&mut defs);
22 insert_file_writer_interface(&mut defs);
23 insert_dir_entry_interface(&mut defs);
24 insert_mount_info_interface(&mut defs);
25 insert_info_interface(&mut defs);
26
27 insert_fn(
28 &mut defs,
29 "cwd",
30 Vec::new(),
31 Type::String,
32 "/** The absolute guest working directory used by relative paths. Shared by the program and packages; no capability required. Defaults to `/`. */",
33 );
34 insert_fn(
35 &mut defs,
36 "maxReadSize",
37 Vec::new(),
38 Type::Number,
39 "/**\n * Maximum number of bytes `read` / `readText` will load whole; past this they return `undefined`. Also the upper bound on `readBytes(path, offset, length)`'s `length`. Configured by the harness per Store; defaults to the 50 MB tier memory cap.\n */",
40 );
41 insert_fn(
42 &mut defs,
43 "info",
44 Vec::new(),
45 Type::InterfaceRef {
46 mangled: crate::mangle::package_symbol(MODULE_NAME, "Info"),
47 package: crate::Package(MODULE_NAME.to_string()),
48 name: "Info".to_string(),
49 args: Vec::new(),
50 },
51 "/**\n * The active VFS configuration: the root's `mode` (`\"none\"` / `\"ephemeral\"` / `\"per_session\"` / `\"named\"`), `access`, `volume` and `sizeLimit` (the cap on the bytes its files may hold, or `-1` when none applies), plus `mounts`, the named volumes grafted below the root. Deterministic; no capability required. The host directories backing the VFS are never exposed.\n */",
52 );
53 insert_fn(
54 &mut defs,
55 "exists",
56 vec![path_param.clone()],
57 Type::Boolean,
58 "/**\n * Returns `true` iff `path` resolves to a filesystem entry under the VFS root. Symlinks count as existing; broken symlinks count as not existing (mirrors `std::path::exists`).\n * @param path File path under the VFS root.\n * @capability fs.stat { path }\n */",
59 );
60 insert_fn(
61 &mut defs,
62 "size",
63 vec![path_param.clone()],
64 Type::Number,
65 "/**\n * File size in bytes. Traps on directories or missing paths — call `exists(path)` first or use `stat(path)` if you need to handle absence.\n * @param path File path under the VFS root.\n * @capability fs.stat { path }\n */",
66 );
67 insert_fn(
68 &mut defs,
69 "stat",
70 vec![path_param.clone()],
71 Type::Union(vec![
72 Type::InterfaceRef {
73 mangled: crate::mangle::package_symbol(MODULE_NAME, "Stat"),
74 package: crate::Package(MODULE_NAME.to_string()),
75 name: "Stat".to_string(),
76 args: Vec::new(),
77 },
78 Type::Undefined,
79 ]),
80 "/**\n * Metadata about an entry under the VFS root. Returns `undefined` when the path does not exist; otherwise returns a `Stat` carrying `kind` / `size` / `modifiedAt`.\n * @param path File path under the VFS root.\n * @capability fs.stat { path }\n */",
81 );
82 insert_fn(
83 &mut defs,
84 "peek",
85 vec![path_param.clone()],
86 Type::InterfaceRef {
87 mangled: crate::mangle::package_symbol(MODULE_NAME, "Peek"),
88 package: crate::Package(MODULE_NAME.to_string()),
89 name: "Peek".to_string(),
90 args: Vec::new(),
91 },
92 "/**\n * Quick file-only inspection: preview (first ~256 bytes decoded UTF-8 lossy), detected `encoding` (`utf-8` / `utf-16le` / `utf-16be` / `latin1`), `lineEnding` (`lf` / `crlf`), and total `size`. Traps on directories / missing paths.\n * @param path File path under the VFS root.\n * @capability fs.stat { path }\n */",
93 );
94 insert_fn(
95 &mut defs,
96 "read",
97 vec![path_param.clone()],
98 bytes_or_undefined.clone(),
99 "/**\n * Read the whole file as a `Uint8Array`. Returns `undefined` when the file is larger than `maxReadSize()` — the typechecker forces narrowing before use. Traps on missing paths or directories.\n * @param path File path under the VFS root.\n * @capability fs.read { path }\n */",
100 );
101 insert_fn(
102 &mut defs,
103 "readText",
104 vec![path_param.clone()],
105 string_or_undefined.clone(),
106 "/**\n * Read the whole file as a UTF-8 string. Returns `undefined` when the file is larger than `maxReadSize()`. Strips a leading UTF-8 BOM by default; invalid bytes are replaced by U+FFFD.\n * @param path File path under the VFS root.\n * @capability fs.read { path }\n */",
107 );
108 insert_fn(
109 &mut defs,
110 "write",
111 vec![path_param.clone(), Param::new("content", Type::Uint8Array)],
112 Type::Void,
113 "/**\n * Write `content` to `path` atomically (temp-file + rename). Throws when the parent directory does not exist — agents must `mkdir(parent, { recursive: true })` first.\n * @param path File path under the VFS root.\n * @param content Bytes to write.\n * @capability fs.write { path, length: number }\n */",
114 );
115 insert_fn(
116 &mut defs,
117 "writeText",
118 vec![path_param.clone(), Param::new("content", Type::String)],
119 Type::Void,
120 "/**\n * UTF-8 atomic write. Same parent-directory rule as `write`.\n * @param path File path under the VFS root.\n * @param content Text to write as UTF-8.\n * @capability fs.write { path, length: number }\n */",
121 );
122 insert_fn(
123 &mut defs,
124 "append",
125 vec![path_param.clone(), Param::new("content", Type::Uint8Array)],
126 Type::Void,
127 "/**\n * Append `content` to `path`. Creates the file if missing; throws when the parent directory does not exist. NOT atomic — concurrent writers race.\n * @param path File path under the VFS root.\n * @param content Bytes to append.\n * @capability fs.write { path, length: number }\n */",
128 );
129 insert_fn(
130 &mut defs,
131 "appendText",
132 vec![path_param.clone(), Param::new("content", Type::String)],
133 Type::Void,
134 "/**\n * UTF-8 append. Same parent-directory rule as `append`.\n * @param path File path under the VFS root.\n * @param content Text to append as UTF-8.\n * @capability fs.write { path, length: number }\n */",
135 );
136 insert_fn(
137 &mut defs,
138 "readBytes",
139 vec![
140 path_param.clone(),
141 Param::new("offset", Type::Number),
142 Param::new("length", Type::Number),
143 ],
144 Type::Uint8Array,
145 "/**\n * Random-access byte-range read. Traps if `length > maxReadSize()`, if `offset` is negative, or on I/O errors. The returned `Uint8Array` may be shorter than `length` if the request runs past EOF.\n * @param path File path under the VFS root.\n * @param offset Zero-based byte offset.\n * @param length Maximum number of bytes to read.\n * @capability fs.read { path, length }\n */",
146 );
147 insert_fn(
148 &mut defs,
149 "mkdir",
150 vec![path_param.clone(), Param::new("recursive", Type::Boolean)],
151 Type::Void,
152 "/**\n * Create the directory at `path`. `recursive=true` creates intermediate directories (like `mkdir -p`); `recursive=false` throws when the parent is missing or the target already exists. Until options objects land, the flag is positional.\n * @param path Directory path under the VFS root.\n * @param recursive Whether to create missing parents.\n * @capability fs.mkdir { path, recursive }\n */",
153 );
154 insert_fn(
155 &mut defs,
156 "remove",
157 vec![path_param.clone(), Param::new("recursive", Type::Boolean)],
158 Type::Void,
159 "/**\n * Remove the entry at `path`. Files unconditionally; directories require `recursive=true` (matches `rm -rf`). Without the flag, a non-empty directory throws.\n * @param path File or directory path under the VFS root.\n * @param recursive Whether to remove directories recursively.\n * @capability fs.remove { path, recursive }\n */",
160 );
161 insert_fn(
162 &mut defs,
163 "move",
164 vec![
165 Param::new("from", Type::String),
166 Param::new("to", Type::String),
167 ],
168 Type::Void,
169 "/**\n * Move / rename. Atomic within one volume. Between volumes (the root and a mount, or two mounts — see `info().mounts`) it copies, then removes the source, so it is not atomic: if removing the source fails, the destination is kept and the call throws with both copies present. Replacing a file in another volume needs room there for both versions until the move completes, and a link the copy cannot reproduce fails the move before the source is touched.\n * @param from Source path under the VFS root.\n * @param to Destination path under the VFS root.\n * @capability fs.move { from, to }\n */",
170 );
171 insert_fn(
172 &mut defs,
173 "copy",
174 vec![
175 Param::new("from", Type::String),
176 Param::new("to", Type::String),
177 Param::new("recursive", Type::Boolean),
178 ],
179 Type::Void,
180 "/**\n * Copy `from` to `to`. Directories require `recursive=true`. Symlinks are copied as links (the link target is preserved; the file it points at is not followed) so a writable VFS area can't be used to exfiltrate the target.\n * @param from Source path under the VFS root.\n * @param to Destination path under the VFS root.\n * @param recursive Whether to copy directories recursively.\n * @capability fs.copy { from, to, recursive }\n */",
181 );
182 insert_fn(
183 &mut defs,
184 "writer",
185 vec![path_param.clone()],
186 Type::InterfaceRef {
187 mangled: crate::mangle::package_symbol(MODULE_NAME, "FileWriter"),
188 package: crate::Package(MODULE_NAME.to_string()),
189 name: "FileWriter".to_string(),
190 args: Vec::new(),
191 },
192 "/**\n * Open `path` as an append-only `FileWriter`. The writer buffers internally and only commits on `close()` (atomic temp-file + rename) — half-written outputs from a crashed transform don't leak. Throws when the parent directory does not exist.\n * @param path Destination path under the VFS root.\n * @capability fs.write { path }\n */",
193 );
194 insert_fn(
195 &mut defs,
196 "lines",
197 vec![path_param.clone()],
198 Type::InterfaceRef {
199 mangled: crate::mangle::prelude("Iterator"),
200 package: crate::Package::prelude(),
201 name: "Iterator".to_string(),
202 args: vec![Type::String],
203 },
204 "/**\n * Stream the file at `path` as a constant-memory line iterator. Each `next()` returns one line stripped of its trailing CR/LF. A leading UTF-8 BOM on the first line is dropped. The file descriptor is released when the iterator is closed (a `for...of` loop closes it on exit, including `break`/`throw`) or, failing that, when it is garbage-collected.\n * @param path File path under the VFS root.\n * @capability fs.read { path }\n */",
205 );
206 insert_fn(
207 &mut defs,
208 "bytes",
209 vec![path_param.clone(), Param::new("chunkSize", Type::Number)],
210 Type::InterfaceRef {
211 mangled: crate::mangle::prelude("Iterator"),
212 package: crate::Package::prelude(),
213 name: "Iterator".to_string(),
214 args: vec![Type::Uint8Array],
215 },
216 "/**\n * Stream the file at `path` as a constant-memory byte iterator. Each `next()` returns up to `chunkSize` bytes; the last chunk may be shorter. Sized for large binary inputs that don't fit `maxReadSize`.\n * @param path File path under the VFS root.\n * @param chunkSize Maximum bytes per iterator chunk.\n * @capability fs.read { path, chunkSize }\n */",
217 );
218 insert_fn(
219 &mut defs,
220 "list",
221 vec![path_param.clone(), Param::new("recursive", Type::Boolean)],
222 Type::InterfaceRef {
223 mangled: crate::mangle::prelude("Iterator"),
224 package: crate::Package::prelude(),
225 name: "Iterator".to_string(),
226 args: vec![Type::InterfaceRef {
227 mangled: crate::mangle::package_symbol(MODULE_NAME, "DirEntry"),
228 package: crate::Package(MODULE_NAME.to_string()),
229 name: "DirEntry".to_string(),
230 args: Vec::new(),
231 }],
232 },
233 "/**\n * List the children of the directory at `path` as a constant-memory iterator of `DirEntry`. `recursive=true` walks descendants as well; `recursive=false` yields only direct children.\n *\n * Order: a directory is always yielded before its contents, and a directory's whole subtree is yielded as one consecutive run — no entry from outside a subtree is interleaved into it. Down to 32 levels of nesting that is exactly depth-first (matching `find` / `os.walk`); deeper than that the walk runs out of directory handles and a subdirectory's contents follow the rest of its parent's entries instead of coming directly after it, so don't depend on strict depth-first order past that depth. Siblings come in whatever order the filesystem reports — not sorted.\n *\n * Symlinks surface as `kind=\"symlink\"` and are not followed. A recursive walk is best-effort: a subdirectory it cannot read — or, past a fixed ceiling on how many postponed descents one walk holds, cannot afford to remember — is skipped and the walk continues, so a listing is not proof that a path is absent.\n * @param path Directory path under the VFS root.\n * @param recursive Whether to walk descendants recursively.\n * @capability fs.list { path, recursive }\n */",
234 );
235
236 defs
237}
238
239fn insert_fn(defs: &mut PackageDeclaration, name: &str, params: Vec<Param>, ret: Type, doc: &str) {
240 defs.values.insert(
241 name.to_string(),
242 ValueSymbol {
243 name: name.to_string(),
244 mangled_name: crate::mangle::package_symbol(MODULE_NAME, name),
245 declaration_span: Span::at(crate::FileId::FS),
246 kind: ValueKind::Function {
247 generics: Vec::new(),
248 params,
249 ret,
250 type_predicate: None,
251 doc: crate::doc(crate::FileId::FS, doc),
252 },
253 },
254 );
255}
256
257fn insert_stat_interface(defs: &mut PackageDeclaration) {
258 let mut properties = BTreeMap::new();
259 insert_property(
260 &mut properties,
261 "kind",
262 Type::String,
263 "/** One of `\"file\"` / `\"directory\"` / `\"symlink\"` / `\"other\"`. Symlinks are reported as `\"symlink\"` without dereferencing. */",
264 );
265 insert_property(
266 &mut properties,
267 "size",
268 Type::Number,
269 "/** File size in bytes. `0` for non-files (directories, symlinks, other). */",
270 );
271 insert_property(
272 &mut properties,
273 "modifiedAt",
274 Type::Number,
275 "/** Last-modified timestamp in milliseconds since the Unix epoch. `0` when the underlying filesystem doesn't report one. */",
276 );
277 defs.types.insert(
278 "Stat".to_string(),
279 TypeSymbol {
280 name: "Stat".to_string(),
281 mangled_name: crate::mangle::package_symbol(MODULE_NAME, "Stat"),
282 declaration_span: Span::at(crate::FileId::FS),
283 kind: TypeKind::Interface { index: None,
284 generics: Vec::new(),
285 methods: BTreeMap::new(),
286 properties,
287 dispatch: Dispatch::Direct,
288 doc: crate::doc(crate::FileId::FS,
289 "/** Filesystem metadata returned by `stat(path)`. Constructed only by `stat`; user code reads `kind` / `size` / `modifiedAt` via property access. */",
290 ),
291 },
292 },
293 );
294}
295
296fn insert_peek_interface(defs: &mut PackageDeclaration) {
297 let mut properties = BTreeMap::new();
298 insert_property(
299 &mut properties,
300 "preview",
301 Type::String,
302 "/** First ~256 bytes of the file decoded as UTF-8 lossy. Use `lines` / `read` for full content. */",
303 );
304 insert_property(
305 &mut properties,
306 "encoding",
307 Type::String,
308 "/** Detected text encoding: `\"utf-8\"` / `\"utf-16le\"` / `\"utf-16be\"` / `\"latin1\"`. BOM-driven when a BOM is present; falls back to a UTF-8 validity check then `latin1`. */",
309 );
310 insert_property(
311 &mut properties,
312 "lineEnding",
313 Type::String,
314 "/** `\"crlf\"` if a CRLF sequence appears in the preview; `\"lf\"` otherwise (including files with no line terminators yet). */",
315 );
316 insert_property(
317 &mut properties,
318 "size",
319 Type::Number,
320 "/** Total file size in bytes — same value as `size(path)`. */",
321 );
322 defs.types.insert(
323 "Peek".to_string(),
324 TypeSymbol {
325 name: "Peek".to_string(),
326 mangled_name: crate::mangle::package_symbol(MODULE_NAME, "Peek"),
327 declaration_span: Span::at(crate::FileId::FS),
328 kind: TypeKind::Interface { index: None,
329 generics: Vec::new(),
330 methods: BTreeMap::new(),
331 properties,
332 dispatch: Dispatch::Direct,
333 doc: crate::doc(crate::FileId::FS,
334 "/** Lightweight file-only inspection — preview + transport metadata. Constructed only by `peek`; user code reads fields via property access. */",
335 ),
336 },
337 },
338 );
339}
340
341fn insert_dir_entry_interface(defs: &mut PackageDeclaration) {
342 let mut properties = BTreeMap::new();
343 insert_property(
344 &mut properties,
345 "kind",
346 Type::String,
347 "/** `\"file\"` / `\"directory\"` / `\"symlink\"` / `\"other\"`. */",
348 );
349 insert_property(
350 &mut properties,
351 "name",
352 Type::String,
353 "/** Basename of the entry (no parent path). */",
354 );
355 insert_property(
356 &mut properties,
357 "path",
358 Type::String,
359 "/** Full guest-visible path under the VFS root, with a leading `/`. */",
360 );
361 insert_property(
362 &mut properties,
363 "size",
364 Type::Number,
365 "/** File size in bytes; `0` for non-files. */",
366 );
367 defs.types.insert(
368 "DirEntry".to_string(),
369 TypeSymbol {
370 name: "DirEntry".to_string(),
371 mangled_name: crate::mangle::package_symbol(MODULE_NAME, "DirEntry"),
372 declaration_span: Span::at(crate::FileId::FS),
373 kind: TypeKind::Interface { index: None,
374 generics: Vec::new(),
375 methods: BTreeMap::new(),
376 properties,
377 dispatch: Dispatch::Direct,
378 doc: crate::doc(crate::FileId::FS,
379 "/** Directory entry yielded by `list(path, recursive)`. Properties: `kind` / `name` / `path` / `size`. Constructed only by the iterator. */",
380 ),
381 },
382 },
383 );
384}
385
386fn insert_info_interface(defs: &mut PackageDeclaration) {
387 let mut properties = BTreeMap::new();
388 insert_property(
389 &mut properties,
390 "mode",
391 Type::String,
392 "/** The root's mode: `\"none\"` / `\"ephemeral\"` / `\"per_session\"` / `\"named\"`. */",
393 );
394 insert_property(
395 &mut properties,
396 "sizeLimit",
397 Type::Number,
398 "/** The most bytes the files in the root may hold, or `-1` when no limit applies. A write that would pass it throws a `QuotaExceededError`. A named volume's limit is shared with every session and blueprint that uses it. */",
399 );
400 insert_property(
401 &mut properties,
402 "access",
403 Type::String,
404 "/** `\"read_write\"`, or `\"read_only\"` when every write to the root throws a `PermissionDeniedError`. */",
405 );
406 insert_property(
407 &mut properties,
408 "volume",
409 Type::String,
410 "/** The named volume backing the root under `mode: \"named\"`; `\"\"` otherwise, and for a directory `submilli run --vfs` exposes. */",
411 );
412 insert_property(
413 &mut properties,
414 "mounts",
415 Type::Array(Box::new(mount_info_type())),
416 "/** The named volumes mounted below the root, sorted by path; empty when there are none. Paths under a mount's `path` read and write that volume. */",
417 );
418 defs.types.insert(
419 "Info".to_string(),
420 TypeSymbol {
421 name: "Info".to_string(),
422 mangled_name: crate::mangle::package_symbol(MODULE_NAME, "Info"),
423 declaration_span: Span::at(crate::FileId::FS),
424 kind: TypeKind::Interface { index: None,
425 generics: Vec::new(),
426 methods: BTreeMap::new(),
427 properties,
428 dispatch: Dispatch::Direct,
429 doc: crate::doc(crate::FileId::FS,
430 "/** VFS configuration returned by `info()`: the root's `mode`, `access`, `volume` and `sizeLimit` (`-1` when no limit applies), plus its `mounts`. Never carries a host path. */",
431 ),
432 },
433 },
434 );
435}
436
437fn mount_info_type() -> Type {
438 Type::InterfaceRef {
439 mangled: crate::mangle::package_symbol(MODULE_NAME, "MountInfo"),
440 package: crate::Package(MODULE_NAME.to_string()),
441 name: "MountInfo".to_string(),
442 args: Vec::new(),
443 }
444}
445
446fn insert_mount_info_interface(defs: &mut PackageDeclaration) {
447 let mut properties = BTreeMap::new();
448 insert_property(
449 &mut properties,
450 "path",
451 Type::String,
452 "/** The guest path the volume is mounted at, such as `/memory`. */",
453 );
454 insert_property(
455 &mut properties,
456 "mode",
457 Type::String,
458 "/** Always `\"named\"`: mounts are named volumes the server declares. */",
459 );
460 insert_property(
461 &mut properties,
462 "volume",
463 Type::String,
464 "/** The volume's name. Its files persist across runs and sessions, and other blueprints that mount it see them. */",
465 );
466 insert_property(
467 &mut properties,
468 "access",
469 Type::String,
470 "/** `\"read_write\"`, or `\"read_only\"` when every write under `path` throws a `PermissionDeniedError`. */",
471 );
472 insert_property(
473 &mut properties,
474 "sizeLimit",
475 Type::Number,
476 "/** The most bytes the volume may hold, shared with everyone who mounts it, or `-1` when no limit applies. */",
477 );
478 defs.types.insert(
479 "MountInfo".to_string(),
480 TypeSymbol {
481 name: "MountInfo".to_string(),
482 mangled_name: crate::mangle::package_symbol(MODULE_NAME, "MountInfo"),
483 declaration_span: Span::at(crate::FileId::FS),
484 kind: TypeKind::Interface { index: None,
485 generics: Vec::new(),
486 methods: BTreeMap::new(),
487 properties,
488 dispatch: Dispatch::Direct,
489 doc: crate::doc(crate::FileId::FS,
490 "/** One volume mounted below the VFS root, as `info().mounts` lists it. Mount points cannot be removed or moved. Never carries a host path. */",
491 ),
492 },
493 },
494 );
495}
496
497fn insert_file_writer_interface(defs: &mut PackageDeclaration) {
498 let mut methods = BTreeMap::new();
499 methods.insert(
500 "close".to_string(),
501 MethodSig {
502 optional: false,
503 generics: Vec::new(),
504 params: Vec::new(),
505 ret: Type::Void,
506 predicate: None,
507 doc: crate::doc(crate::FileId::FS,
508 "/** Flush the internal buffer, fsync the temp file, and atomically rename it over the destination. Subsequent method calls on this writer trap — close once. */",
509 ),
510 },
511 );
512 methods.insert(
513 "writeBytes".to_string(),
514 MethodSig {
515 optional: false,
516 generics: Vec::new(),
517 params: vec![Param::new("bytes", Type::Uint8Array)],
518 ret: Type::Void,
519 predicate: None,
520 doc: crate::doc(crate::FileId::FS,
521 "/** Append `bytes` to the buffer. Crash before `close()` means nothing reaches `final_path`. */",
522 ),
523 },
524 );
525 methods.insert(
526 "writeLine".to_string(),
527 MethodSig {
528 optional: false,
529 generics: Vec::new(),
530 params: vec![Param::new("line", Type::String)],
531 ret: Type::Void,
532 predicate: None,
533 doc: crate::doc(crate::FileId::FS,
534 "/** Append `line` followed by `\\n` (LF). Pair with `appendText` for CRLF-aware output. */",
535 ),
536 },
537 );
538 defs.types.insert(
539 "FileWriter".to_string(),
540 TypeSymbol {
541 name: "FileWriter".to_string(),
542 mangled_name: crate::mangle::package_symbol(MODULE_NAME, "FileWriter"),
543 declaration_span: Span::at(crate::FileId::FS),
544 kind: TypeKind::Interface { index: None,
545 generics: Vec::new(),
546 methods,
547 properties: BTreeMap::new(),
548 dispatch: Dispatch::Direct,
549 doc: crate::doc(crate::FileId::FS,
550 "/** Append-only writer returned by `writer(path)`. Internal buffer + atomic temp-file + rename on `close()`. Construct only via `writer`; user code uses `writeLine` / `writeBytes` / `close`. */",
551 ),
552 },
553 },
554 );
555}
556
557fn insert_property(
558 properties: &mut BTreeMap<String, PropertySig>,
559 name: &str,
560 ty: Type,
561 doc: &str,
562) {
563 properties.insert(
564 name.to_string(),
565 PropertySig {
566 ty,
567 readonly: true,
568 intrinsic: false,
569 optional: false,
570 doc: crate::doc(crate::FileId::FS, doc),
571 },
572 );
573}