diff --git a/README.md b/README.md index 9c74588..9fec2a7 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,7 @@ | **权限系统** | 危险操作前请求许可 | | **YOLO 模式** | 使用 `--yolo` 跳过所有提示(类似 Claude Code) | | **对话历史** | 跨会话保存 | +| **多行输入** | 按 Ctrl+J 插入换行 | @@ -74,6 +75,7 @@ | **Permission System** | Asks before dangerous operations | | **YOLO Mode** | Skip all prompts with `--yolo` (like Claude Code) | | **Conversation History** | Persists across sessions | +| **Multiline Input** | Press Ctrl+J to insert newlines | diff --git a/deepseek_code/cli.py b/deepseek_code/cli.py index 695be21..bfc5b7e 100644 --- a/deepseek_code/cli.py +++ b/deepseek_code/cli.py @@ -8,6 +8,7 @@ from dotenv import load_dotenv from prompt_toolkit import PromptSession from prompt_toolkit.history import FileHistory +from prompt_toolkit.key_binding import KeyBindings from rich.console import Console from . import __version__ @@ -30,12 +31,26 @@ def get_prompt_session() -> PromptSession: - """Create a prompt session with history.""" + """Create a prompt session with history and multiline support.""" history_dir = os.path.expanduser("~/.deepseek-code") os.makedirs(history_dir, exist_ok=True) history_file = os.path.join(history_dir, "prompt_history") - return PromptSession(history=FileHistory(history_file)) + bindings = KeyBindings() + + @bindings.add("enter") + def _(event): + event.current_buffer.validate_and_handle() + + @bindings.add("c-j") + def _(event): + event.current_buffer.insert_text("\n") + + return PromptSession( + history=FileHistory(history_file), + key_bindings=bindings, + multiline=True, + ) def interactive_loop(agent: Agent) -> None: @@ -120,6 +135,7 @@ def print_help(agent: Agent) -> None: /status - Show current mode status [bold]Tips:[/bold] + - Ctrl+J inserts a newline (for multiline input) - Ask the AI to read files before editing them - Use 'always' when prompted to auto-approve similar operations - Create a DEEPSEEK.md file in your project root for project-specific context