htmlgraph 0.20.1__py3-none-any.whl → 0.27.5__py3-none-any.whl

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.
Files changed (304) hide show
  1. htmlgraph/.htmlgraph/.session-warning-state.json +6 -0
  2. htmlgraph/.htmlgraph/agents.json +72 -0
  3. htmlgraph/.htmlgraph/htmlgraph.db +0 -0
  4. htmlgraph/__init__.py +51 -1
  5. htmlgraph/__init__.pyi +123 -0
  6. htmlgraph/agent_detection.py +26 -10
  7. htmlgraph/agent_registry.py +2 -1
  8. htmlgraph/analytics/__init__.py +8 -1
  9. htmlgraph/analytics/cli.py +86 -20
  10. htmlgraph/analytics/cost_analyzer.py +391 -0
  11. htmlgraph/analytics/cost_monitor.py +664 -0
  12. htmlgraph/analytics/cost_reporter.py +675 -0
  13. htmlgraph/analytics/cross_session.py +617 -0
  14. htmlgraph/analytics/dependency.py +10 -6
  15. htmlgraph/analytics/pattern_learning.py +771 -0
  16. htmlgraph/analytics/session_graph.py +707 -0
  17. htmlgraph/analytics/strategic/__init__.py +80 -0
  18. htmlgraph/analytics/strategic/cost_optimizer.py +611 -0
  19. htmlgraph/analytics/strategic/pattern_detector.py +876 -0
  20. htmlgraph/analytics/strategic/preference_manager.py +709 -0
  21. htmlgraph/analytics/strategic/suggestion_engine.py +747 -0
  22. htmlgraph/analytics/work_type.py +67 -27
  23. htmlgraph/analytics_index.py +53 -20
  24. htmlgraph/api/__init__.py +3 -0
  25. htmlgraph/api/cost_alerts_websocket.py +416 -0
  26. htmlgraph/api/main.py +2498 -0
  27. htmlgraph/api/static/htmx.min.js +1 -0
  28. htmlgraph/api/static/style-redesign.css +1344 -0
  29. htmlgraph/api/static/style.css +1079 -0
  30. htmlgraph/api/templates/dashboard-redesign.html +1366 -0
  31. htmlgraph/api/templates/dashboard.html +794 -0
  32. htmlgraph/api/templates/partials/activity-feed-hierarchical.html +326 -0
  33. htmlgraph/api/templates/partials/activity-feed.html +1100 -0
  34. htmlgraph/api/templates/partials/agents-redesign.html +317 -0
  35. htmlgraph/api/templates/partials/agents.html +317 -0
  36. htmlgraph/api/templates/partials/event-traces.html +373 -0
  37. htmlgraph/api/templates/partials/features-kanban-redesign.html +509 -0
  38. htmlgraph/api/templates/partials/features.html +578 -0
  39. htmlgraph/api/templates/partials/metrics-redesign.html +346 -0
  40. htmlgraph/api/templates/partials/metrics.html +346 -0
  41. htmlgraph/api/templates/partials/orchestration-redesign.html +443 -0
  42. htmlgraph/api/templates/partials/orchestration.html +198 -0
  43. htmlgraph/api/templates/partials/spawners.html +375 -0
  44. htmlgraph/api/templates/partials/work-items.html +613 -0
  45. htmlgraph/api/websocket.py +538 -0
  46. htmlgraph/archive/__init__.py +24 -0
  47. htmlgraph/archive/bloom.py +234 -0
  48. htmlgraph/archive/fts.py +297 -0
  49. htmlgraph/archive/manager.py +583 -0
  50. htmlgraph/archive/search.py +244 -0
  51. htmlgraph/atomic_ops.py +560 -0
  52. htmlgraph/attribute_index.py +2 -1
  53. htmlgraph/bounded_paths.py +539 -0
  54. htmlgraph/builders/base.py +57 -2
  55. htmlgraph/builders/bug.py +19 -3
  56. htmlgraph/builders/chore.py +19 -3
  57. htmlgraph/builders/epic.py +19 -3
  58. htmlgraph/builders/feature.py +27 -3
  59. htmlgraph/builders/insight.py +2 -1
  60. htmlgraph/builders/metric.py +2 -1
  61. htmlgraph/builders/pattern.py +2 -1
  62. htmlgraph/builders/phase.py +19 -3
  63. htmlgraph/builders/spike.py +29 -3
  64. htmlgraph/builders/track.py +42 -1
  65. htmlgraph/cigs/__init__.py +81 -0
  66. htmlgraph/cigs/autonomy.py +385 -0
  67. htmlgraph/cigs/cost.py +475 -0
  68. htmlgraph/cigs/messages_basic.py +472 -0
  69. htmlgraph/cigs/messaging.py +365 -0
  70. htmlgraph/cigs/models.py +771 -0
  71. htmlgraph/cigs/pattern_storage.py +427 -0
  72. htmlgraph/cigs/patterns.py +503 -0
  73. htmlgraph/cigs/posttool_analyzer.py +234 -0
  74. htmlgraph/cigs/reporter.py +818 -0
  75. htmlgraph/cigs/tracker.py +317 -0
  76. htmlgraph/cli/.htmlgraph/.session-warning-state.json +6 -0
  77. htmlgraph/cli/.htmlgraph/agents.json +72 -0
  78. htmlgraph/cli/.htmlgraph/htmlgraph.db +0 -0
  79. htmlgraph/cli/__init__.py +42 -0
  80. htmlgraph/cli/__main__.py +6 -0
  81. htmlgraph/cli/analytics.py +1424 -0
  82. htmlgraph/cli/base.py +685 -0
  83. htmlgraph/cli/constants.py +206 -0
  84. htmlgraph/cli/core.py +954 -0
  85. htmlgraph/cli/main.py +147 -0
  86. htmlgraph/cli/models.py +475 -0
  87. htmlgraph/cli/templates/__init__.py +1 -0
  88. htmlgraph/cli/templates/cost_dashboard.py +399 -0
  89. htmlgraph/cli/work/__init__.py +239 -0
  90. htmlgraph/cli/work/browse.py +115 -0
  91. htmlgraph/cli/work/features.py +568 -0
  92. htmlgraph/cli/work/orchestration.py +676 -0
  93. htmlgraph/cli/work/report.py +728 -0
  94. htmlgraph/cli/work/sessions.py +466 -0
  95. htmlgraph/cli/work/snapshot.py +559 -0
  96. htmlgraph/cli/work/tracks.py +486 -0
  97. htmlgraph/cli_commands/__init__.py +1 -0
  98. htmlgraph/cli_commands/feature.py +195 -0
  99. htmlgraph/cli_framework.py +115 -0
  100. htmlgraph/collections/__init__.py +2 -0
  101. htmlgraph/collections/base.py +197 -14
  102. htmlgraph/collections/bug.py +2 -1
  103. htmlgraph/collections/chore.py +2 -1
  104. htmlgraph/collections/epic.py +2 -1
  105. htmlgraph/collections/feature.py +2 -1
  106. htmlgraph/collections/insight.py +2 -1
  107. htmlgraph/collections/metric.py +2 -1
  108. htmlgraph/collections/pattern.py +2 -1
  109. htmlgraph/collections/phase.py +2 -1
  110. htmlgraph/collections/session.py +194 -0
  111. htmlgraph/collections/spike.py +13 -2
  112. htmlgraph/collections/task_delegation.py +241 -0
  113. htmlgraph/collections/todo.py +14 -1
  114. htmlgraph/collections/traces.py +487 -0
  115. htmlgraph/config/cost_models.json +56 -0
  116. htmlgraph/config.py +190 -0
  117. htmlgraph/context_analytics.py +2 -1
  118. htmlgraph/converter.py +116 -7
  119. htmlgraph/cost_analysis/__init__.py +5 -0
  120. htmlgraph/cost_analysis/analyzer.py +438 -0
  121. htmlgraph/dashboard.html +2246 -248
  122. htmlgraph/dashboard.html.backup +6592 -0
  123. htmlgraph/dashboard.html.bak +7181 -0
  124. htmlgraph/dashboard.html.bak2 +7231 -0
  125. htmlgraph/dashboard.html.bak3 +7232 -0
  126. htmlgraph/db/__init__.py +38 -0
  127. htmlgraph/db/queries.py +790 -0
  128. htmlgraph/db/schema.py +1788 -0
  129. htmlgraph/decorators.py +317 -0
  130. htmlgraph/dependency_models.py +2 -1
  131. htmlgraph/deploy.py +26 -27
  132. htmlgraph/docs/API_REFERENCE.md +841 -0
  133. htmlgraph/docs/HTTP_API.md +750 -0
  134. htmlgraph/docs/INTEGRATION_GUIDE.md +752 -0
  135. htmlgraph/docs/ORCHESTRATION_PATTERNS.md +717 -0
  136. htmlgraph/docs/README.md +532 -0
  137. htmlgraph/docs/__init__.py +77 -0
  138. htmlgraph/docs/docs_version.py +55 -0
  139. htmlgraph/docs/metadata.py +93 -0
  140. htmlgraph/docs/migrations.py +232 -0
  141. htmlgraph/docs/template_engine.py +143 -0
  142. htmlgraph/docs/templates/_sections/cli_reference.md.j2 +52 -0
  143. htmlgraph/docs/templates/_sections/core_concepts.md.j2 +29 -0
  144. htmlgraph/docs/templates/_sections/sdk_basics.md.j2 +69 -0
  145. htmlgraph/docs/templates/base_agents.md.j2 +78 -0
  146. htmlgraph/docs/templates/example_user_override.md.j2 +47 -0
  147. htmlgraph/docs/version_check.py +163 -0
  148. htmlgraph/edge_index.py +2 -1
  149. htmlgraph/error_handler.py +544 -0
  150. htmlgraph/event_log.py +86 -37
  151. htmlgraph/event_migration.py +2 -1
  152. htmlgraph/file_watcher.py +12 -8
  153. htmlgraph/find_api.py +2 -1
  154. htmlgraph/git_events.py +67 -9
  155. htmlgraph/hooks/.htmlgraph/.session-warning-state.json +6 -0
  156. htmlgraph/hooks/.htmlgraph/agents.json +72 -0
  157. htmlgraph/hooks/.htmlgraph/index.sqlite +0 -0
  158. htmlgraph/hooks/__init__.py +8 -0
  159. htmlgraph/hooks/bootstrap.py +169 -0
  160. htmlgraph/hooks/cigs_pretool_enforcer.py +354 -0
  161. htmlgraph/hooks/concurrent_sessions.py +208 -0
  162. htmlgraph/hooks/context.py +350 -0
  163. htmlgraph/hooks/drift_handler.py +525 -0
  164. htmlgraph/hooks/event_tracker.py +790 -99
  165. htmlgraph/hooks/git_commands.py +175 -0
  166. htmlgraph/hooks/installer.py +5 -1
  167. htmlgraph/hooks/orchestrator.py +327 -76
  168. htmlgraph/hooks/orchestrator_reflector.py +31 -4
  169. htmlgraph/hooks/post_tool_use_failure.py +32 -7
  170. htmlgraph/hooks/post_tool_use_handler.py +257 -0
  171. htmlgraph/hooks/posttooluse.py +92 -19
  172. htmlgraph/hooks/pretooluse.py +527 -7
  173. htmlgraph/hooks/prompt_analyzer.py +637 -0
  174. htmlgraph/hooks/session_handler.py +668 -0
  175. htmlgraph/hooks/session_summary.py +395 -0
  176. htmlgraph/hooks/state_manager.py +504 -0
  177. htmlgraph/hooks/subagent_detection.py +202 -0
  178. htmlgraph/hooks/subagent_stop.py +369 -0
  179. htmlgraph/hooks/task_enforcer.py +99 -4
  180. htmlgraph/hooks/validator.py +212 -91
  181. htmlgraph/ids.py +2 -1
  182. htmlgraph/learning.py +125 -100
  183. htmlgraph/mcp_server.py +2 -1
  184. htmlgraph/models.py +217 -18
  185. htmlgraph/operations/README.md +62 -0
  186. htmlgraph/operations/__init__.py +79 -0
  187. htmlgraph/operations/analytics.py +339 -0
  188. htmlgraph/operations/bootstrap.py +289 -0
  189. htmlgraph/operations/events.py +244 -0
  190. htmlgraph/operations/fastapi_server.py +231 -0
  191. htmlgraph/operations/hooks.py +350 -0
  192. htmlgraph/operations/initialization.py +597 -0
  193. htmlgraph/operations/initialization.py.backup +228 -0
  194. htmlgraph/operations/server.py +303 -0
  195. htmlgraph/orchestration/__init__.py +58 -0
  196. htmlgraph/orchestration/claude_launcher.py +179 -0
  197. htmlgraph/orchestration/command_builder.py +72 -0
  198. htmlgraph/orchestration/headless_spawner.py +281 -0
  199. htmlgraph/orchestration/live_events.py +377 -0
  200. htmlgraph/orchestration/model_selection.py +327 -0
  201. htmlgraph/orchestration/plugin_manager.py +140 -0
  202. htmlgraph/orchestration/prompts.py +137 -0
  203. htmlgraph/orchestration/spawner_event_tracker.py +383 -0
  204. htmlgraph/orchestration/spawners/__init__.py +16 -0
  205. htmlgraph/orchestration/spawners/base.py +194 -0
  206. htmlgraph/orchestration/spawners/claude.py +173 -0
  207. htmlgraph/orchestration/spawners/codex.py +435 -0
  208. htmlgraph/orchestration/spawners/copilot.py +294 -0
  209. htmlgraph/orchestration/spawners/gemini.py +471 -0
  210. htmlgraph/orchestration/subprocess_runner.py +36 -0
  211. htmlgraph/{orchestration.py → orchestration/task_coordination.py} +16 -8
  212. htmlgraph/orchestration.md +563 -0
  213. htmlgraph/orchestrator-system-prompt-optimized.txt +863 -0
  214. htmlgraph/orchestrator.py +2 -1
  215. htmlgraph/orchestrator_config.py +357 -0
  216. htmlgraph/orchestrator_mode.py +115 -4
  217. htmlgraph/parallel.py +2 -1
  218. htmlgraph/parser.py +86 -6
  219. htmlgraph/path_query.py +608 -0
  220. htmlgraph/pattern_matcher.py +636 -0
  221. htmlgraph/pydantic_models.py +476 -0
  222. htmlgraph/quality_gates.py +350 -0
  223. htmlgraph/query_builder.py +2 -1
  224. htmlgraph/query_composer.py +509 -0
  225. htmlgraph/reflection.py +443 -0
  226. htmlgraph/refs.py +344 -0
  227. htmlgraph/repo_hash.py +512 -0
  228. htmlgraph/repositories/__init__.py +292 -0
  229. htmlgraph/repositories/analytics_repository.py +455 -0
  230. htmlgraph/repositories/analytics_repository_standard.py +628 -0
  231. htmlgraph/repositories/feature_repository.py +581 -0
  232. htmlgraph/repositories/feature_repository_htmlfile.py +668 -0
  233. htmlgraph/repositories/feature_repository_memory.py +607 -0
  234. htmlgraph/repositories/feature_repository_sqlite.py +858 -0
  235. htmlgraph/repositories/filter_service.py +620 -0
  236. htmlgraph/repositories/filter_service_standard.py +445 -0
  237. htmlgraph/repositories/shared_cache.py +621 -0
  238. htmlgraph/repositories/shared_cache_memory.py +395 -0
  239. htmlgraph/repositories/track_repository.py +552 -0
  240. htmlgraph/repositories/track_repository_htmlfile.py +619 -0
  241. htmlgraph/repositories/track_repository_memory.py +508 -0
  242. htmlgraph/repositories/track_repository_sqlite.py +711 -0
  243. htmlgraph/sdk/__init__.py +398 -0
  244. htmlgraph/sdk/__init__.pyi +14 -0
  245. htmlgraph/sdk/analytics/__init__.py +19 -0
  246. htmlgraph/sdk/analytics/engine.py +155 -0
  247. htmlgraph/sdk/analytics/helpers.py +178 -0
  248. htmlgraph/sdk/analytics/registry.py +109 -0
  249. htmlgraph/sdk/base.py +484 -0
  250. htmlgraph/sdk/constants.py +216 -0
  251. htmlgraph/sdk/core.pyi +308 -0
  252. htmlgraph/sdk/discovery.py +120 -0
  253. htmlgraph/sdk/help/__init__.py +12 -0
  254. htmlgraph/sdk/help/mixin.py +699 -0
  255. htmlgraph/sdk/mixins/__init__.py +15 -0
  256. htmlgraph/sdk/mixins/attribution.py +113 -0
  257. htmlgraph/sdk/mixins/mixin.py +410 -0
  258. htmlgraph/sdk/operations/__init__.py +12 -0
  259. htmlgraph/sdk/operations/mixin.py +427 -0
  260. htmlgraph/sdk/orchestration/__init__.py +17 -0
  261. htmlgraph/sdk/orchestration/coordinator.py +203 -0
  262. htmlgraph/sdk/orchestration/spawner.py +204 -0
  263. htmlgraph/sdk/planning/__init__.py +19 -0
  264. htmlgraph/sdk/planning/bottlenecks.py +93 -0
  265. htmlgraph/sdk/planning/mixin.py +211 -0
  266. htmlgraph/sdk/planning/parallel.py +186 -0
  267. htmlgraph/sdk/planning/queue.py +210 -0
  268. htmlgraph/sdk/planning/recommendations.py +87 -0
  269. htmlgraph/sdk/planning/smart_planning.py +319 -0
  270. htmlgraph/sdk/session/__init__.py +19 -0
  271. htmlgraph/sdk/session/continuity.py +57 -0
  272. htmlgraph/sdk/session/handoff.py +110 -0
  273. htmlgraph/sdk/session/info.py +309 -0
  274. htmlgraph/sdk/session/manager.py +103 -0
  275. htmlgraph/sdk/strategic/__init__.py +26 -0
  276. htmlgraph/sdk/strategic/mixin.py +563 -0
  277. htmlgraph/server.py +295 -107
  278. htmlgraph/session_hooks.py +300 -0
  279. htmlgraph/session_manager.py +285 -3
  280. htmlgraph/session_registry.py +587 -0
  281. htmlgraph/session_state.py +436 -0
  282. htmlgraph/session_warning.py +2 -1
  283. htmlgraph/sessions/__init__.py +23 -0
  284. htmlgraph/sessions/handoff.py +756 -0
  285. htmlgraph/system_prompts.py +450 -0
  286. htmlgraph/templates/orchestration-view.html +350 -0
  287. htmlgraph/track_builder.py +33 -1
  288. htmlgraph/track_manager.py +38 -0
  289. htmlgraph/transcript.py +18 -5
  290. htmlgraph/validation.py +115 -0
  291. htmlgraph/watch.py +2 -1
  292. htmlgraph/work_type_utils.py +2 -1
  293. {htmlgraph-0.20.1.data → htmlgraph-0.27.5.data}/data/htmlgraph/dashboard.html +2246 -248
  294. {htmlgraph-0.20.1.dist-info → htmlgraph-0.27.5.dist-info}/METADATA +95 -64
  295. htmlgraph-0.27.5.dist-info/RECORD +337 -0
  296. {htmlgraph-0.20.1.dist-info → htmlgraph-0.27.5.dist-info}/entry_points.txt +1 -1
  297. htmlgraph/cli.py +0 -4839
  298. htmlgraph/sdk.py +0 -2359
  299. htmlgraph-0.20.1.dist-info/RECORD +0 -118
  300. {htmlgraph-0.20.1.data → htmlgraph-0.27.5.data}/data/htmlgraph/styles.css +0 -0
  301. {htmlgraph-0.20.1.data → htmlgraph-0.27.5.data}/data/htmlgraph/templates/AGENTS.md.template +0 -0
  302. {htmlgraph-0.20.1.data → htmlgraph-0.27.5.data}/data/htmlgraph/templates/CLAUDE.md.template +0 -0
  303. {htmlgraph-0.20.1.data → htmlgraph-0.27.5.data}/data/htmlgraph/templates/GEMINI.md.template +0 -0
  304. {htmlgraph-0.20.1.dist-info → htmlgraph-0.27.5.dist-info}/WHEEL +0 -0
