shotgun-sh 0.2.3.dev2__py3-none-any.whl → 0.2.11.dev1__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 (107) hide show
  1. shotgun/agents/agent_manager.py +524 -58
  2. shotgun/agents/common.py +62 -62
  3. shotgun/agents/config/constants.py +0 -6
  4. shotgun/agents/config/manager.py +14 -3
  5. shotgun/agents/config/models.py +16 -0
  6. shotgun/agents/config/provider.py +68 -13
  7. shotgun/agents/context_analyzer/__init__.py +28 -0
  8. shotgun/agents/context_analyzer/analyzer.py +493 -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 +24 -2
  14. shotgun/agents/export.py +4 -5
  15. shotgun/agents/history/compaction.py +9 -4
  16. shotgun/agents/history/context_extraction.py +93 -6
  17. shotgun/agents/history/history_processors.py +14 -2
  18. shotgun/agents/history/token_counting/anthropic.py +32 -10
  19. shotgun/agents/models.py +50 -2
  20. shotgun/agents/plan.py +4 -5
  21. shotgun/agents/research.py +4 -5
  22. shotgun/agents/specify.py +4 -5
  23. shotgun/agents/tasks.py +4 -5
  24. shotgun/agents/tools/__init__.py +0 -2
  25. shotgun/agents/tools/codebase/codebase_shell.py +6 -0
  26. shotgun/agents/tools/codebase/directory_lister.py +6 -0
  27. shotgun/agents/tools/codebase/file_read.py +6 -0
  28. shotgun/agents/tools/codebase/query_graph.py +6 -0
  29. shotgun/agents/tools/codebase/retrieve_code.py +6 -0
  30. shotgun/agents/tools/file_management.py +71 -9
  31. shotgun/agents/tools/registry.py +217 -0
  32. shotgun/agents/tools/web_search/__init__.py +24 -12
  33. shotgun/agents/tools/web_search/anthropic.py +24 -3
  34. shotgun/agents/tools/web_search/gemini.py +22 -10
  35. shotgun/agents/tools/web_search/openai.py +21 -12
  36. shotgun/api_endpoints.py +7 -3
  37. shotgun/build_constants.py +1 -1
  38. shotgun/cli/clear.py +52 -0
  39. shotgun/cli/compact.py +186 -0
  40. shotgun/cli/context.py +111 -0
  41. shotgun/cli/models.py +1 -0
  42. shotgun/cli/update.py +16 -2
  43. shotgun/codebase/core/manager.py +10 -1
  44. shotgun/llm_proxy/__init__.py +5 -2
  45. shotgun/llm_proxy/clients.py +12 -7
  46. shotgun/logging_config.py +8 -10
  47. shotgun/main.py +70 -10
  48. shotgun/posthog_telemetry.py +9 -3
  49. shotgun/prompts/agents/export.j2 +18 -1
  50. shotgun/prompts/agents/partials/common_agent_system_prompt.j2 +5 -1
  51. shotgun/prompts/agents/partials/interactive_mode.j2 +24 -7
  52. shotgun/prompts/agents/plan.j2 +1 -1
  53. shotgun/prompts/agents/research.j2 +1 -1
  54. shotgun/prompts/agents/specify.j2 +270 -3
  55. shotgun/prompts/agents/state/system_state.j2 +4 -0
  56. shotgun/prompts/agents/tasks.j2 +1 -1
  57. shotgun/prompts/loader.py +2 -2
  58. shotgun/prompts/tools/web_search.j2 +14 -0
  59. shotgun/sentry_telemetry.py +4 -15
  60. shotgun/settings.py +238 -0
  61. shotgun/telemetry.py +15 -32
  62. shotgun/tui/app.py +203 -9
  63. shotgun/tui/commands/__init__.py +1 -1
  64. shotgun/tui/components/context_indicator.py +136 -0
  65. shotgun/tui/components/mode_indicator.py +70 -0
  66. shotgun/tui/components/status_bar.py +48 -0
  67. shotgun/tui/containers.py +93 -0
  68. shotgun/tui/dependencies.py +39 -0
  69. shotgun/tui/protocols.py +45 -0
  70. shotgun/tui/screens/chat/__init__.py +5 -0
  71. shotgun/tui/screens/chat/chat.tcss +54 -0
  72. shotgun/tui/screens/chat/chat_screen.py +1110 -0
  73. shotgun/tui/screens/chat/codebase_index_prompt_screen.py +64 -0
  74. shotgun/tui/screens/chat/codebase_index_selection.py +12 -0
  75. shotgun/tui/screens/chat/help_text.py +39 -0
  76. shotgun/tui/screens/chat/prompt_history.py +48 -0
  77. shotgun/tui/screens/chat.tcss +11 -0
  78. shotgun/tui/screens/chat_screen/command_providers.py +68 -2
  79. shotgun/tui/screens/chat_screen/history/__init__.py +22 -0
  80. shotgun/tui/screens/chat_screen/history/agent_response.py +66 -0
  81. shotgun/tui/screens/chat_screen/history/chat_history.py +116 -0
  82. shotgun/tui/screens/chat_screen/history/formatters.py +115 -0
  83. shotgun/tui/screens/chat_screen/history/partial_response.py +43 -0
  84. shotgun/tui/screens/chat_screen/history/user_question.py +42 -0
  85. shotgun/tui/screens/confirmation_dialog.py +151 -0
  86. shotgun/tui/screens/model_picker.py +30 -6
  87. shotgun/tui/screens/pipx_migration.py +153 -0
  88. shotgun/tui/screens/welcome.py +24 -5
  89. shotgun/tui/services/__init__.py +5 -0
  90. shotgun/tui/services/conversation_service.py +182 -0
  91. shotgun/tui/state/__init__.py +7 -0
  92. shotgun/tui/state/processing_state.py +185 -0
  93. shotgun/tui/widgets/__init__.py +5 -0
  94. shotgun/tui/widgets/widget_coordinator.py +247 -0
  95. shotgun/utils/datetime_utils.py +77 -0
  96. shotgun/utils/file_system_utils.py +3 -2
  97. shotgun/utils/update_checker.py +69 -14
  98. shotgun_sh-0.2.11.dev1.dist-info/METADATA +129 -0
  99. shotgun_sh-0.2.11.dev1.dist-info/RECORD +190 -0
  100. {shotgun_sh-0.2.3.dev2.dist-info → shotgun_sh-0.2.11.dev1.dist-info}/entry_points.txt +1 -0
  101. {shotgun_sh-0.2.3.dev2.dist-info → shotgun_sh-0.2.11.dev1.dist-info}/licenses/LICENSE +1 -1
  102. shotgun/agents/tools/user_interaction.py +0 -37
  103. shotgun/tui/screens/chat.py +0 -804
  104. shotgun/tui/screens/chat_screen/history.py +0 -352
  105. shotgun_sh-0.2.3.dev2.dist-info/METADATA +0 -467
  106. shotgun_sh-0.2.3.dev2.dist-info/RECORD +0 -154
  107. {shotgun_sh-0.2.3.dev2.dist-info → shotgun_sh-0.2.11.dev1.dist-info}/WHEEL +0 -0
@@ -0,0 +1,93 @@
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.agent_manager import AgentManager
9
+ from shotgun.agents.config import get_provider_model
10
+ from shotgun.agents.conversation_manager import ConversationManager
11
+ from shotgun.agents.models import AgentDeps, AgentType
12
+ from shotgun.sdk.codebase import CodebaseSDK
13
+ from shotgun.tui.commands import CommandHandler
14
+ from shotgun.tui.filtered_codebase_service import FilteredCodebaseService
15
+ from shotgun.tui.services.conversation_service import ConversationService
16
+ from shotgun.tui.state.processing_state import ProcessingStateManager
17
+ from shotgun.tui.utils.mode_progress import PlaceholderHints
18
+ from shotgun.tui.widgets.widget_coordinator import WidgetCoordinator
19
+ from shotgun.utils import get_shotgun_home
20
+
21
+ if TYPE_CHECKING:
22
+ pass
23
+
24
+
25
+ # Placeholder system prompt function (agents provide their own)
26
+ # Using Object provider to pass the function itself, not call it
27
+ def _placeholder_system_prompt(ctx: "RunContext[AgentDeps]") -> str:
28
+ raise RuntimeError(
29
+ "This should not be called - agents provide their own system_prompt_fn"
30
+ )
31
+
32
+
33
+ class TUIContainer(containers.DeclarativeContainer):
34
+ """Dependency injection container for TUI components.
35
+
36
+ This container manages the lifecycle and dependencies of all TUI components,
37
+ ensuring consistent configuration and facilitating testing.
38
+ """
39
+
40
+ # Configuration
41
+ config = providers.Configuration()
42
+
43
+ # Core dependencies
44
+ model_config = providers.Singleton(get_provider_model)
45
+
46
+ storage_dir = providers.Singleton(lambda: get_shotgun_home() / "codebases")
47
+
48
+ codebase_service = providers.Singleton(
49
+ FilteredCodebaseService, storage_dir=storage_dir
50
+ )
51
+
52
+ system_prompt_fn = providers.Object(_placeholder_system_prompt)
53
+
54
+ # AgentDeps singleton
55
+ agent_deps = providers.Singleton(
56
+ AgentDeps,
57
+ interactive_mode=True,
58
+ is_tui_context=True,
59
+ llm_model=model_config,
60
+ codebase_service=codebase_service,
61
+ system_prompt_fn=system_prompt_fn,
62
+ )
63
+
64
+ # Service singletons
65
+ codebase_sdk = providers.Singleton(CodebaseSDK)
66
+
67
+ command_handler = providers.Singleton(CommandHandler)
68
+
69
+ placeholder_hints = providers.Singleton(PlaceholderHints)
70
+
71
+ conversation_manager = providers.Singleton(ConversationManager)
72
+
73
+ conversation_service = providers.Factory(
74
+ ConversationService, conversation_manager=conversation_manager
75
+ )
76
+
77
+ # Factory for AgentManager (needs agent_type parameter)
78
+ agent_manager_factory = providers.Factory(
79
+ AgentManager, deps=agent_deps, initial_type=providers.Object(AgentType.RESEARCH)
80
+ )
81
+
82
+ # Factory for ProcessingStateManager (needs ChatScreen reference)
83
+ processing_state_factory = providers.Factory(
84
+ ProcessingStateManager,
85
+ screen=providers.Object(None), # Will be overridden when creating ChatScreen
86
+ telemetry_context=providers.Object({}), # Will be overridden when creating
87
+ )
88
+
89
+ # Factory for WidgetCoordinator (needs ChatScreen reference)
90
+ widget_coordinator_factory = providers.Factory(
91
+ WidgetCoordinator,
92
+ screen=providers.Object(None), # Will be overridden when creating ChatScreen
93
+ )
@@ -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
+ 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 = 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
+ }