# Package Manager — Deep Dive

The package manager uses a JSON `vex.json` manifest. This page explains package
identity, dependency selection, workspaces, and native artifacts for the 0.4.0
documentation. Start with [Your first project](../guide/first-project.md) for a
complete application and test before adding external dependencies.

## Manifest

`vex new` creates a project with a `vex.json`; `vex init` creates one in an
existing directory. The manifest's top-level package fields include `name`,
`version`, and `dependencies`. Other supported fields include optional entry
points, testing, workspace, native, and code-generation configuration. See the
[package-manager reference](vex-pm-reference.md) and the manifest
parser for the current schema.

```json
{
  "name": "my-project",
  "version": "0.1.0",
  "dependencies": {}
}
```

Older TOML examples using `vex.toml`, `[package]`, `[features]`, or
`[workspace.dependencies]` do not describe this JSON manifest parser. Do not
assume they can be copied into a current project. A manifest field being
accepted also does not prove every toolchain command consumes that field.

## Dependency Resolution and Lock Files

The development CLI exposes top-level commands such as `vex add`, `vex remove`,
`vex list` and `vex update`; use their `--help` output for arguments. A
manifest dependency is a version string or an object with a required `version`
and optional `headers`. Workspace replacements are a separate mechanism; do
not copy TOML `path`, `git`, `branch`, `features` or `optional` examples into
this dependency shape without verifying the installed version.

`vex.lock` is JSON. It records versions, resolved locations and integrity
information, and can include a canonical Git source and commit. Their presence
is not unconditional: lock generation may lack a commit or a verified content
hash when the relevant checkout or Git database is unavailable. A lock file's
existence alone is therefore not evidence of a fully reproducible build. Use
locked mode where supported and verify that the required metadata and source
are available; see the [package-manager reference](vex-pm-reference.md).

## Workspaces

Workspace configuration is stored in the `workspace` field of the root
`vex.json`, with member paths and optional replace/exclude directives. The
current CLI exposes `vex workspace init`, `add`, `remove`, `list`, `sync`, and
`replace`; these are distinct from the top-level build and test commands.

From a directory where `workspace-demo` does not already exist:

```bash
vex new workspace-demo
cd workspace-demo
vex workspace init
vex new core
vex workspace add core
vex workspace list
```

`workspace list` should list `core`, and the root `vex.json` should contain
the following field alongside its package metadata:

```json
"workspace": {
  "members": ["core"]
}
```

This is a manifest fragment, not a complete JSON document. The child has its
own `core/vex.json`, source directory, and tests. The five CLI invocations
above completed successfully on the compiler identified in the
[evidence guide](../guide/verification-evidence.md); this checked scaffold creation
and membership, not external dependency resolution or every member's native
build.

`workspace add` expects the member directory to exist. It can create a minimal
manifest when the directory has none, but `vex new core` provides the normal
source and test scaffold. Membership describes the workspace; imports still
need to name an available package or source module. Use the package's manifest
and the [modules guide](../guide/modules.md) to make those dependencies explicit.

## Native Dependencies

Manifest-owned native features and their target-specific artifacts are
separate from ordinary package dependencies. For declarations, ownership,
artifact types and target selection, see the [native FFI pipeline](vex-pm-native-ffi.md)
and [FFI guide](../guide/ffi.md). Validate native linking on each intended target.

## Publishing, Registries and Build Scripts

Earlier versions of this page presented `vex pm publish`, a registry endpoint,
TOML feature syntax and automatic `build.vx` scripts as current workflows.
Those examples are not established by the development CLI and manifest
schema above. Do not use them as release instructions; consult the actual
release's documentation and command help for any supported publishing or build
workflow.

## Related

- [Package-manager reference](vex-pm-reference.md)
- [CLI reference](vex-cli-reference.md)
- [Testing](../guide/tooling/testing.md)
