Planck.Agent.SkillIndex (Planck.Agent v0.1.7)

Copy Markdown View Source

Holds all skill-related state for a running agent.

Two concerns live here:

  • System prompt indexpool, ranked, and top_n are frozen at session start and used by SystemPrompt.build/1 on every turn without calling any external function (cache-friendly).
  • Tool dispatchnames and refresh_fn are used by the load_skill and list_skills tools to resolve and hot-reload the skill pool.

Summary

Functions

Build a SkillIndex from agent start opts.

Return an empty skill index.

Refresh pool and ranked by calling index_refresh_fn.

Types

t()

@type t() :: %Planck.Agent.SkillIndex{
  index_refresh_fn: (-> {[Planck.Agent.Skill.t()], [String.t()]}) | nil,
  names: [String.t()],
  pool: [Planck.Agent.Skill.t()],
  ranked: [String.t()],
  refresh_fn: (-> [Planck.Agent.Skill.t()]) | nil,
  top_n: pos_integer()
}
  • :pool — frozen list of Skill.t() for the system prompt index; set at session start, refreshed at compaction
  • :ranked — skill names ordered by usage history (from SQLite); used by the index to determine the "last used" section
  • :top_n — maximum number of ranked skills shown in the index
  • :names — skill names declared in TEAM.json "skills" array; used by AgentSpec.to_start_opts/2 for tool resolution
  • :refresh_fn — returns the live skill pool; called by load_skill and list_skills tools only, never by the system prompt
  • :index_refresh_fn — called after compaction to rebuild pool and ranked; returns {[Skill.t()], [String.t()]}. nil means the index stays frozen for the entire session.

Functions

from_opts(opts)

@spec from_opts(keyword()) :: t()

Build a SkillIndex from agent start opts.

new()

@spec new() :: t()

Return an empty skill index.

refresh(index)

@spec refresh(t()) :: t()

Refresh pool and ranked by calling index_refresh_fn.

Called after compaction — the right moment to pick up newly created skills and updated usage rankings without busting the prefix cache on normal turns. Returns the index unchanged when no index_refresh_fn is set.