Skip to content
Topaz6.0 · Before release
Download

Search documentation

Specification 6.0 · Not released · Tested product 5.21.3

Use arrow keys to choose a result. Press Enter to open.

Type an API name, diagnostic number, rule, or project topic.

    Tools

    add

    Adds a dependency to a package manifest.

    Invocation, options and results

    Link

    topaz add

    Synopsis
    1. topaz add <dep>

    Input

    topaz add <name>@<version> declares one exact registry version. topaz add <name> --path <relative-path> declares one local package. A local declaration rejects an operand containing @.

    A dependency name is a nonempty sequence of ASCII letters, digits, underscores, or hyphens. A version is a nonempty exact identifier using ASCII letters, digits, dots, underscores, hyphens, or plus signs. Version ranges are rejected.

    A local path is nonempty and relative to the selected package root. The referenced package must load successfully and its declared package name must match the operand. Parent-relative local paths retain their filesystem meaning.

    --root <dir> defaults to the current directory. The root must contain a valid topaz.toml. The manifest selects the language mode, so --language-version is rejected.

    The name std is managed by the package language mode and cannot be added. A dependency that already exists is rejected even when the requested declaration is equal. Extra operands, --release, output-format options, missing values, repeated options, and attached values are rejected.

    Options and conflicts

    OptionDefaultContractConflicts
    --root <dir>.

    The explicit source root or package root for this invocation.

    None listed
    --path <dir>Not specified

    add only: local dependency path

    None listed

    Output channels

    stdout

    stderr

    Exit status

    0

    The new manifest was validated and written.

    1

    Invalid arguments, invalid manifests, duplicate or reserved names, invalid versions or paths, local package identity mismatches, failed content hashing, and failed manifest writes.

    Effects

    The command reads the root manifest and reads local dependency content when --path is present. It writes the root topaz.toml after validating the complete proposed manifest.

    The new declaration is appended to [dependencies]. The section is created when absent. Existing declarations and other sections retain their order. The resulting text uses line feeds and ends with a line feed.

    The command does not change dependency source files. A write failure is an error and may leave a partial manifest because manifest replacement is not a multi-file transaction.

    The command makes no network requests. Declaring a registry version neither downloads it nor verifies remote availability.

    For the same initial manifest bytes, operand, relative path, and admitted dependency bytes, the resulting manifest bytes are identical. Filesystem timestamps do not select a dependency version or content identity.

    Repeating the same command against its completed result fails as a duplicate declaration.

    The command changes the manifest without updating or deleting topaz.lock and without materializing a vendor tree. An existing lock therefore becomes stale when its manifest identity changes.

    A later lock or vendor operation records the new package identity. A locked compilation rejects the stale lock until it is updated.

    Operation

    Link

    Registry dependencies use an exact version. Local dependencies identify a relative path and its content identity.

    Option conditions

    Link

    --path applies to add only

    add uses topaz.toml [package].language; drop --language-version

    Behavior contract

    Link
    Ruletools-commands-add.rule.behavior

    Command behavior

    Arguments and rejection

    topaz add <name>@<version> declares one exact registry version. topaz add <name> --path <relative-path> declares one local package. A local declaration rejects an operand containing @.

    A dependency name is a nonempty sequence of ASCII letters, digits, underscores, or hyphens. A version is a nonempty exact identifier using ASCII letters, digits, dots, underscores, hyphens, or plus signs. Version ranges are rejected.

    A local path is nonempty and relative to the selected package root. The referenced package must load successfully and its declared package name must match the operand. Parent-relative local paths retain their filesystem meaning.

    --root <dir> defaults to the current directory. The root must contain a valid topaz.toml. The manifest selects the language mode, so --language-version is rejected.

    The name std is managed by the package language mode and cannot be added. A dependency that already exists is rejected even when the requested declaration is equal. Extra operands, --release, output-format options, missing values, repeated options, and attached values are rejected.

    Output

    On success standard output is empty and standard error identifies the added dependency and the updated manifest path.

    Failures write a human diagnostic to standard error. --format json is rejected because dependency editing has no JSON report.

    A registry declaration is emitted as a dependency table with a version member. A local declaration is emitted as a table with path and the computed content hash.

    Exit status

    Exit code 0 means the new manifest was validated and written.

    Exit code 1 covers invalid arguments, invalid manifests, duplicate or reserved names, invalid versions or paths, local package identity mismatches, failed content hashing, and failed manifest writes.

    Filesystem effects

    The command reads the root manifest and reads local dependency content when --path is present. It writes the root topaz.toml after validating the complete proposed manifest.

    The new declaration is appended to [dependencies]. The section is created when absent. Existing declarations and other sections retain their order. The resulting text uses line feeds and ends with a line feed.

    The command does not change dependency source files. A write failure is an error and may leave a partial manifest because manifest replacement is not a multi-file transaction.

    Network access

    The command makes no network requests. Declaring a registry version neither downloads it nor verifies remote availability.

    Reproducibility

    For the same initial manifest bytes, operand, relative path, and admitted dependency bytes, the resulting manifest bytes are identical. Filesystem timestamps do not select a dependency version or content identity.

    Repeating the same command against its completed result fails as a duplicate declaration.

    Packages and locks

    The command changes the manifest without updating or deleting topaz.lock and without materializing a vendor tree. An existing lock therefore becomes stale when its manifest identity changes.

    A later lock or vendor operation records the new package identity. A locked compilation rejects the stale lock until it is updated.

    Why

    A registry version selects published content while a local path selects a filesystem package. These are distinct dependency intentions. Both use the same table representation so identity fields have one manifest form.

    Source evidence

    The linked public CLI recipe checks the exact displayed argument rejection before the requested operation. It does not execute the successful operation or verify its effects.

    Successful dependency editing changes a manifest and is outside the execution allowlist. The linked safe recipe checks rejection of --release. Remote registry access is not part of this command and is not executed.

    Example contract

    Link
    Ruletools-commands-add.rule.invocation

    Example contract

    The invocation topaz add main.tpz --language-version 5.21 --release is expected to exit with 1.

    Reject the build-only --release option before touching a package manifest. Dependency resolution or installation is not exercised.

    Why

    --release controls build optimization. Rejecting it for dependency edits prevents an ignored option from appearing to configure the dependency.

    Source evidence

    Example

    Link

    Argument-rejection example

    Link
    main.tpzArgument-rejection exampleOpen in Playground
    1. function identity<T>(value: T) -> T {
    2. value
    3. }
    target product 5.21.3
    Expected result

    Expected result

    Textual rejection details remain Pending in the reference model. The independent Tools example gate expects exit 1.

    Reject the build-only --release option before touching a package manifest. Dependency resolution or installation is not exercised.

    Source evidence

    Verification scope

    Link

    Observed with Topaz 5.21.3 on 2026-11-06T08:36:29.642Z. This invocation passed; exit 1. 3 assertions were evaluated against the independent expected result. Execution record. This result covers the displayed invocation.

    Related references

    Link

    Compiler selection

    Packages, locks and targets

    Menu

    Download