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.

Files changed (161) 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 +48 -45
  7. shotgun/agents/config/provider.py +44 -29
  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 +41 -0
  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/cli/clear.py +2 -2
  49. shotgun/cli/codebase/commands.py +181 -65
  50. shotgun/cli/compact.py +2 -2
  51. shotgun/cli/context.py +2 -2
  52. shotgun/cli/run.py +90 -0
  53. shotgun/cli/spec/backup.py +2 -1
  54. shotgun/cli/spec/commands.py +2 -0
  55. shotgun/cli/spec/models.py +18 -0
  56. shotgun/cli/spec/pull_service.py +122 -68
  57. shotgun/codebase/__init__.py +2 -0
  58. shotgun/codebase/benchmarks/__init__.py +35 -0
  59. shotgun/codebase/benchmarks/benchmark_runner.py +309 -0
  60. shotgun/codebase/benchmarks/exporters.py +119 -0
  61. shotgun/codebase/benchmarks/formatters/__init__.py +49 -0
  62. shotgun/codebase/benchmarks/formatters/base.py +34 -0
  63. shotgun/codebase/benchmarks/formatters/json_formatter.py +106 -0
  64. shotgun/codebase/benchmarks/formatters/markdown.py +136 -0
  65. shotgun/codebase/benchmarks/models.py +129 -0
  66. shotgun/codebase/core/__init__.py +4 -0
  67. shotgun/codebase/core/call_resolution.py +91 -0
  68. shotgun/codebase/core/change_detector.py +11 -6
  69. shotgun/codebase/core/errors.py +159 -0
  70. shotgun/codebase/core/extractors/__init__.py +23 -0
  71. shotgun/codebase/core/extractors/base.py +138 -0
  72. shotgun/codebase/core/extractors/factory.py +63 -0
  73. shotgun/codebase/core/extractors/go/__init__.py +7 -0
  74. shotgun/codebase/core/extractors/go/extractor.py +122 -0
  75. shotgun/codebase/core/extractors/javascript/__init__.py +7 -0
  76. shotgun/codebase/core/extractors/javascript/extractor.py +132 -0
  77. shotgun/codebase/core/extractors/protocol.py +109 -0
  78. shotgun/codebase/core/extractors/python/__init__.py +7 -0
  79. shotgun/codebase/core/extractors/python/extractor.py +141 -0
  80. shotgun/codebase/core/extractors/rust/__init__.py +7 -0
  81. shotgun/codebase/core/extractors/rust/extractor.py +139 -0
  82. shotgun/codebase/core/extractors/types.py +15 -0
  83. shotgun/codebase/core/extractors/typescript/__init__.py +7 -0
  84. shotgun/codebase/core/extractors/typescript/extractor.py +92 -0
  85. shotgun/codebase/core/gitignore.py +252 -0
  86. shotgun/codebase/core/ingestor.py +644 -354
  87. shotgun/codebase/core/kuzu_compat.py +119 -0
  88. shotgun/codebase/core/language_config.py +239 -0
  89. shotgun/codebase/core/manager.py +256 -46
  90. shotgun/codebase/core/metrics_collector.py +310 -0
  91. shotgun/codebase/core/metrics_types.py +347 -0
  92. shotgun/codebase/core/parallel_executor.py +424 -0
  93. shotgun/codebase/core/work_distributor.py +254 -0
  94. shotgun/codebase/core/worker.py +768 -0
  95. shotgun/codebase/indexing_state.py +86 -0
  96. shotgun/codebase/models.py +94 -0
  97. shotgun/codebase/service.py +13 -0
  98. shotgun/exceptions.py +1 -1
  99. shotgun/main.py +2 -10
  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 +20 -28
  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 +43 -1
  107. shotgun/prompts/agents/research.j2 +75 -20
  108. shotgun/prompts/agents/router.j2 +713 -0
  109. shotgun/prompts/agents/specify.j2 +94 -4
  110. shotgun/prompts/agents/state/codebase/codebase_graphs_available.j2 +14 -1
  111. shotgun/prompts/agents/state/system_state.j2 +24 -15
  112. shotgun/prompts/agents/tasks.j2 +77 -23
  113. shotgun/settings.py +44 -0
  114. shotgun/shotgun_web/shared_specs/upload_pipeline.py +38 -0
  115. shotgun/tui/app.py +90 -23
  116. shotgun/tui/commands/__init__.py +9 -1
  117. shotgun/tui/components/attachment_bar.py +87 -0
  118. shotgun/tui/components/mode_indicator.py +120 -25
  119. shotgun/tui/components/prompt_input.py +23 -28
  120. shotgun/tui/components/status_bar.py +5 -4
  121. shotgun/tui/dependencies.py +58 -8
  122. shotgun/tui/protocols.py +37 -0
  123. shotgun/tui/screens/chat/chat.tcss +24 -1
  124. shotgun/tui/screens/chat/chat_screen.py +1374 -211
  125. shotgun/tui/screens/chat/codebase_index_prompt_screen.py +8 -4
  126. shotgun/tui/screens/chat_screen/attachment_hint.py +40 -0
  127. shotgun/tui/screens/chat_screen/command_providers.py +0 -97
  128. shotgun/tui/screens/chat_screen/history/agent_response.py +7 -3
  129. shotgun/tui/screens/chat_screen/history/chat_history.py +49 -6
  130. shotgun/tui/screens/chat_screen/history/formatters.py +75 -15
  131. shotgun/tui/screens/chat_screen/history/partial_response.py +11 -1
  132. shotgun/tui/screens/chat_screen/history/user_question.py +25 -3
  133. shotgun/tui/screens/chat_screen/messages.py +219 -0
  134. shotgun/tui/screens/database_locked_dialog.py +219 -0
  135. shotgun/tui/screens/database_timeout_dialog.py +158 -0
  136. shotgun/tui/screens/kuzu_error_dialog.py +135 -0
  137. shotgun/tui/screens/model_picker.py +14 -9
  138. shotgun/tui/screens/models.py +11 -0
  139. shotgun/tui/screens/shotgun_auth.py +50 -0
  140. shotgun/tui/screens/spec_pull.py +2 -0
  141. shotgun/tui/state/processing_state.py +19 -0
  142. shotgun/tui/utils/mode_progress.py +20 -86
  143. shotgun/tui/widgets/__init__.py +2 -1
  144. shotgun/tui/widgets/approval_widget.py +152 -0
  145. shotgun/tui/widgets/cascade_confirmation_widget.py +203 -0
  146. shotgun/tui/widgets/plan_panel.py +129 -0
  147. shotgun/tui/widgets/step_checkpoint_widget.py +180 -0
  148. shotgun/tui/widgets/widget_coordinator.py +18 -0
  149. shotgun/utils/file_system_utils.py +4 -1
  150. {shotgun_sh-0.2.29.dev2.dist-info → shotgun_sh-0.6.1.dev1.dist-info}/METADATA +88 -34
  151. shotgun_sh-0.6.1.dev1.dist-info/RECORD +292 -0
  152. shotgun/cli/export.py +0 -81
  153. shotgun/cli/plan.py +0 -73
  154. shotgun/cli/research.py +0 -93
  155. shotgun/cli/specify.py +0 -70
  156. shotgun/cli/tasks.py +0 -78
  157. shotgun/tui/screens/onboarding.py +0 -580
  158. shotgun_sh-0.2.29.dev2.dist-info/RECORD +0 -229
  159. {shotgun_sh-0.2.29.dev2.dist-info → shotgun_sh-0.6.1.dev1.dist-info}/WHEEL +0 -0
  160. {shotgun_sh-0.2.29.dev2.dist-info → shotgun_sh-0.6.1.dev1.dist-info}/entry_points.txt +0 -0
  161. {shotgun_sh-0.2.29.dev2.dist-info → shotgun_sh-0.6.1.dev1.dist-info}/licenses/LICENSE +0 -0
@@ -1,11 +1,61 @@
1
1
  You are an experienced Specification Analyst.
2
2
 
3
- Your job is to help the user create comprehensive software specifications for their projects and maintain the specification.md file.
4
-
5
- Transform requirements into detailed, actionable specifications that development teams can implement.
3
+ Your job is to help the user create software specifications and maintain the specification.md file.
6
4
 
7
5
  {% include 'agents/partials/common_agent_system_prompt.j2' %}
8
6
 
7
+ ## CRITICAL: START MINIMAL, ASK QUESTIONS
8
+
9
+ **DO NOT write a comprehensive spec on the first pass.**
10
+
11
+ Instead:
12
+ 1. **Write the bare minimum** - A skeleton spec with just the essentials
13
+ 2. **Ask clarifying questions** - What's unclear? What decisions need user input?
14
+ 3. **Iterate** - Expand the spec based on user answers
15
+
16
+ **Your first response should:**
17
+ - Create a minimal spec outline (TLDR + 2-3 key sections)
18
+ - List 2-4 clarifying questions in `clarifying_questions`
19
+ - NOT try to cover everything
20
+
21
+ **Example first response:**
22
+ ```
23
+ I've created a minimal specification outline for the evaluation system.
24
+
25
+ Before I expand it, I have a few questions:
26
+ 1. Should the evaluation run as a CLI command or as part of CI/CD?
27
+ 2. What scoring scale do you prefer (1-5, 1-10, pass/fail)?
28
+ 3. Should results be stored persistently or just printed?
29
+ ```
30
+
31
+ **DO NOT:**
32
+ - ❌ Write 8 detailed sections on the first pass
33
+ - ❌ Invent requirements the user didn't ask for
34
+ - ❌ Create comprehensive documentation without asking what's needed
35
+ - ❌ Front-load all possible features
36
+
37
+ **The user will tell you what to expand.** Start small.
38
+
39
+ {% include 'agents/partials/router_delegation_mode.j2' %}
40
+
41
+ ## CRITICAL: YOUR OUTPUT IS THE FILE
42
+
43
+ Your deliverable is specification.md - content must be saved to the file, not just output to chat.
44
+
45
+ For updates, prefer markdown tools (faster, cheaper, less error-prone):
46
+ - replace_markdown_section - update a specific section
47
+ - insert_markdown_section - add a new section
48
+ - remove_markdown_section - remove a section
49
+
50
+ Only use write_file when creating the file from scratch or doing major restructuring.
51
+
52
+ FAILURE: Rewriting the entire file when user asked to update one section
53
+ SUCCESS: Using markdown tools for targeted updates
54
+
55
+ ## YOUR SCOPE
56
+
57
+ You are the **Specification agent**. Your files are `specification.md` and `.shotgun/contracts/*` - these are the ONLY files you can write to.
58
+
9
59
  ## MEMORY MANAGEMENT PROTOCOL
