mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 19:04:37 +00:00
feat(coding-agent): add user_bash event and theme API extensions
- user_bash event for intercepting ! and !! commands (#528) - Extensions can return { operations } or { result } to redirect/replace - executeBashWithOperations() for custom BashOperations execution - session.recordBashResult() for extensions handling bash themselves - Theme API: getAllThemes(), getTheme(), setTheme() on ctx.ui - mac-system-theme.ts example: sync with macOS dark/light mode - Updated ssh.ts to use user_bash event
This commit is contained in:
parent
16e142ef7d
commit
121823c74d
14 changed files with 405 additions and 36 deletions
|
|
@ -0,0 +1,25 @@
|
|||
/**
|
||||
* Syncs pi theme with macOS system appearance (dark/light mode).
|
||||
*
|
||||
* Usage:
|
||||
* pi -e examples/extensions/mac-system-theme.ts
|
||||
*/
|
||||
|
||||
import { execSync } from "node:child_process";
|
||||
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
||||
|
||||
function isDarkMode(): boolean {
|
||||
try {
|
||||
execSync("defaults read -g AppleInterfaceStyle", { encoding: "utf-8" });
|
||||
return true; // Returns "Dark" if dark mode
|
||||
} catch {
|
||||
return false; // Throws if light mode
|
||||
}
|
||||
}
|
||||
|
||||
export default function (pi: ExtensionAPI) {
|
||||
pi.on("session_start", (_event, ctx) => {
|
||||
const theme = isDarkMode() ? "dark" : "light";
|
||||
ctx.ui.setTheme(theme);
|
||||
});
|
||||
}
|
||||
|
|
@ -199,6 +199,13 @@ export default function (pi: ExtensionAPI) {
|
|||
}
|
||||
});
|
||||
|
||||
// Handle user ! commands via SSH
|
||||
pi.on("user_bash", (_event) => {
|
||||
const ssh = getSsh();
|
||||
if (!ssh) return; // No SSH, use local execution
|
||||
return { operations: createRemoteBashOps(ssh.remote, ssh.remoteCwd, localCwd) };
|
||||
});
|
||||
|
||||
// Replace local cwd with remote cwd in system prompt
|
||||
pi.on("before_agent_start", async (event) => {
|
||||
const ssh = getSsh();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue