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
@@ -1,7 +1,7 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { randomUUID } from "node:crypto";
4
- import { makeDiff } from "@sanity/diff-match-patch";
4
+ import { textReplacements } from "../../shared/textDiff.js";
5
5
  import { isTextContent } from "../../shared/fileTypes.js";
6
6
  import { isCollaborativeTextFile, maxCollaborativeFileBytes } from "../collaboration.js";
7
7
  import { assertNoSourceSymlinks, outputRoot, resolveSourcePath, sourceRoot } from "../files.js";
@@ -34,30 +34,9 @@ export async function ensureAgentInstructions(context, projectId, user) {
34
34
  }, { preflight: () => { requireEditableProject(db, projectId, user); } });
35
35
  }
36
36
  const ignored = (name) => name === ".git" || name === ".texlite-agent-conflicts" || /\.(?:collaboration-\d+-[^.]+|agent-[^.]+)\.tmp$/.test(name);
37
+ /** Exact (uncleaned) replacements, so three-way merging never widens an edit. */
37
38
  function changes(before, after) {
38
- const result = [];
39
- let offset = 0;
40
- let pending;
41
- for (const [kind, text] of makeDiff(before, after, { checkLines: true, timeout: 1 })) {
42
- if (kind === 0) {
43
- if (pending)
44
- result.push(pending);
45
- pending = undefined;
46
- offset += text.length;
47
- }
48
- else {
49
- pending ??= { from: offset, to: offset, insert: "" };
50
- if (kind === -1) {
51
- offset += text.length;
52
- pending.to = offset;
53
- }
54
- else
55
- pending.insert += text;
56
- }
57
- }
58
- if (pending)
59
- result.push(pending);
60
- return result;
39
+ return textReplacements(before, after);
61
40
  }
62
41
  /** Conservative three-way merge: never fuzzy-apply overlapping replacements. */
