manifest

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package manifest reads and writes the PromptVM context-sync manifest that declares which workspace/directory a repo syncs to and what gets captured.

Three scopes mirror Claude Code's settings hierarchy:

local   → .promptvm/config.local.json   (gitignored, machine-specific)
project → .promptvm/config.json         (committable, shared with the team)
user    → <os.UserConfigDir()>/promptvm/config.json (global default)

Resolution precedence is local → project → user (most specific wins). Scalar fields take the most-specific non-empty value. Capture-policy arrays (events, excludePaths) REPLACE rather than concat — the most-specific scope that sets them wins, so a repo can drop PreCompact (DX-5). Only the scope that explicitly declares an array overrides; an absent array (JSON `null`) inherits from the next-broader scope.

Index

Constants

View Source
const SchemaVersion = "1.0"

SchemaVersion is the current manifest schema version.

Variables

View Source
var (
	DefaultEvents       = []string{"SessionEnd", "PreCompact"}
	DefaultMode         = "summary"
	DefaultExcludePaths = []string{"**/.env*", "secrets/**", ".git/**"}
	DefaultGovernance   = "inherit"
)

Default capture policy values, applied when no scope sets them.

Functions

func Path

func Path(scope Scope, repoRoot string) (string, error)

Path returns the manifest file path for the given scope. The project and local paths are anchored at repoRoot (or cwd when repoRoot is "").

func Write

func Write(path string, m *Manifest) error

Write atomically writes a manifest to path (tmp + rename), creating parent directories as needed.

func WriteScope

func WriteScope(scope Scope, repoRoot string, m *Manifest) (string, error)

WriteScope writes a manifest for the given scope anchored at repoRoot.

Types

type Capture

type Capture struct {
	Enabled      *bool    `json:"enabled,omitempty"`
	Events       []string `json:"events,omitempty"`
	Mode         string   `json:"mode,omitempty"`
	ExcludePaths []string `json:"excludePaths,omitempty"`
	Redact       *bool    `json:"redact,omitempty"`
	Governance   string   `json:"governance,omitempty"`
}

Capture is the capture-policy block of a manifest.

type Manifest

type Manifest struct {
	SchemaVersion string   `json:"schemaVersion,omitempty"`
	Workspace     string   `json:"workspace,omitempty"`
	Directory     string   `json:"directory,omitempty"`
	Capture       *Capture `json:"capture,omitempty"`
}

Manifest is the on-disk shape of a single scope's config file. Pointer and nil-slice fields let Resolve distinguish "unset" (inherit) from "set".

func Read

func Read(path string) (*Manifest, error)

Read loads a single manifest file. A missing file yields (nil, nil) so callers can treat "absent" as "inherit".

func ReadScope

func ReadScope(scope Scope, repoRoot string) (*Manifest, error)

ReadScope loads the manifest for a scope, anchored at repoRoot. Returns (nil, nil) when the file does not exist.

type Resolved

type Resolved struct {
	Workspace    string
	Directory    string
	Enabled      bool
	Events       []string
	Mode         string
	ExcludePaths []string
	Redact       bool
	Governance   string
}

Resolved is the fully-defaulted, flattened view used by the runtime after merging all scopes. Every field carries a concrete value.

func Resolve

func Resolve(repoRoot string) (*Resolved, error)

Resolve merges the user → project → local scopes (broad to specific) into a fully-defaulted Resolved. repoRoot anchors the project/local files. Missing files are skipped. Capture-policy arrays REPLACE (most-specific wins).

func (*Resolved) EventSelected

func (r *Resolved) EventSelected(event string) bool

EventSelected reports whether the resolved policy captures on the given Claude Code hook event name.

type Scope

type Scope string

Scope identifies one of the three manifest tiers.

const (
	ScopeLocal   Scope = "local"
	ScopeProject Scope = "project"
	ScopeUser    Scope = "user"
)

Jump to

Keyboard shortcuts

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