@@ -4,20 +4,32 @@ import { CodeBlock } from '../components/CodeBlock';
44import { RelatedPages , type RelatedPage } from '../components/RelatedPages' ;
55
66const relatedPages : RelatedPage [ ] = [
7- { id : 'system-prompt' , label : 'Prompt构建' , description : 'System Prompt 如何注入 skills 列表' } ,
7+ {
8+ id : 'system-prompt' ,
9+ label : 'Prompt构建' ,
10+ description : 'System Prompt 如何注入 skills 列表' ,
11+ } ,
812 { id : 'tool-ref' , label : '工具参考' , description : 'activate_skill 工具细节' } ,
9- { id : 'policy-engine' , label : 'Policy 策略引擎' , description : 'activate_skill 默认 ask_user' } ,
13+ {
14+ id : 'policy-engine' ,
15+ label : 'Policy 策略引擎' ,
16+ description : 'activate_skill 默认 ask_user' ,
17+ } ,
1018 { id : 'slash-cmd' , label : '斜杠命令' , description : '/skills 命令与 UI 展示' } ,
1119] ;
1220
1321export function AgentSkills ( ) {
1422 return (
1523 < div className = "space-y-8" >
1624 < section >
17- < h2 className = "text-2xl font-bold text-cyan-400 mb-2" > Agent Skills(技能系统)</ h2 >
25+ < h2 className = "text-2xl font-bold text-cyan-400 mb-2" >
26+ Agent Skills(技能系统)
27+ </ h2 >
1828 < p className = "text-gray-300" >
19- Skills 是一套“可发现 + 可激活”的专家指令包:CLI 启动时从固定目录扫描 < code > SKILL.md</ code > ,模型在合适时机通过
20- < code className = "text-cyan-300" > activate_skill</ code > 取回指令,并把其作为本次任务的优先执行规范。
29+ Skills 是一套“可发现 + 可激活”的专家指令包:CLI 启动时从固定目录扫描{ ' ' }
30+ < code > SKILL.md</ code > ,模型在合适时机通过
31+ < code className = "text-cyan-300" > activate_skill</ code > { ' ' }
32+ 取回指令,并把其作为本次任务的优先执行规范。
2133 </ p >
2234 </ section >
2335
@@ -30,7 +42,8 @@ export function AgentSkills() {
3042 </ HighlightBox >
3143 < HighlightBox title = "任务自适配" variant = "green" >
3244 < p className = "text-sm text-gray-300" >
33- 模型先看到可用 skills 列表,再按任务匹配主动激活(而不是靠用户记住命令名)。
45+ 模型先看到可用 skills
46+ 列表,再按任务匹配主动激活(而不是靠用户记住命令名)。
3447 </ p >
3548 </ HighlightBox >
3649 < HighlightBox title = "可控注入" variant = "purple" >
@@ -43,13 +56,17 @@ export function AgentSkills() {
4356
4457 < Layer title = "技能发现(Discovery)" icon = "🗂️" >
4558 < p className = "text-gray-300 mb-4" >
46- skills 启用后,< code > SkillManager</ code > 会扫描 < code > */SKILL.md</ code > 并汇总为“可用技能清单”。
47- 覆盖优先级为:< strong > Built-in(最低) → Extension → User → Workspace(最高)</ strong > (同名以 YAML frontmatter 的 < code > name</ code > 为准)。
59+ skills 启用后,< code > SkillManager</ code > 会扫描{ ' ' }
60+ < code > */SKILL.md</ code > 并汇总为“可用技能清单”。 覆盖优先级为:
61+ < strong >
62+ Built-in(最低) → Extension → User → Workspace(最高)
63+ </ strong >
64+ (同名以 YAML frontmatter 的 < code > name</ code > 为准)。
4865 </ p >
4966
5067 < CodeBlock
5168 title = "目录约定(storage.ts)"
52- code = { `// packages/core/src/config/storage.ts
69+ code = { `// gemini-cli/ packages/core/src/config/storage.ts
5370static getUserSkillsDir(): string {
5471 return path.join(Storage.getGlobalGeminiDir(), 'skills'); // ~/.gemini/skills
5572}
@@ -61,7 +78,7 @@ getProjectSkillsDir(): string {
6178
6279 < CodeBlock
6380 title = "发现顺序与覆盖(skillManager.ts)"
64- code = { `// packages/core/src/skills/skillManager.ts
81+ code = { `// gemini-cli/ packages/core/src/skills/skillManager.ts
6582// Precedence: Built-in (lowest) -> Extensions -> User -> Workspace (highest).
6683async discoverSkills(storage: Storage, extensions: GeminiCLIExtension[] = []) {
6784 this.clearSkills();
@@ -100,14 +117,17 @@ description: Pre-implementation confidence assessment (≥90% required).
100117
101118 < Layer title = "激活机制(activate_skill)" icon = "🧩" >
102119 < p className = "text-gray-300 mb-4" >
103- 模型激活 skill 时调用 < code className = "text-cyan-300" > activate_skill</ code > ,工具会返回一个带标签的片段:
104- < code className = "text-purple-300" > <ACTIVATED_SKILL></ code > 中包含 < code > <INSTRUCTIONS></ code > 与
120+ 模型激活 skill 时调用{ ' ' }
121+ < code className = "text-cyan-300" > activate_skill</ code >
122+ ,工具会返回一个带标签的片段:
123+ < code className = "text-purple-300" > <ACTIVATED_SKILL></ code > { ' ' }
124+ 中包含 < code > <INSTRUCTIONS></ code > 与
105125 < code > <AVAILABLE_RESOURCES></ code > (技能目录的文件结构)。
106126 </ p >
107127
108128 < CodeBlock
109129 title = "返回格式(activate-skill.ts)"
110- code = { `// packages/core/src/tools/activate-skill.ts
130+ code = { `// gemini-cli/ packages/core/src/tools/activate-skill.ts
111131return {
112132 llmContent: \`<ACTIVATED_SKILL name="\${skillName}">
113133 <INSTRUCTIONS>
@@ -122,21 +142,26 @@ return {
122142 />
123143
124144 < div className = "bg-amber-500/10 border border-amber-500/30 rounded-lg p-4" >
125- < div className = "text-amber-400 font-semibold mb-2" > 为什么默认 ask_user?</ div >
145+ < div className = "text-amber-400 font-semibold mb-2" >
146+ 为什么默认 ask_user?
147+ </ div >
126148 < p className = "text-sm text-gray-300" >
127- 激活 skill 的本质是“把本地文件中的指令注入到对话上下文”,属于高影响操作;默认策略要求用户确认以明确知情与授权。
149+ 激活 skill
150+ 的本质是“把本地文件中的指令注入到对话上下文”,属于高影响操作;默认策略要求用户确认以明确知情与授权。
128151 </ p >
129152 </ div >
130153 </ Layer >
131154
132155 < Layer title = "Schema 收敛:把 name 变成 enum" icon = "🧷" >
133156 < p className = "text-gray-300 mb-4" >
134- 技能列表发现完成后,CLI 会< strong > 重新注册一次</ strong > < code > ActivateSkillTool</ code > ,让参数 < code > name</ code >
135- 从 < code > string</ code > 收敛为 < code > enum(availableSkillNames)</ code > ,从而减少模型“瞎猜技能名”的概率。
157+ 技能列表发现完成后,CLI 会< strong > 重新注册一次</ strong > { ' ' }
158+ < code > ActivateSkillTool</ code > ,让参数 < code > name</ code > 从{ ' ' }
159+ < code > string</ code > 收敛为 < code > enum(availableSkillNames)</ code >
160+ ,从而减少模型“瞎猜技能名”的概率。
136161 </ p >
137162 < CodeBlock
138163 title = "config.ts:发现技能后重注册工具"
139- code = { `// packages/core/src/config/config.ts (节选)
164+ code = { `// gemini-cli/ packages/core/src/config/config.ts (节选)
140165if (this.skillsSupport) {
141166 await this.getSkillManager().discoverSkills(this.storage, this.getExtensions());
142167 this.getSkillManager().setDisabledSkills(this.disabledSkills);
@@ -151,12 +176,14 @@ if (this.skillsSupport) {
151176
152177 < Layer title = "System Prompt 注入" icon = "🧱" >
153178 < p className = "text-gray-300 mb-4" >
154- 当存在可用 skills 时,System Prompt 会追加一个 < code > Available Agent Skills</ code > 段落,列出技能元信息,并要求模型:
155- 一旦拿到 < code > <ACTIVATED_SKILL></ code > ,必须把 < code > <INSTRUCTIONS></ code > 当作本任务的专家流程规范。
179+ 当存在可用 skills 时,System Prompt 会追加一个{ ' ' }
180+ < code > Available Agent Skills</ code > 段落,列出技能元信息,并要求模型:
181+ 一旦拿到 < code > <ACTIVATED_SKILL></ code > ,必须把{ ' ' }
182+ < code > <INSTRUCTIONS></ code > 当作本任务的专家流程规范。
156183 </ p >
157184 < CodeBlock
158185 title = "prompts.ts 片段(skillsPrompt)"
159- code = { `// packages/core/src/core/prompts.ts
186+ code = { `// gemini-cli/ packages/core/src/core/prompts.ts
160187const skills = config.getSkillManager().getSkills();
161188if (skills.length > 0) {
162189 skillsPrompt = \`
@@ -170,11 +197,13 @@ You have access to the following specialized skills...
170197
171198 < Layer title = "用户侧管理(/skills + settings)" icon = "🧰" >
172199 < p className = "text-gray-300 mb-4" >
173- Skills 目前属于实验特性:通过 < code > experimental.skills</ code > 开启;通过 < code > skills.disabled</ code > 禁用特定技能。
174- CLI 也提供 < code > /skills</ code > 命令用于列出与启用/禁用/刷新(禁用/启用后建议 < code > /skills reload</ code > 让本会话生效)。
200+ Skills 目前属于实验特性:通过 < code > experimental.skills</ code > { ' ' }
201+ 开启;通过 < code > skills.disabled</ code > 禁用特定技能。 CLI 也提供{ ' ' }
202+ < code > /skills</ code > 命令用于列出与启用/禁用/刷新(禁用/启用后建议{ ' ' }
203+ < code > /skills reload</ code > 让本会话生效)。
175204 </ p >
176205 < CodeBlock
177- title = "配置项(docs/cli/settings.md)"
206+ title = "配置项(gemini-cli/ docs/cli/settings.md)"
178207 code = { `experimental.skills: boolean # Enable Agent Skills (experimental)
179208skills.disabled: string[] # List of disabled skills (restart required)` }
180209 />
@@ -187,13 +216,15 @@ skills.disabled: string[] # List of disabled skills (restart required)`}
187216/skills reload` }
188217 />
189218 < p className = "text-xs text-gray-400 mt-2" >
190- 说明:< code > /skills list --all</ code > 会展示内建 skills(例如 < code > skill-creator</ code > ),否则默认隐藏。
219+ 说明:< code > /skills list --all</ code > 会展示内建 skills(例如{ ' ' }
220+ < code > skill-creator</ code > ),否则默认隐藏。
191221 </ p >
192222 </ Layer >
193223
194224 < Layer title = "终端命令(gemini skills)" icon = "🧪" >
195225 < p className = "text-gray-300 mb-4" >
196- 除了 Slash Commands,CLI 还提供 < code > gemini skills</ code > 子命令用于安装/卸载技能包(默认 user scope)。
226+ 除了 Slash Commands,CLI 还提供 < code > gemini skills</ code > { ' ' }
227+ 子命令用于安装/卸载技能包(默认 user scope)。
197228 </ p >
198229 < CodeBlock
199230 title = "gemini skills 管理"
@@ -213,12 +244,15 @@ gemini skills disable my-skill --scope workspace`}
213244
214245 < Layer title = "扩展技能与安全披露" icon = "🛡️" >
215246 < p className = "text-gray-300 mb-4" >
216- Extension 可以携带 < code > skills/</ code > 目录(例如 < code > skills/my-skill/SKILL.md</ code > )。在安装/更新扩展时,CLI 会在 consent
217- 文本中明确提示:< strong > Agent skills 会把指令注入 system prompt</ strong > ,并展示每个 skill 的名称、描述与文件位置,要求用户确认后才继续安装。
247+ Extension 可以携带 < code > skills/</ code > 目录(例如{ ' ' }
248+ < code > skills/my-skill/SKILL.md</ code > )。在安装/更新扩展时,CLI 会在
249+ consent 文本中明确提示:
250+ < strong > Agent skills 会把指令注入 system prompt</ strong > ,并展示每个
251+ skill 的名称、描述与文件位置,要求用户确认后才继续安装。
218252 </ p >
219253 < CodeBlock
220254 title = "extensions/consent.ts:skills 风险提示(节选)"
221- code = { `// packages/cli/src/config/extensions/consent.ts
255+ code = { `// gemini-cli/ packages/cli/src/config/extensions/consent.ts
222256export const SKILLS_WARNING_MESSAGE = chalk.yellow(
223257 "Agent skills inject specialized instructions and domain-specific knowledge into the agent's system prompt..."
224258);
0 commit comments