mainspring-coding-tools 0.1.0__tar.gz
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.
- mainspring_coding_tools-0.1.0/LICENSE +21 -0
- mainspring_coding_tools-0.1.0/PKG-INFO +59 -0
- mainspring_coding_tools-0.1.0/README.md +34 -0
- mainspring_coding_tools-0.1.0/mainspring_coding_tools/__init__.py +154 -0
- mainspring_coding_tools-0.1.0/mainspring_coding_tools/__main__.py +112 -0
- mainspring_coding_tools-0.1.0/mainspring_coding_tools/cli.py +362 -0
- mainspring_coding_tools-0.1.0/mainspring_coding_tools/coding.py +326 -0
- mainspring_coding_tools-0.1.0/mainspring_coding_tools/files.py +458 -0
- mainspring_coding_tools-0.1.0/mainspring_coding_tools/jobs.py +356 -0
- mainspring_coding_tools-0.1.0/mainspring_coding_tools/payload.py +40 -0
- mainspring_coding_tools-0.1.0/mainspring_coding_tools/persona.py +45 -0
- mainspring_coding_tools-0.1.0/mainspring_coding_tools/py.typed +0 -0
- mainspring_coding_tools-0.1.0/mainspring_coding_tools/safety.py +424 -0
- mainspring_coding_tools-0.1.0/mainspring_coding_tools/search.py +204 -0
- mainspring_coding_tools-0.1.0/mainspring_coding_tools/shell.py +336 -0
- mainspring_coding_tools-0.1.0/mainspring_coding_tools/web.py +590 -0
- mainspring_coding_tools-0.1.0/pyproject.toml +44 -0
- mainspring_coding_tools-0.1.0/pyproject.toml.orig +44 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 mainspring contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mainspring-coding-tools
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Coding agent toolset and terminal REPL for mainspring.
|
|
5
|
+
Author: mainspring contributors
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
16
|
+
Classifier: Typing :: Typed
|
|
17
|
+
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
18
|
+
Requires-Dist: mainspring-agent
|
|
19
|
+
Requires-Python: >=3.11
|
|
20
|
+
Project-URL: Homepage, https://github.com/chyong/mainspring
|
|
21
|
+
Project-URL: Documentation, https://github.com/chyong/mainspring/tree/main/docs
|
|
22
|
+
Project-URL: Repository, https://github.com/chyong/mainspring
|
|
23
|
+
Project-URL: Issues, https://github.com/chyong/mainspring/issues
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# mainspring-coding-tools
|
|
27
|
+
|
|
28
|
+
编码智能体工具组(T10):读 / 写 / 编辑 / 搜索 / shell / 后台任务 / todo / 可选网页工具,
|
|
29
|
+
外加一个终端 REPL。除 core 外零额外运行时依赖。
|
|
30
|
+
|
|
31
|
+
## 安装
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install mainspring-coding-tools
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## 终端编码助手
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
mainspring-coder --root .
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
工具卡片、diff、写文件与执行命令前的 `y/n` 审批全在终端里;命令:`/new`、`/resume`、
|
|
44
|
+
`/model <name>`、`/quit`。独立入口使用内存会话与本机命令引擎;需要持久化与沙箱引擎时,
|
|
45
|
+
改用仓库 `examples/coding_cli.py` 的完整装配。
|
|
46
|
+
|
|
47
|
+
## 作为库使用
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
from pathlib import Path
|
|
51
|
+
from mainspring_coding_tools import SafetyPolicy, build_coding_tools
|
|
52
|
+
|
|
53
|
+
tools = build_coding_tools(SafetyPolicy(root=Path.cwd()))
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
14 个工具:读写编辑、列目录、glob、grep、bash、后台任务状态与终止、todo、网页搜索与抓取。
|
|
57
|
+
所有有副作用的工具在注册了审批 Hook 时都会走审批链。
|
|
58
|
+
|
|
59
|
+
mainspring 工作区成员,与 [core](https://github.com/chyong/mainspring) 同源。MIT。
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# mainspring-coding-tools
|
|
2
|
+
|
|
3
|
+
编码智能体工具组(T10):读 / 写 / 编辑 / 搜索 / shell / 后台任务 / todo / 可选网页工具,
|
|
4
|
+
外加一个终端 REPL。除 core 外零额外运行时依赖。
|
|
5
|
+
|
|
6
|
+
## 安装
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
pip install mainspring-coding-tools
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## 终端编码助手
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
mainspring-coder --root .
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
工具卡片、diff、写文件与执行命令前的 `y/n` 审批全在终端里;命令:`/new`、`/resume`、
|
|
19
|
+
`/model <name>`、`/quit`。独立入口使用内存会话与本机命令引擎;需要持久化与沙箱引擎时,
|
|
20
|
+
改用仓库 `examples/coding_cli.py` 的完整装配。
|
|
21
|
+
|
|
22
|
+
## 作为库使用
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
from pathlib import Path
|
|
26
|
+
from mainspring_coding_tools import SafetyPolicy, build_coding_tools
|
|
27
|
+
|
|
28
|
+
tools = build_coding_tools(SafetyPolicy(root=Path.cwd()))
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
14 个工具:读写编辑、列目录、glob、grep、bash、后台任务状态与终止、todo、网页搜索与抓取。
|
|
32
|
+
所有有副作用的工具在注册了审批 Hook 时都会走审批链。
|
|
33
|
+
|
|
34
|
+
mainspring 工作区成员,与 [core](https://github.com/chyong/mainspring) 同源。MIT。
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"""mainspring-coding-tools:编码智能体工具外挂(M9,ADR-002 同款「能力走外挂」)。
|
|
2
|
+
|
|
3
|
+
core 提供「能不能跑 / 该不该跑」(Runner + Hook + Guardrail + HITL),本外挂提供
|
|
4
|
+
「拿什么干活」:一组可直接进 ``Agent.tools`` 的编码工具 + 一个可配置的安全总闸。
|
|
5
|
+
core 零改动,外挂可整体卸载;与既有 extras 同规格(workspace 成员 / import-linter
|
|
6
|
+
登记 / 显式装配),不新增第三方运行时依赖,工具实现全 stdlib。
|
|
7
|
+
|
|
8
|
+
模块归属(T10-1 定骨架,后续卡逐格填实现):
|
|
9
|
+
|
|
10
|
+
files.py 读 / 写工具:read_file、write_file、edit_file(T10-2 / T10-3)
|
|
11
|
+
search.py 只读检索:glob、grep(T10-2)
|
|
12
|
+
web.py 出网工具:web_search、web_fetch(stdlib urllib + SSRF 防线,T15-⑥)
|
|
13
|
+
shell.py 命令执行:bash,沙箱引擎经装配层注入(T10-4)
|
|
14
|
+
jobs.py 后台任务:bash_bg / job_status / job_kill(T15-⑨)
|
|
15
|
+
coding.py todo 任务清单工具 + 编码 Agent 装配工厂(T10-5 / T10-7)
|
|
16
|
+
safety.py SafetyPolicy:项目根白名单 / 危险命令表 / 审批默认值(T10-6)
|
|
17
|
+
payload.py 结构化 payload 契约:版本号 / 基类 / 截断标志(T10-2 起)
|
|
18
|
+
|
|
19
|
+
三条设计不变量(先定死,后补必返工):
|
|
20
|
+
|
|
21
|
+
1. **工具结果一律结构化 payload**:路径、命中列表、unified diff、退出码、截断标志
|
|
22
|
+
都是一等数据;文本只是投影。M11 前端的 diff / 卡片渲染直接消费它,禁止用裸
|
|
23
|
+
print 文本约定当接口。``@tool`` 会把 dict / BaseModel 序列化成 JSON 文本回填,
|
|
24
|
+
所以 payload 的形状就是跨进程协议,改格式必须联动前端评审。
|
|
25
|
+
2. **写 / 执行默认 require_approval**:不另起审批机制,直接经 core 的
|
|
26
|
+
``Hook.pre_tool_use`` 三态裁决 + Runner 的 pending 快照;读类默认放行,
|
|
27
|
+
开关可经 yaml 配置。任何安全组件异常一律降级 deny(fail-closed)。
|
|
28
|
+
3. **沙箱 / 记忆等外挂不互 import**:import-linter 的 independence 契约禁止
|
|
29
|
+
extras 之间产生依赖箭头,需要复用 M7~M8 沙箱资产时走**装配层注入**
|
|
30
|
+
(同 core.config.backends 的间接装配口径),由 CLI / server 把引擎实例送进来。
|
|
31
|
+
|
|
32
|
+
用法示例(T10-7 起:CLI 与 server 共用一处装配)::
|
|
33
|
+
|
|
34
|
+
from mainspring_coding_tools import (
|
|
35
|
+
SafetyPolicy, build_coding_agent, build_coding_tools, default_run_config,
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
policy = SafetyPolicy(Path.cwd())
|
|
39
|
+
agent = build_coding_agent(model, tools=build_coding_tools(policy), policy=policy)
|
|
40
|
+
result = await Runner().run(agent, "把 foo 重命名成 bar 并跑测试", cfg=default_run_config())
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
from __future__ import annotations
|
|
44
|
+
|
|
45
|
+
from pathlib import Path
|
|
46
|
+
|
|
47
|
+
from mainspring.tool import Tool
|
|
48
|
+
|
|
49
|
+
from .cli import CoderREPL, TerminalSink, render_event, render_pending
|
|
50
|
+
from .coding import (
|
|
51
|
+
CODING_AGENT_NAME,
|
|
52
|
+
DEFAULT_INSTRUCTIONS,
|
|
53
|
+
DEFAULT_MAX_TURNS,
|
|
54
|
+
DEFAULT_TOKEN_BUDGET,
|
|
55
|
+
TodoBindingHook,
|
|
56
|
+
TodoBoard,
|
|
57
|
+
TodoItem,
|
|
58
|
+
TodoStatus,
|
|
59
|
+
build_coding_agent,
|
|
60
|
+
build_coding_tools,
|
|
61
|
+
build_todo_tools,
|
|
62
|
+
default_run_config,
|
|
63
|
+
)
|
|
64
|
+
from .files import (
|
|
65
|
+
build_file_tools,
|
|
66
|
+
build_read_file_tools,
|
|
67
|
+
build_write_tools,
|
|
68
|
+
preview_diff_payload,
|
|
69
|
+
)
|
|
70
|
+
from .jobs import JobManager, build_background_tools
|
|
71
|
+
from .payload import PAYLOAD_VERSION
|
|
72
|
+
from .persona import CODING_PERSONA, PERSONA_NAME, PERSONA_VERSION
|
|
73
|
+
from .safety import (
|
|
74
|
+
COMMAND_TOOLS,
|
|
75
|
+
CONTROL_TOOLS,
|
|
76
|
+
ApprovalHook,
|
|
77
|
+
CommandSafetyHook,
|
|
78
|
+
SafetyHook,
|
|
79
|
+
SafetyPolicy,
|
|
80
|
+
SafetyTextGuardrail,
|
|
81
|
+
UnsafeCommand,
|
|
82
|
+
UnsafePath,
|
|
83
|
+
check_command,
|
|
84
|
+
)
|
|
85
|
+
from .search import build_search_tools
|
|
86
|
+
from .shell import CommandEngine, CommandPolicy, LocalEngine, build_shell_tools, run_command
|
|
87
|
+
from .web import (
|
|
88
|
+
DEFAULT_FETCH_MAX_CHARS,
|
|
89
|
+
DEFAULT_SEARCH_BACKEND,
|
|
90
|
+
build_web_tools,
|
|
91
|
+
web_fetch_payload,
|
|
92
|
+
web_search_payload,
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
__all__ = [
|
|
96
|
+
"CODING_AGENT_NAME",
|
|
97
|
+
"CODING_PERSONA",
|
|
98
|
+
"COMMAND_TOOLS",
|
|
99
|
+
"CONTROL_TOOLS",
|
|
100
|
+
"DEFAULT_FETCH_MAX_CHARS",
|
|
101
|
+
"DEFAULT_INSTRUCTIONS",
|
|
102
|
+
"DEFAULT_MAX_TURNS",
|
|
103
|
+
"DEFAULT_SEARCH_BACKEND",
|
|
104
|
+
"DEFAULT_TOKEN_BUDGET",
|
|
105
|
+
"PAYLOAD_VERSION",
|
|
106
|
+
"PERSONA_NAME",
|
|
107
|
+
"PERSONA_VERSION",
|
|
108
|
+
"ApprovalHook",
|
|
109
|
+
"CoderREPL",
|
|
110
|
+
"CommandEngine",
|
|
111
|
+
"CommandPolicy",
|
|
112
|
+
"CommandSafetyHook",
|
|
113
|
+
"JobManager",
|
|
114
|
+
"LocalEngine",
|
|
115
|
+
"SafetyHook",
|
|
116
|
+
"SafetyPolicy",
|
|
117
|
+
"SafetyTextGuardrail",
|
|
118
|
+
"TerminalSink",
|
|
119
|
+
"TodoBindingHook",
|
|
120
|
+
"TodoBoard",
|
|
121
|
+
"TodoItem",
|
|
122
|
+
"TodoStatus",
|
|
123
|
+
"UnsafeCommand",
|
|
124
|
+
"UnsafePath",
|
|
125
|
+
"build_background_tools",
|
|
126
|
+
"build_coding_agent",
|
|
127
|
+
"build_coding_tools",
|
|
128
|
+
"build_file_tools",
|
|
129
|
+
"build_read_file_tools",
|
|
130
|
+
"build_read_tools",
|
|
131
|
+
"build_search_tools",
|
|
132
|
+
"build_shell_tools",
|
|
133
|
+
"build_todo_tools",
|
|
134
|
+
"build_web_tools",
|
|
135
|
+
"build_write_tools",
|
|
136
|
+
"check_command",
|
|
137
|
+
"default_run_config",
|
|
138
|
+
"preview_diff_payload",
|
|
139
|
+
"render_event",
|
|
140
|
+
"render_pending",
|
|
141
|
+
"run_command",
|
|
142
|
+
"web_fetch_payload",
|
|
143
|
+
"web_search_payload",
|
|
144
|
+
]
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def build_read_tools(root: Path | str | SafetyPolicy | None = None) -> list[Tool]:
|
|
148
|
+
"""只读工具组(T10-2):read_file / glob / grep,共用一份 SafetyPolicy。
|
|
149
|
+
|
|
150
|
+
传 SafetyPolicy 时直接复用(写工具、执行工具将共用同一份策略对象);
|
|
151
|
+
传路径或 None 时按该目录 / 当前工作目录构造。装配层只需造一次策略。
|
|
152
|
+
"""
|
|
153
|
+
policy = root if isinstance(root, SafetyPolicy) else SafetyPolicy(Path(root or Path.cwd()))
|
|
154
|
+
return [*build_read_file_tools(policy), *build_search_tools(policy)]
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"""``python -m mainspring_coding_tools`` / ``mainspring-coder`` 的最小安装入口。
|
|
2
|
+
|
|
3
|
+
本包已发 PyPI,安装后必须有可直接执行的入口;但外挂之间禁止互相 import
|
|
4
|
+
(import-linter 的 independence 契约),所以这里只用 core 的内存 store 与
|
|
5
|
+
内置 ``LocalEngine``,不引入 session-sqlite / sandbox 两个外挂。
|
|
6
|
+
|
|
7
|
+
需要「会话持久化 / 断电恢复 / 强隔离沙箱引擎」时,改用仓库内的完整装配件::
|
|
8
|
+
|
|
9
|
+
uv run --no-sync python examples/coding_cli.py --db .mainspring/coder.db --engine subprocess
|
|
10
|
+
|
|
11
|
+
那条路径由应用层注入引擎与 sqlite 后端,能力更全;本入口定位是装完即用的
|
|
12
|
+
零额外依赖 REPL(会话仅存活于本进程)。
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
import argparse
|
|
18
|
+
import asyncio
|
|
19
|
+
import contextlib
|
|
20
|
+
import os
|
|
21
|
+
import sys
|
|
22
|
+
from pathlib import Path
|
|
23
|
+
from typing import Any
|
|
24
|
+
|
|
25
|
+
from mainspring.config import ModelConfig, ModelSettingsConfig, build_model
|
|
26
|
+
from mainspring.runner import Runner
|
|
27
|
+
|
|
28
|
+
from .cli import CoderREPL, TerminalSink
|
|
29
|
+
from .coding import build_coding_agent, build_coding_tools
|
|
30
|
+
from .safety import SafetyPolicy
|
|
31
|
+
from .shell import CommandPolicy, LocalEngine
|
|
32
|
+
|
|
33
|
+
__all__ = ["main"]
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _configure_console() -> None:
|
|
37
|
+
"""Windows 控制台默认 cp936:显式切 UTF-8,避免中文提示 UnicodeEncodeError。"""
|
|
38
|
+
for stream in (sys.stdout, sys.stderr):
|
|
39
|
+
reconfigure = getattr(stream, "reconfigure", None)
|
|
40
|
+
if reconfigure is None:
|
|
41
|
+
continue
|
|
42
|
+
with contextlib.suppress(ValueError, OSError):
|
|
43
|
+
reconfigure(encoding="utf-8", errors="replace")
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def _write(text: str) -> None:
|
|
47
|
+
sys.stdout.write(text)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
async def _read_line(prompt: str) -> str:
|
|
51
|
+
_write(prompt)
|
|
52
|
+
sys.stdout.flush()
|
|
53
|
+
line = await asyncio.to_thread(sys.stdin.readline)
|
|
54
|
+
if line == "":
|
|
55
|
+
raise EOFError
|
|
56
|
+
return str(line).rstrip("\n")
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def main(argv: list[str] | None = None) -> int:
|
|
60
|
+
parser = argparse.ArgumentParser(
|
|
61
|
+
prog="mainspring-coder",
|
|
62
|
+
description="mainspring 编码智能体(零额外依赖入口:内存会话 + LocalEngine)",
|
|
63
|
+
epilog="需要持久化会话或强隔离引擎请用 examples/coding_cli.py(--db / --engine)。",
|
|
64
|
+
)
|
|
65
|
+
parser.add_argument("--root", default=str(Path.cwd()), help="项目根(路径白名单边界)")
|
|
66
|
+
parser.add_argument("--model", default="qwen3:14b", help="模型名(/model 可切换)")
|
|
67
|
+
parser.add_argument(
|
|
68
|
+
"--provider", default=os.environ.get("MAINSPRING_PROVIDER", "ollama"), help="方言名"
|
|
69
|
+
)
|
|
70
|
+
parser.add_argument("--no-ansi", action="store_true", help="关闭颜色转义")
|
|
71
|
+
args = parser.parse_args(argv)
|
|
72
|
+
_configure_console()
|
|
73
|
+
|
|
74
|
+
policy = SafetyPolicy(Path(args.root).resolve())
|
|
75
|
+
engine = LocalEngine()
|
|
76
|
+
engine.check_available()
|
|
77
|
+
tools = build_coding_tools(
|
|
78
|
+
policy,
|
|
79
|
+
engine=engine,
|
|
80
|
+
# 引擎最小环境不继承宿主;透传 PATH 才能找到 python / pytest / git
|
|
81
|
+
command_policy=CommandPolicy(env_allowlist=("PATH",)),
|
|
82
|
+
)
|
|
83
|
+
runner = Runner(sink=TerminalSink(_write, ansi=not args.no_ansi))
|
|
84
|
+
|
|
85
|
+
def agent_for(name: str) -> Any:
|
|
86
|
+
chat = build_model(
|
|
87
|
+
ModelConfig(
|
|
88
|
+
provider=args.provider,
|
|
89
|
+
model=name,
|
|
90
|
+
settings=ModelSettingsConfig(temperature=0.0, max_output_tokens=4096),
|
|
91
|
+
)
|
|
92
|
+
)
|
|
93
|
+
return build_coding_agent(chat, tools, policy)
|
|
94
|
+
|
|
95
|
+
repl = CoderREPL(
|
|
96
|
+
runner=runner,
|
|
97
|
+
agent_for=agent_for,
|
|
98
|
+
model_name=args.model,
|
|
99
|
+
policy=policy,
|
|
100
|
+
write=_write,
|
|
101
|
+
read_line=_read_line,
|
|
102
|
+
ansi=not args.no_ansi,
|
|
103
|
+
)
|
|
104
|
+
try:
|
|
105
|
+
return asyncio.run(repl.run())
|
|
106
|
+
except KeyboardInterrupt:
|
|
107
|
+
sys.stdout.write("\n已中断\n")
|
|
108
|
+
return 130
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
if __name__ == "__main__":
|
|
112
|
+
sys.exit(main())
|