Documentation
¶
Index ¶
Constants ¶
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.
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.
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 ¶
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
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.
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.