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.0.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.0-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for logic_md-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b2f531af75aea047936fd753e06d4bc8dca5103ee8f3f6de58b2e0f20d7b5eea
MD5 6ca22f4c8dfb6416274a25fd3f30d0b0
BLAKE2b-256 3b92eb059a7e0a21470593e87b1830850b27ff0195663b42f6e2738bbc627ebb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: logic_md-0.1.0-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.12.6

File hashes

Hashes for logic_md-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eccc6610457249654ae2b97707681b2c4fd41440ef44e99a93339cfdaf8cdab8
MD5 b799b1029ee57b33cbe5533ead72f8b7
BLAKE2b-256 c1270103154ed514a5f42e6e099785a8b87b309fbceddea5461d1499a8e9748d

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