sugarai 3.1.1.dev4__tar.gz → 3.3.1__tar.gz

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 (105) hide show
  1. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/PKG-INFO +120 -4
  2. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/README.md +114 -2
  3. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/pyproject.toml +7 -2
  4. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/agent/base.py +72 -56
  5. sugarai-3.3.1/sugar/config/__init__.py +6 -0
  6. sugarai-3.3.1/sugar/config/issue_responder_config.py +143 -0
  7. sugarai-3.3.1/sugar/config/prompt_config.py +135 -0
  8. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/core/loop.py +20 -0
  9. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/discovery/github_watcher.py +154 -2
  10. sugarai-3.3.1/sugar/executor/agent_sdk_executor.py +441 -0
  11. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/main.py +174 -1
  12. sugarai-3.3.1/sugar/mcp/__init__.py +34 -0
  13. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/profiles/issue_responder.py +16 -1
  14. sugarai-3.3.1/sugar/ralph/__init__.py +19 -0
  15. sugarai-3.3.1/sugar/ralph/config.py +75 -0
  16. sugarai-3.3.1/sugar/ralph/profile.py +365 -0
  17. sugarai-3.3.1/sugar/ralph/validator.py +293 -0
  18. sugarai-3.3.1/sugar/storage/__init__.py +5 -0
  19. sugarai-3.3.1/sugar/storage/issue_response_manager.py +258 -0
  20. sugarai-3.3.1/sugar/triage/__init__.py +43 -0
  21. sugarai-3.3.1/sugar/triage/capability_scanner.py +752 -0
  22. sugarai-3.3.1/sugar/triage/complexity_analyzer.py +739 -0
  23. sugarai-3.3.1/sugar/triage/triage_analyzer.py +440 -0
  24. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugarai.egg-info/PKG-INFO +120 -4
  25. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugarai.egg-info/SOURCES.txt +19 -0
  26. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugarai.egg-info/requires.txt +5 -0
  27. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/tests/test_agent.py +24 -1
  28. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/tests/test_cli.py +105 -0
  29. sugarai-3.3.1/tests/test_complexity_analyzer.py +634 -0
  30. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/tests/test_core_loop.py +48 -0
  31. sugarai-3.3.1/tests/test_github_client.py +561 -0
  32. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/tests/test_goose_integration.py +3 -2
  33. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/tests/test_issue_responder_cli.py +36 -7
  34. sugarai-3.3.1/tests/test_issue_response_integration.py +1042 -0
  35. sugarai-3.3.1/tests/test_mcp_integration.py +498 -0
  36. sugarai-3.3.1/tests/test_mcp_server.py +253 -0
  37. sugarai-3.3.1/tests/test_prompt_config.py +359 -0
  38. sugarai-3.3.1/tests/test_ralph.py +410 -0
  39. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/tests/test_subagent_manager.py +13 -9
  40. sugarai-3.1.1.dev4/sugar/executor/agent_sdk_executor.py +0 -223
  41. sugarai-3.1.1.dev4/sugar/mcp/__init__.py +0 -11
  42. sugarai-3.1.1.dev4/sugar/utils/__init__.py +0 -0
  43. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/LICENSE +0 -0
  44. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/setup.cfg +0 -0
  45. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/__init__.py +0 -0
  46. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/__version__.py +0 -0
  47. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/agent/__init__.py +0 -0
  48. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/agent/hooks.py +0 -0
  49. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/agent/subagent_manager.py +0 -0
  50. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/agent/tools.py +0 -0
  51. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/billing/__init__.py +0 -0
  52. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/billing/api_keys.py +0 -0
  53. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/billing/tiers.py +0 -0
  54. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/billing/usage.py +0 -0
  55. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/core/__init__.py +0 -0
  56. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/discovery/__init__.py +0 -0
  57. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/discovery/code_quality.py +0 -0
  58. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/discovery/error_monitor.py +0 -0
  59. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/discovery/test_coverage.py +0 -0
  60. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/executor/__init__.py +0 -0
  61. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/executor/base.py +0 -0
  62. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/executor/claude_wrapper.py +0 -0
  63. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/executor/structured_request.py +0 -0
  64. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/integrations/__init__.py +0 -0
  65. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/integrations/github.py +0 -0
  66. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/learning/__init__.py +0 -0
  67. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/learning/adaptive_scheduler.py +0 -0
  68. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/learning/feedback_processor.py +0 -0
  69. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/mcp/server.py +0 -0
  70. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/orchestration/__init__.py +0 -0
  71. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/orchestration/agent_router.py +0 -0
  72. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/orchestration/task_orchestrator.py +0 -0
  73. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/profiles/__init__.py +0 -0
  74. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/profiles/base.py +0 -0
  75. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/profiles/default.py +0 -0
  76. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/quality_gates/__init__.py +0 -0
  77. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/quality_gates/coordinator.py +0 -0
  78. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/quality_gates/diff_validator.py +0 -0
  79. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/quality_gates/evidence.py +0 -0
  80. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/quality_gates/failure_handler.py +0 -0
  81. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/quality_gates/functional_verifier.py +0 -0
  82. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/quality_gates/preflight_checks.py +0 -0
  83. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/quality_gates/success_criteria.py +0 -0
  84. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/quality_gates/test_validator.py +0 -0
  85. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/quality_gates/truth_enforcer.py +0 -0
  86. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/storage/task_type_manager.py +0 -0
  87. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/storage/work_queue.py +0 -0
  88. {sugarai-3.1.1.dev4/sugar/storage → sugarai-3.3.1/sugar/utils}/__init__.py +0 -0
  89. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/utils/git_operations.py +0 -0
  90. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/utils/toon_encoder.py +0 -0
  91. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/workflow/__init__.py +0 -0
  92. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugar/workflow/orchestrator.py +0 -0
  93. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugarai.egg-info/dependency_links.txt +0 -0
  94. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugarai.egg-info/entry_points.txt +0 -0
  95. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/sugarai.egg-info/top_level.txt +0 -0
  96. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/tests/test_billing.py +0 -0
  97. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/tests/test_hold_functionality.py +0 -0
  98. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/tests/test_hooks.py +0 -0
  99. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/tests/test_orchestration.py +0 -0
  100. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/tests/test_profiles.py +0 -0
  101. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/tests/test_quality_gates.py +0 -0
  102. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/tests/test_storage.py +0 -0
  103. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/tests/test_task_types.py +0 -0
  104. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/tests/test_toon_encoder.py +0 -0
  105. {sugarai-3.1.1.dev4 → sugarai-3.3.1}/tests/test_v3_benchmarks.py +0 -0
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sugarai
3
- Version: 3.1.1.dev4
4
- Summary: Sugar 🍰 - A dev team that never stops. Delegate full tasks to AI in the background.
3
+ Version: 3.3.1
4
+ Summary: Sugar 🍰 - Vibe coding while you sleep. Autonomous AI development for Claude Code.
5
5
  Author-email: Steven Leggett <contact@roboticforce.io>
