Skip to content

API Reference parrot.sdd.installer

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

parrot.sdd.installer

View source

Deploy the packaged SDD flow (parrot/sdd/_assets/) into a repository (FEAT-633 M6, rev 0.2).

Conflict rule (C4, receipt-driven — sdd/.sdd-installed.json records the SHA-256 of every byte sequence this installer wrote): absent → write + record; matches the receipt → upgrade; differs from the receipt → edited; not in the receipt and not byte-identical → foreign; unrecorded but byte-identical → adopt as current. Every manifest target is a parrot-owned SDD asset, so by default install overwrites edited and foreign targets (an upgrade replaces them) and uninstall removes them; keep_edits restores the conservative rule (skip/keep them + warning). Seeds (sdd/config.json and manifest entries flagged "seed": true) are written once and never touched again.

Attribute AGY_EXPERIENCE_HOOK_NAME

Attribute AGY_HOOKS_PATH

Attribute AGY_HOOK_LINE

Attribute AGY_HOOK_NAME

Attribute AGY_OWNERSHIP_NAME

Attribute DANGEROUS_HOOK_LINE

Alias EXTERNAL_TOOL_RE

Re-exported from parrot.sdd.audit.EXTERNAL_TOOL_RE.

Attribute FileState

Attribute GITATTRIBUTES_BLOCK

Attribute GITIGNORE_BEGIN

Attribute GITIGNORE_BLOCK

Attribute GITIGNORE_END

Attribute GUARD_HOOK_LINE

Attribute HOOK_WIRING_NOTE

Attribute MANIFEST_SCHEMA_VERSION

Attribute PlanAction

Class PlannedAction

One step of an install/uninstall plan; str() is the --dry-run line.

Fields:

Field Type Default Description
action PlanAction
target str
note str ''

Attribute RECEIPT_PATH

Attribute RECEIPT_SCHEMA_VERSION

Attribute SDD_TOOLKITS

Type: tuple[str, ...]

Attribute SETTINGS_PATH

Attribute SUPPORTED_HOSTS

Type: tuple[str, ...]

Alias SddConfig

Re-exported from parrot.sdd.config.SddConfig.

Function agy_hook_command

Return the agy hook command and its form; same bare/baked rule as :func:guard_hook_command.

agy_hook_command(*, portable: bool | None) -> tuple[str, Literal['bare', 'baked']]

Parameter Type Default Description
portable bool | None

Returns: tuple[str, Literal['bare', 'baked']]

Function agy_settings_paths

The user's agy settings.json files: every one that exists, else every one whose agy directory exists.

agy auto-approves a command only through permissions.allow rules in these files (a hook cannot), so the managed SDD rules have to live here rather than in the repository. An empty list means agy has not run for this user yet; nothing is created then.

agy_settings_paths() -> list[Path]

Returns: list[Path]

Function classify_entry

C4 state of one manifest target.

missing → not on disk; foreign → on disk, not in the receipt, not byte-identical to the packaged copy; edited → on disk, in the receipt, SHA differs from the record; current → SHA equals the record (or unrecorded but byte-identical to the packaged copy — adopted) AND equals the packaged copy; outdated → SHA equals the record but the packaged copy changed. The packaged copy is the one rendered with hook (C25).

classify_entry(root: Path, entry: dict[str, Any], receipt: dict[str, Any], hook: str = GUARD_HOOK_LINE) -> FileState

Parameter Type Default Description
root Path
entry dict[str, Any]
receipt dict[str, Any]
hook str GUARD_HOOK_LINE

Returns: FileState

Function dangerous_hook_command

Return the dangerous-actions guard command and its form; same bare/baked rule as :func:guard_hook_command.

dangerous_hook_command(*, portable: bool | None) -> tuple[str, Literal['bare', 'baked']]

Parameter Type Default Description
portable bool | None

Returns: tuple[str, Literal['bare', 'baked']]

Function gitignore_block

The managed block for root: the fixed rules plus the resolved in-repository worktree rule.

gitignore_block(root: Path) -> str

Parameter Type Default Description
root Path Primary repository root.

Returns: str — The managed .gitignore block; an external worktree root gets no worktree rule.

Raises:

  • SddConfigError — the resolved worktree root is the repository itself.

Function guard_hook_command

Return the guard-hook command to render and its form (rev 0.6 C25).

bare when portable is true or when it is unspecified and parrot on PATH resolves under the managed launcher home; otherwise baked: the absolute path of this interpreter's venv parrot script. An explicit false value always selects the baked form.

