htmlgraph 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- htmlgraph-0.1.0/.gitignore +49 -0
- htmlgraph-0.1.0/PKG-INFO +207 -0
- htmlgraph-0.1.0/README.md +173 -0
- htmlgraph-0.1.0/examples/todo-list/demo.py +124 -0
- htmlgraph-0.1.0/examples/todo-list/index.html +359 -0
- htmlgraph-0.1.0/examples/todo-list/styles.css +43 -0
- htmlgraph-0.1.0/examples/todo-list/task-001.html +41 -0
- htmlgraph-0.1.0/examples/todo-list/task-002.html +75 -0
- htmlgraph-0.1.0/examples/todo-list/task-003.html +53 -0
- htmlgraph-0.1.0/examples/todo-list/task-004.html +62 -0
- htmlgraph-0.1.0/examples/todo-list/task-005.html +48 -0
- htmlgraph-0.1.0/pyproject.toml +91 -0
- htmlgraph-0.1.0/src/python/htmlgraph/__init__.py +26 -0
- htmlgraph-0.1.0/src/python/htmlgraph/agents.py +503 -0
- htmlgraph-0.1.0/src/python/htmlgraph/analytics_index.py +739 -0
- htmlgraph-0.1.0/src/python/htmlgraph/cli.py +1442 -0
- htmlgraph-0.1.0/src/python/htmlgraph/converter.py +524 -0
- htmlgraph-0.1.0/src/python/htmlgraph/event_log.py +121 -0
- htmlgraph-0.1.0/src/python/htmlgraph/event_migration.py +72 -0
- htmlgraph-0.1.0/src/python/htmlgraph/file_watcher.py +116 -0
- htmlgraph-0.1.0/src/python/htmlgraph/git_events.py +638 -0
- htmlgraph-0.1.0/src/python/htmlgraph/graph.py +590 -0
- htmlgraph-0.1.0/src/python/htmlgraph/mcp_server.py +660 -0
- htmlgraph-0.1.0/src/python/htmlgraph/models.py +555 -0
- htmlgraph-0.1.0/src/python/htmlgraph/parser.py +378 -0
- htmlgraph-0.1.0/src/python/htmlgraph/server.py +740 -0
- htmlgraph-0.1.0/src/python/htmlgraph/session_manager.py +1220 -0
- htmlgraph-0.1.0/src/python/htmlgraph/styles.css +345 -0
- htmlgraph-0.1.0/src/python/htmlgraph/watch.py +128 -0
- htmlgraph-0.1.0/tests/python/__init__.py +1 -0
- htmlgraph-0.1.0/tests/python/test_cli_commands.py +265 -0
- htmlgraph-0.1.0/tests/python/test_dashboard_ui.py +157 -0
- htmlgraph-0.1.0/tests/python/test_event_index.py +210 -0
- htmlgraph-0.1.0/tests/python/test_git_events.py +49 -0
- htmlgraph-0.1.0/tests/python/test_mcp_server.py +174 -0
- htmlgraph-0.1.0/tests/python/test_mcp_stdio_transport.py +44 -0
- htmlgraph-0.1.0/tests/python/test_models.py +317 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
.venv/
|
|
3
|
+
__pycache__/
|
|
4
|
+
*.py[cod]
|
|
5
|
+
*$py.class
|
|
6
|
+
*.so
|
|
7
|
+
.Python
|
|
8
|
+
build/
|
|
9
|
+
develop-eggs/
|
|
10
|
+
dist/
|
|
11
|
+
downloads/
|
|
12
|
+
eggs/
|
|
13
|
+
.eggs/
|
|
14
|
+
lib/
|
|
15
|
+
lib64/
|
|
16
|
+
parts/
|
|
17
|
+
sdist/
|
|
18
|
+
var/
|
|
19
|
+
wheels/
|
|
20
|
+
*.egg-info/
|
|
21
|
+
.installed.cfg
|
|
22
|
+
*.egg
|
|
23
|
+
|
|
24
|
+
# Testing
|
|
25
|
+
.coverage
|
|
26
|
+
.pytest_cache/
|
|
27
|
+
htmlcov/
|
|
28
|
+
|
|
29
|
+
# Playwright
|
|
30
|
+
.playwright-mcp/
|
|
31
|
+
|
|
32
|
+
# IDE
|
|
33
|
+
.idea/
|
|
34
|
+
.vscode/
|
|
35
|
+
*.swp
|
|
36
|
+
*.swo
|
|
37
|
+
*~
|
|
38
|
+
|
|
39
|
+
# OS
|
|
40
|
+
.DS_Store
|
|
41
|
+
Thumbs.db
|
|
42
|
+
|
|
43
|
+
# Local development
|
|
44
|
+
*.log
|
|
45
|
+
|
|
46
|
+
# HtmlGraph analytics index (rebuildable cache)
|
|
47
|
+
.htmlgraph/index.sqlite
|
|
48
|
+
.htmlgraph/index.sqlite-wal
|
|
49
|
+
.htmlgraph/index.sqlite-shm
|
htmlgraph-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: htmlgraph
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: HTML is All You Need - Graph database on web standards
|
|
5
|
+
Project-URL: Homepage, https://github.com/Shakes-tzd/htmlgraph
|
|
6
|
+
Project-URL: Documentation, https://github.com/Shakes-tzd/htmlgraph#readme
|
|
7
|
+
Project-URL: Repository, https://github.com/Shakes-tzd/htmlgraph
|
|
8
|
+
Project-URL: Issues, https://github.com/Shakes-tzd/htmlgraph/issues
|
|
9
|
+
Author-email: Shakes <shakes@example.com>
|
|
10
|
+
License: MIT
|
|
11
|
+
Keywords: agents,ai,css,database,graph,html
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Database
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Requires-Dist: justhtml>=0.6.0
|
|
23
|
+
Requires-Dist: pydantic>=2.0.0
|
|
24
|
+
Requires-Dist: watchdog>=3.0.0
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: black>=23.0.0; extra == 'dev'
|
|
27
|
+
Requires-Dist: mypy>=1.0.0; extra == 'dev'
|
|
28
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest>=7.0.0; extra == 'dev'
|
|
30
|
+
Requires-Dist: ruff>=0.1.0; extra == 'dev'
|
|
31
|
+
Provides-Extra: sqlite
|
|
32
|
+
Requires-Dist: aiosqlite>=0.19.0; extra == 'sqlite'
|
|
33
|
+
Description-Content-Type: text/markdown
|
|
34
|
+
|
|
35
|
+
# HtmlGraph
|
|
36
|
+
|
|
37
|
+
**"HTML is All You Need"**
|
|
38
|
+
|
|
39
|
+
A lightweight graph database framework built entirely on web standards. Use HTML files as nodes, hyperlinks as edges, and CSS selectors as the query language.
|
|
40
|
+
|
|
41
|
+
## Why HtmlGraph?
|
|
42
|
+
|
|
43
|
+
Modern AI agent systems are drowning in complexity:
|
|
44
|
+
- Neo4j/Memgraph ā Docker, JVM, learn Cypher
|
|
45
|
+
- Redis/PostgreSQL ā More infrastructure
|
|
46
|
+
- Custom protocols ā More learning curves
|
|
47
|
+
|
|
48
|
+
**HtmlGraph uses what you already know:**
|
|
49
|
+
- ā
HTML files = Graph nodes
|
|
50
|
+
- ā
`<a href>` = Graph edges
|
|
51
|
+
- ā
CSS selectors = Query language
|
|
52
|
+
- ā
Any browser = Visual interface
|
|
53
|
+
- ā
Git = Version control (diffs work!)
|
|
54
|
+
|
|
55
|
+
## Installation
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
pip install htmlgraph
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Quick Start
|
|
62
|
+
|
|
63
|
+
### Python
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
from htmlgraph import HtmlGraph, Node, Edge, Step
|
|
67
|
+
|
|
68
|
+
# Initialize graph from directory
|
|
69
|
+
graph = HtmlGraph("features/")
|
|
70
|
+
|
|
71
|
+
# Create a node
|
|
72
|
+
node = Node(
|
|
73
|
+
id="feature-001",
|
|
74
|
+
title="User Authentication",
|
|
75
|
+
type="feature",
|
|
76
|
+
status="in-progress",
|
|
77
|
+
priority="high",
|
|
78
|
+
steps=[
|
|
79
|
+
Step(description="Create auth routes"),
|
|
80
|
+
Step(description="Add middleware"),
|
|
81
|
+
Step(description="Implement OAuth"),
|
|
82
|
+
],
|
|
83
|
+
edges={
|
|
84
|
+
"blocked_by": [Edge(target_id="feature-002", title="Database Schema")]
|
|
85
|
+
}
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
# Add to graph (creates HTML file)
|
|
89
|
+
graph.add(node)
|
|
90
|
+
|
|
91
|
+
# Query with CSS selectors
|
|
92
|
+
blocked = graph.query("[data-status='blocked']")
|
|
93
|
+
high_priority = graph.query("[data-priority='high']")
|
|
94
|
+
|
|
95
|
+
# Graph traversal
|
|
96
|
+
path = graph.shortest_path("feature-001", "feature-010")
|
|
97
|
+
deps = graph.transitive_deps("feature-001")
|
|
98
|
+
bottlenecks = graph.find_bottlenecks()
|
|
99
|
+
|
|
100
|
+
# Get lightweight context for AI agents (~50 tokens)
|
|
101
|
+
print(node.to_context())
|
|
102
|
+
# Output:
|
|
103
|
+
# # feature-001: User Authentication
|
|
104
|
+
# Status: in-progress | Priority: high
|
|
105
|
+
# Progress: 0/3 steps (0%)
|
|
106
|
+
# ā ļø Blocked by: Database Schema
|
|
107
|
+
# Next: Create auth routes
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Agent Interface
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
from htmlgraph.agents import AgentInterface
|
|
114
|
+
|
|
115
|
+
agent = AgentInterface("features/", agent_id="claude")
|
|
116
|
+
|
|
117
|
+
# Get next available task
|
|
118
|
+
task = agent.get_next_task(priority="high")
|
|
119
|
+
|
|
120
|
+
# Get lightweight context
|
|
121
|
+
context = agent.get_context(task.id)
|
|
122
|
+
|
|
123
|
+
# Update progress
|
|
124
|
+
agent.complete_step(task.id, step_index=0)
|
|
125
|
+
|
|
126
|
+
# Complete task
|
|
127
|
+
agent.complete_task(task.id)
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### HTML File Format
|
|
131
|
+
|
|
132
|
+
HtmlGraph nodes are standard HTML files:
|
|
133
|
+
|
|
134
|
+
```html
|
|
135
|
+
<!DOCTYPE html>
|
|
136
|
+
<html lang="en">
|
|
137
|
+
<head>
|
|
138
|
+
<meta charset="UTF-8">
|
|
139
|
+
<title>User Authentication</title>
|
|
140
|
+
</head>
|
|
141
|
+
<body>
|
|
142
|
+
<article id="feature-001"
|
|
143
|
+
data-type="feature"
|
|
144
|
+
data-status="in-progress"
|
|
145
|
+
data-priority="high">
|
|
146
|
+
|
|
147
|
+
<header>
|
|
148
|
+
<h1>User Authentication</h1>
|
|
149
|
+
</header>
|
|
150
|
+
|
|
151
|
+
<nav data-graph-edges>
|
|
152
|
+
<section data-edge-type="blocked_by">
|
|
153
|
+
<h3>Blocked By:</h3>
|
|
154
|
+
<ul>
|
|
155
|
+
<li><a href="feature-002.html">Database Schema</a></li>
|
|
156
|
+
</ul>
|
|
157
|
+
</section>
|
|
158
|
+
</nav>
|
|
159
|
+
|
|
160
|
+
<section data-steps>
|
|
161
|
+
<h3>Steps</h3>
|
|
162
|
+
<ol>
|
|
163
|
+
<li data-completed="true">ā
Create auth routes</li>
|
|
164
|
+
<li data-completed="false">ā³ Add middleware</li>
|
|
165
|
+
</ol>
|
|
166
|
+
</section>
|
|
167
|
+
</article>
|
|
168
|
+
</body>
|
|
169
|
+
</html>
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Features
|
|
173
|
+
|
|
174
|
+
- **Zero dependencies** beyond `justhtml` and `pydantic`
|
|
175
|
+
- **CSS selector queries** - no new query language to learn
|
|
176
|
+
- **Version control friendly** - git diff works perfectly
|
|
177
|
+
- **Human readable** - open in any browser
|
|
178
|
+
- **AI agent optimized** - lightweight context generation
|
|
179
|
+
- **Graph algorithms** - BFS, shortest path, cycle detection, topological sort
|
|
180
|
+
|
|
181
|
+
## Comparison
|
|
182
|
+
|
|
183
|
+
| Feature | Neo4j | JSON | HtmlGraph |
|
|
184
|
+
|---------|-------|------|-----------|
|
|
185
|
+
| Setup | Docker + JVM | None | None |
|
|
186
|
+
| Query Language | Cypher | jq | CSS selectors |
|
|
187
|
+
| Human Readable | ā Browser needed | š” Text editor | ā
Any browser |
|
|
188
|
+
| Version Control | ā Binary | ā
JSON diff | ā
HTML diff |
|
|
189
|
+
| Visual UI | ā Separate tool | ā Build it | ā
Built-in |
|
|
190
|
+
| Graph Native | ā
| ā | ā
|
|
|
191
|
+
|
|
192
|
+
## Use Cases
|
|
193
|
+
|
|
194
|
+
1. **AI Agent Coordination** - Task tracking, dependencies, progress
|
|
195
|
+
2. **Knowledge Bases** - Linked notes with visual navigation
|
|
196
|
+
3. **Documentation** - Interconnected docs with search
|
|
197
|
+
4. **Task Management** - Todo lists with dependencies
|
|
198
|
+
|
|
199
|
+
## License
|
|
200
|
+
|
|
201
|
+
MIT
|
|
202
|
+
|
|
203
|
+
## Links
|
|
204
|
+
|
|
205
|
+
- [GitHub](https://github.com/Shakes-tzd/htmlgraph)
|
|
206
|
+
- [Documentation](https://github.com/Shakes-tzd/htmlgraph#readme)
|
|
207
|
+
- [Examples](https://github.com/Shakes-tzd/htmlgraph/tree/main/examples)
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# HtmlGraph
|
|
2
|
+
|
|
3
|
+
**"HTML is All You Need"**
|
|
4
|
+
|
|
5
|
+
A lightweight graph database framework built entirely on web standards. Use HTML files as nodes, hyperlinks as edges, and CSS selectors as the query language.
|
|
6
|
+
|
|
7
|
+
## Why HtmlGraph?
|
|
8
|
+
|
|
9
|
+
Modern AI agent systems are drowning in complexity:
|
|
10
|
+
- Neo4j/Memgraph ā Docker, JVM, learn Cypher
|
|
11
|
+
- Redis/PostgreSQL ā More infrastructure
|
|
12
|
+
- Custom protocols ā More learning curves
|
|
13
|
+
|
|
14
|
+
**HtmlGraph uses what you already know:**
|
|
15
|
+
- ā
HTML files = Graph nodes
|
|
16
|
+
- ā
`<a href>` = Graph edges
|
|
17
|
+
- ā
CSS selectors = Query language
|
|
18
|
+
- ā
Any browser = Visual interface
|
|
19
|
+
- ā
Git = Version control (diffs work!)
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pip install htmlgraph
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Quick Start
|
|
28
|
+
|
|
29
|
+
### Python
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
from htmlgraph import HtmlGraph, Node, Edge, Step
|
|
33
|
+
|
|
34
|
+
# Initialize graph from directory
|
|
35
|
+
graph = HtmlGraph("features/")
|
|
36
|
+
|
|
37
|
+
# Create a node
|
|
38
|
+
node = Node(
|
|
39
|
+
id="feature-001",
|
|
40
|
+
title="User Authentication",
|
|
41
|
+
type="feature",
|
|
42
|
+
status="in-progress",
|
|
43
|
+
priority="high",
|
|
44
|
+
steps=[
|
|
45
|
+
Step(description="Create auth routes"),
|
|
46
|
+
Step(description="Add middleware"),
|
|
47
|
+
Step(description="Implement OAuth"),
|
|
48
|
+
],
|
|
49
|
+
edges={
|
|
50
|
+
"blocked_by": [Edge(target_id="feature-002", title="Database Schema")]
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
# Add to graph (creates HTML file)
|
|
55
|
+
graph.add(node)
|
|
56
|
+
|
|
57
|
+
# Query with CSS selectors
|
|
58
|
+
blocked = graph.query("[data-status='blocked']")
|
|
59
|
+
high_priority = graph.query("[data-priority='high']")
|
|
60
|
+
|
|
61
|
+
# Graph traversal
|
|
62
|
+
path = graph.shortest_path("feature-001", "feature-010")
|
|
63
|
+
deps = graph.transitive_deps("feature-001")
|
|
64
|
+
bottlenecks = graph.find_bottlenecks()
|
|
65
|
+
|
|
66
|
+
# Get lightweight context for AI agents (~50 tokens)
|
|
67
|
+
print(node.to_context())
|
|
68
|
+
# Output:
|
|
69
|
+
# # feature-001: User Authentication
|
|
70
|
+
# Status: in-progress | Priority: high
|
|
71
|
+
# Progress: 0/3 steps (0%)
|
|
72
|
+
# ā ļø Blocked by: Database Schema
|
|
73
|
+
# Next: Create auth routes
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Agent Interface
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
from htmlgraph.agents import AgentInterface
|
|
80
|
+
|
|
81
|
+
agent = AgentInterface("features/", agent_id="claude")
|
|
82
|
+
|
|
83
|
+
# Get next available task
|
|
84
|
+
task = agent.get_next_task(priority="high")
|
|
85
|
+
|
|
86
|
+
# Get lightweight context
|
|
87
|
+
context = agent.get_context(task.id)
|
|
88
|
+
|
|
89
|
+
# Update progress
|
|
90
|
+
agent.complete_step(task.id, step_index=0)
|
|
91
|
+
|
|
92
|
+
# Complete task
|
|
93
|
+
agent.complete_task(task.id)
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### HTML File Format
|
|
97
|
+
|
|
98
|
+
HtmlGraph nodes are standard HTML files:
|
|
99
|
+
|
|
100
|
+
```html
|
|
101
|
+
<!DOCTYPE html>
|
|
102
|
+
<html lang="en">
|
|
103
|
+
<head>
|
|
104
|
+
<meta charset="UTF-8">
|
|
105
|
+
<title>User Authentication</title>
|
|
106
|
+
</head>
|
|
107
|
+
<body>
|
|
108
|
+
<article id="feature-001"
|
|
109
|
+
data-type="feature"
|
|
110
|
+
data-status="in-progress"
|
|
111
|
+
data-priority="high">
|
|
112
|
+
|
|
113
|
+
<header>
|
|
114
|
+
<h1>User Authentication</h1>
|
|
115
|
+
</header>
|
|
116
|
+
|
|
117
|
+
<nav data-graph-edges>
|
|
118
|
+
<section data-edge-type="blocked_by">
|
|
119
|
+
<h3>Blocked By:</h3>
|
|
120
|
+
<ul>
|
|
121
|
+
<li><a href="feature-002.html">Database Schema</a></li>
|
|
122
|
+
</ul>
|
|
123
|
+
</section>
|
|
124
|
+
</nav>
|
|
125
|
+
|
|
126
|
+
<section data-steps>
|
|
127
|
+
<h3>Steps</h3>
|
|
128
|
+
<ol>
|
|
129
|
+
<li data-completed="true">ā
Create auth routes</li>
|
|
130
|
+
<li data-completed="false">ā³ Add middleware</li>
|
|
131
|
+
</ol>
|
|
132
|
+
</section>
|
|
133
|
+
</article>
|
|
134
|
+
</body>
|
|
135
|
+
</html>
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Features
|
|
139
|
+
|
|
140
|
+
- **Zero dependencies** beyond `justhtml` and `pydantic`
|
|
141
|
+
- **CSS selector queries** - no new query language to learn
|
|
142
|
+
- **Version control friendly** - git diff works perfectly
|
|
143
|
+
- **Human readable** - open in any browser
|
|
144
|
+
- **AI agent optimized** - lightweight context generation
|
|
145
|
+
- **Graph algorithms** - BFS, shortest path, cycle detection, topological sort
|
|
146
|
+
|
|
147
|
+
## Comparison
|
|
148
|
+
|
|
149
|
+
| Feature | Neo4j | JSON | HtmlGraph |
|
|
150
|
+
|---------|-------|------|-----------|
|
|
151
|
+
| Setup | Docker + JVM | None | None |
|
|
152
|
+
| Query Language | Cypher | jq | CSS selectors |
|
|
153
|
+
| Human Readable | ā Browser needed | š” Text editor | ā
Any browser |
|
|
154
|
+
| Version Control | ā Binary | ā
JSON diff | ā
HTML diff |
|
|
155
|
+
| Visual UI | ā Separate tool | ā Build it | ā
Built-in |
|
|
156
|
+
| Graph Native | ā
| ā | ā
|
|
|
157
|
+
|
|
158
|
+
## Use Cases
|
|
159
|
+
|
|
160
|
+
1. **AI Agent Coordination** - Task tracking, dependencies, progress
|
|
161
|
+
2. **Knowledge Bases** - Linked notes with visual navigation
|
|
162
|
+
3. **Documentation** - Interconnected docs with search
|
|
163
|
+
4. **Task Management** - Todo lists with dependencies
|
|
164
|
+
|
|
165
|
+
## License
|
|
166
|
+
|
|
167
|
+
MIT
|
|
168
|
+
|
|
169
|
+
## Links
|
|
170
|
+
|
|
171
|
+
- [GitHub](https://github.com/Shakes-tzd/htmlgraph)
|
|
172
|
+
- [Documentation](https://github.com/Shakes-tzd/htmlgraph#readme)
|
|
173
|
+
- [Examples](https://github.com/Shakes-tzd/htmlgraph/tree/main/examples)
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
HtmlGraph Todo List Demo
|
|
4
|
+
|
|
5
|
+
Demonstrates basic HtmlGraph usage with a simple todo list.
|
|
6
|
+
Run this script from the examples/todo-list directory.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import sys
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
# Add src to path for development
|
|
13
|
+
sys.path.insert(0, str(Path(__file__).parent.parent.parent / "src" / "python"))
|
|
14
|
+
|
|
15
|
+
from htmlgraph import HtmlGraph, Node, Edge, Step
|
|
16
|
+
from htmlgraph.agents import AgentInterface
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def main():
|
|
20
|
+
"""Demonstrate HtmlGraph todo list operations."""
|
|
21
|
+
print("=" * 60)
|
|
22
|
+
print("HtmlGraph Todo List Demo")
|
|
23
|
+
print("'HTML is All You Need'")
|
|
24
|
+
print("=" * 60)
|
|
25
|
+
|
|
26
|
+
# Initialize graph from current directory
|
|
27
|
+
graph = HtmlGraph(".")
|
|
28
|
+
print(f"\nš Loaded {len(graph)} tasks from HTML files")
|
|
29
|
+
|
|
30
|
+
# Show stats
|
|
31
|
+
stats = graph.stats()
|
|
32
|
+
print(f"\nš Statistics:")
|
|
33
|
+
print(f" Total tasks: {stats['total']}")
|
|
34
|
+
print(f" Completion: {stats['completion_rate']}%")
|
|
35
|
+
print(f" By status: {stats['by_status']}")
|
|
36
|
+
|
|
37
|
+
# Query examples
|
|
38
|
+
print("\nš Query Examples:")
|
|
39
|
+
|
|
40
|
+
# Find blocked tasks
|
|
41
|
+
blocked = graph.query("[data-status='blocked']")
|
|
42
|
+
print(f"\n Blocked tasks ({len(blocked)}):")
|
|
43
|
+
for task in blocked:
|
|
44
|
+
print(f" - {task.id}: {task.title}")
|
|
45
|
+
|
|
46
|
+
# Find high priority tasks
|
|
47
|
+
high_priority = graph.query("[data-priority='high']")
|
|
48
|
+
print(f"\n High priority tasks ({len(high_priority)}):")
|
|
49
|
+
for task in high_priority:
|
|
50
|
+
print(f" - {task.id}: {task.title} [{task.status}]")
|
|
51
|
+
|
|
52
|
+
# Graph traversal
|
|
53
|
+
print("\nš Graph Traversal:")
|
|
54
|
+
|
|
55
|
+
# Find dependencies
|
|
56
|
+
deps = graph.transitive_deps("task-003", relationship="blocked_by")
|
|
57
|
+
print(f"\n task-003 depends on: {deps}")
|
|
58
|
+
|
|
59
|
+
# Find bottlenecks
|
|
60
|
+
bottlenecks = graph.find_bottlenecks(top_n=3)
|
|
61
|
+
print(f"\n Bottleneck tasks (blocking most others):")
|
|
62
|
+
for task_id, count in bottlenecks:
|
|
63
|
+
task = graph.get(task_id)
|
|
64
|
+
name = task.title if task else task_id
|
|
65
|
+
print(f" - {task_id}: {name} (blocks {count} others)")
|
|
66
|
+
|
|
67
|
+
# Agent interface demo
|
|
68
|
+
print("\nš¤ Agent Interface Demo:")
|
|
69
|
+
|
|
70
|
+
agent = AgentInterface(".", agent_id="demo-agent")
|
|
71
|
+
|
|
72
|
+
# Get summary
|
|
73
|
+
print(f"\n {agent.get_summary()}")
|
|
74
|
+
|
|
75
|
+
# Get next available task
|
|
76
|
+
next_task = agent.get_next_task()
|
|
77
|
+
if next_task:
|
|
78
|
+
print(f"\n Next available task:")
|
|
79
|
+
print(f" {agent.get_context(next_task.id)}")
|
|
80
|
+
|
|
81
|
+
# Create a new task programmatically
|
|
82
|
+
print("\n⨠Creating new task programmatically...")
|
|
83
|
+
|
|
84
|
+
new_task = Node(
|
|
85
|
+
id="task-005",
|
|
86
|
+
title="Write documentation",
|
|
87
|
+
type="task",
|
|
88
|
+
status="todo",
|
|
89
|
+
priority="medium",
|
|
90
|
+
content="<p>Create comprehensive documentation for HtmlGraph.</p>",
|
|
91
|
+
steps=[
|
|
92
|
+
Step(description="Write README.md"),
|
|
93
|
+
Step(description="Create API reference"),
|
|
94
|
+
Step(description="Add usage examples"),
|
|
95
|
+
],
|
|
96
|
+
edges={
|
|
97
|
+
"blocked_by": [Edge(target_id="task-002", title="Implement core models")]
|
|
98
|
+
}
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
# Save to HTML file
|
|
102
|
+
filepath = graph.add(new_task)
|
|
103
|
+
print(f" Created: {filepath}")
|
|
104
|
+
|
|
105
|
+
# Show the generated HTML
|
|
106
|
+
print(f"\n Generated HTML preview (first 500 chars):")
|
|
107
|
+
html_content = filepath.read_text()[:500]
|
|
108
|
+
print(f" {html_content}...")
|
|
109
|
+
|
|
110
|
+
# Generate context for AI agent
|
|
111
|
+
print("\nš AI Agent Context (lightweight ~50 tokens):")
|
|
112
|
+
print(new_task.to_context())
|
|
113
|
+
|
|
114
|
+
# Export as Mermaid diagram
|
|
115
|
+
print("\nš Mermaid Diagram:")
|
|
116
|
+
print(graph.to_mermaid(relationship="blocked_by"))
|
|
117
|
+
|
|
118
|
+
print("\n" + "=" * 60)
|
|
119
|
+
print("Demo complete! Check the generated HTML files.")
|
|
120
|
+
print("=" * 60)
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
if __name__ == "__main__":
|
|
124
|
+
main()
|