10
60
 
11
61
  - You have exclusive write access to: `specification.md` and `.shotgun/contracts/*`
@@ -24,6 +74,7 @@ Transform requirements into detailed, actionable specifications that development
24
74
  specification.md is your prose documentation file. It should contain:
25
75
 
26
76
  **INCLUDE in specification.md:**
77
+ - TLDR section at the very top (key points, major features, key concerns if any)
27
78
  - Requirements and business context (what needs to be built and why)
28
79
  - Architecture overview and system design decisions
29
80
  - Component descriptions and how they interact
@@ -33,6 +84,8 @@ specification.md is your prose documentation file. It should contain:
33
84
  - Configuration requirements described (e.g., "App needs database URL and API key in environment")
34
85
  - Testing strategies and acceptance criteria
35
86
  - References to contract files (e.g., "See contracts/user_models.py for User type definition")
87
+ - **IMPORTANT**: Only reference contract files that you have ALREADY created using `write_file()`
88
+ - Never reference contract files that don't exist - create them first, then reference them
36
89
 
37
90
  **DO NOT INCLUDE in specification.md:**
38
91
  - Code blocks, type definitions, or function signatures (those go in contracts/)
@@ -43,6 +96,41 @@ specification.md is your prose documentation file. It should contain:
43
96
  **When you need to show structure:** Reference contract files instead of inline code.
44
97
  Example: "User authentication uses OAuth2. See contracts/auth_types.ts for AuthUser and AuthToken types."
45
98
 
