Class: Pikuri::Tasks::Delete
- Inherits:
-
Pikuri::Tool
- Object
- Pikuri::Tool
- Pikuri::Tasks::Delete
- Defined in:
- lib/pikuri/tasks/delete.rb
Overview
The task_delete tool: remove the item whose content exactly matches from the list. Used to drop items that turned out to be unnecessary, were created in error, or have been superseded —rather than leaving them sitting in pending as visual noise.
Distinct from Completed: completed means the work was actually done; delete means the task should never have been there. The list itself draws no such distinction once an item is gone, but the LLM picks the right verb because the tool names make the intent clear.
Returns the rendered current list via List#render on success, or “Error: no such task: ‘<content>’” when the content does not match.
Constant Summary collapse
- DESCRIPTION =
<<~DESC Remove a task from the list. Use this for items that turn out not to be needed, were created in error, or have been superseded. Usage: - Pass the exact `content` string the task was created with. - Use `task_completed` (not this) when the work was actually done. - On `Error: no such task: ...` the call did nothing — read the returned list in any subsequent tool's output to pick the right name. - On success the full current list is returned for you to read back. DESC
Class Method Summary collapse
Instance Method Summary collapse
- #initialize(list:) ⇒ Delete constructor
Constructor Details
#initialize(list:) ⇒ Delete
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/pikuri/tasks/delete.rb', line 33 def initialize(list:) super( name: 'task_delete', description: DESCRIPTION, parameters: Pikuri::Tool::Parameters.build { |p| p.required_string :content, 'Exact content of the existing task to remove, ' \ 'e.g. "Add dark mode toggle".' }, execute: lambda { |content:| Delete.execute(list: list, content: content) } ) end |
Class Method Details
.execute(list:, content:) ⇒ String
51 52 53 54 55 56 |
# File 'lib/pikuri/tasks/delete.rb', line 51 def self.execute(list:, content:) list.delete(content) list.render rescue ItemNotFound "Error: no such task: '#{content}'" end |