@self-review/serve 1.45.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 (553) hide show
  1. package/README.md +128 -0
  2. package/dist/cli.js +839 -0
  3. package/dist/cli.js.map +1 -0
  4. package/dist/client/assets/_basePickBy-DzL66huQ.js +1 -0
  5. package/dist/client/assets/_baseUniq-D_kA9hnK.js +1 -0
  6. package/dist/client/assets/arc-LxCcHggQ.js +1 -0
  7. package/dist/client/assets/architectureDiagram-VXUJARFQ-BmSW2FCh.js +36 -0
  8. package/dist/client/assets/blockDiagram-VD42YOAC-Duz6oS5b.js +122 -0
  9. package/dist/client/assets/c4Diagram-YG6GDRKO-Bv4P72yB.js +10 -0
  10. package/dist/client/assets/channel-ydExFSqY.js +1 -0
  11. package/dist/client/assets/chunk-4BX2VUAB-D2GfUqwd.js +1 -0
  12. package/dist/client/assets/chunk-55IACEB6-C68L7s0h.js +1 -0
  13. package/dist/client/assets/chunk-B4BG7PRW-BtVwfswM.js +165 -0
  14. package/dist/client/assets/chunk-DI55MBZ5-BDdO91wt.js +220 -0
  15. package/dist/client/assets/chunk-FMBD7UC4-tB9OepVI.js +15 -0
  16. package/dist/client/assets/chunk-QN33PNHL-HjKgp1PB.js +1 -0
  17. package/dist/client/assets/chunk-QZHKN3VN-GT04-vw7.js +1 -0
  18. package/dist/client/assets/chunk-TZMSLE5B-DpxXSXMp.js +1 -0
  19. package/dist/client/assets/classDiagram-2ON5EDUG-Dg8dmmRD.js +1 -0
  20. package/dist/client/assets/classDiagram-v2-WZHVMYZB-Dg8dmmRD.js +1 -0
  21. package/dist/client/assets/clone-Bq6xpRgi.js +1 -0
  22. package/dist/client/assets/cose-bilkent-S5V4N54A-Ds41oEbD.js +1 -0
  23. package/dist/client/assets/cytoscape.esm-5J0xJHOV.js +321 -0
  24. package/dist/client/assets/dagre-6UL2VRFP-DZiEousR.js +4 -0
  25. package/dist/client/assets/defaultLocale-DX6XiGOO.js +1 -0
  26. package/dist/client/assets/diagram-PSM6KHXK-0_alnUMs.js +24 -0
  27. package/dist/client/assets/diagram-QEK2KX5R-KFaKVdU8.js +43 -0
  28. package/dist/client/assets/diagram-S2PKOQOG-C2Dy10VG.js +24 -0
  29. package/dist/client/assets/erDiagram-Q2GNP2WA-_P7rrcgu.js +60 -0
  30. package/dist/client/assets/flowDiagram-NV44I4VS-BvC6gSn5.js +162 -0
  31. package/dist/client/assets/ganttDiagram-JELNMOA3-DjzuVPeB.js +267 -0
  32. package/dist/client/assets/gitGraphDiagram-V2S2FVAM-B9fPDqqA.js +65 -0
  33. package/dist/client/assets/graph-BqLQdgDA.js +1 -0
  34. package/dist/client/assets/index-CAXQd1OO.js +286 -0
  35. package/dist/client/assets/index-CmSvc3Wo.css +1 -0
  36. package/dist/client/assets/infoDiagram-HS3SLOUP-DiMCwlkY.js +2 -0
  37. package/dist/client/assets/init-Gi6I4Gst.js +1 -0
  38. package/dist/client/assets/journeyDiagram-XKPGCS4Q-Dn5WdzPP.js +139 -0
  39. package/dist/client/assets/kanban-definition-3W4ZIXB7-D-BINTOt.js +89 -0
  40. package/dist/client/assets/katex-DhXJpUyf.js +261 -0
  41. package/dist/client/assets/layout-Bo5pDIcD.js +1 -0
  42. package/dist/client/assets/linear-CNmY37sq.js +1 -0
  43. package/dist/client/assets/mermaid.core-DfADLZQ1.js +250 -0
  44. package/dist/client/assets/mindmap-definition-VGOIOE7T-H5HwEwuX.js +68 -0
  45. package/dist/client/assets/ordinal-Cboi1Yqb.js +1 -0
  46. package/dist/client/assets/pieDiagram-ADFJNKIX-RiZa5XQN.js +30 -0
  47. package/dist/client/assets/quadrantDiagram-AYHSOK5B-CFFX55h2.js +7 -0
  48. package/dist/client/assets/requirementDiagram-UZGBJVZJ-B6JBcV1I.js +64 -0
  49. package/dist/client/assets/sankeyDiagram-TZEHDZUN-GZT80dnc.js +10 -0
  50. package/dist/client/assets/sequenceDiagram-WL72ISMW-CbUqoUma.js +145 -0
  51. package/dist/client/assets/stateDiagram-FKZM4ZOC-LEb-ZQVV.js +1 -0
  52. package/dist/client/assets/stateDiagram-v2-4FDKWEC3-BYGHA8iw.js +1 -0
  53. package/dist/client/assets/timeline-definition-IT6M3QCI-Cm1Kd50N.js +61 -0
  54. package/dist/client/assets/treemap-GDKQZRPO-CWXk-dEb.js +160 -0
  55. package/dist/client/assets/xychartDiagram-PRI3JC2R-BUllxp6G.js +7 -0
  56. package/dist/client/index.html +29 -0
  57. package/dist/core/src/apply-suggestion.d.ts +76 -0
  58. package/dist/core/src/apply-suggestion.d.ts.map +1 -0
  59. package/dist/core/src/apply-suggestion.js +109 -0
  60. package/dist/core/src/apply-suggestion.js.map +1 -0
  61. package/dist/core/src/config.d.ts +3 -0
  62. package/dist/core/src/config.d.ts.map +1 -0
  63. package/dist/core/src/config.js +196 -0
  64. package/dist/core/src/config.js.map +1 -0
  65. package/dist/core/src/diff-parser.d.ts +3 -0
  66. package/dist/core/src/diff-parser.d.ts.map +1 -0
  67. package/dist/core/src/diff-parser.js +236 -0
  68. package/dist/core/src/diff-parser.js.map +1 -0
  69. package/dist/core/src/directory-scanner.d.ts +18 -0
  70. package/dist/core/src/directory-scanner.d.ts.map +1 -0
  71. package/dist/core/src/directory-scanner.js +99 -0
  72. package/dist/core/src/directory-scanner.js.map +1 -0
  73. package/dist/core/src/fetch-comments.d.ts +69 -0
  74. package/dist/core/src/fetch-comments.d.ts.map +1 -0
  75. package/dist/core/src/fetch-comments.js +180 -0
  76. package/dist/core/src/fetch-comments.js.map +1 -0
  77. package/dist/core/src/file-type-utils.d.ts +16 -0
  78. package/dist/core/src/file-type-utils.d.ts.map +1 -0
  79. package/dist/core/src/file-type-utils.js +106 -0
  80. package/dist/core/src/file-type-utils.js.map +1 -0
  81. package/dist/core/src/forge-provider.d.ts +123 -0
  82. package/dist/core/src/forge-provider.d.ts.map +1 -0
  83. package/dist/core/src/forge-provider.js +68 -0
  84. package/dist/core/src/forge-provider.js.map +1 -0
  85. package/dist/core/src/fs-utils.d.ts +7 -0
  86. package/dist/core/src/fs-utils.d.ts.map +1 -0
  87. package/dist/core/src/fs-utils.js +20 -0
  88. package/dist/core/src/fs-utils.js.map +1 -0
  89. package/dist/core/src/git-diff-args.d.ts +38 -0
  90. package/dist/core/src/git-diff-args.d.ts.map +1 -0
  91. package/dist/core/src/git-diff-args.js +170 -0
  92. package/dist/core/src/git-diff-args.js.map +1 -0
  93. package/dist/core/src/git-diff-loader.d.ts +14 -0
  94. package/dist/core/src/git-diff-loader.d.ts.map +1 -0
  95. package/dist/core/src/git-diff-loader.js +30 -0
  96. package/dist/core/src/git-diff-loader.js.map +1 -0
  97. package/dist/core/src/git.d.ts +52 -0
  98. package/dist/core/src/git.d.ts.map +1 -0
  99. package/dist/core/src/git.js +191 -0
  100. package/dist/core/src/git.js.map +1 -0
  101. package/dist/core/src/github-provider.d.ts +7 -0
  102. package/dist/core/src/github-provider.d.ts.map +1 -0
  103. package/dist/core/src/github-provider.js +151 -0
  104. package/dist/core/src/github-provider.js.map +1 -0
  105. package/dist/core/src/gitlab-provider.d.ts +10 -0
  106. package/dist/core/src/gitlab-provider.d.ts.map +1 -0
  107. package/dist/core/src/gitlab-provider.js +207 -0
  108. package/dist/core/src/gitlab-provider.js.map +1 -0
  109. package/dist/core/src/guide-loader.d.ts +23 -0
  110. package/dist/core/src/guide-loader.d.ts.map +1 -0
  111. package/dist/core/src/guide-loader.js +95 -0
  112. package/dist/core/src/guide-loader.js.map +1 -0
  113. package/dist/core/src/guide-parser.d.ts +34 -0
  114. package/dist/core/src/guide-parser.d.ts.map +1 -0
  115. package/dist/core/src/guide-parser.js +136 -0
  116. package/dist/core/src/guide-parser.js.map +1 -0
  117. package/dist/core/src/guide-schema.d.ts +2 -0
  118. package/dist/core/src/guide-schema.d.ts.map +1 -0
  119. package/dist/core/src/guide-schema.js +202 -0
  120. package/dist/core/src/guide-schema.js.map +1 -0
  121. package/dist/core/src/ignore-filter.d.ts +8 -0
  122. package/dist/core/src/ignore-filter.d.ts.map +1 -0
  123. package/dist/core/src/ignore-filter.js +16 -0
  124. package/dist/core/src/ignore-filter.js.map +1 -0
  125. package/dist/core/src/index.d.ts +38 -0
  126. package/dist/core/src/index.d.ts.map +1 -0
  127. package/dist/core/src/index.js +54 -0
  128. package/dist/core/src/index.js.map +1 -0
  129. package/dist/core/src/materializer.d.ts +60 -0
  130. package/dist/core/src/materializer.d.ts.map +1 -0
  131. package/dist/core/src/materializer.js +255 -0
  132. package/dist/core/src/materializer.js.map +1 -0
  133. package/dist/core/src/payload-sizing.d.ts +20 -0
  134. package/dist/core/src/payload-sizing.d.ts.map +1 -0
  135. package/dist/core/src/payload-sizing.js +74 -0
  136. package/dist/core/src/payload-sizing.js.map +1 -0
  137. package/dist/core/src/remote-mode.d.ts +89 -0
  138. package/dist/core/src/remote-mode.d.ts.map +1 -0
  139. package/dist/core/src/remote-mode.js +193 -0
  140. package/dist/core/src/remote-mode.js.map +1 -0
  141. package/dist/core/src/review-handlers.d.ts +160 -0
  142. package/dist/core/src/review-handlers.d.ts.map +1 -0
  143. package/dist/core/src/review-handlers.js +463 -0
  144. package/dist/core/src/review-handlers.js.map +1 -0
  145. package/dist/core/src/staged-untracked.d.ts +12 -0
  146. package/dist/core/src/staged-untracked.d.ts.map +1 -0
  147. package/dist/core/src/staged-untracked.js +21 -0
  148. package/dist/core/src/staged-untracked.js.map +1 -0
  149. package/dist/core/src/startup-mode.d.ts +6 -0
  150. package/dist/core/src/startup-mode.d.ts.map +1 -0
  151. package/dist/core/src/startup-mode.js +73 -0
  152. package/dist/core/src/startup-mode.js.map +1 -0
  153. package/dist/core/src/synthetic-diff.d.ts +21 -0
  154. package/dist/core/src/synthetic-diff.d.ts.map +1 -0
  155. package/dist/core/src/synthetic-diff.js +104 -0
  156. package/dist/core/src/synthetic-diff.js.map +1 -0
  157. package/dist/core/src/thread-mapper.d.ts +39 -0
  158. package/dist/core/src/thread-mapper.d.ts.map +1 -0
  159. package/dist/core/src/thread-mapper.js +217 -0
  160. package/dist/core/src/thread-mapper.js.map +1 -0
  161. package/dist/core/src/types.d.ts +2 -0
  162. package/dist/core/src/types.d.ts.map +1 -0
  163. package/dist/core/src/types.js +2 -0
  164. package/dist/core/src/types.js.map +1 -0
  165. package/dist/core/src/xml-parser.d.ts +15 -0
  166. package/dist/core/src/xml-parser.d.ts.map +1 -0
  167. package/dist/core/src/xml-parser.js +237 -0
  168. package/dist/core/src/xml-parser.js.map +1 -0
  169. package/dist/core/src/xml-serializer.d.ts +4 -0
  170. package/dist/core/src/xml-serializer.d.ts.map +1 -0
  171. package/dist/core/src/xml-serializer.js +923 -0
  172. package/dist/core/src/xml-serializer.js.map +1 -0
  173. package/dist/react/src/ReviewPanel.d.ts +72 -0
  174. package/dist/react/src/ReviewPanel.d.ts.map +1 -0
  175. package/dist/react/src/ReviewPanel.js +51 -0
  176. package/dist/react/src/ReviewPanel.js.map +1 -0
  177. package/dist/react/src/SingleFileReview.d.ts +49 -0
  178. package/dist/react/src/SingleFileReview.d.ts.map +1 -0
  179. package/dist/react/src/SingleFileReview.js +41 -0
  180. package/dist/react/src/SingleFileReview.js.map +1 -0
  181. package/dist/react/src/adapter.d.ts +72 -0
  182. package/dist/react/src/adapter.d.ts.map +1 -0
  183. package/dist/react/src/adapter.js +2 -0
  184. package/dist/react/src/adapter.js.map +1 -0
  185. package/dist/react/src/components/Comments/AttachmentDropZone.d.ts +10 -0
  186. package/dist/react/src/components/Comments/AttachmentDropZone.d.ts.map +1 -0
  187. package/dist/react/src/components/Comments/AttachmentDropZone.js +52 -0
  188. package/dist/react/src/components/Comments/AttachmentDropZone.js.map +1 -0
  189. package/dist/react/src/components/Comments/AttachmentImage.d.ts +6 -0
  190. package/dist/react/src/components/Comments/AttachmentImage.d.ts.map +1 -0
  191. package/dist/react/src/components/Comments/AttachmentImage.js +50 -0
  192. package/dist/react/src/components/Comments/AttachmentImage.js.map +1 -0
  193. package/dist/react/src/components/Comments/AttachmentThumbnail.d.ts +6 -0
  194. package/dist/react/src/components/Comments/AttachmentThumbnail.d.ts.map +1 -0
  195. package/dist/react/src/components/Comments/AttachmentThumbnail.js +16 -0
  196. package/dist/react/src/components/Comments/AttachmentThumbnail.js.map +1 -0
  197. package/dist/react/src/components/Comments/CategorySelector.d.ts +6 -0
  198. package/dist/react/src/components/Comments/CategorySelector.d.ts.map +1 -0
  199. package/dist/react/src/components/Comments/CategorySelector.js +27 -0
  200. package/dist/react/src/components/Comments/CategorySelector.js.map +1 -0
  201. package/dist/react/src/components/Comments/CommentDisplay.d.ts +7 -0
  202. package/dist/react/src/components/Comments/CommentDisplay.d.ts.map +1 -0
  203. package/dist/react/src/components/Comments/CommentDisplay.js +103 -0
  204. package/dist/react/src/components/Comments/CommentDisplay.js.map +1 -0
  205. package/dist/react/src/components/Comments/CommentInput.d.ts +11 -0
  206. package/dist/react/src/components/Comments/CommentInput.d.ts.map +1 -0
  207. package/dist/react/src/components/Comments/CommentInput.js +81 -0
  208. package/dist/react/src/components/Comments/CommentInput.js.map +1 -0
  209. package/dist/react/src/components/Comments/ComposerCore.d.ts +49 -0
  210. package/dist/react/src/components/Comments/ComposerCore.d.ts.map +1 -0
  211. package/dist/react/src/components/Comments/ComposerCore.js +91 -0
  212. package/dist/react/src/components/Comments/ComposerCore.js.map +1 -0
  213. package/dist/react/src/components/Comments/EmojiAutocomplete.d.ts +14 -0
  214. package/dist/react/src/components/Comments/EmojiAutocomplete.d.ts.map +1 -0
  215. package/dist/react/src/components/Comments/EmojiAutocomplete.js +19 -0
  216. package/dist/react/src/components/Comments/EmojiAutocomplete.js.map +1 -0
  217. package/dist/react/src/components/Comments/ReplyDisplay.d.ts +22 -0
  218. package/dist/react/src/components/Comments/ReplyDisplay.d.ts.map +1 -0
  219. package/dist/react/src/components/Comments/ReplyDisplay.js +38 -0
  220. package/dist/react/src/components/Comments/ReplyDisplay.js.map +1 -0
  221. package/dist/react/src/components/Comments/ReplyInput.d.ts +9 -0
  222. package/dist/react/src/components/Comments/ReplyInput.d.ts.map +1 -0
  223. package/dist/react/src/components/Comments/ReplyInput.js +47 -0
  224. package/dist/react/src/components/Comments/ReplyInput.js.map +1 -0
  225. package/dist/react/src/components/Comments/SuggestionApplyControl.d.ts +27 -0
  226. package/dist/react/src/components/Comments/SuggestionApplyControl.d.ts.map +1 -0
  227. package/dist/react/src/components/Comments/SuggestionApplyControl.js +103 -0
  228. package/dist/react/src/components/Comments/SuggestionApplyControl.js.map +1 -0
  229. package/dist/react/src/components/Comments/SuggestionBlock.d.ts +26 -0
  230. package/dist/react/src/components/Comments/SuggestionBlock.d.ts.map +1 -0
  231. package/dist/react/src/components/Comments/SuggestionBlock.js +33 -0
  232. package/dist/react/src/components/Comments/SuggestionBlock.js.map +1 -0
  233. package/dist/react/src/components/Comments/SuggestionPanel.d.ts +8 -0
  234. package/dist/react/src/components/Comments/SuggestionPanel.d.ts.map +1 -0
  235. package/dist/react/src/components/Comments/SuggestionPanel.js +12 -0
  236. package/dist/react/src/components/Comments/SuggestionPanel.js.map +1 -0
  237. package/dist/react/src/components/DiffViewer/DiffContentArea.d.ts +35 -0
  238. package/dist/react/src/components/DiffViewer/DiffContentArea.d.ts.map +1 -0
  239. package/dist/react/src/components/DiffViewer/DiffContentArea.js +40 -0
  240. package/dist/react/src/components/DiffViewer/DiffContentArea.js.map +1 -0
  241. package/dist/react/src/components/DiffViewer/DiffViewer.d.ts +4 -0
  242. package/dist/react/src/components/DiffViewer/DiffViewer.d.ts.map +1 -0
  243. package/dist/react/src/components/DiffViewer/DiffViewer.js +110 -0
  244. package/dist/react/src/components/DiffViewer/DiffViewer.js.map +1 -0
  245. package/dist/react/src/components/DiffViewer/EmptyDiffMessage.d.ts +6 -0
  246. package/dist/react/src/components/DiffViewer/EmptyDiffMessage.d.ts.map +1 -0
  247. package/dist/react/src/components/DiffViewer/EmptyDiffMessage.js +18 -0
  248. package/dist/react/src/components/DiffViewer/EmptyDiffMessage.js.map +1 -0
  249. package/dist/react/src/components/DiffViewer/EmptyLinePane.d.ts +2 -0
  250. package/dist/react/src/components/DiffViewer/EmptyLinePane.d.ts.map +1 -0
  251. package/dist/react/src/components/DiffViewer/EmptyLinePane.js +5 -0
  252. package/dist/react/src/components/DiffViewer/EmptyLinePane.js.map +1 -0
  253. package/dist/react/src/components/DiffViewer/ExpandContextBar.d.ts +10 -0
  254. package/dist/react/src/components/DiffViewer/ExpandContextBar.d.ts.map +1 -0
  255. package/dist/react/src/components/DiffViewer/ExpandContextBar.js +16 -0
  256. package/dist/react/src/components/DiffViewer/ExpandContextBar.js.map +1 -0
  257. package/dist/react/src/components/DiffViewer/FileSection.d.ts +9 -0
  258. package/dist/react/src/components/DiffViewer/FileSection.d.ts.map +1 -0
  259. package/dist/react/src/components/DiffViewer/FileSection.js +137 -0
  260. package/dist/react/src/components/DiffViewer/FileSection.js.map +1 -0
  261. package/dist/react/src/components/DiffViewer/FileSectionBody.d.ts +13 -0
  262. package/dist/react/src/components/DiffViewer/FileSectionBody.d.ts.map +1 -0
  263. package/dist/react/src/components/DiffViewer/FileSectionBody.js +8 -0
  264. package/dist/react/src/components/DiffViewer/FileSectionBody.js.map +1 -0
  265. package/dist/react/src/components/DiffViewer/FileSectionHeader.d.ts +16 -0
  266. package/dist/react/src/components/DiffViewer/FileSectionHeader.d.ts.map +1 -0
  267. package/dist/react/src/components/DiffViewer/FileSectionHeader.js +53 -0
  268. package/dist/react/src/components/DiffViewer/FileSectionHeader.js.map +1 -0
  269. package/dist/react/src/components/DiffViewer/FrontMatterTable.d.ts +6 -0
  270. package/dist/react/src/components/DiffViewer/FrontMatterTable.d.ts.map +1 -0
  271. package/dist/react/src/components/DiffViewer/FrontMatterTable.js +30 -0
  272. package/dist/react/src/components/DiffViewer/FrontMatterTable.js.map +1 -0
  273. package/dist/react/src/components/DiffViewer/GuideChapterDivider.d.ts +20 -0
  274. package/dist/react/src/components/DiffViewer/GuideChapterDivider.d.ts.map +1 -0
  275. package/dist/react/src/components/DiffViewer/GuideChapterDivider.js +27 -0
  276. package/dist/react/src/components/DiffViewer/GuideChapterDivider.js.map +1 -0
  277. package/dist/react/src/components/DiffViewer/GuideOverviewContent.d.ts +16 -0
  278. package/dist/react/src/components/DiffViewer/GuideOverviewContent.d.ts.map +1 -0
  279. package/dist/react/src/components/DiffViewer/GuideOverviewContent.js +56 -0
  280. package/dist/react/src/components/DiffViewer/GuideOverviewContent.js.map +1 -0
  281. package/dist/react/src/components/DiffViewer/GuideOverviewDialog.d.ts +12 -0
  282. package/dist/react/src/components/DiffViewer/GuideOverviewDialog.d.ts.map +1 -0
  283. package/dist/react/src/components/DiffViewer/GuideOverviewDialog.js +13 -0
  284. package/dist/react/src/components/DiffViewer/GuideOverviewDialog.js.map +1 -0
  285. package/dist/react/src/components/DiffViewer/GuideOverviewPanel.d.ts +8 -0
  286. package/dist/react/src/components/DiffViewer/GuideOverviewPanel.d.ts.map +1 -0
  287. package/dist/react/src/components/DiffViewer/GuideOverviewPanel.js +16 -0
  288. package/dist/react/src/components/DiffViewer/GuideOverviewPanel.js.map +1 -0
  289. package/dist/react/src/components/DiffViewer/HunkHeader.d.ts +5 -0
  290. package/dist/react/src/components/DiffViewer/HunkHeader.d.ts.map +1 -0
  291. package/dist/react/src/components/DiffViewer/HunkHeader.js +5 -0
  292. package/dist/react/src/components/DiffViewer/HunkHeader.js.map +1 -0
  293. package/dist/react/src/components/DiffViewer/InlineCommentSlot.d.ts +18 -0
  294. package/dist/react/src/components/DiffViewer/InlineCommentSlot.d.ts.map +1 -0
  295. package/dist/react/src/components/DiffViewer/InlineCommentSlot.js +13 -0
  296. package/dist/react/src/components/DiffViewer/InlineCommentSlot.js.map +1 -0
  297. package/dist/react/src/components/DiffViewer/MarkdownCode.d.ts +9 -0
  298. package/dist/react/src/components/DiffViewer/MarkdownCode.d.ts.map +1 -0
  299. package/dist/react/src/components/DiffViewer/MarkdownCode.js +24 -0
  300. package/dist/react/src/components/DiffViewer/MarkdownCode.js.map +1 -0
  301. package/dist/react/src/components/DiffViewer/MermaidBlock.d.ts +4 -0
  302. package/dist/react/src/components/DiffViewer/MermaidBlock.d.ts.map +1 -0
  303. package/dist/react/src/components/DiffViewer/MermaidBlock.js +51 -0
  304. package/dist/react/src/components/DiffViewer/MermaidBlock.js.map +1 -0
  305. package/dist/react/src/components/DiffViewer/RenderedImageView.d.ts +8 -0
  306. package/dist/react/src/components/DiffViewer/RenderedImageView.d.ts.map +1 -0
  307. package/dist/react/src/components/DiffViewer/RenderedImageView.js +46 -0
  308. package/dist/react/src/components/DiffViewer/RenderedImageView.js.map +1 -0
  309. package/dist/react/src/components/DiffViewer/RenderedMarkdownView.d.ts +16 -0
  310. package/dist/react/src/components/DiffViewer/RenderedMarkdownView.d.ts.map +1 -0
  311. package/dist/react/src/components/DiffViewer/RenderedMarkdownView.js +324 -0
  312. package/dist/react/src/components/DiffViewer/RenderedMarkdownView.js.map +1 -0
  313. package/dist/react/src/components/DiffViewer/RenderedSvgView.d.ts +7 -0
  314. package/dist/react/src/components/DiffViewer/RenderedSvgView.d.ts.map +1 -0
  315. package/dist/react/src/components/DiffViewer/RenderedSvgView.js +21 -0
  316. package/dist/react/src/components/DiffViewer/RenderedSvgView.js.map +1 -0
  317. package/dist/react/src/components/DiffViewer/SplitView.d.ts +23 -0
  318. package/dist/react/src/components/DiffViewer/SplitView.d.ts.map +1 -0
  319. package/dist/react/src/components/DiffViewer/SplitView.js +137 -0
  320. package/dist/react/src/components/DiffViewer/SplitView.js.map +1 -0
  321. package/dist/react/src/components/DiffViewer/SyntaxLine.d.ts +49 -0
  322. package/dist/react/src/components/DiffViewer/SyntaxLine.d.ts.map +1 -0
  323. package/dist/react/src/components/DiffViewer/SyntaxLine.js +73 -0
  324. package/dist/react/src/components/DiffViewer/SyntaxLine.js.map +1 -0
  325. package/dist/react/src/components/DiffViewer/UnifiedView.d.ts +23 -0
  326. package/dist/react/src/components/DiffViewer/UnifiedView.d.ts.map +1 -0
  327. package/dist/react/src/components/DiffViewer/UnifiedView.js +96 -0
  328. package/dist/react/src/components/DiffViewer/UnifiedView.js.map +1 -0
  329. package/dist/react/src/components/DiffViewer/diff-utils.d.ts +31 -0
  330. package/dist/react/src/components/DiffViewer/diff-utils.d.ts.map +1 -0
  331. package/dist/react/src/components/DiffViewer/diff-utils.js +134 -0
  332. package/dist/react/src/components/DiffViewer/diff-utils.js.map +1 -0
  333. package/dist/react/src/components/DiffViewer/useDragSelection.d.ts +25 -0
  334. package/dist/react/src/components/DiffViewer/useDragSelection.d.ts.map +1 -0
  335. package/dist/react/src/components/DiffViewer/useDragSelection.js +210 -0
  336. package/dist/react/src/components/DiffViewer/useDragSelection.js.map +1 -0
  337. package/dist/react/src/components/DiffViewer/useExpandContext.d.ts +15 -0
  338. package/dist/react/src/components/DiffViewer/useExpandContext.d.ts.map +1 -0
  339. package/dist/react/src/components/DiffViewer/useExpandContext.js +209 -0
  340. package/dist/react/src/components/DiffViewer/useExpandContext.js.map +1 -0
  341. package/dist/react/src/components/FileTree.d.ts +2 -0
  342. package/dist/react/src/components/FileTree.d.ts.map +1 -0
  343. package/dist/react/src/components/FileTree.js +93 -0
  344. package/dist/react/src/components/FileTree.js.map +1 -0
  345. package/dist/react/src/components/FileTreeEntry.d.ts +13 -0
  346. package/dist/react/src/components/FileTreeEntry.d.ts.map +1 -0
  347. package/dist/react/src/components/FileTreeEntry.js +21 -0
  348. package/dist/react/src/components/FileTreeEntry.js.map +1 -0
  349. package/dist/react/src/components/FileTreeToggle.d.ts +15 -0
  350. package/dist/react/src/components/FileTreeToggle.d.ts.map +1 -0
  351. package/dist/react/src/components/FileTreeToggle.js +16 -0
  352. package/dist/react/src/components/FileTreeToggle.js.map +1 -0
  353. package/dist/react/src/components/GuideRouteHud.d.ts +10 -0
  354. package/dist/react/src/components/GuideRouteHud.d.ts.map +1 -0
  355. package/dist/react/src/components/GuideRouteHud.js +43 -0
  356. package/dist/react/src/components/GuideRouteHud.js.map +1 -0
  357. package/dist/react/src/components/GuideRouteMap.d.ts +20 -0
  358. package/dist/react/src/components/GuideRouteMap.d.ts.map +1 -0
  359. package/dist/react/src/components/GuideRouteMap.js +58 -0
  360. package/dist/react/src/components/GuideRouteMap.js.map +1 -0
  361. package/dist/react/src/components/GuideStation.d.ts +28 -0
  362. package/dist/react/src/components/GuideStation.d.ts.map +1 -0
  363. package/dist/react/src/components/GuideStation.js +24 -0
  364. package/dist/react/src/components/GuideStation.js.map +1 -0
  365. package/dist/react/src/components/HintOverlay.d.ts +13 -0
  366. package/dist/react/src/components/HintOverlay.d.ts.map +1 -0
  367. package/dist/react/src/components/HintOverlay.js +27 -0
  368. package/dist/react/src/components/HintOverlay.js.map +1 -0
  369. package/dist/react/src/components/KeyboardNavigationManager.d.ts +2 -0
  370. package/dist/react/src/components/KeyboardNavigationManager.d.ts.map +1 -0
  371. package/dist/react/src/components/KeyboardNavigationManager.js +8 -0
  372. package/dist/react/src/components/KeyboardNavigationManager.js.map +1 -0
  373. package/dist/react/src/components/Layout.d.ts +2 -0
  374. package/dist/react/src/components/Layout.d.ts.map +1 -0
  375. package/dist/react/src/components/Layout.js +63 -0
  376. package/dist/react/src/components/Layout.js.map +1 -0
  377. package/dist/react/src/components/ReviewProgress.d.ts +2 -0
  378. package/dist/react/src/components/ReviewProgress.d.ts.map +1 -0
  379. package/dist/react/src/components/ReviewProgress.js +25 -0
  380. package/dist/react/src/components/ReviewProgress.js.map +1 -0
  381. package/dist/react/src/components/Toolbar.d.ts +6 -0
  382. package/dist/react/src/components/Toolbar.d.ts.map +1 -0
  383. package/dist/react/src/components/Toolbar.js +61 -0
  384. package/dist/react/src/components/Toolbar.js.map +1 -0
  385. package/dist/react/src/components/TruncatedPath.d.ts +7 -0
  386. package/dist/react/src/components/TruncatedPath.d.ts.map +1 -0
  387. package/dist/react/src/components/TruncatedPath.js +15 -0
  388. package/dist/react/src/components/TruncatedPath.js.map +1 -0
  389. package/dist/react/src/components/ui/badge.d.ts +10 -0
  390. package/dist/react/src/components/ui/badge.d.ts.map +1 -0
  391. package/dist/react/src/components/ui/badge.js +21 -0
  392. package/dist/react/src/components/ui/badge.js.map +1 -0
  393. package/dist/react/src/components/ui/button.d.ts +11 -0
  394. package/dist/react/src/components/ui/button.d.ts.map +1 -0
  395. package/dist/react/src/components/ui/button.js +32 -0
  396. package/dist/react/src/components/ui/button.js.map +1 -0
  397. package/dist/react/src/components/ui/dialog.d.ts +12 -0
  398. package/dist/react/src/components/ui/dialog.d.ts.map +1 -0
  399. package/dist/react/src/components/ui/dialog.js +23 -0
  400. package/dist/react/src/components/ui/dialog.js.map +1 -0
  401. package/dist/react/src/components/ui/input.d.ts +4 -0
  402. package/dist/react/src/components/ui/input.d.ts.map +1 -0
  403. package/dist/react/src/components/ui/input.js +9 -0
  404. package/dist/react/src/components/ui/input.js.map +1 -0
  405. package/dist/react/src/components/ui/separator.d.ts +6 -0
  406. package/dist/react/src/components/ui/separator.d.ts.map +1 -0
  407. package/dist/react/src/components/ui/separator.js +8 -0
  408. package/dist/react/src/components/ui/separator.js.map +1 -0
  409. package/dist/react/src/components/ui/table.d.ts +11 -0
  410. package/dist/react/src/components/ui/table.d.ts.map +1 -0
  411. package/dist/react/src/components/ui/table.js +21 -0
  412. package/dist/react/src/components/ui/table.js.map +1 -0
  413. package/dist/react/src/components/ui/textarea.d.ts +4 -0
  414. package/dist/react/src/components/ui/textarea.d.ts.map +1 -0
  415. package/dist/react/src/components/ui/textarea.js +9 -0
  416. package/dist/react/src/components/ui/textarea.js.map +1 -0
  417. package/dist/react/src/components/ui/toggle-group.d.ts +22 -0
  418. package/dist/react/src/components/ui/toggle-group.d.ts.map +1 -0
  419. package/dist/react/src/components/ui/toggle-group.js +48 -0
  420. package/dist/react/src/components/ui/toggle-group.js.map +1 -0
  421. package/dist/react/src/components/ui/tooltip.d.ts +16 -0
  422. package/dist/react/src/components/ui/tooltip.d.ts.map +1 -0
  423. package/dist/react/src/components/ui/tooltip.js +21 -0
  424. package/dist/react/src/components/ui/tooltip.js.map +1 -0
  425. package/dist/react/src/context/ConfigContext.d.ts +26 -0
  426. package/dist/react/src/context/ConfigContext.d.ts.map +1 -0
  427. package/dist/react/src/context/ConfigContext.js +150 -0
  428. package/dist/react/src/context/ConfigContext.js.map +1 -0
  429. package/dist/react/src/context/DiffNavigationContext.d.ts +16 -0
  430. package/dist/react/src/context/DiffNavigationContext.d.ts.map +1 -0
  431. package/dist/react/src/context/DiffNavigationContext.js +79 -0
  432. package/dist/react/src/context/DiffNavigationContext.js.map +1 -0
  433. package/dist/react/src/context/GuideContext.d.ts +28 -0
  434. package/dist/react/src/context/GuideContext.d.ts.map +1 -0
  435. package/dist/react/src/context/GuideContext.js +64 -0
  436. package/dist/react/src/context/GuideContext.js.map +1 -0
  437. package/dist/react/src/context/ReviewAdapterContext.d.ts +9 -0
  438. package/dist/react/src/context/ReviewAdapterContext.d.ts.map +1 -0
  439. package/dist/react/src/context/ReviewAdapterContext.js +10 -0
  440. package/dist/react/src/context/ReviewAdapterContext.js.map +1 -0
  441. package/dist/react/src/context/ReviewContext.d.ts +60 -0
  442. package/dist/react/src/context/ReviewContext.d.ts.map +1 -0
  443. package/dist/react/src/context/ReviewContext.js +233 -0
  444. package/dist/react/src/context/ReviewContext.js.map +1 -0
  445. package/dist/react/src/hooks/useDiffNavigation.d.ts +4 -0
  446. package/dist/react/src/hooks/useDiffNavigation.d.ts.map +1 -0
  447. package/dist/react/src/hooks/useDiffNavigation.js +5 -0
  448. package/dist/react/src/hooks/useDiffNavigation.js.map +1 -0
  449. package/dist/react/src/hooks/useEmojiAutocomplete.d.ts +24 -0
  450. package/dist/react/src/hooks/useEmojiAutocomplete.d.ts.map +1 -0
  451. package/dist/react/src/hooks/useEmojiAutocomplete.js +175 -0
  452. package/dist/react/src/hooks/useEmojiAutocomplete.js.map +1 -0
  453. package/dist/react/src/hooks/useKeyboardNavigation.d.ts +15 -0
  454. package/dist/react/src/hooks/useKeyboardNavigation.d.ts.map +1 -0
  455. package/dist/react/src/hooks/useKeyboardNavigation.js +227 -0
  456. package/dist/react/src/hooks/useKeyboardNavigation.js.map +1 -0
  457. package/dist/react/src/hooks/useReviewBridge.d.ts +15 -0
  458. package/dist/react/src/hooks/useReviewBridge.d.ts.map +1 -0
  459. package/dist/react/src/hooks/useReviewBridge.js +43 -0
  460. package/dist/react/src/hooks/useReviewBridge.js.map +1 -0
  461. package/dist/react/src/hooks/useReviewState.d.ts +16 -0
  462. package/dist/react/src/hooks/useReviewState.d.ts.map +1 -0
  463. package/dist/react/src/hooks/useReviewState.js +101 -0
  464. package/dist/react/src/hooks/useReviewState.js.map +1 -0
  465. package/dist/react/src/index.d.ts +25 -0
  466. package/dist/react/src/index.d.ts.map +1 -0
  467. package/dist/react/src/index.js +22 -0
  468. package/dist/react/src/index.js.map +1 -0
  469. package/dist/react/src/lib/utils.d.ts +3 -0
  470. package/dist/react/src/lib/utils.d.ts.map +1 -0
  471. package/dist/react/src/lib/utils.js +6 -0
  472. package/dist/react/src/lib/utils.js.map +1 -0
  473. package/dist/react/src/utils/category-utils.d.ts +17 -0
  474. package/dist/react/src/utils/category-utils.d.ts.map +1 -0
  475. package/dist/react/src/utils/category-utils.js +23 -0
  476. package/dist/react/src/utils/category-utils.js.map +1 -0
  477. package/dist/react/src/utils/comment-anchors.d.ts +4 -0
  478. package/dist/react/src/utils/comment-anchors.d.ts.map +1 -0
  479. package/dist/react/src/utils/comment-anchors.js +17 -0
  480. package/dist/react/src/utils/comment-anchors.js.map +1 -0
  481. package/dist/react/src/utils/diff-styles.d.ts +12 -0
  482. package/dist/react/src/utils/diff-styles.d.ts.map +1 -0
  483. package/dist/react/src/utils/diff-styles.js +46 -0
  484. package/dist/react/src/utils/diff-styles.js.map +1 -0
  485. package/dist/react/src/utils/emoji-data.d.ts +8 -0
  486. package/dist/react/src/utils/emoji-data.d.ts.map +1 -0
  487. package/dist/react/src/utils/emoji-data.js +43 -0
  488. package/dist/react/src/utils/emoji-data.js.map +1 -0
  489. package/dist/react/src/utils/file-type-utils.d.ts +20 -0
  490. package/dist/react/src/utils/file-type-utils.d.ts.map +1 -0
  491. package/dist/react/src/utils/file-type-utils.js +110 -0
  492. package/dist/react/src/utils/file-type-utils.js.map +1 -0
  493. package/dist/react/src/utils/front-matter.d.ts +14 -0
  494. package/dist/react/src/utils/front-matter.d.ts.map +1 -0
  495. package/dist/react/src/utils/front-matter.js +40 -0
  496. package/dist/react/src/utils/front-matter.js.map +1 -0
  497. package/dist/react/src/utils/guide-accents.d.ts +46 -0
  498. package/dist/react/src/utils/guide-accents.d.ts.map +1 -0
  499. package/dist/react/src/utils/guide-accents.js +100 -0
  500. package/dist/react/src/utils/guide-accents.js.map +1 -0
  501. package/dist/react/src/utils/guide-display.d.ts +48 -0
  502. package/dist/react/src/utils/guide-display.d.ts.map +1 -0
  503. package/dist/react/src/utils/guide-display.js +75 -0
  504. package/dist/react/src/utils/guide-display.js.map +1 -0
  505. package/dist/react/src/utils/image-utils.d.ts +3 -0
  506. package/dist/react/src/utils/image-utils.d.ts.map +1 -0
  507. package/dist/react/src/utils/image-utils.js +33 -0
  508. package/dist/react/src/utils/image-utils.js.map +1 -0
  509. package/dist/react/src/utils/passive-content.d.ts +9 -0
  510. package/dist/react/src/utils/passive-content.d.ts.map +1 -0
  511. package/dist/react/src/utils/passive-content.js +135 -0
  512. package/dist/react/src/utils/passive-content.js.map +1 -0
  513. package/dist/react/src/utils/remark-emoji.d.ts +3 -0
  514. package/dist/react/src/utils/remark-emoji.d.ts.map +1 -0
  515. package/dist/react/src/utils/remark-emoji.js +38 -0
  516. package/dist/react/src/utils/remark-emoji.js.map +1 -0
  517. package/dist/serve/src/args.d.ts +15 -0
  518. package/dist/serve/src/args.d.ts.map +1 -0
  519. package/dist/serve/src/args.js +65 -0
  520. package/dist/serve/src/args.js.map +1 -0
  521. package/dist/serve/src/cli.d.ts +3 -0
  522. package/dist/serve/src/cli.d.ts.map +1 -0
  523. package/dist/serve/src/cli.js +81 -0
  524. package/dist/serve/src/cli.js.map +1 -0
  525. package/dist/serve/src/client/adapter.d.ts +25 -0
  526. package/dist/serve/src/client/adapter.d.ts.map +1 -0
  527. package/dist/serve/src/client/adapter.js +190 -0
  528. package/dist/serve/src/client/adapter.js.map +1 -0
  529. package/dist/serve/src/client/index.d.ts +2 -0
  530. package/dist/serve/src/client/index.d.ts.map +1 -0
  531. package/dist/serve/src/client/index.js +135 -0
  532. package/dist/serve/src/client/index.js.map +1 -0
  533. package/dist/serve/src/lifecycle.d.ts +27 -0
  534. package/dist/serve/src/lifecycle.d.ts.map +1 -0
  535. package/dist/serve/src/lifecycle.js +73 -0
  536. package/dist/serve/src/lifecycle.js.map +1 -0
  537. package/dist/serve/src/server.d.ts +34 -0
  538. package/dist/serve/src/server.d.ts.map +1 -0
  539. package/dist/serve/src/server.js +430 -0
  540. package/dist/serve/src/server.js.map +1 -0
  541. package/dist/serve/src/startup.d.ts +19 -0
  542. package/dist/serve/src/startup.d.ts.map +1 -0
  543. package/dist/serve/src/startup.js +117 -0
  544. package/dist/serve/src/startup.js.map +1 -0
  545. package/dist/serve/src/validate.d.ts +44 -0
  546. package/dist/serve/src/validate.d.ts.map +1 -0
  547. package/dist/serve/src/validate.js +295 -0
  548. package/dist/serve/src/validate.js.map +1 -0
  549. package/dist/types/src/index.d.ts +417 -0
  550. package/dist/types/src/index.d.ts.map +1 -0
  551. package/dist/types/src/index.js +5 -0
  552. package/dist/types/src/index.js.map +1 -0
  553. package/package.json +38 -0
