project

package
v0.6.1-rc.1 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

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

Constants

This section is empty.

Variables

View Source
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 Directory

func Directory(ctx context.Context, fallback string) string

Directory returns the active tool cwd, falling back when no instance is bound.

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 Commands

type Commands struct {
	Start *string `json:"start,omitempty"`
}

type Discoverer

type Discoverer interface {
	FromDirectory(ctx context.Context, directory string) (Info, string, error)
}

type DiscovererFunc

type DiscovererFunc func(context.Context, string) (Info, string, error)

func (DiscovererFunc) FromDirectory

func (f DiscovererFunc) FromDirectory(ctx context.Context, directory string) (Info, string, error)

type ID

type ID string
const GlobalID ID = "global"

type Icon

type Icon struct {
	URL      *string `json:"url,omitempty"`
	Override *string `json:"override,omitempty"`
	Color    *string `json:"color,omitempty"`
}

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.

func Discover

func Discover(ctx context.Context, directory string) (Info, string, error)

Discover resolves the project for directory: inside a git repository it yields the worktree and a stable project id, elsewhere the global project.

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.

func Require

func Require(ctx context.Context) (InstanceContext, error)

type LoadInput

type LoadInput struct {
	Directory string
	Worktree  string
	Project   *Info
}

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()

func (*Store) Load

func (s *Store) Load(ctx context.Context, input LoadInput) (InstanceContext, error)

func (*Store) Provide

func (s *Store) Provide(ctx context.Context, input LoadInput, fn func(context.Context) error) error

func (*Store) Reload

func (s *Store) Reload(ctx context.Context, input LoadInput) (InstanceContext, error)

type Time

type Time struct {
	Created     int64  `json:"created"`
	Updated     int64  `json:"updated"`
	Initialized *int64 `json:"initialized,omitempty"`
}

Jump to

Keyboard shortcuts

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