Docs · Toolchain
package.vyipac
package.vyipac is a package's manifest: a YAML file in the package's root
folder. This page lists every key the compiler reads, with its type, meaning,
and default. Guide
14, Modules and packages
introduces packages, and the CLI reference shows
how commands use the manifest's entries.
name: shop
version: 0.1.0
lang: 0.0.1
deps:
json: ^1.0.0
entries:
shop: src/main.vyi
shop-admin: src/admin.vyi
export: src/lib.vyi
source:
root: src
exclude:
- "**/*.tests.vyi"
comptime:
maxDepth: 4096
maxSteps: 400000Keys
Every key is optional, and an empty file is a valid manifest.
| Key | Type | Default | Meaning |
|---|---|---|---|
name | string | none | the package's name |
version | string | none | the package's version |
lang | string | 0.0.1 | the Vyi version the package is written for; picks the version of every @ package |
deps | map of name to string | none | third-party packages and their version constraints |
entries | map of name to path | none | the package's programs: a name for each, and its entry file |
export | path | none | the package's library file |
source | mapping | every .vyi file | which files the language server treats as part of the package |
comptime | mapping | the compiler's limits | limits on compile-time evaluation |
hasBuiltIns | bool | false | lets the package use :<markBuiltIn() |
hasInlineMarkers | bool | false | lets the package use :<markInline() |
Paths are relative to the folder that holds the manifest, with / between
folders.
A file that isn't valid YAML, or a key whose value has the wrong shape (a number where a map belongs, say), fails every build under the manifest:
vyi run: imports: parse manifest package.vyipac: yaml: unmarshal errors:
line 2: cannot unmarshal !!int `5` into map[string]stringThe compiler ignores a key not in the table. The editor marks it with the
warning vyipacUnknownKey, marks a value of the wrong shape with
vyipacWrongType, and completes key names as you type.
Which manifest applies
For a program, the manifest is the first package.vyipac found in the entry
file's folder or a folder above it. The folder that holds it is the
package root:
- Paths in errors are relative to the package root.
- A relative import may not leave the package root. One that does is an error:
import "../../shared/util" escapes the package root. lang,deps,comptime, and the two permission keys are read from this manifest. The manifest of a package the program imports never changes them.
Without a manifest, the entry file's folder is the root. An import that climbs
above it finds nothing:
imported file "../shared/util" not found (looked for ../shared/util.vyi).
Such a program has no deps, so it can import only relative paths and @
packages, and it uses the standard packages' default version.
A vyi command given an entry name, or no program, looks for the manifest
from the current folder instead (CLI).
name, version, lang
name: shop
version: 0.1.0
lang: 0.0.1nameidentifies the package. Names that start with@belong to the standard packages, such as@coreand@io.versionis the package's own version, a semantic version such as0.1.0.langis the Vyi version the package is written for. It is also the version of every@package the program imports: withlang: 0.0.1, an import of"@fmt"loads@fmt0.0.1. Withoutlang, or without a manifest, the version is0.0.1. A version that isn't installed fails each@import withpackage "@fmt" ([email protected]) not found, and, because@corecan't load either, names such asResultandOkare undefined.
The compiler reads each of the three as text and doesn't check its format.
deps
deps:
json: ^1.0.0
http: 2.3.0deps maps each third-party package the program uses to a version
constraint. A dependency is imported by its bare name, with no ./ and no
@, as in import { decode } from "json". Importing a bare name that deps
doesn't declare is an error:
import { decode } from "json" // error: unknown dependency "json"
fn main() !u8 { return Ok(0) }Fetching and installing dependencies is (planned). An import of a declared
dependency fails with cannot resolve import "json", and the constraints are
not read.
entries
entries:
shop: src/main.vyi
shop-admin: src/admin.vyientries names the package's programs. Each key is a program's name, and its
value is the program's entry file. A program is its entry file and every file
its imports reach. vyi run shop runs the entry named shop, and vyi run
with no name runs them all (CLI).
An entry file must exist and must declare a top-level main: a fn main, or a
con main bound to an arrow function. vyi reports a broken entry on stderr
and leaves it out of the command:
| Problem | Reported as |
|---|---|
| the file doesn't exist | entryFileMissing: entry "ghost" points at "src/nope.vyi", which does not exist |
the file has no top-level main | entryFileNoMain: entry "lib" points at a file that has no main: "src/lib.vyi" |
This check looks only for the declaration. The signature main must have,
fn main() !u8, is checked when the program compiles
(guide 07).
When a package declares entries, a .vyi file given to a vyi command must
be one of them (CLI).
export
export: src/lib.vyiexport names the package's library file: the file another package gets when
it imports this one by name. It needs no main, and it usually re-exports the
package's public names. A package can declare both entries and export.
The file must exist; a missing one is reported as entryFileMissing:
export points at "src/lib.vyi", which does not exist. Importing a package by
name through its export file comes with dependency installation
(planned).
source
source:
root: src
include:
- "**/*.vyi"
exclude:
- "vendor/**"
- "**/*.tests.vyi"source says which .vyi files under the manifest's folder belong to the
package. The language server reads it: it checks, and reports errors in, the
files that belong. vyi commands compile what a program's imports reach and
don't read source, and an import reaches a file whether or not it belongs.
Without source, every .vyi file under the manifest's folder belongs. With
it, a file belongs when all three hold:
- it is under
root, a folder relative to the manifest (.or norootmeans the manifest's own folder), - it matches an
includepattern, orincludeis missing or empty, - it matches no
excludepattern.
| Key | Type | Default |
|---|---|---|
root | path to a folder | the manifest's folder |
include | list of patterns | every .vyi file under root |
exclude | list of patterns | none |
A pattern is matched against the file's path relative to root, one segment
(the part between /s) at a time:
| Pattern | Matches |
|---|---|
* | any characters within one segment |
? | one character within a segment |
[abc], [a-z] | one character from the set or range |
** | any number of whole segments, including none |
**/*.tests.vyi matches a test file at any depth, including directly under
root. vendor/*.vyi matches only files directly inside vendor/.
The editor marks a root that isn't a folder with sourceRootMissing.
Nested manifests
A package.vyipac can sit inside another package's folders, such as a
vendored package. Each .vyi file belongs to the nearest manifest at or above
it, and only that manifest's source decides whether the file belongs. A
manifest without source still claims every file under its folder, so an outer
package never claims a file under an inner manifest. An outer
exclude: ["vendor/**"] isn't needed to keep vendor/lib/ out when
vendor/lib/ has its own manifest.
comptime
comptime:
maxDepth: 4096
maxSteps: 400000comptime limits compile-time evaluation
(known values)
in the programs built from this package.
| Key | Type | Default | Meaning |
|---|---|---|---|
maxDepth | positive integer | 1024 | how many calls deep one compile-time evaluation may nest |
maxSteps | positive integer | 100000 | how many steps one compile-time evaluation may take; each loop iteration and each call is a step, and the count starts over for each evaluation |
An evaluation that goes deeper fails with comptimeDepthExceeded, and one that
takes more steps fails with comptimeStepLimitExceeded. The message names the
manifest key and the flag that raise the limit.
- The flags
--comptime-max-depthand--comptime-max-stepsoverride these for one command (CLI flags). - A key that is missing, or
0, keeps the default. - A negative value fails every build under the manifest:
comptime.maxSteps must be a positive integer, got -1.
hasBuiltIns and hasInlineMarkers
hasBuiltIns: true
hasInlineMarkers: trueTwo decorators need the package's permission (statements reference):
| Key | Allows |
|---|---|
hasBuiltIns | :<markBuiltIn(), which makes a declaration visible in every file of the program without an import |
hasInlineMarkers | :<markInline(), which puts a function's body in place of each call |
Both are false by default, and @core has both without declaring them.
Using a decorator without the key is an error on the decorator:
markBuiltIn used without manifest opt-in. @fmt and @errors declare
hasBuiltIns, and @mem declares hasInlineMarkers.