Commit Graph

7 Commits

Author SHA1 Message Date
vvzvlad
5826255a2f feat(sync): runnable FS->Docmost push (dry-run default, --apply writes)
Wire the push cycle (SPEC §6) into a runnable command; SAFE BY DEFAULT.

- runPush + main(): dry-run by default (plan only, ZERO Docmost writes, no ref
  advance); --apply is the ONLY path that builds a client and mutates Docmost
- orchestration mirrors pull.ts: assertGitAvailable -> ensureRepo ->
  merge-in-progress guard (§9/§12) -> checkout main -> commit local working tree
  (Docmost-Sync-Source: local, §7.3) -> base = refs/docmost/last-pushed else
  docmost -> diffNameStatus(base, main) -> computePushActions -> (apply) ->
  write-back created pageIds + advance refs; divergent-docmost escalates (exit 1)
- npm run push (dry-run) / npm run push -- --apply (writes; needs creds)
- fix (review Blocker): pass the WHOLE VaultGit to applyPushActions (bare method
  refs lost `this` -> --apply crashed on real git); regression test exercises the
  --apply path against a REAL VaultGit temp repo + fake client (proven to catch it)
- symmetric divergent-docmost escalation in both ff branches; dry-run logs the
  local commit explicitly; SPEC §6 notes the dry-run/local-commit behavior
- 737 -> 747 green (x2 stable); build clean; corpus STABLE

Deferred (daemon increment): FS-watcher/debounce (§7.1), git-remote push (§7.2),
continuous poll loop, pull-side §10 record consumption, fractional-index position.
2026-06-21 02:30:46 +03:00
vvzvlad
4b34f4d30a feat(sync): resolve §11 idempotency via canonical comparison + corpus harness
Close Задача №0 (SPEC §11) with the spec-sanctioned option (b): compare a
canonicalized ProseMirror form instead of raw bytes.

- canonicalize.ts: canonicalizeContent/docsCanonicallyEqual — strip node attrs.id,
  drop null/undefined attrs, and drop attrs equal to their type's known non-null
  schema default (KNOWN_DEFAULTS: link target/rel, comment.resolved, orderedList.start,
  diagram/media align) so "absent" ≡ "default"; comment anchors + meaningful attrs kept
- roundtrip.ts: assert markdown byte-stability AND canonical stability; add --corpus
  mode and mutually-exclusive-flag warning
- synthetic corpus (headings, marks, lists, table, callout, code w/ trailing \n,
  diagrams, textStyle/mention) + canonicalize/corpus tests (558 green)
- known converter asymmetries (block image after paragraph; embed width/height
  coercion) converge to a fixpoint after one export->import pass -> handled by
  normalize-on-write at vault-write time; isolated under it.fails
- SPEC §11: record the resolution and normalize-on-write strategy
2026-06-16 23:23:32 +03:00
vvzvlad
447d2508ae feat(sync): scaffold monorepo, extract docmost-client, add Phase-0 harness + read-only pull
Lock the access-layer decision (REST only) and start implementation per SPEC.

- monorepo (npm workspaces): packages/docmost-client = DocmostClient + lib/*
  copied 1:1 from docmost-mcp/src (backport target), plus bannered sync methods
  (listTrash, restorePage, listAllSpacePages, exportPageBody, listRecentSince /
  collectRecentSince cursor scan)
- engine stays the root app per AGENTS.md (src/, test/, build/, data/, settings.ts);
  add roundtrip.ts (SPEC §11 idempotency harness), pull.ts (SPEC §6 read-only
  Docmost->FS mirror), sanitize.ts (SPEC §12 filenames, path-traversal-safe)
- Dockerfile builds the workspace lib before the app; vitest gates CI
- exportPageBody never touches /comments (SPEC §3); serializeDocmostMarkdownBody
  emits meta + body only
- SPEC: resolve access-layer (REST), reflect root-engine layout + REST pagination
- tests: sanitize (incl. dot-traversal), collectRecentSince (cutoff/dedup/cap),
  stripBlockIds, markdown round-trip byte-stability

Note: raw ProseMirror round-trip is byte-stable in Markdown but not yet attribute-
idempotent (SPEC §11 Задача №0, before Phase 2).
2026-06-16 20:20:20 +03:00
vvzvlad
2f92dc4c1f docs(spec): add monorepo implementation and access layer notes
Add documentation of the monorepo layout, describing the `docmost-client` and `sync` packages and their responsibilities. Clarify that all Docmost access is performed via REST for reads, while writes use collab/Yjs, documenting the architectural decision and its rationale.
2026-06-16 19:11:53 +03:00
vvzvlad
cc584a97f3 docs(spec): resolve remaining §12 open questions; expand §16 REST map
Research Docmost source (docmost/docmost@main) to close the last four §12 items.

- auth: dedicated service user; API-key (EE/Cloud) vs login JWT (OSS, 90d default,
  no refresh, session-bound) with "401 -> re-login"
- position: reuse `fractional-indexing-jittered` generateJitteredKeyBetween,
  siblings via /sidebar-pages, compare as raw bytes (COLLATE "C")
- initial clone: canonical = sidebar-pages walk + /info via our converter;
  spaces/export (turndown markdown, no meta/anchors) is bootstrap-only, not baseline
- attachments: v1 keeps them as links (out of scope), includeAttachments flag noted
- §16: add auth/JWT/API-key facts, /sidebar-pages, bulk export endpoints,
  extra gotchas (collation, throttling, EE-only API keys)
- park "REST vs direct Postgres" as the sole remaining open question
2026-06-16 18:54:10 +03:00
vvzvlad
42eb986596 docs(spec): resolve open questions §12 and add confirmed Docmost REST map
Research Docmost source (docmost/docmost@main) to pin real REST endpoints
and close all five §12 TODOs.

- §6: replace MCP `list_pages` polling with the real "changes since T"
  mechanism — `POST /api/pages/recent` (updatedAt DESC, cursor) + client cutoff
- §8: concrete trash/restore endpoints (per-space `trash`, `restore`),
  auto-purge note and `permanentlyDelete` guard
- §10: add `lastUpdatedById` loop-guard signal
- §12: turn open questions into decisions (trash/restore, changes-since-T,
  commit-attribution trailer, filename collisions, long-offline reconciliation);
  add a new list of genuinely-open items
- §15/§16: add the confirmed Docmost REST map (auth, info, recent, create,
  update, move, move-to-space, delete, trash, restore) with gotchas
- fix a nested-list markdown glitch in §12
2026-06-16 18:37:50 +03:00
vvzvlad
d5cd1bba02 docs: add project spec and VS Code workspace 2026-06-16 18:30:04 +03:00