htmlgraph 0.26.25__py3-none-any.whl → 0.27.1__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 (175) hide show
  1. htmlgraph/__init__.py +23 -1
  2. htmlgraph/__init__.pyi +123 -0
  3. htmlgraph/agent_registry.py +2 -1
  4. htmlgraph/analytics/cli.py +3 -3
  5. htmlgraph/analytics/cost_analyzer.py +5 -1
  6. htmlgraph/analytics/cost_monitor.py +664 -0
  7. htmlgraph/analytics/cross_session.py +13 -9
  8. htmlgraph/analytics/dependency.py +10 -6
  9. htmlgraph/analytics/strategic/__init__.py +80 -0
  10. htmlgraph/analytics/strategic/cost_optimizer.py +611 -0
  11. htmlgraph/analytics/strategic/pattern_detector.py +876 -0
  12. htmlgraph/analytics/strategic/preference_manager.py +709 -0
  13. htmlgraph/analytics/strategic/suggestion_engine.py +747 -0
  14. htmlgraph/analytics/work_type.py +15 -11
  15. htmlgraph/analytics_index.py +2 -1
  16. htmlgraph/api/cost_alerts_websocket.py +416 -0
  17. htmlgraph/api/main.py +167 -62
  18. htmlgraph/api/websocket.py +538 -0
  19. htmlgraph/attribute_index.py +2 -1
  20. htmlgraph/builders/base.py +2 -1
  21. htmlgraph/builders/bug.py +2 -1
  22. htmlgraph/builders/chore.py +2 -1
  23. htmlgraph/builders/epic.py +2 -1
  24. htmlgraph/builders/feature.py +2 -1
  25. htmlgraph/builders/insight.py +2 -1
  26. htmlgraph/builders/metric.py +2 -1
  27. htmlgraph/builders/pattern.py +2 -1
  28. htmlgraph/builders/phase.py +2 -1
  29. htmlgraph/builders/spike.py +2 -1
  30. htmlgraph/builders/track.py +2 -1
  31. htmlgraph/cli/analytics.py +2 -1
  32. htmlgraph/cli/base.py +2 -1
  33. htmlgraph/cli/core.py +2 -1
  34. htmlgraph/cli/main.py +2 -1
  35. htmlgraph/cli/models.py +2 -1
  36. htmlgraph/cli/templates/cost_dashboard.py +2 -1
  37. htmlgraph/cli/work/__init__.py +2 -1
  38. htmlgraph/cli/work/browse.py +2 -1
  39. htmlgraph/cli/work/features.py +2 -1
  40. htmlgraph/cli/work/orchestration.py +2 -1
  41. htmlgraph/cli/work/report.py +2 -1
  42. htmlgraph/cli/work/sessions.py +2 -1
  43. htmlgraph/cli/work/snapshot.py +2 -1
  44. htmlgraph/cli/work/tracks.py +2 -1
  45. htmlgraph/collections/base.py +10 -5
  46. htmlgraph/collections/bug.py +2 -1
  47. htmlgraph/collections/chore.py +2 -1
  48. htmlgraph/collections/epic.py +2 -1
  49. htmlgraph/collections/feature.py +2 -1
  50. htmlgraph/collections/insight.py +2 -1
  51. htmlgraph/collections/metric.py +2 -1
  52. htmlgraph/collections/pattern.py +2 -1
  53. htmlgraph/collections/phase.py +2 -1
  54. htmlgraph/collections/session.py +12 -7
  55. htmlgraph/collections/spike.py +6 -1
  56. htmlgraph/collections/task_delegation.py +7 -2
  57. htmlgraph/collections/todo.py +2 -1
  58. htmlgraph/collections/traces.py +15 -10
  59. htmlgraph/config/cost_models.json +56 -0
  60. htmlgraph/context_analytics.py +2 -1
  61. htmlgraph/db/schema.py +67 -6
  62. htmlgraph/dependency_models.py +2 -1
  63. htmlgraph/edge_index.py +2 -1
  64. htmlgraph/event_log.py +83 -64
  65. htmlgraph/event_migration.py +2 -1
  66. htmlgraph/file_watcher.py +12 -8
  67. htmlgraph/find_api.py +2 -1
  68. htmlgraph/git_events.py +6 -2
  69. htmlgraph/hooks/cigs_pretool_enforcer.py +5 -1
  70. htmlgraph/hooks/drift_handler.py +3 -3
  71. htmlgraph/hooks/event_tracker.py +40 -61
  72. htmlgraph/hooks/installer.py +5 -1
  73. htmlgraph/hooks/orchestrator.py +4 -0
  74. htmlgraph/hooks/orchestrator_reflector.py +4 -0
  75. htmlgraph/hooks/post_tool_use_failure.py +7 -3
  76. htmlgraph/hooks/posttooluse.py +4 -0
  77. htmlgraph/hooks/prompt_analyzer.py +5 -5
  78. htmlgraph/hooks/session_handler.py +2 -1
  79. htmlgraph/hooks/session_summary.py +6 -2
  80. htmlgraph/hooks/validator.py +8 -4
  81. htmlgraph/ids.py +2 -1
  82. htmlgraph/learning.py +2 -1
  83. htmlgraph/mcp_server.py +2 -1
  84. htmlgraph/operations/analytics.py +2 -1
  85. htmlgraph/operations/bootstrap.py +2 -1
  86. htmlgraph/operations/events.py +2 -1
  87. htmlgraph/operations/fastapi_server.py +2 -1
  88. htmlgraph/operations/hooks.py +2 -1
  89. htmlgraph/operations/initialization.py +2 -1
  90. htmlgraph/operations/server.py +2 -1
  91. htmlgraph/orchestration/claude_launcher.py +23 -20
  92. htmlgraph/orchestration/command_builder.py +2 -1
  93. htmlgraph/orchestration/headless_spawner.py +6 -2
  94. htmlgraph/orchestration/model_selection.py +7 -3
  95. htmlgraph/orchestration/plugin_manager.py +24 -19
  96. htmlgraph/orchestration/spawners/claude.py +5 -2
  97. htmlgraph/orchestration/spawners/codex.py +12 -19
  98. htmlgraph/orchestration/spawners/copilot.py +13 -18
  99. htmlgraph/orchestration/spawners/gemini.py +12 -19
  100. htmlgraph/orchestration/subprocess_runner.py +6 -3
  101. htmlgraph/orchestration/task_coordination.py +16 -8
  102. htmlgraph/orchestrator.py +2 -1
  103. htmlgraph/parallel.py +2 -1
  104. htmlgraph/query_builder.py +2 -1
  105. htmlgraph/reflection.py +2 -1
  106. htmlgraph/refs.py +2 -1
  107. htmlgraph/repo_hash.py +2 -1
  108. htmlgraph/repositories/__init__.py +292 -0
  109. htmlgraph/repositories/analytics_repository.py +455 -0
  110. htmlgraph/repositories/analytics_repository_standard.py +628 -0
  111. htmlgraph/repositories/feature_repository.py +581 -0
  112. htmlgraph/repositories/feature_repository_htmlfile.py +668 -0
  113. htmlgraph/repositories/feature_repository_memory.py +607 -0
  114. htmlgraph/repositories/feature_repository_sqlite.py +858 -0
  115. htmlgraph/repositories/filter_service.py +620 -0
  116. htmlgraph/repositories/filter_service_standard.py +445 -0
  117. htmlgraph/repositories/shared_cache.py +621 -0
  118. htmlgraph/repositories/shared_cache_memory.py +395 -0
  119. htmlgraph/repositories/track_repository.py +552 -0
  120. htmlgraph/repositories/track_repository_htmlfile.py +619 -0
  121. htmlgraph/repositories/track_repository_memory.py +508 -0
  122. htmlgraph/repositories/track_repository_sqlite.py +711 -0
  123. htmlgraph/sdk/__init__.py +398 -0
  124. htmlgraph/sdk/__init__.pyi +14 -0
  125. htmlgraph/sdk/analytics/__init__.py +19 -0
  126. htmlgraph/sdk/analytics/engine.py +155 -0
  127. htmlgraph/sdk/analytics/helpers.py +178 -0
  128. htmlgraph/sdk/analytics/registry.py +109 -0
  129. htmlgraph/sdk/base.py +484 -0
  130. htmlgraph/sdk/constants.py +216 -0
  131. htmlgraph/sdk/core.pyi +308 -0
  132. htmlgraph/sdk/discovery.py +120 -0
  133. htmlgraph/sdk/help/__init__.py +12 -0
  134. htmlgraph/sdk/help/mixin.py +699 -0
  135. htmlgraph/sdk/mixins/__init__.py +15 -0
  136. htmlgraph/sdk/mixins/attribution.py +113 -0
  137. htmlgraph/sdk/mixins/mixin.py +410 -0
  138. htmlgraph/sdk/operations/__init__.py +12 -0
  139. htmlgraph/sdk/operations/mixin.py +427 -0
  140. htmlgraph/sdk/orchestration/__init__.py +17 -0
  141. htmlgraph/sdk/orchestration/coordinator.py +203 -0
  142. htmlgraph/sdk/orchestration/spawner.py +204 -0
  143. htmlgraph/sdk/planning/__init__.py +19 -0
  144. htmlgraph/sdk/planning/bottlenecks.py +93 -0
  145. htmlgraph/sdk/planning/mixin.py +211 -0
  146. htmlgraph/sdk/planning/parallel.py +186 -0
  147. htmlgraph/sdk/planning/queue.py +210 -0
  148. htmlgraph/sdk/planning/recommendations.py +87 -0
  149. htmlgraph/sdk/planning/smart_planning.py +319 -0
  150. htmlgraph/sdk/session/__init__.py +19 -0
  151. htmlgraph/sdk/session/continuity.py +57 -0
  152. htmlgraph/sdk/session/handoff.py +110 -0
  153. htmlgraph/sdk/session/info.py +309 -0
  154. htmlgraph/sdk/session/manager.py +103 -0
  155. htmlgraph/sdk/strategic/__init__.py +26 -0
  156. htmlgraph/sdk/strategic/mixin.py +563 -0
  157. htmlgraph/server.py +21 -17
  158. htmlgraph/session_warning.py +2 -1
  159. htmlgraph/sessions/handoff.py +4 -3
  160. htmlgraph/system_prompts.py +2 -1
  161. htmlgraph/track_builder.py +2 -1
  162. htmlgraph/transcript.py +2 -1
  163. htmlgraph/watch.py +2 -1
  164. htmlgraph/work_type_utils.py +2 -1
  165. {htmlgraph-0.26.25.dist-info → htmlgraph-0.27.1.dist-info}/METADATA +1 -1
  166. htmlgraph-0.27.1.dist-info/RECORD +332 -0
  167. htmlgraph/sdk.py +0 -3500
  168. htmlgraph-0.26.25.dist-info/RECORD +0 -274
  169. {htmlgraph-0.26.25.data → htmlgraph-0.27.1.data}/data/htmlgraph/dashboard.html +0 -0
  170. {htmlgraph-0.26.25.data → htmlgraph-0.27.1.data}/data/htmlgraph/styles.css +0 -0
  171. {htmlgraph-0.26.25.data → htmlgraph-0.27.1.data}/data/htmlgraph/templates/AGENTS.md.template +0 -0
  172. {htmlgraph-0.26.25.data → htmlgraph-0.27.1.data}/data/htmlgraph/templates/CLAUDE.md.template +0 -0
  173. {htmlgraph-0.26.25.data → htmlgraph-0.27.1.data}/data/htmlgraph/templates/GEMINI.md.template +0 -0
  174. {htmlgraph-0.26.25.dist-info → htmlgraph-0.27.1.dist-info}/WHEEL +0 -0
  175. {htmlgraph-0.26.25.dist-info → htmlgraph-0.27.1.dist-info}/entry_points.txt +0 -0
