Invocation, options and results
Linktopaz add
topaz add <dep>
Input
topaz add <name>@<version> declares one exact registry version. topaz add <name> - 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.
- defaults to the current directory. The root must contain a valid topaz.. The manifest selects the language mode, so - 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, -, output-format options, missing values, repeated options, and attached values are rejected.
Options and conflicts
| Option | Default | Contract | Conflicts |
|---|---|---|---|
--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 - is present. It writes the root topaz. 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. 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
LinkRegistry dependencies use an exact version. Local dependencies identify a relative path and its content identity.
Option conditions
Link- applies to add only
add uses topaz.toml [package].language; drop --language-version
Behavior contract
LinkCommand behavior
Arguments and rejection
topaz add <name>@<version> declares one exact registry version. topaz add <name> - 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.
- defaults to the current directory. The root must contain a valid topaz.. The manifest selects the language mode, so - 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, -, 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. - 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 - is present. It writes the root topaz. 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. 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
- compiler/crates/topaz_cli/src/command/flags.rs at
b48527d0a174 - compiler/crates/topaz_cli/src/command/dispatch.rs at
b48527d0a174 - compiler/crates/topaz_cli/src/command/validation.rs at
b48527d0a174 - compiler/crates/topaz_cli/src/package/dependency.rs at
b48527d0a174
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 -. Remote registry access is not part of this command and is not executed.
Example contract
LinkExample contract
The invocation topaz add main. 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
- controls build optimization. Rejecting it for dependency edits prevents an ignored option from appearing to configure the dependency.
Source evidence
- compiler/crates/topaz_cli/src/command/flags.rs at
b48527d0a174 - compiler/crates/topaz_cli/src/command/dispatch.rs at
b48527d0a174 - compiler/crates/topaz_cli/src/command/validation.rs at
b48527d0a174 - compiler/crates/topaz_cli/src/package/dependency.rs at
b48527d0a174
Example
LinkArgument-rejection example
Linkfunction identity<T>(value: T) -> T {value}
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
- compiler/crates/topaz_cli/src/command/flags.rs at
b48527d0a174 - compiler/crates/topaz_cli/src/command/dispatch.rs at
b48527d0a174 - compiler/crates/topaz_cli/src/command/validation.rs at
b48527d0a174 - compiler/crates/topaz_cli/src/package/dependency.rs at
b48527d0a174
Verification scope
LinkObserved 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.