@@ -0,0 +1,752 @@
1
+ # HtmlGraph Integration Guide
2
+
3
+ Quick start guide to integrate HtmlGraph into your project. Get up and running in 5 minutes.
4
+
5
+ ## Table of Contents
6
+
7
+ 1. [Installation](#installation)
8
+ 2. [Quick Start](#quick-start)
9
+ 3. [Common Patterns](#common-patterns)
10
+ 4. [Integration Patterns](#integration-patterns)
11
+ 5. [Troubleshooting](#troubleshooting)
12
+
13
+ ---
14
+
15
+ ## Installation
16
+
17
+ ### Via pip
18
+
19
+ ```bash
20
+ pip install htmlgraph
21
+ ```
22
+
23
+ ### Via uv (Recommended)
24
+
25
+ ```bash
26
+ uv pip install htmlgraph
27
+ ```
28
+
29
+ ### Development Installation
30
+
31
+ ```bash
32
+ git clone https://github.com/anthropics/htmlgraph.git
33
+ cd htmlgraph
34
+ uv pip install -e .
35
+ ```
36
+
37
+ ### Verify Installation
38
+
39
+ ```bash
40
+ python -c "from htmlgraph import SDK; print('Installation successful!')"
41
+ ```
42
+
43
+ ---
44
+
45
+ ## Quick Start
46
+
47
+ ### 5-Minute Setup
48
+
49
+ **Step 1: Initialize HtmlGraph**
50
+
51
+ ```bash
52
+ # Create .htmlgraph directory
53
+ mkdir -p .htmlgraph/{features,bugs,spikes}
54
+ ```
55
+
56
+ **Step 2: First Script**
57
+
58
+ ```python
59
+ from htmlgraph import SDK
60
+
61
+ # Initialize SDK (auto-discovers .htmlgraph)
62
+ sdk = SDK(agent="claude")
63
+
64
+ # Create a feature
65
+ feature = sdk.features.create("User Authentication") \
66
+ .set_priority("high") \
67
+ .add_steps(["Design", "Implement", "Test"]) \
68
+ .save()
69
+
70
+ print(f"Created feature: {feature.id}")
71
+
72
+ # Query features
73
+ features = sdk.features.all()
74
+ print(f"Total features: {len(features)}")
75
+
76
+ # Mark as done
77
+ sdk.features.mark_done([feature.id])
78
+ ```
79
+
80
+ **Step 3: Start Server (Optional)**
81
+
82
+ ```bash
83
+ htmlgraph serve --port 8080
84
+ ```
85
+
86
+ Then visit: http://localhost:8080
87
+
88
+ ---
89
+
90
+ ## Common Patterns
91
+
92
+ ### Creating Work Items
93
+
94
+ ```python
95
+ from htmlgraph import SDK
96
+
97
+ sdk = SDK(agent="claude")
98
+
99
+ # Feature with full details
100
+ feature = sdk.features.create("User Authentication System") \
101
+ .set_priority("high") \
102
+ .set_status("todo") \
103
+ .set_description("Implement JWT-based authentication") \
104
+ .add_steps([
105
+ "Design schema",
106
+ "Implement API",
107
+ "Add tests",
108
+ "Deploy"
109
+ ]) \
110
+ .save()
111
+
112
+ # Bug report
113
+ bug = sdk.bugs.create("Login button not responsive") \
114
+ .set_priority("high") \
115
+ .set_description("Fix CSS media query for mobile") \
116
+ .save()
117
+
118
+ # Investigation spike
119
+ spike = sdk.spikes.create("Investigate caching strategies") \
120
+ .save()
121
+
122
+ # Maintenance chore
123
+ chore = sdk.chores.create("Update dependencies") \
124
+ .save()
125
+ ```
126
+
127
+ ---
128
+
129
+ ### Querying Work
130
+
131
+ ```python
132
+ # Get single item
133
+ feature = sdk.features.get("feat-12345")
134
+
135
+ # Get all items
136
+ all_features = sdk.features.all()
137
+
138
+ # Filter by status
139
+ todos = sdk.features.where(status="todo")
140
+
141
+ # Multiple filters
142
+ high_priority_bugs = sdk.bugs.where(
143
+ status="todo",
144
+ priority="high"
145
+ )
146
+
147
+ # Complex queries
148
+ from htmlgraph import HtmlGraph, QueryBuilder
149
+
150
+ graph = HtmlGraph("features/")
151
+ results = graph.query_builder() \
152
+ .where("status", "todo") \
153
+ .and_("priority").in_(["high", "critical"]) \
154
+ .execute()
155
+ ```
156
+
157
+ ---
158
+
159
+ ### Updating Work
160
+
161
+ ```python
162
+ # Update single item
163
+ with sdk.features.edit(feature.id) as f:
164
+ f.status = "in-progress"
165
+ f.priority = "critical"
166
+ # Auto-saves on context exit
167
+
168
+ # Batch update
169
+ sdk.features.batch_update({
170
+ feature.id: {"status": "done"},
171
+ other_id: {"priority": "low"}
172
+ })
173
+
174
+ # Mark multiple as done
175
+ sdk.features.mark_done([feat1, feat2, feat3])
176
+ ```
177
+
178
+ ---
179
+
180
+ ### Work Item Relationships
181
+
182
+ ```python
183
+ # Create blocking relationships
184
+ feature_a = sdk.features.create("Feature A").save()
185
+ feature_b = sdk.features.create("Feature B") \
186
+ .blocks(feature_a.id) \
187
+ .save()
188
+
189
+ # Feature A is blocked by Feature B
190
+ feature_b = sdk.features.create("Feature B") \
191
+ .blocked_by(feature_a.id) \
192
+ .save()
193
+ ```
194
+
195
+ ---
196
+
197
+ ### Analytics
198
+
199
+ ```python
200
+ # Work distribution
201
+ distribution = sdk.analytics.get_work_type_distribution()
202
+ # Returns: {"feature": 25, "spike": 8, "bug": 12}
203
+
204
+ # Find bottlenecks
205
+ bottlenecks = sdk.dep_analytics.find_bottlenecks(top_n=5)
206
+ for item in bottlenecks:
207
+ print(f"{item['title']} blocks {item['blocking_count']} items")
208
+
209
+ # Get parallelizable work
210
+ parallel = sdk.dep_analytics.get_parallel_work(max_agents=3)
211
+ for agent, tasks in parallel.items():
212
+ print(f"{agent}: {len(tasks)} tasks")
213
+ ```
214
+
215
+ ---
216
+
217
+ ## Integration Patterns
218
+
219
+ ### Pattern 1: Project Initialization
220
+
221
+ Auto-initialize HtmlGraph in your project:
222
+
223
+ ```python
224
+ # setup.py
225
+ from htmlgraph import SDK
226
+ from pathlib import Path
227
+
228
+ def initialize_htmlgraph():
229
+ """Initialize HtmlGraph on project startup."""
230
+ htmlgraph_dir = Path(".htmlgraph")
231
+
232
+ if not htmlgraph_dir.exists():
233
+ print("Initializing HtmlGraph...")
234
+ (htmlgraph_dir / "features").mkdir(parents=True, exist_ok=True)
235
+ (htmlgraph_dir / "bugs").mkdir(exist_ok=True)
236
+ (htmlgraph_dir / "spikes").mkdir(exist_ok=True)
237
+ print("HtmlGraph initialized!")
238
+
239
+ return SDK(agent="system")
240
+
241
+ sdk = initialize_htmlgraph()
242
+ ```
243
+
244
+ ---
245
+
246
+ ### Pattern 2: Context Manager for Sessions
247
+
248
+ ```python
249
+ from htmlgraph import SDK
250
+ from contextlib import contextmanager
251
+
252
+ @contextmanager
253
+ def work_session(agent_name, feature_id):
254
+ """Context manager for working on a feature."""
255
+ sdk = SDK(agent=agent_name)
256
+
257
+ feature = sdk.features.get(feature_id)
258
+ if not feature:
259
+ raise ValueError(f"Feature {feature_id} not found")
260
+
261
+ # Start work
262
+ with sdk.features.edit(feature_id) as f:
263
+ f.status = "in-progress"
264
+ yield f
265
+
266
+ # Automatically save progress on exit
267
+ f.status = "done"
268
+ print(f"Completed: {f.title}")
269
+
270
+ # Usage
271
+ with work_session("claude", "feat-123") as feature:
272
+ print(f"Working on: {feature.title}")
273
+ # Your work here...
274
+ ```
275
+
276
+ ---
277
+
278
+ ### Pattern 3: Logging & Auditing
279
+
280
+ ```python
281
+ from htmlgraph import SDK
282
+ from datetime import datetime
283
+
284
+ sdk = SDK(agent="logger")
285
+
286
+ def log_action(action, item_id, details):
287
+ """Log all actions to spikes for audit trail."""
288
+ spike = sdk.spikes.create(f"{action}: {item_id}") \
289
+ .set_description(f"""
290
+ Action: {action}
291
+ Item: {item_id}
292
+ Timestamp: {datetime.now().isoformat()}
293
+ Details: {details}
294
+ """) \
295
+ .save()
296
+
297
+ return spike.id
298
+
299
+ # Usage
300
+ log_action("FEATURE_CREATED", "feat-123", "Created by deploy script")
301
+ log_action("BUG_FIXED", "bug-456", "Applied security patch")
302
+ ```
303
+
304
+ ---
305
+
306
+ ### Pattern 4: Status Monitoring
307
+
308
+ ```python
309
+ from htmlgraph import SDK
310
+
311
+ sdk = SDK(agent="monitor")
312
+
313
+ def get_project_health():
314
+ """Get overall project health metrics."""
315
+ features = sdk.features.all()
316
+
317
+ stats = {
318
+ "total": len(features),
319
+ "completed": len([f for f in features if f.status == "done"]),
320
+ "in_progress": len([f for f in features if f.status == "in-progress"]),
321
+ "blocked": len([f for f in features if f.status == "blocked"]),
322
+ "todo": len([f for f in features if f.status == "todo"]),
323
+ }
324
+
325
+ # Calculate completion percentage
326
+ if stats["total"] > 0:
327
+ stats["completion_percent"] = (
328
+ stats["completed"] / stats["total"] * 100
329
+ )
330
+
331
+ return stats
332
+
333
+ # Usage
334
+ health = get_project_health()
335
+ print(f"Project {health['completion_percent']:.1f}% complete")
336
+ print(f"In progress: {health['in_progress']}")
337
+ print(f"Blocked: {health['blocked']}")
338
+ ```
339
+
340
+ ---
341
+
342
+ ### Pattern 5: Task Delegation
343
+
344
+ ```python
345
+ from htmlgraph import SDK, delegate_with_id
346
+
347
+ sdk = SDK(agent="orchestrator")
348
+
349
+ def delegate_feature_work(feature_id, engineer):
350
+ """Delegate feature implementation to engineer."""
351
+
352
+ feature = sdk.features.get(feature_id)
353
+ if not feature:
354
+ raise ValueError(f"Feature {feature_id} not found")
355
+
356
+ # Create delegation
357
+ task_id = delegate_with_id(
358
+ prompt=f"""
359
+ Implement this feature:
360
+
361
+ Title: {feature.title}
362
+ Description: {feature.content}
363
+ Steps: {[s.description for s in feature.steps]}
364
+ """,
365
+ agent=engineer,
366
+ task_id=f"impl-{feature_id}"
367
+ )
368
+
369
+ # Track delegation
370
+ with sdk.features.edit(feature_id) as f:
371
+ f.status = "in-progress"
372
+ f.assigned_agent = engineer
373
+
374
+ return task_id
375
+
376
+ # Usage
377
+ task_id = delegate_feature_work("feat-123", "code-generator")
378
+ ```
379
+
380
+ ---
381
+
382
+ ### Pattern 6: Batch Import
383
+
384
+ ```python
385
+ from htmlgraph import SDK
386
+
387
+ sdk = SDK(agent="importer")
388
+
389
+ def import_features_from_csv(csv_file):
390
+ """Import features from CSV file."""
391
+
392
+ import csv
393
+
394
+ imported = []
395
+ failed = []
396
+
397
+ with open(csv_file) as f:
398
+ reader = csv.DictReader(f)
399
+
400
+ for row in reader:
401
+ try:
402
+ feature = sdk.features.create(row["title"]) \
403
+ .set_priority(row.get("priority", "medium")) \
404
+ .set_description(row.get("description", "")) \
405
+ .save()
406
+
407
+ imported.append(feature.id)
408
+ except Exception as e:
409
+ failed.append((row["title"], str(e)))
410
+
411
+ return {
412
+ "imported": len(imported),
413
+ "failed": len(failed),
414
+ "feature_ids": imported,
415
+ "errors": failed
416
+ }
417
+
418
+ # Usage
419
+ result = import_features_from_csv("features.csv")
420
+ print(f"Imported {result['imported']}, Failed {result['failed']}")
421
+ ```
422
+
423
+ ---
424
+
425
+ ### Pattern 7: CI/CD Integration
426
+
427
+ ```python
428
+ # deploy.py
429
+ from htmlgraph import SDK
430
+
431
+ def pre_deploy_check():
432
+ """Check project health before deployment."""
433
+
434
+ sdk = SDK(agent="ci-cd")
435
+
436
+ # Get blockers
437
+ blocked = sdk.features.where(status="blocked")
438
+ if blocked:
439
+ print(f"ERROR: {len(blocked)} blocked features")
440
+ for f in blocked:
441
+ print(f" - {f.title}")
442
+ return False
443
+
444
+ # Get work in progress
445
+ in_progress = sdk.features.where(status="in-progress")
446
+ if in_progress:
447
+ print(f"WARNING: {len(in_progress)} features still in progress")
448
+
449
+ # Check for high-priority bugs
450
+ critical_bugs = sdk.bugs.where(
451
+ status="todo",
452
+ priority="critical"
453
+ )
454
+ if critical_bugs:
455
+ print(f"ERROR: {len(critical_bugs)} critical bugs")
456
+ return False
457
+
458
+ return True
459
+
460
+ # Usage in CI/CD pipeline
461
+ if __name__ == "__main__":
462
+ if pre_deploy_check():
463
+ print("OK to deploy")
464
+ else:
465
+ print("Deployment blocked")
466
+ exit(1)
467
+ ```
468
+
469
+ ---
470
+
471
+ ### Pattern 8: Metrics Collection
472
+
473
+ ```python
474
+ from htmlgraph import SDK
475
+ from datetime import datetime, timedelta
476
+
477
+ sdk = SDK(agent="metrics")
478
+
479
+ def collect_metrics(days=7):
480
+ """Collect project metrics for the last N days."""
481
+
482
+ cutoff = datetime.now() - timedelta(days=days)
483
+ features = sdk.features.all()
484
+
485
+ recent_features = [
486
+ f for f in features
487
+ if datetime.fromisoformat(f.created_at) > cutoff
488
+ ]
489
+
490
+ metrics = {
491
+ "period_days": days,
492
+ "features_created": len(recent_features),
493
+ "features_completed": len([
494
+ f for f in recent_features if f.status == "done"
495
+ ]),
496
+ "average_completion_rate": len([
497
+ f for f in recent_features if f.status == "done"
498
+ ]) / len(recent_features) if recent_features else 0,
499
+ "bottlenecks": sdk.dep_analytics.find_bottlenecks(top_n=3),
500
+ }
501
+
502
+ return metrics
503
+
504
+ # Usage
505
+ metrics = collect_metrics(days=7)
506
+ print(f"Features created: {metrics['features_created']}")
507
+ print(f"Features completed: {metrics['features_completed']}")
508
+ print(f"Completion rate: {metrics['average_completion_rate']:.1%}")
509
+ ```
510
+
511
+ ---
512
+
513
+ ## Troubleshooting
514
+
515
+ ### Issue: "Agent identifier is required"
516
+
517
+ **Cause:** No agent specified when creating SDK
518
+
519
+ **Solution:**
520
+ ```python
521
+ # ❌ Wrong
522
+ sdk = SDK()
523
+
524
+ # ✅ Correct
525
+ sdk = SDK(agent="claude")
526
+ ```
527
+
528
+ ---
529
+
530
+ ### Issue: ".htmlgraph directory not found"
531
+
532
+ **Cause:** Directory structure not created
533
+
534
+ **Solution:**
535
+ ```python
536
+ from pathlib import Path
537
+
538
+ # Create directory structure
539
+ for subdir in ["features", "bugs", "spikes", "chores"]:
540
+ Path(f".htmlgraph/{subdir}").mkdir(parents=True, exist_ok=True)
541
+
542
+ sdk = SDK(agent="claude")
543
+ ```
544
+
545
+ ---
546
+
547
+ ### Issue: "NodeNotFoundError when editing"
548
+
549
+ **Cause:** Item ID doesn't exist
550
+
551
+ **Solution:**
552
+ ```python
553
+ from htmlgraph.exceptions import NodeNotFoundError
554
+
555
+ try:
556
+ with sdk.features.edit("feat-missing") as f:
557
+ f.status = "done"
558
+ except NodeNotFoundError:
559
+ print("Feature not found - creating new one")
560
+ feature = sdk.features.create("New Feature").save()
561
+ ```
562
+
563
+ ---
564
+
565
+ ### Issue: Empty results from queries
566
+
567
+ **Cause:** Wrong query syntax or no matching items
568
+
569
+ **Solution:**
570
+ ```python
571
+ # Check what's available
572
+ all_items = sdk.features.all()
573
+ print(f"Total items: {len(all_items)}")
574
+
575
+ # Print available statuses
576
+ statuses = set(f.status for f in all_items)
577
+ print(f"Available statuses: {statuses}")
578
+
579
+ # Query correctly
580
+ todos = sdk.features.where(status="todo")
581
+ print(f"Found {len(todos)} todos")
582
+ ```
583
+
584
+ ---
585
+
586
+ ### Issue: Slow queries
587
+
588
+ **Cause:** Large graph or complex queries
589
+
590
+ **Solution:**
591
+ ```python
592
+ # Use QueryBuilder for complex queries (more efficient)
593
+ from htmlgraph import HtmlGraph
594
+
595
+ graph = HtmlGraph("features/")
596
+ results = graph.query_builder() \
597
+ .where("priority", "high") \
598
+ .and_("status").in_(["todo", "in-progress"]) \
599
+ .execute()
600
+
601
+ # Or filter in Python (for small datasets)
602
+ results = [
603
+ f for f in sdk.features.all()
604
+ if f.priority == "high" and f.status != "done"
605
+ ]
606
+ ```
607
+
608
+ ---
609
+
610
+ ### Issue: Permission errors
611
+
612
+ **Cause:** Directory permission issues
613
+
614
+ **Solution:**
615
+ ```bash
616
+ # Check permissions
617
+ ls -la .htmlgraph/
618
+ chmod -R 755 .htmlgraph/
619
+
620
+ # Or create with proper permissions
621
+ mkdir -p .htmlgraph/{features,bugs,spikes}
622
+ chmod 755 .htmlgraph
623
+ chmod 755 .htmlgraph/*
624
+ ```
625
+
626
+ ---
627
+
628
+ ## Next Steps
629
+
630
+ 1. **Read the full API reference** - [API_REFERENCE.md](API_REFERENCE.md)
631
+ 2. **Explore HTTP API** - [HTTP_API.md](HTTP_API.md)
632
+ 3. **Learn orchestration patterns** - [ORCHESTRATION_PATTERNS.md](ORCHESTRATION_PATTERNS.md)
633
+ 4. **Join the community** - GitHub discussions
634
+ 5. **Report issues** - GitHub issues
635
+
636
+ ---
637
+
638
+ ## Complete Example Application
639
+
640
+ ```python
641
+ """
642
+ Complete example: Project management dashboard
643
+ """
644
+
645
+ from htmlgraph import SDK
646
+ from datetime import datetime
647
+
648
+ class ProjectManager:
649
+ def __init__(self, agent_name):
650
+ self.sdk = SDK(agent=agent_name)
651
+ self.initialize()
652
+
653
+ def initialize(self):
654
+ """Ensure .htmlgraph structure exists."""
655
+ from pathlib import Path
656
+ for subdir in ["features", "bugs", "spikes"]:
657
+ (Path(".htmlgraph") / subdir).mkdir(parents=True, exist_ok=True)
658
+
659
+ def create_feature(self, title, priority="medium", steps=None):
660
+ """Create a new feature."""
661
+ builder = self.sdk.features.create(title).set_priority(priority)
662
+ if steps:
663
+ builder.add_steps(steps)
664
+ return builder.save()
665
+
666
+ def create_bug(self, title, severity="medium"):
667
+ """Create a bug report."""
668
+ return self.sdk.bugs.create(title) \
669
+ .set_priority(severity) \
670
+ .save()
671
+
672
+ def get_status(self):
673
+ """Get project status."""
674
+ features = self.sdk.features.all()
675
+ bugs = self.sdk.bugs.all()
676
+
677
+ return {
678
+ "features": {
679
+ "total": len(features),
680
+ "done": len([f for f in features if f.status == "done"]),
681
+ "in_progress": len([f for f in features if f.status == "in-progress"]),
682
+ "blocked": len([f for f in features if f.status == "blocked"]),
683
+ },
684
+ "bugs": {
685
+ "total": len(bugs),
686
+ "critical": len([b for b in bugs if b.priority == "critical"]),
687
+ "open": len([b for b in bugs if b.status != "done"]),
688
+ },
689
+ "health": {
690
+ "bottlenecks": self.sdk.dep_analytics.find_bottlenecks(top_n=3),
691
+ "distribution": self.sdk.analytics.get_work_type_distribution(),
692
+ }
693
+ }
694
+
695
+ def report(self):
696
+ """Print project report."""
697
+ status = self.get_status()
698
+
699
+ print("=" * 50)
700
+ print("PROJECT STATUS REPORT")
701
+ print("=" * 50)
702
+
703
+ print("\nFEATURES:")
704
+ print(f" Total: {status['features']['total']}")
705
+ print(f" Done: {status['features']['done']}")
706
+ print(f" In Progress: {status['features']['in_progress']}")
707
+ print(f" Blocked: {status['features']['blocked']}")
708
+
709
+ print("\nBUGS:")
710
+ print(f" Total: {status['bugs']['total']}")
711
+ print(f" Critical: {status['bugs']['critical']}")
712
+ print(f" Open: {status['bugs']['open']}")
713
+
714
+ print("\nHEALTH METRICS:")
715
+ bottlenecks = status['health']['bottlenecks']
716
+ if bottlenecks:
717
+ print(" Top Bottlenecks:")
718
+ for item in bottlenecks[:3]:
719
+ print(f" - {item['title']} (blocks {item['blocking_count']})")
720
+
721
+ print("\n" + "=" * 50)
722
+
723
+ # Usage
724
+ if __name__ == "__main__":
725
+ pm = ProjectManager("claude")
726
+
727
+ # Create some work
728
+ feature = pm.create_feature(
729
+ "User Authentication",
730
+ priority="high",
731
+ steps=["Design", "Implement", "Test"]
732
+ )
733
+
734
+ bug = pm.create_bug("Login button styling", severity="medium")
735
+
736
+ # Print report
737
+ pm.report()
738
+ ```
739
+
740
+ ---
741
+
742
+ ## Getting Help
743
+
744
+ - **Documentation**: See [API_REFERENCE.md](API_REFERENCE.md)
745
+ - **Examples**: Check GitHub repository examples/
746
+ - **Issues**: Report bugs on GitHub
747
+ - **Discussions**: Join community discussions
748
+
749
+ ---
750
+
751
+ Version: 0.24.1
752
+ Last Updated: 2025-01-06