Metadata-Version: 2.4
Name: semantic-dom-ssg
Version: 0.1.0
Summary: Python implementation of ISO/IEC draft standard for SemanticDOM and Semantic State Graph. O(1) element lookup, deterministic navigation, agent-ready web interoperability. MCP and Django compatible.
Project-URL: Homepage, https://github.com/gorgalxandr/semantic-dom-ssg
Project-URL: Documentation, https://github.com/gorgalxandr/semantic-dom-ssg#readme
Project-URL: Repository, https://github.com/gorgalxandr/semantic-dom-ssg
Project-URL: Issues, https://github.com/gorgalxandr/semantic-dom-ssg/issues
Author-email: George <george@consltr.com>
Maintainer-email: George <george@consltr.com>
License-Expression: MIT
Keywords: a11y,accessibility,ai-agent,django,llm,mcp,model-context-protocol,semantic-dom,semantic-state-graph,ssg,toon,web-automation
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: Django
Classifier: Framework :: Django :: 4.0
Classifier: Framework :: Django :: 5.0
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Text Processing :: Markup :: HTML
Requires-Python: >=3.10
Requires-Dist: beautifulsoup4>=4.12.0
Requires-Dist: lxml>=5.0.0
Provides-Extra: all
Requires-Dist: django>=4.0; extra == 'all'
Requires-Dist: mcp>=1.0.0; extra == 'all'
Provides-Extra: dev
Requires-Dist: black>=24.0; extra == 'dev'
Requires-Dist: mypy>=1.9; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
Requires-Dist: pytest-django>=4.8; extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: ruff>=0.3; extra == 'dev'
Provides-Extra: django
Requires-Dist: django>=4.0; extra == 'django'
Provides-Extra: mcp
Requires-Dist: mcp>=1.0.0; extra == 'mcp'
Description-Content-Type: text/markdown

# SemanticDOM SSG - Python

Python implementation of the SemanticDOM & Semantic State Graph (SSG) specification for AI-first web development.

## Installation

```bash
pip install semantic-dom-ssg
```

With Django integration:
```bash
pip install semantic-dom-ssg[django]
```

With MCP server support:
```bash
pip install semantic-dom-ssg[mcp]
```

## Quick Start

```python
from semantic_dom_ssg import SemanticDOMParser, ToonSerializer

# Parse HTML
parser = SemanticDOMParser()
doc = parser.parse(html_content, "https://example.com")

# O(1) element lookup
button = doc.query("submit-btn")

# List landmarks and interactables
for landmark in doc.landmarks:
    print(f"{landmark.role}: {landmark.label}")

# Get agent certification
cert = doc.agent_ready
print(f"Score: {cert.score}/100")

# Serialize to TOON format (40-50% token savings)
toon = ToonSerializer.serialize(doc)
```

## Django Integration

### Middleware
```python
# settings.py
MIDDLEWARE = [
    # ...
    'semantic_dom_ssg.django.SemanticDOMMiddleware',
]
```

### Template Tags
```django
{% load semantic_dom %}

<button {% semantic_id "submit-btn" %} {% semantic_intent "submit" %}>
    Submit
</button>

<nav {% semantic_landmark "navigation" "Main menu" %}>
    ...
</nav>
```

### Views
```python
from semantic_dom_ssg.django import SemanticDOMView

class MyView(SemanticDOMView):
    template_name = 'my_template.html'
```

## CLI

```bash
# Parse HTML to JSON
semantic-dom parse index.html

# Parse to TOON format
semantic-dom parse index.html -f toon

# Validate compliance
semantic-dom validate index.html

# Show statistics
semantic-dom stats index.html

# Run MCP server
semantic-dom mcp-server
```

## MCP Server

The package includes an MCP (Model Context Protocol) server for AI agent integration:

```bash
semantic-dom mcp-server
```

Available tools:
- `parse_html` - Parse HTML into SemanticDOM
- `semantic_query` - O(1) element lookup
- `semantic_navigate` - Navigate to landmarks
- `semantic_list_landmarks` - List all landmarks
- `semantic_list_interactables` - List interactive elements
- `semantic_state_graph` - Get state transitions
- `semantic_certification` - Get agent readiness score

## Specification

Implements ISO/IEC-SDOM-SSG-DRAFT-2024:
- O(1) element lookup via semantic IDs
- Semantic State Graph for UI state modeling
- TOON format for token-efficient serialization
- Agent certification scoring

## License

MIT
