MCPcopy
hub / github.com/Doorman11991/smallcode / getSkillContext

Function getSkillContext

bin/smallcode.js:2092–2107  ·  view source on GitHub ↗
(messages)

Source from the content-addressed store, hash-verified

2090// Fix #18: Cap skill injection to ~1000 tokens (4000 chars). Multiple matching
2091// skills can each be a full .md file, quickly blowing up the system prompt.
2092function getSkillContext(messages) {
2093 if (!skillManager) return '';
2094 try {
2095 const lastUser = [...messages].reverse().find(m => m.role === 'user');
2096 if (!lastUser) return '';
2097 const skills = skillManager.getAutoSkills(lastUser.content);
2098 if (skills.length === 0) return '';
2099 const formatted = skillManager.formatForPrompt(skills);
2100 // Hard cap: truncate if too long
2101 return formatted.length > 4000
2102 ? formatted.slice(0, 4000) + '\n... (skills truncated to fit context)'
2103 : formatted;
2104 } catch {
2105 return '';
2106 }
2107}
2108
2109// Get plugin prompt injections for the current task type
2110// Fix #17: Cap plugin injection to ~500 tokens (2000 chars).

Callers 2

buildCompactSystemPromptFunction · 0.70
buildDynamicContextFunction · 0.70

Calls 2

getAutoSkillsMethod · 0.80
formatForPromptMethod · 0.45

Tested by

no test coverage detected