From 05354f6143345633e2512d6ddfa218cb2dee3813 Mon Sep 17 00:00:00 2001 From: Yurii Bakurov <45154988+Yurii201811@users.noreply.github.com> Date: Wed, 23 Sep 2026 08:17:25 +0200 Subject: [PATCH 1/2] fix: classify loose snapshots as generated output --- CHANGELOG.md | 7 +++++++ README.md | 2 ++ package-lock.json | 12 ++---------- package.json | 2 +- src/classify.js | 1 + test/loose-snapshots.test.js | 32 ++++++++++++++++++++++++++++++++ 6 files changed, 45 insertions(+), 11 deletions(-) create mode 100644 test/loose-snapshots.test.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 966d236..e870310 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,13 @@ All notable changes to this project are documented here, following [Keep a Changelog](https://keepachangelog.com/) and semantic versioning. +## [0.1.17] - 2026-09-23 + +### Fixed + +- Classify loose `.snap` files as generated trim candidates, alongside existing snapshot-directory handling. +- Repair unresolved merge markers in the package lockfile while updating release metadata. + ## [0.1.16] - 2026-09-17 ### Fixed diff --git a/README.md b/README.md index 89e3050..9ebdf2b 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,8 @@ ctxtrim · my-repo · 412 files ✓ .cursorignore (created, 34 patterns), .aiexclude (created, 34 patterns) ``` +Loose `.snap` files are treated as generated output and suggested for trimming, just like files inside `__snapshots__/` directories. + Estimates use the widely-cited ~4-chars-per-token rule (great for ranking and relative savings; pass `--price` to match your model). Vendored dependency and build output directories (`node_modules`, `dist`, `build`, ...) are reported as a single entry keyed by directory name — sized from a cheap stat walk without reading the files inside. Directory-level categories are decided by the directory name, not by reading its contents. diff --git a/package-lock.json b/package-lock.json index 20a1a7d..4f11004 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,20 +1,12 @@ { "name": "ctxtrim", -<<<<<<< HEAD - "version": "0.1.16", -======= - "version": "0.1.15", ->>>>>>> origin/main + "version": "0.1.17", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "ctxtrim", -<<<<<<< HEAD - "version": "0.1.16", -======= - "version": "0.1.15", ->>>>>>> origin/main + "version": "0.1.17", "license": "MIT", "bin": { "ctxtrim": "bin/ctxtrim.js" diff --git a/package.json b/package.json index 8f855ca..726111b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ctxtrim", - "version": "0.1.16", + "version": "0.1.17", "description": "Trim what bloats your AI coding context. Scan a repo, find the high-cost/low-value files ballooning your Claude Code / Cursor / Codex context, and write ignore files to cut token cost. Zero dependencies.", "type": "module", "bin": { diff --git a/src/classify.js b/src/classify.js index 8a1bc2b..5cdca2d 100644 --- a/src/classify.js +++ b/src/classify.js @@ -51,6 +51,7 @@ export function classifyPath(rel) { if (parts.some((p) => VENDOR_DIRS.includes(p))) return { category: "vendored", trim: true, binary: false, reason: "vendored dependency directory" }; if (parts.some((p) => BUILD_DIRS.includes(p))) return { category: "build", trim: true, binary: false, reason: "build / generated output directory" }; if (LOCKFILES.has(name)) return { category: "lockfile", trim: true, binary: false, reason: "dependency lockfile" }; + if (ext === ".snap") return { category: "generated", trim: true, binary: false, reason: "generated snapshot" }; if (MINIFIED.test(name)) return { category: "minified", trim: true, binary: false, reason: "minified / bundled / sourcemap" }; if (DATA_EXT.has(ext)) return { category: "data", trim: true, binary: false, reason: "data file" }; return null; diff --git a/test/loose-snapshots.test.js b/test/loose-snapshots.test.js new file mode 100644 index 0000000..266120a --- /dev/null +++ b/test/loose-snapshots.test.js @@ -0,0 +1,32 @@ +import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { classify } from "../src/classify.js"; +import { scanRepo } from "../src/scan.js"; + +test("loose snapshot files are generated trim candidates", () => { + for (const name of ["a.snap", "nested/result.SNAP"]) { + const result = classify(name, { tokens: 10, sample: "expected output" }); + assert.equal(result.category, "generated", name); + assert.equal(result.trim, true, name); + assert.equal(result.binary, false, name); + } + assert.equal(classify("test/__snapshots__/a.snap", {}).category, "build"); + assert.equal(classify("src/snapshot.js", { tokens: 10 }).trim, false); +}); + +test("scan includes loose snapshots in token totals and ignore patterns", (t) => { + const root = mkdtempSync(join(tmpdir(), "ctxtrim-loose-snap-")); + t.after(() => rmSync(root, { recursive: true, force: true })); + mkdirSync(join(root, "test")); + writeFileSync(join(root, "test", "result.snap"), "expected output\n".repeat(20)); + writeFileSync(join(root, "source.js"), "export const value = 1;\n"); + const result = scanRepo(root); + const snapshot = result.files.find((file) => file.rel === "test/result.snap"); + assert.equal(snapshot.category, "generated"); + assert.ok(snapshot.tokens > 0); + assert.equal(result.totals.trimTokens, snapshot.tokens); + assert.deepEqual(result.patterns, ["test/result.snap"]); +}); From 39ff0a6cee9b84389ff63972d273939d393b2ce4 Mon Sep 17 00:00:00 2001 From: royalpinto007 Date: Wed, 23 Sep 2026 17:37:03 +0530 Subject: [PATCH 2/2] resolve merge: keep 0.1.19 version --- package-lock.json | 8 -------- package.json | 4 ---- 2 files changed, 12 deletions(-) diff --git a/package-lock.json b/package-lock.json index 80f9faf..125adc3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,20 +1,12 @@ { "name": "ctxtrim", -<<<<<<< HEAD "version": "0.1.19", -======= - "version": "0.1.18", ->>>>>>> origin/main "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "ctxtrim", -<<<<<<< HEAD "version": "0.1.19", -======= - "version": "0.1.18", ->>>>>>> origin/main "license": "MIT", "bin": { "ctxtrim": "bin/ctxtrim.js" diff --git a/package.json b/package.json index 15b80e2..2a851ac 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,6 @@ { "name": "ctxtrim", -<<<<<<< HEAD "version": "0.1.19", -======= - "version": "0.1.18", ->>>>>>> origin/main "description": "Trim what bloats your AI coding context. Scan a repo, find the high-cost/low-value files ballooning your Claude Code / Cursor / Codex context, and write ignore files to cut token cost. Zero dependencies.", "type": "module", "bin": {