6
6
  License: MIT
7
7
  Project-URL: Homepage, https://github.com/roboticforce/sugar
@@ -50,13 +50,17 @@ Provides-Extra: test
50
50
  Requires-Dist: pytest>=7.0.0; extra == "test"
51
51
  Requires-Dist: pytest-asyncio>=0.21.0; extra == "test"
52
52
  Requires-Dist: pytest-cov>=4.0.0; extra == "test"
53
+ Provides-Extra: mcp
54
+ Requires-Dist: mcp>=1.0.0; extra == "mcp"
55
+ Requires-Dist: starlette>=0.27.0; extra == "mcp"
56
+ Requires-Dist: uvicorn>=0.22.0; extra == "mcp"
53
57
  Dynamic: license-file
54
58
 
55
59
  # Sugar 🍰
56
60
 
57
- A dev team that never stops.
61
+ Vibe coding while you sleep.
58
62
 
59
- Delegate full tasks to AI in the background. Sugar builds features, fixes bugs, and ships code while you focus on what matters.
63
+ Autonomous AI development for Claude Code. Sugar builds features, fixes bugs, and ships code while you focus on what matters.
60
64
 
61
65
  ## What It Does
62
66
 
@@ -208,6 +212,108 @@ sugar list --status completed
208
212
  - Confidence-based auto-posting
