@lisang233/pi-sync
Personal Pi extension that syncs Pi configuration through Git with background auto-sync and git-style fetch/merge conflict handling.
Package details
Install @lisang233/pi-sync from npm and Pi will load the resources declared by the package manifest.
$ pi install npm:@lisang233/pi-sync- Package
@lisang233/pi-sync- Version
0.1.3- Published
- Aug 11, 2026
- Downloads
- 474/mo · 474/wk
- Author
- lisang233
- License
- MIT
- Types
- extension
- Size
- 86.6 KB
- Dependencies
- 1 dependency · 2 peers
Pi manifest JSON
{
"extensions": [
"./src/index.ts"
]
}Security note
Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.
README
🔄 pi-sync
A personal Pi extension that syncs Pi configuration through Git with git-style fetch/pull/merge/push, a single config file, and conflict resolution inside the Pi UI.
Experimental. This is a from-scratch rewrite of the classic pi-sync flow: one config file, one git remote, content-level diffs, three-way merges, and deliberate commands that never move your files without asking.
✨ Features
- Single config, direct connection — one
pi-sync.jsonpoints at one git remote and branch. No two-level setup/connection model. - Observe-only automatic —
automatic: truefetches at session start and shows a persistent status-bar indicator (up-to-date / ahead / behind / conflict). It never pushes, pulls or merges on its own. - Git-style pull —
/sync pullfetches and merges. Clean changes apply directly; divergence without a flag writes nothing;--forceoverwrites local files;--mergeopens in-UI conflict resolution. - In-UI conflict resolution — divergent edits are parsed into conflict blocks and resolved one at a time (keep local / keep remote / type a replacement). Progress persists across sessions;
/sync mergeresumes,/sync merge --abortrestores the pre-merge backup. - JSON-aware merging — single-line
settings.json/keybindings.json/models.jsonmerge field-wise, so formatting or an unrelated field change doesn't conflict. - Closed-loop status —
/sync statusshows the effective config, the sync state, any in-progress merge, and the exact next step;/sync status --diffshows the content-level diff (JSON pretty-printed, secrets masked, bounded). - No stored credentials — Git uses your existing SSH/credential-helper setup; the config file never holds tokens.
📦 Install
pi install -l ~/Documents/code/pi-sync
or from npm once published:
pi install npm:@lisang233/pi-sync
🚀 Quick start
/sync init # first-run wizard: remote, branch, include, automatic
/sync config # view and edit the config at any time
/sync status # config + sync state + next step (--diff for content)
/sync fetch # pull the remote snapshot without applying
/sync pull # fetch + merge (--force overwrites, --merge resolves)
/sync merge # continue an in-progress merge (--abort discards)
/sync push # publish local snapshot (--force overwrites remote)
⚙️ Settings
The config lives at ~/.pi/agent/pi-sync.json (agent dir honors PI_CODING_AGENT_DIR):
{
"remote": "git@github.com:you/pi-sync.git",
"branch": "pi-sync",
"include": [
"settings.json",
"keybindings.json",
"models.json",
"skills",
"prompts",
"themes",
"extensions",
"extension-settings"
],
"automatic": true
}
includeselects which agent-dir paths sync. The defaults aresettings.json,keybindings.json,models.json,skills,prompts,themes,extensions, andextension-settings. Sessions andAGENTS.mdare intentionally not included by default. Edit it any time with/sync config.automaticonly controls whether a non-destructive fetch runs at session start; the status-bar indicator always reflects the last known state.- State lives under
<agent-dir>/pi-sync/(a mirror git repo,state.json,merge-session/, and backups).
🗂️ Package layout
src/
index.ts extension entrypoint
extension.ts lifecycle, /sync command routes, session-start fetch
config.ts single-file config load/validate/save
config-ui.ts interactive config editor (view + edit fields)
paths.ts agent-dir paths and include normalization
git.ts git subprocess backend (fetch/push/show/merge-file)
snapshot.ts scan include paths into a hashed snapshot
state.ts last-applied snapshot + remote revision
status.ts sync-state derivation and indicator text
merge-session.ts persistent conflict-resolution session store
conflict.ts diff3 marker parsing and resolved-text splicing
resolve.ts structured block-by-block conflict resolver
diff.ts content-level diff with JSON formatting and secret masking
merge.ts three-way merge (JSON field-wise + git merge-file fallback)
operations.ts status/push/pull/fetch/merge
wizard.ts first-run setup wizard
test/ vitest unit + local-bare-repo end-to-end tests
🔎 Keywords
pi-package pi-extension pi sync git
📄 License
MIT