@yeaft/webchat-agent 1.0.86 → 1.0.88
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/yeaft/engine.js +22 -15
package/package.json
CHANGED
package/yeaft/engine.js
CHANGED
|
@@ -96,41 +96,48 @@ const RETRY_DEFAULTS = Object.freeze({
|
|
|
96
96
|
jitterRatio: 0.25,
|
|
97
97
|
});
|
|
98
98
|
|
|
99
|
-
// Accept
|
|
100
|
-
//
|
|
101
|
-
// for older clients and typed history.
|
|
102
|
-
const
|
|
99
|
+
// Accept legacy namespaced commands and Claude Code-style bare skill commands.
|
|
100
|
+
// Project-tier skills are shown as /<skill-name>; /yeaft-skills:<name> and
|
|
101
|
+
// /skill:<name> stay supported for globals, older clients, and typed history.
|
|
102
|
+
const PREFIXED_SKILL_COMMAND_RE = /^\/(?:skill|yeaft-skills):([^\s]+)(\s+|$)/;
|
|
103
103
|
const BARE_SKILL_COMMAND_RE = /^\/([A-Za-z0-9][A-Za-z0-9_.-]*)(\s+|$)/;
|
|
104
104
|
|
|
105
|
+
function skillManagerHasSkill(skillManager, name) {
|
|
106
|
+
if (!skillManager || !name) return false;
|
|
107
|
+
if (typeof skillManager.has === 'function') return !!skillManager.has(name);
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
|
|
105
111
|
function parseExplicitSkillCommand(prompt, skillManager) {
|
|
106
112
|
if (typeof prompt !== 'string') {
|
|
107
113
|
return { skillName: null, cleanedPrompt: prompt };
|
|
108
114
|
}
|
|
109
|
-
const
|
|
110
|
-
if (
|
|
115
|
+
const prefixed = prompt.match(PREFIXED_SKILL_COMMAND_RE);
|
|
116
|
+
if (prefixed) {
|
|
111
117
|
return {
|
|
112
|
-
skillName:
|
|
113
|
-
cleanedPrompt: prompt.slice(
|
|
118
|
+
skillName: prefixed[1],
|
|
119
|
+
cleanedPrompt: prompt.slice(prefixed[0].length),
|
|
114
120
|
};
|
|
115
121
|
}
|
|
116
|
-
|
|
117
|
-
|
|
122
|
+
|
|
123
|
+
const bare = prompt.match(BARE_SKILL_COMMAND_RE);
|
|
124
|
+
if (bare && skillManagerHasSkill(skillManager, bare[1])) {
|
|
118
125
|
return {
|
|
119
|
-
skillName:
|
|
120
|
-
cleanedPrompt: prompt.slice(
|
|
126
|
+
skillName: bare[1],
|
|
127
|
+
cleanedPrompt: prompt.slice(bare[0].length),
|
|
121
128
|
};
|
|
122
129
|
}
|
|
123
130
|
return { skillName: null, cleanedPrompt: prompt };
|
|
124
131
|
}
|
|
125
132
|
|
|
126
|
-
function stripLeadingSkillCommandFromPromptParts(promptParts) {
|
|
133
|
+
function stripLeadingSkillCommandFromPromptParts(promptParts, skillManager) {
|
|
127
134
|
if (!Array.isArray(promptParts) || promptParts.length === 0) return promptParts;
|
|
128
135
|
let stripped = false;
|
|
129
136
|
return promptParts.map(part => {
|
|
130
137
|
if (stripped || !part || part.type !== 'text' || typeof part.text !== 'string') {
|
|
131
138
|
return part;
|
|
132
139
|
}
|
|
133
|
-
const parsed = parseExplicitSkillCommand(part.text);
|
|
140
|
+
const parsed = parseExplicitSkillCommand(part.text, skillManager);
|
|
134
141
|
if (!parsed.skillName) return part;
|
|
135
142
|
stripped = true;
|
|
136
143
|
return { ...part, text: parsed.cleanedPrompt };
|
|
@@ -1652,7 +1659,7 @@ export class Engine {
|
|
|
1652
1659
|
const parsedSkill = parseExplicitSkillCommand(parsed.cleanedPrompt, this.#skillManager);
|
|
1653
1660
|
const effectivePrompt = parsedSkill.cleanedPrompt;
|
|
1654
1661
|
const effectivePromptParts = parsedSkill.skillName
|
|
1655
|
-
? stripLeadingSkillCommandFromPromptParts(promptParts)
|
|
1662
|
+
? stripLeadingSkillCommandFromPromptParts(promptParts, this.#skillManager)
|
|
1656
1663
|
: promptParts;
|
|
1657
1664
|
const configuredEffort = normalizeEffort(this.#config?.modelEffort);
|
|
1658
1665
|
const effectiveUserEffort = normalizeEffort(userEffort) || parsed.effort || configuredEffort || null;
|