file

package
v0.8.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package file provides file ops tool calls

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendEditContext

func AppendEditContext(path string, startLine, endLine, oldReplaced, newLineCount int) string

AppendEditContext 生成行范围编辑后的上下文窗口。

startLine/endLine 是原编辑范围的 1-based 包含行号; oldReplaced 是被替换的原始行数(endLine - startLine + 1); newLineCount 是替换后的新行数。

参考 ds4 agent_edit_result_append_context 的设计:

  • 编辑前 5 行 + 编辑后 8 行非对称窗口(下游更重要)
  • 编辑块 ≤36 行全量显示,>36 行首尾各 18 行截断
  • 行偏移警告(行数变化时)

func AppendWriteFileContext

func AppendWriteFileContext(path string) string

AppendWriteFileContext 生成全文件写入后的上下文窗口。

小文件(≤36 行)全量展示;大文件首尾各 18 行。

func DisplayPath added in v0.8.6

func DisplayPath(ctx context.Context, path string) string

DisplayPath 返回适合显示的文件路径(相对于项目根目录)。 如果 path 在项目根目录下,返回相对路径;否则返回原始 path。 projectRoot 为空时也返回原始 path。

func ExpandFilePattern

func ExpandFilePattern(pattern string) ([]string, error)

ExpandFilePattern 扩展文件模式

func ParseLineRange

func ParseLineRange(args ToolArgs) (int, int, error)

func ResolvePath

func ResolvePath(ctx context.Context, path string) string

ResolvePath 解析文件路径:

  1. 如果是 "~" 开头(如 ~/.dscli/skills/...),展开为用户主目录
  2. 如果是绝对路径,直接使用
  3. 否则是相对路径,拼接项目根目录

Types

type SearchConfig

type SearchConfig struct {
	MaxDepth        int      // 最大递归深度
	ExcludeDirs     []string // 排除目录列表
	ExcludePatterns []string // 排除模式列表
}

SearchConfig 搜索配置

type ToolArgs

type ToolArgs = toolcall.ToolArgs

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL