mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 14:03:49 +00:00
feat(coding-agent): add ctx.reload and reload-runtime example closes #1371
This commit is contained in:
parent
0bd205ab87
commit
e1b56c1d28
8 changed files with 114 additions and 0 deletions
|
|
@ -147,6 +147,8 @@ export type NavigateTreeHandler = (
|
|||
|
||||
export type SwitchSessionHandler = (sessionPath: string) => Promise<{ cancelled: boolean }>;
|
||||
|
||||
export type ReloadHandler = () => Promise<void>;
|
||||
|
||||
export type ShutdownHandler = () => void;
|
||||
|
||||
/**
|
||||
|
|
@ -210,6 +212,7 @@ export class ExtensionRunner {
|
|||
private forkHandler: ForkHandler = async () => ({ cancelled: false });
|
||||
private navigateTreeHandler: NavigateTreeHandler = async () => ({ cancelled: false });
|
||||
private switchSessionHandler: SwitchSessionHandler = async () => ({ cancelled: false });
|
||||
private reloadHandler: ReloadHandler = async () => {};
|
||||
private shutdownHandler: ShutdownHandler = () => {};
|
||||
private shortcutDiagnostics: ResourceDiagnostic[] = [];
|
||||
private commandDiagnostics: ResourceDiagnostic[] = [];
|
||||
|
|
@ -269,6 +272,7 @@ export class ExtensionRunner {
|
|||
this.forkHandler = actions.fork;
|
||||
this.navigateTreeHandler = actions.navigateTree;
|
||||
this.switchSessionHandler = actions.switchSession;
|
||||
this.reloadHandler = actions.reload;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -277,6 +281,7 @@ export class ExtensionRunner {
|
|||
this.forkHandler = async () => ({ cancelled: false });
|
||||
this.navigateTreeHandler = async () => ({ cancelled: false });
|
||||
this.switchSessionHandler = async () => ({ cancelled: false });
|
||||
this.reloadHandler = async () => {};
|
||||
}
|
||||
|
||||
setUIContext(uiContext?: ExtensionUIContext): void {
|
||||
|
|
@ -501,6 +506,7 @@ export class ExtensionRunner {
|
|||
fork: (entryId) => this.forkHandler(entryId),
|
||||
navigateTree: (targetId, options) => this.navigateTreeHandler(targetId, options),
|
||||
switchSession: (sessionPath) => this.switchSessionHandler(sessionPath),
|
||||
reload: () => this.reloadHandler(),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -306,6 +306,9 @@ export interface ExtensionCommandContext extends ExtensionContext {
|
|||
|
||||
/** Switch to a different session file. */
|
||||
switchSession(sessionPath: string): Promise<{ cancelled: boolean }>;
|
||||
|
||||
/** Reload extensions, skills, prompts, and themes. */
|
||||
reload(): Promise<void>;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
|
|
@ -1234,6 +1237,7 @@ export interface ExtensionCommandContextActions {
|
|||
options?: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string },
|
||||
) => Promise<{ cancelled: boolean }>;
|
||||
switchSession: (sessionPath: string) => Promise<{ cancelled: boolean }>;
|
||||
reload: () => Promise<void>;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1068,6 +1068,9 @@ export class InteractiveMode {
|
|||
await this.handleResumeSession(sessionPath);
|
||||
return { cancelled: false };
|
||||
},
|
||||
reload: async () => {
|
||||
await this.handleReloadCommand();
|
||||
},
|
||||
},
|
||||
shutdownHandler: () => {
|
||||
this.shutdownRequested = true;
|
||||
|
|
|
|||
|
|
@ -63,6 +63,9 @@ export async function runPrintMode(session: AgentSession, options: PrintModeOpti
|
|||
const success = await session.switchSession(sessionPath);
|
||||
return { cancelled: !success };
|
||||
},
|
||||
reload: async () => {
|
||||
await session.reload();
|
||||
},
|
||||
},
|
||||
onError: (err) => {
|
||||
console.error(`Extension error (${err.extensionPath}): ${err.error}`);
|
||||
|
|
|
|||
|
|
@ -295,6 +295,9 @@ export async function runRpcMode(session: AgentSession): Promise<never> {
|
|||
const success = await session.switchSession(sessionPath);
|
||||
return { cancelled: !success };
|
||||
},
|
||||
reload: async () => {
|
||||
await session.reload();
|
||||
},
|
||||
},
|
||||
shutdownHandler: () => {
|
||||
shutdownRequested = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue