@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.
- package/README.md +128 -0
- package/dist/cli.js +839 -0
- package/dist/cli.js.map +1 -0
- package/dist/client/assets/_basePickBy-DzL66huQ.js +1 -0
- package/dist/client/assets/_baseUniq-D_kA9hnK.js +1 -0
- package/dist/client/assets/arc-LxCcHggQ.js +1 -0
- package/dist/client/assets/architectureDiagram-VXUJARFQ-BmSW2FCh.js +36 -0
- package/dist/client/assets/blockDiagram-VD42YOAC-Duz6oS5b.js +122 -0
- package/dist/client/assets/c4Diagram-YG6GDRKO-Bv4P72yB.js +10 -0
- package/dist/client/assets/channel-ydExFSqY.js +1 -0
- package/dist/client/assets/chunk-4BX2VUAB-D2GfUqwd.js +1 -0
- package/dist/client/assets/chunk-55IACEB6-C68L7s0h.js +1 -0
- package/dist/client/assets/chunk-B4BG7PRW-BtVwfswM.js +165 -0
- package/dist/client/assets/chunk-DI55MBZ5-BDdO91wt.js +220 -0
- package/dist/client/assets/chunk-FMBD7UC4-tB9OepVI.js +15 -0
- package/dist/client/assets/chunk-QN33PNHL-HjKgp1PB.js +1 -0
- package/dist/client/assets/chunk-QZHKN3VN-GT04-vw7.js +1 -0
- package/dist/client/assets/chunk-TZMSLE5B-DpxXSXMp.js +1 -0
- package/dist/client/assets/classDiagram-2ON5EDUG-Dg8dmmRD.js +1 -0
- package/dist/client/assets/classDiagram-v2-WZHVMYZB-Dg8dmmRD.js +1 -0
- package/dist/client/assets/clone-Bq6xpRgi.js +1 -0
- package/dist/client/assets/cose-bilkent-S5V4N54A-Ds41oEbD.js +1 -0
- package/dist/client/assets/cytoscape.esm-5J0xJHOV.js +321 -0
- package/dist/client/assets/dagre-6UL2VRFP-DZiEousR.js +4 -0
- package/dist/client/assets/defaultLocale-DX6XiGOO.js +1 -0
- package/dist/client/assets/diagram-PSM6KHXK-0_alnUMs.js +24 -0
- package/dist/client/assets/diagram-QEK2KX5R-KFaKVdU8.js +43 -0
- package/dist/client/assets/diagram-S2PKOQOG-C2Dy10VG.js +24 -0
- package/dist/client/assets/erDiagram-Q2GNP2WA-_P7rrcgu.js +60 -0
- package/dist/client/assets/flowDiagram-NV44I4VS-BvC6gSn5.js +162 -0
- package/dist/client/assets/ganttDiagram-JELNMOA3-DjzuVPeB.js +267 -0
- package/dist/client/assets/gitGraphDiagram-V2S2FVAM-B9fPDqqA.js +65 -0
- package/dist/client/assets/graph-BqLQdgDA.js +1 -0
- package/dist/client/assets/index-CAXQd1OO.js +286 -0
- package/dist/client/assets/index-CmSvc3Wo.css +1 -0
- package/dist/client/assets/infoDiagram-HS3SLOUP-DiMCwlkY.js +2 -0
- package/dist/client/assets/init-Gi6I4Gst.js +1 -0
- package/dist/client/assets/journeyDiagram-XKPGCS4Q-Dn5WdzPP.js +139 -0
- package/dist/client/assets/kanban-definition-3W4ZIXB7-D-BINTOt.js +89 -0
- package/dist/client/assets/katex-DhXJpUyf.js +261 -0
- package/dist/client/assets/layout-Bo5pDIcD.js +1 -0
- package/dist/client/assets/linear-CNmY37sq.js +1 -0
- package/dist/client/assets/mermaid.core-DfADLZQ1.js +250 -0
- package/dist/client/assets/mindmap-definition-VGOIOE7T-H5HwEwuX.js +68 -0
- package/dist/client/assets/ordinal-Cboi1Yqb.js +1 -0
- package/dist/client/assets/pieDiagram-ADFJNKIX-RiZa5XQN.js +30 -0
- package/dist/client/assets/quadrantDiagram-AYHSOK5B-CFFX55h2.js +7 -0
- package/dist/client/assets/requirementDiagram-UZGBJVZJ-B6JBcV1I.js +64 -0
- package/dist/client/assets/sankeyDiagram-TZEHDZUN-GZT80dnc.js +10 -0
- package/dist/client/assets/sequenceDiagram-WL72ISMW-CbUqoUma.js +145 -0
- package/dist/client/assets/stateDiagram-FKZM4ZOC-LEb-ZQVV.js +1 -0
- package/dist/client/assets/stateDiagram-v2-4FDKWEC3-BYGHA8iw.js +1 -0
- package/dist/client/assets/timeline-definition-IT6M3QCI-Cm1Kd50N.js +61 -0
- package/dist/client/assets/treemap-GDKQZRPO-CWXk-dEb.js +160 -0
- package/dist/client/assets/xychartDiagram-PRI3JC2R-BUllxp6G.js +7 -0
- package/dist/client/index.html +29 -0
- package/dist/core/src/apply-suggestion.d.ts +76 -0
- package/dist/core/src/apply-suggestion.d.ts.map +1 -0
- package/dist/core/src/apply-suggestion.js +109 -0
- package/dist/core/src/apply-suggestion.js.map +1 -0
- package/dist/core/src/config.d.ts +3 -0
- package/dist/core/src/config.d.ts.map +1 -0
- package/dist/core/src/config.js +196 -0
- package/dist/core/src/config.js.map +1 -0
- package/dist/core/src/diff-parser.d.ts +3 -0
- package/dist/core/src/diff-parser.d.ts.map +1 -0
- package/dist/core/src/diff-parser.js +236 -0
- package/dist/core/src/diff-parser.js.map +1 -0
- package/dist/core/src/directory-scanner.d.ts +18 -0
- package/dist/core/src/directory-scanner.d.ts.map +1 -0
- package/dist/core/src/directory-scanner.js +99 -0
- package/dist/core/src/directory-scanner.js.map +1 -0
- package/dist/core/src/fetch-comments.d.ts +69 -0
- package/dist/core/src/fetch-comments.d.ts.map +1 -0
- package/dist/core/src/fetch-comments.js +180 -0
- package/dist/core/src/fetch-comments.js.map +1 -0
- package/dist/core/src/file-type-utils.d.ts +16 -0
- package/dist/core/src/file-type-utils.d.ts.map +1 -0
- package/dist/core/src/file-type-utils.js +106 -0
- package/dist/core/src/file-type-utils.js.map +1 -0
- package/dist/core/src/forge-provider.d.ts +123 -0
- package/dist/core/src/forge-provider.d.ts.map +1 -0
- package/dist/core/src/forge-provider.js +68 -0
- package/dist/core/src/forge-provider.js.map +1 -0
- package/dist/core/src/fs-utils.d.ts +7 -0
- package/dist/core/src/fs-utils.d.ts.map +1 -0
- package/dist/core/src/fs-utils.js +20 -0
- package/dist/core/src/fs-utils.js.map +1 -0
- package/dist/core/src/git-diff-args.d.ts +38 -0
- package/dist/core/src/git-diff-args.d.ts.map +1 -0
- package/dist/core/src/git-diff-args.js +170 -0
- package/dist/core/src/git-diff-args.js.map +1 -0
- package/dist/core/src/git-diff-loader.d.ts +14 -0
- package/dist/core/src/git-diff-loader.d.ts.map +1 -0
- package/dist/core/src/git-diff-loader.js +30 -0
- package/dist/core/src/git-diff-loader.js.map +1 -0
- package/dist/core/src/git.d.ts +52 -0
- package/dist/core/src/git.d.ts.map +1 -0
- package/dist/core/src/git.js +191 -0
- package/dist/core/src/git.js.map +1 -0
- package/dist/core/src/github-provider.d.ts +7 -0
- package/dist/core/src/github-provider.d.ts.map +1 -0
- package/dist/core/src/github-provider.js +151 -0
- package/dist/core/src/github-provider.js.map +1 -0
- package/dist/core/src/gitlab-provider.d.ts +10 -0
- package/dist/core/src/gitlab-provider.d.ts.map +1 -0
- package/dist/core/src/gitlab-provider.js +207 -0
- package/dist/core/src/gitlab-provider.js.map +1 -0
- package/dist/core/src/guide-loader.d.ts +23 -0
- package/dist/core/src/guide-loader.d.ts.map +1 -0
- package/dist/core/src/guide-loader.js +95 -0
- package/dist/core/src/guide-loader.js.map +1 -0
- package/dist/core/src/guide-parser.d.ts +34 -0
- package/dist/core/src/guide-parser.d.ts.map +1 -0
- package/dist/core/src/guide-parser.js +136 -0
- package/dist/core/src/guide-parser.js.map +1 -0
- package/dist/core/src/guide-schema.d.ts +2 -0
- package/dist/core/src/guide-schema.d.ts.map +1 -0
- package/dist/core/src/guide-schema.js +202 -0
- package/dist/core/src/guide-schema.js.map +1 -0
- package/dist/core/src/ignore-filter.d.ts +8 -0
- package/dist/core/src/ignore-filter.d.ts.map +1 -0
- package/dist/core/src/ignore-filter.js +16 -0
- package/dist/core/src/ignore-filter.js.map +1 -0
- package/dist/core/src/index.d.ts +38 -0
- package/dist/core/src/index.d.ts.map +1 -0
- package/dist/core/src/index.js +54 -0
- package/dist/core/src/index.js.map +1 -0
- package/dist/core/src/materializer.d.ts +60 -0
- package/dist/core/src/materializer.d.ts.map +1 -0
- package/dist/core/src/materializer.js +255 -0
- package/dist/core/src/materializer.js.map +1 -0
- package/dist/core/src/payload-sizing.d.ts +20 -0
- package/dist/core/src/payload-sizing.d.ts.map +1 -0
- package/dist/core/src/payload-sizing.js +74 -0
- package/dist/core/src/payload-sizing.js.map +1 -0
- package/dist/core/src/remote-mode.d.ts +89 -0
- package/dist/core/src/remote-mode.d.ts.map +1 -0
- package/dist/core/src/remote-mode.js +193 -0
- package/dist/core/src/remote-mode.js.map +1 -0
- package/dist/core/src/review-handlers.d.ts +160 -0
- package/dist/core/src/review-handlers.d.ts.map +1 -0
- package/dist/core/src/review-handlers.js +463 -0
- package/dist/core/src/review-handlers.js.map +1 -0
- package/dist/core/src/staged-untracked.d.ts +12 -0
- package/dist/core/src/staged-untracked.d.ts.map +1 -0
- package/dist/core/src/staged-untracked.js +21 -0
- package/dist/core/src/staged-untracked.js.map +1 -0
- package/dist/core/src/startup-mode.d.ts +6 -0
- package/dist/core/src/startup-mode.d.ts.map +1 -0
- package/dist/core/src/startup-mode.js +73 -0
- package/dist/core/src/startup-mode.js.map +1 -0
- package/dist/core/src/synthetic-diff.d.ts +21 -0
- package/dist/core/src/synthetic-diff.d.ts.map +1 -0
- package/dist/core/src/synthetic-diff.js +104 -0
- package/dist/core/src/synthetic-diff.js.map +1 -0
- package/dist/core/src/thread-mapper.d.ts +39 -0
- package/dist/core/src/thread-mapper.d.ts.map +1 -0
- package/dist/core/src/thread-mapper.js +217 -0
- package/dist/core/src/thread-mapper.js.map +1 -0
- package/dist/core/src/types.d.ts +2 -0
- package/dist/core/src/types.d.ts.map +1 -0
- package/dist/core/src/types.js +2 -0
- package/dist/core/src/types.js.map +1 -0
- package/dist/core/src/xml-parser.d.ts +15 -0
- package/dist/core/src/xml-parser.d.ts.map +1 -0
- package/dist/core/src/xml-parser.js +237 -0
- package/dist/core/src/xml-parser.js.map +1 -0
- package/dist/core/src/xml-serializer.d.ts +4 -0
- package/dist/core/src/xml-serializer.d.ts.map +1 -0
- package/dist/core/src/xml-serializer.js +923 -0
- package/dist/core/src/xml-serializer.js.map +1 -0
- package/dist/react/src/ReviewPanel.d.ts +72 -0
- package/dist/react/src/ReviewPanel.d.ts.map +1 -0
- package/dist/react/src/ReviewPanel.js +51 -0
- package/dist/react/src/ReviewPanel.js.map +1 -0
- package/dist/react/src/SingleFileReview.d.ts +49 -0
- package/dist/react/src/SingleFileReview.d.ts.map +1 -0
- package/dist/react/src/SingleFileReview.js +41 -0
- package/dist/react/src/SingleFileReview.js.map +1 -0
- package/dist/react/src/adapter.d.ts +72 -0
- package/dist/react/src/adapter.d.ts.map +1 -0
- package/dist/react/src/adapter.js +2 -0
- package/dist/react/src/adapter.js.map +1 -0
- package/dist/react/src/components/Comments/AttachmentDropZone.d.ts +10 -0
- package/dist/react/src/components/Comments/AttachmentDropZone.d.ts.map +1 -0
- package/dist/react/src/components/Comments/AttachmentDropZone.js +52 -0
- package/dist/react/src/components/Comments/AttachmentDropZone.js.map +1 -0
- package/dist/react/src/components/Comments/AttachmentImage.d.ts +6 -0
- package/dist/react/src/components/Comments/AttachmentImage.d.ts.map +1 -0
- package/dist/react/src/components/Comments/AttachmentImage.js +50 -0
- package/dist/react/src/components/Comments/AttachmentImage.js.map +1 -0
- package/dist/react/src/components/Comments/AttachmentThumbnail.d.ts +6 -0
- package/dist/react/src/components/Comments/AttachmentThumbnail.d.ts.map +1 -0
- package/dist/react/src/components/Comments/AttachmentThumbnail.js +16 -0
- package/dist/react/src/components/Comments/AttachmentThumbnail.js.map +1 -0
- package/dist/react/src/components/Comments/CategorySelector.d.ts +6 -0
- package/dist/react/src/components/Comments/CategorySelector.d.ts.map +1 -0
- package/dist/react/src/components/Comments/CategorySelector.js +27 -0
- package/dist/react/src/components/Comments/CategorySelector.js.map +1 -0
- package/dist/react/src/components/Comments/CommentDisplay.d.ts +7 -0
- package/dist/react/src/components/Comments/CommentDisplay.d.ts.map +1 -0
- package/dist/react/src/components/Comments/CommentDisplay.js +103 -0
- package/dist/react/src/components/Comments/CommentDisplay.js.map +1 -0
- package/dist/react/src/components/Comments/CommentInput.d.ts +11 -0
- package/dist/react/src/components/Comments/CommentInput.d.ts.map +1 -0
- package/dist/react/src/components/Comments/CommentInput.js +81 -0
- package/dist/react/src/components/Comments/CommentInput.js.map +1 -0
- package/dist/react/src/components/Comments/ComposerCore.d.ts +49 -0
- package/dist/react/src/components/Comments/ComposerCore.d.ts.map +1 -0
- package/dist/react/src/components/Comments/ComposerCore.js +91 -0
- package/dist/react/src/components/Comments/ComposerCore.js.map +1 -0
- package/dist/react/src/components/Comments/EmojiAutocomplete.d.ts +14 -0
- package/dist/react/src/components/Comments/EmojiAutocomplete.d.ts.map +1 -0
- package/dist/react/src/components/Comments/EmojiAutocomplete.js +19 -0
- package/dist/react/src/components/Comments/EmojiAutocomplete.js.map +1 -0
- package/dist/react/src/components/Comments/ReplyDisplay.d.ts +22 -0
- package/dist/react/src/components/Comments/ReplyDisplay.d.ts.map +1 -0
- package/dist/react/src/components/Comments/ReplyDisplay.js +38 -0
- package/dist/react/src/components/Comments/ReplyDisplay.js.map +1 -0
- package/dist/react/src/components/Comments/ReplyInput.d.ts +9 -0
- package/dist/react/src/components/Comments/ReplyInput.d.ts.map +1 -0
- package/dist/react/src/components/Comments/ReplyInput.js +47 -0
- package/dist/react/src/components/Comments/ReplyInput.js.map +1 -0
- package/dist/react/src/components/Comments/SuggestionApplyControl.d.ts +27 -0
- package/dist/react/src/components/Comments/SuggestionApplyControl.d.ts.map +1 -0
- package/dist/react/src/components/Comments/SuggestionApplyControl.js +103 -0
- package/dist/react/src/components/Comments/SuggestionApplyControl.js.map +1 -0
- package/dist/react/src/components/Comments/SuggestionBlock.d.ts +26 -0
- package/dist/react/src/components/Comments/SuggestionBlock.d.ts.map +1 -0
- package/dist/react/src/components/Comments/SuggestionBlock.js +33 -0
- package/dist/react/src/components/Comments/SuggestionBlock.js.map +1 -0
- package/dist/react/src/components/Comments/SuggestionPanel.d.ts +8 -0
- package/dist/react/src/components/Comments/SuggestionPanel.d.ts.map +1 -0
- package/dist/react/src/components/Comments/SuggestionPanel.js +12 -0
- package/dist/react/src/components/Comments/SuggestionPanel.js.map +1 -0
- package/dist/react/src/components/DiffViewer/DiffContentArea.d.ts +35 -0
- package/dist/react/src/components/DiffViewer/DiffContentArea.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/DiffContentArea.js +40 -0
- package/dist/react/src/components/DiffViewer/DiffContentArea.js.map +1 -0
- package/dist/react/src/components/DiffViewer/DiffViewer.d.ts +4 -0
- package/dist/react/src/components/DiffViewer/DiffViewer.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/DiffViewer.js +110 -0
- package/dist/react/src/components/DiffViewer/DiffViewer.js.map +1 -0
- package/dist/react/src/components/DiffViewer/EmptyDiffMessage.d.ts +6 -0
- package/dist/react/src/components/DiffViewer/EmptyDiffMessage.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/EmptyDiffMessage.js +18 -0
- package/dist/react/src/components/DiffViewer/EmptyDiffMessage.js.map +1 -0
- package/dist/react/src/components/DiffViewer/EmptyLinePane.d.ts +2 -0
- package/dist/react/src/components/DiffViewer/EmptyLinePane.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/EmptyLinePane.js +5 -0
- package/dist/react/src/components/DiffViewer/EmptyLinePane.js.map +1 -0
- package/dist/react/src/components/DiffViewer/ExpandContextBar.d.ts +10 -0
- package/dist/react/src/components/DiffViewer/ExpandContextBar.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/ExpandContextBar.js +16 -0
- package/dist/react/src/components/DiffViewer/ExpandContextBar.js.map +1 -0
- package/dist/react/src/components/DiffViewer/FileSection.d.ts +9 -0
- package/dist/react/src/components/DiffViewer/FileSection.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/FileSection.js +137 -0
- package/dist/react/src/components/DiffViewer/FileSection.js.map +1 -0
- package/dist/react/src/components/DiffViewer/FileSectionBody.d.ts +13 -0
- package/dist/react/src/components/DiffViewer/FileSectionBody.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/FileSectionBody.js +8 -0
- package/dist/react/src/components/DiffViewer/FileSectionBody.js.map +1 -0
- package/dist/react/src/components/DiffViewer/FileSectionHeader.d.ts +16 -0
- package/dist/react/src/components/DiffViewer/FileSectionHeader.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/FileSectionHeader.js +53 -0
- package/dist/react/src/components/DiffViewer/FileSectionHeader.js.map +1 -0
- package/dist/react/src/components/DiffViewer/FrontMatterTable.d.ts +6 -0
- package/dist/react/src/components/DiffViewer/FrontMatterTable.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/FrontMatterTable.js +30 -0
- package/dist/react/src/components/DiffViewer/FrontMatterTable.js.map +1 -0
- package/dist/react/src/components/DiffViewer/GuideChapterDivider.d.ts +20 -0
- package/dist/react/src/components/DiffViewer/GuideChapterDivider.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/GuideChapterDivider.js +27 -0
- package/dist/react/src/components/DiffViewer/GuideChapterDivider.js.map +1 -0
- package/dist/react/src/components/DiffViewer/GuideOverviewContent.d.ts +16 -0
- package/dist/react/src/components/DiffViewer/GuideOverviewContent.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/GuideOverviewContent.js +56 -0
- package/dist/react/src/components/DiffViewer/GuideOverviewContent.js.map +1 -0
- package/dist/react/src/components/DiffViewer/GuideOverviewDialog.d.ts +12 -0
- package/dist/react/src/components/DiffViewer/GuideOverviewDialog.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/GuideOverviewDialog.js +13 -0
- package/dist/react/src/components/DiffViewer/GuideOverviewDialog.js.map +1 -0
- package/dist/react/src/components/DiffViewer/GuideOverviewPanel.d.ts +8 -0
- package/dist/react/src/components/DiffViewer/GuideOverviewPanel.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/GuideOverviewPanel.js +16 -0
- package/dist/react/src/components/DiffViewer/GuideOverviewPanel.js.map +1 -0
- package/dist/react/src/components/DiffViewer/HunkHeader.d.ts +5 -0
- package/dist/react/src/components/DiffViewer/HunkHeader.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/HunkHeader.js +5 -0
- package/dist/react/src/components/DiffViewer/HunkHeader.js.map +1 -0
- package/dist/react/src/components/DiffViewer/InlineCommentSlot.d.ts +18 -0
- package/dist/react/src/components/DiffViewer/InlineCommentSlot.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/InlineCommentSlot.js +13 -0
- package/dist/react/src/components/DiffViewer/InlineCommentSlot.js.map +1 -0
- package/dist/react/src/components/DiffViewer/MarkdownCode.d.ts +9 -0
- package/dist/react/src/components/DiffViewer/MarkdownCode.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/MarkdownCode.js +24 -0
- package/dist/react/src/components/DiffViewer/MarkdownCode.js.map +1 -0
- package/dist/react/src/components/DiffViewer/MermaidBlock.d.ts +4 -0
- package/dist/react/src/components/DiffViewer/MermaidBlock.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/MermaidBlock.js +51 -0
- package/dist/react/src/components/DiffViewer/MermaidBlock.js.map +1 -0
- package/dist/react/src/components/DiffViewer/RenderedImageView.d.ts +8 -0
- package/dist/react/src/components/DiffViewer/RenderedImageView.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/RenderedImageView.js +46 -0
- package/dist/react/src/components/DiffViewer/RenderedImageView.js.map +1 -0
- package/dist/react/src/components/DiffViewer/RenderedMarkdownView.d.ts +16 -0
- package/dist/react/src/components/DiffViewer/RenderedMarkdownView.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/RenderedMarkdownView.js +324 -0
- package/dist/react/src/components/DiffViewer/RenderedMarkdownView.js.map +1 -0
- package/dist/react/src/components/DiffViewer/RenderedSvgView.d.ts +7 -0
- package/dist/react/src/components/DiffViewer/RenderedSvgView.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/RenderedSvgView.js +21 -0
- package/dist/react/src/components/DiffViewer/RenderedSvgView.js.map +1 -0
- package/dist/react/src/components/DiffViewer/SplitView.d.ts +23 -0
- package/dist/react/src/components/DiffViewer/SplitView.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/SplitView.js +137 -0
- package/dist/react/src/components/DiffViewer/SplitView.js.map +1 -0
- package/dist/react/src/components/DiffViewer/SyntaxLine.d.ts +49 -0
- package/dist/react/src/components/DiffViewer/SyntaxLine.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/SyntaxLine.js +73 -0
- package/dist/react/src/components/DiffViewer/SyntaxLine.js.map +1 -0
- package/dist/react/src/components/DiffViewer/UnifiedView.d.ts +23 -0
- package/dist/react/src/components/DiffViewer/UnifiedView.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/UnifiedView.js +96 -0
- package/dist/react/src/components/DiffViewer/UnifiedView.js.map +1 -0
- package/dist/react/src/components/DiffViewer/diff-utils.d.ts +31 -0
- package/dist/react/src/components/DiffViewer/diff-utils.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/diff-utils.js +134 -0
- package/dist/react/src/components/DiffViewer/diff-utils.js.map +1 -0
- package/dist/react/src/components/DiffViewer/useDragSelection.d.ts +25 -0
- package/dist/react/src/components/DiffViewer/useDragSelection.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/useDragSelection.js +210 -0
- package/dist/react/src/components/DiffViewer/useDragSelection.js.map +1 -0
- package/dist/react/src/components/DiffViewer/useExpandContext.d.ts +15 -0
- package/dist/react/src/components/DiffViewer/useExpandContext.d.ts.map +1 -0
- package/dist/react/src/components/DiffViewer/useExpandContext.js +209 -0
- package/dist/react/src/components/DiffViewer/useExpandContext.js.map +1 -0
- package/dist/react/src/components/FileTree.d.ts +2 -0
- package/dist/react/src/components/FileTree.d.ts.map +1 -0
- package/dist/react/src/components/FileTree.js +93 -0
- package/dist/react/src/components/FileTree.js.map +1 -0
- package/dist/react/src/components/FileTreeEntry.d.ts +13 -0
- package/dist/react/src/components/FileTreeEntry.d.ts.map +1 -0
- package/dist/react/src/components/FileTreeEntry.js +21 -0
- package/dist/react/src/components/FileTreeEntry.js.map +1 -0
- package/dist/react/src/components/FileTreeToggle.d.ts +15 -0
- package/dist/react/src/components/FileTreeToggle.d.ts.map +1 -0
- package/dist/react/src/components/FileTreeToggle.js +16 -0
- package/dist/react/src/components/FileTreeToggle.js.map +1 -0
- package/dist/react/src/components/GuideRouteHud.d.ts +10 -0
- package/dist/react/src/components/GuideRouteHud.d.ts.map +1 -0
- package/dist/react/src/components/GuideRouteHud.js +43 -0
- package/dist/react/src/components/GuideRouteHud.js.map +1 -0
- package/dist/react/src/components/GuideRouteMap.d.ts +20 -0
- package/dist/react/src/components/GuideRouteMap.d.ts.map +1 -0
- package/dist/react/src/components/GuideRouteMap.js +58 -0
- package/dist/react/src/components/GuideRouteMap.js.map +1 -0
- package/dist/react/src/components/GuideStation.d.ts +28 -0
- package/dist/react/src/components/GuideStation.d.ts.map +1 -0
- package/dist/react/src/components/GuideStation.js +24 -0
- package/dist/react/src/components/GuideStation.js.map +1 -0
- package/dist/react/src/components/HintOverlay.d.ts +13 -0
- package/dist/react/src/components/HintOverlay.d.ts.map +1 -0
- package/dist/react/src/components/HintOverlay.js +27 -0
- package/dist/react/src/components/HintOverlay.js.map +1 -0
- package/dist/react/src/components/KeyboardNavigationManager.d.ts +2 -0
- package/dist/react/src/components/KeyboardNavigationManager.d.ts.map +1 -0
- package/dist/react/src/components/KeyboardNavigationManager.js +8 -0
- package/dist/react/src/components/KeyboardNavigationManager.js.map +1 -0
- package/dist/react/src/components/Layout.d.ts +2 -0
- package/dist/react/src/components/Layout.d.ts.map +1 -0
- package/dist/react/src/components/Layout.js +63 -0
- package/dist/react/src/components/Layout.js.map +1 -0
- package/dist/react/src/components/ReviewProgress.d.ts +2 -0
- package/dist/react/src/components/ReviewProgress.d.ts.map +1 -0
- package/dist/react/src/components/ReviewProgress.js +25 -0
- package/dist/react/src/components/ReviewProgress.js.map +1 -0
- package/dist/react/src/components/Toolbar.d.ts +6 -0
- package/dist/react/src/components/Toolbar.d.ts.map +1 -0
- package/dist/react/src/components/Toolbar.js +61 -0
- package/dist/react/src/components/Toolbar.js.map +1 -0
- package/dist/react/src/components/TruncatedPath.d.ts +7 -0
- package/dist/react/src/components/TruncatedPath.d.ts.map +1 -0
- package/dist/react/src/components/TruncatedPath.js +15 -0
- package/dist/react/src/components/TruncatedPath.js.map +1 -0
- package/dist/react/src/components/ui/badge.d.ts +10 -0
- package/dist/react/src/components/ui/badge.d.ts.map +1 -0
- package/dist/react/src/components/ui/badge.js +21 -0
- package/dist/react/src/components/ui/badge.js.map +1 -0
- package/dist/react/src/components/ui/button.d.ts +11 -0
- package/dist/react/src/components/ui/button.d.ts.map +1 -0
- package/dist/react/src/components/ui/button.js +32 -0
- package/dist/react/src/components/ui/button.js.map +1 -0
- package/dist/react/src/components/ui/dialog.d.ts +12 -0
- package/dist/react/src/components/ui/dialog.d.ts.map +1 -0
- package/dist/react/src/components/ui/dialog.js +23 -0
- package/dist/react/src/components/ui/dialog.js.map +1 -0
- package/dist/react/src/components/ui/input.d.ts +4 -0
- package/dist/react/src/components/ui/input.d.ts.map +1 -0
- package/dist/react/src/components/ui/input.js +9 -0
- package/dist/react/src/components/ui/input.js.map +1 -0
- package/dist/react/src/components/ui/separator.d.ts +6 -0
- package/dist/react/src/components/ui/separator.d.ts.map +1 -0
- package/dist/react/src/components/ui/separator.js +8 -0
- package/dist/react/src/components/ui/separator.js.map +1 -0
- package/dist/react/src/components/ui/table.d.ts +11 -0
- package/dist/react/src/components/ui/table.d.ts.map +1 -0
- package/dist/react/src/components/ui/table.js +21 -0
- package/dist/react/src/components/ui/table.js.map +1 -0
- package/dist/react/src/components/ui/textarea.d.ts +4 -0
- package/dist/react/src/components/ui/textarea.d.ts.map +1 -0
- package/dist/react/src/components/ui/textarea.js +9 -0
- package/dist/react/src/components/ui/textarea.js.map +1 -0
- package/dist/react/src/components/ui/toggle-group.d.ts +22 -0
- package/dist/react/src/components/ui/toggle-group.d.ts.map +1 -0
- package/dist/react/src/components/ui/toggle-group.js +48 -0
- package/dist/react/src/components/ui/toggle-group.js.map +1 -0
- package/dist/react/src/components/ui/tooltip.d.ts +16 -0
- package/dist/react/src/components/ui/tooltip.d.ts.map +1 -0
- package/dist/react/src/components/ui/tooltip.js +21 -0
- package/dist/react/src/components/ui/tooltip.js.map +1 -0
- package/dist/react/src/context/ConfigContext.d.ts +26 -0
- package/dist/react/src/context/ConfigContext.d.ts.map +1 -0
- package/dist/react/src/context/ConfigContext.js +150 -0
- package/dist/react/src/context/ConfigContext.js.map +1 -0
- package/dist/react/src/context/DiffNavigationContext.d.ts +16 -0
- package/dist/react/src/context/DiffNavigationContext.d.ts.map +1 -0
- package/dist/react/src/context/DiffNavigationContext.js +79 -0
- package/dist/react/src/context/DiffNavigationContext.js.map +1 -0
- package/dist/react/src/context/GuideContext.d.ts +28 -0
- package/dist/react/src/context/GuideContext.d.ts.map +1 -0
- package/dist/react/src/context/GuideContext.js +64 -0
- package/dist/react/src/context/GuideContext.js.map +1 -0
- package/dist/react/src/context/ReviewAdapterContext.d.ts +9 -0
- package/dist/react/src/context/ReviewAdapterContext.d.ts.map +1 -0
- package/dist/react/src/context/ReviewAdapterContext.js +10 -0
- package/dist/react/src/context/ReviewAdapterContext.js.map +1 -0
- package/dist/react/src/context/ReviewContext.d.ts +60 -0
- package/dist/react/src/context/ReviewContext.d.ts.map +1 -0
- package/dist/react/src/context/ReviewContext.js +233 -0
- package/dist/react/src/context/ReviewContext.js.map +1 -0
- package/dist/react/src/hooks/useDiffNavigation.d.ts +4 -0
- package/dist/react/src/hooks/useDiffNavigation.d.ts.map +1 -0
- package/dist/react/src/hooks/useDiffNavigation.js +5 -0
- package/dist/react/src/hooks/useDiffNavigation.js.map +1 -0
- package/dist/react/src/hooks/useEmojiAutocomplete.d.ts +24 -0
- package/dist/react/src/hooks/useEmojiAutocomplete.d.ts.map +1 -0
- package/dist/react/src/hooks/useEmojiAutocomplete.js +175 -0
- package/dist/react/src/hooks/useEmojiAutocomplete.js.map +1 -0
- package/dist/react/src/hooks/useKeyboardNavigation.d.ts +15 -0
- package/dist/react/src/hooks/useKeyboardNavigation.d.ts.map +1 -0
- package/dist/react/src/hooks/useKeyboardNavigation.js +227 -0
- package/dist/react/src/hooks/useKeyboardNavigation.js.map +1 -0
- package/dist/react/src/hooks/useReviewBridge.d.ts +15 -0
- package/dist/react/src/hooks/useReviewBridge.d.ts.map +1 -0
- package/dist/react/src/hooks/useReviewBridge.js +43 -0
- package/dist/react/src/hooks/useReviewBridge.js.map +1 -0
- package/dist/react/src/hooks/useReviewState.d.ts +16 -0
- package/dist/react/src/hooks/useReviewState.d.ts.map +1 -0
- package/dist/react/src/hooks/useReviewState.js +101 -0
- package/dist/react/src/hooks/useReviewState.js.map +1 -0
- package/dist/react/src/index.d.ts +25 -0
- package/dist/react/src/index.d.ts.map +1 -0
- package/dist/react/src/index.js +22 -0
- package/dist/react/src/index.js.map +1 -0
- package/dist/react/src/lib/utils.d.ts +3 -0
- package/dist/react/src/lib/utils.d.ts.map +1 -0
- package/dist/react/src/lib/utils.js +6 -0
- package/dist/react/src/lib/utils.js.map +1 -0
- package/dist/react/src/utils/category-utils.d.ts +17 -0
- package/dist/react/src/utils/category-utils.d.ts.map +1 -0
- package/dist/react/src/utils/category-utils.js +23 -0
- package/dist/react/src/utils/category-utils.js.map +1 -0
- package/dist/react/src/utils/comment-anchors.d.ts +4 -0
- package/dist/react/src/utils/comment-anchors.d.ts.map +1 -0
- package/dist/react/src/utils/comment-anchors.js +17 -0
- package/dist/react/src/utils/comment-anchors.js.map +1 -0
- package/dist/react/src/utils/diff-styles.d.ts +12 -0
- package/dist/react/src/utils/diff-styles.d.ts.map +1 -0
- package/dist/react/src/utils/diff-styles.js +46 -0
- package/dist/react/src/utils/diff-styles.js.map +1 -0
- package/dist/react/src/utils/emoji-data.d.ts +8 -0
- package/dist/react/src/utils/emoji-data.d.ts.map +1 -0
- package/dist/react/src/utils/emoji-data.js +43 -0
- package/dist/react/src/utils/emoji-data.js.map +1 -0
- package/dist/react/src/utils/file-type-utils.d.ts +20 -0
- package/dist/react/src/utils/file-type-utils.d.ts.map +1 -0
- package/dist/react/src/utils/file-type-utils.js +110 -0
- package/dist/react/src/utils/file-type-utils.js.map +1 -0
- package/dist/react/src/utils/front-matter.d.ts +14 -0
- package/dist/react/src/utils/front-matter.d.ts.map +1 -0
- package/dist/react/src/utils/front-matter.js +40 -0
- package/dist/react/src/utils/front-matter.js.map +1 -0
- package/dist/react/src/utils/guide-accents.d.ts +46 -0
- package/dist/react/src/utils/guide-accents.d.ts.map +1 -0
- package/dist/react/src/utils/guide-accents.js +100 -0
- package/dist/react/src/utils/guide-accents.js.map +1 -0
- package/dist/react/src/utils/guide-display.d.ts +48 -0
- package/dist/react/src/utils/guide-display.d.ts.map +1 -0
- package/dist/react/src/utils/guide-display.js +75 -0
- package/dist/react/src/utils/guide-display.js.map +1 -0
- package/dist/react/src/utils/image-utils.d.ts +3 -0
- package/dist/react/src/utils/image-utils.d.ts.map +1 -0
- package/dist/react/src/utils/image-utils.js +33 -0
- package/dist/react/src/utils/image-utils.js.map +1 -0
- package/dist/react/src/utils/passive-content.d.ts +9 -0
- package/dist/react/src/utils/passive-content.d.ts.map +1 -0
- package/dist/react/src/utils/passive-content.js +135 -0
- package/dist/react/src/utils/passive-content.js.map +1 -0
- package/dist/react/src/utils/remark-emoji.d.ts +3 -0
- package/dist/react/src/utils/remark-emoji.d.ts.map +1 -0
- package/dist/react/src/utils/remark-emoji.js +38 -0
- package/dist/react/src/utils/remark-emoji.js.map +1 -0
- package/dist/serve/src/args.d.ts +15 -0
- package/dist/serve/src/args.d.ts.map +1 -0
- package/dist/serve/src/args.js +65 -0
- package/dist/serve/src/args.js.map +1 -0
- package/dist/serve/src/cli.d.ts +3 -0
- package/dist/serve/src/cli.d.ts.map +1 -0
- package/dist/serve/src/cli.js +81 -0
- package/dist/serve/src/cli.js.map +1 -0
- package/dist/serve/src/client/adapter.d.ts +25 -0
- package/dist/serve/src/client/adapter.d.ts.map +1 -0
- package/dist/serve/src/client/adapter.js +190 -0
- package/dist/serve/src/client/adapter.js.map +1 -0
- package/dist/serve/src/client/index.d.ts +2 -0
- package/dist/serve/src/client/index.d.ts.map +1 -0
- package/dist/serve/src/client/index.js +135 -0
- package/dist/serve/src/client/index.js.map +1 -0
- package/dist/serve/src/lifecycle.d.ts +27 -0
- package/dist/serve/src/lifecycle.d.ts.map +1 -0
- package/dist/serve/src/lifecycle.js +73 -0
- package/dist/serve/src/lifecycle.js.map +1 -0
- package/dist/serve/src/server.d.ts +34 -0
- package/dist/serve/src/server.d.ts.map +1 -0
- package/dist/serve/src/server.js +430 -0
- package/dist/serve/src/server.js.map +1 -0
- package/dist/serve/src/startup.d.ts +19 -0
- package/dist/serve/src/startup.d.ts.map +1 -0
- package/dist/serve/src/startup.js +117 -0
- package/dist/serve/src/startup.js.map +1 -0
- package/dist/serve/src/validate.d.ts +44 -0
- package/dist/serve/src/validate.d.ts.map +1 -0
- package/dist/serve/src/validate.js +295 -0
- package/dist/serve/src/validate.js.map +1 -0
- package/dist/types/src/index.d.ts +417 -0
- package/dist/types/src/index.d.ts.map +1 -0
- package/dist/types/src/index.js +5 -0
- package/dist/types/src/index.js.map +1 -0
- package/package.json +38 -0
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
// src/main/diff-parser.ts
|
|
2
|
+
// Parse unified diff output into DiffFile[]
|
|
3
|
+
export function parseDiff(rawDiff) {
|
|
4
|
+
if (!rawDiff.trim()) {
|
|
5
|
+
return [];
|
|
6
|
+
}
|
|
7
|
+
const lines = rawDiff.split('\n');
|
|
8
|
+
const files = [];
|
|
9
|
+
let currentFile = null;
|
|
10
|
+
let currentHunk = null;
|
|
11
|
+
let oldLineNumber = 0;
|
|
12
|
+
let newLineNumber = 0;
|
|
13
|
+
let hasModeChange = false;
|
|
14
|
+
function flushFile() {
|
|
15
|
+
if (currentFile &&
|
|
16
|
+
(currentFile.oldPath || currentFile.newPath) &&
|
|
17
|
+
(currentFile.isBinary ||
|
|
18
|
+
currentFile.hunks.length > 0 ||
|
|
19
|
+
currentFile.changeType !== 'modified' ||
|
|
20
|
+
hasModeChange)) {
|
|
21
|
+
files.push(currentFile);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
for (let i = 0; i < lines.length; i++) {
|
|
25
|
+
const line = lines[i];
|
|
26
|
+
// Start of a new file
|
|
27
|
+
if (line.startsWith('diff --git ')) {
|
|
28
|
+
// Flush the pending hunk into the current file before saving
|
|
29
|
+
if (currentHunk && currentHunk.header && currentFile) {
|
|
30
|
+
currentFile.hunks.push(currentHunk);
|
|
31
|
+
currentHunk = null;
|
|
32
|
+
}
|
|
33
|
+
flushFile();
|
|
34
|
+
// Extract paths from "diff --git a/<old> b/<new>" as fallback
|
|
35
|
+
// for binary files that lack --- / +++ lines
|
|
36
|
+
const gitPaths = parseGitDiffHeader(line);
|
|
37
|
+
// Initialize new file
|
|
38
|
+
currentFile = {
|
|
39
|
+
oldPath: gitPaths.oldPath,
|
|
40
|
+
newPath: gitPaths.newPath,
|
|
41
|
+
changeType: 'modified',
|
|
42
|
+
isBinary: false,
|
|
43
|
+
hunks: [],
|
|
44
|
+
};
|
|
45
|
+
currentHunk = null;
|
|
46
|
+
hasModeChange = false;
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (!currentFile)
|
|
50
|
+
continue;
|
|
51
|
+
// Detect file mode changes
|
|
52
|
+
if (line.startsWith('new file mode')) {
|
|
53
|
+
currentFile.changeType = 'added';
|
|
54
|
+
currentFile.oldPath = '';
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
if (line.startsWith('deleted file mode')) {
|
|
58
|
+
currentFile.changeType = 'deleted';
|
|
59
|
+
currentFile.newPath = '';
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (line.startsWith('new mode ')) {
|
|
63
|
+
hasModeChange = true;
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
if (line.startsWith('rename from ')) {
|
|
67
|
+
currentFile.changeType = 'renamed';
|
|
68
|
+
currentFile.oldPath = decodeGitPath(line.substring('rename from '.length));
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (line.startsWith('rename to ')) {
|
|
72
|
+
currentFile.newPath = decodeGitPath(line.substring('rename to '.length));
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
// Parse old file path
|
|
76
|
+
if (!currentHunk && line.startsWith('--- ')) {
|
|
77
|
+
const path = decodeGitPath(line.substring(4).split('\t')[0]);
|
|
78
|
+
currentFile.oldPath = path === '/dev/null' ? '' : stripPrefix(path);
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
// Parse new file path
|
|
82
|
+
if (!currentHunk && line.startsWith('+++ ')) {
|
|
83
|
+
const path = decodeGitPath(line.substring(4).split('\t')[0]);
|
|
84
|
+
currentFile.newPath = path === '/dev/null' ? '' : stripPrefix(path);
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
// Detect binary files
|
|
88
|
+
if (line.startsWith('Binary files ')) {
|
|
89
|
+
currentFile.isBinary = true;
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
// Parse hunk header
|
|
93
|
+
if (line.startsWith('@@')) {
|
|
94
|
+
// Save previous hunk if exists
|
|
95
|
+
if (currentHunk && currentHunk.header) {
|
|
96
|
+
currentFile.hunks.push(currentHunk);
|
|
97
|
+
}
|
|
98
|
+
// Parse hunk header: @@ -oldStart,oldLines +newStart,newLines @@ context
|
|
99
|
+
const match = line.match(/@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@(.*)$/);
|
|
100
|
+
if (match) {
|
|
101
|
+
const oldStart = parseInt(match[1], 10);
|
|
102
|
+
const oldLines = match[2] ? parseInt(match[2], 10) : 1;
|
|
103
|
+
const newStart = parseInt(match[3], 10);
|
|
104
|
+
const newLines = match[4] ? parseInt(match[4], 10) : 1;
|
|
105
|
+
const _context = match[5];
|
|
106
|
+
currentHunk = {
|
|
107
|
+
header: line,
|
|
108
|
+
oldStart,
|
|
109
|
+
oldLines,
|
|
110
|
+
newStart,
|
|
111
|
+
newLines,
|
|
112
|
+
lines: [],
|
|
113
|
+
};
|
|
114
|
+
oldLineNumber = oldStart;
|
|
115
|
+
newLineNumber = newStart;
|
|
116
|
+
}
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
// Parse diff lines (must have a current hunk)
|
|
120
|
+
if (currentHunk && currentHunk.lines) {
|
|
121
|
+
if (line.startsWith('+')) {
|
|
122
|
+
// Addition
|
|
123
|
+
currentHunk.lines.push({
|
|
124
|
+
type: 'addition',
|
|
125
|
+
oldLineNumber: null,
|
|
126
|
+
newLineNumber: newLineNumber,
|
|
127
|
+
content: line.substring(1),
|
|
128
|
+
});
|
|
129
|
+
newLineNumber++;
|
|
130
|
+
}
|
|
131
|
+
else if (line.startsWith('-')) {
|
|
132
|
+
// Deletion
|
|
133
|
+
currentHunk.lines.push({
|
|
134
|
+
type: 'deletion',
|
|
135
|
+
oldLineNumber: oldLineNumber,
|
|
136
|
+
newLineNumber: null,
|
|
137
|
+
content: line.substring(1),
|
|
138
|
+
});
|
|
139
|
+
oldLineNumber++;
|
|
140
|
+
}
|
|
141
|
+
else if (line.startsWith(' ')) {
|
|
142
|
+
// Context line
|
|
143
|
+
currentHunk.lines.push({
|
|
144
|
+
type: 'context',
|
|
145
|
+
oldLineNumber: oldLineNumber,
|
|
146
|
+
newLineNumber: newLineNumber,
|
|
147
|
+
content: line.substring(1),
|
|
148
|
+
});
|
|
149
|
+
oldLineNumber++;
|
|
150
|
+
newLineNumber++;
|
|
151
|
+
}
|
|
152
|
+
else if (line.startsWith('\\')) {
|
|
153
|
+
// "" - ignore
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
// Some other line (could be empty or malformed), treat as context
|
|
158
|
+
if (currentHunk.lines.length > 0) {
|
|
159
|
+
currentHunk.lines.push({
|
|
160
|
+
type: 'context',
|
|
161
|
+
oldLineNumber: oldLineNumber,
|
|
162
|
+
newLineNumber: newLineNumber,
|
|
163
|
+
content: line,
|
|
164
|
+
});
|
|
165
|
+
oldLineNumber++;
|
|
166
|
+
newLineNumber++;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
// Save the last hunk and file
|
|
172
|
+
if (currentHunk && currentHunk.header && currentFile) {
|
|
173
|
+
currentFile.hunks.push(currentHunk);
|
|
174
|
+
}
|
|
175
|
+
flushFile();
|
|
176
|
+
return files;
|
|
177
|
+
}
|
|
178
|
+
function stripPrefix(path) {
|
|
179
|
+
// Remove single-character prefix (a/, b/, c/, i/, w/, etc.)
|
|
180
|
+
// Git uses a/b by default, but mnemonicPrefix uses c/i/w/o
|
|
181
|
+
if (path.length > 2 && path[1] === '/') {
|
|
182
|
+
return path.substring(2);
|
|
183
|
+
}
|
|
184
|
+
return path;
|
|
185
|
+
}
|
|
186
|
+
function decodeGitPath(path) {
|
|
187
|
+
if (!path.startsWith('"') || !path.endsWith('"'))
|
|
188
|
+
return path;
|
|
189
|
+
const escapes = {
|
|
190
|
+
a: '\x07',
|
|
191
|
+
b: '\b',
|
|
192
|
+
f: '\f',
|
|
193
|
+
n: '\n',
|
|
194
|
+
r: '\r',
|
|
195
|
+
t: '\t',
|
|
196
|
+
v: '\v',
|
|
197
|
+
'"': '"',
|
|
198
|
+
'\\': '\\',
|
|
199
|
+
};
|
|
200
|
+
return path.slice(1, -1).replace(/(?:\\[0-7]{1,3})+|\\[abfnrtv"\\]/g, escape => {
|
|
201
|
+
if (/^\\[0-7]/.test(escape)) {
|
|
202
|
+
// Git quotes UTF-8 bytes as octal, so decode each run together.
|
|
203
|
+
const bytes = escape
|
|
204
|
+
.slice(1)
|
|
205
|
+
.split('\\')
|
|
206
|
+
.map(byte => parseInt(byte, 8));
|
|
207
|
+
return Buffer.from(bytes).toString('utf8');
|
|
208
|
+
}
|
|
209
|
+
return escapes[escape[1]];
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
function parseGitDiffHeader(line) {
|
|
213
|
+
const paths = line.substring('diff --git '.length);
|
|
214
|
+
// Quoted paths are single C-style tokens, even when they contain spaces.
|
|
215
|
+
const quotedOld = paths.match(/^("(?:\\.|[^"\\])*") (.+)$/);
|
|
216
|
+
const quotedNew = paths.match(/^(.+) ("(?:\\.|[^"\\])*")$/);
|
|
217
|
+
const quoted = quotedOld || quotedNew;
|
|
218
|
+
if (quoted) {
|
|
219
|
+
return {
|
|
220
|
+
oldPath: stripPrefix(decodeGitPath(quoted[1])),
|
|
221
|
+
newPath: stripPrefix(decodeGitPath(quoted[2])),
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
// Unquoted names can contain spaces. Prefer a boundary whose two paths
|
|
225
|
+
// agree; rename headers supply the exact paths when they differ.
|
|
226
|
+
const separators = [...paths.matchAll(/ [bwico]\//g)];
|
|
227
|
+
const boundary = separators.find(match => stripPrefix(paths.substring(0, match.index)) ===
|
|
228
|
+
stripPrefix(paths.substring(match.index + 1))) || separators[0];
|
|
229
|
+
if (!boundary)
|
|
230
|
+
return { oldPath: '', newPath: '' };
|
|
231
|
+
return {
|
|
232
|
+
oldPath: stripPrefix(paths.substring(0, boundary.index)),
|
|
233
|
+
newPath: stripPrefix(paths.substring(boundary.index + 1)),
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
//# sourceMappingURL=diff-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff-parser.js","sourceRoot":"","sources":["../../../../core/src/diff-parser.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAC1B,4CAA4C;AAI5C,MAAM,UAAU,SAAS,CAAC,OAAe;IACvC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;QACpB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAClC,MAAM,KAAK,GAA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;IAC5D,MAAM,MAAM,GAAG,SAAS,IAAI,SAAS,CAAC;IACtC,IAAI,MAAM,EAAE,CAAC;QACX,OAAO;YACL,OAAO,EAAE,WAAW,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;YAC9C,OAAO,EAAE,WAAW,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;SAC/C,CAAC;IACJ,CAAC;IAED,uEAAuE;IACvE,iEAAiE;IACjE,MAAM,UAAU,GAAG,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC;IACtD,MAAM,QAAQ,GACZ,UAAU,CAAC,IAAI,CACb,KAAK,CAAC,EAAE,CACN,WAAW,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;QAC5C,WAAW,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,KAAM,GAAG,CAAC,CAAC,CAAC,CACjD,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;IACrB,IAAI,CAAC,QAAQ;QAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;IAEnD,OAAO;QACL,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;QACxD,OAAO,EAAE,WAAW,CAAC,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAM,GAAG,CAAC,CAAC,CAAC;KAC3D,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DiffFile } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Recursively scan a directory and return DiffFile[] with every file
|
|
4
|
+
* treated as a new addition (changeType: 'added').
|
|
5
|
+
*
|
|
6
|
+
* @param directoryPath - Absolute path to the directory to scan
|
|
7
|
+
* @param ignorePatterns - Optional gitignore-compatible patterns to exclude files
|
|
8
|
+
* @returns Parsed DiffFile array for all files in the directory
|
|
9
|
+
*/
|
|
10
|
+
export declare function scanDirectory(directoryPath: string, ignorePatterns?: string[]): Promise<DiffFile[]>;
|
|
11
|
+
/**
|
|
12
|
+
* Scan a single file and return DiffFile[] with the file treated as a new addition.
|
|
13
|
+
*
|
|
14
|
+
* @param filePath - Absolute path to the file to scan
|
|
15
|
+
* @returns Parsed DiffFile array (single element)
|
|
16
|
+
*/
|
|
17
|
+
export declare function scanFile(filePath: string): Promise<DiffFile[]>;
|
|
18
|
+
//# sourceMappingURL=directory-scanner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory-scanner.d.ts","sourceRoot":"","sources":["../../../../core/src/directory-scanner.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAKnC;;;;;;;GAOG;AACH,wBAAsB,aAAa,CACjC,aAAa,EAAE,MAAM,EACrB,cAAc,GAAE,MAAM,EAAO,GAC5B,OAAO,CAAC,QAAQ,EAAE,CAAC,CA0DrB;AAED;;;;;GAKG;AACH,wBAAsB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,CAoBpE"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// src/main/directory-scanner.ts
|
|
2
|
+
// Recursively scans a directory and produces DiffFile[] treating all files as new additions.
|
|
3
|
+
import { readdir, stat } from 'fs/promises';
|
|
4
|
+
import { join, relative, basename, dirname } from 'path';
|
|
5
|
+
import { generateSyntheticDiffs } from './synthetic-diff';
|
|
6
|
+
import { parseDiff } from './diff-parser';
|
|
7
|
+
import { createIgnoreFilter } from './ignore-filter';
|
|
8
|
+
/**
|
|
9
|
+
* Recursively scan a directory and return DiffFile[] with every file
|
|
10
|
+
* treated as a new addition (changeType: 'added').
|
|
11
|
+
*
|
|
12
|
+
* @param directoryPath - Absolute path to the directory to scan
|
|
13
|
+
* @param ignorePatterns - Optional gitignore-compatible patterns to exclude files
|
|
14
|
+
* @returns Parsed DiffFile array for all files in the directory
|
|
15
|
+
*/
|
|
16
|
+
export async function scanDirectory(directoryPath, ignorePatterns = []) {
|
|
17
|
+
// Verify the path is a directory
|
|
18
|
+
try {
|
|
19
|
+
const dirStat = await stat(directoryPath);
|
|
20
|
+
if (!dirStat.isDirectory()) {
|
|
21
|
+
console.error(`Error: "${directoryPath}" is not a directory`);
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
if (error instanceof Error) {
|
|
27
|
+
console.error(`Error accessing directory "${directoryPath}": ${error.message}`);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
console.error(`Error accessing directory "${directoryPath}": unknown error`);
|
|
31
|
+
}
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
const filePaths = [];
|
|
35
|
+
try {
|
|
36
|
+
const entries = await readdir(directoryPath, {
|
|
37
|
+
recursive: true,
|
|
38
|
+
withFileTypes: true,
|
|
39
|
+
});
|
|
40
|
+
for (const entry of entries) {
|
|
41
|
+
if (!entry.isFile()) {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
// Build the full path from the entry's parentPath (or path) and name
|
|
45
|
+
const parentDir = entry.parentPath ?? entry.path;
|
|
46
|
+
const fullPath = join(parentDir, entry.name);
|
|
47
|
+
const relativePath = relative(directoryPath, fullPath);
|
|
48
|
+
filePaths.push(relativePath);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
if (error instanceof Error) {
|
|
53
|
+
console.error(`Error reading directory "${directoryPath}": ${error.message}`);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
console.error(`Error reading directory "${directoryPath}": unknown error`);
|
|
57
|
+
}
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
60
|
+
// Sort for deterministic output
|
|
61
|
+
filePaths.sort();
|
|
62
|
+
// Apply ignore patterns
|
|
63
|
+
const shouldKeep = createIgnoreFilter(ignorePatterns);
|
|
64
|
+
const filteredPaths = filePaths.filter(p => shouldKeep(p));
|
|
65
|
+
if (filteredPaths.length === 0) {
|
|
66
|
+
return [];
|
|
67
|
+
}
|
|
68
|
+
const diffText = generateSyntheticDiffs(filteredPaths, directoryPath);
|
|
69
|
+
return parseDiff(diffText);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Scan a single file and return DiffFile[] with the file treated as a new addition.
|
|
73
|
+
*
|
|
74
|
+
* @param filePath - Absolute path to the file to scan
|
|
75
|
+
* @returns Parsed DiffFile array (single element)
|
|
76
|
+
*/
|
|
77
|
+
export async function scanFile(filePath) {
|
|
78
|
+
try {
|
|
79
|
+
const fileStat = await stat(filePath);
|
|
80
|
+
if (!fileStat.isFile()) {
|
|
81
|
+
console.error(`Error: "${filePath}" is not a file`);
|
|
82
|
+
return [];
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
if (error instanceof Error) {
|
|
87
|
+
console.error(`Error accessing file "${filePath}": ${error.message}`);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
console.error(`Error accessing file "${filePath}": unknown error`);
|
|
91
|
+
}
|
|
92
|
+
return [];
|
|
93
|
+
}
|
|
94
|
+
const fileName = basename(filePath);
|
|
95
|
+
const rootDir = dirname(filePath);
|
|
96
|
+
const diffText = generateSyntheticDiffs([fileName], rootDir);
|
|
97
|
+
return parseDiff(diffText);
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=directory-scanner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directory-scanner.js","sourceRoot":"","sources":["../../../../core/src/directory-scanner.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,6FAA6F;AAE7F,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,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BAAiB,CAAC,CAAC;YACpD,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,OAAO,CAAC,KAAK,CAAC,yBAAyB,QAAQ,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACxE,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CAAC,yBAAyB,QAAQ,kBAAkB,CAAC,CAAC;QACrE,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACpC,MAAM,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAClC,MAAM,QAAQ,GAAG,sBAAsB,CAAC,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC;IAC7D,OAAO,SAAS,CAAC,QAAQ,CAAC,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { ForgeCommandRunner, ForgeName, ForgeProvider, ForgeUrl } from './forge-provider';
|
|
2
|
+
import type { ExistingClone, MaterializeResult } from './materializer';
|
|
3
|
+
import type { AppConfig, DiffFile, RemoteForge, ReviewComment, ReviewState } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Injectable seams for the orchestration. Defaults spawn real processes and
|
|
6
|
+
* touch the real filesystem; tests replace them wholesale.
|
|
7
|
+
*/
|
|
8
|
+
export interface FetchCommentsDeps {
|
|
9
|
+
/** Command runner shared by git, gh and glab invocations. */
|
|
10
|
+
runner: ForgeCommandRunner;
|
|
11
|
+
createProvider: (forge: ForgeName, runner: ForgeCommandRunner) => ForgeProvider;
|
|
12
|
+
materialize: (url: ForgeUrl, baseBranch: string, cwd: string, runner: ForgeCommandRunner, existingClone?: ExistingClone | null) => Promise<MaterializeResult>;
|
|
13
|
+
detectExistingClone: (url: ForgeUrl, cwd: string, runner: ForgeCommandRunner) => Promise<ExistingClone | null>;
|
|
14
|
+
resolveRemoteDefaultBranch: (url: ForgeUrl, runner: ForgeCommandRunner, existing?: ExistingClone | null) => Promise<string>;
|
|
15
|
+
loadDiffFiles: (repoPath: string, baseSha: string, headSha: string) => Promise<DiffFile[]>;
|
|
16
|
+
serialize: (state: ReviewState, outputPath: string) => Promise<string>;
|
|
17
|
+
writeFile: (path: string, content: string) => void;
|
|
18
|
+
loadConfig: () => AppConfig;
|
|
19
|
+
now: () => Date;
|
|
20
|
+
}
|
|
21
|
+
export interface BuildRemoteReviewStateArgs {
|
|
22
|
+
remoteUrl: string;
|
|
23
|
+
forge: RemoteForge;
|
|
24
|
+
baseSha: string;
|
|
25
|
+
headSha: string;
|
|
26
|
+
diffFiles: DiffFile[];
|
|
27
|
+
comments: ReviewComment[];
|
|
28
|
+
timestamp: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Assemble the ReviewState for a fetched remote review. Pure and
|
|
32
|
+
* deterministic: same inputs, same state.
|
|
33
|
+
*
|
|
34
|
+
* Placement rules:
|
|
35
|
+
* - Every diff file gets a file entry in diff order; fetched threads land on
|
|
36
|
+
* their files, in thread order.
|
|
37
|
+
* - Comments whose path is not in the diff (e.g. outdated anchors on files
|
|
38
|
+
* no longer touched) get a synthetic entry with change-type "modified" —
|
|
39
|
+
* the schema requires the attribute and "modified" is the least-claiming
|
|
40
|
+
* value for a file we cannot classify.
|
|
41
|
+
* - Review-level threads (sentinel {@link REVIEW_LEVEL_FILE_PATH}) are
|
|
42
|
+
* folded into a single trailing file entry with the sentinel path: the v3
|
|
43
|
+
* schema requires every <comment> inside a <file path>, and the empty
|
|
44
|
+
* path can never collide with a real diff path, so consumers detect these
|
|
45
|
+
* by comparing against the constant. Omitted when there are none.
|
|
46
|
+
* - Every file is viewed="false": fetch-comments reviews nothing, and a
|
|
47
|
+
* viewed mark claims a human looked at the file. A subsequent
|
|
48
|
+
* --resume-from session therefore starts with the full file list pending.
|
|
49
|
+
* - `source` is `{ type: 'welcome' }`: the remote-* root attributes are the
|
|
50
|
+
* review's source shape, and the three shapes (git, directory, remote)
|
|
51
|
+
* are mutually exclusive by contract, so no local source attributes are
|
|
52
|
+
* serialized.
|
|
53
|
+
*/
|
|
54
|
+
export declare function buildRemoteReviewState(args: BuildRemoteReviewStateArgs): ReviewState;
|
|
55
|
+
export interface FetchCommentsOptions {
|
|
56
|
+
/** Include threads the forge marks resolved (GitLab). Default false. */
|
|
57
|
+
includeResolved?: boolean;
|
|
58
|
+
/** Working directory for clone detection and output resolution. */
|
|
59
|
+
cwd?: string;
|
|
60
|
+
/** Test seams; every omitted member falls back to the real default. */
|
|
61
|
+
deps?: Partial<FetchCommentsDeps>;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Run the headless fetch-comments flow end to end. Throws on any failure
|
|
65
|
+
* (the caller prints the message to stderr and exits 1); the temporary
|
|
66
|
+
* clone, when one was created, is removed on both success and failure.
|
|
67
|
+
*/
|
|
68
|
+
export declare function runFetchComments(url: string, options?: FetchCommentsOptions): Promise<void>;
|
|
69
|
+
//# sourceMappingURL=fetch-comments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-comments.d.ts","sourceRoot":"","sources":["../../../../core/src/fetch-comments.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,kBAAkB,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAS/F,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAMvE,OAAO,KAAK,EACV,SAAS,EACT,QAAQ,EAER,WAAW,EACX,aAAa,EACb,WAAW,EACZ,MAAM,SAAS,CAAC;AAEjB;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,6DAA6D;IAC7D,MAAM,EAAE,kBAAkB,CAAC;IAC3B,cAAc,EAAE,CAAC,KAAK,EAAE,SAAS,EA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G;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,0BAA0B,GAAG,WAAW,CAkDpF;AAED,MAAM,WAAW,oBAAoB;IACnC,wEAAwE;IACxE,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,mEAAmE;IACnE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,uEAAuE;IACvE,IAAI,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;CACnC;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,IAAI,CAAC,CAqFf"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
// packages/core/src/fetch-comments.ts
|
|
2
|
+
// Headless orchestrator for `self-review fetch-comments <URL>`: materialize
|
|
3
|
+
// the PR/MR, fetch and map its discussion threads, and write a v3 review.xml
|
|
4
|
+
// with remote provenance — no window, nothing on stdout, all logging on
|
|
5
|
+
// stderr. Every collaborator is injectable so the flow is unit-testable; the
|
|
6
|
+
// CLI entry in main.ts stays thin.
|
|
7
|
+
import { writeFileSync } from 'fs';
|
|
8
|
+
import { resolve } from 'path';
|
|
9
|
+
import { ForgeCliUnavailableError, parseForgeUrl } from './forge-provider';
|
|
10
|
+
import { createGitHubProvider } from './github-provider';
|
|
11
|
+
import { createGitLabProvider } from './gitlab-provider';
|
|
12
|
+
import { defaultGitRunner, detectExistingClone, materialize, resolveRemoteDefaultBranch, } from './materializer';
|
|
13
|
+
import { mapThreadsToReviewComments, REVIEW_LEVEL_FILE_PATH } from './thread-mapper';
|
|
14
|
+
import { parseDiff } from './diff-parser';
|
|
15
|
+
import { runGitDiffAsync } from './git';
|
|
16
|
+
import { serializeReview } from './xml-serializer';
|
|
17
|
+
import { loadConfig } from './config';
|
|
18
|
+
function defaultDeps() {
|
|
19
|
+
return {
|
|
20
|
+
runner: defaultGitRunner,
|
|
21
|
+
createProvider: (forge, runner) => forge === 'github' ? createGitHubProvider(runner) : createGitLabProvider(runner),
|
|
22
|
+
detectExistingClone,
|
|
23
|
+
materialize,
|
|
24
|
+
resolveRemoteDefaultBranch,
|
|
25
|
+
loadDiffFiles: async (repoPath, baseSha, headSha) =>
|
|
26
|
+
// Triple-dot: diff from the merge base, matching how forges present a
|
|
27
|
+
// PR/MR diff. Runs inside the materialized clone.
|
|
28
|
+
parseDiff(await runGitDiffAsync([`${baseSha}...${headSha}`], repoPath)),
|
|
29
|
+
serialize: serializeReview,
|
|
30
|
+
writeFile: (path, content) => writeFileSync(path, content, 'utf-8'),
|
|
31
|
+
loadConfig,
|
|
32
|
+
now: () => new Date(),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Assemble the ReviewState for a fetched remote review. Pure and
|
|
37
|
+
* deterministic: same inputs, same state.
|
|
38
|
+
*
|
|
39
|
+
* Placement rules:
|
|
40
|
+
* - Every diff file gets a file entry in diff order; fetched threads land on
|
|
41
|
+
* their files, in thread order.
|
|
42
|
+
* - Comments whose path is not in the diff (e.g. outdated anchors on files
|
|
43
|
+
* no longer touched) get a synthetic entry with change-type "modified" —
|
|
44
|
+
* the schema requires the attribute and "modified" is the least-claiming
|
|
45
|
+
* value for a file we cannot classify.
|
|
46
|
+
* - Review-level threads (sentinel {@link REVIEW_LEVEL_FILE_PATH}) are
|
|
47
|
+
* folded into a single trailing file entry with the sentinel path: the v3
|
|
48
|
+
* schema requires every <comment> inside a <file path>, and the empty
|
|
49
|
+
* path can never collide with a real diff path, so consumers detect these
|
|
50
|
+
* by comparing against the constant. Omitted when there are none.
|
|
51
|
+
* - Every file is viewed="false": fetch-comments reviews nothing, and a
|
|
52
|
+
* viewed mark claims a human looked at the file. A subsequent
|
|
53
|
+
* --resume-from session therefore starts with the full file list pending.
|
|
54
|
+
* - `source` is `{ type: 'welcome' }`: the remote-* root attributes are the
|
|
55
|
+
* review's source shape, and the three shapes (git, directory, remote)
|
|
56
|
+
* are mutually exclusive by contract, so no local source attributes are
|
|
57
|
+
* serialized.
|
|
58
|
+
*/
|
|
59
|
+
export function buildRemoteReviewState(args) {
|
|
60
|
+
const commentsByPath = new Map();
|
|
61
|
+
for (const comment of args.comments) {
|
|
62
|
+
const list = commentsByPath.get(comment.filePath);
|
|
63
|
+
if (list) {
|
|
64
|
+
list.push(comment);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
commentsByPath.set(comment.filePath, [comment]);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const files = [];
|
|
71
|
+
const diffPaths = new Set();
|
|
72
|
+
for (const diffFile of args.diffFiles) {
|
|
73
|
+
const path = diffFile.changeType === 'deleted' ? diffFile.oldPath : diffFile.newPath;
|
|
74
|
+
diffPaths.add(path);
|
|
75
|
+
files.push({
|
|
76
|
+
path,
|
|
77
|
+
changeType: diffFile.changeType,
|
|
78
|
+
viewed: false,
|
|
79
|
+
comments: commentsByPath.get(path) ?? [],
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
// Synthetic entries for anchored comments whose file is not in the diff,
|
|
83
|
+
// in first-appearance order.
|
|
84
|
+
for (const [path, comments] of commentsByPath) {
|
|
85
|
+
if (path === REVIEW_LEVEL_FILE_PATH || diffPaths.has(path))
|
|
86
|
+
continue;
|
|
87
|
+
files.push({ path, changeType: 'modified', viewed: false, comments });
|
|
88
|
+
}
|
|
89
|
+
const reviewLevel = commentsByPath.get(REVIEW_LEVEL_FILE_PATH);
|
|
90
|
+
if (reviewLevel && reviewLevel.length > 0) {
|
|
91
|
+
files.push({
|
|
92
|
+
path: REVIEW_LEVEL_FILE_PATH,
|
|
93
|
+
changeType: 'modified',
|
|
94
|
+
viewed: false,
|
|
95
|
+
comments: reviewLevel,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
timestamp: args.timestamp,
|
|
100
|
+
source: { type: 'welcome' },
|
|
101
|
+
files,
|
|
102
|
+
remoteUrl: args.remoteUrl,
|
|
103
|
+
remoteBaseSha: args.baseSha,
|
|
104
|
+
remoteHeadSha: args.headSha,
|
|
105
|
+
remoteForge: args.forge,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Run the headless fetch-comments flow end to end. Throws on any failure
|
|
110
|
+
* (the caller prints the message to stderr and exits 1); the temporary
|
|
111
|
+
* clone, when one was created, is removed on both success and failure.
|
|
112
|
+
*/
|
|
113
|
+
export async function runFetchComments(url, options = {}) {
|
|
114
|
+
const deps = { ...defaultDeps(), ...options.deps };
|
|
115
|
+
const cwd = options.cwd ?? process.cwd();
|
|
116
|
+
const forgeUrl = parseForgeUrl(url);
|
|
117
|
+
if (forgeUrl === null) {
|
|
118
|
+
throw new Error(`Not a recognized pull/merge request URL: ${url}\n` +
|
|
119
|
+
'Expected a GitHub PR URL (…/pull/N) or a GitLab MR URL ' +
|
|
120
|
+
'(…/-/merge_requests/N).');
|
|
121
|
+
}
|
|
122
|
+
const provider = deps.createProvider(forgeUrl.forge, deps.runner);
|
|
123
|
+
let baseBranch;
|
|
124
|
+
let existingClone;
|
|
125
|
+
try {
|
|
126
|
+
baseBranch = await provider.fetchBaseBranch(forgeUrl);
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
if (!(error instanceof ForgeCliUnavailableError))
|
|
130
|
+
throw error;
|
|
131
|
+
console.error(`[fetch-comments] ${error.message}`);
|
|
132
|
+
console.error(`[fetch-comments] ${error.cli} unavailable for the base-branch lookup — ` +
|
|
133
|
+
'falling back to the remote default branch via git ls-remote.');
|
|
134
|
+
existingClone = await deps.detectExistingClone(forgeUrl, cwd, deps.runner);
|
|
135
|
+
baseBranch = await deps.resolveRemoteDefaultBranch(forgeUrl, deps.runner, existingClone);
|
|
136
|
+
}
|
|
137
|
+
console.error(`[fetch-comments] Base branch: ${baseBranch}`);
|
|
138
|
+
const materialized = await deps.materialize(forgeUrl, baseBranch, cwd, deps.runner, existingClone);
|
|
139
|
+
try {
|
|
140
|
+
let threads;
|
|
141
|
+
try {
|
|
142
|
+
threads = await provider.fetchThreads(forgeUrl, {
|
|
143
|
+
includeResolved: options.includeResolved ?? false,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
if (error instanceof ForgeCliUnavailableError) {
|
|
148
|
+
// Fetching comments is this subcommand's entire purpose: no
|
|
149
|
+
// degradation, fail with a clear error.
|
|
150
|
+
throw new Error(`Cannot fetch discussion threads: ${error.message}\n` +
|
|
151
|
+
`fetch-comments requires the ${error.cli} CLI to be installed ` +
|
|
152
|
+
'and authenticated.');
|
|
153
|
+
}
|
|
154
|
+
throw error;
|
|
155
|
+
}
|
|
156
|
+
console.error(`[fetch-comments] Fetched ${threads.length} threads`);
|
|
157
|
+
const diffFiles = await deps.loadDiffFiles(materialized.repoPath, materialized.baseSha, materialized.headSha);
|
|
158
|
+
// The diff is what anchors a `suggestion` fence: without it the mapper
|
|
159
|
+
// cannot read the original code a fence proposes to replace.
|
|
160
|
+
const comments = mapThreadsToReviewComments(threads, diffFiles);
|
|
161
|
+
const state = buildRemoteReviewState({
|
|
162
|
+
remoteUrl: url,
|
|
163
|
+
forge: forgeUrl.forge,
|
|
164
|
+
baseSha: materialized.baseSha,
|
|
165
|
+
headSha: materialized.headSha,
|
|
166
|
+
diffFiles,
|
|
167
|
+
comments,
|
|
168
|
+
timestamp: deps.now().toISOString(),
|
|
169
|
+
});
|
|
170
|
+
const config = deps.loadConfig();
|
|
171
|
+
const outputPath = resolve(cwd, config.outputFile);
|
|
172
|
+
const xml = await deps.serialize(state, outputPath);
|
|
173
|
+
deps.writeFile(outputPath, xml + '\n');
|
|
174
|
+
console.error(`[fetch-comments] ${comments.length} threads written to ${outputPath}`);
|
|
175
|
+
}
|
|
176
|
+
finally {
|
|
177
|
+
materialized.cleanup();
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=fetch-comments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":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