Documentation
¶
Overview ¶
Package rules 提供规则管理系统 支持 Global(全局)和 Project(项目)两个级别的规则
Index ¶
- type Loader
- type Manager
- func (m *Manager) AddGlobalRule(rule *Rule)
- func (m *Manager) AddProjectRule(projectID string, rule *Rule)
- func (m *Manager) GetRulesContent(projectID string) string
- func (m *Manager) GetRulesForProject(projectID string) []*Rule
- func (m *Manager) LoadGlobalRules(ctx context.Context) error
- func (m *Manager) LoadProjectRules(ctx context.Context, projectID string) error
- func (m *Manager) RegisterLoader(loader Loader)
- type ManagerConfig
- type Rule
- type RuleSet
- type Scope
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Loader ¶
type Loader interface {
// LoadGlobalRules 加载全局规则
LoadGlobalRules(ctx context.Context) ([]*Rule, error)
// LoadProjectRules 加载项目规则
LoadProjectRules(ctx context.Context, projectID string) ([]*Rule, error)
}
Loader 规则加载器接口
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager 规则管理器
func (*Manager) AddProjectRule ¶
AddProjectRule 添加项目规则
func (*Manager) GetRulesContent ¶
GetRulesContent 获取规则内容(用于 AI 上下文注入)
func (*Manager) GetRulesForProject ¶
GetRulesForProject 获取项目的所有规则
func (*Manager) LoadGlobalRules ¶
LoadGlobalRules 加载全局规则
func (*Manager) LoadProjectRules ¶
LoadProjectRules 加载项目规则
func (*Manager) RegisterLoader ¶
RegisterLoader 注册规则加载器
type ManagerConfig ¶
type ManagerConfig struct {
// GlobalRulesPath 全局规则文件路径
GlobalRulesPath string
// ProjectBasePath 项目基础路径
ProjectBasePath string
// ProjectRuleFile 项目规则文件名(默认 AGENTS.md)
ProjectRuleFile string
// AutoReload 是否自动重新加载
AutoReload bool
}
ManagerConfig 管理器配置
type Rule ¶
type Rule struct {
// ID 规则 ID
ID string `json:"id"`
// Scope 作用域
Scope Scope `json:"scope"`
// Title 标题
Title string `json:"title"`
// Content 规则内容
Content string `json:"content"`
// Source 来源(AGENTS.md, user_config, system)
Source string `json:"source"`
// SourcePath 来源路径(如文件路径)
SourcePath string `json:"source_path,omitempty"`
// Priority 优先级(数字越大优先级越高)
Priority int `json:"priority"`
// Enabled 是否启用
Enabled bool `json:"enabled"`
// Tags 标签
Tags []string `json:"tags,omitempty"`
// Metadata 元数据
Metadata map[string]any `json:"metadata,omitempty"`
// CreatedAt 创建时间
CreatedAt time.Time `json:"created_at"`
// UpdatedAt 更新时间
UpdatedAt time.Time `json:"updated_at"`
}
Rule 规则
type RuleSet ¶
type RuleSet struct {
// GlobalRules 全局规则
GlobalRules []*Rule `json:"global_rules"`
// ProjectRules 项目规则(key: projectID)
ProjectRules map[string][]*Rule `json:"project_rules"`
}
RuleSet 规则集
func (*RuleSet) AddProjectRule ¶
AddProjectRule 添加项目规则
func (*RuleSet) GetRulesContent ¶
GetRulesContent 获取规则内容(用于注入 AI 上下文)
func (*RuleSet) GetRulesForProject ¶
GetRulesForProject 获取项目的所有规则(包含全局规则)
Click to show internal directories.
Click to hide internal directories.