shotgun-sh 0.2.23.dev1__py3-none-any.whl → 0.2.29.dev2__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 (86) hide show
  1. shotgun/agents/agent_manager.py +3 -3
  2. shotgun/agents/common.py +1 -1
  3. shotgun/agents/config/manager.py +36 -21
  4. shotgun/agents/config/models.py +30 -0
  5. shotgun/agents/config/provider.py +27 -14
  6. shotgun/agents/context_analyzer/analyzer.py +6 -2
  7. shotgun/agents/conversation/__init__.py +18 -0
  8. shotgun/agents/conversation/filters.py +164 -0
  9. shotgun/agents/conversation/history/chunking.py +278 -0
  10. shotgun/agents/{history → conversation/history}/compaction.py +27 -1
  11. shotgun/agents/{history → conversation/history}/constants.py +5 -0
  12. shotgun/agents/conversation/history/file_content_deduplication.py +216 -0
  13. shotgun/agents/{history → conversation/history}/history_processors.py +267 -3
  14. shotgun/agents/{conversation_manager.py → conversation/manager.py} +1 -1
  15. shotgun/agents/{conversation_history.py → conversation/models.py} +8 -94
  16. shotgun/agents/tools/web_search/openai.py +1 -1
  17. shotgun/cli/clear.py +1 -1
  18. shotgun/cli/compact.py +5 -3
  19. shotgun/cli/context.py +1 -1
  20. shotgun/cli/spec/__init__.py +5 -0
  21. shotgun/cli/spec/backup.py +81 -0
  22. shotgun/cli/spec/commands.py +130 -0
  23. shotgun/cli/spec/models.py +30 -0
  24. shotgun/cli/spec/pull_service.py +165 -0
  25. shotgun/codebase/core/ingestor.py +153 -7
  26. shotgun/codebase/models.py +2 -0
  27. shotgun/exceptions.py +5 -3
  28. shotgun/main.py +2 -0
  29. shotgun/posthog_telemetry.py +1 -1
  30. shotgun/prompts/agents/partials/common_agent_system_prompt.j2 +3 -3
  31. shotgun/prompts/agents/partials/interactive_mode.j2 +3 -3
  32. shotgun/prompts/agents/research.j2 +0 -3
  33. shotgun/prompts/history/chunk_summarization.j2 +34 -0
  34. shotgun/prompts/history/combine_summaries.j2 +53 -0
  35. shotgun/shotgun_web/__init__.py +67 -1
  36. shotgun/shotgun_web/client.py +42 -1
  37. shotgun/shotgun_web/constants.py +46 -0
  38. shotgun/shotgun_web/exceptions.py +29 -0
  39. shotgun/shotgun_web/models.py +390 -0
  40. shotgun/shotgun_web/shared_specs/__init__.py +32 -0
  41. shotgun/shotgun_web/shared_specs/file_scanner.py +175 -0
  42. shotgun/shotgun_web/shared_specs/hasher.py +83 -0
  43. shotgun/shotgun_web/shared_specs/models.py +71 -0
  44. shotgun/shotgun_web/shared_specs/upload_pipeline.py +291 -0
  45. shotgun/shotgun_web/shared_specs/utils.py +34 -0
  46. shotgun/shotgun_web/specs_client.py +703 -0
  47. shotgun/shotgun_web/supabase_client.py +31 -0
  48. shotgun/tui/app.py +39 -0
  49. shotgun/tui/containers.py +1 -1
  50. shotgun/tui/layout.py +5 -0
  51. shotgun/tui/screens/chat/chat_screen.py +212 -16
  52. shotgun/tui/screens/chat/codebase_index_prompt_screen.py +147 -19
  53. shotgun/tui/screens/chat_screen/command_providers.py +10 -0
  54. shotgun/tui/screens/chat_screen/history/chat_history.py +0 -36
  55. shotgun/tui/screens/confirmation_dialog.py +40 -0
  56. shotgun/tui/screens/model_picker.py +7 -1
  57. shotgun/tui/screens/onboarding.py +149 -0
  58. shotgun/tui/screens/pipx_migration.py +46 -0
  59. shotgun/tui/screens/provider_config.py +41 -0
  60. shotgun/tui/screens/shared_specs/__init__.py +21 -0
  61. shotgun/tui/screens/shared_specs/create_spec_dialog.py +273 -0
  62. shotgun/tui/screens/shared_specs/models.py +56 -0
  63. shotgun/tui/screens/shared_specs/share_specs_dialog.py +390 -0
  64. shotgun/tui/screens/shared_specs/upload_progress_screen.py +452 -0
  65. shotgun/tui/screens/shotgun_auth.py +60 -6
  66. shotgun/tui/screens/spec_pull.py +286 -0
  67. shotgun/tui/screens/welcome.py +91 -0
  68. shotgun/tui/services/conversation_service.py +5 -2
  69. shotgun/tui/widgets/widget_coordinator.py +1 -1
  70. {shotgun_sh-0.2.23.dev1.dist-info → shotgun_sh-0.2.29.dev2.dist-info}/METADATA +1 -1
  71. {shotgun_sh-0.2.23.dev1.dist-info → shotgun_sh-0.2.29.dev2.dist-info}/RECORD +86 -59
  72. {shotgun_sh-0.2.23.dev1.dist-info → shotgun_sh-0.2.29.dev2.dist-info}/WHEEL +1 -1
  73. /shotgun/agents/{history → conversation/history}/__init__.py +0 -0
  74. /shotgun/agents/{history → conversation/history}/context_extraction.py +0 -0
  75. /shotgun/agents/{history → conversation/history}/history_building.py +0 -0
  76. /shotgun/agents/{history → conversation/history}/message_utils.py +0 -0
  77. /shotgun/agents/{history → conversation/history}/token_counting/__init__.py +0 -0
  78. /shotgun/agents/{history → conversation/history}/token_counting/anthropic.py +0 -0
  79. /shotgun/agents/{history → conversation/history}/token_counting/base.py +0 -0
  80. /shotgun/agents/{history → conversation/history}/token_counting/openai.py +0 -0
  81. /shotgun/agents/{history → conversation/history}/token_counting/sentencepiece_counter.py +0 -0
  82. /shotgun/agents/{history → conversation/history}/token_counting/tokenizer_cache.py +0 -0
  83. /shotgun/agents/{history → conversation/history}/token_counting/utils.py +0 -0
  84. /shotgun/agents/{history → conversation/history}/token_estimation.py +0 -0
  85. {shotgun_sh-0.2.23.dev1.dist-info → shotgun_sh-0.2.29.dev2.dist-info}/entry_points.txt +0 -0
  86. {shotgun_sh-0.2.23.dev1.dist-info → shotgun_sh-0.2.29.dev2.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,34 @@
1
+ You are summarizing chunk {{ chunk_index }} of {{ total_chunks }} from a conversation that is too large to summarize at once.
2
+
3
+ Focus on preserving:
4
+ 1. ALL file paths, function names, variable names, URLs, and identifiers VERBATIM
5
+ 2. Key decisions and their rationale
6
+ 3. Tool call results (summarize large outputs, keep critical data)
7
+ 4. Important errors or issues encountered
8
+ 5. User requests and how they were addressed
9
+
10
+ <CHUNK_CONTENT>
11
+ {{ chunk_content }}
12
+ </CHUNK_CONTENT>
13
+
14
+ <OUTPUT_FORMAT>
15
+ ## Topics Covered
16
+ Brief bullet points of main topics discussed in this chunk.
17
+
18
+ ## Entities & References
19
+ - Files: [list all file paths mentioned, verbatim]
20
+ - Functions/Classes: [list all function/method/class names, verbatim]
21
+ - Variables/Keys: [configuration keys, env vars, etc., verbatim]
22
+ - Links/IDs: [any URLs, ticket IDs, etc., verbatim]
23
+
24
+ ## Actions & Results
25
+ Summarized tool calls and their outcomes. Preserve important data verbatim.
26
+
27
+ ## Important Decisions
28
+ Key decisions made and their rationale.
29
+
30
+ ## Status at Chunk End
31
+ Current active task or objective at the end of this chunk (if any), or "N/A" if this chunk completes without active work.
32
+ </OUTPUT_FORMAT>
33
+
34
+ Be concise but preserve all critical information. This summary will be combined with others to create a complete conversation summary.
@@ -0,0 +1,53 @@
1
+ You are combining {{ num_summaries }} conversation chunk summaries into a unified summary.
2
+
3
+ <CHUNK_SUMMARIES>
4
+ {% for summary in chunk_summaries %}
5
+ --- Chunk {{ loop.index }} of {{ num_summaries }} ---
6
+ {{ summary }}
7
+
8
+ {% endfor %}
9
+ </CHUNK_SUMMARIES>
10
+
11
+ Instructions:
12
+ 1. Merge overlapping information - don't repeat the same facts
13
+ 2. Preserve ALL entity references (files, functions, variables) from ALL chunks
14
+ 3. Maintain chronological timeline of actions
15
+ 4. Identify patterns and evolution across chunks
16
+ 5. The current status should reflect the LAST chunk's end state
17
+
18
+ <OUTPUT_FORMAT>
19
+ # Context
20
+
21
+ Short summary of the discussion, grouped by topics or tasks if any.
22
+ Present it as clear bullet points. Be brief but do not lose information that might be important for the current state, task or objectives.
23
+
24
+ # Key elements, learnings and entities
25
+
26
+ Present the important elements of context, learnings and entities from the discussion. Be very detailed.
27
+
28
+ Present it as clear bullet points. Be brief but do not lose information that might be important for the current state, task or objectives.
29
+
30
+ If the agent obtained information via tools, preserve it verbatim if it was short, summarize it if it was long focusing on preserving all of the most important facts and information.
31
+
32
+ If there are any links mentioned, IDs, filenames, etc. - preserve them verbatim.
33
+
34
+ # Timeline
35
+
36
+ For important tasks and content, provide
37
+ - User: asked to handle a complex task X: <summary of the task>
38
+ - Assistant: we handle it by doing A, B, C...
39
+ - Tools used and output summary
40
+
41
+ ...
42
+ - User: asked to handle a complex task Y: <summary of the task>
43
+ - Assistant: we handle it by doing A, B, C...
44
+ - Tools used and output summary
45
+
46
+ Do not hesitate to merge original messages, remove noise. We want to be as concise and brief as possible.
47
+
48
+ # Current status, task and objectives
49
+
50
+ Based on the conversation, include here the current status, task and objectives.
51
+
52
+ CRITICAL: This is not about summarizing or compacting. We are talking about the status, task and objectives currently active in the conversation to keep as much context as possible regarding the last messages.
53
+ </OUTPUT_FORMAT>
@@ -1,14 +1,48 @@
1
- """Shotgun Web API client for subscription and authentication."""
1
+ """Shotgun Web API client for subscription, authentication, and shared specs."""
2
2
 
3
3
  from .client import ShotgunWebClient, check_token_status, create_unification_token
4
+ from .exceptions import (
5
+ ConflictError,
6
+ ForbiddenError,
7
+ NotFoundError,
8
+ PayloadTooLargeError,
9
+ RateLimitExceededError,
10
+ ShotgunWebError,
11
+ UnauthorizedError,
12
+ )
4
13
  from .models import (
14
+ # Specs models
15
+ ErrorDetail,
16
+ ErrorResponse,
17
+ FileListResponse,
18
+ FileMetadata,
19
+ FileUploadRequest,
20
+ FileUploadResponse,
21
+ PermissionCheckResponse,
22
+ PublicSpecResponse,
23
+ SpecCreateRequest,
24
+ SpecCreateResponse,
25
+ SpecFileResponse,
26
+ SpecListResponse,
27
+ SpecResponse,
28
+ SpecUpdateRequest,
29
+ SpecVersionCreateRequest,
30
+ SpecVersionResponse,
31
+ SpecVersionState,
32
+ # Token models
5
33
  TokenCreateRequest,
6
34
  TokenCreateResponse,
7
35
  TokenStatus,
8
36
  TokenStatusResponse,
37
+ VersionCloseResponse,
38
+ VersionCreateResponse,
39
+ VersionListResponse,
40
+ WorkspaceRole,
9
41
  )
42
+ from .specs_client import SpecsClient
10
43
 
11
44
  __all__ = [
45
+ # Existing exports
12
46
  "ShotgunWebClient",
13
47
  "create_unification_token",
14
48
  "check_token_status",
@@ -16,4 +50,36 @@ __all__ = [
16
50
  "TokenCreateResponse",
17
51
  "TokenStatus",
18
52
  "TokenStatusResponse",
53
+ # Specs client
54
+ "SpecsClient",
55
+ # Exceptions
56
+ "ShotgunWebError",
57
+ "UnauthorizedError",
58
+ "ForbiddenError",
59
+ "NotFoundError",
60
+ "ConflictError",
61
+ "PayloadTooLargeError",
62
+ "RateLimitExceededError",
63
+ # Specs models
64
+ "ErrorDetail",
65
+ "ErrorResponse",
66
+ "FileListResponse",
67
+ "FileMetadata",
68
+ "FileUploadRequest",
69
+ "FileUploadResponse",
70
+ "PermissionCheckResponse",
71
+ "PublicSpecResponse",
72
+ "SpecCreateRequest",
73
+ "SpecCreateResponse",
74
+ "SpecFileResponse",
75
+ "SpecListResponse",
76
+ "SpecResponse",
77
+ "SpecUpdateRequest",
78
+ "SpecVersionCreateRequest",
79
+ "SpecVersionResponse",
80
+ "SpecVersionState",
81
+ "VersionCloseResponse",
82
+ "VersionCreateResponse",
83
+ "VersionListResponse",
84
+ "WorkspaceRole",
19
85
  ]
@@ -5,11 +5,13 @@ import httpx
5
5
  from shotgun.logging_config import get_logger
6
6
 
7
7
  from .constants import (
8
+ ME_PATH,
8
9
  SHOTGUN_WEB_BASE_URL,
9
10
  UNIFICATION_TOKEN_CREATE_PATH,
10
11
  UNIFICATION_TOKEN_STATUS_PATH,
11
12
  )
12
13
  from .models import (
14
+ MeResponse,
13
15
  TokenCreateRequest,
14
16
  TokenCreateResponse,
15
17
  TokenStatusResponse,
@@ -66,7 +68,7 @@ class ShotgunWebClient:
66
68
  return result
67
69
 
68
70
  except httpx.HTTPError as e:
69
- logger.error("Failed to create unification token: %s", e)
71
+ logger.error("Failed to create unification token at %s: %s", url, e)
70
72
  raise
71
73
 
72
74
  def check_token_status(self, token: str) -> TokenStatusResponse:
@@ -106,6 +108,45 @@ class ShotgunWebClient:
106
108
  logger.error("Failed to check token status: %s", e)
107
109
  raise
108
110
 
111
+ def get_me(self, jwt: str) -> MeResponse:
112
+ """Get current user info including workspace.
113
+
114
+ Args:
115
+ jwt: Supabase JWT for authentication
116
+
117
+ Returns:
118
+ User info including workspace details
119
+
120
+ Raises:
121
+ httpx.HTTPStatusError: If authentication fails (401) or other HTTP errors
122
+ httpx.HTTPError: For other request failures
123
+ """
124
+ url = f"{self.base_url}{ME_PATH}"
125
+
126
+ logger.debug("Fetching user info from /api/me")
127
+
128
+ try:
129
+ response = httpx.get(
130
+ url,
131
+ headers={"Authorization": f"Bearer {jwt}"},
132
+ timeout=self.timeout,
133
+ )
134
+ response.raise_for_status()
135
+
136
+ data = response.json()
137
+ result = MeResponse.model_validate(data)
138
+
139
+ logger.info("Successfully fetched user info for %s", result.email)
140
+ return result
141
+
142
+ except httpx.HTTPStatusError as e:
143
+ if e.response.status_code == 401:
144
+ logger.error("Authentication failed for /api/me")
145
+ raise
146
+ except httpx.HTTPError as e:
147
+ logger.error("Failed to fetch user info: %s", e)
148
+ raise
149
+
109
150
 
110
151
  # Convenience functions for standalone use
111
152
  def create_unification_token(shotgun_instance_id: str) -> TokenCreateResponse:
@@ -6,16 +6,62 @@ from shotgun.api_endpoints import SHOTGUN_WEB_BASE_URL
6
6
  # API endpoints
7
7
  UNIFICATION_TOKEN_CREATE_PATH = "/api/unification/token/create" # noqa: S105
8
8
  UNIFICATION_TOKEN_STATUS_PATH = "/api/unification/token/{token}/status" # noqa: S105
9
+ ME_PATH = "/api/me"
9
10
 
10
11
  # Polling configuration
11
12
  DEFAULT_POLL_INTERVAL_SECONDS = 3
12
13
  DEFAULT_TOKEN_TIMEOUT_SECONDS = 1800 # 30 minutes
13
14
 
15
+ # Workspaces API endpoint
16
+ WORKSPACES_PATH = "/api/workspaces"
17
+
18
+ # Specs API endpoints
19
+ PERMISSIONS_PATH = "/api/workspaces/{workspace_id}/specs/permissions"
20
+ SPECS_BASE_PATH = "/api/workspaces/{workspace_id}/specs"
21
+ SPECS_DETAIL_PATH = "/api/workspaces/{workspace_id}/specs/{spec_id}"
22
+ VERSIONS_PATH = "/api/workspaces/{workspace_id}/specs/{spec_id}/versions"
23
+ VERSION_DETAIL_PATH = (
24
+ "/api/workspaces/{workspace_id}/specs/{spec_id}/versions/{version_id}"
25
+ )
26
+ VERSION_CLOSE_PATH = (
27
+ "/api/workspaces/{workspace_id}/specs/{spec_id}/versions/{version_id}/close"
28
+ )
29
+ VERSION_SET_LATEST_PATH = (
30
+ "/api/workspaces/{workspace_id}/specs/{spec_id}/versions/{version_id}/set-latest"
31
+ )
32
+ FILES_PATH = (
33
+ "/api/workspaces/{workspace_id}/specs/{spec_id}/versions/{version_id}/files"
34
+ )
35
+ FILE_DETAIL_PATH = "/api/workspaces/{workspace_id}/specs/{spec_id}/versions/{version_id}/files/{file_id}"
36
+ PUBLIC_SPEC_PATH = "/api/public/specs/{spec_id}"
37
+ PUBLIC_SPEC_FILES_PATH = "/api/public/specs/{spec_id}/files"
38
+ PUBLIC_FILE_PATH = "/api/public/specs/{spec_id}/files/{file_id}"
39
+
40
+ # CLI convenience endpoint (version lookup by ID only)
41
+ VERSION_BY_ID_PATH = "/api/versions/{version_id}"
42
+
14
43
  # Re-export for backward compatibility
15
44
  __all__ = [
16
45
  "SHOTGUN_WEB_BASE_URL",
17
46
  "UNIFICATION_TOKEN_CREATE_PATH",
18
47
  "UNIFICATION_TOKEN_STATUS_PATH",
48
+ "ME_PATH",
19
49
  "DEFAULT_POLL_INTERVAL_SECONDS",
20
50
  "DEFAULT_TOKEN_TIMEOUT_SECONDS",
51
+ # Workspaces endpoint
52
+ "WORKSPACES_PATH",
53
+ # Specs endpoints
54
+ "PERMISSIONS_PATH",
55
+ "SPECS_BASE_PATH",
56
+ "SPECS_DETAIL_PATH",
57
+ "VERSIONS_PATH",
58
+ "VERSION_DETAIL_PATH",
59
+ "VERSION_CLOSE_PATH",
60
+ "VERSION_SET_LATEST_PATH",
61
+ "FILES_PATH",
62
+ "FILE_DETAIL_PATH",
63
+ "PUBLIC_SPEC_PATH",
64
+ "PUBLIC_SPEC_FILES_PATH",
65
+ "PUBLIC_FILE_PATH",
66
+ "VERSION_BY_ID_PATH",
21
67
  ]
@@ -0,0 +1,29 @@
1
+ """Typed exceptions for Shotgun Web API operations."""
2
+
3
+
4
+ class ShotgunWebError(Exception):
5
+ """Base exception for Shotgun Web API operations."""
6
+
7
+
8
+ class UnauthorizedError(ShotgunWebError):
9
+ """401 - Missing or invalid authentication token."""
10
+
11
+
12
+ class ForbiddenError(ShotgunWebError):
13
+ """403 - Insufficient permissions for the requested operation."""
14
+
15
+
16
+ class NotFoundError(ShotgunWebError):
17
+ """404 - Resource not found."""
18
+
19
+
20
+ class ConflictError(ShotgunWebError):
21
+ """409 - Name conflict or duplicate path."""
22
+
23
+
24
+ class PayloadTooLargeError(ShotgunWebError):
25
+ """413 - File exceeds maximum size limit."""
26
+
27
+
28
+ class RateLimitExceededError(ShotgunWebError):
29
+ """429 - Rate limit exceeded."""