Models¶
Pydantic data models for HtmlGraph entities.
Overview¶
HtmlGraph uses Pydantic models for:
- Type safety and validation
- Serialization to/from HTML
- JSON export/import
- Schema documentation
All models are immutable by default and validate on construction.
Feature¶
Represents a unit of work.
from htmlgraph.models import Feature, FeatureStatus, Priority
feature = Feature(
id="feature-20241216-103045",
title="Add user authentication",
status=FeatureStatus.IN_PROGRESS,
priority=Priority.HIGH,
steps=[
Step(description="Create endpoint", completed=True),
Step(description="Add middleware", completed=False)
]
)
Fields¶
id: str- Unique identifiertitle: str- Feature titlestatus: FeatureStatus- Current statuspriority: Priority- Priority levelcreated: datetime- Creation timestampupdated: datetime- Last update timestampsteps: list[Step]- Implementation stepsproperties: dict- Custom propertiestrack_id: Optional[str]- Parent track ID
Methods¶
to_html() -> str- Convert to HTML file contentsave()- Save to diskto_dict() -> dict- Convert to dictionaryto_json() -> str- Convert to JSON
Track¶
Represents a multi-feature project.
from htmlgraph.models import Track
track = Track(
track_id="track-20241216-120000",
title="User Authentication System",
priority=Priority.HIGH,
has_spec=True,
has_plan=True
)
Fields¶
track_id: str- Unique identifiertitle: str- Track titledescription: str- Track descriptionpriority: Priority- Priority levelstatus: str- Current statuscreated: datetime- Creation timestampupdated: datetime- Last update timestamphas_spec: bool- Whether track has a spechas_plan: bool- Whether track has a plan
Session¶
Represents an agent work session.
from htmlgraph.models import Session
session = Session(
id="session-abc-123",
agent="claude",
start_time=datetime.now(),
features_worked_on=["feature-001", "feature-002"]
)
Fields¶
id: str- Unique identifieragent: str- Agent namestart_time: datetime- Session startend_time: Optional[datetime]- Session endfeatures_worked_on: list[str]- Feature IDsevent_count: int- Number of events logged
Step¶
Represents a single implementation step.
from htmlgraph.models import Step
step = Step(
description="Create login endpoint",
completed=False,
agent="claude",
timestamp=datetime.now()
)
Fields¶
description: str- Step descriptioncompleted: bool- Completion statusagent: Optional[str]- Agent who completed ittimestamp: Optional[datetime]- Completion time
Enums¶
FeatureStatus¶
from htmlgraph.models import FeatureStatus
FeatureStatus.TODO # Not started
FeatureStatus.IN_PROGRESS # Currently working
FeatureStatus.BLOCKED # Waiting on dependencies
FeatureStatus.DONE # Completed
FeatureStatus.CANCELLED # Work abandoned
Priority¶
from htmlgraph.models import Priority
Priority.LOW # Low priority
Priority.MEDIUM # Medium priority (default)
Priority.HIGH # High priority
Priority.CRITICAL # Critical priority
Complete API Reference¶
For detailed API documentation with type signatures and complete field definitions, see the Python source code in src/python/htmlgraph/models.py.