dandy 3.0.0a4__tar.gz → 3.0.0a6__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 (249) hide show
  1. {dandy-3.0.0a4 → dandy-3.0.0a6}/PKG-INFO +9 -3
  2. {dandy-3.0.0a4 → dandy-3.0.0a6}/README.md +7 -1
  3. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/__init__.py +15 -5
  4. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/agent/agent.py +140 -16
  5. dandy-3.0.0a6/dandy/application/agent/attachments.py +173 -0
  6. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/agent/cli/cli_agent.py +12 -3
  7. dandy-3.0.0a6/dandy/application/agent/cli/environment.py +105 -0
  8. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/agent/cli/intelligence/bots/coding_bot.py +10 -10
  9. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/agent/cli/intelligence/bots/init_bot.py +1 -1
  10. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/agent/cli/intelligence/bots/session_naming_bot.py +2 -2
  11. dandy-3.0.0a6/dandy/application/agent/cli/intelligence/prompts/coding_prompts.py +70 -0
  12. dandy-3.0.0a6/dandy/application/agent/cli/intelligence/prompts/init_prompts.py +79 -0
  13. dandy-3.0.0a6/dandy/application/agent/cli/intelligence/prompts/narration_prompt.py +15 -0
  14. dandy-3.0.0a6/dandy/application/agent/cli/intelligence/prompts/path_prompt.py +9 -0
  15. dandy-3.0.0a6/dandy/application/agent/cli/intelligence/prompts/session_name_prompt.py +25 -0
  16. dandy-3.0.0a6/dandy/application/agent/cli/intelligence/prompts/tool_calling_prompt.py +17 -0
  17. dandy-3.0.0a6/dandy/application/agent/exceptions.py +9 -0
  18. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/agent/intelligence/tools/__init__.py +10 -1
  19. dandy-3.0.0a6/dandy/application/agent/intelligence/tools/clock/__init__.py +6 -0
  20. dandy-3.0.0a6/dandy/application/agent/intelligence/tools/clock/clock_tool.py +34 -0
  21. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/agent/intelligence/tools/command/command_tool.py +2 -1
  22. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/agent/intelligence/tools/file/edit_file_tool.py +1 -2
  23. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/agent/intelligence/tools/file/read_file_tool.py +1 -1
  24. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/agent/intelligence/tools/git/git_status_tool.py +4 -0
  25. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/agent/intelligence/tools/question/question_tool.py +11 -6
  26. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/agent/session.py +1 -12
  27. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/agent/session_store.py +44 -4
  28. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/bot/bot.py +3 -7
  29. dandy-3.0.0a6/dandy/application/bot/exceptions.py +5 -0
  30. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/decision/decision.py +26 -14
  31. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/diligence/second_pass/diligence.py +5 -5
  32. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/diligence/stop_word_removal/diligence.py +3 -6
  33. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/diligence/vowel_removal/diligence.py +2 -6
  34. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/llm/service.py +6 -5
  35. dandy-3.0.0a6/dandy/application/skill/loader.py +162 -0
  36. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/skill/service.py +6 -6
  37. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/skill/tools.py +5 -0
  38. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/tool/service.py +21 -16
  39. dandy-3.0.0a6/dandy/domain/decision/exceptions.py +17 -0
  40. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/domain/decision/prompts.py +6 -2
  41. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/domain/guard/__init__.py +2 -0
  42. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/domain/guard/context_guard.py +4 -0
  43. dandy-3.0.0a6/dandy/domain/guard/defaults.py +15 -0
  44. dandy-3.0.0a6/dandy/domain/guard/guard.py +241 -0
  45. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/domain/guard/repeat_guard.py +4 -0
  46. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/domain/intel/annotation.py +6 -4
  47. dandy-3.0.0a6/dandy/domain/intel/exceptions.py +5 -0
  48. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/domain/intel/factory.py +6 -4
  49. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/domain/intel/intel.py +30 -13
  50. dandy-3.0.0a6/dandy/domain/request/exceptions.py +9 -0
  51. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/domain/request/options.py +4 -4
  52. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/domain/request/prompts.py +7 -2
  53. dandy-3.0.0a6/dandy/domain/skill/exceptions.py +5 -0
  54. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/domain/skill/skill.py +4 -4
  55. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/domain/tool/beat.py +7 -3
  56. dandy-3.0.0a6/dandy/domain/tool/exceptions.py +5 -0
  57. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/domain/tool/tool.py +12 -4
  58. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/infrastructure/cache/decorators.py +3 -1
  59. dandy-3.0.0a6/dandy/infrastructure/cache/exceptions.py +5 -0
  60. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/infrastructure/cache/key.py +2 -2
  61. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/infrastructure/cache/sqlite/cache.py +13 -5
  62. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/infrastructure/cache/sqlite/connection.py +7 -1
  63. dandy-3.0.0a6/dandy/infrastructure/future/exceptions.py +9 -0
  64. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/infrastructure/future/future.py +9 -6
  65. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/infrastructure/http/connector.py +2 -2
  66. dandy-3.0.0a6/dandy/infrastructure/http/exceptions.py +5 -0
  67. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/infrastructure/llm/config.py +30 -12
  68. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/infrastructure/llm/connector.py +25 -17
  69. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/infrastructure/recorder/events.py +2 -1
  70. dandy-3.0.0a6/dandy/infrastructure/recorder/exceptions.py +5 -0
  71. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/infrastructure/recorder/recorder.py +4 -4
  72. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/infrastructure/recorder/recording.py +7 -7
  73. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/interfaces/cli/cli.py +162 -57
  74. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/interfaces/cli/commands.py +20 -4
  75. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/interfaces/cli/main.py +14 -13
  76. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/interfaces/cli/one_shot.py +13 -26
  77. dandy-3.0.0a6/dandy/interfaces/cli/thinking_phrases.py +230 -0
  78. dandy-3.0.0a6/dandy/interfaces/cli/tui/banner.py +137 -0
  79. dandy-3.0.0a6/dandy/interfaces/cli/tui/notify.py +144 -0
  80. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/interfaces/cli/tui/printer.py +38 -34
  81. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/interfaces/cli/tui/story_progress.py +158 -8
  82. dandy-3.0.0a6/dandy/interfaces/cli/tui/tui.py +487 -0
  83. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/interfaces/cli/usage.py +12 -4
  84. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/interfaces/cli/utils.py +13 -4
  85. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/shared/constants.py +3 -1
  86. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/shared/exceptions.py +13 -7
  87. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/shared/files.py +7 -7
  88. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/shared/interaction.py +20 -2
  89. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/shared/media.py +9 -9
  90. dandy-3.0.0a6/dandy/shared/notifications.py +46 -0
  91. dandy-3.0.0a6/dandy/shared/service/exceptions.py +5 -0
  92. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/shared/service/mixin.py +2 -2
  93. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/shared/settings/default_settings.py +7 -1
  94. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/shared/settings/load.py +39 -3
  95. dandy-3.0.0a6/dandy/shared/settings/settings.py +113 -0
  96. dandy-3.0.0a6/dandy/shared/typing/__init__.py +0 -0
  97. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/shared/typing/constants.py +0 -2
  98. dandy-3.0.0a6/dandy/shared/typing/exceptions.py +5 -0
  99. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/shared/typing/signature.py +4 -4
  100. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/shared/typing/typed_kwargs.py +6 -3
  101. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/shared/utils.py +0 -4
  102. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy.egg-info/PKG-INFO +9 -3
  103. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy.egg-info/SOURCES.txt +15 -2
  104. {dandy-3.0.0a4 → dandy-3.0.0a6}/pyproject.toml +4 -3
  105. {dandy-3.0.0a4 → dandy-3.0.0a6}/tests/test_dandy.py +4 -2
  106. dandy-3.0.0a4/dandy/application/agent/cli/intelligence/prompts.py +0 -183
  107. dandy-3.0.0a4/dandy/application/agent/exceptions.py +0 -9
  108. dandy-3.0.0a4/dandy/application/bot/exceptions.py +0 -9
  109. dandy-3.0.0a4/dandy/domain/decision/exceptions.py +0 -17
  110. dandy-3.0.0a4/dandy/domain/guard/guard.py +0 -136
  111. dandy-3.0.0a4/dandy/domain/intel/exceptions.py +0 -9
  112. dandy-3.0.0a4/dandy/domain/request/exceptions.py +0 -14
  113. dandy-3.0.0a4/dandy/domain/skill/exceptions.py +0 -5
  114. dandy-3.0.0a4/dandy/domain/tool/exceptions.py +0 -5
  115. dandy-3.0.0a4/dandy/infrastructure/cache/exceptions.py +0 -9
  116. dandy-3.0.0a4/dandy/infrastructure/future/exceptions.py +0 -9
  117. dandy-3.0.0a4/dandy/infrastructure/http/exceptions.py +0 -9
  118. dandy-3.0.0a4/dandy/infrastructure/recorder/exceptions.py +0 -9
  119. dandy-3.0.0a4/dandy/interfaces/cli/thinking_phrases.py +0 -315
  120. dandy-3.0.0a4/dandy/interfaces/cli/tui/banner.py +0 -56
  121. dandy-3.0.0a4/dandy/interfaces/cli/tui/tui.py +0 -226
  122. dandy-3.0.0a4/dandy/shared/connector/exceptions.py +0 -9
  123. dandy-3.0.0a4/dandy/shared/service/exceptions.py +0 -9
  124. dandy-3.0.0a4/dandy/shared/settings/settings.py +0 -88
  125. dandy-3.0.0a4/dandy/shared/typing/exceptions.py +0 -9
  126. {dandy-3.0.0a4 → dandy-3.0.0a6}/LICENSE.md +0 -0
  127. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/__init__.py +0 -0
  128. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/agent/__init__.py +0 -0
  129. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/agent/cli/__init__.py +0 -0
  130. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/agent/cli/agents_md.py +0 -0
  131. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/agent/cli/intelligence/__init__.py +0 -0
  132. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/agent/cli/intelligence/bots/__init__.py +0 -0
  133. {dandy-3.0.0a4/dandy/application/agent/intelligence → dandy-3.0.0a6/dandy/application/agent/cli/intelligence/prompts}/__init__.py +0 -0
  134. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/agent/intel.py +0 -0
  135. {dandy-3.0.0a4/dandy/application/bot → dandy-3.0.0a6/dandy/application/agent/intelligence}/__init__.py +0 -0
  136. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/agent/intelligence/tools/command/__init__.py +0 -0
  137. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/agent/intelligence/tools/file/__init__.py +0 -0
  138. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/agent/intelligence/tools/file/create_directory_tool.py +0 -0
  139. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/agent/intelligence/tools/file/delete_file_tool.py +0 -0
  140. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/agent/intelligence/tools/file/list_directory_tool.py +0 -0
  141. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/agent/intelligence/tools/file/search_tool.py +0 -0
  142. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/agent/intelligence/tools/file/write_file_tool.py +0 -0
  143. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/agent/intelligence/tools/git/__init__.py +0 -0
  144. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/agent/intelligence/tools/git/git_diff_tool.py +0 -0
  145. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/agent/intelligence/tools/paths.py +0 -0
  146. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/agent/intelligence/tools/question/__init__.py +0 -0
  147. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/agent/intelligence/tools/tool_errors.py +0 -0
  148. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/agent/prompts.py +0 -0
  149. {dandy-3.0.0a4/dandy/application/decision → dandy-3.0.0a6/dandy/application/bot}/__init__.py +0 -0
  150. {dandy-3.0.0a4/dandy/application/diligence → dandy-3.0.0a6/dandy/application/decision}/__init__.py +0 -0
  151. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/decision/mixin.py +0 -0
  152. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/decision/service.py +0 -0
  153. {dandy-3.0.0a4/dandy/application/diligence/second_pass → dandy-3.0.0a6/dandy/application/diligence}/__init__.py +0 -0
  154. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/diligence/diligence.py +0 -0
  155. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/diligence/handler.py +0 -0
  156. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/diligence/mixin.py +0 -0
  157. {dandy-3.0.0a4/dandy/application/diligence/stop_word_removal → dandy-3.0.0a6/dandy/application/diligence/second_pass}/__init__.py +0 -0
  158. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/diligence/service.py +0 -0
  159. {dandy-3.0.0a4/dandy/application/diligence/vowel_removal → dandy-3.0.0a6/dandy/application/diligence/stop_word_removal}/__init__.py +0 -0
  160. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/diligence/stop_word_removal/constants.py +0 -0
  161. {dandy-3.0.0a4/dandy/application/llm → dandy-3.0.0a6/dandy/application/diligence/vowel_removal}/__init__.py +0 -0
  162. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/diligence/vowel_removal/constants.py +0 -0
  163. {dandy-3.0.0a4/dandy/application/skill → dandy-3.0.0a6/dandy/application/llm}/__init__.py +0 -0
  164. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/llm/mixin.py +0 -0
  165. {dandy-3.0.0a4/dandy/application/tool → dandy-3.0.0a6/dandy/application/skill}/__init__.py +0 -0
  166. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/skill/mixin.py +0 -0
  167. {dandy-3.0.0a4/dandy/domain → dandy-3.0.0a6/dandy/application/tool}/__init__.py +0 -0
  168. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/application/tool/mixin.py +0 -0
  169. {dandy-3.0.0a4/dandy/domain/decision → dandy-3.0.0a6/dandy/domain}/__init__.py +0 -0
  170. {dandy-3.0.0a4/dandy/domain/intel → dandy-3.0.0a6/dandy/domain/decision}/__init__.py +0 -0
  171. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/domain/decision/intel.py +0 -0
  172. {dandy-3.0.0a4/dandy/domain/message → dandy-3.0.0a6/dandy/domain/intel}/__init__.py +0 -0
  173. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/domain/intel/mixin.py +0 -0
  174. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/domain/intel/service.py +0 -0
  175. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/domain/intel/typing.py +0 -0
  176. {dandy-3.0.0a4/dandy/domain/prompt → dandy-3.0.0a6/dandy/domain/message}/__init__.py +0 -0
  177. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/domain/message/compaction.py +0 -0
  178. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/domain/message/message.py +0 -0
  179. {dandy-3.0.0a4/dandy/domain/request → dandy-3.0.0a6/dandy/domain/prompt}/__init__.py +0 -0
  180. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/domain/prompt/prompt.py +0 -0
  181. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/domain/prompt/snippet.py +0 -0
  182. {dandy-3.0.0a4/dandy/domain/tokens → dandy-3.0.0a6/dandy/domain/request}/__init__.py +0 -0
  183. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/domain/request/request.py +0 -0
  184. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/domain/skill/__init__.py +0 -0
  185. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/domain/skill/prompts.py +0 -0
  186. {dandy-3.0.0a4/dandy/infrastructure → dandy-3.0.0a6/dandy/domain/tokens}/__init__.py +0 -0
  187. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/domain/tokens/estimate.py +0 -0
  188. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/domain/tool/__init__.py +0 -0
  189. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/domain/tool/intel.py +0 -0
  190. {dandy-3.0.0a4/dandy/infrastructure/cache → dandy-3.0.0a6/dandy/infrastructure}/__init__.py +0 -0
  191. {dandy-3.0.0a4/dandy/infrastructure/cache/memory → dandy-3.0.0a6/dandy/infrastructure/cache}/__init__.py +0 -0
  192. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/infrastructure/cache/cache.py +0 -0
  193. {dandy-3.0.0a4/dandy/infrastructure/cache/sqlite → dandy-3.0.0a6/dandy/infrastructure/cache/memory}/__init__.py +0 -0
  194. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/infrastructure/cache/memory/cache.py +0 -0
  195. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/infrastructure/cache/memory/decorators.py +0 -0
  196. {dandy-3.0.0a4/dandy/infrastructure/file → dandy-3.0.0a6/dandy/infrastructure/cache/sqlite}/__init__.py +0 -0
  197. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/infrastructure/cache/sqlite/decorators.py +0 -0
  198. {dandy-3.0.0a4/dandy/infrastructure/future → dandy-3.0.0a6/dandy/infrastructure/file}/__init__.py +0 -0
  199. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/infrastructure/file/mixin.py +0 -0
  200. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/infrastructure/file/service.py +0 -0
  201. {dandy-3.0.0a4/dandy/infrastructure/http → dandy-3.0.0a6/dandy/infrastructure/future}/__init__.py +0 -0
  202. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/infrastructure/future/process.py +0 -0
  203. {dandy-3.0.0a4/dandy/infrastructure/llm → dandy-3.0.0a6/dandy/infrastructure/http}/__init__.py +0 -0
  204. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/infrastructure/http/intel.py +0 -0
  205. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/infrastructure/http/mixin.py +0 -0
  206. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/infrastructure/http/service.py +0 -0
  207. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/infrastructure/http/url.py +0 -0
  208. {dandy-3.0.0a4/dandy/infrastructure/recorder → dandy-3.0.0a6/dandy/infrastructure/llm}/__init__.py +0 -0
  209. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/infrastructure/llm/fenced_json.py +0 -0
  210. {dandy-3.0.0a4/dandy/infrastructure/recorder/renderer → dandy-3.0.0a6/dandy/infrastructure/recorder}/__init__.py +0 -0
  211. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/infrastructure/recorder/bot_events.py +0 -0
  212. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/infrastructure/recorder/decision_events.py +0 -0
  213. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/infrastructure/recorder/decorators.py +0 -0
  214. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/infrastructure/recorder/diligence_events.py +0 -0
  215. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/infrastructure/recorder/llm_events.py +0 -0
  216. {dandy-3.0.0a4/dandy/interfaces → dandy-3.0.0a6/dandy/infrastructure/recorder/renderer}/__init__.py +0 -0
  217. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/infrastructure/recorder/renderer/html.py +0 -0
  218. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/infrastructure/recorder/renderer/html_templates/base_event_template.html +0 -0
  219. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/infrastructure/recorder/renderer/html_templates/base_recording_output_template.html +0 -0
  220. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/infrastructure/recorder/renderer/json.py +0 -0
  221. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/infrastructure/recorder/renderer/markdown.py +0 -0
  222. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/infrastructure/recorder/renderer/renderer.py +0 -0
  223. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/infrastructure/recorder/tool_events.py +0 -0
  224. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/infrastructure/recorder/utils.py +0 -0
  225. {dandy-3.0.0a4/dandy/interfaces/cli → dandy-3.0.0a6/dandy/interfaces}/__init__.py +0 -0
  226. {dandy-3.0.0a4/dandy/interfaces/cli/tui → dandy-3.0.0a6/dandy/interfaces/cli}/__init__.py +0 -0
  227. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/interfaces/cli/error_log.py +0 -0
  228. {dandy-3.0.0a4/dandy/shared → dandy-3.0.0a6/dandy/interfaces/cli/tui}/__init__.py +0 -0
  229. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/interfaces/cli/tui/ascii.py +0 -0
  230. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/interfaces/cli/tui/markdown.py +0 -0
  231. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/interfaces/cli/tui/text.py +0 -0
  232. {dandy-3.0.0a4/dandy/shared/connector → dandy-3.0.0a6/dandy/shared}/__init__.py +0 -0
  233. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/shared/cancellation.py +0 -0
  234. {dandy-3.0.0a4/dandy/shared/service → dandy-3.0.0a6/dandy/shared/connector}/__init__.py +0 -0
  235. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/shared/connector/connector.py +0 -0
  236. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/shared/debug.py +0 -0
  237. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/shared/hashing.py +0 -0
  238. {dandy-3.0.0a4/dandy/shared/typing → dandy-3.0.0a6/dandy/shared/service}/__init__.py +0 -0
  239. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/shared/service/service.py +0 -0
  240. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/shared/settings/__init__.py +0 -0
  241. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/shared/singleton.py +0 -0
  242. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/shared/subprocess.py +0 -0
  243. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/shared/typing/registry.py +0 -0
  244. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy/shared/typing/typing.py +0 -0
  245. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy.egg-info/dependency_links.txt +0 -0
  246. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy.egg-info/entry_points.txt +0 -0
  247. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy.egg-info/requires.txt +0 -0
  248. {dandy-3.0.0a4 → dandy-3.0.0a6}/dandy.egg-info/top_level.txt +0 -0
  249. {dandy-3.0.0a4 → dandy-3.0.0a6}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dandy
