Skip to main content

agentdir

Virtual filesystem for agent-optimized exploration of general-purpose files using CoW reflinks.

agentdir is a Python binding for the agentdir Rust library. It lets you map real directories of documents, media, datasets, generated artifacts, plain text, binaries, or any other OS-visible files into a virtual file tree, move and copy entries without touching the originals, track original-file changes, and fork the tree into isolated snapshots via copy-on-write.

  • Version: 0.1.6
  • License: MIT
  • Python: >= 3.9
  • Built with: PyO3 + maturin (native Rust extension, abi3 wheels)

Installation

pip install agentdir

No extra dependencies. The package ships pre-built abi3 wheels for Linux, macOS, and Windows.

Installation only installs the binding. After mapping original files, call Workspace.refresh() whenever the original file tree may have changed. The Python binding exposes reconciliation through refresh() and refresh_with_hash_verification(); it does not start the CLI watch loop for you.


Quick Start

from agentdir import Workspace

ws = Workspace.init("./workspace")
summary = ws.map("./team-files", "/files")
print(f"Mapped {summary['entries_added']} entries")

content = ws.read_bytes("/files/q1-report.txt")
print(content.decode())

ws.mv("/files/q1-report.txt", "/reports/q1-report.txt")  # original files are untouched

# Reconcile source changes before an agent/session depends on the view.
sync = ws.refresh()
print(sync)

All methods are synchronous. There is no async API. Internally the library runs a Tokio runtime, but the Python surface is fully blocking.

If you also install the CLI, long-running workflows can run agentdir -w ./workspace watch --interval 60 in a separate process. The watcher combines filesystem events with periodic full rescans; Python applications should otherwise call refresh() on their own schedule or at session boundaries.


API Reference

Import

from agentdir import Workspace, SnapshotWorkspace

Workspace

Static methods

Workspace.init(path: str, strategy: str = "reflink") -> Workspace

Initialize a new workspace at path. The strategy controls how files are materialized:

Value Behavior
"reflink" CoW reflink, falls back to byte-copy if unsupported (default)
"symlink" Symbolic links
"virtual" Metadata-only, no materialization
Workspace.open(path: str) -> Workspace

Open an existing workspace. Raises FileNotFoundError if the workspace does not exist at path.


Instance methods

map(source: str, mount: str) -> dict[str, int]

Map a source directory into the virtual tree at mount. Returns a summary dict:

{
    "entries_added": int,
    "reflinked":     int,
    "copied":        int,
    "symlinked":     int,
    "dirs_created":  int,
    "errors":        int,
}
unmap(mount: str) -> dict[str, int]

Remove the mapping at mount and clean up its entries. Returns:

{"entries_removed": int}
mv(from_path: str, to_path: str) -> None

Move a virtual entry. The original file on disk is not touched.

cp(from_path: str, to_path: str) -> None

Copy a virtual entry. The original file on disk is not touched.

mkdir(path: str) -> None

Create a virtual directory.

rmdir(path: str, recursive: bool) -> None

Remove a virtual directory. Pass recursive=True to remove non-empty directories.

rename(path: str, new_name: str) -> None

Rename the last path component of a virtual entry. new_name is a bare name, not a full path.

exists(path: str) -> bool

Return True if the virtual path exists.

stat(path: str) -> dict[str, object]

Return metadata for a virtual path:

{
    "virtual_path":  str,
    "source_path":   str,
    "size_bytes":    int,
    "mtime_ns":      int,
    "entry_type":    str,   # "File" or "Directory"
    "materialized":  bool,
}
read_bytes(path: str) -> bytes

Read the raw bytes of a file at the given virtual path.

refresh() -> dict[str, int]

Detect changes in source directories and apply them to the virtual tree. Returns:

{
    "added":     int,
    "refreshed": int,
    "removed":   int,
    "errors":    int,
}
refresh_with_hash_verification(verify_hashes: bool = False) -> dict[str, int]

Same as refresh(), with an optional SHA-256 pass. When verify_hashes=True, files whose mtime and size are unchanged are additionally verified by content hash to catch silent modifications. Returns the same shape as refresh().

status() -> dict[str, object]

Return workspace-level metadata:

{
    "total_entries":           int,
    "source_roots":            int,
    "materialized_root":       str,
    "last_updated_epoch_secs": int,
}
export_mapping(reverse: bool = False, relative_to: str | None = None) -> dict[str, str]

Export the source-to-virtual path mapping as a plain dict. Pass reverse=True to get virtual-to-source instead. Pass relative_to to relativize source paths against a base directory.

map_batch(mappings: list[tuple[str, str]]) -> dict[str, object]

Map multiple files in one call. Each tuple is (source_path, mount_point). Note: batch map accepts files only, not directories. Returns:

{
    "entries_added": int,
    "reflinked":     int,
    "copied":        int,
    "symlinked":     int,
    "dirs_created":  int,
}
rglob(pattern: str) -> list[str]

Match virtual paths against a glob pattern. Supports * and ** wildcards (e.g. "/files/*.pdf", "/media/**/*.png"). Returns a list of matching virtual paths.

list_snapshots() -> list[str]

Return the names of all snapshots attached to this workspace.

snapshot(name: str) -> SnapshotWorkspace

Create a named CoW snapshot of the current virtual tree. The snapshot starts as a fork of the workspace and accepts isolated writes.