209
213
  - Searchable issue history
210
214
 
215
+ **Ralph Wiggum Integration** *(New)*
216
+ - Iterative execution for complex tasks
217
+ - Self-correcting loops until tests pass
218
+ - Prevents single-shot failures
219
+ - Automatic completion detection
220
+
221
+ ## Ralph Wiggum: Why Sugar Gets It Right
222
+
223
+ Here's the thing about AI coding: **single-shot attempts often fail on complex tasks**.
224
+
225
+ Ask Claude to implement a feature in one go, and you might get something that's 80% right. But that 20% means broken tests, edge cases missed, or subtle bugs. You end up going back and forth, manually iterating until it works.
226
+
227
+ **Ralph Wiggum fixes this by design.**
228
+
229
+ Instead of trying to complete a task perfectly the first time, Sugar can feed the same prompt repeatedly. Each iteration:
230
+
231
+ 1. Claude sees its previous work in the files
232
+ 2. Runs tests and sees what's failing
233
+ 3. Fixes issues and improves the implementation
234
+ 4. Repeats until the task is actually complete
235
+
236
+ ```bash
237
+ # Without Ralph (traditional single-shot):
238
+ sugar add "Implement rate limiting"
239
+ # Claude attempts once, maybe tests fail, task marked "done" anyway
240
+
241
+ # With Ralph (iterative):
242
+ sugar add "Implement rate limiting" --ralph --max-iterations 10
243
+ # Claude iterates: implement → test → fix → test → fix → done
244
+ # Only marked complete when tests actually pass
245
+ ```
246
+
247
+ **Think of it like code review cycles**, but automated. Junior dev writes code, tests fail, they fix it, tests pass, PR merged. Ralph does this loop automatically.
248
+
249
+ ### When to Use Ralph
250
+
251
+ | Task Type | Without Ralph | With Ralph |
252
+ |-----------|---------------|------------|
253
+ | Simple bug fix | Works fine | Overkill |
254
+ | New feature | Hit or miss | Iterates until working |
255
+ | Complex refactor | Often breaks things | Self-corrects |
256
+ | TDD implementation | Tests often fail | Keeps going until green |
257
+ | Flaky test debugging | Might give up | Tries multiple approaches |
258
+
259
+ ### How It Works
260
+
261
+ ```
262
+ Iteration 1: "Implement rate limiting"
263
+ → Creates RateLimiter class
264
+ → Tests: 2 passing, 3 failing
265
+
266
+ Iteration 2: Same prompt, sees previous work
267
+ → Fixes failing tests
268
+ → Tests: 4 passing, 1 failing
269
+
270
+ Iteration 3: Same prompt, sees more progress
271
+ → Handles edge case
272
+ → Tests: 5 passing, 0 failing
273
+ → Outputs: <promise>DONE</promise>
274
+ → Task complete!
275
+ ```
276
+
277
+ The `<promise>` tag is how Claude signals "I'm actually done." Without it, Ralph knows to keep iterating.
278
+
279
+ ### Setup
280
+
281
+ **Ralph is built into Sugar** - no separate installation required. Just enable it in your config:
282
+
283
+ ```yaml
284
+ # .sugar/config.yaml
285
+ sugar:
286
+ ralph:
287
+ enabled: true
288
+ max_iterations: 10
289
+ require_completion_criteria: true
290
+ ```
291
+
292
+ Or use the `--ralph` flag when adding tasks:
293
+
294
+ ```bash
295
+ sugar add "Complex feature" --ralph --max-iterations 15
296
+ ```
297
+
298
+ ### Safety First
299
+
300
+ Ralph won't run forever. You must include:
301
+ - A `<promise>` tag in your prompt (completion signal)
302
+ - OR `--max-iterations` flag (safety limit)
303
+
304
+ Sugar validates this BEFORE starting. No completion criteria = task rejected.
305
+
306
+ ### Interactive Use (Claude Code)
307
+
308
+ For interactive Ralph loops in Claude Code sessions (outside of Sugar), install the Ralph Wiggum plugin:
309
+
310
+ ```bash
311
+ # If you have the toolkit installed:
312
+ /ralph-wiggum:ralph-loop "Fix the flaky tests" --max-iterations 10
313
+ ```
314
+
315
+ **Full docs:** [docs/ralph-wiggum.md](docs/ralph-wiggum.md)
316
+
211
317
  ## Issue Responder