3
- Version: 3.0.0a4
3
+ Version: 3.0.0a6
4
4
  Summary: Python Artificial Intelligence Framework
5
5
  Author-email: Nathan Johnson <nathanj@stratusadv.com>
6
6
  License-Expression: MIT
@@ -9,7 +9,7 @@ Project-URL: Documentation, https://dandysoftware.com
9
9
  Project-URL: Repository, https://github.com/stratusadv/dandy
10
10
  Project-URL: Changelog, https://dandysoftware.com/changelog/changelog/
11
11
  Keywords: dandy,ai,cli,llm,agent,prompt,gpt,bot,workflow,automation,artificial intelligence
12
- Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Development Status :: 4 - Beta
13
13
  Classifier: Operating System :: OS Independent
14
14
  Classifier: Programming Language :: Python :: 3
15
15
  Classifier: Programming Language :: Python :: 3.11
@@ -72,10 +72,16 @@ The `dandy` command runs the coding assistant against the current project. Run i
72
72
  ```bash
73
73
  dandy # start an interactive agentic loop
74
74
  dandy "fix the failing tests" # run one request, then exit
75
+ dandy -r "one more fix" # run one request inside the latest session
76
+ dandy -s my-session "resume me" # run one request inside a named session
77
+ dandy -n new-name # start a fresh, pre-named conversation
78
+ dandy --sessions # list saved sessions
79
+ dandy --init # create or refresh the project AGENTS.md
80
+ dandy -d old-session # delete a saved session
75
81
  dandy -h # show usage
76
82
  ```
