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
htmlgraph/__init__.py CHANGED
@@ -5,6 +5,28 @@ 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
8
30
  from htmlgraph.agent_detection import detect_agent_name, get_agent_display_name
9
31
  from htmlgraph.agents import AgentInterface
10
32
  from htmlgraph.analytics import Analytics, DependencyAnalytics
@@ -96,7 +118,7 @@ from htmlgraph.types import (
96
118
  )
97
119
  from htmlgraph.work_type_utils import infer_work_type, infer_work_type_from_id
98
120
 
99
- __version__ = "0.26.25"
121
+ __version__ = "0.27.1"
100
122
  __all__ = [
101
123
  # Exceptions
102
124
  "HtmlGraphError",
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]
@@ -1,3 +1,5 @@
1
+ from __future__ import annotations
2
+
1
3
  """
2
4
  Agent Registry - Manages agent capabilities and routing.
3
5
 
@@ -7,7 +9,6 @@ Provides:
7
9
  - Capability matching for task routing
8
10
  """
9
11
 
10
- from __future__ import annotations
11
12
 
12
13
  import json
13
14
  from dataclasses import dataclass, field
@@ -109,7 +109,7 @@ def _iter_with_progress(
109
109
 
110
110
 
111
111
  def _display_session_analytics(
112
- console: Console, sdk: SDK, session_id: str, graph_dir: str, quiet: bool
112
+ console: Console, sdk: "SDK", session_id: str, graph_dir: str, quiet: bool
113
113
  ) -> None:
114
114
  """Display analytics for a single session."""
115
115
  from htmlgraph.converter import html_to_session
@@ -221,7 +221,7 @@ def _display_session_analytics(
221
221
 
222
222
  def _display_recent_sessions(
223
223
  console: Console,
224
- sdk: SDK,
224
+ sdk: "SDK",
225
225
  session_files: list[Path],
226
226
  graph_dir: str,
227
227
  quiet: bool,
@@ -286,7 +286,7 @@ def _display_recent_sessions(
286
286
 
287
287
  def _display_project_analytics(
288
288
  console: Console,
289
- sdk: SDK,
289
+ sdk: "SDK",
290
290
  session_files: list[Path],
291
291
  graph_dir: str,
292
292
  quiet: bool,
@@ -1,3 +1,7 @@
1
+ import logging
2
+
3
+ logger = logging.getLogger(__name__)
4
+
1
5
  """
2
6
  CostAnalyzer for OTEL ROI Analysis - Phase 1.
3
7
 
@@ -15,7 +19,7 @@ Usage:
15
19
  from htmlgraph.analytics.cost_analyzer import CostAnalyzer
16
20
  analyzer = CostAnalyzer()
17
21
  delegations = analyzer.get_task_delegations_with_costs()
18
- print(f"Total delegation cost: ${delegations['total_cost_usd']:.2f}")
22
+ logger.info(f"Total delegation cost: ${delegations['total_cost_usd']:.2f}")
19
23
  """
20
24
 
21
25
  import sqlite3