@usepipr/runtime 0.3.7 → 0.3.8

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.
@@ -58,6 +58,9 @@ declare const piprConfigSchema: z.ZodObject<{
58
58
  }>;
59
59
  }, z.core.$strict>;
60
60
  }, z.core.$strict>;
61
+ showHeader: z.ZodDefault<z.ZodBoolean>;
62
+ showFooter: z.ZodDefault<z.ZodBoolean>;
63
+ showStats: z.ZodDefault<z.ZodBoolean>;
61
64
  }, z.core.$strict>;
62
65
  limits: z.ZodOptional<z.ZodObject<{
63
66
  timeoutSeconds: z.ZodOptional<z.ZodNumber>;
@@ -105,6 +108,9 @@ declare const runtimeSettingsSchema: z.ZodObject<{
105
108
  }>;
106
109
  }, z.core.$strict>;
107
110
  }, z.core.$strict>;
111
+ showHeader: z.ZodDefault<z.ZodBoolean>;
112
+ showFooter: z.ZodDefault<z.ZodBoolean>;
113
+ showStats: z.ZodDefault<z.ZodBoolean>;
108
114
  }, z.core.$strict>;
109
115
  limits: z.ZodOptional<z.ZodObject<{
110
116
  timeoutSeconds: z.ZodOptional<z.ZodNumber>;
@@ -261,6 +267,19 @@ declare const priorReviewStateSchema: z.ZodObject<{
261
267
  lastSeenHeadSha: z.ZodString;
262
268
  lastCommentedHeadSha: z.ZodOptional<z.ZodString>;
263
269
  }, z.core.$strict>>;
270
+ stats: z.ZodOptional<z.ZodObject<{
271
+ models: z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
272
+ agentRuns: z.ZodNumber;
273
+ durationMs: z.ZodNumber;
274
+ inputTokens: z.ZodNumber;
275
+ outputTokens: z.ZodNumber;
276
+ costUsd: z.ZodNumber;
277
+ usageStatus: z.ZodEnum<{
278
+ complete: "complete";
279
+ partial: "partial";
280
+ unavailable: "unavailable";
281
+ }>;
282
+ }, z.core.$strict>>;
264
283
  }, z.core.$strict>;
265
284
  type PriorReviewState = z.infer<typeof priorReviewStateSchema>;
266
285
  //#endregion
@@ -380,6 +399,19 @@ declare const publicationPlanSchema: z.ZodObject<{
380
399
  lastSeenHeadSha: z.ZodString;
381
400
  lastCommentedHeadSha: z.ZodOptional<z.ZodString>;
382
401
  }, z.core.$strict>>;
402
+ stats: z.ZodOptional<z.ZodObject<{
403
+ models: z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>;
404
+ agentRuns: z.ZodNumber;
405
+ durationMs: z.ZodNumber;
406
+ inputTokens: z.ZodNumber;
407
+ outputTokens: z.ZodNumber;
408
+ costUsd: z.ZodNumber;
409
+ usageStatus: z.ZodEnum<{
410
+ complete: "complete";
411
+ partial: "partial";
412
+ unavailable: "unavailable";
413
+ }>;
414
+ }, z.core.$strict>>;
383
415
  }, z.core.$strict>;
