diffing 0.6.2 → 0.7.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 (186) hide show
  1. package/README.md +134 -100
  2. package/dist/apply-suggestion-BAuyCYk6.mjs +54 -0
  3. package/dist/cli-agent-BlMtx1Tx.mjs +736 -0
  4. package/dist/cli-agent-C4Fb90GL.mjs +728 -0
  5. package/dist/cli-agent-ChALuNbw.mjs +841 -0
  6. package/dist/cli-agent-D71pq2ep.mjs +841 -0
  7. package/dist/cli-agent-qBT8clNM.mjs +841 -0
  8. package/dist/cli-gh-6qiblgj7.mjs +150 -0
  9. package/dist/cli-gh-D5OCnjNe.mjs +150 -0
  10. package/dist/cli-gh-KjPnyST6.mjs +150 -0
  11. package/dist/cli.mjs +38 -66
  12. package/dist/client/assets/{angular-html-Dg8frIKA.js → angular-html-Dh86jUvr.js} +1 -1
  13. package/dist/client/assets/{angular-ts-BgXWv16g.js → angular-ts-Bh4wRJtT.js} +1 -1
  14. package/dist/client/assets/{apl-uFl-_xI6.js → apl-BSXBHduT.js} +1 -1
  15. package/dist/client/assets/{arc-2DyFlUoQ.js → arc-CRQlhBrV.js} +1 -1
  16. package/dist/client/assets/{architectureDiagram-3BPJPVTR-Cpo5XnQh.js → architectureDiagram-3BPJPVTR-BXq3UvEv.js} +1 -1
  17. package/dist/client/assets/{astro-CsSgohj_.js → astro-Bh00klUw.js} +1 -1
  18. package/dist/client/assets/{blade-tmMbmea0.js → blade-CisA3zhm.js} +1 -1
  19. package/dist/client/assets/{blockDiagram-GPEHLZMM-C2j4VeON.js → blockDiagram-GPEHLZMM-Bw-PTAJr.js} +1 -1
  20. package/dist/client/assets/{c-CYFchk-Y.js → c-D-pHVWrf.js} +1 -1
  21. package/dist/client/assets/{c4Diagram-AAUBKEIU-B9Iu60rg.js → c4Diagram-AAUBKEIU-C0XyiqC_.js} +1 -1
  22. package/dist/client/assets/channel-CDxgOu-3.js +1 -0
  23. package/dist/client/assets/{chunk-2J33WTMH-CYF5wgmI.js → chunk-2J33WTMH-DekjZXNj.js} +1 -1
  24. package/dist/client/assets/{chunk-3OPIFGDE-BsCKEfSk.js → chunk-3OPIFGDE-BtROpcL8.js} +1 -1
  25. package/dist/client/assets/{chunk-4BX2VUAB-CKaohpWW.js → chunk-4BX2VUAB-C92XLTlx.js} +1 -1
  26. package/dist/client/assets/{chunk-55IACEB6-CPg0c8fY.js → chunk-55IACEB6-CceUgh8N.js} +1 -1
  27. package/dist/client/assets/{chunk-5ZQYHXKU-qstslfP1.js → chunk-5ZQYHXKU-DSbYPAe7.js} +1 -1
  28. package/dist/client/assets/{chunk-727SXJPM-C1WRwOi2.js → chunk-727SXJPM-DVzUJa-9.js} +1 -1
  29. package/dist/client/assets/{chunk-AQP2D5EJ-_jbfFh_H.js → chunk-AQP2D5EJ-6n3Z_IFa.js} +1 -1
  30. package/dist/client/assets/{chunk-BSJP7CBP-CjQkUxwj.js → chunk-BSJP7CBP-BgVLnkxr.js} +1 -1
  31. package/dist/client/assets/{chunk-CSCIHK7Q-D4khYgW5.js → chunk-CSCIHK7Q-CkGMXntp.js} +1 -1
  32. package/dist/client/assets/{chunk-FMBD7UC4-B1r9As4X.js → chunk-FMBD7UC4-BM8lrLBo.js} +1 -1
  33. package/dist/client/assets/{chunk-KSCS5N6A-XehlazPT.js → chunk-KSCS5N6A-Bm2pjMQg.js} +1 -1
  34. package/dist/client/assets/{chunk-L5ZTLDWV-5KMCRmgT.js → chunk-L5ZTLDWV-VL17ikXM.js} +1 -1
  35. package/dist/client/assets/{chunk-LZXEDZCA--x7aE-36.js → chunk-LZXEDZCA-B629g67M.js} +2 -2
  36. package/dist/client/assets/{chunk-ND2GUHAM-BcUeNQF6.js → chunk-ND2GUHAM-CjZGwhKA.js} +1 -1
  37. package/dist/client/assets/{chunk-NZK2D7GU-HdA4zA81.js → chunk-NZK2D7GU-DGsLjESY.js} +1 -1
  38. package/dist/client/assets/{chunk-O5CBEL6O-BbkpkgBW.js → chunk-O5CBEL6O-EyUrGY3l.js} +1 -1
  39. package/dist/client/assets/chunk-QZHKN3VN-DJCeMpP8.js +1 -0
  40. package/dist/client/assets/chunk-WU5MYG2G-BbuOkMaH.js +1 -0
  41. package/dist/client/assets/{chunk-XPW4576I-BrjJtb92.js → chunk-XPW4576I-C2TeAQmQ.js} +1 -1
  42. package/dist/client/assets/classDiagram-4FO5ZUOK-D5oJbiED.js +1 -0
  43. package/dist/client/assets/classDiagram-v2-Q7XG4LA2-5MJt5ZxQ.js +1 -0
  44. package/dist/client/assets/{cobol-CbEdzJpe.js → cobol-DsRZMP16.js} +1 -1
  45. package/dist/client/assets/{coffee-BYBPPvKf.js → coffee-DP0-MMsE.js} +1 -1
  46. package/dist/client/assets/{cose-bilkent-S5V4N54A-C2UlmvWG.js → cose-bilkent-S5V4N54A-DMmK0b0W.js} +1 -1
  47. package/dist/client/assets/{cpp-Cy1Wnp8d.js → cpp-B6XYbbze.js} +1 -1
  48. package/dist/client/assets/{crystal-Bg1sUJya.js → crystal-dBLPFLMp.js} +1 -1
  49. package/dist/client/assets/{css-C6iyzRBi.js → css-tgwuSZL0.js} +1 -1
  50. package/dist/client/assets/{dagre-BM42HDAG-CLP5IYO3.js → dagre-BM42HDAG-CgNkf0TR.js} +1 -1
  51. package/dist/client/assets/{diagram-2AECGRRQ-Dg8GXMUD.js → diagram-2AECGRRQ-ocAqn0LV.js} +1 -1
  52. package/dist/client/assets/{diagram-5GNKFQAL-D5eskvC7.js → diagram-5GNKFQAL-CB1Yo4Gc.js} +1 -1
  53. package/dist/client/assets/{diagram-KO2AKTUF-SO-9Apcj.js → diagram-KO2AKTUF-B2vpMBRT.js} +1 -1
  54. package/dist/client/assets/{diagram-LMA3HP47-Dz15-yRy.js → diagram-LMA3HP47-DuxZOaQS.js} +1 -1
  55. package/dist/client/assets/{diagram-OG6HWLK6-BuQK0W1m.js → diagram-OG6HWLK6-CkShDmcv.js} +1 -1
  56. package/dist/client/assets/{dist-CZ555WMx.js → dist-BgZIvk5w.js} +1 -1
  57. package/dist/client/assets/{edge-CmOR4HCT.js → edge-Bokubn8E.js} +1 -1
  58. package/dist/client/assets/{elixir-CK9qhOZG.js → elixir-BEzcf3Xg.js} +1 -1
  59. package/dist/client/assets/{elm-DZWlTp8-.js → elm-vJyLTAER.js} +1 -1
  60. package/dist/client/assets/{erDiagram-TEJ5UH35-D7vADGZy.js → erDiagram-TEJ5UH35-BFV1NQAH.js} +1 -1
  61. package/dist/client/assets/{erb-CTTGdXJ0.js → erb-DDkAmjBS.js} +1 -1
  62. package/dist/client/assets/{flowDiagram-I6XJVG4X-BwcgAtP3.js → flowDiagram-I6XJVG4X-DU8xbFdO.js} +1 -1
  63. package/dist/client/assets/{ganttDiagram-6RSMTGT7-kInginE9.js → ganttDiagram-6RSMTGT7-DCb7Qh0c.js} +1 -1
  64. package/dist/client/assets/{git-rebase-B_sSbVaY.js → git-rebase-DWcifAdK.js} +1 -1
  65. package/dist/client/assets/{gitGraphDiagram-PVQCEYII-C4pDDMLO.js → gitGraphDiagram-PVQCEYII-C_Tw-piE.js} +1 -1
  66. package/dist/client/assets/{glimmer-js-BaLXlo90.js → glimmer-js--HDru5ys.js} +1 -1
  67. package/dist/client/assets/{glimmer-ts-ugNWY62Y.js → glimmer-ts-DAdXisHh.js} +1 -1
  68. package/dist/client/assets/{glsl-CDofiyvf.js → glsl-CmIRlJht.js} +1 -1
  69. package/dist/client/assets/{graphql-lRTsx6gb.js → graphql-tx4-7I3U.js} +1 -1
  70. package/dist/client/assets/{hack-DG646xxf.js → hack-yA0XjhF7.js} +1 -1
  71. package/dist/client/assets/{haml-CjNyEqTY.js → haml-BR5MUE1b.js} +1 -1
  72. package/dist/client/assets/{handlebars-DmTlsycc.js → handlebars-BPOF7iOf.js} +1 -1
  73. package/dist/client/assets/{html-CYKa0iGt.js → html-BbteRk96.js} +1 -1
  74. package/dist/client/assets/{html-derivative-CJrmldEy.js → html-derivative-59NNrcMm.js} +1 -1
  75. package/dist/client/assets/{http-Dv_sB6KO.js → http-D3odGQI4.js} +1 -1
  76. package/dist/client/assets/{hurl-aIa6gC3s.js → hurl-BLTj8fPj.js} +1 -1
  77. package/dist/client/assets/index-BZcKS8Sb.css +1 -0
  78. package/dist/client/assets/{index-DLwFuHoH.js → index-DHXpO7eS.js} +136 -98
  79. package/dist/client/assets/{infoDiagram-5YYISTIA-DE1yaqeG.js → infoDiagram-5YYISTIA-CI6hJyRl.js} +1 -1
  80. package/dist/client/assets/{ishikawaDiagram-YF4QCWOH-D61KC690.js → ishikawaDiagram-YF4QCWOH-gMS1P1LQ.js} +1 -1
  81. package/dist/client/assets/{java--GCJC5Ht.js → java-CsViuzs_.js} +1 -1
  82. package/dist/client/assets/{javascript-CLU-vrsL.js → javascript-DQgsl2Dh.js} +1 -1
  83. package/dist/client/assets/{jinja-DpKxO4hN.js → jinja-DQNp2NUA.js} +1 -1
  84. package/dist/client/assets/{jison-DAzEKgwk.js → jison-CDDOZQdc.js} +1 -1
  85. package/dist/client/assets/{journeyDiagram-JHISSGLW-Bt37oidm.js → journeyDiagram-JHISSGLW-BTQ_Ws_h.js} +1 -1
  86. package/dist/client/assets/{json-CoxC1kMn.js → json-DP4TqCuE.js} +1 -1
  87. package/dist/client/assets/{jsx-Bjv8cqXv.js → jsx-Df5hn0Tf.js} +1 -1
  88. package/dist/client/assets/{julia-2HI5Piu6.js → julia--u33yGLi.js} +1 -1
  89. package/dist/client/assets/{just-AUrPjdB4.js → just-BCpMmSOD.js} +1 -1
  90. package/dist/client/assets/{kanban-definition-UN3LZRKU-D46QdRYJ.js → kanban-definition-UN3LZRKU-CvqGbLR_.js} +1 -1
  91. package/dist/client/assets/{latex-DjzDlfkY.js → latex-D8D4jZGw.js} +1 -1
  92. package/dist/client/assets/{line-D_rKDTVX.js → line-DBgaS_RW.js} +1 -1
  93. package/dist/client/assets/{linear-DCm3ZWOL.js → linear-RQVzKNVU.js} +1 -1
  94. package/dist/client/assets/{liquid-DZ8JEV93.js → liquid-CkH85f12.js} +1 -1
  95. package/dist/client/assets/{lua-iKYCK6sd.js → lua-iKoV7WE3.js} +1 -1
  96. package/dist/client/assets/{marko-CrhrBZpj.js → marko-N8ScQSqT.js} +1 -1
  97. package/dist/client/assets/{mdc-M6YkRqT_.js → mdc-BvHTOxsp.js} +1 -1
  98. package/dist/client/assets/{mermaid-parser.core-DOlZkAUl.js → mermaid-parser.core-CwDRwMR7.js} +1 -1
  99. package/dist/client/assets/{mermaid.core-B5kraaYr.js → mermaid.core-D2LDJgXO.js} +3 -3
  100. package/dist/client/assets/{mindmap-definition-RKZ34NQL-CG-S_0Tm.js → mindmap-definition-RKZ34NQL-FRnPh642.js} +1 -1
  101. package/dist/client/assets/{nginx-DGSv66H3.js → nginx-DGgvASuI.js} +1 -1
  102. package/dist/client/assets/{nim-wTb9iFPK.js → nim-D-v9hzvR.js} +1 -1
  103. package/dist/client/assets/{perl-BrLOtih-.js → perl-CG8leJ8K.js} +1 -1
  104. package/dist/client/assets/{php-BpG59zED.js → php-DvkeSP10.js} +1 -1
  105. package/dist/client/assets/{pieDiagram-4H26LBE5-BSsvT950.js → pieDiagram-4H26LBE5-CepOg38Y.js} +1 -1
  106. package/dist/client/assets/{pug-L7QegceF.js → pug-B4T7-xaL.js} +1 -1
  107. package/dist/client/assets/{qml-Bhe1hZ7B.js → qml-BE6D5Bxn.js} +1 -1
  108. package/dist/client/assets/{quadrantDiagram-W4KKPZXB-Bxs1ZIId.js → quadrantDiagram-W4KKPZXB-DOFAsP60.js} +1 -1
  109. package/dist/client/assets/{r-D1TBw_pw.js → r-BKZg9Mcq.js} +1 -1
  110. package/dist/client/assets/{razor-CQm1uFKr.js → razor-D-02oaxL.js} +1 -1
  111. package/dist/client/assets/{regexp--jRne08M.js → regexp-BDFvAR1k.js} +1 -1
  112. package/dist/client/assets/{requirementDiagram-4Y6WPE33-BvrwIHRn.js → requirementDiagram-4Y6WPE33-BBVNH-2W.js} +1 -1
  113. package/dist/client/assets/review-export-D5iIl46_.js +7 -0
  114. package/dist/client/assets/{rst-DojkdR69.js → rst-BcT26OSj.js} +1 -1
  115. package/dist/client/assets/{ruby-CihGsdWE.js → ruby-Cq_YQvFT.js} +1 -1
  116. package/dist/client/assets/{sankeyDiagram-5OEKKPKP-ChVx7-uL.js → sankeyDiagram-5OEKKPKP-BQfCTbBX.js} +1 -1
  117. package/dist/client/assets/{sas-De9KOrSF.js → sas-DN9oTxKY.js} +1 -1
  118. package/dist/client/assets/{scss-s1VsrZAM.js → scss-BK_sp3z2.js} +1 -1
  119. package/dist/client/assets/{sequenceDiagram-3UESZ5HK-DfGXu7Db.js → sequenceDiagram-3UESZ5HK-CKAW2eyx.js} +1 -1
  120. package/dist/client/assets/{shellscript-BQarhH5B.js → shellscript-CvNpOu0J.js} +1 -1
  121. package/dist/client/assets/{shellsession-DudKTKQ_.js → shellsession-8-yj2cJj.js} +1 -1
  122. package/dist/client/assets/{soy-CQggW1_P.js → soy-C6Q9atPF.js} +1 -1
  123. package/dist/client/assets/{sql-CyxjmxEX.js → sql-CBL3BuHb.js} +1 -1
  124. package/dist/client/assets/{src-Be3tFbq6.js → src-D-VUWIK5.js} +1 -1
  125. package/dist/client/assets/{stata-Baq2oukf.js → stata-B2Q7Vqzu.js} +1 -1
  126. package/dist/client/assets/{stateDiagram-AJRCARHV-DUsSkWi-.js → stateDiagram-AJRCARHV-BGJiv0qO.js} +1 -1
  127. package/dist/client/assets/stateDiagram-v2-BHNVJYJU-CdUgMghp.js +1 -0
  128. package/dist/client/assets/{surrealql-DY_lPQU6.js → surrealql-C-A2N8vk.js} +1 -1
  129. package/dist/client/assets/{svelte-oBaORrzD.js → svelte-VAut_-uy.js} +1 -1
  130. package/dist/client/assets/{templ-WpkyVGPg.js → templ-mUetM--K.js} +1 -1
  131. package/dist/client/assets/{tex-t_gMyObp.js → tex-BT53mWGp.js} +1 -1
  132. package/dist/client/assets/{timeline-definition-PNZ67QCA-DO30eyIk.js → timeline-definition-PNZ67QCA-lVwMt1rk.js} +1 -1
  133. package/dist/client/assets/{ts-tags-Dn6NjJLA.js → ts-tags-VkIOkgLN.js} +1 -1
  134. package/dist/client/assets/{tsx-DDWp_p5y.js → tsx-D_aaGHTf.js} +1 -1
  135. package/dist/client/assets/{twig-FBY22xUa.js → twig-CufwqKkk.js} +1 -1
  136. package/dist/client/assets/{typescript-BHZBosYe.js → typescript-osFD2CEV.js} +1 -1
  137. package/dist/client/assets/{vennDiagram-CIIHVFJN-DbE8UKE1.js → vennDiagram-CIIHVFJN-_K9NtpA5.js} +1 -1
  138. package/dist/client/assets/{vue-CrOmWBlh.js → vue-Bub1rXmL.js} +1 -1
  139. package/dist/client/assets/{vue-html-jBuGpXgg.js → vue-html-CN3x2pYg.js} +1 -1
  140. package/dist/client/assets/{vue-vine-DEzqOkvG.js → vue-vine-C0csYkGm.js} +1 -1
  141. package/dist/client/assets/{wardleyDiagram-YWT4CUSO-BqhSY5Qs.js → wardleyDiagram-YWT4CUSO-B2jTMfra.js} +1 -1
  142. package/dist/client/assets/{xml-DkWImCZV.js → xml-my6OjeGb.js} +1 -1
  143. package/dist/client/assets/{xsl-BotuNSYU.js → xsl-Bx0YVn26.js} +1 -1
  144. package/dist/client/assets/{xychartDiagram-2RQKCTM6-DA2pXGD9.js → xychartDiagram-2RQKCTM6-DfZ4YYXU.js} +1 -1
  145. package/dist/client/assets/{yaml-8lMTQUH5.js → yaml-DanwOypk.js} +1 -1
  146. package/dist/client/index.html +2 -2
  147. package/dist/comment-format-B5AcGcR-.mjs +118 -0
  148. package/dist/comment-format-CKTt0fzi.mjs +113 -0
  149. package/dist/comment-format-DG_PAehC.mjs +117 -0
  150. package/dist/completions-ZSKYvW06.mjs +126 -0
  151. package/dist/diff-fingerprint-CWa-soYD.mjs +78 -0
  152. package/dist/doctor-q6oA64hm.mjs +195 -0
  153. package/dist/find-tui-binary-CRpbYXLC.mjs +52 -0
  154. package/dist/git-Czo96ymM.mjs +789 -0
  155. package/dist/git-DaP_1rVy.mjs +2 -0
  156. package/dist/github-C9GLNak7.mjs +2 -0
  157. package/dist/github-HfIlIS-J.mjs +525 -0
  158. package/dist/mcp-7eXATtez.mjs +1334 -0
  159. package/dist/mcp-BBk8AIO4.mjs +1334 -0
  160. package/dist/mcp-BJxrW9dS.mjs +1334 -0
  161. package/dist/mcp-BhT5GgYF.mjs +1334 -0
  162. package/dist/mcp-BsGdNA88.mjs +1334 -0
  163. package/dist/mcp-Ca9QAlJ0.mjs +1334 -0
  164. package/dist/mcp-eor39qmD.mjs +1352 -0
  165. package/dist/plan-format-BQyx--mp.mjs +144 -0
  166. package/dist/plan-format-Bi46QS0m.mjs +132 -0
  167. package/dist/review-export-BoV0884M.mjs +66 -0
  168. package/dist/review-export-CKTI5Od_.mjs +66 -0
  169. package/dist/review-export-DjxKBeIZ.mjs +66 -0
  170. package/dist/server-AisDKkpW.mjs +3227 -0
  171. package/dist/server-BUsRhL1B.mjs +3283 -0
  172. package/dist/server-Bc2m9R5-.mjs +3263 -0
  173. package/dist/server-C105rwQw.mjs +3283 -0
  174. package/dist/server-D0Ni8PKP.mjs +3252 -0
  175. package/dist/server-TOElOuNP.mjs +3258 -0
  176. package/dist/server-lock-uqSdDYeR.mjs +153 -0
  177. package/dist/settings-BVnzGFL7.mjs +478 -0
  178. package/dist/update-check-fe0tR8tx.mjs +129 -0
  179. package/package.json +1 -1
  180. package/dist/client/assets/channel-Br3gV-0C.js +0 -1
  181. package/dist/client/assets/chunk-QZHKN3VN-yNyHmFLj.js +0 -1
  182. package/dist/client/assets/chunk-WU5MYG2G-DOSgjhZV.js +0 -1
  183. package/dist/client/assets/classDiagram-4FO5ZUOK-BV8x1oiD.js +0 -1
  184. package/dist/client/assets/classDiagram-v2-Q7XG4LA2-AibFxRy2.js +0 -1
  185. package/dist/client/assets/index-CkjX2qPW.css +0 -1
  186. package/dist/client/assets/stateDiagram-v2-BHNVJYJU-DczGQieS.js +0 -1
