htmlgraph 0.9.3__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 (331) 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 +173 -17
  5. htmlgraph/__init__.pyi +123 -0
  6. htmlgraph/agent_detection.py +127 -0
  7. htmlgraph/agent_registry.py +45 -30
  8. htmlgraph/agents.py +160 -107
  9. htmlgraph/analytics/__init__.py +9 -2
  10. htmlgraph/analytics/cli.py +190 -51
  11. htmlgraph/analytics/cost_analyzer.py +391 -0
  12. htmlgraph/analytics/cost_monitor.py +664 -0
  13. htmlgraph/analytics/cost_reporter.py +675 -0
  14. htmlgraph/analytics/cross_session.py +617 -0
  15. htmlgraph/analytics/dependency.py +192 -100
  16. htmlgraph/analytics/pattern_learning.py +771 -0
  17. htmlgraph/analytics/session_graph.py +707 -0
  18. htmlgraph/analytics/strategic/__init__.py +80 -0
  19. htmlgraph/analytics/strategic/cost_optimizer.py +611 -0
  20. htmlgraph/analytics/strategic/pattern_detector.py +876 -0
  21. htmlgraph/analytics/strategic/preference_manager.py +709 -0
  22. htmlgraph/analytics/strategic/suggestion_engine.py +747 -0
  23. htmlgraph/analytics/work_type.py +190 -14
  24. htmlgraph/analytics_index.py +135 -51
  25. htmlgraph/api/__init__.py +3 -0
  26. htmlgraph/api/cost_alerts_websocket.py +416 -0
  27. htmlgraph/api/main.py +2498 -0
  28. htmlgraph/api/static/htmx.min.js +1 -0
  29. htmlgraph/api/static/style-redesign.css +1344 -0
  30. htmlgraph/api/static/style.css +1079 -0
  31. htmlgraph/api/templates/dashboard-redesign.html +1366 -0
  32. htmlgraph/api/templates/dashboard.html +794 -0
  33. htmlgraph/api/templates/partials/activity-feed-hierarchical.html +326 -0
  34. htmlgraph/api/templates/partials/activity-feed.html +1100 -0
  35. htmlgraph/api/templates/partials/agents-redesign.html +317 -0
  36. htmlgraph/api/templates/partials/agents.html +317 -0
  37. htmlgraph/api/templates/partials/event-traces.html +373 -0
  38. htmlgraph/api/templates/partials/features-kanban-redesign.html +509 -0
  39. htmlgraph/api/templates/partials/features.html +578 -0
  40. htmlgraph/api/templates/partials/metrics-redesign.html +346 -0
  41. htmlgraph/api/templates/partials/metrics.html +346 -0
  42. htmlgraph/api/templates/partials/orchestration-redesign.html +443 -0
  43. htmlgraph/api/templates/partials/orchestration.html +198 -0
  44. htmlgraph/api/templates/partials/spawners.html +375 -0
  45. htmlgraph/api/templates/partials/work-items.html +613 -0
  46. htmlgraph/api/websocket.py +538 -0
  47. htmlgraph/archive/__init__.py +24 -0
  48. htmlgraph/archive/bloom.py +234 -0
  49. htmlgraph/archive/fts.py +297 -0
  50. htmlgraph/archive/manager.py +583 -0
  51. htmlgraph/archive/search.py +244 -0
  52. htmlgraph/atomic_ops.py +560 -0
  53. htmlgraph/attribute_index.py +208 -0
  54. htmlgraph/bounded_paths.py +539 -0
  55. htmlgraph/builders/__init__.py +14 -0
  56. htmlgraph/builders/base.py +118 -29
  57. htmlgraph/builders/bug.py +150 -0
  58. htmlgraph/builders/chore.py +119 -0
  59. htmlgraph/builders/epic.py +150 -0
  60. htmlgraph/builders/feature.py +31 -6
  61. htmlgraph/builders/insight.py +195 -0
  62. htmlgraph/builders/metric.py +217 -0
  63. htmlgraph/builders/pattern.py +202 -0
  64. htmlgraph/builders/phase.py +162 -0
  65. htmlgraph/builders/spike.py +52 -19
  66. htmlgraph/builders/track.py +148 -72
  67. htmlgraph/cigs/__init__.py +81 -0
  68. htmlgraph/cigs/autonomy.py +385 -0
  69. htmlgraph/cigs/cost.py +475 -0
  70. htmlgraph/cigs/messages_basic.py +472 -0
  71. htmlgraph/cigs/messaging.py +365 -0
  72. htmlgraph/cigs/models.py +771 -0
  73. htmlgraph/cigs/pattern_storage.py +427 -0
  74. htmlgraph/cigs/patterns.py +503 -0
  75. htmlgraph/cigs/posttool_analyzer.py +234 -0
  76. htmlgraph/cigs/reporter.py +818 -0
  77. htmlgraph/cigs/tracker.py +317 -0
  78. htmlgraph/cli/.htmlgraph/.session-warning-state.json +6 -0
  79. htmlgraph/cli/.htmlgraph/agents.json +72 -0
  80. htmlgraph/cli/.htmlgraph/htmlgraph.db +0 -0
  81. htmlgraph/cli/__init__.py +42 -0
  82. htmlgraph/cli/__main__.py +6 -0
  83. htmlgraph/cli/analytics.py +1424 -0
  84. htmlgraph/cli/base.py +685 -0
  85. htmlgraph/cli/constants.py +206 -0
  86. htmlgraph/cli/core.py +954 -0
  87. htmlgraph/cli/main.py +147 -0
  88. htmlgraph/cli/models.py +475 -0
  89. htmlgraph/cli/templates/__init__.py +1 -0
  90. htmlgraph/cli/templates/cost_dashboard.py +399 -0
  91. htmlgraph/cli/work/__init__.py +239 -0
  92. htmlgraph/cli/work/browse.py +115 -0
  93. htmlgraph/cli/work/features.py +568 -0
  94. htmlgraph/cli/work/orchestration.py +676 -0
  95. htmlgraph/cli/work/report.py +728 -0
  96. htmlgraph/cli/work/sessions.py +466 -0
  97. htmlgraph/cli/work/snapshot.py +559 -0
  98. htmlgraph/cli/work/tracks.py +486 -0
  99. htmlgraph/cli_commands/__init__.py +1 -0
  100. htmlgraph/cli_commands/feature.py +195 -0
  101. htmlgraph/cli_framework.py +115 -0
  102. htmlgraph/collections/__init__.py +18 -0
  103. htmlgraph/collections/base.py +415 -98
  104. htmlgraph/collections/bug.py +53 -0
  105. htmlgraph/collections/chore.py +53 -0
  106. htmlgraph/collections/epic.py +53 -0
  107. htmlgraph/collections/feature.py +12 -26
  108. htmlgraph/collections/insight.py +100 -0
  109. htmlgraph/collections/metric.py +92 -0
  110. htmlgraph/collections/pattern.py +97 -0
  111. htmlgraph/collections/phase.py +53 -0
  112. htmlgraph/collections/session.py +194 -0
  113. htmlgraph/collections/spike.py +56 -16
  114. htmlgraph/collections/task_delegation.py +241 -0
  115. htmlgraph/collections/todo.py +511 -0
  116. htmlgraph/collections/traces.py +487 -0
  117. htmlgraph/config/cost_models.json +56 -0
  118. htmlgraph/config.py +190 -0
  119. htmlgraph/context_analytics.py +344 -0
  120. htmlgraph/converter.py +216 -28
  121. htmlgraph/cost_analysis/__init__.py +5 -0
  122. htmlgraph/cost_analysis/analyzer.py +438 -0
  123. htmlgraph/dashboard.html +2406 -307
  124. htmlgraph/dashboard.html.backup +6592 -0
  125. htmlgraph/dashboard.html.bak +7181 -0
  126. htmlgraph/dashboard.html.bak2 +7231 -0
  127. htmlgraph/dashboard.html.bak3 +7232 -0
  128. htmlgraph/db/__init__.py +38 -0
  129. htmlgraph/db/queries.py +790 -0
  130. htmlgraph/db/schema.py +1788 -0
  131. htmlgraph/decorators.py +317 -0
  132. htmlgraph/dependency_models.py +19 -2
  133. htmlgraph/deploy.py +142 -125
  134. htmlgraph/deployment_models.py +474 -0
  135. htmlgraph/docs/API_REFERENCE.md +841 -0
  136. htmlgraph/docs/HTTP_API.md +750 -0
  137. htmlgraph/docs/INTEGRATION_GUIDE.md +752 -0
  138. htmlgraph/docs/ORCHESTRATION_PATTERNS.md +717 -0
  139. htmlgraph/docs/README.md +532 -0
  140. htmlgraph/docs/__init__.py +77 -0
  141. htmlgraph/docs/docs_version.py +55 -0
  142. htmlgraph/docs/metadata.py +93 -0
  143. htmlgraph/docs/migrations.py +232 -0
  144. htmlgraph/docs/template_engine.py +143 -0
  145. htmlgraph/docs/templates/_sections/cli_reference.md.j2 +52 -0
  146. htmlgraph/docs/templates/_sections/core_concepts.md.j2 +29 -0
  147. htmlgraph/docs/templates/_sections/sdk_basics.md.j2 +69 -0
  148. htmlgraph/docs/templates/base_agents.md.j2 +78 -0
  149. htmlgraph/docs/templates/example_user_override.md.j2 +47 -0
  150. htmlgraph/docs/version_check.py +163 -0
  151. htmlgraph/edge_index.py +182 -27
  152. htmlgraph/error_handler.py +544 -0
  153. htmlgraph/event_log.py +100 -52
  154. htmlgraph/event_migration.py +13 -4
  155. htmlgraph/exceptions.py +49 -0
  156. htmlgraph/file_watcher.py +101 -28
  157. htmlgraph/find_api.py +75 -63
  158. htmlgraph/git_events.py +145 -63
  159. htmlgraph/graph.py +1122 -106
  160. htmlgraph/hooks/.htmlgraph/.session-warning-state.json +6 -0
  161. htmlgraph/hooks/.htmlgraph/agents.json +72 -0
  162. htmlgraph/hooks/.htmlgraph/index.sqlite +0 -0
  163. htmlgraph/hooks/__init__.py +45 -0
  164. htmlgraph/hooks/bootstrap.py +169 -0
  165. htmlgraph/hooks/cigs_pretool_enforcer.py +354 -0
  166. htmlgraph/hooks/concurrent_sessions.py +208 -0
  167. htmlgraph/hooks/context.py +350 -0
  168. htmlgraph/hooks/drift_handler.py +525 -0
  169. htmlgraph/hooks/event_tracker.py +1314 -0
  170. htmlgraph/hooks/git_commands.py +175 -0
  171. htmlgraph/hooks/hooks-config.example.json +12 -0
  172. htmlgraph/hooks/installer.py +343 -0
  173. htmlgraph/hooks/orchestrator.py +674 -0
  174. htmlgraph/hooks/orchestrator_reflector.py +223 -0
  175. htmlgraph/hooks/post-checkout.sh +28 -0
  176. htmlgraph/hooks/post-commit.sh +24 -0
  177. htmlgraph/hooks/post-merge.sh +26 -0
  178. htmlgraph/hooks/post_tool_use_failure.py +273 -0
  179. htmlgraph/hooks/post_tool_use_handler.py +257 -0
  180. htmlgraph/hooks/posttooluse.py +408 -0
  181. htmlgraph/hooks/pre-commit.sh +94 -0
  182. htmlgraph/hooks/pre-push.sh +28 -0
  183. htmlgraph/hooks/pretooluse.py +819 -0
  184. htmlgraph/hooks/prompt_analyzer.py +637 -0
  185. htmlgraph/hooks/session_handler.py +668 -0
  186. htmlgraph/hooks/session_summary.py +395 -0
  187. htmlgraph/hooks/state_manager.py +504 -0
  188. htmlgraph/hooks/subagent_detection.py +202 -0
  189. htmlgraph/hooks/subagent_stop.py +369 -0
  190. htmlgraph/hooks/task_enforcer.py +255 -0
  191. htmlgraph/hooks/task_validator.py +177 -0
  192. htmlgraph/hooks/validator.py +628 -0
  193. htmlgraph/ids.py +41 -27
  194. htmlgraph/index.d.ts +286 -0
  195. htmlgraph/learning.py +767 -0
  196. htmlgraph/mcp_server.py +69 -23
  197. htmlgraph/models.py +1586 -87
  198. htmlgraph/operations/README.md +62 -0
  199. htmlgraph/operations/__init__.py +79 -0
  200. htmlgraph/operations/analytics.py +339 -0
  201. htmlgraph/operations/bootstrap.py +289 -0
  202. htmlgraph/operations/events.py +244 -0
  203. htmlgraph/operations/fastapi_server.py +231 -0
  204. htmlgraph/operations/hooks.py +350 -0
  205. htmlgraph/operations/initialization.py +597 -0
  206. htmlgraph/operations/initialization.py.backup +228 -0
  207. htmlgraph/operations/server.py +303 -0
  208. htmlgraph/orchestration/__init__.py +58 -0
  209. htmlgraph/orchestration/claude_launcher.py +179 -0
  210. htmlgraph/orchestration/command_builder.py +72 -0
  211. htmlgraph/orchestration/headless_spawner.py +281 -0
  212. htmlgraph/orchestration/live_events.py +377 -0
  213. htmlgraph/orchestration/model_selection.py +327 -0
  214. htmlgraph/orchestration/plugin_manager.py +140 -0
  215. htmlgraph/orchestration/prompts.py +137 -0
  216. htmlgraph/orchestration/spawner_event_tracker.py +383 -0
  217. htmlgraph/orchestration/spawners/__init__.py +16 -0
  218. htmlgraph/orchestration/spawners/base.py +194 -0
  219. htmlgraph/orchestration/spawners/claude.py +173 -0
  220. htmlgraph/orchestration/spawners/codex.py +435 -0
  221. htmlgraph/orchestration/spawners/copilot.py +294 -0
  222. htmlgraph/orchestration/spawners/gemini.py +471 -0
  223. htmlgraph/orchestration/subprocess_runner.py +36 -0
  224. htmlgraph/orchestration/task_coordination.py +343 -0
  225. htmlgraph/orchestration.md +563 -0
  226. htmlgraph/orchestrator-system-prompt-optimized.txt +863 -0
  227. htmlgraph/orchestrator.py +669 -0
  228. htmlgraph/orchestrator_config.py +357 -0
  229. htmlgraph/orchestrator_mode.py +328 -0
  230. htmlgraph/orchestrator_validator.py +133 -0
  231. htmlgraph/parallel.py +646 -0
  232. htmlgraph/parser.py +160 -35
  233. htmlgraph/path_query.py +608 -0
  234. htmlgraph/pattern_matcher.py +636 -0
  235. htmlgraph/planning.py +147 -52
  236. htmlgraph/pydantic_models.py +476 -0
  237. htmlgraph/quality_gates.py +350 -0
  238. htmlgraph/query_builder.py +109 -72
  239. htmlgraph/query_composer.py +509 -0
  240. htmlgraph/reflection.py +443 -0
  241. htmlgraph/refs.py +344 -0
  242. htmlgraph/repo_hash.py +512 -0
  243. htmlgraph/repositories/__init__.py +292 -0
  244. htmlgraph/repositories/analytics_repository.py +455 -0
  245. htmlgraph/repositories/analytics_repository_standard.py +628 -0
  246. htmlgraph/repositories/feature_repository.py +581 -0
  247. htmlgraph/repositories/feature_repository_htmlfile.py +668 -0
  248. htmlgraph/repositories/feature_repository_memory.py +607 -0
  249. htmlgraph/repositories/feature_repository_sqlite.py +858 -0
  250. htmlgraph/repositories/filter_service.py +620 -0
  251. htmlgraph/repositories/filter_service_standard.py +445 -0
  252. htmlgraph/repositories/shared_cache.py +621 -0
  253. htmlgraph/repositories/shared_cache_memory.py +395 -0
  254. htmlgraph/repositories/track_repository.py +552 -0
  255. htmlgraph/repositories/track_repository_htmlfile.py +619 -0
  256. htmlgraph/repositories/track_repository_memory.py +508 -0
  257. htmlgraph/repositories/track_repository_sqlite.py +711 -0
  258. htmlgraph/routing.py +8 -19
  259. htmlgraph/scripts/deploy.py +1 -2
  260. htmlgraph/sdk/__init__.py +398 -0
  261. htmlgraph/sdk/__init__.pyi +14 -0
  262. htmlgraph/sdk/analytics/__init__.py +19 -0
  263. htmlgraph/sdk/analytics/engine.py +155 -0
  264. htmlgraph/sdk/analytics/helpers.py +178 -0
  265. htmlgraph/sdk/analytics/registry.py +109 -0
  266. htmlgraph/sdk/base.py +484 -0
  267. htmlgraph/sdk/constants.py +216 -0
  268. htmlgraph/sdk/core.pyi +308 -0
  269. htmlgraph/sdk/discovery.py +120 -0
  270. htmlgraph/sdk/help/__init__.py +12 -0
  271. htmlgraph/sdk/help/mixin.py +699 -0
  272. htmlgraph/sdk/mixins/__init__.py +15 -0
  273. htmlgraph/sdk/mixins/attribution.py +113 -0
  274. htmlgraph/sdk/mixins/mixin.py +410 -0
  275. htmlgraph/sdk/operations/__init__.py +12 -0
  276. htmlgraph/sdk/operations/mixin.py +427 -0
  277. htmlgraph/sdk/orchestration/__init__.py +17 -0
  278. htmlgraph/sdk/orchestration/coordinator.py +203 -0
  279. htmlgraph/sdk/orchestration/spawner.py +204 -0
  280. htmlgraph/sdk/planning/__init__.py +19 -0
  281. htmlgraph/sdk/planning/bottlenecks.py +93 -0
  282. htmlgraph/sdk/planning/mixin.py +211 -0
  283. htmlgraph/sdk/planning/parallel.py +186 -0
  284. htmlgraph/sdk/planning/queue.py +210 -0
  285. htmlgraph/sdk/planning/recommendations.py +87 -0
  286. htmlgraph/sdk/planning/smart_planning.py +319 -0
  287. htmlgraph/sdk/session/__init__.py +19 -0
  288. htmlgraph/sdk/session/continuity.py +57 -0
  289. htmlgraph/sdk/session/handoff.py +110 -0
  290. htmlgraph/sdk/session/info.py +309 -0
  291. htmlgraph/sdk/session/manager.py +103 -0
  292. htmlgraph/sdk/strategic/__init__.py +26 -0
  293. htmlgraph/sdk/strategic/mixin.py +563 -0
  294. htmlgraph/server.py +685 -180
  295. htmlgraph/services/__init__.py +10 -0
  296. htmlgraph/services/claiming.py +199 -0
  297. htmlgraph/session_hooks.py +300 -0
  298. htmlgraph/session_manager.py +1392 -175
  299. htmlgraph/session_registry.py +587 -0
  300. htmlgraph/session_state.py +436 -0
  301. htmlgraph/session_warning.py +201 -0
  302. htmlgraph/sessions/__init__.py +23 -0
  303. htmlgraph/sessions/handoff.py +756 -0
  304. htmlgraph/setup.py +34 -17
  305. htmlgraph/spike_index.py +143 -0
  306. htmlgraph/sync_docs.py +12 -15
  307. htmlgraph/system_prompts.py +450 -0
  308. htmlgraph/templates/AGENTS.md.template +366 -0
  309. htmlgraph/templates/CLAUDE.md.template +97 -0
  310. htmlgraph/templates/GEMINI.md.template +87 -0
  311. htmlgraph/templates/orchestration-view.html +350 -0
  312. htmlgraph/track_builder.py +146 -15
  313. htmlgraph/track_manager.py +69 -21
  314. htmlgraph/transcript.py +890 -0
  315. htmlgraph/transcript_analytics.py +699 -0
  316. htmlgraph/types.py +323 -0
  317. htmlgraph/validation.py +115 -0
  318. htmlgraph/watch.py +8 -5
  319. htmlgraph/work_type_utils.py +3 -2
  320. {htmlgraph-0.9.3.data → htmlgraph-0.27.5.data}/data/htmlgraph/dashboard.html +2406 -307
  321. htmlgraph-0.27.5.data/data/htmlgraph/templates/AGENTS.md.template +366 -0
  322. htmlgraph-0.27.5.data/data/htmlgraph/templates/CLAUDE.md.template +97 -0
  323. htmlgraph-0.27.5.data/data/htmlgraph/templates/GEMINI.md.template +87 -0
  324. {htmlgraph-0.9.3.dist-info → htmlgraph-0.27.5.dist-info}/METADATA +97 -64
  325. htmlgraph-0.27.5.dist-info/RECORD +337 -0
  326. {htmlgraph-0.9.3.dist-info → htmlgraph-0.27.5.dist-info}/entry_points.txt +1 -1
  327. htmlgraph/cli.py +0 -2688
  328. htmlgraph/sdk.py +0 -709
  329. htmlgraph-0.9.3.dist-info/RECORD +0 -61
  330. {htmlgraph-0.9.3.data → htmlgraph-0.27.5.data}/data/htmlgraph/styles.css +0 -0
  331. {htmlgraph-0.9.3.dist-info → htmlgraph-0.27.5.dist-info}/WHEEL +0 -0
