difit 1.0.3 → 1.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.
@@ -175,4 +175,4 @@ prismjs/prism.js:
175
175
  ${m.body}`,generateAllCommentsPrompt:()=>t.length===0?"No comments available.":t.map(y=>`${y.file}:${y.line}
176
176
  ${y.body}`).join(`
177
177
  =====
178
- `)}}function sy(){const[e,t]=O.useState(null),[n,r]=O.useState(new Set),[l,o]=O.useState("side-by-side"),[i,a]=O.useState(!0),[s,d]=O.useState(!0),[m,y]=O.useState(null),[h,k]=O.useState(!1),[p,g]=O.useState(320),{comments:x,addComment:u,removeComment:c,updateComment:f,generatePrompt:w,generateAllCommentsPrompt:b}=ay(e==null?void 0:e.commit),E=T=>{T.preventDefault();const W=T.clientX,D=p,G=We=>{const L=Math.max(200,Math.min(600,D+(We.clientX-W)));g(L)},ue=()=>{document.removeEventListener("mousemove",G),document.removeEventListener("mouseup",ue)};document.addEventListener("mousemove",G),document.addEventListener("mouseup",ue)};O.useEffect(()=>{N()},[i]);const C=T=>{const W=["pnpm-lock.yaml","package-lock.json","yarn.lock","Cargo.lock","Gemfile.lock","composer.lock","Pipfile.lock","poetry.lock","go.sum","mix.lock"],D=T.split("/").pop()||"";return W.includes(D)},N=async()=>{try{const T=await fetch(`/api/diff?ignoreWhitespace=${i}`);if(!T.ok)throw new Error("Failed to fetch diff data");const W=await T.json();t(W);const D=W.files.filter(G=>C(G.path)).map(G=>G.path);D.length>0&&r(G=>new Set([...G,...D]))}catch(T){y(T instanceof Error?T.message:"Unknown error")}finally{d(!1)}},R=(T,W,D,G)=>(u(T,W,D,G),Promise.resolve()),A=async()=>{try{const T=b();await navigator.clipboard.writeText(T),k(!0),setTimeout(()=>k(!1),2e3)}catch(T){console.error("Failed to copy all comments prompt:",T)}},z=T=>{r(W=>{const D=new Set(W);return D.has(T)?D.delete(T):(D.add(T),setTimeout(()=>{const ue=document.getElementById(`file-${T.replace(/[^a-zA-Z0-9]/g,"-")}`);ue&&ue.scrollIntoView({behavior:"instant",block:"start"})},100)),D})};return s?v.jsx("div",{className:"flex items-center justify-center h-screen bg-github-bg-primary",children:v.jsx("div",{className:"text-github-text-secondary text-base",children:"Loading diff..."})}):m?v.jsxs("div",{className:"flex flex-col items-center justify-center h-screen bg-github-bg-primary text-center gap-2",children:[v.jsx("h2",{className:"text-github-danger text-2xl mb-2",children:"Error"}),v.jsx("p",{className:"text-github-text-secondary text-base",children:m})]}):e?v.jsxs("div",{className:"h-screen flex flex-col",children:[v.jsxs("header",{className:"bg-github-bg-secondary border-b border-github-border flex items-center",children:[v.jsx("div",{className:"px-4 py-3 border-r border-github-border",style:{width:`${p}px`,minWidth:"200px",maxWidth:"600px"},children:v.jsxs("h1",{className:"text-lg font-semibold text-github-text-primary m-0 flex items-center gap-2",children:[v.jsx(_f,{size:20}),"ReviewIt"]})}),v.jsx("div",{className:"w-1"}),v.jsxs("div",{className:"flex-1 px-4 py-3 flex items-center justify-between gap-4",children:[v.jsxs("div",{className:"flex items-center gap-3",children:[v.jsxs("div",{className:"flex bg-github-bg-tertiary border border-github-border rounded-md p-1",children:[v.jsxs("button",{onClick:()=>o("side-by-side"),className:`px-3 py-1.5 text-xs font-medium rounded transition-all duration-200 flex items-center gap-1.5 cursor-pointer ${l==="side-by-side"?"bg-github-bg-primary text-github-text-primary shadow-sm":"text-github-text-secondary hover:text-github-text-primary"}`,children:[v.jsx(Nf,{size:14}),"Side by Side"]}),v.jsxs("button",{onClick:()=>o("inline"),className:`px-3 py-1.5 text-xs font-medium rounded transition-all duration-200 flex items-center gap-1.5 cursor-pointer ${l==="inline"?"bg-github-bg-primary text-github-text-primary shadow-sm":"text-github-text-secondary hover:text-github-text-primary"}`,children:[v.jsx(xf,{size:14}),"Inline"]})]}),v.jsx(Lc,{checked:i,onChange:a,label:"Ignore Whitespace",title:i?"Show whitespace changes":"Ignore whitespace changes"})]}),v.jsxs("div",{className:"flex items-center gap-4 text-sm text-github-text-secondary",children:[x.length>0&&v.jsxs("button",{onClick:A,className:"text-xs px-3 py-1.5 bg-yellow-900/20 text-yellow-200 border border-yellow-600/50 rounded hover:bg-yellow-800/30 hover:border-yellow-500 transition-all whitespace-nowrap flex items-center gap-1.5",title:`Copy all ${x.length} comments to Claude Code`,children:[v.jsx(bc,{size:12}),h?"Copied All!":`Copy All Prompt (${x.length})`]}),v.jsxs("span",{children:["Reviewing:"," ",v.jsx("code",{className:"bg-github-bg-tertiary px-1.5 py-0.5 rounded text-xs text-github-text-primary",children:e.commit})]}),v.jsxs("span",{children:[e.files.length," file",e.files.length!==1?"s":""," changed"]})]})]})]}),v.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[v.jsx("aside",{className:"bg-github-bg-secondary border-r border-github-border overflow-y-auto",style:{width:`${p}px`,minWidth:"200px",maxWidth:"600px"},children:v.jsx(iy,{files:e.files,onScrollToFile:T=>{const W=document.getElementById(`file-${T.replace(/[^a-zA-Z0-9]/g,"-")}`);W&&W.scrollIntoView({behavior:"smooth",block:"start"})},comments:x,reviewedFiles:n,onToggleReviewed:z})}),v.jsx("div",{className:"w-1 bg-github-border hover:bg-github-text-muted cursor-col-resize transition-colors",onMouseDown:E,title:"Drag to resize file list"}),v.jsx("main",{className:"flex-1 overflow-y-auto",children:e.files.map(T=>v.jsx("div",{id:`file-${T.path.replace(/[^a-zA-Z0-9]/g,"-")}`,className:"mb-6",children:v.jsx(ly,{file:T,comments:x.filter(W=>W.file===T.path),diffMode:l,reviewedFiles:n,onToggleReviewed:z,onAddComment:R,onGeneratePrompt:w,onRemoveComment:c,onUpdateComment:f})},T.path))})]})]}):v.jsxs("div",{className:"flex flex-col items-center justify-center h-screen bg-github-bg-primary text-center gap-2",children:[v.jsx("h2",{className:"text-github-danger text-2xl mb-2",children:"No data"}),v.jsx("p",{className:"text-github-text-secondary text-base",children:"No diff data available"})]})}to.createRoot(document.getElementById("root")).render(v.jsx(ei.StrictMode,{children:v.jsx(sy,{})}));
178
+ `)}}function sy(){const[e,t]=O.useState(null),[n,r]=O.useState(new Set),[l,o]=O.useState("side-by-side"),[i,a]=O.useState(!0),[s,d]=O.useState(!0),[m,y]=O.useState(null),[h,k]=O.useState(!1),[p,g]=O.useState(320),{comments:x,addComment:u,removeComment:c,updateComment:f,generatePrompt:w,generateAllCommentsPrompt:b}=ay(e==null?void 0:e.commit),E=T=>{T.preventDefault();const W=T.clientX,D=p,G=We=>{const L=Math.max(200,Math.min(600,D+(We.clientX-W)));g(L)},ue=()=>{document.removeEventListener("mousemove",G),document.removeEventListener("mouseup",ue)};document.addEventListener("mousemove",G),document.addEventListener("mouseup",ue)};O.useEffect(()=>{N()},[i]);const C=T=>{const W=["pnpm-lock.yaml","package-lock.json","yarn.lock","Cargo.lock","Gemfile.lock","composer.lock","Pipfile.lock","poetry.lock","go.sum","mix.lock"],D=T.split("/").pop()||"";return W.includes(D)},N=async()=>{try{const T=await fetch(`/api/diff?ignoreWhitespace=${i}`);if(!T.ok)throw new Error("Failed to fetch diff data");const W=await T.json();t(W);const D=W.files.filter(G=>C(G.path)).map(G=>G.path);D.length>0&&r(G=>new Set([...G,...D]))}catch(T){y(T instanceof Error?T.message:"Unknown error")}finally{d(!1)}},R=(T,W,D,G)=>(u(T,W,D,G),Promise.resolve()),A=async()=>{try{const T=b();await navigator.clipboard.writeText(T),k(!0),setTimeout(()=>k(!1),2e3)}catch(T){console.error("Failed to copy all comments prompt:",T)}},z=T=>{r(W=>{const D=new Set(W);return D.has(T)?D.delete(T):(D.add(T),setTimeout(()=>{const ue=document.getElementById(`file-${T.replace(/[^a-zA-Z0-9]/g,"-")}`);ue&&ue.scrollIntoView({behavior:"instant",block:"start"})},100)),D})};return s?v.jsx("div",{className:"flex items-center justify-center h-screen bg-github-bg-primary",children:v.jsx("div",{className:"text-github-text-secondary text-base",children:"Loading diff..."})}):m?v.jsxs("div",{className:"flex flex-col items-center justify-center h-screen bg-github-bg-primary text-center gap-2",children:[v.jsx("h2",{className:"text-github-danger text-2xl mb-2",children:"Error"}),v.jsx("p",{className:"text-github-text-secondary text-base",children:m})]}):e?v.jsxs("div",{className:"h-screen flex flex-col",children:[v.jsxs("header",{className:"bg-github-bg-secondary border-b border-github-border flex items-center",children:[v.jsx("div",{className:"px-4 py-3 border-r border-github-border",style:{width:`${p}px`,minWidth:"200px",maxWidth:"600px"},children:v.jsxs("h1",{className:"text-lg font-semibold text-github-text-primary m-0 flex items-center gap-2",children:[v.jsx(_f,{size:20}),"ReviewIt"]})}),v.jsx("div",{className:"w-1"}),v.jsxs("div",{className:"flex-1 px-4 py-3 flex items-center justify-between gap-4",children:[v.jsxs("div",{className:"flex items-center gap-3",children:[v.jsxs("div",{className:"flex bg-github-bg-tertiary border border-github-border rounded-md p-1",children:[v.jsxs("button",{onClick:()=>o("side-by-side"),className:`px-3 py-1.5 text-xs font-medium rounded transition-all duration-200 flex items-center gap-1.5 cursor-pointer ${l==="side-by-side"?"bg-github-bg-primary text-github-text-primary shadow-sm":"text-github-text-secondary hover:text-github-text-primary"}`,children:[v.jsx(Nf,{size:14}),"Side by Side"]}),v.jsxs("button",{onClick:()=>o("inline"),className:`px-3 py-1.5 text-xs font-medium rounded transition-all duration-200 flex items-center gap-1.5 cursor-pointer ${l==="inline"?"bg-github-bg-primary text-github-text-primary shadow-sm":"text-github-text-secondary hover:text-github-text-primary"}`,children:[v.jsx(xf,{size:14}),"Inline"]})]}),v.jsx(Lc,{checked:i,onChange:a,label:"Ignore Whitespace",title:i?"Show whitespace changes":"Ignore whitespace changes"})]}),v.jsxs("div",{className:"flex items-center gap-4 text-sm text-github-text-secondary",children:[x.length>0&&v.jsxs("button",{onClick:A,className:"text-xs px-3 py-1.5 bg-yellow-900/20 text-yellow-200 border border-yellow-600/50 rounded hover:bg-yellow-800/30 hover:border-yellow-500 transition-all whitespace-nowrap flex items-center gap-1.5",title:`Copy all ${x.length} comments to Claude Code`,children:[v.jsx(bc,{size:12}),h?"Copied All!":`Copy All Prompt (${x.length})`]}),v.jsxs("span",{children:["Reviewing:"," ",v.jsx("code",{className:"bg-github-bg-tertiary px-1.5 py-0.5 rounded text-xs text-github-text-primary",children:e.commit.includes("..")?v.jsxs(v.Fragment,{children:[v.jsxs("span",{className:"text-github-text-secondary font-medium",children:[e.commit.split("..")[0],".."]}),v.jsx("span",{className:"font-medium",children:e.commit.split("..")[1]})]}):e.commit})]}),v.jsxs("span",{children:[e.files.length," file",e.files.length!==1?"s":""," changed"]})]})]})]}),v.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[v.jsx("aside",{className:"bg-github-bg-secondary border-r border-github-border overflow-y-auto",style:{width:`${p}px`,minWidth:"200px",maxWidth:"600px"},children:v.jsx(iy,{files:e.files,onScrollToFile:T=>{const W=document.getElementById(`file-${T.replace(/[^a-zA-Z0-9]/g,"-")}`);W&&W.scrollIntoView({behavior:"smooth",block:"start"})},comments:x,reviewedFiles:n,onToggleReviewed:z})}),v.jsx("div",{className:"w-1 bg-github-border hover:bg-github-text-muted cursor-col-resize transition-colors",onMouseDown:E,title:"Drag to resize file list"}),v.jsx("main",{className:"flex-1 overflow-y-auto",children:e.files.map(T=>v.jsx("div",{id:`file-${T.path.replace(/[^a-zA-Z0-9]/g,"-")}`,className:"mb-6",children:v.jsx(ly,{file:T,comments:x.filter(W=>W.file===T.path),diffMode:l,reviewedFiles:n,onToggleReviewed:z,onAddComment:R,onGeneratePrompt:w,onRemoveComment:c,onUpdateComment:f})},T.path))})]})]}):v.jsxs("div",{className:"flex flex-col items-center justify-center h-screen bg-github-bg-primary text-center gap-2",children:[v.jsx("h2",{className:"text-github-danger text-2xl mb-2",children:"No data"}),v.jsx("p",{className:"text-github-text-secondary text-base",children:"No diff data available"})]})}to.createRoot(document.getElementById("root")).render(v.jsx(ei.StrictMode,{children:v.jsx(sy,{})}));
@@ -10,7 +10,7 @@
10
10
  <link rel="icon" type="image/png" sizes="512x512" href="/icon-512x512.png" />
