klaude-code 2.0.2__py3-none-any.whl → 2.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- klaude_code/app/__init__.py +12 -0
- klaude_code/app/runtime.py +215 -0
- klaude_code/cli/auth_cmd.py +2 -2
- klaude_code/cli/config_cmd.py +2 -2
- klaude_code/cli/cost_cmd.py +1 -1
- klaude_code/cli/debug.py +12 -36
- klaude_code/cli/list_model.py +3 -3
- klaude_code/cli/main.py +17 -60
- klaude_code/cli/self_update.py +2 -187
- klaude_code/cli/session_cmd.py +2 -2
- klaude_code/config/config.py +1 -1
- klaude_code/config/select_model.py +1 -1
- klaude_code/const.py +9 -1
- klaude_code/core/agent.py +9 -62
- klaude_code/core/agent_profile.py +291 -0
- klaude_code/core/executor.py +335 -230
- klaude_code/core/manager/llm_clients_builder.py +1 -1
- klaude_code/core/manager/sub_agent_manager.py +16 -29
- klaude_code/core/reminders.py +84 -103
- klaude_code/core/task.py +12 -20
- klaude_code/core/tool/__init__.py +5 -19
- klaude_code/core/tool/context.py +84 -0
- klaude_code/core/tool/file/apply_patch_tool.py +18 -21
- klaude_code/core/tool/file/edit_tool.py +39 -42
- klaude_code/core/tool/file/read_tool.py +14 -9
- klaude_code/core/tool/file/write_tool.py +12 -13
- klaude_code/core/tool/report_back_tool.py +4 -1
- klaude_code/core/tool/shell/bash_tool.py +6 -11
- klaude_code/core/tool/sub_agent_tool.py +8 -7
- klaude_code/core/tool/todo/todo_write_tool.py +3 -9
- klaude_code/core/tool/todo/update_plan_tool.py +3 -5
- klaude_code/core/tool/tool_abc.py +2 -1
- klaude_code/core/tool/tool_registry.py +2 -33
- klaude_code/core/tool/tool_runner.py +13 -10
- klaude_code/core/tool/web/mermaid_tool.py +3 -1
- klaude_code/core/tool/web/web_fetch_tool.py +5 -3
- klaude_code/core/tool/web/web_search_tool.py +5 -3
- klaude_code/core/turn.py +87 -30
- klaude_code/llm/anthropic/client.py +1 -1
- klaude_code/llm/bedrock/client.py +1 -1
- klaude_code/llm/claude/client.py +1 -1
- klaude_code/llm/codex/client.py +1 -1
- klaude_code/llm/google/client.py +1 -1
- klaude_code/llm/openai_compatible/client.py +1 -1
- klaude_code/llm/openai_compatible/tool_call_accumulator.py +1 -1
- klaude_code/llm/openrouter/client.py +1 -1
- klaude_code/llm/openrouter/reasoning.py +1 -1
- klaude_code/llm/responses/client.py +1 -1
- klaude_code/protocol/commands.py +1 -0
- klaude_code/protocol/events/__init__.py +57 -0
- klaude_code/protocol/events/base.py +18 -0
- klaude_code/protocol/events/chat.py +20 -0
- klaude_code/protocol/events/lifecycle.py +22 -0
- klaude_code/protocol/events/metadata.py +15 -0
- klaude_code/protocol/events/streaming.py +43 -0
- klaude_code/protocol/events/system.py +53 -0
- klaude_code/protocol/events/tools.py +27 -0
- klaude_code/protocol/op.py +5 -0
- klaude_code/protocol/tools.py +0 -1
- klaude_code/session/session.py +6 -7
- klaude_code/skill/assets/create-plan/SKILL.md +76 -0
- klaude_code/skill/loader.py +32 -88
- klaude_code/skill/manager.py +38 -0
- klaude_code/skill/system_skills.py +1 -1
- klaude_code/tui/__init__.py +8 -0
- klaude_code/{command → tui/command}/__init__.py +3 -0
- klaude_code/{command → tui/command}/clear_cmd.py +2 -1
- klaude_code/tui/command/copy_cmd.py +53 -0
- klaude_code/{command → tui/command}/debug_cmd.py +3 -2
- klaude_code/{command → tui/command}/export_cmd.py +2 -1
- klaude_code/{command → tui/command}/export_online_cmd.py +2 -1
- klaude_code/{command → tui/command}/fork_session_cmd.py +4 -3
- klaude_code/{command → tui/command}/help_cmd.py +2 -1
- klaude_code/{command → tui/command}/model_cmd.py +4 -3
- klaude_code/{command → tui/command}/model_select.py +2 -2
- klaude_code/{command → tui/command}/prompt_command.py +4 -3
- klaude_code/{command → tui/command}/refresh_cmd.py +3 -1
- klaude_code/{command → tui/command}/registry.py +6 -5
- klaude_code/{command → tui/command}/release_notes_cmd.py +2 -1
- klaude_code/{command → tui/command}/resume_cmd.py +4 -3
- klaude_code/{command → tui/command}/status_cmd.py +2 -1
- klaude_code/{command → tui/command}/terminal_setup_cmd.py +2 -1
- klaude_code/{command → tui/command}/thinking_cmd.py +3 -2
- klaude_code/tui/commands.py +164 -0
- klaude_code/{ui/renderers → tui/components}/assistant.py +3 -3
- klaude_code/{ui/renderers → tui/components}/bash_syntax.py +2 -2
- klaude_code/{ui/renderers → tui/components}/common.py +1 -1
- klaude_code/{ui/renderers → tui/components}/developer.py +4 -4
- klaude_code/{ui/renderers → tui/components}/diffs.py +2 -2
- klaude_code/{ui/renderers → tui/components}/errors.py +2 -2
- klaude_code/{ui/renderers → tui/components}/metadata.py +7 -7
- klaude_code/{ui → tui/components}/rich/markdown.py +9 -23
- klaude_code/{ui → tui/components}/rich/status.py +2 -2
- klaude_code/{ui → tui/components}/rich/theme.py +3 -1
- klaude_code/{ui/renderers → tui/components}/sub_agent.py +23 -43
- klaude_code/{ui/renderers → tui/components}/thinking.py +3 -3
- klaude_code/{ui/renderers → tui/components}/tools.py +13 -17
- klaude_code/{ui/renderers → tui/components}/user_input.py +3 -20
- klaude_code/tui/display.py +85 -0
- klaude_code/{ui/modes/repl → tui/input}/__init__.py +1 -1
- klaude_code/{ui/modes/repl → tui/input}/completers.py +1 -1
- klaude_code/{ui/modes/repl/input_prompt_toolkit.py → tui/input/prompt_toolkit.py} +6 -6
- klaude_code/tui/machine.py +608 -0
- klaude_code/tui/renderer.py +707 -0
- klaude_code/tui/runner.py +321 -0
- klaude_code/tui/terminal/__init__.py +56 -0
- klaude_code/{ui → tui}/terminal/color.py +1 -1
- klaude_code/{ui → tui}/terminal/control.py +1 -1
- klaude_code/{ui → tui}/terminal/notifier.py +1 -1
- klaude_code/ui/__init__.py +6 -50
- klaude_code/ui/core/display.py +3 -3
- klaude_code/ui/core/input.py +2 -1
- klaude_code/ui/{modes/debug/display.py → debug_mode.py} +1 -1
- klaude_code/ui/{modes/exec/display.py → exec_mode.py} +0 -2
- klaude_code/ui/terminal/__init__.py +6 -54
- klaude_code/ui/terminal/title.py +31 -0
- klaude_code/update.py +163 -0
- {klaude_code-2.0.2.dist-info → klaude_code-2.1.1.dist-info}/METADATA +1 -1
- klaude_code-2.1.1.dist-info/RECORD +233 -0
- klaude_code/cli/runtime.py +0 -518
- klaude_code/core/prompt.py +0 -108
- klaude_code/core/tool/skill/skill_tool.md +0 -24
- klaude_code/core/tool/skill/skill_tool.py +0 -87
- klaude_code/core/tool/tool_context.py +0 -148
- klaude_code/protocol/events.py +0 -195
- klaude_code/skill/assets/dev-docs/SKILL.md +0 -108
- klaude_code/trace/__init__.py +0 -21
- klaude_code/ui/core/stage_manager.py +0 -48
- klaude_code/ui/modes/__init__.py +0 -1
- klaude_code/ui/modes/debug/__init__.py +0 -1
- klaude_code/ui/modes/exec/__init__.py +0 -1
- klaude_code/ui/modes/repl/display.py +0 -61
- klaude_code/ui/modes/repl/event_handler.py +0 -629
- klaude_code/ui/modes/repl/renderer.py +0 -464
- klaude_code/ui/renderers/__init__.py +0 -0
- klaude_code/ui/utils/__init__.py +0 -1
- klaude_code-2.0.2.dist-info/RECORD +0 -227
- /klaude_code/{trace/log.py → log.py} +0 -0
- /klaude_code/{command → tui/command}/command_abc.py +0 -0
- /klaude_code/{command → tui/command}/prompt-commit.md +0 -0
- /klaude_code/{command → tui/command}/prompt-init.md +0 -0
- /klaude_code/{core/tool/skill → tui/components}/__init__.py +0 -0
- /klaude_code/{ui/renderers → tui/components}/mermaid_viewer.py +0 -0
- /klaude_code/{ui → tui/components}/rich/__init__.py +0 -0
- /klaude_code/{ui → tui/components}/rich/cjk_wrap.py +0 -0
- /klaude_code/{ui → tui/components}/rich/code_panel.py +0 -0
- /klaude_code/{ui → tui/components}/rich/live.py +0 -0
- /klaude_code/{ui → tui/components}/rich/quote.py +0 -0
- /klaude_code/{ui → tui/components}/rich/searchable_text.py +0 -0
- /klaude_code/{ui/modes/repl → tui/input}/clipboard.py +0 -0
- /klaude_code/{ui/modes/repl → tui/input}/key_bindings.py +0 -0
- /klaude_code/{ui → tui}/terminal/image.py +0 -0
- /klaude_code/{ui → tui}/terminal/progress_bar.py +0 -0
- /klaude_code/{ui → tui}/terminal/selector.py +0 -0
- /klaude_code/ui/{utils/common.py → common.py} +0 -0
- {klaude_code-2.0.2.dist-info → klaude_code-2.1.1.dist-info}/WHEEL +0 -0
- {klaude_code-2.0.2.dist-info → klaude_code-2.1.1.dist-info}/entry_points.txt +0 -0
|
@@ -1,29 +1,12 @@
|
|
|
1
1
|
import re
|
|
2
|
-
from collections.abc import Callable
|
|
3
2
|
|
|
4
3
|
from rich.console import Group, RenderableType
|
|
5
4
|
from rich.text import Text
|
|
6
5
|
|
|
7
6
|
from klaude_code.skill import get_available_skills
|
|
8
|
-
from klaude_code.
|
|
9
|
-
from klaude_code.
|
|
10
|
-
|
|
11
|
-
# Module-level command name checker. Set by cli/runtime.py on startup.
|
|
12
|
-
_command_name_checker: Callable[[str], bool] | None = None
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def set_command_name_checker(checker: Callable[[str], bool]) -> None:
|
|
16
|
-
"""Set the command name validation function (called from runtime layer)."""
|
|
17
|
-
global _command_name_checker
|
|
18
|
-
_command_name_checker = checker
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
def is_slash_command_name(name: str) -> bool:
|
|
22
|
-
"""Check if name is a valid slash command using the injected checker."""
|
|
23
|
-
if _command_name_checker is None:
|
|
24
|
-
return False
|
|
25
|
-
return _command_name_checker(name)
|
|
26
|
-
|
|
7
|
+
from klaude_code.tui.command import is_slash_command_name
|
|
8
|
+
from klaude_code.tui.components.common import create_grid
|
|
9
|
+
from klaude_code.tui.components.rich.theme import ThemeKey
|
|
27
10
|
|
|
28
11
|
# Match @-file patterns only when they appear at the beginning of the line
|
|
29
12
|
# or immediately after whitespace, to avoid treating mid-word email-like
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
import contextlib
|
|
5
|
+
from collections.abc import Coroutine
|
|
6
|
+
from typing import Any, override
|
|
7
|
+
|
|
8
|
+
from klaude_code.protocol import events
|
|
9
|
+
from klaude_code.tui.machine import DisplayStateMachine
|
|
10
|
+
from klaude_code.tui.renderer import TUICommandRenderer
|
|
11
|
+
from klaude_code.tui.terminal.notifier import TerminalNotifier
|
|
12
|
+
from klaude_code.ui.core.display import DisplayABC
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class TUIDisplay(DisplayABC):
|
|
16
|
+
"""Interactive terminal display using Rich for rendering."""
|
|
17
|
+
|
|
18
|
+
def __init__(self, theme: str | None = None, notifier: TerminalNotifier | None = None):
|
|
19
|
+
self._notifier = notifier or TerminalNotifier()
|
|
20
|
+
self._machine = DisplayStateMachine()
|
|
21
|
+
self._renderer = TUICommandRenderer(theme=theme, notifier=self._notifier)
|
|
22
|
+
|
|
23
|
+
self._sigint_toast_clear_handle: asyncio.Handle | None = None
|
|
24
|
+
self._bg_tasks: set[asyncio.Task[None]] = set()
|
|
25
|
+
|
|
26
|
+
def _create_bg_task(self, coro: Coroutine[Any, Any, None]) -> None:
|
|
27
|
+
task = asyncio.create_task(coro)
|
|
28
|
+
self._bg_tasks.add(task)
|
|
29
|
+
task.add_done_callback(self._bg_tasks.discard)
|
|
30
|
+
|
|
31
|
+
@override
|
|
32
|
+
async def consume_event(self, event: events.Event) -> None:
|
|
33
|
+
commands = self._machine.transition(event)
|
|
34
|
+
await self._renderer.execute(commands)
|
|
35
|
+
|
|
36
|
+
@override
|
|
37
|
+
async def start(self) -> None:
|
|
38
|
+
pass
|
|
39
|
+
|
|
40
|
+
@override
|
|
41
|
+
async def stop(self) -> None:
|
|
42
|
+
if self._sigint_toast_clear_handle is not None:
|
|
43
|
+
with contextlib.suppress(Exception):
|
|
44
|
+
self._sigint_toast_clear_handle.cancel()
|
|
45
|
+
self._sigint_toast_clear_handle = None
|
|
46
|
+
|
|
47
|
+
for task in list(self._bg_tasks):
|
|
48
|
+
with contextlib.suppress(Exception):
|
|
49
|
+
task.cancel()
|
|
50
|
+
self._bg_tasks.clear()
|
|
51
|
+
|
|
52
|
+
await self._renderer.stop()
|
|
53
|
+
|
|
54
|
+
with contextlib.suppress(Exception):
|
|
55
|
+
self._renderer.stop_bottom_live()
|
|
56
|
+
|
|
57
|
+
def show_sigint_exit_toast(self, *, window_seconds: float = 2.0) -> None:
|
|
58
|
+
"""Show a transient Ctrl+C hint in the TUI status line."""
|
|
59
|
+
|
|
60
|
+
async def _apply_show() -> None:
|
|
61
|
+
await self._renderer.execute(self._machine.show_sigint_exit_toast())
|
|
62
|
+
|
|
63
|
+
async def _apply_clear() -> None:
|
|
64
|
+
await self._renderer.execute(self._machine.clear_sigint_exit_toast())
|
|
65
|
+
|
|
66
|
+
loop = asyncio.get_running_loop()
|
|
67
|
+
self._create_bg_task(_apply_show())
|
|
68
|
+
|
|
69
|
+
if self._sigint_toast_clear_handle is not None:
|
|
70
|
+
with contextlib.suppress(Exception):
|
|
71
|
+
self._sigint_toast_clear_handle.cancel()
|
|
72
|
+
self._sigint_toast_clear_handle = None
|
|
73
|
+
|
|
74
|
+
def _schedule_clear() -> None:
|
|
75
|
+
self._create_bg_task(_apply_clear())
|
|
76
|
+
|
|
77
|
+
self._sigint_toast_clear_handle = loop.call_later(window_seconds, _schedule_clear)
|
|
78
|
+
|
|
79
|
+
def hide_progress_ui(self) -> None:
|
|
80
|
+
"""Stop transient Rich UI elements before prompt-toolkit takes control."""
|
|
81
|
+
|
|
82
|
+
with contextlib.suppress(Exception):
|
|
83
|
+
self._renderer.spinner_stop()
|
|
84
|
+
with contextlib.suppress(Exception):
|
|
85
|
+
self._renderer.stop_bottom_live()
|
|
@@ -28,8 +28,8 @@ from prompt_toolkit.document import Document
|
|
|
28
28
|
from prompt_toolkit.formatted_text import FormattedText
|
|
29
29
|
|
|
30
30
|
from klaude_code.const import COMPLETER_CACHE_TTL_SEC, COMPLETER_CMD_TIMEOUT_SEC, COMPLETER_DEBOUNCE_SEC
|
|
31
|
+
from klaude_code.log import DebugType, log_debug
|
|
31
32
|
from klaude_code.protocol.commands import CommandInfo
|
|
32
|
-
from klaude_code.trace.log import DebugType, log_debug
|
|
33
33
|
|
|
34
34
|
# Pattern to match @token for completion refresh (used by key bindings).
|
|
35
35
|
# Supports both plain tokens like `@src/file.py` and quoted tokens like
|
|
@@ -35,13 +35,13 @@ from klaude_code.config.thinking import (
|
|
|
35
35
|
from klaude_code.protocol import llm_param
|
|
36
36
|
from klaude_code.protocol.commands import CommandInfo
|
|
37
37
|
from klaude_code.protocol.message import UserInputPayload
|
|
38
|
+
from klaude_code.tui.components.user_input import USER_MESSAGE_MARK
|
|
39
|
+
from klaude_code.tui.input.clipboard import capture_clipboard_tag, copy_to_clipboard, extract_images_from_text
|
|
40
|
+
from klaude_code.tui.input.completers import AT_TOKEN_PATTERN, create_repl_completer
|
|
41
|
+
from klaude_code.tui.input.key_bindings import create_key_bindings
|
|
42
|
+
from klaude_code.tui.terminal.color import is_light_terminal_background
|
|
43
|
+
from klaude_code.tui.terminal.selector import SelectItem, SelectOverlay, build_model_select_items
|
|
38
44
|
from klaude_code.ui.core.input import InputProviderABC
|
|
39
|
-
from klaude_code.ui.modes.repl.clipboard import capture_clipboard_tag, copy_to_clipboard, extract_images_from_text
|
|
40
|
-
from klaude_code.ui.modes.repl.completers import AT_TOKEN_PATTERN, create_repl_completer
|
|
41
|
-
from klaude_code.ui.modes.repl.key_bindings import create_key_bindings
|
|
42
|
-
from klaude_code.ui.renderers.user_input import USER_MESSAGE_MARK
|
|
43
|
-
from klaude_code.ui.terminal.color import is_light_terminal_background
|
|
44
|
-
from klaude_code.ui.terminal.selector import SelectItem, SelectOverlay, build_model_select_items
|
|
45
45
|
|
|
46
46
|
|
|
47
47
|
class REPLStatusSnapshot(NamedTuple):
|