@prata.ma/anvil
v6.0.2
Published
Readme
@prata.ma/anvil
User-facing Anvil library and CLI facade for governed workspaces.
Overview
@prata.ma/anvil is the main package boundary for Anvil itself. It owns the anvil.yaml manifest contract, schema-backed validation, governed project and global sync behavior, catalog block resolution, manifest-native skill operations, lock handling, Forge and Smith helper exports, and the anvil / anv CLI surface that exposes those capabilities.
Within the workspace, this package is the top-level Anvil boundary for user-facing governance behavior plus shared Forge and Smith helper exports. Consumers should depend on @prata.ma/anvil for manifest loading, sync orchestration, schema access, the supported CLI, and the supported root helper exports instead of reaching into internal command modules or block-deployment helpers directly.
Release remains Changesets-based. The repo now uses generated package fragments at @state/releases/changelog.md, optional global intent at @state/releases/global.md, one curated repo-level summary at @state/releases/active.md, and one archived copy under @state/releases/history/ after publish.
Installation
Install the package from npm when using Anvil outside this monorepo.
npm
{
"dependencies": {
"@prata.ma/anvil": "^0.0.0"
}
}Usage
@prata.ma/anvil supports both library-style usage and the packaged CLI surface.
Library
import {
anvilSync,
getAnvilSchemaPath,
loadAnvilManifest,
validateAnvilManifest,
} from '@prata.ma/anvil'
const loadedManifest = loadAnvilManifest(process.cwd())
if (!loadedManifest) {
throw new Error('No anvil.yaml found')
}
const validation = validateAnvilManifest(loadedManifest.manifest)
if (!validation.valid) {
throw new Error(validation.issues.map(issue => issue.message).join('; '))
}
console.log(getAnvilSchemaPath())
await anvilSync(loadedManifest)CLI
anvil status # Show workspace status
anvil issue list # List HQ Rhythm issues
anvil issue create --title "Add issue subcommands" --kind Feature --workspace Anvil --problem "Manual issue handling" --intent "Add a first CLI slice"
anvil issue update ISS-7 --level Beat --stage Beat/Execute
anvil manifest validate # Validate anvil.yaml
anvil skill find typescript # Search skills.sh without changing workspace state
anvil skill add antfu/skills --skill pnpm # Declare and sync one skill
anvil skill remove pnpm --yes # Remove the declaration and reconcile managed outputs
anvil skill list # Show declarations, ownership, revisions, and deployment status
anvil skill check # Check deployment drift and available upstream updates
anvil skill update antfu:pnpm # Update one standalone skill within its declared constraint
anvil skill create my-skill # Scaffold authored content without deploying it
anvil sync # Run governed project sync
anvil sync --only skill,mcp # Reconcile selected content kinds
anvil sync --global # Run standalone global sync
anvil sync --prune # Remove undeclared tool-target content, then sync
anvil release check # Validate release readiness
anvil release prepare # Apply versioning and scaffold @state/releases/active.md
anvil release publish # Publish packages and finalize the repo release
anvil release status # Show current release status
anvil hub query "status" # Query configured hub context
anv # Launch the interactive shortcut when running in a TTYPatterns
The package is typically used in one of two ways:
- as a library facade for manifest parsing, root resolution, recipe loading, and sync orchestration
- as the
anvilCLI for workspace-facing command flows such ascatalog,hub,issue,manifest,plugin,release,skill,status, andsync
Internally, package command modules route shared prompt, spinner, and log behavior through src/lib/cli.ts and its ux facade instead of importing @clack/prompts ad hoc at each call site.
API
@prata.ma/anvil exposes a documented library surface and two CLI binaries.
Exports
@prata.ma/anvil- root library facade@prata.ma/anvil/changelog- packaged Changesets changelog module for repos with a known<owner>/<repo>slug@prata.ma/anvil/manifest- manifest loading, parsing, validation, and root-resolution helpers@prata.ma/anvil/schema- packagedanvil.yamlJSON schema- root exports from
src/index.ts, including manifest helpers, recipe helpers, sync helpers, Forge product-discovery helpers, Smith layout helpers, andgetAnvilPackageStatus()
Commands
The package ships two binaries:
anvil- standard CLI entrypointanv- shorthand launcher entrypoint
Top-level CLI command areas currently include catalog, hub, issue, manifest, plugin, release, skill, status, and sync.
Issues
anvil issue list
anvil issue list --workspace Anvil --query rhythm
anvil issue create --title "Add issue subcommands" --kind Feature --workspace Anvil --problem "Manual issue handling" --intent "Add a first CLI slice"
anvil issue update ISS-7 --level Beat --stage Beat/Execute
anvil issue update 356c08fe-bfbd-804a-b156-f90b4ddc56fc --kind Feature --problem "Normalize this row"anvil issue is the first HQ-focused issue operator slice in this package:
- it reads the live Notion HQ root from
hub.document.rootIdinanvil.yaml - it manages the shared
Issuesdatabase using Rhythm/HQ field mapping instead of treating Notion as raw freeform CRUD listis the read/search surface for v1, with--queryplus explicit lifecycle filtersupdateaccepts either a canonical HQ id such asISS-7or a Notion page id- existing partial intake rows remain visible and can be normalized through
update
Workspace
anvil status
anvil sync
anvil sync --global
anvil sync --prune
anvil sync --only skill,mcp
anvil sync --only mcp --global
anvil sync --only skill --dry-run --json
anvil sync --verboseBare sync selects all kinds. --only accepts comma-separated singular names: rule, reference, command, skill, agent, plugin, and mcp. It limits staging, deployment, managed cleanup, reporting, and lock changes. Unselected content is retained. Rules and references can regenerate root instructions; commands include command-derived Codex skills. Partial block deployment does not claim a whole-block refresh and reports related block content that remains unaligned.
--dry-run previews selected declared/authored inventory and prune targets without changing workspace files or resolving remote sources. MCP previews also use the normal target preflight checks. It is not a byte-level diff for every generated artifact. --json includes phase timings and counts; --verbose shows them in human-readable runs. Source timing is included in staging. Git clone/fetch counts and copied/unchanged skill-file counts distinguish network work from deployment work.
Sync deploys resolved content; it does not check whether a newer Git-backed skill revision exists:
| Source state | Sync behavior | | -------------------------------------------------- | ------------------------------------------------------------ | | New declaration | Resolve once, deploy, and record the commit. | | Recorded revision and cached objects | Restore that revision without fetching upstream. | | Recorded revision but missing cached objects | Retrieve the exact revision; fail if it cannot be retrieved. | | Legacy lock entry without usable revision evidence | Resolve once and report the migration. |
Local/catalog sources use current local or installed package content. Remote plugin declarations also retain their recorded resolution during sync. Skill updates are explicit; this release does not introduce a public block-update command.
MCP Deployment
Block content/ai.jsonc is merged first; the configured authored AI root's ai.jsonc overrides it.
| Tool | Project target | Global target |
| -------- | -------------------- | ----------------------------- |
| Claude | .mcp.json | ~/.claude.json |
| OpenCode | opencode.jsonc | XDG OpenCode opencode.jsonc |
| Cursor | .cursor/mcp.json | ~/.cursor/mcp.json |
| Codex | .codex/config.toml | ~/.codex/config.toml |
Sync creates missing targets, preserves unrelated settings and servers, and removes obsolete owned entries, including when the desired server set becomes empty. JSONC comments and text outside Codex's managed block are retained. Ownership hashes live in .anvil/mcp-ownership.json; keep this generated record for safe reconciliation. Anvil preflights all MCP targets before writing them. Conflicting unmanaged or modified managed values stop sync rather than being overwritten. Equivalent legacy entries can be adopted; historical entries without ownership evidence are not broadly deleted.
Claude uses HTTP/stdio configuration, OpenCode uses V2 mcp.servers, and Codex uses scalar command, separate args, and second-based timeout fields. Credentials remain environment references where supported. Codex cannot represent arbitrary environment interpolation in URLs, commands, mixed header strings, or renamed environment variables; unsupported mappings fail before MCP writes. Anvil writes configuration only: tool trust, OAuth sign-in, and connection health remain tool-managed.
Skills
anvil skill find [query] [--owner <owner>] [--json]
anvil skill add <source> [--skill <name[,name]> | --all] [--global] [--json]
anvil skill remove [name...] [--all] [--global] [--yes] [--json]
anvil skill list [--global] [--json]
anvil skill check [name-or-ref] [--global] [--json]
anvil skill update <name-or-ref> [--global] [--json]
anvil skill update --all [--global] [--json]
anvil skill create <name> [--description <text>] [--global] [--json]The skill commands are a manifest-native convenience layer:
findsearches skills.sh and never changes local workspace stateaddresolves selected skills, records deterministic provider-backed declarations inanvil.yaml, validates the manifest, and invokes skill-only sync; existing resolutions are retainedremovedeletes selected manifest declarations and invokes skill-only sync while preserving unmanaged and authored skillslistis local and read-only; it identifies standalone, block-owned, authored, overridden, and unmanaged skillscheckalways examines deployment drift and upstream updates; it does not change manifests, locks, staging, or deployed output, but may update shared source cachesupdateresolves newer allowed revisions for the selected standalone declarations, then deploys skills without advancing unrelated resolutionscreatewrites a scaffold beneath the configured AI root'sskills/directory, refuses existing paths, and does not deploy it- project scope is the default;
--globaltargets the standalone manifest under~/.config/anvil/ - Git-backed declarations store exact repository-relative skill paths, while catalog-backed declarations keep their existing boolean install form
Use anvil skill update <ref> or --all to advance standalone skills. Branch declarations follow the branch when explicitly updated; tags and full commit SHA declarations remain pinned. A commit recorded in the lock is a resolution, not a user pin. Block-owned skills report their owning block and cannot be independently updated. --all reports block-owned exclusions instead of silently updating a whole block. check returns exit status 1 for drift, available updates, incomplete block alignment, or unknown results; failed upstream checks never claim that a skill is current.
Add saves the declaration before deployment. If sync fails, the manifest remains saved; fix the cause and rerun sync. Failed updates retain the previous resolved lock, but generated staging or output may already have changed: cross-file rollback is not promised. Sync can restore the prior locked Git content. Unmanaged same-name skill directories cause a conflict rather than being replaced.
Git-backed sync uses repository leases through refresh, sparse checkout, and copying. skill add releases its discovery lease before nested sync. Incomplete new clones never become live caches; verified invalid owned caches are quarantined and rebuilt once. Busy Git caches, invalid legacy caches, and unknown or abandoned lease locks stop with their exact recovery path. Verify that the owning Anvil process and all associated Git processes have stopped before moving only that cache or lock aside. Do not delete the whole Anvil cache or change a valid branch declaration to work around a cache error.
Skill deployment excludes .git and node_modules, including for repository-root skills. Relative asset symlinks and executable file modes are preserved and participate in unchanged-content checks. SKILL.md must be a regular file with YAML frontmatter; Git-backed staging/checks do not execute alternate frontmatter engines.
Release
anvil release check
anvil release prepare
anvil release publish
anvil release statusThe normal release workflow is Changesets-based:
pnpm changesetauthors the intended package version changes- when a repo uses the packaged custom changelog surface, configure
.changeset/config.jsonwith@prata.ma/anvil/changelogplus a known GitHub repo slug anvil release checkvalidates release readiness through Turbo-backed package and block-package tasksanvil release prepareapplies version bumps, updates package changelogs, generates@state/releases/changelog.md, and scaffolds@state/releases/active.md- review
@state/releases/global.md,@state/releases/changelog.md, and compose@state/releases/active.md, especially## Highlightsand## Changelog - commit the prepared release changes
anvil release publishpublishes public packages, creates the coordinated GitHub Release from@state/releases/active.md, archives it to@state/releases/history/, and deletesactive.md,global.md, andchangelog.md
Repo-only releases are also supported by default:
- if
anvil release preparefinds no package version changes, it still writes@state/releases/changelog.mdand scaffolds@state/releases/active.mdas a repo-only release summary anvil release publishskips package publishing for that case and still finalizes the coordinated repo tag and GitHub Release
Manifest
anvil manifest validatePlugins
anvil plugin add <source>
anvil plugin list
anvil plugin remove <name>Catalog And Hub
anvil catalog review
anvil catalog block check .
anvil catalog block sync .
anvil catalog block apply .
anvil hub pull
anvil hub query <text>
anvil hub status
anvil hub sync --product
anvil hub sync --state
anvil hub sync --systemConfiguration
anvil.yamlis the primary workspace manifest consumed by the package.@prata.ma/anvil/schemaandgetAnvilSchemaPath()expose the schema contract for that manifest.anvil issuecurrently relies onhub.document.provider: notionplus the live HQhub.document.rootIdto discover the sharedIssues,Workspaces,Products, and optionalInstancestables.anvilSync()materializes governed content into.anvil/and generated compatibility outputs.anvil skill add/removechanges onlycatalogsandskillsin the selected manifest, preserving unrelated comments and structure before invoking skill-only sync.anvil skill finduses the skills.sh directory as read-only discovery and does not treat marketplace or filesystem state as workspace authority.- Active and finalized repo release summaries live under
@state/releases/. - Catalog agents are now authored as one markdown file at
content/agents/<name>.md, staged into.anvil/agents, and rendered into tool-specific agent targets for OpenCode, Claude, Cursor, and Codex. - The CLI
anvil synccommand owns the final enriched project lock snapshot after external manifest-backed skills and plugins are resolved. - Project sync deploys the State session bundle from
.anvil/plugins/to.opencode/plugins/and records its ownership hash in.opencode/plugins/.anvil-managed.json. If the global OpenCodeplugins/session.jsis byte-identical, project sync reports the global provider and removes only its unchanged managed project copy to avoid duplicate plugin IDs. A different global bundle, a modified managed project plugin, or an unmanaged project conflict stops deployment. Sync preserves unrelated plugins. The local catalog requires a prior State block build; the published catalog carries its bundledsession.js. - Run project sync after adding or removing the global State plugin. Project sync restores the local copy when the global copy is absent; global sync does not scan or change other repos.
- OpenCode MCP sync writes declared servers under V2
mcp.serversin project or globalopencode.jsonc; it preserves unrelated JSONC comments and settings. V2 loads bothAGENTS.mdand configuredinstructions. In compiled-rule mode, avoid an extra glob for rules already included inAGENTS.md. - OpenCode commands accept
opencode.subagentand the legacyopencode.subtaskinput. Sync emits nativesubagent; conflicting alias values are rejected instead of silently changing delegation. anvil sync --globalroutes the same sync command through the standalone global Anvil root under~/.config/anvil/.- Global sync merges managed
.anvil/skills and commands with repo-authored.ai/skills and commands, with authored content taking precedence when names or command ids overlap. anvil sync --pruneremoves undeclared content from selected tool-target kinds after one grouped confirmation prompt, and aborts if that prompt is declined or cancelled. Codex command-derived skill cleanup belongs tocommandselection, not ordinaryskillselection. Dry-run never prunes.- Project and global
anvil-lock.yamlfiles are managed sync snapshots for provenance and ownership diagnostics, while deployedmetadata.anvilmarkers remain the authoritative cleanup signal. - Project and global sync now print the same
Deployed,Skipped, andUndeclaredsummary surface, with conservative cleanup still preserving unmanaged deployed items. - Lock snapshots now include deterministic instruction-budget metrics: top-level
summaryplus per-entrylines,chars, andtokensfor managed agents, rules, commands, references, skills, and block rollups. - Root-generated lock entries use synthetic managed refs such as
anvil:root-agentsandanvil:root-agents-overrideinstead of filename-shaped keys.
Development
Use the package-local scripts while working in @packages/anvil, and keep user-facing behavior routed through the documented facade and command layers instead of scattering it across unrelated packages.
This package participates in the repo's Changesets, npm publish, and GitHub Release automation through canonical Turbo tasks. anvil release check orchestrates package build, lint, test, and test:type tasks plus block package lint and test tasks so repeated release checks can reuse Turbo cache.
Commands
pnpm --filter @prata.ma/anvil build
pnpm --filter @prata.ma/anvil lint
pnpm --filter @prata.ma/anvil test
pnpm --filter @prata.ma/anvil test:type
pnpm anvil release checkTesting
Vitest covers manifest parsing, selected-kind preservation, MCP ownership and project/global output, read-only skill inspection, scaffolding, exact-revision restoration, grouped updates, pinned sources, shared-cache isolation across workspaces, failure recovery, and the existing facade command surfaces. Git lifecycle proofs use temporary local upstreams, not public services.
Conventions
- Keep the CLI layer thin: command modules should delegate real behavior into importable library code.
- Keep shared command UX behavior centralized in
src/lib/cli.tsthrough the internaluxfacade. - Preserve
@prata.ma/anvilas the supported root package for workspace governance plus public Forge and Smith helper exports. - Keep manifest and sync behavior deterministic because generated governance outputs depend on it.
- Treat internal command modules and
src/lib/*helpers as implementation details unless they are explicitly exported. - Keep lock snapshots and deployed markers aligned, but do not let lock state reclaim primary cleanup authority from
metadata.anvil. - Keep lock summaries aggregated from leaf instruction-bearing entries so block rollups do not double count the same content.
- Keep
anvilSync()focused on managed deployment work; let the CLI sync command own the final project lock snapshot when external declarations are involved.
Status
This package is active and central to the current workspace model.
Maturity
@prata.ma/anvil is active for workspace dogfooding and public-package preparation.
Scope
The package supports manifest loading and validation, schema access, selective project/global sync, the skill lifecycle commands, block deployment, catalog tooling, plugin management, live HQ issue management, Forge and Smith helpers, and the main Anvil CLI facade.
Notes
- This package is published as
@prata.ma/anvil, and release validation now runs through Turbo-backed canonical tasks consumed byanvil release check. - The supported library surface is limited to the documented exports; deep imports into
src/commands/*orsrc/lib/*should not be treated as stable public API. scripts/postbuild.mjsis part of the package contract because it copies.mjsoutputs to.jsand stages catalog assets into build output aftertsdowncompletes.
