supernote 0.23.0__tar.gz → 0.24.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (209) hide show
  1. {supernote-0.23.0 → supernote-0.24.0}/PKG-INFO +38 -53
  2. {supernote-0.23.0 → supernote-0.24.0}/README.md +36 -50
  3. {supernote-0.23.0 → supernote-0.24.0}/pyproject.toml +3 -4
  4. supernote-0.24.0/supernote/__init__.py +31 -0
  5. supernote-0.24.0/supernote/alembic/versions/a2b3c4d5e6f7_scope_summary_unique_identifier_by_user.py +68 -0
  6. supernote-0.24.0/supernote/alembic/versions/b7397248a96b_merge_mixed_case_system_roots.py +142 -0
  7. supernote-0.24.0/supernote/alembic/versions/c1d2e3f4a5b6_add_embedding_model_to_note_page_content.py +62 -0
  8. supernote-0.24.0/supernote/alembic/versions/c3d4e5f6a7b8_seed_sync_initialized_for_existing_users.py +43 -0
  9. supernote-0.24.0/supernote/alembic/versions/d4e5f6a7b8c9_unify_schedule_ids_as_string.py +143 -0
  10. supernote-0.24.0/supernote/alembic/versions/e7f8a9b0c1d2_add_update_time_to_schedule_task_group.py +39 -0
  11. supernote-0.24.0/supernote/alembic/versions/f1a2b3c4d5e6_make_schedule_task_list_id_nullable.py +49 -0
  12. {supernote-0.23.0 → supernote-0.24.0}/supernote/cli/admin.py +195 -18
  13. {supernote-0.23.0 → supernote-0.24.0}/supernote/cli/client.py +7 -5
  14. {supernote-0.23.0 → supernote-0.24.0}/supernote/client/__init__.py +3 -11
  15. {supernote-0.23.0 → supernote-0.24.0}/supernote/client/admin.py +61 -5
  16. {supernote-0.23.0 → supernote-0.24.0}/supernote/client/client.py +51 -7
  17. {supernote-0.23.0 → supernote-0.24.0}/supernote/client/device.py +11 -3
  18. {supernote-0.23.0 → supernote-0.24.0}/supernote/client/login_client.py +20 -4
  19. {supernote-0.23.0 → supernote-0.24.0}/supernote/client/schedule.py +81 -17
  20. {supernote-0.23.0 → supernote-0.24.0}/supernote/client/socket.py +50 -43
  21. {supernote-0.23.0 → supernote-0.24.0}/supernote/client/summary.py +14 -12
  22. {supernote-0.23.0 → supernote-0.24.0}/supernote/client/web.py +53 -10
  23. {supernote-0.23.0 → supernote-0.24.0}/supernote/models/__init__.py +1 -0
  24. {supernote-0.23.0 → supernote-0.24.0}/supernote/models/auth.py +13 -17
  25. {supernote-0.23.0 → supernote-0.24.0}/supernote/models/base.py +18 -6
  26. {supernote-0.23.0 → supernote-0.24.0}/supernote/models/equipment.py +60 -0
  27. {supernote-0.23.0 → supernote-0.24.0}/supernote/models/file_device.py +1 -1
  28. {supernote-0.23.0 → supernote-0.24.0}/supernote/models/file_web.py +10 -1
  29. {supernote-0.23.0 → supernote-0.24.0}/supernote/models/schedule.py +13 -3
  30. supernote-0.24.0/supernote/models/socket.py +452 -0
  31. {supernote-0.23.0 → supernote-0.24.0}/supernote/models/system.py +56 -1
  32. supernote-0.24.0/supernote/models/webhook.py +64 -0
  33. {supernote-0.23.0 → supernote-0.24.0}/supernote/notebook/converter.py +61 -52
  34. {supernote-0.23.0 → supernote-0.24.0}/supernote/notebook/decoder.py +31 -17
  35. {supernote-0.23.0 → supernote-0.24.0}/supernote/notebook/fileformat.py +8 -1
  36. {supernote-0.23.0 → supernote-0.24.0}/supernote/notebook/parser.py +85 -54
  37. supernote-0.24.0/supernote/server/ai/__init__.py +22 -0
  38. supernote-0.24.0/supernote/server/ai/base.py +16 -0
  39. supernote-0.24.0/supernote/server/ai/models/__init__.py +27 -0
  40. supernote-0.24.0/supernote/server/ai/models/embedding.py +126 -0
  41. supernote-0.24.0/supernote/server/ai/models/fake/__init__.py +7 -0
  42. supernote-0.24.0/supernote/server/ai/models/fake/embedding.py +51 -0
  43. supernote-0.24.0/supernote/server/ai/models/fake/ocr.py +42 -0
  44. supernote-0.24.0/supernote/server/ai/models/fake/summary.py +62 -0
  45. supernote-0.24.0/supernote/server/ai/models/gemini/__init__.py +8 -0
  46. supernote-0.24.0/supernote/server/ai/models/gemini/backend.py +127 -0
  47. supernote-0.24.0/supernote/server/ai/models/gemini/embedding.py +55 -0
  48. supernote-0.24.0/supernote/server/ai/models/gemini/ocr.py +58 -0
  49. supernote-0.24.0/supernote/server/ai/models/gemini/summary.py +59 -0
  50. supernote-0.24.0/supernote/server/ai/models/ocr.py +89 -0
  51. supernote-0.24.0/supernote/server/ai/models/openai/__init__.py +13 -0
  52. supernote-0.24.0/supernote/server/ai/models/openai/backend.py +131 -0
  53. supernote-0.24.0/supernote/server/ai/models/openai/embedding.py +49 -0
  54. supernote-0.24.0/supernote/server/ai/models/openai/ocr.py +59 -0
  55. supernote-0.24.0/supernote/server/ai/models/openai/summary.py +60 -0
  56. supernote-0.24.0/supernote/server/ai/models/summary.py +91 -0
  57. supernote-0.24.0/supernote/server/ai/prompts.py +139 -0
  58. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/app.py +119 -225
  59. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/config.py +247 -11
  60. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/constants.py +17 -8
  61. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/db/migrations.py +10 -1
  62. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/db/models/note_processing.py +3 -0
  63. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/db/models/schedule.py +16 -35
  64. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/db/models/summary.py +17 -5
  65. supernote-0.24.0/supernote/server/events.py +210 -0
  66. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/exceptions.py +26 -0
  67. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/mcp/auth.py +41 -17
  68. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/mcp/models.py +50 -2
  69. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/mcp/server.py +66 -5
  70. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/metrics.py +13 -0
  71. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/routes/admin.py +131 -23
  72. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/routes/auth.py +167 -49
  73. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/routes/extended.py +47 -12
  74. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/routes/file_device.py +115 -45
  75. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/routes/file_web.py +91 -22
  76. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/routes/oss.py +248 -53
  77. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/routes/schedule.py +81 -26
  78. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/routes/summary.py +121 -24
  79. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/services/__init__.py +1 -0
  80. supernote-0.24.0/supernote/server/services/blob.py +351 -0
  81. supernote-0.24.0/supernote/server/services/conversion.py +175 -0
  82. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/services/coordination.py +28 -15
  83. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/services/file.py +486 -300
  84. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/services/ical_export.py +4 -13
  85. supernote-0.24.0/supernote/server/services/integrity.py +974 -0
  86. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/services/processor.py +258 -70
  87. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/services/processor_modules/__init__.py +24 -5
  88. supernote-0.23.0/supernote/server/services/processor_modules/gemini_embedding.py → supernote-0.24.0/supernote/server/services/processor_modules/embedding.py +27 -34
  89. supernote-0.23.0/supernote/server/services/processor_modules/gemini_ocr.py → supernote-0.24.0/supernote/server/services/processor_modules/ocr.py +26 -40
  90. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/services/processor_modules/page_hashing.py +41 -40
  91. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/services/processor_modules/png_conversion.py +37 -14
  92. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/services/processor_modules/summary.py +83 -138
  93. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/services/schedule.py +182 -65
  94. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/services/search.py +53 -22
  95. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/services/summary.py +312 -69
  96. supernote-0.24.0/supernote/server/services/user.py +830 -0
  97. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/services/vfs.py +266 -40
  98. supernote-0.24.0/supernote/server/services/webhook.py +254 -0
  99. supernote-0.24.0/supernote/server/socket.py +725 -0
  100. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/socket_auth.py +1 -30
  101. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/static/index.html +38 -5
  102. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/static/js/api/client.js +204 -1
  103. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/static/js/api/schedule.js +19 -14
  104. supernote-0.24.0/supernote/server/static/js/components/FileCard.js +163 -0
  105. supernote-0.24.0/supernote/server/static/js/components/FileViewer.js +461 -0
  106. supernote-0.24.0/supernote/server/static/js/components/MoveModal.js +213 -0
  107. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/static/js/components/SearchModal.js +15 -8
  108. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/static/js/components/TaskPanel.js +42 -17
  109. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/static/js/composables/useFileSystem.js +12 -4
  110. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/static/js/composables/useSchedule.js +15 -10
  111. supernote-0.24.0/supernote/server/static/js/composables/useToast.js +31 -0
  112. supernote-0.24.0/supernote/server/static/js/main.js +708 -0
  113. supernote-0.24.0/supernote/server/trace.py +256 -0
  114. supernote-0.24.0/supernote/server/utils/paths.py +86 -0
  115. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/utils/prompt_loader.py +1 -1
  116. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/utils/rate_limit.py +12 -2
  117. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/utils/tasks.py +10 -2
  118. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/utils/url_signer.py +40 -24
  119. {supernote-0.23.0 → supernote-0.24.0}/supernote.egg-info/PKG-INFO +38 -53
  120. {supernote-0.23.0 → supernote-0.24.0}/supernote.egg-info/SOURCES.txt +35 -4
  121. {supernote-0.23.0 → supernote-0.24.0}/supernote.egg-info/requires.txt +0 -1
  122. supernote-0.23.0/supernote/__init__.py +0 -28
  123. supernote-0.23.0/supernote/models/socket.py +0 -226
  124. supernote-0.23.0/supernote/server/events.py +0 -62
  125. supernote-0.23.0/supernote/server/services/blob.py +0 -208
  126. supernote-0.23.0/supernote/server/services/gemini.py +0 -103
  127. supernote-0.23.0/supernote/server/services/integrity.py +0 -112
  128. supernote-0.23.0/supernote/server/services/user.py +0 -484
  129. supernote-0.23.0/supernote/server/socket.py +0 -185
  130. supernote-0.23.0/supernote/server/static/js/components/FileCard.js +0 -98
  131. supernote-0.23.0/supernote/server/static/js/components/FileViewer.js +0 -192
  132. supernote-0.23.0/supernote/server/static/js/components/MoveModal.js +0 -74
  133. supernote-0.23.0/supernote/server/static/js/main.js +0 -425
  134. supernote-0.23.0/supernote/server/utils/gemini_content.py +0 -52
  135. supernote-0.23.0/supernote/server/utils/paths.py +0 -57
  136. {supernote-0.23.0 → supernote-0.24.0}/LICENSE +0 -0
  137. {supernote-0.23.0 → supernote-0.24.0}/setup.cfg +0 -0
  138. {supernote-0.23.0 → supernote-0.24.0}/supernote/alembic/__init__.py +0 -0
  139. {supernote-0.23.0 → supernote-0.24.0}/supernote/alembic/env.py +0 -0
  140. {supernote-0.23.0 → supernote-0.24.0}/supernote/alembic/script.py.mako +0 -0
  141. {supernote-0.23.0 → supernote-0.24.0}/supernote/alembic/versions/0543a383957b_initial_schema.py +0 -0
  142. {supernote-0.23.0 → supernote-0.24.0}/supernote/alembic/versions/68964804740d_prevent_user_id_reuse.py +0 -0
  143. {supernote-0.23.0 → supernote-0.24.0}/supernote/alembic/versions/7a8291f043bc_add_links_and_sort_fields_to_schedule_task.py +0 -0
  144. {supernote-0.23.0 → supernote-0.24.0}/supernote/alembic/versions/b8e9c0d1e2f3_backfill_summary_md5_and_timestamps.py +0 -0
  145. {supernote-0.23.0 → supernote-0.24.0}/supernote/alembic/versions/d1e2f3a4b5c6_add_client_task_ids.py +0 -0
  146. {supernote-0.23.0 → supernote-0.24.0}/supernote/alembic.ini +0 -0
  147. {supernote-0.23.0 → supernote-0.24.0}/supernote/cli/__init__.py +0 -0
  148. {supernote-0.23.0 → supernote-0.24.0}/supernote/cli/main.py +0 -0
  149. {supernote-0.23.0 → supernote-0.24.0}/supernote/cli/notebook.py +0 -0
  150. {supernote-0.23.0 → supernote-0.24.0}/supernote/cli/server.py +0 -0
  151. {supernote-0.23.0 → supernote-0.24.0}/supernote/client/api.py +0 -0
  152. {supernote-0.23.0 → supernote-0.24.0}/supernote/client/auth.py +0 -0
  153. {supernote-0.23.0 → supernote-0.24.0}/supernote/client/exceptions.py +0 -0
  154. {supernote-0.23.0 → supernote-0.24.0}/supernote/client/extended.py +0 -0
  155. {supernote-0.23.0 → supernote-0.24.0}/supernote/client/hashing.py +0 -0
  156. {supernote-0.23.0 → supernote-0.24.0}/supernote/models/extended.py +0 -0
  157. {supernote-0.23.0 → supernote-0.24.0}/supernote/models/file_common.py +0 -0
  158. {supernote-0.23.0 → supernote-0.24.0}/supernote/models/summary.py +0 -0
  159. {supernote-0.23.0 → supernote-0.24.0}/supernote/models/user.py +0 -0
  160. {supernote-0.23.0 → supernote-0.24.0}/supernote/notebook/__init__.py +0 -0
  161. {supernote-0.23.0 → supernote-0.24.0}/supernote/notebook/color.py +0 -0
  162. {supernote-0.23.0 → supernote-0.24.0}/supernote/notebook/exceptions.py +0 -0
  163. {supernote-0.23.0 → supernote-0.24.0}/supernote/notebook/manipulator.py +0 -0
  164. {supernote-0.23.0 → supernote-0.24.0}/supernote/notebook/utils.py +0 -0
  165. {supernote-0.23.0 → supernote-0.24.0}/supernote/py.typed +0 -0
  166. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/__init__.py +0 -0
  167. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/db/__init__.py +0 -0
  168. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/db/base.py +0 -0
  169. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/db/models/__init__.py +0 -0
  170. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/db/models/device.py +0 -0
  171. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/db/models/file.py +0 -0
  172. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/db/models/kv.py +0 -0
  173. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/db/models/login_record.py +0 -0
  174. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/db/models/user.py +0 -0
  175. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/db/session.py +0 -0
  176. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/mcp/__init__.py +0 -0
  177. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/resources/__init__.py +0 -0
  178. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/resources/prompts/__init__.py +0 -0
  179. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/resources/prompts/ocr/common/context.md +0 -0
  180. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/resources/prompts/ocr/common/legend.md +0 -0
  181. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/resources/prompts/ocr/daily/prompt.md +0 -0
  182. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/resources/prompts/ocr/default/system.md +0 -0
  183. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/resources/prompts/ocr/monthly/prompt.md +0 -0
  184. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/resources/prompts/ocr/weekly/prompt.md +0 -0
  185. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/resources/prompts/summary/common/instruction.md +0 -0
  186. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/resources/prompts/summary/daily/prompt.md +0 -0
  187. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/resources/prompts/summary/default/prompt.md +0 -0
  188. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/resources/prompts/summary/monthly/prompt.md +0 -0
  189. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/resources/prompts/summary/weekly/prompt.md +0 -0
  190. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/routes/decorators.py +0 -0
  191. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/routes/system.py +0 -0
  192. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/static/favicon.ico +0 -0
  193. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/static/js/components/DashboardView.js +0 -0
  194. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/static/js/components/LoginCard.js +0 -0
  195. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/static/js/components/RenameModal.js +0 -0
  196. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/static/js/components/Sidebar.js +0 -0
  197. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/static/js/components/SummaryPanel.js +0 -0
  198. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/static/js/components/SystemPanel.js +0 -0
  199. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/static/style.css +0 -0
  200. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/utils/auth_utils.py +0 -0
  201. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/utils/hashing.py +0 -0
  202. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/utils/note_content.py +0 -0
  203. {supernote-0.23.0 → supernote-0.24.0}/supernote/server/utils/unique_id.py +0 -0
  204. {supernote-0.23.0 → supernote-0.24.0}/supernote/testing/__init__.py +0 -0
  205. {supernote-0.23.0 → supernote-0.24.0}/supernote/testing/server_runner.py +0 -0
  206. {supernote-0.23.0 → supernote-0.24.0}/supernote.egg-info/dependency_links.txt +0 -0
  207. {supernote-0.23.0 → supernote-0.24.0}/supernote.egg-info/entry_points.txt +0 -0
  208. {supernote-0.23.0 → supernote-0.24.0}/supernote.egg-info/top_level.txt +0 -0
  209. {supernote-0.23.0 → supernote-0.24.0}/tests/test_init.py +0 -0
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: supernote
3
- Version: 0.23.0
3
+ Version: 0.24.0
4
4
  Summary: All-in-one toolkit for Supernote devices: parse notebooks, self-host services, access services
