Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 49 additions & 11 deletions packages/cli/src/ui/commands/skillsCommand.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface FakeSkill {
description?: string;
priority?: number;
userInvocable?: boolean;
level?: string;
}

function makeContext(opts: {
Expand Down Expand Up @@ -108,9 +109,24 @@ describe('skillsCommand bare entry', () => {
if (!skillsCommand.action) throw new Error('action missing');
const context = makeContext({
skills: [
{ name: 'high', priority: 100 },
{ name: 'low', priority: -5 },
{ name: 'mid', priority: 10 },
{
name: 'high',
priority: 100,
description: 'High priority',
level: 'project',
},
{
name: 'low',
priority: -5,
description: 'Low priority',
level: 'bundled',
},
{
name: 'mid',
priority: 10,
description: 'Mid priority',
level: 'user',
},
],
executionMode: 'acp',
});
Comment thread
doudouOUC marked this conversation as resolved.
Expand All @@ -120,7 +136,11 @@ describe('skillsCommand bare entry', () => {
expect(context.ui.addItem).toHaveBeenCalledWith(
{
type: MessageType.SKILLS_LIST,
skills: [{ name: 'high' }, { name: 'mid' }, { name: 'low' }],
skills: [
{ name: 'high', description: 'High priority', level: 'Project' },
{ name: 'mid', description: 'Mid priority', level: 'User' },
{ name: 'low', description: 'Low priority', level: 'Bundled' },
],
},
expect.any(Number),
);
Expand All @@ -130,9 +150,14 @@ describe('skillsCommand bare entry', () => {
if (!skillsCommand.action) throw new Error('action missing');
const context = makeContext({
skills: [
{ name: 'alpha' },
{ name: 'model-only', userInvocable: false },
{ name: 'gamma' },
{ name: 'alpha', description: 'Alpha skill', level: 'bundled' },
{
name: 'model-only',
userInvocable: false,
description: 'Model only',
level: 'bundled',
},
{ name: 'gamma', description: 'Gamma skill', level: 'bundled' },
],
executionMode: 'non_interactive',
});
Expand All @@ -142,7 +167,10 @@ describe('skillsCommand bare entry', () => {
expect(context.ui.addItem).toHaveBeenCalledWith(
{
type: MessageType.SKILLS_LIST,
skills: [{ name: 'alpha' }, { name: 'gamma' }],
skills: [
{ name: 'alpha', description: 'Alpha skill', level: 'Bundled' },
{ name: 'gamma', description: 'Gamma skill', level: 'Bundled' },
],
},
expect.any(Number),
);
Expand All @@ -151,7 +179,11 @@ describe('skillsCommand bare entry', () => {
it('omits disabled skills from the non-interactive listing', async () => {
if (!skillsCommand.action) throw new Error('action missing');
const context = makeContext({
skills: [{ name: 'alpha' }, { name: 'beta' }, { name: 'gamma' }],
skills: [
{ name: 'alpha', description: 'Alpha', level: 'bundled' },
{ name: 'beta', description: 'Beta', level: 'bundled' },
{ name: 'gamma', description: 'Gamma', level: 'bundled' },
],
workspaceDisabled: ['beta'],
mergedDisabled: ['beta'],
executionMode: 'non_interactive',
Expand All @@ -162,7 +194,10 @@ describe('skillsCommand bare entry', () => {
expect(context.ui.addItem).toHaveBeenCalledWith(
{
type: MessageType.SKILLS_LIST,
skills: [{ name: 'alpha' }, { name: 'gamma' }],
skills: [
{ name: 'alpha', description: 'Alpha', level: 'Bundled' },
{ name: 'gamma', description: 'Gamma', level: 'Bundled' },
],
},
expect.any(Number),
);
Expand All @@ -189,7 +224,10 @@ describe('skillsCommand bare entry', () => {
it('shows a clarifying message when all skills are disabled in non-interactive mode', async () => {
if (!skillsCommand.action) throw new Error('action missing');
const context = makeContext({
skills: [{ name: 'a' }, { name: 'b' }],
skills: [
{ name: 'a', description: 'Skill A', level: 'bundled' },
{ name: 'b', description: 'Skill B', level: 'bundled' },
],
workspaceDisabled: ['a', 'b'],
mergedDisabled: ['a', 'b'],
executionMode: 'acp',
Expand Down
7 changes: 6 additions & 1 deletion packages/cli/src/ui/commands/skillsCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
import { MessageType, type HistoryItemSkillsList } from '../types.js';
import { t } from '../../i18n/index.js';
import { normalizeSkillPriority } from '@qwen-code/qwen-code-core';
import { levelLabel } from '../utils/skill-level-label.js';

export const skillsCommand: SlashCommand = {
name: 'skills',
Expand Down Expand Up @@ -87,7 +88,11 @@ export const skillsCommand: SlashCommand = {
);
const skillsListItem: HistoryItemSkillsList = {
type: MessageType.SKILLS_LIST,
skills: sortedSkills.map((skill) => ({ name: skill.name })),
skills: sortedSkills.map((skill) => ({
name: skill.name,
description: skill.description,
level: levelLabel(skill.level),
})),
};
context.ui.addItem(skillsListItem, Date.now());
},
Expand Down
18 changes: 1 addition & 17 deletions packages/cli/src/ui/components/skills/SkillsManagerDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import type {
import type { LoadedSettings } from '../../../config/settings.js';
import { SettingScope } from '../../../config/settings.js';
import { t } from '../../../i18n/index.js';
import { levelLabel } from '../../utils/skill-level-label.js';
import type { UseHistoryManagerReturn } from '../../hooks/useHistoryManager.js';
import { useKeypress } from '../../hooks/useKeypress.js';
import { theme } from '../../semantic-colors.js';
Expand Down Expand Up @@ -68,23 +69,6 @@ const LEVEL_ORDER: Record<SkillLevel, number> = {
bundled: 3,
};

// Level labels are looked up at render-time (not module-load) so that
// switching `/language` after startup actually flips the visible label.
function levelLabel(level: SkillLevel): string {
switch (level) {
case 'project':
return t('Project');
case 'user':
return t('User');
case 'extension':
return t('Extension');
case 'bundled':
return t('Bundled');
default:
return level;
}
}

const NAME_COLUMN = 24;

function lower(name: string): string {
Expand Down
22 changes: 21 additions & 1 deletion packages/cli/src/ui/components/views/SkillsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ import { theme } from '../../semantic-colors.js';
import { type SkillDefinition } from '../../types.js';
import { t } from '../../../i18n/index.js';

const NAME_COLUMN = 24;
Comment thread
doudouOUC marked this conversation as resolved.

function truncate(text: string, max: number): string {
if (text.length <= max) return text;
Comment thread
doudouOUC marked this conversation as resolved.
return `${text.slice(0, Math.max(0, max - 1))}…`;
}

interface SkillsListProps {
skills: readonly SkillDefinition[];
}
Expand All @@ -25,8 +32,21 @@ export const SkillsList: React.FC<SkillsListProps> = ({ skills }) => (
<Box key={skill.name} flexDirection="row">
<Text color={theme.text.primary}>{' '}- </Text>
<Text bold color={theme.text.accent}>
{skill.name}
{skill.description
? truncate(skill.name, NAME_COLUMN).padEnd(NAME_COLUMN)
: skill.name}
</Text>
{skill.description && (
<Text color={theme.text.secondary}>
{' '}
{truncate(skill.description, 80)}
</Text>
)}
{skill.level && (
<Text color={theme.text.secondary}>
{' '}({skill.level})
Comment thread
doudouOUC marked this conversation as resolved.
Outdated
</Text>
)}
</Box>
))
) : (
Expand Down
9 changes: 3 additions & 6 deletions packages/cli/src/ui/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@ export interface ToolDefinition {

export interface SkillDefinition {
name: string;
description?: string;
level?: string;
Comment thread
doudouOUC marked this conversation as resolved.
}

export type HistoryItemToolsList = HistoryItemBase & {
Expand Down Expand Up @@ -564,12 +566,7 @@ export type HistoryItemDoctor = HistoryItemBase & {
};

export type GoalStatusKind =
| 'set'
| 'achieved'
| 'cleared'
| 'failed'
| 'aborted'
| 'checking';
'set' | 'achieved' | 'cleared' | 'failed' | 'aborted' | 'checking';

export const TERMINAL_GOAL_STATUS_KINDS = [
'achieved',
Expand Down
24 changes: 24 additions & 0 deletions packages/cli/src/ui/utils/skill-level-label.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* @license
* Copyright 2025 Qwen
* SPDX-License-Identifier: Apache-2.0
*/

import type { SkillLevel } from '@qwen-code/qwen-code-core';
import { t } from '../../i18n/index.js';

// Call at render/command time, not module-load, so `/language` switches take effect.
export function levelLabel(level: SkillLevel): string {
Comment thread
doudouOUC marked this conversation as resolved.
switch (level) {
case 'project':
return t('Project');
case 'user':
return t('User');
case 'extension':
return t('Extension');
case 'bundled':
return t('Bundled');
default:
return level;
Comment thread
doudouOUC marked this conversation as resolved.
Outdated
}
}
Loading