Merge #4054 into stage-mj

This commit is contained in:
nesquena-hermes
2026-06-12 20:14:42 +00:00
3 changed files with 35 additions and 7 deletions

View File

@@ -949,8 +949,11 @@ async function cmdUse(args){
}
return;
}
const directive = `[USER OVERRIDE] You MUST consult skill '${match.name}' via skill_view before responding to the next message.`;
resolve(directive);
const detail = await api(`/api/skills/content?name=${encodeURIComponent(match.name)}`);
const skillContent = detail&&typeof detail.content==='string' ? detail.content.trim() : '';
if(!skillContent) throw new Error(`Skill \`${match.name}\` has no readable content.`);
const directive = `[USER OVERRIDE] You MUST follow the skill '${match.name}' content provided below before responding to the next message.`;
resolve({name:match.name,directive,content:skillContent});
if(isCurrentSession()){
S.messages.push({role:'assistant', content:`Next turn: skill \`${match.name}\` will be forced.`});
renderMessages();

View File

@@ -1063,10 +1063,22 @@ async function send(){
if(_forcedSkillDirectivePending){
const _pending=_forcedSkillDirectivePending;
if(!_pending.sessionId||_pending.sessionId===activeSid){
const _directive = await _pending.promise;
const _directivePayload = await _pending.promise;
if(_forcedSkillDirectivePending===_pending)_forcedSkillDirectivePending = null;
if(typeof _directive==='string'&&_directive){
msgText=`${_directive}\n\n${msgText||''}`.trim();
if(_directivePayload){
const _directive = typeof _directivePayload==='string'
? _directivePayload
: String(_directivePayload.directive||'').trim();
const _forcedSkillName = typeof _directivePayload==='string'
? ''
: String(_directivePayload.name||'').trim();
const _forcedSkillContent = typeof _directivePayload==='string'
? ''
: String(_directivePayload.content||'').trim();
const _forcedSkillBlock = _forcedSkillName&&_forcedSkillContent
? `[FORCED SKILL CONTEXT: ${_forcedSkillName}]\n${_forcedSkillContent}\n[/FORCED SKILL CONTEXT]`
: '';
msgText=`${_directive}${_forcedSkillBlock?`\n\n${_forcedSkillBlock}`:''}\n\n${msgText||''}`.trim();
}
}
}