@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
package/dist/cli.js ADDED
@@ -0,0 +1,839 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/cli.ts
4
+ import { createRequire } from "module";
5
+
6
+ // src/args.ts
7
+ var VALUE_FLAGS = {
8
+ "--output": "outputPath",
9
+ "-o": "outputPath",
10
+ "--resume-from": "resumeFrom"
11
+ };
12
+ function requireValue(flag, value) {
13
+ if (value === "") {
14
+ throw new Error(`${flag} requires a file path argument`);
15
+ }
16
+ return value;
17
+ }
18
+ function parseServeArgs(argv) {
19
+ const args = {
20
+ gitDiffArgs: [],
21
+ outputPath: null,
22
+ resumeFrom: null,
23
+ help: false,
24
+ version: false
25
+ };
26
+ for (let i = 0; i < argv.length; i++) {
27
+ const arg = argv[i];
28
+ if (arg === "--help" || arg === "-h") {
29
+ args.help = true;
30
+ continue;
31
+ }
32
+ if (arg === "--version" || arg === "-v") {
33
+ args.version = true;
34
+ continue;
35
+ }
36
+ const equals = arg.indexOf("=");
37
+ if (equals > 0) {
38
+ const field2 = VALUE_FLAGS[arg.slice(0, equals)];
39
+ if (field2) {
40
+ args[field2] = requireValue(arg.slice(0, equals), arg.slice(equals + 1));
41
+ continue;
42
+ }
43
+ }
44
+ const field = VALUE_FLAGS[arg];
45
+ if (field) {
46
+ if (i + 1 >= argv.length) {
47
+ throw new Error(`${arg} requires a file path argument`);
48
+ }
49
+ args[field] = requireValue(arg, argv[i + 1]);
50
+ i++;
51
+ continue;
52
+ }
53
+ args.gitDiffArgs.push(arg);
54
+ }
55
+ return args;
56
+ }
57
+
58
+ // src/startup.ts
59
+ import { resolve } from "path";
60
+ import {
61
+ applyStagedUntrackedDefault,
62
+ checkWritability,
63
+ computePayloadStats,
64
+ countTotalLines,
65
+ createIgnoreFilter,
66
+ createReviewSession,
67
+ determineMode,
68
+ loadConfig,
69
+ loadGitDiffWithUntracked,
70
+ loadGuide,
71
+ normalizeGitDiffArgs,
72
+ parseReviewXml,
73
+ scanDirectory,
74
+ scanFile
75
+ } from "@self-review/core";
76
+ async function loadDiffForMode(gitDiffArgs, config) {
77
+ const mode = determineMode(gitDiffArgs);
78
+ console.error(`[serve] Startup mode: ${mode}`);
79
+ if (mode === "git") {
80
+ const { files, repository } = await loadGitDiffWithUntracked(gitDiffArgs);
81
+ const shouldKeep = createIgnoreFilter(config.ignore);
82
+ return {
83
+ files: files.filter((f) => shouldKeep(f.newPath || f.oldPath)),
84
+ source: { type: "git", gitDiffArgs: gitDiffArgs.join(" "), repository }
85
+ };
86
+ }
87
+ if (mode === "file") {
88
+ const fileArg = gitDiffArgs.find((a) => a !== "--" && !a.startsWith("-"));
89
+ const sourcePath = resolve(process.cwd(), fileArg);
90
+ return { files: await scanFile(sourcePath), source: { type: "file", sourcePath } };
91
+ }
92
+ if (mode === "directory") {
93
+ const dirArg = gitDiffArgs.find((a) => a !== "--" && !a.startsWith("-"));
94
+ const sourcePath = resolve(process.cwd(), dirArg);
95
+ return {
96
+ files: await scanDirectory(sourcePath, config.ignore),
97
+ source: { type: "directory", sourcePath }
98
+ };
99
+ }
100
+ throw new Error(
101
+ "Nothing to review: this is not a git repository and no path was given. Run self-review-serve inside a git repository, or pass a directory or file to review."
102
+ );
103
+ }
104
+ function containmentRoot(payload) {
105
+ return payload.source.type === "git" ? payload.source.repository : process.cwd();
106
+ }
107
+ async function resolveSession(args) {
108
+ let config = loadConfig();
109
+ const outputPath = resolve(process.cwd(), args.outputPath ?? config.outputFile);
110
+ if (!checkWritability(outputPath)) {
111
+ throw new Error(
112
+ `Output path is not writable: ${outputPath}. Pass a writable path with --output, or set output-file in .self-review.yaml.`
113
+ );
114
+ }
115
+ console.error(`[serve] Output path: ${outputPath}`);
116
+ let gitDiffArgs = args.gitDiffArgs;
117
+ if (gitDiffArgs.length === 0 && config.defaultDiffArgs) {
118
+ gitDiffArgs = config.defaultDiffArgs.split(" ").filter((a) => a.length > 0);
119
+ }
120
+ gitDiffArgs = normalizeGitDiffArgs(gitDiffArgs);
121
+ config = applyStagedUntrackedDefault(config, gitDiffArgs);
122
+ const diffData = await loadDiffForMode(gitDiffArgs, config);
123
+ console.error(`[serve] Loaded ${diffData.files.length} files`);
124
+ const stats = computePayloadStats(diffData.files.length, countTotalLines(diffData.files), config);
125
+ if (stats.exceedsAny) {
126
+ console.error(
127
+ `[serve] Large payload: ${stats.fileCount} files, ${stats.totalLines} lines (thresholds ${config.maxFiles} files, ${config.maxTotalLines} lines) \u2014 serving file contents on demand`
128
+ );
129
+ diffData.isLargePayload = true;
130
+ }
131
+ const session = createReviewSession();
132
+ if (args.resumeFrom) {
133
+ const resumePath = resolve(process.cwd(), args.resumeFrom);
134
+ let parsed;
135
+ try {
136
+ parsed = parseReviewXml(resumePath);
137
+ } catch (error) {
138
+ throw new Error(
139
+ `Could not read the resume file ${resumePath}: ` + (error instanceof Error ? error.message : String(error))
140
+ );
141
+ }
142
+ session.resumeComments = parsed.comments;
143
+ session.resumeViewedFiles = parsed.viewedFiles;
144
+ console.error(
145
+ `[serve] Resumed ${parsed.comments.length} comments and ${parsed.viewedFiles.length} viewed files from ${resumePath}`
146
+ );
147
+ }
148
+ const guideData = await loadGuide(
149
+ outputPath,
150
+ config,
151
+ diffData.files.map((f) => f.newPath || f.oldPath)
152
+ );
153
+ if (guideData) {
154
+ console.error(`[serve] Walkthrough guide loaded: ${guideData.groups.length} groups`);
155
+ }
156
+ session.diffData = diffData;
157
+ session.guideData = guideData;
158
+ session.config = config;
159
+ session.outputPathInfo = { resolvedOutputPath: outputPath, outputPathWritable: true };
160
+ return { session, repositoryRoot: containmentRoot(diffData), outputPath };
161
+ }
162
+
163
+ // src/lifecycle.ts
164
+ import * as fs from "fs";
165
+ import { serializeReview, takeReviewState } from "@self-review/core";
166
+ async function writeReviewOutput(state, outputPath) {
167
+ const xml = await serializeReview(state, outputPath);
168
+ fs.writeFileSync(outputPath, xml + "\n", "utf-8");
169
+ }
170
+ function shutdown(server, exit, code) {
171
+ server.closeAllConnections();
172
+ server.close();
173
+ exit(code);
174
+ }
175
+ function completeReviewOnSubmit(options) {
176
+ const { server, session, outputPath, exit = process.exit } = options;
177
+ let completing = false;
178
+ server.on("request", (req, res) => {
179
+ if (req.method !== "POST" || pathnameOf(req.url) !== "/api/review") {
180
+ return;
181
+ }
182
+ res.on("finish", () => {
183
+ if (res.statusCode !== 200 || completing) {
184
+ return;
185
+ }
186
+ completing = true;
187
+ void complete(server, session, outputPath, exit);
188
+ });
189
+ });
190
+ }
191
+ function pathnameOf(url) {
192
+ try {
193
+ return new URL(url ?? "/", "http://localhost").pathname;
194
+ } catch {
195
+ return null;
196
+ }
197
+ }
198
+ async function complete(server, session, outputPath, exit) {
199
+ const state = takeReviewState(session);
200
+ if (!state) {
201
+ console.error("[serve] Review submission accepted but no state was recorded");
202
+ shutdown(server, exit, 1);
203
+ return;
204
+ }
205
+ try {
206
+ await writeReviewOutput(state, outputPath);
207
+ } catch (error) {
208
+ console.error(
209
+ `[serve] Error saving review: ${error instanceof Error ? error.message : String(error)}`
210
+ );
211
+ shutdown(server, exit, 1);
212
+ return;
213
+ }
214
+ console.error(`[serve] Review written to ${outputPath}`);
215
+ shutdown(server, exit, 0);
216
+ }
217
+
218
+ // src/server.ts
219
+ import * as fs3 from "fs";
220
+ import * as http from "http";
221
+ import * as path2 from "path";
222
+ import { fileURLToPath } from "url";
223
+ import {
224
+ getDiffLoad,
225
+ getConfigLoad,
226
+ getResumeLoad,
227
+ getFileHunks,
228
+ loadImage,
229
+ readAttachment,
230
+ expandContext,
231
+ submitReviewState,
232
+ applySuggestionForSession
233
+ } from "@self-review/core";
234
+
235
+ // src/validate.ts
236
+ import * as fs2 from "fs";
237
+ import * as path from "path";
238
+ function realpathDeepestExisting(absolute) {
239
+ const missing = [];
240
+ let current = absolute;
241
+ for (; ; ) {
242
+ try {
243
+ const real = fs2.realpathSync(current);
244
+ return missing.length === 0 ? real : path.join(real, ...missing);
245
+ } catch {
246
+ const parent = path.dirname(current);
247
+ if (parent === current) {
248
+ return null;
249
+ }
250
+ missing.unshift(path.basename(current));
251
+ current = parent;
252
+ }
253
+ }
254
+ }
255
+ function containPath(root, candidate) {
256
+ let resolvedRoot;
257
+ try {
258
+ resolvedRoot = fs2.realpathSync(root);
259
+ } catch {
260
+ return null;
261
+ }
262
+ const resolved = realpathDeepestExisting(path.resolve(resolvedRoot, candidate));
263
+ if (resolved === null) {
264
+ return null;
265
+ }
266
+ if (resolved === resolvedRoot) {
267
+ return resolved;
268
+ }
269
+ const rootWithSep = resolvedRoot.endsWith(path.sep) ? resolvedRoot : resolvedRoot + path.sep;
270
+ return resolved.startsWith(rootWithSep) ? resolved : null;
271
+ }
272
+ var MAX_CONTEXT_LINES = 99999;
273
+ function isRecord(value) {
274
+ return typeof value === "object" && value !== null && !Array.isArray(value);
275
+ }
276
+ var EXPAND_CONTEXT_KEYS = /* @__PURE__ */ new Set(["filePath", "contextLines"]);
277
+ function parseExpandContextBody(body) {
278
+ if (typeof body !== "object" || body === null || Array.isArray(body)) {
279
+ return { ok: false, error: "body must be a JSON object" };
280
+ }
281
+ const record = body;
282
+ for (const key of Object.keys(record)) {
283
+ if (!EXPAND_CONTEXT_KEYS.has(key)) {
284
+ return { ok: false, error: `unknown field: ${key}` };
285
+ }
286
+ }
287
+ const { filePath, contextLines } = record;
288
+ if (typeof filePath !== "string") {
289
+ return { ok: false, error: "filePath must be a string" };
290
+ }
291
+ if (typeof contextLines !== "number" || !Number.isInteger(contextLines) || contextLines < 0 || contextLines > MAX_CONTEXT_LINES) {
292
+ return {
293
+ ok: false,
294
+ error: `contextLines must be an integer between 0 and ${MAX_CONTEXT_LINES}`
295
+ };
296
+ }
297
+ return { ok: true, value: { filePath, contextLines } };
298
+ }
299
+ var APPLY_KEYS = /* @__PURE__ */ new Set(["filePath", "lineRange", "suggestion"]);
300
+ var LINE_RANGE_KEYS = /* @__PURE__ */ new Set(["side", "start", "end"]);
301
+ var SUGGESTION_KEYS = /* @__PURE__ */ new Set(["originalCode", "proposedCode"]);
302
+ function parseSuggestionApplyBody(body) {
303
+ if (!isRecord(body)) {
304
+ return { ok: false, error: "body must be a JSON object" };
305
+ }
306
+ for (const key of Object.keys(body)) {
307
+ if (!APPLY_KEYS.has(key)) return { ok: false, error: `unknown field: ${key}` };
308
+ }
309
+ const { filePath, lineRange, suggestion } = body;
310
+ if (typeof filePath !== "string" || filePath === "") {
311
+ return { ok: false, error: "filePath must be a non-empty string" };
312
+ }
313
+ if (lineRange !== null) {
314
+ if (!isRecord(lineRange)) {
315
+ return { ok: false, error: "lineRange must be an object or null" };
316
+ }
317
+ for (const key of Object.keys(lineRange)) {
318
+ if (!LINE_RANGE_KEYS.has(key)) {
319
+ return { ok: false, error: `unknown lineRange field: ${key}` };
320
+ }
321
+ }
322
+ if (lineRange.side !== "old" && lineRange.side !== "new") {
323
+ return { ok: false, error: "lineRange.side must be 'old' or 'new'" };
324
+ }
325
+ for (const key of ["start", "end"]) {
326
+ const value = lineRange[key];
327
+ if (typeof value !== "number" || !Number.isInteger(value) || value < 1) {
328
+ return { ok: false, error: `lineRange.${key} must be a positive integer` };
329
+ }
330
+ }
331
+ if (lineRange.end < lineRange.start) {
332
+ return { ok: false, error: "lineRange.end must not precede lineRange.start" };
333
+ }
334
+ }
335
+ if (!isRecord(suggestion)) {
336
+ return { ok: false, error: "suggestion must be an object" };
337
+ }
338
+ for (const key of Object.keys(suggestion)) {
339
+ if (!SUGGESTION_KEYS.has(key)) {
340
+ return { ok: false, error: `unknown suggestion field: ${key}` };
341
+ }
342
+ }
343
+ for (const key of ["originalCode", "proposedCode"]) {
344
+ if (typeof suggestion[key] !== "string") {
345
+ return { ok: false, error: `suggestion.${key} must be a string` };
346
+ }
347
+ }
348
+ return { ok: true, value: body };
349
+ }
350
+ var REVIEW_STATE_KEYS = /* @__PURE__ */ new Set(["timestamp", "source", "files"]);
351
+ function parseReviewStateBody(body) {
352
+ if (typeof body !== "object" || body === null || Array.isArray(body)) {
353
+ return { ok: false, error: "body must be a JSON object" };
354
+ }
355
+ const record = body;
356
+ for (const key of Object.keys(record)) {
357
+ if (!REVIEW_STATE_KEYS.has(key)) {
358
+ return { ok: false, error: `unknown field: ${key}` };
359
+ }
360
+ }
361
+ const { timestamp, source, files } = record;
362
+ if (typeof timestamp !== "string") {
363
+ return { ok: false, error: "timestamp must be a string" };
364
+ }
365
+ if (typeof source !== "object" || source === null || Array.isArray(source)) {
366
+ return { ok: false, error: "source must be an object" };
367
+ }
368
+ if (!Array.isArray(files)) {
369
+ return { ok: false, error: "files must be an array" };
370
+ }
371
+ const decoded = decodeFileAttachments(files);
372
+ if (!decoded.ok) {
373
+ return decoded;
374
+ }
375
+ return { ok: true, value: { timestamp, source, files: decoded.value } };
376
+ }
377
+ var BASE64_PATTERN = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)$/;
378
+ var RAW_DATA_ERROR = "attachment data must be sent base64-encoded as dataBase64, never as a serialized ArrayBuffer";
379
+ var ID_PATTERN = /^[A-Za-z0-9_-]{1,64}$/;
380
+ function checkId(entry, what) {
381
+ if (entry.id === void 0) return null;
382
+ if (typeof entry.id !== "string" || !ID_PATTERN.test(entry.id)) {
383
+ return `${what} id must match ${ID_PATTERN.source}`;
384
+ }
385
+ return null;
386
+ }
387
+ function base64ToArrayBuffer(value) {
388
+ const buffer = Buffer.from(value, "base64");
389
+ return buffer.buffer.slice(
390
+ buffer.byteOffset,
391
+ buffer.byteOffset + buffer.byteLength
392
+ );
393
+ }
394
+ function decodeAttachmentList(list) {
395
+ const decoded = [];
396
+ for (const entry of list) {
397
+ if (!isRecord(entry)) {
398
+ decoded.push(entry);
399
+ continue;
400
+ }
401
+ if (entry.data !== void 0) {
402
+ return { ok: false, error: RAW_DATA_ERROR };
403
+ }
404
+ if (entry.dataBase64 === void 0) {
405
+ decoded.push(entry);
406
+ continue;
407
+ }
408
+ const encoded = entry.dataBase64;
409
+ if (typeof encoded !== "string" || !BASE64_PATTERN.test(encoded)) {
410
+ return { ok: false, error: "attachment dataBase64 must be non-empty base64" };
411
+ }
412
+ const { dataBase64: _encoded, ...rest } = entry;
413
+ decoded.push({ ...rest, data: base64ToArrayBuffer(encoded) });
414
+ }
415
+ return { ok: true, value: decoded };
416
+ }
417
+ function decodeFileAttachments(files) {
418
+ const decodedFiles = [];
419
+ for (const file of files) {
420
+ if (!isRecord(file) || !Array.isArray(file.comments)) {
421
+ decodedFiles.push(file);
422
+ continue;
423
+ }
424
+ const decodedComments = [];
425
+ for (const comment of file.comments) {
426
+ if (!isRecord(comment)) {
427
+ decodedComments.push(comment);
428
+ continue;
429
+ }
430
+ const commentIdError = checkId(comment, "comment");
431
+ if (commentIdError) return { ok: false, error: commentIdError };
432
+ const next = { ...comment };
433
+ if (Array.isArray(comment.attachments)) {
434
+ const result = decodeAttachmentList(comment.attachments);
435
+ if (!result.ok) return result;
436
+ next.attachments = result.value;
437
+ }
438
+ if (Array.isArray(comment.replies)) {
439
+ const decodedReplies = [];
440
+ for (const reply of comment.replies) {
441
+ if (!isRecord(reply)) {
442
+ decodedReplies.push(reply);
443
+ continue;
444
+ }
445
+ const replyIdError = checkId(reply, "reply");
446
+ if (replyIdError) return { ok: false, error: replyIdError };
447
+ if (!Array.isArray(reply.attachments)) {
448
+ decodedReplies.push(reply);
449
+ continue;
450
+ }
451
+ const result = decodeAttachmentList(reply.attachments);
452
+ if (!result.ok) return result;
453
+ decodedReplies.push({ ...reply, attachments: result.value });
454
+ }
455
+ next.replies = decodedReplies;
456
+ }
457
+ decodedComments.push(next);
458
+ }
459
+ decodedFiles.push({ ...file, comments: decodedComments });
460
+ }
461
+ return { ok: true, value: decodedFiles };
462
+ }
463
+
464
+ // src/server.ts
465
+ var CLIENT_DIR = fileURLToPath(new URL("./client/", import.meta.url));
466
+ var MAX_EXPAND_CONTEXT_BODY_BYTES = 64 * 1024;
467
+ var MAX_REVIEW_BODY_BYTES = 32 * 1024 * 1024;
468
+ var CONTENT_TYPES = {
469
+ ".html": "text/html; charset=utf-8",
470
+ ".js": "text/javascript; charset=utf-8",
471
+ ".mjs": "text/javascript; charset=utf-8",
472
+ ".css": "text/css; charset=utf-8",
473
+ ".map": "application/json; charset=utf-8",
474
+ ".json": "application/json; charset=utf-8",
475
+ ".svg": "image/svg+xml",
476
+ ".png": "image/png",
477
+ ".ico": "image/x-icon",
478
+ ".woff": "font/woff",
479
+ ".woff2": "font/woff2",
480
+ ".txt": "text/plain; charset=utf-8"
481
+ };
482
+ var CSP = [
483
+ "default-src 'self'",
484
+ "script-src 'self'",
485
+ "style-src 'self' 'unsafe-inline'",
486
+ "img-src 'self' data: blob:",
487
+ "font-src 'self' data:",
488
+ "connect-src 'self'",
489
+ "frame-src 'none'",
490
+ "child-src 'none'",
491
+ "object-src 'none'",
492
+ "base-uri 'none'",
493
+ "form-action 'none'",
494
+ "frame-ancestors 'none'"
495
+ ].join("; ");
496
+ var SECURITY_HEADERS = {
497
+ "content-security-policy": CSP,
498
+ "x-content-type-options": "nosniff",
499
+ "x-frame-options": "DENY",
500
+ "referrer-policy": "no-referrer"
501
+ };
502
+ var LOOPBACK_HOSTNAMES = /* @__PURE__ */ new Set(["127.0.0.1", "localhost", "[::1]"]);
503
+ function normalizeHost(value) {
504
+ const lowered = value.toLowerCase();
505
+ return lowered.endsWith(":80") ? lowered.slice(0, -3) : lowered;
506
+ }
507
+ function hostIsLoopback(req) {
508
+ const host = req.headers.host;
509
+ if (host === void 0) return false;
510
+ let seen = 0;
511
+ for (let i = 0; i < req.rawHeaders.length; i += 2) {
512
+ if (req.rawHeaders[i].toLowerCase() === "host") seen++;
513
+ }
514
+ if (seen !== 1) return false;
515
+ const match = /^(\[[^\]]*\]|[^:]*)(?::(\d+))?$/.exec(host);
516
+ if (match === null) return false;
517
+ return LOOPBACK_HOSTNAMES.has(match[1].toLowerCase());
518
+ }
519
+ function originMatchesHost(req) {
520
+ const origin = req.headers.origin;
521
+ if (origin === void 0) return true;
522
+ const host = req.headers.host;
523
+ if (host === void 0) return false;
524
+ let parsed;
525
+ try {
526
+ parsed = new URL(origin);
527
+ } catch {
528
+ return false;
529
+ }
530
+ if (parsed.protocol !== "http:") return false;
531
+ if (origin !== `${parsed.protocol}//${parsed.host}`) return false;
532
+ return normalizeHost(parsed.host) === normalizeHost(host);
533
+ }
534
+ function fetchSiteIsSelf(req) {
535
+ const site = req.headers["sec-fetch-site"];
536
+ if (site === void 0) return true;
537
+ return site === "same-origin" || site === "none";
538
+ }
539
+ function sendJson(res, status, value, headers = {}) {
540
+ res.writeHead(status, {
541
+ "content-type": "application/json; charset=utf-8",
542
+ "cache-control": "no-store",
543
+ ...SECURITY_HEADERS,
544
+ ...headers
545
+ });
546
+ res.end(JSON.stringify(value ?? null));
547
+ }
548
+ function sendError(res, status, error) {
549
+ sendJson(res, status, { error }, status === 413 ? { connection: "close" } : {});
550
+ }
551
+ function requireContainedPath(ctx) {
552
+ const raw = ctx.url.searchParams.get("path");
553
+ const resolved = raw ? containPath(ctx.repositoryRoot, raw) : null;
554
+ if (raw === null || resolved === null) {
555
+ sendError(ctx.res, 400, "path must be a file under the repository root");
556
+ return null;
557
+ }
558
+ return { raw, resolved };
559
+ }
560
+ function readJsonBody(req, maxBytes) {
561
+ const contentType = req.headers["content-type"] ?? "";
562
+ if (!contentType.toLowerCase().startsWith("application/json")) {
563
+ return Promise.resolve({
564
+ ok: false,
565
+ status: 415,
566
+ error: "content-type must be application/json"
567
+ });
568
+ }
569
+ const declared = Number(req.headers["content-length"]);
570
+ if (Number.isFinite(declared) && declared > maxBytes) {
571
+ return Promise.resolve({ ok: false, status: 413, error: "request body too large" });
572
+ }
573
+ return new Promise((resolve3) => {
574
+ const chunks = [];
575
+ let received = 0;
576
+ req.on("data", (chunk) => {
577
+ received += chunk.length;
578
+ if (received > maxBytes) {
579
+ chunks.length = 0;
580
+ req.removeAllListeners("data");
581
+ req.removeAllListeners("end");
582
+ resolve3({ ok: false, status: 413, error: "request body too large" });
583
+ return;
584
+ }
585
+ chunks.push(chunk);
586
+ });
587
+ req.on("end", () => {
588
+ try {
589
+ resolve3({ ok: true, value: JSON.parse(Buffer.concat(chunks).toString("utf-8")) });
590
+ } catch {
591
+ resolve3({ ok: false, status: 400, error: "body must be valid JSON" });
592
+ }
593
+ });
594
+ req.on("error", () => {
595
+ resolve3({ ok: false, status: 400, error: "request body could not be read" });
596
+ });
597
+ });
598
+ }
599
+ var routes = {
600
+ "GET /api/diff": async ({ res, session }) => {
601
+ sendJson(res, 200, getDiffLoad(session));
602
+ },
603
+ "GET /api/config": async ({ res, session }) => {
604
+ sendJson(res, 200, getConfigLoad(session));
605
+ },
606
+ "GET /api/resume": async ({ res, session }) => {
607
+ sendJson(res, 200, getResumeLoad(session));
608
+ },
609
+ "GET /api/file": async (ctx) => {
610
+ const contained = requireContainedPath(ctx);
611
+ if (contained === null) return;
612
+ sendJson(ctx.res, 200, getFileHunks(ctx.session, contained.raw));
613
+ },
614
+ "GET /api/image": async (ctx) => {
615
+ const contained = requireContainedPath(ctx);
616
+ if (contained === null) return;
617
+ sendJson(ctx.res, 200, await loadImage(ctx.session, contained.raw));
618
+ },
619
+ "GET /api/attachment": async (ctx) => {
620
+ const assetRoot = ctx.session.outputPathInfo ? path2.dirname(ctx.session.outputPathInfo.resolvedOutputPath) : ctx.repositoryRoot;
621
+ const raw = ctx.url.searchParams.get("path");
622
+ const resolved = raw ? containPath(assetRoot, raw) : null;
623
+ if (resolved === null) {
624
+ sendError(ctx.res, 400, "path must be a file under the output directory");
625
+ return;
626
+ }
627
+ const data = await readAttachment(resolved);
628
+ if (data === null) {
629
+ sendError(ctx.res, 404, "attachment not found");
630
+ return;
631
+ }
632
+ const { res } = ctx;
633
+ res.writeHead(200, {
634
+ "content-type": "application/octet-stream",
635
+ "cache-control": "no-store",
636
+ ...SECURITY_HEADERS
637
+ });
638
+ res.end(Buffer.from(data));
639
+ },
640
+ "POST /api/expand-context": async ({ req, res, session, repositoryRoot }) => {
641
+ const body = await readJsonBody(req, MAX_EXPAND_CONTEXT_BODY_BYTES);
642
+ if (!body.ok) {
643
+ sendError(res, body.status, body.error);
644
+ return;
645
+ }
646
+ const parsed = parseExpandContextBody(body.value);
647
+ if (!parsed.ok) {
648
+ sendError(res, 400, parsed.error);
649
+ return;
650
+ }
651
+ if (containPath(repositoryRoot, parsed.value.filePath) === null) {
652
+ sendError(res, 400, "filePath must be a file under the repository root");
653
+ return;
654
+ }
655
+ sendJson(res, 200, await expandContext(session, parsed.value));
656
+ },
657
+ // The one route that rewrites a file in the reviewed tree. Core refuses
658
+ // unless the anchored lines still match the suggestion's recorded original
659
+ // byte for byte, and resolves the destination itself; the path is contained
660
+ // here so a request cannot even name a file outside the repository.
661
+ "POST /api/apply-suggestion": async ({ req, res, session, repositoryRoot }) => {
662
+ const body = await readJsonBody(req, MAX_EXPAND_CONTEXT_BODY_BYTES);
663
+ if (!body.ok) {
664
+ sendError(res, body.status, body.error);
665
+ return;
666
+ }
667
+ const parsed = parseSuggestionApplyBody(body.value);
668
+ if (!parsed.ok) {
669
+ sendError(res, 400, parsed.error);
670
+ return;
671
+ }
672
+ if (containPath(repositoryRoot, parsed.value.filePath) === null) {
673
+ sendError(res, 400, "filePath must be a file under the repository root");
674
+ return;
675
+ }
676
+ sendJson(res, 200, applySuggestionForSession(session, parsed.value));
677
+ },
678
+ "POST /api/review": async ({ req, res, session }) => {
679
+ const body = await readJsonBody(req, MAX_REVIEW_BODY_BYTES);
680
+ if (!body.ok) {
681
+ sendError(res, body.status, body.error);
682
+ return;
683
+ }
684
+ const parsed = parseReviewStateBody(body.value);
685
+ if (!parsed.ok) {
686
+ sendError(res, 400, parsed.error);
687
+ return;
688
+ }
689
+ submitReviewState(session, parsed.value);
690
+ sendJson(res, 200, null);
691
+ }
692
+ };
693
+ var ROUTE_PATHS = new Set(Object.keys(routes).map((key) => key.split(" ")[1]));
694
+ async function serveStatic(res, clientDir, pathname) {
695
+ let decoded;
696
+ try {
697
+ decoded = decodeURIComponent(pathname);
698
+ } catch {
699
+ sendError(res, 404, "not found");
700
+ return;
701
+ }
702
+ const relative = decoded === "/" ? "index.html" : decoded.replace(/^\/+/, "");
703
+ const resolved = containPath(clientDir, relative);
704
+ if (resolved === null) {
705
+ sendError(res, 404, "not found");
706
+ return;
707
+ }
708
+ let data;
709
+ try {
710
+ const stat = await fs3.promises.stat(resolved);
711
+ if (!stat.isFile()) {
712
+ sendError(res, 404, "not found");
713
+ return;
714
+ }
715
+ data = await fs3.promises.readFile(resolved);
716
+ } catch {
717
+ sendError(res, 404, "not found");
718
+ return;
719
+ }
720
+ res.writeHead(200, {
721
+ "content-type": CONTENT_TYPES[path2.extname(resolved).toLowerCase()] ?? "application/octet-stream",
722
+ "content-length": data.length,
723
+ ...SECURITY_HEADERS
724
+ });
725
+ res.end(data);
726
+ }
727
+ function createReviewServer(options) {
728
+ const { session, repositoryRoot, clientDir = CLIENT_DIR } = options;
729
+ return http.createServer(async (req, res) => {
730
+ const method = req.method ?? "GET";
731
+ let url;
732
+ try {
733
+ url = new URL(req.url ?? "/", "http://localhost");
734
+ } catch {
735
+ sendError(res, 400, "malformed request URL");
736
+ return;
737
+ }
738
+ if (!hostIsLoopback(req) || !originMatchesHost(req) || !fetchSiteIsSelf(req)) {
739
+ sendError(res, 403, "forbidden");
740
+ return;
741
+ }
742
+ try {
743
+ const handler = routes[`${method} ${url.pathname}`];
744
+ if (handler) {
745
+ await handler({ req, res, url, session, repositoryRoot });
746
+ } else if (ROUTE_PATHS.has(url.pathname)) {
747
+ sendError(res, 405, "method not allowed");
748
+ } else if (url.pathname.startsWith("/api/")) {
749
+ sendError(res, 404, "not found");
750
+ } else if (method === "GET") {
751
+ await serveStatic(res, clientDir, url.pathname);
752
+ } else {
753
+ sendError(res, 404, "not found");
754
+ }
755
+ } catch (error) {
756
+ console.error(`[serve] ${method} ${url.pathname} failed:`, error);
757
+ if (!res.headersSent) {
758
+ sendError(res, 500, "internal error");
759
+ } else {
760
+ res.end();
761
+ }
762
+ }
763
+ });
764
+ }
765
+ function listenLoopback(server, port = 0) {
766
+ return new Promise((resolve3, reject) => {
767
+ server.once("error", reject);
768
+ server.listen(port, "127.0.0.1", () => {
769
+ server.off("error", reject);
770
+ const address = server.address();
771
+ resolve3({ port: address.port, url: `http://127.0.0.1:${address.port}/` });
772
+ });
773
+ });
774
+ }
775
+
776
+ // src/cli.ts
777
+ var HELP = `
778
+ self-review-serve - Serve the self-review interface over HTTP
779
+
780
+ Usage: self-review-serve [options] [<git-diff-args>...]
781
+
782
+ Options:
783
+ -o, --output <file> Write the review to <file> (default: ./review.xml, or
784
+ output-file from .self-review.yaml)
785
+ --resume-from <file> Load a previous review XML file
786
+ -h, --help Show this help message
787
+ -v, --version Show version number
788
+
789
+ All other arguments are passed to git diff. With none, the unstaged working
790
+ tree changes are reviewed. Outside a git repository, pass a directory or file.
791
+
792
+ Examples:
793
+ self-review-serve # unstaged changes
794
+ self-review-serve --staged
795
+ self-review-serve main..feature-branch
796
+ self-review-serve --resume-from review.xml # resume a previous review
797
+
798
+ The URL is printed to stderr on start. The output path is fixed by the
799
+ arguments above and cannot be changed from the browser. Completing the review
800
+ writes that file and stops this process. Nothing is saved before then, and
801
+ closing the tab once you have written a comment warns you first.
802
+
803
+ The listener binds to 127.0.0.1 and refuses any request that names another
804
+ host or origin, so a web page cannot reach it. There is no authentication:
805
+ anything that can reach the port can read the diff and complete the review,
806
+ which on a shared host means every local user. An ssh -L forward works.
807
+ `.trim();
808
+ function printVersion() {
809
+ try {
810
+ const requireFromHere = createRequire(import.meta.url);
811
+ const pkg = requireFromHere("../package.json");
812
+ console.error(`self-review-serve v${pkg.version}`);
813
+ } catch {
814
+ console.error("self-review-serve (version unknown)");
815
+ }
816
+ }
817
+ async function main() {
818
+ const args = parseServeArgs(process.argv.slice(2));
819
+ if (args.help) {
820
+ console.error(HELP);
821
+ return;
822
+ }
823
+ if (args.version) {
824
+ printVersion();
825
+ return;
826
+ }
827
+ const { session, repositoryRoot, outputPath } = await resolveSession(args);
828
+ const server = createReviewServer({ session, repositoryRoot });
829
+ completeReviewOnSubmit({ server, session, outputPath });
830
+ const { url } = await listenLoopback(server);
831
+ console.error(`[serve] Review ready at ${url}`);
832
+ console.error(`[serve] Completing the review writes ${outputPath} and stops this process.`);
833
+ console.error("[serve] The listener is loopback-only and unauthenticated.");
834
+ }
835
+ main().catch((error) => {
836
+ console.error(`[serve] ${error instanceof Error ? error.message : String(error)}`);
837
+ process.exit(1);
838
+ });
839
+ //# sourceMappingURL=cli.js.map