guard_hook_command(*, portable: bool | None) -> tuple[str, Literal['bare', 'baked']]

Parameter Type Default Description
portable bool | None

Returns: tuple[str, Literal['bare', 'baked']]

Function install_sdd_integration

Deploy packaged SDD assets for hosts into root, replacing older or hand-edited copies.

install_sdd_integration(root: Path, hosts: Sequence[str] = ('claude',), *, keep_edits: bool = False, dry_run: bool = False, portable: bool | None = None, base_branch: str | None = None, push_base: bool = False, hotfix_base: str | None = None, dangerous_guard: bool = True, sdd_coder: bool = True, agy_permissions: bool = True) -> list[str]

Parameter Type Default Description
root Path Target repository root (need not be a Python project).
hosts Sequence[str] ('claude',) Any of SUPPORTED_HOSTS; shared assets (templates, WORKFLOW.md) install for every host.
keep_edits bool False Skip manifest targets edited since parrot wrote them or not recorded in the receipt (default: overwrite them — every manifest target is a parrot-owned SDD asset). Seeds are never overwritten either way.
dry_run bool False Return the plan (plan: <action> <target> lines) and write NOTHING — no asset, seed, gitignore, ledger, config, receipt, or directory.
portable bool | None None True writes bare launcher commands, False writes baked paths, and None retains a host's existing form or follows the managed launcher for a fresh host (C25).
base_branch str | None None C31 — seed sdd/config.json with this base branch (when absent) and prepare it. Conflicts with an existing config that sets a different one.
push_base bool False C31 — also git push -u origin <base_branch> when origin lacks it.
hotfix_base str | None None C31 — seed sdd/config.json with this hotfix branch (when absent). Needed when base_branch is main (the default hotfix branch): the two must differ.
dangerous_guard bool True C32 — register the PreToolUse dangerous-actions guard in .claude/settings.json (claude host); False skips it.
sdd_coder bool True C34 — register the sdd-coder and bounded-source MCP toolkits (.parrot/mcp-toolkits.yaml plus the host MCP config) and report the usable roster; False skips all of it.
agy_permissions bool True Brief agy-permission-hook (google host) — register the agy PreToolUse permission hook in .agents/hooks.json and merge the managed permissions.allow rules into the user's agy settings.json (additive; ownership is recorded per user next to that file, so uninstall removes only rules parrot added, once no repository uses them); False skips both.

Returns: list[str] — Human-readable action log; skipped conflicts and audit findings start with warning:; dry-run lines start with plan:.

Raises:

  • ValueError — unknown host; SddConfigError (a ValueError) for a malformed existing sdd/config.json, raised before anything is written.
  • RuntimeError — packaged manifest missing/unsupported.
  • LegacyWorktreesError — worktrees are still registered under .claude/worktrees/ (nothing is written).

Function load_manifest

Return the manifest's assets list.

load_manifest() -> list[dict[str, Any]]

Returns: list[dict[str, Any]]

Raises:

  • RuntimeError — manifest missing or schema_version unsupported.

Function load_receipt

Return <root>/sdd/.sdd-installed.json or an empty receipt when absent.

Shape: {"schema_version": 1, "version": "<ai-parrot that wrote it>" | None, "files": {target: sha256}, "blocks": {".gitattributes": sha256}, "ledger_hooks": [event, ...]} — missing blocks / ledger_hooks keys default to {} / []. An unreadable or wrong-schema receipt is treated as empty and logged at WARNING (never raises).

load_receipt(root: Path) -> dict[str, Any]

Parameter Type Default Description
root Path

Returns: dict[str, Any]

Attribute logger

Alias managed_launcher_on_path

Re-exported from parrot.launcher.managed_launcher_on_path.

Alias missing_tools

Re-exported from parrot.sdd.audit.missing_tools.

Function plan_install

Pure: the ordered plan for install (assets, seeds, gitignore, ledger, config). No I/O writes.

plan_install(root: Path, hosts: Sequence[str], *, keep_edits: bool = False, hook: str = GUARD_HOOK_LINE, base_branch: str | None = None, dangerous_guard: bool = True, sdd_coder: bool = True, agy_permissions: bool = True) -> list[PlannedAction]

Parameter Type Default Description
root Path
hosts Sequence[str]
keep_edits bool False
hook str GUARD_HOOK_LINE
base_branch str | None None
dangerous_guard bool True
sdd_coder bool True
agy_permissions bool True

Returns: list[PlannedAction]

Function plan_stale

Build the pure stale-file removal plan, honoring keep globs and symlink safety.

