UNPKG

openai-cli-unofficial

Version:

A powerful OpenAI CLI Coding Agent built with TypeScript

107 lines 3.09 kB
import { Messages } from '../../types/language'; import { CommandManager } from './commands'; import { FileSearchManager } from './files'; export interface InputSuggestion { type: 'command' | 'file'; value: string; display: string; description: string; } export interface InputState { input: string; suggestions: InputSuggestion[]; selectedIndex: number; showingSuggestions: boolean; suggestionsType: 'command' | 'file' | null; } export declare class InputHandler { private commandManager; private fileSearchManager; private messages; private selectedFiles; private selectedImageFiles; private selectedTextFiles; constructor(commandManager: CommandManager, fileSearchManager: FileSearchManager, messages: Messages); /** * 分析输入并返回建议 */ analyzInput(input: string): Promise<InputState>; /** * 检查是否有同名文件冲突 */ private checkForNameConflicts; /** * 格式化文件显示文本 */ private formatFileDisplay; /** * 获取文件描述信息 */ private getFileDescription; /** * 处理建议选择 */ handleSuggestionSelection(currentInput: string, suggestion: InputSuggestion): string; /** * 渲染建议列表 */ renderSuggestions(suggestions: InputSuggestion[], selectedIndex: number): string[]; /** * 计算包含ANSI颜色代码的字符串显示宽度 */ private getDisplayWidthWithAnsi; /** * 检查是否是宽字符(中文、日文等) */ private isWideChar; /** * 在保持颜色格式的情况下截断字符串 */ private truncateWithColor; /** * 获取建议类型的标题 */ getSuggestionTitle(type: 'command' | 'file' | null): string; /** * 更新选中文件列表(当用户修改输入时调用) */ updateSelectedFiles(currentInput: string): void; /** * 强制同步输入文本和选中文件列表 * 当需要确保文件列表与当前输入完全同步时调用 */ syncSelectedFiles(currentInput: string): void; /** * 从输入文本中提取文件引用 * 支持的格式: * - "@文件路径 " - 文件路径后跟空格 * - "@文件路径" - 文件路径在字符串末尾 * - "@src/components/input-handler.ts 这是用户消息" - 文件路径后跟用户自定义消息 */ private extractFileReferences; /** * 获取当前选中的文件列表 */ getSelectedFiles(): string[]; /** * 获取当前选中的图片文件列表 */ getSelectedImageFiles(): string[]; /** * 获取当前选中的文本文件列表 */ getSelectedTextFiles(): string[]; /** * 清除选中文件列表 */ clearSelectedFiles(): void; /** * 检查指定文件是否已选中 */ isFileSelected(filePath: string): boolean; /** * 更新语言设置 */ updateLanguage(messages: Messages): void; } //# sourceMappingURL=input-handler.d.ts.map