Skip to main content
A provider turns a locator into units, text and fingerprints. The file provider is built into hibi and serves the schemes file: and repo:. Other sources are served by external providers.

Resource classes

The class of a file follows from its lower-cased extension: Every file also has one unit of kind file that spans all of it; the empty selector, as in --subject file:docs/retry.md, selects it. A code file that does not parse without error cannot be anchored until it parses: every side on it is unavailable with reason resource_unavailable, naming the line where the parser reports its first error (the mistake can be before or after it), a new anchor on it fails, and cover lists it as unavailable (see fingerprints). A #symbol on a markdown, prose or text file is refused, because such a file has no declarations: a new anchor fails with invalid_anchor, and a stored one makes the side unavailable with reason selector_refused. A file that is not valid UTF-8 is not read, and a side on it is unavailable with reason not_text. A code file larger than 2 MiB, or any other file larger than 8 MiB, is unavailable with reason too_large, as is a file with more than 100,000 units. A symbolic link anywhere in the path is not followed: the file counts as not found, and a side on it is missing with reason resource_not_found. CRLF line endings are read as LF. A claim on src/grow.rs#SMALL, after the file grew past 2 MiB:
output
When git can be used, a file: path must also be in the root’s git file list: tracked, or untracked and not ignored, compared byte for byte. A path that differs only in letter case, or a file git ignores, is not found, even on a file system that ignores case. Paths under .git/ and .hibi/ are never read. Without git, any regular file under the root can be read.
output
output

Unit kinds

hibi providers lists the classes and profiles of the build.

Prose

A Markdown or prose file is split into blocks at blank lines, lines that hold only an HTML or JSX tag, and thematic breaks (---, ***, ___). A fenced code block is one unit of kind fenced. A heading, a list item, a blockquote line and a table row each start a new piece; a table’s separator row is dropped. Pieces other than headings and fences are cut into sentences after ., ! or ? followed by whitespace, or followed by one ", ', ) or ] and then whitespace. There is no cut inside an inline code span, inside a list item’s marker such as 3., or at the end of a table row. Three consequences of these rules can surprise:
  • Prose directly after a fence, with no blank line, joins the fenced unit. A block that contains a fence is one fenced unit.
  • An HTML comment is prose. Its text is cut into sentences like any other line, the <!-- and --> included.
  • A setext heading is a sentence. Only # headings are heading units. A line underlined with === becomes one sentence together with its underline.
For example, this file:
docs/split.md
has these units:
output
This document:
docs/guide.md
has these units, as listed by a scope that asks for every prose kind:
output
A list item with two sentences gives two units of kind list-item. A .mdx component tag on its own line is a boundary, so prose inside a component is still split.

Code

Code is parsed with tree-sitter. Six grammars are compiled in: TypeScript, TSX, Python, Rust, Go and Java. Declarations are found at the top level and inside containers (classes, interfaces, traits, impls, structs, enums, modules). hibi never looks inside a function body, so local declarations are not units.
  • Members are units. Struct fields, enum variants, interface members, Java enum constants and record components each are a unit. A data member has kind field; an enum variant or constant has kind variant; a function member has kind method.
  • Attributes and decorators belong to their declaration. A Rust #[derive(...)] or a TypeScript @Injectable() is part of the unit of the declaration it precedes, so changing it stales claims on that declaration.
  • Doc comments are not part of the fingerprint. A comment, including rustdoc, JSDoc and Javadoc, never changes a fingerprint and cannot be quoted in an anchor. A Python docstring is a string and counts.
  • Top-level statements that are not declarations, such as console.log("loaded"); or Go’s package main, are units of kind statement.
These files in src/ give the units below, as listed by a scope over file:src/** with every code kind:
src/config.rs
src/api.ts
The other languages follow the same pattern:

Symbols and keys

The symbol of a declaration is its path, joined with .: MAX_ATTEMPTS, Config.timeout_secs, Store.get, inner.LIMIT. Use it after # in a compact anchor. A Rust impl block is named impl Config (or impl Display for Config for a trait impl); its methods have paths that start with the type, Config.new, whichever impl block they are in. A symbol that contains ::, such as impl fmt::Display for Config, cannot be written in a compact anchor: write the anchor as JSON (see compact anchors). Unit keys identify a unit within one file: A declaration key stays the same when the declaration is edited or moved within the file. A content key stays the same when the unit moves or is edited in a way its fingerprint ignores, such as whitespace, and changes when its fingerprint changes. When two units of a file would get the same key, the second and later in the file get ~2, ~3 and so on, so moving one of them ahead of the other swaps their keys. Exclusions in a scope use these keys.

Sibling repositories

repo:<alias>//<path> reads a file of another git repository with the same rules. The alias must be declared in .hibi/hibi.toml and allowed in your user config; see configuration. The file must also be in the sibling’s git file list: tracked, or untracked and not ignored. Any other path is missing with reason resource_not_found, even when the file exists on disk.