texlite 0.21.0 → 0.22.0

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 (295) hide show
  1. package/DESIGN.md +169 -22
  2. package/OPERATIONS.md +2 -2
  3. package/README.md +43 -37
  4. package/README.zh-CN.md +37 -31
  5. package/dist/client/assets/AdminUsers-DepqkT6m.js +1 -0
  6. package/dist/client/assets/AdminUsers-DepqkT6m.js.br +0 -0
  7. package/dist/client/assets/AdminUsers-DepqkT6m.js.gz +0 -0
  8. package/dist/client/assets/{AgentIcon-dCMgWJG-.css → AgentIcon-DeoZDwgh.css} +1 -1
  9. package/dist/client/assets/AgentIcon-DeoZDwgh.css.br +0 -0
  10. package/dist/client/assets/AgentIcon-DeoZDwgh.css.gz +0 -0
  11. package/dist/client/assets/{AgentManagement-0n1UkKZ5.js → AgentManagement-DlV6tHez.js} +1 -1
  12. package/dist/client/assets/AgentManagement-DlV6tHez.js.br +0 -0
  13. package/dist/client/assets/AgentManagement-DlV6tHez.js.gz +0 -0
  14. package/dist/client/assets/AgentTerminal-CvOz5X_j.js +2 -0
  15. package/dist/client/assets/AgentTerminal-CvOz5X_j.js.br +0 -0
  16. package/dist/client/assets/AgentTerminal-CvOz5X_j.js.gz +0 -0
  17. package/dist/client/assets/{AgentTerminalSurface-CIouKd-C.js → AgentTerminalSurface-COqg_GdK.js} +1 -1
  18. package/dist/client/assets/AgentTerminalSurface-COqg_GdK.js.br +0 -0
  19. package/dist/client/assets/AgentTerminalSurface-COqg_GdK.js.gz +0 -0
  20. package/dist/client/assets/AvatarSettingsDialog-C8WQhZBK.js +1 -0
  21. package/dist/client/assets/AvatarSettingsDialog-C8WQhZBK.js.br +0 -0
  22. package/dist/client/assets/AvatarSettingsDialog-C8WQhZBK.js.gz +0 -0
  23. package/dist/client/assets/CitationBibtexEditor-SpudGDwi.js +1 -0
  24. package/dist/client/assets/CitationLibraryDialog-DgOIkLwK.js +3 -0
  25. package/dist/client/assets/CitationLibraryDialog-DgOIkLwK.js.br +0 -0
  26. package/dist/client/assets/CitationLibraryDialog-DgOIkLwK.js.gz +0 -0
  27. package/dist/client/assets/CitationNotesPreview-D3CjBD0p.js +1 -0
  28. package/dist/client/assets/Dashboard-CD1w42mA.js +5 -0
  29. package/dist/client/assets/Dashboard-CD1w42mA.js.br +0 -0
  30. package/dist/client/assets/Dashboard-CD1w42mA.js.gz +0 -0
  31. package/dist/client/assets/GitDialog-DGzZ3GRj.js +4 -0
  32. package/dist/client/assets/GitDialog-DGzZ3GRj.js.br +0 -0
  33. package/dist/client/assets/GitDialog-DGzZ3GRj.js.gz +0 -0
  34. package/dist/client/assets/GitHubAccountDialog-CGZl3mcY.js +1 -0
  35. package/dist/client/assets/GitHubAccountDialog-CGZl3mcY.js.br +0 -0
  36. package/dist/client/assets/GitHubAccountDialog-CGZl3mcY.js.gz +0 -0
  37. package/dist/client/assets/HistoryDialog-DTZxCgyT.js +8 -0
  38. package/dist/client/assets/HistoryDialog-DTZxCgyT.js.br +0 -0
  39. package/dist/client/assets/HistoryDialog-DTZxCgyT.js.gz +0 -0
  40. package/dist/client/assets/InfoPopover-Ba7GvcuW.js +1 -0
  41. package/dist/client/assets/LatexEditor-Boc-45KL.js +25 -0
  42. package/dist/client/assets/LatexEditor-Boc-45KL.js.br +0 -0
  43. package/dist/client/assets/LatexEditor-Boc-45KL.js.gz +0 -0
  44. package/dist/client/assets/MarkdownContent-BeKi2gI5.js +36 -0
  45. package/dist/client/assets/MarkdownContent-BeKi2gI5.js.br +0 -0
  46. package/dist/client/assets/MarkdownContent-BeKi2gI5.js.gz +0 -0
  47. package/dist/client/assets/MarkdownPreview-BH2iwvle.js +1 -0
  48. package/dist/client/assets/MarkdownPreview-BH2iwvle.js.br +0 -0
  49. package/dist/client/assets/MarkdownPreview-BH2iwvle.js.gz +0 -0
  50. package/dist/client/assets/{ProjectIconPickerDialog-DAiP7wVe.js → ProjectIconPickerDialog-Bfkaxcnh.js} +1 -1
  51. package/dist/client/assets/ProjectIconPickerDialog-Bfkaxcnh.js.br +0 -0
  52. package/dist/client/assets/ProjectIconPickerDialog-Bfkaxcnh.js.gz +0 -0
  53. package/dist/client/assets/ProjectSearchDialog-DPIzxVYj.js +1 -0
  54. package/dist/client/assets/ProjectSearchDialog-DPIzxVYj.js.br +0 -0
  55. package/dist/client/assets/ProjectSearchDialog-DPIzxVYj.js.gz +0 -0
  56. package/dist/client/assets/ProjectSettings-ChXx_cmP.js +4 -0
  57. package/dist/client/assets/ProjectSettings-ChXx_cmP.js.br +0 -0
  58. package/dist/client/assets/ProjectSettings-ChXx_cmP.js.gz +0 -0
  59. package/dist/client/assets/ProjectWorkspace-B-w2ix8N.js +25 -0
  60. package/dist/client/assets/ProjectWorkspace-B-w2ix8N.js.br +0 -0
  61. package/dist/client/assets/ProjectWorkspace-B-w2ix8N.js.gz +0 -0
  62. package/dist/client/assets/{QuickOpenDialog-kW-97LBY.js → QuickOpenDialog-CHjPlBu2.js} +1 -1
  63. package/dist/client/assets/QuickOpenDialog-CHjPlBu2.js.br +0 -0
  64. package/dist/client/assets/QuickOpenDialog-CHjPlBu2.js.gz +0 -0
  65. package/dist/client/assets/{ReadOnlySource-B-ZZIpJq.js → ReadOnlySource-DKcmDg0e.js} +2 -2
  66. package/dist/client/assets/SelectionHistoryDialog-Dnj22E8N.js +3 -0
  67. package/dist/client/assets/SelectionHistoryDialog-Dnj22E8N.js.br +0 -0
  68. package/dist/client/assets/SelectionHistoryDialog-Dnj22E8N.js.gz +0 -0
  69. package/dist/client/assets/SharedProjectPage-l8GSYTm-.js +2 -0
  70. package/dist/client/assets/SharedProjectPage-l8GSYTm-.js.br +0 -0
  71. package/dist/client/assets/SharedProjectPage-l8GSYTm-.js.gz +0 -0
  72. package/dist/client/assets/{SystemMetricsDialog-Dz_zxjfR.js → SystemMetricsDialog-DkmBA4o4.js} +1 -1
  73. package/dist/client/assets/SystemMetricsDialog-DkmBA4o4.js.br +0 -0
  74. package/dist/client/assets/SystemMetricsDialog-DkmBA4o4.js.gz +0 -0
  75. package/dist/client/assets/TagManagementDialog-BM1MRuwh.js +1 -0
  76. package/dist/client/assets/TagManagementDialog-BM1MRuwh.js.br +0 -0
  77. package/dist/client/assets/TagManagementDialog-BM1MRuwh.js.gz +0 -0
  78. package/dist/client/assets/ThemeSwitcher-dcvtWVCO.js +1 -0
  79. package/dist/client/assets/{WordCountDialog-CJb1b8cD.js → WordCountDialog-DI0Jv-fg.js} +1 -1
  80. package/dist/client/assets/WordCountDialog-DI0Jv-fg.js.br +0 -0
  81. package/dist/client/assets/WordCountDialog-DI0Jv-fg.js.gz +0 -0
  82. package/dist/client/assets/{bibtexFormatterWorker-B_jvobIv.js → bibtexFormatterWorker-Bp8kjjvw.js} +14 -14
  83. package/dist/client/assets/bibtexFormatterWorker-Bp8kjjvw.js.br +0 -0
  84. package/dist/client/assets/bibtexFormatterWorker-Bp8kjjvw.js.gz +0 -0
  85. package/dist/client/assets/bibtexMetadataWorker-CQozbzep.js +2 -0
  86. package/dist/client/assets/bibtexMetadataWorker-CQozbzep.js.br +0 -0
  87. package/dist/client/assets/bibtexMetadataWorker-CQozbzep.js.gz +0 -0
  88. package/dist/client/assets/bibtexNames-CPGbBJxd.js +1 -0
  89. package/dist/client/assets/bibtexReferences-xpSF8IXH.js +1 -0
  90. package/dist/client/assets/bot-ClmnQ29j.js +1 -0
  91. package/dist/client/assets/{chktex-CCcr_9m7.js → chktex-BrzPYHey.js} +2 -2
  92. package/dist/client/assets/citationAuthors-BWHXhKvT.js +1 -0
  93. package/dist/client/assets/citationAuthors-BWHXhKvT.js.br +0 -0
  94. package/dist/client/assets/citationAuthors-BWHXhKvT.js.gz +0 -0
  95. package/dist/client/assets/citationLibrary-DxGdbZEQ.js +1 -0
  96. package/dist/client/assets/citationLibrary-DxGdbZEQ.js.br +0 -0
  97. package/dist/client/assets/citationLibrary-DxGdbZEQ.js.gz +0 -0
  98. package/dist/client/assets/dist-Dxkdrap6.js +2 -0
  99. package/dist/client/assets/dist-Dxkdrap6.js.br +0 -0
  100. package/dist/client/assets/dist-Dxkdrap6.js.gz +0 -0
  101. package/dist/client/assets/editor-CkUEg2La.js +14 -0
  102. package/dist/client/assets/editor-CkUEg2La.js.br +0 -0
  103. package/dist/client/assets/editor-CkUEg2La.js.gz +0 -0
  104. package/dist/client/assets/editor-languages-kcWr1Z3Q.js +36 -0
  105. package/dist/client/assets/editor-languages-kcWr1Z3Q.js.br +0 -0
  106. package/dist/client/assets/editor-languages-kcWr1Z3Q.js.gz +0 -0
  107. package/dist/client/assets/editorThemeExtension-BWtZV1Af.js +1 -0
  108. package/dist/client/assets/editorThemeExtension-BWtZV1Af.js.br +0 -0
  109. package/dist/client/assets/editorThemeExtension-BWtZV1Af.js.gz +0 -0
  110. package/dist/client/assets/generatedParser-CZa2vsK6.js +1 -0
  111. package/dist/client/assets/generatedParser-CZa2vsK6.js.br +0 -0
  112. package/dist/client/assets/generatedParser-CZa2vsK6.js.gz +0 -0
  113. package/dist/client/assets/git-compare-arrows-158rS_vn.js +1 -0
  114. package/dist/client/assets/i18n-Dtn6w-qA.js +13 -0
  115. package/dist/client/assets/i18n-Dtn6w-qA.js.br +0 -0
  116. package/dist/client/assets/i18n-Dtn6w-qA.js.gz +0 -0
  117. package/dist/client/assets/index-BbU2fbRw.css +1 -0
  118. package/dist/client/assets/index-BbU2fbRw.css.br +0 -0
  119. package/dist/client/assets/index-BbU2fbRw.css.gz +0 -0
  120. package/dist/client/assets/index-CPR6YZEf.js +2 -0
  121. package/dist/client/assets/index-CPR6YZEf.js.br +0 -0
  122. package/dist/client/assets/index-CPR6YZEf.js.gz +0 -0
  123. package/dist/client/assets/katex-Ca9qmXPj.js +257 -0
  124. package/dist/client/assets/katex-Ca9qmXPj.js.br +0 -0
  125. package/dist/client/assets/katex-Ca9qmXPj.js.gz +0 -0
  126. package/dist/client/assets/katex.min-VLoWtPY0.js +1 -0
  127. package/dist/client/assets/{latexFormatterWorker-BIDCSZPd.js → latexFormatterWorker-BWiogBYE.js} +1 -1
  128. package/dist/client/assets/latexFormatterWorker-BWiogBYE.js.br +0 -0
  129. package/dist/client/assets/latexFormatterWorker-BWiogBYE.js.gz +0 -0
  130. package/dist/client/assets/latexScanner-D9bMX44Y.js +6 -0
  131. package/dist/client/assets/latexScanner-D9bMX44Y.js.br +0 -0
  132. package/dist/client/assets/latexScanner-D9bMX44Y.js.gz +0 -0
  133. package/dist/client/assets/palette-8_-Y5XON.js +1 -0
  134. package/dist/client/assets/relativeTime-mmWGtWRR.js +1 -0
  135. package/dist/client/assets/relativeTime-mmWGtWRR.js.br +0 -0
  136. package/dist/client/assets/relativeTime-mmWGtWRR.js.gz +0 -0
  137. package/dist/client/assets/{sourceCursorStore-QnrFw3Ft.js → sourceCursorStore-BVDvDKeP.js} +1 -1
  138. package/dist/client/assets/sourceCursorStore-BVDvDKeP.js.br +0 -0
  139. package/dist/client/assets/sourceCursorStore-BVDvDKeP.js.gz +0 -0
  140. package/dist/client/assets/{spellCheck-D-tYd_ac.js → spellCheck-BTyLQAFH.js} +1 -1
  141. package/dist/client/assets/spellCheck-BTyLQAFH.js.br +0 -0
  142. package/dist/client/assets/spellCheck-BTyLQAFH.js.gz +0 -0
  143. package/dist/client/assets/{textLanguageSupport-Kz9ESEVW.js → textLanguageSupport-Ck8lMOWz.js} +1 -1
  144. package/dist/client/assets/{textLanguages-Dac6mieP.js → textLanguages-CwWstpJ5.js} +5 -5
  145. package/dist/client/assets/textLanguages-CwWstpJ5.js.br +0 -0
  146. package/dist/client/assets/textLanguages-CwWstpJ5.js.gz +0 -0
  147. package/dist/client/assets/useDeletionTransitions-Ba_yhkrl.js +1 -0
  148. package/dist/client/assets/useDeletionTransitions-Ba_yhkrl.js.br +0 -0
  149. package/dist/client/assets/useDeletionTransitions-Ba_yhkrl.js.gz +0 -0
  150. package/dist/client/assets/{vimSupport-DWYaSMuX.js → vimSupport-C-WiMLjc.js} +6 -6
  151. package/dist/client/assets/vimSupport-C-WiMLjc.js.br +0 -0
  152. package/dist/client/assets/{vimSupport-DWYaSMuX.js.gz → vimSupport-C-WiMLjc.js.gz} +0 -0
  153. package/dist/client/index.html +3 -3
  154. package/dist/server/agentChanges.js +149 -0
  155. package/dist/server/agents/sessions.js +1 -1
  156. package/dist/server/agents/workspaces.js +7 -27
  157. package/dist/server/app.js +13 -6
  158. package/dist/server/boundedExpiringCache.js +69 -0
  159. package/dist/server/citationFolderTransfer.js +5 -5
  160. package/dist/server/citationInput.js +1 -0
  161. package/dist/server/collaboration.js +8 -4
  162. package/dist/server/db.js +23 -0
  163. package/dist/server/editHistory.js +71 -12
  164. package/dist/server/git.js +58 -7
  165. package/dist/server/history.js +58 -9
  166. package/dist/server/i18n.js +6 -0
  167. package/dist/server/locales/zh-Hant.js +3 -0
  168. package/dist/server/projectReferences.js +110 -9
  169. package/dist/server/routes/auth.js +3 -0
  170. package/dist/server/routes/citations.js +28 -61
  171. package/dist/server/routes/comments.js +8 -3
  172. package/dist/server/routes/projectGit.js +10 -0
  173. package/dist/server/routes/projectHistory.js +42 -0
  174. package/dist/server/routes/users.js +2 -2
  175. package/dist/shared/bibtexBraces.js +20 -0
  176. package/dist/shared/bibtexNames.js +82 -0
  177. package/dist/shared/bibtexReferences.js +52 -12
  178. package/dist/shared/bibtexText.js +175 -0
  179. package/dist/shared/gitProtocol.js +2 -0
  180. package/dist/shared/historyProtocol.js +5 -0
  181. package/dist/shared/textDiff.js +36 -1
  182. package/package.json +1 -1
  183. package/dist/client/assets/AdminUsers-Cpj29JD6.js +0 -1
  184. package/dist/client/assets/AdminUsers-Cpj29JD6.js.br +0 -0
  185. package/dist/client/assets/AdminUsers-Cpj29JD6.js.gz +0 -0
  186. package/dist/client/assets/AgentIcon-dCMgWJG-.css.br +0 -0
  187. package/dist/client/assets/AgentIcon-dCMgWJG-.css.gz +0 -0
  188. package/dist/client/assets/AgentManagement-0n1UkKZ5.js.br +0 -0
  189. package/dist/client/assets/AgentManagement-0n1UkKZ5.js.gz +0 -0
  190. package/dist/client/assets/AgentTerminal-BbGH5iPx.js +0 -2
  191. package/dist/client/assets/AgentTerminal-BbGH5iPx.js.br +0 -0
  192. package/dist/client/assets/AgentTerminal-BbGH5iPx.js.gz +0 -0
  193. package/dist/client/assets/AgentTerminalSurface-CIouKd-C.js.br +0 -0
  194. package/dist/client/assets/AgentTerminalSurface-CIouKd-C.js.gz +0 -0
  195. package/dist/client/assets/AvatarSettingsDialog-BjTx2yjQ.js +0 -1
  196. package/dist/client/assets/AvatarSettingsDialog-BjTx2yjQ.js.br +0 -0
  197. package/dist/client/assets/AvatarSettingsDialog-BjTx2yjQ.js.gz +0 -0
  198. package/dist/client/assets/CitationBibtexEditor-B4ITqbxl.js +0 -1
  199. package/dist/client/assets/CitationLibraryDialog-DDP3gXNt.js +0 -3
  200. package/dist/client/assets/CitationLibraryDialog-DDP3gXNt.js.br +0 -0
  201. package/dist/client/assets/CitationLibraryDialog-DDP3gXNt.js.gz +0 -0
  202. package/dist/client/assets/CitationNotesPreview-BjbIDOCl.js +0 -36
  203. package/dist/client/assets/CitationNotesPreview-BjbIDOCl.js.br +0 -0
  204. package/dist/client/assets/CitationNotesPreview-BjbIDOCl.js.gz +0 -0
  205. package/dist/client/assets/Dashboard-Dc3ANXhG.js +0 -5
  206. package/dist/client/assets/Dashboard-Dc3ANXhG.js.br +0 -0
  207. package/dist/client/assets/Dashboard-Dc3ANXhG.js.gz +0 -0
  208. package/dist/client/assets/GitDialog-CzLmo9Z_.js +0 -3
  209. package/dist/client/assets/GitDialog-CzLmo9Z_.js.br +0 -0
  210. package/dist/client/assets/GitDialog-CzLmo9Z_.js.gz +0 -0
  211. package/dist/client/assets/GitHubAccountDialog-DsQgHv-Z.js +0 -1
  212. package/dist/client/assets/GitHubAccountDialog-DsQgHv-Z.js.br +0 -0
  213. package/dist/client/assets/GitHubAccountDialog-DsQgHv-Z.js.gz +0 -0
  214. package/dist/client/assets/HistoryDialog-C4zmnE1s.js +0 -8
  215. package/dist/client/assets/HistoryDialog-C4zmnE1s.js.br +0 -0
  216. package/dist/client/assets/HistoryDialog-C4zmnE1s.js.gz +0 -0
  217. package/dist/client/assets/InfoPopover-Dkz742vJ.js +0 -1
  218. package/dist/client/assets/LatexEditor-BRPiyMbH.js +0 -25
  219. package/dist/client/assets/LatexEditor-BRPiyMbH.js.br +0 -0
  220. package/dist/client/assets/LatexEditor-BRPiyMbH.js.gz +0 -0
  221. package/dist/client/assets/ProjectIconPickerDialog-DAiP7wVe.js.br +0 -0
  222. package/dist/client/assets/ProjectIconPickerDialog-DAiP7wVe.js.gz +0 -0
  223. package/dist/client/assets/ProjectSearchDialog-B5a5mHXl.js +0 -1
  224. package/dist/client/assets/ProjectSearchDialog-B5a5mHXl.js.br +0 -0
  225. package/dist/client/assets/ProjectSearchDialog-B5a5mHXl.js.gz +0 -0
  226. package/dist/client/assets/ProjectSettings-CARW1k8M.js +0 -4
  227. package/dist/client/assets/ProjectSettings-CARW1k8M.js.br +0 -0
  228. package/dist/client/assets/ProjectSettings-CARW1k8M.js.gz +0 -0
  229. package/dist/client/assets/ProjectWorkspace-BQ3QGBVy.js +0 -31
  230. package/dist/client/assets/ProjectWorkspace-BQ3QGBVy.js.br +0 -0
  231. package/dist/client/assets/ProjectWorkspace-BQ3QGBVy.js.gz +0 -0
  232. package/dist/client/assets/QuickOpenDialog-kW-97LBY.js.br +0 -0
  233. package/dist/client/assets/QuickOpenDialog-kW-97LBY.js.gz +0 -0
  234. package/dist/client/assets/SelectionHistoryDialog-CmHcjD4T.js +0 -3
  235. package/dist/client/assets/SelectionHistoryDialog-CmHcjD4T.js.br +0 -0
  236. package/dist/client/assets/SelectionHistoryDialog-CmHcjD4T.js.gz +0 -0
  237. package/dist/client/assets/SharedProjectPage-BjhT-js7.js +0 -2
  238. package/dist/client/assets/SharedProjectPage-BjhT-js7.js.br +0 -0
  239. package/dist/client/assets/SharedProjectPage-BjhT-js7.js.gz +0 -0
  240. package/dist/client/assets/SystemMetricsDialog-Dz_zxjfR.js.br +0 -0
  241. package/dist/client/assets/SystemMetricsDialog-Dz_zxjfR.js.gz +0 -0
  242. package/dist/client/assets/TagManagementDialog-BIsAi9rh.js +0 -1
  243. package/dist/client/assets/TagManagementDialog-BIsAi9rh.js.br +0 -0
  244. package/dist/client/assets/TagManagementDialog-BIsAi9rh.js.gz +0 -0
  245. package/dist/client/assets/ThemeSwitcher-dp0oKTtC.js +0 -1
  246. package/dist/client/assets/ThemeSwitcher-dp0oKTtC.js.br +0 -0
  247. package/dist/client/assets/ThemeSwitcher-dp0oKTtC.js.gz +0 -0
  248. package/dist/client/assets/WordCountDialog-CJb1b8cD.js.br +0 -0
  249. package/dist/client/assets/WordCountDialog-CJb1b8cD.js.gz +0 -0
  250. package/dist/client/assets/bibtexFormatterWorker-B_jvobIv.js.br +0 -0
  251. package/dist/client/assets/bibtexFormatterWorker-B_jvobIv.js.gz +0 -0
  252. package/dist/client/assets/citationLibrary-BzlqZiFU.js +0 -26
  253. package/dist/client/assets/citationLibrary-BzlqZiFU.js.br +0 -0
  254. package/dist/client/assets/citationLibrary-BzlqZiFU.js.gz +0 -0
  255. package/dist/client/assets/clipboard-CslquMx4.js +0 -1
  256. package/dist/client/assets/editor-fyrvjoqA.js +0 -14
  257. package/dist/client/assets/editor-fyrvjoqA.js.br +0 -0
  258. package/dist/client/assets/editor-fyrvjoqA.js.gz +0 -0
  259. package/dist/client/assets/editor-languages-D1a-K8dK.js +0 -36
  260. package/dist/client/assets/editor-languages-D1a-K8dK.js.br +0 -0
  261. package/dist/client/assets/editor-languages-D1a-K8dK.js.gz +0 -0
  262. package/dist/client/assets/editorThemeExtension-BpJbXyCP.js +0 -1
  263. package/dist/client/assets/editorThemeExtension-BpJbXyCP.js.br +0 -0
  264. package/dist/client/assets/editorThemeExtension-BpJbXyCP.js.gz +0 -0
  265. package/dist/client/assets/eye-BnslGpqB.js +0 -1
  266. package/dist/client/assets/i18n-DNTfpttY.js +0 -13
  267. package/dist/client/assets/i18n-DNTfpttY.js.br +0 -0
  268. package/dist/client/assets/i18n-DNTfpttY.js.gz +0 -0
  269. package/dist/client/assets/index-CfSDaTd4.js +0 -2
  270. package/dist/client/assets/index-CfSDaTd4.js.br +0 -0
  271. package/dist/client/assets/index-CfSDaTd4.js.gz +0 -0
  272. package/dist/client/assets/index-PNFHDg2W.css +0 -1
  273. package/dist/client/assets/index-PNFHDg2W.css.br +0 -0
  274. package/dist/client/assets/index-PNFHDg2W.css.gz +0 -0
  275. package/dist/client/assets/katex-CBRBI6nR.js +0 -257
  276. package/dist/client/assets/katex-CBRBI6nR.js.br +0 -0
  277. package/dist/client/assets/katex-CBRBI6nR.js.gz +0 -0
  278. package/dist/client/assets/latexFormatterWorker-BIDCSZPd.js.br +0 -0
  279. package/dist/client/assets/latexFormatterWorker-BIDCSZPd.js.gz +0 -0
  280. package/dist/client/assets/relativeTime-DKEihsTa.js +0 -1
  281. package/dist/client/assets/relativeTime-DKEihsTa.js.br +0 -0
  282. package/dist/client/assets/relativeTime-DKEihsTa.js.gz +0 -0
  283. package/dist/client/assets/sourceCursorStore-QnrFw3Ft.js.br +0 -0
  284. package/dist/client/assets/sourceCursorStore-QnrFw3Ft.js.gz +0 -0
  285. package/dist/client/assets/spellCheck-D-tYd_ac.js.br +0 -0
  286. package/dist/client/assets/spellCheck-D-tYd_ac.js.gz +0 -0
  287. package/dist/client/assets/textLanguages-Dac6mieP.js.br +0 -0
  288. package/dist/client/assets/textLanguages-Dac6mieP.js.gz +0 -0
  289. package/dist/client/assets/useDeletionTransitions-TAZINdHX.js +0 -1
  290. package/dist/client/assets/useDeletionTransitions-TAZINdHX.js.br +0 -0
  291. package/dist/client/assets/useDeletionTransitions-TAZINdHX.js.gz +0 -0
  292. package/dist/client/assets/vimSupport-DWYaSMuX.js.br +0 -0
  293. /package/dist/client/assets/{AgentIcon-DsoMeMA8.js → AgentIcon-CA-PfOka.js} +0 -0
  294. /package/dist/client/assets/{AgentIcon-DsoMeMA8.js.br → AgentIcon-CA-PfOka.js.br} +0 -0
  295. /package/dist/client/assets/{AgentIcon-DsoMeMA8.js.gz → AgentIcon-CA-PfOka.js.gz} +0 -0
@@ -5,6 +5,19 @@ import { assertNoSourceSymlinks, listProjectFiles, outputRoot, projectRoot, reso
5
5
  import { httpError } from "./http.js";
6
6
  import { MAX_TEXT_PREVIEW_BYTES } from "./limits.js";
7
7
  import { defaultHistoryTracking, historyTextCandidate, historyTrackingOverride } from "../shared/historyTracking.js";
8
+ const HOUR_MS = 60 * 60_000;
9
+ const DAY_MS = 24 * HOUR_MS;
10
+ /** Server-local hour or day, matching the local days the timeline is grouped by. */
11
+ function historyBucket(time, size) {
12
+ const date = new Date(time);
13
+ const day = `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`;
14
+ return size === "day" ? `day:${day}` : `hour:${day}:${date.getHours()}`;
15
+ }
16
+ /** Every version younger than this is kept. */
17
+ const HISTORY_KEEP_ALL_MS = DAY_MS;
18
+ /** Up to this age one version per hour is kept; older history keeps one per day. */
19
+ const HISTORY_KEEP_HOURLY_MS = 7 * DAY_MS;
20
+ /** Fixed window, from a run's first save, in which autosaves (or one user's agent writes) share a snapshot. */
8
21
  const AUTOSAVE_COALESCE_MS = 2 * 60_000;
9
22
  // Logical stored payload; SQLite pages, indexes and WAL are shared database overhead.
10
23
  function historyMetadataBytes(row) {
@@ -55,7 +68,16 @@ export class ProjectHistoryService {
55
68
  return null;
56
69
  }
57
70
  const createdAt = new Date().toISOString();
58
- if (!policyChanged && reason === "autosave" && previous?.reason === "autosave" && !previous.label
71
+ // Autosaves coalesce across authors, but agent and human changes never
72
+ // share a snapshot, so the state before an agent started stays a separate
73
+ // restore point. A coding agent's file writes, seen by separate source
74
+ // polls, coalesce only with the same user's previous agent write.
75
+ const hasAgent = Boolean(options.hasAgent);
76
+ const sameRun = reason === "autosave"
77
+ ? previous?.reason === "autosave" && Boolean(previous.has_agent) === hasAgent
78
+ : reason === "file" && hasAgent && previous?.reason === "file"
79
+ && Boolean(previous.has_agent) && previous.author_id === authorId;
80
+ if (!policyChanged && sameRun && previous && !previous.label
59
81
  && JSON.stringify(parseManifest(previous.manifest_json).tracking) === JSON.stringify(tracking)
60
82
  && Date.parse(createdAt) - Date.parse(previous.created_at) < AUTOSAVE_COALESCE_MS) {
61
83
  const merged = [...new Set([...parseStringArray(previous.changed_paths_json), ...changedPaths])].sort();
@@ -73,9 +95,9 @@ export class ProjectHistoryService {
73
95
  }
74
96
  const id = randomUUID();
75
97
  this.db.prepare(`INSERT INTO project_history_versions
76
- (id, project_id, author_id, reason, manifest_json, changed_paths_json, created_at)
77
- VALUES (?, ?, ?, ?, ?, ?, ?)`)
78
- .run(id, projectId, authorId, reason, JSON.stringify(manifest), JSON.stringify(changedPaths), createdAt);
98
+ (id, project_id, author_id, reason, has_agent, manifest_json, changed_paths_json, created_at)
99
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?)`)
100
+ .run(id, projectId, authorId, reason, options.hasAgent ? 1 : 0, JSON.stringify(manifest), JSON.stringify(changedPaths), createdAt);
79
101
  this.saveBaseline(projectId, manifest);
80
102
  if (!options.deferRetention)
81
103
  this.pruneVersions(projectId);
@@ -573,15 +595,41 @@ export class ProjectHistoryService {
573
595
  }
574
596
  };
575
597
  // 1. Cap by historyMaxVersions (prune excess ordinary versions when configured; 0 = unlimited)
598
+ const remainingOrdinary = () => ordinaryDesc.filter((row) => !toDeleteIds.has(row.id));
576
599
  if (this.config.historyMaxVersions > 0 && ordinaryDesc.length > this.config.historyMaxVersions) {
577
600
  const obsolete = ordinaryDesc.slice(this.config.historyMaxVersions);
578
601
  for (const row of obsolete)
579
602
  removeVersionRefs(row.id);
580
603
  }
581
- // 2. Cap by historyMaxStorageBytes (prune remaining eligible versions from oldest to newest)
604
+ // 2. Over the storage budget, first thin older history so the budget
605
+ // covers a longer period: keep every version from the last day, the newest
606
+ // of each local hour for the last week, and the newest of each local day
607
+ // before that. The latest version occupies its own hour or day. Labeled,
608
+ // initial, restore and pre-restore checkpoint versions are never thinned.
609
+ // Under the budget nothing is removed.
610
+ if (retainedBytes > this.config.historyMaxStorageBytes) {
611
+ const now = Date.now();
612
+ const keptBuckets = new Set();
613
+ for (const row of remainingOrdinary()) {
614
+ const time = Date.parse(row.created_at);
615
+ if (!Number.isFinite(time) || now - time <= HISTORY_KEEP_ALL_MS)
616
+ continue;
617
+ const bucket = historyBucket(time, now - time <= HISTORY_KEEP_HOURLY_MS ? "hour" : "day");
618
+ if (row.id === latestId || row.reason === "restore" || row.reason === "checkpoint") {
619
+ if (row.id === latestId)
620
+ keptBuckets.add(bucket);
621
+ continue;
622
+ }
623
+ if (keptBuckets.has(bucket))
624
+ removeVersionRefs(row.id);
625
+ else
626
+ keptBuckets.add(bucket);
627
+ }
628
+ }
629
+ // 3. Still over the budget: prune remaining eligible versions from oldest to newest.
582
630
  if (retainedBytes > this.config.historyMaxStorageBytes) {
583
- const remainingEligibleAsc = ordinaryDesc
584
- .filter((row) => row.id !== latestId && !toDeleteIds.has(row.id))
631
+ const remainingEligibleAsc = remainingOrdinary()
632
+ .filter((row) => row.id !== latestId)
585
633
  .reverse();
586
634
  for (const row of remainingEligibleAsc) {
587
635
  if (retainedBytes <= this.config.historyMaxStorageBytes)
@@ -591,13 +639,13 @@ export class ProjectHistoryService {
591
639
  }
592
640
  if (!toDeleteIds.size)
593
641
  return;
594
- // 3. Batch delete rows in a single transaction
642
+ // 4. Batch delete rows in a single transaction
595
643
  const remove = this.db.prepare("DELETE FROM project_history_versions WHERE id = ? AND project_id = ?");
596
644
  this.db.transaction(() => {
597
645
  for (const id of toDeleteIds)
598
646
  remove.run(id, projectId);
599
647
  })();
600
- // 4. Remove unreferenced CAS objects on disk
648
+ // 5. Remove unreferenced CAS objects on disk
601
649
  for (const [digest, count] of refCounts.entries()) {
602
650
  if (count === 0)
603
651
  fs.rmSync(this.objectPath(projectId, digest), { force: true });
@@ -758,6 +806,7 @@ function versionJson(row) {
758
806
  username: row.author_username ?? "deleted-user",
759
807
  name: row.author_name ?? "Deleted User"
760
808
  } : null,
809
+ hasAgent: Boolean(row.has_agent),
761
810
  changedPaths: parseStringArray(row.changed_paths_json),
762
811
  fileCount: files.length,
763
812
  totalSize: files.reduce((sum, file) => sum + file.size, 0)
@@ -50,6 +50,8 @@ const enMessages = {
50
50
  COMPILE_FORBIDDEN: "You do not have permission to compile this project.",
51
51
  COMPILE_SNAPSHOT_BUSY: "The project source is still being saved. Try compiling again shortly.",
52
52
  CURRENT_PASSWORD_INVALID: "The current password is incorrect.",
53
+ PASSWORD_CHANGE_REQUIRED: "Change your temporary password before continuing.",
54
+ PASSWORD_UNCHANGED: "Choose a password different from your temporary password.",
53
55
  DICTIONARY_EDIT_FORBIDDEN: "You do not have permission to maintain this project's dictionary.",
54
56
  DIRECTORY_NOT_FOUND: "The destination folder does not exist.",
55
57
  FILE_CONTENT_INVALID: "The file content is invalid.",
@@ -62,6 +64,7 @@ const enMessages = {
62
64
  GIT_COMMAND_FAILED: "The Git command failed. Check the server log for details.",
63
65
  GIT_COMMIT_MESSAGE_INVALID: "Enter a commit message of 300 characters or fewer.",
64
66
  GIT_DETACHED_HEAD: "The repository is in detached HEAD state. Return to the default branch first.",
67
+ GIT_IDENTITY_INVALID: "Enter a valid Git author name and email address (at most 100 and 254 characters).",
65
68
  GIT_REPOSITORY_NAME_INVALID: "Enter a GitHub repository name.",
66
69
  GIT_REPOSITORY_NOT_INITIALIZED: "Git is not initialized for this project.",
67
70
  GIT_REPOSITORY_RESPONSE_INVALID: "GitHub did not return a valid repository.",
@@ -197,6 +200,8 @@ const zhMessages = {
197
200
  COMPILE_FORBIDDEN: "你没有编译此项目的权限。",
198
201
  COMPILE_SNAPSHOT_BUSY: "项目源码仍在保存,请稍后重新编译。",
199
202
  CURRENT_PASSWORD_INVALID: "当前密码错误。",
203
+ PASSWORD_CHANGE_REQUIRED: "请先修改初始密码再继续。",
204
+ PASSWORD_UNCHANGED: "新密码不能与初始密码相同。",
200
205
  DICTIONARY_EDIT_FORBIDDEN: "你没有维护本项目词典的权限。",
201
206
  DIRECTORY_NOT_FOUND: "目标文件夹不存在。",
202
207
  FILE_CONTENT_INVALID: "文件内容格式不正确。",
@@ -209,6 +214,7 @@ const zhMessages = {
209
214
  GIT_COMMAND_FAILED: "Git 命令执行失败,请查看服务器日志了解详情。",
210
215
  GIT_COMMIT_MESSAGE_INVALID: "请输入不超过 300 个字符的提交说明。",
211
216
  GIT_DETACHED_HEAD: "当前处于 detached HEAD,请先返回默认分支。",
217
+ GIT_IDENTITY_INVALID: "请输入有效的 Git 作者名和邮箱地址(分别不超过 100 和 254 个字符)。",
212
218
  GIT_REPOSITORY_NAME_INVALID: "请输入 GitHub 仓库名称。",
213
219
  GIT_REPOSITORY_NOT_INITIALIZED: "该项目尚未初始化 Git。",
214
220
  GIT_REPOSITORY_RESPONSE_INVALID: "GitHub 没有返回有效的仓库信息。",
@@ -44,6 +44,8 @@ export const zhHantMessages = {
44
44
  COMPILE_FORBIDDEN: "你沒有編譯此專案的權限。",
45
45
  COMPILE_SNAPSHOT_BUSY: "專案原始碼仍在儲存,請稍後重新編譯。",
46
46
  CURRENT_PASSWORD_INVALID: "目前密碼錯誤。",
47
+ PASSWORD_CHANGE_REQUIRED: "請先變更初始密碼再繼續。",
48
+ PASSWORD_UNCHANGED: "新密碼不能與初始密碼相同。",
47
49
  DICTIONARY_EDIT_FORBIDDEN: "你沒有維護本專案字典的權限。",
48
50
  DIRECTORY_NOT_FOUND: "目標資料夾不存在。",
49
51
  FILE_CONTENT_INVALID: "檔案內容格式不正確。",
@@ -56,6 +58,7 @@ export const zhHantMessages = {
56
58
  GIT_COMMAND_FAILED: "Git 命令執行失敗,請檢視伺服器記錄以了解詳情。",
57
59
  GIT_COMMIT_MESSAGE_INVALID: "請輸入不超過 300 個字元的提交說明。",
58
60
  GIT_DETACHED_HEAD: "目前處於 detached HEAD,請先返回預設分支。",
61
+ GIT_IDENTITY_INVALID: "請輸入有效的 Git 作者名稱和電子郵件地址(分別不超過 100 和 254 個字元)。",
59
62
  GIT_REPOSITORY_NAME_INVALID: "請輸入 GitHub 儲存庫名稱。",
60
63
  GIT_REPOSITORY_NOT_INITIALIZED: "該專案尚未初始化 Git。",
61
64
  GIT_REPOSITORY_RESPONSE_INVALID: "GitHub 未傳回有效的儲存庫資訊。",
@@ -1,4 +1,5 @@
1
1
  import fs from "node:fs";
2
+ import { BoundedExpiringCache } from "./boundedExpiringCache.js";
2
3
  import { listProjectFilesAsync, resolveSourcePath } from "./files.js";
3
4
  import { findLatexReferenceDefinitions, lineAndColumnAt } from "../shared/latexReferences.js";
4
5
  import { documentSourceOrder, latexDocumentDirectives, resolveProjectReferencePath, uniqueProjectPaths } from "./latexDocumentGraph.js";
@@ -6,6 +7,36 @@ const definitionExtensions = /\.(?:tex|sty|cls)$/i;
6
7
  const texExtension = /\.tex$/i;
7
8
  const bibExtension = /\.bib$/i;
8
9
  const MAX_REFERENCE_KEY_LENGTH = 512;
10
+ // Hover and navigation can resolve many keys from one project in quick
11
+ // succession. Cache the source snapshot by file metadata so different keys do
12
+ // not re-read and re-parse every LaTeX source inside the same short window.
13
+ const sourceCache = new BoundedExpiringCache({
14
+ ttlMs: 15_000,
15
+ maxEntries: 16,
16
+ maxEntryBytes: 8 * 1024 * 1024,
17
+ maxBytes: 32 * 1024 * 1024
18
+ });
19
+ // A .bib file can be several megabytes and every hover re-resolves its key.
20
+ // Keep only a key -> location index per file revision, not the content, so an
21
+ // unchanged bibliography is neither re-read nor re-scanned. Validity comes
22
+ // from the revision; the sliding lifetime only frees indexes nobody uses.
23
+ const bibliographyIndexCache = new BoundedExpiringCache({
24
+ ttlMs: 5 * 60_000,
25
+ refreshOnHit: true,
26
+ maxEntries: 64,
27
+ maxEntryBytes: 4 * 1024 * 1024,
28
+ maxBytes: 16 * 1024 * 1024
29
+ });
30
+ /** Resident size of the source-snapshot cache, for diagnostics and tests. */
31
+ export function projectReferenceCacheStats() {
32
+ const { entries, bytes } = sourceCache.stats();
33
+ return { projects: entries, bytes };
34
+ }
35
+ /** Resident size of the per-file bibliography index cache, for diagnostics and tests. */
36
+ export function bibliographyIndexCacheStats() {
37
+ const { entries, bytes } = bibliographyIndexCache.stats();
38
+ return { files: entries, bytes };
39
+ }
9
40
  export function validReferenceKey(value) {
10
41
  return typeof value === "string"
11
42
  && value.trim().length > 0
@@ -20,21 +51,19 @@ export function validReferenceKey(value) {
20
51
  * archive or template from shadowing the bibliography used by the selected
21
52
  * main document.
22
53
  */
23
- export async function resolveProjectReference(config, projectId, kind, keyInput, options = {}) {
24
- // Keep the former preferred-path argument working for internal callers
25
- // during the transition to the richer main-document-aware lookup options.
26
- const lookup = typeof options === "string" ? { preferredPath: options } : options;
54
+ export async function resolveProjectReference(config, projectId, kind, keyInput, lookup = {}) {
27
55
  const key = keyInput.trim();
28
56
  const files = (await listProjectFilesAsync(config, projectId))
29
57
  .filter((entry) => entry.type === "file" && (definitionExtensions.test(entry.path) || bibExtension.test(entry.path)));
30
58
  const sourceEntries = files.filter((entry) => definitionExtensions.test(entry.path));
31
59
  const bibEntries = files.filter((entry) => bibExtension.test(entry.path));
32
- const sourceContents = await readProjectSources(config, projectId, sourceEntries.map((entry) => entry.path));
60
+ const { contents: sourceContents, directives: sourceDirectives } = await projectSourceSnapshot(config, projectId, sourceEntries);
33
61
  const sourcePaths = [...sourceContents.keys()].sort((left, right) => left.localeCompare(right));
34
62
  const bibPaths = bibEntries.map((entry) => entry.path).sort((left, right) => left.localeCompare(right));
35
- const sourceDirectives = new Map();
36
- for (const [entryPath, source] of sourceContents)
37
- sourceDirectives.set(entryPath, latexDocumentDirectives(source));
63
+ // Without both size and mtime there is no trustworthy version; an empty
64
+ // revision is omitted from the target and disables server-side caching.
65
+ const revisions = new Map(files.map((entry) => [entry.path,
66
+ entry.size === undefined || entry.mtimeMs === undefined ? "" : `${entry.size}:${entry.mtimeMs}`]));
38
67
  const preferredPath = sourceContents.has(lookup.preferredPath ?? "") ? lookup.preferredPath ?? "" : "";
39
68
  const mainFile = sourceContents.has(lookup.mainFile ?? "") && texExtension.test(lookup.mainFile ?? "")
40
69
  ? lookup.mainFile ?? ""
@@ -48,6 +77,15 @@ export async function resolveProjectReference(config, projectId, kind, keyInput,
48
77
  ? uniqueProjectPaths([...prioritizedSources, ...sourcePaths])
49
78
  : citationLookupOrder(sourceDirectives, prioritizedSources, bibPaths, sourcePaths);
50
79
  for (const entryPath of orderedPaths) {
80
+ const revision = revisions.get(entryPath) ?? "";
81
+ if (bibExtension.test(entryPath) && !sourceContents.has(entryPath)) {
82
+ if (kind !== "citation")
83
+ continue;
84
+ const location = (await bibliographyIndex(config, projectId, entryPath, revision))?.get(key);
85
+ if (!location)
86
+ continue;
87
+ return { path: entryPath, ...location, kind, source: "bibtex", ...(revision ? { revision } : {}) };
88
+ }
51
89
  const source = sourceContents.get(entryPath)
52
90
  ?? await readProjectFile(config, projectId, entryPath);
53
91
  if (source === null)
@@ -57,10 +95,73 @@ export async function resolveProjectReference(config, projectId, kind, keyInput,
57
95
  if (!definition)
58
96
  continue;
59
97
  const location = lineAndColumnAt(source, definition.targetFrom);
60
- return { path: entryPath, ...location, kind, source: definition.source };
98
+ return { path: entryPath, ...location, kind, source: definition.source, ...(revision ? { revision } : {}) };
61
99
  }
62
100
  return null;
63
101
  }
102
+ async function projectSourceSnapshot(config, projectId, entries) {
103
+ const signature = entries
104
+ .map((entry) => `${entry.path}:${entry.size ?? 0}:${entry.mtimeMs ?? 0}`)
105
+ .sort()
106
+ .join("\n");
107
+ const cached = sourceCache.get(projectId);
108
+ if (cached?.signature === signature)
109
+ return cached;
110
+ const contents = await readProjectSources(config, projectId, entries.map((entry) => entry.path));
111
+ const directives = new Map();
112
+ for (const [entryPath, source] of contents)
113
+ directives.set(entryPath, latexDocumentDirectives(source));
114
+ const bytes = [...contents.values()].reduce((total, source) => total + Buffer.byteLength(source, "utf8"), 0);
115
+ sourceCache.set(projectId, { signature, contents, directives }, bytes);
116
+ return { contents, directives };
117
+ }
118
+ /**
119
+ * Key -> location index of one .bib file, reused while its revision is
120
+ * unchanged. Returns null when the file has disappeared.
121
+ */
122
+ async function bibliographyIndex(config, projectId, entryPath, revision) {
123
+ const cacheKey = `${projectId}\0${entryPath}`;
124
+ if (revision) {
125
+ const cached = bibliographyIndexCache.get(cacheKey);
126
+ if (cached?.revision === revision)
127
+ return cached.locations;
128
+ }
129
+ const source = await readProjectFile(config, projectId, entryPath);
130
+ if (source === null) {
131
+ bibliographyIndexCache.delete(cacheKey);
132
+ return null;
133
+ }
134
+ const locations = new Map();
135
+ let bytes = 0;
136
+ // Definitions arrive in source order, so one forward pass yields every line
137
+ // and column instead of rescanning from the start for each entry.
138
+ let line = 1;
139
+ let lineStart = 0;
140
+ let scanned = 0;
141
+ for (const definition of findLatexReferenceDefinitions(source, "citation", true)) {
142
+ if (locations.has(definition.key))
143
+ continue;
144
+ let location;
145
+ if (definition.targetFrom < scanned) {
146
+ location = lineAndColumnAt(source, definition.targetFrom);
147
+ }
148
+ else {
149
+ const target = Math.min(definition.targetFrom, source.length);
150
+ for (; scanned < target; scanned += 1) {
151
+ if (source.charCodeAt(scanned) !== 10)
152
+ continue;
153
+ line += 1;
154
+ lineStart = scanned + 1;
155
+ }
156
+ location = { line, column: target - lineStart + 1 };
157
+ }
158
+ locations.set(definition.key, location);
159
+ bytes += definition.key.length * 2 + 64;
160
+ }
161
+ if (revision)
162
+ bibliographyIndexCache.set(cacheKey, { revision, locations }, bytes);
163
+ return locations;
164
+ }
64
165
  async function readProjectSources(config, projectId, paths) {
65
166
  const contents = new Map();
66
167
  await Promise.all(paths.map(async (entryPath) => {
@@ -70,6 +70,9 @@ export function registerAuthRoutes(app, context) {
70
70
  if (!(await verifyPassword(currentPassword, user.password_hash))) {
71
71
  return apiError(reply, 400, "CURRENT_PASSWORD_INVALID");
72
72
  }
73
+ if (user.must_change_password && newPassword === currentPassword) {
74
+ return apiError(reply, 400, "PASSWORD_UNCHANGED");
75
+ }
73
76
  const passwordHash = await hashPassword(newPassword);
74
77
  db.prepare("UPDATE users SET password_hash = ?, must_change_password = 0 WHERE id = ?")
75
78
  .run(passwordHash, user.id);
@@ -3,8 +3,12 @@ import { requireUser } from "../auth.js";
3
3
  import { apiError, httpError, ValidationError } from "../http.js";
4
4
  import { MAX_CITATION_BIBTEX_BYTES } from "../limits.js";
5
5
  import { assertCitationCollectionCapacity, citationCollectionIds, citationCollectionsForEntries, filterCitationCollection, registerCitationCollectionRoutes } from "../citationCollections.js";
6
- import { comparableCitationBibtex } from "../../shared/citationContent.js";
7
6
  import { citationInput } from "../citationInput.js";
7
+ /**
8
+ * The lookup carries only citation keys from one .bib file, which is itself
9
+ * capped at MAX_CITATION_BIBTEX_BYTES; twice that leaves room for JSON quoting.
10
+ */
11
+ const MAX_LOOKUP_BODY_BYTES = MAX_CITATION_BIBTEX_BYTES * 2;
8
12
  const tagColors = ["red", "orange", "yellow", "green", "blue", "purple", "gray"];
9
13
  const now = () => new Date().toISOString();
10
14
  function escapeLikePattern(value) {
@@ -26,6 +30,7 @@ function citationJson(row, tags = [], collectionIds = []) {
26
30
  title: row.title,
27
31
  authors: row.authors,
28
32
  year: row.year,
33
+ venue: row.venue,
29
34
  revision: row.revision,
30
35
  collectionIds,
31
36
  tags: tags.map((tag) => ({ id: tag.id, name: tag.name, color: tag.color, ownerId: tag.user_id })),
@@ -102,8 +107,9 @@ export function registerCitationRoutes(app, context) {
102
107
  OR COALESCE(title, '') LIKE ? ESCAPE '\\'
103
108
  OR COALESCE(authors, '') LIKE ? ESCAPE '\\'
104
109
  OR COALESCE(year, '') LIKE ? ESCAPE '\\'
110
+ OR COALESCE(venue, '') LIKE ? ESCAPE '\\'
105
111
  )`);
106
- params.push(...Array.from({ length: 5 }, () => `%${escapeLikePattern(search)}%`));
112
+ params.push(...Array.from({ length: 6 }, () => `%${escapeLikePattern(search)}%`));
107
113
  }
108
114
  if (tagId) {
109
115
  where.push(`EXISTS (SELECT 1 FROM citation_library_entry_tags filter_link
@@ -194,31 +200,11 @@ export function registerCitationRoutes(app, context) {
194
200
  return;
195
201
  return apiError(reply, 403, "CITATION_LIBRARY_PRIVATE");
196
202
  });
197
- app.post("/api/citations/lookup", { bodyLimit: MAX_CITATION_BIBTEX_BYTES * 8 }, async (request, reply) => {
203
+ app.post("/api/citations/lookup", { bodyLimit: MAX_LOOKUP_BODY_BYTES }, async (request, reply) => {
198
204
  const user = requireUser(request, reply, db);
199
205
  if (!user)
200
206
  return;
201
- const body = request.body;
202
- let contents = null;
203
- let keyInput = body?.keys;
204
- if (body?.entries !== undefined) {
205
- if (body.keys !== undefined || !Array.isArray(body.entries) || body.entries.length > 5000)
206
- throw new ValidationError();
207
- contents = new Map();
208
- let bytes = 0;
209
- keyInput = body.entries.map((value) => {
210
- if (typeof value !== "object" || !value)
211
- throw new ValidationError();
212
- const item = value;
213
- if (typeof item.citationKey !== "string" || typeof item.bibtex !== "string" || !item.bibtex.trim())
214
- throw new ValidationError();
215
- bytes += Buffer.byteLength(item.bibtex, "utf8");
216
- if (bytes > MAX_CITATION_BIBTEX_BYTES)
217
- throw httpError(413, "CITATION_TOO_LARGE");
218
- contents.set(item.citationKey.trim().toLowerCase(), comparableCitationBibtex(item.bibtex));
219
- return item.citationKey;
220
- });
221
- }
207
+ const keyInput = request.body?.keys;
222
208
  if (!Array.isArray(keyInput) || keyInput.length > 5000
223
209
  || keyInput.some((key) => typeof key !== "string" || !key.trim() || key.length > 512)) {
224
210
  throw new ValidationError();
@@ -228,12 +214,11 @@ export function registerCitationRoutes(app, context) {
228
214
  for (let offset = 0; offset < keys.length; offset += 500) {
229
215
  const chunk = keys.slice(offset, offset + 500);
230
216
  const placeholders = chunk.map(() => "?").join(", ");
231
- const rows = db.prepare(`SELECT id, citation_key, revision${contents ? ", bibtex" : ""} FROM citation_library_entries
217
+ const rows = db.prepare(`SELECT id, citation_key, revision FROM citation_library_entries
232
218
  WHERE user_id = ? AND citation_key COLLATE NOCASE IN (${placeholders})`)
233
219
  .iterate(user.id, ...chunk);
234
220
  for (const row of rows)
235
- matches.push({ id: row.id, citationKey: row.citation_key, revision: row.revision,
236
- ...(contents ? { sameContent: comparableCitationBibtex(row.bibtex) === contents.get(row.citation_key.toLowerCase()) } : {}) });
221
+ matches.push({ id: row.id, citationKey: row.citation_key, revision: row.revision });
237
222
  }
238
223
  return { matches };
239
224
  });
