/knowledge/. Each file is assembled from the
document’s completed, enabled segments.
For API key setup, see Dify Setup.
Config
mounts=; it has no drift detection, so restored cache entries are served as saved and other reads reach the live backend.
Fields marked secret are redacted in snapshots.
VFS.md
The VFS.md an agent reads with Dify mounted at/<path>.
- Rendered
- Raw
slug. If a document has no configured slug
metadata, Mirage falls back to the Dify document name.
Creating Slug Metadata in Dify
In the Dify Knowledge UI, open a document and add a metadata item whose name matchesslug_metadata_name. The default name is slug.
doc_metadata from Dify and uses this value as the document’s
virtual path below the mount prefix.
Use these rules for slug metadata values:
- Use
/to create folders. - Do not use empty segments,
., or... - Keep each slug metadata value unique across the dataset.
- Do not use a path that is also needed as a folder. For example,
guidesandguides/quickstart.mdcannot both be document paths.
enabledistrueindexing_statusiscompletedarchivedisfalse
Reading Documents
cat, head, tail, and grep read Dify document segments. Segment content
is joined with a single newline between chunks.
Search
Thesearch CLI asks Dify’s dataset retrieval API. Use
it when meaning matters more than exact text matching. Register it on the
workspace:
--top-k defaults to 10 and is capped at 100. --threshold must be between
0 and 1; another value, or another method, exits 1 before Dify ranks
anything.
Results are emitted one retrieval hit per block:
document_name, which requires Dify Built-in Fields to be enabled in dataset
metadata.
Scoped Search Requirements
Mirage converts a scoped search path into Dify metadata filters:
To make scoped search reliable:
- Add the configured slug metadata field to every document.
- Enable Dify Built-in Fields in the dataset metadata settings.
- Ensure
document_nameis available if you rely on name-based paths.
cat,
grep, and find can still see the same file.
Cache
The VFS uses Mirage’s index cache for the virtual tree. Directory listings and path resolution reuse the cached document tree until the index expires or the workspace is recreated. If documents are edited directly in Dify, repeated operations can temporarily see cached paths and metadata. Document content is still read from Dify when commands materialize file data.Example
examples/python/vfs/dify/dify.py.