Skip to main content

MAGI Specification

This document provides detailed specifications for the three optional components of MAGI (Markdown for Agent Guidance & Instruction): YAML Front Matter, ai-script Code Blocks, and Markdown Footnotes for Relationships. MAGI is designed to be saved in files with the .mda extension to clearly signal the presence of enhanced components. While standard Markdown files (.md) can contain MAGI elements for backward compatibility, processors optimized for MAGI might prioritize .mda files or treat .md files as standard Markdown, potentially ignoring ai-script blocks or footnote relationships unless explicitly configured to parse them. The MAGI format, represented as a string, is suitable for transmission via REST APIs, either as request payloads (e.g., sending content to be processed) or response bodies (e.g., returning processed or generated content in MAGI format).

1. Front Matter Schema

Provides structured metadata using YAML syntax, enclosed by --- delimiters at the very beginning of the .mda file. Fields: Field names use kebab-case (e.g., doc-id, created-date). Note: While all fields are technically optional for basic .mda validity, doc-id is essential if using the Footnote relationship feature. Custom fields are allowed but may be ignored by standard processors.

2. AI Script Block (ai-script)

Embeds instructions for AI processing within standard Markdown fenced code blocks using the ai-script language identifier. The content must be a single, valid JSON object. Field names within the JSON use kebab-case (e.g., script-id, model-name). JSON Fields: Processing Hint: A comment like <!-- AI-PROCESSOR: Content blocks marked with ```ai-script are instructions for AI systems and should not be presented to human users --> can optionally precede the block to explicitly guide processing systems, but detection should rely on the ai-script identifier. Alternative: Instructions can also be passed externally (e.g., via API metadata alongside the MAGI content string) for separation of concerns, especially in complex multi-agent systems.

3. Footnote Relationships

Leverages standard Markdown footnote syntax ([^ref-id] and [^ref-id]: ...) to define typed relationships between the current document and other resources. The footnote definition must contain a single JSON object enclosed in backticks (`). JSON Fields within Footnote Definition: Field names use kebab-case (e.g., rel-type, doc-id). Implementation Notes:
  • Ensure the doc-id used in footnotes corresponds accurately to a doc-id defined in the Front Matter of the target .mda document for internal links.
  • Consistent use of rel-type values is crucial for building reliable knowledge graphs.
  • Standard Markdown parsers will render the footnote with the backticks and JSON string as the literal content. MAGI-aware parsers extract and interpret the JSON.