@@ -245,46 +230,28 @@ export function registerCitationRoutes(app, context) {
245
230
  const citation = citationInput(body);
246
231
  const tagIds = citationTagIds(db, user.id, body?.tagIds);
247
232
  const collectionIds = citationCollectionIds(db, user.id, body?.collectionIds);
248
- const overwrite = body?.overwrite === true;
249
- const existing = db.prepare("SELECT id, revision FROM citation_library_entries WHERE user_id = ? AND citation_key = ? COLLATE NOCASE")
250
- .get(user.id, citation.citationKey);
251
- if (existing && !overwrite)
252
- return apiError(reply, 409, "CITATION_KEY_EXISTS");
253
- const expectedRevision = existing ? citationExpectedRevision(body?.expectedRevision) : null;
254
- if (existing && existing.revision !== expectedRevision) {
255
- return apiError(reply, 409, "CITATION_CONFLICT");
256
- }
257
- const id = existing?.id ?? randomUUID();
233
+ // POST only creates. An existing entry is changed through PATCH, which
234
+ // requires its revision; a key already in the library is a conflict.
235
+ const id = randomUUID();
258
236
  const timestamp = now();
259
237
  db.transaction(() => {
238
+ const existing = db.prepare("SELECT 1 FROM citation_library_entries WHERE user_id = ? AND citation_key = ? COLLATE NOCASE")
239
+ .get(user.id, citation.citationKey);
240
+ if (existing)
241
+ throw httpError(409, "CITATION_KEY_EXISTS");
260
242
  assertCitationCollectionCapacity(db, user.id, id, collectionIds ?? []);
261
- if (existing) {
262
- const result = db.prepare(`UPDATE citation_library_entries SET citation_key = ?, entry_type = ?, bibtex = ?,
263
- title = ?, authors = ?, year = ?, notes = COALESCE(?, notes), revision = revision + 1, updated_at = ?
264
- WHERE id = ? AND user_id = ? AND revision = ?`)
265
- .run(citation.citationKey, citation.entryType, citation.bibtex, citation.title, citation.authors, citation.year, citation.notes ?? null, timestamp, id, user.id, expectedRevision);
266
- if (!result.changes)
267
- throw httpError(409, "CITATION_CONFLICT");
268
- }
269
- else {
270
- db.prepare(`INSERT INTO citation_library_entries
271
- (id, user_id, citation_key, entry_type, bibtex, title, authors, year, notes, revision, created_at, updated_at)
272
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, 1, ?, ?)`)
273
- .run(id, user.id, citation.citationKey, citation.entryType, citation.bibtex, citation.title, citation.authors, citation.year, citation.notes ?? "", timestamp, timestamp);
274
- }
275
- if (tagIds !== null) {
276
- db.prepare("DELETE FROM citation_library_entry_tags WHERE entry_id = ?").run(id);
277
- for (const tagId of tagIds)
278
- db.prepare("INSERT INTO citation_library_entry_tags (entry_id, tag_id, created_at) VALUES (?, ?, ?)").run(id, tagId, timestamp);
279
- }
280
- // Saving from a project's .bib adds the chosen folder without removing
281
- // other placements of an already-saved reference.
243
+ db.prepare(`INSERT INTO citation_library_entries
244
+ (id, user_id, citation_key, entry_type, bibtex, title, authors, year, venue, notes, revision, created_at, updated_at)
245
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1, ?, ?)`)
246
+ .run(id, user.id, citation.citationKey, citation.entryType, citation.bibtex, citation.title, citation.authors, citation.year, citation.venue, citation.notes ?? "", timestamp, timestamp);
247
+ for (const tagId of tagIds ?? [])
248
+ db.prepare("INSERT INTO citation_library_entry_tags (entry_id, tag_id, created_at) VALUES (?, ?, ?)").run(id, tagId, timestamp);
282
249
  for (const collectionId of collectionIds ?? [])
283
250
  db.prepare("INSERT OR IGNORE INTO citation_library_entry_collections (entry_id, collection_id) VALUES (?, ?)").run(id, collectionId);
284
251
  })();
285
252
  const row = db.prepare("SELECT * FROM citation_library_entries WHERE id = ? AND user_id = ?")
286
253
  .get(id, user.id);
287
- return reply.code(existing ? 200 : 201).send({ entry: citationDetails(db, row), updated: Boolean(existing) });
254
+ return reply.code(201).send({ entry: citationDetails(db, row) });
288
255
  });
289
256
  app.patch("/api/citations/:citationId/tags", async (request, reply) => {
290
257
  const user = requireUser(request, reply, db);
@@ -360,9 +327,9 @@ export function registerCitationRoutes(app, context) {
360
327
  if (duplicate)
361
328
  return apiError(reply, 409, "CITATION_KEY_EXISTS");
362
329
  const result = db.prepare(`UPDATE citation_library_entries SET citation_key = ?, entry_type = ?, bibtex = ?,
363
- title = ?, authors = ?, year = ?, notes = COALESCE(?, notes), revision = revision + 1, updated_at = ?
330
+ title = ?, authors = ?, year = ?, venue = ?, notes = COALESCE(?, notes), revision = revision + 1, updated_at = ?
364
331
  WHERE id = ? AND user_id = ? AND revision = ?`)
365
- .run(citation.citationKey, citation.entryType, citation.bibtex, citation.title, citation.authors, citation.year, citation.notes ?? null, now(), citationId, user.id, expectedRevision);
332
+ .run(citation.citationKey, citation.entryType, citation.bibtex, citation.title, citation.authors, citation.year, citation.venue, citation.notes ?? null, now(), citationId, user.id, expectedRevision);
366
333
  if (!result.changes)
367
334
  return apiError(reply, 409, "CITATION_CONFLICT");
368
335
  const updated = db.prepare("SELECT * FROM citation_library_entries WHERE id = ? AND user_id = ?")
@@ -6,7 +6,7 @@ import { resolveSourcePath, safeRelativePath } from "../files.js";
6
6
  import { apiError, httpError } from "../http.js";
7
7
  import { accessibleProject } from "../projects.js";
8
8
  import { isCollaborativeTextFile } from "../collaboration.js";
9
- import { attachSuggestion, suggestionRow } from "../commentSuggestions.js";
9
+ import { attachSuggestion, suggestionReviewers, suggestionRow } from "../commentSuggestions.js";
10
10
  import { registerSuggestionRoutes } from "./commentSuggestions.js";
11
11
  import { defaultSuggestionComments } from "../../shared/suggestionMessages.js";
12
12
  import { serverLocale } from "../i18n.js";
@@ -217,8 +217,13 @@ export function registerCommentRoutes(app, context) {
217
217
  changed = true;
218
218
  }
219
219
  if (typeof body.resolved === "boolean") {
220
- if (body.resolved && suggestionRow(db, id, commentId)?.status === "pending")
221
- return apiError(reply, 409, "SUGGESTION_PENDING");
220
+ if (body.resolved) {
221
+ const suggestion = suggestionRow(db, id, commentId);
222
+ if (suggestion?.status === "pending" && (suggestion.apply_update
223
+ || suggestionReviewers(db, id, suggestion.author_id).some(user => user.id === suggestion.reviewer_id))) {
224
+ return apiError(reply, 409, "SUGGESTION_PENDING");
225
+ }
226
+ }
222
227
  changed = true;
223
228
  }
224
229
  if (!changed)
@@ -38,6 +38,16 @@ export function registerProjectGitRoutes(app, context) {
38
38
  return apiError(reply, 400, "GIT_TOKEN_INVALID");
39
39
  return { status: await projectGit.configureUserToken(user.id, body.token) };
40
40
  });
41
+ app.put("/api/account/github/identity", async (request, reply) => {
42
+ const user = requireUser(request, reply, db);
43
+ if (!user)
44
+ return;
45
+ const body = request.body;
46
+ if (typeof body.username !== "string" || typeof body.email !== "string") {
47
+ return apiError(reply, 400, "GIT_IDENTITY_INVALID");
48
+ }
49
+ return { status: projectGit.updateGitIdentity(user.id, body.username, body.email) };
50
+ });
41
51
  app.delete("/api/account/github", async (request, reply) => {
42
52
  const user = requireUser(request, reply, db);
43
53
  if (!user)
@@ -7,6 +7,8 @@ import { resolveSourcePath, safeRelativePath } from "../files.js";
7
7
  import { apiError, httpError } from "../http.js";
8
8
  import { MAX_TEXT_PREVIEW_BYTES } from "../limits.js";
9
9
  import { defaultHistoryTracking, historyTextCandidate } from "../../shared/historyTracking.js";
10
+ /** Files with agent changes examined per request; the newest edits matter most. */
11
+ const MAX_AGENT_CHANGE_FILES = 200;
10
12
  import { accessibleProject, canEdit } from "../projects.js";
11
13
  import { commentsSummaryForProject, projectJson, projectTextSnapshot, reanchorProjectSnapshot, requireEditableProject, requireProjectOwnerPermission, tagsForProject, text, touchProject } from "./projectShared.js";
12
14
  /** Register retained project version listing, inspection, restoration, and cleanup routes. */
@@ -80,6 +82,46 @@ export function registerProjectHistoryRoutes(app, context) {
80
82
  throw httpError(404, "PROJECT_NOT_FOUND");
81
83
  } });
82
84
  });
