Skip to content

AI-native knowledge base & Evernote/Obsidian alternative with instant sync & native MCP. Free on Cloudflare or self-hosted via Docker.

30.8 KB
Raw Blame

Third-party note import change scope

简体中文

Related: Issue #657. Contract: third-party import plan.

Problem and objective

Extend the former Evernote command-line guide entry with online, additive Web/desktop imports from Evernote, Obsidian and Joplin, preserving hierarchy, metadata, images and attachments. Preflight precedes writes; retries within a task reuse its created objects, while separate imports do not automatically merge existing data.

Feature scope and acceptance

ID Allowed behavior Acceptance
I01 Replace the guide card with shared third-party import while retaining the guide link. Web/desktop accept files, multiple ENEX files, directories, ZIPs, and Joplin JEX. Retain backup entries. Select every source from Settings; old backup/guide entries remain available.
I02 Add platform-neutral parsers, lazy source readers, and folder/resource indexes. Cover Evernote, Obsidian, Joplin RAW/Markdown/JEX under plan Section 3 without dropping notes based on resource directory names. Add export fixtures and expectations before implementation; verify nested paths, bodies, metadata, and resources.
I03 Map available metadata under Section 3. Warn on absent timestamps while retaining creation defaults; do not guess conflicting or timezone-ambiguous times. Preserve unknown Front Matter and encrypted source text. Check original instants, missing/conflicting metadata feedback, and recoverable source text.
I04 Preflight scans without remote writes and shows new notebook/note/resource counts, paths, destination identity, and issues. Users select top-level or an existing parent; no folder creation before confirmation. Dismissing preflight writes nothing; planned and actual counts agree.
I05 Add import capabilities and memo REST endpoints, reusing importMemosRecord, existing permissions, and 1–25-item batches. Fix source/item IDs per task. Unsupported older servers disable only this import entry with upgrade feedback. Real API checks for idempotency, isolation, item failures, and old endpoint compatibility.
I06 Create, upload, and rewrite one note at a time without text/title truncation or image recompression. Reuse a resource within one note; retain per-note ownership across notes. Expose already-supported optional update timestamps in the client; preserve source times and protect final writes using the import baseline and edit session. Read actual EdgeEver resources without source access; read back times, tags, final bodies, and non-overwriting conflicts.
I07 Preflight retains API limits: 80-character notebook names, 160-character titles, 100 MiB images, and 1 GiB attachments. Normalize tags in source order, remove empty/duplicate values and keep the first 24; ignore extras with a non-blocking preflight warning showing the ignored count. Explain ENEX export for .notes. Locate escaping paths, ambiguous/missing resources, and duplicate archive paths; do not follow symlinks, resolve external entities, or execute scripts. Optional-metadata warnings may be acknowledged. Invalid sources identify issues and block confirmation without writes; valid relative paths remain usable. Excess-tag imports from all three sources succeed and read back the first 24; task-local retry introduces neither conflicts nor duplicates.
I08 Scan/decompress in a Worker and page indexes into task-scoped IndexedDB. Do not buffer entire libraries of bodies/base64 or archives. Read ENEX sequentially twice; stage resources in chunks for existing multipart upload. Fail on exhausted temporary storage without whole-library memory fallback. Measure large ENEX fields and 1/4 GiB archives with fixed note counts, memory, disk use, cancellation, and cleanup.
I09 Workspace-owned controller, one active task per workspace. Bind identity/request context after confirmation; cancel on logout or instance/account changes and reject late cross-workspace results. Pause desktop sync, wait for active sync, release on every exit, then refresh. Check settings unmounts, identity changes, and sync/readback after success/failure/cancellation.
I10 Retain created notes while distinguishing incomplete, failed, cancelled, and unconfirmed outcomes. Task-local retry uses existing note/resource maps and missing steps only. Do not blindly replay uncertain directory/resource/final-update writes or delete existing data. New tasks remain additive. First note succeeds, second resource fails, third has not started; retry creates no duplicates, conflicts do not overwrite, uncertain writes are not reported successful.
I11 Add mature ZIP/SAX/TAR/incremental-MD5 dependencies and necessary build integration, client methods, shared subpath exports, existing locale text, and only relevant tests/sanitized evidence. Prove browser builds/large-field behavior; run targeted flows and the three required typecheck/build commands.