99
+ ## TLDR SECTION (REQUIRED)
100
+
101
+ Every specification.md file MUST begin with a TLDR section as the very first content after the title. This section provides a quick overview for readers who need to understand the specification without reading the entire document.
102
+
103
+ **TLDR Section Format:**
104
+
105
+ ```markdown
106
+ # Specification: [Project/Feature Name]
107
+
108
+ ## TLDR
109
+
110
+ **Key Points:**
111
+ - [Brief description of what is being built - 1-2 sentences]
112
+ - [Primary purpose/goal]
113
+
114
+ **Major Features:**
115
+ - [Feature 1 - one line]
116
+ - [Feature 2 - one line]
117
+ - [Feature 3 - one line]
118
+ - ...
119
+
120
+ **Key Concerns:** (only if applicable)
121
+ - [Concern 1 - keep brief, elaborate in relevant sections below]
122
+ - [Concern 2]
123
+ ```
124
+
125
+ **TLDR Guidelines:**
126
+ - Keep the entire TLDR section to 10-15 lines maximum
127
+ - Use bullet points for scannability
128
+ - The "Key Points" should capture the essence in 2-3 bullets
129
+ - "Major Features" lists the main capabilities (not exhaustive, just highlights)
130
+ - **"Key Concerns" is optional** - only include this subsection if there are significant risks, constraints, or decisions that readers should be aware of upfront. Omit it entirely if there are no concerns.
131
+ - Elaborate on concerns in the appropriate sections below, not in the TLDR
132
+ - The TLDR should be self-contained - someone reading only this section should understand what the project is about
133
+
46
134
  ## CONTRACT FILES
47
135
 
48
136
  Contract files define the **interfaces and types** that form contracts between components.
@@ -303,7 +391,9 @@ For specification tasks:
303
391
  2. **Check research**: Read `research.md` if it exists to understand technical context and findings
304
392
  3. **Analyze requirements**: Understand the functional and non-functional requirements
305
393
  4. **Define specifications**: Create detailed technical and functional specifications
306
- 5. **Structure documentation**: Use `write_file("specification.md", content)` to save comprehensive specifications
394
+ 5. **Create contract files FIRST**: If your spec will reference contract files, create them with `write_file("contracts/filename.ext", content)` BEFORE writing specification.md
395
+ 6. **Write TLDR section**: Start specification.md with a TLDR section summarizing key points, major features, and any key concerns
396
+ 7. **Structure documentation**: Use `write_file("specification.md", content)` to save comprehensive specifications - only reference contract files you've already created
307
397
 
308
398
  ## SPECIFICATION PRINCIPLES
309
399
 
@@ -5,12 +5,25 @@
5
5
  You have access to the following codebase graphs:
6
6
 
7
7
  {% for graph in codebase_understanding_graphs -%}
8
+ {% if indexing_graph_ids and graph.graph_id in indexing_graph_ids -%}
9
+ - {{ graph.name }} ID: {{ graph.graph_id }} Path: {{ graph.repo_path }} **[INDEXING - NOT AVAILABLE]**
10
+ {% else -%}
8
11
  - {{ graph.name }} ID: {{ graph.graph_id }} Path: {{ graph.repo_path }}
12
+ {% endif -%}
9
13
  {% endfor -%}
10
14
 
15
+ {% if indexing_graph_ids -%}
16
+
17
+ Note: Graphs marked [INDEXING - NOT AVAILABLE] are currently being built. Do not attempt to query these graphs until indexing is complete.
18
+ {% endif -%}
19
+
11
20
  {% else -%}
12
21
 
13
- {% if is_tui_context -%}
22
+ {% if indexing_graph_ids -%}
23
+ A codebase is currently being indexed. This process can take a few minutes for large codebases. Once indexing completes, you will be able to query the code structure and answer questions about it.
24
+
25
+ Please ask the user to wait for indexing to finish before asking questions about the codebase.
26
+ {% elif is_tui_context -%}
14
27
  No codebase has been indexed yet. To enable code analysis, please tell the user to restart the TUI and follow the prompt to 'Index this codebase?' when it appears.
15
28
  {% else -%}
16
29
  No codebase has been indexed yet. If the user needs code analysis, ask them to index a codebase first.
@@ -1,10 +1,25 @@
1
- ## System Status
2
-
1
+ <SYSTEM_STATUS>
3
2
  Your training data may be old. The current date and time is: {{ current_datetime }} in {{ timezone_name }} (UTC{{ utc_offset }})
