local-diff-reviewer 2.0.3 → 2.0.4
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 +1 -1
- package/dist/cli/start.js +57 -0
- package/dist/web/assets/{arc-D-670Kn4.js → arc-C1LfqnQj.js} +1 -1
- package/dist/web/assets/{architectureDiagram-3BPJPVTR-BzwTHU5z.js → architectureDiagram-3BPJPVTR-CS0CIxyc.js} +1 -1
- package/dist/web/assets/{blockDiagram-GPEHLZMM-BdDwnuAb.js → blockDiagram-GPEHLZMM-7lcMQVcJ.js} +1 -1
- package/dist/web/assets/{c4Diagram-AAUBKEIU-CXEqG_GU.js → c4Diagram-AAUBKEIU-Dtur5jY6.js} +1 -1
- package/dist/web/assets/channel-BCzDp0xU.js +1 -0
- package/dist/web/assets/{chunk-2J33WTMH-CZ4V4veG.js → chunk-2J33WTMH-CUphoLg3.js} +1 -1
- package/dist/web/assets/{chunk-3OPIFGDE-CSbZWMMk.js → chunk-3OPIFGDE-CJlnkH7A.js} +1 -1
- package/dist/web/assets/{chunk-4BX2VUAB-DQKSnAKr.js → chunk-4BX2VUAB-C7C7iSBt.js} +1 -1
- package/dist/web/assets/{chunk-55IACEB6-D8bwvdHN.js → chunk-55IACEB6-DVT73F1u.js} +1 -1
- package/dist/web/assets/{chunk-5ZQYHXKU-DvtLcgxK.js → chunk-5ZQYHXKU-BCdAy2Av.js} +1 -1
- package/dist/web/assets/{chunk-727SXJPM-H3vpTuXt.js → chunk-727SXJPM-CEBrkXNB.js} +1 -1
- package/dist/web/assets/{chunk-AQP2D5EJ-gvn0I0el.js → chunk-AQP2D5EJ-gDFNaZ5u.js} +1 -1
- package/dist/web/assets/{chunk-BSJP7CBP-0tfc4u9P.js → chunk-BSJP7CBP-Billgaob.js} +1 -1
- package/dist/web/assets/{chunk-CSCIHK7Q-CmUNorU_.js → chunk-CSCIHK7Q-C4mJfPsd.js} +1 -1
- package/dist/web/assets/{chunk-FMBD7UC4-wQoZCxnn.js → chunk-FMBD7UC4-gXNxUaZH.js} +1 -1
- package/dist/web/assets/{chunk-KSCS5N6A-C99WFWps.js → chunk-KSCS5N6A-BKVQKRzM.js} +1 -1
- package/dist/web/assets/{chunk-L5ZTLDWV-C19pdXo3.js → chunk-L5ZTLDWV-BTFbg-fF.js} +1 -1
- package/dist/web/assets/{chunk-LZXEDZCA-DEg-msWi.js → chunk-LZXEDZCA-DHjgkf3p.js} +2 -2
- package/dist/web/assets/{chunk-ND2GUHAM-KEtB8AkU.js → chunk-ND2GUHAM-DOQ6r_hF.js} +1 -1
- package/dist/web/assets/{chunk-NZK2D7GU-DmtZJoF8.js → chunk-NZK2D7GU-BCySDXIh.js} +1 -1
- package/dist/web/assets/{chunk-O5CBEL6O-Cx3xql2c.js → chunk-O5CBEL6O-D-p8TXq4.js} +1 -1
- package/dist/web/assets/chunk-QZHKN3VN-fDyf2aIa.js +1 -0
- package/dist/web/assets/chunk-WU5MYG2G-BnCHHp_R.js +1 -0
- package/dist/web/assets/{chunk-XPW4576I-D7PZzhoh.js → chunk-XPW4576I-CXxG7FT6.js} +1 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-DoQlfcGs.js +1 -0
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-C9WXX2G5.js +1 -0
- package/dist/web/assets/{cose-bilkent-S5V4N54A-M9qjyQx9.js → cose-bilkent-S5V4N54A-y5KS6LHF.js} +1 -1
- package/dist/web/assets/{dagre-BM42HDAG-D5nWlspM.js → dagre-BM42HDAG-DWOmEcp4.js} +1 -1
- package/dist/web/assets/{diagram-2AECGRRQ-BhTAme0Q.js → diagram-2AECGRRQ-BjLV1KvM.js} +1 -1
- package/dist/web/assets/{diagram-5GNKFQAL-Dc1hSI_F.js → diagram-5GNKFQAL-CfnbR-6R.js} +1 -1
- package/dist/web/assets/{diagram-KO2AKTUF-IAnRJdmD.js → diagram-KO2AKTUF-D4JWdCCe.js} +1 -1
- package/dist/web/assets/{diagram-LMA3HP47-DHVHjnnV.js → diagram-LMA3HP47-CUFMEc1T.js} +1 -1
- package/dist/web/assets/{diagram-OG6HWLK6-C_H7osqu.js → diagram-OG6HWLK6-BHK7LBvY.js} +1 -1
- package/dist/web/assets/{dist-BG1gu1Ss.js → dist-rYMgVM7u.js} +1 -1
- package/dist/web/assets/{erDiagram-TEJ5UH35-DLllKoDy.js → erDiagram-TEJ5UH35-DuAlUiuD.js} +1 -1
- package/dist/web/assets/{flowDiagram-I6XJVG4X-D30CzWi4.js → flowDiagram-I6XJVG4X-Bw9s0pK6.js} +1 -1
- package/dist/web/assets/{ganttDiagram-6RSMTGT7-CUYze69W.js → ganttDiagram-6RSMTGT7-CxsSgKuD.js} +1 -1
- package/dist/web/assets/{gitGraphDiagram-PVQCEYII-DqnAgTPL.js → gitGraphDiagram-PVQCEYII-JhVl25Ua.js} +1 -1
- package/dist/web/assets/{index-Bj-SGY1j.js → index-Beb3YD1D.js} +34 -34
- package/dist/web/assets/index-d_43MU8e.css +1 -0
- package/dist/web/assets/{infoDiagram-5YYISTIA-DLByNsQT.js → infoDiagram-5YYISTIA-Bg3Buo_8.js} +1 -1
- package/dist/web/assets/{ishikawaDiagram-YF4QCWOH-Cfqh-ASX.js → ishikawaDiagram-YF4QCWOH-BpitbvFG.js} +1 -1
- package/dist/web/assets/{journeyDiagram-JHISSGLW--6a-6EC4.js → journeyDiagram-JHISSGLW-Dmn612rN.js} +1 -1
- package/dist/web/assets/{kanban-definition-UN3LZRKU-DqC73u-B.js → kanban-definition-UN3LZRKU-BZc--aOJ.js} +1 -1
- package/dist/web/assets/{line-DLfo_7hP.js → line-CE8FywkX.js} +1 -1
- package/dist/web/assets/{linear-DjJbe9Qt.js → linear-BZJmlPIB.js} +1 -1
- package/dist/web/assets/{mermaid-parser.core-BgcI22sk.js → mermaid-parser.core-g4eHJB5T.js} +1 -1
- package/dist/web/assets/{mermaid.core-BcjNq9LF.js → mermaid.core-sLgwusnq.js} +3 -3
- package/dist/web/assets/{mindmap-definition-RKZ34NQL-hyOI_Nvs.js → mindmap-definition-RKZ34NQL-jMIrHQbc.js} +1 -1
- package/dist/web/assets/{pieDiagram-4H26LBE5-DIRyMqsX.js → pieDiagram-4H26LBE5-BbsNErwP.js} +1 -1
- package/dist/web/assets/{quadrantDiagram-W4KKPZXB-D0Ngh6Zm.js → quadrantDiagram-W4KKPZXB-TAAf-krj.js} +1 -1
- package/dist/web/assets/{requirementDiagram-4Y6WPE33-CWgQtiKO.js → requirementDiagram-4Y6WPE33-DmtnJao4.js} +1 -1
- package/dist/web/assets/{sankeyDiagram-5OEKKPKP-BhD0ArVz.js → sankeyDiagram-5OEKKPKP-AsVbhELP.js} +1 -1
- package/dist/web/assets/{sequenceDiagram-3UESZ5HK-DfJPUW4m.js → sequenceDiagram-3UESZ5HK-Ba8D9Bb1.js} +1 -1
- package/dist/web/assets/{src-DNwcy7qQ.js → src-CGljw68o.js} +1 -1
- package/dist/web/assets/{stateDiagram-AJRCARHV-Cl55-mV_.js → stateDiagram-AJRCARHV-D0aLVTLA.js} +1 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-IBEP5b2C.js +1 -0
- package/dist/web/assets/{timeline-definition-PNZ67QCA-C09jbMhf.js → timeline-definition-PNZ67QCA-Di2VlsLx.js} +1 -1
- package/dist/web/assets/{vennDiagram-CIIHVFJN-ClTgJwJ3.js → vennDiagram-CIIHVFJN-C4c521Ry.js} +1 -1
- package/dist/web/assets/{wardleyDiagram-YWT4CUSO-BPhiawQp.js → wardleyDiagram-YWT4CUSO-CO1thfrU.js} +1 -1
- package/dist/web/assets/{xychartDiagram-2RQKCTM6-D_s4kTlT.js → xychartDiagram-2RQKCTM6-C-7j4JCA.js} +1 -1
- package/dist/web/index.html +2 -2
- package/docs/images/diff-review-ui.jpg +0 -0
- package/package.json +1 -1
- package/dist/web/assets/channel-CcPqlxfZ.js +0 -1
- package/dist/web/assets/chunk-QZHKN3VN-C4n2vK6k.js +0 -1
- package/dist/web/assets/chunk-WU5MYG2G-D7WrkCVH.js +0 -1
- package/dist/web/assets/classDiagram-4FO5ZUOK-CQky5FXy.js +0 -1
- package/dist/web/assets/classDiagram-v2-Q7XG4LA2-CkiVtIc_.js +0 -1
- package/dist/web/assets/index-BM79LMhf.css +0 -1
- package/dist/web/assets/stateDiagram-v2-BHNVJYJU-DFN-iZGL.js +0 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# diff-review
|
|
2
2
|
|
|
3
|
-

