@self-review/core 1.44.0 → 1.45.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.
- package/dist/index.cjs +13 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +23 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DiffFile, ReviewState, ReviewComment, DiffSource, RemoteForge, ReviewGuide, ResolvedGuideGroup, AppConfig, PayloadStats, LineRange, Suggestion, DiffLoadPayload, GuideLoadPayload, OutputPathInfo, RemoteDriftInfo, SuggestionApplyRequest, SuggestionApplyOutcome, ExpandContextRequest, DiffHunk, ResumeLoadPayload, ImageLoadResult, RemoteSessionInfo } from '@self-review/types';
|
|
2
|
-
export { AppConfig, Attachment, CategoryDef, ChangeType, CommentConfidence, CommentSeverity, DiffFile, DiffHunk, DiffLine, DiffLineType, DiffLoadPayload, DiffSource, ExpandContextRequest, ExpandContextResponse, FileReviewState, FindInPageRequest, FindInPageResult, GuideFileEntry, GuideGroup, ImageLoadResult, LineRange, OutputPathInfo, PayloadStats, ResolvedGuideFile, ResolvedGuideGroup, ResumeLoadPayload, ReviewComment, ReviewGuide, ReviewState, Suggestion, VersionUpdateInfo } from '@self-review/types';
|
|
2
|
+
export { AppConfig, ApplyDestinationOutcome, Attachment, CategoryDef, ChangeType, CommentConfidence, CommentSeverity, DiffFile, DiffHunk, DiffLine, DiffLineType, DiffLoadPayload, DiffSource, ExpandContextRequest, ExpandContextResponse, FileReviewState, FindInPageRequest, FindInPageResult, GuideFileEntry, GuideGroup, ImageLoadResult, LineRange, OutputPathInfo, PayloadStats, ResolvedGuideFile, ResolvedGuideGroup, ResumeLoadPayload, ReviewComment, ReviewGuide, ReviewState, Suggestion, SuggestionApplyOutcome, SuggestionApplyRequest, VersionUpdateInfo } from '@self-review/types';
|
|
3
3
|
|
|
4
4
|
declare function parseDiff(rawDiff: string): DiffFile[];
|
|
5
5
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DiffFile, ReviewState, ReviewComment, DiffSource, RemoteForge, ReviewGuide, ResolvedGuideGroup, AppConfig, PayloadStats, LineRange, Suggestion, DiffLoadPayload, GuideLoadPayload, OutputPathInfo, RemoteDriftInfo, SuggestionApplyRequest, SuggestionApplyOutcome, ExpandContextRequest, DiffHunk, ResumeLoadPayload, ImageLoadResult, RemoteSessionInfo } from '@self-review/types';
|
|
2
|
-
export { AppConfig, Attachment, CategoryDef, ChangeType, CommentConfidence, CommentSeverity, DiffFile, DiffHunk, DiffLine, DiffLineType, DiffLoadPayload, DiffSource, ExpandContextRequest, ExpandContextResponse, FileReviewState, FindInPageRequest, FindInPageResult, GuideFileEntry, GuideGroup, ImageLoadResult, LineRange, OutputPathInfo, PayloadStats, ResolvedGuideFile, ResolvedGuideGroup, ResumeLoadPayload, ReviewComment, ReviewGuide, ReviewState, Suggestion, VersionUpdateInfo } from '@self-review/types';
|
|
2
|
+
export { AppConfig, ApplyDestinationOutcome, Attachment, CategoryDef, ChangeType, CommentConfidence, CommentSeverity, DiffFile, DiffHunk, DiffLine, DiffLineType, DiffLoadPayload, DiffSource, ExpandContextRequest, ExpandContextResponse, FileReviewState, FindInPageRequest, FindInPageResult, GuideFileEntry, GuideGroup, ImageLoadResult, LineRange, OutputPathInfo, PayloadStats, ResolvedGuideFile, ResolvedGuideGroup, ResumeLoadPayload, ReviewComment, ReviewGuide, ReviewState, Suggestion, SuggestionApplyOutcome, SuggestionApplyRequest, VersionUpdateInfo } from '@self-review/types';
|
|
3
3
|
|
|
4
4
|
declare function parseDiff(rawDiff: string): DiffFile[];
|
|
5
5
|
|
package/dist/index.js
CHANGED
|
@@ -646,18 +646,25 @@ function extFromMediaType(mediaType) {
|
|
|
646
646
|
};
|
|
647
647
|
return map[mediaType] || "png";
|
|
648
648
|
}
|
|
649
|
+
function assetNameComponent(idPrefix) {
|
|
650
|
+
return String(idPrefix ?? "").replace(/[^A-Za-z0-9_-]/g, "_");
|
|
651
|
+
}
|
|
649
652
|
function persistAttachments(attachments, idPrefix, assetDir, onWrite) {
|
|
650
653
|
if (!attachments?.length) return attachments;
|
|
651
654
|
return attachments.map((att, index) => {
|
|
652
655
|
if (!att.data) return att;
|
|
653
656
|
onWrite();
|
|
654
657
|
const ext = extFromMediaType(att.mediaType);
|
|
655
|
-
const fileName = `${idPrefix}-${index}.${ext}`;
|
|
658
|
+
const fileName = `${assetNameComponent(idPrefix)}-${index}.${ext}`;
|
|
656
659
|
const relativePath = `.self-review-assets/${fileName}`;
|
|
660
|
+
const target = path.join(assetDir, fileName);
|
|
661
|
+
if (path.dirname(path.resolve(target)) !== path.resolve(assetDir)) {
|
|
662
|
+
throw new Error(`Refusing to write an attachment outside ${assetDir}: ${fileName}`);
|
|
663
|
+
}
|
|
657
664
|
if (!fs.existsSync(assetDir)) {
|
|
658
665
|
fs.mkdirSync(assetDir, { recursive: true });
|
|
659
666
|
}
|
|
660
|
-
fs.writeFileSync(
|
|
667
|
+
fs.writeFileSync(target, Buffer.from(att.data));
|
|
661
668
|
return { ...att, fileName: relativePath, data: void 0 };
|
|
662
669
|
});
|
|
663
670
|
}
|
|
@@ -1690,7 +1697,7 @@ function checkWritability(filePath) {
|
|
|
1690
1697
|
|
|
1691
1698
|
// src/apply-suggestion.ts
|
|
1692
1699
|
import { readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "fs";
|
|
1693
|
-
import { isAbsolute, relative as relative2, resolve, sep } from "path";
|
|
1700
|
+
import { isAbsolute, relative as relative2, resolve as resolve2, sep } from "path";
|
|
1694
1701
|
function refuse(filePath, reason, detail) {
|
|
1695
1702
|
return { status: "refused", filePath, reason, detail };
|
|
1696
1703
|
}
|
|
@@ -1729,8 +1736,8 @@ function applySuggestion(request) {
|
|
|
1729
1736
|
"The destination directory must be an absolute path."
|
|
1730
1737
|
);
|
|
1731
1738
|
}
|
|
1732
|
-
const root =
|
|
1733
|
-
const absolutePath =
|
|
1739
|
+
const root = resolve2(destinationRoot);
|
|
1740
|
+
const absolutePath = resolve2(root, filePath);
|
|
1734
1741
|
const rel = relative2(root, absolutePath);
|
|
1735
1742
|
if (isAbsolute(filePath) || rel === "" || rel === ".." || rel.startsWith(`..${sep}`)) {
|
|
1736
1743
|
return refuse(
|
|
@@ -2267,14 +2274,14 @@ import * as path2 from "path";
|
|
|
2267
2274
|
var LOCAL_BASE_REF = "refs/self-review/base";
|
|
2268
2275
|
var LOCAL_HEAD_REF = "refs/self-review/head";
|
|
2269
2276
|
var AUTH_HINT = "Hint: if this repository is private or requires authentication, run `gh auth setup-git` (GitHub) or `glab auth git-credential` (GitLab) to wire your CLI credentials into git.";
|
|
2270
|
-
var defaultGitRunner = (command, args) => new Promise((
|
|
2277
|
+
var defaultGitRunner = (command, args) => new Promise((resolve7, reject) => {
|
|
2271
2278
|
execFile2(command, args, { maxBuffer: 50 * 1024 * 1024 }, (error, stdout, stderr) => {
|
|
2272
2279
|
const spawnCode = error?.code;
|
|
2273
2280
|
if (error && typeof spawnCode === "string") {
|
|
2274
2281
|
reject(error);
|
|
2275
2282
|
return;
|
|
2276
2283
|
}
|
|
2277
|
-
|
|
2284
|
+
resolve7({
|
|
2278
2285
|
stdout: stdout ?? "",
|
|
2279
2286
|
stderr: stderr ?? "",
|
|
2280
2287
|
exitCode: error ? typeof spawnCode === "number" ? spawnCode : 1 : 0
|
|
@@ -2452,7 +2459,7 @@ import path3 from "path";
|
|
|
2452
2459
|
|
|
2453
2460
|
// src/git-diff-args.ts
|
|
2454
2461
|
import { existsSync as existsSync3 } from "fs";
|
|
2455
|
-
import { resolve as
|
|
2462
|
+
import { resolve as resolve3 } from "path";
|
|
2456
2463
|
var OPTIONS_WITH_SEPARATE_VALUES = /* @__PURE__ */ new Set([
|
|
2457
2464
|
"--output",
|
|
2458
2465
|
"--src-prefix",
|
|
@@ -2511,7 +2518,7 @@ function normalizeGitDiffArgs(args, cwd = process.cwd()) {
|
|
|
2511
2518
|
if (hasSeparator) return args;
|
|
2512
2519
|
for (const i of positionalIndices) {
|
|
2513
2520
|
const arg = args[i];
|
|
2514
|
-
if (existsSync3(
|
|
2521
|
+
if (existsSync3(resolve3(cwd, arg))) {
|
|
2515
2522
|
return [...args.slice(0, i), "--", ...args.slice(i)];
|
|
2516
2523
|
}
|
|
2517
2524
|
}
|
|
@@ -2849,7 +2856,7 @@ function commitReviewStart(session, payload) {
|
|
|
2849
2856
|
// src/startup-mode.ts
|
|
2850
2857
|
import { existsSync as existsSync4, statSync as statSync2 } from "fs";
|
|
2851
2858
|
import { execFileSync, execSync } from "child_process";
|
|
2852
|
-
import { resolve as
|
|
2859
|
+
import { resolve as resolve4 } from "path";
|
|
2853
2860
|
function isInGitRepo() {
|
|
2854
2861
|
try {
|
|
2855
2862
|
execSync("git rev-parse --git-dir", { stdio: "ignore" });
|
|
@@ -2872,7 +2879,7 @@ function determineMode(gitDiffArgs) {
|
|
|
2872
2879
|
const { positionalIndices } = classifyGitDiffArgs(gitDiffArgs);
|
|
2873
2880
|
const firstPositional = gitDiffArgs[positionalIndices[0]];
|
|
2874
2881
|
if (firstPositional) {
|
|
2875
|
-
const candidate =
|
|
2882
|
+
const candidate = resolve4(process.cwd(), firstPositional);
|
|
2876
2883
|
try {
|
|
2877
2884
|
if (existsSync4(candidate) && statSync2(candidate).isFile()) {
|
|
2878
2885
|
if (isInGitRepo()) {
|
|
@@ -2887,7 +2894,7 @@ function determineMode(gitDiffArgs) {
|
|
|
2887
2894
|
return "git";
|
|
2888
2895
|
}
|
|
2889
2896
|
if (firstPositional) {
|
|
2890
|
-
const candidate =
|
|
2897
|
+
const candidate = resolve4(process.cwd(), firstPositional);
|
|
2891
2898
|
try {
|
|
2892
2899
|
if (existsSync4(candidate) && statSync2(candidate).isDirectory()) {
|
|
2893
2900
|
return "directory";
|
|
@@ -2900,7 +2907,7 @@ function determineMode(gitDiffArgs) {
|
|
|
2900
2907
|
|
|
2901
2908
|
// src/guide-loader.ts
|
|
2902
2909
|
import { readFile } from "fs/promises";
|
|
2903
|
-
import { extname, resolve as
|
|
2910
|
+
import { extname, resolve as resolve5 } from "path";
|
|
2904
2911
|
function deriveGuidePath(outputPath) {
|
|
2905
2912
|
const ext = extname(outputPath);
|
|
2906
2913
|
const base = ext ? outputPath.slice(0, -ext.length) : outputPath;
|
|
@@ -2908,7 +2915,7 @@ function deriveGuidePath(outputPath) {
|
|
|
2908
2915
|
}
|
|
2909
2916
|
function resolveGuidePath(outputPath, config) {
|
|
2910
2917
|
if (config.guideFile) {
|
|
2911
|
-
return
|
|
2918
|
+
return resolve5(process.cwd(), config.guideFile);
|
|
2912
2919
|
}
|
|
2913
2920
|
return deriveGuidePath(outputPath);
|
|
2914
2921
|
}
|
|
@@ -3130,7 +3137,7 @@ function computeRemoteDrift(recordedHeadSha, liveHeadSha) {
|
|
|
3130
3137
|
|
|
3131
3138
|
// src/fetch-comments.ts
|
|
3132
3139
|
import { writeFileSync as writeFileSync3 } from "fs";
|
|
3133
|
-
import { resolve as
|
|
3140
|
+
import { resolve as resolve6 } from "path";
|
|
3134
3141
|
function defaultDeps2() {
|
|
3135
3142
|
return {
|
|
3136
3143
|
runner: defaultGitRunner,
|
|
@@ -3258,7 +3265,7 @@ fetch-comments requires the ${error.cli} CLI to be installed and authenticated.`
|
|
|
3258
3265
|
timestamp: deps.now().toISOString()
|
|
3259
3266
|
});
|
|
3260
3267
|
const config = deps.loadConfig();
|
|
3261
|
-
const outputPath =
|
|
3268
|
+
const outputPath = resolve6(cwd, config.outputFile);
|
|
3262
3269
|
const xml = await deps.serialize(state, outputPath);
|
|
3263
3270
|
deps.writeFile(outputPath, xml + "\n");
|
|
3264
3271
|
console.error(`[fetch-comments] ${comments.length} threads written to ${outputPath}`);
|