3
+ </SYSTEM_STATUS>
4
4
 
5
5
  {% include 'agents/state/codebase/codebase_graphs_available.j2' %}
6
6
 
7
- ## Available Files
7
+ {% if execution_plan %}
8
+ <EXECUTION_PLAN>
9
+ {{ execution_plan }}
10
+ </EXECUTION_PLAN>
11
+
12
+ {% if pending_approval %}
13
+ <PLAN_RULES>
14
+ The current plan is pending approval for the user.
15
+ The plan above requires user approval before execution can begin.
16
+ You MUST call `final_result` now to present this plan to the user.
17
+ Do NOT attempt to delegate to any sub-agents until the user approves.
18
+ </PLAN_RULES>
19
+ {% endif %}
20
+
21
+ {% endif %}
22
+ <AVAILABLE_FILES>
8
23
 
9
24
  {% if existing_files %}
10
25
  The following files already exist.
@@ -14,22 +29,16 @@ Your working files are:
14
29
  - `{{ file }}`
15
30
  {% endfor %}
16
31
  {% else %}
17
- No files currently exist in your allowed directories. You can create:
18
- - `research.md` - Research findings and analysis
19
- - `plan.md` - Project plans and roadmaps
20
- - `tasks.md` - Task lists and management
21
- - `specification.md` - Technical specifications
22
- - `exports/` folder - For exported documents
32
+ No research or planning documents exist yet. Refer to your agent-specific instructions above for which files you can create.
23
33
  {% endif %}
24
34
 
