mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-25 04:24:51 -07:00
Agent Skills: Implement /skills reload (#15865)
This commit is contained in:
@@ -356,6 +356,7 @@ export interface ConfigParameters {
|
||||
disabledSkills?: string[];
|
||||
experimentalJitContext?: boolean;
|
||||
onModelChange?: (model: string) => void;
|
||||
onReload?: () => Promise<{ disabledSkills?: string[] }>;
|
||||
}
|
||||
|
||||
export class Config {
|
||||
@@ -479,10 +480,13 @@ export class Config {
|
||||
private experimentsPromise: Promise<void> | undefined;
|
||||
private hookSystem?: HookSystem;
|
||||
private readonly onModelChange: ((model: string) => void) | undefined;
|
||||
private readonly onReload:
|
||||
| (() => Promise<{ disabledSkills?: string[] }>)
|
||||
| undefined;
|
||||
|
||||
private readonly enableAgents: boolean;
|
||||
private readonly skillsSupport: boolean;
|
||||
private readonly disabledSkills: string[];
|
||||
private disabledSkills: string[];
|
||||
|
||||
private readonly experimentalJitContext: boolean;
|
||||
private contextManager?: ContextManager;
|
||||
@@ -643,6 +647,7 @@ export class Config {
|
||||
this.projectHooks = params.projectHooks;
|
||||
this.experiments = params.experiments;
|
||||
this.onModelChange = params.onModelChange;
|
||||
this.onReload = params.onReload;
|
||||
|
||||
if (params.contextFileName) {
|
||||
setGeminiMdFilename(params.contextFileName);
|
||||
@@ -1520,6 +1525,38 @@ export class Config {
|
||||
return this.skillsSupport;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reloads skills by re-discovering them from extensions and local directories.
|
||||
*/
|
||||
async reloadSkills(): Promise<void> {
|
||||
if (!this.skillsSupport) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.onReload) {
|
||||
const refreshed = await this.onReload();
|
||||
this.disabledSkills = refreshed.disabledSkills ?? [];
|
||||
}
|
||||
|
||||
await this.getSkillManager().discoverSkills(
|
||||
this.storage,
|
||||
this.getExtensions(),
|
||||
);
|
||||
this.getSkillManager().setDisabledSkills(this.disabledSkills);
|
||||
|
||||
// Re-register ActivateSkillTool to update its schema with the newly discovered skills
|
||||
if (this.getSkillManager().getSkills().length > 0) {
|
||||
this.getToolRegistry().registerTool(
|
||||
new ActivateSkillTool(this, this.messageBus),
|
||||
);
|
||||
} else {
|
||||
this.getToolRegistry().unregisterTool(ActivateSkillTool.Name);
|
||||
}
|
||||
|
||||
// Notify the client that system instructions might need updating
|
||||
await this.updateSystemInstructionIfInitialized();
|
||||
}
|
||||
|
||||
isInteractive(): boolean {
|
||||
return this.interactive;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user