shotgun-sh 0.1.14__py3-none-any.whl → 0.2.11__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.

Potentially problematic release.


This version of shotgun-sh might be problematic. Click here for more details.

Files changed (143) hide show
  1. shotgun/agents/agent_manager.py +715 -75
  2. shotgun/agents/common.py +80 -75
  3. shotgun/agents/config/constants.py +21 -10
  4. shotgun/agents/config/manager.py +322 -97
  5. shotgun/agents/config/models.py +114 -84
  6. shotgun/agents/config/provider.py +232 -88
  7. shotgun/agents/context_analyzer/__init__.py +28 -0
  8. shotgun/agents/context_analyzer/analyzer.py +471 -0
  9. shotgun/agents/context_analyzer/constants.py +9 -0
  10. shotgun/agents/context_analyzer/formatter.py +115 -0
  11. shotgun/agents/context_analyzer/models.py +212 -0
  12. shotgun/agents/conversation_history.py +125 -2
  13. shotgun/agents/conversation_manager.py +57 -19
  14. shotgun/agents/export.py +6 -7
  15. shotgun/agents/history/compaction.py +10 -5
  16. shotgun/agents/history/context_extraction.py +93 -6
  17. shotgun/agents/history/history_processors.py +129 -12
  18. shotgun/agents/history/token_counting/__init__.py +31 -0
  19. shotgun/agents/history/token_counting/anthropic.py +127 -0
  20. shotgun/agents/history/token_counting/base.py +78 -0
  21. shotgun/agents/history/token_counting/openai.py +90 -0
  22. shotgun/agents/history/token_counting/sentencepiece_counter.py +127 -0
  23. shotgun/agents/history/token_counting/tokenizer_cache.py +92 -0
  24. shotgun/agents/history/token_counting/utils.py +144 -0
  25. shotgun/agents/history/token_estimation.py +12 -12
  26. shotgun/agents/llm.py +62 -0
  27. shotgun/agents/models.py +59 -4
  28. shotgun/agents/plan.py +6 -7
  29. shotgun/agents/research.py +7 -8
  30. shotgun/agents/specify.py +6 -7
  31. shotgun/agents/tasks.py +6 -7
  32. shotgun/agents/tools/__init__.py +0 -2
  33. shotgun/agents/tools/codebase/codebase_shell.py +6 -0
  34. shotgun/agents/tools/codebase/directory_lister.py +6 -0
  35. shotgun/agents/tools/codebase/file_read.py +11 -2
  36. shotgun/agents/tools/codebase/query_graph.py +6 -0
  37. shotgun/agents/tools/codebase/retrieve_code.py +6 -0
  38. shotgun/agents/tools/file_management.py +82 -16
  39. shotgun/agents/tools/registry.py +217 -0
  40. shotgun/agents/tools/web_search/__init__.py +55 -16
  41. shotgun/agents/tools/web_search/anthropic.py +76 -51
  42. shotgun/agents/tools/web_search/gemini.py +50 -27
  43. shotgun/agents/tools/web_search/openai.py +26 -17
  44. shotgun/agents/tools/web_search/utils.py +2 -2
  45. shotgun/agents/usage_manager.py +164 -0
  46. shotgun/api_endpoints.py +15 -0
  47. shotgun/cli/clear.py +53 -0
  48. shotgun/cli/compact.py +186 -0
  49. shotgun/cli/config.py +41 -67
  50. shotgun/cli/context.py +111 -0
  51. shotgun/cli/export.py +1 -1
  52. shotgun/cli/feedback.py +50 -0
  53. shotgun/cli/models.py +3 -2
  54. shotgun/cli/plan.py +1 -1
  55. shotgun/cli/research.py +1 -1
  56. shotgun/cli/specify.py +1 -1
  57. shotgun/cli/tasks.py +1 -1
  58. shotgun/cli/update.py +16 -2
  59. shotgun/codebase/core/change_detector.py +5 -3
  60. shotgun/codebase/core/code_retrieval.py +4 -2
  61. shotgun/codebase/core/ingestor.py +57 -16
  62. shotgun/codebase/core/manager.py +20 -7
  63. shotgun/codebase/core/nl_query.py +1 -1
  64. shotgun/codebase/models.py +4 -4
  65. shotgun/exceptions.py +32 -0
  66. shotgun/llm_proxy/__init__.py +19 -0
  67. shotgun/llm_proxy/clients.py +44 -0
  68. shotgun/llm_proxy/constants.py +15 -0
  69. shotgun/logging_config.py +18 -27
  70. shotgun/main.py +91 -12
  71. shotgun/posthog_telemetry.py +81 -10
  72. shotgun/prompts/agents/export.j2 +18 -1
  73. shotgun/prompts/agents/partials/common_agent_system_prompt.j2 +5 -1
  74. shotgun/prompts/agents/partials/interactive_mode.j2 +24 -7
  75. shotgun/prompts/agents/plan.j2 +1 -1
  76. shotgun/prompts/agents/research.j2 +1 -1
  77. shotgun/prompts/agents/specify.j2 +270 -3
  78. shotgun/prompts/agents/state/system_state.j2 +4 -0
  79. shotgun/prompts/agents/tasks.j2 +1 -1
  80. shotgun/prompts/loader.py +2 -2
  81. shotgun/prompts/tools/web_search.j2 +14 -0
  82. shotgun/sentry_telemetry.py +27 -18
  83. shotgun/settings.py +238 -0
  84. shotgun/shotgun_web/__init__.py +19 -0
  85. shotgun/shotgun_web/client.py +138 -0
  86. shotgun/shotgun_web/constants.py +21 -0
  87. shotgun/shotgun_web/models.py +47 -0
  88. shotgun/telemetry.py +24 -36
  89. shotgun/tui/app.py +251 -23
  90. shotgun/tui/commands/__init__.py +1 -1
  91. shotgun/tui/components/context_indicator.py +179 -0
  92. shotgun/tui/components/mode_indicator.py +70 -0
  93. shotgun/tui/components/status_bar.py +48 -0
  94. shotgun/tui/containers.py +91 -0
  95. shotgun/tui/dependencies.py +39 -0
  96. shotgun/tui/protocols.py +45 -0
  97. shotgun/tui/screens/chat/__init__.py +5 -0
  98. shotgun/tui/screens/chat/chat.tcss +54 -0
  99. shotgun/tui/screens/chat/chat_screen.py +1234 -0
  100. shotgun/tui/screens/chat/codebase_index_prompt_screen.py +64 -0
  101. shotgun/tui/screens/chat/codebase_index_selection.py +12 -0
  102. shotgun/tui/screens/chat/help_text.py +40 -0
  103. shotgun/tui/screens/chat/prompt_history.py +48 -0
  104. shotgun/tui/screens/chat.tcss +11 -0
  105. shotgun/tui/screens/chat_screen/command_providers.py +226 -11
  106. shotgun/tui/screens/chat_screen/history/__init__.py +22 -0
  107. shotgun/tui/screens/chat_screen/history/agent_response.py +66 -0
  108. shotgun/tui/screens/chat_screen/history/chat_history.py +116 -0
  109. shotgun/tui/screens/chat_screen/history/formatters.py +115 -0
  110. shotgun/tui/screens/chat_screen/history/partial_response.py +43 -0
  111. shotgun/tui/screens/chat_screen/history/user_question.py +42 -0
  112. shotgun/tui/screens/confirmation_dialog.py +151 -0
  113. shotgun/tui/screens/feedback.py +193 -0
  114. shotgun/tui/screens/github_issue.py +102 -0
  115. shotgun/tui/screens/model_picker.py +352 -0
  116. shotgun/tui/screens/onboarding.py +431 -0
  117. shotgun/tui/screens/pipx_migration.py +153 -0
  118. shotgun/tui/screens/provider_config.py +156 -39
  119. shotgun/tui/screens/shotgun_auth.py +295 -0
  120. shotgun/tui/screens/welcome.py +198 -0
  121. shotgun/tui/services/__init__.py +5 -0
  122. shotgun/tui/services/conversation_service.py +184 -0
  123. shotgun/tui/state/__init__.py +7 -0
  124. shotgun/tui/state/processing_state.py +185 -0
  125. shotgun/tui/utils/mode_progress.py +14 -7
  126. shotgun/tui/widgets/__init__.py +5 -0
  127. shotgun/tui/widgets/widget_coordinator.py +262 -0
  128. shotgun/utils/datetime_utils.py +77 -0
  129. shotgun/utils/env_utils.py +13 -0
  130. shotgun/utils/file_system_utils.py +22 -2
  131. shotgun/utils/marketing.py +110 -0
  132. shotgun/utils/update_checker.py +69 -14
  133. shotgun_sh-0.2.11.dist-info/METADATA +130 -0
  134. shotgun_sh-0.2.11.dist-info/RECORD +194 -0
  135. {shotgun_sh-0.1.14.dist-info → shotgun_sh-0.2.11.dist-info}/entry_points.txt +1 -0
  136. {shotgun_sh-0.1.14.dist-info → shotgun_sh-0.2.11.dist-info}/licenses/LICENSE +1 -1
  137. shotgun/agents/history/token_counting.py +0 -429
  138. shotgun/agents/tools/user_interaction.py +0 -37
  139. shotgun/tui/screens/chat.py +0 -797
  140. shotgun/tui/screens/chat_screen/history.py +0 -350
  141. shotgun_sh-0.1.14.dist-info/METADATA +0 -466
  142. shotgun_sh-0.1.14.dist-info/RECORD +0 -133
  143. {shotgun_sh-0.1.14.dist-info → shotgun_sh-0.2.11.dist-info}/WHEEL +0 -0
@@ -0,0 +1,91 @@
1
+ """Dependency injection container for TUI components."""
2
+
3
+ from typing import TYPE_CHECKING
4
+
5
+ from dependency_injector import containers, providers
6
+ from pydantic_ai import RunContext
7
+
8
+ from shotgun.agents.conversation_manager import ConversationManager
9
+ from shotgun.agents.models import AgentDeps
10
+ from shotgun.sdk.codebase import CodebaseSDK
11
+ from shotgun.tui.commands import CommandHandler
12
+ from shotgun.tui.filtered_codebase_service import FilteredCodebaseService
13
+ from shotgun.tui.services.conversation_service import ConversationService
14
+ from shotgun.tui.state.processing_state import ProcessingStateManager
15
+ from shotgun.tui.utils.mode_progress import PlaceholderHints
16
+ from shotgun.tui.widgets.widget_coordinator import WidgetCoordinator
17
+ from shotgun.utils import get_shotgun_home
18
+
19
+ if TYPE_CHECKING:
20
+ pass
21
+
22
+
23
+ # Placeholder system prompt function (agents provide their own)
24
+ # Using Object provider to pass the function itself, not call it
25
+ def _placeholder_system_prompt(ctx: "RunContext[AgentDeps]") -> str:
26
+ raise RuntimeError(
27
+ "This should not be called - agents provide their own system_prompt_fn"
28
+ )
29
+
30
+
31
+ class TUIContainer(containers.DeclarativeContainer):
32
+ """Dependency injection container for TUI components.
33
+
34
+ This container manages the lifecycle and dependencies of all TUI components,
35
+ ensuring consistent configuration and facilitating testing.
36
+
37
+ Note: model_config and agent_deps are created lazily via async factory methods
38
+ since get_provider_model() is now async.
39
+ """
40
+
41
+ # Configuration
42
+ config = providers.Configuration()
43
+
44
+ # Core dependencies
45
+ # TODO: Figure out a better solution for async dependency injection
46
+ # model_config is now loaded lazily via create_default_tui_deps()
47
+ # because get_provider_model() is async. This breaks the DI pattern
48
+ # and should be refactored to support async factories properly.
49
+
50
+ storage_dir = providers.Singleton(lambda: get_shotgun_home() / "codebases")
51
+
52
+ codebase_service = providers.Singleton(
53
+ FilteredCodebaseService, storage_dir=storage_dir
54
+ )
55
+
56
+ system_prompt_fn = providers.Object(_placeholder_system_prompt)
57
+
58
+ # TODO: Figure out a better solution for async dependency injection
59
+ # AgentDeps is now created via async create_default_tui_deps()
60
+ # instead of using DI container's Singleton provider because it requires
61
+ # async model_config initialization
62
+
63
+ # Service singletons
64
+ codebase_sdk = providers.Singleton(CodebaseSDK)
65
+
66
+ command_handler = providers.Singleton(CommandHandler)
67
+
68
+ placeholder_hints = providers.Singleton(PlaceholderHints)
69
+
70
+ conversation_manager = providers.Singleton(ConversationManager)
71
+
72
+ conversation_service = providers.Factory(
73
+ ConversationService, conversation_manager=conversation_manager
74
+ )
75
+
76
+ # TODO: Figure out a better solution for async dependency injection
77
+ # AgentManager factory removed - create via async initialization
78
+ # since it requires async agent creation
79
+
80
+ # Factory for ProcessingStateManager (needs ChatScreen reference)
81
+ processing_state_factory = providers.Factory(
82
+ ProcessingStateManager,
83
+ screen=providers.Object(None), # Will be overridden when creating ChatScreen
84
+ telemetry_context=providers.Object({}), # Will be overridden when creating
85
+ )
86
+
87
+ # Factory for WidgetCoordinator (needs ChatScreen reference)
88
+ widget_coordinator_factory = providers.Factory(
89
+ WidgetCoordinator,
90
+ screen=providers.Object(None), # Will be overridden when creating ChatScreen
91
+ )
@@ -0,0 +1,39 @@
1
+ """Dependency creation utilities for TUI components."""
2
+
3
+ from pydantic_ai import RunContext
4
+
5
+ from shotgun.agents.config import get_provider_model
6
+ from shotgun.agents.models import AgentDeps
7
+ from shotgun.tui.filtered_codebase_service import FilteredCodebaseService
8
+ from shotgun.utils import get_shotgun_home
9
+
10
+
11
+ async def create_default_tui_deps() -> AgentDeps:
12
+ """Create default AgentDeps for TUI components.
13
+
14
+ This creates a standard AgentDeps configuration suitable for interactive
15
+ TUI usage with:
16
+ - Interactive mode enabled
17
+ - TUI context flag set
18
+ - Filtered codebase service (restricted to CWD)
19
+ - Placeholder system prompt (agents provide their own)
20
+
21
+ Returns:
22
+ Configured AgentDeps instance ready for TUI use.
23
+ """
24
+ model_config = await get_provider_model()
25
+ storage_dir = get_shotgun_home() / "codebases"
26
+ codebase_service = FilteredCodebaseService(storage_dir)
27
+
28
+ def _placeholder_system_prompt_fn(ctx: RunContext[AgentDeps]) -> str:
29
+ raise RuntimeError(
30
+ "This should not be called - agents provide their own system_prompt_fn"
31
+ )
32
+
33
+ return AgentDeps(
34
+ interactive_mode=True,
35
+ is_tui_context=True,
36
+ llm_model=model_config,
37
+ codebase_service=codebase_service,
38
+ system_prompt_fn=_placeholder_system_prompt_fn,
39
+ )
@@ -0,0 +1,45 @@
1
+ """Protocol definitions for TUI components.
2
+
3
+ These protocols define interfaces that components can depend on without
4
+ creating circular imports. Screens like ChatScreen can satisfy these
5
+ protocols without explicitly implementing them.
6
+ """
7
+
8
+ from typing import Protocol, runtime_checkable
9
+
10
+
11
+ @runtime_checkable
12
+ class QAStateProvider(Protocol):
13
+ """Protocol for screens that provide Q&A mode state.
14
+
15
+ This protocol allows components to check if they're on a screen with
16
+ Q&A mode without importing the concrete ChatScreen class, eliminating
17
+ circular dependencies.
18
+ """
19
+
20
+ @property
21
+ def qa_mode(self) -> bool:
22
+ """Whether Q&A mode is currently active.
23
+
24
+ Returns:
25
+ True if Q&A mode is active, False otherwise.
26
+ """
27
+ ...
28
+
29
+
30
+ @runtime_checkable
31
+ class ProcessingStateProvider(Protocol):
32
+ """Protocol for screens that provide processing state.
33
+
34
+ This protocol allows components to check if they're on a screen with
35
+ an active agent processing without importing the concrete ChatScreen class.
36
+ """
37
+
38
+ @property
39
+ def working(self) -> bool:
40
+ """Whether an agent is currently working.
41
+
42
+ Returns:
43
+ True if an agent is processing, False otherwise.
44
+ """
45
+ ...
@@ -0,0 +1,5 @@
1
+ """Chat screen module."""
2
+
3
+ from shotgun.tui.screens.chat.chat_screen import ChatScreen
4
+
5
+ __all__ = ["ChatScreen"]
@@ -0,0 +1,54 @@
1
+ ChatHistory {
2
+ height: auto;
3
+ }
4
+
5
+ PromptInput {
6
+ min-height: 3;
7
+ max-height: 7;
8
+ height: auto;
9
+ }
10
+
11
+ StatusBar {
12
+ height: auto;
13
+ }
14
+
15
+ ModeIndicator {
16
+ height: auto;
17
+ }
18
+
19
+ #footer {
20
+ dock: bottom;
21
+ height: auto;
22
+ padding: 1 1 1 2;
23
+ max-height: 14;
24
+ }
25
+
26
+ #window {
27
+ align: left bottom;
28
+ }
29
+
30
+ .hidden {
31
+ display: none;
32
+ }
33
+
34
+ #footer > Grid {
35
+ height: auto;
36
+ grid-columns: 1fr auto;
37
+ grid-size: 2;
38
+ }
39
+
40
+
41
+ #right-footer-indicators {
42
+ width: auto;
43
+ height: auto;
44
+ layout: vertical;
45
+ }
46
+
47
+ #context-indicator {
48
+ text-align: end;
49
+ height: 1;
50
+ }
51
+
52
+ #indexing-job-display {
53
+ text-align: end;
54
+ }