Class: Insika::Commands::WriteSkill
- Inherits:
-
Object
- Object
- Insika::Commands::WriteSkill
- Defined in:
- lib/insika/commands/write_skill.rb
Overview
Control command: writes a shared skill (complete SKILL.md) into the SkillStore and RELOADS the catalog — takes effect without a restart (hot). Validates the frontmatter (name required) before writing. -> { name, updated_at }.
Instance Method Summary collapse
- #call(command) ⇒ Object
-
#initialize(skill_store:, skill_catalog:, event_stream:) ⇒ WriteSkill
constructor
A new instance of WriteSkill.
Constructor Details
#initialize(skill_store:, skill_catalog:, event_stream:) ⇒ WriteSkill
Returns a new instance of WriteSkill.
13 14 15 16 17 |
# File 'lib/insika/commands/write_skill.rb', line 13 def initialize(skill_store:, skill_catalog:, event_stream:) @skill_store = skill_store @skill_catalog = skill_catalog @event_stream = event_stream end |
Instance Method Details
#call(command) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/insika/commands/write_skill.rb', line 19 def call(command) p = AgentPayload.symbolize(command.payload) name = AgentPayload.presence(p[:name]) content = p[:content].to_s raise Insika::ValidationError, "name is required" if name.nil? validate_frontmatter!(content) rec = @skill_store.write(name, content, create_only: !!p[:create_only]) @skill_catalog.reload @event_stream.emit(Insika::Event.new( type: :skill_written, data: { name: name }, meta: { at: Time.now.utc.iso8601 } )) { name: name, updated_at: rec["updated_at"] } end |