212
318
 
213
319
  Automatically analyze and respond to GitHub issues with AI-powered insights. Sugar understands issue context, codebase structure, and project patterns to generate helpful responses.
@@ -228,6 +334,16 @@ sugar issue respond 42 --post
228
334
 
229
335
  The Issue Responder evaluates confidence before posting. Use `--force-post` to override the confidence check, or adjust the threshold with `--confidence-threshold`.
230
336
 
337
+ **Custom Prompts:** Customize Sugar's responses per-project by creating `.sugar/prompts/issue_responder.json`:
338
+
339
+ ```json
340
+ {
341
+ "instructions": "You are a helpful assistant for MyProject. Be friendly and professional.",
342
+ "guidelines": ["Always search the codebase first", "Include file paths"],
343
+ "constraints": ["Never share API keys", "Don't promise release dates"]
344
+ }
345
+ ```
346
+
231
347
  **Full documentation:** [docs/issue-responder.md](docs/issue-responder.md)
232
348
 
233
349
  ## How It Works
@@ -1,8 +1,8 @@
1
1
  # Sugar 🍰
2
2
 
3
- A dev team that never stops.
3
+ Vibe coding while you sleep.
4
4
 
5
- Delegate full tasks to AI in the background. Sugar builds features, fixes bugs, and ships code while you focus on what matters.
5
+ Autonomous AI development for Claude Code. Sugar builds features, fixes bugs, and ships code while you focus on what matters.
6
6
 
7
7
  ## What It Does
8
8
 
@@ -154,6 +154,108 @@ sugar list --status completed
154
154
  - Confidence-based auto-posting
155
155
  - Searchable issue history
156
156
 
