kimi-cli 0.44__py3-none-any.whl → 0.78__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 +349 -40
- kimi_cli/__init__.py +6 -0
- kimi_cli/acp/AGENTS.md +91 -0
- kimi_cli/acp/__init__.py +13 -0
- kimi_cli/acp/convert.py +111 -0
- kimi_cli/acp/kaos.py +270 -0
- kimi_cli/acp/mcp.py +46 -0
- kimi_cli/acp/server.py +335 -0
- kimi_cli/acp/session.py +445 -0
- kimi_cli/acp/tools.py +158 -0
- kimi_cli/acp/types.py +13 -0
- kimi_cli/agents/default/agent.yaml +4 -4
- kimi_cli/agents/default/sub.yaml +2 -1
- kimi_cli/agents/default/system.md +79 -21
- kimi_cli/agents/okabe/agent.yaml +17 -0
- kimi_cli/agentspec.py +53 -25
- kimi_cli/app.py +180 -52
- kimi_cli/cli/__init__.py +595 -0
- kimi_cli/cli/__main__.py +8 -0
- kimi_cli/cli/info.py +63 -0
- kimi_cli/cli/mcp.py +349 -0
- kimi_cli/config.py +153 -17
- kimi_cli/constant.py +3 -0
- kimi_cli/exception.py +23 -2
- kimi_cli/flow/__init__.py +117 -0
- kimi_cli/flow/d2.py +376 -0
- kimi_cli/flow/mermaid.py +218 -0
- kimi_cli/llm.py +129 -23
- kimi_cli/metadata.py +32 -7
- kimi_cli/platforms.py +262 -0
- kimi_cli/prompts/__init__.py +2 -0
- kimi_cli/prompts/compact.md +4 -5
- kimi_cli/session.py +223 -31
- kimi_cli/share.py +2 -0
- kimi_cli/skill.py +145 -0
- kimi_cli/skills/kimi-cli-help/SKILL.md +55 -0
- kimi_cli/skills/skill-creator/SKILL.md +351 -0
- kimi_cli/soul/__init__.py +51 -20
- kimi_cli/soul/agent.py +213 -85
- kimi_cli/soul/approval.py +86 -17
- kimi_cli/soul/compaction.py +64 -53
- kimi_cli/soul/context.py +38 -5
- kimi_cli/soul/denwarenji.py +2 -0
- kimi_cli/soul/kimisoul.py +442 -60
- kimi_cli/soul/message.py +54 -54
- kimi_cli/soul/slash.py +72 -0
- kimi_cli/soul/toolset.py +387 -6
- kimi_cli/toad.py +74 -0
- kimi_cli/tools/AGENTS.md +5 -0
- kimi_cli/tools/__init__.py +42 -34
- kimi_cli/tools/display.py +25 -0
- kimi_cli/tools/dmail/__init__.py +10 -10
- kimi_cli/tools/dmail/dmail.md +11 -9
- kimi_cli/tools/file/__init__.py +1 -3
- kimi_cli/tools/file/glob.py +20 -23
- kimi_cli/tools/file/grep.md +1 -1
- kimi_cli/tools/file/{grep.py → grep_local.py} +51 -23
- kimi_cli/tools/file/read.md +24 -6
- kimi_cli/tools/file/read.py +134 -50
- kimi_cli/tools/file/replace.md +1 -1
- kimi_cli/tools/file/replace.py +36 -29
- kimi_cli/tools/file/utils.py +282 -0
- kimi_cli/tools/file/write.py +43 -22
- kimi_cli/tools/multiagent/__init__.py +7 -0
- kimi_cli/tools/multiagent/create.md +11 -0
- kimi_cli/tools/multiagent/create.py +50 -0
- kimi_cli/tools/{task/__init__.py → multiagent/task.py} +48 -53
- kimi_cli/tools/shell/__init__.py +120 -0
- kimi_cli/tools/{bash → shell}/bash.md +1 -2
- kimi_cli/tools/shell/powershell.md +25 -0
- kimi_cli/tools/test.py +4 -4
- kimi_cli/tools/think/__init__.py +2 -2
- kimi_cli/tools/todo/__init__.py +14 -8
- kimi_cli/tools/utils.py +64 -24
- kimi_cli/tools/web/fetch.py +68 -13
- kimi_cli/tools/web/search.py +10 -12
- kimi_cli/ui/acp/__init__.py +65 -412
- kimi_cli/ui/print/__init__.py +37 -49
- kimi_cli/ui/print/visualize.py +179 -0
- kimi_cli/ui/shell/__init__.py +141 -84
- kimi_cli/ui/shell/console.py +2 -0
- kimi_cli/ui/shell/debug.py +28 -23
- kimi_cli/ui/shell/keyboard.py +5 -1
- kimi_cli/ui/shell/prompt.py +220 -194
- kimi_cli/ui/shell/replay.py +111 -46
- kimi_cli/ui/shell/setup.py +89 -82
- kimi_cli/ui/shell/slash.py +422 -0
- kimi_cli/ui/shell/update.py +4 -2
- kimi_cli/ui/shell/usage.py +271 -0
- kimi_cli/ui/shell/visualize.py +574 -72
- kimi_cli/ui/wire/__init__.py +267 -0
- kimi_cli/ui/wire/jsonrpc.py +142 -0
- kimi_cli/ui/wire/protocol.py +1 -0
- kimi_cli/utils/__init__.py +0 -0
- kimi_cli/utils/aiohttp.py +2 -0
- kimi_cli/utils/aioqueue.py +72 -0
- kimi_cli/utils/broadcast.py +37 -0
- kimi_cli/utils/changelog.py +12 -7
- kimi_cli/utils/clipboard.py +12 -0
- kimi_cli/utils/datetime.py +37 -0
- kimi_cli/utils/environment.py +58 -0
- kimi_cli/utils/envvar.py +12 -0
- kimi_cli/utils/frontmatter.py +44 -0
- kimi_cli/utils/logging.py +7 -6
- kimi_cli/utils/message.py +9 -14
- kimi_cli/utils/path.py +99 -9
- kimi_cli/utils/pyinstaller.py +6 -0
- kimi_cli/utils/rich/__init__.py +33 -0
- kimi_cli/utils/rich/columns.py +99 -0
- kimi_cli/utils/rich/markdown.py +961 -0
- kimi_cli/utils/rich/markdown_sample.md +108 -0
- kimi_cli/utils/rich/markdown_sample_short.md +2 -0
- kimi_cli/utils/signals.py +2 -0
- kimi_cli/utils/slashcmd.py +124 -0
- kimi_cli/utils/string.py +2 -0
- kimi_cli/utils/term.py +168 -0
- kimi_cli/utils/typing.py +20 -0
- kimi_cli/wire/__init__.py +98 -29
- kimi_cli/wire/serde.py +45 -0
- kimi_cli/wire/types.py +299 -0
- kimi_cli-0.78.dist-info/METADATA +200 -0
- kimi_cli-0.78.dist-info/RECORD +135 -0
- kimi_cli-0.78.dist-info/entry_points.txt +4 -0
- kimi_cli/cli.py +0 -250
- kimi_cli/soul/runtime.py +0 -96
- kimi_cli/tools/bash/__init__.py +0 -99
- kimi_cli/tools/file/patch.md +0 -8
- kimi_cli/tools/file/patch.py +0 -143
- kimi_cli/tools/mcp.py +0 -85
- kimi_cli/ui/shell/liveview.py +0 -386
- kimi_cli/ui/shell/metacmd.py +0 -262
- kimi_cli/wire/message.py +0 -91
- kimi_cli-0.44.dist-info/METADATA +0 -188
- kimi_cli-0.44.dist-info/RECORD +0 -89
- kimi_cli-0.44.dist-info/entry_points.txt +0 -3
- /kimi_cli/tools/{task → multiagent}/task.md +0 -0
- {kimi_cli-0.44.dist-info → kimi_cli-0.78.dist-info}/WHEEL +0 -0
kimi_cli/soul/context.py
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
1
3
|
import json
|
|
2
4
|
from collections.abc import Sequence
|
|
3
5
|
from pathlib import Path
|
|
4
6
|
|
|
5
7
|
import aiofiles
|
|
6
8
|
import aiofiles.os
|
|
7
|
-
from kosong.
|
|
9
|
+
from kosong.message import Message
|
|
8
10
|
|
|
9
11
|
from kimi_cli.soul.message import system
|
|
10
12
|
from kimi_cli.utils.logging import logger
|
|
@@ -59,6 +61,10 @@ class Context:
|
|
|
59
61
|
def n_checkpoints(self) -> int:
|
|
60
62
|
return self._next_checkpoint_id
|
|
61
63
|
|
|
64
|
+
@property
|
|
65
|
+
def file_backend(self) -> Path:
|
|
66
|
+
return self._file_backend
|
|
67
|
+
|
|
62
68
|
async def checkpoint(self, add_user_message: bool):
|
|
63
69
|
checkpoint_id = self._next_checkpoint_id
|
|
64
70
|
self._next_checkpoint_id += 1
|
|
@@ -90,14 +96,14 @@ class Context:
|
|
|
90
96
|
logger.error("Checkpoint {checkpoint_id} does not exist", checkpoint_id=checkpoint_id)
|
|
91
97
|
raise ValueError(f"Checkpoint {checkpoint_id} does not exist")
|
|
92
98
|
|
|
93
|
-
# rotate the
|
|
99
|
+
# rotate the context file
|
|
94
100
|
rotated_file_path = await next_available_rotation(self._file_backend)
|
|
95
101
|
if rotated_file_path is None:
|
|
96
102
|
logger.error("No available rotation path found")
|
|
97
103
|
raise RuntimeError("No available rotation path found")
|
|
98
|
-
await aiofiles.os.
|
|
104
|
+
await aiofiles.os.replace(self._file_backend, rotated_file_path)
|
|
99
105
|
logger.debug(
|
|
100
|
-
"Rotated
|
|
106
|
+
"Rotated context file: {rotated_file_path}", rotated_file_path=rotated_file_path
|
|
101
107
|
)
|
|
102
108
|
|
|
103
109
|
# restore the context until the specified checkpoint
|
|
@@ -125,9 +131,36 @@ class Context:
|
|
|
125
131
|
message = Message.model_validate(line_json)
|
|
126
132
|
self._history.append(message)
|
|
127
133
|
|
|
134
|
+
async def clear(self):
|
|
135
|
+
"""
|
|
136
|
+
Clear the context history.
|
|
137
|
+
This is almost equivalent to revert_to(0), but without relying on the assumption
|
|
138
|
+
that the first checkpoint exists.
|
|
139
|
+
File backend will be rotated.
|
|
140
|
+
|
|
141
|
+
Raises:
|
|
142
|
+
RuntimeError: When no available rotation path is found.
|
|
143
|
+
"""
|
|
144
|
+
|
|
145
|
+
logger.debug("Clearing context")
|
|
146
|
+
|
|
147
|
+
# rotate the context file
|
|
148
|
+
rotated_file_path = await next_available_rotation(self._file_backend)
|
|
149
|
+
if rotated_file_path is None:
|
|
150
|
+
logger.error("No available rotation path found")
|
|
151
|
+
raise RuntimeError("No available rotation path found")
|
|
152
|
+
await aiofiles.os.replace(self._file_backend, rotated_file_path)
|
|
153
|
+
logger.debug(
|
|
154
|
+
"Rotated context file: {rotated_file_path}", rotated_file_path=rotated_file_path
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
self._history.clear()
|
|
158
|
+
self._token_count = 0
|
|
159
|
+
self._next_checkpoint_id = 0
|
|
160
|
+
|
|
128
161
|
async def append_message(self, message: Message | Sequence[Message]):
|
|
129
162
|
logger.debug("Appending message(s) to context: {message}", message=message)
|
|
130
|
-
messages = message if isinstance(message,
|
|
163
|
+
messages = [message] if isinstance(message, Message) else message
|
|
131
164
|
self._history.extend(messages)
|
|
132
165
|
|
|
133
166
|
async with aiofiles.open(self._file_backend, "a", encoding="utf-8") as f:
|