context

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildFullSystemPrompt

func BuildFullSystemPrompt(cfg SystemPromptConfig, tools []provider.ToolDef) string

BuildFullSystemPrompt 使用 SystemPromptConfig 构建完整系统提示词(新接口) 包含多层级 XINCODE.md 发现、完整环境信息

func BuildSystemContext

func BuildSystemContext(cfg SystemPromptConfig) string

BuildSystemContext 构建系统上下文(git status 等) CC 参考:getSystemContext()

func BuildSystemPrompt

func BuildSystemPrompt(tools []provider.ToolDef, projectInstructions string) string

BuildSystemPrompt 构建完整系统提示词(保持旧接口兼容) 结构对标 CC src/constants/prompts.ts 分层:Identity → System → Doing Tasks → Tools → Tone

func BuildUserContext

func BuildUserContext(cfg SystemPromptConfig) string

BuildUserContext 构建用户上下文(注入为首条 user message 的 system-reminder) CC 参考:getUserContext() + prependUserContext()

func FormatMemoryForPrompt

func FormatMemoryForPrompt(files []MemoryFileInfo, projectDir string) string

FormatMemoryForPrompt 将所有发现的文件格式化为系统提示词的一部分 CC 参考:getUserContext() 中 claudeMd 的格式

func GetGitStatus

func GetGitStatus(workDir string) string

GetGitStatus 采集 git 状态,格式对标 CC context.ts 的 getGitStatus() 返回空字符串表示不在 git 仓库中

func IsGitRepo

func IsGitRepo(workDir string) bool

IsGitRepo 快速检测是否在 git 仓库中(不执行多余命令)

Types

type MemoryFileInfo

type MemoryFileInfo struct {
	Path    string     // 绝对路径
	Type    MemoryType // 来源层级
	Content string     // 文件内容(含 @include 展开后)
}

MemoryFileInfo 表示一个已发现的配置/记忆文件

func DiscoverMemoryFiles

func DiscoverMemoryFiles(projectDir, homeDir string) []MemoryFileInfo

DiscoverMemoryFiles 按优先级发现所有配置文件 加载顺序(低 → 高优先级):managed → user → project → rules → local CC 参考:src/utils/claudemd.ts — getClaudeMds()

type MemoryType

type MemoryType string

MemoryType 配置文件来源层级 CC 参考:src/utils/claudemd.ts — MemoryType

const (
	MemoryTypeManaged MemoryType = "managed" // /etc/xincode/XINCODE.md(系统级)
	MemoryTypeUser    MemoryType = "user"    // ~/.xincode/XINCODE.md(用户级)
	MemoryTypeProject MemoryType = "project" // ./XINCODE.md, .xincode/XINCODE.md, .xincode/rules/*.md
	MemoryTypeLocal   MemoryType = "local"   // ./XINCODE.local.md(不提交 git 的个人配置)
	MemoryTypeAutoMem MemoryType = "automem" // ~/.xincode/projects/{hash}/memory/
)

type SystemPromptConfig

type SystemPromptConfig struct {
	WorkDir    string
	HomeDir    string
	Model      string
	Provider   string
	Version    string
	ToolCount  int
	PermMode   string
	MaxContext int
}

SystemPromptConfig 构建系统提示词所需的配置

Jump to

Keyboard shortcuts

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