Skip to main content

Progressive Formalization for Markdown using Pydantic and Pytest

Project description

Typedown: Markdown that scales

License: MIT Python 3.12+ Linter: Ruff

Typedown is a Consensus Modeling Language (CML) designed for Literate Modeling. It bridges the gap between the fluidity of human thought (Markdown) and the rigor of engineering (Pydantic + Pytest).

"You don't know it until you model it."


The Trinity

Typedown treats Markdown as a first-class language for Consensus as Code (CaC), built on three pillars:

  1. Markdown (Interface): Retains natural language expressiveness. It's the habitat for humans and AI.
  2. Pydantic (Structure): Defines strict data schemas via model blocks.
  3. Pytest (Logic): Enforces business rules and constraints via spec blocks.

Why Typedown?

Traditional tools force a binary choice:

  • Liquids (Text/Markdown): High fluidity but zero structural integrity. Documentation rots instantly.
  • Crystals (Code/JSON/SQL): High integrity but zero flexibility. Hard for humans to browse and for AI to grasp intent.

Typedown is Active Soft Matter. It allows information to "phase transition" from loose notes into solid, validated models within the same document.

Core Features

  • Markdown that scales: Manage thousands of interconnected entities with IDE-grade navigation and validation.
  • Progressive Formalization: Start with a sketch, end with a verified system.
  • Triple Resolution: Resolve references [[ref]] through Hash (L0), Handle (L1), and Logical ID (L2).
  • Evolution Semantics: Track time using former (versioning) to manage history.
  • Context-Aware Scoping: Implicit hierarchy via config.td and directory inheritance.
  • QC Pipeline: Four-layered validation from syntax (Lint) to external facts (Test).

Quick Start

1. Define a Model

Define your schema directly in Markdown using Python:

```model:UserAccount
class UserAccount(BaseModel):
    name: str
    age: int = Field(..., ge=18)
    role: str = "member"
```

2. Declare an Entity

Instantiate data using YAML with smart reference unboxing:

```entity UserAccount: alice
id: "iam/user/alice-v1"
name: "Alice"
age: 30
role: "admin"
```

3. Write a Specification

Add business logic that targets your data:

```spec id=check_roles
@target(type="UserAccount")
def validate_admin(subject: UserAccount):
    if subject.role == "admin":
        assert subject.age >= 25, "Admins must be senior"
```

CLI Usage

The td tool is your companion for the development loop:

  • td lint: (L1) Check Markdown syntax and YAML formatting.
  • td check: (L2) Validate entities against Pydantic models.
  • td validate: (L3) Check references and run spec blocks (Internal Logic).
  • td test: (L4) Run external verification (Oracles/APIs).
  • td run <script>: Execute scripts defined in Front Matter.

Installation

Typedown is designed for the uv ecosystem. We recommend using uv or uvx over standard piping.

🚀 Instant Run (Recommended)

Use uvx to execute Typedown instantly without managing environments:

uvx typedown --help

🛠️ Global Tool

Install it as a standalone tool available everywhere:

uv tool install typedown

📦 Project Dependency

Add it to your Python project:

uv add typedown

⌨️ VS Code Extension

Install Typedown Integration from:

Documentation


License

MIT © IndenScale

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

typedown-0.2.6.tar.gz (224.6 kB view details)

Uploaded Source

Built Distribution

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

typedown-0.2.6-py3-none-any.whl (75.0 kB view details)

Uploaded Python 3

File details

Details for the file typedown-0.2.6.tar.gz.

File metadata

  • Download URL: typedown-0.2.6.tar.gz
  • Upload date:
  • Size: 224.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for typedown-0.2.6.tar.gz
Algorithm Hash digest
SHA256 a1377741042a531f90608c3a1f2cf7ba2034f8953845a286fc2d49afde32df7d
MD5 ff4798ab505d773b88811aeea914028b
BLAKE2b-256 fc1d1300b17f68f37dfb329938fa244df034df19b2e94b87f350e46743effca7

See more details on using hashes here.

Provenance

The following attestation bundles were made for typedown-0.2.6.tar.gz:

Publisher: publish-pypi.yml on IndenScale/Typedown

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file typedown-0.2.6-py3-none-any.whl.

File metadata

  • Download URL: typedown-0.2.6-py3-none-any.whl
  • Upload date:
  • Size: 75.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for typedown-0.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 dd67cea46599cf39cdca74a0770aaf9412191f4a710e7cf956c866b2706aa0b7
MD5 600b5f96e22278497bc3e89749ad8a69
BLAKE2b-256 61e162ab8913df78b1822f71c63109936ed50265a105bebbe6b51fbde2877bb5

See more details on using hashes here.

Provenance

The following attestation bundles were made for typedown-0.2.6-py3-none-any.whl:

Publisher: publish-pypi.yml on IndenScale/Typedown

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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