reference

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEngineClosed Engine 已关闭
	ErrEngineClosed = errors.New("engine is closed")

	// ErrPromptsFSNotSet 嵌入的提示词文件系统未设置
	ErrPromptsFSNotSet = errors.New("prompts filesystem not set, call SetPromptsFS() first")

	// ErrInvalidOptions 无效的配置选项
	ErrInvalidOptions = errors.New("invalid options")
)

Functions

This section is empty.

Types

type AddRepoOptions

type AddRepoOptions struct {
	Target     string // Git URL 或本地路径
	Local      bool   // 是否为本地仓库
	Name       string // 自定义链接名称
	Branch     string // 指定分支或标签
	Update     bool   // 强制更新已有缓存
	ProjectDir string // 项目目录
}

AddRepoOptions 添加仓库选项

type AddRepoResult

type AddRepoResult struct {
	RefName string
	RefType RefType
}

AddRepoResult 添加仓库结果

type DoctorCheck

type DoctorCheck struct {
	Group   string `json:"group"`
	Name    string `json:"name"`
	Status  string `json:"status"`
	Details string `json:"details"`
}

DoctorCheck 诊断检查项

type DoctorResult

type DoctorResult struct {
	Checks  []DoctorCheck `json:"checks"`
	Summary string        `json:"summary"`
}

DoctorResult 诊断结果

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

Engine reference 库的核心引擎

func New

func New(opts Options) (*Engine, error)

New 创建新的 Engine 实例

func (*Engine) AddRepo

func (e *Engine) AddRepo(ctx context.Context, opts AddRepoOptions) (*AddRepoResult, error)

AddRepo 添加仓库引用

func (*Engine) Close

func (e *Engine) Close() error

Close 关闭 Engine,释放资源

func (*Engine) Doctor

func (e *Engine) Doctor(ctx context.Context, projectDir string) (*DoctorResult, error)

Doctor 诊断并修复引用健康状态

func (*Engine) GetAppConfig

func (e *Engine) GetAppConfig() *models.AppConfig

GetAppConfig 获取应用配置

func (*Engine) GetDB

func (e *Engine) GetDB() *gorm.DB

GetDB 获取数据库连接

func (*Engine) GetLogger

func (e *Engine) GetLogger() *zap.Logger

GetLogger 获取日志记录器

func (*Engine) GetRepoIndexer

func (e *Engine) GetRepoIndexer() *repo.RepoIndexer

GetRepoIndexer 获取仓库索引器(高级用法)

func (*Engine) Inject

func (e *Engine) Inject(ctx context.Context, projectDir string) (string, error)

Inject 生成 reference.map.jsonl 并注入 AI Agent 配置

func (*Engine) ListRepos

func (e *Engine) ListRepos(ctx context.Context, projectDir string) (*ListReposResult, error)

ListRepos 列出项目中的所有引用仓库

func (*Engine) RemoveRepo

func (e *Engine) RemoveRepo(ctx context.Context, opts RemoveRepoOptions) error

RemoveRepo 移除仓库引用

func (*Engine) SCC

func (e *Engine) SCC(repoPath string) (*SCCResult, error)

SCC 运行代码统计

func (*Engine) SetPromptsFS

func (e *Engine) SetPromptsFS(fs interface{ ReadFile(string) ([]byte, error) })

SetPromptsFS 设置嵌入的提示词文件系统

func (*Engine) UpdateRepos

func (e *Engine) UpdateRepos(ctx context.Context, opts UpdateReposOptions) error

UpdateRepos 更新远程仓库缓存

type ListReposResult

type ListReposResult struct {
	Repos []RepoItem `json:"repos"`
}

ListReposResult 列出仓库结果

type Options

type Options struct {
	// AppDir 应用数据目录,默认 ~/.cicbyte/apps/reference
	AppDir string

	// DB 数据库连接,可选。为 nil 时内部自动创建 SQLite 连接
	DB *gorm.DB

	// PromptsFS 嵌入的提示词文件系统,可选。
	// 为 nil 时模板注入功能(Inject)不可用
	PromptsFS fs.FS

	// Logger 日志记录器,可选。为 nil 时使用 nop logger
	Logger *zap.Logger

	// ReposPath 覆盖默认的仓库缓存目录
	// 默认: AppDir/repos
	ReposPath string

	// WikiPath 覆盖默认的知识库目录
	// 默认: AppDir/wiki
	WikiPath string

	// LocalWikiPath 覆盖默认的本地知识库目录
	// 默认: AppDir/localwiki
	LocalWikiPath string

	// Proxy 代理设置,可选
	Proxy ProxyOptions
}

Options Engine 配置选项

func (*Options) Validate

func (o *Options) Validate() error

Validate 验证选项

type ProxyOptions

type ProxyOptions struct {
	// HTTP HTTP/HTTPS 代理地址
	HTTP string

	// Git Git 专用代理,为空则回退使用 HTTP
	Git string
}

ProxyOptions 代理配置

type RefType

type RefType string

RefType 引用类型

const (
	RefTypeRemote RefType = "remote"
	RefTypeLocal  RefType = "local"
)

type RemoveRepoOptions

type RemoveRepoOptions struct {
	Identifier string // 仓库标识符
	Purge      bool   // 同时删除全局缓存
	Clean      bool   // 同时清除 AI 配置和 .reference/ 目录
	Yes        bool   // 跳过确认提示
	All        bool   // 移除全部引用
	ProjectDir string // 项目目录
}

RemoveRepoOptions 移除仓库选项

type RepoInfo

type RepoInfo struct {
	ID        uint      `json:"id"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`

	ProjectDir string  `json:"project_dir"`
	LinkName   string  `json:"link_name"`
	RefType    RefType `json:"ref_type"`

	// 远程仓库字段
	RemoteURL string `json:"remote_url,omitempty"`
	Host      string `json:"host,omitempty"`
	Namespace string `json:"namespace,omitempty"`
	RepoName  string `json:"repo_name,omitempty"`
	CachePath string `json:"cache_path,omitempty"`

	// 本地仓库字段
	LocalPath string `json:"local_path,omitempty"`

	// Wiki 路径
	WikiSubPath string `json:"wiki_sub_path,omitempty"`

	// 引用链接名
	RefName string `json:"ref_name,omitempty"`

	// 元数据
	Branch   string     `json:"branch,omitempty"`
	Commit   string     `json:"commit,omitempty"`
	CommitAt *time.Time `json:"commit_at,omitempty"`
}

RepoInfo 仓库信息

type RepoItem

type RepoItem struct {
	Type      string `json:"type"`
	Name      string `json:"name"`
	Source    string `json:"source"`
	CachePath string `json:"cache_path"`
	CommitAt  string `json:"commit_at"`
	Branch    string `json:"branch"`
}

RepoItem 仓库列表项

type SCCFileStat

type SCCFileStat struct {
	Type     string `json:"type"`
	File     string `json:"file"`
	Language string `json:"language"`
	Code     int    `json:"code"`
	Complex  int    `json:"complexity"`
}

SCCFileStat 文件统计

type SCCLangStat

type SCCLangStat struct {
	Type    string `json:"type"`
	Name    string `json:"name"`
	Count   int    `json:"count"`
	Code    int    `json:"code"`
	Complex int    `json:"complexity"`
}

SCCLangStat 语言统计

type SCCResult

type SCCResult struct {
	Repo     string        `json:"repo"`
	Path     string        `json:"path"`
	Langs    []SCCLangStat `json:"languages"`
	TopFiles []SCCFileStat `json:"topFiles"`
}

SCCResult 代码统计结果

type UpdateReposOptions

type UpdateReposOptions struct {
	Identifier string // 仓库标识符,为空则更新全部
	ProjectDir string // 项目目录
}

UpdateReposOptions 更新仓库选项

Jump to

Keyboard shortcuts

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