85
+ /**
86
+ * The caller's own coding-agent changes across the project, mapped to the
87
+ * current sources. Other users' agent work is never returned. Read-only:
88
+ * which changes were reviewed is kept by the browser.
89
+ */
90
+ app.get("/api/projects/:id/agent-changes", async (request, reply) => {
91
+ const user = requireUser(request, reply, db);
92
+ if (!user)
93
+ return;
94
+ const { id } = request.params;
95
+ if (!accessibleProject(db, id, user))
96
+ return apiError(reply, 404, "PROJECT_NOT_FOUND");
97
+ return await projectMutations.runConsistentRead(id, () => {
98
+ const paths = db.prepare(`SELECT DISTINCT file_path FROM project_edit_segments
99
+ WHERE project_id = ? AND author_id = ? AND has_agent = 1 ORDER BY file_path LIMIT ?`)
100
+ .all(id, user.id, MAX_AGENT_CHANGE_FILES).map((row) => row.file_path);
101
+ const files = [];
102
+ for (const filePath of paths) {
103
+ if (!isCollaborativeTextFile(filePath))
104
+ continue;
105
+ let source;
106
+ try {
107
+ source = resolveSourcePath(config, id, filePath);
108
+ }
109
+ catch {
110
+ continue;
111
+ }
112
+ if (!fs.existsSync(source) || !fs.statSync(source).isFile() || fs.statSync(source).size > maxCollaborativeFileBytes(config))
113
+ continue;
114
+ const content = fs.readFileSync(source, "utf8");
115
+ const changes = editHistory.agentChanges(id, filePath, content, user.id);
116
+ if (changes.length)
117
+ files.push({ path: filePath, sourceHash: hashText(content), changes });
118
+ }
119
+ return { files };
120
+ }, { preflight: () => {
121
+ if (!accessibleProject(db, id, user))
122
+ throw httpError(404, "PROJECT_NOT_FOUND");
123
+ } });
124
+ });
83
125
  app.get("/api/projects/:id/history", async (request, reply) => {
84
126
  const user = requireUser(request, reply, db);
85
127
  if (!user)
@@ -58,11 +58,11 @@ export function registerUserManagementRoutes(app, context) {
58
58
  const user = {
59
59
  id: randomUUID(), username, display_name: displayName,
60
60
  password_hash: await hashPassword(password), role, disabled: 0,
61
- must_change_password: 0, can_create_projects: body?.canCreateProjects === true ? 1 : 0, created_at: now()
61
+ must_change_password: 1, can_create_projects: body?.canCreateProjects === true ? 1 : 0, created_at: now()
62
62
  };
63
63
  db.prepare(`INSERT INTO users
64
64
  (id, username, display_name, password_hash, role, disabled, must_change_password, can_create_projects, created_at)
65
- VALUES (?, ?, ?, ?, ?, 0, 0, ?, ?)`)
65
+ VALUES (?, ?, ?, ?, ?, 0, 1, ?, ?)`)
66
66
  .run(user.id, user.username, user.display_name, user.password_hash, user.role, user.can_create_projects, user.created_at);
67
67
  return reply.code(201).send({ user: publicUser(user) });
68
68
  });
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Index just after the brace that closes the BibTeX group opened at `start`,
3
+ * or -1 when the group is not closed. A backslash escapes the next character,
4
+ * so `\{` and `\}` are not counted.
5
+ */
6
+ export function bracedGroupEnd(source, start) {
7
+ let depth = 0;
8
+ for (let index = start; index < source.length; index += 1) {
9
+ const character = source[index];
10
+ if (character === "\\") {
11
+ index += 1;
12
+ continue;
13
+ }
14
+ if (character === "{")
15
+ depth += 1;
16
+ else if (character === "}" && --depth === 0)
17
+ return index + 1;
18
+ }
19
+ return -1;
20
+ }