Skip to content
Kward Search API index

Class: Kward::EditorPromptSession

Inherits:
Object
  • Object
show all
Defined in:
lib/kward/cli/editor_prompt_session.rb

Overview

Transactional draft used while an agent works on an active editor buffer.

The live terminal editor remains owned by PromptInterface. Agent tool calls update this draft and the caller commits it only after a successful turn.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ EditorPromptSession

Returns a new instance of EditorPromptSession.



10
11
12
13
14
# File 'lib/kward/cli/editor_prompt_session.rb', line 10

def initialize(context)
  @context = context.dup
  @initial_content = @context.fetch(:content).to_s.dup
  @content = @initial_content.dup
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



8
9
10
# File 'lib/kward/cli/editor_prompt_session.rb', line 8

def content
  @content
end

#contextObject (readonly)

Returns the value of attribute context.



8
9
10
# File 'lib/kward/cli/editor_prompt_session.rb', line 8

def context
  @context
end

Instance Method Details

#changed?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/kward/cli/editor_prompt_session.rb', line 20

def changed?
  @content != @initial_content
end

#initial_contentObject



24
25
26
# File 'lib/kward/cli/editor_prompt_session.rb', line 24

def initial_content
  @initial_content.dup
end

#replace(content) ⇒ Object



16
17
18
# File 'lib/kward/cli/editor_prompt_session.rb', line 16

def replace(content)
  @content = content.to_s
end