77
83
 
78
- Inside the interactive session every message goes to the coding agent. `/clear` resets the conversation, and pressing `escape` twice (or `/quit`) exits the loop. Use the one-shot form when you only want a single answer without entering the REPL.
84
+ Inside the interactive session every message goes to the coding agent. `/new` (or `/n`) starts a fresh conversation, `/sessions` (or `/s`) lists or resumes saved sessions, and pressing `escape` twice (or `/quit`) exits the loop. Use the one-shot form when you only want a single answer without entering the REPL.
79
85
 
80
86
  The CLI's model is set with `CLI_CONFIG` in `dandy_settings.py`, e.g. `CLI_CONFIG = {'CODING': 'DEFAULT'}` points the coding agent at the `DEFAULT` entry in `LLM_CONFIGS`.
81
87
 
@@ -28,10 +28,16 @@ The `dandy` command runs the coding assistant against the current project. Run i
28
28
  ```bash
29
29
  dandy # start an interactive agentic loop
30
30
  dandy "fix the failing tests" # run one request, then exit
31
+ dandy -r "one more fix" # run one request inside the latest session
32
+ dandy -s my-session "resume me" # run one request inside a named session
33
+ dandy -n new-name # start a fresh, pre-named conversation
34
+ dandy --sessions # list saved sessions
35
+ dandy --init # create or refresh the project AGENTS.md
36
+ dandy -d old-session # delete a saved session
31
37
  dandy -h # show usage
32
38
  ```
33
39
 
34
- Inside the interactive session every message goes to the coding agent. `/clear` resets the conversation, and pressing `escape` twice (or `/quit`) exits the loop. Use the one-shot form when you only want a single answer without entering the REPL.
40
+ Inside the interactive session every message goes to the coding agent. `/new` (or `/n`) starts a fresh conversation, `/sessions` (or `/s`) lists or resumes saved sessions, and pressing `escape` twice (or `/quit`) exits the loop. Use the one-shot form when you only want a single answer without entering the REPL.
35
41
 
36
42
  The CLI's model is set with `CLI_CONFIG` in `dandy_settings.py`, e.g. `CLI_CONFIG = {'CODING': 'DEFAULT'}` points the coding agent at the `DEFAULT` entry in `LLM_CONFIGS`.
37
43
 
@@ -6,7 +6,13 @@ from dandy.infrastructure.cache.memory.decorators import cache_to_memory
6
6
  from dandy.infrastructure.cache.sqlite.cache import SqliteCache
7
7
  from dandy.infrastructure.cache.sqlite.decorators import cache_to_sqlite
8
8
  from dandy.infrastructure.cache.key import generate_cache_key
9
- from dandy.shared.exceptions import DandyCriticalError, DandyError, DandyRecoverableError
9
+ from dandy.shared.exceptions import (
10
+ DandyConfigurationError,
11
+ DandyError,
12
+ DandyExternalError,
13
+ DandyFlowError,
14
+ DandyUsageError,
15
+ )
10
16
  from dandy.shared.hashing import HashMixin
11
17
  from dandy.infrastructure.future.process import process_to_future
12
18
  from dandy.domain.intel.intel import BaseIntel, BaseListIntel, DefaultIntel
@@ -31,9 +37,11 @@ __all__ = [
31
37
  'BaseTool',
32
38
  'Bot',
33
39
  'Dandy',
34
- 'DandyCriticalError',
40
+ 'DandyConfigurationError',
35
41
  'DandyError',
36
- 'DandyRecoverableError',
42
+ 'DandyExternalError',
43
+ 'DandyFlowError',
44
+ 'DandyUsageError',
37
45
  'Decision',
38
46
  'DefaultIntel',
39
47
  'HashMixin',
@@ -70,9 +78,11 @@ class Dandy:
70
78
  BaseSkill = BaseSkill
71
79
  BaseTool = BaseTool
72
80
  Bot = Bot
73
- DandyCriticalError = DandyCriticalError
81
+ DandyConfigurationError = DandyConfigurationError
74
82
  DandyError = DandyError
75
- DandyRecoverableError = DandyRecoverableError
83
+ DandyExternalError = DandyExternalError
84
+ DandyFlowError = DandyFlowError
85
+ DandyUsageError = DandyUsageError
76
86
  Decision = Decision
77
87
  DefaultIntel = DefaultIntel
78
88
  HashMixin = HashMixin
@@ -1,14 +1,21 @@
1
1
  from __future__ import annotations
2
2
 
3
- from typing import TYPE_CHECKING, Callable
3
+ from typing import TYPE_CHECKING, Callable, Sequence
4
4
 
5
5
  from pydantic import ValidationError
6
6
 
7
- from dandy.application.agent.exceptions import AgentCriticalError, AgentRecoverableError
7
+ from dandy.application.agent.attachments import (
8
+ ATTACHMENT_KIND_AUDIO,
9
+ ATTACHMENT_KIND_IMAGE,
10
+ TurnAttachment,
11
+ attachments_token_count,
12
+ )
13
+ from dandy.application.agent.exceptions import AgentUsageError, AgentExternalError
8
14
  from dandy.application.agent.intel import AgentSession, AgentTurnIntel
9
15
  from dandy.application.agent.prompts import continuation_prompt
10
16
  from dandy.shared.cancellation import stop_signal
11
17
  from dandy.shared.exceptions import RUN_STOPPED_MESSAGE, RunStoppedError
18
+ from dandy.domain.guard.guard import GuardChain
12
19
  from dandy.domain.message.compaction import (
13
20
  COMPACTION_TARGET_RATIO,
14
21
  COMPACTION_TRIGGER_RATIO,
@@ -18,6 +25,7 @@ from dandy.domain.message.compaction import (
18
25
  )
19
26
  from dandy.domain.message.message import MessageHistory
20
27
  from dandy.domain.prompt.prompt import Prompt
28
+ from dandy.domain.request.exceptions import LlmExternalError
21
29
  from dandy.domain.skill.skill import to_skill_instances
22
30
  from dandy.domain.tokens.estimate import get_estimated_token_count_for_string
23
31
  from dandy.domain.tool.beat import StoryBeat
@@ -25,6 +33,7 @@ from dandy.domain.tool.beat import StoryBeat
25
33
  if TYPE_CHECKING:
26
34
  from dandy.application.bot.bot import Bot
27
35
  from dandy.application.llm.service import LlmService
36
+ from dandy.domain.guard.guard import Guard
28
37
  from dandy.domain.intel.typing import IntelType
29
38
  from dandy.domain.skill.skill import SkillType
30
39
  from dandy.domain.tool.tool import ToolType
@@ -35,7 +44,7 @@ if TYPE_CHECKING:
35
44
  # reproduce-then-fix-then-verify workflow while still bounding a model stuck
36
45
  # in a degenerate tool-call loop. Pass max_tool_rounds=None to a specific
37
46
  # Agent to disable the cap.
38
- AGENT_MAX_TOOL_ROUNDS_DEFAULT = 200
47
+ AGENT_MAX_TOOL_ROUNDS_DEFAULT = None
39
48
 
40
49
 
41
50
  class Agent:
@@ -55,6 +64,7 @@ class Agent:
55
64
  max_turns: int | None = None,
56
65
  max_tool_rounds: int | None = AGENT_MAX_TOOL_ROUNDS_DEFAULT,
57
66
  intel_class: type[IntelType] | None = None,
67
+ guards: Sequence[Guard] | None = None,
58
68
  ) -> None:
59
69
  self.bot = bot
60
70
  self.tools = tools
@@ -62,9 +72,13 @@ class Agent:
62
72
  self.max_turns = max_turns
63
73
  self.max_tool_rounds = max_tool_rounds
64
74
  self.intel_class = intel_class or AgentTurnIntel
75
+ self.guards = list(guards) if guards is not None else None
65
76
  self.history = MessageHistory()
66
77
  self.max_context_tokens = self._resolve_context_size()
67
78
  self.last_request: str | None = None
79
+ self._guard_chain = GuardChain(self.guards or [])
80
+ self._turn_count = 0
81
+ self._pending_turn_note: str | None = None
68
82
 
69
83
  if self.skills:
70
84
  self.bot.llm.skills.register(self.skills)
@@ -85,24 +99,41 @@ class Agent:
85
99
  progress_callback: Callable[[StoryBeat], None] | None = None,
86
100
  verbose_callback: Callable[[str], None] | None = None,
87
101
  tool_call_callback: Callable[[str, dict[str, object]], None] | None = None,
102
+ attachments: list[TurnAttachment] | None = None,
88
103
  ) -> IntelType:
89
104
  """Run one exchange: prepare, compact, work through any tool rounds, return the answer.
90
105
 
91
106
  The conversation accumulates in ``self.history`` across turns. When
92
107
  ``tool_call_callback`` is given, it is called once per executed tool
93
- call with the tool name and its validated keyword arguments.
108
+ call with the tool name and its validated keyword arguments. The
109
+ agent's guards (when given) watch the turn boundaries: a turn-start
110
+ failure stops the turn before any LLM spend, and a combined
111
+ turn-end ``note`` is appended to the next ``run()`` continuation.
112
+ ``attachments`` join the incoming message: image and audio
113
+ attachments become native content parts on the same user message,
114
+ and project-file attachments are named in the message text for the
115
+ agent to read with its tools.
94
116
  """
95
117
  if stop_signal.is_set():
96
118
  raise RunStoppedError(RUN_STOPPED_MESSAGE)
97
119
 
120
+ self._turn_count += 1
98
121
  self.last_request = self._message_as_str(message)
99
122
  self.max_context_tokens = self._resolve_context_size()
100
123
  message = self._prepare_message(message, progress_callback, verbose_callback)
124
+ self._watch_turn_start(message, verbose_callback)
101
125
  self._compact_history_for_next_message(message, progress_callback)
102
- self._ensure_history_fits(message)
126
+ self._ensure_history_fits(message, attachments)
127
+
128
+ prompt = message
129
+ attachments = attachments or []
103
130
 
