First step of docs/git-sync-plan.md. New workspace package @docmost/git-sync vendoring the PURE parts from docmost-sync (HEAD b03eb35): - lib: markdown-converter, markdown-document, canonicalize, docmost-schema, node-ops, diff, and an extracted markdown-to-prosemirror (only the pure marked->HTML->generateJSON path from upstream collaboration.ts; no websocket). - engine (pure, no IO): reconcile, layout, sanitize, stabilize, loop-guard. Ported the upstream pure-module + round-trip corpus tests (vitest): 314 pass, 3 expected upstream known-limitation fails. tsc clean. No server wiring yet. docmost-schema inlines getStyleProperty (as packages/mcp does — @tiptap/core 3.20.4 doesn't export it). IO engine (pull/push/git/settings) deferred to later Phase A/B steps; the editor-ext idempotency gate (plan §13.1) is the next step. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
24 lines
1.0 KiB
TypeScript
24 lines
1.0 KiB
TypeScript
/**
|
|
* Deterministic filename strategy (SPEC §12).
|
|
*
|
|
* The file name is COSMETIC — the source of truth for the file<->page link is
|
|
* `pageId` / `slugId` inside the meta block, so renaming a file is safe. These
|
|
* functions are intentionally dependency-free and pure, so they are trivially
|
|
* unit-testable.
|
|
*/
|
|
/**
|
|
* Sanitize a page title into a safe file-name component (WITHOUT extension).
|
|
*
|
|
* Steps: replace forbidden / control characters with "-", collapse whitespace
|
|
* runs to a single space, trim, cap the length, then guard against an empty
|
|
* result, an all-dots result, or a reserved Windows device name by prefixing
|
|
* with "_".
|
|
*/
|
|
export declare function sanitizeTitle(title: string): string;
|
|
/**
|
|
* Disambiguate a sanitized name when two siblings in the same folder collapse
|
|
* to the same name. Appends a stable suffix built from the page's `slugId`, so
|
|
* the result stays deterministic across runs (SPEC §12: `Title ~slugId`).
|
|
*/
|
|
export declare function disambiguate(name: string, slugId: string): string;
|