How yowainwright/pastoralist works
Purpose and Entry Points
Pastoralist is a Node/TypeScript CLI and GitHub Action that maintains an audit appendix for package-manager dependency overrides. It discovers overrides and dependents, optionally enriches them with vulnerability data, then reports or safely writes consolidated metadata to project manifests. Primary program entry is src/index.ts; CLI parsing/dispatch begins in src/cli/index.ts and src/cli/parser/index.ts. The Action entry is action.yml with runtime logic in src/cli/action.ts.
CLI Orchestration and Modes
The CLI converts commands and flags (doctor, init, normal update, dry-run, removal, summary, JSON/quiet, security) into typed execution options, interactive prompts, and terminal output. src/cli/index.ts coordinates this boundary; src/cli/cmds/init/index.ts initializes project configuration; src/cli/security/index.ts handles CLI-facing security behavior. This layer should not contain package-manifest mutation logic.
Configuration and Project Boundary
Configuration is loaded from package metadata or supported external config formats, validated, and normalized before core processing. src/config/index.ts, src/config/validators.ts, and src/config/validation/utils.ts define that contract; src/schema.json is the distributable schema. Config establishes traversal scope, security policy/provider, workspace behavior, and write/check modes.
Package, Workspace, and Override Discovery
Core analysis reads manifests and package-manager-specific override syntax: npm/Bun overrides, pnpm overrides, and Yarn resolutions. src/core/index.ts is the central workflow; src/core/package/index.ts owns manifest/package interpretation; src/core/workspaces.ts discovers and aggregates workspace packages. The important boundary is read analysis versus an eventual root-manifest update: workspace findings are consolidated into one root appendix.
Audit Appendix and Lifecycle Management
The appendix records each override’s dependents and ledger rationale, preserving package-manager instructions rather than replacing them. src/core/appendix/index.ts, src/core/overrides/index.ts, and src/core/update/index.ts construct/reconcile records and apply updates. Update behavior supports preview versus write, detects stale entries, and only removes unused overrides under explicit removal mode. Patch support links patch-package artifacts through src/core/patches.ts.
Security Enrichment
Security scanning augments override records with CVEs, severity, source provider, and patched-version information. src/core/security/index.ts orchestrates checks and setup; pluggable adapters live under src/core/security/providers/, including osv.ts, github.ts, snyk.ts, socket.ts, and spektion.ts. This is an external-network boundary with provider-specific credentials/setup in src/core/security/setup.ts; default OSV behavior is exposed through CLI flags and configuration.
Output, Observability, and Supporting Runtime Services
Human-readable terminal UX, machine JSON output, summaries, prompts, and dependency graphs are separated from core decisions in src/dx/index.ts, src/dx/output.ts, and src/dx/terminal-graph.ts. Logging and telemetry-style observability are isolated in src/observability/logger.ts. Reusable infrastructure includes bounded concurrency, retries, npm metadata access, and disk/LRU caching in src/utils/limit.ts, src/utils/retry.ts, and src/utils/cache/index.ts.
Distribution, Automation, and Documentation Site
The package is published to npm and can produce ScriptC/Homebrew binaries through scripts/build-bin.ts and release scripts. GitHub workflows provide CI, npm publication, release artifacts/attestation, and Homebrew updates, notably .github/workflows/publish.yml and .github/workflows/homebrew.yml. A separate Vite/React documentation site under app/ uses app/src/main.tsx for browser entry and app/src/entry-server.tsx plus app/scripts/prerender.ts for prerendering; it consumes MDX content from app/src/content/docs/ and is deployed via .github/workflows/gh-pages.yml.
Main entry points: core/index.ts Core workflow · cli/index.ts CLI orchestration · appendix/index.ts Audit appendix · config/index.ts Configuration contract
Components 28
Entry surfaces
- Program entry
src/index.ts - CLI orchestration · Dispatches commands, prompts, and presentation modes.
src/cli/index.ts - Command parser
src/cli/parser/index.ts - GitHub Action
src/cli/action.ts - Action manifest
action.yml - Project initialization
src/cli/cmds/init/index.ts
Analysis and update runtime
- Configuration contract · Normalizes scope, workspace, security, and write-mode policy.
src/config/index.ts - Config schema
src/schema.json - Core workflow · Consolidates findings into a root-manifest appendix.
src/core/index.ts - Manifest interpretation
src/core/package/index.ts - Workspace discovery
src/core/workspaces.ts - Override discovery · Handles npm/Bun overrides, pnpm overrides, and Yarn resolutions.
src/core/overrides/index.ts - Audit appendix · Preserves override instructions and records dependents and rationale.
src/core/appendix/index.ts - Manifest update · Writes only when requested and removes entries only in explicit removal mode.
src/core/update/index.ts - Patch artifacts
src/core/patches.ts
Security enrichment
- Security checks
src/core/security/index.ts - Security providers · OSV, GitHub, Snyk, Socket, and Spektion adapters.
- Provider setup
src/core/security/setup.ts
Runtime support
- Output and terminal UX · Produces human, JSON, summary, prompt, and graph output.
src/dx/index.ts - Cache and network utilities · Provides caching, bounded concurrency, retries, and npm metadata access.
src/utils/cache/index.ts - Logging
src/observability/logger.ts
Distribution and docs
- Binary build
scripts/build-bin.ts - Package publication · Publishes npm releases and release artifacts.
.github/workflows/publish.yml - Homebrew updates
.github/workflows/homebrew.yml - Documentation site
app/src/main.tsx - Docs prerendering
app/scripts/prerender.ts - MDX documentation
- Docs deployment
.github/workflows/gh-pages.yml
Connections 29
- Program entry → CLI orchestration: starts CLI
- CLI orchestration → Command parser: parses commands
- Action manifest → GitHub Action: invokes
- GitHub Action → CLI orchestration: uses execution boundary
- CLI orchestration → Project initialization: runs init
- CLI orchestration → Configuration contract: loads options
- Configuration contract → Config schema: validates against
- CLI orchestration → Core workflow: runs analysis/update
- Configuration contract → Core workflow: supplies policy
- Core workflow → Manifest interpretation: reads manifests
- Core workflow → Workspace discovery: discovers scope
- Workspace discovery → Manifest interpretation: aggregates packages
- Manifest interpretation → Override discovery: extracts override syntax
- Core workflow → Audit appendix: builds records
- Override discovery → Audit appendix: documents overrides
- Patch artifacts → Audit appendix: links patches
- Audit appendix → Manifest update: reconciles lifecycle
- Core workflow → Security checks: optionally enriches
- Security checks → Security providers: queries
- Provider setup → Security providers: configures credentials
- Security checks → Audit appendix: adds vulnerability data
- Core workflow → Output and terminal UX: reports results
- Core workflow → Cache and network utilities: uses cached metadata
- Core workflow → Logging: logs activity
- Binary build → Package publication: produces release binaries
- Package publication → Homebrew updates: triggers formula updates
- MDX documentation → Documentation site: renders content
- MDX documentation → Docs prerendering: prerenders content
- Docs prerendering → Docs deployment: publishes site