plan_stale(root: Path, hosts: Sequence[str], *, keep: Sequence[str] = ()) -> list[PlannedAction]

Parameter Type Default Description
root Path
hosts Sequence[str]
keep Sequence[str] ()

Returns: list[PlannedAction]

Function plan_uninstall

Pure: remove every present manifest target (edited/foreign included) unless keep_edits, which removes only targets whose on-disk SHA matches the receipt; keep shared assets another installed host still needs; seeds and state are never planned for removal.

plan_uninstall(root: Path, hosts: Sequence[str], *, keep_edits: bool = False) -> list[PlannedAction]

Parameter Type Default Description
root Path
hosts Sequence[str]
keep_edits bool False

Returns: list[PlannedAction]

Function remove_stale_sdd_files

Remove stale SDD files while preserving current assets, seeds, state, and the receipt.

remove_stale_sdd_files(root: Path, hosts: Sequence[str] = SUPPORTED_HOSTS, *, keep: Sequence[str] = (), dry_run: bool = False) -> list[str]

Parameter Type Default Description
root Path
hosts Sequence[str] SUPPORTED_HOSTS
keep Sequence[str] ()
dry_run bool False

Returns: list[str]

Alias scan_paths

Re-exported from parrot.sdd.audit.scan_paths.

Alias script_path

Re-exported from parrot.launcher.script_path.

Function sdd_status

Per-host install state (C4/C15/C25):

{"hosts": {h: {"current": [...], "outdated": [...], "edited": [...], "foreign": [...], "missing": [...]}}, "seeds": {"<target>": "seed-present" | "missing"}, "config": bool, "gitignore": bool, "id_ledger": bool, "gitattributes": bool, "ledger_hooks": bool, # [rev 0.5 D5] "guard_hook": {"form": "bare" | "baked" | "other" | None, "command": str | None, "targets": [str], "resolvable": bool}, # [rev 0.6 C25] "stale": [...], "stale_mcp": [...], "receipt_version": str | None} (targets are repo-relative strings). Import-cheap: parrot self doctor (TASK-4080) imports this lazily and treats outdated/edited as "not current". Guard-hook assets are compared against the rendering matching the form already on disk, so a bare or baked install reports current until the mode is changed by a re-install.

sdd_status(root: Path) -> dict[str, Any]

Parameter Type Default Description
root Path

Returns: dict[str, Any]

Function uninstall_sdd_integration

Remove the SDD assets for hosts — every present manifest target, including ones edited since install or never recorded in the receipt; with keep_edits only receipt-matching files go (others are kept and reported).

The .gitignore block, the recorded .gitattributes block (C23) and the receipt are removed only when no recorded file remains; the ledger hooks are removed only when receipt["ledger_hooks"] says this integration created them and no parrot-wiki post-commit block shows the Claude integration shares them; sdd/tasks/.id_ledger.json, sdd/config.json and seeds are never removed (state / team-owned). dry_run returns the plan and writes nothing.

uninstall_sdd_integration(root: Path, hosts: Sequence[str] = ('claude',), *, keep_edits: bool = False, dry_run: bool = False) -> list[str]

Parameter Type Default Description
root Path
hosts Sequence[str] ('claude',)
keep_edits bool False
dry_run bool False

Returns: list[str]

Function worktree_root_scope

Classify worktree_root(root): ("inside", rel), ("external", None) or ("repo-root", None).

Canonical paths are compared, so relative ../ overrides and symlinks classify like absolute paths.

worktree_root_scope(root: Path) -> tuple[str, str | None]

Parameter Type Default Description
root Path Primary repository root.

Returns: tuple[str, str | None] — The scope and, for "inside", the repository-relative POSIX path of the resolved root.

Function worktree_test_isolation

Why tests run inside a feature worktree (<worktree root>/<feature>/) may not exercise the worktree's own code, else None.

SDD runs each task's tests in a worktree, but the shared .venv usually has the project installed editable from the MAIN checkout, so pytest silently imports that copy; a virtual project ([tool.uv] package = false) cannot import its own modules at all. A rootdir-relative pytest pythonpath fixes both. Read-only and never raises; it never edits the user's pytest config.

worktree_test_isolation(root: Path, test_command: str | None) -> str | None

Parameter Type Default Description
root Path Repository root (the main checkout).
test_command str | None sdd/config.json test_command (None when unset).

Returns: str | None — One sentence naming the cause and the recommended pythonpath setting, or None when the repo is not a Python project, test_command does not run pytest or already sets PYTHONPATH, or pytest already has a pythonpath setting.

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