mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 18:01:22 +00:00
When set to true, the skill is hidden from the system prompt, preventing agentic invocation. Users can still invoke explicitly via /skill:name. Also fixes pre-existing test bug where source expectation was wrong. Fixes #927
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
/**
|
|
* Skills Configuration
|
|
*
|
|
* Skills provide specialized instructions loaded into the system prompt.
|
|
* Discover, filter, merge, or replace them.
|
|
*/
|
|
|
|
import { createAgentSession, DefaultResourceLoader, SessionManager, type Skill } from "@mariozechner/pi-coding-agent";
|
|
|
|
// Or define custom skills inline
|
|
const customSkill: Skill = {
|
|
name: "my-skill",
|
|
description: "Custom project instructions",
|
|
filePath: "/virtual/SKILL.md",
|
|
baseDir: "/virtual",
|
|
source: "path",
|
|
disableModelInvocation: false,
|
|
};
|
|
|
|
const loader = new DefaultResourceLoader({
|
|
skillsOverride: (current) => {
|
|
const filteredSkills = current.skills.filter((s) => s.name.includes("browser") || s.name.includes("search"));
|
|
return {
|
|
skills: [...filteredSkills, customSkill],
|
|
diagnostics: current.diagnostics,
|
|
};
|
|
},
|
|
});
|
|
await loader.reload();
|
|
|
|
// Discover all skills from cwd/.pi/skills, ~/.pi/agent/skills, etc.
|
|
const { skills: allSkills, diagnostics } = loader.getSkills();
|
|
console.log(
|
|
"Discovered skills:",
|
|
allSkills.map((s) => s.name),
|
|
);
|
|
if (diagnostics.length > 0) {
|
|
console.log("Warnings:", diagnostics);
|
|
}
|
|
|
|
await createAgentSession({
|
|
resourceLoader: loader,
|
|
sessionManager: SessionManager.inMemory(),
|
|
});
|
|
|
|
console.log("Session created with filtered skills");
|