11
11
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
12
12
  <title>ReviewIt - Git Diff Viewer</title>
13
- <script type="module" crossorigin src="/assets/index-DhzESvUd.js"></script>
13
+ <script type="module" crossorigin src="/assets/index-DlET-Ch1.js"></script>
14
14
  <link rel="stylesheet" crossorigin href="/assets/index-CpclbaYk.css">
15
15
  </head>
16
16
  <body>
@@ -13,8 +13,12 @@ export class GitDiffParser {
13
13
  diffArgs = ['HEAD'];
14
14
  }
15
15
  else {
16
- // Resolve commitish to actual commit hash
17
- resolvedCommit = await this.git.revparse([commitish]);
16
+ // Resolve commitish to actual commit hash and get short version
17
+ const fullHash = await this.git.revparse([commitish]);
18
+ const shortHash = fullHash.substring(0, 7);
19
+ const parentHash = await this.git.revparse([`${commitish}^`]);
20
+ const shortParentHash = parentHash.substring(0, 7);
21
+ resolvedCommit = `${shortParentHash}..${shortHash}`;
18
22
  diffArgs = [`${commitish}^`, commitish];
19
23
  }
20
24
  if (ignoreWhitespace) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "difit",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "A lightweight command-line tool that spins up a local web server to display Git commit diffs in a GitHub-like Files changed view",
5
5
  "type": "module",
6
6
  "engines": {