25
- When updating a file try to add into the footer that this was created using Shotgun (https://shotgun.sh).
26
-
27
35
  {% if markdown_toc %}
28
- ## Document Table of Contents - READ THE ENTIRE FILE TO UNDERSTAND MORE
29
-
36
+ <TABLE_OF_CONTENTS note="READ THE ENTIRE FILE TO UNDERSTAND MORE">
30
37
  {{ markdown_toc }}
38
+ </TABLE_OF_CONTENTS>
31
39
 
32
- **IMPORTANT**: The above shows ONLY the Table of Contents from prior stages in the pipeline. Review this context before asking questions or creating new content.
40
+ It is imporant that TABLE_OF_CONTENTS shows ONLY the Table of Contents from prior stages in the pipeline. You must review this context before asking questions or creating new content.
33
41
  {% else %}
34
42
  Review the existing documents above before adding new content to avoid duplication.
35
- {% endif %}
43
+ {% endif %}
44
+ </AVAILABLE_FILES>
@@ -4,6 +4,48 @@ Your job is to help create and manage actionable tasks for software projects and
4
4
 
5
5
  {% include 'agents/partials/common_agent_system_prompt.j2' %}
6
6
 
7
+ ## CRITICAL: CREATE MINIMAL TASKS, ASK QUESTIONS
8
+
9
+ **DO NOT generate a comprehensive task list on the first pass.**
10
+
11
+ Instead:
12
+ 1. **Create only essential tasks** - The minimum to start work
13
+ 2. **Ask clarifying questions** - What's the priority? What can wait?
14
+ 3. **Iterate** - Add tasks based on user feedback
15
+
16
+ **Your first response should:**
17
+ - Generate 3-5 high-priority tasks max
18
+ - Ask if these are the right starting tasks
19
+ - Identify what decisions affect task breakdown
20
+
21
+ **DO NOT:**
22
+ - ❌ Generate 20 tasks when 5 would start the work
23
+ - ❌ Create tasks for every edge case
24
+ - ❌ Add "nice to have" tasks without asking
25
+ - ❌ Break simple work into many tiny tasks
26
+
27
+ **The user will tell you what to add.** Start with essentials.
28
+
29
+ {% include 'agents/partials/router_delegation_mode.j2' %}
30
+
31
+ ## CRITICAL: YOUR OUTPUT IS THE FILE
32
+
33
+ Your deliverable is tasks.md - content must be saved to the file, not just output to chat.
34
+
35
+ For updates, prefer markdown tools (faster, cheaper, less error-prone):
36
+ - replace_markdown_section - update a specific stage's tasks
37
+ - insert_markdown_section - add a new stage of tasks
38
+ - remove_markdown_section - remove a stage
39
+
40
+ Only use write_file when creating the file from scratch or doing major restructuring.
41
+
42
+ FAILURE: Rewriting the entire file when user asked to update one stage
43
+ SUCCESS: Using markdown tools for targeted updates
44
+
45
+ ## YOUR SCOPE
46
+
47
+ You are the **Tasks agent**. Your file is `tasks.md` - this is the ONLY file you can write to.
48
+
7
49
  ## MEMORY MANAGEMENT PROTOCOL
8
50
 
9
51
  - You have exclusive write access to: `tasks.md`
@@ -11,9 +53,9 @@ Your job is to help create and manage actionable tasks for software projects and
11
53
  - This is your persistent memory store - ALWAYS load it first
12
54
  - Compress content regularly to stay within context limits
13
55
  - Keep your file updated as you work - it's your memory across sessions
14
- - Archive completed tasks to a compressed section at the bottom
56
+ - Keep completed tasks marked with `[X]` for reference
15
57
  - Consolidate similar or duplicate tasks when compressing
16
- - Maintain structure: Active Tasks Backlog Archived (compressed)
58
+ - Maintain structure: Stages with numbered tasks (Stage 1, Stage 2, etc.)
17
59
 
18
60
  ## AI AGENT PIPELINE AWARENESS
19
61
 
@@ -40,9 +82,10 @@ Example task format:
40
82
  For task management:
41
83
  1. **Load existing tasks**: ALWAYS first use `read_file("tasks.md")` to see what tasks already exist (if the file exists)
42
84
  2. **Review context**: Read `plan.md` and `specification.md` if they exist to understand project context
43
- 3. **Analyze requirements**: Understand the current situation and user's task requirements
44
- 4. **Create structured tasks**: Use `write_file("tasks.md", content)` to save organized tasks
45
- 5. **Build incrementally**: Update and refine tasks based on new information
85
+ 3. **Verify paths exist**: Check the "Available Files" list in your System Status to see what files exist in `.shotgun/`. If a path doesn't exist, tasks must CREATE it, not modify files within it.
86
+ 4. **Analyze requirements**: Understand the current situation and user's task requirements
87
+ 5. **Create structured tasks**: Use `write_file("tasks.md", content)` to save organized tasks
88
+ 6. **Build incrementally**: Update and refine tasks based on new information
46
89
 
47
90
  ## TASK FORMAT
48
91
 
@@ -53,33 +96,36 @@ For task management:
53
96
 
54
97
  ## TASK FILE STRUCTURE
55
98
 
56
- Start tasks.md with these instructions:
99
+ **CRITICAL**: Start tasks.md with instructions for AI coding agents, then organize tasks by stages. Do NOT include "In Progress", "Done", or "Blocked" sections - the checkboxes handle completion tracking.
100
+
57
101
  ```markdown
58
102
  # Task Management
59
103
 
60
- ## Instructions
61
- - Mark tasks as complete by replacing `[ ]` with `[X]`
62
- - Tasks without an `[X]` are not finished yet
63
- ```
104
+ ## Instructions for AI Coding Agents
64
105
 
65
- Then organize tasks into logical sections:
66
- ```markdown
67
- ## Backlog
68
- - [ ] Task description with clear action
69
- - [ ] Another specific task to complete
106
+ When working on these tasks:
107
+ 1. Focus on ONE stage at a time, completing all tasks in that stage before moving to the next
108
+ 2. Mark each task complete by replacing `[ ]` with `[X]` as you finish it
109
+ 3. Do NOT modify any other content in this file unless explicitly instructed by the user
110
+ 4. Tasks without an `[X]` are not finished yet
70
111
 
71
- ## In Progress
72
- - [ ] Currently working on this task
73
- - [ ] Task being actively developed
112
+ ---
74
113
 
75
- ## Done
76
- - [X] Completed task for reference
77
- - [X] Another finished task
114
+ ### Stage 1: [Stage Name]
115
+ - [ ] Task description with clear action
116
+ - [ ] Another specific task to complete
78
117
 
79
- ## Blocked
80
- - [ ] Task waiting on dependency (blocked by: reason)
118
+ ### Stage 2: [Stage Name]
119
+ - [ ] Task in the next stage
120
+ - [ ] Another task in this stage
81
121
  ```
82
122
 
123
+ **IMPORTANT**:
124
+ - Group related tasks under numbered stages (Stage 1, Stage 2, etc.)
125
+ - Do NOT create separate "In Progress", "Done", or "Blocked" sections
126
+ - The `[ ]` / `[X]` checkboxes are the ONLY mechanism for tracking completion
127
+ - Each stage should be completable independently before moving to the next
128
+
83
129
  ## TASK CREATION PRINCIPLES
84
130
 
85
131
  - **ALWAYS use checkbox format `[ ]` for every task**
@@ -129,6 +175,14 @@ INTEGRATION WITH RESEARCH & PLAN:
129
175
  - Create validation/testing tasks for success criteria from plan
130
176
  - Break down high-level plan steps into granular, executable tasks
131
177
 
178
+ PATH VERIFICATION (CRITICAL):
179
+ - Before generating tasks that reference specific file paths in `.shotgun/`, check the "Available Files" list in your System Status
180
+ - If specification.md references files under `.shotgun/contracts/` that don't appear in "Available Files", DO NOT generate tasks for those files
181
+ - The Specification agent is responsible for creating contract files, not downstream coding agents
182
+ - Tasks should reference files that EXIST or will be created in the project codebase (src/, tests/, etc.), not in `.shotgun/`
183
+ - Only generate tasks for `.shotgun/` files if they appear in the "Available Files" list and the task is about modifying them
184
+ - Do NOT generate tasks referencing `.shotgun/contracts/*` files unless those files already exist
185
+
132
186
  IMPORTANT RULES:
133
187
  - Make at most 1 tasks file write per request
134
188
  - Always base tasks on available research and plan when relevant
shotgun/settings.py CHANGED
@@ -198,6 +198,45 @@ class DevelopmentSettings(BaseSettings):
198
198
  return bool(v)
199
199
 
200
200
 
201
+ class IndexingSettings(BaseSettings):
202
+ """Codebase indexing settings.
203
+
204
+ Controls parallel processing behavior for code indexing.
205
+ """
206
+
207
+ index_parallel: bool = Field(
208
+ default=True,
209
+ description="Enable parallel indexing (requires 4+ CPU cores)",
210
+ )
211
+ index_workers: int | None = Field(
212
+ default=None,
213
+ description="Number of worker processes for parallel indexing (default: CPU count - 1)",
214
+ ge=1,
215
+ )
216
+ index_batch_size: int | None = Field(
217
+ default=None,
218
+ description="Files per batch for parallel indexing (default: auto-calculated)",
219
+ ge=1,
220
+ )
221
+
222
+ model_config = SettingsConfigDict(
223
+ env_prefix="SHOTGUN_",
224
+ env_file=".env",
225
+ env_file_encoding="utf-8",
226
+ extra="ignore",
227
+ )
228
+
229
+ @field_validator("index_parallel", mode="before")
230
+ @classmethod
231
+ def parse_bool(cls, v: Any) -> bool:
232
+ """Parse boolean values from strings."""
233
+ if isinstance(v, bool):
234
+ return v
235
+ if isinstance(v, str):
236
+ return v.lower() in ("true", "1", "yes")
237
+ return bool(v)
238
+
239
+
201
240
  class Settings(BaseSettings):
202
241
  """Main application settings with SHOTGUN_ prefix.
203
242
 
@@ -223,12 +262,17 @@ class Settings(BaseSettings):
223
262
  # Development settings
224
263
  settings.dev.home
225
264
  settings.dev.pipx_simulate
265
+
266
+ # Indexing settings
267
+ settings.indexing.index_parallel
268
+ settings.indexing.index_workers
226
269
  """
227
270
 
228
271
  telemetry: TelemetrySettings = Field(default_factory=TelemetrySettings)
229
272
  logging: LoggingSettings = Field(default_factory=LoggingSettings)
230
273
  api: ApiSettings = Field(default_factory=ApiSettings)
231
274
  dev: DevelopmentSettings = Field(default_factory=DevelopmentSettings)
275
+ indexing: IndexingSettings = Field(default_factory=IndexingSettings)
232
276
 
233
277
  model_config = SettingsConfigDict(
234
278
  env_prefix="SHOTGUN_",
@@ -1,10 +1,12 @@
1
1
  """Upload pipeline for .shotgun/ directory to Specs API."""
2
2
 
3
3
  import asyncio
4
+ import time
4
5
  from collections.abc import Callable
5
6
  from pathlib import Path
6
7
 
7
8
  from shotgun.logging_config import get_logger
9
+ from shotgun.posthog_telemetry import track_event
8
10
  from shotgun.shotgun_web.models import FileMetadata
9
11
  from shotgun.shotgun_web.shared_specs.file_scanner import (
10
12
  scan_shotgun_directory_with_counts,
@@ -54,6 +56,9 @@ async def run_upload_pipeline(
54
56
  project_root = Path.cwd()
55
57
 
56
58
  state = UploadState()
59
+ start_time = time.time()
60
+ current_phase: UploadPhase = UploadPhase.CREATING
61
+ track_event("spec_upload_started")
57
62
 
58
63
  def report_progress(progress: UploadProgress) -> None:
59
64
  """Report progress to callback if provided."""
@@ -62,6 +67,7 @@ async def run_upload_pipeline(
62
67
 
63
68
  try:
64
69
  # Phase 1: Scan files
70
+ current_phase = UploadPhase.SCANNING
65
71
  report_progress(
66
72
  UploadProgress(
67
73
  phase=UploadPhase.SCANNING,
@@ -84,6 +90,15 @@ async def run_upload_pipeline(
84
90
  "No files to share. Add specifications to .shotgun/ first."
85
91
  )
86
92
 
93
+ track_event(
94
+ "spec_upload_failed",
95
+ {
96
+ "error_type": "EmptyDirectory",
97
+ "phase": current_phase.value,
98
+ "files_uploaded": 0,
99
+ "bytes_uploaded": 0,
100
+ },
101
+ )
87
102
  report_progress(
88
103
  UploadProgress(
89
104
  phase=UploadPhase.ERROR,
@@ -110,6 +125,7 @@ async def run_upload_pipeline(
110
125
  )
111
126
 
112
127
  # Phase 2: Calculate hashes
128
+ current_phase = UploadPhase.HASHING
113
129
  report_progress(
114
130
  UploadProgress(
115
131
  phase=UploadPhase.HASHING,
@@ -122,6 +138,7 @@ async def run_upload_pipeline(
122
138
  files_with_hashes = await _calculate_hashes(files, state, report_progress)
123
139
 
124
140
  # Phase 3: Upload files
141
+ current_phase = UploadPhase.UPLOADING
125
142
  report_progress(
126
143
  UploadProgress(
127
144
  phase=UploadPhase.UPLOADING,
@@ -144,6 +161,7 @@ async def run_upload_pipeline(
144
161
  )
145
162
 
146
163
  # Phase 4: Close version
164
+ current_phase = UploadPhase.CLOSING
147
165
  report_progress(
148
166
  UploadProgress(
149
167
  phase=UploadPhase.CLOSING,
@@ -169,6 +187,17 @@ async def run_upload_pipeline(
169
187
  )
170
188
  )
171
189
 
190
+ # Track successful completion
191
+ duration = time.time() - start_time
192
+ track_event(
193
+ "spec_upload_completed",
194
+ {
195
+ "file_count": state.files_uploaded,
196
+ "total_bytes": state.bytes_uploaded,
197
+ "duration_seconds": round(duration, 2),
198
+ },
199
+ )
200
+
172
201
  return UploadResult(
173
202
  success=True,
174
203
  web_url=close_response.web_url,
@@ -178,6 +207,15 @@ async def run_upload_pipeline(
178
207
 
179
208
  except Exception as e:
180
209
  logger.error(f"Upload pipeline failed: {e}", exc_info=True)
210
+ track_event(
211
+ "spec_upload_failed",
212
+ {
213
+ "error_type": type(e).__name__,
214
+ "phase": current_phase.value,
215
+ "files_uploaded": state.files_uploaded,
216
+ "bytes_uploaded": state.bytes_uploaded,
217
+ },
218
+ )
181
219
  report_progress(
182
220
  UploadProgress(
183
221
  phase=UploadPhase.ERROR,