code-puppy 0.0.287__py3-none-any.whl → 0.0.323__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. code_puppy/__init__.py +3 -1
  2. code_puppy/agents/agent_code_puppy.py +5 -4
  3. code_puppy/agents/agent_creator_agent.py +22 -18
  4. code_puppy/agents/agent_manager.py +2 -2
  5. code_puppy/agents/base_agent.py +496 -102
  6. code_puppy/callbacks.py +8 -0
  7. code_puppy/chatgpt_codex_client.py +283 -0
  8. code_puppy/cli_runner.py +795 -0
  9. code_puppy/command_line/add_model_menu.py +19 -16
  10. code_puppy/command_line/attachments.py +10 -5
  11. code_puppy/command_line/autosave_menu.py +269 -41
  12. code_puppy/command_line/colors_menu.py +515 -0
  13. code_puppy/command_line/command_handler.py +10 -24
  14. code_puppy/command_line/config_commands.py +106 -25
  15. code_puppy/command_line/core_commands.py +32 -20
  16. code_puppy/command_line/mcp/add_command.py +3 -16
  17. code_puppy/command_line/mcp/base.py +0 -3
  18. code_puppy/command_line/mcp/catalog_server_installer.py +15 -15
  19. code_puppy/command_line/mcp/custom_server_form.py +66 -5
  20. code_puppy/command_line/mcp/custom_server_installer.py +17 -17
  21. code_puppy/command_line/mcp/edit_command.py +15 -22
  22. code_puppy/command_line/mcp/handler.py +7 -2
  23. code_puppy/command_line/mcp/help_command.py +2 -2
  24. code_puppy/command_line/mcp/install_command.py +10 -14
  25. code_puppy/command_line/mcp/install_menu.py +2 -6
  26. code_puppy/command_line/mcp/list_command.py +2 -2
  27. code_puppy/command_line/mcp/logs_command.py +174 -65
  28. code_puppy/command_line/mcp/remove_command.py +2 -2
  29. code_puppy/command_line/mcp/restart_command.py +7 -2
  30. code_puppy/command_line/mcp/search_command.py +16 -10
  31. code_puppy/command_line/mcp/start_all_command.py +16 -6
  32. code_puppy/command_line/mcp/start_command.py +12 -10
  33. code_puppy/command_line/mcp/status_command.py +4 -5
  34. code_puppy/command_line/mcp/stop_all_command.py +5 -1
  35. code_puppy/command_line/mcp/stop_command.py +6 -4
  36. code_puppy/command_line/mcp/test_command.py +2 -2
  37. code_puppy/command_line/mcp/wizard_utils.py +20 -16
  38. code_puppy/command_line/model_settings_menu.py +53 -7
  39. code_puppy/command_line/motd.py +1 -1
  40. code_puppy/command_line/pin_command_completion.py +82 -7
  41. code_puppy/command_line/prompt_toolkit_completion.py +32 -9
  42. code_puppy/command_line/session_commands.py +11 -4
  43. code_puppy/config.py +217 -53
  44. code_puppy/error_logging.py +118 -0
  45. code_puppy/gemini_code_assist.py +385 -0
  46. code_puppy/keymap.py +126 -0
  47. code_puppy/main.py +5 -745
  48. code_puppy/mcp_/__init__.py +17 -0
  49. code_puppy/mcp_/blocking_startup.py +63 -36
  50. code_puppy/mcp_/captured_stdio_server.py +1 -1
  51. code_puppy/mcp_/config_wizard.py +4 -4
  52. code_puppy/mcp_/dashboard.py +15 -6
  53. code_puppy/mcp_/managed_server.py +25 -5
  54. code_puppy/mcp_/manager.py +65 -0
  55. code_puppy/mcp_/mcp_logs.py +224 -0
  56. code_puppy/mcp_/registry.py +6 -6
  57. code_puppy/messaging/__init__.py +184 -2
  58. code_puppy/messaging/bus.py +610 -0
  59. code_puppy/messaging/commands.py +167 -0
  60. code_puppy/messaging/markdown_patches.py +57 -0
  61. code_puppy/messaging/message_queue.py +3 -3
  62. code_puppy/messaging/messages.py +470 -0
  63. code_puppy/messaging/renderers.py +43 -141
  64. code_puppy/messaging/rich_renderer.py +900 -0
  65. code_puppy/messaging/spinner/console_spinner.py +39 -2
  66. code_puppy/model_factory.py +292 -53
  67. code_puppy/model_utils.py +57 -48
  68. code_puppy/models.json +19 -5
  69. code_puppy/plugins/__init__.py +152 -10
  70. code_puppy/plugins/chatgpt_oauth/config.py +20 -12
  71. code_puppy/plugins/chatgpt_oauth/oauth_flow.py +5 -6
  72. code_puppy/plugins/chatgpt_oauth/register_callbacks.py +3 -3
  73. code_puppy/plugins/chatgpt_oauth/test_plugin.py +30 -13
  74. code_puppy/plugins/chatgpt_oauth/utils.py +180 -65
  75. code_puppy/plugins/claude_code_oauth/config.py +15 -11
  76. code_puppy/plugins/claude_code_oauth/register_callbacks.py +28 -0
  77. code_puppy/plugins/claude_code_oauth/utils.py +6 -1
  78. code_puppy/plugins/example_custom_command/register_callbacks.py +2 -2
  79. code_puppy/plugins/oauth_puppy_html.py +3 -0
  80. code_puppy/plugins/shell_safety/agent_shell_safety.py +1 -134
  81. code_puppy/plugins/shell_safety/command_cache.py +156 -0
  82. code_puppy/plugins/shell_safety/register_callbacks.py +77 -3
  83. code_puppy/prompts/codex_system_prompt.md +310 -0
  84. code_puppy/pydantic_patches.py +131 -0
  85. code_puppy/session_storage.py +2 -1
  86. code_puppy/status_display.py +7 -5
  87. code_puppy/terminal_utils.py +126 -0
  88. code_puppy/tools/agent_tools.py +131 -70
  89. code_puppy/tools/browser/browser_control.py +10 -14
  90. code_puppy/tools/browser/browser_interactions.py +20 -28
  91. code_puppy/tools/browser/browser_locators.py +27 -29
  92. code_puppy/tools/browser/browser_navigation.py +9 -9
  93. code_puppy/tools/browser/browser_screenshot.py +12 -14
  94. code_puppy/tools/browser/browser_scripts.py +17 -29
  95. code_puppy/tools/browser/browser_workflows.py +24 -25
  96. code_puppy/tools/browser/camoufox_manager.py +22 -26
  97. code_puppy/tools/command_runner.py +410 -88
  98. code_puppy/tools/common.py +51 -38
  99. code_puppy/tools/file_modifications.py +98 -24
  100. code_puppy/tools/file_operations.py +113 -202
  101. code_puppy/version_checker.py +28 -13
  102. {code_puppy-0.0.287.data → code_puppy-0.0.323.data}/data/code_puppy/models.json +19 -5
  103. {code_puppy-0.0.287.dist-info → code_puppy-0.0.323.dist-info}/METADATA +3 -8
  104. code_puppy-0.0.323.dist-info/RECORD +168 -0
  105. code_puppy/tui_state.py +0 -55
  106. code_puppy-0.0.287.dist-info/RECORD +0 -153
  107. {code_puppy-0.0.287.data → code_puppy-0.0.323.data}/data/code_puppy/models_dev_api.json +0 -0
  108. {code_puppy-0.0.287.dist-info → code_puppy-0.0.323.dist-info}/WHEEL +0 -0
  109. {code_puppy-0.0.287.dist-info → code_puppy-0.0.323.dist-info}/entry_points.txt +0 -0
  110. {code_puppy-0.0.287.dist-info → code_puppy-0.0.323.dist-info}/licenses/LICENSE +0 -0
@@ -12,6 +12,7 @@ import uuid
12
12
  from pathlib import Path
13
13
  from typing import Dict, List, Optional
14
14
 
15
+ from code_puppy import config
15
16
  from .managed_server import ServerConfig
16
17
 
17
18
  # Configure logging
@@ -23,7 +24,7 @@ class ServerRegistry:
23
24
  Registry for managing MCP server configurations.
24
25
 
25
26
  Provides CRUD operations for server configurations with thread-safe access,
26
- validation, and persistent storage to ~/.code_puppy/mcp_registry.json.
27
+ validation, and persistent storage to XDG_DATA_HOME/code_puppy/mcp_registry.json.
27
28
 
28
29
  All operations are thread-safe and use JSON serialization for ServerConfig objects.
29
30
  Handles file not existing gracefully and validates configurations according to
@@ -36,13 +37,12 @@ class ServerRegistry:
36
37
 
37
38
  Args:
38
39
  storage_path: Optional custom path for registry storage.
39
- Defaults to ~/.code_puppy/mcp_registry.json
40
+ Defaults to XDG_DATA_HOME/code_puppy/mcp_registry.json
40
41
  """
41
42
  if storage_path is None:
42
- home_dir = Path.home()
43
- code_puppy_dir = home_dir / ".code_puppy"
44
- code_puppy_dir.mkdir(exist_ok=True)
45
- self._storage_path = code_puppy_dir / "mcp_registry.json"
43
+ data_dir = Path(config.DATA_DIR)
44
+ data_dir.mkdir(parents=True, exist_ok=True, mode=0o700)
45
+ self._storage_path = data_dir / "mcp_registry.json"
46
46
  else:
47
47
  self._storage_path = Path(storage_path)
48
48
 
@@ -1,3 +1,71 @@
1
+ """Code Puppy Messaging System.
2
+
3
+ This package provides both the legacy messaging API and the new structured
4
+ messaging system.
5
+
6
+ Legacy API (backward compatible):
7
+ - emit_info(), emit_warning(), emit_error(), etc.
8
+ - MessageQueue, UIMessage, MessageType
9
+ - Used by existing code throughout the codebase
10
+
11
+ New Structured Messaging API:
12
+ - MessageBus for bidirectional Agent <-> UI communication
13
+ - Pydantic message models (TextMessage, DiffMessage, etc.)
14
+ - Command models for UI -> Agent communication
15
+ - RichConsoleRenderer for presentation
16
+
17
+ Example (legacy):
18
+ >>> from code_puppy.messaging import emit_info, emit_error
19
+ >>> emit_info("Operation complete")
20
+ >>> emit_error("Something went wrong")
21
+
22
+ Example (new):
23
+ >>> from code_puppy.messaging import (
24
+ ... MessageBus, get_message_bus,
25
+ ... TextMessage, MessageLevel,
26
+ ... RichConsoleRenderer,
27
+ ... )
28
+ >>> bus = get_message_bus()
29
+ >>> bus.emit(TextMessage(level=MessageLevel.INFO, text="Hello"))
30
+ """
31
+
32
+ # =============================================================================
33
+ # Apply Rich Markdown patches (left-justified headers)
34
+ # =============================================================================
35
+ from .markdown_patches import patch_markdown_headings
36
+
37
+ patch_markdown_headings()
38
+
39
+ # =============================================================================
40
+ # Legacy API (backward compatible)
41
+ # =============================================================================
42
+
43
+ # Message bus
44
+ from .bus import (
45
+ MessageBus,
46
+ emit_shell_line,
47
+ get_message_bus,
48
+ get_session_context,
49
+ reset_message_bus,
50
+ set_session_context,
51
+ )
52
+ from .bus import emit as bus_emit # Convenience functions (new API versions)
53
+ from .bus import emit_debug as bus_emit_debug
54
+ from .bus import emit_error as bus_emit_error
55
+ from .bus import emit_info as bus_emit_info
56
+ from .bus import emit_success as bus_emit_success
57
+ from .bus import emit_warning as bus_emit_warning
58
+
59
+ # Command types (UI -> Agent)
60
+ from .commands import ( # Base; Agent control; User interaction responses; Union type
61
+ AnyCommand,
62
+ BaseCommand,
63
+ CancelAgentCommand,
64
+ ConfirmationResponse,
65
+ InterruptShellCommand,
66
+ SelectionResponse,
67
+ UserInputResponse,
68
+ )
1
69
  from .message_queue import (
2
70
  MessageQueue,
3
71
  MessageType,
@@ -19,14 +87,66 @@ from .message_queue import (
19
87
  get_global_queue,
20
88
  provide_prompt_response,
21
89
  )
90
+
91
+ # Message types and enums
92
+ from .messages import ( # Enums, Base, Text, File ops, Diff, Shell, Agent, etc.
93
+ AgentReasoningMessage,
94
+ AgentResponseMessage,
95
+ AnyMessage,
96
+ BaseMessage,
97
+ ConfirmationRequest,
98
+ DiffLine,
99
+ DiffMessage,
100
+ DividerMessage,
101
+ FileContentMessage,
102
+ FileEntry,
103
+ FileListingMessage,
104
+ GrepMatch,
105
+ GrepResultMessage,
106
+ MessageCategory,
107
+ MessageLevel,
108
+ SelectionRequest,
109
+ ShellLineMessage,
110
+ ShellOutputMessage,
111
+ ShellStartMessage,
112
+ SpinnerControl,
113
+ StatusPanelMessage,
114
+ SubAgentInvocationMessage,
115
+ SubAgentResponseMessage,
116
+ TextMessage,
117
+ UserInputRequest,
118
+ VersionCheckMessage,
119
+ )
22
120
  from .queue_console import QueueConsole, get_queue_console
23
- from .renderers import InteractiveRenderer, SynchronousInteractiveRenderer, TUIRenderer
121
+ from .renderers import InteractiveRenderer, SynchronousInteractiveRenderer
122
+
123
+ # Renderer
124
+ from .rich_renderer import (
125
+ DEFAULT_STYLES,
126
+ DIFF_STYLES,
127
+ RendererProtocol,
128
+ RichConsoleRenderer,
129
+ )
130
+
131
+ # =============================================================================
132
+ # New Structured Messaging API
133
+ # =============================================================================
134
+
135
+
136
+ # =============================================================================
137
+ # Export all public symbols
138
+ # =============================================================================
24
139
 
25
140
  __all__ = [
141
+ # -------------------------------------------------------------------------
142
+ # Legacy API (backward compatible)
143
+ # -------------------------------------------------------------------------
144
+ # Message queue
26
145
  "MessageQueue",
27
146
  "MessageType",
28
147
  "UIMessage",
29
148
  "get_global_queue",
149
+ # Legacy emit functions
30
150
  "emit_message",
31
151
  "emit_info",
32
152
  "emit_success",
@@ -42,9 +162,71 @@ __all__ = [
42
162
  "emit_prompt",
43
163
  "provide_prompt_response",
44
164
  "get_buffered_startup_messages",
165
+ # Legacy renderers
45
166
  "InteractiveRenderer",
46
- "TUIRenderer",
47
167
  "SynchronousInteractiveRenderer",
48
168
  "QueueConsole",
49
169
  "get_queue_console",
170
+ # -------------------------------------------------------------------------
171
+ # New Structured Messaging API
172
+ # -------------------------------------------------------------------------
173
+ # Enums
174
+ "MessageLevel",
175
+ "MessageCategory",
176
+ # Base classes
177
+ "BaseMessage",
178
+ "BaseCommand",
179
+ # Message types
180
+ "TextMessage",
181
+ "FileEntry",
182
+ "FileListingMessage",
183
+ "FileContentMessage",
184
+ "GrepMatch",
185
+ "GrepResultMessage",
186
+ "DiffLine",
187
+ "DiffMessage",
188
+ "ShellStartMessage",
189
+ "ShellLineMessage",
190
+ "ShellOutputMessage",
191
+ "emit_shell_line",
192
+ "AgentReasoningMessage",
193
+ "AgentResponseMessage",
194
+ "SubAgentInvocationMessage",
195
+ "SubAgentResponseMessage",
196
+ "UserInputRequest",
197
+ "ConfirmationRequest",
198
+ "SelectionRequest",
199
+ "SpinnerControl",
200
+ "DividerMessage",
201
+ "StatusPanelMessage",
202
+ "VersionCheckMessage",
203
+ "AnyMessage",
204
+ # Command types
205
+ "CancelAgentCommand",
206
+ "InterruptShellCommand",
207
+ "UserInputResponse",
208
+ "ConfirmationResponse",
209
+ "SelectionResponse",
210
+ "AnyCommand",
211
+ # Message bus
212
+ "MessageBus",
213
+ "get_message_bus",
214
+ "reset_message_bus",
215
+ # Session context
216
+ "set_session_context",
217
+ "get_session_context",
218
+ # New API convenience functions (prefixed to avoid collision)
219
+ "bus_emit",
220
+ "bus_emit_info",
221
+ "bus_emit_warning",
222
+ "bus_emit_error",
223
+ "bus_emit_success",
224
+ "bus_emit_debug",
225
+ # Renderer
226
+ "RendererProtocol",
227
+ "RichConsoleRenderer",
228
+ "DEFAULT_STYLES",
229
+ "DIFF_STYLES",
230
+ # Markdown patches
231
+ "patch_markdown_headings",
50
232
  ]