@@ -0,0 +1,6 @@
1
+ {
2
+ "dismissed_at": null,
3
+ "dismissed_by": null,
4
+ "session_id": null,
5
+ "show_count": 59
6
+ }
@@ -0,0 +1,72 @@
1
+ {
2
+ "version": "1.0",
3
+ "updated": "2026-01-11T04:13:54.354401",
4
+ "agents": {
5
+ "claude": {
6
+ "id": "claude",
7
+ "name": "Claude",
8
+ "capabilities": [
9
+ "python",
10
+ "javascript",
11
+ "typescript",
12
+ "html",
13
+ "css",
14
+ "code-review",
15
+ "testing",
16
+ "documentation",
17
+ "debugging",
18
+ "refactoring",
19
+ "architecture",
20
+ "api-design"
21
+ ],
22
+ "max_parallel_tasks": 3,
23
+ "preferred_complexity": [
24
+ "low",
25
+ "medium",
26
+ "high",
27
+ "very-high"
28
+ ],
29
+ "active": true,
30
+ "metadata": {}
31
+ },
32
+ "gemini": {
33
+ "id": "gemini",
34
+ "name": "Gemini",
35
+ "capabilities": [
36
+ "python",
37
+ "data-analysis",
38
+ "documentation",
39
+ "testing",
40
+ "code-review",
41
+ "javascript"
42
+ ],
43
+ "max_parallel_tasks": 2,
44
+ "preferred_complexity": [
45
+ "low",
46
+ "medium",
47
+ "high"
48
+ ],
49
+ "active": true,
50
+ "metadata": {}
51
+ },
52
+ "codex": {
53
+ "id": "codex",
54
+ "name": "Codex",
55
+ "capabilities": [
56
+ "python",
57
+ "javascript",
58
+ "debugging",
59
+ "testing",
60
+ "code-generation",
61
+ "documentation"
62
+ ],
63
+ "max_parallel_tasks": 2,
64
+ "preferred_complexity": [
65
+ "low",
66
+ "medium"
67
+ ],
68
+ "active": true,
69
+ "metadata": {}
70
+ }
71
+ }
72
+ }
Binary file
htmlgraph/__init__.py CHANGED
@@ -5,35 +5,131 @@ A lightweight graph database framework using HTML files as nodes,
5
5
  hyperlinks as edges, and CSS selectors as the query language.
