Skip to main content

Python SDK for LOGIC.md — declarative AI agent reasoning specifications

Project description

logic-md

A Python SDK for parsing and validating LOGIC.md specifications — declarative reasoning configurations for AI agents.

Status: Alpha — parser and validator only.

Installation

pip install logic-md

Quick Start

from logic_md import parse, validate

# Parse a LOGIC.md file
with open("my-agent.logic.md") as f:
    content = f.read()

result = parse(content)
if result.ok:
    print(f"Parsed spec: {result.data['name']}")
else:
    print(f"Parse errors: {result.errors}")

# Validate the parsed spec
val_result = validate(result.data)
if val_result.ok:
    print("Spec is valid!")
else:
    for error in val_result.errors:
        print(f"Validation error at {error['path']}: {error['message']}")

API

parse(content: str) -> ParseResult

Extracts YAML frontmatter from a LOGIC.md file and returns a ParseResult:

  • ok: bool — True if parsing succeeded
  • data: dict — Parsed YAML frontmatter (if ok=True)
  • content: str — Markdown body after frontmatter
  • errors: list[str] — Error messages (if ok=False)

Example:

result = parse("---\nspec_version: '1.0'\nname: my-agent\n---\n# My Agent")
# result.ok = True
# result.data = {"spec_version": "1.0", "name": "my-agent"}
# result.content = "# My Agent"

validate(spec: dict) -> ValidationResult

Validates a parsed spec against the LOGIC.md JSON Schema and returns a ValidationResult:

  • ok: bool — True if spec is valid
  • data: dict — The validated spec (if ok=True)
  • errors: list[dict] — Validation errors with path, keyword, message (if ok=False)

Example:

result = validate({"spec_version": "1.0", "name": "my-agent"})
# result.ok = True
# result.data = {"spec_version": "1.0", "name": "my-agent"}

LogicSpec

A TypedDict type hint for the parsed/validated spec structure. Use for type hints:

from logic_md import LogicSpec

def process_spec(spec: LogicSpec) -> None:
    print(spec["name"])

Schema

The validator uses the canonical JSON Schema from the logic-md spec repository.

Links

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

logic_md-0.1.1.tar.gz (13.8 kB view details)

Uploaded Source

Built Distribution

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

logic_md-0.1.1-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for logic_md-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9206beb4f9e3f183190fa9226f322c9a6cb7ce2e2cd4e9b0d7e837e7886f9717
MD5 c750e62f844c2ccc48222ba6a93b6c90
BLAKE2b-256 283b62b5e7bbba8ade2d09234cd68b77bdd8951a489b5fdf61709233de0855f7

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for logic_md-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4a843c4bffd4685bc861f99592710420a5ab17afb9cdaf2c3ca52aec15f2841d
MD5 c9debee0cd9b09d3cc9331ea984c5aec
BLAKE2b-256 dd25f8d09dfe9ba30c3b0838ebdc6fceb5aa813c4a60295e32363ff2239ff4dd

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