384
416
  threadActions: z.ZodArray<z.ZodObject<{
385
417
  kind: z.ZodEnum<{
@@ -898,4 +930,4 @@ declare function runActionCommand(options: ActionCommandOptions): Promise<Action
898
930
  declare function runActionCommandWithDependencies(options: ActionCommandDependencyOptions): Promise<ActionCommandResult>;
899
931
  //#endregion
900
932
  export { PlatformInfo as A, GitHubPublicationClient as C, ChangeRequestRef as D, ChangeRequestEventContext as E, supportedOfficialInitAdapters as F, RepositoryRef as M, RuntimeSettings as N, DiffManifest as O, OfficialInitAdapter as P, ActionLogSink as S, PublicationResult as T, piBuiltinToolNames as _, runInspectCommand as a, piThinkingLevels as b, ActionCommandOptions as c, DryRunCommandResult as d, InitCommandOptions as f, RuntimeCommandOptions as g, LocalReviewCommandResult as h, runInitCommand as i, ProviderConfig as j, PiprConfig as k, ActionCommandResult as l, LocalReviewCommandOptions as m, runActionCommandWithDependencies as n, runLocalReviewCommand as o, InspectCommandResult as p, runDryRunCommand as r, runValidateCommand as s, runActionCommand as t, DryRunCommandOptions as u, piReadOnlyToolNames as v, PublicationError as w, ActionLogRecord as x, piRequiredCliFlags as y };
901
- //# sourceMappingURL=commands-Bcta0T4L.d.mts.map
933
+ //# sourceMappingURL=commands-C5_GHGxN.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands-C5_GHGxN.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/hosts/github/command.ts","../src/hosts/github/publication-client.ts","../src/shared/logging.ts","../src/pi/contract.ts","../src/review/task/task-output.ts","../src/review/task/task-runtime.ts","../src/action/types.ts","../src/action/commands.ts"],"mappings":";;;;KAsBY;EACV;EACA;EACA;;cAGW;KAED,8BAA8B;;;cCCpC,sBAAoB,EAAA;;;;;;;;;;;;;;cAyBpB,kBAAgB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAkBhB,uBAAqB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAMrB,oBAAkB,EAAA;;;;cAKlB,qBAAmB,EAAA;;;;cAanB,wBAAsB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAWtB,iCAA+B,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAqE/B,uBAAqB,EAAA;;;;;;;;cAMrB,8BAA4B,EAAA;;;;;;;KAEtB,iBAAiB,EAAE,aAAa;KAGhC,aAAa,EAAE,aAAa;KAC5B,kBAAkB,EAAE,aAAa;KACjC,eAAe,EAAE,aAAa;KAC9B,gBAAgB,EAAE,aAAa;KAC/B,mBAAmB,EAAE,aAAa;KAClC,4BAA4B,EAAE,aAAa;KAE3C,kBAAkB,EAAE,aAAa;KACjC,yBAAyB,EAAE,aAAa;;;KC7KxC;EACV;EACA;EACA;EACA;EACA,QAAQ;IAAQ;IAAc;;EAC9B,UAAU;IAAQ;IAAiB;IAAc;;EACjD;EACA;;;;cCCW,wBAAsB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KASvB,mBAAmB,EAAE,aAAa;;;cCAxC,6BAA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ACpB,SAAS,wBACR,QAAQ;;iBASW,iBACpB,SAAS,uBACR,QAAQ;;iBAoBW,sBACpB,SAAS,4BACR,QAAQ;;iBA2EW,iBACpB,SAAS,uBACR,QAAQ;iBAIW,iCACpB,SAAS,iCACR,QAAQ"}
@@ -272,7 +272,10 @@ const piprConfigSchema = z.strictObject({
272
272
  providers: z.array(providerConfigSchema).min(1),
273
273
  publication: z.strictObject({
274
274
  maxInlineComments: z.number().int().min(0).max(50).optional(),
275
- autoResolve: autoResolveConfigSchema
275
+ autoResolve: autoResolveConfigSchema,
276
+ showHeader: z.boolean().default(true),
277
+ showFooter: z.boolean().default(true),
278
+ showStats: z.boolean().default(true)
276
279
  }),
277
280
  limits: z.strictObject({
278
281
  timeoutSeconds: z.number().int().positive().max(3600).optional(),
@@ -526,7 +529,7 @@ function compareStableSemver(left, right) {
526
529
  }
527
530
  //#endregion
528
531
  //#region src/shared/version.ts
529
- const runtimeVersion = "0.3.7";
532
+ const runtimeVersion = "0.3.8";
530
533
  //#endregion
531
534
  //#region src/config/version-compat.ts
532
535
  async function resolveConfigVersionCompatibility(options) {
@@ -776,7 +779,10 @@ function planToRuntimeSettings(plan, options) {
776
779
  providers,
777
780
  publication: {
778
781
  maxInlineComments: plan.publication.maxInlineComments,
779
- autoResolve: normalizeAutoResolveConfig(plan.publication.autoResolve, defaultProvider.id)
782
+ autoResolve: normalizeAutoResolveConfig(plan.publication.autoResolve, defaultProvider.id),
783
+ showHeader: plan.publication.showHeader ?? true,
784
+ showFooter: plan.publication.showFooter ?? true,
785
+ showStats: plan.publication.showStats ?? true
780
786
  },
781
787
  limits: plan.limits
782
788
  },
@@ -3544,8 +3550,8 @@ function isOfficialInitRecipeId(recipe) {
3544
3550
  //#endregion
3545
3551
  //#region src/config/init.ts
3546
3552
  const supportedOfficialInitAdapters = ["github"];
3547
- const defaultWorkflowActionRef = "somus/pipr@v0.3.7";
3548
- const defaultSdkVersion = "0.3.7";
3553
+ const defaultWorkflowActionRef = "somus/pipr@v0.3.8";
3554
+ const defaultSdkVersion = "0.3.8";
3549
3555
  function resolveOfficialInitAdapters(adapters) {
3550
3556
  if (adapters === void 0) return [...supportedOfficialInitAdapters];
3551
3557
  if (adapters.length === 0) return [];
@@ -5756,10 +5762,63 @@ const mainCommentTitles = /* @__PURE__ */ new Set([
5756
5762
  "# Pipr Review",
5757
5763
  mainCommentTitle
5758
5764
  ]);
5765
+ const mainCommentHeaderHiddenMarker = "<!-- pipr:header:hidden -->";
5766
+ const mainCommentFooterHiddenMarker = "<!-- pipr:footer:hidden -->";
5759
5767
  const reviewStatsStartMarker = "<!-- pipr:stats:start -->";
5760
5768
  const reviewStatsEndMarker = "<!-- pipr:stats:end -->";
5769
+ const reviewStatsHiddenMarker = "<!-- pipr:stats:hidden -->";
5761
5770
  const escapedRepositoryUrl = piprRepositoryUrl.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
5762
5771
  const mainCommentAttributionPattern = new RegExp(`^<sub>Review generated by \\[Pipr\\]\\(${escapedRepositoryUrl}\\) for commit \`[^\`]+\`\\.(?: Config SDK \\d+\\.\\d+\\.\\d+ is behind (?:Pipr \\d+\\.\\d+\\.\\d+|\\[Pipr \\d+\\.\\d+\\.\\d+\\]\\(${escapedRepositoryUrl}/releases/tag/v\\d+\\.\\d+\\.\\d+\\))\\.)?</sub>$`);
5772
+ const maxReviewStatsModelLength = 200;
5773
+ const credentialLikeModelPattern = /(?:(?:AKIA|ASIA)[0-9A-Z]{16}|AIza[0-9A-Za-z_-]{35}|(?:sk|rk)_live_[A-Za-z0-9]{16,}|sk-(?:proj-)?[A-Za-z0-9_-]{16,}|gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{16,}|glpat-[A-Za-z0-9_-]{16,}|npm_[A-Za-z0-9]{16,}|xox[baprs]-[A-Za-z0-9-]{16,})/i;
5774
+ const highEntropyModelSegmentPattern = /[A-Za-z0-9]{24,}/;
5775
+ const reviewStatsModelSchema = z.string().min(1).max(maxReviewStatsModelLength).transform((model) => sanitizeReviewStatsModel(model) ?? "[invalid model]");
5776
+ const reviewStatsSchema = z.strictObject({
5777
+ models: z.array(reviewStatsModelSchema).min(1).max(20),
5778
+ agentRuns: z.number().int().positive(),
5779
+ durationMs: z.number().int().nonnegative(),
5780
+ inputTokens: z.number().int().nonnegative(),
5781
+ outputTokens: z.number().int().nonnegative(),
5782
+ costUsd: z.number().nonnegative(),
5783
+ usageStatus: z.enum([
5784
+ "complete",
5785
+ "partial",
5786
+ "unavailable"
5787
+ ])
5788
+ });
5789
+ function accumulateReviewStats(prior, current) {
5790
+ if (!prior) return current;
5791
+ if (!current) return prior;
5792
+ const inputTokens = addUsageTotal(prior.inputTokens, current.inputTokens, Number.isSafeInteger);
5793
+ const outputTokens = addUsageTotal(prior.outputTokens, current.outputTokens, Number.isSafeInteger);
5794
+ const costUsd = addUsageTotal(prior.costUsd, current.costUsd, Number.isFinite);
5795
+ const usageStatus = inputTokens.complete && outputTokens.complete && costUsd.complete && prior.usageStatus === current.usageStatus ? prior.usageStatus : "partial";
5796
+ return {
5797
+ models: [.../* @__PURE__ */ new Set([...prior.models, ...current.models])].slice(0, 20),
5798
+ agentRuns: Math.min(Number.MAX_SAFE_INTEGER, prior.agentRuns + current.agentRuns),
5799
+ durationMs: Math.min(Number.MAX_SAFE_INTEGER, prior.durationMs + current.durationMs),
5800
+ inputTokens: inputTokens.total,
5801
+ outputTokens: outputTokens.total,
5802
+ costUsd: costUsd.total,
5803
+ usageStatus
5804
+ };
5805
+ }
5806
+ function addUsageTotal(prior, current, isValid) {
5807
+ const total = prior + current;
5808
+ return isValid(total) && total >= 0 ? {
5809
+ total,
5810
+ complete: true
5811
+ } : {
5812
+ total: prior,
5813
+ complete: false
5814
+ };
5815
+ }
5816
+ function sanitizeReviewStatsModel(model) {
5817
+ const normalized = model.replace(/\s+/g, " ").trim();
5818
+ if (credentialLikeModelPattern.test(normalized) || highEntropyModelSegmentPattern.test(normalized)) return "[redacted credential]";
5819
+ const sanitized = redactPotentialSecrets(normalized);
5820
+ return sanitized ? sanitized.slice(0, maxReviewStatsModelLength) : void 0;
5821
+ }
5763
5822
  //#endregion
5764
5823
  //#region src/review/prior-state.ts
5765
5824
  const mainCommentMarker = "pipr:main-comment";
@@ -5785,7 +5844,8 @@ const priorReviewStateSchema = z.strictObject({
5785
5844
  version: z.literal(1),
5786
5845
  reviewedHeadSha: z.string().min(1),
5787
5846
  selectedTasks: z.array(z.string().min(1)),
5788
- findings: z.array(priorFindingRecordSchema)
5847
+ findings: z.array(priorFindingRecordSchema),
5848
+ stats: reviewStatsSchema.optional()
5789
5849
  });
5790
5850
  function buildPriorReviewState(options) {
5791
5851
  const scopedPriorState = priorReviewStateForSelectedTasks(options.priorState, options.selectedTasks);
@@ -5793,6 +5853,7 @@ function buildPriorReviewState(options) {
5793
5853
  const nextFindings = /* @__PURE__ */ new Map();
5794
5854
  const currentFindingIds = /* @__PURE__ */ new Set();
5795
5855
  const usedPriorIds = /* @__PURE__ */ new Set();
5856
+ const stats = accumulateReviewStats(scopedPriorState?.stats, options.stats);
5796
5857
  for (const finding of options.findings) {
5797
5858
  const id = selectFindingId({
5798
5859
  finding,
@@ -5825,7 +5886,8 @@ function buildPriorReviewState(options) {
5825
5886
  version: 1,
5826
5887
  reviewedHeadSha: options.reviewedHeadSha,
5827
5888
  selectedTasks: options.selectedTasks,
5828
- findings: cappedFindings([...nextFindings.values()], currentFindingIds)
5889
+ findings: cappedFindings([...nextFindings.values()], currentFindingIds),
5890
+ ...stats ? { stats } : {}
5829
5891
  };
5830
5892
  }
5831
5893
  function resolvePriorFindings(state, findingIds) {
@@ -6017,29 +6079,6 @@ function parseAttrs(input) {
6017
6079
  function hashParts(parts) {
6018
6080
  return new Bun.CryptoHasher("sha256").update(parts.join("\n")).digest("hex").slice(0, 16);
6019
6081
  }
6020
- const maxReviewStatsModelLength = 200;
6021
- const credentialLikeModelPattern = /(?:(?:AKIA|ASIA)[0-9A-Z]{16}|AIza[0-9A-Za-z_-]{35}|(?:sk|rk)_live_[A-Za-z0-9]{16,}|sk-(?:proj-)?[A-Za-z0-9_-]{16,}|gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{16,}|glpat-[A-Za-z0-9_-]{16,}|npm_[A-Za-z0-9]{16,}|xox[baprs]-[A-Za-z0-9-]{16,})/i;
6022
- const highEntropyModelSegmentPattern = /[A-Za-z0-9]{24,}/;
6023
- const reviewStatsModelSchema = z.string().min(1).max(maxReviewStatsModelLength).transform((model) => sanitizeReviewStatsModel(model) ?? "[invalid model]");
6024
- const reviewStatsSchema = z.strictObject({
6025
- models: z.array(reviewStatsModelSchema).min(1).max(20),
6026
- agentRuns: z.number().int().positive(),
6027
- durationMs: z.number().int().nonnegative(),
6028
- inputTokens: z.number().int().nonnegative(),
6029
- outputTokens: z.number().int().nonnegative(),
6030
- costUsd: z.number().nonnegative(),
6031
- usageStatus: z.enum([
6032
- "complete",
6033
- "partial",
6034
- "unavailable"
6035
- ])
6036
- });
6037
- function sanitizeReviewStatsModel(model) {
6038
- const normalized = model.replace(/\s+/g, " ").trim();
6039
- if (credentialLikeModelPattern.test(normalized) || highEntropyModelSegmentPattern.test(normalized)) return "[redacted credential]";
6040
- const sanitized = redactPotentialSecrets(normalized);
6041
- return sanitized ? sanitized.slice(0, maxReviewStatsModelLength) : void 0;
6042
- }
6043
6082
  //#endregion
6044
6083
  //#region src/review/comment.ts
6045
6084
  const inlinePublicationItemSchema = z.strictObject({
@@ -6125,7 +6164,10 @@ function buildPublicationPlan(options) {
6125
6164
  event: options.event,
6126
6165
  reviewState,
6127
6166
  main: options.main,
6128
- metadata
6167
+ metadata,
6168
+ showHeader: options.showHeader ?? true,
6169
+ showFooter: options.showFooter ?? true,
6170
+ showStats: options.showStats ?? true
6129
6171
  }),
6130
6172
  mainMarker: mainCommentMarker,
6131
6173
  changeNumber: options.event.change.number,
@@ -6209,14 +6251,14 @@ function renderMainComment(options) {
6209
6251
  reviewState: options.reviewState
6210
6252
  }),
6211
6253
  "",
6212
- mainCommentTitle,
6213
- "",
6254
+ ...!options.showHeader ? [mainCommentHeaderHiddenMarker, ""] : [],
6255
+ ...options.showHeader ? [mainCommentTitle, ""] : [],
6214
6256
  ...options.metadata.validFindings > 0 ? [`**Findings:** ${options.metadata.validFindings}`, ""] : [],
6215
6257
  redactPotentialSecrets(options.main),
6216
6258
  "",
6217
- ...options.metadata.stats ? [renderReviewStats(options.metadata.stats), ""] : [],
6218
- renderMainCommentAttribution(options.metadata),
6219
- ""
6259
+ ...!options.showStats || !options.metadata.stats ? [reviewStatsHiddenMarker, ""] : [],
6260
+ ...options.showStats && options.metadata.stats ? [renderReviewStats(options.metadata.stats), ""] : [],
6261
+ ...options.showFooter ? [renderMainCommentAttribution(options.metadata), ""] : [mainCommentFooterHiddenMarker, ""]
6220
6262
  ].join("\n");
6221
6263
  }
6222
6264
  function renderReviewStats(stats) {
@@ -6307,7 +6349,8 @@ function buildCommentPublishingPlan(options) {
6307
6349
  priorState: options.priorReviewState,
6308
6350
  findings: publishableInlineFindings.map((item) => item.finding),
6309
6351
  reviewedHeadSha: options.event.change.head.sha,
6310
- selectedTasks: options.metadata.selectedTasks
6352
+ selectedTasks: options.metadata.selectedTasks,
6353
+ stats: options.metadata.stats
6311
6354
  });
6312
6355
  const inlineCommentDrafts = prepareInlinePublicationItemsForPublishableFindings({
6313
6356
  publishableFindings: publishableInlineFindings,
@@ -6319,7 +6362,13 @@ function buildCommentPublishingPlan(options) {
6319
6362
  main: options.main,
6320
6363
  inlineItems: inlineCommentDrafts,
6321
6364
  maxInlineComments: options.maxInlineComments,
6322
- metadata: options.metadata,
6365
+ showHeader: options.showHeader,
6366
+ showFooter: options.showFooter,
6367
+ showStats: options.showStats,
6368
+ metadata: {
6369
+ ...options.metadata,
6370
+ ...reviewState.stats ? { stats: reviewState.stats } : {}
6371
+ },
6323
6372
  reviewState,
6324
6373
  threadActions: options.threadActions
6325
6374
  });
@@ -6762,19 +6811,34 @@ function priorReviewForTask(priorMainComment, priorReviewState) {
6762
6811
  }
6763
6812
  function visibleMainComment(body) {
6764
6813
  const sourceLines = body.split("\n");
6765
- const statsRange = generatedReviewStatsRange(sourceLines);
6766
- const lines = sourceLines.filter((line, index) => {
6767
- return !(statsRange && index >= statsRange.start && index <= statsRange.end) && !line.startsWith("<!-- pipr:main-comment ") && !mainCommentAttributionPattern.test(line);
6814
+ const envelope = parseGeneratedMainCommentEnvelope(sourceLines);
6815
+ const lines = sourceLines.filter((_line, index) => {
6816
+ return !(envelope.statsRange && index >= envelope.statsRange.start && index <= envelope.statsRange.end) && index !== envelope.mainMarkerIndex && index !== envelope.headerMarkerIndex && index !== envelope.statsMarkerIndex && index !== envelope.footerIndex;
6768
6817
  });
6769
6818
  while (lines[0] === "") lines.shift();
6770
- if (lines[0] && mainCommentTitles.has(lines[0])) lines.shift();
6819
+ if (envelope.headerMarkerIndex < 0 && lines[0] && mainCommentTitles.has(lines[0])) lines.shift();
6771
6820
  while (lines[0] === "") lines.shift();
6772
6821
  return lines.join("\n").trim();
6773
6822
  }
6774
- function generatedReviewStatsRange(lines) {
6775
- const attributionIndex = lines.findLastIndex((line) => mainCommentAttributionPattern.test(line));
6776
- if (attributionIndex < 0) return;
6777
- const end = lines.slice(0, attributionIndex).findLastIndex((line) => line !== "");
6823
+ function parseGeneratedMainCommentEnvelope(lines) {
6824
+ const mainMarkerIndex = lines.findIndex((line) => line.startsWith("<!-- pipr:main-comment "));
6825
+ const headerCandidateOffset = lines.slice(mainMarkerIndex + 1).findIndex((line) => line !== "");
6826
+ const headerCandidateIndex = mainMarkerIndex + 1 + headerCandidateOffset;
6827
+ const headerMarkerIndex = mainMarkerIndex >= 0 && headerCandidateOffset >= 0 && lines[headerCandidateIndex] === "<!-- pipr:header:hidden -->" ? headerCandidateIndex : -1;
6828
+ const lastLineIndex = lines.findLastIndex((line) => line !== "");
6829
+ const lastLine = lines[lastLineIndex] ?? "";
6830
+ const footerIndex = lastLine === "<!-- pipr:footer:hidden -->" || mainCommentAttributionPattern.test(lastLine) ? lastLineIndex : -1;
6831
+ const lastContentIndex = lines.slice(0, footerIndex < 0 ? lines.length : footerIndex).findLastIndex((line) => line !== "");
6832
+ return {
6833
+ mainMarkerIndex,
6834
+ headerMarkerIndex,
6835
+ statsMarkerIndex: lines[lastContentIndex] === "<!-- pipr:stats:hidden -->" ? lastContentIndex : -1,
6836
+ statsRange: generatedReviewStatsRange(lines, footerIndex),
6837
+ footerIndex
6838
+ };
6839
+ }
6840
+ function generatedReviewStatsRange(lines, generatedFooterIndex) {
6841
+ const end = lines.slice(0, generatedFooterIndex < 0 ? lines.length : generatedFooterIndex).findLastIndex((line) => line !== "");
6778
6842
  if (end < 0) return;
6779
6843
  if (lines[end] !== "<!-- pipr:stats:end -->") return;
6780
6844
  if (lines[end - 1] !== "</details>") return;
@@ -6970,6 +7034,9 @@ async function runTaskRuntime(options) {
6970
7034
  validated,
6971
7035
  manifest: diffManifest,
6972
7036
  maxInlineComments: config.publication.maxInlineComments,
7037
+ showHeader: config.publication.showHeader,
7038
+ showFooter: config.publication.showFooter,
7039
+ showStats: config.publication.showStats,
6973
7040
  priorReviewState: verifier.priorReviewState,
6974
7041
  threadActions: verifier.threadActions,
6975
7042
  metadata: {
@@ -7166,6 +7233,9 @@ function skippedTaskRuntimeResult(options) {
7166
7233
  validated,
7167
7234
  manifest: options.diffManifest,
7168
7235
  maxInlineComments: options.config.publication.maxInlineComments,
7236
+ showHeader: options.config.publication.showHeader,
7237
+ showFooter: options.config.publication.showFooter,
7238
+ showStats: options.config.publication.showStats,
7169
7239
  metadata: {
7170
7240
  runtimeVersion,
7171
7241
  configVersion: options.versionCompatibility?.configVersion,
@@ -9429,4 +9499,4 @@ async function runActionCommandWithDependencies(options) {
9429
9499
  //#endregion
9430
9500
  export { runInspectCommand as a, PublicationError as c, supportedOfficialInitRecipes as d, piBuiltinToolNames as f, piThinkingLevels as h, runInitCommand as i, supportedOfficialInitAdapters as l, piRequiredCliFlags as m, runActionCommandWithDependencies as n, runLocalReviewCommand as o, piReadOnlyToolNames as p, runDryRunCommand as r, runValidateCommand as s, runActionCommand as t, listOfficialInitRecipes as u };
9431
9501
 
9432
- //# sourceMappingURL=commands-DM63Wmy0.mjs.map
9502
+ //# sourceMappingURL=commands-RY37Y0rG.mjs.map