Skip to content

API Reference parrot.sdd.scripts.install_hooks

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.sdd.scripts.install_hooks

View source

install_hooks.py — install the daily /sdd-spec intake prune git hook (FEAT-577).

Adds a marker-delimited block to post-checkout / post-merge / post-commit in the effective hooks directory (git rev-parse --git-path hooks). The block runs python -m scripts.sdd.prune_intake --daily --apply from the primary checkout; the --daily stamp limits it to once per 24 h. Idempotent; --uninstall removes only this block. Refuses (exit 2) when the hooks directory is missing.

Attribute HOOK_EVENTS

Type: tuple[str, ...]

Attribute MARKER_BEGIN

Type: str

Attribute MARKER_END

Type: str

Attribute SHEBANG

Type: str

Function hooks_dir

Resolve git rev-parse --git-path hooks against repo_root (honours core.hooksPath).

hooks_dir(repo_root: Path) -> Path

Parameter Type Default Description
repo_root Path

Returns: Path

Function install

Add or replace the block in each hook; create + chmod +x missing hooks. Raises FileNotFoundError when hooks is missing.

install(hooks: Path, block: str, events: tuple[str, ...] = HOOK_EVENTS) -> list[Path]

Parameter Type Default Description
hooks Path
block str
events tuple[str, ...] HOOK_EVENTS

Returns: list[Path]

Function main

CLI: [--uninstall] [--repo-root]. Exit 0; 2 when the hooks dir is missing (message names core.hooksPath).

main(argv: list[str] | None = None) -> int

Parameter Type Default Description
argv list[str] | None None

Returns: int

Function primary_checkout

Resolve the primary checkout of repo_root's repository.

The hooks directory is shared by every worktree of a repository, so the installed block must cd into the primary checkout — not into whichever linked worktree (or subdirectory) happened to run the installer. git rev-parse --git-common-dir always points at the primary checkout's .git, so its parent is that checkout. Falls back to repo_root resolved when git cannot answer.

primary_checkout(repo_root: Path) -> Path

Parameter Type Default Description
repo_root Path

Returns: Path

Function render_block

The marker-delimited shell block: primary checkout only; prune --daily --apply; never fails.

render_block(python: str, repo_root: Path) -> str

Parameter Type Default Description
python str
repo_root Path

Returns: str

Function uninstall

Remove only the sdd-intake-prune block from each hook; leave everything else byte-identical.

uninstall(hooks: Path, events: tuple[str, ...] = HOOK_EVENTS) -> list[Path]

Parameter Type Default Description
hooks Path
events tuple[str, ...] HOOK_EVENTS

Returns: list[Path]

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally