packagecontent

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: MIT Imports: 13 Imported by: 1

Documentation

Overview

Package packagecontent discovers resources exposed by Pi packages and cross-harness plugin manifests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyConfiguredDelta

func ApplyConfiguredDelta(kind Kind, relativePaths, basePatterns, deltaPatterns []string) ([]string, error)

ApplyConfiguredDelta resolves a project Package override against an inherited Package filter. Project overrides contain only exact +/- member paths; they do not autoload a second Package or alter unrelated inherited members.

func ApplyPatterns

func ApplyPatterns(allPaths, patterns []string, baseDir string, kind Kind) []string

ApplyPatterns applies allowlist, exclude, force-include, and force-exclude patterns without changing input order.

func Collect

func Collect(paths []string, kind Kind) []string

Collect expands files or conventional resource directories for kind.

func Deduplicate

func Deduplicate(values []string) []string

Deduplicate removes empty and repeated strings without changing order.

func DiscoverAgentSkillDirs

func DiscoverAgentSkillDirs(dir string) []string

DiscoverAgentSkillDirs applies the cross-agent `.agents/skills` convention: root Markdown files are documentation, while nested Markdown files are standalone skills.

func DiscoverAutomatic

func DiscoverAutomatic(dir string, kind Kind) []string

DiscoverAutomatic returns resources in one conventional resource directory.

func DiscoverSkillDirs

func DiscoverSkillDirs(dir string) []string

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

func EnabledByOverrides(resourcePath string, patterns []string, baseDir string, kind Kind) bool

EnabledByOverrides reports whether one automatically discovered path remains active after configured overrides.

func FilterAutomatic

func FilterAutomatic(paths, overrides []string, baseDir string, kind Kind) []string

FilterAutomatic applies configured overrides to automatically discovered paths.

func FindMember

func FindMember(resources Resources, kind Kind, name string) (string, error)

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

func FindSourceMember(root string, kind Kind, name string) (string, error)

source may itself be one resource or a package/plugin root containing it.

func InspectConfigured

func InspectConfigured(root string, filters map[Kind][]string) (Resources, []MissingMember, error)

InspectConfigured returns the authored configuration inventory, including safe declarations whose files are missing. It validates the same lexical, absolute-path, glob, and symlink boundaries as startup. Missing declarations are data here so pig config can disable them; ValidateConfigured still rejects every enabled missing declaration.

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

func PublicName(kind Kind, resourcePath, packageName string) (string, error)

PublicName returns the stable kind/name identity for one Package resource. PackageName supplies the fallback identity for a root Dev Container.

func ResolveConfigured

func ResolveConfigured(entries []string, baseDir string, kind Kind) []string

ResolveConfigured expands configured paths and applies their include/exclude patterns relative to baseDir.

func ResourceEnabled

func ResourceEnabled(relativePath string, patterns []string) bool

ResourceEnabled applies one PackageSource resource filter to a relative path.

func SplitPatterns

func SplitPatterns(entries []string) (plain, patterns []string)

SplitPatterns separates literal entries from glob and override entries.

func ValidateConfiguredForStartup

func ValidateConfiguredForStartup(root string, filters map[Kind][]string) (Resources, []MissingMember, []ExtensionIssue, error)

ValidateConfiguredForStartup applies ValidateConfigured's checks for session startup with two differences. When enabled declarations are missing, it returns them with no error and no resources, so the caller can name the member to disable. An enabled extension whose source does not resolve is returned as an ExtensionIssue, every one of them, and removed from the resources instead of failing the Package; upstream loadExtensions likewise records each failing extension and continues with the rest. Every other failure still fails the Package. 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

func ValidateMember(root string, kind Kind, resourcePath string) error

ValidateMember validates one explicitly selected Package member.

func ValidatePackageManifestSyntax

func ValidatePackageManifestSyntax(data []byte) error

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

type ExtensionIssue struct {
	Path string
	Err  error
}

ExtensionIssue is one enabled Package extension whose source does not resolve to a loadable extension.

type Kind

type Kind string

Kind identifies a discoverable package resource class.

const (
	Extensions        Kind = "extensions"
	Skills            Kind = "skills"
	Prompts           Kind = "prompts"
	Themes            Kind = "themes"
	Agents            Kind = "agents"
	MCP               Kind = "mcp"
	Hooks             Kind = "hooks"
	AgentEnvironments Kind = "agent-environments"
)

type MissingMember

type MissingMember struct {
	Kind    Kind
	Path    string
	Pattern string
	Enabled bool
}

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 PiManifest

type PiManifest struct {
	Extensions []string
	Skills     []string
	Prompts    []string
	Themes     []string
}

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

func Discover(root string) (Resources, error)

Discover returns the package and plugin resources exposed by root. A Pi package.json declaration wins for Pi resource kinds; plugin metadata fills kinds the Pi manifest does not declare. Missing or malformed manifests fall back to conventional directory discovery, matching package installation.

func Validate

func Validate(root string) (Resources, error)

Validate checks a source inventory and its portable local file closure. A source without package.json remains valid for direct-resource installation.

func ValidateConfigured

func ValidateConfigured(root string, filters map[Kind][]string) (Resources, error)

ValidateConfigured validates only resources enabled by installed Package filters. Authored Package validation remains strict through ValidatePackage.

func ValidatePackage

func ValidatePackage(root string) (Resources, error)

ValidatePackage checks a Package manifest, inventory, public identities, and portable local closure. Unlike Validate, package.json and its name are required.

func ValidatePackageManifest

func ValidatePackageManifest(root string, data []byte) (Resources, error)

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.

Jump to

Keyboard shortcuts

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