diffprism 0.49.0 → 1.1.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.
@@ -198,6 +198,18 @@ function getUntrackedDiffs(cwd) {
198
198
  }
199
199
  return result;
200
200
  }
201
+ function getRepoRoot(options) {
202
+ const cwd = options?.cwd ?? process.cwd();
203
+ try {
204
+ return execSync("git rev-parse --show-toplevel", {
205
+ cwd,
206
+ encoding: "utf-8",
207
+ stdio: ["pipe", "pipe", "pipe"]
208
+ }).trim();
209
+ } catch {
210
+ return null;
211
+ }
212
+ }
201
213
 
202
214
  // packages/git/src/parser.ts
203
215
  import path2 from "path";
@@ -443,6 +455,7 @@ export {
443
455
  listBranches,
444
456
  listCommits,
445
457
  detectWorktree,
458
+ getRepoRoot,
446
459
  parseDiff,
447
460
  getDiff
448
461
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  parseDiff
3
- } from "./chunk-QGWYCEJN.js";
3
+ } from "./chunk-3GMPE2ZR.js";
4
4
  import {
5
5
  analyze
6
6
  } from "./chunk-DHCVZGHE.js";
@@ -3780,66 +3780,16 @@ function normalizePr(rawDiff, prMetadata, options) {
3780
3780
  }
3781
3781
 
3782
3782
  // packages/github/src/submit.ts
3783
- async function submitGitHubReview(client, owner, repo, prNumber, result) {
3784
- if (result.decision === "dismissed") {
3785
- return null;
3786
- }
3787
- const eventMap = {
3788
- approved: "APPROVE",
3789
- changes_requested: "REQUEST_CHANGES",
3790
- approved_with_comments: "COMMENT"
3791
- };
3792
- const event = eventMap[result.decision];
3793
- if (!event) {
3794
- return null;
3795
- }
3796
- const comments = result.comments.filter((c) => c.file && c.line > 0).map((c) => formatReviewComment(c));
3797
- const body = buildReviewBody(result);
3783
+ async function submitGitHubReview(client, owner, repo, prNumber, review) {
3798
3784
  const { data } = await client.pulls.createReview({
3799
3785
  owner,
3800
3786
  repo,
3801
3787
  pull_number: prNumber,
3802
- event,
3803
- body,
3804
- comments
3788
+ event: review.event,
3789
+ ...review.body ? { body: review.body } : {},
3790
+ comments: review.comments
3805
3791
  });
3806
- return { reviewId: data.id };
3807
- }
3808
- function formatReviewComment(comment) {
3809
- const typePrefix = getCommentTypePrefix(comment.type);
3810
- return {
3811
- path: comment.file,
3812
- line: comment.line,
3813
- body: `${typePrefix}${comment.body}`
3814
- };
3815
- }
3816
- function getCommentTypePrefix(type) {
3817
- switch (type) {
3818
- case "must_fix":
3819
- return "**Must Fix:** ";
3820
- case "suggestion":
3821
- return "**Suggestion:** ";
3822
- case "question":
3823
- return "**Question:** ";
3824
- case "nitpick":
3825
- return "**Nitpick:** ";
3826
- default:
3827
- return "";
3828
- }
3829
- }
3830
- function buildReviewBody(result) {
3831
- const parts = [];
3832
- if (result.summary) {
3833
- parts.push(result.summary);
3834
- }
3835
- if (result.comments.length > 0) {
3836
- const inlineCount = result.comments.filter((c) => c.file && c.line > 0).length;
3837
- if (inlineCount > 0) {
3838
- parts.push(`*${inlineCount} inline comment${inlineCount !== 1 ? "s" : ""} attached.*`);
3839
- }
3840
- }
3841
- parts.push("\n---\n*Reviewed with [DiffPrism](https://github.com/anthropics/diffprism)*");
3842
- return parts.join("\n\n");
3792
+ return { reviewId: data.id, url: data.html_url };
3843
3793
  }
3844
3794
 
3845
3795
  export {
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  ensureServer,
3
3
  submitReviewToServer
4
- } from "./chunk-EPUCA2N5.js";
4
+ } from "./chunk-KRHZSUEK.js";
5
5
  import {
6
6
  parseDiff
7
- } from "./chunk-QGWYCEJN.js";
7
+ } from "./chunk-3GMPE2ZR.js";
8
8
  import {
9
9
  analyze
10
10
  } from "./chunk-DHCVZGHE.js";