mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-22 02:54:31 -07:00
feat(cli): add /insights slash command to analyze past sessions
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2025 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import { InsightsService } from '@google/gemini-cli-core';
|
||||
import { MessageType } from '../types.js';
|
||||
import {
|
||||
type CommandContext,
|
||||
type SlashCommand,
|
||||
CommandKind,
|
||||
} from './types.js';
|
||||
|
||||
/**
|
||||
* Slash command to generate usage insights based on past sessions.
|
||||
*/
|
||||
export const insightsCommand: SlashCommand = {
|
||||
name: 'insights',
|
||||
description: 'Analyze past sessions and get usage improvements and summary.',
|
||||
kind: CommandKind.BUILT_IN,
|
||||
autoExecute: true,
|
||||
action: async (context: CommandContext) => {
|
||||
const config = context.services.config;
|
||||
if (!config) {
|
||||
context.ui.addItem({
|
||||
type: MessageType.ERROR,
|
||||
text: 'Config is not available.',
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
context.ui.addItem({
|
||||
type: MessageType.INFO,
|
||||
text: 'Analyzing your past sessions to generate insights...',
|
||||
});
|
||||
|
||||
try {
|
||||
const insightsService = new InsightsService(config);
|
||||
const baseLlmClient = config.getBaseLlmClient();
|
||||
|
||||
const reportMarkdown =
|
||||
await insightsService.generateInsightsReport(baseLlmClient);
|
||||
|
||||
context.ui.addItem({
|
||||
type: MessageType.GEMINI,
|
||||
text: reportMarkdown,
|
||||
});
|
||||
} catch (error) {
|
||||
context.ui.addItem({
|
||||
type: MessageType.ERROR,
|
||||
text: `Failed to generate insights: ${error instanceof Error ? error.message : String(error)}`,
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user