codemem 0.31.0 → 0.31.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/index.js CHANGED
@@ -3475,7 +3475,7 @@ function collectWorkingSetFile(value, previous) {
3475
3475
  return [...previous, value];
3476
3476
  }
3477
3477
  function addPackRequestOptions(command) {
3478
- return command.option("-n, --limit <n>", "max items", "10").option("--budget <tokens>", "token budget").option("--token-budget <tokens>", "token budget").option("--working-set-file <path>", "recently modified file path used as ranking hint", collectWorkingSetFile, []).option("--project <project>", "project identifier (defaults to git repo root)").option("--all-projects", "search across all projects").option("--compact", "render a scannable index with full detail only for top N items").option("--compact-detail <n>", "items to show in full detail in compact mode (default 3)");
3478
+ return command.option("-n, --limit <n>", "max items", "10").option("--budget <tokens>", "token budget").option("--token-budget <tokens>", "token budget").option("--working-set-file <path>", "recently modified file path used as ranking hint", collectWorkingSetFile, []).option("--project <project>", "project identifier (defaults to git repo root)").option("--all-projects", "search across all projects").option("--compact", "render a scannable index with full detail only for top N items").option("--compact-detail <n>", "items to show in full detail in compact mode (default 3)").option("--compression-mode <mode>", "near-related compression mode: off, compact, or ids (default: CODEMEM_PACK_COMPRESSION or compact)");
3479
3479
  }
3480
3480
  function buildPackRequestOptions(opts, ctx = {}) {
3481
3481
  const limit = parsePositiveInt(opts.limit ?? "10", "limit");
@@ -3491,9 +3491,11 @@ function buildPackRequestOptions(opts, ctx = {}) {
3491
3491
  }
3492
3492
  if ((opts.workingSetFile?.length ?? 0) > 0) filters.working_set_paths = opts.workingSetFile;
3493
3493
  let renderOptions;
3494
- if (opts.compact || opts.compactDetail != null) {
3495
- renderOptions = { compact: true };
3494
+ if (opts.compact || opts.compactDetail != null || opts.compressionMode != null) {
3495
+ renderOptions = {};
3496
+ if (opts.compact || opts.compactDetail != null) renderOptions.compact = true;
3496
3497
  if (opts.compactDetail != null) renderOptions.compactDetailCount = parseNonNegativeInt(opts.compactDetail, "compact detail count");
3498
+ if (opts.compressionMode != null) renderOptions.compressionMode = parseCompressionMode(opts.compressionMode);
3497
3499
  }
3498
3500
  return {
3499
3501
  limit,
@@ -3502,6 +3504,11 @@ function buildPackRequestOptions(opts, ctx = {}) {
3502
3504
  renderOptions
3503
3505
  };
3504
3506
  }
3507
+ function parseCompressionMode(value) {
3508
+ const normalized = value.trim().toLowerCase();
3509
+ if (normalized === "off" || normalized === "compact" || normalized === "ids") return normalized;
3510
+ throw new PackUsageError("compression mode must be one of: off, compact, ids");
3511
+ }
3505
3512
  function parsePositiveInt(value, label) {
3506
3513
  if (!/^\d+$/.test(value.trim())) throw new PackUsageError(`${label} must be a positive integer`);
3507
3514
  const parsed = Number.parseInt(value, 10);