From c2157945ef19646b677b5a3b876ffb58cb17e49f Mon Sep 17 00:00:00 2001 From: claude code agent 227 Date: Wed, 24 Jun 2026 04:28:35 +0300 Subject: [PATCH] feat(git-sync): drop legacy docmost:meta back-compat (vaults wipe+rebuild) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Per owner: test data, no migration. parsePageFile no longer reads the old docmost:meta block — a file without a gitmost_id frontmatter is simply un-tracked (adopt). Vaults are a cache: rm -rf on the transition, rebuilt native from Docmost. Simplifies the format work (no fallback). Doc updated. Co-Authored-By: Claude Opus 4.8 --- docs/backlog/git-sync-thin-meta.md | 19 ++++++------- packages/git-sync/src/lib/page-file.ts | 36 ++++++++---------------- packages/git-sync/test/page-file.test.ts | 10 ------- 3 files changed, 19 insertions(+), 46 deletions(-) diff --git a/docs/backlog/git-sync-thin-meta.md b/docs/backlog/git-sync-thin-meta.md index 6882e5d6..9d60e79f 100644 --- a/docs/backlog/git-sync-thin-meta.md +++ b/docs/backlog/git-sync-thin-meta.md @@ -95,15 +95,12 @@ Obsidian резолвит `[[Заметка]]` по **basename** (не по по - `.obsidian/`, аттачменты, dot-файлы, любые не-`.md` → **игнор** (не страницы), лежат в гите как есть, Obsidian ими владеет. Без `.gitignore`. -## Миграция со старого формата +## Без обратной совместимости -Существующие волты несут `docmost:meta` в файлах. - -- На первом цикле нового движка: если у файла нет frontmatter, но есть - `docmost:meta` → читаем pageId оттуда, переписываем файл в native-формат - (frontmatter id + чистое тело + folder-note layout), разовый «normalize» коммит. -- **Фолбэк навсегда**: `docmost:meta` всё ещё парсится как источник id, если - frontmatter нет (файл со старой системы). (Реализовано в `parsePageFile`.) +Старый `docmost:meta` формат НЕ поддерживаем (данные тестовые). Волт — кэш: на +переходе `rm -rf` волты спейсов, они пересобираются из Docmost сразу в native- +формате. `parsePageFile` не читает `docmost:meta`; файл без `gitmost_id` frontmatter +— это голый/рукописный файл → адопция (не legacy-страница). ## Краевые случаи @@ -117,11 +114,11 @@ Obsidian резолвит `[[Заметка]]` по **basename** (не по по ## План фаз (каждая — юниты движка + браузерный e2e + изолированные shell-e2e) 1. ✅ Формат файла: `parsePageFile`/`serializePageFile` (frontmatter id + тело, - фолбэк на legacy `docmost:meta`). Юниты. Без смены поведения. (готово) -2. PULL пишет native-формат (frontmatter + folder-note layout) + миграция. + `gitmost_id` frontmatter + тело). Юниты. Без смены поведения. (готово) +2. PULL пишет native-формат (frontmatter + folder-note layout). Волты wipe+rebuild. 3. PUSH берёт идентичность из frontmatter, родителя из пути. 4. Адопция голых файлов/папок. -5. Чистка: убрать `docmost:meta` из генерации (оставить фолбэк-парсер). +5. Чистка: выпилить старый `docmost:meta` формат-код целиком. 6. Ссылки: конвертер Docmost-mention ↔ `[[wikilink]]` + переписывание при retitle. ## Риски diff --git a/packages/git-sync/src/lib/page-file.ts b/packages/git-sync/src/lib/page-file.ts index 94fcd8ed..8faf44ec 100644 --- a/packages/git-sync/src/lib/page-file.ts +++ b/packages/git-sync/src/lib/page-file.ts @@ -1,25 +1,22 @@ -import { parseDocmostMarkdown } from "./markdown-document"; - /** - * The THIN page-file format (design: docs/backlog/git-sync-thin-meta.md, option - * C). A page file is CLEAN markdown with a minimal YAML frontmatter carrying ONLY - * the page's durable identity: + * The native-Obsidian page-file format (design: docs/backlog/git-sync-thin-meta.md). + * A page file is CLEAN markdown with a minimal YAML frontmatter carrying ONLY the + * page's durable identity: * * --- - * id: 019ef6fc-2638-7ce1-9ce3-2756ce038480 + * gitmost_id: 019ef6fc-2638-7ce1-9ce3-2756ce038480 * --- * * * Everything else is derived (title = filename, parentPageId = enclosing folder, - * spaceId = the vault, updatedAt = git). The `id` (a Docmost pageId) is the only - * non-derivable bit and travels WITH the file so identity survives any move, + * spaceId = the vault, updatedAt = git). `gitmost_id` (a Docmost pageId) is the + * only non-derivable bit and travels WITH the file so identity survives any move, * even one git's rename detection misses. Third-party editors (Obsidian, …) see * clean markdown; the frontmatter is hidden in their preview. * - * MIGRATION: a file may still carry the LEGACY `` block - * (the pre-thin format). `parsePageFile` reads the id from the frontmatter first, - * then falls back to the legacy meta — so old vaults keep working and a re-sync - * rewrites them into the thin format. + * No backward-compat with the old `docmost:meta` format: vaults are a cache, wiped + * and rebuilt native. A file WITHOUT a `gitmost_id` frontmatter is an un-tracked + * (e.g. hand-written) file -> the caller ADOPTS it (creates a page, writes the id). */ /** @@ -56,23 +53,12 @@ export function parsePageFile(full: string): { } { const text = (full ?? "").replace(/\r\n/g, "\n"); - // 1. Thin format: YAML frontmatter. + // Native format: a `gitmost_id` YAML frontmatter. Anything else (no frontmatter, + // or frontmatter without the key) is an un-tracked file -> adopt. const fm = text.match(FRONTMATTER_RE); if (fm) { return { id: readIdFromYaml(fm[1]), body: text.slice(fm[0].length).trim() }; } - - // 2. Legacy format: `` block (migration fallback). - if (/^\s*