mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 17:00:59 +00:00
- Add setEditorText() and getEditorText() to HookUIContext for prompt generator pattern - custom() now accepts async factories for fire-and-forget work - Add CancellableLoader component to tui package - Add BorderedLoader component for hooks with cancel UI - Export HookAPI, HookContext, HookFactory from main package - Update all examples to import from packages instead of relative paths - Update hooks.md and custom-tools.md documentation fixes #350
42 lines
1 KiB
TypeScript
42 lines
1 KiB
TypeScript
/**
|
|
* Slash Commands
|
|
*
|
|
* File-based commands that inject content when invoked with /commandname.
|
|
*/
|
|
|
|
import {
|
|
createAgentSession,
|
|
discoverSlashCommands,
|
|
type FileSlashCommand,
|
|
SessionManager,
|
|
} from "@mariozechner/pi-coding-agent";
|
|
|
|
// Discover commands from cwd/.pi/commands/ and ~/.pi/agent/commands/
|
|
const discovered = discoverSlashCommands();
|
|
console.log("Discovered slash commands:");
|
|
for (const cmd of discovered) {
|
|
console.log(` /${cmd.name}: ${cmd.description}`);
|
|
}
|
|
|
|
// Define custom commands
|
|
const deployCommand: FileSlashCommand = {
|
|
name: "deploy",
|
|
description: "Deploy the application",
|
|
source: "(custom)",
|
|
content: `# Deploy Instructions
|
|
|
|
1. Build: npm run build
|
|
2. Test: npm test
|
|
3. Deploy: npm run deploy`,
|
|
};
|
|
|
|
// Use discovered + custom commands
|
|
await createAgentSession({
|
|
slashCommands: [...discovered, deployCommand],
|
|
sessionManager: SessionManager.inMemory(),
|
|
});
|
|
|
|
console.log(`Session created with ${discovered.length + 1} slash commands`);
|
|
|
|
// Disable slash commands:
|
|
// slashCommands: []
|