5
- Author-email: jya <jya@wizmy.net>, Allen Porter <allen.porter@gmail.com>
5
+ Author-email: Allen Porter <allen.porter@gmail.com>
6
6
  License-Expression: Apache-2.0
7
7
  Project-URL: Source, https://github.com/allenporter/supernote
8
8
  Requires-Python: >=3.13
@@ -12,7 +12,6 @@ Requires-Dist: colour>=0.1.5
12
12
  Requires-Dist: numpy>=1.19.0
13
13
  Requires-Dist: Pillow>=7.2.0
14
14
  Requires-Dist: potracer>=0.0.1
15
- Requires-Dist: pypng>=0.0.20
16
15
  Requires-Dist: reportlab>=3.6.1
17
16
  Requires-Dist: svgwrite>=1.4
18
17
  Provides-Extra: client
@@ -46,7 +45,7 @@ Dynamic: license-file
46
45
 
47
46
  **A lightweight, self-hosted private cloud server and optional AI intelligence layer for your Ratta Supernote.**
48
47
 
49
- This toolkit is a self-hosted, SQLite-based implementation of the **Supernote Private Cloud** protocol. It provides a simple and resource-efficient sync server with a minimal resource footprint (typically ~200MB idle memory, and 300–400MB to process large notebooks). It implements **100% of the community [Supernote OpenAPI Specification](api-spec/openapi.yaml)**, and can optionally be enhanced with an **AI-driven synthesis engine**—transforming your handwritten notes into structured, searchable knowledge using Google Gemini.
48
+ This toolkit is a self-hosted, SQLite-based implementation of the **Supernote Private Cloud** protocol. It provides a simple and resource-efficient sync server with a minimal resource footprint (~135MB flat in bare sync mode, or ~160MB idle and ~310MB peak when rendering and processing large notebooks). It implements **100% of the community [Supernote OpenAPI Specification](api-spec/openapi.yaml)**, and can optionally be enhanced with an **AI-driven synthesis engine**—transforming your handwritten notes into structured, searchable knowledge using Google Gemini or local OpenAI-compatible models (such as Ollama).
50
49
 
