Agent Skills: Implement /skills reload (#15865)

This commit is contained in:
N. Taylor Mullen
2026-01-05 15:12:51 -08:00
committed by GitHub
parent 8f0324d868
commit 2cb33b2f76
11 changed files with 468 additions and 9 deletions
+38 -1
View File
@@ -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;
}