ripperdoc 0.1.0__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 (81) hide show
  1. ripperdoc/__init__.py +3 -0
  2. ripperdoc/__main__.py +25 -0
  3. ripperdoc/cli/__init__.py +1 -0
  4. ripperdoc/cli/cli.py +317 -0
  5. ripperdoc/cli/commands/__init__.py +76 -0
  6. ripperdoc/cli/commands/agents_cmd.py +234 -0
  7. ripperdoc/cli/commands/base.py +19 -0
  8. ripperdoc/cli/commands/clear_cmd.py +18 -0
  9. ripperdoc/cli/commands/compact_cmd.py +19 -0
  10. ripperdoc/cli/commands/config_cmd.py +31 -0
  11. ripperdoc/cli/commands/context_cmd.py +114 -0
  12. ripperdoc/cli/commands/cost_cmd.py +77 -0
  13. ripperdoc/cli/commands/exit_cmd.py +19 -0
  14. ripperdoc/cli/commands/help_cmd.py +20 -0
  15. ripperdoc/cli/commands/mcp_cmd.py +65 -0
  16. ripperdoc/cli/commands/models_cmd.py +327 -0
  17. ripperdoc/cli/commands/resume_cmd.py +97 -0
  18. ripperdoc/cli/commands/status_cmd.py +167 -0
  19. ripperdoc/cli/commands/tasks_cmd.py +240 -0
  20. ripperdoc/cli/commands/todos_cmd.py +69 -0
  21. ripperdoc/cli/commands/tools_cmd.py +19 -0
  22. ripperdoc/cli/ui/__init__.py +1 -0
  23. ripperdoc/cli/ui/context_display.py +297 -0
  24. ripperdoc/cli/ui/helpers.py +22 -0
  25. ripperdoc/cli/ui/rich_ui.py +1010 -0
  26. ripperdoc/cli/ui/spinner.py +50 -0
  27. ripperdoc/core/__init__.py +1 -0
  28. ripperdoc/core/agents.py +306 -0
  29. ripperdoc/core/commands.py +33 -0
  30. ripperdoc/core/config.py +382 -0
  31. ripperdoc/core/default_tools.py +57 -0
  32. ripperdoc/core/permissions.py +227 -0
  33. ripperdoc/core/query.py +682 -0
  34. ripperdoc/core/system_prompt.py +418 -0
  35. ripperdoc/core/tool.py +214 -0
  36. ripperdoc/sdk/__init__.py +9 -0
  37. ripperdoc/sdk/client.py +309 -0
  38. ripperdoc/tools/__init__.py +1 -0
  39. ripperdoc/tools/background_shell.py +291 -0
  40. ripperdoc/tools/bash_output_tool.py +98 -0
  41. ripperdoc/tools/bash_tool.py +822 -0
  42. ripperdoc/tools/file_edit_tool.py +281 -0
  43. ripperdoc/tools/file_read_tool.py +168 -0
  44. ripperdoc/tools/file_write_tool.py +141 -0
  45. ripperdoc/tools/glob_tool.py +134 -0
  46. ripperdoc/tools/grep_tool.py +232 -0
  47. ripperdoc/tools/kill_bash_tool.py +136 -0
  48. ripperdoc/tools/ls_tool.py +298 -0
  49. ripperdoc/tools/mcp_tools.py +804 -0
  50. ripperdoc/tools/multi_edit_tool.py +393 -0
  51. ripperdoc/tools/notebook_edit_tool.py +325 -0
  52. ripperdoc/tools/task_tool.py +282 -0
  53. ripperdoc/tools/todo_tool.py +362 -0
  54. ripperdoc/tools/tool_search_tool.py +366 -0
  55. ripperdoc/utils/__init__.py +1 -0
  56. ripperdoc/utils/bash_constants.py +51 -0
  57. ripperdoc/utils/bash_output_utils.py +43 -0
  58. ripperdoc/utils/exit_code_handlers.py +241 -0
  59. ripperdoc/utils/log.py +76 -0
  60. ripperdoc/utils/mcp.py +427 -0
  61. ripperdoc/utils/memory.py +239 -0
  62. ripperdoc/utils/message_compaction.py +640 -0
  63. ripperdoc/utils/messages.py +399 -0
  64. ripperdoc/utils/output_utils.py +233 -0
  65. ripperdoc/utils/path_utils.py +46 -0
  66. ripperdoc/utils/permissions/__init__.py +21 -0
  67. ripperdoc/utils/permissions/path_validation_utils.py +165 -0
  68. ripperdoc/utils/permissions/shell_command_validation.py +74 -0
  69. ripperdoc/utils/permissions/tool_permission_utils.py +279 -0
  70. ripperdoc/utils/safe_get_cwd.py +24 -0
  71. ripperdoc/utils/sandbox_utils.py +38 -0
  72. ripperdoc/utils/session_history.py +223 -0
  73. ripperdoc/utils/session_usage.py +110 -0
  74. ripperdoc/utils/shell_token_utils.py +95 -0
  75. ripperdoc/utils/todo.py +199 -0
  76. ripperdoc-0.1.0.dist-info/METADATA +178 -0
  77. ripperdoc-0.1.0.dist-info/RECORD +81 -0
  78. ripperdoc-0.1.0.dist-info/WHEEL +5 -0
  79. ripperdoc-0.1.0.dist-info/entry_points.txt +3 -0
  80. ripperdoc-0.1.0.dist-info/licenses/LICENSE +53 -0
  81. ripperdoc-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,362 @@
1
+ """Todo management tools."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import AsyncGenerator, List, Optional
6
+ from textwrap import dedent
7
+ from pydantic import BaseModel, Field
8
+
9
+ from ripperdoc.core.tool import (
10
+ Tool,
11
+ ToolUseContext,
12
+ ToolResult,
13
+ ToolOutput,
14
+ ToolUseExample,
15
+ ValidationResult,
16
+ )
17
+ from ripperdoc.utils.todo import (
18
+ TodoItem,
19
+ TodoPriority,
20
+ TodoStatus,
21
+ format_todo_lines,
22
+ format_todo_summary,
23
+ get_next_actionable,
24
+ load_todos,
25
+ set_todos,
26
+ summarize_todos,
27
+ validate_todos,
28
+ )
29
+
30
+ TODO_WRITE_PROMPT = dedent(
31
+ """\
32
+ Use this tool to create and manage a structured task list for your current coding session. This helps you track progress, organize complex tasks, and demonstrate thoroughness to the user. It also helps the user understand the progress of the task and overall progress of their requests.
33
+
34
+ ## When to Use This Tool
35
+ Use this tool proactively in these scenarios:
36
+
37
+ 1. Complex multi-step tasks - When a task requires 3 or more distinct steps or actions
38
+ 2. Non-trivial and complex tasks - Tasks that require careful planning or multiple operations
39
+ 3. User explicitly requests todo list - When the user directly asks you to use the todo list
40
+ 4. User provides multiple tasks - When users provide a list of things to be done (numbered or comma-separated)
41
+ 5. After receiving new instructions - Immediately capture user requirements as todos
42
+ 6. When you start working on a task - Mark it as in_progress BEFORE beginning work. Ideally you should only have one todo as in_progress at a time
43
+ 7. After completing a task - Mark it as completed and add any new follow-up tasks discovered during implementation
44
+
45
+ ## When NOT to Use This Tool
46
+
47
+ Skip using this tool when:
48
+ 1. There is only a single, straightforward task
49
+ 2. The task is trivial and tracking it provides no organizational benefit
50
+ 3. The task can be completed in less than 3 trivial steps
51
+ 4. The task is purely conversational or informational
52
+
53
+ NOTE that you should not use this tool if there is only one trivial task to do. In this case you are better off just doing the task directly.
54
+
55
+ ## Task States and Management
56
+
57
+ 1. Task States:
58
+ - pending: Task not yet started
59
+ - in_progress: Currently working on (limit to ONE task at a time)
60
+ - completed: Task finished successfully
61
+
62
+ 2. Task Management:
63
+ - Update task status in real-time as you work
64
+ - Mark tasks complete IMMEDIATELY after finishing (don't batch completions)
65
+ - Only have ONE task in_progress at any time
66
+ - Complete current tasks before starting new ones
67
+ - Remove tasks that are no longer relevant from the list entirely
68
+
69
+ 3. Task Completion Requirements:
70
+ - ONLY mark a task as completed when you have FULLY accomplished it
71
+ - If you encounter errors, blockers, or cannot finish, keep the task as in_progress
72
+ - When blocked, create a new task describing what needs to be resolved
73
+ - Never mark a task as completed if tests are failing, implementation is partial, errors are unresolved, or needed files are missing
74
+
75
+ 4. Task Breakdown:
76
+ - Create specific, actionable items
77
+ - Break complex tasks into smaller, manageable steps
78
+ - Use clear, descriptive task names
79
+
80
+ When in doubt, use this tool. Being proactive with task management demonstrates attentiveness and ensures you complete all requirements successfully.
81
+ """
82
+ )
83
+
84
+
85
+ class TodoInputItem(BaseModel):
86
+ """Single todo input payload."""
87
+
88
+ content: str = Field(description="Task description")
89
+ status: TodoStatus = Field(default="pending", description="pending|in_progress|completed")
90
+ priority: TodoPriority = Field(default="medium", description="high|medium|low")
91
+ id: str = Field(description="Unique identifier for the task")
92
+
93
+
94
+ class TodoWriteToolInput(BaseModel):
95
+ """Input for updating the todo list."""
96
+
97
+ todos: list[TodoInputItem] = Field(description="Complete todo list to persist")
98
+
99
+
100
+ class TodoReadToolInput(BaseModel):
101
+ """Input for reading the todo list."""
102
+
103
+ status: Optional[list[TodoStatus]] = Field(
104
+ default=None, description="Filter by status; omit for all todos"
105
+ )
106
+ limit: int = Field(
107
+ default=0,
108
+ description="Optional limit for the number of todos to return; 0 returns all matches",
109
+ )
110
+ next_only: bool = Field(
111
+ default=False,
112
+ description="Return only the next actionable todo (in_progress first, then pending)",
113
+ )
114
+
115
+
116
+ class TodoToolOutput(BaseModel):
117
+ """Common output for todo operations."""
118
+
119
+ todos: list[TodoItem]
120
+ summary: str
121
+ stats: dict
122
+ next_todo: Optional[TodoItem] = None
123
+
124
+
125
+ class TodoWriteTool(Tool[TodoWriteToolInput, TodoToolOutput]):
126
+ """Create or update the todo list."""
127
+
128
+ @property
129
+ def name(self) -> str:
130
+ return "TodoWrite"
131
+
132
+ async def description(self) -> str:
133
+ return "Create and update a structured task list for the current session."
134
+
135
+ @property
136
+ def input_schema(self) -> type[TodoWriteToolInput]:
137
+ return TodoWriteToolInput
138
+
139
+ def input_examples(self) -> List[ToolUseExample]:
140
+ return [
141
+ ToolUseExample(
142
+ description="Seed a three-step plan",
143
+ input={
144
+ "todos": [
145
+ {
146
+ "id": "plan",
147
+ "content": "Review existing API docs",
148
+ "status": "pending",
149
+ "priority": "medium",
150
+ },
151
+ {
152
+ "id": "impl",
153
+ "content": "Implement new endpoint",
154
+ "status": "pending",
155
+ "priority": "high",
156
+ },
157
+ {
158
+ "id": "tests",
159
+ "content": "Add integration tests",
160
+ "status": "pending",
161
+ "priority": "high",
162
+ },
163
+ ]
164
+ },
165
+ ),
166
+ ToolUseExample(
167
+ description="Update a single task already in progress",
168
+ input={
169
+ "todos": [
170
+ {
171
+ "id": "bugfix-123",
172
+ "content": "Fix login redirect loop",
173
+ "status": "in_progress",
174
+ "priority": "high",
175
+ }
176
+ ]
177
+ },
178
+ ),
179
+ ]
180
+
181
+ async def prompt(self, safe_mode: bool = False) -> str:
182
+ return TODO_WRITE_PROMPT
183
+
184
+ def is_read_only(self) -> bool:
185
+ return False
186
+
187
+ def is_concurrency_safe(self) -> bool:
188
+ return False
189
+
190
+ def needs_permissions(self, input_data: Optional[TodoWriteToolInput] = None) -> bool:
191
+ return False
192
+
193
+ async def validate_input(
194
+ self,
195
+ input_data: TodoWriteToolInput,
196
+ context: Optional[ToolUseContext] = None,
197
+ ) -> ValidationResult:
198
+ todos = [TodoItem(**todo.model_dump()) for todo in input_data.todos]
199
+ ok, message = validate_todos(todos)
200
+ if not ok:
201
+ return ValidationResult(result=False, message=message)
202
+ return ValidationResult(result=True)
203
+
204
+ def render_result_for_assistant(self, output: TodoToolOutput) -> str:
205
+ return output.summary
206
+
207
+ def render_tool_use_message(
208
+ self,
209
+ input_data: TodoWriteToolInput,
210
+ verbose: bool = False,
211
+ ) -> str:
212
+ return f"Updating todo list with {len(input_data.todos)} item(s)"
213
+
214
+ async def call(
215
+ self,
216
+ input_data: TodoWriteToolInput,
217
+ context: ToolUseContext,
218
+ ) -> AsyncGenerator[ToolOutput, None]:
219
+ try:
220
+ todos = [TodoItem(**todo.model_dump()) for todo in input_data.todos]
221
+ updated = set_todos(todos)
222
+ summary = format_todo_summary(updated)
223
+ lines = format_todo_lines(updated)
224
+ result_text = "\n".join([summary, *lines]) if lines else summary
225
+ output = TodoToolOutput(
226
+ todos=updated,
227
+ summary=summary,
228
+ stats=summarize_todos(updated),
229
+ next_todo=get_next_actionable(updated),
230
+ )
231
+ yield ToolResult(data=output, result_for_assistant=result_text)
232
+ except Exception as exc:
233
+ error = f"Error updating todos: {exc}"
234
+ yield ToolResult(
235
+ data=TodoToolOutput(
236
+ todos=[],
237
+ summary=error,
238
+ stats={"total": 0, "by_status": {}, "by_priority": {}},
239
+ next_todo=None,
240
+ ),
241
+ result_for_assistant=error,
242
+ )
243
+
244
+
245
+ class TodoReadTool(Tool[TodoReadToolInput, TodoToolOutput]):
246
+ """Read the todo list and pick the next task."""
247
+
248
+ @property
249
+ def name(self) -> str:
250
+ return "TodoRead"
251
+
252
+ async def description(self) -> str:
253
+ return (
254
+ "Reads the stored todo list for this project so you can review tasks, "
255
+ "pick the next item to execute, and update progress."
256
+ )
257
+
258
+ @property
259
+ def input_schema(self) -> type[TodoReadToolInput]:
260
+ return TodoReadToolInput
261
+
262
+ def input_examples(self) -> List[ToolUseExample]:
263
+ return [
264
+ ToolUseExample(
265
+ description="Get only the next actionable todo",
266
+ input={"next_only": True},
267
+ ),
268
+ ToolUseExample(
269
+ description="List recent completed tasks with a limit",
270
+ input={"status": ["completed"], "limit": 5},
271
+ ),
272
+ ]
273
+
274
+ async def prompt(self, safe_mode: bool = False) -> str:
275
+ return (
276
+ "Use TodoRead to fetch the current todo list before making progress or when you need "
277
+ "to confirm the next action. You can request only the next actionable item or filter "
278
+ "by status."
279
+ )
280
+
281
+ def is_read_only(self) -> bool:
282
+ return True
283
+
284
+ def is_concurrency_safe(self) -> bool:
285
+ return True
286
+
287
+ def needs_permissions(self, input_data: Optional[TodoReadToolInput] = None) -> bool:
288
+ return False
289
+
290
+ async def validate_input(
291
+ self,
292
+ input_data: TodoReadToolInput,
293
+ context: Optional[ToolUseContext] = None,
294
+ ) -> ValidationResult:
295
+ if input_data.limit < 0:
296
+ return ValidationResult(result=False, message="limit cannot be negative")
297
+ if input_data.status:
298
+ invalid = [
299
+ status
300
+ for status in input_data.status
301
+ if status not in ("pending", "in_progress", "completed")
302
+ ]
303
+ if invalid:
304
+ return ValidationResult(
305
+ result=False,
306
+ message=f"Invalid status values: {', '.join(invalid)}",
307
+ )
308
+ return ValidationResult(result=True)
309
+
310
+ def render_result_for_assistant(self, output: TodoToolOutput) -> str:
311
+ return output.summary
312
+
313
+ def render_tool_use_message(
314
+ self,
315
+ input_data: TodoReadToolInput,
316
+ verbose: bool = False,
317
+ ) -> str:
318
+ if input_data.next_only:
319
+ return "Reading next actionable todo"
320
+ return "Reading todo list"
321
+
322
+ async def call(
323
+ self,
324
+ input_data: TodoReadToolInput,
325
+ context: ToolUseContext,
326
+ ) -> AsyncGenerator[ToolOutput, None]:
327
+ all_todos = load_todos()
328
+ filtered = all_todos
329
+
330
+ if input_data.status:
331
+ allowed = set(input_data.status)
332
+ filtered = [todo for todo in all_todos if todo.status in allowed]
333
+
334
+ display = filtered
335
+ next_todo = get_next_actionable(filtered)
336
+
337
+ if input_data.next_only:
338
+ display = [next_todo] if next_todo else []
339
+
340
+ if input_data.limit and input_data.limit > 0:
341
+ display = display[: input_data.limit]
342
+
343
+ if not all_todos:
344
+ summary = "No todos stored yet."
345
+ elif input_data.next_only:
346
+ summary = (
347
+ f"Next actionable todo: {next_todo.content} (id: {next_todo.id}, status: {next_todo.status})."
348
+ if next_todo
349
+ else "No actionable todos (none pending or in_progress)."
350
+ )
351
+ else:
352
+ summary = format_todo_summary(filtered)
353
+
354
+ lines = format_todo_lines(display)
355
+ result_text = "\n".join([summary, *lines]) if lines else summary
356
+ output = TodoToolOutput(
357
+ todos=display,
358
+ summary=summary,
359
+ stats=summarize_todos(filtered),
360
+ next_todo=next_todo,
361
+ )
362
+ yield ToolResult(data=output, result_for_assistant=result_text)