Usage
facet system to talk to external tools, most often AI coding harnesses (OpenCode, Claude Code, Codex, etc.). Adapters define where assets and configuration live on disk.
Run with no specifier to choose from an interactive picker of the first-party adapters (TTY only) — in a non-interactive shell the no-argument form fails with a structured error and exit 1.
Built-in adapters
These names resolve to the first-party adapter packages:opencode— OpenCode adapter (@agent-facets/adapter-opencode)claude-code— Claude Code adapter (@agent-facets/adapter-claude-code)codex— Codex adapter (@agent-facets/adapter-codex)
A per-install
--target-dir flag is intentionally not supported: later invocations (such as facet build) would have no way to locate adapters placed in non-default locations.Exit codes
What it does
The install flow stages and verifies a candidate before it ever touches the existing installation:- Download (or clone/copy) the source and bundle it into a self-contained
adapter.jsin temporary storage. - Verify the bundle: it must export a valid adapter that declares a supported adapter API. For npm sources the runtime declaration must also match the package metadata used for selection.
- Acquire a per-adapter replacement lock, copy the verified bundle into a new generation under
$FACET_DIR/adapters/<name>/generations/<generation-id>/, and verify it again at its final path. - Atomically activate the new generation by replacing the
installation.jsonreceipt — the record of the active generation, verified API, and source provenance (specifier, resolved npm package/version, integrity). - Remove the previous generation.
FACET_DIR layout.
Specifier formats
Adapter specifiers accept
git+ URLs even though facet sources for facet add reject them — adapter installs and facet installs follow different source rules.1.2.3, major wildcard 1.*, minor wildcard 1.2.*, *, or latest. npm range syntax (^1.2.3, ~1.2.3, comparators, hyphen/OR/x-ranges, prerelease tags) is rejected with an error listing the supported forms.
Compatible resolution
Every adapter declares the adapter API contract it was built against, and each CLI release supports an exact set of adapter APIs (currently0.1, the tagged request/result contract). A CLI that supports only 0.1 treats an adapter still declaring the earlier positional 0.0 as unsupported; an older 0.0 CLI conversely keeps selecting the highest compatible 0.0 release, so the two lines advance independently. For npm installs, the CLI reads the package’s version metadata (the facetAdapterApiVersion field each release publishes) and selects the highest stable release that both satisfies your version selector and declares a supported API:
- A bare name,
*, orlatestselects the highest compatible release — independent of npm’slatestdist-tag. - A wildcard selector (
1.*,1.2.*) selects the highest compatible release in the range. - An exact version considers only that release: if it is incompatible, the install fails rather than substituting another version.
- Releases with a missing or malformed declaration are never selected.
#ref still pins exactly what gets built (a tag, branch, or commit), and both Git and local sources are built as supplied and must pass the same runtime compatibility verification before installation.
See also
facet adapter list— list installed adapters.facet adapter remove— remove an installed adapter.- Environment variables —
FACET_DIRand the directory layout.