mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-29 20:20:57 +00:00
fix(review): prepend YOUR_MODEL_ID declaration for model attribution
Some models (e.g., glm-5.1) ignore the {{model}} template in code
blocks and write their own footer without the model name. Fix:
1. BundledSkillLoader prepends YOUR_MODEL_ID="glm-5.1" as a top-level
declaration at the start of the skill body — impossible to miss
2. SKILL.md references YOUR_MODEL_ID in footer instructions
3. Empty model → empty string (no "unknown" — prefer omission)
4. YOUR_MODEL_ID declaration only prepended when model is available
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
3364cf880f
commit
df3cfd1e83
3 changed files with 26 additions and 12 deletions
|
|
@ -146,11 +146,15 @@ describe('BundledSkillLoader', () => {
|
|||
|
||||
expect(result).toEqual({
|
||||
type: 'submit_prompt',
|
||||
content: [{ text: 'Review by qwen3-coder via Qwen Code' }],
|
||||
content: [
|
||||
{
|
||||
text: 'YOUR_MODEL_ID="qwen3-coder"\n\nReview by qwen3-coder via Qwen Code',
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it('should use "unknown" for {{model}} when getModel returns undefined', async () => {
|
||||
it('should use empty string for {{model}} when getModel returns undefined', async () => {
|
||||
const skill = makeSkill({
|
||||
body: 'Review by {{model}}',
|
||||
});
|
||||
|
|
@ -166,7 +170,7 @@ describe('BundledSkillLoader', () => {
|
|||
|
||||
expect(result).toEqual({
|
||||
type: 'submit_prompt',
|
||||
content: [{ text: 'Review by unknown' }],
|
||||
content: [{ text: 'Review by ' }],
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -188,11 +192,15 @@ describe('BundledSkillLoader', () => {
|
|||
|
||||
expect(result).toEqual({
|
||||
type: 'submit_prompt',
|
||||
content: [{ text: 'Review by qwen3-coder\n\n/review 123' }],
|
||||
content: [
|
||||
{
|
||||
text: 'YOUR_MODEL_ID="qwen3-coder"\n\nReview by qwen3-coder\n\n/review 123',
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it('should use "unknown" for {{model}} when getModel returns empty string', async () => {
|
||||
it('should use empty string for {{model}} when getModel returns empty string', async () => {
|
||||
const skill = makeSkill({
|
||||
body: 'Review by {{model}}',
|
||||
});
|
||||
|
|
@ -208,7 +216,7 @@ describe('BundledSkillLoader', () => {
|
|||
|
||||
expect(result).toEqual({
|
||||
type: 'submit_prompt',
|
||||
content: [{ text: 'Review by unknown' }],
|
||||
content: [{ text: 'Review by ' }],
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -59,11 +59,17 @@ export class BundledSkillLoader implements ICommandLoader {
|
|||
description: skill.description,
|
||||
kind: CommandKind.SKILL,
|
||||
action: async (context, _args): Promise<SlashCommandActionReturn> => {
|
||||
// Resolve template variables in skill body (e.g., {{model}})
|
||||
// Resolve template variables in skill body
|
||||
let body = skill.body;
|
||||
if (body.includes('{{model}}')) {
|
||||
const modelId = this.config?.getModel()?.trim() || 'unknown';
|
||||
const modelId = this.config?.getModel()?.trim() || '';
|
||||
if (body.includes('{{model}}') || body.includes('YOUR_MODEL_ID')) {
|
||||
body = body.replaceAll('{{model}}', modelId);
|
||||
body = body.replaceAll('YOUR_MODEL_ID', modelId);
|
||||
// Prepend model identity as a top-level declaration so the LLM
|
||||
// cannot miss it even if it doesn't copy the template exactly.
|
||||
if (modelId) {
|
||||
body = `YOUR_MODEL_ID="${modelId}"\n\n${body}`;
|
||||
}
|
||||
}
|
||||
|
||||
const content = context.invocation?.args
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue