shotgun-sh 0.3.3.dev1__py3-none-any.whl → 0.6.2__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.
Files changed (159) hide show
  1. shotgun/agents/agent_manager.py +497 -30
  2. shotgun/agents/cancellation.py +103 -0
  3. shotgun/agents/common.py +90 -77
  4. shotgun/agents/config/README.md +0 -1
  5. shotgun/agents/config/manager.py +52 -8
  6. shotgun/agents/config/models.py +21 -27
  7. shotgun/agents/config/provider.py +44 -27
  8. shotgun/agents/conversation/history/file_content_deduplication.py +66 -43
  9. shotgun/agents/conversation/history/token_counting/base.py +51 -9
  10. shotgun/agents/export.py +12 -13
  11. shotgun/agents/file_read.py +176 -0
  12. shotgun/agents/messages.py +15 -3
  13. shotgun/agents/models.py +90 -2
  14. shotgun/agents/plan.py +12 -13
  15. shotgun/agents/research.py +13 -10
  16. shotgun/agents/router/__init__.py +47 -0
  17. shotgun/agents/router/models.py +384 -0
  18. shotgun/agents/router/router.py +185 -0
  19. shotgun/agents/router/tools/__init__.py +18 -0
  20. shotgun/agents/router/tools/delegation_tools.py +557 -0
  21. shotgun/agents/router/tools/plan_tools.py +403 -0
  22. shotgun/agents/runner.py +17 -2
  23. shotgun/agents/specify.py +12 -13
  24. shotgun/agents/tasks.py +12 -13
  25. shotgun/agents/tools/__init__.py +8 -0
  26. shotgun/agents/tools/codebase/directory_lister.py +27 -39
  27. shotgun/agents/tools/codebase/file_read.py +26 -35
  28. shotgun/agents/tools/codebase/query_graph.py +9 -0
  29. shotgun/agents/tools/codebase/retrieve_code.py +9 -0
  30. shotgun/agents/tools/file_management.py +81 -3
  31. shotgun/agents/tools/file_read_tools/__init__.py +7 -0
  32. shotgun/agents/tools/file_read_tools/multimodal_file_read.py +167 -0
  33. shotgun/agents/tools/markdown_tools/__init__.py +62 -0
  34. shotgun/agents/tools/markdown_tools/insert_section.py +148 -0
  35. shotgun/agents/tools/markdown_tools/models.py +86 -0
  36. shotgun/agents/tools/markdown_tools/remove_section.py +114 -0
  37. shotgun/agents/tools/markdown_tools/replace_section.py +119 -0
  38. shotgun/agents/tools/markdown_tools/utils.py +453 -0
  39. shotgun/agents/tools/registry.py +46 -6
  40. shotgun/agents/tools/web_search/__init__.py +1 -2
  41. shotgun/agents/tools/web_search/gemini.py +1 -3
  42. shotgun/agents/tools/web_search/openai.py +42 -23
  43. shotgun/attachments/__init__.py +41 -0
  44. shotgun/attachments/errors.py +60 -0
  45. shotgun/attachments/models.py +107 -0
  46. shotgun/attachments/parser.py +257 -0
  47. shotgun/attachments/processor.py +193 -0
  48. shotgun/build_constants.py +4 -7
  49. shotgun/cli/clear.py +2 -2
  50. shotgun/cli/codebase/commands.py +181 -65
  51. shotgun/cli/compact.py +2 -2
  52. shotgun/cli/context.py +2 -2
  53. shotgun/cli/error_handler.py +2 -2
  54. shotgun/cli/run.py +90 -0
  55. shotgun/cli/spec/backup.py +2 -1
  56. shotgun/codebase/__init__.py +2 -0
  57. shotgun/codebase/benchmarks/__init__.py +35 -0
  58. shotgun/codebase/benchmarks/benchmark_runner.py +309 -0
  59. shotgun/codebase/benchmarks/exporters.py +119 -0
  60. shotgun/codebase/benchmarks/formatters/__init__.py +49 -0
  61. shotgun/codebase/benchmarks/formatters/base.py +34 -0
  62. shotgun/codebase/benchmarks/formatters/json_formatter.py +106 -0
  63. shotgun/codebase/benchmarks/formatters/markdown.py +136 -0
  64. shotgun/codebase/benchmarks/models.py +129 -0
  65. shotgun/codebase/core/__init__.py +4 -0
  66. shotgun/codebase/core/call_resolution.py +91 -0
  67. shotgun/codebase/core/change_detector.py +11 -6
  68. shotgun/codebase/core/errors.py +159 -0
  69. shotgun/codebase/core/extractors/__init__.py +23 -0
  70. shotgun/codebase/core/extractors/base.py +138 -0
  71. shotgun/codebase/core/extractors/factory.py +63 -0
  72. shotgun/codebase/core/extractors/go/__init__.py +7 -0
  73. shotgun/codebase/core/extractors/go/extractor.py +122 -0
  74. shotgun/codebase/core/extractors/javascript/__init__.py +7 -0
  75. shotgun/codebase/core/extractors/javascript/extractor.py +132 -0
  76. shotgun/codebase/core/extractors/protocol.py +109 -0
  77. shotgun/codebase/core/extractors/python/__init__.py +7 -0
  78. shotgun/codebase/core/extractors/python/extractor.py +141 -0
  79. shotgun/codebase/core/extractors/rust/__init__.py +7 -0
  80. shotgun/codebase/core/extractors/rust/extractor.py +139 -0
  81. shotgun/codebase/core/extractors/types.py +15 -0
  82. shotgun/codebase/core/extractors/typescript/__init__.py +7 -0
  83. shotgun/codebase/core/extractors/typescript/extractor.py +92 -0
  84. shotgun/codebase/core/gitignore.py +252 -0
  85. shotgun/codebase/core/ingestor.py +644 -354
  86. shotgun/codebase/core/kuzu_compat.py +119 -0
  87. shotgun/codebase/core/language_config.py +239 -0
  88. shotgun/codebase/core/manager.py +256 -46
  89. shotgun/codebase/core/metrics_collector.py +310 -0
  90. shotgun/codebase/core/metrics_types.py +347 -0
  91. shotgun/codebase/core/parallel_executor.py +424 -0
  92. shotgun/codebase/core/work_distributor.py +254 -0
  93. shotgun/codebase/core/worker.py +768 -0
  94. shotgun/codebase/indexing_state.py +86 -0
  95. shotgun/codebase/models.py +94 -0
  96. shotgun/codebase/service.py +13 -0
  97. shotgun/exceptions.py +9 -9
  98. shotgun/main.py +3 -16
  99. shotgun/posthog_telemetry.py +165 -24
  100. shotgun/prompts/agents/export.j2 +2 -0
  101. shotgun/prompts/agents/file_read.j2 +48 -0
  102. shotgun/prompts/agents/partials/common_agent_system_prompt.j2 +19 -52
  103. shotgun/prompts/agents/partials/content_formatting.j2 +12 -33
  104. shotgun/prompts/agents/partials/interactive_mode.j2 +9 -32
  105. shotgun/prompts/agents/partials/router_delegation_mode.j2 +35 -0
  106. shotgun/prompts/agents/plan.j2 +38 -12
  107. shotgun/prompts/agents/research.j2 +70 -31
  108. shotgun/prompts/agents/router.j2 +713 -0
  109. shotgun/prompts/agents/specify.j2 +53 -16
  110. shotgun/prompts/agents/state/codebase/codebase_graphs_available.j2 +14 -1
  111. shotgun/prompts/agents/state/system_state.j2 +24 -13
  112. shotgun/prompts/agents/tasks.j2 +72 -34
  113. shotgun/settings.py +49 -10
  114. shotgun/tui/app.py +154 -24
  115. shotgun/tui/commands/__init__.py +9 -1
  116. shotgun/tui/components/attachment_bar.py +87 -0
  117. shotgun/tui/components/mode_indicator.py +120 -25
  118. shotgun/tui/components/prompt_input.py +25 -28
  119. shotgun/tui/components/status_bar.py +14 -7
  120. shotgun/tui/dependencies.py +58 -8
  121. shotgun/tui/protocols.py +55 -0
  122. shotgun/tui/screens/chat/chat.tcss +24 -1
  123. shotgun/tui/screens/chat/chat_screen.py +1376 -213
  124. shotgun/tui/screens/chat/codebase_index_prompt_screen.py +8 -4
  125. shotgun/tui/screens/chat_screen/attachment_hint.py +40 -0
  126. shotgun/tui/screens/chat_screen/command_providers.py +0 -97
  127. shotgun/tui/screens/chat_screen/history/agent_response.py +7 -3
  128. shotgun/tui/screens/chat_screen/history/chat_history.py +58 -6
  129. shotgun/tui/screens/chat_screen/history/formatters.py +75 -15
  130. shotgun/tui/screens/chat_screen/history/partial_response.py +11 -1
  131. shotgun/tui/screens/chat_screen/history/user_question.py +25 -3
  132. shotgun/tui/screens/chat_screen/messages.py +219 -0
  133. shotgun/tui/screens/database_locked_dialog.py +219 -0
  134. shotgun/tui/screens/database_timeout_dialog.py +158 -0
  135. shotgun/tui/screens/kuzu_error_dialog.py +135 -0
  136. shotgun/tui/screens/model_picker.py +1 -3
  137. shotgun/tui/screens/models.py +11 -0
  138. shotgun/tui/state/processing_state.py +19 -0
  139. shotgun/tui/utils/mode_progress.py +20 -86
  140. shotgun/tui/widgets/__init__.py +2 -1
  141. shotgun/tui/widgets/approval_widget.py +152 -0
  142. shotgun/tui/widgets/cascade_confirmation_widget.py +203 -0
  143. shotgun/tui/widgets/plan_panel.py +129 -0
  144. shotgun/tui/widgets/step_checkpoint_widget.py +180 -0
  145. shotgun/tui/widgets/widget_coordinator.py +18 -0
  146. shotgun/utils/file_system_utils.py +4 -1
  147. {shotgun_sh-0.3.3.dev1.dist-info → shotgun_sh-0.6.2.dist-info}/METADATA +88 -35
  148. shotgun_sh-0.6.2.dist-info/RECORD +291 -0
  149. shotgun/cli/export.py +0 -81
  150. shotgun/cli/plan.py +0 -73
  151. shotgun/cli/research.py +0 -93
  152. shotgun/cli/specify.py +0 -70
  153. shotgun/cli/tasks.py +0 -78
  154. shotgun/sentry_telemetry.py +0 -232
  155. shotgun/tui/screens/onboarding.py +0 -580
  156. shotgun_sh-0.3.3.dev1.dist-info/RECORD +0 -229
  157. {shotgun_sh-0.3.3.dev1.dist-info → shotgun_sh-0.6.2.dist-info}/WHEEL +0 -0
  158. {shotgun_sh-0.3.3.dev1.dist-info → shotgun_sh-0.6.2.dist-info}/entry_points.txt +0 -0
  159. {shotgun_sh-0.3.3.dev1.dist-info → shotgun_sh-0.6.2.dist-info}/licenses/LICENSE +0 -0
