Documentation
¶
Overview ¶
Ports packages/coding-agent/src/core/package-manager.ts.
Package packagecontent discovers resources exposed by Pi packages and cross-harness plugin manifests.
Index ¶
- func ApplyConfiguredDelta(kind Kind, relativePaths, basePatterns, deltaPatterns []string) ([]string, error)
- func ApplyPatterns(allPaths, patterns []string, baseDir string, kind Kind) []string
- func Collect(paths []string, kind Kind) []string
- func Deduplicate(values []string) []string
- func DiscoverAgentSkillDirs(dir string) []string
- func DiscoverAutomatic(dir string, kind Kind) []string
- func DiscoverSkillDirs(dir string) []string
- func EnabledByOverrides(resourcePath string, patterns []string, baseDir string, kind Kind) bool
- func FilterAutomatic(paths, overrides []string, baseDir string, kind Kind) []string
- func FindMember(resources Resources, kind Kind, name string) (string, error)
- func FindSourceMember(root string, kind Kind, name string) (string, error)
- func HasPiManifest(root string) bool
- func InspectConfigured(root string, filters map[Kind][]string) (Resources, []MissingMember, error)
- func InspectConfiguredWithResolver(root string, filters map[Kind][]string, resolve extsource.ResolveFunc) (Resources, []MissingMember, error)
- func PublicName(kind Kind, resourcePath, packageName string) (string, error)
- func ResolveConfigured(entries []string, baseDir string, kind Kind) []string
- func ResolveConfiguredWithError(entries []string, baseDir string, kind Kind) ([]string, error)
- func ResourceEnabled(relativePath string, patterns []string) bool
- func SkillFile(resourcePath string) string
- func SplitPatterns(entries []string) (plain, patterns []string)
- func ValidateConfiguredEntries(entries []string, baseDir string) error
- func ValidateConfiguredForStartup(root string, filters map[Kind][]string) (Resources, []MissingMember, []ExtensionIssue, error)
- func ValidateConfiguredForStartupWithResolver(root string, filters map[Kind][]string, resolve extsource.ResolveFunc) (Resources, []MissingMember, []ExtensionIssue, error)
- func ValidateMember(root string, kind Kind, resourcePath string) error
- func ValidatePackageManifestSyntax(data []byte) error
- type ExtensionIssue
- type Kind
- type MissingMember
- type PatternState
- type PiManifest
- type ResourceState
- type Resources
- func Discover(root string) (Resources, error)
- func Validate(root string) (Resources, error)
- func ValidateConfigured(root string, filters map[Kind][]string) (Resources, error)
- func ValidatePackage(root string) (Resources, error)
- func ValidatePackageManifest(root string, data []byte) (Resources, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyConfiguredDelta ¶
func ApplyConfiguredDelta(kind Kind, relativePaths, basePatterns, deltaPatterns []string) ([]string, error)
ApplyConfiguredDelta validates and resolves exact Package-relative selector overrides. Authored autoload-disabled filters use ApplyAutoloadDisabledPatterns.
func ApplyPatterns ¶
ApplyPatterns applies allowlist, exclude, force-include, and force-exclude patterns without changing input order.
func Deduplicate ¶
Deduplicate removes empty and repeated strings without changing order.
func DiscoverAgentSkillDirs ¶
DiscoverAgentSkillDirs applies the cross-agent `.agents/skills` convention: root Markdown files are documentation, while nested Markdown files are standalone skills.
func DiscoverAutomatic ¶
DiscoverAutomatic returns resources in one conventional resource directory.
func DiscoverSkillDirs ¶
DiscoverSkillDirs recursively discovers skill roots and root-level Markdown skills. A directory containing SKILL.md is one skill and is not traversed further. Symlinked files and directories are followed, while hidden entries, node_modules, and paths excluded by .gitignore, .ignore, or .fdignore are skipped.
func EnabledByOverrides ¶
EnabledByOverrides reports whether one automatically discovered path remains active after configured overrides.
func FilterAutomatic ¶
FilterAutomatic applies configured overrides to automatically discovered paths.
func FindMember ¶
FindMember selects one discovered resource by public kind/name identity. pig additive (D18): named Piglet Package origins require stable member identity across exact and conventional Package resources. Extension source paths and Skill frontmatter are authoritative.
func FindSourceMember ¶
source may itself be one resource or a package/plugin root containing it.
func HasPiManifest ¶
HasPiManifest reports whether root's package.json has a "pi" object, which makes upstream resolve root as a Package (readPiManifest).
func InspectConfigured ¶
InspectConfigured returns the discovery inventory, including safe declarations whose files are missing. It uses discovery's tolerant manifest parsing and validates lexical, absolute-path, glob, and symlink boundaries. Missing declarations are data so pig config can disable them; ValidateConfigured remains strict for explicit validation.
func InspectConfiguredWithResolver ¶
func InspectConfiguredWithResolver(root string, filters map[Kind][]string, resolve extsource.ResolveFunc) (Resources, []MissingMember, error)
InspectConfiguredWithResolver returns the configured inventory while using resolve for extension validation. It preserves InspectConfigured semantics while allowing startup to reuse its source-resolution snapshot.
func PublicName ¶
PublicName returns the stable kind/name identity for one Package resource. PackageName supplies the fallback identity for a root Dev Container.
func ResolveConfigured ¶
ResolveConfigured expands configured paths and applies their include/exclude patterns relative to baseDir. It returns nil if a path cannot be resolved. Use ResolveConfiguredWithError when resolution errors must be surfaced.
func ResolveConfiguredWithError ¶
ResolveConfiguredWithError expands configured paths and applies their include/exclude patterns relative to baseDir. Invalid file URLs return Node's error, as Pi's resolveLocalEntries does.
func ResourceEnabled ¶
ResourceEnabled applies the shared include, exclude, exact force-include, and exact force-exclude rules to one package-relative resource path. A nil filter enables the resource; an explicit empty filter disables it.
func SkillFile ¶
SkillFile returns the Markdown file that defines the skill at resourcePath: resourcePath itself when it is a file, as a declared SKILL.md or a root-level Markdown skill is, else the SKILL.md inside the skill directory.
func SplitPatterns ¶
SplitPatterns separates literal entries from glob and override entries.
func ValidateConfiguredEntries ¶
ValidateConfiguredEntries resolves the plain entries of a settings resource array without reading the filesystem and returns the first resolution error.
func ValidateConfiguredForStartup ¶
func ValidateConfiguredForStartup(root string, filters map[Kind][]string) (Resources, []MissingMember, []ExtensionIssue, error)
ValidateConfiguredForStartup uses discovery's tolerant manifest parsing, then checks the enabled resources. Invalid JSON falls back to conventions and malformed Pi fields declare no members, without a diagnostic. Missing declarations and unresolvable extensions are returned separately so callers can continue loading other resources. Each enabled extension resolves once.
func ValidateConfiguredForStartupWithResolver ¶
func ValidateConfiguredForStartupWithResolver(root string, filters map[Kind][]string, resolve extsource.ResolveFunc) (Resources, []MissingMember, []ExtensionIssue, error)
ValidateConfiguredForStartupWithResolver applies startup validation using resolve for extension source classification. A startup-owned resolver can therefore share the exact Definition or error with later loading.
func ValidateMember ¶
ValidateMember validates one explicitly selected Package member.
func ValidatePackageManifestSyntax ¶
ValidatePackageManifestSyntax checks the typed Package manifest boundary without resolving members. It is used before authoring edits so malformed existing fields are never silently discarded or rewritten.
Types ¶
type ExtensionIssue ¶
ExtensionIssue is one enabled Package extension whose source does not resolve to a loadable extension.
type MissingMember ¶
MissingMember is one safe authored Package declaration that currently resolves to no file. Configuration UIs use it to recover by disabling the normal Package filter without treating the declaration as a runtime resource.
type PatternState ¶
PatternState retains the first-match insertion order of upstream's path-to-enabled Map.
func ApplyAutoloadDisabledPatterns ¶
func ApplyAutoloadDisabledPatterns(allPaths, patterns []string, baseDir string, kind Kind) []PatternState
ApplyAutoloadDisabledPatterns returns only paths touched by a pattern, with later patterns replacing their state. Plus/minus match exact paths; other entries use glob matching.
type PiManifest ¶
PiManifest mirrors upstream pi-manifest.ts PiManifest: the resource lists a package.json "pi" object declares. A nil field was absent or malformed.
func ReadPiManifest ¶
func ReadPiManifest(packageJSONPath string) *PiManifest
ReadPiManifest mirrors upstream readPiManifest. It returns nil when the file cannot be read or parsed, or when the package or its "pi" value is not a JSON object. A resource field is kept only when it is an array of strings.
type ResourceState ¶
ResourceState is a resource path and whether the configured patterns enable it.
func AutomaticStates ¶
func AutomaticStates(paths, overrides []string, baseDir string, kind Kind) []ResourceState
AutomaticStates lists automatically discovered paths with whether the overrides leave each enabled (package-manager.ts addAutoDiscoveredResources).
func ResolveConfiguredStates ¶
func ResolveConfiguredStates(entries []string, baseDir string, kind Kind) []ResourceState
ResolveConfiguredStates lists every resource the plain entries resolve, in collection order, with whether the patterns keep it (package-manager.ts resolveLocalEntries adds all files, then marks those the patterns enable).
type Resources ¶
type Resources struct {
PackageName string
PromptFiles []string
ThemeFiles []string
SkillDirs []string
ExtensionEntries []string
AgentFiles []string
MCPFiles []string
HookFiles []string
AgentEnvironments []string
}
Resources is the resource inventory discovered from one materialized source root.
func Discover ¶
Discover returns the package and plugin resources exposed by root. A Pi package.json supplies every Pi resource kind when it has a pi block; plugin metadata supplies Pi kinds only without that block. Missing or malformed manifests fall back to conventional directory discovery.
func Validate ¶
Validate checks a source inventory and its portable local file closure. A source without package.json remains valid for direct-resource installation.
func ValidateConfigured ¶
ValidateConfigured validates only resources enabled by installed Package filters. Authored Package validation remains strict through ValidatePackage.
func ValidatePackage ¶
ValidatePackage checks a Package manifest, inventory, public identities, and portable local closure. Unlike Validate, package.json and its name are required.
func ValidatePackageManifest ¶
ValidatePackageManifest validates prospective package.json data without writing it. Package authoring uses this before atomically replacing a manifest so a failed operation cannot leave invalid state behind.