AFM (Agent-Flavored Markdown) core: parser, CLI, protocols, and interfaces
Project description
AFM Core
Core library for Agent-Flavored Markdown (AFM) - providing parsing, validation, and interface implementations.
Features
- AFM File Parser: Extracts YAML frontmatter and Markdown content (Role, Instructions sections)
- Pydantic Models: Type-safe validation of AFM schema for agents, interfaces, and tools
- Interface Implementations: Console chat, web chat, and webhook interfaces
- AgentRunner Protocol: Pluggable backend system for different execution frameworks
- CLI Framework: Entry point for the
afmcommand with validation and run commands
Installation
This package is typically installed as part of afm-cli. For development or custom integrations:
pip install afm-core
Usage
from afm.parser import parse_afm_file
# Parse an AFM file (returns an AFMRecord)
record = parse_afm_file("agent.afm.md")
# Access parsed data
print(f"Agent: {record.metadata.name}")
print(f"Model: {record.metadata.model.provider}/{record.metadata.model.name}")
print(f"Interfaces: {[i.type for i in record.metadata.interfaces]}")
print(f"Role: {record.role}")
print(f"Instructions: {record.instructions}")
Development
Setup
This project uses uv for dependency management.
# Clone the repository
git clone https://github.com/wso2/reference-implementations-afm.git
cd python-interpreter
# Install dependencies
uv sync
Running Tests
# Run all tests
uv run pytest packages/afm-core/tests/
# Run with coverage
uv run pytest packages/afm-core/tests/ --cov=afm
Code Quality
# Format code
uv run ruff format
# Lint code
uv run ruff check
Project Structure
packages/afm-core/src/afm/
├── __init__.py
├── cli.py # CLI entry point
├── exceptions.py # Custom exceptions
├── models.py # Pydantic models
├── parser.py # AFM file parsing
├── runner.py # AgentRunner protocol and runner utilities
├── schema_validator.py # Schema validation
├── templates.py # Prompt templates
├── update.py # Update checker
├── variables.py # Variable substitution
└── interfaces/ # Interface implementations
├── __init__.py
├── base.py # Interface utilities (get_interfaces, get_http_path)
├── console_chat.py
├── web_chat.py
└── webhook.py
Documentation
For comprehensive documentation, see the project README.
License
Apache-2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file afm_core-0.1.7.tar.gz.
File metadata
- Download URL: afm_core-0.1.7.tar.gz
- Upload date:
- Size: 30.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d8ea2f679a438acb5d2006bb04506456e77ccf40e1611ca3215948c9c1d2213
|
|
| MD5 |
01393ae6d1ddb429a4a869397e197fa7
|
|
| BLAKE2b-256 |
3a270aba94e6618d3077d5418beca1c2b70e4cebc0253784189709d03c1725fc
|
File details
Details for the file afm_core-0.1.7-py3-none-any.whl.
File metadata
- Download URL: afm_core-0.1.7-py3-none-any.whl
- Upload date:
- Size: 42.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.6 {"installer":{"name":"uv","version":"0.10.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ac0884a3d23797893093e8ff349e105a77985e1cc6549048f2c281b727091c4
|
|
| MD5 |
05dba54ecd47f8f56b69968e706ebf9a
|
|
| BLAKE2b-256 |
e6235e2e66ac568019aa1bd3fb6bb58288853c1b04d8ecd79c7b0f66c94cdb1e
|