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;