mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-12 21:03:05 -07:00
[Skills] UX Polishing: Transparent feedback and CLI refinements (#15954)
This commit is contained in:
@@ -60,6 +60,7 @@ describe('skills disable command', () => {
|
|||||||
const mockSettings = {
|
const mockSettings = {
|
||||||
forScope: vi.fn().mockReturnValue({
|
forScope: vi.fn().mockReturnValue({
|
||||||
settings: { skills: { disabled: [] } },
|
settings: { skills: { disabled: [] } },
|
||||||
|
path: '/user/settings.json',
|
||||||
}),
|
}),
|
||||||
setValue: vi.fn(),
|
setValue: vi.fn(),
|
||||||
};
|
};
|
||||||
@@ -79,7 +80,7 @@ describe('skills disable command', () => {
|
|||||||
);
|
);
|
||||||
expect(emitConsoleLog).toHaveBeenCalledWith(
|
expect(emitConsoleLog).toHaveBeenCalledWith(
|
||||||
'log',
|
'log',
|
||||||
'Skill "skill1" disabled by adding it to the disabled list in user settings.',
|
'Skill "skill1" disabled by adding it to the disabled list in user (/user/settings.json) settings. Restart required to take effect.',
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -5,19 +5,16 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import type { CommandModule } from 'yargs';
|
import type { CommandModule } from 'yargs';
|
||||||
import {
|
import { loadSettings, SettingScope } from '../../config/settings.js';
|
||||||
loadSettings,
|
|
||||||
SettingScope,
|
|
||||||
type LoadableSettingScope,
|
|
||||||
} from '../../config/settings.js';
|
|
||||||
import { debugLogger } from '@google/gemini-cli-core';
|
import { debugLogger } from '@google/gemini-cli-core';
|
||||||
import { exitCli } from '../utils.js';
|
import { exitCli } from '../utils.js';
|
||||||
import { disableSkill } from '../../utils/skillSettings.js';
|
import { disableSkill } from '../../utils/skillSettings.js';
|
||||||
import { renderSkillActionFeedback } from '../../utils/skillUtils.js';
|
import { renderSkillActionFeedback } from '../../utils/skillUtils.js';
|
||||||
|
import chalk from 'chalk';
|
||||||
|
|
||||||
interface DisableArgs {
|
interface DisableArgs {
|
||||||
name: string;
|
name: string;
|
||||||
scope: LoadableSettingScope;
|
scope: SettingScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function handleDisable(args: DisableArgs) {
|
export async function handleDisable(args: DisableArgs) {
|
||||||
@@ -26,7 +23,14 @@ export async function handleDisable(args: DisableArgs) {
|
|||||||
const settings = loadSettings(workspaceDir);
|
const settings = loadSettings(workspaceDir);
|
||||||
|
|
||||||
const result = disableSkill(settings, name, scope);
|
const result = disableSkill(settings, name, scope);
|
||||||
debugLogger.log(renderSkillActionFeedback(result, (label, _path) => label));
|
let feedback = renderSkillActionFeedback(
|
||||||
|
result,
|
||||||
|
(label, path) => `${chalk.bold(label)} (${chalk.dim(path)})`,
|
||||||
|
);
|
||||||
|
if (result.status === 'success') {
|
||||||
|
feedback += ' Restart required to take effect.';
|
||||||
|
}
|
||||||
|
debugLogger.log(feedback);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const disableCommand: CommandModule = {
|
export const disableCommand: CommandModule = {
|
||||||
@@ -43,11 +47,11 @@ export const disableCommand: CommandModule = {
|
|||||||
alias: 's',
|
alias: 's',
|
||||||
describe: 'The scope to disable the skill in (user or project).',
|
describe: 'The scope to disable the skill in (user or project).',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: 'user',
|
default: 'project',
|
||||||
choices: ['user', 'project'],
|
choices: ['user', 'project'],
|
||||||
}),
|
}),
|
||||||
handler: async (argv) => {
|
handler: async (argv) => {
|
||||||
const scope: LoadableSettingScope =
|
const scope =
|
||||||
argv['scope'] === 'project' ? SettingScope.Workspace : SettingScope.User;
|
argv['scope'] === 'project' ? SettingScope.Workspace : SettingScope.User;
|
||||||
await handleDisable({
|
await handleDisable({
|
||||||
name: argv['name'] as string,
|
name: argv['name'] as string,
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ describe('skills enable command', () => {
|
|||||||
);
|
);
|
||||||
expect(emitConsoleLog).toHaveBeenCalledWith(
|
expect(emitConsoleLog).toHaveBeenCalledWith(
|
||||||
'log',
|
'log',
|
||||||
'Skill "skill1" enabled by removing it from the disabled list in user and project settings.',
|
'Skill "skill1" enabled by removing it from the disabled list in user (/user/settings.json) and project (/project/settings.json) settings. Restart required to take effect.',
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -122,7 +122,7 @@ describe('skills enable command', () => {
|
|||||||
);
|
);
|
||||||
expect(emitConsoleLog).toHaveBeenCalledWith(
|
expect(emitConsoleLog).toHaveBeenCalledWith(
|
||||||
'log',
|
'log',
|
||||||
'Skill "skill1" enabled by removing it from the disabled list in project and user settings.',
|
'Skill "skill1" enabled by removing it from the disabled list in project (/workspace/settings.json) and user (/user/settings.json) settings. Restart required to take effect.',
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { debugLogger } from '@google/gemini-cli-core';
|
|||||||
import { exitCli } from '../utils.js';
|
import { exitCli } from '../utils.js';
|
||||||
import { enableSkill } from '../../utils/skillSettings.js';
|
import { enableSkill } from '../../utils/skillSettings.js';
|
||||||
import { renderSkillActionFeedback } from '../../utils/skillUtils.js';
|
import { renderSkillActionFeedback } from '../../utils/skillUtils.js';
|
||||||
|
import chalk from 'chalk';
|
||||||
|
|
||||||
interface EnableArgs {
|
interface EnableArgs {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -21,7 +22,14 @@ export async function handleEnable(args: EnableArgs) {
|
|||||||
const settings = loadSettings(workspaceDir);
|
const settings = loadSettings(workspaceDir);
|
||||||
|
|
||||||
const result = enableSkill(settings, name);
|
const result = enableSkill(settings, name);
|
||||||
debugLogger.log(renderSkillActionFeedback(result, (label, _path) => label));
|
let feedback = renderSkillActionFeedback(
|
||||||
|
result,
|
||||||
|
(label, path) => `${chalk.bold(label)} (${chalk.dim(path)})`,
|
||||||
|
);
|
||||||
|
if (result.status === 'success') {
|
||||||
|
feedback += ' Restart required to take effect.';
|
||||||
|
}
|
||||||
|
debugLogger.log(feedback);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const enableCommand: CommandModule = {
|
export const enableCommand: CommandModule = {
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ describe('skillsCommand', () => {
|
|||||||
expect(context.ui.addItem).toHaveBeenCalledWith(
|
expect(context.ui.addItem).toHaveBeenCalledWith(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
type: MessageType.INFO,
|
type: MessageType.INFO,
|
||||||
text: 'Skill "skill1" disabled by adding it to the disabled list in project settings. Use "/skills reload" for it to take effect.',
|
text: 'Skill "skill1" disabled by adding it to the disabled list in project (/workspace) settings. Use "/skills reload" for it to take effect.',
|
||||||
}),
|
}),
|
||||||
expect.any(Number),
|
expect.any(Number),
|
||||||
);
|
);
|
||||||
@@ -211,7 +211,7 @@ describe('skillsCommand', () => {
|
|||||||
expect(context.ui.addItem).toHaveBeenCalledWith(
|
expect(context.ui.addItem).toHaveBeenCalledWith(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
type: MessageType.INFO,
|
type: MessageType.INFO,
|
||||||
text: 'Skill "skill1" enabled by removing it from the disabled list in project and user settings. Use "/skills reload" for it to take effect.',
|
text: 'Skill "skill1" enabled by removing it from the disabled list in project (/workspace) and user (/user/settings.json) settings. Use "/skills reload" for it to take effect.',
|
||||||
}),
|
}),
|
||||||
expect.any(Number),
|
expect.any(Number),
|
||||||
);
|
);
|
||||||
@@ -251,7 +251,7 @@ describe('skillsCommand', () => {
|
|||||||
expect(context.ui.addItem).toHaveBeenCalledWith(
|
expect(context.ui.addItem).toHaveBeenCalledWith(
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
type: MessageType.INFO,
|
type: MessageType.INFO,
|
||||||
text: 'Skill "skill1" enabled by removing it from the disabled list in project and user settings. Use "/skills reload" for it to take effect.',
|
text: 'Skill "skill1" enabled by removing it from the disabled list in project (/workspace) and user (/user/settings.json) settings. Use "/skills reload" for it to take effect.',
|
||||||
}),
|
}),
|
||||||
expect.any(Number),
|
expect.any(Number),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ async function disableAction(
|
|||||||
|
|
||||||
let feedback = renderSkillActionFeedback(
|
let feedback = renderSkillActionFeedback(
|
||||||
result,
|
result,
|
||||||
(label, _path) => `${label}`,
|
(label, path) => `${label} (${path})`,
|
||||||
);
|
);
|
||||||
if (result.status === 'success') {
|
if (result.status === 'success') {
|
||||||
feedback += ' Use "/skills reload" for it to take effect.';
|
feedback += ' Use "/skills reload" for it to take effect.';
|
||||||
@@ -131,7 +131,7 @@ async function enableAction(
|
|||||||
|
|
||||||
let feedback = renderSkillActionFeedback(
|
let feedback = renderSkillActionFeedback(
|
||||||
result,
|
result,
|
||||||
(label, _path) => `${label}`,
|
(label, path) => `${label} (${path})`,
|
||||||
);
|
);
|
||||||
if (result.status === 'success') {
|
if (result.status === 'success') {
|
||||||
feedback += ' Use "/skills reload" for it to take effect.';
|
feedback += ' Use "/skills reload" for it to take effect.';
|
||||||
|
|||||||
Reference in New Issue
Block a user