@younndai/lyt-mesh 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +200 -0
- package/NOTICE +23 -0
- package/README.md +135 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +34 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/clone-all.d.ts +3 -0
- package/dist/commands/clone-all.d.ts.map +1 -0
- package/dist/commands/clone-all.js +66 -0
- package/dist/commands/clone-all.js.map +1 -0
- package/dist/commands/mesh-init.d.ts +3 -0
- package/dist/commands/mesh-init.d.ts.map +1 -0
- package/dist/commands/mesh-init.js +70 -0
- package/dist/commands/mesh-init.js.map +1 -0
- package/dist/commands/pod-status.d.ts +3 -0
- package/dist/commands/pod-status.d.ts.map +1 -0
- package/dist/commands/pod-status.js +67 -0
- package/dist/commands/pod-status.js.map +1 -0
- package/dist/commands/source.d.ts +3 -0
- package/dist/commands/source.d.ts.map +1 -0
- package/dist/commands/source.js +83 -0
- package/dist/commands/source.js.map +1 -0
- package/dist/commands/status.d.ts +4 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +121 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/sync.d.ts +3 -0
- package/dist/commands/sync.d.ts.map +1 -0
- package/dist/commands/sync.js +234 -0
- package/dist/commands/sync.js.map +1 -0
- package/dist/commands/validate.d.ts +3 -0
- package/dist/commands/validate.d.ts.map +1 -0
- package/dist/commands/validate.js +66 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/discovery/github.d.ts +19 -0
- package/dist/discovery/github.d.ts.map +1 -0
- package/dist/discovery/github.js +90 -0
- package/dist/discovery/github.js.map +1 -0
- package/dist/discovery/walk.d.ts +28 -0
- package/dist/discovery/walk.d.ts.map +1 -0
- package/dist/discovery/walk.js +78 -0
- package/dist/discovery/walk.js.map +1 -0
- package/dist/flows/clone-all.d.ts +53 -0
- package/dist/flows/clone-all.d.ts.map +1 -0
- package/dist/flows/clone-all.js +123 -0
- package/dist/flows/clone-all.js.map +1 -0
- package/dist/flows/mesh-init-validate.d.ts +22 -0
- package/dist/flows/mesh-init-validate.d.ts.map +1 -0
- package/dist/flows/mesh-init-validate.js +195 -0
- package/dist/flows/mesh-init-validate.js.map +1 -0
- package/dist/flows/mesh-init.d.ts +46 -0
- package/dist/flows/mesh-init.d.ts.map +1 -0
- package/dist/flows/mesh-init.js +302 -0
- package/dist/flows/mesh-init.js.map +1 -0
- package/dist/flows/pod-status.d.ts +37 -0
- package/dist/flows/pod-status.d.ts.map +1 -0
- package/dist/flows/pod-status.js +269 -0
- package/dist/flows/pod-status.js.map +1 -0
- package/dist/flows/status.d.ts +16 -0
- package/dist/flows/status.d.ts.map +1 -0
- package/dist/flows/status.js +76 -0
- package/dist/flows/status.js.map +1 -0
- package/dist/flows/sync-check.d.ts +38 -0
- package/dist/flows/sync-check.d.ts.map +1 -0
- package/dist/flows/sync-check.js +180 -0
- package/dist/flows/sync-check.js.map +1 -0
- package/dist/flows/sync-watch.d.ts +24 -0
- package/dist/flows/sync-watch.d.ts.map +1 -0
- package/dist/flows/sync-watch.js +217 -0
- package/dist/flows/sync-watch.js.map +1 -0
- package/dist/flows/sync.d.ts +45 -0
- package/dist/flows/sync.d.ts.map +1 -0
- package/dist/flows/sync.js +513 -0
- package/dist/flows/sync.js.map +1 -0
- package/dist/flows/validate.d.ts +22 -0
- package/dist/flows/validate.d.ts.map +1 -0
- package/dist/flows/validate.js +62 -0
- package/dist/flows/validate.js.map +1 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -0
- package/dist/mesh-command.d.ts +3 -0
- package/dist/mesh-command.d.ts.map +1 -0
- package/dist/mesh-command.js +31 -0
- package/dist/mesh-command.js.map +1 -0
- package/dist/source/repo.d.ts +14 -0
- package/dist/source/repo.d.ts.map +1 -0
- package/dist/source/repo.js +71 -0
- package/dist/source/repo.js.map +1 -0
- package/dist/source/types.d.ts +22 -0
- package/dist/source/types.d.ts.map +1 -0
- package/dist/source/types.js +49 -0
- package/dist/source/types.js.map +1 -0
- package/package.json +77 -0
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 MARLINK TRADING SRL (YounndAI)
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { existsSync } from "node:fs";
|
|
17
|
+
import chokidar from "chokidar";
|
|
18
|
+
import { backfillFigmentCaches, closeRegistry, listVaults, openRegistry, reconcileFigmentWrite, toVaultRelPosix, } from "@younndai/lyt-vault";
|
|
19
|
+
import { syncFlow } from "./sync.js";
|
|
20
|
+
export const DEFAULT_COMMIT_DEBOUNCE_MS = 30_000;
|
|
21
|
+
const IGNORED_SEGMENTS = /(?:^|[\\/])(?:\.git|node_modules|\.lyt)(?:[\\/]|$)/;
|
|
22
|
+
export const isIgnoredWatchPath = (path) => IGNORED_SEGMENTS.test(path);
|
|
23
|
+
export async function syncWatchFlow(opts = {}) {
|
|
24
|
+
const commitDebounceMs = opts.commitDebounceMs ?? DEFAULT_COMMIT_DEBOUNCE_MS;
|
|
25
|
+
const watcherFactory = opts.watcherFactory ??
|
|
26
|
+
((paths, ignored) => chokidar.watch(paths, {
|
|
27
|
+
ignored,
|
|
28
|
+
ignoreInitial: true,
|
|
29
|
+
persistent: true,
|
|
30
|
+
// C2 (Lane M Wave 0 v2.1) — never traverse a symlink out of the
|
|
31
|
+
// vault root, so a symlinked dir/file in `notes/` can't have its
|
|
32
|
+
// out-of-vault target indexed (info-disclosure). Paired with the
|
|
33
|
+
// lstat guard in reconcile-figment-write.ts:readFigmentBody.
|
|
34
|
+
followSymlinks: false,
|
|
35
|
+
}));
|
|
36
|
+
const db = await openRegistry();
|
|
37
|
+
let activeVaults;
|
|
38
|
+
try {
|
|
39
|
+
activeVaults = (await listVaults(db)).filter((v) => v.status === "active" && existsSync(v.path));
|
|
40
|
+
}
|
|
41
|
+
finally {
|
|
42
|
+
await closeRegistry(db);
|
|
43
|
+
}
|
|
44
|
+
const debounceTimers = new Map();
|
|
45
|
+
const watchedPaths = activeVaults.map((v) => v.path);
|
|
46
|
+
const watcher = watcherFactory(watchedPaths, isIgnoredWatchPath);
|
|
47
|
+
// Track every in-flight reconcile / backfill so whenIdle() can await the
|
|
48
|
+
// full set. A reconcile is non-fatal (the markdown is the SoT and is
|
|
49
|
+
// already on disk); we never let a reconcile rejection escape.
|
|
50
|
+
const pending = new Set();
|
|
51
|
+
const track = (p) => {
|
|
52
|
+
pending.add(p);
|
|
53
|
+
void p.finally(() => pending.delete(p));
|
|
54
|
+
};
|
|
55
|
+
// M1 (Lane M Wave 0 v2.1) — per-vault serialization. Two FTS writers can
|
|
56
|
+
// target the same vault concurrently: the per-event incremental reconcile
|
|
57
|
+
// (reconcileNotesEvent → reconcileFigmentWrite, delete+insert) and the
|
|
58
|
+
// debounced full-walk (runSyncForVault → syncFlow → upsertFtsCache, which
|
|
59
|
+
// truncates the whole table then bulk-inserts). Running them at once on
|
|
60
|
+
// the same DB risks a torn cache. We chain every per-vault DB operation
|
|
61
|
+
// through a promise tail so they run strictly one-at-a-time PER VAULT
|
|
62
|
+
// (different vaults stay parallel). QUEUE, never drop — an edit landing
|
|
63
|
+
// mid-sync still reconciles after the sync drains. The chain swallows
|
|
64
|
+
// rejections so one failed op never poisons the tail.
|
|
65
|
+
const vaultChains = new Map();
|
|
66
|
+
const serialize = (vaultName, fn) => {
|
|
67
|
+
const prev = vaultChains.get(vaultName) ?? Promise.resolve();
|
|
68
|
+
const next = prev.then(fn, fn);
|
|
69
|
+
// Keep the tail rejection-proof so the next queued op always runs.
|
|
70
|
+
const guarded = next.catch(() => undefined);
|
|
71
|
+
vaultChains.set(vaultName, guarded);
|
|
72
|
+
void guarded.finally(() => {
|
|
73
|
+
// Drop the chain entry only if no newer op has replaced it (avoids an
|
|
74
|
+
// unbounded map for long-lived watchers over many vaults).
|
|
75
|
+
if (vaultChains.get(vaultName) === guarded)
|
|
76
|
+
vaultChains.delete(vaultName);
|
|
77
|
+
});
|
|
78
|
+
return next;
|
|
79
|
+
};
|
|
80
|
+
const scheduleCommit = (vaultName) => {
|
|
81
|
+
const existing = debounceTimers.get(vaultName);
|
|
82
|
+
if (existing)
|
|
83
|
+
clearTimeout(existing);
|
|
84
|
+
const t = setTimeout(() => {
|
|
85
|
+
debounceTimers.delete(vaultName);
|
|
86
|
+
// M1 — the debounced full-sync (which runs the full-walk FTS reconcile
|
|
87
|
+
// inside syncFlow) goes through the SAME per-vault chain as the
|
|
88
|
+
// incremental reconcile, so the two never run concurrently for one
|
|
89
|
+
// vault. Tracked so whenIdle() awaits an in-flight sync.
|
|
90
|
+
track(serialize(vaultName, () => runSyncForVault(vaultName, opts)));
|
|
91
|
+
}, commitDebounceMs);
|
|
92
|
+
debounceTimers.set(vaultName, t);
|
|
93
|
+
};
|
|
94
|
+
const resolveVaultForPath = (changedPath) => {
|
|
95
|
+
// chokidar emits absolute paths on Windows + POSIX.
|
|
96
|
+
for (const v of activeVaults) {
|
|
97
|
+
if (changedPath === v.path ||
|
|
98
|
+
changedPath.startsWith(v.path + "/") ||
|
|
99
|
+
changedPath.startsWith(v.path + "\\")) {
|
|
100
|
+
return v;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return null;
|
|
104
|
+
};
|
|
105
|
+
// Lane M Wave 0 v2 — incremental FTS reconcile on a notes/** file event.
|
|
106
|
+
// CHEAP-SEARCH INVARIANT: fresh search is the cheap universal layer, so
|
|
107
|
+
// we reconcile the FTS cache ONLY (provenance:false). The reconcile is
|
|
108
|
+
// non-fatal: a failure logs + is swallowed (the markdown SoT is on disk;
|
|
109
|
+
// the cache heals on the next startup backfill / `lyt vault rebuild-fts`).
|
|
110
|
+
const reconcileNotesEvent = (vault, op, relPath) => {
|
|
111
|
+
// M1 — queue through the per-vault chain so this incremental reconcile
|
|
112
|
+
// never overlaps the debounced full-walk for the same vault.
|
|
113
|
+
const p = serialize(vault.name, async () => {
|
|
114
|
+
await reconcileFigmentWrite(vault.path, op, { relPath }, { provenance: false });
|
|
115
|
+
opts.onReconcile?.(vault.name, op, relPath);
|
|
116
|
+
}).catch((err) => {
|
|
117
|
+
// eslint-disable-next-line no-console
|
|
118
|
+
console.warn(`sync-watch: FTS reconcile failed for ${vault.name}:${relPath} (${op}); markdown SoT preserved, heals on next backfill/rebuild-fts`, err);
|
|
119
|
+
});
|
|
120
|
+
track(p);
|
|
121
|
+
};
|
|
122
|
+
watcher.on("all", (evt, changedPath) => {
|
|
123
|
+
const v = resolveVaultForPath(changedPath);
|
|
124
|
+
if (!v)
|
|
125
|
+
return;
|
|
126
|
+
// Commit-debounce fires for ANY change in the vault (unchanged behavior).
|
|
127
|
+
scheduleCommit(v.name);
|
|
128
|
+
// FTS reconcile is notes/**-ONLY (the figment_fts source set). Changes
|
|
129
|
+
// under work/, handoffs/, .lyt/, .git/ etc. are NOT part of the cheap
|
|
130
|
+
// search cache and are skipped here.
|
|
131
|
+
const relPath = toVaultRelPosix(changedPath, v.path);
|
|
132
|
+
if (!isNotesFigment(relPath))
|
|
133
|
+
return;
|
|
134
|
+
// Map the chokidar event → reconcile op. chokidar's default config does
|
|
135
|
+
// not emit rename as a single event (it surfaces unlink + add), so we
|
|
136
|
+
// only handle add/change (→ upsert) and unlink (→ delete). A rename is
|
|
137
|
+
// therefore an unlink of the old path + an add of the new path, each of
|
|
138
|
+
// which reconciles correctly on its own.
|
|
139
|
+
if (evt === "add" || evt === "change") {
|
|
140
|
+
reconcileNotesEvent(v, "upsert", relPath);
|
|
141
|
+
}
|
|
142
|
+
else if (evt === "unlink") {
|
|
143
|
+
reconcileNotesEvent(v, "delete", relPath);
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
// Lane M Wave 0 v2 — one-time startup backfill per watched vault so an
|
|
147
|
+
// existing stale/empty figment_fts heals the moment the watcher starts.
|
|
148
|
+
// Non-fatal: a backfill failure logs + is swallowed.
|
|
149
|
+
if (opts.skipStartupBackfill !== true) {
|
|
150
|
+
for (const v of activeVaults) {
|
|
151
|
+
const p = backfillFigmentCaches(v.path)
|
|
152
|
+
.then(() => undefined)
|
|
153
|
+
.catch((err) => {
|
|
154
|
+
// eslint-disable-next-line no-console
|
|
155
|
+
console.warn(`sync-watch: startup FTS backfill failed for ${v.name}`, err);
|
|
156
|
+
});
|
|
157
|
+
track(p);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
let stopped = false;
|
|
161
|
+
const stop = async () => {
|
|
162
|
+
if (stopped)
|
|
163
|
+
return;
|
|
164
|
+
stopped = true;
|
|
165
|
+
for (const t of debounceTimers.values())
|
|
166
|
+
clearTimeout(t);
|
|
167
|
+
debounceTimers.clear();
|
|
168
|
+
await watcher.close();
|
|
169
|
+
// Let any in-flight reconciles settle so we don't close over a busy DB.
|
|
170
|
+
await whenIdle();
|
|
171
|
+
// Flush: run sync one last time so any pending changes get committed.
|
|
172
|
+
try {
|
|
173
|
+
await syncFlow({ resolveMeshContext: opts.resolveMeshContext === true });
|
|
174
|
+
}
|
|
175
|
+
catch {
|
|
176
|
+
// Best-effort flush.
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
const whenIdle = async () => {
|
|
180
|
+
// Drain the pending set until it stabilises (a settling reconcile can
|
|
181
|
+
// enqueue nothing further, but a backfill completing while events arrive
|
|
182
|
+
// means we re-check until empty).
|
|
183
|
+
while (pending.size > 0) {
|
|
184
|
+
await Promise.allSettled([...pending]);
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
if (opts.signal) {
|
|
188
|
+
opts.signal.addEventListener("abort", () => {
|
|
189
|
+
void stop();
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
const triggerChange = (vaultName) => {
|
|
193
|
+
scheduleCommit(vaultName);
|
|
194
|
+
};
|
|
195
|
+
return { stop, triggerChange, whenIdle };
|
|
196
|
+
}
|
|
197
|
+
// A figment lives under the vault's `notes/` tree (the figment_fts source
|
|
198
|
+
// set per upsert-fts-cache.ts) and is a markdown file. Matches both
|
|
199
|
+
// `notes/x.md` and nested `notes/sub/x.md`; excludes everything else.
|
|
200
|
+
function isNotesFigment(relPath) {
|
|
201
|
+
return relPath.startsWith("notes/") && relPath.toLowerCase().endsWith(".md");
|
|
202
|
+
}
|
|
203
|
+
async function runSyncForVault(vaultName, opts) {
|
|
204
|
+
try {
|
|
205
|
+
const result = await syncFlow({
|
|
206
|
+
vaultNames: [vaultName],
|
|
207
|
+
resolveMeshContext: opts.resolveMeshContext === true,
|
|
208
|
+
});
|
|
209
|
+
if (opts.onTick && result.reports.length > 0) {
|
|
210
|
+
opts.onTick(result.reports[0]);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
catch {
|
|
214
|
+
// Swallow — watcher must keep running.
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
//# sourceMappingURL=sync-watch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-watch.js","sourceRoot":"","sources":["../../src/flows/sync-watch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,QAA4B,MAAM,UAAU,CAAC;AAEpD,OAAO,EACL,qBAAqB,EACrB,aAAa,EACb,UAAU,EACV,Y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| "pushed" | "pulled" | "diverged-synced" | "conflict" | "skipped-frozen" | "skipped-tombstoned" | "skipped-disconnected" | "skipped-missing" | "no-upstream" | "not-git-repo" | "error";
|
|
3
|
+
export interface VaultSyncReport {
|
|
4
|
+
name: string;
|
|
5
|
+
path: string;
|
|
6
|
+
status: VaultSyncStatus;
|
|
7
|
+
message: string;
|
|
8
|
+
ahead?: number;
|
|
9
|
+
behind?: number;
|
|
10
|
+
dirtyCount?: number;
|
|
11
|
+
meshContextResolved?: boolean;
|
|
12
|
+
errorOutput?: string;
|
|
13
|
+
subscribed?: boolean;
|
|
14
|
+
indexCorrupt?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface SyncFrictionHint {
|
|
17
|
+
vaultName: string;
|
|
18
|
+
vaultStatus: VaultSyncStatus;
|
|
19
|
+
category: "sync.failed" | "sync.conflict";
|
|
20
|
+
message: string;
|
|
21
|
+
}
|
|
22
|
+
export interface SyncFlowResult {
|
|
23
|
+
reports: VaultSyncReport[];
|
|
24
|
+
ok: boolean;
|
|
25
|
+
frictionHints: SyncFrictionHint[];
|
|
26
|
+
}
|
|
27
|
+
export type GitRunner = (args: readonly string[], opts: GitRunOptions) => Promise<GitRunResult>;
|
|
28
|
+
export interface SyncFlowArgs {
|
|
29
|
+
vaultNames?: readonly string[];
|
|
30
|
+
resolveMeshContext?: boolean;
|
|
31
|
+
runGit?: GitRunner;
|
|
32
|
+
now?: Date;
|
|
33
|
+
message?: string;
|
|
34
|
+
}
|
|
35
|
+
export declare function syncFlow(args?: SyncFlowArgs): Promise<SyncFlowResult>;
|
|
36
|
+
declare function parsePorcelainPath(line: string): string | null;
|
|
37
|
+
export declare function classifyCheckStatus(args: {
|
|
38
|
+
ahead: number;
|
|
39
|
+
behind: number;
|
|
40
|
+
dirtyCount: number;
|
|
41
|
+
hasUpstream: boolean;
|
|
42
|
+
frozen: boolean;
|
|
43
|
+
}): string;
|
|
44
|
+
export { parsePorcelainPath as _parsePorcelainPath };
|
|
45
|
+
//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