@@ -1,13 +1,44 @@
1
1
  """Dependency creation utilities for TUI components."""
2
2
 
3
+ from typing import Any
4
+
3
5
  from pydantic_ai import RunContext
4
6
 
5
7
  from shotgun.agents.config import get_provider_model
8
+ from shotgun.agents.config.models import ModelConfig
6
9
  from shotgun.agents.models import AgentDeps
10
+ from shotgun.agents.router.models import RouterDeps, RouterMode
11
+ from shotgun.codebase.service import CodebaseService
7
12
  from shotgun.tui.filtered_codebase_service import FilteredCodebaseService
8
13
  from shotgun.utils import get_shotgun_home
9
14
 
10
15
 
16
+ async def _get_tui_config() -> tuple[ModelConfig, CodebaseService]:
17
+ """Get common TUI configuration components.
18
+
19
+ Returns:
20
+ Tuple of (model_config, codebase_service) for TUI deps.
21
+ """
22
+ model_config = await get_provider_model()
23
+ storage_dir = get_shotgun_home() / "codebases"
24
+ codebase_service = FilteredCodebaseService(storage_dir)
25
+ return model_config, codebase_service
26
+
27
+
28
+ def _placeholder_system_prompt_fn(ctx: RunContext[Any]) -> str:
29
+ """Placeholder system prompt that should never be called.
30
+
31
+ Agents provide their own system_prompt_fn via their create functions.
32
+ This placeholder exists only to satisfy the AgentDeps requirement.
33
+
34
+ Raises:
35
+ RuntimeError: Always, as this should never be invoked.
36
+ """
37
+ raise RuntimeError(
38
+ "This should not be called - agents provide their own system_prompt_fn"
39
+ )
40
+
41
+
11
42
  async def create_default_tui_deps() -> AgentDeps:
12
43
  """Create default AgentDeps for TUI components.
13
44
 
@@ -21,14 +52,7 @@ async def create_default_tui_deps() -> AgentDeps:
21
52
  Returns:
22
53
  Configured AgentDeps instance ready for TUI use.
23
54
  """
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
- )
55
+ model_config, codebase_service = await _get_tui_config()
32
56
 
33
57
  return AgentDeps(
34
58
  interactive_mode=True,
@@ -37,3 +61,29 @@ async def create_default_tui_deps() -> AgentDeps:
37
61
  codebase_service=codebase_service,
38
62
  system_prompt_fn=_placeholder_system_prompt_fn,
39
63
  )
64
+
65
+
66
+ async def create_default_router_deps() -> RouterDeps:
67
+ """Create default RouterDeps for TUI components with router mode.
68
+
69
+ This creates a RouterDeps configuration suitable for interactive
70
+ TUI usage with:
71
+ - Router mode always starts in PLANNING (not persisted)
72
+ - Interactive mode enabled
73
+ - TUI context flag set
74
+ - Filtered codebase service (restricted to CWD)
75
+ - Placeholder system prompt (router provides its own)
76
+
77
+ Returns:
78
+ Configured RouterDeps instance ready for TUI use.
79
+ """
80
+ model_config, codebase_service = await _get_tui_config()
81
+
82
+ return RouterDeps(
83
+ interactive_mode=True,
84
+ is_tui_context=True,
85
+ llm_model=model_config,
86
+ codebase_service=codebase_service,
87
+ system_prompt_fn=_placeholder_system_prompt_fn,
88
+ router_mode=RouterMode.PLANNING,
89
+ )
shotgun/tui/protocols.py CHANGED
@@ -43,3 +43,58 @@ class ProcessingStateProvider(Protocol):
43
43
  True if an agent is processing, False otherwise.
