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.0.tar.gz (13.6 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.0-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for structfast-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5d644be95ec20fc6863c1d9fa13533516e814a4d7c4ce4e88f3d527f1f500e30
MD5 8ad67eea52dd860ece6b4b8c0c3bd12b
BLAKE2b-256 e8e3f74440fea8b5d262f6d19659a2754b7e7917552e0c417d81112cc20477c3

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for structfast-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 14f4e152dd5e1449132522f15c4a1f5b18fd150aeaddf94786384497ca5a9fdd
MD5 ac82ba8d43858d921ebd29a7b4c56f54
BLAKE2b-256 40276f7848781f5cbb4307939ff34ef4a482c88407c7dee7c790a8e70bbfaad8

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