util

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const CommitAttributionSummaryFile = ".commit-attribution-summary"
View Source
const PreCommitCheckpointFile = ".pre-commit-checkpoint"
View Source
const ShortIDLen = 8

ShortIDLen is the number of characters shown in human-facing checkpoint IDs.

Variables

This section is empty.

Functions

func AppConfigDir

func AppConfigDir() (string, error)

AppConfigDir returns the global Semantica config directory.

func AppendActivityLog

func AppendActivityLog(semDir, format string, args ...any)

AppendActivityLog appends a timestamped log line to .semantica/activity.log.

func CommitAttributionSummaryPath

func CommitAttributionSummaryPath(semDir string) string

func EnsureGitignoreEntries

func EnsureGitignoreEntries(repoRoot string, entries []string) error

EnsureGitignoreEntries appends any missing entries to the repo's .gitignore under a "# Semantica" section. Entries that already appear (with or without trailing slash for directories) are skipped.

func IsConnected

func IsConnected(semDir string) bool

IsConnected returns true if the repo is connected to Semantica.

func IsEnabled

func IsEnabled(semDir string) bool

IsEnabled checks whether Semantica is enabled by looking for the marker file (.semantica/enabled) rather than parsing settings.json.

func IsEnabledAt

func IsEnabledAt(repoPath string) bool

IsEnabledAt checks whether Semantica is enabled for a repo at the given path.

func IsImplementationSummaryEnabled added in v0.2.1

func IsImplementationSummaryEnabled(semDir string) bool

IsImplementationSummaryEnabled returns true if the auto-implementation-summary automation is enabled. For existing installations that predate this setting, the field is absent in settings.json and defaults to true (matching the semantica enable default). On first read, the setting is backfilled so future reads are explicit.

func IsPlaybookEnabled

func IsPlaybookEnabled(semDir string) bool

IsPlaybookEnabled returns true if the auto-playbook automation is enabled.

func OpenWorkerLog

func OpenWorkerLog(semDir string) (*os.File, error)

OpenWorkerLog opens .semantica/worker.log in append mode. The caller is responsible for closing the returned file.

func PreCommitCheckpointPath

func PreCommitCheckpointPath(semDir string) string

func ResolveExecutable

func ResolveExecutable(names []string, extraCandidates ...string) string

ResolveExecutable returns the first matching executable path for any of the provided binary names. It checks PATH first, then common user and package manager install locations used on macOS and Linux.

func SettingsPath

func SettingsPath(semDir string) string

func ShortID

func ShortID(full string) string

ShortID returns the first ShortIDLen characters of a full ID. If the input is shorter than ShortIDLen, it is returned unchanged.

func TrailersEnabled

func TrailersEnabled(semDir string) bool

TrailersEnabled returns whether attribution and diagnostics trailers are on. Defaults to true when the key is absent or settings cannot be read.

func WriteSettings

func WriteSettings(semDir string, s Settings) error

WriteSettings atomically writes the settings file via tmp+rename. It also maintains a .semantica/enabled marker file used by Git hooks for a reliable enabled check without parsing JSON in shell.

Types

type Automations

type Automations struct {
	Playbook              PlaybookAutomation              `json:"playbook"`
	ImplementationSummary ImplementationSummaryAutomation `json:"implementation_summary"`
}

type ImplementationSummaryAutomation added in v0.2.1

type ImplementationSummaryAutomation struct {
	Enabled bool `json:"enabled"`
}

type PlaybookAutomation

type PlaybookAutomation struct {
	Enabled bool `json:"enabled"`
}

type Settings

type Settings struct {
	Enabled         bool         `json:"enabled"`
	Version         int          `json:"version"`
	Providers       []string     `json:"providers,omitempty"`
	Trailers        *bool        `json:"trailers,omitempty"`
	Automations     *Automations `json:"automations,omitempty"`
	Connected       bool         `json:"connected"`
	ConnectedRepoID string       `json:"connected_repo_id,omitempty"`
}

func ReadSettings

func ReadSettings(semDir string) (Settings, error)

ReadSettings reads the settings file from the given .semantica directory. Returns zero-value Settings (Enabled: false) if the file is missing. Returns an error if the file exists but cannot be parsed, so callers can distinguish "not configured" from "settings format has changed."

Jump to

Keyboard shortcuts

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