157
+ **Ralph Wiggum Integration** *(New)*
158
+ - Iterative execution for complex tasks
159
+ - Self-correcting loops until tests pass
160
+ - Prevents single-shot failures
161
+ - Automatic completion detection
162
+
163
+ ## Ralph Wiggum: Why Sugar Gets It Right
164
+
165
+ Here's the thing about AI coding: **single-shot attempts often fail on complex tasks**.
166
+
167
+ Ask Claude to implement a feature in one go, and you might get something that's 80% right. But that 20% means broken tests, edge cases missed, or subtle bugs. You end up going back and forth, manually iterating until it works.
168
+
169
+ **Ralph Wiggum fixes this by design.**
170
+
171
+ Instead of trying to complete a task perfectly the first time, Sugar can feed the same prompt repeatedly. Each iteration:
172
+
173
+ 1. Claude sees its previous work in the files
174
+ 2. Runs tests and sees what's failing
175
+ 3. Fixes issues and improves the implementation
176
+ 4. Repeats until the task is actually complete
177
+
178
+ ```bash
179
+ # Without Ralph (traditional single-shot):
180
+ sugar add "Implement rate limiting"
181
+ # Claude attempts once, maybe tests fail, task marked "done" anyway
182
+
183
+ # With Ralph (iterative):
184
+ sugar add "Implement rate limiting" --ralph --max-iterations 10
185
+ # Claude iterates: implement → test → fix → test → fix → done
186
+ # Only marked complete when tests actually pass
187
+ ```
188
+
189
+ **Think of it like code review cycles**, but automated. Junior dev writes code, tests fail, they fix it, tests pass, PR merged. Ralph does this loop automatically.
190
+
191
+ ### When to Use Ralph
192
+
193
+ | Task Type | Without Ralph | With Ralph |
194
+ |-----------|---------------|------------|
195
+ | Simple bug fix | Works fine | Overkill |
196
+ | New feature | Hit or miss | Iterates until working |
197
+ | Complex refactor | Often breaks things | Self-corrects |
198
+ | TDD implementation | Tests often fail | Keeps going until green |
199
+ | Flaky test debugging | Might give up | Tries multiple approaches |
200
+
201
+ ### How It Works
202
+
203
+ ```
204
+ Iteration 1: "Implement rate limiting"
205
+ → Creates RateLimiter class
206
+ → Tests: 2 passing, 3 failing
207
+
208
+ Iteration 2: Same prompt, sees previous work
209
+ → Fixes failing tests
210
+ → Tests: 4 passing, 1 failing
211
+
212
+ Iteration 3: Same prompt, sees more progress
213
+ → Handles edge case
214
+ → Tests: 5 passing, 0 failing
215
+ → Outputs: <promise>DONE</promise>
216
+ → Task complete!
217
+ ```
218
+
219
+ The `<promise>` tag is how Claude signals "I'm actually done." Without it, Ralph knows to keep iterating.
220
+
221
+ ### Setup
222
+
223
+ **Ralph is built into Sugar** - no separate installation required. Just enable it in your config:
224
+
225
+ ```yaml
226
+ # .sugar/config.yaml
227
+ sugar:
228
+ ralph:
229
+ enabled: true
230
+ max_iterations: 10
231
+ require_completion_criteria: true
232
+ ```
233
+
234
+ Or use the `--ralph` flag when adding tasks:
235
+
236
+ ```bash
237
+ sugar add "Complex feature" --ralph --max-iterations 15
238
+ ```
239
+
240
+ ### Safety First
241
+
242
+ Ralph won't run forever. You must include:
243
+ - A `<promise>` tag in your prompt (completion signal)
244
+ - OR `--max-iterations` flag (safety limit)
245
+
246
+ Sugar validates this BEFORE starting. No completion criteria = task rejected.
247
+
248
+ ### Interactive Use (Claude Code)
249
+
250
+ For interactive Ralph loops in Claude Code sessions (outside of Sugar), install the Ralph Wiggum plugin:
251
+
252
+ ```bash
253
+ # If you have the toolkit installed:
254
+ /ralph-wiggum:ralph-loop "Fix the flaky tests" --max-iterations 10
255
+ ```
256
+
257
+ **Full docs:** [docs/ralph-wiggum.md](docs/ralph-wiggum.md)
258
+
157
259
  ## Issue Responder
158
260
 
159
261
  Automatically analyze and respond to GitHub issues with AI-powered insights. Sugar understands issue context, codebase structure, and project patterns to generate helpful responses.
@@ -174,6 +276,16 @@ sugar issue respond 42 --post
174
276
 
175
277
  The Issue Responder evaluates confidence before posting. Use `--force-post` to override the confidence check, or adjust the threshold with `--confidence-threshold`.
176
278
 
279
+ **Custom Prompts:** Customize Sugar's responses per-project by creating `.sugar/prompts/issue_responder.json`:
280
+
281
+ ```json
282
+ {
283
+ "instructions": "You are a helpful assistant for MyProject. Be friendly and professional.",
284
+ "guidelines": ["Always search the codebase first", "Include file paths"],
285
+ "constraints": ["Never share API keys", "Don't promise release dates"]
286
+ }
287
+ ```
288
+
177
289
  **Full documentation:** [docs/issue-responder.md](docs/issue-responder.md)
178
290
 
179
291
  ## How It Works
@@ -4,8 +4,8 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "sugarai"
7
- version = "3.1.1.dev4"
8
- description = "Sugar 🍰 - A dev team that never stops. Delegate full tasks to AI in the background."
7
+ version = "3.3.1"
8
+ description = "Sugar 🍰 - Vibe coding while you sleep. Autonomous AI development for Claude Code."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
11
11
  license = {text = "MIT"}
