Skip to main content
Use a FileTree to keep a document with its illustrations, a skill with its scripts, or any set of files that refer to each other by relative path. For the bundled agent skill, run ep skills show edsl-file-trees --human.

Use a FileTree in a model question

Put the snapshot in a scenario and reference its field in the question text. This example saves a review job you can inspect locally.
Both {{ files }} and {{ scenario.files }} expand the tree at the reference. Text appears verbatim under its relative path. Opaque files become numbered FileStore attachments, and the prompt maps each number to a path. Entries appear in path order, including files the article does not link to. Only the first rendered reference to that field in each question expands it. A question that omits the reference or skips it in a conditional receives none of the tree. The Jobs package captures the selected snapshot. To review an older revision, use FileTree.git.load("post.ep", ref="HEAD~1") when building the scenario. Preview lists attachment paths, MIME types, sizes, and SHA-256 hashes. For a post with two figures, add --expect-files 2 to check the count. Choose a model that accepts the file types and total input size. EDSL reports known adapter incompatibilities with the offending relative path.

Read a code from one image

The examples/filetree-vision directory in the EDSL repository contains a two-file snapshot. In source/note.md, the batch is KITE-724 and the instruction is to read the purple card. In source/images/cards.png, three colored cards each show a different five-digit number. The saved question asks for the batch and the selected code, joined by a slash. Download the example files. Three colored cards, each displaying a five-digit code. From the repository root, inspect the exact input and the recorded live answer offline.
Preview shows one attachment named images/cards.png. The check verifies that the target number is absent from the prompt text. In the recorded run, OpenAI’s gpt-4o-mini-2024-07-18 returned KITE-724/74923, matching the number on the purple card. To repeat the provider call with OpenAI credentials, use a separate output file and bypass the cache.

Directory snapshots

Directory capture preserves relative paths, empty directories, executable flags, and file contents, including line endings. It skips Git’s own .git metadata and rejects symlinks and special files. Choose a new or empty destination directory when materializing. Git tracks readable UTF-8 text and an index giving every file’s SHA-256 digest and size. The portable .ep keeps one copy of each asset outside Git’s object database, including images replaced in later revisions. Copying the package preserves offline rendering and restoration. Version 1 packages remain readable. Their next save uses the new format and preserves the original commits. With FileTree support enabled on your Coop server, publish or retrieve the package using the standard commands:
Pushing publishes the package’s current revision and uploads the files every earlier revision uses, skipping files already published for that tree. If Coop has a newer version than your package, for example one you pushed from another copy, ep push stops. Run ep pull first, then push again. As with other EDSL objects, history stays with the owner. When you clone a tree you own on a server with Git hosting, ep clone copies its full history and files. Anyone else who can open the tree receives its current revision as a new package with a single commit, and ep pull adds a commit whenever the published revision changes. Either way the clone contains the file bytes and works offline. A plain Git clone of a version 2 tree carries its text and pointers; use ep clone or the portable package for the images as well. On the Coop object page, a file tree sits beside a viewer. A root-level README.md opens first, otherwise SKILL.md, otherwise the first root-level .md or .markdown file. Use relative image references such as ![Cover](images/cover.webp). A relative link such as [Rubric](references/rubric.md#scoring) opens the linked Markdown document in the reader. Images and links in that document resolve from its own folder. Links to other files download the published bytes. The browser’s Back button returns to the previous document. Select any file in the tree to view it. Markdown renders as a document, PDF and Word (.docx) files show their pages, CSV and TSV files show as a table, and images and other text files display directly. Every file has a Download button. The tree shows folders, including empty ones, and file sizes. Choose Use in Research Agent to open a draft request to retrieve and inspect that FileTree by UUID. Coop displays Expected Parrot survey respondent links as buttons. Use ordinary Markdown link text to set the button label. For example:
This displays Give us feedback. Use the respondent URL for your survey, including any invitation parameters. The optional label ep_button displays Take the survey. To keep a UTF-8 file opaque, pass its relative path in blob_paths=["runs/job.json"] to from_directory, or use --blob runs/job.json on each CLI capture. When constructing a tree directly, strings supply literal text, bytes supply an opaque blob, and a Path or EDSL FileStore supplies a snapshot of its contents. JSON serialization carries one snapshot, while a saved .ep carries the revision history.

Inspect an agent skill

Capture the skill directory so its SKILL.md, scripts, and references share one revision. Inspect the saved package to see the skill name and description in data.skill.
In Python, FileTree.load("my-skill.ep").skill_metadata() returns the full YAML front matter, including extra fields such as tags. The root SKILL.md must declare a non-empty string for both name and description. The method raises ValueError with a correction if it cannot read those fields. For a package with a malformed root skill file, ep inspect still lists its paths and includes an INVALID_SKILL_METADATA warning.

Compile Markdown to PDF

Install Pandoc and XeLaTeX on your PATH. Call to_pdf() to compile a Markdown document from the loaded revision. It returns a PDF FileStore, and passing an output path also writes the PDF there.
Reference figures relative to the selected Markdown file. For example, reports/post.md can embed ../images/chart.png. A missing figure raises an error identifying the source and image. The print style supports title, author, and date metadata, tables, captions, and syntax-highlighted code. Use trusted documents with the local TeX toolchain. For WebP figures, install Pillow. The PDF compiler renders a temporary PNG from the captured WebP. Pass an installed body font with font="Times New Roman" when a document needs glyphs such as ○.

Export Markdown or HTML with embedded images

Give export_document() a Markdown or HTML output path. It reads one Markdown source from the loaded revision and writes its referenced images into the output as base64 data URIs. The same source-selection rules as to_pdf() apply.
Both exports require Pandoc. Markdown images (including reference-style images), HTML image tags, and responsive image candidates resolve relative to the source. Keep external image files in the tree and reference their relative paths. Ordinary hyperlinks remain links. Pandoc can normalize Markdown formatting. Some Markdown hosts block data URIs for images; open the HTML export in a browser for a portable view.

Export a saved revision from the CLI

Use -o to choose a format by filename, or --output-dir to write all three formats from the same revision. Omit --source when the tree has one Markdown file. With several Markdown files, give the full path inside the tree.
The last command writes exports/post.md, exports/post.html, and exports/post.pdf. Each file uses the selected source’s basename. PDF exports also require XeLaTeX and accept an installed body font via --font. The JSON receipt gives the selected source, its Git commit, and the path to each file in outputs. Use referenced_images to see which local files the source uses, and embedded_images to see which of those files each format includes. For example, Markdown and HTML preserve responsive image candidates in raw HTML, while PDF uses Markdown image nodes. An image used twice appears once in each list. Text-only documents have empty lists. A missing local image fails the export before any output file is replaced.