shotgun-sh 0.2.29.dev2__py3-none-any.whl → 0.6.1.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 +497 -30
- shotgun/agents/cancellation.py +103 -0
- shotgun/agents/common.py +90 -77
- shotgun/agents/config/README.md +0 -1
- shotgun/agents/config/manager.py +52 -8
- shotgun/agents/config/models.py +48 -45
- shotgun/agents/config/provider.py +44 -29
- shotgun/agents/conversation/history/file_content_deduplication.py +66 -43
- shotgun/agents/conversation/history/token_counting/base.py +51 -9
- shotgun/agents/export.py +12 -13
- shotgun/agents/file_read.py +176 -0
- shotgun/agents/messages.py +15 -3
- shotgun/agents/models.py +90 -2
- shotgun/agents/plan.py +12 -13
- shotgun/agents/research.py +13 -10
- shotgun/agents/router/__init__.py +47 -0
- shotgun/agents/router/models.py +384 -0
- shotgun/agents/router/router.py +185 -0
- shotgun/agents/router/tools/__init__.py +18 -0
- shotgun/agents/router/tools/delegation_tools.py +557 -0
- shotgun/agents/router/tools/plan_tools.py +403 -0
- shotgun/agents/runner.py +17 -2
- shotgun/agents/specify.py +12 -13
- shotgun/agents/tasks.py +12 -13
- shotgun/agents/tools/__init__.py +8 -0
- shotgun/agents/tools/codebase/directory_lister.py +27 -39
- shotgun/agents/tools/codebase/file_read.py +26 -35
- shotgun/agents/tools/codebase/query_graph.py +9 -0
- shotgun/agents/tools/codebase/retrieve_code.py +9 -0
- shotgun/agents/tools/file_management.py +81 -3
- shotgun/agents/tools/file_read_tools/__init__.py +7 -0
- shotgun/agents/tools/file_read_tools/multimodal_file_read.py +167 -0
- shotgun/agents/tools/markdown_tools/__init__.py +62 -0
- shotgun/agents/tools/markdown_tools/insert_section.py +148 -0
- shotgun/agents/tools/markdown_tools/models.py +86 -0
- shotgun/agents/tools/markdown_tools/remove_section.py +114 -0
- shotgun/agents/tools/markdown_tools/replace_section.py +119 -0
- shotgun/agents/tools/markdown_tools/utils.py +453 -0
- shotgun/agents/tools/registry.py +41 -0
- shotgun/agents/tools/web_search/__init__.py +1 -2
- shotgun/agents/tools/web_search/gemini.py +1 -3
- shotgun/agents/tools/web_search/openai.py +42 -23
- shotgun/attachments/__init__.py +41 -0
- shotgun/attachments/errors.py +60 -0
- shotgun/attachments/models.py +107 -0
- shotgun/attachments/parser.py +257 -0
- shotgun/attachments/processor.py +193 -0
- shotgun/cli/clear.py +2 -2
- shotgun/cli/codebase/commands.py +181 -65
- shotgun/cli/compact.py +2 -2
- shotgun/cli/context.py +2 -2
- shotgun/cli/run.py +90 -0
- shotgun/cli/spec/backup.py +2 -1
- shotgun/cli/spec/commands.py +2 -0
- shotgun/cli/spec/models.py +18 -0
- shotgun/cli/spec/pull_service.py +122 -68
- shotgun/codebase/__init__.py +2 -0
- shotgun/codebase/benchmarks/__init__.py +35 -0
- shotgun/codebase/benchmarks/benchmark_runner.py +309 -0
- shotgun/codebase/benchmarks/exporters.py +119 -0
- shotgun/codebase/benchmarks/formatters/__init__.py +49 -0
- shotgun/codebase/benchmarks/formatters/base.py +34 -0
- shotgun/codebase/benchmarks/formatters/json_formatter.py +106 -0
- shotgun/codebase/benchmarks/formatters/markdown.py +136 -0
- shotgun/codebase/benchmarks/models.py +129 -0
- shotgun/codebase/core/__init__.py +4 -0
- shotgun/codebase/core/call_resolution.py +91 -0
- shotgun/codebase/core/change_detector.py +11 -6
- shotgun/codebase/core/errors.py +159 -0
- shotgun/codebase/core/extractors/__init__.py +23 -0
- shotgun/codebase/core/extractors/base.py +138 -0
- shotgun/codebase/core/extractors/factory.py +63 -0
- shotgun/codebase/core/extractors/go/__init__.py +7 -0
- shotgun/codebase/core/extractors/go/extractor.py +122 -0
- shotgun/codebase/core/extractors/javascript/__init__.py +7 -0
- shotgun/codebase/core/extractors/javascript/extractor.py +132 -0
- shotgun/codebase/core/extractors/protocol.py +109 -0
- shotgun/codebase/core/extractors/python/__init__.py +7 -0
- shotgun/codebase/core/extractors/python/extractor.py +141 -0
- shotgun/codebase/core/extractors/rust/__init__.py +7 -0
- shotgun/codebase/core/extractors/rust/extractor.py +139 -0
- shotgun/codebase/core/extractors/types.py +15 -0
- shotgun/codebase/core/extractors/typescript/__init__.py +7 -0
- shotgun/codebase/core/extractors/typescript/extractor.py +92 -0
- shotgun/codebase/core/gitignore.py +252 -0
- shotgun/codebase/core/ingestor.py +644 -354
- shotgun/codebase/core/kuzu_compat.py +119 -0
- shotgun/codebase/core/language_config.py +239 -0
- shotgun/codebase/core/manager.py +256 -46
- shotgun/codebase/core/metrics_collector.py +310 -0
- shotgun/codebase/core/metrics_types.py +347 -0
- shotgun/codebase/core/parallel_executor.py +424 -0
- shotgun/codebase/core/work_distributor.py +254 -0
- shotgun/codebase/core/worker.py +768 -0
- shotgun/codebase/indexing_state.py +86 -0
- shotgun/codebase/models.py +94 -0
- shotgun/codebase/service.py +13 -0
- shotgun/exceptions.py +1 -1
- shotgun/main.py +2 -10
- shotgun/prompts/agents/export.j2 +2 -0
- shotgun/prompts/agents/file_read.j2 +48 -0
- shotgun/prompts/agents/partials/common_agent_system_prompt.j2 +20 -28
- shotgun/prompts/agents/partials/content_formatting.j2 +12 -33
- shotgun/prompts/agents/partials/interactive_mode.j2 +9 -32
- shotgun/prompts/agents/partials/router_delegation_mode.j2 +35 -0
- shotgun/prompts/agents/plan.j2 +43 -1
- shotgun/prompts/agents/research.j2 +75 -20
- shotgun/prompts/agents/router.j2 +713 -0
- shotgun/prompts/agents/specify.j2 +94 -4
- shotgun/prompts/agents/state/codebase/codebase_graphs_available.j2 +14 -1
- shotgun/prompts/agents/state/system_state.j2 +24 -15
- shotgun/prompts/agents/tasks.j2 +77 -23
- shotgun/settings.py +44 -0
- shotgun/shotgun_web/shared_specs/upload_pipeline.py +38 -0
- shotgun/tui/app.py +90 -23
- shotgun/tui/commands/__init__.py +9 -1
- shotgun/tui/components/attachment_bar.py +87 -0
- shotgun/tui/components/mode_indicator.py +120 -25
- shotgun/tui/components/prompt_input.py +23 -28
- shotgun/tui/components/status_bar.py +5 -4
- shotgun/tui/dependencies.py +58 -8
- shotgun/tui/protocols.py +37 -0
- shotgun/tui/screens/chat/chat.tcss +24 -1
- shotgun/tui/screens/chat/chat_screen.py +1374 -211
- shotgun/tui/screens/chat/codebase_index_prompt_screen.py +8 -4
- shotgun/tui/screens/chat_screen/attachment_hint.py +40 -0
- shotgun/tui/screens/chat_screen/command_providers.py +0 -97
- shotgun/tui/screens/chat_screen/history/agent_response.py +7 -3
- shotgun/tui/screens/chat_screen/history/chat_history.py +49 -6
- shotgun/tui/screens/chat_screen/history/formatters.py +75 -15
- shotgun/tui/screens/chat_screen/history/partial_response.py +11 -1
- shotgun/tui/screens/chat_screen/history/user_question.py +25 -3
- shotgun/tui/screens/chat_screen/messages.py +219 -0
- shotgun/tui/screens/database_locked_dialog.py +219 -0
- shotgun/tui/screens/database_timeout_dialog.py +158 -0
- shotgun/tui/screens/kuzu_error_dialog.py +135 -0
- shotgun/tui/screens/model_picker.py +14 -9
- shotgun/tui/screens/models.py +11 -0
- shotgun/tui/screens/shotgun_auth.py +50 -0
- shotgun/tui/screens/spec_pull.py +2 -0
- shotgun/tui/state/processing_state.py +19 -0
- shotgun/tui/utils/mode_progress.py +20 -86
- shotgun/tui/widgets/__init__.py +2 -1
- shotgun/tui/widgets/approval_widget.py +152 -0
- shotgun/tui/widgets/cascade_confirmation_widget.py +203 -0
- shotgun/tui/widgets/plan_panel.py +129 -0
- shotgun/tui/widgets/step_checkpoint_widget.py +180 -0
- shotgun/tui/widgets/widget_coordinator.py +18 -0
- shotgun/utils/file_system_utils.py +4 -1
- {shotgun_sh-0.2.29.dev2.dist-info → shotgun_sh-0.6.1.dev1.dist-info}/METADATA +88 -34
- shotgun_sh-0.6.1.dev1.dist-info/RECORD +292 -0
- shotgun/cli/export.py +0 -81
- shotgun/cli/plan.py +0 -73
- shotgun/cli/research.py +0 -93
- shotgun/cli/specify.py +0 -70
- shotgun/cli/tasks.py +0 -78
- shotgun/tui/screens/onboarding.py +0 -580
- shotgun_sh-0.2.29.dev2.dist-info/RECORD +0 -229
- {shotgun_sh-0.2.29.dev2.dist-info → shotgun_sh-0.6.1.dev1.dist-info}/WHEEL +0 -0
- {shotgun_sh-0.2.29.dev2.dist-info → shotgun_sh-0.6.1.dev1.dist-info}/entry_points.txt +0 -0
- {shotgun_sh-0.2.29.dev2.dist-info → shotgun_sh-0.6.1.dev1.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"""State tracking for codebase indexing operations."""
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
from typing import ClassVar
|
|
5
|
+
|
|
6
|
+
from shotgun.logging_config import get_logger
|
|
7
|
+
|
|
8
|
+
logger = get_logger(__name__)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class IndexingState:
|
|
12
|
+
"""Tracks which graph_ids are currently being indexed.
|
|
13
|
+
|
|
14
|
+
This is a simple state container that tools can check to determine
|
|
15
|
+
if a graph is available or currently being built. This prevents
|
|
16
|
+
race conditions on Windows where Kuzu uses exclusive file locking.
|
|
17
|
+
|
|
18
|
+
Uses class-level state so all service instances share the same state.
|
|
19
|
+
This is similar to how CodebaseGraphManager shares connections.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
# Error message for when tools try to access a graph being indexed
|
|
23
|
+
INDEXING_IN_PROGRESS_ERROR = (
|
|
24
|
+
"This codebase is currently being indexed. "
|
|
25
|
+
"Please wait for indexing to complete before accessing it."
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
# Class-level state shared across all instances
|
|
29
|
+
_active_graphs: ClassVar[set[str]] = set()
|
|
30
|
+
_lock: ClassVar[asyncio.Lock | None] = None
|
|
31
|
+
|
|
32
|
+
@classmethod
|
|
33
|
+
def _get_lock(cls) -> asyncio.Lock:
|
|
34
|
+
"""Get or create the class-level lock."""
|
|
35
|
+
if cls._lock is None:
|
|
36
|
+
cls._lock = asyncio.Lock()
|
|
37
|
+
return cls._lock
|
|
38
|
+
|
|
39
|
+
async def start(self, graph_id: str) -> None:
|
|
40
|
+
"""Mark a graph as being indexed.
|
|
41
|
+
|
|
42
|
+
Args:
|
|
43
|
+
graph_id: The graph ID that is starting to be indexed
|
|
44
|
+
"""
|
|
45
|
+
lock = self._get_lock()
|
|
46
|
+
async with lock:
|
|
47
|
+
self._active_graphs.add(graph_id)
|
|
48
|
+
logger.debug(f"Indexing started for graph: {graph_id}")
|
|
49
|
+
|
|
50
|
+
async def complete(self, graph_id: str) -> None:
|
|
51
|
+
"""Mark a graph as finished indexing.
|
|
52
|
+
|
|
53
|
+
Args:
|
|
54
|
+
graph_id: The graph ID that finished indexing
|
|
55
|
+
"""
|
|
56
|
+
lock = self._get_lock()
|
|
57
|
+
async with lock:
|
|
58
|
+
self._active_graphs.discard(graph_id)
|
|
59
|
+
logger.debug(f"Indexing completed for graph: {graph_id}")
|
|
60
|
+
|
|
61
|
+
def is_active(self, graph_id: str) -> bool:
|
|
62
|
+
"""Check if a specific graph is currently being indexed.
|
|
63
|
+
|
|
64
|
+
Args:
|
|
65
|
+
graph_id: The graph ID to check
|
|
66
|
+
|
|
67
|
+
Returns:
|
|
68
|
+
True if the graph is currently being indexed
|
|
69
|
+
"""
|
|
70
|
+
return graph_id in self._active_graphs
|
|
71
|
+
|
|
72
|
+
def has_active(self) -> bool:
|
|
73
|
+
"""Check if any graph is currently being indexed.
|
|
74
|
+
|
|
75
|
+
Returns:
|
|
76
|
+
True if any graph is being indexed
|
|
77
|
+
"""
|
|
78
|
+
return len(self._active_graphs) > 0
|
|
79
|
+
|
|
80
|
+
def get_active_ids(self) -> set[str]:
|
|
81
|
+
"""Get set of graph IDs currently being indexed.
|
|
82
|
+
|
|
83
|
+
Returns:
|
|
84
|
+
Copy of the set of graph IDs being indexed
|
|
85
|
+
"""
|
|
86
|
+
return self._active_graphs.copy()
|
shotgun/codebase/models.py
CHANGED
|
@@ -16,6 +16,15 @@ class GraphStatus(StrEnum):
|
|
|
16
16
|
ERROR = "ERROR" # Last operation failed
|
|
17
17
|
|
|
18
18
|
|
|
19
|
+
class IgnoreReason(StrEnum):
|
|
20
|
+
"""Reason why a file or directory was ignored during indexing."""
|
|
21
|
+
|
|
22
|
+
HARDCODED = (
|
|
23
|
+
"hardcoded" # Matched hardcoded ignore patterns (venv, node_modules, etc.)
|
|
24
|
+
)
|
|
25
|
+
GITIGNORE = "gitignore" # Matched .gitignore pattern
|
|
26
|
+
|
|
27
|
+
|
|
19
28
|
class QueryType(StrEnum):
|
|
20
29
|
"""Type of query being executed."""
|
|
21
30
|
|
|
@@ -33,6 +42,55 @@ class ProgressPhase(StrEnum):
|
|
|
33
42
|
FLUSH_RELATIONSHIPS = "flush_relationships" # Flushing relationships to database
|
|
34
43
|
|
|
35
44
|
|
|
45
|
+
class NodeLabel(StrEnum):
|
|
46
|
+
"""Node type labels for the code knowledge graph."""
|
|
47
|
+
|
|
48
|
+
PROJECT = "Project" # Top-level project node
|
|
49
|
+
PACKAGE = "Package" # Python package/namespace
|
|
50
|
+
FOLDER = "Folder" # Directory structure
|
|
51
|
+
FILE = "File" # Source file
|
|
52
|
+
MODULE = "Module" # Python module
|
|
53
|
+
CLASS = "Class" # Class definition
|
|
54
|
+
FUNCTION = "Function" # Function definition
|
|
55
|
+
METHOD = "Method" # Method definition (inside a class)
|
|
56
|
+
FILE_METADATA = "FileMetadata" # File tracking metadata (hash, mtime)
|
|
57
|
+
EXTERNAL_PACKAGE = "ExternalPackage" # External dependency
|
|
58
|
+
DELETION_LOG = "DeletionLog" # Deletion audit trail
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class RelationshipType(StrEnum):
|
|
62
|
+
"""Relationship types for the code knowledge graph."""
|
|
63
|
+
|
|
64
|
+
# Containment relationships (used with suffixes _PKG, _FOLDER in tables)
|
|
65
|
+
CONTAINS_PACKAGE = "CONTAINS_PACKAGE" # Container to Package
|
|
66
|
+
CONTAINS_FOLDER = "CONTAINS_FOLDER" # Container to Folder
|
|
67
|
+
CONTAINS_FILE = "CONTAINS_FILE" # Container to File
|
|
68
|
+
CONTAINS_MODULE = "CONTAINS_MODULE" # Container to Module
|
|
69
|
+
|
|
70
|
+
# Definition relationships
|
|
71
|
+
DEFINES = "DEFINES" # Module to Class
|
|
72
|
+
DEFINES_FUNC = "DEFINES_FUNC" # Module to Function
|
|
73
|
+
DEFINES_METHOD = "DEFINES_METHOD" # Class to Method
|
|
74
|
+
|
|
75
|
+
# Call relationships
|
|
76
|
+
CALLS = "CALLS" # Function to Function
|
|
77
|
+
CALLS_FM = "CALLS_FM" # Function to Method
|
|
78
|
+
CALLS_MF = "CALLS_MF" # Method to Function
|
|
79
|
+
CALLS_MM = "CALLS_MM" # Method to Method
|
|
80
|
+
|
|
81
|
+
# Tracking relationships (FileMetadata to entity)
|
|
82
|
+
TRACKS_MODULE = "TRACKS_Module" # FileMetadata to Module
|
|
83
|
+
TRACKS_CLASS = "TRACKS_Class" # FileMetadata to Class
|
|
84
|
+
TRACKS_FUNCTION = "TRACKS_Function" # FileMetadata to Function
|
|
85
|
+
TRACKS_METHOD = "TRACKS_Method" # FileMetadata to Method
|
|
86
|
+
|
|
87
|
+
# Other relationships
|
|
88
|
+
INHERITS = "INHERITS" # Child Class to Parent Class
|
|
89
|
+
OVERRIDES = "OVERRIDES" # Method to Method (override)
|
|
90
|
+
IMPORTS = "IMPORTS" # Module to Module
|
|
91
|
+
DEPENDS_ON_EXTERNAL = "DEPENDS_ON_EXTERNAL" # Project to ExternalPackage
|
|
92
|
+
|
|
93
|
+
|
|
36
94
|
class IndexProgress(BaseModel):
|
|
37
95
|
"""Progress information for codebase indexing."""
|
|
38
96
|
|
|
@@ -49,6 +107,42 @@ class IndexProgress(BaseModel):
|
|
|
49
107
|
ProgressCallback = Callable[[IndexProgress], None]
|
|
50
108
|
|
|
51
109
|
|
|
110
|
+
class GitignoreStats(BaseModel):
|
|
111
|
+
"""Statistics from gitignore pattern matching."""
|
|
112
|
+
|
|
113
|
+
gitignore_files_loaded: int = Field(
|
|
114
|
+
default=0, description="Number of .gitignore files loaded"
|
|
115
|
+
)
|
|
116
|
+
patterns_loaded: int = Field(default=0, description="Total patterns loaded")
|
|
117
|
+
files_checked: int = Field(default=0, description="Number of paths checked")
|
|
118
|
+
files_ignored: int = Field(
|
|
119
|
+
default=0, description="Number of paths ignored by gitignore"
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
class IndexingStats(BaseModel):
|
|
124
|
+
"""Statistics from codebase indexing."""
|
|
125
|
+
|
|
126
|
+
dirs_scanned: int = Field(default=0, description="Directories scanned")
|
|
127
|
+
dirs_ignored_hardcoded: int = Field(
|
|
128
|
+
default=0, description="Directories ignored by hardcoded patterns"
|
|
129
|
+
)
|
|
130
|
+
dirs_ignored_gitignore: int = Field(
|
|
131
|
+
default=0, description="Directories ignored by gitignore"
|
|
132
|
+
)
|
|
133
|
+
files_scanned: int = Field(default=0, description="Files scanned")
|
|
134
|
+
files_ignored_hardcoded: int = Field(
|
|
135
|
+
default=0, description="Files ignored by hardcoded patterns"
|
|
136
|
+
)
|
|
137
|
+
files_ignored_gitignore: int = Field(
|
|
138
|
+
default=0, description="Files ignored by gitignore"
|
|
139
|
+
)
|
|
140
|
+
files_ignored_no_parser: int = Field(
|
|
141
|
+
default=0, description="Files ignored due to no parser available"
|
|
142
|
+
)
|
|
143
|
+
files_processed: int = Field(default=0, description="Files successfully processed")
|
|
144
|
+
|
|
145
|
+
|
|
52
146
|
class OperationStats(BaseModel):
|
|
53
147
|
"""Statistics for a graph operation (build/update)."""
|
|
54
148
|
|
shotgun/codebase/service.py
CHANGED
|
@@ -7,6 +7,7 @@ from typing import Any
|
|
|
7
7
|
from shotgun.codebase.core.cypher_models import CypherGenerationNotPossibleError
|
|
8
8
|
from shotgun.codebase.core.manager import CodebaseGraphManager
|
|
9
9
|
from shotgun.codebase.core.nl_query import generate_cypher
|
|
10
|
+
from shotgun.codebase.indexing_state import IndexingState
|
|
10
11
|
from shotgun.codebase.models import CodebaseGraph, QueryResult, QueryType
|
|
11
12
|
from shotgun.logging_config import get_logger
|
|
12
13
|
|
|
@@ -28,6 +29,18 @@ class CodebaseService:
|
|
|
28
29
|
self.storage_dir = storage_dir
|
|
29
30
|
self.storage_dir.mkdir(parents=True, exist_ok=True)
|
|
30
31
|
self.manager = CodebaseGraphManager(storage_dir)
|
|
32
|
+
self.indexing = IndexingState()
|
|
33
|
+
|
|
34
|
+
def compute_graph_id(self, repo_path: str | Path) -> str:
|
|
35
|
+
"""Compute graph_id for a repo path without creating the graph.
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
repo_path: Path to the repository
|
|
39
|
+
|
|
40
|
+
Returns:
|
|
41
|
+
The graph_id that would be used for this repo path
|
|
42
|
+
"""
|
|
43
|
+
return self.manager.generate_graph_id(str(repo_path))
|
|
31
44
|
|
|
32
45
|
async def list_graphs(self) -> list[CodebaseGraph]:
|
|
33
46
|
"""List all existing graphs.
|
shotgun/exceptions.py
CHANGED
|
@@ -81,7 +81,7 @@ class ContextSizeLimitExceeded(ErrorNotPickedUpBySentry):
|
|
|
81
81
|
f"⚠️ **Context too large for {self.model_name}**\n\n"
|
|
82
82
|
f"Your conversation history exceeds this model's limit ({self.max_tokens:,} tokens).\n\n"
|
|
83
83
|
f"**Choose an action:**\n\n"
|
|
84
|
-
f"1. Switch to a larger model (
|
|
84
|
+
f"1. Switch to a larger model (`/` → Change Model)\n"
|
|
85
85
|
f"2. Switch to a larger model, compact (`/compact`), then switch back to {self.model_name}\n"
|
|
86
86
|
f"3. Clear conversation (`/clear`)\n"
|
|
87
87
|
)
|
shotgun/main.py
CHANGED
|
@@ -28,13 +28,9 @@ from shotgun.cli import (
|
|
|
28
28
|
compact,
|
|
29
29
|
config,
|
|
30
30
|
context,
|
|
31
|
-
export,
|
|
32
31
|
feedback,
|
|
33
|
-
|
|
34
|
-
research,
|
|
32
|
+
run,
|
|
35
33
|
spec,
|
|
36
|
-
specify,
|
|
37
|
-
tasks,
|
|
38
34
|
update,
|
|
39
35
|
)
|
|
40
36
|
from shotgun.logging_config import configure_root_logger, get_logger
|
|
@@ -89,11 +85,7 @@ app.add_typer(
|
|
|
89
85
|
app.add_typer(context.app, name="context", help="Analyze conversation context usage")
|
|
90
86
|
app.add_typer(compact.app, name="compact", help="Compact conversation history")
|
|
91
87
|
app.add_typer(clear.app, name="clear", help="Clear conversation history")
|
|
92
|
-
app.add_typer(
|
|
93
|
-
app.add_typer(plan.app, name="plan", help="Generate structured plans")
|
|
94
|
-
app.add_typer(specify.app, name="specify", help="Generate comprehensive specifications")
|
|
95
|
-
app.add_typer(tasks.app, name="tasks", help="Generate task lists with agentic approach")
|
|
96
|
-
app.add_typer(export.app, name="export", help="Export artifacts to various formats")
|
|
88
|
+
app.add_typer(run.app, name="run", help="Run a prompt using the Router agent")
|
|
97
89
|
app.add_typer(update.app, name="update", help="Check for and install updates")
|
|
98
90
|
app.add_typer(feedback.app, name="feedback", help="Send us feedback")
|
|
99
91
|
app.add_typer(spec.app, name="spec", help="Manage shared specifications")
|
shotgun/prompts/agents/export.j2
CHANGED
|
@@ -10,6 +10,8 @@ Your primary job is to generate Agents.md or CLAUDE.md files following the https
|
|
|
10
10
|
|
|
11
11
|
{% include 'agents/partials/common_agent_system_prompt.j2' %}
|
|
12
12
|
|
|
13
|
+
{% include 'agents/partials/router_delegation_mode.j2' %}
|
|
14
|
+
|
|
13
15
|
## MEMORY MANAGEMENT PROTOCOL
|
|
14
16
|
|
|
15
17
|
- You can write to ANY file EXCEPT protected files
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
You are a File Reading Agent - a lightweight, focused assistant for finding and reading files.
|
|
2
|
+
|
|
3
|
+
## YOUR PURPOSE
|
|
4
|
+
|
|
5
|
+
Your job is to:
|
|
6
|
+
1. **Search** for files matching the user's description
|
|
7
|
+
2. **Read** file contents (including PDFs and images)
|
|
8
|
+
3. **Summarize** what you found
|
|
9
|
+
4. **Return** the file paths so they can be loaded into context
|
|
10
|
+
|
|
11
|
+
## TOOLS AVAILABLE
|
|
12
|
+
|
|
13
|
+
- `directory_lister` - List contents of a directory
|
|
14
|
+
- `file_read` - Read text file contents
|
|
15
|
+
- `read_file` - Read file by path
|
|
16
|
+
- `multimodal_file_read` - Verify PDFs and images exist and get their absolute paths
|
|
17
|
+
|
|
18
|
+
## WORKFLOW
|
|
19
|
+
|
|
20
|
+
1. **Understand the request** - What file is the user looking for?
|
|
21
|
+
2. **Search systematically** - Use directory_lister to explore, then read candidates
|
|
22
|
+
3. **For PDFs/images** - Use `multimodal_file_read` to verify they exist and get the absolute path
|
|
23
|
+
4. **Identify the right file** - Confirm you found what was requested
|
|
24
|
+
5. **Return results** - Include the absolute file path in `files_found` so the Router can load it
|
|
25
|
+
|
|
26
|
+
## OUTPUT FORMAT
|
|
27
|
+
|
|
28
|
+
When you find the file(s):
|
|
29
|
+
- Provide a brief summary of what you found
|
|
30
|
+
- **Always include absolute file paths in the `files_found` field** of your response
|
|
31
|
+
- This allows the Router to load the files into its context
|
|
32
|
+
|
|
33
|
+
Example response:
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"response": "Found the user stories document at /home/user/docs/user_stories_v2.pdf. It contains 3 user stories about authentication, profile management, and notifications.",
|
|
37
|
+
"files_found": ["/home/user/docs/user_stories_v2.pdf"]
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## IMPORTANT NOTES
|
|
42
|
+
|
|
43
|
+
- You are a **read-only** agent - you cannot create or modify files
|
|
44
|
+
- Use `multimodal_file_read` for PDFs and images to verify they exist and get absolute paths
|
|
45
|
+
- The Router will load the actual file content using the paths you return in `files_found`
|
|
46
|
+
- Be efficient - search systematically, don't read every file
|
|
47
|
+
- Return file paths as **absolute paths** for reliability
|
|
48
|
+
- If you can't find the file, say so clearly and suggest alternatives
|
|
@@ -1,39 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
* Business Analysis
|
|
3
|
-
* Product Management
|
|
4
|
-
* Software Architecture
|
|
5
|
-
* Software Development
|
|
1
|
+
You are an experienced Software Architect with experience in Business Analysis, Product Management, Software Architecture, and Software Development
|
|
6
2
|
|
|
7
|
-
##
|
|
3
|
+
## YOUR ROLE IN THE PIPELINE
|
|
8
4
|
|
|
5
|
+
<YOUR_ROLE>
|
|
6
|
+
It is critical that you understand you are a DOCUMENTATION and PLANNING agent, NOT a coding/implementation agent.
|
|
7
|
+
You produce DOCUMENTS (research, specifications, plans, tasks) that AI coding agents will consume
|
|
8
|
+
You do NOT try to write production code, implement features, or make code changes.
|
|
9
|
+
NEVER offer to "move forward with implementation" or "start coding" - that's not your job
|
|
10
|
+
NEVER ask "would you like me to implement this?" - implementation is done by separate AI coding tools
|
|
11
|
+
Your deliverable is always a document file (.md), not code execution
|
|
12
|
+
When your work is complete, the user will take your documents to a coding agent (Claude Code, Cursor, etc.)
|
|
13
|
+
</YOUR_ROLE>
|
|
14
|
+
|
|
15
|
+
<KEY_RULES>
|
|
9
16
|
{% if interactive_mode %}
|
|
10
|
-
|
|
17
|
+
Ask CLARIFYING QUESTIONS using structured output for complex or multi-step tasks when the request lacks sufficient detail.
|
|
11
18
|
- Return your response with the clarifying_questions field populated
|
|
12
19
|
- For simple, straightforward requests, make reasonable assumptions and proceed.
|
|
13
20
|
- Only ask the most critical questions to avoid overwhelming the user.
|
|
14
21
|
- Questions should be clear, specific, and answerable
|
|
15
22
|
{% endif %}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
7. **Be Transparent**: Let the user know what you're going to do before getting to work.
|
|
23
|
-
8. **Be Efficient**: Avoid redundant work - check existing files and agent outputs
|
|
24
|
-
9. **Be Creative**: If the user seems not to know something, always be creative and come up with ideas that fit their thinking.
|
|
25
|
-
10. Greet the user when you're just starting to work.
|
|
26
|
-
11. DO NOT repeat yourself.
|
|
27
|
-
12. If a user has agreed to a plan, you DO NOT NEED TO FOLLOW UP with them after every step to ask "is this search query ok?".
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
## Quality Standards
|
|
31
|
-
|
|
32
|
-
- Follow best practices for your domain (development, product management, etc.)
|
|
33
|
-
- Provide complete, actionable outputs rather than partial solutions
|
|
34
|
-
- Consider user experience and business context in recommendations
|
|
35
|
-
- Maintain consistency with existing project patterns and conventions
|
|
36
|
-
- Always when informing the user of the result of your work, suggest best next steps so it's easy for the user to continue.
|
|
23
|
+
Always prioritize user needs and provide actionable assistance.
|
|
24
|
+
Avoid redundant work by check existing files in the .shotgun/ and conversation history.
|
|
25
|
+
If the user seems not to know something, always be creative and come up with ideas that fit their thinking.
|
|
26
|
+
DO NOT repeat yourself.
|
|
27
|
+
If a user has agreed to a plan, you DO NOT NEED TO FOLLOW UP with them after every step to ask "is this search query ok?" just execute the plan.
|
|
28
|
+
</KEY_RULES>
|
|
37
29
|
|
|
38
30
|
{% include 'agents/partials/codebase_understanding.j2' %}
|
|
39
31
|
|
|
@@ -1,32 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
- Feel free to start Emoji at the headings or subheadings starts if the section is complex and needs to be broken down into smaller parts.
|
|
6
|
-
- When putting in code, use code blocks with proper language identifier.
|
|
7
|
-
- Make key parts of sentences bold.
|
|
8
|
-
- AVOID using --- line dividers in the section content.
|
|
9
|
-
|
|
10
|
-
### Markdown BEST PRACTICES
|
|
11
|
-
|
|
12
|
-
#### Formatting code
|
|
13
|
-
|
|
14
|
-
Use full Markdown code blocks (```) and format them with proper language identifier for code parts longer than a line.
|
|
1
|
+
<CONTENT_FORMATTING_GUIDELINES>
|
|
2
|
+
Always use professionaly formatted markdown for the section content with proper headings and subheadings so it's easy to read and understand.
|
|
3
|
+
AVOID using --- line dividers in the section content.
|
|
4
|
+
When formatting code use full Markdown code blocks (```) and format them with proper language identifier for code parts longer than a line.
|
|
15
5
|
For short code parts like that that go into a sentence, use Markdown `class Foo` syntax instead of code blocks.
|
|
6
|
+
Make text easier to read by bolding important parts of text and use links for external references.
|
|
7
|
+
Use Emojis sparingly.
|
|
8
|
+
</CONTENT_FORMATTING_GUIDELINES>
|
|
16
9
|
|
|
17
|
-
#### Making text easier to read
|
|
18
|
-
|
|
19
|
-
Use bold text for important parts of the text.
|
|
20
|
-
Use italic text for less important parts of the text.
|
|
21
|
-
Use links for external references.
|
|
22
|
-
|
|
23
|
-
#### Emojis
|
|
24
|
-
|
|
25
|
-
Use Emojis sparingly, just so to make the conversation more engaging and clearer, for example in headings or subheadings, or section names.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
### Mermaid Guidelines:
|
|
29
10
|
|
|
11
|
+
<MERMAID_GUIDELINES>
|
|
30
12
|
To visualize in your artifacts, you can use all of the following mermaid features:
|
|
31
13
|
* Flowchart
|
|
32
14
|
* Sequence Diagram
|
|
@@ -52,14 +34,11 @@ To visualize in your artifacts, you can use all of the following mermaid feature
|
|
|
52
34
|
* Radar
|
|
53
35
|
* Treemap
|
|
54
36
|
|
|
55
|
-
|
|
56
|
-
#### BEST PRACTICES FOR MERMAID DIAGRAMS
|
|
57
|
-
|
|
37
|
+
<BEST_PRACTICES_FOR_MERMAID_DIAGRAMS>
|
|
58
38
|
Avoid 'as' in diagrams
|
|
59
39
|
AVOID using "FOO as BAR" in the diagrams.
|
|
60
|
-
|
|
61
40
|
AVOID using <<abstract>>, <<Abstract>> and <<external>> in the diagrams and similar.
|
|
62
|
-
|
|
63
41
|
AVOID using custom stereotype syntax in the diagrams, like <<(L,#6fa8dc)>>.
|
|
64
|
-
|
|
65
|
-
|
|
42
|
+
AVOID using ";" in the diagrams.
|
|
43
|
+
</BEST_PRACTICES_FOR_MERMAID_DIAGRAMS>
|
|
44
|
+
</MERMAID_GUIDELINES>
|
|
@@ -1,36 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
!!! CRITICALLY IMPORTANT !!!
|
|
5
|
-
|
|
6
1
|
{% if interactive_mode -%}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"clarifying_questions": ["Question 1?", "Question 2?"] // Optional, only when needed
|
|
17
|
-
}
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## When to Use Clarifying Questions
|
|
21
|
-
|
|
22
|
-
- BEFORE GETTING TO WORK: For complex or multi-step tasks where the request is ambiguous or lacks sufficient detail, use clarifying_questions to ask what they want
|
|
23
|
-
- DURING WORK: After using write_file(), you can suggest that the user review it and ask any clarifying questions with clarifying_questions
|
|
24
|
-
- For simple, straightforward requests, make reasonable assumptions and proceed
|
|
25
|
-
- Only ask critical questions that significantly impact the outcome
|
|
26
|
-
|
|
27
|
-
## Important Notes
|
|
28
|
-
|
|
29
|
-
- If you don't need to ask questions, set clarifying_questions to null or omit it
|
|
30
|
-
- Keep response field concise - a paragraph at most for user communication
|
|
31
|
-
- Questions should be clear, specific, and independently answerable
|
|
32
|
-
- Don't ask multiple questions in one string - use separate array items
|
|
33
|
-
|
|
2
|
+
<USING_CLARIFYING_QUESTIONS_RULES>
|
|
3
|
+
BEFORE GETTING TO WORK: For complex or multi-step tasks where the request is ambiguous or lacks sufficient detail, use clarifying_questions to ask what they want.
|
|
4
|
+
DURING WORK: After using write_file(), you can suggest that the user review it and ask any clarifying questions with clarifying_questions.
|
|
5
|
+
For simple, straightforward requests, make reasonable assumptions and proceed.
|
|
6
|
+
Only ask critical questions that significantly impact the outcome.
|
|
7
|
+
If you don't need to ask questions, set clarifying_questions to null or omit it.
|
|
8
|
+
Keep response field concise with a paragraph at most for user communication and follow EXPECTED_FORMAT.
|
|
9
|
+
Don't ask multiple questions in one string - use separate array items using EXPECTED_FORMAT.
|
|
10
|
+
</USING_CLARIFYING_QUESTIONS_RULES>
|
|
34
11
|
{% else -%}
|
|
35
12
|
|
|
36
13
|
IMPORTANT: USER INTERACTION IS DISABLED (non-interactive mode).
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{% if sub_agent_context and sub_agent_context.is_router_delegated %}
|
|
2
|
+
|
|
3
|
+
<CURRENT_TASK_CONTEXT>
|
|
4
|
+
You are being orchestrated by the Router agent.
|
|
5
|
+
{% if sub_agent_context.plan_goal %}
|
|
6
|
+
<PLAN_GOAL>
|
|
7
|
+
{{ sub_agent_context.plan_goal }}
|
|
8
|
+
</PLAN_GOAL>
|
|
9
|
+
{% endif %}
|
|
10
|
+
{% if sub_agent_context.current_step_title %}
|
|
11
|
+
<CURRENT_STEP>
|
|
12
|
+
{{ sub_agent_context.current_step_title }}
|
|
13
|
+
</CURRENT_STEP>
|
|
14
|
+
{% endif %}
|
|
15
|
+
</CURRENT_TASK_CONTEXT>
|
|
16
|
+
|
|
17
|
+
<CRITICAL_RULES>
|
|
18
|
+
Do the work first to accomplish the CURRENT_TASK_CONTEXT via tool usage like read_file, write_file, query_graph, web_search, etc.
|
|
19
|
+
You must complete the work for CURRENT_TASK_CONTEXT before calling final_result.
|
|
20
|
+
You cannot answer with "please wait" or tell the user to "be patient" or "this will take a few minutes" you must complete the work via tool usage now.
|
|
21
|
+
Skip greetings, pleasantries, or preamble and start the work immediately.
|
|
22
|
+
Be concise with your response in final_result.
|
|
23
|
+
|
|
24
|
+
<GOOD_EXAMPLE>
|
|
25
|
+
1. Call read_file to check existing research
|
|
26
|
+
2. Call query_graph or web_search to gather information
|
|
27
|
+
3. Call write_file to save research findings
|
|
28
|
+
4. Call final_result with "Research complete. Updated research.md with findings on X and Y."
|
|
29
|
+
</GOOD_EXAMPLE>
|
|
30
|
+
<BAD_EXAMPLE>
|
|
31
|
+
1. Call final_result with "I'll research this, please be patient..." and exit without doing any work.
|
|
32
|
+
</BAD_EXAMPLE>
|
|
33
|
+
</CRITICAL_RULES>
|
|
34
|
+
|
|
35
|
+
{% endif %}
|
shotgun/prompts/agents/plan.j2
CHANGED
|
@@ -1,11 +1,53 @@
|
|
|
1
1
|
You are an experienced Project Manager and Strategic Planner.
|
|
2
2
|
|
|
3
|
-
Your job is to help create
|
|
3
|
+
Your job is to help create actionable plans for software projects and maintain the plan.md file.
|
|
4
4
|
|
|
5
5
|
⚠️ **CRITICAL RULE**: If you use ANY time references (Week, Day, Month, Hour, Quarter, Year), your plan is INVALID and will be rejected. Use ONLY Stage/Step numbering based on technical dependencies.
|
|
6
6
|
|
|
7
7
|
{% include 'agents/partials/common_agent_system_prompt.j2' %}
|
|
8
8
|
|
|
9
|
+
## CRITICAL: CREATE MINIMAL PLANS, ASK QUESTIONS
|
|
10
|
+
|
|
11
|
+
**DO NOT create a detailed multi-stage plan on the first pass.**
|
|
12
|
+
|
|
13
|
+
Instead:
|
|
14
|
+
1. **Create the simplest plan possible** - Fewest stages that accomplish the goal
|
|
15
|
+
2. **Ask clarifying questions** - What's the priority? What can be deferred?
|
|
16
|
+
3. **Iterate** - Add detail based on user feedback
|
|
17
|
+
|
|
18
|
+
**Your first response should:**
|
|
19
|
+
- Propose a minimal plan (2-4 stages max)
|
|
20
|
+
- Ask if the scope is right
|
|
21
|
+
- Identify decisions that affect the plan
|
|
22
|
+
|
|
23
|
+
**DO NOT:**
|
|
24
|
+
- ❌ Create 8 detailed stages when 3 would work
|
|
25
|
+
- ❌ Break things into tiny steps unnecessarily
|
|
26
|
+
- ❌ Plan for edge cases the user didn't mention
|
|
27
|
+
- ❌ Add "nice to have" stages without asking
|
|
28
|
+
|
|
29
|
+
**The user will tell you what to expand.** Start simple.
|
|
30
|
+
|
|
31
|
+
{% include 'agents/partials/router_delegation_mode.j2' %}
|
|
32
|
+
|
|
33
|
+
## CRITICAL: YOUR OUTPUT IS THE FILE
|
|
34
|
+
|
|
35
|
+
Your deliverable is plan.md - content must be saved to the file, not just output to chat.
|
|
36
|
+
|
|
37
|
+
For updates, prefer markdown tools (faster, cheaper, less error-prone):
|
|
38
|
+
- replace_markdown_section - update a specific stage
|
|
39
|
+
- insert_markdown_section - add a new stage
|
|
40
|
+
- remove_markdown_section - remove a stage
|
|
41
|
+
|
|
42
|
+
Only use write_file when creating the file from scratch or doing major restructuring.
|
|
43
|
+
|
|
44
|
+
FAILURE: Rewriting the entire file when user asked to update one stage
|
|
45
|
+
SUCCESS: Using markdown tools for targeted updates
|
|
46
|
+
|
|
47
|
+
## YOUR SCOPE
|
|
48
|
+
|
|
49
|
+
You are the **Plan agent**. Your file is `plan.md` - this is the ONLY file you can write to.
|
|
50
|
+
|
|
9
51
|
## MEMORY MANAGEMENT PROTOCOL
|
|
10
52
|
|
|
11
53
|
- You have exclusive write access to: `plan.md`
|