Skip to main content

Turn text-based folder trees into real directories and files.

Project description

structfast

structfast is a production-ready Python package and CLI that turns text-based folder trees into real directories and files.

It is designed for trees copied from:

  • ChatGPT or other AI tools
  • GitHub READMEs
  • markdown docs
  • plain text notes
  • indentation-only outlines

Features

  • Parse .txt, .md, or raw string input
  • Support Unicode tree drawings like ├──, └──,
  • Handle indentation-based and messy AI-generated structures
  • Build safely with dry-run, overwrite, and skip-existing modes
  • Read structures directly from the clipboard
  • Export an existing directory back into a tree representation
  • Use as both a CLI tool and a Python API

Installation

Install with pip:

pip install structfast

Install with uv:

uv tool install structfast

Run without installing globally:

uvx structfast build structure.txt

Quick Start

Given a text file named structure.txt:

a2a-system/
├── backend/
│   ├── agents/
│   │   ├── planner.py
│   │   ├── worker.py
│   │   └── critic.py
│   └── main.py
└── requirements.txt

Build it in the current directory:

structfast build structure.txt

With uv:

uvx structfast build structure.txt

Preview without writing:

structfast build structure.txt --dry-run

Build into a specific root:

structfast build structure.txt --root ./sandbox

Paste directly from the clipboard:

structfast paste --dry-run --smart

Export an existing directory:

structfast export .

CLI Reference

structfast build <source>

Options:

  • --root PATH: destination root directory, defaults to the current directory
  • --dry-run: print planned actions without creating files or folders
  • --force: overwrite existing files
  • --skip-existing: skip any path that already exists
  • --smart: enable aggressive cleanup for malformed trees and inconsistent indentation
  • --verbose: show extra parser and builder details

Example output:

[DIR] a2a-system/
[DIR] a2a-system/backend/
[FILE] a2a-system/backend/main.py
[FILE] a2a-system/requirements.txt

structfast paste

Reads clipboard content using pyperclip, parses it, and builds the structure with the same flags as build.

structfast export <path>

Generates a tree view from an existing directory. By default it prints to stdout; use --output structure.txt to write it to a file.

Python API

from structfast import build_structure, export_structure, parse_structure

result = build_structure("structure.txt", root=".", dry_run=True, smart=True)
for action in result.actions:
    print(action.kind, action.relative_path, action.status)

nodes = parse_structure(\"\"\"
project/
  app/
    main.py
  README.md
\"\"\")

tree = export_structure(".")
print(tree)

Smart Parsing

The --smart mode makes parsing more forgiving by:

  • stripping markdown fences and list bullets
  • normalizing tabs to spaces
  • tolerating inconsistent indentation levels
  • cleaning common AI formatting artifacts
  • inferring directory types from nesting when trailing / is missing

Safety Model

  • Existing directories are reused safely
  • Existing files are only overwritten with --force
  • Use --skip-existing to ignore existing paths
  • Use --dry-run to inspect planned actions before writing

Development

Create a local dev environment with pip:

python -m venv .venv
. .venv/bin/activate
pip install -e .[dev]

Create a local dev environment with uv:

uv sync --dev

Run tests with pip/venv:

pytest

Run tests with uv:

uv run pytest

Run the CLI in development with uv:

uv run structfast build structure.txt --dry-run

Build distributions with either tool:

python -m build
uv build

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

structfast-0.1.1.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

structfast-0.1.1-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

Details for the file structfast-0.1.1.tar.gz.

File metadata

  • Download URL: structfast-0.1.1.tar.gz
  • Upload date:
  • Size: 14.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for structfast-0.1.1.tar.gz
Algorithm Hash digest
SHA256 01e5d5b747c562e5827ce5f1fe597ac3b7090fa00fa46442a517429052ee80ed
MD5 877c3ec6daa87036fa77022b4a4582c0
BLAKE2b-256 3d370c5f2af2be2700d4759ff0b7a16928724a9d4a7bff081268a23db98dfdc0

See more details on using hashes here.

File details

Details for the file structfast-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: structfast-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 12.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for structfast-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 55b86e9f4344dbde8aa5f3db204dec7a0d1de40a0c74329993fd0f65f3d82dc8
MD5 8d3e2ba02321624bfa43b3af8ab5349e
BLAKE2b-256 87d344759ba019fcccfe04ef0b99303bd6378a7139a216f0379cad88f92fc878

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page