Package com.tnsai.skills
Class SkillManager
java.lang.Object
com.tnsai.skills.SkillManager
Per-agent facade over the
SkillStore +
SkillResolver + SkillSession stack (TNS-289).
The agent calls this class on every chat turn to:
- Detect a
/skill-name [args]prefix in the user message and route toinvoke(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>). - 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)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordResult of parsing a/skill-name [args]user message. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringMagic prefix the user types to invoke a skill manually. -
Constructor Summary
ConstructorsConstructorDescriptionSkillManager(String agentName, SkillStore store, SkillResolver resolver, SkillResolverPolicy policy, int maxActiveSkills) -
Method Summary
Modifier and TypeMethodDescriptionSnapshot of currently active skills (for inspection / tests).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.parseSlashCommand(String userMessage) Detect whetheruserMessagestarts with a/skill-name [args]prefix and, if so, return a parsedSkillManager.SlashCommand.policy()voidpreloadFrom(SkillManager parent) Preload every active skill fromparentinto this manager's session (TNS-289).renderPromptSection(String latestUserMessage) Build the "Skills" section appended to the system prompt for the next LLM call.voidReset session state — drop every active skill.store()
-
Field Details
-
SLASH_PREFIX
Magic prefix the user types to invoke a skill manually.- See Also:
-
-
Constructor Details
-
SkillManager
public SkillManager(String agentName, SkillStore store, SkillResolver resolver, SkillResolverPolicy policy, int maxActiveSkills)
-
-
Method Details
-
parseSlashCommand
Detect whetheruserMessagestarts with a/skill-name [args]prefix and, if so, return a parsedSkillManager.SlashCommand. ReturnsOptional.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'sdisable-model-invocationanduser-invocableflags whensourceisSkillActivationEvent.Source.MODEL_TOOL_CALLorSkillActivationEvent.Source.USER_SLASH_COMMANDrespectively. -
renderPromptSection
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.latestUserMessagemay benullwhen 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
Snapshot of currently active skills (for inspection / tests). -
resetSession
public void resetSession()Reset session state — drop every active skill. -
preloadFrom
Preload every active skill fromparentinto this manager's session (TNS-289). Used when anAgentGroupspawns a subagent — the child inherits the parent's activated skill bodies so its first turn already has the procedural context, mirroring Claude Code'scontext: forkpattern for subagents.Re-activations replace any same-named skill the child had previously activated; the parent's snapshot wins.
-
store
-
policy
-