@@ -1,3 +1,9 @@
1
+ from __future__ import annotations
2
+
3
+ import logging
4
+
5
+ logger = logging.getLogger(__name__)
6
+
1
7
  """
2
8
  Cross-session analytics using Git commits as the continuity spine.
3
9
 
@@ -38,8 +44,6 @@ Example:
38
44
  authors = cross.work_by_author(since_commit="abc123")
39
45
  """
40
46
 
41
- from __future__ import annotations
42
-
43
47
  import subprocess
44
48
  from collections import defaultdict
45
49
  from dataclasses import dataclass
@@ -147,8 +151,8 @@ class CrossSessionAnalytics:
147
151
  ... from_commit="HEAD~10",
148
152
  ... to_commit="HEAD"
149
153
  ... )
150
- >>> print(f"Total events: {report.total_events}")
151
- >>> print(f"Features: {', '.join(report.features)}")
154
+ >>> logger.info(f"Total events: {report.total_events}")
155
+ >>> logger.info(f"Features: {', '.join(report.features)}")
152
156
  """
153
157
  # Get commit list from Git
154
158
  commits = self._get_commits_in_range(from_commit, to_commit)
@@ -273,7 +277,7 @@ class CrossSessionAnalytics:
273
277
 
274
278
  Example:
275
279
  >>> sessions = cross.sessions_for_feature("feature-auth")
276
- >>> print(f"Feature worked on in {len(sessions)} sessions")
280
+ >>> logger.info(f"Feature worked on in {len(sessions)} sessions")
277
281
  """
278
282
  sessions = set()
279
283
 
@@ -320,8 +324,8 @@ class CrossSessionAnalytics:
320
324
 
321
325
  Example:
322
326
  >>> report = cross.feature_cross_session_report("feature-auth")
323
- >>> print(f"Implemented across {len(report.sessions)} sessions")
324
- >>> print(f"Duration: {report.duration_hours:.1f} hours")
327
+ >>> logger.info(f"Implemented across {len(report.sessions)} sessions")
328
+ >>> logger.info(f"Duration: {report.duration_hours:.1f} hours")
325
329
  """
326
330
  sessions = set()
327
331
  commits = set()
@@ -395,7 +399,7 @@ class CrossSessionAnalytics:
395
399
  Example:
396
400
  >>> authors = cross.work_by_author(since_commit="v1.0.0")
397
401
  >>> for email, stats in authors.items():
398
- ... print(f"{email}: {stats['event_count']} events")
402
+ ... logger.info(f"{email}: {stats['event_count']} events")
399
403
  """
400
404
  authors: dict[str, dict[str, Any]] = defaultdict(
401
405
  lambda: {
@@ -476,7 +480,7 @@ class CrossSessionAnalytics:
476
480
 
477
481
  Example:
478
482
  >>> commits = cross.commits_for_session("session-abc")
479
- >>> print(f"Session produced {len(commits)} commits")
483
+ >>> logger.info(f"Session produced {len(commits)} commits")
480
484
  """
481
485
  commits = set()
482
486
 
@@ -1,3 +1,9 @@
1
+ from __future__ import annotations
2
+
3
+ import logging
4
+
5
+ logger = logging.getLogger(__name__)
6
+
1
7
  """
2
8
  Dependency-aware analytics for HtmlGraph.
3
9
 
@@ -9,8 +15,6 @@ Provides advanced graph analysis for project management:
9
15
  - Work prioritization
10
16
  """
11
17
 
12
- from __future__ import annotations
13
-
14
18
  from collections import deque
15
19
  from typing import TYPE_CHECKING
16
20
 
@@ -55,12 +59,12 @@ class DependencyAnalytics:
55
59
  # Find bottlenecks (cached internally for performance)
56
60
  bottlenecks = dep.find_bottlenecks(top_n=5)
57
61
  for bn in bottlenecks:
58
- print(f"{bn.title} blocks {bn.transitive_blocking} features")
62
+ logger.info(f"{bn.title} blocks {bn.transitive_blocking} features")
59
63
 
60
64
  # Get work recommendations (reuses cached data)
61
65
  recs = dep.recommend_next_tasks(agent_count=3)
62
66
  for rec in recs.recommendations:
63
- print(f"Work on: {rec.title} (unlocks {len(rec.unlocks)} features)")
67
+ logger.info(f"Work on: {rec.title} (unlocks {len(rec.unlocks)} features)")
64
68
 
65
69
  # After making graph changes, invalidate cache
66
70
  sdk.features.update(feature_id, status="done")
@@ -201,7 +205,7 @@ class DependencyAnalytics:
201
205
 
202
206
  Example:
203
207
  report = dep.find_parallelizable_work(status="todo")
204
- print(f"Can work on {report.max_parallelism} features in parallel")
208
+ logger.info(f"Can work on {report.max_parallelism} features in parallel")
205
209
  """
206
210
  # Get dependency levels (topological layers)
207
211
  levels = self.dependency_levels(status_filter=[status])
@@ -456,7 +460,7 @@ class DependencyAnalytics:
456
460
  Example:
457
461
  recs = dep.recommend_next_tasks(agent_count=3)
458
462
  for rec in recs.recommendations:
459
- print(f"Work on: {rec.title}")
463
+ logger.info(f"Work on: {rec.title}")
460
464
  """
461
465
  # Get all nodes with target status
462
466
  candidates = [n for n in self.graph.nodes.values() if n.status == status]
@@ -0,0 +1,80 @@
1
+ """
2
+ Strategic Analytics - Phase 3: Pattern Detection & Smart Suggestions
3
+
4
+ This module provides intelligent pattern detection and suggestion systems
5
+ that learn from user delegation patterns and make smart suggestions.
6
+
7
+ Key Components:
8
+ 1. PatternDetector - Detects tool sequences, delegation chains, error patterns
9
+ 2. SuggestionEngine - Generates context-aware suggestions with ranking
10
+ 3. PreferenceManager - Learns user preferences from feedback
11
+ 4. CostOptimizer - Suggests token budgets, parallelization, model selection
12
+
13
+ Usage:
14
+ from htmlgraph.analytics.strategic import (
15
+ PatternDetector,
16
+ SuggestionEngine,
17
+ PreferenceManager,
18
+ CostOptimizer,
19
+ )
20
+
21
+ # Detect patterns from event history
22
+ detector = PatternDetector(db_path)
23
+ patterns = detector.detect_all_patterns()
24
+
25
+ # Get suggestions for current context
26
+ engine = SuggestionEngine(db_path)
27
+ suggestions = engine.suggest(context)
28
+
29
+ # Learn from feedback
30
+ manager = PreferenceManager(db_path)
31
+ manager.record_feedback(suggestion_id, accepted=True)
32
+ """
33
+
34
+ from htmlgraph.analytics.strategic.cost_optimizer import (
35
+ CostOptimizer,
36
+ ModelRecommendation,
37
+ ParallelizationStrategy,
38
+ TokenBudget,
39
+ )
40
+ from htmlgraph.analytics.strategic.pattern_detector import (
41
+ DelegationChain,
42
+ ErrorPattern,
43
+ Pattern,
44
+ PatternDetector,
45
+ PatternType,
46
+ ToolSequencePattern,
47
+ )
48
+ from htmlgraph.analytics.strategic.preference_manager import (
49
+ Feedback,
50
+ PreferenceManager,
51
+ UserPreferences,
52
+ )
53
+ from htmlgraph.analytics.strategic.suggestion_engine import (
54
+ Suggestion,
55
+ SuggestionEngine,
56
+ SuggestionType,
57
+ )
58
+
59
+ __all__ = [
60
+ # Pattern Detection
61
+ "PatternDetector",
62
+ "Pattern",
63
+ "PatternType",
64
+ "ToolSequencePattern",
65
+ "DelegationChain",
66
+ "ErrorPattern",
67
+ # Suggestion Engine
68
+ "SuggestionEngine",
69
+ "Suggestion",
70
+ "SuggestionType",
71
+ # Preference Manager
72
+ "PreferenceManager",
73
+ "UserPreferences",
74
+ "Feedback",
75
+ # Cost Optimizer
76
+ "CostOptimizer",
77
+ "TokenBudget",
78
+ "ParallelizationStrategy",
79
+ "ModelRecommendation",
80
+ ]