6
6
  """
7
7
 
8
+ import logging
9
+
10
+ from rich.console import Console
11
+ from rich.logging import RichHandler
12
+
13
+ # Configure Rich logging for entire SDK
14
+ # CRITICAL: Use stderr=True to prevent pollution of stdout (hooks output JSON to stdout)
15
+ logging.basicConfig(
16
+ handlers=[
17
+ RichHandler(
18
+ console=Console(stderr=True),
19
+ show_time=True,
20
+ show_level=True,
21
+ rich_tracebacks=True,
22
+ )
23
+ ],
24
+ level=logging.INFO,
25
+ format="%(message)s",
26
+ datefmt="[%X]",
27
+ )
28
+
29
+ # SDK now lives in sdk/core.py - clean import from sdk package
30
+ from htmlgraph.agent_detection import detect_agent_name, get_agent_display_name
31
+ from htmlgraph.agents import AgentInterface
32
+ from htmlgraph.analytics import Analytics, DependencyAnalytics
33
+ from htmlgraph.atomic_ops import (
34
+ AtomicFileWriter,
35
+ DirectoryLocker,
36
+ atomic_rename,
37
+ cleanup_orphaned_temp_files,
38
+ safe_temp_file,
39
+ validate_atomic_write,
40
+ )
41
+ from htmlgraph.builders import BaseBuilder, FeatureBuilder, SpikeBuilder
42
+ from htmlgraph.collections import BaseCollection, FeatureCollection, SpikeCollection
43
+ from htmlgraph.context_analytics import ContextAnalytics, ContextUsage
44
+ from htmlgraph.decorators import RetryError, retry, retry_async
45
+ from htmlgraph.edge_index import EdgeIndex, EdgeRef
46
+ from htmlgraph.exceptions import (
47
+ ClaimConflictError,
48
+ HtmlGraphError,
49
+ NodeNotFoundError,
50
+ SessionNotFoundError,
51
+ ValidationError,
52
+ )
53
+ from htmlgraph.find_api import FindAPI, find, find_all
54
+ from htmlgraph.graph import CompiledQuery, HtmlGraph
55
+ from htmlgraph.ids import (
56
+ generate_hierarchical_id,
57
+ generate_id,
58
+ is_legacy_id,
59
+ is_valid_id,
60
+ parse_id,
61
+ )
62
+ from htmlgraph.learning import LearningPersistence, auto_persist_on_session_end
8
63
  from htmlgraph.models import (
9
- Node,
64
+ ActivityEntry,
65
+ AggregatedMetric,
66
+ Chore,
67
+ ContextSnapshot,
10
68
  Edge,
11
- Step,
12
69
  Graph,
70
+ MaintenanceType,
71
+ Node,
72
+ Pattern,
13
73
  Session,
14
- ActivityEntry,
74
+ SessionInsight,
15
75
  Spike,
16
- Chore,
17
- WorkType,
18
76
  SpikeType,
19
- MaintenanceType,
77
+ Step,
78
+ WorkType,
20
79
  )
21
- from htmlgraph.graph import HtmlGraph
22
- from htmlgraph.edge_index import EdgeIndex, EdgeRef
23
- from htmlgraph.query_builder import QueryBuilder, Condition, Operator
24
- from htmlgraph.find_api import FindAPI, find, find_all
25
- from htmlgraph.agents import AgentInterface
80
+ from htmlgraph.orchestration import (
81
+ delegate_with_id,
82
+ generate_task_id,
83
+ get_results_by_task_id,
84
+ parallel_delegate,
85
+ )
86
+ from htmlgraph.orchestrator_mode import OrchestratorMode, OrchestratorModeManager
87
+ from htmlgraph.parallel import AggregateResult, ParallelAnalysis, ParallelWorkflow
88
+ from htmlgraph.query_builder import Condition, Operator, QueryBuilder
89
+ from htmlgraph.reflection import ComputationalReflection, get_reflection_context
90
+ from htmlgraph.repo_hash import RepoHash
91
+ from htmlgraph.sdk import SDK
26
92
  from htmlgraph.server import serve
27
93
  from htmlgraph.session_manager import SessionManager
28
- from htmlgraph.sdk import SDK
29
- from htmlgraph.analytics import Analytics, DependencyAnalytics
30
- from htmlgraph.ids import generate_id, generate_hierarchical_id, parse_id, is_valid_id, is_legacy_id
94
+ from htmlgraph.session_registry import SessionRegistry
95
+ from htmlgraph.types import (
96
+ ActiveWorkItem,
97
+ AggregateResultsDict,
98
+ BottleneckDict,
99
+ FeatureSummary,
100
+ HighRiskTask,
101
+ ImpactAnalysisDict,
102
+ OrchestrationResult,
103
+ ParallelGuidelines,
104
+ ParallelPlanResult,
105
+ ParallelWorkInfo,
106
+ PlanningContext,
107
+ ProjectStatus,
108
+ RiskAssessmentDict,
109
+ SessionAnalytics,
110
+ SessionStartInfo,
111
+ SessionSummary,
112
+ SmartPlanResult,
113
+ SubagentPrompt,
114
+ TaskPrompt,
115
+ TrackCreationResult,
116
+ WorkQueueItem,
117
+ WorkRecommendation,
118
+ )
31
119
  from htmlgraph.work_type_utils import infer_work_type, infer_work_type_from_id
32
- from htmlgraph.builders import BaseBuilder, FeatureBuilder, SpikeBuilder
33
- from htmlgraph.collections import BaseCollection, FeatureCollection, SpikeCollection
34
120
 
35
- __version__ = "0.9.3"
121
+ __version__ = "0.27.5"
36
122
  __all__ = [
123
+ # Exceptions
124
+ "HtmlGraphError",
125
+ "NodeNotFoundError",
126
+ "SessionNotFoundError",
127
+ "ClaimConflictError",
128
+ "ValidationError",
129
+ "RetryError",
130
+ # Decorators
131
+ "retry",
132
+ "retry_async",
37
133
  # Core models
38
134
  "Node",
39
135
  "Edge",
@@ -41,14 +137,19 @@ __all__ = [
41
137
  "Graph",
42
138
  "Session",
43
139
  "ActivityEntry",
140
+ "ContextSnapshot",
44
141
  "Spike",
45
142
  "Chore",
143
+ "Pattern",
144
+ "SessionInsight",
145
+ "AggregatedMetric",
46
146
  # Work type classification (Phase 1)
47
147
  "WorkType",
48
148
  "SpikeType",
49
149
  "MaintenanceType",
50
150
  # Graph operations
51
151
  "HtmlGraph",
152
+ "CompiledQuery",
52
153
  "EdgeIndex",
53
154
  "EdgeRef",
54
155
  "QueryBuilder",
@@ -59,9 +160,13 @@ __all__ = [
59
160
  "find_all",
60
161
  "AgentInterface",
61
162
  "SessionManager",
163
+ "SessionRegistry",
164
+ "RepoHash",
62
165
  "SDK",
63
166
  "Analytics", # Phase 2: Work Type Analytics
64
167
  "DependencyAnalytics", # Advanced dependency-aware analytics
168
+ "ContextAnalytics", # Context usage tracking and analytics
169
+ "ContextUsage", # Context usage data structure
65
170
  "serve",
66
171
  # ID generation (collision-resistant, multi-agent safe)
67
172
  "generate_id",
@@ -80,4 +185,55 @@ __all__ = [
80
185
  "BaseCollection",
81
186
  "FeatureCollection",
82
187
  "SpikeCollection",
188
+ # Agent detection
189
+ "detect_agent_name",
190
+ "get_agent_display_name",
191
+ # Parallel workflow coordination
192
+ "ParallelWorkflow",
193
+ "ParallelAnalysis",
194
+ "AggregateResult",
195
+ # Type definitions (TypedDict for SDK return types)
196
+ "BottleneckDict",
197
+ "WorkRecommendation",
198
+ "ParallelWorkInfo",
199
+ "RiskAssessmentDict",
200
+ "HighRiskTask",
201
+ "ImpactAnalysisDict",
202
+ "SessionStartInfo",
203
+ "ProjectStatus",
204
+ "ActiveWorkItem",
205
+ "FeatureSummary",
206
+ "SessionSummary",
207
+ "SessionAnalytics",
208
+ "WorkQueueItem",
209
+ "SmartPlanResult",
210
+ "PlanningContext",
211
+ "TrackCreationResult",
212
+ "SubagentPrompt",
213
+ "OrchestrationResult",
214
+ "ParallelPlanResult",
215
+ "TaskPrompt",
216
+ "ParallelGuidelines",
217
+ "AggregateResultsDict",
218
+ # Active Learning Persistence
219
+ "LearningPersistence",
220
+ "auto_persist_on_session_end",
221
+ # Computational Reflection (pre-computed context injection)
222
+ "ComputationalReflection",
223
+ "get_reflection_context",
224
+ # Orchestrator Mode Management
225
+ "OrchestratorMode",
226
+ "OrchestratorModeManager",
227
+ # Orchestration helpers for parallel task coordination
228
+ "delegate_with_id",
229
+ "get_results_by_task_id",
230
+ "parallel_delegate",
231
+ "generate_task_id",
232
+ # Atomic file operations (Phase 1.3: Session File Tracking)
233
+ "AtomicFileWriter",
234
+ "DirectoryLocker",
235
+ "atomic_rename",
236
+ "cleanup_orphaned_temp_files",
237
+ "safe_temp_file",
238
+ "validate_atomic_write",
83
239
  ]
htmlgraph/__init__.pyi ADDED
@@ -0,0 +1,123 @@
1
+ """
2
+ Type stub for htmlgraph package.
3
+
4
+ This stub provides type information for mypy when the SDK class
5
+ is loaded dynamically via importlib at runtime.
6
+ """
7
+
8
+ from htmlgraph.agent_detection import detect_agent_name as detect_agent_name
9
+ from htmlgraph.agent_detection import get_agent_display_name as get_agent_display_name
10
+ from htmlgraph.agents import AgentInterface as AgentInterface
11
+ from htmlgraph.analytics import Analytics as Analytics
12
+
13
+ # Analytics
14
+ from htmlgraph.analytics import DependencyAnalytics as DependencyAnalytics
15
+ from htmlgraph.atomic_ops import AtomicFileWriter as AtomicFileWriter
16
+ from htmlgraph.atomic_ops import DirectoryLocker as DirectoryLocker
17
+ from htmlgraph.atomic_ops import atomic_rename as atomic_rename
18
+ from htmlgraph.atomic_ops import (
19
+ cleanup_orphaned_temp_files as cleanup_orphaned_temp_files,
20
+ )
21
+ from htmlgraph.atomic_ops import safe_temp_file as safe_temp_file
22
+ from htmlgraph.atomic_ops import validate_atomic_write as validate_atomic_write
23
+ from htmlgraph.builders import BaseBuilder as BaseBuilder
24
+ from htmlgraph.builders import FeatureBuilder as FeatureBuilder
25
+ from htmlgraph.builders import SpikeBuilder as SpikeBuilder
26
+ from htmlgraph.collections import BaseCollection as BaseCollection
27
+
28
+ # Collections
29
+ from htmlgraph.collections import FeatureCollection as FeatureCollection
30
+ from htmlgraph.collections import SpikeCollection as SpikeCollection
31
+ from htmlgraph.context_analytics import ContextAnalytics as ContextAnalytics
32
+ from htmlgraph.context_analytics import ContextUsage as ContextUsage
33
+ from htmlgraph.decorators import RetryError as RetryError
34
+ from htmlgraph.decorators import retry as retry
35
+ from htmlgraph.decorators import retry_async as retry_async
36
+ from htmlgraph.edge_index import EdgeIndex as EdgeIndex
37
+ from htmlgraph.edge_index import EdgeRef as EdgeRef
38
+ from htmlgraph.exceptions import ClaimConflictError as ClaimConflictError
39
+ from htmlgraph.exceptions import HtmlGraphError as HtmlGraphError
40
+ from htmlgraph.exceptions import NodeNotFoundError as NodeNotFoundError
41
+ from htmlgraph.exceptions import SessionNotFoundError as SessionNotFoundError
42
+ from htmlgraph.exceptions import ValidationError as ValidationError
43
+ from htmlgraph.find_api import FindAPI as FindAPI
44
+ from htmlgraph.find_api import find as find
45
+ from htmlgraph.find_api import find_all as find_all
46
+ from htmlgraph.graph import CompiledQuery as CompiledQuery
47
+ from htmlgraph.graph import HtmlGraph as HtmlGraph
48
+ from htmlgraph.ids import generate_hierarchical_id as generate_hierarchical_id
49
+ from htmlgraph.ids import generate_id as generate_id
50
+ from htmlgraph.ids import is_legacy_id as is_legacy_id
51
+ from htmlgraph.ids import is_valid_id as is_valid_id
52
+ from htmlgraph.ids import parse_id as parse_id
53
+ from htmlgraph.learning import LearningPersistence as LearningPersistence
54
+ from htmlgraph.learning import (
55
+ auto_persist_on_session_end as auto_persist_on_session_end,
56
+ )
57
+ from htmlgraph.models import ActivityEntry as ActivityEntry
58
+ from htmlgraph.models import AggregatedMetric as AggregatedMetric
59
+ from htmlgraph.models import Chore as Chore
60
+ from htmlgraph.models import ContextSnapshot as ContextSnapshot
61
+ from htmlgraph.models import Edge as Edge
62
+ from htmlgraph.models import Graph as Graph
63
+ from htmlgraph.models import MaintenanceType as MaintenanceType
64
+ from htmlgraph.models import Node as Node
65
+ from htmlgraph.models import Pattern as Pattern
66
+ from htmlgraph.models import Session as Session
67
+ from htmlgraph.models import SessionInsight as SessionInsight
68
+ from htmlgraph.models import Spike as Spike
69
+ from htmlgraph.models import SpikeType as SpikeType
70
+ from htmlgraph.models import Step as Step
71
+ from htmlgraph.models import WorkType as WorkType
72
+ from htmlgraph.orchestration import delegate_with_id as delegate_with_id
73
+ from htmlgraph.orchestration import generate_task_id as generate_task_id
74
+ from htmlgraph.orchestration import get_results_by_task_id as get_results_by_task_id
75
+ from htmlgraph.orchestration import parallel_delegate as parallel_delegate
76
+ from htmlgraph.orchestrator_mode import OrchestratorMode as OrchestratorMode
77
+ from htmlgraph.orchestrator_mode import (
78
+ OrchestratorModeManager as OrchestratorModeManager,
79
+ )
80
+ from htmlgraph.parallel import AggregateResult as AggregateResult
81
+ from htmlgraph.parallel import ParallelAnalysis as ParallelAnalysis
82
+ from htmlgraph.parallel import ParallelWorkflow as ParallelWorkflow
83
+ from htmlgraph.query_builder import Condition as Condition
84
+ from htmlgraph.query_builder import Operator as Operator
85
+ from htmlgraph.query_builder import QueryBuilder as QueryBuilder
86
+ from htmlgraph.reflection import ComputationalReflection as ComputationalReflection
87
+ from htmlgraph.reflection import get_reflection_context as get_reflection_context
88
+ from htmlgraph.repo_hash import RepoHash as RepoHash
89
+ from htmlgraph.sdk.core import SDK as SDK
90
+ from htmlgraph.server import serve as serve
91
+ from htmlgraph.session_manager import SessionManager as SessionManager
92
+ from htmlgraph.session_registry import SessionRegistry as SessionRegistry
93
+ from htmlgraph.types import ActiveWorkItem as ActiveWorkItem
94
+ from htmlgraph.types import AggregateResultsDict as AggregateResultsDict
95
+ from htmlgraph.types import BottleneckDict as BottleneckDict
96
+ from htmlgraph.types import FeatureSummary as FeatureSummary
97
+ from htmlgraph.types import HighRiskTask as HighRiskTask
98
+ from htmlgraph.types import ImpactAnalysisDict as ImpactAnalysisDict
99
+ from htmlgraph.types import OrchestrationResult as OrchestrationResult
100
+ from htmlgraph.types import ParallelGuidelines as ParallelGuidelines
101
+ from htmlgraph.types import ParallelPlanResult as ParallelPlanResult
102
+ from htmlgraph.types import ParallelWorkInfo as ParallelWorkInfo
103
+ from htmlgraph.types import PlanningContext as PlanningContext
104
+ from htmlgraph.types import ProjectStatus as ProjectStatus
105
+ from htmlgraph.types import RiskAssessmentDict as RiskAssessmentDict
106
+ from htmlgraph.types import SessionAnalytics as SessionAnalytics
107
+ from htmlgraph.types import SessionStartInfo as SessionStartInfo
108
+ from htmlgraph.types import SessionSummary as SessionSummary
109
+ from htmlgraph.types import SmartPlanResult as SmartPlanResult
110
+ from htmlgraph.types import SubagentPrompt as SubagentPrompt
111
+ from htmlgraph.types import TaskPrompt as TaskPrompt
112
+ from htmlgraph.types import TrackCreationResult as TrackCreationResult
113
+ from htmlgraph.types import WorkQueueItem as WorkQueueItem
114
+ from htmlgraph.types import WorkRecommendation as WorkRecommendation
115
+ from htmlgraph.work_type_utils import infer_work_type as infer_work_type
116
+ from htmlgraph.work_type_utils import infer_work_type_from_id as infer_work_type_from_id
117
+
118
+ __version__: str
119
+
120
+ # SDK is imported from htmlgraph.sdk.core (see import above)
121
+ # Re-exported here for backward compatibility
122
+
123
+ __all__: list[str]
@@ -0,0 +1,127 @@
1
+ """
2
+ Agent Detection Utilities
3
+
4
+ Intelligently detect which AI agent/interface is running HtmlGraph.
5
+ """
6
+
7
+ import os
8
+ import sys
9
+ from pathlib import Path
10
+
11
+
12
+ def detect_agent_name() -> str:
13
+ """
14
+ Detect the current agent/interface name based on environment.
15
+
16
+ Returns:
17
+ Agent name (e.g., "claude-code", "gemini", "cli")
18
+
19
+ Detection order:
20
+ 1. HTMLGRAPH_AGENT environment variable (explicit override)
21
+ 2. HTMLGRAPH_PARENT_AGENT (set by hooks for session context)
22
+ 3. Gemini detection (GEMINI environment markers) - checked before Claude to allow override
23
+ 4. Claude Code detection (CLAUDECODE env var, parent process)
24
+ 5. Fall back to "cli" only if no AI agent detected
25
+ """
26
+ # 1. Explicit override
27
+ explicit = os.environ.get("HTMLGRAPH_AGENT")
28
+ if explicit:
29
+ return explicit.strip()
30
+
31
+ # 2. Parent agent context (set by HtmlGraph hooks)
32
+ parent_agent = os.environ.get("HTMLGRAPH_PARENT_AGENT")
33
+ if parent_agent:
34
+ return parent_agent.strip()
35
+
36
+ # 3. Gemini detection (checked before Claude to allow explicit override)
37
+ if _is_gemini():
38
+ return "gemini"
39
+
40
+ # 4. Claude Code detection
41
+ if _is_claude_code():
42
+ return "claude-code"
43
+
44
+ # 5. Default to CLI only if no AI agent detected
45
+ return "cli"
46
+
47
+
48
+ def _is_claude_code() -> bool:
49
+ """Check if running in Claude Code environment."""
50
+ # Check for Claude Code environment variables
51
+ # CLAUDECODE=1 is set by Claude Code CLI
52
+ if os.environ.get("CLAUDECODE"):
53
+ return True
54
+
55
+ # CLAUDE_CODE_ENTRYPOINT indicates the entry point (cli, api, etc.)
56
+ if os.environ.get("CLAUDE_CODE_ENTRYPOINT"):
57
+ return True
58
+
59
+ if os.environ.get("CLAUDE_CODE_VERSION"):
60
+ return True
61
+
62
+ if os.environ.get("CLAUDE_API_KEY"):
63
+ return True
64
+
65
+ # Check for .claude directory in user home or project
66
+ claude_config = Path.home() / ".claude"
67
+ if claude_config.exists():
68
+ # Check if there's a recent session or settings
69
+ settings = claude_config / "settings.json"
70
+ if settings.exists():
71
+ return True
72
+
73
+ # Check parent process name (heuristic)
74
+ try:
75
+ import psutil
76
+
77
+ current = psutil.Process()
78
+ parent = current.parent()
79
+ if parent:
80
+ parent_name = parent.name().lower()
81
+ if "claude" in parent_name:
82
+ return True
83
+ except (ImportError, Exception):
84
+ pass
85
+
86
+ return False
87
+
88
+
89
+ def _is_gemini() -> bool:
90
+ """Check if running in Gemini environment."""
91
+ # Check for Gemini-specific environment variables
92
+ if os.environ.get("GEMINI_API_KEY"):
93
+ return True
94
+
95
+ if os.environ.get("GOOGLE_AI_STUDIO"):
96
+ return True
97
+
98
+ # Check for gemini in command line args
99
+ if any("gemini" in arg.lower() for arg in sys.argv):
100
+ return True
101
+
102
+ return False
103
+
104
+
105
+ def get_agent_display_name(agent: str) -> str:
106
+ """
107
+ Get a human-friendly display name for an agent.
108
+
109
+ Args:
110
+ agent: Agent identifier (e.g., "claude", "cli", "gemini")
111
+
112
+ Returns:
113
+ Display name (e.g., "Claude", "CLI", "Gemini")
114
+ """
115
+ display_names = {
116
+ "claude": "Claude",
117
+ "claude-code": "Claude Code",
118
+ "gemini": "Gemini",
119
+ "cli": "CLI",
120
+ "haiku": "Haiku",
121
+ "opus": "Opus",
122
+ "sonnet": "Sonnet",
123
+ "claude-opus-4-5-20251101": "Claude Opus 4.5",
124
+ "claude-sonnet-4-20250514": "Claude Sonnet 4",
125
+ }
126
+
127
+ return display_names.get(agent.lower(), agent.title())