Skip to content

Latest commit

 

History

History
43 lines (29 loc) · 1.98 KB

File metadata and controls

43 lines (29 loc) · 1.98 KB

Snapshot autocommit

This repository ships a full Python example that auto-commits recognized file changes through a snapshot worker.

This is an opt-in example, not a built-in pi-yaml-hooks feature.

Use the bundled example (repo-only)

The atomic-commit-snapshot-worker directory is repo-only; it is not shipped in the npm tarball. Clone the GitHub repository to use it.

Hook snippet

Use this as a project-local hook. It is a repo-specific workflow, and project hooks only load after the repo or worktree anchor is trusted.

hooks:
  - id: snapshot-autocommit
    event: file.changed
    async: true
    actions:
      - bash: 'python3 <snapshot-example-dir>/snapshot-hook.py'

  - id: snapshot-flush-on-exit
    event: session.deleted
    actions:
      - bash: 'python3 <snapshot-example-dir>/snapshot-worker.py --flush --repo "$PI_PROJECT_DIR"'

Replace <snapshot-example-dir> with the actual path to the cloned examples/atomic-commit-snapshot-worker/ directory that contains snapshot-hook.py, snapshot-worker.py, and snapshot_shared.py. pi install alone does not give you a stable working-tree path for this snippet.

When to use it

Use this example when you want:

  • automatic git commits after edits settle
  • a per-worktree queue and worker
  • a more advanced example of file.changed, async, and session.deleted

The session.deleted flush path is best-effort on PI because that event is intentionally lossy.