Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
35 changes: 35 additions & 0 deletions packages/cli/src/ui/commands/contextCommand.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function makeMockConfig(contextWindowSize = 32_000): Config {
getSkillManager: vi.fn().mockReturnValue({
listSkills: vi.fn().mockResolvedValue([]),
}),
getDisabledSkillNames: vi.fn().mockReturnValue(new Set()),
getChatCompression: vi.fn().mockReturnValue(undefined),
getAutoCompactThreshold: vi.fn(),
getExperimentalZedIntegration: vi.fn().mockReturnValue(false),
Expand Down Expand Up @@ -83,6 +84,7 @@ describe('collectContextData (contextCommand)', () => {
getSkillManager: vi.fn().mockReturnValue({
listSkills: vi.fn().mockResolvedValue([]),
}),
getDisabledSkillNames: vi.fn().mockReturnValue(new Set()),
getChatCompression: vi.fn().mockReturnValue(undefined),
getAutoCompactThreshold: vi.fn(),
getExperimentalZedIntegration: vi.fn().mockReturnValue(false),
Expand Down Expand Up @@ -205,6 +207,7 @@ describe('collectContextData (contextCommand)', () => {
getSkillManager: vi.fn().mockReturnValue({
listSkills: vi.fn().mockResolvedValue([]),
}),
getDisabledSkillNames: vi.fn().mockReturnValue(new Set()),
getChatCompression: vi.fn().mockReturnValue(undefined),
getAutoCompactThreshold: vi.fn(),
getExperimentalZedIntegration: vi.fn().mockReturnValue(false),
Expand Down Expand Up @@ -250,6 +253,7 @@ describe('collectContextData (contextCommand)', () => {
getSkillManager: vi.fn().mockReturnValue({
listSkills: vi.fn().mockResolvedValue([]),
}),
getDisabledSkillNames: vi.fn().mockReturnValue(new Set()),
getChatCompression: vi.fn().mockReturnValue(undefined),
getAutoCompactThreshold: vi.fn(),
getExperimentalZedIntegration: vi.fn().mockReturnValue(false),
Expand Down Expand Up @@ -281,6 +285,37 @@ describe('collectContextData (contextCommand)', () => {
expect(data.memoryFiles[0].path).toBe(t('auto memory'));
expect(data.memoryFiles[0].tokens).toBeGreaterThan(0);
});

it('excludes disabled skills from the detail breakdown', async () => {
const config = {
...makeMockConfig(),
getSkillManager: vi.fn().mockReturnValue({
listSkills: vi.fn().mockResolvedValue([
{
name: 'enabled-skill',
description: 'Enabled skill',
level: 'user',
filePath: '/skills/enabled-skill/SKILL.md',
body: 'Enabled body',
},
{
name: 'Disabled-Skill',
description: 'Disabled skill',
level: 'user',
filePath: '/skills/disabled-skill/SKILL.md',
body: 'Disabled body',
},
]),
}),
getDisabledSkillNames: vi
.fn()
.mockReturnValue(new Set(['disabled-skill'])),
} as unknown as Config;

const data = await collectContextData(config, true);

expect(data.skills.map((skill) => skill.name)).toEqual(['enabled-skill']);
});
});

describe('/context shows three-tier thresholds', () => {
Expand Down
7 changes: 6 additions & 1 deletion packages/cli/src/ui/commands/contextCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ export async function collectContextData(

const skillManager = config.getSkillManager();
const skillConfigs = skillManager ? await skillManager.listSkills() : [];
const disabledSkillNames = config.getDisabledSkillNames();
let loadedBodiesTokens = 0;
const skills: ContextSkillDetail[] = skillConfigs.map((skill) => {
const listingTokens = estimateTokens(
Expand Down Expand Up @@ -382,7 +383,11 @@ export async function collectContextData(
builtinTools: showDetails ? detailBuiltinTools : [],
mcpTools: showDetails ? detailMcpTools : [],
memoryFiles: showDetails ? detailMemoryFiles : [],
skills: showDetails ? detailSkills : [],
skills: showDetails
? detailSkills.filter(
(skill) => !disabledSkillNames.has(skill.name.toLowerCase()),
)
: [],
isEstimated,
showDetails,
};
Expand Down
Loading