co-mono/packages/coding-agent/examples/sdk/04-skills.ts
Mario Zechner af2d8509e6 Fix --no-skills flag not preventing skills from loading
The --no-skills flag set options.skills = [] in main.ts, but the
interactive mode UI would rediscover skills anyway because it called
loadSkills() directly instead of using the already-loaded skills.

Changes:
- Add AgentSession.skills and AgentSession.skillWarnings properties
- discoverSkills() now returns { skills, warnings } instead of Skill[]
- Interactive mode uses session.skills instead of calling loadSkills()
- Update SDK docs and examples for new return type

Fixes #577
2026-01-08 23:41:54 +01:00

47 lines
1.4 KiB
TypeScript

/**
* Skills Configuration
*
* Skills provide specialized instructions loaded into the system prompt.
* Discover, filter, merge, or replace them.
*/
import { createAgentSession, discoverSkills, SessionManager, type Skill } from "@mariozechner/pi-coding-agent";
// Discover all skills from cwd/.pi/skills, ~/.pi/agent/skills, etc.
const { skills: allSkills, warnings } = discoverSkills();
console.log(
"Discovered skills:",
allSkills.map((s) => s.name),
);
if (warnings.length > 0) {
console.log("Warnings:", warnings);
}
// Filter to specific skills
const filteredSkills = allSkills.filter((s) => s.name.includes("browser") || s.name.includes("search"));
// Or define custom skills inline
const customSkill: Skill = {
name: "my-skill",
description: "Custom project instructions",
filePath: "/virtual/SKILL.md",
baseDir: "/virtual",
source: "custom",
};
// Use filtered + custom skills
await createAgentSession({
skills: [...filteredSkills, customSkill],
sessionManager: SessionManager.inMemory(),
});
console.log(`Session created with ${filteredSkills.length + 1} skills`);
// To disable all skills:
// skills: []
// To use discovery with filtering via settings:
// discoverSkills(process.cwd(), undefined, {
// ignoredSkills: ["browser-tools"], // glob patterns to exclude
// includeSkills: ["brave-*"], // glob patterns to include (empty = all)
// })