refactor(skills): replace 'project' with 'workspace' scope (#16380)

This commit is contained in:
N. Taylor Mullen
2026-01-14 13:05:26 -08:00
committed by GitHub
parent b3eecc3a50
commit c8c7b57a79
8 changed files with 56 additions and 26 deletions

View File

@@ -84,6 +84,34 @@ describe('skills disable command', () => {
);
});
it('should disable an enabled skill in workspace scope', async () => {
const mockSettings = {
forScope: vi.fn().mockReturnValue({
settings: { skills: { disabled: [] } },
path: '/workspace/.gemini/settings.json',
}),
setValue: vi.fn(),
};
mockLoadSettings.mockReturnValue(
mockSettings as unknown as LoadedSettings,
);
await handleDisable({
name: 'skill1',
scope: SettingScope.Workspace as LoadableSettingScope,
});
expect(mockSettings.setValue).toHaveBeenCalledWith(
SettingScope.Workspace,
'skills.disabled',
['skill1'],
);
expect(emitConsoleLog).toHaveBeenCalledWith(
'log',
'Skill "skill1" disabled by adding it to the disabled list in workspace (/workspace/.gemini/settings.json) settings.',
);
});
it('should log a message if the skill is already disabled', async () => {
const mockSettings = {
forScope: vi.fn().mockReturnValue({

View File

@@ -42,14 +42,16 @@ export const disableCommand: CommandModule = {
})
.option('scope', {
alias: 's',
describe: 'The scope to disable the skill in (user or project).',
describe: 'The scope to disable the skill in (user or workspace).',
type: 'string',
default: 'project',
choices: ['user', 'project'],
default: 'workspace',
choices: ['user', 'workspace'],
}),
handler: async (argv) => {
const scope =
argv['scope'] === 'project' ? SettingScope.Workspace : SettingScope.User;
argv['scope'] === 'workspace'
? SettingScope.Workspace
: SettingScope.User;
await handleDisable({
name: argv['name'] as string,
scope,

View File

@@ -64,7 +64,7 @@ describe('skills enable command', () => {
path: '/user/settings.json',
};
}
return { settings: {}, path: '/project/settings.json' };
return { settings: {}, path: '/workspace/settings.json' };
}),
setValue: vi.fn(),
};
@@ -81,7 +81,7 @@ describe('skills enable command', () => {
);
expect(emitConsoleLog).toHaveBeenCalledWith(
'log',
'Skill "skill1" enabled by removing it from the disabled list in user (/user/settings.json) and project (/project/settings.json) settings.',
'Skill "skill1" enabled by removing it from the disabled list in user (/user/settings.json) and workspace (/workspace/settings.json) settings.',
);
});
@@ -122,7 +122,7 @@ describe('skills enable command', () => {
);
expect(emitConsoleLog).toHaveBeenCalledWith(
'log',
'Skill "skill1" enabled by removing it from the disabled list in project (/workspace/settings.json) and user (/user/settings.json) settings.',
'Skill "skill1" enabled by removing it from the disabled list in workspace (/workspace/settings.json) and user (/user/settings.json) settings.',
);
});

View File

@@ -225,7 +225,7 @@ describe('skillsCommand', () => {
expect(context.ui.addItem).toHaveBeenCalledWith(
expect.objectContaining({
type: MessageType.INFO,
text: 'Skill "skill1" disabled by adding it to the disabled list in project (/workspace) settings. Use "/skills reload" for it to take effect.',
text: 'Skill "skill1" disabled by adding it to the disabled list in workspace (/workspace) settings. Use "/skills reload" for it to take effect.',
}),
);
});
@@ -253,7 +253,7 @@ describe('skillsCommand', () => {
expect(context.ui.addItem).toHaveBeenCalledWith(
expect.objectContaining({
type: MessageType.INFO,
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.',
text: 'Skill "skill1" enabled by removing it from the disabled list in workspace (/workspace) and user (/user/settings.json) settings. Use "/skills reload" for it to take effect.',
}),
);
});
@@ -292,7 +292,7 @@ describe('skillsCommand', () => {
expect(context.ui.addItem).toHaveBeenCalledWith(
expect.objectContaining({
type: MessageType.INFO,
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.',
text: 'Skill "skill1" enabled by removing it from the disabled list in workspace (/workspace) and user (/user/settings.json) settings. Use "/skills reload" for it to take effect.',
}),
);
});

View File

@@ -47,7 +47,7 @@ export function renderSkillActionFeedback(
const formatScopeItem = (s: { scope: SettingScope; path: string }) => {
const label =
s.scope === SettingScope.Workspace ? 'project' : s.scope.toLowerCase();
s.scope === SettingScope.Workspace ? 'workspace' : s.scope.toLowerCase();
return formatScope(label, s.path);
};