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

@@ -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
 
@@ -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.items:
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" and isinstance(part.content, dict):
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: shotgun-sh
3
- Version: 0.1.9
3
+ Version: 0.1.10
4
4
  Summary: AI-powered research, planning, and task management CLI tool
5
5
  Project-URL: Homepage, https://shotgun.sh/
6
6
  Project-URL: Repository, https://github.com/shotgun-sh/shotgun
@@ -7,7 +7,7 @@ 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=xw9xNEwVU-P4NGqF8W6mzVw4HNqtSfegAN9atog7aEo,23813
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
@@ -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=JjQOKjCZpLBcw9CMorkBjOt2U5Ikr81hEQRtQmhw_KM,7459
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
126
  shotgun/utils/update_checker.py,sha256=TorvPRLtTVVNrTdKFZCfhrz9CQfkJZa4Mi9vQgsppvM,7698
127
- shotgun_sh-0.1.9.dist-info/METADATA,sha256=YIhhJFDkWJlANPFrZqI2-MbLnOj8Z1daZulls9TfsZE,11191
128
- shotgun_sh-0.1.9.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
129
- shotgun_sh-0.1.9.dist-info/entry_points.txt,sha256=asZxLU4QILneq0MWW10saVCZc4VWhZfb0wFZvERnzfA,45
130
- shotgun_sh-0.1.9.dist-info/licenses/LICENSE,sha256=YebsZl590zCHrF_acCU5pmNt0pnAfD2DmAnevJPB1tY,1065
131
- shotgun_sh-0.1.9.dist-info/RECORD,,
127
+ shotgun_sh-0.1.10.dist-info/METADATA,sha256=7GJ-Ybz0uPRHDpT1H-niARSd3YaBJXPwcU7X9YpCZVk,11192
128
+ shotgun_sh-0.1.10.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
129
+ shotgun_sh-0.1.10.dist-info/entry_points.txt,sha256=asZxLU4QILneq0MWW10saVCZc4VWhZfb0wFZvERnzfA,45
130
+ shotgun_sh-0.1.10.dist-info/licenses/LICENSE,sha256=YebsZl590zCHrF_acCU5pmNt0pnAfD2DmAnevJPB1tY,1065
131
+ shotgun_sh-0.1.10.dist-info/RECORD,,