@staff0rd/assist 0.679.0 → 0.680.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.js CHANGED
@@ -6,7 +6,7 @@ import { Command } from "commander";
6
6
  // package.json
7
7
  var package_default = {
8
8
  name: "@staff0rd/assist",
9
- version: "0.679.0",
9
+ version: "0.680.0",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -30724,6 +30724,66 @@ function buildHighLevelStructure(files) {
30724
30724
  };
30725
30725
  }
30726
30726
 
30727
+ // src/commands/review/highLevel/capHighLevelPatches.ts
30728
+ import { minimatch as minimatch7 } from "minimatch";
30729
+
30730
+ // src/commands/review/highLevel/capPatchToBudget.ts
30731
+ function hunksOf(patch2) {
30732
+ const hunks = [];
30733
+ for (const line of patch2.split("\n")) {
30734
+ const last = hunks[hunks.length - 1];
30735
+ if (line.startsWith("@@") || last === void 0) hunks.push(line);
30736
+ else hunks[hunks.length - 1] = `${last}
30737
+ ${line}`;
30738
+ }
30739
+ return hunks;
30740
+ }
30741
+ function capPatchToBudget(patch2, budget) {
30742
+ const kept = [];
30743
+ let lines2 = 0;
30744
+ for (const hunk of hunksOf(patch2)) {
30745
+ const size = hunk.split("\n").length;
30746
+ if (lines2 + size > budget)
30747
+ return {
30748
+ ...kept.length > 0 ? { patch: kept.join("\n") } : {},
30749
+ truncated: true
30750
+ };
30751
+ kept.push(hunk);
30752
+ lines2 += size;
30753
+ }
30754
+ return { patch: patch2, truncated: false };
30755
+ }
30756
+
30757
+ // src/commands/review/highLevel/capHighLevelPatches.ts
30758
+ var MAX_FILE_PATCH_LINES = 1500;
30759
+ var MAX_TOTAL_PATCH_LINES = 2e4;
30760
+ function criticalFirst(files, criticalPaths) {
30761
+ const isCritical = (file) => criticalPaths.some((glob) => minimatch7(file.path, glob));
30762
+ return [...files].sort(
30763
+ (a, b) => Number(isCritical(b)) - Number(isCritical(a))
30764
+ );
30765
+ }
30766
+ function capped(file, budget) {
30767
+ if (file.patch === void 0) return file;
30768
+ const { patch: patch2, truncated } = capPatchToBudget(file.patch, budget);
30769
+ const { patch: _dropped, ...rest } = file;
30770
+ return {
30771
+ ...rest,
30772
+ ...patch2 === void 0 ? {} : { patch: patch2 },
30773
+ ...truncated ? { truncated: true } : {}
30774
+ };
30775
+ }
30776
+ function capHighLevelPatches(files, criticalPaths) {
30777
+ let remaining = MAX_TOTAL_PATCH_LINES;
30778
+ const byPath = /* @__PURE__ */ new Map();
30779
+ for (const file of criticalFirst(files, criticalPaths)) {
30780
+ const result = capped(file, Math.min(MAX_FILE_PATCH_LINES, remaining));
30781
+ remaining -= result.patch?.split("\n").length ?? 0;
30782
+ byPath.set(file.path, result);
30783
+ }
30784
+ return files.map((file) => byPath.get(file.path) ?? file);
30785
+ }
30786
+
30727
30787
  // src/commands/review/highLevel/checkDescriptionLinksIssue.ts
30728
30788
  var ISSUE_URL_PATTERN = /https?:\/\/github\.com\/[\w.-]+\/[\w.-]+\/issues\/\d+/g;
30729
30789
  var CROSS_REPO_PATTERN = /\b[\w.-]+\/[\w.-]+#\d+/g;
@@ -30781,7 +30841,7 @@ function checkDescriptionWordCap(body, cap2) {
30781
30841
  }
30782
30842
 
30783
30843
  // src/commands/review/highLevel/checkUiEvidence.ts
30784
- import { minimatch as minimatch7 } from "minimatch";
30844
+ import { minimatch as minimatch8 } from "minimatch";
30785
30845
  var EVIDENCE_PATTERNS = [
30786
30846
  /!\[[^\]]*\]\([^)]+\)/g,
