feat: add new tool

This commit is contained in:
DarkSky
2026-02-01 04:37:13 +08:00
parent 759aa1b684
commit b49e48b467
12 changed files with 800 additions and 2 deletions
+19
View File
@@ -0,0 +1,19 @@
import { readFileSync } from 'node:fs';
import path from 'node:path';
import { applyUpdate, Doc } from 'yjs';
export function getDisplayLabel(inputPath: string) {
const resolved = path.resolve(process.cwd(), inputPath);
if (resolved === inputPath) {
return inputPath;
}
return `${inputPath} (${resolved})`;
}
export function readYjsDocFromFile(filePath: string): Doc {
const bin = readFileSync(filePath);
const doc = new Doc();
applyUpdate(doc, new Uint8Array(bin));
return doc;
}