shotgun-sh 0.1.9__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.
- shotgun/agents/agent_manager.py +761 -52
- shotgun/agents/common.py +80 -75
- shotgun/agents/config/constants.py +21 -10
- shotgun/agents/config/manager.py +322 -97
- shotgun/agents/config/models.py +114 -84
- shotgun/agents/config/provider.py +232 -88
- shotgun/agents/context_analyzer/__init__.py +28 -0
- shotgun/agents/context_analyzer/analyzer.py +471 -0
- shotgun/agents/context_analyzer/constants.py +9 -0
- shotgun/agents/context_analyzer/formatter.py +115 -0
- shotgun/agents/context_analyzer/models.py +212 -0
- shotgun/agents/conversation_history.py +125 -2
- shotgun/agents/conversation_manager.py +57 -19
- shotgun/agents/export.py +6 -7
- shotgun/agents/history/compaction.py +23 -3
- shotgun/agents/history/context_extraction.py +93 -6
- shotgun/agents/history/history_processors.py +179 -11
- shotgun/agents/history/token_counting/__init__.py +31 -0
- shotgun/agents/history/token_counting/anthropic.py +127 -0
- shotgun/agents/history/token_counting/base.py +78 -0
- shotgun/agents/history/token_counting/openai.py +90 -0
- shotgun/agents/history/token_counting/sentencepiece_counter.py +127 -0
- shotgun/agents/history/token_counting/tokenizer_cache.py +92 -0
- shotgun/agents/history/token_counting/utils.py +144 -0
- shotgun/agents/history/token_estimation.py +12 -12
- shotgun/agents/llm.py +62 -0
- shotgun/agents/models.py +59 -4
- shotgun/agents/plan.py +6 -7
- shotgun/agents/research.py +7 -8
- shotgun/agents/specify.py +6 -7
- shotgun/agents/tasks.py +6 -7
- shotgun/agents/tools/__init__.py +0 -2
- shotgun/agents/tools/codebase/codebase_shell.py +6 -0
- shotgun/agents/tools/codebase/directory_lister.py +6 -0
- shotgun/agents/tools/codebase/file_read.py +11 -2
- shotgun/agents/tools/codebase/query_graph.py +6 -0
- shotgun/agents/tools/codebase/retrieve_code.py +6 -0
- shotgun/agents/tools/file_management.py +82 -16
- shotgun/agents/tools/registry.py +217 -0
- shotgun/agents/tools/web_search/__init__.py +55 -16
- shotgun/agents/tools/web_search/anthropic.py +76 -51
- shotgun/agents/tools/web_search/gemini.py +50 -27
- shotgun/agents/tools/web_search/openai.py +26 -17
- shotgun/agents/tools/web_search/utils.py +2 -2
- shotgun/agents/usage_manager.py +164 -0
- shotgun/api_endpoints.py +15 -0
- shotgun/cli/clear.py +53 -0
- shotgun/cli/codebase/commands.py +71 -2
- shotgun/cli/compact.py +186 -0
- shotgun/cli/config.py +41 -67
- shotgun/cli/context.py +111 -0
- shotgun/cli/export.py +1 -1
- shotgun/cli/feedback.py +50 -0
- shotgun/cli/models.py +3 -2
- shotgun/cli/plan.py +1 -1
- shotgun/cli/research.py +1 -1
- shotgun/cli/specify.py +1 -1
- shotgun/cli/tasks.py +1 -1
- shotgun/cli/update.py +18 -5
- shotgun/codebase/core/change_detector.py +5 -3
- shotgun/codebase/core/code_retrieval.py +4 -2
- shotgun/codebase/core/ingestor.py +169 -19
- shotgun/codebase/core/manager.py +177 -13
- shotgun/codebase/core/nl_query.py +1 -1
- shotgun/codebase/models.py +28 -3
- shotgun/codebase/service.py +14 -2
- shotgun/exceptions.py +32 -0
- shotgun/llm_proxy/__init__.py +19 -0
- shotgun/llm_proxy/clients.py +44 -0
- shotgun/llm_proxy/constants.py +15 -0
- shotgun/logging_config.py +18 -27
- shotgun/main.py +91 -4
- shotgun/posthog_telemetry.py +87 -40
- shotgun/prompts/agents/export.j2 +18 -1
- shotgun/prompts/agents/partials/common_agent_system_prompt.j2 +5 -1
- shotgun/prompts/agents/partials/interactive_mode.j2 +24 -7
- shotgun/prompts/agents/plan.j2 +1 -1
- shotgun/prompts/agents/research.j2 +1 -1
- shotgun/prompts/agents/specify.j2 +270 -3
- shotgun/prompts/agents/state/system_state.j2 +4 -0
- shotgun/prompts/agents/tasks.j2 +1 -1
- shotgun/prompts/codebase/partials/cypher_rules.j2 +13 -0
- shotgun/prompts/loader.py +2 -2
- shotgun/prompts/tools/web_search.j2 +14 -0
- shotgun/sdk/codebase.py +60 -2
- shotgun/sentry_telemetry.py +28 -21
- shotgun/settings.py +238 -0
- shotgun/shotgun_web/__init__.py +19 -0
- shotgun/shotgun_web/client.py +138 -0
- shotgun/shotgun_web/constants.py +21 -0
- shotgun/shotgun_web/models.py +47 -0
- shotgun/telemetry.py +24 -36
- shotgun/tui/app.py +275 -23
- shotgun/tui/commands/__init__.py +1 -1
- shotgun/tui/components/context_indicator.py +179 -0
- shotgun/tui/components/mode_indicator.py +70 -0
- shotgun/tui/components/status_bar.py +48 -0
- shotgun/tui/components/vertical_tail.py +6 -0
- shotgun/tui/containers.py +91 -0
- shotgun/tui/dependencies.py +39 -0
- shotgun/tui/filtered_codebase_service.py +46 -0
- shotgun/tui/protocols.py +45 -0
- shotgun/tui/screens/chat/__init__.py +5 -0
- shotgun/tui/screens/chat/chat.tcss +54 -0
- shotgun/tui/screens/chat/chat_screen.py +1234 -0
- shotgun/tui/screens/chat/codebase_index_prompt_screen.py +64 -0
- shotgun/tui/screens/chat/codebase_index_selection.py +12 -0
- shotgun/tui/screens/chat/help_text.py +40 -0
- shotgun/tui/screens/chat/prompt_history.py +48 -0
- shotgun/tui/screens/chat.tcss +11 -0
- shotgun/tui/screens/chat_screen/command_providers.py +226 -11
- shotgun/tui/screens/chat_screen/history/__init__.py +22 -0
- shotgun/tui/screens/chat_screen/history/agent_response.py +66 -0
- shotgun/tui/screens/chat_screen/history/chat_history.py +116 -0
- shotgun/tui/screens/chat_screen/history/formatters.py +115 -0
- shotgun/tui/screens/chat_screen/history/partial_response.py +43 -0
- shotgun/tui/screens/chat_screen/history/user_question.py +42 -0
- shotgun/tui/screens/confirmation_dialog.py +151 -0
- shotgun/tui/screens/feedback.py +193 -0
- shotgun/tui/screens/github_issue.py +102 -0
- shotgun/tui/screens/model_picker.py +352 -0
- shotgun/tui/screens/onboarding.py +431 -0
- shotgun/tui/screens/pipx_migration.py +153 -0
- shotgun/tui/screens/provider_config.py +156 -39
- shotgun/tui/screens/shotgun_auth.py +295 -0
- shotgun/tui/screens/welcome.py +198 -0
- shotgun/tui/services/__init__.py +5 -0
- shotgun/tui/services/conversation_service.py +184 -0
- shotgun/tui/state/__init__.py +7 -0
- shotgun/tui/state/processing_state.py +185 -0
- shotgun/tui/utils/mode_progress.py +14 -7
- shotgun/tui/widgets/__init__.py +5 -0
- shotgun/tui/widgets/widget_coordinator.py +262 -0
- shotgun/utils/datetime_utils.py +77 -0
- shotgun/utils/env_utils.py +13 -0
- shotgun/utils/file_system_utils.py +22 -2
- shotgun/utils/marketing.py +110 -0
- shotgun/utils/source_detection.py +16 -0
- shotgun/utils/update_checker.py +73 -21
- shotgun_sh-0.2.11.dist-info/METADATA +130 -0
- shotgun_sh-0.2.11.dist-info/RECORD +194 -0
- {shotgun_sh-0.1.9.dist-info → shotgun_sh-0.2.11.dist-info}/entry_points.txt +1 -0
- {shotgun_sh-0.1.9.dist-info → shotgun_sh-0.2.11.dist-info}/licenses/LICENSE +1 -1
- shotgun/agents/history/token_counting.py +0 -429
- shotgun/agents/tools/user_interaction.py +0 -37
- shotgun/tui/screens/chat.py +0 -818
- shotgun/tui/screens/chat_screen/history.py +0 -222
- shotgun_sh-0.1.9.dist-info/METADATA +0 -466
- shotgun_sh-0.1.9.dist-info/RECORD +0 -131
- {shotgun_sh-0.1.9.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,46 @@
|
|
|
1
|
+
"""Filtered codebase service that restricts access to current directory's codebase only."""
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from shotgun.codebase.models import CodebaseGraph
|
|
6
|
+
from shotgun.codebase.service import CodebaseService
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class FilteredCodebaseService(CodebaseService):
|
|
10
|
+
"""CodebaseService subclass that filters graphs to only those accessible from CWD.
|
|
11
|
+
|
|
12
|
+
This ensures TUI agents can only see and access the codebase indexed from the
|
|
13
|
+
current working directory, providing isolation between different project directories.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
def __init__(self, storage_dir: Path | str):
|
|
17
|
+
"""Initialize the filtered service.
|
|
18
|
+
|
|
19
|
+
Args:
|
|
20
|
+
storage_dir: Directory to store graph databases
|
|
21
|
+
"""
|
|
22
|
+
super().__init__(storage_dir)
|
|
23
|
+
self._cwd = str(Path.cwd().resolve())
|
|
24
|
+
|
|
25
|
+
async def list_graphs(self) -> list[CodebaseGraph]:
|
|
26
|
+
"""List only graphs accessible from the current working directory.
|
|
27
|
+
|
|
28
|
+
Returns:
|
|
29
|
+
Filtered list of CodebaseGraph objects accessible from CWD
|
|
30
|
+
"""
|
|
31
|
+
# Use the existing filtering logic from list_graphs_for_directory
|
|
32
|
+
return await super().list_graphs_for_directory(self._cwd)
|
|
33
|
+
|
|
34
|
+
async def list_graphs_for_directory(
|
|
35
|
+
self, directory: Path | str | None = None
|
|
36
|
+
) -> list[CodebaseGraph]:
|
|
37
|
+
"""List graphs for directory - always filters to CWD for TUI context.
|
|
38
|
+
|
|
39
|
+
Args:
|
|
40
|
+
directory: Ignored in TUI context, always uses CWD
|
|
41
|
+
|
|
42
|
+
Returns:
|
|
43
|
+
Filtered list of CodebaseGraph objects accessible from CWD
|
|
44
|
+
"""
|
|
45
|
+
# Always use CWD regardless of what directory is passed
|
|
46
|
+
return await super().list_graphs_for_directory(self._cwd)
|
shotgun/tui/protocols.py
ADDED
|
@@ -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,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
|
+
}
|