mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-11 06:31:01 -07:00
feat: add /features command and lifecycle visibility
This commit is contained in:
@@ -31,6 +31,7 @@ import { docsCommand } from '../ui/commands/docsCommand.js';
|
||||
import { directoryCommand } from '../ui/commands/directoryCommand.js';
|
||||
import { editorCommand } from '../ui/commands/editorCommand.js';
|
||||
import { extensionsCommand } from '../ui/commands/extensionsCommand.js';
|
||||
import { featuresCommand } from '../ui/commands/featuresCommand.js';
|
||||
import { footerCommand } from '../ui/commands/footerCommand.js';
|
||||
import { helpCommand } from '../ui/commands/helpCommand.js';
|
||||
import { shortcutsCommand } from '../ui/commands/shortcutsCommand.js';
|
||||
@@ -119,6 +120,7 @@ export class BuiltinCommandLoader implements ICommandLoader {
|
||||
},
|
||||
]
|
||||
: [extensionsCommand(this.config?.getEnableExtensionReloading())]),
|
||||
featuresCommand,
|
||||
helpCommand,
|
||||
footerCommand,
|
||||
shortcutsCommand,
|
||||
|
||||
64
packages/cli/src/ui/commands/featuresCommand.test.ts
Normal file
64
packages/cli/src/ui/commands/featuresCommand.test.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2026 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import { describe, it, expect, type vi } from 'vitest';
|
||||
import { featuresCommand } from './featuresCommand.js';
|
||||
import { createMockCommandContext } from '../../test-utils/mockCommandContext.js';
|
||||
import { MessageType, type HistoryItemFeaturesList } from '../types.js';
|
||||
import { FeatureStage } from '@google/gemini-cli-core';
|
||||
|
||||
describe('featuresCommand', () => {
|
||||
it('should display an error if the feature gate is unavailable', async () => {
|
||||
const mockContext = createMockCommandContext({
|
||||
services: {
|
||||
config: {
|
||||
getFeatureGate: () => undefined,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (!featuresCommand.action) throw new Error('Action not defined');
|
||||
await featuresCommand.action(mockContext, '');
|
||||
|
||||
expect(mockContext.ui.addItem).toHaveBeenCalledWith({
|
||||
type: MessageType.ERROR,
|
||||
text: 'Could not retrieve feature gate.',
|
||||
});
|
||||
});
|
||||
|
||||
it('should list alpha, beta, and deprecated features', async () => {
|
||||
const mockFeatures = [
|
||||
{ key: 'alphaFeat', enabled: false, stage: FeatureStage.Alpha },
|
||||
{ key: 'betaFeat', enabled: true, stage: FeatureStage.Beta },
|
||||
{ key: 'deprecatedFeat', enabled: false, stage: FeatureStage.Deprecated },
|
||||
{ key: 'gaFeat', enabled: true, stage: FeatureStage.GA },
|
||||
];
|
||||
|
||||
const mockContext = createMockCommandContext({
|
||||
services: {
|
||||
config: {
|
||||
getFeatureGate: () => ({
|
||||
getFeatureInfo: () => mockFeatures,
|
||||
}),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (!featuresCommand.action) throw new Error('Action not defined');
|
||||
await featuresCommand.action(mockContext, '');
|
||||
|
||||
const [message] = (mockContext.ui.addItem as ReturnType<typeof vi.fn>).mock
|
||||
.calls[0];
|
||||
const featuresList = message as HistoryItemFeaturesList;
|
||||
expect(featuresList.type).toBe(MessageType.FEATURES_LIST);
|
||||
expect(featuresList.features).toHaveLength(3);
|
||||
expect(featuresList.features.map((f) => f.key)).toEqual([
|
||||
'alphaFeat',
|
||||
'betaFeat',
|
||||
'deprecatedFeat',
|
||||
]);
|
||||
});
|
||||
});
|
||||
46
packages/cli/src/ui/commands/featuresCommand.ts
Normal file
46
packages/cli/src/ui/commands/featuresCommand.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2026 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import {
|
||||
type CommandContext,
|
||||
type SlashCommand,
|
||||
CommandKind,
|
||||
} from './types.js';
|
||||
import { MessageType, type HistoryItemFeaturesList } from '../types.js';
|
||||
import { FeatureStage } from '@google/gemini-cli-core';
|
||||
|
||||
export const featuresCommand: SlashCommand = {
|
||||
name: 'features',
|
||||
altNames: ['feature'],
|
||||
description: 'List alpha, beta, and deprecated Gemini CLI features.',
|
||||
kind: CommandKind.BUILT_IN,
|
||||
autoExecute: false,
|
||||
action: async (context: CommandContext): Promise<void> => {
|
||||
const featureGate = context.services.config?.getFeatureGate();
|
||||
if (!featureGate) {
|
||||
context.ui.addItem({
|
||||
type: MessageType.ERROR,
|
||||
text: 'Could not retrieve feature gate.',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const allFeatures = featureGate.getFeatureInfo();
|
||||
const filteredFeatures = allFeatures.filter(
|
||||
(f) =>
|
||||
f.stage === FeatureStage.Alpha ||
|
||||
f.stage === FeatureStage.Beta ||
|
||||
f.stage === FeatureStage.Deprecated,
|
||||
);
|
||||
|
||||
const featuresListItem: HistoryItemFeaturesList = {
|
||||
type: MessageType.FEATURES_LIST,
|
||||
features: filteredFeatures,
|
||||
};
|
||||
|
||||
context.ui.addItem(featuresListItem);
|
||||
},
|
||||
};
|
||||
@@ -29,6 +29,7 @@ import { ExtensionsList } from './views/ExtensionsList.js';
|
||||
import { getMCPServerStatus } from '@google/gemini-cli-core';
|
||||
import { ToolsList } from './views/ToolsList.js';
|
||||
import { SkillsList } from './views/SkillsList.js';
|
||||
import { FeaturesList } from './views/FeaturesList.js';
|
||||
import { AgentsStatus } from './views/AgentsStatus.js';
|
||||
import { McpStatus } from './views/McpStatus.js';
|
||||
import { ChatList } from './views/ChatList.js';
|
||||
@@ -205,6 +206,9 @@ export const HistoryItemDisplay: React.FC<HistoryItemDisplayProps> = ({
|
||||
showDescriptions={itemForDisplay.showDescriptions}
|
||||
/>
|
||||
)}
|
||||
{itemForDisplay.type === 'features_list' && (
|
||||
<FeaturesList features={itemForDisplay.features} />
|
||||
)}
|
||||
{itemForDisplay.type === 'agents_list' && (
|
||||
<AgentsStatus
|
||||
agents={itemForDisplay.agents}
|
||||
|
||||
50
packages/cli/src/ui/components/views/FeaturesList.test.tsx
Normal file
50
packages/cli/src/ui/components/views/FeaturesList.test.tsx
Normal file
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2026 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { FeaturesList } from './FeaturesList.js';
|
||||
import { type FeatureInfo } from '../../types.js';
|
||||
import { FeatureStage } from '@google/gemini-cli-core';
|
||||
import { renderWithProviders } from '../../../test-utils/render.js';
|
||||
|
||||
const mockFeatures: FeatureInfo[] = [
|
||||
{
|
||||
key: 'alphaFeat',
|
||||
enabled: false,
|
||||
stage: FeatureStage.Alpha,
|
||||
since: '0.30.0',
|
||||
description: 'An alpha feature.',
|
||||
},
|
||||
{
|
||||
key: 'betaFeat',
|
||||
enabled: true,
|
||||
stage: FeatureStage.Beta,
|
||||
since: '0.29.0',
|
||||
description: 'A beta feature.',
|
||||
},
|
||||
{
|
||||
key: 'deprecatedFeat',
|
||||
enabled: false,
|
||||
stage: FeatureStage.Deprecated,
|
||||
since: '0.28.0',
|
||||
until: '0.31.0',
|
||||
description: 'A deprecated feature.',
|
||||
},
|
||||
];
|
||||
|
||||
describe('<FeaturesList />', () => {
|
||||
it('renders correctly with features', () => {
|
||||
const { lastFrame } = renderWithProviders(
|
||||
<FeaturesList features={mockFeatures} />,
|
||||
);
|
||||
expect(lastFrame()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('renders correctly with no features', () => {
|
||||
const { lastFrame } = renderWithProviders(<FeaturesList features={[]} />);
|
||||
expect(lastFrame()).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
174
packages/cli/src/ui/components/views/FeaturesList.tsx
Normal file
174
packages/cli/src/ui/components/views/FeaturesList.tsx
Normal file
@@ -0,0 +1,174 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2026 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import type React from 'react';
|
||||
import { Box, Text } from 'ink';
|
||||
import { theme } from '../../semantic-colors.js';
|
||||
import { type FeatureInfo } from '../../types.js';
|
||||
import { FeatureStage } from '@google/gemini-cli-core';
|
||||
|
||||
interface FeaturesListProps {
|
||||
features: FeatureInfo[];
|
||||
}
|
||||
|
||||
export const FeaturesList: React.FC<FeaturesListProps> = ({ features }) => {
|
||||
if (features.length === 0) {
|
||||
return (
|
||||
<Box flexDirection="column" marginBottom={1}>
|
||||
<Text color={theme.text.primary}> No features found</Text>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
const alphaFeatures = features.filter((f) => f.stage === FeatureStage.Alpha);
|
||||
const betaFeatures = features.filter((f) => f.stage === FeatureStage.Beta);
|
||||
const deprecatedFeatures = features.filter(
|
||||
(f) => f.stage === FeatureStage.Deprecated,
|
||||
);
|
||||
|
||||
// Column widths as percentages/proportions
|
||||
const colWidths = {
|
||||
feature: '40%',
|
||||
status: '20%',
|
||||
since: '20%',
|
||||
until: '20%',
|
||||
};
|
||||
|
||||
const renderSection = (
|
||||
title: string,
|
||||
sectionFeatures: FeatureInfo[],
|
||||
stageColor: string,
|
||||
) => {
|
||||
if (sectionFeatures.length === 0) return null;
|
||||
|
||||
return (
|
||||
<Box flexDirection="column" marginBottom={1}>
|
||||
<Box flexDirection="row" marginBottom={1}>
|
||||
<Text bold color={stageColor}>
|
||||
┃
|
||||
</Text>
|
||||
<Box marginLeft={1}>
|
||||
<Text bold color={theme.text.primary}>
|
||||
{title}
|
||||
</Text>
|
||||
<Text color={theme.text.secondary}>
|
||||
{' '}
|
||||
({sectionFeatures.length})
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
{/* Table Header */}
|
||||
<Box
|
||||
flexDirection="row"
|
||||
paddingX={1}
|
||||
borderStyle="single"
|
||||
borderTop={true}
|
||||
borderBottom={true}
|
||||
borderLeft={false}
|
||||
borderRight={false}
|
||||
borderColor={theme.border.default}
|
||||
>
|
||||
<Box width={colWidths.feature}>
|
||||
<Text bold color={theme.text.secondary}>
|
||||
FEATURE
|
||||
</Text>
|
||||
</Box>
|
||||
<Box width={colWidths.status}>
|
||||
<Text bold color={theme.text.secondary}>
|
||||
STATUS
|
||||
</Text>
|
||||
</Box>
|
||||
<Box width={colWidths.since}>
|
||||
<Text bold color={theme.text.secondary}>
|
||||
SINCE
|
||||
</Text>
|
||||
</Box>
|
||||
<Box width={colWidths.until}>
|
||||
<Text bold color={theme.text.secondary}>
|
||||
UNTIL
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
{/* Table Rows */}
|
||||
{sectionFeatures.map((feature) => (
|
||||
<Box
|
||||
key={feature.key}
|
||||
flexDirection="column"
|
||||
paddingX={1}
|
||||
paddingTop={1}
|
||||
>
|
||||
<Box flexDirection="row">
|
||||
<Box width={colWidths.feature}>
|
||||
<Text bold color={theme.text.accent}>
|
||||
{feature.key}
|
||||
</Text>
|
||||
</Box>
|
||||
<Box width={colWidths.status}>
|
||||
<Box flexDirection="row">
|
||||
<Text>{feature.enabled ? '🟢 ' : '🔴 '}</Text>
|
||||
<Text
|
||||
color={
|
||||
feature.enabled
|
||||
? theme.status.success
|
||||
: theme.status.error
|
||||
}
|
||||
>
|
||||
{feature.enabled ? 'Enabled' : 'Disabled'}
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
<Box width={colWidths.since}>
|
||||
<Text color={theme.text.secondary}>{feature.since || '—'}</Text>
|
||||
</Box>
|
||||
<Box width={colWidths.until}>
|
||||
<Text color={theme.text.secondary}>{feature.until || '—'}</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
{feature.description && (
|
||||
<Box marginLeft={2} marginBottom={1}>
|
||||
<Text dimColor color={theme.text.primary}>
|
||||
{feature.description}
|
||||
</Text>
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
))}
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<Box flexDirection="column" marginBottom={1}>
|
||||
{renderSection('Alpha Features', alphaFeatures, theme.status.error)}
|
||||
{renderSection('Beta Features', betaFeatures, theme.status.warning)}
|
||||
{renderSection(
|
||||
'Deprecated Features',
|
||||
deprecatedFeatures,
|
||||
theme.text.secondary,
|
||||
)}
|
||||
|
||||
<Box flexDirection="row" marginTop={1} paddingX={1}>
|
||||
<Text color={theme.text.secondary}>
|
||||
💡 Use{' '}
|
||||
<Text bold color={theme.text.accent}>
|
||||
/settings
|
||||
</Text>{' '}
|
||||
to enable or disable features. You can also use stage toggles like{' '}
|
||||
<Text bold color={theme.text.accent}>
|
||||
allAlpha=true
|
||||
</Text>{' '}
|
||||
or{' '}
|
||||
<Text bold color={theme.text.accent}>
|
||||
allBeta=false
|
||||
</Text>{' '}
|
||||
to toggle entire stages.
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,43 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`<FeaturesList /> > renders correctly with features 1`] = `
|
||||
"┃ Alpha Features (1)
|
||||
|
||||
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
FEATURE STATUS SINCE UNTIL
|
||||
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
alphaFeat 🔴 Disabled 0.30.0 —
|
||||
An alpha feature.
|
||||
|
||||
|
||||
┃ Beta Features (1)
|
||||
|
||||
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
FEATURE STATUS SINCE UNTIL
|
||||
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
betaFeat 🟢 Enabled 0.29.0 —
|
||||
A beta feature.
|
||||
|
||||
|
||||
┃ Deprecated Features (1)
|
||||
|
||||
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
FEATURE STATUS SINCE UNTIL
|
||||
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
deprecatedFeat 🔴 Disabled 0.28.0 0.31.0
|
||||
A deprecated feature.
|
||||
|
||||
|
||||
|
||||
💡 Use /settings to enable or disable features. You can also use stage toggles like allAlpha=true or allBeta=false to
|
||||
toggle entire stages.
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`<FeaturesList /> > renders correctly with no features 1`] = `
|
||||
" No features found
|
||||
"
|
||||
`;
|
||||
@@ -15,13 +15,14 @@ import {
|
||||
type SkillDefinition,
|
||||
type AgentDefinition,
|
||||
type ApprovalMode,
|
||||
type FeatureInfo,
|
||||
CoreToolCallStatus,
|
||||
checkExhaustive,
|
||||
} from '@google/gemini-cli-core';
|
||||
import type { PartListUnion } from '@google/genai';
|
||||
import { type ReactNode } from 'react';
|
||||
|
||||
export type { ThoughtSummary, SkillDefinition };
|
||||
export type { ThoughtSummary, SkillDefinition, FeatureInfo };
|
||||
|
||||
export enum AuthState {
|
||||
// Attempting to authenticate or re-authenticate
|
||||
@@ -288,6 +289,11 @@ export type HistoryItemSkillsList = HistoryItemBase & {
|
||||
showDescriptions: boolean;
|
||||
};
|
||||
|
||||
export type HistoryItemFeaturesList = HistoryItemBase & {
|
||||
type: 'features_list';
|
||||
features: FeatureInfo[];
|
||||
};
|
||||
|
||||
export type AgentDefinitionJson = Pick<
|
||||
AgentDefinition,
|
||||
'name' | 'displayName' | 'description' | 'kind'
|
||||
@@ -374,6 +380,7 @@ export type HistoryItemWithoutId =
|
||||
| HistoryItemExtensionsList
|
||||
| HistoryItemToolsList
|
||||
| HistoryItemSkillsList
|
||||
| HistoryItemFeaturesList
|
||||
| HistoryItemAgentsList
|
||||
| HistoryItemMcpStatus
|
||||
| HistoryItemChatList
|
||||
@@ -399,6 +406,7 @@ export enum MessageType {
|
||||
EXTENSIONS_LIST = 'extensions_list',
|
||||
TOOLS_LIST = 'tools_list',
|
||||
SKILLS_LIST = 'skills_list',
|
||||
FEATURES_LIST = 'features_list',
|
||||
AGENTS_LIST = 'agents_list',
|
||||
MCP_STATUS = 'mcp_status',
|
||||
CHAT_LIST = 'chat_list',
|
||||
|
||||
@@ -1126,6 +1126,13 @@ export class Config implements McpContext {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the feature gate for querying feature status.
|
||||
*/
|
||||
getFeatureGate(): FeatureGate {
|
||||
return this.featureGate;
|
||||
}
|
||||
|
||||
isInitialized(): boolean {
|
||||
return this.initialized;
|
||||
}
|
||||
|
||||
@@ -100,6 +100,48 @@ describe('FeatureGate', () => {
|
||||
expect(gate.enabled('testGA')).toBe(true);
|
||||
});
|
||||
|
||||
it('should return feature info with metadata', () => {
|
||||
const gate = DefaultFeatureGate.deepCopy();
|
||||
gate.add({
|
||||
feat1: [
|
||||
{
|
||||
preRelease: FeatureStage.Alpha,
|
||||
since: '0.1.0',
|
||||
description: 'Feature 1',
|
||||
},
|
||||
],
|
||||
feat2: [
|
||||
{
|
||||
preRelease: FeatureStage.Beta,
|
||||
since: '0.2.0',
|
||||
until: '0.3.0',
|
||||
description: 'Feature 2',
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const info = gate.getFeatureInfo();
|
||||
const feat1 = info.find((f) => f.key === 'feat1');
|
||||
const feat2 = info.find((f) => f.key === 'feat2');
|
||||
|
||||
expect(feat1).toEqual({
|
||||
key: 'feat1',
|
||||
enabled: false,
|
||||
stage: FeatureStage.Alpha,
|
||||
since: '0.1.0',
|
||||
until: undefined,
|
||||
description: 'Feature 1',
|
||||
});
|
||||
expect(feat2).toEqual({
|
||||
key: 'feat2',
|
||||
enabled: true,
|
||||
stage: FeatureStage.Beta,
|
||||
since: '0.2.0',
|
||||
until: '0.3.0',
|
||||
description: 'Feature 2',
|
||||
});
|
||||
});
|
||||
|
||||
it('should respect allAlpha/allBeta toggles', () => {
|
||||
const gate = DefaultFeatureGate.deepCopy();
|
||||
gate.add({
|
||||
|
||||
@@ -67,6 +67,18 @@ export interface FeatureSpec {
|
||||
description?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* FeatureInfo provides a summary of a feature's current state and metadata.
|
||||
*/
|
||||
export interface FeatureInfo {
|
||||
key: string;
|
||||
enabled: boolean;
|
||||
stage: FeatureStage;
|
||||
since?: string;
|
||||
until?: string;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* FeatureGate provides a read-only interface to query feature status.
|
||||
*/
|
||||
@@ -79,6 +91,10 @@ export interface FeatureGate {
|
||||
* Returns all known feature keys.
|
||||
*/
|
||||
knownFeatures(): string[];
|
||||
/**
|
||||
* Returns all features with their status and metadata.
|
||||
*/
|
||||
getFeatureInfo(): FeatureInfo[];
|
||||
/**
|
||||
* Returns a mutable copy of the current gate.
|
||||
*/
|
||||
@@ -189,6 +205,22 @@ class FeatureGateImpl implements MutableFeatureGate {
|
||||
return Array.from(this.specs.keys());
|
||||
}
|
||||
|
||||
getFeatureInfo(): FeatureInfo[] {
|
||||
return Array.from(this.specs.entries())
|
||||
.map(([key, specs]) => {
|
||||
const latestSpec = specs[specs.length - 1];
|
||||
return {
|
||||
key,
|
||||
enabled: this.enabled(key),
|
||||
stage: latestSpec.preRelease,
|
||||
since: latestSpec.since,
|
||||
until: latestSpec.until,
|
||||
description: latestSpec.description,
|
||||
};
|
||||
})
|
||||
.sort((a, b) => a.key.localeCompare(b.key));
|
||||
}
|
||||
|
||||
deepCopy(): MutableFeatureGate {
|
||||
const copy = new FeatureGateImpl();
|
||||
copy.specs = new Map(
|
||||
|
||||
Reference in New Issue
Block a user