mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 13:04:08 +00:00
docs(coding-agent): improve extensions.md, add missing examples
- Add cross-links to session.md, keybindings.md, themes.md - Document truncateLine, highlightCode, getLanguageFromPath utilities - Add examples for previously undocumented APIs: - message-renderer.ts: registerMessageRenderer with Box styling - session-name.ts: setSessionName/getSessionName - event-bus.ts: pi.events for inter-extension communication - bookmark.ts: setLabel for entry bookmarking - Update examples table in extensions.md and README.md
This commit is contained in:
parent
c565fa9af8
commit
930207130b
6 changed files with 285 additions and 68 deletions
50
packages/coding-agent/examples/extensions/bookmark.ts
Normal file
50
packages/coding-agent/examples/extensions/bookmark.ts
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/**
|
||||
* Entry bookmarking example.
|
||||
*
|
||||
* Shows setLabel to mark entries with labels for easy navigation in /tree.
|
||||
* Labels appear in the tree view and help you find important points.
|
||||
*
|
||||
* Usage: /bookmark [label] - bookmark the last assistant message
|
||||
*/
|
||||
|
||||
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
||||
|
||||
export default function (pi: ExtensionAPI) {
|
||||
pi.registerCommand("bookmark", {
|
||||
description: "Bookmark last message (usage: /bookmark [label])",
|
||||
handler: async (args, ctx) => {
|
||||
const label = args.trim() || `bookmark-${Date.now()}`;
|
||||
|
||||
// Find the last assistant message entry
|
||||
const entries = ctx.sessionManager.getEntries();
|
||||
for (let i = entries.length - 1; i >= 0; i--) {
|
||||
const entry = entries[i];
|
||||
if (entry.type === "message" && entry.message.role === "assistant") {
|
||||
pi.setLabel(entry.id, label);
|
||||
ctx.ui.notify(`Bookmarked as: ${label}`, "info");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ctx.ui.notify("No assistant message to bookmark", "warning");
|
||||
},
|
||||
});
|
||||
|
||||
// Remove bookmark
|
||||
pi.registerCommand("unbookmark", {
|
||||
description: "Remove bookmark from last labeled entry",
|
||||
handler: async (_args, ctx) => {
|
||||
const entries = ctx.sessionManager.getEntries();
|
||||
for (let i = entries.length - 1; i >= 0; i--) {
|
||||
const entry = entries[i];
|
||||
const label = ctx.sessionManager.getLabel(entry.id);
|
||||
if (label) {
|
||||
pi.setLabel(entry.id, undefined);
|
||||
ctx.ui.notify(`Removed bookmark: ${label}`, "info");
|
||||
return;
|
||||
}
|
||||
}
|
||||
ctx.ui.notify("No bookmarked entry found", "warning");
|
||||
},
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue