@jphutchins/code-review 0.1.0-alpha.36-rc.0 → 0.1.0-alpha.36

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
@@ -773,8 +773,7 @@ var DEFAULT_RESERVE = {
773
773
  frac: 0.15,
774
774
  growth: 0.25,
775
775
  flatUsd: 0.02,
776
- flatMs: 12e4,
777
- flatMem: 2 * 1024 * 1024 * 1024
776
+ flatMs: 12e4
778
777
  };
779
778
  var SOFT_MULTIPLE = 2;
780
779
  var growingReserve = (used, limit, flat, r) => {
@@ -801,7 +800,6 @@ var decideBudget = (i) => {
801
800
  const worst = [costAxis(i), timeAxis(i)].filter((a) => a !== null).reduce((max, a) => Math.max(max, axisSeverity(a)), 0);
802
801
  return worst === 2 ? { kind: "hard" } : worst === 1 ? { kind: "soft" } : { kind: "ok" };
803
802
  };
804
- var memoryCritical = (availMemBytes, totalMemBytes, floorBytes) => availMemBytes !== null && totalMemBytes !== null && totalMemBytes > 0 && availMemBytes <= floorBytes;
805
803
  var pct = (n) => `${String(Math.round(n * 100))}%`;
806
804
  var money = (n) => `$${n.toFixed(2)}`;
807
805
  var mins = (ms) => `${(ms / 6e4).toFixed(1)}m`;
@@ -856,7 +854,6 @@ var lastValidPath = (draftPath) => {
856
854
  };
857
855
  var mainHasWrittenDraft = (draftMtimeMs, seedMarkerMtimeMs) => draftMtimeMs !== null && (seedMarkerMtimeMs === null || draftMtimeMs > seedMarkerMtimeMs);
858
856
  var spawnFloorMessage = (draftPath) => `Write your own first-pass findings to ${draftPath} before spawning subagents \u2014 a review must never depend on subagents alone, and a pre-seeded draft does not count until you have revised it yourself this run. Write ${draftPath} from what you have read so far (preliminary findings are fine), run \`code-review validate ${draftPath} --explain\` until it passes, then fan out; your subagents run in the background, so keep refining the draft as their reports arrive.`;
859
- var memoryPressureMessage = (draftPath) => `System memory is critically low right now, so another subagent can't be spawned \u2014 a fresh process is the fastest way to tip the runner into an out-of-memory kill that would lose the whole review. Don't wind down: keep reading code directly and keep folding the reports from subagents already running into ${draftPath}, then try spawning again in a moment \u2014 this clears as soon as running subagents finish and free their memory.`;
860
857
  var forceBackgroundSpawn = (toolInput) => ({
861
858
  hookSpecificOutput: {
862
859
  hookEventName: "PreToolUse",
@@ -902,8 +899,6 @@ var evaluateBudgetHook = (input, params) => {
902
899
  if (phase.kind === "hard" && blockedDuringConvergence(toolName, rec["tool_input"]))
903
900
  return denyPreTool(budgetMessage(inputs, phase, params.draftPath, isSubagent));
904
901
  if (SPAWN_TOOLS.has(toolName)) {
905
- if (memoryCritical(params.availMemBytes, params.totalMemBytes, params.reserve.flatMem))
906
- return denyPreTool(memoryPressureMessage(params.draftPath));
907
902
  if (!isSubagent && !params.mainDraftWritten)
908
903
  return denyPreTool(spawnFloorMessage(params.draftPath));
909
904
  return forceBackgroundSpawn(rec["tool_input"]);
@@ -950,21 +945,6 @@ var parseFraction = (raw, fallback) => {
950
945
  const n = Number.parseFloat(raw);
951
946
  return Number.isFinite(n) && n >= 0 && n <= 1 ? n : fallback;
952
947
  };
953
- var BYTE_UNIT = {
954
- "": 1,
955
- k: 1024,
956
- m: 1024 * 1024,
957
- g: 1024 * 1024 * 1024,
958
- t: 1024 * 1024 * 1024 * 1024
959
- };
960
- var parseByteSize = (raw) => {
961
- const m = /^(\d+(?:\.\d+)?)\s*([kmgt])?(?:i?b)?$/i.exec(raw.trim());
962
- if (m === null) return null;
963
- const [, num = "", unit = ""] = m;
964
- const n = Number.parseFloat(num);
965
- const mult = BYTE_UNIT[unit.toLowerCase()];
966
- return Number.isFinite(n) && mult !== void 0 ? n * mult : null;
967
- };
968
948
  var budgetHookCommand = (draftPath, opts) => [
969
949
  "code-review budget-hook --draft",
970
950
  shellQuote(draftPath),
@@ -974,8 +954,7 @@ var budgetHookCommand = (draftPath, opts) => [
974
954
  ...opts.reserveFrac ? ["--reserve-frac", shellQuote(opts.reserveFrac)] : [],
975
955
  ...opts.reserveGrowth ? ["--reserve-growth", shellQuote(opts.reserveGrowth)] : [],
976
956
  ...opts.reserveUsd ? ["--reserve-usd", shellQuote(opts.reserveUsd)] : [],
977
- ...opts.reserveWall ? ["--reserve-wall", shellQuote(opts.reserveWall)] : [],
978
- ...opts.reserveMem ? ["--reserve-mem", shellQuote(opts.reserveMem)] : []
957
+ ...opts.reserveWall ? ["--reserve-wall", shellQuote(opts.reserveWall)] : []
979
958
  ].join(" ");
980
959
 
981
960
  // src/format.ts
@@ -3058,18 +3037,6 @@ var snapshotIfValid = (draftPath) => {
3058
3037
  );
3059
3038
  }
3060
3039
  };
3061
- var readMemInfo = () => {
3062
- try {
3063
- const text = readFileSync("/proc/meminfo", "utf8");
3064
- const kb = (key2) => {
3065
- const m = new RegExp(`^${key2}:\\s+(\\d+)\\s+kB`, "m").exec(text);
3066
- return m?.[1] !== void 0 ? Number(m[1]) * 1024 : null;
3067
- };
3068
- return { availBytes: kb("MemAvailable"), totalBytes: kb("MemTotal") };
3069
- } catch {
3070
- return { availBytes: null, totalBytes: null };
3071
- }
3072
- };
3073
3040
  var budgetHookCmd = defineCommand({
3074
3041
  meta: {
3075
3042
  name: "budget-hook",
@@ -3108,17 +3075,12 @@ var budgetHookCmd = defineCommand({
3108
3075
  "reserve-wall": {
3109
3076
  type: "string",
3110
3077
  description: "Flat wall-clock wind-down floor (e.g. 2m, 120s), whichever is larger with --reserve-frac (default: 2m)"
3111
- },
3112
- "reserve-mem": {
3113
- type: "string",
3114
- description: "Free-RAM floor (e.g. 2g, 1536m) below which new subagent spawns are denied until memory recovers; not a convergence axis (default: 2g)"
3115
3078
  }
3116
3079
  },
3117
3080
  run: async ({ args }) => {
3118
3081
  try {
3119
3082
  const draftPath = resolve$1(args.draft);
3120
3083
  const input = readStdinJSON();
3121
- const mem = readMemInfo();
3122
3084
  const transcriptPath = transcriptPathOf(input);
3123
3085
  const tree = transcriptPath ? readTranscriptTree(resolve$1(transcriptPath)) : void 0;
3124
3086
  const usage = tree ? sumTranscriptUsage(tree.entries) : void 0;
@@ -3135,14 +3097,11 @@ var budgetHookCmd = defineCommand({
3135
3097
  nowMs: Date.now()
3136
3098
  }),
3137
3099
  wallMs,
3138
- availMemBytes: mem.availBytes,
3139
- totalMemBytes: mem.totalBytes,
3140
3100
  reserve: {
3141
3101
  frac: parseFraction(args["reserve-frac"], DEFAULT_RESERVE.frac),
3142
3102
  growth: parseFraction(args["reserve-growth"], DEFAULT_RESERVE.growth),
3143
3103
  flatUsd: parseBudgetUsd(args["reserve-usd"]) ?? DEFAULT_RESERVE.flatUsd,
3144
- flatMs: args["reserve-wall"] ? parseWallMs(args["reserve-wall"]) ?? DEFAULT_RESERVE.flatMs : DEFAULT_RESERVE.flatMs,
3145
- flatMem: args["reserve-mem"] ? parseByteSize(args["reserve-mem"]) ?? DEFAULT_RESERVE.flatMem : DEFAULT_RESERVE.flatMem
3104
+ flatMs: args["reserve-wall"] ? parseWallMs(args["reserve-wall"]) ?? DEFAULT_RESERVE.flatMs : DEFAULT_RESERVE.flatMs
3146
3105
  },
3147
3106
  draftPath,
3148
3107
  mainDraftWritten: mainHasWrittenDraft(
@@ -3219,10 +3178,6 @@ var printSettingsCmd = defineCommand({
3219
3178
  "reserve-wall": {
3220
3179
  type: "string",
3221
3180
  description: "Flat wall-clock wind-down floor (e.g. 2m), whichever is larger with --reserve-frac (default: 2m)"
3222
- },
3223
- "reserve-mem": {
3224
- type: "string",
3225
- description: "Free-RAM floor (e.g. 2g) below which new subagent spawns are denied until memory recovers (default: 2g)"
3226
3181
  }
3227
3182
  },
3228
3183
  run: async ({ args }) => {
@@ -3244,8 +3199,7 @@ var printSettingsCmd = defineCommand({
3244
3199
  reserveFrac: args["reserve-frac"],
3245
3200
  reserveGrowth: args["reserve-growth"],
3246
3201
  reserveUsd: args["reserve-usd"],
3247
- reserveWall: args["reserve-wall"],
3248
- reserveMem: args["reserve-mem"]
3202
+ reserveWall: args["reserve-wall"]
3249
3203
  }
3250
3204
  });
3251
3205
  process.stdout.write(`${JSON.stringify(settings)}