settings

package
v0.7.161 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const CommitIfFilter = "Bash(git commit*)"

CommitIfFilter is the per-entry "if" condition that restricts hook entries to git commit commands. The Bash(pattern) syntax is evaluated as a glob against the bash command string, not the tool name.

View Source
const CommitMatcher = "Bash"

CommitMatcher is the PreToolUse hook group matcher that chunk manages. It targets the Bash tool by name; per Claude Code's hook spec, matcher filters only on tool name. Command-content filtering is done via CommitIfFilter on individual hook entries.

View Source
const StopCommand = "chunk validate"

StopCommand is the Stop hook command that chunk manages. Merge identifies chunk's own Stop entry by this exact string, so it must stay in sync with the command written by Build and BuildCodex.

Variables

This section is empty.

Functions

func Build

func Build(commands []config.Command) ([]byte, error)

Build generates .claude/settings.json content from commands. It creates:

  • A PreToolUse hook matching "Bash(git commit*)" that runs each command before commits.
  • A Stop hook that runs "chunk validate" after every session.

func BuildCodex added in v0.7.85

func BuildCodex(commands []config.Command) ([]byte, error)

BuildCodex generates .codex/hooks.json content from commands. Produces the same hook structure as Build but without Claude Code-specific metadata ($schema, _comment) and without a permissions block. Commands run as-is; Codex sets CWD to the project root before invoking hooks.

func Diff

func Diff(original, merged []byte) string

Diff returns a unified diff string between the original and merged JSON. Returns an empty string if there are no differences.

Types

type MergeResult

type MergeResult struct {
	Original []byte // existing settings.json content (re-marshaled for normalized formatting)
	Merged   []byte // merged result
	Changed  bool   // false if already up to date
}

MergeResult holds the computed merge without performing any I/O.

func Merge

func Merge(existing, generated []byte) (*MergeResult, error)

Merge computes the merged settings from existing and generated JSON bytes. It preserves all unknown keys in the existing settings and applies chunk's generated keys on top. Returns data only — display and file writing are the caller's responsibility.

func MergeCodex added in v0.7.85

func MergeCodex(existing, generated []byte) (*MergeResult, error)

MergeCodex computes the merged .codex/hooks.json from existing and generated bytes. It preserves all unknown keys and hook types, and replaces chunk's own PreToolUse and Stop hook entries via the same mergeHooks used for .claude/settings.json.

Jump to

Keyboard shortcuts

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