SIGN IN SIGN UP

feat(pi-coding-agent): 编码工具集 + SDK 封装(core/,不含 TUI)

pi-coding-agent 基线落地。对应上游 packages/coding-agent/src/core/,
有意偏离:不复刻 TUI(modes/interactive/)、CLI 入口(cli.ts/main.ts)。

truncate.py(截断工具):
- truncate_head(头部保留,read/find/grep/ls 用)
- truncate_tail(尾部保留,bash 用)
- truncate_line(单行截断,grep 用)
- DEFAULT_MAX_LINES=2000 / DEFAULT_MAX_BYTES=50KB / GREP_MAX_LINE_LENGTH=500

tools.py(7 个编码工具,各实现 AgentTool 协议):
- bash:asyncio 子进程执行,进程树 kill,尾部截断+全文落盘
- read:文本+图像,offset/limit 分页,头部截断
- edit:精确文本替换,唯一性校验,per-path asyncio.Lock 串行化
- write:写文件,自动创建父目录
- grep:纯 Python regex 搜索(不依赖 ripgrep),glob 过滤,gitignore
- find:glob 模式查找文件
- ls:目录列表,目录加 trailing slash
- create_coding_tools / create_read_only_tools / create_all_tools 工厂

sdk.py(SDK 封装):
- CodingAgent:组合 pi-agent-core Agent + 编码工具 + 默认 system prompt
- prompt/continue_/steer/follow_up/abort/wait_for_idle/reset
- create_agent_session 工厂入口(精简版 createAgentSession)

真实 LLM 集成测试(DeepSeek)全部通过:
- read:读取文件报告内容 ✓
- write:创建 hello.py ✓
- edit:修改 config.py(DEBUG=False→True)✓
- ls/bash:列出目录识别 Python 文件 ✓

验证:175 测试通过(32 工具 + 4 集成 + 其他),mypy strict / ruff 全绿。
J
Justin Gao committed
41e96a7cdb2693b433ed913a85c8e901416b64e7
Parent: 812d215