Documentation
¶
Overview ¶
Package project resolves the directory and project a tool call runs against. The instance travels on context.Context so concurrent scheduler leaves cannot bleed working directories into one another.
Index ¶
- Variables
- func ContainsPath(path string, instance InstanceContext) bool
- func Directory(ctx context.Context, fallback string) string
- func Provide[T any](ctx context.Context, instance InstanceContext, ...) (T, error)
- func RedirectIntoDirectory(path string, instance InstanceContext) string
- func WithContext(ctx context.Context, instance InstanceContext) context.Context
- type Bootstrap
- type BootstrapFunc
- type Commands
- type Discoverer
- type DiscovererFunc
- type ID
- type Icon
- type Info
- type InstanceContext
- type LoadInput
- type Store
- func (s *Store) Dispose(instance InstanceContext)
- func (s *Store) DisposeAll()
- func (s *Store) Load(ctx context.Context, input LoadInput) (InstanceContext, error)
- func (s *Store) Provide(ctx context.Context, input LoadInput, fn func(context.Context) error) error
- func (s *Store) Reload(ctx context.Context, input LoadInput) (InstanceContext, error)
- type Time
Constants ¶
This section is empty.
Variables ¶
var ErrNoInstance = errors.New("project: no instance in context")
Functions ¶
func ContainsPath ¶
func ContainsPath(path string, instance InstanceContext) bool
ContainsPath reports whether path is inside the instance directory or its worktree; a non-git worktree of "/" does not count as containing anything.
func Provide ¶
func Provide[T any](ctx context.Context, instance InstanceContext, fn func(context.Context) (T, error)) (T, error)
Provide invokes fn with an instance-bound context.
func RedirectIntoDirectory ¶
func RedirectIntoDirectory(path string, instance InstanceContext) string
RedirectIntoDirectory remaps an absolute original-worktree path into the active isolated directory.
func WithContext ¶
func WithContext(ctx context.Context, instance InstanceContext) context.Context
WithContext binds an instance to ctx. The value is immutable by convention.
Types ¶
type Bootstrap ¶
type Bootstrap interface {
Run(ctx context.Context, instance InstanceContext) error
}
type BootstrapFunc ¶
type BootstrapFunc func(context.Context, InstanceContext) error
func (BootstrapFunc) Run ¶
func (f BootstrapFunc) Run(ctx context.Context, instance InstanceContext) error
type Discoverer ¶
type DiscovererFunc ¶
func (DiscovererFunc) FromDirectory ¶
type Info ¶
type Info struct {
ID ID `json:"id"`
Worktree string `json:"worktree"`
VCS *string `json:"vcs,omitempty"`
Name *string `json:"name,omitempty"`
Icon *Icon `json:"icon,omitempty"`
Commands *Commands `json:"commands,omitempty"`
Time Time `json:"time"`
Sandboxes []string `json:"sandboxes"`
}
Info is the public project record.
type InstanceContext ¶
type InstanceContext struct {
Directory string `json:"directory"`
Worktree string `json:"worktree"`
Project Info `json:"project"`
}
InstanceContext is the execution boundary a tool call resolves paths against: which directory it runs in, and which project that is.
func FromContext ¶
func FromContext(ctx context.Context) (InstanceContext, bool)
FromContext returns the bound instance.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store caches one booted instance per resolved active directory.
func NewStore ¶
func NewStore(discover Discoverer, bootstrap Bootstrap) *Store
func (*Store) Dispose ¶
func (s *Store) Dispose(instance InstanceContext)
func (*Store) DisposeAll ¶
func (s *Store) DisposeAll()