# yowainwright/pastoralist architecture

> Architecture diagram of the GitHub repository yowainwright/pastoralist, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yowainwright/pastoralist
- Repository: https://github.com/yowainwright/pastoralist

## Overview

#### 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: [`src/core/index.ts`](https://github.com/yowainwright/pastoralist/blob/main/src/core/index.ts) (Core workflow), [`src/cli/index.ts`](https://github.com/yowainwright/pastoralist/blob/main/src/cli/index.ts) (CLI orchestration), [`src/core/appendix/index.ts`](https://github.com/yowainwright/pastoralist/blob/main/src/core/appendix/index.ts) (Audit appendix), [`src/config/index.ts`](https://github.com/yowainwright/pastoralist/blob/main/src/config/index.ts) (Configuration contract)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry surfaces"]
  node_program(("Program entry<br/>Node/TypeScript<br/>[index.ts]"))
  node_cli["CLI orchestration<br/>CLI boundary<br/>[index.ts]"]
  node_parser["Command parser<br/>CLI parser<br/>[index.ts]"]
  node_action["GitHub Action<br/>Action runtime<br/>[action.ts]"]
  node_action_manifest["Action manifest<br/>GitHub Action metadata<br/>[action.yml]"]
  node_init["Project initialization<br/>CLI command<br/>[index.ts]"]
end

subgraph group_runtime["Analysis and update runtime"]
  node_config["Configuration contract<br/>config loading/validation<br/>[index.ts]"]
  node_schema["Config schema<br/>JSON Schema<br/>[schema.json]"]
  node_core["Core workflow<br/>analysis orchestrator<br/>[index.ts]"]
  node_packages["Manifest interpretation<br/>package analysis<br/>[index.ts]"]
  node_workspaces["Workspace discovery<br/>workspace aggregation<br/>[workspaces.ts]"]
  node_overrides["Override discovery<br/>package-manager overrides<br/>[index.ts]"]
  node_appendix["Audit appendix<br/>record reconciliation<br/>[index.ts]"]
  node_update["Manifest update<br/>preview/write lifecycle<br/>[index.ts]"]
  node_patches["Patch artifacts<br/>patch-package integration<br/>[patches.ts]"]
end

subgraph group_security["Security enrichment"]
  node_security_orchestrator["Security checks<br/>security orchestrator<br/>[index.ts]"]
  node_providers["Security providers<br/>provider adapters"]
  node_security_setup["Provider setup<br/>credential setup<br/>[setup.ts]"]
end

subgraph group_support["Runtime support"]
  node_dx["Output and terminal UX<br/>presentation layer<br/>[index.ts]"]
  node_cache["Cache and network utilities<br/>runtime infrastructure<br/>[index.ts]"]
  node_observability["Logging<br/>observability<br/>[logger.ts]"]
end

subgraph group_delivery["Distribution and docs"]
  node_binary_build["Binary build<br/>release build script<br/>[build-bin.ts]"]
  node_publish["Package publication<br/>GitHub workflow<br/>[publish.yml]"]
  node_homebrew["Homebrew updates<br/>GitHub workflow<br/>[homebrew.yml]"]
  node_docs_client["Documentation site<br/>Vite/React browser entry<br/>[main.tsx]"]
  node_docs_prerender["Docs prerendering<br/>SSR/prerender pipeline<br/>[prerender.ts]"]
  node_docs_content["MDX documentation<br/>docs content"]
  node_docs_deploy["Docs deployment<br/>GitHub Pages workflow<br/>[gh-pages.yml]"]
end

node_program -->|"starts CLI"| node_cli
node_cli -->|"parses commands"| node_parser
node_action_manifest -->|"invokes"| node_action
node_action -->|"uses execution boundary"| node_cli
node_cli -->|"runs init"| node_init
node_cli -->|"loads options"| node_config
node_config -->|"validates against"| node_schema
node_cli -->|"runs analysis/update"| node_core
node_config -->|"supplies policy"| node_core
node_core -->|"reads manifests"| node_packages
node_core -->|"discovers scope"| node_workspaces
node_workspaces -->|"aggregates packages"| node_packages
node_packages -->|"extracts override syntax"| node_overrides
node_core -->|"builds records"| node_appendix
node_overrides -->|"documents overrides"| node_appendix
node_patches -->|"links patches"| node_appendix
node_appendix -->|"reconciles lifecycle"| node_update
node_core -.->|"optionally enriches"| node_security_orchestrator
node_security_orchestrator -->|"queries"| node_providers
node_security_setup -->|"configures credentials"| node_providers
node_security_orchestrator -->|"adds vulnerability data"| node_appendix
node_core -->|"reports results"| node_dx
node_core -.->|"uses cached metadata"| node_cache
node_core -.->|"logs activity"| node_observability
node_binary_build -->|"produces release binaries"| node_publish
node_publish -.->|"triggers formula updates"| node_homebrew
node_docs_content -->|"renders content"| node_docs_client
node_docs_content -->|"prerenders content"| node_docs_prerender
node_docs_prerender -->|"publishes site"| node_docs_deploy

click node_program "https://github.com/yowainwright/pastoralist/blob/main/src/index.ts"
click node_cli "https://github.com/yowainwright/pastoralist/blob/main/src/cli/index.ts"
click node_parser "https://github.com/yowainwright/pastoralist/blob/main/src/cli/parser/index.ts"
click node_action "https://github.com/yowainwright/pastoralist/blob/main/src/cli/action.ts"
click node_action_manifest "https://github.com/yowainwright/pastoralist/blob/main/action.yml"
click node_init "https://github.com/yowainwright/pastoralist/blob/main/src/cli/cmds/init/index.ts"
click node_config "https://github.com/yowainwright/pastoralist/blob/main/src/config/index.ts"
click node_schema "https://github.com/yowainwright/pastoralist/blob/main/src/schema.json"
click node_core "https://github.com/yowainwright/pastoralist/blob/main/src/core/index.ts"
click node_packages "https://github.com/yowainwright/pastoralist/blob/main/src/core/package/index.ts"
click node_workspaces "https://github.com/yowainwright/pastoralist/blob/main/src/core/workspaces.ts"
click node_overrides "https://github.com/yowainwright/pastoralist/blob/main/src/core/overrides/index.ts"
click node_appendix "https://github.com/yowainwright/pastoralist/blob/main/src/core/appendix/index.ts"
click node_update "https://github.com/yowainwright/pastoralist/blob/main/src/core/update/index.ts"
click node_patches "https://github.com/yowainwright/pastoralist/blob/main/src/core/patches.ts"
click node_security_orchestrator "https://github.com/yowainwright/pastoralist/blob/main/src/core/security/index.ts"
click node_security_setup "https://github.com/yowainwright/pastoralist/blob/main/src/core/security/setup.ts"
click node_dx "https://github.com/yowainwright/pastoralist/blob/main/src/dx/index.ts"
click node_cache "https://github.com/yowainwright/pastoralist/blob/main/src/utils/cache/index.ts"
click node_observability "https://github.com/yowainwright/pastoralist/blob/main/src/observability/logger.ts"
click node_binary_build "https://github.com/yowainwright/pastoralist/blob/main/scripts/build-bin.ts"
click node_publish "https://github.com/yowainwright/pastoralist/blob/main/.github/workflows/publish.yml"
click node_homebrew "https://github.com/yowainwright/pastoralist/blob/main/.github/workflows/homebrew.yml"
click node_docs_client "https://github.com/yowainwright/pastoralist/blob/main/app/src/main.tsx"
click node_docs_prerender "https://github.com/yowainwright/pastoralist/blob/main/app/scripts/prerender.ts"
click node_docs_deploy "https://github.com/yowainwright/pastoralist/blob/main/.github/workflows/gh-pages.yml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_program,node_cli,node_parser,node_action,node_action_manifest,node_init toneBlue
class node_config,node_schema,node_core,node_packages,node_workspaces,node_overrides,node_appendix,node_update,node_patches toneAmber
class node_security_orchestrator,node_providers,node_security_setup toneMint
class node_dx,node_cache,node_observability toneRose
class node_binary_build,node_publish,node_homebrew,node_docs_client,node_docs_prerender,node_docs_content,node_docs_deploy toneIndigo
```

## Components

### Entry surfaces

- [Program entry](https://github.com/yowainwright/pastoralist/blob/main/src/index.ts): Node/TypeScript · `src/index.ts`
- [CLI orchestration](https://github.com/yowainwright/pastoralist/blob/main/src/cli/index.ts): CLI boundary · Dispatches commands, prompts, and presentation modes. · `src/cli/index.ts`
- [Command parser](https://github.com/yowainwright/pastoralist/blob/main/src/cli/parser/index.ts): CLI parser · `src/cli/parser/index.ts`
- [GitHub Action](https://github.com/yowainwright/pastoralist/blob/main/src/cli/action.ts): Action runtime · `src/cli/action.ts`
- [Action manifest](https://github.com/yowainwright/pastoralist/blob/main/action.yml): GitHub Action metadata · `action.yml`
- [Project initialization](https://github.com/yowainwright/pastoralist/blob/main/src/cli/cmds/init/index.ts): CLI command · `src/cli/cmds/init/index.ts`

### Analysis and update runtime

- [Configuration contract](https://github.com/yowainwright/pastoralist/blob/main/src/config/index.ts): config loading/validation · Normalizes scope, workspace, security, and write-mode policy. · `src/config/index.ts`
- [Config schema](https://github.com/yowainwright/pastoralist/blob/main/src/schema.json): JSON Schema · `src/schema.json`
- [Core workflow](https://github.com/yowainwright/pastoralist/blob/main/src/core/index.ts): analysis orchestrator · Consolidates findings into a root-manifest appendix. · `src/core/index.ts`
- [Manifest interpretation](https://github.com/yowainwright/pastoralist/blob/main/src/core/package/index.ts): package analysis · `src/core/package/index.ts`
- [Workspace discovery](https://github.com/yowainwright/pastoralist/blob/main/src/core/workspaces.ts): workspace aggregation · `src/core/workspaces.ts`
- [Override discovery](https://github.com/yowainwright/pastoralist/blob/main/src/core/overrides/index.ts): package-manager overrides · Handles npm/Bun overrides, pnpm overrides, and Yarn resolutions. · `src/core/overrides/index.ts`
- [Audit appendix](https://github.com/yowainwright/pastoralist/blob/main/src/core/appendix/index.ts): record reconciliation · Preserves override instructions and records dependents and rationale. · `src/core/appendix/index.ts`
- [Manifest update](https://github.com/yowainwright/pastoralist/blob/main/src/core/update/index.ts): preview/write lifecycle · Writes only when requested and removes entries only in explicit removal mode. · `src/core/update/index.ts`
- [Patch artifacts](https://github.com/yowainwright/pastoralist/blob/main/src/core/patches.ts): patch-package integration · `src/core/patches.ts`

### Security enrichment

- [Security checks](https://github.com/yowainwright/pastoralist/blob/main/src/core/security/index.ts): security orchestrator · `src/core/security/index.ts`
- **Security providers**: provider adapters · OSV, GitHub, Snyk, Socket, and Spektion adapters.
- [Provider setup](https://github.com/yowainwright/pastoralist/blob/main/src/core/security/setup.ts): credential setup · `src/core/security/setup.ts`

### Runtime support

- [Output and terminal UX](https://github.com/yowainwright/pastoralist/blob/main/src/dx/index.ts): presentation layer · Produces human, JSON, summary, prompt, and graph output. · `src/dx/index.ts`
- [Cache and network utilities](https://github.com/yowainwright/pastoralist/blob/main/src/utils/cache/index.ts): runtime infrastructure · Provides caching, bounded concurrency, retries, and npm metadata access. · `src/utils/cache/index.ts`
- [Logging](https://github.com/yowainwright/pastoralist/blob/main/src/observability/logger.ts): observability · `src/observability/logger.ts`

### Distribution and docs

- [Binary build](https://github.com/yowainwright/pastoralist/blob/main/scripts/build-bin.ts): release build script · `scripts/build-bin.ts`
- [Package publication](https://github.com/yowainwright/pastoralist/blob/main/.github/workflows/publish.yml): GitHub workflow · Publishes npm releases and release artifacts. · `.github/workflows/publish.yml`
- [Homebrew updates](https://github.com/yowainwright/pastoralist/blob/main/.github/workflows/homebrew.yml): GitHub workflow · `.github/workflows/homebrew.yml`
- [Documentation site](https://github.com/yowainwright/pastoralist/blob/main/app/src/main.tsx): Vite/React browser entry · `app/src/main.tsx`
- [Docs prerendering](https://github.com/yowainwright/pastoralist/blob/main/app/scripts/prerender.ts): SSR/prerender pipeline · `app/scripts/prerender.ts`
- **MDX documentation**: docs content
- [Docs deployment](https://github.com/yowainwright/pastoralist/blob/main/.github/workflows/gh-pages.yml): GitHub Pages workflow · `.github/workflows/gh-pages.yml`

## Connections

- 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
