dandy 3.0.0a2__tar.gz → 3.0.0a5__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.
- {dandy-3.0.0a2 → dandy-3.0.0a5}/PKG-INFO +9 -3
- {dandy-3.0.0a2 → dandy-3.0.0a5}/README.md +7 -1
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/__init__.py +21 -5
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/agent/agent.py +84 -11
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/agent/cli/cli_agent.py +12 -3
- dandy-3.0.0a5/dandy/application/agent/cli/environment.py +105 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/agent/cli/intelligence/bots/coding_bot.py +10 -10
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/agent/cli/intelligence/bots/init_bot.py +1 -1
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/agent/cli/intelligence/bots/session_naming_bot.py +2 -2
- dandy-3.0.0a5/dandy/application/agent/cli/intelligence/prompts/coding_prompts.py +70 -0
- dandy-3.0.0a5/dandy/application/agent/cli/intelligence/prompts/init_prompts.py +79 -0
- dandy-3.0.0a5/dandy/application/agent/cli/intelligence/prompts/narration_prompt.py +15 -0
- dandy-3.0.0a5/dandy/application/agent/cli/intelligence/prompts/path_prompt.py +9 -0
- dandy-3.0.0a5/dandy/application/agent/cli/intelligence/prompts/session_name_prompt.py +25 -0
- dandy-3.0.0a5/dandy/application/agent/cli/intelligence/prompts/tool_calling_prompt.py +17 -0
- dandy-3.0.0a5/dandy/application/agent/exceptions.py +9 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/agent/intelligence/tools/__init__.py +10 -1
- dandy-3.0.0a5/dandy/application/agent/intelligence/tools/clock/__init__.py +6 -0
- dandy-3.0.0a5/dandy/application/agent/intelligence/tools/clock/clock_tool.py +34 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/agent/intelligence/tools/command/command_tool.py +2 -1
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/agent/intelligence/tools/file/edit_file_tool.py +1 -2
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/agent/intelligence/tools/file/read_file_tool.py +1 -1
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/agent/intelligence/tools/git/git_status_tool.py +4 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/agent/session.py +1 -12
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/agent/session_store.py +44 -4
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/bot/bot.py +3 -7
- dandy-3.0.0a5/dandy/application/bot/exceptions.py +5 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/decision/decision.py +31 -15
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/diligence/second_pass/diligence.py +5 -5
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/diligence/stop_word_removal/diligence.py +3 -6
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/diligence/vowel_removal/diligence.py +2 -6
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/llm/service.py +72 -4
- dandy-3.0.0a5/dandy/application/skill/loader.py +162 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/skill/service.py +6 -6
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/tool/service.py +51 -36
- dandy-3.0.0a5/dandy/domain/decision/exceptions.py +17 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/domain/decision/prompts.py +6 -2
- dandy-3.0.0a5/dandy/domain/guard/__init__.py +22 -0
- dandy-3.0.0a5/dandy/domain/guard/context_guard.py +57 -0
- dandy-3.0.0a5/dandy/domain/guard/defaults.py +15 -0
- dandy-3.0.0a5/dandy/domain/guard/guard.py +241 -0
- dandy-3.0.0a5/dandy/domain/guard/repeat_guard.py +108 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/domain/intel/annotation.py +6 -4
- dandy-3.0.0a5/dandy/domain/intel/exceptions.py +5 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/domain/intel/factory.py +6 -4
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/domain/intel/intel.py +32 -14
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/domain/message/message.py +7 -3
- dandy-3.0.0a5/dandy/domain/request/exceptions.py +9 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/domain/request/options.py +6 -5
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/domain/request/prompts.py +7 -2
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/domain/request/request.py +7 -1
- dandy-3.0.0a5/dandy/domain/skill/exceptions.py +5 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/domain/skill/skill.py +18 -6
- dandy-3.0.0a5/dandy/domain/tool/__init__.py +4 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/domain/tool/beat.py +7 -3
- dandy-3.0.0a5/dandy/domain/tool/exceptions.py +5 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/domain/tool/tool.py +27 -5
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/infrastructure/cache/decorators.py +3 -1
- dandy-3.0.0a5/dandy/infrastructure/cache/exceptions.py +5 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/infrastructure/cache/key.py +5 -2
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/infrastructure/cache/sqlite/cache.py +13 -5
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/infrastructure/cache/sqlite/connection.py +7 -1
- dandy-3.0.0a5/dandy/infrastructure/future/exceptions.py +9 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/infrastructure/future/future.py +9 -6
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/infrastructure/http/connector.py +2 -2
- dandy-3.0.0a5/dandy/infrastructure/http/exceptions.py +5 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/infrastructure/llm/config.py +72 -13
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/infrastructure/llm/connector.py +35 -17
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/infrastructure/recorder/events.py +2 -1
- dandy-3.0.0a5/dandy/infrastructure/recorder/exceptions.py +5 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/infrastructure/recorder/recorder.py +4 -4
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/infrastructure/recorder/recording.py +7 -7
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/interfaces/cli/cli.py +153 -73
- dandy-3.0.0a5/dandy/interfaces/cli/commands.py +89 -0
- dandy-3.0.0a5/dandy/interfaces/cli/main.py +137 -0
- dandy-3.0.0a5/dandy/interfaces/cli/one_shot.py +97 -0
- dandy-3.0.0a5/dandy/interfaces/cli/thinking_phrases.py +230 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/interfaces/cli/tui/banner.py +24 -2
- dandy-3.0.0a5/dandy/interfaces/cli/tui/notify.py +144 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/interfaces/cli/tui/printer.py +19 -15
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/interfaces/cli/tui/story_progress.py +50 -8
- dandy-3.0.0a5/dandy/interfaces/cli/tui/tui.py +230 -0
- dandy-3.0.0a5/dandy/interfaces/cli/usage.py +63 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/interfaces/cli/utils.py +13 -4
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/shared/constants.py +3 -1
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/shared/exceptions.py +13 -7
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/shared/files.py +7 -7
- dandy-3.0.0a5/dandy/shared/hashing.py +125 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/shared/media.py +9 -9
- dandy-3.0.0a5/dandy/shared/notifications.py +46 -0
- dandy-3.0.0a5/dandy/shared/service/exceptions.py +5 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/shared/service/mixin.py +2 -2
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/shared/settings/default_settings.py +7 -1
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/shared/settings/load.py +39 -3
- dandy-3.0.0a5/dandy/shared/settings/settings.py +113 -0
- dandy-3.0.0a5/dandy/shared/typing/__init__.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/shared/typing/constants.py +0 -2
- dandy-3.0.0a5/dandy/shared/typing/exceptions.py +5 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/shared/typing/signature.py +4 -4
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/shared/typing/typed_kwargs.py +6 -3
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/shared/utils.py +0 -4
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy.egg-info/PKG-INFO +9 -3
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy.egg-info/SOURCES.txt +22 -3
- {dandy-3.0.0a2 → dandy-3.0.0a5}/pyproject.toml +2 -1
- {dandy-3.0.0a2 → dandy-3.0.0a5}/tests/test_dandy.py +6 -2
- dandy-3.0.0a2/dandy/application/agent/cli/intelligence/prompts.py +0 -183
- dandy-3.0.0a2/dandy/application/agent/exceptions.py +0 -9
- dandy-3.0.0a2/dandy/application/bot/exceptions.py +0 -9
- dandy-3.0.0a2/dandy/domain/decision/exceptions.py +0 -17
- dandy-3.0.0a2/dandy/domain/intel/exceptions.py +0 -9
- dandy-3.0.0a2/dandy/domain/request/exceptions.py +0 -14
- dandy-3.0.0a2/dandy/domain/skill/exceptions.py +0 -5
- dandy-3.0.0a2/dandy/domain/tool/__init__.py +0 -5
- dandy-3.0.0a2/dandy/domain/tool/exceptions.py +0 -5
- dandy-3.0.0a2/dandy/domain/tool/repeated_call.py +0 -145
- dandy-3.0.0a2/dandy/infrastructure/cache/exceptions.py +0 -9
- dandy-3.0.0a2/dandy/infrastructure/future/exceptions.py +0 -9
- dandy-3.0.0a2/dandy/infrastructure/http/exceptions.py +0 -9
- dandy-3.0.0a2/dandy/infrastructure/recorder/exceptions.py +0 -9
- dandy-3.0.0a2/dandy/interfaces/cli/main.py +0 -130
- dandy-3.0.0a2/dandy/interfaces/cli/thinking_phrases.py +0 -315
- dandy-3.0.0a2/dandy/interfaces/cli/tui/tui.py +0 -131
- dandy-3.0.0a2/dandy/shared/connector/exceptions.py +0 -9
- dandy-3.0.0a2/dandy/shared/service/exceptions.py +0 -9
- dandy-3.0.0a2/dandy/shared/settings/settings.py +0 -88
- dandy-3.0.0a2/dandy/shared/typing/exceptions.py +0 -9
- {dandy-3.0.0a2 → dandy-3.0.0a5}/LICENSE.md +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/__init__.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/agent/__init__.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/agent/cli/__init__.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/agent/cli/agents_md.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/agent/cli/intelligence/__init__.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/agent/cli/intelligence/bots/__init__.py +0 -0
- {dandy-3.0.0a2/dandy/application/agent/intelligence → dandy-3.0.0a5/dandy/application/agent/cli/intelligence/prompts}/__init__.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/agent/intel.py +0 -0
- {dandy-3.0.0a2/dandy/application/bot → dandy-3.0.0a5/dandy/application/agent/intelligence}/__init__.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/agent/intelligence/tools/command/__init__.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/agent/intelligence/tools/file/__init__.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/agent/intelligence/tools/file/create_directory_tool.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/agent/intelligence/tools/file/delete_file_tool.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/agent/intelligence/tools/file/list_directory_tool.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/agent/intelligence/tools/file/search_tool.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/agent/intelligence/tools/file/write_file_tool.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/agent/intelligence/tools/git/__init__.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/agent/intelligence/tools/git/git_diff_tool.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/agent/intelligence/tools/paths.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/agent/intelligence/tools/question/__init__.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/agent/intelligence/tools/question/question_tool.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/agent/intelligence/tools/tool_errors.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/agent/prompts.py +0 -0
- {dandy-3.0.0a2/dandy/application/decision → dandy-3.0.0a5/dandy/application/bot}/__init__.py +0 -0
- {dandy-3.0.0a2/dandy/application/diligence → dandy-3.0.0a5/dandy/application/decision}/__init__.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/decision/mixin.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/decision/service.py +0 -0
- {dandy-3.0.0a2/dandy/application/diligence/second_pass → dandy-3.0.0a5/dandy/application/diligence}/__init__.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/diligence/diligence.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/diligence/handler.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/diligence/mixin.py +0 -0
- {dandy-3.0.0a2/dandy/application/diligence/stop_word_removal → dandy-3.0.0a5/dandy/application/diligence/second_pass}/__init__.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/diligence/service.py +0 -0
- {dandy-3.0.0a2/dandy/application/diligence/vowel_removal → dandy-3.0.0a5/dandy/application/diligence/stop_word_removal}/__init__.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/diligence/stop_word_removal/constants.py +0 -0
- {dandy-3.0.0a2/dandy/application/llm → dandy-3.0.0a5/dandy/application/diligence/vowel_removal}/__init__.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/diligence/vowel_removal/constants.py +0 -0
- {dandy-3.0.0a2/dandy/application/skill → dandy-3.0.0a5/dandy/application/llm}/__init__.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/llm/mixin.py +0 -0
- {dandy-3.0.0a2/dandy/application/tool → dandy-3.0.0a5/dandy/application/skill}/__init__.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/skill/mixin.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/skill/tools.py +0 -0
- {dandy-3.0.0a2/dandy/domain → dandy-3.0.0a5/dandy/application/tool}/__init__.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/tool/mixin.py +0 -0
- {dandy-3.0.0a2/dandy/domain/decision → dandy-3.0.0a5/dandy/domain}/__init__.py +0 -0
- {dandy-3.0.0a2/dandy/domain/intel → dandy-3.0.0a5/dandy/domain/decision}/__init__.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/domain/decision/intel.py +0 -0
- {dandy-3.0.0a2/dandy/domain/message → dandy-3.0.0a5/dandy/domain/intel}/__init__.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/domain/intel/mixin.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/domain/intel/service.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/domain/intel/typing.py +0 -0
- {dandy-3.0.0a2/dandy/domain/prompt → dandy-3.0.0a5/dandy/domain/message}/__init__.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/domain/message/compaction.py +0 -0
- {dandy-3.0.0a2/dandy/domain/request → dandy-3.0.0a5/dandy/domain/prompt}/__init__.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/domain/prompt/prompt.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/domain/prompt/snippet.py +0 -0
- {dandy-3.0.0a2/dandy/domain/tokens → dandy-3.0.0a5/dandy/domain/request}/__init__.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/domain/skill/__init__.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/domain/skill/prompts.py +0 -0
- {dandy-3.0.0a2/dandy/infrastructure → dandy-3.0.0a5/dandy/domain/tokens}/__init__.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/domain/tokens/estimate.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/domain/tool/intel.py +0 -0
- {dandy-3.0.0a2/dandy/infrastructure/cache → dandy-3.0.0a5/dandy/infrastructure}/__init__.py +0 -0
- {dandy-3.0.0a2/dandy/infrastructure/cache/memory → dandy-3.0.0a5/dandy/infrastructure/cache}/__init__.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/infrastructure/cache/cache.py +0 -0
- {dandy-3.0.0a2/dandy/infrastructure/cache/sqlite → dandy-3.0.0a5/dandy/infrastructure/cache/memory}/__init__.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/infrastructure/cache/memory/cache.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/infrastructure/cache/memory/decorators.py +0 -0
- {dandy-3.0.0a2/dandy/infrastructure/file → dandy-3.0.0a5/dandy/infrastructure/cache/sqlite}/__init__.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/infrastructure/cache/sqlite/decorators.py +0 -0
- {dandy-3.0.0a2/dandy/infrastructure/future → dandy-3.0.0a5/dandy/infrastructure/file}/__init__.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/infrastructure/file/mixin.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/infrastructure/file/service.py +0 -0
- {dandy-3.0.0a2/dandy/infrastructure/http → dandy-3.0.0a5/dandy/infrastructure/future}/__init__.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/infrastructure/future/process.py +0 -0
- {dandy-3.0.0a2/dandy/infrastructure/llm → dandy-3.0.0a5/dandy/infrastructure/http}/__init__.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/infrastructure/http/intel.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/infrastructure/http/mixin.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/infrastructure/http/service.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/infrastructure/http/url.py +0 -0
- {dandy-3.0.0a2/dandy/infrastructure/recorder → dandy-3.0.0a5/dandy/infrastructure/llm}/__init__.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/infrastructure/llm/fenced_json.py +0 -0
- {dandy-3.0.0a2/dandy/infrastructure/recorder/renderer → dandy-3.0.0a5/dandy/infrastructure/recorder}/__init__.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/infrastructure/recorder/bot_events.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/infrastructure/recorder/decision_events.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/infrastructure/recorder/decorators.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/infrastructure/recorder/diligence_events.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/infrastructure/recorder/llm_events.py +0 -0
- {dandy-3.0.0a2/dandy/interfaces → dandy-3.0.0a5/dandy/infrastructure/recorder/renderer}/__init__.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/infrastructure/recorder/renderer/html.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/infrastructure/recorder/renderer/html_templates/base_event_template.html +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/infrastructure/recorder/renderer/html_templates/base_recording_output_template.html +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/infrastructure/recorder/renderer/json.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/infrastructure/recorder/renderer/markdown.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/infrastructure/recorder/renderer/renderer.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/infrastructure/recorder/tool_events.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/infrastructure/recorder/utils.py +0 -0
- {dandy-3.0.0a2/dandy/interfaces/cli → dandy-3.0.0a5/dandy/interfaces}/__init__.py +0 -0
- {dandy-3.0.0a2/dandy/interfaces/cli/tui → dandy-3.0.0a5/dandy/interfaces/cli}/__init__.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/interfaces/cli/error_log.py +0 -0
- {dandy-3.0.0a2/dandy/shared → dandy-3.0.0a5/dandy/interfaces/cli/tui}/__init__.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/interfaces/cli/tui/ascii.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/interfaces/cli/tui/markdown.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/interfaces/cli/tui/text.py +0 -0
- {dandy-3.0.0a2/dandy/shared/connector → dandy-3.0.0a5/dandy/shared}/__init__.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/shared/cancellation.py +0 -0
- {dandy-3.0.0a2/dandy/shared/service → dandy-3.0.0a5/dandy/shared/connector}/__init__.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/shared/connector/connector.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/shared/debug.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/shared/interaction.py +0 -0
- {dandy-3.0.0a2/dandy/shared/typing → dandy-3.0.0a5/dandy/shared/service}/__init__.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/shared/service/service.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/shared/settings/__init__.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/shared/singleton.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/shared/subprocess.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/shared/typing/registry.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/shared/typing/typing.py +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy.egg-info/dependency_links.txt +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy.egg-info/entry_points.txt +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy.egg-info/requires.txt +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/dandy.egg-info/top_level.txt +0 -0
- {dandy-3.0.0a2 → dandy-3.0.0a5}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dandy
|
|
3
|
-
Version: 3.0.
|
|
3
|
+
Version: 3.0.0a5
|
|
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 ::
|
|
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. `/
|
|
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. `/
|
|
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,12 +6,20 @@ 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
|
|
9
|
+
from dandy.shared.exceptions import (
|
|
10
|
+
DandyConfigurationError,
|
|
11
|
+
DandyError,
|
|
12
|
+
DandyExternalError,
|
|
13
|
+
DandyFlowError,
|
|
14
|
+
DandyUsageError,
|
|
15
|
+
)
|
|
16
|
+
from dandy.shared.hashing import HashMixin
|
|
10
17
|
from dandy.infrastructure.future.process import process_to_future
|
|
11
18
|
from dandy.domain.intel.intel import BaseIntel, BaseListIntel, DefaultIntel
|
|
12
19
|
from dandy.domain.message.message import MessageHistory
|
|
13
20
|
from dandy.domain.prompt.prompt import Prompt
|
|
14
21
|
from dandy.domain.request.options import LlmOptions
|
|
22
|
+
from dandy.infrastructure.llm.config import LlmConfig
|
|
15
23
|
from dandy.infrastructure.recorder.decorators import (
|
|
16
24
|
recorder_to_html_file,
|
|
17
25
|
recorder_to_json_file,
|
|
@@ -29,11 +37,15 @@ __all__ = [
|
|
|
29
37
|
'BaseTool',
|
|
30
38
|
'Bot',
|
|
31
39
|
'Dandy',
|
|
32
|
-
'
|
|
40
|
+
'DandyConfigurationError',
|
|
33
41
|
'DandyError',
|
|
34
|
-
'
|
|
42
|
+
'DandyExternalError',
|
|
43
|
+
'DandyFlowError',
|
|
44
|
+
'DandyUsageError',
|
|
35
45
|
'Decision',
|
|
36
46
|
'DefaultIntel',
|
|
47
|
+
'HashMixin',
|
|
48
|
+
'LlmConfig',
|
|
37
49
|
'LlmOptions',
|
|
38
50
|
'MemoryCache',
|
|
39
51
|
'MessageHistory',
|
|
@@ -66,11 +78,15 @@ class Dandy:
|
|
|
66
78
|
BaseSkill = BaseSkill
|
|
67
79
|
BaseTool = BaseTool
|
|
68
80
|
Bot = Bot
|
|
69
|
-
|
|
81
|
+
DandyConfigurationError = DandyConfigurationError
|
|
70
82
|
DandyError = DandyError
|
|
71
|
-
|
|
83
|
+
DandyExternalError = DandyExternalError
|
|
84
|
+
DandyFlowError = DandyFlowError
|
|
85
|
+
DandyUsageError = DandyUsageError
|
|
72
86
|
Decision = Decision
|
|
73
87
|
DefaultIntel = DefaultIntel
|
|
88
|
+
HashMixin = HashMixin
|
|
89
|
+
LlmConfig = LlmConfig
|
|
74
90
|
LlmOptions = LlmOptions
|
|
75
91
|
MemoryCache = MemoryCache
|
|
76
92
|
MessageHistory = MessageHistory
|
|
@@ -1,14 +1,15 @@
|
|
|
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
|
|
7
|
+
from dandy.application.agent.exceptions import AgentUsageError, AgentExternalError
|
|
8
8
|
from dandy.application.agent.intel import AgentSession, AgentTurnIntel
|
|
9
9
|
from dandy.application.agent.prompts import continuation_prompt
|
|
10
10
|
from dandy.shared.cancellation import stop_signal
|
|
11
11
|
from dandy.shared.exceptions import RUN_STOPPED_MESSAGE, RunStoppedError
|
|
12
|
+
from dandy.domain.guard.guard import GuardChain
|
|
12
13
|
from dandy.domain.message.compaction import (
|
|
13
14
|
COMPACTION_TARGET_RATIO,
|
|
14
15
|
COMPACTION_TRIGGER_RATIO,
|
|
@@ -18,12 +19,15 @@ from dandy.domain.message.compaction import (
|
|
|
18
19
|
)
|
|
19
20
|
from dandy.domain.message.message import MessageHistory
|
|
20
21
|
from dandy.domain.prompt.prompt import Prompt
|
|
22
|
+
from dandy.domain.request.exceptions import LlmExternalError
|
|
21
23
|
from dandy.domain.skill.skill import to_skill_instances
|
|
22
24
|
from dandy.domain.tokens.estimate import get_estimated_token_count_for_string
|
|
23
25
|
from dandy.domain.tool.beat import StoryBeat
|
|
24
26
|
|
|
25
27
|
if TYPE_CHECKING:
|
|
26
28
|
from dandy.application.bot.bot import Bot
|
|
29
|
+
from dandy.application.llm.service import LlmService
|
|
30
|
+
from dandy.domain.guard.guard import Guard
|
|
27
31
|
from dandy.domain.intel.typing import IntelType
|
|
28
32
|
from dandy.domain.skill.skill import SkillType
|
|
29
33
|
from dandy.domain.tool.tool import ToolType
|
|
@@ -54,6 +58,7 @@ class Agent:
|
|
|
54
58
|
max_turns: int | None = None,
|
|
55
59
|
max_tool_rounds: int | None = AGENT_MAX_TOOL_ROUNDS_DEFAULT,
|
|
56
60
|
intel_class: type[IntelType] | None = None,
|
|
61
|
+
guards: Sequence[Guard] | None = None,
|
|
57
62
|
) -> None:
|
|
58
63
|
self.bot = bot
|
|
59
64
|
self.tools = tools
|
|
@@ -61,9 +66,13 @@ class Agent:
|
|
|
61
66
|
self.max_turns = max_turns
|
|
62
67
|
self.max_tool_rounds = max_tool_rounds
|
|
63
68
|
self.intel_class = intel_class or AgentTurnIntel
|
|
69
|
+
self.guards = list(guards) if guards is not None else None
|
|
64
70
|
self.history = MessageHistory()
|
|
65
71
|
self.max_context_tokens = self._resolve_context_size()
|
|
66
72
|
self.last_request: str | None = None
|
|
73
|
+
self._guard_chain = GuardChain(self.guards or [])
|
|
74
|
+
self._turn_count = 0
|
|
75
|
+
self._pending_turn_note: str | None = None
|
|
67
76
|
|
|
68
77
|
if self.skills:
|
|
69
78
|
self.bot.llm.skills.register(self.skills)
|
|
@@ -74,6 +83,10 @@ class Agent:
|
|
|
74
83
|
context_size = self.bot.llm.config.context_size
|
|
75
84
|
return context_size if context_size > 0 else DEFAULT_CONTEXT_WINDOW
|
|
76
85
|
|
|
86
|
+
@property
|
|
87
|
+
def llm(self) -> LlmService:
|
|
88
|
+
return self.bot.llm
|
|
89
|
+
|
|
77
90
|
def turn(
|
|
78
91
|
self,
|
|
79
92
|
message: Prompt | str | None = None,
|
|
@@ -85,17 +98,23 @@ class Agent:
|
|
|
85
98
|
|
|
86
99
|
The conversation accumulates in ``self.history`` across turns. When
|
|
87
100
|
``tool_call_callback`` is given, it is called once per executed tool
|
|
88
|
-
call with the tool name and its validated keyword arguments.
|
|
101
|
+
call with the tool name and its validated keyword arguments. The
|
|
102
|
+
agent's guards (when given) watch the turn boundaries: a turn-start
|
|
103
|
+
failure stops the turn before any LLM spend, and a combined
|
|
104
|
+
turn-end ``note`` is appended to the next ``run()`` continuation.
|
|
89
105
|
"""
|
|
90
106
|
if stop_signal.is_set():
|
|
91
107
|
raise RunStoppedError(RUN_STOPPED_MESSAGE)
|
|
92
108
|
|
|
109
|
+
self._turn_count += 1
|
|
93
110
|
self.last_request = self._message_as_str(message)
|
|
111
|
+
self.max_context_tokens = self._resolve_context_size()
|
|
94
112
|
message = self._prepare_message(message, progress_callback, verbose_callback)
|
|
113
|
+
self._watch_turn_start(message, verbose_callback)
|
|
95
114
|
self._compact_history_for_next_message(message, progress_callback)
|
|
96
115
|
self._ensure_history_fits(message)
|
|
97
116
|
|
|
98
|
-
|
|
117
|
+
result = self.bot.llm.tools.prompt_to_intel(
|
|
99
118
|
prompt=message,
|
|
100
119
|
tools=self.tools,
|
|
101
120
|
intel_class=self.intel_class,
|
|
@@ -105,8 +124,13 @@ class Agent:
|
|
|
105
124
|
verbose_callback=verbose_callback,
|
|
106
125
|
tool_call_callback=tool_call_callback,
|
|
107
126
|
max_tool_iterations=self.max_tool_rounds,
|
|
127
|
+
guards=self.guards,
|
|
108
128
|
)
|
|
109
129
|
|
|
130
|
+
self._watch_turn_end(result, verbose_callback)
|
|
131
|
+
|
|
132
|
+
return result
|
|
133
|
+
|
|
110
134
|
def _prepare_message(
|
|
111
135
|
self,
|
|
112
136
|
message: Prompt | str | None,
|
|
@@ -116,6 +140,48 @@ class Agent:
|
|
|
116
140
|
"""Subclass hook to shape the incoming message before it goes to the bot."""
|
|
117
141
|
return message
|
|
118
142
|
|
|
143
|
+
def _watch_turn_start(
|
|
144
|
+
self, message: Prompt | str | None, verbose_callback: Callable[[str], None] | None
|
|
145
|
+
) -> None:
|
|
146
|
+
"""Run the turn-start guards; a failure stops the turn before any LLM spend."""
|
|
147
|
+
try:
|
|
148
|
+
self._guard_chain.on_turn_start(
|
|
149
|
+
turn_number=self._turn_count,
|
|
150
|
+
message=message,
|
|
151
|
+
history_token_count=self.history.estimated_token_count,
|
|
152
|
+
context_window=self.max_context_tokens,
|
|
153
|
+
verbose_callback=verbose_callback,
|
|
154
|
+
)
|
|
155
|
+
except LlmExternalError as error:
|
|
156
|
+
raise AgentExternalError(str(error)) from error
|
|
157
|
+
|
|
158
|
+
def _watch_turn_end(
|
|
159
|
+
self, result: IntelType, verbose_callback: Callable[[str], None] | None
|
|
160
|
+
) -> None:
|
|
161
|
+
"""Run the turn-end guards; a combined note steers the next run() continuation."""
|
|
162
|
+
try:
|
|
163
|
+
outcome = self._guard_chain.on_turn_end(
|
|
164
|
+
turn_number=self._turn_count,
|
|
165
|
+
result=result,
|
|
166
|
+
history_token_count=self.history.estimated_token_count,
|
|
167
|
+
context_window=self.max_context_tokens,
|
|
168
|
+
verbose_callback=verbose_callback,
|
|
169
|
+
)
|
|
170
|
+
except LlmExternalError as error:
|
|
171
|
+
raise AgentExternalError(str(error)) from error
|
|
172
|
+
|
|
173
|
+
if outcome.note is not None:
|
|
174
|
+
self._pending_turn_note = outcome.note
|
|
175
|
+
|
|
176
|
+
def _continuation_with_pending_note(self) -> Prompt:
|
|
177
|
+
continuation = continuation_prompt()
|
|
178
|
+
|
|
179
|
+
if self._pending_turn_note is not None:
|
|
180
|
+
continuation.text(self._pending_turn_note)
|
|
181
|
+
self._pending_turn_note = None
|
|
182
|
+
|
|
183
|
+
return continuation
|
|
184
|
+
|
|
119
185
|
def _ensure_history_fits(self, message: Prompt | str | None) -> None:
|
|
120
186
|
"""Fail clearly when compaction could not bring the conversation under the window.
|
|
121
187
|
|
|
@@ -135,7 +201,7 @@ class Agent:
|
|
|
135
201
|
'after dropping everything droppable. Clear the conversation and retry, '
|
|
136
202
|
'with a shorter message if possible.'
|
|
137
203
|
)
|
|
138
|
-
raise
|
|
204
|
+
raise AgentExternalError(error_message)
|
|
139
205
|
|
|
140
206
|
def run(
|
|
141
207
|
self,
|
|
@@ -157,7 +223,9 @@ class Agent:
|
|
|
157
223
|
f'{self.intel_class.__name__} has no `done` field and no `is_done` '
|
|
158
224
|
f'callback was given.'
|
|
159
225
|
)
|
|
160
|
-
raise
|
|
226
|
+
raise AgentUsageError(message)
|
|
227
|
+
|
|
228
|
+
self._pending_turn_note = None
|
|
161
229
|
|
|
162
230
|
result = self.turn(
|
|
163
231
|
request,
|
|
@@ -176,10 +244,10 @@ class Agent:
|
|
|
176
244
|
f'Agent gave up after {self.max_turns} turns without the request '
|
|
177
245
|
f'being complete.'
|
|
178
246
|
)
|
|
179
|
-
raise
|
|
247
|
+
raise AgentExternalError(message)
|
|
180
248
|
|
|
181
249
|
result = self.turn(
|
|
182
|
-
|
|
250
|
+
self._continuation_with_pending_note(),
|
|
183
251
|
progress_callback=progress_callback,
|
|
184
252
|
verbose_callback=verbose_callback,
|
|
185
253
|
tool_call_callback=tool_call_callback,
|
|
@@ -189,10 +257,15 @@ class Agent:
|
|
|
189
257
|
return result
|
|
190
258
|
|
|
191
259
|
def clear(self) -> None:
|
|
192
|
-
"""Reset the conversation history and the
|
|
260
|
+
"""Reset the conversation history, the bot, and the guard state."""
|
|
193
261
|
self.history = MessageHistory()
|
|
194
262
|
self.last_request = None
|
|
195
263
|
self.bot.reset()
|
|
264
|
+
self._turn_count = 0
|
|
265
|
+
self._pending_turn_note = None
|
|
266
|
+
|
|
267
|
+
for guard in self.guards or []:
|
|
268
|
+
guard.reset()
|
|
196
269
|
|
|
197
270
|
def save_session(self) -> AgentSession:
|
|
198
271
|
"""Snapshot the conversation and LLM context for later loading.
|
|
@@ -228,7 +301,7 @@ class Agent:
|
|
|
228
301
|
session = AgentSession.model_validate_json(session_json)
|
|
229
302
|
except ValidationError:
|
|
230
303
|
message = 'The session JSON is not a valid agent session snapshot.'
|
|
231
|
-
raise
|
|
304
|
+
raise AgentExternalError(message) from None
|
|
232
305
|
|
|
233
306
|
self.load_session(session)
|
|
234
307
|
|
|
@@ -286,7 +359,7 @@ class Agent:
|
|
|
286
359
|
if progress_callback is not None:
|
|
287
360
|
progress_callback(
|
|
288
361
|
StoryBeat(
|
|
289
|
-
description='Compacting my thoughts into a more manageable size',
|
|
362
|
+
description='... Compacting my thoughts into a more manageable size',
|
|
290
363
|
kind='compaction',
|
|
291
364
|
)
|
|
292
365
|
)
|
|
@@ -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__(
|
|
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:
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import platform
|
|
3
|
+
import shutil
|
|
4
|
+
import subprocess
|
|
5
|
+
import sys
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
from dandy.application.agent.session import session
|
|
9
|
+
from dandy.domain.prompt.prompt import Prompt
|
|
10
|
+
|
|
11
|
+
_HIDDEN_TOP_LEVEL_NAMES = {'.git', '.dandy', '.venv', 'node_modules', '__pycache__', '.hypothesis'}
|
|
12
|
+
_GIT_COMMAND_TIMEOUT_SECONDS = 5
|
|
13
|
+
_MAX_TOP_LEVEL_ENTRIES = 50
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _git_project_info(project_base_path: Path) -> tuple[str, str] | None:
|
|
17
|
+
"""(branch, short dirty status) for the project repo, or None when unavailable."""
|
|
18
|
+
if not (project_base_path / '.git').exists() or shutil.which('git') is None:
|
|
19
|
+
return None
|
|
20
|
+
|
|
21
|
+
git = shutil.which('git')
|
|
22
|
+
|
|
23
|
+
def run_git(*arguments: str) -> subprocess.CompletedProcess[str]:
|
|
24
|
+
return subprocess.run(
|
|
25
|
+
[git, *arguments],
|
|
26
|
+
cwd=project_base_path,
|
|
27
|
+
capture_output=True,
|
|
28
|
+
text=True,
|
|
29
|
+
check=False,
|
|
30
|
+
timeout=_GIT_COMMAND_TIMEOUT_SECONDS,
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
try:
|
|
34
|
+
branch_result = run_git('rev-parse', '--abbrev-ref', 'HEAD')
|
|
35
|
+
status_result = run_git('status', '--porcelain')
|
|
36
|
+
except (OSError, subprocess.TimeoutExpired):
|
|
37
|
+
return None
|
|
38
|
+
|
|
39
|
+
if branch_result.returncode != 0 or not branch_result.stdout.strip():
|
|
40
|
+
return None
|
|
41
|
+
|
|
42
|
+
changed_count = len([line for line in status_result.stdout.splitlines() if line.strip()])
|
|
43
|
+
status = 'clean' if changed_count == 0 else f'{changed_count} changed'
|
|
44
|
+
|
|
45
|
+
return branch_result.stdout.strip(), status
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def _top_level_listing(project_base_path: Path) -> str:
|
|
49
|
+
try:
|
|
50
|
+
entries = sorted(project_base_path.iterdir(), key=lambda entry: entry.name.lower())
|
|
51
|
+
except OSError:
|
|
52
|
+
return 'unavailable'
|
|
53
|
+
|
|
54
|
+
names = [entry.name + '/' if entry.is_dir() else entry.name for entry in entries]
|
|
55
|
+
names = [name for name in names if name.split('/')[0] not in _HIDDEN_TOP_LEVEL_NAMES]
|
|
56
|
+
|
|
57
|
+
if len(names) > _MAX_TOP_LEVEL_ENTRIES:
|
|
58
|
+
hidden_count = len(names) - _MAX_TOP_LEVEL_ENTRIES
|
|
59
|
+
names = [*names[:_MAX_TOP_LEVEL_ENTRIES], f'... ({hidden_count} more)']
|
|
60
|
+
|
|
61
|
+
return ', '.join(names) if names else '(empty)'
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def collect_environment() -> dict[str, str]:
|
|
65
|
+
"""A snapshot of the host and project environment, for the coding agent prompt.
|
|
66
|
+
|
|
67
|
+
Every lookup is bounded and failure-tolerant: a missing git repo or a
|
|
68
|
+
vanished project root degrades the corresponding line instead of raising.
|
|
69
|
+
"""
|
|
70
|
+
environment: dict[str, str] = {}
|
|
71
|
+
|
|
72
|
+
environment['OS'] = platform.platform()
|
|
73
|
+
environment['User'] = os.environ.get('USER') or os.environ.get('USERNAME') or 'unknown'
|
|
74
|
+
environment['Python'] = platform.python_version()
|
|
75
|
+
|
|
76
|
+
if sys.prefix != sys.base_prefix:
|
|
77
|
+
environment['Python'] += f' (virtualenv: {sys.prefix})'
|
|
78
|
+
|
|
79
|
+
environment['Project root'] = str(session.project_base_path)
|
|
80
|
+
environment['Top level'] = _top_level_listing(session.project_base_path)
|
|
81
|
+
|
|
82
|
+
for manifest_name in ('justfile', 'Justfile', 'makefile', 'Makefile'):
|
|
83
|
+
if (session.project_base_path / manifest_name).is_file():
|
|
84
|
+
environment['Build tooling'] = manifest_name
|
|
85
|
+
break
|
|
86
|
+
|
|
87
|
+
git_info = _git_project_info(session.project_base_path)
|
|
88
|
+
|
|
89
|
+
if git_info:
|
|
90
|
+
branch, status = git_info
|
|
91
|
+
environment['Git'] = f'branch {branch}, {status}'
|
|
92
|
+
else:
|
|
93
|
+
environment['Git'] = 'not a git repository'
|
|
94
|
+
|
|
95
|
+
return environment
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def environment_section() -> Prompt:
|
|
99
|
+
"""The collected environment as a compact Environment section for agent guidelines."""
|
|
100
|
+
return (
|
|
101
|
+
Prompt()
|
|
102
|
+
.sub_heading('Environment')
|
|
103
|
+
.text('Snapshot of the working environment, captured when this conversation started.')
|
|
104
|
+
.list([f'{key}: {value}' for key, value in collect_environment().items()])
|
|
105
|
+
)
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
from dandy.application.agent.cli.agents_md import agents_md_section, read_agents_md
|
|
2
|
-
from dandy.application.agent.cli.
|
|
2
|
+
from dandy.application.agent.cli.environment import environment_section
|
|
3
|
+
from dandy.application.agent.cli.intelligence.prompts.coding_prompts import (
|
|
4
|
+
coding_task_prompt,
|
|
5
|
+
coding_guidelines_prompt,
|
|
6
|
+
)
|
|
3
7
|
from dandy.application.agent.session import session
|
|
4
8
|
from dandy.application.agent.intelligence.tools import AGENT_TOOLS
|
|
5
9
|
from dandy.application.bot.bot import Bot
|
|
@@ -9,15 +13,17 @@ from dandy.domain.prompt.prompt import Prompt
|
|
|
9
13
|
|
|
10
14
|
|
|
11
15
|
class CodingBot(Bot):
|
|
12
|
-
role = '
|
|
16
|
+
role = 'Advanced Coding Assistant'
|
|
17
|
+
task = coding_task_prompt()
|
|
13
18
|
|
|
14
19
|
def __post_init__(self) -> None:
|
|
15
20
|
super().__post_init__()
|
|
16
21
|
self.llm_config = get_cli_llm_config('CODING')
|
|
17
22
|
self.guidelines = self.build_guidelines()
|
|
18
23
|
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
@staticmethod
|
|
25
|
+
def build_guidelines() -> Prompt:
|
|
26
|
+
guidelines = coding_guidelines_prompt(environment=environment_section())
|
|
21
27
|
agents_md = read_agents_md(session.agents_md_path)
|
|
22
28
|
|
|
23
29
|
if agents_md is not None:
|
|
@@ -25,11 +31,5 @@ class CodingBot(Bot):
|
|
|
25
31
|
|
|
26
32
|
return guidelines
|
|
27
33
|
|
|
28
|
-
task = (
|
|
29
|
-
'Implement the user coding request by editing the project. '
|
|
30
|
-
'Use the available tools to explore and modify the code, '
|
|
31
|
-
'then give a short summary of what you changed and why.'
|
|
32
|
-
)
|
|
33
|
-
|
|
34
34
|
def process(self, user_input: Prompt | str) -> DefaultIntel:
|
|
35
35
|
return self.llm.tools.prompt_to_intel(prompt=user_input, tools=AGENT_TOOLS)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from dandy.application.agent.cli.intelligence.prompts import init_guidelines_prompt
|
|
1
|
+
from dandy.application.agent.cli.intelligence.prompts.init_prompts import init_guidelines_prompt
|
|
2
2
|
from dandy.application.agent.intelligence.tools import AGENT_TOOLS
|
|
3
3
|
from dandy.application.bot.bot import Bot
|
|
4
4
|
from dandy.shared.settings.load import get_cli_llm_config
|
{dandy-3.0.0a2 → dandy-3.0.0a5}/dandy/application/agent/cli/intelligence/bots/session_naming_bot.py
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from dandy.application.agent.intel import SessionNameIntel
|
|
2
|
-
from dandy.application.agent.cli.intelligence.prompts import session_name_prompt
|
|
2
|
+
from dandy.application.agent.cli.intelligence.prompts.session_name_prompt import session_name_prompt
|
|
3
3
|
from dandy.application.bot.bot import Bot
|
|
4
4
|
from dandy.shared.settings.load import get_cli_llm_config
|
|
5
5
|
from dandy.domain.prompt.prompt import Prompt
|
|
@@ -29,7 +29,7 @@ class SessionNamingBot(Bot):
|
|
|
29
29
|
)
|
|
30
30
|
|
|
31
31
|
task = (
|
|
32
|
-
|
|
32
|
+
"Create a short title for the user's coding request: 6 to 10 words, "
|
|
33
33
|
'title case, plain words only.'
|
|
34
34
|
)
|
|
35
35
|
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
from dandy.application.agent.cli.intelligence.prompts.narration_prompt import _narration_section
|
|
2
|
+
from dandy.application.agent.cli.intelligence.prompts.path_prompt import _paths_section
|
|
3
|
+
from dandy.application.agent.cli.intelligence.prompts.tool_calling_prompt import (
|
|
4
|
+
_tool_calling_section,
|
|
5
|
+
)
|
|
6
|
+
from dandy.domain.prompt.prompt import Prompt
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def coding_task_prompt() -> Prompt:
|
|
10
|
+
return Prompt(
|
|
11
|
+
'Implement the user coding request by editing the project. '
|
|
12
|
+
'Write understandable quality code, '
|
|
13
|
+
'improve code structure, '
|
|
14
|
+
'consider edge cases, '
|
|
15
|
+
'validate your changes, '
|
|
16
|
+
'and look for existing solutions in the project.'
|
|
17
|
+
'Use the available tools to explore and modify the code, '
|
|
18
|
+
'then give a short summary of what you changed and why.'
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def coding_guidelines_prompt(environment: Prompt | None = None) -> Prompt:
|
|
23
|
+
guidelines = _paths_section()
|
|
24
|
+
|
|
25
|
+
if environment is not None:
|
|
26
|
+
guidelines = guidelines.prompt(environment)
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
guidelines.sub_heading('Editing Code')
|
|
30
|
+
.list(
|
|
31
|
+
[
|
|
32
|
+
'Read a file before editing it so you can match the exact text.',
|
|
33
|
+
(
|
|
34
|
+
'Prefer edit_file for small targeted changes over rewriting the '
|
|
35
|
+
'whole file with write_file.'
|
|
36
|
+
),
|
|
37
|
+
'When choosing the old_string for edit_file, match the whitespace exactly.',
|
|
38
|
+
'After making changes, verify them by reading the affected files again.',
|
|
39
|
+
(
|
|
40
|
+
'Use search_files to locate code instead of guessing or reading '
|
|
41
|
+
'many files blindly.'
|
|
42
|
+
),
|
|
43
|
+
'Use git_status and git_diff to check what has changed before and after editing.',
|
|
44
|
+
(
|
|
45
|
+
'To run tests, linters, or other commands use run_command, '
|
|
46
|
+
'but only when it is actually needed.'
|
|
47
|
+
),
|
|
48
|
+
(
|
|
49
|
+
'Once the request is complete, stop calling tools and respond with '
|
|
50
|
+
'your final answer as plain text, never as a tool call.'
|
|
51
|
+
),
|
|
52
|
+
]
|
|
53
|
+
)
|
|
54
|
+
.prompt(
|
|
55
|
+
_narration_section(
|
|
56
|
+
examples=[
|
|
57
|
+
'"Let me check the current git status."',
|
|
58
|
+
'"Reading the test file to understand it."',
|
|
59
|
+
]
|
|
60
|
+
)
|
|
61
|
+
)
|
|
62
|
+
.prompt(
|
|
63
|
+
_tool_calling_section(
|
|
64
|
+
never_paste_text=(
|
|
65
|
+
'Never paste tool arguments or your answer as a javascript or JSON '
|
|
66
|
+
'code block in your message text.'
|
|
67
|
+
)
|
|
68
|
+
)
|
|
69
|
+
)
|
|
70
|
+
)
|