Skip to content

Commit 06b64b0

Browse files
authored
Merge pull request #1534 from QwenLM/feat/extension
Feat/extension
2 parents 21b26a4 + 9af348d commit 06b64b0

File tree

147 files changed

+14290
-6837
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+14290
-6837
lines changed

docs/developers/_meta.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ export default {
1919

2020
tools: 'Tools',
2121

22-
extensions: {
23-
display: 'hidden',
24-
},
2522
examples: {
2623
display: 'hidden',
2724
},

docs/developers/extensions/extension.md

Lines changed: 0 additions & 158 deletions
This file was deleted.

docs/users/_meta.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export default {
2020
},
2121
features: 'Features',
2222
configuration: 'Configuration',
23+
extension: 'Extension',
2324
reference: 'Reference',
2425
support: 'Support',
2526
// need refine

docs/users/extension/_meta.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export default {
2+
introduction: 'Introduction',
3+
'getting-start-extensions': {
4+
display: 'hidden',
5+
},
6+
'extension-releasing': {
7+
display: 'hidden',
8+
},
9+
};
File renamed without changes.

docs/developers/extensions/getting-started-extensions.md renamed to docs/users/extension/getting-started-extensions.md

Lines changed: 92 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -148,22 +148,107 @@ Custom commands provide a way to create shortcuts for complex prompts. Let's add
148148
mkdir -p commands/fs
149149
```
150150

151-
2. Create a file named `commands/fs/grep-code.toml`:
151+
2. Create a file named `commands/fs/grep-code.md`:
152+
153+
```markdown
154+
---
155+
description: Search for a pattern in code and summarize findings
156+
---
152157
153-
```toml
154-
prompt = """
155158
Please summarize the findings for the pattern `{{args}}`.
156159
157160
Search Results:
158161
!{grep -r {{args}} .}
159-
"""
160162
```
161163
162164
This command, `/fs:grep-code`, will take an argument, run the `grep` shell command with it, and pipe the results into a prompt for summarization.
163165
166+
> **Note:** Commands use Markdown format with optional YAML frontmatter. TOML format is deprecated but still supported for backwards compatibility.
167+
164168
After saving the file, restart the Qwen Code. You can now run `/fs:grep-code "some pattern"` to use your new command.
165169
166-
## Step 5: Add a Custom `QWEN.md`
170+
## Step 5: Add Custom Skills and Subagents (Optional)
171+
172+
Extensions can also provide custom skills and subagents to extend Qwen Code's capabilities.
173+
174+
### Adding a Custom Skill
175+
176+
Skills are model-invoked capabilities that the AI can automatically use when relevant.
177+
178+
1. Create a `skills` directory with a skill subdirectory:
179+
180+
```bash
181+
mkdir -p skills/code-analyzer
182+
```
183+
184+
2. Create a `skills/code-analyzer/SKILL.md` file:
185+
186+
```markdown
187+
---
188+
name: code-analyzer
189+
description: Analyzes code structure and provides insights about complexity, dependencies, and potential improvements
190+
---
191+
192+
# Code Analyzer
193+
194+
## Instructions
195+
196+
When analyzing code, focus on:
197+
198+
- Code complexity and maintainability
199+
- Dependencies and coupling
200+
- Potential performance issues
201+
- Suggestions for improvements
202+
203+
## Examples
204+
205+
- "Analyze the complexity of this function"
206+
- "What are the dependencies of this module?"
207+
```
208+
209+
### Adding a Custom Subagent
210+
211+
Subagents are specialized AI assistants for specific tasks.
212+
213+
1. Create an `agents` directory:
214+
215+
```bash
216+
mkdir -p agents
217+
```
218+
219+
2. Create an `agents/refactoring-expert.md` file:
220+
221+
```markdown
222+
---
223+
name: refactoring-expert
224+
description: Specialized in code refactoring, improving code structure and maintainability
225+
tools:
226+
- read_file
227+
- write_file
228+
- read_many_files
229+
---
230+
231+
You are a refactoring specialist focused on improving code quality.
232+
233+
Your expertise includes:
234+
235+
- Identifying code smells and anti-patterns
236+
- Applying SOLID principles
237+
- Improving code readability and maintainability
238+
- Safe refactoring with minimal risk
239+
240+
For each refactoring task:
241+
242+
1. Analyze the current code structure
243+
2. Identify areas for improvement
244+
3. Propose refactoring steps
245+
4. Implement changes incrementally
246+
5. Verify functionality is preserved
247+
```
248+
249+
After restarting Qwen Code, your custom skills will be available via `/skills` and subagents via `/agents manage`.
250+
251+
## Step 6: Add a Custom `QWEN.md`
167252
168253
You can provide persistent context to the model by adding a `QWEN.md` file to your extension. This is useful for giving the model instructions on how to behave or information about your extension's tools. Note that you may not always need this for extensions built to expose commands and prompts.
169254
@@ -194,7 +279,7 @@ You can provide persistent context to the model by adding a `QWEN.md` file to yo
194279
195280
Restart the CLI again. The model will now have the context from your `QWEN.md` file in every session where the extension is active.
196281
197-
## Step 6: Releasing Your Extension
282+
## Step 7: Releasing Your Extension
198283
199284
Once you are happy with your extension, you can share it with others. The two primary ways of releasing extensions are via a Git repository or through GitHub Releases. Using a public Git repository is the simplest method.
200285
@@ -207,6 +292,7 @@ You've successfully created a Qwen Code extension! You learned how to:
207292
- Bootstrap a new extension from a template.
208293
- Add custom tools with an MCP server.
209294
- Create convenient custom commands.
295+
- Add custom skills and subagents.
210296
- Provide persistent context to the model.
211297
- Link your extension for local development.
212298

0 commit comments

Comments
 (0)