Skip to content

feat: add pi-yaml-hooks support (YAML hooks for pi)#616

Closed
ryaneggz wants to merge 1 commit into
developmentfrom
feat/pi-yaml-hooks
Closed

feat: add pi-yaml-hooks support (YAML hooks for pi)#616
ryaneggz wants to merge 1 commit into
developmentfrom
feat/pi-yaml-hooks

Conversation

@ryaneggz

@ryaneggz ryaneggz commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

What

Adds pi-yaml-hooks support to the harness β€” event-driven YAML hooks for the pi coding agent, adapted from KristjanPikhof/Pi-YAML-Hooks examples/.

Approach (scope decisions)

Advisor-guided. The three upstream example packs were triaged rather than dumped in wholesale:

Pack Decision Why
engine (pi-yaml-hooks npm) Install β€” pinned in .pi/settings.json packages[] Idiomatic thin package pin (same model as sibling pi packages)
post-tool-developer-feedback Adapted β†’ active hook (.pi/hook/hooks.yaml) Non-blocking, genuinely useful proof-of-usability
pre-tool-developer-guards Vendored reference-only, NOT wired Fully superseded by .pi/extensions/path-guard.ts; wiring it would double-fire confirmations
atomic-commit-snapshot-worker Not vendored (pointer only) Repo-only, destructive auto-commit, ~3.4k LOC of fcntl/signal Python

Changes

  • .pi/settings.json β€” pin npm:pi-yaml-hooks@2026.6.14; settings.test.ts updated in lockstep (the array is asserted with toEqual).
  • .pi/hook/hooks.yaml β€” active hook: NDJSON audit log (tool.after.write|edit under harness source areas) + setStatus on dependency-file changes. Deliberately observe-only: no bash blocking, no tool: prompt injection (would interfere with autopilot/cron pi sessions).
  • .pi/hook/post-tool-log.mjs β€” audit-log helper (writes git-ignored .pi-hook-logs/).
  • .pi/hook/README.md β€” provenance, event/action/condition schema, trust model, and why packs 1/3 aren't wired.
  • .pi/hook/examples/pre-tool-developer-guards/ β€” vendored reference pack.
  • .gitignore β€” ignore .pi-hook-logs/.
  • .pi/UPSTREAM.md β€” tracking entry (MIT, quarterly review, lockstep-bump note).

⚠️ Trust decision (operator-facing)

Project hooks are inert until the repo is trusted via /hooks-trust or PI_YAML_HOOKS_TRUST_PROJECT=1. This PR does not auto-trust globally β€” that would change behavior across every pi session (autopilot, cron, slack bridge) and is left as an explicit operator choice, documented in .pi/hook/README.md. The engine loads everywhere via the pin, but hooks.yaml does nothing until trusted.

Verification

  • node_modules/.bin/vitest run .pi/extensions/__tests__/ β†’ 57 passed (incl. settings.test.ts with the new pin).
  • node --check on both .mjs helpers; active hooks.yaml confirmed free of command: actions (rejected by pi at load).
  • npm view pi-yaml-hooks version β†’ 2026.6.14 (pin verified against registry, not guessed).

πŸ€– Generated with Claude Code

Pin the pi-yaml-hooks engine (npm:pi-yaml-hooks@2026.6.14) and ship a
conservative, observe-only project hook config plus a vendored reference
example, adapted from KristjanPikhof/Pi-YAML-Hooks/examples.

- .pi/settings.json: pin engine in packages[]; settings.test.ts kept in
  lockstep (toEqual assertion).
- .pi/hook/hooks.yaml: active demonstration hook β€” NDJSON audit log +
  setStatus on dep changes. Non-blocking, no prompt injection (won't
  interfere with autopilot/cron); inert until the project is trusted.
- .pi/hook/examples/pre-tool-developer-guards: vendored reference-only;
  intentionally NOT wired (superseded by .pi/extensions/path-guard.ts).
- atomic-commit-snapshot-worker: deliberately not vendored (repo-only,
  destructive auto-commit, ~3.4k LOC) β€” documented via pointer.
- .gitignore: ignore .pi-hook-logs/ audit output.
- .pi/UPSTREAM.md: tracking entry (MIT, quarterly review, lockstep bump).

Trust is an operator decision (/hooks-trust or PI_YAML_HOOKS_TRUST_PROJECT=1);
the harness does not auto-trust globally.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ryaneggz

Copy link
Copy Markdown
Collaborator Author

Closing as superseded by #655 (merged as 0eaa152), which adopted cc-safety-net@1.0.6 as the canonical cross-provider bash guard and retired path-guard.ts's RISKY_BASH branch.

Why close rather than rebase:

  • This PR conflicts with feat: adopt cc-safety-net as cross-provider destructive-command guard (#654)Β #655 in .pi/settings.json (packages array) and .pi/extensions/__tests__/settings.test.ts.
  • The vendored pre-tool-developer-guards reference pack was justified as "superseded by path-guard.ts" β€” that rationale is now stale twice over; cc-safety-net is the pi bash guard.
  • The audit-trail value is partially covered by cc-safety-net's per-session logs (~/.cc-safety-net/logs/<session_id>.jsonl, persisted via named volume).

Salvageable idea not covered elsewhere: an observe-only write/edit audit log (cc-safety-net only sees Bash, not file-edit tools). If wanted, re-scope as a slim fresh PR on the new baseline: engine pin + hooks.yaml + log helper only, no vendored guards pack.

Branch feat/pi-yaml-hooks left intact for reference.

@ryaneggz ryaneggz closed this Jul 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant