Class: Pikuri::Tasks::Completed

Inherits:
Pikuri::Tool
  • Object
show all
Defined in:
lib/pikuri/tasks/completed.rb

Overview

The task_completed tool: mark the item with the given id as completed. Same shape and rationale as InProgress — the status is baked into the tool name to remove the enum-typo failure mode (+“completed”+ / “complete” / “done”), and the item is addressed by the numeric #id from the rendered list.

Returns the rendered current list via List#render on success. On a bad id returns “Error: no such task id: <id>” plus the current list, so the LLM can pick the right id in one turn.

Constant Summary collapse

DESCRIPTION =

Returns:

  • (String)
<<~DESC
  Mark a task as `completed` once the work — including any required verification — is actually done.

  Usage:
  - Pass the task's numeric `id` as shown in the rendered list (`- #3 [in_progress] ...` → id 3).
  - Do NOT mark `completed` based on intent; mark it only after the underlying work is verified.
  - If the work is partially done or blocked, leave the task `in_progress` and add a follow-up via `task_create`.
  - On `Error: no such task id: ...` the call did nothing — the error includes the current list; pick the right id from it.
  - On success the full current list is returned for you to read back.
DESC

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(list:) ⇒ Completed

Parameters:



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/pikuri/tasks/completed.rb', line 29

def initialize(list:)
  super(
    name: 'task_completed',
    description: DESCRIPTION,
    parameters: Pikuri::Tool::Parameters.build { |p|
      p.required_integer :id,
                         'Numeric id of the existing task to mark as ' \
                         'completed, as shown in the rendered list, e.g. 3.'
    },
    execute: lambda { |id:|
      Completed.execute(list: list, id: id)
    }
  )
end

Class Method Details

.execute(list:, id:) ⇒ String

Parameters:

  • list (List)
  • id (Integer)

Returns:

  • (String)


47
48
49
50
51
52
# File 'lib/pikuri/tasks/completed.rb', line 47

def self.execute(list:, id:)
  list.set_status(id: id, status: 'completed')
  list.render
rescue ItemNotFound
  "Error: no such task id: #{id}. Current list:\n#{list.render}"
end