mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-16 21:03:42 +00:00
Update plan: move exec to HookAPI, sessionManager/modelRegistry to contexts
- exec() moves from HookEventContext/HookCommandContext to HookAPI - sessionManager/modelRegistry move from SessionEventBase to HookEventContext - HookCommandContext keeps sessionManager/modelRegistry (command handlers need them) - Both sendMessage and exec accessed via pi closure in command handlers
This commit is contained in:
parent
09e7e9196c
commit
e25aef0594
1 changed files with 21 additions and 2 deletions
|
|
@ -165,6 +165,26 @@ Calls `sessionManager.appendCustomEntry()` directly.
|
|||
**New: `registerCommand()` (types ✅, wiring TODO)**
|
||||
|
||||
```typescript
|
||||
// HookAPI (the `pi` object) - utilities available to all hooks:
|
||||
interface HookAPI {
|
||||
sendMessage(message: HookMessage, triggerTurn?: boolean): void;
|
||||
appendEntry(customType: string, data?: unknown): void;
|
||||
registerCommand(name: string, options: RegisteredCommand): void;
|
||||
registerCustomMessageRenderer(customType: string, renderer: CustomMessageRenderer): void;
|
||||
exec(command: string, args: string[], options?: ExecOptions): Promise<ExecResult>;
|
||||
}
|
||||
|
||||
// HookEventContext - passed to event handlers, has stable context:
|
||||
interface HookEventContext {
|
||||
ui: HookUIContext;
|
||||
hasUI: boolean;
|
||||
cwd: string;
|
||||
sessionManager: SessionManager;
|
||||
modelRegistry: ModelRegistry;
|
||||
}
|
||||
// Note: exec moved to HookAPI, sessionManager/modelRegistry moved from SessionEventBase
|
||||
|
||||
// HookCommandContext - passed to command handlers:
|
||||
interface HookCommandContext {
|
||||
args: string; // Everything after /commandname
|
||||
ui: HookUIContext;
|
||||
|
|
@ -172,9 +192,8 @@ interface HookCommandContext {
|
|||
cwd: string;
|
||||
sessionManager: SessionManager;
|
||||
modelRegistry: ModelRegistry;
|
||||
exec(command: string, args: string[], options?: ExecOptions): Promise<ExecResult>;
|
||||
}
|
||||
// Note: sendMessage not on context - handler captures `pi` in closure
|
||||
// Note: exec and sendMessage accessed via `pi` closure
|
||||
|
||||
registerCommand(name: string, options: {
|
||||
description?: string;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue