07. 文件操作对比:Crush vs Kimi Code CLI
7.1 文件读取
Crush view工具
const (
MaxReadSize = 5 * 1024 * 1024 // 5MB
DefaultReadLimit = 2000
MaxLineLength = 2000
)
// 输出格式
" 1: package main\n"
" 2: import \"fmt\"\n"
Kimi Code CLI ReadFile
MAX_LINES = 1000
MAX_LINE_LENGTH = 2000
# 自动检测媒体文件并委托给ReadMediaFile
7.2 文件编辑安全策略
Crush: 文件跟踪
// 必须先读取才能编辑
if !fileTracker.HasRead(path) {
return "You must read the file before editing"
}
// 检查是否被修改
if fileTracker.WasModified(path) {
return "File was modified. Please read it again."
}
Kimi Code CLI: 唯一匹配
# old_str必须唯一
count = content.count(params.old_str)
if count > 1:
return ToolError("Found {count} occurrences. Must be unique.")
7.3 对比总结