|
|
4
4
|
|
|
5
5
|
AI chat 里的本地代码审查工具。可以直接用 CLI 打开,也可以安装成 agent skill。
|
|
6
6
|
|
package/dist/cli/start.js
CHANGED
|
@@ -479,6 +479,20 @@ async function readFileForPreview(file, mode, repoRoot) {
|
|
|
479
479
|
}
|
|
480
480
|
return { content: await readFile2(join2(repoRoot, targetPath), "utf8"), deleted: false };
|
|
481
481
|
}
|
|
482
|
+
async function readDiffFileContents(file, mode, repoRoot) {
|
|
483
|
+
const [oldContent, newContent] = await Promise.all([
|
|
484
|
+
readDiffSideContent(file, mode, repoRoot, "old"),
|
|
485
|
+
readDiffSideContent(file, mode, repoRoot, "new")
|
|
486
|
+
]);
|
|
487
|
+
const oldLines = splitContentLines(oldContent);
|
|
488
|
+
const newLines = splitContentLines(newContent);
|
|
489
|
+
return {
|
|
490
|
+
oldLines,
|
|
491
|
+
newLines,
|
|
492
|
+
oldTotalLines: oldLines.length,
|
|
493
|
+
newTotalLines: newLines.length
|
|
494
|
+
};
|
|
495
|
+
}
|
|
482
496
|
function parseReviewMode(args) {
|
|
483
497
|
const filtered = args.filter(Boolean);
|
|
484
498
|
if (filtered.length === 0 || filtered[0] === "working") return { kind: "working" };
|
|
@@ -497,6 +511,31 @@ function isSafeRepoPath(repoRoot, path) {
|
|
|
497
511
|
async function gitShow(revPath, repoRoot) {
|
|
498
512
|
return execGitStdout(["show", revPath], repoRoot);
|
|
499
513
|
}
|
|
514
|
+
async function readDiffSideContent(file, mode, repoRoot, side) {
|
|
515
|
+
const path = side === "old" ? file.oldPath : file.path;
|
|
516
|
+
if (!path || path === "/dev/null") return "";
|
|
517
|
+
if (!isSafeRepoPath(repoRoot, path)) {
|
|
518
|
+
throw new Error(`Unsafe file path: ${path}`);
|
|
519
|
+
}
|
|
520
|
+
if (side === "old") {
|
|
521
|
+
if (file.status === "added") return "";
|
|
522
|
+
if (mode.kind === "staged") return gitShow(`HEAD:${path}`, repoRoot);
|
|
523
|
+
if (mode.kind === "revision") return gitShow(`${mode.base}:${path}`, repoRoot);
|
|
524
|
+
return file.status === "deleted" ? gitShow(`HEAD:${path}`, repoRoot) : readFile2(join2(repoRoot, path), "utf8");
|
|
525
|
+
}
|
|
526
|
+
if (file.status === "deleted") return "";
|
|
527
|
+
if (mode.kind === "staged") return gitShow(`:${path}`, repoRoot);
|
|
528
|
+
if (mode.kind === "revision") return gitShow(`${mode.target}:${path}`, repoRoot);
|
|
529
|
+
return readFile2(join2(repoRoot, path), "utf8");
|
|
530
|
+
}
|
|
531
|
+
function splitContentLines(content) {
|
|
532
|
+
const normalized = content.replace(/\r\n/g, "\n");
|
|
533
|
+
const lines = normalized.split("\n");
|
|
534
|
+
if (lines.length > 0 && lines.at(-1) === "") {
|
|
535
|
+
lines.pop();
|
|
536
|
+
}
|
|
537
|
+
return lines;
|
|
538
|
+
}
|
|
500
539
|
async function execGitStdout(args, cwd) {
|
|
501
540
|
const { stdout } = await execGit(args, cwd);
|
|
502
541
|
return stdout;
|
|
@@ -798,6 +837,24 @@ async function startServer(state, port = 4966) {
|
|
|
798
837
|
next(error);
|
|
799
838
|
}
|
|
800
839
|
});
|
|
840
|
+
app.get("/api/diff-file-contents", async (req, res, next) => {
|
|
841
|
+
try {
|
|
842
|
+
const filePath = String(req.query.path ?? "");
|
|
843
|
+
if (!filePath) {
|
|
844
|
+
res.status(400).json({ error: "File path is required" });
|
|
845
|
+
return;
|
|
846
|
+
}
|
|
847
|
+
const file = state.diffFiles.find((item) => item.path === filePath || item.oldPath === filePath);
|
|
848
|
+
if (!file) {
|
|
849
|
+
res.status(404).json({ error: "Diff file not found" });
|
|
850
|
+
return;
|
|
851
|
+
}
|
|
852
|
+
const contents = await readDiffFileContents(file, state.session.mode, state.session.repoRoot);
|
|
853
|
+
res.json(contents);
|
|
854
|
+
} catch (error) {
|
|
855
|
+
next(error);
|
|
856
|
+
}
|
|
857
|
+
});
|
|
801
858
|
app.get("/api/markdown-asset", (req, res) => {
|
|
802
859
|
const relativePath = String(req.query.path ?? "").trim();
|
|
803
860
|
if (!relativePath) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./path-BJQEcSo7.js";import{a as n,c as r,d as i,f as a,i as o,l as s,m as c,n as l,o as u,p as d,r as f,u as p}from"./dist-
|
|
1
|
+
import{n as e,t}from"./path-BJQEcSo7.js";import{a as n,c as r,d as i,f as a,i as o,l as s,m as c,n as l,o as u,p as d,r as f,u as p}from"./dist-rYMgVM7u.js";function m(e){return e.innerRadius}function h(e){return e.outerRadius}function g(e){return e.startAngle}function _(e){return e.endAngle}function v(e){return e&&e.padAngle}function y(e,t,n,r,i,a,o,s){var c=n-e,l=r-t,u=o-i,d=s-a,f=d*c-u*l;if(!(f*f<1e-12))return f=(u*(t-a)-d*(e-i))/f,[e+f*c,t+f*l]}function b(e,t,n,r,i,a,o){var c=e-n,l=t-r,u=(o?a:-a)/d(c*c+l*l),f=u*l,p=-u*c,m=e+f,h=t+p,g=n+f,_=r+p,v=(m+g)/2,y=(h+_)/2,b=g-m,x=_-h,S=b*b+x*x,C=i-a,w=m*_-g*h,T=(x<0?-1:1)*d(s(0,C*C*S-w*w)),E=(w*x-b*T)/S,D=(-w*b-x*T)/S,O=(w*x+b*T)/S,k=(-w*b+x*T)/S,A=E-v,j=D-y,M=O-v,N=k-y;return A*A+j*j>M*M+N*N&&(E=O,D=k),{cx:E,cy:D,x01:-f,y01:-p,x11:E*(i/C-1),y11:D*(i/C-1)}}function x(){var s=m,x=h,S=e(0),C=null,w=g,T=_,E=v,D=null,O=t(k);function k(){var e,t,m=+s.apply(this,arguments),h=+x.apply(this,arguments),g=w.apply(this,arguments)-r,_=T.apply(this,arguments)-r,v=l(_-g),k=_>g;if(D||=e=O(),h<m&&(t=h,h=m,m=t),!(h>1e-12))D.moveTo(0,0);else if(v>c-1e-12)D.moveTo(h*u(g),h*a(g)),D.arc(0,0,h,g,_,!k),m>1e-12&&(D.moveTo(m*u(_),m*a(_)),D.arc(0,0,m,_,g,k));else{var A=g,j=_,M=g,N=_,P=v,F=v,I=E.apply(this,arguments)/2,L=I>1e-12&&(C?+C.apply(this,arguments):d(m*m+h*h)),R=p(l(h-m)/2,+S.apply(this,arguments)),z=R,B=R,V,H;if(L>1e-12){var U=o(L/m*a(I)),W=o(L/h*a(I));(P-=U*2)>1e-12?(U*=k?1:-1,M+=U,N-=U):(P=0,M=N=(g+_)/2),(F-=W*2)>1e-12?(W*=k?1:-1,A+=W,j-=W):(F=0,A=j=(g+_)/2)}var G=h*u(A),K=h*a(A),q=m*u(N),J=m*a(N);if(R>1e-12){var Y=h*u(j),X=h*a(j),Z=m*u(M),Q=m*a(M),$;if(v<i)if($=y(G,K,Z,Q,Y,X,q,J)){var ee=G-$[0],te=K-$[1],ne=Y-$[0],re=X-$[1],ie=1/a(f((ee*ne+te*re)/(d(ee*ee+te*te)*d(ne*ne+re*re)))/2),ae=d($[0]*$[0]+$[1]*$[1]);z=p(R,(m-ae)/(ie-1)),B=p(R,(h-ae)/(ie+1))}else z=B=0}F>1e-12?B>1e-12?(V=b(Z,Q,G,K,h,B,k),H=b(Y,X,q,J,h,B,k),D.moveTo(V.cx+V.x01,V.cy+V.y01),B<R?D.arc(V.cx,V.cy,B,n(V.y01,V.x01),n(H.y01,H.x01),!k):(D.arc(V.cx,V.cy,B,n(V.y01,V.x01),n(V.y11,V.x11),!k),D.arc(0,0,h,n(V.cy+V.y11,V.cx+V.x11),n(H.cy+H.y11,H.cx+H.x11),!k),D.arc(H.cx,H.cy,B,n(H.y11,H.x11),n(H.y01,H.x01),!k))):(D.moveTo(G,K),D.arc(0,0,h,A,j,!k)):D.moveTo(G,K),!(m>1e-12)||!(P>1e-12)?D.lineTo(q,J):z>1e-12?(V=b(q,J,Y,X,m,-z,k),H=b(G,K,Z,Q,m,-z,k),D.lineTo(V.cx+V.x01,V.cy+V.y01),z<R?D.arc(V.cx,V.cy,z,n(V.y01,V.x01),n(H.y01,H.x01),!k):(D.arc(V.cx,V.cy,z,n(V.y01,V.x01),n(V.y11,V.x11),!k),D.arc(0,0,m,n(V.cy+V.y11,V.cx+V.x11),n(H.cy+H.y11,H.cx+H.x11),k),D.arc(H.cx,H.cy,z,n(H.y11,H.x11),n(H.y01,H.x01),!k))):D.arc(0,0,m,N,M,k)}if(D.closePath(),e)return D=null,e+``||null}return k.centroid=function(){var e=(+s.apply(this,arguments)+ +x.apply(this,arguments))/2,t=(+w.apply(this,arguments)+ +T.apply(this,arguments))/2-i/2;return[u(t)*e,a(t)*e]},k.innerRadius=function(t){return arguments.length?(s=typeof t==`function`?t:e(+t),k):s},k.outerRadius=function(t){return arguments.length?(x=typeof t==`function`?t:e(+t),k):x},k.cornerRadius=function(t){return arguments.length?(S=typeof t==`function`?t:e(+t),k):S},k.padRadius=function(t){return arguments.length?(C=t==null?null:typeof t==`function`?t:e(+t),k):C},k.startAngle=function(t){return arguments.length?(w=typeof t==`function`?t:e(+t),k):w},k.endAngle=function(t){return arguments.length?(T=typeof t==`function`?t:e(+t),k):T},k.padAngle=function(t){return arguments.length?(E=typeof t==`function`?t:e(+t),k):E},k.context=function(e){return arguments.length?(D=e??null,k):D},k}export{x as t};
|