Skip to main content

Bolt Anchors

Name resource locations and build nested paths in bolt.

Bolt anchors let you bind a resource declaration to an identifier with the as clause. The anchor can then be used as a value or extended with / to build nested resource locations.

Installation

pip install bolt-anchors

Configuration

Add the plugin to your beet.yml/beet.json after bolt.

pipeline:
  - mecha

require:
  - bolt
  - bolt_anchors

Usage

Bind an anchor when declaring any resource. The anchor holds the fully resolved resource location of the declaration.

append function ~/foo as foo:
    print(foo)
    function foo / "bar":
        say foo bar

foo holds the fully resolved resource location of the declaration (relative to the current file and the enclosing declarations). It can be extended into a nested resource location, used as a value, and reused to declare or call other resources. Anchors work for any resource type and any path depth.

loot_table ./technical/loot as LOOT {}
print(LOOT)

Interpolated paths

Any location value can be interpolated with {...} and extended with / segments. This also works for plain bolt variables that hold a location.

FOO = ~/foo

function FOO:          # demo:foo
    say plain

function {FOO}/bar:    # demo:foo/bar
    say interpolated

Anchors support the same syntax, as well as the foo / "bar" shorthand.

append function ~/anchor as a:
    function {a}/"quoted"/child as c:
        print(c)
        say child

as binds a runtime Anchor value: a str subclass that additionally supports / for joining path segments. It can be used anywhere a string can, including format strings and comparisons.

append function ~/foo as foo:
    say f"path {foo}/bar"   # path demo:foo/bar
    print(foo / "baz")       # demo:foo/baz
    print(foo == "demo:foo") # True

Anchors can be used as values, interpolated into strings, and reused when declaring or calling other resources.

function ~/utils as utils:
    function utils / "math" / "add":
        scoreboard players add @s points 1

advancement ./tech/root as ROOT {}
predicate ROOT / "check" {}
say f"prefix is {utils}"
function utils / "math" / "add"

Moving the path scope

The anchor command changes the current path scope without creating a resource. Nested locations and anchors inside its block resolve against the new location.

anchor demo:foo as foo:
    function ~/bar as bar:
        print(bar) # demo:foo/bar
    function foo / "baz" as baz:
        print(baz) # demo:foo/baz

The block itself emits no file. Commands and statements inside an anchor block are treated like regular top-level code and are inlined into the current file, while any resource declarations create files relative to the new scope.

Development

uv sync --dev
uv run pytest
uv run ruff check

Metadata

Release files for bolt-anchors 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bolt-anchors 0.4.0
File Size Uploaded Provenance Actions
bolt_anchors-0.4.0.tar.gz 7.5 kB With provenance Details for bolt_anchors-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bolt-anchors 0.4.0
File Interpreter ABI Platform Actions
bolt_anchors-0.4.0-py3-none-any.whl Python 3 none any Details for bolt_anchors-0.4.0-py3-none-any.whl

Total release size: 16.0 kB

Release files / bolt_anchors-0.4.0.tar.gz

Download URL bolt_anchors-0.4.0.tar.gz
Size 7.5 kB
Tags Source
SHA-256 checksum
How to use checksums
684d60094377de33a541b92594f50d2aeb5a373dbb3c93a914996d4f7261d056
BLAKE2b-256 checksum
How to use checksums
90b7af73a73f6f7d27f0605d9681a4758d110a8627545ba96b3b8825861c59ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Release files / bolt_anchors-0.4.0-py3-none-any.whl

Download URL bolt_anchors-0.4.0-py3-none-any.whl
Size 8.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5fc3046c0bd675d14ea4b8d6bcc1a8f6fc8df0b22da16cae72781e8ab93cb9a9
BLAKE2b-256 checksum
How to use checksums
a3c582a38d5cfd2945b195582b1c4512fea28ab51e5f673c2e3883f70e1188a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

Security for bolt-anchors 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for bolt_anchors-0.4.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page