kimi-cli 0.40__py3-none-any.whl → 0.41__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.
Potentially problematic release.
This version of kimi-cli might be problematic. Click here for more details.
- kimi_cli/CHANGELOG.md +12 -0
- kimi_cli/__init__.py +18 -280
- kimi_cli/agents/koder/system.md +1 -1
- kimi_cli/agentspec.py +104 -0
- kimi_cli/cli.py +235 -0
- kimi_cli/constant.py +4 -0
- kimi_cli/llm.py +69 -0
- kimi_cli/prompts/__init__.py +2 -2
- kimi_cli/soul/__init__.py +102 -6
- kimi_cli/soul/agent.py +157 -0
- kimi_cli/soul/approval.py +1 -1
- kimi_cli/soul/compaction.py +4 -4
- kimi_cli/soul/context.py +5 -0
- kimi_cli/soul/globals.py +92 -0
- kimi_cli/soul/kimisoul.py +21 -26
- kimi_cli/tools/dmail/__init__.py +1 -1
- kimi_cli/tools/file/glob.md +1 -1
- kimi_cli/tools/file/glob.py +2 -2
- kimi_cli/tools/file/grep.py +1 -1
- kimi_cli/tools/file/patch.py +2 -2
- kimi_cli/tools/file/read.py +1 -1
- kimi_cli/tools/file/replace.py +2 -2
- kimi_cli/tools/file/write.py +2 -2
- kimi_cli/tools/task/__init__.py +23 -22
- kimi_cli/tools/task/task.md +1 -1
- kimi_cli/tools/todo/__init__.py +1 -1
- kimi_cli/tools/utils.py +1 -1
- kimi_cli/tools/web/search.py +2 -2
- kimi_cli/ui/__init__.py +0 -69
- kimi_cli/ui/acp/__init__.py +8 -9
- kimi_cli/ui/print/__init__.py +17 -35
- kimi_cli/ui/shell/__init__.py +5 -13
- kimi_cli/ui/shell/liveview.py +1 -1
- kimi_cli/ui/shell/metacmd.py +3 -3
- kimi_cli/ui/shell/setup.py +5 -5
- kimi_cli/ui/shell/update.py +2 -2
- kimi_cli/ui/shell/visualize.py +10 -7
- kimi_cli/utils/changelog.py +3 -1
- kimi_cli/wire/__init__.py +57 -0
- kimi_cli/{soul/wire.py → wire/message.py} +4 -39
- {kimi_cli-0.40.dist-info → kimi_cli-0.41.dist-info}/METADATA +34 -1
- kimi_cli-0.41.dist-info/RECORD +85 -0
- kimi_cli-0.41.dist-info/entry_points.txt +3 -0
- kimi_cli/agent.py +0 -261
- kimi_cli/utils/provider.py +0 -70
- kimi_cli-0.40.dist-info/RECORD +0 -81
- kimi_cli-0.40.dist-info/entry_points.txt +0 -3
- {kimi_cli-0.40.dist-info → kimi_cli-0.41.dist-info}/WHEEL +0 -0
kimi_cli/ui/print/__init__.py
CHANGED
|
@@ -3,18 +3,18 @@ import json
|
|
|
3
3
|
import signal
|
|
4
4
|
import sys
|
|
5
5
|
from functools import partial
|
|
6
|
+
from pathlib import Path
|
|
6
7
|
from typing import Literal
|
|
7
8
|
|
|
8
9
|
import aiofiles
|
|
9
10
|
from kosong.base.message import Message
|
|
10
11
|
from kosong.chat_provider import ChatProviderError
|
|
11
12
|
|
|
12
|
-
from kimi_cli.soul import LLMNotSet, MaxStepsReached
|
|
13
|
-
from kimi_cli.soul.kimisoul import KimiSoul
|
|
14
|
-
from kimi_cli.soul.wire import StepInterrupted, Wire
|
|
15
|
-
from kimi_cli.ui import RunCancelled, run_soul
|
|
13
|
+
from kimi_cli.soul import LLMNotSet, MaxStepsReached, RunCancelled, Soul, run_soul
|
|
16
14
|
from kimi_cli.utils.logging import logger
|
|
17
15
|
from kimi_cli.utils.message import message_extract_text
|
|
16
|
+
from kimi_cli.wire import WireUISide
|
|
17
|
+
from kimi_cli.wire.message import StepInterrupted
|
|
18
18
|
|
|
19
19
|
InputFormat = Literal["text", "stream-json"]
|
|
20
20
|
OutputFormat = Literal["text", "stream-json"]
|
|
@@ -25,17 +25,23 @@ class PrintApp:
|
|
|
25
25
|
An app implementation that prints the agent behavior to the console.
|
|
26
26
|
|
|
27
27
|
Args:
|
|
28
|
-
soul (
|
|
28
|
+
soul (Soul): The soul to run.
|
|
29
29
|
input_format (InputFormat): The input format to use.
|
|
30
30
|
output_format (OutputFormat): The output format to use.
|
|
31
|
+
context_file (Path): The file to store the context.
|
|
31
32
|
"""
|
|
32
33
|
|
|
33
|
-
def __init__(
|
|
34
|
+
def __init__(
|
|
35
|
+
self,
|
|
36
|
+
soul: Soul,
|
|
37
|
+
input_format: InputFormat,
|
|
38
|
+
output_format: OutputFormat,
|
|
39
|
+
context_file: Path,
|
|
40
|
+
):
|
|
34
41
|
self.soul = soul
|
|
35
42
|
self.input_format = input_format
|
|
36
43
|
self.output_format = output_format
|
|
37
|
-
self.
|
|
38
|
-
# TODO(approval): proper approval request handling
|
|
44
|
+
self.context_file = context_file
|
|
39
45
|
|
|
40
46
|
async def run(self, command: str | None = None) -> bool:
|
|
41
47
|
cancel_event = asyncio.Event()
|
|
@@ -95,30 +101,6 @@ class PrintApp:
|
|
|
95
101
|
loop.remove_signal_handler(signal.SIGINT)
|
|
96
102
|
return False
|
|
97
103
|
|
|
98
|
-
# TODO: unify with `_soul_run` in `ShellApp` and `ACPAgentImpl`
|
|
99
|
-
async def _soul_run(self, user_input: str):
|
|
100
|
-
wire = Wire()
|
|
101
|
-
logger.debug("Starting visualization loop")
|
|
102
|
-
|
|
103
|
-
if self.output_format == "text":
|
|
104
|
-
vis_task = asyncio.create_task(self._visualize_text(wire))
|
|
105
|
-
else:
|
|
106
|
-
assert self.output_format == "stream-json"
|
|
107
|
-
if not self.soul._context._file_backend.exists():
|
|
108
|
-
self.soul._context._file_backend.touch()
|
|
109
|
-
start_position = self.soul._context._file_backend.stat().st_size
|
|
110
|
-
vis_task = asyncio.create_task(self._visualize_stream_json(wire, start_position))
|
|
111
|
-
|
|
112
|
-
try:
|
|
113
|
-
await self.soul.run(user_input, wire)
|
|
114
|
-
finally:
|
|
115
|
-
wire.shutdown()
|
|
116
|
-
# shutting down the event queue should break the visualization loop
|
|
117
|
-
try:
|
|
118
|
-
await asyncio.wait_for(vis_task, timeout=0.5)
|
|
119
|
-
except TimeoutError:
|
|
120
|
-
logger.warning("Visualization loop timed out")
|
|
121
|
-
|
|
122
104
|
def _read_next_command(self) -> str | None:
|
|
123
105
|
while True:
|
|
124
106
|
json_line = sys.stdin.readline()
|
|
@@ -144,7 +126,7 @@ class PrintApp:
|
|
|
144
126
|
except Exception:
|
|
145
127
|
logger.warning("Ignoring invalid user message: {json_line}", json_line=json_line)
|
|
146
128
|
|
|
147
|
-
async def _visualize_text(self, wire:
|
|
129
|
+
async def _visualize_text(self, wire: WireUISide):
|
|
148
130
|
try:
|
|
149
131
|
while True:
|
|
150
132
|
msg = await wire.receive()
|
|
@@ -154,10 +136,10 @@ class PrintApp:
|
|
|
154
136
|
except asyncio.QueueShutDown:
|
|
155
137
|
logger.debug("Visualization loop shutting down")
|
|
156
138
|
|
|
157
|
-
async def _visualize_stream_json(self, wire:
|
|
139
|
+
async def _visualize_stream_json(self, wire: WireUISide, start_position: int):
|
|
158
140
|
# TODO: be aware of context compaction
|
|
159
141
|
try:
|
|
160
|
-
async with aiofiles.open(self.
|
|
142
|
+
async with aiofiles.open(self.context_file, encoding="utf-8") as f:
|
|
161
143
|
await f.seek(start_position)
|
|
162
144
|
while True:
|
|
163
145
|
should_end = False
|
kimi_cli/ui/shell/__init__.py
CHANGED
|
@@ -9,9 +9,8 @@ from rich.panel import Panel
|
|
|
9
9
|
from rich.table import Table
|
|
10
10
|
from rich.text import Text
|
|
11
11
|
|
|
12
|
-
from kimi_cli.soul import LLMNotSet, MaxStepsReached, Soul
|
|
12
|
+
from kimi_cli.soul import LLMNotSet, MaxStepsReached, RunCancelled, Soul, run_soul
|
|
13
13
|
from kimi_cli.soul.kimisoul import KimiSoul
|
|
14
|
-
from kimi_cli.ui import RunCancelled, run_soul
|
|
15
14
|
from kimi_cli.ui.shell.console import console
|
|
16
15
|
from kimi_cli.ui.shell.metacmd import get_meta_command
|
|
17
16
|
from kimi_cli.ui.shell.prompt import CustomPromptSession, PromptMode, toast
|
|
@@ -20,12 +19,6 @@ from kimi_cli.ui.shell.visualize import visualize
|
|
|
20
19
|
from kimi_cli.utils.logging import logger
|
|
21
20
|
|
|
22
21
|
|
|
23
|
-
class Reload(Exception):
|
|
24
|
-
"""Reload configuration."""
|
|
25
|
-
|
|
26
|
-
pass
|
|
27
|
-
|
|
28
|
-
|
|
29
22
|
class ShellApp:
|
|
30
23
|
def __init__(self, soul: Soul, welcome_info: dict[str, str] | None = None):
|
|
31
24
|
self.soul = soul
|
|
@@ -106,6 +99,8 @@ class ShellApp:
|
|
|
106
99
|
loop.remove_signal_handler(signal.SIGINT)
|
|
107
100
|
|
|
108
101
|
async def _run_meta_command(self, command_str: str):
|
|
102
|
+
from kimi_cli.cli import Reload
|
|
103
|
+
|
|
109
104
|
parts = command_str.split(" ")
|
|
110
105
|
command_name = parts[0]
|
|
111
106
|
command_args = parts[1:]
|
|
@@ -188,9 +183,6 @@ class ShellApp:
|
|
|
188
183
|
except RunCancelled:
|
|
189
184
|
logger.info("Cancelled by user")
|
|
190
185
|
console.print("[red]Interrupted by user[/red]")
|
|
191
|
-
except Reload:
|
|
192
|
-
# just propagate
|
|
193
|
-
raise
|
|
194
186
|
except BaseException as e:
|
|
195
187
|
logger.exception("Unknown error:")
|
|
196
188
|
console.print(f"[red]Unknown error: {e}[/red]")
|
|
@@ -265,9 +257,9 @@ def _print_welcome_info(name: str, model: str, info_items: dict[str, str]) -> No
|
|
|
265
257
|
)
|
|
266
258
|
|
|
267
259
|
if LATEST_VERSION_FILE.exists():
|
|
268
|
-
from kimi_cli import
|
|
260
|
+
from kimi_cli.constant import VERSION as current_version
|
|
269
261
|
|
|
270
|
-
latest_version = LATEST_VERSION_FILE.read_text().strip()
|
|
262
|
+
latest_version = LATEST_VERSION_FILE.read_text(encoding="utf-8").strip()
|
|
271
263
|
if semver_tuple(latest_version) > semver_tuple(current_version):
|
|
272
264
|
rows.append(
|
|
273
265
|
Text.from_markup(
|
kimi_cli/ui/shell/liveview.py
CHANGED
|
@@ -15,10 +15,10 @@ from rich.status import Status
|
|
|
15
15
|
from rich.text import Text
|
|
16
16
|
|
|
17
17
|
from kimi_cli.soul import StatusSnapshot
|
|
18
|
-
from kimi_cli.soul.wire import ApprovalRequest, ApprovalResponse
|
|
19
18
|
from kimi_cli.tools import extract_subtitle
|
|
20
19
|
from kimi_cli.ui.shell.console import console
|
|
21
20
|
from kimi_cli.ui.shell.keyboard import KeyEvent
|
|
21
|
+
from kimi_cli.wire.message import ApprovalRequest, ApprovalResponse
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
class _ToolCallDisplay:
|
kimi_cli/ui/shell/metacmd.py
CHANGED
|
@@ -8,8 +8,8 @@ from kosong.base.message import Message
|
|
|
8
8
|
from rich.panel import Panel
|
|
9
9
|
|
|
10
10
|
import kimi_cli.prompts as prompts
|
|
11
|
-
from kimi_cli.agent import load_agents_md
|
|
12
11
|
from kimi_cli.soul.context import Context
|
|
12
|
+
from kimi_cli.soul.globals import load_agents_md
|
|
13
13
|
from kimi_cli.soul.kimisoul import KimiSoul
|
|
14
14
|
from kimi_cli.soul.message import system
|
|
15
15
|
from kimi_cli.ui.shell.console import console
|
|
@@ -173,9 +173,9 @@ def help(app: "ShellApp", args: list[str]):
|
|
|
173
173
|
@meta_command
|
|
174
174
|
def version(app: "ShellApp", args: list[str]):
|
|
175
175
|
"""Show version information"""
|
|
176
|
-
from kimi_cli import
|
|
176
|
+
from kimi_cli.constant import VERSION
|
|
177
177
|
|
|
178
|
-
console.print(f"kimi, version {
|
|
178
|
+
console.print(f"kimi, version {VERSION}")
|
|
179
179
|
|
|
180
180
|
|
|
181
181
|
@meta_command(name="release-notes")
|
kimi_cli/ui/shell/setup.py
CHANGED
|
@@ -26,19 +26,19 @@ class _Platform(NamedTuple):
|
|
|
26
26
|
_PLATFORMS = [
|
|
27
27
|
_Platform(
|
|
28
28
|
id="kimi-for-coding",
|
|
29
|
-
name="Kimi For Coding",
|
|
29
|
+
name="Kimi For Coding (CN)",
|
|
30
30
|
base_url="https://api.kimi.com/coding/v1",
|
|
31
31
|
search_url="https://api.kimi.com/coding/v1/search",
|
|
32
32
|
),
|
|
33
33
|
_Platform(
|
|
34
34
|
id="moonshot-cn",
|
|
35
|
-
name="Moonshot AI 开放平台",
|
|
35
|
+
name="Moonshot AI 开放平台 (moonshot.cn)",
|
|
36
36
|
base_url="https://api.moonshot.cn/v1",
|
|
37
37
|
allowed_models=["kimi-k2-turbo-preview", "kimi-k2-0905-preview", "kimi-k2-0711-preview"],
|
|
38
38
|
),
|
|
39
39
|
_Platform(
|
|
40
40
|
id="moonshot-ai",
|
|
41
|
-
name="Moonshot AI Open Platform",
|
|
41
|
+
name="Moonshot AI Open Platform (moonshot.ai)",
|
|
42
42
|
base_url="https://api.moonshot.ai/v1",
|
|
43
43
|
allowed_models=["kimi-k2-turbo-preview", "kimi-k2-0905-preview", "kimi-k2-0711-preview"],
|
|
44
44
|
),
|
|
@@ -77,7 +77,7 @@ async def setup(app: "ShellApp", args: list[str]):
|
|
|
77
77
|
await asyncio.sleep(1)
|
|
78
78
|
console.clear()
|
|
79
79
|
|
|
80
|
-
from kimi_cli import Reload
|
|
80
|
+
from kimi_cli.cli import Reload
|
|
81
81
|
|
|
82
82
|
raise Reload
|
|
83
83
|
|
|
@@ -185,6 +185,6 @@ async def _prompt_text(prompt: str, *, is_password: bool = False) -> str | None:
|
|
|
185
185
|
@meta_command
|
|
186
186
|
def reload(app: "ShellApp", args: list[str]):
|
|
187
187
|
"""Reload configuration"""
|
|
188
|
-
from kimi_cli import Reload
|
|
188
|
+
from kimi_cli.cli import Reload
|
|
189
189
|
|
|
190
190
|
raise Reload
|
kimi_cli/ui/shell/update.py
CHANGED
|
@@ -85,7 +85,7 @@ LATEST_VERSION_FILE = get_share_dir() / "latest_version.txt"
|
|
|
85
85
|
|
|
86
86
|
|
|
87
87
|
async def _do_update(*, print: bool, check_only: bool) -> UpdateResult:
|
|
88
|
-
from kimi_cli import
|
|
88
|
+
from kimi_cli.constant import VERSION as current_version
|
|
89
89
|
|
|
90
90
|
def _print(message: str) -> None:
|
|
91
91
|
if print:
|
|
@@ -105,7 +105,7 @@ async def _do_update(*, print: bool, check_only: bool) -> UpdateResult:
|
|
|
105
105
|
return UpdateResult.FAILED
|
|
106
106
|
|
|
107
107
|
logger.debug("Latest version: {latest_version}", latest_version=latest_version)
|
|
108
|
-
LATEST_VERSION_FILE.write_text(latest_version)
|
|
108
|
+
LATEST_VERSION_FILE.write_text(latest_version, encoding="utf-8")
|
|
109
109
|
|
|
110
110
|
cur_t = semver_tuple(current_version)
|
|
111
111
|
lat_t = semver_tuple(latest_version)
|
kimi_cli/ui/shell/visualize.py
CHANGED
|
@@ -5,19 +5,19 @@ from kosong.base.message import ContentPart, TextPart, ToolCall, ToolCallPart
|
|
|
5
5
|
from kosong.tooling import ToolResult
|
|
6
6
|
|
|
7
7
|
from kimi_cli.soul import StatusSnapshot
|
|
8
|
-
from kimi_cli.
|
|
8
|
+
from kimi_cli.ui.shell.console import console
|
|
9
|
+
from kimi_cli.ui.shell.keyboard import listen_for_keyboard
|
|
10
|
+
from kimi_cli.ui.shell.liveview import StepLiveView, StepLiveViewWithMarkdown
|
|
11
|
+
from kimi_cli.utils.logging import logger
|
|
12
|
+
from kimi_cli.wire import WireUISide
|
|
13
|
+
from kimi_cli.wire.message import (
|
|
9
14
|
ApprovalRequest,
|
|
10
15
|
CompactionBegin,
|
|
11
16
|
CompactionEnd,
|
|
12
17
|
StatusUpdate,
|
|
13
18
|
StepBegin,
|
|
14
19
|
StepInterrupted,
|
|
15
|
-
Wire,
|
|
16
20
|
)
|
|
17
|
-
from kimi_cli.ui.shell.console import console
|
|
18
|
-
from kimi_cli.ui.shell.keyboard import listen_for_keyboard
|
|
19
|
-
from kimi_cli.ui.shell.liveview import StepLiveView, StepLiveViewWithMarkdown
|
|
20
|
-
from kimi_cli.utils.logging import logger
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
@asynccontextmanager
|
|
@@ -39,7 +39,10 @@ async def _keyboard_listener(step: StepLiveView):
|
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
async def visualize(
|
|
42
|
-
wire:
|
|
42
|
+
wire: WireUISide,
|
|
43
|
+
*,
|
|
44
|
+
initial_status: StatusSnapshot,
|
|
45
|
+
cancel_event: asyncio.Event | None = None,
|
|
43
46
|
):
|
|
44
47
|
"""
|
|
45
48
|
A loop to consume agent events and visualize the agent behavior.
|
kimi_cli/utils/changelog.py
CHANGED
|
@@ -98,4 +98,6 @@ def format_release_notes(changelog: dict[str, ReleaseEntry]) -> str:
|
|
|
98
98
|
return "\n".join(parts).strip()
|
|
99
99
|
|
|
100
100
|
|
|
101
|
-
CHANGELOG = parse_changelog(
|
|
101
|
+
CHANGELOG = parse_changelog(
|
|
102
|
+
(Path(__file__).parent.parent / "CHANGELOG.md").read_text(encoding="utf-8")
|
|
103
|
+
)
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
|
|
3
|
+
from kosong.base.message import ContentPart, ToolCallPart
|
|
4
|
+
|
|
5
|
+
from kimi_cli.utils.logging import logger
|
|
6
|
+
from kimi_cli.wire.message import WireMessage
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Wire:
|
|
10
|
+
"""
|
|
11
|
+
A channel for communication between the soul and the UI during a soul run.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
def __init__(self):
|
|
15
|
+
self._queue = asyncio.Queue[WireMessage]()
|
|
16
|
+
self._soul_side = WireSoulSide(self._queue)
|
|
17
|
+
self._ui_side = WireUISide(self._queue)
|
|
18
|
+
|
|
19
|
+
@property
|
|
20
|
+
def soul_side(self) -> "WireSoulSide":
|
|
21
|
+
return self._soul_side
|
|
22
|
+
|
|
23
|
+
@property
|
|
24
|
+
def ui_side(self) -> "WireUISide":
|
|
25
|
+
return self._ui_side
|
|
26
|
+
|
|
27
|
+
def shutdown(self) -> None:
|
|
28
|
+
self._queue.shutdown()
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class WireSoulSide:
|
|
32
|
+
"""
|
|
33
|
+
The soul side of a wire.
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
def __init__(self, queue: asyncio.Queue[WireMessage]):
|
|
37
|
+
self._queue = queue
|
|
38
|
+
|
|
39
|
+
def send(self, msg: WireMessage) -> None:
|
|
40
|
+
if not isinstance(msg, ContentPart | ToolCallPart):
|
|
41
|
+
logger.debug("Sending wire message: {msg}", msg=msg)
|
|
42
|
+
self._queue.put_nowait(msg)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class WireUISide:
|
|
46
|
+
"""
|
|
47
|
+
The UI side of a wire.
|
|
48
|
+
"""
|
|
49
|
+
|
|
50
|
+
def __init__(self, queue: asyncio.Queue[WireMessage]):
|
|
51
|
+
self._queue = queue
|
|
52
|
+
|
|
53
|
+
async def receive(self) -> WireMessage:
|
|
54
|
+
msg = await self._queue.get()
|
|
55
|
+
if not isinstance(msg, ContentPart | ToolCallPart):
|
|
56
|
+
logger.debug("Receiving wire message: {msg}", msg=msg)
|
|
57
|
+
return msg
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
import uuid
|
|
3
|
-
from contextvars import ContextVar
|
|
4
3
|
from enum import Enum
|
|
5
|
-
from typing import NamedTuple
|
|
4
|
+
from typing import TYPE_CHECKING, NamedTuple
|
|
6
5
|
|
|
7
6
|
from kosong.base.message import ContentPart, ToolCall, ToolCallPart
|
|
8
7
|
from kosong.tooling import ToolResult
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
from kimi_cli.
|
|
9
|
+
if TYPE_CHECKING:
|
|
10
|
+
from kimi_cli.soul import StatusSnapshot
|
|
12
11
|
|
|
13
12
|
|
|
14
13
|
class StepBegin(NamedTuple):
|
|
@@ -39,7 +38,7 @@ class CompactionEnd:
|
|
|
39
38
|
|
|
40
39
|
|
|
41
40
|
class StatusUpdate(NamedTuple):
|
|
42
|
-
status: StatusSnapshot
|
|
41
|
+
status: "StatusSnapshot"
|
|
43
42
|
|
|
44
43
|
|
|
45
44
|
type ControlFlowEvent = StepBegin | StepInterrupted | CompactionBegin | CompactionEnd | StatusUpdate
|
|
@@ -90,37 +89,3 @@ class ApprovalRequest:
|
|
|
90
89
|
|
|
91
90
|
|
|
92
91
|
type WireMessage = Event | ApprovalRequest
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
class Wire:
|
|
96
|
-
"""
|
|
97
|
-
A channel for communication between the soul and the UI.
|
|
98
|
-
"""
|
|
99
|
-
|
|
100
|
-
def __init__(self):
|
|
101
|
-
self._queue = asyncio.Queue[WireMessage]()
|
|
102
|
-
|
|
103
|
-
def send(self, msg: WireMessage) -> None:
|
|
104
|
-
if not isinstance(msg, ContentPart | ToolCallPart):
|
|
105
|
-
logger.debug("Sending wire message: {msg}", msg=msg)
|
|
106
|
-
self._queue.put_nowait(msg)
|
|
107
|
-
|
|
108
|
-
async def receive(self) -> WireMessage:
|
|
109
|
-
msg = await self._queue.get()
|
|
110
|
-
if not isinstance(msg, ContentPart | ToolCallPart):
|
|
111
|
-
logger.debug("Receiving wire message: {msg}", msg=msg)
|
|
112
|
-
return msg
|
|
113
|
-
|
|
114
|
-
def shutdown(self) -> None:
|
|
115
|
-
self._queue.shutdown()
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
current_wire = ContextVar[Wire | None]("current_wire", default=None)
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
def get_wire_or_none() -> Wire | None:
|
|
122
|
-
"""
|
|
123
|
-
Get the current wire or None.
|
|
124
|
-
Expect to be not None when called from anywhere in the agent loop.
|
|
125
|
-
"""
|
|
126
|
-
return current_wire.get()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: kimi-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.41
|
|
4
4
|
Summary: Kimi CLI is your next CLI agent.
|
|
5
5
|
Requires-Dist: agent-client-protocol>=0.4.9
|
|
6
6
|
Requires-Dist: aiofiles>=25.1.0
|
|
@@ -24,6 +24,11 @@ Description-Content-Type: text/markdown
|
|
|
24
24
|
|
|
25
25
|
# Kimi CLI
|
|
26
26
|
|
|
27
|
+
[](https://github.com/MoonshotAI/kimi-cli/graphs/commit-activity)
|
|
28
|
+
[](https://github.com/MoonshotAI/kimi-cli/actions)
|
|
29
|
+
[](https://pypi.org/project/kimi-cli/)
|
|
30
|
+
[](https://pypistats.org/packages/kimi-cli)
|
|
31
|
+
|
|
27
32
|
[中文](https://www.kimi.com/coding/docs/kimi-cli.html)
|
|
28
33
|
|
|
29
34
|
Kimi CLI is a new CLI agent that can help you with your software development tasks and terminal operations.
|
|
@@ -152,3 +157,31 @@ Run `kimi` with `--mcp-config-file` option to connect to the specified MCP serve
|
|
|
152
157
|
```sh
|
|
153
158
|
kimi --mcp-config-file /path/to/mcp.json
|
|
154
159
|
```
|
|
160
|
+
|
|
161
|
+
## Development
|
|
162
|
+
|
|
163
|
+
To develop Kimi CLI, run:
|
|
164
|
+
|
|
165
|
+
```sh
|
|
166
|
+
git clone https://github.com/MoonshotAI/kimi-cli.git
|
|
167
|
+
cd kimi-cli
|
|
168
|
+
|
|
169
|
+
make prepare # prepare the development environment
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Then you can start working on Kimi CLI.
|
|
173
|
+
|
|
174
|
+
Refer to the following commands after you make changes:
|
|
175
|
+
|
|
176
|
+
```sh
|
|
177
|
+
uv run kimi # run Kimi CLI
|
|
178
|
+
|
|
179
|
+
make format # format code
|
|
180
|
+
make check # run linting and type checking
|
|
181
|
+
make test # run tests
|
|
182
|
+
make help # show all make targets
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## Contributing
|
|
186
|
+
|
|
187
|
+
We welcome contributions to Kimi CLI! Please refer to [CONTRIBUTING.md](./CONTRIBUTING.md) for more information.
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
kimi_cli/CHANGELOG.md,sha256=123552f382ba5832f923e1c03878e563423d92a7ff5f9a55014686e069e7056c,7648
|
|
2
|
+
kimi_cli/__init__.py,sha256=17c8048d23b3d27c3c4645ebc541d14bd2e42071db6d6df5abee06a7256d7541,4249
|
|
3
|
+
kimi_cli/agents/koder/README.md,sha256=2d9a987110652915cd1a4356caec3eef9380479ce36906c377a1ed177d46690f,96
|
|
4
|
+
kimi_cli/agents/koder/agent.yaml,sha256=f1c5c585e8e0a52419c820d56a4aa928eebdf7bb21f0907d6c02d4ea1c8909d7,709
|
|
5
|
+
kimi_cli/agents/koder/sub.yaml,sha256=e0c1ea34fdb04b0d6dc635709f0f130aff25d7f9fb97e238470143c8145be251,634
|
|
6
|
+
kimi_cli/agents/koder/system.md,sha256=1d8fd4956b2442215396b5e9651771c9da8f9505ccbd3b6d5e91b1ac4ff35418,5001
|
|
7
|
+
kimi_cli/agentspec.py,sha256=fc5d180fe27a50a7d1b616c2ee6cffb823f8d9990f724250110c2d489b89ae9b,3973
|
|
8
|
+
kimi_cli/cli.py,sha256=6e1de173cd73c6d49f8922dd07fc4f177bcfe038416c3fe3e7d464759f7dd50d,6229
|
|
9
|
+
kimi_cli/config.py,sha256=37dd65f2aa03c051dc92d09d9c110361ee35bb8dc94eced2c1e8bf01e3918353,4157
|
|
10
|
+
kimi_cli/constant.py,sha256=78e25b9304cca7b6f70bb08bf0e1fee4b066297a05386e56dd6935ba42027cd9,110
|
|
11
|
+
kimi_cli/llm.py,sha256=4c807741b6073fc18533baf6025f2351035690e94d7993dc9e3ef9a1050e7022,2668
|
|
12
|
+
kimi_cli/metadata.py,sha256=70c01da57529a9f585c0c5f3dd642f92ef16c4e49a107d8da838fa6d4746546a,3933
|
|
13
|
+
kimi_cli/prompts/__init__.py,sha256=6dc5ed2d841f145c09550075f30853cdc51f00d2f5d9aa1097f8edea770536e7,174
|
|
14
|
+
kimi_cli/prompts/compact.md,sha256=6655bd7d8270b24d8f97b51ef7c471cf71d686c56f8ec9a5cc9e47caa3aae87c,1877
|
|
15
|
+
kimi_cli/prompts/init.md,sha256=d271a0df6dd7b330ffec4f645a74c0392dafc1b3bfc1e3f2a77624e96cf6abbe,1380
|
|
16
|
+
kimi_cli/py.typed,sha256=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855,0
|
|
17
|
+
kimi_cli/share.py,sha256=4292df7f44177419c45c772a933b5f36e2b7533f8cef9842629a438bc7856dc0,204
|
|
18
|
+
kimi_cli/soul/__init__.py,sha256=c1c09bb719c46db8d95873e4ef9856cbef92f54035829749c779ab0fad3dfc50,4702
|
|
19
|
+
kimi_cli/soul/agent.py,sha256=cc9ae5b903f7048372fe15833ac95ab9b694eefb0b97981321f51be5fe247560,4942
|
|
20
|
+
kimi_cli/soul/approval.py,sha256=48cd230dff81dfd70bd85f1ad2b99604d5569cf617a4c79c444f9772bbc89ce6,2552
|
|
21
|
+
kimi_cli/soul/compaction.py,sha256=dab17979060fceeed4a7a344373833022dc7abac04282364f2a1b20e6edd4581,3558
|
|
22
|
+
kimi_cli/soul/context.py,sha256=5536c54186ca3df22ad33007e37588228fd1097f0cb8aab68b634433e8cd0ad6,5993
|
|
23
|
+
kimi_cli/soul/denwarenji.py,sha256=66b95f052a1fa844e2347972d34e1916a7be24d3e493701b451f5380b0375c9f,1384
|
|
24
|
+
kimi_cli/soul/globals.py,sha256=fe85cfb616671c06f4b9eb9fcbef78929169e18d26a6abb3c6d3efd686593c97,2638
|
|
25
|
+
kimi_cli/soul/kimisoul.py,sha256=44fa91ff54902adc142588c4168a7919ea342759c5e5412cae660fac07802984,11658
|
|
26
|
+
kimi_cli/soul/message.py,sha256=b0fce0a0901fad38f2778b85f82427d4a42906891893a643e537a9268eb6e190,2529
|
|
27
|
+
kimi_cli/soul/toolset.py,sha256=60166d89ef0efac690fa6866e88afe70fbe80ad862ba2524d70ddf657a730d14,744
|
|
28
|
+
kimi_cli/tools/__init__.py,sha256=4d612402814eede7182e0a55e7dd21c4532b5dd44700dc744763a8308c2f74f8,3280
|
|
29
|
+
kimi_cli/tools/bash/__init__.py,sha256=de21b19c714bda53f6c89e3348c4c82fb4278040130fed1d261b3ab203054e8c,3028
|
|
30
|
+
kimi_cli/tools/bash/bash.md,sha256=5d9cc54b3718097951340b0a737c8e1fa308341fd2c4ebd121be94de31dd5f73,2348
|
|
31
|
+
kimi_cli/tools/dmail/__init__.py,sha256=a9186ed4e52c34cab7516060bb6edca73324912233b1581c0d3a40b026400133,1277
|
|
32
|
+
kimi_cli/tools/dmail/dmail.md,sha256=0d18cae387dd52127ddc99e296253c09e68ccba5f343153c0adbe77d7586e759,1912
|
|
33
|
+
kimi_cli/tools/file/__init__.py,sha256=1516fb4c71097f9c14b605e7b9a1872af8786bdcb48323d1fa83bb1419436abb,546
|
|
34
|
+
kimi_cli/tools/file/glob.md,sha256=11fbfaf6033f57b69c6f91077ddd90505036937cd7217600d96992b9a48b7ca7,1400
|
|
35
|
+
kimi_cli/tools/file/glob.py,sha256=24f52f61e0c9dff7eb2e8138238de365d17f90dfff6555b27e741bf5f7bc43a6,5413
|
|
36
|
+
kimi_cli/tools/file/grep.md,sha256=12353db42cf3b5d9d91ac7c0f0b9c2a732e8b050c23a78f4e668db823cca4d50,245
|
|
37
|
+
kimi_cli/tools/file/grep.py,sha256=01794320049b46207aeb28bd7f3dbea373ede891916107cab871ea959e81a335,9787
|
|
38
|
+
kimi_cli/tools/file/patch.md,sha256=f9edbed6c6a03bf7448a51acc1f42622395fd7f1674a814e9a3b2302d3b7b92e,404
|
|
39
|
+
kimi_cli/tools/file/patch.py,sha256=022262263a062bbc3418c132588b5c1e039a0e6c3572af5389193b5aea235027,5228
|
|
40
|
+
kimi_cli/tools/file/read.md,sha256=4c2d83e557daadc0612fb1a613e252b2c8e4df7ae57e6db094e9e75e994cb23b,1066
|
|
41
|
+
kimi_cli/tools/file/read.py,sha256=5d452270c9e0e668276cc3dfad56d5b26c8431a8b0d9b97d0d4484c8e62b5faa,5068
|
|
42
|
+
kimi_cli/tools/file/replace.md,sha256=f429f263fa580f2f6107907a33ba8800dcdbd4fc1d9ff8dc4f858bd76ec6bbc6,267
|
|
43
|
+
kimi_cli/tools/file/replace.py,sha256=615bb2d1e4d14f5f2c3e780af69b0f69b23f4b610f451077c93d57a1ca860cf1,5204
|
|
44
|
+
kimi_cli/tools/file/write.md,sha256=f37b0f4742da57797ec4dd29fbd4fdc9b6617c6be644724a3b16d651c6129cec,324
|
|
45
|
+
kimi_cli/tools/file/write.py,sha256=9aff67ce8817adf223f9bd982c7ad5d8b13f4d33b221147ac3253035d3a2b7a7,4378
|
|
46
|
+
kimi_cli/tools/mcp.py,sha256=12f63c9ee5b82a5b0f23daca0b5ce4ceb3a6190ce5b553ee24e499699521e426,3620
|
|
47
|
+
kimi_cli/tools/task/__init__.py,sha256=e671d9ea87c811104629eaaf8a1f8e9c3c82b0294354683dba6747ea528bdbcd,6032
|
|
48
|
+
kimi_cli/tools/task/task.md,sha256=391cc3553c7d310a323626bae180dd41cb810fb1233583713ebde105f954147a,2280
|
|
49
|
+
kimi_cli/tools/test.py,sha256=c094a91a2d1a5259e192f1147facd5eebd5e5c413787fce167db90e4b41b5119,1442
|
|
50
|
+
kimi_cli/tools/think/__init__.py,sha256=31b06088e2404cb09d42e0acec97c185e4861890bb687f28b41f39cea01b5733,603
|
|
51
|
+
kimi_cli/tools/think/think.md,sha256=ab40d4de1d8adb208384a4ab548e35776283cb0a681c6e208b041fc40ccba724,200
|
|
52
|
+
kimi_cli/tools/todo/__init__.py,sha256=aa02c8afa19d9ae2ef1f6ffee147dc96732a9cb9895aa5e13fe0f9efe753fe00,897
|
|
53
|
+
kimi_cli/tools/todo/set_todo_list.md,sha256=89509503f43ab321d440a04dc133ddc3e29859f68907a42c39e6093f7bfd485c,1654
|
|
54
|
+
kimi_cli/tools/utils.py,sha256=2e00d6f04f91e05a91bfb691e547a76193063fa6769a03f7d3ff992aba9372bf,4596
|
|
55
|
+
kimi_cli/tools/web/__init__.py,sha256=e13108c598828a8a05907a7a821e7ac92f5d63572bb9866dc12ca026094acb42,95
|
|
56
|
+
kimi_cli/tools/web/fetch.md,sha256=56d00bd93b4e379c4f7efe445fce963eb26b8d20f85d4c19097ba6f33bd0019a,67
|
|
57
|
+
kimi_cli/tools/web/fetch.py,sha256=66448121d27d67f75b977c32244c721c2ccff1b2e097c2fe6717e66018d8f747,3183
|
|
58
|
+
kimi_cli/tools/web/search.md,sha256=24049f9e90d37083e0fc78b8b2e3a5f6fadf09bea00f36712b235d1212a2f532,146
|
|
59
|
+
kimi_cli/tools/web/search.py,sha256=2f72c82ed1f775db9fed2ef1ceb1a26184b745805d11f070e198a2c16668c152,4347
|
|
60
|
+
kimi_cli/ui/__init__.py,sha256=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855,0
|
|
61
|
+
kimi_cli/ui/acp/__init__.py,sha256=cc8bf39f342de7661134f282369b286bb6c4571b1e0001a0cb216207a62d709c,17354
|
|
62
|
+
kimi_cli/ui/print/__init__.py,sha256=10590ec04b8d0f8d1593471c40fc96d7062854f3fbc81a6822703d8118310fd1,5730
|
|
63
|
+
kimi_cli/ui/shell/__init__.py,sha256=35e3a4a29e8610bc214a696c064746db8d19e991f014904e9ef2bd3845e63947,10708
|
|
64
|
+
kimi_cli/ui/shell/console.py,sha256=bcbf7efd214cba3d2259f2a2c1842250cde96d49e4f9f1e0b60273cf1c366be3,842
|
|
65
|
+
kimi_cli/ui/shell/debug.py,sha256=cd4e7259c83f099b5c6519713be5306580f30d3fa4944e07916d4468e960c9c7,5562
|
|
66
|
+
kimi_cli/ui/shell/keyboard.py,sha256=8735c00363484263681adf885baec824e5f76cb4084bd024651e80190926edc5,3035
|
|
67
|
+
kimi_cli/ui/shell/liveview.py,sha256=f4e6ac37c446740b5c55cf37d5ebd327b5d41334d41d5e54ad8ad15445c1a492,14239
|
|
68
|
+
kimi_cli/ui/shell/metacmd.py,sha256=69ef37801f9d5ce513717d6351966f54f363c5ce41b176e98a0fc8b71fe5a78c,7786
|
|
69
|
+
kimi_cli/ui/shell/prompt.py,sha256=f85446d77b998e2594380c29000b06614e3fae8537db46ec96fc5ddc25490b45,19096
|
|
70
|
+
kimi_cli/ui/shell/setup.py,sha256=36be348c8cdbb908f1b896f7dfd93802df4d76eeb8572d39b81a34dfd5ee2a3c,5374
|
|
71
|
+
kimi_cli/ui/shell/update.py,sha256=56dcb0bd1da82b98c22bfdddca717a2805bd8ac3e93bf23fb3b508549c41fae8,7340
|
|
72
|
+
kimi_cli/ui/shell/visualize.py,sha256=7035d53e41ae59e5df7008759ee4f14e44352cc4ac087c6b67d784a7dd51c733,4291
|
|
73
|
+
kimi_cli/utils/aiohttp.py,sha256=f8f61e3beaf6439e949c33c3a10db3035bf88136e882b09c858ea92a4c888e00,245
|
|
74
|
+
kimi_cli/utils/changelog.py,sha256=bfcf5a5a360b13648bb7a6abc83e427270caa502646b5acc950d62148510641c,3402
|
|
75
|
+
kimi_cli/utils/logging.py,sha256=129298ac214ecd8d913c3431cc05d754f9c4c8c4042c458618bf9e8ddebdb763,399
|
|
76
|
+
kimi_cli/utils/message.py,sha256=ca8f8d3c7dc6d4fce938d1cfe8a7a7343e39ce1e2f0c7b2d76d838edc7d9f187,304
|
|
77
|
+
kimi_cli/utils/path.py,sha256=fdd4fc08999ddc7c610f884b4ba8d27932248b9ed06b5eb4139519edd00b3f75,687
|
|
78
|
+
kimi_cli/utils/pyinstaller.py,sha256=e5d709d0490ef8645bbed2d2363920c59f25bd17c04f471bf4a8c0fa2ebe1801,581
|
|
79
|
+
kimi_cli/utils/string.py,sha256=f8a842ee014b9023d4045392f33ca6f576f5238ad3d40cb6df071a3ce9f5ed9c,365
|
|
80
|
+
kimi_cli/wire/__init__.py,sha256=92514141ef99c2923dacba48e7c96692d636848e3b222de7de9f696691cc1aaa,1427
|
|
81
|
+
kimi_cli/wire/message.py,sha256=72222d3f3d7228a323dbba7b1084f35018104c58e4bb2aa51d0827984791841d,2398
|
|
82
|
+
kimi_cli-0.41.dist-info/WHEEL,sha256=70ab3c2925fe316809860cb034f99ba13c4b49819b339959274aab755cc084a8,78
|
|
83
|
+
kimi_cli-0.41.dist-info/entry_points.txt,sha256=97e051756296e9db3167f6dce61d6c88e58d170314a2d63d18c84c73a5c1333b,44
|
|
84
|
+
kimi_cli-0.41.dist-info/METADATA,sha256=d3865fbce4c1bdaae5bd311dab5cca3569035d80cb65b27185d740596522c5e2,5187
|
|
85
|
+
kimi_cli-0.41.dist-info/RECORD,,
|