Documentation
¶
Overview ¶
Package resource implements @-prefixed resource discovery and inline resolution. When a user types "@path/to/file" or "@sess:id" in a prompt, the reference is resolved to its content before the LLM sees it.
Resolvers are composable — add a new resolver by implementing the Resolver interface and registering it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type FileResolver ¶
type FileResolver struct {
// contains filtered or unexported fields
}
FileResolver resolves @path/to/file references by glob-matching against a root directory.
func NewFileResolver ¶
func NewFileResolver(root string) *FileResolver
NewFileResolver creates a file resolver rooted at the given directory.
func (*FileResolver) Prefix ¶
func (f *FileResolver) Prefix() string
type Ref ¶
type Ref struct {
Start int // Byte offset of "@"
End int // Byte offset after the last character of the reference
Raw string // Full matched string including "@"
Path string // Content after "@" (e.g. "src/main.go")
}
Ref represents a single @reference found in text.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds all available resource resolvers.
func NewRegistry ¶
NewRegistry creates a resource registry with the given resolvers.
type Resolver ¶
type Resolver interface {
// Prefix is the resource prefix (e.g. "sess:" for @sess:...).
// Empty string means the resolver handles bare @references (like files).
Prefix() string
// Search finds resources matching the query. Called for autocomplete.
Search(ctx context.Context, query string, limit int) ([]Resource, error)
// Load retrieves the full content of a resource by its full ID (e.g. "@src/main.go").
Load(ctx context.Context, id string) (string, error)
}
A Resolver discovers and loads resources by type.
type Resource ¶
type Resource struct {
ID string `json:"id"` // Full @ reference (e.g. "@src/main.go")
Type string `json:"type"` // "file", "session", "skill"
Label string `json:"label"` // Display label (e.g. "src/main.go")
Detail string `json:"detail"` // One-line description (e.g. "Go source, 142 lines")
Content string `json:"-"` // Full content (not sent in search results)
}
Resource is a discovered resource returned by a Resolver.
type SessionResolver ¶
type SessionResolver struct {
// contains filtered or unexported fields
}
SessionResolver resolves @sess:id references from a session store.
func NewSessionResolver ¶
func NewSessionResolver(sessionDir string) *SessionResolver
NewSessionResolver creates a session resolver.
func (*SessionResolver) Prefix ¶
func (s *SessionResolver) Prefix() string