mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-21 20:04:55 +00:00
Add SDK usage examples
12 examples showing increasing levels of customization: - 01-minimal: all defaults - 02-custom-model: model and thinking level - 03-custom-prompt: replace or modify prompt - 04-skills: discover, filter, merge skills - 05-tools: built-in tools, custom tools - 06-hooks: logging, blocking, result modification - 07-context-files: AGENTS.md files - 08-slash-commands: file-based commands - 09-api-keys-and-oauth: API key resolution, OAuth config - 10-settings: compaction, retry, terminal settings - 11-sessions: persistence options - 12-full-control: replace everything Also exports FileSlashCommand type from index.ts
This commit is contained in:
parent
86cfe6a436
commit
56121dcac1
15 changed files with 723 additions and 0 deletions
44
packages/coding-agent/examples/sdk/04-skills.ts
Normal file
44
packages/coding-agent/examples/sdk/04-skills.ts
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/**
|
||||
* Skills Configuration
|
||||
*
|
||||
* Skills provide specialized instructions loaded into the system prompt.
|
||||
* Discover, filter, merge, or replace them.
|
||||
*/
|
||||
|
||||
import { createAgentSession, discoverSkills, SessionManager, type Skill } from "../../src/index.js";
|
||||
|
||||
// Discover all skills from cwd/.pi/skills, ~/.pi/agent/skills, etc.
|
||||
const allSkills = discoverSkills();
|
||||
console.log(
|
||||
"Discovered skills:",
|
||||
allSkills.map((s) => s.name),
|
||||
);
|
||||
|
||||
// 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
|
||||
const { session } = 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)
|
||||
// })
|
||||
Loading…
Add table
Add a link
Reference in a new issue