mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-14 13:53:02 -07:00
Agent Skills: Implement Core Skill Infrastructure & Tiered Discovery (#15698)
This commit is contained in:
@@ -94,6 +94,7 @@ import { DELEGATE_TO_AGENT_TOOL_NAME } from '../tools/tool-names.js';
|
||||
import { getExperiments } from '../code_assist/experiments/experiments.js';
|
||||
import { ExperimentFlags } from '../code_assist/experiments/flagNames.js';
|
||||
import { debugLogger } from '../utils/debugLogger.js';
|
||||
import { SkillManager } from '../services/skillManager.js';
|
||||
import { startupProfiler } from '../telemetry/startupProfiler.js';
|
||||
|
||||
import { ApprovalMode } from '../policy/types.js';
|
||||
@@ -348,6 +349,8 @@ export interface ConfigParameters {
|
||||
};
|
||||
previewFeatures?: boolean;
|
||||
enableAgents?: boolean;
|
||||
skillsSupport?: boolean;
|
||||
disabledSkills?: string[];
|
||||
experimentalJitContext?: boolean;
|
||||
onModelChange?: (model: string) => void;
|
||||
}
|
||||
@@ -363,6 +366,7 @@ export class Config {
|
||||
private promptRegistry!: PromptRegistry;
|
||||
private resourceRegistry!: ResourceRegistry;
|
||||
private agentRegistry!: AgentRegistry;
|
||||
private skillManager!: SkillManager;
|
||||
private sessionId: string;
|
||||
private fileSystemService: FileSystemService;
|
||||
private contentGeneratorConfig!: ContentGeneratorConfig;
|
||||
@@ -475,6 +479,8 @@ export class Config {
|
||||
private readonly onModelChange: ((model: string) => void) | undefined;
|
||||
|
||||
private readonly enableAgents: boolean;
|
||||
private readonly skillsSupport: boolean;
|
||||
private readonly disabledSkills: string[];
|
||||
|
||||
private readonly experimentalJitContext: boolean;
|
||||
private contextManager?: ContextManager;
|
||||
@@ -542,9 +548,11 @@ export class Config {
|
||||
this.model = params.model;
|
||||
this._activeModel = params.model;
|
||||
this.enableAgents = params.enableAgents ?? false;
|
||||
this.experimentalJitContext = params.experimentalJitContext ?? false;
|
||||
this.skillsSupport = params.skillsSupport ?? false;
|
||||
this.disabledSkills = params.disabledSkills ?? [];
|
||||
this.modelAvailabilityService = new ModelAvailabilityService();
|
||||
this.previewFeatures = params.previewFeatures ?? undefined;
|
||||
this.experimentalJitContext = params.experimentalJitContext ?? false;
|
||||
this.maxSessionTurns = params.maxSessionTurns ?? -1;
|
||||
this.experimentalZedIntegration =
|
||||
params.experimentalZedIntegration ?? false;
|
||||
@@ -624,6 +632,7 @@ export class Config {
|
||||
params.approvalMode ?? params.policyEngineConfig?.approvalMode,
|
||||
});
|
||||
this.messageBus = new MessageBus(this.policyEngine, this.debugMode);
|
||||
this.skillManager = new SkillManager();
|
||||
this.outputSettings = {
|
||||
format: params.output?.format ?? OutputFormat.TEXT,
|
||||
};
|
||||
@@ -721,6 +730,12 @@ export class Config {
|
||||
]);
|
||||
initMcpHandle?.end();
|
||||
|
||||
// Discover skills if enabled
|
||||
if (this.skillsSupport) {
|
||||
await this.getSkillManager().discoverSkills(this.storage);
|
||||
this.getSkillManager().setDisabledSkills(this.disabledSkills);
|
||||
}
|
||||
|
||||
// Initialize hook system if enabled
|
||||
if (this.enableHooks) {
|
||||
this.hookSystem = new HookSystem(this);
|
||||
@@ -973,6 +988,10 @@ export class Config {
|
||||
return this.promptRegistry;
|
||||
}
|
||||
|
||||
getSkillManager(): SkillManager {
|
||||
return this.skillManager;
|
||||
}
|
||||
|
||||
getResourceRegistry(): ResourceRegistry {
|
||||
return this.resourceRegistry;
|
||||
}
|
||||
@@ -1478,6 +1497,10 @@ export class Config {
|
||||
);
|
||||
}
|
||||
|
||||
isSkillsSupportEnabled(): boolean {
|
||||
return this.skillsSupport;
|
||||
}
|
||||
|
||||
isInteractive(): boolean {
|
||||
return this.interactive;
|
||||
}
|
||||
|
||||
@@ -45,6 +45,16 @@ describe('Storage – additional helpers', () => {
|
||||
expect(storage.getProjectCommandsDir()).toBe(expected);
|
||||
});
|
||||
|
||||
it('getUserSkillsDir returns ~/.gemini/skills', () => {
|
||||
const expected = path.join(os.homedir(), GEMINI_DIR, 'skills');
|
||||
expect(Storage.getUserSkillsDir()).toBe(expected);
|
||||
});
|
||||
|
||||
it('getProjectSkillsDir returns project/.gemini/skills', () => {
|
||||
const expected = path.join(projectRoot, GEMINI_DIR, 'skills');
|
||||
expect(storage.getProjectSkillsDir()).toBe(expected);
|
||||
});
|
||||
|
||||
it('getUserAgentsDir returns ~/.gemini/agents', () => {
|
||||
const expected = path.join(os.homedir(), GEMINI_DIR, 'agents');
|
||||
expect(Storage.getUserAgentsDir()).toBe(expected);
|
||||
|
||||
@@ -50,6 +50,10 @@ export class Storage {
|
||||
return path.join(Storage.getGlobalGeminiDir(), 'commands');
|
||||
}
|
||||
|
||||
static getUserSkillsDir(): string {
|
||||
return path.join(Storage.getGlobalGeminiDir(), 'skills');
|
||||
}
|
||||
|
||||
static getGlobalMemoryFilePath(): string {
|
||||
return path.join(Storage.getGlobalGeminiDir(), 'memory.md');
|
||||
}
|
||||
@@ -127,6 +131,10 @@ export class Storage {
|
||||
return path.join(this.getGeminiDir(), 'commands');
|
||||
}
|
||||
|
||||
getProjectSkillsDir(): string {
|
||||
return path.join(this.getGeminiDir(), 'skills');
|
||||
}
|
||||
|
||||
getProjectAgentsDir(): string {
|
||||
return path.join(this.getGeminiDir(), 'agents');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user