Unchanged boundaries

  • Preserve MCP imports, ordinary editing, offline queues, Rust structures, sync, backup and encrypted restore contracts. Apart from R28/R39's paging-index migrations, add no database structures, global required settings or authorization scopes.
  • No native mobile import entry, cross-run merging, resume after exiting the app, Obsidian plugin/inter-note conversion, remote-image capture or whole-library transaction rollback.
  • Keep installers, automatic updates, versions and release/deployment mechanisms unchanged. Existing Cloudflare upgrades retain the Worker, D1, R2, administrator and authentication Secret without resetting passwords or replacing the instance. Tests use authored sources and isolated directories, never personal libraries.

Important choices and evolution

Parse on the client and write through the shared API rather than adding a desktop offline-import protocol. This gives Web and Electron one behavior and Cloudflare and Docker one business implementation without extending Rust or sync protocols. Indexes contain locators and metadata; bodies and resources are read per note. Results retain only locators, version baselines and resource mappings rather than accumulating the library's bodies again.

The original rejection of more than 24 tags is superseded by I07/R11: normalize in source order, keep the first 24, ignore extras and warn. This retains the existing API storage boundary without blocking a library migration over surplus tags. Missing Joplin ancestors are export boundaries rather than invented folders; included cycles and invalid parent types remain errors.

Use mature Markdown parsers and serializers rather than global regex replacement or a dual-parser adapter. Optional image-link attributes fit the existing block-image schema; structural empty list paragraphs are handled only in the export projection, not by changing storage. Dependency choices follow the lockfile and actual TipTap contract, not drift in a local dependency directory.

Source, write and lifecycle repairs

