poe-code 3.0.337 → 3.0.338
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/dist/index.js +76 -25
- package/dist/index.js.map +3 -3
- package/dist/metafile.json +1 -1
- package/dist/providers/poe-agent.js +75 -24
- package/dist/providers/poe-agent.js.map +3 -3
- package/package.json +1 -1
- package/packages/github-review/dist/diff.d.ts +3 -0
- package/packages/github-review/dist/diff.js +22 -3
- package/packages/github-review/dist/gh.js +8 -7
- package/packages/github-review/dist/pr-url.js +8 -5
- package/packages/github-review/dist/review-history.js +23 -2
- package/packages/github-review/dist/review.js +12 -9
|
@@ -46173,6 +46173,8 @@ function parseReviewDiff(diffText) {
|
|
|
46173
46173
|
status: "modified",
|
|
46174
46174
|
hunks: [],
|
|
46175
46175
|
reviewableLines: [],
|
|
46176
|
+
leftLineSet: /* @__PURE__ */ new Set(),
|
|
46177
|
+
rightContextLineSet: /* @__PURE__ */ new Set(),
|
|
46176
46178
|
reviewableLineSet: /* @__PURE__ */ new Set()
|
|
46177
46179
|
};
|
|
46178
46180
|
continue;
|
|
@@ -46225,11 +46227,13 @@ function parseReviewDiff(diffText) {
|
|
|
46225
46227
|
}
|
|
46226
46228
|
if (line.startsWith("-") && !line.startsWith("---")) {
|
|
46227
46229
|
currentHunk.lines.push({ side: "LEFT", line: oldLine, text: line });
|
|
46230
|
+
currentFile.leftLineSet.add(oldLine);
|
|
46228
46231
|
oldLine += 1;
|
|
46229
46232
|
continue;
|
|
46230
46233
|
}
|
|
46231
46234
|
if (line.startsWith(" ")) {
|
|
46232
46235
|
currentHunk.lines.push({ side: "RIGHT", line: newLine, text: line });
|
|
46236
|
+
currentFile.rightContextLineSet.add(newLine);
|
|
46233
46237
|
currentFile.reviewableLineSet.add(newLine);
|
|
46234
46238
|
oldLine += 1;
|
|
46235
46239
|
newLine += 1;
|
|
@@ -46247,6 +46251,8 @@ function parseReviewDiff(diffText) {
|
|
|
46247
46251
|
files: publicFiles,
|
|
46248
46252
|
fileOrder: new Map(publicFiles.map((file, index) => [file.path, index])),
|
|
46249
46253
|
reviewableLinesByPath: new Map(files.map((file) => [file.path, file.reviewableLineSet])),
|
|
46254
|
+
leftLinesByPath: new Map(files.map((file) => [file.path, file.leftLineSet])),
|
|
46255
|
+
rightContextLinesByPath: new Map(files.map((file) => [file.path, file.rightContextLineSet])),
|
|
46250
46256
|
rendered: publicFiles.map(renderReviewFile).join("\n\n")
|
|
46251
46257
|
};
|
|
46252
46258
|
}
|
|
@@ -46254,20 +46260,35 @@ function validateInlineComments(comments, context) {
|
|
|
46254
46260
|
const accepted = [];
|
|
46255
46261
|
const seen = /* @__PURE__ */ new Set();
|
|
46256
46262
|
for (const comment of comments) {
|
|
46257
|
-
const path71 = comment.path
|
|
46263
|
+
const path71 = comment.path;
|
|
46258
46264
|
const body = comment.body.trim();
|
|
46259
|
-
if (
|
|
46265
|
+
if (path71.length === 0 || !body || !Number.isInteger(comment.line) || comment.line < 1) {
|
|
46260
46266
|
throw new Error("Inline review comments require path, positive line, and body.");
|
|
46261
46267
|
}
|
|
46268
|
+
if (comment.side === "LEFT") {
|
|
46269
|
+
throw new Error(
|
|
46270
|
+
`Inline comment target ${path71}:${comment.line} is a left-side diff target; only right-side comments are supported.`
|
|
46271
|
+
);
|
|
46272
|
+
}
|
|
46262
46273
|
if (!context.reviewableLinesByPath.get(path71)?.has(comment.line)) {
|
|
46263
46274
|
throw new Error(
|
|
46264
46275
|
`Inline comment target ${path71}:${comment.line} is not a valid right-side diff target.`
|
|
46265
46276
|
);
|
|
46266
46277
|
}
|
|
46278
|
+
if (!comment.side && context.leftLinesByPath.get(path71)?.has(comment.line) && context.rightContextLinesByPath.get(path71)?.has(comment.line)) {
|
|
46279
|
+
throw new Error(
|
|
46280
|
+
`Inline comment target ${path71}:${comment.line} is ambiguous; specify side RIGHT to target the right-side diff line.`
|
|
46281
|
+
);
|
|
46282
|
+
}
|
|
46267
46283
|
const key2 = `${path71}\0${comment.line}\0${body}`;
|
|
46268
46284
|
if (!seen.has(key2)) {
|
|
46269
46285
|
seen.add(key2);
|
|
46270
|
-
accepted.push({
|
|
46286
|
+
accepted.push({
|
|
46287
|
+
path: path71,
|
|
46288
|
+
line: comment.line,
|
|
46289
|
+
...comment.side ? { side: comment.side } : {},
|
|
46290
|
+
body
|
|
46291
|
+
});
|
|
46271
46292
|
}
|
|
46272
46293
|
}
|
|
46273
46294
|
accepted.sort((left, right) => {
|
|
@@ -46435,7 +46456,7 @@ function rateLimitStatus(response, input) {
|
|
|
46435
46456
|
// packages/github-review/src/pr-url.ts
|
|
46436
46457
|
function parseUrl(value) {
|
|
46437
46458
|
try {
|
|
46438
|
-
return new URL(value);
|
|
46459
|
+
return new URL(value.trim());
|
|
46439
46460
|
} catch {
|
|
46440
46461
|
return null;
|
|
46441
46462
|
}
|
|
@@ -46455,6 +46476,9 @@ function parsePathPart(value) {
|
|
|
46455
46476
|
return null;
|
|
46456
46477
|
}
|
|
46457
46478
|
}
|
|
46479
|
+
function formatPullRequestUrl(ref) {
|
|
46480
|
+
return `https://${ref.host}/${encodeURIComponent(ref.owner)}/${encodeURIComponent(ref.repo)}/pull/${ref.number}`;
|
|
46481
|
+
}
|
|
46458
46482
|
function parseGitHubPullRequestRef(prUrl) {
|
|
46459
46483
|
const parsed = parseUrl(prUrl);
|
|
46460
46484
|
if (!parsed || parsed.protocol !== "https:" || !parsed.hostname || parsed.username || parsed.password) {
|
|
@@ -46470,20 +46494,20 @@ function parseGitHubPullRequestRef(prUrl) {
|
|
|
46470
46494
|
if (!owner || !repo || !Number.isSafeInteger(number) || number <= 0) {
|
|
46471
46495
|
return null;
|
|
46472
46496
|
}
|
|
46473
|
-
|
|
46497
|
+
const ref = {
|
|
46474
46498
|
host: parsed.host.toLowerCase(),
|
|
46475
46499
|
owner,
|
|
46476
46500
|
repo,
|
|
46477
|
-
number
|
|
46478
|
-
url: prUrl
|
|
46501
|
+
number
|
|
46479
46502
|
};
|
|
46503
|
+
return { ...ref, url: formatPullRequestUrl(ref) };
|
|
46480
46504
|
}
|
|
46481
46505
|
function canonicalPullRequestUrl(prUrl) {
|
|
46482
46506
|
const ref = parseGitHubPullRequestRef(prUrl);
|
|
46483
46507
|
if (!ref) {
|
|
46484
46508
|
return prUrl;
|
|
46485
46509
|
}
|
|
46486
|
-
return
|
|
46510
|
+
return ref.url;
|
|
46487
46511
|
}
|
|
46488
46512
|
|
|
46489
46513
|
// packages/github-review/src/gh.ts
|
|
@@ -46541,12 +46565,13 @@ function parseJson2(stdout, action) {
|
|
|
46541
46565
|
}
|
|
46542
46566
|
}
|
|
46543
46567
|
function ghPrView(prUrl, fields, options = {}) {
|
|
46544
|
-
requirePullRequestRef(prUrl);
|
|
46568
|
+
const ref = requirePullRequestRef(prUrl);
|
|
46569
|
+
const canonicalPrUrl = ref.url;
|
|
46545
46570
|
const requestedFields = dedupe([...fields]);
|
|
46546
|
-
const result = runGh(["pr", "view",
|
|
46571
|
+
const result = runGh(["pr", "view", canonicalPrUrl, "--json", requestedFields.join(",")], options);
|
|
46547
46572
|
if (result.code === 0) {
|
|
46548
46573
|
const parsed2 = parseJsonRecord(result.stdout, "gh pr view");
|
|
46549
|
-
parsed2.url ??=
|
|
46574
|
+
parsed2.url ??= canonicalPrUrl;
|
|
46550
46575
|
return parsed2;
|
|
46551
46576
|
}
|
|
46552
46577
|
const availableFields = parseGhAvailableFields(result.stderr);
|
|
@@ -46554,17 +46579,20 @@ function ghPrView(prUrl, fields, options = {}) {
|
|
|
46554
46579
|
if (fallbackFields.length === 0 || fallbackFields.length === requestedFields.length) {
|
|
46555
46580
|
throw new Error(result.stderr.trim() || result.stdout.trim() || "gh pr view failed");
|
|
46556
46581
|
}
|
|
46557
|
-
const fallback = runGh(
|
|
46582
|
+
const fallback = runGh(
|
|
46583
|
+
["pr", "view", canonicalPrUrl, "--json", fallbackFields.join(",")],
|
|
46584
|
+
options
|
|
46585
|
+
);
|
|
46558
46586
|
if (fallback.code !== 0) {
|
|
46559
46587
|
throw new Error(fallback.stderr.trim() || fallback.stdout.trim() || "gh pr view failed");
|
|
46560
46588
|
}
|
|
46561
46589
|
const parsed = parseJsonRecord(fallback.stdout, "gh pr view");
|
|
46562
|
-
parsed.url ??=
|
|
46590
|
+
parsed.url ??= canonicalPrUrl;
|
|
46563
46591
|
return parsed;
|
|
46564
46592
|
}
|
|
46565
46593
|
function ghPrDiff(prUrl, options = {}) {
|
|
46566
|
-
requirePullRequestRef(prUrl);
|
|
46567
|
-
return runGhOrThrow(["pr", "diff",
|
|
46594
|
+
const ref = requirePullRequestRef(prUrl);
|
|
46595
|
+
return runGhOrThrow(["pr", "diff", ref.url], options);
|
|
46568
46596
|
}
|
|
46569
46597
|
function ghApiJson(prUrl, args, payload, options = {}) {
|
|
46570
46598
|
const ref = requirePullRequestRef(prUrl);
|
|
@@ -46716,18 +46744,21 @@ function reviewEndpoint(prUrl) {
|
|
|
46716
46744
|
}
|
|
46717
46745
|
return `repos/${ref.owner}/${ref.repo}/pulls/${ref.number}/reviews`;
|
|
46718
46746
|
}
|
|
46719
|
-
function
|
|
46720
|
-
|
|
46721
|
-
|
|
46747
|
+
function normalizeReviewComments(comments) {
|
|
46748
|
+
return comments.map((comment) => {
|
|
46749
|
+
const path71 = comment.path.trim();
|
|
46750
|
+
const body = comment.body.trim();
|
|
46751
|
+
if (!path71) {
|
|
46722
46752
|
throw new Error("Review comment path must be non-empty.");
|
|
46723
46753
|
}
|
|
46724
46754
|
if (!Number.isSafeInteger(comment.line) || comment.line <= 0) {
|
|
46725
46755
|
throw new Error("Review comment line must be a positive integer.");
|
|
46726
46756
|
}
|
|
46727
|
-
if (!
|
|
46757
|
+
if (!body) {
|
|
46728
46758
|
throw new Error("Review comment body must be non-empty.");
|
|
46729
46759
|
}
|
|
46730
|
-
|
|
46760
|
+
return { path: path71, line: comment.line, body };
|
|
46761
|
+
});
|
|
46731
46762
|
}
|
|
46732
46763
|
function submissionFromResponse(response) {
|
|
46733
46764
|
return {
|
|
@@ -46740,8 +46771,7 @@ function submitPullRequestReview(input) {
|
|
|
46740
46771
|
if (!REVIEW_DECISIONS.has(input.decision)) {
|
|
46741
46772
|
throw new Error(`Invalid pull request review decision: ${input.decision}`);
|
|
46742
46773
|
}
|
|
46743
|
-
const comments = input.comments ?? [];
|
|
46744
|
-
validateReviewComments(comments);
|
|
46774
|
+
const comments = normalizeReviewComments(input.comments ?? []);
|
|
46745
46775
|
const response = ghApiJson(
|
|
46746
46776
|
prUrl,
|
|
46747
46777
|
["--method", "POST", reviewEndpoint(prUrl)],
|
|
@@ -46830,9 +46860,30 @@ function isAtOrAfter(value, since) {
|
|
|
46830
46860
|
if (!value) return false;
|
|
46831
46861
|
return new Date(value).getTime() >= new Date(since).getTime();
|
|
46832
46862
|
}
|
|
46833
|
-
function
|
|
46863
|
+
function rawCreatedAt(record, kind) {
|
|
46834
46864
|
return kind === "review_body" ? text4(record, "submitted_at") ?? text4(record, "created_at") : text4(record, "created_at") ?? text4(record, "submitted_at");
|
|
46835
46865
|
}
|
|
46866
|
+
function createdAt(record, kind) {
|
|
46867
|
+
const value = rawCreatedAt(record, kind);
|
|
46868
|
+
if (!value) {
|
|
46869
|
+
return null;
|
|
46870
|
+
}
|
|
46871
|
+
const timestamp = new Date(value);
|
|
46872
|
+
if (Number.isNaN(timestamp.getTime())) {
|
|
46873
|
+
throw new Error(`Invalid GitHub review-history ${kind} timestamp: ${value}`);
|
|
46874
|
+
}
|
|
46875
|
+
return timestamp.toISOString();
|
|
46876
|
+
}
|
|
46877
|
+
function dedupeRepos(repos) {
|
|
46878
|
+
const deduped = /* @__PURE__ */ new Map();
|
|
46879
|
+
for (const repo of repos) {
|
|
46880
|
+
const key2 = repo.toLowerCase();
|
|
46881
|
+
if (!deduped.has(key2)) {
|
|
46882
|
+
deduped.set(key2, repo);
|
|
46883
|
+
}
|
|
46884
|
+
}
|
|
46885
|
+
return [...deduped.values()];
|
|
46886
|
+
}
|
|
46836
46887
|
var ReviewHistoryFetcher = class {
|
|
46837
46888
|
constructor(options) {
|
|
46838
46889
|
this.options = options;
|
|
@@ -47061,7 +47112,7 @@ async function* fetchReviewHistory(options) {
|
|
|
47061
47112
|
if (options.maxComments !== void 0 && (!Number.isInteger(options.maxComments) || options.maxComments < 1)) {
|
|
47062
47113
|
throw new Error("Review-history maxComments must be a positive integer.");
|
|
47063
47114
|
}
|
|
47064
|
-
const repos =
|
|
47115
|
+
const repos = dedupeRepos(options.repos);
|
|
47065
47116
|
for (const repo of repos) {
|
|
47066
47117
|
if (!validRepo(repo)) {
|
|
47067
47118
|
throw new Error(`Invalid GitHub repository name: ${repo}`);
|