Class: Insika::Commands::WriteSkill
- Inherits:
-
Object
- Object
- Insika::Commands::WriteSkill
- Defined in:
- lib/insika/commands/write_skill.rb
Overview
Control command: writes a 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, agent, updated_at }.
agent (optional) writes into that agent's scope instead of the shared one: the
SPECIALIZATION of a shared skill, or a skill private to one agent. Same name
either way — the store position is the identity, so the frontmatter inside an
override keeps saying the bare shared name and the level-1 catalog, load_skill,
the labels and the events all keep displaying it.
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.
18 19 20 21 22 |
# File 'lib/insika/commands/write_skill.rb', line 18 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
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/insika/commands/write_skill.rb', line 24 def call(command) p = AgentPayload.symbolize(command.payload) name = AgentPayload.presence(p[:name]) agent = AgentPayload.presence(p[:agent]) content = p[:content].to_s raise Insika::ValidationError, "name is required" if name.nil? validate_frontmatter!(content) rec = @skill_store.write(name, content, agent: agent, create_only: !!p[:create_only]) @skill_catalog.reload emit(:skill_written, name, agent) { name: name, agent: agent, updated_at: rec["updated_at"] } end |