44
44
  """
45
45
  ...
46
+
47
+
48
+ @runtime_checkable
49
+ class RouterModeProvider(Protocol):
50
+ """Protocol for screens that provide router mode state.
51
+
52
+ This protocol allows components to check the current router mode
53
+ (Planning or Drafting) without importing the concrete ChatScreen class.
54
+ """
55
+
56
+ @property
57
+ def router_mode(self) -> str | None:
58
+ """The current router mode.
59
+
60
+ Returns:
61
+ 'planning' or 'drafting' if in router mode, None otherwise.
62
+ """
63
+ ...
64
+
65
+
66
+ @runtime_checkable
67
+ class ActiveSubAgentProvider(Protocol):
68
+ """Protocol for screens that provide active sub-agent state.
69
+
70
+ This protocol allows components to check which sub-agent is currently
71
+ executing during router delegation without importing ChatScreen.
72
+ """
73
+
74
+ @property
75
+ def active_sub_agent(self) -> str | None:
76
+ """The currently executing sub-agent type.
77
+
78
+ Returns:
79
+ The sub-agent type string (e.g., 'research', 'specify') if
80
+ a sub-agent is executing, None if idle.
81
+ """
82
+ ...
83
+
84
+
85
+ @runtime_checkable
86
+ class QuitConfirmationProvider(Protocol):
87
+ """Protocol for apps that provide quit confirmation state.
88
+
89
+ This protocol allows components (like StatusBar) to check if a quit
90
+ confirmation is pending without importing the concrete App class.
91
+ """
92
+
93
+ @property
94
+ def quit_pending(self) -> bool:
95
+ """Whether a quit confirmation is pending.
96
+
97
+ Returns:
98
+ True if user pressed Ctrl+C and needs to confirm quit.
99
+ """
100
+ ...
@@ -16,11 +16,19 @@ ModeIndicator {
16
16
  height: auto;
17
17
  }
18
18
 
19
+ ModeIndicator.mode-planning {
20
+ /* Blue/cyan accent for planning mode */
21
+ }
22
+
23
+ ModeIndicator.mode-drafting {
24
+ /* Green accent for drafting mode */
25
+ }
26
+
19
27
  #footer {
20
28
  dock: bottom;
21
29
  height: auto;
22
30
  padding: 1 1 1 2;
23
- max-height: 14;
31
+ max-height: 24;
24
32
  }
25
33
 
26
34
  #window {
@@ -51,4 +59,19 @@ ModeIndicator {
51
59
 
52
60
  #indexing-job-display {
53
61
  text-align: end;
62
+ }
63
+
64
+ AttachmentBar {
65
+ height: auto;
66
+ padding: 0 1;
67
+ background: $secondary-background;
68
+ margin-bottom: 1;
69
+ }
70
+
71
+ AttachmentBar.hidden {
72
+ display: none;
73
+ }
74
+
75
+ AttachmentBar Static {
76
+ color: $text-accent;
54
77
  }