51
50
  <p align="center">
52
51
  <img src="docs/static-assets/hero-overview.jpg" alt="Supernote Overview" width="800">
@@ -59,11 +58,11 @@ This toolkit is a self-hosted, SQLite-based implementation of the **Supernote Pr
59
58
 
60
59
  This project is designed to be **fully compatible** with the official Supernote Private Cloud protocol, serving as a lightweight alternative that operates on a single SQLite database and runs comfortably on low-power NAS setups and home lab servers:
61
60
 
62
- - **⚡ Lightweight Sync**: Runs on a simple, efficient Python/Asyncio stack with SQLite. Consumes ~200MB of idle memory (recommending 300–400MB for notebook processing).
61
+ - **⚡ Lightweight Sync**: Runs on a simple, efficient Python/Asyncio stack with SQLite. Consumes ~135MB in bare sync mode, or ~160MB idle (~310MB peak) with the Web UI, MCP server, and background notebook processing enabled.
63
62
  - **📋 OpenAPI Spec Compliant**: Implements **100% of the community [Supernote OpenAPI specification](api-spec/openapi.yaml)**.
64
63
  - **🛡️ Private & Secure**: You own your database and files. Runs locally on your NAS or local server with no external data leakage.
65
64
  - **🖥️ Sleek Web UI**: Browse notes, manage tasks, and export iCalendar (`.ics`) task feeds for Home Assistant, Apple Calendar, Google Calendar, and Outlook.
