Class: Pikuri::Workspace::Confirmer

Inherits:
Object
  • Object
show all
Defined in:
lib/pikuri/workspace/confirmer.rb

Overview

Port for asking the user to confirm a potentially destructive tool operation — currently Code::Bash (every command) and Write (overwrite of an existing file with non-identical content). Subclass and implement #confirm?.

Why a Boolean return

v1 returns true or false. Two paths-not-taken worth recording so a future reader knows the design space was considered:

  1. Richer return (:once / :always / :reject) — rejected because it creates decision fatigue, and the long-term answer is to make confirmations rare rather than smart (sandboxing, agentic destructiveness analysis).

  2. Agentic destructive-or-not classifier — deferred to v2.

The intended escape from confirmation prompts today is sandboxing (docker / dev-container) plus the --yolo flag on bin/pikuri-code (which wires AUTO_APPROVE instead of TERMINAL).

Seam discipline

Tools that need confirmation take a Confirmer via constructor and invoke #confirm? with a semantic Requestwhat is being asked, never how it should look. All presentation belongs to the confirmer implementation: color, the answer cue, answer parsing, and — security-relevant — neutralizing hostile bytes in LLM-supplied text. The chrome-independent half of that (escape control bytes, flag bidi / zero-width / homoglyph spoofs) is the shared Sanitizer; the medium-specific half stays with the renderer that knows its medium (a terminal prints the sanitized text directly; a web client wraps it in HTML-escaping). Tools do not call gets / puts directly — same lesson as listeners, keep IO at the seam so a TUI / web client can plug a different implementation in without touching tool code.

Direct Known Subclasses

AutoApprove, Terminal

Defined Under Namespace

Classes: AutoApprove, Request, Terminal

Constant Summary collapse

TERMINAL =

Shared singleton instance of Terminal. Stateless; reusable across tools and sub-agents.

Terminal.new
AUTO_APPROVE =

Shared singleton instance of AutoApprove.

AutoApprove.new

Instance Method Summary collapse

Instance Method Details

#confirm?(request:) ⇒ Boolean

Returns true iff approved.

Parameters:

  • request (Request)

    semantic content composed by the calling tool. The confirmer renders it (escaping for its medium), poses the question, and parses the answer.

Returns:

  • (Boolean)

    true iff approved

Raises:

  • (NotImplementedError)

    in the abstract base



71
72
73
# File 'lib/pikuri/workspace/confirmer.rb', line 71

def confirm?(request:)
  raise NotImplementedError, "#{self.class}#confirm? must be implemented"
end