codemem 0.31.1 → 0.31.3
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 +14 -4
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -2404,6 +2404,9 @@ function buildCoordinatorCommand() {
|
|
|
2404
2404
|
var coordinatorCommand = buildCoordinatorCommand();
|
|
2405
2405
|
//#endregion
|
|
2406
2406
|
//#region src/commands/db.ts
|
|
2407
|
+
function escapeSqlLikePattern(value) {
|
|
2408
|
+
return value.replaceAll("\\", "\\\\").replaceAll("%", "\\%").replaceAll("_", "\\_");
|
|
2409
|
+
}
|
|
2407
2410
|
function formatBytes(bytes) {
|
|
2408
2411
|
if (bytes < 1024) return `${bytes} B`;
|
|
2409
2412
|
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
@@ -2565,7 +2568,7 @@ renameProjectCmd.action((oldName, newName, opts) => {
|
|
|
2565
2568
|
const store = new MemoryStore(resolveDbPath(resolveDbOpt(opts)));
|
|
2566
2569
|
try {
|
|
2567
2570
|
const dryRun = !opts.apply;
|
|
2568
|
-
const suffixPattern = `%/${oldName
|
|
2571
|
+
const suffixPattern = `%/${escapeSqlLikePattern(oldName)}`;
|
|
2569
2572
|
const tables = ["sessions", "raw_event_sessions"];
|
|
2570
2573
|
const counts = {};
|
|
2571
2574
|
const run = () => {
|
|
@@ -3475,7 +3478,7 @@ function collectWorkingSetFile(value, previous) {
|
|
|
3475
3478
|
return [...previous, value];
|
|
3476
3479
|
}
|
|
3477
3480
|
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)");
|
|
3481
|
+
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
3482
|
}
|
|
3480
3483
|
function buildPackRequestOptions(opts, ctx = {}) {
|
|
3481
3484
|
const limit = parsePositiveInt(opts.limit ?? "10", "limit");
|
|
@@ -3491,9 +3494,11 @@ function buildPackRequestOptions(opts, ctx = {}) {
|
|
|
3491
3494
|
}
|
|
3492
3495
|
if ((opts.workingSetFile?.length ?? 0) > 0) filters.working_set_paths = opts.workingSetFile;
|
|
3493
3496
|
let renderOptions;
|
|
3494
|
-
if (opts.compact || opts.compactDetail != null) {
|
|
3495
|
-
renderOptions = {
|
|
3497
|
+
if (opts.compact || opts.compactDetail != null || opts.compressionMode != null) {
|
|
3498
|
+
renderOptions = {};
|
|
3499
|
+
if (opts.compact || opts.compactDetail != null) renderOptions.compact = true;
|
|
3496
3500
|
if (opts.compactDetail != null) renderOptions.compactDetailCount = parseNonNegativeInt(opts.compactDetail, "compact detail count");
|
|
3501
|
+
if (opts.compressionMode != null) renderOptions.compressionMode = parseCompressionMode(opts.compressionMode);
|
|
3497
3502
|
}
|
|
3498
3503
|
return {
|
|
3499
3504
|
limit,
|
|
@@ -3502,6 +3507,11 @@ function buildPackRequestOptions(opts, ctx = {}) {
|
|
|
3502
3507
|
renderOptions
|
|
3503
3508
|
};
|
|
3504
3509
|
}
|
|
3510
|
+
function parseCompressionMode(value) {
|
|
3511
|
+
const normalized = value.trim().toLowerCase();
|
|
3512
|
+
if (normalized === "off" || normalized === "compact" || normalized === "ids") return normalized;
|
|
3513
|
+
throw new PackUsageError("compression mode must be one of: off, compact, ids");
|
|
3514
|
+
}
|
|
3505
3515
|
function parsePositiveInt(value, label) {
|
|
3506
3516
|
if (!/^\d+$/.test(value.trim())) throw new PackUsageError(`${label} must be a positive integer`);
|
|
3507
3517
|
const parsed = Number.parseInt(value, 10);
|