@@ -59,6 +59,11 @@ test = [
59
59
  "pytest-asyncio>=0.21.0",
60
60
  "pytest-cov>=4.0.0"
61
61
  ]
62
+ mcp = [
63
+ "mcp>=1.0.0",
64
+ "starlette>=0.27.0",
65
+ "uvicorn>=0.22.0",
66
+ ]
62
67
 
63
68
  [project.scripts]
64
69
  sugar = "sugar.main:cli"
@@ -134,8 +134,8 @@ class SugarAgentConfig:
134
134
  # Working directory
135
135
  working_directory: Optional[str] = None
136
136
 
137
- # Timeout for operations (seconds)
138
- timeout: int = 300
137
+ # Timeout for operations (seconds) - default 2 hours for complex tasks
138
+ timeout: int = 7200
139
139
 
140
140
  # Retry settings for transient errors
141
141
  max_retries: int = 3
@@ -299,60 +299,76 @@ Guidelines:
299
299
  files_modified = []
300
300
 
301
301
  # Use the SDK's query() function which returns an async generator
302
- async for message in query(prompt=prompt, options=options):
303
- # Handle different message types from the SDK
304
- # The SDK may return dicts or typed objects depending on version
305
- if SDK_HAS_TYPES and isinstance(message, AssistantMessage):
306
- # Typed SDK - iterate through content blocks
307
- for block in message.content:
308
- if isinstance(block, TextBlock):
309
- content_parts.append(block.text)
310
- elif isinstance(block, ToolUseBlock):
311
- tool_use = {
312
- "tool": block.name,
313
- "input": block.input,
314
- }
315
- tool_uses.append(tool_use)
316
-
317
- # Track file modifications
318
- if block.name in ("Write", "Edit"):
319
- file_path = block.input.get("file_path")
320
- if file_path and file_path not in files_modified:
321
- files_modified.append(file_path)
322
-
323
- elif isinstance(message, dict):
324
- # Dict-based SDK response
325
- msg_type = message.get("type", "")
326
-
327
- if msg_type == "assistant":
328
- # Process content blocks
329
- content = message.get("content", [])
330
- for block in content:
331
- block_type = block.get("type", "")
332
- if block_type == "text":
333
- content_parts.append(block.get("text", ""))
334
- elif block_type == "tool_use":
335
- tool_use = {
336
- "tool": block.get("name", ""),
337
- "input": block.get("input", {}),
338
- }
339
- tool_uses.append(tool_use)
340
-
341
- # Track file modifications
342
- tool_name = block.get("name", "")
343
- if tool_name in ("Write", "Edit"):
344
- file_path = block.get("input", {}).get("file_path")
345
- if file_path and file_path not in files_modified:
346
- files_modified.append(file_path)
347
-
348
- elif msg_type == "text":
349
- # Direct text message
350
- content_parts.append(message.get("text", ""))
351
-
352
- elif msg_type == "result":
353
- # Final result message
354
- if message.get("content"):
355
- content_parts.append(str(message.get("content", "")))
302
+ # Wrap with timeout to prevent hanging if generator doesn't signal completion
303
+ try:
304
+ async with asyncio.timeout(self.config.timeout):
305
+ async for message in query(prompt=prompt, options=options):
306
+ # Handle different message types from the SDK
307
+ # The SDK may return dicts or typed objects depending on version
308
+ if SDK_HAS_TYPES and isinstance(message, AssistantMessage):
309
+ # Typed SDK - iterate through content blocks
310
+ for block in message.content:
311
+ if isinstance(block, TextBlock):
312
+ content_parts.append(block.text)
313
+ elif isinstance(block, ToolUseBlock):
314
+ tool_use = {
315
+ "tool": block.name,
316
+ "input": block.input,
317
+ }
318
+ tool_uses.append(tool_use)
319
+
320
+ # Track file modifications
321
+ if block.name in ("Write", "Edit"):
322
+ file_path = block.input.get("file_path")
323
+ if file_path and file_path not in files_modified:
324
+ files_modified.append(file_path)
325
+
326
+ elif isinstance(message, dict):
327
+ # Dict-based SDK response
328
+ msg_type = message.get("type", "")
329
+
330
+ if msg_type == "assistant":
331
+ # Process content blocks
332
+ content = message.get("content", [])
333
+ for block in content:
334
+ block_type = block.get("type", "")
335
+ if block_type == "text":
336
+ content_parts.append(block.get("text", ""))
337
+ elif block_type == "tool_use":
338
+ tool_use = {
339
+ "tool": block.get("name", ""),
340
+ "input": block.get("input", {}),
341
+ }
342
+ tool_uses.append(tool_use)
343
+
344
+ # Track file modifications
345
+ tool_name = block.get("name", "")
346
+ if tool_name in ("Write", "Edit"):
347
+ file_path = block.get("input", {}).get(
348
+ "file_path"
349
+ )
350
+ if (
351
+ file_path
352
+ and file_path not in files_modified
353
+ ):
354
+ files_modified.append(file_path)
355
+
356
+ elif msg_type == "text":
357
+ # Direct text message
358
+ content_parts.append(message.get("text", ""))
359
+
360
+ elif msg_type == "result":
361
+ # Final result message
362
+ if message.get("content"):
363
+ content_parts.append(str(message.get("content", "")))
364
+
365
+ except asyncio.TimeoutError:
366
+ logger.warning(
367
+ f"Query timed out after {self.config.timeout}s. "
368
+ f"Returning partial results: {len(tool_uses)} tool uses, "
369
+ f"{len(files_modified)} files modified"
370
+ )
371
+ # Return partial results - the work done so far is still valid
356
372
 
357
373
  return content_parts, tool_uses, files_modified
358
374
 
@@ -0,0 +1,6 @@
1
+ """Sugar configuration loaders."""
2
+
3
+ from .issue_responder_config import IssueResponderConfig
4
+ from .prompt_config import PersonaConfig, PromptConfig
5
+
6
+ __all__ = ["IssueResponderConfig", "PersonaConfig", "PromptConfig"]
@@ -0,0 +1,143 @@
1
+ """Configuration loader for the Issue Responder feature."""
2
+
3
+ from dataclasses import dataclass, field
4
+ from typing import List, Optional
5
+ import yaml
6
+ from pathlib import Path
7
+
8
+
9
+ @dataclass
10
+ class IssueResponderConfig:
11
+ """Configuration for AI-powered automatic issue responses.
12
+
13
+ Attributes:
14
+ enabled: Enable automatic issue responses
15
+ auto_post_threshold: Minimum confidence score (0.0-1.0) to auto-post responses
16
+ max_response_length: Maximum characters per response
17
+ response_delay_seconds: Delay before posting (0 = immediate)
18
+ rate_limit_per_hour: Maximum responses per hour (0 = unlimited)
19
+ respond_to_labels: Only respond to issues with these labels (empty = all)
20
+ skip_labels: Never respond to issues with these labels
21
+ skip_bot_issues: Skip issues created by bots
22
+ handle_follow_ups: How to handle follow-up comments - "ignore" | "queue" | "auto"
23
+ model: Claude model to use for generating responses
24
+ """
25
+
26
+ enabled: bool = False
27
+ auto_post_threshold: float = 0.8
28
+ max_response_length: int = 2000
29
+ response_delay_seconds: int = 0
30
+ rate_limit_per_hour: int = 10
31
+ respond_to_labels: List[str] = field(default_factory=list)
32
+ skip_labels: List[str] = field(
33
+ default_factory=lambda: ["wontfix", "duplicate", "stale"]
34
+ )
35
+ skip_bot_issues: bool = True
36
+ handle_follow_ups: str = "ignore" # "ignore" | "queue" | "auto"
37
+ model: str = "claude-sonnet-4-20250514"
38
+
39
+ @classmethod
40
+ def from_dict(cls, data: dict) -> "IssueResponderConfig":
41
+ """Create IssueResponderConfig from a dictionary.
42
+
43
+ Args:
44
+ data: Dictionary containing configuration values
45
+
46
+ Returns:
47
+ IssueResponderConfig instance
48
+
49
+ Example:
50
+ >>> config_data = {
51
+ ... "enabled": True,
52
+ ... "auto_post_threshold": 0.9,
53
+ ... "respond_to_labels": ["question", "help-wanted"]
54
+ ... }
55
+ >>> config = IssueResponderConfig.from_dict(config_data)
56
+ """
57
+ # Filter to only include known fields
58
+ valid_fields = {f.name for f in cls.__dataclass_fields__.values()}
59
+ filtered_data = {k: v for k, v in data.items() if k in valid_fields}
60
+ return cls(**filtered_data)
61
+
62
+ @classmethod
63
+ def load_from_file(cls, config_path: str) -> "IssueResponderConfig":
64
+ """Load IssueResponderConfig from a YAML configuration file.
65
+
66
+ Args:
67
+ config_path: Path to the YAML configuration file
68
+
69
+ Returns:
70
+ IssueResponderConfig instance with values from the file
71
+
72
+ Raises:
73
+ FileNotFoundError: If the config file doesn't exist
74
+ KeyError: If the 'issue_responder' section is missing
75
+ yaml.YAMLError: If the YAML file is malformed
76
+
77
+ Example:
78
+ >>> config = IssueResponderConfig.load_from_file(".sugar/config.yaml")
79
+ """
80
+ config_file = Path(config_path)
81
+
82
+ if not config_file.exists():
83
+ raise FileNotFoundError(f"Configuration file not found: {config_path}")
84
+
85
+ with open(config_file, "r") as f:
86
+ config_data = yaml.safe_load(f)
87
+
88
+ # Navigate to the issue_responder section
89
+ if "sugar" not in config_data:
90
+ raise KeyError("Configuration file missing 'sugar' section")
91
+
92
+ if "issue_responder" not in config_data["sugar"]:
93
+ raise KeyError("Configuration file missing 'sugar.issue_responder' section")
94
+
95
+ issue_responder_data = config_data["sugar"]["issue_responder"]
96
+ return cls.from_dict(issue_responder_data)
97
+
98
+ def validate(self) -> List[str]:
99
+ """Validate configuration values and return list of errors.
100
+
101
+ Returns:
102
+ List of validation error messages (empty if valid)
103
+
104
+ Example:
105
+ >>> config = IssueResponderConfig(auto_post_threshold=1.5)
106
+ >>> errors = config.validate()
107
+ >>> if errors:
108
+ ... print("Invalid configuration:", errors)
109
+ """
110
+ errors = []
111
+
112
+ # Validate auto_post_threshold
113
+ if not 0.0 <= self.auto_post_threshold <= 1.0:
114
+ errors.append(
115
+ f"auto_post_threshold must be between 0.0 and 1.0, got {self.auto_post_threshold}"
116
+ )
117
+
118
+ # Validate max_response_length
119
+ if self.max_response_length <= 0:
120
+ errors.append(
121
+ f"max_response_length must be positive, got {self.max_response_length}"
122
+ )
123
+
124
+ # Validate response_delay_seconds
125
+ if self.response_delay_seconds < 0:
126
+ errors.append(
127
+ f"response_delay_seconds must be non-negative, got {self.response_delay_seconds}"
128
+ )
129
+
130
+ # Validate rate_limit_per_hour
131
+ if self.rate_limit_per_hour < 0:
132
+ errors.append(
133
+ f"rate_limit_per_hour must be non-negative, got {self.rate_limit_per_hour}"
134
+ )
135
+
136
+ # Validate handle_follow_ups
137
+ valid_follow_up_values = {"ignore", "queue", "auto"}
138
+ if self.handle_follow_ups not in valid_follow_up_values:
139
+ errors.append(
140
+ f"handle_follow_ups must be one of {valid_follow_up_values}, got '{self.handle_follow_ups}'"
141
+ )
142
+
143
+ return errors