30787
30847
  /<(?:img|video)\b[^>]*>/gi,
@@ -30804,7 +30864,7 @@ function checkUiEvidence(body, changedFiles2, uiPaths) {
30804
30864
  reason: "review.highLevel.uiPaths is unset, so no UI evidence is required"
30805
30865
  };
30806
30866
  const touched = changedFiles2.filter(
30807
- (file) => uiPaths.some((glob) => minimatch7(file, glob))
30867
+ (file) => uiPaths.some((glob) => minimatch8(file, glob))
30808
30868
  );
30809
30869
  if (touched.length === 0)
30810
30870
  return {
@@ -30971,17 +31031,20 @@ function resolveHighLevelConfig(config) {
30971
31031
  }
30972
31032
 
30973
31033
  // src/commands/review/highLevel/selectCriticalDiffs.ts
30974
- import { minimatch as minimatch8 } from "minimatch";
31034
+ import { minimatch as minimatch9 } from "minimatch";
30975
31035
  function selectCriticalDiffs(files, criticalPaths) {
30976
31036
  if (criticalPaths.length === 0) return [];
30977
- return files.filter((file) => criticalPaths.some((glob) => minimatch8(file.path, glob))).map(({ path: path91, status: status3, additions, deletions, diffUrl: diffUrl2, patch: patch2 }) => ({
30978
- path: path91,
30979
- status: status3,
30980
- additions,
30981
- deletions,
30982
- diffUrl: diffUrl2,
30983
- patch: patch2 ?? null
30984
- }));
31037
+ return files.filter((file) => criticalPaths.some((glob) => minimatch9(file.path, glob))).map(
31038
+ ({ path: path91, status: status3, additions, deletions, diffUrl: diffUrl2, patch: patch2, truncated }) => ({
31039
+ path: path91,
31040
+ status: status3,
31041
+ additions,
31042
+ deletions,
31043
+ diffUrl: diffUrl2,
31044
+ patch: patch2 ?? null,
31045
+ ...truncated ? { truncated: true } : {}
31046
+ })
31047
+ );
30985
31048
  }
30986
31049
 
30987
31050
  // src/commands/review/highLevel/gatherHighLevelSubject.ts
@@ -30989,8 +31052,11 @@ function gatherHighLevelSubject(prNumber, force) {
30989
31052
  const { org, repo } = getRepoInfo();
30990
31053
  const slug2 = `${org}/${repo}`;
30991
31054
  const pr = fetchHighLevelPr(prNumber, { org, repo });
30992
- const files = fetchHighLevelFiles(prNumber, slug2);
30993
31055
  const config = resolveHighLevelConfig(loadConfig());
31056
+ const files = capHighLevelPatches(
31057
+ fetchHighLevelFiles(prNumber, slug2),
31058
+ config.criticalPaths
31059
+ );
30994
31060
  const saved = force ? void 0 : loadHighLevelReview(slug2, pr.headRef, pr.headSha);
30995
31061
  return {
30996
31062
  repo: slug2,
@@ -31044,6 +31110,42 @@ function highLevelChangedFileCount(structure) {
31044
31110
  return structure.added + structure.removed + structure.modified;
31045
31111
  }
31046
31112
 
31113
+ // src/commands/review/highLevel/highLevelPreviewMetadata.ts
31114
+ function highLevelPreviewMetadata(subject) {
31115
+ return [
31116
+ { label: "Branch", value: subject.headRef },
31117
+ { label: "Head", value: subject.headSha.slice(0, 7) },
31118
+ {
31119
+ label: "Changed files",
31120
+ value: String(highLevelChangedFileCount(subject.structure))
31121
+ },
31122
+ { label: "Critical files", value: String(subject.criticalDiffs.length) },
31123
+ ...subject.saved ? [{ label: "Reopened from", value: subject.saved.reviewedAt }] : []
31124
+ ];
31125
+ }
31126
+
31127
+ // src/commands/review/highLevel/highLevelPreviewPayload.ts
31128
+ function highLevelPreviewPayload(subject) {
31129
+ const {
31130
+ repo,
31131
+ prNumber,
31132
+ checks: checks2,
31133
+ structure,
31134
+ criticalDiffs,
31135
+ criticalPaths,
31136
+ saved
31137
+ } = subject;
31138
+ return {
31139
+ repo,
31140
+ prNumber,
31141
+ checks: checks2,
31142
+ structure,
31143
+ criticalDiffs,
31144
+ criticalPaths,
31145
+ ...saved ? { saved } : {}
31146
+ };
31147
+ }
31148
+
31047
31149
  // src/commands/review/highLevel/saveHighLevelReview.ts
31048
31150
  import { mkdirSync as mkdirSync21, writeFileSync as writeFileSync38 } from "fs";
31049
31151
  import { dirname as dirname34 } from "path";
@@ -31056,28 +31158,6 @@ function saveHighLevelReview(record) {
31056
31158
  }
31057
31159
 
31058
31160
  // src/commands/review/highLevel/openHighLevelOverlay.ts
31059
- function payloadOf(subject) {
31060
- const { checks: checks2, structure, criticalDiffs, criticalPaths, saved } = subject;
31061
- return {
31062
- checks: checks2,
31063
- structure,
31064
- criticalDiffs,
31065
- criticalPaths,
31066
- ...saved ? { saved } : {}
31067
- };
31068
- }
31069
- function metadataOf(subject) {
31070
- return [
31071
- { label: "Branch", value: subject.headRef },
31072
- { label: "Head", value: subject.headSha.slice(0, 7) },
31073
- {
31074
- label: "Changed files",
31075
- value: String(highLevelChangedFileCount(subject.structure))
31076
- },
31077
- { label: "Critical files", value: String(subject.criticalDiffs.length) },
31078
- ...subject.saved ? [{ label: "Reopened from", value: subject.saved.reviewedAt }] : []
31079
- ];
31080
- }
31081
31161
  async function openHighLevelOverlay(sessionId, subject) {
31082
31162
  const decision = await awaitPreviewApproval(
31083
31163
  "High-level review",
@@ -31085,10 +31165,10 @@ async function openHighLevelOverlay(sessionId, subject) {
31085
31165
  sessionId,
31086
31166
  requestId: randomUUID17(),
31087
31167
  title: `High-level review of ${subject.repo}#${subject.prNumber}`,
31088
- body: JSON.stringify(payloadOf(subject)),
31168
+ body: JSON.stringify(highLevelPreviewPayload(subject)),
31089
31169
  prNumber: subject.prNumber,
31090
31170
  kind: "high-level-review",
31091
- metadata: metadataOf(subject)
31171
+ metadata: highLevelPreviewMetadata(subject)
31092
31172
  },
31093
31173
  { rejectIsOutcome: true }
31094
31174
  );
@@ -40581,7 +40661,7 @@ async function changedFiles(path91) {
40581
40661
  const lines2 = status3.ok ? nonEmptyLines(status3.out) : [];
40582
40662
  return {
40583
40663
  summary: `${lines2.length} uncommitted ${lines2.length === 1 ? "file" : "files"}`,
40584
- items: capped(lines2)
40664
+ items: capped2(lines2)
40585
40665
  };
40586
40666
  }
40587
40667
  async function unpushedCommits(path91, reason4) {
@@ -40590,13 +40670,13 @@ async function unpushedCommits(path91, reason4) {
40590
40670
  const lines2 = nonEmptyLines(log2.out);
40591
40671
  return {
40592
40672
  summary: `${lines2.length} unpushed ${lines2.length === 1 ? "commit" : "commits"}`,
40593
- items: capped(lines2)
40673
+ items: capped2(lines2)
40594
40674
  };
40595
40675
  }
40596
40676
  function nonEmptyLines(out) {
40597
40677
  return out.split("\n").map((line) => line.trim()).filter((line) => line !== "");
40598
40678
  }
40599
- function capped(lines2) {
40679
+ function capped2(lines2) {
40600
40680
  if (lines2.length <= MAX_ITEMS) return lines2;
40601
40681
  return [
40602
40682
  ...lines2.slice(0, MAX_ITEMS),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.679.0",
3
+ "version": "0.680.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {