htmlgraph 0.26.25__py3-none-any.whl → 0.27.0__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 (147) 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/cross_session.py +13 -9
  7. htmlgraph/analytics/dependency.py +10 -6
  8. htmlgraph/analytics/work_type.py +15 -11
  9. htmlgraph/analytics_index.py +2 -1
  10. htmlgraph/api/main.py +58 -28
  11. htmlgraph/attribute_index.py +2 -1
  12. htmlgraph/builders/base.py +2 -1
  13. htmlgraph/builders/bug.py +2 -1
  14. htmlgraph/builders/chore.py +2 -1
  15. htmlgraph/builders/epic.py +2 -1
  16. htmlgraph/builders/feature.py +2 -1
  17. htmlgraph/builders/insight.py +2 -1
  18. htmlgraph/builders/metric.py +2 -1
  19. htmlgraph/builders/pattern.py +2 -1
  20. htmlgraph/builders/phase.py +2 -1
  21. htmlgraph/builders/spike.py +2 -1
  22. htmlgraph/builders/track.py +2 -1
  23. htmlgraph/cli/analytics.py +2 -1
  24. htmlgraph/cli/base.py +2 -1
  25. htmlgraph/cli/core.py +2 -1
  26. htmlgraph/cli/main.py +2 -1
  27. htmlgraph/cli/models.py +2 -1
  28. htmlgraph/cli/templates/cost_dashboard.py +2 -1
  29. htmlgraph/cli/work/__init__.py +2 -1
  30. htmlgraph/cli/work/browse.py +2 -1
  31. htmlgraph/cli/work/features.py +2 -1
  32. htmlgraph/cli/work/orchestration.py +2 -1
  33. htmlgraph/cli/work/report.py +2 -1
  34. htmlgraph/cli/work/sessions.py +2 -1
  35. htmlgraph/cli/work/snapshot.py +2 -1
  36. htmlgraph/cli/work/tracks.py +2 -1
  37. htmlgraph/collections/base.py +10 -5
  38. htmlgraph/collections/bug.py +2 -1
  39. htmlgraph/collections/chore.py +2 -1
  40. htmlgraph/collections/epic.py +2 -1
  41. htmlgraph/collections/feature.py +2 -1
  42. htmlgraph/collections/insight.py +2 -1
  43. htmlgraph/collections/metric.py +2 -1
  44. htmlgraph/collections/pattern.py +2 -1
  45. htmlgraph/collections/phase.py +2 -1
  46. htmlgraph/collections/session.py +12 -7
  47. htmlgraph/collections/spike.py +6 -1
  48. htmlgraph/collections/task_delegation.py +7 -2
  49. htmlgraph/collections/todo.py +2 -1
  50. htmlgraph/collections/traces.py +15 -10
  51. htmlgraph/context_analytics.py +2 -1
  52. htmlgraph/dependency_models.py +2 -1
  53. htmlgraph/edge_index.py +2 -1
  54. htmlgraph/event_log.py +81 -66
  55. htmlgraph/event_migration.py +2 -1
  56. htmlgraph/file_watcher.py +12 -8
  57. htmlgraph/find_api.py +2 -1
  58. htmlgraph/git_events.py +6 -2
  59. htmlgraph/hooks/cigs_pretool_enforcer.py +5 -1
  60. htmlgraph/hooks/drift_handler.py +3 -3
  61. htmlgraph/hooks/event_tracker.py +40 -61
  62. htmlgraph/hooks/installer.py +5 -1
  63. htmlgraph/hooks/orchestrator.py +4 -0
  64. htmlgraph/hooks/orchestrator_reflector.py +4 -0
  65. htmlgraph/hooks/post_tool_use_failure.py +7 -3
  66. htmlgraph/hooks/posttooluse.py +4 -0
  67. htmlgraph/hooks/prompt_analyzer.py +5 -5
  68. htmlgraph/hooks/session_handler.py +2 -1
  69. htmlgraph/hooks/session_summary.py +6 -2
  70. htmlgraph/hooks/validator.py +8 -4
  71. htmlgraph/ids.py +2 -1
  72. htmlgraph/learning.py +2 -1
  73. htmlgraph/mcp_server.py +2 -1
  74. htmlgraph/operations/analytics.py +2 -1
  75. htmlgraph/operations/bootstrap.py +2 -1
  76. htmlgraph/operations/events.py +2 -1
  77. htmlgraph/operations/fastapi_server.py +2 -1
  78. htmlgraph/operations/hooks.py +2 -1
  79. htmlgraph/operations/initialization.py +2 -1
  80. htmlgraph/operations/server.py +2 -1
  81. htmlgraph/orchestration/claude_launcher.py +23 -20
  82. htmlgraph/orchestration/command_builder.py +2 -1
  83. htmlgraph/orchestration/headless_spawner.py +6 -2
  84. htmlgraph/orchestration/model_selection.py +7 -3
  85. htmlgraph/orchestration/plugin_manager.py +24 -19
  86. htmlgraph/orchestration/spawners/claude.py +5 -2
  87. htmlgraph/orchestration/spawners/codex.py +12 -19
  88. htmlgraph/orchestration/spawners/copilot.py +13 -18
  89. htmlgraph/orchestration/spawners/gemini.py +12 -19
  90. htmlgraph/orchestration/subprocess_runner.py +6 -3
  91. htmlgraph/orchestration/task_coordination.py +16 -8
  92. htmlgraph/orchestrator.py +2 -1
  93. htmlgraph/parallel.py +2 -1
  94. htmlgraph/query_builder.py +2 -1
  95. htmlgraph/reflection.py +2 -1
  96. htmlgraph/refs.py +2 -1
  97. htmlgraph/repo_hash.py +2 -1
  98. htmlgraph/sdk/__init__.py +398 -0
  99. htmlgraph/sdk/__init__.pyi +14 -0
  100. htmlgraph/sdk/analytics/__init__.py +19 -0
  101. htmlgraph/sdk/analytics/engine.py +155 -0
  102. htmlgraph/sdk/analytics/helpers.py +178 -0
  103. htmlgraph/sdk/analytics/registry.py +109 -0
  104. htmlgraph/sdk/base.py +484 -0
  105. htmlgraph/sdk/constants.py +216 -0
  106. htmlgraph/sdk/core.pyi +308 -0
  107. htmlgraph/sdk/discovery.py +120 -0
  108. htmlgraph/sdk/help/__init__.py +12 -0
  109. htmlgraph/sdk/help/mixin.py +699 -0
  110. htmlgraph/sdk/mixins/__init__.py +15 -0
  111. htmlgraph/sdk/mixins/attribution.py +113 -0
  112. htmlgraph/sdk/mixins/mixin.py +410 -0
  113. htmlgraph/sdk/operations/__init__.py +12 -0
  114. htmlgraph/sdk/operations/mixin.py +427 -0
  115. htmlgraph/sdk/orchestration/__init__.py +17 -0
  116. htmlgraph/sdk/orchestration/coordinator.py +203 -0
  117. htmlgraph/sdk/orchestration/spawner.py +204 -0
  118. htmlgraph/sdk/planning/__init__.py +19 -0
  119. htmlgraph/sdk/planning/bottlenecks.py +93 -0
  120. htmlgraph/sdk/planning/mixin.py +211 -0
  121. htmlgraph/sdk/planning/parallel.py +186 -0
  122. htmlgraph/sdk/planning/queue.py +210 -0
  123. htmlgraph/sdk/planning/recommendations.py +87 -0
  124. htmlgraph/sdk/planning/smart_planning.py +319 -0
  125. htmlgraph/sdk/session/__init__.py +19 -0
  126. htmlgraph/sdk/session/continuity.py +57 -0
  127. htmlgraph/sdk/session/handoff.py +110 -0
  128. htmlgraph/sdk/session/info.py +309 -0
  129. htmlgraph/sdk/session/manager.py +103 -0
  130. htmlgraph/server.py +21 -17
  131. htmlgraph/session_warning.py +2 -1
  132. htmlgraph/sessions/handoff.py +4 -3
  133. htmlgraph/system_prompts.py +2 -1
  134. htmlgraph/track_builder.py +2 -1
  135. htmlgraph/transcript.py +2 -1
  136. htmlgraph/watch.py +2 -1
  137. htmlgraph/work_type_utils.py +2 -1
  138. {htmlgraph-0.26.25.dist-info → htmlgraph-0.27.0.dist-info}/METADATA +15 -1
  139. {htmlgraph-0.26.25.dist-info → htmlgraph-0.27.0.dist-info}/RECORD +146 -114
  140. htmlgraph/sdk.py +0 -3500
  141. {htmlgraph-0.26.25.data → htmlgraph-0.27.0.data}/data/htmlgraph/dashboard.html +0 -0
  142. {htmlgraph-0.26.25.data → htmlgraph-0.27.0.data}/data/htmlgraph/styles.css +0 -0
  143. {htmlgraph-0.26.25.data → htmlgraph-0.27.0.data}/data/htmlgraph/templates/AGENTS.md.template +0 -0
  144. {htmlgraph-0.26.25.data → htmlgraph-0.27.0.data}/data/htmlgraph/templates/CLAUDE.md.template +0 -0
  145. {htmlgraph-0.26.25.data → htmlgraph-0.27.0.data}/data/htmlgraph/templates/GEMINI.md.template +0 -0
  146. {htmlgraph-0.26.25.dist-info → htmlgraph-0.27.0.dist-info}/WHEEL +0 -0
  147. {htmlgraph-0.26.25.dist-info → htmlgraph-0.27.0.dist-info}/entry_points.txt +0 -0
@@ -1,3 +1,5 @@
1
+ from __future__ import annotations
2
+
1
3
  """
2
4
  Chore builder for creating maintenance task nodes.
3
5
 
@@ -5,7 +7,6 @@ Extends BaseBuilder with chore-specific methods like
5
7
  chore type and recurrence.
6
8
  """
7
9
 
8
- from __future__ import annotations
9
10
 
10
11
  from typing import TYPE_CHECKING, Any
11
12
 
@@ -1,3 +1,5 @@
1
+ from __future__ import annotations
2
+
1
3
  """
2
4
  Epic builder for creating large body of work nodes.
3
5
 
@@ -5,7 +7,6 @@ Extends BaseBuilder with epic-specific methods like
5
7
  child features and milestones.
6
8
  """
7
9
 
8
- from __future__ import annotations
9
10
 
10
11
  from datetime import date
11
12
  from typing import TYPE_CHECKING, Any
@@ -1,3 +1,5 @@
1
+ from __future__ import annotations
2
+
1
3
  """
2
4
  Feature builder for creating feature nodes.
3
5
 
@@ -5,7 +7,6 @@ Extends BaseBuilder with feature-specific methods like
5
7
  capability management.
6
8
  """
7
9
 
8
- from __future__ import annotations
9
10
 
10
11
  from typing import TYPE_CHECKING, Any
11
12
 
@@ -1,3 +1,5 @@
1
+ from __future__ import annotations
2
+
1
3
  """
2
4
  Insight builder for creating session insight nodes.
3
5
 
@@ -5,7 +7,6 @@ Extends BaseBuilder with insight-specific methods for
5
7
  session health scoring and pattern detection.
6
8
  """
7
9
 
8
- from __future__ import annotations
9
10
 
10
11
  from typing import TYPE_CHECKING, Any
11
12
 
@@ -1,3 +1,5 @@
1
+ from __future__ import annotations
2
+
1
3
  """
2
4
  Metric builder for creating aggregated metric nodes.
3
5
 
@@ -5,7 +7,6 @@ Extends BaseBuilder with metric-specific methods for
5
7
  time-series aggregation and trend analysis.
6
8
  """
7
9
 
8
- from __future__ import annotations
9
10
 
10
11
  from datetime import datetime
11
12
  from typing import TYPE_CHECKING, Any
@@ -1,3 +1,5 @@
1
+ from __future__ import annotations
2
+
1
3
  """
2
4
  Pattern builder for creating workflow pattern nodes.
3
5
 
@@ -5,7 +7,6 @@ Extends BaseBuilder with pattern-specific methods for
5
7
  tracking optimal and anti-pattern tool sequences.
6
8
  """
7
9
 
8
- from __future__ import annotations
9
10
 
10
11
  from datetime import datetime
11
12
  from typing import TYPE_CHECKING, Any
@@ -1,3 +1,5 @@
1
+ from __future__ import annotations
2
+
1
3
  """
2
4
  Phase builder for creating project phase nodes.
3
5
 
@@ -5,7 +7,6 @@ Extends BaseBuilder with phase-specific methods like
5
7
  phase ordering and dependencies.
6
8
  """
7
9
 
8
- from __future__ import annotations
9
10
 
10
11
  from datetime import date
11
12
  from typing import TYPE_CHECKING, Any
@@ -1,3 +1,5 @@
1
+ from __future__ import annotations
2
+
1
3
  """
2
4
  Spike builder for creating spike investigation nodes.
3
5
 
@@ -5,7 +7,6 @@ Extends BaseBuilder with spike-specific methods like
5
7
  spike_type and timebox_hours.
6
8
  """
7
9
 
8
- from __future__ import annotations
9
10
 
10
11
  from typing import TYPE_CHECKING, Any
11
12
 
@@ -1,8 +1,9 @@
1
+ from __future__ import annotations
2
+
1
3
  """
2
4
  Track Builder for agent-friendly track creation.
3
5
  """
4
6
 
5
- from __future__ import annotations
6
7
 
7
8
  import re
8
9
  from datetime import datetime
@@ -1,3 +1,5 @@
1
+ from __future__ import annotations
2
+
1
3
  """HtmlGraph CLI - Analytics and reporting commands.
2
4
 
3
5
  Commands for analytics and reporting:
@@ -7,7 +9,6 @@ Commands for analytics and reporting:
7
9
  - sync-docs: Documentation synchronization
8
10
  """
9
11
 
10
- from __future__ import annotations
11
12
 
12
13
  import argparse
13
14
  import json
htmlgraph/cli/base.py CHANGED
@@ -1,3 +1,5 @@
1
+ from __future__ import annotations
2
+
1
3
  """Base classes and utilities for CLI commands.
2
4
 
3
5
  Provides:
@@ -10,7 +12,6 @@ Provides:
10
12
  - save_traceback: Save full tracebacks to log files instead of console
11
13
  """
12
14
 
13
- from __future__ import annotations
14
15
 
15
16
  import argparse
16
17
  import json
htmlgraph/cli/core.py CHANGED
@@ -1,3 +1,5 @@
1
+ from __future__ import annotations
2
+
1
3
  """HtmlGraph CLI - Infrastructure commands.
2
4
 
3
5
  Commands for core infrastructure operations:
@@ -11,7 +13,6 @@ Commands for core infrastructure operations:
11
13
  - Other utilities
12
14
  """
13
15
 
14
- from __future__ import annotations
15
16
 
16
17
  import argparse
17
18
  import sys
htmlgraph/cli/main.py CHANGED
@@ -1,10 +1,11 @@
1
+ from __future__ import annotations
2
+
1
3
  """HtmlGraph CLI - Main entry point.
2
4
 
3
5
  Entry point with argument parsing and command routing.
4
6
  Keeps main() thin by delegating to command modules.
5
7
  """
6
8
 
7
- from __future__ import annotations
8
9
 
9
10
  import argparse
10
11
  import sys
htmlgraph/cli/models.py CHANGED
@@ -1,3 +1,5 @@
1
+ from __future__ import annotations
2
+
1
3
  """HtmlGraph CLI - Pydantic models for command filters and configuration.
2
4
 
3
5
  This module provides type-safe models for validating command inputs:
@@ -5,7 +7,6 @@ This module provides type-safe models for validating command inputs:
5
7
  - Configuration models for infrastructure commands (init, serve)
6
8
  """
7
9
 
8
- from __future__ import annotations
9
10
 
10
11
  from datetime import datetime
11
12
  from typing import Literal
@@ -1,10 +1,11 @@
1
+ from __future__ import annotations
2
+
1
3
  """HTML template for cost dashboard.
2
4
 
3
5
  This module generates a beautiful, interactive HTML dashboard for cost analysis.
4
6
  Separated from main CLI code for maintainability and testability.
5
7
  """
6
8
 
7
- from __future__ import annotations
8
9
 
9
10
  from datetime import datetime
10
11
  from typing import TYPE_CHECKING, Any
@@ -1,3 +1,5 @@
1
+ from __future__ import annotations
2
+
1
3
  """HtmlGraph CLI - Work management commands.
2
4
 
3
5
  Commands for managing work items:
@@ -9,7 +11,6 @@ Commands for managing work items:
9
11
  - Other work-related operations
10
12
  """
11
13
 
12
- from __future__ import annotations
13
14
 
14
15
  from typing import TYPE_CHECKING
15
16
 
@@ -1,6 +1,7 @@
1
+ from __future__ import annotations
2
+
1
3
  """HtmlGraph CLI - Browse command for opening dashboard in browser."""
2
4
 
3
- from __future__ import annotations
4
5
 
5
6
  import argparse
6
7
  import webbrowser
@@ -1,6 +1,7 @@
1
+ from __future__ import annotations
2
+
1
3
  """HtmlGraph CLI - Feature management commands."""
2
4
 
3
- from __future__ import annotations
4
5
 
5
6
  import argparse
6
7
  from typing import TYPE_CHECKING
@@ -1,6 +1,7 @@
1
+ from __future__ import annotations
2
+
1
3
  """HtmlGraph CLI - Orchestration commands (Archive, Orchestrator, Claude)."""
2
4
 
3
- from __future__ import annotations
4
5
 
5
6
  import argparse
6
7
  from datetime import datetime
@@ -1,3 +1,5 @@
1
+ from __future__ import annotations
2
+
1
3
  """HtmlGraph CLI - Session report commands.
2
4
 
3
5
  Commands for generating "What Did Claude Do?" reports:
@@ -7,7 +9,6 @@ THE killer feature that differentiates HtmlGraph - complete observability
7
9
  of AI agent activities with cost attribution and tool usage analysis.
8
10
  """
9
11
 
10
- from __future__ import annotations
11
12
 
12
13
  import argparse
13
14
  import sqlite3
@@ -1,6 +1,7 @@
1
+ from __future__ import annotations
2
+
1
3
  """HtmlGraph CLI - Session management commands."""
2
4
 
3
- from __future__ import annotations
4
5
 
5
6
  import argparse
6
7
  from typing import TYPE_CHECKING
@@ -1,6 +1,7 @@
1
+ from __future__ import annotations
2
+
1
3
  """HtmlGraph CLI - Snapshot command for graph state visualization."""
2
4
 
3
- from __future__ import annotations
4
5
 
5
6
  import argparse
6
7
  import json
@@ -1,6 +1,7 @@
1
+ from __future__ import annotations
2
+
1
3
  """HtmlGraph CLI - Track management commands."""
2
4
 
3
- from __future__ import annotations
4
5
 
5
6
  import argparse
6
7
  from pathlib import Path
@@ -1,3 +1,9 @@
1
+ from __future__ import annotations
2
+
3
+ import logging
4
+
5
+ logger = logging.getLogger(__name__)
6
+
1
7
  """
2
8
  Base collection class for managing nodes.
3
9
 
@@ -5,7 +11,6 @@ Provides common collection functionality for all node types
5
11
  with lazy-loading, filtering, and batch operations.
6
12
  """
7
13
 
8
- from __future__ import annotations
9
14
 
10
15
  from collections.abc import Callable, Iterator
11
16
  from contextlib import contextmanager
@@ -227,7 +232,7 @@ class BaseCollection(Generic[CollectionT]):
227
232
  Example:
228
233
  >>> feature = sdk.features.get("feat-abc123")
229
234
  >>> ref = sdk.features.get_ref(feature.id)
230
- >>> print(ref) # "@f1"
235
+ >>> logger.info("%s", ref) # "@f1"
231
236
  """
232
237
  if self._ref_manager:
233
238
  result = self._ref_manager.get_ref(node_id)
@@ -466,7 +471,7 @@ class BaseCollection(Generic[CollectionT]):
466
471
 
467
472
  Example:
468
473
  >>> count = sdk.features.batch_delete(["feat-001", "feat-002", "feat-003"])
469
- >>> print(f"Deleted {count} features")
474
+ >>> logger.info(f"Deleted {count} features")
470
475
  """
471
476
  graph = self._ensure_graph()
472
477
  return cast(int, graph.batch_delete(node_ids))
@@ -540,9 +545,9 @@ class BaseCollection(Generic[CollectionT]):
540
545
 
541
546
  Example:
542
547
  >>> result = sdk.features.mark_done(["feat-001", "feat-002"])
543
- >>> print(f"Completed {result['success_count']} of {len(node_ids)}")
548
+ >>> logger.info(f"Completed {result['success_count']} of {len(node_ids)}")
544
549
  >>> if result['failed_ids']:
545
- ... print(f"Failed: {result['failed_ids']}")
550
+ ... logger.info(f"Failed: {result['failed_ids']}")
546
551
  """
547
552
  graph = self._ensure_graph()
548
553
  results: dict[str, Any] = {"success_count": 0, "failed_ids": [], "warnings": []}
@@ -1,10 +1,11 @@
1
+ from __future__ import annotations
2
+
1
3
  """
2
4
  Bug collection for managing bug report work items.
3
5
 
4
6
  Extends BaseCollection with bug-specific builder support.
5
7
  """
6
8
 
7
- from __future__ import annotations
8
9
 
9
10
  from typing import TYPE_CHECKING
10
11
 
@@ -1,10 +1,11 @@
1
+ from __future__ import annotations
2
+
1
3
  """
2
4
  Chore collection for managing maintenance task work items.
3
5
 
4
6
  Extends BaseCollection with chore-specific builder support.
5
7
  """
6
8
 
7
- from __future__ import annotations
8
9
 
9
10
  from typing import TYPE_CHECKING
10
11
 
@@ -1,10 +1,11 @@
1
+ from __future__ import annotations
2
+
1
3
  """
2
4
  Epic collection for managing large body of work items.
3
5
 
4
6
  Extends BaseCollection with epic-specific builder support.
5
7
  """
6
8
 
7
- from __future__ import annotations
8
9
 
9
10
  from typing import TYPE_CHECKING
10
11
 
@@ -1,10 +1,11 @@
1
+ from __future__ import annotations
2
+
1
3
  """
2
4
  Feature collection for managing feature work items.
3
5
 
4
6
  Extends BaseCollection with feature-specific builder support.
5
7
  """
6
8
 
7
- from __future__ import annotations
8
9
 
9
10
  from typing import TYPE_CHECKING
10
11
 
@@ -1,10 +1,11 @@
1
+ from __future__ import annotations
2
+
1
3
  """
2
4
  SessionInsight collection for managing session insights.
3
5
 
4
6
  Extends BaseCollection with insight-specific query methods.
5
7
  """
6
8
 
7
- from __future__ import annotations
8
9
 
9
10
  from typing import TYPE_CHECKING
10
11
 
@@ -1,10 +1,11 @@
1
+ from __future__ import annotations
2
+
1
3
  """
2
4
  AggregatedMetric collection for managing aggregated metrics.
3
5
 
4
6
  Extends BaseCollection with metric-specific query methods.
5
7
  """
6
8
 
7
- from __future__ import annotations
8
9
 
9
10
  from typing import TYPE_CHECKING
10
11
 
@@ -1,10 +1,11 @@
1
+ from __future__ import annotations
2
+
1
3
  """
2
4
  Pattern collection for managing workflow patterns.
3
5
 
4
6
  Extends BaseCollection with pattern-specific query methods.
5
7
  """
6
8
 
7
- from __future__ import annotations
8
9
 
9
10
  from typing import TYPE_CHECKING
10
11
 
@@ -1,10 +1,11 @@
1
+ from __future__ import annotations
2
+
1
3
  """
2
4
  Phase collection for managing project phase work items.
3
5
 
4
6
  Extends BaseCollection with phase-specific builder support.
5
7
  """
6
8
 
7
- from __future__ import annotations
8
9
 
9
10
  from typing import TYPE_CHECKING
10
11
 
@@ -1,3 +1,9 @@
1
+ from __future__ import annotations
2
+
3
+ import logging
4
+
5
+ logger = logging.getLogger(__name__)
6
+
1
7
  """
2
8
  SessionCollection - Session state and management interface.
3
9
 
@@ -13,7 +19,6 @@ Integration with SessionStart hook:
13
19
  sdk.sessions.setup_environment_variables(state)
14
20
  """
15
21
 
16
- from __future__ import annotations
17
22
 
18
23
  from typing import TYPE_CHECKING
19
24
 
@@ -82,9 +87,9 @@ class SessionCollection(BaseCollection):
82
87
  Example:
83
88
  >>> sdk = SDK()
84
89
  >>> state = sdk.sessions.get_current_state()
85
- >>> print(f"Session: {state['session_id']}")
86
- >>> print(f"Post-compact: {state['is_post_compact']}")
87
- >>> print(f"Delegation enabled: {state['delegation_enabled']}")
90
+ >>> logger.info(f"Session: {state['session_id']}")
91
+ >>> logger.info(f"Post-compact: {state['is_post_compact']}")
92
+ >>> logger.info(f"Delegation enabled: {state['delegation_enabled']}")
88
93
  """
89
94
  return self._state_manager.get_current_state()
90
95
 
@@ -116,8 +121,8 @@ class SessionCollection(BaseCollection):
116
121
  >>> sdk = SDK()
117
122
  >>> state = sdk.sessions.get_current_state()
118
123
  >>> env_vars = sdk.sessions.setup_environment_variables(state)
119
- >>> print(f"CLAUDE_SESSION_ID: {env_vars['CLAUDE_SESSION_ID']}")
120
- >>> print(f"CLAUDE_DELEGATION_ENABLED: {env_vars['CLAUDE_DELEGATION_ENABLED']}")
124
+ >>> logger.info(f"CLAUDE_SESSION_ID: {env_vars['CLAUDE_SESSION_ID']}")
125
+ >>> logger.info(f"CLAUDE_DELEGATION_ENABLED: {env_vars['CLAUDE_DELEGATION_ENABLED']}")
121
126
  """
122
127
  return self._state_manager.setup_environment_variables(
123
128
  session_state=session_state, auto_detect_compact=auto_detect_compact
@@ -168,7 +173,7 @@ class SessionCollection(BaseCollection):
168
173
  Example:
169
174
  >>> sdk = SDK()
170
175
  >>> if sdk.sessions.detect_compact_automatically():
171
- ... print("This is a post-compact session")
176
+ ... logger.info("This is a post-compact session")
172
177
  """
173
178
  return self._state_manager.detect_compact_automatically()
174
179
 
@@ -1,10 +1,15 @@
1
+ from __future__ import annotations
2
+
3
+ import logging
4
+
5
+ logger = logging.getLogger(__name__)
6
+
1
7
  """
2
8
  Spike collection for managing investigation and research spikes.
3
9
 
4
10
  Extends BaseCollection with spike-specific builder support.
5
11
  """
6
12
 
7
- from __future__ import annotations
8
13
 
9
14
  from datetime import datetime
10
15
  from typing import TYPE_CHECKING
@@ -1,3 +1,9 @@
1
+ from __future__ import annotations
2
+
3
+ import logging
4
+
5
+ logger = logging.getLogger(__name__)
6
+
1
7
  """
2
8
  Task delegation collection for tracking spawned agent work.
3
9
 
@@ -12,7 +18,6 @@ Captures observability data for Task() calls:
12
18
  This data proves multi-agent orchestration works and enables dashboard attribution.
13
19
  """
14
20
 
15
- from __future__ import annotations
16
21
 
17
22
  from datetime import datetime
18
23
  from typing import TYPE_CHECKING, Any
@@ -41,7 +46,7 @@ class TaskDelegationCollection(BaseCollection["TaskDelegationCollection"]):
41
46
  >>> sdk = SDK(agent="orchestrator")
42
47
  >>> delegations = sdk.task_delegations.where(agent_type="codex-spawner")
43
48
  >>> for d in delegations:
44
- ... print(f"{d.agent_type}: {d.task_description} ({d.duration_seconds}s)")
49
+ ... logger.info(f"{d.agent_type}: {d.task_description} ({d.duration_seconds}s)")
45
50
  >>>
46
51
  >>> # Get all delegations for a specific agent
47
52
  >>> gemini_work = sdk.task_delegations.where(agent_type="gemini-spawner")
@@ -1,3 +1,5 @@
1
+ from __future__ import annotations
2
+
1
3
  """
2
4
  Todo collection for managing persistent todo items.
3
5
 
@@ -8,7 +10,6 @@ Unlike other collections, TodoCollection provides:
8
10
  - Bulk sync from TodoWrite format
9
11
  """
10
12
 
11
- from __future__ import annotations
12
13
 
13
14
  from datetime import datetime
14
15
  from typing import TYPE_CHECKING, Any