open_snapshot(name: str) -> SnapshotWorkspace

Open an existing named snapshot.

destroy_snapshot(name: str) -> None

Destroy a named snapshot and remove its files from disk.


SnapshotWorkspace

A CoW fork of a Workspace. Writes to a snapshot are isolated and do not affect the base workspace or any original files.

exists(path: str) -> bool

Return True if the virtual path exists in this snapshot.

stat(path: str) -> dict[str, object]

Return metadata for a virtual path. Same shape as Workspace.stat().

read_bytes(path: str) -> bytes

Read the raw bytes of a file in this snapshot.

write(path: str, content: bytes) -> None

Write content to a file in this snapshot. The write is copy-on-write and does not affect the base workspace.

export_mapping(reverse: bool = False, relative_to: str | None = None) -> dict[str, str]

Export the path mapping for this snapshot. Same semantics as Workspace.export_mapping().

destroy() -> None

Destroy this snapshot and remove all its files from disk.


Examples

Map a directory and read files

from agentdir import Workspace

ws = Workspace.init("./workspace")
summary = ws.map("./team-files", "/files")
print(f"Mapped {summary['entries_added']} entries")

content = ws.read_bytes("/files/q1-report.txt")
print(content.decode())

ws.mv("/files/q1-report.txt", "/reports/q1-report.txt")  # original files untouched

Snapshots with isolated writes

from agentdir import Workspace

ws = Workspace.init("./workspace")
ws.map("./team-files", "/files")

snap = ws.snapshot("experiment")
snap.write("/files/q1-report.txt", b"snapshot-only draft")

# Base workspace is unaffected:
original = ws.read_bytes("/files/q1-report.txt")
modified = snap.read_bytes("/files/q1-report.txt")

snap.destroy()

License

MIT. See LICENSE for details.

For the CLI and Rust library, see the main repository: https://github.com/NomaDamas/agentdir

Metadata

Release files for agentdir 0.1.6

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

Source distribution (sdist)

Source distribution for agentdir 0.1.6
File Size Uploaded Provenance
agentdir-0.1.6.tar.gz 87.5 kB With provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for agentdir 0.1.6
File
agentdir-0.1.6-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details
agentdir-0.1.6-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details
agentdir-0.1.6-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.9 abi3 Linux glibc 2.17+ ARM64 Details
agentdir-0.1.6-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details
agentdir-0.1.6-cp39-abi3-macosx_10_12_x86_64.whl CPython 3.9 abi3 macOS 10.12+ x86-64 Details

Total release size: 6.8 MB

Release files / agentdir-0.1.6.tar.gz

Download URL agentdir-0.1.6.tar.gz
Size 87.5 kB
Tags Source
SHA-256 checksum
How to use checksums
43436fa69170923861bae1f9ac5a4e871f6fae6d4b79afb84faf2edc965e85af
BLAKE2b-256 checksum
How to use checksums
e784c25f45a8b40a500543d7501a00742710cb7866097d052cad9703e6b20df6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 11, 2026.

Transparency log

Release files / agentdir-0.1.6-cp39-abi3-win_amd64.whl

Download URL agentdir-0.1.6-cp39-abi3-win_amd64.whl
Size 1.2 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
1519657d9b1580010e99f95e463c23e157a2e9d2d5708d750e2c2793e18a1d96
BLAKE2b-256 checksum
How to use checksums
f9ae962c7378d5106cee6debcd01895c4dea6d5a2f088132adfeab0b86bdb9bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 11, 2026.

Transparency log

Release files / agentdir-0.1.6-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL agentdir-0.1.6-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.5 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
e0afd6c02918942e78042224a1142a749389695b78bde68f463b48325311673f
BLAKE2b-256 checksum
How to use checksums
e7c32ff023d9272ad1ab4e5bac890a581b2673273c68fecdf59fbb1efa7bf1a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 11, 2026.

Transparency log

Release files / agentdir-0.1.6-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL agentdir-0.1.6-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 1.4 MB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
467943cb309c1937edab63401c15d5f64299c5908fa0fbffb8fb1ba849c4fdcf
BLAKE2b-256 checksum
How to use checksums
cfe73dc4badaa314250f6cafeb9bec571cd08697adcf4392d0a6a838302855dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 11, 2026.

Transparency log

Release files / agentdir-0.1.6-cp39-abi3-macosx_11_0_arm64.whl

Download URL agentdir-0.1.6-cp39-abi3-macosx_11_0_arm64.whl
Size 1.3 MB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
2cef27cd188f1372c88ea285af698a6e0cc492aa2e9c92f2c77b2186ced470d7
BLAKE2b-256 checksum
How to use checksums
7c2394409062505bae66ef4330293a97fcf4dd31f9f73d1f393f8920798de40a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 11, 2026.

Transparency log

Release files / agentdir-0.1.6-cp39-abi3-macosx_10_12_x86_64.whl

Download URL agentdir-0.1.6-cp39-abi3-macosx_10_12_x86_64.whl
Size 1.3 MB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
1799022b978f501259c189c329ae5c34a3523cfbc857ff865d0bdccfd66001dd
BLAKE2b-256 checksum
How to use checksums
019adddf288001486c278b31bfc3f5727dca2ec2247f886ae647e6848846a25d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 11, 2026.

Transparency log

Security for agentdir 0.1.6

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

All 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for agentdir-0.1.6.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 Jun 11, 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.

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