feat: expand skill command registration
This commit is contained in:
@@ -38,6 +38,20 @@ function listAgents(cfg: ClawdbotConfig): AgentEntry[] {
|
||||
return list.filter((entry): entry is AgentEntry => Boolean(entry && typeof entry === "object"));
|
||||
}
|
||||
|
||||
export function listAgentIds(cfg: ClawdbotConfig): string[] {
|
||||
const agents = listAgents(cfg);
|
||||
if (agents.length === 0) return [DEFAULT_AGENT_ID];
|
||||
const seen = new Set<string>();
|
||||
const ids: string[] = [];
|
||||
for (const entry of agents) {
|
||||
const id = normalizeAgentId(entry?.id);
|
||||
if (seen.has(id)) continue;
|
||||
seen.add(id);
|
||||
ids.push(id);
|
||||
}
|
||||
return ids.length > 0 ? ids : [DEFAULT_AGENT_ID];
|
||||
}
|
||||
|
||||
export function resolveDefaultAgentId(cfg: ClawdbotConfig): string {
|
||||
const agents = listAgents(cfg);
|
||||
if (agents.length === 0) return DEFAULT_AGENT_ID;
|
||||
|
||||
@@ -321,17 +321,26 @@ export function buildWorkspaceSkillCommandSpecs(
|
||||
|
||||
const specs: SkillCommandSpec[] = [];
|
||||
for (const entry of userInvocable) {
|
||||
const base = sanitizeSkillCommandName(entry.skill.name);
|
||||
const rawName = entry.skill.name;
|
||||
const base = sanitizeSkillCommandName(rawName);
|
||||
if (base !== rawName) {
|
||||
console.warn(`[skills] Sanitized skill command name "${rawName}" to "/${base}".`);
|
||||
}
|
||||
const unique = resolveUniqueSkillCommandName(base, used);
|
||||
if (unique !== base) {
|
||||
console.warn(
|
||||
`[skills] De-duplicated skill command name for "${rawName}" to "/${unique}".`,
|
||||
);
|
||||
}
|
||||
used.add(unique.toLowerCase());
|
||||
const rawDescription = entry.skill.description?.trim() || entry.skill.name;
|
||||
const rawDescription = entry.skill.description?.trim() || rawName;
|
||||
const description =
|
||||
rawDescription.length > SKILL_COMMAND_DESCRIPTION_MAX_LENGTH
|
||||
? rawDescription.slice(0, SKILL_COMMAND_DESCRIPTION_MAX_LENGTH - 1) + "…"
|
||||
: rawDescription;
|
||||
specs.push({
|
||||
name: unique,
|
||||
skillName: entry.skill.name,
|
||||
skillName: rawName,
|
||||
description,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user