@@ -0,0 +1,144 @@
1
+ //#region src/lib/plan-format.ts
2
+ /**
3
+ * Serialize a reviewed plan into the `<plan-review>` XML envelope handed back to
4
+ * a waiting agent. The diff-review counterpart is {@link formatComments}; this
5
+ * keeps the two handoffs structurally consistent so an agent learns one shape.
6
+ *
7
+ * Shared by the server's `/api/plan-review/await` handoff, the `diffing plan`
8
+ * CLI, and the MCP server so every channel emits byte-identical output.
9
+ */
10
+ function escapeAttr(value) {
11
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
12
+ }
13
+ /** Human-readable guidance the agent should act on, derived from the verdict. */
14
+ function decisionSummary(decision) {
15
+ switch (decision) {
16
+ case "approved": return "The reviewer APPROVED this plan. Proceed with implementation exactly as described, taking any inline comments into account.";
17
+ case "rejected": return "The reviewer REJECTED this plan. Do NOT proceed. Reconsider the approach based on the comments; only continue once a new plan is approved.";
18
+ case "changes-requested": return "The reviewer REQUESTED CHANGES. Revise the plan to address every open comment below, then resubmit the updated plan for re-review (do not start implementation yet).";
19
+ case "comment-only": return "The reviewer chose COMMENT-ONLY mode. You MUST NOT edit any files or implement the plan. Only reply to the comments below — answer questions, provide clarification, or discuss. The decision comment (if present) is your prompt for this chat.";
20
+ default: return "This plan has not been decided yet. Wait for the reviewer to approve, reject, or request changes.";
21
+ }
22
+ }
23
+ /**
24
+ * Resolve the line label for a plan comment: `plan` for whole-plan notes,
25
+ * `12-15` for a multi-line selection, otherwise the single line number.
26
+ */
27
+ function lineLabel(comment) {
28
+ if (comment.lineNumber === 0) return "plan";
29
+ if (comment.startLineNumber && comment.startLineNumber !== comment.lineNumber) return `${comment.startLineNumber}-${comment.lineNumber}`;
30
+ return `${comment.lineNumber}`;
31
+ }
32
+ function formatPlanReview(plan, options = {}) {
33
+ const { viewingVersion, mode } = options;
34
+ const isHistorical = viewingVersion !== void 0 && viewingVersion !== plan.version;
35
+ const versions = plan.versions ?? [];
36
+ const historical = isHistorical && versions.length > 0 ? versions.find((v) => v.version === viewingVersion) : void 0;
37
+ const bodyToRender = historical ? historical.body : plan.body;
38
+ const titleToRender = historical ? historical.title : plan.title;
39
+ const visibleComments = isHistorical ? (plan.comments ?? []).filter((c) => c.createdAtPlanVersion === viewingVersion) : plan.comments ?? [];
40
+ const modeAttr = mode && mode !== "standard" ? ` mode="${mode}"` : "";
41
+ const lines = [];
42
+ lines.push("<plan-review>");
43
+ lines.push(" <instructions>");
44
+ lines.push(" You are an AI coding assistant receiving a human review of a plan you submitted.");
45
+ if (mode === "comment-only") lines.push(" ⚠️ COMMENT-ONLY MODE: You MUST NOT edit any files or implement the plan. Your only task is to reply to the comments below — answer questions, provide clarification, or discuss. The decision comment (if present) is your prompt for this chat.");
46
+ else {
47
+ lines.push(" - The \"decision\" attribute is the headline verdict: \"approved\", \"rejected\", \"changes-requested\", \"comment-only\", or \"pending\".");
48
+ lines.push(" - <decision-summary> tells you, in plain language, what to do next based on that verdict.");
49
+ lines.push(" - <decision-comment> is the reviewer's overall note (may be absent).");
50
+ lines.push(" - <plan-body> is the exact markdown of the plan being reviewed. Inline comments target lines within it.");
51
+ lines.push(" - Each <comment> targets a line (\"line=42\"), a range (\"line=12-15\"), or the whole plan (\"line=plan\").");
52
+ lines.push(" \"section\" names the nearest markdown heading for context. Only address comments with status=\"open\".");
53
+ lines.push(" - <context> is structured: <quote> is the exact text the human highlighted (when present);");
54
+ lines.push(" <source line=\"N\" end-line=\"M\"> is the full plan source line(s). Prefer <quote> when deciding what they meant.");
55
+ lines.push(" - Optional severity=\"blocking|nit|question|praise\" on <comment>: treat blocking as must-fix,");
56
+ lines.push(" nit as optional polish, question as needing an answer, praise as positive note (no action required).");
57
+ lines.push("");
58
+ lines.push(" HOW TO RESPOND:");
59
+ lines.push(" - If approved: proceed with the work.");
60
+ lines.push(" - If changes-requested: revise the plan and resubmit it for another review round.");
61
+ lines.push(" - If rejected: stop and rethink; do not implement.");
62
+ lines.push(" - If comment-only: do NOT implement; only reply to comments.");
63
+ lines.push(" Prefer the diffing CLI or MCP (port-agnostic, no copy-paste):");
64
+ lines.push(" diffing plan reply <comment-id> --body \"...\" --model \"<your-model-name>\"");
65
+ lines.push(" diffing plan resolve <comment-id>");
66
+ lines.push(" diffing plan submit <revised-plan.md> --id <plan-id> # resubmit a new version for re-review");
67
+ lines.push(" (Or the equivalent MCP tools: reply_to_plan_comment, resolve_plan_comment, submit_plan.)");
68
+ }
69
+ lines.push(" </instructions>");
70
+ const decidedAttr = plan.decidedAt ? ` decided-at="${new Date(plan.decidedAt).toISOString()}"` : "";
71
+ const viewingAttr = isHistorical ? ` viewing-version="${viewingVersion}"` : "";
72
+ lines.push(` <plan id="${escapeAttr(plan.id)}" title="${escapeAttr(titleToRender)}" version="${plan.version}" decision="${plan.decision}"${decidedAttr}${viewingAttr}${modeAttr}>`);
73
+ lines.push(` <decision-summary><![CDATA[${decisionSummary(plan.decision)}]]></decision-summary>`);
74
+ const trimmedDecisionComment = plan.decisionComment?.trim();
75
+ if (trimmedDecisionComment) lines.push(` <decision-comment><![CDATA[${trimmedDecisionComment}]]></decision-comment>`);
76
+ if (isHistorical) lines.push(` <viewing-version-info><![CDATA[Reviewing historical version ${viewingVersion} of ${plan.version}. Comments are filtered to those anchored to v${viewingVersion}.]]></viewing-version-info>`);
77
+ lines.push(` <plan-body><![CDATA[${bodyToRender}]]></plan-body>`);
78
+ if (visibleComments.length > 0) {
79
+ lines.push(" <comments>");
80
+ for (const comment of visibleComments) {
81
+ const sectionAttr = comment.sectionTitle ? ` section="${escapeAttr(comment.sectionTitle)}"` : "";
82
+ const isoDate = new Date(comment.createdAt).toISOString();
83
+ const versionAttr = ` plan-version="${comment.createdAtPlanVersion ?? plan.version}"`;
84
+ const severityAttr = comment.severity && comment.severity !== "none" ? ` severity="${comment.severity}"` : "";
85
+ lines.push(` <comment id="${escapeAttr(comment.id)}" line="${lineLabel(comment)}"${sectionAttr} status="${comment.status}"${severityAttr} created-at="${isoDate}"${versionAttr}>`);
86
+ if (comment.lineNumber !== 0 && (comment.lineContent || comment.selectedQuote)) {
87
+ const start = comment.startLineNumber && comment.startLineNumber !== comment.lineNumber ? comment.startLineNumber : comment.lineNumber;
88
+ const end = comment.lineNumber;
89
+ const endAttr = end !== start ? ` end-line="${end}"` : "";
90
+ lines.push(` <context line="${start}"${endAttr}>`);
91
+ if (comment.selectedQuote?.trim()) lines.push(` <quote><![CDATA[${comment.selectedQuote.trim()}]]></quote>`);
92
+ if (comment.lineContent) lines.push(` <source line="${start}"${endAttr}><![CDATA[${comment.lineContent}]]></source>`);
93
+ lines.push(" </context>");
94
+ }
95
+ lines.push(` <body><![CDATA[${comment.body}]]></body>`);
96
+ if (comment.replies && comment.replies.length > 0) {
97
+ lines.push(" <replies>");
98
+ for (const reply of comment.replies) {
99
+ const replyIsoDate = new Date(reply.createdAt).toISOString();
100
+ const roleAttr = reply.role ? ` role="${reply.role}"` : " role=\"agent\"";
101
+ const modelAttr = reply.model ? ` model="${escapeAttr(reply.model)}"` : "";
102
+ lines.push(` <reply id="${escapeAttr(reply.id)}" created-at="${replyIsoDate}"${roleAttr}${modelAttr}>`);
103
+ lines.push(` <![CDATA[${reply.body}]]>`);
104
+ lines.push(" </reply>");
105
+ }
106
+ lines.push(" </replies>");
107
+ }
108
+ lines.push(" </comment>");
109
+ }
110
+ lines.push(" </comments>");
111
+ }
112
+ lines.push(" </plan>");
113
+ lines.push("</plan-review>");
114
+ return lines.join("\n");
115
+ }
116
+ /**
117
+ * Find the nearest markdown ATX heading at or above a 1-based line, so a comment
118
+ * can record which section of the plan it belongs to. Returns the heading text
119
+ * without the leading `#`s, or undefined when the line precedes any heading.
120
+ */
121
+ function sectionTitleForLine(body, lineNumber) {
122
+ if (lineNumber < 1) return void 0;
123
+ const lines = body.split("\n");
124
+ const end = Math.min(lineNumber, lines.length);
125
+ for (let i = end - 1; i >= 0; i--) {
126
+ const match = /^\s{0,3}(#{1,6})\s+(.*?)\s*#*\s*$/.exec(lines[i]);
127
+ if (match) return match[2].trim();
128
+ }
129
+ }
130
+ /**
131
+ * Snapshot the plan text spanned by a 1-based, inclusive [start, end] line
132
+ * range, used as the `lineContent` anchor when a comment is created without one
133
+ * (e.g. posted by an agent over the API).
134
+ */
135
+ function extractPlanLines(body, startLine, endLine) {
136
+ if (startLine < 1) return "";
137
+ const lines = body.split("\n");
138
+ const from = Math.max(1, startLine);
139
+ const to = Math.min(endLine, lines.length);
140
+ if (to < from) return "";
141
+ return lines.slice(from - 1, to).join("\n");
142
+ }
143
+ //#endregion
144
+ export { formatPlanReview as n, sectionTitleForLine as r, extractPlanLines as t };
@@ -0,0 +1,132 @@
1
+ //#region src/lib/plan-format.ts
2
+ /**
3
+ * Serialize a reviewed plan into the `<plan-review>` XML envelope handed back to
4
+ * a waiting agent. The diff-review counterpart is {@link formatComments}; this
5
+ * keeps the two handoffs structurally consistent so an agent learns one shape.
6
+ *
7
+ * Shared by the server's `/api/plan-review/await` handoff, the `diffing plan`
8
+ * CLI, and the MCP server so every channel emits byte-identical output.
9
+ */
10
+ function escapeAttr(value) {
11
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
12
+ }
13
+ /** Human-readable guidance the agent should act on, derived from the verdict. */
14
+ function decisionSummary(decision) {
15
+ switch (decision) {
16
+ case "approved": return "The reviewer APPROVED this plan. Proceed with implementation exactly as described, taking any inline comments into account.";
17
+ case "rejected": return "The reviewer REJECTED this plan. Do NOT proceed. Reconsider the approach based on the comments; only continue once a new plan is approved.";
18
+ case "changes-requested": return "The reviewer REQUESTED CHANGES. Revise the plan to address every open comment below, then resubmit the updated plan for re-review (do not start implementation yet).";
19
+ case "comment-only": return "The reviewer chose COMMENT-ONLY mode. You MUST NOT edit any files or implement the plan. Only reply to the comments below — answer questions, provide clarification, or discuss. The decision comment (if present) is your prompt for this chat.";
20
+ default: return "This plan has not been decided yet. Wait for the reviewer to approve, reject, or request changes.";
21
+ }
22
+ }
23
+ /**
24
+ * Resolve the line label for a plan comment: `plan` for whole-plan notes,
25
+ * `12-15` for a multi-line selection, otherwise the single line number.
26
+ */
27
+ function lineLabel(comment) {
28
+ if (comment.lineNumber === 0) return "plan";
29
+ if (comment.startLineNumber && comment.startLineNumber !== comment.lineNumber) return `${comment.startLineNumber}-${comment.lineNumber}`;
30
+ return `${comment.lineNumber}`;
31
+ }
32
+ function formatPlanReview(plan, options = {}) {
33
+ const { viewingVersion, mode } = options;
34
+ const isHistorical = viewingVersion !== void 0 && viewingVersion !== plan.version;
35
+ const versions = plan.versions ?? [];
36
+ const historical = isHistorical && versions.length > 0 ? versions.find((v) => v.version === viewingVersion) : void 0;
37
+ const bodyToRender = historical ? historical.body : plan.body;
38
+ const titleToRender = historical ? historical.title : plan.title;
39
+ const visibleComments = isHistorical ? (plan.comments ?? []).filter((c) => c.createdAtPlanVersion === viewingVersion) : plan.comments ?? [];
40
+ const modeAttr = mode && mode !== "standard" ? ` mode="${mode}"` : "";
41
+ const lines = [];
42
+ lines.push("<plan-review>");
43
+ lines.push(" <instructions>");
44
+ lines.push(" You are an AI coding assistant receiving a human review of a plan you submitted.");
45
+ if (mode === "comment-only") lines.push(" ⚠️ COMMENT-ONLY MODE: You MUST NOT edit any files or implement the plan. Your only task is to reply to the comments below — answer questions, provide clarification, or discuss. The decision comment (if present) is your prompt for this chat.");
46
+ else {
47
+ lines.push(" - The \"decision\" attribute is the headline verdict: \"approved\", \"rejected\", \"changes-requested\", \"comment-only\", or \"pending\".");
48
+ lines.push(" - <decision-summary> tells you, in plain language, what to do next based on that verdict.");
49
+ lines.push(" - <decision-comment> is the reviewer's overall note (may be absent).");
50
+ lines.push(" - <plan-body> is the exact markdown of the plan being reviewed. Inline comments target lines within it.");
51
+ lines.push(" - Each <comment> targets a line (\"line=42\"), a range (\"line=12-15\"), or the whole plan (\"line=plan\").");
52
+ lines.push(" \"section\" names the nearest markdown heading for context. Only address comments with status=\"open\".");
53
+ lines.push(" - <context> contains the exact plan text the comment is anchored to.");
54
+ lines.push("");
55
+ lines.push(" HOW TO RESPOND:");
56
+ lines.push(" - If approved: proceed with the work.");
57
+ lines.push(" - If changes-requested: revise the plan and resubmit it for another review round.");
58
+ lines.push(" - If rejected: stop and rethink; do not implement.");
59
+ lines.push(" - If comment-only: do NOT implement; only reply to comments.");
60
+ lines.push(" Prefer the diffing CLI or MCP (port-agnostic, no copy-paste):");
61
+ lines.push(" diffing plan reply <comment-id> --body \"...\" --model \"<your-model-name>\"");
62
+ lines.push(" diffing plan resolve <comment-id>");
63
+ lines.push(" diffing plan submit <revised-plan.md> --id <plan-id> # resubmit a new version for re-review");
64
+ lines.push(" (Or the equivalent MCP tools: reply_to_plan_comment, resolve_plan_comment, submit_plan.)");
65
+ }
66
+ lines.push(" </instructions>");
67
+ const decidedAttr = plan.decidedAt ? ` decided-at="${new Date(plan.decidedAt).toISOString()}"` : "";
68
+ const viewingAttr = isHistorical ? ` viewing-version="${viewingVersion}"` : "";
69
+ lines.push(` <plan id="${escapeAttr(plan.id)}" title="${escapeAttr(titleToRender)}" version="${plan.version}" decision="${plan.decision}"${decidedAttr}${viewingAttr}${modeAttr}>`);
70
+ lines.push(` <decision-summary><![CDATA[${decisionSummary(plan.decision)}]]></decision-summary>`);
71
+ const trimmedDecisionComment = plan.decisionComment?.trim();
72
+ if (trimmedDecisionComment) lines.push(` <decision-comment><![CDATA[${trimmedDecisionComment}]]></decision-comment>`);
73
+ if (isHistorical) lines.push(` <viewing-version-info><![CDATA[Reviewing historical version ${viewingVersion} of ${plan.version}. Comments are filtered to those anchored to v${viewingVersion}.]]></viewing-version-info>`);
74
+ lines.push(` <plan-body><![CDATA[${bodyToRender}]]></plan-body>`);
75
+ if (visibleComments.length > 0) {
76
+ lines.push(" <comments>");
77
+ for (const comment of visibleComments) {
78
+ const sectionAttr = comment.sectionTitle ? ` section="${escapeAttr(comment.sectionTitle)}"` : "";
79
+ const isoDate = new Date(comment.createdAt).toISOString();
80
+ const versionAttr = ` plan-version="${comment.createdAtPlanVersion ?? plan.version}"`;
81
+ lines.push(` <comment id="${escapeAttr(comment.id)}" line="${lineLabel(comment)}"${sectionAttr} status="${comment.status}" created-at="${isoDate}"${versionAttr}>`);
82
+ if (comment.lineNumber !== 0 && comment.lineContent) lines.push(` <context><![CDATA[${comment.lineContent}]]></context>`);
83
+ lines.push(` <body><![CDATA[${comment.body}]]></body>`);
84
+ if (comment.replies && comment.replies.length > 0) {
85
+ lines.push(" <replies>");
86
+ for (const reply of comment.replies) {
87
+ const replyIsoDate = new Date(reply.createdAt).toISOString();
88
+ const roleAttr = reply.role ? ` role="${reply.role}"` : " role=\"agent\"";
89
+ const modelAttr = reply.model ? ` model="${escapeAttr(reply.model)}"` : "";
90
+ lines.push(` <reply id="${escapeAttr(reply.id)}" created-at="${replyIsoDate}"${roleAttr}${modelAttr}>`);
91
+ lines.push(` <![CDATA[${reply.body}]]>`);
92
+ lines.push(" </reply>");
93
+ }
94
+ lines.push(" </replies>");
95
+ }
96
+ lines.push(" </comment>");
97
+ }
98
+ lines.push(" </comments>");
99
+ }
100
+ lines.push(" </plan>");
101
+ lines.push("</plan-review>");
102
+ return lines.join("\n");
103
+ }
104
+ /**
105
+ * Find the nearest markdown ATX heading at or above a 1-based line, so a comment
106
+ * can record which section of the plan it belongs to. Returns the heading text
107
+ * without the leading `#`s, or undefined when the line precedes any heading.
108
+ */
109
+ function sectionTitleForLine(body, lineNumber) {
110
+ if (lineNumber < 1) return void 0;
111
+ const lines = body.split("\n");
112
+ const end = Math.min(lineNumber, lines.length);
113
+ for (let i = end - 1; i >= 0; i--) {
114
+ const match = /^\s{0,3}(#{1,6})\s+(.*?)\s*#*\s*$/.exec(lines[i]);
115
+ if (match) return match[2].trim();
116
+ }
117
+ }
118
+ /**
119
+ * Snapshot the plan text spanned by a 1-based, inclusive [start, end] line
120
+ * range, used as the `lineContent` anchor when a comment is created without one
121
+ * (e.g. posted by an agent over the API).
122
+ */
123
+ function extractPlanLines(body, startLine, endLine) {
124
+ if (startLine < 1) return "";
125
+ const lines = body.split("\n");
126
+ const from = Math.max(1, startLine);
127
+ const to = Math.min(endLine, lines.length);
128
+ if (to < from) return "";
129
+ return lines.slice(from - 1, to).join("\n");
130
+ }
131
+ //#endregion
132
+ export { formatPlanReview as n, sectionTitleForLine as r, extractPlanLines as t };
@@ -0,0 +1,66 @@
1
+ import { n as reviewDecisionSummary } from "./comment-format-DG_PAehC.mjs";
2
+ //#region src/lib/review-export.ts
3
+ /**
4
+ * Export a review as human-readable Markdown (clipboard / download / CLI).
5
+ * Mirrors the structure of {@link formatComments} (grouped by file) but as MD.
6
+ */
7
+ function formatCommentsMarkdown(comments, generalComment, decision, mode) {
8
+ const trimmedGeneral = generalComment?.trim();
9
+ if (comments.length === 0 && !decision && !trimmedGeneral) return "";
10
+ const grouped = /* @__PURE__ */ new Map();
11
+ for (const comment of comments) {
12
+ const list = grouped.get(comment.filePath) ?? [];
13
+ list.push(comment);
14
+ grouped.set(comment.filePath, list);
15
+ }
16
+ const files = [...grouped.keys()].sort((a, b) => a.localeCompare(b));
17
+ const lines = [];
18
+ lines.push("# Code review");
19
+ lines.push("");
20
+ if (decision) {
21
+ lines.push(`**Verdict:** \`${decision}\`${mode && mode !== "standard" ? ` · mode \`${mode}\`` : ""}`);
22
+ lines.push("");
23
+ lines.push(reviewDecisionSummary(decision));
24
+ lines.push("");
25
+ }
26
+ if (trimmedGeneral) {
27
+ lines.push("## Overall note");
28
+ lines.push("");
29
+ lines.push(trimmedGeneral);
30
+ lines.push("");
31
+ }
32
+ if (files.length === 0) {
33
+ lines.push("_No inline comments._");
34
+ lines.push("");
35
+ return lines.join("\n");
36
+ }
37
+ for (const filePath of files) {
38
+ const fileComments = grouped.get(filePath);
39
+ lines.push(`## \`${filePath}\``);
40
+ lines.push("");
41
+ for (const c of fileComments) {
42
+ const line = c.lineNumber === 0 ? "file" : c.startLineNumber && c.startLineNumber !== c.lineNumber ? `L${c.startLineNumber}–${c.lineNumber}` : `L${c.lineNumber}`;
43
+ const status = c.status === "resolved" ? "resolved" : "open";
44
+ lines.push(`### ${line} · ${c.side} · ${status}`);
45
+ lines.push("");
46
+ if (c.lineNumber !== 0 && c.lineContent) {
47
+ const prefix = c.side === "additions" ? "+" : "-";
48
+ const code = c.lineContent.split("\n").map((l) => `${prefix} ${l}`).join("\n");
49
+ lines.push("```diff");
50
+ lines.push(code);
51
+ lines.push("```");
52
+ lines.push("");
53
+ }
54
+ lines.push(c.body);
55
+ lines.push("");
56
+ if (c.replies?.length) for (const r of c.replies) {
57
+ const who = r.role === "agent" ? `agent${r.model ? ` (${r.model})` : ""}` : "reviewer";
58
+ lines.push(`> **${who}:** ${r.body.replace(/\n/g, "\n> ")}`);
59
+ lines.push("");
60
+ }
61
+ }
62
+ }
63
+ return lines.join("\n").trimEnd() + "\n";
64
+ }
65
+ //#endregion
66
+ export { formatCommentsMarkdown };
@@ -0,0 +1,66 @@
1
+ import { n as reviewDecisionSummary } from "./comment-format-CKTt0fzi.mjs";
2
+ //#region src/lib/review-export.ts
3
+ /**
4
+ * Export a review as human-readable Markdown (clipboard / download / CLI).
5
+ * Mirrors the structure of {@link formatComments} (grouped by file) but as MD.
6
+ */
7
+ function formatCommentsMarkdown(comments, generalComment, decision, mode) {
8
+ const trimmedGeneral = generalComment?.trim();
9
+ if (comments.length === 0 && !decision && !trimmedGeneral) return "";
10
+ const grouped = /* @__PURE__ */ new Map();
11
+ for (const comment of comments) {
12
+ const list = grouped.get(comment.filePath) ?? [];
13
+ list.push(comment);
14
+ grouped.set(comment.filePath, list);
15
+ }
16
+ const files = [...grouped.keys()].sort((a, b) => a.localeCompare(b));
17
+ const lines = [];
18
+ lines.push("# Code review");
19
+ lines.push("");
20
+ if (decision) {
21
+ lines.push(`**Verdict:** \`${decision}\`${mode && mode !== "standard" ? ` · mode \`${mode}\`` : ""}`);
22
+ lines.push("");
23
+ lines.push(reviewDecisionSummary(decision));
24
+ lines.push("");
25
+ }
26
+ if (trimmedGeneral) {
27
+ lines.push("## Overall note");
28
+ lines.push("");
29
+ lines.push(trimmedGeneral);
30
+ lines.push("");
31
+ }
32
+ if (files.length === 0) {
33
+ lines.push("_No inline comments._");
34
+ lines.push("");
35
+ return lines.join("\n");
36
+ }
37
+ for (const filePath of files) {
38
+ const fileComments = grouped.get(filePath);
39
+ lines.push(`## \`${filePath}\``);
40
+ lines.push("");
41
+ for (const c of fileComments) {
42
+ const line = c.lineNumber === 0 ? "file" : c.startLineNumber && c.startLineNumber !== c.lineNumber ? `L${c.startLineNumber}–${c.lineNumber}` : `L${c.lineNumber}`;
43
+ const status = c.status === "resolved" ? "resolved" : "open";
44
+ lines.push(`### ${line} · ${c.side} · ${status}`);
45
+ lines.push("");
46
+ if (c.lineNumber !== 0 && c.lineContent) {
47
+ const prefix = c.side === "additions" ? "+" : "-";
48
+ const code = c.lineContent.split("\n").map((l) => `${prefix} ${l}`).join("\n");
49
+ lines.push("```diff");
50
+ lines.push(code);
51
+ lines.push("```");
52
+ lines.push("");
53
+ }
54
+ lines.push(c.body);
55
+ lines.push("");
56
+ if (c.replies?.length) for (const r of c.replies) {
57
+ const who = r.role === "agent" ? `agent${r.model ? ` (${r.model})` : ""}` : "reviewer";
58
+ lines.push(`> **${who}:** ${r.body.replace(/\n/g, "\n> ")}`);
59
+ lines.push("");
60
+ }
61
+ }
62
+ }
63
+ return lines.join("\n").trimEnd() + "\n";
64
+ }
65
+ //#endregion
66
+ export { formatCommentsMarkdown };
@@ -0,0 +1,66 @@
1
+ import { n as reviewDecisionSummary } from "./comment-format-B5AcGcR-.mjs";
2
+ //#region src/lib/review-export.ts
3
+ /**
4
+ * Export a review as human-readable Markdown (clipboard / download / CLI).
5
+ * Mirrors the structure of {@link formatComments} (grouped by file) but as MD.
6
+ */
7
+ function formatCommentsMarkdown(comments, generalComment, decision, mode) {
8
+ const trimmedGeneral = generalComment?.trim();
9
+ if (comments.length === 0 && !decision && !trimmedGeneral) return "";
10
+ const grouped = /* @__PURE__ */ new Map();
11
+ for (const comment of comments) {
12
+ const list = grouped.get(comment.filePath) ?? [];
13
+ list.push(comment);
14
+ grouped.set(comment.filePath, list);
15
+ }
16
+ const files = [...grouped.keys()].sort((a, b) => a.localeCompare(b));
17
+ const lines = [];
18
+ lines.push("# Code review");
19
+ lines.push("");
20
+ if (decision) {
21
+ lines.push(`**Verdict:** \`${decision}\`${mode && mode !== "standard" ? ` · mode \`${mode}\`` : ""}`);
22
+ lines.push("");
23
+ lines.push(reviewDecisionSummary(decision));
24
+ lines.push("");
25
+ }
26
+ if (trimmedGeneral) {
27
+ lines.push("## Overall note");
28
+ lines.push("");
29
+ lines.push(trimmedGeneral);
30
+ lines.push("");
31
+ }
32
+ if (files.length === 0) {
33
+ lines.push("_No inline comments._");
34
+ lines.push("");
35
+ return lines.join("\n");
36
+ }
37
+ for (const filePath of files) {
38
+ const fileComments = grouped.get(filePath);
39
+ lines.push(`## \`${filePath}\``);
40
+ lines.push("");
41
+ for (const c of fileComments) {
42
+ const line = c.lineNumber === 0 ? "file" : c.startLineNumber && c.startLineNumber !== c.lineNumber ? `L${c.startLineNumber}–${c.lineNumber}` : `L${c.lineNumber}`;
43
+ const status = c.status === "resolved" ? "resolved" : "open";
44
+ lines.push(`### ${line} · ${c.side} · ${status}`);
45
+ lines.push("");
46
+ if (c.lineNumber !== 0 && c.lineContent) {
47
+ const prefix = c.side === "additions" ? "+" : "-";
48
+ const code = c.lineContent.split("\n").map((l) => `${prefix} ${l}`).join("\n");
49
+ lines.push("```diff");
50
+ lines.push(code);
51
+ lines.push("```");
52
+ lines.push("");
53
+ }
54
+ lines.push(c.body);
55
+ lines.push("");
56
+ if (c.replies?.length) for (const r of c.replies) {
57
+ const who = r.role === "agent" ? `agent${r.model ? ` (${r.model})` : ""}` : "reviewer";
58
+ lines.push(`> **${who}:** ${r.body.replace(/\n/g, "\n> ")}`);
59
+ lines.push("");
60
+ }
61
+ }
62
+ }
63
+ return lines.join("\n").trimEnd() + "\n";
64
+ }
65
+ //#endregion
66
+ export { formatCommentsMarkdown };