source

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package source resolves an authorized extension path into one conventional factory or exact isolated standalone definition.

Index

Constants

View Source
const GoSDKModulePath = "github.com/MichaelKinsy/PiG/extensions/sdk"

GoSDKModulePath is the Go SDK module path that current Pig scaffolds import.

View Source
const LegacyGoSDKModulePath = "github.com/mainstai/pig/extensions/sdk"

LegacyGoSDKModulePath is the module path the same Go SDK carried in Pig 0.84 and earlier. Factories written against it stay loadable: generated runners alias it to the current SDK source, so the extension compiles against the SDK that speaks the running host's protocol.

Variables

This section is empty.

Functions

func IsGoSDKModulePath

func IsGoSDKModulePath(path string) bool

IsGoSDKModulePath reports whether path names the Go SDK module under its current or legacy module path.

func NodeDeclaresExtensions

func NodeDeclaresExtensions(dir string) bool

NodeDeclaresExtensions reports whether dir's package.json has a "pi" manifest with a non-empty "pi.extensions" list. Upstream loads only what such a manifest names.

func NodeDirectoryEntries

func NodeDirectoryEntries(dir string) []string

NodeDirectoryEntries returns the extension entry files in dir as upstream Pi's collectAutoExtensionEntries (core/package-manager.ts) does: the entries dir's own package.json "pi.extensions" declares when any exist, else dir/index.ts, else dir/index.js; otherwise every .ts and .js file in dir and the entry of every subdirectory that has one, skipping hidden entries, node_modules, and paths excluded by dir's .gitignore, .ignore, or .fdignore. A directory with none of these has no entries.

func NodeDirectoryImport

func NodeDirectoryImport(dir string) (file string, ok bool)

NodeDirectoryImport returns the file upstream's jiti import of the directory dir loads: <dir><ext>, then <dir>/index<ext> over jiti's extensions, then require.resolve's package.json "main" (the file, then with .js, .json or .node, then its index.js, index.json or index.node), then dir's index.js, index.json or index.node. ok is false when none exists.

func NodeManifestEntries

func NodeManifestEntries(root string) (entries, missing []string, declared bool, err error)

NodeManifestEntries returns the extension entry files a Node package's package.json "pi.extensions" names, in declaration order, as upstream Pi's package manager collects them (collectFilesFromManifestEntries in core/package-manager.ts): a file entry is itself, a directory entry expands with NodeDirectoryEntries, and an entry that does not exist is reported in missing. declared is false when package.json has no non-empty "pi.extensions".

func NodeRootEntries

func NodeRootEntries(dir string) []string

NodeRootEntries is upstream's resolveExtensionEntries (core/package-manager.ts): the existing entries dir's package.json "pi.extensions" declares, else index.ts, else index.js, else nil. Declared entries are returned as declared, without expanding a directory among them, as upstream does.

Types

type Definition

type Definition struct {
	Language           string
	Form               Form
	Root               string
	Entrypoint         string
	ModulePath         string
	Package            string
	Factory            string
	Packable           bool
	GoWorkspaceModules []string
	// SDKModulePath is the Go SDK module path a Go factory imports.
	SDKModulePath string
}

Definition is the complete runtime input derived from one authorized source.

func Resolve

func Resolve(input string) (Definition, error)

Resolve classifies one exact source path without reading any extension metadata file.

type Form

type Form string

Form is one supported author-facing extension execution form.

const (
	// Factory is a conventional language factory hosted by a generated runner.
	Factory Form = "factory"
	// Standalone is an exact isolated executable or executable source.
	Standalone Form = "standalone"
)

type ResolveFunc

type ResolveFunc func(string) (Definition, error)

ResolveFunc classifies one exact extension source path. Callers that own a bounded resolution snapshot use it to share one source scan across startup validation, discovery, trust, and loading.

Jump to

Keyboard shortcuts

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