| |
| |
| |
| |
| |
|
|
| import * as fs from 'node:fs'; |
| import * as path from 'node:path'; |
| import type { |
| CommandContext, |
| SlashCommand, |
| SlashCommandActionReturn, |
| } from './types.js'; |
| import { CommandKind } from './types.js'; |
| import { performInit } from '@google/gemini-cli-core'; |
|
|
| export const initCommand: SlashCommand = { |
| name: 'init', |
| description: 'Analyzes the project and creates a tailored GEMINI.md file', |
| kind: CommandKind.BUILT_IN, |
| autoExecute: true, |
| action: async ( |
| context: CommandContext, |
| _args: string, |
| ): Promise<SlashCommandActionReturn> => { |
| if (!context.services.agentContext?.config) { |
| return { |
| type: 'message', |
| messageType: 'error', |
| content: 'Configuration not available.', |
| }; |
| } |
| const targetDir = context.services.agentContext.config.getTargetDir(); |
| const geminiMdPath = path.join(targetDir, 'GEMINI.md'); |
|
|
| const result = performInit(fs.existsSync(geminiMdPath)); |
|
|
| if (result.type === 'submit_prompt') { |
| |
| fs.writeFileSync(geminiMdPath, '', 'utf8'); |
|
|
| context.ui.addItem( |
| { |
| type: 'info', |
| text: 'Empty GEMINI.md created. Now analyzing the project to populate it.', |
| }, |
| Date.now(), |
| ); |
| } |
|
|
| |
| return result as SlashCommandActionReturn; |
| }, |
| }; |
|
|