@@ -0,0 +1,923 @@
1
+ // src/main/xml-serializer.ts
2
+ // Serialize ReviewState to XML and validate against XSD
3
+ import * as path from 'path';
4
+ import * as fs from 'fs';
5
+ import { validateXML } from 'xmllint-wasm';
6
+ // Embed the XSD schema for validation.
7
+ // This MUST stay byte-identical to the on-disk canonical copy
8
+ // (.agents/skills/self-review-apply/assets/self-review-v3.xsd);
9
+ // the sync test in xsd-schema.test.ts enforces it.
10
+ export const XSD_SCHEMA = `<?xml version="1.0" encoding="UTF-8"?>
11
+ <xs:schema
12
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
13
+ xmlns:sr="urn:self-review:v3"
14
+ targetNamespace="urn:self-review:v3"
15
+ elementFormDefault="qualified"
16
+ >
17
+
18
+ <!--
19
+ self-review XML Schema v3
20
+ =========================
21
+ Defines the output format for the self-review application.
22
+ This schema is designed to be both machine-validated and
23
+ fed to an LLM so it can understand the structure of review feedback.
24
+
25
+ Key concepts:
26
+ - A <review> contains one <file> per file in the diff.
27
+ - A <file> contains zero or more <comment> elements.
28
+ - A <comment> with no line attributes is a file-level comment.
29
+ - A <comment> with old-line-start/old-line-end refers to lines
30
+ in the pre-change version of the file (typically deleted lines).
31
+ - A <comment> with new-line-start/new-line-end refers to lines
32
+ in the post-change version of the file (added or context lines).
33
+ - Exactly one pair (old-line-* or new-line-*) should be present
34
+ for line-level comments. This constraint cannot be expressed in
35
+ XSD 1.0 and is enforced by the application.
36
+ - A <comment> may carry an ordered list of <reply> children, which
37
+ are turns in a conversation about that comment.
38
+
39
+ Changes from v1:
40
+ - <comment> gained two optional attributes, severity and confidence,
41
+ so an automated consumer can threshold on findings instead of
42
+ applying all of them or none of them. See CommentType.
43
+
44
+ Changes from v2:
45
+ - <comment> gained an optional, unbounded <reply> child, so a finding
46
+ and the responses to it form a single legible thread instead of a
47
+ set of disconnected assertions. See ReplyType.
48
+
49
+ Amended in place (still v3):
50
+ - The review root gained optional remote-url, remote-base-sha,
51
+ remote-head-sha and remote-forge attributes, and <comment> and
52
+ <reply> gained an optional remote-id attribute, so a review taken
53
+ against a remote pull/merge request records its provenance. Purely
54
+ additive: a document carrying none of them is unchanged. See
55
+ ReviewType.
56
+ -->
57
+
58
+ <!-- ===== Root element ===== -->
59
+
60
+ <xs:element name="review" type="sr:ReviewType">
61
+ <xs:annotation>
62
+ <xs:documentation>
63
+ Root element of a self-review output file. Contains one file element
64
+ per file in the git diff, including files with no comments.
65
+ </xs:documentation>
66
+ </xs:annotation>
67
+ </xs:element>
68
+
69
+ <!-- ===== Complex types ===== -->
70
+
71
+ <xs:complexType name="ReviewType">
72
+ <xs:sequence>
73
+ <xs:element name="file" type="sr:FileType" minOccurs="0" maxOccurs="unbounded" />
74
+ </xs:sequence>
75
+ <xs:attribute name="timestamp" type="xs:dateTime" use="required">
76
+ <xs:annotation>
77
+ <xs:documentation>
78
+ ISO 8601 timestamp of when the review was completed (window closed).
79
+ </xs:documentation>
80
+ </xs:annotation>
81
+ </xs:attribute>
82
+ <xs:attribute name="git-diff-args" type="xs:string" use="optional">
83
+ <xs:annotation>
84
+ <xs:documentation>
85
+ The git diff arguments that were passed to self-review on the CLI.
86
+ Example: "--staged", "main..feature-branch", "HEAD~3".
87
+ Present only when reviewing a git diff.
88
+ </xs:documentation>
89
+ </xs:annotation>
90
+ </xs:attribute>
91
+ <xs:attribute name="repository" type="xs:string" use="optional">
92
+ <xs:annotation>
93
+ <xs:documentation>
94
+ Absolute path to the repository root where self-review was invoked.
95
+ Present only when reviewing a git diff.
96
+ </xs:documentation>
97
+ </xs:annotation>
98
+ </xs:attribute>
99
+ <xs:attribute name="source-path" type="xs:string" use="optional">
100
+ <xs:annotation>
101
+ <xs:documentation>
102
+ Absolute path to the directory being reviewed.
103
+ Present only when reviewing a directory (non-git mode).
104
+ </xs:documentation>
105
+ </xs:annotation>
106
+ </xs:attribute>
107
+ <xs:attribute name="remote-url" type="xs:string" use="optional">
108
+ <xs:annotation>
109
+ <xs:documentation>
110
+ URL of the remote pull/merge request this review was taken
111
+ against. Example: "https://github.com/owner/repo/pull/42".
112
+ Present only when reviewing a remote PR/MR.
113
+
114
+ The remote-* attributes form a third source shape alongside
115
+ git-diff-args/repository (local git diff) and source-path
116
+ (directory review). The three shapes are mutually exclusive;
117
+ XSD 1.0 cannot express that constraint, so it is enforced by
118
+ the application.
119
+ </xs:documentation>
120
+ </xs:annotation>
121
+ </xs:attribute>
122
+ <xs:attribute name="remote-base-sha" type="xs:string" use="optional">
123
+ <xs:annotation>
124
+ <xs:documentation>
125
+ Commit SHA the remote diff was computed from (the base of the
126
+ PR/MR at fetch time). Together with remote-head-sha it pins the
127
+ review to the exact diff it was written against, so a consumer
128
+ can detect drift when the remote branch moves.
129
+ Present only when reviewing a remote PR/MR.
130
+ </xs:documentation>
131
+ </xs:annotation>
132
+ </xs:attribute>
133
+ <xs:attribute name="remote-head-sha" type="xs:string" use="optional">
134
+ <xs:annotation>
135
+ <xs:documentation>
136
+ Commit SHA of the head of the remote PR/MR branch at fetch time.
137
+ See remote-base-sha for how the pair supports drift detection.
138
+ Present only when reviewing a remote PR/MR.
139
+ </xs:documentation>
140
+ </xs:annotation>
141
+ </xs:attribute>
142
+ <xs:attribute name="remote-forge" type="sr:RemoteForgeEnum" use="optional">
143
+ <xs:annotation>
144
+ <xs:documentation>
145
+ Which forge hosts the remote PR/MR. Names the id space of the
146
+ remote-id attributes on comments and replies, and selects the
147
+ API machinery a future posting feature would use.
148
+ Present only when reviewing a remote PR/MR.
149
+ </xs:documentation>
150
+ </xs:annotation>
151
+ </xs:attribute>
152
+ </xs:complexType>
153
+
154
+ <xs:complexType name="FileType">
155
+ <xs:annotation>
156
+ <xs:documentation>
157
+ Represents a single file in the diff. Files with no comments
158
+ appear as empty elements. The path is relative to the repository root.
159
+ </xs:documentation>
160
+ </xs:annotation>
161
+ <xs:sequence>
162
+ <xs:element name="comment" type="sr:CommentType" minOccurs="0" maxOccurs="unbounded" />
163
+ </xs:sequence>
164
+ <xs:attribute name="path" type="xs:string" use="required">
165
+ <xs:annotation>
166
+ <xs:documentation>
167
+ File path relative to the repository root. For renamed files,
168
+ this is the new path.
169
+ </xs:documentation>
170
+ </xs:annotation>
171
+ </xs:attribute>
172
+ <xs:attribute name="change-type" type="sr:ChangeTypeEnum" use="required">
173
+ <xs:annotation>
174
+ <xs:documentation>
175
+ The type of change: added, modified, deleted, or renamed.
176
+ </xs:documentation>
177
+ </xs:annotation>
178
+ </xs:attribute>
179
+ <xs:attribute name="viewed" type="xs:boolean" use="required">
180
+ <xs:annotation>
181
+ <xs:documentation>
182
+ Whether the reviewer marked this file as reviewed.
183
+ true = the reviewer looked at this file.
184
+ false = the reviewer did not mark this file as viewed.
185
+ This helps an AI agent distinguish "reviewed with no comments"
186
+ from "not yet reviewed."
187
+ </xs:documentation>
188
+ </xs:annotation>
189
+ </xs:attribute>
190
+ </xs:complexType>
191
+
192
+ <xs:complexType name="CommentType">
193
+ <xs:annotation>
194
+ <xs:documentation>
195
+ A review comment. Three forms:
196
+
197
+ 1. File-level comment: no line attributes present.
198
+ Applies to the file as a whole.
199
+
200
+ 2. Comment on new/added/context lines: new-line-start and
201
+ new-line-end are present. These reference line numbers in the
202
+ post-change version of the file.
203
+
204
+ 3. Comment on old/deleted lines: old-line-start and old-line-end
205
+ are present. These reference line numbers in the pre-change
206
+ version of the file.
207
+
208
+ For single-line comments, start and end are equal.
209
+ Exactly one pair (old or new) should be present for line-level
210
+ comments. Both pairs absent = file-level comment.
211
+
212
+ The category child says what kind of finding this is. The severity
213
+ and confidence attributes say how much weight to put on it: severity
214
+ is how consequential the finding is if it is real, confidence is how
215
+ sure the author is that it is real. They are independent, and an
216
+ automated consumer is expected to threshold on both.
217
+ </xs:documentation>
218
+ </xs:annotation>
219
+ <xs:sequence>
220
+ <xs:element name="body" type="xs:string">
221
+ <xs:annotation>
222
+ <xs:documentation>
223
+ The comment text. May contain markdown formatting.
224
+ </xs:documentation>
225
+ </xs:annotation>
226
+ </xs:element>
227
+ <xs:element name="category" type="xs:string">
228
+ <xs:annotation>
229
+ <xs:documentation>
230
+ Required category tag for this comment (e.g., "bug", "style",
231
+ "nit", "question", "security"). Categories are defined in the
232
+ project-level .self-review.yaml configuration. Every comment
233
+ must have a category to help AI agents prioritize and triage
234
+ feedback.
235
+ </xs:documentation>
236
+ </xs:annotation>
237
+ </xs:element>
238
+ <xs:element name="suggestion" type="sr:SuggestionType" minOccurs="0">
239
+ <xs:annotation>
240
+ <xs:documentation>
241
+ Optional code replacement proposal. When present, the AI agent
242
+ should replace the original-code with the proposed-code at the
243
+ referenced line range.
244
+ </xs:documentation>
245
+ </xs:annotation>
246
+ </xs:element>
247
+ <xs:element name="attachment" type="sr:AttachmentType" minOccurs="0" maxOccurs="unbounded">
248
+ <xs:annotation>
249
+ <xs:documentation>
250
+ Optional image attachment. The path attribute references an image file
251
+ stored in the .self-review-assets/ directory alongside the XML output.
252
+ </xs:documentation>
253
+ </xs:annotation>
254
+ </xs:element>
255
+ <xs:element name="reply" type="sr:ReplyType" minOccurs="0" maxOccurs="unbounded">
256
+ <xs:annotation>
257
+ <xs:documentation>
258
+ Optional ordered list of replies to this comment. The comment
259
+ itself is the root of the thread; each reply is a later turn in
260
+ the conversation about it.
261
+ </xs:documentation>
262
+ </xs:annotation>
263
+ </xs:element>
264
+ </xs:sequence>
265
+ <xs:attribute name="old-line-start" type="xs:positiveInteger" use="optional">
266
+ <xs:annotation>
267
+ <xs:documentation>
268
+ Start line number in the pre-change (old) version of the file.
269
+ Use for comments on deleted lines.
270
+ </xs:documentation>
271
+ </xs:annotation>
272
+ </xs:attribute>
273
+ <xs:attribute name="old-line-end" type="xs:positiveInteger" use="optional">
274
+ <xs:annotation>
275
+ <xs:documentation>
276
+ End line number (inclusive) in the pre-change (old) version.
277
+ Must be >= old-line-start when both are present.
278
+ </xs:documentation>
279
+ </xs:annotation>
280
+ </xs:attribute>
281
+ <xs:attribute name="new-line-start" type="xs:positiveInteger" use="optional">
282
+ <xs:annotation>
283
+ <xs:documentation>
284
+ Start line number in the post-change (new) version of the file.
285
+ Use for comments on added or context (unchanged) lines.
286
+ </xs:documentation>
287
+ </xs:annotation>
288
+ </xs:attribute>
289
+ <xs:attribute name="new-line-end" type="xs:positiveInteger" use="optional">
290
+ <xs:annotation>
291
+ <xs:documentation>
292
+ End line number (inclusive) in the post-change (new) version.
293
+ Must be >= new-line-start when both are present.
294
+ </xs:documentation>
295
+ </xs:annotation>
296
+ </xs:attribute>
297
+ <xs:attribute name="author" type="xs:string" use="optional">
298
+ <xs:annotation>
299
+ <xs:documentation>
300
+ The author of this comment. When present, indicates the comment
301
+ was generated by a bot or LLM (e.g., "Claude Sonnet 4.6").
302
+ When absent, the comment is assumed to be authored by the human
303
+ reviewer.
304
+ </xs:documentation>
305
+ </xs:annotation>
306
+ </xs:attribute>
307
+ <xs:attribute name="severity" type="sr:SeverityEnum" use="optional">
308
+ <xs:annotation>
309
+ <xs:documentation>
310
+ How consequential this finding is if it turns out to be real.
311
+ Judge the impact of the problem, not how confident you are that
312
+ the problem exists, and not how much work the fix is.
313
+
314
+ This attribute has no schema default on purpose. When it is
315
+ absent, a consumer must treat the comment as falling below any
316
+ severity floor it applies, i.e. absent never satisfies a
317
+ threshold. Comments written by a human in the self-review UI
318
+ normally carry no severity.
319
+ </xs:documentation>
320
+ </xs:annotation>
321
+ </xs:attribute>
322
+ <xs:attribute name="confidence" type="sr:ConfidenceEnum" use="optional">
323
+ <xs:annotation>
324
+ <xs:documentation>
325
+ How sure the author is that this finding is real, i.e. that it
326
+ describes an actual defect in the code as written rather than a
327
+ hypothetical one.
328
+
329
+ Confidence is about the evidence, not about how strongly the
330
+ comment is worded. A finding whose argument depends on a
331
+ constraint that is not visible in the diff, on a caller that was
332
+ not read, or on a failure scenario that was imagined rather than
333
+ traced, is low confidence however plausible its prose sounds.
334
+ LLM reviewers systematically overstate certainty here; a
335
+ consumer thresholding on this attribute is relying on it being
336
+ lowered honestly.
337
+
338
+ This attribute has no schema default on purpose. When it is
339
+ absent, a consumer must treat the comment as falling below any
340
+ confidence floor it applies, i.e. absent never satisfies a
341
+ threshold.
342
+ </xs:documentation>
343
+ </xs:annotation>
344
+ </xs:attribute>
345
+ <xs:attribute name="remote-id" type="xs:string" use="optional">
346
+ <xs:annotation>
347
+ <xs:documentation>
348
+ Identifier of the remote discussion thread or comment this
349
+ comment was fetched from, in the id space of the forge named by
350
+ remote-forge on the review root. Provenance and forward
351
+ machinery: it lets a consumer trace the finding back to its
352
+ origin, and a future posting feature reply to the existing
353
+ thread instead of opening a new one. Absent on comments
354
+ authored locally.
355
+ </xs:documentation>
356
+ </xs:annotation>
357
+ </xs:attribute>
358
+ </xs:complexType>
359
+
360
+ <xs:complexType name="ReplyType">
361
+ <xs:annotation>
362
+ <xs:documentation>
363
+ A reply to a review comment. Replies turn a finding into a
364
+ conversation: the comment asserts something, a reply answers it, a
365
+ later reply answers that.
366
+
367
+ Four rules govern replies. Only the first is beyond what XSD 1.0
368
+ can express, and it is enforced by the application and by the
369
+ skills that author these documents. Rules 2 to 4 are enforced by
370
+ the content model below; they are spelled out anyway, because the
371
+ reason for a constraint is what an author needs in order to write
372
+ a good reply, and a validator only ever reports the constraint:
373
+
374
+ 1. Replies are ordered. Document order is conversation order, and
375
+ it is the only ordering signal. There are no timestamps and no
376
+ identifiers: the earlier reply is the earlier turn.
377
+
378
+ 2. Replies are flat. A reply is never nested inside another reply.
379
+ A reply that addresses an earlier reply says so in its body.
380
+
381
+ 3. A reply carries no thresholding metadata. There is no category,
382
+ no severity and no confidence on a reply. Those are properties
383
+ of the finding, and the finding is the root comment, whose
384
+ severity and confidence govern the whole thread.
385
+
386
+ 4. A reply carries no suggestion. A concrete counter-proposal goes
387
+ in the reply body as a fenced code block. Allowing a suggestion
388
+ on both the root and a reply would force every consumer to
389
+ invent its own precedence rule.
390
+
391
+ When a machine consumes a thread, the last human turn is the
392
+ tie-breaker over any earlier machine assertion.
393
+ </xs:documentation>
394
+ </xs:annotation>
395
+ <xs:sequence>
396
+ <xs:element name="body" type="xs:string">
397
+ <xs:annotation>
398
+ <xs:documentation>
399
+ The reply text. May contain markdown formatting, including
400
+ fenced code blocks, which is where a counter-proposal goes
401
+ since replies carry no suggestion element.
402
+ </xs:documentation>
403
+ </xs:annotation>
404
+ </xs:element>
405
+ <xs:element name="attachment" type="sr:AttachmentType" minOccurs="0" maxOccurs="unbounded">
406
+ <xs:annotation>
407
+ <xs:documentation>
408
+ Optional image attachment, identical in form and semantics to
409
+ a comment attachment. The path attribute references an image
410
+ file stored in the .self-review-assets/ directory alongside
411
+ the XML output.
412
+ </xs:documentation>
413
+ </xs:annotation>
414
+ </xs:element>
415
+ </xs:sequence>
416
+ <xs:attribute name="author" type="xs:string" use="optional">
417
+ <xs:annotation>
418
+ <xs:documentation>
419
+ The author of this reply, with the same semantics as
420
+ CommentType/@author. When present, the reply was generated by a
421
+ bot or LLM (e.g., "Claude Opus 5"). When absent, the reply is
422
+ the human reviewer's.
423
+ </xs:documentation>
424
+ </xs:annotation>
425
+ </xs:attribute>
426
+ <xs:attribute name="remote-id" type="xs:string" use="optional">
427
+ <xs:annotation>
428
+ <xs:documentation>
429
+ Identifier of the remote comment this reply was fetched from,
430
+ with the same semantics as CommentType/@remote-id: an id in the
431
+ forge's own id space, kept for provenance and for a future
432
+ posting feature. Absent on replies authored locally.
433
+
434
+ A remote-id is not an ordering signal. Document order remains
435
+ conversation order, exactly as rule 1 above states.
436
+ </xs:documentation>
437
+ </xs:annotation>
438
+ </xs:attribute>
439
+ </xs:complexType>
440
+
441
+ <xs:complexType name="SuggestionType">
442
+ <xs:annotation>
443
+ <xs:documentation>
444
+ A code replacement proposal. The original-code is the literal text
445
+ currently at the referenced lines. The proposed-code is what the
446
+ reviewer suggests it should be replaced with. The AI agent can apply
447
+ this by performing a text substitution.
448
+ </xs:documentation>
449
+ </xs:annotation>
450
+ <xs:sequence>
451
+ <xs:element name="original-code" type="xs:string">
452
+ <xs:annotation>
453
+ <xs:documentation>
454
+ The existing code at the referenced line range, copied verbatim
455
+ from the diff. Used by the AI agent to locate the replacement
456
+ target via text matching.
457
+ </xs:documentation>
458
+ </xs:annotation>
459
+ </xs:element>
460
+ <xs:element name="proposed-code" type="xs:string">
461
+ <xs:annotation>
462
+ <xs:documentation>
463
+ The replacement code proposed by the reviewer. The AI agent
464
+ should substitute original-code with this text.
465
+ </xs:documentation>
466
+ </xs:annotation>
467
+ </xs:element>
468
+ </xs:sequence>
469
+ </xs:complexType>
470
+
471
+ <xs:complexType name="AttachmentType">
472
+ <xs:annotation>
473
+ <xs:documentation>
474
+ Reference to an image file attached to a review comment. The file is stored
475
+ alongside the XML output in the .self-review-assets/ directory.
476
+ </xs:documentation>
477
+ </xs:annotation>
478
+ <xs:attribute name="path" type="xs:string" use="required">
479
+ <xs:annotation>
480
+ <xs:documentation>Relative path from the XML file to the image file.</xs:documentation>
481
+ </xs:annotation>
482
+ </xs:attribute>
483
+ <xs:attribute name="media-type" type="xs:string" use="required">
484
+ <xs:annotation>
485
+ <xs:documentation>MIME type of the image (e.g., image/png, image/jpeg).</xs:documentation>
486
+ </xs:annotation>
487
+ </xs:attribute>
488
+ </xs:complexType>
489
+
490
+ <!-- ===== Simple types ===== -->
491
+
492
+ <xs:simpleType name="ChangeTypeEnum">
493
+ <xs:annotation>
494
+ <xs:documentation>
495
+ The type of change a file underwent in the diff.
496
+ </xs:documentation>
497
+ </xs:annotation>
498
+ <xs:restriction base="xs:string">
499
+ <xs:enumeration value="added">
500
+ <xs:annotation>
501
+ <xs:documentation>New file that did not exist before.</xs:documentation>
502
+ </xs:annotation>
503
+ </xs:enumeration>
504
+ <xs:enumeration value="modified">
505
+ <xs:annotation>
506
+ <xs:documentation>Existing file with content changes.</xs:documentation>
507
+ </xs:annotation>
508
+ </xs:enumeration>
509
+ <xs:enumeration value="deleted">
510
+ <xs:annotation>
511
+ <xs:documentation>File was removed.</xs:documentation>
512
+ </xs:annotation>
513
+ </xs:enumeration>
514
+ <xs:enumeration value="renamed">
515
+ <xs:annotation>
516
+ <xs:documentation>File was moved or renamed, with or without content changes.</xs:documentation>
517
+ </xs:annotation>
518
+ </xs:enumeration>
519
+ </xs:restriction>
520
+ </xs:simpleType>
521
+
522
+ <xs:simpleType name="SeverityEnum">
523
+ <xs:annotation>
524
+ <xs:documentation>
525
+ How consequential a finding is if it is real. Ordered from most to
526
+ least consequential: critical, major, minor, info.
527
+ </xs:documentation>
528
+ </xs:annotation>
529
+ <xs:restriction base="xs:string">
530
+ <xs:enumeration value="critical">
531
+ <xs:annotation>
532
+ <xs:documentation>
533
+ Causes data loss, a security hole, or a crash or corruption on a
534
+ path that real usage reaches. Shipping this is not acceptable.
535
+ </xs:documentation>
536
+ </xs:annotation>
537
+ </xs:enumeration>
538
+ <xs:enumeration value="major">
539
+ <xs:annotation>
540
+ <xs:documentation>
541
+ Produces wrong behaviour, or breaks a documented contract, on a
542
+ path that real usage reaches. The code does not do what it is
543
+ supposed to do, but nothing is destroyed and there is no security
544
+ impact.
545
+ </xs:documentation>
546
+ </xs:annotation>
547
+ </xs:enumeration>
548
+ <xs:enumeration value="minor">
549
+ <xs:annotation>
550
+ <xs:documentation>
551
+ Real but bounded: a mishandled edge case that is unlikely to be
552
+ hit, a missing test, a leak of something cheap, or a maintenance
553
+ hazard that will cost time later. Behaviour is correct today.
554
+ </xs:documentation>
555
+ </xs:annotation>
556
+ </xs:enumeration>
557
+ <xs:enumeration value="info">
558
+ <xs:annotation>
559
+ <xs:documentation>
560
+ No defect. Style, naming, phrasing, a question for the author, or
561
+ a note recorded for context. Nothing is wrong if this is never
562
+ acted on.
563
+ </xs:documentation>
564
+ </xs:annotation>
565
+ </xs:enumeration>
566
+ </xs:restriction>
567
+ </xs:simpleType>
568
+
569
+ <xs:simpleType name="ConfidenceEnum">
570
+ <xs:annotation>
571
+ <xs:documentation>
572
+ How sure the author is that a finding is real. Ordered from most to
573
+ least sure: high, medium, low.
574
+ </xs:documentation>
575
+ </xs:annotation>
576
+ <xs:restriction base="xs:string">
577
+ <xs:enumeration value="high">
578
+ <xs:annotation>
579
+ <xs:documentation>
580
+ The evidence is in the code that was read. The failure can be
581
+ traced from the diff itself, and no assumption about unseen code,
582
+ unseen callers, or unstated requirements is needed to reach it.
583
+ </xs:documentation>
584
+ </xs:annotation>
585
+ </xs:enumeration>
586
+ <xs:enumeration value="medium">
587
+ <xs:annotation>
588
+ <xs:documentation>
589
+ Likely real, but it rests on one assumption that was not verified,
590
+ such as how a caller behaves, what a dependency guarantees, or
591
+ what the intended requirement was. Stating that assumption in the
592
+ body is expected at this level.
593
+ </xs:documentation>
594
+ </xs:annotation>
595
+ </xs:enumeration>
596
+ <xs:enumeration value="low">
597
+ <xs:annotation>
598
+ <xs:documentation>
599
+ Speculative. The failure scenario was imagined rather than traced,
600
+ or the finding depends on a constraint the author invented, or the
601
+ author could not tell intent from the code. Worth a human's eyes,
602
+ not worth acting on unattended.
603
+ </xs:documentation>
604
+ </xs:annotation>
605
+ </xs:enumeration>
606
+ </xs:restriction>
607
+ </xs:simpleType>
608
+
609
+ <xs:simpleType name="RemoteForgeEnum">
610
+ <xs:annotation>
611
+ <xs:documentation>
612
+ The forge hosting a remote pull/merge request.
613
+ </xs:documentation>
614
+ </xs:annotation>
615
+ <xs:restriction base="xs:string">
616
+ <xs:enumeration value="github">
617
+ <xs:annotation>
618
+ <xs:documentation>A GitHub pull request.</xs:documentation>
619
+ </xs:annotation>
620
+ </xs:enumeration>
621
+ <xs:enumeration value="gitlab">
622
+ <xs:annotation>
623
+ <xs:documentation>A GitLab merge request.</xs:documentation>
624
+ </xs:annotation>
625
+ </xs:enumeration>
626
+ </xs:restriction>
627
+ </xs:simpleType>
628
+
629
+ </xs:schema>`;
630
+ function extFromMediaType(mediaType) {
631
+ // Same reasoning as `assetNameComponent`: anything not in the map falls
632
+ // back to png, including a value that is not a string at all.
633
+ const map = {
634
+ 'image/png': 'png',
635
+ 'image/jpeg': 'jpg',
636
+ 'image/webp': 'webp',
637
+ 'image/gif': 'gif',
638
+ };
639
+ return map[mediaType] || 'png';
640
+ }
641
+ /**
642
+ * Copies one attachment list's in-memory blobs into the asset directory and
643
+ * returns the list with each fileName rewritten to its on-disk location and the
644
+ * data buffer stripped.
645
+ *
646
+ * Shared by the comment walk and the reply walk. Serialization emits the
647
+ * fileName it is given without checking that anything was written, so an
648
+ * attachment list that misses this function produces a document that validates
649
+ * against the schema while pointing at a file that does not exist. That failure
650
+ * has no error surface, which is why both walks go through here.
651
+ *
652
+ * The idPrefix names the resulting files. Comments pass their own id, so
653
+ * existing asset names are unchanged; replies pass a prefix that cannot collide
654
+ * with a comment's.
655
+ */
656
+ /**
657
+ * Reduce an id to something that can only ever name a file *inside* the asset
658
+ * directory.
659
+ *
660
+ * A comment id is not trusted input. The desktop gets its ReviewState from its
661
+ * own renderer, but the serve front end accepts a whole document over HTTP, so
662
+ * `../../x` in an id would walk this function's write out of the asset
663
+ * directory and onto an arbitrary path. Every id this app generates is a UUID,
664
+ * so restricting the prefix to the URL-safe alphabet renames nothing in
665
+ * practice and leaves existing asset names byte-identical.
666
+ */
667
+ function assetNameComponent(idPrefix) {
668
+ // Coerced rather than assumed: this runs before the document is validated
669
+ // against anything, so a caller that omits an id reaches here with
670
+ // `undefined`, and a bare `.replace` would turn that into a crash *after*
671
+ // the review has already been taken off the session — losing it. The
672
+ // serializer's job here is to name a file, not to police the document.
673
+ return String(idPrefix ?? '').replace(/[^A-Za-z0-9_-]/g, '_');
674
+ }
675
+ function persistAttachments(attachments, idPrefix, assetDir, onWrite) {
676
+ if (!attachments?.length)
677
+ return attachments;
678
+ return attachments.map((att, index) => {
679
+ if (!att.data)
680
+ return att;
681
+ onWrite();
682
+ const ext = extFromMediaType(att.mediaType);
683
+ const fileName = `${assetNameComponent(idPrefix)}-${index}.${ext}`;
684
+ const relativePath = `.self-review-assets/${fileName}`;
685
+ const target = path.join(assetDir, fileName);
686
+ // `assetNameComponent` already makes this unreachable. It stays because
687
+ // this write happens *before* the document is validated against the XSD
688
+ // (see `serializeReview`), so a file lands on disk even when serialization
689
+ // goes on to fail — which makes an escape here permanent, and worth a
690
+ // second, independent check rather than one clever regex.
691
+ if (path.dirname(path.resolve(target)) !== path.resolve(assetDir)) {
692
+ throw new Error(`Refusing to write an attachment outside ${assetDir}: ${fileName}`);
693
+ }
694
+ if (!fs.existsSync(assetDir)) {
695
+ fs.mkdirSync(assetDir, { recursive: true });
696
+ }
697
+ fs.writeFileSync(target, Buffer.from(att.data));
698
+ return { ...att, fileName: relativePath, data: undefined };
699
+ });
700
+ }
701
+ function writeAttachments(state, outputFilePath) {
702
+ const assetDir = path.join(path.dirname(outputFilePath), '.self-review-assets');
703
+ let hasAttachments = false;
704
+ const markWritten = () => {
705
+ hasAttachments = true;
706
+ };
707
+ const updatedFiles = state.files.map(file => ({
708
+ ...file,
709
+ // Every comment is walked, including one with no attachments of its own:
710
+ // its replies may carry attachments, and short-circuiting on the comment's
711
+ // own list would drop those blobs without a word.
712
+ comments: file.comments.map(comment => ({
713
+ ...comment,
714
+ attachments: persistAttachments(comment.attachments, comment.id, assetDir, markWritten),
715
+ ...(comment.replies
716
+ ? {
717
+ replies: comment.replies.map(reply => ({
718
+ ...reply,
719
+ attachments: persistAttachments(reply.attachments, `${comment.id}-r-${reply.id}`, assetDir, markWritten),
720
+ })),
721
+ }
722
+ : {}),
723
+ })),
724
+ }));
725
+ if (hasAttachments) {
726
+ console.error(`[main] Wrote attachment files to ${assetDir}`);
727
+ }
728
+ return { ...state, files: updatedFiles };
729
+ }
730
+ export async function serializeReview(state, outputFilePath) {
731
+ const processedState = writeAttachments(state, outputFilePath);
732
+ const xml = buildXml(processedState);
733
+ // Validate the XML against the XSD
734
+ try {
735
+ const validationResult = await validateXML({
736
+ xml: [{ fileName: 'review.xml', contents: xml }],
737
+ schema: [{ fileName: 'self-review-v3.xsd', contents: XSD_SCHEMA }],
738
+ });
739
+ if (!validationResult.valid) {
740
+ const errors = validationResult.errors || [];
741
+ console.error('XML validation failed:');
742
+ errors.forEach((err) => console.error(` ${err}`));
743
+ throw new Error('Generated XML does not conform to schema');
744
+ }
745
+ }
746
+ catch (error) {
747
+ // Re-throw if it's a schema validation failure (our own throw above)
748
+ if (error instanceof Error && error.message === 'Generated XML does not conform to schema') {
749
+ throw error;
750
+ }
751
+ // Infrastructure failure (e.g. WASM load): log warning and return XML anyway
752
+ if (error instanceof Error) {
753
+ console.error(`[main] XML validation infrastructure failed: ${error.message} - emitting XML without validation`);
754
+ }
755
+ else {
756
+ console.error('[main] XML validation infrastructure failed - emitting XML without validation');
757
+ }
758
+ return xml;
759
+ }
760
+ return xml;
761
+ }
762
+ function buildSourceAttributes(state) {
763
+ const source = state.source;
764
+ if (source.type === 'git') {
765
+ return ` git-diff-args="${escapeXml(source.gitDiffArgs)}" repository="${escapeXml(source.repository)}"`;
766
+ }
767
+ if (source.type === 'directory' || source.type === 'file') {
768
+ return ` source-path="${escapeXml(source.sourcePath)}"`;
769
+ }
770
+ // welcome mode: no source attributes
771
+ return '';
772
+ }
773
+ /**
774
+ * Remote provenance attributes on the review root. Like severity and
775
+ * confidence on a comment, absent means "not a remote review", so each
776
+ * attribute is emitted only when its field is set: a purely local review
777
+ * serializes byte-identically to a document written before these existed.
778
+ */
779
+ function buildRemoteAttributes(state) {
780
+ const attrs = [];
781
+ if (state.remoteUrl) {
782
+ attrs.push(`remote-url="${escapeXml(state.remoteUrl)}"`);
783
+ }
784
+ if (state.remoteBaseSha) {
785
+ attrs.push(`remote-base-sha="${escapeXml(state.remoteBaseSha)}"`);
786
+ }
787
+ if (state.remoteHeadSha) {
788
+ attrs.push(`remote-head-sha="${escapeXml(state.remoteHeadSha)}"`);
789
+ }
790
+ if (state.remoteForge) {
791
+ attrs.push(`remote-forge="${state.remoteForge}"`);
792
+ }
793
+ return attrs.length > 0 ? ' ' + attrs.join(' ') : '';
794
+ }
795
+ function buildXml(state) {
796
+ const lines = [];
797
+ // XML declaration
798
+ lines.push('<?xml version="1.0" encoding="UTF-8"?>');
799
+ // Root element with namespace
800
+ const sourceAttrs = buildSourceAttributes(state);
801
+ const remoteAttrs = buildRemoteAttributes(state);
802
+ lines.push(`<review xmlns="urn:self-review:v3" timestamp="${escapeXml(state.timestamp)}"${sourceAttrs}${remoteAttrs}>`);
803
+ // Files
804
+ for (const file of state.files) {
805
+ lines.push(...buildFileXml(file));
806
+ }
807
+ // Close root element
808
+ lines.push('</review>');
809
+ return lines.join('\n');
810
+ }
811
+ function buildFileXml(file) {
812
+ const lines = [];
813
+ if (file.comments.length === 0) {
814
+ // Self-closing tag for files with no comments
815
+ lines.push(` <file path="${escapeXml(file.path)}" change-type="${file.changeType}" viewed="${file.viewed}" />`);
816
+ }
817
+ else {
818
+ // Opening tag
819
+ lines.push(` <file path="${escapeXml(file.path)}" change-type="${file.changeType}" viewed="${file.viewed}">`);
820
+ // Comments
821
+ for (const comment of file.comments) {
822
+ lines.push(...buildCommentXml(comment));
823
+ }
824
+ // Closing tag
825
+ lines.push(' </file>');
826
+ }
827
+ return lines;
828
+ }
829
+ function buildCommentXml(comment) {
830
+ const lines = [];
831
+ const attrs = [];
832
+ // Add line attributes
833
+ if (comment.lineRange) {
834
+ if (comment.lineRange.side === 'old') {
835
+ attrs.push(`old-line-start="${comment.lineRange.start}"`);
836
+ attrs.push(`old-line-end="${comment.lineRange.end}"`);
837
+ }
838
+ else {
839
+ attrs.push(`new-line-start="${comment.lineRange.start}"`);
840
+ attrs.push(`new-line-end="${comment.lineRange.end}"`);
841
+ }
842
+ }
843
+ if (comment.author) {
844
+ attrs.push(`author="${escapeXml(comment.author)}"`);
845
+ }
846
+ // Thresholding signals. Absent means "below any floor", so they are omitted
847
+ // rather than defaulted when the author did not take a position.
848
+ if (comment.severity) {
849
+ attrs.push(`severity="${comment.severity}"`);
850
+ }
851
+ if (comment.confidence) {
852
+ attrs.push(`confidence="${comment.confidence}"`);
853
+ }
854
+ // Remote provenance. Absent means locally authored, so it is omitted
855
+ // rather than defaulted, exactly like the signals above.
856
+ if (comment.remoteId) {
857
+ attrs.push(`remote-id="${escapeXml(comment.remoteId)}"`);
858
+ }
859
+ const attrStr = attrs.length > 0 ? ' ' + attrs.join(' ') : '';
860
+ // Opening tag
861
+ lines.push(` <comment${attrStr}>`);
862
+ // Body (preserve whitespace and newlines)
863
+ lines.push(` <body>${escapeXml(comment.body)}</body>`);
864
+ // Category (required)
865
+ lines.push(` <category>${escapeXml(comment.category)}</category>`);
866
+ // Suggestion
867
+ if (comment.suggestion) {
868
+ lines.push(' <suggestion>');
869
+ lines.push(` <original-code>${escapeXml(comment.suggestion.originalCode)}</original-code>`);
870
+ lines.push(` <proposed-code>${escapeXml(comment.suggestion.proposedCode)}</proposed-code>`);
871
+ lines.push(' </suggestion>');
872
+ }
873
+ // Attachments
874
+ lines.push(...buildAttachmentXml(comment.attachments, ' '));
875
+ // Replies, in array order: document order is conversation order, and it is
876
+ // the only ordering signal a reply has.
877
+ for (const reply of comment.replies ?? []) {
878
+ lines.push(...buildReplyXml(reply));
879
+ }
880
+ // Closing tag
881
+ lines.push(' </comment>');
882
+ return lines;
883
+ }
884
+ /**
885
+ * Attachment elements are identical in form and meaning under a comment and
886
+ * under a reply, so both call sites emit them from here.
887
+ */
888
+ function buildAttachmentXml(attachments, indent) {
889
+ if (!attachments?.length)
890
+ return [];
891
+ return attachments.map(att => `${indent}<attachment path="${escapeXml(att.fileName)}" media-type="${escapeXml(att.mediaType)}" />`);
892
+ }
893
+ /**
894
+ * A reply is a flat turn in the thread: a body, optional attachments and an
895
+ * optional author. It carries no category, severity, confidence, suggestion or
896
+ * nested replies — those belong to the root comment, which owns the finding.
897
+ * See ReplyType in the XSD for the reasoning.
898
+ */
899
+ function buildReplyXml(reply) {
900
+ const attrs = [];
901
+ if (reply.author) {
902
+ attrs.push(`author="${escapeXml(reply.author)}"`);
903
+ }
904
+ if (reply.remoteId) {
905
+ attrs.push(`remote-id="${escapeXml(reply.remoteId)}"`);
906
+ }
907
+ const attrStr = attrs.length > 0 ? ' ' + attrs.join(' ') : '';
908
+ return [
909
+ ` <reply${attrStr}>`,
910
+ ` <body>${escapeXml(reply.body)}</body>`,
911
+ ...buildAttachmentXml(reply.attachments, ' '),
912
+ ' </reply>',
913
+ ];
914
+ }
915
+ function escapeXml(str) {
916
+ return str
917
+ .replace(/&/g, '&amp;')
918
+ .replace(/</g, '&lt;')
919
+ .replace(/>/g, '&gt;')
920
+ .replace(/"/g, '&quot;')
921
+ .replace(/'/g, '&apos;');
922
+ }
923
+ //# sourceMappingURL=xml-serializer.js.map