From 5fe9d1f0c4ea01dd91014b0b25c0e3dd1c94ae0c Mon Sep 17 00:00:00 2001 From: VPS Date: Thu, 19 Feb 2026 10:07:29 +0000 Subject: [PATCH] feat: add includeInternal option to sync i:-prefixed files Adds to , allowing specific internal files (stored with prefix by Self-hosted LiveSync) to be synced to the local storage peer. By default, all paths containing are filtered out, which excludes hidden/internal files like and . With this option, callers can whitelist specific glob patterns (e.g. ) to opt specific internal directories back in. The prefix is stripped before dispatching to PeerStorage so the file is written to the correct filesystem path. --- PeerCouchDB.ts | 12 +++++++++++- types.ts | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/PeerCouchDB.ts b/PeerCouchDB.ts index d58d0e1..43b491b 100644 --- a/PeerCouchDB.ts +++ b/PeerCouchDB.ts @@ -5,6 +5,7 @@ import { decodeBinary } from "./lib/src/string_and_binary/convert.ts"; import { isPlainText } from "./lib/src/string_and_binary/path.ts"; import { DispatchFun, Peer } from "./Peer.ts"; import { createBinaryBlob, createTextBlob, isDocContentSame, unique } from "./lib/src/common/utils.ts"; +import { minimatch } from "minimatch"; // export class PeerInstance() @@ -156,6 +157,9 @@ export class PeerCouchDB extends Peer { if (path.startsWith("/")) { path = path.substring(1); } + if (path.startsWith("i:")) { + path = path.substring(2); + } if (entry.deleted || entry._deleted) { this.sendLog(`${path} delete detected`); await this.dispatchDeleted(path); @@ -166,7 +170,13 @@ export class PeerCouchDB extends Peer { } }, (entry) => { this.setSetting("since", this.man.since); - if (entry.path.indexOf(":") !== -1) return false; + if (entry.path.indexOf(":") !== -1) { + if (this.config.includeInternal && entry.path.startsWith("i:")) { + const stripped = entry.path.substring(2); + return this.config.includeInternal.some(pattern => minimatch(stripped, pattern, { dot: true })); + } + return false; + } return entry.path.startsWith(baseDir); }); } diff --git a/types.ts b/types.ts index 2e19e0a..12c79c0 100644 --- a/types.ts +++ b/types.ts @@ -18,6 +18,8 @@ export interface PeerStorageConf { useChokidar?: boolean; } export interface PeerCouchDBConf extends DirectFileManipulatorOptions { + /** Glob patterns for i:-prefixed (internal) files to sync, e.g. [".claude/**"] */ + includeInternal?: string[]; type: "couchdb"; useRemoteTweaks?: true; group?: string;