ID Allowed behavior Acceptance
R01 Persist the unconfirmed marker before resource commit, retaining it after a lost response or failed mapping save. Repeated retries must not clear it and upload again. Lose a response after the real API commits a resource; repeated retries leave exactly one resource.
R02 Refresh folders after attempted directory writes fail or cancel before any note exists, after releasing the sync pause. Fail the second folder; read back the first and check release before refresh.
R03 Gate asynchronous pages/scan results by task generation and append concurrent copies of one page only once. Reject new RPCs while a Worker closes, avoiding stale state and hung promises. Control page/close response ordering; discard old results, prevent duplicate pages and reject new requests promptly.
R04 Key task identity by account and instance only; display-name changes retain the controller while updating its label. React rerender retains the controller for label changes; account/instance changes still replace and dispose it.
R05 Preserve task text and adjacent paragraphs after self-closing ENML todos. Read back checked/unchecked task labels and the following paragraph.
R06 Replace actual Markdown destination spans only, preserving nested labels, titles, reference uses and code. URI-encode literal fragment parentheses so existing attachment tokenizers do not truncate them. Reuse locked [email protected] with the existing GFM extension and decoding/identifier helpers as direct shared dependencies, without custom Markdown codecs. Remove the highlighting-AST/string-gate adapter. Upload both nested-link resources through the real API; retain labels/titles/reference definitions and ignore unused definitions.
R07 Distinguish explicitly selected archives from ordinary ZIP/JEX attachments inside a directory; expand only the former. Read original archive attachment bytes without extra notes; direct archive import continues working.
R08 Prefer the Vault root for non-explicit-relative Obsidian folder paths; treat Wiki filenames literally instead of URL-decoding them. Convert non-image Wiki embeds to existing readable attachment links, defaulting labels to filenames and retaining fragments. Remove the constant condition and unused alias lookup. Resolve root/local collisions to root bytes and import filenames containing a literal percent sign.
R09 Do not normalize invalid calendar dates into another day; retain existing invalid/missing-time warnings and creation defaults. Warn for February 30 in a non-leap year; preserve valid leap days and timezone instants.
R10 Classify RAW structure by source entry, not basename, preventing renamed RAW files from also becoming Markdown notes. A renamed RAW entry creates one note with unchanged hierarchy/resources.
R11 Canonicalize valid import tags before limiting to 24 (strip leading #, remove empty/duplicate values); replay comparisons use the server default for missing titles. Ordinary editing is unchanged. All three sources retain correct counts with hash-only/prefixed tags; retry after a lost create response for an untitled RAW note creates no duplicates or false conflicts.
R12 Do not apply the editor's 64 KiB property parsing budget to imported metadata. Preserve ordinary editing's limit and YAML syntax, mapping, alias and cycle protections. Retain original source; still persist only the first 24 tags. Import valid Front Matter larger than 64 KiB and read back title, times, 24 tags and complete source; existing ordinary property protections still pass.
R13 Follow Joplin's export contract: absent parents are the export boundary, while included hierarchy is preserved. A standalone note uses the existing default notebook; do not invent missing ancestors. Existing non-folder parents and cycles still fail. Import standalone RAW notes and a JEX subtree; read back hierarchy, body and resources. Invalid parent types and cycles still block preflight.
R14 Resolve decode-named-character-reference exactly to its own DOM-free default implementation in Web builds, fixing the import Worker's document is not defined. Development and production share this resolution with unchanged entity decoding semantics. Declare locked version 1.3.0 directly without upgrading other dependencies. Import ENEX and a Vault using the production build; verify Worker startup, entity/escaped paths, images and attachments.
R15 Attachment Markdown tokenizers must not consume partial links inside nested labels. Leave nested links/images to the existing Markdown engine; retain ordinary attachment recognition and persistence rules. A real imported nested image remains an image in saved JSON and the actual page; existing attachment and PDF cases pass.
R16 Preserve image outer links in optional link: { href, title } attributes throughout the shared image schema, Markdown parsing/export and aligned-image HTML. Split image paragraphs to fit the existing block-image schema, retaining container text order, required list paragraphs and galleries. Apply existing public-resource mapping to shared image outer links. Reuse locked [email protected] for link serialization and existing link safety rules without activating unsafe HTML targets or rewriting ordinary HTML anchors. Image previews, text links and sync/backup protocols remain unchanged. After real import, rich-text edit, save, reopen and export retain outer resource URL/title and image src/title. Custom schemas, lists/quotes, galleries and aligned images round-trip links; sharing URLs, ordinary anchors and safety checks pass.
R17 Preserve resource URL queries and fragments during public-share rewriting, covering image outer links and existing ordinary resource links. Replace only the resource base without changing permissions or share scope. Retain an image link's ?download=1#page=3 in memo/notebook shares and Markdown export without mutating the source object.
R18 Cancel scans during Worker initialization and preview loading: immediately invalidate that generation, return to selection and close its captured reader/index. Running cancellation still retains results and task-local retries. Initialization cancellation sends no scan; cancelled previews cannot publish late results, and old cleanup cannot close a newly selected reader.
R19 After attempted writes, refresh after releasing the sync pause even if Worker/temporary-resource cleanup fails. Preserve the cleanup error and completed writes. A real API write followed by a failing finishReading still runs release→finish→refresh; the result and note remain readable.
R20 Prefix source-folder result keys to separate them from the destination control record. Do not reject or rename a legal __destination source folder. Same-named ENEX creates a real child under an existing parent; a failed top-level import retries without duplicate creation.
R21 Recognize Joplin RAW/JEX metadata records that start directly with id: without a title/body separator. Non-note records, including note/tag associations, must not become notes; restore their tag relationships. Real Joplin 3.7.21 desktop RAW/JEX exports scan and import as 5 notes, 3 notebooks and 6 note-owned resources; keep 24 of 30 tags.
R22 Resolve Obsidian ZIP root resources inside a single top-level wrapper directory. Root .obsidian configuration contributes to root detection but is not imported. Preserve notebook paths, root-path precedence and directory archive attachments. Real Obsidian 1.14.5 Vault ZIP and unwrapped directory both read back 6 notes and 6 resources; root resources still win local-name collisions.
R23 Protect literal percent signs that are not two-hex-digit escapes before standard URI decoding of Markdown attachment paths. Wiki paths remain literal; traversal and invalid UTF-8 remain rejected. Joplin desktop Markdown / Front Matter exports resolve 说明%20100%.txt to the original bytes; existing traversal, ambiguity and Wiki percent cases still pass.
R24 Under I02's body/task preservation contract, recognize current Evernote ENEX --en-todo / --en-checked lists and --en-codeblock blocks, excluding hidden layout metadata from visible content. Reuse locked @mixmark-io/[email protected], already used by the clipper, for a detached DOM before Turndown and the existing GFM plugin handle lists, code blocks and escaping. Do not execute source styles/scripts; retain legacy en-todo support. A real Evernote 11.40.2 export first reproduces lost task states/formatting; real API and Web imports then read back checked/unchecked tasks, code blocks, headings, tables, tags, original timestamps and all five attachment bytes.
R25 Under I06's attachment preservation contract, label ENEX media with its original resource filename when alt is absent, retaining existing PDF recognition and preview controls. Normalize media to standard detached-DOM images/links and reuse Turndown escaping; existing alt still takes precedence. Resource context is an optional conversion-callback argument, preserving one-argument callers. The real export's PDF shows its filename and opens a preview; other attachments/images retain names and original bytes. Ordinary ENEX, task-local retries and existing callbacks still pass.
R26 Under I02's table preservation contract, put an ENML table's actual all-th first row in a standard thead, preventing colgroup from making the existing GFM plugin insert an empty header. Do not promote ordinary data rows. The same real ENEX's two-row table still has two rows after import, retaining the original header text.

Large-library reads and exports

Per-note creation previously called getNotebook with repeated COUNT/MAX, producing N × (N−1) cumulative memo-row aggregate contributions for N notes in one folder. Web exports also rescanned and sorted successive OFFSET pages. R27 uses lightweight existence checks; R28 gives updated clients indexed continuation while retaining legacy fields, ordering, OFFSET calls and backup consistency.

ID Allowed behavior Acceptance
R27 Use a lightweight ID/workspace/non-deleted lookup for boolean notebook existence checks in import/create, duplication, move/merge, child creation and parent changes. Preserve getNotebook statistics, permissions and existing missing-target errors. Reproduce cumulative aggregates through real imports/folder creation, then verify large note/folder operations do not recount notes. Missing, foreign-workspace and deleted targets retain their existing rejection contract.
R28 Add optional opaque cursor / nextCursor to browser JSON/ZIP and Markdown exports, retaining creation-time/ID ordering. A cursor carries the continuation position and traversed offset. Cursor requests omit repeated totals by default; explicit includeTotal=1 still returns totals. Only malformed new cursors return invalid_export_cursor / HTTP 400. Preserve legacy OFFSET requests, response fields, defaults and ordering. Updated consumers retain OFFSET traversal when a server provides no cursor, without adding older-server prerequisites. Add an incremental migration for a (workspace_id, is_deleted, created_at, id) memo index. Reproduce full page scans first. Verify complete ZIP/Markdown ordering, resources and revisions without gaps/duplicates, tied timestamps and selected-note filters. Upgrade a real prior schema/data set, preserving fields and old calls. Local whole-traversal work grows approximately linearly with indexed continuation queries.
R39 Add 0086_memo_id_paging_index.sql with only a (workspace_id, id) index on memos, allowing consistent-backup memo pages and initial sync to seek by workspace and ID range. Retain 0085; do not change business fields, triggers, queries, filters, cursors, page sizes, APIs or client defaults. Write a failing prior-schema regression before applying the migration. Retain existing data, complete traversal, workspace isolation and deleted-note behavior. Compare 1,000/4,000 notes without preceding ANALYZE for approximately linear reads, measuring actual D1 rows_read / rows_written, construction and insert costs. Existing creation-time exports must retain their 0085 index.

0085_export_cursor_index.sql adds one-time index-build reads and ongoing index write/storage costs without changing business fields. The main risk is skipped or duplicate page boundaries. Application rollback can restore old requests while leaving the index; removal requires another migration, never editing an executed file. Multipart upload retains P + 2 R2 Class A operations per resource and at most three attempts per part. Add no import caps, required settings, automatic retries or remote reads. Measure representative local data rather than load-testing Cloudflare.

Content preservation, staging and result state

ID Allowed behavior Acceptance
R29 Restore dependencies from the existing lockfile first and check the actual TipTap 3.31.4/shared marked contract; do not upgrade the parser to accommodate local dependency-directory drift. Repair Markdown round-trips for image-only list items, preserving bullet/ordered/task lists, checked state, adjacent text and nesting, plus image and outer-link targets. Keep the existing list schema without new persisted nodes or attributes. Reproduce under locked dependencies, then verify list structure, schema and linked images for existing JSON → Markdown → JSON and Markdown → JSON → Markdown. Check ordinary paragraphs, quotes and lists. Both typechecks, affected tests and Web build pass; exercise saving and reopening in the actual editor.
R30 Serialize ENML media and otherwise unreferenced attachments through existing Markdown tooling so unmatched brackets, backslashes and other label characters are escaped correctly. Display CR/LF in labels as spaces; uploaded filenames retain the existing API normalization (trim surrounding whitespace, replace path separators with hyphens, remove control characters and keep the first 160 characters). Resource bytes and upload rules are unchanged. Use the same mature Markdown serializer for shared images; derive image alt from parsed inline tokens and decode PDF/file labels with the existing micromark escape/entity decoder, keeping syntax escapes out of visible filenames. Keep original label escapes when tokenizing image outer links, reusing Marked’s built-in link/reflink grammar and lexer without new syntax or an HTML fallback. Retain explicit alt precedence and introduce no filename rejection. Import images/attachments with standalone ], [, backslashes, line breaks, spaces and percent signs through real HTTP. No evernote-resource: remains; image/attachment nodes and original bytes read back correctly. Existing URL-encoded path cases continue to pass.
R31 Persist a pending-confirmation marker before creating a source folder. Retain it when creation succeeds but local mapping persistence fails, or when the commit outcome is unknown, preventing blind task-local recreation. Definite server rejection retains existing retry behavior; do not create remotely if the marker cannot be stored. Real API runs simulate local-space failure before and after creation. After space recovers, safely retry or retain uncertainty without duplicate folders.
R32 Treat Joplin rawBinary entries as candidates, confirming a payload only through a valid type_: 4 RAW resource record belonging to a different source entry. Classify in stages without reading Markdown attachments in full. Unconfirmed Markdown remains a note regardless of resource-folder names or 32-character filenames. Plain and RAW-shaped Markdown attachments upload as resources without extra notes or full-text preflight reads. Valid Markdown in resource folders without RAW descriptors and renamed descriptors remain supported.
R33 Continue uploading identical same-note ENEX resources once. Remove staged chunks for deduplicated resources during per-note reading/release instead of accumulating them until task completion. Real imports with duplicate embedded resources create one resource, preserve original bytes and leave no duplicate chunks after releasing that note.
R34 Terminate ZIP read/write channels when decompression initialization, validation or cancellation fails so pending reads and cleanup settle. Retain existing error reporting without a password entry point or fallback. An unreadable valid encrypted ZIP promptly yields preflight errors; cancellation settles and ordinary ZIP reading/cleanup still work.
R35 Opening a result note hides the dialog without discarding the current task, folder mappings or retry state. Explicit result dismissal and importing another source retain their existing cleanup. Open an incomplete note, return to Settings and retry with the same task/IDs; explicit dismissal still cleans up.
R36 Use own-property semantics for filenames, MIME extensions and resource URL maps, safely storing legal keys such as __proto__ without treating prototype properties as MIME values or uploaded resources. Add no filename restrictions. Real uploads and retries of toString, constructor, __proto__ and related names preserve final URLs, MIME values and original bytes without duplicates.
R37 Store only required memo baselines in import results: IDs, notebook, revision/content fingerprint and source timestamps, not full Markdown/JSON/text. Clear intended Markdown after successful or confirmed commits; retain commit-comparison content only for the current incomplete item. Multiple large completed notes leave no full bodies in the result index or UI snapshots. Lost-final-response verification, task-local retries and concurrent-edit protection still pass.
R38 Use Turndown’s existing asterisk emphasis option for ENML so default underscores do not become literal text between adjacent Chinese characters. Preserve bold, links, tables and attachments without changing shared Markdown syntax. The real Evernote export retains Chinese italics in saved API JSON and the Web page; bold and other formatting still pass.
R40 Keep images inside ENML links inline so Markdown conversion preserves the outer URL/title, image target and label in saved content. Ordinary images and attachments retain existing block layout, escaping and upload behavior. Add no image attributes or rendering-safety changes. Reproduce the lost outer link first. Import directly linked images and images nested in inline elements through the real API; check saved JSON, Markdown round-trips and saving/reopening. Existing ordinary-media cases still pass.
R41 Preserve external URIs in standard Markdown, including FTP and Obsidian protocols, without resolving them as local attachments, reading their targets, activating new protocols or adding preflight warnings. Keep rejecting file: and Windows drive forms under existing local-path rules; retain traversal, invalid local encoding and literal Wiki-path behavior. Reproduce FTP/Obsidian URIs being reported as outsideRoot first. Verify error-free Obsidian/Joplin preflight, no resource uploads and unchanged URI text after real import. Traversal, file:, drive paths and invalid local encoding remain rejected.

R40 removes block wrapping only for linked images, retaining R24/R25's ordinary-media layout rather than changing all ENML formatting. R41 separates URI classification from local resource lookup without extending a protocol allowlist or weakening path validation. Existing rendering-safety rules still decide whether a link may be activated.

Delivery contents

ID Allowed behavior Acceptance
C01 Keep only concise bilingual acceptance conclusions in the evidence directory. Move screenshots, response captures, installation details and one-off scripts out, and update dependent documentation. Retain minimal authored source fixtures and independent expected bytes directly consumed by integration tests, marking the PDF fixture as binary in Git to preserve its format bytes. Remove the same temporary artifacts from unpublished feature history, retaining recovery copies outside the repository. Neither the current tree nor history to be pushed contains these temporary artifacts. Tests still consume retained fixtures, and documentation has no broken references.
C02 Remove the unreferenced EvernoteImportGuideCard.tsx; retain the legacy guide page, route, links and still-used translations. Reference checks and Web build pass; the import entry and guide route remain usable.

Keep screenshots and operational records outside Git and attach images to the PR. The repository retains bilingual conclusions, maintainable tests and the authored source fixtures they consume. Preserve an independent recovery copy before cleaning unpublished history; do not rewrite other branches.

D1 paging reads

R39 adds a (workspace_id, id) index, its migration, paging regressions and read/write-cost validation. Retain APIs, clients, the backup protocol and existing migration 0085. See plan section 9 for the choice, index costs, prior-schema upgrade acceptance and rollback. Unchanged-backup probing and search-index deduplication are outside this iteration.

R39's migration, prior-schema upgrade and contract regressions pass locally. Actual D1 row counts confirm approximately linear reads and one additional index-row write per inserted memo. APIs, clients and runtime business code are unchanged. Production migration and complete-flow usage remain deployment acceptance work.

Risks and rollback

Import is high-risk data writing: partial new objects, duplicates, incorrect timestamps and resource references are the worst outcomes. Append only, retain sources, item outcomes and commit baselines; cancellation does not undo completed writes and code rollback does not delete imported notes. Removing the entry/routes leaves imported data usable as ordinary notes. Cleanup requires confirmed actual IDs, never bulk deletion by name.

Shared codec repairs affect editing round-trips for images, lists and attachment labels. Use source Markdown, original JSON and independent resource bytes as expectations; do not rewrite historical notes automatically. Before deployment, retain the Worker version, private D1 backup and an independent recovery entry. Stop later deployment steps if migrations or key acceptance fail and restore from these materials as needed.

Completion reconciliation

I01–I11, R01–R41 and C01/C02 are implemented; every behavior in the task diff maps to these entries, with no additional input restrictions, permissions or sync/backup protocol changes. Focused checks cover source formats, hierarchy/metadata/original bytes, failure retries, concurrent-edit protection and resource cleanup. See acceptance conclusions for the conditions and measurements of large-library reads, cursor exports, real-browser preflight and large-body result retention. Both typechecks, the Web build and targeted lint pass.

R40/R41 regressions reproduce the original failures before repair; all 24 affected checks pass afterwards. Production Web with real Worker/IndexedDB and an isolated API imports linked images, edits/saves and reopens them with outer links and original image bytes intact. External-URI preflight allows confirmation and actual import retains source text with no resource uploads. Obsidian/Joplin API regressions and existing local-path rejection checks pass.

Cloudflare has R27–R30 and 0085; the acceptance document records the real prior-instance upgrade and readback. R31–R41 and 0086 are not deployed. Earlier macOS/Linux native results do not cover the latest repairs. Windows native, USB mobile devices, older-client editing, AppImage installation/cross-version updates and Docker container deployment remain unverified; builds and driver-level checks do not replace those flows.