@usepipr/runtime 0.4.1 → 0.4.2
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/{commands-0cyQHxpm.d.mts → commands-DtdTtej_.d.mts} +6 -2
- package/dist/commands-DtdTtej_.d.mts.map +1 -0
- package/dist/{commands-46Q2ZDt0.mjs → commands-EZV-Icbs.mjs} +334 -62
- package/dist/commands-EZV-Icbs.mjs.map +1 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +2 -2
- package/dist/internal/docs.mjs +1 -1
- package/dist/internal/testing.d.mts +1 -1
- package/dist/internal/testing.mjs +1 -1
- package/dist/{official-github-workflow-Cx-Yhh86.mjs → official-github-workflow-BuZs6bOx.mjs} +9 -11
- package/dist/{official-github-workflow-Cx-Yhh86.mjs.map → official-github-workflow-BuZs6bOx.mjs.map} +1 -1
- package/package.json +2 -2
- package/dist/commands-0cyQHxpm.d.mts.map +0 -1
- package/dist/commands-46Q2ZDt0.mjs.map +0 -1
|
@@ -299,13 +299,15 @@ declare const priorReviewStateSchema: z.ZodObject<{
|
|
|
299
299
|
selectedTasks: z.ZodArray<z.ZodString>;
|
|
300
300
|
findings: z.ZodArray<z.ZodObject<{
|
|
301
301
|
id: z.ZodString;
|
|
302
|
+
anchorFingerprint: z.ZodOptional<z.ZodString>;
|
|
303
|
+
issueFingerprint: z.ZodOptional<z.ZodString>;
|
|
302
304
|
status: z.ZodEnum<{
|
|
303
305
|
open: "open";
|
|
304
306
|
resolved: "resolved";
|
|
305
307
|
}>;
|
|
306
308
|
path: z.ZodString;
|
|
307
309
|
rangeId: z.ZodString;
|
|
308
|
-
side: z.ZodType<ReviewSide, unknown, z.core.$ZodTypeInternals<ReviewSide, unknown>>;
|
|
310
|
+
side: z.ZodType<import("@usepipr/sdk").ReviewSide, unknown, z.core.$ZodTypeInternals<import("@usepipr/sdk").ReviewSide, unknown>>;
|
|
309
311
|
startLine: z.ZodNumber;
|
|
310
312
|
endLine: z.ZodNumber;
|
|
311
313
|
firstSeenHeadSha: z.ZodString;
|
|
@@ -433,6 +435,8 @@ declare const publicationPlanSchema: z.ZodObject<{
|
|
|
433
435
|
selectedTasks: z.ZodArray<z.ZodString>;
|
|
434
436
|
findings: z.ZodArray<z.ZodObject<{
|
|
435
437
|
id: z.ZodString;
|
|
438
|
+
anchorFingerprint: z.ZodOptional<z.ZodString>;
|
|
439
|
+
issueFingerprint: z.ZodOptional<z.ZodString>;
|
|
436
440
|
status: z.ZodEnum<{
|
|
437
441
|
open: "open";
|
|
438
442
|
resolved: "resolved";
|
|
@@ -844,4 +848,4 @@ declare function runHostRunCommand(options: HostRunCommandOptions): Promise<Host
|
|
|
844
848
|
declare function runHostRunCommandWithDependencies(options: HostRunCommandDependencyOptions): Promise<HostRunCommandResult>;
|
|
845
849
|
//#endregion
|
|
846
850
|
export { DiffManifest as A, RuntimeLogSink as C, PublicationResult as D, PublicationError as E, RuntimeSettings as F, OfficialInitAdapter as I, supportedOfficialInitAdapters as L, PlatformInfo as M, ProviderConfig as N, ChangeRequestEventContext as O, RepositoryRef as P, RuntimeLogRecord as S, RepositoryPermission as T, piBuiltinToolNames as _, runInspectCommand as a, piThinkingLevels as b, DryRunCommandOptions as c, HostRunCommandResult as d, InitCommandOptions as f, RuntimeCommandOptions as g, LocalReviewCommandResult as h, runInitCommand as i, PiprConfig as j, ChangeRequestRef as k, DryRunCommandResult as l, LocalReviewCommandOptions as m, runHostRunCommand as n, runLocalReviewCommand as o, InspectCommandResult as p, runHostRunCommandWithDependencies as r, runValidateCommand as s, runDryRunCommand as t, HostRunCommandOptions as u, piReadOnlyToolNames as v, CodeHostAdapter as w, SecretRedactor as x, piRequiredCliFlags as y };
|
|
847
|
-
//# sourceMappingURL=commands-
|
|
851
|
+
//# sourceMappingURL=commands-DtdTtej_.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands-DtdTtej_.d.mts","names":[],"sources":["../src/config/init.ts","../src/types.ts","../src/config/project.ts","../src/review/prior-state.ts","../src/review/comment.ts","../src/review/publication-result.ts","../src/hosts/types.ts","../src/shared/logging.ts","../src/shared/secret-redaction.ts","../src/pi/contract.ts","../src/review/task/task-output.ts","../src/review/task/task-runtime.ts","../src/host-run/types.ts","../src/host-run/commands.ts"],"mappings":"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"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as resolveReadAtRefRequest, d as isRecord, l as unavailableReadAtRefResult, n as boundedLineSlice, r as parseManifestPath, u as createDiffRangeIndex } from "./runtime-tools-core-D8_WsbL_.mjs";
|
|
2
|
-
import { a as officialInitRecipeWorkflowEnvSecrets, i as officialInitRecipeFiles, r as officialInitRecipeConfigTs, t as renderOfficialGithubWorkflow } from "./official-github-workflow-
|
|
2
|
+
import { a as officialInitRecipeWorkflowEnvSecrets, i as officialInitRecipeFiles, r as officialInitRecipeConfigTs, t as renderOfficialGithubWorkflow } from "./official-github-workflow-BuZs6bOx.mjs";
|
|
3
3
|
import { t as isPublishableSuggestedFixSelection } from "./suggested-fix-publication-policy-B5Wwuudp.mjs";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import { chmod, chown, cp, lstat, mkdir, mkdtemp, readdir, rm } from "node:fs/promises";
|
|
@@ -597,7 +597,7 @@ function compareStableSemver(left, right) {
|
|
|
597
597
|
}
|
|
598
598
|
//#endregion
|
|
599
599
|
//#region src/shared/version.ts
|
|
600
|
-
const runtimeVersion = "0.4.
|
|
600
|
+
const runtimeVersion = "0.4.2";
|
|
601
601
|
//#endregion
|
|
602
602
|
//#region src/config/version-compat.ts
|
|
603
603
|
async function resolveConfigVersionCompatibility(options) {
|
|
@@ -939,8 +939,8 @@ const supportedOfficialInitAdapters = [
|
|
|
939
939
|
"azure-devops",
|
|
940
940
|
"bitbucket"
|
|
941
941
|
];
|
|
942
|
-
const defaultGitLabImageRef = "ghcr.io/somus/pipr:v0.4.
|
|
943
|
-
const defaultSdkVersion = "0.4.
|
|
942
|
+
const defaultGitLabImageRef = "ghcr.io/somus/pipr:v0.4.2";
|
|
943
|
+
const defaultSdkVersion = "0.4.2";
|
|
944
944
|
function resolveOfficialInitAdapters(adapters) {
|
|
945
945
|
if (adapters === void 0) return ["github"];
|
|
946
946
|
if (adapters.length === 0) return [];
|
|
@@ -3837,6 +3837,146 @@ function findingFingerprint(finding) {
|
|
|
3837
3837
|
return new Bun.CryptoHasher("sha256").update(basis).digest("hex").slice(0, 16);
|
|
3838
3838
|
}
|
|
3839
3839
|
//#endregion
|
|
3840
|
+
//#region src/review/agent/review-schema.ts
|
|
3841
|
+
const reviewFindingPropertyNames = [
|
|
3842
|
+
"body",
|
|
3843
|
+
"path",
|
|
3844
|
+
"rangeId",
|
|
3845
|
+
"side",
|
|
3846
|
+
"startLine",
|
|
3847
|
+
"endLine"
|
|
3848
|
+
];
|
|
3849
|
+
const completeReviewFindingPropertyMask = (1 << reviewFindingPropertyNames.length) - 1;
|
|
3850
|
+
const unresolvedSchemaReference = Symbol("unresolvedSchemaReference");
|
|
3851
|
+
const singleSchemaKeywords = [
|
|
3852
|
+
"additionalItems",
|
|
3853
|
+
"additionalProperties",
|
|
3854
|
+
"contains",
|
|
3855
|
+
"else",
|
|
3856
|
+
"if",
|
|
3857
|
+
"items",
|
|
3858
|
+
"then",
|
|
3859
|
+
"unevaluatedProperties"
|
|
3860
|
+
];
|
|
3861
|
+
const schemaArrayKeywords = [
|
|
3862
|
+
"allOf",
|
|
3863
|
+
"anyOf",
|
|
3864
|
+
"oneOf",
|
|
3865
|
+
"prefixItems"
|
|
3866
|
+
];
|
|
3867
|
+
const schemaMapKeywords = [
|
|
3868
|
+
"dependentSchemas",
|
|
3869
|
+
"patternProperties",
|
|
3870
|
+
"properties"
|
|
3871
|
+
];
|
|
3872
|
+
const alternativeSchemaKeywords = ["anyOf", "oneOf"];
|
|
3873
|
+
function schemaContainsReviewFinding(value) {
|
|
3874
|
+
if (!isRecord(value)) return false;
|
|
3875
|
+
return reachableSchemaContainsReviewFinding(value, value, /* @__PURE__ */ new Set());
|
|
3876
|
+
}
|
|
3877
|
+
function reachableSchemaContainsReviewFinding(schema, rootSchema, visited) {
|
|
3878
|
+
if (Array.isArray(schema)) return schema.some((child) => reachableSchemaContainsReviewFinding(child, rootSchema, visited));
|
|
3879
|
+
if (!isRecord(schema) || visited.has(schema)) return false;
|
|
3880
|
+
visited.add(schema);
|
|
3881
|
+
return schemaObjectPropertyMasks(schema, rootSchema, /* @__PURE__ */ new Set()).has(completeReviewFindingPropertyMask) || reachableChildSchemas(schema, rootSchema).some((child) => reachableSchemaContainsReviewFinding(child, rootSchema, visited));
|
|
3882
|
+
}
|
|
3883
|
+
function reachableChildSchemas(schema, rootSchema) {
|
|
3884
|
+
const referencedSchema = resolveLocalSchemaReference(rootSchema, schema.$ref);
|
|
3885
|
+
return [
|
|
3886
|
+
...referencedSchema === void 0 ? [] : [referencedSchema],
|
|
3887
|
+
...singleSchemaKeywords.map((keyword) => schema[keyword]),
|
|
3888
|
+
...schemaArrayKeywords.flatMap((keyword) => Array.isArray(schema[keyword]) ? schema[keyword] : []),
|
|
3889
|
+
...schemaMapKeywords.flatMap((keyword) => {
|
|
3890
|
+
const children = schema[keyword];
|
|
3891
|
+
return isRecord(children) ? Object.values(children) : [];
|
|
3892
|
+
})
|
|
3893
|
+
];
|
|
3894
|
+
}
|
|
3895
|
+
function schemaObjectPropertyMasks(schema, rootSchema, visited) {
|
|
3896
|
+
if (schema === true || visited.has(schema)) return /* @__PURE__ */ new Set([0]);
|
|
3897
|
+
if (!isRecord(schema) || !schemaAllowsObject(schema, rootSchema, /* @__PURE__ */ new Set())) return /* @__PURE__ */ new Set();
|
|
3898
|
+
visited.add(schema);
|
|
3899
|
+
const conjunctiveMasks = conjunctiveSchemas(schema, rootSchema).reduce((masks, child) => combinePropertyMasks(masks, schemaObjectPropertyMasks(child, rootSchema, new Set(visited))), /* @__PURE__ */ new Set([reviewFindingPropertyMask(schema)]));
|
|
3900
|
+
return alternativeSchemaGroups(schema).reduce((masks, alternatives) => combinePropertyMasks(masks, alternativePropertyMasks(alternatives, rootSchema, visited)), conjunctiveMasks);
|
|
3901
|
+
}
|
|
3902
|
+
function conjunctiveSchemas(schema, rootSchema) {
|
|
3903
|
+
const referencedSchema = resolveLocalSchemaReference(rootSchema, schema.$ref);
|
|
3904
|
+
const allOf = Array.isArray(schema.allOf) ? schema.allOf : [];
|
|
3905
|
+
return referencedSchema === void 0 ? allOf : [referencedSchema, ...allOf];
|
|
3906
|
+
}
|
|
3907
|
+
function alternativeSchemaGroups(schema) {
|
|
3908
|
+
return alternativeSchemaKeywords.map((keyword) => schema[keyword]).filter((alternatives) => Array.isArray(alternatives));
|
|
3909
|
+
}
|
|
3910
|
+
function alternativePropertyMasks(alternatives, rootSchema, visited) {
|
|
3911
|
+
return new Set(alternatives.flatMap((child) => [...schemaObjectPropertyMasks(child, rootSchema, new Set(visited))]));
|
|
3912
|
+
}
|
|
3913
|
+
function reviewFindingPropertyMask(schema) {
|
|
3914
|
+
let mask = 0;
|
|
3915
|
+
const properties = isRecord(schema.properties) ? schema.properties : {};
|
|
3916
|
+
const patternProperties = isRecord(schema.patternProperties) ? schema.patternProperties : {};
|
|
3917
|
+
const propertyPatterns = Object.keys(patternProperties).flatMap((pattern) => {
|
|
3918
|
+
try {
|
|
3919
|
+
return [new RegExp(pattern)];
|
|
3920
|
+
} catch {
|
|
3921
|
+
return [];
|
|
3922
|
+
}
|
|
3923
|
+
});
|
|
3924
|
+
const required = new Set(Array.isArray(schema.required) ? schema.required.filter((propertyName) => typeof propertyName === "string") : []);
|
|
3925
|
+
for (const [index, propertyName] of reviewFindingPropertyNames.entries()) if (propertyName in properties || required.has(propertyName) || propertyPatterns.some((pattern) => pattern.test(propertyName))) mask |= 1 << index;
|
|
3926
|
+
return mask;
|
|
3927
|
+
}
|
|
3928
|
+
function combinePropertyMasks(left, right) {
|
|
3929
|
+
const combined = /* @__PURE__ */ new Set();
|
|
3930
|
+
for (const leftMask of left) for (const rightMask of right) {
|
|
3931
|
+
combined.add(leftMask | rightMask);
|
|
3932
|
+
if (combined.has(completeReviewFindingPropertyMask)) return /* @__PURE__ */ new Set([completeReviewFindingPropertyMask]);
|
|
3933
|
+
}
|
|
3934
|
+
return combined;
|
|
3935
|
+
}
|
|
3936
|
+
function schemaAllowsObject(schema, rootSchema, visited) {
|
|
3937
|
+
if (schema === false) return false;
|
|
3938
|
+
if (schema === true || !isRecord(schema) || visited.has(schema)) return true;
|
|
3939
|
+
visited.add(schema);
|
|
3940
|
+
return directSchemaAllowsObject(schema) && conjunctiveSchemas(schema, rootSchema).every((child) => schemaAllowsObject(child, rootSchema, new Set(visited))) && alternativeSchemaGroups(schema).every((alternatives) => alternatives.some((child) => schemaAllowsObject(child, rootSchema, new Set(visited))));
|
|
3941
|
+
}
|
|
3942
|
+
function directSchemaAllowsObject(schema) {
|
|
3943
|
+
const type = schema.type;
|
|
3944
|
+
if (typeof type === "string") return type === "object";
|
|
3945
|
+
if (Array.isArray(type) && !type.includes("object")) return false;
|
|
3946
|
+
if ("const" in schema && !isRecord(schema.const)) return false;
|
|
3947
|
+
return !Array.isArray(schema.enum) || schema.enum.some(isRecord);
|
|
3948
|
+
}
|
|
3949
|
+
function resolveLocalSchemaReference(rootSchema, reference) {
|
|
3950
|
+
if (reference === "#") return rootSchema;
|
|
3951
|
+
if (typeof reference !== "string" || !reference.startsWith("#/")) return;
|
|
3952
|
+
let current = rootSchema;
|
|
3953
|
+
for (const encodedSegment of reference.slice(2).split("/")) {
|
|
3954
|
+
const segment = decodePointerSegment(encodedSegment);
|
|
3955
|
+
if (segment === void 0) return;
|
|
3956
|
+
current = resolvePointerSegment(current, segment);
|
|
3957
|
+
if (current === unresolvedSchemaReference) return;
|
|
3958
|
+
}
|
|
3959
|
+
return current;
|
|
3960
|
+
}
|
|
3961
|
+
function decodePointerSegment(encodedSegment) {
|
|
3962
|
+
try {
|
|
3963
|
+
return decodeURIComponent(encodedSegment).replaceAll("~1", "/").replaceAll("~0", "~");
|
|
3964
|
+
} catch {
|
|
3965
|
+
return;
|
|
3966
|
+
}
|
|
3967
|
+
}
|
|
3968
|
+
function resolvePointerSegment(current, segment) {
|
|
3969
|
+
if (Array.isArray(current)) return resolveArrayPointerSegment(current, segment);
|
|
3970
|
+
if (!isRecord(current) || !(segment in current)) return unresolvedSchemaReference;
|
|
3971
|
+
return current[segment];
|
|
3972
|
+
}
|
|
3973
|
+
function resolveArrayPointerSegment(current, segment) {
|
|
3974
|
+
if (!/^(0|[1-9]\d*)$/.test(segment)) return unresolvedSchemaReference;
|
|
3975
|
+
const index = Number(segment);
|
|
3976
|
+
if (!Number.isSafeInteger(index) || index >= current.length) return unresolvedSchemaReference;
|
|
3977
|
+
return current[index];
|
|
3978
|
+
}
|
|
3979
|
+
//#endregion
|
|
3840
3980
|
//#region src/review/agent/agent-prompt.ts
|
|
3841
3981
|
async function renderAgentPrompt(options) {
|
|
3842
3982
|
const prompt = await renderAgentDefinitionPrompt(options.agent, options.input, options.agentRunContext.prompt);
|
|
@@ -3893,12 +4033,12 @@ function outputPrompt(schema) {
|
|
|
3893
4033
|
]);
|
|
3894
4034
|
if (schema.id === reviewResultSchemaId) {
|
|
3895
4035
|
lines.splice(2, 0, `Example:\n${JSON.stringify(reviewSchemaExample$1(), null, 2)}`, ...suggestedFixRules);
|
|
3896
|
-
lines.push("For inlineFindings, use only fields shown in the schema. Each finding's path, rangeId, and side must identify one Diff Manifest commentable range, and its startLine and endLine must select a valid span within that range. If no valid span applies, omit the finding.", ...inlineSelectionPromptLines(),
|
|
4036
|
+
lines.push("For inlineFindings, use only fields shown in the schema. Each finding's path, rangeId, and side must identify one Diff Manifest commentable range, and its startLine and endLine must select a valid span within that range. If no valid span applies, omit the finding.", ...inlineSelectionPromptLines(), "For inlineFindings.body, write the exact inline comment body.");
|
|
3897
4037
|
} else if (schemaMentionsField(schema.jsonSchema, "suggestedFix")) lines.splice(2, 0, ...suggestedFixRules);
|
|
3898
4038
|
return lines.join("\n\n");
|
|
3899
4039
|
}
|
|
3900
4040
|
function customInlineSelectionPrompt(schema, diffManifest) {
|
|
3901
|
-
if (!diffManifest || schema.id === reviewResultSchemaId) return;
|
|
4041
|
+
if (!diffManifest || schema.id === reviewResultSchemaId || !schemaContainsReviewFinding(schema.jsonSchema)) return;
|
|
3902
4042
|
return promptSection("Inline Review Selection Policy", inlineSelectionPromptLines().join("\n"));
|
|
3903
4043
|
}
|
|
3904
4044
|
function inlineSelectionPromptLines() {
|
|
@@ -3922,16 +4062,16 @@ function schemaMentionsField(value, fieldName) {
|
|
|
3922
4062
|
return Object.entries(value).some(([key, child]) => key === fieldName || schemaMentionsField(child, fieldName));
|
|
3923
4063
|
}
|
|
3924
4064
|
function reviewPolicyPrompt(schema) {
|
|
3925
|
-
if (schema.id !== reviewResultSchemaId) return;
|
|
4065
|
+
if (schema.id !== reviewResultSchemaId && !schemaContainsReviewFinding(schema.jsonSchema)) return;
|
|
3926
4066
|
return promptSection("Review Policy", [
|
|
3927
4067
|
"Review only changed behavior.",
|
|
3928
4068
|
"Report only actionable defects, security risks, regressions, or meaningful test gaps.",
|
|
3929
4069
|
"Before emitting a finding, verify that the changed code introduces or exposes the issue, repository evidence supports it, and the impact is concrete. If any part is uncertain, omit it.",
|
|
3930
4070
|
"When changed behavior crosses a function, type, API, configuration, or data boundary, inspect relevant callers, callees, and tests before deciding whether the change is defective or intentionally coordinated.",
|
|
3931
|
-
"Put each actionable issue in
|
|
3932
|
-
"
|
|
3933
|
-
"
|
|
3934
|
-
`State the concrete defect and user-visible or runtime impact directly. Keep each body to one short paragraph, at most two sentences, and at most 700 characters.`,
|
|
4071
|
+
"Put each actionable issue in the schema's finding collection. Do not leave actionable defects or test gaps only in the summary.",
|
|
4072
|
+
"When the output includes a summary, base it only on changed behavior and evidence available in the Diff Manifest or read tools. Do not claim tests or checks ran, passed, or failed unless their output is present.",
|
|
4073
|
+
"Finding bodies must be publication-ready review prose, not analysis notes.",
|
|
4074
|
+
`State the concrete defect and user-visible or runtime impact directly. Keep each body to one short paragraph, at most two sentences, and at most 700 characters. Treat 700 as a hard ceiling, not a target; prefer 250-450 characters when possible.`,
|
|
3935
4075
|
"Do not include step-by-step reasoning, broad context, praise, restated diff, alternatives, or code snippets unless they are necessary to identify the defect.",
|
|
3936
4076
|
"Never copy a secret-looking literal from changed code into the review summary, inline finding body, or suggestedFix. Describe only the secret kind and location.",
|
|
3937
4077
|
"Omit speculative, style-only, broad refactor, external-fact, and out-of-diff findings.",
|
|
@@ -3950,14 +4090,15 @@ function pathScopePrompt(paths) {
|
|
|
3950
4090
|
].join("\n");
|
|
3951
4091
|
}
|
|
3952
4092
|
function priorFindingsPrompt(state) {
|
|
3953
|
-
const
|
|
3954
|
-
if (
|
|
4093
|
+
const findings = state?.findings.filter((finding) => finding.status === "open") ?? [];
|
|
4094
|
+
if (findings.length === 0) return;
|
|
3955
4095
|
return [
|
|
3956
4096
|
"Prior pipr findings:",
|
|
3957
4097
|
JSON.stringify({
|
|
3958
4098
|
reviewedHeadSha: state?.reviewedHeadSha,
|
|
3959
|
-
findings:
|
|
4099
|
+
findings: findings.map((finding) => ({
|
|
3960
4100
|
id: finding.id,
|
|
4101
|
+
status: finding.status,
|
|
3961
4102
|
path: finding.path,
|
|
3962
4103
|
rangeId: finding.rangeId,
|
|
3963
4104
|
side: finding.side,
|
|
@@ -4446,6 +4587,8 @@ const findingIdSchema = z.string().min(1).regex(/^[A-Za-z0-9_.-]+$/);
|
|
|
4446
4587
|
const priorFindingStatusSchema = z.enum(["open", "resolved"]);
|
|
4447
4588
|
const priorFindingRecordSchema = z.strictObject({
|
|
4448
4589
|
id: findingIdSchema,
|
|
4590
|
+
anchorFingerprint: z.string().regex(/^[a-f0-9]{64}$/).optional(),
|
|
4591
|
+
issueFingerprint: z.string().regex(/^[a-f0-9]{64}$/).optional(),
|
|
4449
4592
|
status: priorFindingStatusSchema,
|
|
4450
4593
|
path: z.string().min(1),
|
|
4451
4594
|
rangeId: z.string().min(1),
|
|
@@ -4469,33 +4612,23 @@ function buildPriorReviewState(options) {
|
|
|
4469
4612
|
const nextFindings = /* @__PURE__ */ new Map();
|
|
4470
4613
|
const usedPriorIds = /* @__PURE__ */ new Set();
|
|
4471
4614
|
const stats = accumulateReviewStats(scopedPriorState?.stats, options.stats);
|
|
4472
|
-
|
|
4473
|
-
|
|
4615
|
+
const findings = options.findings.map((item) => item.finding);
|
|
4616
|
+
const fingerprintCounts = countFindingFingerprints(options.findings);
|
|
4617
|
+
for (const { finding, anchorFingerprint, issueFingerprint, previousPath } of options.findings) {
|
|
4618
|
+
const record = buildFindingRecord({
|
|
4474
4619
|
finding,
|
|
4475
|
-
findings
|
|
4620
|
+
findings,
|
|
4476
4621
|
priorFindings,
|
|
4477
|
-
usedPriorIds
|
|
4622
|
+
usedPriorIds,
|
|
4623
|
+
reviewedHeadSha: options.reviewedHeadSha,
|
|
4624
|
+
anchorFingerprint,
|
|
4625
|
+
issueFingerprint,
|
|
4626
|
+
previousPath,
|
|
4627
|
+
fingerprintCounts
|
|
4478
4628
|
});
|
|
4479
|
-
|
|
4480
|
-
if (prior) usedPriorIds.add(prior.id);
|
|
4481
|
-
const record = {
|
|
4482
|
-
id,
|
|
4483
|
-
status: "open",
|
|
4484
|
-
path: finding.path,
|
|
4485
|
-
rangeId: finding.rangeId,
|
|
4486
|
-
side: finding.side,
|
|
4487
|
-
startLine: finding.startLine,
|
|
4488
|
-
endLine: finding.endLine,
|
|
4489
|
-
firstSeenHeadSha: prior?.firstSeenHeadSha ?? options.reviewedHeadSha,
|
|
4490
|
-
lastSeenHeadSha: options.reviewedHeadSha,
|
|
4491
|
-
...prior?.lastCommentedHeadSha ? { lastCommentedHeadSha: prior.lastCommentedHeadSha } : {}
|
|
4492
|
-
};
|
|
4493
|
-
nextFindings.set(id, record);
|
|
4494
|
-
}
|
|
4495
|
-
for (const prior of priorFindings.values()) {
|
|
4496
|
-
if (nextFindings.has(prior.id)) continue;
|
|
4497
|
-
nextFindings.set(prior.id, prior);
|
|
4629
|
+
nextFindings.set(record.id, record);
|
|
4498
4630
|
}
|
|
4631
|
+
addHistoricalFindings(nextFindings, priorFindings.values());
|
|
4499
4632
|
return {
|
|
4500
4633
|
version: 1,
|
|
4501
4634
|
reviewedHeadSha: options.reviewedHeadSha,
|
|
@@ -4504,6 +4637,57 @@ function buildPriorReviewState(options) {
|
|
|
4504
4637
|
...stats ? { stats } : {}
|
|
4505
4638
|
};
|
|
4506
4639
|
}
|
|
4640
|
+
function buildFindingRecord(options) {
|
|
4641
|
+
const selection = selectPriorFindingRecord(options);
|
|
4642
|
+
const prior = options.priorFindings.get(selection.id);
|
|
4643
|
+
markPriorFindingUsed(options.usedPriorIds, prior);
|
|
4644
|
+
return {
|
|
4645
|
+
id: selection.id,
|
|
4646
|
+
...findingIdentity(options.anchorFingerprint, options.issueFingerprint),
|
|
4647
|
+
status: selection.status,
|
|
4648
|
+
path: options.finding.path,
|
|
4649
|
+
rangeId: options.finding.rangeId,
|
|
4650
|
+
side: options.finding.side,
|
|
4651
|
+
startLine: options.finding.startLine,
|
|
4652
|
+
endLine: options.finding.endLine,
|
|
4653
|
+
...findingHistory(prior, options.reviewedHeadSha)
|
|
4654
|
+
};
|
|
4655
|
+
}
|
|
4656
|
+
function selectPriorFindingRecord(options) {
|
|
4657
|
+
const resolvedMatch = matchResolvedFindingRecord([...options.priorFindings.values()], options.finding, options.anchorFingerprint, options.issueFingerprint, options.fingerprintCounts, options.previousPath);
|
|
4658
|
+
if (resolvedMatch) return {
|
|
4659
|
+
id: resolvedMatch.id,
|
|
4660
|
+
status: "resolved"
|
|
4661
|
+
};
|
|
4662
|
+
return {
|
|
4663
|
+
id: selectFindingId({
|
|
4664
|
+
finding: options.finding,
|
|
4665
|
+
findings: options.findings,
|
|
4666
|
+
priorFindings: options.priorFindings,
|
|
4667
|
+
usedPriorIds: options.usedPriorIds
|
|
4668
|
+
}),
|
|
4669
|
+
status: "open"
|
|
4670
|
+
};
|
|
4671
|
+
}
|
|
4672
|
+
function markPriorFindingUsed(usedPriorIds, prior) {
|
|
4673
|
+
if (prior) usedPriorIds.add(prior.id);
|
|
4674
|
+
}
|
|
4675
|
+
function findingIdentity(anchorFingerprint, issueFingerprint) {
|
|
4676
|
+
return {
|
|
4677
|
+
...anchorFingerprint ? { anchorFingerprint } : {},
|
|
4678
|
+
...issueFingerprint ? { issueFingerprint } : {}
|
|
4679
|
+
};
|
|
4680
|
+
}
|
|
4681
|
+
function findingHistory(prior, reviewedHeadSha) {
|
|
4682
|
+
return {
|
|
4683
|
+
firstSeenHeadSha: prior?.firstSeenHeadSha ?? reviewedHeadSha,
|
|
4684
|
+
lastSeenHeadSha: reviewedHeadSha,
|
|
4685
|
+
...prior?.lastCommentedHeadSha ? { lastCommentedHeadSha: prior.lastCommentedHeadSha } : {}
|
|
4686
|
+
};
|
|
4687
|
+
}
|
|
4688
|
+
function addHistoricalFindings(findings, historicalFindings) {
|
|
4689
|
+
for (const finding of historicalFindings) if (!findings.has(finding.id)) findings.set(finding.id, finding);
|
|
4690
|
+
}
|
|
4507
4691
|
function resolvePriorFindings(state, findingIds) {
|
|
4508
4692
|
const resolved = new Set(findingIds);
|
|
4509
4693
|
return {
|
|
@@ -4523,6 +4707,22 @@ function matchFindingRecord(state, finding) {
|
|
|
4523
4707
|
if (deterministic) return deterministic;
|
|
4524
4708
|
return findOpenOverlappingFinding(state.findings, finding);
|
|
4525
4709
|
}
|
|
4710
|
+
function matchResolvedFindingRecord(records, finding, anchorFingerprint, issueFingerprint, currentFingerprintCounts, previousPath) {
|
|
4711
|
+
if (!anchorFingerprint || !issueFingerprint || (currentFingerprintCounts?.get(findingFingerprintKey(finding.path, anchorFingerprint, issueFingerprint)) ?? 1) !== 1) return;
|
|
4712
|
+
const candidates = records.filter((record) => record.anchorFingerprint === anchorFingerprint && record.issueFingerprint === issueFingerprint && (record.path === finding.path || record.path === previousPath));
|
|
4713
|
+
return candidates.length === 1 && candidates[0]?.status === "resolved" ? candidates[0] : void 0;
|
|
4714
|
+
}
|
|
4715
|
+
function countFindingFingerprints(findings) {
|
|
4716
|
+
const counts = /* @__PURE__ */ new Map();
|
|
4717
|
+
for (const { finding, anchorFingerprint, issueFingerprint } of findings) if (anchorFingerprint && issueFingerprint) {
|
|
4718
|
+
const key = findingFingerprintKey(finding.path, anchorFingerprint, issueFingerprint);
|
|
4719
|
+
counts.set(key, (counts.get(key) ?? 0) + 1);
|
|
4720
|
+
}
|
|
4721
|
+
return counts;
|
|
4722
|
+
}
|
|
4723
|
+
function findingFingerprintKey(path, anchorFingerprint, issueFingerprint) {
|
|
4724
|
+
return `${path}\0${anchorFingerprint}\0${issueFingerprint}`;
|
|
4725
|
+
}
|
|
4526
4726
|
function renderMainCommentMarker(options) {
|
|
4527
4727
|
return `<!-- ${options.marker} change=${options.changeNumber} version=1 state=${encodeReviewState({
|
|
4528
4728
|
...options.reviewState,
|
|
@@ -4587,6 +4787,20 @@ function applyResolvedFindingMarkers(state, commentBodies) {
|
|
|
4587
4787
|
}))
|
|
4588
4788
|
};
|
|
4589
4789
|
}
|
|
4790
|
+
function applyNativeThreadResolutions(state, resolutions) {
|
|
4791
|
+
const resolutionByFinding = new Map(resolutions.map((resolution) => [`${resolution.findingId}:${resolution.findingHeadSha}`, resolution.resolved]));
|
|
4792
|
+
return {
|
|
4793
|
+
...state,
|
|
4794
|
+
findings: state.findings.map((finding) => {
|
|
4795
|
+
if (!finding.lastCommentedHeadSha) return finding;
|
|
4796
|
+
const resolved = resolutionByFinding.get(`${finding.id}:${finding.lastCommentedHeadSha}`);
|
|
4797
|
+
return resolved === void 0 ? finding : {
|
|
4798
|
+
...finding,
|
|
4799
|
+
status: resolved ? "resolved" : "open"
|
|
4800
|
+
};
|
|
4801
|
+
})
|
|
4802
|
+
};
|
|
4803
|
+
}
|
|
4590
4804
|
function extractVerifierResponseMarkers(commentBodies) {
|
|
4591
4805
|
return new Set(extractMarkerRecords(commentBodies, verifierResponseMarkerPrefix).map((record) => record.marker));
|
|
4592
4806
|
}
|
|
@@ -4782,7 +4996,7 @@ function publicationPlanForHostCapabilities(plan, capabilities) {
|
|
|
4782
4996
|
}
|
|
4783
4997
|
function buildPublicationPlan(options) {
|
|
4784
4998
|
const reviewState = options.reviewState ?? buildPriorReviewState({
|
|
4785
|
-
findings: options.inlineItems.map((item) => item.finding),
|
|
4999
|
+
findings: options.inlineItems.map((item) => ({ finding: item.finding })),
|
|
4786
5000
|
reviewedHeadSha: options.metadata.reviewedHeadSha,
|
|
4787
5001
|
selectedTasks: options.metadata.selectedTasks
|
|
4788
5002
|
});
|
|
@@ -4827,10 +5041,12 @@ function preparePublishableInlineFindings(options) {
|
|
|
4827
5041
|
}
|
|
4828
5042
|
function prepareInlinePublicationItemsForPublishableFindings(options) {
|
|
4829
5043
|
const seenFindingIds = /* @__PURE__ */ new Set();
|
|
4830
|
-
|
|
5044
|
+
const fingerprintCounts = countFindingFingerprints(options.publishableFindings);
|
|
5045
|
+
return inlinePublicationItemsSchema.parse(options.publishableFindings.flatMap(({ finding: publishableFinding, range, previousPath, anchorFingerprint, issueFingerprint }) => {
|
|
4831
5046
|
const findingId = findingIdFor(publishableFinding, options.reviewState);
|
|
4832
5047
|
const stateRecord = options.reviewState ? matchFindingRecord(options.reviewState, publishableFinding) : void 0;
|
|
4833
|
-
|
|
5048
|
+
const resolvedRecord = options.reviewState ? matchResolvedFindingRecord(options.reviewState.findings, publishableFinding, anchorFingerprint, issueFingerprint, fingerprintCounts, previousPath) : void 0;
|
|
5049
|
+
if (seenFindingIds.has(findingId) || resolvedRecord !== void 0 || stateRecord?.lastCommentedHeadSha === options.reviewedHeadSha) return [];
|
|
4834
5050
|
seenFindingIds.add(findingId);
|
|
4835
5051
|
const marker = inlineFindingMarker(findingId, options.reviewedHeadSha);
|
|
4836
5052
|
return [inlinePublicationItemSchema.parse({
|
|
@@ -4977,10 +5193,17 @@ function buildCommentPublishingPlan(options) {
|
|
|
4977
5193
|
const publishableInlineFindings = preparePublishableInlineFindings({
|
|
4978
5194
|
validated: options.validated,
|
|
4979
5195
|
manifest: options.manifest
|
|
5196
|
+
}).map((item) => {
|
|
5197
|
+
const fingerprint = selectedCodeFingerprint(item.finding, item.range);
|
|
5198
|
+
return fingerprint ? {
|
|
5199
|
+
...item,
|
|
5200
|
+
anchorFingerprint: fingerprint,
|
|
5201
|
+
issueFingerprint: findingIssueFingerprint(item.finding)
|
|
5202
|
+
} : item;
|
|
4980
5203
|
});
|
|
4981
5204
|
const reviewState = buildPriorReviewState({
|
|
4982
5205
|
priorState: options.priorReviewState,
|
|
4983
|
-
findings: publishableInlineFindings
|
|
5206
|
+
findings: publishableInlineFindings,
|
|
4984
5207
|
reviewedHeadSha: options.event.change.head.sha,
|
|
4985
5208
|
selectedTasks: options.metadata.selectedTasks,
|
|
4986
5209
|
stats: options.metadata.stats
|
|
@@ -5011,6 +5234,20 @@ function buildCommentPublishingPlan(options) {
|
|
|
5011
5234
|
inlineCommentDrafts: publicationPlan.inlineItems
|
|
5012
5235
|
};
|
|
5013
5236
|
}
|
|
5237
|
+
function selectedCodeFingerprint(finding, range) {
|
|
5238
|
+
if (range.preview === void 0) return;
|
|
5239
|
+
const lines = range.preview.replaceAll("\r\n", "\n").replaceAll("\r", "\n").split("\n");
|
|
5240
|
+
const startOffset = finding.startLine - range.startLine;
|
|
5241
|
+
const endOffset = finding.endLine - range.startLine + 1;
|
|
5242
|
+
if (startOffset < 0 || endOffset > lines.length) return;
|
|
5243
|
+
const selected = lines.slice(startOffset, endOffset).map((line) => line.trimEnd()).join("\n");
|
|
5244
|
+
return new Bun.CryptoHasher("sha256").update(selected).digest("hex");
|
|
5245
|
+
}
|
|
5246
|
+
function findingIssueFingerprint(finding) {
|
|
5247
|
+
const identity = finding.body.normalize("NFKC").toLowerCase().replace(/<[^>]*>/g, " ").replace(/\[([^\]]+)\]\([^)]*\)/g, "$1").replace(/[^\p{L}\p{N}_]+/gu, " ").trim().replace(/\s+/g, " ") || finding.body.normalize("NFKC").toLowerCase().trim();
|
|
5248
|
+
if (!identity) return;
|
|
5249
|
+
return new Bun.CryptoHasher("sha256").update(identity).digest("hex");
|
|
5250
|
+
}
|
|
5014
5251
|
//#endregion
|
|
5015
5252
|
//#region src/review/publication-redaction.ts
|
|
5016
5253
|
function redactReviewPublication(options) {
|
|
@@ -6417,8 +6654,17 @@ async function loadAzureDevOpsPriorReviewState(options) {
|
|
|
6417
6654
|
const state = extractPriorReviewState(await loadAzureDevOpsPriorMainComment(options), options.change.change.number);
|
|
6418
6655
|
if (!state) return void 0;
|
|
6419
6656
|
const owner = await authenticatedAzureOwner(options.client);
|
|
6420
|
-
const
|
|
6421
|
-
|
|
6657
|
+
const threads = await options.client.listThreads(azureCoordinates$1(options.change).repositoryId, options.change.change.number);
|
|
6658
|
+
const bodies = ownedThreadComments(threads, owner.uniqueName).map((comment) => comment.content);
|
|
6659
|
+
return applyNativeThreadResolutions(applyResolvedFindingMarkers(applyInlineFindingMarkers(state, bodies), bodies), threads.flatMap((thread) => {
|
|
6660
|
+
const root = thread.comments[0];
|
|
6661
|
+
const marker = root ? extractInlineFindingMarkerRecords([root.content])[0] : void 0;
|
|
6662
|
+
return root && marker && root.author?.uniqueName === owner.uniqueName ? [{
|
|
6663
|
+
findingId: marker.id,
|
|
6664
|
+
findingHeadSha: marker.head,
|
|
6665
|
+
resolved: isResolved(thread)
|
|
6666
|
+
}] : [];
|
|
6667
|
+
}));
|
|
6422
6668
|
}
|
|
6423
6669
|
async function loadAzureDevOpsPriorMainComment(options) {
|
|
6424
6670
|
const owner = await authenticatedAzureOwner(options.client);
|
|
@@ -7027,7 +7273,14 @@ async function loadBitbucketPriorReviewState(options) {
|
|
|
7027
7273
|
const state = extractPriorReviewState(body ? normalizeBitbucketMarkdown(body) : void 0, options.change.change.number);
|
|
7028
7274
|
if (!state) return void 0;
|
|
7029
7275
|
const bodies = comments.map((comment) => normalizeBitbucketMarkdown(comment.content.raw));
|
|
7030
|
-
return applyResolvedFindingMarkers(applyInlineFindingMarkers(state, bodies), bodies)
|
|
7276
|
+
return applyNativeThreadResolutions(applyResolvedFindingMarkers(applyInlineFindingMarkers(state, bodies), bodies), comments.flatMap((comment) => {
|
|
7277
|
+
const marker = !comment.parent ? extractInlineFindingMarkerRecords([normalizeBitbucketMarkdown(comment.content.raw)])[0] : void 0;
|
|
7278
|
+
return marker ? [{
|
|
7279
|
+
findingId: marker.id,
|
|
7280
|
+
findingHeadSha: marker.head,
|
|
7281
|
+
resolved: comment.resolution !== void 0
|
|
7282
|
+
}] : [];
|
|
7283
|
+
}));
|
|
7031
7284
|
}
|
|
7032
7285
|
async function loadBitbucketPriorMainComment(options) {
|
|
7033
7286
|
const body = (await loadBitbucketOwnedComments(options)).find((comment) => normalizeBitbucketMarkdown(comment.content.raw).includes(mainMarker$1(options.change.change.number)))?.content.raw;
|
|
@@ -7893,23 +8146,20 @@ async function loadGitHubPriorReviewState(options) {
|
|
|
7893
8146
|
ownerLogin
|
|
7894
8147
|
}), options.change.change.number);
|
|
7895
8148
|
if (!state) return;
|
|
7896
|
-
const
|
|
7897
|
-
|
|
7898
|
-
|
|
7899
|
-
|
|
7900
|
-
|
|
8149
|
+
const { ownerComments, threadByCommentId } = await loadOwnedReviewThreads(options, ownerLogin);
|
|
8150
|
+
const inlineBodies = ownerComments.map((comment) => comment.body ?? "");
|
|
8151
|
+
return applyNativeThreadResolutions(applyResolvedFindingMarkers(applyInlineFindingMarkers(state, inlineBodies), inlineBodies), ownerComments.flatMap((comment) => {
|
|
8152
|
+
const marker = extractInlineFindingMarkerRecords([comment.body ?? ""])[0];
|
|
8153
|
+
const thread = threadByCommentId.get(comment.id);
|
|
8154
|
+
return marker && thread ? [{
|
|
8155
|
+
findingId: marker.id,
|
|
8156
|
+
findingHeadSha: marker.head,
|
|
8157
|
+
resolved: thread.isResolved
|
|
8158
|
+
}] : [];
|
|
8159
|
+
}));
|
|
7901
8160
|
}
|
|
7902
8161
|
async function loadGitHubInlineThreadContexts(options) {
|
|
7903
|
-
const
|
|
7904
|
-
const comments = await options.client.listReviewComments({
|
|
7905
|
-
repo: options.change.repository.slug,
|
|
7906
|
-
pullRequestNumber: options.change.change.number
|
|
7907
|
-
});
|
|
7908
|
-
const ownerComments = comments.filter((comment) => comment.authorLogin === ownerLogin);
|
|
7909
|
-
const threadByCommentId = reviewThreadByCommentId(await options.client.listReviewThreads({
|
|
7910
|
-
repo: options.change.repository.slug,
|
|
7911
|
-
pullRequestNumber: options.change.change.number
|
|
7912
|
-
}));
|
|
8162
|
+
const { comments, ownerComments, threadByCommentId } = await loadOwnedReviewThreads(options, await options.client.getAuthenticatedUserLogin());
|
|
7913
8163
|
const commentById = new Map(comments.map((comment) => [comment.id, comment]));
|
|
7914
8164
|
return ownerComments.flatMap((comment) => {
|
|
7915
8165
|
const marker = extractInlineFindingMarkerRecords([comment.body ?? ""])[0];
|
|
@@ -7933,6 +8183,19 @@ async function loadGitHubInlineThreadContexts(options) {
|
|
|
7933
8183
|
}];
|
|
7934
8184
|
});
|
|
7935
8185
|
}
|
|
8186
|
+
async function loadOwnedReviewThreads(options, ownerLogin) {
|
|
8187
|
+
const coordinates = {
|
|
8188
|
+
repo: options.change.repository.slug,
|
|
8189
|
+
pullRequestNumber: options.change.change.number
|
|
8190
|
+
};
|
|
8191
|
+
const comments = await options.client.listReviewComments(coordinates);
|
|
8192
|
+
const threads = await options.client.listReviewThreads(coordinates);
|
|
8193
|
+
return {
|
|
8194
|
+
comments,
|
|
8195
|
+
ownerComments: comments.filter((comment) => comment.authorLogin === ownerLogin),
|
|
8196
|
+
threadByCommentId: reviewThreadByCommentId(threads)
|
|
8197
|
+
};
|
|
8198
|
+
}
|
|
7936
8199
|
async function loadGitHubPriorMainComment(options) {
|
|
7937
8200
|
const ownerLogin = options.ownerLogin ?? await options.client.getAuthenticatedUserLogin();
|
|
7938
8201
|
return findMainComment(await options.client.listIssueComments({
|
|
@@ -8723,8 +8986,17 @@ async function loadGitLabPriorReviewState(options) {
|
|
|
8723
8986
|
const state = extractPriorReviewState(await loadGitLabPriorMainComment(options), options.change.change.number);
|
|
8724
8987
|
if (!state) return void 0;
|
|
8725
8988
|
const owner = await options.client.currentUser();
|
|
8726
|
-
const
|
|
8727
|
-
|
|
8989
|
+
const discussions = await options.client.listDiscussions(gitLabCoordinates$1(options.change).projectId, options.change.change.number);
|
|
8990
|
+
const bodies = discussionNotes(discussions).filter((note) => note.author?.username === owner.username).map((note) => note.body);
|
|
8991
|
+
return applyNativeThreadResolutions(applyResolvedFindingMarkers(applyInlineFindingMarkers(state, bodies), bodies), discussions.flatMap((discussion) => {
|
|
8992
|
+
const root = discussion.notes[0];
|
|
8993
|
+
const marker = root ? extractInlineFindingMarkerRecords([root.body])[0] : void 0;
|
|
8994
|
+
return root && marker && root.author?.username === owner.username ? [{
|
|
8995
|
+
findingId: marker.id,
|
|
8996
|
+
findingHeadSha: marker.head,
|
|
8997
|
+
resolved: root.resolved ?? false
|
|
8998
|
+
}] : [];
|
|
8999
|
+
}));
|
|
8728
9000
|
}
|
|
8729
9001
|
async function loadGitLabPriorMainComment(options) {
|
|
8730
9002
|
const owner = await options.client.currentUser();
|
|
@@ -9982,4 +10254,4 @@ async function runHostRunCommandWithDependencies(options) {
|
|
|
9982
10254
|
//#endregion
|
|
9983
10255
|
export { piReadOnlyToolNames as _, runInspectCommand as a, createGitHubHostAdapter as c, createGitLabClient as d, createBitbucketClient as f, piBuiltinToolNames as g, supportedOfficialInitAdapters as h, runInitCommand as i, PublicationError as l, azureOrganizationFromUrl as m, runHostRunCommand as n, runLocalReviewCommand as o, createAzureDevOpsClient as p, runHostRunCommandWithDependencies as r, runValidateCommand as s, runDryRunCommand as t, createKnownSecretRedactor as u, piRequiredCliFlags as v, piThinkingLevels as y };
|
|
9984
10256
|
|
|
9985
|
-
//# sourceMappingURL=commands-
|
|
10257
|
+
//# sourceMappingURL=commands-EZV-Icbs.mjs.map
|