66
- - **📜 Optional AI Synthesis**: If configured with a Gemini API key, it automatically transcribes handwriting and generates summaries (Daily, Weekly, Monthly).
65
+ - **📜 Optional AI Synthesis**: When configured with an AI provider (Google Gemini or a local OpenAI-compatible model such as Ollama), it automatically transcribes handwriting and generates summaries (Daily, Weekly, Monthly).
67
66
  - **🔍 Optional Semantic Search**: Vectorizes content for concept-based search across all notebooks.
68
67
  - **🤖 Agent Ready (MCP)**: Securely connect your notes to AI agents (Claude, Gemini, ChatGPT) via the built-in [Model Context Protocol](https://modelcontextprotocol.io/) server.
69
68
 
@@ -72,7 +71,7 @@ This project is designed to be **fully compatible** with the official Supernote
72
71
  Beyond simple storage, Supernote provides an active processing pipeline to increase the utility of your notes:
73
72
 
74
73
  1. **Sync**: Your device uploads `.note` files using the official Private Cloud protocol.
75
- 2. **Transcribe**: The server extract pages and use Gemini Vision to OCR your handwriting.
74
+ 2. **Transcribe**: The server extracts pages and uses a vision model (Gemini or local VLM) to OCR your handwriting.
76
75
  3. **Synthesize**: AI Analyzers review your journals to find tasks, themes, and summaries.
77
76
  4. **Index**: Every word is vectorized, enabling semantic search across your entire library.
78
77
 
@@ -98,7 +97,7 @@ You can run the server either as a **Lite Sync Server (Zero-Config)** or with th
98
97
  Choose one of the options below to start the server.
99
98
 
100
99
  #### Option A: Lite Sync Server (Zero-Config)
101
- No API keys or external services required. Runs locally with SQLite.
100
+ No API keys or external services required. Runs locally with SQLite (~160MB idle, ~310MB peak when rendering notebook previews).
102
101
 
103
102
  * **Using Python**:
104
103
  ```bash
@@ -117,6 +116,15 @@ No API keys or external services required. Runs locally with SQLite.
117
116
  --name supernote-server \
118
117
  supernote
119
118
  ```
119
+ * **Bare Sync Mode (~135MB flat RAM)**: To run a minimal headless sync server without the Web UI, background PNG rasterization, or MCP server, disable `web_enabled` and `mcp_enabled` via environment variables or `config.yaml`:
120
+ ```bash
121
+ SUPERNOTE_MCP_ENABLED=false SUPERNOTE_WEB_ENABLED=false supernote serve
122
+ ```
123
+ ```yaml
124
+ # config/config.yaml
125
+ mcp_enabled: false
126
+ web_enabled: false
127
+ ```
120
128
 
121
129
  #### Option B: AI & Knowledge Hub (With Gemini)
122
130
  Enables handwriting transcription, summarization, and semantic search. Requires a Google Gemini API Key.
@@ -141,6 +149,11 @@ Enables handwriting transcription, summarization, and semantic search. Requires
141
149
  supernote
142
150
  ```
143
151
 
152
+ #### Option C: AI & Knowledge Hub (With a Local Model)
153
+ Runs the same features against a model server on your own hardware, such as [Ollama](https://ollama.com/), llama.cpp, vLLM or LM Studio, so your notes never leave your network. You need a vision-capable chat model for OCR and summaries, and an embedding model for search. Configure the `openai` provider in `config/config.yaml` (`/data/config/config.yaml` in Docker) as described in the [server AI configuration](supernote/server/README.md#ai-configuration).
154
+
155
+ When the server runs in Docker and Ollama runs on the host, use `http://host.docker.internal:11434/v1` as the `base_url` (on Linux, also pass `--add-host=host.docker.internal:host-gateway`).
156
+
144
157
  ### 2. Bootstrap Your User
145
158
 
146
159
  Once the server is running, register your administrator account:
@@ -216,43 +229,6 @@ pip install supernote[all]
216
229
 
217
230
  To set up the project for development, please refer to the [Contributing Guide](docs/CONTRIBUTING.md).
218
231
 
219
- ### Parse a Notebook (Local)
220
-
221
- ```python
222
- from supernote.notebook import parse_notebook
223
-
224
- notebook = parse_notebook("mynote.note")
225
- notebook.to_pdf("output.pdf")
226
- ```
227
-
228
- The notebook parser is a fork and slightly lighter dependency version of [supernote-tool](https://github.com/jya-dev/supernote-tool). All credit goes to the original authors for providing an amazing low-level utility.
229
-
230
- ### Run with Docker
231
-
232
- ```bash
233
- # Build the image locally
234
- docker build -t supernote .
235
-
236
- # Run container (maps your local storage directory to the container's /data volume)
237
- docker run -d \
238
- -p 8080:8080 \
239
- -v $(pwd)/storage:/data \
240
- --name supernote-server \
241
- supernote
242
- ```
243
-
244
- See [Server Documentation](https://github.com/allenporter/supernote/blob/main/supernote/server/README.md) for more configuration details.
245
-
246
- ### Developer API
247
-
248
- Integrate Supernote into your own Python applications:
249
-
250
- ```python
251
- from supernote.client import Supernote
252
- # See library docstrings for usage examples
253
- ```
254
-
255
-
256
232
  ## CLI Usage
257
233
 
258
234
  ```bash
@@ -268,18 +244,27 @@ supernote cloud ls / # List remote files
268
244
  supernote cloud download /Note.note # Download to local machine
269
245
  ```
270
246
 
271
- ## Notebook Operations (Local)
247
+ ## Notebook Operations & Developer API
272
248
 
273
- You can use the built-in parser outside of the cloud server:
249
+ You can use the built-in notebook parser or async client directly in your own Python applications:
274
250
 
275
251
  ```python
276
- from supernote.notebook import parse_notebook
252
+ from pathlib import Path
253
+ from supernote.notebook import PdfConverter, load_notebook
254
+
255
+ note = load_notebook("journal.note")
256
+ pdf_bytes = PdfConverter(note).convert(-1) # Multi-page PDF conversion
257
+ Path("journal.pdf").write_bytes(pdf_bytes)
258
+ ```
259
+
260
+ ```python
261
+ from supernote.client import Supernote
277
262
 
278
- note = parse_notebook("journal.note")
279
- note.to_pdf("journal.pdf") # Multi-layer PDF conversion
263
+ async with await Supernote.login("user@example.com", "password", host="http://localhost:8080") as sn:
264
+ files = await sn.device.list_folder("/")
280
265
  ```
281
266
 
282
- The notebook parser is a fork of the excellent [supernote-tool](https://github.com/jya-dev/supernote-tool) with updated dependencies and modern type hints.
267
+ The notebook parser originally started as a fork of [supernote-tool](https://github.com/jya-dev/supernote-tool) with lighter dependencies and modern type hints. All credit goes to the original authors for providing the foundational parser utility.
283
268
 
284
269
  ## Customizing AI Prompts
285
270
 
@@ -342,8 +327,8 @@ While the official Supernote Private Cloud by Ratta provides a production-grade
342
327
  | Capability | Official Private Cloud (Ratta) | Supernote Private Cloud (This Project) |
343
328
  |------------|-------------------------------|-----------------------------|
344
329
  | **Core Sync** | ✅ Robust & Validated | ✅ Fully Compatible (100% OpenAPI compliant) |
345
- | **Memory Footprint**| ⚠️ High (~2 GB+ RAM required) | **⚡ Low (~300–400MB active)** |
346
- | **AI Analysis** | Basic OCR (Device-side) | **Optional: Gemini-powered Transcriptions & Synthesis** |
330
+ | **Memory Footprint**| ⚠️ High (~2 GB+ RAM required) | **⚡ Low (~135MB bare sync, ~160MB idle / ~310MB active full)** |
331
+ | **AI Analysis** | Basic OCR (Device-side) | **Optional: AI-powered Transcriptions & Synthesis (Gemini or Local Models)** |
347
332
  | **Search** | Path/Filename | **Optional: Semantic Concept Search** |
348
333
  | **Stack** | Java / Spring Boot + Redis + MariaDB | Python / Asyncio + SQLite |
349
334
  | **Database** | Heavy MariaDB Instance | **Single SQLite File** |
@@ -2,7 +2,7 @@
2
2
 
3
3
  **A lightweight, self-hosted private cloud server and optional AI intelligence layer for your Ratta Supernote.**
4
4
 
5
- This toolkit is a self-hosted, SQLite-based implementation of the **Supernote Private Cloud** protocol. It provides a simple and resource-efficient sync server with a minimal resource footprint (typically ~200MB idle memory, and 300–400MB to process large notebooks). It implements **100% of the community [Supernote OpenAPI Specification](api-spec/openapi.yaml)**, and can optionally be enhanced with an **AI-driven synthesis engine**—transforming your handwritten notes into structured, searchable knowledge using Google Gemini.
5
+ This toolkit is a self-hosted, SQLite-based implementation of the **Supernote Private Cloud** protocol. It provides a simple and resource-efficient sync server with a minimal resource footprint (~135MB flat in bare sync mode, or ~160MB idle and ~310MB peak when rendering and processing large notebooks). It implements **100% of the community [Supernote OpenAPI Specification](api-spec/openapi.yaml)**, and can optionally be enhanced with an **AI-driven synthesis engine**—transforming your handwritten notes into structured, searchable knowledge using Google Gemini or local OpenAI-compatible models (such as Ollama).
6
6
 
7
7
  <p align="center">
8
8
  <img src="docs/static-assets/hero-overview.jpg" alt="Supernote Overview" width="800">
@@ -15,11 +15,11 @@ This toolkit is a self-hosted, SQLite-based implementation of the **Supernote Pr
15
15
 
16
16
  This project is designed to be **fully compatible** with the official Supernote Private Cloud protocol, serving as a lightweight alternative that operates on a single SQLite database and runs comfortably on low-power NAS setups and home lab servers:
17
17
 
18
- - **⚡ Lightweight Sync**: Runs on a simple, efficient Python/Asyncio stack with SQLite. Consumes ~200MB of idle memory (recommending 300–400MB for notebook processing).
18
+ - **⚡ Lightweight Sync**: Runs on a simple, efficient Python/Asyncio stack with SQLite. Consumes ~135MB in bare sync mode, or ~160MB idle (~310MB peak) with the Web UI, MCP server, and background notebook processing enabled.
19
19
  - **📋 OpenAPI Spec Compliant**: Implements **100% of the community [Supernote OpenAPI specification](api-spec/openapi.yaml)**.
20
20
  - **🛡️ Private & Secure**: You own your database and files. Runs locally on your NAS or local server with no external data leakage.
21
21
  - **🖥️ Sleek Web UI**: Browse notes, manage tasks, and export iCalendar (`.ics`) task feeds for Home Assistant, Apple Calendar, Google Calendar, and Outlook.
22
- - **📜 Optional AI Synthesis**: If configured with a Gemini API key, it automatically transcribes handwriting and generates summaries (Daily, Weekly, Monthly).
22
+ - **📜 Optional AI Synthesis**: When configured with an AI provider (Google Gemini or a local OpenAI-compatible model such as Ollama), it automatically transcribes handwriting and generates summaries (Daily, Weekly, Monthly).
23
23
  - **🔍 Optional Semantic Search**: Vectorizes content for concept-based search across all notebooks.
24
24
  - **🤖 Agent Ready (MCP)**: Securely connect your notes to AI agents (Claude, Gemini, ChatGPT) via the built-in [Model Context Protocol](https://modelcontextprotocol.io/) server.
25
25
 
@@ -28,7 +28,7 @@ This project is designed to be **fully compatible** with the official Supernote
28
28
  Beyond simple storage, Supernote provides an active processing pipeline to increase the utility of your notes:
29
29
 
30
30
  1. **Sync**: Your device uploads `.note` files using the official Private Cloud protocol.
31
- 2. **Transcribe**: The server extract pages and use Gemini Vision to OCR your handwriting.
31
+ 2. **Transcribe**: The server extracts pages and uses a vision model (Gemini or local VLM) to OCR your handwriting.
32
32
  3. **Synthesize**: AI Analyzers review your journals to find tasks, themes, and summaries.
33
33
  4. **Index**: Every word is vectorized, enabling semantic search across your entire library.
34
34
 
@@ -54,7 +54,7 @@ You can run the server either as a **Lite Sync Server (Zero-Config)** or with th
54
54
  Choose one of the options below to start the server.
55
55
 
56
56
  #### Option A: Lite Sync Server (Zero-Config)
57
- No API keys or external services required. Runs locally with SQLite.
57
+ No API keys or external services required. Runs locally with SQLite (~160MB idle, ~310MB peak when rendering notebook previews).
58
58
 
59
59
  * **Using Python**:
60
60
  ```bash
@@ -73,6 +73,15 @@ No API keys or external services required. Runs locally with SQLite.
73
73
  --name supernote-server \
74
74
  supernote
75
75
  ```
76
+ * **Bare Sync Mode (~135MB flat RAM)**: To run a minimal headless sync server without the Web UI, background PNG rasterization, or MCP server, disable `web_enabled` and `mcp_enabled` via environment variables or `config.yaml`:
77
+ ```bash
78
+ SUPERNOTE_MCP_ENABLED=false SUPERNOTE_WEB_ENABLED=false supernote serve
79
+ ```
80
+ ```yaml
81
+ # config/config.yaml
82
+ mcp_enabled: false
83
+ web_enabled: false
84
+ ```
76
85
 
77
86
  #### Option B: AI & Knowledge Hub (With Gemini)
78
87
  Enables handwriting transcription, summarization, and semantic search. Requires a Google Gemini API Key.
@@ -97,6 +106,11 @@ Enables handwriting transcription, summarization, and semantic search. Requires
97
106
  supernote
98
107
  ```
99
108
 
109
+ #### Option C: AI & Knowledge Hub (With a Local Model)
110
+ Runs the same features against a model server on your own hardware, such as [Ollama](https://ollama.com/), llama.cpp, vLLM or LM Studio, so your notes never leave your network. You need a vision-capable chat model for OCR and summaries, and an embedding model for search. Configure the `openai` provider in `config/config.yaml` (`/data/config/config.yaml` in Docker) as described in the [server AI configuration](supernote/server/README.md#ai-configuration).
111
+
112
+ When the server runs in Docker and Ollama runs on the host, use `http://host.docker.internal:11434/v1` as the `base_url` (on Linux, also pass `--add-host=host.docker.internal:host-gateway`).
113
+
100
114
  ### 2. Bootstrap Your User
101
115
 
102
116
  Once the server is running, register your administrator account:
@@ -172,43 +186,6 @@ pip install supernote[all]
172
186
 
173
187
  To set up the project for development, please refer to the [Contributing Guide](docs/CONTRIBUTING.md).
174
188
 
175
- ### Parse a Notebook (Local)
176
-
177
- ```python
178
- from supernote.notebook import parse_notebook
179
-
180
- notebook = parse_notebook("mynote.note")
181
- notebook.to_pdf("output.pdf")
182
- ```
183
-
184
- The notebook parser is a fork and slightly lighter dependency version of [supernote-tool](https://github.com/jya-dev/supernote-tool). All credit goes to the original authors for providing an amazing low-level utility.
185
-
186
- ### Run with Docker
187
-
188
- ```bash
189
- # Build the image locally
190
- docker build -t supernote .
191
-
192
- # Run container (maps your local storage directory to the container's /data volume)
193
- docker run -d \
194
- -p 8080:8080 \
195
- -v $(pwd)/storage:/data \
196
- --name supernote-server \
197
- supernote
198
- ```
199
-
200
- See [Server Documentation](https://github.com/allenporter/supernote/blob/main/supernote/server/README.md) for more configuration details.
201
-
202
- ### Developer API
203
-
204
- Integrate Supernote into your own Python applications:
205
-
206
- ```python
207
- from supernote.client import Supernote
208
- # See library docstrings for usage examples
209
- ```
210
-
211
-
212
189
  ## CLI Usage
213
190
 
214
191
  ```bash
@@ -224,18 +201,27 @@ supernote cloud ls / # List remote files
224
201
  supernote cloud download /Note.note # Download to local machine
225
202
  ```
226
203
 
227
- ## Notebook Operations (Local)
204
+ ## Notebook Operations & Developer API
228
205
 
229
- You can use the built-in parser outside of the cloud server:
206
+ You can use the built-in notebook parser or async client directly in your own Python applications:
230
207
 
231
208
  ```python
232
- from supernote.notebook import parse_notebook
209
+ from pathlib import Path
210
+ from supernote.notebook import PdfConverter, load_notebook
211
+
212
+ note = load_notebook("journal.note")
213
+ pdf_bytes = PdfConverter(note).convert(-1) # Multi-page PDF conversion
214
+ Path("journal.pdf").write_bytes(pdf_bytes)
215
+ ```
216
+
217
+ ```python
218
+ from supernote.client import Supernote
233
219
 
234
- note = parse_notebook("journal.note")
235
- note.to_pdf("journal.pdf") # Multi-layer PDF conversion
220
+ async with await Supernote.login("user@example.com", "password", host="http://localhost:8080") as sn:
221
+ files = await sn.device.list_folder("/")
236
222
  ```
237
223
 
238
- The notebook parser is a fork of the excellent [supernote-tool](https://github.com/jya-dev/supernote-tool) with updated dependencies and modern type hints.
224
+ The notebook parser originally started as a fork of [supernote-tool](https://github.com/jya-dev/supernote-tool) with lighter dependencies and modern type hints. All credit goes to the original authors for providing the foundational parser utility.
239
225
 
240
226
  ## Customizing AI Prompts
241
227
 
@@ -298,8 +284,8 @@ While the official Supernote Private Cloud by Ratta provides a production-grade
298
284
  | Capability | Official Private Cloud (Ratta) | Supernote Private Cloud (This Project) |
299
285
  |------------|-------------------------------|-----------------------------|
300
286
  | **Core Sync** | ✅ Robust & Validated | ✅ Fully Compatible (100% OpenAPI compliant) |
301
- | **Memory Footprint**| ⚠️ High (~2 GB+ RAM required) | **⚡ Low (~300–400MB active)** |
302
- | **AI Analysis** | Basic OCR (Device-side) | **Optional: Gemini-powered Transcriptions & Synthesis** |
287
+ | **Memory Footprint**| ⚠️ High (~2 GB+ RAM required) | **⚡ Low (~135MB bare sync, ~160MB idle / ~310MB active full)** |
288
+ | **AI Analysis** | Basic OCR (Device-side) | **Optional: AI-powered Transcriptions & Synthesis (Gemini or Local Models)** |
303
289
  | **Search** | Path/Filename | **Optional: Semantic Concept Search** |
304
290
  | **Stack** | Java / Spring Boot + Redis + MariaDB | Python / Asyncio + SQLite |
305
291
  | **Database** | Heavy MariaDB Instance | **Single SQLite File** |
@@ -4,14 +4,13 @@ requires = ["setuptools>=77.0"]
4
4
 
5
5
  [project]
6
6
  name = "supernote"
7
- version = "0.23.0"
7
+ version = "0.24.0"
8
8
  license = "Apache-2.0"
9
9
  license-files = ["LICENSE"]
10
10
  description = "All-in-one toolkit for Supernote devices: parse notebooks, self-host services, access services"
11
11
  readme = "README.md"
12
12
  authors = [
13
- { name = "jya", email = "jya@wizmy.net" },
14
- { name = "Allen Porter", email = "allen.porter@gmail.com" }
13
+ { name = "Allen Porter", email = "allen.porter@gmail.com" },
15
14
  ]
16
15
  requires-python = ">=3.13"
17
16
  classifiers = []
@@ -21,7 +20,6 @@ dependencies = [
21
20
  "numpy>=1.19.0",
22
21
  "Pillow>=7.2.0",
23
22
  "potracer>=0.0.1",
24
- "pypng>=0.0.20",
25
23
  "reportlab>=3.6.1",
26
24
  "svgwrite>=1.4",
27
25
  ]
@@ -123,3 +121,4 @@ exclude = [
123
121
  [tool.ty.rules]
124
122
  unused-type-ignore-comment = "ignore"
125
123
  unresolved-import = "ignore"
124
+ invalid-attribute-override = "ignore"
@@ -0,0 +1,31 @@
1
+ """
2
+ .. include:: ../README.md
3
+ """
4
+
5
+ import importlib
6
+ from typing import Any
7
+
8
+ __all__ = [
9
+ "client",
10
+ "models",
11
+ "notebook",
12
+ "server",
13
+ ]
14
+
15
+
16
+ def __getattr__(name: str) -> Any:
17
+ """Lazily import top-level subpackages on first attribute access (PEP 562).
18
+
19
+ Python executes `supernote/__init__.py` whenever any subpackage (such as
20
+ `supernote.server`, `supernote.client`, or `supernote.notebook`) is imported.
21
+ Deferring subpackage imports until accessed avoids pulling in unrelated
22
+ subpackages and their heavy dependencies (e.g. SQLAlchemy/aiohttp when
23
+ using the notebook parser, or client modules when running the server),
24
+ Then caches the loaded module in `globals()` so subsequent attribute lookups
25
+ have zero overhead.
26
+ """
27
+ if name in __all__:
28
+ module = importlib.import_module(f".{name}", __name__)
29
+ globals()[name] = module
30
+ return module
31
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
@@ -0,0 +1,68 @@
1
+ """Scope summary and summary tag unique_identifier and primary key by user_id
2
+
3
+ Revision ID: a2b3c4d5e6f7
4
+ Revises: f1a2b3c4d5e6
5
+ Create Date: 2026-10-19 06:40:00.000000
6
+
7
+ """
8
+
9
+ from typing import Sequence, Union
10
+
11
+ from alembic import op
12
+
13
+ # revision identifiers, used by Alembic.
14
+ revision: str = "a2b3c4d5e6f7"
15
+ down_revision: Union[str, Sequence[str], None] = "f1a2b3c4d5e6"
16
+ branch_labels: Union[str, Sequence[str], None] = None
17
+ depends_on: Union[str, Sequence[str], None] = None
18
+
19
+ _NAMING_CONVENTION = {
20
+ "uq": "uq_%(table_name)s_%(column_0_name)s",
21
+ "pk": "pk_%(table_name)s",
22
+ }
23
+
24
+
25
+ def upgrade() -> None:
26
+ """Upgrade schema."""
27
+ with op.batch_alter_table(
28
+ "f_summary", naming_convention=_NAMING_CONVENTION
29
+ ) as batch_op:
30
+ batch_op.drop_constraint("uq_f_summary_unique_identifier", type_="unique")
31
+ batch_op.create_unique_constraint(
32
+ "uq_f_summary_user_uuid", ["user_id", "unique_identifier"]
33
+ )
34
+ batch_op.drop_constraint("pk_f_summary", type_="primary")
35
+ batch_op.create_primary_key("pk_f_summary", ["id", "user_id"])
36
+
37
+ with op.batch_alter_table(
38
+ "f_summary_tag", naming_convention=_NAMING_CONVENTION
39
+ ) as batch_op:
40
+ batch_op.drop_constraint("uq_f_summary_tag_unique_identifier", type_="unique")
41
+ batch_op.create_unique_constraint(
42
+ "uq_f_summary_tag_user_uuid", ["user_id", "unique_identifier"]
43
+ )
44
+ batch_op.drop_constraint("pk_f_summary_tag", type_="primary")
45
+ batch_op.create_primary_key("pk_f_summary_tag", ["id", "user_id"])
46
+
47
+
48
+ def downgrade() -> None:
49
+ """Downgrade schema."""
50
+ with op.batch_alter_table(
51
+ "f_summary_tag", naming_convention=_NAMING_CONVENTION
52
+ ) as batch_op:
53
+ batch_op.drop_constraint("uq_f_summary_tag_user_uuid", type_="unique")
54
+ batch_op.create_unique_constraint(
55
+ "uq_f_summary_tag_unique_identifier", ["unique_identifier"]
56
+ )
57
+ batch_op.drop_constraint("pk_f_summary_tag", type_="primary")
58
+ batch_op.create_primary_key("pk_f_summary_tag", ["id"])
59
+
60
+ with op.batch_alter_table(
61
+ "f_summary", naming_convention=_NAMING_CONVENTION
62
+ ) as batch_op:
63
+ batch_op.drop_constraint("uq_f_summary_user_uuid", type_="unique")
64
+ batch_op.create_unique_constraint(
65
+ "uq_f_summary_unique_identifier", ["unique_identifier"]
66
+ )
67
+ batch_op.drop_constraint("pk_f_summary", type_="primary")
68
+ batch_op.create_primary_key("pk_f_summary", ["id"])
@@ -0,0 +1,142 @@
1
+ """merge mixed-case system root folders into the firmware's names
2
+
3
+ Revision ID: b7397248a96b
4
+ Revises: 68964804740d
5
+ Create Date: 2026-10-18 15:00:00.000000
6
+
7
+ """
8
+
9
+ import logging
10
+ import time
11
+ from typing import Sequence, Union
12
+
13
+ import sqlalchemy as sa
14
+ from alembic import op
15
+
16
+ # revision identifiers, used by Alembic.
17
+ revision: str = "b7397248a96b"
18
+ down_revision: Union[str, None] = "68964804740d"
19
+ branch_labels: Union[str, Sequence[str], None] = None
20
+ depends_on: Union[str, Sequence[str], None] = None
21
+
22
+ logger = logging.getLogger("alembic.runtime.migration")
23
+
24
+ ROOT_RENAMES = {"Export": "EXPORT", "Inbox": "INBOX", "Screenshot": "SCREENSHOT"}
25
+
26
+
27
+ def _children(bind: sa.Connection, user_id: int, parent_id: int) -> list[sa.Row]:
28
+ return list(
29
+ bind.execute(
30
+ sa.text(
31
+ "SELECT id, file_name, is_folder FROM f_user_file "
32
+ "WHERE user_id = :user_id AND directory_id = :parent_id "
33
+ "AND is_active = 'Y' ORDER BY id"
34
+ ),
35
+ {"user_id": user_id, "parent_id": parent_id},
36
+ )
37
+ )
38
+
39
+
40
+ def _free_name(name: str, is_folder: str, taken: set[tuple[str, str]]) -> str:
41
+ """Pick `name (n).ext` the way the server autorenames a moved item."""
42
+ base, ext = name, ""
43
+ if is_folder != "Y" and "." in name:
44
+ base, ext = name.rsplit(".", 1)
45
+ ext = f".{ext}"
46
+ counter = 1
47
+ while (candidate := f"{base} ({counter}){ext}", is_folder) in taken:
48
+ counter += 1
49
+ return candidate
50
+
51
+
52
+ def _merge(
53
+ bind: sa.Connection, user_id: int, src_id: int, dst_id: int, now: int
54
+ ) -> None:
55
+ """Move everything in folder `src_id` into folder `dst_id`, then retire `src_id`."""
56
+ existing = {(c.file_name, c.is_folder): c for c in _children(bind, user_id, dst_id)}
57
+ src_children = _children(bind, user_id, src_id)
58
+ placed = set(existing)
59
+ taken = set(existing) | {(c.file_name, c.is_folder) for c in src_children}
60
+
61
+ for child in src_children:
62
+ clash = existing.get((child.file_name, child.is_folder))
63
+ if clash is not None and child.is_folder == "Y":
64
+ _merge(bind, user_id, child.id, clash.id, now)
65
+ continue
66
+
67
+ new_name = child.file_name
68
+ if (new_name, child.is_folder) in placed:
69
+ new_name = _free_name(child.file_name, child.is_folder, taken)
70
+ placed.add((new_name, child.is_folder))
71
+ taken.add((new_name, child.is_folder))
72
+ existing[(new_name, child.is_folder)] = child
73
+ bind.execute(
74
+ sa.text(
75
+ "UPDATE f_user_file SET directory_id = :dst, file_name = :name, "
76
+ "update_time = :now WHERE id = :id"
77
+ ),
78
+ {"dst": dst_id, "name": new_name, "now": now, "id": child.id},
79
+ )
80
+
81
+ # Reparent any soft-deleted (Recycle Bin) children so restoring them finds an active parent.
82
+ bind.execute(
83
+ sa.text(
84
+ "UPDATE f_user_file SET directory_id = :dst, update_time = :now "
85
+ "WHERE user_id = :user_id AND directory_id = :src AND is_active = 'N'"
86
+ ),
87
+ {"dst": dst_id, "src": src_id, "user_id": user_id, "now": now},
88
+ )
89
+ bind.execute(
90
+ sa.text("DELETE FROM f_user_file WHERE id = :id"),
91
+ {"id": src_id},
92
+ )
93
+
94
+
95
+ def upgrade() -> None:
96
+ bind = op.get_bind()
97
+ now = int(time.time() * 1000)
98
+
99
+ for old_name, new_name in ROOT_RENAMES.items():
100
+ rows = bind.execute(
101
+ sa.text(
102
+ "SELECT id, user_id FROM f_user_file WHERE directory_id = 0 "
103
+ "AND file_name = :name AND is_folder = 'Y' AND is_active = 'Y' "
104
+ "ORDER BY id"
105
+ ),
106
+ {"name": old_name},
107
+ ).fetchall()
108
+
109
+ for row in rows:
110
+ target = bind.execute(
111
+ sa.text(
112
+ "SELECT id FROM f_user_file WHERE user_id = :user_id "
113
+ "AND directory_id = 0 AND file_name = :name "
114
+ "AND is_folder = 'Y' AND is_active = 'Y' ORDER BY id LIMIT 1"
115
+ ),
116
+ {"user_id": row.user_id, "name": new_name},
117
+ ).scalar()
118
+
119
+ if target is None:
120
+ bind.execute(
121
+ sa.text(
122
+ "UPDATE f_user_file SET file_name = :name, update_time = :now "
123
+ "WHERE id = :id"
124
+ ),
125
+ {"name": new_name, "now": now, "id": row.id},
126
+ )
127
+ logger.info(
128
+ "Renamed root %s to %s for user %s", old_name, new_name, row.user_id
129
+ )
130
+ else:
131
+ _merge(bind, row.user_id, row.id, target, now)
132
+ logger.info(
133
+ "Merged root %s into %s for user %s",
134
+ old_name,
135
+ new_name,
136
+ row.user_id,
137
+ )
138
+
139
+
140
+ def downgrade() -> None:
141
+ # Merged folders cannot be split apart again; the names are left as they are.
142
+ pass
@@ -0,0 +1,62 @@
1
+ """add embedding_model to note page content
2
+
3
+ Revision ID: c1d2e3f4a5b6
4
+ Revises: b7397248a96b
5
+ Create Date: 2026-10-19 02:20:00.000000
6
+
7
+ """
8
+
9
+ from typing import Sequence, Union
10
+
11
+ import sqlalchemy as sa
12
+ from alembic import op
13
+
14
+ from supernote.server.config import ServerConfig
15
+
16
+ # revision identifiers, used by Alembic.
17
+ revision: str = "c1d2e3f4a5b6"
18
+ down_revision: Union[str, None] = "b7397248a96b"
19
+ branch_labels: Union[str, Sequence[str], None] = None
20
+ depends_on: Union[str, Sequence[str], None] = None
21
+
22
+
23
+ def _get_configured_embedding_model() -> str:
24
+ context_config = op.get_context().config
25
+ server_config: ServerConfig | None = (
26
+ context_config.attributes.get("server_config")
27
+ if context_config is not None
28
+ else None
29
+ )
30
+ if server_config is None:
31
+ server_config = ServerConfig.load()
32
+ return server_config.gemini_embedding_model
33
+
34
+
35
+ def upgrade() -> None:
36
+ with op.batch_alter_table("f_note_page_content") as batch_op:
37
+ batch_op.add_column(sa.Column("embedding_model", sa.String(), nullable=True))
38
+
39
+ embedding_model = _get_configured_embedding_model()
40
+ bind = op.get_bind()
41
+ bind.execute(
42
+ sa.text(
43
+ "UPDATE f_note_page_content "
44
+ "SET embedding_model = :model "
45
+ "WHERE embedding IS NOT NULL AND embedding_model IS NULL"
46
+ ),
47
+ {"model": embedding_model},
48
+ )
49
+ bind.execute(
50
+ sa.text(
51
+ "UPDATE f_system_task "
52
+ "SET data = :model "
53
+ "WHERE task_type = 'EMBEDDING_GENERATION' "
54
+ "AND status = 'COMPLETED' AND data IS NULL"
55
+ ),
56
+ {"model": embedding_model},
57
+ )
58
+
59
+
60
+ def downgrade() -> None:
61
+ with op.batch_alter_table("f_note_page_content") as batch_op:
62
+ batch_op.drop_column("embedding_model")