@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
42 lines • 1.71 kB
JavaScript
import { parseSkillMcpDeclarations, skillActivationTargets, } from "./skills.js";
/**
* Skills-carry-MCP reveal state, per execution scope (brain/hand S16c). A runtime serving several scopes keeps one
* state per scope, so one scope's turn does not replace another's skills and one scope's `/skill:<name>` does not
* use up another's reveal of the same skill. A runtime serving one scope keeps exactly one state, as before.
*/
export function createMcpSkillReveal(options) {
const states = new WeakMap();
const stateOf = (scope) => {
const existing = states.get(scope);
if (existing !== undefined)
return existing;
const created = {
declarations: { servers: new Map(), warnings: [] },
skills: new Map(),
loaded: new Set(),
};
states.set(scope, created);
return created;
};
return {
startTurn(scope, skills) {
const state = stateOf(scope);
state.skills = new Map(skills.map((skill) => [skill.name, skill]));
state.declarations = parseSkillMcpDeclarations(skills);
return state.declarations;
},
skills(scope) {
return stateOf(scope).skills;
},
reveal(scope, skillName) {
const state = stateOf(scope);
if (state.loaded.has(skillName) || !state.skills.has(skillName))
return;
state.loaded.add(skillName);
const targets = skillActivationTargets(state.declarations, skillName, options.registered());
if (targets.length > 0)
options.activate(targets);
},
};
}
//# sourceMappingURL=skill-reveal.js.map