resolve

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMaxDepth     = 10
	DefaultMaxResources = 50
)

Variables

This section is empty.

Functions

func ParseProfileID added in v0.31.0

func ParseProfileID(data []byte) (string, error)

ParseProfileID extracts and validates the profile id from YAML content.

func ResolveRelativeURL added in v0.15.0

func ResolveRelativeURL(parentURL, relRef string) (string, error)

ResolveRelativeURL resolves a relative reference against a parent URL using RFC 3986 semantics. Absolute URLs are returned unchanged. The caller must validate the resolved URL against allowed prefixes.

func ValidIdentifier added in v0.31.0

func ValidIdentifier(s string) bool

ValidIdentifier reports whether s is a safe identifier for use in CLI arguments and gateway operations: starts with an alphanumeric, then alphanumerics, underscores, or hyphens.

func WarnLiteralCredentials added in v0.31.0

func WarnLiteralCredentials(providerName string, creds map[string]string) string

WarnLiteralCredentials returns a warning string if any credential value does not look like a ${VAR} reference. Returns empty string if all OK.

Types

type Dependency

type Dependency struct {
	Field     string
	URL       string
	LocalPath string
	SHA256    string
	FetchedAt time.Time
	CacheHit  bool
	Type      string // "file" or "directory"
	Warning   string // non-fatal warning about this dependency
}

Dependency records a single URL that was resolved to a local cache path.

type ProfileYAML added in v0.31.0

type ProfileYAML struct {
	ID string `yaml:"id"`
}

ProfileYAML is the subset of an openshell profile definition needed for validation. The full profile schema is openshell's concern.

type ResolveOpts

type ResolveOpts struct {
	WorkspaceRoot string
	FetchPolicy   fetch.FetchPolicy
	TraceID       string
	AuditLogPath  string

	// TreeFetcher fetches all files under a path in a remote repository.
	// When nil, defaults to gitfetch.FetchTree (git sparse checkout).
	TreeFetcher gitfetch.TreeFetchFunc

	// GitToken is an optional token for authenticating git fetches.
	// Empty means unauthenticated (sufficient for public repos).
	GitToken string

	// MaxDepth controls transitive dependency resolution depth.
	// 0 disables transitive resolution (Phase 1 behavior).
	// <0 uses DefaultMaxDepth (10).
	//
	// MaxResources uses different semantics: <=0 always uses
	// DefaultMaxResources (50). The asymmetry exists because MaxDepth=0
	// is a meaningful "disable" value, while MaxResources=0 ("allow zero
	// resources") would prevent even non-transitive URL resolution.
	MaxDepth     int
	MaxResources int
}

ResolveOpts controls how URL-referenced resources are resolved.

type ResolveResult added in v0.31.0

type ResolveResult struct {
	Deps      []Dependency
	Profiles  []ResolvedProfile
	Providers []ResolvedProvider
}

ResolveResult contains all outputs from harness resolution.

func ResolveHarness

func ResolveHarness(ctx context.Context, h *harness.Harness, opts ResolveOpts) (ResolveResult, error)

ResolveHarness resolves URL-referenced declarative fields (Agent, Policy, Skills, Profiles, Providers) in the harness to local cache paths. Local paths are left unchanged. The harness is modified in place: URL fields are replaced with cache paths, and h.Skills may grow to include transitively resolved skill dependencies. Returns a ResolveResult containing all resolved dependencies, profiles, and providers.

Skills are directories: when a skill field is a URL, the resolver uses git sparse checkout (via TreeFetcher / gitfetch.FetchTree) to fetch the directory tree and cache it locally. Only URLs pointing to supported forges (github.com) are accepted for skills. Agents and policies remain single files.

Profiles and Providers: URL-referenced entries are fetched, validated, and returned in the result. URL-based providers are removed from h.Providers, leaving only local provider names.

Skills with dependencies: frontmatter are recursively resolved up to MaxDepth levels. Diamond dependencies are deduplicated; cycles are rejected. Set MaxDepth to 0 to disable transitive resolution. Negative values use DefaultMaxDepth (10).

Trusting a skill means trusting its entire transitive dependency closure: a skill's frontmatter can declare relative references that resolve to different paths on the same allowed domain. All transitive deps are still validated against allowed_remote_resources and SHA256 integrity hashes.

The default limits (depth=10, resources=50) bound worst-case resolution. CI environments with untrusted harnesses should set tighter limits. See ADR-0038 for the security model and trust semantics.

type ResolvedProfile added in v0.31.0

type ResolvedProfile struct {
	ID        string
	LocalPath string
}

ResolvedProfile is a profile definition fetched from a URL and validated to have a non-empty id field.

type ResolvedProvider added in v0.31.0

type ResolvedProvider struct {
	Def       harness.ProviderDef
	LocalPath string
}

ResolvedProvider is a provider definition fetched from a URL.

Jump to

Keyboard shortcuts

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