63
42
  export function mergeAgentText(base, editor, agent) {
@@ -264,7 +243,7 @@ export class AgentSourceSync {
264
243
  if (next !== null) {
265
244
  if (next !== after?.text)
266
245
  this.write(relative, next);
267
- if (!collaboration.importExternalText(this.projectId, relative, next, this.userId)) {
246
+ if (!collaboration.importExternalText(this.projectId, relative, next, this.userId, { agent: true })) {
268
247
  const previous = before?.text ?? "";
269
248
  reanchorFileComments(db, this.projectId, relative, previous, next);
270
249
  collaboration.updateFile(this.projectId, relative, next, this.userId);
@@ -289,7 +268,8 @@ export class AgentSourceSync {
289
268
  this.syncing = false;
290
269
  if (changed.length) {
291
270
  touchProject(db, this.projectId, this.userId);
292
- recordHistory(this.projectId, this.userId, "file", changed);
271
+ // The task's user is the author; the flag shows a coding agent made the change.
272
+ recordHistory(this.projectId, this.userId, "file", changed, { hasAgent: true });
293
273
  collaboration.signalComments(this.projectId);
294
274
  }
295
275
  }
@@ -336,6 +316,6 @@ function externalEdit(filePath, before, after, authorId) {
336
316
  shift += edit.insert.length - (edit.to - edit.from);
337
317
  return createEditHistorySpan(edit.from, afterStart, before.slice(edit.from, edit.to), edit.insert);
338
318
  });
339
- return { filePath, authorId, kind: "edit", beforeHash: hashText(before), afterHash: hashText(after), createdAt, updatedAt: createdAt,
319
+ return { filePath, authorId, kind: "edit", hasAgent: true, beforeHash: hashText(before), afterHash: hashText(after), createdAt, updatedAt: createdAt,
340
320
  steps: [{ beforeHash: hashText(before), afterHash: hashText(after), createdAt, spans }] };
341
321
  }
@@ -125,9 +125,9 @@ export async function buildApp(config, db, options = {}) {
125
125
  app.log.error({ err: error, projectId: id }, "Failed to record project edit history");
126
126
  signalHistory(id);
127
127
  });
128
- const recordHistory = (projectId, userId, reason, paths) => {
128
+ const recordHistory = (projectId, userId, reason, paths, { hasAgent = false } = {}) => {
129
129
  try {
130
- const version = history.record(projectId, userId, reason, failedSnapshots.has(projectId) ? undefined : paths, { deferRetention: reason === "autosave" });
130
+ const version = history.record(projectId, userId, reason, failedSnapshots.has(projectId) ? undefined : paths, { deferRetention: reason === "autosave", hasAgent });
131
131
  if (failedSnapshots.delete(projectId))
132
132
  signalHistory(projectId);
133
133
  if (version && reason === "autosave")
@@ -144,7 +144,9 @@ export async function buildApp(config, db, options = {}) {
144
144
  const collaboration = new CollaborationService(config, db, ({ projectId, userId, paths, edits, durationMs }) => {
145
145
  const started = performance.now();
146
146
  editRetry.save(projectId, edits);
147
- recordHistory(projectId, userId, "autosave", paths);
147
+ // A coding agent's text reaches the source through the live room, so the
148
+ // autosave that persists it carries the flag of its edit segments.
149
+ recordHistory(projectId, userId, "autosave", paths, { hasAgent: edits.some((edit) => edit.hasAgent) });
148
150
  metrics.record("collaboration.persist", durationMs + performance.now() - started);
149
151
  });
150
152
  const projectMutations = new ProjectMutationCoordinator(collaboration);
@@ -274,16 +276,21 @@ export async function buildApp(config, db, options = {}) {
274
276
  : null;
275
277
  const routePrefix = basePathPrefix(config.basePath);
276
278
  await app.register(async (routes) => {
277
- routes.addHook("onRequest", async (request) => {
278
- const requestPath = withoutBasePath(config.basePath, request.url) ?? request.url;
279
+ routes.addHook("onRequest", async (request, reply) => {
280
+ const requestPath = (withoutBasePath(config.basePath, request.url) ?? request.url).split("?")[0];
279
281
  if (requestPath.startsWith("/api/")
280
282
  && requestPath !== "/api/auth/login"
281
283
  && requestPath !== "/api/health"
282
284
  && requestPath !== "/api/config") {
283
285
  const token = request.cookies.texlite_session;
284
- if (token && !currentUser(request, db)) {
286
+ const user = token ? currentUser(request, db) : null;
287
+ if (token && !user) {
285
288
  db.prepare("DELETE FROM sessions WHERE id = ?").run(digestToken(token));
286
289
  }
290
+ if (user?.must_change_password
291
+ && !["/api/me", "/api/me/password", "/api/auth/logout"].includes(requestPath)) {
292
+ return apiError(reply, 403, "PASSWORD_CHANGE_REQUIRED");
293
+ }
287
294
  }
288
295
  });
289
296
  registerSystemRoutes(routes, {
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Small least-recently-used cache bounded by entry count and bytes.
3
+ *
4
+ * The TTL does more than stop an entry from being reused: one unref'd timer,
5
+ * aimed at the earliest expiry, frees expired entries so an idle project's
6
+ * data does not stay resident until something else displaces it. The timer is
7
+ * not re-armed once the cache is empty and never keeps the process alive.
8
+ */
9
+ export class BoundedExpiringCache {
10
+ limits;
11
+ entries = new Map();
12
+ totalBytes = 0;
13
+ sweep = null;
14
+ constructor(limits) {
15
+ this.limits = limits;
16
+ }
17
+ get(key) {
18
+ const entry = this.entries.get(key);
19
+ if (!entry || entry.expiresAt <= Date.now())
20
+ return undefined;
21
+ // Refresh recency so an actively used entry is evicted last.
22
+ this.entries.delete(key);
23
+ this.entries.set(key, entry);
24
+ if (this.limits.refreshOnHit)
25
+ entry.expiresAt = Date.now() + this.limits.ttlMs;
26
+ return entry.value;
27
+ }
28
+ set(key, value, bytes) {
29
+ this.delete(key);
30
+ if (bytes > this.limits.maxEntryBytes)
31
+ return;
32
+ this.entries.set(key, { value, bytes, expiresAt: Date.now() + this.limits.ttlMs });
33
+ this.totalBytes += bytes;
34
+ while (this.entries.size > this.limits.maxEntries || this.totalBytes > this.limits.maxBytes) {
35
+ const oldest = this.entries.keys().next().value;
36
+ if (oldest === undefined)
37
+ break;
38
+ this.delete(oldest);
39
+ }
40
+ this.scheduleSweep();
41
+ }
42
+ delete(key) {
43
+ const removed = this.entries.get(key);
44
+ if (!removed)
45
+ return;
46
+ this.entries.delete(key);
47
+ this.totalBytes -= removed.bytes;
48
+ }
49
+ stats() {
50
+ return { entries: this.entries.size, bytes: this.totalBytes };
51
+ }
52
+ scheduleSweep() {
53
+ if (this.sweep !== null || this.entries.size === 0)
54
+ return;
55
+ let earliest = Infinity;
56
+ for (const entry of this.entries.values())
57
+ earliest = Math.min(earliest, entry.expiresAt);
58
+ this.sweep = setTimeout(() => {
59
+ this.sweep = null;
60
+ const now = Date.now();
61
+ for (const [key, entry] of this.entries) {
62
+ if (entry.expiresAt <= now)
63
+ this.delete(key);
64
+ }
65
+ this.scheduleSweep();
66
+ }, Math.max(0, earliest - Date.now()));
67
+ this.sweep.unref();
68
+ }
69
+ }
@@ -8,7 +8,7 @@ export function exportCitationFolder(db, userId, folder) {
8
8
  const bundle = { format: CITATION_FOLDER_FORMAT, version: CITATION_FOLDER_VERSION, entries: [] };
9
9
  let bytes = Buffer.byteLength(JSON.stringify(bundle), "utf8");
10
10
  const rows = db.prepare(`SELECT entry.citation_key AS citationKey, entry.entry_type AS entryType,
11
- entry.bibtex, entry.title, entry.authors, entry.year, entry.notes
11
+ entry.bibtex, entry.title, entry.authors, entry.year, entry.venue, entry.notes
12
12
  FROM citation_library_entries entry JOIN citation_library_entry_collections link ON link.entry_id = entry.id
13
13
  WHERE entry.user_id = ? AND link.collection_id = ? ORDER BY entry.citation_key COLLATE NOCASE, entry.id`)
14
14
  .iterate(userId, folder.id);
@@ -53,16 +53,16 @@ export function registerCitationFolderImport(app, db) {
53
53
  }
54
54
  db.prepare("INSERT INTO citation_library_collections (id, user_id, name, created_at) VALUES (?, ?, ?, ?)").run(id, user.id, candidate, timestamp);
55
55
  const upsert = db.prepare(`INSERT INTO citation_library_entries
56
- (id, user_id, citation_key, entry_type, bibtex, title, authors, year, notes, revision, created_at, updated_at)
57
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, 1, ?, ?)
56
+ (id, user_id, citation_key, entry_type, bibtex, title, authors, year, venue, notes, revision, created_at, updated_at)
57
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1, ?, ?)
58
58
  ON CONFLICT (user_id, citation_key) DO UPDATE SET citation_key = excluded.citation_key,
59
59
  entry_type = excluded.entry_type, bibtex = excluded.bibtex, title = excluded.title,
60
- authors = excluded.authors, year = excluded.year, notes = excluded.notes,
60
+ authors = excluded.authors, year = excluded.year, venue = excluded.venue, notes = excluded.notes,
61
61
  revision = citation_library_entries.revision + 1, updated_at = excluded.updated_at
62
62
  RETURNING id`);
63
63
  const place = db.prepare("INSERT INTO citation_library_entry_collections (entry_id, collection_id) VALUES (?, ?)");
64
64
  for (const entry of entries.values()) {
65
- const saved = upsert.get(randomUUID(), user.id, entry.citationKey, entry.entryType, entry.bibtex, entry.title, entry.authors, entry.year, entry.notes, timestamp, timestamp);
65
+ const saved = upsert.get(randomUUID(), user.id, entry.citationKey, entry.entryType, entry.bibtex, entry.title, entry.authors, entry.year, entry.venue, entry.notes, timestamp, timestamp);
66
66
  // Existing placements and tags are retained. Imported content replaces
67
67
  // the user's shared entry, so all its placements see the updated notes.
68
68
  place.run(saved.id, id);
@@ -29,6 +29,7 @@ export function citationInput(value) {
29
29
  return {
30
30
  bibtex: body.bibtex.trim(), citationKey: body.citationKey.trim(), entryType: body.entryType.trim(),
31
31
  title: nullableText(body.title, 2048), authors: nullableText(body.authors, 2048), year: nullableText(body.year, 128),
32
+ venue: nullableText(body.venue, 2048),
32
33
  notes: body.notes
33
34
  };
34
35
  }
@@ -224,7 +224,8 @@ export class CollaborationService {
224
224
  this.externalSources.delete(projectId); };
225
225
  }
226
226
  /** Apply disk edits as a real attributed Yjs delta, retaining pending human edits and anchors. */
227
- importExternalText(projectId, filePath, content, userId) {
227
+ /** `agent` marks text written by a coding agent on behalf of `userId`; it is recorded in edit history. */
228
+ importExternalText(projectId, filePath, content, userId, { agent = false } = {}) {
228
229
  const room = this.rooms.get(projectId);
229
230
  if (!room || !isCollaborativeTextFile(filePath))
230
231
  return false;
@@ -247,7 +248,7 @@ export class CollaborationService {
247
248
  offset += value.length;
248
249
  }
249
250
  }
250
- }, { externalUserId: userId });
251
+ }, { externalUserId: userId, ...(agent ? { agent: true } : {}) });
251
252
  this.bumpFiles(room, { kind: "update", path: filePath });
252
253
  return true;
253
254
  }
@@ -1033,7 +1034,7 @@ export class CollaborationService {
1033
1034
  this.recordEditStep(room, filePath, connection.user.id, event, before, after, this.activeFormatLease(room, filePath)?.connection === connection);
1034
1035
  }
1035
1036
  if (isExternalOrigin(transaction.origin) && before !== after) {
1036
- this.recordEditStep(room, filePath, transaction.origin.externalUserId, event, before, after);
1037
+ this.recordEditStep(room, filePath, transaction.origin.externalUserId, event, before, after, false, transaction.origin.agent === true);
1037
1038
  }
1038
1039
  if (before !== after) {
1039
1040
  const edits = [];
@@ -1077,7 +1078,7 @@ export class CollaborationService {
1077
1078
  * segment is only handed to the history service after `flushRoom()` has
1078
1079
  * made the matching source content durable.
1079
1080
  */
1080
- recordEditStep(room, filePath, authorId, event, before, after, formatted = false) {
1081
+ recordEditStep(room, filePath, authorId, event, before, after, formatted = false, hasAgent = false) {
1081
1082
  const spans = editSpansFromYDelta(event.delta, before, after);
1082
1083
  if (!spans.length)
1083
1084
  return;
@@ -1095,6 +1096,8 @@ export class CollaborationService {
1095
1096
  && previous.filePath === filePath
1096
1097
  && previous.authorId === authorId
1097
1098
  && previous.kind === kind
1099
+ // Agent and direct edits by the same user stay in separate segments.
1100
+ && Boolean(previous.hasAgent) === hasAgent
1098
1101
  && previous.afterHash === step.beforeHash
1099
1102
  && Number.isFinite(previousTime)
1100
1103
  && Date.parse(createdAt) - previousTime <= EDIT_SEGMENT_IDLE_MS) {
@@ -1107,6 +1110,7 @@ export class CollaborationService {
1107
1110
  filePath,
1108
1111
  authorId,
1109
1112
  kind,
1113
+ ...(hasAgent ? { hasAgent: true } : {}),
1110
1114
  beforeHash: step.beforeHash,
1111
1115
  afterHash: step.afterHash,
1112
1116
  createdAt,
package/dist/server/db.js CHANGED
@@ -174,6 +174,29 @@ const databaseMigrations = [
174
174
  if (missingColumn(db, "citation_library_entries", "notes")) {
175
175
  db.exec("ALTER TABLE citation_library_entries ADD COLUMN notes TEXT NOT NULL DEFAULT ''");
176
176
  }
177
+ } },
178
+ { version: 20, name: "add_user_git_identity", apply: (db) => {
179
+ if (missingColumn(db, "user_github_settings", "git_username")) {
180
+ db.exec("ALTER TABLE user_github_settings ADD COLUMN git_username TEXT");
181
+ }
182
+ if (missingColumn(db, "user_github_settings", "git_email")) {
183
+ db.exec("ALTER TABLE user_github_settings ADD COLUMN git_email TEXT");
184
+ }
185
+ } },
186
+ { version: 21, name: "add_citation_venue", apply: (db) => {
187
+ if (missingColumn(db, "citation_library_entries", "venue")) {
188
+ db.exec("ALTER TABLE citation_library_entries ADD COLUMN venue TEXT");
189
+ }
190
+ } },
191
+ // A coding agent took part in a snapshot or an edit segment. Rows written
192
+ // before this migration cannot be classified reliably and stay false.
193
+ { version: 22, name: "add_agent_history_flags", apply: (db) => {
194
+ if (missingColumn(db, "project_history_versions", "has_agent")) {
195
+ db.exec("ALTER TABLE project_history_versions ADD COLUMN has_agent INTEGER NOT NULL DEFAULT 0");
196
+ }
197
+ if (missingColumn(db, "project_edit_segments", "has_agent")) {
198
+ db.exec("ALTER TABLE project_edit_segments ADD COLUMN has_agent INTEGER NOT NULL DEFAULT 0");
199
+ }
177
200
  } }
178
201
  ];
179
202
  function migrateGitHubTokensToUsers(db) {
@@ -1,6 +1,7 @@
1
1
  import { createHash, randomUUID } from "node:crypto";
2
2
  import { CONFIG_DEFAULTS } from "./config.js";
3
3
  import { safeRelativePath } from "./files.js";
4
+ import { collectAgentChanges } from "./agentChanges.js";
4
5
  /** Store reversible replacements; only selection-history presentation is shortened. */
5
6
  export function createEditHistorySpan(beforeStart, afterStart, deleted, inserted) {
6
7
  return {
@@ -10,8 +11,13 @@ export function createEditHistorySpan(beforeStart, afterStart, deleted, inserted
10
11
  deletedPreview: deleted, insertedPreview: inserted, truncated: false
11
12
  };
12
13
  }
14
+ /** Agent-change mapping walks at most this many of a file's newest segments. */
15
+ const MAX_AGENT_CHANGE_CHAIN_SEGMENTS = 2_000;
13
16
  const DEFAULT_RESULT_LIMIT = 60;
14
- const EDIT_SESSION_GAP_MS = 2 * 60 * 1_000;
17
+ /** Edits separated by at most this pause belong to one displayed entry. */
18
+ const EDIT_SESSION_GAP_MS = 5 * 60 * 1_000;
19
+ /** A long continuous session is still split, so earlier states stay visible. */
20
+ const MAX_EDIT_ENTRY_SPAN_MS = 30 * 60 * 1_000;
15
21
  const MAX_PASSAGE_PREVIEW_CHARS = 6_000;
16
22
  export const DEFAULT_EDIT_HISTORY_MAX_STORAGE_BYTES = CONFIG_DEFAULTS.editHistoryMaxStorageMB * 1024 * 1024;
17
23
  /**
@@ -49,11 +55,11 @@ export class ProjectEditHistoryService {
49
55
  segments.push({ segment, stepsJson, stepsBytes });
50
56
  }
51
57
  const insert = this.db.prepare(`INSERT INTO project_edit_segments
52
- (id, project_id, file_path, author_id, kind, before_hash, after_hash, steps_json, created_at, updated_at, steps_bytes)
53
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`);
58
+ (id, project_id, file_path, author_id, kind, has_agent, before_hash, after_hash, steps_json, created_at, updated_at, steps_bytes)
59
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`);
54
60
  this.db.transaction(() => {
55
61
  for (const { segment, stepsJson, stepsBytes } of segments) {
56
- insert.run(randomUUID(), projectId, segment.filePath, segment.authorId, segment.kind, segment.beforeHash, segment.afterHash, stepsJson, segment.createdAt, segment.updatedAt, stepsBytes);
62
+ insert.run(randomUUID(), projectId, segment.filePath, segment.authorId, segment.kind, segment.hasAgent ? 1 : 0, segment.beforeHash, segment.afterHash, stepsJson, segment.createdAt, segment.updatedAt, stepsBytes);
57
63
  }
58
64
  for (const segment of skipped)
59
65
  this.recordRetentionBoundary(projectId, segment.filePath, segment.afterHash, segment.updatedAt);
@@ -175,8 +181,11 @@ export class ProjectEditHistoryService {
175
181
  break;
176
182
  }
177
183
  if (relevant) {
178
- if (openEntry && (canMergeIntoEntry(openEntry, row) || hasSameSelectionContent(openEntry, afterPassage))) {
179
- mergeSelectionHistoryEntry(openEntry, row);
184
+ if (openEntry && canMergeIntoEntry(openEntry, row)) {
185
+ mergeSelectionHistoryEntry(openEntry, row, "session");
186
+ }
187
+ else if (openEntry && hasSameSelectionContent(openEntry, afterPassage)) {
188
+ mergeSelectionHistoryEntry(openEntry, row, "same-text");
180
189
  }
181
190
  else {
182
191
  if (openEntry) {
@@ -203,6 +212,40 @@ export class ProjectEditHistoryService {
203
212
  }
204
213
  return { entries, baseline, hasMore: !exhaustedRows, chainComplete };
205
214
  }
215
+ /**
216
+ * Coding-agent changes made for `userId` in one file, mapped to `currentSource`.
217
+ * Only the newest part of the chain is walked; a gap in it (an unrecorded
218
+ * replacement, a restore, retention) drops everything before the gap, and a
219
+ * chain that does not end at the current source yields nothing rather than
220
+ * misplaced ranges.
221
+ */
222
+ agentChanges(projectId, filePathInput, currentSource, userId) {
223
+ const filePath = safeRelativePath(filePathInput);
224
+ const rows = this.db.prepare(`SELECT id, author_id, has_agent, before_hash, after_hash, steps_json
225
+ FROM project_edit_segments WHERE project_id = ? AND file_path = ?
226
+ ORDER BY updated_at DESC, rowid DESC LIMIT ?`)
227
+ .all(projectId, filePath, MAX_AGENT_CHANGE_CHAIN_SEGMENTS).reverse();
228
+ let steps = [];
229
+ let expectedHash = null;
230
+ for (const row of rows) {
231
+ const parsed = parseSteps(row.steps_json);
232
+ const valid = parsed.length > 0 && parsed[0].beforeHash === row.before_hash && parsed.at(-1).afterHash === row.after_hash
233
+ && parsed.every((step, index) => index === 0 || parsed[index - 1].afterHash === step.beforeHash);
234
+ // A gap before this row, or a row that cannot be replayed, means earlier
235
+ // positions cannot be carried forward.
236
+ if (!valid || (expectedHash !== null && row.before_hash !== expectedHash))
237
+ steps = [];
238
+ expectedHash = row.after_hash;
239
+ if (!valid)
240
+ continue;
241
+ const agent = Boolean(row.has_agent) && row.author_id === userId;
242
+ parsed.forEach((step, index) => steps.push({ id: `${row.id}:${index}`, agent, createdAt: step.createdAt, spans: step.spans }));
243
+ }
244
+ if (expectedHash !== hashText(currentSource))
245
+ return [];
246
+ const first = steps.findIndex((step) => step.agent);
247
+ return first < 0 ? [] : collectAgentChanges(steps.slice(first), currentSource);
248
+ }
206
249
  reachedRetentionBoundary(projectId, filePath, expectedHash) {
207
250
  const row = this.db.prepare(`SELECT after_hash FROM project_edit_history_boundaries
208
251
  WHERE project_id = ? AND file_path = ?`).get(projectId, filePath);
@@ -218,15 +261,26 @@ function createSelectionHistoryEntry(row, afterPassage) {
218
261
  updatedAt: row.updated_at,
219
262
  authorKeys: new Set([authorKey(row)]),
220
263
  authors: [authorFromRow(row)],
264
+ hasAgent: Boolean(row.has_agent),
221
265
  content: content.text,
222
266
  contentTruncated: content.truncated
223
267
  };
224
268
  }
269
+ /**
270
+ * Rows are visited newest first. A row joins the open entry when it is part of
271
+ * the same editing session (no pause longer than the gap before the entry's
272
+ * oldest edit, and the entry stays within its maximum span) and when it is the
273
+ * same kind of change: agent and direct edits are shown separately.
274
+ */
225
275
  function canMergeIntoEntry(entry, row) {
226
- const latest = Date.parse(entry.updatedAt);
227
- const current = Date.parse(row.updated_at);
228
- return Number.isFinite(latest) && Number.isFinite(current)
229
- && latest >= current && latest - current <= EDIT_SESSION_GAP_MS;
276
+ const newest = Date.parse(entry.updatedAt);
277
+ const oldest = Date.parse(entry.createdAt);
278
+ const rowEnd = Date.parse(row.updated_at);
279
+ const rowStart = Date.parse(row.created_at);
280
+ return [newest, oldest, rowEnd, rowStart].every(Number.isFinite)
281
+ && Boolean(row.has_agent) === entry.hasAgent
282
+ && oldest >= rowEnd && oldest - rowEnd <= EDIT_SESSION_GAP_MS
283
+ && newest - rowStart <= MAX_EDIT_ENTRY_SPAN_MS;
230
284
  }
231
285
  /**
232
286
  * A history row can be relevant because it moved a selection boundary even
@@ -241,8 +295,13 @@ function hasSameSelectionContent(entry, passage) {
241
295
  && candidate.text !== null && !candidate.truncated
242
296
  && entry.content === candidate.text;
243
297
  }
244
- function mergeSelectionHistoryEntry(entry, row) {
298
+ function mergeSelectionHistoryEntry(entry, row, reason) {
245
299
  entry.createdAt = row.created_at;
300
+ // Session merges only join rows of the same kind, so the flag is unchanged.
301
+ // An older row folded in because the entry's newer rows left the selected
302
+ // text as it produced it is the row that wrote that text: its flag decides.
303
+ if (reason === "same-text")
304
+ entry.hasAgent = Boolean(row.has_agent);
246
305
  if (!entry.authorKeys.has(authorKey(row))) {
247
306
  entry.authorKeys.add(authorKey(row));
248
307
  entry.authors.push(authorFromRow(row));
@@ -332,7 +391,7 @@ function validateSpan(span) {
332
391
  || typeof span.truncated !== "boolean")
333
392
  throw new Error("Invalid edit history span");
334
393
  }
335
- function parseSteps(input) {
394
+ export function parseSteps(input) {
336
395
  try {
337
396
  const parsed = JSON.parse(input);
338
397
  if (!Array.isArray(parsed))
@@ -23,6 +23,7 @@ export class ProjectGitService {
23
23
  assertNoSourceSymlinks(this.config, project.id);
24
24
  const settings = this.settings(project.id);
25
25
  const account = this.userSettings(project.owner_id);
26
+ const commitIdentity = this.identityForUser(project.owner_id);
26
27
  const gitDirectory = path.join(sourceRoot(this.config, project.id), ".git");
27
28
  let gitStat = null;
28
29
  try {
@@ -49,7 +50,8 @@ export class ProjectGitService {
49
50
  restorable: false,
50
51
  changedFiles: 0,
51
52
  ahead: 0,
52
- latestCommit: null
53
+ latestCommit: null,
54
+ commitIdentity
53
55
  };
54
56
  const root = sourceRoot(this.config, project.id);
55
57
  const porcelain = (await this.git(root, ["status", "--porcelain=v1"])).stdout.trim();
@@ -77,12 +79,35 @@ export class ProjectGitService {
77
79
  restorable: porcelain.split("\n").some((line) => Boolean(line) && !line.startsWith("??")),
78
80
  changedFiles: porcelain ? porcelain.split("\n").length : 0,
79
81
  ahead: aheadResult?.code === 0 ? Number.parseInt(aheadResult.stdout.trim(), 10) || 0 : 0,
80
- latestCommit: latestResult.code === 0 ? parseCommit(latestResult.stdout.trim()) : null
82
+ latestCommit: latestResult.code === 0 ? parseCommit(latestResult.stdout.trim()) : null,
83
+ commitIdentity
81
84
  };
82
85
  }
83
86
  githubAccountStatus(userId) {
84
87
  const settings = this.userSettings(userId);
85
- return { tokenConfigured: Boolean(settings?.token_ciphertext), githubLogin: settings?.github_login ?? null };
88
+ const identity = this.identityForUser(userId);
89
+ return {
90
+ tokenConfigured: Boolean(settings?.token_ciphertext),
91
+ githubLogin: settings?.github_login ?? null,
92
+ gitUsername: identity.name,
93
+ gitEmail: identity.email
94
+ };
95
+ }
96
+ updateGitIdentity(userId, usernameInput, emailInput) {
97
+ const username = usernameInput.trim();
98
+ const email = emailInput.trim();
99
+ const controlCharacter = /\p{Cc}/u;
100
+ if (!username || username.length > 100 || controlCharacter.test(username) || /[<>]/.test(username)
101
+ || !email || email.length > 254 || controlCharacter.test(email) || !/^[^\s<>@]+@[^\s<>@]+$/.test(email)) {
102
+ throw httpError(400, "GIT_IDENTITY_INVALID");
103
+ }
104
+ const timestamp = new Date().toISOString();
105
+ this.db.prepare(`INSERT INTO user_github_settings (user_id, git_username, git_email, created_at, updated_at)
106
+ VALUES (?, ?, ?, ?, ?)
107
+ ON CONFLICT(user_id) DO UPDATE SET
108
+ git_username = excluded.git_username, git_email = excluded.git_email, updated_at = excluded.updated_at`)
109
+ .run(userId, username, email, timestamp, timestamp);
110
+ return this.githubAccountStatus(userId);
86
111
  }
87
112
  async configureUserToken(userId, tokenInput) {
88
113
  const token = tokenInput.trim();
@@ -101,7 +126,11 @@ export class ProjectGitService {
101
126
  return this.githubAccountStatus(userId);
102
127
  }
103
128
  removeUserToken(userId) {
104
- this.db.prepare("DELETE FROM user_github_settings WHERE user_id = ?").run(userId);
129
+ // Keep the row so a separately configured commit identity survives
130
+ // disconnecting GitHub.
131
+ this.db.prepare(`UPDATE user_github_settings
132
+ SET token_ciphertext = NULL, github_login = NULL, updated_at = ? WHERE user_id = ?`)
133
+ .run(new Date().toISOString(), userId);
105
134
  return this.githubAccountStatus(userId);
106
135
  }
107
136
  async createGitHubRepository(project, name, isPrivate) {
@@ -148,13 +177,24 @@ export class ProjectGitService {
148
177
  const staged = await this.git(root, ["diff", "--cached", "--quiet"], [1]);
149
178
  if (staged.code === 0)
150
179
  throw httpError(409, "GIT_NO_CHANGES");
180
+ const identity = this.identityForUser(owner.id);
181
+ // GIT_AUTHOR_* / GIT_COMMITTER_* take precedence over -c configuration.
182
+ // Pin them to the saved identity so a host-level environment cannot
183
+ // replace the author shown in the UI or on GitHub.
184
+ const identityEnvironment = {
185
+ ...process.env,
186
+ GIT_AUTHOR_NAME: identity.name,
187
+ GIT_AUTHOR_EMAIL: identity.email,
188
+ GIT_COMMITTER_NAME: identity.name,
189
+ GIT_COMMITTER_EMAIL: identity.email
190
+ };
151
191
  await this.git(root, [
152
- "-c", `user.name=${owner.username}`,
153
- "-c", `user.email=${owner.username}@texlite.com`,
192
+ "-c", `user.name=${identity.name}`,
193
+ "-c", `user.email=${identity.email}`,
154
194
  "-c", "commit.gpgSign=false",
155
195
  "-c", "core.hooksPath=/dev/null",
156
196
  "commit", "-m", message
157
- ]);
197
+ ], [], identityEnvironment);
158
198
  const result = await this.git(root, ["log", "-1", "--format=%H%x1f%h%x1f%an%x1f%ae%x1f%aI%x1f%s"]);
159
199
  return parseCommit(result.stdout.trim());
160
200
  }
@@ -282,6 +322,17 @@ export class ProjectGitService {
282
322
  userSettings(userId) {
283
323
  return this.db.prepare("SELECT * FROM user_github_settings WHERE user_id = ?").get(userId);
284
324
  }
325
+ /** Resolve the effective author identity, applying account defaults. */
326
+ identityForUser(userId) {
327
+ const row = this.db.prepare(`SELECT users.username, settings.git_username, settings.git_email
328
+ FROM users LEFT JOIN user_github_settings settings ON settings.user_id = users.id
329
+ WHERE users.id = ?`).get(userId);
330
+ const username = row?.username ?? "texlite";
331
+ return {
332
+ name: row?.git_username?.trim() || username,
333
+ email: row?.git_email?.trim() || `${username}@texlite.com`
334
+ };
335
+ }
285
336
  requireUserTokenSettings(userId) {
286
337
  const settings = this.userSettings(userId);
287
338
  if (!settings?.token_ciphertext)