Class: Insika::Pack

Inherits:
Data
  • Object
show all
Defined in:
lib/insika/pack.rb

Overview

Provisioning pack (Phase 6/D4/F6): the PORTABLE form of an agent — a manifest + the prompt files + the skills + the data-tool defs. It's what docs/prompt-base/06 describes as a workspace, here in a value object consumable by the PackImporter (which emits the authoring Commands). GENERIC per project (NF1): the engine doesn't know achei-b2b — the pack is the contract.

config: Hash — manifest (AgentProfile.build attrs: id/model/provider/
      limits/metadata/tools_deferred/…). `id`/`model` required there.
files:  { "IDENTITY.md" => "<content>", ... } — prompt files (become
      prompt_files via write_agent_file). File name = key.
skills: { "escalation-to-human" => "<SKILL.md>", ... } — 1 per skill.
tools:  [ { ToolDefinition hash }, ... ] — the pack's data-tool defs.

Two sources: from_h (GatewayClient JSON — provisioning API, task 8) and from_dir (a folder on disk per docs/prompt-base/06 — authoring/CLI).

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config

Returns:

  • (Object)

    the current value of config



21
22
23
# File 'lib/insika/pack.rb', line 21

def config
  @config
end

#filesObject (readonly)

Returns the value of attribute files

Returns:

  • (Object)

    the current value of files



21
22
23
# File 'lib/insika/pack.rb', line 21

def files
  @files
end

#skillsObject (readonly)

Returns the value of attribute skills

Returns:

  • (Object)

    the current value of skills



21
22
23
# File 'lib/insika/pack.rb', line 21

def skills
  @skills
end

#toolsObject (readonly)

Returns the value of attribute tools

Returns:

  • (Object)

    the current value of tools



21
22
23
# File 'lib/insika/pack.rb', line 21

def tools
  @tools
end

Class Method Details

.from_dir(path) ⇒ Object

Folder on disk (docs/prompt-base/06): agent.config.json + *.md at the root + skills/<name>/SKILL.md + tools/*.json (1 ToolDefinition per file).



52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/insika/pack.rb', line 52

def self.from_dir(path)
  root = path.to_s
  config_file = File.join(root, "agent.config.json")
  raise Insika::ValidationError, "pack missing agent.config.json in #{root}" unless File.exist?(config_file)

  new(
    config: symbolize(JSON.parse(File.read(config_file, encoding: "UTF-8"))),
    files: read_md_files(root),
    skills: read_skills(File.join(root, "skills")),
    tools: read_tools(File.join(root, "tools"))
  )
end

.from_h(hash) ⇒ Object

Raw Hash (string|symbol keys) -> Pack. Tolerates both key conventions (the JSON wire may arrive symbolized or not).



24
25
26
27
28
29
30
31
32
# File 'lib/insika/pack.rb', line 24

def self.from_h(hash)
  h = hash || {}
  new(
    config: symbolize(dig(h, :config) || {}),
    files: text_values!(stringify_keys(dig(h, :files) || {}), "files"),
    skills: text_values!(stringify_keys(dig(h, :skills) || {}), "skills"),
    tools: Array(dig(h, :tools))
  )
end