config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 28, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package config carries the layered-config primitives shared across cli-guard consumers: path helpers, repo-slug derivation, the Audit

Path defaults and per-repo audit derivation. Globals live under ~/.coily so they outlive any individual repo. Locals live under

Index

Constants

View Source
const AuditSubdir = "audit"

AuditSubdir is the subdirectory under the global dir where per-repo audit logs live. One JSONL file per repo slug.

View Source
const GlobalDirName = ".coily"

GlobalDirName is the single directory under $HOME that holds every coily global - configs and the per-repo audit subtree.

View Source
const LocalDirName = ".coily"

LocalDirName is the per-repo overlay directory. Lives at the root of the checkout. Holds the local config overlay and the per-repo command

View Source
const SessionProfileFile = "profile"

SessionProfileFile is the basename of the per-session sentinel file containing the active lockdown profile name. Plain text, one line.

View Source
const SessionsSubdir = "sessions"

SessionsSubdir is the subdirectory under AuditSubdir where per-session state lives. One directory per CLAUDE_CODE_SESSION_ID. Currently holds

View Source
const UnrootedAuditName = "_unrooted"

UnrootedAuditName is the slug used when coily is invoked outside any git repo (or inside one with no origin remote). All such invocations land in

Variables

This section is empty.

Functions

func DefaultAuditPath

func DefaultAuditPath() (string, error)

DefaultAuditPath returns ~/.coily/audit/<slug>.jsonl, where slug is derived from the current git repo's origin remote. Falls back to

func ExpandHome

func ExpandHome(p string) string

ExpandHome turns a leading "~/" or "~" into the user's home directory. Returns the input unchanged if it doesn't start with "~" or if $HOME

func GlobalConfigPath

func GlobalConfigPath() (string, error)

GlobalConfigPath returns ~/.coily/config.yaml.

func GlobalDir

func GlobalDir() (string, error)

GlobalDir returns ~/.coily, expanded against $HOME. Returns an error only if $HOME cannot be resolved.

func LocalConfigPath

func LocalConfigPath() (string, error)

LocalConfigPath returns ./.coily/config.yaml relative to the current working directory. The file may or may not exist.

func OverlayFile

func OverlayFile[T any](dst *T, path string) error

OverlayFile reads path (if it exists) and yaml-unmarshals onto dst. Missing file is not an error: the consumer's prior layer keeps its

func RepoAuditSlug

func RepoAuditSlug() string

RepoAuditSlug returns the audit slug for the current working directory. Format: "<owner>-<repo>" lowercased and reduced to [a-z0-9-]. Returns

func ResetRepoSlugCacheForTest

func ResetRepoSlugCacheForTest()

ResetRepoSlugCacheForTest clears the cache. Test-only.

func SanitizeSlug

func SanitizeSlug(s string) string

SanitizeSlug normalizes input to lowercase, replaces every non-[a-z0-9-] run with a single dash, and trims leading and trailing dashes. Exported

func SessionDir

func SessionDir(sessionID string) (string, error)

SessionDir returns ~/.coily/audit/sessions/<sessionID>. Caller is responsible for MkdirAll. Returns an error if sessionID is empty or

func SessionProfilePath

func SessionProfilePath(sessionID string) (string, error)

SessionProfilePath returns the per-session profile sentinel file path for sessionID. Errors propagate from SessionDir.

Types

type Audit

type Audit struct {
	LogPath    string `yaml:"log_path"`
	MaxSizeMB  int    `yaml:"max_size_mb"`
	MaxBackups int    `yaml:"max_backups"`
	MaxAgeDays int    `yaml:"max_age_days"`
	Compress   bool   `yaml:"compress"`
}

Audit controls where the JSONL audit log lives and how lumberjack rotates it. LogPath defaults to ~/.coily/audit/<slug>.jsonl when left

Jump to

Keyboard shortcuts

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