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.

yaml
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: 400000

Keys

Every key is optional, and an empty file is a valid manifest.

KeyTypeDefaultMeaning
namestringnonethe package's name
versionstringnonethe package's version
langstring0.0.1the Vyi version the package is written for; picks the version of every @ package
depsmap of name to stringnonethird-party packages and their version constraints
entriesmap of name to pathnonethe package's programs: a name for each, and its entry file
exportpathnonethe package's library file
sourcemappingevery .vyi filewhich files the language server treats as part of the package
comptimemappingthe compiler's limitslimits on compile-time evaluation
hasBuiltInsboolfalselets the package use :<markBuiltIn()
hasInlineMarkersboolfalselets 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:

text
vyi run: imports: parse manifest package.vyipac: yaml: unmarshal errors:
  line 2: cannot unmarshal !!int `5` into map[string]string

The 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

yaml
name: shop
version: 0.1.0
lang: 0.0.1
  • name identifies the package. Names that start with @ belong to the standard packages, such as @core and @io.
  • version is the package's own version, a semantic version such as 0.1.0.
  • lang is the Vyi version the package is written for. It is also the version of every @ package the program imports: with lang: 0.0.1, an import of "@fmt" loads @fmt 0.0.1. Without lang, or without a manifest, the version is 0.0.1. A version that isn't installed fails each @ import with package "@fmt" ([email protected]) not found, and, because @core can't load either, names such as Result and Ok are undefined.

The compiler reads each of the three as text and doesn't check its format.

deps

yaml
deps:
  json: ^1.0.0
  http: 2.3.0

deps 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:

Vyi · does not compile
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

yaml
entries:
  shop: src/main.vyi
  shop-admin: src/admin.vyi

entries 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:

ProblemReported as
the file doesn't existentryFileMissing: entry "ghost" points at "src/nope.vyi", which does not exist
the file has no top-level mainentryFileNoMain: 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

yaml
export: src/lib.vyi

export 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

yaml
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:

  1. it is under root, a folder relative to the manifest (. or no root means the manifest's own folder),
  2. it matches an include pattern, or include is missing or empty,
  3. it matches no exclude pattern.
KeyTypeDefault
rootpath to a folderthe manifest's folder
includelist of patternsevery .vyi file under root
excludelist of patternsnone

A pattern is matched against the file's path relative to root, one segment (the part between /s) at a time:

PatternMatches
*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

yaml
comptime:
  maxDepth: 4096
  maxSteps: 400000

comptime limits compile-time evaluation (known values) in the programs built from this package.

KeyTypeDefaultMeaning
maxDepthpositive integer1024how many calls deep one compile-time evaluation may nest
maxStepspositive integer100000how 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-depth and --comptime-max-steps override 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

yaml
hasBuiltIns: true
hasInlineMarkers: true

Two decorators need the package's permission (statements reference):

KeyAllows
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.