Class SkillManager

java.lang.Object
com.tnsai.skills.SkillManager

public final class SkillManager extends Object
Per-agent facade over the SkillStore + SkillResolver + SkillSession stack (TNS-289).

The agent calls this class on every chat turn to:

  1. Detect a /skill-name [args] prefix in the user message and route to invoke(java.lang.String, java.util.List<java.lang.String>, java.util.Map<java.lang.String, java.lang.String>, com.tnsai.events.SkillActivationEvent.Source, java.util.function.Consumer<com.tnsai.events.TnsAIEvent>).
  2. Append a "Skills" section to the system prompt — both the top-N candidate descriptions (when policy is SkillResolverPolicy.AUTO) and the rendered bodies of any already-activated skills.
Since:
0.10.0 (TNS-289)
  • Field Details

    • SLASH_PREFIX

      public static final String SLASH_PREFIX
      Magic prefix the user types to invoke a skill manually.
      See Also:
  • Constructor Details

  • Method Details

    • parseSlashCommand

      public Optional<SkillManager.SlashCommand> parseSlashCommand(String userMessage)
      Detect whether userMessage starts with a /skill-name [args] prefix and, if so, return a parsed SkillManager.SlashCommand. Returns Optional.empty() for regular messages.
    • invoke

      public Optional<ActiveSkill> invoke(String name, List<String> arguments, Map<String,String> environment, SkillActivationEvent.Source source, Consumer<TnsAIEvent> eventConsumer)
      Invoke a skill by name with the supplied arguments. Honours the skill's disable-model-invocation and user-invocable flags when source is SkillActivationEvent.Source.MODEL_TOOL_CALL or SkillActivationEvent.Source.USER_SLASH_COMMAND respectively.
    • renderPromptSection

      public String renderPromptSection(String latestUserMessage)
      Build the "Skills" section appended to the system prompt for the next LLM call. Combines (a) candidate listings produced by the resolver against the latest user message and (b) the rendered bodies of every active skill.

      latestUserMessage may be null when the caller has no message to score against (e.g. preparing a synthetic prompt) — in that case only the active-skill bodies are emitted.

    • activeSkills

      public List<ActiveSkill> activeSkills()
      Snapshot of currently active skills (for inspection / tests).
    • resetSession

      public void resetSession()
      Reset session state — drop every active skill.
    • preloadFrom

      public void preloadFrom(SkillManager parent)
      Preload every active skill from parent into this manager's session (TNS-289). Used when an AgentGroup spawns a subagent — the child inherits the parent's activated skill bodies so its first turn already has the procedural context, mirroring Claude Code's context: fork pattern for subagents.

      Re-activations replace any same-named skill the child had previously activated; the parent's snapshot wins.

    • store

      public SkillStore store()
    • policy

      public SkillResolverPolicy policy()