fix(agent): enforce capability-gap skill recovery guidance

This commit is contained in:
Jiayuan Zhang 2026-02-17 01:18:00 +08:00
parent 2074aac49e
commit 7eb18f47fc
2 changed files with 13 additions and 1 deletions

View file

@ -218,6 +218,15 @@ describe("buildSkillsSection", () => {
expect(text).toContain("suggest activating it");
});
it("includes capability-gap recovery guidance", () => {
const result = buildSkillsSection("## commit\nDo commits.", "full");
const text = result.join("\n");
expect(text).toContain("capability gap");
expect(text).toContain("meta-skill-installer");
expect(text).toContain("explicit user confirmation");
expect(text).toContain("clawhub install");
});
it("returns empty in minimal mode", () => {
expect(buildSkillsSection("skills", "minimal")).toEqual([]);
});

View file

@ -399,7 +399,10 @@ export function buildSkillsSection(
"- If exactly one skill clearly applies: follow its instructions.",
"- If multiple could apply: choose the most specific one.",
"- If none clearly apply but an **inactive skill** matches the user's intent: suggest activating it.",
"- If no skill matches at all: skip skill invocation.",
"- If the request needs a capability you currently lack: do not stop at refusal. Treat it as a capability gap and propose a recovery path.",
"- If `meta-skill-installer` is available and no installed skill matches: proactively offer to search ClawHub for candidates and run security review before install.",
"- Ask for explicit user confirmation before final `clawhub install` / `clawhub update` unless the user already clearly asked you to install in this turn.",
"- After install/update, verify the skill path and retry the original user task.",
"",
budgeted,
"",