pigdocs

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package pigdocs materializes the reference documentation embedded in Stock Pig under the user's config root (`~/.pig/docs` by default).

Pig ships as a standalone binary. Unlike upstream Pi, which installs package documentation beside its npm entry point, Pig cannot assume that a source checkout exists. The embedded bundle lets the running agent inspect the exact extension, Package, and Piglet contracts that its binary implements.

The docs sync is idempotent and content-addressed. Users can also force a sync or read the bundle through `pig docs`. This is stock distribution infrastructure; it does not activate an extension or optional Piglet.

Output layout

~/.pig/docs/
  README.md            index
  commands.md          slash commands + CLI verbs
  concepts.md          how pig fits together: resources, packages, piglets
  config.md            settings, env vars, paths
  divergences.md       pig vs upstream pi
  extension-api.md     subprocess SDK host API surface
  extensions.md        extension model, manifest, lifecycle
  models.md            model selection, cycling, thinking
  packages.md          packages: shareable resource bundles installed with pig install
  piglets.md          Piglet schema, carriers, component closure, and environments
  providers.md         provider list, auth, env
  runtime-cells.md     packed-cell runtime mechanics
  skills.md            SKILL.md skills: format, loading, discovery

Index

Constants

View Source
const (

	// SubDir is the docs directory name under the pig config root.
	SubDir = "docs"
)

Variables

This section is empty.

Functions

func DocsDir

func DocsDir(configRoot string) string

DocsDir returns the absolute docs directory for a given config root.

func EnsureSynced

func EnsureSynced(configRoot string) error

EnsureSynced is the idempotent startup helper. It writes embedded docs only when the on-disk digest differs, so warm starts do no writable filesystem work. All errors are returned to the caller; Pig core should treat any failure as non-fatal (logs a warning at most).

func List

func List() []string

List returns the embedded doc filenames in stable alphabetical order. It is the canonical source for `pig docs list` and for any caller that needs to enumerate available topics.

func Read

func Read(name string) ([]byte, error)

Read returns the embedded bytes of a single doc file. Names may be given with or without the .md suffix; ".." and absolute paths are rejected so this is safe to drive from CLI input.

func RunCommand

func RunCommand(args []string, stdout, stderr io.Writer) int

RunCommand implements the stock pre-session `pig docs` command. It returns -1 when the arguments target another command.

pig docs                       sync + summary (default)
pig docs sync                  force re-sync embedded docs
pig docs path                  print docs dir
pig docs list                  list available doc files
pig docs show <name>           print one doc to stdout

func Sync

func Sync(configRoot string) ([]string, error)

Sync writes every embedded doc into <configRoot>/docs, overwriting existing files. It also writes the content digest marker. Returns the list of relative paths written.

Types

This section is empty.

Jump to

Keyboard shortcuts

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