104
- return self.bot.llm.tools.prompt_to_intel(
105
- prompt=message,
131
+ if attachments:
132
+ self._append_attachment_message(message, attachments)
133
+ prompt = None
134
+
135
+ result = self.bot.llm.tools.prompt_to_intel(
136
+ prompt=prompt,
106
137
  tools=self.tools,
107
138
  intel_class=self.intel_class,
108
139
  message_history=self.history,
@@ -111,8 +142,13 @@ class Agent:
111
142
  verbose_callback=verbose_callback,
112
143
  tool_call_callback=tool_call_callback,
113
144
  max_tool_iterations=self.max_tool_rounds,
145
+ guards=self.guards,
114
146
  )
115
147
 
148
+ self._watch_turn_end(result, verbose_callback)
149
+
150
+ return result
151
+
116
152
  def _prepare_message(
117
153
  self,
118
154
  message: Prompt | str | None,
@@ -122,7 +158,84 @@ class Agent:
122
158
  """Subclass hook to shape the incoming message before it goes to the bot."""
123
159
  return message
124
160
 
125
- def _ensure_history_fits(self, message: Prompt | str | None) -> None:
161
+ def _append_attachment_message(
162
+ self, message: Prompt | str | None, attachments: list[TurnAttachment]
163
+ ) -> None:
164
+ """Add the incoming message to the history together with its attachments.
165
+
166
+ Image and audio attachments join the message as native content parts
167
+ on the same user message (the LLM sees them as one turn of input);
168
+ project-file attachments are already copied into the project and are
169
+ named in the message text so the agent reads them with its tools.
170
+ """
171
+ text = self._message_as_str(message) or ''
172
+ image_file_paths = [
173
+ attachment.source_path
174
+ for attachment in attachments
175
+ if attachment.kind == ATTACHMENT_KIND_IMAGE
176
+ ]
177
+ audio_file_paths = [
178
+ attachment.source_path
179
+ for attachment in attachments
180
+ if attachment.kind == ATTACHMENT_KIND_AUDIO
181
+ ]
182
+
183
+ for attachment in attachments:
184
+ if attachment.kind == 'project_file' and attachment.delivery_path:
185
+ text = f'{text}\nRead the attached file at {attachment.delivery_path}.'
186
+
187
+ self.history.add_message(
188
+ role='user',
189
+ text=text or None,
190
+ image_file_paths=image_file_paths,
191
+ audio_file_paths=audio_file_paths,
192
+ )
193
+
194
+ def _watch_turn_start(
195
+ self, message: Prompt | str | None, verbose_callback: Callable[[str], None] | None
196
+ ) -> None:
197
+ """Run the turn-start guards; a failure stops the turn before any LLM spend."""
198
+ try:
199
+ self._guard_chain.on_turn_start(
200
+ turn_number=self._turn_count,
201
+ message=message,
202
+ history_token_count=self.history.estimated_token_count,
203
+ context_window=self.max_context_tokens,
204
+ verbose_callback=verbose_callback,
205
+ )
206
+ except LlmExternalError as error:
207
+ raise AgentExternalError(str(error)) from error
208
+
209
+ def _watch_turn_end(
210
+ self, result: IntelType, verbose_callback: Callable[[str], None] | None
211
+ ) -> None:
212
+ """Run the turn-end guards; a combined note steers the next run() continuation."""
213
+ try:
214
+ outcome = self._guard_chain.on_turn_end(
215
+ turn_number=self._turn_count,
216
+ result=result,
217
+ history_token_count=self.history.estimated_token_count,
218
+ context_window=self.max_context_tokens,
219
+ verbose_callback=verbose_callback,
220
+ )
221
+ except LlmExternalError as error:
222
+ raise AgentExternalError(str(error)) from error
223
+
224
+ if outcome.note is not None:
225
+ self._pending_turn_note = outcome.note
226
+
227
+ def _continuation_with_pending_note(self) -> Prompt:
228
+ continuation = continuation_prompt()
229
+
230
+ if self._pending_turn_note is not None:
231
+ continuation.text(self._pending_turn_note)
232
+ self._pending_turn_note = None
233
+
234
+ return continuation
235
+
236
+ def _ensure_history_fits(
237
+ self, message: Prompt | str | None, attachments: list[TurnAttachment] | None = None
238
+ ) -> None:
126
239
  """Fail clearly when compaction could not bring the conversation under the window.
127
240
 
128
241
  Compaction drops everything it can drop and then gives up without
@@ -130,7 +243,11 @@ class Agent:
130
243
  valid request can be built, so callers see this instead of an opaque
131
244
  provider 400.
132
245
  """
133
- total_token_count = self.history.estimated_token_count + self._incoming_token_count(message)
246
+ total_token_count = (
247
+ self.history.estimated_token_count
248
+ + self._incoming_token_count(message)
249
+ + attachments_token_count(attachments or [])
250
+ )
134
251
 
135
252
  if total_token_count <= self.max_context_tokens:
136
253
  return
@@ -141,7 +258,7 @@ class Agent:
141
258
  'after dropping everything droppable. Clear the conversation and retry, '
142
259
  'with a shorter message if possible.'
143
260
  )
144
- raise AgentRecoverableError(error_message)
261
+ raise AgentExternalError(error_message)
145
262
 
146
263
  def run(
147
264
  self,
@@ -163,7 +280,9 @@ class Agent:
163
280
  f'{self.intel_class.__name__} has no `done` field and no `is_done` '
164
281
  f'callback was given.'
165
282
  )
166
- raise AgentCriticalError(message)
283
+ raise AgentUsageError(message)
284
+
285
+ self._pending_turn_note = None
167
286
 
168
287
  result = self.turn(
169
288
  request,
@@ -182,10 +301,10 @@ class Agent:
182
301
  f'Agent gave up after {self.max_turns} turns without the request '
183
302
  f'being complete.'
184
303
  )
185
- raise AgentRecoverableError(message)
304
+ raise AgentExternalError(message)
186
305
 
187
306
  result = self.turn(
188
- continuation_prompt(),
307
+ self._continuation_with_pending_note(),
189
308
  progress_callback=progress_callback,
190
309
  verbose_callback=verbose_callback,
191
310
  tool_call_callback=tool_call_callback,
@@ -195,10 +314,15 @@ class Agent:
195
314
  return result
196
315
 
197
316
  def clear(self) -> None:
198
- """Reset the conversation history and the bot."""
317
+ """Reset the conversation history, the bot, and the guard state."""
199
318
  self.history = MessageHistory()
200
319
  self.last_request = None
201
320
  self.bot.reset()
321
+ self._turn_count = 0
322
+ self._pending_turn_note = None
323
+
324
+ for guard in self.guards or []:
325
+ guard.reset()
202
326
 
203
327
  def save_session(self) -> AgentSession:
204
328
  """Snapshot the conversation and LLM context for later loading.
@@ -234,7 +358,7 @@ class Agent:
234
358
  session = AgentSession.model_validate_json(session_json)
235
359
  except ValidationError:
236
360
  message = 'The session JSON is not a valid agent session snapshot.'
237
- raise AgentRecoverableError(message) from None
361
+ raise AgentExternalError(message) from None
238
362
 
239
363
  self.load_session(session)
240
364
 
@@ -292,7 +416,7 @@ class Agent:
292
416
  if progress_callback is not None:
293
417
  progress_callback(
294
418
  StoryBeat(
295
- description='Compacting my thoughts into a more manageable size',
419
+ description='... Compacting my thoughts into a more manageable size',
296
420
  kind='compaction',
297
421
  )
298
422
  )
@@ -0,0 +1,173 @@
1
+ from __future__ import annotations
2
+
3
+ import contextlib
4
+ import re
5
+ import shutil
6
+ from dataclasses import dataclass
7
+ from datetime import UTC, datetime
8
+ from pathlib import Path
9
+
10
+ from dandy.shared.files import encode_file_to_base64
11
+ from dandy.shared.constants import DANDY_LOCAL_DIRECTORY_NAME
12
+ from dandy.domain.tokens.estimate import (
13
+ get_estimated_token_count_for_image,
14
+ get_estimated_token_count_for_string,
15
+ )
16
+
17
+ ATTACHMENT_KIND_IMAGE = 'image'
18
+ ATTACHMENT_KIND_AUDIO = 'audio'
19
+ ATTACHMENT_KIND_PROJECT_FILE = 'project_file'
20
+
21
+ _IMAGE_EXTENSIONS = {'.png', '.jpg', '.jpeg', '.gif', '.webp'}
22
+ _AUDIO_EXTENSIONS = {'.mp3', '.wav', '.ogg', '.m4a', '.flac'}
23
+
24
+ # A path-like token: a run of non-whitespace, non-quote characters. Slashes
25
+ # stay inside the token (so "a/b.txt" is one token, not two).
26
+ _PATH_TOKEN_RE = re.compile(r'[^\s\'"<>|*?]+')
27
+
28
+
29
+ @dataclass(frozen=True)
30
+ class TurnAttachment:
31
+ """One file attached to a turn, classified for how it reaches the model.
32
+
33
+ `image` and `audio` attachments go to the LLM as native content parts;
34
+ `project_file` attachments are copied under `<project>/.dandy/attachments/`
35
+ and the agent is told to read `delivery_path` with its own tools.
36
+ """
37
+
38
+ source_path: Path
39
+ kind: str
40
+ delivery_path: Path | None = None
41
+
42
+
43
+ def _is_path_like(token: str) -> bool:
44
+ if '://' in token:
45
+ return False
46
+
47
+ # A token with a dot (a file in the project root), a slash, a backslash,
48
+ # a leading ~, or a leading / (an absolute path) is worth checking for
49
+ # existence; bare prose words and punctuation are not.
50
+ return any(character.isalnum() for character in token) and (
51
+ '.' in token or '/' in token or '\\' in token or token.startswith('~')
52
+ )
53
+
54
+
55
+ def detect_attachment_paths(text: str, base_path: Path) -> tuple[str, list[Path]]:
56
+ """Pull existing file-path tokens out of the input text.
57
+
58
+ Returns the text with the tokens removed (surrounding text preserved) and
59
+ the resolved paths that exist on disk. Relative paths resolve against
60
+ `base_path` (the project root) and `~` expands to the home directory.
61
+ """
62
+ if not text:
63
+ return text, []
64
+
65
+ found: list[Path] = []
66
+ removed_tokens: set[str] = set()
67
+
68
+ for match in _PATH_TOKEN_RE.finditer(text):
69
+ token = match.group(0)
70
+
71
+ if not _is_path_like(token) or token in removed_tokens:
72
+ continue
73
+
74
+ candidate = Path(token).expanduser()
75
+
76
+ if not candidate.is_absolute():
77
+ candidate = base_path / candidate
78
+
79
+ if not candidate.is_file():
80
+ continue
81
+
82
+ removed_tokens.add(token)
83
+ found.append(candidate)
84
+
85
+ remaining = text
86
+
87
+ for token in removed_tokens:
88
+ remaining = remaining.replace(token, ' ')
89
+
90
+ return ' '.join(remaining.split()), found
91
+
92
+
93
+ def _attachment_kind(file_path: Path) -> str:
94
+ suffix = file_path.suffix.lower()
95
+
96
+ if suffix in _IMAGE_EXTENSIONS:
97
+ return ATTACHMENT_KIND_IMAGE
98
+ if suffix in _AUDIO_EXTENSIONS:
99
+ return ATTACHMENT_KIND_AUDIO
100
+
101
+ return ATTACHMENT_KIND_PROJECT_FILE
102
+
103
+
104
+ def _delivery_name(file_path: Path) -> str:
105
+ stamp = datetime.now(UTC).strftime('%Y%m%dT%H%M%S')
106
+ return f'{stamp}__{file_path.name}'
107
+
108
+
109
+ def _unique_delivery_path(directory: Path, name: str) -> Path:
110
+ delivery = directory / name
111
+ counter = 2
112
+ suffix = Path(name).suffix
113
+ stem = Path(name).name[: -len(suffix)] if suffix else name
114
+
115
+ while delivery.exists():
116
+ delivery = directory / f'{stem}-{counter}{suffix}'
117
+ counter += 1
118
+
119
+ return delivery
120
+
121
+
122
+ def prepare_turn_attachments(
123
+ paths: list[Path], base_path: Path
124
+ ) -> tuple[list[TurnAttachment], list[str]]:
125
+ """Classify the detected paths and copy project files into the project.
126
+
127
+ Images and audio stay where they are (the connector base64-encodes them);
128
+ every other file is copied into `<base>/.dandy/attachments/` so the agent
129
+ can read it with its read_file tool. Failures become issue strings and
130
+ never raise.
131
+ """
132
+ attachments: list[TurnAttachment] = []
133
+ issues: list[str] = []
134
+
135
+ for source_path in paths:
136
+ try:
137
+ kind = _attachment_kind(source_path)
138
+
139
+ if kind == ATTACHMENT_KIND_PROJECT_FILE:
140
+ directory = base_path / DANDY_LOCAL_DIRECTORY_NAME / 'attachments'
141
+ directory.mkdir(parents=True, exist_ok=True)
142
+ delivery_path = _unique_delivery_path(directory, _delivery_name(source_path))
143
+ shutil.copyfile(source_path, delivery_path)
144
+ attachments.append(
145
+ TurnAttachment(source_path=source_path, kind=kind, delivery_path=delivery_path)
146
+ )
147
+ else:
148
+ attachments.append(TurnAttachment(source_path=source_path, kind=kind))
149
+ except Exception as error:
150
+ issues.append(f'Could not attach "{source_path.name}": {error}')
151
+
152
+ return attachments, issues
153
+
154
+
155
+ def attachments_token_count(attachments: list[TurnAttachment]) -> int:
156
+ """The calibrated token estimate the attachments add to a turn.
157
+
158
+ Images are priced at the high-detail default (they are attached at the
159
+ wire default `auto`, which the estimator treats as high); audio is priced
160
+ on its base64 payload size.
161
+ """
162
+ token_count = 0
163
+
164
+ for attachment in attachments:
165
+ if attachment.kind == ATTACHMENT_KIND_IMAGE:
166
+ token_count += get_estimated_token_count_for_image(detail='auto')
167
+ elif attachment.kind == ATTACHMENT_KIND_AUDIO:
168
+ with contextlib.suppress(Exception):
169
+ token_count += get_estimated_token_count_for_string(
170
+ encode_file_to_base64(attachment.source_path)
171
+ )
172
+
173
+ return token_count
@@ -1,12 +1,12 @@
1
1
  from __future__ import annotations
2
2
 
3
- from typing import TYPE_CHECKING, Callable
3
+ from typing import TYPE_CHECKING, Callable, Sequence
4
4
 
5
5
  from dandy.application.agent.agent import AGENT_MAX_TOOL_ROUNDS_DEFAULT, Agent
6
6
  from dandy.application.agent.cli.agents_md import read_agents_md
7
7
  from dandy.application.agent.cli.intelligence.bots.coding_bot import CodingBot
8
8
  from dandy.application.agent.cli.intelligence.bots.init_bot import InitBot
9
- from dandy.application.agent.cli.intelligence.prompts import init_prompt
9
+ from dandy.application.agent.cli.intelligence.prompts.init_prompts import init_prompt
10
10
  from dandy.application.agent.session import session
11
11
  from dandy.application.agent.intelligence.tools import AGENT_TOOLS
12
12
  from dandy.application.agent.intelligence.tools.question import QuestionHandler, QuestionTool
@@ -14,17 +14,26 @@ from dandy.domain.intel.intel import DefaultIntel
14
14
  from dandy.domain.message.message import MessageContent
15
15
 
16
16
  if TYPE_CHECKING:
17
+ from dandy.domain.guard.guard import Guard
18
+ from dandy.domain.skill.skill import SkillType
17
19
  from dandy.domain.tool.beat import StoryBeat
18
20
 
19
21
 
20
22
  class CliAgent(Agent):
21
23
  """Multi-turn coding agent that keeps the conversation across turns."""
22
24
 
23
- def __init__(self, ask_user: QuestionHandler | None = None) -> None:
25
+ def __init__(
26
+ self,
27
+ ask_user: QuestionHandler | None = None,
28
+ skills: list[SkillType] | None = None,
29
+ guards: Sequence[Guard] | None = None,
30
+ ) -> None:
24
31
  super().__init__(
25
32
  bot=CodingBot(),
26
33
  tools=[*AGENT_TOOLS, QuestionTool(ask_user=ask_user)],
34
+ skills=skills,
27
35
  intel_class=DefaultIntel,
36
+ guards=guards,
28
37
  )
29
38
 
30
39
  def reload_agents_md(self) -> str: