tcmts.cli.files

Server

exportFiles (cb: Codebase, ns: string, dir: string, own?: boolean) => number
Write the files kept under `ns` to `dir`, laid out by their names (`ns.a.b` is `a/b.<format>`), and the file named `ns` itself, if there is one and `own`, as `<its name>.<format>`: how many.
fileContent (cb: CodebaseCore, rec: DefRecord, ns: string) => Buffer<ArrayBufferLike>
A file definition's content as it reads now: its `{@link}`s naming what they reach by its current name, from `ns`.
fileDefinition (cb: CodebaseCore, name: string, format: string, content: Buffer<ArrayBufferLike>, alsoNew?: Set<st…
A file kept in the codebase as written, as a definition named `name`. Markdown's `{@link}`s to code are references by hash, so they read with current names and follow updates; its links to other files are kept as written, and checked: one to a file of the codebase that isn't there (and isn't among `alsoNew`) is a warning. A binary format's bytes are kept as base64. `format` is a hidden file's after a dot (`.gitignore` is ".", `.mcp.json` ".json"), kept so in its IR, as it's written back.
fileFormat (file: string) => string | undefined
The format of a file kept in the codebase as written (not code), from its name: its extension, or undefined.
fileLeaf (file: string) => string
A file's name in its namespace: its name without the extension (dashes kept; no dots), and without the dot a hidden file's name starts with (`.gitignore` is `gitignore`, `.mcp.json` is `mcp`).
followMove (cb: Codebase, from: string, to: string) => Map<string, DefRecord>
After the file `from` moved to `to`: the pages whose links change, as new definitions, by name.
linkedName (fromName: string, target: string) => { name: string; rest: string; } | undefined
The file in the codebase a page's link reaches, by its name (and the rest of the link: `#anchor`), or undefined for a link that isn't to such a file (a URL, the same page, code, somewhere outside the codebase).
linkingTo (cb: Codebase, name: string) => string[]
The pages (Markdown files) that link to the file named `name`.
relinked (cb: Codebase, name: string, rec: DefRecord, from: string, to: string) => string | undefined
A page's text with its links following a move: links to `from` lead to `to`, and if the page is the one that moved (`name` was `from`), its links to others are written from where it is now. Undefined if nothing changes.

Shared

BINARY_FORMATS Set<string>
FILE_PATH RegExp
A name a file can have: a namespace path, then its own name (letters, digits, `_`, `-`).
TEXT_FORMATS Set<string>
Formats kept as written, by extension: text ones as text, the rest as bytes.
dirSegment (dir: string) => string
A namespace segment for a directory, as the mirror names them (`src` directories don't count).
fileName (leaf: string, rec: DefRecord) => string
A file's name on disk: its name in the codebase, and its format as the extension (none for a file without one, like `Dockerfile`), after a dot for a hidden file (`.gitignore`, `.mcp.json`).
filesIn (cb: CodebaseCore, ns: string) => Map<string, DefRecord>
The files kept in the codebase under `ns` (all of them for ""): name → definition.
formatOf (rec: DefRecord) => string
A file definition's format, from its IR: its extension ("" for a file without one, like `Dockerfile`), without the dot a hidden file's starts with (`fileName` puts it back).
isBytes (rec: DefRecord) => boolean
Whether a file definition holds bytes (an image, or anything that isn't text) rather than text.
isText (content: Buffer<ArrayBufferLike>) => boolean
Whether content is text: valid UTF-8.
linkedCode (cb: CodebaseCore, ns: string, name: string) => string | undefined
The definition a page's `@link` tag in `ns` names: by that name, or within `ns` or a namespace above it.
markdownLinks (text: string) => { start: number; end: number; target: string; code: boolean; }[]
Where a Markdown file links, outside code (fences and inline code): `[text](target)`, `[label]: target`, and `@link` tags naming code (`code`). Offsets are the target's.
relativeLink (fromName: string, toName: string, format: string) => string
How a page links to a file of the codebase: the relative path from the one name to the other (with its format).

Tests

testHiddenFilesKeepTheirDot () => void
A file's format is its extension (none for a `Dockerfile`), after a dot for a hidden file, so it's written back with it; what reads a format sees it without the dot, and a file that isn't hidden is kept as it always was.