shotgun-sh 0.1.8.dev1__py3-none-any.whl → 0.1.10.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.
- shotgun/agents/agent_manager.py +2 -5
- shotgun/main.py +4 -33
- shotgun/tui/app.py +4 -16
- shotgun/tui/screens/chat_screen/history.py +43 -4
- shotgun/utils/update_checker.py +101 -229
- {shotgun_sh-0.1.8.dev1.dist-info → shotgun_sh-0.1.10.dev1.dist-info}/METADATA +1 -1
- {shotgun_sh-0.1.8.dev1.dist-info → shotgun_sh-0.1.10.dev1.dist-info}/RECORD +10 -10
- {shotgun_sh-0.1.8.dev1.dist-info → shotgun_sh-0.1.10.dev1.dist-info}/WHEEL +0 -0
- {shotgun_sh-0.1.8.dev1.dist-info → shotgun_sh-0.1.10.dev1.dist-info}/entry_points.txt +0 -0
- {shotgun_sh-0.1.8.dev1.dist-info → shotgun_sh-0.1.10.dev1.dist-info}/licenses/LICENSE +0 -0
shotgun/agents/agent_manager.py
CHANGED
|
@@ -277,6 +277,8 @@ class AgentManager(Widget):
|
|
|
277
277
|
|
|
278
278
|
# Clear file tracker before each run to track only this run's operations
|
|
279
279
|
deps.file_tracker.clear()
|
|
280
|
+
# preprocess messages; maybe we need to include the user answer in the message history
|
|
281
|
+
|
|
280
282
|
original_messages = self.ui_message_history.copy()
|
|
281
283
|
|
|
282
284
|
if prompt:
|
|
@@ -477,11 +479,6 @@ class AgentManager(Widget):
|
|
|
477
479
|
elif isinstance(event, FunctionToolResultEvent):
|
|
478
480
|
request_message = ModelRequest(parts=[event.result])
|
|
479
481
|
state.messages.append(request_message)
|
|
480
|
-
if (
|
|
481
|
-
event.result.tool_name == "ask_user"
|
|
482
|
-
): # special handling to ask_user, because deferred tool results mean we missed the user response
|
|
483
|
-
self.ui_message_history.append(request_message)
|
|
484
|
-
self._post_messages_updated()
|
|
485
482
|
## this is what the user responded with
|
|
486
483
|
self._post_partial_message(is_last=False)
|
|
487
484
|
|
shotgun/main.py
CHANGED
|
@@ -22,7 +22,7 @@ from shotgun.posthog_telemetry import setup_posthog_observability
|
|
|
22
22
|
from shotgun.sentry_telemetry import setup_sentry_observability
|
|
23
23
|
from shotgun.telemetry import setup_logfire_observability
|
|
24
24
|
from shotgun.tui import app as tui_app
|
|
25
|
-
from shotgun.utils.update_checker import
|
|
25
|
+
from shotgun.utils.update_checker import perform_auto_update_async
|
|
26
26
|
|
|
27
27
|
# Load environment variables from .env file
|
|
28
28
|
load_dotenv()
|
|
@@ -50,15 +50,6 @@ logger.debug("Sentry observability enabled: %s", _sentry_enabled)
|
|
|
50
50
|
_posthog_enabled = setup_posthog_observability()
|
|
51
51
|
logger.debug("PostHog analytics enabled: %s", _posthog_enabled)
|
|
52
52
|
|
|
53
|
-
# Global variable to store update notification
|
|
54
|
-
_update_notification: str | None = None
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
def _update_callback(notification: str) -> None:
|
|
58
|
-
"""Callback to store update notification."""
|
|
59
|
-
global _update_notification
|
|
60
|
-
_update_notification = notification
|
|
61
|
-
|
|
62
53
|
|
|
63
54
|
app = typer.Typer(
|
|
64
55
|
name="shotgun",
|
|
@@ -121,39 +112,19 @@ def main(
|
|
|
121
112
|
"""Shotgun - AI-powered CLI tool."""
|
|
122
113
|
logger.debug("Starting shotgun CLI application")
|
|
123
114
|
|
|
124
|
-
# Start async update check (non-blocking)
|
|
115
|
+
# Start async update check and install (non-blocking)
|
|
125
116
|
if not ctx.resilient_parsing:
|
|
126
|
-
|
|
127
|
-
callback=_update_callback, no_update_check=no_update_check
|
|
128
|
-
)
|
|
117
|
+
perform_auto_update_async(no_update_check=no_update_check)
|
|
129
118
|
|
|
130
119
|
if ctx.invoked_subcommand is None and not ctx.resilient_parsing:
|
|
131
120
|
logger.debug("Launching shotgun TUI application")
|
|
132
121
|
tui_app.run(no_update_check=no_update_check, continue_session=continue_session)
|
|
133
|
-
|
|
134
|
-
# Show update notification after TUI exits
|
|
135
|
-
if _update_notification:
|
|
136
|
-
from rich.console import Console
|
|
137
|
-
|
|
138
|
-
console = Console()
|
|
139
|
-
console.print(f"\n[cyan]{_update_notification}[/cyan]", style="bold")
|
|
140
|
-
|
|
141
122
|
raise typer.Exit()
|
|
142
123
|
|
|
143
|
-
# For CLI commands,
|
|
144
|
-
# This is handled by registering an atexit handler
|
|
124
|
+
# For CLI commands, register PostHog shutdown handler
|
|
145
125
|
if not ctx.resilient_parsing and ctx.invoked_subcommand is not None:
|
|
146
126
|
import atexit
|
|
147
127
|
|
|
148
|
-
def show_update_notification() -> None:
|
|
149
|
-
if _update_notification:
|
|
150
|
-
from rich.console import Console
|
|
151
|
-
|
|
152
|
-
console = Console()
|
|
153
|
-
console.print(f"\n[cyan]{_update_notification}[/cyan]", style="bold")
|
|
154
|
-
|
|
155
|
-
atexit.register(show_update_notification)
|
|
156
|
-
|
|
157
128
|
# Register PostHog shutdown handler
|
|
158
129
|
def shutdown_posthog() -> None:
|
|
159
130
|
from shotgun.posthog_telemetry import shutdown
|
shotgun/tui/app.py
CHANGED
|
@@ -9,7 +9,7 @@ from shotgun.agents.config import ConfigManager, get_config_manager
|
|
|
9
9
|
from shotgun.logging_config import get_logger
|
|
10
10
|
from shotgun.tui.screens.splash import SplashScreen
|
|
11
11
|
from shotgun.utils.file_system_utils import get_shotgun_base_path
|
|
12
|
-
from shotgun.utils.update_checker import
|
|
12
|
+
from shotgun.utils.update_checker import perform_auto_update_async
|
|
13
13
|
|
|
14
14
|
from .screens.chat import ChatScreen
|
|
15
15
|
from .screens.directory_setup import DirectorySetupScreen
|
|
@@ -36,16 +36,10 @@ class ShotgunApp(App[None]):
|
|
|
36
36
|
self.config_manager: ConfigManager = get_config_manager()
|
|
37
37
|
self.no_update_check = no_update_check
|
|
38
38
|
self.continue_session = continue_session
|
|
39
|
-
self.update_notification: str | None = None
|
|
40
39
|
|
|
41
|
-
# Start async update check
|
|
40
|
+
# Start async update check and install
|
|
42
41
|
if not no_update_check:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
def _update_callback(self, notification: str) -> None:
|
|
46
|
-
"""Store update notification to show later."""
|
|
47
|
-
self.update_notification = notification
|
|
48
|
-
logger.debug(f"Update notification received: {notification}")
|
|
42
|
+
perform_auto_update_async(no_update_check=no_update_check)
|
|
49
43
|
|
|
50
44
|
def on_mount(self) -> None:
|
|
51
45
|
self.theme = "gruvbox"
|
|
@@ -88,13 +82,7 @@ class ShotgunApp(App[None]):
|
|
|
88
82
|
return shotgun_dir.exists() and shotgun_dir.is_dir()
|
|
89
83
|
|
|
90
84
|
async def action_quit(self) -> None:
|
|
91
|
-
"""
|
|
92
|
-
if self.update_notification:
|
|
93
|
-
# Show notification before quitting
|
|
94
|
-
from rich.console import Console
|
|
95
|
-
|
|
96
|
-
console = Console()
|
|
97
|
-
console.print(f"\n[cyan]{self.update_notification}[/cyan]", style="bold")
|
|
85
|
+
"""Quit the application."""
|
|
98
86
|
self.exit()
|
|
99
87
|
|
|
100
88
|
def get_system_commands(self, screen: Screen[Any]) -> Iterable[SystemCommand]:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import json
|
|
2
|
-
from collections.abc import Sequence
|
|
2
|
+
from collections.abc import Generator, Sequence
|
|
3
3
|
|
|
4
4
|
from pydantic_ai.messages import (
|
|
5
5
|
BuiltinToolCallPart,
|
|
@@ -19,6 +19,7 @@ from textual.reactive import reactive
|
|
|
19
19
|
from textual.widget import Widget
|
|
20
20
|
from textual.widgets import Markdown
|
|
21
21
|
|
|
22
|
+
from shotgun.agents.models import UserAnswer
|
|
22
23
|
from shotgun.tui.components.vertical_tail import VerticalTail
|
|
23
24
|
from shotgun.tui.screens.chat_screen.hint_message import HintMessage, HintMessageWidget
|
|
24
25
|
|
|
@@ -86,7 +87,7 @@ class ChatHistory(Widget):
|
|
|
86
87
|
self.vertical_tail = VerticalTail()
|
|
87
88
|
|
|
88
89
|
with self.vertical_tail:
|
|
89
|
-
for item in self.
|
|
90
|
+
for item in self.filtered_items():
|
|
90
91
|
if isinstance(item, ModelRequest):
|
|
91
92
|
yield UserQuestionWidget(item)
|
|
92
93
|
elif isinstance(item, HintMessage):
|
|
@@ -98,6 +99,44 @@ class ChatHistory(Widget):
|
|
|
98
99
|
)
|
|
99
100
|
self.call_later(self.autoscroll)
|
|
100
101
|
|
|
102
|
+
def filtered_items(self) -> Generator[ModelMessage | HintMessage, None, None]:
|
|
103
|
+
for idx, next_item in enumerate(self.items):
|
|
104
|
+
prev_item = self.items[idx - 1] if idx > 0 else None
|
|
105
|
+
|
|
106
|
+
if isinstance(prev_item, ModelRequest) and isinstance(
|
|
107
|
+
next_item, ModelResponse
|
|
108
|
+
):
|
|
109
|
+
ask_user_tool_response_part = next(
|
|
110
|
+
(
|
|
111
|
+
part
|
|
112
|
+
for part in prev_item.parts
|
|
113
|
+
if isinstance(part, ToolReturnPart)
|
|
114
|
+
and part.tool_name == "ask_user"
|
|
115
|
+
),
|
|
116
|
+
None,
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
ask_user_part = next(
|
|
120
|
+
(
|
|
121
|
+
part
|
|
122
|
+
for part in next_item.parts
|
|
123
|
+
if isinstance(part, ToolCallPart)
|
|
124
|
+
and part.tool_name == "ask_user"
|
|
125
|
+
),
|
|
126
|
+
None,
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
if not ask_user_part or not ask_user_tool_response_part:
|
|
130
|
+
yield next_item
|
|
131
|
+
continue
|
|
132
|
+
if (
|
|
133
|
+
ask_user_tool_response_part.tool_call_id
|
|
134
|
+
== ask_user_part.tool_call_id
|
|
135
|
+
):
|
|
136
|
+
continue # don't emit tool call that happens after tool response
|
|
137
|
+
|
|
138
|
+
yield next_item
|
|
139
|
+
|
|
101
140
|
def update_messages(self, messages: list[ModelMessage | HintMessage]) -> None:
|
|
102
141
|
"""Update the displayed messages without recomposing."""
|
|
103
142
|
if not self.vertical_tail:
|
|
@@ -133,8 +172,8 @@ class UserQuestionWidget(Widget):
|
|
|
133
172
|
f"**>** {part.content if isinstance(part.content, str) else ''}\n\n"
|
|
134
173
|
)
|
|
135
174
|
elif isinstance(part, ToolReturnPart):
|
|
136
|
-
if part.tool_name == "ask_user"
|
|
137
|
-
acc += f"**>** {part.content['answer']}\n\n"
|
|
175
|
+
if part.tool_name == "ask_user":
|
|
176
|
+
acc += f"**>** {part.content.answer if isinstance(part.content, UserAnswer) else part.content['answer']}\n\n"
|
|
138
177
|
else:
|
|
139
178
|
# acc += " ∟ finished\n\n" # let's not show anything yet
|
|
140
179
|
pass
|
shotgun/utils/update_checker.py
CHANGED
|
@@ -1,125 +1,133 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""Simple auto-update functionality for shotgun-sh CLI."""
|
|
2
2
|
|
|
3
|
-
import json
|
|
4
3
|
import subprocess
|
|
5
4
|
import sys
|
|
6
5
|
import threading
|
|
7
|
-
from collections.abc import Callable
|
|
8
|
-
from datetime import datetime, timedelta, timezone
|
|
9
6
|
from pathlib import Path
|
|
10
7
|
|
|
11
|
-
import httpx
|
|
12
|
-
from packaging import version
|
|
13
|
-
from pydantic import BaseModel, Field, ValidationError
|
|
14
|
-
|
|
15
|
-
from shotgun import __version__
|
|
16
8
|
from shotgun.logging_config import get_logger
|
|
17
|
-
from shotgun.utils.file_system_utils import get_shotgun_home
|
|
18
9
|
|
|
19
10
|
logger = get_logger(__name__)
|
|
20
11
|
|
|
21
|
-
# Configuration constants
|
|
22
|
-
UPDATE_CHECK_INTERVAL = timedelta(hours=24)
|
|
23
|
-
PYPI_API_URL = "https://pypi.org/pypi/shotgun-sh/json"
|
|
24
|
-
REQUEST_TIMEOUT = 5.0 # seconds
|
|
25
|
-
|
|
26
12
|
|
|
27
|
-
def
|
|
28
|
-
"""
|
|
13
|
+
def detect_installation_method() -> str:
|
|
14
|
+
"""Detect how shotgun-sh was installed.
|
|
29
15
|
|
|
30
16
|
Returns:
|
|
31
|
-
|
|
17
|
+
Installation method: 'pipx', 'pip', 'venv', or 'unknown'.
|
|
32
18
|
"""
|
|
33
|
-
|
|
19
|
+
# Check for pipx installation
|
|
20
|
+
try:
|
|
21
|
+
result = subprocess.run(
|
|
22
|
+
["pipx", "list", "--short"], # noqa: S607
|
|
23
|
+
capture_output=True,
|
|
24
|
+
text=True,
|
|
25
|
+
timeout=5, # noqa: S603
|
|
26
|
+
)
|
|
27
|
+
if "shotgun-sh" in result.stdout:
|
|
28
|
+
logger.debug("Detected pipx installation")
|
|
29
|
+
return "pipx"
|
|
30
|
+
except (subprocess.SubprocessError, FileNotFoundError):
|
|
31
|
+
pass
|
|
34
32
|
|
|
33
|
+
# Check if we're in a virtual environment
|
|
34
|
+
if hasattr(sys, "real_prefix") or (
|
|
35
|
+
hasattr(sys, "base_prefix") and sys.base_prefix != sys.prefix
|
|
36
|
+
):
|
|
37
|
+
logger.debug("Detected virtual environment installation")
|
|
38
|
+
return "venv"
|
|
35
39
|
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
# Check for user installation
|
|
41
|
+
import site
|
|
38
42
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
user_site = site.getusersitepackages()
|
|
44
|
+
if user_site and Path(user_site).exists():
|
|
45
|
+
shotgun_path = Path(user_site) / "shotgun"
|
|
46
|
+
if shotgun_path.exists() or any(
|
|
47
|
+
p.exists() for p in Path(user_site).glob("shotgun_sh*")
|
|
48
|
+
):
|
|
49
|
+
logger.debug("Detected pip --user installation")
|
|
50
|
+
return "pip"
|
|
45
51
|
|
|
52
|
+
# Default to pip if we can't determine
|
|
53
|
+
logger.debug("Could not detect installation method, defaulting to pip")
|
|
54
|
+
return "pip"
|
|
46
55
|
|
|
47
|
-
def is_dev_version(version_str: str | None = None) -> bool:
|
|
48
|
-
"""Check if the current or given version is a development version.
|
|
49
56
|
|
|
50
|
-
|
|
51
|
-
|
|
57
|
+
def perform_auto_update(no_update_check: bool = False) -> None:
|
|
58
|
+
"""Perform automatic update if installed via pipx.
|
|
52
59
|
|
|
53
|
-
|
|
54
|
-
|
|
60
|
+
Args:
|
|
61
|
+
no_update_check: If True, skip the update.
|
|
55
62
|
"""
|
|
56
|
-
|
|
57
|
-
|
|
63
|
+
if no_update_check:
|
|
64
|
+
return
|
|
58
65
|
|
|
66
|
+
try:
|
|
67
|
+
# Only auto-update for pipx installations
|
|
68
|
+
if detect_installation_method() != "pipx":
|
|
69
|
+
logger.debug("Not a pipx installation, skipping auto-update")
|
|
70
|
+
return
|
|
59
71
|
|
|
60
|
-
|
|
61
|
-
|
|
72
|
+
# Run pipx upgrade quietly
|
|
73
|
+
logger.debug("Running pipx upgrade shotgun-sh --quiet")
|
|
74
|
+
result = subprocess.run(
|
|
75
|
+
["pipx", "upgrade", "shotgun-sh", "--quiet"], # noqa: S607, S603
|
|
76
|
+
capture_output=True,
|
|
77
|
+
text=True,
|
|
78
|
+
timeout=30,
|
|
79
|
+
)
|
|
62
80
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
81
|
+
if result.returncode == 0:
|
|
82
|
+
# Check if there was an actual update (pipx shows output even with --quiet for actual updates)
|
|
83
|
+
if result.stdout and "upgraded" in result.stdout.lower():
|
|
84
|
+
logger.info("Shotgun-sh has been updated to the latest version")
|
|
85
|
+
else:
|
|
86
|
+
# Only log errors at debug level to not annoy users
|
|
87
|
+
logger.debug(f"Auto-update check failed: {result.stderr or result.stdout}")
|
|
69
88
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
except (json.JSONDecodeError, OSError, PermissionError, ValidationError) as e:
|
|
75
|
-
logger.debug(f"Failed to load cache: {e}")
|
|
76
|
-
return None
|
|
89
|
+
except subprocess.TimeoutExpired:
|
|
90
|
+
logger.debug("Auto-update timed out")
|
|
91
|
+
except Exception as e:
|
|
92
|
+
logger.debug(f"Auto-update error: {e}")
|
|
77
93
|
|
|
78
94
|
|
|
79
|
-
def
|
|
80
|
-
"""
|
|
95
|
+
def perform_auto_update_async(no_update_check: bool = False) -> threading.Thread:
|
|
96
|
+
"""Run auto-update in a background thread.
|
|
81
97
|
|
|
82
98
|
Args:
|
|
83
|
-
|
|
99
|
+
no_update_check: If True, skip the update.
|
|
100
|
+
|
|
101
|
+
Returns:
|
|
102
|
+
The thread object that was started.
|
|
84
103
|
"""
|
|
85
|
-
cache_file = get_cache_file()
|
|
86
104
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
cache_file.parent.mkdir(parents=True, exist_ok=True)
|
|
105
|
+
def _run_update() -> None:
|
|
106
|
+
perform_auto_update(no_update_check)
|
|
90
107
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
logger.debug(f"Failed to save cache: {e}")
|
|
108
|
+
thread = threading.Thread(target=_run_update, daemon=True)
|
|
109
|
+
thread.start()
|
|
110
|
+
return thread
|
|
95
111
|
|
|
96
112
|
|
|
97
|
-
|
|
98
|
-
|
|
113
|
+
# Keep these for backward compatibility with the update CLI command
|
|
114
|
+
import httpx # noqa: E402
|
|
115
|
+
from packaging import version # noqa: E402
|
|
99
116
|
|
|
100
|
-
|
|
101
|
-
no_update_check: If True, skip update checks.
|
|
117
|
+
from shotgun import __version__ # noqa: E402
|
|
102
118
|
|
|
103
|
-
Returns:
|
|
104
|
-
True if update check should be performed, False otherwise.
|
|
105
|
-
"""
|
|
106
|
-
# Skip if explicitly disabled
|
|
107
|
-
if no_update_check:
|
|
108
|
-
return False
|
|
109
119
|
|
|
110
|
-
|
|
111
|
-
if
|
|
112
|
-
logger.debug("Skipping update check for development version")
|
|
113
|
-
return False
|
|
120
|
+
def is_dev_version(version_str: str | None = None) -> bool:
|
|
121
|
+
"""Check if the current or given version is a development version.
|
|
114
122
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if not cache:
|
|
118
|
-
return True
|
|
123
|
+
Args:
|
|
124
|
+
version_str: Version string to check. If None, uses current version.
|
|
119
125
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
126
|
+
Returns:
|
|
127
|
+
True if version contains 'dev', False otherwise.
|
|
128
|
+
"""
|
|
129
|
+
check_version = version_str or __version__
|
|
130
|
+
return "dev" in check_version.lower()
|
|
123
131
|
|
|
124
132
|
|
|
125
133
|
def get_latest_version() -> str | None:
|
|
@@ -129,20 +137,16 @@ def get_latest_version() -> str | None:
|
|
|
129
137
|
Latest version string if successful, None otherwise.
|
|
130
138
|
"""
|
|
131
139
|
try:
|
|
132
|
-
with httpx.Client(timeout=
|
|
133
|
-
response = client.get(
|
|
140
|
+
with httpx.Client(timeout=5.0) as client:
|
|
141
|
+
response = client.get("https://pypi.org/pypi/shotgun-sh/json")
|
|
134
142
|
response.raise_for_status()
|
|
135
|
-
|
|
136
143
|
data = response.json()
|
|
137
144
|
latest = data.get("info", {}).get("version")
|
|
138
|
-
|
|
139
145
|
if latest:
|
|
140
146
|
logger.debug(f"Latest version from PyPI: {latest}")
|
|
141
147
|
return str(latest)
|
|
142
|
-
|
|
143
|
-
except (httpx.RequestError, httpx.HTTPStatusError, json.JSONDecodeError) as e:
|
|
148
|
+
except (httpx.RequestError, httpx.HTTPStatusError) as e:
|
|
144
149
|
logger.debug(f"Failed to fetch latest version: {e}")
|
|
145
|
-
|
|
146
150
|
return None
|
|
147
151
|
|
|
148
152
|
|
|
@@ -165,50 +169,6 @@ def compare_versions(current: str, latest: str) -> bool:
|
|
|
165
169
|
return False
|
|
166
170
|
|
|
167
171
|
|
|
168
|
-
def detect_installation_method() -> str:
|
|
169
|
-
"""Detect how shotgun-sh was installed.
|
|
170
|
-
|
|
171
|
-
Returns:
|
|
172
|
-
Installation method: 'pipx', 'pip', 'venv', or 'unknown'.
|
|
173
|
-
"""
|
|
174
|
-
# Check for pipx installation
|
|
175
|
-
try:
|
|
176
|
-
result = subprocess.run(
|
|
177
|
-
["pipx", "list", "--short"], # noqa: S607
|
|
178
|
-
capture_output=True,
|
|
179
|
-
text=True,
|
|
180
|
-
timeout=30, # noqa: S603
|
|
181
|
-
)
|
|
182
|
-
if "shotgun-sh" in result.stdout:
|
|
183
|
-
logger.debug("Detected pipx installation")
|
|
184
|
-
return "pipx"
|
|
185
|
-
except (subprocess.SubprocessError, FileNotFoundError):
|
|
186
|
-
pass
|
|
187
|
-
|
|
188
|
-
# Check if we're in a virtual environment
|
|
189
|
-
if hasattr(sys, "real_prefix") or (
|
|
190
|
-
hasattr(sys, "base_prefix") and sys.base_prefix != sys.prefix
|
|
191
|
-
):
|
|
192
|
-
logger.debug("Detected virtual environment installation")
|
|
193
|
-
return "venv"
|
|
194
|
-
|
|
195
|
-
# Check for user installation
|
|
196
|
-
import site
|
|
197
|
-
|
|
198
|
-
user_site = site.getusersitepackages()
|
|
199
|
-
if user_site and Path(user_site).exists():
|
|
200
|
-
shotgun_path = Path(user_site) / "shotgun"
|
|
201
|
-
if shotgun_path.exists() or any(
|
|
202
|
-
p.exists() for p in Path(user_site).glob("shotgun_sh*")
|
|
203
|
-
):
|
|
204
|
-
logger.debug("Detected pip --user installation")
|
|
205
|
-
return "pip"
|
|
206
|
-
|
|
207
|
-
# Default to pip if we can't determine
|
|
208
|
-
logger.debug("Could not detect installation method, defaulting to pip")
|
|
209
|
-
return "pip"
|
|
210
|
-
|
|
211
|
-
|
|
212
172
|
def get_update_command(method: str) -> list[str]:
|
|
213
173
|
"""Get the appropriate update command based on installation method.
|
|
214
174
|
|
|
@@ -228,17 +188,17 @@ def get_update_command(method: str) -> list[str]:
|
|
|
228
188
|
|
|
229
189
|
|
|
230
190
|
def perform_update(force: bool = False) -> tuple[bool, str]:
|
|
231
|
-
"""Perform
|
|
191
|
+
"""Perform manual update of shotgun-sh (for CLI command).
|
|
232
192
|
|
|
233
193
|
Args:
|
|
234
|
-
force: If True, update even if it's a dev version
|
|
194
|
+
force: If True, update even if it's a dev version.
|
|
235
195
|
|
|
236
196
|
Returns:
|
|
237
197
|
Tuple of (success, message).
|
|
238
198
|
"""
|
|
239
199
|
# Check if dev version and not forced
|
|
240
200
|
if is_dev_version() and not force:
|
|
241
|
-
return False, "Cannot
|
|
201
|
+
return False, "Cannot update development version. Use --force to override."
|
|
242
202
|
|
|
243
203
|
# Get latest version
|
|
244
204
|
latest = get_latest_version()
|
|
@@ -263,12 +223,6 @@ def perform_update(force: bool = False) -> tuple[bool, str]:
|
|
|
263
223
|
if result.returncode == 0:
|
|
264
224
|
message = f"Successfully updated from {__version__} to {latest}"
|
|
265
225
|
logger.info(message)
|
|
266
|
-
|
|
267
|
-
# Clear cache to trigger fresh check next time
|
|
268
|
-
cache_file = get_cache_file()
|
|
269
|
-
if cache_file.exists():
|
|
270
|
-
cache_file.unlink()
|
|
271
|
-
|
|
272
226
|
return True, message
|
|
273
227
|
else:
|
|
274
228
|
error_msg = f"Update failed: {result.stderr or result.stdout}"
|
|
@@ -281,95 +235,13 @@ def perform_update(force: bool = False) -> tuple[bool, str]:
|
|
|
281
235
|
return False, f"Update failed: {e}"
|
|
282
236
|
|
|
283
237
|
|
|
284
|
-
def format_update_notification(current: str, latest: str) -> str:
|
|
285
|
-
"""Format a user-friendly update notification message.
|
|
286
|
-
|
|
287
|
-
Args:
|
|
288
|
-
current: Current version.
|
|
289
|
-
latest: Latest available version.
|
|
290
|
-
|
|
291
|
-
Returns:
|
|
292
|
-
Formatted notification string.
|
|
293
|
-
"""
|
|
294
|
-
return f"Update available: {current} → {latest}. Run 'shotgun update' to upgrade."
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
def check_for_updates_sync(no_update_check: bool = False) -> str | None:
|
|
298
|
-
"""Synchronously check for updates and return notification if available.
|
|
299
|
-
|
|
300
|
-
Args:
|
|
301
|
-
no_update_check: If True, skip update checks.
|
|
302
|
-
|
|
303
|
-
Returns:
|
|
304
|
-
Update notification string if update available, None otherwise.
|
|
305
|
-
"""
|
|
306
|
-
if not should_check_for_updates(no_update_check):
|
|
307
|
-
# Check cache for existing notification
|
|
308
|
-
cache = load_cache()
|
|
309
|
-
if cache and cache.update_available:
|
|
310
|
-
current = cache.current_version
|
|
311
|
-
latest = cache.latest_version
|
|
312
|
-
if compare_versions(current, latest):
|
|
313
|
-
return format_update_notification(current, latest)
|
|
314
|
-
return None
|
|
315
|
-
|
|
316
|
-
latest_version = get_latest_version()
|
|
317
|
-
if not latest_version:
|
|
318
|
-
return None
|
|
319
|
-
latest = latest_version # Type narrowing - we know it's not None here
|
|
320
|
-
|
|
321
|
-
# Update cache
|
|
322
|
-
now = datetime.now(timezone.utc)
|
|
323
|
-
update_available = compare_versions(__version__, latest)
|
|
324
|
-
|
|
325
|
-
cache_data = UpdateCache(
|
|
326
|
-
last_check=now,
|
|
327
|
-
latest_version=latest,
|
|
328
|
-
current_version=__version__,
|
|
329
|
-
update_available=update_available,
|
|
330
|
-
)
|
|
331
|
-
save_cache(cache_data)
|
|
332
|
-
|
|
333
|
-
if update_available:
|
|
334
|
-
return format_update_notification(__version__, latest)
|
|
335
|
-
|
|
336
|
-
return None
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
def check_for_updates_async(
|
|
340
|
-
callback: Callable[[str], None] | None = None, no_update_check: bool = False
|
|
341
|
-
) -> threading.Thread:
|
|
342
|
-
"""Asynchronously check for updates in a background thread.
|
|
343
|
-
|
|
344
|
-
Args:
|
|
345
|
-
callback: Optional callback function to call with notification string.
|
|
346
|
-
no_update_check: If True, skip update checks.
|
|
347
|
-
|
|
348
|
-
Returns:
|
|
349
|
-
The thread object that was started.
|
|
350
|
-
"""
|
|
351
|
-
|
|
352
|
-
def _check_updates() -> None:
|
|
353
|
-
try:
|
|
354
|
-
notification = check_for_updates_sync(no_update_check)
|
|
355
|
-
if notification and callback:
|
|
356
|
-
callback(notification)
|
|
357
|
-
except Exception as e:
|
|
358
|
-
logger.debug(f"Error in async update check: {e}")
|
|
359
|
-
|
|
360
|
-
thread = threading.Thread(target=_check_updates, daemon=True)
|
|
361
|
-
thread.start()
|
|
362
|
-
return thread
|
|
363
|
-
|
|
364
|
-
|
|
365
238
|
__all__ = [
|
|
366
|
-
"
|
|
239
|
+
"detect_installation_method",
|
|
240
|
+
"perform_auto_update",
|
|
241
|
+
"perform_auto_update_async",
|
|
367
242
|
"is_dev_version",
|
|
368
|
-
"should_check_for_updates",
|
|
369
243
|
"get_latest_version",
|
|
370
|
-
"
|
|
244
|
+
"compare_versions",
|
|
245
|
+
"get_update_command",
|
|
371
246
|
"perform_update",
|
|
372
|
-
"check_for_updates_async",
|
|
373
|
-
"check_for_updates_sync",
|
|
374
|
-
"format_update_notification",
|
|
375
247
|
]
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
shotgun/__init__.py,sha256=P40K0fnIsb7SKcQrFnXZ4aREjpWchVDhvM1HxI4cyIQ,104
|
|
2
2
|
shotgun/build_constants.py,sha256=RXNxMz46HaB5jucgMVpw8a2yCJqjbhTOh0PddyEVMN8,713
|
|
3
3
|
shotgun/logging_config.py,sha256=UKenihvgH8OA3W0b8ZFcItYaFJVe9MlsMYlcevyW1HY,7440
|
|
4
|
-
shotgun/main.py,sha256=
|
|
4
|
+
shotgun/main.py,sha256=qteehx2FyqPVvSRNawEMorybNiIrYfgVeqtMaASQcPw,4606
|
|
5
5
|
shotgun/posthog_telemetry.py,sha256=usfaJ8VyqckLIbLgoj2yhuNyDh0VWA5EJPRr7a0dyVs,5054
|
|
6
6
|
shotgun/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
7
|
shotgun/sentry_telemetry.py,sha256=0W0o810ewFpIcdPsi_q4uKLiaP6zDYRRE5MHpIbQIPo,2954
|
|
8
8
|
shotgun/telemetry.py,sha256=Ves6Ih3hshpKVNVAUUmwRdtW8NkTjFPg8hEqvFKZ0t0,3208
|
|
9
9
|
shotgun/agents/__init__.py,sha256=8Jzv1YsDuLyNPFJyckSr_qI4ehTVeDyIMDW4omsfPGc,25
|
|
10
|
-
shotgun/agents/agent_manager.py,sha256=
|
|
10
|
+
shotgun/agents/agent_manager.py,sha256=xSyra7R8s8RP2N0Oh1fYlwu46EB16npRNckzKGY-rGg,23578
|
|
11
11
|
shotgun/agents/common.py,sha256=vt7ECq1rT6GR5Rt63t0whH0R0cydrk7Mty2KyPL8mEg,19045
|
|
12
12
|
shotgun/agents/conversation_history.py,sha256=5J8_1yxdZiiWTq22aDio88DkBDZ4_Lh_p5Iy5_ENszc,3898
|
|
13
13
|
shotgun/agents/conversation_manager.py,sha256=fxAvXbEl3Cl2ugJ4N9aWXaqZtkrnfj3QzwjWC4LFXwI,3514
|
|
@@ -102,7 +102,7 @@ shotgun/sdk/exceptions.py,sha256=qBcQv0v7ZTwP7CMcxZST4GqCsfOWtOUjSzGBo0-heqo,412
|
|
|
102
102
|
shotgun/sdk/models.py,sha256=X9nOTUHH0cdkQW1NfnMEDu-QgK9oUsEISh1Jtwr5Am4,5496
|
|
103
103
|
shotgun/sdk/services.py,sha256=J4PJFSxCQ6--u7rb3Ta-9eYtlYcxcbnzrMP6ThyCnw4,705
|
|
104
104
|
shotgun/tui/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
105
|
-
shotgun/tui/app.py,sha256=
|
|
105
|
+
shotgun/tui/app.py,sha256=rNi1a2vIhu385-DylE1rYgVj3_cok65X_z1lEamrFqo,3445
|
|
106
106
|
shotgun/tui/styles.tcss,sha256=ETyyw1bpMBOqTi5RLcAJUScdPWTvAWEqE9YcT0kVs_E,121
|
|
107
107
|
shotgun/tui/commands/__init__.py,sha256=8D5lvtpqMW5-fF7Bg3oJtUzU75cKOv6aUaHYYszydU8,2518
|
|
108
108
|
shotgun/tui/components/prompt_input.py,sha256=Ss-htqraHZAPaehGE4x86ij0veMjc4UgadMXpbdXr40,2229
|
|
@@ -117,15 +117,15 @@ shotgun/tui/screens/splash.py,sha256=E2MsJihi3c9NY1L28o_MstDxGwrCnnV7zdq00MrGAsw
|
|
|
117
117
|
shotgun/tui/screens/chat_screen/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
118
118
|
shotgun/tui/screens/chat_screen/command_providers.py,sha256=55JIH9T8QnyHRsMoXhOi87FiVM-d6o7OKpCe82uDP9I,7840
|
|
119
119
|
shotgun/tui/screens/chat_screen/hint_message.py,sha256=WOpbk8q7qt7eOHTyyHvh_IQIaublVDeJGaLpsxEk9FA,933
|
|
120
|
-
shotgun/tui/screens/chat_screen/history.py,sha256=
|
|
120
|
+
shotgun/tui/screens/chat_screen/history.py,sha256=pmgtvPDcY4dyxLyMH0RrVmf8qBouW1hM99VSUn7XGPQ,8950
|
|
121
121
|
shotgun/tui/utils/__init__.py,sha256=cFjDfoXTRBq29wgP7TGRWUu1eFfiIG-LLOzjIGfadgI,150
|
|
122
122
|
shotgun/tui/utils/mode_progress.py,sha256=lseRRo7kMWLkBzI3cU5vqJmS2ZcCjyRYf9Zwtvc-v58,10931
|
|
123
123
|
shotgun/utils/__init__.py,sha256=WinIEp9oL2iMrWaDkXz2QX4nYVPAm8C9aBSKTeEwLtE,198
|
|
124
124
|
shotgun/utils/env_utils.py,sha256=8QK5aw_f_V2AVTleQQlcL0RnD4sPJWXlDG46fsHu0d8,1057
|
|
125
125
|
shotgun/utils/file_system_utils.py,sha256=l-0p1bEHF34OU19MahnRFdClHufThfGAjQ431teAIp0,1004
|
|
126
|
-
shotgun/utils/update_checker.py,sha256=
|
|
127
|
-
shotgun_sh-0.1.
|
|
128
|
-
shotgun_sh-0.1.
|
|
129
|
-
shotgun_sh-0.1.
|
|
130
|
-
shotgun_sh-0.1.
|
|
131
|
-
shotgun_sh-0.1.
|
|
126
|
+
shotgun/utils/update_checker.py,sha256=TorvPRLtTVVNrTdKFZCfhrz9CQfkJZa4Mi9vQgsppvM,7698
|
|
127
|
+
shotgun_sh-0.1.10.dev1.dist-info/METADATA,sha256=lOgwJ67x2-dV2pZjAW8GpJsPaYhZia4C7b5Ta-XaYr8,11197
|
|
128
|
+
shotgun_sh-0.1.10.dev1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
129
|
+
shotgun_sh-0.1.10.dev1.dist-info/entry_points.txt,sha256=asZxLU4QILneq0MWW10saVCZc4VWhZfb0wFZvERnzfA,45
|
|
130
|
+
shotgun_sh-0.1.10.dev1.dist-info/licenses/LICENSE,sha256=YebsZl590zCHrF_acCU5pmNt0pnAfD2DmAnevJPB1tY,1065
|
|
131
|
+
shotgun_sh-0.1.10.dev1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|