@@ -1,3 +1,9 @@
1
+ from __future__ import annotations
2
+
3
+ import logging
4
+
5
+ logger = logging.getLogger(__name__)
6
+
1
7
  """
2
8
  Tool Execution Traces Collection
3
9
 
@@ -11,21 +17,20 @@ Example:
11
17
  >>> # Get traces for current session
12
18
  >>> traces = sdk.traces.get_traces(session_id="sess-abc123")
13
19
  >>> for trace in traces:
14
- ... print(f"{trace.tool_name}: {trace.duration_ms}ms")
20
+ ... logger.info(f"{trace.tool_name}: {trace.duration_ms}ms")
15
21
  >>>
16
22
  >>> # Find slow tool calls
17
23
  >>> slow = sdk.traces.get_slow_traces(threshold_ms=1000)
18
24
  >>>
19
25
  >>> # Get hierarchical view (parent-child relationships)
20
26
  >>> tree = sdk.traces.get_trace_tree(trace_id="trace-xyz")
21
- >>> print(f"Root: {tree.root.tool_name}")
22
- >>> print(f"Children: {len(tree.children)}")
27
+ >>> logger.info(f"Root: {tree.root.tool_name}")
28
+ >>> logger.info(f"Children: {len(tree.children)}")
23
29
  >>>
24
30
  >>> # Get error traces for debugging
25
31
  >>> errors = sdk.traces.get_error_traces(session_id="sess-abc123")
26
32
  """
27
33
 
28
- from __future__ import annotations
29
34
 
30
35
  from dataclasses import dataclass
31
36
  from datetime import datetime, timezone
@@ -245,7 +250,7 @@ class TraceCollection:
245
250
 
246
251
  return None
247
252
  except Exception as e:
248
- print(f"Error getting trace {tool_use_id}: {e}")
253
+ logger.info(f"Error getting trace {tool_use_id}: {e}")
249
254
  return None
250
255
 
251
256
  def get_traces(
@@ -302,7 +307,7 @@ class TraceCollection:
302
307
  rows = cursor.fetchall()
303
308
  return [self._row_to_trace(row) for row in rows]
304
309
  except Exception as e:
305
- print(f"Error getting traces for session {session_id}: {e}")
310
+ logger.info(f"Error getting traces for session {session_id}: {e}")
306
311
  return []
307
312
 
308
313
  def get_traces_by_tool(self, tool_name: str, limit: int = 100) -> list[TraceRecord]:
@@ -337,7 +342,7 @@ class TraceCollection:
337
342
  rows = cursor.fetchall()
338
343
  return [self._row_to_trace(row) for row in rows]
339
344
  except Exception as e:
340
- print(f"Error getting traces for tool {tool_name}: {e}")
345
+ logger.info(f"Error getting traces for tool {tool_name}: {e}")
341
346
  return []
342
347
 
343
348
  def get_trace_tree(self, trace_id: str) -> TraceTree | None:
@@ -403,7 +408,7 @@ class TraceCollection:
403
408
 
404
409
  return build_tree(root)
405
410
  except Exception as e:
406
- print(f"Error getting trace tree for {trace_id}: {e}")
411
+ logger.info(f"Error getting trace tree for {trace_id}: {e}")
407
412
  return None
408
413
 
409
414
  def get_slow_traces(self, threshold_ms: int, limit: int = 100) -> list[TraceRecord]:
@@ -440,7 +445,7 @@ class TraceCollection:
440
445
  rows = cursor.fetchall()
441
446
  return [self._row_to_trace(row) for row in rows]
442
447
  except Exception as e:
443
- print(f"Error getting slow traces: {e}")
448
+ logger.info(f"Error getting slow traces: {e}")
444
449
  return []
445
450
 
446
451
  def get_error_traces(self, session_id: str, limit: int = 100) -> list[TraceRecord]:
@@ -478,5 +483,5 @@ class TraceCollection:
478
483
  rows = cursor.fetchall()
479
484
  return [self._row_to_trace(row) for row in rows]
480
485
  except Exception as e:
481
- print(f"Error getting error traces: {e}")
486
+ logger.info(f"Error getting error traces: {e}")
482
487
  return []
@@ -1,3 +1,5 @@
1
+ from __future__ import annotations
2
+
1
3
  """
2
4
  Context Analytics for HtmlGraph
3
5
 
@@ -7,7 +9,6 @@ Provides hierarchical context usage tracking and analytics:
7
9
  Enables drill-down analysis of where context was consumed.
8
10
  """
9
11
 
10
- from __future__ import annotations
11
12
 
12
13
  from dataclasses import dataclass, field
13
14
  from typing import TYPE_CHECKING, Any